srcdev-nuxt-forms 2.4.23 → 3.0.0

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.
Files changed (85) hide show
  1. package/nuxt.config.ts +3 -0
  2. package/package.json +2 -2
  3. package/assets/styles/ally/_utils.css +0 -20
  4. package/assets/styles/ally/_variables.css +0 -8
  5. package/assets/styles/ally/index.css +0 -2
  6. package/assets/styles/forms/index.css +0 -2
  7. package/assets/styles/forms/themes/_error.css +0 -85
  8. package/assets/styles/forms/themes/_ghost.css +0 -85
  9. package/assets/styles/forms/themes/_input-action-underlined.css +0 -20
  10. package/assets/styles/forms/themes/_input-action.css +0 -20
  11. package/assets/styles/forms/themes/_primary.css +0 -90
  12. package/assets/styles/forms/themes/_secondary.css +0 -85
  13. package/assets/styles/forms/themes/_success.css +0 -85
  14. package/assets/styles/forms/themes/_tertiary.css +0 -85
  15. package/assets/styles/forms/themes/_warning.css +0 -85
  16. package/assets/styles/forms/themes/index.css +0 -9
  17. package/assets/styles/forms/variables/_sizes.css +0 -71
  18. package/assets/styles/forms/variables/_theme.css +0 -11
  19. package/assets/styles/forms/variables/index.css +0 -2
  20. package/assets/styles/main.css +0 -5
  21. package/assets/styles/typography/index.css +0 -2
  22. package/assets/styles/typography/utils/_font-classes.css +0 -190
  23. package/assets/styles/typography/utils/_weights.css +0 -69
  24. package/assets/styles/typography/utils/index.css +0 -2
  25. package/assets/styles/typography/variables/_colors.css +0 -14
  26. package/assets/styles/typography/variables/_reponsive-font-size.css +0 -10
  27. package/assets/styles/typography/variables/index.css +0 -2
  28. package/assets/styles/utils/_margin-helpers.css +0 -334
  29. package/assets/styles/utils/_padding-helpers.css +0 -308
  30. package/assets/styles/utils/_page.css +0 -36
  31. package/assets/styles/utils/index.css +0 -3
  32. package/assets/styles/variables/colors/_blue.css +0 -15
  33. package/assets/styles/variables/colors/_gray.css +0 -16
  34. package/assets/styles/variables/colors/_green.css +0 -15
  35. package/assets/styles/variables/colors/_orange.css +0 -15
  36. package/assets/styles/variables/colors/_red.css +0 -15
  37. package/assets/styles/variables/colors/_yellow.css +0 -15
  38. package/assets/styles/variables/colors/colors.css +0 -6
  39. package/assets/styles/variables/index.css +0 -1
  40. package/components/forms/c12/prop-validators/index.ts +0 -38
  41. package/components/forms/c12/utils.ts +0 -14
  42. package/components/forms/form-errors/InputError.vue +0 -172
  43. package/components/forms/form-errors/tests/InputError.spec.ts +0 -67
  44. package/components/forms/input-button/InputButtonCore.vue +0 -191
  45. package/components/forms/input-button/variants/InputButtonConfirm.vue +0 -66
  46. package/components/forms/input-button/variants/InputButtonSubmit.vue +0 -62
  47. package/components/forms/input-checkbox/MultipleCheckboxes.vue +0 -203
  48. package/components/forms/input-checkbox/SingleCheckbox.vue +0 -169
  49. package/components/forms/input-checkbox/tests/MultipleCheckboxes.spec.ts +0 -98
  50. package/components/forms/input-checkbox/tests/data/tags.json +0 -67
  51. package/components/forms/input-checkbox-radio/InputCheckboxRadioButton.vue +0 -214
  52. package/components/forms/input-checkbox-radio/InputCheckboxRadioCore.vue +0 -191
  53. package/components/forms/input-checkbox-radio/InputCheckboxRadioWithLabel.vue +0 -111
  54. package/components/forms/input-number/InputNumberCore.vue +0 -203
  55. package/components/forms/input-number/variants/InputNumberDefault.vue +0 -154
  56. package/components/forms/input-radio/MultipleRadiobuttons.vue +0 -201
  57. package/components/forms/input-radio/tests/MultipleRadioButtons.spec.ts +0 -89
  58. package/components/forms/input-radio/tests/data/tags.json +0 -67
  59. package/components/forms/input-range/InputRangeCore.vue +0 -274
  60. package/components/forms/input-range/variants/InputRangeDefault.vue +0 -156
  61. package/components/forms/input-range-fancy/InputRangeFancyCore.vue +0 -450
  62. package/components/forms/input-range-fancy/InputRangeFancyWithLabel.vue +0 -124
  63. package/components/forms/input-text/InputTextCore.vue +0 -331
  64. package/components/forms/input-text/variants/InputPasswordWithLabel.vue +0 -130
  65. package/components/forms/input-text/variants/InputTextAsNumberWithLabel.vue +0 -187
  66. package/components/forms/input-text/variants/InputTextWithLabel.vue +0 -298
  67. package/components/forms/input-textarea/InputTextareaCore.vue +0 -234
  68. package/components/forms/input-textarea/variants/InputTextareaWithLabel.vue +0 -267
  69. package/components/forms/toggle-switch/ToggleSwitchCore.vue +0 -216
  70. package/components/forms/toggle-switch/variants/ToggleSwitchWithLabel.vue +0 -105
  71. package/components/forms/toggle-switch/variants/ToggleSwitchWithLabelInline.vue +0 -102
  72. package/components/forms/ui/FormField.vue +0 -78
  73. package/components/forms/ui/FormWrapper.vue +0 -35
  74. package/components/utils/colour-scheme-select/ColourSchemeSelect.vue +0 -270
  75. package/components/utils/colour-scheme-select/ColourSchemeSelectOld.vue +0 -225
  76. package/components/utils/dark-mode-switcher/DarkModeSwitcher.vue +0 -47
  77. package/composables/useApiRequest.ts +0 -25
  78. package/composables/useColourScheme.ts +0 -25
  79. package/composables/useErrorMessages.ts +0 -59
  80. package/composables/useFormControl.ts +0 -248
  81. package/composables/useSleep.ts +0 -5
  82. package/composables/useStyleClassPassthrough.ts +0 -30
  83. package/composables/useZodValidation.ts +0 -148
  84. package/types/types.forms.ts +0 -216
  85. package/types/types.zodFormControl.ts +0 -21
@@ -1,267 +0,0 @@
1
- <template>
2
- <div class="input-textarea-with-label" :data-form-theme="formTheme" :class="[elementClasses, inputVariant, { dirty: isDirty }, { active: isActive }]">
3
- <label :for="id" class="input-textarea-label body-normal-semibold">{{ label }}</label>
4
-
5
- <InputTextareaCore
6
- v-model="modelValue"
7
- v-model:isDirty="isDirty"
8
- v-model:isActive="isActive"
9
- :maxlength
10
- :id
11
- :name
12
- :placeholder
13
- :label
14
- :fieldHasError
15
- :required
16
- :styleClassPassthrough
17
- :theme
18
- :size
19
- :inputVariant
20
- >
21
- <template v-if="hasLeftSlot" #left>
22
- <slot name="left"></slot>
23
- </template>
24
- <template v-if="hasRightSlot" #right>
25
- <slot name="right"></slot>
26
- </template>
27
- </InputTextareaCore>
28
- <InputError :errorMessage :showError="fieldHasError" :id :isDetached="false" />
29
- </div>
30
- </template>
31
-
32
- <script setup lang="ts">
33
- import propValidators from '../../c12/prop-validators';
34
- const props = defineProps({
35
- maxlength: {
36
- type: Number,
37
- default: 255,
38
- },
39
- name: {
40
- type: String,
41
- required: true,
42
- },
43
- placeholder: {
44
- type: String,
45
- default: '',
46
- },
47
- label: {
48
- type: String,
49
- required: true,
50
- },
51
- errorMessage: {
52
- type: [Object, String],
53
- required: true,
54
- },
55
- fieldHasError: {
56
- type: Boolean,
57
- default: false,
58
- },
59
- required: {
60
- type: Boolean,
61
- default: false,
62
- },
63
- styleClassPassthrough: {
64
- type: Array as PropType<string[]>,
65
- default: () => [],
66
- },
67
- theme: {
68
- type: String as PropType<string>,
69
- default: 'primary',
70
- validator(value: string) {
71
- return propValidators.theme.includes(value);
72
- },
73
- },
74
- size: {
75
- type: String as PropType<string>,
76
- default: 'normal',
77
- validator(value: string) {
78
- return propValidators.size.includes(value);
79
- },
80
- },
81
- inputVariant: {
82
- type: String as PropType<string>,
83
- default: 'normal',
84
- validator(value: string) {
85
- return propValidators.inputVariant.includes(value);
86
- },
87
- },
88
- });
89
-
90
- const slots = useSlots();
91
- const hasLeftSlot = computed(() => slots.left !== undefined);
92
- const hasRightSlot = computed(() => slots.right !== undefined);
93
-
94
- const id = useId();
95
- const formTheme = computed(() => {
96
- return props.fieldHasError ? 'error' : props.theme;
97
- });
98
-
99
- const modelValue = defineModel<string | number | readonly string[] | null | undefined>();
100
- const isActive = ref<boolean>(false);
101
- const isDirty = ref<boolean>(false);
102
-
103
- const { elementClasses, updateElementClasses } = useStyleClassPassthrough(props.styleClassPassthrough);
104
-
105
- const testDirty = () => {
106
- const watchValue = modelValue.value ?? '';
107
-
108
- if (!isDirty.value && typeof watchValue === 'string' && watchValue.length > 0) {
109
- isDirty.value = true;
110
- }
111
- };
112
-
113
- onMounted(() => {
114
- testDirty();
115
- });
116
-
117
- watch(
118
- () => modelValue.value,
119
- () => {
120
- testDirty();
121
- }
122
- );
123
- </script>
124
-
125
- <style lang="css">
126
- .input-textarea-with-label {
127
- --_input-textarea-with-label-margin-block-start: 0;
128
- --_input-textarea-with-label-background-color: transparent;
129
-
130
- --_input-textarea-wrapper-border: var(--form-element-border-width) solid var(--theme-form-input-border);
131
- --_input-textarea-wrapper-border-radius: var(--form-input-border-radius);
132
- --_input-textarea-wrapper-border-underlined: var(--form-element-border-width-underlined) solid var(--theme-form-input-border);
133
- --_input-textarea-wrapper-outline: var(--form-element-outline-width) solid var(--theme-form-input-outline);
134
- --_input-textarea-wrapper-box-shadow: var(--_focus-box-shadow);
135
- --_input-textarea-wrapper-padding-block: 0;
136
-
137
- --_focus-box-shadow: var(--box-shadow-off);
138
-
139
- /* Label vars */
140
- --_label-textarea-color: var(--theme-form-input-text-label-color-normal);
141
- --_label-textarea-margin-block: 0.8rem;
142
- --_label-textarea-size: var(--step-2);
143
- --_label-textarea-weight: normal;
144
- --_label-textarea-height: auto;
145
- --_label-textarea-line-height: 1.5;
146
- --_label-textarea-background-color: var(--_input-textarea-with-label-background-color);
147
-
148
- &.underlined {
149
- --_label-textarea-color: var(--theme-form-input-text-label-color-underlined);
150
- --_label-offset: 1rem 0;
151
- --_input-textarea-with-label-background-color: color-mix(in srgb, currentColor 5%, transparent);
152
-
153
- --_input-textarea-wrapper-underlined-border-radius-top-left: 0;
154
- --_input-textarea-wrapper-underlined-border-radius-top-right: 0;
155
- --_input-textarea-wrapper-underlined-border-radius-bottom-left: 4px;
156
- --_input-textarea-wrapper-underlined-border-radius-bottom-right: 4px;
157
-
158
- --_label-textarea-background-color: transparent;
159
- --_label-textarea-height: fit-content;
160
-
161
- &:has(.input-textarea-wrapper.active),
162
- &:has(.input-textarea-wrapper.dirty) {
163
- --_label-offset: 0 -3.2rem;
164
- --_label-textarea-weight: bolder;
165
- --_label-textarea-size: var(--step-1);
166
- /* line-height: 1.5; */
167
- /* padding: 0.2rem 1.2rem; */
168
- }
169
- }
170
-
171
- &.outlined {
172
- --_label-textarea-color: var(--theme-form-input-text-label-color-outlined);
173
-
174
- --_label-offset: 1rem 0;
175
- --_input-textarea-with-label-background-color: var(--theme-form-input-bg-normal);
176
-
177
- --_input-textarea-wrapper-padding-block: 0.4em 0;
178
- --_label-textarea-height: fit-content;
179
-
180
- &:has(.input-textarea-wrapper.active),
181
- &:has(.input-textarea-wrapper.dirty) {
182
- --_label-offset: 1rem -2.8rem;
183
- --_label-textarea-weight: normal;
184
- /* --_label-textarea-size: var(--step-1); */
185
- /* line-height: 1.5; */
186
- /* padding: 0.2rem 1.2rem; */
187
- }
188
- }
189
-
190
- &:not(.normal) {
191
- --_input-textarea-with-label-margin-block-start: 3em;
192
-
193
- &:has(.input-textarea-wrapper.active),
194
- &:has(.input-textarea-wrapper.dirty) {
195
- /* --_label-offset: 1rem -2.8rem; */
196
- /* font-size: var(--step-1); */
197
- /* line-height: 1.5; */
198
- /* padding: 0.2rem 1.2rem; */
199
- }
200
-
201
- &:focus-within {
202
- --_input-textarea-wrapper-box-shadow: var(--box-shadow-on);
203
- --_input-textarea-wrapper-outline: var(--form-element-outline-width) solid hsl(from var(--theme-form-input-outline-focus) h s 90%);
204
- }
205
- }
206
-
207
- /*
208
- * Apply generic styles
209
- **/
210
-
211
- background-color: var(--_input-textarea-with-label-background-color);
212
- border-radius: var(--_input-textarea-wrapper-border-radius);
213
- /* overflow: clip; */
214
-
215
- &.underlined {
216
- border-bottom: var(--_input-textarea-wrapper-border-underlined);
217
- border-top-left-radius: var(--_input-textarea-wrapper-underlined-border-radius-top-left);
218
- border-top-right-radius: var(--_input-textarea-wrapper-underlined-border-radius-top-right);
219
- border-bottom-left-radius: var(--_input-textarea-wrapper-underlined-border-radius-bottom-left);
220
- border-bottom-right-radius: var(--_input-textarea-wrapper-underlined-border-radius-bottom-right);
221
- }
222
-
223
- &.outlined {
224
- border: var(--_input-textarea-wrapper-border);
225
- outline: var(--_input-textarea-wrapper-outline);
226
- box-shadow: var(--_input-textarea-wrapper-box-shadow);
227
- padding-block: var(--_input-textarea-wrapper-padding-block);
228
- }
229
-
230
- &:not(.normal) {
231
- display: grid;
232
- grid-template-columns: 1fr;
233
- grid-template-rows: 1fr;
234
- grid-template-areas: 'underlined-textarea-stack';
235
-
236
- margin-block-start: var(--_input-textarea-with-label-margin-block-start);
237
-
238
- .input-textarea-label {
239
- grid-area: underlined-textarea-stack;
240
- z-index: 2;
241
- }
242
- .input-textarea-wrapper {
243
- grid-area: underlined-textarea-stack;
244
- z-index: 1;
245
- }
246
- }
247
-
248
- .input-textarea-label {
249
- display: inline-block;
250
- color: var(--_label-textarea-color);
251
- background-color: var(--_label-textarea-background-color);
252
- margin-block: var(--_label-textarea-margin-block);
253
- font-size: var(--_label-textarea-size);
254
- font-weight: var(--_label-textarea-weight);
255
- line-height: var(--_label-textarea-line-height);
256
- translate: var(--_label-offset);
257
- width: fit-content;
258
- height: var(--_label-textarea-height);
259
- transition: font-size 0.2s ease-in-out, translate 0.2s ease-in-out;
260
-
261
- &:not(.normal) {
262
- display: flex;
263
- align-items: center;
264
- }
265
- }
266
- }
267
- </style>
@@ -1,216 +0,0 @@
1
- <template>
2
- <div class="toggle-switch-core" :class="elementClasses" :data-size="size" :data-form-theme="formTheme">
3
- <div @click="toggleSwitchValue" class="toggle-switch-input" :class="[{ round }]" :for="inputId">
4
- <input type="checkbox" v-model="modelValue" :true-value :false-value :aria-invalid="fieldHasError" :id="inputId" :aria-describedby="`${id}-description`" :name :required />
5
- <div class="symbol-wrapper" :class="[{ round }]">
6
- <div class="symbol" :class="[{ round }]">
7
- <div v-if="hasIconOnSlot" class="symbol-icon icon-on">
8
- <slot name="iconOn"></slot>
9
- </div>
10
-
11
- <div v-if="hasIconOffSlot" class="symbol-icon icon-off">
12
- <slot name="iconOff"></slot>
13
- </div>
14
- </div>
15
- </div>
16
- </div>
17
- </div>
18
- </template>
19
-
20
- <script setup lang="ts">
21
- import propValidators from '../c12/prop-validators';
22
-
23
- const props = defineProps({
24
- id: {
25
- type: String,
26
- required: true,
27
- },
28
- name: {
29
- type: String,
30
- required: true,
31
- },
32
- required: {
33
- type: Boolean,
34
- default: false,
35
- },
36
- fieldHasError: {
37
- type: Boolean,
38
- default: false,
39
- },
40
- trueValue: {
41
- type: [String, Number, Boolean],
42
- default: true,
43
- },
44
- falseValue: {
45
- type: [String, Number, Boolean],
46
- default: false,
47
- },
48
- styleClassPassthrough: {
49
- type: Array as PropType<string[]>,
50
- default: () => [],
51
- },
52
- theme: {
53
- type: String as PropType<string>,
54
- default: 'primary',
55
- validator(value: string) {
56
- return propValidators.theme.includes(value);
57
- },
58
- },
59
- round: {
60
- type: Boolean,
61
- default: true,
62
- },
63
- size: {
64
- type: String as PropType<string>,
65
- default: 'normal',
66
- validator(value: string) {
67
- return propValidators.size.includes(value);
68
- },
69
- },
70
- ariaDescribedby: {
71
- type: String,
72
- default: null,
73
- },
74
- });
75
-
76
- const slots = useSlots();
77
- const hasIconOnSlot = computed(() => slots.iconOn !== undefined);
78
- const hasIconOffSlot = computed(() => slots.iconOff !== undefined);
79
-
80
- const formTheme = computed(() => {
81
- return props.fieldHasError ? 'error' : props.theme;
82
- });
83
-
84
- const modelValue = defineModel();
85
- const { elementClasses } = useStyleClassPassthrough(props.styleClassPassthrough);
86
-
87
- const inputId = computed(() => `toggle-sitch-${props.id}`);
88
-
89
- const toggleSwitchValue = () => {
90
- modelValue.value = modelValue.value === props.trueValue ? props.falseValue : props.trueValue;
91
- };
92
- </script>
93
-
94
- <style lang="css">
95
- .toggle-switch-core {
96
- --_transition-duration: 0.4s;
97
-
98
- .toggle-switch-label {
99
- display: block;
100
- }
101
-
102
- .toggle-switch-input {
103
- position: relative;
104
- display: inline-block;
105
- height: calc(var(--form-toggle-symbol-size) + calc(var(--form-element-border-width) * 2) + calc(var(--form-element-outline-width) * 2));
106
- width: calc(var(--form-toggle-symbol-size) * 2 - calc(var(--form-element-border-width) * 2) + calc(var(--form-element-outline-width) * 2) + var(--form-toggle-switch-width-adjustment));
107
-
108
- input {
109
- opacity: 0;
110
- width: 0;
111
- height: 0;
112
- }
113
- input:checked {
114
- --_icon-on-opacity: 1;
115
- --_icon-off-opacity: 0;
116
- }
117
-
118
- .symbol-wrapper {
119
- position: absolute;
120
- cursor: pointer;
121
- top: 0;
122
- left: 0;
123
- right: 0;
124
- bottom: 0;
125
- overflow: clip;
126
-
127
- .symbol {
128
- display: grid;
129
- grid-template-areas: 'icon-stack';
130
- overflow: clip;
131
- position: absolute;
132
-
133
- .symbol-icon {
134
- grid-area: icon-stack;
135
- display: flex;
136
- align-items: center;
137
- justify-content: center;
138
- }
139
- }
140
- }
141
- }
142
- }
143
-
144
- /*
145
- * ToggleSwitch configurable
146
- **/
147
- .toggle-switch-core {
148
- .toggle-switch-input {
149
- &.round {
150
- border-radius: calc(var(--form-toggle-symbol-size) + calc(var(--form-element-border-width) * 2));
151
- }
152
-
153
- .symbol-wrapper {
154
- border: var(--theme-form-toggle-border);
155
- background-color: var(--theme-form-toggle-bg-off);
156
- outline: var(--theme-form-toggle-outline);
157
- transition: 0.4s;
158
-
159
- &.round {
160
- border-radius: var(--form-toggle-symbol-size);
161
- }
162
- .symbol {
163
- height: calc(var(--form-toggle-symbol-size) - 0.6rem);
164
- width: calc(var(--form-toggle-symbol-size) - 0.6rem);
165
- left: 0.4rem;
166
- bottom: 0.4rem;
167
- background-color: var(--theme-form-toggle-symbol-off);
168
- transition: var(--_transition-duration);
169
-
170
- &.round {
171
- border-radius: 50%;
172
- }
173
-
174
- .symbol-icon {
175
- transition: var(--_transition-duration);
176
-
177
- &.icon-on {
178
- color: var(--theme-form-toggle-icon-stroke-colour-on);
179
- opacity: 0;
180
- }
181
- &.icon-off {
182
- color: var(--theme-form-toggle-icon-stroke-colour-off);
183
- opacity: 1;
184
- }
185
-
186
- .icon {
187
- --_icon-size: var(--form-icon-size);
188
- height: var(--_icon-size);
189
- width: var(--_icon-size);
190
- }
191
- }
192
- }
193
- }
194
-
195
- input:focus-visible + .symbol-wrapper {
196
- box-shadow: var(--box-shadow-on);
197
- outline: var(--form-element-outline-width) solid hsl(from var(--theme-form-input-outline-focus) h s 90%);
198
- }
199
-
200
- input:checked + .symbol-wrapper .symbol {
201
- --_on-position: calc(var(--form-toggle-symbol-size) * 0.8);
202
- background-color: var(--theme-form-toggle-symbol-on);
203
- transform: translateX(var(--_on-position));
204
-
205
- .symbol-icon {
206
- &.icon-on {
207
- opacity: 1;
208
- }
209
- &.icon-off {
210
- opacity: 0;
211
- }
212
- }
213
- }
214
- }
215
- }
216
- </style>
@@ -1,105 +0,0 @@
1
- <template>
2
- <div class="toggle-switch-with-label" :class="[elementClasses]" :data-form-theme="formTheme">
3
- <label class="toggle-switch-label input-text-label body-normal-bold" :for="`toggle-sitch-${id}`">{{ label }}</label>
4
- <div v-if="hasDescriptionSlot" :id="`${id}-description`">
5
- <slot name="description"></slot>
6
- </div>
7
- <ToggleSwitchCore v-model="modelValue" :id :name :required :field-has-error :true-value :false-value :theme :round :size :ariaDescribedby>
8
- <template v-if="hasIconOnSlot" #iconOn>
9
- <slot name="iconOn"></slot>
10
- </template>
11
-
12
- <template v-if="hasIconOffSlot" #iconOff>
13
- <slot name="iconOff"></slot>
14
- </template>
15
- </ToggleSwitchCore>
16
- <InputError :errorMessage :showError="fieldHasError" :id="errorId" :isDetached="true" />
17
- </div>
18
- </template>
19
-
20
- <script setup lang="ts">
21
- import propValidators from '../../c12/prop-validators';
22
-
23
- const props = defineProps({
24
- name: {
25
- type: String,
26
- required: true,
27
- },
28
- label: {
29
- type: String,
30
- required: true,
31
- },
32
- required: {
33
- type: Boolean,
34
- default: false,
35
- },
36
- errorMessage: {
37
- type: [Object, String],
38
- default: '',
39
- required: false,
40
- },
41
- fieldHasError: {
42
- type: Boolean,
43
- default: false,
44
- },
45
- trueValue: {
46
- type: [String, Number, Boolean],
47
- default: true,
48
- },
49
- falseValue: {
50
- type: [String, Number, Boolean],
51
- default: false,
52
- },
53
- styleClassPassthrough: {
54
- type: Array as PropType<string[]>,
55
- default: () => [],
56
- },
57
- theme: {
58
- type: String as PropType<string>,
59
- default: 'primary',
60
- validator(value: string) {
61
- return propValidators.theme.includes(value);
62
- },
63
- },
64
- round: {
65
- type: Boolean,
66
- default: true,
67
- },
68
- size: {
69
- type: String as PropType<string>,
70
- default: 'normal',
71
- validator(value: string) {
72
- return propValidators.size.includes(value);
73
- },
74
- },
75
- });
76
-
77
- const slots = useSlots();
78
- const hasDescriptionSlot = computed(() => slots.description !== undefined);
79
- const hasIconOnSlot = computed(() => slots.iconOn !== undefined);
80
- const hasIconOffSlot = computed(() => slots.iconOff !== undefined);
81
-
82
- const formTheme = computed(() => {
83
- return props.fieldHasError ? 'error' : props.theme;
84
- });
85
-
86
- const id = useId();
87
- const errorId = `${id}-error-message`;
88
- const ariaDescribedby = computed(() => {
89
- const ariaDescribedbyId = hasDescriptionSlot.value ? `${id}-description` : undefined;
90
- return props.fieldHasError ? errorId : ariaDescribedbyId;
91
- });
92
-
93
- const modelValue = defineModel();
94
- const { elementClasses } = useStyleClassPassthrough(props.styleClassPassthrough);
95
- </script>
96
-
97
- <style lang="css">
98
- .toggle-switch-with-label {
99
- --_transition-duration: 0.4s;
100
-
101
- .toggle-switch-label {
102
- display: block;
103
- }
104
- }
105
- </style>
@@ -1,102 +0,0 @@
1
- <template>
2
- <div class="toggle-switch-with-label-inline" :class="[elementClasses]" :data-form-theme="theme">
3
- <label class="toggle-switch-label input-text-label" :class="labelWeightClass" :for="`toggle-sitch-${id}`">{{ label }}</label>
4
- <ToggleSwitchCore v-model="modelValue" :id :name :true-value :false-value :theme :round :size>
5
- <template v-if="hasIconOnSlot" #iconOn>
6
- <slot name="iconOn"></slot>
7
- </template>
8
-
9
- <template v-if="hasIconOffSlot" #iconOff>
10
- <slot name="iconOff"></slot>
11
- </template>
12
- </ToggleSwitchCore>
13
- </div>
14
- </template>
15
-
16
- <script setup lang="ts">
17
- import propValidators from '../../c12/prop-validators';
18
-
19
- const props = defineProps({
20
- name: {
21
- type: String,
22
- required: true,
23
- },
24
- label: {
25
- type: String,
26
- required: true,
27
- },
28
- labelWeight: {
29
- type: String as PropType<string>,
30
- default: 'semi-bold',
31
- validator(value: string) {
32
- return propValidators.labelWeight.includes(value);
33
- },
34
- },
35
- trueValue: {
36
- type: [String, Number, Boolean],
37
- default: true,
38
- },
39
- falseValue: {
40
- type: [String, Number, Boolean],
41
- default: false,
42
- },
43
- styleClassPassthrough: {
44
- type: Array as PropType<string[]>,
45
- default: () => [],
46
- },
47
- theme: {
48
- type: String as PropType<string>,
49
- default: 'primary',
50
- validator(value: string) {
51
- return propValidators.theme.includes(value);
52
- },
53
- },
54
- round: {
55
- type: Boolean,
56
- default: true,
57
- },
58
- size: {
59
- type: String as PropType<string>,
60
- default: 'normal',
61
- validator(value: string) {
62
- return propValidators.size.includes(value);
63
- },
64
- },
65
- });
66
-
67
- const slots = useSlots();
68
- const hasIconOnSlot = computed(() => slots.iconOn !== undefined);
69
- const hasIconOffSlot = computed(() => slots.iconOff !== undefined);
70
-
71
- const id = useId();
72
-
73
- const labelWeightClass = computed(() => {
74
- switch (props.labelWeight) {
75
- case 'bold':
76
- return 'body-normal-bold';
77
- case 'semi-bold':
78
- return 'body-normal-semibold';
79
- case 'normal':
80
- return 'body-normal';
81
- default:
82
- return 'body-normal-semibold';
83
- }
84
- });
85
-
86
- const modelValue = defineModel();
87
- const { elementClasses } = useStyleClassPassthrough(props.styleClassPassthrough);
88
- </script>
89
-
90
- <style lang="css">
91
- .toggle-switch-with-label-inline {
92
- --_transition-duration: 0.4s;
93
- display: flex;
94
- align-items: center;
95
- gap: 12px;
96
-
97
- .toggle-switch-label {
98
- display: block;
99
- white-space: nowrap;
100
- }
101
- }
102
- </style>