@aemforms/af-core 0.22.164 → 0.22.166
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 -6
- package/esm/types/src/Container.d.ts +1 -0
- package/esm/types/src/Field.d.ts +1 -0
- package/esm/types/src/types/Json.d.ts +1 -1
- package/lib/Container.d.ts +1 -0
- package/lib/Container.js +6 -0
- package/lib/Field.d.ts +1 -0
- package/lib/Field.js +27 -5
- package/lib/Scriptable.js +3 -0
- package/lib/types/Json.d.ts +1 -1
- package/lib/types/Json.js +1 -1
- package/package.json +2 -2
package/esm/afb-runtime.js
CHANGED
|
@@ -57,7 +57,7 @@ const defaultConstraintTypeMessages = Object.freeze({
|
|
|
57
57
|
[ConstraintType.RANGE_UNDERFLOW]: 'Value must be greater than or equal to ${0}.',
|
|
58
58
|
[ConstraintType.TYPE_MISMATCH]: 'Please enter a valid value.',
|
|
59
59
|
[ConstraintType.VALUE_MISSING]: 'Please fill in this field.',
|
|
60
|
-
[ConstraintType.STEP_MISMATCH]: 'Please enter a valid value.',
|
|
60
|
+
[ConstraintType.STEP_MISMATCH]: 'Please enter a valid value. The two nearest valid values are ${0} and ${1}.',
|
|
61
61
|
[ConstraintType.FORMAT_MISMATCH]: 'Specify the value in allowed format : ${0}.',
|
|
62
62
|
[ConstraintType.ACCEPT_MISMATCH]: 'The specified file type not supported.',
|
|
63
63
|
[ConstraintType.FILE_SIZE_MISMATCH]: 'File too large. Reduce size and try again.',
|
|
@@ -2005,6 +2005,9 @@ class Scriptable extends BaseNode {
|
|
|
2005
2005
|
getCompiledEvent(eName) {
|
|
2006
2006
|
if (!(eName in this._events)) {
|
|
2007
2007
|
let eString = this._jsonModel.events?.[eName];
|
|
2008
|
+
if (eName === 'custom:setProperty' && typeof eString === 'undefined') {
|
|
2009
|
+
eString = ['$event.payload'];
|
|
2010
|
+
}
|
|
2008
2011
|
if (typeof eString === 'string' && eString.length > 0) {
|
|
2009
2012
|
eString = [eString];
|
|
2010
2013
|
}
|
|
@@ -2543,6 +2546,9 @@ class Container extends Scriptable {
|
|
|
2543
2546
|
x.reset();
|
|
2544
2547
|
});
|
|
2545
2548
|
}
|
|
2549
|
+
get valid() {
|
|
2550
|
+
return this.items.every((item) => item.valid);
|
|
2551
|
+
}
|
|
2546
2552
|
validate() {
|
|
2547
2553
|
return this.items.flatMap(x => {
|
|
2548
2554
|
return x.validate();
|
|
@@ -2679,6 +2685,9 @@ __decorate([
|
|
|
2679
2685
|
__decorate([
|
|
2680
2686
|
dependencyTracked()
|
|
2681
2687
|
], Container.prototype, "minItems", null);
|
|
2688
|
+
__decorate([
|
|
2689
|
+
dependencyTracked()
|
|
2690
|
+
], Container.prototype, "valid", null);
|
|
2682
2691
|
__decorate([
|
|
2683
2692
|
dependencyTracked()
|
|
2684
2693
|
], Container.prototype, "activeChild", null);
|
|
@@ -4967,10 +4976,32 @@ class Field extends Scriptable {
|
|
|
4967
4976
|
const afConstraintKey = constraint;
|
|
4968
4977
|
const html5ConstraintType = constraintKeys[afConstraintKey];
|
|
4969
4978
|
const constraintTypeMessages = getConstraintTypeMessages();
|
|
4970
|
-
|
|
4979
|
+
const customMessage = this._jsonModel.constraintMessages?.[afConstraintKey === 'exclusiveMaximum' ? 'maximum' :
|
|
4971
4980
|
afConstraintKey === 'exclusiveMinimum' ? 'minimum' :
|
|
4972
|
-
afConstraintKey]
|
|
4973
|
-
|
|
4981
|
+
afConstraintKey];
|
|
4982
|
+
if (customMessage) {
|
|
4983
|
+
const stepValues = constraint === 'step' ? this._getStepMessageValues() : [this._jsonModel[afConstraintKey]];
|
|
4984
|
+
return replaceTemplatePlaceholders(customMessage, stepValues.length === 2 ? stepValues : [this._jsonModel.step]);
|
|
4985
|
+
}
|
|
4986
|
+
if (constraint === 'step') {
|
|
4987
|
+
const stepValues = this._getStepMessageValues();
|
|
4988
|
+
if (stepValues.length === 2) {
|
|
4989
|
+
return replaceTemplatePlaceholders(constraintTypeMessages[html5ConstraintType], stepValues);
|
|
4990
|
+
}
|
|
4991
|
+
return 'Please enter a valid value.';
|
|
4992
|
+
}
|
|
4993
|
+
return replaceTemplatePlaceholders(constraintTypeMessages[html5ConstraintType], [this._jsonModel[afConstraintKey]]);
|
|
4994
|
+
}
|
|
4995
|
+
_getStepMessageValues() {
|
|
4996
|
+
const result = this.checkStep();
|
|
4997
|
+
if (!result.valid
|
|
4998
|
+
&& result.prev != null
|
|
4999
|
+
&& result.next != null
|
|
5000
|
+
&& Number.isFinite(result.prev)
|
|
5001
|
+
&& Number.isFinite(result.next)) {
|
|
5002
|
+
return [result.prev, result.next];
|
|
5003
|
+
}
|
|
5004
|
+
return [];
|
|
4974
5005
|
}
|
|
4975
5006
|
get errorMessage() {
|
|
4976
5007
|
return this._jsonModel.errorMessage;
|
|
@@ -5030,7 +5061,7 @@ class Field extends Scriptable {
|
|
|
5030
5061
|
let next, prev;
|
|
5031
5062
|
if (!valid) {
|
|
5032
5063
|
next = (Math.ceil(qt) * fStep + fIVal) / factor;
|
|
5033
|
-
prev =
|
|
5064
|
+
prev = next - step;
|
|
5034
5065
|
}
|
|
5035
5066
|
return {
|
|
5036
5067
|
valid,
|
|
@@ -5181,7 +5212,7 @@ class Field extends Scriptable {
|
|
|
5181
5212
|
else {
|
|
5182
5213
|
valid = this.checkEnum(value, Constraints);
|
|
5183
5214
|
constraint = 'enum';
|
|
5184
|
-
if (valid && this.type === 'number') {
|
|
5215
|
+
if (valid && (this.type === 'number' || this.type === 'integer')) {
|
|
5185
5216
|
valid = this.checkStep().valid;
|
|
5186
5217
|
constraint = 'step';
|
|
5187
5218
|
}
|
|
@@ -179,6 +179,7 @@ declare abstract class Container<T extends ContainerJson & RulesJson> extends Sc
|
|
|
179
179
|
removeItem(action: Action): void;
|
|
180
180
|
queueEvent(action: Action): void;
|
|
181
181
|
reset(): void;
|
|
182
|
+
get valid(): boolean;
|
|
182
183
|
validate(): import("./types/Model").ValidationError[];
|
|
183
184
|
dispatch(action: Action): void;
|
|
184
185
|
importData(dataModel: any): void;
|
package/esm/types/src/Field.d.ts
CHANGED
|
@@ -65,6 +65,7 @@ declare class Field extends Scriptable<FieldJson> implements FieldModel {
|
|
|
65
65
|
valueOf(): any;
|
|
66
66
|
toString(): any;
|
|
67
67
|
getErrorMessage(constraint: keyof (ConstraintsMessages)): string;
|
|
68
|
+
private _getStepMessageValues;
|
|
68
69
|
get errorMessage(): string | undefined;
|
|
69
70
|
set errorMessage(e: string | undefined);
|
|
70
71
|
set constraintMessage(constraint: {
|
|
@@ -179,7 +179,7 @@ export declare const getConstraintTypeMessages: () => {
|
|
|
179
179
|
rangeUnderflow: "Value must be greater than or equal to ${0}.";
|
|
180
180
|
typeMismatch: "Please enter a valid value.";
|
|
181
181
|
valueMissing: "Please fill in this field.";
|
|
182
|
-
stepMismatch: "Please enter a valid value.";
|
|
182
|
+
stepMismatch: "Please enter a valid value. The two nearest valid values are ${0} and ${1}.";
|
|
183
183
|
formatMismatch: "Specify the value in allowed format : ${0}.";
|
|
184
184
|
acceptMismatch: "The specified file type not supported.";
|
|
185
185
|
fileSizeMismatch: "File too large. Reduce size and try again.";
|
package/lib/Container.d.ts
CHANGED
|
@@ -179,6 +179,7 @@ declare abstract class Container<T extends ContainerJson & RulesJson> extends Sc
|
|
|
179
179
|
removeItem(action: Action): void;
|
|
180
180
|
queueEvent(action: Action): void;
|
|
181
181
|
reset(): void;
|
|
182
|
+
get valid(): boolean;
|
|
182
183
|
validate(): import("./types/Model").ValidationError[];
|
|
183
184
|
dispatch(action: Action): void;
|
|
184
185
|
importData(dataModel: any): void;
|
package/lib/Container.js
CHANGED
|
@@ -347,6 +347,9 @@ class Container extends Scriptable_1.default {
|
|
|
347
347
|
x.reset();
|
|
348
348
|
});
|
|
349
349
|
}
|
|
350
|
+
get valid() {
|
|
351
|
+
return this.items.every((item) => item.valid);
|
|
352
|
+
}
|
|
350
353
|
validate() {
|
|
351
354
|
return this.items.flatMap(x => {
|
|
352
355
|
return x.validate();
|
|
@@ -487,6 +490,9 @@ __decorate([
|
|
|
487
490
|
__decorate([
|
|
488
491
|
(0, BaseNode_1.dependencyTracked)()
|
|
489
492
|
], Container.prototype, "minItems", null);
|
|
493
|
+
__decorate([
|
|
494
|
+
(0, BaseNode_1.dependencyTracked)()
|
|
495
|
+
], Container.prototype, "valid", null);
|
|
490
496
|
__decorate([
|
|
491
497
|
(0, BaseNode_1.dependencyTracked)()
|
|
492
498
|
], Container.prototype, "activeChild", null);
|
package/lib/Field.d.ts
CHANGED
|
@@ -65,6 +65,7 @@ declare class Field extends Scriptable<FieldJson> implements FieldModel {
|
|
|
65
65
|
valueOf(): any;
|
|
66
66
|
toString(): any;
|
|
67
67
|
getErrorMessage(constraint: keyof (ConstraintsMessages)): string;
|
|
68
|
+
private _getStepMessageValues;
|
|
68
69
|
get errorMessage(): string | undefined;
|
|
69
70
|
set errorMessage(e: string | undefined);
|
|
70
71
|
set constraintMessage(constraint: {
|
package/lib/Field.js
CHANGED
|
@@ -478,10 +478,32 @@ class Field extends Scriptable_1.default {
|
|
|
478
478
|
const afConstraintKey = constraint;
|
|
479
479
|
const html5ConstraintType = types_1.constraintKeys[afConstraintKey];
|
|
480
480
|
const constraintTypeMessages = (0, types_1.getConstraintTypeMessages)();
|
|
481
|
-
|
|
481
|
+
const customMessage = (_a = this._jsonModel.constraintMessages) === null || _a === void 0 ? void 0 : _a[afConstraintKey === 'exclusiveMaximum' ? 'maximum' :
|
|
482
482
|
afConstraintKey === 'exclusiveMinimum' ? 'minimum' :
|
|
483
|
-
afConstraintKey]
|
|
484
|
-
|
|
483
|
+
afConstraintKey];
|
|
484
|
+
if (customMessage) {
|
|
485
|
+
const stepValues = constraint === 'step' ? this._getStepMessageValues() : [this._jsonModel[afConstraintKey]];
|
|
486
|
+
return (0, FormUtils_1.replaceTemplatePlaceholders)(customMessage, stepValues.length === 2 ? stepValues : [this._jsonModel.step]);
|
|
487
|
+
}
|
|
488
|
+
if (constraint === 'step') {
|
|
489
|
+
const stepValues = this._getStepMessageValues();
|
|
490
|
+
if (stepValues.length === 2) {
|
|
491
|
+
return (0, FormUtils_1.replaceTemplatePlaceholders)(constraintTypeMessages[html5ConstraintType], stepValues);
|
|
492
|
+
}
|
|
493
|
+
return 'Please enter a valid value.';
|
|
494
|
+
}
|
|
495
|
+
return (0, FormUtils_1.replaceTemplatePlaceholders)(constraintTypeMessages[html5ConstraintType], [this._jsonModel[afConstraintKey]]);
|
|
496
|
+
}
|
|
497
|
+
_getStepMessageValues() {
|
|
498
|
+
const result = this.checkStep();
|
|
499
|
+
if (!result.valid
|
|
500
|
+
&& result.prev != null
|
|
501
|
+
&& result.next != null
|
|
502
|
+
&& Number.isFinite(result.prev)
|
|
503
|
+
&& Number.isFinite(result.next)) {
|
|
504
|
+
return [result.prev, result.next];
|
|
505
|
+
}
|
|
506
|
+
return [];
|
|
485
507
|
}
|
|
486
508
|
get errorMessage() {
|
|
487
509
|
return this._jsonModel.errorMessage;
|
|
@@ -537,7 +559,7 @@ class Field extends Scriptable_1.default {
|
|
|
537
559
|
let next, prev;
|
|
538
560
|
if (!valid) {
|
|
539
561
|
next = (Math.ceil(qt) * fStep + fIVal) / factor;
|
|
540
|
-
prev =
|
|
562
|
+
prev = next - step;
|
|
541
563
|
}
|
|
542
564
|
return {
|
|
543
565
|
valid,
|
|
@@ -688,7 +710,7 @@ class Field extends Scriptable_1.default {
|
|
|
688
710
|
else {
|
|
689
711
|
valid = this.checkEnum(value, Constraints);
|
|
690
712
|
constraint = 'enum';
|
|
691
|
-
if (valid && this.type === 'number') {
|
|
713
|
+
if (valid && (this.type === 'number' || this.type === 'integer')) {
|
|
692
714
|
valid = this.checkStep().valid;
|
|
693
715
|
constraint = 'step';
|
|
694
716
|
}
|
package/lib/Scriptable.js
CHANGED
|
@@ -47,6 +47,9 @@ class Scriptable extends BaseNode_1.BaseNode {
|
|
|
47
47
|
var _a;
|
|
48
48
|
if (!(eName in this._events)) {
|
|
49
49
|
let eString = (_a = this._jsonModel.events) === null || _a === void 0 ? void 0 : _a[eName];
|
|
50
|
+
if (eName === 'custom:setProperty' && typeof eString === 'undefined') {
|
|
51
|
+
eString = ['$event.payload'];
|
|
52
|
+
}
|
|
50
53
|
if (typeof eString === 'string' && eString.length > 0) {
|
|
51
54
|
eString = [eString];
|
|
52
55
|
}
|
package/lib/types/Json.d.ts
CHANGED
|
@@ -179,7 +179,7 @@ export declare const getConstraintTypeMessages: () => {
|
|
|
179
179
|
rangeUnderflow: "Value must be greater than or equal to ${0}.";
|
|
180
180
|
typeMismatch: "Please enter a valid value.";
|
|
181
181
|
valueMissing: "Please fill in this field.";
|
|
182
|
-
stepMismatch: "Please enter a valid value.";
|
|
182
|
+
stepMismatch: "Please enter a valid value. The two nearest valid values are ${0} and ${1}.";
|
|
183
183
|
formatMismatch: "Specify the value in allowed format : ${0}.";
|
|
184
184
|
acceptMismatch: "The specified file type not supported.";
|
|
185
185
|
fileSizeMismatch: "File too large. Reduce size and try again.";
|
package/lib/types/Json.js
CHANGED
|
@@ -56,7 +56,7 @@ const defaultConstraintTypeMessages = Object.freeze({
|
|
|
56
56
|
[exports.ConstraintType.RANGE_UNDERFLOW]: 'Value must be greater than or equal to ${0}.',
|
|
57
57
|
[exports.ConstraintType.TYPE_MISMATCH]: 'Please enter a valid value.',
|
|
58
58
|
[exports.ConstraintType.VALUE_MISSING]: 'Please fill in this field.',
|
|
59
|
-
[exports.ConstraintType.STEP_MISMATCH]: 'Please enter a valid value.',
|
|
59
|
+
[exports.ConstraintType.STEP_MISMATCH]: 'Please enter a valid value. The two nearest valid values are ${0} and ${1}.',
|
|
60
60
|
[exports.ConstraintType.FORMAT_MISMATCH]: 'Specify the value in allowed format : ${0}.',
|
|
61
61
|
[exports.ConstraintType.ACCEPT_MISMATCH]: 'The specified file type not supported.',
|
|
62
62
|
[exports.ConstraintType.FILE_SIZE_MISMATCH]: 'File too large. Reduce size and try again.',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aemforms/af-core",
|
|
3
|
-
"version": "0.22.
|
|
3
|
+
"version": "0.22.166",
|
|
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.166"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@babel/preset-env": "^7.20.2",
|