@websolutespa/bom-mixer-forms 0.2.2 → 0.3.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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @websolutespa/bom-mixer-forms
2
2
 
3
+ ## 0.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Updating: next 13.
8
+
3
9
  ## 0.2.2
4
10
 
5
11
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -1,299 +1,299 @@
1
1
  import { IEquatable, IOption } from '@websolutespa/bom-core';
2
2
  import { DependencyList } from 'react';
3
3
 
4
- declare class EventEmitter {
5
- protected events_: {
6
- [key: string]: ((...args: any[]) => any)[];
7
- };
8
- on(event: string, listener: (...args: any[]) => any): void;
9
- off(event: string, listener: (...args: any[]) => any): void;
10
- emit(event: string, ...args: any[]): void;
11
- once(event: string, listener: (...args: any[]) => any): void;
4
+ declare class EventEmitter {
5
+ protected events_: {
6
+ [key: string]: ((...args: any[]) => any)[];
7
+ };
8
+ on(event: string, listener: (...args: any[]) => any): void;
9
+ off(event: string, listener: (...args: any[]) => any): void;
10
+ emit(event: string, ...args: any[]): void;
11
+ once(event: string, listener: (...args: any[]) => any): void;
12
12
  }
13
13
 
14
- declare class FormAbstractCollection<T extends FormControls> extends FormAbstract {
15
- controls_: T;
16
- constructor(controls: T, validators?: (FormValidator | FormValidator[]));
17
- initControl_(controlOrValue: FormAbstract | any, key: any): FormAbstract;
18
- protected setInitialOptions(options?: FormOptions): void;
19
- protected checkAsyncPropState_(key: string, option?: FormActivator, root?: FormCollection): Promise<boolean>;
20
- updateState_(): void;
21
- revalidate_(): Promise<void>;
22
- protected validate_(root?: FormCollection): Promise<void>;
23
- reset(): void;
24
- patch(value: any): void;
25
- get(key: keyof T): FormAbstract;
26
- set(control: FormAbstract, key: keyof T): void;
27
- add(control: FormAbstract, key: keyof T): void;
28
- remove(control: FormAbstract): void;
29
- removeKey(key: keyof T): void;
30
- addValidators(...validators: FormValidator[]): void;
31
- replaceValidators(...validators: FormValidator[]): void;
32
- clearValidators(): void;
33
- protected forEach_(callback: Function): void;
34
- protected reduce_(callback: Function, result: any): any;
35
- protected all_(key: (keyof FormAbstract), value: any): boolean;
36
- protected any_(key: (keyof FormAbstract), value: any): boolean;
37
- protected map_(): FormAbstract[];
38
- get controls(): T;
39
- set controls(controls: T);
40
- set disabled(disabled: boolean);
41
- set readonly(readonly: boolean);
42
- set hidden(hidden: boolean);
43
- set submitted(submitted: boolean);
44
- set touched(touched: boolean);
45
- get value(): {
46
- [key: string]: any;
47
- };
48
- set value(value: {
49
- [key: string]: any;
50
- });
51
- get errors(): {
52
- [key: string]: any;
53
- };
54
- set errors(errors: {
55
- [key: string]: any;
56
- });
14
+ declare class FormAbstractCollection<T extends FormControls> extends FormAbstract {
15
+ controls_: T;
16
+ constructor(controls: T, validators?: (FormValidator | FormValidator[]));
17
+ initControl_(controlOrValue: FormAbstract | any, key: any): FormAbstract;
18
+ protected setInitialOptions(options?: FormOptions): void;
19
+ protected checkAsyncPropState_(key: string, option?: FormActivator, root?: FormCollection): Promise<boolean>;
20
+ updateState_(): void;
21
+ revalidate_(): Promise<void>;
22
+ protected validate_(root?: FormCollection): Promise<void>;
23
+ reset(): void;
24
+ patch(value: any): void;
25
+ get(key: keyof T): FormAbstract;
26
+ set(control: FormAbstract, key: keyof T): void;
27
+ add(control: FormAbstract, key: keyof T): void;
28
+ remove(control: FormAbstract): void;
29
+ removeKey(key: keyof T): void;
30
+ addValidators(...validators: FormValidator[]): void;
31
+ replaceValidators(...validators: FormValidator[]): void;
32
+ clearValidators(): void;
33
+ protected forEach_(callback: Function): void;
34
+ protected reduce_(callback: Function, result: any): any;
35
+ protected all_(key: (keyof FormAbstract), value: any): boolean;
36
+ protected any_(key: (keyof FormAbstract), value: any): boolean;
37
+ protected map_(): FormAbstract[];
38
+ get controls(): T;
39
+ set controls(controls: T);
40
+ set disabled(disabled: boolean);
41
+ set readonly(readonly: boolean);
42
+ set hidden(hidden: boolean);
43
+ set submitted(submitted: boolean);
44
+ set touched(touched: boolean);
45
+ get value(): {
46
+ [key: string]: any;
47
+ };
48
+ set value(value: {
49
+ [key: string]: any;
50
+ });
51
+ get errors(): {
52
+ [key: string]: any;
53
+ };
54
+ set errors(errors: {
55
+ [key: string]: any;
56
+ });
57
57
  }
58
58
 
59
- declare class FormArray extends FormAbstractCollection<FormAbstract[]> {
60
- constructor(controls?: FormAbstract[], validators?: FormValidator | FormValidator[], initialOptions?: FormOptions);
61
- forEach_(callback: (control: FormAbstract, key: number) => any): void;
62
- map_(): FormAbstract[];
63
- get value(): any[];
64
- get length(): number;
65
- protected init(control: FormAbstract, key: number): void;
66
- set(control: FormAbstract, key: number): void;
67
- add(control: FormAbstract, key: number): void;
68
- push(control: FormAbstract): void;
69
- insert(control: FormAbstract, key: number): void;
70
- remove(control: FormAbstract): void;
71
- removeKey(key: number): void;
72
- at(key: number): FormAbstract;
73
- }
59
+ declare class FormArray extends FormAbstractCollection<FormAbstract[]> {
60
+ constructor(controls?: FormAbstract[], validators?: FormValidator | FormValidator[], initialOptions?: FormOptions);
61
+ forEach_(callback: (control: FormAbstract, key: number) => any): void;
62
+ map_(): FormAbstract[];
63
+ get value(): any[];
64
+ get length(): number;
65
+ protected init(control: FormAbstract, key: number): void;
66
+ set(control: FormAbstract, key: number): void;
67
+ add(control: FormAbstract, key: number): void;
68
+ push(control: FormAbstract): void;
69
+ insert(control: FormAbstract, key: number): void;
70
+ remove(control: FormAbstract): void;
71
+ removeKey(key: number): void;
72
+ at(key: number): FormAbstract;
73
+ }
74
74
  declare function formArray(controls?: FormAbstract[], validators?: FormValidator | FormValidator[]): FormArray;
75
75
 
76
- declare class FormControl extends FormAbstract {
77
- constructor(value?: any, validators?: FormValidator | FormValidator[], initialOptions?: FormOptions);
78
- }
76
+ declare class FormControl extends FormAbstract {
77
+ constructor(value?: any, validators?: FormValidator | FormValidator[], initialOptions?: FormOptions);
78
+ }
79
79
  declare function formControl(value?: any, validators?: FormValidator | FormValidator[]): FormControl;
80
80
 
81
- declare class FormGroup extends FormAbstractCollection<{
82
- [key: string]: FormAbstract;
83
- }> {
84
- constructor(controls?: {
85
- [key: string]: FormAbstract | any;
86
- }, validators?: FormValidator | FormValidator[], initialOptions?: FormOptions);
87
- }
88
- declare function formGroup(controls?: {
89
- [key: string]: FormAbstract | any;
81
+ declare class FormGroup extends FormAbstractCollection<{
82
+ [key: string]: FormAbstract;
83
+ }> {
84
+ constructor(controls?: {
85
+ [key: string]: FormAbstract | any;
86
+ }, validators?: FormValidator | FormValidator[], initialOptions?: FormOptions);
87
+ }
88
+ declare function formGroup(controls?: {
89
+ [key: string]: FormAbstract | any;
90
90
  }, validators?: FormValidator | FormValidator[]): FormGroup;
91
91
 
92
- type IControlParam = {
93
- uid: number;
94
- control: FormControl;
95
- };
96
- type IFormOption = {
97
- id: IEquatable;
98
- name: string;
99
- };
100
- type FormOptions = {
101
- schema?: ControlType;
102
- name?: string;
103
- label?: string;
104
- value?: string;
105
- placeholder?: string;
106
- required?: FormActivator;
107
- hidden?: FormActivator;
108
- disabled?: FormActivator;
109
- readonly?: FormActivator;
110
- options?: IOption[];
111
- optionsExtra?: {
112
- asEquatable: boolean;
113
- };
114
- };
115
- type ValidationError = {
116
- [key: string]: any;
117
- };
118
- type FormControls = {
119
- [key: string]: FormAbstract;
120
- } | FormAbstract[];
121
- type FormCollection = FormAbstractCollection<FormControls>;
122
- type FormActivator = boolean | ((value: any, rootValue: any, control?: FormAbstract, root?: FormCollection) => boolean | Promise<boolean>);
123
- type FormValidator = (value: any, rootValue: any, control?: FormAbstract, root?: FormCollection) => null | ValidationError;
124
- type FormAsyncValidator = (value: any, rootValue: any, control?: FormAbstract, root?: FormCollection) => Promise<null | ValidationError>;
125
- type FormFlags = {
126
- [key: string]: boolean;
127
- };
128
- type FormErrors = {
129
- [key: string]: any;
130
- };
131
- type FormValidationError = {
132
- key: string;
133
- value: any;
134
- };
135
- type FormValidationErrors = FormValidationError[];
136
- type FormState<T> = {
137
- value: T | null;
138
- flags: FormFlags;
139
- errors: FormValidationErrors;
140
- };
141
- type ControlType = 'group' | 'array' | string;
142
- type IFormBuilderControlSchema = {
143
- schema: ControlType;
144
- name?: string;
145
- label?: string;
146
- value?: string;
147
- placeholder?: string;
148
- required?: FormActivator;
149
- hidden?: FormActivator;
150
- disabled?: FormActivator;
151
- readonly?: FormActivator;
152
- options?: IOption[];
153
- optionsExtra?: {
154
- asEquatable: boolean;
155
- };
156
- validators?: FormValidator | FormValidator[];
157
- children?: IFormBuilderSchema;
158
- };
159
- type IFormBuilderGroupSchema = {
160
- [key: string]: IFormBuilderControlSchema;
161
- };
162
- type IFormBuilderArraySchema = IFormBuilderControlSchema[];
163
- type IFormBuilderGroupValues = {
164
- [key: string]: FormGroup | FormArray | FormControl;
165
- };
166
- type IFormBuilderSchema = IFormBuilderGroupSchema | IFormBuilderArraySchema;
167
- type StateValue = StateValue[] | {
168
- [key: string]: StateValue;
92
+ type IControlParam = {
93
+ uid: number;
94
+ control: FormControl;
95
+ };
96
+ type IFormOption = {
97
+ id: IEquatable;
98
+ name: string;
99
+ };
100
+ type FormOptions = {
101
+ schema?: ControlType;
102
+ name?: string;
103
+ label?: string;
104
+ value?: string;
105
+ placeholder?: string;
106
+ required?: FormActivator;
107
+ hidden?: FormActivator;
108
+ disabled?: FormActivator;
109
+ readonly?: FormActivator;
110
+ options?: IOption[];
111
+ optionsExtra?: {
112
+ asEquatable: boolean;
113
+ };
114
+ };
115
+ type ValidationError = {
116
+ [key: string]: any;
117
+ };
118
+ type FormControls = {
119
+ [key: string]: FormAbstract;
120
+ } | FormAbstract[];
121
+ type FormCollection = FormAbstractCollection<FormControls>;
122
+ type FormActivator = boolean | ((value: any, rootValue: any, control?: FormAbstract, root?: FormCollection) => boolean | Promise<boolean>);
123
+ type FormValidator = (value: any, rootValue: any, control?: FormAbstract, root?: FormCollection) => null | ValidationError;
124
+ type FormAsyncValidator = (value: any, rootValue: any, control?: FormAbstract, root?: FormCollection) => Promise<null | ValidationError>;
125
+ type FormFlags = {
126
+ [key: string]: boolean;
127
+ };
128
+ type FormErrors = {
129
+ [key: string]: any;
130
+ };
131
+ type FormValidationError = {
132
+ key: string;
133
+ value: any;
134
+ };
135
+ type FormValidationErrors = FormValidationError[];
136
+ type FormState<T> = {
137
+ value: T | null;
138
+ flags: FormFlags;
139
+ errors: FormValidationErrors;
140
+ };
141
+ type ControlType = 'group' | 'array' | string;
142
+ type IFormBuilderControlSchema = {
143
+ schema: ControlType;
144
+ name?: string;
145
+ label?: string;
146
+ value?: string;
147
+ placeholder?: string;
148
+ required?: FormActivator;
149
+ hidden?: FormActivator;
150
+ disabled?: FormActivator;
151
+ readonly?: FormActivator;
152
+ options?: IOption[];
153
+ optionsExtra?: {
154
+ asEquatable: boolean;
155
+ };
156
+ validators?: FormValidator | FormValidator[];
157
+ children?: IFormBuilderSchema;
158
+ };
159
+ type IFormBuilderGroupSchema = {
160
+ [key: string]: IFormBuilderControlSchema;
161
+ };
162
+ type IFormBuilderArraySchema = IFormBuilderControlSchema[];
163
+ type IFormBuilderGroupValues = {
164
+ [key: string]: FormGroup | FormArray | FormControl;
165
+ };
166
+ type IFormBuilderSchema = IFormBuilderGroupSchema | IFormBuilderArraySchema;
167
+ type StateValue = StateValue[] | {
168
+ [key: string]: StateValue;
169
169
  } | number | string | boolean | null | undefined;
170
170
 
171
- declare class FormAbstract extends EventEmitter {
172
- errors_: ValidationError;
173
- value_: any;
174
- validators_: FormValidator[];
175
- state_: any;
176
- name?: string | number;
177
- parent?: FormCollection;
178
- schema: ControlType;
179
- options?: IOption[];
180
- optionsExtra?: {
181
- asEquatable: boolean;
182
- };
183
- protected initialOptions_?: FormOptions;
184
- private markAsDirty_;
185
- constructor(value: any, validators?: (FormValidator | FormValidator[]));
186
- protected setInitialOptions(options?: FormOptions): void;
187
- protected checkAsyncState_(root?: FormCollection): Promise<boolean>;
188
- protected checkAsyncPropState_(key: string, option?: FormActivator, root?: FormCollection): Promise<boolean>;
189
- protected revalidate_(): Promise<void>;
190
- protected validate_(root?: FormCollection): Promise<void>;
191
- validateAndChange_(root?: FormCollection): Promise<void>;
192
- protected updateStateAndChange_(): Promise<void>;
193
- protected change_(propagate?: boolean): void;
194
- protected updateState_(): void;
195
- reset(): void;
196
- patch(value: any): void;
197
- addValidators(...validators: FormValidator[]): void;
198
- replaceValidators(...validators: FormValidator[]): void;
199
- clearValidators(): void;
200
- protected get path(): (string | number)[];
201
- protected get root(): FormCollection | FormAbstract;
202
- private label_?;
203
- get label(): string;
204
- set label(label: string);
205
- private placeholder_?;
206
- get placeholder(): string;
207
- set placeholder(placeholder: string);
208
- get validators(): FormValidator[];
209
- set validators(validators: FormValidator[]);
210
- get state(): any;
211
- get errors(): ValidationError;
212
- get invalid(): any;
213
- get disabled(): any;
214
- set disabled(disabled: any);
215
- get hidden(): any;
216
- set hidden(hidden: any);
217
- get readonly(): any;
218
- set readonly(readonly: any);
219
- get dirty(): any;
220
- set dirty(dirty: any);
221
- get touched(): any;
222
- set touched(touched: any);
223
- get submitted(): any;
224
- set submitted(submitted: any);
225
- get valid(): any;
226
- get enabled(): any;
227
- get visible(): any;
228
- get writeable(): any;
229
- get pristine(): any;
230
- get untouched(): any;
231
- get unsubmitted(): any;
232
- get value(): any;
233
- set value(value: any);
171
+ declare class FormAbstract extends EventEmitter {
172
+ errors_: ValidationError;
173
+ value_: any;
174
+ validators_: FormValidator[];
175
+ state_: any;
176
+ name?: string | number;
177
+ parent?: FormCollection;
178
+ schema: ControlType;
179
+ options?: IOption[];
180
+ optionsExtra?: {
181
+ asEquatable: boolean;
182
+ };
183
+ protected initialOptions_?: FormOptions;
184
+ private markAsDirty_;
185
+ constructor(value: any, validators?: (FormValidator | FormValidator[]));
186
+ protected setInitialOptions(options?: FormOptions): void;
187
+ protected checkAsyncState_(root?: FormCollection): Promise<boolean>;
188
+ protected checkAsyncPropState_(key: string, option?: FormActivator, root?: FormCollection): Promise<boolean>;
189
+ protected revalidate_(): Promise<void>;
190
+ protected validate_(root?: FormCollection): Promise<void>;
191
+ validateAndChange_(root?: FormCollection): Promise<void>;
192
+ protected updateStateAndChange_(): Promise<void>;
193
+ protected change_(propagate?: boolean): void;
194
+ protected updateState_(): void;
195
+ reset(): void;
196
+ patch(value: any): void;
197
+ addValidators(...validators: FormValidator[]): void;
198
+ replaceValidators(...validators: FormValidator[]): void;
199
+ clearValidators(): void;
200
+ protected get path(): (string | number)[];
201
+ protected get root(): FormCollection | FormAbstract;
202
+ private label_?;
203
+ get label(): string;
204
+ set label(label: string);
205
+ private placeholder_?;
206
+ get placeholder(): string;
207
+ set placeholder(placeholder: string);
208
+ get validators(): FormValidator[];
209
+ set validators(validators: FormValidator[]);
210
+ get state(): any;
211
+ get errors(): ValidationError;
212
+ get invalid(): any;
213
+ get disabled(): any;
214
+ set disabled(disabled: any);
215
+ get hidden(): any;
216
+ set hidden(hidden: any);
217
+ get readonly(): any;
218
+ set readonly(readonly: any);
219
+ get dirty(): any;
220
+ set dirty(dirty: any);
221
+ get touched(): any;
222
+ set touched(touched: any);
223
+ get submitted(): any;
224
+ set submitted(submitted: any);
225
+ get valid(): any;
226
+ get enabled(): any;
227
+ get visible(): any;
228
+ get writeable(): any;
229
+ get pristine(): any;
230
+ get untouched(): any;
231
+ get unsubmitted(): any;
232
+ get value(): any;
233
+ set value(value: any);
234
234
  }
235
235
 
236
- declare function validValue(value: any): any;
237
- declare function isThenable(result: any): any;
238
- declare function mapErrors_(errors: FormErrors): FormValidationError[];
239
- declare function valueToString(value: IOption | IOption[] | IEquatable | IEquatable[] | null): string | string[] | undefined;
240
- declare function stringToValue(value: string | string[] | undefined, options?: IOption[], optionsExtra?: {
241
- asEquatable: boolean;
236
+ declare function validValue(value: any): any;
237
+ declare function isThenable(result: any): any;
238
+ declare function mapErrors_(errors: FormErrors): FormValidationError[];
239
+ declare function valueToString(value: IOption | IOption[] | IEquatable | IEquatable[] | null): string | string[] | undefined;
240
+ declare function stringToValue(value: string | string[] | undefined, options?: IOption[], optionsExtra?: {
241
+ asEquatable: boolean;
242
242
  }): IOption | IOption[] | IEquatable | IEquatable[] | null;
243
243
 
244
- /**
245
- * an email pattern validator
246
- */
244
+ /**
245
+ * an email pattern validator
246
+ */
247
247
  declare function EmailValidator(): FormValidator;
248
248
 
249
- /**
250
- * an equality match validation on another field
251
- */
249
+ /**
250
+ * an equality match validation on another field
251
+ */
252
252
  declare function MatchValidator(getOtherValue: (value: any, rootValue: any, control?: FormAbstract, root?: FormAbstract) => any): FormValidator;
253
253
 
254
- /**
255
- * a max string length validator
256
- */
254
+ /**
255
+ * a max string length validator
256
+ */
257
257
  declare function MaxLengthValidator(maxlength: number): FormValidator;
258
258
 
259
- /**
260
- * a max number value validator
261
- */
259
+ /**
260
+ * a max number value validator
261
+ */
262
262
  declare function MaxValidator(max: number): FormValidator;
263
263
 
264
- /**
265
- * a min string length validator
266
- */
264
+ /**
265
+ * a min string length validator
266
+ */
267
267
  declare function MinLengthValidator(minlength: number): FormValidator;
268
268
 
269
- /**
270
- * a min number value validator
271
- */
269
+ /**
270
+ * a min number value validator
271
+ */
272
272
  declare function MinValidator(min: number): FormValidator;
273
273
 
274
- /**
275
- * a null validator
276
- */
274
+ /**
275
+ * a null validator
276
+ */
277
277
  declare function NullValidator(): FormValidator;
278
278
 
279
- /**
280
- * a regex pattern validator
281
- */
279
+ /**
280
+ * a regex pattern validator
281
+ */
282
282
  declare function PatternValidator(pattern: string | RegExp): FormValidator;
283
283
 
284
- /**
285
- * a required dependant on another field
286
- */
284
+ /**
285
+ * a required dependant on another field
286
+ */
287
287
  declare function RequiredIfValidator(condition: (value: any, rootValue: any, control?: FormAbstract, root?: FormAbstract) => boolean): FormValidator;
288
288
 
289
- /**
290
- * a required and true validator
291
- */
289
+ /**
290
+ * a required and true validator
291
+ */
292
292
  declare function RequiredTrueValidator(): FormValidator;
293
293
 
294
- /**
295
- * a required validator
296
- */
294
+ /**
295
+ * a required validator
296
+ */
297
297
  declare function RequiredValidator(): FormValidator;
298
298
 
299
299
  declare function useControl<T>(control: FormAbstract): [FormState<T>, (value: T | null) => void, () => void, () => void, FormAbstract];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@websolutespa/bom-mixer-forms",
3
- "version": "0.2.2",
3
+ "version": "0.3.0",
4
4
  "description": "Mixer Forms module of the BOM Repository",
5
5
  "keywords": [
6
6
  "bom",
@@ -26,22 +26,20 @@
26
26
  "peerDependencies": {
27
27
  "@websolutespa/bom-core": "*",
28
28
  "@websolutespa/bom-mixer-hooks": "*",
29
- "styled-components": ">= 5.3.5",
30
29
  "react": ">= 18.2.0"
31
30
  },
32
31
  "devDependencies": {
33
- "@types/react": "^18.0.18",
34
- "@types/react-dom": "^18.0.6",
35
- "@types/styled-components": "^5.1.26",
32
+ "@types/react": "^18.2.18",
33
+ "@types/react-dom": "^18.2.7",
36
34
  "@websolutespa/bom-cli": "*",
37
35
  "@websolutespa/test": "*",
38
36
  "@websolutespa/tsconfig": "*",
39
- "eslint": "^8.36.0",
37
+ "eslint": "^8.46.0",
40
38
  "eslint-config-websolute": "*",
41
39
  "raw-loader": "^4.0.2",
42
40
  "ts-node": "^10.9.1",
43
41
  "tsup": "^6.7.0",
44
- "typescript": "^4.8.4"
42
+ "typescript": "^5.1.6"
45
43
  },
46
44
  "publishConfig": {
47
45
  "access": "public"