gd-bs 6.1.6 → 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>";
@@ -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();