@aemforms/af-core 0.22.20 → 0.22.22

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 (53) hide show
  1. package/LICENSE +18 -4
  2. package/lib/cjs/index.cjs +267 -1876
  3. package/lib/esm/BaseNode-dc59ab07.js +478 -0
  4. package/lib/esm/BaseNode.js +26 -454
  5. package/lib/esm/Checkbox.js +37 -1
  6. package/lib/esm/CheckboxGroup.js +38 -1
  7. package/lib/esm/Container.js +30 -9
  8. package/lib/esm/DateField.js +38 -2
  9. package/lib/esm/Field.d.ts +2 -2
  10. package/lib/esm/Field.js +62 -26
  11. package/lib/esm/Fieldset.js +36 -3
  12. package/lib/esm/FileObject.js +23 -1
  13. package/lib/esm/FileUpload.js +34 -1
  14. package/lib/esm/Form.d.ts +1 -1
  15. package/lib/esm/Form.js +40 -8
  16. package/lib/esm/FormInstance.js +53 -5
  17. package/lib/esm/FormMetaData.js +26 -1
  18. package/lib/esm/InstanceManager.js +35 -8
  19. package/lib/esm/Node.js +25 -1
  20. package/lib/esm/Scriptable.js +29 -2
  21. package/lib/esm/controller/EventQueue.js +23 -1
  22. package/lib/esm/controller/Events.d.ts +1 -1
  23. package/lib/esm/controller/Events.js +41 -19
  24. package/lib/esm/controller/Logger.d.ts +2 -2
  25. package/lib/esm/controller/Logger.js +23 -1
  26. package/lib/esm/data/DataGroup.js +24 -1
  27. package/lib/esm/data/DataValue.js +23 -1
  28. package/lib/esm/data/EmptyDataValue.js +23 -1
  29. package/lib/esm/index.js +55 -21
  30. package/lib/esm/rules/FunctionRuntime.d.ts +3 -3
  31. package/lib/esm/rules/FunctionRuntime.js +31 -6
  32. package/lib/esm/rules/RuleEngine.js +30 -1
  33. package/lib/esm/types/Json.d.ts +16 -16
  34. package/lib/esm/types/Json.js +24 -2
  35. package/lib/esm/types/Model.d.ts +4 -4
  36. package/lib/esm/types/Model.js +23 -1
  37. package/lib/esm/types/index.js +22 -2
  38. package/lib/esm/utils/DataRefParser.d.ts +2 -2
  39. package/lib/esm/utils/DataRefParser.js +31 -6
  40. package/lib/esm/utils/Fetch.d.ts +1 -1
  41. package/lib/esm/utils/Fetch.js +24 -2
  42. package/lib/esm/utils/FormCreationUtils.js +40 -2
  43. package/lib/esm/utils/FormUtils.js +33 -8
  44. package/lib/esm/utils/JsonUtils.js +34 -11
  45. package/lib/esm/utils/LogUtils.js +23 -1
  46. package/lib/esm/utils/SchemaUtils.js +24 -2
  47. package/lib/esm/utils/TranslationUtils.d.ts +1 -1
  48. package/lib/esm/utils/TranslationUtils.js +32 -9
  49. package/lib/esm/utils/ValidationUtils.d.ts +4 -4
  50. package/lib/esm/utils/ValidationUtils.js +30 -4
  51. package/package.json +4 -3
  52. package/lib/browser/afb-events.js +0 -151
  53. package/lib/browser/afb-runtime.js +0 -3620
@@ -1,4 +1,24 @@
1
- export class ValidationError {
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 {
2
22
  fieldName;
3
23
  errorMessages;
4
24
  constructor(fieldName = '', errorMessages = []) {
@@ -6,3 +26,5 @@ export class ValidationError {
6
26
  this.fieldName = fieldName;
7
27
  }
8
28
  }
29
+
30
+ export { ValidationError };
@@ -1,2 +1,22 @@
1
- export * from './Json.js';
2
- export * from './Model.js';
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,8 +1,8 @@
1
1
  import DataGroup from '../data/DataGroup.js';
2
2
  import DataValue from '../data/DataValue.js';
3
- declare type TokenType = string;
3
+ type TokenType = string;
4
4
  export declare const TOK_GLOBAL: TokenType;
5
- export declare type Token = {
5
+ export type Token = {
6
6
  type: TokenType;
7
7
  value: string | number;
8
8
  start: number;
@@ -1,25 +1,48 @@
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
+
1
21
  import DataGroup from '../data/DataGroup.js';
22
+ import '../data/DataValue.js';
23
+ import '../data/EmptyDataValue.js';
24
+
2
25
  const TOK_DOT = 'DOT';
3
26
  const TOK_IDENTIFIER = 'Identifier';
4
- export const TOK_GLOBAL = 'Global';
27
+ const TOK_GLOBAL = 'Global';
5
28
  const TOK_BRACKET = 'bracket';
6
29
  const TOK_NUMBER = 'Number';
7
30
  const globalStartToken = '$';
8
- export const identifier = (value, start) => {
31
+ const identifier = (value, start) => {
9
32
  return {
10
33
  type: TOK_IDENTIFIER,
11
34
  value,
12
35
  start
13
36
  };
14
37
  };
15
- export const bracket = (value, start) => {
38
+ const bracket = (value, start) => {
16
39
  return {
17
40
  type: TOK_BRACKET,
18
41
  value,
19
42
  start
20
43
  };
21
44
  };
22
- export const global$ = () => {
45
+ const global$ = () => {
23
46
  return {
24
47
  type: TOK_GLOBAL,
25
48
  start: 0,
@@ -154,10 +177,10 @@ class Tokenizer {
154
177
  return this._result_tokens;
155
178
  }
156
179
  }
157
- export const tokenize = (stream) => {
180
+ const tokenize = (stream) => {
158
181
  return new Tokenizer(stream).tokenize();
159
182
  };
160
- export const resolveData = (data, input, create) => {
183
+ const resolveData = (data, input, create) => {
161
184
  let tokens;
162
185
  if (typeof input === 'string') {
163
186
  tokens = tokenize(input);
@@ -220,3 +243,5 @@ export const resolveData = (data, input, create) => {
220
243
  }
221
244
  return result;
222
245
  };
246
+
247
+ export { TOK_GLOBAL, bracket, global$, identifier, resolveData, tokenize };
@@ -1,5 +1,5 @@
1
1
  export declare const request: (url: string, data?: any, options?: RequestOptions) => any;
2
- export declare type RequestOptions = {
2
+ export type RequestOptions = {
3
3
  contentType?: string;
4
4
  method?: 'POST' | 'GET';
5
5
  headers?: any;
@@ -1,4 +1,24 @@
1
- export const request = (url, data = null, options = {}) => {
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 = {}) => {
2
22
  const opts = { ...defaultRequestOptions, ...options };
3
23
  const updatedUrl = opts.method === 'GET' && data ? convertQueryString(url, data) : url;
4
24
  if (opts.method !== 'GET') {
@@ -34,7 +54,7 @@ export const request = (url, data = null, options = {}) => {
34
54
  const defaultRequestOptions = {
35
55
  method: 'GET'
36
56
  };
37
- export const convertQueryString = (endpoint, payload) => {
57
+ const convertQueryString = (endpoint, payload) => {
38
58
  if (!payload) {
39
59
  return endpoint;
40
60
  }
@@ -59,3 +79,5 @@ export const convertQueryString = (endpoint, payload) => {
59
79
  }
60
80
  return endpoint.includes('?') ? `${endpoint}&${params.join('&')}` : `${endpoint}?${params.join('&')}`;
61
81
  };
82
+
83
+ export { convertQueryString, request };
@@ -1,11 +1,47 @@
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
+
1
21
  import { InstanceManager } from '../InstanceManager.js';
2
22
  import { Fieldset } from '../Fieldset.js';
3
- import { isCheckbox, isCheckboxGroup, isDateField, isFile, isRepeatable } from './JsonUtils.js';
23
+ import { isRepeatable, isFile, isCheckbox, isCheckboxGroup, isDateField } from './JsonUtils.js';
4
24
  import FileUpload from '../FileUpload.js';
5
25
  import Checkbox from '../Checkbox.js';
6
26
  import CheckboxGroup from '../CheckboxGroup.js';
7
27
  import DateField from '../DateField.js';
8
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
+
9
45
  const alternateFieldTypeMapping = {
10
46
  'text': 'text-input',
11
47
  'number': 'number-input',
@@ -71,4 +107,6 @@ class FormFieldFactoryImpl {
71
107
  return retVal;
72
108
  }
73
109
  }
74
- export const FormFieldFactory = new FormFieldFactoryImpl();
110
+ const FormFieldFactory = new FormFieldFactoryImpl();
111
+
112
+ export { FormFieldFactory };
@@ -1,8 +1,31 @@
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
+
1
21
  import { isFile } from './JsonUtils.js';
2
22
  import { FileObject } from '../FileObject.js';
23
+ import '../types/Json.js';
24
+ import './SchemaUtils.js';
25
+
3
26
  const chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_'.split('');
4
27
  const fileSizeRegex = /^(\d*\.?\d+)(\\?(?=[KMGT])([KMGT])(?:i?B)?|B?)$/i;
5
- export const randomWord = (l) => {
28
+ const randomWord = (l) => {
6
29
  const ret = [];
7
30
  for (let i = 0; i <= l; i++) {
8
31
  const randIndex = Math.floor(Math.random() * (chars.length));
@@ -10,10 +33,10 @@ export const randomWord = (l) => {
10
33
  }
11
34
  return ret.join('');
12
35
  };
13
- export const isEmpty = (value) => {
36
+ const isEmpty = (value) => {
14
37
  return value === '' || value === null || value === undefined;
15
38
  };
16
- export const getAttachments = (input) => {
39
+ const getAttachments = (input) => {
17
40
  const items = input.items || [];
18
41
  return items?.reduce((acc, item) => {
19
42
  let ret = null;
@@ -40,7 +63,7 @@ export const getAttachments = (input) => {
40
63
  return Object.assign(acc, ret);
41
64
  }, {});
42
65
  };
43
- export const getFileSizeInBytes = (str) => {
66
+ const getFileSizeInBytes = (str) => {
44
67
  let retVal = 0;
45
68
  if (typeof str === 'string') {
46
69
  const matches = fileSizeRegex.exec(str.trim());
@@ -55,7 +78,7 @@ const sizeToBytes = (size, symbol) => {
55
78
  const i = Math.pow(1024, sizes[symbol]);
56
79
  return Math.round(size * i);
57
80
  };
58
- export const IdGenerator = function* (initial = 50) {
81
+ const IdGenerator = function* (initial = 50) {
59
82
  const initialize = function () {
60
83
  const arr = [];
61
84
  for (let i = 0; i < initial; i++) {
@@ -80,11 +103,11 @@ export const IdGenerator = function* (initial = 50) {
80
103
  }
81
104
  } while (ids.length > 0);
82
105
  };
83
- export const isDataUrl = (str) => {
106
+ const isDataUrl = (str) => {
84
107
  const dataUrlRegex = /^data:([a-z]+\/[a-z0-9-+.]+)?;(?:name=(.*);)?base64,(.*)$/;
85
108
  return dataUrlRegex.exec(str.trim()) != null;
86
109
  };
87
- export const extractFileInfo = (file) => {
110
+ const extractFileInfo = (file) => {
88
111
  if (file !== null) {
89
112
  let retVal = null;
90
113
  if (file instanceof FileObject) {
@@ -160,7 +183,7 @@ export const extractFileInfo = (file) => {
160
183
  return null;
161
184
  }
162
185
  };
163
- export const dataURItoBlob = (dataURI) => {
186
+ const dataURItoBlob = (dataURI) => {
164
187
  const regex = /^data:([a-z]+\/[a-z0-9-+.]+)?(?:;name=([^;]+))?(;base64)?,(.+)$/;
165
188
  const groups = regex.exec(dataURI);
166
189
  if (groups !== null) {
@@ -185,3 +208,5 @@ export const dataURItoBlob = (dataURI) => {
185
208
  return null;
186
209
  }
187
210
  };
211
+
212
+ export { IdGenerator, dataURItoBlob, extractFileInfo, getAttachments, getFileSizeInBytes, isDataUrl, isEmpty, randomWord };
@@ -1,6 +1,27 @@
1
- import { constraintProps } from '../types/index.js';
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 { constraintProps } from '../types/Json.js';
2
22
  import { defaultFieldTypes } from './SchemaUtils.js';
3
- export const getProperty = (data, key, def) => {
23
+
24
+ const getProperty = (data, key, def) => {
4
25
  if (key in data) {
5
26
  return data[key];
6
27
  }
@@ -12,27 +33,27 @@ export const getProperty = (data, key, def) => {
12
33
  }
13
34
  return def;
14
35
  };
15
- export const isFile = function (item) {
36
+ const isFile = function (item) {
16
37
  return (item?.type === 'file' || item?.type === 'file[]') ||
17
38
  ((item?.type === 'string' || item?.type === 'string[]') &&
18
39
  (item?.format === 'binary' || item?.format === 'data-url'));
19
40
  };
20
- export const checkIfConstraintsArePresent = function (item) {
41
+ const checkIfConstraintsArePresent = function (item) {
21
42
  return constraintProps.some(cp => item[cp] !== undefined);
22
43
  };
23
- export const isCheckbox = function (item) {
44
+ const isCheckbox = function (item) {
24
45
  const fieldType = item?.fieldType || defaultFieldTypes(item);
25
46
  return fieldType === 'checkbox';
26
47
  };
27
- export const isCheckboxGroup = function (item) {
48
+ const isCheckboxGroup = function (item) {
28
49
  const fieldType = item?.fieldType || defaultFieldTypes(item);
29
50
  return fieldType === 'checkbox-group';
30
51
  };
31
- export const isDateField = function (item) {
52
+ const isDateField = function (item) {
32
53
  const fieldType = item?.fieldType || defaultFieldTypes(item);
33
54
  return (fieldType === 'text-input' && item?.format === 'date') || fieldType === 'date-input';
34
55
  };
35
- export function deepClone(obj, idGenerator) {
56
+ function deepClone(obj, idGenerator) {
36
57
  let result;
37
58
  if (obj instanceof Array) {
38
59
  result = [];
@@ -52,7 +73,7 @@ export function deepClone(obj, idGenerator) {
52
73
  }
53
74
  return result;
54
75
  }
55
- export function checkIfKeyAdded(currentObj, prevObj, objKey) {
76
+ function checkIfKeyAdded(currentObj, prevObj, objKey) {
56
77
  if (currentObj != null && prevObj != null) {
57
78
  const newPrvObj = { ...prevObj };
58
79
  newPrvObj[objKey] = currentObj[objKey];
@@ -63,10 +84,10 @@ export function checkIfKeyAdded(currentObj, prevObj, objKey) {
63
84
  return false;
64
85
  }
65
86
  }
66
- export const jsonString = (obj) => {
87
+ const jsonString = (obj) => {
67
88
  return JSON.stringify(obj, null, 2);
68
89
  };
69
- export const isRepeatable = (obj) => {
90
+ const isRepeatable = (obj) => {
70
91
  return ((obj.repeatable &&
71
92
  ((obj.minOccur === undefined && obj.maxOccur === undefined) ||
72
93
  (obj.minOccur !== undefined && obj.maxOccur !== undefined && obj.maxOccur !== 0) ||
@@ -74,3 +95,5 @@ export const isRepeatable = (obj) => {
74
95
  (obj.minOccur !== undefined && obj.minOccur >= 0) ||
75
96
  (obj.maxOccur !== undefined && obj.maxOccur !== 0))) || false);
76
97
  };
98
+
99
+ export { checkIfConstraintsArePresent, checkIfKeyAdded, deepClone, getProperty, isCheckbox, isCheckboxGroup, isDateField, isFile, isRepeatable, jsonString };
@@ -1,6 +1,28 @@
1
- export const logFormCallbacks = (callbacks) => {
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 logFormCallbacks = (callbacks) => {
2
22
  const s = Object.entries(callbacks).map(([id, fn]) => {
3
23
  return `${id} : ${fn.length}`;
4
24
  }).join(' ');
5
25
  console.log(s);
6
26
  };
27
+
28
+ export { logFormCallbacks };
@@ -1,3 +1,23 @@
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
+
1
21
  const objToMap = (o) => new Map(Object.entries(o));
2
22
  const stringViewTypes = objToMap({ 'date': 'date-input', 'data-url': 'file-input', 'binary': 'file-input' });
3
23
  const typeToViewTypes = objToMap({
@@ -9,7 +29,7 @@ const typeToViewTypes = objToMap({
9
29
  'file[]': 'file-input'
10
30
  });
11
31
  const arrayTypes = ['string[]', 'boolean[]', 'number[]', 'array'];
12
- export const defaultFieldTypes = (schema) => {
32
+ const defaultFieldTypes = (schema) => {
13
33
  const type = schema.type || 'string';
14
34
  if ('enum' in schema) {
15
35
  const enums = schema.enum;
@@ -66,6 +86,8 @@ const fieldSchema = (input) => {
66
86
  };
67
87
  }
68
88
  };
69
- export const exportDataSchema = (form) => {
89
+ const exportDataSchema = (form) => {
70
90
  return fieldSchema(form);
71
91
  };
92
+
93
+ export { defaultFieldTypes, exportDataSchema };
@@ -2,7 +2,7 @@ import { FieldJson, FieldsetJson, FormJson } from '../types/index.js';
2
2
  export declare const TRANSLATION_TOKEN = "##";
3
3
  export declare const TRANSLATION_ID = "afs:translationIds";
4
4
  export declare const CUSTOM_PROPS_KEY = "properties";
5
- declare type formElementJson = FieldJson | FieldsetJson | FormJson | any;
5
+ type formElementJson = FieldJson | FieldsetJson | FormJson | any;
6
6
  export declare const invalidateTranslation: (input: formElementJson, updates: any) => void;
7
7
  export declare const addTranslationId: (input: formElementJson, additionalTranslationProps?: string[]) => formElementJson;
8
8
  export declare const getOrElse: (input: any, key: string | string[], defaultValue?: any) => any;
@@ -1,7 +1,28 @@
1
- import { translationProps } from '../types/index.js';
2
- export const TRANSLATION_TOKEN = '##';
3
- export const TRANSLATION_ID = 'afs:translationIds';
4
- export const CUSTOM_PROPS_KEY = 'properties';
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 { translationProps } from '../types/Json.js';
22
+
23
+ const TRANSLATION_TOKEN = '##';
24
+ const TRANSLATION_ID = 'afs:translationIds';
25
+ const CUSTOM_PROPS_KEY = 'properties';
5
26
  const defaultBcp47LangTags = [
6
27
  'de-DE',
7
28
  'en-US',
@@ -14,14 +35,14 @@ const defaultBcp47LangTags = [
14
35
  'zh-CN',
15
36
  'zh-TW'
16
37
  ];
17
- export const invalidateTranslation = (input, updates) => {
38
+ const invalidateTranslation = (input, updates) => {
18
39
  translationProps.forEach((prop) => {
19
40
  if (prop in updates && input?.[CUSTOM_PROPS_KEY]?.[TRANSLATION_ID]?.[prop]) {
20
41
  delete input?.[CUSTOM_PROPS_KEY]?.[TRANSLATION_ID]?.[prop];
21
42
  }
22
43
  });
23
44
  };
24
- export const addTranslationId = (input, additionalTranslationProps = []) => {
45
+ const addTranslationId = (input, additionalTranslationProps = []) => {
25
46
  const model = input;
26
47
  const transProps = [...translationProps, ...additionalTranslationProps];
27
48
  _createTranslationId(model, '', transProps);
@@ -84,7 +105,7 @@ const _createTranslationObj = (input, translationObj, translationProps) => {
84
105
  }
85
106
  });
86
107
  };
87
- export const getOrElse = (input, key, defaultValue = null) => {
108
+ const getOrElse = (input, key, defaultValue = null) => {
88
109
  if (!key) {
89
110
  return defaultValue;
90
111
  }
@@ -96,13 +117,13 @@ export const getOrElse = (input, key, defaultValue = null) => {
96
117
  }
97
118
  return index == arr.length ? objValue : defaultValue;
98
119
  };
99
- export const createTranslationObj = (input, additionalTranslationProps = []) => {
120
+ const createTranslationObj = (input, additionalTranslationProps = []) => {
100
121
  const obj = {};
101
122
  const transProps = [...translationProps, ...additionalTranslationProps];
102
123
  _createTranslationObj(input, obj, transProps);
103
124
  return obj;
104
125
  };
105
- export const createTranslationObject = (input, additionalTranslationProps = [], bcp47LangTags = []) => {
126
+ const createTranslationObject = (input, additionalTranslationProps = [], bcp47LangTags = []) => {
106
127
  const transProps = [...translationProps, ...additionalTranslationProps];
107
128
  const inputCopy = JSON.parse(JSON.stringify(input));
108
129
  const obj = createTranslationObj(addTranslationId(inputCopy, additionalTranslationProps), transProps);
@@ -113,3 +134,5 @@ export const createTranslationObject = (input, additionalTranslationProps = [],
113
134
  }
114
135
  return [inputCopy, allLangs];
115
136
  };
137
+
138
+ export { CUSTOM_PROPS_KEY, TRANSLATION_ID, TRANSLATION_TOKEN, addTranslationId, createTranslationObj, createTranslationObject, getOrElse, invalidateTranslation };
@@ -1,9 +1,9 @@
1
- declare type ValidationResult = {
1
+ type ValidationResult = {
2
2
  valid: boolean;
3
3
  value: any;
4
4
  };
5
5
  export declare const coerceType: (param: any, type: 'string' | 'number' | 'boolean') => string | number | boolean;
6
- declare type ValidConstraintsType = {
6
+ type ValidConstraintsType = {
7
7
  date: ValidationConstraints[];
8
8
  string: ValidationConstraints[];
9
9
  number: ValidationConstraints[];
@@ -11,8 +11,8 @@ declare type ValidConstraintsType = {
11
11
  file: ValidationConstraints[];
12
12
  };
13
13
  export declare const ValidConstraints: ValidConstraintsType;
14
- export declare type ValidationConstraints = 'type' | 'format' | 'minimum' | 'maximum' | 'exclusiveMinimum' | 'exclusiveMaximum' | 'minItems' | 'maxItems' | 'uniqueItems' | 'minLength' | 'maxLength' | 'pattern' | 'required' | 'enum' | 'accept' | 'maxFileSize';
15
- declare type ConstraintsObject = {
14
+ export type ValidationConstraints = 'type' | 'format' | 'minimum' | 'maximum' | 'exclusiveMinimum' | 'exclusiveMaximum' | 'minItems' | 'maxItems' | 'uniqueItems' | 'minLength' | 'maxLength' | 'pattern' | 'required' | 'enum' | 'accept' | 'maxFileSize';
15
+ type ConstraintsObject = {
16
16
  [key in ValidationConstraints]: (constraint: any, inputVal: any) => ValidationResult;
17
17
  };
18
18
  export declare const Constraints: ConstraintsObject;