@aemforms/af-core 0.22.152 → 0.22.153
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;
|
|
@@ -3709,6 +3709,57 @@ class FunctionRuntimeImpl {
|
|
|
3709
3709
|
return _today / MS_IN_DAY;
|
|
3710
3710
|
},
|
|
3711
3711
|
_signature: []
|
|
3712
|
+
},
|
|
3713
|
+
formatInput: {
|
|
3714
|
+
_func: (args) => {
|
|
3715
|
+
const input = args[0];
|
|
3716
|
+
const format = args[1];
|
|
3717
|
+
if (!input || !format) {
|
|
3718
|
+
return input;
|
|
3719
|
+
}
|
|
3720
|
+
const inputStr = String(input).replace(/\D/g, '');
|
|
3721
|
+
switch (String(format).toLowerCase()) {
|
|
3722
|
+
case 'phonenumber': {
|
|
3723
|
+
if (inputStr.length >= 10) {
|
|
3724
|
+
const areaCode = inputStr.substring(0, 3);
|
|
3725
|
+
const firstThree = inputStr.substring(3, 6);
|
|
3726
|
+
const lastFour = inputStr.substring(6, 10);
|
|
3727
|
+
return `(${areaCode}) ${firstThree}-${lastFour}`;
|
|
3728
|
+
}
|
|
3729
|
+
else if (inputStr.length >= 7) {
|
|
3730
|
+
const firstThree = inputStr.substring(0, 3);
|
|
3731
|
+
const lastFour = inputStr.substring(3, 7);
|
|
3732
|
+
return `(${firstThree}) ${lastFour}`;
|
|
3733
|
+
}
|
|
3734
|
+
return inputStr;
|
|
3735
|
+
}
|
|
3736
|
+
case 'socialsecuritynumber': {
|
|
3737
|
+
if (inputStr.length >= 9) {
|
|
3738
|
+
const firstThree = inputStr.substring(0, 3);
|
|
3739
|
+
const middleTwo = inputStr.substring(3, 5);
|
|
3740
|
+
const lastFour = inputStr.substring(5, 9);
|
|
3741
|
+
return `${firstThree}-${middleTwo}-${lastFour}`;
|
|
3742
|
+
}
|
|
3743
|
+
return inputStr;
|
|
3744
|
+
}
|
|
3745
|
+
case 'email-alphanumeric': {
|
|
3746
|
+
const alphanumeric = String(input).replace(/[^a-zA-Z0-9]/g, '');
|
|
3747
|
+
if (alphanumeric.length > 0) {
|
|
3748
|
+
return `${alphanumeric}@example.com`;
|
|
3749
|
+
}
|
|
3750
|
+
return input;
|
|
3751
|
+
}
|
|
3752
|
+
case 'zipcode': {
|
|
3753
|
+
if (inputStr.length >= 5) {
|
|
3754
|
+
return inputStr.substring(0, 5);
|
|
3755
|
+
}
|
|
3756
|
+
return inputStr;
|
|
3757
|
+
}
|
|
3758
|
+
default:
|
|
3759
|
+
return input;
|
|
3760
|
+
}
|
|
3761
|
+
},
|
|
3762
|
+
_signature: []
|
|
3712
3763
|
}
|
|
3713
3764
|
};
|
|
3714
3765
|
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;
|
|
@@ -858,6 +858,57 @@ class FunctionRuntimeImpl {
|
|
|
858
858
|
return _today / MS_IN_DAY;
|
|
859
859
|
},
|
|
860
860
|
_signature: []
|
|
861
|
+
},
|
|
862
|
+
formatInput: {
|
|
863
|
+
_func: (args) => {
|
|
864
|
+
const input = args[0];
|
|
865
|
+
const format = args[1];
|
|
866
|
+
if (!input || !format) {
|
|
867
|
+
return input;
|
|
868
|
+
}
|
|
869
|
+
const inputStr = String(input).replace(/\D/g, '');
|
|
870
|
+
switch (String(format).toLowerCase()) {
|
|
871
|
+
case 'phonenumber': {
|
|
872
|
+
if (inputStr.length >= 10) {
|
|
873
|
+
const areaCode = inputStr.substring(0, 3);
|
|
874
|
+
const firstThree = inputStr.substring(3, 6);
|
|
875
|
+
const lastFour = inputStr.substring(6, 10);
|
|
876
|
+
return `(${areaCode}) ${firstThree}-${lastFour}`;
|
|
877
|
+
}
|
|
878
|
+
else if (inputStr.length >= 7) {
|
|
879
|
+
const firstThree = inputStr.substring(0, 3);
|
|
880
|
+
const lastFour = inputStr.substring(3, 7);
|
|
881
|
+
return `(${firstThree}) ${lastFour}`;
|
|
882
|
+
}
|
|
883
|
+
return inputStr;
|
|
884
|
+
}
|
|
885
|
+
case 'socialsecuritynumber': {
|
|
886
|
+
if (inputStr.length >= 9) {
|
|
887
|
+
const firstThree = inputStr.substring(0, 3);
|
|
888
|
+
const middleTwo = inputStr.substring(3, 5);
|
|
889
|
+
const lastFour = inputStr.substring(5, 9);
|
|
890
|
+
return `${firstThree}-${middleTwo}-${lastFour}`;
|
|
891
|
+
}
|
|
892
|
+
return inputStr;
|
|
893
|
+
}
|
|
894
|
+
case 'email-alphanumeric': {
|
|
895
|
+
const alphanumeric = String(input).replace(/[^a-zA-Z0-9]/g, '');
|
|
896
|
+
if (alphanumeric.length > 0) {
|
|
897
|
+
return `${alphanumeric}@example.com`;
|
|
898
|
+
}
|
|
899
|
+
return input;
|
|
900
|
+
}
|
|
901
|
+
case 'zipcode': {
|
|
902
|
+
if (inputStr.length >= 5) {
|
|
903
|
+
return inputStr.substring(0, 5);
|
|
904
|
+
}
|
|
905
|
+
return inputStr;
|
|
906
|
+
}
|
|
907
|
+
default:
|
|
908
|
+
return input;
|
|
909
|
+
}
|
|
910
|
+
},
|
|
911
|
+
_signature: []
|
|
861
912
|
}
|
|
862
913
|
};
|
|
863
914
|
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.153",
|
|
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.153"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@babel/preset-env": "^7.20.2",
|