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.
package/index.html CHANGED
@@ -15,6 +15,7 @@
15
15
  <h1>Library</h1>
16
16
  <form>
17
17
  <div id="dev"></div>
18
+ <div id="icon-link"></div>
18
19
  <div id="alert"></div>
19
20
  <div id="btn-loading"></div>
20
21
  <div id="spinner"></div>
@@ -86,6 +87,12 @@
86
87
  });
87
88
 
88
89
  // Components
90
+ GD.Components.IconLink({
91
+ el: document.getElementById("icon-link"),
92
+ content: "Icon Link",
93
+ iconType: GD.Icons(GD.IconTypes.Badge3d),
94
+ type: GD.Components.IconLinkTypes.AfterText
95
+ })
89
96
  GD.Components.ListBox({
90
97
  el: document.getElementById("listbox"),
91
98
  label: "List Box Example:",
@@ -1020,7 +1027,7 @@
1020
1027
  type: 2,
1021
1028
  options: {
1022
1029
  autoClose: false,
1023
- backdrop: false
1030
+ backdrop: true
1024
1031
  }
1025
1032
  });
1026
1033
 
@@ -1124,8 +1131,8 @@
1124
1131
  });
1125
1132
  window["myNavTabs"] = GD.Components.Nav({
1126
1133
  el: document.querySelector("#navTabs"),
1127
- fadeTabs: true,
1128
- isTabs: true,
1134
+ //fadeTabs: true,
1135
+ isUnderline: true,
1129
1136
  items: [{
1130
1137
  title: "NavTab 1",
1131
1138
  tabContent: "This is the content for tab 1.",
@@ -1159,7 +1166,7 @@
1159
1166
  imageUrl: "https://via.placeholder.com/400x200",
1160
1167
  imageAlt: "First Slide",
1161
1168
  isActive: true
1162
- }, {
1169
+ }/*, {
1163
1170
  captions: "<h5>Second Slide</h5>",
1164
1171
  imageUrl: "https://via.placeholder.com/400x200",
1165
1172
  imageAlt: "Second Slide"
@@ -1169,7 +1176,7 @@
1169
1176
  imageAlt: "Third Slide"
1170
1177
  }, {
1171
1178
  content: "<h1>Header</h1><h3>Title</h3><p>Content</p>"
1172
- }]
1179
+ }*/]
1173
1180
  });
1174
1181
  window["collapse"] = GD.Components.Collapse({
1175
1182
  el: document.querySelector("#collapse"),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gd-bs",
3
- "version": "6.1.5",
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
@@ -0,0 +1,71 @@
1
+ import { IIconLink, IIconLinkProps } from "./types";
2
+ import { Base } from "../base";
3
+ import { appendContent } from "../common";
4
+ import { HTML } from "./templates";
5
+
6
+ /**
7
+ * Icon Link Types
8
+ */
9
+ export enum IconLinkTypes {
10
+ AfterText = 1,
11
+ BeforeText = 2
12
+ }
13
+ /**
14
+ * Icon Link
15
+ * @property props - The list box properties.
16
+ */
17
+ class _IconLink extends Base<IIconLinkProps> implements IIconLink {
18
+ private _elIcon: HTMLOrSVGElement = null;
19
+
20
+ // Constructor
21
+ constructor(props: IIconLinkProps, template: string = HTML) {
22
+ super(template, props);
23
+
24
+ // Configure the list box
25
+ this.configure();
26
+
27
+ // Configure the events
28
+ this.configureEvents();
29
+
30
+ // Configure the parent
31
+ this.configureParent();
32
+ }
33
+
34
+ // Configures the list box
35
+ private configure() {
36
+ // Render the content
37
+ appendContent(this.el, this.props.content);
38
+
39
+ // Set the icon if it exists
40
+ if (this.props.iconType) {
41
+ if (typeof (this.props.iconType) === "function") {
42
+ // Set the icon
43
+ this._elIcon = this.props.iconType(this.props.iconSize, this.props.iconSize, this.props.iconClassName);
44
+ }
45
+ // Else, it's an element
46
+ else if (typeof (this.props.iconType === "object")) {
47
+ // Set the icon
48
+ this._elIcon = this.props.iconType;
49
+ } else { return; }
50
+
51
+ // See if we are rendering the content first
52
+ if (this.props.type == IconLinkTypes.AfterText) {
53
+ // Append the icon
54
+ this.el.appendChild(this._elIcon);
55
+ } else {
56
+ // Prepend the icon
57
+ this.el.prepend(this._elIcon);
58
+ }
59
+ }
60
+ }
61
+
62
+ // Configures the events
63
+ private configureEvents() {
64
+ }
65
+
66
+ /**
67
+ * Public Interface
68
+ */
69
+
70
+ }
71
+ export const IconLink = (props: IIconLinkProps, template?: string): IIconLink => { return new _IconLink(props, template); }
@@ -0,0 +1,2 @@
1
+ // Form
2
+ export const HTML = `<a class="icon-link" href="#"></a>`.trim();
@@ -0,0 +1,68 @@
1
+ /**
2
+ * <div id="demo"></div>
3
+ * <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/gd-sprest-bs/5.0.3/gd-sprest-bs.min.js"></script>
4
+ * <script type="text/javascript">
5
+ * // Wait for the window to be loaded
6
+ * window.addEventListener("load", function() {
7
+ * // Create the icon link
8
+ * $REST.Components.IconLink({
9
+ * el: document.querySelector("#demo"),
10
+ * content: "Icon Link",
11
+ * type: $REST.Components.IconLinkTypes.BeforeIcon,
12
+ * icon: $REST.Icons($REST.IconTypes.Badge3d)
13
+ * });
14
+ * });
15
+ * </script>
16
+ */
17
+
18
+ /**
19
+ * Icon Link
20
+ *
21
+ * ```ts
22
+ * import { Components } from "gd-sprest-bs";
23
+ * import { Badge3d } from "gd-sprest-bs/build/icons/svgs/badge3d";
24
+ *
25
+ * // Create the icon link
26
+ * let el = document.querySelector("#icon-link");
27
+ * Components.IconLink({
28
+ * el: el,
29
+ * content: "Icon Link",
30
+ * iconType: Badge3d,
31
+ * type: Components.IconLinkTypes.AfterIcon,
32
+ * });
33
+ * ```
34
+ */
35
+ export const IconLink: (props: IIconLinkProps, template?: string) => IIconLink;
36
+
37
+ /**
38
+ * Icon Link Types
39
+ */
40
+ export const IconLinkTypes: IIconLinkTypes;
41
+
42
+ import { IBase, IBaseProps } from "../types";
43
+
44
+ /**
45
+ * Icon Link
46
+ */
47
+ export interface IIconLink extends IBase<IIconLinkProps> { }
48
+
49
+ /**
50
+ * Icon Link Properties
51
+ */
52
+ export interface IIconLinkProps<T = Element> extends IBaseProps<IIconLink> {
53
+ content?: string | T;
54
+ data?: any;
55
+ href?: string;
56
+ iconClassName?: string;
57
+ iconSize?: number;
58
+ iconType?: Function;
59
+ type?: number;
60
+ }
61
+
62
+ /**
63
+ * Icon Link Types
64
+ */
65
+ export type IIconLinkTypes = {
66
+ AfterText: number;
67
+ BeforeText: number;
68
+ }
@@ -11,6 +11,7 @@ export * from "./checkboxGroup";
11
11
  export * from "./collapse";
12
12
  export * from "./dropdown";
13
13
  export * from "./form";
14
+ export * from "./iconLink";
14
15
  export * from "./inputGroup";
15
16
  export * from "./jumbotron";
16
17
  export * from "./listBox";
@@ -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();
@@ -27,13 +27,14 @@ class _Nav extends Base<INavProps> implements INav {
27
27
  // Configure the card group
28
28
  private configure(itemTemplate: string) {
29
29
  // Update the navigation
30
- let nav = this.el.querySelector(".nav");
30
+ let nav = this.el.classList.contains("nav") ? this.el : this.el.querySelector(".nav");
31
31
  if (nav) {
32
32
  this.props.id ? nav.id = this.props.id : null;
33
33
  this.props.enableFill ? this.el.classList.add("nav-fill") : null;
34
34
  this.props.isJustified ? this.el.classList.add("nav-justified") : null;
35
35
  this.props.isPills ? this.el.classList.add("nav-pills") : null;
36
36
  this.props.isTabs ? this.el.classList.add("nav-tabs") : null;
37
+ this.props.isUnderline ? this.el.classList.add("nav-underline") : null;
37
38
  this.props.isVertical ? this.el.classList.add("flex-column") : null;
38
39
  }
39
40
 
@@ -48,11 +49,11 @@ class _Nav extends Base<INavProps> implements INav {
48
49
  }
49
50
 
50
51
  // Configures the tab link event
51
- private configureTabEvents(tab: NavLink) {
52
+ private configureLinkEvents(link: NavLink) {
52
53
  // Add a click event
53
- tab.el.addEventListener("click", () => {
54
+ link.el.addEventListener("click", () => {
54
55
  let prevTab: INavLink = null;
55
- let newTab: INavLink = tab;
56
+ let newTab: INavLink = link;
56
57
 
57
58
  // Parse the links
58
59
  for (let i = 0; i < this._links.length; i++) {
@@ -69,7 +70,7 @@ class _Nav extends Base<INavProps> implements INav {
69
70
  }
70
71
 
71
72
  // Toggle the link
72
- tab.toggle(this.props.fadeTabs);
73
+ link.toggle(this.props.fadeTabs);
73
74
 
74
75
  // Call the click event
75
76
  this.props.onClick ? this.props.onClick(newTab, prevTab) : null;
@@ -82,7 +83,7 @@ class _Nav extends Base<INavProps> implements INav {
82
83
  this._links = [];
83
84
 
84
85
  // Get the nav and tab elements
85
- let nav = this.el.querySelector(".nav") || this.el;
86
+ let nav = this.el.classList.contains("nav") ? this.el : this.el.querySelector(".nav");
86
87
  if (nav) {
87
88
  let tabs = this.el.querySelector(".tab-content");
88
89
 
@@ -94,11 +95,11 @@ class _Nav extends Base<INavProps> implements INav {
94
95
  nav.appendChild(link.el);
95
96
  this._links.push(link);
96
97
 
98
+ // Configure the link event
99
+ this.configureLinkEvents(link);
100
+
97
101
  // See if we are rendering tabs
98
102
  if (tabs) {
99
- // Configure the events
100
- this.configureTabEvents(link);
101
-
102
103
  // Add the tab content
103
104
  tabs.appendChild(link.elTabContent);
104
105
 
@@ -112,13 +112,13 @@ export class NavLink extends Base<INavLinkProps> implements INavLink {
112
112
  if (this.isActive) {
113
113
  // Hide this link and tab
114
114
  this._elLink.classList.remove("active");
115
- this._elTab.classList.remove("active");
116
- this._elTab.classList.remove("show");
115
+ this._elTab ? this._elTab.classList.remove("active") : null;
116
+ this._elTab ? this._elTab.classList.remove("show") : null;
117
117
  } else {
118
118
  // Show this link and tab
119
119
  this._elLink.classList.add("active");
120
- this._elTab.classList.add("active");
121
- fadeTabs ? this._elTab.classList.add("show") : null;
120
+ this._elTab ? this._elTab.classList.add("active") : null;
121
+ this._elTab && fadeTabs ? this._elTab.classList.add("show") : null;
122
122
  }
123
123
  }
124
124
  }
@@ -90,6 +90,7 @@ export interface INavProps<T = Element> extends IBaseProps<INav> {
90
90
  isJustified?: boolean;
91
91
  isPills?: boolean;
92
92
  isTabs?: boolean;
93
+ isUnderline?: boolean;
93
94
  isVertical?: boolean;
94
95
  onClick?: (newTab?: INavLink, prevTab?: INavLink) => void;
95
96
  onLinkRendered?: (el?: HTMLElement, item?: INavLinkProps) => void;
@@ -451,38 +451,16 @@
451
451
  /** Modal background - Shouldn't be under the .bs class */
452
452
 
453
453
  .modal-backdrop {
454
- position: fixed;
455
- top: 0;
456
- left: 0;
457
- z-index: $zindex-modal-backdrop;
458
- width: 100vw;
459
- height: 100vh;
460
- background-color: $modal-backdrop-bg;
461
- // Fade for backdrop
462
- &.fade {
463
- opacity: 0;
464
- }
465
- &.show {
466
- opacity: $modal-backdrop-opacity;
467
- }
454
+ --bs-backdrop-zindex: #{$zindex-modal-backdrop};
455
+ --bs-backdrop-bg: #{$modal-backdrop-bg};
456
+ --bs-backdrop-opacity: #{$modal-backdrop-opacity};
457
+
458
+ @include overlay-backdrop(var(--bs-backdrop-zindex), var(--bs-backdrop-bg), var(--bs-backdrop-opacity));
468
459
  }
469
460
 
470
461
 
471
462
  /** Offcanvas background - Shouldn't be under the .bs class */
472
463
 
473
464
  .offcanvas-backdrop {
474
- position: fixed;
475
- top: 0;
476
- left: 0;
477
- z-index: $zindex-offcanvas-backdrop;
478
- width: 100vw;
479
- height: 100vh;
480
- background-color: $offcanvas-backdrop-bg;
481
- // Fade for backdrop
482
- &.fade {
483
- opacity: 0;
484
- }
485
- &.show {
486
- opacity: $offcanvas-backdrop-opacity;
487
- }
488
- }
465
+ @include overlay-backdrop($zindex-offcanvas-backdrop, $offcanvas-backdrop-bg, $offcanvas-backdrop-opacity);
466
+ }