@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/Radio/sgds-radio.ts
DELETED
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import { html } from "lit";
|
|
2
|
-
import { customElement, property, state } from "lit/decorators.js";
|
|
3
|
-
import { classMap } from "lit/directives/class-map.js";
|
|
4
|
-
import { watch } from "../utils/watch";
|
|
5
|
-
import styles from "./sgds-radio.scss";
|
|
6
|
-
import SgdsElement from "../utils/sgds-element";
|
|
7
|
-
import { ifDefined } from "lit/directives/if-defined.js";
|
|
8
|
-
import { live } from "lit/directives/live.js";
|
|
9
|
-
import genId from "../utils/generateId";
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
@customElement("sgds-radio")
|
|
13
|
-
export class SgdsRadio extends SgdsElement {
|
|
14
|
-
static styles = styles;
|
|
15
|
-
|
|
16
|
-
@state() checked = false;
|
|
17
|
-
@state() protected hasFocus = false;
|
|
18
|
-
|
|
19
|
-
/** The radio's value attribute. */
|
|
20
|
-
@property() value: string;
|
|
21
|
-
|
|
22
|
-
/** For id/for pair of the HTML form control. */
|
|
23
|
-
@property({ type: String, reflect: true }) radioId = genId("radio");
|
|
24
|
-
|
|
25
|
-
/** Disables the radio. */
|
|
26
|
-
@property({ type: Boolean, reflect: true }) disabled = false;
|
|
27
|
-
|
|
28
|
-
/** Aligns the radios horizontally */
|
|
29
|
-
@property({ type: Boolean, reflect: true }) isInline = false;
|
|
30
|
-
|
|
31
|
-
/** For aria-label */
|
|
32
|
-
@property({ type: String, reflect: true }) ariaLabel = "";
|
|
33
|
-
|
|
34
|
-
connectedCallback(): void {
|
|
35
|
-
super.connectedCallback();
|
|
36
|
-
this.setInitialAttributes();
|
|
37
|
-
this.addEventListeners();
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
@watch("checked")
|
|
41
|
-
handleCheckedChange() {
|
|
42
|
-
this.setAttribute("aria-checked", this.checked ? "true" : "false");
|
|
43
|
-
this.setAttribute("tabindex", this.checked ? "0" : "-1");
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
@watch("disabled", { waitUntilFirstUpdate: true })
|
|
47
|
-
handleDisabledChange() {
|
|
48
|
-
this.setAttribute("aria-disabled", this.disabled ? "true" : "false");
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
private handleBlur() {
|
|
52
|
-
this.hasFocus = false;
|
|
53
|
-
this.emit('sgds-blur');
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
private handleClick() {
|
|
57
|
-
if (!this.disabled) {
|
|
58
|
-
this.checked = true;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
private handleFocus() {
|
|
63
|
-
this.hasFocus = true;
|
|
64
|
-
this.emit('sgds-focus');
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
private addEventListeners() {
|
|
68
|
-
this.addEventListener('blur', () => this.handleBlur());
|
|
69
|
-
this.addEventListener('click', () => this.handleClick());
|
|
70
|
-
this.addEventListener('focus', () => this.handleFocus());
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
private setInitialAttributes() {
|
|
74
|
-
this.setAttribute("role", "radio");
|
|
75
|
-
this.setAttribute("tabindex", "-1");
|
|
76
|
-
this.setAttribute("aria-disabled", this.disabled ? "true" : "false");
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
render() {
|
|
80
|
-
return html`
|
|
81
|
-
<div
|
|
82
|
-
part="base"
|
|
83
|
-
class=${classMap({
|
|
84
|
-
"form-check": true,
|
|
85
|
-
"form-check-inline": this.isInline,
|
|
86
|
-
})}
|
|
87
|
-
>
|
|
88
|
-
<input
|
|
89
|
-
part="control"
|
|
90
|
-
class=${classMap({
|
|
91
|
-
"form-check-input": true,
|
|
92
|
-
})}
|
|
93
|
-
type="radio"
|
|
94
|
-
id=${ifDefined(this.radioId)}
|
|
95
|
-
value=${ifDefined(this.value)}
|
|
96
|
-
.checked=${live(this.checked)}
|
|
97
|
-
?disabled=${this.disabled}
|
|
98
|
-
aria-disabled=${this.disabled ? "true" : "false"}
|
|
99
|
-
aria-checked=${this.checked ? "true" : "false"}
|
|
100
|
-
@click=${this.handleClick}
|
|
101
|
-
/>
|
|
102
|
-
<label
|
|
103
|
-
part="label"
|
|
104
|
-
for="${ifDefined(this.radioId)}"
|
|
105
|
-
aria-label=${ifDefined(this.ariaLabel)}
|
|
106
|
-
class="form-check-label"
|
|
107
|
-
><slot></slot
|
|
108
|
-
></label>
|
|
109
|
-
</div>
|
|
110
|
-
`;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
declare global {
|
|
115
|
-
interface HTMLElementTagNameMap {
|
|
116
|
-
'sgds-radio': SgdsRadio;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
export default SgdsRadio;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
@import "../utils/base.scss";
|
|
2
|
-
@import "~@govtechsg/sgds/sass/forms/form-check";
|
|
3
|
-
@import "~@govtechsg/sgds/sass/forms/labels";
|
|
4
|
-
@import "~@govtechsg/sgds/sass/forms/validation";
|
|
5
|
-
@import "~@govtechsg/sgds/sass/forms/form-text";
|
|
6
|
-
@import "~@govtechsg/sgds/sass/forms/form-control";
|
|
7
|
-
@import "~@govtechsg/sgds/sass/forms/form-control-group";
|
|
8
|
-
@import "~@govtechsg/sgds/sass/forms/input-group";
|
|
9
|
-
|
|
10
|
-
.visually-hidden {
|
|
11
|
-
position: absolute;
|
|
12
|
-
width: 1px;
|
|
13
|
-
height: 1px;
|
|
14
|
-
padding: 0;
|
|
15
|
-
margin: -1px;
|
|
16
|
-
overflow: hidden;
|
|
17
|
-
clip: rect(0, 0, 0, 0);
|
|
18
|
-
white-space: nowrap;
|
|
19
|
-
border: 0;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
|
|
@@ -1,221 +0,0 @@
|
|
|
1
|
-
import { html, css } from "lit";
|
|
2
|
-
import { customElement, property, state, query } from "lit/decorators.js";
|
|
3
|
-
import { classMap } from "lit/directives/class-map.js";
|
|
4
|
-
import { watch } from "../utils/watch";
|
|
5
|
-
import styles from "./sgds-radiogroup.scss";
|
|
6
|
-
import SgdsElement from "../utils/sgds-element";
|
|
7
|
-
import SgdsRadio from "./sgds-radio";
|
|
8
|
-
import { FormSubmitController } from "../utils/form";
|
|
9
|
-
|
|
10
|
-
@customElement("sgds-radiogroup")
|
|
11
|
-
export class SgdsRadioGroup extends SgdsElement {
|
|
12
|
-
static styles = styles;
|
|
13
|
-
|
|
14
|
-
protected readonly formSubmitController = new FormSubmitController(this, {
|
|
15
|
-
defaultValue: (control: SgdsRadioGroup) => control.defaultValue,
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
@query("slot:not([name])") defaultSlot: HTMLSlotElement;
|
|
19
|
-
@query(".radio-group__validation-input") input: HTMLInputElement;
|
|
20
|
-
|
|
21
|
-
@state() private defaultValue = "";
|
|
22
|
-
@state() private customErrorMessage = "";
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* The radio group label. Required for proper accessibility. If you need to display HTML, you can use the `label` slot
|
|
26
|
-
* instead.
|
|
27
|
-
*/
|
|
28
|
-
@property() label = "";
|
|
29
|
-
|
|
30
|
-
/** The selected value of the control. */
|
|
31
|
-
@property({ reflect: true }) value = "";
|
|
32
|
-
|
|
33
|
-
/** The name assigned to the radio controls. */
|
|
34
|
-
@property({ reflect: true }) name = "option";
|
|
35
|
-
|
|
36
|
-
/** Ensures a child radio is checked before allowing the containing form to submit. */
|
|
37
|
-
@property({ type: Boolean, reflect: true }) required = false;
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* This will be true when the control is in an invalid state.
|
|
41
|
-
*/
|
|
42
|
-
@property({ type: Boolean, reflect: true }) invalid = false;
|
|
43
|
-
|
|
44
|
-
@property({ type: String, reflect: true }) invalidFeedback =
|
|
45
|
-
"default feedback";
|
|
46
|
-
|
|
47
|
-
@watch("value")
|
|
48
|
-
handleValueChange() {
|
|
49
|
-
if (this.hasUpdated) {
|
|
50
|
-
this.emit("sgds-change");
|
|
51
|
-
this.updateCheckedRadio();
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
connectedCallback() {
|
|
56
|
-
super.connectedCallback();
|
|
57
|
-
this.defaultValue = this.value;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
get validity(): ValidityState {
|
|
61
|
-
const hasMissingData = !((this.value && this.required) || !this.required);
|
|
62
|
-
const hasCustomError = this.customErrorMessage !== "";
|
|
63
|
-
return {
|
|
64
|
-
badInput: false,
|
|
65
|
-
customError: hasCustomError,
|
|
66
|
-
patternMismatch: false,
|
|
67
|
-
rangeOverflow: false,
|
|
68
|
-
rangeUnderflow: false,
|
|
69
|
-
stepMismatch: false,
|
|
70
|
-
tooLong: false,
|
|
71
|
-
tooShort: false,
|
|
72
|
-
typeMismatch: false,
|
|
73
|
-
valid: hasMissingData ? false : true,
|
|
74
|
-
valueMissing: !hasMissingData,
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/** Checks for validity and shows the browser's validation message if the control is invalid. */
|
|
79
|
-
reportValidity(): boolean {
|
|
80
|
-
const validity = this.validity;
|
|
81
|
-
|
|
82
|
-
// this.errorMessage = this.customErrorMessage || validity.valid ? '' : this.input.validationMessage;
|
|
83
|
-
// this.invalid = !this.input.checkValidity();
|
|
84
|
-
this.invalid = !validity.valid;
|
|
85
|
-
|
|
86
|
-
if (!validity.valid) {
|
|
87
|
-
this.showNativeErrorMessage();
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
return !this.invalid;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
private getAllRadios() {
|
|
94
|
-
return [...this.querySelectorAll<SgdsRadio>("sgds-radio")];
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
handleRadioClick(event: MouseEvent) {
|
|
98
|
-
const target = event.target as SgdsRadio;
|
|
99
|
-
|
|
100
|
-
if (target.disabled) {
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
this.value = target.value;
|
|
105
|
-
const radios = this.getAllRadios();
|
|
106
|
-
radios.forEach((radio) => (radio.checked = radio === target));
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
handleKeyDown(event: KeyboardEvent) {
|
|
110
|
-
if (
|
|
111
|
-
!["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight", " "].includes(
|
|
112
|
-
event.key
|
|
113
|
-
)
|
|
114
|
-
) {
|
|
115
|
-
return;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
const radios = this.getAllRadios().filter((radio) => !radio.disabled);
|
|
119
|
-
const checkedRadio = radios.find((radio) => radio.checked) ?? radios[0];
|
|
120
|
-
//if eventkey is space, index increment is 0, if eventkey arrowup/arrowleft, index is -1, arrowright/arrowdown, index incr is 1
|
|
121
|
-
const incr =
|
|
122
|
-
event.key === " "
|
|
123
|
-
? 0
|
|
124
|
-
: ["ArrowUp", "ArrowLeft"].includes(event.key)
|
|
125
|
-
? -1
|
|
126
|
-
: 1;
|
|
127
|
-
let index = radios.indexOf(checkedRadio) + incr;
|
|
128
|
-
if (index < 0) {
|
|
129
|
-
index = radios.length - 1;
|
|
130
|
-
}
|
|
131
|
-
if (index > radios.length - 1) {
|
|
132
|
-
index = 0;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
this.getAllRadios().forEach((radio) => {
|
|
136
|
-
radio.checked = false;
|
|
137
|
-
radio.tabIndex = -1;
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
this.value = radios[index].value;
|
|
141
|
-
radios[index].checked = true;
|
|
142
|
-
radios[index].tabIndex = 0;
|
|
143
|
-
radios[index].focus();
|
|
144
|
-
|
|
145
|
-
event.preventDefault();
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
handleLabelClick() {
|
|
149
|
-
const radios = this.getAllRadios();
|
|
150
|
-
const checked = radios.find((radio) => radio.checked);
|
|
151
|
-
const radioToFocus = checked || radios[0];
|
|
152
|
-
|
|
153
|
-
// Move focus to the checked radio (or the first one if none are checked) when clicking the label
|
|
154
|
-
if (radioToFocus) {
|
|
155
|
-
radioToFocus.focus();
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
handleSlotChange() {
|
|
160
|
-
const radios = this.getAllRadios();
|
|
161
|
-
|
|
162
|
-
radios.forEach((radio) => (radio.checked = radio.value === this.value));
|
|
163
|
-
|
|
164
|
-
if (!radios.some((radio) => radio.checked)) {
|
|
165
|
-
if (radios[0]) radios[0]!.tabIndex = 0;
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
handleInvalid() {
|
|
170
|
-
this.invalid = true;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
showNativeErrorMessage() {
|
|
174
|
-
this.input.hidden = false;
|
|
175
|
-
this.input.reportValidity();
|
|
176
|
-
setTimeout(() => (this.input.hidden = true), 10000);
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
updateCheckedRadio() {
|
|
180
|
-
const radios = this.getAllRadios();
|
|
181
|
-
radios.forEach((radio) => (radio.checked = radio.value === this.value));
|
|
182
|
-
this.invalid = !this.validity.valid;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
render() {
|
|
186
|
-
const defaultSlot = html`
|
|
187
|
-
<div>
|
|
188
|
-
<slot
|
|
189
|
-
@click=${this.handleRadioClick}
|
|
190
|
-
@keydown=${this.handleKeyDown}
|
|
191
|
-
@slotchange=${this.handleSlotChange}
|
|
192
|
-
role="presentation"
|
|
193
|
-
></slot>
|
|
194
|
-
</div>
|
|
195
|
-
`;
|
|
196
|
-
return html`
|
|
197
|
-
<fieldset role="radiogroup" part="base" name=${this.name}>
|
|
198
|
-
<label @click=${this.handleLabelClick} class="form-label" part="label">
|
|
199
|
-
<slot name="label">${this.label}</slot>
|
|
200
|
-
</label>
|
|
201
|
-
${defaultSlot}
|
|
202
|
-
<input
|
|
203
|
-
part="control"
|
|
204
|
-
type="text"
|
|
205
|
-
class="radio-group__validation-input visually-hidden ${classMap({
|
|
206
|
-
"is-invalid": this.invalid,
|
|
207
|
-
})}"
|
|
208
|
-
?required=${this.required}
|
|
209
|
-
tabindex="-1"
|
|
210
|
-
@invalid=${this.handleInvalid}
|
|
211
|
-
hidden
|
|
212
|
-
/>
|
|
213
|
-
<div class="invalid-feedback" part="invalidFeedback">
|
|
214
|
-
${this.invalidFeedback}
|
|
215
|
-
</div>
|
|
216
|
-
</fieldset>
|
|
217
|
-
`;
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
export default SgdsRadioGroup;
|
package/src/Sidenav/index.ts
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
@import "../utils/base.scss";
|
|
2
|
-
@import "~@govtechsg/sgds/sass/transitions";
|
|
3
|
-
@import "~bootstrap-icons/font/fonts/bootstrap-icons.css";
|
|
4
|
-
|
|
5
|
-
:host {
|
|
6
|
-
--sidenav-theme-color: #5925DC;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
.sidenav-btn {
|
|
10
|
-
width: 100%;
|
|
11
|
-
text-align: initial;
|
|
12
|
-
line-height: 1.5rem;
|
|
13
|
-
font-size: 1rem;
|
|
14
|
-
border: 0;
|
|
15
|
-
background: 0;
|
|
16
|
-
padding: 0.5rem 1rem;
|
|
17
|
-
border-left: $navbar-border-bottom-height solid transparent;
|
|
18
|
-
border-radius: 0;
|
|
19
|
-
display: flex;
|
|
20
|
-
align-items: center;
|
|
21
|
-
|
|
22
|
-
&.active,
|
|
23
|
-
&:hover {
|
|
24
|
-
color: var(--sidenav-theme-color);
|
|
25
|
-
border-left-color: var(--sidenav-theme-color);
|
|
26
|
-
font-weight: $font-weight-bold;
|
|
27
|
-
}
|
|
28
|
-
&.disabled{
|
|
29
|
-
opacity: 0.65;
|
|
30
|
-
pointer-events: none;
|
|
31
|
-
}
|
|
32
|
-
svg {
|
|
33
|
-
&.bi-chevron-down {
|
|
34
|
-
@extend .ms-auto;
|
|
35
|
-
transition: all 0.3s ease-in-out;
|
|
36
|
-
transform: rotate(180deg);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
&:not(.active) {
|
|
40
|
-
svg {
|
|
41
|
-
&.bi-chevron-down {
|
|
42
|
-
transform: rotate(0deg);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
a.sidenav-btn {
|
|
49
|
-
color: inherit;
|
|
50
|
-
text-decoration: none;
|
|
51
|
-
line-height: 1.5rem;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
.sidenav-list {
|
|
55
|
-
list-style: none;
|
|
56
|
-
display: flex;
|
|
57
|
-
flex-direction: column;
|
|
58
|
-
padding-left: 0;
|
|
59
|
-
margin: 0;
|
|
60
|
-
line-height: 2rem;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
.collapse,
|
|
64
|
-
.collapse.show,
|
|
65
|
-
.collapsing {
|
|
66
|
-
margin-top: $sidenav-item-spacing;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
::slotted(*[slot="title"]) {
|
|
70
|
-
display: flex;
|
|
71
|
-
gap: 1rem;
|
|
72
|
-
align-items: center;
|
|
73
|
-
}
|
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
import { html } from "lit";
|
|
2
|
-
import { customElement, property } from "lit/decorators.js";
|
|
3
|
-
import SgdsElement from "../utils/sgds-element";
|
|
4
|
-
import styles from "./sgds-sidenav-item.scss";
|
|
5
|
-
import { ref, createRef, Ref } from "lit/directives/ref.js";
|
|
6
|
-
import { Collapse } from "bootstrap";
|
|
7
|
-
import genId from "../utils/generateId";
|
|
8
|
-
import { classMap } from "lit/directives/class-map.js";
|
|
9
|
-
|
|
10
|
-
@customElement("sgds-sidenav-item")
|
|
11
|
-
export class SgdsSidenavItem extends SgdsElement {
|
|
12
|
-
static styles = styles;
|
|
13
|
-
|
|
14
|
-
private myCollapse: Ref<HTMLElement> = createRef();
|
|
15
|
-
private bsCollapse: Collapse = null;
|
|
16
|
-
|
|
17
|
-
/** when true, toggles the sidenav-item to open on first load and
|
|
18
|
-
* set the active stylings.
|
|
19
|
-
*/
|
|
20
|
-
@property({ type: Boolean })
|
|
21
|
-
active = false;
|
|
22
|
-
|
|
23
|
-
@property({ type: String })
|
|
24
|
-
href = "";
|
|
25
|
-
|
|
26
|
-
@property({ type: String })
|
|
27
|
-
collapseId = genId("sidenav", "collapse");
|
|
28
|
-
|
|
29
|
-
@property({ type: String })
|
|
30
|
-
buttonId = genId("sidenav", "button");
|
|
31
|
-
|
|
32
|
-
@property({ type: Boolean, reflect: true })
|
|
33
|
-
disabled = false;
|
|
34
|
-
|
|
35
|
-
private index = "-1";
|
|
36
|
-
|
|
37
|
-
private _onClick() {
|
|
38
|
-
this.emit("sgds-toggle", { detail: { index: this.index } });
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
private _onClickButton() {
|
|
42
|
-
this._onClick();
|
|
43
|
-
if (this.bsCollapse) {
|
|
44
|
-
this.bsCollapse.toggle();
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
private _onClickLink() {
|
|
48
|
-
this._onClick();
|
|
49
|
-
this.active = true;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* closeItem - closes sidenav and inactivates it
|
|
54
|
-
*/
|
|
55
|
-
public closeItem() {
|
|
56
|
-
this.active = false;
|
|
57
|
-
if (this.bsCollapse) this.bsCollapse.hide();
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* openItem
|
|
61
|
-
*/
|
|
62
|
-
public openItem() {
|
|
63
|
-
this.active = true;
|
|
64
|
-
if (this.bsCollapse) this.bsCollapse.show();
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
firstUpdated() {
|
|
68
|
-
// if sidenav has menu, initialise bootstrap collapse
|
|
69
|
-
if (!this.href) {
|
|
70
|
-
this.bsCollapse = new Collapse(this.myCollapse.value, {
|
|
71
|
-
toggle: this.active,
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
this.myCollapse.value.addEventListener("show.bs.collapse", () => {
|
|
75
|
-
this.active = true;
|
|
76
|
-
});
|
|
77
|
-
this.myCollapse.value.addEventListener("shown.bs.collapse", () => {
|
|
78
|
-
this.active = true;
|
|
79
|
-
});
|
|
80
|
-
this.myCollapse.value.addEventListener("hide.bs.collapse", () => {
|
|
81
|
-
this.active = false;
|
|
82
|
-
});
|
|
83
|
-
this.myCollapse.value.addEventListener("hidden.bs.collapse", () => {
|
|
84
|
-
this.active = false;
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
render() {
|
|
90
|
-
const withMenuTemplate = html` <button
|
|
91
|
-
@click=${() => this._onClickButton()}
|
|
92
|
-
class="collapsed sidenav-btn ${classMap({
|
|
93
|
-
disabled: this.disabled,
|
|
94
|
-
active: this.active,
|
|
95
|
-
})} "
|
|
96
|
-
aria-expanded="${this.active}"
|
|
97
|
-
aria-controls="${this.collapseId}"
|
|
98
|
-
aria-selected="${this.active}"
|
|
99
|
-
id="${this.buttonId}"
|
|
100
|
-
?disabled=${this.disabled}
|
|
101
|
-
aria-disabled=${this.disabled ? "true" : "false"}
|
|
102
|
-
>
|
|
103
|
-
<slot name="title"></slot>
|
|
104
|
-
<svg
|
|
105
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
106
|
-
width="16"
|
|
107
|
-
height="16"
|
|
108
|
-
fill="currentColor"
|
|
109
|
-
class="bi bi-chevron-down"
|
|
110
|
-
viewBox="0 0 16 16"
|
|
111
|
-
>
|
|
112
|
-
<path
|
|
113
|
-
fill-rule="evenodd"
|
|
114
|
-
d="M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z"
|
|
115
|
-
/>
|
|
116
|
-
</svg>
|
|
117
|
-
</button>
|
|
118
|
-
<div class="collapse" ${ref(this.myCollapse)} id="${this.collapseId}">
|
|
119
|
-
<ul class="sidenav-list" aria-labelledby="${this.buttonId}">
|
|
120
|
-
<slot></slot>
|
|
121
|
-
</ul>
|
|
122
|
-
</div>`;
|
|
123
|
-
|
|
124
|
-
const noMenuTemplate = html`
|
|
125
|
-
<a
|
|
126
|
-
href=${this.href}
|
|
127
|
-
@click=${() => this._onClickLink()}
|
|
128
|
-
class="sidenav-btn ${classMap({
|
|
129
|
-
disabled: this.disabled,
|
|
130
|
-
active: this.active,
|
|
131
|
-
})} "
|
|
132
|
-
aria-selected="${this.active}"
|
|
133
|
-
?disabled=${this.disabled}
|
|
134
|
-
aria-disabled=${this.disabled ? "true" : "false"}
|
|
135
|
-
>
|
|
136
|
-
<slot name="title"></slot>
|
|
137
|
-
</a>
|
|
138
|
-
`;
|
|
139
|
-
return html`
|
|
140
|
-
<li class="sidenav-item" aria-haspopup="${!this.href}">
|
|
141
|
-
${this.href ? noMenuTemplate : withMenuTemplate}
|
|
142
|
-
</li>
|
|
143
|
-
`;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
@import "../utils/base.scss";
|
|
2
|
-
|
|
3
|
-
a.nav-link {
|
|
4
|
-
display: block;
|
|
5
|
-
color: inherit;
|
|
6
|
-
font-size: $sidenav-fontsize;
|
|
7
|
-
padding-top: 0.5rem;
|
|
8
|
-
padding-bottom: 0.5rem;
|
|
9
|
-
padding-left: calc(
|
|
10
|
-
#{$sidenav-item-spacing * 4} + #{$sidenav-btn-border-width}
|
|
11
|
-
);
|
|
12
|
-
padding-right: 0;
|
|
13
|
-
text-decoration: none;
|
|
14
|
-
|
|
15
|
-
&.active,
|
|
16
|
-
&:hover {
|
|
17
|
-
color: var(--sidenav-theme-color);
|
|
18
|
-
}
|
|
19
|
-
// Disabled state lightens text
|
|
20
|
-
&.disabled {
|
|
21
|
-
color: $nav-link-disabled-color;
|
|
22
|
-
pointer-events: none;
|
|
23
|
-
cursor: default;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import LinkElement from "../utils/link-element";
|
|
2
|
-
import { customElement } from "lit/decorators.js";
|
|
3
|
-
import styles from "./sgds-sidenav-link.scss";
|
|
4
|
-
|
|
5
|
-
@customElement("sgds-sidenav-link")
|
|
6
|
-
export class SgdsSidenavLink extends LinkElement {
|
|
7
|
-
static styles = styles;
|
|
8
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { html } from "lit";
|
|
2
|
-
import SgdsElement from "../utils/sgds-element";
|
|
3
|
-
import { customElement, property } from "lit/decorators.js";
|
|
4
|
-
import styles from "./sgds-sidenav.scss";
|
|
5
|
-
|
|
6
|
-
@customElement("sgds-sidenav")
|
|
7
|
-
export class SgdsSidenav extends SgdsElement {
|
|
8
|
-
static styles = styles;
|
|
9
|
-
|
|
10
|
-
@property({ type: Boolean, attribute: true })
|
|
11
|
-
alwaysOpen = false;
|
|
12
|
-
|
|
13
|
-
render() {
|
|
14
|
-
this.alwaysOpen
|
|
15
|
-
? null
|
|
16
|
-
: this.addEventListener("sgds-toggle", (e: CustomEvent) => {
|
|
17
|
-
const children = this.shadowRoot.querySelector('slot').assignedElements({flatten: true});
|
|
18
|
-
for (let i = 0; i < children.length; i++) {
|
|
19
|
-
if (e.detail.index != i) {
|
|
20
|
-
(children[i] as any).closeItem();
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
return html`
|
|
26
|
-
<nav class="sidenav" id="${this.id}">
|
|
27
|
-
<ul>
|
|
28
|
-
<slot></slot>
|
|
29
|
-
</ul>
|
|
30
|
-
</nav>
|
|
31
|
-
`;
|
|
32
|
-
}
|
|
33
|
-
}
|
package/src/Tab/index.ts
DELETED