srcdev-nuxt-forms 0.0.23 → 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.
- package/.prettierrc +2 -1
- package/LICENSE +21 -0
- package/assets/styles/forms/index.css +1 -0
- package/assets/styles/forms/themes/_error.css +9 -0
- package/assets/styles/forms/themes/_ghost.css +11 -0
- package/assets/styles/forms/themes/_primary.css +11 -1
- package/assets/styles/forms/themes/_secondary.css +13 -0
- package/assets/styles/forms/themes/_success.css +12 -0
- package/assets/styles/forms/themes/_tertiary.css +11 -0
- package/assets/styles/forms/themes/_warning.css +11 -0
- package/assets/styles/forms/themes/index.css +5 -0
- package/assets/styles/forms/utils/_a11y.css +5 -0
- package/assets/styles/forms/utils/index.css +1 -0
- package/assets/styles/forms/variables/_theme.css +56 -2
- package/assets/styles/variables/colors/_gray.css +1 -0
- package/assets/styles/variables/colors/_orange.css +1 -1
- package/assets/styles/variables/colors/_red.css +1 -1
- package/components/forms/c12/prop-validators/index.ts +13 -0
- package/components/forms/c12/utils.ts +14 -0
- package/components/forms/c12/validation-patterns/en.json +13 -1
- package/components/forms/form-errors/InputError.vue +132 -0
- package/components/forms/input-button/InputButtonCore.vue +370 -0
- package/components/forms/input-button/variants/InputButtonConfirm.vue +78 -0
- package/components/forms/input-button/variants/InputButtonSubmit.vue +74 -0
- package/components/forms/input-checkbox/InputCheckboxCore.vue +407 -0
- package/components/forms/input-checkbox/InputCheckboxWithLabel.vue +125 -0
- package/components/forms/input-checkbox/variants/MultipleCheckboxes.vue +194 -0
- package/components/forms/input-checkbox/variants/SingleCheckbox.vue +157 -0
- package/components/forms/input-radio/InputRadioCore.vue +226 -0
- package/components/forms/input-radio/InputRadioWithLabel.vue +118 -0
- package/components/forms/input-radio/variants/MultipleRadio.vue +183 -0
- package/components/forms/input-radio/variants/SingleRadio.vue +131 -0
- package/components/forms/input-range/InputRangeCore.vue +171 -0
- package/components/forms/input-range/variants/InputRangeDefault.vue +131 -0
- package/components/forms/input-text/InputTextCore.vue +115 -79
- package/components/forms/input-text/variants/material/InputEmailMaterial.vue +72 -0
- package/components/forms/input-text/variants/material/InputPasswordMaterial.vue +114 -0
- package/components/forms/input-text/variants/material/InputTextMaterial.vue +68 -0
- package/components/forms/input-text/variants/material/InputTextMaterialCore.vue +313 -0
- package/components/forms/input-textarea/InputTextareaCore.vue +170 -0
- package/components/forms/input-textarea/variants/material/InputTextareaMaterial.vue +75 -0
- package/components/forms/input-textarea/variants/material/InputTextareaMaterialCore.vue +290 -0
- package/components/forms/ui/FormField.vue +7 -2
- package/components/forms/ui/FormWrapper.vue +2 -2
- package/components/ui/content-grid/ContentGrid.vue +85 -0
- package/composables/useErrorMessages.ts +21 -9
- package/composables/useFormControl.ts +171 -41
- package/layouts/default.vue +28 -3
- package/nuxt.config.ts +26 -3
- package/package.json +9 -6
- package/pages/forms/examples/buttons/index.vue +155 -0
- package/pages/forms/examples/material/text-fields.vue +372 -0
- package/pages/index.vue +2 -70
- package/pages/limit-text.vue +43 -0
- package/server/api/places/list.get.ts +23 -0
- package/server/api/textFields.post.ts +37 -0
- package/server/api/utils/index.get.ts +20 -0
- package/server/data/places/cities.json +37 -0
- package/server/data/places/countries.json +55 -0
- package/server/data/utils/title.json +49 -0
- package/types/types.forms.ts +38 -13
- package/types/types.places.ts +8 -0
- package/components/forms/input-text/InputTextField.vue +0 -22
- package/components/forms/input-text/variants/InputTextMaterial.vue +0 -192
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"data": [
|
|
3
|
+
{
|
|
4
|
+
"id": "mr",
|
|
5
|
+
"name": "title",
|
|
6
|
+
"value": "title-12",
|
|
7
|
+
"label": "Mr"
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"id": "Mrs",
|
|
11
|
+
"name": "title",
|
|
12
|
+
"value": "title-23",
|
|
13
|
+
"label": "Mrs"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"id": "ms",
|
|
17
|
+
"name": "title",
|
|
18
|
+
"value": "title-42",
|
|
19
|
+
"label": "Ms"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"id": "madam",
|
|
23
|
+
"name": "title",
|
|
24
|
+
"value": "title-56",
|
|
25
|
+
"label": "Madam"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"id": "prof",
|
|
29
|
+
"name": "title",
|
|
30
|
+
"value": "title-09",
|
|
31
|
+
"label": "Professor"
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"id": "sir",
|
|
35
|
+
"name": "title",
|
|
36
|
+
"value": "title-11",
|
|
37
|
+
"label": "Sir"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"id": "lady",
|
|
41
|
+
"name": "title",
|
|
42
|
+
"value": "title-22",
|
|
43
|
+
"label": "Lady"
|
|
44
|
+
}
|
|
45
|
+
],
|
|
46
|
+
"total": 5,
|
|
47
|
+
"skip": 0,
|
|
48
|
+
"limit": 10
|
|
49
|
+
}
|
package/types/types.forms.ts
CHANGED
|
@@ -12,19 +12,19 @@ export interface IOptionsConfig {
|
|
|
12
12
|
label: string;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
+
export interface IFormMultipleOptions {
|
|
16
|
+
data: IOptionsConfig[];
|
|
17
|
+
total: number;
|
|
18
|
+
skip: number;
|
|
19
|
+
limit: number;
|
|
20
|
+
}
|
|
21
|
+
|
|
15
22
|
export interface IOptionsValueArr {
|
|
16
23
|
[key: string]: string | boolean | number | URL | object;
|
|
17
24
|
}
|
|
18
25
|
|
|
19
26
|
export interface IFieldsInitialState {
|
|
20
|
-
[key: string]:
|
|
21
|
-
| null
|
|
22
|
-
| string
|
|
23
|
-
| boolean
|
|
24
|
-
| number
|
|
25
|
-
| URL
|
|
26
|
-
| object
|
|
27
|
-
| IOptionsValueArr[];
|
|
27
|
+
[key: string]: null | string | boolean | number | URL | object | IOptionsValueArr[];
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
export interface IValidityState {
|
|
@@ -57,7 +57,7 @@ export interface IValidityStateArr {
|
|
|
57
57
|
};
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
export interface
|
|
60
|
+
export interface IFormFieldsState {
|
|
61
61
|
[key: string]: boolean;
|
|
62
62
|
}
|
|
63
63
|
|
|
@@ -72,18 +72,43 @@ export interface InpuTextC12 {
|
|
|
72
72
|
errorMessage: string;
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
export interface
|
|
75
|
+
export interface IErrorMessagesArr {
|
|
76
76
|
[x: string]: ICustomErrorMessage;
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
+
export interface IFormFieldC12 {
|
|
80
|
+
label: string;
|
|
81
|
+
placeholder: string;
|
|
82
|
+
errorMessage: string;
|
|
83
|
+
useCustomError: boolean;
|
|
84
|
+
customErrors: null | string | string[];
|
|
85
|
+
isValid: boolean;
|
|
86
|
+
isDirty: boolean;
|
|
87
|
+
type: string;
|
|
88
|
+
previousValue: null | string | boolean | number | URL | object;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export interface IFormFieldsC12 {
|
|
92
|
+
[x: string]: IFormFieldC12;
|
|
93
|
+
}
|
|
94
|
+
|
|
79
95
|
export interface IFormData {
|
|
80
96
|
[x: string]: string | boolean | number | URL | object;
|
|
81
97
|
data: IFieldsInitialState;
|
|
82
|
-
validityState:
|
|
98
|
+
validityState: IFormFieldsState;
|
|
99
|
+
dirtyFields: IFormFieldsState;
|
|
100
|
+
focusedField: string;
|
|
83
101
|
isPending: boolean;
|
|
84
102
|
errorCount: number;
|
|
85
|
-
|
|
103
|
+
errorMessages: IErrorMessagesArr;
|
|
104
|
+
formFieldsC12: IFormFieldsC12;
|
|
86
105
|
formIsValid: boolean;
|
|
87
|
-
|
|
106
|
+
submitAttempted: boolean;
|
|
107
|
+
submitDisabled: boolean;
|
|
88
108
|
submitSuccess: boolean;
|
|
109
|
+
displayErrorMessages: boolean;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export interface IApiErrorMessages {
|
|
113
|
+
[x: string]: string;
|
|
89
114
|
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div>
|
|
3
|
-
<input type="text" class="input-text" v-model="formValue" />
|
|
4
|
-
</div>
|
|
5
|
-
</template>
|
|
6
|
-
<script setup lang="ts">
|
|
7
|
-
console.log('InputText component loaded')
|
|
8
|
-
|
|
9
|
-
const formValue = ref('')
|
|
10
|
-
|
|
11
|
-
watchEffect(() => {
|
|
12
|
-
console.log('Form value changed to: ', formValue.value)
|
|
13
|
-
})
|
|
14
|
-
</script>
|
|
15
|
-
|
|
16
|
-
<style lang="css">
|
|
17
|
-
.input-text {
|
|
18
|
-
border: var(--input-border-width-thin) solid var(--input-border);
|
|
19
|
-
border-radius: var(--input-border-radius);
|
|
20
|
-
padding: 10px;
|
|
21
|
-
}
|
|
22
|
-
</style>
|
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="input-text-material" :class="[{ error: fieldHasError }]">
|
|
3
|
-
<label
|
|
4
|
-
class="label"
|
|
5
|
-
:class="[{ active: isFocused }, { dirty: isDirty }]"
|
|
6
|
-
:for="id"
|
|
7
|
-
>{{ labelText }}</label
|
|
8
|
-
>
|
|
9
|
-
<div class="input-text-container">
|
|
10
|
-
<InputTextCore
|
|
11
|
-
:id
|
|
12
|
-
:name
|
|
13
|
-
:type
|
|
14
|
-
:validation
|
|
15
|
-
:required
|
|
16
|
-
v-model="modelValue"
|
|
17
|
-
v-model:isFocused="isFocused"
|
|
18
|
-
v-model:isDirty="isDirty"
|
|
19
|
-
:c12
|
|
20
|
-
:style-class-passthrough="styleClassPassthroughRef"
|
|
21
|
-
/>
|
|
22
|
-
</div>
|
|
23
|
-
</div>
|
|
24
|
-
</template>
|
|
25
|
-
|
|
26
|
-
<script setup lang="ts">
|
|
27
|
-
import type { InpuTextC12, IFormData } from '@/types/types.forms';
|
|
28
|
-
import { validationConfig } from '@/components/forms/c12/validation-patterns';
|
|
29
|
-
|
|
30
|
-
const props = defineProps({
|
|
31
|
-
type: {
|
|
32
|
-
// type: String as PropType<"text" | "password" | "tel" | "number" | "email" | "url">, // This breaks props setup in unit tests
|
|
33
|
-
type: String,
|
|
34
|
-
validator(value: string) {
|
|
35
|
-
return ['text', 'password', 'tel', 'number', 'email', 'url'].includes(
|
|
36
|
-
value
|
|
37
|
-
);
|
|
38
|
-
},
|
|
39
|
-
},
|
|
40
|
-
id: {
|
|
41
|
-
// type: String as PropType<string>,
|
|
42
|
-
type: String,
|
|
43
|
-
required: true,
|
|
44
|
-
},
|
|
45
|
-
name: {
|
|
46
|
-
type: String,
|
|
47
|
-
default: null,
|
|
48
|
-
},
|
|
49
|
-
validation: {
|
|
50
|
-
type: String,
|
|
51
|
-
default: '',
|
|
52
|
-
},
|
|
53
|
-
required: {
|
|
54
|
-
type: Boolean,
|
|
55
|
-
value: false,
|
|
56
|
-
},
|
|
57
|
-
isPending: {
|
|
58
|
-
type: Boolean,
|
|
59
|
-
value: false,
|
|
60
|
-
},
|
|
61
|
-
c12: {
|
|
62
|
-
type: Object as PropType<InpuTextC12>,
|
|
63
|
-
required: true,
|
|
64
|
-
},
|
|
65
|
-
styleClassPassthrough: {
|
|
66
|
-
type: String,
|
|
67
|
-
default: '',
|
|
68
|
-
},
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
const name = computed(() => {
|
|
72
|
-
return props.name !== null ? props.name : props.id;
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
const labelText = computed(() => {
|
|
76
|
-
return fieldHasError.value ? errorMessage.value : props.c12.label;
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
const { styleClassPassthroughRef, updateClasses } =
|
|
80
|
-
useUpdateStyleClassPassthrough(props.styleClassPassthrough);
|
|
81
|
-
|
|
82
|
-
const modelValue = defineModel() as Ref<IFormData>;
|
|
83
|
-
const isFocused = ref(false);
|
|
84
|
-
const isDirty = ref(false);
|
|
85
|
-
|
|
86
|
-
const { errorMessage, setDefaultError, fieldHasError } = useErrorMessage(
|
|
87
|
-
name.value,
|
|
88
|
-
modelValue
|
|
89
|
-
);
|
|
90
|
-
setDefaultError(props.c12.errorMessage);
|
|
91
|
-
</script>
|
|
92
|
-
|
|
93
|
-
<style lang="css">
|
|
94
|
-
.input-text-material {
|
|
95
|
-
input {
|
|
96
|
-
background-color: transparent;
|
|
97
|
-
line-height: var(--line-height);
|
|
98
|
-
|
|
99
|
-
&:focus {
|
|
100
|
-
outline: none;
|
|
101
|
-
box-shadow: none;
|
|
102
|
-
border: none;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
label {
|
|
107
|
-
margin: initial;
|
|
108
|
-
line-height: var(--line-height);
|
|
109
|
-
padding: initial;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
--_gutter: 12px;
|
|
113
|
-
--_form-theme: var(--theme-primary);
|
|
114
|
-
--_border-width: var(--input-border-width-default);
|
|
115
|
-
|
|
116
|
-
display: grid;
|
|
117
|
-
border-radius: 2px;
|
|
118
|
-
outline: var(--_border-width) solid var(--_form-theme);
|
|
119
|
-
|
|
120
|
-
margin-bottom: 20px;
|
|
121
|
-
overflow: hidden;
|
|
122
|
-
/* transition: all linear 0.2s; */
|
|
123
|
-
|
|
124
|
-
&:focus-within {
|
|
125
|
-
outline: calc(var(--_border-width) * 2) solid var(--_form-theme);
|
|
126
|
-
background-color: hsl(from var(--_form-theme) h s 95%);
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
&.error {
|
|
130
|
-
outline: calc(var(--_border-width) * 2) solid var(--theme-error);
|
|
131
|
-
background-color: hsl(from var(--theme-error) h s 95%);
|
|
132
|
-
|
|
133
|
-
/* .label {
|
|
134
|
-
color: var(--theme-error);
|
|
135
|
-
} */
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
.label {
|
|
139
|
-
grid-row: 1;
|
|
140
|
-
grid-column: 1;
|
|
141
|
-
|
|
142
|
-
font-family: var(--font-family);
|
|
143
|
-
font-size: 20px;
|
|
144
|
-
font-weight: 700;
|
|
145
|
-
padding: var(--_gutter);
|
|
146
|
-
transform: translateY(12px);
|
|
147
|
-
transition: all linear 0.2s;
|
|
148
|
-
background-color: transparent;
|
|
149
|
-
|
|
150
|
-
&.active,
|
|
151
|
-
&.dirty {
|
|
152
|
-
font-size: 14px;
|
|
153
|
-
transform: translateY(0);
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
.input-text-container {
|
|
158
|
-
display: grid;
|
|
159
|
-
grid-row: 1;
|
|
160
|
-
grid-column: 1;
|
|
161
|
-
margin-top: 2rem;
|
|
162
|
-
background-color: transparent;
|
|
163
|
-
|
|
164
|
-
.input-text {
|
|
165
|
-
font-family: var(--font-family);
|
|
166
|
-
border: 0px solid green;
|
|
167
|
-
padding: calc(var(--_gutter) / 2) var(--_gutter);
|
|
168
|
-
font-size: var(--font-size);
|
|
169
|
-
margin: 0;
|
|
170
|
-
opacity: 0;
|
|
171
|
-
transition: opacity linear 0.2s;
|
|
172
|
-
|
|
173
|
-
&.active,
|
|
174
|
-
&.dirty {
|
|
175
|
-
opacity: 1;
|
|
176
|
-
}
|
|
177
|
-
/*
|
|
178
|
-
&::placeholder,
|
|
179
|
-
&:-ms-input-placeholder,
|
|
180
|
-
&::-moz-placeholder, */
|
|
181
|
-
&::-webkit-input-placeholder {
|
|
182
|
-
font-family: var(--font-family);
|
|
183
|
-
/* color: var(--gray-5); */
|
|
184
|
-
color: hsl(from var(--_form-theme) h s 50%);
|
|
185
|
-
font-size: var(--font-size);
|
|
186
|
-
font-style: italic;
|
|
187
|
-
font-weight: 500;
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
</style>
|