srcdev-nuxt-forms 6.1.0 → 6.1.2
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/app/assets/styles/extends-layer/srcdev-forms/components/_input-description.css +13 -0
- package/app/assets/styles/extends-layer/srcdev-forms/components/index.css +10 -9
- package/app/assets/styles/setup/theming/themes/_default.css +3 -0
- package/app/assets/styles/setup/theming/themes/_error.css +4 -1
- package/app/assets/styles/setup/theming/themes/_secondary.css +4 -1
- package/app/assets/styles/setup/theming/themes/_success.css +4 -1
- package/app/assets/styles/setup/theming/themes/_warning.css +4 -1
- package/app/assets/styles/setup/utility-classes/_margin.css +334 -0
- package/app/assets/styles/setup/utility-classes/_padding.css +308 -0
- package/app/assets/styles/setup/utility-classes/index.css +4 -2
- package/app/components/forms/form-fieldset/FormFieldset.vue +19 -10
- package/app/components/forms/input-button/InputButtonCore.vue +25 -28
- package/app/components/forms/input-checkbox/MultipleCheckboxes.vue +48 -38
- package/app/components/forms/input-checkbox/SingleCheckbox.vue +52 -33
- package/app/components/forms/input-checkbox-radio/InputCheckboxRadioButton.vue +40 -22
- package/app/components/forms/input-checkbox-radio/InputCheckboxRadioWithLabel.vue +33 -17
- package/app/components/forms/input-description/InputDescription.vue +71 -0
- package/app/components/forms/input-label/InputLabel.vue +14 -12
- package/app/components/forms/input-number/InputNumberCore.vue +26 -22
- package/app/components/forms/input-number/variants/InputNumberDefault.vue +50 -27
- package/app/components/forms/input-radio/MultipleRadiobuttons.vue +31 -25
- package/app/components/forms/input-range/InputRangeCore.vue +30 -28
- package/app/components/forms/input-range/variants/InputRangeDefault.vue +45 -28
- package/app/components/forms/input-range-fancy/InputRangeFancyWithLabel.vue +31 -18
- package/app/components/forms/input-select/variants/InputSelectWithLabel.vue +80 -45
- package/app/components/forms/input-text/InputTextCore.vue +4 -6
- package/app/components/forms/input-text/variants/InputTextAsNumberWithLabel.vue +42 -33
- package/app/components/forms/input-text/variants/InputTextWithLabel.vue +83 -50
- package/app/components/forms/input-textarea/InputTextareaCore.vue +34 -25
- package/app/components/forms/input-textarea/variants/InputTextareaWithLabel.vue +100 -50
- package/app/components/forms/toggle-switch/ToggleSwitchCore.vue +43 -25
- package/app/components/forms/toggle-switch/ToggleSwitchCoreOld.vue +36 -22
- package/app/components/forms/toggle-switch/variants/ToggleSwitchWithLabel.vue +42 -25
- package/app/components/forms/toggle-switch/variants/ToggleSwitchWithLabelInline.vue +30 -26
- package/package.json +1 -1
|
@@ -3,9 +3,16 @@
|
|
|
3
3
|
class="input-textarea-wrapper"
|
|
4
4
|
:data-theme="formTheme"
|
|
5
5
|
:data-size="size"
|
|
6
|
-
:class="[
|
|
6
|
+
:class="[
|
|
7
|
+
inputVariant,
|
|
8
|
+
{ dirty: isDirty },
|
|
9
|
+
{ active: isActive },
|
|
10
|
+
{ error: fieldHasError },
|
|
11
|
+
{ 'has-left-slot': slots.left },
|
|
12
|
+
{ 'has-right-slot': slots.right },
|
|
13
|
+
]"
|
|
7
14
|
>
|
|
8
|
-
<span v-if="
|
|
15
|
+
<span v-if="slots.left" class="slot left-slot">
|
|
9
16
|
<slot name="left"></slot>
|
|
10
17
|
</span>
|
|
11
18
|
|
|
@@ -19,19 +26,19 @@
|
|
|
19
26
|
v-model="modelValue"
|
|
20
27
|
ref="inputField"
|
|
21
28
|
:aria-invalid="fieldHasError"
|
|
22
|
-
:aria-describedby
|
|
29
|
+
:aria-describedby
|
|
23
30
|
@focusin="updateFocus(true)"
|
|
24
31
|
@focusout="updateFocus(false)"
|
|
25
32
|
></textarea>
|
|
26
33
|
|
|
27
|
-
<span v-if="
|
|
34
|
+
<span v-if="slots.right" class="slot right-slot">
|
|
28
35
|
<slot name="right"></slot>
|
|
29
36
|
</span>
|
|
30
37
|
</div>
|
|
31
38
|
</template>
|
|
32
39
|
|
|
33
40
|
<script setup lang="ts">
|
|
34
|
-
import propValidators from
|
|
41
|
+
import propValidators from "../c12/prop-validators"
|
|
35
42
|
const props = defineProps({
|
|
36
43
|
maxlength: {
|
|
37
44
|
type: Number,
|
|
@@ -47,7 +54,11 @@ const props = defineProps({
|
|
|
47
54
|
},
|
|
48
55
|
placeholder: {
|
|
49
56
|
type: String,
|
|
50
|
-
default:
|
|
57
|
+
default: "",
|
|
58
|
+
},
|
|
59
|
+
ariaDescribedby: {
|
|
60
|
+
type: String,
|
|
61
|
+
default: "",
|
|
51
62
|
},
|
|
52
63
|
fieldHasError: {
|
|
53
64
|
type: Boolean,
|
|
@@ -63,46 +74,44 @@ const props = defineProps({
|
|
|
63
74
|
},
|
|
64
75
|
theme: {
|
|
65
76
|
type: String as PropType<string>,
|
|
66
|
-
default:
|
|
77
|
+
default: "primary",
|
|
67
78
|
validator(value: string) {
|
|
68
|
-
return propValidators.theme.includes(value)
|
|
79
|
+
return propValidators.theme.includes(value)
|
|
69
80
|
},
|
|
70
81
|
},
|
|
71
82
|
size: {
|
|
72
83
|
type: String as PropType<string>,
|
|
73
|
-
default:
|
|
84
|
+
default: "default",
|
|
74
85
|
validator(value: string) {
|
|
75
|
-
return propValidators.size.includes(value)
|
|
86
|
+
return propValidators.size.includes(value)
|
|
76
87
|
},
|
|
77
88
|
},
|
|
78
89
|
inputVariant: {
|
|
79
90
|
type: String as PropType<string>,
|
|
80
|
-
default:
|
|
91
|
+
default: "normal",
|
|
81
92
|
validator(value: string) {
|
|
82
|
-
return propValidators.inputVariant.includes(value)
|
|
93
|
+
return propValidators.inputVariant.includes(value)
|
|
83
94
|
},
|
|
84
95
|
},
|
|
85
|
-
})
|
|
96
|
+
})
|
|
86
97
|
|
|
87
|
-
const slots = useSlots()
|
|
88
|
-
const hasLeftSlot = computed(() => slots.left !== undefined);
|
|
89
|
-
const hasRightSlot = computed(() => slots.right !== undefined);
|
|
98
|
+
const slots = useSlots()
|
|
90
99
|
|
|
91
100
|
const formTheme = computed(() => {
|
|
92
|
-
return props.fieldHasError ?
|
|
93
|
-
})
|
|
101
|
+
return props.fieldHasError ? "error" : props.theme
|
|
102
|
+
})
|
|
94
103
|
|
|
95
|
-
const modelValue = defineModel<string | number | readonly string[] | null | undefined>()
|
|
96
|
-
const isDirty = defineModel(
|
|
97
|
-
const isActive = defineModel(
|
|
104
|
+
const modelValue = defineModel<string | number | readonly string[] | null | undefined>()
|
|
105
|
+
const isDirty = defineModel("isDirty")
|
|
106
|
+
const isActive = defineModel("isActive")
|
|
98
107
|
|
|
99
108
|
const updateFocus = (isFocused: boolean) => {
|
|
100
|
-
isActive.value = isFocused
|
|
101
|
-
}
|
|
109
|
+
isActive.value = isFocused
|
|
110
|
+
}
|
|
102
111
|
|
|
103
|
-
const inputField = ref<HTMLInputElement | null>(null)
|
|
112
|
+
const inputField = ref<HTMLInputElement | null>(null)
|
|
104
113
|
|
|
105
|
-
const { elementClasses } = useStyleClassPassthrough(props.styleClassPassthrough)
|
|
114
|
+
const { elementClasses } = useStyleClassPassthrough(props.styleClassPassthrough)
|
|
106
115
|
</script>
|
|
107
116
|
|
|
108
117
|
<style lang="css">
|
|
@@ -1,38 +1,84 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div
|
|
3
|
-
<
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
<div>
|
|
3
|
+
<div
|
|
4
|
+
class="input-textarea-with-label"
|
|
5
|
+
:data-theme="formTheme"
|
|
6
|
+
:class="[elementClasses, inputVariant, { dirty: isDirty }, { active: isActive }]"
|
|
7
|
+
>
|
|
8
|
+
<InputLabel
|
|
9
|
+
:for="id"
|
|
10
|
+
:id
|
|
11
|
+
:theme
|
|
12
|
+
:name
|
|
13
|
+
:input-variant
|
|
14
|
+
:field-has-error
|
|
15
|
+
:style-class-passthrough="['input-textarea-label']"
|
|
16
|
+
>
|
|
17
|
+
<template #textLabel>{{ label }}</template>
|
|
18
|
+
</InputLabel>
|
|
19
|
+
|
|
20
|
+
<InputDescription
|
|
21
|
+
v-if="inputVariant !== 'outlined'"
|
|
22
|
+
:id
|
|
23
|
+
:name
|
|
24
|
+
:input-variant
|
|
25
|
+
:field-has-error="fieldHasError"
|
|
26
|
+
:style-class-passthrough="['input-text-description']"
|
|
27
|
+
>
|
|
28
|
+
<template v-if="slots.descriptionHtml" #descriptionHtml>
|
|
29
|
+
<slot name="descriptionHtml"></slot>
|
|
30
|
+
</template>
|
|
31
|
+
<template v-if="slots.descriptionText" #descriptionText>
|
|
32
|
+
<slot name="descriptionText"></slot>
|
|
33
|
+
</template>
|
|
34
|
+
</InputDescription>
|
|
6
35
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
36
|
+
<InputTextareaCore
|
|
37
|
+
v-model="modelValue"
|
|
38
|
+
v-model:isDirty="isDirty"
|
|
39
|
+
v-model:isActive="isActive"
|
|
40
|
+
:maxlength
|
|
41
|
+
:id
|
|
42
|
+
:name
|
|
43
|
+
:placeholder
|
|
44
|
+
:label
|
|
45
|
+
:field-has-error
|
|
46
|
+
:required
|
|
47
|
+
:style-class-passthrough
|
|
48
|
+
:theme
|
|
49
|
+
:size
|
|
50
|
+
:input-variant
|
|
51
|
+
>
|
|
52
|
+
<template v-if="slots.left" #left>
|
|
53
|
+
<slot name="left"></slot>
|
|
54
|
+
</template>
|
|
55
|
+
<template v-if="slots.right" #right>
|
|
56
|
+
<slot name="right"></slot>
|
|
57
|
+
</template>
|
|
58
|
+
</InputTextareaCore>
|
|
59
|
+
<InputError :errorMessage :showError="fieldHasError" :id :isDetached="false" :inputVariant />
|
|
60
|
+
</div>
|
|
61
|
+
|
|
62
|
+
<InputDescription
|
|
63
|
+
v-if="inputVariant === 'outlined'"
|
|
12
64
|
:id
|
|
13
65
|
:name
|
|
14
|
-
:
|
|
15
|
-
:
|
|
16
|
-
:
|
|
17
|
-
:required
|
|
18
|
-
:styleClassPassthrough
|
|
19
|
-
:theme
|
|
20
|
-
:size
|
|
21
|
-
:inputVariant
|
|
66
|
+
:input-variant
|
|
67
|
+
:field-has-error="fieldHasError"
|
|
68
|
+
:style-class-passthrough="['input-text-description']"
|
|
22
69
|
>
|
|
23
|
-
<template v-if="
|
|
24
|
-
<slot name="
|
|
70
|
+
<template v-if="slots.descriptionHtml" #descriptionHtml>
|
|
71
|
+
<slot name="descriptionHtml"></slot>
|
|
25
72
|
</template>
|
|
26
|
-
<template v-if="
|
|
27
|
-
<slot name="
|
|
73
|
+
<template v-if="slots.descriptionText" #descriptionText>
|
|
74
|
+
<slot name="descriptionText"></slot>
|
|
28
75
|
</template>
|
|
29
|
-
</
|
|
30
|
-
<InputError :errorMessage :showError="fieldHasError" :id :isDetached="false" :inputVariant />
|
|
76
|
+
</InputDescription>
|
|
31
77
|
</div>
|
|
32
78
|
</template>
|
|
33
79
|
|
|
34
80
|
<script setup lang="ts">
|
|
35
|
-
import propValidators from
|
|
81
|
+
import propValidators from "../../c12/prop-validators"
|
|
36
82
|
const props = defineProps({
|
|
37
83
|
maxlength: {
|
|
38
84
|
type: Number,
|
|
@@ -44,7 +90,7 @@ const props = defineProps({
|
|
|
44
90
|
},
|
|
45
91
|
placeholder: {
|
|
46
92
|
type: String,
|
|
47
|
-
default:
|
|
93
|
+
default: "",
|
|
48
94
|
},
|
|
49
95
|
label: {
|
|
50
96
|
type: String,
|
|
@@ -68,58 +114,62 @@ const props = defineProps({
|
|
|
68
114
|
},
|
|
69
115
|
theme: {
|
|
70
116
|
type: String as PropType<string>,
|
|
71
|
-
default:
|
|
117
|
+
default: "primary",
|
|
72
118
|
validator(value: string) {
|
|
73
|
-
return propValidators.theme.includes(value)
|
|
119
|
+
return propValidators.theme.includes(value)
|
|
74
120
|
},
|
|
75
121
|
},
|
|
76
122
|
size: {
|
|
77
123
|
type: String as PropType<string>,
|
|
78
|
-
default:
|
|
124
|
+
default: "default",
|
|
79
125
|
validator(value: string) {
|
|
80
|
-
return propValidators.size.includes(value)
|
|
126
|
+
return propValidators.size.includes(value)
|
|
81
127
|
},
|
|
82
128
|
},
|
|
83
129
|
inputVariant: {
|
|
84
130
|
type: String as PropType<string>,
|
|
85
|
-
default:
|
|
131
|
+
default: "normal",
|
|
86
132
|
validator(value: string) {
|
|
87
|
-
return propValidators.inputVariant.includes(value)
|
|
133
|
+
return propValidators.inputVariant.includes(value)
|
|
88
134
|
},
|
|
89
135
|
},
|
|
90
|
-
})
|
|
136
|
+
})
|
|
91
137
|
|
|
92
|
-
const slots = useSlots()
|
|
93
|
-
const hasLeftSlot = computed(() => slots.left !== undefined);
|
|
94
|
-
const hasRightSlot = computed(() => slots.right !== undefined);
|
|
138
|
+
const slots = useSlots()
|
|
95
139
|
|
|
96
|
-
const id = useId();
|
|
97
140
|
const formTheme = computed(() => {
|
|
98
|
-
return props.fieldHasError ?
|
|
99
|
-
})
|
|
141
|
+
return props.fieldHasError ? "error" : props.theme
|
|
142
|
+
})
|
|
143
|
+
|
|
144
|
+
const id = `${props.name}-${useId()}`
|
|
145
|
+
const errorId = `${id}-error-message`
|
|
146
|
+
const ariaDescribedby = computed(() => {
|
|
147
|
+
const ariaDescribedbyId = slots.descriptionText || slots.descriptionHtml ? `${id}-description` : undefined
|
|
148
|
+
return props.fieldHasError ? errorId : ariaDescribedbyId
|
|
149
|
+
})
|
|
100
150
|
|
|
101
|
-
const modelValue = defineModel<string | number | readonly string[] | null | undefined>()
|
|
102
|
-
const isActive = ref<boolean>(false)
|
|
103
|
-
const isDirty = ref<boolean>(false)
|
|
151
|
+
const modelValue = defineModel<string | number | readonly string[] | null | undefined>()
|
|
152
|
+
const isActive = ref<boolean>(false)
|
|
153
|
+
const isDirty = ref<boolean>(false)
|
|
104
154
|
|
|
105
|
-
const { elementClasses
|
|
155
|
+
const { elementClasses } = useStyleClassPassthrough(props.styleClassPassthrough)
|
|
106
156
|
|
|
107
157
|
const testDirty = () => {
|
|
108
|
-
const watchValue = modelValue.value ??
|
|
158
|
+
const watchValue = modelValue.value ?? ""
|
|
109
159
|
|
|
110
|
-
if (!isDirty.value && typeof watchValue ===
|
|
111
|
-
isDirty.value = true
|
|
160
|
+
if (!isDirty.value && typeof watchValue === "string" && watchValue.length > 0) {
|
|
161
|
+
isDirty.value = true
|
|
112
162
|
}
|
|
113
|
-
}
|
|
163
|
+
}
|
|
114
164
|
|
|
115
165
|
onMounted(() => {
|
|
116
|
-
testDirty()
|
|
117
|
-
})
|
|
166
|
+
testDirty()
|
|
167
|
+
})
|
|
118
168
|
|
|
119
169
|
watch(
|
|
120
170
|
() => modelValue.value,
|
|
121
171
|
() => {
|
|
122
|
-
testDirty()
|
|
172
|
+
testDirty()
|
|
123
173
|
}
|
|
124
|
-
)
|
|
174
|
+
)
|
|
125
175
|
</script>
|
|
@@ -1,7 +1,23 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="toggle-switch-core" :class="elementClasses" :data-size="size" :data-theme="formTheme">
|
|
3
|
-
<div
|
|
4
|
-
|
|
3
|
+
<div
|
|
4
|
+
@click="toggleSwitchValue"
|
|
5
|
+
class="toggle-switch-wrapper"
|
|
6
|
+
:class="[{ round }, { 'use-default-icons': useDefaultIcons }]"
|
|
7
|
+
:for="inputId"
|
|
8
|
+
>
|
|
9
|
+
<input
|
|
10
|
+
type="checkbox"
|
|
11
|
+
v-model="modelValue"
|
|
12
|
+
:true-value
|
|
13
|
+
:false-value
|
|
14
|
+
:aria-invalid="fieldHasError"
|
|
15
|
+
:id="inputId"
|
|
16
|
+
:aria-describedby="`${id}-description`"
|
|
17
|
+
:name
|
|
18
|
+
:required
|
|
19
|
+
:checked="isChecked"
|
|
20
|
+
/>
|
|
5
21
|
<div class="symbol-wrapper" :class="[{ round }]">
|
|
6
22
|
<div class="symbol" :class="[{ round }]">
|
|
7
23
|
<div class="symbol-icon icon-on">
|
|
@@ -22,7 +38,7 @@
|
|
|
22
38
|
</template>
|
|
23
39
|
|
|
24
40
|
<script setup lang="ts">
|
|
25
|
-
import propValidators from
|
|
41
|
+
import propValidators from "../c12/prop-validators"
|
|
26
42
|
|
|
27
43
|
const props = defineProps({
|
|
28
44
|
id: {
|
|
@@ -55,9 +71,9 @@ const props = defineProps({
|
|
|
55
71
|
},
|
|
56
72
|
theme: {
|
|
57
73
|
type: String as PropType<string>,
|
|
58
|
-
default:
|
|
74
|
+
default: "primary",
|
|
59
75
|
validator(value: string) {
|
|
60
|
-
return propValidators.theme.includes(value)
|
|
76
|
+
return propValidators.theme.includes(value)
|
|
61
77
|
},
|
|
62
78
|
},
|
|
63
79
|
round: {
|
|
@@ -66,39 +82,36 @@ const props = defineProps({
|
|
|
66
82
|
},
|
|
67
83
|
size: {
|
|
68
84
|
type: String as PropType<string>,
|
|
69
|
-
default:
|
|
85
|
+
default: "default",
|
|
70
86
|
validator(value: string) {
|
|
71
|
-
return propValidators.size.includes(value)
|
|
87
|
+
return propValidators.size.includes(value)
|
|
72
88
|
},
|
|
73
89
|
},
|
|
74
90
|
ariaDescribedby: {
|
|
75
91
|
type: String,
|
|
76
92
|
default: null,
|
|
77
93
|
},
|
|
78
|
-
})
|
|
94
|
+
})
|
|
79
95
|
|
|
80
|
-
const slots = useSlots()
|
|
81
|
-
const
|
|
82
|
-
const hasIconOffSlot = computed(() => slots.iconOff !== undefined);
|
|
83
|
-
const useDefaultIcons = computed(() => !hasIconOnSlot.value && !hasIconOffSlot.value);
|
|
96
|
+
const slots = useSlots()
|
|
97
|
+
const useDefaultIcons = computed(() => !slots.iconOn && !slots.iconOff)
|
|
84
98
|
|
|
85
99
|
const formTheme = computed(() => {
|
|
86
|
-
return props.fieldHasError ?
|
|
87
|
-
})
|
|
100
|
+
return props.fieldHasError ? "error" : props.theme
|
|
101
|
+
})
|
|
88
102
|
|
|
89
|
-
const modelValue = defineModel()
|
|
90
|
-
const { elementClasses } = useStyleClassPassthrough(props.styleClassPassthrough)
|
|
103
|
+
const modelValue = defineModel()
|
|
104
|
+
const { elementClasses } = useStyleClassPassthrough(props.styleClassPassthrough)
|
|
91
105
|
|
|
92
|
-
const inputId = computed(() => `toggle-sitch-${props.id}`)
|
|
106
|
+
const inputId = computed(() => `toggle-sitch-${props.id}`)
|
|
93
107
|
|
|
94
108
|
const isChecked = computed(() => {
|
|
95
|
-
return modelValue.value === props.trueValue
|
|
96
|
-
})
|
|
109
|
+
return modelValue.value === props.trueValue
|
|
110
|
+
})
|
|
97
111
|
|
|
98
112
|
const toggleSwitchValue = () => {
|
|
99
|
-
modelValue.value = modelValue.value === props.trueValue ? props.falseValue : props.trueValue
|
|
100
|
-
|
|
101
|
-
};
|
|
113
|
+
modelValue.value = modelValue.value === props.trueValue ? props.falseValue : props.trueValue
|
|
114
|
+
}
|
|
102
115
|
</script>
|
|
103
116
|
|
|
104
117
|
<style lang="css">
|
|
@@ -149,16 +162,21 @@ const toggleSwitchValue = () => {
|
|
|
149
162
|
/* background: blue; */
|
|
150
163
|
border: var(--theme-form-toggle-border-width) solid var(--theme-form-toggle-border-color);
|
|
151
164
|
outline: var(--theme-form-toggle-outline-width) solid var(--theme-form-toggle-outline-color);
|
|
152
|
-
border-radius: calc(
|
|
165
|
+
border-radius: calc(
|
|
166
|
+
var(--_symbol-size) + calc(var(--theme-form-toggle-border-width) * 2) + calc(var(--_switch-padding) * 2)
|
|
167
|
+
);
|
|
153
168
|
display: inline-flex;
|
|
154
169
|
align-items: center;
|
|
155
170
|
justify-content: start;
|
|
156
|
-
width: calc(
|
|
171
|
+
width: calc(
|
|
172
|
+
var(--_symbol-size) + var(--_symbol-checked-offset) + calc(var(--theme-form-toggle-border-width) * 2) +
|
|
173
|
+
calc(var(--_switch-padding) * 2)
|
|
174
|
+
);
|
|
157
175
|
padding: var(--_switch-padding);
|
|
158
176
|
|
|
159
177
|
.symbol {
|
|
160
178
|
display: inline-grid;
|
|
161
|
-
grid-template-areas:
|
|
179
|
+
grid-template-areas: "icon";
|
|
162
180
|
place-content: center;
|
|
163
181
|
|
|
164
182
|
aspect-ratio: 1/1;
|
|
@@ -1,14 +1,24 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="toggle-switch-core" :class="elementClasses" :data-size="size" :data-theme="formTheme">
|
|
3
3
|
<div @click="toggleSwitchValue" class="toggle-switch-input" :class="[{ round }]" :for="inputId">
|
|
4
|
-
<input
|
|
4
|
+
<input
|
|
5
|
+
type="checkbox"
|
|
6
|
+
v-model="modelValue"
|
|
7
|
+
:true-value
|
|
8
|
+
:false-value
|
|
9
|
+
:aria-invalid="fieldHasError"
|
|
10
|
+
:id="inputId"
|
|
11
|
+
:aria-describedby="`${id}-description`"
|
|
12
|
+
:name
|
|
13
|
+
:required
|
|
14
|
+
/>
|
|
5
15
|
<div class="symbol-wrapper" :class="[{ round }]">
|
|
6
16
|
<div class="symbol" :class="[{ round }]">
|
|
7
|
-
<div v-if="
|
|
17
|
+
<div v-if="slots.iconOn" class="symbol-icon icon-on">
|
|
8
18
|
<slot name="iconOn"></slot>
|
|
9
19
|
</div>
|
|
10
20
|
|
|
11
|
-
<div v-if="
|
|
21
|
+
<div v-if="slots.iconOff" class="symbol-icon icon-off">
|
|
12
22
|
<slot name="iconOff"></slot>
|
|
13
23
|
</div>
|
|
14
24
|
</div>
|
|
@@ -18,7 +28,7 @@
|
|
|
18
28
|
</template>
|
|
19
29
|
|
|
20
30
|
<script setup lang="ts">
|
|
21
|
-
import propValidators from
|
|
31
|
+
import propValidators from "../c12/prop-validators"
|
|
22
32
|
|
|
23
33
|
const props = defineProps({
|
|
24
34
|
id: {
|
|
@@ -51,9 +61,9 @@ const props = defineProps({
|
|
|
51
61
|
},
|
|
52
62
|
theme: {
|
|
53
63
|
type: String as PropType<string>,
|
|
54
|
-
default:
|
|
64
|
+
default: "primary",
|
|
55
65
|
validator(value: string) {
|
|
56
|
-
return propValidators.theme.includes(value)
|
|
66
|
+
return propValidators.theme.includes(value)
|
|
57
67
|
},
|
|
58
68
|
},
|
|
59
69
|
round: {
|
|
@@ -62,33 +72,31 @@ const props = defineProps({
|
|
|
62
72
|
},
|
|
63
73
|
size: {
|
|
64
74
|
type: String as PropType<string>,
|
|
65
|
-
default:
|
|
75
|
+
default: "default",
|
|
66
76
|
validator(value: string) {
|
|
67
|
-
return propValidators.size.includes(value)
|
|
77
|
+
return propValidators.size.includes(value)
|
|
68
78
|
},
|
|
69
79
|
},
|
|
70
80
|
ariaDescribedby: {
|
|
71
81
|
type: String,
|
|
72
82
|
default: null,
|
|
73
83
|
},
|
|
74
|
-
})
|
|
84
|
+
})
|
|
75
85
|
|
|
76
|
-
const slots = useSlots()
|
|
77
|
-
const hasIconOnSlot = computed(() => slots.iconOn !== undefined);
|
|
78
|
-
const hasIconOffSlot = computed(() => slots.iconOff !== undefined);
|
|
86
|
+
const slots = useSlots()
|
|
79
87
|
|
|
80
88
|
const formTheme = computed(() => {
|
|
81
|
-
return props.fieldHasError ?
|
|
82
|
-
})
|
|
89
|
+
return props.fieldHasError ? "error" : props.theme
|
|
90
|
+
})
|
|
83
91
|
|
|
84
|
-
const modelValue = defineModel()
|
|
85
|
-
const { elementClasses } = useStyleClassPassthrough(props.styleClassPassthrough)
|
|
92
|
+
const modelValue = defineModel()
|
|
93
|
+
const { elementClasses } = useStyleClassPassthrough(props.styleClassPassthrough)
|
|
86
94
|
|
|
87
|
-
const inputId = computed(() => `toggle-sitch-${props.id}`)
|
|
95
|
+
const inputId = computed(() => `toggle-sitch-${props.id}`)
|
|
88
96
|
|
|
89
97
|
const toggleSwitchValue = () => {
|
|
90
|
-
modelValue.value = modelValue.value === props.trueValue ? props.falseValue : props.trueValue
|
|
91
|
-
}
|
|
98
|
+
modelValue.value = modelValue.value === props.trueValue ? props.falseValue : props.trueValue
|
|
99
|
+
}
|
|
92
100
|
</script>
|
|
93
101
|
|
|
94
102
|
<style lang="css">
|
|
@@ -102,8 +110,14 @@ const toggleSwitchValue = () => {
|
|
|
102
110
|
.toggle-switch-input {
|
|
103
111
|
position: relative;
|
|
104
112
|
display: inline-block;
|
|
105
|
-
height: calc(
|
|
106
|
-
|
|
113
|
+
height: calc(
|
|
114
|
+
var(--form-toggle-symbol-size) + calc(var(--form-element-border-width) * 2) +
|
|
115
|
+
calc(var(--form-element-outline-width) * 2)
|
|
116
|
+
);
|
|
117
|
+
width: calc(
|
|
118
|
+
var(--form-toggle-symbol-size) * 2 - calc(var(--form-element-border-width) * 2) +
|
|
119
|
+
calc(var(--form-element-outline-width) * 2) + var(--form-toggle-switch-width-adjustment)
|
|
120
|
+
);
|
|
107
121
|
|
|
108
122
|
input {
|
|
109
123
|
opacity: 0;
|
|
@@ -126,7 +140,7 @@ const toggleSwitchValue = () => {
|
|
|
126
140
|
|
|
127
141
|
.symbol {
|
|
128
142
|
display: grid;
|
|
129
|
-
grid-template-areas:
|
|
143
|
+
grid-template-areas: "icon-stack";
|
|
130
144
|
overflow: clip;
|
|
131
145
|
position: absolute;
|
|
132
146
|
|