srcdev-nuxt-forms 6.0.1 → 6.1.1
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/README.md +45 -5
- package/app/assets/styles/extends-layer/srcdev-forms/components/_form-fieldset.css +1 -1
- package/app/assets/styles/extends-layer/srcdev-forms/components/_input-button.css +1 -1
- package/app/assets/styles/extends-layer/srcdev-forms/components/_input-checkbox-radio-core.css +1 -1
- package/app/assets/styles/extends-layer/srcdev-forms/components/_input-checkbox-radio-options-button.css +1 -1
- package/app/assets/styles/extends-layer/srcdev-forms/components/_input-error.css +1 -1
- package/app/assets/styles/extends-layer/srcdev-forms/components/_input-label.css +1 -1
- package/app/assets/styles/extends-layer/srcdev-forms/components/_input-select.css +1 -1
- package/app/assets/styles/extends-layer/srcdev-forms/components/_input-text.css +1 -1
- package/app/assets/styles/extends-layer/srcdev-forms/components/_input-textarea.css +1 -1
- package/app/assets/styles/setup/_head.css +1 -1
- package/app/assets/styles/setup/typography/vars/_reponsive-font-sizes.css +10 -10
- package/app/assets/styles/setup/typography/vars/index.css +0 -1
- 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 -27
- 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-label/InputLabel.vue +10 -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 +48 -37
- package/app/components/forms/input-text/InputTextCore.vue +56 -52
- package/app/components/forms/input-text/variants/InputTextAsNumberWithLabel.vue +42 -33
- package/app/components/forms/input-text/variants/InputTextWithLabel.vue +51 -42
- package/app/components/forms/input-textarea/InputTextareaCore.vue +29 -24
- package/app/components/forms/input-textarea/variants/InputTextareaWithLabel.vue +41 -31
- 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/nuxt.config.ts +11 -11
- package/package.json +2 -2
- package/app/assets/styles/setup/typography/vars/_colors.css +0 -14
- package/app/assets/styles/setup/variables/index.css +0 -1
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div
|
|
3
|
-
|
|
2
|
+
<div
|
|
3
|
+
class="input-textarea-with-label"
|
|
4
|
+
:data-theme="formTheme"
|
|
5
|
+
:class="[elementClasses, inputVariant, { dirty: isDirty }, { active: isActive }]"
|
|
6
|
+
>
|
|
7
|
+
<InputLabel
|
|
8
|
+
:for="id"
|
|
9
|
+
:id
|
|
10
|
+
:theme
|
|
11
|
+
:name
|
|
12
|
+
:input-variant
|
|
13
|
+
:field-has-error
|
|
14
|
+
:style-class-passthrough="['input-textarea-label']"
|
|
15
|
+
>
|
|
4
16
|
<template #textLabel>{{ label }}</template>
|
|
5
17
|
</InputLabel>
|
|
6
18
|
|
|
@@ -20,10 +32,10 @@
|
|
|
20
32
|
:size
|
|
21
33
|
:inputVariant
|
|
22
34
|
>
|
|
23
|
-
<template v-if="
|
|
35
|
+
<template v-if="slots.left" #left>
|
|
24
36
|
<slot name="left"></slot>
|
|
25
37
|
</template>
|
|
26
|
-
<template v-if="
|
|
38
|
+
<template v-if="slots.right" #right>
|
|
27
39
|
<slot name="right"></slot>
|
|
28
40
|
</template>
|
|
29
41
|
</InputTextareaCore>
|
|
@@ -32,7 +44,7 @@
|
|
|
32
44
|
</template>
|
|
33
45
|
|
|
34
46
|
<script setup lang="ts">
|
|
35
|
-
import propValidators from
|
|
47
|
+
import propValidators from "../../c12/prop-validators"
|
|
36
48
|
const props = defineProps({
|
|
37
49
|
maxlength: {
|
|
38
50
|
type: Number,
|
|
@@ -44,7 +56,7 @@ const props = defineProps({
|
|
|
44
56
|
},
|
|
45
57
|
placeholder: {
|
|
46
58
|
type: String,
|
|
47
|
-
default:
|
|
59
|
+
default: "",
|
|
48
60
|
},
|
|
49
61
|
label: {
|
|
50
62
|
type: String,
|
|
@@ -68,58 +80,56 @@ const props = defineProps({
|
|
|
68
80
|
},
|
|
69
81
|
theme: {
|
|
70
82
|
type: String as PropType<string>,
|
|
71
|
-
default:
|
|
83
|
+
default: "primary",
|
|
72
84
|
validator(value: string) {
|
|
73
|
-
return propValidators.theme.includes(value)
|
|
85
|
+
return propValidators.theme.includes(value)
|
|
74
86
|
},
|
|
75
87
|
},
|
|
76
88
|
size: {
|
|
77
89
|
type: String as PropType<string>,
|
|
78
|
-
default:
|
|
90
|
+
default: "default",
|
|
79
91
|
validator(value: string) {
|
|
80
|
-
return propValidators.size.includes(value)
|
|
92
|
+
return propValidators.size.includes(value)
|
|
81
93
|
},
|
|
82
94
|
},
|
|
83
95
|
inputVariant: {
|
|
84
96
|
type: String as PropType<string>,
|
|
85
|
-
default:
|
|
97
|
+
default: "normal",
|
|
86
98
|
validator(value: string) {
|
|
87
|
-
return propValidators.inputVariant.includes(value)
|
|
99
|
+
return propValidators.inputVariant.includes(value)
|
|
88
100
|
},
|
|
89
101
|
},
|
|
90
|
-
})
|
|
102
|
+
})
|
|
91
103
|
|
|
92
|
-
const slots = useSlots()
|
|
93
|
-
const hasLeftSlot = computed(() => slots.left !== undefined);
|
|
94
|
-
const hasRightSlot = computed(() => slots.right !== undefined);
|
|
104
|
+
const slots = useSlots()
|
|
95
105
|
|
|
96
|
-
const id = useId()
|
|
106
|
+
const id = useId()
|
|
97
107
|
const formTheme = computed(() => {
|
|
98
|
-
return props.fieldHasError ?
|
|
99
|
-
})
|
|
108
|
+
return props.fieldHasError ? "error" : props.theme
|
|
109
|
+
})
|
|
100
110
|
|
|
101
|
-
const modelValue = defineModel<string | number | readonly string[] | null | undefined>()
|
|
102
|
-
const isActive = ref<boolean>(false)
|
|
103
|
-
const isDirty = ref<boolean>(false)
|
|
111
|
+
const modelValue = defineModel<string | number | readonly string[] | null | undefined>()
|
|
112
|
+
const isActive = ref<boolean>(false)
|
|
113
|
+
const isDirty = ref<boolean>(false)
|
|
104
114
|
|
|
105
|
-
const { elementClasses
|
|
115
|
+
const { elementClasses } = useStyleClassPassthrough(props.styleClassPassthrough)
|
|
106
116
|
|
|
107
117
|
const testDirty = () => {
|
|
108
|
-
const watchValue = modelValue.value ??
|
|
118
|
+
const watchValue = modelValue.value ?? ""
|
|
109
119
|
|
|
110
|
-
if (!isDirty.value && typeof watchValue ===
|
|
111
|
-
isDirty.value = true
|
|
120
|
+
if (!isDirty.value && typeof watchValue === "string" && watchValue.length > 0) {
|
|
121
|
+
isDirty.value = true
|
|
112
122
|
}
|
|
113
|
-
}
|
|
123
|
+
}
|
|
114
124
|
|
|
115
125
|
onMounted(() => {
|
|
116
|
-
testDirty()
|
|
117
|
-
})
|
|
126
|
+
testDirty()
|
|
127
|
+
})
|
|
118
128
|
|
|
119
129
|
watch(
|
|
120
130
|
() => modelValue.value,
|
|
121
131
|
() => {
|
|
122
|
-
testDirty()
|
|
132
|
+
testDirty()
|
|
123
133
|
}
|
|
124
|
-
)
|
|
134
|
+
)
|
|
125
135
|
</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
|
|
|
@@ -1,18 +1,38 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="toggle-switch-with-label" :class="[elementClasses]" :data-theme="formTheme">
|
|
3
|
-
<InputLabel
|
|
3
|
+
<InputLabel
|
|
4
|
+
:for="`toggle-sitch-${id}`"
|
|
5
|
+
:id
|
|
6
|
+
:theme
|
|
7
|
+
:name
|
|
8
|
+
input-variant="normal"
|
|
9
|
+
:field-has-error
|
|
10
|
+
:style-class-passthrough="['input-switch-label', 'input-text-label', 'body-normal-bold']"
|
|
11
|
+
>
|
|
4
12
|
<template #textLabel>{{ label }}</template>
|
|
5
13
|
</InputLabel>
|
|
6
14
|
|
|
7
|
-
<div v-if="
|
|
15
|
+
<div v-if="slots.description" :id="`${id}-description`">
|
|
8
16
|
<slot name="description"></slot>
|
|
9
17
|
</div>
|
|
10
|
-
<ToggleSwitchCore
|
|
11
|
-
|
|
18
|
+
<ToggleSwitchCore
|
|
19
|
+
v-model="modelValue"
|
|
20
|
+
:id
|
|
21
|
+
:name
|
|
22
|
+
:required
|
|
23
|
+
:field-has-error
|
|
24
|
+
:true-value
|
|
25
|
+
:false-value
|
|
26
|
+
:theme
|
|
27
|
+
:round
|
|
28
|
+
:size
|
|
29
|
+
:ariaDescribedby
|
|
30
|
+
>
|
|
31
|
+
<template v-if="slots.iconOn" #iconOn>
|
|
12
32
|
<slot name="iconOn"></slot>
|
|
13
33
|
</template>
|
|
14
34
|
|
|
15
|
-
<template v-if="
|
|
35
|
+
<template v-if="slots.iconOff" #iconOff>
|
|
16
36
|
<slot name="iconOff"></slot>
|
|
17
37
|
</template>
|
|
18
38
|
</ToggleSwitchCore>
|
|
@@ -21,7 +41,7 @@
|
|
|
21
41
|
</template>
|
|
22
42
|
|
|
23
43
|
<script setup lang="ts">
|
|
24
|
-
import propValidators from
|
|
44
|
+
import propValidators from "../../c12/prop-validators"
|
|
25
45
|
|
|
26
46
|
const props = defineProps({
|
|
27
47
|
name: {
|
|
@@ -38,7 +58,7 @@ const props = defineProps({
|
|
|
38
58
|
},
|
|
39
59
|
errorMessage: {
|
|
40
60
|
type: [Object, String],
|
|
41
|
-
default:
|
|
61
|
+
default: "",
|
|
42
62
|
required: false,
|
|
43
63
|
},
|
|
44
64
|
fieldHasError: {
|
|
@@ -59,9 +79,9 @@ const props = defineProps({
|
|
|
59
79
|
},
|
|
60
80
|
theme: {
|
|
61
81
|
type: String as PropType<string>,
|
|
62
|
-
default:
|
|
82
|
+
default: "primary",
|
|
63
83
|
validator(value: string) {
|
|
64
|
-
return propValidators.theme.includes(value)
|
|
84
|
+
return propValidators.theme.includes(value)
|
|
65
85
|
},
|
|
66
86
|
},
|
|
67
87
|
round: {
|
|
@@ -70,31 +90,28 @@ const props = defineProps({
|
|
|
70
90
|
},
|
|
71
91
|
size: {
|
|
72
92
|
type: String as PropType<string>,
|
|
73
|
-
default:
|
|
93
|
+
default: "default",
|
|
74
94
|
validator(value: string) {
|
|
75
|
-
return propValidators.size.includes(value)
|
|
95
|
+
return propValidators.size.includes(value)
|
|
76
96
|
},
|
|
77
97
|
},
|
|
78
|
-
})
|
|
98
|
+
})
|
|
79
99
|
|
|
80
|
-
const slots = useSlots()
|
|
81
|
-
const hasDescriptionSlot = computed(() => slots.description !== undefined);
|
|
82
|
-
const hasIconOnSlot = computed(() => slots.iconOn !== undefined);
|
|
83
|
-
const hasIconOffSlot = computed(() => slots.iconOff !== undefined);
|
|
100
|
+
const slots = useSlots()
|
|
84
101
|
|
|
85
102
|
const formTheme = computed(() => {
|
|
86
|
-
return props.fieldHasError ?
|
|
87
|
-
})
|
|
103
|
+
return props.fieldHasError ? "error" : props.theme
|
|
104
|
+
})
|
|
88
105
|
|
|
89
|
-
const id = useId()
|
|
90
|
-
const errorId = `${id}-error-message
|
|
106
|
+
const id = useId()
|
|
107
|
+
const errorId = `${id}-error-message`
|
|
91
108
|
const ariaDescribedby = computed(() => {
|
|
92
|
-
const ariaDescribedbyId =
|
|
93
|
-
return props.fieldHasError ? errorId : ariaDescribedbyId
|
|
94
|
-
})
|
|
109
|
+
const ariaDescribedbyId = slots.description ? `${id}-description` : undefined
|
|
110
|
+
return props.fieldHasError ? errorId : ariaDescribedbyId
|
|
111
|
+
})
|
|
95
112
|
|
|
96
|
-
const modelValue = defineModel()
|
|
97
|
-
const { elementClasses } = useStyleClassPassthrough(props.styleClassPassthrough)
|
|
113
|
+
const modelValue = defineModel()
|
|
114
|
+
const { elementClasses } = useStyleClassPassthrough(props.styleClassPassthrough)
|
|
98
115
|
</script>
|
|
99
116
|
|
|
100
117
|
<style lang="css">
|
|
@@ -1,15 +1,22 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="toggle-switch-with-label-inline" :class="[elementClasses]" :data-theme="theme">
|
|
3
|
-
<InputLabel
|
|
3
|
+
<InputLabel
|
|
4
|
+
:for="`toggle-sitch-${id}`"
|
|
5
|
+
:id
|
|
6
|
+
:theme
|
|
7
|
+
:name
|
|
8
|
+
input-variant="normal"
|
|
9
|
+
:style-class-passthrough="['input-switch-label', 'input-text-label', labelWeightClass]"
|
|
10
|
+
>
|
|
4
11
|
<template #textLabel>{{ label }}</template>
|
|
5
12
|
</InputLabel>
|
|
6
13
|
|
|
7
14
|
<ToggleSwitchCore v-model="modelValue" :id :name :true-value :false-value :theme :round :size>
|
|
8
|
-
<template v-if="
|
|
15
|
+
<template v-if="slots.iconOn" #iconOn>
|
|
9
16
|
<slot name="iconOn"></slot>
|
|
10
17
|
</template>
|
|
11
18
|
|
|
12
|
-
<template v-if="
|
|
19
|
+
<template v-if="slots.iconOff" #iconOff>
|
|
13
20
|
<slot name="iconOff"></slot>
|
|
14
21
|
</template>
|
|
15
22
|
</ToggleSwitchCore>
|
|
@@ -17,7 +24,7 @@
|
|
|
17
24
|
</template>
|
|
18
25
|
|
|
19
26
|
<script setup lang="ts">
|
|
20
|
-
import propValidators from
|
|
27
|
+
import propValidators from "../../c12/prop-validators"
|
|
21
28
|
|
|
22
29
|
const props = defineProps({
|
|
23
30
|
name: {
|
|
@@ -30,9 +37,9 @@ const props = defineProps({
|
|
|
30
37
|
},
|
|
31
38
|
labelWeight: {
|
|
32
39
|
type: String as PropType<string>,
|
|
33
|
-
default:
|
|
40
|
+
default: "semi-bold",
|
|
34
41
|
validator(value: string) {
|
|
35
|
-
return propValidators.labelWeight.includes(value)
|
|
42
|
+
return propValidators.labelWeight.includes(value)
|
|
36
43
|
},
|
|
37
44
|
},
|
|
38
45
|
trueValue: {
|
|
@@ -49,9 +56,9 @@ const props = defineProps({
|
|
|
49
56
|
},
|
|
50
57
|
theme: {
|
|
51
58
|
type: String as PropType<string>,
|
|
52
|
-
default:
|
|
59
|
+
default: "primary",
|
|
53
60
|
validator(value: string) {
|
|
54
|
-
return propValidators.theme.includes(value)
|
|
61
|
+
return propValidators.theme.includes(value)
|
|
55
62
|
},
|
|
56
63
|
},
|
|
57
64
|
round: {
|
|
@@ -60,34 +67,31 @@ const props = defineProps({
|
|
|
60
67
|
},
|
|
61
68
|
size: {
|
|
62
69
|
type: String as PropType<string>,
|
|
63
|
-
default:
|
|
70
|
+
default: "default",
|
|
64
71
|
validator(value: string) {
|
|
65
|
-
return propValidators.size.includes(value)
|
|
72
|
+
return propValidators.size.includes(value)
|
|
66
73
|
},
|
|
67
74
|
},
|
|
68
|
-
})
|
|
75
|
+
})
|
|
69
76
|
|
|
70
|
-
const slots = useSlots()
|
|
71
|
-
const
|
|
72
|
-
const hasIconOffSlot = computed(() => slots.iconOff !== undefined);
|
|
73
|
-
|
|
74
|
-
const id = useId();
|
|
77
|
+
const slots = useSlots()
|
|
78
|
+
const id = useId()
|
|
75
79
|
|
|
76
80
|
const labelWeightClass = computed(() => {
|
|
77
81
|
switch (props.labelWeight) {
|
|
78
|
-
case
|
|
79
|
-
return
|
|
80
|
-
case
|
|
81
|
-
return
|
|
82
|
-
case
|
|
83
|
-
return
|
|
82
|
+
case "bold":
|
|
83
|
+
return "body-normal-bold"
|
|
84
|
+
case "semi-bold":
|
|
85
|
+
return "body-normal-semibold"
|
|
86
|
+
case "normal":
|
|
87
|
+
return "body-normal"
|
|
84
88
|
default:
|
|
85
|
-
return
|
|
89
|
+
return "body-normal-semibold"
|
|
86
90
|
}
|
|
87
|
-
})
|
|
91
|
+
})
|
|
88
92
|
|
|
89
|
-
const modelValue = defineModel()
|
|
90
|
-
const { elementClasses } = useStyleClassPassthrough(props.styleClassPassthrough)
|
|
93
|
+
const modelValue = defineModel()
|
|
94
|
+
const { elementClasses } = useStyleClassPassthrough(props.styleClassPassthrough)
|
|
91
95
|
</script>
|
|
92
96
|
|
|
93
97
|
<style lang="css">
|
package/nuxt.config.ts
CHANGED
|
@@ -2,39 +2,39 @@
|
|
|
2
2
|
|
|
3
3
|
export default defineNuxtConfig({
|
|
4
4
|
devtools: { enabled: true },
|
|
5
|
-
css: [
|
|
6
|
-
modules: [
|
|
5
|
+
css: ["modern-normalize", "./app/assets/styles/main.css"],
|
|
6
|
+
modules: ["@nuxt/eslint", "@nuxt/icon", "@nuxt/test-utils/module"],
|
|
7
7
|
alias: {
|
|
8
|
-
|
|
8
|
+
"#shared": "./shared",
|
|
9
9
|
},
|
|
10
10
|
typescript: {
|
|
11
11
|
tsConfig: {
|
|
12
12
|
compilerOptions: {
|
|
13
|
-
types: [
|
|
13
|
+
types: ["vitest/globals"], // TypeScript support for globals
|
|
14
14
|
},
|
|
15
15
|
},
|
|
16
16
|
},
|
|
17
17
|
app: {
|
|
18
18
|
head: {
|
|
19
19
|
htmlAttrs: {
|
|
20
|
-
lang:
|
|
21
|
-
|
|
20
|
+
lang: "en",
|
|
21
|
+
"data-color-scheme": "auto",
|
|
22
22
|
},
|
|
23
|
-
titleTemplate:
|
|
24
|
-
meta: [{ charset:
|
|
23
|
+
titleTemplate: "%s - Website name",
|
|
24
|
+
meta: [{ charset: "utf-8" }, { name: "viewport", content: "width=device-width, initial-scale=1" }],
|
|
25
25
|
},
|
|
26
26
|
},
|
|
27
27
|
components: [
|
|
28
28
|
{
|
|
29
|
-
path:
|
|
29
|
+
path: "./components",
|
|
30
30
|
pathPrefix: false,
|
|
31
31
|
},
|
|
32
32
|
],
|
|
33
33
|
vue: {
|
|
34
34
|
runtimeCompiler: true,
|
|
35
35
|
},
|
|
36
|
-
compatibilityDate:
|
|
36
|
+
compatibilityDate: "2024-12-01",
|
|
37
37
|
future: {
|
|
38
38
|
compatibilityVersion: 4,
|
|
39
39
|
},
|
|
40
|
-
})
|
|
40
|
+
})
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "srcdev-nuxt-forms",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "6.
|
|
4
|
+
"version": "6.1.1",
|
|
5
5
|
"main": "nuxt.config.ts",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"clean": "rm -rf .nuxt && rm -rf .output && rm -rf .playground/.nuxt && rm -rf .playground/.output",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"@iconify-json/carbon": "1.2.10",
|
|
27
27
|
"@iconify-json/material-symbols": "1.2.29",
|
|
28
28
|
"@iconify-json/material-symbols-light": "1.2.29",
|
|
29
|
-
"@nuxt/eslint
|
|
29
|
+
"@nuxt/eslint": "1.8.0",
|
|
30
30
|
"@nuxt/icon": "1.15.0",
|
|
31
31
|
"@nuxt/test-utils": "3.19.2",
|
|
32
32
|
"@vue/test-utils": "2.4.6",
|