@aemforms/af-core 0.22.144 → 0.22.146
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/esm/afb-runtime.js +37 -15
- package/esm/types/src/Field.d.ts +3 -1
- package/lib/BaseNode.js +21 -6
- package/lib/Container.js +2 -1
- package/lib/Field.d.ts +3 -1
- package/lib/Field.js +11 -4
- package/lib/rules/FunctionRuntime.js +1 -1
- package/lib/utils/FormUtils.js +2 -2
- package/package.json +2 -2
package/esm/afb-runtime.js
CHANGED
|
@@ -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 };
|
|
@@ -1606,7 +1606,14 @@ class BaseNode {
|
|
|
1606
1606
|
};
|
|
1607
1607
|
}
|
|
1608
1608
|
_addDependent(dependent, propertyName) {
|
|
1609
|
-
|
|
1609
|
+
const existingDependency = this._dependents.find(({ node, propertyName: existingProp }) => {
|
|
1610
|
+
let isExistingDependent = node === dependent;
|
|
1611
|
+
if (isExistingDependent && propertyName && propertyName.startsWith('properties.')) {
|
|
1612
|
+
isExistingDependent = existingProp === propertyName;
|
|
1613
|
+
}
|
|
1614
|
+
return isExistingDependent;
|
|
1615
|
+
});
|
|
1616
|
+
if (existingDependency === undefined) {
|
|
1610
1617
|
const subscription = this.subscribe((change) => {
|
|
1611
1618
|
const changes = change.payload.changes;
|
|
1612
1619
|
const propsToLook = [...dynamicProps, 'items'];
|
|
@@ -1694,7 +1701,9 @@ class BaseNode {
|
|
|
1694
1701
|
}
|
|
1695
1702
|
notifyChildren.call(this, changeAction);
|
|
1696
1703
|
if (validationConstraintsList.includes(prop)) {
|
|
1697
|
-
this.
|
|
1704
|
+
if (this.hasValueBeenSet === undefined || this.hasValueBeenSet) {
|
|
1705
|
+
this.validate();
|
|
1706
|
+
}
|
|
1698
1707
|
}
|
|
1699
1708
|
return changeAction.payload.changes;
|
|
1700
1709
|
}
|
|
@@ -1747,10 +1756,16 @@ class BaseNode {
|
|
|
1747
1756
|
if (key !== '') {
|
|
1748
1757
|
const create = this.defaultDataModel(key);
|
|
1749
1758
|
if (create !== undefined) {
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
_data
|
|
1753
|
-
|
|
1759
|
+
if (typeof contextualDataModel.$getDataNode === 'function') {
|
|
1760
|
+
_data = contextualDataModel.$getDataNode(key);
|
|
1761
|
+
if (_data === undefined) {
|
|
1762
|
+
_data = create;
|
|
1763
|
+
contextualDataModel.$addDataNode(key, _data);
|
|
1764
|
+
}
|
|
1765
|
+
}
|
|
1766
|
+
else {
|
|
1767
|
+
console.error(`$getDataNode method is undefined for "${name}" with dataModel type "${contextualDataModel.$type}"`);
|
|
1768
|
+
_data = undefined;
|
|
1754
1769
|
}
|
|
1755
1770
|
}
|
|
1756
1771
|
}
|
|
@@ -2525,7 +2540,7 @@ class Container extends Scriptable {
|
|
|
2525
2540
|
activeChild.activeChild = null;
|
|
2526
2541
|
activeChild = temp;
|
|
2527
2542
|
}
|
|
2528
|
-
const change = propertyChange('activeChild', c, this._activeChild);
|
|
2543
|
+
const change = propertyChange('activeChild', c?.getState(), this._activeChild?.getState());
|
|
2529
2544
|
this._activeChild = c;
|
|
2530
2545
|
if (this.parent && c !== null) {
|
|
2531
2546
|
this.parent.activeChild = this;
|
|
@@ -3546,7 +3561,7 @@ class FunctionRuntimeImpl {
|
|
|
3546
3561
|
return '';
|
|
3547
3562
|
}
|
|
3548
3563
|
if (interpreter.globals.form?.properties?.queryParams?.[param]) {
|
|
3549
|
-
return interpreter.globals.form.properties.queryParams[param];
|
|
3564
|
+
return interpreter.globals.form.properties.queryParams[param.toLowerCase()];
|
|
3550
3565
|
}
|
|
3551
3566
|
try {
|
|
3552
3567
|
const urlParams = new URLSearchParams(window?.location?.search || '');
|
|
@@ -4248,6 +4263,11 @@ __decorate([
|
|
|
4248
4263
|
|
|
4249
4264
|
const validTypes = ['string', 'number', 'integer', 'boolean', 'file', 'string[]', 'number[]', 'integer[]', 'boolean[]', 'file[]', 'array', 'object'];
|
|
4250
4265
|
class Field extends Scriptable {
|
|
4266
|
+
_ruleNodeReference = [];
|
|
4267
|
+
_hasValueBeenSet = false;
|
|
4268
|
+
get hasValueBeenSet() {
|
|
4269
|
+
return this._hasValueBeenSet;
|
|
4270
|
+
}
|
|
4251
4271
|
constructor(params, _options) {
|
|
4252
4272
|
super(params, _options);
|
|
4253
4273
|
if (_options.mode !== 'restore') {
|
|
@@ -4261,7 +4281,6 @@ class Field extends Scriptable {
|
|
|
4261
4281
|
}
|
|
4262
4282
|
}
|
|
4263
4283
|
}
|
|
4264
|
-
_ruleNodeReference = [];
|
|
4265
4284
|
_initialize() {
|
|
4266
4285
|
super._initialize();
|
|
4267
4286
|
this.setupRuleNode();
|
|
@@ -4376,7 +4395,12 @@ class Field extends Scriptable {
|
|
|
4376
4395
|
}
|
|
4377
4396
|
const props = ['minimum', 'maximum', 'exclusiveMinimum', 'exclusiveMaximum'];
|
|
4378
4397
|
if (this._jsonModel.type !== 'string') {
|
|
4379
|
-
this.
|
|
4398
|
+
if (this._jsonModel.fieldType === 'file-input') {
|
|
4399
|
+
this.unset('pattern', 'minLength', 'maxLength');
|
|
4400
|
+
}
|
|
4401
|
+
else {
|
|
4402
|
+
this.unset('format', 'pattern', 'minLength', 'maxLength');
|
|
4403
|
+
}
|
|
4380
4404
|
}
|
|
4381
4405
|
else if (this._jsonModel.fieldType === 'date-input') {
|
|
4382
4406
|
this._jsonModel.format = 'date';
|
|
@@ -4565,6 +4589,7 @@ class Field extends Scriptable {
|
|
|
4565
4589
|
const typeRes = Constraints.type(this.getInternalType() || 'string', val);
|
|
4566
4590
|
const changes = this._setProperty('value', typeRes.value, false);
|
|
4567
4591
|
if (changes.length > 0) {
|
|
4592
|
+
this._hasValueBeenSet = true;
|
|
4568
4593
|
this._updateRuleNodeReference(typeRes.value);
|
|
4569
4594
|
if (typeof dataNode !== 'undefined') {
|
|
4570
4595
|
dataNode.setValue(this.getDataNodeValue(this._jsonModel.value), this._jsonModel.value, this);
|
|
@@ -4777,9 +4802,6 @@ class Field extends Scriptable {
|
|
|
4777
4802
|
case 'date-input':
|
|
4778
4803
|
this._jsonModel.format = 'date';
|
|
4779
4804
|
break;
|
|
4780
|
-
case 'file-input':
|
|
4781
|
-
this._jsonModel.format = 'data-url';
|
|
4782
|
-
break;
|
|
4783
4805
|
case 'date-time':
|
|
4784
4806
|
this._jsonModel.format = 'date-time';
|
|
4785
4807
|
break;
|
package/esm/types/src/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/BaseNode.js
CHANGED
|
@@ -304,7 +304,14 @@ class BaseNode {
|
|
|
304
304
|
};
|
|
305
305
|
}
|
|
306
306
|
_addDependent(dependent, propertyName) {
|
|
307
|
-
|
|
307
|
+
const existingDependency = this._dependents.find(({ node, propertyName: existingProp }) => {
|
|
308
|
+
let isExistingDependent = node === dependent;
|
|
309
|
+
if (isExistingDependent && propertyName && propertyName.startsWith('properties.')) {
|
|
310
|
+
isExistingDependent = existingProp === propertyName;
|
|
311
|
+
}
|
|
312
|
+
return isExistingDependent;
|
|
313
|
+
});
|
|
314
|
+
if (existingDependency === undefined) {
|
|
308
315
|
const subscription = this.subscribe((change) => {
|
|
309
316
|
const changes = change.payload.changes;
|
|
310
317
|
const propsToLook = [...exports.dynamicProps, 'items'];
|
|
@@ -392,7 +399,9 @@ class BaseNode {
|
|
|
392
399
|
}
|
|
393
400
|
notifyChildren.call(this, changeAction);
|
|
394
401
|
if (ValidationUtils_1.validationConstraintsList.includes(prop)) {
|
|
395
|
-
this.
|
|
402
|
+
if (this.hasValueBeenSet === undefined || this.hasValueBeenSet) {
|
|
403
|
+
this.validate();
|
|
404
|
+
}
|
|
396
405
|
}
|
|
397
406
|
return changeAction.payload.changes;
|
|
398
407
|
}
|
|
@@ -445,10 +454,16 @@ class BaseNode {
|
|
|
445
454
|
if (key !== '') {
|
|
446
455
|
const create = this.defaultDataModel(key);
|
|
447
456
|
if (create !== undefined) {
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
_data
|
|
451
|
-
|
|
457
|
+
if (typeof contextualDataModel.$getDataNode === 'function') {
|
|
458
|
+
_data = contextualDataModel.$getDataNode(key);
|
|
459
|
+
if (_data === undefined) {
|
|
460
|
+
_data = create;
|
|
461
|
+
contextualDataModel.$addDataNode(key, _data);
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
else {
|
|
465
|
+
console.error(`$getDataNode method is undefined for "${name}" with dataModel type "${contextualDataModel.$type}"`);
|
|
466
|
+
_data = undefined;
|
|
452
467
|
}
|
|
453
468
|
}
|
|
454
469
|
}
|
package/lib/Container.js
CHANGED
|
@@ -422,6 +422,7 @@ class Container extends Scriptable_1.default {
|
|
|
422
422
|
return this._activeChild;
|
|
423
423
|
}
|
|
424
424
|
set activeChild(c) {
|
|
425
|
+
var _a;
|
|
425
426
|
if (c !== this._activeChild) {
|
|
426
427
|
let activeChild = this._activeChild;
|
|
427
428
|
while (activeChild instanceof Container) {
|
|
@@ -429,7 +430,7 @@ class Container extends Scriptable_1.default {
|
|
|
429
430
|
activeChild.activeChild = null;
|
|
430
431
|
activeChild = temp;
|
|
431
432
|
}
|
|
432
|
-
const change = (0, Events_1.propertyChange)('activeChild', c, this._activeChild);
|
|
433
|
+
const change = (0, Events_1.propertyChange)('activeChild', c === null || c === void 0 ? void 0 : c.getState(), (_a = this._activeChild) === null || _a === void 0 ? void 0 : _a.getState());
|
|
433
434
|
this._activeChild = c;
|
|
434
435
|
if (this.parent && c !== null) {
|
|
435
436
|
this.parent.activeChild = this;
|
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.
|
|
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;
|
|
@@ -741,7 +741,7 @@ class FunctionRuntimeImpl {
|
|
|
741
741
|
return '';
|
|
742
742
|
}
|
|
743
743
|
if ((_c = (_b = (_a = interpreter.globals.form) === null || _a === void 0 ? void 0 : _a.properties) === null || _b === void 0 ? void 0 : _b.queryParams) === null || _c === void 0 ? void 0 : _c[param]) {
|
|
744
|
-
return interpreter.globals.form.properties.queryParams[param];
|
|
744
|
+
return interpreter.globals.form.properties.queryParams[param.toLowerCase()];
|
|
745
745
|
}
|
|
746
746
|
try {
|
|
747
747
|
const urlParams = new URLSearchParams(((_d = window === null || window === void 0 ? void 0 : window.location) === null || _d === void 0 ? void 0 : _d.search) || '');
|
package/lib/utils/FormUtils.js
CHANGED
|
@@ -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.
|
|
3
|
+
"version": "0.22.146",
|
|
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.
|
|
40
|
+
"@aemforms/af-formatters": "^0.22.146"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@babel/preset-env": "^7.20.2",
|