@aemforms/af-core 0.22.17 → 0.22.18
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/lib/BaseNode.d.ts +11 -0
- package/lib/BaseNode.js +36 -8
- package/lib/CheckboxGroup.js +3 -0
- package/lib/Container.d.ts +22 -215
- package/lib/Container.js +6 -3
- package/lib/Field.d.ts +24 -8
- package/lib/Field.js +179 -13
- package/lib/FileObject.d.ts +3 -2
- package/lib/FileObject.js +6 -3
- package/lib/FileUpload.d.ts +2 -1
- package/lib/FileUpload.js +4 -1
- package/lib/Form.d.ts +35 -196
- package/lib/Scriptable.d.ts +1 -1
- package/lib/Scriptable.js +4 -4
- package/lib/types/Json.d.ts +3 -0
- package/lib/types/Model.d.ts +7 -6
- package/lib/utils/FormUtils.js +8 -5
- package/lib/utils/ValidationUtils.js +14 -0
- package/package.json +2 -2
package/lib/Scriptable.js
CHANGED
|
@@ -18,12 +18,12 @@ class Scriptable extends BaseNode_1.BaseNode {
|
|
|
18
18
|
this._events = {};
|
|
19
19
|
this._rules = {};
|
|
20
20
|
}
|
|
21
|
-
|
|
22
|
-
return this._jsonModel.rules
|
|
21
|
+
getRules() {
|
|
22
|
+
return typeof this._jsonModel.rules !== 'object' ? {} : this._jsonModel.rules;
|
|
23
23
|
}
|
|
24
24
|
getCompiledRule(eName, rule) {
|
|
25
25
|
if (!(eName in this._rules)) {
|
|
26
|
-
const eString = rule || this.
|
|
26
|
+
const eString = rule || this.getRules()[eName];
|
|
27
27
|
if (typeof eString === 'string' && eString.length > 0) {
|
|
28
28
|
try {
|
|
29
29
|
this._rules[eName] = this.ruleEngine.compileRule(eString);
|
|
@@ -76,7 +76,7 @@ class Scriptable extends BaseNode_1.BaseNode {
|
|
|
76
76
|
});
|
|
77
77
|
}
|
|
78
78
|
executeAllRules(context) {
|
|
79
|
-
const entries = Object.entries(this.
|
|
79
|
+
const entries = Object.entries(this.getRules());
|
|
80
80
|
if (entries.length > 0) {
|
|
81
81
|
const scope = this.getExpressionScope();
|
|
82
82
|
entries.forEach(([prop, rule]) => {
|
package/lib/types/Json.d.ts
CHANGED
|
@@ -82,6 +82,9 @@ export declare type BaseJson = TranslationBaseJson & RulesJson & ConstraintsJson
|
|
|
82
82
|
properties?: {
|
|
83
83
|
[key: string]: any;
|
|
84
84
|
};
|
|
85
|
+
screenReaderText?: string;
|
|
86
|
+
tooltip?: string;
|
|
87
|
+
altText?: string;
|
|
85
88
|
};
|
|
86
89
|
/** Type for `form field properties`which can be translated based on `adaptive form specification` */
|
|
87
90
|
declare type TranslationFieldJson = {
|
package/lib/types/Model.d.ts
CHANGED
|
@@ -39,14 +39,15 @@ interface WithState<T> {
|
|
|
39
39
|
*/
|
|
40
40
|
getState: () => State<T>;
|
|
41
41
|
}
|
|
42
|
-
|
|
43
|
-
export declare type State<T> = T extends ContainerJson ? T & {
|
|
44
|
-
id: string;
|
|
45
|
-
items: Array<State<FieldJson | ContainerJson>>;
|
|
46
|
-
} : T & {
|
|
42
|
+
declare type stateProps = {
|
|
47
43
|
id: string;
|
|
44
|
+
index: number;
|
|
48
45
|
':type': string;
|
|
49
46
|
};
|
|
47
|
+
/** Generic type for a form object state */
|
|
48
|
+
export declare type State<T> = stateProps & (T extends ContainerJson ? T & {
|
|
49
|
+
items: Array<State<FieldJson | ContainerJson>>;
|
|
50
|
+
} : T);
|
|
50
51
|
/**
|
|
51
52
|
* @private
|
|
52
53
|
*/
|
|
@@ -344,7 +345,7 @@ export interface IFileObject {
|
|
|
344
345
|
/**
|
|
345
346
|
* Media type of the file data
|
|
346
347
|
*/
|
|
347
|
-
|
|
348
|
+
mediaType: string;
|
|
348
349
|
/**
|
|
349
350
|
* Data of the file attachment. It can be uri or any file interface specific to channel (in web, it is file object).
|
|
350
351
|
*/
|
package/lib/utils/FormUtils.js
CHANGED
|
@@ -150,7 +150,7 @@ const extractFileInfo = (file) => {
|
|
|
150
150
|
// case: file object
|
|
151
151
|
retVal = {
|
|
152
152
|
name: file.name,
|
|
153
|
-
|
|
153
|
+
mediaType: file.type,
|
|
154
154
|
size: file.size,
|
|
155
155
|
data: file
|
|
156
156
|
};
|
|
@@ -162,7 +162,7 @@ const extractFileInfo = (file) => {
|
|
|
162
162
|
const { blob, name } = result;
|
|
163
163
|
retVal = {
|
|
164
164
|
name: name,
|
|
165
|
-
|
|
165
|
+
mediaType: blob.type,
|
|
166
166
|
size: blob.size,
|
|
167
167
|
data: blob
|
|
168
168
|
};
|
|
@@ -174,6 +174,9 @@ const extractFileInfo = (file) => {
|
|
|
174
174
|
try {
|
|
175
175
|
jFile = JSON.parse(file);
|
|
176
176
|
retVal = jFile;
|
|
177
|
+
if (!retVal.mediaType) {
|
|
178
|
+
retVal.mediaType = retVal.type;
|
|
179
|
+
}
|
|
177
180
|
}
|
|
178
181
|
catch (ex) {
|
|
179
182
|
// do nothing
|
|
@@ -185,7 +188,7 @@ const extractFileInfo = (file) => {
|
|
|
185
188
|
const blob = result.blob;
|
|
186
189
|
retVal = {
|
|
187
190
|
name: jFile === null || jFile === void 0 ? void 0 : jFile.name,
|
|
188
|
-
|
|
191
|
+
mediaType: (jFile === null || jFile === void 0 ? void 0 : jFile.type) || (jFile === null || jFile === void 0 ? void 0 : jFile.mediaType),
|
|
189
192
|
size: blob.size,
|
|
190
193
|
data: blob
|
|
191
194
|
};
|
|
@@ -196,7 +199,7 @@ const extractFileInfo = (file) => {
|
|
|
196
199
|
const fileName = jFile.split('/').pop();
|
|
197
200
|
retVal = {
|
|
198
201
|
name: fileName,
|
|
199
|
-
|
|
202
|
+
mediaType: 'application/octet-stream',
|
|
200
203
|
size: 0,
|
|
201
204
|
data: jFile
|
|
202
205
|
};
|
|
@@ -205,7 +208,7 @@ const extractFileInfo = (file) => {
|
|
|
205
208
|
// todo: just added for ease of integration for the view layer
|
|
206
209
|
retVal = {
|
|
207
210
|
name: jFile === null || jFile === void 0 ? void 0 : jFile.name,
|
|
208
|
-
|
|
211
|
+
mediaType: (jFile === null || jFile === void 0 ? void 0 : jFile.type) || (jFile === null || jFile === void 0 ? void 0 : jFile.mediaType),
|
|
209
212
|
size: jFile === null || jFile === void 0 ? void 0 : jFile.size,
|
|
210
213
|
data: jFile === null || jFile === void 0 ? void 0 : jFile.data
|
|
211
214
|
};
|
|
@@ -49,6 +49,11 @@ exports.isDataUrl = isDataUrl;
|
|
|
49
49
|
* @returns {@link ValidationResult | Validation result}
|
|
50
50
|
*/
|
|
51
51
|
const checkNumber = (inputVal) => {
|
|
52
|
+
if (inputVal === '' || inputVal == null) {
|
|
53
|
+
return {
|
|
54
|
+
value: '', valid: true
|
|
55
|
+
};
|
|
56
|
+
}
|
|
52
57
|
let value = parseFloat(inputVal);
|
|
53
58
|
const valid = !isNaN(value);
|
|
54
59
|
if (!valid) {
|
|
@@ -58,7 +63,16 @@ const checkNumber = (inputVal) => {
|
|
|
58
63
|
value, valid
|
|
59
64
|
};
|
|
60
65
|
};
|
|
66
|
+
/**
|
|
67
|
+
*
|
|
68
|
+
* @param inputVal
|
|
69
|
+
*/
|
|
61
70
|
const checkInteger = (inputVal) => {
|
|
71
|
+
if (inputVal == '' || inputVal == null) {
|
|
72
|
+
return {
|
|
73
|
+
value: '', valid: true
|
|
74
|
+
};
|
|
75
|
+
}
|
|
62
76
|
let value = parseFloat(inputVal);
|
|
63
77
|
const valid = !isNaN(value) && Math.round(value) === value;
|
|
64
78
|
if (!valid) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aemforms/af-core",
|
|
3
|
-
"version": "0.22.
|
|
3
|
+
"version": "0.22.18",
|
|
4
4
|
"description": "Core Module for Forms Runtime",
|
|
5
5
|
"author": "Adobe Systems",
|
|
6
6
|
"license": "Adobe Proprietary",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@adobe/json-formula": "^0.1.44",
|
|
38
|
-
"@aemforms/af-formatters": "^0.22.
|
|
38
|
+
"@aemforms/af-formatters": "^0.22.18"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@types/jest": "^27.5.1",
|