mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-05 23:50:08 +00:00
- Create WidgetValue union type for all valid widget values - Replace 'any' types with proper generic constraints in SimplifiedWidget - Add runtime validation for widget values in useGraphNodeManager - Update WidgetSelect to use constrained generics instead of any - Fix type assertions with proper validation functions - Ensure SafeWidgetData uses WidgetValue type consistently This eliminates most 'any' usage while maintaining runtime safety through validation.
60 lines
1.4 KiB
Vue
60 lines
1.4 KiB
Vue
<template>
|
|
<div class="flex flex-col gap-1">
|
|
<label v-if="widget.name" class="text-sm opacity-80">{{
|
|
widget.name
|
|
}}</label>
|
|
<Select
|
|
v-model="localValue"
|
|
:options="selectOptions"
|
|
v-bind="filteredProps"
|
|
:disabled="readonly"
|
|
@update:model-value="onChange"
|
|
/>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import Select from 'primevue/select'
|
|
import { computed } from 'vue'
|
|
|
|
import { useWidgetValue } from '@/composables/graph/useWidgetValue'
|
|
import type { SimplifiedWidget } from '@/types/simplifiedWidget'
|
|
import {
|
|
PANEL_EXCLUDED_PROPS,
|
|
filterWidgetProps
|
|
} from '@/utils/widgetPropFilter'
|
|
|
|
const props = defineProps<{
|
|
widget: SimplifiedWidget<string | number | undefined>
|
|
modelValue: string | number | undefined
|
|
readonly?: boolean
|
|
}>()
|
|
|
|
const emit = defineEmits<{
|
|
'update:modelValue': [value: string | number | undefined]
|
|
}>()
|
|
|
|
// Use the composable for consistent widget value handling
|
|
const { localValue, onChange } = useWidgetValue({
|
|
widget: props.widget,
|
|
modelValue: props.modelValue,
|
|
defaultValue: props.widget.options?.values?.[0] || '',
|
|
emit
|
|
})
|
|
|
|
const filteredProps = computed(() =>
|
|
filterWidgetProps(props.widget.options, PANEL_EXCLUDED_PROPS)
|
|
)
|
|
|
|
// Extract select options from widget options
|
|
const selectOptions = computed(() => {
|
|
const options = props.widget.options
|
|
|
|
if (options?.values && Array.isArray(options.values)) {
|
|
return options.values
|
|
}
|
|
|
|
return []
|
|
})
|
|
</script>
|