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
|
@@ -104,9 +104,9 @@ var _Alert = /** @class */ (function (_super) {
|
|
|
104
104
|
// Add the fade class
|
|
105
105
|
_this.el.classList.add("fade");
|
|
106
106
|
setTimeout(function () { _this.hide(); }, 250);
|
|
107
|
+
// Execute the event
|
|
108
|
+
_this.props.onClose ? _this.props.onClose(_this.props) : null;
|
|
107
109
|
});
|
|
108
|
-
// Execute the event
|
|
109
|
-
this.props.onClose ? this.props.onClose(this.props) : null;
|
|
110
110
|
}
|
|
111
111
|
};
|
|
112
112
|
/**
|
|
@@ -162,11 +162,21 @@ var _Button = /** @class */ (function (_super) {
|
|
|
162
162
|
});
|
|
163
163
|
}
|
|
164
164
|
// See if we are toggling anything
|
|
165
|
-
if (this.props.toggleObj
|
|
165
|
+
if (this.props.toggleObj) {
|
|
166
166
|
// Add a click event
|
|
167
167
|
this.el.addEventListener("click", function (ev) {
|
|
168
|
-
//
|
|
169
|
-
_this.props.toggleObj.toggle
|
|
168
|
+
// See if it's a function
|
|
169
|
+
if (typeof (_this.props.toggleObj.toggle) === "function") {
|
|
170
|
+
// Toggle the object
|
|
171
|
+
_this.props.toggleObj.toggle();
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
var objToggle = window[_this.props.toggleObj];
|
|
175
|
+
if (typeof (objToggle === null || objToggle === void 0 ? void 0 : objToggle.toggle) === "function") {
|
|
176
|
+
// Toggle the object
|
|
177
|
+
objToggle.toggle();
|
|
178
|
+
}
|
|
179
|
+
}
|
|
170
180
|
});
|
|
171
181
|
}
|
|
172
182
|
};
|
|
@@ -0,0 +1,529 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.CustomElement = void 0;
|
|
15
|
+
var CustomElement = /** @class */ (function () {
|
|
16
|
+
function CustomElement(el) {
|
|
17
|
+
var componentName = el.nodeName.substring(3);
|
|
18
|
+
// Get the component props
|
|
19
|
+
var props = __assign(__assign({}, this.getProps(el, componentName)), { el: el });
|
|
20
|
+
switch (componentName) {
|
|
21
|
+
case "ACCORDION":
|
|
22
|
+
props.items = this.getChildItems(el, "item", componentName);
|
|
23
|
+
GD.Components.Accordion(props);
|
|
24
|
+
break;
|
|
25
|
+
case "ALERT":
|
|
26
|
+
GD.Components.Alert(props);
|
|
27
|
+
break;
|
|
28
|
+
case "BADGE":
|
|
29
|
+
GD.Components.Badge(props);
|
|
30
|
+
break;
|
|
31
|
+
case "BREADCRUMB":
|
|
32
|
+
props.items = this.getChildItems(el, "item", componentName);
|
|
33
|
+
GD.Components.Breadcrumb(props);
|
|
34
|
+
break;
|
|
35
|
+
case "BUTTON":
|
|
36
|
+
GD.Components.Button(props);
|
|
37
|
+
break;
|
|
38
|
+
case "BUTTON-GROUP":
|
|
39
|
+
props.buttons = this.getChildItems(el, "bs-button", "BUTTON");
|
|
40
|
+
GD.Components.ButtonGroup(props);
|
|
41
|
+
break;
|
|
42
|
+
case "CARD":
|
|
43
|
+
props.body = this.getChildItems(el, "card-body", componentName);
|
|
44
|
+
props.header = this.getChildItems(el, "card-footer", componentName);
|
|
45
|
+
props.footer = this.getChildItems(el, "card-header", componentName);
|
|
46
|
+
GD.Components.Card(props);
|
|
47
|
+
break;
|
|
48
|
+
case "CARD-GROUP":
|
|
49
|
+
props.cards = this.getChildItems(el, "bs-card", "CARD");
|
|
50
|
+
GD.Components.CardGroup(props);
|
|
51
|
+
break;
|
|
52
|
+
case "CAROUSEL":
|
|
53
|
+
props.items = this.getChildItems(el, "item", componentName);
|
|
54
|
+
GD.Components.Carousel(props);
|
|
55
|
+
break;
|
|
56
|
+
case "CHECKBOX-GROUP":
|
|
57
|
+
props.items = this.getChildItems(el, "item", componentName);
|
|
58
|
+
GD.Components.CheckboxGroup(props);
|
|
59
|
+
break;
|
|
60
|
+
case "COLLAPSE":
|
|
61
|
+
GD.Components.Collapse(props);
|
|
62
|
+
break;
|
|
63
|
+
case "DROPDOWN":
|
|
64
|
+
props.items = this.getChildItems(el, "item", componentName);
|
|
65
|
+
GD.Components.Dropdown(props);
|
|
66
|
+
break;
|
|
67
|
+
case "FORM":
|
|
68
|
+
var controls = [];
|
|
69
|
+
var rows = [];
|
|
70
|
+
var _loop_1 = function (i) {
|
|
71
|
+
var elChild = el.children[i];
|
|
72
|
+
switch (elChild.nodeName) {
|
|
73
|
+
// Append the control
|
|
74
|
+
case "BS-FORM-CONTROL":
|
|
75
|
+
//controls.push((new RenderComponents(elChild, true, true)).Props[0]);
|
|
76
|
+
break;
|
|
77
|
+
// Append the row
|
|
78
|
+
case "ROW":
|
|
79
|
+
var columns = [];
|
|
80
|
+
/*
|
|
81
|
+
let rowControls = (new RenderComponents(elChild, true)).Props;
|
|
82
|
+
if (rowControls?.length > 0) {
|
|
83
|
+
// Append the control
|
|
84
|
+
for (let i = 0; i < rowControls.length; i++) {
|
|
85
|
+
columns.push({ control: rowControls[i] });
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
*/
|
|
89
|
+
// Append the row
|
|
90
|
+
rows.push({ columns: columns });
|
|
91
|
+
break;
|
|
92
|
+
// Default
|
|
93
|
+
default:
|
|
94
|
+
// Add it to the appropriate property
|
|
95
|
+
// Move the custom html
|
|
96
|
+
if (rows.length > 0) {
|
|
97
|
+
rows.push({
|
|
98
|
+
columns: [{
|
|
99
|
+
control: {
|
|
100
|
+
onControlRendered: function (ctrl) { ctrl.el.appendChild(elChild); }
|
|
101
|
+
}
|
|
102
|
+
}]
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
controls.push({
|
|
107
|
+
onControlRendered: function (ctrl) { ctrl.el.appendChild(elChild); }
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
// Parse the child elements
|
|
114
|
+
for (var i = 0; i < el.children.length; i++) {
|
|
115
|
+
_loop_1(i);
|
|
116
|
+
}
|
|
117
|
+
// Set the rows
|
|
118
|
+
props.rows = rows.length > 0 ? rows : undefined;
|
|
119
|
+
// Set the controls
|
|
120
|
+
//props.controls = this.getChildItems(el, "bs-form-control", componentName);
|
|
121
|
+
props.controls = controls.length > 0 ? controls : undefined;
|
|
122
|
+
// Render the form
|
|
123
|
+
GD.Components.Form(props);
|
|
124
|
+
break;
|
|
125
|
+
case "FORM-CONTROL":
|
|
126
|
+
props.items = this.getChildItems(el, "item", componentName);
|
|
127
|
+
GD.Components.FormControl(props);
|
|
128
|
+
break;
|
|
129
|
+
case "ICON-LINK":
|
|
130
|
+
GD.Components.IconLink(props);
|
|
131
|
+
break;
|
|
132
|
+
case "INPUT-GROUP":
|
|
133
|
+
// Get the prepended label
|
|
134
|
+
var prependedLabel = el.querySelector("prepended-label");
|
|
135
|
+
if (prependedLabel) {
|
|
136
|
+
// Set the property
|
|
137
|
+
props.prependedLabel = prependedLabel.innerHTML.trim();
|
|
138
|
+
}
|
|
139
|
+
// Set the properties
|
|
140
|
+
props.appendedButtons = this.getChildItems(el, "appended-button", "APPENDED-BUTTON");
|
|
141
|
+
props.prependedButtons = this.getChildItems(el, "prepended-button", "PREPENDED-BUTTON");
|
|
142
|
+
GD.Components.InputGroup(props);
|
|
143
|
+
break;
|
|
144
|
+
case "LIST-BOX":
|
|
145
|
+
props.items = this.getChildItems(el, "item", componentName);
|
|
146
|
+
GD.Components.ListBox(props);
|
|
147
|
+
break;
|
|
148
|
+
case "LIST-GROUP":
|
|
149
|
+
props.items = this.getChildItems(el, "item", componentName);
|
|
150
|
+
GD.Components.ListGroup(props);
|
|
151
|
+
break;
|
|
152
|
+
case "MODAL":
|
|
153
|
+
// Set the custom elements
|
|
154
|
+
props.body = this.getElement(el, "bs-modal-body");
|
|
155
|
+
props.footer = this.getElement(el, "bs-modal-footer");
|
|
156
|
+
props.header = this.getElement(el, "bs-modal-header");
|
|
157
|
+
props.title = this.getElement(el, "bs-modal-title");
|
|
158
|
+
// Render the modal
|
|
159
|
+
GD.Components.Modal(props);
|
|
160
|
+
break;
|
|
161
|
+
case "NAV":
|
|
162
|
+
props.items = this.getChildItems(el, "nav-item", componentName);
|
|
163
|
+
GD.Components.Nav(props);
|
|
164
|
+
break;
|
|
165
|
+
case "NAVBAR":
|
|
166
|
+
// Parse the child elements
|
|
167
|
+
for (var i = 0; i < el.children.length; i++) {
|
|
168
|
+
var elChild = el.children[i];
|
|
169
|
+
switch (elChild.nodeName) {
|
|
170
|
+
// Append the item
|
|
171
|
+
case "NAVBAR-ITEM":
|
|
172
|
+
var item = this.getProps(elChild, elChild.nodeName);
|
|
173
|
+
item.items = this.getChildItems(elChild, "navbar-item", componentName);
|
|
174
|
+
props.items = props.items || [];
|
|
175
|
+
props.items.push(item);
|
|
176
|
+
break;
|
|
177
|
+
// Append the item
|
|
178
|
+
case "NAVBAR-ITEM-END":
|
|
179
|
+
var itemEnd = this.getProps(elChild, elChild.nodeName);
|
|
180
|
+
itemEnd.itemsEnd = this.getChildItems(elChild, "navbar-item-end", componentName);
|
|
181
|
+
props.itemsEnd = props.itemsEnd || [];
|
|
182
|
+
props.itemsEnd.push(itemEnd);
|
|
183
|
+
break;
|
|
184
|
+
// Set the searchbox
|
|
185
|
+
case "NAVBAR-SEARCH-BOX":
|
|
186
|
+
props.searchBox = this.getProps(elChild, elChild.nodeName);
|
|
187
|
+
break;
|
|
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
|
+
var 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
|
+
}
|
|
228
|
+
catch (_a) { }
|
|
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
|
+
// Creates an element and appends the children to it
|
|
252
|
+
CustomElement.prototype.createElement = function (elSource, removeFl) {
|
|
253
|
+
if (removeFl === void 0) { removeFl = true; }
|
|
254
|
+
var elTarget = document.createElement("div");
|
|
255
|
+
// See if the target exists
|
|
256
|
+
while (elSource.firstChild) {
|
|
257
|
+
elTarget.appendChild(elSource.firstChild);
|
|
258
|
+
}
|
|
259
|
+
// Render any custom elements
|
|
260
|
+
//new RenderComponents(elTarget);
|
|
261
|
+
// Remove the element
|
|
262
|
+
removeFl ? elSource.remove() : null;
|
|
263
|
+
// Return the target element
|
|
264
|
+
return elTarget.childNodes.length > 0 ? elTarget : null;
|
|
265
|
+
};
|
|
266
|
+
// Converts the custom childelements
|
|
267
|
+
CustomElement.prototype.getChildItems = function (el, propName, componentName) {
|
|
268
|
+
var _this = this;
|
|
269
|
+
var items = [];
|
|
270
|
+
// Get the item elements
|
|
271
|
+
el.querySelectorAll(propName).forEach(function (elItem) {
|
|
272
|
+
var _a, _b, _c, _d;
|
|
273
|
+
// Ensure this is an item
|
|
274
|
+
if (elItem.nodeName == propName.toUpperCase()) {
|
|
275
|
+
var item = _this.getProps(elItem, componentName);
|
|
276
|
+
// See if there is content
|
|
277
|
+
if (elItem.innerHTML) {
|
|
278
|
+
// Set custom child elements
|
|
279
|
+
switch (elItem.nodeName) {
|
|
280
|
+
case "APPENDED-BUTTON":
|
|
281
|
+
case "BTN-PROPS":
|
|
282
|
+
case "CARD-ACTION":
|
|
283
|
+
case "PREPENDED-BUTTON":
|
|
284
|
+
item.text = (_a = (item.text || elItem.innerHTML)) === null || _a === void 0 ? void 0 : _a.trim();
|
|
285
|
+
break;
|
|
286
|
+
case "BS-CARD":
|
|
287
|
+
item.body = _this.getChildItems(elItem, "card-body", componentName);
|
|
288
|
+
item.header = _this.getChildItems(elItem, "card-footer", componentName);
|
|
289
|
+
item.footer = _this.getChildItems(elItem, "card-header", componentName);
|
|
290
|
+
break;
|
|
291
|
+
case "BS-COL":
|
|
292
|
+
item.title = (_b = (item.title || elItem.innerHTML)) === null || _b === void 0 ? void 0 : _b.trim();
|
|
293
|
+
break;
|
|
294
|
+
case "CARD-BODY":
|
|
295
|
+
item.actions = _this.getChildItems(elItem, "card-action", elItem.nodeName);
|
|
296
|
+
break;
|
|
297
|
+
case "NAVBAR-ITEM":
|
|
298
|
+
item.items = _this.getChildItems(elItem, "navbar-item", componentName);
|
|
299
|
+
item.text = (_c = (item.text || elItem.innerHTML)) === null || _c === void 0 ? void 0 : _c.trim();
|
|
300
|
+
break;
|
|
301
|
+
case "NAVBAR-ITEM-END":
|
|
302
|
+
item.items = _this.getChildItems(elItem, "navbar-item-end", componentName);
|
|
303
|
+
item.text = (_d = (item.text || elItem.innerHTML)) === null || _d === void 0 ? void 0 : _d.trim();
|
|
304
|
+
break;
|
|
305
|
+
case "TOOLBAR-ITEM":
|
|
306
|
+
item.buttons = _this.getChildItems(elItem, "bs-button", "BUTTON");
|
|
307
|
+
break;
|
|
308
|
+
}
|
|
309
|
+
// See if there is a sub-component
|
|
310
|
+
switch (componentName) {
|
|
311
|
+
case "LIST-GROUP":
|
|
312
|
+
// Set the badge
|
|
313
|
+
var badge = _this.getChildItems(elItem, "bs-badge", componentName);
|
|
314
|
+
if ((badge === null || badge === void 0 ? void 0 : badge.length) > 0) {
|
|
315
|
+
item.badge = badge[0];
|
|
316
|
+
}
|
|
317
|
+
break;
|
|
318
|
+
}
|
|
319
|
+
// Set the custom property
|
|
320
|
+
switch (componentName) {
|
|
321
|
+
// content
|
|
322
|
+
case "ACCORDION":
|
|
323
|
+
case "CARD":
|
|
324
|
+
case "CAROUSEL":
|
|
325
|
+
case "LIST-GROUP":
|
|
326
|
+
item.content = item.content || _this.createElement(elItem);
|
|
327
|
+
break;
|
|
328
|
+
// label
|
|
329
|
+
case "CHECKBOX-GROUP":
|
|
330
|
+
item.label = item.label || elItem.innerHTML;
|
|
331
|
+
break;
|
|
332
|
+
// tab content
|
|
333
|
+
case "NAV":
|
|
334
|
+
item.tabContent = item.tabContent || _this.createElement(elItem);
|
|
335
|
+
break;
|
|
336
|
+
// text
|
|
337
|
+
case "CARD-BODY":
|
|
338
|
+
break;
|
|
339
|
+
case "BREADCRUMB":
|
|
340
|
+
case "DROPDOWN":
|
|
341
|
+
case "FORM-CONTROL":
|
|
342
|
+
case "LIST-BOX":
|
|
343
|
+
item.text = item.text || elItem.innerHTML;
|
|
344
|
+
break;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
// Add the item
|
|
348
|
+
items.push(item);
|
|
349
|
+
// Remove the item
|
|
350
|
+
elItem.remove();
|
|
351
|
+
}
|
|
352
|
+
});
|
|
353
|
+
// See if items exist
|
|
354
|
+
if (items.length > 0) {
|
|
355
|
+
switch (propName) {
|
|
356
|
+
case "btn-props":
|
|
357
|
+
return items[0];
|
|
358
|
+
default:
|
|
359
|
+
return items;
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
// Return nothing
|
|
363
|
+
return undefined;
|
|
364
|
+
};
|
|
365
|
+
// Converts the target component name to an element
|
|
366
|
+
CustomElement.prototype.getElement = function (elSource, componentName) {
|
|
367
|
+
var elTarget = null;
|
|
368
|
+
// See if the target exists
|
|
369
|
+
elSource.childNodes.forEach(function (el) {
|
|
370
|
+
if (el.nodeName == componentName.toUpperCase()) {
|
|
371
|
+
// Create the element
|
|
372
|
+
elTarget = document.createElement("div");
|
|
373
|
+
// Set the element
|
|
374
|
+
while (el.firstChild) {
|
|
375
|
+
elTarget.appendChild(el.firstChild);
|
|
376
|
+
}
|
|
377
|
+
// Remove the element
|
|
378
|
+
el.remove();
|
|
379
|
+
}
|
|
380
|
+
});
|
|
381
|
+
// Return the target element
|
|
382
|
+
return elTarget;
|
|
383
|
+
};
|
|
384
|
+
// Gets the property name
|
|
385
|
+
CustomElement.prototype.getPropName = function (propName) {
|
|
386
|
+
var idx = propName.indexOf('-');
|
|
387
|
+
while (idx > 0) {
|
|
388
|
+
// Update the key and index
|
|
389
|
+
propName = propName.substring(0, idx) + propName[idx + 1].toUpperCase() + propName.substring(idx + 2);
|
|
390
|
+
idx = propName.indexOf('-');
|
|
391
|
+
}
|
|
392
|
+
// Return the property name
|
|
393
|
+
return propName;
|
|
394
|
+
};
|
|
395
|
+
// Gets the properties of an element and returns an object
|
|
396
|
+
CustomElement.prototype.getProps = function (el, componentName) {
|
|
397
|
+
var _a, _b;
|
|
398
|
+
var props = {};
|
|
399
|
+
// Parse the attributes
|
|
400
|
+
for (var i = 0; i < el.attributes.length; i++) {
|
|
401
|
+
var attribute = el.attributes[i];
|
|
402
|
+
// Set the value
|
|
403
|
+
var value = attribute.value;
|
|
404
|
+
// Convert the value
|
|
405
|
+
if (typeof (value) === "string") {
|
|
406
|
+
// See if it's a boolean value
|
|
407
|
+
if ((value === null || value === void 0 ? void 0 : value.toLowerCase()) == "true") {
|
|
408
|
+
value = true;
|
|
409
|
+
}
|
|
410
|
+
else if ((value === null || value === void 0 ? void 0 : value.toLowerCase()) == "false") {
|
|
411
|
+
value = false;
|
|
412
|
+
}
|
|
413
|
+
// Else, see if it's linked to a global library
|
|
414
|
+
else if (value.indexOf('.') > 0) {
|
|
415
|
+
// Split the value
|
|
416
|
+
var objInfo = value.split('.');
|
|
417
|
+
// See if this is linked to a global library
|
|
418
|
+
var objProp = null;
|
|
419
|
+
for (var i_1 = 0; i_1 < objInfo.length; i_1++) {
|
|
420
|
+
if (i_1 == 0) {
|
|
421
|
+
objProp = window[objInfo[0]];
|
|
422
|
+
if (objProp) {
|
|
423
|
+
continue;
|
|
424
|
+
}
|
|
425
|
+
else {
|
|
426
|
+
break;
|
|
427
|
+
}
|
|
428
|
+
;
|
|
429
|
+
}
|
|
430
|
+
// Update the object
|
|
431
|
+
objProp = objProp[objInfo[i_1]];
|
|
432
|
+
if (objProp == null) {
|
|
433
|
+
break;
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
// See if the object exists
|
|
437
|
+
if (objProp) {
|
|
438
|
+
// Update the value
|
|
439
|
+
value = objProp;
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
else {
|
|
443
|
+
try {
|
|
444
|
+
// See if it's JSON
|
|
445
|
+
var jsonObj = JSON.parse(value);
|
|
446
|
+
value = jsonObj;
|
|
447
|
+
}
|
|
448
|
+
catch (_c) {
|
|
449
|
+
try {
|
|
450
|
+
// See if it's a reference
|
|
451
|
+
var elTarget = document.querySelector(value);
|
|
452
|
+
if (elTarget) {
|
|
453
|
+
value = elTarget;
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
catch (_d) { }
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
// Add the property
|
|
461
|
+
props[this.getPropName(attribute.name)] = value;
|
|
462
|
+
}
|
|
463
|
+
// See if there is a sub-component
|
|
464
|
+
switch (componentName) {
|
|
465
|
+
case "BUTTON":
|
|
466
|
+
// Set the spinner
|
|
467
|
+
var spinner = this.getChildItems(el, "bs-spinner", componentName);
|
|
468
|
+
if ((spinner === null || spinner === void 0 ? void 0 : spinner.length) > 0) {
|
|
469
|
+
props.spinner = spinner[0];
|
|
470
|
+
}
|
|
471
|
+
break;
|
|
472
|
+
}
|
|
473
|
+
// Set common properties
|
|
474
|
+
var clearElementFl = false;
|
|
475
|
+
switch (componentName) {
|
|
476
|
+
// content
|
|
477
|
+
case "ALERT":
|
|
478
|
+
case "BADGE":
|
|
479
|
+
case "COLLAPSE":
|
|
480
|
+
case "ICON-LINK":
|
|
481
|
+
props.content = this.createElement(el, false);
|
|
482
|
+
break;
|
|
483
|
+
// data
|
|
484
|
+
case "DATA":
|
|
485
|
+
// Try to parse the value
|
|
486
|
+
try {
|
|
487
|
+
var data = JSON.parse(el.innerHTML.trim());
|
|
488
|
+
props.data = data;
|
|
489
|
+
clearElementFl = true;
|
|
490
|
+
}
|
|
491
|
+
catch (_e) { }
|
|
492
|
+
break;
|
|
493
|
+
// label
|
|
494
|
+
case "PROGRESS":
|
|
495
|
+
clearElementFl = props.label ? false : true;
|
|
496
|
+
props.label = (_a = (props.label || el.innerHTML)) === null || _a === void 0 ? void 0 : _a.trim();
|
|
497
|
+
break;
|
|
498
|
+
// text
|
|
499
|
+
case "BUTTON":
|
|
500
|
+
case "NAVBAR-ITEM":
|
|
501
|
+
case "NAVBAR-ITEM-END":
|
|
502
|
+
clearElementFl = props.text ? false : true;
|
|
503
|
+
props.text = (_b = (props.text || el.innerHTML)) === null || _b === void 0 ? void 0 : _b.trim();
|
|
504
|
+
break;
|
|
505
|
+
// value
|
|
506
|
+
case "INPUT-GROUP":
|
|
507
|
+
case "NAVBAR-SEARCH-BOX":
|
|
508
|
+
// Ensure the value exists
|
|
509
|
+
if (typeof (props.value) != "undefined") {
|
|
510
|
+
props.value = typeof (props.value) === "string" ? props.value : props.value;
|
|
511
|
+
}
|
|
512
|
+
else {
|
|
513
|
+
clearElementFl = true;
|
|
514
|
+
props.value = el.innerHTML.trim();
|
|
515
|
+
}
|
|
516
|
+
break;
|
|
517
|
+
}
|
|
518
|
+
// Clear the element
|
|
519
|
+
if (clearElementFl) {
|
|
520
|
+
while (el.firstChild) {
|
|
521
|
+
el.removeChild(el.firstChild);
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
// Return the properties
|
|
525
|
+
return props;
|
|
526
|
+
};
|
|
527
|
+
return CustomElement;
|
|
528
|
+
}());
|
|
529
|
+
exports.CustomElement = CustomElement;
|