gd-bs 5.2.1 → 5.2.2
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/build/components/index.js +1 -0
- package/build/components/tooltipGroup/index.js +82 -0
- package/build/components/tooltipGroup/templates.js +4 -0
- package/dist/gd-bs-icons.js +23 -1
- package/dist/gd-bs-icons.min.js +1 -1
- package/dist/gd-bs.d.ts +59 -0
- package/dist/gd-bs.js +23 -1
- package/dist/gd-bs.min.js +1 -1
- package/package.json +1 -1
- package/src/components/components.d.ts +2 -1
- package/src/components/index.ts +2 -1
- package/src/components/tooltipGroup/index.ts +75 -0
- package/src/components/tooltipGroup/templates.ts +1 -0
- package/src/components/tooltipGroup/types.d.ts +75 -0
package/package.json
CHANGED
package/src/components/index.ts
CHANGED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { ITooltip } from "../tooltip/types";
|
|
2
|
+
import { ITooltipGroup, ITooltipGroupProps } from "./types";
|
|
3
|
+
import { Base } from "../base";
|
|
4
|
+
import { Tooltip } from "../tooltip";
|
|
5
|
+
import { HTML } from "./templates";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Tooltip Group
|
|
9
|
+
* @property props - The tooltip group properties.
|
|
10
|
+
*/
|
|
11
|
+
class _TooltipGroup extends Base<ITooltipGroupProps> implements ITooltipGroup {
|
|
12
|
+
private _tooltips: Array<ITooltip> = null;
|
|
13
|
+
|
|
14
|
+
// Constructor
|
|
15
|
+
constructor(props: ITooltipGroupProps, template: string = HTML, btnTemplate?: string) {
|
|
16
|
+
super(template, props);
|
|
17
|
+
|
|
18
|
+
// Configure the tooltip group
|
|
19
|
+
this.configure(btnTemplate);
|
|
20
|
+
|
|
21
|
+
// Configure the parent
|
|
22
|
+
this.configureParent();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Configure the tooltip group
|
|
26
|
+
private configure(btnTemplate: string) {
|
|
27
|
+
// Set the attributes
|
|
28
|
+
this.props.id ? this.el.id = this.props.id : null;
|
|
29
|
+
this.props.label ? this.el.setAttribute("aria-label", this.props.label) : null;
|
|
30
|
+
|
|
31
|
+
// Set the class names
|
|
32
|
+
this.el.classList.add(this.props.isVertical ? "btn-group-vertical" : "btn-group");
|
|
33
|
+
this.props.isLarge ? this.el.classList.add("btn-group-lg") : null;
|
|
34
|
+
this.props.isSmall ? this.el.classList.add("btn-group-sm") : null;
|
|
35
|
+
|
|
36
|
+
// Render the tooltips
|
|
37
|
+
this.renderTooltips(btnTemplate);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Render the tooltips
|
|
41
|
+
private renderTooltips(tooltipTemplate: string) {
|
|
42
|
+
// Clear the tooltips
|
|
43
|
+
this._tooltips = [];
|
|
44
|
+
|
|
45
|
+
// Parse the tooltips
|
|
46
|
+
let tooltips = this.props.tooltips || [];
|
|
47
|
+
for (let i = 0; i < tooltips.length; i++) {
|
|
48
|
+
let tooltipProps = tooltips[i];
|
|
49
|
+
|
|
50
|
+
// Set the property
|
|
51
|
+
tooltipProps.type = tooltipProps.type || this.props.tooltipType;
|
|
52
|
+
|
|
53
|
+
// See if the button props exists
|
|
54
|
+
if (tooltipProps.btnProps) {
|
|
55
|
+
// Set the button type
|
|
56
|
+
tooltipProps.btnProps.type = tooltipProps.btnProps.type || this.props.buttonType;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// Create the tooltip
|
|
60
|
+
let tooltip = Tooltip(tooltipProps, tooltipTemplate);
|
|
61
|
+
this._tooltips.push(tooltip);
|
|
62
|
+
|
|
63
|
+
// Append the tooltip to the group
|
|
64
|
+
this.el.appendChild(tooltip.el);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Public Interface
|
|
70
|
+
*/
|
|
71
|
+
|
|
72
|
+
// Reference to the tooltips
|
|
73
|
+
get tooltips(): Array<ITooltip> { return this._tooltips; }
|
|
74
|
+
}
|
|
75
|
+
export const TooltipGroup = (props: ITooltipGroupProps, template?: string, tooltipTemplate?: string): ITooltipGroup => { return new _TooltipGroup(props, template, tooltipTemplate); }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const HTML = `<div class="btn-group" role="group"></div>`;
|
|
@@ -0,0 +1,75 @@
|
|
|
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
|
+
* // Render the tooltip group
|
|
8
|
+
* $REST.Components.TooltipGroup({
|
|
9
|
+
* el: document.querySelector("#demo"),
|
|
10
|
+
* buttonType: $REST.Components.ButtonTypes.Primary,
|
|
11
|
+
* tooltipType: $REST.Components.TooltipTypes.LeftStart,
|
|
12
|
+
* tooltips: [
|
|
13
|
+
* { text: "Left", onClick: function() { alert("Left button was clicked."); } },
|
|
14
|
+
* { text: "Middle", onClick: function() { alert("Middle button was clicked."); } },
|
|
15
|
+
* { text: "Right", onClick: function() { alert("Right button was clicked."); } }
|
|
16
|
+
* ]
|
|
17
|
+
* });
|
|
18
|
+
* });
|
|
19
|
+
* </script>
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* ### Tooltip Group
|
|
24
|
+
*
|
|
25
|
+
* ```ts
|
|
26
|
+
* import { Components } from "gd-sprest-bs";
|
|
27
|
+
*
|
|
28
|
+
* // Create the group
|
|
29
|
+
* let el = document.querySelector("#buttonGroup");
|
|
30
|
+
* let tooltipGroup = Components.TooltipGroup({
|
|
31
|
+
* el: el,
|
|
32
|
+
* buttonType: $REST.Components.ButtonTypes.Primary,
|
|
33
|
+
* buttons: [
|
|
34
|
+
* { text: "Left", onClick: function() { alert("Left button was clicked."); } },
|
|
35
|
+
* { text: "Middle", onClick: function() { alert("Middle button was clicked."); } },
|
|
36
|
+
* { text: "Right", onClick: function() { alert("Right button was clicked."); } }
|
|
37
|
+
* ]
|
|
38
|
+
* });
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
export const TooltipGroup: (props: ITooltipGroupProps, template?: string, btnTemplate?: string) => ITooltipGroup;
|
|
42
|
+
|
|
43
|
+
import { IBaseProps } from "../types";
|
|
44
|
+
import { ITooltip, ITooltipProps } from "../tooltip/types";
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Tooltip Group
|
|
48
|
+
*/
|
|
49
|
+
export interface ITooltipGroup {
|
|
50
|
+
/** The element. */
|
|
51
|
+
el: Element;
|
|
52
|
+
|
|
53
|
+
/** The tooltips. */
|
|
54
|
+
tooltips: Array<ITooltip>;
|
|
55
|
+
|
|
56
|
+
/** Hides the button group. */
|
|
57
|
+
hide: () => void;
|
|
58
|
+
|
|
59
|
+
/** Shows the button group. */
|
|
60
|
+
show: () => void;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Tooltip Group Properties
|
|
65
|
+
*/
|
|
66
|
+
export interface ITooltipGroupProps extends IBaseProps<ITooltipGroup> {
|
|
67
|
+
tooltips?: Array<ITooltipProps>;
|
|
68
|
+
buttonType?: number;
|
|
69
|
+
id?: string;
|
|
70
|
+
isLarge?: boolean;
|
|
71
|
+
isSmall?: boolean;
|
|
72
|
+
isVertical?: boolean;
|
|
73
|
+
label?: string;
|
|
74
|
+
tooltipType?: number;
|
|
75
|
+
}
|