@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
package/package.json
CHANGED
package/src/index.css
CHANGED
|
@@ -32,17 +32,6 @@
|
|
|
32
32
|
h6 {
|
|
33
33
|
@apply text-xs leading-4 font-semibold;
|
|
34
34
|
}
|
|
35
|
-
|
|
36
|
-
/* Forms: here for backward compatibility. Use <BaseInput> instead. */
|
|
37
|
-
[type="text"],
|
|
38
|
-
[type="email"],
|
|
39
|
-
[type="password"],
|
|
40
|
-
[type="number"],
|
|
41
|
-
[type="search"],
|
|
42
|
-
[type="tel"],
|
|
43
|
-
textarea {
|
|
44
|
-
@apply mt-1 shadow-sm focus:ring-xy-blue-500 focus:border-xy-blue block w-full sm:text-sm border-gray-600 rounded-md;
|
|
45
|
-
}
|
|
46
35
|
}
|
|
47
36
|
|
|
48
37
|
@layer components {
|
|
@@ -131,9 +120,4 @@
|
|
|
131
120
|
.max-h-screen-1\/2 {
|
|
132
121
|
max-height: 50vh;
|
|
133
122
|
}
|
|
134
|
-
|
|
135
|
-
/* Forms */
|
|
136
|
-
.xy-input-error {
|
|
137
|
-
@apply focus:ring-red-700 focus:border-red-700 text-red-900 placeholder-red-700 placeholder-opacity-75 border-red-700;
|
|
138
|
-
}
|
|
139
123
|
}
|
|
@@ -1,13 +1,29 @@
|
|
|
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
|
-
|
|
8
|
-
|
|
6
|
+
defineOptions({
|
|
7
|
+
inheritAttrs: false,
|
|
8
|
+
})
|
|
9
|
+
|
|
10
|
+
type TextLikeInputs =
|
|
11
|
+
| "date"
|
|
12
|
+
| "datetime-local"
|
|
13
|
+
| "email"
|
|
14
|
+
| "month"
|
|
15
|
+
| "number"
|
|
16
|
+
| "password"
|
|
17
|
+
| "search"
|
|
18
|
+
| "tel"
|
|
19
|
+
| "text"
|
|
20
|
+
| "time"
|
|
21
|
+
| "url"
|
|
22
|
+
| "week"
|
|
23
|
+
|
|
24
|
+
withDefaults(
|
|
9
25
|
defineProps<{
|
|
10
|
-
type:
|
|
26
|
+
type: TextLikeInputs
|
|
11
27
|
help?: string
|
|
12
28
|
label?: string
|
|
13
29
|
modelValue?: string | number
|
|
@@ -20,68 +36,34 @@ const props = withDefaults(
|
|
|
20
36
|
)
|
|
21
37
|
|
|
22
38
|
const emit = defineEmits(["update:modelValue"])
|
|
23
|
-
|
|
24
|
-
const uuid = (attrs.id as string) || Uniques.CreateIdAttribute()
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* common text based inputs
|
|
28
|
-
*/
|
|
29
|
-
const textInputTypes = [
|
|
30
|
-
"date",
|
|
31
|
-
"datetime-local",
|
|
32
|
-
"email",
|
|
33
|
-
"month",
|
|
34
|
-
"number",
|
|
35
|
-
"password",
|
|
36
|
-
"search",
|
|
37
|
-
"tel",
|
|
38
|
-
"text",
|
|
39
|
-
"time",
|
|
40
|
-
"url",
|
|
41
|
-
"week",
|
|
42
|
-
]
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* determine if this input is a common text based input
|
|
46
|
-
*/
|
|
47
|
-
const isTextType = computed((): boolean => {
|
|
48
|
-
return typeof props.type === "string" && textInputTypes.includes(props.type)
|
|
49
|
-
})
|
|
39
|
+
const { inputID, isValid } = useInputField()
|
|
50
40
|
</script>
|
|
41
|
+
|
|
51
42
|
<template>
|
|
52
|
-
<
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
:placeholder="label"
|
|
79
|
-
:type="type"
|
|
80
|
-
:value="modelValue"
|
|
81
|
-
v-bind="$attrs"
|
|
82
|
-
@input="
|
|
83
|
-
emit('update:modelValue', ($event.target as HTMLInputElement).value)
|
|
84
|
-
"
|
|
85
|
-
/>
|
|
86
|
-
<InputHelp :id="`${uuid}-help`" :text="help"></InputHelp>
|
|
43
|
+
<div>
|
|
44
|
+
<div class="mb-1">
|
|
45
|
+
<InputLabel :id="`${inputID}-label`" :for="inputID" :label="label" />
|
|
46
|
+
</div>
|
|
47
|
+
<input
|
|
48
|
+
:id="inputID"
|
|
49
|
+
:aria-labelledby="label ? `${inputID}-label` : undefined"
|
|
50
|
+
:aria-describedby="help ? `${inputID}-help` : undefined"
|
|
51
|
+
:class="[
|
|
52
|
+
'block w-full rounded-md border-0 py-2 shadow-sm ring-1 ring-inset focus:ring-2 sm:text-sm sm:leading-6',
|
|
53
|
+
'disabled:cursor-not-allowed disabled:bg-gray-50 disabled:text-gray-600 disabled:ring-gray-200',
|
|
54
|
+
isValid
|
|
55
|
+
? 'text-gray-800 ring-gray-300 placeholder:text-gray-400 focus:ring-xy-blue-500'
|
|
56
|
+
: 'text-red-900 ring-red-700 placeholder:text-red-300 focus:ring-red-700',
|
|
57
|
+
]"
|
|
58
|
+
:type="type"
|
|
59
|
+
:value="modelValue"
|
|
60
|
+
v-bind="$attrs"
|
|
61
|
+
@input="
|
|
62
|
+
emit('update:modelValue', ($event.target as HTMLInputElement).value)
|
|
63
|
+
"
|
|
64
|
+
/>
|
|
65
|
+
<div class="mt-1">
|
|
66
|
+
<InputHelp :id="`${inputID}-help`" :text="help" />
|
|
67
|
+
</div>
|
|
68
|
+
</div>
|
|
87
69
|
</template>
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import InputLabel from "./InputLabel.vue"
|
|
3
3
|
import InputHelp from "./InputHelp.vue"
|
|
4
|
-
import
|
|
5
|
-
|
|
4
|
+
import { useInputField } from "@/composables/forms"
|
|
5
|
+
|
|
6
|
+
defineOptions({
|
|
7
|
+
inheritAttrs: false,
|
|
8
|
+
})
|
|
6
9
|
|
|
7
10
|
withDefaults(
|
|
8
11
|
defineProps<{
|
|
@@ -16,18 +19,24 @@ withDefaults(
|
|
|
16
19
|
}
|
|
17
20
|
)
|
|
18
21
|
const emits = defineEmits(["update:modelValue"])
|
|
19
|
-
const
|
|
20
|
-
const uuid = (attrs.id as string) || Uniques.CreateIdAttribute()
|
|
22
|
+
const { inputID, isDisabled, isValid } = useInputField()
|
|
21
23
|
</script>
|
|
24
|
+
|
|
22
25
|
<template>
|
|
23
26
|
<div class="relative flex items-start">
|
|
24
|
-
<div class="flex items-center h-
|
|
27
|
+
<div class="flex items-center h-6">
|
|
25
28
|
<input
|
|
26
|
-
:id="
|
|
27
|
-
:aria-labelledby="label ? `${
|
|
28
|
-
:aria-describedby="help ? `${
|
|
29
|
+
:id="inputID"
|
|
30
|
+
:aria-labelledby="label ? `${inputID}-label` : undefined"
|
|
31
|
+
:aria-describedby="help ? `${inputID}-help` : undefined"
|
|
29
32
|
:checked="modelValue"
|
|
30
|
-
class="
|
|
33
|
+
:class="[
|
|
34
|
+
'h-4 w-4 rounded',
|
|
35
|
+
'border-gray-300 text-xy-blue',
|
|
36
|
+
'disabled:bg-gray-100 disabled:border-gray-200 disabled:cursor-not-allowed disabled:opacity-100',
|
|
37
|
+
'checked:disabled:bg-xy-blue checked:disabled:border-xy-blue checked:disabled:opacity-50',
|
|
38
|
+
isValid ? 'focus:ring-xy-blue-500' : 'focus:ring-red-700',
|
|
39
|
+
]"
|
|
31
40
|
type="checkbox"
|
|
32
41
|
v-bind="{
|
|
33
42
|
onChange: ($event) => {
|
|
@@ -39,15 +48,12 @@ const uuid = (attrs.id as string) || Uniques.CreateIdAttribute()
|
|
|
39
48
|
</div>
|
|
40
49
|
<div class="ml-3">
|
|
41
50
|
<InputLabel
|
|
42
|
-
:id="`${
|
|
43
|
-
|
|
44
|
-
:disabled="
|
|
45
|
-
$attrs.hasOwnProperty('disabled') && $attrs.disabled !== false
|
|
46
|
-
"
|
|
47
|
-
:for="uuid"
|
|
51
|
+
:id="`${inputID}-label`"
|
|
52
|
+
:for="inputID"
|
|
48
53
|
:label="label"
|
|
54
|
+
:class="isDisabled && 'cursor-not-allowed'"
|
|
49
55
|
/>
|
|
50
|
-
<InputHelp :id="`${
|
|
56
|
+
<InputHelp :id="`${inputID}-help`" :text="help"></InputHelp>
|
|
51
57
|
</div>
|
|
52
58
|
</div>
|
|
53
59
|
</template>
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import Uniques from "@/helpers/Uniques"
|
|
3
2
|
import flatpickr from "flatpickr"
|
|
4
3
|
import "flatpickr/dist/flatpickr.min.css"
|
|
5
|
-
import { onMounted
|
|
4
|
+
import { onMounted } from "vue"
|
|
6
5
|
import BaseInput from "./BaseInput.vue"
|
|
6
|
+
import { useInputField } from "@/composables/forms"
|
|
7
|
+
|
|
8
|
+
defineOptions({
|
|
9
|
+
inheritAttrs: false,
|
|
10
|
+
})
|
|
7
11
|
|
|
8
12
|
const props = withDefaults(
|
|
9
13
|
defineProps<{
|
|
@@ -25,8 +29,7 @@ const props = withDefaults(
|
|
|
25
29
|
)
|
|
26
30
|
|
|
27
31
|
const emits = defineEmits(["update:modelValue"])
|
|
28
|
-
const
|
|
29
|
-
const uuid = (attrs.id as string) || Uniques.CreateIdAttribute()
|
|
32
|
+
const { inputID } = useInputField()
|
|
30
33
|
|
|
31
34
|
const updateModelValue = (value: { minDate: number; maxDate: number }) => {
|
|
32
35
|
emits("update:modelValue", value)
|
|
@@ -84,15 +87,16 @@ onMounted(() => {
|
|
|
84
87
|
}
|
|
85
88
|
}
|
|
86
89
|
|
|
87
|
-
flatpickr(`#${
|
|
90
|
+
flatpickr(`#${inputID.value}`, opts)
|
|
88
91
|
})
|
|
89
92
|
</script>
|
|
93
|
+
|
|
90
94
|
<template>
|
|
91
95
|
<BaseInput
|
|
92
|
-
:id="
|
|
96
|
+
:id="inputID"
|
|
93
97
|
type="text"
|
|
94
98
|
placeholder="mm-dd-yyyy range"
|
|
95
99
|
:label="label"
|
|
96
100
|
:help="help"
|
|
97
|
-
|
|
101
|
+
/>
|
|
98
102
|
</template>
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { hasSlotContent } from "@/helpers/Slots"
|
|
3
2
|
withDefaults(
|
|
4
3
|
defineProps<{
|
|
4
|
+
label?: string
|
|
5
5
|
tag?: string
|
|
6
6
|
}>(),
|
|
7
7
|
{
|
|
8
|
+
label: "",
|
|
8
9
|
tag: "legend",
|
|
9
10
|
}
|
|
10
11
|
)
|
|
11
12
|
</script>
|
|
13
|
+
|
|
12
14
|
<template>
|
|
13
15
|
<component
|
|
14
16
|
:is="tag"
|
|
15
|
-
v-if="
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
class: 'text-sm font-semibold leading-snug text-gray-900',
|
|
19
|
-
}"
|
|
17
|
+
v-if="label"
|
|
18
|
+
class="block text-base/6 font-medium text-gray-800"
|
|
19
|
+
v-bind="$attrs"
|
|
20
20
|
>
|
|
21
|
-
|
|
21
|
+
{{ label }}
|
|
22
22
|
</component>
|
|
23
23
|
</template>
|
|
@@ -14,10 +14,8 @@ withDefaults(
|
|
|
14
14
|
<component
|
|
15
15
|
:is="tag"
|
|
16
16
|
v-if="text"
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
class: 'mt-1 text-sm leading-snug font-normal text-gray-700',
|
|
20
|
-
}"
|
|
17
|
+
class="text-sm leading-6 font-normal text-gray-600"
|
|
18
|
+
v-bind="$attrs"
|
|
21
19
|
>
|
|
22
20
|
{{ text }}
|
|
23
21
|
</component>
|
|
@@ -1,28 +1,23 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
withDefaults(
|
|
3
3
|
defineProps<{
|
|
4
|
-
disabled?: boolean
|
|
5
4
|
label?: string
|
|
6
5
|
tag?: string
|
|
7
6
|
}>(),
|
|
8
7
|
{
|
|
9
|
-
disabled: false,
|
|
10
8
|
label: "",
|
|
11
9
|
tag: "label",
|
|
12
10
|
}
|
|
13
11
|
)
|
|
14
12
|
</script>
|
|
13
|
+
|
|
15
14
|
<template>
|
|
16
15
|
<component
|
|
17
16
|
:is="tag"
|
|
18
17
|
v-if="label"
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
'opacity-75': disabled,
|
|
22
|
-
}"
|
|
23
|
-
v-bind="{
|
|
24
|
-
...$attrs,
|
|
25
|
-
}"
|
|
26
|
-
>{{ label }}</component
|
|
18
|
+
class="block text-sm/6 font-medium text-gray-800"
|
|
19
|
+
v-bind="$attrs"
|
|
27
20
|
>
|
|
21
|
+
{{ label }}
|
|
22
|
+
</component>
|
|
28
23
|
</template>
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import Uniques from "@/helpers/Uniques"
|
|
3
|
-
import { computed, useAttrs, useSlots } from "vue"
|
|
4
2
|
import FieldsetLegend from "./FieldsetLegend.vue"
|
|
5
3
|
import InputLabel from "./InputLabel.vue"
|
|
6
4
|
import InputHelp from "./InputHelp.vue"
|
|
5
|
+
import { useInputField } from "@/composables/forms"
|
|
6
|
+
|
|
7
|
+
defineOptions({
|
|
8
|
+
inheritAttrs: false,
|
|
9
|
+
})
|
|
7
10
|
|
|
8
11
|
type CheckboxValue = string | number
|
|
9
12
|
type ModelValue = CheckboxValue[]
|
|
@@ -17,13 +20,13 @@ const props = withDefaults(
|
|
|
17
20
|
value: CheckboxValue
|
|
18
21
|
}[]
|
|
19
22
|
help?: string
|
|
20
|
-
|
|
23
|
+
label?: string
|
|
21
24
|
modelValue: ModelValue
|
|
22
|
-
columns?: 2 | 3
|
|
25
|
+
columns?: 2 | 3
|
|
23
26
|
}>(),
|
|
24
27
|
{
|
|
25
28
|
help: "",
|
|
26
|
-
|
|
29
|
+
label: "",
|
|
27
30
|
columns: undefined,
|
|
28
31
|
}
|
|
29
32
|
)
|
|
@@ -31,12 +34,9 @@ const props = withDefaults(
|
|
|
31
34
|
const emit = defineEmits<{
|
|
32
35
|
(e: "update:modelValue", modelValue: ModelValue): void
|
|
33
36
|
}>()
|
|
34
|
-
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
const hasLegend = computed(() => {
|
|
38
|
-
return props.legend !== "" || slots.legend !== undefined
|
|
39
|
-
})
|
|
37
|
+
|
|
38
|
+
const { inputID, isDisabled } = useInputField()
|
|
39
|
+
|
|
40
40
|
const onChange = (checked: boolean, val: CheckboxValue) => {
|
|
41
41
|
let updateModelValue = [...props.modelValue]
|
|
42
42
|
|
|
@@ -49,27 +49,25 @@ const onChange = (checked: boolean, val: CheckboxValue) => {
|
|
|
49
49
|
emit("update:modelValue", updateModelValue)
|
|
50
50
|
}
|
|
51
51
|
</script>
|
|
52
|
+
|
|
52
53
|
<template>
|
|
53
54
|
<fieldset
|
|
54
55
|
class="space-y-5"
|
|
55
|
-
:aria-labelledby="
|
|
56
|
-
:aria-describedby="help ? `${
|
|
56
|
+
:aria-labelledby="label ? `${inputID}-legend` : undefined"
|
|
57
|
+
:aria-describedby="help ? `${inputID}-help` : undefined"
|
|
57
58
|
>
|
|
58
|
-
<div v-if="
|
|
59
|
-
<FieldsetLegend :id="`${
|
|
60
|
-
|
|
61
|
-
<slot v-if="$slots.legend" name="legend"></slot>
|
|
62
|
-
</FieldsetLegend>
|
|
63
|
-
<InputHelp :id="`${uuid}-help`" tag="p" :text="help" />
|
|
59
|
+
<div v-if="label">
|
|
60
|
+
<FieldsetLegend :id="`${inputID}-legend`" :label="label" />
|
|
61
|
+
<InputHelp v-if="help" :id="`${inputID}-help`" tag="p" :text="help" />
|
|
64
62
|
</div>
|
|
63
|
+
|
|
65
64
|
<div class="flex">
|
|
66
65
|
<div
|
|
67
|
-
class="grid gap-
|
|
66
|
+
class="grid gap-y-5"
|
|
68
67
|
:class="{
|
|
69
|
-
'sm:grid sm:gap-
|
|
68
|
+
'sm:grid sm:gap-x-5 sm:space-y-0': columns !== undefined,
|
|
70
69
|
'sm:grid-cols-2': columns === 2,
|
|
71
70
|
'sm:grid-cols-3': columns === 3,
|
|
72
|
-
'sm:grid-cols-4': columns === 4,
|
|
73
71
|
}"
|
|
74
72
|
>
|
|
75
73
|
<div
|
|
@@ -77,18 +75,21 @@ const onChange = (checked: boolean, val: CheckboxValue) => {
|
|
|
77
75
|
:key="option.value"
|
|
78
76
|
class="flex items-start"
|
|
79
77
|
>
|
|
80
|
-
<div class="flex items-center h-
|
|
78
|
+
<div class="flex items-center h-6">
|
|
81
79
|
<input
|
|
82
|
-
:id="`${
|
|
83
|
-
:aria-labelledby="`${
|
|
80
|
+
:id="`${inputID}-${index}`"
|
|
81
|
+
:aria-labelledby="`${inputID}-${index}-label`"
|
|
84
82
|
:aria-describedby="
|
|
85
|
-
option
|
|
86
|
-
? `${uuid}-${index}-help`
|
|
87
|
-
: undefined
|
|
83
|
+
option.help ? `${inputID}-${index}-help` : undefined
|
|
88
84
|
"
|
|
89
85
|
:checked="modelValue.includes(option.value)"
|
|
90
|
-
:disabled="option.disabled
|
|
91
|
-
class="
|
|
86
|
+
:disabled="option.disabled"
|
|
87
|
+
:class="[
|
|
88
|
+
'h-4 w-4 rounded',
|
|
89
|
+
'border-gray-300 text-xy-blue focus:ring-xy-blue-500',
|
|
90
|
+
'disabled:bg-gray-100 disabled:border-gray-200 disabled:cursor-not-allowed disabled:opacity-100',
|
|
91
|
+
'checked:disabled:bg-xy-blue checked:disabled:border-xy-blue checked:disabled:opacity-50',
|
|
92
|
+
]"
|
|
92
93
|
type="checkbox"
|
|
93
94
|
v-bind="{
|
|
94
95
|
onChange: ($event) => {
|
|
@@ -100,21 +101,12 @@ const onChange = (checked: boolean, val: CheckboxValue) => {
|
|
|
100
101
|
</div>
|
|
101
102
|
<div class="ml-3">
|
|
102
103
|
<InputLabel
|
|
103
|
-
:id="`${
|
|
104
|
-
|
|
105
|
-
:disabled="
|
|
106
|
-
($attrs.hasOwnProperty('disabled') &&
|
|
107
|
-
$attrs.disabled !== false) ||
|
|
108
|
-
option.disabled === true
|
|
109
|
-
"
|
|
110
|
-
:for="`${uuid}-${index}`"
|
|
104
|
+
:id="`${inputID}-${index}-label`"
|
|
105
|
+
:for="`${inputID}-${index}`"
|
|
111
106
|
:label="option.label"
|
|
107
|
+
:class="(isDisabled || option.disabled) && 'cursor-not-allowed'"
|
|
112
108
|
/>
|
|
113
|
-
<InputHelp
|
|
114
|
-
:id="`${uuid}-${index}-help`"
|
|
115
|
-
class="-mt-1"
|
|
116
|
-
:text="option.help"
|
|
117
|
-
/>
|
|
109
|
+
<InputHelp :id="`${inputID}-${index}-help`" :text="option.help" />
|
|
118
110
|
</div>
|
|
119
111
|
</div>
|
|
120
112
|
</div>
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import Uniques from "@/helpers/Uniques"
|
|
3
|
-
import { computed, useAttrs, useSlots } from "vue"
|
|
4
2
|
import FieldsetLegend from "./FieldsetLegend.vue"
|
|
5
3
|
import InputHelp from "./InputHelp.vue"
|
|
6
4
|
import InputLabel from "./InputLabel.vue"
|
|
5
|
+
import { useInputField } from "@/composables/forms"
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
defineOptions({
|
|
8
|
+
inheritAttrs: false,
|
|
9
|
+
})
|
|
10
|
+
|
|
11
|
+
withDefaults(
|
|
9
12
|
defineProps<{
|
|
10
13
|
options: {
|
|
11
14
|
disabled?: boolean
|
|
@@ -14,46 +17,39 @@ const props = withDefaults(
|
|
|
14
17
|
value: string | number
|
|
15
18
|
}[]
|
|
16
19
|
help?: string
|
|
17
|
-
|
|
20
|
+
label?: string
|
|
18
21
|
modelValue?: string | number
|
|
19
|
-
columns?: 2 | 3
|
|
22
|
+
columns?: 2 | 3
|
|
20
23
|
}>(),
|
|
21
24
|
{
|
|
22
25
|
help: "",
|
|
23
|
-
|
|
26
|
+
label: "",
|
|
24
27
|
modelValue: undefined,
|
|
25
28
|
columns: undefined,
|
|
26
29
|
}
|
|
27
30
|
)
|
|
28
31
|
const emits = defineEmits(["update:modelValue"])
|
|
29
|
-
const
|
|
30
|
-
const slots = useSlots()
|
|
31
|
-
const uuid = (attrs.id as string) || Uniques.CreateIdAttribute()
|
|
32
|
-
const hasLegend = computed(() => {
|
|
33
|
-
return props.legend !== "" || slots.legend !== undefined
|
|
34
|
-
})
|
|
32
|
+
const { inputID, isDisabled } = useInputField()
|
|
35
33
|
</script>
|
|
34
|
+
|
|
36
35
|
<template>
|
|
37
36
|
<fieldset
|
|
38
37
|
class="space-y-5"
|
|
39
|
-
:aria-labelledby="
|
|
40
|
-
:aria-describedby="help ? `${
|
|
38
|
+
:aria-labelledby="label ? `${inputID}-legend` : undefined"
|
|
39
|
+
:aria-describedby="help ? `${inputID}-help` : undefined"
|
|
41
40
|
>
|
|
42
|
-
<div v-if="
|
|
43
|
-
<FieldsetLegend :id="`${
|
|
44
|
-
|
|
45
|
-
<slot v-if="$slots.legend" name="legend"></slot>
|
|
46
|
-
</FieldsetLegend>
|
|
47
|
-
<InputHelp :id="`${uuid}-help`" tag="p" :text="help" />
|
|
41
|
+
<div v-if="label">
|
|
42
|
+
<FieldsetLegend :id="`${inputID}-legend`" :label="label" />
|
|
43
|
+
<InputHelp v-if="help" :id="`${inputID}-help`" tag="p" :text="help" />
|
|
48
44
|
</div>
|
|
45
|
+
|
|
49
46
|
<div class="flex">
|
|
50
47
|
<div
|
|
51
|
-
class="grid gap-
|
|
48
|
+
class="grid gap-y-5"
|
|
52
49
|
:class="{
|
|
53
|
-
'sm:grid sm:gap-
|
|
50
|
+
'sm:grid sm:gap-x-5 sm:space-y-0': columns !== undefined,
|
|
54
51
|
'sm:grid-cols-2': columns === 2,
|
|
55
52
|
'sm:grid-cols-3': columns === 3,
|
|
56
|
-
'sm:grid-cols-4': columns === 4,
|
|
57
53
|
}"
|
|
58
54
|
>
|
|
59
55
|
<div
|
|
@@ -61,19 +57,22 @@ const hasLegend = computed(() => {
|
|
|
61
57
|
:key="option.value"
|
|
62
58
|
class="flex items-start"
|
|
63
59
|
>
|
|
64
|
-
<div class="flex items-center h-
|
|
60
|
+
<div class="flex items-center h-6">
|
|
65
61
|
<input
|
|
66
|
-
:id="`${
|
|
62
|
+
:id="`${inputID}-${index}`"
|
|
67
63
|
:aria-describedby="
|
|
68
|
-
option
|
|
69
|
-
? `${uuid}-${index}-help`
|
|
70
|
-
: undefined
|
|
64
|
+
option.help ? `${inputID}-${index}-help` : undefined
|
|
71
65
|
"
|
|
72
|
-
:aria-labelledby="`${
|
|
66
|
+
:aria-labelledby="`${inputID}-${index}-label`"
|
|
73
67
|
:checked="modelValue === option.value"
|
|
74
|
-
class="
|
|
75
|
-
|
|
76
|
-
|
|
68
|
+
:class="[
|
|
69
|
+
'h-4 w-4',
|
|
70
|
+
'border-gray-300 text-xy-blue focus:ring-xy-blue-500',
|
|
71
|
+
'disabled:bg-gray-100 disabled:border-gray-200 disabled:cursor-not-allowed disabled:opacity-100',
|
|
72
|
+
'checked:disabled:bg-xy-blue checked:disabled:border-xy-blue checked:disabled:opacity-50',
|
|
73
|
+
]"
|
|
74
|
+
:disabled="option.disabled"
|
|
75
|
+
:name="inputID"
|
|
77
76
|
type="radio"
|
|
78
77
|
:value="option.value"
|
|
79
78
|
v-bind="{
|
|
@@ -86,21 +85,13 @@ const hasLegend = computed(() => {
|
|
|
86
85
|
</div>
|
|
87
86
|
<div class="ml-3">
|
|
88
87
|
<InputLabel
|
|
89
|
-
:id="`${
|
|
90
|
-
|
|
91
|
-
:disabled="
|
|
92
|
-
($attrs.hasOwnProperty('disabled') &&
|
|
93
|
-
$attrs.disabled !== false) ||
|
|
94
|
-
option.disabled === true
|
|
95
|
-
"
|
|
96
|
-
:for="`${uuid}-${index}`"
|
|
88
|
+
:id="`${inputID}-${index}-label`"
|
|
89
|
+
:for="`${inputID}-${index}`"
|
|
97
90
|
:label="option.label"
|
|
91
|
+
:class="(isDisabled || option.disabled) && 'cursor-not-allowed'"
|
|
98
92
|
/>
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
class="-mt-1"
|
|
102
|
-
:text="option.help"
|
|
103
|
-
/>
|
|
93
|
+
|
|
94
|
+
<InputHelp :id="`${inputID}-${index}-help`" :text="option.help" />
|
|
104
95
|
</div>
|
|
105
96
|
</div>
|
|
106
97
|
</div>
|