@govtechsg/sgds-web-component 3.3.3-rc.2 → 3.4.0-rc.1
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/Masthead/index.js +1 -1
- package/base/card-element.d.ts +2 -1
- package/base/card-element.js +2 -10
- package/base/card-element.js.map +1 -1
- package/base/card.js +1 -1
- package/base/sgds-element2.js +1 -1
- package/components/Accordion/index.umd.js +1 -1
- package/components/Alert/index.umd.js +1 -1
- package/components/Badge/index.umd.js +1 -1
- package/components/Breadcrumb/index.umd.js +1 -1
- package/components/Button/index.umd.js +1 -1
- package/components/Card/index.umd.js +3716 -3705
- package/components/Card/index.umd.js.map +1 -1
- package/components/Card/sgds-card.d.ts +8 -1
- package/components/Card/sgds-card.js +47 -14
- package/components/Card/sgds-card.js.map +1 -1
- package/components/Checkbox/index.umd.js +1 -1
- package/components/ComboBox/index.umd.js +9 -1
- package/components/ComboBox/index.umd.js.map +1 -1
- package/components/ComboBox/sgds-combo-box.d.ts +4 -0
- package/components/ComboBox/sgds-combo-box.js +8 -0
- package/components/ComboBox/sgds-combo-box.js.map +1 -1
- package/components/Datepicker/index.umd.js +1 -1
- package/components/DescriptionList/index.umd.js +1 -1
- package/components/Divider/index.umd.js +1 -1
- package/components/Drawer/drawer.js +1 -1
- package/components/Drawer/index.umd.js +17 -4
- package/components/Drawer/index.umd.js.map +1 -1
- package/components/Drawer/sgds-drawer.d.ts +8 -0
- package/components/Drawer/sgds-drawer.js +15 -2
- package/components/Drawer/sgds-drawer.js.map +1 -1
- package/components/Dropdown/index.umd.js +1 -1
- package/components/FileUpload/index.umd.js +1 -1
- package/components/Footer/index.umd.js +1 -1
- package/components/Icon/index.umd.js +1 -1
- package/components/IconButton/index.umd.js +1 -1
- package/components/IconCard/index.umd.js +93 -137
- package/components/IconCard/index.umd.js.map +1 -1
- package/components/IconCard/sgds-icon-card.d.ts +7 -2
- package/components/IconCard/sgds-icon-card.js +39 -12
- package/components/IconCard/sgds-icon-card.js.map +1 -1
- package/components/IconList/index.umd.js +1 -1
- package/components/ImageCard/index.umd.js +91 -136
- package/components/ImageCard/index.umd.js.map +1 -1
- package/components/ImageCard/sgds-image-card.d.ts +7 -2
- package/components/ImageCard/sgds-image-card.js +37 -11
- package/components/ImageCard/sgds-image-card.js.map +1 -1
- package/components/Input/index.umd.js +1 -1
- package/components/Link/index.umd.js +1 -1
- package/components/Mainnav/index.umd.js +44 -63
- package/components/Mainnav/index.umd.js.map +1 -1
- package/components/Mainnav/mainnav-context.d.ts +4 -1
- package/components/Mainnav/mainnav-context.js +3 -2
- package/components/Mainnav/mainnav-context.js.map +1 -1
- package/components/Mainnav/sgds-mainnav-dropdown.d.ts +1 -3
- package/components/Mainnav/sgds-mainnav-dropdown.js +13 -33
- package/components/Mainnav/sgds-mainnav-dropdown.js.map +1 -1
- package/components/Mainnav/sgds-mainnav-item.js +4 -2
- package/components/Mainnav/sgds-mainnav-item.js.map +1 -1
- package/components/Mainnav/sgds-mainnav.d.ts +4 -2
- package/components/Mainnav/sgds-mainnav.js +26 -28
- package/components/Mainnav/sgds-mainnav.js.map +1 -1
- package/components/Masthead/index.umd.js +1 -1
- package/components/Modal/index.umd.js +1 -1
- package/components/OverflowMenu/index.umd.js +1 -1
- package/components/Pagination/index.umd.js +1 -1
- package/components/ProgressBar/index.umd.js +1 -1
- package/components/QuantityToggle/index.umd.js +1 -1
- package/components/Radio/index.umd.js +1 -1
- package/components/Select/index.umd.js +12 -1
- package/components/Select/index.umd.js.map +1 -1
- package/components/Select/sgds-select.d.ts +5 -0
- package/components/Select/sgds-select.js +11 -0
- package/components/Select/sgds-select.js.map +1 -1
- package/components/Sidenav/index.umd.js +1 -1
- package/components/Skeleton/index.umd.js +1 -1
- package/components/Spinner/index.umd.js +1 -1
- package/components/Stepper/index.umd.js +1 -1
- package/components/Subnav/index.umd.js +1 -1
- package/components/Switch/index.umd.js +1 -1
- package/components/Tab/index.umd.js +1 -1
- package/components/Table/index.umd.js +1 -1
- package/components/TableOfContents/index.umd.js +1 -1
- package/components/Textarea/index.umd.js +1 -1
- package/components/ThumbnailCard/index.umd.js +93 -142
- package/components/ThumbnailCard/index.umd.js.map +1 -1
- package/components/ThumbnailCard/sgds-thumbnail-card.d.ts +7 -2
- package/components/ThumbnailCard/sgds-thumbnail-card.js +38 -16
- package/components/ThumbnailCard/sgds-thumbnail-card.js.map +1 -1
- package/components/ThumbnailCard/thumbnail-card.js +1 -1
- package/components/Toast/index.umd.js +1 -1
- package/components/Tooltip/index.umd.js +1 -1
- package/components/index.umd.js +238 -121
- package/components/index.umd.js.map +1 -1
- package/index.umd.js +238 -121
- package/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/react/base/card-element.cjs.js +2 -10
- package/react/base/card-element.cjs.js.map +1 -1
- package/react/base/card-element.js +2 -10
- package/react/base/card-element.js.map +1 -1
- package/react/base/card.cjs.js +1 -1
- package/react/base/card.js +1 -1
- package/react/base/sgds-element.cjs2.js +1 -1
- package/react/base/sgds-element2.js +1 -1
- package/react/combo-box/index.cjs.js +3 -0
- package/react/combo-box/index.cjs.js.map +1 -1
- package/react/combo-box/index.js +3 -0
- package/react/combo-box/index.js.map +1 -1
- package/react/components/Card/sgds-card.cjs.js +46 -13
- package/react/components/Card/sgds-card.cjs.js.map +1 -1
- package/react/components/Card/sgds-card.js +47 -14
- package/react/components/Card/sgds-card.js.map +1 -1
- package/react/components/ComboBox/sgds-combo-box.cjs.js +8 -0
- package/react/components/ComboBox/sgds-combo-box.cjs.js.map +1 -1
- package/react/components/ComboBox/sgds-combo-box.js +8 -0
- package/react/components/ComboBox/sgds-combo-box.js.map +1 -1
- package/react/components/Drawer/drawer.cjs.js +1 -1
- package/react/components/Drawer/drawer.js +1 -1
- package/react/components/Drawer/sgds-drawer.cjs.js +15 -2
- package/react/components/Drawer/sgds-drawer.cjs.js.map +1 -1
- package/react/components/Drawer/sgds-drawer.js +15 -2
- package/react/components/Drawer/sgds-drawer.js.map +1 -1
- package/react/components/IconCard/sgds-icon-card.cjs.js +38 -11
- package/react/components/IconCard/sgds-icon-card.cjs.js.map +1 -1
- package/react/components/IconCard/sgds-icon-card.js +39 -12
- package/react/components/IconCard/sgds-icon-card.js.map +1 -1
- package/react/components/ImageCard/sgds-image-card.cjs.js +36 -10
- package/react/components/ImageCard/sgds-image-card.cjs.js.map +1 -1
- package/react/components/ImageCard/sgds-image-card.js +37 -11
- package/react/components/ImageCard/sgds-image-card.js.map +1 -1
- package/react/components/Mainnav/mainnav-context.cjs.js +4 -2
- package/react/components/Mainnav/mainnav-context.cjs.js.map +1 -1
- package/react/components/Mainnav/mainnav-context.js +3 -2
- package/react/components/Mainnav/mainnav-context.js.map +1 -1
- package/react/components/Mainnav/sgds-mainnav-dropdown.cjs.js +12 -32
- package/react/components/Mainnav/sgds-mainnav-dropdown.cjs.js.map +1 -1
- package/react/components/Mainnav/sgds-mainnav-dropdown.js +13 -33
- package/react/components/Mainnav/sgds-mainnav-dropdown.js.map +1 -1
- package/react/components/Mainnav/sgds-mainnav-item.cjs.js +4 -2
- package/react/components/Mainnav/sgds-mainnav-item.cjs.js.map +1 -1
- package/react/components/Mainnav/sgds-mainnav-item.js +4 -2
- package/react/components/Mainnav/sgds-mainnav-item.js.map +1 -1
- package/react/components/Mainnav/sgds-mainnav.cjs.js +25 -27
- package/react/components/Mainnav/sgds-mainnav.cjs.js.map +1 -1
- package/react/components/Mainnav/sgds-mainnav.js +26 -28
- package/react/components/Mainnav/sgds-mainnav.js.map +1 -1
- package/react/components/Select/sgds-select.cjs.js +11 -0
- package/react/components/Select/sgds-select.cjs.js.map +1 -1
- package/react/components/Select/sgds-select.js +11 -0
- package/react/components/Select/sgds-select.js.map +1 -1
- package/react/components/ThumbnailCard/sgds-thumbnail-card.cjs.js +37 -15
- package/react/components/ThumbnailCard/sgds-thumbnail-card.cjs.js.map +1 -1
- package/react/components/ThumbnailCard/sgds-thumbnail-card.js +38 -16
- package/react/components/ThumbnailCard/sgds-thumbnail-card.js.map +1 -1
- package/react/components/ThumbnailCard/thumbnail-card.cjs.js +1 -1
- package/react/components/ThumbnailCard/thumbnail-card.js +1 -1
- package/react/select/index.cjs.js +3 -0
- package/react/select/index.cjs.js.map +1 -1
- package/react/select/index.js +3 -0
- package/react/select/index.js.map +1 -1
|
@@ -18,6 +18,7 @@ import { SgdsCloseButton } from '../../internals/CloseButton/sgds-close-button.j
|
|
|
18
18
|
* @slot default - The drawer's main content
|
|
19
19
|
* @slot title - The title of the drawer
|
|
20
20
|
* @slot description - The description of the drawer
|
|
21
|
+
* @slot footer - The footer of the drawer
|
|
21
22
|
*
|
|
22
23
|
* @event sgds-show - Emitted when the drawer opens.
|
|
23
24
|
* @event sgds-after-show - Emitted after the drawer opens and all animations are complete.
|
|
@@ -39,6 +40,13 @@ class SgdsDrawer extends SgdsElement {
|
|
|
39
40
|
* use the `show()` and `hide()` methods and this attribute will reflect the drawer's open state.
|
|
40
41
|
*/
|
|
41
42
|
this.open = false;
|
|
43
|
+
/**
|
|
44
|
+
* Defines the size of the drawer panel.
|
|
45
|
+
* For drawers placed on the left or right (`start`/`end`), this controls the drawer's width.
|
|
46
|
+
* For drawers placed on the top or bottom, this controls the drawer's height.
|
|
47
|
+
* Accepts `small`, `medium`, or `large`. Defaults to `small`.
|
|
48
|
+
*/
|
|
49
|
+
this.size = "sm";
|
|
42
50
|
/** The direction from which the drawer will open. */
|
|
43
51
|
this.placement = "end";
|
|
44
52
|
/**
|
|
@@ -54,7 +62,6 @@ class SgdsDrawer extends SgdsElement {
|
|
|
54
62
|
};
|
|
55
63
|
}
|
|
56
64
|
firstUpdated() {
|
|
57
|
-
this.drawer.hidden = !this.open;
|
|
58
65
|
if (this.open) {
|
|
59
66
|
this.addOpenListeners();
|
|
60
67
|
if (!this.contained) {
|
|
@@ -192,11 +199,12 @@ class SgdsDrawer extends SgdsElement {
|
|
|
192
199
|
return waitForEvent(this, "sgds-after-hide");
|
|
193
200
|
}
|
|
194
201
|
render() {
|
|
202
|
+
const isHydrated = this.hasUpdated;
|
|
203
|
+
const shouldHide = !this.open && !isHydrated;
|
|
195
204
|
return html `
|
|
196
205
|
<div
|
|
197
206
|
class=${classMap({
|
|
198
207
|
drawer: true,
|
|
199
|
-
"drawer-open": this.open,
|
|
200
208
|
"drawer-top": this.placement === "top",
|
|
201
209
|
"drawer-end": this.placement === "end",
|
|
202
210
|
"drawer-bottom": this.placement === "bottom",
|
|
@@ -204,6 +212,7 @@ class SgdsDrawer extends SgdsElement {
|
|
|
204
212
|
"drawer-contained": this.contained,
|
|
205
213
|
"drawer-fixed": !this.contained
|
|
206
214
|
})}
|
|
215
|
+
?hidden=${shouldHide}
|
|
207
216
|
>
|
|
208
217
|
<div class="drawer-overlay" @click=${() => this.requestClose("overlay")} tabindex="-1"></div>
|
|
209
218
|
|
|
@@ -224,6 +233,7 @@ class SgdsDrawer extends SgdsElement {
|
|
|
224
233
|
></sgds-close-button>
|
|
225
234
|
</header>
|
|
226
235
|
<slot class="drawer-body"></slot>
|
|
236
|
+
<slot name="footer"></slot>
|
|
227
237
|
</div>
|
|
228
238
|
</div>
|
|
229
239
|
`;
|
|
@@ -246,6 +256,9 @@ __decorate([
|
|
|
246
256
|
__decorate([
|
|
247
257
|
property({ type: Boolean, reflect: true })
|
|
248
258
|
], SgdsDrawer.prototype, "open", void 0);
|
|
259
|
+
__decorate([
|
|
260
|
+
property({ type: String, reflect: true })
|
|
261
|
+
], SgdsDrawer.prototype, "size", void 0);
|
|
249
262
|
__decorate([
|
|
250
263
|
property({ type: String, reflect: true })
|
|
251
264
|
], SgdsDrawer.prototype, "placement", void 0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sgds-drawer.js","sources":["../../../../src/components/Drawer/sgds-drawer.ts"],"sourcesContent":["import { html } 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 \"../../internals/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 *\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 /** The direction from which the drawer will open. */\n @property({ type: String, reflect: true }) placement: \"top\" | \"end\" | \"bottom\" | \"start\" = \"end\";\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() {\n this.drawer.hidden = !this.open;\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 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 return html`\n <div\n class=${classMap({\n drawer: true,\n \"drawer-open\": this.open,\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 >\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-hidden=${this.open ? \"false\" : \"true\"}\n tabindex=\"0\"\n >\n <header class=\"drawer-header\">\n <slot name=\"title\"></slot>\n <slot name=\"description\"></slot>\n <sgds-close-button\n class=\"drawer-close\"\n aria-label=\"close drawer\"\n @click=\"${() => this.requestClose(\"close-button\")}\"\n ></sgds-close-button>\n </header>\n <slot class=\"drawer-body\"></slot>\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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,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;;;;"}
|
|
1
|
+
{"version":3,"file":"sgds-drawer.js","sources":["../../../../src/components/Drawer/sgds-drawer.ts"],"sourcesContent":["import { html } 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 \"../../internals/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 * 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() {\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-hidden=${this.open ? \"false\" : \"true\"}\n tabindex=\"0\"\n >\n <header class=\"drawer-header\">\n <slot name=\"title\"></slot>\n <slot name=\"description\"></slot>\n <sgds-close-button\n class=\"drawer-close\"\n aria-label=\"close drawer\"\n @click=\"${() => this.requestClose(\"close-button\")}\"\n ></sgds-close-button>\n </header>\n <slot class=\"drawer-body\"></slot>\n <slot name=\"footer\"></slot>\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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AAA;AACD,IAAA,YAAY,EAAE;AACZ,QAAA,EAAE,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;;;;"}
|
|
@@ -9,7 +9,6 @@ var staticHtml_js = require('lit/static-html.js');
|
|
|
9
9
|
var decorators_js = require('lit/decorators.js');
|
|
10
10
|
var classMap_js = require('lit/directives/class-map.js');
|
|
11
11
|
var cardElement = require('../../base/card-element.cjs.js');
|
|
12
|
-
var slot = require('../../utils/slot.cjs.js');
|
|
13
12
|
var iconCard = require('./icon-card.cjs.js');
|
|
14
13
|
|
|
15
14
|
/**
|
|
@@ -21,16 +20,30 @@ var iconCard = require('./icon-card.cjs.js');
|
|
|
21
20
|
* @slot title - The title of the card
|
|
22
21
|
* @slot description - The paragrapher text of the card
|
|
23
22
|
* @slot lower - Accepts any additional content to be displayed below the card description, such as badges, metadata, or supplementary information.
|
|
24
|
-
* @slot
|
|
23
|
+
* @slot footer - Footer area of the card. Accepts links, actions, or any custom content.
|
|
24
|
+
* @slot link - (@deprecated) Deprecated since 3.3.2 in favour of `footer` slot.
|
|
25
|
+
* Legacy slot for anchor elements. Use `footer` instead.
|
|
25
26
|
*/
|
|
26
27
|
class SgdsIconCard extends cardElement.CardElement {
|
|
27
28
|
constructor() {
|
|
28
29
|
super(...arguments);
|
|
29
30
|
/** Removes the card's internal padding when set to true. */
|
|
30
31
|
this.noPadding = false;
|
|
31
|
-
|
|
32
|
+
}
|
|
33
|
+
get linkSlotItems() {
|
|
34
|
+
if (!this.linkNode || this.linkNode.length === 0)
|
|
35
|
+
return null;
|
|
36
|
+
const element = this.linkNode[0];
|
|
37
|
+
return (element.querySelector("a") || element);
|
|
38
|
+
}
|
|
39
|
+
get footerSlotItems() {
|
|
40
|
+
if (!this.footerNode || this.footerNode.length === 0)
|
|
41
|
+
return null;
|
|
42
|
+
const element = this.footerNode[0];
|
|
43
|
+
return (element.querySelector("a") || element);
|
|
32
44
|
}
|
|
33
45
|
firstUpdated() {
|
|
46
|
+
var _a, _b;
|
|
34
47
|
if (this._iconNode.length === 0) {
|
|
35
48
|
if ((this.orientation === "vertical" && this._upperNode.length === 0) || this.orientation === "horizontal") {
|
|
36
49
|
const media = this.shadowRoot.querySelector(".card-media");
|
|
@@ -40,14 +53,24 @@ class SgdsIconCard extends cardElement.CardElement {
|
|
|
40
53
|
body.style.padding = "0px";
|
|
41
54
|
}
|
|
42
55
|
}
|
|
56
|
+
if (this.stretchedLink) {
|
|
57
|
+
const footerHref = (_a = this.footerSlotItems) === null || _a === void 0 ? void 0 : _a.href;
|
|
58
|
+
const linkHref = (_b = this.linkSlotItems) === null || _b === void 0 ? void 0 : _b.href;
|
|
59
|
+
if (footerHref) {
|
|
60
|
+
this.card.setAttribute("href", footerHref);
|
|
61
|
+
}
|
|
62
|
+
else if (linkHref) {
|
|
63
|
+
this.card.setAttribute("href", linkHref);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
43
66
|
}
|
|
44
67
|
render() {
|
|
45
68
|
const tag = this.stretchedLink ? staticHtml_js.literal `a` : staticHtml_js.literal `div`;
|
|
46
69
|
const cardTabIndex = !this.stretchedLink || this.disabled ? -1 : 0;
|
|
47
|
-
const hasDescriptionSlot = this.hasSlotController.test("description");
|
|
48
70
|
return staticHtml_js.html `
|
|
49
71
|
<${tag}
|
|
50
|
-
class="
|
|
72
|
+
class="${classMap_js.classMap({
|
|
73
|
+
card: true,
|
|
51
74
|
disabled: this.disabled
|
|
52
75
|
})}"
|
|
53
76
|
tabindex=${cardTabIndex}
|
|
@@ -66,13 +89,11 @@ class SgdsIconCard extends cardElement.CardElement {
|
|
|
66
89
|
</div>
|
|
67
90
|
<slot></slot>
|
|
68
91
|
</div>
|
|
69
|
-
|
|
70
|
-
? staticHtml_js.html `<p class="card-text">
|
|
71
|
-
<slot name="description"></slot>
|
|
72
|
-
</p>`
|
|
73
|
-
: lit.nothing}
|
|
92
|
+
<slot name="description"></slot>
|
|
74
93
|
<slot name="lower"></slot>
|
|
75
|
-
<slot name="
|
|
94
|
+
<slot name="footer">
|
|
95
|
+
<slot name="link" @slotchange=${this.handleLinkSlotChange}></slot>
|
|
96
|
+
</slot>
|
|
76
97
|
</div>
|
|
77
98
|
</${tag}>
|
|
78
99
|
`;
|
|
@@ -85,6 +106,12 @@ tslib.__decorate([
|
|
|
85
106
|
tslib.__decorate([
|
|
86
107
|
decorators_js.queryAssignedNodes({ slot: "upper", flatten: true })
|
|
87
108
|
], SgdsIconCard.prototype, "_upperNode", void 0);
|
|
109
|
+
tslib.__decorate([
|
|
110
|
+
decorators_js.queryAssignedElements({ slot: "footer" })
|
|
111
|
+
], SgdsIconCard.prototype, "footerNode", void 0);
|
|
112
|
+
tslib.__decorate([
|
|
113
|
+
decorators_js.queryAssignedElements({ slot: "link" })
|
|
114
|
+
], SgdsIconCard.prototype, "linkNode", void 0);
|
|
88
115
|
tslib.__decorate([
|
|
89
116
|
decorators_js.property({ type: Boolean, reflect: true })
|
|
90
117
|
], SgdsIconCard.prototype, "noPadding", void 0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sgds-icon-card.cjs.js","sources":["../../../../src/components/IconCard/sgds-icon-card.ts"],"sourcesContent":["import { nothing } from \"lit\";\nimport { html, literal } from \"lit/static-html.js\";\nimport { property, queryAssignedNodes } from \"lit/decorators.js\";\nimport { classMap } from \"lit/directives/class-map.js\";\nimport { CardElement } from \"../../base/card-element\";\nimport
|
|
1
|
+
{"version":3,"file":"sgds-icon-card.cjs.js","sources":["../../../../src/components/IconCard/sgds-icon-card.ts"],"sourcesContent":["import { nothing } from \"lit\";\nimport { html, literal } from \"lit/static-html.js\";\nimport { property, queryAssignedElements, queryAssignedNodes } from \"lit/decorators.js\";\nimport { classMap } from \"lit/directives/class-map.js\";\nimport { CardElement } from \"../../base/card-element\";\nimport SgdsLink from \"../Link/sgds-link\";\nimport IconCardStyle from \"./icon-card.css\";\n\n/**\n * @summary Icon cards can be used for headers and footers, a wide variety of content, contain contextual background colors and images.\n * @slot default - The content area of the card, placed directly under the title. Accepts any HTML or custom elements.\n * @slot icon - Accepts an icon element to visually represent the card. Only a single element is allowed to be passed in.\n * @slot upper - Accepts any content to be displayed at the top of the subtitle. Commonly used for badges, status indicators, or decorative elements.\n * @slot subtitle - The subtitle of the card\n * @slot title - The title of the card\n * @slot description - The paragrapher text of the card\n * @slot lower - Accepts any additional content to be displayed below the card description, such as badges, metadata, or supplementary information.\n * @slot footer - Footer area of the card. Accepts links, actions, or any custom content.\n * @slot link - (@deprecated) Deprecated since 3.3.2 in favour of `footer` slot.\n * Legacy slot for anchor elements. Use `footer` instead.\n */\nexport class SgdsIconCard extends CardElement {\n static styles = [...CardElement.styles, IconCardStyle];\n\n /** @internal */\n @queryAssignedNodes({ slot: \"icon\", flatten: true })\n _iconNode!: Array<Node>;\n /** @internal */\n @queryAssignedNodes({ slot: \"upper\", flatten: true })\n _upperNode!: Array<Node>;\n @queryAssignedElements({ slot: \"footer\" })\n private footerNode!: HTMLElement[];\n @queryAssignedElements({ slot: \"link\" })\n private linkNode!: HTMLAnchorElement[] | SgdsLink[];\n\n /** Removes the card's internal padding when set to true. */\n @property({ type: Boolean, reflect: true }) noPadding = false;\n\n private get linkSlotItems(): HTMLAnchorElement | null {\n if (!this.linkNode || this.linkNode.length === 0) return null;\n const element = this.linkNode[0] as HTMLElement;\n return (element.querySelector(\"a\") || element) as HTMLAnchorElement;\n }\n\n private get footerSlotItems(): HTMLAnchorElement | null {\n if (!this.footerNode || this.footerNode.length === 0) return null;\n const element = this.footerNode[0] as HTMLElement;\n return (element.querySelector(\"a\") || element) as HTMLAnchorElement;\n }\n\n protected firstUpdated() {\n if (this._iconNode.length === 0) {\n if ((this.orientation === \"vertical\" && this._upperNode.length === 0) || this.orientation === \"horizontal\") {\n const media = this.shadowRoot.querySelector(\".card-media\") as HTMLDivElement;\n media.style.display = \"none\";\n\n const body = this.shadowRoot.querySelector(\".card-body\") as HTMLDivElement;\n if (this.noPadding) body.style.padding = \"0px\";\n }\n }\n\n if (this.stretchedLink) {\n const footerHref = this.footerSlotItems?.href;\n const linkHref = this.linkSlotItems?.href;\n\n if (footerHref) {\n this.card.setAttribute(\"href\", footerHref);\n } else if (linkHref) {\n this.card.setAttribute(\"href\", linkHref);\n }\n }\n }\n\n render() {\n const tag = this.stretchedLink ? literal`a` : literal`div`;\n const cardTabIndex = !this.stretchedLink || this.disabled ? -1 : 0;\n\n return html`\n <${tag} \n class=\"${classMap({\n card: true,\n disabled: this.disabled\n })}\"\n tabindex=${cardTabIndex}\n >\n ${this.tinted && !this.noPadding ? html`<div class=\"card-tinted-bg\"></div>` : nothing}\n <div class=\"card-media\">\n <slot name=\"icon\"></slot>\n ${this.orientation === \"vertical\" ? html`<slot name=\"upper\"></slot>` : nothing}\n </div>\n <div class=\"card-body\">\n ${this.orientation === \"horizontal\" ? html`<slot name=\"upper\"></slot>` : nothing}\n <div class=\"card-header-container\">\n <div class=\"card-header\">\n <slot name=\"subtitle\"></slot>\n <h3 class=\"card-title\"><slot name=\"title\" @slotchange=${this.handleTitleSlotChange}></slot></h3>\n </div>\n <slot></slot>\n </div>\n <slot name=\"description\"></slot>\n <slot name=\"lower\"></slot>\n <slot name=\"footer\">\n <slot name=\"link\" @slotchange=${this.handleLinkSlotChange}></slot>\n </slot>\n </div>\n </${tag}>\n `;\n }\n}\n\nexport default SgdsIconCard;\n"],"names":["CardElement","literal","html","classMap","nothing","IconCardStyle","__decorate","queryAssignedNodes","queryAssignedElements","property"],"mappings":";;;;;;;;;;;;;AAQA;;;;;;;;;;;;AAYG;AACG,MAAO,YAAa,SAAQA,uBAAW,CAAA;AAA7C,IAAA,WAAA,GAAA;;;QAe8C,IAAS,CAAA,SAAA,GAAG,KAAK,CAAC;KAwE/D;AAtEC,IAAA,IAAY,aAAa,GAAA;QACvB,IAAI,CAAC,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC;AAAE,YAAA,OAAO,IAAI,CAAC;QAC9D,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAgB,CAAC;QAChD,QAAQ,OAAO,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,OAAO,EAAuB;KACrE;AAED,IAAA,IAAY,eAAe,GAAA;QACzB,IAAI,CAAC,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,UAAU,CAAC,MAAM,KAAK,CAAC;AAAE,YAAA,OAAO,IAAI,CAAC;QAClE,MAAM,OAAO,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC,CAAgB,CAAC;QAClD,QAAQ,OAAO,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AAE,CAAC;AAC5B,CAAA,EAAA,YAAA,CAAA,SAAA,EAAA,YAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAEjBD,gBAAA,CAAA;AADP,IAAAE,mCAAqB,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;AACP,CAAA,EAAA,YAAA,CAAA,SAAA,EAAA,YAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAE3BF,gBAAA,CAAA;AADP,IAAAE,mCAAqB,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;AACY,CAAA,EAAA,YAAA,CAAA,SAAA,EAAA,UAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAGRF,gBAAA,CAAA;IAA3CG,sBAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAAmB,CAAA,EAAA,YAAA,CAAA,SAAA,EAAA,WAAA,EAAA,KAAA,CAAA,CAAA;;;;;"}
|
|
@@ -2,10 +2,9 @@
|
|
|
2
2
|
import { __decorate } from 'tslib';
|
|
3
3
|
import { nothing } from 'lit';
|
|
4
4
|
import { literal, html } from 'lit/static-html.js';
|
|
5
|
-
import { queryAssignedNodes, property } from 'lit/decorators.js';
|
|
5
|
+
import { queryAssignedNodes, queryAssignedElements, property } from 'lit/decorators.js';
|
|
6
6
|
import { classMap } from 'lit/directives/class-map.js';
|
|
7
7
|
import { CardElement } from '../../base/card-element.js';
|
|
8
|
-
import { HasSlotController } from '../../utils/slot.js';
|
|
9
8
|
import css_248z from './icon-card.js';
|
|
10
9
|
|
|
11
10
|
/**
|
|
@@ -17,16 +16,30 @@ import css_248z from './icon-card.js';
|
|
|
17
16
|
* @slot title - The title of the card
|
|
18
17
|
* @slot description - The paragrapher text of the card
|
|
19
18
|
* @slot lower - Accepts any additional content to be displayed below the card description, such as badges, metadata, or supplementary information.
|
|
20
|
-
* @slot
|
|
19
|
+
* @slot footer - Footer area of the card. Accepts links, actions, or any custom content.
|
|
20
|
+
* @slot link - (@deprecated) Deprecated since 3.3.2 in favour of `footer` slot.
|
|
21
|
+
* Legacy slot for anchor elements. Use `footer` instead.
|
|
21
22
|
*/
|
|
22
23
|
class SgdsIconCard extends CardElement {
|
|
23
24
|
constructor() {
|
|
24
25
|
super(...arguments);
|
|
25
26
|
/** Removes the card's internal padding when set to true. */
|
|
26
27
|
this.noPadding = false;
|
|
27
|
-
|
|
28
|
+
}
|
|
29
|
+
get linkSlotItems() {
|
|
30
|
+
if (!this.linkNode || this.linkNode.length === 0)
|
|
31
|
+
return null;
|
|
32
|
+
const element = this.linkNode[0];
|
|
33
|
+
return (element.querySelector("a") || element);
|
|
34
|
+
}
|
|
35
|
+
get footerSlotItems() {
|
|
36
|
+
if (!this.footerNode || this.footerNode.length === 0)
|
|
37
|
+
return null;
|
|
38
|
+
const element = this.footerNode[0];
|
|
39
|
+
return (element.querySelector("a") || element);
|
|
28
40
|
}
|
|
29
41
|
firstUpdated() {
|
|
42
|
+
var _a, _b;
|
|
30
43
|
if (this._iconNode.length === 0) {
|
|
31
44
|
if ((this.orientation === "vertical" && this._upperNode.length === 0) || this.orientation === "horizontal") {
|
|
32
45
|
const media = this.shadowRoot.querySelector(".card-media");
|
|
@@ -36,14 +49,24 @@ class SgdsIconCard extends CardElement {
|
|
|
36
49
|
body.style.padding = "0px";
|
|
37
50
|
}
|
|
38
51
|
}
|
|
52
|
+
if (this.stretchedLink) {
|
|
53
|
+
const footerHref = (_a = this.footerSlotItems) === null || _a === void 0 ? void 0 : _a.href;
|
|
54
|
+
const linkHref = (_b = this.linkSlotItems) === null || _b === void 0 ? void 0 : _b.href;
|
|
55
|
+
if (footerHref) {
|
|
56
|
+
this.card.setAttribute("href", footerHref);
|
|
57
|
+
}
|
|
58
|
+
else if (linkHref) {
|
|
59
|
+
this.card.setAttribute("href", linkHref);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
39
62
|
}
|
|
40
63
|
render() {
|
|
41
64
|
const tag = this.stretchedLink ? literal `a` : literal `div`;
|
|
42
65
|
const cardTabIndex = !this.stretchedLink || this.disabled ? -1 : 0;
|
|
43
|
-
const hasDescriptionSlot = this.hasSlotController.test("description");
|
|
44
66
|
return html `
|
|
45
67
|
<${tag}
|
|
46
|
-
class="
|
|
68
|
+
class="${classMap({
|
|
69
|
+
card: true,
|
|
47
70
|
disabled: this.disabled
|
|
48
71
|
})}"
|
|
49
72
|
tabindex=${cardTabIndex}
|
|
@@ -62,13 +85,11 @@ class SgdsIconCard extends CardElement {
|
|
|
62
85
|
</div>
|
|
63
86
|
<slot></slot>
|
|
64
87
|
</div>
|
|
65
|
-
|
|
66
|
-
? html `<p class="card-text">
|
|
67
|
-
<slot name="description"></slot>
|
|
68
|
-
</p>`
|
|
69
|
-
: nothing}
|
|
88
|
+
<slot name="description"></slot>
|
|
70
89
|
<slot name="lower"></slot>
|
|
71
|
-
<slot name="
|
|
90
|
+
<slot name="footer">
|
|
91
|
+
<slot name="link" @slotchange=${this.handleLinkSlotChange}></slot>
|
|
92
|
+
</slot>
|
|
72
93
|
</div>
|
|
73
94
|
</${tag}>
|
|
74
95
|
`;
|
|
@@ -81,6 +102,12 @@ __decorate([
|
|
|
81
102
|
__decorate([
|
|
82
103
|
queryAssignedNodes({ slot: "upper", flatten: true })
|
|
83
104
|
], SgdsIconCard.prototype, "_upperNode", void 0);
|
|
105
|
+
__decorate([
|
|
106
|
+
queryAssignedElements({ slot: "footer" })
|
|
107
|
+
], SgdsIconCard.prototype, "footerNode", void 0);
|
|
108
|
+
__decorate([
|
|
109
|
+
queryAssignedElements({ slot: "link" })
|
|
110
|
+
], SgdsIconCard.prototype, "linkNode", void 0);
|
|
84
111
|
__decorate([
|
|
85
112
|
property({ type: Boolean, reflect: true })
|
|
86
113
|
], SgdsIconCard.prototype, "noPadding", void 0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sgds-icon-card.js","sources":["../../../../src/components/IconCard/sgds-icon-card.ts"],"sourcesContent":["import { nothing } from \"lit\";\nimport { html, literal } from \"lit/static-html.js\";\nimport { property, queryAssignedNodes } from \"lit/decorators.js\";\nimport { classMap } from \"lit/directives/class-map.js\";\nimport { CardElement } from \"../../base/card-element\";\nimport
|
|
1
|
+
{"version":3,"file":"sgds-icon-card.js","sources":["../../../../src/components/IconCard/sgds-icon-card.ts"],"sourcesContent":["import { nothing } from \"lit\";\nimport { html, literal } from \"lit/static-html.js\";\nimport { property, queryAssignedElements, queryAssignedNodes } from \"lit/decorators.js\";\nimport { classMap } from \"lit/directives/class-map.js\";\nimport { CardElement } from \"../../base/card-element\";\nimport SgdsLink from \"../Link/sgds-link\";\nimport IconCardStyle from \"./icon-card.css\";\n\n/**\n * @summary Icon cards can be used for headers and footers, a wide variety of content, contain contextual background colors and images.\n * @slot default - The content area of the card, placed directly under the title. Accepts any HTML or custom elements.\n * @slot icon - Accepts an icon element to visually represent the card. Only a single element is allowed to be passed in.\n * @slot upper - Accepts any content to be displayed at the top of the subtitle. Commonly used for badges, status indicators, or decorative elements.\n * @slot subtitle - The subtitle of the card\n * @slot title - The title of the card\n * @slot description - The paragrapher text of the card\n * @slot lower - Accepts any additional content to be displayed below the card description, such as badges, metadata, or supplementary information.\n * @slot footer - Footer area of the card. Accepts links, actions, or any custom content.\n * @slot link - (@deprecated) Deprecated since 3.3.2 in favour of `footer` slot.\n * Legacy slot for anchor elements. Use `footer` instead.\n */\nexport class SgdsIconCard extends CardElement {\n static styles = [...CardElement.styles, IconCardStyle];\n\n /** @internal */\n @queryAssignedNodes({ slot: \"icon\", flatten: true })\n _iconNode!: Array<Node>;\n /** @internal */\n @queryAssignedNodes({ slot: \"upper\", flatten: true })\n _upperNode!: Array<Node>;\n @queryAssignedElements({ slot: \"footer\" })\n private footerNode!: HTMLElement[];\n @queryAssignedElements({ slot: \"link\" })\n private linkNode!: HTMLAnchorElement[] | SgdsLink[];\n\n /** Removes the card's internal padding when set to true. */\n @property({ type: Boolean, reflect: true }) noPadding = false;\n\n private get linkSlotItems(): HTMLAnchorElement | null {\n if (!this.linkNode || this.linkNode.length === 0) return null;\n const element = this.linkNode[0] as HTMLElement;\n return (element.querySelector(\"a\") || element) as HTMLAnchorElement;\n }\n\n private get footerSlotItems(): HTMLAnchorElement | null {\n if (!this.footerNode || this.footerNode.length === 0) return null;\n const element = this.footerNode[0] as HTMLElement;\n return (element.querySelector(\"a\") || element) as HTMLAnchorElement;\n }\n\n protected firstUpdated() {\n if (this._iconNode.length === 0) {\n if ((this.orientation === \"vertical\" && this._upperNode.length === 0) || this.orientation === \"horizontal\") {\n const media = this.shadowRoot.querySelector(\".card-media\") as HTMLDivElement;\n media.style.display = \"none\";\n\n const body = this.shadowRoot.querySelector(\".card-body\") as HTMLDivElement;\n if (this.noPadding) body.style.padding = \"0px\";\n }\n }\n\n if (this.stretchedLink) {\n const footerHref = this.footerSlotItems?.href;\n const linkHref = this.linkSlotItems?.href;\n\n if (footerHref) {\n this.card.setAttribute(\"href\", footerHref);\n } else if (linkHref) {\n this.card.setAttribute(\"href\", linkHref);\n }\n }\n }\n\n render() {\n const tag = this.stretchedLink ? literal`a` : literal`div`;\n const cardTabIndex = !this.stretchedLink || this.disabled ? -1 : 0;\n\n return html`\n <${tag} \n class=\"${classMap({\n card: true,\n disabled: this.disabled\n })}\"\n tabindex=${cardTabIndex}\n >\n ${this.tinted && !this.noPadding ? html`<div class=\"card-tinted-bg\"></div>` : nothing}\n <div class=\"card-media\">\n <slot name=\"icon\"></slot>\n ${this.orientation === \"vertical\" ? html`<slot name=\"upper\"></slot>` : nothing}\n </div>\n <div class=\"card-body\">\n ${this.orientation === \"horizontal\" ? html`<slot name=\"upper\"></slot>` : nothing}\n <div class=\"card-header-container\">\n <div class=\"card-header\">\n <slot name=\"subtitle\"></slot>\n <h3 class=\"card-title\"><slot name=\"title\" @slotchange=${this.handleTitleSlotChange}></slot></h3>\n </div>\n <slot></slot>\n </div>\n <slot name=\"description\"></slot>\n <slot name=\"lower\"></slot>\n <slot name=\"footer\">\n <slot name=\"link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O,EAAE,IAAI,EAAE,CAAC;AAAmB,CAAA,EAAA,YAAA,CAAA,SAAA,EAAA,WAAA,EAAA,KAAA,CAAA,CAAA;;;;"}
|
|
@@ -9,7 +9,6 @@ var staticHtml_js = require('lit/static-html.js');
|
|
|
9
9
|
var decorators_js = require('lit/decorators.js');
|
|
10
10
|
var classMap_js = require('lit/directives/class-map.js');
|
|
11
11
|
var cardElement = require('../../base/card-element.cjs.js');
|
|
12
|
-
var slot = require('../../utils/slot.cjs.js');
|
|
13
12
|
var imageCard = require('./image-card.cjs.js');
|
|
14
13
|
|
|
15
14
|
/**
|
|
@@ -23,7 +22,9 @@ var imageCard = require('./image-card.cjs.js');
|
|
|
23
22
|
* @slot title - The title of the card
|
|
24
23
|
* @slot description - The paragrapher text of the card
|
|
25
24
|
* @slot lower - Accepts any additional content to be displayed below the card description, such as badges, metadata, or supplementary information.
|
|
26
|
-
* @slot
|
|
25
|
+
* @slot footer - Footer area of the card. Accepts links, actions, or any custom content.
|
|
26
|
+
* @slot link - (@deprecated) Deprecated since 3.3.2 in favour of `footer` slot.
|
|
27
|
+
* Legacy slot for anchor elements. Use `footer` instead.
|
|
27
28
|
*/
|
|
28
29
|
class SgdsImageCard extends cardElement.CardElement {
|
|
29
30
|
constructor() {
|
|
@@ -34,9 +35,21 @@ class SgdsImageCard extends cardElement.CardElement {
|
|
|
34
35
|
this.imagePosition = "before";
|
|
35
36
|
/** Controls how the image is sized and aligned within the card. Available options: `default`, `padding around`, `aspect ratio` */
|
|
36
37
|
this.imageAdjustment = "default";
|
|
37
|
-
|
|
38
|
+
}
|
|
39
|
+
get linkSlotItems() {
|
|
40
|
+
if (!this.linkNode || this.linkNode.length === 0)
|
|
41
|
+
return null;
|
|
42
|
+
const element = this.linkNode[0];
|
|
43
|
+
return (element.querySelector("a") || element);
|
|
44
|
+
}
|
|
45
|
+
get footerSlotItems() {
|
|
46
|
+
if (!this.footerNode || this.footerNode.length === 0)
|
|
47
|
+
return null;
|
|
48
|
+
const element = this.footerNode[0];
|
|
49
|
+
return (element.querySelector("a") || element);
|
|
38
50
|
}
|
|
39
51
|
firstUpdated() {
|
|
52
|
+
var _a, _b;
|
|
40
53
|
if (this._imageNode.length === 0) {
|
|
41
54
|
const image = this.shadowRoot.querySelector(".card-image");
|
|
42
55
|
const body = this.shadowRoot.querySelector(".card-body");
|
|
@@ -44,6 +57,16 @@ class SgdsImageCard extends cardElement.CardElement {
|
|
|
44
57
|
if (this.noPadding)
|
|
45
58
|
body.style.padding = "0px";
|
|
46
59
|
}
|
|
60
|
+
if (this.stretchedLink) {
|
|
61
|
+
const footerHref = (_a = this.footerSlotItems) === null || _a === void 0 ? void 0 : _a.href;
|
|
62
|
+
const linkHref = (_b = this.linkSlotItems) === null || _b === void 0 ? void 0 : _b.href;
|
|
63
|
+
if (footerHref) {
|
|
64
|
+
this.card.setAttribute("href", footerHref);
|
|
65
|
+
}
|
|
66
|
+
else if (linkHref) {
|
|
67
|
+
this.card.setAttribute("href", linkHref);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
47
70
|
}
|
|
48
71
|
handleImgSlotChange(e) {
|
|
49
72
|
const childNodes = e.target.assignedNodes({ flatten: true });
|
|
@@ -54,7 +77,6 @@ class SgdsImageCard extends cardElement.CardElement {
|
|
|
54
77
|
render() {
|
|
55
78
|
const tag = this.stretchedLink ? staticHtml_js.literal `a` : staticHtml_js.literal `div`;
|
|
56
79
|
const cardTabIndex = !this.stretchedLink || this.disabled ? -1 : 0;
|
|
57
|
-
const hasDescriptionSlot = this.hasSlotController.test("description");
|
|
58
80
|
return staticHtml_js.html `
|
|
59
81
|
<${tag}
|
|
60
82
|
class="card ${classMap_js.classMap({
|
|
@@ -77,13 +99,11 @@ class SgdsImageCard extends cardElement.CardElement {
|
|
|
77
99
|
</div>
|
|
78
100
|
<slot></slot>
|
|
79
101
|
</div>
|
|
80
|
-
|
|
81
|
-
? staticHtml_js.html `<p class="card-text">
|
|
82
|
-
<slot name="description"></slot>
|
|
83
|
-
</p>`
|
|
84
|
-
: lit.nothing}
|
|
102
|
+
<slot name="description"></slot>
|
|
85
103
|
<slot name="lower"></slot>
|
|
86
|
-
<slot name="
|
|
104
|
+
<slot name="footer">
|
|
105
|
+
<slot name="link" @slotchange=${this.handleLinkSlotChange}></slot>
|
|
106
|
+
</slot>
|
|
87
107
|
</div>
|
|
88
108
|
</${tag}>
|
|
89
109
|
`;
|
|
@@ -93,6 +113,12 @@ SgdsImageCard.styles = [...cardElement.CardElement.styles, imageCard["default"]]
|
|
|
93
113
|
tslib.__decorate([
|
|
94
114
|
decorators_js.queryAssignedNodes({ slot: "image", flatten: true })
|
|
95
115
|
], SgdsImageCard.prototype, "_imageNode", void 0);
|
|
116
|
+
tslib.__decorate([
|
|
117
|
+
decorators_js.queryAssignedElements({ slot: "footer" })
|
|
118
|
+
], SgdsImageCard.prototype, "footerNode", void 0);
|
|
119
|
+
tslib.__decorate([
|
|
120
|
+
decorators_js.queryAssignedElements({ slot: "link" })
|
|
121
|
+
], SgdsImageCard.prototype, "linkNode", void 0);
|
|
96
122
|
tslib.__decorate([
|
|
97
123
|
decorators_js.property({ type: Boolean, reflect: true })
|
|
98
124
|
], SgdsImageCard.prototype, "noPadding", void 0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sgds-image-card.cjs.js","sources":["../../../../src/components/ImageCard/sgds-image-card.ts"],"sourcesContent":["import { nothing } from \"lit\";\nimport { html, literal } from \"lit/static-html.js\";\nimport { property, queryAssignedNodes } from \"lit/decorators.js\";\nimport { classMap } from \"lit/directives/class-map.js\";\nimport { CardElement } from \"../../base/card-element\";\nimport {
|
|
1
|
+
{"version":3,"file":"sgds-image-card.cjs.js","sources":["../../../../src/components/ImageCard/sgds-image-card.ts"],"sourcesContent":["import { nothing } from \"lit\";\nimport { html, literal } from \"lit/static-html.js\";\nimport { property, queryAssignedElements, queryAssignedNodes } from \"lit/decorators.js\";\nimport { classMap } from \"lit/directives/class-map.js\";\nimport { CardElement } from \"../../base/card-element\";\nimport { CardImageAdjustment, CardImagePosition } from \"../Card/types\";\nimport SgdsLink from \"../Link/sgds-link\";\nimport imageCardStyle from \"./image-card.css\";\n\n/**\n * @summary Image cards can be used for headers and footers, a wide variety of content, contain contextual background colors and images.\n * @slot default - The content area of the card, placed directly under the title. Accepts any HTML or custom elements.\n * @slot image - Accepts an image or svg element of the card. Only a single element is allowed to be passed in.\n * @slot image-badge - Accepts an element for a badge, positioned at the top-left corner of the image.\n * @slot image-action - Accepts an element for an overflow or contextual menu, positioned at the top-right corner of the image. Typically used for action menu.\n * @slot upper - Accepts any content to be displayed at the top of the subtitle. Commonly used for badges, status indicators, or decorative elements.\n * @slot subtitle - The subtitle of the card\n * @slot title - The title of the card\n * @slot description - The paragrapher text of the card\n * @slot lower - Accepts any additional content to be displayed below the card description, such as badges, metadata, or supplementary information.\n * @slot footer - Footer area of the card. Accepts links, actions, or any custom content.\n * @slot link - (@deprecated) Deprecated since 3.3.2 in favour of `footer` slot.\n * Legacy slot for anchor elements. Use `footer` instead.\n */\nexport class SgdsImageCard extends CardElement {\n static styles = [...CardElement.styles, imageCardStyle];\n\n /** @internal */\n @queryAssignedNodes({ slot: \"image\", flatten: true })\n _imageNode!: Array<Node>;\n @queryAssignedElements({ slot: \"footer\" })\n private footerNode!: HTMLElement[];\n @queryAssignedElements({ slot: \"link\" })\n private linkNode!: HTMLAnchorElement[] | SgdsLink[];\n\n /** Removes the card's internal padding when set to true. */\n @property({ type: Boolean, reflect: true }) noPadding = false;\n\n /** Sets the image position of the card. Available options: `before`, `after` */\n @property({ type: String, reflect: true }) imagePosition: CardImagePosition = \"before\";\n\n /** Controls how the image is sized and aligned within the card. Available options: `default`, `padding around`, `aspect ratio` */\n @property({ type: String, reflect: true }) imageAdjustment: CardImageAdjustment = \"default\";\n\n private get linkSlotItems(): HTMLAnchorElement | null {\n if (!this.linkNode || this.linkNode.length === 0) return null;\n const element = this.linkNode[0] as HTMLElement;\n return (element.querySelector(\"a\") || element) as HTMLAnchorElement;\n }\n\n private get footerSlotItems(): HTMLAnchorElement | null {\n if (!this.footerNode || this.footerNode.length === 0) return null;\n const element = this.footerNode[0] as HTMLElement;\n return (element.querySelector(\"a\") || element) as HTMLAnchorElement;\n }\n\n protected firstUpdated() {\n if (this._imageNode.length === 0) {\n const image = this.shadowRoot.querySelector(\".card-image\") as HTMLDivElement;\n const body = this.shadowRoot.querySelector(\".card-body\") as HTMLDivElement;\n image.style.display = \"none\";\n if (this.noPadding) body.style.padding = \"0px\";\n }\n\n if (this.stretchedLink) {\n const footerHref = this.footerSlotItems?.href;\n const linkHref = this.linkSlotItems?.href;\n\n if (footerHref) {\n this.card.setAttribute(\"href\", footerHref);\n } else if (linkHref) {\n this.card.setAttribute(\"href\", linkHref);\n }\n }\n }\n\n handleImgSlotChange(e: Event) {\n const childNodes = (e.target as HTMLSlotElement).assignedNodes({ flatten: true }) as Array<HTMLOrSVGImageElement>;\n\n if (childNodes.length > 1) {\n return console.error(\"Multiple elements passed into SgdsCard's image slot\");\n }\n }\n\n render() {\n const tag = this.stretchedLink ? literal`a` : literal`div`;\n const cardTabIndex = !this.stretchedLink || this.disabled ? -1 : 0;\n\n return html`\n <${tag} \n class=\"card ${classMap({\n disabled: this.disabled\n })}\"\n tabindex=${cardTabIndex}\n >\n ${this.tinted && !this.noPadding ? html`<div class=\"card-tinted-bg\"></div>` : nothing}\n <div class=\"card-image\">\n\t\t\t\t\t<slot name=\"image\" @slotchange=${this.handleImgSlotChange}></slot>\n\t\t\t\t\t<slot name=\"image-badge\"></slot>\n\t\t\t\t\t<slot name=\"image-action\"></slot>\n </div>\n <div class=\"card-body\">\n\t\t\t\t\t<slot name=\"upper\"></slot>\n <div class=\"card-header-container\">\n <div class=\"card-header\">\n <slot name=\"subtitle\"></slot>\n <h3 class=\"card-title\"><slot name=\"title\" @slotchange=${this.handleTitleSlotChange}></slot></h3>\n </div>\n <slot></slot>\n </div>\n <slot name=\"description\"></slot>\n <slot name=\"lower\"></slot>\n <slot name=\"footer\">\n <slot name=\"link\" @slotchange=${this.handleLinkSlotChange}></slot>\n </slot>\n </div>\n </${tag}>\n `;\n }\n}\n\nexport default SgdsImageCard;\n"],"names":["CardElement","literal","html","classMap","nothing","imageCardStyle","__decorate","queryAssignedNodes","queryAssignedElements","property"],"mappings":";;;;;;;;;;;;;AASA;;;;;;;;;;;;;;AAcG;AACG,MAAO,aAAc,SAAQA,uBAAW,CAAA;AAA9C,IAAA,WAAA,GAAA;;;QAY8C,IAAS,CAAA,SAAA,GAAG,KAAK,CAAC;;QAGnB,IAAa,CAAA,aAAA,GAAsB,QAAQ,CAAC;;QAG5C,IAAe,CAAA,eAAA,GAAwB,SAAS,CAAC;KA6E7F;AA3EC,IAAA,IAAY,aAAa,GAAA;QACvB,IAAI,CAAC,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC;AAAE,YAAA,OAAO,IAAI,CAAC;QAC9D,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAgB,CAAC;QAChD,QAAQ,OAAO,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,OAAO,EAAuB;KACrE;AAED,IAAA,IAAY,eAAe,GAAA;QACzB,IAAI,CAAC,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,UAAU,CAAC,MAAM,KAAK,CAAC;AAAE,YAAA,OAAO,IAAI,CAAC;QAClE,MAAM,OAAO,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC,CAAgB,CAAC;QAClD,QAAQ,OAAO,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,OAAO,EAAuB;KACrE;IAES,YAAY,GAAA;;QACpB,IAAI,IAAI,CAAC,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE;YAChC,MAAM,KAAK,GAAG,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,aAAa,CAAmB,CAAC;YAC7E,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC,aAAa,C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