@aemforms/af-core 0.22.25 → 0.22.29
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/cjs/index.cjs +7345 -0
- package/lib/esm/BaseNode-d78cc1b0.js +478 -0
- package/lib/esm/BaseNode.d.ts +93 -0
- package/lib/esm/BaseNode.js +26 -0
- package/lib/esm/Checkbox.d.ts +79 -0
- package/lib/esm/Checkbox.js +63 -0
- package/lib/esm/CheckboxGroup.d.ts +18 -0
- package/lib/esm/CheckboxGroup.js +60 -0
- package/lib/esm/Container.d.ts +58 -0
- package/lib/esm/Container.js +379 -0
- package/lib/esm/DateField.d.ts +5 -0
- package/lib/esm/DateField.js +57 -0
- package/lib/esm/Field.d.ts +206 -0
- package/lib/esm/Field.js +692 -0
- package/lib/esm/Fieldset.d.ts +16 -0
- package/lib/esm/Fieldset.js +78 -0
- package/lib/esm/FileObject.d.ts +16 -0
- package/lib/esm/FileObject.js +48 -0
- package/lib/esm/FileUpload.d.ts +22 -0
- package/lib/esm/FileUpload.js +141 -0
- package/lib/esm/Form.d.ts +113 -0
- package/lib/esm/Form.js +208 -0
- package/lib/esm/FormInstance.d.ts +13 -0
- package/lib/esm/FormInstance.js +129 -0
- package/lib/esm/FormMetaData.d.ts +7 -0
- package/lib/esm/FormMetaData.js +35 -0
- package/lib/esm/InstanceManager.d.ts +9 -0
- package/lib/esm/InstanceManager.js +58 -0
- package/lib/esm/Node.d.ts +7 -0
- package/lib/esm/Node.js +40 -0
- package/lib/esm/Scriptable.d.ts +17 -0
- package/lib/esm/Scriptable.js +190 -0
- package/lib/esm/controller/EventQueue.d.ts +17 -0
- package/lib/esm/controller/EventQueue.js +108 -0
- package/lib/esm/controller/Events.d.ts +85 -0
- package/lib/esm/controller/Events.js +171 -0
- package/lib/esm/controller/Logger.d.ts +11 -0
- package/lib/esm/controller/Logger.js +52 -0
- package/lib/esm/data/DataGroup.d.ts +20 -0
- package/lib/esm/data/DataGroup.js +100 -0
- package/lib/esm/data/DataValue.d.ts +16 -0
- package/lib/esm/data/DataValue.js +68 -0
- package/lib/esm/data/EmptyDataValue.d.ts +14 -0
- package/lib/esm/data/EmptyDataValue.js +51 -0
- package/lib/esm/index.d.ts +21 -0
- package/lib/esm/index.js +55 -0
- package/lib/esm/rules/FunctionRuntime.d.ts +51 -0
- package/lib/esm/rules/FunctionRuntime.js +345 -0
- package/lib/esm/rules/RuleEngine.d.ts +12 -0
- package/lib/esm/rules/RuleEngine.js +76 -0
- package/lib/esm/types/Json.d.ts +119 -0
- package/lib/esm/types/Json.js +29 -0
- package/lib/esm/types/Model.d.ts +131 -0
- package/lib/esm/types/Model.js +30 -0
- package/lib/esm/types/index.d.ts +2 -0
- package/lib/esm/types/index.js +22 -0
- package/lib/esm/utils/DataRefParser.d.ts +27 -0
- package/lib/esm/utils/DataRefParser.js +247 -0
- package/lib/esm/utils/Fetch.d.ts +8 -0
- package/lib/esm/utils/Fetch.js +83 -0
- package/lib/esm/utils/FormCreationUtils.d.ts +9 -0
- package/lib/esm/utils/FormCreationUtils.js +112 -0
- package/lib/esm/utils/FormUtils.d.ts +12 -0
- package/lib/esm/utils/FormUtils.js +212 -0
- package/lib/esm/utils/JsonUtils.d.ts +11 -0
- package/lib/esm/utils/JsonUtils.js +99 -0
- package/lib/esm/utils/LogUtils.d.ts +4 -0
- package/lib/esm/utils/LogUtils.js +28 -0
- package/lib/esm/utils/SchemaUtils.d.ts +3 -0
- package/lib/esm/utils/SchemaUtils.js +93 -0
- package/lib/esm/utils/TranslationUtils.d.ts +11 -0
- package/lib/esm/utils/TranslationUtils.js +138 -0
- package/lib/esm/utils/ValidationUtils.d.ts +19 -0
- package/lib/esm/utils/ValidationUtils.js +300 -0
- package/package.json +14 -2
|
@@ -0,0 +1,478 @@
|
|
|
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(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
|
+
};
|
|
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 };
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { Action, BaseJson, BaseModel, callbackFn, ContainerModel, FormModel, Primitives, ValidationError } from './types/index.js';
|
|
2
|
+
import DataGroup from './data/DataGroup.js';
|
|
3
|
+
import DataValue from './data/DataValue.js';
|
|
4
|
+
export declare const editableProperties: string[];
|
|
5
|
+
export declare const dynamicProps: string[];
|
|
6
|
+
export declare const staticFields: string[];
|
|
7
|
+
export declare const target: unique symbol;
|
|
8
|
+
export declare const qualifiedName: unique symbol;
|
|
9
|
+
export declare function dependencyTracked(): (target: BaseNode<any>, propertyKey: string, descriptor: PropertyDescriptor) => void;
|
|
10
|
+
export declare const include: (...fieldTypes: string[]) => (target: BaseNode<any>, propertyKey: string, descriptor: PropertyDescriptor) => void;
|
|
11
|
+
export declare const exclude: (...fieldTypes: string[]) => (target: BaseNode<any>, propertyKey: string, descriptor: PropertyDescriptor) => void;
|
|
12
|
+
export declare abstract class BaseNode<T extends BaseJson> implements BaseModel {
|
|
13
|
+
private _options;
|
|
14
|
+
private _ruleNode;
|
|
15
|
+
private _lang?;
|
|
16
|
+
private _callbacks;
|
|
17
|
+
private _dependents;
|
|
18
|
+
protected _jsonModel: T & {
|
|
19
|
+
id: string;
|
|
20
|
+
};
|
|
21
|
+
private _tokens;
|
|
22
|
+
get isContainer(): boolean;
|
|
23
|
+
constructor(params: T, _options: {
|
|
24
|
+
form: FormModel;
|
|
25
|
+
parent: ContainerModel;
|
|
26
|
+
});
|
|
27
|
+
abstract value: Primitives;
|
|
28
|
+
abstract reset(): any;
|
|
29
|
+
protected setupRuleNode(): void;
|
|
30
|
+
ruleNodeReference(): this;
|
|
31
|
+
getRuleNode(): any;
|
|
32
|
+
private getFromRule;
|
|
33
|
+
get id(): string;
|
|
34
|
+
get index(): number;
|
|
35
|
+
get parent(): ContainerModel;
|
|
36
|
+
get type(): string | undefined;
|
|
37
|
+
get repeatable(): any;
|
|
38
|
+
get fieldType(): string;
|
|
39
|
+
get ':type'(): string;
|
|
40
|
+
get name(): string | undefined;
|
|
41
|
+
get description(): string | undefined;
|
|
42
|
+
set description(d: string | undefined);
|
|
43
|
+
get dataRef(): string | null | undefined;
|
|
44
|
+
get visible(): boolean | undefined;
|
|
45
|
+
set visible(v: boolean | undefined);
|
|
46
|
+
get form(): FormModel;
|
|
47
|
+
get ruleEngine(): import("./rules/RuleEngine.js").default;
|
|
48
|
+
get label(): import("./types/Json.js").Label | undefined;
|
|
49
|
+
set label(l: import("./types/Json.js").Label | undefined);
|
|
50
|
+
get uniqueItems(): boolean | undefined;
|
|
51
|
+
isTransparent(): boolean;
|
|
52
|
+
getState(isRepeatableChild?: boolean): T & {
|
|
53
|
+
properties: {
|
|
54
|
+
[key: string]: any;
|
|
55
|
+
};
|
|
56
|
+
index: number;
|
|
57
|
+
parent: undefined;
|
|
58
|
+
qualifiedName: any;
|
|
59
|
+
events: {};
|
|
60
|
+
rules: {};
|
|
61
|
+
repeatable: boolean | undefined;
|
|
62
|
+
':type': string;
|
|
63
|
+
id: string;
|
|
64
|
+
};
|
|
65
|
+
subscribe(callback: callbackFn, eventName?: string): {
|
|
66
|
+
unsubscribe: () => void;
|
|
67
|
+
};
|
|
68
|
+
_addDependent(dependent: BaseModel): void;
|
|
69
|
+
removeDependent(dependent: BaseModel): void;
|
|
70
|
+
abstract validate(): Array<ValidationError>;
|
|
71
|
+
abstract executeAction(action: Action): any;
|
|
72
|
+
queueEvent(action: Action): void;
|
|
73
|
+
dispatch(action: Action): void;
|
|
74
|
+
notifyDependents(action: Action): void;
|
|
75
|
+
_setProperty<T>(prop: string, newValue: T, notify?: boolean): any;
|
|
76
|
+
_bindToDataModel(contextualDataModel: DataGroup): void;
|
|
77
|
+
private _data?;
|
|
78
|
+
getDataNode(): DataValue | undefined;
|
|
79
|
+
get language(): string | undefined;
|
|
80
|
+
get properties(): {
|
|
81
|
+
[key: string]: any;
|
|
82
|
+
};
|
|
83
|
+
set properties(p: {
|
|
84
|
+
[key: string]: any;
|
|
85
|
+
});
|
|
86
|
+
abstract defaultDataModel(name: string | number): DataValue | undefined;
|
|
87
|
+
abstract importData(a: DataGroup): any;
|
|
88
|
+
getNonTransparentParent(): ContainerModel;
|
|
89
|
+
_initialize(): void;
|
|
90
|
+
protected _applyUpdates(propNames: string[], updates: any): any;
|
|
91
|
+
get qualifiedName(): any;
|
|
92
|
+
focus(): void;
|
|
93
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
export { B as BaseNode, d as dependencyTracked, b as dynamicProps, a as editableProperties, e as exclude, i as include, q as qualifiedName, s as staticFields, t as target } from './BaseNode-d78cc1b0.js';
|
|
22
|
+
import './controller/Events.js';
|
|
23
|
+
import './utils/DataRefParser.js';
|
|
24
|
+
import './data/EmptyDataValue.js';
|
|
25
|
+
import './data/DataGroup.js';
|
|
26
|
+
import './data/DataValue.js';
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import Field from './Field.js';
|
|
2
|
+
declare class Checkbox extends Field {
|
|
3
|
+
private offValue;
|
|
4
|
+
_getConstraintObject(): {
|
|
5
|
+
enum: (constraint: any, inputVal: any) => {
|
|
6
|
+
valid: boolean;
|
|
7
|
+
value: any;
|
|
8
|
+
};
|
|
9
|
+
accept: (constraint: any, inputVal: any) => {
|
|
10
|
+
valid: boolean;
|
|
11
|
+
value: any;
|
|
12
|
+
};
|
|
13
|
+
exclusiveMinimum: (constraint: any, inputVal: any) => {
|
|
14
|
+
valid: boolean;
|
|
15
|
+
value: any;
|
|
16
|
+
};
|
|
17
|
+
exclusiveMaximum: (constraint: any, inputVal: any) => {
|
|
18
|
+
valid: boolean;
|
|
19
|
+
value: any;
|
|
20
|
+
};
|
|
21
|
+
format: (constraint: any, inputVal: any) => {
|
|
22
|
+
valid: boolean;
|
|
23
|
+
value: any;
|
|
24
|
+
};
|
|
25
|
+
maxFileSize: (constraint: any, inputVal: any) => {
|
|
26
|
+
valid: boolean;
|
|
27
|
+
value: any;
|
|
28
|
+
};
|
|
29
|
+
maxLength: (constraint: any, inputVal: any) => {
|
|
30
|
+
valid: boolean;
|
|
31
|
+
value: any;
|
|
32
|
+
};
|
|
33
|
+
maximum: (constraint: any, inputVal: any) => {
|
|
34
|
+
valid: boolean;
|
|
35
|
+
value: any;
|
|
36
|
+
};
|
|
37
|
+
maxItems: (constraint: any, inputVal: any) => {
|
|
38
|
+
valid: boolean;
|
|
39
|
+
value: any;
|
|
40
|
+
};
|
|
41
|
+
minLength: (constraint: any, inputVal: any) => {
|
|
42
|
+
valid: boolean;
|
|
43
|
+
value: any;
|
|
44
|
+
};
|
|
45
|
+
minimum: (constraint: any, inputVal: any) => {
|
|
46
|
+
valid: boolean;
|
|
47
|
+
value: any;
|
|
48
|
+
};
|
|
49
|
+
minItems: (constraint: any, inputVal: any) => {
|
|
50
|
+
valid: boolean;
|
|
51
|
+
value: any;
|
|
52
|
+
};
|
|
53
|
+
pattern: (constraint: any, inputVal: any) => {
|
|
54
|
+
valid: boolean;
|
|
55
|
+
value: any;
|
|
56
|
+
};
|
|
57
|
+
required: (constraint: any, inputVal: any) => {
|
|
58
|
+
valid: boolean;
|
|
59
|
+
value: any;
|
|
60
|
+
};
|
|
61
|
+
type: (constraint: any, inputVal: any) => {
|
|
62
|
+
valid: boolean;
|
|
63
|
+
value: any;
|
|
64
|
+
};
|
|
65
|
+
uniqueItems: (constraint: any, inputVal: any) => {
|
|
66
|
+
valid: boolean;
|
|
67
|
+
value: any;
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
protected _getDefaults(): {
|
|
71
|
+
enforceEnum: boolean;
|
|
72
|
+
readOnly: boolean;
|
|
73
|
+
enabled: boolean;
|
|
74
|
+
visible: boolean;
|
|
75
|
+
type: string | undefined;
|
|
76
|
+
};
|
|
77
|
+
get enum(): any[];
|
|
78
|
+
}
|
|
79
|
+
export default Checkbox;
|