@aemforms/af-core 0.22.75 → 0.22.77
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 +27 -6
- package/esm/types/src/Checkbox.d.ts +2 -1
- package/esm/types/src/Field.d.ts +5 -3
- package/esm/types/src/Form.d.ts +1 -1
- package/esm/types/src/types/Json.d.ts +2 -5
- package/esm/types/src/types/Model.d.ts +1 -0
- package/lib/BaseNode.js +1 -1
- package/lib/Checkbox.d.ts +2 -1
- package/lib/Field.d.ts +5 -3
- package/lib/Field.js +6 -0
- package/lib/Form.d.ts +1 -1
- package/lib/Form.js +2 -2
- package/lib/rules/FunctionRuntime.js +19 -3
- package/lib/types/Json.d.ts +2 -5
- package/lib/types/Model.d.ts +1 -0
- package/lib/utils/TranslationUtils.js +0 -5
- package/package.json +2 -2
package/esm/afb-runtime.js
CHANGED
|
@@ -1439,7 +1439,7 @@ class BaseNode {
|
|
|
1439
1439
|
return [];
|
|
1440
1440
|
}
|
|
1441
1441
|
_bindToDataModel(contextualDataModel) {
|
|
1442
|
-
if (this.id === '$form') {
|
|
1442
|
+
if (this.fieldType === 'form' || this.id === '$form') {
|
|
1443
1443
|
this._data = contextualDataModel;
|
|
1444
1444
|
return;
|
|
1445
1445
|
}
|
|
@@ -2626,8 +2626,23 @@ class FunctionRuntimeImpl {
|
|
|
2626
2626
|
},
|
|
2627
2627
|
submitForm: (payload, validateForm, contentType) => {
|
|
2628
2628
|
const submitAs = contentType || 'multipart/form-data';
|
|
2629
|
-
const args = [
|
|
2629
|
+
const args = [payload, validateForm, submitAs];
|
|
2630
2630
|
return FunctionRuntimeImpl.getInstance().getFunctions().submitForm._func.call(undefined, args, data, interpreter);
|
|
2631
|
+
},
|
|
2632
|
+
markFieldAsInvalid: (fieldIdentifier, validationMessage, option) => {
|
|
2633
|
+
if (!option || option.useId) {
|
|
2634
|
+
interpreter.globals.form.getElement(fieldIdentifier)?.markAsInvalid(validationMessage);
|
|
2635
|
+
}
|
|
2636
|
+
else if (option && option.useDataRef) {
|
|
2637
|
+
interpreter.globals.form.visit(function callback(f) {
|
|
2638
|
+
if (f.dataRef === fieldIdentifier) {
|
|
2639
|
+
f.markAsInvalid(validationMessage);
|
|
2640
|
+
}
|
|
2641
|
+
});
|
|
2642
|
+
}
|
|
2643
|
+
else if (option && option.useQualifiedName) {
|
|
2644
|
+
interpreter.globals.form.resolveQualifiedName(fieldIdentifier)?.markAsInvalid(validationMessage);
|
|
2645
|
+
}
|
|
2631
2646
|
}
|
|
2632
2647
|
}
|
|
2633
2648
|
};
|
|
@@ -2729,8 +2744,8 @@ class FunctionRuntimeImpl {
|
|
|
2729
2744
|
},
|
|
2730
2745
|
submitForm: {
|
|
2731
2746
|
_func: (args, data, interpreter) => {
|
|
2732
|
-
let success =
|
|
2733
|
-
let error =
|
|
2747
|
+
let success = null;
|
|
2748
|
+
let error = null;
|
|
2734
2749
|
let submit_data;
|
|
2735
2750
|
let validate_form;
|
|
2736
2751
|
let submit_as;
|
|
@@ -3046,7 +3061,7 @@ class Form extends Container {
|
|
|
3046
3061
|
};
|
|
3047
3062
|
});
|
|
3048
3063
|
const fieldChangedAction = new FieldChanged(changes, field);
|
|
3049
|
-
this.
|
|
3064
|
+
this.notifyDependents(fieldChangedAction);
|
|
3050
3065
|
}
|
|
3051
3066
|
});
|
|
3052
3067
|
}
|
|
@@ -3110,7 +3125,7 @@ class Form extends Container {
|
|
|
3110
3125
|
return null;
|
|
3111
3126
|
}
|
|
3112
3127
|
get id() {
|
|
3113
|
-
return '$form';
|
|
3128
|
+
return this._jsonModel.id || '$form';
|
|
3114
3129
|
}
|
|
3115
3130
|
get title() {
|
|
3116
3131
|
return this._jsonModel.title || '';
|
|
@@ -3412,6 +3427,9 @@ class Field extends Scriptable {
|
|
|
3412
3427
|
get displayFormat() {
|
|
3413
3428
|
return this.withCategory(this._jsonModel.displayFormat);
|
|
3414
3429
|
}
|
|
3430
|
+
get displayValueExpression() {
|
|
3431
|
+
return this._jsonModel.displayValueExpression;
|
|
3432
|
+
}
|
|
3415
3433
|
get placeholder() {
|
|
3416
3434
|
return this._jsonModel.placeholder;
|
|
3417
3435
|
}
|
|
@@ -3529,6 +3547,9 @@ class Field extends Scriptable {
|
|
|
3529
3547
|
}
|
|
3530
3548
|
}
|
|
3531
3549
|
get displayValue() {
|
|
3550
|
+
if (this.displayValueExpression && typeof this.displayValueExpression === 'string' && this.displayValueExpression.length !== 0) {
|
|
3551
|
+
return this.executeExpression(this.displayValueExpression);
|
|
3552
|
+
}
|
|
3532
3553
|
const df = this.displayFormat;
|
|
3533
3554
|
if (df && this.isNotEmpty(this.value) && this.valid !== false) {
|
|
3534
3555
|
try {
|
|
@@ -95,7 +95,7 @@ declare class Checkbox extends Field {
|
|
|
95
95
|
description?: string | undefined;
|
|
96
96
|
rules?: import("./types").Items<string> | undefined;
|
|
97
97
|
events?: import("./types").Items<string | string[] | undefined> | undefined;
|
|
98
|
-
enumNames?: string[] |
|
|
98
|
+
enumNames?: string[] | undefined;
|
|
99
99
|
enum?: any[] | undefined;
|
|
100
100
|
accept?: string[] | undefined;
|
|
101
101
|
enforceEnum?: boolean | undefined;
|
|
@@ -141,6 +141,7 @@ declare class Checkbox extends Field {
|
|
|
141
141
|
validationMessage?: string | undefined;
|
|
142
142
|
default?: any;
|
|
143
143
|
value?: any;
|
|
144
|
+
displayValueExpression?: string | undefined;
|
|
144
145
|
emptyValue?: "" | "undefined" | "null" | undefined;
|
|
145
146
|
_dependents?: string[] | undefined;
|
|
146
147
|
allowedComponents?: undefined;
|
package/esm/types/src/Field.d.ts
CHANGED
|
@@ -28,6 +28,7 @@ declare class Field extends Scriptable<FieldJson> implements FieldModel {
|
|
|
28
28
|
private coerceParam;
|
|
29
29
|
get editFormat(): string | undefined;
|
|
30
30
|
get displayFormat(): string | undefined;
|
|
31
|
+
get displayValueExpression(): string | undefined;
|
|
31
32
|
get placeholder(): string | undefined;
|
|
32
33
|
get readOnly(): boolean | undefined;
|
|
33
34
|
set readOnly(e: boolean | undefined);
|
|
@@ -39,8 +40,8 @@ declare class Field extends Scriptable<FieldJson> implements FieldModel {
|
|
|
39
40
|
get emptyValue(): "" | null | undefined;
|
|
40
41
|
get enum(): any[] | undefined;
|
|
41
42
|
set enum(e: any[] | undefined);
|
|
42
|
-
get enumNames(): string[] |
|
|
43
|
-
set enumNames(e: string[] |
|
|
43
|
+
get enumNames(): string[] | undefined;
|
|
44
|
+
set enumNames(e: string[] | undefined);
|
|
44
45
|
get required(): boolean;
|
|
45
46
|
set required(r: boolean);
|
|
46
47
|
get maximum(): number | undefined;
|
|
@@ -162,7 +163,7 @@ declare class Field extends Scriptable<FieldJson> implements FieldModel {
|
|
|
162
163
|
description?: string | undefined;
|
|
163
164
|
rules?: import("./types").Items<string> | undefined;
|
|
164
165
|
events?: import("./types").Items<string | string[] | undefined> | undefined;
|
|
165
|
-
enumNames?: string[] |
|
|
166
|
+
enumNames?: string[] | undefined;
|
|
166
167
|
enum?: any[] | undefined;
|
|
167
168
|
accept?: string[] | undefined;
|
|
168
169
|
enforceEnum?: boolean | undefined;
|
|
@@ -208,6 +209,7 @@ declare class Field extends Scriptable<FieldJson> implements FieldModel {
|
|
|
208
209
|
validationMessage?: string | undefined;
|
|
209
210
|
default?: any;
|
|
210
211
|
value?: any;
|
|
212
|
+
displayValueExpression?: string | undefined;
|
|
211
213
|
emptyValue?: "" | "undefined" | "null" | undefined;
|
|
212
214
|
checked?: boolean | undefined;
|
|
213
215
|
_dependents?: string[] | undefined;
|
package/esm/types/src/Form.d.ts
CHANGED
|
@@ -26,7 +26,7 @@ declare class Form extends Container<FormJson> implements FormModel {
|
|
|
26
26
|
getState(forRestore?: boolean): {
|
|
27
27
|
description?: string | undefined;
|
|
28
28
|
} & import("./types/Json").RulesJson & {
|
|
29
|
-
enumNames?: string[] |
|
|
29
|
+
enumNames?: string[] | undefined;
|
|
30
30
|
enum?: any[] | undefined;
|
|
31
31
|
} & {
|
|
32
32
|
accept?: string[] | undefined;
|
|
@@ -7,12 +7,8 @@ export type Label = {
|
|
|
7
7
|
richText?: boolean;
|
|
8
8
|
visible?: boolean;
|
|
9
9
|
};
|
|
10
|
-
export type EnumName = {
|
|
11
|
-
value: string;
|
|
12
|
-
richText?: boolean;
|
|
13
|
-
};
|
|
14
10
|
type TranslationConstraintsJson = {
|
|
15
|
-
enumNames?: string[]
|
|
11
|
+
enumNames?: string[];
|
|
16
12
|
enum?: any[];
|
|
17
13
|
};
|
|
18
14
|
export type ConstraintsJson = TranslationConstraintsJson & {
|
|
@@ -99,6 +95,7 @@ export type FieldJson = BaseJson & TranslationFieldJson & {
|
|
|
99
95
|
editFormat?: string;
|
|
100
96
|
editValue?: string;
|
|
101
97
|
displayValue?: string;
|
|
98
|
+
displayValueExpression?: string;
|
|
102
99
|
emptyValue?: 'null' | 'undefined' | '';
|
|
103
100
|
checked?: boolean;
|
|
104
101
|
};
|
|
@@ -78,6 +78,7 @@ export interface FieldModel extends BaseModel, ScriptableField, WithState<FieldJ
|
|
|
78
78
|
readonly editFormat?: string;
|
|
79
79
|
readonly displayFormat?: string;
|
|
80
80
|
readonly displayValue?: string;
|
|
81
|
+
readonly displayValueExpression?: string;
|
|
81
82
|
readonly editValue?: string;
|
|
82
83
|
}
|
|
83
84
|
export interface FormMetaDataModel {
|
package/lib/BaseNode.js
CHANGED
package/lib/Checkbox.d.ts
CHANGED
|
@@ -95,7 +95,7 @@ declare class Checkbox extends Field {
|
|
|
95
95
|
description?: string | undefined;
|
|
96
96
|
rules?: import("./types").Items<string> | undefined;
|
|
97
97
|
events?: import("./types").Items<string | string[] | undefined> | undefined;
|
|
98
|
-
enumNames?: string[] |
|
|
98
|
+
enumNames?: string[] | undefined;
|
|
99
99
|
enum?: any[] | undefined;
|
|
100
100
|
accept?: string[] | undefined;
|
|
101
101
|
enforceEnum?: boolean | undefined;
|
|
@@ -141,6 +141,7 @@ declare class Checkbox extends Field {
|
|
|
141
141
|
validationMessage?: string | undefined;
|
|
142
142
|
default?: any;
|
|
143
143
|
value?: any;
|
|
144
|
+
displayValueExpression?: string | undefined;
|
|
144
145
|
emptyValue?: "" | "undefined" | "null" | undefined;
|
|
145
146
|
_dependents?: string[] | undefined;
|
|
146
147
|
allowedComponents?: undefined;
|
package/lib/Field.d.ts
CHANGED
|
@@ -28,6 +28,7 @@ declare class Field extends Scriptable<FieldJson> implements FieldModel {
|
|
|
28
28
|
private coerceParam;
|
|
29
29
|
get editFormat(): string | undefined;
|
|
30
30
|
get displayFormat(): string | undefined;
|
|
31
|
+
get displayValueExpression(): string | undefined;
|
|
31
32
|
get placeholder(): string | undefined;
|
|
32
33
|
get readOnly(): boolean | undefined;
|
|
33
34
|
set readOnly(e: boolean | undefined);
|
|
@@ -39,8 +40,8 @@ declare class Field extends Scriptable<FieldJson> implements FieldModel {
|
|
|
39
40
|
get emptyValue(): "" | null | undefined;
|
|
40
41
|
get enum(): any[] | undefined;
|
|
41
42
|
set enum(e: any[] | undefined);
|
|
42
|
-
get enumNames(): string[] |
|
|
43
|
-
set enumNames(e: string[] |
|
|
43
|
+
get enumNames(): string[] | undefined;
|
|
44
|
+
set enumNames(e: string[] | undefined);
|
|
44
45
|
get required(): boolean;
|
|
45
46
|
set required(r: boolean);
|
|
46
47
|
get maximum(): number | undefined;
|
|
@@ -162,7 +163,7 @@ declare class Field extends Scriptable<FieldJson> implements FieldModel {
|
|
|
162
163
|
description?: string | undefined;
|
|
163
164
|
rules?: import("./types").Items<string> | undefined;
|
|
164
165
|
events?: import("./types").Items<string | string[] | undefined> | undefined;
|
|
165
|
-
enumNames?: string[] |
|
|
166
|
+
enumNames?: string[] | undefined;
|
|
166
167
|
enum?: any[] | undefined;
|
|
167
168
|
accept?: string[] | undefined;
|
|
168
169
|
enforceEnum?: boolean | undefined;
|
|
@@ -208,6 +209,7 @@ declare class Field extends Scriptable<FieldJson> implements FieldModel {
|
|
|
208
209
|
validationMessage?: string | undefined;
|
|
209
210
|
default?: any;
|
|
210
211
|
value?: any;
|
|
212
|
+
displayValueExpression?: string | undefined;
|
|
211
213
|
emptyValue?: "" | "undefined" | "null" | undefined;
|
|
212
214
|
checked?: boolean | undefined;
|
|
213
215
|
_dependents?: string[] | undefined;
|
package/lib/Field.js
CHANGED
|
@@ -177,6 +177,9 @@ class Field extends Scriptable_1.default {
|
|
|
177
177
|
get displayFormat() {
|
|
178
178
|
return this.withCategory(this._jsonModel.displayFormat);
|
|
179
179
|
}
|
|
180
|
+
get displayValueExpression() {
|
|
181
|
+
return this._jsonModel.displayValueExpression;
|
|
182
|
+
}
|
|
180
183
|
get placeholder() {
|
|
181
184
|
return this._jsonModel.placeholder;
|
|
182
185
|
}
|
|
@@ -295,6 +298,9 @@ class Field extends Scriptable_1.default {
|
|
|
295
298
|
}
|
|
296
299
|
}
|
|
297
300
|
get displayValue() {
|
|
301
|
+
if (this.displayValueExpression && typeof this.displayValueExpression === 'string' && this.displayValueExpression.length !== 0) {
|
|
302
|
+
return this.executeExpression(this.displayValueExpression);
|
|
303
|
+
}
|
|
298
304
|
const df = this.displayFormat;
|
|
299
305
|
if (df && this.isNotEmpty(this.value) && this.valid !== false) {
|
|
300
306
|
try {
|
package/lib/Form.d.ts
CHANGED
|
@@ -26,7 +26,7 @@ declare class Form extends Container<FormJson> implements FormModel {
|
|
|
26
26
|
getState(forRestore?: boolean): {
|
|
27
27
|
description?: string | undefined;
|
|
28
28
|
} & import("./types/Json").RulesJson & {
|
|
29
|
-
enumNames?: string[] |
|
|
29
|
+
enumNames?: string[] | undefined;
|
|
30
30
|
enum?: any[] | undefined;
|
|
31
31
|
} & {
|
|
32
32
|
accept?: string[] | undefined;
|
package/lib/Form.js
CHANGED
|
@@ -179,7 +179,7 @@ class Form extends Container_1.default {
|
|
|
179
179
|
};
|
|
180
180
|
});
|
|
181
181
|
const fieldChangedAction = new Events_1.FieldChanged(changes, field);
|
|
182
|
-
this.
|
|
182
|
+
this.notifyDependents(fieldChangedAction);
|
|
183
183
|
}
|
|
184
184
|
});
|
|
185
185
|
}
|
|
@@ -244,7 +244,7 @@ class Form extends Container_1.default {
|
|
|
244
244
|
return null;
|
|
245
245
|
}
|
|
246
246
|
get id() {
|
|
247
|
-
return '$form';
|
|
247
|
+
return this._jsonModel.id || '$form';
|
|
248
248
|
}
|
|
249
249
|
get title() {
|
|
250
250
|
return this._jsonModel.title || '';
|
|
@@ -205,8 +205,24 @@ class FunctionRuntimeImpl {
|
|
|
205
205
|
},
|
|
206
206
|
submitForm: (payload, validateForm, contentType) => {
|
|
207
207
|
const submitAs = contentType || 'multipart/form-data';
|
|
208
|
-
const args = [
|
|
208
|
+
const args = [payload, validateForm, submitAs];
|
|
209
209
|
return FunctionRuntimeImpl.getInstance().getFunctions().submitForm._func.call(undefined, args, data, interpreter);
|
|
210
|
+
},
|
|
211
|
+
markFieldAsInvalid: (fieldIdentifier, validationMessage, option) => {
|
|
212
|
+
var _a, _b;
|
|
213
|
+
if (!option || option.useId) {
|
|
214
|
+
(_a = interpreter.globals.form.getElement(fieldIdentifier)) === null || _a === void 0 ? void 0 : _a.markAsInvalid(validationMessage);
|
|
215
|
+
}
|
|
216
|
+
else if (option && option.useDataRef) {
|
|
217
|
+
interpreter.globals.form.visit(function callback(f) {
|
|
218
|
+
if (f.dataRef === fieldIdentifier) {
|
|
219
|
+
f.markAsInvalid(validationMessage);
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
else if (option && option.useQualifiedName) {
|
|
224
|
+
(_b = interpreter.globals.form.resolveQualifiedName(fieldIdentifier)) === null || _b === void 0 ? void 0 : _b.markAsInvalid(validationMessage);
|
|
225
|
+
}
|
|
210
226
|
}
|
|
211
227
|
}
|
|
212
228
|
};
|
|
@@ -308,8 +324,8 @@ class FunctionRuntimeImpl {
|
|
|
308
324
|
},
|
|
309
325
|
submitForm: {
|
|
310
326
|
_func: (args, data, interpreter) => {
|
|
311
|
-
let success =
|
|
312
|
-
let error =
|
|
327
|
+
let success = null;
|
|
328
|
+
let error = null;
|
|
313
329
|
let submit_data;
|
|
314
330
|
let validate_form;
|
|
315
331
|
let submit_as;
|
package/lib/types/Json.d.ts
CHANGED
|
@@ -7,12 +7,8 @@ export declare type Label = {
|
|
|
7
7
|
richText?: boolean;
|
|
8
8
|
visible?: boolean;
|
|
9
9
|
};
|
|
10
|
-
export declare type EnumName = {
|
|
11
|
-
value: string;
|
|
12
|
-
richText?: boolean;
|
|
13
|
-
};
|
|
14
10
|
declare type TranslationConstraintsJson = {
|
|
15
|
-
enumNames?: string[]
|
|
11
|
+
enumNames?: string[];
|
|
16
12
|
enum?: any[];
|
|
17
13
|
};
|
|
18
14
|
export declare type ConstraintsJson = TranslationConstraintsJson & {
|
|
@@ -99,6 +95,7 @@ export declare type FieldJson = BaseJson & TranslationFieldJson & {
|
|
|
99
95
|
editFormat?: string;
|
|
100
96
|
editValue?: string;
|
|
101
97
|
displayValue?: string;
|
|
98
|
+
displayValueExpression?: string;
|
|
102
99
|
emptyValue?: 'null' | 'undefined' | '';
|
|
103
100
|
checked?: boolean;
|
|
104
101
|
};
|
package/lib/types/Model.d.ts
CHANGED
|
@@ -78,6 +78,7 @@ export interface FieldModel extends BaseModel, ScriptableField, WithState<FieldJ
|
|
|
78
78
|
readonly editFormat?: string;
|
|
79
79
|
readonly displayFormat?: string;
|
|
80
80
|
readonly displayValue?: string;
|
|
81
|
+
readonly displayValueExpression?: string;
|
|
81
82
|
readonly editValue?: string;
|
|
82
83
|
}
|
|
83
84
|
export interface FormMetaDataModel {
|
|
@@ -35,11 +35,6 @@ const addTranslationId = (input, additionalTranslationProps = []) => {
|
|
|
35
35
|
exports.addTranslationId = addTranslationId;
|
|
36
36
|
const _createTranslationId = (input, path, transProps) => {
|
|
37
37
|
Object.entries(input).forEach(([key, value]) => {
|
|
38
|
-
if (key === 'enumNames' && value instanceof Array) {
|
|
39
|
-
value = value.map((x) => {
|
|
40
|
-
return typeof x === 'string' ? x : x === null || x === void 0 ? void 0 : x.value;
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
38
|
if (typeof value == 'object') {
|
|
44
39
|
if (input instanceof Array) {
|
|
45
40
|
if (value && 'name' in value) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aemforms/af-core",
|
|
3
|
-
"version": "0.22.
|
|
3
|
+
"version": "0.22.77",
|
|
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.77"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@babel/preset-env": "^7.20.2",
|