@aemforms/af-core 0.22.31 → 0.22.33

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 (98) hide show
  1. package/lib/{esm/BaseNode.d.ts → BaseNode.d.ts} +6 -6
  2. package/lib/{esm/BaseNode-f84b22c6.js → BaseNode.js} +58 -94
  3. package/lib/{esm/Checkbox.d.ts → Checkbox.d.ts} +1 -1
  4. package/lib/Checkbox.js +29 -0
  5. package/lib/{esm/CheckboxGroup.d.ts → CheckboxGroup.d.ts} +2 -2
  6. package/lib/CheckboxGroup.js +24 -0
  7. package/lib/{esm/Container.d.ts → Container.d.ts} +4 -4
  8. package/lib/{esm/Container.js → Container.js} +51 -77
  9. package/lib/{esm/DateField.d.ts → DateField.d.ts} +1 -1
  10. package/lib/DateField.js +26 -0
  11. package/lib/{esm/Field.d.ts → Field.d.ts} +7 -7
  12. package/lib/{esm/Field.js → Field.js} +84 -104
  13. package/lib/{esm/Fieldset.d.ts → Fieldset.d.ts} +7 -7
  14. package/lib/{esm/Fieldset.js → Fieldset.js} +14 -43
  15. package/lib/{esm/FileObject.d.ts → FileObject.d.ts} +1 -1
  16. package/lib/FileObject.js +29 -0
  17. package/lib/{esm/FileUpload.d.ts → FileUpload.d.ts} +3 -3
  18. package/lib/FileUpload.js +124 -0
  19. package/lib/{esm/Form.d.ts → Form.d.ts} +12 -12
  20. package/lib/{esm/Form.js → Form.js} +34 -65
  21. package/lib/{esm/FormInstance.d.ts → FormInstance.d.ts} +3 -3
  22. package/lib/FormInstance.js +94 -0
  23. package/lib/{esm/FormMetaData.d.ts → FormMetaData.d.ts} +2 -2
  24. package/lib/FormMetaData.js +15 -0
  25. package/lib/{esm/InstanceManager.d.ts → InstanceManager.d.ts} +2 -2
  26. package/lib/InstanceManager.js +35 -0
  27. package/lib/Node.js +15 -0
  28. package/lib/{esm/Scriptable.d.ts → Scriptable.d.ts} +3 -3
  29. package/lib/{esm/Scriptable.js → Scriptable.js} +17 -38
  30. package/lib/{esm/controller → controller}/EventQueue.d.ts +3 -3
  31. package/lib/{esm/controller → controller}/EventQueue.js +8 -32
  32. package/lib/{esm/controller → controller}/Events.d.ts +2 -2
  33. package/lib/{esm/controller → controller}/Events.js +22 -26
  34. package/lib/{esm/controller → controller}/Logger.d.ts +2 -2
  35. package/lib/controller/Logger.js +33 -0
  36. package/lib/{esm/data → data}/DataGroup.d.ts +1 -1
  37. package/lib/{esm/data → data}/DataGroup.js +20 -38
  38. package/lib/{esm/data → data}/DataValue.d.ts +1 -1
  39. package/lib/{esm/data → data}/DataValue.js +4 -26
  40. package/lib/{esm/data → data}/EmptyDataValue.d.ts +1 -1
  41. package/lib/data/EmptyDataValue.js +34 -0
  42. package/lib/index.d.ts +21 -0
  43. package/lib/index.js +57 -0
  44. package/lib/{esm/rules → rules}/FunctionRuntime.d.ts +3 -3
  45. package/lib/{esm/rules → rules}/FunctionRuntime.js +52 -63
  46. package/lib/{esm/rules → rules}/RuleEngine.d.ts +1 -1
  47. package/lib/rules/RuleEngine.js +51 -0
  48. package/lib/{esm/types → types}/Json.d.ts +16 -16
  49. package/lib/types/Json.js +10 -0
  50. package/lib/{esm/types → types}/Model.d.ts +9 -9
  51. package/lib/types/Model.js +10 -0
  52. package/lib/types/index.d.ts +2 -0
  53. package/lib/types/index.js +18 -0
  54. package/lib/{esm/utils → utils}/DataRefParser.d.ts +4 -4
  55. package/lib/{esm/utils → utils}/DataRefParser.js +30 -45
  56. package/lib/{esm/utils → utils}/Fetch.d.ts +1 -1
  57. package/lib/utils/Fetch.js +74 -0
  58. package/lib/{esm/utils → utils}/FormCreationUtils.d.ts +1 -1
  59. package/lib/utils/FormCreationUtils.js +67 -0
  60. package/lib/{esm/utils → utils}/FormUtils.d.ts +2 -1
  61. package/lib/{esm/utils → utils}/FormUtils.js +62 -46
  62. package/lib/{esm/utils → utils}/JsonUtils.d.ts +1 -1
  63. package/lib/utils/JsonUtils.js +89 -0
  64. package/lib/{esm/utils → utils}/LogUtils.d.ts +1 -1
  65. package/lib/utils/LogUtils.js +10 -0
  66. package/lib/{esm/utils → utils}/SchemaUtils.d.ts +1 -1
  67. package/lib/{esm/utils → utils}/SchemaUtils.js +9 -29
  68. package/lib/{esm/utils → utils}/TranslationUtils.d.ts +2 -2
  69. package/lib/utils/TranslationUtils.js +125 -0
  70. package/lib/{esm/utils → utils}/ValidationUtils.d.ts +4 -4
  71. package/lib/{esm/utils → utils}/ValidationUtils.js +13 -35
  72. package/package.json +8 -13
  73. package/lib/cjs/index.cjs +0 -7426
  74. package/lib/esm/BaseNode.js +0 -26
  75. package/lib/esm/Checkbox.js +0 -63
  76. package/lib/esm/CheckboxGroup.js +0 -60
  77. package/lib/esm/DateField.js +0 -57
  78. package/lib/esm/FileObject.js +0 -48
  79. package/lib/esm/FileUpload.js +0 -141
  80. package/lib/esm/FormInstance.js +0 -129
  81. package/lib/esm/FormMetaData.js +0 -35
  82. package/lib/esm/InstanceManager.js +0 -58
  83. package/lib/esm/Node.js +0 -40
  84. package/lib/esm/controller/Logger.js +0 -52
  85. package/lib/esm/data/EmptyDataValue.js +0 -51
  86. package/lib/esm/index.d.ts +0 -21
  87. package/lib/esm/index.js +0 -55
  88. package/lib/esm/rules/RuleEngine.js +0 -76
  89. package/lib/esm/types/Json.js +0 -29
  90. package/lib/esm/types/Model.js +0 -30
  91. package/lib/esm/types/index.d.ts +0 -2
  92. package/lib/esm/types/index.js +0 -22
  93. package/lib/esm/utils/Fetch.js +0 -83
  94. package/lib/esm/utils/FormCreationUtils.js +0 -112
  95. package/lib/esm/utils/JsonUtils.js +0 -99
  96. package/lib/esm/utils/LogUtils.js +0 -28
  97. package/lib/esm/utils/TranslationUtils.js +0 -138
  98. /package/lib/{esm/Node.d.ts → Node.d.ts} +0 -0
@@ -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 };
File without changes