@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,265 @@
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.ComponentPanel = class ComponentPanel
5
+ {
6
+ constructor(form, configPanelManager)
7
+ {
8
+ this.form = form;
9
+ this.cf = form.componentFactory;
10
+ this.cpm = configPanelManager;
11
+ this.InputTypeOption = this.cpm.InputTypeOption;
12
+ }
13
+
14
+ render(field)
15
+ {
16
+ const panelId = 'ComponentPanel',
17
+ typeName = this.cf.getComponentType(field.inputType).name,
18
+ templateId = `ComponentPanel_${typeName}`,
19
+ customTemplateId = field.panelTemplates?.[panelId],
20
+ panel = this.cpm.panelBar.panels.find(p => p.id === panelId),
21
+ contentEl = panel.contentElement,
22
+ idPrefix = `${this.form.id}_${panelId}_`,
23
+ settings = field.componentSettings || new this.form.constructor.ComponentSettings(),
24
+ namePrefix = 'componentSettings.',
25
+ panelTitle = $lib.format(this.form.labels.componentPanelHeader, this.form.labels[`${typeName.charAt(0).toLowerCase() + typeName.slice(1)}`] || typeName),
26
+ events = this.cpm.createBindingEvents(field),
27
+ createComponent = (type, id, cloneId, value, compSettings = {}, container = this.form) =>
28
+ {
29
+ return this.cf.createComponent(
30
+ container,
31
+ componyx.UI[type],
32
+ this.cf.createElement(`${idPrefix}${id}_input`).id,
33
+ this.form[cloneId],
34
+ {
35
+ ...compSettings,
36
+ name: (id === 'value') ? id : namePrefix + id,
37
+ value,
38
+ events: {
39
+ ...(compSettings.events || {}),
40
+ ...events
41
+ }
42
+ }
43
+ );
44
+ },
45
+ componentField = (type, id, cloneId, value, compSettings = {}, container) => ({
46
+ id,
47
+ label: this.form.labels[id],
48
+ fieldElement: createComponent(type, id, cloneId, value, compSettings, container).element
49
+ }),
50
+ numericField = (...args) => componentField('NumericBox', ...args),
51
+ maskedField = (...args) => componentField('MaskedTextBox', ...args),
52
+ dateField = (id, cloneId, value, compSettings = {}) =>
53
+ {
54
+ const formattedValue = (!$lib.isEmpty(value)) ? $lib.formatDate($lib.parseDate(value, 'YYYY-MM-DD'), this.form.format.dateFormat) : null;
55
+ return componentField('DatePicker', id, cloneId, formattedValue, { ...compSettings, dateFormat: this.form.format.dateFormat });
56
+ },
57
+ timeField = (...args) => componentField('TimePicker', ...args);
58
+
59
+
60
+ this.cpm.panelBar.updatePanelTitle(panel, panelTitle);
61
+ this.cpm.panelBar.showPanel(panel);
62
+
63
+ let fields = [];
64
+ let customConfigFields = [];
65
+ settings.parent = field;
66
+
67
+ switch (field.inputType)
68
+ {
69
+ case this.InputTypeOption.MASKEDTEXTBOX:
70
+ if ($lib.isEmpty(settings.mask)) settings.mask = '____-____';
71
+ if ($lib.isEmpty(settings.allowedCharacters)) settings.allowedCharacters = 0;
72
+
73
+ fields = [
74
+ { id: 'mask', type: 'input', value: settings.mask, config: { tooltipId: this.cf.addTooltip(`${idPrefix}mask_tooltip`, { tooltip: this.form.labels.maskTooltip }) } },
75
+ maskedField('value', 'valueMaskedTextBoxId', field.value, { mask: settings.mask }),
76
+ {
77
+ id: 'allowedCharacters',
78
+ type: 'radio',
79
+ options: [
80
+ { value: 0, label: this.form.labels.allowedCharactersAlphanumeric, checked: settings.allowedCharacters === 0 },
81
+ { value: 1, label: this.form.labels.allowedCharactersDigits, checked: settings.allowedCharacters === 1 },
82
+ { value: 2, label: this.form.labels.allowedCharactersLetters, checked: settings.allowedCharacters === 2 }
83
+ ]
84
+ }
85
+ ];
86
+ break;
87
+
88
+ case this.InputTypeOption.NUMERICBOX:
89
+ settings.precision = (!$lib.isEmpty(settings.precision)) ? parseFloat(settings.precision) : 0;
90
+
91
+ fields = [
92
+ numericField('precision', 'precisionNumericBoxId', settings.precision),
93
+ numericField('value', 'valueNumericBoxId', field.value, { precision: settings.precision }),
94
+ numericField('minValue', 'minValueNumericBoxId', settings.minValue, { precision: settings.precision }),
95
+ numericField('maxValue', 'maxValueNumericBoxId', settings.maxValue, { precision: settings.precision }),
96
+ ];
97
+ break;
98
+
99
+ case this.InputTypeOption.COMBOBOX:
100
+ fields = [
101
+ {
102
+ id: 'multiSelect', type: 'checkbox', checked: settings.multiSelect, config: { switch: true }, events: {
103
+ onchange: () =>
104
+ {
105
+ field.options?.forEach(opt => { opt.selected = false; });
106
+ this.cpm.renderOptionsPanel(field);
107
+ }
108
+ }
109
+ },
110
+ { id: 'multiSelectTagging', type: 'checkbox', checked: settings.multiSelectTagging, config: { switch: true } },
111
+ { id: 'allowInput', type: 'checkbox', checked: settings.allowInput, config: { switch: true } }
112
+ ];
113
+ break;
114
+
115
+ case this.InputTypeOption.DATEPICKER:
116
+ settings.allowedDates = settings.allowedDates || [];
117
+ fields = [
118
+ { id: 'today', type: 'checkbox', checked: settings.today, config: { switch: true }, events: { onchange: (evt) => { this.cpm.setDisabled(`${idPrefix + typeName}_value_field`, evt.target.checked); } } },
119
+ dateField('value', 'valueDatePickerId', field.value),
120
+ dateField('minValue', 'minValueDatePickerId', settings.minValue),
121
+ dateField('maxValue', 'maxValueDatePickerId', settings.maxValue),
122
+ { id: 'allowedDates', fieldElement: this.#createAllowedListComponent(this.cf.getComponentType(this.InputTypeOption.DATEPICKER), `${idPrefix}allowedDates_input`, this.form.addAllowedDatePickerId, settings.allowedDates) },
123
+ { id: 'disallowDates', type: 'checkbox', checked: settings.disallowDates, config: { switch: true } }
124
+ ];
125
+ break;
126
+
127
+ case this.InputTypeOption.TIMEPICKER:
128
+ settings.allowedTimes = settings.allowedTimes || [];
129
+ fields = [
130
+ timeField('value', 'valueTimePickerId', field.value),
131
+ timeField('minValue', 'minValueTimePickerId', settings.minValue),
132
+ timeField('maxValue', 'maxValueTimePickerId', settings.maxValue),
133
+ numericField('incrementalValue', 'incrementalValueNumericBoxId', settings.incrementalValue, { incrementalValue: 5 }),
134
+ { id: 'allowedTimes', fieldElement: this.#createAllowedListComponent(this.cf.getComponentType(this.InputTypeOption.TIMEPICKER), `${idPrefix}allowedTimes_input`, this.form.addAllowedTimePickerId, settings.allowedTimes) },
135
+ { id: 'disallowTimes', type: 'checkbox', value: settings.disallowTimes, config: { switch: true } }
136
+ ];
137
+ break;
138
+
139
+ case this.InputTypeOption.SLIDER:
140
+ fields = [
141
+ { id: 'range', type: 'checkbox', checked: settings.range, config: { switch: true } },
142
+ { id: 'trackSize', type: 'input', value: settings.trackSize },
143
+ (settings.range) ? numericField('startValue', 'startValueNumericBoxId', settings.startValue) : null,
144
+ numericField('value', 'valueNumericBoxId', field.value),
145
+ numericField('minValue', 'minValueNumericBoxId', settings.minValue),
146
+ numericField('maxValue', 'maxValueNumericBoxId', settings.maxValue),
147
+ numericField('tickMarks', 'tickMarksNumericBoxId', settings.tickMarks),
148
+ ];
149
+ break;
150
+
151
+ case this.InputTypeOption.FILEUPLOAD:
152
+ fields = [
153
+ { id: 'accept', type: 'input', value: settings.accept || '' },
154
+ numericField('maxFileSize', 'maxFileSizeNumericBoxId', settings.maxFileSize),
155
+ numericField('maxFiles', 'maxFilesNumericBoxId', settings.maxFiles),
156
+ { id: 'dataSourceId', fieldElement: this.cpm.createDataSourceCombo(`${idPrefix}fileUpload_dataSourceId`, this.InputTypeOption.FILEUPLOAD, 'componentSettings.dataSourceId') }
157
+ ];
158
+ break;
159
+
160
+ case this.InputTypeOption.EDITOR:
161
+
162
+ const visibleCommands = settings.visibleCommands || {};
163
+ const all = visibleCommands.all,
164
+ config = { switch: true, disabled: all };
165
+
166
+ if (all)
167
+ visibleCommands.list = visibleCommands.block = visibleCommands.link = visibleCommands.special = true;
168
+
169
+ fields = [
170
+ { id: 'all', name: 'visibleCommands.all', type: 'checkbox', checked: all, config: { switch: true } },
171
+ { id: 'list', name: 'visibleCommands.list', type: 'checkbox', checked: settings.list, config },
172
+ { id: 'block', name: 'visibleCommands.block', type: 'checkbox', checked: settings.block, config },
173
+ { id: 'link', name: 'visibleCommands.link', type: 'checkbox', checked: settings.link, config },
174
+ { id: 'special', name: 'visibleCommands.special', type: 'checkbox', checked: settings.special, config },
175
+ ];
176
+ break;
177
+ }
178
+
179
+ if (field.customType)
180
+ {
181
+ const config = this.form.constructor.getCustomType(field.customType);
182
+
183
+ if (config)
184
+ customConfigFields = config.configGetter(this.form, field, panelId);
185
+ }
186
+
187
+ // Render the panel fields
188
+ this.cpm.renderPanel(field, contentEl, [...fields, ...customConfigFields], customTemplateId || templateId, `${idPrefix + typeName}_`, namePrefix);
189
+ this.cpm.bindProperties(field, contentEl);
190
+ }
191
+
192
+ #createAllowedListComponent(componentType, pickerId, cloneId, values)
193
+ {
194
+ const pickerEl = this.cf.createComponent(this.form, componentType, pickerId, cloneId).element,
195
+ container = $lib.element({ content: pickerEl, props: { className: this.cpm.getCssClass(this.cpm.classOption.ALLOWED_LIST) } });
196
+
197
+ this.cf.createButton(container, `${pickerId}_add`, this.form.addAllowedItemButtonId, {
198
+ hasIcon: true,
199
+ cssClassIcon: 'ico-plus',
200
+ cssClass: this.cpm.getCssClass(this.cpm.classOption.ADD),
201
+ command: () =>
202
+ {
203
+ const pickerInstance = $UI.store[pickerId],
204
+ isDatePicker = pickerInstance.constructor.name === 'DatePicker',
205
+ value = (isDatePicker && !$lib.isEmpty(pickerInstance.getDate())) ? $lib.formatDate(pickerInstance.getDate(), 'YYYY-MM-DD') : pickerInstance.getValue();
206
+
207
+ if (!value)
208
+ return;
209
+
210
+ if (!values.includes(value))
211
+ {
212
+ values.push(value);
213
+ this.#createAllowedList(container, values, pickerId);
214
+ }
215
+ }
216
+ });
217
+
218
+ this.#createAllowedList(container, values, pickerId);
219
+ return container;
220
+ }
221
+
222
+ #createAllowedList(container, values, pickerId)
223
+ {
224
+ let ul = container.querySelector('ul'),
225
+ isDatePicker = $UI.store[pickerId].constructor.name === 'DatePicker';
226
+
227
+ if (ul)
228
+ ul.innerHTML = '';
229
+ else
230
+ ul = $lib.element({ container: container, tag: 'ul' });
231
+
232
+ for (const value of values)
233
+ {
234
+ const li = $lib.element({ container: ul, tag: 'li' });
235
+
236
+ $lib.element({ container: li, tag: 'span', content: (isDatePicker) ? $lib.formatDate(this.#parseISODate(value), this.form.format.dateFormat) : value });
237
+
238
+ const removeButton = this.cf.createButton(li, `${pickerId}_remove`, this.form.removeAllowedItemButtonId, {
239
+ hasIcon: true,
240
+ cssClassIcon: 'ico-bin',
241
+ cssClass: this.cpm.getCssClass(this.cpm.classOption.REMOVE),
242
+ command: () =>
243
+ {
244
+ const index = values.findIndex(v => v === value);
245
+
246
+ if (index !== -1)
247
+ values.splice(index, 1);
248
+
249
+ this.#createAllowedList(container, values, pickerId);
250
+ }
251
+ });
252
+
253
+ li.appendChild(removeButton.element);
254
+ }
255
+ }
256
+
257
+ #parseISODate(value)
258
+ {
259
+ return $lib.parseDate(value, 'YYYY-MM-DD');
260
+ }
261
+ };
262
+
263
+ var ComponentPanel = componyx.UI.form_modules.ComponentPanel;
264
+
265
+ export { ComponentPanel as default };