@aemforms/af-core 0.15.0

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.
Files changed (69) hide show
  1. package/LICENSE +5 -0
  2. package/README.md +34 -0
  3. package/lib/BaseNode.d.ts +117 -0
  4. package/lib/BaseNode.js +368 -0
  5. package/lib/Checkbox.d.ts +80 -0
  6. package/lib/Checkbox.js +49 -0
  7. package/lib/CheckboxGroup.d.ts +30 -0
  8. package/lib/CheckboxGroup.js +40 -0
  9. package/lib/Container.d.ts +336 -0
  10. package/lib/Container.js +279 -0
  11. package/lib/Field.d.ts +185 -0
  12. package/lib/Field.js +432 -0
  13. package/lib/Fieldset.d.ts +31 -0
  14. package/lib/Fieldset.js +97 -0
  15. package/lib/FileObject.d.ts +17 -0
  16. package/lib/FileObject.js +30 -0
  17. package/lib/FileUpload.d.ts +42 -0
  18. package/lib/FileUpload.js +299 -0
  19. package/lib/Form.d.ts +413 -0
  20. package/lib/Form.js +247 -0
  21. package/lib/FormInstance.d.ts +26 -0
  22. package/lib/FormInstance.js +116 -0
  23. package/lib/FormMetaData.d.ts +11 -0
  24. package/lib/FormMetaData.js +28 -0
  25. package/lib/Node.d.ts +12 -0
  26. package/lib/Node.js +27 -0
  27. package/lib/Scriptable.d.ts +27 -0
  28. package/lib/Scriptable.js +216 -0
  29. package/lib/controller/Controller.d.ts +207 -0
  30. package/lib/controller/Controller.js +263 -0
  31. package/lib/controller/EventQueue.d.ts +24 -0
  32. package/lib/controller/EventQueue.js +99 -0
  33. package/lib/controller/index.d.ts +1 -0
  34. package/lib/controller/index.js +24 -0
  35. package/lib/data/DataGroup.d.ts +25 -0
  36. package/lib/data/DataGroup.js +74 -0
  37. package/lib/data/DataValue.d.ts +22 -0
  38. package/lib/data/DataValue.js +50 -0
  39. package/lib/data/EmptyDataValue.d.ts +14 -0
  40. package/lib/data/EmptyDataValue.js +46 -0
  41. package/lib/index.d.ts +27 -0
  42. package/lib/index.js +59 -0
  43. package/lib/rules/FunctionRuntime.d.ts +44 -0
  44. package/lib/rules/FunctionRuntime.js +271 -0
  45. package/lib/rules/RuleEngine.d.ts +23 -0
  46. package/lib/rules/RuleEngine.js +67 -0
  47. package/lib/types/Json.d.ts +126 -0
  48. package/lib/types/Json.js +16 -0
  49. package/lib/types/Model.d.ts +352 -0
  50. package/lib/types/Model.js +20 -0
  51. package/lib/types/index.d.ts +2 -0
  52. package/lib/types/index.js +25 -0
  53. package/lib/utils/DataRefParser.d.ts +30 -0
  54. package/lib/utils/DataRefParser.js +249 -0
  55. package/lib/utils/Fetch.d.ts +7 -0
  56. package/lib/utils/Fetch.js +29 -0
  57. package/lib/utils/FormUtils.d.ts +47 -0
  58. package/lib/utils/FormUtils.js +172 -0
  59. package/lib/utils/JsonUtils.d.ts +55 -0
  60. package/lib/utils/JsonUtils.js +128 -0
  61. package/lib/utils/LogUtils.d.ts +7 -0
  62. package/lib/utils/LogUtils.js +17 -0
  63. package/lib/utils/SchemaUtils.d.ts +16 -0
  64. package/lib/utils/SchemaUtils.js +92 -0
  65. package/lib/utils/TranslationUtils.d.ts +34 -0
  66. package/lib/utils/TranslationUtils.js +156 -0
  67. package/lib/utils/ValidationUtils.d.ts +153 -0
  68. package/lib/utils/ValidationUtils.js +339 -0
  69. package/package.json +60 -0
@@ -0,0 +1,263 @@
1
+ "use strict";
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
+ exports.RemoveItem = exports.AddItem = exports.CustomEvent = exports.FieldChanged = exports.Submit = exports.ValidationComplete = exports.Blur = exports.Click = exports.Initialize = exports.propertyChange = exports.ExecuteRule = exports.Valid = exports.Invalid = exports.Change = exports.ActionImpl = void 0;
11
+ /**
12
+ * Implementation of generic event
13
+ * @private
14
+ */
15
+ class ActionImpl {
16
+ constructor(payload, type, _metadata) {
17
+ this._metadata = _metadata;
18
+ this._payload = payload;
19
+ this._type = type;
20
+ }
21
+ get type() {
22
+ return this._type;
23
+ }
24
+ get payload() {
25
+ return this._payload;
26
+ }
27
+ get metadata() {
28
+ return this._metadata;
29
+ }
30
+ get target() {
31
+ return this._target;
32
+ }
33
+ get isCustomEvent() {
34
+ return false;
35
+ }
36
+ payloadToJson() {
37
+ return this.payload;
38
+ }
39
+ toJson() {
40
+ return {
41
+ payload: this.payloadToJson(),
42
+ type: this.type,
43
+ isCustomEvent: this.isCustomEvent
44
+ };
45
+ }
46
+ toString() {
47
+ return JSON.stringify(this.toJson());
48
+ }
49
+ }
50
+ exports.ActionImpl = ActionImpl;
51
+ /**
52
+ * Implementation of `change` event. The change event is triggered on the field whenever the value of the field is changed
53
+ */
54
+ class Change extends ActionImpl {
55
+ /**
56
+ * @constructor
57
+ * @param [payload] event payload
58
+ * @param [dispatch] true to trigger the event on all the fields in DFS order starting from the top level form element, false otherwise
59
+ */
60
+ constructor(payload, dispatch = false) {
61
+ super(payload, 'change', { dispatch });
62
+ }
63
+ }
64
+ exports.Change = Change;
65
+ /**
66
+ * Implementation of `invalid` event. The invalid event is triggered when a Field’s value becomes invalid after a change event or whenever its value property change
67
+ */
68
+ class Invalid extends ActionImpl {
69
+ /**
70
+ * @constructor
71
+ * @param [payload] event payload
72
+ */
73
+ constructor(payload = {}) {
74
+ super(payload, 'invalid', {});
75
+ }
76
+ }
77
+ exports.Invalid = Invalid;
78
+ /**
79
+ * Implementation of `valid` event. The valid event is triggered whenever the field’s valid state is changed from invalid to valid.
80
+ */
81
+ class Valid extends ActionImpl {
82
+ /**
83
+ * @constructor
84
+ * @param [payload] event payload
85
+ */
86
+ constructor(payload = {}) {
87
+ super(payload, 'valid', {});
88
+ }
89
+ }
90
+ exports.Valid = Valid;
91
+ /**
92
+ * Implementation of an ExecuteRule event.
93
+ * @private
94
+ */
95
+ class ExecuteRule extends ActionImpl {
96
+ /**
97
+ * @constructor
98
+ * @param [payload] event payload
99
+ * @param [dispatch] true to trigger the event on all the fields in DFS order starting from the top level form element, false otherwise
100
+ */
101
+ constructor(payload = {}, dispatch = false) {
102
+ super(payload, 'executeRule', { dispatch });
103
+ }
104
+ }
105
+ exports.ExecuteRule = ExecuteRule;
106
+ /**
107
+ * Creates a change event
108
+ * @param propertyName name of the form field property
109
+ * @param currentValue current value
110
+ * @param prevValue previous value
111
+ * @returns {@link Change} change event
112
+ */
113
+ const propertyChange = (propertyName, currentValue, prevValue) => {
114
+ return new Change({
115
+ changes: [
116
+ {
117
+ propertyName,
118
+ currentValue,
119
+ prevValue
120
+ }
121
+ ]
122
+ });
123
+ };
124
+ exports.propertyChange = propertyChange;
125
+ /**
126
+ * Implementation of `initialize` event. The event is triggered on all the fields when the form initialisation is complete
127
+ */
128
+ class Initialize extends ActionImpl {
129
+ /**
130
+ * @constructor
131
+ * @param [payload] event payload
132
+ * @param [dispatch] true to trigger the event on all the fields in DFS order starting from the top level form element, false otherwise
133
+ */
134
+ constructor(payload, dispatch = false) {
135
+ super(payload, 'initialize', { dispatch });
136
+ }
137
+ }
138
+ exports.Initialize = Initialize;
139
+ /**
140
+ * Implementation of `click` event. The event is triggered when user clicks on an element.
141
+ */
142
+ class Click extends ActionImpl {
143
+ /**
144
+ * @constructor
145
+ * @param [payload] event payload
146
+ * @param [dispatch] true to trigger the event on all the fields in DFS order starting from the top level form element, false otherwise
147
+ */
148
+ constructor(payload, dispatch = false) {
149
+ super(payload, 'click', { dispatch });
150
+ }
151
+ }
152
+ exports.Click = Click;
153
+ /**
154
+ * Implementation of `blur` event. The event is triggered when the element loses focus.
155
+ */
156
+ class Blur extends ActionImpl {
157
+ /**
158
+ * @constructor
159
+ * @param [payload] event payload
160
+ * @param [dispatch] true to trigger the event on all the fields in DFS order starting from the top level form element, false otherwise
161
+ */
162
+ constructor(payload, dispatch = false) {
163
+ super(payload, 'blur', { dispatch });
164
+ }
165
+ }
166
+ exports.Blur = Blur;
167
+ /**
168
+ * Implementation of `ValidationComplete` event. The ValidationComplete event is triggered once validation is completed
169
+ * on the form.
170
+ *
171
+ * An example of using this event,
172
+ * ```
173
+ * function onValidationComplete(event) {
174
+ * const x = event.payload[0].id;
175
+ * // do something with the invalid field
176
+ * }
177
+ * ```
178
+ */
179
+ class ValidationComplete extends ActionImpl {
180
+ /**
181
+ * @constructor
182
+ * @param [payload] event payload (ie) list of {@link ValidationError | validation errors}
183
+ * @param [dispatch] true to trigger the event on all the fields in DFS order starting from the top level form element, false otherwise
184
+ */
185
+ constructor(payload, dispatch = false) {
186
+ super(payload, 'validationComplete', { dispatch });
187
+ }
188
+ }
189
+ exports.ValidationComplete = ValidationComplete;
190
+ /**
191
+ * Implementation of `submit` event. The submit event is triggered on the Form.
192
+ * To trigger the submit event, submit function needs to be invoked or one can invoke dispatchEvent API.
193
+ */
194
+ class Submit extends ActionImpl {
195
+ /**
196
+ * @constructor
197
+ * @param [payload] event payload
198
+ * @param [dispatch] true to trigger the event on all the fields in DFS order starting from the top level form element, false otherwise
199
+ */
200
+ constructor(payload, dispatch = false) {
201
+ super(payload, 'submit', { dispatch });
202
+ }
203
+ }
204
+ exports.Submit = Submit;
205
+ /**
206
+ * Implementation of `fieldChanged` event. The field changed event is triggered on the field which it has changed.
207
+ */
208
+ class FieldChanged extends ActionImpl {
209
+ constructor(changes, field) {
210
+ super({
211
+ field,
212
+ changes
213
+ }, 'fieldChanged');
214
+ }
215
+ }
216
+ exports.FieldChanged = FieldChanged;
217
+ /**
218
+ * Implementation of `custom event`.
219
+ */
220
+ class CustomEvent extends ActionImpl {
221
+ /**
222
+ * @constructor
223
+ * @param [eventName] name of the event
224
+ * @param [payload] event payload
225
+ * @param [dispatch] true to trigger the event on all the fields in DFS order starting from the top level form element, false otherwise
226
+ */
227
+ constructor(eventName, payload = {}, dispatch = false) {
228
+ super(payload, eventName, { dispatch });
229
+ }
230
+ /**
231
+ * Defines if the event is custom
232
+ */
233
+ get isCustomEvent() {
234
+ return true;
235
+ }
236
+ }
237
+ exports.CustomEvent = CustomEvent;
238
+ /**
239
+ * Implementation of `addItem` event. The event is triggered on a panel to add a new instance of items inside it.
240
+ */
241
+ class AddItem extends ActionImpl {
242
+ /**
243
+ * @constructor
244
+ * @param [payload] event payload
245
+ */
246
+ constructor(payload) {
247
+ super(payload, 'addItem');
248
+ }
249
+ }
250
+ exports.AddItem = AddItem;
251
+ /**
252
+ * Implementation of `removeItem` event. The event is triggered on a panel to remove an instance of items inside it.
253
+ */
254
+ class RemoveItem extends ActionImpl {
255
+ /**
256
+ * @constructor
257
+ * @param [payload] event payload
258
+ */
259
+ constructor(payload) {
260
+ super(payload, 'removeItem');
261
+ }
262
+ }
263
+ exports.RemoveItem = RemoveItem;
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Defines event queue and event node
3
+ */
4
+ import { Action, BaseJson } from '../types';
5
+ import { BaseNode } from '../BaseNode';
6
+ import { Logger } from '../Form';
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
+ */
12
+ declare class EventQueue {
13
+ private logger;
14
+ private _runningEventCount;
15
+ private _isProcessing;
16
+ private _pendingEvents;
17
+ constructor(logger?: Logger);
18
+ get length(): number;
19
+ get isProcessing(): boolean;
20
+ isQueued<T extends BaseJson>(node: BaseNode<T>, event: Action): boolean;
21
+ queue<T extends BaseJson>(node: BaseNode<T>, events: Action | Action[], priority?: boolean): void;
22
+ runPendingQueue(): void;
23
+ }
24
+ export default EventQueue;
@@ -0,0 +1,99 @@
1
+ "use strict";
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 Form_1 = require("../Form");
11
+ /**
12
+ * Implementation of event node
13
+ * @private
14
+ */
15
+ class EventNode {
16
+ constructor(_node, _event) {
17
+ this._node = _node;
18
+ this._event = _event;
19
+ }
20
+ get node() {
21
+ return this._node;
22
+ }
23
+ get event() {
24
+ return this._event;
25
+ }
26
+ isEqual(that) {
27
+ return that !== null && that !== undefined && this._node == that._node && this._event.type == that._event.type;
28
+ }
29
+ toString() {
30
+ return this._node.id + '__' + this.event.type;
31
+ }
32
+ valueOf() {
33
+ return this.toString();
34
+ }
35
+ }
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
+ class EventQueue {
42
+ constructor(logger = new Form_1.Logger('off')) {
43
+ this.logger = logger;
44
+ this._isProcessing = false;
45
+ this._pendingEvents = [];
46
+ this._runningEventCount = {};
47
+ }
48
+ get length() {
49
+ return this._pendingEvents.length;
50
+ }
51
+ get isProcessing() {
52
+ return this._isProcessing;
53
+ }
54
+ isQueued(node, event) {
55
+ const evntNode = new EventNode(node, event);
56
+ return this._pendingEvents.find(x => evntNode.isEqual(x)) !== undefined;
57
+ }
58
+ queue(node, events, priority = false) {
59
+ if (!node || !events) {
60
+ return;
61
+ }
62
+ if (!(events instanceof Array)) {
63
+ events = [events];
64
+ }
65
+ events.forEach(e => {
66
+ const evntNode = new EventNode(node, e);
67
+ const counter = this._runningEventCount[evntNode.valueOf()] || 0;
68
+ const alreadyExists = this.isQueued(node, e);
69
+ if (!alreadyExists || counter < 10) {
70
+ this.logger.info(`Queued event : ${e.type} node: ${node.id} - ${node.name}`);
71
+ //console.log(`Event Details ${e.toString()}`)
72
+ if (priority) {
73
+ const index = this._isProcessing ? 1 : 0;
74
+ this._pendingEvents.splice(index, 0, evntNode);
75
+ }
76
+ else {
77
+ this._pendingEvents.push(evntNode);
78
+ }
79
+ this._runningEventCount[evntNode.valueOf()] = counter + 1;
80
+ }
81
+ });
82
+ }
83
+ runPendingQueue() {
84
+ if (this._isProcessing) {
85
+ return;
86
+ }
87
+ this._isProcessing = true;
88
+ while (this._pendingEvents.length > 0) {
89
+ const e = this._pendingEvents[0];
90
+ this.logger.info(`Dequeued event : ${e.event.type} node: ${e.node.id} - ${e.node.name}`);
91
+ //console.log(`Event Details ${e.event.toString()}`);
92
+ e.node.executeAction(e.event);
93
+ this._pendingEvents.shift();
94
+ }
95
+ this._runningEventCount = {};
96
+ this._isProcessing = false;
97
+ }
98
+ }
99
+ exports.default = EventQueue;
@@ -0,0 +1 @@
1
+ export * from './Controller';
@@ -0,0 +1,24 @@
1
+ "use strict";
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
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ var desc = Object.getOwnPropertyDescriptor(m, k);
12
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
13
+ desc = { enumerable: true, get: function() { return m[k]; } };
14
+ }
15
+ Object.defineProperty(o, k2, desc);
16
+ }) : (function(o, m, k, k2) {
17
+ if (k2 === undefined) k2 = k;
18
+ o[k2] = m[k];
19
+ }));
20
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
21
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
22
+ };
23
+ Object.defineProperty(exports, "__esModule", { value: true });
24
+ __exportStar(require("./Controller"), exports);
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Defines data group
3
+ */
4
+ import DataValue from './DataValue';
5
+ /**
6
+ * @private
7
+ */
8
+ export default class DataGroup extends DataValue {
9
+ $_items: {
10
+ [key: string | number]: DataValue | DataGroup;
11
+ };
12
+ constructor(_name: string | number, _value: {
13
+ [key: string | number]: any;
14
+ }, _type?: string);
15
+ get $value(): Array<any> | {
16
+ [key: string]: any;
17
+ };
18
+ get $length(): number;
19
+ $convertToDataValue(): DataValue;
20
+ $addDataNode(name: string | number, value: DataGroup | DataValue): void;
21
+ $removeDataNode(name: string | number): void;
22
+ $getDataNode(name: string | number): DataValue | undefined;
23
+ $containsDataNode(name: string | number): boolean;
24
+ get $isDataGroup(): boolean;
25
+ }
@@ -0,0 +1,74 @@
1
+ "use strict";
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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
10
+ return (mod && mod.__esModule) ? mod : { "default": mod };
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
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 {
22
+ constructor(_name, _value, _type = typeof _value) {
23
+ super(_name, _value, _type);
24
+ this.$_items = {};
25
+ Object.entries(_value).forEach(([key, value]) => {
26
+ let x;
27
+ const t = value instanceof Array ? 'array' : typeof value;
28
+ if (typeof value === 'object' && value != null) {
29
+ x = new DataGroup(key, value, t);
30
+ }
31
+ else {
32
+ x = new DataValue_1.default(key, value, t);
33
+ }
34
+ this.$_items[key] = x;
35
+ });
36
+ }
37
+ get $value() {
38
+ if (this.$type === 'array') {
39
+ return Object.values(this.$_items).filter(x => typeof x !== 'undefined').map(x => x.$value);
40
+ }
41
+ else {
42
+ return Object.fromEntries(Object.values(this.$_items).filter(x => typeof x !== 'undefined').map(x => {
43
+ return [x.$name, x.$value];
44
+ }));
45
+ }
46
+ }
47
+ get $length() {
48
+ return Object.entries(this.$_items).length;
49
+ }
50
+ $convertToDataValue() {
51
+ return new DataValue_1.default(this.$name, this.$value, this.$type);
52
+ }
53
+ $addDataNode(name, value) {
54
+ if (value !== EmptyDataValue_1.default) {
55
+ this.$_items[name] = value;
56
+ }
57
+ }
58
+ $removeDataNode(name) {
59
+ //@ts-ignore not calling delete
60
+ this.$_items[name] = undefined;
61
+ }
62
+ $getDataNode(name) {
63
+ if (this.$_items.hasOwnProperty(name)) {
64
+ return this.$_items[name];
65
+ }
66
+ }
67
+ $containsDataNode(name) {
68
+ return this.$_items.hasOwnProperty(name) && typeof (this.$_items[name]) !== 'undefined';
69
+ }
70
+ get $isDataGroup() {
71
+ return true;
72
+ }
73
+ }
74
+ exports.default = DataGroup;
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Defines data value
3
+ */
4
+ import { FieldModel } from '../types';
5
+ /**
6
+ * @private
7
+ */
8
+ export default class DataValue {
9
+ private $_name;
10
+ private $_value;
11
+ private $_type;
12
+ private $_fields;
13
+ constructor($_name: string | number, $_value: any, $_type?: string);
14
+ valueOf(): any;
15
+ get $name(): string | number;
16
+ get $value(): any;
17
+ setValue(typedValue: any, originalValue: any): void;
18
+ get $type(): string;
19
+ $bindToField(field: FieldModel): void;
20
+ $convertToDataValue(): DataValue;
21
+ get $isDataGroup(): boolean;
22
+ }
@@ -0,0 +1,50 @@
1
+ "use strict";
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
+ /**
11
+ * @private
12
+ */
13
+ class DataValue {
14
+ constructor($_name, $_value, $_type = typeof $_value) {
15
+ this.$_name = $_name;
16
+ this.$_value = $_value;
17
+ this.$_type = $_type;
18
+ this.$_fields = [];
19
+ }
20
+ valueOf() {
21
+ return this.$_value;
22
+ }
23
+ get $name() {
24
+ return this.$_name;
25
+ }
26
+ get $value() {
27
+ return this.$_value;
28
+ }
29
+ setValue(typedValue, originalValue) {
30
+ this.$_value = typedValue;
31
+ this.$_fields.forEach(x => {
32
+ x.value = originalValue;
33
+ });
34
+ }
35
+ get $type() {
36
+ return this.$_type;
37
+ }
38
+ $bindToField(field) {
39
+ if (this.$_fields.indexOf(field) === -1) {
40
+ this.$_fields.push(field);
41
+ }
42
+ }
43
+ $convertToDataValue() {
44
+ return this;
45
+ }
46
+ get $isDataGroup() {
47
+ return false;
48
+ }
49
+ }
50
+ exports.default = DataValue;
@@ -0,0 +1,14 @@
1
+ import DataValue from './DataValue';
2
+ declare class NullDataValueClass extends DataValue {
3
+ constructor();
4
+ setValue(): void;
5
+ $bindToField(): void;
6
+ $length(): number;
7
+ $convertToDataValue(): DataValue;
8
+ $addDataNode(): void;
9
+ $removeDataNode(): void;
10
+ $getDataNode(): this;
11
+ $containsDataNode(): boolean;
12
+ }
13
+ declare const NullDataValue: NullDataValueClass;
14
+ export default NullDataValue;
@@ -0,0 +1,46 @@
1
+ "use strict";
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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
10
+ return (mod && mod.__esModule) ? mod : { "default": mod };
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ const DataValue_1 = __importDefault(require("./DataValue"));
14
+ const value = Symbol('NullValue');
15
+ class NullDataValueClass extends DataValue_1.default {
16
+ constructor() {
17
+ super('', value, 'null');
18
+ }
19
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
20
+ setValue() {
21
+ }
22
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
23
+ $bindToField() {
24
+ }
25
+ $length() {
26
+ return 0;
27
+ }
28
+ $convertToDataValue() {
29
+ return this;
30
+ }
31
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
32
+ $addDataNode() {
33
+ }
34
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
35
+ $removeDataNode() {
36
+ }
37
+ $getDataNode() {
38
+ return this;
39
+ }
40
+ $containsDataNode() {
41
+ return false;
42
+ }
43
+ }
44
+ //@ts-ignore
45
+ const NullDataValue = new NullDataValueClass();
46
+ exports.default = NullDataValue;
package/lib/index.d.ts ADDED
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Copyright 2022 Adobe, Inc.
3
+ *
4
+ * 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.
5
+ *
6
+ * 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.
7
+ */
8
+ export * from './FormInstance';
9
+ export * from './types/index';
10
+ export * from './controller/index';
11
+ export * from './utils/TranslationUtils';
12
+ export * from './utils/JsonUtils';
13
+ export * from './utils/SchemaUtils';
14
+ import { getFileSizeInBytes } from './utils/FormUtils';
15
+ import { BaseNode } from './BaseNode';
16
+ import Checkbox from './Checkbox';
17
+ import CheckboxGroup from './CheckboxGroup';
18
+ import Container from './Container';
19
+ import Field from './Field';
20
+ import { Fieldset } from './Fieldset';
21
+ import { FileObject } from './FileObject';
22
+ import FileUpload from './FileUpload';
23
+ import FormMetaData from './FormMetaData';
24
+ import Node from './Node';
25
+ import Scriptable from './Scriptable';
26
+ import Form from './Form';
27
+ export { Form, BaseNode, Checkbox, CheckboxGroup, Container, Field, Fieldset, FileObject, FileUpload, FormMetaData, Node, Scriptable, getFileSizeInBytes };