@aemforms/af-core 0.22.31 → 0.22.33

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 (98) hide show
  1. package/lib/{esm/BaseNode.d.ts → BaseNode.d.ts} +6 -6
  2. package/lib/{esm/BaseNode-f84b22c6.js → BaseNode.js} +58 -94
  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} +7 -7
  12. package/lib/{esm/Field.js → Field.js} +84 -104
  13. package/lib/{esm/Fieldset.d.ts → Fieldset.d.ts} +7 -7
  14. package/lib/{esm/Fieldset.js → Fieldset.js} +14 -43
  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} +12 -12
  20. package/lib/{esm/Form.js → Form.js} +34 -65
  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/Node.js +15 -0
  28. package/lib/{esm/Scriptable.d.ts → Scriptable.d.ts} +3 -3
  29. package/lib/{esm/Scriptable.js → Scriptable.js} +17 -38
  30. package/lib/{esm/controller → controller}/EventQueue.d.ts +3 -3
  31. package/lib/{esm/controller → controller}/EventQueue.js +8 -32
  32. package/lib/{esm/controller → controller}/Events.d.ts +2 -2
  33. package/lib/{esm/controller → controller}/Events.js +22 -26
  34. package/lib/{esm/controller → controller}/Logger.d.ts +2 -2
  35. package/lib/controller/Logger.js +33 -0
  36. package/lib/{esm/data → data}/DataGroup.d.ts +1 -1
  37. package/lib/{esm/data → data}/DataGroup.js +20 -38
  38. package/lib/{esm/data → data}/DataValue.d.ts +1 -1
  39. package/lib/{esm/data → data}/DataValue.js +4 -26
  40. package/lib/{esm/data → data}/EmptyDataValue.d.ts +1 -1
  41. package/lib/data/EmptyDataValue.js +34 -0
  42. package/lib/index.d.ts +21 -0
  43. package/lib/index.js +57 -0
  44. package/lib/{esm/rules → rules}/FunctionRuntime.d.ts +3 -3
  45. package/lib/{esm/rules → rules}/FunctionRuntime.js +52 -63
  46. package/lib/{esm/rules → rules}/RuleEngine.d.ts +1 -1
  47. package/lib/rules/RuleEngine.js +51 -0
  48. package/lib/{esm/types → types}/Json.d.ts +16 -16
  49. package/lib/types/Json.js +10 -0
  50. package/lib/{esm/types → types}/Model.d.ts +9 -9
  51. package/lib/types/Model.js +10 -0
  52. package/lib/types/index.d.ts +2 -0
  53. package/lib/types/index.js +18 -0
  54. package/lib/{esm/utils → utils}/DataRefParser.d.ts +4 -4
  55. package/lib/{esm/utils → utils}/DataRefParser.js +30 -45
  56. package/lib/{esm/utils → utils}/Fetch.d.ts +1 -1
  57. package/lib/utils/Fetch.js +74 -0
  58. package/lib/{esm/utils → utils}/FormCreationUtils.d.ts +1 -1
  59. package/lib/utils/FormCreationUtils.js +67 -0
  60. package/lib/{esm/utils → utils}/FormUtils.d.ts +2 -1
  61. package/lib/{esm/utils → utils}/FormUtils.js +62 -46
  62. package/lib/{esm/utils → utils}/JsonUtils.d.ts +1 -1
  63. package/lib/utils/JsonUtils.js +89 -0
  64. package/lib/{esm/utils → utils}/LogUtils.d.ts +1 -1
  65. package/lib/utils/LogUtils.js +10 -0
  66. package/lib/{esm/utils → utils}/SchemaUtils.d.ts +1 -1
  67. package/lib/{esm/utils → utils}/SchemaUtils.js +9 -29
  68. package/lib/{esm/utils → utils}/TranslationUtils.d.ts +2 -2
  69. package/lib/utils/TranslationUtils.js +125 -0
  70. package/lib/{esm/utils → utils}/ValidationUtils.d.ts +4 -4
  71. package/lib/{esm/utils → utils}/ValidationUtils.js +13 -35
  72. package/package.json +8 -13
  73. package/lib/cjs/index.cjs +0 -7426
  74. package/lib/esm/BaseNode.js +0 -26
  75. package/lib/esm/Checkbox.js +0 -63
  76. package/lib/esm/CheckboxGroup.js +0 -60
  77. package/lib/esm/DateField.js +0 -57
  78. package/lib/esm/FileObject.js +0 -48
  79. package/lib/esm/FileUpload.js +0 -141
  80. package/lib/esm/FormInstance.js +0 -129
  81. package/lib/esm/FormMetaData.js +0 -35
  82. package/lib/esm/InstanceManager.js +0 -58
  83. package/lib/esm/Node.js +0 -40
  84. package/lib/esm/controller/Logger.js +0 -52
  85. package/lib/esm/data/EmptyDataValue.js +0 -51
  86. package/lib/esm/index.d.ts +0 -21
  87. package/lib/esm/index.js +0 -55
  88. package/lib/esm/rules/RuleEngine.js +0 -76
  89. package/lib/esm/types/Json.js +0 -29
  90. package/lib/esm/types/Model.js +0 -30
  91. package/lib/esm/types/index.d.ts +0 -2
  92. package/lib/esm/types/index.js +0 -22
  93. package/lib/esm/utils/Fetch.js +0 -83
  94. package/lib/esm/utils/FormCreationUtils.js +0 -112
  95. package/lib/esm/utils/JsonUtils.js +0 -99
  96. package/lib/esm/utils/LogUtils.js +0 -28
  97. package/lib/esm/utils/TranslationUtils.js +0 -138
  98. /package/lib/{esm/Node.d.ts → Node.d.ts} +0 -0
@@ -1,41 +1,25 @@
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, d as dependencyTracked } from './BaseNode-f84b22c6.js';
22
- import { isRepeatable, deepClone } from './utils/JsonUtils.js';
23
- import Scriptable from './Scriptable.js';
24
- import { propertyChange, Initialize, ExecuteRule, RemoveItem } from './controller/Events.js';
25
- import DataGroup from './data/DataGroup.js';
26
- import './utils/DataRefParser.js';
27
- import './data/DataValue.js';
28
- import './data/EmptyDataValue.js';
29
- import './types/Json.js';
30
- import './utils/SchemaUtils.js';
31
-
32
- class Container extends Scriptable {
33
- _children = [];
34
- _childrenReference;
35
- _itemTemplate = null;
36
- fieldFactory;
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 JsonUtils_1 = require("./utils/JsonUtils");
13
+ const Scriptable_1 = __importDefault(require("./Scriptable"));
14
+ const Events_1 = require("./controller/Events");
15
+ const DataGroup_1 = __importDefault(require("./data/DataGroup"));
16
+ const BaseNode_1 = require("./BaseNode");
17
+ class Container extends Scriptable_1.default {
37
18
  constructor(json, _options) {
38
19
  super(json, { form: _options.form, parent: _options.parent });
20
+ this._children = [];
21
+ this._itemTemplate = null;
22
+ this._activeChild = null;
39
23
  this.fieldFactory = _options.fieldFactory;
40
24
  }
41
25
  ruleNodeReference() {
@@ -58,7 +42,7 @@ class Container extends Scriptable {
58
42
  this._childrenReference.pop();
59
43
  }
60
44
  const elems = this._children.splice(m, items2Remove);
61
- this.notifyDependents(propertyChange('items', elems, null));
45
+ this.notifyDependents((0, Events_1.propertyChange)('items', elems, null));
62
46
  }
63
47
  }
64
48
  get minItems() {
@@ -70,41 +54,34 @@ class Container extends Scriptable {
70
54
  get isContainer() {
71
55
  return true;
72
56
  }
73
- _activeChild = null;
74
57
  isSiteContainer(item) {
75
- return ':items' in item;
58
+ return (':items' in item || 'cqItems' in item) && !('fieldType' in item);
76
59
  }
77
60
  isAFormField(item) {
78
61
  return ('fieldType' in item || 'id' in item || 'name' in item || 'dataRef' in item || 'type' in item);
79
62
  }
80
63
  getItemsState(isRepeatableChild = false) {
81
- if (this._jsonModel.type === 'array' || isRepeatable(this._jsonModel) || isRepeatableChild) {
64
+ if (this._jsonModel.type === 'array' || (0, JsonUtils_1.isRepeatable)(this._jsonModel) || isRepeatableChild) {
82
65
  return this._children.map(x => {
83
- return { ...x.getState(true) };
66
+ return Object.assign({}, x.getState(true));
84
67
  });
85
68
  }
86
69
  else {
87
- return this._jsonModel.items.map(x => {
70
+ return this._jsonModel.items ? this._jsonModel.items.map(x => {
88
71
  if (this.isSiteContainer(x)) {
89
- return {
90
- ...x,
91
- ':items': this.walkSiteContainerItems(x)
92
- };
72
+ return Object.assign(Object.assign({}, x), { ':items': this.walkSiteContainerItems(x) });
93
73
  }
94
74
  else if (this.isAFormField(x)) {
95
- return { ...this.form.getElement(x?.id).getState(isRepeatableChild) };
75
+ return Object.assign({}, this.form.getElement(x === null || x === void 0 ? void 0 : x.id).getState(isRepeatableChild));
96
76
  }
97
77
  else {
98
78
  return x;
99
79
  }
100
- });
80
+ }) : [];
101
81
  }
102
82
  }
103
83
  getState(isRepeatableChild = false) {
104
- return {
105
- ...super.getState(isRepeatableChild),
106
- items: this.getItemsState(isRepeatableChild)
107
- };
84
+ return Object.assign(Object.assign({}, super.getState(isRepeatableChild)), { items: this.getItemsState(isRepeatableChild) });
108
85
  }
109
86
  _createChild(child, options) {
110
87
  const { parent = this } = options;
@@ -116,7 +93,7 @@ class Container extends Scriptable {
116
93
  walkSiteContainerItems(x) {
117
94
  return Object.fromEntries(Object.entries(x[':items']).map(([key, value]) => {
118
95
  if (this.isAFormField(value)) {
119
- return [key, this.form.getElement(value?.id).getState()];
96
+ return [key, this.form.getElement(value === null || value === void 0 ? void 0 : value.id).getState()];
120
97
  }
121
98
  else if (this.isSiteContainer(value)) {
122
99
  return this.walkSiteContainerItems(value);
@@ -160,10 +137,7 @@ class Container extends Scriptable {
160
137
  index = this._children.length;
161
138
  }
162
139
  const form = this.form;
163
- const itemTemplate = {
164
- index,
165
- ...deepClone(itemJson, cloneIds ? () => { return form.getUniqueId(); } : undefined)
166
- };
140
+ const itemTemplate = Object.assign({ index }, (0, JsonUtils_1.deepClone)(itemJson, cloneIds ? () => { return form.getUniqueId(); } : undefined));
167
141
  const retVal = this._createChild(itemTemplate, { parent: this, form: this.form });
168
142
  itemJson.id = retVal.id;
169
143
  this.form.fieldAdded(retVal);
@@ -186,7 +160,7 @@ class Container extends Scriptable {
186
160
  }
187
161
  else {
188
162
  const instance = type === 'array' ? [] : {};
189
- return new DataGroup(name, instance, type);
163
+ return new DataGroup_1.default(name, instance, type);
190
164
  }
191
165
  }
192
166
  _initialize() {
@@ -194,7 +168,7 @@ class Container extends Scriptable {
194
168
  const items = this._jsonModel.items || [];
195
169
  this._childrenReference = this._jsonModel.type == 'array' ? [] : {};
196
170
  if (this._jsonModel.type == 'array' && items.length === 1 && this.getDataNode() != null) {
197
- this._itemTemplate = deepClone(items[0]);
171
+ this._itemTemplate = (0, JsonUtils_1.deepClone)(items[0]);
198
172
  if (typeof (this._jsonModel.minItems) !== 'number') {
199
173
  this._jsonModel.minItems = 0;
200
174
  }
@@ -257,11 +231,11 @@ class Container extends Scriptable {
257
231
  dataNode.$addDataNode(instanceIndex, _data);
258
232
  }
259
233
  retVal._initialize();
260
- this.notifyDependents(propertyChange('items', retVal.getState(), null));
261
- retVal.dispatch(new Initialize());
262
- retVal.dispatch(new ExecuteRule());
234
+ this.notifyDependents((0, Events_1.propertyChange)('items', retVal.getState(), null));
235
+ retVal.dispatch(new Events_1.Initialize());
236
+ retVal.dispatch(new Events_1.ExecuteRule());
263
237
  for (let i = instanceIndex + 1; i < this._children.length; i++) {
264
- this._children[i].dispatch(new ExecuteRule());
238
+ this._children[i].dispatch(new Events_1.ExecuteRule());
265
239
  }
266
240
  }
267
241
  }
@@ -281,26 +255,27 @@ class Container extends Scriptable {
281
255
  this._children.splice(instanceIndex, 1);
282
256
  this.getDataNode().$removeDataNode(instanceIndex);
283
257
  for (let i = instanceIndex; i < this._children.length; i++) {
284
- this._children[i].dispatch(new ExecuteRule());
258
+ this._children[i].dispatch(new Events_1.ExecuteRule());
285
259
  }
286
- this.notifyDependents(propertyChange('items', null, state));
260
+ this.notifyDependents((0, Events_1.propertyChange)('items', null, state));
287
261
  }
288
262
  }
289
263
  }
290
264
  queueEvent(action) {
265
+ var _a;
291
266
  super.queueEvent(action);
292
- if (action.metadata?.dispatch) {
267
+ if ((_a = action.metadata) === null || _a === void 0 ? void 0 : _a.dispatch) {
293
268
  this.items.forEach(x => {
294
269
  x.queueEvent(action);
295
270
  });
296
271
  }
297
272
  }
298
273
  reset() {
299
- if (this.type === 'array' || isRepeatable(this._jsonModel)) {
274
+ if (this.type === 'array' || (0, JsonUtils_1.isRepeatable)(this._jsonModel)) {
300
275
  if (this.items.length > this._jsonModel.initialItems) {
301
276
  const itemsToBeRemoved = this.items.length - this._jsonModel.initialItems;
302
277
  for (let i = 0; i < itemsToBeRemoved; i++) {
303
- this.dispatch(new RemoveItem());
278
+ this.dispatch(new Events_1.RemoveItem());
304
279
  }
305
280
  }
306
281
  }
@@ -322,8 +297,8 @@ class Container extends Scriptable {
322
297
  this.syncDataAndFormModel(dataNode);
323
298
  }
324
299
  syncDataAndFormModel(contextualDataModel) {
325
- if (contextualDataModel?.$type === 'array' && this._itemTemplate != null) {
326
- const dataLength = contextualDataModel?.$value.length;
300
+ if ((contextualDataModel === null || contextualDataModel === void 0 ? void 0 : contextualDataModel.$type) === 'array' && this._itemTemplate != null) {
301
+ const dataLength = contextualDataModel === null || contextualDataModel === void 0 ? void 0 : contextualDataModel.$value.length;
327
302
  const itemsLength = this._children.length;
328
303
  const maxItems = this._jsonModel.maxItems === -1 ? dataLength : this._jsonModel.maxItems;
329
304
  const minItems = this._jsonModel.minItems;
@@ -356,24 +331,23 @@ class Container extends Scriptable {
356
331
  activeChild.activeChild = null;
357
332
  activeChild = temp;
358
333
  }
359
- const change = propertyChange('activeChild', c, this._activeChild);
334
+ const change = (0, Events_1.propertyChange)('activeChild', c, this._activeChild);
360
335
  this._activeChild = c;
361
336
  if (this.parent && c !== null) {
362
337
  this.parent.activeChild = this;
363
338
  }
364
- this._jsonModel.activeChild = c?.id;
339
+ this._jsonModel.activeChild = c === null || c === void 0 ? void 0 : c.id;
365
340
  this.notifyDependents(change);
366
341
  }
367
342
  }
368
343
  }
369
344
  __decorate([
370
- dependencyTracked()
345
+ (0, BaseNode_1.dependencyTracked)()
371
346
  ], Container.prototype, "maxItems", null);
372
347
  __decorate([
373
- dependencyTracked()
348
+ (0, BaseNode_1.dependencyTracked)()
374
349
  ], Container.prototype, "minItems", null);
375
350
  __decorate([
376
- dependencyTracked()
351
+ (0, BaseNode_1.dependencyTracked)()
377
352
  ], Container.prototype, "activeChild", null);
378
-
379
- export { Container as default };
353
+ exports.default = Container;
@@ -1,4 +1,4 @@
1
- import Field from './Field.js';
1
+ import Field from './Field';
2
2
  declare class DateField extends Field {
3
3
  protected _applyDefaults(): void;
4
4
  }
@@ -0,0 +1,26 @@
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
+ const Field_1 = __importDefault(require("./Field"));
7
+ const af_formatters_1 = require("@aemforms/af-formatters");
8
+ class DateField extends Field_1.default {
9
+ _applyDefaults() {
10
+ super._applyDefaults();
11
+ const locale = new Intl.DateTimeFormat().resolvedOptions().locale;
12
+ if (!this._jsonModel.editFormat) {
13
+ this._jsonModel.editFormat = 'short';
14
+ }
15
+ if (!this._jsonModel.displayFormat) {
16
+ this._jsonModel.displayFormat = this._jsonModel.editFormat;
17
+ }
18
+ if (!this._jsonModel.placeholder) {
19
+ this._jsonModel.placeholder = (0, af_formatters_1.parseDateSkeleton)(this._jsonModel.editFormat, locale);
20
+ }
21
+ if (!this._jsonModel.description) {
22
+ this._jsonModel.description = `To enter today's date use ${(0, af_formatters_1.formatDate)(new Date(), locale, this._jsonModel.editFormat)}`;
23
+ }
24
+ }
25
+ }
26
+ exports.default = DateField;
@@ -1,7 +1,7 @@
1
- import { ConstraintsMessages, ContainerModel, FieldJson, FieldModel, FormModel, ValidationError } from './types/index.js';
2
- import Scriptable from './Scriptable.js';
3
- import DataValue from './data/DataValue.js';
4
- import DataGroup from './data/DataGroup.js';
1
+ import { ConstraintsMessages, ContainerModel, FieldJson, FieldModel, FormModel, ValidationError } from './types';
2
+ import Scriptable from './Scriptable';
3
+ import DataValue from './data/DataValue';
4
+ import DataGroup from './data/DataGroup';
5
5
  declare class Field extends Scriptable<FieldJson> implements FieldModel {
6
6
  constructor(params: FieldJson, _options: {
7
7
  form: FormModel;
@@ -152,8 +152,8 @@ declare class Field extends Scriptable<FieldJson> implements FieldModel {
152
152
  enabled: boolean | undefined;
153
153
  readOnly: boolean | undefined;
154
154
  description?: string | undefined;
155
- rules: import("./types/Json.js").Items<string> & {};
156
- events: import("./types/Json.js").Items<string | string[] | undefined> & {};
155
+ rules: import("./types").Items<string> & {};
156
+ events: import("./types").Items<string | string[] | undefined> & {};
157
157
  enumNames?: string[] | undefined;
158
158
  enum?: any[] | undefined;
159
159
  accept?: string[] | undefined;
@@ -179,7 +179,7 @@ declare class Field extends Scriptable<FieldJson> implements FieldModel {
179
179
  dataRef?: string | null | undefined;
180
180
  lang?: string | undefined;
181
181
  ':type': string;
182
- label?: import("./types/Json.js").Label | undefined;
182
+ label?: import("./types").Label | undefined;
183
183
  visible?: boolean | undefined;
184
184
  name?: string | undefined;
185
185
  constraintMessages?: ConstraintsMessages | undefined;