@aemforms/af-core 0.22.69 → 0.22.71

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.
@@ -1163,8 +1163,7 @@ class Scriptable extends BaseNode {
1163
1163
  if (prop === Symbol.toStringTag) {
1164
1164
  return 'Object';
1165
1165
  }
1166
- prop = prop;
1167
- if (prop.startsWith('$')) {
1166
+ if (typeof prop === 'string' && prop.startsWith('$')) {
1168
1167
  const retValue = target.self[prop];
1169
1168
  if (retValue instanceof BaseNode) {
1170
1169
  return retValue.getRuleNode();
@@ -1250,7 +1249,7 @@ class Container extends Scriptable {
1250
1249
  _itemTemplate = null;
1251
1250
  fieldFactory;
1252
1251
  constructor(json, _options) {
1253
- super(json, { form: _options.form, parent: _options.parent });
1252
+ super(json, { form: _options.form, parent: _options.parent, mode: _options.mode });
1254
1253
  this.fieldFactory = _options.fieldFactory;
1255
1254
  }
1256
1255
  _getDefaults() {
@@ -1360,11 +1359,7 @@ class Container extends Scriptable {
1360
1359
  };
1361
1360
  }
1362
1361
  _createChild(child, options) {
1363
- const { parent = this } = options;
1364
- return this.fieldFactory.createField(child, {
1365
- form: options.form,
1366
- parent
1367
- });
1362
+ return this.fieldFactory.createField(child, options);
1368
1363
  }
1369
1364
  walkSiteContainerItems(x) {
1370
1365
  return Object.fromEntries(Object.entries(x[':items']).map(([key, value]) => {
@@ -1416,7 +1411,7 @@ class Container extends Scriptable {
1416
1411
  });
1417
1412
  }
1418
1413
  }
1419
- _addChild(itemJson, index, cloneIds = false) {
1414
+ _addChild(itemJson, index, cloneIds = false, mode = 'create') {
1420
1415
  let nonTransparentParent = this;
1421
1416
  while (nonTransparentParent != null && nonTransparentParent.isTransparent()) {
1422
1417
  nonTransparentParent = nonTransparentParent.parent;
@@ -1429,7 +1424,7 @@ class Container extends Scriptable {
1429
1424
  index,
1430
1425
  ...deepClone(itemJson, cloneIds ? () => { return form.getUniqueId(); } : undefined)
1431
1426
  };
1432
- const retVal = this._createChild(itemTemplate, { parent: this, form: this.form });
1427
+ const retVal = this._createChild(itemTemplate, { parent: this, form: this.form, mode });
1433
1428
  itemJson.id = retVal.id;
1434
1429
  this.form.fieldAdded(retVal);
1435
1430
  this._addChildToRuleNode(retVal, { parent: nonTransparentParent });
@@ -1485,7 +1480,7 @@ class Container extends Scriptable {
1485
1480
  itemTemplate = deepClone(items[i]);
1486
1481
  itemTemplate.repeatable = undefined;
1487
1482
  }
1488
- child = this._addChild(itemTemplate, undefined, i > this._jsonModel.items.length - 1);
1483
+ child = this._addChild(itemTemplate, undefined, i > this._jsonModel.items.length - 1, mode);
1489
1484
  }
1490
1485
  else {
1491
1486
  child = this._addChild(this._itemTemplate, undefined, i > this._jsonModel.items.length - 1);
@@ -1502,7 +1497,7 @@ class Container extends Scriptable {
1502
1497
  this._initializeSiteContainer(item);
1503
1498
  }
1504
1499
  else if (this.isAFormField(item)) {
1505
- const child = this._addChild(item);
1500
+ const child = this._addChild(item, undefined, false, mode);
1506
1501
  child._initialize(mode);
1507
1502
  }
1508
1503
  else {
@@ -2866,9 +2861,11 @@ class RuleEngine {
2866
2861
  class Fieldset extends Container {
2867
2862
  constructor(params, _options) {
2868
2863
  super(params, _options);
2869
- this._applyDefaults();
2870
- this.queueEvent(new Initialize());
2871
- this.queueEvent(new ExecuteRule());
2864
+ if (_options.mode !== 'restore') {
2865
+ this._applyDefaults();
2866
+ this.queueEvent(new Initialize());
2867
+ this.queueEvent(new ExecuteRule());
2868
+ }
2872
2869
  }
2873
2870
  _getDefaults() {
2874
2871
  return {
@@ -3211,9 +3208,11 @@ const validTypes = ['string', 'number', 'integer', 'boolean', 'file', 'string[]'
3211
3208
  class Field extends Scriptable {
3212
3209
  constructor(params, _options) {
3213
3210
  super(params, _options);
3214
- this._applyDefaults();
3215
- this.queueEvent(new Initialize());
3216
- this.queueEvent(new ExecuteRule());
3211
+ if (_options.mode !== 'restore') {
3212
+ this._applyDefaults();
3213
+ this.queueEvent(new Initialize());
3214
+ this.queueEvent(new ExecuteRule());
3215
+ }
3217
3216
  }
3218
3217
  _ruleNodeReference = [];
3219
3218
  _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/lib/Scriptable.js CHANGED
@@ -92,8 +92,7 @@ class Scriptable extends BaseNode_1.BaseNode {
92
92
  if (prop === Symbol.toStringTag) {
93
93
  return 'Object';
94
94
  }
95
- prop = prop;
96
- if (prop.startsWith('$')) {
95
+ if (typeof prop === 'string' && prop.startsWith('$')) {
97
96
  const retValue = target.self[prop];
98
97
  if (retValue instanceof BaseNode_1.BaseNode) {
99
98
  return retValue.getRuleNode();
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.71",
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.71"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@babel/preset-env": "^7.20.2",