@aemforms/af-core 0.22.76 → 0.22.78
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 +13 -10
- package/esm/types/src/Checkbox.d.ts +1 -1
- package/esm/types/src/Field.d.ts +4 -3
- package/esm/types/src/Form.d.ts +1 -1
- package/esm/types/src/types/Json.d.ts +1 -5
- package/lib/BaseNode.js +1 -1
- package/lib/Checkbox.d.ts +1 -1
- package/lib/Field.d.ts +4 -3
- package/lib/Field.js +17 -7
- package/lib/Form.d.ts +1 -1
- package/lib/Form.js +2 -2
- package/lib/types/Json.d.ts +1 -5
- 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
|
}
|
|
@@ -3061,7 +3061,7 @@ class Form extends Container {
|
|
|
3061
3061
|
};
|
|
3062
3062
|
});
|
|
3063
3063
|
const fieldChangedAction = new FieldChanged(changes, field);
|
|
3064
|
-
this.
|
|
3064
|
+
this.notifyDependents(fieldChangedAction);
|
|
3065
3065
|
}
|
|
3066
3066
|
});
|
|
3067
3067
|
}
|
|
@@ -3125,7 +3125,7 @@ class Form extends Container {
|
|
|
3125
3125
|
return null;
|
|
3126
3126
|
}
|
|
3127
3127
|
get id() {
|
|
3128
|
-
return '$form';
|
|
3128
|
+
return this._jsonModel.id || '$form';
|
|
3129
3129
|
}
|
|
3130
3130
|
get title() {
|
|
3131
3131
|
return this._jsonModel.title || '';
|
|
@@ -3898,12 +3898,15 @@ class Field extends Scriptable {
|
|
|
3898
3898
|
}
|
|
3899
3899
|
triggerValidationEvent(changes) {
|
|
3900
3900
|
if (changes.validity) {
|
|
3901
|
-
|
|
3902
|
-
|
|
3903
|
-
|
|
3904
|
-
|
|
3905
|
-
|
|
3906
|
-
|
|
3901
|
+
this.#triggerValidationEvent();
|
|
3902
|
+
}
|
|
3903
|
+
}
|
|
3904
|
+
#triggerValidationEvent() {
|
|
3905
|
+
if (this.validity.valid) {
|
|
3906
|
+
this.dispatch(new Valid());
|
|
3907
|
+
}
|
|
3908
|
+
else {
|
|
3909
|
+
this.dispatch(new Invalid());
|
|
3907
3910
|
}
|
|
3908
3911
|
}
|
|
3909
3912
|
validate() {
|
|
@@ -3911,8 +3914,8 @@ class Field extends Scriptable {
|
|
|
3911
3914
|
return [];
|
|
3912
3915
|
}
|
|
3913
3916
|
const changes = this.evaluateConstraints();
|
|
3917
|
+
this.#triggerValidationEvent();
|
|
3914
3918
|
if (changes.validity) {
|
|
3915
|
-
this.triggerValidationEvent(changes);
|
|
3916
3919
|
this.notifyDependents(new Change({ changes: Object.values(changes) }));
|
|
3917
3920
|
}
|
|
3918
3921
|
return this.valid ? [] : [new ValidationError(this.id, [this._jsonModel.errorMessage])];
|
|
@@ -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;
|
package/esm/types/src/Field.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import Scriptable from './Scriptable';
|
|
|
3
3
|
import DataValue from './data/DataValue';
|
|
4
4
|
import DataGroup from './data/DataGroup';
|
|
5
5
|
declare class Field extends Scriptable<FieldJson> implements FieldModel {
|
|
6
|
+
#private;
|
|
6
7
|
constructor(params: FieldJson, _options: {
|
|
7
8
|
form: FormModel;
|
|
8
9
|
parent: ContainerModel;
|
|
@@ -40,8 +41,8 @@ declare class Field extends Scriptable<FieldJson> implements FieldModel {
|
|
|
40
41
|
get emptyValue(): "" | null | undefined;
|
|
41
42
|
get enum(): any[] | undefined;
|
|
42
43
|
set enum(e: any[] | undefined);
|
|
43
|
-
get enumNames(): string[] |
|
|
44
|
-
set enumNames(e: string[] |
|
|
44
|
+
get enumNames(): string[] | undefined;
|
|
45
|
+
set enumNames(e: string[] | undefined);
|
|
45
46
|
get required(): boolean;
|
|
46
47
|
set required(r: boolean);
|
|
47
48
|
get maximum(): number | undefined;
|
|
@@ -163,7 +164,7 @@ declare class Field extends Scriptable<FieldJson> implements FieldModel {
|
|
|
163
164
|
description?: string | undefined;
|
|
164
165
|
rules?: import("./types").Items<string> | undefined;
|
|
165
166
|
events?: import("./types").Items<string | string[] | undefined> | undefined;
|
|
166
|
-
enumNames?: string[] |
|
|
167
|
+
enumNames?: string[] | undefined;
|
|
167
168
|
enum?: any[] | undefined;
|
|
168
169
|
accept?: string[] | undefined;
|
|
169
170
|
enforceEnum?: boolean | 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 & {
|
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;
|
package/lib/Field.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import Scriptable from './Scriptable';
|
|
|
3
3
|
import DataValue from './data/DataValue';
|
|
4
4
|
import DataGroup from './data/DataGroup';
|
|
5
5
|
declare class Field extends Scriptable<FieldJson> implements FieldModel {
|
|
6
|
+
#private;
|
|
6
7
|
constructor(params: FieldJson, _options: {
|
|
7
8
|
form: FormModel;
|
|
8
9
|
parent: ContainerModel;
|
|
@@ -40,8 +41,8 @@ declare class Field extends Scriptable<FieldJson> implements FieldModel {
|
|
|
40
41
|
get emptyValue(): "" | null | undefined;
|
|
41
42
|
get enum(): any[] | undefined;
|
|
42
43
|
set enum(e: any[] | undefined);
|
|
43
|
-
get enumNames(): string[] |
|
|
44
|
-
set enumNames(e: string[] |
|
|
44
|
+
get enumNames(): string[] | undefined;
|
|
45
|
+
set enumNames(e: string[] | undefined);
|
|
45
46
|
get required(): boolean;
|
|
46
47
|
set required(r: boolean);
|
|
47
48
|
get maximum(): number | undefined;
|
|
@@ -163,7 +164,7 @@ declare class Field extends Scriptable<FieldJson> implements FieldModel {
|
|
|
163
164
|
description?: string | undefined;
|
|
164
165
|
rules?: import("./types").Items<string> | undefined;
|
|
165
166
|
events?: import("./types").Items<string | string[] | undefined> | undefined;
|
|
166
|
-
enumNames?: string[] |
|
|
167
|
+
enumNames?: string[] | undefined;
|
|
167
168
|
enum?: any[] | undefined;
|
|
168
169
|
accept?: string[] | undefined;
|
|
169
170
|
enforceEnum?: boolean | undefined;
|
package/lib/Field.js
CHANGED
|
@@ -5,9 +5,15 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
5
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
6
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
7
|
};
|
|
8
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
+
};
|
|
8
13
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
14
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
15
|
};
|
|
16
|
+
var _Field_instances, _Field_triggerValidationEvent;
|
|
11
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
18
|
const types_1 = require("./types");
|
|
13
19
|
const ValidationUtils_1 = require("./utils/ValidationUtils");
|
|
@@ -23,6 +29,7 @@ const validTypes = ['string', 'number', 'integer', 'boolean', 'file', 'string[]'
|
|
|
23
29
|
class Field extends Scriptable_1.default {
|
|
24
30
|
constructor(params, _options) {
|
|
25
31
|
super(params, _options);
|
|
32
|
+
_Field_instances.add(this);
|
|
26
33
|
this._ruleNodeReference = [];
|
|
27
34
|
if (_options.mode !== 'restore') {
|
|
28
35
|
this._applyDefaults();
|
|
@@ -642,12 +649,7 @@ class Field extends Scriptable_1.default {
|
|
|
642
649
|
}
|
|
643
650
|
triggerValidationEvent(changes) {
|
|
644
651
|
if (changes.validity) {
|
|
645
|
-
|
|
646
|
-
this.dispatch(new Events_1.Valid());
|
|
647
|
-
}
|
|
648
|
-
else {
|
|
649
|
-
this.dispatch(new Events_1.Invalid());
|
|
650
|
-
}
|
|
652
|
+
__classPrivateFieldGet(this, _Field_instances, "m", _Field_triggerValidationEvent).call(this);
|
|
651
653
|
}
|
|
652
654
|
}
|
|
653
655
|
validate() {
|
|
@@ -655,8 +657,8 @@ class Field extends Scriptable_1.default {
|
|
|
655
657
|
return [];
|
|
656
658
|
}
|
|
657
659
|
const changes = this.evaluateConstraints();
|
|
660
|
+
__classPrivateFieldGet(this, _Field_instances, "m", _Field_triggerValidationEvent).call(this);
|
|
658
661
|
if (changes.validity) {
|
|
659
|
-
this.triggerValidationEvent(changes);
|
|
660
662
|
this.notifyDependents(new Events_1.Change({ changes: Object.values(changes) }));
|
|
661
663
|
}
|
|
662
664
|
return this.valid ? [] : [new types_1.ValidationError(this.id, [this._jsonModel.errorMessage])];
|
|
@@ -692,6 +694,14 @@ class Field extends Scriptable_1.default {
|
|
|
692
694
|
}
|
|
693
695
|
}
|
|
694
696
|
}
|
|
697
|
+
_Field_instances = new WeakSet(), _Field_triggerValidationEvent = function _Field_triggerValidationEvent() {
|
|
698
|
+
if (this.validity.valid) {
|
|
699
|
+
this.dispatch(new Events_1.Valid());
|
|
700
|
+
}
|
|
701
|
+
else {
|
|
702
|
+
this.dispatch(new Events_1.Invalid());
|
|
703
|
+
}
|
|
704
|
+
};
|
|
695
705
|
__decorate([
|
|
696
706
|
(0, BaseNode_1.dependencyTracked)(),
|
|
697
707
|
(0, BaseNode_1.exclude)('button', 'image', 'plain-text')
|
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 || '';
|
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 & {
|
|
@@ -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.78",
|
|
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.78"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@babel/preset-env": "^7.20.2",
|