@govtechsg/sgds-web-component 3.3.2 → 3.3.3-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 +2 -2
- 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 +2 -2
- package/components/Badge/index.umd.js +1 -1
- package/components/Breadcrumb/index.umd.js +36 -11
- package/components/Breadcrumb/index.umd.js.map +1 -1
- package/components/Button/button.js +1 -1
- package/components/Button/index.umd.js +61 -54
- package/components/Button/index.umd.js.map +1 -1
- package/components/Button/sgds-button.d.ts +1 -6
- package/components/Button/sgds-button.js +11 -27
- package/components/Button/sgds-button.js.map +1 -1
- package/components/Card/index.umd.js +111 -83
- package/components/Card/index.umd.js.map +1 -1
- package/components/Card/sgds-card.d.ts +2 -5
- package/components/Card/sgds-card.js +28 -28
- package/components/Card/sgds-card.js.map +1 -1
- package/components/Checkbox/index.umd.js +1 -1
- package/components/ComboBox/index.umd.js +2 -2
- package/components/Datepicker/index.umd.js +62 -29
- package/components/Datepicker/index.umd.js.map +1 -1
- package/components/DescriptionList/index.umd.js +1 -1
- package/components/Divider/index.umd.js +1 -1
- package/components/Drawer/index.umd.js +1 -1
- package/components/Dropdown/index.umd.js +2 -2
- package/components/FileUpload/index.umd.js +62 -29
- package/components/FileUpload/index.umd.js.map +1 -1
- package/components/Footer/footer-item.js +1 -1
- package/components/Footer/index.umd.js +89 -45
- package/components/Footer/index.umd.js.map +1 -1
- package/components/Footer/sgds-footer.d.ts +1 -1
- package/components/Footer/sgds-footer.js +39 -44
- package/components/Footer/sgds-footer.js.map +1 -1
- package/components/Icon/icon.js +1 -1
- package/components/Icon/index.umd.js +2 -2
- package/components/IconButton/index.umd.js +2 -2
- package/components/IconCard/index.umd.js +93 -14
- package/components/IconCard/index.umd.js.map +1 -1
- package/components/IconCard/sgds-icon-card.d.ts +1 -0
- package/components/IconCard/sgds-icon-card.js +8 -3
- package/components/IconCard/sgds-icon-card.js.map +1 -1
- package/components/IconList/index.umd.js +1 -1
- package/components/ImageCard/index.umd.js +93 -14
- package/components/ImageCard/index.umd.js.map +1 -1
- package/components/ImageCard/sgds-image-card.d.ts +1 -0
- package/components/ImageCard/sgds-image-card.js +8 -3
- package/components/ImageCard/sgds-image-card.js.map +1 -1
- package/components/Input/index.umd.js +2 -2
- package/components/Link/index.umd.js +35 -10
- package/components/Link/index.umd.js.map +1 -1
- package/components/Link/link.js +1 -1
- package/components/Link/sgds-link.d.ts +3 -0
- package/components/Link/sgds-link.js +33 -8
- package/components/Link/sgds-link.js.map +1 -1
- package/components/Mainnav/index.umd.js +2 -2
- package/components/Masthead/index.umd.js +2 -2
- package/components/Masthead/masthead.js +1 -1
- package/components/Modal/index.umd.js +1 -1
- package/components/OverflowMenu/index.umd.js +2 -2
- package/components/Pagination/index.umd.js +62 -29
- package/components/Pagination/index.umd.js.map +1 -1
- package/components/ProgressBar/index.umd.js +1 -1
- package/components/QuantityToggle/index.umd.js +2 -2
- package/components/Radio/index.umd.js +1 -1
- package/components/Select/index.umd.js +2 -2
- package/components/Sidenav/index.umd.js +2 -2
- package/components/Skeleton/index.umd.js +1 -1
- package/components/Spinner/index.umd.js +1 -1
- package/components/Stepper/index.umd.js +2 -2
- package/components/Subnav/index.umd.js +3 -3
- package/components/Subnav/subnav-item.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 -14
- package/components/ThumbnailCard/index.umd.js.map +1 -1
- package/components/ThumbnailCard/sgds-thumbnail-card.d.ts +1 -0
- package/components/ThumbnailCard/sgds-thumbnail-card.js +8 -3
- package/components/ThumbnailCard/sgds-thumbnail-card.js.map +1 -1
- package/components/Toast/index.umd.js +1 -1
- package/components/Tooltip/index.umd.js +1 -1
- package/components/index.umd.js +131 -119
- package/components/index.umd.js.map +1 -1
- package/index.umd.js +133 -121
- package/index.umd.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/sgds-element.cjs2.js +1 -1
- package/react/base/sgds-element2.js +1 -1
- package/react/components/Button/button.cjs.js +1 -1
- package/react/components/Button/button.js +1 -1
- package/react/components/Button/sgds-button.cjs.js +10 -26
- package/react/components/Button/sgds-button.cjs.js.map +1 -1
- package/react/components/Button/sgds-button.js +11 -27
- package/react/components/Button/sgds-button.js.map +1 -1
- package/react/components/Card/sgds-card.cjs.js +27 -27
- package/react/components/Card/sgds-card.cjs.js.map +1 -1
- package/react/components/Card/sgds-card.js +28 -28
- package/react/components/Card/sgds-card.js.map +1 -1
- package/react/components/Footer/footer-item.cjs.js +1 -1
- package/react/components/Footer/footer-item.js +1 -1
- package/react/components/Footer/sgds-footer.cjs.js +38 -43
- package/react/components/Footer/sgds-footer.cjs.js.map +1 -1
- package/react/components/Footer/sgds-footer.js +39 -44
- package/react/components/Footer/sgds-footer.js.map +1 -1
- package/react/components/Icon/icon.cjs.js +1 -1
- package/react/components/Icon/icon.js +1 -1
- package/react/components/IconCard/sgds-icon-card.cjs.js +8 -3
- package/react/components/IconCard/sgds-icon-card.cjs.js.map +1 -1
- package/react/components/IconCard/sgds-icon-card.js +8 -3
- package/react/components/IconCard/sgds-icon-card.js.map +1 -1
- package/react/components/ImageCard/sgds-image-card.cjs.js +8 -3
- package/react/components/ImageCard/sgds-image-card.cjs.js.map +1 -1
- package/react/components/ImageCard/sgds-image-card.js +8 -3
- package/react/components/ImageCard/sgds-image-card.js.map +1 -1
- package/react/components/Link/link.cjs.js +1 -1
- package/react/components/Link/link.js +1 -1
- package/react/components/Link/sgds-link.cjs.js +33 -8
- package/react/components/Link/sgds-link.cjs.js.map +1 -1
- package/react/components/Link/sgds-link.js +33 -8
- package/react/components/Link/sgds-link.js.map +1 -1
- package/react/components/Masthead/masthead.cjs.js +1 -1
- package/react/components/Masthead/masthead.js +1 -1
- package/react/components/Subnav/subnav-item.cjs.js +1 -1
- package/react/components/Subnav/subnav-item.js +1 -1
- package/react/components/ThumbnailCard/sgds-thumbnail-card.cjs.js +8 -3
- package/react/components/ThumbnailCard/sgds-thumbnail-card.cjs.js.map +1 -1
- package/react/components/ThumbnailCard/sgds-thumbnail-card.js +8 -3
- package/react/components/ThumbnailCard/sgds-thumbnail-card.js.map +1 -1
|
@@ -15,10 +15,6 @@ export type ButtonVariant = "primary" | "outline" | "ghost" | "danger";
|
|
|
15
15
|
export declare class SgdsButton extends ButtonElement {
|
|
16
16
|
static styles: import("lit").CSSResult[];
|
|
17
17
|
/** @internal */
|
|
18
|
-
private _hasLeftIcon;
|
|
19
|
-
/** @internal */
|
|
20
|
-
private _hasRightIcon;
|
|
21
|
-
/** @internal */
|
|
22
18
|
private readonly formSubmitController;
|
|
23
19
|
/** The behavior of the button with default as `type='button', `reset` resets all the controls to their initial values and `submit` submits the form data to the server */
|
|
24
20
|
type: "button" | "submit" | "reset";
|
|
@@ -37,10 +33,9 @@ export declare class SgdsButton extends ButtonElement {
|
|
|
37
33
|
formTarget: "_self" | "_blank" | "_parent" | "_top" | string;
|
|
38
34
|
/** When set, the button will be in full width. */
|
|
39
35
|
fullWidth: boolean;
|
|
36
|
+
private readonly hasSlotController;
|
|
40
37
|
protected _handleClick(event: MouseEvent): void;
|
|
41
38
|
private _clickHandler;
|
|
42
|
-
private _handleLeftIconSlotchange;
|
|
43
|
-
private _handleRightIconSlotchange;
|
|
44
39
|
render(): import("lit-html").TemplateResult;
|
|
45
40
|
}
|
|
46
41
|
export default SgdsButton;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { __decorate } from 'tslib';
|
|
2
|
-
import {
|
|
2
|
+
import { property } from 'lit/decorators.js';
|
|
3
3
|
import { classMap } from 'lit/directives/class-map.js';
|
|
4
4
|
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
5
5
|
import { literal, html } from 'lit/static-html.js';
|
|
6
6
|
import ButtonElement from '../../base/button-element.js';
|
|
7
7
|
import css_248z from '../../styles/anchor.js';
|
|
8
|
+
import { HasSlotController } from '../../utils/slot.js';
|
|
8
9
|
import { FormSubmitController } from '../../utils/formSubmitController.js';
|
|
9
10
|
import css_248z$1 from './button.js';
|
|
10
11
|
|
|
@@ -24,10 +25,6 @@ class SgdsButton extends ButtonElement {
|
|
|
24
25
|
constructor() {
|
|
25
26
|
super(...arguments);
|
|
26
27
|
/** @internal */
|
|
27
|
-
this._hasLeftIcon = false;
|
|
28
|
-
/** @internal */
|
|
29
|
-
this._hasRightIcon = false;
|
|
30
|
-
/** @internal */
|
|
31
28
|
this.formSubmitController = new FormSubmitController(this, {
|
|
32
29
|
form: (input) => {
|
|
33
30
|
// Buttons support a form attribute that points to an arbitrary form, so if this attribute it set we need to query
|
|
@@ -45,6 +42,7 @@ class SgdsButton extends ButtonElement {
|
|
|
45
42
|
this.type = "button";
|
|
46
43
|
/** When set, the button will be in full width. */
|
|
47
44
|
this.fullWidth = false;
|
|
45
|
+
this.hasSlotController = new HasSlotController(this, "leftIcon", "rightIcon");
|
|
48
46
|
this._clickHandler = () => {
|
|
49
47
|
if (this.type === "submit") {
|
|
50
48
|
this.formSubmitController.submit(this);
|
|
@@ -63,28 +61,20 @@ class SgdsButton extends ButtonElement {
|
|
|
63
61
|
this.removeEventListener("click", this._clickHandler);
|
|
64
62
|
this.addEventListener("click", this._clickHandler);
|
|
65
63
|
}
|
|
66
|
-
_handleLeftIconSlotchange(e) {
|
|
67
|
-
const childNodes = e.target.assignedNodes({ flatten: true });
|
|
68
|
-
if (childNodes.length > 0) {
|
|
69
|
-
return (this._hasLeftIcon = true);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
_handleRightIconSlotchange(e) {
|
|
73
|
-
const childNodes = e.target.assignedNodes({ flatten: true });
|
|
74
|
-
if (childNodes.length > 0) {
|
|
75
|
-
return (this._hasRightIcon = true);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
64
|
render() {
|
|
79
65
|
const isLink = this.href;
|
|
80
66
|
const tag = isLink ? literal `a` : literal `button`;
|
|
67
|
+
const hasLeftIconSlot = this.hasSlotController.test("leftIcon");
|
|
68
|
+
const hasRightIconSlot = this.hasSlotController.test("rightIcon");
|
|
69
|
+
const noIconSlot = !hasLeftIconSlot && !hasRightIconSlot;
|
|
81
70
|
return html `
|
|
82
71
|
<${tag}
|
|
83
72
|
class="btn ${classMap({
|
|
84
73
|
disabled: this.disabled,
|
|
85
74
|
active: this.active,
|
|
86
|
-
"has-left-icon":
|
|
87
|
-
"has-right-icon":
|
|
75
|
+
"has-left-icon": hasLeftIconSlot,
|
|
76
|
+
"has-right-icon": hasRightIconSlot,
|
|
77
|
+
"no-icon": noIconSlot
|
|
88
78
|
})}"
|
|
89
79
|
?disabled=${ifDefined(isLink ? undefined : this.disabled)}
|
|
90
80
|
type=${ifDefined(isLink ? undefined : this.type)}
|
|
@@ -100,20 +90,14 @@ class SgdsButton extends ButtonElement {
|
|
|
100
90
|
@blur=${this._handleBlur}
|
|
101
91
|
aria-label=${ifDefined(this.ariaLabel)}
|
|
102
92
|
>
|
|
103
|
-
<slot name="leftIcon"
|
|
93
|
+
<slot name="leftIcon"></slot>
|
|
104
94
|
<span><slot></slot></span>
|
|
105
|
-
<slot name="rightIcon"
|
|
95
|
+
<slot name="rightIcon"></slot>
|
|
106
96
|
</${tag}>
|
|
107
97
|
`;
|
|
108
98
|
}
|
|
109
99
|
}
|
|
110
100
|
SgdsButton.styles = [...ButtonElement.styles, css_248z, css_248z$1];
|
|
111
|
-
__decorate([
|
|
112
|
-
state()
|
|
113
|
-
], SgdsButton.prototype, "_hasLeftIcon", void 0);
|
|
114
|
-
__decorate([
|
|
115
|
-
state()
|
|
116
|
-
], SgdsButton.prototype, "_hasRightIcon", void 0);
|
|
117
101
|
__decorate([
|
|
118
102
|
property({ type: String, reflect: true })
|
|
119
103
|
], SgdsButton.prototype, "type", void 0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sgds-button.js","sources":["../../../src/components/Button/sgds-button.ts"],"sourcesContent":["import { property, state } from \"lit/decorators.js\";\nimport { classMap } from \"lit/directives/class-map.js\";\nimport { ifDefined } from \"lit/directives/if-defined.js\";\nimport { html, literal } from \"lit/static-html.js\";\nimport ButtonElement from \"../../base/button-element\";\nimport anchorStyles from \"../../styles/anchor.css\";\nimport { FormSubmitController } from \"../../utils/formSubmitController\";\nimport buttonStyles from \"./button.css\";\n\nexport type ButtonVariant = \"primary\" | \"outline\" | \"ghost\" | \"danger\";\n\n/**\n * @summary Custom button styles for actions in forms, dialogs, and more with support for multiple sizes, states, and more.\n *\n * @slot default - The button's label.\n * @slot leftIcon - The slot for icon to the left of the button text\n * @slot rightIcon - The slot for icon to the right of the button text\n *\n * @event sgds-blur - Emitted when the button is blurred.\n * @event sgds-focus - Emitted when the button is focused.\n *\n *\n */\nexport class SgdsButton extends ButtonElement {\n static styles = [...ButtonElement.styles, anchorStyles, buttonStyles];\n /** @internal */\n @state()\n private _hasLeftIcon = false;\n\n /** @internal */\n @state()\n private _hasRightIcon = false;\n\n /** @internal */\n private readonly formSubmitController = new FormSubmitController(this, {\n form: (input: HTMLInputElement) => {\n // Buttons support a form attribute that points to an arbitrary form, so if this attribute it set we need to query\n // the form from the same root using its id\n if (input.hasAttribute(\"form\")) {\n const doc = input.getRootNode() as Document | ShadowRoot;\n const formId = input.getAttribute(\"form\");\n return doc.getElementById(formId) as HTMLFormElement;\n }\n\n // Fall back to the closest containing form\n return input.closest(\"form\");\n }\n });\n /** The behavior of the button with default as `type='button', `reset` resets all the controls to their initial values and `submit` submits the form data to the server */\n @property({ type: String, reflect: true }) type: \"button\" | \"submit\" | \"reset\" = \"button\";\n /**\n * The \"form owner\" to associate the button with. If omitted, the closest containing form will be used instead. The\n * value of this attribute must be an id of a form in the same document or shadow root as the button.\n */\n @property({ type: String, reflect: true }) form: string;\n\n /** Used to override the form owner's `action` attribute. */\n @property({ type: String, reflect: true, attribute: \"formaction\" }) formAction: string;\n\n /** Used to override the form owner's `method` attribute. */\n @property({ type: String, reflect: true, attribute: \"formmethod\" }) formMethod: \"post\" | \"get\";\n\n /** Used to override the form owner's `novalidate` attribute. */\n @property({ attribute: \"formnovalidate\", type: Boolean, reflect: true })\n formNoValidate: boolean;\n\n /** Used to override the form owner's `target` attribute. */\n @property({ type: String, reflect: true, attribute: \"formtarget\" }) formTarget:\n | \"_self\"\n | \"_blank\"\n | \"_parent\"\n | \"_top\"\n | string;\n\n /** When set, the button will be in full width. */\n @property({ type: Boolean, reflect: true }) fullWidth = false;\n\n protected override _handleClick(event: MouseEvent) {\n if (this.disabled) {\n event.preventDefault();\n event.stopPropagation();\n return;\n }\n\n this.removeEventListener(\"click\", this._clickHandler);\n this.addEventListener(\"click\", this._clickHandler);\n }\n\n private _clickHandler = () => {\n if (this.type === \"submit\") {\n this.formSubmitController.submit(this);\n }\n if (this.type === \"reset\") {\n this.formSubmitController.reset(this);\n }\n };\n\n private _handleLeftIconSlotchange(e: Event) {\n const childNodes = (e.target as HTMLSlotElement).assignedNodes({ flatten: true }) as Array<HTMLOrSVGImageElement>;\n if (childNodes.length > 0) {\n return (this._hasLeftIcon = true);\n }\n }\n\n private _handleRightIconSlotchange(e: Event) {\n const childNodes = (e.target as HTMLSlotElement).assignedNodes({ flatten: true }) as Array<HTMLOrSVGImageElement>;\n if (childNodes.length > 0) {\n return (this._hasRightIcon = true);\n }\n }\n\n render() {\n const isLink = this.href;\n const tag = isLink ? literal`a` : literal`button`;\n return html`\n <${tag}\n class=\"btn ${classMap({\n disabled: this.disabled,\n active: this.active,\n \"has-left-icon\": this._hasLeftIcon,\n \"has-right-icon\": this._hasRightIcon\n })}\"\n ?disabled=${ifDefined(isLink ? undefined : this.disabled)}\n type=${ifDefined(isLink ? undefined : this.type)}\n href=${ifDefined(isLink ? this.href : undefined)}\n target=${ifDefined(isLink ? this.target : undefined)}\n download=${ifDefined(isLink ? this.download : undefined)}\n rel=${ifDefined(isLink && this.target === \"_blank\" ? \"noreferrer noopener\" : undefined)}\n role=${ifDefined(isLink ? \"button\" : undefined)}\n aria-disabled=${this.disabled ? \"true\" : \"false\"}\n tabindex=${this.disabled ? \"-1\" : \"0\"}\n @click=${this._handleClick}\n @focus=${this._handleFocus}\n @blur=${this._handleBlur}\n aria-label=${ifDefined(this.ariaLabel)}\n >\n <slot name=\"leftIcon\" @slotchange=${this._handleLeftIconSlotchange}></slot>\n <span><slot></slot></span>\n <slot name=\"rightIcon\" @slotchange=${this._handleRightIconSlotchange}></slot>\n </${tag}>\n `;\n }\n}\n\nexport default SgdsButton;\n"],"names":["anchorStyles","buttonStyles"],"mappings":";;;;;;;;;;AAWA;;;;;;;;;;;AAWG;AACG,MAAO,UAAW,SAAQ,aAAa,CAAA;AAA7C,IAAA,WAAA,GAAA;;;QAIU,IAAY,CAAA,YAAA,GAAG,KAAK,CAAC;;QAIrB,IAAa,CAAA,aAAA,GAAG,KAAK,CAAC;;AAGb,QAAA,IAAA,CAAA,oBAAoB,GAAG,IAAI,oBAAoB,CAAC,IAAI,EAAE;AACrE,YAAA,IAAI,EAAE,CAAC,KAAuB,KAAI;;;AAGhC,gBAAA,IAAI,KAAK,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE;AAC9B,oBAAA,MAAM,GAAG,GAAG,KAAK,CAAC,WAAW,EAA2B,CAAC;oBACzD,MAAM,MAAM,GAAG,KAAK,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;AAC1C,oBAAA,OAAO,GAAG,CAAC,cAAc,CAAC,MAAM,CAAoB,CAAC;iBACtD;;AAGD,gBAAA,OAAO,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;aAC9B;AACF,SAAA,CAAC,CAAC;;QAEwC,IAAI,CAAA,IAAA,GAAkC,QAAQ,CAAC;;QA0B9C,IAAS,CAAA,SAAA,GAAG,KAAK,CAAC;QAatD,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A,UAAA,CAAA,SAAA,EAAA,YAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAI/F,UAAA,CAAA;AADC,IAAA,QAAQ,CAAC,EAAE,SAAS,EAAE,gBAAgB,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAChD,CAAA,EAAA,UAAA,CAAA,SAAA,EAAA,gBAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAG4C,UAAA,CAAA;AAAnE,IAAA,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC;AAKxD,CAAA,EAAA,UAAA,CAAA,SAAA,EAAA,YAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAGiC,UAAA,CAAA;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAAmB,CAAA,EAAA,UAAA,CAAA,SAAA,EAAA,WAAA,EAAA,KAAA,CAAA,CAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"sgds-button.js","sources":["../../../src/components/Button/sgds-button.ts"],"sourcesContent":["import { property } from \"lit/decorators.js\";\nimport { classMap } from \"lit/directives/class-map.js\";\nimport { ifDefined } from \"lit/directives/if-defined.js\";\nimport { html, literal } from \"lit/static-html.js\";\nimport ButtonElement from \"../../base/button-element\";\nimport anchorStyles from \"../../styles/anchor.css\";\nimport { HasSlotController } from \"../../utils/slot\";\nimport { FormSubmitController } from \"../../utils/formSubmitController\";\nimport buttonStyles from \"./button.css\";\n\nexport type ButtonVariant = \"primary\" | \"outline\" | \"ghost\" | \"danger\";\n\n/**\n * @summary Custom button styles for actions in forms, dialogs, and more with support for multiple sizes, states, and more.\n *\n * @slot default - The button's label.\n * @slot leftIcon - The slot for icon to the left of the button text\n * @slot rightIcon - The slot for icon to the right of the button text\n *\n * @event sgds-blur - Emitted when the button is blurred.\n * @event sgds-focus - Emitted when the button is focused.\n *\n *\n */\nexport class SgdsButton extends ButtonElement {\n static styles = [...ButtonElement.styles, anchorStyles, buttonStyles];\n\n /** @internal */\n private readonly formSubmitController = new FormSubmitController(this, {\n form: (input: HTMLInputElement) => {\n // Buttons support a form attribute that points to an arbitrary form, so if this attribute it set we need to query\n // the form from the same root using its id\n if (input.hasAttribute(\"form\")) {\n const doc = input.getRootNode() as Document | ShadowRoot;\n const formId = input.getAttribute(\"form\");\n return doc.getElementById(formId) as HTMLFormElement;\n }\n\n // Fall back to the closest containing form\n return input.closest(\"form\");\n }\n });\n /** The behavior of the button with default as `type='button', `reset` resets all the controls to their initial values and `submit` submits the form data to the server */\n @property({ type: String, reflect: true }) type: \"button\" | \"submit\" | \"reset\" = \"button\";\n /**\n * The \"form owner\" to associate the button with. If omitted, the closest containing form will be used instead. The\n * value of this attribute must be an id of a form in the same document or shadow root as the button.\n */\n @property({ type: String, reflect: true }) form: string;\n\n /** Used to override the form owner's `action` attribute. */\n @property({ type: String, reflect: true, attribute: \"formaction\" }) formAction: string;\n\n /** Used to override the form owner's `method` attribute. */\n @property({ type: String, reflect: true, attribute: \"formmethod\" }) formMethod: \"post\" | \"get\";\n\n /** Used to override the form owner's `novalidate` attribute. */\n @property({ attribute: \"formnovalidate\", type: Boolean, reflect: true })\n formNoValidate: boolean;\n\n /** Used to override the form owner's `target` attribute. */\n @property({ type: String, reflect: true, attribute: \"formtarget\" }) formTarget:\n | \"_self\"\n | \"_blank\"\n | \"_parent\"\n | \"_top\"\n | string;\n\n /** When set, the button will be in full width. */\n @property({ type: Boolean, reflect: true }) fullWidth = false;\n\n private readonly hasSlotController = new HasSlotController(this, \"leftIcon\", \"rightIcon\");\n\n protected override _handleClick(event: MouseEvent) {\n if (this.disabled) {\n event.preventDefault();\n event.stopPropagation();\n return;\n }\n\n this.removeEventListener(\"click\", this._clickHandler);\n this.addEventListener(\"click\", this._clickHandler);\n }\n\n private _clickHandler = () => {\n if (this.type === \"submit\") {\n this.formSubmitController.submit(this);\n }\n if (this.type === \"reset\") {\n this.formSubmitController.reset(this);\n }\n };\n\n render() {\n const isLink = this.href;\n const tag = isLink ? literal`a` : literal`button`;\n const hasLeftIconSlot = this.hasSlotController.test(\"leftIcon\");\n const hasRightIconSlot = this.hasSlotController.test(\"rightIcon\");\n const noIconSlot = !hasLeftIconSlot && !hasRightIconSlot;\n\n return html`\n <${tag}\n class=\"btn ${classMap({\n disabled: this.disabled,\n active: this.active,\n \"has-left-icon\": hasLeftIconSlot,\n \"has-right-icon\": hasRightIconSlot,\n \"no-icon\": noIconSlot\n })}\"\n ?disabled=${ifDefined(isLink ? undefined : this.disabled)}\n type=${ifDefined(isLink ? undefined : this.type)}\n href=${ifDefined(isLink ? this.href : undefined)}\n target=${ifDefined(isLink ? this.target : undefined)}\n download=${ifDefined(isLink ? this.download : undefined)}\n rel=${ifDefined(isLink && this.target === \"_blank\" ? \"noreferrer noopener\" : undefined)}\n role=${ifDefined(isLink ? \"button\" : undefined)}\n aria-disabled=${this.disabled ? \"true\" : \"false\"}\n tabindex=${this.disabled ? \"-1\" : \"0\"}\n @click=${this._handleClick}\n @focus=${this._handleFocus}\n @blur=${this._handleBlur}\n aria-label=${ifDefined(this.ariaLabel)}\n >\n <slot name=\"leftIcon\"></slot>\n <span><slot></slot></span>\n <slot name=\"rightIcon\"></slot>\n </${tag}>\n `;\n }\n}\n\nexport default SgdsButton;\n"],"names":["anchorStyles","buttonStyles"],"mappings":";;;;;;;;;;;AAYA;;;;;;;;;;;AAWG;AACG,MAAO,UAAW,SAAQ,aAAa,CAAA;AAA7C,IAAA,WAAA,GAAA;;;AAImB,QAAA,IAAA,CAAA,oBAAoB,GAAG,IAAI,oBAAoB,CAAC,IAAI,EAAE;AACrE,YAAA,IAAI,EAAE,CAAC,KAAuB,KAAI;;;AAGhC,gBAAA,IAAI,KAAK,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE;AAC9B,oBAAA,MAAM,GAAG,GAAG,KAAK,CAAC,WAAW,EAA2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EAAE,CAAC;AAChD,CAAA,EAAA,UAAA,CAAA,SAAA,EAAA,gBAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAG4C,UAAA,CAAA;AAAnE,IAAA,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC;AAKxD,CAAA,EAAA,UAAA,CAAA,SAAA,EAAA,YAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAGiC,UAAA,CAAA;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAAmB,CAAA,EAAA,UAAA,CAAA,SAAA,EAAA,WAAA,EAAA,KAAA,CAAA,CAAA;;;;"}
|
|
@@ -2974,51 +2974,6 @@
|
|
|
2974
2974
|
});
|
|
2975
2975
|
}
|
|
2976
2976
|
|
|
2977
|
-
/**
|
|
2978
|
-
* @license
|
|
2979
|
-
* Copyright 2017 Google LLC
|
|
2980
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
2981
|
-
*/
|
|
2982
|
-
/**
|
|
2983
|
-
* A property decorator that converts a class property into a getter that
|
|
2984
|
-
* returns the `assignedNodes` of the given `slot`.
|
|
2985
|
-
*
|
|
2986
|
-
* Can be passed an optional {@linkcode QueryAssignedNodesOptions} object.
|
|
2987
|
-
*
|
|
2988
|
-
* Example usage:
|
|
2989
|
-
* ```ts
|
|
2990
|
-
* class MyElement {
|
|
2991
|
-
* @queryAssignedNodes({slot: 'list', flatten: true})
|
|
2992
|
-
* listItems!: Array<Node>;
|
|
2993
|
-
*
|
|
2994
|
-
* render() {
|
|
2995
|
-
* return html`
|
|
2996
|
-
* <slot name="list"></slot>
|
|
2997
|
-
* `;
|
|
2998
|
-
* }
|
|
2999
|
-
* }
|
|
3000
|
-
* ```
|
|
3001
|
-
*
|
|
3002
|
-
* Note the type of this property should be annotated as `Array<Node>`. Use the
|
|
3003
|
-
* queryAssignedElements decorator to list only elements, and optionally filter
|
|
3004
|
-
* the element list using a CSS selector.
|
|
3005
|
-
*
|
|
3006
|
-
* @category Decorator
|
|
3007
|
-
*/
|
|
3008
|
-
function queryAssignedNodes(options) {
|
|
3009
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3010
|
-
return ((obj, name) => {
|
|
3011
|
-
const { slot } = options ?? {};
|
|
3012
|
-
const slotSelector = `slot${slot ? `[name=${slot}]` : ':not([name])'}`;
|
|
3013
|
-
return desc(obj, name, {
|
|
3014
|
-
get() {
|
|
3015
|
-
const slotEl = this.renderRoot?.querySelector(slotSelector);
|
|
3016
|
-
return (slotEl?.assignedNodes(options) ?? []);
|
|
3017
|
-
},
|
|
3018
|
-
});
|
|
3019
|
-
});
|
|
3020
|
-
}
|
|
3021
|
-
|
|
3022
2977
|
/**
|
|
3023
2978
|
* @license
|
|
3024
2979
|
* Copyright 2017 Google LLC
|
|
@@ -4499,7 +4454,7 @@
|
|
|
4499
4454
|
`is not recommended.`);
|
|
4500
4455
|
}
|
|
4501
4456
|
|
|
4502
|
-
var css_248z$8 = css`:host{-webkit-text-size-adjust:100%;-webkit-tap-highlight-color:rgba(0,0,0,0);color:var(--sgds-body-color-default);font-family:var(--sgds-font-family-brand);font-size:var(--sgds-font-size-2);font-weight:var(--sgds-font-weight-regular);line-height:var(--sgds-line-height-body);margin:0;*,:after,:before{box-sizing:border-box}:disabled{cursor:not-allowed}@media (prefers-reduced-motion:no-preference){:root{scroll-behavior:smooth}}
|
|
4457
|
+
var css_248z$8 = css`:host{-webkit-text-size-adjust:100%;-webkit-tap-highlight-color:rgba(0,0,0,0);color:var(--sgds-body-color-default);font-family:var(--sgds-font-family-brand);font-size:var(--sgds-font-size-2);font-weight:var(--sgds-font-weight-regular);line-height:var(--sgds-line-height-body);margin:0;*,:after,:before{box-sizing:border-box}:disabled{cursor:not-allowed}@media (prefers-reduced-motion:no-preference){:root{scroll-behavior:smooth}}::slotted(a[target=_blank]):after,a[target=_blank]:after{background-color:currentColor;content:"/";display:inline-block;height:var(--sgds-icon-size-lg);margin-left:.25rem;-webkit-mask-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' fill='none'%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M9.774 4.4H9.8a.6.6 0 1 1 0 1.2c-.85 0-1.451 0-1.922.039-.463.038-.745.11-.968.223A2.4 2.4 0 0 0 5.861 6.91c-.113.223-.184.505-.222.968-.039.47-.04 1.072-.04 1.922v4.4c0 .85.001 1.451.04 1.922.038.463.11.745.222.968a2.4 2.4 0 0 0 1.05 1.048c.222.114.504.185.967.223.47.038 1.072.039 1.922.039h4.4c.85 0 1.451 0 1.921-.039.464-.038.746-.11.969-.223a2.4 2.4 0 0 0 1.048-1.048c.113-.223.185-.505.223-.968.038-.47.039-1.072.039-1.922a.6.6 0 1 1 1.2 0v.026c0 .818 0 1.468-.043 1.993-.044.538-.136.996-.35 1.415a3.6 3.6 0 0 1-1.573 1.574c-.42.213-.878.305-1.415.35-.525.042-1.175.042-1.993.042H9.774c-.818 0-1.469 0-1.993-.043-.538-.044-.996-.136-1.415-.35a3.6 3.6 0 0 1-1.574-1.573c-.213-.42-.305-.877-.35-1.415-.042-.525-.042-1.175-.042-1.993V9.774c0-.818 0-1.468.043-1.993.044-.538.136-.996.35-1.415a3.6 3.6 0 0 1 1.573-1.574c.42-.213.877-.305 1.415-.35C8.305 4.4 8.956 4.4 9.774 4.4ZM12.4 5a.6.6 0 0 1 .6-.6h6a.6.6 0 0 1 .6.6v6a.6.6 0 1 1-1.2 0V6.449l-5.976 5.975a.6.6 0 0 1-.848-.848L17.55 5.6H13a.6.6 0 0 1-.6-.6Z' fill='%230E0E0E'/%3E%3C/svg%3E");mask-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' fill='none'%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M9.774 4.4H9.8a.6.6 0 1 1 0 1.2c-.85 0-1.451 0-1.922.039-.463.038-.745.11-.968.223A2.4 2.4 0 0 0 5.861 6.91c-.113.223-.184.505-.222.968-.039.47-.04 1.072-.04 1.922v4.4c0 .85.001 1.451.04 1.922.038.463.11.745.222.968a2.4 2.4 0 0 0 1.05 1.048c.222.114.504.185.967.223.47.038 1.072.039 1.922.039h4.4c.85 0 1.451 0 1.921-.039.464-.038.746-.11.969-.223a2.4 2.4 0 0 0 1.048-1.048c.113-.223.185-.505.223-.968.038-.47.039-1.072.039-1.922a.6.6 0 1 1 1.2 0v.026c0 .818 0 1.468-.043 1.993-.044.538-.136.996-.35 1.415a3.6 3.6 0 0 1-1.573 1.574c-.42.213-.878.305-1.415.35-.525.042-1.175.042-1.993.042H9.774c-.818 0-1.469 0-1.993-.043-.538-.044-.996-.136-1.415-.35a3.6 3.6 0 0 1-1.574-1.573c-.213-.42-.305-.877-.35-1.415-.042-.525-.042-1.175-.042-1.993V9.774c0-.818 0-1.468.043-1.993.044-.538.136-.996.35-1.415a3.6 3.6 0 0 1 1.573-1.574c.42-.213.877-.305 1.415-.35C8.305 4.4 8.956 4.4 9.774 4.4ZM12.4 5a.6.6 0 0 1 .6-.6h6a.6.6 0 0 1 .6.6v6a.6.6 0 1 1-1.2 0V6.449l-5.976 5.975a.6.6 0 0 1-.848-.848L17.55 5.6H13a.6.6 0 0 1-.6-.6Z' fill='%230E0E0E'/%3E%3C/svg%3E");-webkit-mask-position:center;mask-position:center;-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat;vertical-align:bottom;width:var(--sgds-icon-size-lg)}::slotted(svg){vertical-align:middle}}`;
|
|
4503
4458
|
|
|
4504
4459
|
/**
|
|
4505
4460
|
* @cssprop --sgds-{stateColor} - State colors in hexadecimal value
|
|
@@ -4560,7 +4515,7 @@
|
|
|
4560
4515
|
/** @internal */
|
|
4561
4516
|
SgdsElement.dependencies = {};
|
|
4562
4517
|
|
|
4563
|
-
var css_248z$7 = css
|
|
4518
|
+
var css_248z$7 = css`:host{display:inline-flex}.nav-link::slotted(a){color:var(--sgds-link-color-default);cursor:pointer;line-height:var(--sgds-line-height-body);text-decoration:none!important}.nav-link::slotted(a:focus),.nav-link::slotted(a:focus-visible),.nav-link::slotted(a:hover),.nav-link::slotted(a[active]){color:var( --sgds-link-color-emphasis)}.nav-link::slotted(a:focus),.nav-link::slotted(a:focus-visible){outline:0}.nav-link::slotted(a:focus-visible:not([disabled])){box-shadow:var(--sgds-box-shadow-focus)}.nav-link::slotted(a[disabled]){cursor:not-allowed;opacity:var(--sgds-opacity-50)}:host([variant=danger]) .nav-link::slotted(a){--sgds-link-color-default:var(--sgds-danger-color-default);color:var(--sgds-link-color-default,--sgds-danger-color-default)}:host([variant=danger]) .nav-link::slotted(a:focus),:host([variant=danger]) .nav-link::slotted(a:focus-visible),:host([variant=danger]) .nav-link::slotted(a:hover){--sgds-link-color-emphasis:var(--sgds-danger-color-emphasis);color:var(--sgds-link-color-emphasis,--sgds-danger-color-emphasis)}:host([variant=neutral]) .nav-link::slotted(a){--sgds-link-color-default:var(--sgds-color-default);color:var(--sgds-link-color-default,--sgds-color-default)}:host([variant=neutral]) .nav-link::slotted(a:focus),:host([variant=neutral]) .nav-link::slotted(a:focus-visible),:host([variant=neutral]) .nav-link::slotted(a:hover){--sgds-link-color-emphasis:var(--sgds-color-default);color:var(--sgds-link-color-emphasis,--sgds-color-default)}:host([variant=light]) .nav-link::slotted(a){--sgds-link-color-default:var(--sgds-color-fixed-light);color:var(--sgds-link-color-default,--sgds-color-fixed-light)}:host([variant=light]) .nav-link::slotted(a:focus),:host([variant=light]) .nav-link::slotted(a:focus-visible),:host([variant=light]) .nav-link::slotted(a:hover){--sgds-link-color-emphasis:var(--sgds-color-fixed-light);color:var(--sgds-link-color-emphasis,--sgds-color-fixed-light)}:host([variant=dark]) .nav-link::slotted(a){--sgds-link-color-default:var(--sgds-color-fixed-dark);color:var(--sgds-link-color-default,--sgds-color-fixed-dark)}:host([variant=dark]) .nav-link::slotted(a:focus),:host([variant=dark]) .nav-link::slotted(a:focus-visible),:host([variant=dark]) .nav-link::slotted(a:hover){--sgds-link-color-emphasis:var(--sgds-color-fixed-dark);color:var(--sgds-link-color-emphasis,--sgds-color-fixed-dark)}:host([size=lg]) .nav-link::slotted(a){font-size:var(--sgds-font-size-3)!important}:host([size=sm]) .nav-link::slotted(a){font-size:var(--sgds-font-size-1)!important;line-height:var(--sgds-line-height-min)}:host([size=xs]) .nav-link::slotted(a){font-size:var(--sgds-font-size-0)!important;line-height:var(--sgds-line-height-16)}`;
|
|
4564
4519
|
|
|
4565
4520
|
/**
|
|
4566
4521
|
* @summary Link allows users to click and navigate their way from page to page
|
|
@@ -4575,16 +4530,41 @@
|
|
|
4575
4530
|
/** when true, sets the active stylings of the link */
|
|
4576
4531
|
this.variant = "primary";
|
|
4577
4532
|
}
|
|
4578
|
-
|
|
4579
|
-
|
|
4580
|
-
|
|
4581
|
-
|
|
4582
|
-
|
|
4583
|
-
|
|
4533
|
+
_processAnchor(anchor) {
|
|
4534
|
+
if (anchor.hasAttribute("disabled")) {
|
|
4535
|
+
anchor.setAttribute("href", "javascript:void(0)");
|
|
4536
|
+
anchor.setAttribute("tabindex", "-1");
|
|
4537
|
+
}
|
|
4538
|
+
else {
|
|
4539
|
+
anchor.setAttribute("tabindex", "0");
|
|
4540
|
+
}
|
|
4541
|
+
}
|
|
4542
|
+
_processIcon(anchor) {
|
|
4543
|
+
const icons = anchor.querySelectorAll("sgds-icon");
|
|
4544
|
+
icons.forEach(icon => {
|
|
4545
|
+
icon.classList.remove("icon-left", "icon-right");
|
|
4546
|
+
if (!icon.previousElementSibling && !icon.previousSibling) {
|
|
4547
|
+
icon.classList.add("icon-left");
|
|
4584
4548
|
}
|
|
4585
|
-
|
|
4586
|
-
|
|
4549
|
+
if (!icon.nextElementSibling && !icon.nextSibling) {
|
|
4550
|
+
icon.classList.add("icon-right");
|
|
4587
4551
|
}
|
|
4552
|
+
});
|
|
4553
|
+
}
|
|
4554
|
+
_handleSlotChange(e) {
|
|
4555
|
+
const anchor = e.target
|
|
4556
|
+
.assignedElements()
|
|
4557
|
+
.find(el => el.tagName.toLowerCase() === "a");
|
|
4558
|
+
if (anchor) {
|
|
4559
|
+
this._processAnchor(anchor);
|
|
4560
|
+
this._processIcon(anchor);
|
|
4561
|
+
}
|
|
4562
|
+
}
|
|
4563
|
+
firstUpdated() {
|
|
4564
|
+
const anchor = this.querySelector("a");
|
|
4565
|
+
if (anchor) {
|
|
4566
|
+
this._processAnchor(anchor);
|
|
4567
|
+
this._processIcon(anchor);
|
|
4588
4568
|
}
|
|
4589
4569
|
}
|
|
4590
4570
|
render() {
|
|
@@ -4600,7 +4580,7 @@
|
|
|
4600
4580
|
property({ type: String, reflect: true })
|
|
4601
4581
|
], SgdsLink.prototype, "variant", void 0);
|
|
4602
4582
|
|
|
4603
|
-
var css_248z$6 = css`:host([disabled]){cursor:not-allowed}:host([orientation=horizontal]) .card{flex-direction:row}:host(:not([hideBorder])) .card{border:var(--sgds-border-width-1) solid var(--sgds-border-color-muted)}:host([orientation=horizontal]) .card-body{flex:1}:host([orientation=horizontal]) .card-media{padding:var(--sgds-padding-xl) var(--sgds-padding-none) var(--sgds-padding-xl) var(--sgds-padding-xl)}:host([orientation=horizontal]) .card-image{width:40%}:host([imagePosition=after]) .card-image{order:1}:host([orientation=vertical][imagePosition=after]) slot[name=image]::slotted(img){border-radius:calc(var(--sgds-border-radius-md) - var(--sgds-border-width-1));border-top-left-radius:var(--sgds-border-radius-none);border-top-right-radius:var(--sgds-border-radius-none)}:host([orientation=horizontal][imagePosition=after]) slot[name=image]::slotted(img){border-radius:calc(var(--sgds-border-radius-md) - var(--sgds-border-width-1));border-bottom-left-radius:var(--sgds-border-radius-none);border-top-left-radius:var(--sgds-border-radius-none)}:host([orientation=horizontal]) slot[name=image]::slotted(img){border-bottom-left-radius:calc(var(--sgds-border-radius-md) - var(--sgds-border-width-1));border-top-right-radius:var(--sgds-border-radius-none);height:100%;object-fit:cover}:host([orientation=vertical][imageAdjustment="padding around"]) .card-image{margin:var(--sgds-margin-sm) var(--sgds-margin-sm) var(--sgds-padding-none)}:host([orientation=vertical][imageAdjustment="padding around"][imagePosition=after]) .card-image{margin:var(--sgds-margin-none) var(--sgds-margin-sm) var(--sgds-margin-sm)}:host([orientation=horizontal][imageAdjustment="padding around"]) .card-image{margin:var(--sgds-margin-sm) var(--sgds-margin-none) var(--sgds-margin-sm) var(--sgds-margin-sm)}:host([orientation=horizontal][imageAdjustment="padding around"][imagePosition=after]) .card-image{margin:var(--sgds-margin-sm) var(--sgds-margin-sm) var(--sgds-margin-sm) var(--sgds-margin-none)}:host([orientation][imageAdjustment="padding around"]) slot[name=image]::slotted(img){border-radius:calc(var(--sgds-border-radius-md) - var(--sgds-border-width-1))}:host([orientation=vertical]:not([imageAdjustment="aspect ratio"])) slot[name=image]::slotted(img){height:auto}:host([orientation=vertical][imageAdjustment="aspect ratio"]) slot[name=image]::slotted(img){object-fit:cover}.card{word-wrap:break-word;background-clip:border-box;background-color:var(--sgds-surface-default);border:var(--sgds-border-width-1) solid var(--sgds-border-color-transparent);border-radius:var(--sgds-border-radius-md);box-shadow:none;display:flex;flex-direction:column;height:100%;min-width:0;position:relative;transition:box-shadow .3s ease}a.card{color:initial;text-decoration:none}@media (prefers-reduced-motion:reduce){.card{transition:none}}.card.disabled{opacity:var(--sgds-opacity-50);pointer-events:none}a.card:focus{outline:0}a.card:not(.disabled):focus-visible{box-shadow:var(--sgds-box-shadow-focus)}.card-tinted-bg{border-radius:var(--sgds-border-radius-md);bottom:0;left:0;opacity:var(--sgds-opacity-0);position:absolute;right:0;top:0}.card-image{flex:1;position:relative}.card-media{align-items:flex-start;display:flex;justify-content:space-between;line-height:0;padding:var(--sgds-padding-xl) var(--sgds-padding-xl) var(--sgds-padding-none)}.card-thumbnail{align-items:center;border:var(--sgds-border-width-1) solid var(--sgds-border-color-muted);border-radius:var(--sgds-border-radius-full);display:flex;height:var(--sgds-dimension-80);justify-content:center;width:var(--sgds-dimension-80)}.card-body{color:var(--sgds-body-color-default);display:flex;flex:1 1 auto;flex-direction:column;gap:var(--sgds-gap-xl);padding:var(--sgds-padding-xl);z-index:1}.card-header-container{display:flex;flex-direction:column;gap:var(--sgds-gap-sm)}.card-header{display:flex;flex-direction:column;gap:var(--sgds-gap-xs)}.card-title{--sgds-font-size-5:var(--sgds-font-size-4);--sgds-font-size-6:var(--sgds-font-size-4);--sgds-margin-2-xs:var(--sgds-margin-none);--sgds-font-weight-bold:var(--sgds-font-weight-semibold);color:var(--sgds-body-color-default);font-size:var(--sgds-font-size-4);font-weight:var(--sgds-font-weight-semibold)}.card-subtitle,.card-text,.card-title{margin-bottom:var(--sgds-margin-none)}slot[name=subtitle]::slotted(*){--sgds-margin-2-xs:var(--sgds-margin-none);--sgds-margin-xs:var(--sgds-margin-none);--sgds-font-size-4:var(--sgds-font-size-1);--sgds-font-size-5:var(--sgds-font-size-1);--sgds-font-size-6:var(--sgds-font-size-1);--sgds-font-weight-bold:var(--sgds-font-weight-semibold);--sgds-line-height-heading:var(--sgds-line-height-min);--sgds-letter-spacing-tight:var(--sgds-letter-spacing-wide);color:var(--sgds-color-default);font-size:var(--sgds-font-size-1);font-weight:var(--sgds-font-weight-semibold);letter-spacing:var(--sgds-letter-spacing-wide);line-height:var(--sgds-line-height-min);margin:var(--sgds-margin-none);text-transform:uppercase}slot[name=title]::slotted(a){--sgds-font-size-2:var(--sgds-font-size-4);--sgds-font-weight-regular:var(--sgds-font-weight-semibold);color:var(--sgds-link-color-default);font-size:var(--sgds-font-size-4);font-weight:var(--sgds-font-weight-semibold);text-decoration:none!important}slot[name=description]::slotted(*){color:var(--sgds-color-subtle)}slot[name=image]::slotted(img){border-top-left-radius:calc(var(--sgds-border-radius-md) - var(--sgds-border-width-1));border-top-right-radius:calc(var(--sgds-border-radius-md) - var(--sgds-border-width-1));display:block;width:100%}slot[name=link]::slotted(*){font-weight:700;margin-top:auto;padding-top:var(--sgds-padding-sm)}slot[name=link]::slotted(a){color:var(--sgds-link-color-default);
|
|
4583
|
+
var css_248z$6 = css`:host([disabled]){cursor:not-allowed}:host([orientation=horizontal]) .card{flex-direction:row}:host(:not([hideBorder])) .card{border:var(--sgds-border-width-1) solid var(--sgds-border-color-muted)}:host([orientation=horizontal]) .card-body{flex:1}:host([orientation=horizontal]) .card-media{padding:var(--sgds-padding-xl) var(--sgds-padding-none) var(--sgds-padding-xl) var(--sgds-padding-xl)}:host([orientation=horizontal]) .card-image{width:40%}:host([imagePosition=after]) .card-image{order:1}:host([orientation=vertical][imagePosition=after]) slot[name=image]::slotted(img){border-radius:calc(var(--sgds-border-radius-md) - var(--sgds-border-width-1));border-top-left-radius:var(--sgds-border-radius-none);border-top-right-radius:var(--sgds-border-radius-none)}:host([orientation=horizontal][imagePosition=after]) slot[name=image]::slotted(img){border-radius:calc(var(--sgds-border-radius-md) - var(--sgds-border-width-1));border-bottom-left-radius:var(--sgds-border-radius-none);border-top-left-radius:var(--sgds-border-radius-none)}:host([orientation=horizontal]) slot[name=image]::slotted(img){border-bottom-left-radius:calc(var(--sgds-border-radius-md) - var(--sgds-border-width-1));border-top-right-radius:var(--sgds-border-radius-none);height:100%;object-fit:cover}:host([orientation=vertical][imageAdjustment="padding around"]) .card-image{margin:var(--sgds-margin-sm) var(--sgds-margin-sm) var(--sgds-padding-none)}:host([orientation=vertical][imageAdjustment="padding around"][imagePosition=after]) .card-image{margin:var(--sgds-margin-none) var(--sgds-margin-sm) var(--sgds-margin-sm)}:host([orientation=horizontal][imageAdjustment="padding around"]) .card-image{margin:var(--sgds-margin-sm) var(--sgds-margin-none) var(--sgds-margin-sm) var(--sgds-margin-sm)}:host([orientation=horizontal][imageAdjustment="padding around"][imagePosition=after]) .card-image{margin:var(--sgds-margin-sm) var(--sgds-margin-sm) var(--sgds-margin-sm) var(--sgds-margin-none)}:host([orientation][imageAdjustment="padding around"]) slot[name=image]::slotted(img){border-radius:calc(var(--sgds-border-radius-md) - var(--sgds-border-width-1))}:host([orientation=vertical]:not([imageAdjustment="aspect ratio"])) slot[name=image]::slotted(img){height:auto}:host([orientation=vertical][imageAdjustment="aspect ratio"]) slot[name=image]::slotted(img){object-fit:cover}.card{word-wrap:break-word;background-clip:border-box;background-color:var(--sgds-surface-default);border:var(--sgds-border-width-1) solid var(--sgds-border-color-transparent);border-radius:var(--sgds-border-radius-md);box-shadow:none;display:flex;flex-direction:column;height:100%;min-width:0;position:relative;transition:box-shadow .3s ease}a.card{color:initial;text-decoration:none}@media (prefers-reduced-motion:reduce){.card{transition:none}}.card.disabled{opacity:var(--sgds-opacity-50);pointer-events:none}a.card:focus{outline:0}a.card:not(.disabled):focus-visible{box-shadow:var(--sgds-box-shadow-focus)}.card-tinted-bg{border-radius:var(--sgds-border-radius-md);bottom:0;left:0;opacity:var(--sgds-opacity-0);position:absolute;right:0;top:0}.card-image{flex:1;position:relative}.card-media{align-items:flex-start;display:flex;justify-content:space-between;line-height:0;padding:var(--sgds-padding-xl) var(--sgds-padding-xl) var(--sgds-padding-none)}.card-thumbnail{align-items:center;border:var(--sgds-border-width-1) solid var(--sgds-border-color-muted);border-radius:var(--sgds-border-radius-full);display:flex;height:var(--sgds-dimension-80);justify-content:center;width:var(--sgds-dimension-80)}.card-body{color:var(--sgds-body-color-default);display:flex;flex:1 1 auto;flex-direction:column;gap:var(--sgds-gap-xl);padding:var(--sgds-padding-xl);z-index:1}.card-header-container{display:flex;flex-direction:column;gap:var(--sgds-gap-sm)}.card-header{display:flex;flex-direction:column;gap:var(--sgds-gap-xs)}.card-title{--sgds-font-size-5:var(--sgds-font-size-4);--sgds-font-size-6:var(--sgds-font-size-4);--sgds-margin-2-xs:var(--sgds-margin-none);--sgds-font-weight-bold:var(--sgds-font-weight-semibold);color:var(--sgds-body-color-default);font-size:var(--sgds-font-size-4);font-weight:var(--sgds-font-weight-semibold)}.card-subtitle,.card-text,.card-title{margin-bottom:var(--sgds-margin-none)}slot[name=subtitle]::slotted(*){--sgds-margin-2-xs:var(--sgds-margin-none);--sgds-margin-xs:var(--sgds-margin-none);--sgds-font-size-4:var(--sgds-font-size-1);--sgds-font-size-5:var(--sgds-font-size-1);--sgds-font-size-6:var(--sgds-font-size-1);--sgds-font-weight-bold:var(--sgds-font-weight-semibold);--sgds-line-height-heading:var(--sgds-line-height-min);--sgds-letter-spacing-tight:var(--sgds-letter-spacing-wide);color:var(--sgds-color-default);font-size:var(--sgds-font-size-1);font-weight:var(--sgds-font-weight-semibold);letter-spacing:var(--sgds-letter-spacing-wide);line-height:var(--sgds-line-height-min);margin:var(--sgds-margin-none);text-transform:uppercase}slot[name=title]::slotted(a){--sgds-font-size-2:var(--sgds-font-size-4);--sgds-font-weight-regular:var(--sgds-font-weight-semibold);color:var(--sgds-link-color-default);font-size:var(--sgds-font-size-4);font-weight:var(--sgds-font-weight-semibold);text-decoration:none!important}slot[name=description]::slotted(*){color:var(--sgds-color-subtle)}slot[name=image]::slotted(img){border-top-left-radius:calc(var(--sgds-border-radius-md) - var(--sgds-border-width-1));border-top-right-radius:calc(var(--sgds-border-radius-md) - var(--sgds-border-width-1));display:block;width:100%}slot[name=link]::slotted(*){font-weight:700;margin-top:auto;padding-top:var(--sgds-padding-sm)}slot[name=link]::slotted(a){color:var(--sgds-link-color-default);height:auto!important;text-decoration:none!important}slot[name=link]::slotted(a:focus),slot[name=link]::slotted(a:hover),slot[name=title]::slotted(a:focus),slot[name=title]::slotted(a:hover){color:var(--sgds-link-color-emphasis)}slot[name=link]::slotted(a:focus),slot[name=title]::slotted(a:focus){outline:0}slot[name=link]::slotted(a:focus-visible),slot[name=title]::slotted(a:focus-visible){box-shadow:var(--sgds-box-shadow-focus)}`;
|
|
4604
4584
|
|
|
4605
4585
|
var css_248z$5 = css`.text-primary{color:var(--sgds-primary-rgb)!important}.text-secondary{color:var(--sgds-secondary-rgb)!important}.text-success{color:var(--sgds-success-rgb)!important}.text-info{color:var(--sgds-info-rgb)!important}.text-warning{color:var(--sgds-warning-rgb)!important}.text-danger{color:var(--sgds-danger-rgb)!important}.text-light{color:var(--sgds-light-rgb)!important}.text-dark{color:var(--sgds-dark-rgb)!important}.text-muted{color:var(--sgds-secondary-color)!important}`;
|
|
4606
4586
|
|
|
@@ -4669,12 +4649,63 @@
|
|
|
4669
4649
|
property({ type: String, reflect: true })
|
|
4670
4650
|
], CardElement.prototype, "orientation", void 0);
|
|
4671
4651
|
|
|
4652
|
+
class HasSlotController {
|
|
4653
|
+
constructor(host, ...slotNames) {
|
|
4654
|
+
this.slotNames = [];
|
|
4655
|
+
(this.host = host).addController(this);
|
|
4656
|
+
this.slotNames = slotNames;
|
|
4657
|
+
this.handleSlotChange = this.handleSlotChange.bind(this);
|
|
4658
|
+
}
|
|
4659
|
+
hasDefaultSlot() {
|
|
4660
|
+
return [...this.host.childNodes].some(node => {
|
|
4661
|
+
var _a;
|
|
4662
|
+
if (node.nodeType === node.TEXT_NODE && ((_a = node.textContent) === null || _a === void 0 ? void 0 : _a.trim()) !== "") {
|
|
4663
|
+
return true;
|
|
4664
|
+
}
|
|
4665
|
+
if (node.nodeType === node.ELEMENT_NODE) {
|
|
4666
|
+
const el = node;
|
|
4667
|
+
const tagName = el.tagName.toLowerCase();
|
|
4668
|
+
// Ignore visually hidden elements since they aren't rendered
|
|
4669
|
+
if (tagName === "sl-visually-hidden") {
|
|
4670
|
+
return false;
|
|
4671
|
+
}
|
|
4672
|
+
// If it doesn't have a slot attribute, it's part of the default slot
|
|
4673
|
+
if (!el.hasAttribute("slot")) {
|
|
4674
|
+
return true;
|
|
4675
|
+
}
|
|
4676
|
+
}
|
|
4677
|
+
return false;
|
|
4678
|
+
});
|
|
4679
|
+
}
|
|
4680
|
+
hasNamedSlot(name) {
|
|
4681
|
+
return this.host.querySelector(`:scope > [slot="${name}"]`) !== null;
|
|
4682
|
+
}
|
|
4683
|
+
test(slotName) {
|
|
4684
|
+
return slotName === "[default]" ? this.hasDefaultSlot() : this.hasNamedSlot(slotName);
|
|
4685
|
+
}
|
|
4686
|
+
hostConnected() {
|
|
4687
|
+
var _a;
|
|
4688
|
+
(_a = this.host.shadowRoot) === null || _a === void 0 ? void 0 : _a.addEventListener("slotchange", this.handleSlotChange);
|
|
4689
|
+
}
|
|
4690
|
+
hostDisconnected() {
|
|
4691
|
+
var _a;
|
|
4692
|
+
(_a = this.host.shadowRoot) === null || _a === void 0 ? void 0 : _a.removeEventListener("slotchange", this.handleSlotChange);
|
|
4693
|
+
}
|
|
4694
|
+
handleSlotChange(event) {
|
|
4695
|
+
const slot = event.target;
|
|
4696
|
+
if ((this.slotNames.includes("[default]") && !slot.name) || (slot.name && this.slotNames.includes(slot.name))) {
|
|
4697
|
+
this.host.requestUpdate();
|
|
4698
|
+
}
|
|
4699
|
+
}
|
|
4700
|
+
}
|
|
4701
|
+
|
|
4672
4702
|
var css_248z = css`:host([tinted]) .card-tinted-bg{background-color:var(--sgds-bg-translucent-subtle);opacity:var(--sgds-opacity-50)}slot[name=menu]::slotted(*){position:absolute;right:20px;top:20px;z-index:10}`;
|
|
4673
4703
|
|
|
4674
4704
|
/**
|
|
4675
4705
|
* @summary Cards can be used for headers and footers, a wide variety of content, contain contextual background colors and images.
|
|
4676
4706
|
* @slot default - The content area of the card, placed directly under the title. Accepts any HTML or custom elements.
|
|
4677
4707
|
* @slot menu - Accepts an element for an overflow or contextual menu, positioned at the top-right corner of the card. Typically used for action menus or dropdowns.
|
|
4708
|
+
* @slot upper - Accepts an element to be displayed above the card content. When used, it overrides image and icon slot content.
|
|
4678
4709
|
* @slot image - Accepts an image or svg element of the card. Only a single element is allowed to be passed in.
|
|
4679
4710
|
* @slot icon - Accepts an icon element to visually represent the card. Only a single element is allowed to be passed in.
|
|
4680
4711
|
* @slot subtitle - The subtitle of the card
|
|
@@ -4690,41 +4721,42 @@
|
|
|
4690
4721
|
this.imagePosition = "before";
|
|
4691
4722
|
/** Controls how the image is sized and aligned within the card. Available options: `default`, `padding around`, `aspect ratio` */
|
|
4692
4723
|
this.imageAdjustment = "default";
|
|
4693
|
-
|
|
4694
|
-
firstUpdated() {
|
|
4695
|
-
if (this._imageNode.length === 0) {
|
|
4696
|
-
const icon = this.shadowRoot.querySelector(".card-image");
|
|
4697
|
-
icon.style.display = "none";
|
|
4698
|
-
}
|
|
4699
|
-
if (this._iconNode.length === 0) {
|
|
4700
|
-
const media = this.shadowRoot.querySelector(".card-media");
|
|
4701
|
-
media.style.display = "none";
|
|
4702
|
-
}
|
|
4724
|
+
this.hasSlotController = new HasSlotController(this, "image", "icon", "menu", "description");
|
|
4703
4725
|
}
|
|
4704
4726
|
handleImgSlotChange(e) {
|
|
4705
4727
|
const childNodes = e.target.assignedNodes({ flatten: true });
|
|
4706
4728
|
if (childNodes.length > 1) {
|
|
4707
|
-
|
|
4729
|
+
console.error("Multiple elements passed into SgdsCard's image slot");
|
|
4730
|
+
}
|
|
4731
|
+
if (this.hasSlotController.test("icon") && this.hasSlotController.test("icon")) {
|
|
4732
|
+
console.error("Both image and icon slots cannot be used together in SgdsCard");
|
|
4708
4733
|
}
|
|
4709
4734
|
}
|
|
4710
4735
|
render() {
|
|
4711
4736
|
const tag = this.stretchedLink ? literal `a` : literal `div`;
|
|
4712
4737
|
const cardTabIndex = !this.stretchedLink || this.disabled ? -1 : 0;
|
|
4738
|
+
const hasDescriptionSlot = this.hasSlotController.test("description");
|
|
4739
|
+
const hasImageSlot = this.hasSlotController.test("image");
|
|
4740
|
+
const hasIconSlot = this.hasSlotController.test("icon");
|
|
4741
|
+
const hasMenuSlot = this.hasSlotController.test("menu");
|
|
4742
|
+
const hasUpperSlot = this.hasSlotController.test("upper");
|
|
4713
4743
|
return html `
|
|
4714
|
-
<${tag}
|
|
4744
|
+
<${tag}
|
|
4715
4745
|
class="card ${classMap({
|
|
4716
4746
|
disabled: this.disabled
|
|
4717
4747
|
})}"
|
|
4718
4748
|
tabindex=${cardTabIndex}
|
|
4719
4749
|
>
|
|
4720
4750
|
<div class="card-tinted-bg"></div>
|
|
4721
|
-
|
|
4722
|
-
<
|
|
4723
|
-
|
|
4724
|
-
|
|
4725
|
-
|
|
4726
|
-
<slot name="icon"></slot>
|
|
4751
|
+
|
|
4752
|
+
${hasMenuSlot ? html ` <slot name="menu"></slot> ` : nothing}
|
|
4753
|
+
<div class=${classMap({ "card-image": hasImageSlot, "card-media": hasIconSlot || hasUpperSlot })}>
|
|
4754
|
+
<slot name="upper">
|
|
4755
|
+
${hasImageSlot ? html ` <slot name="image" @slotchange=${this.handleImgSlotChange}></slot> ` : nothing}
|
|
4756
|
+
${hasIconSlot ? html ` <slot name="icon"></slot> ` : nothing}
|
|
4757
|
+
</slot>
|
|
4727
4758
|
</div>
|
|
4759
|
+
|
|
4728
4760
|
<div class="card-body">
|
|
4729
4761
|
<div class="card-header-container">
|
|
4730
4762
|
<div class="card-header">
|
|
@@ -4733,9 +4765,11 @@
|
|
|
4733
4765
|
</div>
|
|
4734
4766
|
<slot></slot>
|
|
4735
4767
|
</div>
|
|
4736
|
-
|
|
4737
|
-
|
|
4738
|
-
|
|
4768
|
+
${hasDescriptionSlot
|
|
4769
|
+
? html `<p class="card-text">
|
|
4770
|
+
<slot name="description"></slot>
|
|
4771
|
+
</p>`
|
|
4772
|
+
: nothing}
|
|
4739
4773
|
<slot name="lower"></slot>
|
|
4740
4774
|
<slot name="link" @slotchange=${this.handleLinkSlotChange}></slot>
|
|
4741
4775
|
</div>
|
|
@@ -4744,12 +4778,6 @@
|
|
|
4744
4778
|
}
|
|
4745
4779
|
}
|
|
4746
4780
|
SgdsCard.styles = [...CardElement.styles, css_248z];
|
|
4747
|
-
__decorate([
|
|
4748
|
-
queryAssignedNodes({ slot: "image", flatten: true })
|
|
4749
|
-
], SgdsCard.prototype, "_imageNode", void 0);
|
|
4750
|
-
__decorate([
|
|
4751
|
-
queryAssignedNodes({ slot: "icon", flatten: true })
|
|
4752
|
-
], SgdsCard.prototype, "_iconNode", void 0);
|
|
4753
4781
|
__decorate([
|
|
4754
4782
|
property({ type: String, reflect: true })
|
|
4755
4783
|
], SgdsCard.prototype, "imagePosition", void 0);
|