gd-bs 6.1.5 → 6.1.7

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.
@@ -45,7 +45,7 @@ var _Carousel = /** @class */ (function (_super) {
45
45
  // Configure the card group
46
46
  _Carousel.prototype.configure = function (slideTemplate) {
47
47
  // Set the attributes
48
- this.el.id = "carousel" + (this.props.id == null ? "" : this.props.id);
48
+ this.el.id = this.props.id == null ? "carousel" : this.props.id;
49
49
  this.props.enableCrossfade ? this.el.classList.add("carousel-fade") : null;
50
50
  // Render the indicators
51
51
  this.renderIndicators();
@@ -181,8 +181,9 @@ var _Carousel = /** @class */ (function (_super) {
181
181
  for (var i = 0; i < items.length; i++) {
182
182
  var item = items[i];
183
183
  // Create the item
184
- var elItem = document.createElement("li");
184
+ var elItem = document.createElement("button");
185
185
  elItem.setAttribute("data-bs-target", "#" + this.el.id);
186
+ elItem.setAttribute("aria-label", "Slide " + (i + 1));
186
187
  elItem.setAttribute("data-bs-slide-to", i.toString());
187
188
  item.isActive ? elItem.classList.add("active") : null;
188
189
  elItem.addEventListener("click", function (ev) {
@@ -210,16 +211,25 @@ var _Carousel = /** @class */ (function (_super) {
210
211
  // Get the indicators
211
212
  var slides = this.el.querySelector(".carousel-inner");
212
213
  if (slides) {
214
+ var hasActiveItem = false;
213
215
  // Parse the items
214
216
  var items = this.props.items || [];
215
217
  for (var i = 0; i < items.length; i++) {
216
218
  var slide = new item_1.CarouselItem(items[i], slideTemplate);
217
219
  this._slides.push(slide);
220
+ // See if this is active
221
+ slide.isActive ? hasActiveItem = true : null;
218
222
  // Create the item element
219
223
  slides.appendChild(slide.el);
220
224
  // Call the event
221
225
  this.props.onSlideRendered ? this.props.onSlideRendered(slide.el, items[i]) : null;
222
226
  }
227
+ // See if it doesn't have an active item
228
+ if (!hasActiveItem) {
229
+ // Set the first as active
230
+ var firstSlide = this._slides[0];
231
+ firstSlide ? firstSlide.el.classList.add("active") : null;
232
+ }
223
233
  }
224
234
  };
225
235
  // Starts to move automatically
@@ -257,6 +267,10 @@ var _Carousel = /** @class */ (function (_super) {
257
267
  var currentSlide = null;
258
268
  var nextSlide = null;
259
269
  var options = this.props.options || {};
270
+ // Ensure there are multiple slides
271
+ if (this._slides.length < 2) {
272
+ return;
273
+ }
260
274
  // Parse the slides
261
275
  for (var i = 0; i < this._slides.length; i++) {
262
276
  var slide = this._slides[i];
@@ -270,8 +284,10 @@ var _Carousel = /** @class */ (function (_super) {
270
284
  currentSlide = slide;
271
285
  nextSlide = this._slides[i + 1] || this._slides[0];
272
286
  // Update the indicators
273
- this._indicators[i].classList.remove("active");
274
- (this._indicators[i + 1] || this._indicators[0]).classList.add("active");
287
+ var indicator = this._indicators[i];
288
+ indicator ? indicator.classList.remove("active") : null;
289
+ var nextIndicator = this._indicators[i + 1] || this._indicators[0];
290
+ nextIndicator ? nextIndicator.classList.add("active") : null;
275
291
  break;
276
292
  }
277
293
  }
@@ -283,6 +299,10 @@ var _Carousel = /** @class */ (function (_super) {
283
299
  var currentSlide = null;
284
300
  var nextSlide = this._slides[idx];
285
301
  var slideRight = true;
302
+ // Ensure there are multiple slides
303
+ if (this._slides.length < 2) {
304
+ return;
305
+ }
286
306
  // Parse the slides
287
307
  for (var i = 0; i < this._slides.length; i++) {
288
308
  var slide = this._slides[i];
@@ -297,8 +317,10 @@ var _Carousel = /** @class */ (function (_super) {
297
317
  // Set the current slide
298
318
  currentSlide = slide;
299
319
  // Update the indicators
300
- this._indicators[i].classList.remove("active");
301
- this._indicators[idx].classList.add("active");
320
+ var indicator = this._indicators[i];
321
+ indicator ? indicator.classList.remove("active") : null;
322
+ var nextIndicator = this._indicators[idx];
323
+ nextIndicator ? nextIndicator.classList.add("active") : null;
302
324
  break;
303
325
  }
304
326
  }
@@ -315,6 +337,10 @@ var _Carousel = /** @class */ (function (_super) {
315
337
  var currentSlide = null;
316
338
  var options = this.props.options || {};
317
339
  var prevSlide = null;
340
+ // Ensure there are multiple slides
341
+ if (this._slides.length < 2) {
342
+ return;
343
+ }
318
344
  // Parse the slides
319
345
  for (var i = 0; i < this._slides.length; i++) {
320
346
  var slide = this._slides[i];
@@ -23,6 +23,8 @@ var CarouselItem = /** @class */ (function () {
23
23
  }
24
24
  // Configure the item
25
25
  CarouselItem.prototype.configure = function () {
26
+ // Set the class names
27
+ (0, common_1.setClassNames)(this._el, this._props.className);
26
28
  // Set the attributes
27
29
  this._props.isActive ? this._el.classList.add("active") : null;
28
30
  // Get the image elements
@@ -2,6 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.HTMLItem = exports.HTML = void 0;
4
4
  // Carousel
5
- exports.HTML = "\n<div class=\"carousel slide\" data-bs-ride=\"carousel\">\n <ol class=\"carousel-indicators\"></ol>\n <div class=\"carousel-inner\"></div>\n <a class=\"carousel-control-prev\" href=\"#\" role=\"button\" data-bs-slide=\"prev\">\n <span class=\"carousel-control-prev-icon\" aria-hidden=\"true\"></span>\n <span class=\"visually-hidden\">Previous</span>\n </a>\n <a class=\"carousel-control-next\" href=\"#\" role=\"button\" data-bs-slide=\"next\">\n <span class=\"carousel-control-next-icon\" aria-hidden=\"true\"></span>\n <span class=\"visually-hidden\">Next</span>\n </a>\n</div>".trim();
5
+ exports.HTML = "\n<div class=\"carousel slide\" data-bs-ride=\"carousel\">\n <div class=\"carousel-indicators\"></div>\n <div class=\"carousel-inner\"></div>\n <a class=\"carousel-control-prev\" href=\"#\" role=\"button\" data-bs-slide=\"prev\">\n <span class=\"carousel-control-prev-icon\" aria-hidden=\"true\"></span>\n <span class=\"visually-hidden\">Previous</span>\n </a>\n <a class=\"carousel-control-next\" href=\"#\" role=\"button\" data-bs-slide=\"next\">\n <span class=\"carousel-control-next-icon\" aria-hidden=\"true\"></span>\n <span class=\"visually-hidden\">Next</span>\n </a>\n</div>".trim();
6
6
  // Carousel Item
7
7
  exports.HTMLItem = "\n<div class=\"carousel-item\">\n <img class=\"d-block w-100\" />\n <div class=\"carousel-caption\"></div>\n</div>".trim();
@@ -4,6 +4,6 @@ exports.HTMLRow = exports.HTMLGroup = exports.HTML = void 0;
4
4
  // Form
5
5
  exports.HTML = "<form class=\"needs-validation\"></form>";
6
6
  // Group
7
- exports.HTMLGroup = "\n<div>\n <label class=\"form-label\" tabindex=\"-1\"></label>\n <small class=\"form-text text-muted\" tabindex=\"-1\"></small>\n</div>".trim();
7
+ exports.HTMLGroup = "\n<div>\n <label class=\"form-label\" tabindex=\"-1\"></label>\n <small class=\"form-text\" tabindex=\"-1\"></small>\n</div>".trim();
8
8
  // Row
9
9
  exports.HTMLRow = "<div class=\"row\"></div>";
@@ -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);
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.HTML = void 0;
4
- exports.HTML = "\n<div class=\"modal\" tabindex=\"-1\" aria-hidden=\"true\">\n <div class=\"modal-dialog\">\n <div class=\"modal-content\">\n <div class=\"modal-header\">\n <div class=\"modal-title fs-5\"></div>\n <button type=\"button\" class=\"btn-close\" data-bs-dismiss=\"modal\" area-label=\"Close\"></button>\n </div>\n <div class=\"modal-body\"></div>\n <div class=\"modal-footer\"></div>\n </div>\n </div>\n</div>".trim();
4
+ exports.HTML = "\n<div class=\"modal\" tabindex=\"-1\" aria-hidden=\"true\">\n <div class=\"modal-dialog\">\n <div class=\"modal-content\">\n <div class=\"modal-header\">\n <div class=\"modal-title fs-5\"></div>\n <button type=\"button\" class=\"btn-close\" data-bs-dismiss=\"modal\" aria-label=\"Close\"></button>\n </div>\n <div class=\"modal-body\"></div>\n <div class=\"modal-footer\"></div>\n </div>\n </div>\n</div>".trim();
@@ -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;