Line data Source code
1 16 : <script setup lang="ts">
2 : import type { SimplifiedWidget } from '@/types/simplifiedWidget'
3 : import { useHideLayoutField, useWidgetHeight } from '@/types/widgetTypes'
4 : import { cn } from '@comfyorg/tailwind-utils'
5 :
6 : import WidgetLayoutFieldLabel from './WidgetLayoutFieldLabel.vue'
7 :
8 : const { widget, rootClass, valueText, inputId, fullWidthControl, noBorder } =
9 : defineProps<{
10 : widget: Pick<
11 : SimplifiedWidget<string | number | undefined>,
12 : 'name' | 'label' | 'displayLabel' | 'borderStyle'
13 : >
14 : rootClass?: string
15 : valueText?: string
16 : inputId?: string
17 : fullWidthControl?: boolean
18 : noBorder?: boolean
19 : fillWidth?: boolean
20 : }>()
21 :
22 5194 : const hideLayoutField = useHideLayoutField()
23 : </script>
24 :
25 : <template>
26 : <div
27 : :class="
28 : cn(
29 : 'relative isolate flex min-w-0 items-center rounded-(--node-widget-radius) border-(length:--node-widget-border-width) border-node-border bg-input focus-within:ring focus-within:ring-ring **:focus-visible:ring-0 **:focus-visible:outline-none',
30 : fullWidthControl ? 'py-2' : useWidgetHeight(),
31 : !noBorder && widget.borderStyle,
32 : rootClass
33 : )
34 : "
35 : @pointerdown.stop
36 : @pointermove.stop
37 : @pointerup.stop
38 : >
39 : <label
40 : v-if="inputId && !hideLayoutField"
41 : :for="inputId"
42 : aria-hidden="true"
43 : data-testid="widget-row-hit-area"
44 : class="absolute inset-0 -z-10 cursor-[inherit]"
45 : />
46 : <slot name="leading" />
47 : <WidgetLayoutFieldLabel
48 : :widget
49 : :input-id
50 : :class="cn($slots.leading ? 'pl-2' : 'pl-3', fullWidthControl && 'z-10')"
51 : />
52 : <slot name="between" />
53 : <div :class="cn('ml-auto grid min-w-0 shrink', fillWidth && 'flex-1')">
54 : <span
55 : v-if="valueText !== undefined"
56 : aria-hidden="true"
57 : :data-value="valueText"
58 : :class="
59 : cn(
60 : 'invisible col-start-1 row-start-1 truncate pl-2 after:content-[attr(data-value)]',
61 : fullWidthControl ? 'pr-2' : 'pr-7'
62 : )
63 : "
64 : />
65 : <div
66 : :class="
67 : cn(
68 : 'col-start-1 row-start-1 min-w-0 cursor-[inherit] rounded-(--node-widget-radius) transition-all',
69 : fullWidthControl && 'absolute inset-0'
70 : )
71 : "
72 : >
73 : <slot :border-style="widget.borderStyle" />
74 : </div>
75 : </div>
76 : </div>
77 : </template>
|