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.
package/index.html CHANGED
@@ -1166,7 +1166,7 @@
1166
1166
  imageUrl: "https://via.placeholder.com/400x200",
1167
1167
  imageAlt: "First Slide",
1168
1168
  isActive: true
1169
- }, {
1169
+ }/*, {
1170
1170
  captions: "<h5>Second Slide</h5>",
1171
1171
  imageUrl: "https://via.placeholder.com/400x200",
1172
1172
  imageAlt: "Second Slide"
@@ -1176,7 +1176,7 @@
1176
1176
  imageAlt: "Third Slide"
1177
1177
  }, {
1178
1178
  content: "<h1>Header</h1><h3>Title</h3><p>Content</p>"
1179
- }]
1179
+ }*/]
1180
1180
  });
1181
1181
  window["collapse"] = GD.Components.Collapse({
1182
1182
  el: document.querySelector("#collapse"),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gd-bs",
3
- "version": "6.1.6",
3
+ "version": "6.1.7",
4
4
  "description": "Bootstrap JavaScript, TypeScript and Web Components library.",
5
5
  "main": "build/index.js",
6
6
  "typings": "src/index.d.ts",
@@ -31,7 +31,7 @@ class _Carousel extends Base<ICarouselProps> implements ICarousel {
31
31
  // Configure the card group
32
32
  private configure(slideTemplate: string) {
33
33
  // Set the attributes
34
- this.el.id = "carousel" + (this.props.id == null ? "" : this.props.id);
34
+ this.el.id = this.props.id == null ? "carousel" : this.props.id;
35
35
  this.props.enableCrossfade ? this.el.classList.add("carousel-fade") : null;
36
36
 
37
37
  // Render the indicators
@@ -182,8 +182,9 @@ class _Carousel extends Base<ICarouselProps> implements ICarousel {
182
182
  let item = items[i];
183
183
 
184
184
  // Create the item
185
- let elItem = document.createElement("li");
185
+ let elItem = document.createElement("button");
186
186
  elItem.setAttribute("data-bs-target", "#" + this.el.id);
187
+ elItem.setAttribute("aria-label", "Slide " + (i + 1));
187
188
  elItem.setAttribute("data-bs-slide-to", i.toString());
188
189
  item.isActive ? elItem.classList.add("active") : null;
189
190
  elItem.addEventListener("click", ev => {
@@ -194,7 +195,7 @@ class _Carousel extends Base<ICarouselProps> implements ICarousel {
194
195
 
195
196
  // Go to the slide
196
197
  this.nextWhenVisible(elSlide.getAttribute("data-bs-slide-to"));
197
- })
198
+ });
198
199
 
199
200
  // Add the item
200
201
  indicators.appendChild(elItem);
@@ -215,18 +216,30 @@ class _Carousel extends Base<ICarouselProps> implements ICarousel {
215
216
  // Get the indicators
216
217
  let slides = this.el.querySelector(".carousel-inner");
217
218
  if (slides) {
219
+ let hasActiveItem = false;
220
+
218
221
  // Parse the items
219
222
  let items = this.props.items || [];
220
223
  for (let i = 0; i < items.length; i++) {
221
224
  let slide = new CarouselItem(items[i], slideTemplate);
222
225
  this._slides.push(slide);
223
226
 
227
+ // See if this is active
228
+ slide.isActive ? hasActiveItem = true : null;
229
+
224
230
  // Create the item element
225
231
  slides.appendChild(slide.el);
226
232
 
227
233
  // Call the event
228
234
  this.props.onSlideRendered ? this.props.onSlideRendered(slide.el, items[i]) : null;
229
235
  }
236
+
237
+ // See if it doesn't have an active item
238
+ if (!hasActiveItem) {
239
+ // Set the first as active
240
+ let firstSlide = this._slides[0];
241
+ firstSlide ? firstSlide.el.classList.add("active") : null;
242
+ }
230
243
  }
231
244
  }
232
245
 
@@ -265,6 +278,9 @@ class _Carousel extends Base<ICarouselProps> implements ICarousel {
265
278
  let nextSlide: CarouselItem = null;
266
279
  let options = this.props.options || {};
267
280
 
281
+ // Ensure there are multiple slides
282
+ if (this._slides.length < 2) { return; }
283
+
268
284
  // Parse the slides
269
285
  for (let i = 0; i < this._slides.length; i++) {
270
286
  let slide = this._slides[i];
@@ -281,8 +297,10 @@ class _Carousel extends Base<ICarouselProps> implements ICarousel {
281
297
  nextSlide = this._slides[i + 1] || this._slides[0];
282
298
 
283
299
  // Update the indicators
284
- this._indicators[i].classList.remove("active");
285
- (this._indicators[i + 1] || this._indicators[0]).classList.add("active");
300
+ let indicator = this._indicators[i];
301
+ indicator ? indicator.classList.remove("active") : null;
302
+ let nextIndicator = this._indicators[i + 1] || this._indicators[0];
303
+ nextIndicator ? nextIndicator.classList.add("active") : null;
286
304
  break;
287
305
  }
288
306
  }
@@ -297,6 +315,9 @@ class _Carousel extends Base<ICarouselProps> implements ICarousel {
297
315
  let nextSlide: CarouselItem = this._slides[idx];
298
316
  let slideRight = true;
299
317
 
318
+ // Ensure there are multiple slides
319
+ if (this._slides.length < 2) { return; }
320
+
300
321
  // Parse the slides
301
322
  for (let i = 0; i < this._slides.length; i++) {
302
323
  let slide = this._slides[i];
@@ -313,8 +334,10 @@ class _Carousel extends Base<ICarouselProps> implements ICarousel {
313
334
  currentSlide = slide;
314
335
 
315
336
  // Update the indicators
316
- this._indicators[i].classList.remove("active");
317
- this._indicators[idx].classList.add("active");
337
+ let indicator = this._indicators[i];
338
+ indicator ? indicator.classList.remove("active") : null;
339
+ let nextIndicator = this._indicators[idx];
340
+ nextIndicator ? nextIndicator.classList.add("active") : null;
318
341
  break;
319
342
  }
320
343
  }
@@ -335,6 +358,9 @@ class _Carousel extends Base<ICarouselProps> implements ICarousel {
335
358
  let options = this.props.options || {};
336
359
  let prevSlide: CarouselItem = null;
337
360
 
361
+ // Ensure there are multiple slides
362
+ if (this._slides.length < 2) { return; }
363
+
338
364
  // Parse the slides
339
365
  for (let i = 0; i < this._slides.length; i++) {
340
366
  let slide = this._slides[i];
@@ -1,5 +1,5 @@
1
1
  import { ICarouselItem } from "./types";
2
- import { appendContent } from "../common";
2
+ import { appendContent, setClassNames } from "../common";
3
3
  import { HTMLItem } from "./templates";
4
4
 
5
5
  /**
@@ -25,6 +25,9 @@ export class CarouselItem {
25
25
 
26
26
  // Configure the item
27
27
  private configure() {
28
+ // Set the class names
29
+ setClassNames(this._el, this._props.className);
30
+
28
31
  // Set the attributes
29
32
  this._props.isActive ? this._el.classList.add("active") : null;
30
33
 
@@ -1,7 +1,7 @@
1
1
  // Carousel
2
2
  export const HTML = `
3
3
  <div class="carousel slide" data-bs-ride="carousel">
4
- <ol class="carousel-indicators"></ol>
4
+ <div class="carousel-indicators"></div>
5
5
  <div class="carousel-inner"></div>
6
6
  <a class="carousel-control-prev" href="#" role="button" data-bs-slide="prev">
7
7
  <span class="carousel-control-prev-icon" aria-hidden="true"></span>
@@ -5,7 +5,7 @@ export const HTML = `<form class="needs-validation"></form>`;
5
5
  export const HTMLGroup = `
6
6
  <div>
7
7
  <label class="form-label" tabindex="-1"></label>
8
- <small class="form-text text-muted" tabindex="-1"></small>
8
+ <small class="form-text" tabindex="-1"></small>
9
9
  </div>`.trim();
10
10
 
11
11
  // Row
@@ -4,10 +4,10 @@ export const HTML = `
4
4
  <div class="modal-content">
5
5
  <div class="modal-header">
6
6
  <div class="modal-title fs-5"></div>
7
- <button type="button" class="btn-close" data-bs-dismiss="modal" area-label="Close"></button>
7
+ <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
8
8
  </div>
9
9
  <div class="modal-body"></div>
10
10
  <div class="modal-footer"></div>
11
11
  </div>
12
12
  </div>
13
- </div>`.trim();
13
+ </div>`.trim();