Skip to content

Commit bd7f3cb

Browse files
committed
Fix value bindings
1 parent 0dd42a1 commit bd7f3cb

File tree

5 files changed

+80
-15
lines changed

5 files changed

+80
-15
lines changed

src/components/graph/vueWidgets/WidgetColorPicker.vue

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@
55
widget.name
66
}}</label>
77
<ColorPicker
8-
v-model="value"
8+
v-model="localValue"
99
v-bind="filteredProps"
1010
:disabled="readonly"
1111
inline
12+
@update:model-value="onChange"
1213
/>
1314
</div>
1415
</template>
@@ -17,19 +18,31 @@
1718
import ColorPicker from 'primevue/colorpicker'
1819
import { computed } from 'vue'
1920
21+
import { useWidgetValue } from '@/composables/graph/useWidgetValue'
2022
import type { SimplifiedWidget } from '@/types/simplifiedWidget'
2123
import {
2224
PANEL_EXCLUDED_PROPS,
2325
filterWidgetProps
2426
} from '@/utils/widgetPropFilter'
2527
26-
const value = defineModel<string>({ required: true })
27-
2828
const props = defineProps<{
2929
widget: SimplifiedWidget<string>
30+
modelValue: string
3031
readonly?: boolean
3132
}>()
3233
34+
const emit = defineEmits<{
35+
'update:modelValue': [value: string]
36+
}>()
37+
38+
// Use the composable for consistent widget value handling
39+
const { localValue, onChange } = useWidgetValue({
40+
widget: props.widget,
41+
modelValue: props.modelValue,
42+
defaultValue: '#000000',
43+
emit
44+
})
45+
3346
// ColorPicker specific excluded props include panel/overlay classes
3447
const COLOR_PICKER_EXCLUDED_PROPS = [...PANEL_EXCLUDED_PROPS] as const
3548

src/components/graph/vueWidgets/WidgetMultiSelect.vue

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@
44
widget.name
55
}}</label>
66
<MultiSelect
7-
v-model="value"
7+
v-model="localValue"
88
v-bind="filteredProps"
99
:disabled="readonly"
1010
class="flex-grow min-w-[8em] max-w-[20em] text-xs"
1111
size="small"
1212
:pt="{
1313
option: 'text-xs'
1414
}"
15+
@update:model-value="onChange"
1516
/>
1617
</div>
1718
</template>
@@ -20,19 +21,31 @@
2021
import MultiSelect from 'primevue/multiselect'
2122
import { computed } from 'vue'
2223
24+
import { useWidgetValue } from '@/composables/graph/useWidgetValue'
2325
import type { SimplifiedWidget } from '@/types/simplifiedWidget'
2426
import {
2527
PANEL_EXCLUDED_PROPS,
2628
filterWidgetProps
2729
} from '@/utils/widgetPropFilter'
2830
29-
const value = defineModel<any[]>({ required: true })
30-
3131
const props = defineProps<{
3232
widget: SimplifiedWidget<any[]>
33+
modelValue: any[]
3334
readonly?: boolean
3435
}>()
3536
37+
const emit = defineEmits<{
38+
'update:modelValue': [value: any[]]
39+
}>()
40+
41+
// Use the composable for consistent widget value handling
42+
const { localValue, onChange } = useWidgetValue({
43+
widget: props.widget,
44+
modelValue: props.modelValue,
45+
defaultValue: [],
46+
emit
47+
})
48+
3649
// MultiSelect specific excluded props include overlay styles
3750
const MULTISELECT_EXCLUDED_PROPS = [
3851
...PANEL_EXCLUDED_PROPS,

src/components/graph/vueWidgets/WidgetSelectButton.vue

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
widget.name
55
}}</label>
66
<SelectButton
7-
v-model="value"
7+
v-model="localValue"
88
v-bind="filteredProps"
99
:disabled="readonly"
1010
class="flex-grow min-w-[8em] max-w-[20em] text-xs"
@@ -13,6 +13,7 @@
1313
label: 'text-xs'
1414
}
1515
}"
16+
@update:model-value="onChange"
1617
/>
1718
</div>
1819
</template>
@@ -21,19 +22,31 @@
2122
import SelectButton from 'primevue/selectbutton'
2223
import { computed } from 'vue'
2324
25+
import { useWidgetValue } from '@/composables/graph/useWidgetValue'
2426
import type { SimplifiedWidget } from '@/types/simplifiedWidget'
2527
import {
2628
STANDARD_EXCLUDED_PROPS,
2729
filterWidgetProps
2830
} from '@/utils/widgetPropFilter'
2931
30-
const value = defineModel<any>({ required: true })
31-
3232
const props = defineProps<{
3333
widget: SimplifiedWidget<any>
34+
modelValue: any
3435
readonly?: boolean
3536
}>()
3637
38+
const emit = defineEmits<{
39+
'update:modelValue': [value: any]
40+
}>()
41+
42+
// Use the composable for consistent widget value handling
43+
const { localValue, onChange } = useWidgetValue({
44+
widget: props.widget,
45+
modelValue: props.modelValue,
46+
defaultValue: null,
47+
emit
48+
})
49+
3750
const filteredProps = computed(() =>
3851
filterWidgetProps(props.widget.options, STANDARD_EXCLUDED_PROPS)
3952
)

src/components/graph/vueWidgets/WidgetTextarea.vue

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,44 @@
11
<template>
22
<Textarea
3-
v-model="value"
3+
v-model="localValue"
44
v-bind="filteredProps"
55
:disabled="readonly"
66
class="w-full text-xs"
77
size="small"
88
rows="3"
9+
@update:model-value="onChange"
910
/>
1011
</template>
1112

1213
<script setup lang="ts">
1314
import Textarea from 'primevue/textarea'
1415
import { computed } from 'vue'
1516
17+
import { useWidgetValue } from '@/composables/graph/useWidgetValue'
1618
import type { SimplifiedWidget } from '@/types/simplifiedWidget'
1719
import {
1820
INPUT_EXCLUDED_PROPS,
1921
filterWidgetProps
2022
} from '@/utils/widgetPropFilter'
2123
22-
const value = defineModel<string>({ required: true })
23-
2424
const props = defineProps<{
2525
widget: SimplifiedWidget<string>
26+
modelValue: string
2627
readonly?: boolean
2728
}>()
2829
30+
const emit = defineEmits<{
31+
'update:modelValue': [value: string]
32+
}>()
33+
34+
// Use the composable for consistent widget value handling
35+
const { localValue, onChange } = useWidgetValue({
36+
widget: props.widget,
37+
modelValue: props.modelValue,
38+
defaultValue: '',
39+
emit
40+
})
41+
2942
const filteredProps = computed(() =>
3043
filterWidgetProps(props.widget.options, INPUT_EXCLUDED_PROPS)
3144
)

src/components/graph/vueWidgets/WidgetTreeSelect.vue

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44
widget.name
55
}}</label>
66
<TreeSelect
7-
v-model="value"
7+
v-model="localValue"
88
v-bind="filteredProps"
99
:disabled="readonly"
1010
class="flex-grow min-w-[8em] max-w-[20em] text-xs"
1111
size="small"
12+
@update:model-value="onChange"
1213
/>
1314
</div>
1415
</template>
@@ -17,19 +18,31 @@
1718
import TreeSelect from 'primevue/treeselect'
1819
import { computed } from 'vue'
1920
21+
import { useWidgetValue } from '@/composables/graph/useWidgetValue'
2022
import type { SimplifiedWidget } from '@/types/simplifiedWidget'
2123
import {
2224
PANEL_EXCLUDED_PROPS,
2325
filterWidgetProps
2426
} from '@/utils/widgetPropFilter'
2527
26-
const value = defineModel<any>({ required: true })
27-
2828
const props = defineProps<{
2929
widget: SimplifiedWidget<any>
30+
modelValue: any
3031
readonly?: boolean
3132
}>()
3233
34+
const emit = defineEmits<{
35+
'update:modelValue': [value: any]
36+
}>()
37+
38+
// Use the composable for consistent widget value handling
39+
const { localValue, onChange } = useWidgetValue({
40+
widget: props.widget,
41+
modelValue: props.modelValue,
42+
defaultValue: null,
43+
emit
44+
})
45+
3346
// TreeSelect specific excluded props
3447
const TREE_SELECT_EXCLUDED_PROPS = [
3548
...PANEL_EXCLUDED_PROPS,

0 commit comments

Comments
 (0)