Skip to content

Commit

Permalink
chore: ApiSelect props name changed
Browse files Browse the repository at this point in the history
  • Loading branch information
mynetfan committed Dec 9, 2024
1 parent 7929a52 commit e8dddfe
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 13 deletions.
4 changes: 2 additions & 2 deletions apps/web-antd/src/adapter/component/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ async function initComponentAdapter() {
component: Select,
loadingSlot: 'suffixIcon',
visibleEvent: 'onDropdownVisibleChange',
modelField: 'value',
modelPropName: 'value',
},
slots,
);
Expand All @@ -103,7 +103,7 @@ async function initComponentAdapter() {
component: TreeSelect,
fieldNames: { label: 'label', value: 'value', children: 'children' },
loadingSlot: 'suffixIcon',
modelField: 'value',
modelPropName: 'value',
optionsPropName: 'treeData',
visibleEvent: 'onVisibleChange',
},
Expand Down
1 change: 0 additions & 1 deletion apps/web-ele/src/adapter/component/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ async function initComponentAdapter() {
props: { label: 'label', children: 'children' },
nodeKey: 'value',
loadingSlot: 'loading',
modelField: 'modelValue',
optionsPropName: 'data',
visibleEvent: 'onVisibleChange',
},
Expand Down
4 changes: 2 additions & 2 deletions apps/web-naive/src/adapter/component/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ async function initComponentAdapter() {
...props,
...attrs,
component: NSelect,
modelField: 'value',
modelPropName: 'value',
},
slots,
);
Expand All @@ -90,7 +90,7 @@ async function initComponentAdapter() {
nodeKey: 'value',
loadingSlot: 'arrow',
keyField: 'value',
modelField: 'value',
modelPropName: 'value',
optionsPropName: 'options',
visibleEvent: 'onVisibleChange',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ interface Props {
/** 触发api请求的事件名 */
visibleEvent?: string;
/** 组件的v-model属性名,默认为modelValue。部分组件可能为value */
modelField?: string;
modelPropName?: string;
}
defineOptions({ name: 'ApiSelect', inheritAttrs: false });
Expand All @@ -69,7 +69,7 @@ const props = withDefaults(defineProps<Props>(), {
loadingSlot: '',
beforeFetch: undefined,
afterFetch: undefined,
modelField: 'modelValue',
modelPropName: 'modelValue',
api: undefined,
options: () => [],
});
Expand All @@ -96,10 +96,10 @@ const getOptions = computed(() => {
return data.map((item) => {
const value = get(item, valueField);
return {
...objectOmit(item, [labelField, valueField]),
...objectOmit(item, [labelField, valueField, childrenField]),
label: get(item, labelField),
value: numberToString ? `${value}` : value,
...(item[childrenField]
...(childrenField && item[childrenField]
? { children: transformData(item[childrenField]) }
: {}),
};
Expand All @@ -113,9 +113,9 @@ const getOptions = computed(() => {
const bindProps = computed(() => {
return {
[props.modelField]: unref(modelValue),
[props.modelPropName]: unref(modelValue),
[props.optionsPropName]: unref(getOptions),
[`onUpdate:${props.modelField}`]: (val: string) => {
[`onUpdate:${props.modelPropName}`]: (val: string) => {
modelValue.value = val;
},
...objectOmit(attrs, ['onUpdate:value']),
Expand Down
4 changes: 2 additions & 2 deletions playground/src/adapter/component/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ async function initComponentAdapter() {
...attrs,
component: Select,
loadingSlot: 'suffixIcon',
modelField: 'value',
modelPropName: 'value',
visibleEvent: 'onVisibleChange',
},
slots,
Expand All @@ -104,7 +104,7 @@ async function initComponentAdapter() {
component: TreeSelect,
fieldNames: { label: 'label', value: 'value', children: 'children' },
loadingSlot: 'suffixIcon',
modelField: 'value',
modelPropName: 'value',
optionsPropName: 'treeData',
visibleEvent: 'onVisibleChange',
},
Expand Down

0 comments on commit e8dddfe

Please sign in to comment.