@aemforms/af-core 0.22.19 → 0.22.20
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 +8886 -0
- package/lib/{BaseNode.d.ts → esm/BaseNode.d.ts} +10 -69
- package/lib/{BaseNode.js → esm/BaseNode.js} +84 -184
- package/lib/esm/Checkbox.d.ts +79 -0
- package/lib/esm/Checkbox.js +27 -0
- package/lib/{CheckboxGroup.d.ts → esm/CheckboxGroup.d.ts} +2 -14
- package/lib/esm/CheckboxGroup.js +23 -0
- package/lib/{Container.d.ts → esm/Container.d.ts} +12 -59
- package/lib/{Container.js → esm/Container.js} +54 -116
- package/lib/{DateField.d.ts → esm/DateField.d.ts} +1 -1
- package/lib/esm/DateField.js +21 -0
- package/lib/{Field.d.ts → esm/Field.d.ts} +39 -104
- package/lib/{Field.js → esm/Field.js} +142 -208
- package/lib/esm/Fieldset.d.ts +16 -0
- package/lib/esm/Fieldset.js +45 -0
- package/lib/{FileObject.d.ts → esm/FileObject.d.ts} +1 -4
- package/lib/esm/FileObject.js +26 -0
- package/lib/{FileUpload.d.ts → esm/FileUpload.d.ts} +3 -18
- package/lib/esm/FileUpload.js +108 -0
- package/lib/{Form.d.ts → esm/Form.d.ts} +19 -85
- package/lib/esm/Form.js +176 -0
- package/lib/esm/FormInstance.d.ts +13 -0
- package/lib/esm/FormInstance.js +81 -0
- package/lib/esm/FormMetaData.d.ts +7 -0
- package/lib/esm/FormMetaData.js +10 -0
- package/lib/esm/InstanceManager.d.ts +9 -0
- package/lib/esm/InstanceManager.js +31 -0
- package/lib/esm/Node.d.ts +7 -0
- package/lib/esm/Node.js +16 -0
- package/lib/esm/Scriptable.d.ts +17 -0
- package/lib/{Scriptable.js → esm/Scriptable.js} +11 -54
- package/lib/{controller → esm/controller}/EventQueue.d.ts +3 -11
- package/lib/{controller → esm/controller}/EventQueue.js +10 -26
- package/lib/esm/controller/Events.d.ts +85 -0
- package/lib/esm/controller/Events.js +149 -0
- package/lib/{controller → esm/controller}/Logger.d.ts +0 -6
- package/lib/{controller → esm/controller}/Logger.js +5 -11
- package/lib/{data → esm/data}/DataGroup.d.ts +1 -7
- package/lib/{data → esm/data}/DataGroup.js +15 -34
- package/lib/{data → esm/data}/DataValue.d.ts +1 -7
- package/lib/esm/data/DataValue.js +46 -0
- package/lib/{data → esm/data}/EmptyDataValue.d.ts +1 -1
- package/lib/esm/data/EmptyDataValue.js +29 -0
- package/lib/esm/index.d.ts +21 -0
- package/lib/esm/index.js +21 -0
- package/lib/{rules → esm/rules}/FunctionRuntime.d.ts +2 -24
- package/lib/{rules → esm/rules}/FunctionRuntime.js +41 -117
- package/lib/esm/rules/RuleEngine.d.ts +12 -0
- package/lib/esm/rules/RuleEngine.js +47 -0
- package/lib/{types → esm/types}/Json.d.ts +3 -22
- package/lib/esm/types/Json.js +7 -0
- package/lib/esm/types/Model.d.ts +131 -0
- package/lib/esm/types/Model.js +8 -0
- package/lib/esm/types/index.d.ts +2 -0
- package/lib/esm/types/index.js +2 -0
- package/lib/{utils → esm/utils}/DataRefParser.d.ts +2 -5
- package/lib/{utils → esm/utils}/DataRefParser.js +22 -49
- package/lib/{utils → esm/utils}/Fetch.d.ts +0 -6
- package/lib/esm/utils/Fetch.js +61 -0
- package/lib/esm/utils/FormCreationUtils.d.ts +9 -0
- package/lib/esm/utils/FormCreationUtils.js +74 -0
- package/lib/esm/utils/FormUtils.d.ts +12 -0
- package/lib/esm/utils/FormUtils.js +187 -0
- package/lib/esm/utils/JsonUtils.d.ts +11 -0
- package/lib/esm/utils/JsonUtils.js +76 -0
- package/lib/{utils → esm/utils}/LogUtils.d.ts +1 -4
- package/lib/esm/utils/LogUtils.js +6 -0
- package/lib/esm/utils/SchemaUtils.d.ts +3 -0
- package/lib/esm/utils/SchemaUtils.js +71 -0
- package/lib/esm/utils/TranslationUtils.d.ts +11 -0
- package/lib/esm/utils/TranslationUtils.js +115 -0
- package/lib/esm/utils/ValidationUtils.d.ts +19 -0
- package/lib/{utils → esm/utils}/ValidationUtils.js +29 -187
- package/package.json +17 -10
- package/lib/Checkbox.d.ts +0 -88
- package/lib/Checkbox.js +0 -49
- package/lib/CheckboxGroup.js +0 -43
- package/lib/DateField.js +0 -35
- package/lib/Fieldset.d.ts +0 -24
- package/lib/Fieldset.js +0 -74
- package/lib/FileObject.js +0 -39
- package/lib/FileUpload.js +0 -155
- package/lib/Form.js +0 -252
- package/lib/FormInstance.d.ts +0 -38
- package/lib/FormInstance.js +0 -127
- package/lib/FormMetaData.d.ts +0 -11
- package/lib/FormMetaData.js +0 -28
- package/lib/InstanceManager.d.ts +0 -16
- package/lib/InstanceManager.js +0 -53
- package/lib/Node.d.ts +0 -12
- package/lib/Node.js +0 -27
- package/lib/Scriptable.d.ts +0 -31
- package/lib/controller/Controller.d.ts +0 -255
- package/lib/controller/Controller.js +0 -328
- package/lib/controller/index.d.ts +0 -1
- package/lib/controller/index.js +0 -24
- package/lib/data/DataValue.js +0 -56
- package/lib/data/EmptyDataValue.js +0 -46
- package/lib/index.d.ts +0 -28
- package/lib/index.js +0 -63
- package/lib/rules/RuleEngine.d.ts +0 -23
- package/lib/rules/RuleEngine.js +0 -62
- package/lib/types/Json.js +0 -19
- package/lib/types/Model.d.ts +0 -393
- package/lib/types/Model.js +0 -20
- package/lib/types/index.d.ts +0 -2
- package/lib/types/index.js +0 -25
- package/lib/utils/Fetch.js +0 -87
- package/lib/utils/FormCreationUtils.d.ts +0 -11
- package/lib/utils/FormCreationUtils.js +0 -83
- package/lib/utils/FormUtils.d.ts +0 -47
- package/lib/utils/FormUtils.js +0 -257
- package/lib/utils/JsonUtils.d.ts +0 -63
- package/lib/utils/JsonUtils.js +0 -157
- package/lib/utils/LogUtils.js +0 -17
- package/lib/utils/SchemaUtils.d.ts +0 -16
- package/lib/utils/SchemaUtils.js +0 -92
- package/lib/utils/TranslationUtils.d.ts +0 -41
- package/lib/utils/TranslationUtils.js +0 -185
- package/lib/utils/ValidationUtils.d.ts +0 -170
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Action, FieldsetModel } from './types/index.js';
|
|
2
|
+
import { Fieldset } from './Fieldset.js';
|
|
3
|
+
export declare class InstanceManager extends Fieldset implements FieldsetModel {
|
|
4
|
+
get maxOccur(): number;
|
|
5
|
+
set maxOccur(m: number);
|
|
6
|
+
get minOccur(): number;
|
|
7
|
+
addInstance(action: Action): void;
|
|
8
|
+
removeInstance(action: Action): void;
|
|
9
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
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;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { Fieldset } from './Fieldset.js';
|
|
8
|
+
import { dependencyTracked } from './BaseNode.js';
|
|
9
|
+
export class InstanceManager extends Fieldset {
|
|
10
|
+
get maxOccur() {
|
|
11
|
+
return this._jsonModel.maxItems;
|
|
12
|
+
}
|
|
13
|
+
set maxOccur(m) {
|
|
14
|
+
this.maxItems = m;
|
|
15
|
+
}
|
|
16
|
+
get minOccur() {
|
|
17
|
+
return this.minItems;
|
|
18
|
+
}
|
|
19
|
+
addInstance(action) {
|
|
20
|
+
return this.addItem(action);
|
|
21
|
+
}
|
|
22
|
+
removeInstance(action) {
|
|
23
|
+
return this.removeItem(action);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
__decorate([
|
|
27
|
+
dependencyTracked()
|
|
28
|
+
], InstanceManager.prototype, "maxOccur", null);
|
|
29
|
+
__decorate([
|
|
30
|
+
dependencyTracked()
|
|
31
|
+
], InstanceManager.prototype, "minOccur", null);
|
package/lib/esm/Node.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { getProperty } from './utils/JsonUtils.js';
|
|
2
|
+
class Node {
|
|
3
|
+
_jsonModel;
|
|
4
|
+
constructor(inputModel) {
|
|
5
|
+
this._jsonModel = {
|
|
6
|
+
...inputModel
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
getP(key, def) {
|
|
10
|
+
return getProperty(this._jsonModel, key, def);
|
|
11
|
+
}
|
|
12
|
+
get isContainer() {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export default Node;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Action, RulesJson, ScriptableField } from './types/index.js';
|
|
2
|
+
import { BaseNode } from './BaseNode.js';
|
|
3
|
+
declare abstract class Scriptable<T extends RulesJson> extends BaseNode<T> implements ScriptableField {
|
|
4
|
+
private _events;
|
|
5
|
+
private _rules;
|
|
6
|
+
getRules(): import("./types/Json.js").Items<string>;
|
|
7
|
+
private getCompiledRule;
|
|
8
|
+
private getCompiledEvent;
|
|
9
|
+
private applyUpdates;
|
|
10
|
+
protected executeAllRules(context: any): void;
|
|
11
|
+
private getExpressionScope;
|
|
12
|
+
private executeEvent;
|
|
13
|
+
executeRule(event: Action, context: any): void;
|
|
14
|
+
executeExpression(expr: string): any;
|
|
15
|
+
executeAction(action: Action): void;
|
|
16
|
+
}
|
|
17
|
+
export default Scriptable;
|
|
@@ -1,23 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
* Your access and use of this software is governed by the Adobe Customer Feedback Program Terms and Conditions or other Beta License Agreement signed by your employer and Adobe, Inc.. This software is NOT open source and may not be used without one of the foregoing licenses. Even with a foregoing license, your access and use of this file is limited to the earlier of (a) 180 days, (b) general availability of the product(s) which utilize this software (i.e. AEM Forms), (c) January 1, 2023, (d) Adobe providing notice to you that you may no longer use the software or that your beta trial has otherwise ended.
|
|
6
|
-
*
|
|
7
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL ADOBE NOR ITS THIRD PARTY PROVIDERS AND PARTNERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
8
|
-
*/
|
|
9
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
const BaseNode_1 = require("./BaseNode");
|
|
11
|
-
/**
|
|
12
|
-
* Defines scriptable aspects (ie rules, events) of form runtime model. Any form runtime object which requires
|
|
13
|
-
* execution of rules/events should extend from this class.
|
|
14
|
-
*/
|
|
15
|
-
class Scriptable extends BaseNode_1.BaseNode {
|
|
16
|
-
constructor() {
|
|
17
|
-
super(...arguments);
|
|
18
|
-
this._events = {};
|
|
19
|
-
this._rules = {};
|
|
20
|
-
}
|
|
1
|
+
import { BaseNode, editableProperties } from './BaseNode.js';
|
|
2
|
+
class Scriptable extends BaseNode {
|
|
3
|
+
_events = {};
|
|
4
|
+
_rules = {};
|
|
21
5
|
getRules() {
|
|
22
6
|
return typeof this._jsonModel.rules !== 'object' ? {} : this._jsonModel.rules;
|
|
23
7
|
}
|
|
@@ -39,9 +23,8 @@ class Scriptable extends BaseNode_1.BaseNode {
|
|
|
39
23
|
return this._rules[eName];
|
|
40
24
|
}
|
|
41
25
|
getCompiledEvent(eName) {
|
|
42
|
-
var _a;
|
|
43
26
|
if (!(eName in this._events)) {
|
|
44
|
-
let eString =
|
|
27
|
+
let eString = this._jsonModel.events?.[eName];
|
|
45
28
|
if (typeof eString === 'string' && eString.length > 0) {
|
|
46
29
|
eString = [eString];
|
|
47
30
|
}
|
|
@@ -61,12 +44,8 @@ class Scriptable extends BaseNode_1.BaseNode {
|
|
|
61
44
|
}
|
|
62
45
|
applyUpdates(updates) {
|
|
63
46
|
Object.entries(updates).forEach(([key, value]) => {
|
|
64
|
-
|
|
65
|
-
// the first check is to disable accessing this.value & this.items property
|
|
66
|
-
// otherwise that will trigger dependency tracking
|
|
67
|
-
if (key in BaseNode_1.editableProperties || (key in this && typeof this[key] !== 'function')) {
|
|
47
|
+
if (key in editableProperties || (key in this && typeof this[key] !== 'function')) {
|
|
68
48
|
try {
|
|
69
|
-
// @ts-ignore
|
|
70
49
|
this[key] = value;
|
|
71
50
|
}
|
|
72
51
|
catch (e) {
|
|
@@ -83,8 +62,7 @@ class Scriptable extends BaseNode_1.BaseNode {
|
|
|
83
62
|
const node = this.getCompiledRule(prop, rule);
|
|
84
63
|
if (node) {
|
|
85
64
|
const newVal = this.ruleEngine.execute(node, scope, context, true);
|
|
86
|
-
if (
|
|
87
|
-
//@ts-ignore
|
|
65
|
+
if (editableProperties.indexOf(prop) > -1) {
|
|
88
66
|
this[prop] = newVal;
|
|
89
67
|
}
|
|
90
68
|
else {
|
|
@@ -98,7 +76,7 @@ class Scriptable extends BaseNode_1.BaseNode {
|
|
|
98
76
|
const parent = this.getNonTransparentParent();
|
|
99
77
|
const target = {
|
|
100
78
|
self: this.getRuleNode(),
|
|
101
|
-
siblings:
|
|
79
|
+
siblings: parent?.ruleNodeReference() || {}
|
|
102
80
|
};
|
|
103
81
|
const scope = new Proxy(target, {
|
|
104
82
|
get: (target, prop) => {
|
|
@@ -106,20 +84,13 @@ class Scriptable extends BaseNode_1.BaseNode {
|
|
|
106
84
|
return 'Object';
|
|
107
85
|
}
|
|
108
86
|
prop = prop;
|
|
109
|
-
// The order of resolution is
|
|
110
|
-
// 1. property
|
|
111
|
-
// 2. sibling
|
|
112
|
-
// 3. child
|
|
113
87
|
if (prop.startsWith('$')) {
|
|
114
|
-
//this returns children as well, so adding an explicit check for property name
|
|
115
88
|
const retValue = target.self[prop];
|
|
116
|
-
if (retValue instanceof
|
|
117
|
-
//$parent
|
|
89
|
+
if (retValue instanceof BaseNode) {
|
|
118
90
|
return retValue.getRuleNode();
|
|
119
91
|
}
|
|
120
92
|
else if (retValue instanceof Array) {
|
|
121
|
-
|
|
122
|
-
return retValue.map(r => r instanceof BaseNode_1.BaseNode ? r.getRuleNode() : r);
|
|
93
|
+
return retValue.map(r => r instanceof BaseNode ? r.getRuleNode() : r);
|
|
123
94
|
}
|
|
124
95
|
else {
|
|
125
96
|
return retValue;
|
|
@@ -152,12 +123,6 @@ class Scriptable extends BaseNode_1.BaseNode {
|
|
|
152
123
|
this.applyUpdates(updates);
|
|
153
124
|
}
|
|
154
125
|
}
|
|
155
|
-
/**
|
|
156
|
-
* Executes the given rule
|
|
157
|
-
* @param event
|
|
158
|
-
* @param context
|
|
159
|
-
* @private
|
|
160
|
-
*/
|
|
161
126
|
executeRule(event, context) {
|
|
162
127
|
if (typeof event.payload.ruleName === 'undefined') {
|
|
163
128
|
this.executeAllRules(context);
|
|
@@ -173,10 +138,6 @@ class Scriptable extends BaseNode_1.BaseNode {
|
|
|
173
138
|
const node = this.ruleEngine.compileRule(expr);
|
|
174
139
|
return this.ruleEngine.execute(node, this.getExpressionScope(), ruleContext);
|
|
175
140
|
}
|
|
176
|
-
/**
|
|
177
|
-
* Executes the given action
|
|
178
|
-
* @param action {@link Action | event object}
|
|
179
|
-
*/
|
|
180
141
|
executeAction(action) {
|
|
181
142
|
const context = {
|
|
182
143
|
'form': this.form,
|
|
@@ -192,15 +153,11 @@ class Scriptable extends BaseNode_1.BaseNode {
|
|
|
192
153
|
const eventName = action.isCustomEvent ? `custom:${action.type}` : action.type;
|
|
193
154
|
const funcName = action.isCustomEvent ? `custom_${action.type}` : action.type;
|
|
194
155
|
const node = this.getCompiledEvent(eventName);
|
|
195
|
-
// @ts-ignore
|
|
196
156
|
if (funcName in this && typeof this[funcName] === 'function') {
|
|
197
|
-
//@ts-ignore
|
|
198
157
|
this[funcName](action, context);
|
|
199
158
|
}
|
|
200
|
-
//todo: apply all the updates at the end or
|
|
201
|
-
// not trigger the change event until the execution is finished
|
|
202
159
|
node.forEach((n) => this.executeEvent(context, n));
|
|
203
160
|
this.notifyDependents(action);
|
|
204
161
|
}
|
|
205
162
|
}
|
|
206
|
-
|
|
163
|
+
export default Scriptable;
|
|
@@ -1,14 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import { Action, BaseJson } from '../types';
|
|
5
|
-
import { BaseNode } from '../BaseNode';
|
|
6
|
-
import { Logger } from './Logger';
|
|
7
|
-
/**
|
|
8
|
-
* Implementation of event queue. When a user event, like change or click, is captured the expression to be evaluated
|
|
9
|
-
* must be put in an Event Queue and then evaluated.
|
|
10
|
-
* @private
|
|
11
|
-
*/
|
|
1
|
+
import { Action, BaseJson } from '../types/index.js';
|
|
2
|
+
import { BaseNode } from '../BaseNode.js';
|
|
3
|
+
import { Logger } from './Logger.js';
|
|
12
4
|
declare class EventQueue {
|
|
13
5
|
private logger;
|
|
14
6
|
static readonly MAX_EVENT_CYCLE_COUNT = 10;
|
|
@@ -1,18 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
/*
|
|
3
|
-
* Copyright 2022 Adobe, Inc.
|
|
4
|
-
*
|
|
5
|
-
* Your access and use of this software is governed by the Adobe Customer Feedback Program Terms and Conditions or other Beta License Agreement signed by your employer and Adobe, Inc.. This software is NOT open source and may not be used without one of the foregoing licenses. Even with a foregoing license, your access and use of this file is limited to the earlier of (a) 180 days, (b) general availability of the product(s) which utilize this software (i.e. AEM Forms), (c) January 1, 2023, (d) Adobe providing notice to you that you may no longer use the software or that your beta trial has otherwise ended.
|
|
6
|
-
*
|
|
7
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL ADOBE NOR ITS THIRD PARTY PROVIDERS AND PARTNERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
8
|
-
*/
|
|
9
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
const Logger_1 = require("./Logger");
|
|
11
|
-
/**
|
|
12
|
-
* Implementation of event node
|
|
13
|
-
* @private
|
|
14
|
-
*/
|
|
1
|
+
import { Logger } from './Logger.js';
|
|
15
2
|
class EventNode {
|
|
3
|
+
_node;
|
|
4
|
+
_event;
|
|
16
5
|
constructor(_node, _event) {
|
|
17
6
|
this._node = _node;
|
|
18
7
|
this._event = _event;
|
|
@@ -33,16 +22,14 @@ class EventNode {
|
|
|
33
22
|
return this.toString();
|
|
34
23
|
}
|
|
35
24
|
}
|
|
36
|
-
/**
|
|
37
|
-
* Implementation of event queue. When a user event, like change or click, is captured the expression to be evaluated
|
|
38
|
-
* must be put in an Event Queue and then evaluated.
|
|
39
|
-
* @private
|
|
40
|
-
*/
|
|
41
25
|
class EventQueue {
|
|
42
|
-
|
|
26
|
+
logger;
|
|
27
|
+
static MAX_EVENT_CYCLE_COUNT = 10;
|
|
28
|
+
_runningEventCount;
|
|
29
|
+
_isProcessing = false;
|
|
30
|
+
_pendingEvents = [];
|
|
31
|
+
constructor(logger = new Logger('off')) {
|
|
43
32
|
this.logger = logger;
|
|
44
|
-
this._isProcessing = false;
|
|
45
|
-
this._pendingEvents = [];
|
|
46
33
|
this._runningEventCount = {};
|
|
47
34
|
}
|
|
48
35
|
get length() {
|
|
@@ -67,7 +54,6 @@ class EventQueue {
|
|
|
67
54
|
const counter = this._runningEventCount[evntNode.valueOf()] || 0;
|
|
68
55
|
if (counter < EventQueue.MAX_EVENT_CYCLE_COUNT) {
|
|
69
56
|
this.logger.info(`Queued event : ${e.type} node: ${node.id} - ${node.name}`);
|
|
70
|
-
//console.log(`Event Details ${e.toString()}`)
|
|
71
57
|
if (priority) {
|
|
72
58
|
const index = this._isProcessing ? 1 : 0;
|
|
73
59
|
this._pendingEvents.splice(index, 0, evntNode);
|
|
@@ -90,7 +76,6 @@ class EventQueue {
|
|
|
90
76
|
while (this._pendingEvents.length > 0) {
|
|
91
77
|
const e = this._pendingEvents[0];
|
|
92
78
|
this.logger.info(`Dequeued event : ${e.event.type} node: ${e.node.id} - ${e.node.name}`);
|
|
93
|
-
//console.log(`Event Details ${e.event.toString()}`);
|
|
94
79
|
e.node.executeAction(e.event);
|
|
95
80
|
this._pendingEvents.shift();
|
|
96
81
|
}
|
|
@@ -98,5 +83,4 @@ class EventQueue {
|
|
|
98
83
|
this._isProcessing = false;
|
|
99
84
|
}
|
|
100
85
|
}
|
|
101
|
-
|
|
102
|
-
exports.default = EventQueue;
|
|
86
|
+
export default EventQueue;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { Action, BaseJson, FieldModel, FieldsetModel, FormModel, ValidationError } from '../types/index.js';
|
|
2
|
+
declare class ActionImpl implements Action {
|
|
3
|
+
private _metadata?;
|
|
4
|
+
protected _type: string;
|
|
5
|
+
private _payload?;
|
|
6
|
+
private _target;
|
|
7
|
+
constructor(payload: any, type: string, _metadata?: any);
|
|
8
|
+
get type(): string;
|
|
9
|
+
get payload(): any;
|
|
10
|
+
get metadata(): any;
|
|
11
|
+
get target(): FormModel | FieldModel | FieldsetModel;
|
|
12
|
+
get isCustomEvent(): boolean;
|
|
13
|
+
protected payloadToJson(): any;
|
|
14
|
+
toJson(): {
|
|
15
|
+
payload: any;
|
|
16
|
+
type: string;
|
|
17
|
+
isCustomEvent: boolean;
|
|
18
|
+
};
|
|
19
|
+
toString(): string;
|
|
20
|
+
}
|
|
21
|
+
export declare type ChangePayload = {
|
|
22
|
+
changes: Array<{
|
|
23
|
+
propertyName: string;
|
|
24
|
+
prevValue?: any;
|
|
25
|
+
currentValue: any;
|
|
26
|
+
}>;
|
|
27
|
+
};
|
|
28
|
+
export declare class Change extends ActionImpl {
|
|
29
|
+
constructor(payload: ChangePayload, dispatch?: boolean);
|
|
30
|
+
withAdditionalChange(change: Change): Change;
|
|
31
|
+
}
|
|
32
|
+
export declare class Invalid extends ActionImpl {
|
|
33
|
+
constructor(payload?: any);
|
|
34
|
+
}
|
|
35
|
+
export declare class Valid extends ActionImpl {
|
|
36
|
+
constructor(payload?: any);
|
|
37
|
+
}
|
|
38
|
+
export declare class ExecuteRule extends ActionImpl {
|
|
39
|
+
constructor(payload?: any, dispatch?: boolean);
|
|
40
|
+
}
|
|
41
|
+
export declare const propertyChange: (propertyName: string, currentValue: any, prevValue?: any) => Change;
|
|
42
|
+
export declare class Initialize extends ActionImpl {
|
|
43
|
+
constructor(payload?: any, dispatch?: boolean);
|
|
44
|
+
}
|
|
45
|
+
export declare class FormLoad extends ActionImpl {
|
|
46
|
+
constructor();
|
|
47
|
+
}
|
|
48
|
+
export declare class Click extends ActionImpl {
|
|
49
|
+
constructor(payload?: any, dispatch?: boolean);
|
|
50
|
+
}
|
|
51
|
+
export declare class Blur extends ActionImpl {
|
|
52
|
+
constructor(payload?: any, dispatch?: boolean);
|
|
53
|
+
}
|
|
54
|
+
export declare class ValidationComplete extends ActionImpl {
|
|
55
|
+
constructor(payload?: Array<ValidationError>, dispatch?: boolean);
|
|
56
|
+
}
|
|
57
|
+
export declare class Focus extends ActionImpl {
|
|
58
|
+
constructor();
|
|
59
|
+
}
|
|
60
|
+
export declare class Submit extends ActionImpl {
|
|
61
|
+
constructor(payload?: any, dispatch?: boolean);
|
|
62
|
+
}
|
|
63
|
+
export declare class Reset extends ActionImpl {
|
|
64
|
+
constructor(payload?: any, dispatch?: boolean);
|
|
65
|
+
}
|
|
66
|
+
export declare class FieldChanged extends ActionImpl {
|
|
67
|
+
constructor(changes: ChangePayload, field: BaseJson);
|
|
68
|
+
}
|
|
69
|
+
export declare class CustomEvent extends ActionImpl {
|
|
70
|
+
constructor(eventName: string, payload?: any, dispatch?: boolean);
|
|
71
|
+
get isCustomEvent(): boolean;
|
|
72
|
+
}
|
|
73
|
+
export declare class AddItem extends ActionImpl {
|
|
74
|
+
constructor(payload?: number);
|
|
75
|
+
}
|
|
76
|
+
export declare class RemoveItem extends ActionImpl {
|
|
77
|
+
constructor(payload?: number);
|
|
78
|
+
}
|
|
79
|
+
export declare class AddInstance extends ActionImpl {
|
|
80
|
+
constructor(payload?: number);
|
|
81
|
+
}
|
|
82
|
+
export declare class RemoveInstance extends ActionImpl {
|
|
83
|
+
constructor(payload?: number);
|
|
84
|
+
}
|
|
85
|
+
export {};
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
class ActionImpl {
|
|
2
|
+
_metadata;
|
|
3
|
+
_type;
|
|
4
|
+
_payload;
|
|
5
|
+
_target;
|
|
6
|
+
constructor(payload, type, _metadata) {
|
|
7
|
+
this._metadata = _metadata;
|
|
8
|
+
this._payload = payload;
|
|
9
|
+
this._type = type;
|
|
10
|
+
}
|
|
11
|
+
get type() {
|
|
12
|
+
return this._type;
|
|
13
|
+
}
|
|
14
|
+
get payload() {
|
|
15
|
+
return this._payload;
|
|
16
|
+
}
|
|
17
|
+
get metadata() {
|
|
18
|
+
return this._metadata;
|
|
19
|
+
}
|
|
20
|
+
get target() {
|
|
21
|
+
return this._target;
|
|
22
|
+
}
|
|
23
|
+
get isCustomEvent() {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
payloadToJson() {
|
|
27
|
+
return this.payload;
|
|
28
|
+
}
|
|
29
|
+
toJson() {
|
|
30
|
+
return {
|
|
31
|
+
payload: this.payloadToJson(),
|
|
32
|
+
type: this.type,
|
|
33
|
+
isCustomEvent: this.isCustomEvent
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
toString() {
|
|
37
|
+
return JSON.stringify(this.toJson());
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
export class Change extends ActionImpl {
|
|
41
|
+
constructor(payload, dispatch = false) {
|
|
42
|
+
super(payload, 'change', { dispatch });
|
|
43
|
+
}
|
|
44
|
+
withAdditionalChange(change) {
|
|
45
|
+
return new Change(this.payload.changes.concat(change.payload.changes), this.metadata);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
export class Invalid extends ActionImpl {
|
|
49
|
+
constructor(payload = {}) {
|
|
50
|
+
super(payload, 'invalid', {});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
export class Valid extends ActionImpl {
|
|
54
|
+
constructor(payload = {}) {
|
|
55
|
+
super(payload, 'valid', {});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
export class ExecuteRule extends ActionImpl {
|
|
59
|
+
constructor(payload = {}, dispatch = false) {
|
|
60
|
+
super(payload, 'executeRule', { dispatch });
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
export const propertyChange = (propertyName, currentValue, prevValue) => {
|
|
64
|
+
return new Change({
|
|
65
|
+
changes: [
|
|
66
|
+
{
|
|
67
|
+
propertyName,
|
|
68
|
+
currentValue,
|
|
69
|
+
prevValue
|
|
70
|
+
}
|
|
71
|
+
]
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
export class Initialize extends ActionImpl {
|
|
75
|
+
constructor(payload, dispatch = false) {
|
|
76
|
+
super(payload, 'initialize', { dispatch });
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
export class FormLoad extends ActionImpl {
|
|
80
|
+
constructor() {
|
|
81
|
+
super({}, 'load', { dispatch: false });
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
export class Click extends ActionImpl {
|
|
85
|
+
constructor(payload, dispatch = false) {
|
|
86
|
+
super(payload, 'click', { dispatch });
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
export class Blur extends ActionImpl {
|
|
90
|
+
constructor(payload, dispatch = false) {
|
|
91
|
+
super(payload, 'blur', { dispatch });
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
export class ValidationComplete extends ActionImpl {
|
|
95
|
+
constructor(payload, dispatch = false) {
|
|
96
|
+
super(payload, 'validationComplete', { dispatch });
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
export class Focus extends ActionImpl {
|
|
100
|
+
constructor() {
|
|
101
|
+
super({}, 'focus', { dispatch: false });
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
export class Submit extends ActionImpl {
|
|
105
|
+
constructor(payload, dispatch = false) {
|
|
106
|
+
super(payload, 'submit', { dispatch });
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
export class Reset extends ActionImpl {
|
|
110
|
+
constructor(payload, dispatch = false) {
|
|
111
|
+
super(payload, 'reset', { dispatch });
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
export class FieldChanged extends ActionImpl {
|
|
115
|
+
constructor(changes, field) {
|
|
116
|
+
super({
|
|
117
|
+
field,
|
|
118
|
+
changes
|
|
119
|
+
}, 'fieldChanged');
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
export class CustomEvent extends ActionImpl {
|
|
123
|
+
constructor(eventName, payload = {}, dispatch = false) {
|
|
124
|
+
super(payload, eventName, { dispatch });
|
|
125
|
+
}
|
|
126
|
+
get isCustomEvent() {
|
|
127
|
+
return true;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
export class AddItem extends ActionImpl {
|
|
131
|
+
constructor(payload) {
|
|
132
|
+
super(payload, 'addItem');
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
export class RemoveItem extends ActionImpl {
|
|
136
|
+
constructor(payload) {
|
|
137
|
+
super(payload, 'removeItem');
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
export class AddInstance extends ActionImpl {
|
|
141
|
+
constructor(payload) {
|
|
142
|
+
super(payload, 'addInstance');
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
export class RemoveInstance extends ActionImpl {
|
|
146
|
+
constructor(payload) {
|
|
147
|
+
super(payload, 'removeInstance');
|
|
148
|
+
}
|
|
149
|
+
}
|
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
export declare type LogFunction = 'info' | 'warn' | 'error' | 'debug';
|
|
2
|
-
/**
|
|
3
|
-
* Logging levels.
|
|
4
|
-
*/
|
|
5
2
|
export declare type LogLevel = 'off' | LogFunction;
|
|
6
|
-
/**
|
|
7
|
-
* @private
|
|
8
|
-
*/
|
|
9
3
|
export declare class Logger {
|
|
10
4
|
debug(msg: string): void;
|
|
11
5
|
info(msg: string): void;
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Logger = void 0;
|
|
4
1
|
const levels = {
|
|
5
2
|
off: 0,
|
|
6
3
|
debug: 1,
|
|
@@ -8,13 +5,7 @@ const levels = {
|
|
|
8
5
|
warn: 3,
|
|
9
6
|
error: 4
|
|
10
7
|
};
|
|
11
|
-
|
|
12
|
-
* @private
|
|
13
|
-
*/
|
|
14
|
-
class Logger {
|
|
15
|
-
constructor(logLevel = 'off') {
|
|
16
|
-
this.logLevel = levels[logLevel];
|
|
17
|
-
}
|
|
8
|
+
export class Logger {
|
|
18
9
|
debug(msg) {
|
|
19
10
|
this.log(msg, 'debug');
|
|
20
11
|
}
|
|
@@ -32,5 +23,8 @@ class Logger {
|
|
|
32
23
|
console[level](msg);
|
|
33
24
|
}
|
|
34
25
|
}
|
|
26
|
+
logLevel;
|
|
27
|
+
constructor(logLevel = 'off') {
|
|
28
|
+
this.logLevel = levels[logLevel];
|
|
29
|
+
}
|
|
35
30
|
}
|
|
36
|
-
exports.Logger = Logger;
|
|
@@ -1,24 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
* Defines data group
|
|
15
|
-
*/
|
|
16
|
-
const DataValue_1 = __importDefault(require("./DataValue"));
|
|
17
|
-
const EmptyDataValue_1 = __importDefault(require("./EmptyDataValue"));
|
|
18
|
-
/**
|
|
19
|
-
* @private
|
|
20
|
-
*/
|
|
21
|
-
class DataGroup extends DataValue_1.default {
|
|
1
|
+
import DataValue from './DataValue.js';
|
|
2
|
+
import NullDataValue from './EmptyDataValue.js';
|
|
3
|
+
export default class DataGroup extends DataValue {
|
|
4
|
+
$_items;
|
|
5
|
+
createEntry(key, value) {
|
|
6
|
+
const t = value instanceof Array ? 'array' : typeof value;
|
|
7
|
+
if (typeof value === 'object' && value != null) {
|
|
8
|
+
return new DataGroup(key, value, t);
|
|
9
|
+
}
|
|
10
|
+
else {
|
|
11
|
+
return new DataValue(key, value, t);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
22
14
|
constructor(_name, _value, _type = typeof _value) {
|
|
23
15
|
super(_name, _value, _type);
|
|
24
16
|
if (_value instanceof Array) {
|
|
@@ -32,15 +24,6 @@ class DataGroup extends DataValue_1.default {
|
|
|
32
24
|
}));
|
|
33
25
|
}
|
|
34
26
|
}
|
|
35
|
-
createEntry(key, value) {
|
|
36
|
-
const t = value instanceof Array ? 'array' : typeof value;
|
|
37
|
-
if (typeof value === 'object' && value != null) {
|
|
38
|
-
return new DataGroup(key, value, t);
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
return new DataValue_1.default(key, value, t);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
27
|
get $value() {
|
|
45
28
|
const enabled = this.$_fields.find(x => x.enabled !== false);
|
|
46
29
|
if (!enabled && this.$_fields.length) {
|
|
@@ -59,10 +42,10 @@ class DataGroup extends DataValue_1.default {
|
|
|
59
42
|
return Object.entries(this.$_items).length;
|
|
60
43
|
}
|
|
61
44
|
$convertToDataValue() {
|
|
62
|
-
return new
|
|
45
|
+
return new DataValue(this.$name, this.$value, this.$type);
|
|
63
46
|
}
|
|
64
47
|
$addDataNode(name, value, override = false) {
|
|
65
|
-
if (value !==
|
|
48
|
+
if (value !== NullDataValue) {
|
|
66
49
|
if (this.$type === 'array') {
|
|
67
50
|
const index = name;
|
|
68
51
|
if (!override) {
|
|
@@ -78,7 +61,6 @@ class DataGroup extends DataValue_1.default {
|
|
|
78
61
|
}
|
|
79
62
|
}
|
|
80
63
|
$removeDataNode(name) {
|
|
81
|
-
//@ts-ignore not calling delete
|
|
82
64
|
this.$_items[name] = undefined;
|
|
83
65
|
}
|
|
84
66
|
$getDataNode(name) {
|
|
@@ -93,4 +75,3 @@ class DataGroup extends DataValue_1.default {
|
|
|
93
75
|
return true;
|
|
94
76
|
}
|
|
95
77
|
}
|
|
96
|
-
exports.default = DataGroup;
|