@aemforms/af-core 0.22.69 → 0.22.70

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.
@@ -1250,7 +1250,7 @@ class Container extends Scriptable {
1250
1250
  _itemTemplate = null;
1251
1251
  fieldFactory;
1252
1252
  constructor(json, _options) {
1253
- super(json, { form: _options.form, parent: _options.parent });
1253
+ super(json, { form: _options.form, parent: _options.parent, mode: _options.mode });
1254
1254
  this.fieldFactory = _options.fieldFactory;
1255
1255
  }
1256
1256
  _getDefaults() {
@@ -1360,11 +1360,7 @@ class Container extends Scriptable {
1360
1360
  };
1361
1361
  }
1362
1362
  _createChild(child, options) {
1363
- const { parent = this } = options;
1364
- return this.fieldFactory.createField(child, {
1365
- form: options.form,
1366
- parent
1367
- });
1363
+ return this.fieldFactory.createField(child, options);
1368
1364
  }
1369
1365
  walkSiteContainerItems(x) {
1370
1366
  return Object.fromEntries(Object.entries(x[':items']).map(([key, value]) => {
@@ -1416,7 +1412,7 @@ class Container extends Scriptable {
1416
1412
  });
1417
1413
  }
1418
1414
  }
1419
- _addChild(itemJson, index, cloneIds = false) {
1415
+ _addChild(itemJson, index, cloneIds = false, mode = 'create') {
1420
1416
  let nonTransparentParent = this;
1421
1417
  while (nonTransparentParent != null && nonTransparentParent.isTransparent()) {
1422
1418
  nonTransparentParent = nonTransparentParent.parent;
@@ -1429,7 +1425,7 @@ class Container extends Scriptable {
1429
1425
  index,
1430
1426
  ...deepClone(itemJson, cloneIds ? () => { return form.getUniqueId(); } : undefined)
1431
1427
  };
1432
- const retVal = this._createChild(itemTemplate, { parent: this, form: this.form });
1428
+ const retVal = this._createChild(itemTemplate, { parent: this, form: this.form, mode });
1433
1429
  itemJson.id = retVal.id;
1434
1430
  this.form.fieldAdded(retVal);
1435
1431
  this._addChildToRuleNode(retVal, { parent: nonTransparentParent });
@@ -1485,7 +1481,7 @@ class Container extends Scriptable {
1485
1481
  itemTemplate = deepClone(items[i]);
1486
1482
  itemTemplate.repeatable = undefined;
1487
1483
  }
1488
- child = this._addChild(itemTemplate, undefined, i > this._jsonModel.items.length - 1);
1484
+ child = this._addChild(itemTemplate, undefined, i > this._jsonModel.items.length - 1, mode);
1489
1485
  }
1490
1486
  else {
1491
1487
  child = this._addChild(this._itemTemplate, undefined, i > this._jsonModel.items.length - 1);
@@ -1502,7 +1498,7 @@ class Container extends Scriptable {
1502
1498
  this._initializeSiteContainer(item);
1503
1499
  }
1504
1500
  else if (this.isAFormField(item)) {
1505
- const child = this._addChild(item);
1501
+ const child = this._addChild(item, undefined, false, mode);
1506
1502
  child._initialize(mode);
1507
1503
  }
1508
1504
  else {
@@ -2866,9 +2862,11 @@ class RuleEngine {
2866
2862
  class Fieldset extends Container {
2867
2863
  constructor(params, _options) {
2868
2864
  super(params, _options);
2869
- this._applyDefaults();
2870
- this.queueEvent(new Initialize());
2871
- this.queueEvent(new ExecuteRule());
2865
+ if (_options.mode !== 'restore') {
2866
+ this._applyDefaults();
2867
+ this.queueEvent(new Initialize());
2868
+ this.queueEvent(new ExecuteRule());
2869
+ }
2872
2870
  }
2873
2871
  _getDefaults() {
2874
2872
  return {
@@ -3211,9 +3209,11 @@ const validTypes = ['string', 'number', 'integer', 'boolean', 'file', 'string[]'
3211
3209
  class Field extends Scriptable {
3212
3210
  constructor(params, _options) {
3213
3211
  super(params, _options);
3214
- this._applyDefaults();
3215
- this.queueEvent(new Initialize());
3216
- this.queueEvent(new ExecuteRule());
3212
+ if (_options.mode !== 'restore') {
3213
+ this._applyDefaults();
3214
+ this.queueEvent(new Initialize());
3215
+ this.queueEvent(new ExecuteRule());
3216
+ }
3217
3217
  }
3218
3218
  _ruleNodeReference = [];
3219
3219
  _initialize() {
@@ -23,6 +23,7 @@ export declare abstract class BaseNode<T extends BaseJson> implements BaseModel
23
23
  constructor(params: T, _options: {
24
24
  form: FormModel;
25
25
  parent: ContainerModel;
26
+ mode?: 'create' | 'restore';
26
27
  });
27
28
  abstract value: Primitives;
28
29
  abstract reset(): any;
@@ -1,9 +1,10 @@
1
1
  import Field from './Field';
2
- import { ContainerModel, FieldJson, FormModel } from './types/index';
2
+ import { ContainerModel, FieldJson, FormCreationMode, FormModel } from './types/index';
3
3
  declare class CheckboxGroup extends Field {
4
4
  constructor(params: FieldJson, _options: {
5
5
  form: FormModel;
6
6
  parent: ContainerModel;
7
+ mode: FormCreationMode;
7
8
  });
8
9
  protected _getFallbackType(): string | undefined;
9
10
  protected _getDefaults(): {
@@ -10,7 +10,7 @@ declare abstract class Container<T extends ContainerJson & RulesJson> extends Sc
10
10
  form: FormModel;
11
11
  parent: ContainerModel;
12
12
  fieldFactory: IFormFieldFactory;
13
- mode: 'create' | 'restore';
13
+ mode?: 'create' | 'restore';
14
14
  });
15
15
  protected _getDefaults(): any;
16
16
  ruleNodeReference(): any;
@@ -6,6 +6,7 @@ declare class Field extends Scriptable<FieldJson> implements FieldModel {
6
6
  constructor(params: FieldJson, _options: {
7
7
  form: FormModel;
8
8
  parent: ContainerModel;
9
+ mode?: 'create' | 'restore';
9
10
  });
10
11
  private _ruleNodeReference;
11
12
  _initialize(): any;
@@ -5,7 +5,7 @@ export declare class Fieldset extends Container<FieldsetJson> implements Fieldse
5
5
  form: FormModel;
6
6
  parent: ContainerModel;
7
7
  fieldFactory: IFormFieldFactory;
8
- mode: FormCreationMode;
8
+ mode?: FormCreationMode;
9
9
  });
10
10
  protected _getDefaults(): any;
11
11
  private _applyDefaults;
package/lib/BaseNode.d.ts CHANGED
@@ -23,6 +23,7 @@ export declare abstract class BaseNode<T extends BaseJson> implements BaseModel
23
23
  constructor(params: T, _options: {
24
24
  form: FormModel;
25
25
  parent: ContainerModel;
26
+ mode?: 'create' | 'restore';
26
27
  });
27
28
  abstract value: Primitives;
28
29
  abstract reset(): any;
@@ -1,9 +1,10 @@
1
1
  import Field from './Field';
2
- import { ContainerModel, FieldJson, FormModel } from './types/index';
2
+ import { ContainerModel, FieldJson, FormCreationMode, FormModel } from './types/index';
3
3
  declare class CheckboxGroup extends Field {
4
4
  constructor(params: FieldJson, _options: {
5
5
  form: FormModel;
6
6
  parent: ContainerModel;
7
+ mode: FormCreationMode;
7
8
  });
8
9
  protected _getFallbackType(): string | undefined;
9
10
  protected _getDefaults(): {
@@ -10,7 +10,7 @@ declare abstract class Container<T extends ContainerJson & RulesJson> extends Sc
10
10
  form: FormModel;
11
11
  parent: ContainerModel;
12
12
  fieldFactory: IFormFieldFactory;
13
- mode: 'create' | 'restore';
13
+ mode?: 'create' | 'restore';
14
14
  });
15
15
  protected _getDefaults(): any;
16
16
  ruleNodeReference(): any;
package/lib/Container.js CHANGED
@@ -19,7 +19,7 @@ const notifyChildrenAttributes = [
19
19
  ];
20
20
  class Container extends Scriptable_1.default {
21
21
  constructor(json, _options) {
22
- super(json, { form: _options.form, parent: _options.parent });
22
+ super(json, { form: _options.form, parent: _options.parent, mode: _options.mode });
23
23
  this._children = [];
24
24
  this._itemTemplate = null;
25
25
  this._activeChild = null;
@@ -115,11 +115,7 @@ class Container extends Scriptable_1.default {
115
115
  } : {})), { items: this.getItemsState(isRepeatableChild, forRestore), enabled: this.enabled, readOnly: this.readOnly });
116
116
  }
117
117
  _createChild(child, options) {
118
- const { parent = this } = options;
119
- return this.fieldFactory.createField(child, {
120
- form: options.form,
121
- parent
122
- });
118
+ return this.fieldFactory.createField(child, options);
123
119
  }
124
120
  walkSiteContainerItems(x) {
125
121
  return Object.fromEntries(Object.entries(x[':items']).map(([key, value]) => {
@@ -165,7 +161,7 @@ class Container extends Scriptable_1.default {
165
161
  });
166
162
  }
167
163
  }
168
- _addChild(itemJson, index, cloneIds = false) {
164
+ _addChild(itemJson, index, cloneIds = false, mode = 'create') {
169
165
  let nonTransparentParent = this;
170
166
  while (nonTransparentParent != null && nonTransparentParent.isTransparent()) {
171
167
  nonTransparentParent = nonTransparentParent.parent;
@@ -175,7 +171,7 @@ class Container extends Scriptable_1.default {
175
171
  }
176
172
  const form = this.form;
177
173
  const itemTemplate = Object.assign({ index }, (0, JsonUtils_1.deepClone)(itemJson, cloneIds ? () => { return form.getUniqueId(); } : undefined));
178
- const retVal = this._createChild(itemTemplate, { parent: this, form: this.form });
174
+ const retVal = this._createChild(itemTemplate, { parent: this, form: this.form, mode });
179
175
  itemJson.id = retVal.id;
180
176
  this.form.fieldAdded(retVal);
181
177
  this._addChildToRuleNode(retVal, { parent: nonTransparentParent });
@@ -231,7 +227,7 @@ class Container extends Scriptable_1.default {
231
227
  itemTemplate = (0, JsonUtils_1.deepClone)(items[i]);
232
228
  itemTemplate.repeatable = undefined;
233
229
  }
234
- child = this._addChild(itemTemplate, undefined, i > this._jsonModel.items.length - 1);
230
+ child = this._addChild(itemTemplate, undefined, i > this._jsonModel.items.length - 1, mode);
235
231
  }
236
232
  else {
237
233
  child = this._addChild(this._itemTemplate, undefined, i > this._jsonModel.items.length - 1);
@@ -248,7 +244,7 @@ class Container extends Scriptable_1.default {
248
244
  this._initializeSiteContainer(item);
249
245
  }
250
246
  else if (this.isAFormField(item)) {
251
- const child = this._addChild(item);
247
+ const child = this._addChild(item, undefined, false, mode);
252
248
  child._initialize(mode);
253
249
  }
254
250
  else {
package/lib/Field.d.ts CHANGED
@@ -6,6 +6,7 @@ declare class Field extends Scriptable<FieldJson> implements FieldModel {
6
6
  constructor(params: FieldJson, _options: {
7
7
  form: FormModel;
8
8
  parent: ContainerModel;
9
+ mode?: 'create' | 'restore';
9
10
  });
10
11
  private _ruleNodeReference;
11
12
  _initialize(): any;
package/lib/Field.js CHANGED
@@ -24,9 +24,11 @@ class Field extends Scriptable_1.default {
24
24
  constructor(params, _options) {
25
25
  super(params, _options);
26
26
  this._ruleNodeReference = [];
27
- this._applyDefaults();
28
- this.queueEvent(new Events_1.Initialize());
29
- this.queueEvent(new Events_1.ExecuteRule());
27
+ if (_options.mode !== 'restore') {
28
+ this._applyDefaults();
29
+ this.queueEvent(new Events_1.Initialize());
30
+ this.queueEvent(new Events_1.ExecuteRule());
31
+ }
30
32
  }
31
33
  _initialize() {
32
34
  super._initialize();
package/lib/Fieldset.d.ts CHANGED
@@ -5,7 +5,7 @@ export declare class Fieldset extends Container<FieldsetJson> implements Fieldse
5
5
  form: FormModel;
6
6
  parent: ContainerModel;
7
7
  fieldFactory: IFormFieldFactory;
8
- mode: FormCreationMode;
8
+ mode?: FormCreationMode;
9
9
  });
10
10
  protected _getDefaults(): any;
11
11
  private _applyDefaults;
package/lib/Fieldset.js CHANGED
@@ -9,9 +9,11 @@ const Events_1 = require("./controller/Events");
9
9
  class Fieldset extends Container_1.default {
10
10
  constructor(params, _options) {
11
11
  super(params, _options);
12
- this._applyDefaults();
13
- this.queueEvent(new Events_1.Initialize());
14
- this.queueEvent(new Events_1.ExecuteRule());
12
+ if (_options.mode !== 'restore') {
13
+ this._applyDefaults();
14
+ this.queueEvent(new Events_1.Initialize());
15
+ this.queueEvent(new Events_1.ExecuteRule());
16
+ }
15
17
  }
16
18
  _getDefaults() {
17
19
  return Object.assign(Object.assign({}, super._getDefaults()), { visible: true, required: false, label: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aemforms/af-core",
3
- "version": "0.22.69",
3
+ "version": "0.22.70",
4
4
  "description": "Core Module for Forms Runtime",
5
5
  "author": "Adobe Systems",
6
6
  "license": "Adobe Proprietary",
@@ -37,7 +37,7 @@
37
37
  },
38
38
  "dependencies": {
39
39
  "@adobe/json-formula": "0.1.50",
40
- "@aemforms/af-formatters": "^0.22.69"
40
+ "@aemforms/af-formatters": "^0.22.70"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@babel/preset-env": "^7.20.2",