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
|
@@ -1,313 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="input-text-material" :class="[`theme-${theme}`, { error: fieldHasError }, { compact: compact }]">
|
|
3
|
-
<label class="input-text-label" :for="id" :class="[{ active: isFocused }, { error: fieldHasError }, { dirty: fieldIsDirty }, { compact: compact }]">
|
|
4
|
-
<span>{{ c12.label }}</span>
|
|
5
|
-
</label>
|
|
6
|
-
<div class="input-text-container" :class="[{ active: isFocused }, { error: fieldHasError }, { dirty: fieldIsDirty }, { compact: compact }]">
|
|
7
|
-
<slot name="input"></slot>
|
|
8
|
-
</div>
|
|
9
|
-
<InputError :errorMessaging :fieldHasError :id :isDetached="false" />
|
|
10
|
-
</div>
|
|
11
|
-
</template>
|
|
12
|
-
|
|
13
|
-
<script setup lang="ts">
|
|
14
|
-
import type { InpuTextC12, IFormData } from '@/types/types.forms';
|
|
15
|
-
|
|
16
|
-
import propValidators from '../../../c12/prop-validators';
|
|
17
|
-
|
|
18
|
-
const props = defineProps({
|
|
19
|
-
size: {
|
|
20
|
-
type: String as PropType<string>,
|
|
21
|
-
default: 'normal',
|
|
22
|
-
validator(value: string) {
|
|
23
|
-
return propValidators.size.includes(value);
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
weight: {
|
|
27
|
-
type: String as PropType<string>,
|
|
28
|
-
default: 'wght-400',
|
|
29
|
-
validator(value: string) {
|
|
30
|
-
return propValidators.weight.includes(value);
|
|
31
|
-
},
|
|
32
|
-
},
|
|
33
|
-
theme: {
|
|
34
|
-
type: String as PropType<string>,
|
|
35
|
-
default: 'primary',
|
|
36
|
-
validator(value: string) {
|
|
37
|
-
return propValidators.theme.includes(value);
|
|
38
|
-
},
|
|
39
|
-
},
|
|
40
|
-
type: {
|
|
41
|
-
type: String,
|
|
42
|
-
required: true,
|
|
43
|
-
validator(value: string) {
|
|
44
|
-
return propValidators.inputTypesText.includes(value);
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
id: {
|
|
48
|
-
type: String,
|
|
49
|
-
required: true,
|
|
50
|
-
},
|
|
51
|
-
name: {
|
|
52
|
-
type: String,
|
|
53
|
-
default: null,
|
|
54
|
-
},
|
|
55
|
-
required: {
|
|
56
|
-
type: Boolean,
|
|
57
|
-
value: false,
|
|
58
|
-
},
|
|
59
|
-
c12: {
|
|
60
|
-
type: Object as PropType<InpuTextC12>,
|
|
61
|
-
required: true,
|
|
62
|
-
},
|
|
63
|
-
styleClassPassthrough: {
|
|
64
|
-
type: String,
|
|
65
|
-
default: '',
|
|
66
|
-
},
|
|
67
|
-
compact: {
|
|
68
|
-
type: Boolean,
|
|
69
|
-
value: false,
|
|
70
|
-
},
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
const errorMessaging = computed(() => {
|
|
74
|
-
if (
|
|
75
|
-
typeof modelValue.value!.formFieldsC12[props.name] !== 'undefined' &&
|
|
76
|
-
modelValue.value!.formFieldsC12[props.name].useCustomError &&
|
|
77
|
-
modelValue.value.data[props.name] === modelValue.value.formFieldsC12[props.name].previousValue
|
|
78
|
-
) {
|
|
79
|
-
return modelValue.value.formFieldsC12[props.name]?.customErrors || [];
|
|
80
|
-
} else {
|
|
81
|
-
return props.c12.errorMessage;
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
const modelValue = defineModel() as Ref<IFormData>;
|
|
86
|
-
|
|
87
|
-
const isFocused = computed(() => {
|
|
88
|
-
return modelValue.value.focusedField == props.name;
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
const fieldIsDirty = computed(() => {
|
|
92
|
-
if (typeof modelValue.value!.formFieldsC12[props.name] !== 'undefined') {
|
|
93
|
-
return modelValue.value!.formFieldsC12[props.name].isDirty;
|
|
94
|
-
} else {
|
|
95
|
-
return false;
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
const fieldHasError = computed(() => {
|
|
100
|
-
if (typeof modelValue.value!.formFieldsC12[props.name] !== 'undefined') {
|
|
101
|
-
return modelValue.value!.submitAttempted && !modelValue.value!.formFieldsC12[props.name].isValid;
|
|
102
|
-
}
|
|
103
|
-
return false;
|
|
104
|
-
});
|
|
105
|
-
</script>
|
|
106
|
-
|
|
107
|
-
<style lang="css">
|
|
108
|
-
.input-text-material {
|
|
109
|
-
--_form-theme: var(--theme-form-primary);
|
|
110
|
-
--_focus-colour: var(--theme-form-primary-focus);
|
|
111
|
-
--_gutter: 12px;
|
|
112
|
-
--_border-width: var(--input-border-width-thin);
|
|
113
|
-
--_border-color: var(--_form-theme);
|
|
114
|
-
--_outline-width: var(--input-outline-width-thin);
|
|
115
|
-
|
|
116
|
-
&.theme-secondary {
|
|
117
|
-
--_form-theme: var(--theme-form-secondary);
|
|
118
|
-
--_focus-colour: var(--theme-form-secondary-focus);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
&.error {
|
|
122
|
-
--_form-theme: var(--theme-error);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
/*
|
|
126
|
-
&:has(.input-text:invalid),
|
|
127
|
-
&:has(.input-textarea:invalid) {
|
|
128
|
-
--_form-theme: green;
|
|
129
|
-
}
|
|
130
|
-
*/
|
|
131
|
-
|
|
132
|
-
/*
|
|
133
|
-
&:not(:placeholder-shown):invalid {
|
|
134
|
-
--_form-theme: green;
|
|
135
|
-
}
|
|
136
|
-
&:has(.text-input:not(:placeholder-shown):invalid) {
|
|
137
|
-
--_form-theme: red;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
*/
|
|
141
|
-
|
|
142
|
-
.input-text-core {
|
|
143
|
-
background-color: transparent;
|
|
144
|
-
line-height: var(--line-height);
|
|
145
|
-
|
|
146
|
-
&:focus {
|
|
147
|
-
outline: none;
|
|
148
|
-
box-shadow: none;
|
|
149
|
-
border: none;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
&:-internal-autofill-selected,
|
|
153
|
-
&:autofill {
|
|
154
|
-
background-color: transparent !important;
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
.input-text-label {
|
|
159
|
-
color: var(--_form-theme);
|
|
160
|
-
margin: initial;
|
|
161
|
-
line-height: var(--line-height);
|
|
162
|
-
padding: initial;
|
|
163
|
-
transition: color 0.2s ease-in-out;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
display: grid;
|
|
167
|
-
border-radius: 2px;
|
|
168
|
-
border: var(--_border-width) solid var(--_border-color);
|
|
169
|
-
|
|
170
|
-
margin-bottom: 20px;
|
|
171
|
-
overflow: hidden;
|
|
172
|
-
|
|
173
|
-
&:focus-within {
|
|
174
|
-
--_border-color: white;
|
|
175
|
-
outline: var(--_outline-width) solid hsl(from var(--_form-theme) h s 50%);
|
|
176
|
-
background-color: hsl(from var(--_form-theme) h s 95%);
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
&:has(.input-text-core:focus-visible),
|
|
180
|
-
&:has(.input-button-core:focus-visible) {
|
|
181
|
-
/* box-shadow: 0 0 2px 3px var(--_focus-colour);
|
|
182
|
-
outline-color: var(--_focus-colour); */
|
|
183
|
-
|
|
184
|
-
outline: var(--focus-visible-outline);
|
|
185
|
-
box-shadow: var(--focus-visible-box-shadow);
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
&.error {
|
|
189
|
-
/* outline: calc(var(--_border-width) * 2) solid var(--theme-error); */
|
|
190
|
-
|
|
191
|
-
border: var(--_border-width) solid var(--theme-error);
|
|
192
|
-
outline: var(--_outline-width) solid hsl(from var(--theme-error) h s 75%);
|
|
193
|
-
|
|
194
|
-
background-color: hsl(from var(--theme-error) h s 95%);
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
.input-text-label {
|
|
198
|
-
grid-row: 1;
|
|
199
|
-
grid-column: 1;
|
|
200
|
-
|
|
201
|
-
font-family: var(--font-family);
|
|
202
|
-
font-size: 20px;
|
|
203
|
-
font-weight: 700;
|
|
204
|
-
padding: var(--_gutter);
|
|
205
|
-
transform: translateY(12px);
|
|
206
|
-
transition: all linear 0.2s;
|
|
207
|
-
background-color: transparent;
|
|
208
|
-
z-index: 2;
|
|
209
|
-
|
|
210
|
-
&.active,
|
|
211
|
-
&.dirty,
|
|
212
|
-
&.error {
|
|
213
|
-
font-size: 16px;
|
|
214
|
-
height: 1.5em;
|
|
215
|
-
transform: translateY(-2px);
|
|
216
|
-
z-index: auto;
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
.input-text-container {
|
|
221
|
-
display: grid;
|
|
222
|
-
grid-row: 1;
|
|
223
|
-
grid-column: 1;
|
|
224
|
-
margin-top: 2rem;
|
|
225
|
-
background-color: transparent;
|
|
226
|
-
opacity: 0;
|
|
227
|
-
transition: opacity linear 0.2s;
|
|
228
|
-
|
|
229
|
-
&.active,
|
|
230
|
-
&.dirty,
|
|
231
|
-
&.error {
|
|
232
|
-
opacity: 1;
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
.input-text-core {
|
|
236
|
-
font-family: var(--font-family);
|
|
237
|
-
border: 0px solid green;
|
|
238
|
-
padding: calc(var(--_gutter) / 2) var(--_gutter);
|
|
239
|
-
font-size: var(--font-size);
|
|
240
|
-
margin: 0;
|
|
241
|
-
/* opacity: 0;
|
|
242
|
-
transition: opacity linear 0.2s;
|
|
243
|
-
|
|
244
|
-
&.active,
|
|
245
|
-
&.dirty {
|
|
246
|
-
opacity: 1;
|
|
247
|
-
} */
|
|
248
|
-
/*
|
|
249
|
-
&::placeholder,
|
|
250
|
-
&:-ms-input-placeholder,
|
|
251
|
-
&::-moz-placeholder, */
|
|
252
|
-
&::-webkit-input-placeholder {
|
|
253
|
-
font-family: var(--font-family);
|
|
254
|
-
/* color: var(--gray-5); */
|
|
255
|
-
color: hsl(from var(--_form-theme) h s 50%);
|
|
256
|
-
font-size: var(--font-size);
|
|
257
|
-
font-style: italic;
|
|
258
|
-
font-weight: 500;
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
/*
|
|
265
|
-
* Compact UI
|
|
266
|
-
**/
|
|
267
|
-
|
|
268
|
-
.input-text-material {
|
|
269
|
-
&.compact {
|
|
270
|
-
overflow: initial;
|
|
271
|
-
|
|
272
|
-
&:focus-within {
|
|
273
|
-
background-color: initial;
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
&.error {
|
|
277
|
-
background-color: initial;
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
.input-text-label {
|
|
282
|
-
&.compact {
|
|
283
|
-
align-content: center;
|
|
284
|
-
font-size: 16px;
|
|
285
|
-
padding: 0 12px;
|
|
286
|
-
transform: translateY(0);
|
|
287
|
-
|
|
288
|
-
span {
|
|
289
|
-
padding: 0 8px;
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
&.active,
|
|
293
|
-
&.dirty,
|
|
294
|
-
&.error {
|
|
295
|
-
font-size: 16px;
|
|
296
|
-
font-weight: 500;
|
|
297
|
-
transform: translateY(-14px);
|
|
298
|
-
z-index: auto;
|
|
299
|
-
|
|
300
|
-
span {
|
|
301
|
-
background-color: white;
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
.input-text-container {
|
|
308
|
-
&.compact {
|
|
309
|
-
margin: 10px 8px 6px 8px;
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
</style>
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<InputTextareaMaterialCore :type :id :name :required :c12 :styleClassPassthrough :theme v-model="modelValue">
|
|
3
|
-
<template #input>
|
|
4
|
-
<InputTextareaCore :id :name :validation :required v-model="modelValue" :c12 :style-class-passthrough="styleClassPassthrough" />
|
|
5
|
-
</template>
|
|
6
|
-
</InputTextareaMaterialCore>
|
|
7
|
-
</template>
|
|
8
|
-
|
|
9
|
-
<script setup lang="ts">
|
|
10
|
-
import type { InpuTextC12, IFormData } from '@/types/types.forms';
|
|
11
|
-
|
|
12
|
-
import propValidators from '../../../c12/prop-validators';
|
|
13
|
-
|
|
14
|
-
const props = defineProps({
|
|
15
|
-
size: {
|
|
16
|
-
type: String as PropType<string>,
|
|
17
|
-
default: 'normal',
|
|
18
|
-
validator(value: string) {
|
|
19
|
-
return propValidators.size.includes(value);
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
weight: {
|
|
23
|
-
type: String as PropType<string>,
|
|
24
|
-
default: 'wght-400',
|
|
25
|
-
validator(value: string) {
|
|
26
|
-
return propValidators.weight.includes(value);
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
theme: {
|
|
30
|
-
type: String as PropType<string>,
|
|
31
|
-
default: 'primary',
|
|
32
|
-
validator(value: string) {
|
|
33
|
-
return propValidators.theme.includes(value);
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
type: {
|
|
37
|
-
// type: String as PropType<"text" | "password" | "tel" | "number" | "email" | "url">, // This breaks props setup in unit tests
|
|
38
|
-
type: String,
|
|
39
|
-
validator(value: string) {
|
|
40
|
-
return ['text', 'password', 'tel', 'number', 'email', 'url'].includes(value);
|
|
41
|
-
},
|
|
42
|
-
},
|
|
43
|
-
id: {
|
|
44
|
-
// type: String as PropType<string>,
|
|
45
|
-
type: String,
|
|
46
|
-
required: true,
|
|
47
|
-
},
|
|
48
|
-
name: {
|
|
49
|
-
type: String,
|
|
50
|
-
default: null,
|
|
51
|
-
},
|
|
52
|
-
validation: {
|
|
53
|
-
type: String,
|
|
54
|
-
default: '',
|
|
55
|
-
},
|
|
56
|
-
required: {
|
|
57
|
-
type: Boolean,
|
|
58
|
-
value: false,
|
|
59
|
-
},
|
|
60
|
-
c12: {
|
|
61
|
-
type: Object as PropType<InpuTextC12>,
|
|
62
|
-
required: true,
|
|
63
|
-
},
|
|
64
|
-
styleClassPassthrough: {
|
|
65
|
-
type: String,
|
|
66
|
-
default: '',
|
|
67
|
-
},
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
const name = computed(() => {
|
|
71
|
-
return props.name !== null ? props.name : props.id;
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
const modelValue = defineModel() as Ref<IFormData>;
|
|
75
|
-
</script>
|
|
@@ -1,290 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="input-textarea-material" :class="[`theme-${theme}`, { error: fieldHasError }, { compact: compact }]">
|
|
3
|
-
<label class="input-textarea-label" :for="id" :class="[{ active: isFocused }, { error: fieldHasError }, { dirty: fieldIsDirty }, { compact: compact }]">
|
|
4
|
-
<span>{{ c12.label }}</span>
|
|
5
|
-
</label>
|
|
6
|
-
<div class="input-textarea-container" :class="[{ active: isFocused }, { error: fieldHasError }, { dirty: fieldIsDirty }, { compact: compact }]">
|
|
7
|
-
<slot name="input"></slot>
|
|
8
|
-
</div>
|
|
9
|
-
<InputError :errorMessaging :fieldHasError :id :isDetached="false" />
|
|
10
|
-
</div>
|
|
11
|
-
</template>
|
|
12
|
-
|
|
13
|
-
<script setup lang="ts">
|
|
14
|
-
import type { InpuTextC12, IFormData } from '@/types/types.forms';
|
|
15
|
-
|
|
16
|
-
import propValidators from '../../../c12/prop-validators';
|
|
17
|
-
|
|
18
|
-
const props = defineProps({
|
|
19
|
-
size: {
|
|
20
|
-
type: String as PropType<string>,
|
|
21
|
-
default: 'normal',
|
|
22
|
-
validator(value: string) {
|
|
23
|
-
return propValidators.size.includes(value);
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
weight: {
|
|
27
|
-
type: String as PropType<string>,
|
|
28
|
-
default: 'wght-400',
|
|
29
|
-
validator(value: string) {
|
|
30
|
-
return propValidators.weight.includes(value);
|
|
31
|
-
},
|
|
32
|
-
},
|
|
33
|
-
theme: {
|
|
34
|
-
type: String as PropType<string>,
|
|
35
|
-
default: 'primary',
|
|
36
|
-
validator(value: string) {
|
|
37
|
-
return propValidators.theme.includes(value);
|
|
38
|
-
},
|
|
39
|
-
},
|
|
40
|
-
id: {
|
|
41
|
-
type: String,
|
|
42
|
-
required: true,
|
|
43
|
-
},
|
|
44
|
-
name: {
|
|
45
|
-
type: String,
|
|
46
|
-
default: null,
|
|
47
|
-
},
|
|
48
|
-
required: {
|
|
49
|
-
type: Boolean,
|
|
50
|
-
value: false,
|
|
51
|
-
},
|
|
52
|
-
c12: {
|
|
53
|
-
type: Object as PropType<InpuTextC12>,
|
|
54
|
-
required: true,
|
|
55
|
-
},
|
|
56
|
-
styleClassPassthrough: {
|
|
57
|
-
type: String,
|
|
58
|
-
default: '',
|
|
59
|
-
},
|
|
60
|
-
compact: {
|
|
61
|
-
type: Boolean,
|
|
62
|
-
value: false,
|
|
63
|
-
},
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
const errorMessaging = computed(() => {
|
|
67
|
-
if (
|
|
68
|
-
typeof modelValue.value!.formFieldsC12[props.name] !== 'undefined' &&
|
|
69
|
-
modelValue.value!.formFieldsC12[props.name].useCustomError &&
|
|
70
|
-
modelValue.value.data[props.name] === modelValue.value.formFieldsC12[props.name].previousValue
|
|
71
|
-
) {
|
|
72
|
-
return modelValue.value.formFieldsC12[props.name]?.customErrors || [];
|
|
73
|
-
} else {
|
|
74
|
-
return props.c12.errorMessage;
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
const modelValue = defineModel() as Ref<IFormData>;
|
|
79
|
-
|
|
80
|
-
const isFocused = computed(() => {
|
|
81
|
-
return modelValue.value.focusedField == props.name;
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
const fieldIsDirty = computed(() => {
|
|
85
|
-
if (typeof modelValue.value!.formFieldsC12[props.name] !== 'undefined') {
|
|
86
|
-
return modelValue.value!.formFieldsC12[props.name].isDirty;
|
|
87
|
-
} else {
|
|
88
|
-
return false;
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
const fieldHasError = computed(() => {
|
|
93
|
-
if (typeof modelValue.value!.formFieldsC12[props.name] !== 'undefined') {
|
|
94
|
-
return modelValue.value!.submitAttempted && !modelValue.value!.formFieldsC12[props.name].isValid;
|
|
95
|
-
}
|
|
96
|
-
return false;
|
|
97
|
-
});
|
|
98
|
-
</script>
|
|
99
|
-
|
|
100
|
-
<style lang="css">
|
|
101
|
-
.input-textarea-material {
|
|
102
|
-
--_form-theme: var(--theme-form-primary);
|
|
103
|
-
--_focus-colour: var(--theme-form-primary-focus);
|
|
104
|
-
--_gutter: 12px;
|
|
105
|
-
--_border-width: var(--input-border-width-thin);
|
|
106
|
-
--_border-color: var(--_form-theme);
|
|
107
|
-
--_outline-width: var(--input-outline-width-thin);
|
|
108
|
-
|
|
109
|
-
&.theme-secondary {
|
|
110
|
-
--_form-theme: var(--theme-form-secondary);
|
|
111
|
-
--_focus-colour: var(--theme-form-secondary-focus);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
&.error {
|
|
115
|
-
--_form-theme: var(--theme-error);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
.input-textarea-core {
|
|
119
|
-
color: var(--_form-theme);
|
|
120
|
-
background-color: transparent;
|
|
121
|
-
line-height: var(--line-height);
|
|
122
|
-
field-sizing: content;
|
|
123
|
-
min-height: 3rem;
|
|
124
|
-
|
|
125
|
-
&:focus {
|
|
126
|
-
outline: none;
|
|
127
|
-
box-shadow: none;
|
|
128
|
-
border: none;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
&:-internal-autofill-selected,
|
|
132
|
-
&:autofill {
|
|
133
|
-
background-color: transparent !important;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
.input-textarea-label {
|
|
138
|
-
color: var(--_form-theme);
|
|
139
|
-
margin: initial;
|
|
140
|
-
line-height: var(--line-height);
|
|
141
|
-
padding: initial;
|
|
142
|
-
transition: color 0.2s ease-in-out;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
display: grid;
|
|
146
|
-
border-radius: 2px;
|
|
147
|
-
border: var(--_border-width) solid var(--_border-color);
|
|
148
|
-
|
|
149
|
-
margin-bottom: 20px;
|
|
150
|
-
overflow: hidden;
|
|
151
|
-
|
|
152
|
-
&:focus-within {
|
|
153
|
-
--_border-color: white;
|
|
154
|
-
outline: var(--_outline-width) solid hsl(from var(--_form-theme) h s 50%);
|
|
155
|
-
background-color: hsl(from var(--_form-theme) h s 95%);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
&:has(.input-textarea-core:focus-visible) {
|
|
159
|
-
box-shadow: 0 0 2px 3px var(--_focus-colour);
|
|
160
|
-
outline-color: var(--_focus-colour);
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
&.error {
|
|
164
|
-
/* outline: calc(var(--_border-width) * 2) solid var(--theme-error); */
|
|
165
|
-
|
|
166
|
-
border: var(--_border-width) solid var(--theme-error);
|
|
167
|
-
outline: var(--_outline-width) solid hsl(from var(--theme-error) h s 75%);
|
|
168
|
-
|
|
169
|
-
background-color: hsl(from var(--theme-error) h s 95%);
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
.input-textarea-label {
|
|
173
|
-
grid-row: 1;
|
|
174
|
-
grid-column: 1;
|
|
175
|
-
|
|
176
|
-
font-family: var(--font-family);
|
|
177
|
-
font-size: 20px;
|
|
178
|
-
font-weight: 700;
|
|
179
|
-
padding: var(--_gutter);
|
|
180
|
-
transform: translateY(12px);
|
|
181
|
-
transition: all linear 0.2s;
|
|
182
|
-
background-color: transparent;
|
|
183
|
-
z-index: 2;
|
|
184
|
-
height: 3.5rem;
|
|
185
|
-
transition: color 0.2s ease-in-out;
|
|
186
|
-
|
|
187
|
-
&.active,
|
|
188
|
-
&.dirty,
|
|
189
|
-
&.error {
|
|
190
|
-
font-size: 16px;
|
|
191
|
-
height: 1.5em;
|
|
192
|
-
transform: translateY(-2px);
|
|
193
|
-
z-index: auto;
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
.input-textarea-container {
|
|
198
|
-
display: grid;
|
|
199
|
-
grid-row: 1;
|
|
200
|
-
grid-column: 1;
|
|
201
|
-
margin-top: 2rem;
|
|
202
|
-
background-color: transparent;
|
|
203
|
-
opacity: 0;
|
|
204
|
-
transition: opacity linear 0.2s;
|
|
205
|
-
|
|
206
|
-
&.active,
|
|
207
|
-
&.dirty,
|
|
208
|
-
&.error {
|
|
209
|
-
opacity: 1;
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
.input-textarea-core {
|
|
213
|
-
font-family: var(--font-family);
|
|
214
|
-
border: 0px solid green;
|
|
215
|
-
padding: calc(var(--_gutter) / 2) var(--_gutter);
|
|
216
|
-
font-size: var(--font-size);
|
|
217
|
-
margin: 0;
|
|
218
|
-
/* opacity: 0;
|
|
219
|
-
transition: opacity linear 0.2s;
|
|
220
|
-
|
|
221
|
-
&.active,
|
|
222
|
-
&.dirty {
|
|
223
|
-
opacity: 1;
|
|
224
|
-
} */
|
|
225
|
-
/*
|
|
226
|
-
&::placeholder,
|
|
227
|
-
&:-ms-input-placeholder,
|
|
228
|
-
&::-moz-placeholder, */
|
|
229
|
-
&::-webkit-input-placeholder {
|
|
230
|
-
font-family: var(--font-family);
|
|
231
|
-
/* color: var(--gray-5); */
|
|
232
|
-
color: hsl(from var(--_form-theme) h s 50%);
|
|
233
|
-
font-size: var(--font-size);
|
|
234
|
-
font-style: italic;
|
|
235
|
-
font-weight: 500;
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
/*
|
|
242
|
-
* Compact UI
|
|
243
|
-
**/
|
|
244
|
-
|
|
245
|
-
.input-textarea-material {
|
|
246
|
-
&.compact {
|
|
247
|
-
overflow: initial;
|
|
248
|
-
|
|
249
|
-
&:focus-within {
|
|
250
|
-
background-color: initial;
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
&.error {
|
|
254
|
-
background-color: initial;
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
.input-textarea-label {
|
|
259
|
-
&.compact {
|
|
260
|
-
align-content: center;
|
|
261
|
-
font-size: 16px;
|
|
262
|
-
padding: 0 12px;
|
|
263
|
-
transform: translateY(0);
|
|
264
|
-
|
|
265
|
-
span {
|
|
266
|
-
padding: 0 8px;
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
&.active,
|
|
270
|
-
&.dirty,
|
|
271
|
-
&.error {
|
|
272
|
-
font-size: 16px;
|
|
273
|
-
font-weight: 500;
|
|
274
|
-
transform: translateY(-14px);
|
|
275
|
-
z-index: auto;
|
|
276
|
-
|
|
277
|
-
span {
|
|
278
|
-
background-color: white;
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
.input-textarea-container {
|
|
285
|
-
&.compact {
|
|
286
|
-
margin: 10px 8px 6px 8px;
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
</style>
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
export const useUpdateStyleClassPassthrough = (classes: string) => {
|
|
2
|
-
const styleClassPassthroughRef = ref(classes);
|
|
3
|
-
|
|
4
|
-
function updateClasses(add: boolean, cssClass: string) {
|
|
5
|
-
let classesArray = classes.split(' ');
|
|
6
|
-
|
|
7
|
-
if (add && !classesArray.includes(cssClass)) {
|
|
8
|
-
classesArray.push(cssClass);
|
|
9
|
-
} else if (!add && classesArray.includes(cssClass)) {
|
|
10
|
-
classesArray = classesArray.filter((className) => className !== cssClass);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
// if (classesArray.includes(cssClass)) {
|
|
14
|
-
// // Remove the value if it's already in the array
|
|
15
|
-
// classesArray = classesArray.filter(className => className !== cssClass);
|
|
16
|
-
// } else {
|
|
17
|
-
// // Add the value if it's not in the array
|
|
18
|
-
// classesArray.push(cssClass);
|
|
19
|
-
// }
|
|
20
|
-
|
|
21
|
-
// Join the array back into a string and assign it back
|
|
22
|
-
styleClassPassthroughRef.value = classesArray.join(' ');
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
return {
|
|
26
|
-
styleClassPassthroughRef,
|
|
27
|
-
updateClasses,
|
|
28
|
-
};
|
|
29
|
-
};
|