gd-bs 6.1.4 → 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.
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.",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gd-bs",
3
- "version": "6.1.4",
3
+ "version": "6.1.6",
4
4
  "description": "Bootstrap JavaScript, TypeScript and Web Components library.",
5
5
  "main": "build/index.js",
6
6
  "typings": "src/index.d.ts",
@@ -651,109 +651,113 @@ export class FormControl implements IFormControl {
651
651
 
652
652
  // Updates the control validation
653
653
  updateValidation(elControl: Element, validation: IFormControlValidationResult) {
654
- // Get the form control
655
- let elFormControl: HTMLElement = elControl.querySelector(".form-control") || elControl.querySelector(".form-select");
656
- if (elFormControl) {
657
- // Clear the invalid/valid classes
658
- elFormControl.classList.remove("is-invalid");
659
- elFormControl.classList.remove("is-valid");
660
-
661
- // Set the class
662
- elFormControl.classList.add(validation.isValid ? "is-valid" : "is-invalid");
663
- } else {
664
- let validateControls = (controls: Array<HTMLElement>) => {
665
- // Parse the controls
666
- for (let i = 0; i < controls.length; i++) {
667
- let control = controls[i];
668
-
669
- // Clear the invalid/valid classes
670
- control.classList.remove("is-invalid");
671
- control.classList.remove("is-valid");
672
-
673
- // Set the class
674
- control.classList.add(validation.isValid ? "is-valid" : "is-invalid");
654
+ // Get the form controls
655
+ let elFormControls = elControl.querySelectorAll(".form-control") || elControl.querySelectorAll(".form-select");
656
+ for (let i = 0; i < elFormControls.length; i++) {
657
+ // Ensure the control exists
658
+ let elFormControl = elFormControls[i] as HTMLElement;
659
+ if (elFormControl) {
660
+ // Clear the invalid/valid classes
661
+ elFormControl.classList.remove("is-invalid");
662
+ elFormControl.classList.remove("is-valid");
663
+
664
+ // Set the class
665
+ elFormControl.classList.add(validation.isValid ? "is-valid" : "is-invalid");
666
+ } else {
667
+ let validateControls = (controls: Array<HTMLElement>) => {
668
+ // Parse the controls
669
+ for (let i = 0; i < controls.length; i++) {
670
+ let control = controls[i];
671
+
672
+ // Clear the invalid/valid classes
673
+ control.classList.remove("is-invalid");
674
+ control.classList.remove("is-valid");
675
+
676
+ // Set the class
677
+ control.classList.add(validation.isValid ? "is-valid" : "is-invalid");
678
+ }
675
679
  }
676
- }
677
680
 
678
- // Get the checkboxes
679
- let elCheckboxes = elControl.querySelectorAll(".form-check-input");
680
- if (elCheckboxes.length > 0) {
681
- // Validate the controls
682
- validateControls(elCheckboxes as any);
681
+ // Get the checkboxes
682
+ let elCheckboxes = elControl.querySelectorAll(".form-check-input");
683
+ if (elCheckboxes.length > 0) {
684
+ // Validate the controls
685
+ validateControls(elCheckboxes as any);
683
686
 
684
- // Set the form control
685
- elFormControl = elCheckboxes.length > 0 ? elCheckboxes[elCheckboxes.length - 1] as any : elFormControl;
686
- }
687
+ // Set the form control
688
+ elFormControl = elCheckboxes.length > 0 ? elCheckboxes[elCheckboxes.length - 1] as any : elFormControl;
689
+ }
687
690
 
688
- // Get the custom controls
689
- let elCustomControls = elControl.querySelectorAll(".custom-control-input");
690
- if (elCustomControls.length > 0) {
691
- // Validate the controls
692
- validateControls(elCustomControls as any);
691
+ // Get the custom controls
692
+ let elCustomControls = elControl.querySelectorAll(".custom-control-input");
693
+ if (elCustomControls.length > 0) {
694
+ // Validate the controls
695
+ validateControls(elCustomControls as any);
693
696
 
694
- // Set the form control
695
- elFormControl = elCustomControls.length > 0 ? elCustomControls[elCustomControls.length - 1] as any : elFormControl;
697
+ // Set the form control
698
+ elFormControl = elCustomControls.length > 0 ? elCustomControls[elCustomControls.length - 1] as any : elFormControl;
699
+ }
696
700
  }
697
- }
698
701
 
699
- // Ensure the form control exists
700
- if (elFormControl) {
701
- let useTooltip = this._formProps.validationType == FormValidationTypes.Tooltip;
702
-
703
- // Clear the old valid message if it exists
704
- let validClassName = useTooltip ? "valid-tooltip" : "valid-feedback";
705
- let elMessage = elFormControl.parentNode.querySelector("." + validClassName) as HTMLElement;
706
- if (elMessage) {
707
- // Clear the message
708
- elMessage.innerHTML = "";
709
- elMessage.style.display = "";
710
- }
702
+ // Ensure the form control exists
703
+ if (elFormControl) {
704
+ let useTooltip = this._formProps.validationType == FormValidationTypes.Tooltip;
711
705
 
712
- // Clear the old valid message if it exists
713
- let invalidClassName = useTooltip ? "invalid-tooltip" : "invalid-feedback";
714
- elMessage = elFormControl.parentNode.querySelector("." + invalidClassName) as HTMLElement;
715
- if (elMessage) {
716
- // Clear the message
717
- elMessage.innerHTML = "";
718
- elMessage.style.display = "";
719
- }
706
+ // Clear the old valid message if it exists
707
+ let validClassName = useTooltip ? "valid-tooltip" : "valid-feedback";
708
+ let elMessage = elFormControl.parentNode.querySelector("." + validClassName) as HTMLElement;
709
+ if (elMessage) {
710
+ // Clear the message
711
+ elMessage.innerHTML = "";
712
+ elMessage.style.display = "";
713
+ }
720
714
 
721
- // See if there is invalid feedback
722
- if (validation.invalidMessage || this._props.errorMessage) {
723
- // Get the element
715
+ // Clear the old valid message if it exists
724
716
  let invalidClassName = useTooltip ? "invalid-tooltip" : "invalid-feedback";
725
717
  elMessage = elFormControl.parentNode.querySelector("." + invalidClassName) as HTMLElement;
726
- if (elMessage == null) {
727
- // Create the element
728
- elMessage = document.createElement("div");
729
- elMessage.className = invalidClassName;
730
- elFormControl.parentNode.appendChild(elMessage);
718
+ if (elMessage) {
719
+ // Clear the message
720
+ elMessage.innerHTML = "";
721
+ elMessage.style.display = "";
731
722
  }
732
723
 
733
- // Set the message
734
- elMessage.innerHTML = validation.invalidMessage || this._props.errorMessage;
735
-
736
- // Update the display
737
- elMessage.style.display = validation.isValid ? "" : "block";
738
- }
739
-
740
- // See if there is valid feedback
741
- if (validation.validMessage) {
742
- // Get the element
743
- let validClassName = useTooltip ? "valid-tooltip" : "valid-feedback";
744
- elMessage = elFormControl.parentNode.querySelector("." + validClassName) as HTMLElement;
745
- if (elMessage == null) {
746
- // Create the element
747
- elMessage = document.createElement("div");
748
- elMessage.className = validClassName;
749
- elFormControl.parentNode.appendChild(elMessage);
724
+ // See if there is invalid feedback
725
+ if (validation.invalidMessage || this._props.errorMessage) {
726
+ // Get the element
727
+ let invalidClassName = useTooltip ? "invalid-tooltip" : "invalid-feedback";
728
+ elMessage = elFormControl.parentNode.querySelector("." + invalidClassName) as HTMLElement;
729
+ if (elMessage == null) {
730
+ // Create the element
731
+ elMessage = document.createElement("div");
732
+ elMessage.className = invalidClassName;
733
+ elFormControl.parentNode.appendChild(elMessage);
734
+ }
735
+
736
+ // Set the message
737
+ elMessage.innerHTML = validation.invalidMessage || this._props.errorMessage;
738
+
739
+ // Update the display
740
+ elMessage.style.display = validation.isValid ? "" : "block";
750
741
  }
751
742
 
752
- // Set the message
753
- elMessage.innerHTML = validation.validMessage;
754
-
755
- // Update the display
756
- elMessage.style.display = validation.isValid ? "block" : "";
743
+ // See if there is valid feedback
744
+ if (validation.validMessage) {
745
+ // Get the element
746
+ let validClassName = useTooltip ? "valid-tooltip" : "valid-feedback";
747
+ elMessage = elFormControl.parentNode.querySelector("." + validClassName) as HTMLElement;
748
+ if (elMessage == null) {
749
+ // Create the element
750
+ elMessage = document.createElement("div");
751
+ elMessage.className = validClassName;
752
+ elFormControl.parentNode.appendChild(elMessage);
753
+ }
754
+
755
+ // Set the message
756
+ elMessage.innerHTML = validation.validMessage;
757
+
758
+ // Update the display
759
+ elMessage.style.display = validation.isValid ? "block" : "";
760
+ }
757
761
  }
758
762
  }
759
763
  }
@@ -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";
@@ -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
+ }