@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
package/lib/Form.d.ts DELETED
@@ -1,262 +0,0 @@
1
- import Container from './Container';
2
- import { Action, BaseModel, FieldJson, FieldModel, FieldsetJson, FieldsetModel, FormJson, FormModel, Items } from './types';
3
- import FormMetaData from './FormMetaData';
4
- import EventQueue from './controller/EventQueue';
5
- import { Logger, LogLevel } from './controller/Logger';
6
- import RuleEngine from './rules/RuleEngine';
7
- /**
8
- * Defines `form model` which implements {@link FormModel | form model}
9
- */
10
- declare class Form extends Container<FormJson> implements FormModel {
11
- private _ruleEngine;
12
- private _eventQueue;
13
- /**
14
- * @private
15
- */
16
- private _fields;
17
- /**
18
- * @private
19
- */
20
- _ids: Generator<string, void, string>;
21
- /**
22
- * @private
23
- */
24
- private _invalidFields;
25
- private _logger;
26
- /**
27
- * @param n
28
- * @param _ruleEngine
29
- * @param _eventQueue
30
- * @param logLevel
31
- * @private
32
- */
33
- constructor(n: FormJson, _ruleEngine: RuleEngine, _eventQueue?: EventQueue, logLevel?: LogLevel);
34
- get logger(): Logger;
35
- private dataRefRegex;
36
- get metaData(): FormMetaData;
37
- get action(): string | undefined;
38
- protected _createChild(child: FieldsetJson | FieldJson): FieldModel | FieldsetModel;
39
- importData(dataModel: any): void;
40
- exportData(): any;
41
- setFocus(field: BaseModel): void;
42
- /**
43
- * Returns the current state of the form
44
- *
45
- * To access the form data and attachments, one needs to use the `data` and `attachments` property.
46
- * For example,
47
- * ```
48
- * const data = form.getState().data
49
- * const attachments = form.getState().attachments
50
- * ```
51
- */
52
- getState(): {
53
- description?: string | undefined;
54
- } & import("./types").RulesJson & {
55
- enumNames?: string[] | undefined;
56
- enum?: any[] | undefined;
57
- } & {
58
- accept?: string[] | undefined;
59
- enforceEnum?: boolean | undefined;
60
- exclusiveMinimum?: number | undefined;
61
- exclusiveMaximum?: number | undefined;
62
- format?: string | undefined;
63
- maxFileSize?: string | number | undefined;
64
- maxLength?: number | undefined;
65
- maximum?: number | undefined;
66
- maxItems?: number | undefined;
67
- minLength?: number | undefined;
68
- minimum?: number | undefined;
69
- minItems?: number | undefined;
70
- pattern?: string | undefined;
71
- required?: boolean | undefined;
72
- step?: number | undefined;
73
- type?: string | undefined;
74
- validationExpression?: string | undefined;
75
- uniqueItems?: boolean | undefined;
76
- } & {
77
- dataRef?: string | null | undefined;
78
- ':type'?: string | undefined;
79
- label?: import("./types").Label | undefined;
80
- enabled?: boolean | undefined;
81
- visible?: boolean | undefined;
82
- name?: string | undefined;
83
- constraintMessages?: import("./types").ConstraintsMessages | undefined;
84
- fieldType?: string | undefined;
85
- errorMessage?: string | undefined;
86
- properties?: {
87
- [key: string]: any;
88
- } | undefined;
89
- screenReaderText?: string | undefined;
90
- tooltip?: string | undefined;
91
- altText?: string | undefined;
92
- } & {
93
- items: (FieldJson | import("./types").ContainerJson)[];
94
- initialItems?: number | undefined;
95
- activeChild?: string | undefined;
96
- } & {
97
- metadata?: import("./types").MetaDataJson | undefined;
98
- data?: any;
99
- title?: string | undefined;
100
- action?: string | undefined;
101
- adaptiveForm?: string | undefined;
102
- } & {
103
- items: ({
104
- id: string;
105
- index: number;
106
- ':type': string;
107
- description?: string | undefined;
108
- rules?: Items<string> | undefined;
109
- events?: Items<string | string[] | undefined> | undefined;
110
- enumNames?: string[] | undefined;
111
- enum?: any[] | undefined;
112
- accept?: string[] | undefined;
113
- enforceEnum?: boolean | undefined;
114
- exclusiveMinimum?: number | undefined;
115
- exclusiveMaximum?: number | undefined;
116
- format?: string | undefined;
117
- maxFileSize?: string | number | undefined;
118
- maxLength?: number | undefined;
119
- maximum?: number | undefined;
120
- maxItems?: number | undefined;
121
- minLength?: number | undefined;
122
- minimum?: number | undefined;
123
- minItems?: number | undefined;
124
- pattern?: string | undefined;
125
- required?: boolean | undefined;
126
- step?: number | undefined;
127
- type?: string | undefined;
128
- validationExpression?: string | undefined;
129
- uniqueItems?: boolean | undefined;
130
- dataRef?: string | null | undefined;
131
- label?: import("./types").Label | undefined;
132
- enabled?: boolean | undefined;
133
- visible?: boolean | undefined;
134
- name?: string | undefined;
135
- constraintMessages?: import("./types").ConstraintsMessages | undefined;
136
- fieldType?: string | undefined;
137
- errorMessage?: string | undefined;
138
- properties?: {
139
- [key: string]: any;
140
- } | undefined;
141
- screenReaderText?: string | undefined;
142
- tooltip?: string | undefined;
143
- altText?: string | undefined;
144
- placeholder?: string | undefined; /**
145
- * Returns the current state of the form
146
- *
147
- * To access the form data and attachments, one needs to use the `data` and `attachments` property.
148
- * For example,
149
- * ```
150
- * const data = form.getState().data
151
- * const attachments = form.getState().attachments
152
- * ```
153
- */
154
- readOnly?: boolean | undefined;
155
- valid?: boolean | undefined;
156
- default?: any;
157
- value?: any;
158
- displayFormat?: string | undefined;
159
- editFormat?: string | undefined;
160
- editValue?: string | undefined;
161
- displayValue?: string | undefined;
162
- emptyValue?: "" | "undefined" | "null" | undefined;
163
- } | {
164
- id: string;
165
- index: number;
166
- ':type': string;
167
- description?: string | undefined;
168
- rules?: Items<string> | undefined;
169
- events?: Items<string | string[] | undefined> | undefined;
170
- enumNames?: string[] | undefined;
171
- enum?: any[] | undefined;
172
- accept?: string[] | undefined;
173
- enforceEnum?: boolean | undefined;
174
- exclusiveMinimum?: number | undefined;
175
- exclusiveMaximum?: number | undefined;
176
- format?: string | undefined;
177
- maxFileSize?: string | number | undefined;
178
- maxLength?: number | undefined;
179
- maximum?: number | undefined;
180
- maxItems?: number | undefined;
181
- minLength?: number | undefined;
182
- minimum?: number | undefined;
183
- minItems?: number | undefined;
184
- pattern?: string | undefined;
185
- required?: boolean | undefined;
186
- step?: number | undefined;
187
- type?: "object" | "array" | undefined;
188
- validationExpression?: string | undefined;
189
- uniqueItems?: boolean | undefined;
190
- dataRef?: string | null | undefined;
191
- label?: import("./types").Label | undefined;
192
- enabled?: boolean | undefined;
193
- visible?: boolean | undefined;
194
- name?: string | undefined;
195
- constraintMessages?: import("./types").ConstraintsMessages | undefined;
196
- fieldType?: string | undefined;
197
- errorMessage?: string | undefined;
198
- properties?: {
199
- [key: string]: any;
200
- } | undefined;
201
- screenReaderText?: string | undefined;
202
- tooltip?: string | undefined;
203
- altText?: string | undefined;
204
- items: (FieldJson | import("./types").ContainerJson)[] & import("./types").State<FieldJson | import("./types").ContainerJson>[];
205
- initialItems?: number | undefined;
206
- activeChild?: string | undefined;
207
- })[];
208
- properties: {
209
- [key: string]: any;
210
- };
211
- index: number;
212
- parent: undefined;
213
- qualifiedName: any;
214
- events: {};
215
- rules: {};
216
- ':type': string;
217
- id: string;
218
- };
219
- get type(): string;
220
- isTransparent(): boolean;
221
- get form(): FormModel;
222
- get ruleEngine(): RuleEngine;
223
- getUniqueId(): string;
224
- /**
225
- * @param field
226
- * @private
227
- */
228
- fieldAdded(field: FieldModel | FieldsetModel): void;
229
- validate(): import("./types").ValidationError[];
230
- /**
231
- * Checks if the given form is valid or not
232
- * @returns `true`, if form is valid, `false` otherwise
233
- */
234
- isValid(): boolean;
235
- /**
236
- * @param field
237
- * @private
238
- */
239
- dispatch(action: Action): void;
240
- /**
241
- * @param action
242
- * @private
243
- */
244
- executeAction(action: Action): void;
245
- /**
246
- * @param action
247
- * @param context
248
- * @private
249
- */
250
- submit(action: Action, context: any): void;
251
- getElement(id: string): FieldModel | FieldsetModel | this;
252
- get qualifiedName(): string;
253
- /**
254
- * @private
255
- */
256
- getEventQueue(): EventQueue;
257
- get name(): string;
258
- get value(): null;
259
- get id(): string;
260
- get title(): string;
261
- }
262
- export default Form;
package/lib/Form.js DELETED
@@ -1,230 +0,0 @@
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 Container_1 = __importDefault(require("./Container"));
14
- const FormMetaData_1 = __importDefault(require("./FormMetaData"));
15
- const Fieldset_1 = require("./Fieldset");
16
- const EventQueue_1 = __importDefault(require("./controller/EventQueue"));
17
- const Logger_1 = require("./controller/Logger");
18
- const FormUtils_1 = require("./utils/FormUtils");
19
- const DataGroup_1 = __importDefault(require("./data/DataGroup"));
20
- const FunctionRuntime_1 = require("./rules/FunctionRuntime");
21
- const controller_1 = require("./controller");
22
- /**
23
- * Defines `form model` which implements {@link FormModel | form model}
24
- */
25
- class Form extends Container_1.default {
26
- /**
27
- * @param n
28
- * @param _ruleEngine
29
- * @param _eventQueue
30
- * @param logLevel
31
- * @private
32
- */
33
- constructor(n, _ruleEngine, _eventQueue = new EventQueue_1.default(), logLevel = 'off') {
34
- //@ts-ignore
35
- super(n, {});
36
- this._ruleEngine = _ruleEngine;
37
- this._eventQueue = _eventQueue;
38
- /**
39
- * @private
40
- */
41
- this._fields = {};
42
- /**
43
- * @private
44
- */
45
- this._invalidFields = [];
46
- this.dataRefRegex = /("[^"]+?"|[^.]+?)(?:\.|$)/g;
47
- this._logger = new Logger_1.Logger(logLevel);
48
- this.queueEvent(new controller_1.Initialize());
49
- this.queueEvent(new controller_1.ExecuteRule());
50
- this._ids = (0, FormUtils_1.IdGenerator)();
51
- this._bindToDataModel(new DataGroup_1.default('$form', {}));
52
- this._initialize();
53
- this.queueEvent(new controller_1.FormLoad());
54
- }
55
- get logger() {
56
- return this._logger;
57
- }
58
- get metaData() {
59
- const metaData = this._jsonModel.metadata || {};
60
- return new FormMetaData_1.default(metaData);
61
- }
62
- get action() {
63
- return this._jsonModel.action;
64
- }
65
- _createChild(child) {
66
- return (0, Fieldset_1.createChild)(child, { form: this, parent: this });
67
- }
68
- importData(dataModel) {
69
- this._bindToDataModel(new DataGroup_1.default('$form', dataModel));
70
- this.syncDataAndFormModel(this.getDataNode());
71
- this._eventQueue.runPendingQueue();
72
- }
73
- exportData() {
74
- var _a;
75
- return (_a = this.getDataNode()) === null || _a === void 0 ? void 0 : _a.$value;
76
- }
77
- setFocus(field) {
78
- const parent = field.parent;
79
- const currentField = field;
80
- while (parent != null && parent.activeChild != currentField) {
81
- parent.activeChild = currentField;
82
- }
83
- }
84
- /**
85
- * Returns the current state of the form
86
- *
87
- * To access the form data and attachments, one needs to use the `data` and `attachments` property.
88
- * For example,
89
- * ```
90
- * const data = form.getState().data
91
- * const attachments = form.getState().attachments
92
- * ```
93
- */
94
- getState() {
95
- // eslint-disable-next-line @typescript-eslint/no-this-alias
96
- const self = this;
97
- const res = super.getState();
98
- res.id = '$form';
99
- Object.defineProperty(res, 'data', {
100
- get: function () {
101
- return self.exportData();
102
- }
103
- });
104
- Object.defineProperty(res, 'attachments', {
105
- get: function () {
106
- return (0, FormUtils_1.getAttachments)(self);
107
- }
108
- });
109
- return res;
110
- }
111
- get type() {
112
- return 'object';
113
- }
114
- isTransparent() {
115
- return false;
116
- }
117
- get form() {
118
- return this;
119
- }
120
- get ruleEngine() {
121
- return this._ruleEngine;
122
- }
123
- getUniqueId() {
124
- if (this._ids == null) {
125
- return '';
126
- }
127
- return this._ids.next().value;
128
- }
129
- /**
130
- * @param field
131
- * @private
132
- */
133
- fieldAdded(field) {
134
- this._fields[field.id] = field;
135
- field.subscribe((action) => {
136
- if (this._invalidFields.indexOf(action.target.id) === -1) {
137
- this._invalidFields.push(action.target.id);
138
- }
139
- }, 'invalid');
140
- field.subscribe((action) => {
141
- const index = this._invalidFields.indexOf(action.target.id);
142
- if (index > -1) {
143
- this._invalidFields.splice(index, 1);
144
- }
145
- }, 'valid');
146
- field.subscribe((action) => {
147
- //@ts-ignore
148
- const field = action.target.getState();
149
- if (field) {
150
- const fieldChangedAction = new controller_1.FieldChanged(action.payload.changes, field);
151
- this.dispatch(fieldChangedAction);
152
- }
153
- });
154
- }
155
- validate() {
156
- const validationErrors = super.validate();
157
- // trigger event on form so that user's can customize their application
158
- this.dispatch(new controller_1.ValidationComplete(validationErrors));
159
- return validationErrors;
160
- }
161
- /**
162
- * Checks if the given form is valid or not
163
- * @returns `true`, if form is valid, `false` otherwise
164
- */
165
- isValid() {
166
- return this._invalidFields.length === 0;
167
- }
168
- /**
169
- * @param field
170
- * @private
171
- */
172
- dispatch(action) {
173
- if (action.type === 'submit') {
174
- super.queueEvent(action);
175
- this._eventQueue.runPendingQueue();
176
- }
177
- else {
178
- super.dispatch(action);
179
- }
180
- }
181
- /**
182
- * @param action
183
- * @private
184
- */
185
- executeAction(action) {
186
- if (action.type !== 'submit' || this._invalidFields.length === 0) {
187
- super.executeAction(action);
188
- }
189
- }
190
- /**
191
- * @param action
192
- * @param context
193
- * @private
194
- */
195
- submit(action, context) {
196
- // if no errors, only then submit
197
- if (this.validate().length === 0) {
198
- const payload = (action === null || action === void 0 ? void 0 : action.payload) || {};
199
- (0, FunctionRuntime_1.submit)(context, payload === null || payload === void 0 ? void 0 : payload.success, payload === null || payload === void 0 ? void 0 : payload.error, payload === null || payload === void 0 ? void 0 : payload.submit_as, payload === null || payload === void 0 ? void 0 : payload.data);
200
- }
201
- }
202
- getElement(id) {
203
- if (id == this.id) {
204
- return this;
205
- }
206
- return this._fields[id];
207
- }
208
- get qualifiedName() {
209
- return '$form';
210
- }
211
- /**
212
- * @private
213
- */
214
- getEventQueue() {
215
- return this._eventQueue;
216
- }
217
- get name() {
218
- return '$form';
219
- }
220
- get value() {
221
- return null;
222
- }
223
- get id() {
224
- return '$form';
225
- }
226
- get title() {
227
- return this._jsonModel.title || '';
228
- }
229
- }
230
- exports.default = Form;
@@ -1,38 +0,0 @@
1
- import { FormModel } from './types';
2
- import { LogLevel } from './controller/Logger';
3
- /**
4
- * Creates form instance using form model definition as per `adaptive form specification`
5
- * @param formModel form model definition
6
- * @param callback a callback that recieves the FormModel instance that gets executed before any event in the Form
7
- * is executed
8
- * @param logLevel Logging Level for the form. Setting it off will disable the logging
9
- * @param fModel existing form model, this is additional optimization to prevent creation of form instance
10
- * @returns {@link FormModel | form model}
11
- */
12
- export declare const createFormInstance: (formModel: any, callback?: ((f: FormModel) => any) | undefined, logLevel?: LogLevel, fModel?: any) => FormModel;
13
- /**
14
- * Validates Form model definition with the given data
15
- * @param formModel form model definition
16
- * @param data form data
17
- * @deprecated use validateFormData
18
- * @returns `true`, if form is valid against the given form data, `false` otherwise
19
- */
20
- export declare const validateFormInstance: (formModel: any, data: any) => boolean;
21
- /**
22
- * Validates Form model definition with the given data
23
- * @param formModel form model definition
24
- * @param data form data
25
- * @deprecated use validateFormData
26
- * @returns {messages: [], valid: boolean}
27
- */
28
- export declare const validateFormData: (formModel: any, data: any) => {
29
- messages: any[];
30
- valid: boolean;
31
- };
32
- /**
33
- * Helper API to fetch form model definition from an AEM instance
34
- * @param url URL of the instance
35
- * @param headers HTTP headers to pass to the aem instance
36
- * @returns promise which resolves to the form model definition
37
- */
38
- export declare const fetchForm: (url: string, headers?: any) => Promise<string>;
@@ -1,119 +0,0 @@
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
- exports.fetchForm = exports.validateFormData = exports.validateFormInstance = exports.createFormInstance = void 0;
14
- const Form_1 = __importDefault(require("./Form"));
15
- const JsonUtils_1 = require("./utils/JsonUtils");
16
- const Fetch_1 = require("./utils/Fetch");
17
- const RuleEngine_1 = __importDefault(require("./rules/RuleEngine"));
18
- const EventQueue_1 = __importDefault(require("./controller/EventQueue"));
19
- const Logger_1 = require("./controller/Logger");
20
- /**
21
- * Creates form instance using form model definition as per `adaptive form specification`
22
- * @param formModel form model definition
23
- * @param callback a callback that recieves the FormModel instance that gets executed before any event in the Form
24
- * is executed
25
- * @param logLevel Logging Level for the form. Setting it off will disable the logging
26
- * @param fModel existing form model, this is additional optimization to prevent creation of form instance
27
- * @returns {@link FormModel | form model}
28
- */
29
- const createFormInstance = (formModel, callback, logLevel = 'error', fModel = undefined) => {
30
- try {
31
- let f = fModel;
32
- if (f == null) {
33
- f = new Form_1.default(Object.assign({}, formModel), new RuleEngine_1.default(), new EventQueue_1.default(new Logger_1.Logger(logLevel)), logLevel);
34
- }
35
- const formData = formModel === null || formModel === void 0 ? void 0 : formModel.data;
36
- if (formData) {
37
- f.importData(formData);
38
- }
39
- if (typeof callback === 'function') {
40
- callback(f);
41
- }
42
- // Once the field or panel is initialized, execute the initialization script
43
- // this means initialization happens after prefill and restore
44
- // Before execution of calcExp, visibleExp, enabledExp, validate, options, navigationChange, we execute init script
45
- //f.queueEvent(new Initialize(undefined, true));
46
- //f.queueEvent(new ExecuteRule(undefined, true));
47
- f.getEventQueue().runPendingQueue();
48
- return f;
49
- }
50
- catch (e) {
51
- console.error(`Unable to create an instance of the Form ${e}`);
52
- throw new Error(e);
53
- }
54
- };
55
- exports.createFormInstance = createFormInstance;
56
- /**
57
- * Validates Form model definition with the given data
58
- * @param formModel form model definition
59
- * @param data form data
60
- * @deprecated use validateFormData
61
- * @returns `true`, if form is valid against the given form data, `false` otherwise
62
- */
63
- const validateFormInstance = (formModel, data) => {
64
- try {
65
- const f = new Form_1.default(Object.assign({}, formModel), new RuleEngine_1.default());
66
- if (data) {
67
- f.importData(data);
68
- }
69
- return f.validate().length === 0;
70
- }
71
- catch (e) {
72
- throw new Error(e);
73
- }
74
- };
75
- exports.validateFormInstance = validateFormInstance;
76
- /**
77
- * Validates Form model definition with the given data
78
- * @param formModel form model definition
79
- * @param data form data
80
- * @deprecated use validateFormData
81
- * @returns {messages: [], valid: boolean}
82
- */
83
- const validateFormData = (formModel, data) => {
84
- try {
85
- const f = new Form_1.default(Object.assign({}, formModel), new RuleEngine_1.default());
86
- if (data) {
87
- f.importData(data);
88
- }
89
- const res = f.validate();
90
- return {
91
- messages: res,
92
- valid: res.length === 0
93
- };
94
- }
95
- catch (e) {
96
- throw new Error(e);
97
- }
98
- };
99
- exports.validateFormData = validateFormData;
100
- /**
101
- * Helper API to fetch form model definition from an AEM instance
102
- * @param url URL of the instance
103
- * @param headers HTTP headers to pass to the aem instance
104
- * @returns promise which resolves to the form model definition
105
- */
106
- const fetchForm = (url, headers = {}) => {
107
- const headerObj = new Headers();
108
- Object.entries(headers).forEach(([key, value]) => {
109
- headerObj.append(key, value);
110
- });
111
- return (0, Fetch_1.request)(`${url}.model.json`, null, { headers }).then((formObj) => {
112
- if ('model' in formObj) {
113
- const { model } = formObj;
114
- formObj = model;
115
- }
116
- return (0, JsonUtils_1.jsonString)(formObj);
117
- });
118
- };
119
- exports.fetchForm = fetchForm;
@@ -1,11 +0,0 @@
1
- import { FormMetaDataModel, MetaDataJson } from './types';
2
- import Node from './Node';
3
- /**
4
- * Defines form metadata which implements {@link FormMetaDataModel | Form MetaData Model}
5
- */
6
- declare class FormMetaData extends Node<MetaDataJson> implements FormMetaDataModel {
7
- get version(): string;
8
- get locale(): string;
9
- get grammar(): string;
10
- }
11
- export default FormMetaData;
@@ -1,28 +0,0 @@
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 Node_1 = __importDefault(require("./Node"));
14
- /**
15
- * Defines form metadata which implements {@link FormMetaDataModel | Form MetaData Model}
16
- */
17
- class FormMetaData extends Node_1.default {
18
- get version() {
19
- return this.getP('version', '');
20
- }
21
- get locale() {
22
- return this.getP('locale', '');
23
- }
24
- get grammar() {
25
- return this.getP('grammar', '');
26
- }
27
- }
28
- exports.default = FormMetaData;