@govtechsg/sgds-web-component 3.3.3-rc.0 → 3.3.3-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/Card/index.umd.js +4023 -4074
- package/components/Card/index.umd.js.map +1 -1
- package/components/Card/sgds-card.d.ts +1 -5
- package/components/Card/sgds-card.js +21 -27
- package/components/Card/sgds-card.js.map +1 -1
- package/components/index.umd.js +19 -25
- package/components/index.umd.js.map +1 -1
- package/index.umd.js +19 -25
- package/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/react/components/Card/sgds-card.cjs.js +20 -26
- package/react/components/Card/sgds-card.cjs.js.map +1 -1
- package/react/components/Card/sgds-card.js +21 -27
- package/react/components/Card/sgds-card.js.map +1 -1
|
@@ -4,6 +4,7 @@ import { CardImageAdjustment, CardImagePosition } from "./types";
|
|
|
4
4
|
* @summary Cards can be used for headers and footers, a wide variety of content, contain contextual background colors and images.
|
|
5
5
|
* @slot default - The content area of the card, placed directly under the title. Accepts any HTML or custom elements.
|
|
6
6
|
* @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.
|
|
7
|
+
* @slot upper - Accepts an element to be displayed above the card content. When used, it overrides image and icon slot content.
|
|
7
8
|
* @slot image - Accepts an image or svg element of the card. Only a single element is allowed to be passed in.
|
|
8
9
|
* @slot icon - Accepts an icon element to visually represent the card. Only a single element is allowed to be passed in.
|
|
9
10
|
* @slot subtitle - The subtitle of the card
|
|
@@ -14,16 +15,11 @@ import { CardImageAdjustment, CardImagePosition } from "./types";
|
|
|
14
15
|
*/
|
|
15
16
|
export declare class SgdsCard extends CardElement {
|
|
16
17
|
static styles: import("lit").CSSResult[];
|
|
17
|
-
/** @internal */
|
|
18
|
-
_imageNode: Array<Node>;
|
|
19
|
-
/** @internal */
|
|
20
|
-
_iconNode: Array<Node>;
|
|
21
18
|
/** Sets the image position of the card. Available options: `before`, `after` */
|
|
22
19
|
imagePosition: CardImagePosition;
|
|
23
20
|
/** Controls how the image is sized and aligned within the card. Available options: `default`, `padding around`, `aspect ratio` */
|
|
24
21
|
imageAdjustment: CardImageAdjustment;
|
|
25
22
|
private readonly hasSlotController;
|
|
26
|
-
protected firstUpdated(): void;
|
|
27
23
|
handleImgSlotChange(e: Event): void;
|
|
28
24
|
render(): import("lit-html").TemplateResult;
|
|
29
25
|
}
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { __decorate } from 'tslib';
|
|
2
|
-
import { nothing } from 'lit';
|
|
3
2
|
import { literal, html } from 'lit/static-html.js';
|
|
4
|
-
import {
|
|
3
|
+
import { property } from 'lit/decorators.js';
|
|
5
4
|
import { classMap } from 'lit/directives/class-map.js';
|
|
6
5
|
import { CardElement } from '../../base/card-element.js';
|
|
7
6
|
import { HasSlotController } from '../../utils/slot.js';
|
|
8
7
|
import css_248z from './card.js';
|
|
8
|
+
import { nothing } from 'lit';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* @summary Cards can be used for headers and footers, a wide variety of content, contain contextual background colors and images.
|
|
12
12
|
* @slot default - The content area of the card, placed directly under the title. Accepts any HTML or custom elements.
|
|
13
13
|
* @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.
|
|
14
|
+
* @slot upper - Accepts an element to be displayed above the card content. When used, it overrides image and icon slot content.
|
|
14
15
|
* @slot image - Accepts an image or svg element of the card. Only a single element is allowed to be passed in.
|
|
15
16
|
* @slot icon - Accepts an icon element to visually represent the card. Only a single element is allowed to be passed in.
|
|
16
17
|
* @slot subtitle - The subtitle of the card
|
|
@@ -26,43 +27,42 @@ class SgdsCard extends CardElement {
|
|
|
26
27
|
this.imagePosition = "before";
|
|
27
28
|
/** Controls how the image is sized and aligned within the card. Available options: `default`, `padding around`, `aspect ratio` */
|
|
28
29
|
this.imageAdjustment = "default";
|
|
29
|
-
this.hasSlotController = new HasSlotController(this, "description");
|
|
30
|
-
}
|
|
31
|
-
firstUpdated() {
|
|
32
|
-
if (this._imageNode.length === 0) {
|
|
33
|
-
const icon = this.shadowRoot.querySelector(".card-image");
|
|
34
|
-
icon.style.display = "none";
|
|
35
|
-
}
|
|
36
|
-
if (this._iconNode.length === 0) {
|
|
37
|
-
const media = this.shadowRoot.querySelector(".card-media");
|
|
38
|
-
media.style.display = "none";
|
|
39
|
-
}
|
|
30
|
+
this.hasSlotController = new HasSlotController(this, "image", "icon", "menu", "description");
|
|
40
31
|
}
|
|
41
32
|
handleImgSlotChange(e) {
|
|
42
33
|
const childNodes = e.target.assignedNodes({ flatten: true });
|
|
43
34
|
if (childNodes.length > 1) {
|
|
44
|
-
|
|
35
|
+
console.error("Multiple elements passed into SgdsCard's image slot");
|
|
36
|
+
}
|
|
37
|
+
if (this.hasSlotController.test("icon") && this.hasSlotController.test("icon")) {
|
|
38
|
+
console.error("Both image and icon slots cannot be used together in SgdsCard");
|
|
45
39
|
}
|
|
46
40
|
}
|
|
47
41
|
render() {
|
|
48
42
|
const tag = this.stretchedLink ? literal `a` : literal `div`;
|
|
49
43
|
const cardTabIndex = !this.stretchedLink || this.disabled ? -1 : 0;
|
|
50
44
|
const hasDescriptionSlot = this.hasSlotController.test("description");
|
|
45
|
+
const hasImageSlot = this.hasSlotController.test("image");
|
|
46
|
+
const hasIconSlot = this.hasSlotController.test("icon");
|
|
47
|
+
const hasMenuSlot = this.hasSlotController.test("menu");
|
|
48
|
+
const hasUpperSlot = this.hasSlotController.test("upper");
|
|
51
49
|
return html `
|
|
52
|
-
<${tag}
|
|
50
|
+
<${tag}
|
|
53
51
|
class="card ${classMap({
|
|
54
52
|
disabled: this.disabled
|
|
55
53
|
})}"
|
|
56
54
|
tabindex=${cardTabIndex}
|
|
57
55
|
>
|
|
58
56
|
<div class="card-tinted-bg"></div>
|
|
59
|
-
|
|
60
|
-
<
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
<slot name="icon"></slot>
|
|
57
|
+
|
|
58
|
+
${hasMenuSlot ? html ` <slot name="menu"></slot> ` : nothing}
|
|
59
|
+
<div class=${classMap({ "card-image": hasImageSlot, "card-media": hasIconSlot || hasUpperSlot })}>
|
|
60
|
+
<slot name="upper">
|
|
61
|
+
${hasImageSlot ? html ` <slot name="image" @slotchange=${this.handleImgSlotChange}></slot> ` : nothing}
|
|
62
|
+
${hasIconSlot ? html ` <slot name="icon"></slot> ` : nothing}
|
|
63
|
+
</slot>
|
|
65
64
|
</div>
|
|
65
|
+
|
|
66
66
|
<div class="card-body">
|
|
67
67
|
<div class="card-header-container">
|
|
68
68
|
<div class="card-header">
|
|
@@ -84,12 +84,6 @@ class SgdsCard extends CardElement {
|
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
86
|
SgdsCard.styles = [...CardElement.styles, css_248z];
|
|
87
|
-
__decorate([
|
|
88
|
-
queryAssignedNodes({ slot: "image", flatten: true })
|
|
89
|
-
], SgdsCard.prototype, "_imageNode", void 0);
|
|
90
|
-
__decorate([
|
|
91
|
-
queryAssignedNodes({ slot: "icon", flatten: true })
|
|
92
|
-
], SgdsCard.prototype, "_iconNode", void 0);
|
|
93
87
|
__decorate([
|
|
94
88
|
property({ type: String, reflect: true })
|
|
95
89
|
], SgdsCard.prototype, "imagePosition", void 0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sgds-card.js","sources":["../../../src/components/Card/sgds-card.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"sgds-card.js","sources":["../../../src/components/Card/sgds-card.ts"],"sourcesContent":["import { html, literal } from \"lit/static-html.js\";\nimport { property } from \"lit/decorators.js\";\nimport { classMap } from \"lit/directives/class-map.js\";\nimport { CardElement } from \"../../base/card-element\";\nimport { HasSlotController } from \"../../utils/slot\";\nimport { CardImageAdjustment, CardImagePosition } from \"./types\";\nimport cardStyle from \"./card.css\";\nimport { nothing } from \"lit\";\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 link - Accepts an anchor element. Only a single element is allowed to be passed in.\n */\nexport class SgdsCard extends CardElement {\n static styles = [...CardElement.styles, cardStyle];\n\n /** Sets the image position of the card. Available options: `before`, `after` */\n @property({ type: String, reflect: true }) imagePosition: CardImagePosition = \"before\";\n\n /** Controls how the image is sized and aligned within the card. Available options: `default`, `padding around`, `aspect ratio` */\n @property({ type: String, reflect: true }) imageAdjustment: CardImageAdjustment = \"default\";\n\n private readonly hasSlotController = new HasSlotController(this, \"image\", \"icon\", \"menu\", \"description\");\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(\"icon\") && 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 const hasDescriptionSlot = this.hasSlotController.test(\"description\");\n\n const hasImageSlot = this.hasSlotController.test(\"image\");\n const hasIconSlot = this.hasSlotController.test(\"icon\");\n const hasMenuSlot = this.hasSlotController.test(\"menu\");\n const hasUpperSlot = this.hasSlotController.test(\"upper\");\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 ${hasMenuSlot ? html` <slot name=\"menu\"></slot> ` : nothing}\n <div class=${classMap({ \"card-image\": hasImageSlot, \"card-media\": hasIconSlot || hasUpperSlot })}>\n <slot name=\"upper\">\n ${hasImageSlot ? html` <slot name=\"image\" @slotchange=${this.handleImgSlotChange}></slot> ` : nothing}\n ${hasIconSlot ? html` <slot name=\"icon\"></slot> ` : nothing}\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 ${\n hasDescriptionSlot\n ? html`<p class=\"card-text\">\n <slot name=\"description\"></slot>\n </p>`\n : nothing\n }\n <slot name=\"lower\"></slot>\n <slot name=\"link\" @slotchange=${this.handleLinkSlotChange}></slot>\n </div>\n </${tag}>\n `;\n }\n}\n\nexport default SgdsCard;\n"],"names":["cardStyle"],"mappings":";;;;;;;;;AASA;;;;;;;;;;;;AAYG;AACG,MAAO,QAAS,SAAQ,WAAW,CAAA;AAAzC,IAAA,WAAA,GAAA;;;QAI6C,IAAa,CAAA,aAAA,GAAsB,QAAQ,CAAC;;QAG5C,IAAe,CAAA,eAAA,GAAwB,SAAS,CAAC;AAE3E,QAAA,IAAA,CAAA,iBAAiB,GAAG,IAAI,iBAAiB,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,CAAC,CAAC;KA6D1G;AA3DC,IAAA,mBAAmB,CAAC,CAAQ,EAAA;AAC1B,QAAA,MAAM,UAAU,GAAI,CAAC,CAAC,MAA0B,CAAC,aAAa,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAiC,CAAC;AAElH,QAAA,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE;AACzB,YAAA,OAAO,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;AAE5F,UAAA,EAAA,YAAY,GAAG,IAAI,CAAA,CAAA,gCAAA,EAAmC,IAAI,CAAC,mBAAmB,CAAA,SAAA,CAAW,GAAG,OAAO,CAAA;YACnG,WAAW,GAAG,IAAI,CAAA,CAA6B,2BAAA,CAAA,GAAG,OAAO,CAAA;;;;;;;;AAQC,oEAAA,EAAA,IAAI,CAAC,qBAAqB,CAAA;;;;YAKpF,kBAAkB;cACd,IAAI,CAAA,CAAA;;AAEC,oBAAA,CAAA;AACP,cAAE,OACN,CAAA;;AAEgC,wCAAA,EAAA,IAAI,CAAC,oBAAoB,CAAA;;UAEzD,GAAG,CAAA;KACR,CAAC;KACH;;AApEM,QAAM,CAAA,MAAA,GAAG,CAAC,GAAG,WAAW,CAAC,MAAM,EAAEA,QAAS,CAApC,CAAsC;AAGR,UAAA,CAAA;IAA1C,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,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;;;;"}
|
package/components/index.umd.js
CHANGED
|
@@ -13633,6 +13633,7 @@
|
|
|
13633
13633
|
* @summary Cards can be used for headers and footers, a wide variety of content, contain contextual background colors and images.
|
|
13634
13634
|
* @slot default - The content area of the card, placed directly under the title. Accepts any HTML or custom elements.
|
|
13635
13635
|
* @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.
|
|
13636
|
+
* @slot upper - Accepts an element to be displayed above the card content. When used, it overrides image and icon slot content.
|
|
13636
13637
|
* @slot image - Accepts an image or svg element of the card. Only a single element is allowed to be passed in.
|
|
13637
13638
|
* @slot icon - Accepts an icon element to visually represent the card. Only a single element is allowed to be passed in.
|
|
13638
13639
|
* @slot subtitle - The subtitle of the card
|
|
@@ -13648,43 +13649,42 @@
|
|
|
13648
13649
|
this.imagePosition = "before";
|
|
13649
13650
|
/** Controls how the image is sized and aligned within the card. Available options: `default`, `padding around`, `aspect ratio` */
|
|
13650
13651
|
this.imageAdjustment = "default";
|
|
13651
|
-
this.hasSlotController = new HasSlotController(this, "description");
|
|
13652
|
-
}
|
|
13653
|
-
firstUpdated() {
|
|
13654
|
-
if (this._imageNode.length === 0) {
|
|
13655
|
-
const icon = this.shadowRoot.querySelector(".card-image");
|
|
13656
|
-
icon.style.display = "none";
|
|
13657
|
-
}
|
|
13658
|
-
if (this._iconNode.length === 0) {
|
|
13659
|
-
const media = this.shadowRoot.querySelector(".card-media");
|
|
13660
|
-
media.style.display = "none";
|
|
13661
|
-
}
|
|
13652
|
+
this.hasSlotController = new HasSlotController(this, "image", "icon", "menu", "description");
|
|
13662
13653
|
}
|
|
13663
13654
|
handleImgSlotChange(e) {
|
|
13664
13655
|
const childNodes = e.target.assignedNodes({ flatten: true });
|
|
13665
13656
|
if (childNodes.length > 1) {
|
|
13666
|
-
|
|
13657
|
+
console.error("Multiple elements passed into SgdsCard's image slot");
|
|
13658
|
+
}
|
|
13659
|
+
if (this.hasSlotController.test("icon") && this.hasSlotController.test("icon")) {
|
|
13660
|
+
console.error("Both image and icon slots cannot be used together in SgdsCard");
|
|
13667
13661
|
}
|
|
13668
13662
|
}
|
|
13669
13663
|
render() {
|
|
13670
13664
|
const tag = this.stretchedLink ? literal `a` : literal `div`;
|
|
13671
13665
|
const cardTabIndex = !this.stretchedLink || this.disabled ? -1 : 0;
|
|
13672
13666
|
const hasDescriptionSlot = this.hasSlotController.test("description");
|
|
13667
|
+
const hasImageSlot = this.hasSlotController.test("image");
|
|
13668
|
+
const hasIconSlot = this.hasSlotController.test("icon");
|
|
13669
|
+
const hasMenuSlot = this.hasSlotController.test("menu");
|
|
13670
|
+
const hasUpperSlot = this.hasSlotController.test("upper");
|
|
13673
13671
|
return html `
|
|
13674
|
-
<${tag}
|
|
13672
|
+
<${tag}
|
|
13675
13673
|
class="card ${classMap({
|
|
13676
13674
|
disabled: this.disabled
|
|
13677
13675
|
})}"
|
|
13678
13676
|
tabindex=${cardTabIndex}
|
|
13679
13677
|
>
|
|
13680
13678
|
<div class="card-tinted-bg"></div>
|
|
13681
|
-
|
|
13682
|
-
<
|
|
13683
|
-
|
|
13684
|
-
|
|
13685
|
-
|
|
13686
|
-
<slot name="icon"></slot>
|
|
13679
|
+
|
|
13680
|
+
${hasMenuSlot ? html ` <slot name="menu"></slot> ` : nothing}
|
|
13681
|
+
<div class=${classMap({ "card-image": hasImageSlot, "card-media": hasIconSlot || hasUpperSlot })}>
|
|
13682
|
+
<slot name="upper">
|
|
13683
|
+
${hasImageSlot ? html ` <slot name="image" @slotchange=${this.handleImgSlotChange}></slot> ` : nothing}
|
|
13684
|
+
${hasIconSlot ? html ` <slot name="icon"></slot> ` : nothing}
|
|
13685
|
+
</slot>
|
|
13687
13686
|
</div>
|
|
13687
|
+
|
|
13688
13688
|
<div class="card-body">
|
|
13689
13689
|
<div class="card-header-container">
|
|
13690
13690
|
<div class="card-header">
|
|
@@ -13706,12 +13706,6 @@
|
|
|
13706
13706
|
}
|
|
13707
13707
|
}
|
|
13708
13708
|
SgdsCard.styles = [...CardElement.styles, css_248z$S];
|
|
13709
|
-
__decorate([
|
|
13710
|
-
queryAssignedNodes({ slot: "image", flatten: true })
|
|
13711
|
-
], SgdsCard.prototype, "_imageNode", void 0);
|
|
13712
|
-
__decorate([
|
|
13713
|
-
queryAssignedNodes({ slot: "icon", flatten: true })
|
|
13714
|
-
], SgdsCard.prototype, "_iconNode", void 0);
|
|
13715
13709
|
__decorate([
|
|
13716
13710
|
property({ type: String, reflect: true })
|
|
13717
13711
|
], SgdsCard.prototype, "imagePosition", void 0);
|