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