@aemforms/af-core 0.22.127 → 0.22.128
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 +54 -8
- package/esm/types/src/BaseNode.d.ts +1 -0
- package/esm/types/src/rules/FunctionRuntime.d.ts +4 -0
- package/lib/BaseNode.d.ts +1 -0
- package/lib/BaseNode.js +14 -3
- package/lib/Form.js +15 -3
- package/lib/rules/FunctionRuntime.d.ts +4 -0
- package/lib/rules/FunctionRuntime.js +25 -2
- package/package.json +2 -2
package/esm/afb-runtime.js
CHANGED
|
@@ -1673,6 +1673,13 @@ class BaseNode {
|
|
|
1673
1673
|
}
|
|
1674
1674
|
return nonTransparentParent;
|
|
1675
1675
|
}
|
|
1676
|
+
_isAncestorRepeatable() {
|
|
1677
|
+
let parent = this.parent;
|
|
1678
|
+
while (parent && !parent.repeatable) {
|
|
1679
|
+
parent = parent.parent;
|
|
1680
|
+
}
|
|
1681
|
+
return Boolean(parent);
|
|
1682
|
+
}
|
|
1676
1683
|
_initialize(mode) {
|
|
1677
1684
|
if (typeof this._data === 'undefined') {
|
|
1678
1685
|
let dataNode, parent = this.parent;
|
|
@@ -1701,13 +1708,17 @@ class BaseNode {
|
|
|
1701
1708
|
return this[qualifiedName];
|
|
1702
1709
|
}
|
|
1703
1710
|
const parent = this.getNonTransparentParent();
|
|
1711
|
+
let qn;
|
|
1704
1712
|
if (parent && parent.type === 'array') {
|
|
1705
|
-
|
|
1713
|
+
qn = `${parent.qualifiedName}[${this.index}]`;
|
|
1706
1714
|
}
|
|
1707
1715
|
else {
|
|
1708
|
-
|
|
1716
|
+
qn = `${parent.qualifiedName}.${this.name}`;
|
|
1709
1717
|
}
|
|
1710
|
-
|
|
1718
|
+
if (!this._isAncestorRepeatable()) {
|
|
1719
|
+
this[qualifiedName] = qn;
|
|
1720
|
+
}
|
|
1721
|
+
return qn;
|
|
1711
1722
|
}
|
|
1712
1723
|
focus() {
|
|
1713
1724
|
if (this.parent) {
|
|
@@ -3234,7 +3245,7 @@ class FunctionRuntimeImpl {
|
|
|
3234
3245
|
addInstance: {
|
|
3235
3246
|
_func: (args, data, interpreter) => {
|
|
3236
3247
|
const element = args[0];
|
|
3237
|
-
const payload = args.length >
|
|
3248
|
+
const payload = args.length > 1 ? valueOf(args[1]) : undefined;
|
|
3238
3249
|
try {
|
|
3239
3250
|
const formElement = interpreter.globals.form.getElement(element.$id);
|
|
3240
3251
|
const action = createAction('addInstance', payload);
|
|
@@ -3249,7 +3260,7 @@ class FunctionRuntimeImpl {
|
|
|
3249
3260
|
removeInstance: {
|
|
3250
3261
|
_func: (args, data, interpreter) => {
|
|
3251
3262
|
const element = args[0];
|
|
3252
|
-
const payload = args.length >
|
|
3263
|
+
const payload = args.length > 1 ? valueOf(args[1]) : undefined;
|
|
3253
3264
|
try {
|
|
3254
3265
|
const formElement = interpreter.globals.form.getElement(element.$id);
|
|
3255
3266
|
const action = createAction('removeInstance', payload);
|
|
@@ -3379,6 +3390,29 @@ class FunctionRuntimeImpl {
|
|
|
3379
3390
|
}
|
|
3380
3391
|
},
|
|
3381
3392
|
_signature: []
|
|
3393
|
+
},
|
|
3394
|
+
getRelativeInstanceIndex: {
|
|
3395
|
+
_func: (args, data, interpreter) => {
|
|
3396
|
+
if (!Array.isArray(args[0]) || args[0].length === 0) {
|
|
3397
|
+
return -1;
|
|
3398
|
+
}
|
|
3399
|
+
const instanceManager = valueOf(args[0])[0].$parent;
|
|
3400
|
+
const field = interpreter.globals.$field;
|
|
3401
|
+
const baseName = instanceManager.$qualifiedName;
|
|
3402
|
+
const qn = field.$qualifiedName;
|
|
3403
|
+
if (qn.startsWith(baseName + '[')) {
|
|
3404
|
+
const startBracket = baseName.length + 1;
|
|
3405
|
+
const endBracket = qn.indexOf(']', startBracket);
|
|
3406
|
+
if (endBracket !== -1) {
|
|
3407
|
+
const idx = Number(qn.slice(startBracket, endBracket));
|
|
3408
|
+
if (!Number.isNaN(idx)) {
|
|
3409
|
+
return idx;
|
|
3410
|
+
}
|
|
3411
|
+
}
|
|
3412
|
+
}
|
|
3413
|
+
return instanceManager.length - 1;
|
|
3414
|
+
},
|
|
3415
|
+
_signature: []
|
|
3382
3416
|
}
|
|
3383
3417
|
};
|
|
3384
3418
|
return { ...defaultFunctions, ...FunctionRuntimeImpl.getInstance().customFunctions };
|
|
@@ -3556,11 +3590,23 @@ class Form extends Container {
|
|
|
3556
3590
|
captchaInfoObj[field.qualifiedName] = field.value;
|
|
3557
3591
|
}
|
|
3558
3592
|
});
|
|
3593
|
+
const additionalMeta = {};
|
|
3559
3594
|
const draftId = this.properties['fd:draftId'] || '';
|
|
3560
3595
|
if (draftId) {
|
|
3561
|
-
|
|
3562
|
-
|
|
3563
|
-
|
|
3596
|
+
additionalMeta['fd:draftId'] = draftId;
|
|
3597
|
+
}
|
|
3598
|
+
const dorProps = this.properties['fd:dor'];
|
|
3599
|
+
if (dorProps && dorProps.dorType !== 'none') {
|
|
3600
|
+
const excludeFromDoRIfHidden = dorProps.excludeFromDoRIfHidden;
|
|
3601
|
+
const excludeFromDoR = Object.values(this._fields)
|
|
3602
|
+
.filter(field => field.enabled === false || (excludeFromDoRIfHidden && field.visible === false))
|
|
3603
|
+
.map(field => field.qualifiedName);
|
|
3604
|
+
if (excludeFromDoR && excludeFromDoR.length > 0) {
|
|
3605
|
+
additionalMeta.excludeFromDoR = excludeFromDoR;
|
|
3606
|
+
}
|
|
3607
|
+
}
|
|
3608
|
+
if (Object.keys(additionalMeta).length > 0) {
|
|
3609
|
+
this.setAdditionalSubmitMetadata(additionalMeta);
|
|
3564
3610
|
}
|
|
3565
3611
|
const options = {
|
|
3566
3612
|
lang: this.lang,
|
|
@@ -98,6 +98,7 @@ export declare abstract class BaseNode<T extends BaseJson> implements BaseModel
|
|
|
98
98
|
abstract defaultDataModel(name: string | number): DataValue | undefined;
|
|
99
99
|
abstract syncDataAndFormModel(a?: DataValue | DataGroup): any;
|
|
100
100
|
getNonTransparentParent(): ContainerModel;
|
|
101
|
+
_isAncestorRepeatable(): boolean;
|
|
101
102
|
_initialize(mode?: FormCreationMode): void;
|
|
102
103
|
protected _applyUpdates(propNames: string[], updates: any): any;
|
|
103
104
|
get qualifiedName(): any;
|
|
@@ -95,6 +95,10 @@ declare class FunctionRuntimeImpl {
|
|
|
95
95
|
_func: (args: Array<unknown>, data: unknown, interpreter: any) => any;
|
|
96
96
|
_signature: never[];
|
|
97
97
|
};
|
|
98
|
+
getRelativeInstanceIndex: {
|
|
99
|
+
_func: (args: Array<unknown>, data: unknown, interpreter: any) => number;
|
|
100
|
+
_signature: never[];
|
|
101
|
+
};
|
|
98
102
|
};
|
|
99
103
|
}
|
|
100
104
|
export declare const FunctionRuntime: FunctionRuntimeImpl;
|
package/lib/BaseNode.d.ts
CHANGED
|
@@ -98,6 +98,7 @@ export declare abstract class BaseNode<T extends BaseJson> implements BaseModel
|
|
|
98
98
|
abstract defaultDataModel(name: string | number): DataValue | undefined;
|
|
99
99
|
abstract syncDataAndFormModel(a?: DataValue | DataGroup): any;
|
|
100
100
|
getNonTransparentParent(): ContainerModel;
|
|
101
|
+
_isAncestorRepeatable(): boolean;
|
|
101
102
|
_initialize(mode?: FormCreationMode): void;
|
|
102
103
|
protected _applyUpdates(propNames: string[], updates: any): any;
|
|
103
104
|
get qualifiedName(): any;
|
package/lib/BaseNode.js
CHANGED
|
@@ -468,6 +468,13 @@ class BaseNode {
|
|
|
468
468
|
}
|
|
469
469
|
return nonTransparentParent;
|
|
470
470
|
}
|
|
471
|
+
_isAncestorRepeatable() {
|
|
472
|
+
let parent = this.parent;
|
|
473
|
+
while (parent && !parent.repeatable) {
|
|
474
|
+
parent = parent.parent;
|
|
475
|
+
}
|
|
476
|
+
return Boolean(parent);
|
|
477
|
+
}
|
|
471
478
|
_initialize(mode) {
|
|
472
479
|
if (typeof this._data === 'undefined') {
|
|
473
480
|
let dataNode, parent = this.parent;
|
|
@@ -496,13 +503,17 @@ class BaseNode {
|
|
|
496
503
|
return this[exports.qualifiedName];
|
|
497
504
|
}
|
|
498
505
|
const parent = this.getNonTransparentParent();
|
|
506
|
+
let qn;
|
|
499
507
|
if (parent && parent.type === 'array') {
|
|
500
|
-
|
|
508
|
+
qn = `${parent.qualifiedName}[${this.index}]`;
|
|
501
509
|
}
|
|
502
510
|
else {
|
|
503
|
-
|
|
511
|
+
qn = `${parent.qualifiedName}.${this.name}`;
|
|
512
|
+
}
|
|
513
|
+
if (!this._isAncestorRepeatable()) {
|
|
514
|
+
this[exports.qualifiedName] = qn;
|
|
504
515
|
}
|
|
505
|
-
return
|
|
516
|
+
return qn;
|
|
506
517
|
}
|
|
507
518
|
focus() {
|
|
508
519
|
if (this.parent) {
|
package/lib/Form.js
CHANGED
|
@@ -156,11 +156,23 @@ class Form extends Container_1.default {
|
|
|
156
156
|
captchaInfoObj[field.qualifiedName] = field.value;
|
|
157
157
|
}
|
|
158
158
|
});
|
|
159
|
+
const additionalMeta = {};
|
|
159
160
|
const draftId = this.properties['fd:draftId'] || '';
|
|
160
161
|
if (draftId) {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
162
|
+
additionalMeta['fd:draftId'] = draftId;
|
|
163
|
+
}
|
|
164
|
+
const dorProps = this.properties['fd:dor'];
|
|
165
|
+
if (dorProps && dorProps.dorType !== 'none') {
|
|
166
|
+
const excludeFromDoRIfHidden = dorProps.excludeFromDoRIfHidden;
|
|
167
|
+
const excludeFromDoR = Object.values(this._fields)
|
|
168
|
+
.filter(field => field.enabled === false || (excludeFromDoRIfHidden && field.visible === false))
|
|
169
|
+
.map(field => field.qualifiedName);
|
|
170
|
+
if (excludeFromDoR && excludeFromDoR.length > 0) {
|
|
171
|
+
additionalMeta.excludeFromDoR = excludeFromDoR;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
if (Object.keys(additionalMeta).length > 0) {
|
|
175
|
+
this.setAdditionalSubmitMetadata(additionalMeta);
|
|
164
176
|
}
|
|
165
177
|
const options = Object.assign({ lang: this.lang, captchaInfo: captchaInfoObj }, this.additionalSubmitMetadata);
|
|
166
178
|
return new SubmitMetaData_1.default(options);
|
|
@@ -95,6 +95,10 @@ declare class FunctionRuntimeImpl {
|
|
|
95
95
|
_func: (args: Array<unknown>, data: unknown, interpreter: any) => any;
|
|
96
96
|
_signature: never[];
|
|
97
97
|
};
|
|
98
|
+
getRelativeInstanceIndex: {
|
|
99
|
+
_func: (args: Array<unknown>, data: unknown, interpreter: any) => number;
|
|
100
|
+
_signature: never[];
|
|
101
|
+
};
|
|
98
102
|
};
|
|
99
103
|
}
|
|
100
104
|
export declare const FunctionRuntime: FunctionRuntimeImpl;
|
|
@@ -584,7 +584,7 @@ class FunctionRuntimeImpl {
|
|
|
584
584
|
addInstance: {
|
|
585
585
|
_func: (args, data, interpreter) => {
|
|
586
586
|
const element = args[0];
|
|
587
|
-
const payload = args.length >
|
|
587
|
+
const payload = args.length > 1 ? valueOf(args[1]) : undefined;
|
|
588
588
|
try {
|
|
589
589
|
const formElement = interpreter.globals.form.getElement(element.$id);
|
|
590
590
|
const action = createAction('addInstance', payload);
|
|
@@ -599,7 +599,7 @@ class FunctionRuntimeImpl {
|
|
|
599
599
|
removeInstance: {
|
|
600
600
|
_func: (args, data, interpreter) => {
|
|
601
601
|
const element = args[0];
|
|
602
|
-
const payload = args.length >
|
|
602
|
+
const payload = args.length > 1 ? valueOf(args[1]) : undefined;
|
|
603
603
|
try {
|
|
604
604
|
const formElement = interpreter.globals.form.getElement(element.$id);
|
|
605
605
|
const action = createAction('removeInstance', payload);
|
|
@@ -732,6 +732,29 @@ class FunctionRuntimeImpl {
|
|
|
732
732
|
}
|
|
733
733
|
},
|
|
734
734
|
_signature: []
|
|
735
|
+
},
|
|
736
|
+
getRelativeInstanceIndex: {
|
|
737
|
+
_func: (args, data, interpreter) => {
|
|
738
|
+
if (!Array.isArray(args[0]) || args[0].length === 0) {
|
|
739
|
+
return -1;
|
|
740
|
+
}
|
|
741
|
+
const instanceManager = valueOf(args[0])[0].$parent;
|
|
742
|
+
const field = interpreter.globals.$field;
|
|
743
|
+
const baseName = instanceManager.$qualifiedName;
|
|
744
|
+
const qn = field.$qualifiedName;
|
|
745
|
+
if (qn.startsWith(baseName + '[')) {
|
|
746
|
+
const startBracket = baseName.length + 1;
|
|
747
|
+
const endBracket = qn.indexOf(']', startBracket);
|
|
748
|
+
if (endBracket !== -1) {
|
|
749
|
+
const idx = Number(qn.slice(startBracket, endBracket));
|
|
750
|
+
if (!Number.isNaN(idx)) {
|
|
751
|
+
return idx;
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
return instanceManager.length - 1;
|
|
756
|
+
},
|
|
757
|
+
_signature: []
|
|
735
758
|
}
|
|
736
759
|
};
|
|
737
760
|
return Object.assign(Object.assign({}, defaultFunctions), FunctionRuntimeImpl.getInstance().customFunctions);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aemforms/af-core",
|
|
3
|
-
"version": "0.22.
|
|
3
|
+
"version": "0.22.128",
|
|
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.128"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@babel/preset-env": "^7.20.2",
|