@aemforms/af-core 0.22.30 → 0.22.32

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 (100) hide show
  1. package/lib/{esm/BaseNode.d.ts → BaseNode.d.ts} +8 -8
  2. package/lib/{esm/BaseNode-d78cc1b0.js → BaseNode.js} +72 -97
  3. package/lib/{esm/Checkbox.d.ts → Checkbox.d.ts} +1 -1
  4. package/lib/Checkbox.js +29 -0
  5. package/lib/{esm/CheckboxGroup.d.ts → CheckboxGroup.d.ts} +2 -2
  6. package/lib/CheckboxGroup.js +24 -0
  7. package/lib/{esm/Container.d.ts → Container.d.ts} +4 -4
  8. package/lib/{esm/Container.js → Container.js} +51 -77
  9. package/lib/{esm/DateField.d.ts → DateField.d.ts} +1 -1
  10. package/lib/DateField.js +26 -0
  11. package/lib/{esm/Field.d.ts → Field.d.ts} +10 -9
  12. package/lib/{esm/Field.js → Field.js} +97 -105
  13. package/lib/Fieldset.d.ts +72 -0
  14. package/lib/Fieldset.js +89 -0
  15. package/lib/{esm/FileObject.d.ts → FileObject.d.ts} +1 -1
  16. package/lib/FileObject.js +29 -0
  17. package/lib/{esm/FileUpload.d.ts → FileUpload.d.ts} +3 -3
  18. package/lib/FileUpload.js +124 -0
  19. package/lib/{esm/Form.d.ts → Form.d.ts} +13 -13
  20. package/lib/{esm/Form.js → Form.js} +34 -68
  21. package/lib/{esm/FormInstance.d.ts → FormInstance.d.ts} +3 -3
  22. package/lib/FormInstance.js +94 -0
  23. package/lib/{esm/FormMetaData.d.ts → FormMetaData.d.ts} +2 -2
  24. package/lib/FormMetaData.js +15 -0
  25. package/lib/{esm/InstanceManager.d.ts → InstanceManager.d.ts} +2 -2
  26. package/lib/InstanceManager.js +35 -0
  27. package/lib/{esm/Node.d.ts → Node.d.ts} +0 -0
  28. package/lib/Node.js +15 -0
  29. package/lib/{esm/Scriptable.d.ts → Scriptable.d.ts} +3 -3
  30. package/lib/{esm/Scriptable.js → Scriptable.js} +17 -38
  31. package/lib/{esm/controller → controller}/EventQueue.d.ts +3 -3
  32. package/lib/{esm/controller → controller}/EventQueue.js +8 -32
  33. package/lib/{esm/controller → controller}/Events.d.ts +2 -2
  34. package/lib/{esm/controller → controller}/Events.js +22 -26
  35. package/lib/{esm/controller → controller}/Logger.d.ts +2 -2
  36. package/lib/controller/Logger.js +33 -0
  37. package/lib/{esm/data → data}/DataGroup.d.ts +1 -1
  38. package/lib/{esm/data → data}/DataGroup.js +20 -38
  39. package/lib/{esm/data → data}/DataValue.d.ts +1 -1
  40. package/lib/{esm/data → data}/DataValue.js +4 -26
  41. package/lib/{esm/data → data}/EmptyDataValue.d.ts +1 -1
  42. package/lib/data/EmptyDataValue.js +34 -0
  43. package/lib/index.d.ts +21 -0
  44. package/lib/index.js +57 -0
  45. package/lib/{esm/rules → rules}/FunctionRuntime.d.ts +3 -3
  46. package/lib/{esm/rules → rules}/FunctionRuntime.js +52 -63
  47. package/lib/{esm/rules → rules}/RuleEngine.d.ts +1 -1
  48. package/lib/rules/RuleEngine.js +51 -0
  49. package/lib/{esm/types → types}/Json.d.ts +18 -16
  50. package/lib/types/Json.js +10 -0
  51. package/lib/{esm/types → types}/Model.d.ts +10 -10
  52. package/lib/types/Model.js +10 -0
  53. package/lib/types/index.d.ts +2 -0
  54. package/lib/types/index.js +18 -0
  55. package/lib/{esm/utils → utils}/DataRefParser.d.ts +10 -4
  56. package/lib/{esm/utils → utils}/DataRefParser.js +48 -42
  57. package/lib/{esm/utils → utils}/Fetch.d.ts +1 -1
  58. package/lib/utils/Fetch.js +74 -0
  59. package/lib/{esm/utils → utils}/FormCreationUtils.d.ts +1 -1
  60. package/lib/utils/FormCreationUtils.js +67 -0
  61. package/lib/{esm/utils → utils}/FormUtils.d.ts +2 -1
  62. package/lib/{esm/utils → utils}/FormUtils.js +62 -46
  63. package/lib/{esm/utils → utils}/JsonUtils.d.ts +1 -1
  64. package/lib/utils/JsonUtils.js +89 -0
  65. package/lib/{esm/utils → utils}/LogUtils.d.ts +1 -1
  66. package/lib/utils/LogUtils.js +10 -0
  67. package/lib/{esm/utils → utils}/SchemaUtils.d.ts +1 -1
  68. package/lib/{esm/utils → utils}/SchemaUtils.js +9 -29
  69. package/lib/{esm/utils → utils}/TranslationUtils.d.ts +2 -2
  70. package/lib/utils/TranslationUtils.js +125 -0
  71. package/lib/{esm/utils → utils}/ValidationUtils.d.ts +4 -4
  72. package/lib/{esm/utils → utils}/ValidationUtils.js +13 -35
  73. package/package.json +8 -13
  74. package/lib/cjs/index.cjs +0 -7345
  75. package/lib/esm/BaseNode.js +0 -26
  76. package/lib/esm/Checkbox.js +0 -63
  77. package/lib/esm/CheckboxGroup.js +0 -60
  78. package/lib/esm/DateField.js +0 -57
  79. package/lib/esm/Fieldset.d.ts +0 -16
  80. package/lib/esm/Fieldset.js +0 -78
  81. package/lib/esm/FileObject.js +0 -48
  82. package/lib/esm/FileUpload.js +0 -141
  83. package/lib/esm/FormInstance.js +0 -129
  84. package/lib/esm/FormMetaData.js +0 -35
  85. package/lib/esm/InstanceManager.js +0 -58
  86. package/lib/esm/Node.js +0 -40
  87. package/lib/esm/controller/Logger.js +0 -52
  88. package/lib/esm/data/EmptyDataValue.js +0 -51
  89. package/lib/esm/index.d.ts +0 -21
  90. package/lib/esm/index.js +0 -55
  91. package/lib/esm/rules/RuleEngine.js +0 -76
  92. package/lib/esm/types/Json.js +0 -29
  93. package/lib/esm/types/Model.js +0 -30
  94. package/lib/esm/types/index.d.ts +0 -2
  95. package/lib/esm/types/index.js +0 -22
  96. package/lib/esm/utils/Fetch.js +0 -83
  97. package/lib/esm/utils/FormCreationUtils.js +0 -112
  98. package/lib/esm/utils/JsonUtils.js +0 -99
  99. package/lib/esm/utils/LogUtils.js +0 -28
  100. package/lib/esm/utils/TranslationUtils.js +0 -138
@@ -1,54 +1,39 @@
1
- /*************************************************************************
2
- * ADOBE CONFIDENTIAL
3
- * ___________________
4
- *
5
- * Copyright 2022 Adobe
6
- * All Rights Reserved.
7
- *
8
- * NOTICE: All information contained herein is, and remains
9
- * the property of Adobe and its suppliers, if any. The intellectual
10
- * and technical concepts contained herein are proprietary to Adobe
11
- * and its suppliers and are protected by all applicable intellectual
12
- * property laws, including trade secret and copyright laws.
13
- * Dissemination of this information or reproduction of this material
14
- * is strictly forbidden unless prior written permission is obtained
15
- * from Adobe.
16
-
17
- * Adobe permits you to use and modify this file solely in accordance with
18
- * the terms of the Adobe license agreement accompanying it.
19
- *************************************************************************/
20
-
21
- import { _ as __decorate, s as staticFields, t as target, d as dependencyTracked, e as exclude, i as include } from './BaseNode-d78cc1b0.js';
22
- import { ValidationError } from './types/Model.js';
23
- import { Constraints, coerceType, ValidConstraints } from './utils/ValidationUtils.js';
24
- import { Initialize, ExecuteRule, Change, Valid, Invalid, propertyChange } from './controller/Events.js';
25
- import Scriptable from './Scriptable.js';
26
- import { defaultFieldTypes } from './utils/SchemaUtils.js';
27
- import DataValue from './data/DataValue.js';
28
- import NullDataValue from './data/EmptyDataValue.js';
29
- import { format } from '@aemforms/af-formatters';
30
- import './utils/DataRefParser.js';
31
- import './data/DataGroup.js';
32
- import './utils/FormUtils.js';
33
- import './utils/JsonUtils.js';
34
- import './types/Json.js';
35
- import './FileObject.js';
36
-
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __importDefault = (this && this.__importDefault) || function (mod) {
9
+ return (mod && mod.__esModule) ? mod : { "default": mod };
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const types_1 = require("./types");
13
+ const ValidationUtils_1 = require("./utils/ValidationUtils");
14
+ const Events_1 = require("./controller/Events");
15
+ const Scriptable_1 = __importDefault(require("./Scriptable"));
16
+ const SchemaUtils_1 = require("./utils/SchemaUtils");
17
+ const DataValue_1 = __importDefault(require("./data/DataValue"));
18
+ const BaseNode_1 = require("./BaseNode");
19
+ const EmptyDataValue_1 = __importDefault(require("./data/EmptyDataValue"));
20
+ const af_formatters_1 = require("@aemforms/af-formatters");
37
21
  const validTypes = ['string', 'number', 'boolean', 'file', 'string[]', 'number[]', 'boolean[]', 'file[]', 'array', 'object'];
38
- class Field extends Scriptable {
22
+ class Field extends Scriptable_1.default {
39
23
  constructor(params, _options) {
40
24
  super(params, _options);
25
+ this._ruleNodeReference = [];
41
26
  this._applyDefaults();
42
- this.queueEvent(new Initialize());
43
- this.queueEvent(new ExecuteRule());
27
+ this.queueEvent(new Events_1.Initialize());
28
+ this.queueEvent(new Events_1.ExecuteRule());
44
29
  }
45
- _ruleNodeReference = [];
46
30
  _initialize() {
47
31
  super._initialize();
48
32
  this.setupRuleNode();
49
33
  }
50
34
  ruleNodeReference() {
51
- if (this.type?.endsWith('[]')) {
35
+ var _a;
36
+ if ((_a = this.type) === null || _a === void 0 ? void 0 : _a.endsWith('[]')) {
52
37
  this._ruleNodeReference = [];
53
38
  }
54
39
  else {
@@ -69,7 +54,7 @@ class Field extends Scriptable {
69
54
  let finalType = type;
70
55
  if (typeof type !== 'string' || validTypes.indexOf(type) === -1) {
71
56
  const _enum = this.enum;
72
- finalType = typeof (_enum?.[0]);
57
+ finalType = typeof (_enum === null || _enum === void 0 ? void 0 : _enum[0]);
73
58
  if (finalType === 'undefined' && typeof this._jsonModel.default !== 'undefined') {
74
59
  if (this._jsonModel.default instanceof Array && this._jsonModel.default.length > 0) {
75
60
  finalType = `${typeof (this._jsonModel.default[0])}[]`;
@@ -111,14 +96,14 @@ class Field extends Scriptable {
111
96
  }
112
97
  const value = this._jsonModel.value;
113
98
  if (value === undefined) {
114
- const typedRes = Constraints.type(this.getInternalType() || 'string', this._jsonModel.default);
99
+ const typedRes = ValidationUtils_1.Constraints.type(this.getInternalType() || 'string', this._jsonModel.default);
115
100
  this._jsonModel.value = typedRes.value;
116
101
  }
117
102
  if (this._jsonModel.type !== 'string') {
118
103
  this.unset('emptyValue');
119
104
  }
120
105
  if (this._jsonModel.fieldType === undefined) {
121
- this.form.logger.error('fieldType property is mandatory. Please ensure all the fields have a fieldType');
106
+ this.form.logger.debug('fieldType property is mandatory. Please ensure all the fields have a fieldType');
122
107
  if (this._jsonModel.viewType) {
123
108
  if (this._jsonModel.viewType.startsWith('custom:')) {
124
109
  this.form.logger.error('viewType property has been removed. For custom types, use :type property');
@@ -129,7 +114,7 @@ class Field extends Scriptable {
129
114
  this._jsonModel.fieldType = this._jsonModel.viewType;
130
115
  }
131
116
  else {
132
- this._jsonModel.fieldType = defaultFieldTypes(this._jsonModel);
117
+ this._jsonModel.fieldType = (0, SchemaUtils_1.defaultFieldTypes)(this._jsonModel);
133
118
  }
134
119
  }
135
120
  if (this._jsonModel.enum === undefined) {
@@ -173,7 +158,7 @@ class Field extends Scriptable {
173
158
  if (typeof val !== 'undefined' && typeof val !== type) {
174
159
  this.form.logger.info(`${param} is not of type ${type}. Trying to coerce.`);
175
160
  try {
176
- this._jsonModel[param] = coerceType(val, type);
161
+ this._jsonModel[param] = (0, ValidationUtils_1.coerceType)(val, type);
177
162
  }
178
163
  catch (e) {
179
164
  this.form.logger.warn(e);
@@ -191,13 +176,23 @@ class Field extends Scriptable {
191
176
  return this._jsonModel.placeholder;
192
177
  }
193
178
  get readOnly() {
194
- return this._jsonModel.readOnly;
179
+ if (this.parent.readOnly !== undefined) {
180
+ return this.parent.readOnly === true ? true : this._jsonModel.readOnly;
181
+ }
182
+ else {
183
+ return this._jsonModel.readOnly;
184
+ }
195
185
  }
196
186
  set readOnly(e) {
197
187
  this._setProperty('readOnly', e);
198
188
  }
199
189
  get enabled() {
200
- return this._jsonModel.enabled;
190
+ if (this.parent.enabled !== undefined) {
191
+ return this.parent.enabled === false ? false : this._jsonModel.enabled;
192
+ }
193
+ else {
194
+ return this._jsonModel.enabled;
195
+ }
201
196
  }
202
197
  set enabled(e) {
203
198
  this._setProperty('enabled', e);
@@ -259,7 +254,7 @@ class Field extends Scriptable {
259
254
  }
260
255
  withCategory(df) {
261
256
  if (df) {
262
- const hasCategory = df?.match(/^(?:date|num)\|/);
257
+ const hasCategory = df === null || df === void 0 ? void 0 : df.match(/^(?:date|num)\|/);
263
258
  if (hasCategory === null) {
264
259
  if (this.format === 'date') {
265
260
  df = `date|${df}`;
@@ -276,7 +271,7 @@ class Field extends Scriptable {
276
271
  const df = this.editFormat;
277
272
  if (df && this.isNotEmpty(this.value) && this.valid !== false) {
278
273
  try {
279
- return format(this.value, this.language, df);
274
+ return (0, af_formatters_1.format)(this.value, this.lang, df);
280
275
  }
281
276
  catch (e) {
282
277
  return this.value;
@@ -290,7 +285,7 @@ class Field extends Scriptable {
290
285
  const df = this.displayFormat;
291
286
  if (df && this.isNotEmpty(this.value) && this.valid !== false) {
292
287
  try {
293
- return format(this.value, this.language, df);
288
+ return (0, af_formatters_1.format)(this.value, this.lang, df);
294
289
  }
295
290
  catch (e) {
296
291
  return this.value;
@@ -305,7 +300,7 @@ class Field extends Scriptable {
305
300
  }
306
301
  updateDataNodeAndTypedValue(val) {
307
302
  const dataNode = this.getDataNode();
308
- if (staticFields.indexOf(this.fieldType) > -1 && typeof dataNode !== 'undefined') {
303
+ if (BaseNode_1.staticFields.indexOf(this.fieldType) > -1 && typeof dataNode !== 'undefined') {
309
304
  return;
310
305
  }
311
306
  const Constraints = this._getConstraintObject();
@@ -330,11 +325,11 @@ class Field extends Scriptable {
330
325
  set value(v) {
331
326
  const changes = this.updateDataNodeAndTypedValue(v);
332
327
  let uniqueRes = { valid: true };
333
- if (changes?.length > 0) {
328
+ if ((changes === null || changes === void 0 ? void 0 : changes.length) > 0) {
334
329
  let updates = {};
335
- const typeRes = Constraints.type(this.getInternalType() || 'string', v);
330
+ const typeRes = ValidationUtils_1.Constraints.type(this.getInternalType() || 'string', v);
336
331
  if (this.parent.uniqueItems && this.parent.type === 'array') {
337
- uniqueRes = Constraints.uniqueItems(this.parent.uniqueItems, this.parent.getDataNode().$value);
332
+ uniqueRes = ValidationUtils_1.Constraints.uniqueItems(this.parent.uniqueItems, this.parent.getDataNode().$value);
338
333
  }
339
334
  if (typeRes.valid && uniqueRes.valid) {
340
335
  updates = this.evaluateConstraints();
@@ -349,7 +344,7 @@ class Field extends Scriptable {
349
344
  if (updates.valid) {
350
345
  this.triggerValidationEvent(updates);
351
346
  }
352
- const changeAction = new Change({ changes: changes.concat(Object.values(updates)) });
347
+ const changeAction = new Events_1.Change({ changes: changes.concat(Object.values(updates)) });
353
348
  this.dispatch(changeAction);
354
349
  }
355
350
  }
@@ -361,12 +356,13 @@ class Field extends Scriptable {
361
356
  'errorMessage': ''
362
357
  };
363
358
  const updates = this._applyUpdates(['valid', 'errorMessage'], validationStateChanges);
364
- const changeAction = new Change({ changes: changes.concat(Object.values(updates)) });
359
+ const changeAction = new Events_1.Change({ changes: changes.concat(Object.values(updates)) });
365
360
  this.dispatch(changeAction);
366
361
  }
367
362
  }
368
363
  _updateRuleNodeReference(value) {
369
- if (this.type?.endsWith('[]')) {
364
+ var _a;
365
+ if ((_a = this.type) === null || _a === void 0 ? void 0 : _a.endsWith('[]')) {
370
366
  if (value != null) {
371
367
  value.forEach((val, index) => {
372
368
  this._ruleNodeReference[index] = val;
@@ -386,18 +382,20 @@ class Field extends Scriptable {
386
382
  return this.type;
387
383
  }
388
384
  valueOf() {
389
- const obj = this[target];
385
+ const obj = this[BaseNode_1.target];
390
386
  const actualField = obj === undefined ? this : obj;
391
387
  actualField.ruleEngine.trackDependency(actualField);
392
388
  return actualField._jsonModel.value || null;
393
389
  }
394
390
  toString() {
395
- const obj = this[target];
391
+ var _a;
392
+ const obj = this[BaseNode_1.target];
396
393
  const actualField = obj === undefined ? this : obj;
397
- return actualField._jsonModel.value?.toString() || '';
394
+ return ((_a = actualField._jsonModel.value) === null || _a === void 0 ? void 0 : _a.toString()) || '';
398
395
  }
399
396
  getErrorMessage(constraint) {
400
- return this._jsonModel.constraintMessages?.[constraint] || '';
397
+ var _a;
398
+ return ((_a = this._jsonModel.constraintMessages) === null || _a === void 0 ? void 0 : _a[constraint]) || '';
401
399
  }
402
400
  get errorMessage() {
403
401
  return this._jsonModel.errorMessage;
@@ -406,7 +404,7 @@ class Field extends Scriptable {
406
404
  return this._jsonModel.screenReaderText;
407
405
  }
408
406
  _getConstraintObject() {
409
- return Constraints;
407
+ return ValidationUtils_1.Constraints;
410
408
  }
411
409
  isArrayType() {
412
410
  return this.type ? this.type.indexOf('[]') > -1 : false;
@@ -424,10 +422,11 @@ class Field extends Scriptable {
424
422
  return true;
425
423
  }
426
424
  checkStep() {
425
+ var _a, _b;
427
426
  const value = this._jsonModel.value;
428
427
  const step = this._jsonModel.step;
429
428
  if (typeof step === 'number') {
430
- const prec = step.toString().split('.')?.[1]?.length || 0;
429
+ const prec = ((_b = (_a = step.toString().split('.')) === null || _a === void 0 ? void 0 : _a[1]) === null || _b === void 0 ? void 0 : _b.length) || 0;
431
430
  const factor = Math.pow(10, prec);
432
431
  const fStep = step * factor;
433
432
  const fVal = value * factor;
@@ -461,22 +460,22 @@ class Field extends Scriptable {
461
460
  case 'string':
462
461
  switch (this.format) {
463
462
  case 'date':
464
- return ValidConstraints.date;
463
+ return ValidationUtils_1.ValidConstraints.date;
465
464
  case 'binary':
466
- return ValidConstraints.file;
465
+ return ValidationUtils_1.ValidConstraints.file;
467
466
  case 'data-url':
468
- return ValidConstraints.file;
467
+ return ValidationUtils_1.ValidConstraints.file;
469
468
  default:
470
- return ValidConstraints.string;
469
+ return ValidationUtils_1.ValidConstraints.string;
471
470
  }
472
471
  case 'file':
473
- return ValidConstraints.file;
472
+ return ValidationUtils_1.ValidConstraints.file;
474
473
  case 'number':
475
474
  case 'integer':
476
- return ValidConstraints.number;
475
+ return ValidationUtils_1.ValidConstraints.number;
477
476
  }
478
477
  if (this.isArrayType()) {
479
- return ValidConstraints.array;
478
+ return ValidationUtils_1.ValidConstraints.array;
480
479
  }
481
480
  return [];
482
481
  }
@@ -559,7 +558,7 @@ class Field extends Scriptable {
559
558
  const restriction = elem[key];
560
559
  const fn = Constraints[key];
561
560
  if (value instanceof Array && this.isArrayType()) {
562
- if (ValidConstraints.array.indexOf(key) !== -1) {
561
+ if (ValidationUtils_1.ValidConstraints.array.indexOf(key) !== -1) {
563
562
  return !fn(restriction, value).valid;
564
563
  }
565
564
  else {
@@ -606,10 +605,10 @@ class Field extends Scriptable {
606
605
  triggerValidationEvent(changes) {
607
606
  if (changes.valid) {
608
607
  if (this.valid) {
609
- this.dispatch(new Valid());
608
+ this.dispatch(new Events_1.Valid());
610
609
  }
611
610
  else {
612
- this.dispatch(new Invalid());
611
+ this.dispatch(new Events_1.Invalid());
613
612
  }
614
613
  }
615
614
  }
@@ -617,76 +616,69 @@ class Field extends Scriptable {
617
616
  const changes = this.evaluateConstraints();
618
617
  if (changes.valid) {
619
618
  this.triggerValidationEvent(changes);
620
- this.notifyDependents(new Change({ changes: Object.values(changes) }));
619
+ this.notifyDependents(new Events_1.Change({ changes: Object.values(changes) }));
621
620
  }
622
- return this.valid ? [] : [new ValidationError(this.id, [this._jsonModel.errorMessage])];
621
+ return this.valid ? [] : [new types_1.ValidationError(this.id, [this._jsonModel.errorMessage])];
623
622
  }
624
623
  importData(contextualDataModel) {
625
624
  this._bindToDataModel(contextualDataModel);
626
625
  const dataNode = this.getDataNode();
627
- if (dataNode !== undefined && dataNode !== NullDataValue && dataNode.$value !== this._jsonModel.value) {
628
- const changeAction = propertyChange('value', dataNode.$value, this._jsonModel.value);
626
+ if (dataNode !== undefined && dataNode !== EmptyDataValue_1.default && dataNode.$value !== this._jsonModel.value) {
627
+ const changeAction = (0, Events_1.propertyChange)('value', dataNode.$value, this._jsonModel.value);
629
628
  this._jsonModel.value = dataNode.$value;
630
629
  this.queueEvent(changeAction);
631
630
  }
632
631
  }
633
632
  defaultDataModel(name) {
634
- const value = staticFields.indexOf(this.fieldType) > -1 ? undefined : this.getDataNodeValue(this._jsonModel.value);
635
- return new DataValue(name, value, this.type || 'string');
633
+ const value = BaseNode_1.staticFields.indexOf(this.fieldType) > -1 ? undefined : this.getDataNodeValue(this._jsonModel.value);
634
+ return new DataValue_1.default(name, value, this.type || 'string');
636
635
  }
637
636
  getState() {
638
- return {
639
- ...super.getState(),
640
- editFormat: this.editFormat,
641
- displayFormat: this.displayFormat,
642
- editValue: this.editValue,
643
- displayValue: this.displayValue
644
- };
637
+ return Object.assign(Object.assign({}, super.getState()), { editFormat: this.editFormat, displayFormat: this.displayFormat, editValue: this.editValue, displayValue: this.displayValue, enabled: this.enabled, readOnly: this.readOnly });
645
638
  }
646
639
  }
647
640
  __decorate([
648
- dependencyTracked(),
649
- exclude('button', 'image', 'plain-text')
641
+ (0, BaseNode_1.dependencyTracked)(),
642
+ (0, BaseNode_1.exclude)('button', 'image', 'plain-text')
650
643
  ], Field.prototype, "readOnly", null);
651
644
  __decorate([
652
- dependencyTracked(),
653
- exclude('image', 'plain-text')
645
+ (0, BaseNode_1.dependencyTracked)(),
646
+ (0, BaseNode_1.exclude)('image', 'plain-text')
654
647
  ], Field.prototype, "enabled", null);
655
648
  __decorate([
656
- dependencyTracked()
649
+ (0, BaseNode_1.dependencyTracked)()
657
650
  ], Field.prototype, "valid", null);
658
651
  __decorate([
659
- dependencyTracked()
652
+ (0, BaseNode_1.dependencyTracked)()
660
653
  ], Field.prototype, "enum", null);
661
654
  __decorate([
662
- dependencyTracked()
655
+ (0, BaseNode_1.dependencyTracked)()
663
656
  ], Field.prototype, "enumNames", null);
664
657
  __decorate([
665
- dependencyTracked()
658
+ (0, BaseNode_1.dependencyTracked)()
666
659
  ], Field.prototype, "required", null);
667
660
  __decorate([
668
- include('date-input', 'number-input')
661
+ (0, BaseNode_1.include)('date-input', 'number-input')
669
662
  ], Field.prototype, "editValue", null);
670
663
  __decorate([
671
- dependencyTracked()
664
+ (0, BaseNode_1.dependencyTracked)()
672
665
  ], Field.prototype, "value", null);
673
666
  __decorate([
674
- include('text-input', 'date-input', 'file-input')
667
+ (0, BaseNode_1.include)('text-input', 'date-input', 'file-input')
675
668
  ], Field.prototype, "format", null);
676
669
  __decorate([
677
- include('text-input')
670
+ (0, BaseNode_1.include)('text-input')
678
671
  ], Field.prototype, "maxLength", null);
679
672
  __decorate([
680
- include('text-input')
673
+ (0, BaseNode_1.include)('text-input')
681
674
  ], Field.prototype, "minLength", null);
682
675
  __decorate([
683
- include('text-input')
676
+ (0, BaseNode_1.include)('text-input')
684
677
  ], Field.prototype, "pattern", null);
685
678
  __decorate([
686
- dependencyTracked()
679
+ (0, BaseNode_1.dependencyTracked)()
687
680
  ], Field.prototype, "exclusiveMinimum", null);
688
681
  __decorate([
689
- dependencyTracked()
682
+ (0, BaseNode_1.dependencyTracked)()
690
683
  ], Field.prototype, "exclusiveMaximum", null);
691
-
692
- export { Field as default };
684
+ exports.default = Field;
@@ -0,0 +1,72 @@
1
+ import Container from './Container';
2
+ import { Action, ContainerModel, FieldModel, FieldsetJson, FieldsetModel, FormModel, IFormFieldFactory } from './types/index';
3
+ export declare class Fieldset extends Container<FieldsetJson> implements FieldsetModel {
4
+ constructor(params: FieldsetJson, _options: {
5
+ form: FormModel;
6
+ parent: ContainerModel;
7
+ fieldFactory: IFormFieldFactory;
8
+ });
9
+ private _applyDefaults;
10
+ get type(): "array" | "object" | undefined;
11
+ get items(): (FieldModel | FieldsetModel)[];
12
+ get value(): null;
13
+ get fieldType(): string;
14
+ get enabled(): boolean | undefined;
15
+ set enabled(e: boolean | undefined);
16
+ get readOnly(): boolean | undefined;
17
+ set readOnly(e: boolean | undefined);
18
+ notifyChildren(action: Action): void;
19
+ getState(): {
20
+ enabled: boolean | undefined;
21
+ readOnly: boolean | undefined;
22
+ description?: string | undefined;
23
+ rules: import("./types/Json").Items<string> & {};
24
+ events: import("./types/Json").Items<string | string[] | undefined> & {};
25
+ enumNames?: string[] | undefined;
26
+ enum?: any[] | undefined;
27
+ accept?: string[] | undefined;
28
+ enforceEnum?: boolean | undefined;
29
+ exclusiveMinimum?: number | undefined;
30
+ exclusiveMaximum?: number | undefined;
31
+ format?: string | undefined;
32
+ maxFileSize?: string | number | undefined;
33
+ maxLength?: number | undefined;
34
+ maximum?: number | undefined;
35
+ maxItems?: number | undefined;
36
+ minOccur?: number | undefined;
37
+ maxOccur?: number | undefined;
38
+ minLength?: number | undefined;
39
+ minimum?: number | undefined;
40
+ minItems?: number | undefined;
41
+ pattern?: string | undefined;
42
+ required?: boolean | undefined;
43
+ step?: number | undefined;
44
+ type?: "object" | "array" | undefined;
45
+ validationExpression?: string | undefined;
46
+ uniqueItems?: boolean | undefined;
47
+ dataRef?: string | null | undefined;
48
+ lang?: string | undefined;
49
+ ':type': string;
50
+ label?: import("./types/Json").Label | undefined;
51
+ visible?: boolean | undefined;
52
+ name?: string | undefined;
53
+ constraintMessages?: import("./types/Json").ConstraintsMessages | undefined;
54
+ fieldType?: string | undefined;
55
+ errorMessage?: string | undefined;
56
+ properties: {
57
+ [key: string]: any;
58
+ };
59
+ repeatable: boolean | undefined;
60
+ screenReaderText?: string | undefined;
61
+ tooltip?: string | undefined;
62
+ altText?: string | undefined;
63
+ viewType?: string | undefined;
64
+ items: (import("./types/Json").FieldJson | import("./types/Json").ContainerJson)[] & any[];
65
+ initialItems?: number | undefined;
66
+ activeChild?: string | undefined;
67
+ index: number;
68
+ parent: undefined;
69
+ qualifiedName: any;
70
+ id: string;
71
+ };
72
+ }
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.Fieldset = void 0;
7
+ const Container_1 = __importDefault(require("./Container"));
8
+ const Events_1 = require("./controller/Events");
9
+ const defaults = {
10
+ visible: true,
11
+ enabled: true
12
+ };
13
+ const notifyChildrenAttributes = [
14
+ 'readOnly', 'enabled'
15
+ ];
16
+ class Fieldset extends Container_1.default {
17
+ constructor(params, _options) {
18
+ super(params, _options);
19
+ this._applyDefaults();
20
+ this.queueEvent(new Events_1.Initialize());
21
+ this.queueEvent(new Events_1.ExecuteRule());
22
+ }
23
+ _applyDefaults() {
24
+ Object.entries(defaults).map(([key, value]) => {
25
+ if (this._jsonModel[key] === undefined) {
26
+ this._jsonModel[key] = value;
27
+ }
28
+ });
29
+ if (this._jsonModel.dataRef && this._jsonModel.type === undefined) {
30
+ this._jsonModel.type = 'object';
31
+ }
32
+ }
33
+ get type() {
34
+ const ret = super.type;
35
+ if (ret === 'array' || ret === 'object') {
36
+ return ret;
37
+ }
38
+ return undefined;
39
+ }
40
+ get items() {
41
+ return super.items;
42
+ }
43
+ get value() {
44
+ return null;
45
+ }
46
+ get fieldType() {
47
+ return 'panel';
48
+ }
49
+ get enabled() {
50
+ if (this.parent.enabled !== undefined) {
51
+ return this.parent.enabled === false ? false : this._jsonModel.enabled;
52
+ }
53
+ else {
54
+ return this._jsonModel.enabled;
55
+ }
56
+ }
57
+ set enabled(e) {
58
+ this._setProperty('enabled', e, true, this.notifyChildren);
59
+ }
60
+ get readOnly() {
61
+ if (this.parent.readOnly !== undefined) {
62
+ return this.parent.readOnly === true ? true : this._jsonModel.readOnly;
63
+ }
64
+ else {
65
+ return this._jsonModel.readOnly;
66
+ }
67
+ }
68
+ set readOnly(e) {
69
+ this._setProperty('readOnly', e, true, this.notifyChildren);
70
+ }
71
+ notifyChildren(action) {
72
+ if (action.payload !== undefined && action.payload.changes !== undefined) {
73
+ for (const change of action.payload.changes) {
74
+ if (change.propertyName !== undefined && notifyChildrenAttributes.includes(change.propertyName)) {
75
+ this.items.forEach((child) => {
76
+ this.notifyDependents.call(child, (0, Events_1.propertyChange)(change.propertyName, child.getState()[change.propertyName], null));
77
+ if (child.fieldType === 'panel') {
78
+ this.notifyChildren.call(child, action);
79
+ }
80
+ });
81
+ }
82
+ }
83
+ }
84
+ }
85
+ getState() {
86
+ return Object.assign(Object.assign({}, super.getState()), { enabled: this.enabled, readOnly: this.readOnly });
87
+ }
88
+ }
89
+ exports.Fieldset = Fieldset;
@@ -1,4 +1,4 @@
1
- import { IFileObject } from './types/index.js';
1
+ import { IFileObject } from './types/index';
2
2
  export declare class FileObject implements IFileObject {
3
3
  data: any;
4
4
  mediaType: string;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FileObject = void 0;
4
+ class FileObject {
5
+ constructor(init) {
6
+ this.mediaType = 'application/octet-stream';
7
+ this.name = 'unknown';
8
+ this.size = 0;
9
+ Object.assign(this, init);
10
+ }
11
+ get type() {
12
+ return this.mediaType;
13
+ }
14
+ toJSON() {
15
+ return {
16
+ 'name': this.name,
17
+ 'size': this.size,
18
+ 'mediaType': this.mediaType,
19
+ 'data': this.data.toString()
20
+ };
21
+ }
22
+ equals(obj) {
23
+ return (this.data === obj.data &&
24
+ this.mediaType === obj.mediaType &&
25
+ this.name === obj.name &&
26
+ this.size === obj.size);
27
+ }
28
+ }
29
+ exports.FileObject = FileObject;
@@ -1,6 +1,6 @@
1
- import Field from './Field.js';
2
- import { FieldModel } from './types/index.js';
3
- import DataGroup from './data/DataGroup.js';
1
+ import Field from './Field';
2
+ import { FieldModel } from './types/index';
3
+ import DataGroup from './data/DataGroup';
4
4
  declare class FileUpload extends Field implements FieldModel {
5
5
  protected _getDefaults(): {
6
6
  accept: string[];