fix: fix IconPicker
props warning (#6108)
Invalid prop: type check failed for prop "onUpdate:value". Expected Function, got Array
This commit is contained in:
parent
f94ca10adf
commit
3b3f8e4e44
@ -1,7 +1,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { VNode } from 'vue';
|
import type { VNode } from 'vue';
|
||||||
|
|
||||||
import { computed, ref, watch, watchEffect } from 'vue';
|
import { computed, ref, useAttrs, watch, watchEffect } from 'vue';
|
||||||
|
|
||||||
import { usePagination } from '@vben/hooks';
|
import { usePagination } from '@vben/hooks';
|
||||||
import { EmptyIcon, Grip, listIcons } from '@vben/icons';
|
import { EmptyIcon, Grip, listIcons } from '@vben/icons';
|
||||||
@ -22,8 +22,9 @@ import {
|
|||||||
VbenIconButton,
|
VbenIconButton,
|
||||||
VbenPopover,
|
VbenPopover,
|
||||||
} from '@vben-core/shadcn-ui';
|
} from '@vben-core/shadcn-ui';
|
||||||
|
import { isFunction } from '@vben-core/shared/utils';
|
||||||
|
|
||||||
import { refDebounced, watchDebounced } from '@vueuse/core';
|
import { objectOmit, refDebounced, watchDebounced } from '@vueuse/core';
|
||||||
|
|
||||||
import { fetchIconsData } from './icons';
|
import { fetchIconsData } from './icons';
|
||||||
|
|
||||||
@ -64,6 +65,8 @@ const emit = defineEmits<{
|
|||||||
change: [string];
|
change: [string];
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
|
const attrs = useAttrs();
|
||||||
|
|
||||||
const modelValue = defineModel({ default: '', type: String });
|
const modelValue = defineModel({ default: '', type: String });
|
||||||
|
|
||||||
const visible = ref(false);
|
const visible = ref(false);
|
||||||
@ -167,7 +170,14 @@ const searchInputProps = computed(() => {
|
|||||||
|
|
||||||
function updateCurrentSelect(v: string) {
|
function updateCurrentSelect(v: string) {
|
||||||
currentSelect.value = v;
|
currentSelect.value = v;
|
||||||
|
const eventKey = `onUpdate:${props.modelValueProp}`;
|
||||||
|
if (attrs[eventKey] && isFunction(attrs[eventKey])) {
|
||||||
|
attrs[eventKey](v);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
const getBindAttrs = computed(() => {
|
||||||
|
return objectOmit(attrs, [`onUpdate:${props.modelValueProp}`]);
|
||||||
|
});
|
||||||
|
|
||||||
defineExpose({ toggleOpenState, open, close });
|
defineExpose({ toggleOpenState, open, close });
|
||||||
</script>
|
</script>
|
||||||
@ -189,7 +199,7 @@ defineExpose({ toggleOpenState, open, close });
|
|||||||
:aria-label="$t('ui.iconPicker.placeholder')"
|
:aria-label="$t('ui.iconPicker.placeholder')"
|
||||||
aria-expanded="visible"
|
aria-expanded="visible"
|
||||||
:[`onUpdate:${modelValueProp}`]="updateCurrentSelect"
|
:[`onUpdate:${modelValueProp}`]="updateCurrentSelect"
|
||||||
v-bind="$attrs"
|
v-bind="getBindAttrs"
|
||||||
>
|
>
|
||||||
<template #[iconSlot]>
|
<template #[iconSlot]>
|
||||||
<VbenIcon
|
<VbenIcon
|
||||||
|
Loading…
Reference in New Issue
Block a user