@componyx/ui 0.0.0-stage → 1.0.4

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 (169) hide show
  1. package/AppSkin/AppSkin.css +1268 -0
  2. package/AppSkin/AppSkin.js +2748 -0
  3. package/AppSkin/Themes/Default.css +241 -0
  4. package/Base/Base.js +3407 -0
  5. package/Base/ComponentIcons.css +66 -0
  6. package/Base/Font/ComponentIcons.woff +0 -0
  7. package/Base/Font/UI.woff +0 -0
  8. package/Base/Library.js +8432 -0
  9. package/Base/NavigationManager.js +462 -0
  10. package/Base/ResponsiveTemplates.js +371 -0
  11. package/Base/Sanitizer.js +288 -0
  12. package/Base/Themes/Default.css +255 -0
  13. package/Base/UI.css +618 -0
  14. package/Base/UIResourcePath.js +6 -0
  15. package/Bindary/Bindary.js +2011 -0
  16. package/Bindary/Modules/Connection.js +216 -0
  17. package/Bindary/Modules/Core.js +854 -0
  18. package/Bindary/Modules/DataUpdater.js +351 -0
  19. package/Bindary/Modules/ExpressionEngine.js +347 -0
  20. package/Bindary/Modules/ProxyManager.js +482 -0
  21. package/Bindary/Modules/Renderer.js +605 -0
  22. package/Bindary/Modules/Router.js +291 -0
  23. package/Bindary/Modules/Scroller.js +89 -0
  24. package/Bindary/Modules/Template.js +1273 -0
  25. package/BookmarkSpy/BookmarkSpy.js +430 -0
  26. package/Box/Box.css +36 -0
  27. package/Box/Box.js +1685 -0
  28. package/Button/Button.css +470 -0
  29. package/Button/Button.js +1398 -0
  30. package/Button/Themes/Default.css +200 -0
  31. package/Carousel/Carousel.css +273 -0
  32. package/Carousel/Carousel.js +607 -0
  33. package/ColorButton/ColorButton.css +39 -0
  34. package/ColorButton/ColorButton.js +336 -0
  35. package/ColorPicker/ColorPicker.css +359 -0
  36. package/ColorPicker/ColorPicker.js +972 -0
  37. package/ComboBox/ComboBox.css +357 -0
  38. package/ComboBox/ComboBox.js +2342 -0
  39. package/ComboBox/Themes/Default.css +23 -0
  40. package/DataPager/DataPager.css +72 -0
  41. package/DataPager/DataPager.js +674 -0
  42. package/DatePicker/DatePicker.css +227 -0
  43. package/DatePicker/DatePicker.js +1531 -0
  44. package/DatePicker/Themes/Default.css +26 -0
  45. package/Dialog/Dialog.css +106 -0
  46. package/Dialog/Dialog.js +572 -0
  47. package/Dialog/Themes/Default.css +10 -0
  48. package/Editor/Data/Emoji.json +8285 -0
  49. package/Editor/Data/Special.json +1042 -0
  50. package/Editor/Editor.css +1562 -0
  51. package/Editor/Editor.js +4058 -0
  52. package/Editor/Font/Editor.woff +0 -0
  53. package/Editor/Modules/ComponentFactory.js +565 -0
  54. package/Editor/Modules/ContentManager.js +748 -0
  55. package/Editor/Modules/DialogManager.js +1234 -0
  56. package/Editor/Modules/EventManager.js +458 -0
  57. package/Editor/Modules/Format.js +950 -0
  58. package/Editor/Modules/History.js +191 -0
  59. package/Editor/Modules/LayoutState.js +379 -0
  60. package/Editor/Modules/ListManager.js +296 -0
  61. package/Editor/Modules/MenuManager.js +388 -0
  62. package/Editor/Modules/NodeManager.js +681 -0
  63. package/Editor/Modules/ParagraphButtons.js +122 -0
  64. package/Editor/Modules/Resizer.js +176 -0
  65. package/Editor/Modules/SelectionRange.js +564 -0
  66. package/Editor/Modules/SourceViewBuilder.js +212 -0
  67. package/Editor/Modules/SymbolPicker.js +208 -0
  68. package/Editor/Modules/Table.js +2327 -0
  69. package/Editor/Modules/TableDialog.js +757 -0
  70. package/Editor/Modules/Toolbar.js +375 -0
  71. package/Editor/Modules/TooltipMenu.js +125 -0
  72. package/Editor/Modules/Utility.js +131 -0
  73. package/Editor/Themes/Default.css +204 -0
  74. package/FileUpload/FileUpload.css +156 -0
  75. package/FileUpload/FileUpload.js +898 -0
  76. package/FileUpload/Themes/Default.css +17 -0
  77. package/Form/Form.css +1934 -0
  78. package/Form/Form.js +4943 -0
  79. package/Form/Modules/ActionManager.js +368 -0
  80. package/Form/Modules/BuildPanelManager.js +319 -0
  81. package/Form/Modules/ComponentFactory.js +468 -0
  82. package/Form/Modules/ComponentPanel.js +265 -0
  83. package/Form/Modules/ConfigPanelManager.js +685 -0
  84. package/Form/Modules/DataBinder.js +602 -0
  85. package/Form/Modules/DataObserver.js +717 -0
  86. package/Form/Modules/Draggable.js +756 -0
  87. package/Form/Modules/OptionsPanel.js +342 -0
  88. package/Form/Modules/Renderer.js +1889 -0
  89. package/Form/Modules/RuleEngine.js +585 -0
  90. package/Form/Modules/RulesPanel.js +1158 -0
  91. package/Form/Modules/Types.js +1709 -0
  92. package/Form/Modules/ValidationManager.js +194 -0
  93. package/Form/Themes/Default.css +216 -0
  94. package/FormField/FormField.css +468 -0
  95. package/FormField/FormField.js +576 -0
  96. package/FormField/Themes/Default.css +99 -0
  97. package/Grid/Grid.css +544 -0
  98. package/Grid/Grid.js +3761 -0
  99. package/Grid/Themes/Default.css +43 -0
  100. package/LICENSE +126 -0
  101. package/MaskedTextBox/MaskedTextBox.css +28 -0
  102. package/MaskedTextBox/MaskedTextBox.js +642 -0
  103. package/MaskedTextBox/Themes/Default.css +6 -0
  104. package/Menu/Menu.css +328 -0
  105. package/Menu/Menu.js +2386 -0
  106. package/Menu/Themes/Default.css +24 -0
  107. package/NumericBox/NumericBox.css +120 -0
  108. package/NumericBox/NumericBox.js +984 -0
  109. package/PanelBar/PanelBar.css +123 -0
  110. package/PanelBar/PanelBar.js +505 -0
  111. package/PanelBar/Themes/Default.css +51 -0
  112. package/PieChart/PieChart.css +95 -0
  113. package/PieChart/PieChart.js +820 -0
  114. package/PieChart/Themes/Default.css +9 -0
  115. package/README.md +178 -3
  116. package/Slider/Slider.css +348 -0
  117. package/Slider/Slider.js +1306 -0
  118. package/Slider/Themes/Default.css +44 -0
  119. package/TabStrip/TabStrip.css +52 -0
  120. package/TabStrip/TabStrip.js +362 -0
  121. package/TabStrip/Themes/Default.css +35 -0
  122. package/TimePicker/Themes/Default.css +30 -0
  123. package/TimePicker/TimePicker.css +253 -0
  124. package/TimePicker/TimePicker.js +1485 -0
  125. package/TooltipManager/Themes/Default.css +21 -0
  126. package/TooltipManager/TooltipManager.css +227 -0
  127. package/TooltipManager/TooltipManager.js +791 -0
  128. package/Validator/Validator.css +54 -0
  129. package/Validator/Validator.js +2508 -0
  130. package/componyx.html-data.json +619 -0
  131. package/index.js +27 -0
  132. package/package.json +43 -4
  133. package/types/AppSkin.d.ts +842 -0
  134. package/types/Base.d.ts +1034 -0
  135. package/types/Bindary.d.ts +1196 -0
  136. package/types/BookmarkSpy.d.ts +112 -0
  137. package/types/Box.d.ts +374 -0
  138. package/types/Button.d.ts +455 -0
  139. package/types/Carousel.d.ts +136 -0
  140. package/types/ColorButton.d.ts +120 -0
  141. package/types/ColorPicker.d.ts +225 -0
  142. package/types/ComboBox.d.ts +507 -0
  143. package/types/DataPager.d.ts +152 -0
  144. package/types/DatePicker.d.ts +354 -0
  145. package/types/Dialog.d.ts +160 -0
  146. package/types/Editor.d.ts +1289 -0
  147. package/types/FileUpload.d.ts +206 -0
  148. package/types/Form.d.ts +3078 -0
  149. package/types/FormField.d.ts +204 -0
  150. package/types/Grid.d.ts +911 -0
  151. package/types/Library.d.ts +1899 -0
  152. package/types/MaskedTextBox.d.ts +91 -0
  153. package/types/Menu.d.ts +577 -0
  154. package/types/NumericBox.d.ts +310 -0
  155. package/types/PanelBar.d.ts +223 -0
  156. package/types/PieChart.d.ts +224 -0
  157. package/types/ResponsiveTemplates.d.ts +108 -0
  158. package/types/Slider.d.ts +227 -0
  159. package/types/TabStrip.d.ts +185 -0
  160. package/types/TimePicker.d.ts +265 -0
  161. package/types/TooltipManager.d.ts +178 -0
  162. package/types/UI.d.ts +29 -0
  163. package/types/Validator.d.ts +653 -0
  164. package/types/index.d.ts +59 -0
  165. package/ui.css +11783 -0
  166. package/ui.js +79477 -0
  167. package/ui.min.css +138 -0
  168. package/ui.min.js +264 -0
  169. package/ui.min.js.map +1 -0
@@ -0,0 +1,368 @@
1
+ /*! Componyx.UI | (c) E.H. Daanen / Componyx | BUSL-1.1 | componyx.com/license */
2
+ componyx.UI.form_modules = componyx.UI.form_modules || {};
3
+
4
+ componyx.UI.form_modules.ActionManager = class ActionManager
5
+ {
6
+ constructor(form)
7
+ {
8
+ this.form = form;
9
+ this.cf = form.componentFactory;
10
+ this.expressionEngine = form.expressionEngine;
11
+ }
12
+
13
+ registerDefaultActions()
14
+ {
15
+ const actions = [
16
+ {
17
+ id: 'value',
18
+ config: {
19
+ supportsFieldSet: false,
20
+ setValue: true,
21
+ label: this.form.labels.action_value,
22
+ execute: (action, target) =>
23
+ {
24
+ this.form.dataBinder.setModelValue(target, action.value);
25
+ this.form.ruleEngine.updateRuleDrivenState(target, 'value', action.value);
26
+ this.updateTarget(target);
27
+ }
28
+ }
29
+ },
30
+ {
31
+ id: 'expression',
32
+ config: {
33
+ supportsFieldSet: false,
34
+ setExpression: true,
35
+ label: this.form.labels.action_expression,
36
+ execute: (action, target) =>
37
+ {
38
+ const value = this.evaluateExpression(action.expression);
39
+ this.form.dataBinder.setModelValue(target, value);
40
+ this.form.ruleEngine.updateRuleDrivenState(target, 'value', value);
41
+ this.updateTarget(target);
42
+ }
43
+ }
44
+ },
45
+ {
46
+ id: 'feedback',
47
+ config: {
48
+ supportsFieldSet: false,
49
+ setExpression: true,
50
+ label: this.form.labels.action_feedback,
51
+ execute: (action, target) =>
52
+ {
53
+ const ruleFeedbackEl = target.element.querySelector('.' + this.form.getCssClass(this.form.classOption.RULE_FEEDBACK)),
54
+ message = this.evaluateExpression(action.expression);
55
+
56
+ ruleFeedbackEl.textContent = message;
57
+ this.form.ruleEngine.updateRuleDrivenState(target, 'feedback', message);
58
+ }
59
+ },
60
+ },
61
+ {
62
+ id: 'alert',
63
+ config: {
64
+ supportsFieldSet: false,
65
+ setExpression: true,
66
+ label: this.form.labels.action_alert,
67
+ execute: (action, target) =>
68
+ {
69
+ const id = `${this.form.id}_${action.id}_alert`,
70
+ dialog = this.cf.createComponent(this.form, componyx.UI.Dialog, this.cf.createElement(id).id, this.form.alertDialogId);
71
+
72
+ dialog.alert(null, this.form.labels.alertDialogHeader, this.evaluateExpression(action.expression));
73
+ }
74
+ },
75
+ },
76
+ {
77
+ id: 'confirm',
78
+ config: {
79
+ supportsFieldSet: false,
80
+ setExpression: true,
81
+ mustAwait: true,
82
+ label: this.form.labels.action_confirm,
83
+ execute: async (action, target) =>
84
+ {
85
+ return new Promise(resolve =>
86
+ {
87
+ const id = `${this.form.id}_${action.id}_confirm`,
88
+ dialog = this.cf.createComponent(this.form, componyx.UI.Dialog, this.cf.createElement(id).id, this.form.confirmDialogId);
89
+
90
+ dialog.confirm((dialog, userConfirmed) =>
91
+ {
92
+ resolve({ success: !!userConfirmed });
93
+ }, this.form.labels.confirmDialogHeader, this.evaluateExpression(action.expression));
94
+ });
95
+ }
96
+ },
97
+ },
98
+ {
99
+ id: 'hide',
100
+ config: {
101
+ supportsFieldSet: true,
102
+ label: this.form.labels.action_hide,
103
+ execute: (action, target) =>
104
+ {
105
+ target.visible = false;
106
+ this.updateTarget(target);
107
+ }
108
+ }
109
+ },
110
+ {
111
+ id: 'show',
112
+ config: {
113
+ supportsFieldSet: true,
114
+ label: this.form.labels.action_show,
115
+ execute: (action, target) =>
116
+ {
117
+ target.visible = true;
118
+ this.updateTarget(target);
119
+ }
120
+ }
121
+ },
122
+ {
123
+ id: 'disable',
124
+ config: {
125
+ supportsFieldSet: true,
126
+ label: this.form.labels.action_disable,
127
+ execute: (action, target) =>
128
+ {
129
+ this.toggleDisabledState(action, target, true);
130
+ }
131
+ }
132
+ },
133
+ {
134
+ id: 'enable',
135
+ config: {
136
+ supportsFieldSet: true,
137
+ label: this.form.labels.action_enable,
138
+ execute: (action, target) =>
139
+ {
140
+ this.toggleDisabledState(action, target, false);
141
+ }
142
+ }
143
+ },
144
+ {
145
+ id: 'required',
146
+ config: {
147
+ supportsFieldSet: true,
148
+ label: this.form.labels.action_required,
149
+ execute: (action, target) =>
150
+ {
151
+ const isFieldSet = (target.type === 'FieldSet'),
152
+ fields = (isFieldSet ? this.form.getFields(target) || [] : [target]);
153
+
154
+ fields.forEach((f) =>
155
+ {
156
+ f.required = true;
157
+ this.form.renderer.updateField(f);
158
+ });
159
+ }
160
+ }
161
+ },
162
+ {
163
+ id: 'optional',
164
+ config: {
165
+ supportsFieldSet: true,
166
+ label: this.form.labels.action_optional,
167
+ execute: (action, target) =>
168
+ {
169
+ const isFieldSet = (target.type === 'FieldSet'),
170
+ fields = (isFieldSet ? this.form.getFields(target) || [] : [target]);
171
+
172
+ fields.forEach((f) =>
173
+ {
174
+ f.required = false;
175
+ this.form.renderer.updateField(f);
176
+ });
177
+ }
178
+ },
179
+ },
180
+ {
181
+ id: 'readonly',
182
+ config: {
183
+ supportsFieldSet: false,
184
+ label: this.form.labels.action_read,
185
+ execute: (action, target) =>
186
+ {
187
+ target.readOnly = true;
188
+ this.updateTarget(target);
189
+ }
190
+ }
191
+ },
192
+ {
193
+ id: 'editable',
194
+ config: {
195
+ supportsFieldSet: false,
196
+ label: this.form.labels.action_editable,
197
+ execute: (action, target) =>
198
+ {
199
+ target.readOnly = false;
200
+ this.updateTarget(target);
201
+ }
202
+ }
203
+ },
204
+ {
205
+ id: 'disable_next',
206
+ config: {
207
+ supportsFieldSet: false,
208
+ label: this.form.labels.action_disable_next,
209
+ execute: (action, target) =>
210
+ {
211
+ const button = (!this.form.hasSections() || this.form.isLastSection()) ? this.form.renderer.submitButton : this.form.renderer.nextButton;
212
+ button?.disable();
213
+ }
214
+ }
215
+ },
216
+ {
217
+ id: 'enable_next',
218
+ config: {
219
+ supportsFieldSet: false,
220
+ label: this.form.labels.action_enable_next,
221
+ execute: (action, target) =>
222
+ {
223
+ const button = (!this.form.hasSections() || this.form.isLastSection()) ? this.form.renderer.submitButton : this.form.renderer.nextButton;
224
+ button?.enable();
225
+ }
226
+ }
227
+ },
228
+ {
229
+ id: 'cancel_submit',
230
+ config: {
231
+ supportsFieldSet: false,
232
+ label: this.form.labels.action_cancel,
233
+ execute: (action, target) =>
234
+ {
235
+ this.form.submitCanceled = true;
236
+ }
237
+ }
238
+ },
239
+ {
240
+ id: 'show_section',
241
+ config: {
242
+ supportsFieldSet: false,
243
+ setValue: true,
244
+ label: this.form.labels.action_show_section,
245
+ execute: (action, target) =>
246
+ {
247
+ if (!this.form.hasSections() || !action.value)
248
+ return;
249
+
250
+ const section = this.form.fieldSets.find((s) => s.id === action.value);
251
+
252
+ if (section)
253
+ this.form.showSection(section);
254
+ }
255
+ }
256
+ },
257
+ {
258
+ id: 'end_form',
259
+ config: {
260
+ supportsFieldSet: false,
261
+ label: this.form.labels.action_end,
262
+ execute: (action, target) =>
263
+ {
264
+ this.form.ended = true;
265
+ this.form.events.onEndForm.fire(this.form);
266
+ return false;
267
+ }
268
+ }
269
+ }
270
+ ];
271
+
272
+ actions.forEach((a) => { this.form.registerAction(a.id, a.config); });
273
+ this.registerApiActions();
274
+ }
275
+
276
+ toggleDisabledState(action, target, disabled)
277
+ {
278
+ const opts = target.options || [],
279
+ selectedValues = new Set(action.value || []),
280
+ InputTypeOption = this.form.constructor.InputTypeOption,
281
+ isOptionField = [InputTypeOption.CHECKBOX, InputTypeOption.SWITCH, InputTypeOption.RADIO, InputTypeOption.COMBOBOX].includes(target.inputType);
282
+
283
+ if (target.type == 'Field' && isOptionField && selectedValues.size)
284
+ {
285
+ if (selectedValues.size === opts.length)
286
+ {
287
+ target.disabled = disabled;
288
+ }
289
+ else
290
+ {
291
+ opts.forEach(opt =>
292
+ {
293
+ if (selectedValues.has(opt.value))
294
+ opt.disabled = disabled;
295
+ });
296
+ }
297
+ }
298
+ else
299
+ {
300
+ target.disabled = disabled;
301
+ }
302
+
303
+ this.updateTarget(target);
304
+ }
305
+
306
+ updateTarget(target)
307
+ {
308
+ if (target.type === 'FieldSet')
309
+ this.form.renderer.updateFieldSet(target);
310
+ else
311
+ this.form.renderer.updateField(target);
312
+ }
313
+
314
+
315
+ registerApiActions()
316
+ {
317
+ this.form.actionEndpoints.forEach(endpoint =>
318
+ {
319
+ this.form.registerAction(`api_${endpoint.id}`,
320
+ {
321
+ supportsFieldSet: false,
322
+ mustAwait: true,
323
+ label: `${endpoint.label}`,
324
+ execute: async (action, target) =>
325
+ {
326
+ const result = await this.form.fetchFromEndpoint(endpoint, { form: this.form, action, target }),
327
+ formCtor = this.form.constructor;
328
+
329
+ if ($lib.isEmpty(result.actions))
330
+ return result;
331
+
332
+ const fieldsById = new Map(this.form.getFields().map(f => [f.id, f]));
333
+
334
+ for (const act of result.actions) // API response includes actions
335
+ {
336
+ const targetField = fieldsById.get(act.fieldId);
337
+
338
+ await this.form.executeAction(new formCtor.Action({
339
+ runtimeActionId: act.runtimeActionId,
340
+ value: act.value
341
+ }), targetField);
342
+ }
343
+
344
+ return result;
345
+ }
346
+ });
347
+ });
348
+ }
349
+
350
+ evaluateExpression(expr)
351
+ {
352
+ const fields = this.form.getFields();
353
+
354
+ const resolver = (token) =>
355
+ {
356
+ const field = fields.find(f => f.name === token);
357
+ if (!field) return '""';
358
+ const value = this.form.dataBinder.getModelValue(field);
359
+ return (value !== undefined) ? value : null;
360
+ };
361
+
362
+ return this.expressionEngine.evaluate(expr)(resolver); // create and execute directly with our field resolver
363
+ }
364
+ };
365
+
366
+ var ActionManager = componyx.UI.form_modules.ActionManager;
367
+
368
+ export { ActionManager as default };
@@ -0,0 +1,319 @@
1
+ /*! Componyx.UI | (c) E.H. Daanen / Componyx | BUSL-1.1 | componyx.com/license */
2
+ componyx.UI.form_modules = componyx.UI.form_modules || {};
3
+ componyx.UI.form_modules.BuildPanelManager = class BuildPanelManager
4
+ {
5
+ #classOption;
6
+ #navigatorUpdateTimerId;
7
+ #navigatorItemUpdateTimerId;
8
+ #navigatorSearchTimerId;
9
+ #navigatorItems = [];
10
+
11
+ constructor(form)
12
+ {
13
+ this.form = form;
14
+ this.panelBar = null;
15
+ this.cf = form.componentFactory;
16
+ this.navigatorMenu = null;
17
+ this.navigatorSearchInput = null;
18
+ this.#classOption = form.classOption;
19
+ }
20
+
21
+ createPanelBar(container, id, cloneId, panels)
22
+ {
23
+ const panelBar = $UI.createComponent(componyx.UI.PanelBar, { id: id, containerElement: container });
24
+ panelBar.clone($UI.store[cloneId], this.form);
25
+
26
+ panelBar.events.onPostRender.priorityAdd(() =>
27
+ {
28
+ this.createBuildBlocks();
29
+
30
+ if (this.form.navigatorPanelId && this.panelBar.panels.find(p => p.id === this.form.navigatorPanelId))
31
+ this.createNavigator();
32
+
33
+ }, null);
34
+
35
+ panelBar.events.onPostRender.priorityAdd(() =>
36
+ {
37
+ this.form.isReady();
38
+ }, null, true);
39
+
40
+ panelBar.expandOnPointerEnter = false;
41
+ panelBar.multiExpand = true;
42
+ panelBar.showing = true;
43
+ panelBar.panels = panels;
44
+ this.panelBar = panelBar;
45
+ }
46
+
47
+ createBuildBlocks()
48
+ {
49
+ this.form.buildBlocks.forEach((buildBlock, index) =>
50
+ {
51
+ const panelId = buildBlock.panelId,
52
+ panel = (!$lib.isEmpty(panelId)) ? this.panelBar.panels.find(p => p.id === panelId) : this.panelBar.panels[0],
53
+ contentEl = panel.contentElement;
54
+
55
+ buildBlock.id = ($lib.isEmpty(buildBlock.id)) ? `build_item_${index}` : buildBlock.id;
56
+
57
+ if (buildBlock.label?.startsWith(':'))
58
+ {
59
+ const key = buildBlock.label.slice(1);
60
+
61
+ if (this.form.labels[key])
62
+ buildBlock.label = this.form.labels[key];
63
+ }
64
+
65
+ this.createBuildBlock(buildBlock, contentEl);
66
+ });
67
+
68
+ this.form.renderChildren(); // render panel-bar buttons
69
+ }
70
+
71
+ createBuildBlock(buildBlock, panelContentEl)
72
+ {
73
+ let element = this.createBuildBlockElement(buildBlock, panelContentEl);
74
+ this.cf.createButton(element, this.form.getId(buildBlock, 'insert'), this.insertBuildBlockButtonId,
75
+ {
76
+ hasIcon: true,
77
+ cssClassIcon: 'ico-plus',
78
+ cssClass: this.form.getCssClass(this.#classOption.BUILD_BLOCK_INSERT),
79
+ command: this.form.insertBuildBlock.bind(this.form, buildBlock)
80
+ });
81
+
82
+ this.form.draggable.createDraggableField(buildBlock);
83
+ }
84
+
85
+ createBuildBlockElement(buildBlock, container)
86
+ {
87
+ const element = $lib.element(container, '', '', '', { "class": `${this.form.getCssClass(this.#classOption.BUILD_BLOCK)} ${buildBlock.cssClass}`.trim() });
88
+
89
+ this.cf.createDragHandle(element);
90
+ $lib.element(element, '', 'i', '', { "class": `${this.form.getCssClass(this.#classOption.ICON)} ${buildBlock.cssClassIcon}`.trim() });
91
+ const labelEl = $lib.element(element, '', 'span', '', { "class": `${this.form.getCssClass(this.#classOption.LABEL)}`.trim() });
92
+
93
+ labelEl.innerHTML = buildBlock.label;
94
+ buildBlock.element = element;
95
+ return element;
96
+ }
97
+
98
+ createNavigator()
99
+ {
100
+ const panelId = this.form.navigatorPanelId,
101
+ panel = this.panelBar.panels.find(p => p.id === panelId),
102
+ contentEl = panel.contentElement,
103
+ inputWrapper = $lib.element({ container: contentEl });
104
+
105
+ this.navigatorSearchInput = this.cf.createInput({
106
+ container: inputWrapper,
107
+ type: 'text',
108
+ placeholder: this.form.labels.navigatorSearchHint,
109
+ events: {
110
+ oninput: () =>
111
+ {
112
+ clearTimeout(this.#navigatorSearchTimerId);
113
+
114
+ this.#navigatorSearchTimerId = setTimeout(() =>
115
+ {
116
+ const fields = this.form.getFields(),
117
+ query = this.navigatorSearchInput.value.toLowerCase(),
118
+ foundField = fields.find(f => ((f.label || '') + ' ' + (f.name || '')).toLowerCase().includes(query));
119
+
120
+ if (!foundField)
121
+ {
122
+ this.navigatorMenu.deselectItem();
123
+ return;
124
+ }
125
+
126
+ let expandList = [],
127
+ current = foundField;
128
+
129
+ while (current.parent)
130
+ {
131
+ expandList.push(current.parent.id);
132
+ current = current.parent;
133
+ }
134
+
135
+ this.navigatorMenu.expand(expandList.reverse(), null, false, true);
136
+
137
+ const button = $UI.store[`${this.navigatorMenu.id}_${foundField.id}`];
138
+ button.element.scrollIntoView({ behavior: "smooth", block: "nearest" });
139
+ this.navigatorMenu.selectItem(foundField.id);
140
+ this.navigatorSearchInput.focus();
141
+ }, this.form.navigatorSearchDelay);
142
+ }
143
+ }
144
+ });
145
+ this.navigatorSearchInput.style.display = 'none';
146
+
147
+ this.navigatorMenu = this.cf.createComponent(contentEl,
148
+ componyx.UI.Menu,
149
+ `${this.form.id}_navigator_menu`,
150
+ this.form.navigatorMenuId,
151
+ {
152
+ horizontalRoot: false,
153
+ itemGroupStyle: "position: static",
154
+ itemList: this.buildNavigatorMenu(),
155
+ events: {
156
+ onPostRender: () => { this.navigatorSearchInput.style.display = ''; },
157
+ onItemSelect: (menu, args) => { this.selectItem(args); }
158
+ }
159
+ });
160
+
161
+ this.navigatorMenu.render();
162
+ }
163
+
164
+ scheduleNavigatorUpdate()
165
+ {
166
+ if (!this.navigatorMenu || this.navigatorMenu.renderState !== $base.static.RenderState.RENDERED)
167
+ return;
168
+
169
+ this.#navigatorItems = []; // complete update, clear list
170
+ clearTimeout(this.#navigatorItemUpdateTimerId);
171
+ clearTimeout(this.#navigatorUpdateTimerId);
172
+ this.#navigatorUpdateTimerId = setTimeout(() => { this.updateNavigator(); });
173
+ }
174
+
175
+ scheduleNavigatorItemUpdate(item, isRemoveField)
176
+ {
177
+ if (!this.navigatorMenu || this.navigatorMenu.renderState !== $base.static.RenderState.RENDERED || this.#navigatorUpdateTimerId)
178
+ return;
179
+
180
+ this.#navigatorItems.push({item, isRemoveField});
181
+ clearTimeout(this.#navigatorItemUpdateTimerId);
182
+ this.#navigatorItemUpdateTimerId = setTimeout(() =>
183
+ {
184
+ this.#navigatorItems.forEach((r) => this.updateNavigatorItem(r.item, r.isRemoveField));
185
+ this.#navigatorItems = [];
186
+ this.#navigatorItemUpdateTimerId = null;
187
+ });
188
+ }
189
+
190
+ updateNavigatorItem(item, isRemoveField)
191
+ {
192
+ if (!this.navigatorMenu || this.navigatorMenu.renderState !== $base.static.RenderState.RENDERED)
193
+ return;
194
+
195
+ const menu = this.navigatorMenu,
196
+ itemPath = menu.loadItem(item.id),
197
+ menuItem = itemPath?.item;
198
+
199
+ if (!menuItem) // update could happen directly after creation of field
200
+ return;
201
+
202
+ if (isRemoveField)
203
+ {
204
+ const parentItem = itemPath.hasParent() ? itemPath.parent().item : null;
205
+
206
+ menu.removeItem(item.id);
207
+
208
+ if (parentItem && parentItem.itemList)
209
+ {
210
+ const index = parentItem.itemList.findIndex(i => i.id === item.id);
211
+ if (index >= 0)
212
+ parentItem.itemList.splice(index, 1);
213
+ }
214
+
215
+ menuItem.itemList = [];
216
+ }
217
+ else // update
218
+ {
219
+ menuItem.text = item.label || item.name || item.id;
220
+ menu.renderItem(menuItem);
221
+
222
+ if (menuItem.expanded)
223
+ menu.expand(menuItem.id, null, false, true);
224
+ }
225
+ }
226
+
227
+ updateNavigator()
228
+ {
229
+ const menu = this.navigatorMenu,
230
+ expandedItems = this.navigatorMenu.getExpandedItems();
231
+
232
+ menu.itemList = this.buildNavigatorMenu();
233
+ menu.destroy();
234
+ menu.events.onPostRender.priorityAdd(() =>
235
+ {
236
+ this.navigatorSearchInput.style.display = '';
237
+
238
+ if (expandedItems?.length)
239
+ {
240
+ const expandedIds = expandedItems.filter(item =>
241
+ {
242
+ if (item.attributes.type === 'Section')
243
+ return this.form.getSection(item.id);
244
+ else if (item.attributes.type === 'FieldSet')
245
+ return this.form.getFieldSet(item.id);
246
+ else // field
247
+ return this.form.getField(item.id);
248
+ }).map(item => item.id);
249
+
250
+ if (expandedIds.length)
251
+ this.navigatorMenu.expand(expandedIds, null, false, true);
252
+ }
253
+ });
254
+ menu.events.onItemSelect.priorityAdd((menu, args) => { this.selectItem(args); });
255
+ menu.render();
256
+ this.#navigatorUpdateTimerId = null;
257
+ }
258
+
259
+ selectItem(args)
260
+ {
261
+ const item = args.item,
262
+ type = item.attributes.type;
263
+
264
+ if (this.form.isField(type))
265
+ this.form.selectField(this.form.getField(item.id));
266
+ else if (type === 'FieldSet')
267
+ this.form.selectFieldSet(this.form.getFieldSet(item.id));
268
+ else
269
+ this.form.selectSection(this.form.getSection(item.id));
270
+ }
271
+
272
+ buildNavigatorMenu(fieldSets = this.form.fieldSets, parentItem = null)
273
+ {
274
+ const itemList = parentItem ? parentItem.itemList = [] : [];
275
+
276
+ fieldSets.forEach((fs) =>
277
+ {
278
+ const cssClassIcon = fs.type === 'Section' ? 'ico-folder-closed' : 'ico-group',
279
+ item = new componyx.UI.Menu.Item(
280
+ {
281
+ id: fs.id,
282
+ text: fs.label || fs.id,
283
+ hasIcon: true,
284
+ cssClassIcon: `${this.form.getCssClass(this.#classOption.ICON)} ${cssClassIcon}`.trim(),
285
+ attributes: { type: fs.type }
286
+ });
287
+
288
+ itemList.push(item);
289
+
290
+ if (!$lib.isEmpty(fs.fieldSets))
291
+ this.buildNavigatorMenu(fs.fieldSets, item);
292
+ else
293
+ {
294
+ (fs.fields || []).forEach((f) =>
295
+ {
296
+ const fieldItem = new componyx.UI.Menu.Item(
297
+ {
298
+ id: f.id,
299
+ text: f.label || f.name,
300
+ hasIcon: true,
301
+ cssClassIcon: `${this.form.getCssClass(this.#classOption.ICON)} ${f.cssClassIcon}`.trim(),
302
+ attributes: { type: f.type }
303
+ });
304
+
305
+ item.itemList = item.itemList || [];
306
+ item.itemList.push(fieldItem);
307
+ });
308
+ }
309
+ });
310
+
311
+ return itemList;
312
+ }
313
+
314
+
315
+ };
316
+
317
+ var BuildPanelManager = componyx.UI.form_modules.BuildPanelManager;
318
+
319
+ export { BuildPanelManager as default };