srcdev-nuxt-forms 2.0.1 → 2.0.3

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.
@@ -1,3 +1,4 @@
1
+ import { ref, reactive, toRaw, type Ref } from 'vue';
1
2
  import { z, ZodError } from 'zod';
2
3
  import type { IFormFieldStateObj, ApiErrorResponse } from '@/types/types.forms';
3
4
 
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "srcdev-nuxt-forms",
3
3
  "type": "module",
4
- "version": "2.0.1",
4
+ "version": "2.0.3",
5
+ "main": "./nuxt.config.ts",
5
6
  "scripts": {
6
7
  "reinstall": "rm -rf node_modules && npm install",
7
8
  "dev": "nuxi dev .playground",
@@ -0,0 +1,216 @@
1
+ export interface IValidationPatterns {
2
+ pattern: string;
3
+ minlength: string;
4
+ maxlength: string;
5
+ hint: string;
6
+ }
7
+
8
+ export interface IOptionsConfig {
9
+ id: string;
10
+ name: string;
11
+ value: string;
12
+ label: string;
13
+ }
14
+
15
+ export interface IFormMultipleOptions {
16
+ data: IOptionsConfig[];
17
+ total: number;
18
+ skip: number;
19
+ limit: number;
20
+ }
21
+
22
+ export interface IOptionsValueArr {
23
+ [key: string]: string | boolean | number | URL | object;
24
+ }
25
+
26
+ export interface IFieldsInitialState {
27
+ [key: string]: null | string | boolean | number | URL | object | IOptionsValueArr[];
28
+ }
29
+
30
+ export type TFieldsInitialState = {
31
+ [key: string]: null | string | boolean | number | URL | object | IOptionsValueArr[];
32
+ };
33
+
34
+ export interface IValidityState {
35
+ badInput: boolean;
36
+ customError: boolean;
37
+ patternMismatch: boolean;
38
+ rangeOverflow: boolean;
39
+ rangeUnderflow: boolean;
40
+ stepMismatch: boolean;
41
+ tooLong: boolean;
42
+ tooShort: boolean;
43
+ typeMismatch: boolean;
44
+ valid: boolean;
45
+ valueMissing: boolean;
46
+ }
47
+
48
+ export interface IValidityStateArr {
49
+ [key: string]: {
50
+ badInput: boolean;
51
+ customError: boolean;
52
+ patternMismatch: boolean;
53
+ rangeOverflow: boolean;
54
+ rangeUnderflow: boolean;
55
+ stepMismatch: boolean;
56
+ tooLong: boolean;
57
+ tooShort: boolean;
58
+ typeMismatch: boolean;
59
+ valid: boolean;
60
+ valueMissing: boolean;
61
+ };
62
+ }
63
+
64
+ export interface IFormFieldsState {
65
+ [key: string]: boolean;
66
+ }
67
+
68
+ export interface ICustomErrorMessage {
69
+ useCustomError: boolean;
70
+ message: string;
71
+ }
72
+
73
+ export interface InpuTextC12 {
74
+ label: string;
75
+ placeholder: string;
76
+ errorMessage: string;
77
+ }
78
+
79
+ export interface IErrorMessagesArr {
80
+ [x: string]: ICustomErrorMessage;
81
+ }
82
+
83
+ export interface IFormFieldC12 {
84
+ label: string;
85
+ placeholder: string;
86
+ errorMessage: string;
87
+ useCustomError: boolean;
88
+ customErrors: null | string | string[];
89
+ isValid: boolean;
90
+ isDirty: boolean;
91
+ type: string;
92
+ previousValue: null | string | boolean | number | URL | object;
93
+ }
94
+
95
+ export interface IFormFieldsC12 {
96
+ [x: string]: IFormFieldC12;
97
+ }
98
+
99
+ export interface IFormFieldState {
100
+ isValid: boolean;
101
+ isDirty: boolean;
102
+ previousValue: null | string | boolean | number | URL | object;
103
+ }
104
+
105
+ export interface IFormFieldStateObj {
106
+ [x: string]: IFormFieldState;
107
+ }
108
+
109
+ export interface IFormData {
110
+ [x: string]: string | boolean | number | URL | object;
111
+ data: IFieldsInitialState;
112
+ validityState: IFormFieldsState;
113
+ dirtyFields: IFormFieldsState;
114
+ focusedField: string;
115
+ isPending: boolean;
116
+ errorCount: number;
117
+ errorMessages: IErrorMessagesArr;
118
+ formFieldsC12: IFormFieldsC12;
119
+ formIsValid: boolean;
120
+ submitAttempted: boolean;
121
+ submitDisabled: boolean;
122
+ submitSuccess: boolean;
123
+ displayErrorMessages: boolean;
124
+ }
125
+
126
+ export interface IApiErrorMessages {
127
+ [x: string]: string;
128
+ }
129
+
130
+ // New types
131
+
132
+ export interface C12nInputText {
133
+ type: string;
134
+ id: string;
135
+ name: string;
136
+ label: string;
137
+ placeholder: string;
138
+ errorMessage: string;
139
+ fieldHasError: boolean;
140
+ required: boolean;
141
+ styleClassPassthrough: string[];
142
+ }
143
+
144
+ export interface C12nMultipleCheckboxes {
145
+ id: string;
146
+ name: string;
147
+ label: string;
148
+ legend: string;
149
+ placeholder: string;
150
+ errorMessage: string;
151
+ fieldHasError: boolean;
152
+ required: boolean;
153
+ styleClassPassthrough: string[];
154
+ }
155
+
156
+ export interface C12nInputCheckboxWithLabel {
157
+ id: string;
158
+ name: string;
159
+ required: string;
160
+ label: string;
161
+ placeholder: string;
162
+ errorMessage: string | string[];
163
+ fieldHasError: boolean;
164
+ styleClassPassthrough: string[];
165
+ }
166
+
167
+ export interface C12nInputRange {
168
+ id: string;
169
+ name: string;
170
+ label: string;
171
+ min: number;
172
+ max: number;
173
+ step: number;
174
+ placeholder: string;
175
+ errorMessage: string;
176
+ fieldHasError: boolean;
177
+ required: boolean;
178
+ styleClassPassthrough: string[];
179
+ }
180
+
181
+ export interface C12nInputTextCore {
182
+ type: string;
183
+ id: string;
184
+ name: string;
185
+ label: string;
186
+ placeholder: string;
187
+ errorMessage: string;
188
+ fieldHasError: boolean;
189
+ required: boolean;
190
+ }
191
+
192
+ export interface InputTextWithLabel {
193
+ type: string;
194
+ id: string;
195
+ name: string;
196
+ label: string;
197
+ placeholder: string;
198
+ errorMessage: string;
199
+ fieldHasError: boolean;
200
+ required: boolean;
201
+ styleClassPassthrough: string[];
202
+ deepCssClassPassthrough: string[];
203
+ }
204
+
205
+ export interface ApiErrorResponse {
206
+ url: string;
207
+ statusCode: number;
208
+ statusMessage: string;
209
+ message: string;
210
+ stack: string;
211
+ data: {
212
+ errors: {
213
+ [key: string]: string | string[]; // Index signature for dynamic keys
214
+ };
215
+ };
216
+ }
@@ -0,0 +1,21 @@
1
+ import type { IFieldsInitialState, IFormFieldsState, IFormFieldsC12, IFormFieldC12, IApiErrorMessages, ICustomErrorMessage, IErrorMessagesArr } from '@/types/types.forms';
2
+
3
+ export interface IZodeFormControl {
4
+ [x: string]: string | boolean | number | URL | object;
5
+ data: IFieldsInitialState;
6
+ validityState: IFormFieldsState;
7
+ dirtyFields: IFormFieldsState;
8
+ focusedField: string;
9
+ isDisabled: boolean;
10
+ isPending: boolean;
11
+ errorCount: number;
12
+ errorMessages: IErrorMessagesArr;
13
+ formFieldsC12: IFormFieldsC12;
14
+ formIsValid: boolean;
15
+ submitAttempted: boolean;
16
+ submitDisabled: boolean;
17
+ submitSuccess: boolean;
18
+ displayErrorMessages: boolean;
19
+ displayLoader: boolean;
20
+ submitSuccessful: boolean;
21
+ }