gd-bs 6.1.5 → 6.1.6

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.
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.IconLink = exports.IconLinkTypes = void 0;
19
+ var base_1 = require("../base");
20
+ var common_1 = require("../common");
21
+ var templates_1 = require("./templates");
22
+ /**
23
+ * Icon Link Types
24
+ */
25
+ var IconLinkTypes;
26
+ (function (IconLinkTypes) {
27
+ IconLinkTypes[IconLinkTypes["AfterText"] = 1] = "AfterText";
28
+ IconLinkTypes[IconLinkTypes["BeforeText"] = 2] = "BeforeText";
29
+ })(IconLinkTypes = exports.IconLinkTypes || (exports.IconLinkTypes = {}));
30
+ /**
31
+ * Icon Link
32
+ * @property props - The list box properties.
33
+ */
34
+ var _IconLink = /** @class */ (function (_super) {
35
+ __extends(_IconLink, _super);
36
+ // Constructor
37
+ function _IconLink(props, template) {
38
+ if (template === void 0) { template = templates_1.HTML; }
39
+ var _this = _super.call(this, template, props) || this;
40
+ _this._elIcon = null;
41
+ // Configure the list box
42
+ _this.configure();
43
+ // Configure the events
44
+ _this.configureEvents();
45
+ // Configure the parent
46
+ _this.configureParent();
47
+ return _this;
48
+ }
49
+ // Configures the list box
50
+ _IconLink.prototype.configure = function () {
51
+ // Render the content
52
+ (0, common_1.appendContent)(this.el, this.props.content);
53
+ // Set the icon if it exists
54
+ if (this.props.iconType) {
55
+ if (typeof (this.props.iconType) === "function") {
56
+ // Set the icon
57
+ this._elIcon = this.props.iconType(this.props.iconSize, this.props.iconSize, this.props.iconClassName);
58
+ }
59
+ // Else, it's an element
60
+ else if (typeof (this.props.iconType === "object")) {
61
+ // Set the icon
62
+ this._elIcon = this.props.iconType;
63
+ }
64
+ else {
65
+ return;
66
+ }
67
+ // See if we are rendering the content first
68
+ if (this.props.type == IconLinkTypes.AfterText) {
69
+ // Append the icon
70
+ this.el.appendChild(this._elIcon);
71
+ }
72
+ else {
73
+ // Prepend the icon
74
+ this.el.prepend(this._elIcon);
75
+ }
76
+ }
77
+ };
78
+ // Configures the events
79
+ _IconLink.prototype.configureEvents = function () {
80
+ };
81
+ return _IconLink;
82
+ }(base_1.Base));
83
+ var IconLink = function (props, template) { return new _IconLink(props, template); };
84
+ exports.IconLink = IconLink;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HTML = void 0;
4
+ // Form
5
+ exports.HTML = "<a class=\"icon-link\" href=\"#\"></a>".trim();
@@ -27,6 +27,7 @@ __exportStar(require("./checkboxGroup"), exports);
27
27
  __exportStar(require("./collapse"), exports);
28
28
  __exportStar(require("./dropdown"), exports);
29
29
  __exportStar(require("./form"), exports);
30
+ __exportStar(require("./iconLink"), exports);
30
31
  __exportStar(require("./inputGroup"), exports);
31
32
  __exportStar(require("./jumbotron"), exports);
32
33
  __exportStar(require("./listBox"), exports);
@@ -41,13 +41,14 @@ var _Nav = /** @class */ (function (_super) {
41
41
  // Configure the card group
42
42
  _Nav.prototype.configure = function (itemTemplate) {
43
43
  // Update the navigation
44
- var nav = this.el.querySelector(".nav");
44
+ var nav = this.el.classList.contains("nav") ? this.el : this.el.querySelector(".nav");
45
45
  if (nav) {
46
46
  this.props.id ? nav.id = this.props.id : null;
47
47
  this.props.enableFill ? this.el.classList.add("nav-fill") : null;
48
48
  this.props.isJustified ? this.el.classList.add("nav-justified") : null;
49
49
  this.props.isPills ? this.el.classList.add("nav-pills") : null;
50
50
  this.props.isTabs ? this.el.classList.add("nav-tabs") : null;
51
+ this.props.isUnderline ? this.el.classList.add("nav-underline") : null;
51
52
  this.props.isVertical ? this.el.classList.add("flex-column") : null;
52
53
  }
53
54
  // Render the nav links
@@ -59,25 +60,25 @@ var _Nav = /** @class */ (function (_super) {
59
60
  this.props.onRendered ? this.props.onRendered(this.el) : null;
60
61
  };
61
62
  // Configures the tab link event
62
- _Nav.prototype.configureTabEvents = function (tab) {
63
+ _Nav.prototype.configureLinkEvents = function (link) {
63
64
  var _this = this;
64
65
  // Add a click event
65
- tab.el.addEventListener("click", function () {
66
+ link.el.addEventListener("click", function () {
66
67
  var prevTab = null;
67
- var newTab = tab;
68
+ var newTab = link;
68
69
  // Parse the links
69
70
  for (var i = 0; i < _this._links.length; i++) {
70
- var link = _this._links[i];
71
+ var link_2 = _this._links[i];
71
72
  // See if it's active
72
- if (link.isActive) {
73
+ if (link_2.isActive) {
73
74
  // Set the old tab
74
- prevTab = link;
75
+ prevTab = link_2;
75
76
  // Toggle it
76
- link.toggle(_this.props.fadeTabs);
77
+ link_2.toggle(_this.props.fadeTabs);
77
78
  }
78
79
  }
79
80
  // Toggle the link
80
- tab.toggle(_this.props.fadeTabs);
81
+ link.toggle(_this.props.fadeTabs);
81
82
  // Call the click event
82
83
  _this.props.onClick ? _this.props.onClick(newTab, prevTab) : null;
83
84
  });
@@ -87,7 +88,7 @@ var _Nav = /** @class */ (function (_super) {
87
88
  // Clear the links
88
89
  this._links = [];
89
90
  // Get the nav and tab elements
90
- var nav = this.el.querySelector(".nav") || this.el;
91
+ var nav = this.el.classList.contains("nav") ? this.el : this.el.querySelector(".nav");
91
92
  if (nav) {
92
93
  var tabs = this.el.querySelector(".tab-content");
93
94
  // Parse the navigation items
@@ -97,10 +98,10 @@ var _Nav = /** @class */ (function (_super) {
97
98
  var link = new link_1.NavLink(links[i], tabs ? true : false, itemTemplate);
98
99
  nav.appendChild(link.el);
99
100
  this._links.push(link);
101
+ // Configure the link event
102
+ this.configureLinkEvents(link);
100
103
  // See if we are rendering tabs
101
104
  if (tabs) {
102
- // Configure the events
103
- this.configureTabEvents(link);
104
105
  // Add the tab content
105
106
  tabs.appendChild(link.elTabContent);
106
107
  // See if the fade option is enabled
@@ -129,14 +129,14 @@ var NavLink = /** @class */ (function (_super) {
129
129
  if (this.isActive) {
130
130
  // Hide this link and tab
131
131
  this._elLink.classList.remove("active");
132
- this._elTab.classList.remove("active");
133
- this._elTab.classList.remove("show");
132
+ this._elTab ? this._elTab.classList.remove("active") : null;
133
+ this._elTab ? this._elTab.classList.remove("show") : null;
134
134
  }
135
135
  else {
136
136
  // Show this link and tab
137
137
  this._elLink.classList.add("active");
138
- this._elTab.classList.add("active");
139
- fadeTabs ? this._elTab.classList.add("show") : null;
138
+ this._elTab ? this._elTab.classList.add("active") : null;
139
+ this._elTab && fadeTabs ? this._elTab.classList.add("show") : null;
140
140
  }
141
141
  };
142
142
  return NavLink;