@aemforms/af-core 0.22.22 → 0.22.25

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 (76) hide show
  1. package/README.md +14 -5
  2. package/package.json +2 -14
  3. package/lib/cjs/index.cjs +0 -7277
  4. package/lib/esm/BaseNode-dc59ab07.js +0 -478
  5. package/lib/esm/BaseNode.d.ts +0 -93
  6. package/lib/esm/BaseNode.js +0 -26
  7. package/lib/esm/Checkbox.d.ts +0 -79
  8. package/lib/esm/Checkbox.js +0 -63
  9. package/lib/esm/CheckboxGroup.d.ts +0 -18
  10. package/lib/esm/CheckboxGroup.js +0 -60
  11. package/lib/esm/Container.d.ts +0 -53
  12. package/lib/esm/Container.js +0 -311
  13. package/lib/esm/DateField.d.ts +0 -5
  14. package/lib/esm/DateField.js +0 -57
  15. package/lib/esm/Field.d.ts +0 -206
  16. package/lib/esm/Field.js +0 -692
  17. package/lib/esm/Fieldset.d.ts +0 -16
  18. package/lib/esm/Fieldset.js +0 -78
  19. package/lib/esm/FileObject.d.ts +0 -16
  20. package/lib/esm/FileObject.js +0 -48
  21. package/lib/esm/FileUpload.d.ts +0 -22
  22. package/lib/esm/FileUpload.js +0 -141
  23. package/lib/esm/Form.d.ts +0 -113
  24. package/lib/esm/Form.js +0 -208
  25. package/lib/esm/FormInstance.d.ts +0 -13
  26. package/lib/esm/FormInstance.js +0 -129
  27. package/lib/esm/FormMetaData.d.ts +0 -7
  28. package/lib/esm/FormMetaData.js +0 -35
  29. package/lib/esm/InstanceManager.d.ts +0 -9
  30. package/lib/esm/InstanceManager.js +0 -58
  31. package/lib/esm/Node.d.ts +0 -7
  32. package/lib/esm/Node.js +0 -40
  33. package/lib/esm/Scriptable.d.ts +0 -17
  34. package/lib/esm/Scriptable.js +0 -190
  35. package/lib/esm/controller/EventQueue.d.ts +0 -17
  36. package/lib/esm/controller/EventQueue.js +0 -108
  37. package/lib/esm/controller/Events.d.ts +0 -85
  38. package/lib/esm/controller/Events.js +0 -171
  39. package/lib/esm/controller/Logger.d.ts +0 -11
  40. package/lib/esm/controller/Logger.js +0 -52
  41. package/lib/esm/data/DataGroup.d.ts +0 -20
  42. package/lib/esm/data/DataGroup.js +0 -100
  43. package/lib/esm/data/DataValue.d.ts +0 -16
  44. package/lib/esm/data/DataValue.js +0 -68
  45. package/lib/esm/data/EmptyDataValue.d.ts +0 -14
  46. package/lib/esm/data/EmptyDataValue.js +0 -51
  47. package/lib/esm/index.d.ts +0 -21
  48. package/lib/esm/index.js +0 -55
  49. package/lib/esm/rules/FunctionRuntime.d.ts +0 -51
  50. package/lib/esm/rules/FunctionRuntime.js +0 -345
  51. package/lib/esm/rules/RuleEngine.d.ts +0 -12
  52. package/lib/esm/rules/RuleEngine.js +0 -76
  53. package/lib/esm/types/Json.d.ts +0 -119
  54. package/lib/esm/types/Json.js +0 -29
  55. package/lib/esm/types/Model.d.ts +0 -131
  56. package/lib/esm/types/Model.js +0 -30
  57. package/lib/esm/types/index.d.ts +0 -2
  58. package/lib/esm/types/index.js +0 -22
  59. package/lib/esm/utils/DataRefParser.d.ts +0 -27
  60. package/lib/esm/utils/DataRefParser.js +0 -247
  61. package/lib/esm/utils/Fetch.d.ts +0 -8
  62. package/lib/esm/utils/Fetch.js +0 -83
  63. package/lib/esm/utils/FormCreationUtils.d.ts +0 -9
  64. package/lib/esm/utils/FormCreationUtils.js +0 -112
  65. package/lib/esm/utils/FormUtils.d.ts +0 -12
  66. package/lib/esm/utils/FormUtils.js +0 -212
  67. package/lib/esm/utils/JsonUtils.d.ts +0 -11
  68. package/lib/esm/utils/JsonUtils.js +0 -99
  69. package/lib/esm/utils/LogUtils.d.ts +0 -4
  70. package/lib/esm/utils/LogUtils.js +0 -28
  71. package/lib/esm/utils/SchemaUtils.d.ts +0 -3
  72. package/lib/esm/utils/SchemaUtils.js +0 -93
  73. package/lib/esm/utils/TranslationUtils.d.ts +0 -11
  74. package/lib/esm/utils/TranslationUtils.js +0 -138
  75. package/lib/esm/utils/ValidationUtils.d.ts +0 -19
  76. package/lib/esm/utils/ValidationUtils.js +0 -300
@@ -1,131 +0,0 @@
1
- import { ConstraintsJson, ContainerJson, FieldJson, FieldsetJson, FormJson, Label, MetaDataJson } from './Json.js';
2
- import RuleEngine from '../rules/RuleEngine.js';
3
- import EventQueue from '../controller/EventQueue.js';
4
- import DataGroup from '../data/DataGroup.js';
5
- import { Logger } from '../controller/Logger.js';
6
- export interface ScriptableField {
7
- rules?: {
8
- [key: string]: string;
9
- };
10
- events?: {
11
- [key: string]: string;
12
- };
13
- ruleEngine: RuleEngine;
14
- }
15
- interface WithState<T> {
16
- getState: () => any;
17
- }
18
- type stateProps = {
19
- id: string;
20
- index: number;
21
- ':type': string;
22
- };
23
- export type State<T> = stateProps & (T extends ContainerJson ? T & {
24
- items: Array<State<FieldJson | ContainerJson>>;
25
- } : T);
26
- export type Subscription = {
27
- unsubscribe(): void;
28
- };
29
- export interface Action {
30
- type: string;
31
- payload: any;
32
- metadata: any;
33
- readonly isCustomEvent: boolean;
34
- readonly target: FormModel | FieldModel | FieldsetModel;
35
- readonly originalAction?: Action;
36
- }
37
- export type callbackFn = (action: Action) => void;
38
- export interface WithController {
39
- subscribe(callback: callbackFn, eventName?: string): Subscription;
40
- dispatch(action: Action): void;
41
- }
42
- export interface BaseModel extends ConstraintsJson, WithController {
43
- readonly name?: string;
44
- readonly dataRef?: string | null;
45
- readonly id: string;
46
- readonly index: number;
47
- readonly qualifiedName: string;
48
- label?: Label;
49
- description?: string;
50
- readOnly?: boolean;
51
- enabled?: boolean;
52
- visible?: boolean;
53
- placeholder?: string;
54
- valid?: boolean;
55
- readonly ':type': string;
56
- readonly 'fieldType': string;
57
- properties: {
58
- [key: string]: any;
59
- };
60
- readonly isContainer: boolean;
61
- readonly parent: ContainerModel | null;
62
- readonly items?: Array<FieldsetModel | FieldModel>;
63
- value: any;
64
- readonly default?: any;
65
- readonly repeatable?: boolean;
66
- readonly language?: string;
67
- validate(): Array<ValidationError>;
68
- reset(): any;
69
- importData(a?: DataGroup): any;
70
- getRuleNode(): any;
71
- ruleNodeReference(): any;
72
- _initialize(): any;
73
- _addDependent(dependent: BaseModel): any;
74
- }
75
- export interface FieldModel extends BaseModel, ScriptableField, WithState<FieldJson> {
76
- parent: ContainerModel;
77
- readonly editFormat?: string;
78
- readonly displayFormat?: string;
79
- readonly displayValue?: string;
80
- readonly editValue?: string;
81
- }
82
- export interface FormMetaDataModel {
83
- readonly version: string;
84
- readonly grammar: string;
85
- }
86
- export interface ContainerModel extends BaseModel, ScriptableField {
87
- items: Array<FieldsetModel | FieldModel>;
88
- parent: ContainerModel;
89
- indexOf(f: FieldModel | FieldsetModel): number;
90
- isTransparent(): boolean;
91
- activeChild: BaseModel | null;
92
- }
93
- export interface FieldsetModel extends ContainerModel, WithState<FieldsetJson> {
94
- type?: 'array' | 'object';
95
- }
96
- export interface FormModel extends ContainerModel, WithState<FormJson> {
97
- readonly id: string;
98
- readonly data?: any;
99
- readonly metadata?: MetaDataJson;
100
- readonly title: string;
101
- readonly logger: Logger;
102
- importData(data: any): any;
103
- exportData(): any;
104
- getElement(id: string): FieldModel | FormModel | FieldsetModel;
105
- getUniqueId(): string;
106
- getEventQueue(): EventQueue;
107
- visit(callBack: (field: FieldModel | FieldsetModel) => void): void;
108
- fieldAdded(field: FieldModel | FieldsetModel): void;
109
- }
110
- export interface IFormFieldFactory {
111
- createField(child: FieldsetJson | FieldJson, options: {
112
- form: FormModel;
113
- parent: ContainerModel;
114
- }): FieldModel | FieldsetModel;
115
- }
116
- export interface IFileObject {
117
- name: string;
118
- mediaType: string;
119
- data?: any;
120
- size?: number;
121
- }
122
- export interface IValidationError {
123
- fieldName: string;
124
- errorMessages: Array<string>;
125
- }
126
- export declare class ValidationError implements IValidationError {
127
- fieldName: string;
128
- errorMessages: Array<string>;
129
- constructor(fieldName?: string, errorMessages?: Array<any>);
130
- }
131
- export {};
@@ -1,30 +0,0 @@
1
- /*************************************************************************
2
- * ADOBE CONFIDENTIAL
3
- * ___________________
4
- *
5
- * Copyright 2022 Adobe
6
- * All Rights Reserved.
7
- *
8
- * NOTICE: All information contained herein is, and remains
9
- * the property of Adobe and its suppliers, if any. The intellectual
10
- * and technical concepts contained herein are proprietary to Adobe
11
- * and its suppliers and are protected by all applicable intellectual
12
- * property laws, including trade secret and copyright laws.
13
- * Dissemination of this information or reproduction of this material
14
- * is strictly forbidden unless prior written permission is obtained
15
- * from Adobe.
16
-
17
- * Adobe permits you to use and modify this file solely in accordance with
18
- * the terms of the Adobe license agreement accompanying it.
19
- *************************************************************************/
20
-
21
- class ValidationError {
22
- fieldName;
23
- errorMessages;
24
- constructor(fieldName = '', errorMessages = []) {
25
- this.errorMessages = errorMessages;
26
- this.fieldName = fieldName;
27
- }
28
- }
29
-
30
- export { ValidationError };
@@ -1,2 +0,0 @@
1
- export * from './Json.js';
2
- export * from './Model.js';
@@ -1,22 +0,0 @@
1
- /*************************************************************************
2
- * ADOBE CONFIDENTIAL
3
- * ___________________
4
- *
5
- * Copyright 2022 Adobe
6
- * All Rights Reserved.
7
- *
8
- * NOTICE: All information contained herein is, and remains
9
- * the property of Adobe and its suppliers, if any. The intellectual
10
- * and technical concepts contained herein are proprietary to Adobe
11
- * and its suppliers and are protected by all applicable intellectual
12
- * property laws, including trade secret and copyright laws.
13
- * Dissemination of this information or reproduction of this material
14
- * is strictly forbidden unless prior written permission is obtained
15
- * from Adobe.
16
-
17
- * Adobe permits you to use and modify this file solely in accordance with
18
- * the terms of the Adobe license agreement accompanying it.
19
- *************************************************************************/
20
-
21
- export { constraintProps, translationProps } from './Json.js';
22
- export { ValidationError } from './Model.js';
@@ -1,27 +0,0 @@
1
- import DataGroup from '../data/DataGroup.js';
2
- import DataValue from '../data/DataValue.js';
3
- type TokenType = string;
4
- export declare const TOK_GLOBAL: TokenType;
5
- export type Token = {
6
- type: TokenType;
7
- value: string | number;
8
- start: number;
9
- };
10
- export declare const identifier: (value: string, start: number) => {
11
- type: string;
12
- value: string;
13
- start: number;
14
- };
15
- export declare const bracket: (value: number, start: number) => {
16
- type: string;
17
- value: number;
18
- start: number;
19
- };
20
- export declare const global$: () => {
21
- type: string;
22
- start: number;
23
- value: string;
24
- };
25
- export declare const tokenize: (stream: string) => Token[];
26
- export declare const resolveData: <T extends DataValue>(data: DataGroup, input: Token[] | string, create?: T | undefined) => DataGroup | DataValue | undefined;
27
- export {};
@@ -1,247 +0,0 @@
1
- /*************************************************************************
2
- * ADOBE CONFIDENTIAL
3
- * ___________________
4
- *
5
- * Copyright 2022 Adobe
6
- * All Rights Reserved.
7
- *
8
- * NOTICE: All information contained herein is, and remains
9
- * the property of Adobe and its suppliers, if any. The intellectual
10
- * and technical concepts contained herein are proprietary to Adobe
11
- * and its suppliers and are protected by all applicable intellectual
12
- * property laws, including trade secret and copyright laws.
13
- * Dissemination of this information or reproduction of this material
14
- * is strictly forbidden unless prior written permission is obtained
15
- * from Adobe.
16
-
17
- * Adobe permits you to use and modify this file solely in accordance with
18
- * the terms of the Adobe license agreement accompanying it.
19
- *************************************************************************/
20
-
21
- import DataGroup from '../data/DataGroup.js';
22
- import '../data/DataValue.js';
23
- import '../data/EmptyDataValue.js';
24
-
25
- const TOK_DOT = 'DOT';
26
- const TOK_IDENTIFIER = 'Identifier';
27
- const TOK_GLOBAL = 'Global';
28
- const TOK_BRACKET = 'bracket';
29
- const TOK_NUMBER = 'Number';
30
- const globalStartToken = '$';
31
- const identifier = (value, start) => {
32
- return {
33
- type: TOK_IDENTIFIER,
34
- value,
35
- start
36
- };
37
- };
38
- const bracket = (value, start) => {
39
- return {
40
- type: TOK_BRACKET,
41
- value,
42
- start
43
- };
44
- };
45
- const global$ = () => {
46
- return {
47
- type: TOK_GLOBAL,
48
- start: 0,
49
- value: globalStartToken
50
- };
51
- };
52
- const isAlphaNum = function (ch) {
53
- return (ch >= 'a' && ch <= 'z')
54
- || (ch >= 'A' && ch <= 'Z')
55
- || (ch >= '0' && ch <= '9')
56
- || ch === '_';
57
- };
58
- const isGlobal = (prev, stream, pos) => {
59
- return prev === null && stream[pos] === globalStartToken;
60
- };
61
- const isIdentifier = (stream, pos) => {
62
- const ch = stream[pos];
63
- if (ch === '$') {
64
- return stream.length > pos && isAlphaNum(stream[pos + 1]);
65
- }
66
- return (ch >= 'a' && ch <= 'z')
67
- || (ch >= 'A' && ch <= 'Z')
68
- || ch === '_';
69
- };
70
- const isNum = (ch) => {
71
- return (ch >= '0' && ch <= '9');
72
- };
73
- class Tokenizer {
74
- stream;
75
- _current;
76
- _tokens = [];
77
- _result_tokens = [];
78
- constructor(stream) {
79
- this.stream = stream;
80
- this._current = 0;
81
- }
82
- _consumeGlobal() {
83
- this._current += 1;
84
- return global$();
85
- }
86
- _consumeUnquotedIdentifier(stream) {
87
- const start = this._current;
88
- this._current += 1;
89
- while (this._current < stream.length && isAlphaNum(stream[this._current])) {
90
- this._current += 1;
91
- }
92
- return identifier(stream.slice(start, this._current), start);
93
- }
94
- _consumeQuotedIdentifier(stream) {
95
- const start = this._current;
96
- this._current += 1;
97
- const maxLength = stream.length;
98
- while (stream[this._current] !== '"' && this._current < maxLength) {
99
- let current = this._current;
100
- if (stream[current] === '\\' && (stream[current + 1] === '\\'
101
- || stream[current + 1] === '"')) {
102
- current += 2;
103
- }
104
- else {
105
- current += 1;
106
- }
107
- this._current = current;
108
- }
109
- this._current += 1;
110
- return identifier(JSON.parse(stream.slice(start, this._current)), start);
111
- }
112
- _consumeNumber(stream) {
113
- const start = this._current;
114
- this._current += 1;
115
- const maxLength = stream.length;
116
- while (isNum(stream[this._current]) && this._current < maxLength) {
117
- this._current += 1;
118
- }
119
- const n = stream.slice(start, this._current);
120
- const value = parseInt(n, 10);
121
- return { type: TOK_NUMBER, value, start };
122
- }
123
- _consumeBracket(stream) {
124
- const start = this._current;
125
- this._current += 1;
126
- let value;
127
- if (isNum(stream[this._current])) {
128
- value = this._consumeNumber(stream).value;
129
- }
130
- else {
131
- throw new Error(`unexpected exception at position ${this._current}. Must be a character`);
132
- }
133
- if (this._current < this.stream.length && stream[this._current] !== ']') {
134
- throw new Error(`unexpected exception at position ${this._current}. Must be a character`);
135
- }
136
- this._current++;
137
- return bracket(value, start);
138
- }
139
- tokenize() {
140
- const stream = this.stream;
141
- while (this._current < stream.length) {
142
- const prev = this._tokens.length ? this._tokens.slice(-1)[0] : null;
143
- if (isGlobal(prev, stream, this._current)) {
144
- const token = this._consumeGlobal();
145
- this._tokens.push(token);
146
- this._result_tokens.push(token);
147
- }
148
- else if (isIdentifier(stream, this._current)) {
149
- const token = this._consumeUnquotedIdentifier(stream);
150
- this._tokens.push(token);
151
- this._result_tokens.push(token);
152
- }
153
- else if (stream[this._current] === '.' && prev != null && prev.type !== TOK_DOT) {
154
- this._tokens.push({
155
- type: TOK_DOT,
156
- value: '.',
157
- start: this._current
158
- });
159
- this._current += 1;
160
- }
161
- else if (stream[this._current] === '[') {
162
- const token = this._consumeBracket(stream);
163
- this._tokens.push(token);
164
- this._result_tokens.push(token);
165
- }
166
- else if (stream[this._current] === '"') {
167
- const token = this._consumeQuotedIdentifier(stream);
168
- this._tokens.push(token);
169
- this._result_tokens.push(token);
170
- }
171
- else {
172
- const p = Math.max(0, this._current - 2);
173
- const s = Math.min(this.stream.length, this._current + 2);
174
- throw new Error(`Exception at parsing stream ${this.stream.slice(p, s)}`);
175
- }
176
- }
177
- return this._result_tokens;
178
- }
179
- }
180
- const tokenize = (stream) => {
181
- return new Tokenizer(stream).tokenize();
182
- };
183
- const resolveData = (data, input, create) => {
184
- let tokens;
185
- if (typeof input === 'string') {
186
- tokens = tokenize(input);
187
- }
188
- else {
189
- tokens = input;
190
- }
191
- let result = data;
192
- let i = 0;
193
- const createIntermediateNode = (token, nextToken, create) => {
194
- return nextToken === null ? create :
195
- (nextToken.type === TOK_BRACKET) ? new DataGroup(token.value, [], 'array') :
196
- new DataGroup(token.value, {});
197
- };
198
- while (i < tokens.length && result != null) {
199
- const token = tokens[i];
200
- if (token.type === TOK_GLOBAL) {
201
- result = data;
202
- }
203
- else if (token.type === TOK_IDENTIFIER) {
204
- if (result instanceof DataGroup && result.$type === 'object') {
205
- if (result.$containsDataNode(token.value) && result.$getDataNode(token.value).$value !== null) {
206
- result = result.$getDataNode(token.value);
207
- }
208
- else if (create) {
209
- const nextToken = i < tokens.length - 1 ? tokens[i + 1] : null;
210
- const toCreate = createIntermediateNode(token, nextToken, create);
211
- result.$addDataNode(token.value, toCreate);
212
- result = toCreate;
213
- }
214
- else {
215
- result = undefined;
216
- }
217
- }
218
- else {
219
- throw new Error(`Looking for ${token.value} in ${result.$value}`);
220
- }
221
- }
222
- else if (token.type === TOK_BRACKET) {
223
- if (result instanceof DataGroup && result.$type === 'array') {
224
- const index = token.value;
225
- if (index < result.$length) {
226
- result = result.$getDataNode(index);
227
- }
228
- else if (create) {
229
- const nextToken = i < tokens.length - 1 ? tokens[i + 1] : null;
230
- const toCreate = createIntermediateNode(token, nextToken, create);
231
- result.$addDataNode(index, toCreate);
232
- result = toCreate;
233
- }
234
- else {
235
- result = undefined;
236
- }
237
- }
238
- else {
239
- throw new Error(`Looking for index ${token.value} in non array${result.$value}`);
240
- }
241
- }
242
- i += 1;
243
- }
244
- return result;
245
- };
246
-
247
- export { TOK_GLOBAL, bracket, global$, identifier, resolveData, tokenize };
@@ -1,8 +0,0 @@
1
- export declare const request: (url: string, data?: any, options?: RequestOptions) => any;
2
- export type RequestOptions = {
3
- contentType?: string;
4
- method?: 'POST' | 'GET';
5
- headers?: any;
6
- mode?: string;
7
- };
8
- export declare const convertQueryString: (endpoint: string, payload: string | null) => string;
@@ -1,83 +0,0 @@
1
- /*************************************************************************
2
- * ADOBE CONFIDENTIAL
3
- * ___________________
4
- *
5
- * Copyright 2022 Adobe
6
- * All Rights Reserved.
7
- *
8
- * NOTICE: All information contained herein is, and remains
9
- * the property of Adobe and its suppliers, if any. The intellectual
10
- * and technical concepts contained herein are proprietary to Adobe
11
- * and its suppliers and are protected by all applicable intellectual
12
- * property laws, including trade secret and copyright laws.
13
- * Dissemination of this information or reproduction of this material
14
- * is strictly forbidden unless prior written permission is obtained
15
- * from Adobe.
16
-
17
- * Adobe permits you to use and modify this file solely in accordance with
18
- * the terms of the Adobe license agreement accompanying it.
19
- *************************************************************************/
20
-
21
- const request = (url, data = null, options = {}) => {
22
- const opts = { ...defaultRequestOptions, ...options };
23
- const updatedUrl = opts.method === 'GET' && data ? convertQueryString(url, data) : url;
24
- if (opts.method !== 'GET') {
25
- opts.body = data;
26
- }
27
- return fetch(updatedUrl, {
28
- ...opts
29
- }).then(async (response) => {
30
- let body;
31
- if (!response.ok) {
32
- console.error(`Error fetching response from ${url} : ${response.statusText}`);
33
- body = response.statusText;
34
- }
35
- else {
36
- if (response?.headers?.get('Content-Type')?.includes('application/json')) {
37
- body = await response.json();
38
- }
39
- else {
40
- body = await response.text();
41
- }
42
- }
43
- const headers = {};
44
- response?.headers?.forEach((value, key) => {
45
- headers[key] = value;
46
- });
47
- return {
48
- status: response.status,
49
- body,
50
- headers
51
- };
52
- });
53
- };
54
- const defaultRequestOptions = {
55
- method: 'GET'
56
- };
57
- const convertQueryString = (endpoint, payload) => {
58
- if (!payload) {
59
- return endpoint;
60
- }
61
- let updatedPayload = {};
62
- try {
63
- updatedPayload = JSON.parse(payload);
64
- }
65
- catch (err) {
66
- console.log('Query params invalid');
67
- }
68
- const params = [];
69
- Object.keys(updatedPayload).forEach((key) => {
70
- if (Array.isArray(updatedPayload[key])) {
71
- params.push(`${encodeURIComponent(key)}=${encodeURIComponent(JSON.stringify(updatedPayload[key]))}`);
72
- }
73
- else {
74
- params.push(`${encodeURIComponent(key)}=${encodeURIComponent(updatedPayload[key])}`);
75
- }
76
- });
77
- if (!params.length) {
78
- return endpoint;
79
- }
80
- return endpoint.includes('?') ? `${endpoint}&${params.join('&')}` : `${endpoint}?${params.join('&')}`;
81
- };
82
-
83
- export { convertQueryString, request };
@@ -1,9 +0,0 @@
1
- import { ContainerModel, FieldJson, FieldModel, FieldsetJson, FieldsetModel, FormModel, IFormFieldFactory } from '../types/index.js';
2
- declare class FormFieldFactoryImpl implements IFormFieldFactory {
3
- createField(child: FieldsetJson | FieldJson, _options: {
4
- form: FormModel;
5
- parent: ContainerModel;
6
- }): FieldModel | FieldsetModel;
7
- }
8
- export declare const FormFieldFactory: FormFieldFactoryImpl;
9
- export {};
@@ -1,112 +0,0 @@
1
- /*************************************************************************
2
- * ADOBE CONFIDENTIAL
3
- * ___________________
4
- *
5
- * Copyright 2022 Adobe
6
- * All Rights Reserved.
7
- *
8
- * NOTICE: All information contained herein is, and remains
9
- * the property of Adobe and its suppliers, if any. The intellectual
10
- * and technical concepts contained herein are proprietary to Adobe
11
- * and its suppliers and are protected by all applicable intellectual
12
- * property laws, including trade secret and copyright laws.
13
- * Dissemination of this information or reproduction of this material
14
- * is strictly forbidden unless prior written permission is obtained
15
- * from Adobe.
16
-
17
- * Adobe permits you to use and modify this file solely in accordance with
18
- * the terms of the Adobe license agreement accompanying it.
19
- *************************************************************************/
20
-
21
- import { InstanceManager } from '../InstanceManager.js';
22
- import { Fieldset } from '../Fieldset.js';
23
- import { isRepeatable, isFile, isCheckbox, isCheckboxGroup, isDateField } from './JsonUtils.js';
24
- import FileUpload from '../FileUpload.js';
25
- import Checkbox from '../Checkbox.js';
26
- import CheckboxGroup from '../CheckboxGroup.js';
27
- import DateField from '../DateField.js';
28
- import Field from '../Field.js';
29
- import '../BaseNode-dc59ab07.js';
30
- import '../controller/Events.js';
31
- import './DataRefParser.js';
32
- import '../data/DataGroup.js';
33
- import '../data/DataValue.js';
34
- import '../data/EmptyDataValue.js';
35
- import '../Container.js';
36
- import '../Scriptable.js';
37
- import '../types/Json.js';
38
- import './SchemaUtils.js';
39
- import './FormUtils.js';
40
- import '../FileObject.js';
41
- import './ValidationUtils.js';
42
- import '../types/Model.js';
43
- import '@aemforms/af-formatters';
44
-
45
- const alternateFieldTypeMapping = {
46
- 'text': 'text-input',
47
- 'number': 'number-input',
48
- 'email': 'text-input',
49
- 'file': 'file-input',
50
- 'range': 'range',
51
- 'textarea': 'multiline-input'
52
- };
53
- class FormFieldFactoryImpl {
54
- createField(child, _options) {
55
- let retVal;
56
- const options = {
57
- ..._options,
58
- fieldFactory: this
59
- };
60
- child.fieldType = child.fieldType ? (child.fieldType in alternateFieldTypeMapping ?
61
- alternateFieldTypeMapping[child.fieldType] : child.fieldType)
62
- : 'text-input';
63
- if (isRepeatable(child)) {
64
- const newChild = {
65
- ...child,
66
- ...('items' in child && { 'type': 'object' }),
67
- minOccur: undefined,
68
- maxOccur: undefined,
69
- repeatable: undefined,
70
- name: undefined
71
- };
72
- const newJson = {
73
- ...{
74
- minItems: child.minOccur || 0,
75
- maxItems: child.maxOccur || -1,
76
- fieldType: child.fieldType,
77
- type: 'array',
78
- name: child.name,
79
- dataRef: child.dataRef
80
- },
81
- ...{
82
- 'items': [newChild]
83
- }
84
- };
85
- retVal = new InstanceManager(newJson, options);
86
- }
87
- else if ('items' in child) {
88
- retVal = new Fieldset(child, options);
89
- }
90
- else {
91
- if (isFile(child) || child.fieldType === 'file-input') {
92
- retVal = new FileUpload(child, options);
93
- }
94
- else if (isCheckbox(child)) {
95
- retVal = new Checkbox(child, options);
96
- }
97
- else if (isCheckboxGroup(child)) {
98
- retVal = new CheckboxGroup(child, options);
99
- }
100
- else if (isDateField(child)) {
101
- retVal = new DateField(child, options);
102
- }
103
- else {
104
- retVal = new Field(child, options);
105
- }
106
- }
107
- return retVal;
108
- }
109
- }
110
- const FormFieldFactory = new FormFieldFactoryImpl();
111
-
112
- export { FormFieldFactory };
@@ -1,12 +0,0 @@
1
- import { ContainerModel } from '../types/index.js';
2
- export declare const randomWord: (l: number) => string;
3
- export declare const isEmpty: (value: any) => boolean;
4
- export declare const getAttachments: (input: ContainerModel) => any;
5
- export declare const getFileSizeInBytes: (str: any) => number;
6
- export declare const IdGenerator: (initial?: number) => Generator<string, void, string>;
7
- export declare const isDataUrl: (str: string) => boolean;
8
- export declare const extractFileInfo: (file: any) => any;
9
- export declare const dataURItoBlob: (dataURI: string) => {
10
- name: string;
11
- blob: Blob;
12
- } | null;