gd-bs 6.6.92 → 6.6.93
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/build/components/custom-element.js +19 -16
- package/build/components/floating-ui/index.js +7 -7
- package/build/index-icons.js +4 -5
- package/build/index.js +4 -5
- package/dist/gd-bs-icons.js +1 -1
- package/dist/gd-bs-icons.js.LICENSE.txt +0 -4
- package/dist/gd-bs-icons.min.js +1 -1
- package/dist/gd-bs.d.ts +3 -4
- package/dist/gd-bs.js +1 -1
- package/dist/gd-bs.js.LICENSE.txt +0 -4
- package/dist/gd-bs.min.js +1 -1
- package/indexv2.html +1 -1
- package/package.json +1 -1
- package/src/components/custom-element.ts +13 -11
- package/src/components/floating-ui/index.ts +7 -7
- package/src/components/form/formTypes.d.ts +2 -2
- package/src/index-icons.ts +5 -6
- package/src/index.d.ts +1 -2
- package/src/index.ts +5 -6
- package/build/render.js +0 -581
- package/src/render.ts +0 -583
package/src/render.ts
DELETED
|
@@ -1,583 +0,0 @@
|
|
|
1
|
-
import * as Components from "./components";
|
|
2
|
-
import "./custom-elements";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Render
|
|
6
|
-
* Looks through the html code to find components and render them.
|
|
7
|
-
*/
|
|
8
|
-
class RenderComponents {
|
|
9
|
-
private _component = null;
|
|
10
|
-
private _el: HTMLElement = null;
|
|
11
|
-
|
|
12
|
-
// The properties for the component
|
|
13
|
-
private _props: any[] = [];
|
|
14
|
-
get Props(): any[] { return this._props; }
|
|
15
|
-
|
|
16
|
-
// Constructor
|
|
17
|
-
constructor(el: HTMLElement, propsOnly: boolean = false, targetSelf: boolean = false) {
|
|
18
|
-
this._el = el;
|
|
19
|
-
|
|
20
|
-
// Render the components
|
|
21
|
-
this.render(propsOnly, targetSelf);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
// Creates an element and appends the children to it
|
|
25
|
-
createElement(elSource: HTMLElement, removeFl: boolean = true): HTMLElement {
|
|
26
|
-
let elTarget = document.createElement("div");
|
|
27
|
-
|
|
28
|
-
// See if the target exists
|
|
29
|
-
while (elSource.firstChild) {
|
|
30
|
-
elTarget.appendChild(elSource.firstChild);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
// Render any custom elements
|
|
34
|
-
new RenderComponents(elTarget);
|
|
35
|
-
|
|
36
|
-
// Remove the element
|
|
37
|
-
removeFl ? elSource.remove() : null;
|
|
38
|
-
|
|
39
|
-
// Return the target element
|
|
40
|
-
return elTarget.childNodes.length > 0 ? elTarget : null;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// Gets the custom elements
|
|
44
|
-
private getElements(targetSelf: boolean): HTMLElement[] {
|
|
45
|
-
let bsElements = [];
|
|
46
|
-
|
|
47
|
-
if (targetSelf) { return [this._el]; }
|
|
48
|
-
|
|
49
|
-
// Get all the elements and find the custom components
|
|
50
|
-
this._el.childNodes.forEach(el => {
|
|
51
|
-
if (el.nodeName.indexOf("BS-") == 0) {
|
|
52
|
-
// Add the element
|
|
53
|
-
bsElements.push(el);
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
return bsElements;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// Converts the custom childelements
|
|
61
|
-
private getChildItems(el: HTMLElement, propName: string, componentName: string) {
|
|
62
|
-
let items = [];
|
|
63
|
-
|
|
64
|
-
// Get the item elements
|
|
65
|
-
el.querySelectorAll(propName).forEach((elItem: HTMLElement) => {
|
|
66
|
-
// Ensure this is an item
|
|
67
|
-
if (elItem.nodeName == propName.toUpperCase()) {
|
|
68
|
-
let item = this.getProps(elItem, componentName);
|
|
69
|
-
|
|
70
|
-
// See if there is content
|
|
71
|
-
if (elItem.innerHTML) {
|
|
72
|
-
// Set custom child elements
|
|
73
|
-
switch (elItem.nodeName) {
|
|
74
|
-
case "APPENDED-BUTTON":
|
|
75
|
-
case "BTN-PROPS":
|
|
76
|
-
case "PREPENDED-BUTTON":
|
|
77
|
-
item.text = (item.text || elItem.innerHTML)?.trim();
|
|
78
|
-
break;
|
|
79
|
-
case "BS-COL":
|
|
80
|
-
item.title = (item.title || elItem.innerHTML)?.trim();
|
|
81
|
-
break;
|
|
82
|
-
case "CARD-BODY":
|
|
83
|
-
item.actions = this.getChildItems(elItem, "card-action", elItem.nodeName);
|
|
84
|
-
break;
|
|
85
|
-
case "CARD-BODY":
|
|
86
|
-
item.actions = this.getChildItems(elItem, "card-action", elItem.nodeName);
|
|
87
|
-
break;
|
|
88
|
-
case "NAVBAR-ITEM":
|
|
89
|
-
item.items = this.getChildItems(elItem, "navbar-item", componentName);
|
|
90
|
-
break;
|
|
91
|
-
case "NAVBAR-ITEM-END":
|
|
92
|
-
item.items = this.getChildItems(elItem, "navbar-item-end", componentName);
|
|
93
|
-
break;
|
|
94
|
-
case "TOOLBAR-ITEM":
|
|
95
|
-
item.buttons = this.getChildItems(elItem, "bs-button", "BUTTON");
|
|
96
|
-
break;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
// See if there is a sub-component
|
|
100
|
-
switch (componentName) {
|
|
101
|
-
case "LIST-GROUP":
|
|
102
|
-
// Set the badge
|
|
103
|
-
let badge = this.getChildItems(elItem, "bs-badge", componentName);
|
|
104
|
-
if (badge?.length > 0) { item.badge = badge[0]; }
|
|
105
|
-
break;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
// Set the custom property
|
|
109
|
-
switch (componentName) {
|
|
110
|
-
// content
|
|
111
|
-
case "ACCORDION":
|
|
112
|
-
case "CARD":
|
|
113
|
-
case "CAROUSEL":
|
|
114
|
-
case "LIST-GROUP":
|
|
115
|
-
item.content = item.content || this.createElement(elItem);
|
|
116
|
-
break;
|
|
117
|
-
// label
|
|
118
|
-
case "CHECKBOX-GROUP":
|
|
119
|
-
item.label = item.label || elItem.innerHTML;
|
|
120
|
-
break;
|
|
121
|
-
// text
|
|
122
|
-
case "CARD-BODY":
|
|
123
|
-
item.text = item.text || this.createElement(elItem);
|
|
124
|
-
break;
|
|
125
|
-
case "BREADCRUMB":
|
|
126
|
-
case "DROPDOWN":
|
|
127
|
-
case "FORM-CONTROL":
|
|
128
|
-
case "LIST-BOX":
|
|
129
|
-
item.text = item.text || elItem.innerHTML;
|
|
130
|
-
break;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
// Add the item
|
|
135
|
-
items.push(item);
|
|
136
|
-
|
|
137
|
-
// Remove the item
|
|
138
|
-
elItem.remove();
|
|
139
|
-
}
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
// See if items exist
|
|
143
|
-
if (items.length > 0) {
|
|
144
|
-
switch (propName) {
|
|
145
|
-
case "btn-props":
|
|
146
|
-
return items[0];
|
|
147
|
-
default:
|
|
148
|
-
return items;
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
// Return nothing
|
|
153
|
-
return undefined;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
// Converts the target component name to an element
|
|
157
|
-
getElement(elSource: HTMLElement, componentName: string): HTMLElement {
|
|
158
|
-
let elTarget: HTMLElement = null;
|
|
159
|
-
|
|
160
|
-
// See if the target exists
|
|
161
|
-
elSource.childNodes.forEach(el => {
|
|
162
|
-
if (el.nodeName == componentName.toUpperCase()) {
|
|
163
|
-
// Create the element
|
|
164
|
-
elTarget = document.createElement("div");
|
|
165
|
-
|
|
166
|
-
// Set the element
|
|
167
|
-
while (el.firstChild) { elTarget.appendChild(el.firstChild); }
|
|
168
|
-
|
|
169
|
-
// Render any custom elements
|
|
170
|
-
new RenderComponents(elTarget);
|
|
171
|
-
|
|
172
|
-
// Remove the element
|
|
173
|
-
el.remove();
|
|
174
|
-
}
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
// Return the target element
|
|
178
|
-
return elTarget;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
// Gets the properties of an element and returns an object
|
|
182
|
-
private getProps(el: HTMLElement, componentName: string): any {
|
|
183
|
-
let props: any = {};
|
|
184
|
-
|
|
185
|
-
// Parse the attributes
|
|
186
|
-
for (let i = 0; i < el.attributes.length; i++) {
|
|
187
|
-
let attribute = el.attributes[i];
|
|
188
|
-
|
|
189
|
-
// Set the value
|
|
190
|
-
let value: any = attribute.value;
|
|
191
|
-
|
|
192
|
-
// Convert the value
|
|
193
|
-
if (typeof (value) === "string") {
|
|
194
|
-
// See if it's a boolean value
|
|
195
|
-
if (value?.toLowerCase() == "true") { value = true; }
|
|
196
|
-
else if (value?.toLowerCase() == "false") { value = false; }
|
|
197
|
-
|
|
198
|
-
// Else, see if it's linked to a global library
|
|
199
|
-
else if (value.indexOf('.') > 0) {
|
|
200
|
-
// Split the value
|
|
201
|
-
let objInfo = value.split('.');
|
|
202
|
-
|
|
203
|
-
// See if this is linked to a global library
|
|
204
|
-
let objProp = null;
|
|
205
|
-
for (let i = 0; i < objInfo.length; i++) {
|
|
206
|
-
if (i == 0) {
|
|
207
|
-
objProp = window[objInfo[0]];
|
|
208
|
-
if (objProp) { continue } else { break };
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
// Update the object
|
|
212
|
-
objProp = objProp[objInfo[i]];
|
|
213
|
-
if (objProp == null) { break; }
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
// See if the object exists
|
|
217
|
-
if (objProp) {
|
|
218
|
-
// Update the value
|
|
219
|
-
value = objProp;
|
|
220
|
-
}
|
|
221
|
-
} else {
|
|
222
|
-
try {
|
|
223
|
-
// See if it's JSON
|
|
224
|
-
let jsonObj = JSON.parse(value);
|
|
225
|
-
value = jsonObj;
|
|
226
|
-
} catch {
|
|
227
|
-
try {
|
|
228
|
-
// See if it's a reference
|
|
229
|
-
let elTarget = document.querySelector(value);
|
|
230
|
-
if (elTarget) {
|
|
231
|
-
value = elTarget;
|
|
232
|
-
}
|
|
233
|
-
} catch { }
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
// Add the property
|
|
239
|
-
props[this.getPropName(attribute.name)] = value;
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
// See if there is a sub-component
|
|
243
|
-
switch (componentName) {
|
|
244
|
-
case "BUTTON":
|
|
245
|
-
// Set the spinner
|
|
246
|
-
let spinner = this.getChildItems(el, "bs-spinner", componentName);
|
|
247
|
-
if (spinner?.length > 0) { props.spinner = spinner[0]; }
|
|
248
|
-
break;
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
// Set common properties
|
|
252
|
-
switch (componentName) {
|
|
253
|
-
// content
|
|
254
|
-
case "ALERT":
|
|
255
|
-
case "BADGE":
|
|
256
|
-
case "COLLAPSE":
|
|
257
|
-
case "ICON-LINK":
|
|
258
|
-
props.content = this.createElement(el, false);
|
|
259
|
-
break;
|
|
260
|
-
// data
|
|
261
|
-
case "DATA":
|
|
262
|
-
// Try to parse the value
|
|
263
|
-
try {
|
|
264
|
-
let data = JSON.parse(el.innerHTML.trim());
|
|
265
|
-
props.data = data;
|
|
266
|
-
} catch { }
|
|
267
|
-
break;
|
|
268
|
-
// label
|
|
269
|
-
case "PROGRESS":
|
|
270
|
-
case "PROGRESS-GROUP":
|
|
271
|
-
props.label = (props.label || el.innerHTML)?.trim();
|
|
272
|
-
break;
|
|
273
|
-
// text
|
|
274
|
-
case "BUTTON":
|
|
275
|
-
case "BUTTON-GROUP":
|
|
276
|
-
case "NAVBAR":
|
|
277
|
-
props.text = (props.text || el.innerHTML)?.trim();
|
|
278
|
-
break;
|
|
279
|
-
// value
|
|
280
|
-
case "INPUT-GROUP":
|
|
281
|
-
case "NAVBAR-SEARCH-BOX":
|
|
282
|
-
// Ensure the value exists
|
|
283
|
-
if (typeof (props.value) != "undefined") {
|
|
284
|
-
props.value = typeof (props.value) === "string" ? props.value : props.value;
|
|
285
|
-
} else {
|
|
286
|
-
props.value = el.innerHTML.trim();
|
|
287
|
-
}
|
|
288
|
-
break;
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
// Return the properties
|
|
292
|
-
return props;
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
// Gets the property name
|
|
296
|
-
private getPropName(propName: string) {
|
|
297
|
-
let idx = propName.indexOf('-');
|
|
298
|
-
while (idx > 0) {
|
|
299
|
-
// Update the key and index
|
|
300
|
-
propName = propName.substring(0, idx) + propName[idx + 1].toUpperCase() + propName.substring(idx + 2);
|
|
301
|
-
idx = propName.indexOf('-');
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
// Return the property name
|
|
305
|
-
return propName;
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
// Renders the custom components
|
|
309
|
-
private render(propsOnly: boolean, targetSelf: boolean) {
|
|
310
|
-
// Parse the elements
|
|
311
|
-
this.getElements(targetSelf).forEach((el: HTMLElement) => {
|
|
312
|
-
let componentName = el.nodeName.substring(3);
|
|
313
|
-
|
|
314
|
-
switch (componentName) {
|
|
315
|
-
case "ACCORDION":
|
|
316
|
-
return;
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
// Get the component props
|
|
320
|
-
let props = { ...this.getProps(el, componentName), el };
|
|
321
|
-
|
|
322
|
-
// Generate the component
|
|
323
|
-
switch (componentName) {
|
|
324
|
-
case "ACCORDION":
|
|
325
|
-
props.items = this.getChildItems(el, "item", componentName);
|
|
326
|
-
propsOnly ? null : this._component = Components.Accordion(props);
|
|
327
|
-
break;
|
|
328
|
-
case "ALERT":
|
|
329
|
-
propsOnly ? null : this._component = Components.Alert(props);
|
|
330
|
-
break;
|
|
331
|
-
case "BADGE":
|
|
332
|
-
propsOnly ? null : this._component = Components.Badge(props);
|
|
333
|
-
break;
|
|
334
|
-
case "BREADCRUMB":
|
|
335
|
-
propsOnly ? null : this._component = Components.Breadcrumb(props);
|
|
336
|
-
break;
|
|
337
|
-
case "BUTTON":
|
|
338
|
-
propsOnly ? null : this._component = Components.Button(props);
|
|
339
|
-
break;
|
|
340
|
-
case "BUTTON-GROUP":
|
|
341
|
-
props.buttons = this.getChildItems(el, "bs-button", componentName);
|
|
342
|
-
propsOnly ? null : this._component = Components.ButtonGroup(props);
|
|
343
|
-
break;
|
|
344
|
-
case "CARD":
|
|
345
|
-
props.body = this.getChildItems(el, "card-body", componentName);
|
|
346
|
-
props.header = this.getChildItems(el, "card-footer", componentName);
|
|
347
|
-
props.footer = this.getChildItems(el, "card-header", componentName);
|
|
348
|
-
propsOnly ? null : this._component = Components.Card(props);
|
|
349
|
-
break;
|
|
350
|
-
case "CARD-GROUP":
|
|
351
|
-
props.cards = (new RenderComponents(el, true)).Props;
|
|
352
|
-
propsOnly ? null : this._component = Components.CardGroup(props);
|
|
353
|
-
break;
|
|
354
|
-
case "CAROUSEL":
|
|
355
|
-
props.items = this.getChildItems(el, "item", componentName);
|
|
356
|
-
propsOnly ? null : this._component = Components.Carousel(props);
|
|
357
|
-
break;
|
|
358
|
-
case "CHECKBOX-GROUP":
|
|
359
|
-
props.items = this.getChildItems(el, "item", componentName);
|
|
360
|
-
propsOnly ? null : this._component = Components.CheckboxGroup(props);
|
|
361
|
-
break;
|
|
362
|
-
case "COLLAPSE":
|
|
363
|
-
propsOnly ? null : this._component = Components.Collapse(props);
|
|
364
|
-
break;
|
|
365
|
-
case "DROPDOWN":
|
|
366
|
-
props.items = this.getChildItems(el, "item", componentName);
|
|
367
|
-
propsOnly ? null : this._component = Components.Dropdown(props);
|
|
368
|
-
break;
|
|
369
|
-
case "FORM":
|
|
370
|
-
let controls = [];
|
|
371
|
-
let rows = [];
|
|
372
|
-
|
|
373
|
-
// Parse the child elements
|
|
374
|
-
for (let i = 0; i < el.children.length; i++) {
|
|
375
|
-
let elChild = el.children[i] as HTMLElement;
|
|
376
|
-
|
|
377
|
-
switch (elChild.nodeName) {
|
|
378
|
-
// Append the control
|
|
379
|
-
case "BS-FORM-CONTROL":
|
|
380
|
-
controls.push((new RenderComponents(elChild, true, true)).Props[0]);
|
|
381
|
-
break;
|
|
382
|
-
|
|
383
|
-
// Append the row
|
|
384
|
-
case "ROW":
|
|
385
|
-
let columns = [];
|
|
386
|
-
let rowControls = (new RenderComponents(elChild, true)).Props;
|
|
387
|
-
if (rowControls?.length > 0) {
|
|
388
|
-
// Append the control
|
|
389
|
-
for (let i = 0; i < rowControls.length; i++) {
|
|
390
|
-
columns.push({ control: rowControls[i] });
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
// Append the row
|
|
395
|
-
rows.push({ columns });
|
|
396
|
-
break;
|
|
397
|
-
|
|
398
|
-
// Default
|
|
399
|
-
default:
|
|
400
|
-
// Add it to the appropriate property
|
|
401
|
-
// Move the custom html
|
|
402
|
-
if (rows.length > 0) {
|
|
403
|
-
rows.push({
|
|
404
|
-
columns: [{
|
|
405
|
-
control: {
|
|
406
|
-
onControlRendered: (ctrl) => { ctrl.el.appendChild(elChild); }
|
|
407
|
-
}
|
|
408
|
-
}]
|
|
409
|
-
});
|
|
410
|
-
} else {
|
|
411
|
-
controls.push({
|
|
412
|
-
onControlRendered: (ctrl) => { ctrl.el.appendChild(elChild); }
|
|
413
|
-
});
|
|
414
|
-
}
|
|
415
|
-
break;
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
// Set the rows
|
|
420
|
-
props.rows = rows.length > 0 ? rows : undefined;
|
|
421
|
-
|
|
422
|
-
// Set the controls
|
|
423
|
-
//props.controls = this.getChildItems(el, "bs-form-control", componentName);
|
|
424
|
-
props.controls = controls.length > 0 ? controls : undefined;
|
|
425
|
-
|
|
426
|
-
// Render the form
|
|
427
|
-
propsOnly ? null : this._component = Components.Form(props);
|
|
428
|
-
break;
|
|
429
|
-
case "FORM-CONTROL":
|
|
430
|
-
props.items = this.getChildItems(el, "item", componentName);
|
|
431
|
-
propsOnly ? null : this._component = Components.FormControl(props);
|
|
432
|
-
break;
|
|
433
|
-
case "ICON-LINK":
|
|
434
|
-
propsOnly ? null : this._component = Components.IconLink(props);
|
|
435
|
-
break;
|
|
436
|
-
case "INPUT-GROUP":
|
|
437
|
-
// Get the prepended label
|
|
438
|
-
let prependedLabel = el.querySelector("prepended-label");
|
|
439
|
-
if (prependedLabel) {
|
|
440
|
-
// Set the property
|
|
441
|
-
props.prependedLabel = prependedLabel.innerHTML.trim();
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
// Set the properties
|
|
445
|
-
props.appendedButtons = this.getChildItems(el, "appended-button", componentName);
|
|
446
|
-
props.prependedButtons = this.getChildItems(el, "prepended-button", componentName);
|
|
447
|
-
propsOnly ? null : this._component = Components.InputGroup(props);
|
|
448
|
-
break;
|
|
449
|
-
case "LIST-BOX":
|
|
450
|
-
props.items = this.getChildItems(el, "item", componentName);
|
|
451
|
-
propsOnly ? null : this._component = Components.ListBox(props);
|
|
452
|
-
break;
|
|
453
|
-
case "LIST-GROUP":
|
|
454
|
-
props.items = this.getChildItems(el, "item", componentName);
|
|
455
|
-
propsOnly ? null : this._component = Components.ListGroup(props);
|
|
456
|
-
break;
|
|
457
|
-
case "MODAL":
|
|
458
|
-
// Set the custom elements
|
|
459
|
-
props.body = this.getElement(el, "bs-modal-body");
|
|
460
|
-
props.footer = this.getElement(el, "bs-modal-footer");
|
|
461
|
-
props.header = this.getElement(el, "bs-modal-header");
|
|
462
|
-
props.title = this.getElement(el, "bs-modal-title");
|
|
463
|
-
|
|
464
|
-
// Render the modal
|
|
465
|
-
propsOnly ? null : this._component = Components.Modal(props);
|
|
466
|
-
break;
|
|
467
|
-
case "NAV":
|
|
468
|
-
props.items = this.getChildItems(el, "nav-item", componentName);
|
|
469
|
-
propsOnly ? null : this._component = Components.Nav(props);
|
|
470
|
-
break;
|
|
471
|
-
case "NAVBAR":
|
|
472
|
-
// Parse the child elements
|
|
473
|
-
for (let i = 0; i < el.children.length; i++) {
|
|
474
|
-
let elChild = el.children[i] as HTMLElement;
|
|
475
|
-
|
|
476
|
-
switch (elChild.nodeName) {
|
|
477
|
-
// Append the item
|
|
478
|
-
case "NAVBAR-ITEM":
|
|
479
|
-
let item = this.getProps(elChild, componentName);
|
|
480
|
-
item.items = this.getChildItems(elChild, "navbar-item", componentName);
|
|
481
|
-
props.items = props.items || [];
|
|
482
|
-
props.items.push(item);
|
|
483
|
-
break;
|
|
484
|
-
|
|
485
|
-
// Append the item
|
|
486
|
-
case "NAVBAR-ITEM-END":
|
|
487
|
-
let itemEnd = this.getProps(elChild, componentName);
|
|
488
|
-
itemEnd.itemsEnd = this.getChildItems(elChild, "navbar-item-end", componentName);
|
|
489
|
-
props.itemsEnd = props.itemsEnd || [];
|
|
490
|
-
props.itemsEnd.push(itemEnd);
|
|
491
|
-
break;
|
|
492
|
-
|
|
493
|
-
// Set the searchbox
|
|
494
|
-
case "NAVBAR-SEARCH-BOX":
|
|
495
|
-
props.searchBox = this.getProps(elChild, elChild.nodeName);
|
|
496
|
-
break;
|
|
497
|
-
}
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
// Render the navbar
|
|
501
|
-
propsOnly ? null : this._component = Components.Navbar(props);
|
|
502
|
-
break;
|
|
503
|
-
case "OFFCANVAS":
|
|
504
|
-
props.body = this.createElement(el, false);
|
|
505
|
-
propsOnly ? null : this._component = Components.Offcanvas(props);
|
|
506
|
-
break;
|
|
507
|
-
case "POPOVER":
|
|
508
|
-
props.options = props.options || {};
|
|
509
|
-
props.options["content"] = this.createElement(el, false);
|
|
510
|
-
propsOnly ? null : this._component = Components.Popover(props);
|
|
511
|
-
break;
|
|
512
|
-
case "PROGRESS":
|
|
513
|
-
propsOnly ? null : this._component = Components.Progress(props);
|
|
514
|
-
break;
|
|
515
|
-
case "PROGRESS-GROUP":
|
|
516
|
-
props.progressbars = this.getChildItems(el, "bs-progress", componentName);
|
|
517
|
-
propsOnly ? null : this._component = Components.ProgressGroup(props);
|
|
518
|
-
break;
|
|
519
|
-
case "SPINNER":
|
|
520
|
-
propsOnly ? null : this._component = Components.Spinner(props);
|
|
521
|
-
break;
|
|
522
|
-
case "TABLE":
|
|
523
|
-
// Parse the child elements
|
|
524
|
-
props.rows = [];
|
|
525
|
-
for (let i = 0; i < el.children.length; i++) {
|
|
526
|
-
let elChild = el.children[i] as HTMLElement;
|
|
527
|
-
if (elChild.nodeName == "BS-ROW") {
|
|
528
|
-
try {
|
|
529
|
-
let row = JSON.parse(elChild.innerHTML);
|
|
530
|
-
props.rows.push(row);
|
|
531
|
-
} catch { }
|
|
532
|
-
}
|
|
533
|
-
}
|
|
534
|
-
|
|
535
|
-
// Set the properties
|
|
536
|
-
props.columns = this.getChildItems(el, "bs-col", componentName);
|
|
537
|
-
propsOnly ? null : this._component = Components.Table(props);
|
|
538
|
-
break;
|
|
539
|
-
case "TOAST":
|
|
540
|
-
props.body = this.createElement(el, false);
|
|
541
|
-
propsOnly ? null : this._component = Components.Toast(props);
|
|
542
|
-
break;
|
|
543
|
-
case "TOOLBAR":
|
|
544
|
-
props.items = this.getChildItems(el, "toolbar-item", componentName);
|
|
545
|
-
propsOnly ? null : this._component = Components.Toolbar(props);
|
|
546
|
-
break;
|
|
547
|
-
case "TOOLTIP":
|
|
548
|
-
props.btnProps = this.getChildItems(el, "btn-props", componentName);
|
|
549
|
-
props.content = props.content || this.createElement(el, false);
|
|
550
|
-
propsOnly ? null : this._component = Components.Tooltip(props);
|
|
551
|
-
break;
|
|
552
|
-
// Do nothing
|
|
553
|
-
default:
|
|
554
|
-
return;
|
|
555
|
-
}
|
|
556
|
-
|
|
557
|
-
// Clear the element
|
|
558
|
-
while (el.firstChild) { el.removeChild(el.firstChild); }
|
|
559
|
-
|
|
560
|
-
// Do nothing if we are only generating properties
|
|
561
|
-
this._props.push(props);
|
|
562
|
-
if (propsOnly) { return; }
|
|
563
|
-
|
|
564
|
-
// Set the class name
|
|
565
|
-
el.classList.add("bs");
|
|
566
|
-
|
|
567
|
-
// Remove the id attribute
|
|
568
|
-
if (el.hasAttribute("id") && (componentName != "MODAL" && componentName != "OFFCANVAS")) { el.removeAttribute("id"); }
|
|
569
|
-
|
|
570
|
-
// See if the parent exists
|
|
571
|
-
if (el.parentElement) {
|
|
572
|
-
// Replace the element
|
|
573
|
-
el.parentElement.insertBefore(this._component.el, el);
|
|
574
|
-
el.parentElement.classList.add("bs");
|
|
575
|
-
el.remove();
|
|
576
|
-
} else {
|
|
577
|
-
// Append the component
|
|
578
|
-
el.appendChild(this._component.el);
|
|
579
|
-
}
|
|
580
|
-
});
|
|
581
|
-
}
|
|
582
|
-
}
|
|
583
|
-
export const render = (el) => { new RenderComponents(el); }
|