@aemforms/af-core 0.22.10 → 0.22.12

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.
package/lib/BaseNode.js CHANGED
@@ -314,7 +314,7 @@ class BaseNode {
314
314
  return;
315
315
  }
316
316
  const dataRef = this._jsonModel.dataRef;
317
- let _data;
317
+ let _data, _parent = contextualDataModel, _key = '';
318
318
  if (dataRef === null) { // null data binding
319
319
  _data = EmptyDataValue_1.default;
320
320
  }
@@ -330,13 +330,18 @@ class BaseNode {
330
330
  const name = this._tokens[this._tokens.length - 1].value;
331
331
  const create = this.defaultDataModel(name);
332
332
  _data = (0, DataRefParser_1.resolveData)(searchData, this._tokens, create);
333
+ // @ts-ignore
334
+ _parent = (0, DataRefParser_1.resolveData)(searchData, this._tokens.slice(0, -1));
335
+ _key = name;
333
336
  }
334
337
  }
335
338
  else { // name data binding
336
339
  if ( //@ts-ignore
337
340
  contextualDataModel !== EmptyDataValue_1.default) {
341
+ _parent = contextualDataModel;
338
342
  const name = this._jsonModel.name || '';
339
343
  const key = contextualDataModel.$type === 'array' ? this.index : name;
344
+ _key = key;
340
345
  if (key !== '') {
341
346
  const create = this.defaultDataModel(key);
342
347
  if (create !== undefined) {
@@ -353,8 +358,10 @@ class BaseNode {
353
358
  }
354
359
  }
355
360
  if (_data) {
356
- if (!this.isContainer) {
361
+ //@ts-ignore
362
+ if (!this.isContainer && _parent !== EmptyDataValue_1.default && _data !== EmptyDataValue_1.default) {
357
363
  _data = _data === null || _data === void 0 ? void 0 : _data.$convertToDataValue();
364
+ _parent.$addDataNode(_key, _data, true);
358
365
  }
359
366
  _data === null || _data === void 0 ? void 0 : _data.$bindToField(this);
360
367
  this._data = _data;
@@ -18,7 +18,7 @@ export default class DataGroup extends DataValue {
18
18
  };
19
19
  get $length(): number;
20
20
  $convertToDataValue(): DataValue;
21
- $addDataNode(name: string | number, value: DataGroup | DataValue): void;
21
+ $addDataNode(name: string | number, value: DataGroup | DataValue, override?: boolean): void;
22
22
  $removeDataNode(name: string | number): void;
23
23
  $getDataNode(name: string | number): any;
24
24
  $containsDataNode(name: string | number): boolean;
@@ -57,11 +57,16 @@ class DataGroup extends DataValue_1.default {
57
57
  $convertToDataValue() {
58
58
  return new DataValue_1.default(this.$name, this.$value, this.$type);
59
59
  }
60
- $addDataNode(name, value) {
60
+ $addDataNode(name, value, override = false) {
61
61
  if (value !== EmptyDataValue_1.default) {
62
62
  if (this.$type === 'array') {
63
63
  const index = name;
64
- this.$_items.splice(index, 0, value);
64
+ if (!override) {
65
+ this.$_items.splice(index, 0, value);
66
+ }
67
+ else {
68
+ this.$_items[name] = value;
69
+ }
65
70
  }
66
71
  else {
67
72
  this.$_items[name] = value;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aemforms/af-core",
3
- "version": "0.22.10",
3
+ "version": "0.22.12",
4
4
  "description": "Core Module for Forms Runtime",
5
5
  "author": "Adobe Systems",
6
6
  "license": "Adobe Proprietary",
@@ -35,7 +35,7 @@
35
35
  },
36
36
  "dependencies": {
37
37
  "@adobe/json-formula": "^0.1.44",
38
- "@aemforms/af-formatters": "^0.22.9"
38
+ "@aemforms/af-formatters": "^0.22.12"
39
39
  },
40
40
  "devDependencies": {
41
41
  "@types/jest": "^27.5.1",