@govtechsg/sgds-web-component 0.0.10 → 0.0.12
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/README.md +102 -10
- package/base/card-element.d.ts +12 -0
- package/{lib/utils → base}/dropdown-element.d.ts +38 -37
- package/{lib/utils → base}/link-element.d.ts +8 -7
- package/{lib/utils → base}/sgds-element.d.ts +6 -5
- package/components/Accordion/index.d.ts +2 -0
- package/components/Accordion/sgds-accordion-item.d.ts +40 -0
- package/components/Accordion/sgds-accordion.d.ts +19 -0
- package/components/ActionCard/index.d.ts +1 -0
- package/{lib/Card → components/ActionCard}/sgds-action-card.d.ts +21 -20
- package/components/Alert/index.d.ts +1 -0
- package/components/Alert/sgds-alert.d.ts +37 -0
- package/components/Badge/index.d.ts +1 -0
- package/components/Badge/sgds-badge.d.ts +10 -0
- package/components/Breadcrumb/index.d.ts +2 -0
- package/components/Breadcrumb/sgds-breadcrumb-item.d.ts +10 -0
- package/components/Breadcrumb/sgds-breadcrumb.d.ts +12 -0
- package/components/Button/index.d.ts +1 -0
- package/{lib → components}/Button/sgds-button.d.ts +55 -48
- package/components/Checkbox/index.d.ts +1 -0
- package/{lib → components}/Checkbox/sgds-checkbox.d.ts +36 -36
- package/components/CloseButton/index.d.ts +1 -0
- package/components/CloseButton/sgds-closebutton.d.ts +9 -0
- package/components/Dropdown/index.d.ts +3 -0
- package/{lib → components}/Dropdown/sgds-dropdown-item.d.ts +8 -7
- package/{lib → components}/Dropdown/sgds-dropdown.d.ts +8 -7
- package/components/FileUpload/index.d.ts +1 -0
- package/components/FileUpload/sgds-fileupload.d.ts +22 -0
- package/components/Footer/index.d.ts +1 -0
- package/{lib → components}/Footer/sgds-footer.d.ts +27 -23
- package/components/Input/index.d.ts +1 -0
- package/{lib → components}/Input/sgds-input.d.ts +42 -42
- package/components/Mainnav/index.d.ts +3 -0
- package/components/Mainnav/sgds-mainnav-dropdown.d.ts +6 -0
- package/components/Mainnav/sgds-mainnav-item.d.ts +8 -0
- package/{lib → components}/Mainnav/sgds-mainnav.d.ts +26 -22
- package/components/Masthead/index.d.ts +1 -0
- package/{lib → components}/Masthead/sgds-masthead.d.ts +9 -12
- package/components/Modal/index.d.ts +1 -0
- package/{lib → components}/Modal/sgds-modal.d.ts +28 -28
- package/components/QuantityToggle/index.d.ts +1 -0
- package/{lib/QuantityToggle/sgds-quantitytoggle.d.ts → components/QuantityToggle/sgds-quantity-toggle.d.ts} +30 -30
- package/components/Radio/index.d.ts +2 -0
- package/{lib/Radio/sgds-radiogroup.d.ts → components/Radio/sgds-radio-group.d.ts} +41 -41
- package/{lib → components}/Radio/sgds-radio.d.ts +31 -31
- package/components/Sidenav/index.d.ts +3 -0
- package/{lib → components}/Sidenav/sgds-sidenav-item.d.ts +36 -28
- package/components/Sidenav/sgds-sidenav-link.d.ts +8 -0
- package/{lib → components}/Sidenav/sgds-sidenav.d.ts +10 -6
- package/components/Stepper/index.d.ts +1 -0
- package/components/Stepper/sgds-stepper.d.ts +17 -0
- package/components/Tab/index.d.ts +3 -0
- package/{lib → components}/Tab/sgds-tab.d.ts +27 -26
- package/{lib → components}/Tab/sgds-tabgroup.d.ts +48 -47
- package/{lib → components}/Tab/sgds-tabpanel.d.ts +26 -25
- package/components/Table/index.d.ts +1 -0
- package/components/Table/sgds-table.d.ts +26 -0
- package/components/Textarea/index.d.ts +1 -0
- package/{lib → components}/Textarea/sgds-textarea.d.ts +53 -53
- package/components/Toast/index.d.ts +1 -0
- package/components/Toast/sgds-toast.d.ts +22 -0
- package/components/Tooltip/index.d.ts +1 -0
- package/components/Tooltip/sgds-tooltip.d.ts +30 -0
- package/index.d.ts +23 -0
- package/index.js +11543 -0
- package/index.js.map +1 -0
- package/main.d.ts +24 -0
- package/package.json +23 -65
- package/react/accordion/index.d.ts +3 -0
- package/react/accordion-item/index.d.ts +8 -0
- package/react/action-card/index.d.ts +3 -0
- package/react/alert/index.d.ts +3 -0
- package/react/badge/index.d.ts +3 -0
- package/react/breadcrumb/index.d.ts +3 -0
- package/react/breadcrumb-item/index.d.ts +3 -0
- package/react/button/index.d.ts +6 -0
- package/react/checkbox/index.d.ts +3 -0
- package/react/cjs/index.js +12510 -0
- package/react/cjs/index.js.map +1 -0
- package/react/closebutton/index.d.ts +5 -0
- package/react/dropdown/index.d.ts +3 -0
- package/react/dropdown-item/index.d.ts +3 -0
- package/react/fileupload/index.d.ts +3 -0
- package/react/footer/index.d.ts +3 -0
- package/react/index.d.ts +34 -0
- package/react/index.js +12453 -0
- package/react/index.js.map +1 -0
- package/react/input/index.d.ts +3 -0
- package/react/mainnav/index.d.ts +3 -0
- package/react/mainnav-dropdown/index.d.ts +3 -0
- package/react/mainnav-item/index.d.ts +3 -0
- package/react/masthead/index.d.ts +3 -0
- package/react/modal/index.d.ts +3 -0
- package/react/package.json +10 -0
- package/react/quantity-toggle/index.d.ts +3 -0
- package/react/radio/index.d.ts +3 -0
- package/react/radio-group/index.d.ts +3 -0
- package/react/sidenav/index.d.ts +3 -0
- package/react/sidenav-item/index.d.ts +5 -0
- package/react/sidenav-link/index.d.ts +3 -0
- package/react/stepper/index.d.ts +3 -0
- package/react/tab/index.d.ts +3 -0
- package/react/tab-group/index.d.ts +3 -0
- package/react/tab-panel/index.d.ts +3 -0
- package/react/table/index.d.ts +3 -0
- package/react/textarea/index.d.ts +3 -0
- package/react/toast/index.d.ts +3 -0
- package/react/tooltip/index.d.ts +3 -0
- package/umd/index.js +11995 -0
- package/umd/index.js.map +1 -0
- package/{lib/utils → utils}/animate.d.ts +10 -10
- package/{lib/utils → utils}/animation-registry.d.ts +18 -18
- package/{lib/utils → utils}/breakpoints.d.ts +5 -5
- package/{lib/utils → utils}/defaultvalue.d.ts +2 -2
- package/{lib/utils → utils}/event.d.ts +2 -2
- package/{lib/utils → utils}/form.d.ts +38 -38
- package/{lib/utils → utils}/generateId.d.ts +1 -1
- package/{lib/utils → utils}/mergeDeep.d.ts +2 -2
- package/{lib/utils → utils}/modal.d.ts +12 -12
- package/{lib/utils → utils}/object.d.ts +2 -2
- package/{lib/utils → utils}/offset.d.ts +4 -4
- package/{lib/utils → utils}/scroll.d.ts +13 -13
- package/{lib/utils → utils}/slot.d.ts +22 -22
- package/{lib/utils → utils}/tabbable.d.ts +8 -8
- package/{lib/utils → utils}/watch.d.ts +14 -14
- package/.github/workflows/publish-latest.yml +0 -22
- package/.github/workflows/publish-pr.yml +0 -28
- package/.husky/commit-msg +0 -4
- package/.husky/prepare-commit-msg +0 -8
- package/.storybook/main.js +0 -16
- package/.storybook/preview-head.html +0 -11
- package/.storybook/preview.js +0 -9
- package/.vscode/settings.json +0 -7
- package/CONTRIBUTING.md +0 -56
- package/LICENSE +0 -20
- package/amplify.yml +0 -22
- package/commitlint.config.js +0 -1
- package/coverage/lcov-report/base.css +0 -224
- package/coverage/lcov-report/block-navigation.js +0 -87
- package/coverage/lcov-report/button-element.scss.html +0 -112
- package/coverage/lcov-report/button-element.ts.html +0 -145
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +0 -116
- package/coverage/lcov-report/prettify.css +0 -1
- package/coverage/lcov-report/prettify.js +0 -2
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +0 -196
- package/coverage/lcov.info +0 -32
- package/index.html +0 -430
- package/lib/Button/index.d.ts +0 -1
- package/lib/Button/index.js +0 -6634
- package/lib/Button/index.js.map +0 -1
- package/lib/Button/package.json +0 -7
- package/lib/Card/index.d.ts +0 -1
- package/lib/Card/index.js +0 -6150
- package/lib/Card/index.js.map +0 -1
- package/lib/Card/package.json +0 -7
- package/lib/Checkbox/index.d.ts +0 -1
- package/lib/Checkbox/index.js +0 -6366
- package/lib/Checkbox/index.js.map +0 -1
- package/lib/Checkbox/package.json +0 -7
- package/lib/Dropdown/index.d.ts +0 -3
- package/lib/Dropdown/index.js +0 -13502
- package/lib/Dropdown/index.js.map +0 -1
- package/lib/Dropdown/package.json +0 -7
- package/lib/Footer/index.d.ts +0 -2
- package/lib/Footer/index.js +0 -7168
- package/lib/Footer/index.js.map +0 -1
- package/lib/Footer/package.json +0 -7
- package/lib/Input/index.d.ts +0 -1
- package/lib/Input/index.js +0 -6656
- package/lib/Input/index.js.map +0 -1
- package/lib/Input/package.json +0 -7
- package/lib/Mainnav/index.d.ts +0 -4
- package/lib/Mainnav/index.js +0 -32546
- package/lib/Mainnav/index.js.map +0 -1
- package/lib/Mainnav/package.json +0 -7
- package/lib/Mainnav/sgds-mainnav-dropdown.d.ts +0 -5
- package/lib/Mainnav/sgds-mainnav-item.d.ts +0 -4
- package/lib/Masthead/index.d.ts +0 -1
- package/lib/Masthead/index.js +0 -7371
- package/lib/Masthead/index.js.map +0 -1
- package/lib/Masthead/package.json +0 -7
- package/lib/Modal/index.d.ts +0 -1
- package/lib/Modal/index.js +0 -6432
- package/lib/Modal/index.js.map +0 -1
- package/lib/Modal/package.json +0 -7
- package/lib/QuantityToggle/index.d.ts +0 -1
- package/lib/QuantityToggle/index.js +0 -7049
- package/lib/QuantityToggle/index.js.map +0 -1
- package/lib/QuantityToggle/package.json +0 -7
- package/lib/Radio/index.d.ts +0 -2
- package/lib/Radio/index.js +0 -12607
- package/lib/Radio/index.js.map +0 -1
- package/lib/Radio/package.json +0 -7
- package/lib/Sidenav/index.d.ts +0 -3
- package/lib/Sidenav/index.js +0 -18739
- package/lib/Sidenav/index.js.map +0 -1
- package/lib/Sidenav/package.json +0 -7
- package/lib/Sidenav/sgds-sidenav-link.d.ts +0 -4
- package/lib/Tab/index.d.ts +0 -3
- package/lib/Tab/index.js +0 -13557
- package/lib/Tab/index.js.map +0 -1
- package/lib/Tab/package.json +0 -7
- package/lib/Textarea/index.d.ts +0 -1
- package/lib/Textarea/index.js +0 -6696
- package/lib/Textarea/index.js.map +0 -1
- package/lib/Textarea/package.json +0 -7
- package/lib/index.d.ts +0 -16
- package/lib/index.js +0 -134580
- package/lib/index.js.map +0 -1
- package/lib/umd/index.js +0 -134587
- package/lib/umd/index.js.map +0 -1
- package/lib/utils/card-element.d.ts +0 -11
- package/mocks/dropdown.d.ts +0 -4
- package/mocks/dropdown.ts +0 -27
- package/mocks/link.d.ts +0 -3
- package/mocks/link.ts +0 -6
- package/rollup.config.js +0 -73
- package/rollup.test.config.js +0 -42
- package/scripts/buildUtils.js +0 -30
- package/scripts/frankBuild.js +0 -49
- package/src/Button/index.ts +0 -1
- package/src/Button/sgds-button.scss +0 -28
- package/src/Button/sgds-button.ts +0 -153
- package/src/Card/index.ts +0 -1
- package/src/Card/sgds-action-card.scss +0 -27
- package/src/Card/sgds-action-card.ts +0 -115
- package/src/Checkbox/index.ts +0 -1
- package/src/Checkbox/sgds-checkbox.scss +0 -4
- package/src/Checkbox/sgds-checkbox.ts +0 -149
- package/src/Dropdown/index.ts +0 -3
- package/src/Dropdown/sgds-dropdown-item.ts +0 -39
- package/src/Dropdown/sgds-dropdown.scss +0 -5
- package/src/Dropdown/sgds-dropdown.ts +0 -54
- package/src/Footer/index.ts +0 -3
- package/src/Footer/sgds-footer.scss +0 -5
- package/src/Footer/sgds-footer.ts +0 -121
- package/src/Input/index.ts +0 -1
- package/src/Input/sgds-input.scss +0 -20
- package/src/Input/sgds-input.ts +0 -178
- package/src/Mainnav/index.ts +0 -4
- package/src/Mainnav/sgds-mainnav-dropdown.scss +0 -13
- package/src/Mainnav/sgds-mainnav-dropdown.ts +0 -45
- package/src/Mainnav/sgds-mainnav-item.scss +0 -24
- package/src/Mainnav/sgds-mainnav-item.ts +0 -8
- package/src/Mainnav/sgds-mainnav.scss +0 -39
- package/src/Mainnav/sgds-mainnav.ts +0 -183
- package/src/Masthead/index.ts +0 -1
- package/src/Masthead/sgds-masthead.scss +0 -217
- package/src/Masthead/sgds-masthead.ts +0 -189
- package/src/Modal/index.ts +0 -1
- package/src/Modal/sgds-modal.scss +0 -128
- package/src/Modal/sgds-modal.ts +0 -309
- package/src/QuantityToggle/index.ts +0 -1
- package/src/QuantityToggle/sgds-quantitytoggle.scss +0 -10
- package/src/QuantityToggle/sgds-quantitytoggle.ts +0 -130
- package/src/Radio/index.ts +0 -2
- package/src/Radio/sgds-radio.scss +0 -5
- package/src/Radio/sgds-radio.ts +0 -120
- package/src/Radio/sgds-radiogroup.scss +0 -22
- package/src/Radio/sgds-radiogroup.ts +0 -221
- package/src/Sidenav/index.ts +0 -4
- package/src/Sidenav/sgds-sidenav-item.scss +0 -73
- package/src/Sidenav/sgds-sidenav-item.ts +0 -145
- package/src/Sidenav/sgds-sidenav-link.scss +0 -25
- package/src/Sidenav/sgds-sidenav-link.ts +0 -8
- package/src/Sidenav/sgds-sidenav.scss +0 -6
- package/src/Sidenav/sgds-sidenav.ts +0 -33
- package/src/Tab/index.ts +0 -3
- package/src/Tab/sgds-tab.scss +0 -84
- package/src/Tab/sgds-tab.ts +0 -87
- package/src/Tab/sgds-tabgroup.scss +0 -198
- package/src/Tab/sgds-tabgroup.ts +0 -295
- package/src/Tab/sgds-tabpanel.scss +0 -12
- package/src/Tab/sgds-tabpanel.ts +0 -55
- package/src/Textarea/index.ts +0 -1
- package/src/Textarea/sgds-textarea.scss +0 -23
- package/src/Textarea/sgds-textarea.ts +0 -201
- package/src/index.ts +0 -16
- package/src/utils/animate.ts +0 -69
- package/src/utils/animation-registry.ts +0 -71
- package/src/utils/base.scss +0 -14
- package/src/utils/breakpoints.ts +0 -5
- package/src/utils/card-element.ts +0 -42
- package/src/utils/components.style.scss +0 -531
- package/src/utils/defaultvalue.ts +0 -51
- package/src/utils/dropdown-element.ts +0 -244
- package/src/utils/event.ts +0 -13
- package/src/utils/form.ts +0 -183
- package/src/utils/generateId.ts +0 -4
- package/src/utils/link-element.ts +0 -34
- package/src/utils/mergeDeep.ts +0 -22
- package/src/utils/modal.ts +0 -64
- package/src/utils/object.ts +0 -2
- package/src/utils/offset.ts +0 -6
- package/src/utils/scroll.ts +0 -57
- package/src/utils/sgds-element.ts +0 -18
- package/src/utils/slot.ts +0 -102
- package/src/utils/tabbable.ts +0 -81
- package/src/utils/watch.ts +0 -62
- package/stories/ActionCard.stories.mdx +0 -199
- package/stories/Button.stories.mdx +0 -194
- package/stories/Checkbox.stories.mdx +0 -196
- package/stories/Dropdown.stories.mdx +0 -152
- package/stories/Footer.stories.mdx +0 -261
- package/stories/Input.stories.mdx +0 -236
- package/stories/MainNav.stories.mdx +0 -169
- package/stories/Masthead.stories.mdx +0 -112
- package/stories/Modal.stories.mdx +0 -103
- package/stories/QuantityToggle.stories.mdx +0 -97
- package/stories/Radio.stories.mdx +0 -262
- package/stories/Sample.stories.js +0 -29
- package/stories/Sample.stories.mdx +0 -33
- package/stories/SideNav.stories.mdx +0 -245
- package/stories/common.js +0 -185
- package/stories/textarea.stories.mdx +0 -253
- package/test/button.element.test.ts +0 -185
- package/test/checkbox.test.ts +0 -240
- package/test/dropdown.test.ts +0 -637
- package/test/footer.test.ts +0 -181
- package/test/generateId.test.ts +0 -18
- package/test/input.element.test.ts +0 -316
- package/test/link-element.test.ts +0 -38
- package/test/mainnav.test.ts +0 -313
- package/test/masthead.test.ts +0 -116
- package/test/modal.test.ts +0 -149
- package/test/quantitytoggle.test.ts +0 -76
- package/test/radio.test.ts +0 -310
- package/test/selectable-card.test.ts +0 -159
- package/test/sidenav.test.ts +0 -390
- package/test/tab.test.ts +0 -76
- package/test/textarea.test.ts +0 -126
- package/tsconfig.json +0 -26
- package/tsconfig.test.json +0 -24
- package/typings/scss.d.ts +0 -5
- package/web-dev-server.config.mjs +0 -7
- package/web-test-runner.config.mjs +0 -47
package/src/Tab/sgds-tab.scss
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
@import '../utils/components.style';
|
|
2
|
-
@import '../utils/base.scss';
|
|
3
|
-
|
|
4
|
-
:host {
|
|
5
|
-
display: inline-block;
|
|
6
|
-
|
|
7
|
-
sgds-tab {
|
|
8
|
-
+ sgds-tab{
|
|
9
|
-
margin-right: 1rem;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
.tab {
|
|
15
|
-
display: inline-flex;
|
|
16
|
-
align-items: center;
|
|
17
|
-
font-family: $font-family-sans-serif;
|
|
18
|
-
font-size: $font-size-base;
|
|
19
|
-
color: $gray-600;
|
|
20
|
-
padding: $nav-sgds-tabs-padding-y 0;
|
|
21
|
-
white-space: nowrap;
|
|
22
|
-
user-select: none;
|
|
23
|
-
cursor: pointer;
|
|
24
|
-
transition: var(--transition-speed) box-shadow, var(--transition-speed) color;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
.tab:focus {
|
|
28
|
-
outline: none;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
.tab:focus-visible:not(.tab--disabled) {
|
|
32
|
-
color: $blue-500;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
.tab:focus-visible {
|
|
36
|
-
outline: $blue-500 solid $input-btn-focus-width;
|
|
37
|
-
outline-offset: calc(-1 * #{$input-btn-focus-width} - 1px);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
.tab.tab--active:not(.tab--disabled) {
|
|
41
|
-
color: $body-color;
|
|
42
|
-
font-weight: $font-weight-bold;
|
|
43
|
-
border-bottom: solid $nav-tabs-border-width $blue-500;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
.tab.tab--disabled {
|
|
49
|
-
opacity: 0.5;
|
|
50
|
-
cursor: not-allowed;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
@media (forced-colors: active) {
|
|
55
|
-
.tab.tab--active:not(.tab--disabled) {
|
|
56
|
-
outline: solid 1px transparent;
|
|
57
|
-
outline-offset: -3px;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
.tab {
|
|
62
|
-
::slotted(i){
|
|
63
|
-
margin-top:-4px;
|
|
64
|
-
margin-right: 0.5rem;
|
|
65
|
-
}
|
|
66
|
-
::slotted(.badge){
|
|
67
|
-
margin-left: 0.5rem;
|
|
68
|
-
}
|
|
69
|
-
&--basic-toggle{
|
|
70
|
-
background-color: $white;
|
|
71
|
-
border: 1px solid $gray-400;
|
|
72
|
-
border-radius: 0;
|
|
73
|
-
color: #1d2939;
|
|
74
|
-
padding: 0.75rem 1.5rem;
|
|
75
|
-
+ .tab--basic-toggle{
|
|
76
|
-
margin-left: -2px;
|
|
77
|
-
}
|
|
78
|
-
&.tab--active:not(.tab--disabled){
|
|
79
|
-
background: var(--indicator-color);
|
|
80
|
-
color: white;
|
|
81
|
-
border-bottom: 1px solid $gray-400;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}
|
package/src/Tab/sgds-tab.ts
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { html } from "lit";
|
|
2
|
-
import { customElement, property, query, state } from "lit/decorators.js";
|
|
3
|
-
import { classMap } from "lit/directives/class-map.js";
|
|
4
|
-
import SgdsElement from "../utils/sgds-element";
|
|
5
|
-
import { watch } from "../utils/watch";
|
|
6
|
-
import styles from "./sgds-tab.scss";
|
|
7
|
-
|
|
8
|
-
let id = 0;
|
|
9
|
-
|
|
10
|
-
@customElement("sgds-tab")
|
|
11
|
-
export class SgdsTab extends SgdsElement {
|
|
12
|
-
static styles = styles;
|
|
13
|
-
@query(".tab") tab: HTMLElement;
|
|
14
|
-
|
|
15
|
-
private readonly attrId = ++id;
|
|
16
|
-
private readonly componentId = `sgds-tab-${this.attrId}`;
|
|
17
|
-
|
|
18
|
-
@property({ reflect: true }) label = "";
|
|
19
|
-
/** The name of the tab panel this tab is associated with. The panel must be located in the same tab group. */
|
|
20
|
-
@property({ reflect: true }) panel = "";
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
/** Draws the tab in an active state. */
|
|
26
|
-
@property({ type: Boolean, reflect: true }) active = false;
|
|
27
|
-
|
|
28
|
-
/** Makes the tab closable and shows a close button. */
|
|
29
|
-
@property({ type: Boolean }) closable = false;
|
|
30
|
-
|
|
31
|
-
/** Disables the tab and prevents selection. */
|
|
32
|
-
@property({ type: Boolean, reflect: true }) disabled = false;
|
|
33
|
-
|
|
34
|
-
@property({ type: Boolean, reflect: true }) variant;
|
|
35
|
-
|
|
36
|
-
connectedCallback() {
|
|
37
|
-
super.connectedCallback();
|
|
38
|
-
this.setAttribute("role", "tab");
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/** Sets focus to the tab. */
|
|
42
|
-
focus(options?: FocusOptions) {
|
|
43
|
-
this.tab.focus(options);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/** Removes focus from the tab. */
|
|
47
|
-
blur() {
|
|
48
|
-
this.tab.blur();
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
handleCloseClick() {
|
|
52
|
-
this.emit("sgds-close");
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
@watch("active")
|
|
56
|
-
handleActiveChange() {
|
|
57
|
-
this.setAttribute("aria-selected", this.active ? "true" : "false");
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
@watch("disabled")
|
|
61
|
-
handleDisabledChange() {
|
|
62
|
-
this.setAttribute("aria-disabled", this.disabled ? "true" : "false");
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
render() {
|
|
66
|
-
// If the user didn't provide an ID, we'll set one so we can link tabs and tab panels with aria labels
|
|
67
|
-
this.id = this.id.length > 0 ? this.id : this.componentId;
|
|
68
|
-
|
|
69
|
-
const getAttr = this.closest('sgds-tab').getAttribute('variant')
|
|
70
|
-
|
|
71
|
-
return html`
|
|
72
|
-
<div
|
|
73
|
-
part="base"
|
|
74
|
-
class=${classMap({
|
|
75
|
-
tab: true,
|
|
76
|
-
"tab--active": this.active,
|
|
77
|
-
"tab--closable": this.closable,
|
|
78
|
-
"tab--disabled": this.disabled,
|
|
79
|
-
[`tab--${getAttr}`]: getAttr
|
|
80
|
-
})}
|
|
81
|
-
tabindex=${this.disabled ? "-1" : "0"}
|
|
82
|
-
>
|
|
83
|
-
<slot></slot>
|
|
84
|
-
</div>
|
|
85
|
-
`;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
@@ -1,198 +0,0 @@
|
|
|
1
|
-
@import '../utils/components.style';
|
|
2
|
-
@import '../utils/base.scss';
|
|
3
|
-
:host {
|
|
4
|
-
--indicator-color: #0f71bb;
|
|
5
|
-
--track-color: transparent;
|
|
6
|
-
--track-width: 2px;
|
|
7
|
-
display: block;
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
.tab-group {
|
|
11
|
-
display: flex;
|
|
12
|
-
border-radius: 0;
|
|
13
|
-
}
|
|
14
|
-
.tab-group__tabs {
|
|
15
|
-
display: flex;
|
|
16
|
-
position: relative;
|
|
17
|
-
}
|
|
18
|
-
.tab-group__indicator {
|
|
19
|
-
position: absolute;
|
|
20
|
-
// transition: var(--sl-transition-fast) translate ease, var(--sl-transition-fast) width ease;
|
|
21
|
-
}
|
|
22
|
-
.tab-group--has-scroll-controls .tab-group__nav-container {
|
|
23
|
-
position: relative;
|
|
24
|
-
padding: 0 var(--sl-spacing-x-large);
|
|
25
|
-
}
|
|
26
|
-
.tab-group__body {
|
|
27
|
-
display: block;
|
|
28
|
-
overflow: auto;
|
|
29
|
-
}
|
|
30
|
-
.tab-group__scroll-button {
|
|
31
|
-
display: flex;
|
|
32
|
-
align-items: center;
|
|
33
|
-
justify-content: center;
|
|
34
|
-
position: absolute;
|
|
35
|
-
top: 0;
|
|
36
|
-
bottom: 0;
|
|
37
|
-
width: var(--sl-spacing-x-large);
|
|
38
|
-
}
|
|
39
|
-
.tab-group__scroll-button--start {
|
|
40
|
-
left: 0;
|
|
41
|
-
}
|
|
42
|
-
.tab-group__scroll-button--end {
|
|
43
|
-
right: 0;
|
|
44
|
-
}
|
|
45
|
-
.tab-group--rtl .tab-group__scroll-button--start {
|
|
46
|
-
left: auto;
|
|
47
|
-
right: 0;
|
|
48
|
-
}
|
|
49
|
-
.tab-group--rtl .tab-group__scroll-button--end {
|
|
50
|
-
left: 0;
|
|
51
|
-
right: auto;
|
|
52
|
-
}
|
|
53
|
-
/*
|
|
54
|
-
* Top
|
|
55
|
-
*/
|
|
56
|
-
.tab-group--top {
|
|
57
|
-
flex-direction: column;
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
.tab-group--top .tab-group__nav-container {
|
|
61
|
-
order: 1;
|
|
62
|
-
}
|
|
63
|
-
.tab-group--top .tab-group__nav {
|
|
64
|
-
display: flex;
|
|
65
|
-
overflow-x: auto;
|
|
66
|
-
/* Hide scrollbar in Firefox */
|
|
67
|
-
scrollbar-width: none;
|
|
68
|
-
}
|
|
69
|
-
/* Hide scrollbar in Chrome/Safari */
|
|
70
|
-
.tab-group--top .tab-group__nav::-webkit-scrollbar {
|
|
71
|
-
width: 0;
|
|
72
|
-
height: 0;
|
|
73
|
-
}
|
|
74
|
-
.tab-group--top .tab-group__tabs {
|
|
75
|
-
flex: 1 1 auto;
|
|
76
|
-
position: relative;
|
|
77
|
-
flex-direction: row;
|
|
78
|
-
border-bottom: solid $nav-tabs-border-width transparent;
|
|
79
|
-
gap: 1rem;
|
|
80
|
-
|
|
81
|
-
}
|
|
82
|
-
.tab-group--top .tab-group__indicator {
|
|
83
|
-
bottom: calc(-1 * #{$nav-tabs-border-width});
|
|
84
|
-
// border-bottom: solid $nav-tabs-border-width $blue-500;
|
|
85
|
-
}
|
|
86
|
-
.tab-group--top .tab-group__body {
|
|
87
|
-
order: 2;
|
|
88
|
-
}
|
|
89
|
-
.tab-group--top ::slotted(sl-tab-panel) {
|
|
90
|
-
--padding: var(--sl-spacing-medium) 0;
|
|
91
|
-
}
|
|
92
|
-
/*
|
|
93
|
-
* Bottom
|
|
94
|
-
*/
|
|
95
|
-
.tab-group--bottom {
|
|
96
|
-
flex-direction: column;
|
|
97
|
-
}
|
|
98
|
-
.tab-group--bottom .tab-group__nav-container {
|
|
99
|
-
order: 2;
|
|
100
|
-
}
|
|
101
|
-
.tab-group--bottom .tab-group__nav {
|
|
102
|
-
display: flex;
|
|
103
|
-
overflow-x: auto;
|
|
104
|
-
/* Hide scrollbar in Firefox */
|
|
105
|
-
scrollbar-width: none;
|
|
106
|
-
}
|
|
107
|
-
/* Hide scrollbar in Chrome/Safari */
|
|
108
|
-
.tab-group--bottom .tab-group__nav::-webkit-scrollbar {
|
|
109
|
-
width: 0;
|
|
110
|
-
height: 0;
|
|
111
|
-
}
|
|
112
|
-
.tab-group--bottom .tab-group__tabs {
|
|
113
|
-
flex: 1 1 auto;
|
|
114
|
-
position: relative;
|
|
115
|
-
flex-direction: row;
|
|
116
|
-
border-top: solid $nav-tabs-border-width transparent;
|
|
117
|
-
}
|
|
118
|
-
.tab-group--bottom .tab-group__indicator {
|
|
119
|
-
top: calc(-1 * #{$nav-tabs-border-width});
|
|
120
|
-
border-top: solid $nav-tabs-border-width $blue-500;
|
|
121
|
-
}
|
|
122
|
-
.tab-group--bottom .tab-group__body {
|
|
123
|
-
order: 1;
|
|
124
|
-
}
|
|
125
|
-
.tab-group--bottom ::slotted(sl-tab-panel) {
|
|
126
|
-
--padding: var(--sl-spacing-medium) 0;
|
|
127
|
-
}
|
|
128
|
-
/*
|
|
129
|
-
* Start
|
|
130
|
-
*/
|
|
131
|
-
.tab-group--start {
|
|
132
|
-
flex-direction: row;
|
|
133
|
-
}
|
|
134
|
-
.tab-group--start .tab-group__nav-container {
|
|
135
|
-
order: 1;
|
|
136
|
-
}
|
|
137
|
-
.tab-group--start .tab-group__tabs {
|
|
138
|
-
flex: 0 0 auto;
|
|
139
|
-
flex-direction: column;
|
|
140
|
-
border-inline-end: solid $nav-tabs-border-width transparent;
|
|
141
|
-
}
|
|
142
|
-
.tab-group--start .tab-group__indicator {
|
|
143
|
-
right: calc(-1 * #{$nav-tabs-border-width});
|
|
144
|
-
border-right: solid $nav-tabs-border-width $blue-500;
|
|
145
|
-
}
|
|
146
|
-
.tab-group--start.tab-group--rtl .tab-group__indicator {
|
|
147
|
-
right: auto;
|
|
148
|
-
left: calc(-1 * #{$nav-tabs-border-width});
|
|
149
|
-
}
|
|
150
|
-
.tab-group--start .tab-group__body {
|
|
151
|
-
flex: 1 1 auto;
|
|
152
|
-
order: 2;
|
|
153
|
-
}
|
|
154
|
-
.tab-group--start ::slotted(sl-tab-panel) {
|
|
155
|
-
--padding: 0 var(--sl-spacing-medium);
|
|
156
|
-
}
|
|
157
|
-
/*
|
|
158
|
-
* End
|
|
159
|
-
*/
|
|
160
|
-
.tab-group--end {
|
|
161
|
-
flex-direction: row;
|
|
162
|
-
}
|
|
163
|
-
.tab-group--end .tab-group__nav-container {
|
|
164
|
-
order: 2;
|
|
165
|
-
}
|
|
166
|
-
.tab-group--end .tab-group__tabs {
|
|
167
|
-
flex: 0 0 auto;
|
|
168
|
-
flex-direction: column;
|
|
169
|
-
border-left: solid $nav-tabs-border-width transparent;
|
|
170
|
-
}
|
|
171
|
-
.tab-group--end .tab-group__indicator {
|
|
172
|
-
left: calc(-1 * #{$nav-tabs-border-width});
|
|
173
|
-
border-inline-start: solid $nav-tabs-border-width $blue-500;
|
|
174
|
-
}
|
|
175
|
-
.tab-group--end.tab-group--rtl .tab-group__indicator {
|
|
176
|
-
right: calc(-1 * #{$nav-tabs-border-width});
|
|
177
|
-
left: auto;
|
|
178
|
-
}
|
|
179
|
-
.tab-group--end .tab-group__body {
|
|
180
|
-
flex: 1 1 auto;
|
|
181
|
-
order: 1;
|
|
182
|
-
}
|
|
183
|
-
.tab-group--end ::slotted(sl-tab-panel) {
|
|
184
|
-
--padding: 0 var(--sl-spacing-medium);
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
.tab-group--top{
|
|
188
|
-
&.tab-group--basic-toggle .tab-group__tabs {
|
|
189
|
-
gap:0;
|
|
190
|
-
::slotted(sgds-tab){
|
|
191
|
-
margin-right: -2px;
|
|
192
|
-
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
package/src/Tab/sgds-tabgroup.ts
DELETED
|
@@ -1,295 +0,0 @@
|
|
|
1
|
-
import { html } from 'lit';
|
|
2
|
-
import { customElement, property, query, state } from 'lit/decorators.js';
|
|
3
|
-
import { classMap } from 'lit/directives/class-map.js';
|
|
4
|
-
import { scrollIntoView } from '../utils/scroll';
|
|
5
|
-
import SgdsElement from "../utils/sgds-element";
|
|
6
|
-
import { watch } from "../utils/watch";
|
|
7
|
-
import styles from "./sgds-tabgroup.scss";
|
|
8
|
-
import { SgdsTabPanel } from './sgds-tabpanel';
|
|
9
|
-
import { SgdsTab } from './sgds-tab';
|
|
10
|
-
|
|
11
|
-
@customElement('sgds-tab-group')
|
|
12
|
-
export class SgdsTabGroup extends SgdsElement {
|
|
13
|
-
static styles = styles;
|
|
14
|
-
|
|
15
|
-
@query('.tab-group') tabGroup: HTMLElement;
|
|
16
|
-
@query('.tab-group__body') body: HTMLSlotElement;
|
|
17
|
-
@query('.tab-group__nav') nav: HTMLElement;
|
|
18
|
-
|
|
19
|
-
private activeTab?: SgdsTab;
|
|
20
|
-
private mutationObserver: MutationObserver;
|
|
21
|
-
private resizeObserver: ResizeObserver;
|
|
22
|
-
private tabs: SgdsTab[] = [];
|
|
23
|
-
private panels: SgdsTabPanel[] = [];
|
|
24
|
-
|
|
25
|
-
@state() private hasScrollControls = false;
|
|
26
|
-
|
|
27
|
-
/** The placement of the tabs. */
|
|
28
|
-
@property() placement: 'top' | 'bottom' | 'start' | 'end' = 'top';
|
|
29
|
-
|
|
30
|
-
@property({reflect: true}) TabVariant: 'basic-toggle' | 'info-toggle';
|
|
31
|
-
/**
|
|
32
|
-
* When set to auto, navigating tabs with the arrow keys will instantly show the corresponding tab panel. When set to
|
|
33
|
-
* manual, the tab will receive focus but will not show until the user presses spacebar or enter.
|
|
34
|
-
*/
|
|
35
|
-
@property() activation: 'auto' | 'manual' = 'auto';
|
|
36
|
-
|
|
37
|
-
/** Disables the scroll arrows that appear when tabs overflow. */
|
|
38
|
-
@property({ attribute: 'no-scroll-controls', type: Boolean }) noScrollControls = false;
|
|
39
|
-
|
|
40
|
-
connectedCallback() {
|
|
41
|
-
super.connectedCallback();
|
|
42
|
-
|
|
43
|
-
this.resizeObserver = new ResizeObserver(() => {
|
|
44
|
-
this.updateScrollControls();
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
this.mutationObserver = new MutationObserver(mutations => {
|
|
48
|
-
// Update aria labels when the DOM changes
|
|
49
|
-
if (mutations.some(m => !['aria-labelledby', 'aria-controls'].includes(m.attributeName!))) {
|
|
50
|
-
setTimeout(() => this.setAriaLabels());
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// Sync tabs when disabled states change
|
|
54
|
-
if (mutations.some(m => m.attributeName === 'disabled')) {
|
|
55
|
-
this.syncTabsAndPanels();
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
this.updateComplete.then(() => {
|
|
60
|
-
this.syncTabsAndPanels();
|
|
61
|
-
this.mutationObserver.observe(this, { attributes: true, childList: true, subtree: true });
|
|
62
|
-
this.resizeObserver.observe(this.nav);
|
|
63
|
-
|
|
64
|
-
// Set initial tab state when the tabs first become visible
|
|
65
|
-
const intersectionObserver = new IntersectionObserver((entries, observer) => {
|
|
66
|
-
if (entries[0].intersectionRatio > 0) {
|
|
67
|
-
this.setAriaLabels();
|
|
68
|
-
this.setTabVariant();
|
|
69
|
-
this.setActiveTab(this.getActiveTab() ?? this.tabs[0], { emitEvents: false });
|
|
70
|
-
observer.unobserve(entries[0].target);
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
intersectionObserver.observe(this.tabGroup);
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
disconnectedCallback() {
|
|
78
|
-
this.mutationObserver.disconnect();
|
|
79
|
-
this.resizeObserver.unobserve(this.nav);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/** Shows the specified tab panel. */
|
|
83
|
-
show(panel: string) {
|
|
84
|
-
const tab = this.tabs.find(el => el.panel === panel);
|
|
85
|
-
|
|
86
|
-
if (tab) {
|
|
87
|
-
this.setActiveTab(tab, { scrollBehavior: 'smooth' });
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
getAllTabs(options: { includeDisabled: boolean } = { includeDisabled: true }) {
|
|
92
|
-
const slot = this.shadowRoot!.querySelector<HTMLSlotElement>('slot[name="nav"]')!;
|
|
93
|
-
|
|
94
|
-
return [...(slot.assignedElements() as SgdsTab[])].filter(el => {
|
|
95
|
-
return options.includeDisabled
|
|
96
|
-
? el.tagName.toLowerCase() === 'sgds-tab'
|
|
97
|
-
: el.tagName.toLowerCase() === 'sgds-tab' && !el.disabled;
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
getAllPanels() {
|
|
102
|
-
return [...this.body.assignedElements()].filter(el => el.tagName.toLowerCase() === 'sgds-tab-panel') as [SgdsTabPanel];
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
getActiveTab() {
|
|
106
|
-
return this.tabs.find(el => el.active);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
handleClick(event: MouseEvent) {
|
|
110
|
-
const target = event.target as HTMLElement;
|
|
111
|
-
const tab = target.closest('sgds-tab') as SgdsTab;
|
|
112
|
-
const tabGroup = tab?.closest('sgds-tab-group');
|
|
113
|
-
|
|
114
|
-
// Ensure the target tab is in this tab group
|
|
115
|
-
if (tabGroup !== this) {
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
if (tab !== null) {
|
|
120
|
-
this.setActiveTab(tab, { scrollBehavior: 'smooth' });
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
handleKeyDown(event: KeyboardEvent) {
|
|
125
|
-
const target = event.target as HTMLElement;
|
|
126
|
-
const tab = target.closest('sgds-tab') as SgdsTab;
|
|
127
|
-
const tabGroup = tab?.closest('sgds-tab-group');
|
|
128
|
-
|
|
129
|
-
// Ensure the target tab is in this tab group
|
|
130
|
-
if (tabGroup !== this) {
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
// Activate a tab
|
|
135
|
-
if (['Enter', ' '].includes(event.key)) {
|
|
136
|
-
if (tab !== null) {
|
|
137
|
-
this.setActiveTab(tab, { scrollBehavior: 'smooth' });
|
|
138
|
-
event.preventDefault();
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
// Move focus left or right
|
|
143
|
-
if (['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown', 'Home', 'End'].includes(event.key)) {
|
|
144
|
-
const activeEl = this.tabs.find(t => t.matches(':focus'));
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
if (activeEl?.tagName.toLowerCase() === 'sgds-tab') {
|
|
148
|
-
let index = this.tabs.indexOf(activeEl);
|
|
149
|
-
|
|
150
|
-
if (event.key === 'Home') {
|
|
151
|
-
index = 0;
|
|
152
|
-
} else if (event.key === 'End') {
|
|
153
|
-
index = this.tabs.length - 1;
|
|
154
|
-
} else if (
|
|
155
|
-
['top', 'bottom'].includes(this.placement) ||
|
|
156
|
-
(['start', 'end'].includes(this.placement) && event.key === 'ArrowUp')
|
|
157
|
-
) {
|
|
158
|
-
index--;
|
|
159
|
-
} else if (
|
|
160
|
-
['top', 'bottom'].includes(this.placement) ||
|
|
161
|
-
(['start', 'end'].includes(this.placement) && event.key === 'ArrowDown')
|
|
162
|
-
) {
|
|
163
|
-
index++;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
if (index < 0) {
|
|
167
|
-
index = this.tabs.length - 1;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
if (index > this.tabs.length - 1) {
|
|
171
|
-
index = 0;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
this.tabs[index].focus({ preventScroll: true });
|
|
175
|
-
|
|
176
|
-
if (this.activation === 'auto') {
|
|
177
|
-
this.setActiveTab(this.tabs[index], { scrollBehavior: 'smooth' });
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
if (['top', 'bottom'].includes(this.placement)) {
|
|
181
|
-
scrollIntoView(this.tabs[index], this.nav, 'horizontal');
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
event.preventDefault();
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
handleScrollToStart() {
|
|
190
|
-
this.nav.scroll({
|
|
191
|
-
left: this.nav.scrollLeft - this.nav.clientWidth,
|
|
192
|
-
behavior: 'smooth'
|
|
193
|
-
});
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
handleScrollToEnd() {
|
|
197
|
-
this.nav.scroll({
|
|
198
|
-
left: this.nav.scrollLeft + this.nav.clientWidth,
|
|
199
|
-
behavior: 'smooth'
|
|
200
|
-
});
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
@watch('noScrollControls', { waitUntilFirstUpdate: true })
|
|
204
|
-
updateScrollControls() {
|
|
205
|
-
if (this.noScrollControls) {
|
|
206
|
-
this.hasScrollControls = false;
|
|
207
|
-
} else {
|
|
208
|
-
this.hasScrollControls =
|
|
209
|
-
['top', 'bottom'].includes(this.placement) && this.nav.scrollWidth > this.nav.clientWidth;
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
setActiveTab(tab: SgdsTab, options?: { emitEvents?: boolean; scrollBehavior?: 'auto' | 'smooth' }) {
|
|
214
|
-
options = {
|
|
215
|
-
emitEvents: true,
|
|
216
|
-
scrollBehavior: 'auto',
|
|
217
|
-
...options
|
|
218
|
-
};
|
|
219
|
-
|
|
220
|
-
if (tab !== this.activeTab && !tab.disabled) {
|
|
221
|
-
const previousTab = this.activeTab;
|
|
222
|
-
this.activeTab = tab;
|
|
223
|
-
|
|
224
|
-
// Sync active tab and panel
|
|
225
|
-
this.tabs.map(el => (el.active = el === this.activeTab));
|
|
226
|
-
this.panels.map(el => (el.active = el.name === this.activeTab?.panel));
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
if (['top', 'bottom'].includes(this.placement)) {
|
|
230
|
-
scrollIntoView(this.activeTab, this.nav, 'horizontal', options.scrollBehavior);
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
// Emit events
|
|
234
|
-
if (options.emitEvents) {
|
|
235
|
-
if (previousTab) {
|
|
236
|
-
this.emit('sgds-tab-hide', { detail: { name: previousTab.panel } });
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
this.emit('sgds-tab-show', { detail: { name: this.activeTab.panel } });
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
setAriaLabels() {
|
|
245
|
-
// Link each tab with its corresponding panel
|
|
246
|
-
this.tabs.forEach(tab => {
|
|
247
|
-
const panel = this.panels.find(el => el.name === tab.panel);
|
|
248
|
-
if (panel) {
|
|
249
|
-
tab.setAttribute('aria-controls', panel.getAttribute('id')!);
|
|
250
|
-
panel.setAttribute('aria-labelledby', tab.getAttribute('id')!);
|
|
251
|
-
}
|
|
252
|
-
});
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
setTabVariant() {
|
|
256
|
-
// Link each tab with its corresponding panel
|
|
257
|
-
this.tabs.forEach(tab => {
|
|
258
|
-
tab.setAttribute('variant', this.TabVariant);
|
|
259
|
-
});
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
// This stores tabs and panels so we can refer to a cache instead of calling querySelectorAll() multiple times.
|
|
263
|
-
syncTabsAndPanels() {
|
|
264
|
-
this.tabs = this.getAllTabs({ includeDisabled: false });
|
|
265
|
-
this.panels = this.getAllPanels();
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
render() {
|
|
269
|
-
return html`
|
|
270
|
-
<div
|
|
271
|
-
part="base"
|
|
272
|
-
class=${classMap({
|
|
273
|
-
'tab-group': true,
|
|
274
|
-
'tab-group--top': this.placement === 'top',
|
|
275
|
-
'tab-group--bottom': this.placement === 'bottom',
|
|
276
|
-
'tab-group--start': this.placement === 'start',
|
|
277
|
-
'tab-group--end': this.placement === 'end',
|
|
278
|
-
'tab-group--basic-toggle': this.TabVariant === 'basic-toggle',
|
|
279
|
-
'tab-group--info-toggle': this.TabVariant === 'info-toggle',
|
|
280
|
-
})}
|
|
281
|
-
@click=${this.handleClick}
|
|
282
|
-
@keydown=${this.handleKeyDown}
|
|
283
|
-
>
|
|
284
|
-
<div class="tab-group__nav-container" part="nav">
|
|
285
|
-
<div class="tab-group__nav">
|
|
286
|
-
<div part="tabs" class="tab-group__tabs" role="tablist">
|
|
287
|
-
<slot name="nav" @slotchange=${this.syncTabsAndPanels}></slot>
|
|
288
|
-
</div>
|
|
289
|
-
</div>
|
|
290
|
-
</div>
|
|
291
|
-
<slot part="body" class="tab-group__body" @slotchange=${this.syncTabsAndPanels}></slot>
|
|
292
|
-
</div>
|
|
293
|
-
`;
|
|
294
|
-
}
|
|
295
|
-
}
|