@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.
- package/AppSkin/AppSkin.css +1268 -0
- package/AppSkin/AppSkin.js +2748 -0
- package/AppSkin/Themes/Default.css +241 -0
- package/Base/Base.js +3407 -0
- package/Base/ComponentIcons.css +66 -0
- package/Base/Font/ComponentIcons.woff +0 -0
- package/Base/Font/UI.woff +0 -0
- package/Base/Library.js +8432 -0
- package/Base/NavigationManager.js +462 -0
- package/Base/ResponsiveTemplates.js +371 -0
- package/Base/Sanitizer.js +288 -0
- package/Base/Themes/Default.css +255 -0
- package/Base/UI.css +618 -0
- package/Base/UIResourcePath.js +6 -0
- package/Bindary/Bindary.js +2011 -0
- package/Bindary/Modules/Connection.js +216 -0
- package/Bindary/Modules/Core.js +854 -0
- package/Bindary/Modules/DataUpdater.js +351 -0
- package/Bindary/Modules/ExpressionEngine.js +347 -0
- package/Bindary/Modules/ProxyManager.js +482 -0
- package/Bindary/Modules/Renderer.js +605 -0
- package/Bindary/Modules/Router.js +291 -0
- package/Bindary/Modules/Scroller.js +89 -0
- package/Bindary/Modules/Template.js +1273 -0
- package/BookmarkSpy/BookmarkSpy.js +430 -0
- package/Box/Box.css +36 -0
- package/Box/Box.js +1685 -0
- package/Button/Button.css +470 -0
- package/Button/Button.js +1398 -0
- package/Button/Themes/Default.css +200 -0
- package/Carousel/Carousel.css +273 -0
- package/Carousel/Carousel.js +607 -0
- package/ColorButton/ColorButton.css +39 -0
- package/ColorButton/ColorButton.js +336 -0
- package/ColorPicker/ColorPicker.css +359 -0
- package/ColorPicker/ColorPicker.js +972 -0
- package/ComboBox/ComboBox.css +357 -0
- package/ComboBox/ComboBox.js +2342 -0
- package/ComboBox/Themes/Default.css +23 -0
- package/DataPager/DataPager.css +72 -0
- package/DataPager/DataPager.js +674 -0
- package/DatePicker/DatePicker.css +227 -0
- package/DatePicker/DatePicker.js +1531 -0
- package/DatePicker/Themes/Default.css +26 -0
- package/Dialog/Dialog.css +106 -0
- package/Dialog/Dialog.js +572 -0
- package/Dialog/Themes/Default.css +10 -0
- package/Editor/Data/Emoji.json +8285 -0
- package/Editor/Data/Special.json +1042 -0
- package/Editor/Editor.css +1562 -0
- package/Editor/Editor.js +4058 -0
- package/Editor/Font/Editor.woff +0 -0
- package/Editor/Modules/ComponentFactory.js +565 -0
- package/Editor/Modules/ContentManager.js +748 -0
- package/Editor/Modules/DialogManager.js +1234 -0
- package/Editor/Modules/EventManager.js +458 -0
- package/Editor/Modules/Format.js +950 -0
- package/Editor/Modules/History.js +191 -0
- package/Editor/Modules/LayoutState.js +379 -0
- package/Editor/Modules/ListManager.js +296 -0
- package/Editor/Modules/MenuManager.js +388 -0
- package/Editor/Modules/NodeManager.js +681 -0
- package/Editor/Modules/ParagraphButtons.js +122 -0
- package/Editor/Modules/Resizer.js +176 -0
- package/Editor/Modules/SelectionRange.js +564 -0
- package/Editor/Modules/SourceViewBuilder.js +212 -0
- package/Editor/Modules/SymbolPicker.js +208 -0
- package/Editor/Modules/Table.js +2327 -0
- package/Editor/Modules/TableDialog.js +757 -0
- package/Editor/Modules/Toolbar.js +375 -0
- package/Editor/Modules/TooltipMenu.js +125 -0
- package/Editor/Modules/Utility.js +131 -0
- package/Editor/Themes/Default.css +204 -0
- package/FileUpload/FileUpload.css +156 -0
- package/FileUpload/FileUpload.js +898 -0
- package/FileUpload/Themes/Default.css +17 -0
- package/Form/Form.css +1934 -0
- package/Form/Form.js +4943 -0
- package/Form/Modules/ActionManager.js +368 -0
- package/Form/Modules/BuildPanelManager.js +319 -0
- package/Form/Modules/ComponentFactory.js +468 -0
- package/Form/Modules/ComponentPanel.js +265 -0
- package/Form/Modules/ConfigPanelManager.js +685 -0
- package/Form/Modules/DataBinder.js +602 -0
- package/Form/Modules/DataObserver.js +717 -0
- package/Form/Modules/Draggable.js +756 -0
- package/Form/Modules/OptionsPanel.js +342 -0
- package/Form/Modules/Renderer.js +1889 -0
- package/Form/Modules/RuleEngine.js +585 -0
- package/Form/Modules/RulesPanel.js +1158 -0
- package/Form/Modules/Types.js +1709 -0
- package/Form/Modules/ValidationManager.js +194 -0
- package/Form/Themes/Default.css +216 -0
- package/FormField/FormField.css +468 -0
- package/FormField/FormField.js +576 -0
- package/FormField/Themes/Default.css +99 -0
- package/Grid/Grid.css +544 -0
- package/Grid/Grid.js +3761 -0
- package/Grid/Themes/Default.css +43 -0
- package/LICENSE +126 -0
- package/MaskedTextBox/MaskedTextBox.css +28 -0
- package/MaskedTextBox/MaskedTextBox.js +642 -0
- package/MaskedTextBox/Themes/Default.css +6 -0
- package/Menu/Menu.css +328 -0
- package/Menu/Menu.js +2386 -0
- package/Menu/Themes/Default.css +24 -0
- package/NumericBox/NumericBox.css +120 -0
- package/NumericBox/NumericBox.js +984 -0
- package/PanelBar/PanelBar.css +123 -0
- package/PanelBar/PanelBar.js +505 -0
- package/PanelBar/Themes/Default.css +51 -0
- package/PieChart/PieChart.css +95 -0
- package/PieChart/PieChart.js +820 -0
- package/PieChart/Themes/Default.css +9 -0
- package/README.md +178 -3
- package/Slider/Slider.css +348 -0
- package/Slider/Slider.js +1306 -0
- package/Slider/Themes/Default.css +44 -0
- package/TabStrip/TabStrip.css +52 -0
- package/TabStrip/TabStrip.js +362 -0
- package/TabStrip/Themes/Default.css +35 -0
- package/TimePicker/Themes/Default.css +30 -0
- package/TimePicker/TimePicker.css +253 -0
- package/TimePicker/TimePicker.js +1485 -0
- package/TooltipManager/Themes/Default.css +21 -0
- package/TooltipManager/TooltipManager.css +227 -0
- package/TooltipManager/TooltipManager.js +791 -0
- package/Validator/Validator.css +54 -0
- package/Validator/Validator.js +2508 -0
- package/componyx.html-data.json +619 -0
- package/index.js +27 -0
- package/package.json +43 -4
- package/types/AppSkin.d.ts +842 -0
- package/types/Base.d.ts +1034 -0
- package/types/Bindary.d.ts +1196 -0
- package/types/BookmarkSpy.d.ts +112 -0
- package/types/Box.d.ts +374 -0
- package/types/Button.d.ts +455 -0
- package/types/Carousel.d.ts +136 -0
- package/types/ColorButton.d.ts +120 -0
- package/types/ColorPicker.d.ts +225 -0
- package/types/ComboBox.d.ts +507 -0
- package/types/DataPager.d.ts +152 -0
- package/types/DatePicker.d.ts +354 -0
- package/types/Dialog.d.ts +160 -0
- package/types/Editor.d.ts +1289 -0
- package/types/FileUpload.d.ts +206 -0
- package/types/Form.d.ts +3078 -0
- package/types/FormField.d.ts +204 -0
- package/types/Grid.d.ts +911 -0
- package/types/Library.d.ts +1899 -0
- package/types/MaskedTextBox.d.ts +91 -0
- package/types/Menu.d.ts +577 -0
- package/types/NumericBox.d.ts +310 -0
- package/types/PanelBar.d.ts +223 -0
- package/types/PieChart.d.ts +224 -0
- package/types/ResponsiveTemplates.d.ts +108 -0
- package/types/Slider.d.ts +227 -0
- package/types/TabStrip.d.ts +185 -0
- package/types/TimePicker.d.ts +265 -0
- package/types/TooltipManager.d.ts +178 -0
- package/types/UI.d.ts +29 -0
- package/types/Validator.d.ts +653 -0
- package/types/index.d.ts +59 -0
- package/ui.css +11783 -0
- package/ui.js +79477 -0
- package/ui.min.css +138 -0
- package/ui.min.js +264 -0
- package/ui.min.js.map +1 -0
|
@@ -0,0 +1,468 @@
|
|
|
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.ComponentFactory = class ComponentFactory
|
|
4
|
+
{
|
|
5
|
+
#classOption;
|
|
6
|
+
constructor(form)
|
|
7
|
+
{
|
|
8
|
+
this.form = form;
|
|
9
|
+
this.InputTypeOption = this.form.constructor.InputTypeOption;
|
|
10
|
+
this.#classOption = form.classOption;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
getComponentType(type)
|
|
14
|
+
{
|
|
15
|
+
return componyx.UI[this.InputTypeOption.getName(type)];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
createElement(id)
|
|
19
|
+
{
|
|
20
|
+
const el = $lib(`#${id}`);
|
|
21
|
+
|
|
22
|
+
if (el)
|
|
23
|
+
return el;
|
|
24
|
+
else
|
|
25
|
+
return $lib.element(this.form, '', '', '', '', { id: `${id}` }); // temporary place inside form container, element will be moved into form-field field template
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
setAttribute(element, attr, value = '')
|
|
29
|
+
{
|
|
30
|
+
element.setAttribute(attr, value);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
createInput({ type, id, name, value, placeholder, checked, disabled, events, container })
|
|
34
|
+
{
|
|
35
|
+
const el = $lib.element(container, '', type === 'textarea' ? 'textarea' : 'input', '', '', {
|
|
36
|
+
type: type !== 'textarea' ? type : undefined,
|
|
37
|
+
id: id || undefined,
|
|
38
|
+
name,
|
|
39
|
+
value: (!$lib.isEmpty(value)) ? value : undefined,
|
|
40
|
+
placeholder: (!$lib.isEmpty(placeholder)) ? placeholder : undefined,
|
|
41
|
+
checked: checked === true ? true : undefined,
|
|
42
|
+
disabled: disabled === true ? true : undefined
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
$lib.each(events, (handler, eventType) =>
|
|
46
|
+
{
|
|
47
|
+
$lib.on(el, eventType, handler);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
return el;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
createTextarea(id, name, value, placeholder, events)
|
|
54
|
+
{
|
|
55
|
+
return this.createInput({ type: 'textarea', id, name, value, placeholder, events });
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
createCheckbox(id, name, value, checked, events)
|
|
59
|
+
{
|
|
60
|
+
return this.createInput({ type: 'checkbox', id, name, value, checked, events });
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
createRadio(id, name, value, checked, events)
|
|
64
|
+
{
|
|
65
|
+
return this.createInput({ type: 'radio', id, name, value, checked, events });
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
createTextInput(id, name, value, placeholder, events)
|
|
69
|
+
{
|
|
70
|
+
return this.createInput({ type: 'text', id, name, value, placeholder, events });
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
createHiddenInput(id)
|
|
74
|
+
{
|
|
75
|
+
return this.createInput({ type: 'hidden', container: this.form, id: id });
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
createDragHandle(container)
|
|
79
|
+
{
|
|
80
|
+
const dragHandle = $lib.element(container, '', '', '', { "class": this.form.getCssClass(this.#classOption.DRAG_HANDLE) });
|
|
81
|
+
dragHandle.innerHTML = '<b></b><b></b><b></b>';
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
createNumericBox(container, id, cloneId, config)
|
|
85
|
+
{
|
|
86
|
+
config.decimalSeparator = this.form.format.decimalSeparator;
|
|
87
|
+
config.groupSeparator = this.form.format.groupSeparator;
|
|
88
|
+
|
|
89
|
+
return this.createComponent(container, this.getComponentType(this.InputTypeOption.NUMERICBOX), this.createElement(id).id, cloneId, config);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
createComboBox(container, id, cloneId, config = {}, noResultLabel)
|
|
93
|
+
{
|
|
94
|
+
if (!config.placeholder)
|
|
95
|
+
config.placeholder = this.form.labels.comboBoxDefaultHint;
|
|
96
|
+
|
|
97
|
+
const combo = this.createComponent(container, this.getComponentType(this.InputTypeOption.COMBOBOX), this.createElement(id).id, cloneId, config);
|
|
98
|
+
|
|
99
|
+
if (noResultLabel)
|
|
100
|
+
combo.setNoResultTemplate(config.noResultLabel);
|
|
101
|
+
|
|
102
|
+
return combo;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
createColorButton(container, id, cloneId, config)
|
|
106
|
+
{
|
|
107
|
+
return this.createComponent(container, componyx.UI.ColorButton, this.createElement(id).id, cloneId, config);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
createButton(container, id, cloneId, config)
|
|
111
|
+
{
|
|
112
|
+
return this.createComponent(container, componyx.UI.Button, id, cloneId, {
|
|
113
|
+
...config,
|
|
114
|
+
transparent: $lib.isEmpty(config.transparent) ? true : config.transparent,
|
|
115
|
+
transparentBorder: $lib.isEmpty(config.transparentBorder) ? true : config.transparentBorder,
|
|
116
|
+
primary: $lib.isEmpty(config.primary) ? false : config.primary,
|
|
117
|
+
hasIcon: !$lib.isEmpty(config.cssClassIcon),
|
|
118
|
+
cssClassIcon: `${this.form.getCssClass(this.#classOption.ICON)} ${config.cssClassIcon}`,
|
|
119
|
+
tooltipManagerId: this.form.tooltipManager.id,
|
|
120
|
+
tooltipId: this.addTooltip(id.replace(`${this.form.id}_`, ''), config),
|
|
121
|
+
command: config.command,
|
|
122
|
+
renderId: false,
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
addTooltip(id, config)
|
|
127
|
+
{
|
|
128
|
+
let key = config.key,
|
|
129
|
+
text = config.tooltip || '';
|
|
130
|
+
|
|
131
|
+
if (key && !config.tooltip)
|
|
132
|
+
text += ` (Ctrl+${key.toUpperCase()})`;
|
|
133
|
+
|
|
134
|
+
if (text)
|
|
135
|
+
{
|
|
136
|
+
this.form.tooltipManager.addTooltip(id, text);
|
|
137
|
+
return id;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
return null;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
createFormField(container, id, cloneId, label, fieldTemplate, config = {}, postRender)
|
|
144
|
+
{
|
|
145
|
+
const formField = this.createComponent(container, componyx.UI.FormField, id, cloneId, {
|
|
146
|
+
...config,
|
|
147
|
+
wrapFieldContent: (fieldTemplate && fieldTemplate.nodeName === 'INPUT' || fieldTemplate.nodeName === 'TEXTAREA') ? false : true, // no need to wrap direct input fields
|
|
148
|
+
tooltipManagerId: (config.tooltipId) ? this.form.tooltipManager.id : null,
|
|
149
|
+
borderless: false,
|
|
150
|
+
events: {
|
|
151
|
+
onPostRender: (formField) =>
|
|
152
|
+
{
|
|
153
|
+
if (postRender)
|
|
154
|
+
postRender(formField);
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
_mustRender: false
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
formField.setLabelTemplate(label);
|
|
161
|
+
formField.setFieldTemplate(fieldTemplate);
|
|
162
|
+
|
|
163
|
+
if (this.form.renderState === $base.static.RenderState.RENDERED)
|
|
164
|
+
formField.render();
|
|
165
|
+
|
|
166
|
+
if (this.form.displayMode === this.form.constructor.DisplayModeOption.BUILD)
|
|
167
|
+
formField.element.tabIndex = 0;
|
|
168
|
+
|
|
169
|
+
return formField;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
createTooltipManager(container, id, cloneId, config = {})
|
|
173
|
+
{
|
|
174
|
+
const tooltipBox = $UI.createComponent(componyx.UI.Box, {
|
|
175
|
+
id: id + '_TooltipManagerBox',
|
|
176
|
+
containerElement: container,
|
|
177
|
+
cssClass: this.form.getCssClass(this.#classOption.FIELD_TOOLTIP),
|
|
178
|
+
expandDirection: componyx.UI.Box.ExpandDirectionOption.DOWN,
|
|
179
|
+
autoPosition: componyx.UI.Box.AutoPositionOption.EXPAND,
|
|
180
|
+
alignX: componyx.UI.Box.AlignXOption.CENTER,
|
|
181
|
+
autoInvertFit: true
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
return this.createComponent(container, componyx.UI.TooltipManager, id, cloneId, { ...config, boxId: tooltipBox.id, _mustRender: false });
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
createComponent(container, type, id, cloneId, config = {})
|
|
188
|
+
{
|
|
189
|
+
const component = $UI.createComponent(type, { id: id, containerElement: container });
|
|
190
|
+
|
|
191
|
+
component.clone($UI.store[cloneId], this.form);
|
|
192
|
+
|
|
193
|
+
const { events, ...restSettings } = config;
|
|
194
|
+
Object.assign(component, Object.fromEntries(Object.entries(restSettings).filter(([k, v]) => v !== undefined))); // don't assign undefined properties
|
|
195
|
+
|
|
196
|
+
if (config._disableDataBinding !== true)
|
|
197
|
+
{
|
|
198
|
+
if ((component.hiddenInputId !== undefined && $lib.isEmpty(component.hiddenInputId))
|
|
199
|
+
|| (component.inputId !== undefined && $lib.isEmpty(component.hiddenInputId))) // set the setting attribute on the input to enable data binding via the DataBinder
|
|
200
|
+
{
|
|
201
|
+
let hiddenId = `${id}_value`,
|
|
202
|
+
hiddenInput = $lib(`#${hiddenId}`);
|
|
203
|
+
|
|
204
|
+
if (!hiddenInput)
|
|
205
|
+
{
|
|
206
|
+
hiddenInput = this.createHiddenInput(hiddenId);
|
|
207
|
+
|
|
208
|
+
if (this.form.isBuildMode())
|
|
209
|
+
this.setAttribute(hiddenInput, 'data-ui-form-setting');
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
if (component.hiddenInputId !== undefined)
|
|
213
|
+
component.hiddenInputId = hiddenInput.id;
|
|
214
|
+
else if (component.inputId !== undefined)
|
|
215
|
+
component.inputId = hiddenInput.id;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
component.keepInputId = true;
|
|
220
|
+
component.cloneInput = false;
|
|
221
|
+
component.ignoreConnectionCallbacks = true;
|
|
222
|
+
component.showing = (!$lib.isEmpty(config.showing)) ? config.showing : true;
|
|
223
|
+
|
|
224
|
+
if (events && typeof events === 'object')
|
|
225
|
+
{
|
|
226
|
+
for (const [eventName, handler] of Object.entries(events))
|
|
227
|
+
{
|
|
228
|
+
if (!eventName || !handler)
|
|
229
|
+
continue;
|
|
230
|
+
|
|
231
|
+
if (component.events?.[eventName]?.priorityAdd)
|
|
232
|
+
{
|
|
233
|
+
component.events[eventName].priorityAdd(handler);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
component.events.onPostRender.priorityAdd(() => { this.form.isReady(); }, null, true); // Mark form ready after internal postRender events, avoiding global postRender call
|
|
239
|
+
|
|
240
|
+
if (this.form.renderState === $base.static.RenderState.RENDERED && config._mustRender !== false)
|
|
241
|
+
component.render();
|
|
242
|
+
|
|
243
|
+
return component;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
getComponentConfig(field, allowSelection = true)
|
|
247
|
+
{
|
|
248
|
+
const config = {
|
|
249
|
+
name: field.name,
|
|
250
|
+
value: field.value,
|
|
251
|
+
placeholder: field.placeholder,
|
|
252
|
+
events: {}
|
|
253
|
+
};
|
|
254
|
+
|
|
255
|
+
if (field.inputType === this.InputTypeOption.MASKEDTEXTBOX)
|
|
256
|
+
{
|
|
257
|
+
this.configureMaskedTextBox(field, config);
|
|
258
|
+
}
|
|
259
|
+
else if (field.inputType === this.InputTypeOption.NUMERICBOX)
|
|
260
|
+
{
|
|
261
|
+
this.configureNumericBox(field, config);
|
|
262
|
+
}
|
|
263
|
+
else if (field.inputType === this.InputTypeOption.COMBOBOX)
|
|
264
|
+
{
|
|
265
|
+
this.configureComboBox(field, config, allowSelection);
|
|
266
|
+
}
|
|
267
|
+
else if (field.inputType === this.InputTypeOption.DATEPICKER)
|
|
268
|
+
{
|
|
269
|
+
this.configureDatePicker(field, config);
|
|
270
|
+
}
|
|
271
|
+
else if (field.inputType === this.InputTypeOption.TIMEPICKER)
|
|
272
|
+
{
|
|
273
|
+
this.configureTimePicker(field, config);
|
|
274
|
+
}
|
|
275
|
+
else if (field.inputType === this.InputTypeOption.SLIDER)
|
|
276
|
+
{
|
|
277
|
+
this.configureSlider(field, config);
|
|
278
|
+
}
|
|
279
|
+
else if (field.inputType === this.InputTypeOption.FILEUPLOAD)
|
|
280
|
+
{
|
|
281
|
+
this.configureFileUpload(field, config);
|
|
282
|
+
}
|
|
283
|
+
else if (field.inputType === this.InputTypeOption.EDITOR)
|
|
284
|
+
{
|
|
285
|
+
this.configureEditor(field, config);
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
return config;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
configureMaskedTextBox(field, config = {})
|
|
292
|
+
{
|
|
293
|
+
const settings = field.componentSettings || {},
|
|
294
|
+
defaults = { allowedCharacters: 0 };
|
|
295
|
+
|
|
296
|
+
return this.#configureComponentConfig(settings, config, defaults);
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
configureNumericBox(field, config = {})
|
|
300
|
+
{
|
|
301
|
+
const settings = field.componentSettings || {};
|
|
302
|
+
|
|
303
|
+
config.decimalSeparator = this.form.format.decimalSeparator;
|
|
304
|
+
config.groupSeparator = this.form.format.groupSeparator;
|
|
305
|
+
|
|
306
|
+
return this.#configureComponentConfig(settings, config);
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
configureComboBox(field, config = {}, allowSelection = true)
|
|
310
|
+
{
|
|
311
|
+
const settings = field.componentSettings || {};
|
|
312
|
+
|
|
313
|
+
this.#configureComponentConfig(settings, config);
|
|
314
|
+
|
|
315
|
+
if (field.dataSourceId)
|
|
316
|
+
{
|
|
317
|
+
config.loadOnDemand = true;
|
|
318
|
+
this.configureDataSource(config, field.dataSourceId);
|
|
319
|
+
}
|
|
320
|
+
else if (!$lib.isEmpty(field.options))
|
|
321
|
+
{
|
|
322
|
+
config.itemList = field.options.map(option =>
|
|
323
|
+
{
|
|
324
|
+
this.form.ensureItemId(option);
|
|
325
|
+
return { id: option.id, text: option.label, value: option.value, selected: (allowSelection) ? option.selected : false, disabled: option.disabled };
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
if (this.form.isBuildMode())
|
|
330
|
+
{
|
|
331
|
+
config.events = {
|
|
332
|
+
onPostRender: (comboBox) =>
|
|
333
|
+
{
|
|
334
|
+
this.form.updateFieldOptions(field);
|
|
335
|
+
}
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
return config;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
configureDatePicker(field, config = {})
|
|
343
|
+
{
|
|
344
|
+
const settings = field.componentSettings || {};
|
|
345
|
+
|
|
346
|
+
config.dateFormat = this.form.format.dateFormat;
|
|
347
|
+
return this.#configureComponentConfig(settings, config);
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
configureTimePicker(field, config = {})
|
|
351
|
+
{
|
|
352
|
+
const settings = field.componentSettings || {},
|
|
353
|
+
defaults = { incrementalValue: 5 };
|
|
354
|
+
return this.#configureComponentConfig(settings, config, defaults);
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
configureSlider(field, config = {})
|
|
358
|
+
{
|
|
359
|
+
const settings = field.componentSettings || {};
|
|
360
|
+
|
|
361
|
+
this.#configureComponentConfig(settings, config);
|
|
362
|
+
|
|
363
|
+
if (settings.range)
|
|
364
|
+
{
|
|
365
|
+
const el = $lib.element({ container: this.form, tag: 'input', props: { id: `${field.id}_Range`, type: 'hidden' } }); // we need to create a hidden input for data-binding
|
|
366
|
+
config.rangeHiddenInputId = el.id;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
if (settings.tickMarks)
|
|
370
|
+
{
|
|
371
|
+
config.tickMarkSide = componyx.UI.Slider.TickMarkSideOption.BOTH;
|
|
372
|
+
config.tickMarkValueSide = componyx.UI.Slider.TickMarkSideOption.AFTER;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
|
|
376
|
+
return config;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
configureFileUpload(field, config = {})
|
|
380
|
+
{
|
|
381
|
+
const settings = field.componentSettings || {};
|
|
382
|
+
|
|
383
|
+
if (field.dataSourceId)
|
|
384
|
+
this.configureDataSource(config, field.dataSourceId);
|
|
385
|
+
|
|
386
|
+
return this.#configureComponentConfig(settings, config);
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
configureEditor(field, config = {})
|
|
390
|
+
{
|
|
391
|
+
const settings = field.componentSettings || {},
|
|
392
|
+
{ visibleCommands, ...otherSettings } = settings,
|
|
393
|
+
commandSettings = visibleCommands || {},
|
|
394
|
+
coreCommands = ['*core'],
|
|
395
|
+
listCommands = ['*list'],
|
|
396
|
+
optionalCommands = [...listCommands, 'block', 'link', 'special'];
|
|
397
|
+
|
|
398
|
+
config.visibleCommands = [...coreCommands];
|
|
399
|
+
|
|
400
|
+
if (commandSettings.all)
|
|
401
|
+
{
|
|
402
|
+
config.visibleCommands = [...coreCommands, ...optionalCommands];
|
|
403
|
+
['all', 'list', 'block', 'link', 'special'].forEach(k => delete commandSettings[k]);
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
for (const [key, value] of Object.entries(commandSettings))
|
|
407
|
+
{
|
|
408
|
+
let cmds = config.visibleCommands;
|
|
409
|
+
|
|
410
|
+
if (!value || cmds.includes(`${key}`) || cmds.includes(`*${key}`))
|
|
411
|
+
continue;
|
|
412
|
+
|
|
413
|
+
config.visibleCommands.push(key);
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
this.#configureComponentConfig(otherSettings, config);
|
|
417
|
+
|
|
418
|
+
return config;
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
configureDataSource(config, dataSourceId)
|
|
422
|
+
{
|
|
423
|
+
let dataSource = this.form.dataSources.find(ds => ds.id === dataSourceId),
|
|
424
|
+
ajaxMethod;
|
|
425
|
+
|
|
426
|
+
config.ajax = { customParameters: dataSource.params ?? {} };
|
|
427
|
+
|
|
428
|
+
if (dataSource.inputType === this.InputTypeOption.FILEUPLOAD)
|
|
429
|
+
ajaxMethod = config.ajax.upload = {};
|
|
430
|
+
else
|
|
431
|
+
ajaxMethod = config.ajax.load = {};
|
|
432
|
+
|
|
433
|
+
ajaxMethod.url = dataSource.url;
|
|
434
|
+
ajaxMethod.absoluteURL = dataSource.absoluteURL || true;
|
|
435
|
+
ajaxMethod.headers = dataSource.headers || null;
|
|
436
|
+
return config;
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
#configureComponentConfig(settings, config, defaults = {})
|
|
440
|
+
{
|
|
441
|
+
for (const key in settings)
|
|
442
|
+
{
|
|
443
|
+
if (settings[key] !== undefined)
|
|
444
|
+
{
|
|
445
|
+
if (Array.isArray(settings[key]))
|
|
446
|
+
config[key] = [...settings[key]];
|
|
447
|
+
else if (typeof settings[key] === 'object' && settings[key] !== null)
|
|
448
|
+
config[key] = { ...settings[key] };
|
|
449
|
+
else
|
|
450
|
+
config[key] = settings[key];
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
for (const key in defaults)
|
|
455
|
+
{
|
|
456
|
+
if (config[key] === undefined && defaults[key] !== undefined)
|
|
457
|
+
{
|
|
458
|
+
config[key] = defaults[key];
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
return config;
|
|
463
|
+
}
|
|
464
|
+
};
|
|
465
|
+
|
|
466
|
+
var ComponentFactory = componyx.UI.form_modules.ComponentFactory;
|
|
467
|
+
|
|
468
|
+
export { ComponentFactory as default };
|