diff --git a/packages/nc-gui-v2/components/general/ColorPicker.vue b/packages/nc-gui-v2/components/general/ColorPicker.vue index 44300663d8..c319f83299 100644 --- a/packages/nc-gui-v2/components/general/ColorPicker.vue +++ b/packages/nc-gui-v2/components/general/ColorPicker.vue @@ -3,10 +3,11 @@ import { Chrome } from '@ckpack/vue-color' import { enumColor } from '@/utils' interface Props { - modelValue: String - colors?: String[] + modelValue: string | any + colors?: string[] rowSize?: number advanced?: Boolean + pickButton?: Boolean } const props = withDefaults(defineProps(), { @@ -14,14 +15,21 @@ const props = withDefaults(defineProps(), { colors: () => enumColor.light.concat(enumColor.dark), rowSize: () => 10, advanced: () => true, + pickButton: () => false, }) const emit = defineEmits(['update:modelValue']) -const vModel = useVModel(props, 'modelValue', emit) + +const vModel = computed({ + get: () => props.modelValue, + set: (val) => { + emit('update:modelValue', val.hex ? val.hex : val || null) + }, +}) const picked = ref(props.modelValue || enumColor.light[0]) -const select = (color: any) => { +const selectColor = (color: any) => { picked.value = color.hex ? color.hex : color vModel.value = color.hex ? color.hex : color } @@ -32,6 +40,12 @@ const compare = (colorA: String, colorB: String) => { } return false } + +watch(picked, (n, _o) => { + if (!props.pickButton) { + vModel.value = n.hex ? n.hex : n + } +})