@aemforms/af-core 0.22.152 → 0.22.154
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
CHANGED
|
@@ -1882,7 +1882,7 @@ class BaseNode {
|
|
|
1882
1882
|
else {
|
|
1883
1883
|
qn = `${parent.qualifiedName}.${this.name}`;
|
|
1884
1884
|
}
|
|
1885
|
-
if (!this._isAncestorRepeatable()) {
|
|
1885
|
+
if (!this.repeatable && !this._isAncestorRepeatable()) {
|
|
1886
1886
|
this[qualifiedName] = qn;
|
|
1887
1887
|
}
|
|
1888
1888
|
return qn;
|
|
@@ -3257,13 +3257,17 @@ class FunctionRuntimeImpl {
|
|
|
3257
3257
|
getData: {
|
|
3258
3258
|
_func: (args, data, interpreter) => {
|
|
3259
3259
|
interpreter.globals.form.logger.warn('The `getData` function is depricated. Use `exportData` instead.');
|
|
3260
|
-
return interpreter.globals.form.
|
|
3260
|
+
return interpreter.globals.form.withDependencyTrackingControl(true, () => {
|
|
3261
|
+
return interpreter.globals.form.exportData();
|
|
3262
|
+
});
|
|
3261
3263
|
},
|
|
3262
3264
|
_signature: []
|
|
3263
3265
|
},
|
|
3264
3266
|
exportData: {
|
|
3265
3267
|
_func: (args, data, interpreter) => {
|
|
3266
|
-
return interpreter.globals.form.
|
|
3268
|
+
return interpreter.globals.form.withDependencyTrackingControl(true, () => {
|
|
3269
|
+
return interpreter.globals.form.exportData();
|
|
3270
|
+
});
|
|
3267
3271
|
},
|
|
3268
3272
|
_signature: []
|
|
3269
3273
|
},
|
|
@@ -3709,6 +3713,57 @@ class FunctionRuntimeImpl {
|
|
|
3709
3713
|
return _today / MS_IN_DAY;
|
|
3710
3714
|
},
|
|
3711
3715
|
_signature: []
|
|
3716
|
+
},
|
|
3717
|
+
formatInput: {
|
|
3718
|
+
_func: (args) => {
|
|
3719
|
+
const input = args[0];
|
|
3720
|
+
const format = args[1];
|
|
3721
|
+
if (!input || !format) {
|
|
3722
|
+
return input;
|
|
3723
|
+
}
|
|
3724
|
+
const inputStr = String(input).replace(/\D/g, '');
|
|
3725
|
+
switch (String(format).toLowerCase()) {
|
|
3726
|
+
case 'phonenumber': {
|
|
3727
|
+
if (inputStr.length >= 10) {
|
|
3728
|
+
const areaCode = inputStr.substring(0, 3);
|
|
3729
|
+
const firstThree = inputStr.substring(3, 6);
|
|
3730
|
+
const lastFour = inputStr.substring(6, 10);
|
|
3731
|
+
return `(${areaCode}) ${firstThree}-${lastFour}`;
|
|
3732
|
+
}
|
|
3733
|
+
else if (inputStr.length >= 7) {
|
|
3734
|
+
const firstThree = inputStr.substring(0, 3);
|
|
3735
|
+
const lastFour = inputStr.substring(3, 7);
|
|
3736
|
+
return `(${firstThree}) ${lastFour}`;
|
|
3737
|
+
}
|
|
3738
|
+
return inputStr;
|
|
3739
|
+
}
|
|
3740
|
+
case 'socialsecuritynumber': {
|
|
3741
|
+
if (inputStr.length >= 9) {
|
|
3742
|
+
const firstThree = inputStr.substring(0, 3);
|
|
3743
|
+
const middleTwo = inputStr.substring(3, 5);
|
|
3744
|
+
const lastFour = inputStr.substring(5, 9);
|
|
3745
|
+
return `${firstThree}-${middleTwo}-${lastFour}`;
|
|
3746
|
+
}
|
|
3747
|
+
return inputStr;
|
|
3748
|
+
}
|
|
3749
|
+
case 'email-alphanumeric': {
|
|
3750
|
+
const alphanumeric = String(input).replace(/[^a-zA-Z0-9]/g, '');
|
|
3751
|
+
if (alphanumeric.length > 0) {
|
|
3752
|
+
return `${alphanumeric}@example.com`;
|
|
3753
|
+
}
|
|
3754
|
+
return input;
|
|
3755
|
+
}
|
|
3756
|
+
case 'zipcode': {
|
|
3757
|
+
if (inputStr.length >= 5) {
|
|
3758
|
+
return inputStr.substring(0, 5);
|
|
3759
|
+
}
|
|
3760
|
+
return inputStr;
|
|
3761
|
+
}
|
|
3762
|
+
default:
|
|
3763
|
+
return input;
|
|
3764
|
+
}
|
|
3765
|
+
},
|
|
3766
|
+
_signature: []
|
|
3712
3767
|
}
|
|
3713
3768
|
};
|
|
3714
3769
|
return { ...defaultFunctions, ...FunctionRuntimeImpl.getInstance().customFunctions };
|
|
@@ -111,6 +111,10 @@ declare class FunctionRuntimeImpl {
|
|
|
111
111
|
_func: () => number;
|
|
112
112
|
_signature: never[];
|
|
113
113
|
};
|
|
114
|
+
formatInput: {
|
|
115
|
+
_func: (args: Array<unknown>) => unknown;
|
|
116
|
+
_signature: never[];
|
|
117
|
+
};
|
|
114
118
|
};
|
|
115
119
|
}
|
|
116
120
|
export declare const FunctionRuntime: FunctionRuntimeImpl;
|
package/lib/BaseNode.js
CHANGED
|
@@ -111,6 +111,10 @@ declare class FunctionRuntimeImpl {
|
|
|
111
111
|
_func: () => number;
|
|
112
112
|
_signature: never[];
|
|
113
113
|
};
|
|
114
|
+
formatInput: {
|
|
115
|
+
_func: (args: Array<unknown>) => unknown;
|
|
116
|
+
_signature: never[];
|
|
117
|
+
};
|
|
114
118
|
};
|
|
115
119
|
}
|
|
116
120
|
export declare const FunctionRuntime: FunctionRuntimeImpl;
|
|
@@ -408,13 +408,17 @@ class FunctionRuntimeImpl {
|
|
|
408
408
|
getData: {
|
|
409
409
|
_func: (args, data, interpreter) => {
|
|
410
410
|
interpreter.globals.form.logger.warn('The `getData` function is depricated. Use `exportData` instead.');
|
|
411
|
-
return interpreter.globals.form.
|
|
411
|
+
return interpreter.globals.form.withDependencyTrackingControl(true, () => {
|
|
412
|
+
return interpreter.globals.form.exportData();
|
|
413
|
+
});
|
|
412
414
|
},
|
|
413
415
|
_signature: []
|
|
414
416
|
},
|
|
415
417
|
exportData: {
|
|
416
418
|
_func: (args, data, interpreter) => {
|
|
417
|
-
return interpreter.globals.form.
|
|
419
|
+
return interpreter.globals.form.withDependencyTrackingControl(true, () => {
|
|
420
|
+
return interpreter.globals.form.exportData();
|
|
421
|
+
});
|
|
418
422
|
},
|
|
419
423
|
_signature: []
|
|
420
424
|
},
|
|
@@ -858,6 +862,57 @@ class FunctionRuntimeImpl {
|
|
|
858
862
|
return _today / MS_IN_DAY;
|
|
859
863
|
},
|
|
860
864
|
_signature: []
|
|
865
|
+
},
|
|
866
|
+
formatInput: {
|
|
867
|
+
_func: (args) => {
|
|
868
|
+
const input = args[0];
|
|
869
|
+
const format = args[1];
|
|
870
|
+
if (!input || !format) {
|
|
871
|
+
return input;
|
|
872
|
+
}
|
|
873
|
+
const inputStr = String(input).replace(/\D/g, '');
|
|
874
|
+
switch (String(format).toLowerCase()) {
|
|
875
|
+
case 'phonenumber': {
|
|
876
|
+
if (inputStr.length >= 10) {
|
|
877
|
+
const areaCode = inputStr.substring(0, 3);
|
|
878
|
+
const firstThree = inputStr.substring(3, 6);
|
|
879
|
+
const lastFour = inputStr.substring(6, 10);
|
|
880
|
+
return `(${areaCode}) ${firstThree}-${lastFour}`;
|
|
881
|
+
}
|
|
882
|
+
else if (inputStr.length >= 7) {
|
|
883
|
+
const firstThree = inputStr.substring(0, 3);
|
|
884
|
+
const lastFour = inputStr.substring(3, 7);
|
|
885
|
+
return `(${firstThree}) ${lastFour}`;
|
|
886
|
+
}
|
|
887
|
+
return inputStr;
|
|
888
|
+
}
|
|
889
|
+
case 'socialsecuritynumber': {
|
|
890
|
+
if (inputStr.length >= 9) {
|
|
891
|
+
const firstThree = inputStr.substring(0, 3);
|
|
892
|
+
const middleTwo = inputStr.substring(3, 5);
|
|
893
|
+
const lastFour = inputStr.substring(5, 9);
|
|
894
|
+
return `${firstThree}-${middleTwo}-${lastFour}`;
|
|
895
|
+
}
|
|
896
|
+
return inputStr;
|
|
897
|
+
}
|
|
898
|
+
case 'email-alphanumeric': {
|
|
899
|
+
const alphanumeric = String(input).replace(/[^a-zA-Z0-9]/g, '');
|
|
900
|
+
if (alphanumeric.length > 0) {
|
|
901
|
+
return `${alphanumeric}@example.com`;
|
|
902
|
+
}
|
|
903
|
+
return input;
|
|
904
|
+
}
|
|
905
|
+
case 'zipcode': {
|
|
906
|
+
if (inputStr.length >= 5) {
|
|
907
|
+
return inputStr.substring(0, 5);
|
|
908
|
+
}
|
|
909
|
+
return inputStr;
|
|
910
|
+
}
|
|
911
|
+
default:
|
|
912
|
+
return input;
|
|
913
|
+
}
|
|
914
|
+
},
|
|
915
|
+
_signature: []
|
|
861
916
|
}
|
|
862
917
|
};
|
|
863
918
|
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.154",
|
|
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.154"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@babel/preset-env": "^7.20.2",
|