@aemforms/af-core 0.22.143 → 0.22.145

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.
@@ -793,7 +793,7 @@ const processItem = (item, excludeUnbound, isAsync) => {
793
793
  ? item.dataRef
794
794
  : (name.length > 0 ? item.name : undefined);
795
795
  if (item.value instanceof Array) {
796
- if (item.type === 'string[]') {
796
+ if (item.type === 'string[]' && item?.format === 'data-url') {
797
797
  if (isAsync) {
798
798
  return item.serialize().then(serializedFiles => {
799
799
  ret[item.id] = serializedFiles.map((x) => {
@@ -815,7 +815,7 @@ const processItem = (item, excludeUnbound, isAsync) => {
815
815
  }
816
816
  }
817
817
  else if (item.value != null) {
818
- if (item.type === 'string') {
818
+ if (item.type === 'string' && item?.format === 'data-url') {
819
819
  if (isAsync) {
820
820
  return item.serialize().then(serializedFile => {
821
821
  ret[item.id] = { ...serializedFile[0], 'dataRef': dataRef };
@@ -1694,7 +1694,9 @@ class BaseNode {
1694
1694
  }
1695
1695
  notifyChildren.call(this, changeAction);
1696
1696
  if (validationConstraintsList.includes(prop)) {
1697
- this.validate();
1697
+ if (this.hasValueBeenSet === undefined || this.hasValueBeenSet) {
1698
+ this.validate();
1699
+ }
1698
1700
  }
1699
1701
  return changeAction.payload.changes;
1700
1702
  }
@@ -1747,10 +1749,16 @@ class BaseNode {
1747
1749
  if (key !== '') {
1748
1750
  const create = this.defaultDataModel(key);
1749
1751
  if (create !== undefined) {
1750
- _data = contextualDataModel.$getDataNode(key);
1751
- if (_data === undefined) {
1752
- _data = create;
1753
- contextualDataModel.$addDataNode(key, _data);
1752
+ if (typeof contextualDataModel.$getDataNode === 'function') {
1753
+ _data = contextualDataModel.$getDataNode(key);
1754
+ if (_data === undefined) {
1755
+ _data = create;
1756
+ contextualDataModel.$addDataNode(key, _data);
1757
+ }
1758
+ }
1759
+ else {
1760
+ console.error(`$getDataNode method is undefined for "${name}" with dataModel type "${contextualDataModel.$type}"`);
1761
+ _data = undefined;
1754
1762
  }
1755
1763
  }
1756
1764
  }
@@ -3050,10 +3058,9 @@ class FunctionRuntimeImpl {
3050
3058
  event: interpreter.globals.$event,
3051
3059
  functions: {
3052
3060
  setProperty: (target, payload) => {
3053
- const field = interpreter.globals.form.getElement(target.$id);
3054
- Object.entries(payload).forEach(([key, value]) => {
3055
- field[key] = value;
3056
- });
3061
+ const eventName = 'custom:setProperty';
3062
+ const args = [target, eventName, payload];
3063
+ return FunctionRuntimeImpl.getInstance().getFunctions().dispatchEvent._func.call(undefined, args, data, interpreter);
3057
3064
  },
3058
3065
  reset: (target) => {
3059
3066
  const eventName = 'reset';
@@ -4249,6 +4256,11 @@ __decorate([
4249
4256
 
4250
4257
  const validTypes = ['string', 'number', 'integer', 'boolean', 'file', 'string[]', 'number[]', 'integer[]', 'boolean[]', 'file[]', 'array', 'object'];
4251
4258
  class Field extends Scriptable {
4259
+ _ruleNodeReference = [];
4260
+ _hasValueBeenSet = false;
4261
+ get hasValueBeenSet() {
4262
+ return this._hasValueBeenSet;
4263
+ }
4252
4264
  constructor(params, _options) {
4253
4265
  super(params, _options);
4254
4266
  if (_options.mode !== 'restore') {
@@ -4262,7 +4274,6 @@ class Field extends Scriptable {
4262
4274
  }
4263
4275
  }
4264
4276
  }
4265
- _ruleNodeReference = [];
4266
4277
  _initialize() {
4267
4278
  super._initialize();
4268
4279
  this.setupRuleNode();
@@ -4377,7 +4388,12 @@ class Field extends Scriptable {
4377
4388
  }
4378
4389
  const props = ['minimum', 'maximum', 'exclusiveMinimum', 'exclusiveMaximum'];
4379
4390
  if (this._jsonModel.type !== 'string') {
4380
- this.unset('format', 'pattern', 'minLength', 'maxLength');
4391
+ if (this._jsonModel.fieldType === 'file-input') {
4392
+ this.unset('pattern', 'minLength', 'maxLength');
4393
+ }
4394
+ else {
4395
+ this.unset('format', 'pattern', 'minLength', 'maxLength');
4396
+ }
4381
4397
  }
4382
4398
  else if (this._jsonModel.fieldType === 'date-input') {
4383
4399
  this._jsonModel.format = 'date';
@@ -4566,6 +4582,7 @@ class Field extends Scriptable {
4566
4582
  const typeRes = Constraints.type(this.getInternalType() || 'string', val);
4567
4583
  const changes = this._setProperty('value', typeRes.value, false);
4568
4584
  if (changes.length > 0) {
4585
+ this._hasValueBeenSet = true;
4569
4586
  this._updateRuleNodeReference(typeRes.value);
4570
4587
  if (typeof dataNode !== 'undefined') {
4571
4588
  dataNode.setValue(this.getDataNodeValue(this._jsonModel.value), this._jsonModel.value, this);
@@ -4778,9 +4795,6 @@ class Field extends Scriptable {
4778
4795
  case 'date-input':
4779
4796
  this._jsonModel.format = 'date';
4780
4797
  break;
4781
- case 'file-input':
4782
- this._jsonModel.format = 'data-url';
4783
- break;
4784
4798
  case 'date-time':
4785
4799
  this._jsonModel.format = 'date-time';
4786
4800
  break;
@@ -3,12 +3,14 @@ import Scriptable from './Scriptable';
3
3
  import DataValue from './data/DataValue';
4
4
  declare class Field extends Scriptable<FieldJson> implements FieldModel {
5
5
  #private;
6
+ private _ruleNodeReference;
7
+ protected _hasValueBeenSet: boolean;
8
+ protected get hasValueBeenSet(): boolean;
6
9
  constructor(params: FieldJson, _options: {
7
10
  form: FormModel;
8
11
  parent: ContainerModel;
9
12
  mode?: 'create' | 'restore';
10
13
  });
11
- private _ruleNodeReference;
12
14
  _initialize(): any;
13
15
  ruleNodeReference(): any;
14
16
  protected _getDefaults(): {
package/lib/BaseNode.js CHANGED
@@ -392,7 +392,9 @@ class BaseNode {
392
392
  }
393
393
  notifyChildren.call(this, changeAction);
394
394
  if (ValidationUtils_1.validationConstraintsList.includes(prop)) {
395
- this.validate();
395
+ if (this.hasValueBeenSet === undefined || this.hasValueBeenSet) {
396
+ this.validate();
397
+ }
396
398
  }
397
399
  return changeAction.payload.changes;
398
400
  }
@@ -445,10 +447,16 @@ class BaseNode {
445
447
  if (key !== '') {
446
448
  const create = this.defaultDataModel(key);
447
449
  if (create !== undefined) {
448
- _data = contextualDataModel.$getDataNode(key);
449
- if (_data === undefined) {
450
- _data = create;
451
- contextualDataModel.$addDataNode(key, _data);
450
+ if (typeof contextualDataModel.$getDataNode === 'function') {
451
+ _data = contextualDataModel.$getDataNode(key);
452
+ if (_data === undefined) {
453
+ _data = create;
454
+ contextualDataModel.$addDataNode(key, _data);
455
+ }
456
+ }
457
+ else {
458
+ console.error(`$getDataNode method is undefined for "${name}" with dataModel type "${contextualDataModel.$type}"`);
459
+ _data = undefined;
452
460
  }
453
461
  }
454
462
  }
package/lib/Field.d.ts CHANGED
@@ -3,12 +3,14 @@ import Scriptable from './Scriptable';
3
3
  import DataValue from './data/DataValue';
4
4
  declare class Field extends Scriptable<FieldJson> implements FieldModel {
5
5
  #private;
6
+ private _ruleNodeReference;
7
+ protected _hasValueBeenSet: boolean;
8
+ protected get hasValueBeenSet(): boolean;
6
9
  constructor(params: FieldJson, _options: {
7
10
  form: FormModel;
8
11
  parent: ContainerModel;
9
12
  mode?: 'create' | 'restore';
10
13
  });
11
- private _ruleNodeReference;
12
14
  _initialize(): any;
13
15
  ruleNodeReference(): any;
14
16
  protected _getDefaults(): {
package/lib/Field.js CHANGED
@@ -31,6 +31,7 @@ class Field extends Scriptable_1.default {
31
31
  super(params, _options);
32
32
  _Field_instances.add(this);
33
33
  this._ruleNodeReference = [];
34
+ this._hasValueBeenSet = false;
34
35
  if (_options.mode !== 'restore') {
35
36
  this._applyDefaults();
36
37
  this.queueEvent(new Events_1.Initialize());
@@ -42,6 +43,9 @@ class Field extends Scriptable_1.default {
42
43
  }
43
44
  }
44
45
  }
46
+ get hasValueBeenSet() {
47
+ return this._hasValueBeenSet;
48
+ }
45
49
  _initialize() {
46
50
  super._initialize();
47
51
  this.setupRuleNode();
@@ -158,7 +162,12 @@ class Field extends Scriptable_1.default {
158
162
  }
159
163
  const props = ['minimum', 'maximum', 'exclusiveMinimum', 'exclusiveMaximum'];
160
164
  if (this._jsonModel.type !== 'string') {
161
- this.unset('format', 'pattern', 'minLength', 'maxLength');
165
+ if (this._jsonModel.fieldType === 'file-input') {
166
+ this.unset('pattern', 'minLength', 'maxLength');
167
+ }
168
+ else {
169
+ this.unset('format', 'pattern', 'minLength', 'maxLength');
170
+ }
162
171
  }
163
172
  else if (this._jsonModel.fieldType === 'date-input') {
164
173
  this._jsonModel.format = 'date';
@@ -347,6 +356,7 @@ class Field extends Scriptable_1.default {
347
356
  const typeRes = Constraints.type(this.getInternalType() || 'string', val);
348
357
  const changes = this._setProperty('value', typeRes.value, false);
349
358
  if (changes.length > 0) {
359
+ this._hasValueBeenSet = true;
350
360
  this._updateRuleNodeReference(typeRes.value);
351
361
  if (typeof dataNode !== 'undefined') {
352
362
  dataNode.setValue(this.getDataNodeValue(this._jsonModel.value), this._jsonModel.value, this);
@@ -559,9 +569,6 @@ class Field extends Scriptable_1.default {
559
569
  case 'date-input':
560
570
  this._jsonModel.format = 'date';
561
571
  break;
562
- case 'file-input':
563
- this._jsonModel.format = 'data-url';
564
- break;
565
572
  case 'date-time':
566
573
  this._jsonModel.format = 'date-time';
567
574
  break;
@@ -248,10 +248,9 @@ class FunctionRuntimeImpl {
248
248
  event: interpreter.globals.$event,
249
249
  functions: {
250
250
  setProperty: (target, payload) => {
251
- const field = interpreter.globals.form.getElement(target.$id);
252
- Object.entries(payload).forEach(([key, value]) => {
253
- field[key] = value;
254
- });
251
+ const eventName = 'custom:setProperty';
252
+ const args = [target, eventName, payload];
253
+ return FunctionRuntimeImpl.getInstance().getFunctions().dispatchEvent._func.call(undefined, args, data, interpreter);
255
254
  },
256
255
  reset: (target) => {
257
256
  const eventName = 'reset';
@@ -51,7 +51,7 @@ const processItem = (item, excludeUnbound, isAsync) => {
51
51
  ? item.dataRef
52
52
  : (name.length > 0 ? item.name : undefined);
53
53
  if (item.value instanceof Array) {
54
- if (item.type === 'string[]') {
54
+ if (item.type === 'string[]' && (item === null || item === void 0 ? void 0 : item.format) === 'data-url') {
55
55
  if (isAsync) {
56
56
  return item.serialize().then(serializedFiles => {
57
57
  ret[item.id] = serializedFiles.map((x) => {
@@ -73,7 +73,7 @@ const processItem = (item, excludeUnbound, isAsync) => {
73
73
  }
74
74
  }
75
75
  else if (item.value != null) {
76
- if (item.type === 'string') {
76
+ if (item.type === 'string' && (item === null || item === void 0 ? void 0 : item.format) === 'data-url') {
77
77
  if (isAsync) {
78
78
  return item.serialize().then(serializedFile => {
79
79
  ret[item.id] = Object.assign(Object.assign({}, serializedFile[0]), { 'dataRef': dataRef });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aemforms/af-core",
3
- "version": "0.22.143",
3
+ "version": "0.22.145",
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.143"
40
+ "@aemforms/af-formatters": "^0.22.145"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@babel/preset-env": "^7.20.2",