@xy-planning-network/trees 0.7.4-dev → 0.7.5-dev
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/trees.es.js +2780 -2715
- package/dist/trees.umd.js +9 -9
- package/package.json +1 -1
- package/src/index.css +0 -16
- package/src/lib-components/forms/BaseInput.vue +49 -67
- package/src/lib-components/forms/Checkbox.vue +22 -16
- package/src/lib-components/forms/DateRangePicker.vue +11 -7
- package/src/lib-components/forms/FieldsetLegend.vue +7 -7
- package/src/lib-components/forms/InputHelp.vue +2 -4
- package/src/lib-components/forms/InputLabel.vue +5 -10
- package/src/lib-components/forms/MultiCheckboxes.vue +35 -43
- package/src/lib-components/forms/Radio.vue +36 -45
- package/src/lib-components/forms/RadioCards.vue +36 -22
- package/src/lib-components/forms/Select.vue +44 -38
- package/src/lib-components/forms/TextArea.vue +33 -34
- package/src/lib-components/forms/Toggle.vue +58 -18
- package/src/lib-components/forms/YesOrNoRadio.vue +42 -48
- package/types/composables/forms.d.ts +10 -8
- package/types/helpers/Debounce.d.ts +1 -1
- package/types/lib-components/forms/BaseInput.vue.d.ts +2 -2
- package/types/lib-components/forms/FieldsetLegend.vue.d.ts +7 -9
- package/types/lib-components/forms/InputLabel.vue.d.ts +0 -5
- package/types/lib-components/forms/MultiCheckboxes.vue.d.ts +10 -17
- package/types/lib-components/forms/Radio.vue.d.ts +10 -17
- package/types/lib-components/forms/RadioCards.vue.d.ts +8 -8
- package/types/lib-components/forms/Select.vue.d.ts +0 -5
- package/types/lib-components/forms/Toggle.vue.d.ts +14 -4
- package/types/lib-components/forms/YesOrNoRadio.vue.d.ts +5 -10
- package/types/lib-components/overlays/Modal.vue.d.ts +1 -1
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import Uniques from "@/helpers/Uniques"
|
|
3
2
|
import {
|
|
4
3
|
RadioGroup,
|
|
5
4
|
RadioGroupDescription,
|
|
@@ -7,10 +6,15 @@ import {
|
|
|
7
6
|
RadioGroupOption,
|
|
8
7
|
} from "@headlessui/vue"
|
|
9
8
|
import { CheckCircleIcon } from "@heroicons/vue/solid"
|
|
10
|
-
import { computed, ref
|
|
9
|
+
import { computed, ref } from "vue"
|
|
11
10
|
import InputLabel from "./InputLabel.vue"
|
|
12
11
|
import InputHelp from "./InputHelp.vue"
|
|
13
12
|
import FieldsetLegend from "./FieldsetLegend.vue"
|
|
13
|
+
import { useInputField } from "@/composables/forms"
|
|
14
|
+
|
|
15
|
+
defineOptions({
|
|
16
|
+
inheritAttrs: false,
|
|
17
|
+
})
|
|
14
18
|
|
|
15
19
|
/*
|
|
16
20
|
* NOTE (spk) headless UI introduced a "name" prop that includes a hidden field
|
|
@@ -35,14 +39,14 @@ const props = withDefaults(
|
|
|
35
39
|
defineProps<{
|
|
36
40
|
columns?: 2 | 3
|
|
37
41
|
help?: string
|
|
38
|
-
|
|
42
|
+
label?: string
|
|
39
43
|
modelValue?: ModelValue
|
|
40
44
|
options: RadioCard[]
|
|
41
45
|
}>(),
|
|
42
46
|
{
|
|
43
47
|
columns: undefined,
|
|
44
48
|
help: "",
|
|
45
|
-
|
|
49
|
+
label: "",
|
|
46
50
|
modelValue: undefined,
|
|
47
51
|
}
|
|
48
52
|
)
|
|
@@ -51,8 +55,7 @@ const emit = defineEmits<{
|
|
|
51
55
|
(e: "update:modelValue", modelValue: ModelValue): void
|
|
52
56
|
}>()
|
|
53
57
|
|
|
54
|
-
const
|
|
55
|
-
const uuid = Uniques.CreateIdAttribute()
|
|
58
|
+
const { inputID, isDisabled, isRequired, nameAttr } = useInputField()
|
|
56
59
|
|
|
57
60
|
// tracking internal state separate from modelValue
|
|
58
61
|
// allows v-model to be undefined by the consumer but still supports
|
|
@@ -74,27 +77,25 @@ const onChange = (val: ModelValue) => {
|
|
|
74
77
|
invalid.value = false
|
|
75
78
|
emit("update:modelValue", val)
|
|
76
79
|
}
|
|
77
|
-
|
|
78
|
-
const nameAttr = computed(() => {
|
|
79
|
-
return typeof attrs.name === "string" && attrs.name !== "" ? attrs.name : uuid
|
|
80
|
-
})
|
|
81
80
|
</script>
|
|
82
81
|
|
|
83
82
|
<template>
|
|
84
83
|
<RadioGroup
|
|
85
84
|
:model-value="checkedState"
|
|
86
|
-
:disabled="
|
|
85
|
+
:disabled="isDisabled"
|
|
87
86
|
:aria-invalid="invalid === true ? 'true' : null"
|
|
88
|
-
:aria-errormessage="invalid === true ? `error-${
|
|
87
|
+
:aria-errormessage="invalid === true ? `error-${inputID}` : null"
|
|
89
88
|
@update:model-value="onChange"
|
|
90
89
|
>
|
|
91
|
-
<RadioGroupLabel v-if="
|
|
92
|
-
<FieldsetLegend tag="div"
|
|
90
|
+
<RadioGroupLabel v-if="label" class="block">
|
|
91
|
+
<FieldsetLegend tag="div" :label="label" />
|
|
93
92
|
</RadioGroupLabel>
|
|
93
|
+
|
|
94
94
|
<RadioGroupDescription v-if="help">
|
|
95
95
|
<InputHelp :text="help" />
|
|
96
96
|
</RadioGroupDescription>
|
|
97
|
-
|
|
97
|
+
|
|
98
|
+
<div v-if="invalid === true" :id="`error-${inputID}`" class="sr-only">
|
|
98
99
|
Please select one of these options.
|
|
99
100
|
</div>
|
|
100
101
|
|
|
@@ -108,17 +109,27 @@ const nameAttr = computed(() => {
|
|
|
108
109
|
<RadioGroupOption
|
|
109
110
|
v-for="option in options"
|
|
110
111
|
:key="option.value"
|
|
111
|
-
v-slot="{
|
|
112
|
+
v-slot="{
|
|
113
|
+
active,
|
|
114
|
+
checked,
|
|
115
|
+
disabled,
|
|
116
|
+
}: {
|
|
117
|
+
active: boolean,
|
|
118
|
+
checked: boolean,
|
|
119
|
+
disabled: boolean,
|
|
120
|
+
}"
|
|
112
121
|
as="template"
|
|
113
|
-
:disabled="
|
|
122
|
+
:disabled="isDisabled || option.disabled"
|
|
114
123
|
:value="option.value"
|
|
115
124
|
>
|
|
116
125
|
<div
|
|
117
|
-
class="relative
|
|
126
|
+
class="relative border rounded-lg shadow-sm p-4 flex focus:outline-none"
|
|
118
127
|
:class="[
|
|
119
|
-
|
|
128
|
+
disabled
|
|
129
|
+
? 'cursor-not-allowed bg-gray-50 border-gray-200 opacity-90'
|
|
130
|
+
: 'cursor-pointer bg-white border-gray-300',
|
|
131
|
+
checked ? 'border-transparent' : '',
|
|
120
132
|
active ? 'border-xy-blue ring-2 ring-xy-blue-500' : '',
|
|
121
|
-
disabled ? 'cursor-not-allowed opacity-75' : '',
|
|
122
133
|
]"
|
|
123
134
|
>
|
|
124
135
|
<div class="flex-1 flex pr-1">
|
|
@@ -130,16 +141,18 @@ const nameAttr = computed(() => {
|
|
|
130
141
|
:label="option.label"
|
|
131
142
|
/>
|
|
132
143
|
</RadioGroupLabel>
|
|
144
|
+
|
|
133
145
|
<RadioGroupDescription v-if="option.help" as="div">
|
|
134
146
|
<InputHelp tag="div" class="mt-auto" :text="option.help" />
|
|
135
147
|
</RadioGroupDescription>
|
|
148
|
+
|
|
136
149
|
<div
|
|
137
150
|
v-if="option.sublabel || $slots.sublabel"
|
|
138
151
|
class="mt-auto mb-0"
|
|
139
152
|
>
|
|
140
153
|
<RadioGroupDescription
|
|
141
154
|
as="div"
|
|
142
|
-
class="
|
|
155
|
+
class="text-sm/5 font-medium mt-4 text-gray-800"
|
|
143
156
|
>
|
|
144
157
|
<slot
|
|
145
158
|
name="sublabel"
|
|
@@ -165,12 +178,13 @@ const nameAttr = computed(() => {
|
|
|
165
178
|
]"
|
|
166
179
|
aria-hidden="true"
|
|
167
180
|
/>
|
|
181
|
+
|
|
168
182
|
<input
|
|
169
183
|
class="sr-only top-1 left-1"
|
|
170
184
|
aria-hidden="true"
|
|
171
185
|
:checked="checked"
|
|
172
186
|
:name="nameAttr"
|
|
173
|
-
:required="
|
|
187
|
+
:required="isRequired"
|
|
174
188
|
tabindex="-1"
|
|
175
189
|
type="radio"
|
|
176
190
|
:value="option.value"
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import Uniques from "@/helpers/Uniques"
|
|
3
2
|
import InputLabel from "./InputLabel.vue"
|
|
4
3
|
import InputHelp from "./InputHelp.vue"
|
|
5
|
-
import {
|
|
4
|
+
import { useInputField } from "@/composables/forms"
|
|
6
5
|
|
|
7
|
-
|
|
6
|
+
defineOptions({
|
|
7
|
+
inheritAttrs: false,
|
|
8
|
+
})
|
|
9
|
+
|
|
10
|
+
withDefaults(
|
|
8
11
|
defineProps<{
|
|
9
|
-
design?: "standard" | "compressed"
|
|
10
12
|
label?: string
|
|
11
13
|
help?: string
|
|
12
14
|
placeholder?: string
|
|
@@ -14,7 +16,6 @@ const props = withDefaults(
|
|
|
14
16
|
modelValue: string | number | undefined
|
|
15
17
|
}>(),
|
|
16
18
|
{
|
|
17
|
-
design: "standard",
|
|
18
19
|
label: "",
|
|
19
20
|
help: "",
|
|
20
21
|
placeholder: "Select an option",
|
|
@@ -22,44 +23,49 @@ const props = withDefaults(
|
|
|
22
23
|
)
|
|
23
24
|
|
|
24
25
|
const emit = defineEmits(["update:modelValue"])
|
|
25
|
-
const
|
|
26
|
-
const uuid = (attrs.id as string) || Uniques.CreateIdAttribute()
|
|
27
|
-
|
|
28
|
-
const classes = computed((): string => {
|
|
29
|
-
return (
|
|
30
|
-
{
|
|
31
|
-
standard:
|
|
32
|
-
"mt-1 block w-full border border-gray-600 rounded-md shadow-sm py-2 px-3 focus:outline-none focus:ring-xy-blue-500 focus:border-xy-blue sm:text-sm disabled:opacity-70 disabled:cursor-not-allowed",
|
|
33
|
-
compressed:
|
|
34
|
-
"appearance-none rounded-none relative block w-full px-3 py-2 border border-gray-600 text-gray-900 focus:outline-none focus:ring-xy-blue-500 focus:border-xy-blue focus:z-10 sm:text-sm disabled:opacity-70 disabled:cursor-not-allowed",
|
|
35
|
-
} as any
|
|
36
|
-
)[props.design]
|
|
37
|
-
})
|
|
26
|
+
const { inputID, isValid } = useInputField()
|
|
38
27
|
</script>
|
|
28
|
+
|
|
39
29
|
<template>
|
|
40
|
-
<
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
30
|
+
<div>
|
|
31
|
+
<div class="mb-1">
|
|
32
|
+
<InputLabel :id="`${inputID}-label`" :for="inputID" :label="label" />
|
|
33
|
+
</div>
|
|
34
|
+
<select
|
|
35
|
+
:id="inputID"
|
|
36
|
+
:aria-labelledby="label ? `${inputID}-label` : undefined"
|
|
37
|
+
:aria-describedby="help ? `${inputID}-help` : undefined"
|
|
38
|
+
:class="[
|
|
39
|
+
'block w-full rounded-md border-0 py-2 shadow-sm ring-1 ring-inset focus:ring-2 sm:text-sm sm:leading-6 pl-3 pr-10',
|
|
40
|
+
'disabled:cursor-not-allowed disabled:bg-gray-50 disabled:text-gray-600 disabled:ring-gray-200 disabled:opacity-100',
|
|
41
|
+
isValid
|
|
42
|
+
? 'text-gray-800 ring-gray-300 placeholder:text-gray-400 focus:ring-xy-blue-500'
|
|
43
|
+
: 'text-red-900 ring-red-700 placeholder:text-red-300 focus:ring-red-700',
|
|
44
|
+
]"
|
|
45
|
+
:value="modelValue"
|
|
46
|
+
v-bind="{
|
|
48
47
|
...$attrs,
|
|
49
48
|
onChange: ($event) => {
|
|
50
49
|
emit('update:modelValue', ($event.target as HTMLInputElement).value)
|
|
51
50
|
},
|
|
52
51
|
}"
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
52
|
+
>
|
|
53
|
+
<option
|
|
54
|
+
v-if="placeholder"
|
|
55
|
+
value=""
|
|
56
|
+
disabled
|
|
57
|
+
selected
|
|
58
|
+
v-text="placeholder"
|
|
59
|
+
/>
|
|
60
|
+
<option
|
|
61
|
+
v-for="option in options"
|
|
62
|
+
:key="option.value"
|
|
63
|
+
:value="option.value"
|
|
64
|
+
v-text="option.label"
|
|
65
|
+
/>
|
|
66
|
+
</select>
|
|
67
|
+
<div class="mt-1">
|
|
68
|
+
<InputHelp :id="`${inputID}-help`" :text="help" />
|
|
69
|
+
</div>
|
|
70
|
+
</div>
|
|
65
71
|
</template>
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import Uniques from "@/helpers/Uniques"
|
|
3
2
|
import InputLabel from "./InputLabel.vue"
|
|
4
3
|
import InputHelp from "./InputHelp.vue"
|
|
5
|
-
import {
|
|
4
|
+
import { useInputField } from "@/composables/forms"
|
|
5
|
+
|
|
6
|
+
defineOptions({
|
|
7
|
+
inheritAttrs: false,
|
|
8
|
+
})
|
|
9
|
+
|
|
6
10
|
withDefaults(
|
|
7
11
|
defineProps<{
|
|
8
12
|
help?: string
|
|
@@ -15,40 +19,35 @@ withDefaults(
|
|
|
15
19
|
modelValue: "",
|
|
16
20
|
}
|
|
17
21
|
)
|
|
18
|
-
|
|
22
|
+
|
|
19
23
|
const emit = defineEmits(["update:modelValue"])
|
|
20
|
-
const
|
|
24
|
+
const { inputID, isValid } = useInputField()
|
|
21
25
|
</script>
|
|
22
26
|
|
|
23
27
|
<template>
|
|
24
|
-
<
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
@input="
|
|
50
|
-
emit('update:modelValue', ($event.target as HTMLInputElement).value)
|
|
51
|
-
"
|
|
52
|
-
/>
|
|
53
|
-
<InputHelp :id="`${uuid}-help`" :text="help"></InputHelp>
|
|
28
|
+
<div>
|
|
29
|
+
<div class="mb-1">
|
|
30
|
+
<InputLabel :id="`${inputID}-label`" :for="inputID" :label="label" />
|
|
31
|
+
</div>
|
|
32
|
+
<textarea
|
|
33
|
+
:id="inputID"
|
|
34
|
+
:aria-labelledby="label ? `${inputID}-label` : undefined"
|
|
35
|
+
:aria-describedby="help ? `${inputID}-help` : undefined"
|
|
36
|
+
:class="[
|
|
37
|
+
'block w-full rounded-md border-0 py-2 shadow-sm ring-1 ring-inset focus:ring-2 sm:text-sm sm:leading-6',
|
|
38
|
+
'disabled:cursor-not-allowed disabled:bg-gray-50 disabled:text-gray-600 disabled:ring-gray-200',
|
|
39
|
+
isValid
|
|
40
|
+
? 'text-gray-800 ring-gray-300 placeholder:text-gray-400 focus:ring-xy-blue-500'
|
|
41
|
+
: 'text-red-900 ring-red-700 placeholder:text-red-300 focus:ring-red-700',
|
|
42
|
+
]"
|
|
43
|
+
:value="modelValue"
|
|
44
|
+
v-bind="$attrs"
|
|
45
|
+
@input="
|
|
46
|
+
emit('update:modelValue', ($event.target as HTMLInputElement).value)
|
|
47
|
+
"
|
|
48
|
+
/>
|
|
49
|
+
<div class="mt-1">
|
|
50
|
+
<InputHelp :id="`${inputID}-help`" :text="help"></InputHelp>
|
|
51
|
+
</div>
|
|
52
|
+
</div>
|
|
54
53
|
</template>
|
|
@@ -1,27 +1,67 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
Switch,
|
|
4
|
+
SwitchGroup,
|
|
5
|
+
SwitchLabel,
|
|
6
|
+
SwitchDescription,
|
|
7
|
+
} from "@headlessui/vue"
|
|
8
|
+
import InputLabel from "@/lib-components/forms/InputLabel.vue"
|
|
9
|
+
import InputHelp from "@/lib-components/forms/InputHelp.vue"
|
|
10
|
+
import { useInputField } from "@/composables/forms"
|
|
3
11
|
|
|
4
|
-
|
|
12
|
+
defineOptions({
|
|
13
|
+
inheritAttrs: false,
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
withDefaults(
|
|
17
|
+
defineProps<{
|
|
18
|
+
modelValue?: boolean | undefined
|
|
19
|
+
label?: string
|
|
20
|
+
help?: string
|
|
21
|
+
}>(),
|
|
22
|
+
{
|
|
23
|
+
modelValue: undefined,
|
|
24
|
+
label: "",
|
|
25
|
+
help: "",
|
|
26
|
+
}
|
|
27
|
+
)
|
|
5
28
|
|
|
6
|
-
withDefaults(defineProps<{ modelValue: boolean }>(), { modelValue: false })
|
|
7
29
|
const emits = defineEmits(["update:modelValue"])
|
|
30
|
+
const { isDisabled } = useInputField()
|
|
8
31
|
</script>
|
|
9
32
|
<template>
|
|
10
|
-
<
|
|
11
|
-
|
|
12
|
-
modelValue ? 'bg-xy-blue' : 'bg-gray-200',
|
|
13
|
-
'relative inline-flex shrink-0 h-6 w-11 border-2 border-transparent rounded-full cursor-pointer transition-colors ease-in-out duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-xy-blue-500',
|
|
14
|
-
]"
|
|
15
|
-
:model-value="modelValue"
|
|
16
|
-
@update:model-value="emits('update:modelValue', $event)"
|
|
17
|
-
>
|
|
18
|
-
<span class="sr-only">Use</span>
|
|
19
|
-
<span
|
|
20
|
-
aria-hidden="true"
|
|
33
|
+
<SwitchGroup as="div" class="flex items-start">
|
|
34
|
+
<Switch
|
|
21
35
|
:class="[
|
|
22
|
-
modelValue ? '
|
|
23
|
-
|
|
36
|
+
modelValue ? 'bg-xy-blue' : 'bg-gray-200',
|
|
37
|
+
isDisabled ? 'opacity-75 cursor-not-allowed' : 'cursor-pointer',
|
|
38
|
+
'relative inline-flex shrink-0 h-6 w-11 border-2 border-transparent rounded-full transition-colors ease-in-out duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-xy-blue-500',
|
|
24
39
|
]"
|
|
25
|
-
|
|
26
|
-
|
|
40
|
+
:disabled="isDisabled"
|
|
41
|
+
:model-value="modelValue"
|
|
42
|
+
@update:model-value="emits('update:modelValue', $event)"
|
|
43
|
+
>
|
|
44
|
+
<span v-if="!label" class="sr-only">Use</span>
|
|
45
|
+
<span
|
|
46
|
+
aria-hidden="true"
|
|
47
|
+
:class="[
|
|
48
|
+
modelValue ? 'translate-x-5' : 'translate-x-0',
|
|
49
|
+
'pointer-events-none inline-block h-5 w-5 rounded-full bg-white shadow transform ring-0 transition ease-in-out duration-200',
|
|
50
|
+
]"
|
|
51
|
+
/>
|
|
52
|
+
</Switch>
|
|
53
|
+
|
|
54
|
+
<div class="ml-3">
|
|
55
|
+
<SwitchLabel v-if="label">
|
|
56
|
+
<InputLabel
|
|
57
|
+
:label="label"
|
|
58
|
+
:class="isDisabled && 'cursor-not-allowed'"
|
|
59
|
+
/>
|
|
60
|
+
</SwitchLabel>
|
|
61
|
+
|
|
62
|
+
<SwitchDescription v-if="help">
|
|
63
|
+
<InputHelp :text="help" />
|
|
64
|
+
</SwitchDescription>
|
|
65
|
+
</div>
|
|
66
|
+
</SwitchGroup>
|
|
27
67
|
</template>
|
|
@@ -1,58 +1,60 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import Uniques from "@/helpers/Uniques"
|
|
3
|
-
import { computed, useAttrs } from "vue"
|
|
4
2
|
import InputLabel from "./InputLabel.vue"
|
|
5
3
|
import InputHelp from "./InputHelp.vue"
|
|
4
|
+
import { useInputField } from "@/composables/forms"
|
|
6
5
|
|
|
7
|
-
|
|
6
|
+
defineOptions({
|
|
7
|
+
inheritAttrs: false,
|
|
8
|
+
})
|
|
9
|
+
|
|
10
|
+
withDefaults(
|
|
8
11
|
defineProps<{
|
|
9
12
|
modelValue?: boolean
|
|
10
13
|
help?: string
|
|
11
|
-
|
|
12
|
-
name?: string
|
|
14
|
+
label?: string
|
|
13
15
|
}>(),
|
|
14
16
|
{
|
|
15
17
|
modelValue: undefined,
|
|
16
18
|
help: "",
|
|
17
|
-
|
|
18
|
-
name: "",
|
|
19
|
+
label: "",
|
|
19
20
|
}
|
|
20
21
|
)
|
|
22
|
+
|
|
21
23
|
const emits = defineEmits(["update:modelValue"])
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
const hasNameAttr = computed((): boolean => {
|
|
25
|
-
return typeof props.name === "string" && props.name !== ""
|
|
26
|
-
})
|
|
24
|
+
const { inputID, isDisabled, nameAttr } = useInputField()
|
|
25
|
+
|
|
27
26
|
const onChange = (e: Event) => {
|
|
28
27
|
emits("update:modelValue", (e.target as HTMLInputElement).value === "true")
|
|
29
28
|
}
|
|
30
29
|
</script>
|
|
30
|
+
|
|
31
31
|
<template>
|
|
32
32
|
<fieldset
|
|
33
33
|
class="space-y-3"
|
|
34
|
-
:aria-labelledby="
|
|
35
|
-
:aria-describedby="help ? `${
|
|
34
|
+
:aria-labelledby="label ? `${inputID}-legend` : undefined"
|
|
35
|
+
:aria-describedby="help ? `${inputID}-help` : undefined"
|
|
36
36
|
>
|
|
37
|
-
<div v-if="
|
|
38
|
-
<InputLabel
|
|
39
|
-
|
|
40
|
-
:label="legend"
|
|
41
|
-
tag="legend"
|
|
42
|
-
></InputLabel>
|
|
43
|
-
<InputHelp :id="`${uuid}-help`" tag="p" :text="help" />
|
|
37
|
+
<div v-if="label">
|
|
38
|
+
<InputLabel class="block my-auto" :label="label" tag="legend" />
|
|
39
|
+
<InputHelp v-if="help" :id="`${inputID}-help`" tag="p" :text="help" />
|
|
44
40
|
</div>
|
|
41
|
+
|
|
45
42
|
<div>
|
|
46
43
|
<label
|
|
47
|
-
class="inline-flex items-center"
|
|
48
|
-
:class="
|
|
49
|
-
:for="`${
|
|
44
|
+
class="inline-flex items-center group"
|
|
45
|
+
:class="isDisabled && 'cursor-not-allowed'"
|
|
46
|
+
:for="`${nameAttr}-true`"
|
|
50
47
|
>
|
|
51
48
|
<input
|
|
52
|
-
:id="`${
|
|
49
|
+
:id="`${nameAttr}-true`"
|
|
53
50
|
type="radio"
|
|
54
|
-
class="
|
|
55
|
-
|
|
51
|
+
:class="[
|
|
52
|
+
'h-4 w-4',
|
|
53
|
+
'border-gray-300 text-xy-blue focus:ring-xy-blue-500',
|
|
54
|
+
'disabled:bg-gray-100 disabled:border-gray-200 disabled:cursor-not-allowed disabled:opacity-100',
|
|
55
|
+
'checked:disabled:bg-xy-blue checked:disabled:border-xy-blue checked:disabled:opacity-50',
|
|
56
|
+
]"
|
|
57
|
+
:name="nameAttr"
|
|
56
58
|
:value="true"
|
|
57
59
|
:checked="modelValue === true"
|
|
58
60
|
v-bind="{
|
|
@@ -60,25 +62,24 @@ const onChange = (e: Event) => {
|
|
|
60
62
|
onChange: onChange,
|
|
61
63
|
}"
|
|
62
64
|
/>
|
|
63
|
-
<InputLabel
|
|
64
|
-
class="ml-2"
|
|
65
|
-
:disabled="
|
|
66
|
-
$attrs.hasOwnProperty('disabled') && $attrs.disabled !== false
|
|
67
|
-
"
|
|
68
|
-
label="Yes"
|
|
69
|
-
tag="span"
|
|
70
|
-
></InputLabel>
|
|
65
|
+
<InputLabel class="ml-3" label="Yes" tag="span" />
|
|
71
66
|
</label>
|
|
67
|
+
|
|
72
68
|
<label
|
|
73
69
|
class="inline-flex items-center ml-6"
|
|
74
|
-
:class="
|
|
75
|
-
:for="`${
|
|
70
|
+
:class="isDisabled && 'cursor-not-allowed'"
|
|
71
|
+
:for="`${nameAttr}-false`"
|
|
76
72
|
>
|
|
77
73
|
<input
|
|
78
|
-
:id="`${
|
|
74
|
+
:id="`${nameAttr}-false`"
|
|
79
75
|
type="radio"
|
|
80
|
-
class="
|
|
81
|
-
|
|
76
|
+
:class="[
|
|
77
|
+
'h-4 w-4',
|
|
78
|
+
'border-gray-300 text-xy-blue focus:ring-xy-blue-500',
|
|
79
|
+
'disabled:bg-gray-100 disabled:border-gray-200 disabled:cursor-not-allowed disabled:opacity-100',
|
|
80
|
+
'checked:disabled:bg-xy-blue checked:disabled:border-xy-blue checked:disabled:opacity-50',
|
|
81
|
+
]"
|
|
82
|
+
:name="nameAttr"
|
|
82
83
|
:value="false"
|
|
83
84
|
:checked="modelValue === false"
|
|
84
85
|
v-bind="{
|
|
@@ -86,14 +87,7 @@ const onChange = (e: Event) => {
|
|
|
86
87
|
onChange: onChange,
|
|
87
88
|
}"
|
|
88
89
|
/>
|
|
89
|
-
<InputLabel
|
|
90
|
-
class="ml-2"
|
|
91
|
-
:disabled="
|
|
92
|
-
$attrs.hasOwnProperty('disabled') && $attrs.disabled !== false
|
|
93
|
-
"
|
|
94
|
-
label="No"
|
|
95
|
-
tag="span"
|
|
96
|
-
></InputLabel>
|
|
90
|
+
<InputLabel class="ml-3" label="No" tag="span" />
|
|
97
91
|
</label>
|
|
98
92
|
</div>
|
|
99
93
|
</fieldset>
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
export declare const useInputField: () => {
|
|
2
|
+
attrs: {
|
|
3
|
+
[x: string]: unknown;
|
|
4
|
+
};
|
|
5
|
+
inputID: import("vue").ComputedRef<string>;
|
|
6
|
+
isDisabled: import("vue").ComputedRef<boolean>;
|
|
7
|
+
isRequired: import("vue").ComputedRef<boolean>;
|
|
8
|
+
isValid: import("vue").ComputedRef<boolean>;
|
|
9
|
+
nameAttr: import("vue").ComputedRef<string>;
|
|
10
|
+
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare function debounce(
|
|
1
|
+
export declare function debounce(fn: (...args: any[]) => void, wait?: number): (...args: any[]) => void;
|
|
2
2
|
export declare function debounceLeading(func: () => void, timeout?: number): (...args: any[]) => void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
2
|
-
type:
|
|
2
|
+
type: "number" | "search" | "time" | "text" | "date" | "datetime-local" | "email" | "month" | "password" | "tel" | "url" | "week";
|
|
3
3
|
help?: string | undefined;
|
|
4
4
|
label?: string | undefined;
|
|
5
5
|
modelValue?: string | number | undefined;
|
|
@@ -8,7 +8,7 @@ declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_T
|
|
|
8
8
|
label: string;
|
|
9
9
|
modelValue: string;
|
|
10
10
|
}>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "update:modelValue"[], "update:modelValue", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
11
|
-
type:
|
|
11
|
+
type: "number" | "search" | "time" | "text" | "date" | "datetime-local" | "email" | "month" | "password" | "tel" | "url" | "week";
|
|
12
12
|
help?: string | undefined;
|
|
13
13
|
label?: string | undefined;
|
|
14
14
|
modelValue?: string | number | undefined;
|
|
@@ -1,16 +1,19 @@
|
|
|
1
|
-
declare const _default:
|
|
1
|
+
declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
2
|
+
label?: string | undefined;
|
|
2
3
|
tag?: string | undefined;
|
|
3
4
|
}>, {
|
|
5
|
+
label: string;
|
|
4
6
|
tag: string;
|
|
5
7
|
}>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
8
|
+
label?: string | undefined;
|
|
6
9
|
tag?: string | undefined;
|
|
7
10
|
}>, {
|
|
11
|
+
label: string;
|
|
8
12
|
tag: string;
|
|
9
13
|
}>>>, {
|
|
14
|
+
label: string;
|
|
10
15
|
tag: string;
|
|
11
|
-
}, {}
|
|
12
|
-
default: (_: {}) => any;
|
|
13
|
-
}>;
|
|
16
|
+
}, {}>;
|
|
14
17
|
export default _default;
|
|
15
18
|
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
16
19
|
type __VLS_TypePropsToRuntimeProps<T> = {
|
|
@@ -26,8 +29,3 @@ type __VLS_WithDefaults<P, D> = {
|
|
|
26
29
|
default: D[K];
|
|
27
30
|
} : P[K];
|
|
28
31
|
};
|
|
29
|
-
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
30
|
-
new (): {
|
|
31
|
-
$slots: S;
|
|
32
|
-
};
|
|
33
|
-
};
|