@aemforms/af-core 0.22.30 → 0.22.32
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.
- package/lib/{esm/BaseNode.d.ts → BaseNode.d.ts} +8 -8
- package/lib/{esm/BaseNode-d78cc1b0.js → BaseNode.js} +72 -97
- package/lib/{esm/Checkbox.d.ts → Checkbox.d.ts} +1 -1
- package/lib/Checkbox.js +29 -0
- package/lib/{esm/CheckboxGroup.d.ts → CheckboxGroup.d.ts} +2 -2
- package/lib/CheckboxGroup.js +24 -0
- package/lib/{esm/Container.d.ts → Container.d.ts} +4 -4
- package/lib/{esm/Container.js → Container.js} +51 -77
- package/lib/{esm/DateField.d.ts → DateField.d.ts} +1 -1
- package/lib/DateField.js +26 -0
- package/lib/{esm/Field.d.ts → Field.d.ts} +10 -9
- package/lib/{esm/Field.js → Field.js} +97 -105
- package/lib/Fieldset.d.ts +72 -0
- package/lib/Fieldset.js +89 -0
- package/lib/{esm/FileObject.d.ts → FileObject.d.ts} +1 -1
- package/lib/FileObject.js +29 -0
- package/lib/{esm/FileUpload.d.ts → FileUpload.d.ts} +3 -3
- package/lib/FileUpload.js +124 -0
- package/lib/{esm/Form.d.ts → Form.d.ts} +13 -13
- package/lib/{esm/Form.js → Form.js} +34 -68
- package/lib/{esm/FormInstance.d.ts → FormInstance.d.ts} +3 -3
- package/lib/FormInstance.js +94 -0
- package/lib/{esm/FormMetaData.d.ts → FormMetaData.d.ts} +2 -2
- package/lib/FormMetaData.js +15 -0
- package/lib/{esm/InstanceManager.d.ts → InstanceManager.d.ts} +2 -2
- package/lib/InstanceManager.js +35 -0
- package/lib/{esm/Node.d.ts → Node.d.ts} +0 -0
- package/lib/Node.js +15 -0
- package/lib/{esm/Scriptable.d.ts → Scriptable.d.ts} +3 -3
- package/lib/{esm/Scriptable.js → Scriptable.js} +17 -38
- package/lib/{esm/controller → controller}/EventQueue.d.ts +3 -3
- package/lib/{esm/controller → controller}/EventQueue.js +8 -32
- package/lib/{esm/controller → controller}/Events.d.ts +2 -2
- package/lib/{esm/controller → controller}/Events.js +22 -26
- package/lib/{esm/controller → controller}/Logger.d.ts +2 -2
- package/lib/controller/Logger.js +33 -0
- package/lib/{esm/data → data}/DataGroup.d.ts +1 -1
- package/lib/{esm/data → data}/DataGroup.js +20 -38
- package/lib/{esm/data → data}/DataValue.d.ts +1 -1
- package/lib/{esm/data → data}/DataValue.js +4 -26
- package/lib/{esm/data → data}/EmptyDataValue.d.ts +1 -1
- package/lib/data/EmptyDataValue.js +34 -0
- package/lib/index.d.ts +21 -0
- package/lib/index.js +57 -0
- package/lib/{esm/rules → rules}/FunctionRuntime.d.ts +3 -3
- package/lib/{esm/rules → rules}/FunctionRuntime.js +52 -63
- package/lib/{esm/rules → rules}/RuleEngine.d.ts +1 -1
- package/lib/rules/RuleEngine.js +51 -0
- package/lib/{esm/types → types}/Json.d.ts +18 -16
- package/lib/types/Json.js +10 -0
- package/lib/{esm/types → types}/Model.d.ts +10 -10
- package/lib/types/Model.js +10 -0
- package/lib/types/index.d.ts +2 -0
- package/lib/types/index.js +18 -0
- package/lib/{esm/utils → utils}/DataRefParser.d.ts +10 -4
- package/lib/{esm/utils → utils}/DataRefParser.js +48 -42
- package/lib/{esm/utils → utils}/Fetch.d.ts +1 -1
- package/lib/utils/Fetch.js +74 -0
- package/lib/{esm/utils → utils}/FormCreationUtils.d.ts +1 -1
- package/lib/utils/FormCreationUtils.js +67 -0
- package/lib/{esm/utils → utils}/FormUtils.d.ts +2 -1
- package/lib/{esm/utils → utils}/FormUtils.js +62 -46
- package/lib/{esm/utils → utils}/JsonUtils.d.ts +1 -1
- package/lib/utils/JsonUtils.js +89 -0
- package/lib/{esm/utils → utils}/LogUtils.d.ts +1 -1
- package/lib/utils/LogUtils.js +10 -0
- package/lib/{esm/utils → utils}/SchemaUtils.d.ts +1 -1
- package/lib/{esm/utils → utils}/SchemaUtils.js +9 -29
- package/lib/{esm/utils → utils}/TranslationUtils.d.ts +2 -2
- package/lib/utils/TranslationUtils.js +125 -0
- package/lib/{esm/utils → utils}/ValidationUtils.d.ts +4 -4
- package/lib/{esm/utils → utils}/ValidationUtils.js +13 -35
- package/package.json +8 -13
- package/lib/cjs/index.cjs +0 -7345
- package/lib/esm/BaseNode.js +0 -26
- package/lib/esm/Checkbox.js +0 -63
- package/lib/esm/CheckboxGroup.js +0 -60
- package/lib/esm/DateField.js +0 -57
- package/lib/esm/Fieldset.d.ts +0 -16
- package/lib/esm/Fieldset.js +0 -78
- package/lib/esm/FileObject.js +0 -48
- package/lib/esm/FileUpload.js +0 -141
- package/lib/esm/FormInstance.js +0 -129
- package/lib/esm/FormMetaData.js +0 -35
- package/lib/esm/InstanceManager.js +0 -58
- package/lib/esm/Node.js +0 -40
- package/lib/esm/controller/Logger.js +0 -52
- package/lib/esm/data/EmptyDataValue.js +0 -51
- package/lib/esm/index.d.ts +0 -21
- package/lib/esm/index.js +0 -55
- package/lib/esm/rules/RuleEngine.js +0 -76
- package/lib/esm/types/Json.js +0 -29
- package/lib/esm/types/Model.js +0 -30
- package/lib/esm/types/index.d.ts +0 -2
- package/lib/esm/types/index.js +0 -22
- package/lib/esm/utils/Fetch.js +0 -83
- package/lib/esm/utils/FormCreationUtils.js +0 -112
- package/lib/esm/utils/JsonUtils.js +0 -99
- package/lib/esm/utils/LogUtils.js +0 -28
- package/lib/esm/utils/TranslationUtils.js +0 -138
|
@@ -1,99 +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 { constraintProps } from '../types/Json.js';
|
|
22
|
-
import { defaultFieldTypes } from './SchemaUtils.js';
|
|
23
|
-
|
|
24
|
-
const getProperty = (data, key, def) => {
|
|
25
|
-
if (key in data) {
|
|
26
|
-
return data[key];
|
|
27
|
-
}
|
|
28
|
-
else if (!key.startsWith(':')) {
|
|
29
|
-
const prefixedKey = `:${key}`;
|
|
30
|
-
if (prefixedKey in data) {
|
|
31
|
-
return data[prefixedKey];
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
return def;
|
|
35
|
-
};
|
|
36
|
-
const isFile = function (item) {
|
|
37
|
-
return (item?.type === 'file' || item?.type === 'file[]') ||
|
|
38
|
-
((item?.type === 'string' || item?.type === 'string[]') &&
|
|
39
|
-
(item?.format === 'binary' || item?.format === 'data-url'));
|
|
40
|
-
};
|
|
41
|
-
const checkIfConstraintsArePresent = function (item) {
|
|
42
|
-
return constraintProps.some(cp => item[cp] !== undefined);
|
|
43
|
-
};
|
|
44
|
-
const isCheckbox = function (item) {
|
|
45
|
-
const fieldType = item?.fieldType || defaultFieldTypes(item);
|
|
46
|
-
return fieldType === 'checkbox';
|
|
47
|
-
};
|
|
48
|
-
const isCheckboxGroup = function (item) {
|
|
49
|
-
const fieldType = item?.fieldType || defaultFieldTypes(item);
|
|
50
|
-
return fieldType === 'checkbox-group';
|
|
51
|
-
};
|
|
52
|
-
const isDateField = function (item) {
|
|
53
|
-
const fieldType = item?.fieldType || defaultFieldTypes(item);
|
|
54
|
-
return (fieldType === 'text-input' && item?.format === 'date') || fieldType === 'date-input';
|
|
55
|
-
};
|
|
56
|
-
function deepClone(obj, idGenerator) {
|
|
57
|
-
let result;
|
|
58
|
-
if (obj instanceof Array) {
|
|
59
|
-
result = [];
|
|
60
|
-
result = obj.map(x => deepClone(x, idGenerator));
|
|
61
|
-
}
|
|
62
|
-
else if (typeof obj === 'object' && obj !== null) {
|
|
63
|
-
result = {};
|
|
64
|
-
Object.entries(obj).forEach(([key, value]) => {
|
|
65
|
-
result[key] = deepClone(value, idGenerator);
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
else {
|
|
69
|
-
result = obj;
|
|
70
|
-
}
|
|
71
|
-
if (idGenerator && result && result.id) {
|
|
72
|
-
result.id = idGenerator();
|
|
73
|
-
}
|
|
74
|
-
return result;
|
|
75
|
-
}
|
|
76
|
-
function checkIfKeyAdded(currentObj, prevObj, objKey) {
|
|
77
|
-
if (currentObj != null && prevObj != null) {
|
|
78
|
-
const newPrvObj = { ...prevObj };
|
|
79
|
-
newPrvObj[objKey] = currentObj[objKey];
|
|
80
|
-
const newJsonStr = jsonString(currentObj).replace(jsonString(newPrvObj), '');
|
|
81
|
-
return newJsonStr === '';
|
|
82
|
-
}
|
|
83
|
-
else {
|
|
84
|
-
return false;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
const jsonString = (obj) => {
|
|
88
|
-
return JSON.stringify(obj, null, 2);
|
|
89
|
-
};
|
|
90
|
-
const isRepeatable = (obj) => {
|
|
91
|
-
return ((obj.repeatable &&
|
|
92
|
-
((obj.minOccur === undefined && obj.maxOccur === undefined) ||
|
|
93
|
-
(obj.minOccur !== undefined && obj.maxOccur !== undefined && obj.maxOccur !== 0) ||
|
|
94
|
-
(obj.minOccur !== undefined && obj.maxOccur !== undefined && obj.minOccur !== 0 && obj.maxOccur !== 0) ||
|
|
95
|
-
(obj.minOccur !== undefined && obj.minOccur >= 0) ||
|
|
96
|
-
(obj.maxOccur !== undefined && obj.maxOccur !== 0))) || false);
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
export { checkIfConstraintsArePresent, checkIfKeyAdded, deepClone, getProperty, isCheckbox, isCheckboxGroup, isDateField, isFile, isRepeatable, jsonString };
|
|
@@ -1,28 +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 logFormCallbacks = (callbacks) => {
|
|
22
|
-
const s = Object.entries(callbacks).map(([id, fn]) => {
|
|
23
|
-
return `${id} : ${fn.length}`;
|
|
24
|
-
}).join(' ');
|
|
25
|
-
console.log(s);
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export { logFormCallbacks };
|
|
@@ -1,138 +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 { translationProps } from '../types/Json.js';
|
|
22
|
-
|
|
23
|
-
const TRANSLATION_TOKEN = '##';
|
|
24
|
-
const TRANSLATION_ID = 'afs:translationIds';
|
|
25
|
-
const CUSTOM_PROPS_KEY = 'properties';
|
|
26
|
-
const defaultBcp47LangTags = [
|
|
27
|
-
'de-DE',
|
|
28
|
-
'en-US',
|
|
29
|
-
'es-ES',
|
|
30
|
-
'fr-FR',
|
|
31
|
-
'it-IT',
|
|
32
|
-
'ja-JP',
|
|
33
|
-
'ko-KR',
|
|
34
|
-
'pt-BR',
|
|
35
|
-
'zh-CN',
|
|
36
|
-
'zh-TW'
|
|
37
|
-
];
|
|
38
|
-
const invalidateTranslation = (input, updates) => {
|
|
39
|
-
translationProps.forEach((prop) => {
|
|
40
|
-
if (prop in updates && input?.[CUSTOM_PROPS_KEY]?.[TRANSLATION_ID]?.[prop]) {
|
|
41
|
-
delete input?.[CUSTOM_PROPS_KEY]?.[TRANSLATION_ID]?.[prop];
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
};
|
|
45
|
-
const addTranslationId = (input, additionalTranslationProps = []) => {
|
|
46
|
-
const model = input;
|
|
47
|
-
const transProps = [...translationProps, ...additionalTranslationProps];
|
|
48
|
-
_createTranslationId(model, '', transProps);
|
|
49
|
-
return model;
|
|
50
|
-
};
|
|
51
|
-
const _createTranslationId = (input, path, transProps) => {
|
|
52
|
-
Object.entries(input).forEach(([key, value]) => {
|
|
53
|
-
if (typeof value == 'object') {
|
|
54
|
-
if (input instanceof Array) {
|
|
55
|
-
if (value && 'name' in value) {
|
|
56
|
-
_createTranslationId(value, `${path === '' ? path : path + TRANSLATION_TOKEN}${value.name}`, transProps);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
_createTranslationId(value, ((key === 'items') ? path : `${path === '' ? path : path + TRANSLATION_TOKEN}${key}`), transProps);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
if (':type' in input ||
|
|
65
|
-
'type' in input ||
|
|
66
|
-
'fieldType' in input) {
|
|
67
|
-
for (const transProp of transProps) {
|
|
68
|
-
if (getOrElse(input, transProp) != null) {
|
|
69
|
-
if (!(CUSTOM_PROPS_KEY in input)) {
|
|
70
|
-
input[CUSTOM_PROPS_KEY] = {};
|
|
71
|
-
}
|
|
72
|
-
if (!(TRANSLATION_ID in input[CUSTOM_PROPS_KEY])) {
|
|
73
|
-
input[CUSTOM_PROPS_KEY][TRANSLATION_ID] = {};
|
|
74
|
-
}
|
|
75
|
-
if (!(transProp in input[CUSTOM_PROPS_KEY][TRANSLATION_ID])) {
|
|
76
|
-
input[CUSTOM_PROPS_KEY][TRANSLATION_ID][transProp] = `${path}${TRANSLATION_TOKEN}${transProp}${TRANSLATION_TOKEN}${Math.floor(Math.random() * 10000) + 1}`;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
};
|
|
84
|
-
const _createTranslationObj = (input, translationObj, translationProps) => {
|
|
85
|
-
Object.values(input).forEach((value) => {
|
|
86
|
-
if (typeof value == 'object') {
|
|
87
|
-
_createTranslationObj(value, translationObj, translationProps);
|
|
88
|
-
}
|
|
89
|
-
else {
|
|
90
|
-
for (const translationProp of translationProps) {
|
|
91
|
-
const objValue = getOrElse(input, translationProp);
|
|
92
|
-
if (objValue && input?.[CUSTOM_PROPS_KEY]?.[TRANSLATION_ID]?.[translationProp]) {
|
|
93
|
-
if (objValue instanceof Array) {
|
|
94
|
-
objValue.forEach((item, index) => {
|
|
95
|
-
if (typeof item === 'string') {
|
|
96
|
-
translationObj[`${input[CUSTOM_PROPS_KEY][TRANSLATION_ID][translationProp]}${TRANSLATION_TOKEN}${index}`] = item;
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
else {
|
|
101
|
-
translationObj[`${input[CUSTOM_PROPS_KEY][TRANSLATION_ID][translationProp]}`] = objValue;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
});
|
|
107
|
-
};
|
|
108
|
-
const getOrElse = (input, key, defaultValue = null) => {
|
|
109
|
-
if (!key) {
|
|
110
|
-
return defaultValue;
|
|
111
|
-
}
|
|
112
|
-
const arr = Array.isArray(key) ? key : key.split('.');
|
|
113
|
-
let objValue = input, index = 0;
|
|
114
|
-
while (index < arr.length && objValue.hasOwnProperty(arr[index])) {
|
|
115
|
-
objValue = objValue[arr[index]];
|
|
116
|
-
index++;
|
|
117
|
-
}
|
|
118
|
-
return index == arr.length ? objValue : defaultValue;
|
|
119
|
-
};
|
|
120
|
-
const createTranslationObj = (input, additionalTranslationProps = []) => {
|
|
121
|
-
const obj = {};
|
|
122
|
-
const transProps = [...translationProps, ...additionalTranslationProps];
|
|
123
|
-
_createTranslationObj(input, obj, transProps);
|
|
124
|
-
return obj;
|
|
125
|
-
};
|
|
126
|
-
const createTranslationObject = (input, additionalTranslationProps = [], bcp47LangTags = []) => {
|
|
127
|
-
const transProps = [...translationProps, ...additionalTranslationProps];
|
|
128
|
-
const inputCopy = JSON.parse(JSON.stringify(input));
|
|
129
|
-
const obj = createTranslationObj(addTranslationId(inputCopy, additionalTranslationProps), transProps);
|
|
130
|
-
const langTags = [...defaultBcp47LangTags, ...bcp47LangTags];
|
|
131
|
-
const allLangs = {};
|
|
132
|
-
for (const langTag of langTags) {
|
|
133
|
-
allLangs[langTag] = JSON.parse(JSON.stringify(obj));
|
|
134
|
-
}
|
|
135
|
-
return [inputCopy, allLangs];
|
|
136
|
-
};
|
|
137
|
-
|
|
138
|
-
export { CUSTOM_PROPS_KEY, TRANSLATION_ID, TRANSLATION_TOKEN, addTranslationId, createTranslationObj, createTranslationObject, getOrElse, invalidateTranslation };
|