srcdev-nuxt-forms 0.2.0 → 1.0.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/assets/styles/brand/_brand.css +150 -0
- package/assets/styles/brand/_brand_dark.css +152 -0
- package/assets/styles/brand/_palette_dark.css +148 -0
- package/assets/styles/brand/_palette_light.css +148 -0
- package/assets/styles/brand/_typography.css +176 -0
- package/assets/styles/brand/index.css +1 -0
- package/assets/styles/forms/index.css +1 -2
- package/assets/styles/forms/themes/_default.css +3 -0
- package/assets/styles/forms/themes/_error.css +45 -11
- package/assets/styles/forms/themes/_ghost.css +42 -10
- package/assets/styles/forms/themes/_primary.css +42 -12
- package/assets/styles/forms/themes/_secondary.css +42 -12
- package/assets/styles/forms/themes/_success.css +42 -11
- package/assets/styles/forms/themes/_tertiary.css +42 -10
- package/assets/styles/forms/themes/_warning.css +42 -10
- package/assets/styles/forms/themes/index.css +1 -0
- package/assets/styles/forms/variables/_palette.css +104 -0
- package/assets/styles/forms/variables/_theme.css +1 -1
- package/assets/styles/forms/variables/index.css +2 -0
- package/assets/styles/main.css +2 -0
- package/assets/styles/scaffolding/_margin-helpers.css +308 -0
- package/assets/styles/scaffolding/_padding-helpers.css +308 -0
- package/assets/styles/scaffolding/_page.css +23 -0
- package/assets/styles/scaffolding/index.css +3 -0
- package/assets/styles/variables/colors/_blue.css +2 -2
- package/assets/styles/variables/colors/_gray.css +1 -1
- package/assets/styles/variables/colors/_green.css +2 -2
- package/assets/styles/variables/colors/_orange.css +2 -2
- package/assets/styles/variables/colors/_red.css +2 -2
- package/assets/styles/variables/colors/_yellow.css +1 -1
- package/components/forms/form-errors/InputError.vue +82 -37
- package/components/forms/input-button/InputButtonCore.vue +25 -104
- package/components/forms/input-checkbox/InputCheckboxCore.vue +37 -181
- package/components/forms/input-checkbox/InputCheckboxWithLabel.vue +42 -51
- package/components/forms/input-checkbox/variants/MultipleCheckboxes.vue +42 -69
- package/components/forms/input-checkbox/variants/SingleCheckbox.vue +126 -111
- package/components/forms/input-number/InputNumberCore.vue +184 -0
- package/components/forms/input-number/variants/InputNumberDefault.vue +155 -0
- package/components/forms/input-radio/InputRadiobuttonCore.vue +212 -0
- package/components/forms/input-radio/InputRadiobuttonWithLabel.vue +103 -0
- package/components/forms/input-radio/variants/MultipleRadiobuttons.vue +166 -0
- package/components/forms/input-range/InputRangeCore.vue +70 -88
- package/components/forms/input-range/variants/InputRangeDefault.vue +74 -46
- package/components/forms/input-text/InputTextCore.vue +141 -109
- package/components/forms/input-text/variants/material/InputPasswordWithLabel.vue +99 -0
- package/components/forms/input-text/variants/material/InputTextAsNumberWithLabel.vue +142 -0
- package/components/forms/input-text/variants/material/InputTextWithLabel.vue +125 -0
- package/components/forms/input-textarea/InputTextareaCore.vue +96 -105
- package/components/forms/input-textarea/variants/InputTextareaWithLabel.vue +106 -0
- package/components/scaffolding/footer/NavFooter.vue +62 -0
- package/composables/useApiRequest.ts +25 -0
- package/composables/useFormControl.ts +2 -0
- package/composables/useSleep.ts +2 -2
- package/composables/useStyleClassPassthrough.ts +30 -0
- package/composables/useZodValidation.ts +120 -0
- package/layouts/default.vue +21 -5
- package/package.json +13 -9
- package/pages/forms/examples/material/cssbattle.vue +60 -0
- package/pages/forms/examples/material/text-fields.vue +375 -153
- package/pages/index.vue +2 -2
- package/pages/typography.vue +83 -0
- package/server/data/places/cities.json +7 -1
- package/types/types.forms.ts +102 -0
- package/types/types.zodFormControl.ts +21 -0
- package/assets/styles/forms/utils/_a11y.css +0 -5
- package/assets/styles/forms/utils/index.css +0 -1
- package/components/forms/input-radio/InputRadioCore.vue +0 -226
- package/components/forms/input-radio/InputRadioWithLabel.vue +0 -118
- package/components/forms/input-radio/variants/MultipleRadio.vue +0 -183
- package/components/forms/input-radio/variants/SingleRadio.vue +0 -131
- package/components/forms/input-text/variants/material/InputEmailMaterial.vue +0 -72
- package/components/forms/input-text/variants/material/InputPasswordMaterial.vue +0 -114
- package/components/forms/input-text/variants/material/InputTextMaterial.vue +0 -68
- package/components/forms/input-text/variants/material/InputTextMaterialCore.vue +0 -313
- package/components/forms/input-textarea/variants/material/InputTextareaMaterial.vue +0 -75
- package/components/forms/input-textarea/variants/material/InputTextareaMaterialCore.vue +0 -290
- package/composables/useUpdateStyleClassPassthrough.ts +0 -29
package/pages/index.vue
CHANGED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<NuxtLayout name="default">
|
|
4
|
+
<template #layout-content>
|
|
5
|
+
<h1 class="heading-3">Typography</h1>
|
|
6
|
+
<h2 class="heading-4">Headings</h2>
|
|
7
|
+
<ul>
|
|
8
|
+
<li class="heading-1">Heading 1</li>
|
|
9
|
+
<li class="heading-2">Heading 2</li>
|
|
10
|
+
<li class="heading-3">Heading 3</li>
|
|
11
|
+
<li class="heading-4">Heading 4</li>
|
|
12
|
+
<li class="heading-5">Heading 5</li>
|
|
13
|
+
<li class="heading-6">Heading 6</li>
|
|
14
|
+
</ul>
|
|
15
|
+
|
|
16
|
+
<h2 class="heading-4">Body Regular</h2>
|
|
17
|
+
<ul>
|
|
18
|
+
<li class="body-large">Body Large</li>
|
|
19
|
+
<li class="body-normal">Body Normal</li>
|
|
20
|
+
<li class="body-small">Body Small</li>
|
|
21
|
+
<li class="body-xsmall">Body X-Small</li>
|
|
22
|
+
</ul>
|
|
23
|
+
|
|
24
|
+
<h2 class="heading-4">Body Semi-Bold</h2>
|
|
25
|
+
<ul>
|
|
26
|
+
<li class="body-large-semibold">Body Large Semi-Bold</li>
|
|
27
|
+
<li class="body-normal-semibold">Body Normal Semi-Bold</li>
|
|
28
|
+
<li class="body-small-semibold">Body Small Semi-Bold</li>
|
|
29
|
+
<li class="body-xsmall-semibold">Body X-Small Semi-Bold</li>
|
|
30
|
+
</ul>
|
|
31
|
+
|
|
32
|
+
<h2 class="heading-4">Body Bold</h2>
|
|
33
|
+
<ul>
|
|
34
|
+
<li class="body-large-bold">Body Large Bold</li>
|
|
35
|
+
<li class="body-normal-bold">Body Normal Bold</li>
|
|
36
|
+
<li class="body-small-bold">Body Small Bold</li>
|
|
37
|
+
<li class="body-xsmall-bold">Body X-Small Bold</li>
|
|
38
|
+
</ul>
|
|
39
|
+
|
|
40
|
+
<h2 class="heading-4">Links</h2>
|
|
41
|
+
<ul>
|
|
42
|
+
<li class="link-large">Link Large</li>
|
|
43
|
+
<li class="link-normal">Link Normal</li>
|
|
44
|
+
<li class="link-small">Link Small</li>
|
|
45
|
+
<li class="link-xsmall">Link X-Small</li>
|
|
46
|
+
</ul>
|
|
47
|
+
</template>
|
|
48
|
+
</NuxtLayout>
|
|
49
|
+
</div>
|
|
50
|
+
</template>
|
|
51
|
+
|
|
52
|
+
<script setup lang="ts">
|
|
53
|
+
definePageMeta({
|
|
54
|
+
layout: false,
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
useHead({
|
|
58
|
+
title: 'Typography Examples',
|
|
59
|
+
meta: [{ name: 'description', content: 'Typography' }],
|
|
60
|
+
bodyAttrs: {
|
|
61
|
+
class: 'typography',
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
</script>
|
|
65
|
+
|
|
66
|
+
<style lang="css">
|
|
67
|
+
.typography {
|
|
68
|
+
/* font-family: 'Poppins', Sans-serif; */
|
|
69
|
+
/* font-family: var(--font-family); */
|
|
70
|
+
|
|
71
|
+
ul {
|
|
72
|
+
list-style-type: none;
|
|
73
|
+
padding: 0;
|
|
74
|
+
|
|
75
|
+
li {
|
|
76
|
+
background: #ffffff;
|
|
77
|
+
border-radius: 5px;
|
|
78
|
+
padding: 10px;
|
|
79
|
+
margin-block-end: 20px;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
</style>
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"data": [
|
|
3
|
+
{
|
|
4
|
+
"id": "bradford-on-avon",
|
|
5
|
+
"name": "cities",
|
|
6
|
+
"value": "cities-2",
|
|
7
|
+
"label": "Bradford on Avon"
|
|
8
|
+
},
|
|
3
9
|
{
|
|
4
10
|
"id": "bath",
|
|
5
11
|
"name": "cities",
|
|
@@ -31,7 +37,7 @@
|
|
|
31
37
|
"label": "Penzance"
|
|
32
38
|
}
|
|
33
39
|
],
|
|
34
|
-
"total":
|
|
40
|
+
"total": 6,
|
|
35
41
|
"skip": 0,
|
|
36
42
|
"limit": 10
|
|
37
43
|
}
|
package/types/types.forms.ts
CHANGED
|
@@ -27,6 +27,10 @@ export interface IFieldsInitialState {
|
|
|
27
27
|
[key: string]: null | string | boolean | number | URL | object | IOptionsValueArr[];
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
export type TFieldsInitialState = {
|
|
31
|
+
[key: string]: null | string | boolean | number | URL | object | IOptionsValueArr[];
|
|
32
|
+
};
|
|
33
|
+
|
|
30
34
|
export interface IValidityState {
|
|
31
35
|
badInput: boolean;
|
|
32
36
|
customError: boolean;
|
|
@@ -92,6 +96,16 @@ export interface IFormFieldsC12 {
|
|
|
92
96
|
[x: string]: IFormFieldC12;
|
|
93
97
|
}
|
|
94
98
|
|
|
99
|
+
export interface IFormFieldState {
|
|
100
|
+
isValid: boolean;
|
|
101
|
+
isDirty: boolean;
|
|
102
|
+
previousValue: null | string | boolean | number | URL | object;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export interface IFormFieldStateObj {
|
|
106
|
+
[x: string]: IFormFieldState;
|
|
107
|
+
}
|
|
108
|
+
|
|
95
109
|
export interface IFormData {
|
|
96
110
|
[x: string]: string | boolean | number | URL | object;
|
|
97
111
|
data: IFieldsInitialState;
|
|
@@ -112,3 +126,91 @@ export interface IFormData {
|
|
|
112
126
|
export interface IApiErrorMessages {
|
|
113
127
|
[x: string]: string;
|
|
114
128
|
}
|
|
129
|
+
|
|
130
|
+
// New types
|
|
131
|
+
|
|
132
|
+
export interface C12nInputText {
|
|
133
|
+
type: string;
|
|
134
|
+
id: string;
|
|
135
|
+
name: string;
|
|
136
|
+
label: string;
|
|
137
|
+
placeholder: string;
|
|
138
|
+
errorMessage: string;
|
|
139
|
+
fieldHasError: boolean;
|
|
140
|
+
required: boolean;
|
|
141
|
+
styleClassPassthrough: string[];
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export interface C12nMultipleCheckboxes {
|
|
145
|
+
id: string;
|
|
146
|
+
name: string;
|
|
147
|
+
label: string;
|
|
148
|
+
legend: string;
|
|
149
|
+
placeholder: string;
|
|
150
|
+
errorMessage: string;
|
|
151
|
+
fieldHasError: boolean;
|
|
152
|
+
required: boolean;
|
|
153
|
+
styleClassPassthrough: string[];
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export interface C12nInputCheckboxWithLabel {
|
|
157
|
+
id: string;
|
|
158
|
+
name: string;
|
|
159
|
+
required: string;
|
|
160
|
+
label: string;
|
|
161
|
+
placeholder: string;
|
|
162
|
+
errorMessage: string | string[];
|
|
163
|
+
fieldHasError: boolean;
|
|
164
|
+
styleClassPassthrough: string[];
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export interface C12nInputRange {
|
|
168
|
+
id: string;
|
|
169
|
+
name: string;
|
|
170
|
+
label: string;
|
|
171
|
+
min: number;
|
|
172
|
+
max: number;
|
|
173
|
+
step: number;
|
|
174
|
+
placeholder: string;
|
|
175
|
+
errorMessage: string;
|
|
176
|
+
fieldHasError: boolean;
|
|
177
|
+
required: boolean;
|
|
178
|
+
styleClassPassthrough: string[];
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
export interface C12nInputTextCore {
|
|
182
|
+
type: string;
|
|
183
|
+
id: string;
|
|
184
|
+
name: string;
|
|
185
|
+
label: string;
|
|
186
|
+
placeholder: string;
|
|
187
|
+
errorMessage: string;
|
|
188
|
+
fieldHasError: boolean;
|
|
189
|
+
required: boolean;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export interface InputTextWithLabel {
|
|
193
|
+
type: string;
|
|
194
|
+
id: string;
|
|
195
|
+
name: string;
|
|
196
|
+
label: string;
|
|
197
|
+
placeholder: string;
|
|
198
|
+
errorMessage: string;
|
|
199
|
+
fieldHasError: boolean;
|
|
200
|
+
required: boolean;
|
|
201
|
+
styleClassPassthrough: string[];
|
|
202
|
+
deepCssClassPassthrough: string[];
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
export interface ApiErrorResponse {
|
|
206
|
+
url: string;
|
|
207
|
+
statusCode: number;
|
|
208
|
+
statusMessage: string;
|
|
209
|
+
message: string;
|
|
210
|
+
stack: string;
|
|
211
|
+
data: {
|
|
212
|
+
errors: {
|
|
213
|
+
[key: string]: string | string[]; // Index signature for dynamic keys
|
|
214
|
+
};
|
|
215
|
+
};
|
|
216
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { IFieldsInitialState, IFormFieldsState, IFormFieldsC12, IFormFieldC12, IApiErrorMessages, ICustomErrorMessage, IErrorMessagesArr } from '@/types/types.forms';
|
|
2
|
+
|
|
3
|
+
export interface IZodeFormControl {
|
|
4
|
+
[x: string]: string | boolean | number | URL | object;
|
|
5
|
+
data: IFieldsInitialState;
|
|
6
|
+
validityState: IFormFieldsState;
|
|
7
|
+
dirtyFields: IFormFieldsState;
|
|
8
|
+
focusedField: string;
|
|
9
|
+
isDisabled: boolean;
|
|
10
|
+
isPending: boolean;
|
|
11
|
+
errorCount: number;
|
|
12
|
+
errorMessages: IErrorMessagesArr;
|
|
13
|
+
formFieldsC12: IFormFieldsC12;
|
|
14
|
+
formIsValid: boolean;
|
|
15
|
+
submitAttempted: boolean;
|
|
16
|
+
submitDisabled: boolean;
|
|
17
|
+
submitSuccess: boolean;
|
|
18
|
+
displayErrorMessages: boolean;
|
|
19
|
+
displayLoader: boolean;
|
|
20
|
+
submitSuccessful: boolean;
|
|
21
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
@import './_a11y.css';
|
|
@@ -1,226 +0,0 @@
|
|
|
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>
|
|
@@ -1,118 +0,0 @@
|
|
|
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>
|