srcdev-nuxt-forms 2.1.4 → 2.1.5

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.
@@ -14,12 +14,12 @@
14
14
  --theme-form-checkbox-bg: light-dark(var(--gray-1), var(--gray-4));
15
15
  --theme-form-checkbox-shadow: transparent;
16
16
  --theme-form-checkbox-shadow-focus: var(--blue-6);
17
- --theme-form-checkbox-symbol: var(--blue-8);
17
+ --theme-form-checkbox-symbol: var(--blue-12);
18
18
 
19
19
  --theme-form-radio-bg: light-dark(var(--gray-1), var(--gray-4));
20
20
  --theme-form-radio-shadow: transparent;
21
21
  --theme-form-radio-shadow-focus: var(--blue-6);
22
- --theme-form-radio-symbol: var(--blue-8);
22
+ --theme-form-radio-symbol: var(--blue-12);
23
23
  }
24
24
 
25
25
  [data-btn-theme='primary'] {
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <div class="input-checkbox-wrapper" :data-form-theme="formTheme" :class="[size, checkboxAppearance, { error: fieldHasError }]">
2
+ <div class="input-checkbox-wrapper" :data-form-theme="formTheme" :class="[size, { error: fieldHasError }]">
3
3
  <input
4
4
  type="checkbox"
5
5
  :true-value="trueValue"
@@ -8,20 +8,20 @@
8
8
  :name
9
9
  :required="required && !multipleOptions"
10
10
  :value="trueValue"
11
- :class="['input-checkbox-core', size, checkboxAppearance, { error: fieldHasError }]"
11
+ class="input-checkbox-core"
12
+ :class="[size, { error: fieldHasError }]"
12
13
  v-model="modelValue"
13
14
  ref="inputField"
14
15
  />
15
- <div v-if="checkboxAppearance === 'with-decorator'" :class="['input-checkbox-decorator', size, checkboxStyle]">
16
- <Icon name="material-symbols:check" class="icon-check" :class="[{ checked: isChecked }]" />
17
- <div v-if="checkboxStyle === 'check' || checkboxStyle === 'cross'" :class="[checkboxStyle, { checked: isChecked }]"></div>
16
+ <div class="input-checkbox-decorator" :class="[size, stateIcon]">
17
+ <Icon :name="icon" class="icon" />
18
18
  </div>
19
19
  </div>
20
20
  </template>
21
21
 
22
22
  <script setup lang="ts">
23
23
  import propValidators from '../c12/prop-validators';
24
- const { id, name, required, trueValue, falseValue, multipleOptions, theme, styleClassPassthrough, size, checkboxAppearance, checkboxStyle, fieldHasError } = defineProps({
24
+ const { id, name, required, trueValue, falseValue, multipleOptions, theme, styleClassPassthrough, size, stateIcon, fieldHasError } = defineProps({
25
25
  id: {
26
26
  type: String,
27
27
  required: true,
@@ -60,18 +60,11 @@ const { id, name, required, trueValue, falseValue, multipleOptions, theme, style
60
60
  return propValidators.size.includes(value);
61
61
  },
62
62
  },
63
- checkboxAppearance: {
64
- type: String as PropType<string>,
65
- default: null,
66
- validator(value: string) {
67
- return propValidators.checkboxAppearance.includes(value);
68
- },
69
- },
70
- checkboxStyle: {
71
- type: String as PropType<string>,
72
- default: 'check',
73
- validator(value: string) {
74
- return propValidators.checkboxStyle.includes(value);
63
+ stateIcon: {
64
+ type: Object as PropType<{ checked: string; unchecked: string }>,
65
+ default: {
66
+ checked: 'carbon:checkbox-checked',
67
+ unchecked: 'carbon:checkbox',
75
68
  },
76
69
  },
77
70
  fieldHasError: {
@@ -103,29 +96,27 @@ const isChecked = computed(() => {
103
96
  return modelValue.value === trueValue;
104
97
  }
105
98
  });
99
+
100
+ const icon = computed(() => {
101
+ return isChecked.value ? stateIcon.checked : stateIcon.unchecked;
102
+ });
106
103
  </script>
107
104
 
108
105
  <style scoped lang="css">
109
106
  .input-checkbox-wrapper {
110
107
  --_checkbox-size: initial;
111
- --_checkbox-border-radius: 4px;
108
+ --_wrapper-size: calc(var(--_checkbox-size) - 5px);
112
109
  --_outline-width: var(--input-outline-width-thin);
113
- --_border-width: var(--input-border-width-default); /* --input-border-width-default / 2px */
110
+ --_border-width: var(--input-border-width-default);
111
+ --_box-shadow: none;
114
112
 
115
113
  display: grid;
116
114
  grid-template-areas: 'element-stack';
115
+ height: var(--_wrapper-size);
116
+ width: var(--_wrapper-size);
117
117
 
118
- &.with-decorator {
119
- border-radius: var(--_checkbox-border-radius);
120
- border: var(--_border-width) solid var(--theme-form-input-border);
121
- height: var(--_checkbox-size);
122
- width: var(--_checkbox-size);
123
-
124
- &:has(.input-checkbox-core:focus-visible) {
125
- border: var(--_border-width) solid var(--theme-form-input-border-focus);
126
- outline: var(--_outline-width) solid hsl(from var(--theme-form-input-outline-focus) h s 50%);
127
- box-shadow: var(--theme-form-focus-box-shadow);
128
- }
118
+ &:has(.input-checkbox-core:focus-visible) {
119
+ --_box-shadow: var(--theme-form-focus-box-shadow);
129
120
  }
130
121
 
131
122
  /* Sizes */
@@ -136,7 +127,7 @@ const isChecked = computed(() => {
136
127
  --_checkbox-size: 24px;
137
128
  }
138
129
  &.normal {
139
- --_checkbox-size: 30px;
130
+ --_checkbox-size: 34px;
140
131
  }
141
132
  &.medium {
142
133
  --_checkbox-size: 40px;
@@ -146,120 +137,36 @@ const isChecked = computed(() => {
146
137
  }
147
138
 
148
139
  .input-checkbox-decorator {
140
+ --_padding: 5px;
149
141
  display: grid;
150
142
  grid-area: element-stack;
151
143
  background-color: var(--theme-form-checkbox-bg);
152
-
153
- border-radius: var(--_checkbox-border-radius);
154
- transform: translate(-2px, -2px);
155
- height: var(--_checkbox-size);
156
- width: var(--_checkbox-size);
144
+ border-radius: 2px;
157
145
  place-content: center;
158
146
  position: relative;
147
+ height: var(--_wrapper-size);
148
+ width: var(--_wrapper-size);
159
149
  z-index: -1;
160
150
 
161
- :not(&.check),
162
- :not(&.cross) {
163
- .icon-check {
164
- display: none;
165
- }
166
- }
167
-
168
- .check {
151
+ .icon {
169
152
  grid-area: stack;
170
- width: calc(var(--_checkbox-size) * 0.2);
171
- height: calc(var(--_checkbox-size) * 0.45);
172
- border-bottom: 3px solid var(--theme-form-checkbox-symbol);
173
- border-right: 3px solid var(--theme-form-checkbox-symbol);
174
- transform: rotate(45deg) translate(-1px, -1px);
175
- opacity: 0;
176
- transition: opacity 0.2s ease-in-out;
177
-
178
- &.checked {
179
- opacity: 1;
180
- }
181
- }
182
-
183
- .cross {
184
- grid-area: stack;
185
- width: calc(var(--_checkbox-size) * 0.65);
186
- height: 3px;
187
- background-color: var(--theme-form-checkbox-symbol);
188
- transform: rotate(45deg);
189
- opacity: 0;
190
- transition: opacity 0.2s ease-in-out;
191
-
192
- &.checked {
193
- opacity: 1;
194
-
195
- &::after {
196
- opacity: 1;
197
- }
198
- }
199
-
200
- &::after {
201
- content: '';
202
- grid-area: stack;
203
- display: block;
204
- width: calc(var(--_checkbox-size) * 0.65);
205
- height: 3px;
206
- background-color: var(--theme-form-checkbox-symbol);
207
- transform: rotate(-90deg);
208
- opacity: 0;
209
- transition: opacity 0.2s ease-in-out;
210
- }
211
- }
212
-
213
- .icon-check {
214
- grid-area: stack;
215
- display: block;
153
+ color: var(--theme-form-radio-symbol);
216
154
  height: var(--_checkbox-size);
217
155
  width: var(--_checkbox-size);
218
- transform: translate(-3px, 0px);
219
- zoom: 0.75;
220
- margin: 0;
221
- opacity: 0;
222
- padding: 0;
223
- transition: opacity 0.2s ease-in-out;
224
-
225
- &.checked {
226
- opacity: 1;
227
- }
156
+ box-shadow: var(--_box-shadow);
228
157
  }
229
158
  }
230
159
 
231
160
  .input-checkbox-core {
232
161
  grid-area: element-stack;
233
- border: var(--_border-width) solid var(--theme-form-input-border);
234
- height: var(--_checkbox-size);
235
- width: var(--_checkbox-size);
236
-
237
- transition: all 0.2s ease-in-out;
238
-
239
- &.with-decorator {
240
- appearance: none;
241
- margin: 0;
242
- overflow: hidden;
243
- opacity: 0;
244
- }
162
+ appearance: none;
163
+ margin: 0;
164
+ overflow: hidden;
165
+ opacity: 0;
245
166
 
246
167
  &:hover {
247
168
  cursor: pointer;
248
169
  }
249
-
250
- &:focus-visible {
251
- border: var(--_border-width) solid var(--theme-form-input-border);
252
- outline: var(--_outline-width) solid hsl(from var(--theme-form-input-outline-focus) h s 50%);
253
- box-shadow: var(--theme-form-focus-box-shadow);
254
- }
255
-
256
- &:checked::after {
257
- /* content: '✔'; */
258
- display: grid;
259
- font-family: var(--font-family);
260
- place-content: center;
261
- font-size: calc(var(--_checkbox-size) * 0.75);
262
- }
263
170
  }
264
171
  }
265
172
  </style>
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <div class="input-radiobutton-wrapper" :data-form-theme="formTheme" :class="[size, checkboxAppearance, { error: fieldHasError }]">
2
+ <div class="input-radiobutton-wrapper" :data-form-theme="formTheme" :class="[size, { error: fieldHasError }]">
3
3
  <input
4
4
  type="radio"
5
5
  :true-value="trueValue"
@@ -8,19 +8,20 @@
8
8
  :name
9
9
  :required="required && !multipleOptions"
10
10
  :value="trueValue"
11
- :class="['input-radiobutton-core', size, checkboxAppearance, { error: fieldHasError }]"
11
+ class="input-radiobutton-core"
12
+ :class="[size, { error: fieldHasError }]"
12
13
  v-model="modelValue"
13
14
  ref="inputField"
14
15
  />
15
- <div v-if="checkboxAppearance === 'with-decorator'" :class="['input-radiobutton-decorator', size, checkboxStyle]">
16
- <div v-if="checkboxStyle === 'check' || checkboxStyle === 'cross'" :class="[checkboxStyle, { checked: isChecked }]"></div>
16
+ <div class="input-radiobutton-decorator" :class="[size]">
17
+ <Icon :name="icon" class="icon" />
17
18
  </div>
18
19
  </div>
19
20
  </template>
20
21
 
21
22
  <script setup lang="ts">
22
23
  import propValidators from '../c12/prop-validators';
23
- const { id, name, required, trueValue, falseValue, multipleOptions, theme, styleClassPassthrough, size, checkboxAppearance, checkboxStyle, fieldHasError } = defineProps({
24
+ const { id, name, required, trueValue, falseValue, multipleOptions, theme, styleClassPassthrough, size, stateIcon, fieldHasError } = defineProps({
24
25
  id: {
25
26
  type: String,
26
27
  required: true,
@@ -59,18 +60,11 @@ const { id, name, required, trueValue, falseValue, multipleOptions, theme, style
59
60
  return propValidators.size.includes(value);
60
61
  },
61
62
  },
62
- checkboxAppearance: {
63
- type: String as PropType<string>,
64
- default: null,
65
- validator(value: string) {
66
- return propValidators.checkboxAppearance.includes(value);
67
- },
68
- },
69
- checkboxStyle: {
70
- type: String as PropType<string>,
71
- default: 'check',
72
- validator(value: string) {
73
- return propValidators.checkboxStyle.includes(value);
63
+ stateIcon: {
64
+ type: Object as PropType<{ checked: string; unchecked: string }>,
65
+ default: {
66
+ checked: 'carbon:radio-button-checked',
67
+ unchecked: 'carbon:radio-button',
74
68
  },
75
69
  },
76
70
  fieldHasError: {
@@ -105,6 +99,10 @@ const isChecked = computed(() => {
105
99
  return modelValue.value === trueValue;
106
100
  }
107
101
  });
102
+
103
+ const icon = computed(() => {
104
+ return isChecked.value ? stateIcon.checked : stateIcon.unchecked;
105
+ });
108
106
  </script>
109
107
 
110
108
  <style scoped lang="css">
@@ -112,22 +110,16 @@ const isChecked = computed(() => {
112
110
  --_checkbox-size: initial;
113
111
  --_outline-width: var(--input-outline-width-thin);
114
112
  --_border-width: var(--input-border-width-default);
113
+ --_box-shadow: none;
115
114
 
116
115
  display: grid;
117
116
  grid-template-areas: 'element-stack';
117
+ height: var(--_checkbox-size);
118
+ width: var(--_checkbox-size);
119
+ overflow: hidden;
118
120
 
119
- &.with-decorator {
120
- border-radius: 50%;
121
- border: var(--_border-width) solid var(--theme-form-input-border);
122
- height: var(--_checkbox-size);
123
- width: var(--_checkbox-size);
124
- overflow: hidden;
125
-
126
- &:has(.input-radiobutton-core:focus-visible) {
127
- border: var(--_border-width) solid var(--theme-form-input-border-focus);
128
- outline: var(--_outline-width) solid hsl(from var(--theme-form-input-outline-focus) h s 50%);
129
- box-shadow: var(--theme-form-focus-box-shadow);
130
- }
121
+ &:has(.input-radiobutton-core:focus-visible) {
122
+ --_box-shadow: var(--theme-form-focus-box-shadow);
131
123
  }
132
124
 
133
125
  /* Sizes */
@@ -138,7 +130,7 @@ const isChecked = computed(() => {
138
130
  --_checkbox-size: 24px;
139
131
  }
140
132
  &.normal {
141
- --_checkbox-size: 30px;
133
+ --_checkbox-size: 34px;
142
134
  }
143
135
  &.medium {
144
136
  --_checkbox-size: 40px;
@@ -152,51 +144,34 @@ const isChecked = computed(() => {
152
144
  display: grid;
153
145
  grid-area: element-stack;
154
146
  background-color: var(--theme-form-checkbox-bg);
155
-
156
- transform: translate(-2px, 0);
147
+ border-radius: 100%;
157
148
  place-content: center;
158
149
  position: relative;
150
+ height: var(--_checkbox-size);
151
+ width: var(--_checkbox-size);
159
152
  z-index: -1;
160
153
 
161
- div {
154
+ .icon {
162
155
  grid-area: stack;
163
- background-color: hsl(from var(--theme-form-radio-symbol) h s 50%);
164
- width: calc(var(--_checkbox-size) - (var(--_padding) * 2));
165
- height: calc(var(--_checkbox-size) - var(--_padding) * 2);
166
- border: 1px solid var(--theme-form-input-border);
167
- border-radius: 50%;
168
- opacity: 0;
169
- transition: opacity 0.2s ease-in-out;
170
-
171
- &.checked {
172
- opacity: 1;
173
- }
156
+ color: var(--theme-form-radio-symbol);
157
+ height: var(--_checkbox-size);
158
+ width: var(--_checkbox-size);
159
+ box-shadow: var(--_box-shadow);
160
+ outline: 1px solid yellow;
174
161
  }
175
162
  }
176
163
 
177
164
  .input-radiobutton-core {
178
165
  grid-area: element-stack;
179
- border: var(--_border-width) solid var(--theme-form-input-border);
180
- height: var(--_checkbox-size);
181
- width: var(--_checkbox-size);
182
-
183
- transition: all 0.2s ease-in-out;
184
-
185
- &.with-decorator {
186
- appearance: none;
187
- margin: 0;
188
- overflow: hidden;
189
- opacity: 0;
190
- }
166
+ appearance: none;
167
+ margin: 0;
168
+ overflow: hidden;
169
+ opacity: 0;
191
170
 
192
171
  &:hover {
193
172
  cursor: pointer;
194
173
  }
195
174
 
196
- /* &:focus-visible {
197
- border-radius: var(--input-border-radius);
198
- } */
199
-
200
175
  &:focus {
201
176
  border: var(--_border-width) solid var(--theme-form-input-border);
202
177
  outline: var(--_outline-width) solid hsl(from var(--theme-form-input-outline) h s 50%);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "srcdev-nuxt-forms",
3
3
  "type": "module",
4
- "version": "2.1.4",
4
+ "version": "2.1.5",
5
5
  "main": "nuxt.config.ts",
6
6
  "scripts": {
7
7
  "clean": "rm -rf .nuxt && rm -rf .output && rm -rf .playground/.nuxt && rm -rf .playground/.output",
@@ -1,56 +0,0 @@
1
- {
2
- "username": {
3
- "pattern": "^[a-zA-Z0-9_\\-'.]{8,20}$",
4
- "minlength": 8,
5
- "maxlength": 20,
6
- "hint": "Uppercase letters and numbers, with ,.- and space"
7
- },
8
- "usernameWeak": {
9
- "pattern": "^[a-zA-Z0-9]{6,20}$",
10
- "minlength": 6,
11
- "maxlength": 20,
12
- "hint": "Mixed case letters"
13
- },
14
- "password": {
15
- "pattern": "^(?=.*\\d)(?=.*[A-Z])(?=.*[a-z])(?=.*[^\\w\\d\\s:])([^\\s]){8,16}$",
16
- "minlength": 8,
17
- "maxlength": 20,
18
- "hint": "!Pa55word"
19
- },
20
- "passwordWeak": {
21
- "pattern": "^[a-zA-Z0-9]{6,20}$",
22
- "minlength": 6,
23
- "maxlength": 20,
24
- "hint": "password"
25
- },
26
- "emailaddress": {
27
- "pattern": "^(?!@)((?!([\\.]))([\\w\\.\\-\\+']{1,}))?((@)([\\w\\-]{1,})+((\\.)([\\w]{2,}))+)$",
28
- "minlength": 7,
29
- "maxlength": 255,
30
- "hint": "you@your-email.com"
31
- },
32
- "url": {
33
- "pattern": "^((http|https)://){1}([\\w\\-]{2,}(\\.))+([\\w]{2,})((/))*((/)[\\w\\-]{1,})*((/)[\\w]{1,}(/))*(/)*$",
34
- "minlength": 13,
35
- "maxlength": 255,
36
- "hint": "https://your-website.com"
37
- },
38
- "telephone": {
39
- "pattern": "^(0|\\+44|\\+353)([\\d\\- ]{10})$",
40
- "minlength": 11,
41
- "maxlength": 14,
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"
55
- }
56
- }
@@ -1,6 +0,0 @@
1
- import en from './en.json'
2
-
3
- export const validationConfig: any = {
4
- 'en-GB': en,
5
- }
6
- export default validationConfig