@aemforms/af-core 0.22.23 → 0.22.26
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/browser/afb-events.js +151 -0
- package/lib/browser/afb-runtime.js +3620 -0
- package/lib/cjs/index.cjs +1876 -267
- package/lib/esm/BaseNode.js +454 -26
- package/lib/esm/Checkbox.js +1 -37
- package/lib/esm/CheckboxGroup.js +1 -38
- package/lib/esm/Container.js +9 -30
- package/lib/esm/DateField.js +2 -38
- package/lib/esm/Field.d.ts +2 -2
- package/lib/esm/Field.js +26 -62
- package/lib/esm/Fieldset.js +3 -36
- package/lib/esm/FileObject.js +1 -23
- package/lib/esm/FileUpload.js +1 -34
- package/lib/esm/Form.d.ts +1 -1
- package/lib/esm/Form.js +8 -40
- package/lib/esm/FormInstance.js +5 -53
- package/lib/esm/FormMetaData.js +1 -26
- package/lib/esm/InstanceManager.js +8 -35
- package/lib/esm/Node.js +1 -25
- package/lib/esm/Scriptable.js +2 -29
- package/lib/esm/controller/EventQueue.js +1 -23
- package/lib/esm/controller/Events.d.ts +1 -1
- package/lib/esm/controller/Events.js +19 -41
- package/lib/esm/controller/Logger.d.ts +2 -2
- package/lib/esm/controller/Logger.js +1 -23
- package/lib/esm/data/DataGroup.js +1 -24
- package/lib/esm/data/DataValue.js +1 -23
- package/lib/esm/data/EmptyDataValue.js +1 -23
- package/lib/esm/index.js +21 -55
- package/lib/esm/rules/FunctionRuntime.d.ts +3 -3
- package/lib/esm/rules/FunctionRuntime.js +6 -31
- package/lib/esm/rules/RuleEngine.js +1 -30
- package/lib/esm/types/Json.d.ts +16 -16
- package/lib/esm/types/Json.js +2 -24
- package/lib/esm/types/Model.d.ts +4 -4
- package/lib/esm/types/Model.js +1 -23
- package/lib/esm/types/index.js +2 -22
- package/lib/esm/utils/DataRefParser.d.ts +2 -2
- package/lib/esm/utils/DataRefParser.js +6 -31
- package/lib/esm/utils/Fetch.d.ts +1 -1
- package/lib/esm/utils/Fetch.js +2 -24
- package/lib/esm/utils/FormCreationUtils.js +2 -40
- package/lib/esm/utils/FormUtils.js +8 -33
- package/lib/esm/utils/JsonUtils.js +11 -34
- package/lib/esm/utils/LogUtils.js +1 -23
- package/lib/esm/utils/SchemaUtils.js +2 -24
- package/lib/esm/utils/TranslationUtils.d.ts +1 -1
- package/lib/esm/utils/TranslationUtils.js +9 -32
- package/lib/esm/utils/ValidationUtils.d.ts +4 -4
- package/lib/esm/utils/ValidationUtils.js +4 -30
- package/package.json +2 -14
- package/lib/esm/BaseNode-dc59ab07.js +0 -478
|
@@ -1,29 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
* ADOBE CONFIDENTIAL
|
|
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 { getFileSizeInBytes, extractFileInfo } from './FormUtils.js';
|
|
1
|
+
import { extractFileInfo, getFileSizeInBytes } from './FormUtils.js';
|
|
22
2
|
import { FileObject } from '../FileObject.js';
|
|
23
|
-
import './JsonUtils.js';
|
|
24
|
-
import '../types/Json.js';
|
|
25
|
-
import './SchemaUtils.js';
|
|
26
|
-
|
|
27
3
|
const dateRegex = /^(\d{4})-(\d{1,2})-(\d{1,2})$/;
|
|
28
4
|
const days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
29
5
|
const daysInMonth = (leapYear, month) => {
|
|
@@ -35,7 +11,7 @@ const daysInMonth = (leapYear, month) => {
|
|
|
35
11
|
const isLeapYear = (year) => {
|
|
36
12
|
return year % 400 === 0 || year % 4 === 0 && year % 100 !== 0;
|
|
37
13
|
};
|
|
38
|
-
const coerceType = (param, type) => {
|
|
14
|
+
export const coerceType = (param, type) => {
|
|
39
15
|
let num;
|
|
40
16
|
switch (type) {
|
|
41
17
|
case 'string':
|
|
@@ -129,14 +105,14 @@ const partitionArray = (inputVal, validatorFn) => {
|
|
|
129
105
|
return acc;
|
|
130
106
|
}, [[], []]);
|
|
131
107
|
};
|
|
132
|
-
const ValidConstraints = {
|
|
108
|
+
export const ValidConstraints = {
|
|
133
109
|
date: ['minimum', 'maximum', 'exclusiveMinimum', 'exclusiveMaximum', 'format'],
|
|
134
110
|
string: ['minLength', 'maxLength', 'pattern'],
|
|
135
111
|
number: ['minimum', 'maximum', 'exclusiveMinimum', 'exclusiveMaximum'],
|
|
136
112
|
array: ['minItems', 'maxItems', 'uniqueItems'],
|
|
137
113
|
file: ['accept', 'maxFileSize']
|
|
138
114
|
};
|
|
139
|
-
const Constraints = {
|
|
115
|
+
export const Constraints = {
|
|
140
116
|
type: (constraint, inputVal) => {
|
|
141
117
|
let value = inputVal;
|
|
142
118
|
if (inputVal == undefined) {
|
|
@@ -296,5 +272,3 @@ const Constraints = {
|
|
|
296
272
|
};
|
|
297
273
|
}
|
|
298
274
|
};
|
|
299
|
-
|
|
300
|
-
export { Constraints, ValidConstraints, coerceType };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aemforms/af-core",
|
|
3
|
-
"version": "0.22.
|
|
3
|
+
"version": "0.22.26",
|
|
4
4
|
"description": "Core Module for Forms Runtime",
|
|
5
5
|
"author": "Adobe Systems",
|
|
6
6
|
"license": "Adobe Proprietary",
|
|
@@ -29,20 +29,8 @@
|
|
|
29
29
|
"publishConfig": {
|
|
30
30
|
"access": "public"
|
|
31
31
|
},
|
|
32
|
-
"scripts": {
|
|
33
|
-
"test": "NODE_OPTIONS=--experimental-vm-modules jest --silent",
|
|
34
|
-
"eslint": "npx eslint src/**",
|
|
35
|
-
"eslint:fix": "npx eslint --fix src/**",
|
|
36
|
-
"test:ci": "NODE_OPTIONS=--experimental-vm-modules jest --silent --coverage",
|
|
37
|
-
"prebuild": "npm run clean && npm run eslint",
|
|
38
|
-
"build": "rollup -c rollup.config.js",
|
|
39
|
-
"clean": "rm -rf lib target",
|
|
40
|
-
"prepublishOnly": "npm run build && npm run test",
|
|
41
|
-
"docs": "npx typedoc --options .typedoc.cjs"
|
|
42
|
-
},
|
|
43
32
|
"dependencies": {
|
|
44
|
-
"@adobe/json-formula": "0.1.50"
|
|
45
|
-
"@aemforms/af-formatters": "^0.22.23"
|
|
33
|
+
"@adobe/json-formula": "0.1.50"
|
|
46
34
|
},
|
|
47
35
|
"devDependencies": {
|
|
48
36
|
"@types/jest": "29.2.4",
|
|
@@ -1,478 +0,0 @@
|
|
|
1
|
-
/*************************************************************************
|
|
2
|
-
* ADOBE CONFIDENTIAL
|
|
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) {
|
|
26
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
27
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
28
|
-
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
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const editableProperties = [
|
|
33
|
-
'value',
|
|
34
|
-
'label',
|
|
35
|
-
'description',
|
|
36
|
-
'visible',
|
|
37
|
-
'enabled',
|
|
38
|
-
'readOnly',
|
|
39
|
-
'enum',
|
|
40
|
-
'enumNames',
|
|
41
|
-
'required',
|
|
42
|
-
'properties',
|
|
43
|
-
'exclusiveMinimum',
|
|
44
|
-
'exclusiveMaximum',
|
|
45
|
-
'maximum',
|
|
46
|
-
'maxItems',
|
|
47
|
-
'minimum',
|
|
48
|
-
'minItems'
|
|
49
|
-
];
|
|
50
|
-
const dynamicProps = [
|
|
51
|
-
...editableProperties,
|
|
52
|
-
'valid',
|
|
53
|
-
'index',
|
|
54
|
-
'activeChild'
|
|
55
|
-
];
|
|
56
|
-
const staticFields = ['plain-text', 'image'];
|
|
57
|
-
class ActionImplWithTarget {
|
|
58
|
-
_action;
|
|
59
|
-
_target;
|
|
60
|
-
constructor(_action, _target) {
|
|
61
|
-
this._action = _action;
|
|
62
|
-
this._target = _target;
|
|
63
|
-
}
|
|
64
|
-
get type() {
|
|
65
|
-
return this._action.type;
|
|
66
|
-
}
|
|
67
|
-
get payload() {
|
|
68
|
-
return this._action.payload;
|
|
69
|
-
}
|
|
70
|
-
get metadata() {
|
|
71
|
-
return this._action.metadata;
|
|
72
|
-
}
|
|
73
|
-
get target() {
|
|
74
|
-
return this._target;
|
|
75
|
-
}
|
|
76
|
-
get isCustomEvent() {
|
|
77
|
-
return this._action.isCustomEvent;
|
|
78
|
-
}
|
|
79
|
-
get originalAction() {
|
|
80
|
-
return this._action.originalAction;
|
|
81
|
-
}
|
|
82
|
-
toString() {
|
|
83
|
-
return this._action.toString();
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
const target = Symbol('target');
|
|
87
|
-
const qualifiedName = Symbol('qualifiedName');
|
|
88
|
-
function dependencyTracked() {
|
|
89
|
-
return function (target, propertyKey, descriptor) {
|
|
90
|
-
const get = descriptor.get;
|
|
91
|
-
if (get != undefined) {
|
|
92
|
-
descriptor.get = function () {
|
|
93
|
-
this.ruleEngine.trackDependency(this);
|
|
94
|
-
return get.call(this);
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
const addOnly = (includeOrExclude) => (...fieldTypes) => (target, propertyKey, descriptor) => {
|
|
100
|
-
const get = descriptor.get;
|
|
101
|
-
if (get != undefined) {
|
|
102
|
-
descriptor.get = function () {
|
|
103
|
-
if (fieldTypes.indexOf(this.fieldType) > -1 === includeOrExclude) {
|
|
104
|
-
return get.call(this);
|
|
105
|
-
}
|
|
106
|
-
return undefined;
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
const set = descriptor.set;
|
|
110
|
-
if (set != undefined) {
|
|
111
|
-
descriptor.set = function (value) {
|
|
112
|
-
if (fieldTypes.indexOf(this.fieldType) > -1 === includeOrExclude) {
|
|
113
|
-
set.call(this, value);
|
|
114
|
-
}
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
};
|
|
118
|
-
const include = addOnly(true);
|
|
119
|
-
const exclude = addOnly(false);
|
|
120
|
-
class BaseNode {
|
|
121
|
-
_options;
|
|
122
|
-
_ruleNode;
|
|
123
|
-
_lang = '';
|
|
124
|
-
_callbacks = {};
|
|
125
|
-
_dependents = [];
|
|
126
|
-
_jsonModel;
|
|
127
|
-
_tokens = [];
|
|
128
|
-
get isContainer() {
|
|
129
|
-
return false;
|
|
130
|
-
}
|
|
131
|
-
constructor(params, _options) {
|
|
132
|
-
this._options = _options;
|
|
133
|
-
this[qualifiedName] = null;
|
|
134
|
-
this._jsonModel = {
|
|
135
|
-
...params,
|
|
136
|
-
id: 'id' in params ? params.id : this.form.getUniqueId()
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
setupRuleNode() {
|
|
140
|
-
const self = this;
|
|
141
|
-
this._ruleNode = new Proxy(this.ruleNodeReference(), {
|
|
142
|
-
get: (ruleNodeReference, prop) => {
|
|
143
|
-
return self.getFromRule(ruleNodeReference, prop);
|
|
144
|
-
}
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
ruleNodeReference() {
|
|
148
|
-
return this;
|
|
149
|
-
}
|
|
150
|
-
getRuleNode() {
|
|
151
|
-
return this._ruleNode;
|
|
152
|
-
}
|
|
153
|
-
getFromRule(ruleNodeReference, prop) {
|
|
154
|
-
if (prop === Symbol.toPrimitive || (prop === 'valueOf' && !ruleNodeReference.hasOwnProperty('valueOf'))) {
|
|
155
|
-
return this.valueOf;
|
|
156
|
-
}
|
|
157
|
-
else if (prop === target) {
|
|
158
|
-
return this;
|
|
159
|
-
}
|
|
160
|
-
else if (typeof (prop) === 'string') {
|
|
161
|
-
if (prop.startsWith('$')) {
|
|
162
|
-
prop = prop.substr(1);
|
|
163
|
-
if (typeof this[prop] !== 'function') {
|
|
164
|
-
const retValue = this[prop];
|
|
165
|
-
if (retValue instanceof BaseNode) {
|
|
166
|
-
return retValue.getRuleNode();
|
|
167
|
-
}
|
|
168
|
-
else if (retValue instanceof Array) {
|
|
169
|
-
return retValue.map(r => r instanceof BaseNode ? r.getRuleNode() : r);
|
|
170
|
-
}
|
|
171
|
-
else {
|
|
172
|
-
return retValue;
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
else {
|
|
177
|
-
if (ruleNodeReference.hasOwnProperty(prop)) {
|
|
178
|
-
return ruleNodeReference[prop];
|
|
179
|
-
}
|
|
180
|
-
else if (typeof ruleNodeReference[prop] === 'function') {
|
|
181
|
-
return ruleNodeReference[prop];
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
get id() {
|
|
187
|
-
return this._jsonModel.id;
|
|
188
|
-
}
|
|
189
|
-
get index() {
|
|
190
|
-
if (this.parent) {
|
|
191
|
-
return this.parent.indexOf(this);
|
|
192
|
-
}
|
|
193
|
-
return 0;
|
|
194
|
-
}
|
|
195
|
-
get parent() {
|
|
196
|
-
return this._options.parent;
|
|
197
|
-
}
|
|
198
|
-
get type() {
|
|
199
|
-
return this._jsonModel.type;
|
|
200
|
-
}
|
|
201
|
-
get repeatable() {
|
|
202
|
-
return this.parent?.hasDynamicItems();
|
|
203
|
-
}
|
|
204
|
-
get fieldType() {
|
|
205
|
-
return this._jsonModel.fieldType || 'text-input';
|
|
206
|
-
}
|
|
207
|
-
get ':type'() {
|
|
208
|
-
return this._jsonModel[':type'] || this.fieldType;
|
|
209
|
-
}
|
|
210
|
-
get name() {
|
|
211
|
-
return this._jsonModel.name;
|
|
212
|
-
}
|
|
213
|
-
get description() {
|
|
214
|
-
return this._jsonModel.description;
|
|
215
|
-
}
|
|
216
|
-
set description(d) {
|
|
217
|
-
this._setProperty('description', d);
|
|
218
|
-
}
|
|
219
|
-
get dataRef() {
|
|
220
|
-
return this._jsonModel.dataRef;
|
|
221
|
-
}
|
|
222
|
-
get visible() {
|
|
223
|
-
return this._jsonModel.visible;
|
|
224
|
-
}
|
|
225
|
-
set visible(v) {
|
|
226
|
-
if (v !== this._jsonModel.visible) {
|
|
227
|
-
const changeAction = propertyChange('visible', v, this._jsonModel.visible);
|
|
228
|
-
this._jsonModel.visible = v;
|
|
229
|
-
this.notifyDependents(changeAction);
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
get form() {
|
|
233
|
-
return this._options.form;
|
|
234
|
-
}
|
|
235
|
-
get ruleEngine() {
|
|
236
|
-
return this.form.ruleEngine;
|
|
237
|
-
}
|
|
238
|
-
get label() {
|
|
239
|
-
return this._jsonModel.label;
|
|
240
|
-
}
|
|
241
|
-
set label(l) {
|
|
242
|
-
if (l !== this._jsonModel.label) {
|
|
243
|
-
const changeAction = propertyChange('label', l, this._jsonModel.label);
|
|
244
|
-
this._jsonModel = {
|
|
245
|
-
...this._jsonModel,
|
|
246
|
-
label: l
|
|
247
|
-
};
|
|
248
|
-
this.notifyDependents(changeAction);
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
get uniqueItems() {
|
|
252
|
-
return this._jsonModel.uniqueItems;
|
|
253
|
-
}
|
|
254
|
-
isTransparent() {
|
|
255
|
-
const isNonTransparent = this.parent?._jsonModel.type === 'array';
|
|
256
|
-
return !this._jsonModel.name && !isNonTransparent;
|
|
257
|
-
}
|
|
258
|
-
getState() {
|
|
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
|
-
};
|
|
270
|
-
}
|
|
271
|
-
subscribe(callback, eventName = 'change') {
|
|
272
|
-
this._callbacks[eventName] = this._callbacks[eventName] || [];
|
|
273
|
-
this._callbacks[eventName].push(callback);
|
|
274
|
-
return {
|
|
275
|
-
unsubscribe: () => {
|
|
276
|
-
this._callbacks[eventName] = this._callbacks[eventName].filter(x => x !== callback);
|
|
277
|
-
}
|
|
278
|
-
};
|
|
279
|
-
}
|
|
280
|
-
_addDependent(dependent) {
|
|
281
|
-
if (this._dependents.find(({ node }) => node === dependent) === undefined) {
|
|
282
|
-
const subscription = this.subscribe((change) => {
|
|
283
|
-
const changes = change.payload.changes;
|
|
284
|
-
const propsToLook = [...dynamicProps, 'items'];
|
|
285
|
-
const isPropChanged = changes.findIndex(x => {
|
|
286
|
-
return propsToLook.indexOf(x.propertyName) > -1;
|
|
287
|
-
}) > -1;
|
|
288
|
-
if (isPropChanged) {
|
|
289
|
-
dependent.dispatch(new ExecuteRule());
|
|
290
|
-
}
|
|
291
|
-
});
|
|
292
|
-
this._dependents.push({ node: dependent, subscription });
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
removeDependent(dependent) {
|
|
296
|
-
const index = this._dependents.findIndex(({ node }) => node === dependent);
|
|
297
|
-
if (index > -1) {
|
|
298
|
-
this._dependents[index].subscription.unsubscribe();
|
|
299
|
-
this._dependents.splice(index, 1);
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
queueEvent(action) {
|
|
303
|
-
const actionWithTarget = new ActionImplWithTarget(action, this);
|
|
304
|
-
this.form.getEventQueue().queue(this, actionWithTarget, ['valid', 'invalid'].indexOf(actionWithTarget.type) > -1);
|
|
305
|
-
}
|
|
306
|
-
dispatch(action) {
|
|
307
|
-
this.queueEvent(action);
|
|
308
|
-
this.form.getEventQueue().runPendingQueue();
|
|
309
|
-
}
|
|
310
|
-
notifyDependents(action) {
|
|
311
|
-
const handlers = this._callbacks[action.type] || [];
|
|
312
|
-
handlers.forEach(x => {
|
|
313
|
-
x(new ActionImplWithTarget(action, this));
|
|
314
|
-
});
|
|
315
|
-
}
|
|
316
|
-
_setProperty(prop, newValue, notify = true) {
|
|
317
|
-
const oldValue = this._jsonModel[prop];
|
|
318
|
-
let isValueSame = false;
|
|
319
|
-
if (newValue !== null && oldValue !== null &&
|
|
320
|
-
typeof newValue === 'object' && typeof oldValue === 'object') {
|
|
321
|
-
isValueSame = JSON.stringify(newValue) === JSON.stringify(oldValue);
|
|
322
|
-
}
|
|
323
|
-
else {
|
|
324
|
-
isValueSame = oldValue === newValue;
|
|
325
|
-
}
|
|
326
|
-
if (!isValueSame) {
|
|
327
|
-
this._jsonModel[prop] = newValue;
|
|
328
|
-
const changeAction = propertyChange(prop, newValue, oldValue);
|
|
329
|
-
if (notify) {
|
|
330
|
-
this.notifyDependents(changeAction);
|
|
331
|
-
}
|
|
332
|
-
return changeAction.payload.changes;
|
|
333
|
-
}
|
|
334
|
-
return [];
|
|
335
|
-
}
|
|
336
|
-
_bindToDataModel(contextualDataModel) {
|
|
337
|
-
if (this.id === '$form') {
|
|
338
|
-
this._data = contextualDataModel;
|
|
339
|
-
return;
|
|
340
|
-
}
|
|
341
|
-
const dataRef = this._jsonModel.dataRef;
|
|
342
|
-
let _data, _parent = contextualDataModel, _key = '';
|
|
343
|
-
if (dataRef === null) {
|
|
344
|
-
_data = NullDataValue;
|
|
345
|
-
}
|
|
346
|
-
else if (dataRef !== undefined) {
|
|
347
|
-
if (this._tokens.length === 0) {
|
|
348
|
-
this._tokens = tokenize(dataRef);
|
|
349
|
-
}
|
|
350
|
-
let searchData = contextualDataModel;
|
|
351
|
-
if (this._tokens[0].type === TOK_GLOBAL) {
|
|
352
|
-
searchData = this.form.getDataNode();
|
|
353
|
-
}
|
|
354
|
-
if (typeof searchData !== 'undefined') {
|
|
355
|
-
const name = this._tokens[this._tokens.length - 1].value;
|
|
356
|
-
const create = this.defaultDataModel(name);
|
|
357
|
-
_data = resolveData(searchData, this._tokens, create);
|
|
358
|
-
_parent = resolveData(searchData, this._tokens.slice(0, -1));
|
|
359
|
-
_key = name;
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
else {
|
|
363
|
-
if (contextualDataModel !== NullDataValue && staticFields.indexOf(this.fieldType) === -1) {
|
|
364
|
-
_parent = contextualDataModel;
|
|
365
|
-
const name = this._jsonModel.name || '';
|
|
366
|
-
const key = contextualDataModel.$type === 'array' ? this.index : name;
|
|
367
|
-
_key = key;
|
|
368
|
-
if (key !== '') {
|
|
369
|
-
const create = this.defaultDataModel(key);
|
|
370
|
-
if (create !== undefined) {
|
|
371
|
-
_data = contextualDataModel.$getDataNode(key);
|
|
372
|
-
if (_data === undefined) {
|
|
373
|
-
_data = create;
|
|
374
|
-
contextualDataModel.$addDataNode(key, _data);
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
else {
|
|
379
|
-
_data = undefined;
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
if (_data) {
|
|
384
|
-
if (!this.isContainer && _parent !== NullDataValue && _data !== NullDataValue) {
|
|
385
|
-
_data = _data?.$convertToDataValue();
|
|
386
|
-
_parent.$addDataNode(_key, _data, true);
|
|
387
|
-
}
|
|
388
|
-
_data?.$bindToField(this);
|
|
389
|
-
this._data = _data;
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
_data;
|
|
393
|
-
getDataNode() {
|
|
394
|
-
return this._data;
|
|
395
|
-
}
|
|
396
|
-
get language() {
|
|
397
|
-
if (!this._lang) {
|
|
398
|
-
if (this.parent) {
|
|
399
|
-
this._lang = this.parent.language;
|
|
400
|
-
}
|
|
401
|
-
else {
|
|
402
|
-
this._lang = Intl.DateTimeFormat().resolvedOptions().locale;
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
return this._lang;
|
|
406
|
-
}
|
|
407
|
-
get properties() {
|
|
408
|
-
return this._jsonModel.properties || {};
|
|
409
|
-
}
|
|
410
|
-
set properties(p) {
|
|
411
|
-
this._setProperty('properties', { ...p });
|
|
412
|
-
}
|
|
413
|
-
getNonTransparentParent() {
|
|
414
|
-
let nonTransparentParent = this.parent;
|
|
415
|
-
while (nonTransparentParent != null && nonTransparentParent.isTransparent()) {
|
|
416
|
-
nonTransparentParent = nonTransparentParent.parent;
|
|
417
|
-
}
|
|
418
|
-
return nonTransparentParent;
|
|
419
|
-
}
|
|
420
|
-
_initialize() {
|
|
421
|
-
if (typeof this._data === 'undefined') {
|
|
422
|
-
let dataNode, parent = this.parent;
|
|
423
|
-
do {
|
|
424
|
-
dataNode = parent.getDataNode();
|
|
425
|
-
parent = parent.parent;
|
|
426
|
-
} while (dataNode === undefined);
|
|
427
|
-
this._bindToDataModel(dataNode);
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
_applyUpdates(propNames, updates) {
|
|
431
|
-
return propNames.reduce((acc, propertyName) => {
|
|
432
|
-
const currentValue = updates[propertyName];
|
|
433
|
-
const changes = this._setProperty(propertyName, currentValue, false);
|
|
434
|
-
if (changes.length > 0) {
|
|
435
|
-
acc[propertyName] = changes[0];
|
|
436
|
-
}
|
|
437
|
-
return acc;
|
|
438
|
-
}, {});
|
|
439
|
-
}
|
|
440
|
-
get qualifiedName() {
|
|
441
|
-
if (this.isTransparent()) {
|
|
442
|
-
return null;
|
|
443
|
-
}
|
|
444
|
-
if (this[qualifiedName] !== null) {
|
|
445
|
-
return this[qualifiedName];
|
|
446
|
-
}
|
|
447
|
-
const parent = this.getNonTransparentParent();
|
|
448
|
-
if (parent && parent.type === 'array') {
|
|
449
|
-
this[qualifiedName] = `${parent.qualifiedName}[${this.index}]`;
|
|
450
|
-
}
|
|
451
|
-
else {
|
|
452
|
-
this[qualifiedName] = `${parent.qualifiedName}.${this.name}`;
|
|
453
|
-
}
|
|
454
|
-
return this[qualifiedName];
|
|
455
|
-
}
|
|
456
|
-
focus() {
|
|
457
|
-
if (this.parent) {
|
|
458
|
-
this.parent.activeChild = this;
|
|
459
|
-
}
|
|
460
|
-
}
|
|
461
|
-
}
|
|
462
|
-
__decorate([
|
|
463
|
-
dependencyTracked()
|
|
464
|
-
], BaseNode.prototype, "index", null);
|
|
465
|
-
__decorate([
|
|
466
|
-
dependencyTracked()
|
|
467
|
-
], BaseNode.prototype, "description", null);
|
|
468
|
-
__decorate([
|
|
469
|
-
dependencyTracked()
|
|
470
|
-
], BaseNode.prototype, "visible", null);
|
|
471
|
-
__decorate([
|
|
472
|
-
dependencyTracked()
|
|
473
|
-
], BaseNode.prototype, "label", null);
|
|
474
|
-
__decorate([
|
|
475
|
-
dependencyTracked()
|
|
476
|
-
], 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 };
|