srcdev-nuxt-forms 0.1.0 → 0.2.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 (50) hide show
  1. package/LICENSE +21 -0
  2. package/assets/styles/forms/index.css +1 -0
  3. package/assets/styles/forms/themes/_primary.css +2 -0
  4. package/assets/styles/forms/themes/_secondary.css +2 -0
  5. package/assets/styles/forms/utils/_a11y.css +5 -0
  6. package/assets/styles/forms/utils/index.css +1 -0
  7. package/assets/styles/forms/variables/_theme.css +11 -17
  8. package/assets/styles/variables/colors/_gray.css +1 -0
  9. package/components/forms/c12/prop-validators/index.ts +8 -20
  10. package/components/forms/c12/utils.ts +14 -0
  11. package/components/forms/c12/validation-patterns/en.json +12 -0
  12. package/components/forms/form-errors/InputError.vue +132 -0
  13. package/components/forms/input-button/InputButtonCore.vue +11 -8
  14. package/components/forms/input-button/variants/InputButtonConfirm.vue +1 -1
  15. package/components/forms/input-button/variants/InputButtonSubmit.vue +1 -1
  16. package/components/forms/input-checkbox/InputCheckboxCore.vue +407 -0
  17. package/components/forms/input-checkbox/InputCheckboxWithLabel.vue +125 -0
  18. package/components/forms/input-checkbox/variants/MultipleCheckboxes.vue +194 -0
  19. package/components/forms/input-checkbox/variants/SingleCheckbox.vue +157 -0
  20. package/components/forms/input-radio/InputRadioCore.vue +226 -0
  21. package/components/forms/input-radio/InputRadioWithLabel.vue +118 -0
  22. package/components/forms/input-radio/variants/MultipleRadio.vue +183 -0
  23. package/components/forms/input-radio/variants/SingleRadio.vue +131 -0
  24. package/components/forms/input-range/InputRangeCore.vue +171 -0
  25. package/components/forms/input-range/variants/InputRangeDefault.vue +131 -0
  26. package/components/forms/input-text/InputTextCore.vue +61 -31
  27. package/components/forms/input-text/variants/material/InputPasswordMaterial.vue +27 -1
  28. package/components/forms/input-text/variants/material/InputTextMaterial.vue +1 -8
  29. package/components/forms/input-text/variants/material/InputTextMaterialCore.vue +83 -28
  30. package/components/forms/input-textarea/InputTextareaCore.vue +170 -0
  31. package/components/forms/input-textarea/variants/material/InputTextareaMaterial.vue +75 -0
  32. package/components/forms/input-textarea/variants/material/InputTextareaMaterialCore.vue +290 -0
  33. package/components/ui/content-grid/ContentGrid.vue +85 -0
  34. package/composables/useErrorMessages.ts +17 -5
  35. package/composables/useFormControl.ts +147 -37
  36. package/layouts/default.vue +7 -13
  37. package/nuxt.config.ts +22 -0
  38. package/package.json +9 -8
  39. package/pages/forms/examples/buttons/index.vue +14 -13
  40. package/pages/forms/examples/material/text-fields.vue +320 -84
  41. package/pages/limit-text.vue +43 -0
  42. package/server/api/places/list.get.ts +23 -0
  43. package/server/api/textFields.post.ts +37 -0
  44. package/server/api/utils/index.get.ts +20 -0
  45. package/server/data/places/cities.json +37 -0
  46. package/server/data/places/countries.json +55 -0
  47. package/server/data/utils/title.json +49 -0
  48. package/types/types.forms.ts +33 -3
  49. package/types/types.places.ts +8 -0
  50. package/pages/forms/examples/material/text-fields-compact.vue +0 -136
@@ -0,0 +1,194 @@
1
+ <template>
2
+ <fieldset class="multiple-checkboxes-fieldset" :class="[`theme-${theme}`, { error: fieldHasError }]">
3
+ <legend :class="[{ 'has-description': hasDescription }]">{{ legend }}</legend>
4
+ <template v-if="hasDescription">
5
+ <slot name="description"></slot>
6
+ </template>
7
+ <InputError :errorMessaging :fieldHasError :id="name" :isDetached="true" />
8
+ <div class="multiple-checkboxes-items" :class="[optionsLayout]">
9
+ <template v-for="item in fieldData.data" :key="item.id">
10
+ <InputCheckboxWithLabel
11
+ :id="item.value"
12
+ :name
13
+ :required
14
+ :c12="{
15
+ label: item.label,
16
+ placeholder: 'eg. Type something here',
17
+ errorMessage: 'Please accept our terms and conditions',
18
+ }"
19
+ v-model="modelValue"
20
+ :true-value="item.value"
21
+ :theme
22
+ :size
23
+ :checkboxAppearance
24
+ :checkboxStyle
25
+ />
26
+ </template>
27
+ </div>
28
+ </fieldset>
29
+ </template>
30
+
31
+ <script setup lang="ts">
32
+ import propValidators from '../../c12/prop-validators';
33
+ import type { IOptionsConfig, IFormMultipleOptions } from '@/types/types.forms';
34
+
35
+ import type { InpuTextC12, IFormFieldC12, IFormData } from '@/types/types.forms';
36
+
37
+ const props = defineProps({
38
+ name: {
39
+ type: String,
40
+ required: true,
41
+ },
42
+ legend: {
43
+ type: String,
44
+ required: true,
45
+ },
46
+ required: {
47
+ type: Boolean,
48
+ value: false,
49
+ },
50
+ c12: {
51
+ type: Object as PropType<InpuTextC12>,
52
+ required: true,
53
+ },
54
+ multipleOptions: {
55
+ type: Boolean,
56
+ default: false,
57
+ },
58
+ styleClassPassthrough: {
59
+ type: String,
60
+ default: '',
61
+ },
62
+ theme: {
63
+ type: String as PropType<string>,
64
+ default: 'primary',
65
+ validator(value: string) {
66
+ return propValidators.theme.includes(value);
67
+ },
68
+ },
69
+ size: {
70
+ type: String as PropType<string>,
71
+ default: 'medium',
72
+ validator(value: string) {
73
+ return propValidators.size.includes(value);
74
+ },
75
+ },
76
+ optionsLayout: {
77
+ type: String as PropType<string>,
78
+ default: 'equal-widths',
79
+ validator(value: string) {
80
+ return propValidators.optionsLayout.includes(value);
81
+ },
82
+ },
83
+ equalCols: {
84
+ type: Boolean,
85
+ default: true,
86
+ },
87
+ checkboxAppearance: {
88
+ type: String as PropType<string>,
89
+ default: null,
90
+ validator(value: string) {
91
+ return propValidators.checkboxAppearance.includes(value);
92
+ },
93
+ },
94
+ checkboxStyle: {
95
+ type: String as PropType<string>,
96
+ default: 'check',
97
+ validator(value: string) {
98
+ return propValidators.checkboxStyle.includes(value);
99
+ },
100
+ },
101
+ });
102
+
103
+ const slots = useSlots();
104
+ const hasDescription = computed(() => slots.description !== undefined);
105
+
106
+ const modelValue = defineModel() as Ref<IFormData>;
107
+ const fieldData = defineModel('fieldData') as Ref<IFormMultipleOptions>;
108
+
109
+ // const isArray = Array.isArray(modelValue.value.data[props.name]);
110
+ // const formFieldC12 = <IFormFieldC12>{
111
+ // label: props.c12.label,
112
+ // placeholder: props.c12.placeholder,
113
+ // errorMessage: props.c12.errorMessage,
114
+ // useCustomError: false,
115
+ // customErrors: {},
116
+ // isValid: false,
117
+ // isDirty: false,
118
+ // type: isArray ? 'array' : 'string',
119
+ // previousValue: null,
120
+ // };
121
+ // modelValue.value.formFieldsC12[props.name] = formFieldC12;
122
+
123
+ const fieldHasError = computed(() => {
124
+ return modelValue.value!.submitAttempted && !modelValue.value!.formFieldsC12[props.name].isValid;
125
+ });
126
+
127
+ const errorMessaging = computed(() => {
128
+ if (
129
+ typeof modelValue.value!.formFieldsC12[props.name] !== 'undefined' &&
130
+ modelValue.value!.formFieldsC12[props.name].useCustomError &&
131
+ modelValue.value.data[props.name] === modelValue.value.formFieldsC12[props.name].previousValue
132
+ ) {
133
+ return modelValue.value.formFieldsC12[props.name]?.customErrors || [];
134
+ } else {
135
+ return props.c12.errorMessage;
136
+ }
137
+ });
138
+ </script>
139
+
140
+ <style lang="css">
141
+ .multiple-checkboxes-fieldset {
142
+ --_form-theme: var(--theme-form-primary);
143
+
144
+ margin: 0;
145
+ padding: 0;
146
+ border: 0;
147
+
148
+ &.theme-secondary {
149
+ --_form-theme: var(--theme-form-secondary);
150
+ }
151
+
152
+ &.error {
153
+ --_form-theme: var(--theme-error);
154
+ }
155
+
156
+ legend {
157
+ color: var(--_form-theme);
158
+ font-family: var(--font-family);
159
+ font-size: 18px;
160
+ font-weight: 500;
161
+
162
+ &.has-description {
163
+ margin-bottom: 0;
164
+ }
165
+ }
166
+
167
+ .label-description {
168
+ font-family: var(--font-family);
169
+ font-size: 16px;
170
+ margin-top: 12px;
171
+ color: var(--theme-form-secondary);
172
+ }
173
+ }
174
+
175
+ .multiple-checkboxes-items {
176
+ display: flex;
177
+ gap: 12px;
178
+ margin-top: 12px;
179
+
180
+ &.inline {
181
+ flex-direction: row;
182
+ flex-wrap: wrap;
183
+ }
184
+
185
+ &.block {
186
+ flex-direction: column;
187
+ }
188
+
189
+ &.equal-widths {
190
+ display: grid;
191
+ grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
192
+ }
193
+ }
194
+ </style>
@@ -0,0 +1,157 @@
1
+ <template>
2
+ <fieldset class="single-checkbox-fieldset" :class="[styleClassPassthrough, `theme-${theme}`, { error: fieldHasError }]">
3
+ <legend :class="[{ 'has-description': hasDescription }]">{{ legend }}</legend>
4
+ <template v-if="hasDescription">
5
+ <slot name="description"></slot>
6
+ </template>
7
+ <InputError :errorMessaging :fieldHasError :id="name" :isDetached="true" />
8
+ <InputCheckboxWithLabel :id :name :required :c12 v-model="modelValue" :theme :size :checkboxAppearance :checkboxStyle />
9
+ </fieldset>
10
+ </template>
11
+
12
+ <script setup lang="ts">
13
+ import propValidators from '../../c12/prop-validators';
14
+
15
+ import type { InpuTextC12, IFormFieldC12, IFormData } from '@/types/types.forms';
16
+ // import { validationConfig } from '@/components/forms/c12/validation-patterns';
17
+
18
+ const props = defineProps({
19
+ id: {
20
+ // type: String as PropType<string>,
21
+ type: String,
22
+ required: true,
23
+ },
24
+ name: {
25
+ type: String,
26
+ required: true,
27
+ },
28
+ legend: {
29
+ type: String,
30
+ required: true,
31
+ },
32
+ required: {
33
+ type: Boolean,
34
+ value: false,
35
+ },
36
+ c12: {
37
+ type: Object as PropType<InpuTextC12>,
38
+ required: true,
39
+ },
40
+ trueValue: {
41
+ type: [String, Number, Boolean],
42
+ default: true,
43
+ },
44
+ falseValue: {
45
+ type: [String, Number, Boolean],
46
+ default: false,
47
+ },
48
+ multipleOptions: {
49
+ type: Boolean,
50
+ default: false,
51
+ },
52
+ styleClassPassthrough: {
53
+ type: String,
54
+ default: '',
55
+ },
56
+ theme: {
57
+ type: String as PropType<string>,
58
+ default: 'primary',
59
+ validator(value: string) {
60
+ return propValidators.theme.includes(value);
61
+ },
62
+ },
63
+ size: {
64
+ type: String as PropType<string>,
65
+ default: 'medium',
66
+ validator(value: string) {
67
+ return propValidators.size.includes(value);
68
+ },
69
+ },
70
+ checkboxAppearance: {
71
+ type: String as PropType<string>,
72
+ default: null,
73
+ validator(value: string) {
74
+ return propValidators.checkboxAppearance.includes(value);
75
+ },
76
+ },
77
+ checkboxStyle: {
78
+ type: String as PropType<string>,
79
+ default: 'check',
80
+ validator(value: string) {
81
+ return propValidators.checkboxStyle.includes(value);
82
+ },
83
+ },
84
+ });
85
+
86
+ const slots = useSlots();
87
+ const hasDescription = computed(() => slots.description !== undefined);
88
+
89
+ const modelValue = defineModel() as Ref<IFormData>;
90
+ const name = computed(() => {
91
+ return props.name !== null ? props.name : props.id;
92
+ });
93
+ const fieldHasError = computed(() => {
94
+ return modelValue.value!.submitAttempted && !modelValue.value!.formFieldsC12[name.value].isValid;
95
+ });
96
+
97
+ const errorMessaging = computed(() => {
98
+ if (
99
+ typeof modelValue.value!.formFieldsC12[props.name] !== 'undefined' &&
100
+ modelValue.value!.formFieldsC12[props.name].useCustomError &&
101
+ modelValue.value.data[props.name] === modelValue.value.formFieldsC12[props.name].previousValue
102
+ ) {
103
+ return modelValue.value.formFieldsC12[props.name]?.customErrors || [];
104
+ } else {
105
+ return props.c12.errorMessage;
106
+ }
107
+ });
108
+ </script>
109
+
110
+ <style lang="css">
111
+ .single-checkbox-fieldset {
112
+ --_form-theme: var(--theme-form-primary);
113
+
114
+ margin: 0;
115
+ padding: 0;
116
+ border: 0;
117
+
118
+ &.theme-secondary {
119
+ --_form-theme: var(--theme-form-secondary);
120
+ }
121
+
122
+ &.error {
123
+ --_form-theme: var(--theme-error);
124
+ }
125
+
126
+ legend {
127
+ color: var(--_form-theme);
128
+ font-family: var(--font-family);
129
+ font-size: 18px;
130
+ font-weight: 500;
131
+ margin-bottom: 12px;
132
+ transition: color 0.2s;
133
+
134
+ &.has-description {
135
+ margin-bottom: 0;
136
+ }
137
+ }
138
+
139
+ .label-description {
140
+ font-family: var(--font-family);
141
+ font-size: 16px;
142
+ margin-top: 12px;
143
+ color: var(--theme-form-secondary);
144
+ }
145
+
146
+ .input-checkbox-with-label {
147
+ margin-block-start: 12px;
148
+ }
149
+
150
+ /* &:has(.input-error-message.show) {
151
+ .input-checkbox-with-label {
152
+ margin-block-start: 12px;
153
+ transition: margin 500ms linear;
154
+ }
155
+ } */
156
+ }
157
+ </style>
@@ -0,0 +1,226 @@
1
+ <template>
2
+ <div class="input-radio-wrapper" :class="[`theme-${theme}`, size, radioAppearance, { error: fieldHasError }]">
3
+ <input
4
+ type="radio"
5
+ :true-value="trueValue"
6
+ :false-value="falseValue"
7
+ :id
8
+ :name
9
+ :required="props.required && !props.multipleOptions"
10
+ :value="trueValue"
11
+ :class="['input-radio-core', radioAppearance]"
12
+ v-model="modelValue.data[name]"
13
+ ref="inputField"
14
+ />
15
+ <div v-if="radioAppearance === 'with-decorator'" class="input-radio-decorator"></div>
16
+ </div>
17
+ </template>
18
+
19
+ <script setup lang="ts">
20
+ import propValidators from '../c12/prop-validators';
21
+ import type { InpuTextC12, IFormFieldC12, IFormData } from '@/types/types.forms';
22
+
23
+ const props = defineProps({
24
+ id: {
25
+ // type: String as PropType<string>,
26
+ type: String,
27
+ required: true,
28
+ },
29
+ name: {
30
+ type: String,
31
+ required: true,
32
+ },
33
+ required: {
34
+ type: Boolean,
35
+ value: false,
36
+ },
37
+ c12: {
38
+ type: Object as PropType<InpuTextC12>,
39
+ required: true,
40
+ },
41
+ trueValue: {
42
+ type: [String, Number, Boolean],
43
+ default: true,
44
+ },
45
+ falseValue: {
46
+ type: [String, Number, Boolean],
47
+ default: false,
48
+ },
49
+ multipleOptions: {
50
+ type: Boolean,
51
+ default: false,
52
+ },
53
+ styleClassPassthrough: {
54
+ type: 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
+ size: {
65
+ type: String as PropType<string>,
66
+ default: 'medium',
67
+ validator(value: string) {
68
+ return propValidators.size.includes(value);
69
+ },
70
+ },
71
+ radioAppearance: {
72
+ type: String as PropType<string>,
73
+ default: null,
74
+ validator(value: string) {
75
+ return propValidators.radioAppearance.includes(value);
76
+ },
77
+ },
78
+ });
79
+
80
+ const modelValue = defineModel() as Ref<IFormData>;
81
+
82
+ const name = computed(() => {
83
+ return props.name !== null ? props.name : props.id;
84
+ });
85
+
86
+ const inputField = ref<HTMLInputElement | null>(null);
87
+
88
+ const isArray = Array.isArray(modelValue.value.data[name.value]);
89
+
90
+ const fieldHasError = computed(() => {
91
+ return modelValue.value!.submitAttempted && !modelValue.value!.formFieldsC12[name.value].isValid;
92
+ });
93
+
94
+ if (modelValue.value.formFieldsC12[name.value] === undefined) {
95
+ const formFieldC12 = <IFormFieldC12>{
96
+ label: props.c12.label,
97
+ placeholder: props.c12.placeholder,
98
+ errorMessage: props.c12.errorMessage,
99
+ useCustomError: false,
100
+ customErrors: {},
101
+ isValid: false,
102
+ isDirty: false,
103
+ type: isArray ? 'array' : 'string',
104
+ previousValue: null,
105
+ };
106
+ modelValue.value.formFieldsC12[name.value] = formFieldC12;
107
+ }
108
+
109
+ const fieldValue = computed(() => {
110
+ return modelValue.value.data[name.value];
111
+ });
112
+
113
+ watch(fieldValue, () => {
114
+ if (isArray) {
115
+ modelValue.value.validityState[name.value] = Object.values(modelValue.value.data[name.value] ?? []).length > 0;
116
+ modelValue.value!.formFieldsC12[name.value].isValid = modelValue.value.validityState[name.value];
117
+ } else {
118
+ if (!modelValue.value!.formFieldsC12[name.value].isDirty) {
119
+ modelValue.value!.formFieldsC12[name.value].isDirty = modelValue.value.data[name.value] !== '';
120
+ }
121
+ modelValue.value!.formFieldsC12[name.value].isValid = inputField.value?.validity.valid ?? false;
122
+ modelValue.value!.validityState[name.value] = inputField.value?.validity.valid ?? false;
123
+ }
124
+ });
125
+ </script>
126
+
127
+ <style scoped lang="css">
128
+ .input-radio-wrapper {
129
+ --_radio-size: initial;
130
+ --_radio-border-radius: 50%;
131
+ --_form-theme: var(--theme-form-primary);
132
+ --_outline-width: var(--input-outline-width-thin);
133
+ --_border-width: var(--input-border-width-thin);
134
+ --_border-color: var(--_form-theme);
135
+ --_focus-colour: var(--theme-form-primary-focus);
136
+ --_background-colour: var(--theme-form-primary-radio-color-bg);
137
+ --_background: none;
138
+ --_decorator-size: calc(var(--_radio-size) - (var(--_border-width) * 2));
139
+ --_checked-color: var(--_background-colour);
140
+ --_box-shadow: 0 0 2px 3px transparent;
141
+
142
+ display: grid;
143
+ grid-template-areas: 'radio-stack';
144
+
145
+ &.theme-secondary {
146
+ --_form-theme: var(--theme-form-secondary);
147
+ --_focus-colour: var(--theme-form-secondary-focus);
148
+ --_background-colour: var(--theme-form-secondary-radio-color-bg);
149
+ }
150
+
151
+ &.error {
152
+ --_form-theme: var(--theme-error);
153
+ }
154
+
155
+ /* Sizes */
156
+ &.x-small {
157
+ --_radio-size: 20px;
158
+ }
159
+ &.small {
160
+ --_radio-size: 24px;
161
+ }
162
+ &.normal {
163
+ --_radio-size: 30px;
164
+ }
165
+ &.medium {
166
+ --_radio-size: 40px;
167
+ }
168
+ &.large {
169
+ --_radio-size: 44px;
170
+ }
171
+
172
+ &:has(.input-radio-core.with-decorator:focus-visible) {
173
+ --_border-color: white;
174
+ --_box-shadow: 0 0 2px 3px var(--_focus-colour);
175
+ --_focus-colour: var(--_focus-colour);
176
+
177
+ &.theme-primary {
178
+ --_focus-colour: var(--theme-form-primary-focus);
179
+ }
180
+
181
+ &.theme-secondary {
182
+ --_focus-colour: var(--theme-form-secondary-focus);
183
+ }
184
+ }
185
+
186
+ &:has(.input-radio-core.with-decorator:checked) {
187
+ --_checked-color: hsl(from var(--_form-theme) h s 50%);
188
+ --_background: radial-gradient(circle, rgba(63, 94, 251, 1) 30%, rgba(63, 94, 251, 0.5550814075630253) 70%, rgba(255, 255, 255, 0.42622986694677867) 100%);
189
+ }
190
+
191
+ &.with-decorator {
192
+ border-radius: var(--_radio-border-radius);
193
+ border: var(--_border-width) solid var(--_border-color);
194
+ height: var(--_radio-size);
195
+ width: var(--_radio-size);
196
+
197
+ .input-radio-decorator {
198
+ grid-area: radio-stack;
199
+ height: var(--_decorator-size);
200
+ width: var(--_decorator-size);
201
+ border: var(--_border-width) solid var(--_background-colour);
202
+ border-radius: var(--_radio-border-radius);
203
+ background: var(--_checked-color);
204
+ /* background: rgb(0, 0, 255); */
205
+ background: var(--_background);
206
+ box-shadow: var(--_box-shadow);
207
+ outline-color: var(--_focus-colour);
208
+ }
209
+
210
+ .input-radio-core {
211
+ grid-area: radio-stack;
212
+ &.with-decorator {
213
+ opacity: 0;
214
+ appearance: none;
215
+ overflow: hidden;
216
+ height: var(--_radio-size);
217
+ width: var(--_radio-size);
218
+ }
219
+
220
+ &:hover {
221
+ cursor: pointer;
222
+ }
223
+ }
224
+ }
225
+ }
226
+ </style>
@@ -0,0 +1,118 @@
1
+ <template>
2
+ <div class="input-radio-with-label" :class="[styleClassPassthrough, `theme-${theme}`, { error: fieldHasError }]">
3
+ <InputRadioCore :id :name :required :c12 v-model="modelValue" :theme :size :trueValue :falseValue :radioAppearance />
4
+ <label class="input-radio-label" :for="id">{{ c12.label }}</label>
5
+ </div>
6
+ </template>
7
+
8
+ <script setup lang="ts">
9
+ import propValidators from '../c12/prop-validators';
10
+
11
+ import type { InpuTextC12, IFormFieldC12, IFormData } from '@/types/types.forms';
12
+ // import { validationConfig } from '@/components/forms/c12/validation-patterns';
13
+
14
+ const props = defineProps({
15
+ id: {
16
+ // type: String as PropType<string>,
17
+ type: String,
18
+ required: true,
19
+ },
20
+ name: {
21
+ type: String,
22
+ required: true,
23
+ },
24
+ required: {
25
+ type: Boolean,
26
+ value: false,
27
+ },
28
+ c12: {
29
+ type: Object as PropType<InpuTextC12>,
30
+ required: true,
31
+ },
32
+ trueValue: {
33
+ type: [String, Number, Boolean],
34
+ default: true,
35
+ },
36
+ falseValue: {
37
+ type: [String, Number, Boolean],
38
+ default: false,
39
+ },
40
+ multipleOptions: {
41
+ type: Boolean,
42
+ default: false,
43
+ },
44
+ styleClassPassthrough: {
45
+ type: String,
46
+ default: '',
47
+ },
48
+ theme: {
49
+ type: String as PropType<string>,
50
+ default: 'primary',
51
+ validator(value: string) {
52
+ return propValidators.theme.includes(value);
53
+ },
54
+ },
55
+ size: {
56
+ type: String as PropType<string>,
57
+ default: 'medium',
58
+ validator(value: string) {
59
+ return propValidators.size.includes(value);
60
+ },
61
+ },
62
+ radioAppearance: {
63
+ type: String as PropType<string>,
64
+ default: null,
65
+ validator(value: string) {
66
+ return propValidators.radioAppearance.includes(value);
67
+ },
68
+ },
69
+ });
70
+
71
+ const slots = useSlots();
72
+ const hasLeftContent = computed(() => slots.left !== undefined);
73
+ const hasRightContent = computed(() => slots.right !== undefined);
74
+
75
+ const modelValue = defineModel() as Ref<IFormData>;
76
+ const name = computed(() => {
77
+ return props.name !== null ? props.name : props.id;
78
+ });
79
+ const fieldHasError = computed(() => {
80
+ return modelValue.value!.submitAttempted && !modelValue.value!.formFieldsC12[name.value].isValid;
81
+ });
82
+ </script>
83
+
84
+ <style lang="css">
85
+ .input-radio-with-label {
86
+ --_form-theme: var(--theme-form-primary);
87
+ --_border-width: var(--input-border-width-default);
88
+ --_outline-width: var(--input-outline-width-thin);
89
+ --_radio-size: 40px;
90
+
91
+ display: flex;
92
+ align-items: center;
93
+
94
+ &.theme-secondary {
95
+ --_form-theme: var(--theme-form-secondary);
96
+ }
97
+
98
+ &.error {
99
+ --_form-theme: var(--theme-error);
100
+ }
101
+
102
+ .input-radio-label {
103
+ color: var(--_form-theme);
104
+ font-family: var(--font-family);
105
+ font-size: 14px;
106
+ font-weight: 500;
107
+ display: flex;
108
+ width: 100%;
109
+ height: 100%;
110
+ align-items: center;
111
+ padding-inline: 10px;
112
+
113
+ &:hover {
114
+ cursor: pointer;
115
+ }
116
+ }
117
+ }
118
+ </style>