@govtechsg/sgds-web-component 3.23.0-rc.0 → 3.23.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/base/card.js +1 -1
- package/base/select-element.d.ts +4 -0
- package/base/select-element.js +6 -0
- package/base/select-element.js.map +1 -1
- package/components/Breadcrumb/index.umd.min.js +34 -33
- package/components/Breadcrumb/index.umd.min.js.map +1 -1
- package/components/Card/index.umd.min.js +1 -1
- package/components/Card/index.umd.min.js.map +1 -1
- package/components/Checkbox/index.umd.min.js +3 -3
- package/components/Checkbox/index.umd.min.js.map +1 -1
- package/components/Checkbox/sgds-checkbox-group.d.ts +5 -0
- package/components/Checkbox/sgds-checkbox-group.js +10 -0
- package/components/Checkbox/sgds-checkbox-group.js.map +1 -1
- package/components/Checkbox/sgds-checkbox.d.ts +5 -1
- package/components/Checkbox/sgds-checkbox.js +10 -1
- package/components/Checkbox/sgds-checkbox.js.map +1 -1
- package/components/ComboBox/index.umd.min.js +7 -6
- package/components/ComboBox/index.umd.min.js.map +1 -1
- package/components/ComboBox/sgds-combo-box.d.ts +11 -0
- package/components/ComboBox/sgds-combo-box.js +34 -0
- package/components/ComboBox/sgds-combo-box.js.map +1 -1
- package/components/Datepicker/index.umd.min.js +1 -1
- package/components/Datepicker/index.umd.min.js.map +1 -1
- package/components/Drawer/index.umd.min.js +10 -5
- package/components/Drawer/index.umd.min.js.map +1 -1
- package/components/Drawer/sgds-drawer.js +5 -4
- package/components/Drawer/sgds-drawer.js.map +1 -1
- package/components/Dropdown/index.umd.min.js +9 -3
- package/components/Dropdown/index.umd.min.js.map +1 -1
- package/components/Dropdown/sgds-dropdown-item.d.ts +2 -0
- package/components/Dropdown/sgds-dropdown-item.js +7 -0
- package/components/Dropdown/sgds-dropdown-item.js.map +1 -1
- package/components/FileUpload/index.umd.min.js +1 -1
- package/components/FileUpload/index.umd.min.js.map +1 -1
- package/components/IconCard/index.umd.min.js +1 -1
- package/components/IconCard/index.umd.min.js.map +1 -1
- package/components/ImageCard/index.umd.min.js +1 -1
- package/components/ImageCard/index.umd.min.js.map +1 -1
- package/components/Input/index.umd.min.js +1 -1
- package/components/Input/index.umd.min.js.map +1 -1
- package/components/Mainnav/index.umd.min.js +6 -3
- package/components/Mainnav/index.umd.min.js.map +1 -1
- package/components/Mainnav/sgds-mainnav-dropdown.d.ts +4 -0
- package/components/Mainnav/sgds-mainnav-dropdown.js +6 -0
- package/components/Mainnav/sgds-mainnav-dropdown.js.map +1 -1
- package/components/OverflowMenu/index.umd.min.js +9 -3
- package/components/OverflowMenu/index.umd.min.js.map +1 -1
- package/components/QuantityToggle/index.umd.min.js +1 -1
- package/components/QuantityToggle/index.umd.min.js.map +1 -1
- package/components/Radio/index.umd.min.js +2 -2
- package/components/Radio/index.umd.min.js.map +1 -1
- package/components/Radio/sgds-radio-group.d.ts +4 -0
- package/components/Radio/sgds-radio-group.js +9 -0
- package/components/Radio/sgds-radio-group.js.map +1 -1
- package/components/Select/index.umd.min.js +3 -3
- package/components/Select/index.umd.min.js.map +1 -1
- package/components/Select/sgds-select.d.ts +4 -0
- package/components/Select/sgds-select.js +10 -1
- package/components/Select/sgds-select.js.map +1 -1
- package/components/Textarea/index.umd.min.js +1 -1
- package/components/Textarea/index.umd.min.js.map +1 -1
- package/components/ThumbnailCard/index.umd.min.js +1 -1
- package/components/ThumbnailCard/index.umd.min.js.map +1 -1
- package/components/index.umd.min.js +81 -77
- package/components/index.umd.min.js.map +1 -1
- package/css/fouc.css +1 -1
- package/custom-elements.json +965 -665
- package/index.umd.min.js +84 -80
- package/index.umd.min.js.map +1 -1
- package/package.json +1 -1
- package/react/base/card.cjs.js +1 -1
- package/react/base/card.js +1 -1
- package/react/base/select-element.cjs.js +6 -0
- package/react/base/select-element.cjs.js.map +1 -1
- package/react/base/select-element.js +6 -0
- package/react/base/select-element.js.map +1 -1
- package/react/checkbox/index.cjs.js +3 -1
- package/react/checkbox/index.cjs.js.map +1 -1
- package/react/checkbox/index.js +3 -1
- package/react/checkbox/index.js.map +1 -1
- package/react/checkbox-group/index.cjs.js +3 -1
- package/react/checkbox-group/index.cjs.js.map +1 -1
- package/react/checkbox-group/index.js +3 -1
- package/react/checkbox-group/index.js.map +1 -1
- package/react/combo-box/index.cjs.js +1 -0
- package/react/combo-box/index.cjs.js.map +1 -1
- package/react/combo-box/index.js +1 -0
- package/react/combo-box/index.js.map +1 -1
- package/react/components/Checkbox/sgds-checkbox-group.cjs.js +10 -0
- package/react/components/Checkbox/sgds-checkbox-group.cjs.js.map +1 -1
- package/react/components/Checkbox/sgds-checkbox-group.js +10 -0
- package/react/components/Checkbox/sgds-checkbox-group.js.map +1 -1
- package/react/components/Checkbox/sgds-checkbox.cjs.js +10 -1
- package/react/components/Checkbox/sgds-checkbox.cjs.js.map +1 -1
- package/react/components/Checkbox/sgds-checkbox.js +10 -1
- package/react/components/Checkbox/sgds-checkbox.js.map +1 -1
- package/react/components/ComboBox/sgds-combo-box.cjs.js +34 -0
- package/react/components/ComboBox/sgds-combo-box.cjs.js.map +1 -1
- package/react/components/ComboBox/sgds-combo-box.js +34 -0
- package/react/components/ComboBox/sgds-combo-box.js.map +1 -1
- package/react/components/Drawer/sgds-drawer.cjs.js +4 -3
- package/react/components/Drawer/sgds-drawer.cjs.js.map +1 -1
- package/react/components/Drawer/sgds-drawer.js +5 -4
- package/react/components/Drawer/sgds-drawer.js.map +1 -1
- package/react/components/Dropdown/sgds-dropdown-item.cjs.js +7 -0
- package/react/components/Dropdown/sgds-dropdown-item.cjs.js.map +1 -1
- package/react/components/Dropdown/sgds-dropdown-item.js +7 -0
- package/react/components/Dropdown/sgds-dropdown-item.js.map +1 -1
- package/react/components/Mainnav/sgds-mainnav-dropdown.cjs.js +6 -0
- package/react/components/Mainnav/sgds-mainnav-dropdown.cjs.js.map +1 -1
- package/react/components/Mainnav/sgds-mainnav-dropdown.js +6 -0
- package/react/components/Mainnav/sgds-mainnav-dropdown.js.map +1 -1
- package/react/components/Radio/sgds-radio-group.cjs.js +9 -0
- package/react/components/Radio/sgds-radio-group.cjs.js.map +1 -1
- package/react/components/Radio/sgds-radio-group.js +9 -0
- package/react/components/Radio/sgds-radio-group.js.map +1 -1
- package/react/components/Select/sgds-select.cjs.js +9 -0
- package/react/components/Select/sgds-select.cjs.js.map +1 -1
- package/react/components/Select/sgds-select.js +10 -1
- package/react/components/Select/sgds-select.js.map +1 -1
- package/react/index.cjs.js +4 -4
- package/react/index.d.ts +1 -1
- package/react/index.js +1 -1
- package/react/radio-group/index.cjs.js +3 -1
- package/react/radio-group/index.cjs.js.map +1 -1
- package/react/radio-group/index.js +3 -1
- package/react/radio-group/index.js.map +1 -1
- package/react/select/index.cjs.js +2 -0
- package/react/select/index.cjs.js.map +1 -1
- package/react/select/index.js +2 -0
- package/react/select/index.js.map +1 -1
- package/react/utils/validatorMixin.cjs.js +9 -11
- package/react/utils/validatorMixin.cjs.js.map +1 -1
- package/react/utils/validatorMixin.js +9 -11
- package/react/utils/validatorMixin.js.map +1 -1
- package/types/react.d.ts +60 -31
- package/utils/validatorMixin.js +9 -11
- package/utils/validatorMixin.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sgds-drawer.cjs.js","sources":["../../../../src/components/Drawer/sgds-drawer.ts"],"sourcesContent":["import { html, nothing, PropertyValueMap } from \"lit\";\nimport { property, query } from \"lit/decorators.js\";\nimport { classMap } from \"lit/directives/class-map.js\";\nimport SgdsElement from \"../../base/sgds-element\";\nimport { animateTo, stopAnimations } from \"../../utils/animate.js\";\nimport { getAnimation, setDefaultAnimation } from \"../../utils/animation-registry.js\";\nimport { waitForEvent } from \"../../utils/event.js\";\nimport { lockBodyScrolling, unlockBodyScrolling } from \"../../utils/scroll.js\";\nimport { watch } from \"../../utils/watch.js\";\nimport drawerStyles from \"./drawer.css\";\nimport SgdsCloseButton from \"../CloseButton/sgds-close-button\";\n\n/**\n * @summary Drawers slide in from a container to expose additional options and information.\n *\n * @slot default - The drawer's main content\n * @slot title - The title of the drawer\n * @slot description - The description of the drawer\n * @slot footer - The footer of the drawer\n *\n * @event sgds-show - Emitted when the drawer opens.\n * @event sgds-after-show - Emitted after the drawer opens and all animations are complete.\n * @event sgds-hide - Emitted when the drawer closes.\n * @event sgds-after-hide - Emitted after the drawer closes and all animations are complete.\n * @event sgds-initial-focus - Emitted when the drawer opens and is ready to receive focus. Calling\n * `event.preventDefault()` will prevent focusing and allow you to set it on a different element, such as an input.\n * @event {{ source: 'close-button' | 'keyboard' | 'overlay' }} sgds-request-close - Emitted when the user attempts to\n * close the drawer by clicking the close button, clicking the overlay, or pressing escape. Calling\n * `event.preventDefault()` will keep the drawer open. Avoid using this unless closing the drawer will result in\n * destructive behavior such as data loss.\n *\n */\nexport class SgdsDrawer extends SgdsElement {\n static styles = [...SgdsElement.styles, drawerStyles];\n /**@internal */\n static dependencies = {\n \"sgds-close-button\": SgdsCloseButton\n };\n\n /** @internal */\n private originalTrigger: HTMLElement | null;\n /** @internal */\n @query(\".drawer\") drawer: HTMLElement;\n /** @internal */\n @query(\".drawer-panel\") panel: HTMLElement;\n /** @internal */\n @query(\".drawer-overlay\") overlay: HTMLElement;\n\n /**\n * Indicates whether or not the drawer is open. You can toggle this attribute to show and hide the drawer, or you can\n * use the `show()` and `hide()` methods and this attribute will reflect the drawer's open state.\n */\n @property({ type: Boolean, reflect: true }) open = false;\n\n /**\n * Defines the size of the drawer panel.\n * For drawers placed on the left or right (`start`/`end`), this controls the drawer's width.\n * For drawers placed on the top or bottom, this controls the drawer's height.\n * Accepts `small`, `medium`, or `large`. Defaults to `small`.\n */\n @property({ type: String, reflect: true }) size: \"sm\" | \"md\" | \"lg\" = \"sm\";\n\n /** The direction from which the drawer will open. */\n @property({ type: String, reflect: true }) placement: \"top\" | \"end\" | \"bottom\" | \"start\" = \"end\";\n\n /**\n * The accessible label for the drawer dialog. This is required for assistive technology.\n */\n @property({ type: String, reflect: true }) ariaLabel = \"\";\n\n /**\n * By default, the drawer slides out of its containing block (usually the viewport). To make the drawer slide out of\n * its parent element, set this attribute and add `position: relative` to the parent.\n */\n @property({ type: Boolean, reflect: true }) contained = false;\n\n firstUpdated(changedProperties: PropertyValueMap<this>) {\n super.firstUpdated(changedProperties);\n\n if (this.open) {\n this.addOpenListeners();\n\n if (!this.contained) {\n lockBodyScrolling(this);\n }\n }\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n\n unlockBodyScrolling(this);\n }\n\n private uppercaseFirstLetter(string: string) {\n return string.charAt(0).toUpperCase() + string.slice(1);\n }\n\n private requestClose(source: \"close-button\" | \"keyboard\" | \"overlay\") {\n const slRequestClose = this.emit(\"sgds-request-close\", {\n cancelable: true,\n detail: { source }\n });\n\n if (slRequestClose.defaultPrevented) {\n const animation = getAnimation(this, \"drawer.denyClose\");\n animateTo(this.panel, animation.keyframes, animation.options);\n return;\n }\n\n this.hide();\n }\n\n private addOpenListeners() {\n document.addEventListener(\"keydown\", this.handleDocumentKeyDown);\n }\n\n private removeOpenListeners() {\n document.removeEventListener(\"keydown\", this.handleDocumentKeyDown);\n }\n\n private handleDocumentKeyDown = (event: KeyboardEvent) => {\n if (this.open && !this.contained && event.key === \"Escape\") {\n event.stopPropagation();\n this.requestClose(\"keyboard\");\n }\n };\n\n @watch(\"open\", { waitUntilFirstUpdate: true })\n async handleOpenChange() {\n if (this.open) {\n // Show\n this.emit(\"sgds-show\");\n this.addOpenListeners();\n this.originalTrigger = document.activeElement as HTMLElement;\n\n // Lock body scrolling only if the drawer isn't contained\n if (!this.contained) {\n lockBodyScrolling(this);\n }\n\n // When the drawer is shown, Safari will attempt to set focus on whatever element has autofocus. This causes the\n // drawer's animation to jitter, so we'll temporarily remove the attribute, call `focus({ preventScroll: true })`\n // ourselves, and add the attribute back afterwards.\n //\n // Related: https://github.com/shoelace-style/shoelace/issues/693\n //\n const autoFocusTarget = this.querySelector(\"[autofocus]\");\n if (autoFocusTarget) {\n autoFocusTarget.removeAttribute(\"autofocus\");\n }\n\n await Promise.all([stopAnimations(this.drawer), stopAnimations(this.overlay)]);\n this.drawer.hidden = false;\n\n // Set initial focus\n requestAnimationFrame(() => {\n const slInitialFocus = this.emit(\"sgds-initial-focus\", { cancelable: true });\n\n if (!slInitialFocus.defaultPrevented) {\n // Set focus to the autofocus target and restore the attribute\n if (autoFocusTarget) {\n (autoFocusTarget as HTMLInputElement).focus({ preventScroll: true });\n } else {\n this.panel.focus({ preventScroll: true });\n }\n }\n\n // Restore the autofocus attribute\n if (autoFocusTarget) {\n autoFocusTarget.setAttribute(\"autofocus\", \"\");\n }\n });\n\n const panelAnimation = getAnimation(this, `drawer.show${this.uppercaseFirstLetter(this.placement)}`);\n const overlayAnimation = getAnimation(this, \"drawer.overlay.show\");\n await Promise.all([\n animateTo(this.panel, panelAnimation.keyframes, panelAnimation.options),\n animateTo(this.overlay, overlayAnimation.keyframes, overlayAnimation.options)\n ]);\n\n this.emit(\"sgds-after-show\");\n } else {\n // Hide\n this.emit(\"sgds-hide\");\n this.removeOpenListeners();\n\n if (!this.contained) {\n unlockBodyScrolling(this);\n }\n\n await Promise.all([stopAnimations(this.drawer), stopAnimations(this.overlay)]);\n const panelAnimation = getAnimation(this, `drawer.hide${this.uppercaseFirstLetter(this.placement)}`);\n const overlayAnimation = getAnimation(this, \"drawer.overlay.hide\");\n\n // Animate the overlay and the panel at the same time. Because animation durations might be different, we need to\n // hide each one individually when the animation finishes, otherwise the first one that finishes will reappear\n // unexpectedly. We'll unhide them after all animations have completed.\n await Promise.all([\n animateTo(this.overlay, overlayAnimation.keyframes, overlayAnimation.options).then(() => {\n this.overlay.hidden = true;\n }),\n animateTo(this.panel, panelAnimation.keyframes, panelAnimation.options).then(() => {\n this.panel.hidden = true;\n })\n ]);\n\n this.drawer.hidden = true;\n\n // Now that the dialog is hidden, restore the overlay and panel for next time\n this.overlay.hidden = false;\n this.panel.hidden = false;\n\n // Restore focus to the original trigger\n const trigger = this.originalTrigger;\n if (typeof trigger?.focus === \"function\") {\n setTimeout(() => trigger.focus());\n }\n\n this.emit(\"sgds-after-hide\");\n }\n }\n\n @watch(\"contained\", { waitUntilFirstUpdate: true })\n handleNoModalChange() {\n if (this.open && !this.contained) {\n lockBodyScrolling(this);\n }\n\n if (this.open && this.contained) {\n unlockBodyScrolling(this);\n }\n }\n\n /** Shows the drawer. */\n public async show() {\n if (this.open) {\n return undefined;\n }\n\n this.open = true;\n return waitForEvent(this, \"sgds-after-show\");\n }\n\n /** Hides the drawer */\n public async hide() {\n if (!this.open) {\n return undefined;\n }\n\n this.open = false;\n return waitForEvent(this, \"sgds-after-hide\");\n }\n\n render() {\n const isHydrated = this.hasUpdated;\n const shouldHide = !this.open && !isHydrated;\n\n return html`\n <div\n class=${classMap({\n drawer: true,\n \"drawer-top\": this.placement === \"top\",\n \"drawer-end\": this.placement === \"end\",\n \"drawer-bottom\": this.placement === \"bottom\",\n \"drawer-start\": this.placement === \"start\",\n \"drawer-contained\": this.contained,\n \"drawer-fixed\": !this.contained\n })}\n ?hidden=${shouldHide}\n >\n <div class=\"drawer-overlay\" @click=${() => this.requestClose(\"overlay\")} tabindex=\"-1\"></div>\n\n <div\n class=\"drawer-panel\"\n role=\"dialog\"\n aria-modal=\"true\"\n aria-label=${this.ariaLabel || nothing}\n aria-hidden=${this.open ? \"false\" : \"true\"}\n tabindex=\"0\"\n >\n <div class=\"drawer-close-wrapper\">\n <sgds-close-button\n class=\"drawer-close\"\n aria-label=\"close drawer\"\n @click=\"${() => this.requestClose(\"close-button\")}\"\n ></sgds-close-button>\n </div>\n <div class=\"drawer-header_and_body\">\n <div class=\"drawer-header\">\n <slot name=\"title\"></slot>\n <slot name=\"description\"></slot>\n </div>\n </div>\n <div>\n <slot class=\"drawer-body\"></slot>\n <slot name=\"footer\"></slot>\n </div>\n </div>\n </div>\n `;\n }\n}\n\n// Top\nsetDefaultAnimation(\"drawer.showTop\", {\n keyframes: [\n { opacity: 0, translate: \"0 -100%\" },\n { opacity: 1, translate: \"0 0\" }\n ],\n options: { duration: 250, easing: \"ease\" }\n});\n\nsetDefaultAnimation(\"drawer.hideTop\", {\n keyframes: [\n { opacity: 1, translate: \"0 0\" },\n { opacity: 0, translate: \"0 -100%\" }\n ],\n options: { duration: 250, easing: \"ease\" }\n});\n\n// End\nsetDefaultAnimation(\"drawer.showEnd\", {\n keyframes: [\n { opacity: 0, translate: \"100%\" },\n { opacity: 1, translate: \"0\" }\n ],\n rtlKeyframes: [\n { opacity: 0, translate: \"-100%\" },\n { opacity: 1, translate: \"0\" }\n ],\n options: { duration: 250, easing: \"ease\" }\n});\n\nsetDefaultAnimation(\"drawer.hideEnd\", {\n keyframes: [\n { opacity: 1, translate: \"0\" },\n { opacity: 0, translate: \"100%\" }\n ],\n rtlKeyframes: [\n { opacity: 1, translate: \"0\" },\n { opacity: 0, translate: \"-100%\" }\n ],\n options: { duration: 250, easing: \"ease\" }\n});\n\n// Bottom\nsetDefaultAnimation(\"drawer.showBottom\", {\n keyframes: [\n { opacity: 0, translate: \"0 100%\" },\n { opacity: 1, translate: \"0 0\" }\n ],\n options: { duration: 250, easing: \"ease\" }\n});\n\nsetDefaultAnimation(\"drawer.hideBottom\", {\n keyframes: [\n { opacity: 1, translate: \"0 0\" },\n { opacity: 0, translate: \"0 100%\" }\n ],\n options: { duration: 250, easing: \"ease\" }\n});\n\n// Start\nsetDefaultAnimation(\"drawer.showStart\", {\n keyframes: [\n { opacity: 0, translate: \"-100%\" },\n { opacity: 1, translate: \"0\" }\n ],\n rtlKeyframes: [\n { opacity: 0, translate: \"100%\" },\n { opacity: 1, translate: \"0\" }\n ],\n options: { duration: 250, easing: \"ease\" }\n});\n\nsetDefaultAnimation(\"drawer.hideStart\", {\n keyframes: [\n { opacity: 1, translate: \"0\" },\n { opacity: 0, translate: \"-100%\" }\n ],\n rtlKeyframes: [\n { opacity: 1, translate: \"0\" },\n { opacity: 0, translate: \"100%\" }\n ],\n options: { duration: 250, easing: \"ease\" }\n});\n\n// Deny close\nsetDefaultAnimation(\"drawer.denyClose\", {\n keyframes: [{ scale: 1 }, { scale: 1.01 }, { scale: 1 }],\n options: { duration: 250 }\n});\n\n// Overlay\nsetDefaultAnimation(\"drawer.overlay.show\", {\n keyframes: [{ opacity: 0 }, { opacity: 1 }],\n options: { duration: 250 }\n});\n\nsetDefaultAnimation(\"drawer.overlay.hide\", {\n keyframes: [{ opacity: 1 }, { opacity: 0 }],\n options: { duration: 250 }\n});\n\nexport default SgdsDrawer;\n"],"names":["SgdsElement","lockBodyScrolling","unlockBodyScrolling","getAnimation","animateTo","stopAnimations","waitForEvent","html","classMap","nothing","drawerStyles","SgdsCloseButton","__decorate","query","property","watch","setDefaultAnimation"],"mappings":";;;;;;;;;;;;;;;;;;AAYA;;;;;;;;;;;;;;;;;;;AAmBG;AACG,MAAO,UAAW,SAAQA,sBAAW,CAAA;AAA3C,IAAA,WAAA,GAAA;;AAgBE;;;AAGG;QACyC,IAAI,CAAA,IAAA,GAAG,KAAK,CAAC;AAEzD;;;;;AAKG;QACwC,IAAI,CAAA,IAAA,GAAuB,IAAI,CAAC;;QAGhC,IAAS,CAAA,SAAA,GAAuC,KAAK,CAAC;AAEjG;;AAEG;QACwC,IAAS,CAAA,SAAA,GAAG,EAAE,CAAC;AAE1D;;;AAGG;QACyC,IAAS,CAAA,SAAA,GAAG,KAAK,CAAC;AA+CtD,QAAA,IAAA,CAAA,qBAAqB,GAAG,CAAC,KAAoB,KAAI;AACvD,YAAA,IAAI,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,SAAS,IAAI,KAAK,CAAC,GAAG,KAAK,QAAQ,EAAE;gBAC1D,KAAK,CAAC,eAAe,EAAE,CAAC;AACxB,gBAAA,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;aAC/B;AACH,SAAC,CAAC;KAgLH;AAlOC,IAAA,YAAY,CAAC,iBAAyC,EAAA;AACpD,QAAA,KAAK,CAAC,YAAY,CAAC,iBAAiB,CAAC,CAAC;AAEtC,QAAA,IAAI,IAAI,C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AAI,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;AACxD,IAAA,OAAO,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE;AAC3B,CAAA,CAAC,CAAC;AAEH;AACAA,qCAAmB,CAAC,qBAAqB,EAAE;AACzC,IAAA,SAAS,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;AAC3C,IAAA,OAAO,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE;AAC3B,CAAA,CAAC,CAAC;AAEHA,qCAAmB,CAAC,qBAAqB,EAAE;AACzC,IAAA,SAAS,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;AAC3C,IAAA,OAAO,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE;AAC3B,CAAA,CAAC;;;;;"}
|
|
1
|
+
{"version":3,"file":"sgds-drawer.cjs.js","sources":["../../../../src/components/Drawer/sgds-drawer.ts"],"sourcesContent":["import { html, PropertyValueMap } from \"lit\";\nimport { property, query } from \"lit/decorators.js\";\nimport { classMap } from \"lit/directives/class-map.js\";\nimport { ifDefined } from \"lit/directives/if-defined.js\";\nimport SgdsElement from \"../../base/sgds-element\";\nimport { animateTo, stopAnimations } from \"../../utils/animate.js\";\nimport { getAnimation, setDefaultAnimation } from \"../../utils/animation-registry.js\";\nimport { waitForEvent } from \"../../utils/event.js\";\nimport { lockBodyScrolling, unlockBodyScrolling } from \"../../utils/scroll.js\";\nimport { watch } from \"../../utils/watch.js\";\nimport drawerStyles from \"./drawer.css\";\nimport SgdsCloseButton from \"../CloseButton/sgds-close-button\";\n\n/**\n * @summary Drawers slide in from a container to expose additional options and information.\n *\n * @slot default - The drawer's main content\n * @slot title - The title of the drawer\n * @slot description - The description of the drawer\n * @slot footer - The footer of the drawer\n *\n * @event sgds-show - Emitted when the drawer opens.\n * @event sgds-after-show - Emitted after the drawer opens and all animations are complete.\n * @event sgds-hide - Emitted when the drawer closes.\n * @event sgds-after-hide - Emitted after the drawer closes and all animations are complete.\n * @event sgds-initial-focus - Emitted when the drawer opens and is ready to receive focus. Calling\n * `event.preventDefault()` will prevent focusing and allow you to set it on a different element, such as an input.\n * @event {{ source: 'close-button' | 'keyboard' | 'overlay' }} sgds-request-close - Emitted when the user attempts to\n * close the drawer by clicking the close button, clicking the overlay, or pressing escape. Calling\n * `event.preventDefault()` will keep the drawer open. Avoid using this unless closing the drawer will result in\n * destructive behavior such as data loss.\n *\n */\nexport class SgdsDrawer extends SgdsElement {\n static styles = [...SgdsElement.styles, drawerStyles];\n /**@internal */\n static dependencies = {\n \"sgds-close-button\": SgdsCloseButton\n };\n\n /** @internal */\n private originalTrigger: HTMLElement | null;\n /** @internal */\n @query(\".drawer\") drawer: HTMLElement;\n /** @internal */\n @query(\".drawer-panel\") panel: HTMLElement;\n /** @internal */\n @query(\".drawer-overlay\") overlay: HTMLElement;\n\n /**\n * Indicates whether or not the drawer is open. You can toggle this attribute to show and hide the drawer, or you can\n * use the `show()` and `hide()` methods and this attribute will reflect the drawer's open state.\n */\n @property({ type: Boolean, reflect: true }) open = false;\n\n /**\n * Defines the size of the drawer panel.\n * For drawers placed on the left or right (`start`/`end`), this controls the drawer's width.\n * For drawers placed on the top or bottom, this controls the drawer's height.\n * Accepts `small`, `medium`, or `large`. Defaults to `small`.\n */\n @property({ type: String, reflect: true }) size: \"sm\" | \"md\" | \"lg\" = \"sm\";\n\n /** The direction from which the drawer will open. */\n @property({ type: String, reflect: true }) placement: \"top\" | \"end\" | \"bottom\" | \"start\" = \"end\";\n\n /**\n * The accessible label for the drawer dialog. This is required for assistive technology.\n */\n @property({ type: String }) ariaLabel = \"Drawer\";\n\n /**\n * By default, the drawer slides out of its containing block (usually the viewport). To make the drawer slide out of\n * its parent element, set this attribute and add `position: relative` to the parent.\n */\n @property({ type: Boolean, reflect: true }) contained = false;\n\n firstUpdated(changedProperties: PropertyValueMap<this>) {\n super.firstUpdated(changedProperties);\n\n if (this.open) {\n this.addOpenListeners();\n\n if (!this.contained) {\n lockBodyScrolling(this);\n }\n }\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n\n unlockBodyScrolling(this);\n }\n\n private uppercaseFirstLetter(string: string) {\n return string.charAt(0).toUpperCase() + string.slice(1);\n }\n\n private requestClose(source: \"close-button\" | \"keyboard\" | \"overlay\") {\n const slRequestClose = this.emit(\"sgds-request-close\", {\n cancelable: true,\n detail: { source }\n });\n\n if (slRequestClose.defaultPrevented) {\n const animation = getAnimation(this, \"drawer.denyClose\");\n animateTo(this.panel, animation.keyframes, animation.options);\n return;\n }\n\n this.hide();\n }\n\n private addOpenListeners() {\n document.addEventListener(\"keydown\", this.handleDocumentKeyDown);\n }\n\n private removeOpenListeners() {\n document.removeEventListener(\"keydown\", this.handleDocumentKeyDown);\n }\n\n private handleDocumentKeyDown = (event: KeyboardEvent) => {\n if (this.open && !this.contained && event.key === \"Escape\") {\n event.stopPropagation();\n this.requestClose(\"keyboard\");\n }\n };\n\n @watch(\"open\", { waitUntilFirstUpdate: true })\n async handleOpenChange() {\n if (this.open) {\n // Show\n this.emit(\"sgds-show\");\n this.addOpenListeners();\n this.originalTrigger = document.activeElement as HTMLElement;\n\n // Lock body scrolling only if the drawer isn't contained\n if (!this.contained) {\n lockBodyScrolling(this);\n }\n\n // When the drawer is shown, Safari will attempt to set focus on whatever element has autofocus. This causes the\n // drawer's animation to jitter, so we'll temporarily remove the attribute, call `focus({ preventScroll: true })`\n // ourselves, and add the attribute back afterwards.\n //\n // Related: https://github.com/shoelace-style/shoelace/issues/693\n //\n const autoFocusTarget = this.querySelector(\"[autofocus]\");\n if (autoFocusTarget) {\n autoFocusTarget.removeAttribute(\"autofocus\");\n }\n\n await Promise.all([stopAnimations(this.drawer), stopAnimations(this.overlay)]);\n this.drawer.hidden = false;\n\n // Set initial focus\n requestAnimationFrame(() => {\n const slInitialFocus = this.emit(\"sgds-initial-focus\", { cancelable: true });\n\n if (!slInitialFocus.defaultPrevented) {\n // Set focus to the autofocus target and restore the attribute\n if (autoFocusTarget) {\n (autoFocusTarget as HTMLInputElement).focus({ preventScroll: true });\n } else {\n this.panel.focus({ preventScroll: true });\n }\n }\n\n // Restore the autofocus attribute\n if (autoFocusTarget) {\n autoFocusTarget.setAttribute(\"autofocus\", \"\");\n }\n });\n\n const panelAnimation = getAnimation(this, `drawer.show${this.uppercaseFirstLetter(this.placement)}`);\n const overlayAnimation = getAnimation(this, \"drawer.overlay.show\");\n await Promise.all([\n animateTo(this.panel, panelAnimation.keyframes, panelAnimation.options),\n animateTo(this.overlay, overlayAnimation.keyframes, overlayAnimation.options)\n ]);\n\n this.emit(\"sgds-after-show\");\n } else {\n // Hide\n this.emit(\"sgds-hide\");\n this.removeOpenListeners();\n\n if (!this.contained) {\n unlockBodyScrolling(this);\n }\n\n await Promise.all([stopAnimations(this.drawer), stopAnimations(this.overlay)]);\n const panelAnimation = getAnimation(this, `drawer.hide${this.uppercaseFirstLetter(this.placement)}`);\n const overlayAnimation = getAnimation(this, \"drawer.overlay.hide\");\n\n // Animate the overlay and the panel at the same time. Because animation durations might be different, we need to\n // hide each one individually when the animation finishes, otherwise the first one that finishes will reappear\n // unexpectedly. We'll unhide them after all animations have completed.\n await Promise.all([\n animateTo(this.overlay, overlayAnimation.keyframes, overlayAnimation.options).then(() => {\n this.overlay.hidden = true;\n }),\n animateTo(this.panel, panelAnimation.keyframes, panelAnimation.options).then(() => {\n this.panel.hidden = true;\n })\n ]);\n\n this.drawer.hidden = true;\n\n // Now that the dialog is hidden, restore the overlay and panel for next time\n this.overlay.hidden = false;\n this.panel.hidden = false;\n\n // Restore focus to the original trigger\n const trigger = this.originalTrigger;\n if (typeof trigger?.focus === \"function\") {\n setTimeout(() => trigger.focus());\n }\n\n this.emit(\"sgds-after-hide\");\n }\n }\n\n @watch(\"contained\", { waitUntilFirstUpdate: true })\n handleNoModalChange() {\n if (this.open && !this.contained) {\n lockBodyScrolling(this);\n }\n\n if (this.open && this.contained) {\n unlockBodyScrolling(this);\n }\n }\n\n /** Shows the drawer. */\n public async show() {\n if (this.open) {\n return undefined;\n }\n\n this.open = true;\n return waitForEvent(this, \"sgds-after-show\");\n }\n\n /** Hides the drawer */\n public async hide() {\n if (!this.open) {\n return undefined;\n }\n\n this.open = false;\n return waitForEvent(this, \"sgds-after-hide\");\n }\n\n render() {\n const isHydrated = this.hasUpdated;\n const shouldHide = !this.open && !isHydrated;\n\n return html`\n <div\n class=${classMap({\n drawer: true,\n \"drawer-top\": this.placement === \"top\",\n \"drawer-end\": this.placement === \"end\",\n \"drawer-bottom\": this.placement === \"bottom\",\n \"drawer-start\": this.placement === \"start\",\n \"drawer-contained\": this.contained,\n \"drawer-fixed\": !this.contained\n })}\n ?hidden=${shouldHide}\n >\n <div class=\"drawer-overlay\" @click=${() => this.requestClose(\"overlay\")} tabindex=\"-1\"></div>\n\n <div\n class=\"drawer-panel\"\n role=\"dialog\"\n aria-modal=\"true\"\n aria-label=${ifDefined(this.ariaLabel)}\n aria-hidden=${this.open ? \"false\" : \"true\"}\n tabindex=\"0\"\n >\n <div class=\"drawer-close-wrapper\">\n <sgds-close-button\n class=\"drawer-close\"\n aria-label=\"close drawer\"\n @click=\"${() => this.requestClose(\"close-button\")}\"\n ></sgds-close-button>\n </div>\n <div class=\"drawer-header_and_body\">\n <div class=\"drawer-header\">\n <slot name=\"title\"></slot>\n <slot name=\"description\"></slot>\n </div>\n </div>\n <div>\n <slot class=\"drawer-body\"></slot>\n <slot name=\"footer\"></slot>\n </div>\n </div>\n </div>\n `;\n }\n}\n\n// Top\nsetDefaultAnimation(\"drawer.showTop\", {\n keyframes: [\n { opacity: 0, translate: \"0 -100%\" },\n { opacity: 1, translate: \"0 0\" }\n ],\n options: { duration: 250, easing: \"ease\" }\n});\n\nsetDefaultAnimation(\"drawer.hideTop\", {\n keyframes: [\n { opacity: 1, translate: \"0 0\" },\n { opacity: 0, translate: \"0 -100%\" }\n ],\n options: { duration: 250, easing: \"ease\" }\n});\n\n// End\nsetDefaultAnimation(\"drawer.showEnd\", {\n keyframes: [\n { opacity: 0, translate: \"100%\" },\n { opacity: 1, translate: \"0\" }\n ],\n rtlKeyframes: [\n { opacity: 0, translate: \"-100%\" },\n { opacity: 1, translate: \"0\" }\n ],\n options: { duration: 250, easing: \"ease\" }\n});\n\nsetDefaultAnimation(\"drawer.hideEnd\", {\n keyframes: [\n { opacity: 1, translate: \"0\" },\n { opacity: 0, translate: \"100%\" }\n ],\n rtlKeyframes: [\n { opacity: 1, translate: \"0\" },\n { opacity: 0, translate: \"-100%\" }\n ],\n options: { duration: 250, easing: \"ease\" }\n});\n\n// Bottom\nsetDefaultAnimation(\"drawer.showBottom\", {\n keyframes: [\n { opacity: 0, translate: \"0 100%\" },\n { opacity: 1, translate: \"0 0\" }\n ],\n options: { duration: 250, easing: \"ease\" }\n});\n\nsetDefaultAnimation(\"drawer.hideBottom\", {\n keyframes: [\n { opacity: 1, translate: \"0 0\" },\n { opacity: 0, translate: \"0 100%\" }\n ],\n options: { duration: 250, easing: \"ease\" }\n});\n\n// Start\nsetDefaultAnimation(\"drawer.showStart\", {\n keyframes: [\n { opacity: 0, translate: \"-100%\" },\n { opacity: 1, translate: \"0\" }\n ],\n rtlKeyframes: [\n { opacity: 0, translate: \"100%\" },\n { opacity: 1, translate: \"0\" }\n ],\n options: { duration: 250, easing: \"ease\" }\n});\n\nsetDefaultAnimation(\"drawer.hideStart\", {\n keyframes: [\n { opacity: 1, translate: \"0\" },\n { opacity: 0, translate: \"-100%\" }\n ],\n rtlKeyframes: [\n { opacity: 1, translate: \"0\" },\n { opacity: 0, translate: \"100%\" }\n ],\n options: { duration: 250, easing: \"ease\" }\n});\n\n// Deny close\nsetDefaultAnimation(\"drawer.denyClose\", {\n keyframes: [{ scale: 1 }, { scale: 1.01 }, { scale: 1 }],\n options: { duration: 250 }\n});\n\n// Overlay\nsetDefaultAnimation(\"drawer.overlay.show\", {\n keyframes: [{ opacity: 0 }, { opacity: 1 }],\n options: { duration: 250 }\n});\n\nsetDefaultAnimation(\"drawer.overlay.hide\", {\n keyframes: [{ opacity: 1 }, { opacity: 0 }],\n options: { duration: 250 }\n});\n\nexport default SgdsDrawer;\n"],"names":["SgdsElement","lockBodyScrolling","unlockBodyScrolling","getAnimation","animateTo","stopAnimations","waitForEvent","html","classMap","ifDefined","drawerStyles","SgdsCloseButton","__decorate","query","property","watch","setDefaultAnimation"],"mappings":";;;;;;;;;;;;;;;;;;;AAaA;;;;;;;;;;;;;;;;;;;AAmBG;AACG,MAAO,UAAW,SAAQA,sBAAW,CAAA;AAA3C,IAAA,WAAA,GAAA;;AAgBE;;;AAGG;QACyC,IAAI,CAAA,IAAA,GAAG,KAAK,CAAC;AAEzD;;;;;AAKG;QACwC,IAAI,CAAA,IAAA,GAAuB,IAAI,CAAC;;QAGhC,IAAS,CAAA,SAAA,GAAuC,KAAK,CAAC;AAEjG;;AAEG;QACyB,IAAS,CAAA,SAAA,GAAG,QAAQ,CAAC;AAEjD;;;AAGG;QACyC,IAAS,CAAA,SAAA,GAAG,KAAK,CAAC;AA+CtD,QAAA,IAAA,CAAA,qBAAqB,GAAG,CAAC,KAAoB,KAAI;AACvD,YAAA,IAAI,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,SAAS,IAAI,KAAK,CAAC,GAAG,KAAK,QAAQ,EAAE;gBAC1D,KAAK,CAAC,eAAe,EAAE,CAAC;AACxB,gBAAA,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;aAC/B;AACH,SAAC,CAAC;KAgLH;AAlOC,IAAA,YAAY,CAAC,iBAAyC,EAAA;AACpD,QAAA,KAAK,CAAC,YAAY,CAAC,iBAAiB,CAAC,CAAC;AAEtC,QAAA,IAAI,IAAI,CAAC,IAAI,EAAE;YACb,IAAI,CAAC,gBAAgB,EAAE,CAAC;AAExB,YAAA,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;gBACnBC,wB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3B,CAAA,CAAC,CAAC;AAEH;AACAA,qCAAmB,CAAC,qBAAqB,EAAE;AACzC,IAAA,SAAS,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;AAC3C,IAAA,OAAO,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE;AAC3B,CAAA,CAAC,CAAC;AAEHA,qCAAmB,CAAC,qBAAqB,EAAE;AACzC,IAAA,SAAS,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;AAC3C,IAAA,OAAO,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE;AAC3B,CAAA,CAAC;;;;;"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { __decorate } from 'tslib';
|
|
3
|
-
import { html
|
|
3
|
+
import { html } from 'lit';
|
|
4
4
|
import { query, property } from 'lit/decorators.js';
|
|
5
5
|
import { classMap } from 'lit/directives/class-map.js';
|
|
6
|
+
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
6
7
|
import SgdsElement from '../../base/sgds-element.js';
|
|
7
8
|
import { animateTo, stopAnimations } from '../../utils/animate.js';
|
|
8
9
|
import { setDefaultAnimation, getAnimation } from '../../utils/animation-registry.js';
|
|
@@ -52,7 +53,7 @@ class SgdsDrawer extends SgdsElement {
|
|
|
52
53
|
/**
|
|
53
54
|
* The accessible label for the drawer dialog. This is required for assistive technology.
|
|
54
55
|
*/
|
|
55
|
-
this.ariaLabel = "";
|
|
56
|
+
this.ariaLabel = "Drawer";
|
|
56
57
|
/**
|
|
57
58
|
* By default, the drawer slides out of its containing block (usually the viewport). To make the drawer slide out of
|
|
58
59
|
* its parent element, set this attribute and add `position: relative` to the parent.
|
|
@@ -225,7 +226,7 @@ class SgdsDrawer extends SgdsElement {
|
|
|
225
226
|
class="drawer-panel"
|
|
226
227
|
role="dialog"
|
|
227
228
|
aria-modal="true"
|
|
228
|
-
aria-label=${this.ariaLabel
|
|
229
|
+
aria-label=${ifDefined(this.ariaLabel)}
|
|
229
230
|
aria-hidden=${this.open ? "false" : "true"}
|
|
230
231
|
tabindex="0"
|
|
231
232
|
>
|
|
@@ -275,7 +276,7 @@ __decorate([
|
|
|
275
276
|
property({ type: String, reflect: true })
|
|
276
277
|
], SgdsDrawer.prototype, "placement", void 0);
|
|
277
278
|
__decorate([
|
|
278
|
-
property({ type: String
|
|
279
|
+
property({ type: String })
|
|
279
280
|
], SgdsDrawer.prototype, "ariaLabel", void 0);
|
|
280
281
|
__decorate([
|
|
281
282
|
property({ type: Boolean, reflect: true })
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sgds-drawer.js","sources":["../../../../src/components/Drawer/sgds-drawer.ts"],"sourcesContent":["import { html, nothing, PropertyValueMap } from \"lit\";\nimport { property, query } from \"lit/decorators.js\";\nimport { classMap } from \"lit/directives/class-map.js\";\nimport SgdsElement from \"../../base/sgds-element\";\nimport { animateTo, stopAnimations } from \"../../utils/animate.js\";\nimport { getAnimation, setDefaultAnimation } from \"../../utils/animation-registry.js\";\nimport { waitForEvent } from \"../../utils/event.js\";\nimport { lockBodyScrolling, unlockBodyScrolling } from \"../../utils/scroll.js\";\nimport { watch } from \"../../utils/watch.js\";\nimport drawerStyles from \"./drawer.css\";\nimport SgdsCloseButton from \"../CloseButton/sgds-close-button\";\n\n/**\n * @summary Drawers slide in from a container to expose additional options and information.\n *\n * @slot default - The drawer's main content\n * @slot title - The title of the drawer\n * @slot description - The description of the drawer\n * @slot footer - The footer of the drawer\n *\n * @event sgds-show - Emitted when the drawer opens.\n * @event sgds-after-show - Emitted after the drawer opens and all animations are complete.\n * @event sgds-hide - Emitted when the drawer closes.\n * @event sgds-after-hide - Emitted after the drawer closes and all animations are complete.\n * @event sgds-initial-focus - Emitted when the drawer opens and is ready to receive focus. Calling\n * `event.preventDefault()` will prevent focusing and allow you to set it on a different element, such as an input.\n * @event {{ source: 'close-button' | 'keyboard' | 'overlay' }} sgds-request-close - Emitted when the user attempts to\n * close the drawer by clicking the close button, clicking the overlay, or pressing escape. Calling\n * `event.preventDefault()` will keep the drawer open. Avoid using this unless closing the drawer will result in\n * destructive behavior such as data loss.\n *\n */\nexport class SgdsDrawer extends SgdsElement {\n static styles = [...SgdsElement.styles, drawerStyles];\n /**@internal */\n static dependencies = {\n \"sgds-close-button\": SgdsCloseButton\n };\n\n /** @internal */\n private originalTrigger: HTMLElement | null;\n /** @internal */\n @query(\".drawer\") drawer: HTMLElement;\n /** @internal */\n @query(\".drawer-panel\") panel: HTMLElement;\n /** @internal */\n @query(\".drawer-overlay\") overlay: HTMLElement;\n\n /**\n * Indicates whether or not the drawer is open. You can toggle this attribute to show and hide the drawer, or you can\n * use the `show()` and `hide()` methods and this attribute will reflect the drawer's open state.\n */\n @property({ type: Boolean, reflect: true }) open = false;\n\n /**\n * Defines the size of the drawer panel.\n * For drawers placed on the left or right (`start`/`end`), this controls the drawer's width.\n * For drawers placed on the top or bottom, this controls the drawer's height.\n * Accepts `small`, `medium`, or `large`. Defaults to `small`.\n */\n @property({ type: String, reflect: true }) size: \"sm\" | \"md\" | \"lg\" = \"sm\";\n\n /** The direction from which the drawer will open. */\n @property({ type: String, reflect: true }) placement: \"top\" | \"end\" | \"bottom\" | \"start\" = \"end\";\n\n /**\n * The accessible label for the drawer dialog. This is required for assistive technology.\n */\n @property({ type: String, reflect: true }) ariaLabel = \"\";\n\n /**\n * By default, the drawer slides out of its containing block (usually the viewport). To make the drawer slide out of\n * its parent element, set this attribute and add `position: relative` to the parent.\n */\n @property({ type: Boolean, reflect: true }) contained = false;\n\n firstUpdated(changedProperties: PropertyValueMap<this>) {\n super.firstUpdated(changedProperties);\n\n if (this.open) {\n this.addOpenListeners();\n\n if (!this.contained) {\n lockBodyScrolling(this);\n }\n }\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n\n unlockBodyScrolling(this);\n }\n\n private uppercaseFirstLetter(string: string) {\n return string.charAt(0).toUpperCase() + string.slice(1);\n }\n\n private requestClose(source: \"close-button\" | \"keyboard\" | \"overlay\") {\n const slRequestClose = this.emit(\"sgds-request-close\", {\n cancelable: true,\n detail: { source }\n });\n\n if (slRequestClose.defaultPrevented) {\n const animation = getAnimation(this, \"drawer.denyClose\");\n animateTo(this.panel, animation.keyframes, animation.options);\n return;\n }\n\n this.hide();\n }\n\n private addOpenListeners() {\n document.addEventListener(\"keydown\", this.handleDocumentKeyDown);\n }\n\n private removeOpenListeners() {\n document.removeEventListener(\"keydown\", this.handleDocumentKeyDown);\n }\n\n private handleDocumentKeyDown = (event: KeyboardEvent) => {\n if (this.open && !this.contained && event.key === \"Escape\") {\n event.stopPropagation();\n this.requestClose(\"keyboard\");\n }\n };\n\n @watch(\"open\", { waitUntilFirstUpdate: true })\n async handleOpenChange() {\n if (this.open) {\n // Show\n this.emit(\"sgds-show\");\n this.addOpenListeners();\n this.originalTrigger = document.activeElement as HTMLElement;\n\n // Lock body scrolling only if the drawer isn't contained\n if (!this.contained) {\n lockBodyScrolling(this);\n }\n\n // When the drawer is shown, Safari will attempt to set focus on whatever element has autofocus. This causes the\n // drawer's animation to jitter, so we'll temporarily remove the attribute, call `focus({ preventScroll: true })`\n // ourselves, and add the attribute back afterwards.\n //\n // Related: https://github.com/shoelace-style/shoelace/issues/693\n //\n const autoFocusTarget = this.querySelector(\"[autofocus]\");\n if (autoFocusTarget) {\n autoFocusTarget.removeAttribute(\"autofocus\");\n }\n\n await Promise.all([stopAnimations(this.drawer), stopAnimations(this.overlay)]);\n this.drawer.hidden = false;\n\n // Set initial focus\n requestAnimationFrame(() => {\n const slInitialFocus = this.emit(\"sgds-initial-focus\", { cancelable: true });\n\n if (!slInitialFocus.defaultPrevented) {\n // Set focus to the autofocus target and restore the attribute\n if (autoFocusTarget) {\n (autoFocusTarget as HTMLInputElement).focus({ preventScroll: true });\n } else {\n this.panel.focus({ preventScroll: true });\n }\n }\n\n // Restore the autofocus attribute\n if (autoFocusTarget) {\n autoFocusTarget.setAttribute(\"autofocus\", \"\");\n }\n });\n\n const panelAnimation = getAnimation(this, `drawer.show${this.uppercaseFirstLetter(this.placement)}`);\n const overlayAnimation = getAnimation(this, \"drawer.overlay.show\");\n await Promise.all([\n animateTo(this.panel, panelAnimation.keyframes, panelAnimation.options),\n animateTo(this.overlay, overlayAnimation.keyframes, overlayAnimation.options)\n ]);\n\n this.emit(\"sgds-after-show\");\n } else {\n // Hide\n this.emit(\"sgds-hide\");\n this.removeOpenListeners();\n\n if (!this.contained) {\n unlockBodyScrolling(this);\n }\n\n await Promise.all([stopAnimations(this.drawer), stopAnimations(this.overlay)]);\n const panelAnimation = getAnimation(this, `drawer.hide${this.uppercaseFirstLetter(this.placement)}`);\n const overlayAnimation = getAnimation(this, \"drawer.overlay.hide\");\n\n // Animate the overlay and the panel at the same time. Because animation durations might be different, we need to\n // hide each one individually when the animation finishes, otherwise the first one that finishes will reappear\n // unexpectedly. We'll unhide them after all animations have completed.\n await Promise.all([\n animateTo(this.overlay, overlayAnimation.keyframes, overlayAnimation.options).then(() => {\n this.overlay.hidden = true;\n }),\n animateTo(this.panel, panelAnimation.keyframes, panelAnimation.options).then(() => {\n this.panel.hidden = true;\n })\n ]);\n\n this.drawer.hidden = true;\n\n // Now that the dialog is hidden, restore the overlay and panel for next time\n this.overlay.hidden = false;\n this.panel.hidden = false;\n\n // Restore focus to the original trigger\n const trigger = this.originalTrigger;\n if (typeof trigger?.focus === \"function\") {\n setTimeout(() => trigger.focus());\n }\n\n this.emit(\"sgds-after-hide\");\n }\n }\n\n @watch(\"contained\", { waitUntilFirstUpdate: true })\n handleNoModalChange() {\n if (this.open && !this.contained) {\n lockBodyScrolling(this);\n }\n\n if (this.open && this.contained) {\n unlockBodyScrolling(this);\n }\n }\n\n /** Shows the drawer. */\n public async show() {\n if (this.open) {\n return undefined;\n }\n\n this.open = true;\n return waitForEvent(this, \"sgds-after-show\");\n }\n\n /** Hides the drawer */\n public async hide() {\n if (!this.open) {\n return undefined;\n }\n\n this.open = false;\n return waitForEvent(this, \"sgds-after-hide\");\n }\n\n render() {\n const isHydrated = this.hasUpdated;\n const shouldHide = !this.open && !isHydrated;\n\n return html`\n <div\n class=${classMap({\n drawer: true,\n \"drawer-top\": this.placement === \"top\",\n \"drawer-end\": this.placement === \"end\",\n \"drawer-bottom\": this.placement === \"bottom\",\n \"drawer-start\": this.placement === \"start\",\n \"drawer-contained\": this.contained,\n \"drawer-fixed\": !this.contained\n })}\n ?hidden=${shouldHide}\n >\n <div class=\"drawer-overlay\" @click=${() => this.requestClose(\"overlay\")} tabindex=\"-1\"></div>\n\n <div\n class=\"drawer-panel\"\n role=\"dialog\"\n aria-modal=\"true\"\n aria-label=${this.ariaLabel || nothing}\n aria-hidden=${this.open ? \"false\" : \"true\"}\n tabindex=\"0\"\n >\n <div class=\"drawer-close-wrapper\">\n <sgds-close-button\n class=\"drawer-close\"\n aria-label=\"close drawer\"\n @click=\"${() => this.requestClose(\"close-button\")}\"\n ></sgds-close-button>\n </div>\n <div class=\"drawer-header_and_body\">\n <div class=\"drawer-header\">\n <slot name=\"title\"></slot>\n <slot name=\"description\"></slot>\n </div>\n </div>\n <div>\n <slot class=\"drawer-body\"></slot>\n <slot name=\"footer\"></slot>\n </div>\n </div>\n </div>\n `;\n }\n}\n\n// Top\nsetDefaultAnimation(\"drawer.showTop\", {\n keyframes: [\n { opacity: 0, translate: \"0 -100%\" },\n { opacity: 1, translate: \"0 0\" }\n ],\n options: { duration: 250, easing: \"ease\" }\n});\n\nsetDefaultAnimation(\"drawer.hideTop\", {\n keyframes: [\n { opacity: 1, translate: \"0 0\" },\n { opacity: 0, translate: \"0 -100%\" }\n ],\n options: { duration: 250, easing: \"ease\" }\n});\n\n// End\nsetDefaultAnimation(\"drawer.showEnd\", {\n keyframes: [\n { opacity: 0, translate: \"100%\" },\n { opacity: 1, translate: \"0\" }\n ],\n rtlKeyframes: [\n { opacity: 0, translate: \"-100%\" },\n { opacity: 1, translate: \"0\" }\n ],\n options: { duration: 250, easing: \"ease\" }\n});\n\nsetDefaultAnimation(\"drawer.hideEnd\", {\n keyframes: [\n { opacity: 1, translate: \"0\" },\n { opacity: 0, translate: \"100%\" }\n ],\n rtlKeyframes: [\n { opacity: 1, translate: \"0\" },\n { opacity: 0, translate: \"-100%\" }\n ],\n options: { duration: 250, easing: \"ease\" }\n});\n\n// Bottom\nsetDefaultAnimation(\"drawer.showBottom\", {\n keyframes: [\n { opacity: 0, translate: \"0 100%\" },\n { opacity: 1, translate: \"0 0\" }\n ],\n options: { duration: 250, easing: \"ease\" }\n});\n\nsetDefaultAnimation(\"drawer.hideBottom\", {\n keyframes: [\n { opacity: 1, translate: \"0 0\" },\n { opacity: 0, translate: \"0 100%\" }\n ],\n options: { duration: 250, easing: \"ease\" }\n});\n\n// Start\nsetDefaultAnimation(\"drawer.showStart\", {\n keyframes: [\n { opacity: 0, translate: \"-100%\" },\n { opacity: 1, translate: \"0\" }\n ],\n rtlKeyframes: [\n { opacity: 0, translate: \"100%\" },\n { opacity: 1, translate: \"0\" }\n ],\n options: { duration: 250, easing: \"ease\" }\n});\n\nsetDefaultAnimation(\"drawer.hideStart\", {\n keyframes: [\n { opacity: 1, translate: \"0\" },\n { opacity: 0, translate: \"-100%\" }\n ],\n rtlKeyframes: [\n { opacity: 1, translate: \"0\" },\n { opacity: 0, translate: \"100%\" }\n ],\n options: { duration: 250, easing: \"ease\" }\n});\n\n// Deny close\nsetDefaultAnimation(\"drawer.denyClose\", {\n keyframes: [{ scale: 1 }, { scale: 1.01 }, { scale: 1 }],\n options: { duration: 250 }\n});\n\n// Overlay\nsetDefaultAnimation(\"drawer.overlay.show\", {\n keyframes: [{ opacity: 0 }, { opacity: 1 }],\n options: { duration: 250 }\n});\n\nsetDefaultAnimation(\"drawer.overlay.hide\", {\n keyframes: [{ opacity: 1 }, { opacity: 0 }],\n options: { duration: 250 }\n});\n\nexport default SgdsDrawer;\n"],"names":["drawerStyles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E,QAAQ,EAAE,GAAG,EAAE;AAC3B,CAAA,CAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"sgds-drawer.js","sources":["../../../../src/components/Drawer/sgds-drawer.ts"],"sourcesContent":["import { html, PropertyValueMap } from \"lit\";\nimport { property, query } from \"lit/decorators.js\";\nimport { classMap } from \"lit/directives/class-map.js\";\nimport { ifDefined } from \"lit/directives/if-defined.js\";\nimport SgdsElement from \"../../base/sgds-element\";\nimport { animateTo, stopAnimations } from \"../../utils/animate.js\";\nimport { getAnimation, setDefaultAnimation } from \"../../utils/animation-registry.js\";\nimport { waitForEvent } from \"../../utils/event.js\";\nimport { lockBodyScrolling, unlockBodyScrolling } from \"../../utils/scroll.js\";\nimport { watch } from \"../../utils/watch.js\";\nimport drawerStyles from \"./drawer.css\";\nimport SgdsCloseButton from \"../CloseButton/sgds-close-button\";\n\n/**\n * @summary Drawers slide in from a container to expose additional options and information.\n *\n * @slot default - The drawer's main content\n * @slot title - The title of the drawer\n * @slot description - The description of the drawer\n * @slot footer - The footer of the drawer\n *\n * @event sgds-show - Emitted when the drawer opens.\n * @event sgds-after-show - Emitted after the drawer opens and all animations are complete.\n * @event sgds-hide - Emitted when the drawer closes.\n * @event sgds-after-hide - Emitted after the drawer closes and all animations are complete.\n * @event sgds-initial-focus - Emitted when the drawer opens and is ready to receive focus. Calling\n * `event.preventDefault()` will prevent focusing and allow you to set it on a different element, such as an input.\n * @event {{ source: 'close-button' | 'keyboard' | 'overlay' }} sgds-request-close - Emitted when the user attempts to\n * close the drawer by clicking the close button, clicking the overlay, or pressing escape. Calling\n * `event.preventDefault()` will keep the drawer open. Avoid using this unless closing the drawer will result in\n * destructive behavior such as data loss.\n *\n */\nexport class SgdsDrawer extends SgdsElement {\n static styles = [...SgdsElement.styles, drawerStyles];\n /**@internal */\n static dependencies = {\n \"sgds-close-button\": SgdsCloseButton\n };\n\n /** @internal */\n private originalTrigger: HTMLElement | null;\n /** @internal */\n @query(\".drawer\") drawer: HTMLElement;\n /** @internal */\n @query(\".drawer-panel\") panel: HTMLElement;\n /** @internal */\n @query(\".drawer-overlay\") overlay: HTMLElement;\n\n /**\n * Indicates whether or not the drawer is open. You can toggle this attribute to show and hide the drawer, or you can\n * use the `show()` and `hide()` methods and this attribute will reflect the drawer's open state.\n */\n @property({ type: Boolean, reflect: true }) open = false;\n\n /**\n * Defines the size of the drawer panel.\n * For drawers placed on the left or right (`start`/`end`), this controls the drawer's width.\n * For drawers placed on the top or bottom, this controls the drawer's height.\n * Accepts `small`, `medium`, or `large`. Defaults to `small`.\n */\n @property({ type: String, reflect: true }) size: \"sm\" | \"md\" | \"lg\" = \"sm\";\n\n /** The direction from which the drawer will open. */\n @property({ type: String, reflect: true }) placement: \"top\" | \"end\" | \"bottom\" | \"start\" = \"end\";\n\n /**\n * The accessible label for the drawer dialog. This is required for assistive technology.\n */\n @property({ type: String }) ariaLabel = \"Drawer\";\n\n /**\n * By default, the drawer slides out of its containing block (usually the viewport). To make the drawer slide out of\n * its parent element, set this attribute and add `position: relative` to the parent.\n */\n @property({ type: Boolean, reflect: true }) contained = false;\n\n firstUpdated(changedProperties: PropertyValueMap<this>) {\n super.firstUpdated(changedProperties);\n\n if (this.open) {\n this.addOpenListeners();\n\n if (!this.contained) {\n lockBodyScrolling(this);\n }\n }\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n\n unlockBodyScrolling(this);\n }\n\n private uppercaseFirstLetter(string: string) {\n return string.charAt(0).toUpperCase() + string.slice(1);\n }\n\n private requestClose(source: \"close-button\" | \"keyboard\" | \"overlay\") {\n const slRequestClose = this.emit(\"sgds-request-close\", {\n cancelable: true,\n detail: { source }\n });\n\n if (slRequestClose.defaultPrevented) {\n const animation = getAnimation(this, \"drawer.denyClose\");\n animateTo(this.panel, animation.keyframes, animation.options);\n return;\n }\n\n this.hide();\n }\n\n private addOpenListeners() {\n document.addEventListener(\"keydown\", this.handleDocumentKeyDown);\n }\n\n private removeOpenListeners() {\n document.removeEventListener(\"keydown\", this.handleDocumentKeyDown);\n }\n\n private handleDocumentKeyDown = (event: KeyboardEvent) => {\n if (this.open && !this.contained && event.key === \"Escape\") {\n event.stopPropagation();\n this.requestClose(\"keyboard\");\n }\n };\n\n @watch(\"open\", { waitUntilFirstUpdate: true })\n async handleOpenChange() {\n if (this.open) {\n // Show\n this.emit(\"sgds-show\");\n this.addOpenListeners();\n this.originalTrigger = document.activeElement as HTMLElement;\n\n // Lock body scrolling only if the drawer isn't contained\n if (!this.contained) {\n lockBodyScrolling(this);\n }\n\n // When the drawer is shown, Safari will attempt to set focus on whatever element has autofocus. This causes the\n // drawer's animation to jitter, so we'll temporarily remove the attribute, call `focus({ preventScroll: true })`\n // ourselves, and add the attribute back afterwards.\n //\n // Related: https://github.com/shoelace-style/shoelace/issues/693\n //\n const autoFocusTarget = this.querySelector(\"[autofocus]\");\n if (autoFocusTarget) {\n autoFocusTarget.removeAttribute(\"autofocus\");\n }\n\n await Promise.all([stopAnimations(this.drawer), stopAnimations(this.overlay)]);\n this.drawer.hidden = false;\n\n // Set initial focus\n requestAnimationFrame(() => {\n const slInitialFocus = this.emit(\"sgds-initial-focus\", { cancelable: true });\n\n if (!slInitialFocus.defaultPrevented) {\n // Set focus to the autofocus target and restore the attribute\n if (autoFocusTarget) {\n (autoFocusTarget as HTMLInputElement).focus({ preventScroll: true });\n } else {\n this.panel.focus({ preventScroll: true });\n }\n }\n\n // Restore the autofocus attribute\n if (autoFocusTarget) {\n autoFocusTarget.setAttribute(\"autofocus\", \"\");\n }\n });\n\n const panelAnimation = getAnimation(this, `drawer.show${this.uppercaseFirstLetter(this.placement)}`);\n const overlayAnimation = getAnimation(this, \"drawer.overlay.show\");\n await Promise.all([\n animateTo(this.panel, panelAnimation.keyframes, panelAnimation.options),\n animateTo(this.overlay, overlayAnimation.keyframes, overlayAnimation.options)\n ]);\n\n this.emit(\"sgds-after-show\");\n } else {\n // Hide\n this.emit(\"sgds-hide\");\n this.removeOpenListeners();\n\n if (!this.contained) {\n unlockBodyScrolling(this);\n }\n\n await Promise.all([stopAnimations(this.drawer), stopAnimations(this.overlay)]);\n const panelAnimation = getAnimation(this, `drawer.hide${this.uppercaseFirstLetter(this.placement)}`);\n const overlayAnimation = getAnimation(this, \"drawer.overlay.hide\");\n\n // Animate the overlay and the panel at the same time. Because animation durations might be different, we need to\n // hide each one individually when the animation finishes, otherwise the first one that finishes will reappear\n // unexpectedly. We'll unhide them after all animations have completed.\n await Promise.all([\n animateTo(this.overlay, overlayAnimation.keyframes, overlayAnimation.options).then(() => {\n this.overlay.hidden = true;\n }),\n animateTo(this.panel, panelAnimation.keyframes, panelAnimation.options).then(() => {\n this.panel.hidden = true;\n })\n ]);\n\n this.drawer.hidden = true;\n\n // Now that the dialog is hidden, restore the overlay and panel for next time\n this.overlay.hidden = false;\n this.panel.hidden = false;\n\n // Restore focus to the original trigger\n const trigger = this.originalTrigger;\n if (typeof trigger?.focus === \"function\") {\n setTimeout(() => trigger.focus());\n }\n\n this.emit(\"sgds-after-hide\");\n }\n }\n\n @watch(\"contained\", { waitUntilFirstUpdate: true })\n handleNoModalChange() {\n if (this.open && !this.contained) {\n lockBodyScrolling(this);\n }\n\n if (this.open && this.contained) {\n unlockBodyScrolling(this);\n }\n }\n\n /** Shows the drawer. */\n public async show() {\n if (this.open) {\n return undefined;\n }\n\n this.open = true;\n return waitForEvent(this, \"sgds-after-show\");\n }\n\n /** Hides the drawer */\n public async hide() {\n if (!this.open) {\n return undefined;\n }\n\n this.open = false;\n return waitForEvent(this, \"sgds-after-hide\");\n }\n\n render() {\n const isHydrated = this.hasUpdated;\n const shouldHide = !this.open && !isHydrated;\n\n return html`\n <div\n class=${classMap({\n drawer: true,\n \"drawer-top\": this.placement === \"top\",\n \"drawer-end\": this.placement === \"end\",\n \"drawer-bottom\": this.placement === \"bottom\",\n \"drawer-start\": this.placement === \"start\",\n \"drawer-contained\": this.contained,\n \"drawer-fixed\": !this.contained\n })}\n ?hidden=${shouldHide}\n >\n <div class=\"drawer-overlay\" @click=${() => this.requestClose(\"overlay\")} tabindex=\"-1\"></div>\n\n <div\n class=\"drawer-panel\"\n role=\"dialog\"\n aria-modal=\"true\"\n aria-label=${ifDefined(this.ariaLabel)}\n aria-hidden=${this.open ? \"false\" : \"true\"}\n tabindex=\"0\"\n >\n <div class=\"drawer-close-wrapper\">\n <sgds-close-button\n class=\"drawer-close\"\n aria-label=\"close drawer\"\n @click=\"${() => this.requestClose(\"close-button\")}\"\n ></sgds-close-button>\n </div>\n <div class=\"drawer-header_and_body\">\n <div class=\"drawer-header\">\n <slot name=\"title\"></slot>\n <slot name=\"description\"></slot>\n </div>\n </div>\n <div>\n <slot class=\"drawer-body\"></slot>\n <slot name=\"footer\"></slot>\n </div>\n </div>\n </div>\n `;\n }\n}\n\n// Top\nsetDefaultAnimation(\"drawer.showTop\", {\n keyframes: [\n { opacity: 0, translate: \"0 -100%\" },\n { opacity: 1, translate: \"0 0\" }\n ],\n options: { duration: 250, easing: \"ease\" }\n});\n\nsetDefaultAnimation(\"drawer.hideTop\", {\n keyframes: [\n { opacity: 1, translate: \"0 0\" },\n { opacity: 0, translate: \"0 -100%\" }\n ],\n options: { duration: 250, easing: \"ease\" }\n});\n\n// End\nsetDefaultAnimation(\"drawer.showEnd\", {\n keyframes: [\n { opacity: 0, translate: \"100%\" },\n { opacity: 1, translate: \"0\" }\n ],\n rtlKeyframes: [\n { opacity: 0, translate: \"-100%\" },\n { opacity: 1, translate: \"0\" }\n ],\n options: { duration: 250, easing: \"ease\" }\n});\n\nsetDefaultAnimation(\"drawer.hideEnd\", {\n keyframes: [\n { opacity: 1, translate: \"0\" },\n { opacity: 0, translate: \"100%\" }\n ],\n rtlKeyframes: [\n { opacity: 1, translate: \"0\" },\n { opacity: 0, translate: \"-100%\" }\n ],\n options: { duration: 250, easing: \"ease\" }\n});\n\n// Bottom\nsetDefaultAnimation(\"drawer.showBottom\", {\n keyframes: [\n { opacity: 0, translate: \"0 100%\" },\n { opacity: 1, translate: \"0 0\" }\n ],\n options: { duration: 250, easing: \"ease\" }\n});\n\nsetDefaultAnimation(\"drawer.hideBottom\", {\n keyframes: [\n { opacity: 1, translate: \"0 0\" },\n { opacity: 0, translate: \"0 100%\" }\n ],\n options: { duration: 250, easing: \"ease\" }\n});\n\n// Start\nsetDefaultAnimation(\"drawer.showStart\", {\n keyframes: [\n { opacity: 0, translate: \"-100%\" },\n { opacity: 1, translate: \"0\" }\n ],\n rtlKeyframes: [\n { opacity: 0, translate: \"100%\" },\n { opacity: 1, translate: \"0\" }\n ],\n options: { duration: 250, easing: \"ease\" }\n});\n\nsetDefaultAnimation(\"drawer.hideStart\", {\n keyframes: [\n { opacity: 1, translate: \"0\" },\n { opacity: 0, translate: \"-100%\" }\n ],\n rtlKeyframes: [\n { opacity: 1, translate: \"0\" },\n { opacity: 0, translate: \"100%\" }\n ],\n options: { duration: 250, easing: \"ease\" }\n});\n\n// Deny close\nsetDefaultAnimation(\"drawer.denyClose\", {\n keyframes: [{ scale: 1 }, { scale: 1.01 }, { scale: 1 }],\n options: { duration: 250 }\n});\n\n// Overlay\nsetDefaultAnimation(\"drawer.overlay.show\", {\n keyframes: [{ opacity: 0 }, { opacity: 1 }],\n options: { duration: 250 }\n});\n\nsetDefaultAnimation(\"drawer.overlay.hide\", {\n keyframes: [{ opacity: 1 }, { opacity: 0 }],\n options: { duration: 250 }\n});\n\nexport default SgdsDrawer;\n"],"names":["drawerStyles"],"mappings":";;;;;;;;;;;;;;;AAaA;;;;;;;;;;;;;;;;;;;AAmBG;AACG,MAAO,UAAW,SAAQ,WAAW,CAAA;AAA3C,IAAA,WAAA,GAAA;;AAgBE;;;AAGG;QACyC,IAAI,CAAA,IAAA,GAAG,KAAK,CAAC;AAEzD;;;;;AAKG;QACwC,IAAI,CAAA,IAAA,GAAuB,IAAI,CAAC;;QAGhC,IAAS,CAAA,SAAA,GAAuC,KAAK,CAAC;AAEjG;;AAEG;QACyB,IAAS,CAAA,SAAA,GAAG,QAAQ,CAAC;AAEjD;;;A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E,OAAO,EAAE,CAAC,EAAE,SAAS,EAAE,GAAG,EAAE;AAC9B,QAAA,EAAE,OAAO,EAAE,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE;AAClC,KAAA;IACD,OAAO,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE;AAC3C,CAAA,CAAC,CAAC;AAEH;AACA,mBAAmB,CAAC,kBAAkB,EAAE;AACtC,IAAA,SAAS,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;AACxD,IAAA,OAAO,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE;AAC3B,CAAA,CAAC,CAAC;AAEH;AACA,mBAAmB,CAAC,qBAAqB,EAAE;AACzC,IAAA,SAAS,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;AAC3C,IAAA,OAAO,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE;AAC3B,CAAA,CAAC,CAAC;AAEH,mBAAmB,CAAC,qBAAqB,EAAE;AACzC,IAAA,SAAS,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;AAC3C,IAAA,OAAO,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE;AAC3B,CAAA,CAAC;;;;"}
|
|
@@ -7,6 +7,7 @@ var tslib = require('tslib');
|
|
|
7
7
|
var lit = require('lit');
|
|
8
8
|
var decorators_js = require('lit/decorators.js');
|
|
9
9
|
var classMap_js = require('lit/directives/class-map.js');
|
|
10
|
+
var ifDefined_js = require('lit/directives/if-defined.js');
|
|
10
11
|
var sgdsElement = require('../../base/sgds-element.cjs.js');
|
|
11
12
|
var sgdsIcon = require('../Icon/sgds-icon.cjs.js');
|
|
12
13
|
var dropdownItem = require('./dropdown-item.cjs.js');
|
|
@@ -23,6 +24,8 @@ class SgdsDropdownItem extends sgdsElement["default"] {
|
|
|
23
24
|
this.active = false;
|
|
24
25
|
/** Disables the SgdsMainnavItem */
|
|
25
26
|
this.disabled = false;
|
|
27
|
+
/** Forwards aria-label to the inner clickable element for accessibility */
|
|
28
|
+
this.ariaLabel = "";
|
|
26
29
|
}
|
|
27
30
|
connectedCallback() {
|
|
28
31
|
super.connectedCallback();
|
|
@@ -42,6 +45,7 @@ class SgdsDropdownItem extends sgdsElement["default"] {
|
|
|
42
45
|
active: this.active
|
|
43
46
|
})}"
|
|
44
47
|
tabindex=${this.disabled ? "-1" : "0"}
|
|
48
|
+
aria-label=${ifDefined_js.ifDefined(this.ariaLabel || undefined)}
|
|
45
49
|
>
|
|
46
50
|
<slot></slot>
|
|
47
51
|
</div>
|
|
@@ -61,6 +65,9 @@ tslib.__decorate([
|
|
|
61
65
|
tslib.__decorate([
|
|
62
66
|
decorators_js.property({ type: Boolean, reflect: true })
|
|
63
67
|
], SgdsDropdownItem.prototype, "disabled", void 0);
|
|
68
|
+
tslib.__decorate([
|
|
69
|
+
decorators_js.property({ type: String })
|
|
70
|
+
], SgdsDropdownItem.prototype, "ariaLabel", void 0);
|
|
64
71
|
|
|
65
72
|
exports.SgdsDropdownItem = SgdsDropdownItem;
|
|
66
73
|
exports["default"] = SgdsDropdownItem;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sgds-dropdown-item.cjs.js","sources":["../../../../src/components/Dropdown/sgds-dropdown-item.ts"],"sourcesContent":["import { html } from \"lit\";\nimport { property, queryAssignedElements } from \"lit/decorators.js\";\nimport { classMap } from \"lit/directives/class-map.js\";\nimport SgdsElement from \"../../base/sgds-element\";\nimport SgdsIcon from \"../Icon/sgds-icon\";\nimport dropdownItemStyle from \"./dropdown-item.css\";\nimport dropdownStyle from \"./dropdown.css\";\n/**\n * @summary `SgdsDropdownItem` are navigation links built with `HTMLAnchorElement`. It should be used in the default slot of `SgdsDropdown`\n * @slot default - The default slot for SgdsDropdownItem. Pass in a single anchor tag per dropdown item directly for navigation items.\n */\nexport class SgdsDropdownItem extends SgdsElement {\n static styles = [dropdownStyle, dropdownItemStyle];\n static dependencies = {\n \"sgds-icon\": SgdsIcon\n };\n\n /** @internal */\n @queryAssignedElements({ flatten: true }) private anchor: HTMLAnchorElement[];\n\n /** when true, sets the active stylings of dropdown item */\n @property({ type: Boolean })\n active = false;\n\n /** Disables the SgdsMainnavItem */\n @property({ type: Boolean, reflect: true })\n disabled = false;\n\n connectedCallback(): void {\n super.connectedCallback();\n this.addEventListener(\"keydown\", (e: KeyboardEvent) => {\n if (e.key === \"Enter\" && this.anchor.length > 0) {\n this.anchor[0].click();\n }\n });\n this.setAttribute(\"role\", \"menuitem\");\n this.setAttribute(\"aria-disabled\", `${this.disabled}`);\n }\n\n render() {\n return html`\n <div\n class=\"dropdown-item ${classMap({\n disabled: this.disabled,\n active: this.active\n })}\"\n tabindex=${this.disabled ? \"-1\" : \"0\"}\n >\n <slot></slot>\n </div>\n `;\n }\n}\n\nexport default SgdsDropdownItem;\n"],"names":["SgdsElement","html","classMap","dropdownStyle","dropdownItemStyle","SgdsIcon","__decorate","queryAssignedElements","property"],"mappings":"
|
|
1
|
+
{"version":3,"file":"sgds-dropdown-item.cjs.js","sources":["../../../../src/components/Dropdown/sgds-dropdown-item.ts"],"sourcesContent":["import { html } from \"lit\";\nimport { property, queryAssignedElements } from \"lit/decorators.js\";\nimport { classMap } from \"lit/directives/class-map.js\";\nimport { ifDefined } from \"lit/directives/if-defined.js\";\nimport SgdsElement from \"../../base/sgds-element\";\nimport SgdsIcon from \"../Icon/sgds-icon\";\nimport dropdownItemStyle from \"./dropdown-item.css\";\nimport dropdownStyle from \"./dropdown.css\";\n/**\n * @summary `SgdsDropdownItem` are navigation links built with `HTMLAnchorElement`. It should be used in the default slot of `SgdsDropdown`\n * @slot default - The default slot for SgdsDropdownItem. Pass in a single anchor tag per dropdown item directly for navigation items.\n */\nexport class SgdsDropdownItem extends SgdsElement {\n static styles = [dropdownStyle, dropdownItemStyle];\n static dependencies = {\n \"sgds-icon\": SgdsIcon\n };\n\n /** @internal */\n @queryAssignedElements({ flatten: true }) private anchor: HTMLAnchorElement[];\n\n /** when true, sets the active stylings of dropdown item */\n @property({ type: Boolean })\n active = false;\n\n /** Disables the SgdsMainnavItem */\n @property({ type: Boolean, reflect: true })\n disabled = false;\n\n /** Forwards aria-label to the inner clickable element for accessibility */\n @property({ type: String })\n ariaLabel = \"\";\n\n connectedCallback(): void {\n super.connectedCallback();\n this.addEventListener(\"keydown\", (e: KeyboardEvent) => {\n if (e.key === \"Enter\" && this.anchor.length > 0) {\n this.anchor[0].click();\n }\n });\n this.setAttribute(\"role\", \"menuitem\");\n this.setAttribute(\"aria-disabled\", `${this.disabled}`);\n }\n\n render() {\n return html`\n <div\n class=\"dropdown-item ${classMap({\n disabled: this.disabled,\n active: this.active\n })}\"\n tabindex=${this.disabled ? \"-1\" : \"0\"}\n aria-label=${ifDefined(this.ariaLabel || undefined)}\n >\n <slot></slot>\n </div>\n `;\n }\n}\n\nexport default SgdsDropdownItem;\n"],"names":["SgdsElement","html","classMap","ifDefined","dropdownStyle","dropdownItemStyle","SgdsIcon","__decorate","queryAssignedElements","property"],"mappings":";;;;;;;;;;;;;;;AAQA;;;AAGG;AACG,MAAO,gBAAiB,SAAQA,sBAAW,CAAA;AAAjD,IAAA,WAAA,GAAA;;;QAWE,IAAM,CAAA,MAAA,GAAG,KAAK,CAAC;;QAIf,IAAQ,CAAA,QAAA,GAAG,KAAK,CAAC;;QAIjB,IAAS,CAAA,SAAA,GAAG,EAAE,CAAC;KA2BhB;IAzBC,iBAAiB,GAAA;QACf,KAAK,CAAC,iBAAiB,EAAE,CAAC;QAC1B,IAAI,CAAC,gBAAgB,CAAC,SAAS,EAAE,CAAC,CAAgB,KAAI;AACpD,YAAA,IAAI,CAAC,CAAC,GAAG,KAAK,OAAO,IAAI,IAAI,CAAC,MAAM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,CAAA,EAAA,gBAAA,CAAA,SAAA,EAAA,UAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAIjBF,gBAAA,CAAA;AADC,IAAAE,sBAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;AACZ,CAAA,EAAA,gBAAA,CAAA,SAAA,EAAA,WAAA,EAAA,KAAA,CAAA,CAAA;;;;;"}
|
|
@@ -3,6 +3,7 @@ import { __decorate } from 'tslib';
|
|
|
3
3
|
import { html } from 'lit';
|
|
4
4
|
import { queryAssignedElements, property } from 'lit/decorators.js';
|
|
5
5
|
import { classMap } from 'lit/directives/class-map.js';
|
|
6
|
+
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
6
7
|
import SgdsElement from '../../base/sgds-element.js';
|
|
7
8
|
import { SgdsIcon } from '../Icon/sgds-icon.js';
|
|
8
9
|
import css_248z$1 from './dropdown-item.js';
|
|
@@ -19,6 +20,8 @@ class SgdsDropdownItem extends SgdsElement {
|
|
|
19
20
|
this.active = false;
|
|
20
21
|
/** Disables the SgdsMainnavItem */
|
|
21
22
|
this.disabled = false;
|
|
23
|
+
/** Forwards aria-label to the inner clickable element for accessibility */
|
|
24
|
+
this.ariaLabel = "";
|
|
22
25
|
}
|
|
23
26
|
connectedCallback() {
|
|
24
27
|
super.connectedCallback();
|
|
@@ -38,6 +41,7 @@ class SgdsDropdownItem extends SgdsElement {
|
|
|
38
41
|
active: this.active
|
|
39
42
|
})}"
|
|
40
43
|
tabindex=${this.disabled ? "-1" : "0"}
|
|
44
|
+
aria-label=${ifDefined(this.ariaLabel || undefined)}
|
|
41
45
|
>
|
|
42
46
|
<slot></slot>
|
|
43
47
|
</div>
|
|
@@ -57,6 +61,9 @@ __decorate([
|
|
|
57
61
|
__decorate([
|
|
58
62
|
property({ type: Boolean, reflect: true })
|
|
59
63
|
], SgdsDropdownItem.prototype, "disabled", void 0);
|
|
64
|
+
__decorate([
|
|
65
|
+
property({ type: String })
|
|
66
|
+
], SgdsDropdownItem.prototype, "ariaLabel", void 0);
|
|
60
67
|
|
|
61
68
|
export { SgdsDropdownItem, SgdsDropdownItem as default };
|
|
62
69
|
//# sourceMappingURL=sgds-dropdown-item.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sgds-dropdown-item.js","sources":["../../../../src/components/Dropdown/sgds-dropdown-item.ts"],"sourcesContent":["import { html } from \"lit\";\nimport { property, queryAssignedElements } from \"lit/decorators.js\";\nimport { classMap } from \"lit/directives/class-map.js\";\nimport SgdsElement from \"../../base/sgds-element\";\nimport SgdsIcon from \"../Icon/sgds-icon\";\nimport dropdownItemStyle from \"./dropdown-item.css\";\nimport dropdownStyle from \"./dropdown.css\";\n/**\n * @summary `SgdsDropdownItem` are navigation links built with `HTMLAnchorElement`. It should be used in the default slot of `SgdsDropdown`\n * @slot default - The default slot for SgdsDropdownItem. Pass in a single anchor tag per dropdown item directly for navigation items.\n */\nexport class SgdsDropdownItem extends SgdsElement {\n static styles = [dropdownStyle, dropdownItemStyle];\n static dependencies = {\n \"sgds-icon\": SgdsIcon\n };\n\n /** @internal */\n @queryAssignedElements({ flatten: true }) private anchor: HTMLAnchorElement[];\n\n /** when true, sets the active stylings of dropdown item */\n @property({ type: Boolean })\n active = false;\n\n /** Disables the SgdsMainnavItem */\n @property({ type: Boolean, reflect: true })\n disabled = false;\n\n connectedCallback(): void {\n super.connectedCallback();\n this.addEventListener(\"keydown\", (e: KeyboardEvent) => {\n if (e.key === \"Enter\" && this.anchor.length > 0) {\n this.anchor[0].click();\n }\n });\n this.setAttribute(\"role\", \"menuitem\");\n this.setAttribute(\"aria-disabled\", `${this.disabled}`);\n }\n\n render() {\n return html`\n <div\n class=\"dropdown-item ${classMap({\n disabled: this.disabled,\n active: this.active\n })}\"\n tabindex=${this.disabled ? \"-1\" : \"0\"}\n >\n <slot></slot>\n </div>\n `;\n }\n}\n\nexport default SgdsDropdownItem;\n"],"names":["dropdownStyle","dropdownItemStyle"],"mappings":"
|
|
1
|
+
{"version":3,"file":"sgds-dropdown-item.js","sources":["../../../../src/components/Dropdown/sgds-dropdown-item.ts"],"sourcesContent":["import { html } from \"lit\";\nimport { property, queryAssignedElements } from \"lit/decorators.js\";\nimport { classMap } from \"lit/directives/class-map.js\";\nimport { ifDefined } from \"lit/directives/if-defined.js\";\nimport SgdsElement from \"../../base/sgds-element\";\nimport SgdsIcon from \"../Icon/sgds-icon\";\nimport dropdownItemStyle from \"./dropdown-item.css\";\nimport dropdownStyle from \"./dropdown.css\";\n/**\n * @summary `SgdsDropdownItem` are navigation links built with `HTMLAnchorElement`. It should be used in the default slot of `SgdsDropdown`\n * @slot default - The default slot for SgdsDropdownItem. Pass in a single anchor tag per dropdown item directly for navigation items.\n */\nexport class SgdsDropdownItem extends SgdsElement {\n static styles = [dropdownStyle, dropdownItemStyle];\n static dependencies = {\n \"sgds-icon\": SgdsIcon\n };\n\n /** @internal */\n @queryAssignedElements({ flatten: true }) private anchor: HTMLAnchorElement[];\n\n /** when true, sets the active stylings of dropdown item */\n @property({ type: Boolean })\n active = false;\n\n /** Disables the SgdsMainnavItem */\n @property({ type: Boolean, reflect: true })\n disabled = false;\n\n /** Forwards aria-label to the inner clickable element for accessibility */\n @property({ type: String })\n ariaLabel = \"\";\n\n connectedCallback(): void {\n super.connectedCallback();\n this.addEventListener(\"keydown\", (e: KeyboardEvent) => {\n if (e.key === \"Enter\" && this.anchor.length > 0) {\n this.anchor[0].click();\n }\n });\n this.setAttribute(\"role\", \"menuitem\");\n this.setAttribute(\"aria-disabled\", `${this.disabled}`);\n }\n\n render() {\n return html`\n <div\n class=\"dropdown-item ${classMap({\n disabled: this.disabled,\n active: this.active\n })}\"\n tabindex=${this.disabled ? \"-1\" : \"0\"}\n aria-label=${ifDefined(this.ariaLabel || undefined)}\n >\n <slot></slot>\n </div>\n `;\n }\n}\n\nexport default SgdsDropdownItem;\n"],"names":["dropdownStyle","dropdownItemStyle"],"mappings":";;;;;;;;;;;AAQA;;;AAGG;AACG,MAAO,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,EAAE,IAAI,EAAE,CAAC;AAAqC,CAAA,EAAA,gBAAA,CAAA,SAAA,EAAA,QAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAI9E,UAAA,CAAA;AADC,IAAA,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AACb,CAAA,EAAA,gBAAA,CAAA,SAAA,EAAA,QAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAIf,UAAA,CAAA;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAC1B,CAAA,EAAA,gBAAA,CAAA,SAAA,EAAA,UAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAIjB,UAAA,CAAA;AADC,IAAA,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;AACZ,CAAA,EAAA,gBAAA,CAAA,SAAA,EAAA,WAAA,EAAA,KAAA,CAAA,CAAA;;;;"}
|
|
@@ -8,6 +8,7 @@ var lit = require('lit');
|
|
|
8
8
|
var context = require('@lit/context');
|
|
9
9
|
var decorators_js = require('lit/decorators.js');
|
|
10
10
|
var classMap_js = require('lit/directives/class-map.js');
|
|
11
|
+
var ifDefined_js = require('lit/directives/if-defined.js');
|
|
11
12
|
var dom = require('@floating-ui/dom');
|
|
12
13
|
var generateId = require('../../utils/generateId.cjs.js');
|
|
13
14
|
var dropdown = require('../Dropdown/dropdown.cjs.js');
|
|
@@ -213,6 +214,7 @@ class SgdsMainnavDropdown extends sgdsElement["default"] {
|
|
|
213
214
|
disabled: this.disabled
|
|
214
215
|
})}"
|
|
215
216
|
aria-disabled=${this.disabled ? "true" : "false"}
|
|
217
|
+
aria-label=${ifDefined_js.ifDefined(this.ariaLabel)}
|
|
216
218
|
tabindex=${this.disabled ? "-1" : "0"}
|
|
217
219
|
role="button"
|
|
218
220
|
@click=${this._openMenu}
|
|
@@ -242,6 +244,7 @@ class SgdsMainnavDropdown extends sgdsElement["default"] {
|
|
|
242
244
|
disabled: this.disabled
|
|
243
245
|
})}"
|
|
244
246
|
aria-disabled=${this.disabled ? "true" : "false"}
|
|
247
|
+
aria-label=${ifDefined_js.ifDefined(this.ariaLabel)}
|
|
245
248
|
id=${this.togglerId}
|
|
246
249
|
tabindex=${this.disabled ? "-1" : "0"}
|
|
247
250
|
role="button"
|
|
@@ -288,6 +291,9 @@ tslib.__decorate([
|
|
|
288
291
|
tslib.__decorate([
|
|
289
292
|
decorators_js.property({ type: Boolean, reflect: true })
|
|
290
293
|
], SgdsMainnavDropdown.prototype, "disabled", void 0);
|
|
294
|
+
tslib.__decorate([
|
|
295
|
+
decorators_js.property({ type: String })
|
|
296
|
+
], SgdsMainnavDropdown.prototype, "ariaLabel", void 0);
|
|
291
297
|
tslib.__decorate([
|
|
292
298
|
decorators_js.queryAssignedElements({ slot: "toggler" })
|
|
293
299
|
], SgdsMainnavDropdown.prototype, "togglerNodes", void 0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sgds-mainnav-dropdown.cjs.js","sources":["../../../../src/components/Mainnav/sgds-mainnav-dropdown.ts"],"sourcesContent":["import { html } from \"lit\";\nimport { consume } from \"@lit/context\";\nimport { property, query, queryAssignedElements, state } from \"lit/decorators.js\";\nimport { SgdsMainnav } from \"./sgds-mainnav\";\nimport { classMap } from \"lit/directives/class-map.js\";\nimport { offset } from \"@floating-ui/dom\";\nimport genId from \"../../utils/generateId\";\nimport dropdownStyle from \"../Dropdown/dropdown.css\";\nimport dropdownMenuStyle from \"../Dropdown/dropdown-menu.css\";\nimport mainnavDropdownStyle from \"./mainnav-dropdown.css\";\nimport SgdsDropdown from \"../Dropdown/sgds-dropdown\";\nimport SgdsDropdownItem from \"../Dropdown/sgds-dropdown-item\";\nimport SgdsIcon from \"../Icon/sgds-icon\";\nimport { MainnavBreakpointContext, MainnavExpandedContext } from \"./mainnav-context\";\nimport SgdsElement from \"../../base/sgds-element\";\n\nconst TAB = \"Tab\";\nconst ENTER = \"Enter\";\nconst SPACE = \" \";\n\n/**\n * @slot default - The menu items. Pass in sgds-dropdown-item as the menu items\n * @slot toggler - The content of the toggler to pass in html content.\n */\nexport class SgdsMainnavDropdown extends SgdsElement {\n static styles = [...SgdsElement.styles, dropdownStyle, dropdownMenuStyle, mainnavDropdownStyle];\n /** @internal */\n static dependencies = {\n \"sgds-dropdown\": SgdsDropdown,\n \"sgds-dropdown-item\": SgdsDropdownItem,\n \"sgds-icon\": SgdsIcon\n };\n\n @consume({ context: MainnavBreakpointContext, subscribe: true })\n @state()\n private _breakpointReached = true;\n\n @consume({ context: MainnavExpandedContext, subscribe: true })\n @state()\n private expanded: boolean;\n\n /** @internal */\n @query(\".nav-link\") navLink: HTMLElement;\n\n /** @internal */\n @query(\".dropdown-items\") dropdownItems: HTMLElement;\n\n /** @internal */\n @query(\".dropdown-items a\") menuHeaderButton: HTMLElement;\n\n /** @internal */\n @query(\".dropdown-items span\") menuHeaderText: HTMLElement;\n\n /** @internal Forwards value to id attribute of toggle button of Dropdown. An unique id generated by default */\n private togglerId: string = genId(\"dropdown\", \"button\");\n\n /** When true, applies active styles on the dropdown button */\n @property({ type: Boolean })\n active = false;\n\n /** When true, applies active styles on the dropdown button */\n @property({ type: Boolean, reflect: true })\n disabled = false;\n\n /** @internal */\n @queryAssignedElements({ slot: \"toggler\" }) private togglerNodes!: HTMLElement[];\n\n /** @internal */\n @queryAssignedElements() private defaultNodes!: SgdsDropdownItem[];\n\n /** @internal */\n get defaultSlotItems(): SgdsDropdownItem[] {\n return [...(this.defaultNodes || [])].filter(\n (node: HTMLElement) => typeof node.tagName !== \"undefined\"\n ) as SgdsDropdownItem[];\n }\n\n updated() {\n if (this._breakpointReached) {\n this._copyTextToMenu();\n this._resetDropdownMenu();\n this._hideDropdownMenuItems();\n }\n }\n\n private _handleSlotChange(e: Event) {\n const items = (e.target as HTMLSlotElement).assignedElements({ flatten: true }) as SgdsDropdownItem[];\n items.forEach(item => {\n item.addEventListener(\"keydown\", this._handleKeyboardMenuItemsEvent.bind(this));\n\n const dropdownItem = item.shadowRoot.querySelector(\".dropdown-item\") as HTMLElement;\n dropdownItem.classList.add(\"mainnav-dropdown-link\");\n\n const link = item.shadowRoot?.querySelector(\"a\") || item.querySelector(\"a\");\n link.tabIndex = -1;\n if (dropdownItem.classList.contains(\"disabled\")) {\n link.setAttribute(\"href\", \"javascript:void(0)\");\n link.setAttribute(\"tabindex\", \"-1\");\n } else {\n link.addEventListener(\"click\", (e: Event) => {\n const target = e.target as HTMLElement;\n const mainnav = target.closest(\"sgds-mainnav\") as SgdsMainnav;\n mainnav.hide();\n });\n }\n });\n }\n\n private _handleDesktopSlotChange(e: Event) {\n const items = (e.target as HTMLSlotElement).assignedElements({ flatten: true }) as SgdsDropdownItem[];\n items.forEach(item => {\n const dropdownItem = item.shadowRoot.querySelector(\".dropdown-item\") as HTMLElement;\n dropdownItem.classList.remove(\"mainnav-dropdown-link\");\n\n const slottedItem = (item.shadowRoot.querySelector(\".dropdown-item slot\") as HTMLSlotElement).assignedElements({\n flatten: true\n });\n slottedItem.forEach(item => {\n if (dropdownItem.classList.contains(\"disabled\")) {\n item.setAttribute(\"href\", \"javascript:void(0)\");\n item.setAttribute(\"tabindex\", \"-1\");\n }\n });\n });\n }\n\n private _handleKeyboardMenuItemsEvent(e: KeyboardEvent) {\n if (!this._breakpointReached) {\n return;\n }\n\n const slottedItems = this.defaultSlotItems.filter(item => !item.hasAttribute(\"disabled\"));\n const items = [this.menuHeaderButton, ...slottedItems];\n const itemLength = items.length;\n if (itemLength === 0) {\n return;\n }\n\n const firstItem = items[0];\n const lastItem = items[itemLength - 1].shadowRoot.querySelector(\".dropdown-item\") as HTMLElement;\n let activeElement = document.activeElement as HTMLElement;\n if (activeElement === this) {\n activeElement = this.shadowRoot.activeElement as HTMLElement;\n }\n\n switch (e.key) {\n case \"Tab\": {\n if (e.shiftKey) {\n if (activeElement === firstItem) {\n e.preventDefault();\n setTimeout(() => {\n lastItem.focus();\n }, 0);\n }\n } else {\n const activeShadowElement = activeElement.shadowRoot\n ? activeElement.shadowRoot.querySelector(\".dropdown-item\")\n : null;\n if (activeShadowElement && activeShadowElement === lastItem) {\n e.preventDefault();\n firstItem.focus();\n }\n }\n break;\n }\n default:\n break;\n }\n }\n\n private _copyTextToMenu() {\n this.menuHeaderText.innerHTML = this.togglerNodes[0].innerHTML;\n }\n\n private _hideDropdownMenuItems() {\n this.dropdownItems.style.display = \"none\";\n this.dropdownItems.setAttribute(\"aria-hidden\", \"true\");\n }\n\n private _resetDropdownMenu(): Promise<void> {\n const navbarBody = this._getNavbarBody();\n if (!navbarBody) return Promise.resolve();\n\n return new Promise(resolve => {\n const onEnd = (event: TransitionEvent) => {\n if (event.propertyName === \"transform\") {\n navbarBody.removeEventListener(\"transitionend\", onEnd);\n resolve();\n }\n };\n\n const hasTransition = getComputedStyle(navbarBody).transitionProperty.includes(\"transform\");\n\n if (hasTransition) {\n navbarBody.addEventListener(\"transitionend\", onEnd);\n navbarBody.style.removeProperty(\"transform\");\n } else {\n navbarBody.style.removeProperty(\"transform\");\n resolve();\n }\n });\n }\n\n private _handleKeyboardOpen(event: KeyboardEvent) {\n if (this.disabled) {\n return;\n }\n\n if (event.key === ENTER || event.key === SPACE) {\n event.preventDefault();\n this._openMenu();\n }\n }\n\n private _getNavbarBody() {\n const mainNav = document.querySelector(\"sgds-mainnav\") as HTMLElement | null;\n\n if (!mainNav?.shadowRoot) {\n console.warn(\"sgds-mainnav or its shadowRoot not found\");\n return;\n }\n\n const navbarBody = mainNav.shadowRoot.querySelector(\".navbar-body\") as HTMLElement;\n if (!navbarBody) {\n console.warn(\".navbar-body not found in sgds-mainnav\");\n return;\n }\n\n return navbarBody;\n }\n\n private _openMenu() {\n const navbarBody = this._getNavbarBody();\n navbarBody.style.transform = \"translateX(-100%)\";\n this.dropdownItems.style.removeProperty(\"display\");\n this.dropdownItems.setAttribute(\"aria-hidden\", \"false\");\n setTimeout(() => {\n this.menuHeaderButton.focus();\n }, 50);\n }\n\n private _handleHeaderKeyboardEvent(event: KeyboardEvent) {\n switch (event.key) {\n case TAB: {\n this._handleKeyboardMenuItemsEvent(event);\n break;\n }\n case ENTER:\n case SPACE: {\n event.preventDefault();\n this._closeMenu();\n break;\n }\n default:\n break;\n }\n }\n\n private async _closeMenu() {\n await this._resetDropdownMenu();\n this._hideDropdownMenuItems();\n this.navLink.focus();\n }\n\n render() {\n const mobileView = html`\n <a\n class=\"${classMap({\n \"nav-link\": true,\n active: this.active,\n disabled: this.disabled\n })}\"\n aria-disabled=${this.disabled ? \"true\" : \"false\"}\n tabindex=${this.disabled ? \"-1\" : \"0\"}\n role=\"button\"\n @click=${this._openMenu}\n @keydown=${this._handleKeyboardOpen}\n >\n <slot name=\"toggler\"></slot>\n <sgds-icon name=\"chevron-right\"></sgds-icon>\n </a>\n <div class=\"dropdown-items\">\n <a tabindex=\"0\" role=\"button\" @click=${this._closeMenu} @keydown=${this._handleHeaderKeyboardEvent}>\n <sgds-icon name=\"chevron-left\"></sgds-icon>\n <span></span>\n </a>\n <slot @slotchange=${this._handleSlotChange}></slot>\n </div>\n `;\n\n const desktopView = html`<sgds-dropdown\n .floatingOpts=${{\n middleware: [offset(0)]\n }}\n ?disabled=${this.disabled}\n >\n <a\n class=\"${classMap({\n \"nav-link\": true,\n active: this.active,\n disabled: this.disabled\n })}\"\n aria-disabled=${this.disabled ? \"true\" : \"false\"}\n id=${this.togglerId}\n tabindex=${this.disabled ? \"-1\" : \"0\"}\n role=\"button\"\n slot=\"toggler\"\n >\n <slot name=\"toggler\"></slot>\n <sgds-icon name=\"chevron-down\"></sgds-icon>\n </a>\n <slot @slotchange=${this._handleDesktopSlotChange}></slot>\n </sgds-dropdown>`;\n\n return this._breakpointReached ? mobileView : desktopView;\n }\n}\n\nexport default SgdsMainnavDropdown;\n"],"names":["SgdsElement","genId","html","classMap","offset","dropdownStyle","dropdownMenuStyle","mainnavDropdownStyle","SgdsDropdown","SgdsDropdownItem","SgdsIcon","__decorate","consume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AAE,IAAI,EAAE,CAAC;AAC1B,CAAA,EAAA,mBAAA,CAAA,SAAA,EAAA,UAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAGmCN,gBAAA,CAAA;AAAnD,IAAAO,mCAAqB,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;AAAsC,CAAA,EAAA,mBAAA,CAAA,SAAA,EAAA,cAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAGhDP,gBAAA,CAAA;AAAhC,IAAAO,mCAAqB,EAAE;AAA2C,CAAA,EAAA,mBAAA,CAAA,SAAA,EAAA,cAAA,EAAA,KAAA,CAAA,CAAA;;;;;"}
|
|
1
|
+
{"version":3,"file":"sgds-mainnav-dropdown.cjs.js","sources":["../../../../src/components/Mainnav/sgds-mainnav-dropdown.ts"],"sourcesContent":["import { html } from \"lit\";\nimport { consume } from \"@lit/context\";\nimport { property, query, queryAssignedElements, state } from \"lit/decorators.js\";\nimport { SgdsMainnav } from \"./sgds-mainnav\";\nimport { classMap } from \"lit/directives/class-map.js\";\nimport { ifDefined } from \"lit/directives/if-defined.js\";\nimport { offset } from \"@floating-ui/dom\";\nimport genId from \"../../utils/generateId\";\nimport dropdownStyle from \"../Dropdown/dropdown.css\";\nimport dropdownMenuStyle from \"../Dropdown/dropdown-menu.css\";\nimport mainnavDropdownStyle from \"./mainnav-dropdown.css\";\nimport SgdsDropdown from \"../Dropdown/sgds-dropdown\";\nimport SgdsDropdownItem from \"../Dropdown/sgds-dropdown-item\";\nimport SgdsIcon from \"../Icon/sgds-icon\";\nimport { MainnavBreakpointContext, MainnavExpandedContext } from \"./mainnav-context\";\nimport SgdsElement from \"../../base/sgds-element\";\n\nconst TAB = \"Tab\";\nconst ENTER = \"Enter\";\nconst SPACE = \" \";\n\n/**\n * @slot default - The menu items. Pass in sgds-dropdown-item as the menu items\n * @slot toggler - The content of the toggler to pass in html content.\n */\nexport class SgdsMainnavDropdown extends SgdsElement {\n static styles = [...SgdsElement.styles, dropdownStyle, dropdownMenuStyle, mainnavDropdownStyle];\n /** @internal */\n static dependencies = {\n \"sgds-dropdown\": SgdsDropdown,\n \"sgds-dropdown-item\": SgdsDropdownItem,\n \"sgds-icon\": SgdsIcon\n };\n\n @consume({ context: MainnavBreakpointContext, subscribe: true })\n @state()\n private _breakpointReached = true;\n\n @consume({ context: MainnavExpandedContext, subscribe: true })\n @state()\n private expanded: boolean;\n\n /** @internal */\n @query(\".nav-link\") navLink: HTMLElement;\n\n /** @internal */\n @query(\".dropdown-items\") dropdownItems: HTMLElement;\n\n /** @internal */\n @query(\".dropdown-items a\") menuHeaderButton: HTMLElement;\n\n /** @internal */\n @query(\".dropdown-items span\") menuHeaderText: HTMLElement;\n\n /** @internal Forwards value to id attribute of toggle button of Dropdown. An unique id generated by default */\n private togglerId: string = genId(\"dropdown\", \"button\");\n\n /** When true, applies active styles on the dropdown button */\n @property({ type: Boolean })\n active = false;\n\n /** When true, applies active styles on the dropdown button */\n @property({ type: Boolean, reflect: true })\n disabled = false;\n\n /**\n * Accessible label for the dropdown's toggle button. Forwarded to the button's aria-label attribute.\n */\n @property({ type: String })\n ariaLabel: string;\n\n /** @internal */\n @queryAssignedElements({ slot: \"toggler\" }) private togglerNodes!: HTMLElement[];\n\n /** @internal */\n @queryAssignedElements() private defaultNodes!: SgdsDropdownItem[];\n\n /** @internal */\n get defaultSlotItems(): SgdsDropdownItem[] {\n return [...(this.defaultNodes || [])].filter(\n (node: HTMLElement) => typeof node.tagName !== \"undefined\"\n ) as SgdsDropdownItem[];\n }\n\n updated() {\n if (this._breakpointReached) {\n this._copyTextToMenu();\n this._resetDropdownMenu();\n this._hideDropdownMenuItems();\n }\n }\n\n private _handleSlotChange(e: Event) {\n const items = (e.target as HTMLSlotElement).assignedElements({ flatten: true }) as SgdsDropdownItem[];\n items.forEach(item => {\n item.addEventListener(\"keydown\", this._handleKeyboardMenuItemsEvent.bind(this));\n\n const dropdownItem = item.shadowRoot.querySelector(\".dropdown-item\") as HTMLElement;\n dropdownItem.classList.add(\"mainnav-dropdown-link\");\n\n const link = item.shadowRoot?.querySelector(\"a\") || item.querySelector(\"a\");\n link.tabIndex = -1;\n if (dropdownItem.classList.contains(\"disabled\")) {\n link.setAttribute(\"href\", \"javascript:void(0)\");\n link.setAttribute(\"tabindex\", \"-1\");\n } else {\n link.addEventListener(\"click\", (e: Event) => {\n const target = e.target as HTMLElement;\n const mainnav = target.closest(\"sgds-mainnav\") as SgdsMainnav;\n mainnav.hide();\n });\n }\n });\n }\n\n private _handleDesktopSlotChange(e: Event) {\n const items = (e.target as HTMLSlotElement).assignedElements({ flatten: true }) as SgdsDropdownItem[];\n items.forEach(item => {\n const dropdownItem = item.shadowRoot.querySelector(\".dropdown-item\") as HTMLElement;\n dropdownItem.classList.remove(\"mainnav-dropdown-link\");\n\n const slottedItem = (item.shadowRoot.querySelector(\".dropdown-item slot\") as HTMLSlotElement).assignedElements({\n flatten: true\n });\n slottedItem.forEach(item => {\n if (dropdownItem.classList.contains(\"disabled\")) {\n item.setAttribute(\"href\", \"javascript:void(0)\");\n item.setAttribute(\"tabindex\", \"-1\");\n }\n });\n });\n }\n\n private _handleKeyboardMenuItemsEvent(e: KeyboardEvent) {\n if (!this._breakpointReached) {\n return;\n }\n\n const slottedItems = this.defaultSlotItems.filter(item => !item.hasAttribute(\"disabled\"));\n const items = [this.menuHeaderButton, ...slottedItems];\n const itemLength = items.length;\n if (itemLength === 0) {\n return;\n }\n\n const firstItem = items[0];\n const lastItem = items[itemLength - 1].shadowRoot.querySelector(\".dropdown-item\") as HTMLElement;\n let activeElement = document.activeElement as HTMLElement;\n if (activeElement === this) {\n activeElement = this.shadowRoot.activeElement as HTMLElement;\n }\n\n switch (e.key) {\n case \"Tab\": {\n if (e.shiftKey) {\n if (activeElement === firstItem) {\n e.preventDefault();\n setTimeout(() => {\n lastItem.focus();\n }, 0);\n }\n } else {\n const activeShadowElement = activeElement.shadowRoot\n ? activeElement.shadowRoot.querySelector(\".dropdown-item\")\n : null;\n if (activeShadowElement && activeShadowElement === lastItem) {\n e.preventDefault();\n firstItem.focus();\n }\n }\n break;\n }\n default:\n break;\n }\n }\n\n private _copyTextToMenu() {\n this.menuHeaderText.innerHTML = this.togglerNodes[0].innerHTML;\n }\n\n private _hideDropdownMenuItems() {\n this.dropdownItems.style.display = \"none\";\n this.dropdownItems.setAttribute(\"aria-hidden\", \"true\");\n }\n\n private _resetDropdownMenu(): Promise<void> {\n const navbarBody = this._getNavbarBody();\n if (!navbarBody) return Promise.resolve();\n\n return new Promise(resolve => {\n const onEnd = (event: TransitionEvent) => {\n if (event.propertyName === \"transform\") {\n navbarBody.removeEventListener(\"transitionend\", onEnd);\n resolve();\n }\n };\n\n const hasTransition = getComputedStyle(navbarBody).transitionProperty.includes(\"transform\");\n\n if (hasTransition) {\n navbarBody.addEventListener(\"transitionend\", onEnd);\n navbarBody.style.removeProperty(\"transform\");\n } else {\n navbarBody.style.removeProperty(\"transform\");\n resolve();\n }\n });\n }\n\n private _handleKeyboardOpen(event: KeyboardEvent) {\n if (this.disabled) {\n return;\n }\n\n if (event.key === ENTER || event.key === SPACE) {\n event.preventDefault();\n this._openMenu();\n }\n }\n\n private _getNavbarBody() {\n const mainNav = document.querySelector(\"sgds-mainnav\") as HTMLElement | null;\n\n if (!mainNav?.shadowRoot) {\n console.warn(\"sgds-mainnav or its shadowRoot not found\");\n return;\n }\n\n const navbarBody = mainNav.shadowRoot.querySelector(\".navbar-body\") as HTMLElement;\n if (!navbarBody) {\n console.warn(\".navbar-body not found in sgds-mainnav\");\n return;\n }\n\n return navbarBody;\n }\n\n private _openMenu() {\n const navbarBody = this._getNavbarBody();\n navbarBody.style.transform = \"translateX(-100%)\";\n this.dropdownItems.style.removeProperty(\"display\");\n this.dropdownItems.setAttribute(\"aria-hidden\", \"false\");\n setTimeout(() => {\n this.menuHeaderButton.focus();\n }, 50);\n }\n\n private _handleHeaderKeyboardEvent(event: KeyboardEvent) {\n switch (event.key) {\n case TAB: {\n this._handleKeyboardMenuItemsEvent(event);\n break;\n }\n case ENTER:\n case SPACE: {\n event.preventDefault();\n this._closeMenu();\n break;\n }\n default:\n break;\n }\n }\n\n private async _closeMenu() {\n await this._resetDropdownMenu();\n this._hideDropdownMenuItems();\n this.navLink.focus();\n }\n\n render() {\n const mobileView = html`\n <a\n class=\"${classMap({\n \"nav-link\": true,\n active: this.active,\n disabled: this.disabled\n })}\"\n aria-disabled=${this.disabled ? \"true\" : \"false\"}\n aria-label=${ifDefined(this.ariaLabel)}\n tabindex=${this.disabled ? \"-1\" : \"0\"}\n role=\"button\"\n @click=${this._openMenu}\n @keydown=${this._handleKeyboardOpen}\n >\n <slot name=\"toggler\"></slot>\n <sgds-icon name=\"chevron-right\"></sgds-icon>\n </a>\n <div class=\"dropdown-items\">\n <a tabindex=\"0\" role=\"button\" @click=${this._closeMenu} @keydown=${this._handleHeaderKeyboardEvent}>\n <sgds-icon name=\"chevron-left\"></sgds-icon>\n <span></span>\n </a>\n <slot @slotchange=${this._handleSlotChange}></slot>\n </div>\n `;\n\n const desktopView = html`<sgds-dropdown\n .floatingOpts=${{\n middleware: [offset(0)]\n }}\n ?disabled=${this.disabled}\n >\n <a\n class=\"${classMap({\n \"nav-link\": true,\n active: this.active,\n disabled: this.disabled\n })}\"\n aria-disabled=${this.disabled ? \"true\" : \"false\"}\n aria-label=${ifDefined(this.ariaLabel)}\n id=${this.togglerId}\n tabindex=${this.disabled ? \"-1\" : \"0\"}\n role=\"button\"\n slot=\"toggler\"\n >\n <slot name=\"toggler\"></slot>\n <sgds-icon name=\"chevron-down\"></sgds-icon>\n </a>\n <slot @slotchange=${this._handleDesktopSlotChange}></slot>\n </sgds-dropdown>`;\n\n return this._breakpointReached ? mobileView : desktopView;\n }\n}\n\nexport default SgdsMainnavDropdown;\n"],"names":["SgdsElement","genId","html","classMap","ifDefined","offset","dropdownStyle","dropdownMenuStyle","mainnavDropdownStyle","SgdsDropdown","SgdsDropdownItem","SgdsIcon","__decorate","consume","MainnavBreakpointContext","state","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AAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAIfN,gBAAA,CAAA;IADCM,sBAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAC1B,CAAA,EAAA,mBAAA,CAAA,SAAA,EAAA,UAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAMjBN,gBAAA,CAAA;AADC,IAAAM,sBAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;AACT,CAAA,EAAA,mBAAA,CAAA,SAAA,EAAA,WAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAGkCN,gBAAA,CAAA;AAAnD,IAAAO,mCAAqB,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;AAAsC,CAAA,EAAA,mBAAA,CAAA,SAAA,EAAA,cAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAGhDP,gBAAA,CAAA;AAAhC,IAAAO,mCAAqB,EAAE;AAA2C,CAAA,EAAA,mBAAA,CAAA,SAAA,EAAA,cAAA,EAAA,KAAA,CAAA,CAAA;;;;;"}
|
|
@@ -4,6 +4,7 @@ import { html } from 'lit';
|
|
|
4
4
|
import { consume } from '@lit/context';
|
|
5
5
|
import { state, query, property, queryAssignedElements } from 'lit/decorators.js';
|
|
6
6
|
import { classMap } from 'lit/directives/class-map.js';
|
|
7
|
+
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
7
8
|
import { offset } from '@floating-ui/dom';
|
|
8
9
|
import genId from '../../utils/generateId.js';
|
|
9
10
|
import css_248z from '../Dropdown/dropdown.js';
|
|
@@ -209,6 +210,7 @@ class SgdsMainnavDropdown extends SgdsElement {
|
|
|
209
210
|
disabled: this.disabled
|
|
210
211
|
})}"
|
|
211
212
|
aria-disabled=${this.disabled ? "true" : "false"}
|
|
213
|
+
aria-label=${ifDefined(this.ariaLabel)}
|
|
212
214
|
tabindex=${this.disabled ? "-1" : "0"}
|
|
213
215
|
role="button"
|
|
214
216
|
@click=${this._openMenu}
|
|
@@ -238,6 +240,7 @@ class SgdsMainnavDropdown extends SgdsElement {
|
|
|
238
240
|
disabled: this.disabled
|
|
239
241
|
})}"
|
|
240
242
|
aria-disabled=${this.disabled ? "true" : "false"}
|
|
243
|
+
aria-label=${ifDefined(this.ariaLabel)}
|
|
241
244
|
id=${this.togglerId}
|
|
242
245
|
tabindex=${this.disabled ? "-1" : "0"}
|
|
243
246
|
role="button"
|
|
@@ -284,6 +287,9 @@ __decorate([
|
|
|
284
287
|
__decorate([
|
|
285
288
|
property({ type: Boolean, reflect: true })
|
|
286
289
|
], SgdsMainnavDropdown.prototype, "disabled", void 0);
|
|
290
|
+
__decorate([
|
|
291
|
+
property({ type: String })
|
|
292
|
+
], SgdsMainnavDropdown.prototype, "ariaLabel", void 0);
|
|
287
293
|
__decorate([
|
|
288
294
|
queryAssignedElements({ slot: "toggler" })
|
|
289
295
|
], SgdsMainnavDropdown.prototype, "togglerNodes", void 0);
|