gd-bs 5.0.6 → 5.1.0
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/listBox/index.js +26 -0
- package/build/components/nav/index.js +6 -6
- package/dist/gd-bs-icons.js +2 -2
- package/dist/gd-bs-icons.min.js +1 -1
- package/dist/gd-bs.d.ts +9 -11
- package/dist/gd-bs.js +2 -2
- package/dist/gd-bs.min.js +1 -1
- package/package.json +1 -1
- package/src/components/accordion/types.d.ts +10 -15
- package/src/components/listBox/index.ts +24 -0
- package/src/components/listBox/types.d.ts +4 -0
- package/src/components/nav/index.ts +6 -6
package/dist/gd-bs.d.ts
CHANGED
|
@@ -59,15 +59,16 @@ declare module 'gd-bs/components/accordion/types' {
|
|
|
59
59
|
* id: "demoAccordion",
|
|
60
60
|
* items: [
|
|
61
61
|
* {
|
|
62
|
-
*
|
|
63
|
-
* content: "This is the content for item 1."
|
|
62
|
+
* header: "Item 1",
|
|
63
|
+
* content: "This is the content for item 1.",
|
|
64
|
+
* showFl: true
|
|
64
65
|
* },
|
|
65
66
|
* {
|
|
66
|
-
*
|
|
67
|
+
* header: "Item 2",
|
|
67
68
|
* content: "This is the content for item 2."
|
|
68
69
|
* },
|
|
69
70
|
* {
|
|
70
|
-
*
|
|
71
|
+
* header: "Item 3",
|
|
71
72
|
* content: "This is the content for item 3."
|
|
72
73
|
* }
|
|
73
74
|
* ]
|
|
@@ -77,7 +78,6 @@ declare module 'gd-bs/components/accordion/types' {
|
|
|
77
78
|
export const Accordion: (props: IAccordionProps, template?: string, itemTemplate?: string) => IAccordion;
|
|
78
79
|
|
|
79
80
|
import { IBase, IBaseProps } from "gd-bs/components/types";
|
|
80
|
-
import { ICollapseOptions } from "gd-bs/components/collapse/types";
|
|
81
81
|
|
|
82
82
|
/**
|
|
83
83
|
* Accordion
|
|
@@ -97,11 +97,6 @@ declare module 'gd-bs/components/accordion/types' {
|
|
|
97
97
|
showFl?: boolean;
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
/**
|
|
101
|
-
* Accordion Options
|
|
102
|
-
*/
|
|
103
|
-
export interface IAccordionOptions extends ICollapseOptions { }
|
|
104
|
-
|
|
105
100
|
/**
|
|
106
101
|
* Accordion Properties
|
|
107
102
|
*/
|
|
@@ -109,7 +104,6 @@ declare module 'gd-bs/components/accordion/types' {
|
|
|
109
104
|
autoCollapse?: boolean;
|
|
110
105
|
id?: string;
|
|
111
106
|
items?: Array<IAccordionItem<T>>;
|
|
112
|
-
options?: IAccordionOptions;
|
|
113
107
|
}
|
|
114
108
|
}
|
|
115
109
|
|
|
@@ -1583,6 +1577,9 @@ declare module 'gd-bs/components/listBox/types' {
|
|
|
1583
1577
|
/** The selected listbox items. */
|
|
1584
1578
|
getValue: () => Array<IDropdownItem>;
|
|
1585
1579
|
|
|
1580
|
+
/** Sets the options */
|
|
1581
|
+
setOptions: (items: Array<IDropdownItem>) => void;
|
|
1582
|
+
|
|
1586
1583
|
/** Sets the listbox value. */
|
|
1587
1584
|
setValue: (value?: string | Array<string> | Array<IDropdownItem>) => void;
|
|
1588
1585
|
}
|
|
@@ -1597,6 +1594,7 @@ declare module 'gd-bs/components/listBox/types' {
|
|
|
1597
1594
|
items: Array<IDropdownItem>;
|
|
1598
1595
|
multi?: boolean;
|
|
1599
1596
|
placeholder?: string;
|
|
1597
|
+
onLoadData?: () => Array<IDropdownItem> | PromiseLike<Array<IDropdownItem>>;
|
|
1600
1598
|
onChange?: (items: IDropdownItem | Array<IDropdownItem>, ev?: Event) => void;
|
|
1601
1599
|
value?: string | Array<string>;
|
|
1602
1600
|
}
|
package/dist/gd-bs.js
CHANGED
|
@@ -1170,7 +1170,7 @@ eval("\n\nObject.defineProperty(exports, \"__esModule\", ({\n value: true\n}));
|
|
|
1170
1170
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
1171
1171
|
|
|
1172
1172
|
"use strict";
|
|
1173
|
-
eval("\n\nvar __extends = this && this.__extends || function () {\n var _extendStatics = function extendStatics(d, b) {\n _extendStatics = Object.setPrototypeOf || {\n __proto__: []\n } instanceof Array && function (d, b) {\n d.__proto__ = b;\n } || function (d, b) {\n for (var p in b) {\n if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];\n }\n };\n\n return _extendStatics(d, b);\n };\n\n return function (d, b) {\n _extendStatics(d, b);\n\n function __() {\n this.constructor = d;\n }\n\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n}();\n\nObject.defineProperty(exports, \"__esModule\", ({\n value: true\n}));\nexports.ListBox = void 0;\n\nvar base_1 = __webpack_require__(/*! ../base */ \"./build/components/base.js\");\n\nvar templates_1 = __webpack_require__(/*! ./templates */ \"./build/components/listBox/templates.js\");\n/**\r\n * List Box\r\n * @property props - The list box properties.\r\n */\n\n\nvar _ListBox = function (_super) {\n __extends(_ListBox, _super); // Constructor\n\n\n function _ListBox(props, template) {\n if (template === void 0) {\n template = templates_1.HTML;\n }\n\n var _this = _super.call(this, template, props) || this;\n\n _this._elLabel = null;\n _this._elSearchBox = null;\n _this._elDatalist = null;\n _this._elValues = null;\n _this._initFl = false;\n _this._items = null;\n _this._selectedItems = null; // Configure the list box\n\n _this.configure(); // Configure the events\n\n\n _this.configureEvents(); // Configure the parent\n\n\n _this.configureParent(); // Set the flag\n\n\n _this._initFl = true;\n return _this;\n } // Configures the list box\n\n\n _ListBox.prototype.configure = function () {\n this._elLabel = this.el.querySelector(\"label\");\n this._elSearchBox = this.el.querySelector(\"input\");\n this._elDatalist = this.el.querySelector(\"datalist\");\n this._elValues = this.el.querySelector(\"ul\"); // See if the placeholder exists\n\n if (this.props.placeholder) {\n // Update the placeholder\n this._elSearchBox ? this._elSearchBox.placeholder = this.props.placeholder : null;\n } // See if the id is set\n\n\n if (this.props.id) {\n // Update the ids\n this.el.id = this.props.id;\n this._elLabel ? this._elLabel.setAttribute(\"for\", this.props.id + \"-search\") : null;\n this._elSearchBox ? this._elSearchBox.id = this.props.id + \"-search\" : null;\n this._elSearchBox ? this._elSearchBox.setAttribute(\"list\", this.props.id + \"-list\") : null;\n this._elDatalist ? this._elDatalist.id = this.props.id + \"-list\" : null;\n } // See if the label exists\n\n\n if (this._elLabel) {\n if (this.props.label) {\n this._elLabel.innerHTML = this.props.label;\n } else {\n // Remove the label\n this.el.removeChild(this._elLabel);\n }\n } // See if this is read-only\n\n\n if (this.props.isReadonly) {\n // Disable the search box\n this._elSearchBox ? this._elSearchBox.disabled = true : null;\n } // Set the options\n\n\n this.setOptions(this.props.items); // Set the value if it's been defined\n\n if (this.props.value != undefined) {\n this.setValue(this.props.value);\n }\n }; // Configures the events\n\n\n _ListBox.prototype.configureEvents = function () {\n var _this = this; // Set the change event on the search box\n\n\n this._elSearchBox.addEventListener(\"input\", function (ev) {\n var value = _this._elSearchBox.value; // Parse the items\n\n for (var i = 0; i < _this._items.length; i++) {\n var item = _this._items[i]; // See if this is the target item\n\n if (item.text == value) {\n // See if this is a multi-select\n if (_this.props.multi) {\n var existsFl = false; // Parse the selected items\n\n for (var j = 0; j < _this._selectedItems.length; j++) {\n var selectedItem = _this._selectedItems[j]; // See if this item is already selected\n\n if (selectedItem.text == item.text) {\n // Set the flag\n existsFl = true;\n break;\n }\n } // Ensure the item wasn't already selected\n\n\n if (!existsFl) {\n // Set the value\n _this.setValue(_this._selectedItems.concat(item).sort(function (a, b) {\n if (a.text < b.text) {\n return -1;\n }\n\n if (a.text > b.text) {\n return 1;\n }\n\n return 0;\n })); // Call the change event\n\n\n _this.props.onChange ? _this.props.onChange(_this._selectedItems, ev) : null;\n }\n } else {\n // Set the value\n _this.setValue(value); // Call the change event\n\n\n _this.props.onChange ? _this.props.onChange(_this._selectedItems, ev) : null;\n } // Clear the selected value\n\n\n _this._elSearchBox.value = \"\"; // Bug - Edge (non-chromium)\n // The menu is still visible, so we fill force a \"blur\" to hide the menu after selection\n\n _this._elSearchBox.blur();\n }\n }\n });\n }; // Method to configure the item event\n\n\n _ListBox.prototype.configureItemEvent = function (elRemove, elItem, item) {\n var _this = this; // Ensure the remove element exists\n\n\n if (elRemove) {\n // Add a click event to the badge\n var badge = elItem.querySelector(\".badge\");\n\n if (badge) {\n badge.addEventListener(\"click\", function (ev) {\n // Remove the item\n _this._elValues.removeChild(elItem); // Find the selected item\n\n\n for (var i = 0; i < _this._selectedItems.length; i++) {\n var selectedItem = _this._selectedItems[i]; // See if this is the target item\n\n if (selectedItem.text == item.text) {\n // Remove this item\n _this._selectedItems.splice(i, 1); // Call the change event\n\n\n _this.props.onChange ? _this.props.onChange(_this._selectedItems, ev) : null;\n break;\n }\n }\n });\n }\n }\n };\n /**\r\n * Public Interface\r\n */\n\n\n _ListBox.prototype.getValue = function () {\n return this._selectedItems;\n };\n\n _ListBox.prototype.setOptions = function (items) {\n if (items === void 0) {\n items = [];\n }\n\n var elDatalist = this.el.querySelector(\"datalist\");\n\n if (elDatalist) {\n // Save a reference to the items\n this._items = items; // Clear the options\n\n while (elDatalist.firstChild) {\n elDatalist.removeChild(elDatalist.firstChild);\n } // Clear the value\n\n\n this._elSearchBox.value = \"\";\n this._selectedItems = []; // Parse the items\n\n for (var i = 0; i < items.length; i++) {\n var props = items[i]; // Add the option\n\n var elOption = document.createElement(\"option\");\n elOption.value = props.text;\n elDatalist.appendChild(elOption); // See if the item is selected\n\n if (props.isSelected) {\n // Add the selected item\n this._selectedItems.push(props);\n }\n } // See if items are selected\n\n\n if (this._selectedItems.length > 0) {\n // Set the value\n this.setValue(this._selectedItems);\n }\n }\n }; // Set the value\n\n\n _ListBox.prototype.setValue = function (value) {\n // Clear the items\n this._selectedItems = [];\n\n while (this._elValues.firstChild) {\n this._elValues.removeChild(this._elValues.firstChild);\n } // Parse the values\n\n\n if (value) {\n // Ensure this is an array\n var values = typeof value === \"string\" || typeof value === \"number\" ? [value] : value; // Parse the values\n\n for (var i = 0; i < values.length; i++) {\n var itemValue = values[i];\n itemValue = typeof itemValue === \"string\" || typeof itemValue === \"number\" ? itemValue : itemValue.text; // Parse the items\n\n for (var j = 0; j < this._items.length; j++) {\n var item = this._items[j]; // See if this is the target item\n\n if (item.text == itemValue || item.value == itemValue) {\n // Add the selected item\n this._selectedItems.push(item); // Create the list item\n\n\n var elItem = document.createElement(\"div\");\n elItem.innerHTML = templates_1.HTMLItem;\n elItem = elItem.firstChild;\n\n this._elValues.appendChild(elItem); // Set the text value\n\n\n var elRemove = elItem.querySelector(\"span\");\n\n if (elRemove) {\n var text = document.createTextNode(item.text);\n elItem.insertBefore(text, elRemove);\n } // See if this is read-only\n\n\n if (this.props.isReadonly) {\n // Delete the \"remove\" button\n elItem.removeChild(elRemove);\n elRemove = null;\n } // Configure the event for this item\n\n\n this.configureItemEvent(elRemove, elItem, item); // Break from the loop\n\n break;\n }\n }\n }\n } // See if a change event exists\n\n\n if (this._initFl && this.props.onChange) {\n // Execute the change event\n this.props.onChange(this.getValue());\n }\n };\n\n return _ListBox;\n}(base_1.Base);\n\nexports.ListBox = function (props, template) {\n return new _ListBox(props, template);\n};\n\n//# sourceURL=webpack://gd-bs/./build/components/listBox/index.js?");
|
|
1173
|
+
eval("\n\nvar __extends = this && this.__extends || function () {\n var _extendStatics = function extendStatics(d, b) {\n _extendStatics = Object.setPrototypeOf || {\n __proto__: []\n } instanceof Array && function (d, b) {\n d.__proto__ = b;\n } || function (d, b) {\n for (var p in b) {\n if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];\n }\n };\n\n return _extendStatics(d, b);\n };\n\n return function (d, b) {\n _extendStatics(d, b);\n\n function __() {\n this.constructor = d;\n }\n\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n}();\n\nObject.defineProperty(exports, \"__esModule\", ({\n value: true\n}));\nexports.ListBox = void 0;\n\nvar base_1 = __webpack_require__(/*! ../base */ \"./build/components/base.js\");\n\nvar templates_1 = __webpack_require__(/*! ./templates */ \"./build/components/listBox/templates.js\");\n/**\r\n * List Box\r\n * @property props - The list box properties.\r\n */\n\n\nvar _ListBox = function (_super) {\n __extends(_ListBox, _super); // Constructor\n\n\n function _ListBox(props, template) {\n if (template === void 0) {\n template = templates_1.HTML;\n }\n\n var _this = _super.call(this, template, props) || this;\n\n _this._elLabel = null;\n _this._elSearchBox = null;\n _this._elDatalist = null;\n _this._elValues = null;\n _this._initFl = false;\n _this._items = null;\n _this._selectedItems = null; // Configure the list box\n\n _this.configure(); // Configure the events\n\n\n _this.configureEvents(); // Configure the parent\n\n\n _this.configureParent(); // Set the flag\n\n\n _this._initFl = true;\n return _this;\n } // Configures the list box\n\n\n _ListBox.prototype.configure = function () {\n this._elLabel = this.el.querySelector(\"label\");\n this._elSearchBox = this.el.querySelector(\"input\");\n this._elDatalist = this.el.querySelector(\"datalist\");\n this._elValues = this.el.querySelector(\"ul\"); // See if the placeholder exists\n\n if (this.props.placeholder) {\n // Update the placeholder\n this._elSearchBox ? this._elSearchBox.placeholder = this.props.placeholder : null;\n } // See if the id is set\n\n\n if (this.props.id) {\n // Update the ids\n this.el.id = this.props.id;\n this._elLabel ? this._elLabel.setAttribute(\"for\", this.props.id + \"-search\") : null;\n this._elSearchBox ? this._elSearchBox.id = this.props.id + \"-search\" : null;\n this._elSearchBox ? this._elSearchBox.setAttribute(\"list\", this.props.id + \"-list\") : null;\n this._elDatalist ? this._elDatalist.id = this.props.id + \"-list\" : null;\n } // See if the label exists\n\n\n if (this._elLabel) {\n if (this.props.label) {\n this._elLabel.innerHTML = this.props.label;\n } else {\n // Remove the label\n this.el.removeChild(this._elLabel);\n }\n } // See if this is read-only\n\n\n if (this.props.isReadonly) {\n // Disable the search box\n this._elSearchBox ? this._elSearchBox.disabled = true : null;\n } // Set the options\n\n\n this.setOptions(this.props.items); // Set the value if it's been defined\n\n if (this.props.value != undefined) {\n this.setValue(this.props.value);\n }\n }; // Configures the events\n\n\n _ListBox.prototype.configureEvents = function () {\n var _this = this; // Execute the load event\n\n\n var returnVal = this.props.onLoadData ? this.props.onLoadData() : null;\n\n if (returnVal) {\n // See if a promise was returned\n if (typeof returnVal.then === \"function\") {\n // Wait for the promise to complete\n returnVal.then(function (items) {\n // Set the options\n _this.setOptions(items); // Set the value if it's been defined\n\n\n if (_this.props.value != undefined) {\n _this.setValue(_this.props.value);\n }\n });\n } else {\n // Set the options\n this.setOptions(returnVal); // Set the value if it's been defined\n\n if (this.props.value != undefined) {\n this.setValue(this.props.value);\n }\n }\n } // Set the change event on the search box\n\n\n this._elSearchBox.addEventListener(\"input\", function (ev) {\n var value = _this._elSearchBox.value; // Parse the items\n\n for (var i = 0; i < _this._items.length; i++) {\n var item = _this._items[i]; // See if this is the target item\n\n if (item.text == value) {\n // See if this is a multi-select\n if (_this.props.multi) {\n var existsFl = false; // Parse the selected items\n\n for (var j = 0; j < _this._selectedItems.length; j++) {\n var selectedItem = _this._selectedItems[j]; // See if this item is already selected\n\n if (selectedItem.text == item.text) {\n // Set the flag\n existsFl = true;\n break;\n }\n } // Ensure the item wasn't already selected\n\n\n if (!existsFl) {\n // Set the value\n _this.setValue(_this._selectedItems.concat(item).sort(function (a, b) {\n if (a.text < b.text) {\n return -1;\n }\n\n if (a.text > b.text) {\n return 1;\n }\n\n return 0;\n })); // Call the change event\n\n\n _this.props.onChange ? _this.props.onChange(_this._selectedItems, ev) : null;\n }\n } else {\n // Set the value\n _this.setValue(value); // Call the change event\n\n\n _this.props.onChange ? _this.props.onChange(_this._selectedItems, ev) : null;\n } // Clear the selected value\n\n\n _this._elSearchBox.value = \"\"; // Bug - Edge (non-chromium)\n // The menu is still visible, so we fill force a \"blur\" to hide the menu after selection\n\n _this._elSearchBox.blur();\n }\n }\n });\n }; // Method to configure the item event\n\n\n _ListBox.prototype.configureItemEvent = function (elRemove, elItem, item) {\n var _this = this; // Ensure the remove element exists\n\n\n if (elRemove) {\n // Add a click event to the badge\n var badge = elItem.querySelector(\".badge\");\n\n if (badge) {\n badge.addEventListener(\"click\", function (ev) {\n // Remove the item\n _this._elValues.removeChild(elItem); // Find the selected item\n\n\n for (var i = 0; i < _this._selectedItems.length; i++) {\n var selectedItem = _this._selectedItems[i]; // See if this is the target item\n\n if (selectedItem.text == item.text) {\n // Remove this item\n _this._selectedItems.splice(i, 1); // Call the change event\n\n\n _this.props.onChange ? _this.props.onChange(_this._selectedItems, ev) : null;\n break;\n }\n }\n });\n }\n }\n };\n /**\r\n * Public Interface\r\n */\n // Gets the selected items\n\n\n _ListBox.prototype.getValue = function () {\n return this._selectedItems;\n }; // Sets the options\n\n\n _ListBox.prototype.setOptions = function (items) {\n if (items === void 0) {\n items = [];\n }\n\n var elDatalist = this.el.querySelector(\"datalist\");\n\n if (elDatalist) {\n // Save a reference to the items\n this._items = items; // Clear the options\n\n while (elDatalist.firstChild) {\n elDatalist.removeChild(elDatalist.firstChild);\n } // Clear the value\n\n\n this._elSearchBox.value = \"\";\n this._selectedItems = []; // Parse the items\n\n for (var i = 0; i < items.length; i++) {\n var props = items[i]; // Add the option\n\n var elOption = document.createElement(\"option\");\n elOption.value = props.text;\n elDatalist.appendChild(elOption); // See if the item is selected\n\n if (props.isSelected) {\n // Add the selected item\n this._selectedItems.push(props);\n }\n } // See if items are selected\n\n\n if (this._selectedItems.length > 0) {\n // Set the value\n this.setValue(this._selectedItems);\n }\n }\n }; // Set the value\n\n\n _ListBox.prototype.setValue = function (value) {\n // Clear the items\n this._selectedItems = [];\n\n while (this._elValues.firstChild) {\n this._elValues.removeChild(this._elValues.firstChild);\n } // Parse the values\n\n\n if (value) {\n // Ensure this is an array\n var values = typeof value === \"string\" || typeof value === \"number\" ? [value] : value; // Parse the values\n\n for (var i = 0; i < values.length; i++) {\n var itemValue = values[i];\n itemValue = typeof itemValue === \"string\" || typeof itemValue === \"number\" ? itemValue : itemValue.text; // Parse the items\n\n for (var j = 0; j < this._items.length; j++) {\n var item = this._items[j]; // See if this is the target item\n\n if (item.text == itemValue || item.value == itemValue) {\n // Add the selected item\n this._selectedItems.push(item); // Create the list item\n\n\n var elItem = document.createElement(\"div\");\n elItem.innerHTML = templates_1.HTMLItem;\n elItem = elItem.firstChild;\n\n this._elValues.appendChild(elItem); // Set the text value\n\n\n var elRemove = elItem.querySelector(\"span\");\n\n if (elRemove) {\n var text = document.createTextNode(item.text);\n elItem.insertBefore(text, elRemove);\n } // See if this is read-only\n\n\n if (this.props.isReadonly) {\n // Delete the \"remove\" button\n elItem.removeChild(elRemove);\n elRemove = null;\n } // Configure the event for this item\n\n\n this.configureItemEvent(elRemove, elItem, item); // Break from the loop\n\n break;\n }\n }\n }\n } // See if a change event exists\n\n\n if (this._initFl && this.props.onChange) {\n // Execute the change event\n this.props.onChange(this.getValue());\n }\n };\n\n return _ListBox;\n}(base_1.Base);\n\nexports.ListBox = function (props, template) {\n return new _ListBox(props, template);\n};\n\n//# sourceURL=webpack://gd-bs/./build/components/listBox/index.js?");
|
|
1174
1174
|
|
|
1175
1175
|
/***/ }),
|
|
1176
1176
|
|
|
@@ -1247,7 +1247,7 @@ eval("\n\nObject.defineProperty(exports, \"__esModule\", ({\n value: true\n}));
|
|
|
1247
1247
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
1248
1248
|
|
|
1249
1249
|
"use strict";
|
|
1250
|
-
eval("\n\nvar __extends = this && this.__extends || function () {\n var _extendStatics = function extendStatics(d, b) {\n _extendStatics = Object.setPrototypeOf || {\n __proto__: []\n } instanceof Array && function (d, b) {\n d.__proto__ = b;\n } || function (d, b) {\n for (var p in b) {\n if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];\n }\n };\n\n return _extendStatics(d, b);\n };\n\n return function (d, b) {\n _extendStatics(d, b);\n\n function __() {\n this.constructor = d;\n }\n\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n}();\n\nObject.defineProperty(exports, \"__esModule\", ({\n value: true\n}));\nexports.Nav = void 0;\n\nvar base_1 = __webpack_require__(/*! ../base */ \"./build/components/base.js\");\n\nvar link_1 = __webpack_require__(/*! ./link */ \"./build/components/nav/link.js\");\n\nvar templates_1 = __webpack_require__(/*! ./templates */ \"./build/components/nav/templates.js\");\n/**\r\n * Navigation\r\n * @param props - The navigation properties.\r\n */\n\n\nvar _Nav = function (_super) {\n __extends(_Nav, _super); // Constructor\n\n\n function _Nav(props, template, itemTemplate) {\n if (template === void 0) {\n template = props.isTabs ? props.isVertical ? templates_1.HTMLVerticalTabs : templates_1.HTMLTabs : templates_1.HTML;\n }\n\n var _this = _super.call(this, template, props) || this;\n\n _this._links = null; // Configure the collapse\n\n _this.configure(itemTemplate); // Configure the parent\n\n\n _this.configureParent();\n\n return _this;\n } // Configure the card group\n\n\n _Nav.prototype.configure = function (itemTemplate) {\n // Update the navigation\n var nav = this.el.querySelector(\".nav\");\n\n if (nav) {\n this.props.id ? nav.id = this.props.id : null;\n this.props.enableFill ? this.el.classList.add(\"nav-fill\") : null;\n this.props.isJustified ? this.el.classList.add(\"nav-justified\") : null;\n this.props.isPills ? this.el.classList.add(\"nav-pills\") : null;\n this.props.isTabs ? this.el.classList.add(\"nav-tabs\") : null;\n this.props.isVertical ? this.el.classList.add(\"flex-column\") : null;\n } // Render the nav links\n\n\n this.renderItems(itemTemplate);\n }; // Configures the link event\n\n\n _Nav.prototype.configureEvents = function (tab) {\n var _this = this; // Add a click event\n\n\n tab.el.addEventListener(\"click\", function () {\n var prevTab = null;\n var newTab = tab; // Parse the links\n\n for (var i = 0; i < _this._links.length; i++) {\n var link = _this._links[i]; // See if it's active\n\n if (link.isActive) {\n // Set the old tab\n prevTab = link; // Toggle it\n\n link.toggle(_this.props.fadeTabs);\n }\n } // Toggle the link\n\n\n tab.toggle(_this.props.fadeTabs); // Call the click event\n\n _this.props.onClick ? _this.props.onClick(newTab, prevTab) : null;\n });\n }; // Renders the links\n\n\n _Nav.prototype.renderItems = function (itemTemplate) {\n // Clear the links\n this._links = []; // Get the nav and tab elements\n\n var nav = this.el.querySelector(\".nav\") || this.el;\n\n if (nav) {\n var tabs = this.el.querySelector(\".tab-content\"); // Parse the navigation items\n\n var links = this.props.items || [];\n\n for (var i = 0; i < links.length; i++) {\n // Create the link\n var link = new link_1.NavLink(links[i], tabs ? true : false, itemTemplate);\n nav.appendChild(link.el);\n\n this._links.push(link); // See if we are rendering tabs\n\n\n if (tabs) {\n // Configure the events\n this.configureEvents(link); // Add the tab content\n\n tabs.appendChild(link.
|
|
1250
|
+
eval("\n\nvar __extends = this && this.__extends || function () {\n var _extendStatics = function extendStatics(d, b) {\n _extendStatics = Object.setPrototypeOf || {\n __proto__: []\n } instanceof Array && function (d, b) {\n d.__proto__ = b;\n } || function (d, b) {\n for (var p in b) {\n if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];\n }\n };\n\n return _extendStatics(d, b);\n };\n\n return function (d, b) {\n _extendStatics(d, b);\n\n function __() {\n this.constructor = d;\n }\n\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n}();\n\nObject.defineProperty(exports, \"__esModule\", ({\n value: true\n}));\nexports.Nav = void 0;\n\nvar base_1 = __webpack_require__(/*! ../base */ \"./build/components/base.js\");\n\nvar link_1 = __webpack_require__(/*! ./link */ \"./build/components/nav/link.js\");\n\nvar templates_1 = __webpack_require__(/*! ./templates */ \"./build/components/nav/templates.js\");\n/**\r\n * Navigation\r\n * @param props - The navigation properties.\r\n */\n\n\nvar _Nav = function (_super) {\n __extends(_Nav, _super); // Constructor\n\n\n function _Nav(props, template, itemTemplate) {\n if (template === void 0) {\n template = props.isTabs ? props.isVertical ? templates_1.HTMLVerticalTabs : templates_1.HTMLTabs : templates_1.HTML;\n }\n\n var _this = _super.call(this, template, props) || this;\n\n _this._links = null; // Configure the collapse\n\n _this.configure(itemTemplate); // Configure the parent\n\n\n _this.configureParent();\n\n return _this;\n } // Configure the card group\n\n\n _Nav.prototype.configure = function (itemTemplate) {\n // Update the navigation\n var nav = this.el.querySelector(\".nav\");\n\n if (nav) {\n this.props.id ? nav.id = this.props.id : null;\n this.props.enableFill ? this.el.classList.add(\"nav-fill\") : null;\n this.props.isJustified ? this.el.classList.add(\"nav-justified\") : null;\n this.props.isPills ? this.el.classList.add(\"nav-pills\") : null;\n this.props.isTabs ? this.el.classList.add(\"nav-tabs\") : null;\n this.props.isVertical ? this.el.classList.add(\"flex-column\") : null;\n } // Render the nav links\n\n\n this.renderItems(itemTemplate);\n }; // Configures the link event\n\n\n _Nav.prototype.configureEvents = function (tab) {\n var _this = this; // Add a click event\n\n\n tab.el.addEventListener(\"click\", function () {\n var prevTab = null;\n var newTab = tab; // Parse the links\n\n for (var i = 0; i < _this._links.length; i++) {\n var link = _this._links[i]; // See if it's active\n\n if (link.isActive) {\n // Set the old tab\n prevTab = link; // Toggle it\n\n link.toggle(_this.props.fadeTabs);\n }\n } // Toggle the link\n\n\n tab.toggle(_this.props.fadeTabs); // Call the click event\n\n _this.props.onClick ? _this.props.onClick(newTab, prevTab) : null;\n });\n }; // Renders the links\n\n\n _Nav.prototype.renderItems = function (itemTemplate) {\n // Clear the links\n this._links = []; // Get the nav and tab elements\n\n var nav = this.el.querySelector(\".nav\") || this.el;\n\n if (nav) {\n var tabs = this.el.querySelector(\".tab-content\"); // Parse the navigation items\n\n var links = this.props.items || [];\n\n for (var i = 0; i < links.length; i++) {\n // Create the link\n var link = new link_1.NavLink(links[i], tabs ? true : false, itemTemplate);\n nav.appendChild(link.el);\n\n this._links.push(link); // See if we are rendering tabs\n\n\n if (tabs) {\n // Configure the events\n this.configureEvents(link); // Add the tab content\n\n tabs.appendChild(link.elTabContent); // See if the fade option is enabled\n\n if (this.props.fadeTabs) {\n // Set the class name\n link.elTabContent.classList.add(\"fade\"); // See if the tab is active\n\n if (link.props.isActive) {\n // Set the class name\n link.elTabContent.classList.add(\"show\");\n }\n }\n } // Call the render events\n\n\n this.props.onLinkRendered ? this.props.onLinkRendered(link.elTab, links[i]) : null;\n this.props.onTabRendered ? this.props.onTabRendered(link.elTabContent, links[i]) : null;\n }\n }\n };\n\n Object.defineProperty(_Nav.prototype, \"activeTab\", {\n /**\r\n * Public Interface\r\n */\n // The active tab\n get: function get() {\n // Parse the links\n for (var i = 0; i < this._links.length; i++) {\n var link = this._links[i]; // See if it's active\n\n if (link.isActive) {\n // Return the link\n return link;\n }\n } // Active tab not found\n\n\n return null;\n },\n enumerable: false,\n configurable: true\n }); // Shows a tab\n\n _Nav.prototype.showTab = function (tabId) {\n // Ensure tabs exist\n if (this.props.isTabs) {\n // Parse the tabs\n for (var i = 0; i < this._links.length; i++) {\n var link = this._links[i]; // See if this is the target tab\n\n if (tabId === i + 1 || link.elTabContent.getAttribute(\"data-title\") == tabId) {\n // Toggle it if it's not active\n link.isActive ? null : link.toggle(this.props.fadeTabs);\n } // Else, see if it's active\n else if (link.isActive) {\n // Toggle it\n link.toggle(this.props.fadeTabs);\n }\n }\n }\n };\n\n return _Nav;\n}(base_1.Base);\n\nexports.Nav = function (props, template, itemTemplate) {\n return new _Nav(props, template, itemTemplate);\n};\n\n//# sourceURL=webpack://gd-bs/./build/components/nav/index.js?");
|
|
1251
1251
|
|
|
1252
1252
|
/***/ }),
|
|
1253
1253
|
|