@aemforms/af-core 0.22.16 → 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 +22 -0
- package/lib/BaseNode.js +86 -9
- package/lib/Checkbox.d.ts +8 -0
- package/lib/CheckboxGroup.js +3 -0
- package/lib/Container.d.ts +39 -196
- package/lib/Container.js +30 -3
- package/lib/Field.d.ts +36 -20
- package/lib/Field.js +211 -50
- package/lib/FileObject.d.ts +2 -0
- package/lib/FileObject.js +9 -0
- package/lib/FileUpload.d.ts +4 -13
- package/lib/FileUpload.js +29 -131
- package/lib/Form.d.ts +41 -212
- package/lib/Form.js +12 -35
- package/lib/FormInstance.d.ts +1 -1
- package/lib/FormInstance.js +3 -25
- package/lib/Scriptable.d.ts +1 -1
- package/lib/Scriptable.js +4 -4
- package/lib/controller/Controller.d.ts +1 -0
- package/lib/controller/Controller.js +3 -0
- package/lib/controller/EventQueue.d.ts +1 -1
- package/lib/controller/EventQueue.js +2 -2
- package/lib/controller/Logger.d.ts +17 -0
- package/lib/controller/Logger.js +36 -0
- package/lib/data/DataValue.d.ts +1 -1
- package/lib/data/DataValue.js +4 -2
- package/lib/rules/FunctionRuntime.d.ts +4 -0
- package/lib/rules/FunctionRuntime.js +13 -0
- package/lib/types/Json.d.ts +4 -0
- package/lib/types/Model.d.ts +12 -6
- package/lib/utils/FormUtils.d.ts +4 -12
- package/lib/utils/FormUtils.js +56 -49
- package/lib/utils/ValidationUtils.d.ts +17 -0
- package/lib/utils/ValidationUtils.js +101 -11
- package/package.json +3 -2
package/lib/BaseNode.d.ts
CHANGED
|
@@ -9,8 +9,12 @@ export declare const editableProperties: string[];
|
|
|
9
9
|
* Defines props that are dynamic and can be changed at runtime.
|
|
10
10
|
*/
|
|
11
11
|
export declare const dynamicProps: string[];
|
|
12
|
+
export declare const staticFields: string[];
|
|
12
13
|
export declare const target: unique symbol;
|
|
14
|
+
export declare const qualifiedName: unique symbol;
|
|
13
15
|
export declare function dependencyTracked(): (target: BaseNode<any>, propertyKey: string, descriptor: PropertyDescriptor) => void;
|
|
16
|
+
export declare const include: (...fieldTypes: string[]) => (target: BaseNode<any>, propertyKey: string, descriptor: PropertyDescriptor) => void;
|
|
17
|
+
export declare const exclude: (...fieldTypes: string[]) => (target: BaseNode<any>, propertyKey: string, descriptor: PropertyDescriptor) => void;
|
|
14
18
|
/**
|
|
15
19
|
* Defines a generic base class which all objects of form runtime model should extend from.
|
|
16
20
|
* @typeparam T type of the form object which extends from {@link BaseJson | base type}
|
|
@@ -68,6 +72,14 @@ export declare abstract class BaseNode<T extends BaseJson> implements BaseModel
|
|
|
68
72
|
*/
|
|
69
73
|
isTransparent(): boolean;
|
|
70
74
|
getState(): T & {
|
|
75
|
+
properties: {
|
|
76
|
+
[key: string]: any;
|
|
77
|
+
};
|
|
78
|
+
index: number;
|
|
79
|
+
parent: undefined;
|
|
80
|
+
qualifiedName: any;
|
|
81
|
+
events: {};
|
|
82
|
+
rules: {};
|
|
71
83
|
':type': string;
|
|
72
84
|
id: string;
|
|
73
85
|
};
|
|
@@ -125,4 +137,14 @@ export declare abstract class BaseNode<T extends BaseJson> implements BaseModel
|
|
|
125
137
|
* @private
|
|
126
138
|
*/
|
|
127
139
|
_initialize(): void;
|
|
140
|
+
/**
|
|
141
|
+
* Checks whether there are any updates in the properties. If there are applies them to the
|
|
142
|
+
* json model as well.
|
|
143
|
+
* @param propNames
|
|
144
|
+
* @param updates
|
|
145
|
+
* @private
|
|
146
|
+
*/
|
|
147
|
+
protected _applyUpdates(propNames: string[], updates: any): any;
|
|
148
|
+
get qualifiedName(): any;
|
|
149
|
+
focus(): void;
|
|
128
150
|
}
|
package/lib/BaseNode.js
CHANGED
|
@@ -16,7 +16,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
16
16
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
17
17
|
};
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
exports.BaseNode = exports.dependencyTracked = exports.target = exports.dynamicProps = exports.editableProperties = void 0;
|
|
19
|
+
exports.BaseNode = exports.exclude = exports.include = exports.dependencyTracked = exports.qualifiedName = exports.target = exports.staticFields = exports.dynamicProps = exports.editableProperties = void 0;
|
|
20
20
|
const controller_1 = require("./controller");
|
|
21
21
|
const DataRefParser_1 = require("./utils/DataRefParser");
|
|
22
22
|
const EmptyDataValue_1 = __importDefault(require("./data/EmptyDataValue"));
|
|
@@ -37,13 +37,13 @@ exports.editableProperties = [
|
|
|
37
37
|
// 'enforceEnum', // not exposed for now
|
|
38
38
|
'exclusiveMinimum',
|
|
39
39
|
'exclusiveMaximum',
|
|
40
|
-
'maxLength',
|
|
40
|
+
// 'maxLength',
|
|
41
41
|
'maximum',
|
|
42
42
|
'maxItems',
|
|
43
|
-
'minLength',
|
|
43
|
+
// 'minLength',
|
|
44
44
|
'minimum',
|
|
45
|
-
'minItems'
|
|
46
|
-
'step'
|
|
45
|
+
'minItems'
|
|
46
|
+
// 'step'
|
|
47
47
|
// 'placeholder' // not exposed for now.
|
|
48
48
|
];
|
|
49
49
|
/**
|
|
@@ -52,8 +52,10 @@ exports.editableProperties = [
|
|
|
52
52
|
exports.dynamicProps = [
|
|
53
53
|
...exports.editableProperties,
|
|
54
54
|
'valid',
|
|
55
|
-
'index'
|
|
55
|
+
'index',
|
|
56
|
+
'activeChild'
|
|
56
57
|
];
|
|
58
|
+
exports.staticFields = ['plain-text', 'image'];
|
|
57
59
|
/**
|
|
58
60
|
* Implementation of action with target
|
|
59
61
|
* @private
|
|
@@ -92,6 +94,7 @@ class ActionImplWithTarget {
|
|
|
92
94
|
}
|
|
93
95
|
}
|
|
94
96
|
exports.target = Symbol('target');
|
|
97
|
+
exports.qualifiedName = Symbol('qualifiedName');
|
|
95
98
|
function dependencyTracked() {
|
|
96
99
|
return function (target, propertyKey, descriptor) {
|
|
97
100
|
const get = descriptor.get;
|
|
@@ -105,6 +108,29 @@ function dependencyTracked() {
|
|
|
105
108
|
};
|
|
106
109
|
}
|
|
107
110
|
exports.dependencyTracked = dependencyTracked;
|
|
111
|
+
const addOnly = (includeOrExclude) => (...fieldTypes) => (target, propertyKey, descriptor) => {
|
|
112
|
+
const get = descriptor.get;
|
|
113
|
+
if (get != undefined) {
|
|
114
|
+
descriptor.get = function () {
|
|
115
|
+
// @ts-ignore
|
|
116
|
+
if (fieldTypes.indexOf(this.fieldType) > -1 === includeOrExclude) {
|
|
117
|
+
return get.call(this);
|
|
118
|
+
}
|
|
119
|
+
return undefined;
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
const set = descriptor.set;
|
|
123
|
+
if (set != undefined) {
|
|
124
|
+
descriptor.set = function (value) {
|
|
125
|
+
// @ts-ignore
|
|
126
|
+
if (fieldTypes.indexOf(this.fieldType) > -1 === includeOrExclude) {
|
|
127
|
+
set.call(this, value);
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
exports.include = addOnly(true);
|
|
133
|
+
exports.exclude = addOnly(false);
|
|
108
134
|
/**
|
|
109
135
|
* Defines a generic base class which all objects of form runtime model should extend from.
|
|
110
136
|
* @typeparam T type of the form object which extends from {@link BaseJson | base type}
|
|
@@ -123,6 +149,8 @@ class BaseNode {
|
|
|
123
149
|
this._callbacks = {};
|
|
124
150
|
this._dependents = [];
|
|
125
151
|
this._tokens = [];
|
|
152
|
+
//@ts-ignore
|
|
153
|
+
this[exports.qualifiedName] = null;
|
|
126
154
|
this._jsonModel = Object.assign(Object.assign({}, params), {
|
|
127
155
|
//@ts-ignore
|
|
128
156
|
id: 'id' in params ? params.id : this.form.getUniqueId() });
|
|
@@ -198,7 +226,10 @@ class BaseNode {
|
|
|
198
226
|
return this._jsonModel.id;
|
|
199
227
|
}
|
|
200
228
|
get index() {
|
|
201
|
-
|
|
229
|
+
if (this.parent) {
|
|
230
|
+
return this.parent.indexOf(this);
|
|
231
|
+
}
|
|
232
|
+
return 0;
|
|
202
233
|
}
|
|
203
234
|
get parent() {
|
|
204
235
|
return this._options.parent;
|
|
@@ -265,7 +296,7 @@ class BaseNode {
|
|
|
265
296
|
return !this._jsonModel.name && !isNonTransparent;
|
|
266
297
|
}
|
|
267
298
|
getState() {
|
|
268
|
-
return Object.assign(Object.assign({}, this._jsonModel), { ':type': this[':type'] });
|
|
299
|
+
return Object.assign(Object.assign({}, this._jsonModel), { properties: this.properties, index: this.index, parent: undefined, qualifiedName: this.qualifiedName, events: {}, rules: {}, ':type': this[':type'] });
|
|
269
300
|
}
|
|
270
301
|
/**
|
|
271
302
|
* @private
|
|
@@ -389,8 +420,9 @@ class BaseNode {
|
|
|
389
420
|
}
|
|
390
421
|
}
|
|
391
422
|
else { // name data binding
|
|
423
|
+
// static fields do not have name bindings
|
|
392
424
|
if ( //@ts-ignore
|
|
393
|
-
contextualDataModel !== EmptyDataValue_1.default) {
|
|
425
|
+
contextualDataModel !== EmptyDataValue_1.default && exports.staticFields.indexOf(this.fieldType) === -1) {
|
|
394
426
|
_parent = contextualDataModel;
|
|
395
427
|
const name = this._jsonModel.name || '';
|
|
396
428
|
const key = contextualDataModel.$type === 'array' ? this.index : name;
|
|
@@ -454,6 +486,51 @@ class BaseNode {
|
|
|
454
486
|
this._bindToDataModel(dataNode);
|
|
455
487
|
}
|
|
456
488
|
}
|
|
489
|
+
/**
|
|
490
|
+
* Checks whether there are any updates in the properties. If there are applies them to the
|
|
491
|
+
* json model as well.
|
|
492
|
+
* @param propNames
|
|
493
|
+
* @param updates
|
|
494
|
+
* @private
|
|
495
|
+
*/
|
|
496
|
+
_applyUpdates(propNames, updates) {
|
|
497
|
+
return propNames.reduce((acc, propertyName) => {
|
|
498
|
+
//@ts-ignore
|
|
499
|
+
const currentValue = updates[propertyName];
|
|
500
|
+
const changes = this._setProperty(propertyName, currentValue, false);
|
|
501
|
+
if (changes.length > 0) {
|
|
502
|
+
acc[propertyName] = changes[0];
|
|
503
|
+
}
|
|
504
|
+
return acc;
|
|
505
|
+
}, {});
|
|
506
|
+
}
|
|
507
|
+
get qualifiedName() {
|
|
508
|
+
if (this.isTransparent()) {
|
|
509
|
+
return null;
|
|
510
|
+
}
|
|
511
|
+
// @ts-ignore
|
|
512
|
+
if (this[exports.qualifiedName] !== null) {
|
|
513
|
+
// @ts-ignore
|
|
514
|
+
return this[exports.qualifiedName];
|
|
515
|
+
}
|
|
516
|
+
// use qualified name
|
|
517
|
+
const parent = this.getNonTransparentParent();
|
|
518
|
+
if (parent && parent.type === 'array') {
|
|
519
|
+
//@ts-ignore
|
|
520
|
+
this[exports.qualifiedName] = `${parent.qualifiedName}[${this.index}]`;
|
|
521
|
+
}
|
|
522
|
+
else {
|
|
523
|
+
//@ts-ignore
|
|
524
|
+
this[exports.qualifiedName] = `${parent.qualifiedName}.${this.name}`;
|
|
525
|
+
}
|
|
526
|
+
//@ts-ignore
|
|
527
|
+
return this[exports.qualifiedName];
|
|
528
|
+
}
|
|
529
|
+
focus() {
|
|
530
|
+
if (this.parent) {
|
|
531
|
+
this.parent.activeChild = this;
|
|
532
|
+
}
|
|
533
|
+
}
|
|
457
534
|
}
|
|
458
535
|
__decorate([
|
|
459
536
|
dependencyTracked()
|
package/lib/Checkbox.d.ts
CHANGED
|
@@ -64,6 +64,14 @@ declare class Checkbox extends Field {
|
|
|
64
64
|
valid: boolean;
|
|
65
65
|
value: any;
|
|
66
66
|
};
|
|
67
|
+
accept: (constraint: string[], value: any) => {
|
|
68
|
+
valid: boolean;
|
|
69
|
+
value: any;
|
|
70
|
+
};
|
|
71
|
+
maxFileSize: (constraint: string | number, value: any) => {
|
|
72
|
+
valid: boolean;
|
|
73
|
+
value: any;
|
|
74
|
+
};
|
|
67
75
|
};
|
|
68
76
|
protected _getDefaults(): {
|
|
69
77
|
enforceEnum: boolean;
|
package/lib/CheckboxGroup.js
CHANGED
|
@@ -32,6 +32,9 @@ class CheckboxGroup extends Field_1.default {
|
|
|
32
32
|
if (typeof fallbackType === 'string') {
|
|
33
33
|
return `${fallbackType}[]`;
|
|
34
34
|
}
|
|
35
|
+
else {
|
|
36
|
+
return 'string[]';
|
|
37
|
+
}
|
|
35
38
|
}
|
|
36
39
|
_getDefaults() {
|
|
37
40
|
return Object.assign(Object.assign({}, super._getDefaults()), { enforceEnum: true, enum: [] });
|
package/lib/Container.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Action, ContainerJson, ContainerModel, FieldJson, FieldModel, FieldsetJson, FieldsetModel, RulesJson } from './types';
|
|
1
|
+
import { Action, BaseModel, ContainerJson, ContainerModel, FieldJson, FieldModel, FieldsetJson, FieldsetModel, RulesJson } from './types';
|
|
2
2
|
import Scriptable from './Scriptable';
|
|
3
3
|
import DataGroup from './data/DataGroup';
|
|
4
4
|
/**
|
|
@@ -30,12 +30,15 @@ declare abstract class Container<T extends ContainerJson & RulesJson> extends Sc
|
|
|
30
30
|
*/
|
|
31
31
|
hasDynamicItems(): boolean;
|
|
32
32
|
get isContainer(): boolean;
|
|
33
|
+
private _activeChild;
|
|
33
34
|
/**
|
|
34
35
|
* Returns the current container state
|
|
35
36
|
*/
|
|
36
37
|
getState(): T & {
|
|
37
|
-
':type': string;
|
|
38
38
|
items: ({
|
|
39
|
+
id: string;
|
|
40
|
+
index: number;
|
|
41
|
+
':type': string;
|
|
39
42
|
description?: string | undefined;
|
|
40
43
|
rules?: import("./types").Items<string> | undefined;
|
|
41
44
|
events?: import("./types").Items<string | string[] | undefined> | undefined;
|
|
@@ -55,22 +58,29 @@ declare abstract class Container<T extends ContainerJson & RulesJson> extends Sc
|
|
|
55
58
|
minItems?: number | undefined;
|
|
56
59
|
pattern?: string | undefined;
|
|
57
60
|
required?: boolean | undefined;
|
|
61
|
+
/**
|
|
62
|
+
* @private
|
|
63
|
+
*/
|
|
58
64
|
step?: number | undefined;
|
|
59
65
|
type?: string | undefined;
|
|
60
66
|
validationExpression?: string | undefined;
|
|
61
67
|
uniqueItems?: boolean | undefined;
|
|
62
68
|
dataRef?: string | null | undefined;
|
|
63
|
-
':type': string;
|
|
64
69
|
label?: import("./types").Label | undefined;
|
|
65
70
|
enabled?: boolean | undefined;
|
|
66
71
|
visible?: boolean | undefined;
|
|
67
72
|
name?: string | undefined;
|
|
68
73
|
constraintMessages?: import("./types").ConstraintsMessages | undefined;
|
|
69
|
-
fieldType?: string | undefined;
|
|
74
|
+
fieldType?: string | undefined; /**
|
|
75
|
+
* Returns the current container state
|
|
76
|
+
*/
|
|
70
77
|
errorMessage?: string | undefined;
|
|
71
78
|
properties?: {
|
|
72
79
|
[key: string]: any;
|
|
73
80
|
} | undefined;
|
|
81
|
+
screenReaderText?: string | undefined;
|
|
82
|
+
tooltip?: string | undefined;
|
|
83
|
+
altText?: string | undefined;
|
|
74
84
|
placeholder?: string | undefined;
|
|
75
85
|
readOnly?: boolean | undefined;
|
|
76
86
|
valid?: boolean | undefined;
|
|
@@ -81,8 +91,10 @@ declare abstract class Container<T extends ContainerJson & RulesJson> extends Sc
|
|
|
81
91
|
editValue?: string | undefined;
|
|
82
92
|
displayValue?: string | undefined;
|
|
83
93
|
emptyValue?: "" | "undefined" | "null" | undefined;
|
|
84
|
-
id: string;
|
|
85
94
|
} | {
|
|
95
|
+
id: string;
|
|
96
|
+
index: number;
|
|
97
|
+
':type': string;
|
|
86
98
|
description?: string | undefined;
|
|
87
99
|
rules?: import("./types").Items<string> | undefined;
|
|
88
100
|
events?: import("./types").Items<string | string[] | undefined> | undefined;
|
|
@@ -102,213 +114,42 @@ declare abstract class Container<T extends ContainerJson & RulesJson> extends Sc
|
|
|
102
114
|
minItems?: number | undefined;
|
|
103
115
|
pattern?: string | undefined;
|
|
104
116
|
required?: boolean | undefined;
|
|
117
|
+
/**
|
|
118
|
+
* @private
|
|
119
|
+
*/
|
|
105
120
|
step?: number | undefined;
|
|
106
121
|
type?: "object" | "array" | undefined;
|
|
107
122
|
validationExpression?: string | undefined;
|
|
108
123
|
uniqueItems?: boolean | undefined;
|
|
109
124
|
dataRef?: string | null | undefined;
|
|
110
|
-
':type'?: string | undefined;
|
|
111
125
|
label?: import("./types").Label | undefined;
|
|
112
126
|
enabled?: boolean | undefined;
|
|
113
127
|
visible?: boolean | undefined;
|
|
114
128
|
name?: string | undefined;
|
|
115
129
|
constraintMessages?: import("./types").ConstraintsMessages | undefined;
|
|
116
|
-
fieldType?: string | undefined;
|
|
130
|
+
fieldType?: string | undefined; /**
|
|
131
|
+
* Returns the current container state
|
|
132
|
+
*/
|
|
117
133
|
errorMessage?: string | undefined;
|
|
118
134
|
properties?: {
|
|
119
135
|
[key: string]: any;
|
|
120
136
|
} | undefined;
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
enum?: any[] | undefined;
|
|
126
|
-
} & {
|
|
127
|
-
accept?: string[] | undefined;
|
|
128
|
-
enforceEnum?: boolean | undefined;
|
|
129
|
-
exclusiveMinimum?: number | undefined;
|
|
130
|
-
exclusiveMaximum?: number | undefined;
|
|
131
|
-
format?: string | undefined;
|
|
132
|
-
maxFileSize?: string | number | undefined;
|
|
133
|
-
maxLength?: number | undefined;
|
|
134
|
-
maximum?: number | undefined;
|
|
135
|
-
maxItems?: number | undefined;
|
|
136
|
-
minLength?: number | undefined;
|
|
137
|
-
minimum?: number | undefined;
|
|
138
|
-
minItems?: number | undefined;
|
|
139
|
-
pattern?: string | undefined;
|
|
140
|
-
required?: boolean | undefined;
|
|
141
|
-
step?: number | undefined;
|
|
142
|
-
type?: string | undefined;
|
|
143
|
-
validationExpression?: string | undefined;
|
|
144
|
-
uniqueItems?: boolean | undefined;
|
|
145
|
-
} & {
|
|
146
|
-
dataRef?: string | null | undefined;
|
|
147
|
-
':type'?: string | undefined;
|
|
148
|
-
label?: import("./types").Label | undefined;
|
|
149
|
-
enabled?: boolean | undefined;
|
|
150
|
-
visible?: boolean | undefined;
|
|
151
|
-
name?: string | undefined;
|
|
152
|
-
constraintMessages?: import("./types").ConstraintsMessages | undefined;
|
|
153
|
-
fieldType?: string | undefined;
|
|
154
|
-
errorMessage?: string | undefined;
|
|
155
|
-
properties?: {
|
|
156
|
-
[key: string]: any;
|
|
157
|
-
} | undefined;
|
|
158
|
-
} & {
|
|
159
|
-
placeholder?: string | undefined;
|
|
160
|
-
} & {
|
|
161
|
-
readOnly?: boolean | undefined;
|
|
162
|
-
valid?: boolean | undefined;
|
|
163
|
-
default?: any;
|
|
164
|
-
value?: any;
|
|
165
|
-
displayFormat?: string | undefined;
|
|
166
|
-
editFormat?: string | undefined;
|
|
167
|
-
editValue?: string | undefined;
|
|
168
|
-
displayValue?: string | undefined;
|
|
169
|
-
emptyValue?: "" | "undefined" | "null" | undefined;
|
|
170
|
-
} & {
|
|
171
|
-
id: string;
|
|
172
|
-
':type': string;
|
|
173
|
-
}) | ({
|
|
174
|
-
description?: string | undefined;
|
|
175
|
-
} & RulesJson & {
|
|
176
|
-
enumNames?: string[] | undefined;
|
|
177
|
-
enum?: any[] | undefined;
|
|
178
|
-
} & {
|
|
179
|
-
accept?: string[] | undefined;
|
|
180
|
-
enforceEnum?: boolean | undefined;
|
|
181
|
-
exclusiveMinimum?: number | undefined;
|
|
182
|
-
exclusiveMaximum?: number | undefined;
|
|
183
|
-
format?: string | undefined;
|
|
184
|
-
maxFileSize?: string | number | undefined;
|
|
185
|
-
maxLength?: number | undefined;
|
|
186
|
-
maximum?: number | undefined;
|
|
187
|
-
maxItems?: number | undefined;
|
|
188
|
-
minLength?: number | undefined;
|
|
189
|
-
minimum?: number | undefined;
|
|
190
|
-
minItems?: number | undefined;
|
|
191
|
-
pattern?: string | undefined;
|
|
192
|
-
required?: boolean | undefined;
|
|
193
|
-
step?: number | undefined;
|
|
194
|
-
type?: string | undefined;
|
|
195
|
-
validationExpression?: string | undefined;
|
|
196
|
-
uniqueItems?: boolean | undefined;
|
|
197
|
-
} & {
|
|
198
|
-
dataRef?: string | null | undefined;
|
|
199
|
-
':type'?: string | undefined;
|
|
200
|
-
label?: import("./types").Label | undefined;
|
|
201
|
-
enabled?: boolean | undefined;
|
|
202
|
-
visible?: boolean | undefined;
|
|
203
|
-
name?: string | undefined;
|
|
204
|
-
constraintMessages?: import("./types").ConstraintsMessages | undefined;
|
|
205
|
-
fieldType?: string | undefined;
|
|
206
|
-
errorMessage?: string | undefined;
|
|
207
|
-
properties?: {
|
|
208
|
-
[key: string]: any;
|
|
209
|
-
} | undefined;
|
|
210
|
-
} & {
|
|
211
|
-
items: (FieldJson | ContainerJson)[];
|
|
212
|
-
initialItems?: number | undefined;
|
|
213
|
-
} & {
|
|
214
|
-
id: string;
|
|
215
|
-
items: (({
|
|
216
|
-
description?: string | undefined;
|
|
217
|
-
} & RulesJson & {
|
|
218
|
-
enumNames?: string[] | undefined;
|
|
219
|
-
enum?: any[] | undefined;
|
|
220
|
-
} & {
|
|
221
|
-
accept?: string[] | undefined;
|
|
222
|
-
enforceEnum?: boolean | undefined;
|
|
223
|
-
exclusiveMinimum?: number | undefined;
|
|
224
|
-
exclusiveMaximum?: number | undefined;
|
|
225
|
-
format?: string | undefined;
|
|
226
|
-
maxFileSize?: string | number | undefined;
|
|
227
|
-
maxLength?: number | undefined;
|
|
228
|
-
maximum?: number | undefined;
|
|
229
|
-
maxItems?: number | undefined;
|
|
230
|
-
minLength?: number | undefined;
|
|
231
|
-
minimum?: number | undefined;
|
|
232
|
-
minItems?: number | undefined;
|
|
233
|
-
pattern?: string | undefined;
|
|
234
|
-
required?: boolean | undefined;
|
|
235
|
-
step?: number | undefined;
|
|
236
|
-
type?: string | undefined;
|
|
237
|
-
validationExpression?: string | undefined;
|
|
238
|
-
uniqueItems?: boolean | undefined;
|
|
239
|
-
} & {
|
|
240
|
-
dataRef?: string | null | undefined;
|
|
241
|
-
':type'?: string | undefined;
|
|
242
|
-
label?: import("./types").Label | undefined;
|
|
243
|
-
enabled?: boolean | undefined;
|
|
244
|
-
visible?: boolean | undefined;
|
|
245
|
-
name?: string | undefined;
|
|
246
|
-
constraintMessages?: import("./types").ConstraintsMessages | undefined;
|
|
247
|
-
fieldType?: string | undefined;
|
|
248
|
-
errorMessage?: string | undefined;
|
|
249
|
-
properties?: {
|
|
250
|
-
[key: string]: any;
|
|
251
|
-
} | undefined;
|
|
252
|
-
} & {
|
|
253
|
-
placeholder?: string | undefined;
|
|
254
|
-
} & {
|
|
255
|
-
readOnly?: boolean | undefined;
|
|
256
|
-
valid?: boolean | undefined;
|
|
257
|
-
default?: any;
|
|
258
|
-
value?: any;
|
|
259
|
-
displayFormat?: string | undefined;
|
|
260
|
-
editFormat?: string | undefined;
|
|
261
|
-
editValue?: string | undefined;
|
|
262
|
-
displayValue?: string | undefined;
|
|
263
|
-
emptyValue?: "" | "undefined" | "null" | undefined;
|
|
264
|
-
} & {
|
|
265
|
-
id: string;
|
|
266
|
-
':type': string;
|
|
267
|
-
}) | ({
|
|
268
|
-
description?: string | undefined;
|
|
269
|
-
} & RulesJson & {
|
|
270
|
-
enumNames?: string[] | undefined;
|
|
271
|
-
enum?: any[] | undefined;
|
|
272
|
-
} & {
|
|
273
|
-
accept?: string[] | undefined;
|
|
274
|
-
enforceEnum?: boolean | undefined;
|
|
275
|
-
exclusiveMinimum?: number | undefined;
|
|
276
|
-
exclusiveMaximum?: number | undefined;
|
|
277
|
-
format?: string | undefined;
|
|
278
|
-
maxFileSize?: string | number | undefined;
|
|
279
|
-
maxLength?: number | undefined;
|
|
280
|
-
maximum?: number | undefined;
|
|
281
|
-
maxItems?: number | undefined;
|
|
282
|
-
minLength?: number | undefined;
|
|
283
|
-
minimum?: number | undefined;
|
|
284
|
-
minItems?: number | undefined;
|
|
285
|
-
pattern?: string | undefined;
|
|
286
|
-
required?: boolean | undefined;
|
|
287
|
-
step?: number | undefined;
|
|
288
|
-
type?: string | undefined;
|
|
289
|
-
validationExpression?: string | undefined;
|
|
290
|
-
uniqueItems?: boolean | undefined;
|
|
291
|
-
} & {
|
|
292
|
-
dataRef?: string | null | undefined;
|
|
293
|
-
':type'?: string | undefined;
|
|
294
|
-
label?: import("./types").Label | undefined;
|
|
295
|
-
enabled?: boolean | undefined;
|
|
296
|
-
visible?: boolean | undefined;
|
|
297
|
-
name?: string | undefined;
|
|
298
|
-
constraintMessages?: import("./types").ConstraintsMessages | undefined;
|
|
299
|
-
fieldType?: string | undefined;
|
|
300
|
-
errorMessage?: string | undefined;
|
|
301
|
-
properties?: {
|
|
302
|
-
[key: string]: any;
|
|
303
|
-
} | undefined;
|
|
304
|
-
} & {
|
|
305
|
-
items: (FieldJson | ContainerJson)[];
|
|
306
|
-
initialItems?: number | undefined;
|
|
307
|
-
} & any))[];
|
|
308
|
-
}))[];
|
|
137
|
+
screenReaderText?: string | undefined;
|
|
138
|
+
tooltip?: string | undefined;
|
|
139
|
+
altText?: string | undefined;
|
|
140
|
+
items: (FieldJson | ContainerJson)[] & import("./types").State<FieldJson | ContainerJson>[];
|
|
309
141
|
initialItems?: number | undefined;
|
|
310
|
-
|
|
142
|
+
activeChild?: string | undefined;
|
|
311
143
|
})[];
|
|
144
|
+
properties: {
|
|
145
|
+
[key: string]: any;
|
|
146
|
+
};
|
|
147
|
+
index: number;
|
|
148
|
+
parent: undefined;
|
|
149
|
+
qualifiedName: any;
|
|
150
|
+
events: {};
|
|
151
|
+
rules: {};
|
|
152
|
+
':type': string;
|
|
312
153
|
id: string;
|
|
313
154
|
};
|
|
314
155
|
protected abstract _createChild(child: FieldsetJson | FieldJson): FieldModel | FieldsetModel;
|
|
@@ -352,5 +193,7 @@ declare abstract class Container<T extends ContainerJson & RulesJson> extends Sc
|
|
|
352
193
|
* @private
|
|
353
194
|
*/
|
|
354
195
|
syncDataAndFormModel(contextualDataModel?: DataGroup): void;
|
|
196
|
+
get activeChild(): BaseModel | null;
|
|
197
|
+
set activeChild(c: BaseModel | null);
|
|
355
198
|
}
|
|
356
199
|
export default Container;
|
package/lib/Container.js
CHANGED
|
@@ -30,6 +30,7 @@ class Container extends Scriptable_1.default {
|
|
|
30
30
|
super(...arguments);
|
|
31
31
|
this._children = [];
|
|
32
32
|
this._itemTemplate = null;
|
|
33
|
+
this._activeChild = null;
|
|
33
34
|
}
|
|
34
35
|
/**
|
|
35
36
|
* @private
|
|
@@ -74,7 +75,7 @@ class Container extends Scriptable_1.default {
|
|
|
74
75
|
* Returns the current container state
|
|
75
76
|
*/
|
|
76
77
|
getState() {
|
|
77
|
-
return Object.assign(Object.assign({},
|
|
78
|
+
return Object.assign(Object.assign({}, super.getState()), { items: this._children.map(x => {
|
|
78
79
|
return Object.assign({}, x.getState());
|
|
79
80
|
}) });
|
|
80
81
|
}
|
|
@@ -153,7 +154,7 @@ class Container extends Scriptable_1.default {
|
|
|
153
154
|
*/
|
|
154
155
|
_initialize() {
|
|
155
156
|
super._initialize();
|
|
156
|
-
const items = this._jsonModel.items;
|
|
157
|
+
const items = this._jsonModel.items || [];
|
|
157
158
|
this._jsonModel.items = [];
|
|
158
159
|
this._childrenReference = this._jsonModel.type == 'array' ? [] : {};
|
|
159
160
|
if (this._jsonModel.type == 'array' && items.length === 1 && this.getDataNode() != null) {
|
|
@@ -182,6 +183,9 @@ class Container extends Scriptable_1.default {
|
|
|
182
183
|
this._jsonModel.maxItems = this._children.length;
|
|
183
184
|
this._jsonModel.initialItems = this._children.length;
|
|
184
185
|
}
|
|
186
|
+
else {
|
|
187
|
+
this.form.logger.warn('A container exists with no items.');
|
|
188
|
+
}
|
|
185
189
|
this.setupRuleNode();
|
|
186
190
|
}
|
|
187
191
|
/**
|
|
@@ -202,7 +206,7 @@ class Container extends Scriptable_1.default {
|
|
|
202
206
|
dataNode.$addDataNode(index, _data);
|
|
203
207
|
}
|
|
204
208
|
retVal._initialize();
|
|
205
|
-
this.notifyDependents((0, controller_1.propertyChange)('items', retVal.getState, null));
|
|
209
|
+
this.notifyDependents((0, controller_1.propertyChange)('items', retVal.getState(), null));
|
|
206
210
|
retVal.dispatch(new controller_1.Initialize());
|
|
207
211
|
retVal.dispatch(new controller_1.ExecuteRule());
|
|
208
212
|
for (let i = index + 1; i < this._children.length; i++) {
|
|
@@ -301,6 +305,26 @@ class Container extends Scriptable_1.default {
|
|
|
301
305
|
x.importData(contextualDataModel);
|
|
302
306
|
});
|
|
303
307
|
}
|
|
308
|
+
get activeChild() {
|
|
309
|
+
return this._activeChild;
|
|
310
|
+
}
|
|
311
|
+
set activeChild(c) {
|
|
312
|
+
if (c !== this._activeChild) {
|
|
313
|
+
let activeChild = this._activeChild;
|
|
314
|
+
while (activeChild instanceof Container) {
|
|
315
|
+
const temp = activeChild.activeChild;
|
|
316
|
+
activeChild.activeChild = null;
|
|
317
|
+
activeChild = temp;
|
|
318
|
+
}
|
|
319
|
+
const change = (0, controller_1.propertyChange)('activeChild', c, this._activeChild);
|
|
320
|
+
this._activeChild = c;
|
|
321
|
+
if (this.parent && c !== null) {
|
|
322
|
+
this.parent.activeChild = this;
|
|
323
|
+
}
|
|
324
|
+
this._jsonModel.activeChild = c === null || c === void 0 ? void 0 : c.id;
|
|
325
|
+
this.notifyDependents(change);
|
|
326
|
+
}
|
|
327
|
+
}
|
|
304
328
|
}
|
|
305
329
|
__decorate([
|
|
306
330
|
(0, BaseNode_1.dependencyTracked)()
|
|
@@ -308,4 +332,7 @@ __decorate([
|
|
|
308
332
|
__decorate([
|
|
309
333
|
(0, BaseNode_1.dependencyTracked)()
|
|
310
334
|
], Container.prototype, "minItems", null);
|
|
335
|
+
__decorate([
|
|
336
|
+
(0, BaseNode_1.dependencyTracked)()
|
|
337
|
+
], Container.prototype, "activeChild", null);
|
|
311
338
|
exports.default = Container;
|