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.
Files changed (64) hide show
  1. package/.prettierrc +2 -1
  2. package/LICENSE +21 -0
  3. package/assets/styles/forms/index.css +1 -0
  4. package/assets/styles/forms/themes/_error.css +9 -0
  5. package/assets/styles/forms/themes/_ghost.css +11 -0
  6. package/assets/styles/forms/themes/_primary.css +11 -1
  7. package/assets/styles/forms/themes/_secondary.css +13 -0
  8. package/assets/styles/forms/themes/_success.css +12 -0
  9. package/assets/styles/forms/themes/_tertiary.css +11 -0
  10. package/assets/styles/forms/themes/_warning.css +11 -0
  11. package/assets/styles/forms/themes/index.css +5 -0
  12. package/assets/styles/forms/utils/_a11y.css +5 -0
  13. package/assets/styles/forms/utils/index.css +1 -0
  14. package/assets/styles/forms/variables/_theme.css +56 -2
  15. package/assets/styles/variables/colors/_gray.css +1 -0
  16. package/assets/styles/variables/colors/_orange.css +1 -1
  17. package/assets/styles/variables/colors/_red.css +1 -1
  18. package/components/forms/c12/prop-validators/index.ts +13 -0
  19. package/components/forms/c12/utils.ts +14 -0
  20. package/components/forms/c12/validation-patterns/en.json +13 -1
  21. package/components/forms/form-errors/InputError.vue +132 -0
  22. package/components/forms/input-button/InputButtonCore.vue +370 -0
  23. package/components/forms/input-button/variants/InputButtonConfirm.vue +78 -0
  24. package/components/forms/input-button/variants/InputButtonSubmit.vue +74 -0
  25. package/components/forms/input-checkbox/InputCheckboxCore.vue +407 -0
  26. package/components/forms/input-checkbox/InputCheckboxWithLabel.vue +125 -0
  27. package/components/forms/input-checkbox/variants/MultipleCheckboxes.vue +194 -0
  28. package/components/forms/input-checkbox/variants/SingleCheckbox.vue +157 -0
  29. package/components/forms/input-radio/InputRadioCore.vue +226 -0
  30. package/components/forms/input-radio/InputRadioWithLabel.vue +118 -0
  31. package/components/forms/input-radio/variants/MultipleRadio.vue +183 -0
  32. package/components/forms/input-radio/variants/SingleRadio.vue +131 -0
  33. package/components/forms/input-range/InputRangeCore.vue +171 -0
  34. package/components/forms/input-range/variants/InputRangeDefault.vue +131 -0
  35. package/components/forms/input-text/InputTextCore.vue +115 -79
  36. package/components/forms/input-text/variants/material/InputEmailMaterial.vue +72 -0
  37. package/components/forms/input-text/variants/material/InputPasswordMaterial.vue +114 -0
  38. package/components/forms/input-text/variants/material/InputTextMaterial.vue +68 -0
  39. package/components/forms/input-text/variants/material/InputTextMaterialCore.vue +313 -0
  40. package/components/forms/input-textarea/InputTextareaCore.vue +170 -0
  41. package/components/forms/input-textarea/variants/material/InputTextareaMaterial.vue +75 -0
  42. package/components/forms/input-textarea/variants/material/InputTextareaMaterialCore.vue +290 -0
  43. package/components/forms/ui/FormField.vue +7 -2
  44. package/components/forms/ui/FormWrapper.vue +2 -2
  45. package/components/ui/content-grid/ContentGrid.vue +85 -0
  46. package/composables/useErrorMessages.ts +21 -9
  47. package/composables/useFormControl.ts +171 -41
  48. package/layouts/default.vue +28 -3
  49. package/nuxt.config.ts +26 -3
  50. package/package.json +9 -6
  51. package/pages/forms/examples/buttons/index.vue +155 -0
  52. package/pages/forms/examples/material/text-fields.vue +372 -0
  53. package/pages/index.vue +2 -70
  54. package/pages/limit-text.vue +43 -0
  55. package/server/api/places/list.get.ts +23 -0
  56. package/server/api/textFields.post.ts +37 -0
  57. package/server/api/utils/index.get.ts +20 -0
  58. package/server/data/places/cities.json +37 -0
  59. package/server/data/places/countries.json +55 -0
  60. package/server/data/utils/title.json +49 -0
  61. package/types/types.forms.ts +38 -13
  62. package/types/types.places.ts +8 -0
  63. package/components/forms/input-text/InputTextField.vue +0 -22
  64. package/components/forms/input-text/variants/InputTextMaterial.vue +0 -192
package/.prettierrc CHANGED
@@ -1,4 +1,5 @@
1
1
  {
2
2
  "semi": true,
3
- "singleQuote": true
3
+ "singleQuote": true,
4
+ "printWidth": 200
4
5
  }
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.
@@ -1,2 +1,3 @@
1
1
  @import './variables/_theme.css';
2
2
  @import './themes/index.css';
3
+ @import './utils/index.css';
@@ -1,3 +1,12 @@
1
1
  :where(html) {
2
2
  --theme-error: var(--red-7);
3
+ --theme-form-error: var(--red-8);
4
+ --theme-form-error-border: var(--red-2);
5
+ --theme-form-error-border-hover: var(--red-0);
6
+ --theme-form-error-outline: var(--red-9);
7
+ --theme-form-error-outline-hover: var(--red-9);
8
+ --theme-form-error-bg: var(--red-9);
9
+ --theme-form-error-bg-hover: var(--red-2);
10
+ --theme-form-error-color: var(--red-1);
11
+ --theme-form-error-color-hover: var(--red-9);
3
12
  }
@@ -0,0 +1,11 @@
1
+ :where(html) {
2
+ --theme-form-ghost: var(--gray-8);
3
+ --theme-form-ghost-border: transparent;
4
+ --theme-form-ghost-border-hover: var(--gray-0);
5
+ --theme-form-ghost-outline: transparent;
6
+ --theme-form-ghost-outline-hover: var(--gray-11);
7
+ --theme-form-ghost-bg: transparent;
8
+ --theme-form-ghost-bg-hover: var(--gray-2);
9
+ --theme-form-ghost-color: var(--gray-11);
10
+ --theme-form-ghost-color-hover: var(--gray-11);
11
+ }
@@ -1,3 +1,13 @@
1
1
  :where(html) {
2
- --theme-primary: var(--blue-8);
2
+ --theme-form-primary: var(--blue-8);
3
+ --theme-form-primary-border: var(--blue-2);
4
+ --theme-form-primary-border-hover: var(--blue-0);
5
+ --theme-form-primary-outline: var(--blue-11);
6
+ --theme-form-primary-outline-hover: var(--blue-11);
7
+ --theme-form-primary-bg: var(--blue-6);
8
+ --theme-form-primary-bg-hover: var(--blue-2);
9
+ --theme-form-primary-color: var(--blue-1);
10
+ --theme-form-primary-color-hover: var(--blue-11);
11
+ --theme-form-primary-focus: var(--blue-6);
12
+ --theme-form-primary-radio-color-bg: var(--gray-00);
3
13
  }
@@ -0,0 +1,13 @@
1
+ :where(html) {
2
+ --theme-form-secondary: var(--gray-8);
3
+ --theme-form-secondary-border: var(--gray-2);
4
+ --theme-form-secondary-border-hover: var(--gray-0);
5
+ --theme-form-secondary-outline: var(--gray-8);
6
+ --theme-form-secondary-outline-hover: var(--gray-8);
7
+ --theme-form-secondary-bg: var(--gray-11);
8
+ --theme-form-secondary-bg-hover: var(--gray-2);
9
+ --theme-form-secondary-color: var(--gray-1);
10
+ --theme-form-secondary-color-hover: var(--gray-11);
11
+ --theme-form-secondary-focus: var(--blue-6);
12
+ --theme-form-secondary-radio-color-bg: var(--gray-00);
13
+ }
@@ -0,0 +1,12 @@
1
+ :where(html) {
2
+ --theme-success: var(--green-7);
3
+ --theme-form-success: var(--green-8);
4
+ --theme-form-success-border: var(--green-2);
5
+ --theme-form-success-border-hover: var(--green-0);
6
+ --theme-form-success-outline: var(--green-9);
7
+ --theme-form-success-outline-hover: var(--green-9);
8
+ --theme-form-success-bg: var(--green-9);
9
+ --theme-form-success-bg-hover: var(--green-2);
10
+ --theme-form-success-color: var(--green-1);
11
+ --theme-form-success-color-hover: var(--green-9);
12
+ }
@@ -0,0 +1,11 @@
1
+ :where(html) {
2
+ --theme-form-tertiary: var(--gray-8);
3
+ --theme-form-tertiary-border: var(--gray-2);
4
+ --theme-form-tertiary-border-hover: var(--gray-2);
5
+ --theme-form-tertiary-outline: var(--gray-8);
6
+ --theme-form-tertiary-outline-hover: var(--gray-8);
7
+ --theme-form-tertiary-bg: var(--gray-1);
8
+ --theme-form-tertiary-bg-hover: var(--gray-11);
9
+ --theme-form-tertiary-color: var(--gray-9);
10
+ --theme-form-tertiary-color-hover: var(--gray-2);
11
+ }
@@ -0,0 +1,11 @@
1
+ :where(html) {
2
+ --theme-form-warning: var(--orange-8);
3
+ --theme-form-warning-border: var(--orange-2);
4
+ --theme-form-warning-border-hover: var(--orange-0);
5
+ --theme-form-warning-outline: var(--orange-11);
6
+ --theme-form-warning-outline-hover: var(--orange-11);
7
+ --theme-form-warning-bg: var(--orange-6);
8
+ --theme-form-warning-bg-hover: var(--orange-2);
9
+ --theme-form-warning-color: var(--orange-1);
10
+ --theme-form-warning-color-hover: var(--orange-11);
11
+ }
@@ -1,2 +1,7 @@
1
1
  @import './_primary.css';
2
+ @import './_secondary.css';
3
+ @import './_tertiary.css';
4
+ @import './_ghost.css';
2
5
  @import './_error.css';
6
+ @import './_success.css';
7
+ @import './_warning.css';
@@ -0,0 +1,5 @@
1
+ :where(html) {
2
+ --focus-visible-colour: #4169e1;
3
+ --focus-visible-box-shadow: 1px 1px 8px 1px var(--focus-visible-colour);
4
+ --focus-visible-outline: 2px solid var(--focus-visible-colour);
5
+ }
@@ -0,0 +1 @@
1
+ @import './_a11y.css';
@@ -7,6 +7,60 @@
7
7
  --input-border-width-default: 2px;
8
8
  --input-border-width-thick: 3px;
9
9
 
10
- --font-family: futura-pt, Seravek, 'Gill Sans Nova', Ubuntu, Calibri,
11
- 'DejaVu Sans', source-sans-pro, sans-serif;
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;
16
+
17
+ --theme-form-button-font-size-x-small: 14px;
18
+ --theme-form-button-font-size-small: 14px;
19
+ --theme-form-button-font-size-normal: 16px;
20
+ --theme-form-button-font-size-medium: 18px;
21
+ --theme-form-button-font-size-large: 20px;
22
+
23
+ /*
24
+ * Button Padding
25
+ */
26
+
27
+ --theme-form-button-padding-block-x-small: 6px;
28
+ --theme-form-button-padding-block-small: 8px;
29
+ --theme-form-button-padding-block-normal: 10px;
30
+ --theme-form-button-padding-block-medium: 12px;
31
+ --theme-form-button-padding-block-large: 12px;
32
+
33
+ --theme-form-button-padding-inline-x-small: 12px;
34
+ --theme-form-button-padding-inline-small: 16px;
35
+ --theme-form-button-padding-inline-normal: 20px;
36
+ --theme-form-button-padding-inline-medium: 22px;
37
+ --theme-form-button-padding-inline-large: 24px;
38
+
39
+ /*
40
+ * Button Icon Sizes and Gap
41
+ */
42
+
43
+ --theme-form-button-padding-inline-icon-only-x-small: 4px;
44
+ --theme-form-button-padding-inline-icon-only-small: 6px;
45
+ --theme-form-button-padding-inline-icon-only-normal: 8px;
46
+ --theme-form-button-padding-inline-icon-only-medium: 10px;
47
+ --theme-form-button-padding-inline-icon-only-large: 12px;
48
+
49
+ --theme-form-button-padding-block-icon-only-x-small: 4px;
50
+ --theme-form-button-padding-block-icon-only-small: 4px;
51
+ --theme-form-button-padding-block-icon-only-normal: 6px;
52
+ --theme-form-button-padding-block-icon-only-medium: 8px;
53
+ --theme-form-button-padding-block-icon-only-large: 10px;
54
+
55
+ --theme-form-button-icon-size-x-small: 18px;
56
+ --theme-form-button-icon-size-small: 18px;
57
+ --theme-form-button-icon-size-normal: 18px;
58
+ --theme-form-button-icon-size-medium: 20px;
59
+ --theme-form-button-icon-size-large: 22px;
60
+
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);
12
66
  }
@@ -1,4 +1,5 @@
1
1
  :where(html) {
2
+ --gray-00: #ffffff;
2
3
  --gray-0: #f8f9fa;
3
4
  --gray-1: #f1f3f5;
4
5
  --gray-2: #e9ecef;
@@ -5,7 +5,7 @@
5
5
  --orange-3: #ffc078;
6
6
  --orange-4: #ffa94d;
7
7
  --orange-5: #ff922b;
8
- --orange-6: #fd7e14;
8
+ --orange-6: #ff7400;
9
9
  --orange-7: #f76707;
10
10
  --orange-8: #e8590c;
11
11
  --orange-9: #d9480f;
@@ -8,7 +8,7 @@
8
8
  --red-6: #fa5252;
9
9
  --red-7: #f03e3e;
10
10
  --red-8: #e03131;
11
- --red-9: #c92a2a;
11
+ --red-9: #ff0b0b;
12
12
  --red-10: #b02525;
13
13
  --red-11: #962020;
14
14
  --red-12: #7d1a1a;
@@ -0,0 +1,13 @@
1
+ export const propValidators = {
2
+ size: ['x-small', 'small', 'normal', 'medium', 'large'],
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'],
11
+ };
12
+
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 };
@@ -24,7 +24,7 @@
24
24
  "hint": "password"
25
25
  },
26
26
  "emailaddress": {
27
- "pattern": "^(?!@)((?!([\\.]))([\\w\\.\\-\\+']{1,}))?((@)([\\w\\-]{2,})+((\\.)([\\w]{2,}))+)$",
27
+ "pattern": "^(?!@)((?!([\\.]))([\\w\\.\\-\\+']{1,}))?((@)([\\w\\-]{1,})+((\\.)([\\w]{2,}))+)$",
28
28
  "minlength": 7,
29
29
  "maxlength": 255,
30
30
  "hint": "you@your-email.com"
@@ -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>