@aemforms/af-core 0.22.25 → 0.22.29

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 (75) hide show
  1. package/lib/cjs/index.cjs +7345 -0
  2. package/lib/esm/BaseNode-d78cc1b0.js +478 -0
  3. package/lib/esm/BaseNode.d.ts +93 -0
  4. package/lib/esm/BaseNode.js +26 -0
  5. package/lib/esm/Checkbox.d.ts +79 -0
  6. package/lib/esm/Checkbox.js +63 -0
  7. package/lib/esm/CheckboxGroup.d.ts +18 -0
  8. package/lib/esm/CheckboxGroup.js +60 -0
  9. package/lib/esm/Container.d.ts +58 -0
  10. package/lib/esm/Container.js +379 -0
  11. package/lib/esm/DateField.d.ts +5 -0
  12. package/lib/esm/DateField.js +57 -0
  13. package/lib/esm/Field.d.ts +206 -0
  14. package/lib/esm/Field.js +692 -0
  15. package/lib/esm/Fieldset.d.ts +16 -0
  16. package/lib/esm/Fieldset.js +78 -0
  17. package/lib/esm/FileObject.d.ts +16 -0
  18. package/lib/esm/FileObject.js +48 -0
  19. package/lib/esm/FileUpload.d.ts +22 -0
  20. package/lib/esm/FileUpload.js +141 -0
  21. package/lib/esm/Form.d.ts +113 -0
  22. package/lib/esm/Form.js +208 -0
  23. package/lib/esm/FormInstance.d.ts +13 -0
  24. package/lib/esm/FormInstance.js +129 -0
  25. package/lib/esm/FormMetaData.d.ts +7 -0
  26. package/lib/esm/FormMetaData.js +35 -0
  27. package/lib/esm/InstanceManager.d.ts +9 -0
  28. package/lib/esm/InstanceManager.js +58 -0
  29. package/lib/esm/Node.d.ts +7 -0
  30. package/lib/esm/Node.js +40 -0
  31. package/lib/esm/Scriptable.d.ts +17 -0
  32. package/lib/esm/Scriptable.js +190 -0
  33. package/lib/esm/controller/EventQueue.d.ts +17 -0
  34. package/lib/esm/controller/EventQueue.js +108 -0
  35. package/lib/esm/controller/Events.d.ts +85 -0
  36. package/lib/esm/controller/Events.js +171 -0
  37. package/lib/esm/controller/Logger.d.ts +11 -0
  38. package/lib/esm/controller/Logger.js +52 -0
  39. package/lib/esm/data/DataGroup.d.ts +20 -0
  40. package/lib/esm/data/DataGroup.js +100 -0
  41. package/lib/esm/data/DataValue.d.ts +16 -0
  42. package/lib/esm/data/DataValue.js +68 -0
  43. package/lib/esm/data/EmptyDataValue.d.ts +14 -0
  44. package/lib/esm/data/EmptyDataValue.js +51 -0
  45. package/lib/esm/index.d.ts +21 -0
  46. package/lib/esm/index.js +55 -0
  47. package/lib/esm/rules/FunctionRuntime.d.ts +51 -0
  48. package/lib/esm/rules/FunctionRuntime.js +345 -0
  49. package/lib/esm/rules/RuleEngine.d.ts +12 -0
  50. package/lib/esm/rules/RuleEngine.js +76 -0
  51. package/lib/esm/types/Json.d.ts +119 -0
  52. package/lib/esm/types/Json.js +29 -0
  53. package/lib/esm/types/Model.d.ts +131 -0
  54. package/lib/esm/types/Model.js +30 -0
  55. package/lib/esm/types/index.d.ts +2 -0
  56. package/lib/esm/types/index.js +22 -0
  57. package/lib/esm/utils/DataRefParser.d.ts +27 -0
  58. package/lib/esm/utils/DataRefParser.js +247 -0
  59. package/lib/esm/utils/Fetch.d.ts +8 -0
  60. package/lib/esm/utils/Fetch.js +83 -0
  61. package/lib/esm/utils/FormCreationUtils.d.ts +9 -0
  62. package/lib/esm/utils/FormCreationUtils.js +112 -0
  63. package/lib/esm/utils/FormUtils.d.ts +12 -0
  64. package/lib/esm/utils/FormUtils.js +212 -0
  65. package/lib/esm/utils/JsonUtils.d.ts +11 -0
  66. package/lib/esm/utils/JsonUtils.js +99 -0
  67. package/lib/esm/utils/LogUtils.d.ts +4 -0
  68. package/lib/esm/utils/LogUtils.js +28 -0
  69. package/lib/esm/utils/SchemaUtils.d.ts +3 -0
  70. package/lib/esm/utils/SchemaUtils.js +93 -0
  71. package/lib/esm/utils/TranslationUtils.d.ts +11 -0
  72. package/lib/esm/utils/TranslationUtils.js +138 -0
  73. package/lib/esm/utils/ValidationUtils.d.ts +19 -0
  74. package/lib/esm/utils/ValidationUtils.js +300 -0
  75. package/package.json +14 -2
@@ -0,0 +1,63 @@
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 Field from './Field.js';
22
+ import { Constraints } from './utils/ValidationUtils.js';
23
+ import './BaseNode-d78cc1b0.js';
24
+ import './controller/Events.js';
25
+ import './utils/DataRefParser.js';
26
+ import './data/DataGroup.js';
27
+ import './data/DataValue.js';
28
+ import './data/EmptyDataValue.js';
29
+ import './types/Model.js';
30
+ import './Scriptable.js';
31
+ import './utils/SchemaUtils.js';
32
+ import '@aemforms/af-formatters';
33
+ import './utils/FormUtils.js';
34
+ import './utils/JsonUtils.js';
35
+ import './types/Json.js';
36
+ import './FileObject.js';
37
+
38
+ const requiredConstraint = (offValue) => (constraint, value) => {
39
+ const valid = Constraints.required(constraint, value).valid && (!constraint || value != offValue);
40
+ return { valid, value };
41
+ };
42
+ class Checkbox extends Field {
43
+ offValue() {
44
+ const opts = this.enum;
45
+ return opts.length > 1 ? opts[1] : null;
46
+ }
47
+ _getConstraintObject() {
48
+ const baseConstraints = { ...super._getConstraintObject() };
49
+ baseConstraints.required = requiredConstraint(this.offValue());
50
+ return baseConstraints;
51
+ }
52
+ _getDefaults() {
53
+ return {
54
+ ...super._getDefaults(),
55
+ enforceEnum: true
56
+ };
57
+ }
58
+ get enum() {
59
+ return this._jsonModel.enum || [];
60
+ }
61
+ }
62
+
63
+ export { Checkbox as default };
@@ -0,0 +1,18 @@
1
+ import Field from './Field.js';
2
+ import { ContainerModel, FieldJson, FormModel } from './types/index.js';
3
+ declare class CheckboxGroup extends Field {
4
+ constructor(params: FieldJson, _options: {
5
+ form: FormModel;
6
+ parent: ContainerModel;
7
+ });
8
+ protected _getFallbackType(): string | undefined;
9
+ protected _getDefaults(): {
10
+ enforceEnum: boolean;
11
+ enum: never[];
12
+ readOnly: boolean;
13
+ enabled: boolean;
14
+ visible: boolean;
15
+ type: string | undefined;
16
+ };
17
+ }
18
+ export default CheckboxGroup;
@@ -0,0 +1,60 @@
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 Field from './Field.js';
22
+ import './BaseNode-d78cc1b0.js';
23
+ import './controller/Events.js';
24
+ import './utils/DataRefParser.js';
25
+ import './data/DataGroup.js';
26
+ import './data/DataValue.js';
27
+ import './data/EmptyDataValue.js';
28
+ import './types/Model.js';
29
+ import './utils/ValidationUtils.js';
30
+ import './utils/FormUtils.js';
31
+ import './utils/JsonUtils.js';
32
+ import './types/Json.js';
33
+ import './utils/SchemaUtils.js';
34
+ import './FileObject.js';
35
+ import './Scriptable.js';
36
+ import '@aemforms/af-formatters';
37
+
38
+ class CheckboxGroup extends Field {
39
+ constructor(params, _options) {
40
+ super(params, _options);
41
+ }
42
+ _getFallbackType() {
43
+ const fallbackType = super._getFallbackType();
44
+ if (typeof fallbackType === 'string') {
45
+ return `${fallbackType}[]`;
46
+ }
47
+ else {
48
+ return 'string[]';
49
+ }
50
+ }
51
+ _getDefaults() {
52
+ return {
53
+ ...super._getDefaults(),
54
+ enforceEnum: true,
55
+ enum: []
56
+ };
57
+ }
58
+ }
59
+
60
+ export { CheckboxGroup as default };
@@ -0,0 +1,58 @@
1
+ import { Action, BaseModel, ContainerJson, ContainerModel, FieldModel, FieldsetModel, FormModel, IFormFieldFactory, RulesJson } from './types/index.js';
2
+ import Scriptable from './Scriptable.js';
3
+ import DataGroup from './data/DataGroup.js';
4
+ declare abstract class Container<T extends ContainerJson & RulesJson> extends Scriptable<T> implements ContainerModel {
5
+ protected _children: Array<FieldModel | FieldsetModel>;
6
+ protected _childrenReference: any;
7
+ private _itemTemplate;
8
+ private fieldFactory;
9
+ constructor(json: T, _options: {
10
+ form: FormModel;
11
+ parent: ContainerModel;
12
+ fieldFactory: IFormFieldFactory;
13
+ });
14
+ ruleNodeReference(): any;
15
+ get items(): (FieldModel | FieldsetModel)[];
16
+ get maxItems(): number;
17
+ set maxItems(m: number);
18
+ get minItems(): number;
19
+ hasDynamicItems(): boolean;
20
+ get isContainer(): boolean;
21
+ private _activeChild;
22
+ private isSiteContainer;
23
+ private isAFormField;
24
+ private getItemsState;
25
+ getState(isRepeatableChild?: boolean): T & {
26
+ items: any[];
27
+ properties: {
28
+ [key: string]: any;
29
+ };
30
+ index: number;
31
+ parent: undefined;
32
+ qualifiedName: any;
33
+ events: {};
34
+ rules: {};
35
+ repeatable: boolean | undefined;
36
+ ':type': string;
37
+ id: string;
38
+ };
39
+ private _createChild;
40
+ private walkSiteContainerItems;
41
+ private _addChildToRuleNode;
42
+ private _addChild;
43
+ indexOf(f: FieldModel | FieldsetModel): number;
44
+ defaultDataModel(name: string): DataGroup | undefined;
45
+ _initialize(): void;
46
+ private _initializeSiteContainer;
47
+ addItem(action: Action): void;
48
+ removeItem(action: Action): void;
49
+ queueEvent(action: Action): void;
50
+ reset(): void;
51
+ validate(): import("./types/Model.js").ValidationError[];
52
+ dispatch(action: Action): void;
53
+ importData(contextualDataModel: DataGroup): void;
54
+ syncDataAndFormModel(contextualDataModel?: DataGroup): void;
55
+ get activeChild(): BaseModel | null;
56
+ set activeChild(c: BaseModel | null);
57
+ }
58
+ export default Container;
@@ -0,0 +1,379 @@
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-d78cc1b0.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;
37
+ constructor(json, _options) {
38
+ super(json, { form: _options.form, parent: _options.parent });
39
+ this.fieldFactory = _options.fieldFactory;
40
+ }
41
+ ruleNodeReference() {
42
+ return this._childrenReference;
43
+ }
44
+ get items() {
45
+ return this._children;
46
+ }
47
+ get maxItems() {
48
+ return this._jsonModel.maxItems;
49
+ }
50
+ set maxItems(m) {
51
+ this._jsonModel.maxItems = m;
52
+ const minItems = this._jsonModel.minItems || 1;
53
+ const itemsLength = this._children.length;
54
+ const items2Remove = Math.min(itemsLength - m, itemsLength - minItems);
55
+ if (items2Remove > 0) {
56
+ for (let i = 0; i < items2Remove; i++) {
57
+ this.getDataNode().$removeDataNode(m + i);
58
+ this._childrenReference.pop();
59
+ }
60
+ const elems = this._children.splice(m, items2Remove);
61
+ this.notifyDependents(propertyChange('items', elems, null));
62
+ }
63
+ }
64
+ get minItems() {
65
+ return this._jsonModel.minItems;
66
+ }
67
+ hasDynamicItems() {
68
+ return this._itemTemplate != null;
69
+ }
70
+ get isContainer() {
71
+ return true;
72
+ }
73
+ _activeChild = null;
74
+ isSiteContainer(item) {
75
+ return ':items' in item;
76
+ }
77
+ isAFormField(item) {
78
+ return ('fieldType' in item || 'id' in item || 'name' in item || 'dataRef' in item || 'type' in item);
79
+ }
80
+ getItemsState(isRepeatableChild = false) {
81
+ if (this._jsonModel.type === 'array' || isRepeatable(this._jsonModel) || isRepeatableChild) {
82
+ return this._children.map(x => {
83
+ return { ...x.getState(true) };
84
+ });
85
+ }
86
+ else {
87
+ return this._jsonModel.items.map(x => {
88
+ if (this.isSiteContainer(x)) {
89
+ return {
90
+ ...x,
91
+ ':items': this.walkSiteContainerItems(x)
92
+ };
93
+ }
94
+ else if (this.isAFormField(x)) {
95
+ return { ...this.form.getElement(x?.id).getState(isRepeatableChild) };
96
+ }
97
+ else {
98
+ return x;
99
+ }
100
+ });
101
+ }
102
+ }
103
+ getState(isRepeatableChild = false) {
104
+ return {
105
+ ...super.getState(isRepeatableChild),
106
+ items: this.getItemsState(isRepeatableChild)
107
+ };
108
+ }
109
+ _createChild(child, options) {
110
+ const { parent = this } = options;
111
+ return this.fieldFactory.createField(child, {
112
+ form: options.form,
113
+ parent
114
+ });
115
+ }
116
+ walkSiteContainerItems(x) {
117
+ return Object.fromEntries(Object.entries(x[':items']).map(([key, value]) => {
118
+ if (this.isAFormField(value)) {
119
+ return [key, this.form.getElement(value?.id).getState()];
120
+ }
121
+ else if (this.isSiteContainer(value)) {
122
+ return this.walkSiteContainerItems(value);
123
+ }
124
+ else {
125
+ return [key, value];
126
+ }
127
+ }));
128
+ }
129
+ _addChildToRuleNode(child, options) {
130
+ const self = this;
131
+ const { parent = this } = options;
132
+ const name = parent.type == 'array' ? parent._children.length + '' : child.name || '';
133
+ if (name.length > 0) {
134
+ Object.defineProperty(parent._childrenReference, name, {
135
+ get: () => {
136
+ if (child.isContainer && child.hasDynamicItems()) {
137
+ self.ruleEngine.trackDependency(child);
138
+ }
139
+ if (self.hasDynamicItems()) {
140
+ self.ruleEngine.trackDependency(self);
141
+ if (this._children[name] !== undefined) {
142
+ return this._children[name].getRuleNode();
143
+ }
144
+ }
145
+ else {
146
+ return child.getRuleNode();
147
+ }
148
+ },
149
+ configurable: true,
150
+ enumerable: true
151
+ });
152
+ }
153
+ }
154
+ _addChild(itemJson, index, cloneIds = false) {
155
+ let nonTransparentParent = this;
156
+ while (nonTransparentParent != null && nonTransparentParent.isTransparent()) {
157
+ nonTransparentParent = nonTransparentParent.parent;
158
+ }
159
+ if (typeof index !== 'number' || index > nonTransparentParent._children.length) {
160
+ index = this._children.length;
161
+ }
162
+ const form = this.form;
163
+ const itemTemplate = {
164
+ index,
165
+ ...deepClone(itemJson, cloneIds ? () => { return form.getUniqueId(); } : undefined)
166
+ };
167
+ const retVal = this._createChild(itemTemplate, { parent: this, form: this.form });
168
+ itemJson.id = retVal.id;
169
+ this.form.fieldAdded(retVal);
170
+ this._addChildToRuleNode(retVal, { parent: nonTransparentParent });
171
+ if (index === this._children.length) {
172
+ this._children.push(retVal);
173
+ }
174
+ else {
175
+ this._children.splice(index, 0, retVal);
176
+ }
177
+ return retVal;
178
+ }
179
+ indexOf(f) {
180
+ return this._children.indexOf(f);
181
+ }
182
+ defaultDataModel(name) {
183
+ const type = this._jsonModel.type || undefined;
184
+ if (type === undefined) {
185
+ return undefined;
186
+ }
187
+ else {
188
+ const instance = type === 'array' ? [] : {};
189
+ return new DataGroup(name, instance, type);
190
+ }
191
+ }
192
+ _initialize() {
193
+ super._initialize();
194
+ const items = this._jsonModel.items || [];
195
+ this._childrenReference = this._jsonModel.type == 'array' ? [] : {};
196
+ if (this._jsonModel.type == 'array' && items.length === 1 && this.getDataNode() != null) {
197
+ this._itemTemplate = deepClone(items[0]);
198
+ if (typeof (this._jsonModel.minItems) !== 'number') {
199
+ this._jsonModel.minItems = 0;
200
+ }
201
+ if (typeof (this._jsonModel.maxItems) !== 'number') {
202
+ this._jsonModel.maxItems = -1;
203
+ }
204
+ if (typeof (this._jsonModel.initialItems) !== 'number') {
205
+ this._jsonModel.initialItems = Math.max(1, this._jsonModel.minItems);
206
+ }
207
+ for (let i = 0; i < this._jsonModel.initialItems; i++) {
208
+ const child = this._addChild(this._itemTemplate, null, true);
209
+ items[0].id = child.id;
210
+ child._initialize();
211
+ }
212
+ }
213
+ else if (items.length > 0) {
214
+ items.forEach((item) => {
215
+ if (this.isSiteContainer(item)) {
216
+ this._initializeSiteContainer(item);
217
+ }
218
+ else if (this.isAFormField(item)) {
219
+ const child = this._addChild(item);
220
+ child._initialize();
221
+ }
222
+ else {
223
+ this.form.logger.warn('A container item was not initialized.');
224
+ }
225
+ });
226
+ this._jsonModel.minItems = this._children.length;
227
+ this._jsonModel.maxItems = this._children.length;
228
+ this._jsonModel.initialItems = this._children.length;
229
+ }
230
+ else {
231
+ this.form.logger.warn('A container exists with no items.');
232
+ }
233
+ this.setupRuleNode();
234
+ }
235
+ _initializeSiteContainer(item) {
236
+ Object.entries(item[':items']).forEach(([key, value]) => {
237
+ if (this.isAFormField(value)) {
238
+ const child = this._addChild(value);
239
+ child._initialize();
240
+ }
241
+ else if (this.isSiteContainer(value)) {
242
+ return this._initializeSiteContainer(value);
243
+ }
244
+ });
245
+ }
246
+ addItem(action) {
247
+ if ((action.type === 'addItem' || action.type == 'addInstance') && this._itemTemplate != null) {
248
+ if ((this._jsonModel.maxItems === -1) || (this._children.length < this._jsonModel.maxItems)) {
249
+ const dataNode = this.getDataNode();
250
+ let instanceIndex = action.payload;
251
+ const retVal = this._addChild(this._itemTemplate, action.payload, true);
252
+ if (typeof instanceIndex !== 'number' || instanceIndex > this._children.length) {
253
+ instanceIndex = this._children.length;
254
+ }
255
+ const _data = retVal.defaultDataModel(instanceIndex);
256
+ if (_data) {
257
+ dataNode.$addDataNode(instanceIndex, _data);
258
+ }
259
+ retVal._initialize();
260
+ this.notifyDependents(propertyChange('items', retVal.getState(), null));
261
+ retVal.dispatch(new Initialize());
262
+ retVal.dispatch(new ExecuteRule());
263
+ for (let i = instanceIndex + 1; i < this._children.length; i++) {
264
+ this._children[i].dispatch(new ExecuteRule());
265
+ }
266
+ }
267
+ }
268
+ }
269
+ removeItem(action) {
270
+ if ((action.type === 'removeItem' || action.type == 'removeInstance') && this._itemTemplate != null) {
271
+ if (this._children.length == 0) {
272
+ return;
273
+ }
274
+ let instanceIndex = action.payload;
275
+ if (typeof instanceIndex !== 'number') {
276
+ instanceIndex = this._children.length - 1;
277
+ }
278
+ const state = this._children[instanceIndex].getState();
279
+ if (this._children.length > this._jsonModel.minItems) {
280
+ this._childrenReference.pop();
281
+ this._children.splice(instanceIndex, 1);
282
+ this.getDataNode().$removeDataNode(instanceIndex);
283
+ for (let i = instanceIndex; i < this._children.length; i++) {
284
+ this._children[i].dispatch(new ExecuteRule());
285
+ }
286
+ this.notifyDependents(propertyChange('items', null, state));
287
+ }
288
+ }
289
+ }
290
+ queueEvent(action) {
291
+ super.queueEvent(action);
292
+ if (action.metadata?.dispatch) {
293
+ this.items.forEach(x => {
294
+ x.queueEvent(action);
295
+ });
296
+ }
297
+ }
298
+ reset() {
299
+ if (this.type === 'array' || isRepeatable(this._jsonModel)) {
300
+ if (this.items.length > this._jsonModel.initialItems) {
301
+ const itemsToBeRemoved = this.items.length - this._jsonModel.initialItems;
302
+ for (let i = 0; i < itemsToBeRemoved; i++) {
303
+ this.dispatch(new RemoveItem());
304
+ }
305
+ }
306
+ }
307
+ this.items.forEach(x => {
308
+ x.reset();
309
+ });
310
+ }
311
+ validate() {
312
+ return this.items.flatMap(x => {
313
+ return x.validate();
314
+ }).filter(x => x.fieldName !== '');
315
+ }
316
+ dispatch(action) {
317
+ super.dispatch(action);
318
+ }
319
+ importData(contextualDataModel) {
320
+ this._bindToDataModel(contextualDataModel);
321
+ const dataNode = this.getDataNode() || contextualDataModel;
322
+ this.syncDataAndFormModel(dataNode);
323
+ }
324
+ syncDataAndFormModel(contextualDataModel) {
325
+ if (contextualDataModel?.$type === 'array' && this._itemTemplate != null) {
326
+ const dataLength = contextualDataModel?.$value.length;
327
+ const itemsLength = this._children.length;
328
+ const maxItems = this._jsonModel.maxItems === -1 ? dataLength : this._jsonModel.maxItems;
329
+ const minItems = this._jsonModel.minItems;
330
+ let items2Add = Math.min(dataLength - itemsLength, maxItems - itemsLength);
331
+ const items2Remove = Math.min(itemsLength - dataLength, itemsLength - minItems);
332
+ while (items2Add > 0) {
333
+ items2Add--;
334
+ const child = this._addChild(this._itemTemplate);
335
+ child._initialize();
336
+ }
337
+ if (items2Remove > 0) {
338
+ this._children.splice(dataLength, items2Remove);
339
+ for (let i = 0; i < items2Remove; i++) {
340
+ this._childrenReference.pop();
341
+ }
342
+ }
343
+ }
344
+ this._children.forEach(x => {
345
+ x.importData(contextualDataModel);
346
+ });
347
+ }
348
+ get activeChild() {
349
+ return this._activeChild;
350
+ }
351
+ set activeChild(c) {
352
+ if (c !== this._activeChild) {
353
+ let activeChild = this._activeChild;
354
+ while (activeChild instanceof Container) {
355
+ const temp = activeChild.activeChild;
356
+ activeChild.activeChild = null;
357
+ activeChild = temp;
358
+ }
359
+ const change = propertyChange('activeChild', c, this._activeChild);
360
+ this._activeChild = c;
361
+ if (this.parent && c !== null) {
362
+ this.parent.activeChild = this;
363
+ }
364
+ this._jsonModel.activeChild = c?.id;
365
+ this.notifyDependents(change);
366
+ }
367
+ }
368
+ }
369
+ __decorate([
370
+ dependencyTracked()
371
+ ], Container.prototype, "maxItems", null);
372
+ __decorate([
373
+ dependencyTracked()
374
+ ], Container.prototype, "minItems", null);
375
+ __decorate([
376
+ dependencyTracked()
377
+ ], Container.prototype, "activeChild", null);
378
+
379
+ export { Container as default };
@@ -0,0 +1,5 @@
1
+ import Field from './Field.js';
2
+ declare class DateField extends Field {
3
+ protected _applyDefaults(): void;
4
+ }
5
+ export default DateField;
@@ -0,0 +1,57 @@
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 Field from './Field.js';
22
+ import { parseDateSkeleton, formatDate } from '@aemforms/af-formatters';
23
+ import './BaseNode-d78cc1b0.js';
24
+ import './controller/Events.js';
25
+ import './utils/DataRefParser.js';
26
+ import './data/DataGroup.js';
27
+ import './data/DataValue.js';
28
+ import './data/EmptyDataValue.js';
29
+ import './types/Model.js';
30
+ import './utils/ValidationUtils.js';
31
+ import './utils/FormUtils.js';
32
+ import './utils/JsonUtils.js';
33
+ import './types/Json.js';
34
+ import './utils/SchemaUtils.js';
35
+ import './FileObject.js';
36
+ import './Scriptable.js';
37
+
38
+ class DateField extends Field {
39
+ _applyDefaults() {
40
+ super._applyDefaults();
41
+ const locale = new Intl.DateTimeFormat().resolvedOptions().locale;
42
+ if (!this._jsonModel.editFormat) {
43
+ this._jsonModel.editFormat = 'short';
44
+ }
45
+ if (!this._jsonModel.displayFormat) {
46
+ this._jsonModel.displayFormat = this._jsonModel.editFormat;
47
+ }
48
+ if (!this._jsonModel.placeholder) {
49
+ this._jsonModel.placeholder = parseDateSkeleton(this._jsonModel.editFormat, locale);
50
+ }
51
+ if (!this._jsonModel.description) {
52
+ this._jsonModel.description = `To enter today's date use ${formatDate(new Date(), locale, this._jsonModel.editFormat)}`;
53
+ }
54
+ }
55
+ }
56
+
57
+ export { DateField as default };