feat(components): [select-v2] add props attribute #14536
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a replica of #9817. related with #13263. close #11088
after
Please make sure these boxes are checked before submitting your PR, thank you!
dev
branch.Description
🤖 Generated by Copilot at a63f47a
This pull request adds a new feature to the
SelectV2
component that allows users to customize the alias of theoptions
sub-attributes (value
,label
, anddisabled
) using theprops
attribute. It also refactors the select-v2 component and its sub-components to use common utilities and hooks to handle the custom alias and improve the type inference and readability. It updates the documentation and the examples to reflect the new feature. It also simplifies some types and removes some redundant code.Related Issue
Fixes #___.
Explanation of Changes
🤖 Generated by Copilot at a63f47a
props
attribute toSelectV2
component to customize the alias of theoptions
sub-attributes (link, link, link, link)useProps
hook to access theoptions
data using the custom alias in various functions and components (link, link, link, link, link, link, link, link, link, link, link, link, link, link, link, link, link, link, link, link, link, link, link, link, link, link, link, link, link, link, link, link, link)getValueKey
function to generate unique keys for theoptions
using the custom alias of thevalue
attribute (link, link, link, link, link)Option
type to extendRecord<string, any>
and removeOptionCommon
andOptionGroup
types (link, link, link)buildProps
utility to wrap theSelectProps
andOptionProps
objects and improve type inference and readability (link)iconPropType
utility for theclearIcon
prop type (link)definePropType
utility for themodelValue
,options
, andpopperOptions
prop types (link, link, link)useSizeProp
hook for thesize
prop instead of the custom validator (link, link)flattenOptions
function with areduce
method to add a title and a group type for each option group (link)String
constructor instead oftoString
method to avoid potential errors when the value is null or undefined (link, link)getLabel
function fromuseSelect
as it is redundant with theuseProps
hook (link)docs/examples/select-v2/props.vue
file to show an example of using theprops
attribute (link)docs/en-US/component/select-v2.md
file to reflect the changes and add theprops
table (link, link)packages/components/select-v2/src/util.ts
file as it is no longer needed (link)