mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-05 15:40:10 +00:00
"improve" typings
This commit is contained in:
@@ -32,19 +32,20 @@ import ToggleSwitch from 'primevue/toggleswitch'
|
||||
import { computed } from 'vue'
|
||||
|
||||
import type { SimplifiedWidget } from '@/types/simplifiedWidget'
|
||||
import type { WidgetToggleSwitchProps } from '@/types/widgetPropTypes'
|
||||
import {
|
||||
STANDARD_EXCLUDED_PROPS,
|
||||
INPUT_EXCLUDED_PROPS,
|
||||
filterWidgetProps
|
||||
} from '@/utils/widgetPropFilter'
|
||||
|
||||
const value = defineModel<boolean>({ required: true })
|
||||
|
||||
const props = defineProps<{
|
||||
widget: SimplifiedWidget<boolean>
|
||||
widget: SimplifiedWidget<boolean, WidgetToggleSwitchProps>
|
||||
readonly?: boolean
|
||||
}>()
|
||||
|
||||
const filteredProps = computed(() =>
|
||||
filterWidgetProps(props.widget.options, STANDARD_EXCLUDED_PROPS)
|
||||
filterWidgetProps(props.widget.options, INPUT_EXCLUDED_PROPS)
|
||||
)
|
||||
</script>
|
||||
|
||||
@@ -1,38 +1,30 @@
|
||||
/**
|
||||
* Type definitions for widget component props
|
||||
*
|
||||
* These interfaces define the subset of PrimeVue component props that are exposed
|
||||
* for the node-based widget system. They exclude props that allow custom styling,
|
||||
* colors, arbitrary CSS, or could create chaotic interfaces.
|
||||
*
|
||||
* Based on the design authority at:
|
||||
* https://www.figma.com/design/CmhEJxo4oZSuYpqG1Yc39w/Nodes-V3?node-id=441-7806&m=dev
|
||||
*/
|
||||
|
||||
export interface ToggleSwitchProps {
|
||||
modelValue: string | boolean
|
||||
defaultValue?: string | boolean
|
||||
name?: string
|
||||
trueValue?: any
|
||||
falseValue?: any
|
||||
invalid?: boolean
|
||||
disabled?: boolean
|
||||
readonly?: boolean
|
||||
tabindex?: number
|
||||
inputId?: string
|
||||
ariaLabelledby?: string
|
||||
ariaLabel?: string
|
||||
}
|
||||
import type { ToggleSwitchProps as PrimeVueToggleSwitchProps } from 'primevue/toggleswitch'
|
||||
|
||||
/**
|
||||
* Allowed ToggleSwitch props that can be passed through widget options
|
||||
* (excludes style-related props that are filtered out)
|
||||
* Widget ToggleSwitch Component
|
||||
* Excludes: style, class, inputClass, inputStyle, dt, pt, ptOptions, unstyled
|
||||
*
|
||||
* These props are excluded from widget.options to prevent external styling overrides.
|
||||
* The widget component itself can still use these props internally for consistent styling.
|
||||
*/
|
||||
export type AllowedToggleSwitchProps = Pick<
|
||||
ToggleSwitchProps,
|
||||
| 'modelValue'
|
||||
| 'defaultValue'
|
||||
| 'name'
|
||||
| 'trueValue'
|
||||
| 'falseValue'
|
||||
| 'invalid'
|
||||
| 'disabled'
|
||||
| 'readonly'
|
||||
| 'tabindex'
|
||||
| 'inputId'
|
||||
| 'ariaLabelledby'
|
||||
| 'ariaLabel'
|
||||
export type WidgetToggleSwitchProps = Omit<
|
||||
PrimeVueToggleSwitchProps,
|
||||
| 'style'
|
||||
| 'class'
|
||||
| 'inputClass'
|
||||
| 'inputStyle'
|
||||
| 'dt'
|
||||
| 'pt'
|
||||
| 'ptOptions'
|
||||
| 'unstyled'
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user