@webiny/app-admin 6.3.0-beta.1 → 6.3.0-beta.3

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 (234) hide show
  1. package/base/Base/DefaultFieldRenderers.js +69 -5
  2. package/base/Base/DefaultFieldRenderers.js.map +1 -1
  3. package/base/Base/DefaultLayoutRenderers.js +5 -1
  4. package/base/Base/DefaultLayoutRenderers.js.map +1 -1
  5. package/base/Base/FieldRenderers/CheckboxesRenderer.d.ts +13 -0
  6. package/base/Base/FieldRenderers/CheckboxesRenderer.js +28 -0
  7. package/base/Base/FieldRenderers/CheckboxesRenderer.js.map +1 -0
  8. package/base/Base/FieldRenderers/CodeEditorRenderer.d.ts +15 -0
  9. package/base/Base/FieldRenderers/CodeEditorRenderer.js +17 -0
  10. package/base/Base/FieldRenderers/CodeEditorRenderer.js.map +1 -0
  11. package/base/Base/FieldRenderers/DateTimeInputsRenderer.d.ts +17 -0
  12. package/base/Base/FieldRenderers/DateTimeInputsRenderer.js +66 -0
  13. package/base/Base/FieldRenderers/DateTimeInputsRenderer.js.map +1 -0
  14. package/base/Base/FieldRenderers/DateTimeRenderer.d.ts +21 -0
  15. package/base/Base/FieldRenderers/DateTimeRenderer.js +46 -0
  16. package/base/Base/FieldRenderers/DateTimeRenderer.js.map +1 -0
  17. package/base/Base/FieldRenderers/FilePickerRenderer.d.ts +12 -0
  18. package/base/Base/FieldRenderers/FilePickerRenderer.js +47 -0
  19. package/base/Base/FieldRenderers/FilePickerRenderer.js.map +1 -0
  20. package/base/Base/FieldRenderers/FileUrlPickerRenderer.d.ts +12 -0
  21. package/base/Base/FieldRenderers/FileUrlPickerRenderer.js +25 -0
  22. package/base/Base/FieldRenderers/FileUrlPickerRenderer.js.map +1 -0
  23. package/base/Base/FieldRenderers/HiddenRenderer.d.ts +12 -0
  24. package/base/Base/FieldRenderers/HiddenRenderer.js +5 -0
  25. package/base/Base/FieldRenderers/HiddenRenderer.js.map +1 -0
  26. package/base/Base/FieldRenderers/HorizontalTabsRenderer.d.ts +5 -0
  27. package/base/Base/FieldRenderers/HorizontalTabsRenderer.js +27 -0
  28. package/base/Base/FieldRenderers/HorizontalTabsRenderer.js.map +1 -0
  29. package/base/Base/FieldRenderers/InputRenderer.d.ts +4 -7
  30. package/base/Base/FieldRenderers/InputRenderer.js +2 -2
  31. package/base/Base/FieldRenderers/InputRenderer.js.map +1 -1
  32. package/base/Base/FieldRenderers/NumberInputRenderer.d.ts +12 -0
  33. package/base/Base/FieldRenderers/NumberInputRenderer.js +23 -0
  34. package/base/Base/FieldRenderers/NumberInputRenderer.js.map +1 -0
  35. package/base/Base/FieldRenderers/NumberInputsRenderer.d.ts +14 -0
  36. package/base/Base/FieldRenderers/NumberInputsRenderer.js +49 -0
  37. package/base/Base/FieldRenderers/NumberInputsRenderer.js.map +1 -0
  38. package/base/Base/FieldRenderers/ObjectRenderer/DynamicZoneRenderer.d.ts +14 -0
  39. package/base/Base/FieldRenderers/ObjectRenderer/DynamicZoneRenderer.js +20 -0
  40. package/base/Base/FieldRenderers/ObjectRenderer/DynamicZoneRenderer.js.map +1 -0
  41. package/base/Base/FieldRenderers/ObjectRenderer/KeyValueTagsRenderer.d.ts +14 -0
  42. package/base/Base/FieldRenderers/ObjectRenderer/KeyValueTagsRenderer.js +65 -0
  43. package/base/Base/FieldRenderers/ObjectRenderer/KeyValueTagsRenderer.js.map +1 -0
  44. package/base/Base/FieldRenderers/ObjectRenderer/MultiValueDynamicZone.d.ts +10 -0
  45. package/base/Base/FieldRenderers/ObjectRenderer/MultiValueDynamicZone.js +109 -0
  46. package/base/Base/FieldRenderers/ObjectRenderer/MultiValueDynamicZone.js.map +1 -0
  47. package/base/Base/FieldRenderers/ObjectRenderer/ObjectAccordionMultipleRenderer.d.ts +17 -0
  48. package/base/Base/FieldRenderers/ObjectRenderer/ObjectAccordionMultipleRenderer.js +55 -0
  49. package/base/Base/FieldRenderers/ObjectRenderer/ObjectAccordionMultipleRenderer.js.map +1 -0
  50. package/base/Base/FieldRenderers/ObjectRenderer/ObjectFieldComponents.d.ts +7 -3
  51. package/base/Base/FieldRenderers/ObjectRenderer/ObjectFieldComponents.js +15 -19
  52. package/base/Base/FieldRenderers/ObjectRenderer/ObjectFieldComponents.js.map +1 -1
  53. package/base/Base/FieldRenderers/ObjectRenderer/ObjectRenderer.d.ts +5 -8
  54. package/base/Base/FieldRenderers/ObjectRenderer/ObjectRenderer.js +7 -50
  55. package/base/Base/FieldRenderers/ObjectRenderer/ObjectRenderer.js.map +1 -1
  56. package/base/Base/FieldRenderers/ObjectRenderer/SingleValueDynamicZone.d.ts +10 -0
  57. package/base/Base/FieldRenderers/ObjectRenderer/SingleValueDynamicZone.js +64 -0
  58. package/base/Base/FieldRenderers/ObjectRenderer/SingleValueDynamicZone.js.map +1 -0
  59. package/base/Base/FieldRenderers/ObjectRenderer/TemplatePicker.d.ts +10 -0
  60. package/base/Base/FieldRenderers/ObjectRenderer/TemplatePicker.js +85 -0
  61. package/base/Base/FieldRenderers/ObjectRenderer/TemplatePicker.js.map +1 -0
  62. package/base/Base/FieldRenderers/PassthroughRenderer.d.ts +3 -6
  63. package/base/Base/FieldRenderers/PassthroughRenderer.js +9 -23
  64. package/base/Base/FieldRenderers/PassthroughRenderer.js.map +1 -1
  65. package/base/Base/FieldRenderers/RadioButtonsRenderer.d.ts +13 -0
  66. package/base/Base/FieldRenderers/RadioButtonsRenderer.js +27 -0
  67. package/base/Base/FieldRenderers/RadioButtonsRenderer.js.map +1 -0
  68. package/base/Base/FieldRenderers/SelectRenderer.d.ts +6 -8
  69. package/base/Base/FieldRenderers/SelectRenderer.js +8 -5
  70. package/base/Base/FieldRenderers/SelectRenderer.js.map +1 -1
  71. package/base/Base/FieldRenderers/SwitchRenderer.d.ts +12 -0
  72. package/base/Base/FieldRenderers/SwitchRenderer.js +19 -0
  73. package/base/Base/FieldRenderers/SwitchRenderer.js.map +1 -0
  74. package/base/Base/FieldRenderers/TagsRenderer.d.ts +12 -0
  75. package/base/Base/FieldRenderers/TagsRenderer.js +21 -0
  76. package/base/Base/FieldRenderers/TagsRenderer.js.map +1 -0
  77. package/base/Base/FieldRenderers/TextInputsRenderer.d.ts +14 -0
  78. package/base/Base/FieldRenderers/TextInputsRenderer.js +48 -0
  79. package/base/Base/FieldRenderers/TextInputsRenderer.js.map +1 -0
  80. package/base/Base/FieldRenderers/TextareaRenderer.d.ts +3 -6
  81. package/base/Base/FieldRenderers/TextareaRenderer.js +3 -4
  82. package/base/Base/FieldRenderers/TextareaRenderer.js.map +1 -1
  83. package/base/Base/FieldRenderers/TextareasRenderer.d.ts +14 -0
  84. package/base/Base/FieldRenderers/TextareasRenderer.js +51 -0
  85. package/base/Base/FieldRenderers/TextareasRenderer.js.map +1 -0
  86. package/base/Base/FieldRenderers/VerticalTabsRenderer.js +2 -2
  87. package/base/Base/FieldRenderers/VerticalTabsRenderer.js.map +1 -1
  88. package/base/Base/Menus.js +5 -64
  89. package/base/Base/Menus.js.map +1 -1
  90. package/base/Base/RoutesConfig.js +6 -0
  91. package/base/Base/RoutesConfig.js.map +1 -1
  92. package/exports/admin/build-params.d.ts +2 -0
  93. package/exports/admin/build-params.js +3 -0
  94. package/exports/admin/build-params.js.map +1 -1
  95. package/exports/admin/form.d.ts +5 -0
  96. package/exports/admin/form.js +8 -0
  97. package/exports/admin/form.js.map +1 -1
  98. package/exports/admin/ui.d.ts +1 -0
  99. package/exports/admin/ui.js +1 -0
  100. package/exports/admin/ui.js.map +1 -1
  101. package/exports/admin.d.ts +3 -1
  102. package/exports/admin.js +3 -1
  103. package/exports/admin.js.map +1 -1
  104. package/features/formModel/ConditionRuleEvaluator.d.ts +9 -0
  105. package/features/formModel/ConditionRuleEvaluator.js +56 -0
  106. package/features/formModel/ConditionRuleEvaluator.js.map +1 -0
  107. package/features/formModel/Field.d.ts +50 -4
  108. package/features/formModel/Field.js +254 -35
  109. package/features/formModel/Field.js.map +1 -1
  110. package/features/formModel/FieldBuilder.d.ts +17 -35
  111. package/features/formModel/FieldBuilder.js +63 -100
  112. package/features/formModel/FieldBuilder.js.map +1 -1
  113. package/features/formModel/FieldBuilder.test.js +127 -13
  114. package/features/formModel/FieldBuilder.test.js.map +1 -1
  115. package/features/formModel/FieldBuilderRegistry.d.ts +4 -0
  116. package/features/formModel/FieldBuilderRegistry.js +31 -0
  117. package/features/formModel/FieldBuilderRegistry.js.map +1 -0
  118. package/features/formModel/FocusManager.d.ts +14 -0
  119. package/features/formModel/FocusManager.js +109 -0
  120. package/features/formModel/FocusManager.js.map +1 -0
  121. package/features/formModel/FormModel.d.ts +27 -31
  122. package/features/formModel/FormModel.js +210 -403
  123. package/features/formModel/FormModel.js.map +1 -1
  124. package/features/formModel/FormModel.test.js +2044 -193
  125. package/features/formModel/FormModel.test.js.map +1 -1
  126. package/features/formModel/FormModelFactory.d.ts +4 -2
  127. package/features/formModel/FormModelFactory.js +13 -3
  128. package/features/formModel/FormModelFactory.js.map +1 -1
  129. package/features/formModel/FormView.d.ts +2 -0
  130. package/features/formModel/FormView.js +44 -37
  131. package/features/formModel/FormView.js.map +1 -1
  132. package/features/formModel/LayoutBuilderFactory.d.ts +61 -0
  133. package/features/formModel/LayoutBuilderFactory.js +386 -0
  134. package/features/formModel/LayoutBuilderFactory.js.map +1 -0
  135. package/features/formModel/LayoutMutator.d.ts +11 -0
  136. package/features/formModel/LayoutMutator.js +136 -0
  137. package/features/formModel/LayoutMutator.js.map +1 -0
  138. package/features/formModel/LayoutResolver.d.ts +26 -0
  139. package/features/formModel/LayoutResolver.js +239 -0
  140. package/features/formModel/LayoutResolver.js.map +1 -0
  141. package/features/formModel/ObjectField.d.ts +55 -4
  142. package/features/formModel/ObjectField.js +499 -82
  143. package/features/formModel/ObjectField.js.map +1 -1
  144. package/features/formModel/Rules.test.d.ts +1 -0
  145. package/features/formModel/Rules.test.js +289 -0
  146. package/features/formModel/Rules.test.js.map +1 -0
  147. package/features/formModel/abstractions.d.ts +402 -52
  148. package/features/formModel/abstractions.js +55 -0
  149. package/features/formModel/abstractions.js.map +1 -1
  150. package/features/formModel/createFieldRenderer.d.ts +20 -0
  151. package/features/formModel/createFieldRenderer.js +15 -0
  152. package/features/formModel/createFieldRenderer.js.map +1 -0
  153. package/features/formModel/demo/FieldRenderersDemoPresenter.d.ts +18 -0
  154. package/features/formModel/demo/FieldRenderersDemoPresenter.js +225 -0
  155. package/features/formModel/demo/FieldRenderersDemoPresenter.js.map +1 -0
  156. package/features/formModel/demo/FormModelDemo.d.ts +4 -0
  157. package/features/formModel/demo/FormModelDemo.js +230 -0
  158. package/features/formModel/demo/FormModelDemo.js.map +1 -0
  159. package/features/formModel/demo/FormModelDemoPresenter.d.ts +22 -0
  160. package/features/formModel/demo/FormModelDemoPresenter.js +121 -0
  161. package/features/formModel/demo/FormModelDemoPresenter.js.map +1 -0
  162. package/features/formModel/demo/FormModelPhase11Presenter.d.ts +25 -0
  163. package/features/formModel/demo/FormModelPhase11Presenter.js +104 -0
  164. package/features/formModel/demo/FormModelPhase11Presenter.js.map +1 -0
  165. package/features/formModel/demo/FormModelPhase8c1Presenter.d.ts +23 -0
  166. package/features/formModel/demo/FormModelPhase8c1Presenter.js +62 -0
  167. package/features/formModel/demo/FormModelPhase8c1Presenter.js.map +1 -0
  168. package/features/formModel/feature.js +12 -0
  169. package/features/formModel/feature.js.map +1 -1
  170. package/features/formModel/fieldTypes/BooleanFieldType.d.ts +19 -0
  171. package/features/formModel/fieldTypes/BooleanFieldType.js +23 -0
  172. package/features/formModel/fieldTypes/BooleanFieldType.js.map +1 -0
  173. package/features/formModel/fieldTypes/DateTimeFieldType.d.ts +173 -0
  174. package/features/formModel/fieldTypes/DateTimeFieldType.js +369 -0
  175. package/features/formModel/fieldTypes/DateTimeFieldType.js.map +1 -0
  176. package/features/formModel/fieldTypes/FileFieldType.d.ts +18 -0
  177. package/features/formModel/fieldTypes/FileFieldType.js +20 -0
  178. package/features/formModel/fieldTypes/FileFieldType.js.map +1 -0
  179. package/features/formModel/fieldTypes/FileUrlFieldType.d.ts +18 -0
  180. package/features/formModel/fieldTypes/FileUrlFieldType.js +20 -0
  181. package/features/formModel/fieldTypes/FileUrlFieldType.js.map +1 -0
  182. package/features/formModel/fieldTypes/NumberFieldType.d.ts +19 -0
  183. package/features/formModel/fieldTypes/NumberFieldType.js +27 -0
  184. package/features/formModel/fieldTypes/NumberFieldType.js.map +1 -0
  185. package/features/formModel/fieldTypes/ObjectFieldType.d.ts +34 -0
  186. package/features/formModel/fieldTypes/ObjectFieldType.js +109 -0
  187. package/features/formModel/fieldTypes/ObjectFieldType.js.map +1 -0
  188. package/features/formModel/fieldTypes/TextFieldType.d.ts +18 -0
  189. package/features/formModel/fieldTypes/TextFieldType.js +20 -0
  190. package/features/formModel/fieldTypes/TextFieldType.js.map +1 -0
  191. package/features/formModel/fieldTypes/index.d.ts +7 -0
  192. package/features/formModel/fieldTypes/index.js +9 -0
  193. package/features/formModel/fieldTypes/index.js.map +1 -0
  194. package/features/formModel/index.d.ts +13 -4
  195. package/features/formModel/index.js +21 -2
  196. package/features/formModel/index.js.map +1 -1
  197. package/features/formModel/renderers.d.ts +15 -1
  198. package/features/formModel/renderers.js +15 -1
  199. package/features/formModel/renderers.js.map +1 -1
  200. package/features/tools/LexicalContext/LexicalContext.d.ts +14 -0
  201. package/features/tools/LexicalContext/LexicalContext.js +22 -0
  202. package/features/tools/LexicalContext/LexicalContext.js.map +1 -0
  203. package/features/tools/LexicalContext/abstractions.d.ts +11 -0
  204. package/features/tools/LexicalContext/abstractions.js +4 -0
  205. package/features/tools/LexicalContext/abstractions.js.map +1 -0
  206. package/features/tools/LexicalContext/index.d.ts +2 -0
  207. package/features/tools/LexicalContext/index.js +3 -0
  208. package/features/tools/LexicalContext/index.js.map +1 -0
  209. package/features/tools/feature.js +2 -0
  210. package/features/tools/feature.js.map +1 -1
  211. package/features/tools/index.d.ts +1 -0
  212. package/features/tools/index.js +1 -0
  213. package/features/tools/index.js.map +1 -1
  214. package/index.d.ts +8 -1
  215. package/index.js +7 -0
  216. package/index.js.map +1 -1
  217. package/package.json +31 -25
  218. package/presentation/installation/components/SystemInstaller/steps/AdminUserStep/createPasswordValidator.js +1 -1
  219. package/presentation/installation/components/SystemInstaller/steps/AdminUserStep/createPasswordValidator.js.map +1 -1
  220. package/presentation/lexicalContext/useLexicalContext.d.ts +3 -0
  221. package/presentation/lexicalContext/useLexicalContext.js +14 -0
  222. package/presentation/lexicalContext/useLexicalContext.js.map +1 -0
  223. package/presentation/textToLexicalTool/TextToLexicalTool.d.ts +3 -0
  224. package/presentation/textToLexicalTool/TextToLexicalTool.js +6 -2
  225. package/presentation/textToLexicalTool/TextToLexicalTool.js.map +1 -1
  226. package/presentation/textToLexicalTool/textToLexicalState.d.ts +2 -1
  227. package/presentation/textToLexicalTool/textToLexicalState.js +15 -3
  228. package/presentation/textToLexicalTool/textToLexicalState.js.map +1 -1
  229. package/routes.d.ts +1 -0
  230. package/routes.js +4 -0
  231. package/routes.js.map +1 -1
  232. package/base/Base/FieldRenderers/ObjectRenderer/ObjectListFlatRenderer.d.ts +0 -21
  233. package/base/Base/FieldRenderers/ObjectRenderer/ObjectListFlatRenderer.js +0 -28
  234. package/base/Base/FieldRenderers/ObjectRenderer/ObjectListFlatRenderer.js.map +0 -1
@@ -0,0 +1,386 @@
1
+ import { isObjectField } from "./ObjectField.js";
2
+ export class TabBuilder {
3
+ _label = "";
4
+ constructor(existing) {
5
+ this._existing = existing;
6
+ }
7
+ label(text) {
8
+ if (this._existing) {
9
+ this._existing.label = text;
10
+ } else {
11
+ this._label = text;
12
+ }
13
+ return this;
14
+ }
15
+ description(text) {
16
+ if (this._existing) {
17
+ this._existing.description = text;
18
+ } else {
19
+ this._description = text;
20
+ }
21
+ return this;
22
+ }
23
+ icon(icon) {
24
+ if (this._existing) {
25
+ this._existing.icon = icon;
26
+ } else {
27
+ this._icon = icon;
28
+ }
29
+ return this;
30
+ }
31
+ layout(factory) {
32
+ if (this._existing) {
33
+ this._existing.layout.push(...LayoutBuilderFactory.buildNodes(factory(LayoutBuilderFactory.create())));
34
+ } else {
35
+ this._layoutFactory = factory;
36
+ }
37
+ return this;
38
+ }
39
+ rules(r) {
40
+ if (this._existing) {
41
+ this._existing.rules = r;
42
+ } else {
43
+ this._rules = r;
44
+ }
45
+ return this;
46
+ }
47
+ _build(id) {
48
+ if (this._existing) {
49
+ return this._existing;
50
+ }
51
+ return {
52
+ id,
53
+ label: this._label,
54
+ description: this._description,
55
+ icon: this._icon,
56
+ layout: this._layoutFactory ? LayoutBuilderFactory.buildNodes(this._layoutFactory(LayoutBuilderFactory.create())) : [],
57
+ rules: this._rules
58
+ };
59
+ }
60
+ }
61
+ export class TabsBuilder {
62
+ _pendingTabs = [];
63
+ _lastAddedIdx = -1;
64
+ constructor(id) {
65
+ this._id = id;
66
+ }
67
+ renderer(name) {
68
+ this._renderer = name;
69
+ return this;
70
+ }
71
+ tab(tabId, configure) {
72
+ const tb = new TabBuilder();
73
+ configure(tb);
74
+ this._pendingTabs.push({
75
+ tabId,
76
+ tabBuilder: tb
77
+ });
78
+ this._lastAddedIdx = this._pendingTabs.length - 1;
79
+ return this;
80
+ }
81
+ before(_target) {
82
+ return this;
83
+ }
84
+ after(_target) {
85
+ return this;
86
+ }
87
+ rules(r) {
88
+ this._rules = r;
89
+ return this;
90
+ }
91
+ build() {
92
+ return {
93
+ type: "tabs",
94
+ id: this._id,
95
+ renderer: this._renderer,
96
+ tabs: this._pendingTabs.map(p => p.tabBuilder._build(p.tabId)),
97
+ rules: this._rules
98
+ };
99
+ }
100
+ }
101
+ export class TabsAccessBuilder {
102
+ _lastAddedIdx = -1;
103
+ constructor(_node) {
104
+ this._node = _node;
105
+ }
106
+ renderer(name) {
107
+ this._node.renderer = name;
108
+ return this;
109
+ }
110
+ tab(tabId, configure) {
111
+ const existing = this._node.tabs.find(t => t.id === tabId);
112
+ if (existing) {
113
+ configure(new TabBuilder(existing));
114
+ } else {
115
+ const tb = new TabBuilder();
116
+ configure(tb);
117
+ this._node.tabs.push(tb._build(tabId));
118
+ this._lastAddedIdx = this._node.tabs.length - 1;
119
+ }
120
+ return this;
121
+ }
122
+ before(target) {
123
+ if (this._lastAddedIdx >= 0) {
124
+ const tab = this._node.tabs.splice(this._lastAddedIdx, 1)[0];
125
+ const targetIdx = this._node.tabs.findIndex(t => t.id === target);
126
+ if (targetIdx !== -1) {
127
+ this._node.tabs.splice(targetIdx, 0, tab);
128
+ } else {
129
+ this._node.tabs.push(tab);
130
+ }
131
+ }
132
+ return this;
133
+ }
134
+ after(target) {
135
+ if (this._lastAddedIdx >= 0) {
136
+ const tab = this._node.tabs.splice(this._lastAddedIdx, 1)[0];
137
+ const targetIdx = this._node.tabs.findIndex(t => t.id === target);
138
+ if (targetIdx !== -1) {
139
+ this._node.tabs.splice(targetIdx + 1, 0, tab);
140
+ } else {
141
+ this._node.tabs.push(tab);
142
+ }
143
+ }
144
+ return this;
145
+ }
146
+ rules(r) {
147
+ this._node.rules = r;
148
+ return this;
149
+ }
150
+ build() {
151
+ return this._node;
152
+ }
153
+ }
154
+ export class LayoutBuilderFactory {
155
+ static create() {
156
+ return {
157
+ row(...fieldIds) {
158
+ let position;
159
+ const builder = {
160
+ before(target) {
161
+ position = {
162
+ type: "before",
163
+ target
164
+ };
165
+ return builder;
166
+ },
167
+ after(target) {
168
+ position = {
169
+ type: "after",
170
+ target
171
+ };
172
+ return builder;
173
+ },
174
+ build() {
175
+ return {
176
+ type: "row",
177
+ fieldIds,
178
+ position
179
+ };
180
+ }
181
+ };
182
+ return builder;
183
+ },
184
+ separator() {
185
+ return {
186
+ build() {
187
+ return {
188
+ type: "separator"
189
+ };
190
+ }
191
+ };
192
+ },
193
+ tabs(id) {
194
+ return new TabsBuilder(id);
195
+ },
196
+ element(renderer, props) {
197
+ return {
198
+ build() {
199
+ return {
200
+ type: "element",
201
+ renderer,
202
+ props
203
+ };
204
+ }
205
+ };
206
+ },
207
+ object(fieldName, inner) {
208
+ return {
209
+ build() {
210
+ return {
211
+ type: "object",
212
+ fieldName,
213
+ inner: LayoutBuilderFactory.resolveObjectInner(inner)
214
+ };
215
+ }
216
+ };
217
+ }
218
+ };
219
+ }
220
+ static buildNodes(builders) {
221
+ return builders.map(b => b.build());
222
+ }
223
+ static resolvePositionedRows(nodes) {
224
+ const result = [];
225
+ const deferred = [];
226
+ for (const node of nodes) {
227
+ if (node.type === "row" && node.position) {
228
+ deferred.push({
229
+ node,
230
+ position: node.position
231
+ });
232
+ } else {
233
+ result.push(node);
234
+ }
235
+ }
236
+ for (const {
237
+ node,
238
+ position
239
+ } of deferred) {
240
+ const targetIndex = result.findIndex(n => n.type === "row" && n.fieldIds.includes(position.target));
241
+ if (targetIndex === -1) {
242
+ result.push(node);
243
+ continue;
244
+ }
245
+ const insertAt = position.type === "after" ? targetIndex + 1 : targetIndex;
246
+ result.splice(insertAt, 0, node);
247
+ }
248
+ return result;
249
+ }
250
+ static resolveObjectInner(inner) {
251
+ const api = LayoutBuilderFactory.create();
252
+ if (typeof inner === "function") {
253
+ return LayoutBuilderFactory.resolvePositionedRows(LayoutBuilderFactory.buildNodes(inner(api)));
254
+ }
255
+ const resolved = {};
256
+ for (const [tplId, factory] of Object.entries(inner)) {
257
+ resolved[tplId] = LayoutBuilderFactory.resolvePositionedRows(LayoutBuilderFactory.buildNodes(factory(api)));
258
+ }
259
+ return resolved;
260
+ }
261
+ static createNodeHandle(node) {
262
+ const handle = {
263
+ node,
264
+ before(target) {
265
+ handle.position = {
266
+ type: "before",
267
+ target
268
+ };
269
+ return handle;
270
+ },
271
+ after(target) {
272
+ handle.position = {
273
+ type: "after",
274
+ target
275
+ };
276
+ return handle;
277
+ },
278
+ replace(target) {
279
+ handle.position = {
280
+ type: "replace",
281
+ target
282
+ };
283
+ return handle;
284
+ }
285
+ };
286
+ return handle;
287
+ }
288
+ static matchesNodeId(node, nodeId) {
289
+ if ("id" in node && node.id === nodeId) {
290
+ return true;
291
+ }
292
+ if (node.type === "object" && node.fieldName === nodeId) {
293
+ return true;
294
+ }
295
+ return false;
296
+ }
297
+ static findNodeById(layout, nodeId) {
298
+ for (const node of layout) {
299
+ if (LayoutBuilderFactory.matchesNodeId(node, nodeId)) {
300
+ return node;
301
+ }
302
+ if (node.type === "tabs") {
303
+ for (const tab of node.tabs) {
304
+ const found = LayoutBuilderFactory.findNodeById(tab.layout, nodeId);
305
+ if (found) {
306
+ return found;
307
+ }
308
+ }
309
+ }
310
+ }
311
+ return undefined;
312
+ }
313
+ static resolveTabDefinition(input) {
314
+ const api = LayoutBuilderFactory.create();
315
+ return {
316
+ id: input.id,
317
+ label: input.label,
318
+ description: input.description,
319
+ icon: input.icon,
320
+ rules: input.rules,
321
+ layout: LayoutBuilderFactory.buildNodes(input.layout(api))
322
+ };
323
+ }
324
+ static tabsNodeKey(node) {
325
+ return `__tabs_${node.tabs.map(t => t.id).join("_")}`;
326
+ }
327
+ static accessNode(layout, nodeId) {
328
+ return {
329
+ as: type => {
330
+ const node = LayoutBuilderFactory.findNodeById(layout, nodeId);
331
+ if (!node) {
332
+ throw new Error(`Layout node "${nodeId}" not found.`);
333
+ }
334
+ if (node.type !== type) {
335
+ throw new Error(`Layout node "${nodeId}" is type "${node.type}", not "${type}".`);
336
+ }
337
+ if (type === "tabs") {
338
+ return new TabsAccessBuilder(node);
339
+ }
340
+ return node;
341
+ }
342
+ };
343
+ }
344
+ static collectBuilders(fields, builders, predicate, result) {
345
+ const entries = builders instanceof Map ? builders.entries() : Object.entries(builders);
346
+ for (const [name, builder] of entries) {
347
+ if (predicate(builder)) {
348
+ result.push(builder);
349
+ }
350
+ const field = fields instanceof Map ? fields.get(name) : undefined;
351
+ if (field && isObjectField(field)) {
352
+ LayoutBuilderFactory.collectBuilders(field.children, field.config.childBuilders, predicate, result);
353
+ const templates = field.config.templates;
354
+ if (templates) {
355
+ for (const tpl of templates) {
356
+ LayoutBuilderFactory.collectBuildersFlat(tpl.childBuilders, predicate, result);
357
+ }
358
+ }
359
+ }
360
+ }
361
+ }
362
+ static collectFieldIds(layout) {
363
+ const ids = [];
364
+ for (const node of layout) {
365
+ if (node.type === "row") {
366
+ ids.push(...node.fieldIds);
367
+ } else if (node.type === "tabs") {
368
+ for (const tab of node.tabs) {
369
+ ids.push(...LayoutBuilderFactory.collectFieldIds(tab.layout));
370
+ }
371
+ } else if (node.type === "object") {
372
+ ids.push(node.fieldName);
373
+ }
374
+ }
375
+ return ids;
376
+ }
377
+ static collectBuildersFlat(builders, predicate, result) {
378
+ for (const builder of Object.values(builders)) {
379
+ if (predicate(builder)) {
380
+ result.push(builder);
381
+ }
382
+ }
383
+ }
384
+ }
385
+
386
+ //# sourceMappingURL=LayoutBuilderFactory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["isObjectField","TabBuilder","_label","constructor","existing","_existing","label","text","description","_description","icon","_icon","layout","factory","push","LayoutBuilderFactory","buildNodes","create","_layoutFactory","rules","r","_rules","_build","id","TabsBuilder","_pendingTabs","_lastAddedIdx","_id","renderer","name","_renderer","tab","tabId","configure","tb","tabBuilder","length","before","_target","after","build","type","tabs","map","p","TabsAccessBuilder","_node","find","t","target","splice","targetIdx","findIndex","row","fieldIds","position","builder","separator","element","props","object","fieldName","inner","resolveObjectInner","builders","b","resolvePositionedRows","nodes","result","deferred","node","targetIndex","n","includes","insertAt","api","resolved","tplId","Object","entries","createNodeHandle","handle","replace","matchesNodeId","nodeId","findNodeById","found","undefined","resolveTabDefinition","input","tabsNodeKey","join","accessNode","as","Error","collectBuilders","fields","predicate","Map","field","get","children","config","childBuilders","templates","tpl","collectBuildersFlat","collectFieldIds","ids","values"],"sources":["LayoutBuilderFactory.ts"],"sourcesContent":["import type { Icon } from \"~/components/IconPicker/types.js\";\nimport type {\n IField,\n IFieldBuilder,\n ILayoutBuilder,\n ILayoutNodeBuilder,\n ILayoutNodeHandle,\n IPositionedLayoutNode,\n IRule,\n ITabBuilder,\n ITabDefinition,\n ITabDefinitionInput,\n ITabsBuilder,\n ITabsNode,\n IRowBuilder,\n ISeparatorBuilder,\n IElementBuilder,\n IObjectBuilder,\n IRowNode,\n ISeparatorNode,\n IElementNode,\n IObjectNode,\n LayoutNode,\n LayoutPosition,\n LayoutNodeHandleMap,\n ILayoutNodeAccessHandle\n} from \"./abstractions.js\";\nimport { isObjectField } from \"./ObjectField.js\";\nimport type { IObjectFieldConfig } from \"./abstractions.js\";\n\ninterface TabBuilderInternal extends ITabBuilder {\n _build(id: string): ITabDefinition;\n}\n\nexport class TabBuilder implements TabBuilderInternal {\n private _existing: ITabDefinition | undefined;\n private _label = \"\";\n private _description: string | undefined;\n private _icon: ITabDefinition[\"icon\"];\n private _layoutFactory: ((l: ILayoutBuilder) => ILayoutNodeBuilder[]) | undefined;\n private _rules: IRule[] | undefined;\n\n constructor(existing?: ITabDefinition) {\n this._existing = existing;\n }\n\n label(text: string): this {\n if (this._existing) {\n this._existing.label = text;\n } else {\n this._label = text;\n }\n return this;\n }\n\n description(text: string): this {\n if (this._existing) {\n this._existing.description = text;\n } else {\n this._description = text;\n }\n return this;\n }\n\n icon(icon: Icon): this {\n if (this._existing) {\n this._existing.icon = icon;\n } else {\n this._icon = icon;\n }\n return this;\n }\n\n layout(factory: (l: ILayoutBuilder) => ILayoutNodeBuilder[]): this {\n if (this._existing) {\n this._existing.layout.push(\n ...LayoutBuilderFactory.buildNodes(factory(LayoutBuilderFactory.create()))\n );\n } else {\n this._layoutFactory = factory;\n }\n return this;\n }\n\n rules(r: IRule[]): this {\n if (this._existing) {\n this._existing.rules = r;\n } else {\n this._rules = r;\n }\n return this;\n }\n\n _build(id: string): ITabDefinition {\n if (this._existing) {\n return this._existing;\n }\n return {\n id,\n label: this._label,\n description: this._description,\n icon: this._icon,\n layout: this._layoutFactory\n ? LayoutBuilderFactory.buildNodes(\n this._layoutFactory(LayoutBuilderFactory.create())\n )\n : [],\n rules: this._rules\n };\n }\n}\n\nexport class TabsBuilder implements ITabsBuilder {\n private _id: string | undefined;\n private _renderer: string | undefined;\n private _rules: IRule[] | undefined;\n private _pendingTabs: { tabId: string; tabBuilder: TabBuilderInternal }[] = [];\n private _lastAddedIdx = -1;\n\n constructor(id?: string) {\n this._id = id;\n }\n\n renderer(name: string): this {\n this._renderer = name;\n return this;\n }\n\n tab(tabId: string, configure: (tab: ITabBuilder) => void): this {\n const tb = new TabBuilder();\n configure(tb);\n this._pendingTabs.push({ tabId, tabBuilder: tb });\n this._lastAddedIdx = this._pendingTabs.length - 1;\n return this;\n }\n\n before(_target: string): this {\n return this;\n }\n\n after(_target: string): this {\n return this;\n }\n\n rules(r: IRule[]): this {\n this._rules = r;\n return this;\n }\n\n build(): ITabsNode {\n return {\n type: \"tabs\",\n id: this._id,\n renderer: this._renderer,\n tabs: this._pendingTabs.map(p => p.tabBuilder._build(p.tabId)),\n rules: this._rules\n };\n }\n}\n\nexport class TabsAccessBuilder implements ITabsBuilder {\n private _lastAddedIdx = -1;\n\n constructor(private _node: ITabsNode) {}\n\n renderer(name: string): this {\n this._node.renderer = name;\n return this;\n }\n\n tab(tabId: string, configure: (tab: ITabBuilder) => void): this {\n const existing = this._node.tabs.find(t => t.id === tabId);\n if (existing) {\n configure(new TabBuilder(existing));\n } else {\n const tb = new TabBuilder();\n configure(tb);\n this._node.tabs.push(tb._build(tabId));\n this._lastAddedIdx = this._node.tabs.length - 1;\n }\n return this;\n }\n\n before(target: string): this {\n if (this._lastAddedIdx >= 0) {\n const tab = this._node.tabs.splice(this._lastAddedIdx, 1)[0];\n const targetIdx = this._node.tabs.findIndex(t => t.id === target);\n if (targetIdx !== -1) {\n this._node.tabs.splice(targetIdx, 0, tab);\n } else {\n this._node.tabs.push(tab);\n }\n }\n return this;\n }\n\n after(target: string): this {\n if (this._lastAddedIdx >= 0) {\n const tab = this._node.tabs.splice(this._lastAddedIdx, 1)[0];\n const targetIdx = this._node.tabs.findIndex(t => t.id === target);\n if (targetIdx !== -1) {\n this._node.tabs.splice(targetIdx + 1, 0, tab);\n } else {\n this._node.tabs.push(tab);\n }\n }\n return this;\n }\n\n rules(r: IRule[]): this {\n this._node.rules = r;\n return this;\n }\n\n build(): ITabsNode {\n return this._node;\n }\n}\n\nexport class LayoutBuilderFactory {\n static create(): ILayoutBuilder {\n return {\n row(...fieldIds: string[]): IRowBuilder {\n let position: LayoutPosition | undefined;\n const builder: IRowBuilder = {\n before(target: string) {\n position = { type: \"before\", target };\n return builder;\n },\n after(target: string) {\n position = { type: \"after\", target };\n return builder;\n },\n build(): IRowNode {\n return { type: \"row\", fieldIds, position };\n }\n };\n return builder;\n },\n separator(): ISeparatorBuilder {\n return {\n build(): ISeparatorNode {\n return { type: \"separator\" };\n }\n };\n },\n tabs(id?: string): ITabsBuilder {\n return new TabsBuilder(id);\n },\n element(renderer: string, props?: Record<string, unknown>): IElementBuilder {\n return {\n build(): IElementNode {\n return { type: \"element\", renderer, props };\n }\n };\n },\n object(\n fieldName: string,\n inner:\n | ((layout: ILayoutBuilder) => ILayoutNodeBuilder[])\n | Record<string, (layout: ILayoutBuilder) => ILayoutNodeBuilder[]>\n ): IObjectBuilder {\n return {\n build(): IObjectNode {\n return {\n type: \"object\",\n fieldName,\n inner: LayoutBuilderFactory.resolveObjectInner(inner)\n };\n }\n };\n }\n };\n }\n\n static buildNodes(builders: ILayoutNodeBuilder[]): LayoutNode[] {\n return builders.map(b => b.build());\n }\n\n static resolvePositionedRows(nodes: LayoutNode[]): LayoutNode[] {\n const result: LayoutNode[] = [];\n const deferred: { node: LayoutNode; position: LayoutPosition }[] = [];\n\n for (const node of nodes) {\n if (node.type === \"row\" && node.position) {\n deferred.push({ node, position: node.position });\n } else {\n result.push(node);\n }\n }\n\n for (const { node, position } of deferred) {\n const targetIndex = result.findIndex(\n n => n.type === \"row\" && (n as IRowNode).fieldIds.includes(position.target)\n );\n if (targetIndex === -1) {\n result.push(node);\n continue;\n }\n const insertAt = position.type === \"after\" ? targetIndex + 1 : targetIndex;\n result.splice(insertAt, 0, node);\n }\n\n return result;\n }\n\n static resolveObjectInner(\n inner:\n | ((layout: ILayoutBuilder) => ILayoutNodeBuilder[])\n | Record<string, (layout: ILayoutBuilder) => ILayoutNodeBuilder[]>\n ): LayoutNode[] | Record<string, LayoutNode[]> {\n const api = LayoutBuilderFactory.create();\n if (typeof inner === \"function\") {\n return LayoutBuilderFactory.resolvePositionedRows(\n LayoutBuilderFactory.buildNodes(inner(api))\n );\n }\n const resolved: Record<string, LayoutNode[]> = {};\n for (const [tplId, factory] of Object.entries(inner)) {\n resolved[tplId] = LayoutBuilderFactory.resolvePositionedRows(\n LayoutBuilderFactory.buildNodes(factory(api))\n );\n }\n return resolved;\n }\n\n static createNodeHandle(node: LayoutNode): ILayoutNodeHandle {\n const handle: ILayoutNodeHandle = {\n node,\n before(target: string): IPositionedLayoutNode {\n handle.position = { type: \"before\", target };\n return handle;\n },\n after(target: string): IPositionedLayoutNode {\n handle.position = { type: \"after\", target };\n return handle;\n },\n replace(target: string): IPositionedLayoutNode {\n handle.position = { type: \"replace\", target };\n return handle;\n }\n };\n return handle;\n }\n\n static matchesNodeId(node: LayoutNode, nodeId: string): boolean {\n if (\"id\" in node && node.id === nodeId) {\n return true;\n }\n if (node.type === \"object\" && node.fieldName === nodeId) {\n return true;\n }\n return false;\n }\n\n static findNodeById(layout: LayoutNode[], nodeId: string): LayoutNode | undefined {\n for (const node of layout) {\n if (LayoutBuilderFactory.matchesNodeId(node, nodeId)) {\n return node;\n }\n if (node.type === \"tabs\") {\n for (const tab of node.tabs) {\n const found = LayoutBuilderFactory.findNodeById(tab.layout, nodeId);\n if (found) {\n return found;\n }\n }\n }\n }\n return undefined;\n }\n\n static resolveTabDefinition(input: ITabDefinitionInput): ITabDefinition {\n const api = LayoutBuilderFactory.create();\n return {\n id: input.id,\n label: input.label,\n description: input.description,\n icon: input.icon,\n rules: input.rules,\n layout: LayoutBuilderFactory.buildNodes(input.layout(api))\n };\n }\n\n static tabsNodeKey(node: ITabsNode): string {\n return `__tabs_${node.tabs.map(t => t.id).join(\"_\")}`;\n }\n\n static accessNode(layout: LayoutNode[], nodeId: string): ILayoutNodeAccessHandle {\n return {\n as: <T extends keyof LayoutNodeHandleMap>(type: T): LayoutNodeHandleMap[T] => {\n const node = LayoutBuilderFactory.findNodeById(layout, nodeId);\n if (!node) {\n throw new Error(`Layout node \"${nodeId}\" not found.`);\n }\n if (node.type !== type) {\n throw new Error(\n `Layout node \"${nodeId}\" is type \"${node.type}\", not \"${type}\".`\n );\n }\n\n if (type === \"tabs\") {\n return new TabsAccessBuilder(\n node as ITabsNode\n ) as unknown as LayoutNodeHandleMap[T];\n }\n\n return node as unknown as LayoutNodeHandleMap[T];\n }\n };\n }\n\n static collectBuilders(\n fields: Map<string, IField>,\n builders: Map<string, IFieldBuilder> | Record<string, IFieldBuilder>,\n predicate: (builder: IFieldBuilder) => boolean,\n result: IFieldBuilder[]\n ): void {\n const entries = builders instanceof Map ? builders.entries() : Object.entries(builders);\n for (const [name, builder] of entries) {\n if (predicate(builder)) {\n result.push(builder);\n }\n const field = fields instanceof Map ? fields.get(name) : undefined;\n if (field && isObjectField(field)) {\n LayoutBuilderFactory.collectBuilders(\n field.children,\n field.config.childBuilders,\n predicate,\n result\n );\n const templates = (field.config as IObjectFieldConfig).templates;\n if (templates) {\n for (const tpl of templates) {\n LayoutBuilderFactory.collectBuildersFlat(\n tpl.childBuilders,\n predicate,\n result\n );\n }\n }\n }\n }\n }\n\n static collectFieldIds(layout: LayoutNode[]): string[] {\n const ids: string[] = [];\n for (const node of layout) {\n if (node.type === \"row\") {\n ids.push(...node.fieldIds);\n } else if (node.type === \"tabs\") {\n for (const tab of node.tabs) {\n ids.push(...LayoutBuilderFactory.collectFieldIds(tab.layout));\n }\n } else if (node.type === \"object\") {\n ids.push(node.fieldName);\n }\n }\n return ids;\n }\n\n static collectBuildersFlat(\n builders: Record<string, IFieldBuilder>,\n predicate: (builder: IFieldBuilder) => boolean,\n result: IFieldBuilder[]\n ): void {\n for (const builder of Object.values(builders)) {\n if (predicate(builder)) {\n result.push(builder);\n }\n }\n }\n}\n"],"mappings":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AE;MAC3C,IAAIiC,SAAS,CAACzC,OAAO,CAAC,EAAE;QACpBY,MAAM,CAACtD,IAAI,CAAC0C,OAAO,CAAC;MACxB;IACJ;EACJ;AACJ","ignoreList":[]}
@@ -0,0 +1,11 @@
1
+ import type { ILayoutModifier, IPositionedLayoutNode, ILayoutNodeAccessHandle, LayoutNode, LayoutPosition } from "./abstractions.js";
2
+ export declare class LayoutMutator {
3
+ createModifierAPI(removals: string[]): ILayoutModifier;
4
+ applyModifications(layout: LayoutNode[], factory: (modifier: ILayoutModifier) => (LayoutNode | IPositionedLayoutNode)[]): LayoutNode[];
5
+ accessNode(layout: LayoutNode[], nodeId: string): ILayoutNodeAccessHandle;
6
+ removeFromLayout(layout: LayoutNode[], target: string): LayoutNode[];
7
+ insertIntoLayout(layout: LayoutNode[], node: LayoutNode, position: LayoutPosition): LayoutNode[];
8
+ isPositionedNode(entry: LayoutNode | IPositionedLayoutNode): entry is IPositionedLayoutNode;
9
+ private findIndex;
10
+ private nodeMatchesTarget;
11
+ }
@@ -0,0 +1,136 @@
1
+ import { LayoutBuilderFactory } from "./LayoutBuilderFactory.js";
2
+ export class LayoutMutator {
3
+ createModifierAPI(removals) {
4
+ return {
5
+ row(...fieldIds) {
6
+ const node = {
7
+ type: "row",
8
+ fieldIds
9
+ };
10
+ return LayoutBuilderFactory.createNodeHandle(node);
11
+ },
12
+ separator() {
13
+ const node = {
14
+ type: "separator"
15
+ };
16
+ return LayoutBuilderFactory.createNodeHandle(node);
17
+ },
18
+ tabs(config) {
19
+ const node = {
20
+ type: "tabs",
21
+ id: config.id,
22
+ renderer: config.renderer,
23
+ tabs: config.tabs.map(LayoutBuilderFactory.resolveTabDefinition),
24
+ rules: config.rules
25
+ };
26
+ return LayoutBuilderFactory.createNodeHandle(node);
27
+ },
28
+ element(renderer, props) {
29
+ const node = {
30
+ type: "element",
31
+ renderer,
32
+ props
33
+ };
34
+ return LayoutBuilderFactory.createNodeHandle(node);
35
+ },
36
+ object(fieldName, inner) {
37
+ const node = {
38
+ type: "object",
39
+ fieldName,
40
+ inner: LayoutBuilderFactory.resolveObjectInner(inner)
41
+ };
42
+ return LayoutBuilderFactory.createNodeHandle(node);
43
+ },
44
+ remove(target) {
45
+ removals.push(target);
46
+ }
47
+ };
48
+ }
49
+ applyModifications(layout, factory) {
50
+ const removals = [];
51
+ const modifierAPI = this.createModifierAPI(removals);
52
+ const entries = factory(modifierAPI);
53
+ let result = layout;
54
+ for (const target of removals) {
55
+ result = this.removeFromLayout(result, target);
56
+ }
57
+ for (const entry of entries) {
58
+ if (this.isPositionedNode(entry)) {
59
+ const {
60
+ node,
61
+ position
62
+ } = entry;
63
+ if (position) {
64
+ result = this.insertIntoLayout(result, node, position);
65
+ } else {
66
+ result = [...result, node];
67
+ }
68
+ } else {
69
+ result = [...result, entry];
70
+ }
71
+ }
72
+ return result;
73
+ }
74
+ accessNode(layout, nodeId) {
75
+ return LayoutBuilderFactory.accessNode(layout, nodeId);
76
+ }
77
+ removeFromLayout(layout, target) {
78
+ return layout.map(node => {
79
+ if (node.type === "row") {
80
+ const filtered = node.fieldIds.filter(id => id !== target);
81
+ if (filtered.length === 0) {
82
+ return null;
83
+ }
84
+ return {
85
+ ...node,
86
+ fieldIds: filtered
87
+ };
88
+ }
89
+ if (node.type === "tabs" && node.id === target || node.type === "element" && (node.id === target || node.renderer === target) || node.type === "object" && node.fieldName === target) {
90
+ return null;
91
+ }
92
+ return node;
93
+ }).filter(Boolean);
94
+ }
95
+ insertIntoLayout(layout, node, position) {
96
+ const targetIndex = this.findIndex(layout, position.target);
97
+ if (targetIndex === -1) {
98
+ return [...layout, node];
99
+ }
100
+ const result = [...layout];
101
+ switch (position.type) {
102
+ case "before":
103
+ result.splice(targetIndex, 0, node);
104
+ break;
105
+ case "after":
106
+ result.splice(targetIndex + 1, 0, node);
107
+ break;
108
+ case "replace":
109
+ result.splice(targetIndex, 1, node);
110
+ break;
111
+ }
112
+ return result;
113
+ }
114
+ isPositionedNode(entry) {
115
+ return "node" in entry;
116
+ }
117
+ findIndex(layout, target) {
118
+ return layout.findIndex(node => this.nodeMatchesTarget(node, target));
119
+ }
120
+ nodeMatchesTarget(node, target) {
121
+ switch (node.type) {
122
+ case "row":
123
+ return node.fieldIds.includes(target);
124
+ case "tabs":
125
+ return node.id === target;
126
+ case "element":
127
+ return node.id === target || node.renderer === target;
128
+ case "object":
129
+ return node.fieldName === target;
130
+ default:
131
+ return false;
132
+ }
133
+ }
134
+ }
135
+
136
+ //# sourceMappingURL=LayoutMutator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["LayoutBuilderFactory","LayoutMutator","createModifierAPI","removals","row","fieldIds","node","type","createNodeHandle","separator","tabs","config","id","renderer","map","resolveTabDefinition","rules","element","props","object","fieldName","inner","resolveObjectInner","remove","target","push","applyModifications","layout","factory","modifierAPI","entries","result","removeFromLayout","entry","isPositionedNode","position","insertIntoLayout","accessNode","nodeId","filtered","filter","length","Boolean","targetIndex","findIndex","splice","nodeMatchesTarget","includes"],"sources":["LayoutMutator.ts"],"sourcesContent":["import { LayoutBuilderFactory } from \"./LayoutBuilderFactory.js\";\nimport type {\n ILayoutModifier,\n ILayoutNodeHandle,\n IPositionedLayoutNode,\n ILayoutNodeAccessHandle,\n ITabDefinitionInput,\n IRule,\n LayoutNode,\n LayoutPosition,\n IRowNode,\n ISeparatorNode,\n ITabsNode,\n IElementNode,\n IObjectNode,\n ILayoutBuilder,\n ILayoutNodeBuilder\n} from \"./abstractions.js\";\n\nexport class LayoutMutator {\n createModifierAPI(removals: string[]): ILayoutModifier {\n return {\n row(...fieldIds: string[]): ILayoutNodeHandle {\n const node: IRowNode = { type: \"row\", fieldIds };\n return LayoutBuilderFactory.createNodeHandle(node);\n },\n separator(): ILayoutNodeHandle {\n const node: ISeparatorNode = { type: \"separator\" };\n return LayoutBuilderFactory.createNodeHandle(node);\n },\n tabs(config: {\n id?: string;\n renderer?: string;\n tabs: ITabDefinitionInput[];\n rules?: IRule[];\n }): ILayoutNodeHandle {\n const node: ITabsNode = {\n type: \"tabs\",\n id: config.id,\n renderer: config.renderer,\n tabs: config.tabs.map(LayoutBuilderFactory.resolveTabDefinition),\n rules: config.rules\n };\n return LayoutBuilderFactory.createNodeHandle(node);\n },\n element(renderer: string, props?: Record<string, unknown>): ILayoutNodeHandle {\n const node: IElementNode = { type: \"element\", renderer, props };\n return LayoutBuilderFactory.createNodeHandle(node);\n },\n object(\n fieldName: string,\n inner:\n | ((layout: ILayoutBuilder) => ILayoutNodeBuilder[])\n | Record<string, (layout: ILayoutBuilder) => ILayoutNodeBuilder[]>\n ): ILayoutNodeHandle {\n const node: IObjectNode = {\n type: \"object\",\n fieldName,\n inner: LayoutBuilderFactory.resolveObjectInner(inner)\n };\n return LayoutBuilderFactory.createNodeHandle(node);\n },\n remove(target: string): void {\n removals.push(target);\n }\n };\n }\n\n applyModifications(\n layout: LayoutNode[],\n factory: (modifier: ILayoutModifier) => (LayoutNode | IPositionedLayoutNode)[]\n ): LayoutNode[] {\n const removals: string[] = [];\n const modifierAPI = this.createModifierAPI(removals);\n const entries = factory(modifierAPI);\n\n let result = layout;\n\n for (const target of removals) {\n result = this.removeFromLayout(result, target);\n }\n\n for (const entry of entries) {\n if (this.isPositionedNode(entry)) {\n const { node, position } = entry;\n if (position) {\n result = this.insertIntoLayout(result, node, position);\n } else {\n result = [...result, node];\n }\n } else {\n result = [...result, entry];\n }\n }\n\n return result;\n }\n\n accessNode(layout: LayoutNode[], nodeId: string): ILayoutNodeAccessHandle {\n return LayoutBuilderFactory.accessNode(layout, nodeId);\n }\n\n removeFromLayout(layout: LayoutNode[], target: string): LayoutNode[] {\n return layout\n .map(node => {\n if (node.type === \"row\") {\n const filtered = node.fieldIds.filter(id => id !== target);\n if (filtered.length === 0) {\n return null;\n }\n return { ...node, fieldIds: filtered };\n }\n if (\n (node.type === \"tabs\" && node.id === target) ||\n (node.type === \"element\" && (node.id === target || node.renderer === target)) ||\n (node.type === \"object\" && node.fieldName === target)\n ) {\n return null;\n }\n return node;\n })\n .filter(Boolean) as LayoutNode[];\n }\n\n insertIntoLayout(\n layout: LayoutNode[],\n node: LayoutNode,\n position: LayoutPosition\n ): LayoutNode[] {\n const targetIndex = this.findIndex(layout, position.target);\n\n if (targetIndex === -1) {\n return [...layout, node];\n }\n\n const result = [...layout];\n\n switch (position.type) {\n case \"before\":\n result.splice(targetIndex, 0, node);\n break;\n case \"after\":\n result.splice(targetIndex + 1, 0, node);\n break;\n case \"replace\":\n result.splice(targetIndex, 1, node);\n break;\n }\n\n return result;\n }\n\n isPositionedNode(entry: LayoutNode | IPositionedLayoutNode): entry is IPositionedLayoutNode {\n return \"node\" in entry;\n }\n\n private findIndex(layout: LayoutNode[], target: string): number {\n return layout.findIndex(node => this.nodeMatchesTarget(node, target));\n }\n\n private nodeMatchesTarget(node: LayoutNode, target: string): boolean {\n switch (node.type) {\n case \"row\":\n return node.fieldIds.includes(target);\n case \"tabs\":\n return node.id === target;\n case \"element\":\n return node.id === target || node.renderer === target;\n case \"object\":\n return node.fieldName === target;\n default:\n return false;\n }\n }\n}\n"],"mappings":"AAAA,SAASA,oBAAoB;AAmB7B,OAAO,MAAMC,aAAa,CAAC;EACvBC,iBAAiBA,CAACC,QAAkB,EAAmB;IACnD,OAAO;MACHC,GAAGA,CAAC,GAAGC,QAAkB,EAAqB;QAC1C,MAAMC,IAAc,GAAG;UAAEC,IAAI,EAAE,KAAK;UAAEF;QAAS,CAAC;QAChD,OAAOL,oBAAoB,CAACQ,gBAAgB,CAACF,IAAI,CAAC;MACtD,CAAC;MACDG,SAASA,CAAA,EAAsB;QAC3B,MAAMH,IAAoB,GAAG;UAAEC,IAAI,EAAE;QAAY,CAAC;QAClD,OAAOP,oBAAoB,CAACQ,gBAAgB,CAACF,IAAI,CAAC;MACtD,CAAC;MACDI,IAAIA,CAACC,MAKJ,EAAqB;QAClB,MAAML,IAAe,GAAG;UACpBC,IAAI,EAAE,MAAM;UACZK,EAAE,EAAED,MAAM,CAACC,EAAE;U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MAC7B,KAAK,SAAS;QACV,OAAOlB,IAAI,CAACM,EAAE,KAAKY,MAAM,IAAIlB,IAAI,CAACO,QAAQ,KAAKW,MAAM;MACzD,KAAK,QAAQ;QACT,OAAOlB,IAAI,CAACc,SAAS,KAAKI,MAAM;MACpC;QACI,OAAO,KAAK;IACpB;EACJ;AACJ","ignoreList":[]}
@@ -0,0 +1,26 @@
1
+ import type { ObservableMap } from "mobx";
2
+ import type { IField, IRule, LayoutNode, LayoutNodeVM } from "./abstractions.js";
3
+ type RuleEvaluatorFn = (rules: IRule[] | undefined) => {
4
+ visible: boolean;
5
+ disabled: boolean;
6
+ };
7
+ export declare class LayoutResolver {
8
+ private _fields;
9
+ private _activeTabs;
10
+ private _evaluateRules;
11
+ constructor(_fields: Map<string, IField>, _activeTabs: ObservableMap<string, string>, _evaluateRules: RuleEvaluatorFn);
12
+ resolve(layout: LayoutNode[]): LayoutNodeVM[];
13
+ resolveChildLayout(layout: LayoutNode[], children: Map<string, IField>): LayoutNodeVM[];
14
+ collectFieldIds(layout: LayoutNode[]): string[];
15
+ private resolveNode;
16
+ private resolveRowNode;
17
+ private resolveSeparatorNode;
18
+ private resolveTabsNode;
19
+ private resolveElementNode;
20
+ private resolveObjectNode;
21
+ private resolveChildNode;
22
+ private resolveChildTabsNode;
23
+ private tabHasErrors;
24
+ private childTabHasErrors;
25
+ }
26
+ export {};