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.
- package/LICENSE +21 -0
- package/assets/styles/forms/index.css +1 -0
- package/assets/styles/forms/themes/_primary.css +2 -0
- package/assets/styles/forms/themes/_secondary.css +2 -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 +11 -17
- package/assets/styles/variables/colors/_gray.css +1 -0
- package/components/forms/c12/prop-validators/index.ts +8 -20
- package/components/forms/c12/utils.ts +14 -0
- package/components/forms/c12/validation-patterns/en.json +12 -0
- package/components/forms/form-errors/InputError.vue +132 -0
- package/components/forms/input-button/InputButtonCore.vue +11 -8
- package/components/forms/input-button/variants/InputButtonConfirm.vue +1 -1
- package/components/forms/input-button/variants/InputButtonSubmit.vue +1 -1
- 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 +61 -31
- package/components/forms/input-text/variants/material/InputPasswordMaterial.vue +27 -1
- package/components/forms/input-text/variants/material/InputTextMaterial.vue +1 -8
- package/components/forms/input-text/variants/material/InputTextMaterialCore.vue +83 -28
- 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/ui/content-grid/ContentGrid.vue +85 -0
- package/composables/useErrorMessages.ts +17 -5
- package/composables/useFormControl.ts +147 -37
- package/layouts/default.vue +7 -13
- package/nuxt.config.ts +22 -0
- package/package.json +9 -8
- package/pages/forms/examples/buttons/index.vue +14 -13
- package/pages/forms/examples/material/text-fields.vue +320 -84
- 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 +33 -3
- package/types/types.places.ts +8 -0
- package/pages/forms/examples/material/text-fields-compact.vue +0 -136
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 srcdev
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@import './_a11y.css';
|
|
@@ -7,8 +7,12 @@
|
|
|
7
7
|
--input-border-width-default: 2px;
|
|
8
8
|
--input-border-width-thick: 3px;
|
|
9
9
|
|
|
10
|
-
--
|
|
11
|
-
|
|
10
|
+
--input-outline-radius: 4px;
|
|
11
|
+
--input-outline-width-thin: 1px;
|
|
12
|
+
--input-outline-width-default: 2px;
|
|
13
|
+
--input-outline-width-thick: 3px;
|
|
14
|
+
|
|
15
|
+
--font-family: futura-pt, Seravek, 'Gill Sans Nova', Ubuntu, Calibri, 'DejaVu Sans', source-sans-pro, sans-serif;
|
|
12
16
|
|
|
13
17
|
--theme-form-button-font-size-x-small: 14px;
|
|
14
18
|
--theme-form-button-font-size-small: 14px;
|
|
@@ -54,19 +58,9 @@
|
|
|
54
58
|
--theme-form-button-icon-size-medium: 20px;
|
|
55
59
|
--theme-form-button-icon-size-large: 22px;
|
|
56
60
|
|
|
57
|
-
--theme-form-button-icon-gap-x-small: var(
|
|
58
|
-
|
|
59
|
-
);
|
|
60
|
-
--theme-form-button-icon-gap-
|
|
61
|
-
|
|
62
|
-
);
|
|
63
|
-
--theme-form-button-icon-gap-normal: var(
|
|
64
|
-
--theme-form-button-padding-inline-normal
|
|
65
|
-
);
|
|
66
|
-
--theme-form-button-icon-gap-medium: var(
|
|
67
|
-
--theme-form-button-padding-inline-medium
|
|
68
|
-
);
|
|
69
|
-
--theme-form-button-icon-gap-large: var(
|
|
70
|
-
--theme-form-button-padding-inline-large
|
|
71
|
-
);
|
|
61
|
+
--theme-form-button-icon-gap-x-small: var(--theme-form-button-padding-inline-x-small);
|
|
62
|
+
--theme-form-button-icon-gap-small: var(--theme-form-button-padding-inline-small);
|
|
63
|
+
--theme-form-button-icon-gap-normal: var(--theme-form-button-padding-inline-normal);
|
|
64
|
+
--theme-form-button-icon-gap-medium: var(--theme-form-button-padding-inline-medium);
|
|
65
|
+
--theme-form-button-icon-gap-large: var(--theme-form-button-padding-inline-large);
|
|
72
66
|
}
|
|
@@ -1,25 +1,13 @@
|
|
|
1
1
|
export const propValidators = {
|
|
2
2
|
size: ['x-small', 'small', 'normal', 'medium', 'large'],
|
|
3
|
-
weight: [
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
'wght-800',
|
|
12
|
-
'wght-900',
|
|
13
|
-
],
|
|
14
|
-
theme: [
|
|
15
|
-
'primary',
|
|
16
|
-
'secondary',
|
|
17
|
-
'tertiary',
|
|
18
|
-
'ghost',
|
|
19
|
-
'error',
|
|
20
|
-
'success',
|
|
21
|
-
'warning',
|
|
22
|
-
],
|
|
3
|
+
weight: ['wght-100', 'wght-200', 'wght-300', 'wght-400', 'wght-500', 'wght-600', 'wght-700', 'wght-800', 'wght-900'],
|
|
4
|
+
theme: ['primary', 'secondary', 'tertiary', 'ghost', 'error', 'success', 'warning'],
|
|
5
|
+
checkboxAppearance: [null, 'with-decorator'],
|
|
6
|
+
checkboxStyle: ['check', 'cross'],
|
|
7
|
+
radioAppearance: [null, 'with-decorator'],
|
|
8
|
+
optionsLayout: ['block', 'inline', 'equal-widths'],
|
|
9
|
+
inputTypesButton: ['button', 'cancel', 'reset', 'submit'],
|
|
10
|
+
inputTypesText: ['text', 'email', 'password', 'number', 'tel', 'url'],
|
|
23
11
|
};
|
|
24
12
|
|
|
25
13
|
export default propValidators;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { InpuTextC12, IFormFieldC12, IFormData } from '@/types/types.forms';
|
|
2
|
+
|
|
3
|
+
const formFieldC12 = <IFormFieldC12>{
|
|
4
|
+
label: '',
|
|
5
|
+
placeholder: '',
|
|
6
|
+
errorMessage: '',
|
|
7
|
+
useCustomError: false,
|
|
8
|
+
customErrors: {},
|
|
9
|
+
isValid: false,
|
|
10
|
+
isDirty: false,
|
|
11
|
+
type: 'string',
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export { formFieldC12 };
|
|
@@ -40,5 +40,17 @@
|
|
|
40
40
|
"minlength": 11,
|
|
41
41
|
"maxlength": 14,
|
|
42
42
|
"hint": "+441632123123"
|
|
43
|
+
},
|
|
44
|
+
"message": {
|
|
45
|
+
"pattern": "^[a-zA-Z0-9 ,.<>?@:;]{1,255}$",
|
|
46
|
+
"minlength": 1,
|
|
47
|
+
"maxlength": 255,
|
|
48
|
+
"hint": "+441632123123"
|
|
49
|
+
},
|
|
50
|
+
"positiveNumber0to100": {
|
|
51
|
+
"pattern": "^(100|[1-9]?[0-9])$",
|
|
52
|
+
"minlength": 1,
|
|
53
|
+
"maxlength": 3,
|
|
54
|
+
"hint": "Enter a number between 0 and 100"
|
|
43
55
|
}
|
|
44
56
|
}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="input-error-message" :class="[{ show: fieldHasError }, { detached: isDetached }, { hide: !fieldHasError }]">
|
|
3
|
+
<div class="inner" :class="[{ show: fieldHasError }]">
|
|
4
|
+
<div class="message" :id="`${id}-error-message`">
|
|
5
|
+
<ul v-if="isArray">
|
|
6
|
+
<li v-for="(message, index) in errorMessaging" :key="index">{{ message }}</li>
|
|
7
|
+
</ul>
|
|
8
|
+
<span v-else>
|
|
9
|
+
{{ errorMessaging }}
|
|
10
|
+
</span>
|
|
11
|
+
</div>
|
|
12
|
+
</div>
|
|
13
|
+
</div>
|
|
14
|
+
</template>
|
|
15
|
+
|
|
16
|
+
<script setup lang="ts">
|
|
17
|
+
const props = defineProps({
|
|
18
|
+
errorMessaging: {
|
|
19
|
+
type: [Object, String],
|
|
20
|
+
required: true,
|
|
21
|
+
},
|
|
22
|
+
fieldHasError: {
|
|
23
|
+
type: Boolean,
|
|
24
|
+
required: true,
|
|
25
|
+
},
|
|
26
|
+
id: {
|
|
27
|
+
type: String,
|
|
28
|
+
required: true,
|
|
29
|
+
},
|
|
30
|
+
styleClassPassthrough: {
|
|
31
|
+
type: String,
|
|
32
|
+
default: '',
|
|
33
|
+
},
|
|
34
|
+
compact: {
|
|
35
|
+
type: Boolean,
|
|
36
|
+
value: false,
|
|
37
|
+
},
|
|
38
|
+
isDetached: {
|
|
39
|
+
type: Boolean,
|
|
40
|
+
required: true,
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
const isArray = computed(() => {
|
|
45
|
+
return Array.isArray(props.errorMessaging);
|
|
46
|
+
});
|
|
47
|
+
</script>
|
|
48
|
+
|
|
49
|
+
<style lang="css" scoped>
|
|
50
|
+
.input-error-message {
|
|
51
|
+
--_grid-template-rows: 0fr;
|
|
52
|
+
--_opacity-show: 1;
|
|
53
|
+
--_opacity-hide: 0;
|
|
54
|
+
--_opacity: var(--_opacity-hide);
|
|
55
|
+
|
|
56
|
+
--_display-show: block;
|
|
57
|
+
--_display-hide: none;
|
|
58
|
+
--_display: var(--_display-hide);
|
|
59
|
+
--_gutter: 12px;
|
|
60
|
+
--_gutter-block: 0;
|
|
61
|
+
--_gutter-inline: var(--_gutter);
|
|
62
|
+
--_transition-duration: 500ms;
|
|
63
|
+
--_transition-timing-function: linear;
|
|
64
|
+
--_message-translate-y-hide: calc(var(--_gutter) * -2);
|
|
65
|
+
--_message-translate-y-show: 2px;
|
|
66
|
+
--_message-translate-y: var(--_message-translate-y-hide);
|
|
67
|
+
--_padding-message-show: var(--_gutter);
|
|
68
|
+
--_padding-message-hide: 0;
|
|
69
|
+
--_padding-message: var(--_padding-message-hide);
|
|
70
|
+
|
|
71
|
+
grid-row: 2;
|
|
72
|
+
grid-column: 1;
|
|
73
|
+
display: grid;
|
|
74
|
+
grid-template-rows: var(--_grid-template-rows);
|
|
75
|
+
|
|
76
|
+
color: hsl(from var(--theme-error) h s 95%);
|
|
77
|
+
background-color: var(--theme-error);
|
|
78
|
+
|
|
79
|
+
transition-property: grid-template-rows;
|
|
80
|
+
transition-duration: var(--_transition-duration);
|
|
81
|
+
transition-timing-function: var(--_transition-timing-function);
|
|
82
|
+
transition-behavior: allow-discrete;
|
|
83
|
+
|
|
84
|
+
&.detached {
|
|
85
|
+
border-radius: var(--input-border-radius);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
&.show {
|
|
89
|
+
--_grid-template-rows: 1fr;
|
|
90
|
+
--_opacity: var(--_opacity-show);
|
|
91
|
+
--_display: var(--_display-show);
|
|
92
|
+
--_message-translate-y: var(--_message-translate-y-show);
|
|
93
|
+
--_gutter-block: var(--_gutter);
|
|
94
|
+
--_padding-message: var(--_padding-message-show);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.inner {
|
|
98
|
+
overflow: hidden;
|
|
99
|
+
|
|
100
|
+
transition: opacity var(--_transition-duration) var(--_transition-timing-function), display var(--_transition-duration) var(--_transition-timing-function) allow-discrete;
|
|
101
|
+
|
|
102
|
+
&.show {
|
|
103
|
+
display: var(--_display-show);
|
|
104
|
+
opacity: var(--_opacity-show);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.message {
|
|
108
|
+
font-family: var(--font-family);
|
|
109
|
+
font-size: 16px;
|
|
110
|
+
font-weight: 500;
|
|
111
|
+
padding-block: var(--_padding-message);
|
|
112
|
+
padding-inline: var(--_gutter-inline);
|
|
113
|
+
transform: translateY(var(--_message-translate-y));
|
|
114
|
+
|
|
115
|
+
transition-property: transform, padding;
|
|
116
|
+
transition-duration: var(--_transition-duration);
|
|
117
|
+
transition-timing-function: linear;
|
|
118
|
+
|
|
119
|
+
ul {
|
|
120
|
+
list-style-type: none;
|
|
121
|
+
padding-inline-start: 0;
|
|
122
|
+
margin-block-start: 0;
|
|
123
|
+
margin-block-end: 0;
|
|
124
|
+
|
|
125
|
+
li + li {
|
|
126
|
+
margin-block-start: 6px;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
</style>
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
:readonly
|
|
5
5
|
:aria-disabled="readonly"
|
|
6
6
|
:data-test-id="dataTestId"
|
|
7
|
-
class="btn"
|
|
7
|
+
class="input-button-core btn"
|
|
8
8
|
:class="[`btn-${type}`, `theme-${theme}`, size, effectClass, styleClassPassthrough, { 'icon-only': isIconOnly }]"
|
|
9
9
|
>
|
|
10
10
|
<span v-if="useEffect && effect == 'fancy'" class="fancy"></span>
|
|
@@ -54,9 +54,9 @@ const props = defineProps({
|
|
|
54
54
|
},
|
|
55
55
|
type: {
|
|
56
56
|
type: String as PropType<'submit' | 'button' | 'reset'>,
|
|
57
|
-
default: '
|
|
57
|
+
default: 'button',
|
|
58
58
|
validator(value: string) {
|
|
59
|
-
return
|
|
59
|
+
return propValidators.inputTypesButton.includes(value);
|
|
60
60
|
},
|
|
61
61
|
},
|
|
62
62
|
buttonText: {
|
|
@@ -111,7 +111,6 @@ const isIconOnly = computed(() => slots.iconOnly !== undefined);
|
|
|
111
111
|
.btn {
|
|
112
112
|
--_padding-block: var(--theme-form-button-padding-block-normal);
|
|
113
113
|
--_padding-inline: var(--theme-form-button-padding-inline-normal);
|
|
114
|
-
--_border-radius: 4px;
|
|
115
114
|
--_icon-gap: var(--theme-form-button-icon-gap-normal);
|
|
116
115
|
|
|
117
116
|
align-items: center;
|
|
@@ -119,8 +118,7 @@ const isIconOnly = computed(() => slots.iconOnly !== undefined);
|
|
|
119
118
|
gap: var(--_icon-gap);
|
|
120
119
|
justify-content: center;
|
|
121
120
|
border: none;
|
|
122
|
-
border-radius: var(--
|
|
123
|
-
|
|
121
|
+
border-radius: var(--input-border-radius);
|
|
124
122
|
font-family: var(--font-family);
|
|
125
123
|
|
|
126
124
|
padding-inline: var(--_padding-inline);
|
|
@@ -128,11 +126,15 @@ const isIconOnly = computed(() => slots.iconOnly !== undefined);
|
|
|
128
126
|
|
|
129
127
|
transition: all 0.2s ease-in-out;
|
|
130
128
|
|
|
131
|
-
&:hover
|
|
132
|
-
&:focus-visible {
|
|
129
|
+
&:hover {
|
|
133
130
|
cursor: pointer;
|
|
134
131
|
}
|
|
135
132
|
|
|
133
|
+
&:focus-visible {
|
|
134
|
+
outline: var(--focus-visible-outline);
|
|
135
|
+
box-shadow: var(--focus-visible-box-shadow);
|
|
136
|
+
}
|
|
137
|
+
|
|
136
138
|
&[readonly] {
|
|
137
139
|
opacity: 0.5;
|
|
138
140
|
&:hover,
|
|
@@ -266,6 +268,7 @@ const isIconOnly = computed(() => slots.iconOnly !== undefined);
|
|
|
266
268
|
}
|
|
267
269
|
|
|
268
270
|
--_border-width: var(--input-border-width-default);
|
|
271
|
+
--_outline-width: var(--input-outline-width-thin);
|
|
269
272
|
|
|
270
273
|
/*
|
|
271
274
|
* Initial theme (primary)
|