@stackoverflow/stacks 0.75.0 → 1.0.0
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/dist/controllers/index.d.ts +7 -0
- package/dist/controllers/s-expandable-control.d.ts +17 -0
- package/dist/controllers/s-modal.d.ts +97 -0
- package/dist/controllers/s-navigation-tablist.d.ts +36 -0
- package/dist/controllers/s-popover.d.ts +155 -0
- package/dist/controllers/s-table.d.ts +8 -0
- package/dist/controllers/s-tooltip.d.ts +82 -0
- package/dist/controllers/s-uploader.d.ts +48 -0
- package/dist/css/stacks.css +4379 -2660
- package/dist/css/stacks.min.css +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/js/stacks.js +6026 -5403
- package/dist/js/stacks.min.js +1 -1
- package/dist/stacks.d.ts +21 -0
- package/lib/css/atomic/{_stacks-borders.less → borders.less} +30 -30
- package/lib/css/atomic/{_stacks-colors.less → colors.less} +0 -0
- package/lib/css/atomic/{_stacks-flex.less → flex.less} +14 -13
- package/lib/css/atomic/{_stacks-grid.less → grid.less} +12 -11
- package/lib/css/atomic/{_stacks-misc.less → misc.less} +22 -22
- package/lib/css/atomic/spacing.less +314 -0
- package/lib/css/atomic/{_stacks-typography.less → typography.less} +29 -29
- package/lib/css/atomic/width-height.less +194 -0
- package/lib/css/base/{_stacks-body.less → body.less} +3 -5
- package/lib/css/base/{_stacks-configuration-static.less → configuration-static.less} +3 -1
- package/lib/css/base/{_stacks-icons.less → icons.less} +0 -0
- package/lib/css/base/{_stacks-internals.less → internals.less} +0 -10
- package/lib/css/base/{_stacks-reset-meyer.less → reset-meyer.less} +0 -0
- package/lib/css/base/{_stacks-reset-normalize.less → reset-normalize.less} +0 -0
- package/lib/css/base/{_stacks-reset.less → reset.less} +2 -2
- package/lib/css/components/{_stacks-activity-indicator.less → activity-indicator.less} +9 -9
- package/lib/css/components/{_stacks-avatars.less → avatars.less} +40 -40
- package/lib/css/components/{_stacks-badges.less → badges.less} +11 -11
- package/lib/css/components/{_stacks-banners.less → banners.less} +5 -6
- package/lib/css/components/{_stacks-blank-states.less → blank-states.less} +2 -2
- package/lib/css/components/{_stacks-breadcrumbs.less → breadcrumbs.less} +7 -7
- package/lib/css/components/{_stacks-button-groups.less → button-groups.less} +2 -2
- package/lib/css/components/{_stacks-buttons.less → buttons.less} +77 -72
- package/lib/css/components/{_stacks-cards.less → cards.less} +2 -2
- package/lib/css/components/{_stacks-code-blocks.less → code-blocks.less} +8 -8
- package/lib/css/components/{_stacks-collapsible.less → collapsible.less} +0 -0
- package/lib/css/components/{_stacks-inputs.less → inputs.less} +41 -41
- package/lib/css/components/{_stacks-link-previews.less → link-previews.less} +17 -17
- package/lib/css/components/{_stacks-links.less → links.less} +4 -4
- package/lib/css/components/{_stacks-menu.less → menu.less} +5 -5
- package/lib/css/components/{_stacks-modals.less → modals.less} +20 -20
- package/lib/css/components/{_stacks-navigation.less → navigation.less} +12 -12
- package/lib/css/components/{_stacks-notices.less → notices.less} +12 -12
- package/lib/css/components/{_stacks-page-titles.less → page-titles.less} +9 -9
- package/lib/css/components/{_stacks-pagination.less → pagination.less} +8 -8
- package/lib/css/components/{_stacks-popovers.less → popovers.less} +17 -17
- package/lib/css/components/{_stacks-post-summary.less → post-summary.less} +35 -35
- package/lib/css/components/{_stacks-progress-bars.less → progress-bars.less} +29 -30
- package/lib/css/components/{_stacks-prose.less → prose.less} +31 -31
- package/lib/css/components/{_stacks-spinner.less → spinner.less} +14 -14
- package/lib/css/components/{_stacks-tables.less → tables.less} +10 -10
- package/lib/css/components/{_stacks-tags.less → tags.less} +33 -41
- package/lib/css/components/{_stacks-toggle-switches.less → toggle-switches.less} +5 -5
- package/lib/css/components/{_stacks-topbar.less → topbar.less} +27 -40
- package/lib/css/components/{_stacks-uploader.less → uploader.less} +18 -18
- package/lib/css/components/{_stacks-user-cards.less → user-cards.less} +14 -14
- package/lib/css/components/{_stacks-widget-dynamic.less → widget-dynamic.less} +1 -1
- package/lib/css/components/{_stacks-widget-static.less → widget-static.less} +39 -38
- package/lib/css/exports/{_stacks-constants-colors.less → constants-colors.less} +10 -30
- package/lib/css/exports/constants-helpers.less +108 -0
- package/lib/css/exports/constants-type.less +153 -0
- package/lib/css/exports/{_stacks-exports.less → exports.less} +4 -4
- package/lib/css/exports/{_stacks-mixins.less → mixins.less} +18 -1
- package/lib/css/stacks-dynamic.less +12 -13
- package/lib/css/stacks-static.less +38 -38
- package/lib/ts/controllers/index.ts +8 -0
- package/lib/ts/controllers/s-expandable-control.ts +163 -164
- package/lib/ts/controllers/s-modal.ts +259 -261
- package/lib/ts/controllers/s-navigation-tablist.ts +96 -97
- package/lib/ts/controllers/s-popover.ts +438 -440
- package/lib/ts/controllers/s-table.ts +203 -203
- package/lib/ts/controllers/s-tooltip.ts +195 -196
- package/lib/ts/controllers/s-uploader.ts +162 -164
- package/lib/ts/index.ts +20 -0
- package/lib/ts/stacks.ts +73 -68
- package/lib/tsconfig.json +8 -6
- package/package.json +40 -24
- package/dist/css/stacks-flexgrid-shim.min.css +0 -1
- package/lib/css/atomic/_stacks-spacing.less +0 -168
- package/lib/css/atomic/_stacks-width-height.less +0 -195
- package/lib/css/base/_stacks-configuration-dynamic.less +0 -106
- package/lib/css/exports/_stacks-constants-helpers.less +0 -139
- package/lib/css/exports/_stacks-constants-type.less +0 -91
- package/lib/ts/finalize.ts +0 -1
- package/lib/ts/stimulus.d.ts +0 -4
|
@@ -1,119 +1,118 @@
|
|
|
1
|
-
|
|
2
|
-
export class TabListController extends Stacks.StacksController {
|
|
1
|
+
import * as Stacks from "../stacks";
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
private boundHandleKeydown: any // (event: KeyboardEvent) => void;
|
|
3
|
+
export class TabListController extends Stacks.StacksController {
|
|
6
4
|
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
private boundSelectTab: any; // (event: MouseEvent) => void;
|
|
6
|
+
private boundHandleKeydown: any // (event: KeyboardEvent) => void;
|
|
9
7
|
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
connect() {
|
|
9
|
+
super.connect();
|
|
12
10
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
this.boundSelectTab = this.selectTab.bind(this);
|
|
12
|
+
this.boundHandleKeydown = this.handleKeydown.bind(this);
|
|
13
|
+
|
|
14
|
+
for (let tab of this.tabTargets) {
|
|
15
|
+
tab.addEventListener("click", this.boundSelectTab);
|
|
16
|
+
tab.addEventListener("keydown", this.boundHandleKeydown);
|
|
17
17
|
}
|
|
18
|
+
}
|
|
18
19
|
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
disconnect() {
|
|
21
|
+
super.disconnect();
|
|
21
22
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
23
|
+
for (let tab of this.tabTargets) {
|
|
24
|
+
tab.removeEventListener("click", this.boundSelectTab);
|
|
25
|
+
tab.removeEventListener("keydown", this.boundHandleKeydown);
|
|
26
26
|
}
|
|
27
|
+
}
|
|
27
28
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
29
|
+
/**
|
|
30
|
+
* Gets all tabs within the controller.
|
|
31
|
+
*/
|
|
32
|
+
get tabTargets() {
|
|
33
|
+
return <HTMLElement[]>Array.from(this.element.querySelectorAll("[role=tab]"));
|
|
34
|
+
}
|
|
34
35
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
/**
|
|
37
|
+
* Handles click events on individual tabs, causing them to be selected.
|
|
38
|
+
*/
|
|
39
|
+
selectTab(event: MouseEvent) {
|
|
40
|
+
this.switchToTab(<HTMLElement>event.currentTarget);
|
|
41
|
+
}
|
|
41
42
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
43
|
+
/**
|
|
44
|
+
* Handles left and right arrow keydown events on individual tabs,
|
|
45
|
+
* selecting the adjacent tab corresponding to the event.
|
|
46
|
+
*/
|
|
47
|
+
handleKeydown(event: KeyboardEvent) {
|
|
48
|
+
let tabElement = <HTMLElement>event.currentTarget;
|
|
49
|
+
|
|
50
|
+
var tabs = this.tabTargets;
|
|
51
|
+
var tabIndex = tabs.indexOf(tabElement);
|
|
52
|
+
|
|
53
|
+
if (event.key === "ArrowRight") {
|
|
54
|
+
tabIndex++;
|
|
55
|
+
} else if (event.key === "ArrowLeft") {
|
|
56
|
+
tabIndex--;
|
|
57
|
+
} else {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
48
60
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
if (event.key === "ArrowRight") {
|
|
53
|
-
tabIndex++;
|
|
54
|
-
} else if (event.key === "ArrowLeft") {
|
|
55
|
-
tabIndex--;
|
|
56
|
-
} else {
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// Use circular navigation when users go past the first or last tab.
|
|
61
|
-
if (tabIndex < 0) { tabIndex = tabs.length - 1; }
|
|
62
|
-
if (tabIndex >= tabs.length) { tabIndex = 0; }
|
|
61
|
+
// Use circular navigation when users go past the first or last tab.
|
|
62
|
+
if (tabIndex < 0) { tabIndex = tabs.length - 1; }
|
|
63
|
+
if (tabIndex >= tabs.length) { tabIndex = 0; }
|
|
63
64
|
|
|
64
|
-
|
|
65
|
-
|
|
65
|
+
tabElement = <HTMLElement>tabs[tabIndex];
|
|
66
|
+
this.switchToTab(tabElement);
|
|
66
67
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
// Focus the newly selected tab so it can receive keyboard events.
|
|
69
|
+
this.selectedTab?.focus();
|
|
70
|
+
}
|
|
70
71
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
72
|
+
/**
|
|
73
|
+
* Attempts to switch to a new tab, doing nothing if the tab is already selected or
|
|
74
|
+
* the s-navigation-tablist:select event is prevented.
|
|
75
|
+
*/
|
|
76
|
+
private switchToTab(newTab: HTMLElement) {
|
|
76
77
|
|
|
77
|
-
|
|
78
|
-
|
|
78
|
+
var oldTab = this.selectedTab;
|
|
79
|
+
if (oldTab === newTab) { return; }
|
|
79
80
|
|
|
80
|
-
|
|
81
|
+
if (this.triggerEvent("select", { oldTab, newTab }).defaultPrevented) { return; }
|
|
81
82
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Returns the currently selected tab or null if no tabs are selected.
|
|
88
|
-
*/
|
|
89
|
-
public get selectedTab() : HTMLElement | null {
|
|
90
|
-
return this.tabTargets.find(e => e.getAttribute("aria-selected") === "true") || null;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Switches the tablist to the provided tab, updating the tabs and panels
|
|
95
|
-
* to reflect the change.
|
|
96
|
-
* @param selectedTab The tab to select. If `null` is provided or the element
|
|
97
|
-
* is not a valid tab, all tabs will be unselected.
|
|
98
|
-
*/
|
|
99
|
-
public set selectedTab(selectedTab: HTMLElement | null) {
|
|
100
|
-
for (let tab of this.tabTargets) {
|
|
101
|
-
let panelId = tab.getAttribute('aria-controls');
|
|
102
|
-
let panel = panelId ? document.getElementById(panelId) : null;
|
|
83
|
+
this.selectedTab = newTab;
|
|
84
|
+
this.triggerEvent("selected", { oldTab, newTab });
|
|
85
|
+
}
|
|
103
86
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
87
|
+
/**
|
|
88
|
+
* Returns the currently selected tab or null if no tabs are selected.
|
|
89
|
+
*/
|
|
90
|
+
public get selectedTab() : HTMLElement | null {
|
|
91
|
+
return this.tabTargets.find(e => e.getAttribute("aria-selected") === "true") || null;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Switches the tablist to the provided tab, updating the tabs and panels
|
|
96
|
+
* to reflect the change.
|
|
97
|
+
* @param selectedTab The tab to select. If `null` is provided or the element
|
|
98
|
+
* is not a valid tab, all tabs will be unselected.
|
|
99
|
+
*/
|
|
100
|
+
public set selectedTab(selectedTab: HTMLElement | null) {
|
|
101
|
+
for (let tab of this.tabTargets) {
|
|
102
|
+
let panelId = tab.getAttribute('aria-controls');
|
|
103
|
+
let panel = panelId ? document.getElementById(panelId) : null;
|
|
104
|
+
|
|
105
|
+
if (tab === selectedTab) {
|
|
106
|
+
tab.classList.add('is-selected');
|
|
107
|
+
tab.setAttribute('aria-selected', 'true');
|
|
108
|
+
tab.removeAttribute('tabindex');
|
|
109
|
+
panel?.classList.remove('d-none');
|
|
110
|
+
} else {
|
|
111
|
+
tab.classList.remove('is-selected');
|
|
112
|
+
tab.setAttribute('aria-selected', 'false');
|
|
113
|
+
tab.setAttribute('tabindex', '-1');
|
|
114
|
+
panel?.classList.add('d-none');
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
|
-
}
|
|
119
|
-
Stacks.application.register("s-navigation-tablist", Stacks.TabListController);
|
|
118
|
+
}
|