@aemforms/af-core 0.22.74 → 0.22.75
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 +917 -891
- package/esm/types/src/BaseNode.d.ts +4 -2
- package/esm/types/src/Checkbox.d.ts +1 -1
- package/esm/types/src/Container.d.ts +4 -2
- package/esm/types/src/Field.d.ts +1 -1
- package/esm/types/src/Form.d.ts +4 -2
- package/esm/types/src/utils/ValidationUtils.d.ts +2 -1
- package/lib/BaseNode.d.ts +4 -2
- package/lib/BaseNode.js +9 -1
- package/lib/Checkbox.d.ts +1 -1
- package/lib/Container.d.ts +4 -2
- package/lib/Field.d.ts +1 -1
- package/lib/Field.js +0 -1
- package/lib/Form.d.ts +4 -2
- package/lib/rules/FunctionRuntime.js +23 -5
- package/lib/utils/ValidationUtils.d.ts +2 -1
- package/lib/utils/ValidationUtils.js +3 -1
- package/package.json +2 -2
|
@@ -56,14 +56,16 @@ export declare abstract class BaseNode<T extends BaseJson> implements BaseModel
|
|
|
56
56
|
columnClassNames?: undefined;
|
|
57
57
|
columnCount?: undefined;
|
|
58
58
|
gridClassNames?: undefined;
|
|
59
|
+
':type': string;
|
|
60
|
+
repeatable?: boolean | undefined;
|
|
61
|
+
minOccur?: number | undefined;
|
|
62
|
+
maxOccur?: number | undefined;
|
|
59
63
|
properties: {
|
|
60
64
|
[key: string]: any;
|
|
61
65
|
};
|
|
62
66
|
index: number;
|
|
63
67
|
parent: undefined;
|
|
64
68
|
qualifiedName: any;
|
|
65
|
-
repeatable: boolean | undefined;
|
|
66
|
-
':type': string;
|
|
67
69
|
id: string;
|
|
68
70
|
};
|
|
69
71
|
subscribe(callback: callbackFn, eventName?: string): {
|
|
@@ -130,7 +130,7 @@ declare class Checkbox extends Field {
|
|
|
130
130
|
properties: {
|
|
131
131
|
[key: string]: any;
|
|
132
132
|
};
|
|
133
|
-
repeatable
|
|
133
|
+
repeatable?: boolean | undefined;
|
|
134
134
|
screenReaderText?: string | undefined;
|
|
135
135
|
tooltip?: string | undefined;
|
|
136
136
|
altText?: string | undefined;
|
|
@@ -37,14 +37,16 @@ declare abstract class Container<T extends ContainerJson & RulesJson> extends Sc
|
|
|
37
37
|
columnClassNames?: undefined;
|
|
38
38
|
columnCount?: undefined;
|
|
39
39
|
gridClassNames?: undefined;
|
|
40
|
+
':type': string;
|
|
41
|
+
repeatable?: boolean | undefined;
|
|
42
|
+
minOccur?: number | undefined;
|
|
43
|
+
maxOccur?: number | undefined;
|
|
40
44
|
properties: {
|
|
41
45
|
[key: string]: any;
|
|
42
46
|
};
|
|
43
47
|
index: number;
|
|
44
48
|
parent: undefined;
|
|
45
49
|
qualifiedName: any;
|
|
46
|
-
repeatable: boolean | undefined;
|
|
47
|
-
':type': string;
|
|
48
50
|
id: string;
|
|
49
51
|
};
|
|
50
52
|
private _createChild;
|
package/esm/types/src/Field.d.ts
CHANGED
|
@@ -197,7 +197,7 @@ declare class Field extends Scriptable<FieldJson> implements FieldModel {
|
|
|
197
197
|
properties: {
|
|
198
198
|
[key: string]: any;
|
|
199
199
|
};
|
|
200
|
-
repeatable
|
|
200
|
+
repeatable?: boolean | undefined;
|
|
201
201
|
screenReaderText?: string | undefined;
|
|
202
202
|
tooltip?: string | undefined;
|
|
203
203
|
altText?: string | undefined;
|
package/esm/types/src/Form.d.ts
CHANGED
|
@@ -91,14 +91,16 @@ declare class Form extends Container<FormJson> implements FormModel {
|
|
|
91
91
|
columnClassNames?: undefined;
|
|
92
92
|
columnCount?: undefined;
|
|
93
93
|
gridClassNames?: undefined;
|
|
94
|
+
':type': string;
|
|
95
|
+
repeatable?: boolean | undefined;
|
|
96
|
+
minOccur?: number | undefined;
|
|
97
|
+
maxOccur?: number | undefined;
|
|
94
98
|
properties: {
|
|
95
99
|
[key: string]: any;
|
|
96
100
|
};
|
|
97
101
|
index: number;
|
|
98
102
|
parent: undefined;
|
|
99
103
|
qualifiedName: any;
|
|
100
|
-
repeatable: boolean | undefined;
|
|
101
|
-
':type': string;
|
|
102
104
|
id: string;
|
|
103
105
|
};
|
|
104
106
|
get type(): string;
|
|
@@ -12,7 +12,8 @@ type ValidConstraintsType = {
|
|
|
12
12
|
email: ValidationConstraints[];
|
|
13
13
|
};
|
|
14
14
|
export declare const ValidConstraints: ValidConstraintsType;
|
|
15
|
-
export
|
|
15
|
+
export declare const validationConstraintsList: readonly ["type", "format", "minimum", "maximum", "exclusiveMinimum", "exclusiveMaximum", "minItems", "maxItems", "uniqueItems", "minLength", "maxLength", "pattern", "required", "enum", "accept", "maxFileSize"];
|
|
16
|
+
export type ValidationConstraints = typeof validationConstraintsList[number];
|
|
16
17
|
type ConstraintsObject = {
|
|
17
18
|
[key in ValidationConstraints]: (constraint: any, inputVal: any) => ValidationResult;
|
|
18
19
|
};
|
package/lib/BaseNode.d.ts
CHANGED
|
@@ -56,14 +56,16 @@ export declare abstract class BaseNode<T extends BaseJson> implements BaseModel
|
|
|
56
56
|
columnClassNames?: undefined;
|
|
57
57
|
columnCount?: undefined;
|
|
58
58
|
gridClassNames?: undefined;
|
|
59
|
+
':type': string;
|
|
60
|
+
repeatable?: boolean | undefined;
|
|
61
|
+
minOccur?: number | undefined;
|
|
62
|
+
maxOccur?: number | undefined;
|
|
59
63
|
properties: {
|
|
60
64
|
[key: string]: any;
|
|
61
65
|
};
|
|
62
66
|
index: number;
|
|
63
67
|
parent: undefined;
|
|
64
68
|
qualifiedName: any;
|
|
65
|
-
repeatable: boolean | undefined;
|
|
66
|
-
':type': string;
|
|
67
69
|
id: string;
|
|
68
70
|
};
|
|
69
71
|
subscribe(callback: callbackFn, eventName?: string): {
|
package/lib/BaseNode.js
CHANGED
|
@@ -13,6 +13,7 @@ exports.BaseNode = exports.exclude = exports.include = exports.dependencyTracked
|
|
|
13
13
|
const Events_1 = require("./controller/Events");
|
|
14
14
|
const DataRefParser_1 = require("./utils/DataRefParser");
|
|
15
15
|
const EmptyDataValue_1 = __importDefault(require("./data/EmptyDataValue"));
|
|
16
|
+
const ValidationUtils_1 = require("./utils/ValidationUtils");
|
|
16
17
|
exports.editableProperties = [
|
|
17
18
|
'value',
|
|
18
19
|
'label',
|
|
@@ -240,7 +241,11 @@ class BaseNode {
|
|
|
240
241
|
return !this._jsonModel.name && !isNonTransparent;
|
|
241
242
|
}
|
|
242
243
|
getState(forRestore = false) {
|
|
243
|
-
return Object.assign(Object.assign(Object.assign({}, this._jsonModel), { properties: this.properties, index: this.index, parent: undefined, qualifiedName: this.qualifiedName,
|
|
244
|
+
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, this._jsonModel), { properties: this.properties, index: this.index, parent: undefined, qualifiedName: this.qualifiedName }), (this.repeatable === true ? {
|
|
245
|
+
repeatable: true,
|
|
246
|
+
minOccur: this.parent.minItems,
|
|
247
|
+
maxOccur: this.parent.maxItems
|
|
248
|
+
} : {})), { ':type': this[':type'] }), (forRestore ? {
|
|
244
249
|
_dependents: this._dependents.length ? this._dependents.map(x => x.node.id) : undefined,
|
|
245
250
|
allowedComponents: undefined,
|
|
246
251
|
columnClassNames: undefined,
|
|
@@ -323,6 +328,9 @@ class BaseNode {
|
|
|
323
328
|
this.notifyDependents(changeAction);
|
|
324
329
|
}
|
|
325
330
|
notifyChildren.call(this, changeAction);
|
|
331
|
+
if (ValidationUtils_1.validationConstraintsList.includes(prop)) {
|
|
332
|
+
this.validate();
|
|
333
|
+
}
|
|
326
334
|
return changeAction.payload.changes;
|
|
327
335
|
}
|
|
328
336
|
return [];
|
package/lib/Checkbox.d.ts
CHANGED
|
@@ -130,7 +130,7 @@ declare class Checkbox extends Field {
|
|
|
130
130
|
properties: {
|
|
131
131
|
[key: string]: any;
|
|
132
132
|
};
|
|
133
|
-
repeatable
|
|
133
|
+
repeatable?: boolean | undefined;
|
|
134
134
|
screenReaderText?: string | undefined;
|
|
135
135
|
tooltip?: string | undefined;
|
|
136
136
|
altText?: string | undefined;
|
package/lib/Container.d.ts
CHANGED
|
@@ -37,14 +37,16 @@ declare abstract class Container<T extends ContainerJson & RulesJson> extends Sc
|
|
|
37
37
|
columnClassNames?: undefined;
|
|
38
38
|
columnCount?: undefined;
|
|
39
39
|
gridClassNames?: undefined;
|
|
40
|
+
':type': string;
|
|
41
|
+
repeatable?: boolean | undefined;
|
|
42
|
+
minOccur?: number | undefined;
|
|
43
|
+
maxOccur?: number | undefined;
|
|
40
44
|
properties: {
|
|
41
45
|
[key: string]: any;
|
|
42
46
|
};
|
|
43
47
|
index: number;
|
|
44
48
|
parent: undefined;
|
|
45
49
|
qualifiedName: any;
|
|
46
|
-
repeatable: boolean | undefined;
|
|
47
|
-
':type': string;
|
|
48
50
|
id: string;
|
|
49
51
|
};
|
|
50
52
|
private _createChild;
|
package/lib/Field.d.ts
CHANGED
|
@@ -197,7 +197,7 @@ declare class Field extends Scriptable<FieldJson> implements FieldModel {
|
|
|
197
197
|
properties: {
|
|
198
198
|
[key: string]: any;
|
|
199
199
|
};
|
|
200
|
-
repeatable
|
|
200
|
+
repeatable?: boolean | undefined;
|
|
201
201
|
screenReaderText?: string | undefined;
|
|
202
202
|
tooltip?: string | undefined;
|
|
203
203
|
altText?: string | undefined;
|
package/lib/Field.js
CHANGED
package/lib/Form.d.ts
CHANGED
|
@@ -91,14 +91,16 @@ declare class Form extends Container<FormJson> implements FormModel {
|
|
|
91
91
|
columnClassNames?: undefined;
|
|
92
92
|
columnCount?: undefined;
|
|
93
93
|
gridClassNames?: undefined;
|
|
94
|
+
':type': string;
|
|
95
|
+
repeatable?: boolean | undefined;
|
|
96
|
+
minOccur?: number | undefined;
|
|
97
|
+
maxOccur?: number | undefined;
|
|
94
98
|
properties: {
|
|
95
99
|
[key: string]: any;
|
|
96
100
|
};
|
|
97
101
|
index: number;
|
|
98
102
|
parent: undefined;
|
|
99
103
|
qualifiedName: any;
|
|
100
|
-
repeatable: boolean | undefined;
|
|
101
|
-
':type': string;
|
|
102
104
|
id: string;
|
|
103
105
|
};
|
|
104
106
|
get type(): string;
|
|
@@ -202,6 +202,11 @@ class FunctionRuntimeImpl {
|
|
|
202
202
|
},
|
|
203
203
|
exportData: () => {
|
|
204
204
|
return FunctionRuntimeImpl.getInstance().getFunctions().exportData._func.call(undefined, args, data, interpreter);
|
|
205
|
+
},
|
|
206
|
+
submitForm: (payload, validateForm, contentType) => {
|
|
207
|
+
const submitAs = contentType || 'multipart/form-data';
|
|
208
|
+
const args = ['custom:submitSuccess', 'custom:submitError', submitAs, payload, validateForm];
|
|
209
|
+
return FunctionRuntimeImpl.getInstance().getFunctions().submitForm._func.call(undefined, args, data, interpreter);
|
|
205
210
|
}
|
|
206
211
|
}
|
|
207
212
|
};
|
|
@@ -303,11 +308,24 @@ class FunctionRuntimeImpl {
|
|
|
303
308
|
},
|
|
304
309
|
submitForm: {
|
|
305
310
|
_func: (args, data, interpreter) => {
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
+
let success = 'custom:submitSuccess';
|
|
312
|
+
let error = 'custom:submitError';
|
|
313
|
+
let submit_data;
|
|
314
|
+
let validate_form;
|
|
315
|
+
let submit_as;
|
|
316
|
+
if (args.length > 0 && typeof valueOf(args[0]) === 'object') {
|
|
317
|
+
submit_data = args.length > 0 ? valueOf(args[0]) : null;
|
|
318
|
+
validate_form = args.length > 1 ? valueOf(args[1]) : true;
|
|
319
|
+
submit_as = args.length > 2 ? toString(args[2]) : 'multipart/form-data';
|
|
320
|
+
}
|
|
321
|
+
else {
|
|
322
|
+
interpreter.globals.form.logger.warn('This usage of submitForm is deprecated. Please see the documentation and update');
|
|
323
|
+
success = toString(args[0]);
|
|
324
|
+
error = toString(args[1]);
|
|
325
|
+
submit_as = args.length > 2 ? toString(args[2]) : 'multipart/form-data';
|
|
326
|
+
submit_data = args.length > 3 ? valueOf(args[3]) : null;
|
|
327
|
+
validate_form = args.length > 4 ? valueOf(args[4]) : true;
|
|
328
|
+
}
|
|
311
329
|
interpreter.globals.form.dispatch(new Events_1.Submit({
|
|
312
330
|
success,
|
|
313
331
|
error,
|
|
@@ -12,7 +12,8 @@ declare type ValidConstraintsType = {
|
|
|
12
12
|
email: ValidationConstraints[];
|
|
13
13
|
};
|
|
14
14
|
export declare const ValidConstraints: ValidConstraintsType;
|
|
15
|
-
export declare
|
|
15
|
+
export declare const validationConstraintsList: readonly ["type", "format", "minimum", "maximum", "exclusiveMinimum", "exclusiveMaximum", "minItems", "maxItems", "uniqueItems", "minLength", "maxLength", "pattern", "required", "enum", "accept", "maxFileSize"];
|
|
16
|
+
export declare type ValidationConstraints = typeof validationConstraintsList[number];
|
|
16
17
|
declare type ConstraintsObject = {
|
|
17
18
|
[key in ValidationConstraints]: (constraint: any, inputVal: any) => ValidationResult;
|
|
18
19
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Constraints = exports.ValidConstraints = exports.coerceType = void 0;
|
|
3
|
+
exports.Constraints = exports.validationConstraintsList = exports.ValidConstraints = exports.coerceType = void 0;
|
|
4
4
|
const FormUtils_1 = require("./FormUtils");
|
|
5
5
|
const FileObject_1 = require("../FileObject");
|
|
6
6
|
const dateRegex = /^(\d{4})-(\d{1,2})-(\d{1,2})$/;
|
|
@@ -118,6 +118,8 @@ exports.ValidConstraints = {
|
|
|
118
118
|
file: ['accept', 'maxFileSize'],
|
|
119
119
|
email: ['minLength', 'maxLength', 'format', 'pattern']
|
|
120
120
|
};
|
|
121
|
+
exports.validationConstraintsList = ['type', 'format', 'minimum', 'maximum', 'exclusiveMinimum', 'exclusiveMaximum', 'minItems',
|
|
122
|
+
'maxItems', 'uniqueItems', 'minLength', 'maxLength', 'pattern', 'required', 'enum', 'accept', 'maxFileSize'];
|
|
121
123
|
exports.Constraints = {
|
|
122
124
|
type: (constraint, inputVal) => {
|
|
123
125
|
let value = inputVal;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aemforms/af-core",
|
|
3
|
-
"version": "0.22.
|
|
3
|
+
"version": "0.22.75",
|
|
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.75"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@babel/preset-env": "^7.20.2",
|