srcdev-nuxt-forms 0.0.19 → 0.0.21
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/forms/variables/_theme.css +3 -0
- package/assets/styles/main.css +2 -1
- package/assets/styles/variables/colors/_blue.css +15 -0
- package/assets/styles/variables/colors/_gray.css +15 -0
- package/assets/styles/variables/colors/_green.css +15 -0
- package/assets/styles/variables/colors/_orange.css +15 -0
- package/assets/styles/variables/colors/_red.css +15 -0
- package/assets/styles/variables/colors/_yellow.css +15 -0
- package/assets/styles/variables/colors/index.css +6 -0
- package/assets/styles/variables/index.css +1 -1
- package/components/forms/input-text/InputTextCore.vue +18 -8
- package/components/forms/input-text/variants/InputTextMaterial.vue +144 -0
- package/components/forms/ui/FormField.vue +2 -2
- package/components/forms/ui/FormWrapper.vue +2 -2
- package/package.json +1 -1
- package/pages/index.vue +3 -2
- package/assets/styles/variables/_colours.css +0 -10
package/assets/styles/main.css
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
@import
|
|
1
|
+
@import './variables';
|
|
2
|
+
@import './forms';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
:where(html) {
|
|
2
|
+
--blue-0: #e7f5ff;
|
|
3
|
+
--blue-1: #d0ebff;
|
|
4
|
+
--blue-2: #a5d8ff;
|
|
5
|
+
--blue-3: #74c0fc;
|
|
6
|
+
--blue-4: #4dabf7;
|
|
7
|
+
--blue-5: #339af0;
|
|
8
|
+
--blue-6: #228be6;
|
|
9
|
+
--blue-7: #1c7ed6;
|
|
10
|
+
--blue-8: #1971c2;
|
|
11
|
+
--blue-9: #1864ab;
|
|
12
|
+
--blue-10: #145591;
|
|
13
|
+
--blue-11: #114678;
|
|
14
|
+
--blue-12: #0d375e;
|
|
15
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
:where(html) {
|
|
2
|
+
--gray-0: #f8f9fa;
|
|
3
|
+
--gray-1: #f1f3f5;
|
|
4
|
+
--gray-2: #e9ecef;
|
|
5
|
+
--gray-3: #dee2e6;
|
|
6
|
+
--gray-4: #ced4da;
|
|
7
|
+
--gray-5: #adb5bd;
|
|
8
|
+
--gray-6: #868e96;
|
|
9
|
+
--gray-7: #495057;
|
|
10
|
+
--gray-8: #343a40;
|
|
11
|
+
--gray-9: #212529;
|
|
12
|
+
--gray-10: #16191d;
|
|
13
|
+
--gray-11: #0d0f12;
|
|
14
|
+
--gray-12: #030507;
|
|
15
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
:where(html) {
|
|
2
|
+
--green-0: #ebfbee;
|
|
3
|
+
--green-1: #d3f9d8;
|
|
4
|
+
--green-2: #b2f2bb;
|
|
5
|
+
--green-3: #8ce99a;
|
|
6
|
+
--green-4: #69db7c;
|
|
7
|
+
--green-5: #51cf66;
|
|
8
|
+
--green-6: #40c057;
|
|
9
|
+
--green-7: #37b24d;
|
|
10
|
+
--green-8: #2f9e44;
|
|
11
|
+
--green-9: #2b8a3e;
|
|
12
|
+
--green-10: #237032;
|
|
13
|
+
--green-11: #1b5727;
|
|
14
|
+
--green-12: #133d1b;
|
|
15
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
:where(html) {
|
|
2
|
+
--orange-0: #fff4e6;
|
|
3
|
+
--orange-1: #ffe8cc;
|
|
4
|
+
--orange-2: #ffd8a8;
|
|
5
|
+
--orange-3: #ffc078;
|
|
6
|
+
--orange-4: #ffa94d;
|
|
7
|
+
--orange-5: #ff922b;
|
|
8
|
+
--orange-6: #fd7e14;
|
|
9
|
+
--orange-7: #f76707;
|
|
10
|
+
--orange-8: #e8590c;
|
|
11
|
+
--orange-9: #d9480f;
|
|
12
|
+
--orange-10: #bf400d;
|
|
13
|
+
--orange-11: #99330b;
|
|
14
|
+
--orange-12: #802b09;
|
|
15
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
:where(html) {
|
|
2
|
+
--red-0: #fff5f5;
|
|
3
|
+
--red-1: #ffe3e3;
|
|
4
|
+
--red-2: #ffc9c9;
|
|
5
|
+
--red-3: #ffa8a8;
|
|
6
|
+
--red-4: #ff8787;
|
|
7
|
+
--red-5: #ff6b6b;
|
|
8
|
+
--red-6: #fa5252;
|
|
9
|
+
--red-7: #f03e3e;
|
|
10
|
+
--red-8: #e03131;
|
|
11
|
+
--red-9: #c92a2a;
|
|
12
|
+
--red-10: #b02525;
|
|
13
|
+
--red-11: #962020;
|
|
14
|
+
--red-12: #7d1a1a;
|
|
15
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
:where(html) {
|
|
2
|
+
--yellow-0: #fff9db;
|
|
3
|
+
--yellow-1: #fff3bf;
|
|
4
|
+
--yellow-2: #ffec99;
|
|
5
|
+
--yellow-3: #ffe066;
|
|
6
|
+
--yellow-4: #ffd43b;
|
|
7
|
+
--yellow-5: #fcc419;
|
|
8
|
+
--yellow-6: #fab005;
|
|
9
|
+
--yellow-7: #f59f00;
|
|
10
|
+
--yellow-8: #f08c00;
|
|
11
|
+
--yellow-9: #e67700;
|
|
12
|
+
--yellow-10: #b35c00;
|
|
13
|
+
--yellow-11: #804200;
|
|
14
|
+
--yellow-12: #663500;
|
|
15
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
@import
|
|
1
|
+
@import './colors/index.css';
|
|
@@ -7,7 +7,12 @@
|
|
|
7
7
|
:pattern="componentValidation.pattern"
|
|
8
8
|
:maxlength="componentValidation.maxlength"
|
|
9
9
|
:required
|
|
10
|
-
:class="[
|
|
10
|
+
:class="[
|
|
11
|
+
'input-text',
|
|
12
|
+
'text-normal',
|
|
13
|
+
styleClassPassthrough,
|
|
14
|
+
{ error: fieldHasError() },
|
|
15
|
+
]"
|
|
11
16
|
v-model="modelValue.data[name]"
|
|
12
17
|
ref="inputField"
|
|
13
18
|
@focusin="isFocused = true"
|
|
@@ -54,6 +59,10 @@ const props = defineProps({
|
|
|
54
59
|
type: Object as PropType<InpuTextC12>,
|
|
55
60
|
required: true,
|
|
56
61
|
},
|
|
62
|
+
styleClassPassthrough: {
|
|
63
|
+
type: String,
|
|
64
|
+
default: '',
|
|
65
|
+
},
|
|
57
66
|
});
|
|
58
67
|
|
|
59
68
|
const modelValue = defineModel() as Ref<IFormData>;
|
|
@@ -85,9 +94,12 @@ const fieldHasError = () => {
|
|
|
85
94
|
return false;
|
|
86
95
|
};
|
|
87
96
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
97
|
+
watchEffect(() => {
|
|
98
|
+
console.log(
|
|
99
|
+
'InputTextCore >> Form value changed to: ',
|
|
100
|
+
modelValue.value.data[name.value]
|
|
101
|
+
);
|
|
102
|
+
});
|
|
91
103
|
|
|
92
104
|
const isValid = () => {
|
|
93
105
|
setTimeout(() => {
|
|
@@ -115,9 +127,7 @@ onMounted(() => {
|
|
|
115
127
|
</script>
|
|
116
128
|
|
|
117
129
|
<style lang="css">
|
|
118
|
-
.input-text {
|
|
130
|
+
/* .input-text {
|
|
119
131
|
transition: all linear 200ms;
|
|
120
|
-
|
|
121
|
-
width: 100%;
|
|
122
|
-
}
|
|
132
|
+
} */
|
|
123
133
|
</style>
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="input-text-material">
|
|
3
|
+
<label class="label" :class="[{ active: isFocused }]" :for="id"
|
|
4
|
+
>{{ c12.label }} - isFocused({{ isFocused }})</label
|
|
5
|
+
>
|
|
6
|
+
<div class="input-placeholder">
|
|
7
|
+
<InputTextCore
|
|
8
|
+
:id
|
|
9
|
+
:name
|
|
10
|
+
:type
|
|
11
|
+
:validation
|
|
12
|
+
:required
|
|
13
|
+
v-model="modelValue"
|
|
14
|
+
v-model:isFocused="isFocused"
|
|
15
|
+
:c12
|
|
16
|
+
:style-class-passthrough="styleClassPassthrough"
|
|
17
|
+
/>
|
|
18
|
+
</div>
|
|
19
|
+
</div>
|
|
20
|
+
</template>
|
|
21
|
+
|
|
22
|
+
<script setup lang="ts">
|
|
23
|
+
import type { InpuTextC12, IFormData } from '@/types/types.forms';
|
|
24
|
+
import { validationConfig } from '@/components/forms/c12/validation-patterns';
|
|
25
|
+
|
|
26
|
+
const props = defineProps({
|
|
27
|
+
type: {
|
|
28
|
+
// type: String as PropType<"text" | "password" | "tel" | "number" | "email" | "url">, // This breaks props setup in unit tests
|
|
29
|
+
type: String,
|
|
30
|
+
validator(value: string) {
|
|
31
|
+
return ['text', 'password', 'tel', 'number', 'email', 'url'].includes(
|
|
32
|
+
value
|
|
33
|
+
);
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
id: {
|
|
37
|
+
// type: String as PropType<string>,
|
|
38
|
+
type: String,
|
|
39
|
+
required: true,
|
|
40
|
+
},
|
|
41
|
+
name: {
|
|
42
|
+
type: String,
|
|
43
|
+
default: null,
|
|
44
|
+
},
|
|
45
|
+
validation: {
|
|
46
|
+
type: String,
|
|
47
|
+
default: '',
|
|
48
|
+
},
|
|
49
|
+
required: {
|
|
50
|
+
type: Boolean,
|
|
51
|
+
value: false,
|
|
52
|
+
},
|
|
53
|
+
isPending: {
|
|
54
|
+
type: Boolean,
|
|
55
|
+
value: false,
|
|
56
|
+
},
|
|
57
|
+
c12: {
|
|
58
|
+
type: Object as PropType<InpuTextC12>,
|
|
59
|
+
required: true,
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
const name = computed(() => {
|
|
64
|
+
return props.name !== null ? props.name : props.id;
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
const styleClassPassthrough = computed(() => {
|
|
68
|
+
return isFocused.value ? 'is-active' : '';
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
const modelValue = defineModel() as Ref<IFormData>;
|
|
72
|
+
const isFocused = ref(false);
|
|
73
|
+
</script>
|
|
74
|
+
|
|
75
|
+
<style lang="css">
|
|
76
|
+
.input-text-material {
|
|
77
|
+
--_gutter: 12px;
|
|
78
|
+
|
|
79
|
+
display: grid;
|
|
80
|
+
grid-template-columns: 1fr;
|
|
81
|
+
/* grid-template-rows: var(--_gutter) 1fr var(--_gutter); */
|
|
82
|
+
grid-template-rows: var(--_gutter) 1fr var(--_gutter);
|
|
83
|
+
gap: calc(var(--_gutter) / 2);
|
|
84
|
+
|
|
85
|
+
border: 1px solid red;
|
|
86
|
+
border-radius: 2px;
|
|
87
|
+
|
|
88
|
+
margin-bottom: 20px;
|
|
89
|
+
/* padding: calc(2 * var(--_gutter)); */
|
|
90
|
+
|
|
91
|
+
.label {
|
|
92
|
+
grid-row: 2;
|
|
93
|
+
grid-column: 1;
|
|
94
|
+
|
|
95
|
+
font-family: var(--font-family);
|
|
96
|
+
font-size: 16px;
|
|
97
|
+
font-weight: 700;
|
|
98
|
+
padding: var(--_gutter);
|
|
99
|
+
/* transform: translateY(12px); */
|
|
100
|
+
|
|
101
|
+
z-index: 2;
|
|
102
|
+
|
|
103
|
+
transition: all linear 0.2s;
|
|
104
|
+
|
|
105
|
+
&.active {
|
|
106
|
+
grid-row: 1;
|
|
107
|
+
grid-column: 1;
|
|
108
|
+
/* padding: 0; */
|
|
109
|
+
transform: translateY(-10px);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.input-placeholder {
|
|
114
|
+
grid-row: 2;
|
|
115
|
+
grid-column: 1;
|
|
116
|
+
align-content: center;
|
|
117
|
+
padding-inline: var(--_gutter);
|
|
118
|
+
transform: translateY(12px);
|
|
119
|
+
|
|
120
|
+
.input-text {
|
|
121
|
+
font-family: var(--font-family);
|
|
122
|
+
border: 0px solid green;
|
|
123
|
+
padding: var(--_gutter);
|
|
124
|
+
font-size: 16px;
|
|
125
|
+
|
|
126
|
+
/* &::placeholder,
|
|
127
|
+
&:-ms-input-placeholder,
|
|
128
|
+
&::-moz-placeholder, */
|
|
129
|
+
&::-webkit-input-placeholder {
|
|
130
|
+
font-family: var(--font-family);
|
|
131
|
+
color: var(--gray-5);
|
|
132
|
+
font-size: 14px;
|
|
133
|
+
font-style: italic;
|
|
134
|
+
font-weight: 700;
|
|
135
|
+
opacity: 0;
|
|
136
|
+
|
|
137
|
+
&.is-active {
|
|
138
|
+
opacity: 1;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
</style>
|
|
@@ -16,7 +16,7 @@ defineProps({
|
|
|
16
16
|
type: Boolean as PropType<boolean>,
|
|
17
17
|
default: true,
|
|
18
18
|
},
|
|
19
|
-
})
|
|
19
|
+
});
|
|
20
20
|
</script>
|
|
21
21
|
|
|
22
22
|
<style lang="css">
|
|
@@ -26,7 +26,7 @@ defineProps({
|
|
|
26
26
|
|
|
27
27
|
margin-inline: auto;
|
|
28
28
|
width: min(100% - calc(2 * var(--_gutter-width)), var(--_max-width));
|
|
29
|
-
outline: 1px solid
|
|
29
|
+
outline: 1px solid var(--gray-5);
|
|
30
30
|
|
|
31
31
|
&.has-gutter {
|
|
32
32
|
--_gutter-width: 16px;
|
|
@@ -12,12 +12,12 @@ defineProps({
|
|
|
12
12
|
default: 'narrow',
|
|
13
13
|
validator: (val: string) => ['narrow', 'medium', 'wide'].includes(val),
|
|
14
14
|
},
|
|
15
|
-
})
|
|
15
|
+
});
|
|
16
16
|
</script>
|
|
17
17
|
|
|
18
18
|
<style lang="css">
|
|
19
19
|
.form-wrapper {
|
|
20
|
-
outline: 1px solid
|
|
20
|
+
outline: 1px solid var(--gray-12);
|
|
21
21
|
|
|
22
22
|
&.narrow {
|
|
23
23
|
max-width: 400px;
|
package/package.json
CHANGED
package/pages/index.vue
CHANGED
|
@@ -12,17 +12,18 @@
|
|
|
12
12
|
<FormField width="wide" :has-gutter="true">
|
|
13
13
|
<template #default>
|
|
14
14
|
<p>Input text</p>
|
|
15
|
-
<
|
|
15
|
+
<InputTextMaterial
|
|
16
16
|
id="username"
|
|
17
|
+
name="username"
|
|
17
18
|
type="text"
|
|
18
19
|
validation="username"
|
|
19
20
|
:required="true"
|
|
20
|
-
v-model="formData"
|
|
21
21
|
:c12="{
|
|
22
22
|
label: 'Choose Username',
|
|
23
23
|
placeholder: 'eg. YourUserName',
|
|
24
24
|
errorMessage: 'Please enter a valid username',
|
|
25
25
|
}"
|
|
26
|
+
v-model="formData"
|
|
26
27
|
/>
|
|
27
28
|
</template>
|
|
28
29
|
</FormField>
|