@stackoverflow/stacks 1.0.0 → 1.2.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.
Files changed (74) hide show
  1. package/README.md +47 -47
  2. package/dist/controllers/s-popover.d.ts +11 -2
  3. package/dist/css/stacks.css +257 -8
  4. package/dist/css/stacks.min.css +1 -1
  5. package/dist/js/stacks.js +18 -2
  6. package/dist/js/stacks.min.js +1 -1
  7. package/lib/css/atomic/borders.less +378 -378
  8. package/lib/css/atomic/colors.less +209 -209
  9. package/lib/css/atomic/flex.less +375 -375
  10. package/lib/css/atomic/grid.less +174 -174
  11. package/lib/css/atomic/misc.less +343 -343
  12. package/lib/css/atomic/spacing.less +342 -314
  13. package/lib/css/atomic/typography.less +273 -273
  14. package/lib/css/atomic/width-height.less +194 -194
  15. package/lib/css/base/body.less +44 -44
  16. package/lib/css/base/configuration-static.less +61 -61
  17. package/lib/css/base/icons.less +20 -20
  18. package/lib/css/base/internals.less +220 -220
  19. package/lib/css/base/reset-meyer.less +64 -64
  20. package/lib/css/base/reset-normalize.less +449 -449
  21. package/lib/css/base/reset.less +20 -20
  22. package/lib/css/components/activity-indicator.less +44 -45
  23. package/lib/css/components/avatars.less +189 -189
  24. package/lib/css/components/badges.less +254 -209
  25. package/lib/css/components/banners.less +80 -80
  26. package/lib/css/components/blank-states.less +26 -26
  27. package/lib/css/components/breadcrumbs.less +44 -44
  28. package/lib/css/components/button-groups.less +104 -104
  29. package/lib/css/components/buttons.less +665 -665
  30. package/lib/css/components/cards.less +44 -44
  31. package/lib/css/components/code-blocks.less +130 -130
  32. package/lib/css/components/collapsible.less +104 -104
  33. package/lib/css/components/inputs.less +728 -728
  34. package/lib/css/components/link-previews.less +136 -136
  35. package/lib/css/components/links.less +218 -218
  36. package/lib/css/components/menu.less +47 -47
  37. package/lib/css/components/modals.less +133 -133
  38. package/lib/css/components/navigation.less +146 -146
  39. package/lib/css/components/notices.less +233 -233
  40. package/lib/css/components/page-titles.less +60 -60
  41. package/lib/css/components/pagination.less +55 -55
  42. package/lib/css/components/popovers.less +197 -197
  43. package/lib/css/components/post-summary.less +436 -425
  44. package/lib/css/components/progress-bars.less +330 -330
  45. package/lib/css/components/prose.less +503 -503
  46. package/lib/css/components/spinner.less +107 -107
  47. package/lib/css/components/tables.less +341 -341
  48. package/lib/css/components/tags.less +236 -236
  49. package/lib/css/components/toggle-switches.less +144 -144
  50. package/lib/css/components/topbar.less +427 -427
  51. package/lib/css/components/uploader.less +210 -210
  52. package/lib/css/components/user-cards.less +169 -169
  53. package/lib/css/components/widget-dynamic.less +33 -33
  54. package/lib/css/components/widget-static.less +273 -273
  55. package/lib/css/exports/constants-colors.less +1092 -1092
  56. package/lib/css/exports/constants-helpers.less +108 -108
  57. package/lib/css/exports/constants-type.less +153 -153
  58. package/lib/css/exports/exports.less +15 -15
  59. package/lib/css/exports/mixins.less +237 -237
  60. package/lib/css/stacks-dynamic.less +35 -35
  61. package/lib/css/stacks-static.less +86 -86
  62. package/lib/css/stacks.less +13 -13
  63. package/lib/ts/controllers/index.ts +7 -7
  64. package/lib/ts/controllers/s-expandable-control.ts +188 -188
  65. package/lib/ts/controllers/s-modal.ts +321 -321
  66. package/lib/ts/controllers/s-navigation-tablist.ts +117 -117
  67. package/lib/ts/controllers/s-popover.ts +567 -547
  68. package/lib/ts/controllers/s-table.ts +220 -220
  69. package/lib/ts/controllers/s-tooltip.ts +246 -246
  70. package/lib/ts/controllers/s-uploader.ts +172 -172
  71. package/lib/ts/index.ts +20 -20
  72. package/lib/ts/stacks.ts +88 -88
  73. package/lib/tsconfig.json +13 -13
  74. package/package.json +86 -87
@@ -1,118 +1,118 @@
1
- import * as Stacks from "../stacks";
2
-
3
- export class TabListController extends Stacks.StacksController {
4
-
5
- private boundSelectTab: any; // (event: MouseEvent) => void;
6
- private boundHandleKeydown: any // (event: KeyboardEvent) => void;
7
-
8
- connect() {
9
- super.connect();
10
-
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
- }
18
- }
19
-
20
- disconnect() {
21
- super.disconnect();
22
-
23
- for (let tab of this.tabTargets) {
24
- tab.removeEventListener("click", this.boundSelectTab);
25
- tab.removeEventListener("keydown", this.boundHandleKeydown);
26
- }
27
- }
28
-
29
- /**
30
- * Gets all tabs within the controller.
31
- */
32
- get tabTargets() {
33
- return <HTMLElement[]>Array.from(this.element.querySelectorAll("[role=tab]"));
34
- }
35
-
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
- }
42
-
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
- }
60
-
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; }
64
-
65
- tabElement = <HTMLElement>tabs[tabIndex];
66
- this.switchToTab(tabElement);
67
-
68
- // Focus the newly selected tab so it can receive keyboard events.
69
- this.selectedTab?.focus();
70
- }
71
-
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) {
77
-
78
- var oldTab = this.selectedTab;
79
- if (oldTab === newTab) { return; }
80
-
81
- if (this.triggerEvent("select", { oldTab, newTab }).defaultPrevented) { return; }
82
-
83
- this.selectedTab = newTab;
84
- this.triggerEvent("selected", { oldTab, newTab });
85
- }
86
-
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
- }
116
- }
117
- }
1
+ import * as Stacks from "../stacks";
2
+
3
+ export class TabListController extends Stacks.StacksController {
4
+
5
+ private boundSelectTab: any; // (event: MouseEvent) => void;
6
+ private boundHandleKeydown: any // (event: KeyboardEvent) => void;
7
+
8
+ connect() {
9
+ super.connect();
10
+
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
+ }
18
+ }
19
+
20
+ disconnect() {
21
+ super.disconnect();
22
+
23
+ for (let tab of this.tabTargets) {
24
+ tab.removeEventListener("click", this.boundSelectTab);
25
+ tab.removeEventListener("keydown", this.boundHandleKeydown);
26
+ }
27
+ }
28
+
29
+ /**
30
+ * Gets all tabs within the controller.
31
+ */
32
+ get tabTargets() {
33
+ return <HTMLElement[]>Array.from(this.element.querySelectorAll("[role=tab]"));
34
+ }
35
+
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
+ }
42
+
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
+ }
60
+
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; }
64
+
65
+ tabElement = <HTMLElement>tabs[tabIndex];
66
+ this.switchToTab(tabElement);
67
+
68
+ // Focus the newly selected tab so it can receive keyboard events.
69
+ this.selectedTab?.focus();
70
+ }
71
+
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) {
77
+
78
+ var oldTab = this.selectedTab;
79
+ if (oldTab === newTab) { return; }
80
+
81
+ if (this.triggerEvent("select", { oldTab, newTab }).defaultPrevented) { return; }
82
+
83
+ this.selectedTab = newTab;
84
+ this.triggerEvent("selected", { oldTab, newTab });
85
+ }
86
+
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
+ }
116
+ }
117
+ }
118
118
  }