@aemforms/af-core 0.22.30 → 0.22.32
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/{esm/BaseNode.d.ts → BaseNode.d.ts} +8 -8
- package/lib/{esm/BaseNode-d78cc1b0.js → BaseNode.js} +72 -97
- package/lib/{esm/Checkbox.d.ts → Checkbox.d.ts} +1 -1
- package/lib/Checkbox.js +29 -0
- package/lib/{esm/CheckboxGroup.d.ts → CheckboxGroup.d.ts} +2 -2
- package/lib/CheckboxGroup.js +24 -0
- package/lib/{esm/Container.d.ts → Container.d.ts} +4 -4
- package/lib/{esm/Container.js → Container.js} +51 -77
- package/lib/{esm/DateField.d.ts → DateField.d.ts} +1 -1
- package/lib/DateField.js +26 -0
- package/lib/{esm/Field.d.ts → Field.d.ts} +10 -9
- package/lib/{esm/Field.js → Field.js} +97 -105
- package/lib/Fieldset.d.ts +72 -0
- package/lib/Fieldset.js +89 -0
- package/lib/{esm/FileObject.d.ts → FileObject.d.ts} +1 -1
- package/lib/FileObject.js +29 -0
- package/lib/{esm/FileUpload.d.ts → FileUpload.d.ts} +3 -3
- package/lib/FileUpload.js +124 -0
- package/lib/{esm/Form.d.ts → Form.d.ts} +13 -13
- package/lib/{esm/Form.js → Form.js} +34 -68
- package/lib/{esm/FormInstance.d.ts → FormInstance.d.ts} +3 -3
- package/lib/FormInstance.js +94 -0
- package/lib/{esm/FormMetaData.d.ts → FormMetaData.d.ts} +2 -2
- package/lib/FormMetaData.js +15 -0
- package/lib/{esm/InstanceManager.d.ts → InstanceManager.d.ts} +2 -2
- package/lib/InstanceManager.js +35 -0
- package/lib/{esm/Node.d.ts → Node.d.ts} +0 -0
- package/lib/Node.js +15 -0
- package/lib/{esm/Scriptable.d.ts → Scriptable.d.ts} +3 -3
- package/lib/{esm/Scriptable.js → Scriptable.js} +17 -38
- package/lib/{esm/controller → controller}/EventQueue.d.ts +3 -3
- package/lib/{esm/controller → controller}/EventQueue.js +8 -32
- package/lib/{esm/controller → controller}/Events.d.ts +2 -2
- package/lib/{esm/controller → controller}/Events.js +22 -26
- package/lib/{esm/controller → controller}/Logger.d.ts +2 -2
- package/lib/controller/Logger.js +33 -0
- package/lib/{esm/data → data}/DataGroup.d.ts +1 -1
- package/lib/{esm/data → data}/DataGroup.js +20 -38
- package/lib/{esm/data → data}/DataValue.d.ts +1 -1
- package/lib/{esm/data → data}/DataValue.js +4 -26
- package/lib/{esm/data → data}/EmptyDataValue.d.ts +1 -1
- package/lib/data/EmptyDataValue.js +34 -0
- package/lib/index.d.ts +21 -0
- package/lib/index.js +57 -0
- package/lib/{esm/rules → rules}/FunctionRuntime.d.ts +3 -3
- package/lib/{esm/rules → rules}/FunctionRuntime.js +52 -63
- package/lib/{esm/rules → rules}/RuleEngine.d.ts +1 -1
- package/lib/rules/RuleEngine.js +51 -0
- package/lib/{esm/types → types}/Json.d.ts +18 -16
- package/lib/types/Json.js +10 -0
- package/lib/{esm/types → types}/Model.d.ts +10 -10
- package/lib/types/Model.js +10 -0
- package/lib/types/index.d.ts +2 -0
- package/lib/types/index.js +18 -0
- package/lib/{esm/utils → utils}/DataRefParser.d.ts +10 -4
- package/lib/{esm/utils → utils}/DataRefParser.js +48 -42
- package/lib/{esm/utils → utils}/Fetch.d.ts +1 -1
- package/lib/utils/Fetch.js +74 -0
- package/lib/{esm/utils → utils}/FormCreationUtils.d.ts +1 -1
- package/lib/utils/FormCreationUtils.js +67 -0
- package/lib/{esm/utils → utils}/FormUtils.d.ts +2 -1
- package/lib/{esm/utils → utils}/FormUtils.js +62 -46
- package/lib/{esm/utils → utils}/JsonUtils.d.ts +1 -1
- package/lib/utils/JsonUtils.js +89 -0
- package/lib/{esm/utils → utils}/LogUtils.d.ts +1 -1
- package/lib/utils/LogUtils.js +10 -0
- package/lib/{esm/utils → utils}/SchemaUtils.d.ts +1 -1
- package/lib/{esm/utils → utils}/SchemaUtils.js +9 -29
- package/lib/{esm/utils → utils}/TranslationUtils.d.ts +2 -2
- package/lib/utils/TranslationUtils.js +125 -0
- package/lib/{esm/utils → utils}/ValidationUtils.d.ts +4 -4
- package/lib/{esm/utils → utils}/ValidationUtils.js +13 -35
- package/package.json +8 -13
- package/lib/cjs/index.cjs +0 -7345
- package/lib/esm/BaseNode.js +0 -26
- package/lib/esm/Checkbox.js +0 -63
- package/lib/esm/CheckboxGroup.js +0 -60
- package/lib/esm/DateField.js +0 -57
- package/lib/esm/Fieldset.d.ts +0 -16
- package/lib/esm/Fieldset.js +0 -78
- package/lib/esm/FileObject.js +0 -48
- package/lib/esm/FileUpload.js +0 -141
- package/lib/esm/FormInstance.js +0 -129
- package/lib/esm/FormMetaData.js +0 -35
- package/lib/esm/InstanceManager.js +0 -58
- package/lib/esm/Node.js +0 -40
- package/lib/esm/controller/Logger.js +0 -52
- package/lib/esm/data/EmptyDataValue.js +0 -51
- package/lib/esm/index.d.ts +0 -21
- package/lib/esm/index.js +0 -55
- package/lib/esm/rules/RuleEngine.js +0 -76
- package/lib/esm/types/Json.js +0 -29
- package/lib/esm/types/Model.js +0 -30
- package/lib/esm/types/index.d.ts +0 -2
- package/lib/esm/types/index.js +0 -22
- package/lib/esm/utils/Fetch.js +0 -83
- package/lib/esm/utils/FormCreationUtils.js +0 -112
- package/lib/esm/utils/JsonUtils.js +0 -99
- package/lib/esm/utils/LogUtils.js +0 -28
- package/lib/esm/utils/TranslationUtils.js +0 -138
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Action, BaseJson, BaseModel, callbackFn, ContainerModel, FormModel, Primitives, ValidationError } from './types/index
|
|
2
|
-
import DataGroup from './data/DataGroup
|
|
3
|
-
import DataValue from './data/DataValue
|
|
1
|
+
import { Action, BaseJson, BaseModel, callbackFn, ContainerModel, FormModel, Primitives, ValidationError } from './types/index';
|
|
2
|
+
import DataGroup from './data/DataGroup';
|
|
3
|
+
import DataValue from './data/DataValue';
|
|
4
4
|
export declare const editableProperties: string[];
|
|
5
5
|
export declare const dynamicProps: string[];
|
|
6
6
|
export declare const staticFields: string[];
|
|
@@ -44,9 +44,9 @@ export declare abstract class BaseNode<T extends BaseJson> implements BaseModel
|
|
|
44
44
|
get visible(): boolean | undefined;
|
|
45
45
|
set visible(v: boolean | undefined);
|
|
46
46
|
get form(): FormModel;
|
|
47
|
-
get ruleEngine(): import("./rules/RuleEngine
|
|
48
|
-
get label(): import("./types/Json
|
|
49
|
-
set label(l: import("./types/Json
|
|
47
|
+
get ruleEngine(): import("./rules/RuleEngine").default;
|
|
48
|
+
get label(): import("./types/Json").Label | undefined;
|
|
49
|
+
set label(l: import("./types/Json").Label | undefined);
|
|
50
50
|
get uniqueItems(): boolean | undefined;
|
|
51
51
|
isTransparent(): boolean;
|
|
52
52
|
getState(isRepeatableChild?: boolean): T & {
|
|
@@ -72,11 +72,11 @@ export declare abstract class BaseNode<T extends BaseJson> implements BaseModel
|
|
|
72
72
|
queueEvent(action: Action): void;
|
|
73
73
|
dispatch(action: Action): void;
|
|
74
74
|
notifyDependents(action: Action): void;
|
|
75
|
-
_setProperty<T>(prop: string, newValue: T, notify?: boolean): any;
|
|
75
|
+
_setProperty<T>(prop: string, newValue: T, notify?: boolean, notifyChildren?: (action: Action) => void): any;
|
|
76
76
|
_bindToDataModel(contextualDataModel: DataGroup): void;
|
|
77
77
|
private _data?;
|
|
78
78
|
getDataNode(): DataValue | undefined;
|
|
79
|
-
get
|
|
79
|
+
get lang(): string | undefined;
|
|
80
80
|
get properties(): {
|
|
81
81
|
[key: string]: any;
|
|
82
82
|
};
|
|
@@ -1,35 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
* ___________________
|
|
4
|
-
*
|
|
5
|
-
* Copyright 2022 Adobe
|
|
6
|
-
* All Rights Reserved.
|
|
7
|
-
*
|
|
8
|
-
* NOTICE: All information contained herein is, and remains
|
|
9
|
-
* the property of Adobe and its suppliers, if any. The intellectual
|
|
10
|
-
* and technical concepts contained herein are proprietary to Adobe
|
|
11
|
-
* and its suppliers and are protected by all applicable intellectual
|
|
12
|
-
* property laws, including trade secret and copyright laws.
|
|
13
|
-
* Dissemination of this information or reproduction of this material
|
|
14
|
-
* is strictly forbidden unless prior written permission is obtained
|
|
15
|
-
* from Adobe.
|
|
16
|
-
|
|
17
|
-
* Adobe permits you to use and modify this file solely in accordance with
|
|
18
|
-
* the terms of the Adobe license agreement accompanying it.
|
|
19
|
-
*************************************************************************/
|
|
20
|
-
|
|
21
|
-
import { propertyChange, ExecuteRule } from './controller/Events.js';
|
|
22
|
-
import { tokenize, TOK_GLOBAL, resolveData } from './utils/DataRefParser.js';
|
|
23
|
-
import NullDataValue from './data/EmptyDataValue.js';
|
|
24
|
-
|
|
25
|
-
function __decorate(decorators, target, key, desc) {
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
26
3
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
27
4
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
28
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;
|
|
29
6
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
|
|
7
|
+
};
|
|
8
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.BaseNode = exports.exclude = exports.include = exports.dependencyTracked = exports.qualifiedName = exports.target = exports.staticFields = exports.dynamicProps = exports.editableProperties = void 0;
|
|
13
|
+
const Events_1 = require("./controller/Events");
|
|
14
|
+
const DataRefParser_1 = require("./utils/DataRefParser");
|
|
15
|
+
const EmptyDataValue_1 = __importDefault(require("./data/EmptyDataValue"));
|
|
16
|
+
exports.editableProperties = [
|
|
33
17
|
'value',
|
|
34
18
|
'label',
|
|
35
19
|
'description',
|
|
@@ -47,16 +31,14 @@ const editableProperties = [
|
|
|
47
31
|
'minimum',
|
|
48
32
|
'minItems'
|
|
49
33
|
];
|
|
50
|
-
|
|
51
|
-
...editableProperties,
|
|
34
|
+
exports.dynamicProps = [
|
|
35
|
+
...exports.editableProperties,
|
|
52
36
|
'valid',
|
|
53
37
|
'index',
|
|
54
38
|
'activeChild'
|
|
55
39
|
];
|
|
56
|
-
|
|
40
|
+
exports.staticFields = ['plain-text', 'image'];
|
|
57
41
|
class ActionImplWithTarget {
|
|
58
|
-
_action;
|
|
59
|
-
_target;
|
|
60
42
|
constructor(_action, _target) {
|
|
61
43
|
this._action = _action;
|
|
62
44
|
this._target = _target;
|
|
@@ -83,8 +65,8 @@ class ActionImplWithTarget {
|
|
|
83
65
|
return this._action.toString();
|
|
84
66
|
}
|
|
85
67
|
}
|
|
86
|
-
|
|
87
|
-
|
|
68
|
+
exports.target = Symbol('target');
|
|
69
|
+
exports.qualifiedName = Symbol('qualifiedName');
|
|
88
70
|
function dependencyTracked() {
|
|
89
71
|
return function (target, propertyKey, descriptor) {
|
|
90
72
|
const get = descriptor.get;
|
|
@@ -96,6 +78,7 @@ function dependencyTracked() {
|
|
|
96
78
|
}
|
|
97
79
|
};
|
|
98
80
|
}
|
|
81
|
+
exports.dependencyTracked = dependencyTracked;
|
|
99
82
|
const addOnly = (includeOrExclude) => (...fieldTypes) => (target, propertyKey, descriptor) => {
|
|
100
83
|
const get = descriptor.get;
|
|
101
84
|
if (get != undefined) {
|
|
@@ -115,26 +98,20 @@ const addOnly = (includeOrExclude) => (...fieldTypes) => (target, propertyKey, d
|
|
|
115
98
|
};
|
|
116
99
|
}
|
|
117
100
|
};
|
|
118
|
-
|
|
119
|
-
|
|
101
|
+
exports.include = addOnly(true);
|
|
102
|
+
exports.exclude = addOnly(false);
|
|
120
103
|
class BaseNode {
|
|
121
|
-
_options;
|
|
122
|
-
_ruleNode;
|
|
123
|
-
_lang = '';
|
|
124
|
-
_callbacks = {};
|
|
125
|
-
_dependents = [];
|
|
126
|
-
_jsonModel;
|
|
127
|
-
_tokens = [];
|
|
128
|
-
get isContainer() {
|
|
129
|
-
return false;
|
|
130
|
-
}
|
|
131
104
|
constructor(params, _options) {
|
|
132
105
|
this._options = _options;
|
|
133
|
-
this
|
|
134
|
-
this.
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
106
|
+
this._lang = '';
|
|
107
|
+
this._callbacks = {};
|
|
108
|
+
this._dependents = [];
|
|
109
|
+
this._tokens = [];
|
|
110
|
+
this[exports.qualifiedName] = null;
|
|
111
|
+
this._jsonModel = Object.assign(Object.assign({}, params), { id: 'id' in params ? params.id : this.form.getUniqueId() });
|
|
112
|
+
}
|
|
113
|
+
get isContainer() {
|
|
114
|
+
return false;
|
|
138
115
|
}
|
|
139
116
|
setupRuleNode() {
|
|
140
117
|
const self = this;
|
|
@@ -154,7 +131,7 @@ class BaseNode {
|
|
|
154
131
|
if (prop === Symbol.toPrimitive || (prop === 'valueOf' && !ruleNodeReference.hasOwnProperty('valueOf'))) {
|
|
155
132
|
return this.valueOf;
|
|
156
133
|
}
|
|
157
|
-
else if (prop === target) {
|
|
134
|
+
else if (prop === exports.target) {
|
|
158
135
|
return this;
|
|
159
136
|
}
|
|
160
137
|
else if (typeof (prop) === 'string') {
|
|
@@ -199,7 +176,8 @@ class BaseNode {
|
|
|
199
176
|
return this._jsonModel.type;
|
|
200
177
|
}
|
|
201
178
|
get repeatable() {
|
|
202
|
-
|
|
179
|
+
var _a;
|
|
180
|
+
return (_a = this.parent) === null || _a === void 0 ? void 0 : _a.hasDynamicItems();
|
|
203
181
|
}
|
|
204
182
|
get fieldType() {
|
|
205
183
|
return this._jsonModel.fieldType || 'text-input';
|
|
@@ -224,7 +202,7 @@ class BaseNode {
|
|
|
224
202
|
}
|
|
225
203
|
set visible(v) {
|
|
226
204
|
if (v !== this._jsonModel.visible) {
|
|
227
|
-
const changeAction = propertyChange('visible', v, this._jsonModel.visible);
|
|
205
|
+
const changeAction = (0, Events_1.propertyChange)('visible', v, this._jsonModel.visible);
|
|
228
206
|
this._jsonModel.visible = v;
|
|
229
207
|
this.notifyDependents(changeAction);
|
|
230
208
|
}
|
|
@@ -240,11 +218,8 @@ class BaseNode {
|
|
|
240
218
|
}
|
|
241
219
|
set label(l) {
|
|
242
220
|
if (l !== this._jsonModel.label) {
|
|
243
|
-
const changeAction = propertyChange('label', l, this._jsonModel.label);
|
|
244
|
-
this._jsonModel = {
|
|
245
|
-
...this._jsonModel,
|
|
246
|
-
label: l
|
|
247
|
-
};
|
|
221
|
+
const changeAction = (0, Events_1.propertyChange)('label', l, this._jsonModel.label);
|
|
222
|
+
this._jsonModel = Object.assign(Object.assign({}, this._jsonModel), { label: l });
|
|
248
223
|
this.notifyDependents(changeAction);
|
|
249
224
|
}
|
|
250
225
|
}
|
|
@@ -252,21 +227,12 @@ class BaseNode {
|
|
|
252
227
|
return this._jsonModel.uniqueItems;
|
|
253
228
|
}
|
|
254
229
|
isTransparent() {
|
|
255
|
-
|
|
230
|
+
var _a;
|
|
231
|
+
const isNonTransparent = ((_a = this.parent) === null || _a === void 0 ? void 0 : _a._jsonModel.type) === 'array';
|
|
256
232
|
return !this._jsonModel.name && !isNonTransparent;
|
|
257
233
|
}
|
|
258
234
|
getState(isRepeatableChild = false) {
|
|
259
|
-
return {
|
|
260
|
-
...this._jsonModel,
|
|
261
|
-
properties: this.properties,
|
|
262
|
-
index: this.index,
|
|
263
|
-
parent: undefined,
|
|
264
|
-
qualifiedName: this.qualifiedName,
|
|
265
|
-
events: {},
|
|
266
|
-
rules: {},
|
|
267
|
-
repeatable: this.repeatable === true ? true : undefined,
|
|
268
|
-
':type': this[':type']
|
|
269
|
-
};
|
|
235
|
+
return Object.assign(Object.assign({}, this._jsonModel), { properties: this.properties, index: this.index, parent: undefined, qualifiedName: this.qualifiedName, events: {}, rules: {}, repeatable: this.repeatable === true ? true : undefined, ':type': this[':type'] });
|
|
270
236
|
}
|
|
271
237
|
subscribe(callback, eventName = 'change') {
|
|
272
238
|
this._callbacks[eventName] = this._callbacks[eventName] || [];
|
|
@@ -281,12 +247,12 @@ class BaseNode {
|
|
|
281
247
|
if (this._dependents.find(({ node }) => node === dependent) === undefined) {
|
|
282
248
|
const subscription = this.subscribe((change) => {
|
|
283
249
|
const changes = change.payload.changes;
|
|
284
|
-
const propsToLook = [...dynamicProps, 'items'];
|
|
250
|
+
const propsToLook = [...exports.dynamicProps, 'items'];
|
|
285
251
|
const isPropChanged = changes.findIndex(x => {
|
|
286
252
|
return propsToLook.indexOf(x.propertyName) > -1;
|
|
287
253
|
}) > -1;
|
|
288
254
|
if (isPropChanged) {
|
|
289
|
-
dependent.dispatch(new ExecuteRule());
|
|
255
|
+
dependent.dispatch(new Events_1.ExecuteRule());
|
|
290
256
|
}
|
|
291
257
|
});
|
|
292
258
|
this._dependents.push({ node: dependent, subscription });
|
|
@@ -313,7 +279,7 @@ class BaseNode {
|
|
|
313
279
|
x(new ActionImplWithTarget(action, this));
|
|
314
280
|
});
|
|
315
281
|
}
|
|
316
|
-
_setProperty(prop, newValue, notify = true) {
|
|
282
|
+
_setProperty(prop, newValue, notify = true, notifyChildren = (action) => { }) {
|
|
317
283
|
const oldValue = this._jsonModel[prop];
|
|
318
284
|
let isValueSame = false;
|
|
319
285
|
if (newValue !== null && oldValue !== null &&
|
|
@@ -325,10 +291,11 @@ class BaseNode {
|
|
|
325
291
|
}
|
|
326
292
|
if (!isValueSame) {
|
|
327
293
|
this._jsonModel[prop] = newValue;
|
|
328
|
-
const changeAction = propertyChange(prop, newValue, oldValue);
|
|
294
|
+
const changeAction = (0, Events_1.propertyChange)(prop, newValue, oldValue);
|
|
329
295
|
if (notify) {
|
|
330
296
|
this.notifyDependents(changeAction);
|
|
331
297
|
}
|
|
298
|
+
notifyChildren.call(this, changeAction);
|
|
332
299
|
return changeAction.payload.changes;
|
|
333
300
|
}
|
|
334
301
|
return [];
|
|
@@ -341,26 +308,33 @@ class BaseNode {
|
|
|
341
308
|
const dataRef = this._jsonModel.dataRef;
|
|
342
309
|
let _data, _parent = contextualDataModel, _key = '';
|
|
343
310
|
if (dataRef === null) {
|
|
344
|
-
_data =
|
|
311
|
+
_data = EmptyDataValue_1.default;
|
|
345
312
|
}
|
|
346
|
-
else if (dataRef !== undefined) {
|
|
313
|
+
else if (dataRef !== undefined && !this.repeatable) {
|
|
347
314
|
if (this._tokens.length === 0) {
|
|
348
|
-
this._tokens = tokenize(dataRef);
|
|
315
|
+
this._tokens = (0, DataRefParser_1.tokenize)(dataRef);
|
|
349
316
|
}
|
|
350
317
|
let searchData = contextualDataModel;
|
|
351
|
-
if (this._tokens[0].type === TOK_GLOBAL) {
|
|
318
|
+
if (this._tokens[0].type === DataRefParser_1.TOK_GLOBAL) {
|
|
352
319
|
searchData = this.form.getDataNode();
|
|
353
320
|
}
|
|
321
|
+
else if (this._tokens[0].type === DataRefParser_1.TOK_REPEATABLE) {
|
|
322
|
+
let repeatRoot = this.parent;
|
|
323
|
+
while (!repeatRoot.repeatable && repeatRoot !== this.form) {
|
|
324
|
+
repeatRoot = repeatRoot.parent;
|
|
325
|
+
}
|
|
326
|
+
searchData = repeatRoot.getDataNode();
|
|
327
|
+
}
|
|
354
328
|
if (typeof searchData !== 'undefined') {
|
|
355
329
|
const name = this._tokens[this._tokens.length - 1].value;
|
|
356
330
|
const create = this.defaultDataModel(name);
|
|
357
|
-
_data = resolveData(searchData, this._tokens, create);
|
|
358
|
-
_parent = resolveData(searchData, this._tokens.slice(0, -1));
|
|
331
|
+
_data = (0, DataRefParser_1.resolveData)(searchData, this._tokens, create);
|
|
332
|
+
_parent = (0, DataRefParser_1.resolveData)(searchData, this._tokens.slice(0, -1));
|
|
359
333
|
_key = name;
|
|
360
334
|
}
|
|
361
335
|
}
|
|
362
336
|
else {
|
|
363
|
-
if (contextualDataModel !==
|
|
337
|
+
if (contextualDataModel !== EmptyDataValue_1.default && exports.staticFields.indexOf(this.fieldType) === -1) {
|
|
364
338
|
_parent = contextualDataModel;
|
|
365
339
|
const name = this._jsonModel.name || '';
|
|
366
340
|
const key = contextualDataModel.$type === 'array' ? this.index : name;
|
|
@@ -381,22 +355,24 @@ class BaseNode {
|
|
|
381
355
|
}
|
|
382
356
|
}
|
|
383
357
|
if (_data) {
|
|
384
|
-
if (!this.isContainer && _parent !==
|
|
385
|
-
_data = _data
|
|
358
|
+
if (!this.isContainer && _parent !== EmptyDataValue_1.default && _data !== EmptyDataValue_1.default) {
|
|
359
|
+
_data = _data === null || _data === void 0 ? void 0 : _data.$convertToDataValue();
|
|
386
360
|
_parent.$addDataNode(_key, _data, true);
|
|
387
361
|
}
|
|
388
|
-
_data
|
|
362
|
+
_data === null || _data === void 0 ? void 0 : _data.$bindToField(this);
|
|
389
363
|
this._data = _data;
|
|
390
364
|
}
|
|
391
365
|
}
|
|
392
|
-
_data;
|
|
393
366
|
getDataNode() {
|
|
394
367
|
return this._data;
|
|
395
368
|
}
|
|
396
|
-
get
|
|
369
|
+
get lang() {
|
|
370
|
+
if (this._jsonModel.lang) {
|
|
371
|
+
this._lang = this._jsonModel.lang;
|
|
372
|
+
}
|
|
397
373
|
if (!this._lang) {
|
|
398
374
|
if (this.parent) {
|
|
399
|
-
this._lang = this.parent.
|
|
375
|
+
this._lang = this.parent.lang;
|
|
400
376
|
}
|
|
401
377
|
else {
|
|
402
378
|
this._lang = Intl.DateTimeFormat().resolvedOptions().locale;
|
|
@@ -408,7 +384,7 @@ class BaseNode {
|
|
|
408
384
|
return this._jsonModel.properties || {};
|
|
409
385
|
}
|
|
410
386
|
set properties(p) {
|
|
411
|
-
this._setProperty('properties', {
|
|
387
|
+
this._setProperty('properties', Object.assign({}, p));
|
|
412
388
|
}
|
|
413
389
|
getNonTransparentParent() {
|
|
414
390
|
let nonTransparentParent = this.parent;
|
|
@@ -441,17 +417,17 @@ class BaseNode {
|
|
|
441
417
|
if (this.isTransparent()) {
|
|
442
418
|
return null;
|
|
443
419
|
}
|
|
444
|
-
if (this[qualifiedName] !== null) {
|
|
445
|
-
return this[qualifiedName];
|
|
420
|
+
if (this[exports.qualifiedName] !== null) {
|
|
421
|
+
return this[exports.qualifiedName];
|
|
446
422
|
}
|
|
447
423
|
const parent = this.getNonTransparentParent();
|
|
448
424
|
if (parent && parent.type === 'array') {
|
|
449
|
-
this[qualifiedName] = `${parent.qualifiedName}[${this.index}]`;
|
|
425
|
+
this[exports.qualifiedName] = `${parent.qualifiedName}[${this.index}]`;
|
|
450
426
|
}
|
|
451
427
|
else {
|
|
452
|
-
this[qualifiedName] = `${parent.qualifiedName}.${this.name}`;
|
|
428
|
+
this[exports.qualifiedName] = `${parent.qualifiedName}.${this.name}`;
|
|
453
429
|
}
|
|
454
|
-
return this[qualifiedName];
|
|
430
|
+
return this[exports.qualifiedName];
|
|
455
431
|
}
|
|
456
432
|
focus() {
|
|
457
433
|
if (this.parent) {
|
|
@@ -474,5 +450,4 @@ __decorate([
|
|
|
474
450
|
__decorate([
|
|
475
451
|
dependencyTracked()
|
|
476
452
|
], BaseNode.prototype, "properties", null);
|
|
477
|
-
|
|
478
|
-
export { BaseNode as B, __decorate as _, editableProperties as a, dynamicProps as b, dependencyTracked as d, exclude as e, include as i, qualifiedName as q, staticFields as s, target as t };
|
|
453
|
+
exports.BaseNode = BaseNode;
|
package/lib/Checkbox.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const Field_1 = __importDefault(require("./Field"));
|
|
7
|
+
const ValidationUtils_1 = require("./utils/ValidationUtils");
|
|
8
|
+
const requiredConstraint = (offValue) => (constraint, value) => {
|
|
9
|
+
const valid = ValidationUtils_1.Constraints.required(constraint, value).valid && (!constraint || value != offValue);
|
|
10
|
+
return { valid, value };
|
|
11
|
+
};
|
|
12
|
+
class Checkbox extends Field_1.default {
|
|
13
|
+
offValue() {
|
|
14
|
+
const opts = this.enum;
|
|
15
|
+
return opts.length > 1 ? opts[1] : null;
|
|
16
|
+
}
|
|
17
|
+
_getConstraintObject() {
|
|
18
|
+
const baseConstraints = Object.assign({}, super._getConstraintObject());
|
|
19
|
+
baseConstraints.required = requiredConstraint(this.offValue());
|
|
20
|
+
return baseConstraints;
|
|
21
|
+
}
|
|
22
|
+
_getDefaults() {
|
|
23
|
+
return Object.assign(Object.assign({}, super._getDefaults()), { enforceEnum: true });
|
|
24
|
+
}
|
|
25
|
+
get enum() {
|
|
26
|
+
return this._jsonModel.enum || [];
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.default = Checkbox;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import Field from './Field
|
|
2
|
-
import { ContainerModel, FieldJson, FormModel } from './types/index
|
|
1
|
+
import Field from './Field';
|
|
2
|
+
import { ContainerModel, FieldJson, FormModel } from './types/index';
|
|
3
3
|
declare class CheckboxGroup extends Field {
|
|
4
4
|
constructor(params: FieldJson, _options: {
|
|
5
5
|
form: FormModel;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const Field_1 = __importDefault(require("./Field"));
|
|
7
|
+
class CheckboxGroup extends Field_1.default {
|
|
8
|
+
constructor(params, _options) {
|
|
9
|
+
super(params, _options);
|
|
10
|
+
}
|
|
11
|
+
_getFallbackType() {
|
|
12
|
+
const fallbackType = super._getFallbackType();
|
|
13
|
+
if (typeof fallbackType === 'string') {
|
|
14
|
+
return `${fallbackType}[]`;
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
return 'string[]';
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
_getDefaults() {
|
|
21
|
+
return Object.assign(Object.assign({}, super._getDefaults()), { enforceEnum: true, enum: [] });
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.default = CheckboxGroup;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Action, BaseModel, ContainerJson, ContainerModel, FieldModel, FieldsetModel, FormModel, IFormFieldFactory, RulesJson } from './types/index
|
|
2
|
-
import Scriptable from './Scriptable
|
|
3
|
-
import DataGroup from './data/DataGroup
|
|
1
|
+
import { Action, BaseModel, ContainerJson, ContainerModel, FieldModel, FieldsetModel, FormModel, IFormFieldFactory, RulesJson } from './types/index';
|
|
2
|
+
import Scriptable from './Scriptable';
|
|
3
|
+
import DataGroup from './data/DataGroup';
|
|
4
4
|
declare abstract class Container<T extends ContainerJson & RulesJson> extends Scriptable<T> implements ContainerModel {
|
|
5
5
|
protected _children: Array<FieldModel | FieldsetModel>;
|
|
6
6
|
protected _childrenReference: any;
|
|
@@ -48,7 +48,7 @@ declare abstract class Container<T extends ContainerJson & RulesJson> extends Sc
|
|
|
48
48
|
removeItem(action: Action): void;
|
|
49
49
|
queueEvent(action: Action): void;
|
|
50
50
|
reset(): void;
|
|
51
|
-
validate(): import("./types/Model
|
|
51
|
+
validate(): import("./types/Model").ValidationError[];
|
|
52
52
|
dispatch(action: Action): void;
|
|
53
53
|
importData(contextualDataModel: DataGroup): void;
|
|
54
54
|
syncDataAndFormModel(contextualDataModel?: DataGroup): void;
|