@aemforms/af-core 0.22.118 → 0.22.120

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.
@@ -2407,7 +2407,10 @@ class Container extends Scriptable {
2407
2407
  for (const change of action.payload.changes) {
2408
2408
  if (change.propertyName !== undefined && notifyChildrenAttributes.includes(change.propertyName)) {
2409
2409
  this.items.forEach((child) => {
2410
- this.notifyDependents.call(child, propertyChange(change.propertyName, child.getState()[change.propertyName], null));
2410
+ if (change.currentValue !== child.getState()[change.propertyName]) {
2411
+ child._jsonModel[change.propertyName] = change.currentValue;
2412
+ this.notifyDependents.call(child, propertyChange(change.propertyName, child.getState()[change.propertyName], null));
2413
+ }
2411
2414
  if (child.fieldType === 'panel') {
2412
2415
  this.notifyChildren.call(child, action);
2413
2416
  }
@@ -3450,28 +3453,35 @@ class Form extends Container {
3450
3453
  }
3451
3454
  }
3452
3455
  setFocus(field, focusOption) {
3453
- if (!focusOption) {
3454
- this.#clearCurrentFocus(field);
3455
- this.#setActiveFirstDeepChild(field);
3456
- return;
3457
- }
3458
- const parent = (field?.isContainer ? field : field.parent);
3459
- const navigableChidren = this.#getNavigableChildren(parent.items);
3460
- let activeChild = parent.activeChild;
3461
- let currActiveChildIndex = activeChild !== null ? navigableChidren.indexOf(activeChild) : -1;
3462
- if (parent.activeChild === null) {
3463
- this.#setActiveFirstDeepChild(navigableChidren[0]);
3464
- currActiveChildIndex = 0;
3465
- return;
3466
- }
3467
- if (focusOption === FocusOption.NEXT_ITEM) {
3468
- activeChild = this.#getNextItem(currActiveChildIndex, navigableChidren);
3469
- }
3470
- else if (focusOption === FocusOption.PREVIOUS_ITEM) {
3471
- activeChild = this.#getPreviousItem(currActiveChildIndex, navigableChidren);
3456
+ const dependencyTracking = this._ruleEngine.getDependencyTracking();
3457
+ this._ruleEngine.setDependencyTracking(false);
3458
+ try {
3459
+ if (!focusOption) {
3460
+ this.#clearCurrentFocus(field);
3461
+ this.#setActiveFirstDeepChild(field);
3462
+ return;
3463
+ }
3464
+ const parent = (field?.isContainer ? field : field.parent);
3465
+ const navigableChidren = this.#getNavigableChildren(parent.items);
3466
+ let activeChild = parent.activeChild;
3467
+ let currActiveChildIndex = activeChild !== null ? navigableChidren.indexOf(activeChild) : -1;
3468
+ if (parent.activeChild === null) {
3469
+ this.#setActiveFirstDeepChild(navigableChidren[0]);
3470
+ currActiveChildIndex = 0;
3471
+ return;
3472
+ }
3473
+ if (focusOption === FocusOption.NEXT_ITEM) {
3474
+ activeChild = this.#getNextItem(currActiveChildIndex, navigableChidren);
3475
+ }
3476
+ else if (focusOption === FocusOption.PREVIOUS_ITEM) {
3477
+ activeChild = this.#getPreviousItem(currActiveChildIndex, navigableChidren);
3478
+ }
3479
+ if (activeChild !== null) {
3480
+ this.#setActiveFirstDeepChild(activeChild);
3481
+ }
3472
3482
  }
3473
- if (activeChild !== null) {
3474
- this.#setActiveFirstDeepChild(activeChild);
3483
+ finally {
3484
+ this._ruleEngine.setDependencyTracking(dependencyTracking);
3475
3485
  }
3476
3486
  }
3477
3487
  getState(forRestore = false) {
@@ -3681,6 +3691,7 @@ class RuleEngine {
3681
3691
  ];
3682
3692
  customFunctions;
3683
3693
  debugInfo = [];
3694
+ dependencyTracking = true;
3684
3695
  constructor() {
3685
3696
  this.customFunctions = FunctionRuntime.getFunctions();
3686
3697
  }
@@ -3715,10 +3726,16 @@ class RuleEngine {
3715
3726
  return finalRes;
3716
3727
  }
3717
3728
  trackDependency(subscriber) {
3718
- if (this._context && this._context.field !== undefined && this._context.field !== subscriber) {
3729
+ if (this.dependencyTracking && this._context && this._context.field !== undefined && this._context.field !== subscriber) {
3719
3730
  subscriber._addDependent(this._context.field);
3720
3731
  }
3721
3732
  }
3733
+ setDependencyTracking(track) {
3734
+ this.dependencyTracking = track;
3735
+ }
3736
+ getDependencyTracking() {
3737
+ return this.dependencyTracking;
3738
+ }
3722
3739
  }
3723
3740
 
3724
3741
  class Fieldset extends Container {
@@ -3873,6 +3890,9 @@ class Field extends Scriptable {
3873
3890
  if (['plain-text', 'image'].indexOf(this.fieldType) === -1) {
3874
3891
  this._jsonModel.value = undefined;
3875
3892
  }
3893
+ else if (this.fieldType === 'image') {
3894
+ this._jsonModel.value = this._jsonModel.properties['fd:repoPath'] ?? this._jsonModel.value;
3895
+ }
3876
3896
  else {
3877
3897
  this._jsonModel.default = this._jsonModel.default || this._jsonModel.value;
3878
3898
  }
@@ -5,6 +5,7 @@ declare class RuleEngine {
5
5
  private _globalNames;
6
6
  private readonly customFunctions;
7
7
  private debugInfo;
8
+ private dependencyTracking;
8
9
  constructor();
9
10
  compileRule(rule: string, locale?: string): {
10
11
  formula: Formula;
@@ -12,5 +13,7 @@ declare class RuleEngine {
12
13
  };
13
14
  execute(node: any, data: any, globals: any, useValueOf: boolean | undefined, eString: string): any;
14
15
  trackDependency(subscriber: BaseModel): void;
16
+ setDependencyTracking(track: boolean): void;
17
+ getDependencyTracking(): boolean;
15
18
  }
16
19
  export default RuleEngine;
package/lib/Container.js CHANGED
@@ -463,7 +463,10 @@ class Container extends Scriptable_1.default {
463
463
  for (const change of action.payload.changes) {
464
464
  if (change.propertyName !== undefined && notifyChildrenAttributes.includes(change.propertyName)) {
465
465
  this.items.forEach((child) => {
466
- this.notifyDependents.call(child, (0, Events_1.propertyChange)(change.propertyName, child.getState()[change.propertyName], null));
466
+ if (change.currentValue !== child.getState()[change.propertyName]) {
467
+ child._jsonModel[change.propertyName] = change.currentValue;
468
+ this.notifyDependents.call(child, (0, Events_1.propertyChange)(change.propertyName, child.getState()[change.propertyName], null));
469
+ }
467
470
  if (child.fieldType === 'panel') {
468
471
  this.notifyChildren.call(child, action);
469
472
  }
package/lib/Field.js CHANGED
@@ -100,6 +100,7 @@ class Field extends Scriptable_1.default {
100
100
  return finalType;
101
101
  }
102
102
  _applyDefaults() {
103
+ var _a;
103
104
  super._applyDefaultsInModel();
104
105
  this.coerceParam('required', 'boolean');
105
106
  this.coerceParam('readOnly', 'boolean');
@@ -111,6 +112,9 @@ class Field extends Scriptable_1.default {
111
112
  if (['plain-text', 'image'].indexOf(this.fieldType) === -1) {
112
113
  this._jsonModel.value = undefined;
113
114
  }
115
+ else if (this.fieldType === 'image') {
116
+ this._jsonModel.value = (_a = this._jsonModel.properties['fd:repoPath']) !== null && _a !== void 0 ? _a : this._jsonModel.value;
117
+ }
114
118
  else {
115
119
  this._jsonModel.default = this._jsonModel.default || this._jsonModel.value;
116
120
  }
package/lib/Form.js CHANGED
@@ -166,28 +166,35 @@ class Form extends Container_1.default {
166
166
  return new SubmitMetaData_1.default(options);
167
167
  }
168
168
  setFocus(field, focusOption) {
169
- if (!focusOption) {
170
- __classPrivateFieldGet(this, _Form_instances, "m", _Form_clearCurrentFocus).call(this, field);
171
- __classPrivateFieldGet(this, _Form_instances, "m", _Form_setActiveFirstDeepChild).call(this, field);
172
- return;
173
- }
174
- const parent = ((field === null || field === void 0 ? void 0 : field.isContainer) ? field : field.parent);
175
- const navigableChidren = __classPrivateFieldGet(this, _Form_instances, "m", _Form_getNavigableChildren).call(this, parent.items);
176
- let activeChild = parent.activeChild;
177
- let currActiveChildIndex = activeChild !== null ? navigableChidren.indexOf(activeChild) : -1;
178
- if (parent.activeChild === null) {
179
- __classPrivateFieldGet(this, _Form_instances, "m", _Form_setActiveFirstDeepChild).call(this, navigableChidren[0]);
180
- currActiveChildIndex = 0;
181
- return;
182
- }
183
- if (focusOption === index_1.FocusOption.NEXT_ITEM) {
184
- activeChild = __classPrivateFieldGet(this, _Form_instances, "m", _Form_getNextItem).call(this, currActiveChildIndex, navigableChidren);
185
- }
186
- else if (focusOption === index_1.FocusOption.PREVIOUS_ITEM) {
187
- activeChild = __classPrivateFieldGet(this, _Form_instances, "m", _Form_getPreviousItem).call(this, currActiveChildIndex, navigableChidren);
169
+ const dependencyTracking = this._ruleEngine.getDependencyTracking();
170
+ this._ruleEngine.setDependencyTracking(false);
171
+ try {
172
+ if (!focusOption) {
173
+ __classPrivateFieldGet(this, _Form_instances, "m", _Form_clearCurrentFocus).call(this, field);
174
+ __classPrivateFieldGet(this, _Form_instances, "m", _Form_setActiveFirstDeepChild).call(this, field);
175
+ return;
176
+ }
177
+ const parent = ((field === null || field === void 0 ? void 0 : field.isContainer) ? field : field.parent);
178
+ const navigableChidren = __classPrivateFieldGet(this, _Form_instances, "m", _Form_getNavigableChildren).call(this, parent.items);
179
+ let activeChild = parent.activeChild;
180
+ let currActiveChildIndex = activeChild !== null ? navigableChidren.indexOf(activeChild) : -1;
181
+ if (parent.activeChild === null) {
182
+ __classPrivateFieldGet(this, _Form_instances, "m", _Form_setActiveFirstDeepChild).call(this, navigableChidren[0]);
183
+ currActiveChildIndex = 0;
184
+ return;
185
+ }
186
+ if (focusOption === index_1.FocusOption.NEXT_ITEM) {
187
+ activeChild = __classPrivateFieldGet(this, _Form_instances, "m", _Form_getNextItem).call(this, currActiveChildIndex, navigableChidren);
188
+ }
189
+ else if (focusOption === index_1.FocusOption.PREVIOUS_ITEM) {
190
+ activeChild = __classPrivateFieldGet(this, _Form_instances, "m", _Form_getPreviousItem).call(this, currActiveChildIndex, navigableChidren);
191
+ }
192
+ if (activeChild !== null) {
193
+ __classPrivateFieldGet(this, _Form_instances, "m", _Form_setActiveFirstDeepChild).call(this, activeChild);
194
+ }
188
195
  }
189
- if (activeChild !== null) {
190
- __classPrivateFieldGet(this, _Form_instances, "m", _Form_setActiveFirstDeepChild).call(this, activeChild);
196
+ finally {
197
+ this._ruleEngine.setDependencyTracking(dependencyTracking);
191
198
  }
192
199
  }
193
200
  getState(forRestore = false) {
@@ -5,6 +5,7 @@ declare class RuleEngine {
5
5
  private _globalNames;
6
6
  private readonly customFunctions;
7
7
  private debugInfo;
8
+ private dependencyTracking;
8
9
  constructor();
9
10
  compileRule(rule: string, locale?: string): {
10
11
  formula: Formula;
@@ -12,5 +13,7 @@ declare class RuleEngine {
12
13
  };
13
14
  execute(node: any, data: any, globals: any, useValueOf: boolean | undefined, eString: string): any;
14
15
  trackDependency(subscriber: BaseModel): void;
16
+ setDependencyTracking(track: boolean): void;
17
+ getDependencyTracking(): boolean;
15
18
  }
16
19
  export default RuleEngine;
@@ -21,6 +21,7 @@ class RuleEngine {
21
21
  '$event'
22
22
  ];
23
23
  this.debugInfo = [];
24
+ this.dependencyTracking = true;
24
25
  this.customFunctions = FunctionRuntime_1.FunctionRuntime.getFunctions();
25
26
  }
26
27
  compileRule(rule, locale) {
@@ -55,9 +56,15 @@ class RuleEngine {
55
56
  return finalRes;
56
57
  }
57
58
  trackDependency(subscriber) {
58
- if (this._context && this._context.field !== undefined && this._context.field !== subscriber) {
59
+ if (this.dependencyTracking && this._context && this._context.field !== undefined && this._context.field !== subscriber) {
59
60
  subscriber._addDependent(this._context.field);
60
61
  }
61
62
  }
63
+ setDependencyTracking(track) {
64
+ this.dependencyTracking = track;
65
+ }
66
+ getDependencyTracking() {
67
+ return this.dependencyTracking;
68
+ }
62
69
  }
63
70
  exports.default = RuleEngine;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aemforms/af-core",
3
- "version": "0.22.118",
3
+ "version": "0.22.120",
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.118"
40
+ "@aemforms/af-formatters": "^0.22.120"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@babel/preset-env": "^7.20.2",