@aemforms/af-core 0.22.18 → 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.
Files changed (120) hide show
  1. package/lib/browser/afb-events.js +151 -0
  2. package/lib/browser/afb-runtime.js +3620 -0
  3. package/lib/cjs/index.cjs +8886 -0
  4. package/lib/{BaseNode.d.ts → esm/BaseNode.d.ts} +11 -68
  5. package/lib/{BaseNode.js → esm/BaseNode.js} +86 -182
  6. package/lib/esm/Checkbox.d.ts +79 -0
  7. package/lib/esm/Checkbox.js +27 -0
  8. package/lib/{CheckboxGroup.d.ts → esm/CheckboxGroup.d.ts} +2 -14
  9. package/lib/esm/CheckboxGroup.js +23 -0
  10. package/lib/esm/Container.d.ts +53 -0
  11. package/lib/{Container.js → esm/Container.js} +76 -124
  12. package/lib/{DateField.d.ts → esm/DateField.d.ts} +1 -1
  13. package/lib/esm/DateField.js +21 -0
  14. package/lib/{Field.d.ts → esm/Field.d.ts} +44 -98
  15. package/lib/{Field.js → esm/Field.js} +172 -206
  16. package/lib/esm/Fieldset.d.ts +16 -0
  17. package/lib/esm/Fieldset.js +45 -0
  18. package/lib/{FileObject.d.ts → esm/FileObject.d.ts} +1 -4
  19. package/lib/esm/FileObject.js +26 -0
  20. package/lib/{FileUpload.d.ts → esm/FileUpload.d.ts} +3 -18
  21. package/lib/esm/FileUpload.js +108 -0
  22. package/lib/esm/Form.d.ts +113 -0
  23. package/lib/esm/Form.js +176 -0
  24. package/lib/esm/FormInstance.d.ts +13 -0
  25. package/lib/esm/FormInstance.js +81 -0
  26. package/lib/esm/FormMetaData.d.ts +7 -0
  27. package/lib/esm/FormMetaData.js +10 -0
  28. package/lib/esm/InstanceManager.d.ts +9 -0
  29. package/lib/esm/InstanceManager.js +31 -0
  30. package/lib/esm/Node.d.ts +7 -0
  31. package/lib/esm/Node.js +16 -0
  32. package/lib/esm/Scriptable.d.ts +17 -0
  33. package/lib/{Scriptable.js → esm/Scriptable.js} +12 -55
  34. package/lib/{controller → esm/controller}/EventQueue.d.ts +3 -11
  35. package/lib/{controller → esm/controller}/EventQueue.js +10 -26
  36. package/lib/esm/controller/Events.d.ts +85 -0
  37. package/lib/esm/controller/Events.js +149 -0
  38. package/lib/{controller → esm/controller}/Logger.d.ts +0 -6
  39. package/lib/{controller → esm/controller}/Logger.js +5 -11
  40. package/lib/{data → esm/data}/DataGroup.d.ts +1 -7
  41. package/lib/{data → esm/data}/DataGroup.js +20 -35
  42. package/lib/{data → esm/data}/DataValue.d.ts +2 -8
  43. package/lib/esm/data/DataValue.js +46 -0
  44. package/lib/{data → esm/data}/EmptyDataValue.d.ts +1 -1
  45. package/lib/esm/data/EmptyDataValue.js +29 -0
  46. package/lib/esm/index.d.ts +21 -0
  47. package/lib/esm/index.js +21 -0
  48. package/lib/{rules → esm/rules}/FunctionRuntime.d.ts +2 -24
  49. package/lib/{rules → esm/rules}/FunctionRuntime.js +44 -114
  50. package/lib/esm/rules/RuleEngine.d.ts +12 -0
  51. package/lib/esm/rules/RuleEngine.js +47 -0
  52. package/lib/{types → esm/types}/Json.d.ts +6 -22
  53. package/lib/esm/types/Json.js +7 -0
  54. package/lib/esm/types/Model.d.ts +131 -0
  55. package/lib/esm/types/Model.js +8 -0
  56. package/lib/esm/types/index.d.ts +2 -0
  57. package/lib/esm/types/index.js +2 -0
  58. package/lib/{utils → esm/utils}/DataRefParser.d.ts +2 -5
  59. package/lib/{utils → esm/utils}/DataRefParser.js +22 -49
  60. package/lib/{utils → esm/utils}/Fetch.d.ts +1 -0
  61. package/lib/esm/utils/Fetch.js +61 -0
  62. package/lib/esm/utils/FormCreationUtils.d.ts +9 -0
  63. package/lib/esm/utils/FormCreationUtils.js +74 -0
  64. package/lib/esm/utils/FormUtils.d.ts +12 -0
  65. package/lib/esm/utils/FormUtils.js +187 -0
  66. package/lib/esm/utils/JsonUtils.d.ts +11 -0
  67. package/lib/esm/utils/JsonUtils.js +76 -0
  68. package/lib/{utils → esm/utils}/LogUtils.d.ts +1 -4
  69. package/lib/esm/utils/LogUtils.js +6 -0
  70. package/lib/esm/utils/SchemaUtils.d.ts +3 -0
  71. package/lib/esm/utils/SchemaUtils.js +71 -0
  72. package/lib/esm/utils/TranslationUtils.d.ts +11 -0
  73. package/lib/esm/utils/TranslationUtils.js +115 -0
  74. package/lib/esm/utils/ValidationUtils.d.ts +19 -0
  75. package/lib/{utils → esm/utils}/ValidationUtils.js +29 -187
  76. package/package.json +17 -10
  77. package/lib/Checkbox.d.ts +0 -88
  78. package/lib/Checkbox.js +0 -49
  79. package/lib/CheckboxGroup.js +0 -43
  80. package/lib/Container.d.ts +0 -199
  81. package/lib/DateField.js +0 -35
  82. package/lib/Fieldset.d.ts +0 -34
  83. package/lib/Fieldset.js +0 -113
  84. package/lib/FileObject.js +0 -39
  85. package/lib/FileUpload.js +0 -155
  86. package/lib/Form.d.ts +0 -262
  87. package/lib/Form.js +0 -230
  88. package/lib/FormInstance.d.ts +0 -38
  89. package/lib/FormInstance.js +0 -119
  90. package/lib/FormMetaData.d.ts +0 -11
  91. package/lib/FormMetaData.js +0 -28
  92. package/lib/Node.d.ts +0 -12
  93. package/lib/Node.js +0 -27
  94. package/lib/Scriptable.d.ts +0 -31
  95. package/lib/controller/Controller.d.ts +0 -223
  96. package/lib/controller/Controller.js +0 -287
  97. package/lib/controller/index.d.ts +0 -1
  98. package/lib/controller/index.js +0 -24
  99. package/lib/data/DataValue.js +0 -52
  100. package/lib/data/EmptyDataValue.js +0 -46
  101. package/lib/index.d.ts +0 -28
  102. package/lib/index.js +0 -63
  103. package/lib/rules/RuleEngine.d.ts +0 -23
  104. package/lib/rules/RuleEngine.js +0 -62
  105. package/lib/types/Json.js +0 -19
  106. package/lib/types/Model.d.ts +0 -379
  107. package/lib/types/Model.js +0 -20
  108. package/lib/types/index.d.ts +0 -2
  109. package/lib/types/index.js +0 -25
  110. package/lib/utils/Fetch.js +0 -29
  111. package/lib/utils/FormUtils.d.ts +0 -47
  112. package/lib/utils/FormUtils.js +0 -257
  113. package/lib/utils/JsonUtils.d.ts +0 -62
  114. package/lib/utils/JsonUtils.js +0 -143
  115. package/lib/utils/LogUtils.js +0 -17
  116. package/lib/utils/SchemaUtils.d.ts +0 -16
  117. package/lib/utils/SchemaUtils.js +0 -92
  118. package/lib/utils/TranslationUtils.d.ts +0 -41
  119. package/lib/utils/TranslationUtils.js +0 -185
  120. package/lib/utils/ValidationUtils.d.ts +0 -170
@@ -0,0 +1,7 @@
1
+ declare class Node<T> {
2
+ protected _jsonModel: T;
3
+ constructor(inputModel: T);
4
+ protected getP<S>(key: string, def: S): S;
5
+ get isContainer(): boolean;
6
+ }
7
+ export default Node;
@@ -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
- "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 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 = (_a = this._jsonModel.events) === null || _a === void 0 ? void 0 : _a[eName];
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
- // @ts-ignore
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 (BaseNode_1.editableProperties.indexOf(prop) > -1) {
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: (parent === null || parent === void 0 ? void 0 : parent.ruleNodeReference()) || {}
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 BaseNode_1.BaseNode) {
117
- //$parent
89
+ if (retValue instanceof BaseNode) {
118
90
  return retValue.getRuleNode();
119
91
  }
120
92
  else if (retValue instanceof Array) {
121
- //$items
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
- //todo: apply all the updates at the end or
196
- // not trigger the change event until the execution is finished
197
- node.forEach((n) => this.executeEvent(context, n));
198
- // @ts-ignore
199
156
  if (funcName in this && typeof this[funcName] === 'function') {
200
- //@ts-ignore
201
157
  this[funcName](action, context);
202
158
  }
159
+ node.forEach((n) => this.executeEvent(context, n));
203
160
  this.notifyDependents(action);
204
161
  }
205
162
  }
206
- exports.default = Scriptable;
163
+ export default Scriptable;
@@ -1,14 +1,6 @@
1
- /**
2
- * Defines event queue and event node
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
- "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 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
- constructor(logger = new Logger_1.Logger('off')) {
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
- EventQueue.MAX_EVENT_CYCLE_COUNT = 10;
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,10 +1,4 @@
1
- /**
2
- * Defines data group
3
- */
4
- import DataValue from './DataValue';
5
- /**
6
- * @private
7
- */
1
+ import DataValue from './DataValue.js';
8
2
  export default class DataGroup extends DataValue {
9
3
  $_items: {
10
4
  [key: string]: DataValue | DataGroup;
@@ -1,24 +1,16 @@
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 {
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,17 +24,12 @@ 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
- if (this.$type === 'array') {
28
+ const enabled = this.$_fields.find(x => x.enabled !== false);
29
+ if (!enabled && this.$_fields.length) {
30
+ return this.$type === 'array' ? [] : {};
31
+ }
32
+ else if (this.$type === 'array') {
46
33
  return Object.values(this.$_items).filter(x => typeof x !== 'undefined').map(x => x.$value);
47
34
  }
48
35
  else {
@@ -55,10 +42,10 @@ class DataGroup extends DataValue_1.default {
55
42
  return Object.entries(this.$_items).length;
56
43
  }
57
44
  $convertToDataValue() {
58
- return new DataValue_1.default(this.$name, this.$value, this.$type);
45
+ return new DataValue(this.$name, this.$value, this.$type);
59
46
  }
60
47
  $addDataNode(name, value, override = false) {
61
- if (value !== EmptyDataValue_1.default) {
48
+ if (value !== NullDataValue) {
62
49
  if (this.$type === 'array') {
63
50
  const index = name;
64
51
  if (!override) {
@@ -74,7 +61,6 @@ class DataGroup extends DataValue_1.default {
74
61
  }
75
62
  }
76
63
  $removeDataNode(name) {
77
- //@ts-ignore not calling delete
78
64
  this.$_items[name] = undefined;
79
65
  }
80
66
  $getDataNode(name) {
@@ -89,4 +75,3 @@ class DataGroup extends DataValue_1.default {
89
75
  return true;
90
76
  }
91
77
  }
92
- exports.default = DataGroup;
@@ -1,15 +1,9 @@
1
- /**
2
- * Defines data value
3
- */
4
- import { FieldModel } from '../types';
5
- /**
6
- * @private
7
- */
1
+ import { FieldModel } from '../types/index.js';
8
2
  export default class DataValue {
9
3
  private $_name;
10
4
  private $_value;
11
5
  private $_type;
12
- private $_fields;
6
+ $_fields: Array<FieldModel>;
13
7
  constructor($_name: string | number, $_value: any, $_type?: string);
14
8
  valueOf(): any;
15
9
  get $name(): string | number;