@govtechsg/sgds-web-component 3.17.1-rc.0 → 3.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/base/card-element.d.ts +1 -0
- package/base/card-element.js +14 -0
- package/base/card-element.js.map +1 -1
- package/base/card.js +1 -1
- package/components/Breadcrumb/index.umd.min.js +10 -16
- package/components/Breadcrumb/index.umd.min.js.map +1 -1
- package/components/Card/index.umd.min.js +2 -2
- package/components/Card/index.umd.min.js.map +1 -1
- package/components/Card/sgds-card.js +3 -9
- package/components/Card/sgds-card.js.map +1 -1
- package/components/ComboBox/index.umd.min.js +1 -1
- package/components/ComboBox/index.umd.min.js.map +1 -1
- package/components/Datepicker/index.umd.min.js +1 -1
- package/components/Datepicker/index.umd.min.js.map +1 -1
- package/components/Dropdown/dropdown-menu.js +1 -1
- package/components/Dropdown/dropdown.js +1 -1
- package/components/Dropdown/index.umd.min.js +3 -9
- package/components/Dropdown/index.umd.min.js.map +1 -1
- package/components/Dropdown/sgds-dropdown.js +19 -11
- package/components/Dropdown/sgds-dropdown.js.map +1 -1
- package/components/IconCard/index.umd.min.js +3 -3
- package/components/IconCard/index.umd.min.js.map +1 -1
- package/components/IconCard/sgds-icon-card.js +3 -9
- package/components/IconCard/sgds-icon-card.js.map +1 -1
- package/components/ImageCard/index.umd.min.js +2 -2
- package/components/ImageCard/index.umd.min.js.map +1 -1
- package/components/ImageCard/sgds-image-card.js +3 -9
- package/components/ImageCard/sgds-image-card.js.map +1 -1
- package/components/Mainnav/index.umd.min.js +10 -16
- package/components/Mainnav/index.umd.min.js.map +1 -1
- package/components/OverflowMenu/index.umd.min.js +3 -9
- package/components/OverflowMenu/index.umd.min.js.map +1 -1
- package/components/Select/index.umd.min.js +1 -1
- package/components/Select/index.umd.min.js.map +1 -1
- package/components/Stepper/index.d.ts +0 -2
- package/components/Stepper/index.js +0 -2
- package/components/Stepper/index.js.map +1 -1
- package/components/Stepper/index.umd.min.js +23 -47
- package/components/Stepper/index.umd.min.js.map +1 -1
- package/components/Stepper/sgds-stepper.d.ts +2 -23
- package/components/Stepper/sgds-stepper.js +11 -79
- package/components/Stepper/sgds-stepper.js.map +1 -1
- package/components/Stepper/stepper.js +1 -1
- package/components/Stepper/types.d.ts +0 -1
- package/components/ThumbnailCard/index.umd.min.js +5 -5
- package/components/ThumbnailCard/index.umd.min.js.map +1 -1
- package/components/ThumbnailCard/sgds-thumbnail-card.js +6 -9
- package/components/ThumbnailCard/sgds-thumbnail-card.js.map +1 -1
- package/components/index.umd.min.js +9 -17
- package/components/index.umd.min.js.map +1 -1
- package/css/fouc.css +0 -1
- package/custom-elements.json +99 -201
- package/index.umd.min.js +43 -73
- package/index.umd.min.js.map +1 -1
- package/package.json +1 -1
- package/react/base/card-element.cjs.js +14 -0
- package/react/base/card-element.cjs.js.map +1 -1
- package/react/base/card-element.js +14 -0
- 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/components/Card/sgds-card.cjs.js +3 -9
- package/react/components/Card/sgds-card.cjs.js.map +1 -1
- package/react/components/Card/sgds-card.js +3 -9
- package/react/components/Card/sgds-card.js.map +1 -1
- package/react/components/Dropdown/dropdown-menu.cjs.js +1 -1
- package/react/components/Dropdown/dropdown-menu.js +1 -1
- package/react/components/Dropdown/dropdown.cjs.js +1 -1
- package/react/components/Dropdown/dropdown.js +1 -1
- package/react/components/Dropdown/sgds-dropdown.cjs.js +19 -11
- package/react/components/Dropdown/sgds-dropdown.cjs.js.map +1 -1
- package/react/components/Dropdown/sgds-dropdown.js +19 -11
- package/react/components/Dropdown/sgds-dropdown.js.map +1 -1
- package/react/components/IconCard/sgds-icon-card.cjs.js +3 -9
- package/react/components/IconCard/sgds-icon-card.cjs.js.map +1 -1
- package/react/components/IconCard/sgds-icon-card.js +3 -9
- package/react/components/IconCard/sgds-icon-card.js.map +1 -1
- package/react/components/ImageCard/sgds-image-card.cjs.js +3 -9
- package/react/components/ImageCard/sgds-image-card.cjs.js.map +1 -1
- package/react/components/ImageCard/sgds-image-card.js +3 -9
- package/react/components/ImageCard/sgds-image-card.js.map +1 -1
- package/react/components/Stepper/sgds-stepper.cjs.js +10 -78
- package/react/components/Stepper/sgds-stepper.cjs.js.map +1 -1
- package/react/components/Stepper/sgds-stepper.js +11 -79
- package/react/components/Stepper/sgds-stepper.js.map +1 -1
- package/react/components/Stepper/stepper.cjs.js +1 -1
- package/react/components/Stepper/stepper.js +1 -1
- package/react/components/ThumbnailCard/sgds-thumbnail-card.cjs.js +6 -9
- package/react/components/ThumbnailCard/sgds-thumbnail-card.cjs.js.map +1 -1
- package/react/components/ThumbnailCard/sgds-thumbnail-card.js +6 -9
- package/react/components/ThumbnailCard/sgds-thumbnail-card.js.map +1 -1
- package/react/index.cjs.js +38 -40
- package/react/index.cjs.js.map +1 -1
- package/react/index.d.ts +0 -1
- package/react/index.js +0 -1
- package/react/index.js.map +1 -1
- package/types/react.d.ts +3 -18
- package/components/Stepper/sgds-step.d.ts +0 -42
- package/components/Stepper/sgds-step.js +0 -118
- package/components/Stepper/sgds-step.js.map +0 -1
- package/components/Stepper/step.js +0 -6
- package/components/Stepper/step.js.map +0 -1
- package/react/components/Stepper/sgds-step.cjs.js +0 -124
- package/react/components/Stepper/sgds-step.cjs.js.map +0 -1
- package/react/components/Stepper/sgds-step.js +0 -119
- package/react/components/Stepper/sgds-step.js.map +0 -1
- package/react/components/Stepper/step.cjs.js +0 -11
- package/react/components/Stepper/step.cjs.js.map +0 -1
- package/react/components/Stepper/step.js +0 -7
- package/react/components/Stepper/step.js.map +0 -1
- package/react/step/index.cjs.js +0 -40
- package/react/step/index.cjs.js.map +0 -1
- package/react/step/index.d.ts +0 -2
- package/react/step/index.js +0 -16
- package/react/step/index.js.map +0 -1
package/package.json
CHANGED
|
@@ -36,6 +36,20 @@ class CardElement extends sgdsElement["default"] {
|
|
|
36
36
|
}
|
|
37
37
|
return;
|
|
38
38
|
}
|
|
39
|
+
_forwardAnchorAttributes(anchor) {
|
|
40
|
+
const SKIP = new Set(["class", "style", "id"]);
|
|
41
|
+
if (!(anchor === null || anchor === void 0 ? void 0 : anchor.href) ||
|
|
42
|
+
anchor.href.startsWith("javascript:") ||
|
|
43
|
+
anchor.href.startsWith("data:") ||
|
|
44
|
+
anchor.href.startsWith("vbscript:")) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
for (const { name, value } of Array.from(anchor.attributes)) {
|
|
48
|
+
if (!SKIP.has(name) && !name.startsWith("on")) {
|
|
49
|
+
this.card.setAttribute(name, value);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
39
53
|
warnLinkSlotMisused(e) {
|
|
40
54
|
const childNodes = e.target.assignedNodes({ flatten: true });
|
|
41
55
|
if (childNodes.length > 1) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"card-element.cjs.js","sources":["../../../src/base/card-element.ts"],"sourcesContent":["import { property, query } from \"lit/decorators.js\";\nimport { SgdsLink } from \"../components/Link/sgds-link\";\nimport { CardOrientation } from \"../components/Card/types\";\nimport SgdsElement from \"./sgds-element\";\nimport cardStyle from \"./card.css\";\nimport textStyles from \"../styles/text-variants.css\";\nimport bgStyles from \"../styles/bg-variants.css\";\nimport borderStyles from \"../styles/border-variants.css\";\nimport headerStyles from \"../styles/header-class.css\";\nimport paragraphStyles from \"../styles/paragraph.css\";\n\nexport class CardElement extends SgdsElement {\n static styles = [...SgdsElement.styles, textStyles, bgStyles, borderStyles, headerStyles, paragraphStyles, cardStyle];\n\n /** @internal */\n @query(\"a.card\") card: HTMLAnchorElement;\n\n /** Extends the link passed in either `footer` or `link`(deprecated) slot.\n */\n @property({ type: Boolean, reflect: true }) stretchedLink = false;\n\n /** Disables the card */\n @property({ type: Boolean, reflect: true }) disabled = false;\n\n /** When true, hides the default border of the card. */\n @property({ type: Boolean, reflect: true }) hideBorder = false;\n\n /** When true, applies a tinted background color to the card. */\n @property({ type: Boolean, reflect: true }) tinted = false;\n\n /** Sets the orientation of the card. Available options: `vertical`, `horizontal` */\n @property({ type: String, reflect: true }) orientation: CardOrientation = \"vertical\";\n\n handleTitleSlotChange(e: Event) {\n const childNodes = (e.target as HTMLSlotElement).assignedNodes({ flatten: true }) as Array<HTMLElement>;\n\n if (this.stretchedLink && childNodes[0] instanceof HTMLAnchorElement) {\n const hyperlink = childNodes[0].querySelector(\"a\") || childNodes[0];\n hyperlink.removeAttribute(\"href\");\n }\n return;\n }\n\n warnLinkSlotMisused(e: Event) {\n const childNodes = (e.target as HTMLSlotElement).assignedNodes({ flatten: true }) as\n | Array<HTMLLinkElement>\n | Array<HTMLAnchorElement>\n | Array<SgdsLink>;\n\n if (childNodes.length > 1) {\n return console.error(\"Multiple elements passed into SgdsCard's link slot\");\n }\n }\n}\n"],"names":["SgdsElement","textStyles","bgStyles","borderStyles","headerStyles","paragraphStyles","cardStyle","__decorate","query","property"],"mappings":";;;;;;;;;;;;;;;AAWM,MAAO,WAAY,SAAQA,sBAAW,CAAA;AAA5C,IAAA,WAAA,GAAA;;AAME;AACG;QACyC,IAAa,CAAA,aAAA,GAAG,KAAK,CAAC;;QAGtB,IAAQ,CAAA,QAAA,GAAG,KAAK,CAAC;;QAGjB,IAAU,CAAA,UAAA,GAAG,KAAK,CAAC;;QAGnB,IAAM,CAAA,MAAA,GAAG,KAAK,CAAC;;QAGhB,IAAW,CAAA,WAAA,GAAoB,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"card-element.cjs.js","sources":["../../../src/base/card-element.ts"],"sourcesContent":["import { property, query } from \"lit/decorators.js\";\nimport { SgdsLink } from \"../components/Link/sgds-link\";\nimport { CardOrientation } from \"../components/Card/types\";\nimport SgdsElement from \"./sgds-element\";\nimport cardStyle from \"./card.css\";\nimport textStyles from \"../styles/text-variants.css\";\nimport bgStyles from \"../styles/bg-variants.css\";\nimport borderStyles from \"../styles/border-variants.css\";\nimport headerStyles from \"../styles/header-class.css\";\nimport paragraphStyles from \"../styles/paragraph.css\";\n\nexport class CardElement extends SgdsElement {\n static styles = [...SgdsElement.styles, textStyles, bgStyles, borderStyles, headerStyles, paragraphStyles, cardStyle];\n\n /** @internal */\n @query(\"a.card\") card: HTMLAnchorElement;\n\n /** Extends the link passed in either `footer` or `link`(deprecated) slot.\n */\n @property({ type: Boolean, reflect: true }) stretchedLink = false;\n\n /** Disables the card */\n @property({ type: Boolean, reflect: true }) disabled = false;\n\n /** When true, hides the default border of the card. */\n @property({ type: Boolean, reflect: true }) hideBorder = false;\n\n /** When true, applies a tinted background color to the card. */\n @property({ type: Boolean, reflect: true }) tinted = false;\n\n /** Sets the orientation of the card. Available options: `vertical`, `horizontal` */\n @property({ type: String, reflect: true }) orientation: CardOrientation = \"vertical\";\n\n handleTitleSlotChange(e: Event) {\n const childNodes = (e.target as HTMLSlotElement).assignedNodes({ flatten: true }) as Array<HTMLElement>;\n\n if (this.stretchedLink && childNodes[0] instanceof HTMLAnchorElement) {\n const hyperlink = childNodes[0].querySelector(\"a\") || childNodes[0];\n hyperlink.removeAttribute(\"href\");\n }\n return;\n }\n\n protected _forwardAnchorAttributes(anchor: HTMLAnchorElement | null) {\n const SKIP = new Set([\"class\", \"style\", \"id\"]);\n if (\n !anchor?.href ||\n anchor.href.startsWith(\"javascript:\") ||\n anchor.href.startsWith(\"data:\") ||\n anchor.href.startsWith(\"vbscript:\")\n ) {\n return;\n }\n\n for (const { name, value } of Array.from(anchor.attributes)) {\n if (!SKIP.has(name) && !name.startsWith(\"on\")) {\n this.card.setAttribute(name, value);\n }\n }\n }\n\n warnLinkSlotMisused(e: Event) {\n const childNodes = (e.target as HTMLSlotElement).assignedNodes({ flatten: true }) as\n | Array<HTMLLinkElement>\n | Array<HTMLAnchorElement>\n | Array<SgdsLink>;\n\n if (childNodes.length > 1) {\n return console.error(\"Multiple elements passed into SgdsCard's link slot\");\n }\n }\n}\n"],"names":["SgdsElement","textStyles","bgStyles","borderStyles","headerStyles","paragraphStyles","cardStyle","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KAAA,CAAA,CAAA,CAAA;AAGjBF,gBAAA,CAAA;IAA3CE,sBAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAAoB,CAAA,EAAA,WAAA,CAAA,SAAA,EAAA,YAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAGnBF,gBAAA,CAAA;IAA3CE,sBAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAAgB,CAAA,EAAA,WAAA,CAAA,SAAA,EAAA,QAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAGhBF,gBAAA,CAAA;IAA1CE,sBAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAA2C,CAAA,EAAA,WAAA,CAAA,SAAA,EAAA,aAAA,EAAA,KAAA,CAAA,CAAA;;;;"}
|
|
@@ -32,6 +32,20 @@ class CardElement extends SgdsElement {
|
|
|
32
32
|
}
|
|
33
33
|
return;
|
|
34
34
|
}
|
|
35
|
+
_forwardAnchorAttributes(anchor) {
|
|
36
|
+
const SKIP = new Set(["class", "style", "id"]);
|
|
37
|
+
if (!(anchor === null || anchor === void 0 ? void 0 : anchor.href) ||
|
|
38
|
+
anchor.href.startsWith("javascript:") ||
|
|
39
|
+
anchor.href.startsWith("data:") ||
|
|
40
|
+
anchor.href.startsWith("vbscript:")) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
for (const { name, value } of Array.from(anchor.attributes)) {
|
|
44
|
+
if (!SKIP.has(name) && !name.startsWith("on")) {
|
|
45
|
+
this.card.setAttribute(name, value);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
35
49
|
warnLinkSlotMisused(e) {
|
|
36
50
|
const childNodes = e.target.assignedNodes({ flatten: true });
|
|
37
51
|
if (childNodes.length > 1) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"card-element.js","sources":["../../../src/base/card-element.ts"],"sourcesContent":["import { property, query } from \"lit/decorators.js\";\nimport { SgdsLink } from \"../components/Link/sgds-link\";\nimport { CardOrientation } from \"../components/Card/types\";\nimport SgdsElement from \"./sgds-element\";\nimport cardStyle from \"./card.css\";\nimport textStyles from \"../styles/text-variants.css\";\nimport bgStyles from \"../styles/bg-variants.css\";\nimport borderStyles from \"../styles/border-variants.css\";\nimport headerStyles from \"../styles/header-class.css\";\nimport paragraphStyles from \"../styles/paragraph.css\";\n\nexport class CardElement extends SgdsElement {\n static styles = [...SgdsElement.styles, textStyles, bgStyles, borderStyles, headerStyles, paragraphStyles, cardStyle];\n\n /** @internal */\n @query(\"a.card\") card: HTMLAnchorElement;\n\n /** Extends the link passed in either `footer` or `link`(deprecated) slot.\n */\n @property({ type: Boolean, reflect: true }) stretchedLink = false;\n\n /** Disables the card */\n @property({ type: Boolean, reflect: true }) disabled = false;\n\n /** When true, hides the default border of the card. */\n @property({ type: Boolean, reflect: true }) hideBorder = false;\n\n /** When true, applies a tinted background color to the card. */\n @property({ type: Boolean, reflect: true }) tinted = false;\n\n /** Sets the orientation of the card. Available options: `vertical`, `horizontal` */\n @property({ type: String, reflect: true }) orientation: CardOrientation = \"vertical\";\n\n handleTitleSlotChange(e: Event) {\n const childNodes = (e.target as HTMLSlotElement).assignedNodes({ flatten: true }) as Array<HTMLElement>;\n\n if (this.stretchedLink && childNodes[0] instanceof HTMLAnchorElement) {\n const hyperlink = childNodes[0].querySelector(\"a\") || childNodes[0];\n hyperlink.removeAttribute(\"href\");\n }\n return;\n }\n\n warnLinkSlotMisused(e: Event) {\n const childNodes = (e.target as HTMLSlotElement).assignedNodes({ flatten: true }) as\n | Array<HTMLLinkElement>\n | Array<HTMLAnchorElement>\n | Array<SgdsLink>;\n\n if (childNodes.length > 1) {\n return console.error(\"Multiple elements passed into SgdsCard's link slot\");\n }\n }\n}\n"],"names":["textStyles","bgStyles","borderStyles","headerStyles","paragraphStyles","cardStyle"],"mappings":";;;;;;;;;;;AAWM,MAAO,WAAY,SAAQ,WAAW,CAAA;AAA5C,IAAA,WAAA,GAAA;;AAME;AACG;QACyC,IAAa,CAAA,aAAA,GAAG,KAAK,CAAC;;QAGtB,IAAQ,CAAA,QAAA,GAAG,KAAK,CAAC;;QAGjB,IAAU,CAAA,UAAA,GAAG,KAAK,CAAC;;QAGnB,IAAM,CAAA,MAAA,GAAG,KAAK,CAAC;;QAGhB,IAAW,CAAA,WAAA,GAAoB,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"card-element.js","sources":["../../../src/base/card-element.ts"],"sourcesContent":["import { property, query } from \"lit/decorators.js\";\nimport { SgdsLink } from \"../components/Link/sgds-link\";\nimport { CardOrientation } from \"../components/Card/types\";\nimport SgdsElement from \"./sgds-element\";\nimport cardStyle from \"./card.css\";\nimport textStyles from \"../styles/text-variants.css\";\nimport bgStyles from \"../styles/bg-variants.css\";\nimport borderStyles from \"../styles/border-variants.css\";\nimport headerStyles from \"../styles/header-class.css\";\nimport paragraphStyles from \"../styles/paragraph.css\";\n\nexport class CardElement extends SgdsElement {\n static styles = [...SgdsElement.styles, textStyles, bgStyles, borderStyles, headerStyles, paragraphStyles, cardStyle];\n\n /** @internal */\n @query(\"a.card\") card: HTMLAnchorElement;\n\n /** Extends the link passed in either `footer` or `link`(deprecated) slot.\n */\n @property({ type: Boolean, reflect: true }) stretchedLink = false;\n\n /** Disables the card */\n @property({ type: Boolean, reflect: true }) disabled = false;\n\n /** When true, hides the default border of the card. */\n @property({ type: Boolean, reflect: true }) hideBorder = false;\n\n /** When true, applies a tinted background color to the card. */\n @property({ type: Boolean, reflect: true }) tinted = false;\n\n /** Sets the orientation of the card. Available options: `vertical`, `horizontal` */\n @property({ type: String, reflect: true }) orientation: CardOrientation = \"vertical\";\n\n handleTitleSlotChange(e: Event) {\n const childNodes = (e.target as HTMLSlotElement).assignedNodes({ flatten: true }) as Array<HTMLElement>;\n\n if (this.stretchedLink && childNodes[0] instanceof HTMLAnchorElement) {\n const hyperlink = childNodes[0].querySelector(\"a\") || childNodes[0];\n hyperlink.removeAttribute(\"href\");\n }\n return;\n }\n\n protected _forwardAnchorAttributes(anchor: HTMLAnchorElement | null) {\n const SKIP = new Set([\"class\", \"style\", \"id\"]);\n if (\n !anchor?.href ||\n anchor.href.startsWith(\"javascript:\") ||\n anchor.href.startsWith(\"data:\") ||\n anchor.href.startsWith(\"vbscript:\")\n ) {\n return;\n }\n\n for (const { name, value } of Array.from(anchor.attributes)) {\n if (!SKIP.has(name) && !name.startsWith(\"on\")) {\n this.card.setAttribute(name, value);\n }\n }\n }\n\n warnLinkSlotMisused(e: Event) {\n const childNodes = (e.target as HTMLSlotElement).assignedNodes({ flatten: true }) as\n | Array<HTMLLinkElement>\n | Array<HTMLAnchorElement>\n | Array<SgdsLink>;\n\n if (childNodes.length > 1) {\n return console.error(\"Multiple elements passed into SgdsCard's link slot\");\n }\n }\n}\n"],"names":["textStyles","bgStyles","borderStyles","headerStyles","paragraphStyles","cardStyle"],"mappings":";;;;;;;;;;;AAWM,MAAO,WAAY,SAAQ,WAAW,CAAA;AAA5C,IAAA,WAAA,GAAA;;AAME;AACG;QACyC,IAAa,CAAA,aAAA,GAAG,KAAK,CAAC;;QAGtB,IAAQ,CAAA,QAAA,GAAG,KAAK,CAAC;;QAGjB,IAAU,CAAA,UAAA,GAAG,KAAK,CAAC;;QAGnB,IAAM,CAAA,MAAA,GAAG,KAAK,CAAC;;QAGhB,IAAW,CAAA,WAAA,GAAoB,UAAU,CAAC;KAwCtF;AAtCC,IAAA,qBAAqB,CAAC,CAAQ,EAAA;AAC5B,QAAA,MAAM,UAAU,GAAI,CAAC,CAAC,MAA0B,CAAC,aAAa,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAuB,CAAC;QAExG,IAAI,IAAI,CAAC,aAAa,IAAI,UAAU,CAAC,CAAC,CAAC,YAAY,iBAAiB,EAAE;AACpE,YAAA,MAAM,SAAS,GAAG,UAAU,CAAC,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|
|
|
5
5
|
|
|
6
6
|
var lit = require('lit');
|
|
7
7
|
|
|
8
|
-
var css_248z = lit.css`:host([disabled]){cursor:not-allowed}:host(:not([noPadding])) .card:not(.disabled):hover{box-shadow:0 0 1px 0 hsla(0,0%,5%,.12),0 8px 16px 0 hsla(0,0%,5%,.12)}:host([stretchedLink]) slot[name=footer]::slotted(a),:host([stretchedLink]) slot[name=footer]::slotted(sgds-link),:host([stretchedLink]) slot[name=link]::slotted(a),:host([stretchedLink]) slot[name=link]::slotted(sgds-link){display:none}: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-xl) var(--sgds-margin-xl) var(--sgds-padding-none)}:host([orientation=vertical][imageAdjustment="padding around"][imagePosition=after]) .card-image{margin:var(--sgds-margin-none) var(--sgds-margin-xl) var(--sgds-margin-xl)}:host([orientation=horizontal][imageAdjustment="padding around"]) .card-image{margin:var(--sgds-margin-xl) var(--sgds-margin-none) var(--sgds-margin-xl) var(--sgds-margin-xl)}:host([orientation=horizontal][imageAdjustment="padding around"][imagePosition=after]) .card-image{margin:var(--sgds-margin-xl) var(--sgds-margin-xl) var(--sgds-margin-xl) 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:not(.disabled):focus-visible{--sgds-outline-offset-focus:-1px;outline:var(--sgds-outline-focus);outline-offset:var(--sgds-outline-offset-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-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,slot[name=title]::slotted(*){color:var(--sgds-body-color-default);font-size:var(--sgds-font-size-24)!important;font-weight:var(--sgds-font-weight-semibold)!important;margin-bottom:var(--sgds-margin-none)!important}slot[name=subtitle]::slotted(*){color:var(--sgds-color-subtle);font-size:var(--sgds-font-size-14)!important;font-weight:var(--sgds-font-weight-semibold)!important;letter-spacing:var(--sgds-letter-spacing-wide)!important;line-height:var(--sgds-line-height-20)!important;margin:var(--sgds-margin-none)!important;text-transform:uppercase}slot[name=title]::slotted(a){color:var(--sgds-link-color-default);font-size:var(--sgds-font-size-24)!important;font-weight:var(--sgds-font-weight-semibold)!important;margin-bottom:var(--sgds-margin-none)!important;text-decoration:none!important}slot[name=description]::slotted(*){--sgds-paragraph-spacing-xl:var(--sgds-margin-none);color:var(--sgds-color-subtle);margin-bottom:var(--sgds-paragraph-spacing-xl,--sgds-margin-none)}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=footer]::slotted(*),slot[name=link]::slotted(*){margin-top:auto;padding-top:var(--sgds-padding-sm);width:fit-content}slot[name=footer]::slotted(a),slot[name=link]::slotted(a){color:var(--sgds-link-color-default);height:auto!important;text-decoration:none!important}slot[name=footer]::slotted(a:focus),slot[name=footer]::slotted(a:hover),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=footer]::slotted(a:focus-visible),slot[name=link]::slotted(a:focus-visible),slot[name=title]::slotted(a:focus-visible){outline:var(--sgds-outline-focus);outline-offset:var(--sgds-outline-offset-focus)}`;
|
|
8
|
+
var css_248z = lit.css`:host([disabled]){cursor:not-allowed}:host(:not([noPadding])) .card:not(.disabled):hover{box-shadow:0 0 1px 0 hsla(0,0%,5%,.12),0 8px 16px 0 hsla(0,0%,5%,.12)}:host([stretchedLink]) slot[name=footer]::slotted(a),:host([stretchedLink]) slot[name=footer]::slotted(sgds-link),:host([stretchedLink]) slot[name=link]::slotted(a),:host([stretchedLink]) slot[name=link]::slotted(sgds-link){display:none}:host([stretchedLink]) .card:after{display:none}: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-xl) var(--sgds-margin-xl) var(--sgds-padding-none)}:host([orientation=vertical][imageAdjustment="padding around"][imagePosition=after]) .card-image{margin:var(--sgds-margin-none) var(--sgds-margin-xl) var(--sgds-margin-xl)}:host([orientation=horizontal][imageAdjustment="padding around"]) .card-image{margin:var(--sgds-margin-xl) var(--sgds-margin-none) var(--sgds-margin-xl) var(--sgds-margin-xl)}:host([orientation=horizontal][imageAdjustment="padding around"][imagePosition=after]) .card-image{margin:var(--sgds-margin-xl) var(--sgds-margin-xl) var(--sgds-margin-xl) 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:not(.disabled):focus-visible{--sgds-outline-offset-focus:-1px;outline:var(--sgds-outline-focus);outline-offset:var(--sgds-outline-offset-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-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,slot[name=title]::slotted(*){color:var(--sgds-body-color-default);font-size:var(--sgds-font-size-24)!important;font-weight:var(--sgds-font-weight-semibold)!important;margin-bottom:var(--sgds-margin-none)!important}slot[name=subtitle]::slotted(*){color:var(--sgds-color-subtle);font-size:var(--sgds-font-size-14)!important;font-weight:var(--sgds-font-weight-semibold)!important;letter-spacing:var(--sgds-letter-spacing-wide)!important;line-height:var(--sgds-line-height-20)!important;margin:var(--sgds-margin-none)!important;text-transform:uppercase}slot[name=title]::slotted(a){color:var(--sgds-link-color-default);font-size:var(--sgds-font-size-24)!important;font-weight:var(--sgds-font-weight-semibold)!important;margin-bottom:var(--sgds-margin-none)!important;text-decoration:none!important}slot[name=description]::slotted(*){--sgds-paragraph-spacing-xl:var(--sgds-margin-none);color:var(--sgds-color-subtle);margin-bottom:var(--sgds-paragraph-spacing-xl,--sgds-margin-none)}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=footer]::slotted(*),slot[name=link]::slotted(*){margin-top:auto;padding-top:var(--sgds-padding-sm);width:fit-content}slot[name=footer]::slotted(a),slot[name=link]::slotted(a){color:var(--sgds-link-color-default);height:auto!important;text-decoration:none!important}slot[name=footer]::slotted(a:focus),slot[name=footer]::slotted(a:hover),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=footer]::slotted(a:focus-visible),slot[name=link]::slotted(a:focus-visible),slot[name=title]::slotted(a:focus-visible){outline:var(--sgds-outline-focus);outline-offset:var(--sgds-outline-offset-focus)}`;
|
|
9
9
|
|
|
10
10
|
exports["default"] = css_248z;
|
|
11
11
|
//# sourceMappingURL=card.cjs.js.map
|
package/react/base/card.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { css } from 'lit';
|
|
3
3
|
|
|
4
|
-
var css_248z = css`:host([disabled]){cursor:not-allowed}:host(:not([noPadding])) .card:not(.disabled):hover{box-shadow:0 0 1px 0 hsla(0,0%,5%,.12),0 8px 16px 0 hsla(0,0%,5%,.12)}:host([stretchedLink]) slot[name=footer]::slotted(a),:host([stretchedLink]) slot[name=footer]::slotted(sgds-link),:host([stretchedLink]) slot[name=link]::slotted(a),:host([stretchedLink]) slot[name=link]::slotted(sgds-link){display:none}: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-xl) var(--sgds-margin-xl) var(--sgds-padding-none)}:host([orientation=vertical][imageAdjustment="padding around"][imagePosition=after]) .card-image{margin:var(--sgds-margin-none) var(--sgds-margin-xl) var(--sgds-margin-xl)}:host([orientation=horizontal][imageAdjustment="padding around"]) .card-image{margin:var(--sgds-margin-xl) var(--sgds-margin-none) var(--sgds-margin-xl) var(--sgds-margin-xl)}:host([orientation=horizontal][imageAdjustment="padding around"][imagePosition=after]) .card-image{margin:var(--sgds-margin-xl) var(--sgds-margin-xl) var(--sgds-margin-xl) 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:not(.disabled):focus-visible{--sgds-outline-offset-focus:-1px;outline:var(--sgds-outline-focus);outline-offset:var(--sgds-outline-offset-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-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,slot[name=title]::slotted(*){color:var(--sgds-body-color-default);font-size:var(--sgds-font-size-24)!important;font-weight:var(--sgds-font-weight-semibold)!important;margin-bottom:var(--sgds-margin-none)!important}slot[name=subtitle]::slotted(*){color:var(--sgds-color-subtle);font-size:var(--sgds-font-size-14)!important;font-weight:var(--sgds-font-weight-semibold)!important;letter-spacing:var(--sgds-letter-spacing-wide)!important;line-height:var(--sgds-line-height-20)!important;margin:var(--sgds-margin-none)!important;text-transform:uppercase}slot[name=title]::slotted(a){color:var(--sgds-link-color-default);font-size:var(--sgds-font-size-24)!important;font-weight:var(--sgds-font-weight-semibold)!important;margin-bottom:var(--sgds-margin-none)!important;text-decoration:none!important}slot[name=description]::slotted(*){--sgds-paragraph-spacing-xl:var(--sgds-margin-none);color:var(--sgds-color-subtle);margin-bottom:var(--sgds-paragraph-spacing-xl,--sgds-margin-none)}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=footer]::slotted(*),slot[name=link]::slotted(*){margin-top:auto;padding-top:var(--sgds-padding-sm);width:fit-content}slot[name=footer]::slotted(a),slot[name=link]::slotted(a){color:var(--sgds-link-color-default);height:auto!important;text-decoration:none!important}slot[name=footer]::slotted(a:focus),slot[name=footer]::slotted(a:hover),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=footer]::slotted(a:focus-visible),slot[name=link]::slotted(a:focus-visible),slot[name=title]::slotted(a:focus-visible){outline:var(--sgds-outline-focus);outline-offset:var(--sgds-outline-offset-focus)}`;
|
|
4
|
+
var css_248z = css`:host([disabled]){cursor:not-allowed}:host(:not([noPadding])) .card:not(.disabled):hover{box-shadow:0 0 1px 0 hsla(0,0%,5%,.12),0 8px 16px 0 hsla(0,0%,5%,.12)}:host([stretchedLink]) slot[name=footer]::slotted(a),:host([stretchedLink]) slot[name=footer]::slotted(sgds-link),:host([stretchedLink]) slot[name=link]::slotted(a),:host([stretchedLink]) slot[name=link]::slotted(sgds-link){display:none}:host([stretchedLink]) .card:after{display:none}: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-xl) var(--sgds-margin-xl) var(--sgds-padding-none)}:host([orientation=vertical][imageAdjustment="padding around"][imagePosition=after]) .card-image{margin:var(--sgds-margin-none) var(--sgds-margin-xl) var(--sgds-margin-xl)}:host([orientation=horizontal][imageAdjustment="padding around"]) .card-image{margin:var(--sgds-margin-xl) var(--sgds-margin-none) var(--sgds-margin-xl) var(--sgds-margin-xl)}:host([orientation=horizontal][imageAdjustment="padding around"][imagePosition=after]) .card-image{margin:var(--sgds-margin-xl) var(--sgds-margin-xl) var(--sgds-margin-xl) 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:not(.disabled):focus-visible{--sgds-outline-offset-focus:-1px;outline:var(--sgds-outline-focus);outline-offset:var(--sgds-outline-offset-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-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,slot[name=title]::slotted(*){color:var(--sgds-body-color-default);font-size:var(--sgds-font-size-24)!important;font-weight:var(--sgds-font-weight-semibold)!important;margin-bottom:var(--sgds-margin-none)!important}slot[name=subtitle]::slotted(*){color:var(--sgds-color-subtle);font-size:var(--sgds-font-size-14)!important;font-weight:var(--sgds-font-weight-semibold)!important;letter-spacing:var(--sgds-letter-spacing-wide)!important;line-height:var(--sgds-line-height-20)!important;margin:var(--sgds-margin-none)!important;text-transform:uppercase}slot[name=title]::slotted(a){color:var(--sgds-link-color-default);font-size:var(--sgds-font-size-24)!important;font-weight:var(--sgds-font-weight-semibold)!important;margin-bottom:var(--sgds-margin-none)!important;text-decoration:none!important}slot[name=description]::slotted(*){--sgds-paragraph-spacing-xl:var(--sgds-margin-none);color:var(--sgds-color-subtle);margin-bottom:var(--sgds-paragraph-spacing-xl,--sgds-margin-none)}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=footer]::slotted(*),slot[name=link]::slotted(*){margin-top:auto;padding-top:var(--sgds-padding-sm);width:fit-content}slot[name=footer]::slotted(a),slot[name=link]::slotted(a){color:var(--sgds-link-color-default);height:auto!important;text-decoration:none!important}slot[name=footer]::slotted(a:focus),slot[name=footer]::slotted(a:hover),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=footer]::slotted(a:focus-visible),slot[name=link]::slotted(a:focus-visible),slot[name=title]::slotted(a:focus-visible){outline:var(--sgds-outline-focus);outline-offset:var(--sgds-outline-offset-focus)}`;
|
|
5
5
|
|
|
6
6
|
export { css_248z as default };
|
|
7
7
|
//# sourceMappingURL=card.js.map
|
|
@@ -54,17 +54,11 @@ class SgdsCard extends cardElement.CardElement {
|
|
|
54
54
|
return (element.querySelector("a") || element);
|
|
55
55
|
}
|
|
56
56
|
firstUpdated(changedProperties) {
|
|
57
|
-
var _a, _b;
|
|
58
57
|
super.firstUpdated(changedProperties);
|
|
59
58
|
if (this.stretchedLink) {
|
|
60
|
-
const
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
this.card.setAttribute("href", footerHref);
|
|
64
|
-
}
|
|
65
|
-
else if (linkHref) {
|
|
66
|
-
this.card.setAttribute("href", linkHref);
|
|
67
|
-
}
|
|
59
|
+
const footerAnchor = this.footerSlotItems;
|
|
60
|
+
const linkAnchor = this.linkSlotItems;
|
|
61
|
+
this._forwardAnchorAttributes((footerAnchor === null || footerAnchor === void 0 ? void 0 : footerAnchor.href) ? footerAnchor : linkAnchor);
|
|
68
62
|
}
|
|
69
63
|
}
|
|
70
64
|
updated() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sgds-card.cjs.js","sources":["../../../../src/components/Card/sgds-card.ts"],"sourcesContent":["import { PropertyValueMap } from \"lit\";\nimport { property, queryAssignedElements } from \"lit/decorators.js\";\nimport { classMap } from \"lit/directives/class-map.js\";\nimport { html, literal } from \"lit/static-html.js\";\nimport { CardElement } from \"../../base/card-element\";\nimport { HasSlotController } from \"../../utils/slot\";\nimport { CardImageAdjustment, CardImagePosition } from \"./types\";\nimport type SgdsLink from \"../Link/sgds-link\";\nimport cardStyle from \"./card.css\";\n\n/**\n * @summary 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 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.\n * @slot upper - Accepts an element to be displayed above the card content. When used, it overrides image and icon slot content.\n * @slot image - Accepts an image or svg element of the card. Only a single element is allowed to be passed in.\n * @slot icon - Accepts an icon element to visually represent the card. Only a single element is allowed to be passed in.\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 SgdsCard extends CardElement {\n static styles = [...CardElement.styles, cardStyle];\n\n @queryAssignedElements({ slot: \"footer\" })\n private footerNode!: HTMLElement[];\n @queryAssignedElements({ slot: \"link\" })\n private linkNode!: HTMLAnchorElement[] | SgdsLink[];\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 /** Used only for SSR to indicate the presence of the `image` slot. */\n @property({ type: Boolean }) hasImageSlot = false;\n\n /** Used only for SSR to indicate the presence of the `icon` slot. */\n @property({ type: Boolean }) hasIconSlot = false;\n\n /** Used only for SSR to indicate the presence of the `upper` slot. */\n @property({ type: Boolean }) hasUpperSlot = 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 private readonly hasSlotController = new HasSlotController(this, \"image\", \"icon\", \"upper\");\n\n protected firstUpdated(changedProperties: PropertyValueMap<this>) {\n super.firstUpdated(changedProperties);\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 updated() {\n if (!this.hasImageSlot) this.hasImageSlot = this.hasSlotController.test(\"image\");\n if (!this.hasIconSlot) this.hasIconSlot = this.hasSlotController.test(\"icon\");\n if (!this.hasUpperSlot) this.hasUpperSlot = this.hasSlotController.test(\"upper\");\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 console.error(\"Multiple elements passed into SgdsCard's image slot\");\n }\n\n if (this.hasSlotController.test(\"image\") && this.hasSlotController.test(\"icon\")) {\n console.error(\"Both image and icon slots cannot be used together in SgdsCard\");\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 <div class=\"card-tinted-bg\"></div>\n \n <slot name=\"menu\"></slot>\n <div class=${classMap({\n \"card-image\": this.hasImageSlot,\n \"card-media\": this.hasIconSlot || this.hasUpperSlot\n })}>\n <slot name=\"upper\">\n <slot name=\"image\" @slotchange=${this.handleImgSlotChange}></slot>\n <slot name=\"icon\"></slot>\n </slot>\n </div>\n\n <div class=\"card-body\">\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.warnLinkSlotMisused}></slot>\n </slot>\n </div>\n </${tag}>\n `;\n }\n}\n\nexport default SgdsCard;\n"],"names":["CardElement","HasSlotController","literal","html","classMap","cardStyle","__decorate","queryAssignedElements","property"],"mappings":";;;;;;;;;;;;;AAUA;;;;;;;;;;;;;;AAcG;AACG,MAAO,QAAS,SAAQA,uBAAW,CAAA;AAAzC,IAAA,WAAA,GAAA;;;QAS6C,IAAa,CAAA,aAAA,GAAsB,QAAQ,CAAC;;QAG5C,IAAe,CAAA,eAAA,GAAwB,SAAS,CAAC;;QAG/D,IAAY,CAAA,YAAA,GAAG,KAAK,CAAC;;QAGrB,IAAW,CAAA,WAAA,GAAG,KAAK,CAAC;;QAGpB,IAAY,CAAA,YAAA,GAAG,KAAK,CAAC;AAcjC,QAAA,IAAA,CAAA,iBAAiB,GAAG,IAAIC,sBAAiB,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;KA2E5F;AAvFC,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,CAA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/Card/sgds-card.ts"],"sourcesContent":["import { PropertyValueMap } from \"lit\";\nimport { property, queryAssignedElements } from \"lit/decorators.js\";\nimport { classMap } from \"lit/directives/class-map.js\";\nimport { html, literal } from \"lit/static-html.js\";\nimport { CardElement } from \"../../base/card-element\";\nimport { HasSlotController } from \"../../utils/slot\";\nimport { CardImageAdjustment, CardImagePosition } from \"./types\";\nimport type SgdsLink from \"../Link/sgds-link\";\nimport cardStyle from \"./card.css\";\n\n/**\n * @summary 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 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.\n * @slot upper - Accepts an element to be displayed above the card content. When used, it overrides image and icon slot content.\n * @slot image - Accepts an image or svg element of the card. Only a single element is allowed to be passed in.\n * @slot icon - Accepts an icon element to visually represent the card. Only a single element is allowed to be passed in.\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 SgdsCard extends CardElement {\n static styles = [...CardElement.styles, cardStyle];\n\n @queryAssignedElements({ slot: \"footer\" })\n private footerNode!: HTMLElement[];\n @queryAssignedElements({ slot: \"link\" })\n private linkNode!: HTMLAnchorElement[] | SgdsLink[];\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 /** Used only for SSR to indicate the presence of the `image` slot. */\n @property({ type: Boolean }) hasImageSlot = false;\n\n /** Used only for SSR to indicate the presence of the `icon` slot. */\n @property({ type: Boolean }) hasIconSlot = false;\n\n /** Used only for SSR to indicate the presence of the `upper` slot. */\n @property({ type: Boolean }) hasUpperSlot = 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 private readonly hasSlotController = new HasSlotController(this, \"image\", \"icon\", \"upper\");\n\n protected firstUpdated(changedProperties: PropertyValueMap<this>) {\n super.firstUpdated(changedProperties);\n if (this.stretchedLink) {\n const footerAnchor = this.footerSlotItems;\n const linkAnchor = this.linkSlotItems;\n this._forwardAnchorAttributes(footerAnchor?.href ? footerAnchor : linkAnchor);\n }\n }\n\n updated() {\n if (!this.hasImageSlot) this.hasImageSlot = this.hasSlotController.test(\"image\");\n if (!this.hasIconSlot) this.hasIconSlot = this.hasSlotController.test(\"icon\");\n if (!this.hasUpperSlot) this.hasUpperSlot = this.hasSlotController.test(\"upper\");\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 console.error(\"Multiple elements passed into SgdsCard's image slot\");\n }\n\n if (this.hasSlotController.test(\"image\") && this.hasSlotController.test(\"icon\")) {\n console.error(\"Both image and icon slots cannot be used together in SgdsCard\");\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 <div class=\"card-tinted-bg\"></div>\n \n <slot name=\"menu\"></slot>\n <div class=${classMap({\n \"card-image\": this.hasImageSlot,\n \"card-media\": this.hasIconSlot || this.hasUpperSlot\n })}>\n <slot name=\"upper\">\n <slot name=\"image\" @slotchange=${this.handleImgSlotChange}></slot>\n <slot name=\"icon\"></slot>\n </slot>\n </div>\n\n <div class=\"card-body\">\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.warnLinkSlotMisused}></slot>\n </slot>\n </div>\n </${tag}>\n `;\n }\n}\n\nexport default SgdsCard;\n"],"names":["CardElement","HasSlotController","literal","html","classMap","cardStyle","__decorate","queryAssignedElements","property"],"mappings":";;;;;;;;;;;;;AAUA;;;;;;;;;;;;;;AAcG;AACG,MAAO,QAAS,SAAQA,uBAAW,CAAA;AAAzC,IAAA,WAAA,GAAA;;;QAS6C,IAAa,CAAA,aAAA,GAAsB,QAAQ,CAAC;;QAG5C,IAAe,CAAA,eAAA,GAAwB,SAAS,CAAC;;QAG/D,IAAY,CAAA,YAAA,GAAG,KAAK,CAAC;;QAGrB,IAAW,CAAA,WAAA,GAAG,KAAK,CAAC;;QAGpB,IAAY,CAAA,YAAA,GAAG,KAAK,CAAC;AAcjC,QAAA,IAAA,CAAA,iBAAiB,GAAG,IAAIC,sBAAiB,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;KAsE5F;AAlFC,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,C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Element {
|
|
|
50
50
|
return (element.querySelector("a") || element);
|
|
51
51
|
}
|
|
52
52
|
firstUpdated(changedProperties) {
|
|
53
|
-
var _a, _b;
|
|
54
53
|
super.firstUpdated(changedProperties);
|
|
55
54
|
if (this.stretchedLink) {
|
|
56
|
-
const
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
this.card.setAttribute("href", footerHref);
|
|
60
|
-
}
|
|
61
|
-
else if (linkHref) {
|
|
62
|
-
this.card.setAttribute("href", linkHref);
|
|
63
|
-
}
|
|
55
|
+
const footerAnchor = this.footerSlotItems;
|
|
56
|
+
const linkAnchor = this.linkSlotItems;
|
|
57
|
+
this._forwardAnchorAttributes((footerAnchor === null || footerAnchor === void 0 ? void 0 : footerAnchor.href) ? footerAnchor : linkAnchor);
|
|
64
58
|
}
|
|
65
59
|
}
|
|
66
60
|
updated() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sgds-card.js","sources":["../../../../src/components/Card/sgds-card.ts"],"sourcesContent":["import { PropertyValueMap } from \"lit\";\nimport { property, queryAssignedElements } from \"lit/decorators.js\";\nimport { classMap } from \"lit/directives/class-map.js\";\nimport { html, literal } from \"lit/static-html.js\";\nimport { CardElement } from \"../../base/card-element\";\nimport { HasSlotController } from \"../../utils/slot\";\nimport { CardImageAdjustment, CardImagePosition } from \"./types\";\nimport type SgdsLink from \"../Link/sgds-link\";\nimport cardStyle from \"./card.css\";\n\n/**\n * @summary 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 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.\n * @slot upper - Accepts an element to be displayed above the card content. When used, it overrides image and icon slot content.\n * @slot image - Accepts an image or svg element of the card. Only a single element is allowed to be passed in.\n * @slot icon - Accepts an icon element to visually represent the card. Only a single element is allowed to be passed in.\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 SgdsCard extends CardElement {\n static styles = [...CardElement.styles, cardStyle];\n\n @queryAssignedElements({ slot: \"footer\" })\n private footerNode!: HTMLElement[];\n @queryAssignedElements({ slot: \"link\" })\n private linkNode!: HTMLAnchorElement[] | SgdsLink[];\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 /** Used only for SSR to indicate the presence of the `image` slot. */\n @property({ type: Boolean }) hasImageSlot = false;\n\n /** Used only for SSR to indicate the presence of the `icon` slot. */\n @property({ type: Boolean }) hasIconSlot = false;\n\n /** Used only for SSR to indicate the presence of the `upper` slot. */\n @property({ type: Boolean }) hasUpperSlot = 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 private readonly hasSlotController = new HasSlotController(this, \"image\", \"icon\", \"upper\");\n\n protected firstUpdated(changedProperties: PropertyValueMap<this>) {\n super.firstUpdated(changedProperties);\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 updated() {\n if (!this.hasImageSlot) this.hasImageSlot = this.hasSlotController.test(\"image\");\n if (!this.hasIconSlot) this.hasIconSlot = this.hasSlotController.test(\"icon\");\n if (!this.hasUpperSlot) this.hasUpperSlot = this.hasSlotController.test(\"upper\");\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 console.error(\"Multiple elements passed into SgdsCard's image slot\");\n }\n\n if (this.hasSlotController.test(\"image\") && this.hasSlotController.test(\"icon\")) {\n console.error(\"Both image and icon slots cannot be used together in SgdsCard\");\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 <div class=\"card-tinted-bg\"></div>\n \n <slot name=\"menu\"></slot>\n <div class=${classMap({\n \"card-image\": this.hasImageSlot,\n \"card-media\": this.hasIconSlot || this.hasUpperSlot\n })}>\n <slot name=\"upper\">\n <slot name=\"image\" @slotchange=${this.handleImgSlotChange}></slot>\n <slot name=\"icon\"></slot>\n </slot>\n </div>\n\n <div class=\"card-body\">\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.warnLinkSlotMisused}></slot>\n </slot>\n </div>\n </${tag}>\n `;\n }\n}\n\nexport default SgdsCard;\n"],"names":["cardStyle"],"mappings":";;;;;;;;;AAUA;;;;;;;;;;;;;;AAcG;AACG,MAAO,QAAS,SAAQ,WAAW,CAAA;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,OAAO,EAAE,IAAI,EAAE,CAAC;AAA6C,CAAA,EAAA,QAAA,CAAA,SAAA,EAAA,eAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAG5C,UAAA,CAAA;IAA1C,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAAkD,CAAA,EAAA,QAAA,CAAA,SAAA,EAAA,iBAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAG/D,UAAA,CAAA;AAA5B,IAAA,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AAAsB,CAAA,EAAA,QAAA,CAAA,SAAA,EAAA,cAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAGrB,UAAA,CAAA;AAA5B,IAAA,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AAAqB,CAAA,EAAA,QAAA,CAAA,SAAA,EAAA,aAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAGpB,UAAA,CAAA;AAA5B,IAAA,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AAAsB,CAAA,EAAA,QAAA,CAAA,SAAA,EAAA,cAAA,EAAA,KAAA,CAAA,CAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"sgds-card.js","sources":["../../../../src/components/Card/sgds-card.ts"],"sourcesContent":["import { PropertyValueMap } from \"lit\";\nimport { property, queryAssignedElements } from \"lit/decorators.js\";\nimport { classMap } from \"lit/directives/class-map.js\";\nimport { html, literal } from \"lit/static-html.js\";\nimport { CardElement } from \"../../base/card-element\";\nimport { HasSlotController } from \"../../utils/slot\";\nimport { CardImageAdjustment, CardImagePosition } from \"./types\";\nimport type SgdsLink from \"../Link/sgds-link\";\nimport cardStyle from \"./card.css\";\n\n/**\n * @summary 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 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.\n * @slot upper - Accepts an element to be displayed above the card content. When used, it overrides image and icon slot content.\n * @slot image - Accepts an image or svg element of the card. Only a single element is allowed to be passed in.\n * @slot icon - Accepts an icon element to visually represent the card. Only a single element is allowed to be passed in.\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 SgdsCard extends CardElement {\n static styles = [...CardElement.styles, cardStyle];\n\n @queryAssignedElements({ slot: \"footer\" })\n private footerNode!: HTMLElement[];\n @queryAssignedElements({ slot: \"link\" })\n private linkNode!: HTMLAnchorElement[] | SgdsLink[];\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 /** Used only for SSR to indicate the presence of the `image` slot. */\n @property({ type: Boolean }) hasImageSlot = false;\n\n /** Used only for SSR to indicate the presence of the `icon` slot. */\n @property({ type: Boolean }) hasIconSlot = false;\n\n /** Used only for SSR to indicate the presence of the `upper` slot. */\n @property({ type: Boolean }) hasUpperSlot = 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 private readonly hasSlotController = new HasSlotController(this, \"image\", \"icon\", \"upper\");\n\n protected firstUpdated(changedProperties: PropertyValueMap<this>) {\n super.firstUpdated(changedProperties);\n if (this.stretchedLink) {\n const footerAnchor = this.footerSlotItems;\n const linkAnchor = this.linkSlotItems;\n this._forwardAnchorAttributes(footerAnchor?.href ? footerAnchor : linkAnchor);\n }\n }\n\n updated() {\n if (!this.hasImageSlot) this.hasImageSlot = this.hasSlotController.test(\"image\");\n if (!this.hasIconSlot) this.hasIconSlot = this.hasSlotController.test(\"icon\");\n if (!this.hasUpperSlot) this.hasUpperSlot = this.hasSlotController.test(\"upper\");\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 console.error(\"Multiple elements passed into SgdsCard's image slot\");\n }\n\n if (this.hasSlotController.test(\"image\") && this.hasSlotController.test(\"icon\")) {\n console.error(\"Both image and icon slots cannot be used together in SgdsCard\");\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 <div class=\"card-tinted-bg\"></div>\n \n <slot name=\"menu\"></slot>\n <div class=${classMap({\n \"card-image\": this.hasImageSlot,\n \"card-media\": this.hasIconSlot || this.hasUpperSlot\n })}>\n <slot name=\"upper\">\n <slot name=\"image\" @slotchange=${this.handleImgSlotChange}></slot>\n <slot name=\"icon\"></slot>\n </slot>\n </div>\n\n <div class=\"card-body\">\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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A,CAAA,CAAA,CAAA;AAG5C,UAAA,CAAA;IAA1C,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAAkD,CAAA,EAAA,QAAA,CAAA,SAAA,EAAA,iBAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAG/D,UAAA,CAAA;AAA5B,IAAA,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AAAsB,CAAA,EAAA,QAAA,CAAA,SAAA,EAAA,cAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAGrB,UAAA,CAAA;AAA5B,IAAA,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AAAqB,CAAA,EAAA,QAAA,CAAA,SAAA,EAAA,aAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAGpB,UAAA,CAAA;AAA5B,IAAA,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AAAsB,CAAA,EAAA,QAAA,CAAA,SAAA,EAAA,cAAA,EAAA,KAAA,CAAA,CAAA;;;;"}
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
|
|
6
6
|
var lit = require('lit');
|
|
7
7
|
|
|
8
|
-
var css_248z = lit.css`:host([menuisopen]:not([disabled]):not([readonly])) .dropdown-menu{display:block}.dropdown-menu{background-clip:padding-box;background-color:var(--sgds-surface-default);border-radius:var(--sgds-border-radius-md);box-shadow:0 0 1px 0 hsla(0,0%,5%,.12),0 4px 8px 0 hsla(0,0%,5%,.12);color:var(--sgds-color-default);display:none;list-style:none;margin:0;max-height:var(--sgds-dimension-480);
|
|
8
|
+
var css_248z = lit.css`:host([menuisopen]:not([disabled]):not([readonly])) .dropdown-menu{display:block}.dropdown-menu{background-clip:padding-box;background-color:var(--sgds-surface-default);border-radius:var(--sgds-border-radius-md);box-shadow:0 0 1px 0 hsla(0,0%,5%,.12),0 4px 8px 0 hsla(0,0%,5%,.12);color:var(--sgds-color-default);display:none;list-style:none;margin:0;max-height:var(--sgds-dimension-480);min-width:var(--sgds-dimension-192);overflow-y:auto;padding:var(--sgds-padding-xs) 0;position:absolute;text-align:left;z-index:var(--sgds-z-index-floating)}.nav-tabs .dropdown-menu{border-top-left-radius:0;border-top-right-radius:0;margin-top:calc(var(--sgds-nav-tabs-border-width)*-1)}@media (min-width:512px){.navbar-expand-sm .navbar-nav .dropdown-menu{position:absolute}}@media (min-width:768px){.navbar-expand-md .navbar-nav .dropdown-menu{position:absolute}}@media (min-width:1024px){.navbar-expand-lg .navbar-nav .dropdown-menu{position:absolute}}@media (min-width:1280px){.navbar-expand-xl .navbar-nav .dropdown-menu{position:absolute}}@media (min-width:1440px){.navbar-expand-xxl .navbar-nav .dropdown-menu{position:absolute}}.navbar-expand .navbar-nav .dropdown-menu{position:absolute}.sgds.navbar .dropdown-menu.megamenu{left:0;right:0;width:100%}.sgds.combobox>.dropdown-menu{min-width:100%}`;
|
|
9
9
|
|
|
10
10
|
exports["default"] = css_248z;
|
|
11
11
|
//# sourceMappingURL=dropdown-menu.cjs.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { css } from 'lit';
|
|
3
3
|
|
|
4
|
-
var css_248z = css`:host([menuisopen]:not([disabled]):not([readonly])) .dropdown-menu{display:block}.dropdown-menu{background-clip:padding-box;background-color:var(--sgds-surface-default);border-radius:var(--sgds-border-radius-md);box-shadow:0 0 1px 0 hsla(0,0%,5%,.12),0 4px 8px 0 hsla(0,0%,5%,.12);color:var(--sgds-color-default);display:none;list-style:none;margin:0;max-height:var(--sgds-dimension-480);
|
|
4
|
+
var css_248z = css`:host([menuisopen]:not([disabled]):not([readonly])) .dropdown-menu{display:block}.dropdown-menu{background-clip:padding-box;background-color:var(--sgds-surface-default);border-radius:var(--sgds-border-radius-md);box-shadow:0 0 1px 0 hsla(0,0%,5%,.12),0 4px 8px 0 hsla(0,0%,5%,.12);color:var(--sgds-color-default);display:none;list-style:none;margin:0;max-height:var(--sgds-dimension-480);min-width:var(--sgds-dimension-192);overflow-y:auto;padding:var(--sgds-padding-xs) 0;position:absolute;text-align:left;z-index:var(--sgds-z-index-floating)}.nav-tabs .dropdown-menu{border-top-left-radius:0;border-top-right-radius:0;margin-top:calc(var(--sgds-nav-tabs-border-width)*-1)}@media (min-width:512px){.navbar-expand-sm .navbar-nav .dropdown-menu{position:absolute}}@media (min-width:768px){.navbar-expand-md .navbar-nav .dropdown-menu{position:absolute}}@media (min-width:1024px){.navbar-expand-lg .navbar-nav .dropdown-menu{position:absolute}}@media (min-width:1280px){.navbar-expand-xl .navbar-nav .dropdown-menu{position:absolute}}@media (min-width:1440px){.navbar-expand-xxl .navbar-nav .dropdown-menu{position:absolute}}.navbar-expand .navbar-nav .dropdown-menu{position:absolute}.sgds.navbar .dropdown-menu.megamenu{left:0;right:0;width:100%}.sgds.combobox>.dropdown-menu{min-width:100%}`;
|
|
5
5
|
|
|
6
6
|
export { css_248z as default };
|
|
7
7
|
//# sourceMappingURL=dropdown-menu.js.map
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
|
|
6
6
|
var lit = require('lit');
|
|
7
7
|
|
|
8
|
-
var css_248z = lit.css`.dropdown{display:flex;height:inherit;position:relative}`;
|
|
8
|
+
var css_248z = lit.css`.dropdown{display:flex;height:inherit;position:relative}.dropdown-menu{max-width:var(--sgds-dimension-320)}.toggler-container{flex:1;pointer-events:none}.toggler-container ::slotted(*){pointer-events:auto}`;
|
|
9
9
|
|
|
10
10
|
exports["default"] = css_248z;
|
|
11
11
|
//# sourceMappingURL=dropdown.cjs.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { css } from 'lit';
|
|
3
3
|
|
|
4
|
-
var css_248z = css`.dropdown{display:flex;height:inherit;position:relative}`;
|
|
4
|
+
var css_248z = css`.dropdown{display:flex;height:inherit;position:relative}.dropdown-menu{max-width:var(--sgds-dimension-320)}.toggler-container{flex:1;pointer-events:none}.toggler-container ::slotted(*){pointer-events:auto}`;
|
|
5
5
|
|
|
6
6
|
export { css_248z as default };
|
|
7
7
|
//# sourceMappingURL=dropdown.js.map
|
|
@@ -29,11 +29,25 @@ class SgdsDropdown extends dropdownListElement.DropdownListElement {
|
|
|
29
29
|
this.drop = "down";
|
|
30
30
|
this.menuRef = ref_js.ref();
|
|
31
31
|
}
|
|
32
|
-
async _handleClick() {
|
|
33
|
-
if (this.disabled)
|
|
32
|
+
async _handleClick(e) {
|
|
33
|
+
if (this.disabled)
|
|
34
|
+
return;
|
|
35
|
+
const slottedToggler = this._toggler[0];
|
|
36
|
+
if (!slottedToggler) {
|
|
37
|
+
this.toggleMenu();
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
if (e.composedPath().includes(slottedToggler)) {
|
|
41
|
+
this.toggleMenu();
|
|
34
42
|
return;
|
|
35
43
|
}
|
|
36
|
-
|
|
44
|
+
// Click landed in the toggler-container's empty area (passed through pointer-events: none)
|
|
45
|
+
if (!this.menuIsOpen)
|
|
46
|
+
return;
|
|
47
|
+
const menu = this.menuRef.value;
|
|
48
|
+
if (menu && e.composedPath().includes(menu))
|
|
49
|
+
return;
|
|
50
|
+
this.hideMenu();
|
|
37
51
|
}
|
|
38
52
|
_handleCloseMenu() {
|
|
39
53
|
const button = this._toggler[0];
|
|
@@ -66,14 +80,8 @@ class SgdsDropdown extends dropdownListElement.DropdownListElement {
|
|
|
66
80
|
}
|
|
67
81
|
render() {
|
|
68
82
|
return lit.html `
|
|
69
|
-
<div class="dropdown">
|
|
70
|
-
<div
|
|
71
|
-
class="toggler-container"
|
|
72
|
-
${ref_js.ref(this.myDropdown)}
|
|
73
|
-
@click=${this._handleClick}
|
|
74
|
-
aria-expanded="${this.menuIsOpen}"
|
|
75
|
-
aria-haspopup="menu"
|
|
76
|
-
>
|
|
83
|
+
<div class="dropdown" @click=${this._handleClick}>
|
|
84
|
+
<div class="toggler-container" ${ref_js.ref(this.myDropdown)} aria-expanded="${this.menuIsOpen}" aria-haspopup="menu">
|
|
77
85
|
<slot name="toggler"></slot>
|
|
78
86
|
</div>
|
|
79
87
|
<div class="dropdown-menu" role="menu" ${ref_js.ref(this.menuRef)}>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sgds-dropdown.cjs.js","sources":["../../../../src/components/Dropdown/sgds-dropdown.ts"],"sourcesContent":["import { html, PropertyValueMap } from \"lit\";\nimport { property, queryAssignedElements } from \"lit/decorators.js\";\nimport { ref } from \"lit/directives/ref.js\";\nimport { DropdownListElement } from \"../../base/dropdown-list-element\";\nimport { watch } from \"../../utils/watch\";\nimport dropdownMenuStyle from \"./dropdown-menu.css\";\nimport dropdownStyle from \"./dropdown.css\";\n\nexport type DropDirection = \"left\" | \"right\" | \"up\" | \"down\";\nexport type DropdownButtonVariant =\n | \"primary\"\n | \"secondary\"\n | \"success\"\n | \"danger\"\n | \"warning\"\n | \"info\"\n | \"light\"\n | \"dark\";\n\n/**\n * @summary `SgdsDropdown` toggles contextual overlays for displaying lists of links.\n * @slot default - slot for sgds-dropdown-item passed into dropdown's menu\n * @slot toggler - slot for the toggler that triggers the open and closing of menu, typically a button. Only pass in a single element into this slot\n *\n */\nexport class SgdsDropdown extends DropdownListElement {\n static styles = [...DropdownListElement.styles, dropdownStyle, dropdownMenuStyle];\n\n constructor() {\n super();\n this.menuRef = ref();\n }\n\n /** Controls auto-flipping of menu */\n @property({ type: Boolean, reflect: true, state: false })\n noFlip = false;\n\n /** When true, aligns right edge of menu with right edge of button */\n @property({ type: Boolean, reflect: true, state: false })\n menuAlignRight = false;\n\n /** The drop position of menu relative to the toggle button */\n @property({ type: String, reflect: true, state: false })\n drop: DropDirection = \"down\";\n\n @queryAssignedElements({ slot: \"toggler\", flatten: true })\n private _toggler: Array<HTMLElement>;\n\n protected menuRef;\n\n private async _handleClick() {\n if (this.disabled) {\n return;\n }\n this.toggleMenu();\n }\n\n private _handleCloseMenu() {\n const button = this._toggler[0];\n button?.focus();\n }\n\n async connectedCallback() {\n super.connectedCallback();\n this.addEventListener(\"sgds-hide\", this._handleCloseMenu);\n }\n\n async disconnectedCallback() {\n this.removeEventListener(\"sgds-hide\", this._handleCloseMenu);\n }\n\n async firstUpdated(changedProperties: PropertyValueMap<this>) {\n super.firstUpdated(changedProperties);\n if (this.menuIsOpen) {\n await this.updateFloatingPosition();\n }\n this._handleDisabled();\n }\n\n @watch(\"disabled\", { waitUntilFirstUpdate: true })\n _handleDisabled() {\n const button = this._toggler[0];\n if (button) {\n if (this.disabled) {\n button.setAttribute(\"disabled\", \"true\");\n } else {\n button.hasAttribute(\"disabled\") && button.removeAttribute(\"disabled\");\n }\n }\n }\n\n render() {\n return html`\n <div class=\"dropdown\">\n <div
|
|
1
|
+
{"version":3,"file":"sgds-dropdown.cjs.js","sources":["../../../../src/components/Dropdown/sgds-dropdown.ts"],"sourcesContent":["import { html, PropertyValueMap } from \"lit\";\nimport { property, queryAssignedElements } from \"lit/decorators.js\";\nimport { ref } from \"lit/directives/ref.js\";\nimport { DropdownListElement } from \"../../base/dropdown-list-element\";\nimport { watch } from \"../../utils/watch\";\nimport dropdownMenuStyle from \"./dropdown-menu.css\";\nimport dropdownStyle from \"./dropdown.css\";\n\nexport type DropDirection = \"left\" | \"right\" | \"up\" | \"down\";\nexport type DropdownButtonVariant =\n | \"primary\"\n | \"secondary\"\n | \"success\"\n | \"danger\"\n | \"warning\"\n | \"info\"\n | \"light\"\n | \"dark\";\n\n/**\n * @summary `SgdsDropdown` toggles contextual overlays for displaying lists of links.\n * @slot default - slot for sgds-dropdown-item passed into dropdown's menu\n * @slot toggler - slot for the toggler that triggers the open and closing of menu, typically a button. Only pass in a single element into this slot\n *\n */\nexport class SgdsDropdown extends DropdownListElement {\n static styles = [...DropdownListElement.styles, dropdownStyle, dropdownMenuStyle];\n\n constructor() {\n super();\n this.menuRef = ref();\n }\n\n /** Controls auto-flipping of menu */\n @property({ type: Boolean, reflect: true, state: false })\n noFlip = false;\n\n /** When true, aligns right edge of menu with right edge of button */\n @property({ type: Boolean, reflect: true, state: false })\n menuAlignRight = false;\n\n /** The drop position of menu relative to the toggle button */\n @property({ type: String, reflect: true, state: false })\n drop: DropDirection = \"down\";\n\n @queryAssignedElements({ slot: \"toggler\", flatten: true })\n private _toggler: Array<HTMLElement>;\n\n protected menuRef;\n\n private async _handleClick(e: MouseEvent) {\n if (this.disabled) return;\n\n const slottedToggler = this._toggler[0];\n\n if (!slottedToggler) {\n this.toggleMenu();\n return;\n }\n\n if (e.composedPath().includes(slottedToggler)) {\n this.toggleMenu();\n return;\n }\n\n // Click landed in the toggler-container's empty area (passed through pointer-events: none)\n if (!this.menuIsOpen) return;\n const menu = this.menuRef.value;\n if (menu && e.composedPath().includes(menu)) return;\n this.hideMenu();\n }\n\n private _handleCloseMenu() {\n const button = this._toggler[0];\n button?.focus();\n }\n\n async connectedCallback() {\n super.connectedCallback();\n this.addEventListener(\"sgds-hide\", this._handleCloseMenu);\n }\n\n async disconnectedCallback() {\n this.removeEventListener(\"sgds-hide\", this._handleCloseMenu);\n }\n\n async firstUpdated(changedProperties: PropertyValueMap<this>) {\n super.firstUpdated(changedProperties);\n if (this.menuIsOpen) {\n await this.updateFloatingPosition();\n }\n this._handleDisabled();\n }\n\n @watch(\"disabled\", { waitUntilFirstUpdate: true })\n _handleDisabled() {\n const button = this._toggler[0];\n if (button) {\n if (this.disabled) {\n button.setAttribute(\"disabled\", \"true\");\n } else {\n button.hasAttribute(\"disabled\") && button.removeAttribute(\"disabled\");\n }\n }\n }\n\n render() {\n return html`\n <div class=\"dropdown\" @click=${this._handleClick}>\n <div class=\"toggler-container\" ${ref(this.myDropdown)} aria-expanded=\"${this.menuIsOpen}\" aria-haspopup=\"menu\">\n <slot name=\"toggler\"></slot>\n </div>\n <div class=\"dropdown-menu\" role=\"menu\" ${ref(this.menuRef)}>\n <slot id=\"default\" @click=${this.handleSelectSlot}></slot>\n </div>\n </div>\n `;\n }\n}\n\nexport default SgdsDropdown;\n"],"names":["DropdownListElement","ref","html","dropdownStyle","dropdownMenuStyle","__decorate","property","queryAssignedElements","watch"],"mappings":";;;;;;;;;;;;;;AAmBA;;;;;AAKG;AACG,MAAO,YAAa,SAAQA,uCAAmB,CAAA;AAGnD,IAAA,WAAA,GAAA;AACE,QAAA,KAAK,EAAE,CAAC;;QAMV,IAAM,CAAA,MAAA,GAAG,KAAK,CAAC;;QAIf,IAAc,CAAA,cAAA,GAAG,KAAK,CAAC;;QAIvB,IAAI,CAAA,IAAA,GAAkB,MAAM,CAAC;AAb3B,QAAA,IAAI,CAAC,OAAO,GAAGC,UAAG,EAAE,CAAC;KACtB;IAmBO,MAAM,YAAY,CAAC,CAAa,EAAA;QACtC,IAAI,IAAI,CAAC,QAAQ;YAAE,OAAO;QAE1B,MAAM,cAAc,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;QAExC,IAAI,CAAC,cAAc,EAAE;YACnB,IAAI,CAAC,UAAU,EAAE,CAAC;YAClB,OAAO;SACR;QAED,IAAI,CAAC,CAAC,YAAY,EAAE,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE;YAC7C,IAAI,CAAC,UAAU,EAAE,CAAC;YAClB,OAAO;SACR;;QAGD,IAAI,CAAC,IAAI,CAAC,UAAU;YAAE,OAAO;AAC7B,QAAA,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;QAChC,IAAI,IAAI,IAAI,CAAC,CAAC,YAAY,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC;YAAE,OAAO;QACpD,IAAI,CAAC,QAAQ,EAAE,CAAC;KACjB;IAEO,gBAAgB,GAAA;QACtB,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;AAChC,QAAA,MAAM,aAAN,MAAM,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAN,MAAM,CAA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GAAGD,uCAAmB,CAAC,MAAM,EAAEG,mBAAa,EAAEC,uBAAiB,CAAnE,CAAqE;AASlFC,gBAAA,CAAA;AADC,IAAAC,sBAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;AAC1C,CAAA,EAAA,YAAA,CAAA,SAAA,EAAA,QAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAIfD,gBAAA,CAAA;AADC,IAAAC,sBAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;AAClC,CAAA,EAAA,YAAA,CAAA,SAAA,EAAA,gBAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAIvBD,gBAAA,CAAA;AADC,IAAAC,sBAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;AAC3B,CAAA,EAAA,YAAA,CAAA,SAAA,EAAA,MAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAGrBD,gBAAA,CAAA;IADPE,mCAAqB,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AACrB,CAAA,EAAA,YAAA,CAAA,SAAA,EAAA,UAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAiDrCF,gBAAA,CAAA;IADCG,WAAK,CAAC,UAAU,EAAE,EAAE,oBAAoB,EAAE,IAAI,EAAE,CAAC;AAUjD,CAAA,EAAA,YAAA,CAAA,SAAA,EAAA,iBAAA,EAAA,IAAA,CAAA;;;;;"}
|
|
@@ -25,11 +25,25 @@ class SgdsDropdown extends DropdownListElement {
|
|
|
25
25
|
this.drop = "down";
|
|
26
26
|
this.menuRef = ref();
|
|
27
27
|
}
|
|
28
|
-
async _handleClick() {
|
|
29
|
-
if (this.disabled)
|
|
28
|
+
async _handleClick(e) {
|
|
29
|
+
if (this.disabled)
|
|
30
|
+
return;
|
|
31
|
+
const slottedToggler = this._toggler[0];
|
|
32
|
+
if (!slottedToggler) {
|
|
33
|
+
this.toggleMenu();
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
if (e.composedPath().includes(slottedToggler)) {
|
|
37
|
+
this.toggleMenu();
|
|
30
38
|
return;
|
|
31
39
|
}
|
|
32
|
-
|
|
40
|
+
// Click landed in the toggler-container's empty area (passed through pointer-events: none)
|
|
41
|
+
if (!this.menuIsOpen)
|
|
42
|
+
return;
|
|
43
|
+
const menu = this.menuRef.value;
|
|
44
|
+
if (menu && e.composedPath().includes(menu))
|
|
45
|
+
return;
|
|
46
|
+
this.hideMenu();
|
|
33
47
|
}
|
|
34
48
|
_handleCloseMenu() {
|
|
35
49
|
const button = this._toggler[0];
|
|
@@ -62,14 +76,8 @@ class SgdsDropdown extends DropdownListElement {
|
|
|
62
76
|
}
|
|
63
77
|
render() {
|
|
64
78
|
return html `
|
|
65
|
-
<div class="dropdown">
|
|
66
|
-
<div
|
|
67
|
-
class="toggler-container"
|
|
68
|
-
${ref(this.myDropdown)}
|
|
69
|
-
@click=${this._handleClick}
|
|
70
|
-
aria-expanded="${this.menuIsOpen}"
|
|
71
|
-
aria-haspopup="menu"
|
|
72
|
-
>
|
|
79
|
+
<div class="dropdown" @click=${this._handleClick}>
|
|
80
|
+
<div class="toggler-container" ${ref(this.myDropdown)} aria-expanded="${this.menuIsOpen}" aria-haspopup="menu">
|
|
73
81
|
<slot name="toggler"></slot>
|
|
74
82
|
</div>
|
|
75
83
|
<div class="dropdown-menu" role="menu" ${ref(this.menuRef)}>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sgds-dropdown.js","sources":["../../../../src/components/Dropdown/sgds-dropdown.ts"],"sourcesContent":["import { html, PropertyValueMap } from \"lit\";\nimport { property, queryAssignedElements } from \"lit/decorators.js\";\nimport { ref } from \"lit/directives/ref.js\";\nimport { DropdownListElement } from \"../../base/dropdown-list-element\";\nimport { watch } from \"../../utils/watch\";\nimport dropdownMenuStyle from \"./dropdown-menu.css\";\nimport dropdownStyle from \"./dropdown.css\";\n\nexport type DropDirection = \"left\" | \"right\" | \"up\" | \"down\";\nexport type DropdownButtonVariant =\n | \"primary\"\n | \"secondary\"\n | \"success\"\n | \"danger\"\n | \"warning\"\n | \"info\"\n | \"light\"\n | \"dark\";\n\n/**\n * @summary `SgdsDropdown` toggles contextual overlays for displaying lists of links.\n * @slot default - slot for sgds-dropdown-item passed into dropdown's menu\n * @slot toggler - slot for the toggler that triggers the open and closing of menu, typically a button. Only pass in a single element into this slot\n *\n */\nexport class SgdsDropdown extends DropdownListElement {\n static styles = [...DropdownListElement.styles, dropdownStyle, dropdownMenuStyle];\n\n constructor() {\n super();\n this.menuRef = ref();\n }\n\n /** Controls auto-flipping of menu */\n @property({ type: Boolean, reflect: true, state: false })\n noFlip = false;\n\n /** When true, aligns right edge of menu with right edge of button */\n @property({ type: Boolean, reflect: true, state: false })\n menuAlignRight = false;\n\n /** The drop position of menu relative to the toggle button */\n @property({ type: String, reflect: true, state: false })\n drop: DropDirection = \"down\";\n\n @queryAssignedElements({ slot: \"toggler\", flatten: true })\n private _toggler: Array<HTMLElement>;\n\n protected menuRef;\n\n private async _handleClick() {\n if (this.disabled) {\n return;\n }\n this.toggleMenu();\n }\n\n private _handleCloseMenu() {\n const button = this._toggler[0];\n button?.focus();\n }\n\n async connectedCallback() {\n super.connectedCallback();\n this.addEventListener(\"sgds-hide\", this._handleCloseMenu);\n }\n\n async disconnectedCallback() {\n this.removeEventListener(\"sgds-hide\", this._handleCloseMenu);\n }\n\n async firstUpdated(changedProperties: PropertyValueMap<this>) {\n super.firstUpdated(changedProperties);\n if (this.menuIsOpen) {\n await this.updateFloatingPosition();\n }\n this._handleDisabled();\n }\n\n @watch(\"disabled\", { waitUntilFirstUpdate: true })\n _handleDisabled() {\n const button = this._toggler[0];\n if (button) {\n if (this.disabled) {\n button.setAttribute(\"disabled\", \"true\");\n } else {\n button.hasAttribute(\"disabled\") && button.removeAttribute(\"disabled\");\n }\n }\n }\n\n render() {\n return html`\n <div class=\"dropdown\">\n <div
|
|
1
|
+
{"version":3,"file":"sgds-dropdown.js","sources":["../../../../src/components/Dropdown/sgds-dropdown.ts"],"sourcesContent":["import { html, PropertyValueMap } from \"lit\";\nimport { property, queryAssignedElements } from \"lit/decorators.js\";\nimport { ref } from \"lit/directives/ref.js\";\nimport { DropdownListElement } from \"../../base/dropdown-list-element\";\nimport { watch } from \"../../utils/watch\";\nimport dropdownMenuStyle from \"./dropdown-menu.css\";\nimport dropdownStyle from \"./dropdown.css\";\n\nexport type DropDirection = \"left\" | \"right\" | \"up\" | \"down\";\nexport type DropdownButtonVariant =\n | \"primary\"\n | \"secondary\"\n | \"success\"\n | \"danger\"\n | \"warning\"\n | \"info\"\n | \"light\"\n | \"dark\";\n\n/**\n * @summary `SgdsDropdown` toggles contextual overlays for displaying lists of links.\n * @slot default - slot for sgds-dropdown-item passed into dropdown's menu\n * @slot toggler - slot for the toggler that triggers the open and closing of menu, typically a button. Only pass in a single element into this slot\n *\n */\nexport class SgdsDropdown extends DropdownListElement {\n static styles = [...DropdownListElement.styles, dropdownStyle, dropdownMenuStyle];\n\n constructor() {\n super();\n this.menuRef = ref();\n }\n\n /** Controls auto-flipping of menu */\n @property({ type: Boolean, reflect: true, state: false })\n noFlip = false;\n\n /** When true, aligns right edge of menu with right edge of button */\n @property({ type: Boolean, reflect: true, state: false })\n menuAlignRight = false;\n\n /** The drop position of menu relative to the toggle button */\n @property({ type: String, reflect: true, state: false })\n drop: DropDirection = \"down\";\n\n @queryAssignedElements({ slot: \"toggler\", flatten: true })\n private _toggler: Array<HTMLElement>;\n\n protected menuRef;\n\n private async _handleClick(e: MouseEvent) {\n if (this.disabled) return;\n\n const slottedToggler = this._toggler[0];\n\n if (!slottedToggler) {\n this.toggleMenu();\n return;\n }\n\n if (e.composedPath().includes(slottedToggler)) {\n this.toggleMenu();\n return;\n }\n\n // Click landed in the toggler-container's empty area (passed through pointer-events: none)\n if (!this.menuIsOpen) return;\n const menu = this.menuRef.value;\n if (menu && e.composedPath().includes(menu)) return;\n this.hideMenu();\n }\n\n private _handleCloseMenu() {\n const button = this._toggler[0];\n button?.focus();\n }\n\n async connectedCallback() {\n super.connectedCallback();\n this.addEventListener(\"sgds-hide\", this._handleCloseMenu);\n }\n\n async disconnectedCallback() {\n this.removeEventListener(\"sgds-hide\", this._handleCloseMenu);\n }\n\n async firstUpdated(changedProperties: PropertyValueMap<this>) {\n super.firstUpdated(changedProperties);\n if (this.menuIsOpen) {\n await this.updateFloatingPosition();\n }\n this._handleDisabled();\n }\n\n @watch(\"disabled\", { waitUntilFirstUpdate: true })\n _handleDisabled() {\n const button = this._toggler[0];\n if (button) {\n if (this.disabled) {\n button.setAttribute(\"disabled\", \"true\");\n } else {\n button.hasAttribute(\"disabled\") && button.removeAttribute(\"disabled\");\n }\n }\n }\n\n render() {\n return html`\n <div class=\"dropdown\" @click=${this._handleClick}>\n <div class=\"toggler-container\" ${ref(this.myDropdown)} aria-expanded=\"${this.menuIsOpen}\" aria-haspopup=\"menu\">\n <slot name=\"toggler\"></slot>\n </div>\n <div class=\"dropdown-menu\" role=\"menu\" ${ref(this.menuRef)}>\n <slot id=\"default\" @click=${this.handleSelectSlot}></slot>\n </div>\n </div>\n `;\n }\n}\n\nexport default SgdsDropdown;\n"],"names":["dropdownStyle","dropdownMenuStyle"],"mappings":";;;;;;;;;;AAmBA;;;;;AAKG;AACG,MAAO,YAAa,SAAQ,mBAAmB,CAAA;AAGnD,IAAA,WAAA,GAAA;AACE,QAAA,KAAK,EAAE,CAAC;;QAMV,IAAM,CAAA,MAAA,GAAG,KAAK,CAAC;;QAIf,IAAc,CAAA,cAAA,GAAG,KAAK,CAAC;;QAIvB,IAAI,CAAA,IAAA,GAAkB,MAAM,CAAC;AAb3B,QAAA,IAAI,CAAC,OAAO,GAAG,GAAG,EAAE,CAAC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,EAAA,KAAA,CAAA,CAAA,CAAA;AAIvB,UAAA,CAAA;AADC,IAAA,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;AAC3B,CAAA,EAAA,YAAA,CAAA,SAAA,EAAA,MAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAGrB,UAAA,CAAA;IADP,qBAAqB,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AACrB,CAAA,EAAA,YAAA,CAAA,SAAA,EAAA,UAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAiDrC,UAAA,CAAA;IADC,KAAK,CAAC,UAAU,EAAE,EAAE,oBAAoB,EAAE,IAAI,EAAE,CAAC;AAUjD,CAAA,EAAA,YAAA,CAAA,SAAA,EAAA,iBAAA,EAAA,IAAA,CAAA;;;;"}
|
|
@@ -43,7 +43,6 @@ class SgdsIconCard extends cardElement.CardElement {
|
|
|
43
43
|
return (element.querySelector("a") || element);
|
|
44
44
|
}
|
|
45
45
|
firstUpdated(changedProperties) {
|
|
46
|
-
var _a, _b;
|
|
47
46
|
super.firstUpdated(changedProperties);
|
|
48
47
|
if (this._iconNode.length === 0) {
|
|
49
48
|
if ((this.orientation === "vertical" && this._upperNode.length === 0) || this.orientation === "horizontal") {
|
|
@@ -55,14 +54,9 @@ class SgdsIconCard extends cardElement.CardElement {
|
|
|
55
54
|
}
|
|
56
55
|
}
|
|
57
56
|
if (this.stretchedLink) {
|
|
58
|
-
const
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
this.card.setAttribute("href", footerHref);
|
|
62
|
-
}
|
|
63
|
-
else if (linkHref) {
|
|
64
|
-
this.card.setAttribute("href", linkHref);
|
|
65
|
-
}
|
|
57
|
+
const footerAnchor = this.footerSlotItems;
|
|
58
|
+
const linkAnchor = this.linkSlotItems;
|
|
59
|
+
this._forwardAnchorAttributes((footerAnchor === null || footerAnchor === void 0 ? void 0 : footerAnchor.href) ? footerAnchor : linkAnchor);
|
|
66
60
|
}
|
|
67
61
|
}
|
|
68
62
|
render() {
|