Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
<script setup lang="ts">
import type { IconPickerProps } from './types';

import { computed, ref, useAttrs, watch, watchEffect } from 'vue';
import {
computed,
onBeforeUpdate,
ref,
useAttrs,
watch,
watchEffect,
} from 'vue';

import { usePagination } from '@vben/hooks';
import { EmptyIcon, Grip, listIcons } from '@vben/icons';
Expand Down Expand Up @@ -100,7 +107,17 @@ const { paginationList, total, setCurrentPage, currentPage } = usePagination(
);

watchEffect(() => {
currentSelect.value = modelValue.value;
currentSelect.value =
props.modelValueProp === 'modelValue'
? modelValue.value
: ((attrs[props.modelValueProp] as string) ?? '');
});

onBeforeUpdate(() => {
if (props.modelValueProp !== 'modelValue') {
currentSelect.value =
(attrs[props.modelValueProp] as string | undefined) ?? '';
}
});

watch(
Expand All @@ -111,8 +128,7 @@ watch(
);

const handleClick = (icon: string) => {
currentSelect.value = icon;
modelValue.value = icon;
updateCurrentSelect(icon);
close();
};

Expand Down Expand Up @@ -156,7 +172,10 @@ function updateCurrentSelect(v: string) {
}
}
const getBindAttrs = computed(() => {
return objectOmit(attrs, [`onUpdate:${props.modelValueProp}`]);
return objectOmit(attrs, [
`onUpdate:${props.modelValueProp}`,
props.modelValueProp,
]);
});

defineExpose({ toggleOpenState, open, close });
Expand Down
Loading