@rolster/forms 2.6.4 → 2.7.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.
@@ -2,48 +2,50 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- function itIsFormControlOptions(props) {
6
- return (typeof props === 'object' && ('value' in props || 'validators' in props));
5
+ function itIsControlOptions(options) {
6
+ return (typeof options === 'object' &&
7
+ ('value' in options || 'validators' in options));
7
8
  }
8
- function itIsFormGroupOptions(props) {
9
- return typeof props === 'object' && 'controls' in props;
9
+ function itIsGroupOptions(options) {
10
+ return typeof options === 'object' && 'controls' in options;
10
11
  }
11
- function itIsFormArrayOptions(props) {
12
- return (typeof props === 'object' && ('groups' in props || 'validators' in props));
12
+ function itIsArrayOptions(options) {
13
+ return (typeof options === 'object' &&
14
+ ('groups' in options || 'validators' in options));
13
15
  }
14
- function createFormControlOptions(...argsProps) {
15
- const [props, validators] = argsProps;
16
- if (!props) {
17
- return { value: props, validators };
16
+ function createFormControlOptions(...controlOptions) {
17
+ const [options, validators] = controlOptions;
18
+ if (!options) {
19
+ return { value: options, validators };
18
20
  }
19
- if (!validators && itIsFormControlOptions(props)) {
20
- return props;
21
+ if (!validators && itIsControlOptions(options)) {
22
+ return options;
21
23
  }
22
24
  return {
23
- value: props,
25
+ value: options,
24
26
  validators
25
27
  };
26
28
  }
27
- function createFormGroupOptions(...argsProps) {
28
- const [props, validators] = argsProps;
29
- if (!validators && itIsFormGroupOptions(props)) {
30
- return props;
29
+ function createFormGroupOptions(...groupOptions) {
30
+ const [options, validators] = groupOptions;
31
+ if (!validators && itIsGroupOptions(options)) {
32
+ return options;
31
33
  }
32
34
  return {
33
- controls: props,
35
+ controls: options,
34
36
  validators
35
37
  };
36
38
  }
37
- function createFormArrayOptions(...argsProps) {
38
- const [props, validators] = argsProps;
39
- if (!props) {
40
- return { groups: props, validators };
39
+ function createFormArrayOptions(...arrayOptions) {
40
+ const [options, validators] = arrayOptions;
41
+ if (!options) {
42
+ return { groups: options, validators };
41
43
  }
42
- if (!validators && itIsFormArrayOptions(props)) {
43
- return props;
44
+ if (!validators && itIsArrayOptions(options)) {
45
+ return options;
44
46
  }
45
47
  return {
46
- groups: props,
48
+ groups: options,
47
49
  validators
48
50
  };
49
51
  }
@@ -1 +1 @@
1
- {"version":3,"file":"arguments.js","sources":["../esm/arguments.js"],"sourcesContent":["function itIsFormControlOptions(props) {\r\n return (typeof props === 'object' && ('value' in props || 'validators' in props));\r\n}\r\nfunction itIsFormGroupOptions(props) {\r\n return typeof props === 'object' && 'controls' in props;\r\n}\r\nfunction itIsFormArrayOptions(props) {\r\n return (typeof props === 'object' && ('groups' in props || 'validators' in props));\r\n}\r\nexport function createFormControlOptions(...argsProps) {\r\n const [props, validators] = argsProps;\r\n if (!props) {\r\n return { value: props, validators };\r\n }\r\n if (!validators && itIsFormControlOptions(props)) {\r\n return props;\r\n }\r\n return {\r\n value: props,\r\n validators\r\n };\r\n}\r\nexport function createFormGroupOptions(...argsProps) {\r\n const [props, validators] = argsProps;\r\n if (!validators && itIsFormGroupOptions(props)) {\r\n return props;\r\n }\r\n return {\r\n controls: props,\r\n validators\r\n };\r\n}\r\nexport function createFormArrayOptions(...argsProps) {\r\n const [props, validators] = argsProps;\r\n if (!props) {\r\n return { groups: props, validators };\r\n }\r\n if (!validators && itIsFormArrayOptions(props)) {\r\n return props;\r\n }\r\n return {\r\n groups: props,\r\n validators\r\n };\r\n}\r\n//# sourceMappingURL=arguments.js.map"],"names":[],"mappings":";;;;AAAA,SAAS,sBAAsB,CAAC,KAAK,EAAE;AACvC,IAAI,QAAQ,OAAO,KAAK,KAAK,QAAQ,KAAK,OAAO,IAAI,KAAK,IAAI,YAAY,IAAI,KAAK,CAAC,EAAE;AACtF,CAAC;AACD,SAAS,oBAAoB,CAAC,KAAK,EAAE;AACrC,IAAI,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,UAAU,IAAI,KAAK,CAAC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AO,KAAK,CAAC;AACrB,KAAK;AACL,IAAI,OAAO;AACX,QAAQ,MAAM,EAAE,KAAK;AACrB,QAAQ,UAAU;AAClB,KAAK,CAAC;AACN;;;;;;"}
1
+ {"version":3,"file":"arguments.js","sources":["../esm/arguments.js"],"sourcesContent":["function itIsControlOptions(options) {\r\n return (typeof options === 'object' &&\r\n ('value' in options || 'validators' in options));\r\n}\r\nfunction itIsGroupOptions(options) {\r\n return typeof options === 'object' && 'controls' in options;\r\n}\r\nfunction itIsArrayOptions(options) {\r\n return (typeof options === 'object' &&\r\n ('groups' in options || 'validators' in options));\r\n}\r\nexport function createFormControlOptions(...controlOptions) {\r\n const [options, validators] = controlOptions;\r\n if (!options) {\r\n return { value: options, validators };\r\n }\r\n if (!validators && itIsControlOptions(options)) {\r\n return options;\r\n }\r\n return {\r\n value: options,\r\n validators\r\n };\r\n}\r\nexport function createFormGroupOptions(...groupOptions) {\r\n const [options, validators] = groupOptions;\r\n if (!validators && itIsGroupOptions(options)) {\r\n return options;\r\n }\r\n return {\r\n controls: options,\r\n validators\r\n };\r\n}\r\nexport function createFormArrayOptions(...arrayOptions) {\r\n const [options, validators] = arrayOptions;\r\n if (!options) {\r\n return { groups: options, validators };\r\n }\r\n if (!validators && itIsArrayOptions(options)) {\r\n return options;\r\n }\r\n return {\r\n groups: options,\r\n validators\r\n };\r\n}\r\n//# sourceMappingURL=arguments.js.map"],"names":[],"mappings":";;;;AAAA,SAAS,kBAAkB,CAAC,OAAO,EAAE;AACrC,IAAI,QAAQ,OAAO,OAAO,KAAK,QAAQ;AACvC,SAAS,OAAO,IAAI,OAAO,IAAI,YAAY,IAAI,OAAO,CAAC,EAAE;AACzD,CAAC;AACD,SAAS,gBAAgB,CAAC,OAAO,EAAE;AACnC,IAAI,OAAO,OAAO,OAAO,KAAK,QAAQ,IAAI,UAAU,IAAI,OAAO,CAAC;AAChE,CAAC;AACD,SAAS,gBAAgB,CAAC,OAAO,EAAE;AACnC,IAAI,QAAQ,OAAO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OAAO;AACvB,QAAQ,UAAU;AAClB,KAAK,CAAC;AACN;;;;;;"}
package/dist/cjs/index.js CHANGED
@@ -2,51 +2,53 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var commons = require('@rolster/commons');
6
5
  var uuid = require('uuid');
6
+ var commons = require('@rolster/commons');
7
7
 
8
- function itIsFormControlOptions(props) {
9
- return (typeof props === 'object' && ('value' in props || 'validators' in props));
8
+ function itIsControlOptions(options) {
9
+ return (typeof options === 'object' &&
10
+ ('value' in options || 'validators' in options));
10
11
  }
11
- function itIsFormGroupOptions(props) {
12
- return typeof props === 'object' && 'controls' in props;
12
+ function itIsGroupOptions(options) {
13
+ return typeof options === 'object' && 'controls' in options;
13
14
  }
14
- function itIsFormArrayOptions(props) {
15
- return (typeof props === 'object' && ('groups' in props || 'validators' in props));
15
+ function itIsArrayOptions(options) {
16
+ return (typeof options === 'object' &&
17
+ ('groups' in options || 'validators' in options));
16
18
  }
17
- function createFormControlOptions(...argsProps) {
18
- const [props, validators] = argsProps;
19
- if (!props) {
20
- return { value: props, validators };
19
+ function createFormControlOptions(...controlOptions) {
20
+ const [options, validators] = controlOptions;
21
+ if (!options) {
22
+ return { value: options, validators };
21
23
  }
22
- if (!validators && itIsFormControlOptions(props)) {
23
- return props;
24
+ if (!validators && itIsControlOptions(options)) {
25
+ return options;
24
26
  }
25
27
  return {
26
- value: props,
28
+ value: options,
27
29
  validators
28
30
  };
29
31
  }
30
- function createFormGroupOptions(...argsProps) {
31
- const [props, validators] = argsProps;
32
- if (!validators && itIsFormGroupOptions(props)) {
33
- return props;
32
+ function createFormGroupOptions(...groupOptions) {
33
+ const [options, validators] = groupOptions;
34
+ if (!validators && itIsGroupOptions(options)) {
35
+ return options;
34
36
  }
35
37
  return {
36
- controls: props,
38
+ controls: options,
37
39
  validators
38
40
  };
39
41
  }
40
- function createFormArrayOptions(...argsProps) {
41
- const [props, validators] = argsProps;
42
- if (!props) {
43
- return { groups: props, validators };
42
+ function createFormArrayOptions(...arrayOptions) {
43
+ const [options, validators] = arrayOptions;
44
+ if (!options) {
45
+ return { groups: options, validators };
44
46
  }
45
- if (!validators && itIsFormArrayOptions(props)) {
46
- return props;
47
+ if (!validators && itIsArrayOptions(options)) {
48
+ return options;
47
49
  }
48
50
  return {
49
- groups: props,
51
+ groups: options,
50
52
  validators
51
53
  };
52
54
  }
@@ -106,158 +108,15 @@ function someErrors(errors, keys) {
106
108
  return reduceErrors(errors).some((key) => keys.includes(key));
107
109
  }
108
110
 
109
- class FormArray {
110
- constructor(arrayOptions, arrayValidators) {
111
- this.currentGroups = [];
112
- this.currentValid = true;
113
- this.currentDisabled = false;
114
- this.currentErrors = [];
115
- const { groups, validators } = createFormArrayOptions(arrayOptions, arrayValidators);
116
- this.unsusbcriptions = new Map();
117
- this.initialState = groups;
118
- this.validators = validators;
119
- this.refresh(this.initialState);
120
- this.observable = commons.observable(this.value);
121
- groups?.forEach((group) => {
122
- this.subscription(group);
123
- });
124
- }
125
- get groups() {
126
- return this.currentGroups;
127
- }
128
- get controls() {
129
- return this.groups.map(({ controls }) => controls);
130
- }
131
- get touched() {
132
- return groupPartialChecked(this.groups, 'touched');
133
- }
134
- get touchedAll() {
135
- return groupAllChecked(this.groups, 'touchedAll');
136
- }
137
- get untouched() {
138
- return !this.touched;
139
- }
140
- get untouchedAll() {
141
- return !this.touchedAll;
142
- }
143
- get dirty() {
144
- return groupPartialChecked(this.groups, 'dirty');
145
- }
146
- get dirtyAll() {
147
- return groupAllChecked(this.groups, 'dirtyAll');
148
- }
149
- get pristine() {
150
- return !this.dirty;
151
- }
152
- get pristineAll() {
153
- return !this.dirtyAll;
154
- }
155
- get disabled() {
156
- return this.currentDisabled;
157
- }
158
- get enabled() {
159
- return !this.currentDisabled;
160
- }
161
- get valid() {
162
- return this.currentValid && groupAllChecked(this.groups, 'valid');
163
- }
164
- get invalid() {
165
- return !this.currentValid;
166
- }
167
- get value() {
168
- return this.groups.map(({ value: state }) => state);
169
- }
170
- get error() {
171
- return this.currentError;
172
- }
173
- get errors() {
174
- return this.currentErrors;
175
- }
176
- get wrong() {
177
- return this.touched && this.invalid;
178
- }
179
- hasError(key) {
180
- return hasError(this.errors, key);
181
- }
182
- someErrors(keys) {
183
- return someErrors(this.errors, keys);
184
- }
185
- reset() {
186
- this.refresh(this.initialState);
187
- }
188
- disable() {
189
- this.currentDisabled = true;
190
- }
191
- enable() {
192
- this.currentDisabled = false;
193
- }
194
- push(group) {
195
- this.subscription(group);
196
- this.refresh([...this.groups, group]);
197
- }
198
- merge(groups) {
199
- groups.forEach((group) => {
200
- this.subscription(group);
201
- });
202
- this.refresh([...this.groups, ...groups]);
203
- }
204
- set(groups) {
205
- this.currentGroups.forEach(({ uuid }) => {
206
- this.unsusbcriptions.delete(uuid);
207
- });
208
- groups.forEach((group) => {
209
- this.subscription(group);
210
- });
211
- this.refresh(groups); // Update groups
212
- }
213
- remove({ uuid }) {
214
- this.refresh(this.groups.filter((group) => group.uuid !== uuid));
215
- }
216
- setValidators(validators) {
217
- this.validators = validators;
218
- this.updateValidityStatus(this.groups, validators);
219
- }
220
- subscribe(subscriber) {
221
- return this.observable.subscribe(subscriber);
222
- }
223
- subscription(group) {
224
- const unsusbcription = group.subscribe(() => {
225
- this.updateValidityStatus(this.groups, this.validators);
226
- });
227
- this.unsusbcriptions.set(group.uuid, unsusbcription);
228
- }
229
- updateValidityStatus(groups, validators) {
230
- if (validators) {
231
- const errors = arrayIsValid({ groups, validators });
232
- this.currentErrors = errors;
233
- this.currentError = errors[0];
234
- this.currentValid = errors.length === 0;
235
- }
236
- else {
237
- this.currentValid = true;
238
- this.currentErrors = [];
239
- this.currentError = undefined;
240
- }
241
- }
242
- refresh(newGroups) {
243
- const groups = newGroups || [];
244
- this.currentGroups = groups;
245
- this.updateValidityStatus(groups, this.validators);
246
- }
247
- }
248
- function formArray(options, validators) {
249
- return new FormArray(createFormArrayOptions(options, validators));
250
- }
251
-
252
111
  class FormControl {
253
- constructor(controlProps, controlValidators) {
112
+ constructor(controlOptions, controlValidators) {
254
113
  this.currentFocused = false;
255
114
  this.currentTouched = false;
256
115
  this.currentDirty = false;
257
116
  this.currentDisabled = false;
258
117
  this.currentValid = true;
259
118
  this.currentErrors = [];
260
- const { value, validators } = createFormControlOptions(controlProps, controlValidators);
119
+ const { value, validators } = createFormControlOptions(controlOptions, controlValidators);
261
120
  this.observable = commons.observable(value);
262
121
  this.initialValue = value;
263
122
  this.validators = validators;
@@ -480,14 +339,189 @@ function formArrayGroup(options, validators) {
480
339
  return new FormArrayGroup(createFormGroupOptions(options, validators));
481
340
  }
482
341
 
342
+ class FormArrayList extends FormControl {
343
+ constructor(valueToControls, value, validators) {
344
+ super(value || [], validators);
345
+ this.valueToControls = valueToControls;
346
+ this.currentControls = (value || []).map((value) => this.createControls(value));
347
+ this.uuid = uuid.v4();
348
+ }
349
+ get controls() {
350
+ return this.currentControls;
351
+ }
352
+ setValue(values) {
353
+ this.currentControls = values.map((value) => this.createControls(value));
354
+ super.setValue(values);
355
+ }
356
+ createControls(value) {
357
+ const controls = this.valueToControls(value);
358
+ Object.values(controls).forEach((control) => {
359
+ control.subscribe(() => {
360
+ const { value, validators } = this;
361
+ this.updateValueAndValidity(value, validators);
362
+ this.observable.next(value);
363
+ });
364
+ });
365
+ return controls;
366
+ }
367
+ }
368
+ function formArrayList(valueToControl, value, validators) {
369
+ return new FormArrayList(valueToControl, value, validators);
370
+ }
371
+
372
+ class FormArray {
373
+ constructor(arrayOptions, arrayValidators) {
374
+ this.currentGroups = [];
375
+ this.currentValid = true;
376
+ this.currentDisabled = false;
377
+ this.currentErrors = [];
378
+ const { groups, validators } = createFormArrayOptions(arrayOptions, arrayValidators);
379
+ this.unsusbcriptions = new Map();
380
+ this.initialState = groups;
381
+ this.validators = validators;
382
+ this.refresh(this.initialState);
383
+ this.observable = commons.observable(this.value);
384
+ groups?.forEach((group) => {
385
+ this.subscription(group);
386
+ });
387
+ }
388
+ get groups() {
389
+ return this.currentGroups;
390
+ }
391
+ get controls() {
392
+ return this.groups.map(({ controls }) => controls);
393
+ }
394
+ get touched() {
395
+ return groupPartialChecked(this.groups, 'touched');
396
+ }
397
+ get touchedAll() {
398
+ return groupAllChecked(this.groups, 'touchedAll');
399
+ }
400
+ get untouched() {
401
+ return !this.touched;
402
+ }
403
+ get untouchedAll() {
404
+ return !this.touchedAll;
405
+ }
406
+ get dirty() {
407
+ return groupPartialChecked(this.groups, 'dirty');
408
+ }
409
+ get dirtyAll() {
410
+ return groupAllChecked(this.groups, 'dirtyAll');
411
+ }
412
+ get pristine() {
413
+ return !this.dirty;
414
+ }
415
+ get pristineAll() {
416
+ return !this.dirtyAll;
417
+ }
418
+ get disabled() {
419
+ return this.currentDisabled;
420
+ }
421
+ get enabled() {
422
+ return !this.currentDisabled;
423
+ }
424
+ get valid() {
425
+ return this.currentValid && groupAllChecked(this.groups, 'valid');
426
+ }
427
+ get invalid() {
428
+ return !this.currentValid;
429
+ }
430
+ get value() {
431
+ return this.groups.map(({ value: state }) => state);
432
+ }
433
+ get error() {
434
+ return this.currentError;
435
+ }
436
+ get errors() {
437
+ return this.currentErrors;
438
+ }
439
+ get wrong() {
440
+ return this.touched && this.invalid;
441
+ }
442
+ hasError(key) {
443
+ return hasError(this.errors, key);
444
+ }
445
+ someErrors(keys) {
446
+ return someErrors(this.errors, keys);
447
+ }
448
+ reset() {
449
+ this.refresh(this.initialState);
450
+ }
451
+ disable() {
452
+ this.currentDisabled = true;
453
+ }
454
+ enable() {
455
+ this.currentDisabled = false;
456
+ }
457
+ push(group) {
458
+ this.subscription(group);
459
+ this.refresh([...this.groups, group]);
460
+ }
461
+ merge(groups) {
462
+ groups.forEach((group) => {
463
+ this.subscription(group);
464
+ });
465
+ this.refresh([...this.groups, ...groups]);
466
+ }
467
+ set(groups) {
468
+ this.currentGroups.forEach(({ uuid }) => {
469
+ this.unsusbcriptions.delete(uuid);
470
+ });
471
+ groups.forEach((group) => {
472
+ this.subscription(group);
473
+ });
474
+ this.refresh(groups); // Update groups
475
+ }
476
+ remove({ uuid }) {
477
+ this.refresh(this.groups.filter((group) => group.uuid !== uuid));
478
+ }
479
+ setValidators(validators) {
480
+ this.validators = validators;
481
+ this.updateValidityStatus(this.groups, validators);
482
+ }
483
+ subscribe(subscriber) {
484
+ return this.observable.subscribe(subscriber);
485
+ }
486
+ subscription(group) {
487
+ const unsusbcription = group.subscribe(() => {
488
+ this.updateValidityStatus(this.groups, this.validators);
489
+ });
490
+ this.unsusbcriptions.set(group.uuid, unsusbcription);
491
+ }
492
+ updateValidityStatus(groups, validators) {
493
+ if (validators) {
494
+ const errors = arrayIsValid({ groups, validators });
495
+ this.currentErrors = errors;
496
+ this.currentError = errors[0];
497
+ this.currentValid = errors.length === 0;
498
+ }
499
+ else {
500
+ this.currentValid = true;
501
+ this.currentErrors = [];
502
+ this.currentError = undefined;
503
+ }
504
+ }
505
+ refresh(newGroups) {
506
+ const groups = newGroups || [];
507
+ this.currentGroups = groups;
508
+ this.updateValidityStatus(groups, this.validators);
509
+ }
510
+ }
511
+ function formArray(options, validators) {
512
+ return new FormArray(createFormArrayOptions(options, validators));
513
+ }
514
+
483
515
  exports.FormArray = FormArray;
484
516
  exports.FormArrayControl = FormArrayControl;
485
517
  exports.FormArrayGroup = FormArrayGroup;
518
+ exports.FormArrayList = FormArrayList;
486
519
  exports.FormControl = FormControl;
487
520
  exports.FormGroup = FormGroup;
488
521
  exports.formArray = formArray;
489
522
  exports.formArrayControl = formArrayControl;
490
523
  exports.formArrayGroup = formArrayGroup;
524
+ exports.formArrayList = formArrayList;
491
525
  exports.formControl = formControl;
492
526
  exports.formGroup = formGroup;
493
527
  //# sourceMappingURL=index.js.map