@aemforms/af-core 0.22.134 → 0.22.136

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.
@@ -1535,6 +1535,20 @@ class BaseNode {
1535
1535
  this.queueEvent(action);
1536
1536
  this.form.getEventQueue().runPendingQueue();
1537
1537
  }
1538
+ withDependencyTrackingControl(disableDependencyTracking, callback) {
1539
+ const currentDependencyTracking = this.form.ruleEngine.getDependencyTracking();
1540
+ if (disableDependencyTracking) {
1541
+ this.form.ruleEngine.setDependencyTracking(false);
1542
+ }
1543
+ try {
1544
+ return callback();
1545
+ }
1546
+ finally {
1547
+ if (disableDependencyTracking) {
1548
+ this.form.ruleEngine.setDependencyTracking(currentDependencyTracking);
1549
+ }
1550
+ }
1551
+ }
1538
1552
  notifyDependents(action) {
1539
1553
  const depsToRestore = this._jsonModel._dependents;
1540
1554
  if (depsToRestore) {
@@ -1548,7 +1562,9 @@ class BaseNode {
1548
1562
  }
1549
1563
  const handlers = this._callbacks[action.type] || [];
1550
1564
  handlers.forEach(x => {
1551
- x(new ActionImplWithTarget(action, this));
1565
+ this.withDependencyTrackingControl(true, () => {
1566
+ x(new ActionImplWithTarget(action, this));
1567
+ });
1552
1568
  });
1553
1569
  }
1554
1570
  isEmpty(value = this._jsonModel.value) {
@@ -3638,22 +3654,24 @@ class Form extends Container {
3638
3654
  return children.filter(child => child.visible === true);
3639
3655
  }
3640
3656
  #getFirstNavigableChild(container) {
3641
- const navigableChidren = this.#getNavigableChildren(container.items);
3642
- if (navigableChidren) {
3643
- return navigableChidren[0];
3657
+ const navigableChildren = this.#getNavigableChildren(container.items);
3658
+ if (navigableChildren && navigableChildren.length > 0) {
3659
+ return navigableChildren[0];
3644
3660
  }
3645
3661
  return null;
3646
3662
  }
3647
3663
  #setActiveFirstDeepChild(currentField) {
3648
3664
  if (!currentField.isContainer) {
3649
- const parent = currentField.parent;
3650
- parent.activeChild = currentField;
3665
+ currentField.parent.activeChild = currentField;
3651
3666
  return;
3652
3667
  }
3653
3668
  this.#clearCurrentFocus(currentField);
3654
- let currentActiveChild = currentField.activeChild;
3655
- currentActiveChild = (currentActiveChild === null) ? this.#getFirstNavigableChild(currentField) : currentField.activeChild;
3656
- this.#setActiveFirstDeepChild(currentActiveChild);
3669
+ const activeChild = currentField.activeChild || this.#getFirstNavigableChild(currentField);
3670
+ if (activeChild === null) {
3671
+ currentField.parent.activeChild = currentField;
3672
+ return;
3673
+ }
3674
+ this.#setActiveFirstDeepChild(activeChild);
3657
3675
  }
3658
3676
  #getNextItem(currIndex, navigableChidren) {
3659
3677
  if (currIndex < (navigableChidren.length - 1)) {
@@ -84,6 +84,7 @@ export declare abstract class BaseNode<T extends BaseJson> implements BaseModel
84
84
  abstract executeAction(action: Action): any;
85
85
  queueEvent(action: Action): void;
86
86
  dispatch(action: Action): void;
87
+ protected withDependencyTrackingControl<T>(disableDependencyTracking: boolean, callback: () => T): T;
87
88
  notifyDependents(action: Action): void;
88
89
  protected isEmpty(value?: any): boolean;
89
90
  _setProperty<T>(prop: string, newValue: T, notify?: boolean, notifyChildren?: (action: Action) => void): any;
package/lib/BaseNode.d.ts CHANGED
@@ -84,6 +84,7 @@ export declare abstract class BaseNode<T extends BaseJson> implements BaseModel
84
84
  abstract executeAction(action: Action): any;
85
85
  queueEvent(action: Action): void;
86
86
  dispatch(action: Action): void;
87
+ protected withDependencyTrackingControl<T>(disableDependencyTracking: boolean, callback: () => T): T;
87
88
  notifyDependents(action: Action): void;
88
89
  protected isEmpty(value?: any): boolean;
89
90
  _setProperty<T>(prop: string, newValue: T, notify?: boolean, notifyChildren?: (action: Action) => void): any;
package/lib/BaseNode.js CHANGED
@@ -330,6 +330,20 @@ class BaseNode {
330
330
  this.queueEvent(action);
331
331
  this.form.getEventQueue().runPendingQueue();
332
332
  }
333
+ withDependencyTrackingControl(disableDependencyTracking, callback) {
334
+ const currentDependencyTracking = this.form.ruleEngine.getDependencyTracking();
335
+ if (disableDependencyTracking) {
336
+ this.form.ruleEngine.setDependencyTracking(false);
337
+ }
338
+ try {
339
+ return callback();
340
+ }
341
+ finally {
342
+ if (disableDependencyTracking) {
343
+ this.form.ruleEngine.setDependencyTracking(currentDependencyTracking);
344
+ }
345
+ }
346
+ }
333
347
  notifyDependents(action) {
334
348
  const depsToRestore = this._jsonModel._dependents;
335
349
  if (depsToRestore) {
@@ -343,7 +357,9 @@ class BaseNode {
343
357
  }
344
358
  const handlers = this._callbacks[action.type] || [];
345
359
  handlers.forEach(x => {
346
- x(new ActionImplWithTarget(action, this));
360
+ this.withDependencyTrackingControl(true, () => {
361
+ x(new ActionImplWithTarget(action, this));
362
+ });
347
363
  });
348
364
  }
349
365
  isEmpty(value = this._jsonModel.value) {
package/lib/Form.js CHANGED
@@ -401,21 +401,23 @@ class Form extends Container_1.default {
401
401
  _Form_instances = new WeakSet(), _Form_getNavigableChildren = function _Form_getNavigableChildren(children) {
402
402
  return children.filter(child => child.visible === true);
403
403
  }, _Form_getFirstNavigableChild = function _Form_getFirstNavigableChild(container) {
404
- const navigableChidren = __classPrivateFieldGet(this, _Form_instances, "m", _Form_getNavigableChildren).call(this, container.items);
405
- if (navigableChidren) {
406
- return navigableChidren[0];
404
+ const navigableChildren = __classPrivateFieldGet(this, _Form_instances, "m", _Form_getNavigableChildren).call(this, container.items);
405
+ if (navigableChildren && navigableChildren.length > 0) {
406
+ return navigableChildren[0];
407
407
  }
408
408
  return null;
409
409
  }, _Form_setActiveFirstDeepChild = function _Form_setActiveFirstDeepChild(currentField) {
410
410
  if (!currentField.isContainer) {
411
- const parent = currentField.parent;
412
- parent.activeChild = currentField;
411
+ currentField.parent.activeChild = currentField;
413
412
  return;
414
413
  }
415
414
  __classPrivateFieldGet(this, _Form_instances, "m", _Form_clearCurrentFocus).call(this, currentField);
416
- let currentActiveChild = currentField.activeChild;
417
- currentActiveChild = (currentActiveChild === null) ? __classPrivateFieldGet(this, _Form_instances, "m", _Form_getFirstNavigableChild).call(this, currentField) : currentField.activeChild;
418
- __classPrivateFieldGet(this, _Form_instances, "m", _Form_setActiveFirstDeepChild).call(this, currentActiveChild);
415
+ const activeChild = currentField.activeChild || __classPrivateFieldGet(this, _Form_instances, "m", _Form_getFirstNavigableChild).call(this, currentField);
416
+ if (activeChild === null) {
417
+ currentField.parent.activeChild = currentField;
418
+ return;
419
+ }
420
+ __classPrivateFieldGet(this, _Form_instances, "m", _Form_setActiveFirstDeepChild).call(this, activeChild);
419
421
  }, _Form_getNextItem = function _Form_getNextItem(currIndex, navigableChidren) {
420
422
  if (currIndex < (navigableChidren.length - 1)) {
421
423
  return navigableChidren[currIndex + 1];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aemforms/af-core",
3
- "version": "0.22.134",
3
+ "version": "0.22.136",
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.134"
40
+ "@aemforms/af-formatters": "^0.22.136"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@babel/preset-env": "^7.20.2",