@repobit/dex-system-design 3.0.3 → 3.1.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/CHANGELOG.md +25 -0
- package/README.md +35 -0
- package/dist/src/components/agent-endpoints/agent-endpoints.d.ts +1 -0
- package/dist/src/components/agent-endpoints/agent-endpoints.js +12 -12
- package/dist/src/components/agent-endpoints/agent-endpoints.js.map +1 -1
- package/dist/src/components/anchor/anchor-nav.d.ts +2 -1
- package/dist/src/components/anchor/anchor-nav.js +10 -10
- package/dist/src/components/anchor/anchor-nav.js.map +1 -1
- package/dist/src/components/audience-card/audience-card.css.js +1 -1
- package/dist/src/components/audience-card/audience-card.css.js.map +1 -1
- package/dist/src/components/audience-card/audience-card.d.ts +1 -0
- package/dist/src/components/audience-card/audience-card.js +8 -8
- package/dist/src/components/audience-card/audience-card.js.map +1 -1
- package/dist/src/components/awards/awards-flex.d.ts +3 -2
- package/dist/src/components/awards/awards-flex.js +16 -16
- package/dist/src/components/awards/awards-flex.js.map +1 -1
- package/dist/src/components/awards/awards-spotlight.d.ts +2 -1
- package/dist/src/components/awards/awards-spotlight.js +8 -8
- package/dist/src/components/awards/awards-spotlight.js.map +1 -1
- package/dist/src/components/awards/awards.d.ts +1 -1
- package/dist/src/components/bento-grid/bento-grid.d.ts +1 -0
- package/dist/src/components/bento-grid/bento-grid.js +10 -10
- package/dist/src/components/bento-grid/bento-grid.js.map +1 -1
- package/dist/src/components/bento-grid/bento-item.css.js +1 -1
- package/dist/src/components/bento-grid/bento-item.css.js.map +1 -1
- package/dist/src/components/bento-grid/bento-item.d.ts +1 -0
- package/dist/src/components/bento-grid/bento-item.js +9 -9
- package/dist/src/components/bento-grid/bento-item.js.map +1 -1
- package/dist/src/components/button/button.d.ts +1 -1
- package/dist/src/components/cards/card.d.ts +2 -2
- package/dist/src/components/cards/card.js +11 -11
- package/dist/src/components/cards/card.js.map +1 -1
- package/dist/src/components/carousel/carousel.d.ts +2 -2
- package/dist/src/components/carousel/carousel.js +6 -6
- package/dist/src/components/carousel/carousel.js.map +1 -1
- package/dist/src/components/comparison-panel/comparison-panel.d.ts +1 -0
- package/dist/src/components/comparison-panel/comparison-panel.js +12 -12
- package/dist/src/components/comparison-panel/comparison-panel.js.map +1 -1
- package/dist/src/components/compatibility-table/compatibility-table.d.ts +1 -0
- package/dist/src/components/compatibility-table/compatibility-table.js +14 -14
- package/dist/src/components/compatibility-table/compatibility-table.js.map +1 -1
- package/dist/src/components/cta-banner/cta-banner.d.ts +1 -0
- package/dist/src/components/cta-banner/cta-banner.js +8 -8
- package/dist/src/components/cta-banner/cta-banner.js.map +1 -1
- package/dist/src/components/grid/grid.css.js +1 -1
- package/dist/src/components/grid/grid.css.js.map +1 -1
- package/dist/src/components/grid/grid.d.ts +1 -0
- package/dist/src/components/grid/grid.js +4 -3
- package/dist/src/components/grid/grid.js.map +1 -1
- package/dist/src/components/header/header-code.d.ts +3 -2
- package/dist/src/components/header/header-code.js +13 -13
- package/dist/src/components/header/header-code.js.map +1 -1
- package/dist/src/components/heading/heading.d.ts +1 -1
- package/dist/src/components/heading/heading.js +5 -1
- package/dist/src/components/heading/heading.js.map +1 -1
- package/dist/src/components/hero/hero.d.ts +2 -1
- package/dist/src/components/hero/hero.js +9 -9
- package/dist/src/components/hero/hero.js.map +1 -1
- package/dist/src/components/install-options/install-options.d.ts +3 -2
- package/dist/src/components/install-options/install-options.js +17 -17
- package/dist/src/components/install-options/install-options.js.map +1 -1
- package/dist/src/components/link/link.d.ts +1 -1
- package/dist/src/components/list/list-item/list-item.d.ts +1 -1
- package/dist/src/components/logo-marquee/logo-marquee.d.ts +1 -0
- package/dist/src/components/logo-marquee/logo-marquee.js +5 -5
- package/dist/src/components/logo-marquee/logo-marquee.js.map +1 -1
- package/dist/src/components/motion-art/motion-art.js +1 -1
- package/dist/src/components/motion-art/motion-art.js.map +1 -1
- package/dist/src/components/overview/overview.d.ts +1 -0
- package/dist/src/components/overview/overview.js +7 -7
- package/dist/src/components/overview/overview.js.map +1 -1
- package/dist/src/components/page-switcher/page-switcher.d.ts +1 -0
- package/dist/src/components/page-switcher/page-switcher.js +5 -5
- package/dist/src/components/page-switcher/page-switcher.js.map +1 -1
- package/dist/src/components/pagination-dots/pagination-dots.d.ts +1 -1
- package/dist/src/components/partner-banner/partner-banner.d.ts +1 -0
- package/dist/src/components/partner-banner/partner-banner.js +7 -7
- package/dist/src/components/partner-banner/partner-banner.js.map +1 -1
- package/dist/src/components/post-card/post-card.d.ts +1 -0
- package/dist/src/components/post-card/post-card.js +5 -5
- package/dist/src/components/post-card/post-card.js.map +1 -1
- package/dist/src/components/process-steps/process-steps.d.ts +1 -0
- package/dist/src/components/process-steps/process-steps.js +7 -7
- package/dist/src/components/process-steps/process-steps.js.map +1 -1
- package/dist/src/components/quick-answer/quick-answer.d.ts +1 -0
- package/dist/src/components/quick-answer/quick-answer.js +7 -7
- package/dist/src/components/quick-answer/quick-answer.js.map +1 -1
- package/dist/src/components/review/review-grid.d.ts +1 -0
- package/dist/src/components/review/review-grid.js +3 -3
- package/dist/src/components/review/review-grid.js.map +1 -1
- package/dist/src/components/review/review.d.ts +1 -0
- package/dist/src/components/review/review.js +2 -2
- package/dist/src/components/review/review.js.map +1 -1
- package/dist/src/components/section-header/section-header.d.ts +1 -0
- package/dist/src/components/section-header/section-header.js +4 -4
- package/dist/src/components/section-header/section-header.js.map +1 -1
- package/dist/src/components/shared/controller.observer.d.ts +50 -0
- package/dist/src/components/shared/controller.observer.js +2 -0
- package/dist/src/components/shared/controller.observer.js.map +1 -0
- package/dist/src/components/spotlight-section/spotlight-section.d.ts +1 -0
- package/dist/src/components/spotlight-section/spotlight-section.js +7 -7
- package/dist/src/components/spotlight-section/spotlight-section.js.map +1 -1
- package/dist/src/components/stat/stat-highlight.d.ts +5 -5
- package/dist/src/components/stat/stat-highlight.js +2 -2
- package/dist/src/components/stat/stat-highlight.js.map +1 -1
- package/dist/src/components/stat/stat-tile.d.ts +1 -0
- package/dist/src/components/stat/stat-tile.js +5 -5
- package/dist/src/components/stat/stat-tile.js.map +1 -1
- package/dist/src/components/terminal/terminal-cursor.d.ts +1 -0
- package/dist/src/components/terminal/terminal-cursor.js +1 -1
- package/dist/src/components/terminal/terminal-cursor.js.map +1 -1
- package/dist/src/components/terminal/terminal-message.d.ts +4 -3
- package/dist/src/components/terminal/terminal-message.js +25 -25
- package/dist/src/components/terminal/terminal-message.js.map +1 -1
- package/dist/src/components/tooltip/tooltip.js +1 -1
- package/dist/src/components/tooltip/tooltip.js.map +1 -1
- package/dist/src/components/trust-panel/trust-panel.d.ts +1 -0
- package/dist/src/components/trust-panel/trust-panel.js +19 -19
- package/dist/src/components/trust-panel/trust-panel.js.map +1 -1
- package/dist/src/loader/create-loader.d.ts +13 -0
- package/dist/src/loader/create-loader.js +2 -0
- package/dist/src/loader/create-loader.js.map +1 -0
- package/dist/src/loader/loader.d.ts +44 -0
- package/dist/src/loader/loader.js +2 -0
- package/dist/src/loader/loader.js.map +1 -0
- package/dist/src/loader/registry.d.ts +2 -0
- package/dist/src/loader/registry.js +2 -0
- package/dist/src/loader/registry.js.map +1 -0
- package/dist/src/tokens/tokens.js +1 -1
- package/dist/src/tokens/tokens.js.map +1 -1
- package/package.json +12 -4
- package/schemas/component-manifest.json +8 -1
- package/dist/src/tokens/dark-derivation.d.ts +0 -70
- package/dist/src/tokens/dark-derivation.js +0 -2
- package/dist/src/tokens/dark-derivation.js.map +0 -1
- package/dist/src/tokens/dark-findings.d.ts +0 -59
- package/dist/src/tokens/dark-findings.js +0 -2
- package/dist/src/tokens/dark-findings.js.map +0 -1
- package/dist/src/tokens/story-chrome.d.ts +0 -72
- package/dist/src/tokens/story-chrome.js +0 -292
- package/dist/src/tokens/story-chrome.js.map +0 -1
- package/dist/src/tokens/token-map.d.ts +0 -114
- package/dist/src/tokens/token-map.js +0 -2
- package/dist/src/tokens/token-map.js.map +0 -1
- package/dist/src/tokens/token-purposes.d.ts +0 -63
- package/dist/src/tokens/token-purposes.js +0 -2
- package/dist/src/tokens/token-purposes.js.map +0 -1
- package/dist/src/tokens/type-ceiling-words.d.ts +0 -96
- package/dist/src/tokens/type-ceiling-words.js +0 -2
- package/dist/src/tokens/type-ceiling-words.js.map +0 -1
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import{defineElement as e}from"../shared/define-element.js";import
|
|
1
|
+
import{defineElement as e}from"../shared/define-element.js";import"../../tokens/tokens.js";import t from"../../_bundled/oxc-project_runtime/helpers/esm/decorate.js";import"../heading/heading.js";import"../paragraph/paragraph.js";import"../badge/badge.js";import n from"./bento-item.css.js";import{LitElement as r,html as i}from"lit";import{property as a}from"lit/decorators.js";var o=class extends r{constructor(...e){super(...e),this.title=``,this.body=``,this.icon=``,this.priority=`standard`,this.orientation=`auto`,this.tone=`default`,this.badge=``,this.as=`h3`}static{this.styles=[n]}connectedCallback(){super.connectedCallback(),this.hasAttribute(`role`)||this.setAttribute(`role`,`listitem`)}_renderBrand(){return i`
|
|
2
2
|
<div class="bd-bentoitem-box bd-bentoitem-brand">
|
|
3
3
|
<div class="bd-bentoitem-text">
|
|
4
|
-
${this.badge?
|
|
5
|
-
${this.title?
|
|
6
|
-
${this.body?
|
|
4
|
+
${this.badge?i`<bd-badge tone="info" variant="shade" size="sm">${this.badge}</bd-badge>`:``}
|
|
5
|
+
${this.title?i`<bd-h as="${this.as}" visual-level="h3" color="on-brand" class="bd-bentoitem-brand-title"><span class="text">${this.title}</span></bd-h>`:``}
|
|
6
|
+
${this.body?i`<p class="bd-bentoitem-brand-body">${this.body}</p>`:``}
|
|
7
7
|
</div>
|
|
8
8
|
<div class="bd-bentoitem-media"><slot name="media"></slot></div>
|
|
9
9
|
<div class="bd-bentoitem-cta"><slot></slot></div>
|
|
10
10
|
</div>
|
|
11
|
-
`}render(){return this.tone===`brand`?this._renderBrand():
|
|
11
|
+
`}render(){return this.tone===`brand`?this._renderBrand():i`
|
|
12
12
|
<div class="bd-bentoitem-box">
|
|
13
13
|
<div class="bd-bentoitem-icon-wrap">
|
|
14
14
|
<slot name="icon">
|
|
15
|
-
${this.icon?
|
|
15
|
+
${this.icon?i`<img src="${this.icon}" alt="" class="bd-bentoitem-icon" />`:``}
|
|
16
16
|
</slot>
|
|
17
17
|
</div>
|
|
18
18
|
|
|
19
|
-
${this.title?
|
|
19
|
+
${this.title?i`
|
|
20
20
|
<div class="bd-bentoitem-title-wrap">
|
|
21
21
|
<bd-h as="h5" fontWeight="bold"><span class="text">${this.title}</span></bd-h>
|
|
22
22
|
</div>
|
|
23
23
|
`:``}
|
|
24
24
|
|
|
25
|
-
${this.body?
|
|
25
|
+
${this.body?i`<bd-p variant="regular" class="bd-bentoitem-body"><span class="text">${this.body}</span></bd-p>`:``}
|
|
26
26
|
|
|
27
27
|
<slot></slot>
|
|
28
28
|
</div>
|
|
29
|
-
`}};
|
|
29
|
+
`}};t([a({type:String})],o.prototype,`title`,void 0),t([a({type:String})],o.prototype,`body`,void 0),t([a({type:String})],o.prototype,`icon`,void 0),t([a({type:String,reflect:!0})],o.prototype,`priority`,void 0),t([a({type:String,attribute:`orientation`})],o.prototype,`orientation`,void 0),t([a({type:String,reflect:!0})],o.prototype,`tone`,void 0),t([a({type:String})],o.prototype,`badge`,void 0),t([a({type:String})],o.prototype,`as`,void 0),o=t([e(`bd-bento-item`)],o);
|
|
30
30
|
//# sourceMappingURL=bento-item.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bento-item.js","names":["bentoItemCSS","_decorate","__decorate","bento_item_css_default","BentoItem","LitElement","_args","
|
|
1
|
+
{"version":3,"file":"bento-item.js","names":["bentoItemCSS","_decorate","__decorate","bento_item_css_default","BentoItem","LitElement","_args","property","defineElement"],"sources":["../../../../src/components/bento-grid/bento-item.ts"],"sourcesContent":["import { LitElement, html } from \"lit\";\nimport { property } from \"lit/decorators.js\";\nimport { defineElement } from \"#shared/define-element.ts\";\n// Installs the design tokens into document scope; see src/tokens/tokens.ts\nimport \"#tokens/tokens.ts\";\nimport \"#components/badge/badge.ts\";\nimport \"#components/heading/heading.ts\";\nimport \"#components/paragraph/paragraph.ts\";\nimport bentoItemCSS from \"./bento-item.css.ts\";\n\ntype Priority = \"standard\" | \"featured\";\ntype Tone = \"default\" | \"tint\" | \"dark\" | \"brand\";\n\n@defineElement(\"bd-bento-item\")\nclass BentoItem extends LitElement {\n static styles = [bentoItemCSS];\n\n @property({ type: String })\n title = \"\";\n @property({ type: String })\n body = \"\";\n @property({ type: String })\n icon = \"\";\n @property({ type: String, reflect: true })\n priority: Priority = \"standard\";\n @property({ type: String, attribute: \"orientation\" })\n orientation = \"auto\";\n // \"default\" (neutral-25 fill) | \"tint\" (light blue fill) | \"dark\" (dark fill, light text)\n // | \"brand\" (the homepage AI cards: brand fill, a badge, an h3 and an art column)\n @property({ type: String, reflect: true })\n tone: Tone = \"default\";\n // the small label over the title; drawn only on tone=\"brand\"\n @property({ type: String })\n badge = \"\";\n // the title's level in the outline; tone=\"brand\" draws it at the h3 role\n @property({ type: String })\n as = \"h3\";\n\n connectedCallback() {\n super.connectedCallback();\n // The grid's track is a role=\"list\"; each card is one of its items.\n if (!this.hasAttribute(\"role\")) this.setAttribute(\"role\", \"listitem\");\n }\n\n /* The homepage AI card, drawn in the foundation Figma file as Bento card:\n the copy -- an info badge, the title at h3 and the body in the brand's\n ink --, the art from the `media` slot, and the CTA, the default slot (an\n outline-white bd-button-link, lg). In that order on a phone, a column;\n from md the copy and the CTA stack on the near side and the art fills the\n rest of the card. */\n _renderBrand() {\n return html`\n <div class=\"bd-bentoitem-box bd-bentoitem-brand\">\n <div class=\"bd-bentoitem-text\">\n ${this.badge ? html`<bd-badge tone=\"info\" variant=\"shade\" size=\"sm\">${this.badge}</bd-badge>` : \"\"}\n ${this.title\n ? html`<bd-h as=\"${this.as}\" visual-level=\"h3\" color=\"on-brand\" class=\"bd-bentoitem-brand-title\"><span class=\"text\">${this.title}</span></bd-h>`\n : \"\"}\n ${this.body ? html`<p class=\"bd-bentoitem-brand-body\">${this.body}</p>` : \"\"}\n </div>\n <div class=\"bd-bentoitem-media\"><slot name=\"media\"></slot></div>\n <div class=\"bd-bentoitem-cta\"><slot></slot></div>\n </div>\n `;\n }\n\n render() {\n if (this.tone === \"brand\") return this._renderBrand();\n return html`\n <div class=\"bd-bentoitem-box\">\n <div class=\"bd-bentoitem-icon-wrap\">\n <slot name=\"icon\">\n ${this.icon ? html`<img src=\"${this.icon}\" alt=\"\" class=\"bd-bentoitem-icon\" />` : \"\"}\n </slot>\n </div>\n\n ${this.title\n ? html`\n <div class=\"bd-bentoitem-title-wrap\">\n <bd-h as=\"h5\" fontWeight=\"bold\"><span class=\"text\">${this.title}</span></bd-h>\n </div>\n `\n : \"\"}\n\n ${this.body\n ? html`<bd-p variant=\"regular\" class=\"bd-bentoitem-body\"><span class=\"text\">${this.body}</span></bd-p>`\n : \"\"}\n\n <slot></slot>\n </div>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"bd-bento-item\": BentoItem;\n }\n}"],"mappings":"A,0XAaA,IACMI,EADN,cACwBC,CAAW,C,8BAIzB,KAAA,MAAA,GAED,KAAA,KAAA,GAEA,KAAA,KAAA,GAEc,KAAA,SAAA,WAEP,KAAA,YAAA,OAID,KAAA,KAAA,UAGL,KAAA,MAAA,GAGH,KAAA,GAAA,I,QArBW,KAAA,OAAA,CAACL,CAAY,C,CAuB7B,mBAAoB,CAClB,MAAM,kBAAkB,EAEnB,KAAK,aAAa,MAAM,GAAG,KAAK,aAAa,OAAQ,UAAU,CACtE,CAQA,cAAe,CACb,MAAO,EAAI;;;YAGH,KAAK,MAAQ,CAAI,mDAAmD,KAAK,MAAM,aAAe,GAAG;YACjG,KAAK,MACH,CAAI,aAAa,KAAK,GAAG,2FAA2F,KAAK,MAAM,gBAC/H,GAAG;YACL,KAAK,KAAO,CAAI,sCAAsC,KAAK,KAAK,MAAQ,GAAG;;;;;KAMrF,CAEA,QAAS,CAEP,OADI,KAAK,OAAS,QAAgB,KAAK,aAAa,EAC7C,CAAI;;;;cAID,KAAK,KAAO,CAAI,aAAa,KAAK,KAAK,uCAAyC,GAAG;;;;UAIvF,KAAK,MACH,CAAI;;qEAEqD,KAAK,MAAM;;cAGpE,GAAG;;UAEL,KAAK,KACH,CAAI,wEAAwE,KAAK,KAAK,gBACtF,GAAG;;;;KAKb,CACF,EA3EGC,EAAA,CAAAM,EAAS,CAAE,KAAM,MAAO,CAAC,CAAA,EAAAH,EAAA,UAAA,QAAA,IAAA,EAAA,EAEzBH,EAAA,CAAAM,EAAS,CAAE,KAAM,MAAO,CAAC,CAAA,EAAAH,EAAA,UAAA,OAAA,IAAA,EAAA,EAEzBH,EAAA,CAAAM,EAAS,CAAE,KAAM,MAAO,CAAC,CAAA,EAAAH,EAAA,UAAA,OAAA,IAAA,EAAA,EAEzBH,EAAA,CAAAM,EAAS,CAAE,KAAM,OAAQ,QAAS,EAAK,CAAC,CAAA,EAAAH,EAAA,UAAA,WAAA,IAAA,EAAA,EAExCH,EAAA,CAAAM,EAAS,CAAE,KAAM,OAAQ,UAAW,aAAc,CAAC,CAAA,EAAAH,EAAA,UAAA,cAAA,IAAA,EAAA,EAInDH,EAAA,CAAAM,EAAS,CAAE,KAAM,OAAQ,QAAS,EAAK,CAAC,CAAA,EAAAH,EAAA,UAAA,OAAA,IAAA,EAAA,EAGxCH,EAAA,CAAAM,EAAS,CAAE,KAAM,MAAO,CAAC,CAAA,EAAAH,EAAA,UAAA,QAAA,IAAA,EAAA,EAGzBH,EAAA,CAAAM,EAAS,CAAE,KAAM,MAAO,CAAC,CAAA,EAAAH,EAAA,UAAA,KAAA,IAAA,EAAA,EAtB3B,EAAAH,EAAA,CAAAO,EAAc,eAAe,CAAA,EAAAJ,CAAA"}
|
|
@@ -72,7 +72,7 @@ declare class BdButtonBase extends LitElement {
|
|
|
72
72
|
* resizes it at the breakpoint along with the circle.
|
|
73
73
|
*/
|
|
74
74
|
get _describedBy(): typeof nothing | "description";
|
|
75
|
-
get _description(): import("lit-html").TemplateResult<1
|
|
75
|
+
get _description(): typeof nothing | import("lit-html").TemplateResult<1>;
|
|
76
76
|
get _iconContent(): import("lit-html").TemplateResult<1>;
|
|
77
77
|
_handleClick(e: MouseEvent): void;
|
|
78
78
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { LitElement } from "lit";
|
|
2
|
+
import { ObserverController } from "../shared/controller.observer.js";
|
|
2
3
|
import "../../tokens/tokens.js";
|
|
3
4
|
import "../button/button.js";
|
|
4
5
|
import "../heading/heading.js";
|
|
@@ -10,14 +11,13 @@ declare class Card extends LitElement {
|
|
|
10
11
|
subtitle: string;
|
|
11
12
|
bgBlue: boolean;
|
|
12
13
|
variant: Variant;
|
|
13
|
-
|
|
14
|
+
_content: ObserverController<MutationObserver>;
|
|
14
15
|
_getColumnCount(itemCount: number): number;
|
|
15
16
|
_syncColumns(): void;
|
|
16
17
|
_propagateVariant(): void;
|
|
17
18
|
_syncAlignRows(): void;
|
|
18
19
|
_onSlotChange: () => void;
|
|
19
20
|
firstUpdated(): void;
|
|
20
|
-
disconnectedCallback(): void;
|
|
21
21
|
/**
|
|
22
22
|
* Level is the document-outline question and belongs to page composition;
|
|
23
23
|
* the type scale is this component's and stays where it was. visual-level
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import{defineElement as e}from"../shared/define-element.js";import"../../tokens/tokens.js";import t from"../../_bundled/oxc-project_runtime/helpers/esm/decorate.js";import"../heading/heading.js";import{ensembleCSS as n}from"../shared/ensemble.css.js";import"../button/button.js";import r from"./card.css.js";import{LitElement as
|
|
1
|
+
import{defineElement as e}from"../shared/define-element.js";import"../../tokens/tokens.js";import t from"../../_bundled/oxc-project_runtime/helpers/esm/decorate.js";import"../heading/heading.js";import{ensembleCSS as n}from"../shared/ensemble.css.js";import"../button/button.js";import{ObserverController as r}from"../shared/controller.observer.js";import i from"./card.css.js";import{LitElement as a,html as o}from"lit";import{property as s}from"lit/decorators.js";var c=class extends a{constructor(...e){super(...e),this.title=``,this.headingLevel=2,this.subtitle=``,this.bgBlue=!1,this.variant=``,this._content=new r(this,()=>new MutationObserver(()=>this._syncAlignRows()),e=>{e.observe(this,{childList:!0,subtree:!0}),this.hasUpdated&&this._syncAlignRows()}),this._onSlotChange=()=>{this._propagateVariant(),this._syncAlignRows(),this._syncColumns()}}static{this.styles=[n,i]}_getColumnCount(e){return e<=4?e:e<=6?3:e<=8?4:e===9?3:4}_syncColumns(){let e=[...this.querySelectorAll(`bd-card-item`)],t=e.length,n=this._getColumnCount(t),r=Math.min(n,3);this.style.setProperty(`--bd-card-cols`,String(n)),this.style.setProperty(`--bd-card-tracks`,String(n*2)),this.style.setProperty(`--bd-card-tracks-md`,String(r*2));let i=e=>{let n=t%e;return n?{first:t-n,start:e-n+1}:null},a=i(n),o=i(r);e.forEach((e,t)=>{a?.first===t?e.style.setProperty(`--bd-card-start`,String(a.start)):e.style.removeProperty(`--bd-card-start`),o?.first===t?e.style.setProperty(`--bd-card-start-md`,String(o.start)):e.style.removeProperty(`--bd-card-start-md`)})}_propagateVariant(){this.variant&&this.querySelectorAll(`bd-card-item`).forEach(e=>{e._authorSetVariant||(e.variant=this.variant)})}_syncAlignRows(){let e=[...this.querySelectorAll(`bd-card-item`)];e.forEach(e=>e.setAttribute(`align-rows`,``));let t=Math.max(0,...e.map(e=>e._contentNodes?.().length??0));this.style.setProperty(`--bd-card-content-rows`,String(t)),this.style.setProperty(`--bd-card-rows`,String(t+3))}firstUpdated(){this._propagateVariant(),this._syncAlignRows(),this._syncColumns()}get _headingTag(){let e=Number(this.headingLevel);return Number.isInteger(e)&&e>=1&&e<=6?`h${e}`:`h2`}render(){return o`
|
|
2
2
|
<section class="bd-ensemble bd-light-carousel-s">
|
|
3
|
-
${this.title?
|
|
3
|
+
${this.title?o`
|
|
4
4
|
<div class="bd-header-light-carousel-s">
|
|
5
5
|
<bd-h as="${this._headingTag}" visual-level="h1" class="bd-section-title-s">${this.title}</bd-h>
|
|
6
|
-
${this.subtitle?
|
|
6
|
+
${this.subtitle?o`<p class="bd-section-subtitle-s">${this.subtitle}</p>`:``}
|
|
7
7
|
</div>
|
|
8
8
|
`:``}
|
|
9
9
|
|
|
@@ -12,12 +12,12 @@ import{defineElement as e}from"../shared/define-element.js";import"../../tokens/
|
|
|
12
12
|
</div>
|
|
13
13
|
|
|
14
14
|
</section>
|
|
15
|
-
`}};t([
|
|
15
|
+
`}};t([s({type:String})],c.prototype,`title`,void 0),t([s({type:Number,attribute:`heading-level`})],c.prototype,`headingLevel`,void 0),t([s({type:String})],c.prototype,`subtitle`,void 0),t([s({type:Boolean,reflect:!0,attribute:`bg-blue`})],c.prototype,`bgBlue`,void 0),t([s({type:String,reflect:!0})],c.prototype,`variant`,void 0),c=t([e(`bd-card-section`)],c);var l=class extends a{static{this.styles=[i]}constructor(){super(),this.title=``,this.subtitle=``,this.icon=``,this.align=`start`,this.bgBlue=!1,this.ctaAlign=``,this.headingLevel=3,this.variant=``,this._authorSetVariant=this.hasAttribute(`variant`)}_renderIcon(){let e=this.querySelector(`[slot='icon']`),t=this.variant===`outline`,n=t?65:48,r=t?75:48;if(e){let t=e.cloneNode(!0);t.setAttribute(`width`,String(n)),t.setAttribute(`height`,String(r)),t.style.maxWidth=`${n}px`,t.style.maxHeight=`${r}px`,t.style.width=`${n}px`,t.style.height=`${r}px`,t.style.objectFit=`contain`,t.style.display=`block`;let i=t.querySelector(`img`);return i&&(i.style.maxWidth=`${n}px`,i.style.maxHeight=`${r}px`,i.style.width=`${n}px`,i.style.height=`${r}px`,i.style.objectFit=`contain`,i.style.display=`block`,i.removeAttribute(`width`),i.removeAttribute(`height`)),t}return this.icon?o`<img
|
|
16
16
|
src="${this.icon}"
|
|
17
17
|
alt=""
|
|
18
18
|
class="bd-light-icon-s"
|
|
19
19
|
style="width: ${n}px; height: ${r}px;"
|
|
20
|
-
/>`:``}_contentNodes(){return[...this.childNodes].filter(e=>{if(e.nodeType===Node.ELEMENT_NODE){let t=e.getAttribute(`slot`);return t!==`icon`&&t!==`cta`}return e.nodeType===Node.TEXT_NODE&&e.textContent.trim()!==``})}_hasContent(){return this._contentNodes().length>0}get _headingTag(){let e=Number(this.headingLevel);return Number.isInteger(e)&&e>=1&&e<=6?`h${e}`:`h3`}render(){let e=this.variant===`outline`,t=this.align===`center`||e,n=this._hasContent(),r=!!this.querySelector(`[slot='cta']`),i=this.ctaAlign||(t?`center`:`start`),
|
|
20
|
+
/>`:``}_contentNodes(){return[...this.childNodes].filter(e=>{if(e.nodeType===Node.ELEMENT_NODE){let t=e.getAttribute(`slot`);return t!==`icon`&&t!==`cta`}return e.nodeType===Node.TEXT_NODE&&e.textContent.trim()!==``})}_hasContent(){return this._contentNodes().length>0}get _headingTag(){let e=Number(this.headingLevel);return Number.isInteger(e)&&e>=1&&e<=6?`h${e}`:`h3`}render(){let e=this.variant===`outline`,t=this.align===`center`||e,n=this._hasContent(),r=!!this.querySelector(`[slot='cta']`),i=this.ctaAlign||(t?`center`:`start`),a=i===`center`?`justify-content: center;`:i===`end`?`justify-content: flex-end;`:`justify-content: flex-start;`;return o`
|
|
21
21
|
<div
|
|
22
22
|
class="bd-light-box-s
|
|
23
23
|
${t?`bd-light-box-center`:``}
|
|
@@ -28,27 +28,27 @@ import{defineElement as e}from"../shared/define-element.js";import"../../tokens/
|
|
|
28
28
|
${this._renderIcon()}
|
|
29
29
|
</div>
|
|
30
30
|
|
|
31
|
-
${this.title?
|
|
31
|
+
${this.title?o`
|
|
32
32
|
<div class="bd-light-title-badge-wrapper-s ${n?``:`bd-light-title-no-content`}">
|
|
33
33
|
<div class="bd-card-title-group">
|
|
34
34
|
<bd-h as="${this._headingTag}" visual-level="h5" fontWeight="bold">${this.title}</bd-h>
|
|
35
|
-
${this.subtitle?
|
|
35
|
+
${this.subtitle?o`<p class="bd-card-item-subtitle">${this.subtitle}</p>`:``}
|
|
36
36
|
</div>
|
|
37
37
|
</div>
|
|
38
38
|
`:``}
|
|
39
39
|
|
|
40
|
-
${n?
|
|
40
|
+
${n?o`
|
|
41
41
|
<div class="bd-card-content-wrapper">
|
|
42
42
|
<slot></slot>
|
|
43
43
|
</div>
|
|
44
44
|
`:``}
|
|
45
45
|
|
|
46
|
-
${r?
|
|
47
|
-
<div class="bd-card-cta-wrapper" style="${
|
|
46
|
+
${r?o`
|
|
47
|
+
<div class="bd-card-cta-wrapper" style="${a}">
|
|
48
48
|
<slot name="cta"></slot>
|
|
49
49
|
</div>
|
|
50
50
|
`:``}
|
|
51
51
|
|
|
52
52
|
</div>
|
|
53
|
-
`}};t([
|
|
53
|
+
`}};t([s({type:String})],l.prototype,`title`,void 0),t([s({type:String})],l.prototype,`subtitle`,void 0),t([s({type:String})],l.prototype,`icon`,void 0),t([s({type:String})],l.prototype,`align`,void 0),t([s({type:Boolean,reflect:!0,attribute:`bg-blue`})],l.prototype,`bgBlue`,void 0),t([s({type:String,attribute:`cta-align`})],l.prototype,`ctaAlign`,void 0),t([s({type:Number,attribute:`heading-level`})],l.prototype,`headingLevel`,void 0),t([s({type:String,reflect:!0})],l.prototype,`variant`,void 0),l=t([e(`bd-card-item`)],l);
|
|
54
54
|
//# sourceMappingURL=card.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"card.js","names":["carouselCSS","_decorate","__decorate","card_css_default","Card","LitElement","_args","ensembleCSS","itemCount","items","count","cols","colsMd","shortRow","left","n","wide","md","i","item","contentRows","property","defineElement","CardItem","iconEl","isOutline","iconW","iconH","clone","innerImg","node","slot","isCentered","hasContent","hasCtaSlot","ctaAlign","ctaJustify"],"sources":["../../../../src/components/cards/card.ts"],"sourcesContent":["import { LitElement, html } from \"lit\";\nimport { property } from \"lit/decorators.js\";\nimport { defineElement } from \"#shared/define-element.ts\";\n// Installs the design tokens into document scope; see src/tokens/tokens.ts\nimport \"#tokens/tokens.ts\";\nimport \"#components/button/button.ts\";\nimport \"#components/heading/heading.ts\";\nimport carouselCSS from \"./card.css.ts\";\nimport { ensembleCSS } from \"#shared/ensemble.css.ts\";\n\ntype Variant = \"\" | \"outline\";\n\n@defineElement(\"bd-card-section\")\nclass Card extends LitElement {\n static styles = [ensembleCSS, carouselCSS];\n\n @property({ type: String })\n title = \"\";\n @property({ type: Number, attribute: \"heading-level\" })\n headingLevel = 2;\n @property({ type: String })\n subtitle = \"\";\n @property({ type: Boolean, reflect: true, attribute: \"bg-blue\" })\n bgBlue = false;\n // \"\" (default — existing grey-box carousel look) | \"outline\" — bordered,\n // centered cards with a light-blue tint, blue title and centered icon.\n // Propagated to every slotted bd-card-item (see _onSlotChange) unless an\n // item sets its own variant attribute.\n @property({ type: String, reflect: true })\n variant: Variant = \"\";\n\n _mutationObserver: MutationObserver | null = null;\n\n _getColumnCount(itemCount: number) {\n if (itemCount <= 4) return itemCount;\n if (itemCount <= 6) return 3;\n if (itemCount <= 8) return 4;\n if (itemCount === 9) return 3;\n return 4;\n }\n\n /* The column count follows the number of cards, and card.css.ts turns it\n into tracks, so nothing here measures the track. Every card spans two\n tracks of a grid twice as fine, which is what lets a short last row sit\n in the middle, the way the wrapping row this replaces centred it: its\n first card starts as many tracks in as the row is short of cards.\n\n Between md and lg a card's 200px floor fits three to a row, not four,\n so that band has its own count and its own short row. */\n _syncColumns() {\n const items = [...this.querySelectorAll(\"bd-card-item\")];\n const count = items.length;\n const cols = this._getColumnCount(count);\n const colsMd = Math.min(cols, 3);\n this.style.setProperty(\"--bd-card-cols\", String(cols));\n this.style.setProperty(\"--bd-card-tracks\", String(cols * 2));\n this.style.setProperty(\"--bd-card-tracks-md\", String(colsMd * 2));\n\n const shortRow = (n: number) => {\n const left = count % n;\n return left ? { first: count - left, start: n - left + 1 } : null;\n };\n const wide = shortRow(cols);\n const md = shortRow(colsMd);\n items.forEach((item, i) => {\n if (wide?.first === i) item.style.setProperty(\"--bd-card-start\", String(wide.start));\n else item.style.removeProperty(\"--bd-card-start\");\n if (md?.first === i) item.style.setProperty(\"--bd-card-start-md\", String(md.start));\n else item.style.removeProperty(\"--bd-card-start-md\");\n });\n }\n\n // Propagates this.variant onto every slotted bd-card-item that didn't\n // itself declare a variant attribute in its ORIGINAL markup. We can't use\n // item.hasAttribute(\"variant\") here — CardItem's own `variant` property\n // has reflect:true, so Lit reflects its default \"\" onto the attribute on\n // first render, meaning hasAttribute(\"variant\") becomes true for EVERY\n // item almost immediately, even ones the author never touched. Instead\n // we rely on item._authorSetVariant, captured in CardItem's constructor\n // (before Lit's own reflection has a chance to run) — see below.\n _propagateVariant() {\n if (!this.variant) return;\n this.querySelectorAll(\"bd-card-item\").forEach((item) => {\n if (!item._authorSetVariant) {\n item.variant = this.variant;\n }\n });\n }\n\n /* Marks every item as a subgrid of the section (their shadow styles key off\n align-rows) and sizes the shared row tracks: header, title, the longest\n content list, CTA. Above md the cards line up row by row through those\n tracks -- card.css.ts -- which is what the section used to do in script:\n a ResizeObserver, a wait for the fonts, two animation frames and a px\n height written on every card's header, title, content and box.\n\n align-rows was the opt-in to this layout; it is the only one now, so the\n section no longer reads the attribute. */\n _syncAlignRows() {\n const items = [...this.querySelectorAll(\"bd-card-item\")];\n items.forEach((item) => item.setAttribute(\"align-rows\", \"\"));\n\n const contentRows = Math.max(0, ...items.map((item) => item._contentNodes?.().length ?? 0));\n this.style.setProperty(\"--bd-card-content-rows\", String(contentRows));\n this.style.setProperty(\"--bd-card-rows\", String(contentRows + 3));\n }\n\n _onSlotChange = () => {\n this._propagateVariant();\n this._syncAlignRows();\n this._syncColumns();\n }\n\n firstUpdated() {\n this._propagateVariant();\n this._syncAlignRows();\n this._syncColumns();\n\n // Content added to or removed from an item changes its row count, which\n // doesn't trigger slotchange on the section.\n this._mutationObserver = new MutationObserver(() => this._syncAlignRows());\n this._mutationObserver.observe(this, { childList: true, subtree: true });\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n this._mutationObserver?.disconnect();\n }\n\n\n /**\n * Level is the document-outline question and belongs to page composition;\n * the type scale is this component's and stays where it was. visual-level\n * pins the look at h1 so only the semantics move. Defaults to h2, because a\n * reusable section cannot know it is the page's only heading.\n */\n get _headingTag() {\n const n = Number(this.headingLevel);\n return Number.isInteger(n) && n >= 1 && n <= 6 ? `h${n}` : \"h2\";\n }\n\n render() {\n return html`\n <section class=\"bd-ensemble bd-light-carousel-s\">\n ${this.title\n ? html`\n <div class=\"bd-header-light-carousel-s\">\n <bd-h as=\"${this._headingTag}\" visual-level=\"h1\" class=\"bd-section-title-s\">${this.title}</bd-h>\n ${this.subtitle\n ? html`<p class=\"bd-section-subtitle-s\">${this.subtitle}</p>`\n : \"\"}\n </div>\n `\n : \"\"}\n\n <div class=\"bd-light-carousel-track-s\">\n <slot @slotchange=${this._onSlotChange}></slot>\n </div>\n\n </section>\n `;\n }\n}\n\ntype Align = \"start\" | \"center\";\ntype CtaAlign = \"\" | \"start\" | \"center\" | \"end\";\n\n@defineElement(\"bd-card-item\")\nclass CardItem extends LitElement {\n static styles = [carouselCSS];\n\n @property({ type: String })\n title = \"\";\n @property({ type: String })\n subtitle = \"\";\n @property({ type: String })\n icon = \"\";\n @property({ type: String })\n align: Align = \"start\";\n @property({ type: Boolean, reflect: true, attribute: \"bg-blue\" })\n bgBlue = false;\n @property({ type: String, attribute: \"cta-align\" })\n ctaAlign: CtaAlign = \"\";\n @property({ type: Number, attribute: \"heading-level\" })\n headingLevel = 3;\n // \"\" (default) | \"outline\" — see Card.variant above. Reflected so\n // card.css.ts can target it with :host([variant=\"outline\"]).\n @property({ type: String, reflect: true })\n variant: Variant = \"\";\n\n _authorSetVariant: boolean;\n\n constructor() {\n super();\n // Captured BEFORE Lit's own property-to-attribute reflection runs (that\n // happens on first update/render, not here). At this point the DOM\n // parser has already set any attribute the author wrote in markup, so\n // this reliably answers \"did the author explicitly set variant on this\n // element\", independent of whatever default value we assign below.\n this._authorSetVariant = this.hasAttribute(\"variant\");\n }\n\n _renderIcon() {\n const iconEl = this.querySelector<HTMLElement | SVGElement>(\"[slot='icon']\");\n const isOutline = this.variant === \"outline\";\n const iconW = isOutline ? 65 : 48;\n const iconH = isOutline ? 75 : 48;\n\n if (iconEl) {\n const clone = iconEl.cloneNode(true) as typeof iconEl;\n\n // The icon components (bd-globe-icon etc.) size their inner <svg>\n // from their own width/height attributes, not from CSS on the host —\n // setting only clone.style.width/height left the SVG's actual\n // width=\"48\" height=\"48\" attributes untouched, so nothing visibly\n // changed. Overwrite the attributes themselves for anything that\n // looks like an icon component (custom element) or a raw <svg>.\n clone.setAttribute(\"width\", String(iconW));\n clone.setAttribute(\"height\", String(iconH));\n\n clone.style.maxWidth = `${iconW}px`;\n clone.style.maxHeight = `${iconH}px`;\n clone.style.width = `${iconW}px`;\n clone.style.height = `${iconH}px`;\n clone.style.objectFit = \"contain\";\n clone.style.display = \"block\";\n\n const innerImg = clone.querySelector(\"img\");\n if (innerImg) {\n innerImg.style.maxWidth = `${iconW}px`;\n innerImg.style.maxHeight = `${iconH}px`;\n innerImg.style.width = `${iconW}px`;\n innerImg.style.height = `${iconH}px`;\n innerImg.style.objectFit = \"contain\";\n innerImg.style.display = \"block\";\n innerImg.removeAttribute(\"width\");\n innerImg.removeAttribute(\"height\");\n }\n\n return clone;\n }\n\n if (this.icon) {\n return html`<img\n src=\"${this.icon}\"\n alt=\"\"\n class=\"bd-light-icon-s\"\n style=\"width: ${iconW}px; height: ${iconH}px;\"\n />`;\n }\n\n return \"\";\n }\n // Nodes rendered in the default slot — each one is a content row\n _contentNodes() {\n return [...this.childNodes].filter((node) => {\n if (node.nodeType === Node.ELEMENT_NODE) {\n const slot = (node as Element).getAttribute(\"slot\");\n return slot !== \"icon\" && slot !== \"cta\";\n }\n return node.nodeType === Node.TEXT_NODE && (node as Text).textContent.trim() !== \"\";\n });\n }\n\n _hasContent() {\n return this._contentNodes().length > 0;\n }\n\n\n /**\n * One level below the section default. The h5 it used to carry was a type\n * choice, not an outline one, so the size stays on visual-level while the\n * level itself stops skipping three steps below its own section.\n */\n get _headingTag() {\n const n = Number(this.headingLevel);\n return Number.isInteger(n) && n >= 1 && n <= 6 ? `h${n}` : \"h3\";\n }\n\n render() {\n const isOutline = this.variant === \"outline\";\n const isCentered = this.align === \"center\" || isOutline;\n const hasContent = this._hasContent();\n const hasCtaSlot = !!this.querySelector(\"[slot='cta']\");\n const ctaAlign = this.ctaAlign || (isCentered ? \"center\" : \"start\");\n const ctaJustify = ctaAlign === \"center\"\n ? \"justify-content: center;\"\n : ctaAlign === \"end\"\n ? \"justify-content: flex-end;\"\n : \"justify-content: flex-start;\";\n\n return html`\n <div\n class=\"bd-light-box-s\n ${isCentered ? \"bd-light-box-center\" : \"\"}\n ${this.bgBlue ? \"bd-light-box-blue\" : \"\"}\n ${isOutline ? \"bd-light-box-outline\" : \"\"}\"\n >\n <div class=\"bd-light-box-header-s ${isCentered ? \"bd-light-box-header-center\" : \"\"}\">\n ${this._renderIcon()}\n </div>\n\n ${this.title\n ? html`\n <div class=\"bd-light-title-badge-wrapper-s ${!hasContent ? \"bd-light-title-no-content\" : \"\"}\">\n <div class=\"bd-card-title-group\">\n <bd-h as=\"${this._headingTag}\" visual-level=\"h5\" fontWeight=\"bold\">${this.title}</bd-h>\n ${this.subtitle\n ? html`<p class=\"bd-card-item-subtitle\">${this.subtitle}</p>`\n : \"\"}\n </div>\n </div>\n `\n : \"\"}\n\n ${hasContent\n ? html`\n <div class=\"bd-card-content-wrapper\">\n <slot></slot>\n </div>\n `\n : \"\"}\n\n ${hasCtaSlot\n ? html`\n <div class=\"bd-card-cta-wrapper\" style=\"${ctaJustify}\">\n <slot name=\"cta\"></slot>\n </div>\n `\n : \"\"}\n\n </div>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"bd-card-section\": Card;\n \"bd-card-item\" : CardItem;\n }\n}"],"mappings":"A,4YAYA,IACMI,EADN,cACmBC,CAAW,C,8BAIpB,KAAA,MAAA,GAEO,KAAA,aAAA,EAEJ,KAAA,SAAA,GAEF,KAAA,OAAA,GAMU,KAAA,QAAA,GAE0B,KAAA,kBAAA,KA4EvB,KAAA,kBAAA,CACp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AAG;;UAELA,EACE,CAAI;;;;cAKJ,GAAG;;UAELC,EACE,CAAI;wDACwCE,EAAW;;;cAIvD,GAAG;;;KAIb,CACF,EAnKGnC,EAAA,CAAAoB,EAAS,CAAE,KAAM,MAAO,CAAC,CAAA,EAAAE,EAAA,UAAA,QAAA,IAAA,EAAA,EAEzBtB,EAAA,CAAAoB,EAAS,CAAE,KAAM,MAAO,CAAC,CAAA,EAAAE,EAAA,UAAA,WAAA,IAAA,EAAA,EAEzBtB,EAAA,CAAAoB,EAAS,CAAE,KAAM,MAAO,CAAC,CAAA,EAAAE,EAAA,UAAA,OAAA,IAAA,EAAA,EAEzBtB,EAAA,CAAAoB,EAAS,CAAE,KAAM,MAAO,CAAC,CAAA,EAAAE,EAAA,UAAA,QAAA,IAAA,EAAA,EAEzBtB,EAAA,CAAAoB,EAAS,CAAE,KAAM,QAAS,QAAS,GAAM,UAAW,SAAU,CAAC,CAAA,EAAAE,EAAA,UAAA,SAAA,IAAA,EAAA,EAE/DtB,EAAA,CAAAoB,EAAS,CAAE,KAAM,OAAQ,UAAW,WAAY,CAAC,CAAA,EAAAE,EAAA,UAAA,WAAA,IAAA,EAAA,EAEjDtB,EAAA,CAAAoB,EAAS,CAAE,KAAM,OAAQ,UAAW,eAAgB,CAAC,CAAA,EAAAE,EAAA,UAAA,eAAA,IAAA,EAAA,EAIrDtB,EAAA,CAAAoB,EAAS,CAAE,KAAM,OAAQ,QAAS,EAAK,CAAC,CAAA,EAAAE,EAAA,UAAA,UAAA,IAAA,EAAA,EApB1C,EAAAtB,EAAA,CAAAqB,EAAc,cAAc,CAAA,EAAAC,CAAA"}
|
|
1
|
+
{"version":3,"file":"card.js","names":["carouselCSS","_decorate","__decorate","card_css_default","Card","LitElement","_args","ObserverController","observer","ensembleCSS","itemCount","items","count","cols","colsMd","shortRow","left","n","wide","md","i","item","contentRows","property","defineElement","CardItem","iconEl","isOutline","iconW","iconH","clone","innerImg","node","slot","isCentered","hasContent","hasCtaSlot","ctaAlign","ctaJustify"],"sources":["../../../../src/components/cards/card.ts"],"sourcesContent":["import { LitElement, html } from \"lit\";\nimport { property } from \"lit/decorators.js\";\nimport { defineElement } from \"#shared/define-element.ts\";\nimport { ObserverController } from \"#shared/controller.observer.ts\";\n// Installs the design tokens into document scope; see src/tokens/tokens.ts\nimport \"#tokens/tokens.ts\";\nimport \"#components/button/button.ts\";\nimport \"#components/heading/heading.ts\";\nimport carouselCSS from \"./card.css.ts\";\nimport { ensembleCSS } from \"#shared/ensemble.css.ts\";\n\ntype Variant = \"\" | \"outline\";\n\n@defineElement(\"bd-card-section\")\nclass Card extends LitElement {\n static styles = [ensembleCSS, carouselCSS];\n\n @property({ type: String })\n title = \"\";\n @property({ type: Number, attribute: \"heading-level\" })\n headingLevel = 2;\n @property({ type: String })\n subtitle = \"\";\n @property({ type: Boolean, reflect: true, attribute: \"bg-blue\" })\n bgBlue = false;\n // \"\" (default — existing grey-box carousel look) | \"outline\" — bordered,\n // centered cards with a light-blue tint, blue title and centered icon.\n // Propagated to every slotted bd-card-item (see _onSlotChange) unless an\n // item sets its own variant attribute.\n @property({ type: String, reflect: true })\n variant: Variant = \"\";\n\n /* Content added to or removed from an item changes its row count, which\n doesn't trigger slotchange on the section. Watched for as long as the\n section is connected; on a reconnect the rows are counted again at once,\n since nothing reports what changed while it was out of the page. */\n _content = new ObserverController(this,\n () => new MutationObserver(() => this._syncAlignRows()),\n observer => {\n observer.observe(this, { childList: true, subtree: true });\n if (this.hasUpdated) this._syncAlignRows();\n });\n\n _getColumnCount(itemCount: number) {\n if (itemCount <= 4) return itemCount;\n if (itemCount <= 6) return 3;\n if (itemCount <= 8) return 4;\n if (itemCount === 9) return 3;\n return 4;\n }\n\n /* The column count follows the number of cards, and card.css.ts turns it\n into tracks, so nothing here measures the track. Every card spans two\n tracks of a grid twice as fine, which is what lets a short last row sit\n in the middle, the way the wrapping row this replaces centred it: its\n first card starts as many tracks in as the row is short of cards.\n\n Between md and lg a card's 200px floor fits three to a row, not four,\n so that band has its own count and its own short row. */\n _syncColumns() {\n const items = [...this.querySelectorAll(\"bd-card-item\")];\n const count = items.length;\n const cols = this._getColumnCount(count);\n const colsMd = Math.min(cols, 3);\n this.style.setProperty(\"--bd-card-cols\", String(cols));\n this.style.setProperty(\"--bd-card-tracks\", String(cols * 2));\n this.style.setProperty(\"--bd-card-tracks-md\", String(colsMd * 2));\n\n const shortRow = (n: number) => {\n const left = count % n;\n return left ? { first: count - left, start: n - left + 1 } : null;\n };\n const wide = shortRow(cols);\n const md = shortRow(colsMd);\n items.forEach((item, i) => {\n if (wide?.first === i) item.style.setProperty(\"--bd-card-start\", String(wide.start));\n else item.style.removeProperty(\"--bd-card-start\");\n if (md?.first === i) item.style.setProperty(\"--bd-card-start-md\", String(md.start));\n else item.style.removeProperty(\"--bd-card-start-md\");\n });\n }\n\n // Propagates this.variant onto every slotted bd-card-item that didn't\n // itself declare a variant attribute in its ORIGINAL markup. We can't use\n // item.hasAttribute(\"variant\") here — CardItem's own `variant` property\n // has reflect:true, so Lit reflects its default \"\" onto the attribute on\n // first render, meaning hasAttribute(\"variant\") becomes true for EVERY\n // item almost immediately, even ones the author never touched. Instead\n // we rely on item._authorSetVariant, captured in CardItem's constructor\n // (before Lit's own reflection has a chance to run) — see below.\n _propagateVariant() {\n if (!this.variant) return;\n this.querySelectorAll(\"bd-card-item\").forEach((item) => {\n if (!item._authorSetVariant) {\n item.variant = this.variant;\n }\n });\n }\n\n /* Marks every item as a subgrid of the section (their shadow styles key off\n align-rows) and sizes the shared row tracks: header, title, the longest\n content list, CTA. Above md the cards line up row by row through those\n tracks -- card.css.ts -- which is what the section used to do in script:\n a ResizeObserver, a wait for the fonts, two animation frames and a px\n height written on every card's header, title, content and box.\n\n align-rows was the opt-in to this layout; it is the only one now, so the\n section no longer reads the attribute. */\n _syncAlignRows() {\n const items = [...this.querySelectorAll(\"bd-card-item\")];\n items.forEach((item) => item.setAttribute(\"align-rows\", \"\"));\n\n const contentRows = Math.max(0, ...items.map((item) => item._contentNodes?.().length ?? 0));\n this.style.setProperty(\"--bd-card-content-rows\", String(contentRows));\n this.style.setProperty(\"--bd-card-rows\", String(contentRows + 3));\n }\n\n _onSlotChange = () => {\n this._propagateVariant();\n this._syncAlignRows();\n this._syncColumns();\n }\n\n firstUpdated() {\n this._propagateVariant();\n this._syncAlignRows();\n this._syncColumns();\n }\n\n\n /**\n * Level is the document-outline question and belongs to page composition;\n * the type scale is this component's and stays where it was. visual-level\n * pins the look at h1 so only the semantics move. Defaults to h2, because a\n * reusable section cannot know it is the page's only heading.\n */\n get _headingTag() {\n const n = Number(this.headingLevel);\n return Number.isInteger(n) && n >= 1 && n <= 6 ? `h${n}` : \"h2\";\n }\n\n render() {\n return html`\n <section class=\"bd-ensemble bd-light-carousel-s\">\n ${this.title\n ? html`\n <div class=\"bd-header-light-carousel-s\">\n <bd-h as=\"${this._headingTag}\" visual-level=\"h1\" class=\"bd-section-title-s\">${this.title}</bd-h>\n ${this.subtitle\n ? html`<p class=\"bd-section-subtitle-s\">${this.subtitle}</p>`\n : \"\"}\n </div>\n `\n : \"\"}\n\n <div class=\"bd-light-carousel-track-s\">\n <slot @slotchange=${this._onSlotChange}></slot>\n </div>\n\n </section>\n `;\n }\n}\n\ntype Align = \"start\" | \"center\";\ntype CtaAlign = \"\" | \"start\" | \"center\" | \"end\";\n\n@defineElement(\"bd-card-item\")\nclass CardItem extends LitElement {\n static styles = [carouselCSS];\n\n @property({ type: String })\n title = \"\";\n @property({ type: String })\n subtitle = \"\";\n @property({ type: String })\n icon = \"\";\n @property({ type: String })\n align: Align = \"start\";\n @property({ type: Boolean, reflect: true, attribute: \"bg-blue\" })\n bgBlue = false;\n @property({ type: String, attribute: \"cta-align\" })\n ctaAlign: CtaAlign = \"\";\n @property({ type: Number, attribute: \"heading-level\" })\n headingLevel = 3;\n // \"\" (default) | \"outline\" — see Card.variant above. Reflected so\n // card.css.ts can target it with :host([variant=\"outline\"]).\n @property({ type: String, reflect: true })\n variant: Variant = \"\";\n\n _authorSetVariant: boolean;\n\n constructor() {\n super();\n // Captured BEFORE Lit's own property-to-attribute reflection runs (that\n // happens on first update/render, not here). At this point the DOM\n // parser has already set any attribute the author wrote in markup, so\n // this reliably answers \"did the author explicitly set variant on this\n // element\", independent of whatever default value we assign below.\n this._authorSetVariant = this.hasAttribute(\"variant\");\n }\n\n _renderIcon() {\n const iconEl = this.querySelector<HTMLElement | SVGElement>(\"[slot='icon']\");\n const isOutline = this.variant === \"outline\";\n const iconW = isOutline ? 65 : 48;\n const iconH = isOutline ? 75 : 48;\n\n if (iconEl) {\n const clone = iconEl.cloneNode(true) as typeof iconEl;\n\n // The icon components (bd-globe-icon etc.) size their inner <svg>\n // from their own width/height attributes, not from CSS on the host —\n // setting only clone.style.width/height left the SVG's actual\n // width=\"48\" height=\"48\" attributes untouched, so nothing visibly\n // changed. Overwrite the attributes themselves for anything that\n // looks like an icon component (custom element) or a raw <svg>.\n clone.setAttribute(\"width\", String(iconW));\n clone.setAttribute(\"height\", String(iconH));\n\n clone.style.maxWidth = `${iconW}px`;\n clone.style.maxHeight = `${iconH}px`;\n clone.style.width = `${iconW}px`;\n clone.style.height = `${iconH}px`;\n clone.style.objectFit = \"contain\";\n clone.style.display = \"block\";\n\n const innerImg = clone.querySelector(\"img\");\n if (innerImg) {\n innerImg.style.maxWidth = `${iconW}px`;\n innerImg.style.maxHeight = `${iconH}px`;\n innerImg.style.width = `${iconW}px`;\n innerImg.style.height = `${iconH}px`;\n innerImg.style.objectFit = \"contain\";\n innerImg.style.display = \"block\";\n innerImg.removeAttribute(\"width\");\n innerImg.removeAttribute(\"height\");\n }\n\n return clone;\n }\n\n if (this.icon) {\n return html`<img\n src=\"${this.icon}\"\n alt=\"\"\n class=\"bd-light-icon-s\"\n style=\"width: ${iconW}px; height: ${iconH}px;\"\n />`;\n }\n\n return \"\";\n }\n // Nodes rendered in the default slot — each one is a content row\n _contentNodes() {\n return [...this.childNodes].filter((node) => {\n if (node.nodeType === Node.ELEMENT_NODE) {\n const slot = (node as Element).getAttribute(\"slot\");\n return slot !== \"icon\" && slot !== \"cta\";\n }\n return node.nodeType === Node.TEXT_NODE && (node as Text).textContent.trim() !== \"\";\n });\n }\n\n _hasContent() {\n return this._contentNodes().length > 0;\n }\n\n\n /**\n * One level below the section default. The h5 it used to carry was a type\n * choice, not an outline one, so the size stays on visual-level while the\n * level itself stops skipping three steps below its own section.\n */\n get _headingTag() {\n const n = Number(this.headingLevel);\n return Number.isInteger(n) && n >= 1 && n <= 6 ? `h${n}` : \"h3\";\n }\n\n render() {\n const isOutline = this.variant === \"outline\";\n const isCentered = this.align === \"center\" || isOutline;\n const hasContent = this._hasContent();\n const hasCtaSlot = !!this.querySelector(\"[slot='cta']\");\n const ctaAlign = this.ctaAlign || (isCentered ? \"center\" : \"start\");\n const ctaJustify = ctaAlign === \"center\"\n ? \"justify-content: center;\"\n : ctaAlign === \"end\"\n ? \"justify-content: flex-end;\"\n : \"justify-content: flex-start;\";\n\n return html`\n <div\n class=\"bd-light-box-s\n ${isCentered ? \"bd-light-box-center\" : \"\"}\n ${this.bgBlue ? \"bd-light-box-blue\" : \"\"}\n ${isOutline ? \"bd-light-box-outline\" : \"\"}\"\n >\n <div class=\"bd-light-box-header-s ${isCentered ? \"bd-light-box-header-center\" : \"\"}\">\n ${this._renderIcon()}\n </div>\n\n ${this.title\n ? html`\n <div class=\"bd-light-title-badge-wrapper-s ${!hasContent ? \"bd-light-title-no-content\" : \"\"}\">\n <div class=\"bd-card-title-group\">\n <bd-h as=\"${this._headingTag}\" visual-level=\"h5\" fontWeight=\"bold\">${this.title}</bd-h>\n ${this.subtitle\n ? html`<p class=\"bd-card-item-subtitle\">${this.subtitle}</p>`\n : \"\"}\n </div>\n </div>\n `\n : \"\"}\n\n ${hasContent\n ? html`\n <div class=\"bd-card-content-wrapper\">\n <slot></slot>\n </div>\n `\n : \"\"}\n\n ${hasCtaSlot\n ? html`\n <div class=\"bd-card-cta-wrapper\" style=\"${ctaJustify}\">\n <slot name=\"cta\"></slot>\n </div>\n `\n : \"\"}\n\n </div>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"bd-card-section\": Card;\n \"bd-card-item\" : CardItem;\n }\n}"],"mappings":"A,kdAaA,IACMI,EADN,cACmBC,CAAW,C,8BAIpB,KAAA,MAAA,GAEO,KAAA,aAAA,EAEJ,KAAA,SAAA,GAEF,KAAA,OAAA,GAMU,KAAA,QAAA,GAMR,KAAA,SAAA,IAAIE,EAAmB,SAC1B,IAAI,qBAAuB,KAAK,eAAe,CAAC,EACtD,GAAY,CACVC,EAAS,QAAQ,KAAM,CAAE,UAAW,GAAM,QAAS,EAAK,CAAC,EACrD,KAAK,YAAY,KAAK,eAAe,CAC3C,CAAC,EA4EmB,KAAA,kBAAA,CACpB,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACpB,KAAK,aAAa,CACpB,C,QA1GgB,KAAA,OAAA,CAACC,EAAaT,CAAW,C,CA4BzC,gBAAgB,EAAmB,CAKjC,OAJIU,GAAa,EAAUA,EACvBA,GAAa,EAAU,EACvBA,GAAa,EAAU,EACvBA,IAAc,EAAU,EACrB,CACT,CAUA,cAAe,CACb,IAAMC,EAAQ,CAAC,GAAG,KAAK,iBAAiB,cAAc,CAAC,EACjDC,EAAQD,EAAM,OACdE,EAAO,KAAK,gBAAgBD,CAAK,EACjCE,EAAS,KAAK,IAAID,EAAM,CAAC,EAC/B,KAAK,MAAM,YAAY,iBAAkB,OAAOA,CAAI,CAAC,EACrD,KAAK,MAAM,YAAY,mBAAoB,OAAOA,EAAO,CAAC,CAAC,EAC3D,KAAK,MAAM,YAAY,sBAAuB,OAAOC,EAAS,CAAC,CAAC,EAEhE,IAAMC,EAAY,GAAc,CAC9B,IAAMC,EAAOJ,EAAQK,EACrB,OAAOD,EAAO,CAAE,MAAOJ,EAAQI,EAAM,MAAOC,EAAID,EAAO,CAAE,EAAI,IAC/D,EACME,EAAOH,EAASF,CAAI,EACpBM,EAAKJ,E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A,IAAA,EAAA,EApB1C,EAAAxB,EAAA,CAAAuB,EAAc,cAAc,CAAA,EAAAC,CAAA"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { LitElement } from "lit";
|
|
2
|
+
import { ObserverController } from "../shared/controller.observer.js";
|
|
2
3
|
import "../../tokens/tokens.js";
|
|
3
4
|
import "../heading/heading.js";
|
|
4
5
|
import "../icons/plus-icon.js";
|
|
@@ -27,7 +28,7 @@ declare class CustomCarousel extends LitElement {
|
|
|
27
28
|
_shownItem?: ModalItem;
|
|
28
29
|
track: HTMLElement;
|
|
29
30
|
slotElement: HTMLSlotElement;
|
|
30
|
-
|
|
31
|
+
_trackSize: ObserverController<ResizeObserver>;
|
|
31
32
|
constructor();
|
|
32
33
|
/**
|
|
33
34
|
* The heading element this section renders. Level is the document-outline
|
|
@@ -39,7 +40,6 @@ declare class CustomCarousel extends LitElement {
|
|
|
39
40
|
get _headingTag(): string;
|
|
40
41
|
_renderTitle(className: string): import("lit-html").TemplateResult<1>;
|
|
41
42
|
firstUpdated(): void;
|
|
42
|
-
disconnectedCallback(): void;
|
|
43
43
|
waitForImagesToLoad(): Promise<(void | Event)[]>;
|
|
44
44
|
_step(): number;
|
|
45
45
|
_measure(): void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{defineElement as e}from"../shared/define-element.js";import"../../tokens/tokens.js";import t from"../../_bundled/oxc-project_runtime/helpers/esm/decorate.js";import"../heading/heading.js";import"../icons/plus-icon.js";import"../pagination-dots/pagination-dots.js";import
|
|
1
|
+
import{defineElement as e}from"../shared/define-element.js";import"../../tokens/tokens.js";import t from"../../_bundled/oxc-project_runtime/helpers/esm/decorate.js";import"../heading/heading.js";import"../icons/plus-icon.js";import{ObserverController as n}from"../shared/controller.observer.js";import"../pagination-dots/pagination-dots.js";import r from"./carousel.css.js";import"../modal/modal.js";import{LitElement as i,html as a}from"lit";import{property as o,state as s}from"lit/decorators.js";var c=class extends i{_openModal(){this.dispatchEvent(new CustomEvent(`open-modal`,{detail:{title:this.title,modalText:this.modalText,icon:this.icon},bubbles:!0,composed:!0}))}render(){return a`
|
|
2
2
|
<div class="bd-box">
|
|
3
|
-
${this.icon?
|
|
3
|
+
${this.icon?a`<img src="${this.icon}" alt="" class="bd-carousel-icon" />`:``}
|
|
4
4
|
<div class="bd-content">
|
|
5
5
|
<slot></slot>
|
|
6
6
|
</div>
|
|
@@ -13,11 +13,11 @@ import{defineElement as e}from"../shared/define-element.js";import"../../tokens/
|
|
|
13
13
|
<bd-plus-icon size="md"></bd-plus-icon>
|
|
14
14
|
</button>
|
|
15
15
|
</div>
|
|
16
|
-
`}static{this.styles=[
|
|
16
|
+
`}static{this.styles=[r]}};t([o({type:String})],c.prototype,`icon`,void 0),t([o({type:String})],c.prototype,`title`,void 0),t([o({type:String})],c.prototype,`modalText`,void 0),c=t([e(`bd-carousel-item`)],c);var l=class extends i{constructor(){super(),this.title=``,this.headingLevel=2,this.selectedItem=null,this._pages=1,this._page=1,this._trackSize=new n(this,()=>new ResizeObserver(()=>this._measure()),e=>e.observe(this.renderRoot.querySelector(`.bd-carousel-track`))),this._seeking=0}get _headingTag(){let e=Number(this.headingLevel);return Number.isInteger(e)&&e>=1&&e<=6?`h${e}`:`h2`}_renderTitle(e){return a`<bd-h as=${this._headingTag} visual-level="h3" class=${e}
|
|
17
17
|
>${this.title}</bd-h
|
|
18
|
-
>`}firstUpdated(){this.track=this.shadowRoot.querySelector(`.bd-carousel-track`),this.slotElement=this.shadowRoot.querySelector(`slot`),this.track.addEventListener(`scroll`,()=>this._measure(),{passive:!0}),this.track.addEventListener(`scrollend`,()=>{this._seeking=0,this._measure()});for(let e of[`pointerdown`,`touchstart`,`wheel`,`keydown`])this.track.addEventListener(e,()=>{this._seeking=0},{passive:!0});this.slotElement.addEventListener(`slotchange`,()=>{this.waitForImagesToLoad().then(()=>this._measure())}),this.
|
|
18
|
+
>`}firstUpdated(){this.track=this.shadowRoot.querySelector(`.bd-carousel-track`),this.slotElement=this.shadowRoot.querySelector(`slot`),this.track.addEventListener(`scroll`,()=>this._measure(),{passive:!0}),this.track.addEventListener(`scrollend`,()=>{this._seeking=0,this._measure()});for(let e of[`pointerdown`,`touchstart`,`wheel`,`keydown`])this.track.addEventListener(e,()=>{this._seeking=0},{passive:!0});this.slotElement.addEventListener(`slotchange`,()=>{this.waitForImagesToLoad().then(()=>this._measure())}),this.waitForImagesToLoad().then(()=>this._measure()),this.addEventListener(`open-modal`,e=>{this.openModal(e.detail)}),this._enableMouseDrag(this.track)}waitForImagesToLoad(){let e=this.slotElement.assignedElements({flatten:!0}).map(e=>e.shadowRoot?.querySelector(`img`)).filter(e=>e!=null).map(e=>new Promise(t=>{e.complete?t():(e.addEventListener(`load`,t,{once:!0}),e.addEventListener(`error`,t,{once:!0}))}));return Promise.all(e)}_step(){let e=this.slotElement?.assignedElements({flatten:!0})[0];if(!e)return 0;let t=parseFloat(getComputedStyle(this.track).columnGap)||0;return e.offsetWidth+t}_measure(){if(!this.track)return;let e=this.track.scrollWidth-this.track.clientWidth,t=this._step();if(e<=1||t<=0){this._pages=1,this._page=1;return}this._pages=Math.ceil((e-1)/t)+1;let n=this._travelled,r=n>=e-1?this._pages:Math.min(this._pages,Math.round(n/t)+1);this._seeking&&r!==this._seeking||(this._seeking=0,this._page=r)}_stop(e){let t=this.track.scrollWidth-this.track.clientWidth;return Math.min((e-1)*this._step(),t)}get _travelled(){return Math.abs(this.track.scrollLeft)}_scrollToStop(e){let t=getComputedStyle(this.track).direction===`rtl`?-1:1;this.track.scrollTo({left:t*this._stop(e)})}_goToPage(e){this._seeking=e,this._page=e,this._scrollToStop(e)}openModal(e){this.selectedItem=e,this._shownItem=e}closeModal(){this.selectedItem=null}_enableMouseDrag(e){let t=null,n=!1;e.addEventListener(`pointerdown`,n=>{n.pointerType===`mouse`&&n.button===0&&(t={id:n.pointerId,x:n.clientX,left:e.scrollLeft,dragging:!1})}),e.addEventListener(`pointermove`,n=>{if(t?.id!==n.pointerId)return;if(!(n.buttons&1)){t=null;return}let r=n.clientX-t.x;if(!t.dragging){if(Math.abs(r)<4)return;t.dragging=!0,e.setPointerCapture(n.pointerId),e.classList.add(`dragging`)}e.scrollLeft=t.left-r});let r=()=>{let r=t?.dragging;t=null,r&&(e.classList.remove(`dragging`),this._settle(),n=!0,setTimeout(()=>{n=!1}))};for(let t of[`pointerup`,`pointercancel`,`lostpointercapture`])e.addEventListener(t,r);e.addEventListener(`click`,e=>{n&&(e.preventDefault(),e.stopPropagation())},{capture:!0});for(let n of[`selectstart`,`dragstart`])e.addEventListener(n,e=>{t&&e.preventDefault()})}_settle(){let e=this._travelled,t=1;for(let n=2;n<=this._pages;n++)Math.abs(this._stop(n)-e)<Math.abs(this._stop(t)-e)&&(t=n);this._scrollToStop(t)}render(){return a`
|
|
19
19
|
<div class="bd-carousel">
|
|
20
|
-
${this.title?
|
|
20
|
+
${this.title?a`<div class="bd-header-carousel">
|
|
21
21
|
${this._renderTitle(`bd-section-title`)}
|
|
22
22
|
</div>`:``}
|
|
23
23
|
|
|
@@ -46,5 +46,5 @@ import{defineElement as e}from"../shared/define-element.js";import"../../tokens/
|
|
|
46
46
|
.icon="${this._shownItem?.icon??``}"
|
|
47
47
|
@close-modal="${this.closeModal}"
|
|
48
48
|
></bd-modal>
|
|
49
|
-
`}static{this.styles=[
|
|
49
|
+
`}static{this.styles=[r]}};t([o({type:String})],l.prototype,`title`,void 0),t([o({type:Number,attribute:`heading-level`})],l.prototype,`headingLevel`,void 0),t([o({type:Object})],l.prototype,`selectedItem`,void 0),t([s()],l.prototype,`_pages`,void 0),t([s()],l.prototype,`_page`,void 0),l=t([e(`bd-carousel-section`)],l);export{c as CarouselItem};
|
|
50
50
|
//# sourceMappingURL=carousel.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"carousel.js","names":["carouselCSS","_decorate","__decorate","carousel_css_default","CarouselItem","LitElement","property","defineElement","CustomCarousel","n","className","type","promises","el","img","resolve","first","gap","max","step","left","page","sign","item","press","swallowClick","track","e","dx","release","dragged","nearest","state"],"sources":["../../../../src/components/carousel/carousel.ts"],"sourcesContent":["import { LitElement, html } from \"lit\";\nimport { property, state } from \"lit/decorators.js\";\nimport { defineElement } from \"#shared/define-element.ts\";\n// Installs the design tokens into document scope; see src/tokens/tokens.ts\nimport \"#tokens/tokens.ts\";\nimport carouselCSS from \"#components/carousel/carousel.css.ts\";\nimport \"#components/heading/heading.ts\";\nimport \"#components/icons/plus-icon.ts\";\nimport \"#components/modal/modal.ts\";\nimport \"#components/pagination-dots/pagination-dots.ts\";\n\ninterface ModalItem {\n title? : string;\n modalText?: string;\n icon? : string;\n}\n\n@defineElement(\"bd-carousel-item\")\nexport class CarouselItem extends LitElement {\n @property({ type: String })\n icon?: string;\n @property({ type: String })\n title!: string;\n @property({ type: String })\n modalText?: string;\n\n _openModal() {\n this.dispatchEvent(\n new CustomEvent(\"open-modal\", {\n detail: {\n title : this.title,\n modalText: this.modalText,\n icon : this.icon\n },\n bubbles : true,\n composed: true\n })\n );\n }\n\n render() {\n return html`\n <div class=\"bd-box\">\n ${this.icon\n ? html`<img src=\"${this.icon}\" alt=\"\" class=\"bd-carousel-icon\" />`\n : \"\"}\n <div class=\"bd-content\">\n <slot></slot>\n </div>\n <button\n type=\"button\"\n class=\"bd-plus-button\"\n aria-label=\"Open modal for ${this.title}\"\n @click=\"${this._openModal}\"\n >\n <bd-plus-icon size=\"md\"></bd-plus-icon>\n </button>\n </div>\n `;\n }\n\n static styles = [carouselCSS];\n}\n\n@defineElement(\"bd-carousel-section\")\nclass CustomCarousel extends LitElement {\n @property({ type: String })\n title = \"\";\n @property({ type: Number, attribute: \"heading-level\" })\n headingLevel = 2;\n @property({ type: Object })\n selectedItem: ModalItem | null = null;\n // scroll stops, 1-based, read from the track; see _measure\n @state()\n _pages = 1;\n @state()\n _page = 1;\n\n _seeking : number;\n _shownItem? : ModalItem;\n track! : HTMLElement;\n slotElement! : HTMLSlotElement;\n _resizeObserver?: ResizeObserver;\n\n constructor() {\n super();\n this._seeking = 0;\n }\n\n /**\n * The heading element this section renders. Level is the document-outline\n * question and belongs to whoever composes the page; the type scale is this\n * component's own and does not move with it. Defaults to h2, because a\n * reusable section cannot know it is the only thing on the page, and two of\n * these used to put two h1s on one.\n */\n get _headingTag() {\n const n = Number(this.headingLevel);\n return Number.isInteger(n) && n >= 1 && n <= 6 ? `h${n}` : \"h2\";\n }\n\n /* bd-h already builds the dynamic tag, and it keeps the two questions apart\n the way this component needs: as= is the outline level the page composes,\n visual-level= is the type role, which is ours. Building the element here\n meant re-implementing bd-h and then hand-writing the type on top of it --\n and the hand-written type carried no line-height and no margin, so the\n title rendered with the browser's own h2 margins. */\n _renderTitle(className: string) {\n return html`<bd-h as=${this._headingTag} visual-level=\"h3\" class=${className}\n >${this.title}</bd-h\n >`;\n }\n\n firstUpdated() {\n this.track = this.shadowRoot!.querySelector<HTMLElement>(\".bd-carousel-track\")!;\n this.slotElement = this.shadowRoot!.querySelector(\"slot\")!;\n\n this.track.addEventListener(\"scroll\", () => this._measure(), { passive: true });\n this.track.addEventListener(\"scrollend\", () => { this._seeking = 0; this._measure(); });\n // a visitor taking hold of the track ends any scroll a control started\n for (const type of [\"pointerdown\", \"touchstart\", \"wheel\", \"keydown\"]) {\n this.track.addEventListener(type, () => { this._seeking = 0; }, { passive: true });\n }\n\n this.slotElement.addEventListener(\"slotchange\", () => {\n this.waitForImagesToLoad().then(() => this._measure());\n });\n\n this._resizeObserver = new ResizeObserver(() => this._measure());\n this._resizeObserver.observe(this.track);\n\n this.waitForImagesToLoad().then(() => this._measure());\n\n this.addEventListener(\"open-modal\", (e) => {\n this.openModal(e.detail);\n });\n this._enableMouseDrag(this.track);\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n this._resizeObserver?.disconnect();\n }\n\n waitForImagesToLoad() {\n const assignedElements = this.slotElement.assignedElements({\n flatten: true\n });\n const images = assignedElements\n .map((el) => el.shadowRoot?.querySelector(\"img\"))\n .filter((img) => img != null);\n const promises = images.map(\n (img) =>\n new Promise<Event | void>((resolve) => {\n if (img.complete) resolve();\n else {\n img.addEventListener(\"load\", resolve, { once: true });\n img.addEventListener(\"error\", resolve, { once: true });\n }\n })\n );\n return Promise.all(promises);\n }\n\n /* The distance from one item to the next: an item's width and the gap. A\n scroll stop is one of these, and the controls count stops, not items --\n the last stop is wherever the track ends, which is short of a full step\n when the items do not divide the width evenly. */\n _step() {\n const first = this.slotElement?.assignedElements({ flatten: true })[0];\n if (!first) return 0;\n const gap = parseFloat(getComputedStyle(this.track).columnGap) || 0;\n return (first as HTMLElement).offsetWidth + gap;\n }\n\n /* How many stops the track has and which one it is at, from where it has\n scrolled to -- by a control, a drag, a wheel or a keyboard. While a\n control's smooth scroll is on its way, the dot it asked for stays current\n rather than stepping through every stop it passes. */\n _measure() {\n if (!this.track) return;\n const max = this.track.scrollWidth - this.track.clientWidth;\n const step = this._step();\n if (max <= 1 || step <= 0) {\n this._pages = 1;\n this._page = 1;\n return;\n }\n this._pages = Math.ceil((max - 1) / step) + 1;\n const left = this._travelled;\n const page = left >= max - 1 ? this._pages : Math.min(this._pages, Math.round(left / step) + 1);\n if (this._seeking && page !== this._seeking) return;\n this._seeking = 0;\n this._page = page;\n }\n\n /* Where stop n sits, as a distance from the track's start: a whole step per\n stop, and the last at the track's end. */\n _stop(n: number) {\n const max = this.track.scrollWidth - this.track.clientWidth;\n return Math.min((n - 1) * this._step(), max);\n }\n\n /* How far the track has scrolled from its start. On a right-to-left page\n the start is the right edge and scrollLeft runs from 0 down to minus the\n overflow, so the distance is its size and a position written back takes\n its sign; read as a plain number, every stop past the first sat at a\n scrollLeft the track can never reach, and scrolling to one clamped to the\n start. */\n get _travelled() {\n return Math.abs(this.track.scrollLeft);\n }\n\n _scrollToStop(n: number) {\n const sign = getComputedStyle(this.track).direction === \"rtl\" ? -1 : 1;\n this.track.scrollTo({ left: sign * this._stop(n) });\n }\n\n /* Smooth or instant is the track's scroll-behavior, which follows\n prefers-reduced-motion; see carousel.css.ts. */\n _goToPage(n: number) {\n this._seeking = n;\n this._page = n;\n this._scrollToStop(n);\n }\n\n openModal(item: ModalItem) {\n this.selectedItem = item;\n this._shownItem = item;\n }\n\n closeModal() {\n this.selectedItem = null;\n }\n\n /* Mouse drag, the one way of moving the track the browser does not give it:\n wheel, trackpad, touch, pen and the keyboard all scroll it natively. The\n docs promise click-and-drag, so it stays, as a thin layer over the\n scroller -- a mouse press only, one pixel of track per pixel of pointer\n (it was 1.5), and no snapping while the button is down, or every write to\n scrollLeft would land on a stop. On release it settles on the nearest one.\n\n This used to be mousedown and touchmove handlers writing scrollLeft over\n a track that was overflow: hidden, which left the wheel, the trackpad and\n the keyboard with nothing to move, and drove touch by script. */\n _enableMouseDrag(track: HTMLElement) {\n let press: { id: number; x: number; left: number; dragging: boolean } | null = null;\n let swallowClick = false;\n\n track.addEventListener(\"pointerdown\", (e) => {\n if (e.pointerType !== \"mouse\" || e.button !== 0) return;\n press = { id: e.pointerId, x: e.clientX, left: track.scrollLeft, dragging: false };\n });\n\n track.addEventListener(\"pointermove\", (e) => {\n if (press?.id !== e.pointerId) return;\n // the button came up off the track before the press became a drag\n if (!(e.buttons & 1)) { press = null; return; }\n const dx = e.clientX - press.x;\n if (!press.dragging) {\n // a few pixels of travel first, so a click on + stays a click\n if (Math.abs(dx) < 4) return;\n press.dragging = true;\n track.setPointerCapture(e.pointerId);\n track.classList.add(\"dragging\");\n }\n track.scrollLeft = press.left - dx;\n });\n\n const release = () => {\n const dragged = press?.dragging;\n press = null;\n if (!dragged) return;\n track.classList.remove(\"dragging\");\n this._settle();\n // the click a drag ends with is not a click on the + or link under it;\n // it comes in the same task as the pointerup, if it comes at all\n swallowClick = true;\n setTimeout(() => { swallowClick = false; });\n };\n for (const type of [\"pointerup\", \"pointercancel\", \"lostpointercapture\"]) {\n track.addEventListener(type, release);\n }\n\n track.addEventListener(\"click\", (e) => {\n if (!swallowClick) return;\n e.preventDefault();\n e.stopPropagation();\n }, { capture: true });\n\n // a press is for moving the track, not for selecting copy or dragging an icon out\n for (const type of [\"selectstart\", \"dragstart\"]) {\n track.addEventListener(type, (e) => { if (press) e.preventDefault(); });\n }\n }\n\n /* Where a drag leaves the track, the snap would take it: the nearest stop. */\n _settle() {\n const left = this._travelled;\n let nearest = 1;\n for (let n = 2; n <= this._pages; n++) {\n if (Math.abs(this._stop(n) - left) < Math.abs(this._stop(nearest) - left)) nearest = n;\n }\n this._scrollToStop(nearest);\n }\n\n render() {\n return html`\n <div class=\"bd-carousel\">\n ${this.title\n ? html`<div class=\"bd-header-carousel\">\n ${this._renderTitle(\"bd-section-title\")}\n </div>`\n : \"\"}\n\n <div class=\"bd-carousel-track\">\n <slot></slot>\n </div>\n <div class=\"bd-carousel-controls\">\n <bd-pagination-dots\n count=${this._pages}\n current=${this._page}\n label=${this.title || \"Slides\"}\n item-label=\"Go to item\"\n @bd-change=${(e: CustomEvent<{ current: number }>) => this._goToPage(e.detail.current)}\n ></bd-pagination-dots>\n </div>\n </div>\n\n <!-- Always rendered, and closed through open: a dialog closed is what\n hands focus back to the + that opened it, and one removed while\n open drops it on the page instead. It keeps the last item's copy\n while it closes. -->\n <bd-modal\n .open=\"${!!this.selectedItem}\"\n .title=\"${this._shownItem?.title ?? \"\"}\"\n .modalText=\"${this._shownItem?.modalText ?? \"\"}\"\n .icon=\"${this._shownItem?.icon ?? \"\"}\"\n @close-modal=\"${this.closeModal}\"\n ></bd-modal>\n `;\n }\n\n static styles = [carouselCSS];\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"bd-carousel-item\" : CarouselItem;\n \"bd-carousel-section\": CustomCarousel;\n }\n interface HTMLElementEventMap {\n \"open-modal\": CustomEvent<ModalItem>;\n }\n}\n"],"mappings":"A,6aAkBO,IAAMI,EAAN,cAA2BC,CAAW,CAQ3C,YAAa,CACX,KAAK,cACH,IAAI,YAAY,aAAc,CAC5B,OAAQ,CACN,MAAW,KAAK,MAChB,UAAW,KAAK,UAChB,KAAW,KA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A,KAAK,aAAa,kBAAkB,EAAE;oBAE1C,GAAG;;;;;;;oBAOK,KAAK,OAAO;sBACV,KAAK,MAAM;oBACb,KAAK,OAAS,SAAS;;yBAEjB,GAAwC,KAAK,UAAU,EAAE,OAAO,OAAO,EAAE;;;;;;;;;;iBAUlF,CAAC,CAAC,KAAK,aAAa;kBACnB,KAAK,YAAY,OAAS,GAAG;sBACzB,KAAK,YAAY,WAAa,GAAG;iBACtC,KAAK,YAAY,MAAQ,GAAG;wBACrB,KAAK,WAAW;;KAGtC,C,OAEgB,KAAA,OAAA,CAAC/B,CAAW,C,CAC9B,EAtRGC,EAAA,CAAAK,EAAS,CAAE,KAAM,MAAO,CAAC,CAAA,EAAAE,EAAA,UAAA,QAAA,IAAA,EAAA,EAEzBP,EAAA,CAAAK,EAAS,CAAE,KAAM,OAAQ,UAAW,eAAgB,CAAC,CAAA,EAAAE,EAAA,UAAA,eAAA,IAAA,EAAA,EAErDP,EAAA,CAAAK,EAAS,CAAE,KAAM,MAAO,CAAC,CAAA,EAAAE,EAAA,UAAA,eAAA,IAAA,EAAA,EAGzBP,EAAA,CAAA+B,EAAM,CAAA,EAAAxB,EAAA,UAAA,SAAA,IAAA,EAAA,EAENP,EAAA,CAAA+B,EAAM,CAAA,EAAAxB,EAAA,UAAA,QAAA,IAAA,EAAA,EAXR,EAAAP,EAAA,CAAAM,EAAc,qBAAqB,CAAA,EAAAC,CAAA,E"}
|
|
1
|
+
{"version":3,"file":"carousel.js","names":["carouselCSS","_decorate","__decorate","carousel_css_default","CarouselItem","LitElement","property","defineElement","CustomCarousel","ObserverController","observer","n","className","type","promises","el","img","resolve","first","gap","max","step","left","page","sign","item","press","swallowClick","track","e","dx","release","dragged","nearest","state"],"sources":["../../../../src/components/carousel/carousel.ts"],"sourcesContent":["import { LitElement, html } from \"lit\";\nimport { property, state } from \"lit/decorators.js\";\nimport { defineElement } from \"#shared/define-element.ts\";\nimport { ObserverController } from \"#shared/controller.observer.ts\";\n// Installs the design tokens into document scope; see src/tokens/tokens.ts\nimport \"#tokens/tokens.ts\";\nimport carouselCSS from \"#components/carousel/carousel.css.ts\";\nimport \"#components/heading/heading.ts\";\nimport \"#components/icons/plus-icon.ts\";\nimport \"#components/modal/modal.ts\";\nimport \"#components/pagination-dots/pagination-dots.ts\";\n\ninterface ModalItem {\n title? : string;\n modalText?: string;\n icon? : string;\n}\n\n@defineElement(\"bd-carousel-item\")\nexport class CarouselItem extends LitElement {\n @property({ type: String })\n icon?: string;\n @property({ type: String })\n title!: string;\n @property({ type: String })\n modalText?: string;\n\n _openModal() {\n this.dispatchEvent(\n new CustomEvent(\"open-modal\", {\n detail: {\n title : this.title,\n modalText: this.modalText,\n icon : this.icon\n },\n bubbles : true,\n composed: true\n })\n );\n }\n\n render() {\n return html`\n <div class=\"bd-box\">\n ${this.icon\n ? html`<img src=\"${this.icon}\" alt=\"\" class=\"bd-carousel-icon\" />`\n : \"\"}\n <div class=\"bd-content\">\n <slot></slot>\n </div>\n <button\n type=\"button\"\n class=\"bd-plus-button\"\n aria-label=\"Open modal for ${this.title}\"\n @click=\"${this._openModal}\"\n >\n <bd-plus-icon size=\"md\"></bd-plus-icon>\n </button>\n </div>\n `;\n }\n\n static styles = [carouselCSS];\n}\n\n@defineElement(\"bd-carousel-section\")\nclass CustomCarousel extends LitElement {\n @property({ type: String })\n title = \"\";\n @property({ type: Number, attribute: \"heading-level\" })\n headingLevel = 2;\n @property({ type: Object })\n selectedItem: ModalItem | null = null;\n // scroll stops, 1-based, read from the track; see _measure\n @state()\n _pages = 1;\n @state()\n _page = 1;\n\n _seeking : number;\n _shownItem? : ModalItem;\n track! : HTMLElement;\n slotElement!: HTMLSlotElement;\n\n /* The track's size decides how many stops it has. Observed for as long as\n the section is connected -- it used to start in firstUpdated and stop on\n disconnect, so a carousel moved in the page never counted again. */\n _trackSize = new ObserverController(this,\n () => new ResizeObserver(() => this._measure()),\n observer => observer.observe(this.renderRoot.querySelector(\".bd-carousel-track\")!));\n\n constructor() {\n super();\n this._seeking = 0;\n }\n\n /**\n * The heading element this section renders. Level is the document-outline\n * question and belongs to whoever composes the page; the type scale is this\n * component's own and does not move with it. Defaults to h2, because a\n * reusable section cannot know it is the only thing on the page, and two of\n * these used to put two h1s on one.\n */\n get _headingTag() {\n const n = Number(this.headingLevel);\n return Number.isInteger(n) && n >= 1 && n <= 6 ? `h${n}` : \"h2\";\n }\n\n /* bd-h already builds the dynamic tag, and it keeps the two questions apart\n the way this component needs: as= is the outline level the page composes,\n visual-level= is the type role, which is ours. Building the element here\n meant re-implementing bd-h and then hand-writing the type on top of it --\n and the hand-written type carried no line-height and no margin, so the\n title rendered with the browser's own h2 margins. */\n _renderTitle(className: string) {\n return html`<bd-h as=${this._headingTag} visual-level=\"h3\" class=${className}\n >${this.title}</bd-h\n >`;\n }\n\n firstUpdated() {\n this.track = this.shadowRoot!.querySelector<HTMLElement>(\".bd-carousel-track\")!;\n this.slotElement = this.shadowRoot!.querySelector(\"slot\")!;\n\n this.track.addEventListener(\"scroll\", () => this._measure(), { passive: true });\n this.track.addEventListener(\"scrollend\", () => { this._seeking = 0; this._measure(); });\n // a visitor taking hold of the track ends any scroll a control started\n for (const type of [\"pointerdown\", \"touchstart\", \"wheel\", \"keydown\"]) {\n this.track.addEventListener(type, () => { this._seeking = 0; }, { passive: true });\n }\n\n this.slotElement.addEventListener(\"slotchange\", () => {\n this.waitForImagesToLoad().then(() => this._measure());\n });\n\n this.waitForImagesToLoad().then(() => this._measure());\n\n this.addEventListener(\"open-modal\", (e) => {\n this.openModal(e.detail);\n });\n this._enableMouseDrag(this.track);\n }\n\n waitForImagesToLoad() {\n const assignedElements = this.slotElement.assignedElements({\n flatten: true\n });\n const images = assignedElements\n .map((el) => el.shadowRoot?.querySelector(\"img\"))\n .filter((img) => img != null);\n const promises = images.map(\n (img) =>\n new Promise<Event | void>((resolve) => {\n if (img.complete) resolve();\n else {\n img.addEventListener(\"load\", resolve, { once: true });\n img.addEventListener(\"error\", resolve, { once: true });\n }\n })\n );\n return Promise.all(promises);\n }\n\n /* The distance from one item to the next: an item's width and the gap. A\n scroll stop is one of these, and the controls count stops, not items --\n the last stop is wherever the track ends, which is short of a full step\n when the items do not divide the width evenly. */\n _step() {\n const first = this.slotElement?.assignedElements({ flatten: true })[0];\n if (!first) return 0;\n const gap = parseFloat(getComputedStyle(this.track).columnGap) || 0;\n return (first as HTMLElement).offsetWidth + gap;\n }\n\n /* How many stops the track has and which one it is at, from where it has\n scrolled to -- by a control, a drag, a wheel or a keyboard. While a\n control's smooth scroll is on its way, the dot it asked for stays current\n rather than stepping through every stop it passes. */\n _measure() {\n if (!this.track) return;\n const max = this.track.scrollWidth - this.track.clientWidth;\n const step = this._step();\n if (max <= 1 || step <= 0) {\n this._pages = 1;\n this._page = 1;\n return;\n }\n this._pages = Math.ceil((max - 1) / step) + 1;\n const left = this._travelled;\n const page = left >= max - 1 ? this._pages : Math.min(this._pages, Math.round(left / step) + 1);\n if (this._seeking && page !== this._seeking) return;\n this._seeking = 0;\n this._page = page;\n }\n\n /* Where stop n sits, as a distance from the track's start: a whole step per\n stop, and the last at the track's end. */\n _stop(n: number) {\n const max = this.track.scrollWidth - this.track.clientWidth;\n return Math.min((n - 1) * this._step(), max);\n }\n\n /* How far the track has scrolled from its start. On a right-to-left page\n the start is the right edge and scrollLeft runs from 0 down to minus the\n overflow, so the distance is its size and a position written back takes\n its sign; read as a plain number, every stop past the first sat at a\n scrollLeft the track can never reach, and scrolling to one clamped to the\n start. */\n get _travelled() {\n return Math.abs(this.track.scrollLeft);\n }\n\n _scrollToStop(n: number) {\n const sign = getComputedStyle(this.track).direction === \"rtl\" ? -1 : 1;\n this.track.scrollTo({ left: sign * this._stop(n) });\n }\n\n /* Smooth or instant is the track's scroll-behavior, which follows\n prefers-reduced-motion; see carousel.css.ts. */\n _goToPage(n: number) {\n this._seeking = n;\n this._page = n;\n this._scrollToStop(n);\n }\n\n openModal(item: ModalItem) {\n this.selectedItem = item;\n this._shownItem = item;\n }\n\n closeModal() {\n this.selectedItem = null;\n }\n\n /* Mouse drag, the one way of moving the track the browser does not give it:\n wheel, trackpad, touch, pen and the keyboard all scroll it natively. The\n docs promise click-and-drag, so it stays, as a thin layer over the\n scroller -- a mouse press only, one pixel of track per pixel of pointer\n (it was 1.5), and no snapping while the button is down, or every write to\n scrollLeft would land on a stop. On release it settles on the nearest one.\n\n This used to be mousedown and touchmove handlers writing scrollLeft over\n a track that was overflow: hidden, which left the wheel, the trackpad and\n the keyboard with nothing to move, and drove touch by script. */\n _enableMouseDrag(track: HTMLElement) {\n let press: { id: number; x: number; left: number; dragging: boolean } | null = null;\n let swallowClick = false;\n\n track.addEventListener(\"pointerdown\", (e) => {\n if (e.pointerType !== \"mouse\" || e.button !== 0) return;\n press = { id: e.pointerId, x: e.clientX, left: track.scrollLeft, dragging: false };\n });\n\n track.addEventListener(\"pointermove\", (e) => {\n if (press?.id !== e.pointerId) return;\n // the button came up off the track before the press became a drag\n if (!(e.buttons & 1)) { press = null; return; }\n const dx = e.clientX - press.x;\n if (!press.dragging) {\n // a few pixels of travel first, so a click on + stays a click\n if (Math.abs(dx) < 4) return;\n press.dragging = true;\n track.setPointerCapture(e.pointerId);\n track.classList.add(\"dragging\");\n }\n track.scrollLeft = press.left - dx;\n });\n\n const release = () => {\n const dragged = press?.dragging;\n press = null;\n if (!dragged) return;\n track.classList.remove(\"dragging\");\n this._settle();\n // the click a drag ends with is not a click on the + or link under it;\n // it comes in the same task as the pointerup, if it comes at all\n swallowClick = true;\n setTimeout(() => { swallowClick = false; });\n };\n for (const type of [\"pointerup\", \"pointercancel\", \"lostpointercapture\"]) {\n track.addEventListener(type, release);\n }\n\n track.addEventListener(\"click\", (e) => {\n if (!swallowClick) return;\n e.preventDefault();\n e.stopPropagation();\n }, { capture: true });\n\n // a press is for moving the track, not for selecting copy or dragging an icon out\n for (const type of [\"selectstart\", \"dragstart\"]) {\n track.addEventListener(type, (e) => { if (press) e.preventDefault(); });\n }\n }\n\n /* Where a drag leaves the track, the snap would take it: the nearest stop. */\n _settle() {\n const left = this._travelled;\n let nearest = 1;\n for (let n = 2; n <= this._pages; n++) {\n if (Math.abs(this._stop(n) - left) < Math.abs(this._stop(nearest) - left)) nearest = n;\n }\n this._scrollToStop(nearest);\n }\n\n render() {\n return html`\n <div class=\"bd-carousel\">\n ${this.title\n ? html`<div class=\"bd-header-carousel\">\n ${this._renderTitle(\"bd-section-title\")}\n </div>`\n : \"\"}\n\n <div class=\"bd-carousel-track\">\n <slot></slot>\n </div>\n <div class=\"bd-carousel-controls\">\n <bd-pagination-dots\n count=${this._pages}\n current=${this._page}\n label=${this.title || \"Slides\"}\n item-label=\"Go to item\"\n @bd-change=${(e: CustomEvent<{ current: number }>) => this._goToPage(e.detail.current)}\n ></bd-pagination-dots>\n </div>\n </div>\n\n <!-- Always rendered, and closed through open: a dialog closed is what\n hands focus back to the + that opened it, and one removed while\n open drops it on the page instead. It keeps the last item's copy\n while it closes. -->\n <bd-modal\n .open=\"${!!this.selectedItem}\"\n .title=\"${this._shownItem?.title ?? \"\"}\"\n .modalText=\"${this._shownItem?.modalText ?? \"\"}\"\n .icon=\"${this._shownItem?.icon ?? \"\"}\"\n @close-modal=\"${this.closeModal}\"\n ></bd-modal>\n `;\n }\n\n static styles = [carouselCSS];\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"bd-carousel-item\" : CarouselItem;\n \"bd-carousel-section\": CustomCarousel;\n }\n interface HTMLElementEventMap {\n \"open-modal\": CustomEvent<ModalItem>;\n }\n}\n"],"mappings":"A,mfAmBO,IAAMI,EAAN,cAA2BC,CAAW,CAQ3C,YAAa,CACX,KAAK,cACH,IAAI,YAAY,aAAc,CAC5B,OAAQ,CACN,MAAW,KAAK,MAChB,UAAW,KAAK,UAChB,KAAW,KAAK,IAClB,EACA,QAAU,GACV,SAAU,EACZ,CAAC,CACH,CACF,CAEA,QAAS,CACP,MAAO,EAAI;;UAEL,KAAK,KACH,CAAI,aAAa,KAAK,KAAK,sCAC3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AO,EAAE;;;;;;;;;;iBAUlF,CAAC,CAAC,KAAK,aAAa;kBACnB,KAAK,YAAY,OAAS,GAAG;sBACzB,KAAK,YAAY,WAAa,GAAG;iBACtC,KAAK,YAAY,MAAQ,GAAG;wBACrB,KAAK,WAAW;;KAGtC,C,OAEgB,KAAA,OAAA,CAACjC,CAAW,C,CAC9B,EApRGC,EAAA,CAAAK,EAAS,CAAE,KAAM,MAAO,CAAC,CAAA,EAAAE,EAAA,UAAA,QAAA,IAAA,EAAA,EAEzBP,EAAA,CAAAK,EAAS,CAAE,KAAM,OAAQ,UAAW,eAAgB,CAAC,CAAA,EAAAE,EAAA,UAAA,eAAA,IAAA,EAAA,EAErDP,EAAA,CAAAK,EAAS,CAAE,KAAM,MAAO,CAAC,CAAA,EAAAE,EAAA,UAAA,eAAA,IAAA,EAAA,EAGzBP,EAAA,CAAAiC,EAAM,CAAA,EAAA1B,EAAA,UAAA,SAAA,IAAA,EAAA,EAENP,EAAA,CAAAiC,EAAM,CAAA,EAAA1B,EAAA,UAAA,QAAA,IAAA,EAAA,EAXR,EAAAP,EAAA,CAAAM,EAAc,qBAAqB,CAAA,EAAAC,CAAA,E"}
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import{defineElement as e}from"../shared/define-element.js";import
|
|
1
|
+
import{defineElement as e}from"../shared/define-element.js";import"../../tokens/tokens.js";import t from"../../_bundled/oxc-project_runtime/helpers/esm/decorate.js";import"../heading/heading.js";import"../paragraph/paragraph.js";import{ensembleCSS as n}from"../shared/ensemble.css.js";import r from"./comparison-panel.css.js";import{LitElement as i,html as a,nothing as o}from"lit";import{property as s}from"lit/decorators.js";var c=class extends i{constructor(...e){super(...e),this.title=``,this.description=``,this.positiveTitle=``,this.negativeTitle=``,this.positiveItems=[],this.negativeItems=[],this.variant=`light`}static{this.styles=[n,r]}_renderColumn(e,t,n,r){let i=e===`positive`;return a`
|
|
2
2
|
<div class="bd-comparisonpanel-column">
|
|
3
|
-
${t?
|
|
3
|
+
${t?a`
|
|
4
4
|
<bd-h as="h4" class="bd-comparisonpanel-column-title">
|
|
5
5
|
<slot name="${r}-title">${t}</slot>
|
|
6
6
|
</bd-h>
|
|
7
|
-
`:
|
|
7
|
+
`:o}
|
|
8
8
|
|
|
9
9
|
<ul class="bd-comparisonpanel-list">
|
|
10
|
-
${n.map(e=>
|
|
10
|
+
${n.map(e=>a`
|
|
11
11
|
<li class="bd-comparisonpanel-item">
|
|
12
12
|
<span
|
|
13
13
|
class="bd-comparisonpanel-icon ${i?`bd-comparisonpanel-icon--positive`:`bd-comparisonpanel-icon--negative`}"
|
|
14
14
|
aria-hidden="true"
|
|
15
15
|
>
|
|
16
|
-
${i?
|
|
16
|
+
${i?a`
|
|
17
17
|
<svg width="14" height="14" viewBox="0 0 14 14" fill="none">
|
|
18
18
|
<path d="M3 7.2l2.6 2.6L11 4.4" stroke="white" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/>
|
|
19
19
|
</svg>
|
|
20
|
-
`:
|
|
20
|
+
`:a`
|
|
21
21
|
<svg width="14" height="14" viewBox="0 0 14 14" fill="none">
|
|
22
22
|
<path d="M3.5 3.5l7 7M10.5 3.5l-7 7" stroke="white" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/>
|
|
23
23
|
</svg>
|
|
@@ -30,24 +30,24 @@ import{defineElement as e}from"../shared/define-element.js";import{tokens as t}f
|
|
|
30
30
|
|
|
31
31
|
<slot name="${r}"></slot>
|
|
32
32
|
</div>
|
|
33
|
-
`}render(){return
|
|
33
|
+
`}render(){return a`
|
|
34
34
|
<div class="bd-ensemble bd-comparisonpanel-wrapper">
|
|
35
|
-
${this.title?
|
|
35
|
+
${this.title?a`
|
|
36
36
|
<bd-h as="h2" class="bd-comparisonpanel-title">
|
|
37
37
|
<slot name="title">${this.title}</slot>
|
|
38
38
|
</bd-h>
|
|
39
|
-
`:
|
|
39
|
+
`:o}
|
|
40
40
|
|
|
41
|
-
${this.description?
|
|
41
|
+
${this.description?a`
|
|
42
42
|
<bd-p variant="large" class="bd-comparisonpanel-description">
|
|
43
43
|
<slot name="description">${this.description}</slot>
|
|
44
44
|
</bd-p>
|
|
45
|
-
`:
|
|
45
|
+
`:o}
|
|
46
46
|
|
|
47
47
|
<div class="bd-comparisonpanel-columns">
|
|
48
48
|
${this._renderColumn(`positive`,this.positiveTitle,this.positiveItems,`positive`)}
|
|
49
49
|
${this._renderColumn(`negative`,this.negativeTitle,this.negativeItems,`negative`)}
|
|
50
50
|
</div>
|
|
51
51
|
</div>
|
|
52
|
-
`}};
|
|
52
|
+
`}};t([s({type:String})],c.prototype,`title`,void 0),t([s({type:String})],c.prototype,`description`,void 0),t([s({type:String,attribute:`positive-title`})],c.prototype,`positiveTitle`,void 0),t([s({type:String,attribute:`negative-title`})],c.prototype,`negativeTitle`,void 0),t([s({type:Array})],c.prototype,`positiveItems`,void 0),t([s({type:Array})],c.prototype,`negativeItems`,void 0),t([s({type:String,reflect:!0})],c.prototype,`variant`,void 0),c=t([e(`bd-comparison-panel`)],c);
|
|
53
53
|
//# sourceMappingURL=comparison-panel.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"comparison-panel.js","names":["comparisonPanelCSS","_decorate","__decorate","comparison_panel_css_default","ComparisonPanel","LitElement","_args","
|
|
1
|
+
{"version":3,"file":"comparison-panel.js","names":["comparisonPanelCSS","_decorate","__decorate","comparison_panel_css_default","ComparisonPanel","LitElement","_args","ensembleCSS","isPositive","kind","colTitle","slotName","nothing","items","item","property","defineElement"],"sources":["../../../../src/components/comparison-panel/comparison-panel.ts"],"sourcesContent":["import { LitElement, html, nothing } from \"lit\";\nimport { property } from \"lit/decorators.js\";\nimport { defineElement } from \"#shared/define-element.ts\";\n// Installs the design tokens into document scope; see src/tokens/tokens.ts\nimport \"#tokens/tokens.ts\";\nimport \"#components/heading/heading.ts\";\nimport \"#components/paragraph/paragraph.ts\";\nimport comparisonPanelCSS from \"./comparison-panel.css.ts\";\nimport { ensembleCSS } from \"#shared/ensemble.css.ts\";\n\ntype Variant = \"light\" | \"dark\";\ntype ColumnKind = \"positive\" | \"negative\";\n\n@defineElement(\"bd-comparison-panel\")\nclass ComparisonPanel extends LitElement {\n static styles = [ensembleCSS, comparisonPanelCSS];\n\n @property({ type: String })\n title = \"\";\n @property({ type: String })\n description = \"\";\n @property({ type: String, attribute: \"positive-title\" })\n positiveTitle = \"\";\n @property({ type: String, attribute: \"negative-title\" })\n negativeTitle = \"\";\n @property({ type: Array })\n positiveItems: string[] = []; // [String]\n @property({ type: Array })\n negativeItems: string[] = []; // [String]\n // \"light\" (default) — white section, bordered white cards, sans-serif\n // column titles. \"dark\" — near-black gradient section, dark bordered\n // cards, mono uppercase column titles (e.g. \"VPN FOR AI AGENTS IS\").\n @property({ type: String, reflect: true })\n variant: Variant = \"light\";\n\n _renderColumn(kind: ColumnKind, colTitle: string, items: string[], slotName: string) {\n const isPositive = kind === \"positive\";\n return html`\n <div class=\"bd-comparisonpanel-column\">\n ${colTitle\n ? html`\n <bd-h as=\"h4\" class=\"bd-comparisonpanel-column-title\">\n <slot name=\"${slotName}-title\">${colTitle}</slot>\n </bd-h>\n `\n : nothing}\n\n <ul class=\"bd-comparisonpanel-list\">\n ${items.map(\n (item) => html`\n <li class=\"bd-comparisonpanel-item\">\n <span\n class=\"bd-comparisonpanel-icon ${isPositive ? \"bd-comparisonpanel-icon--positive\" : \"bd-comparisonpanel-icon--negative\"}\"\n aria-hidden=\"true\"\n >\n ${isPositive\n ? html`\n <svg width=\"14\" height=\"14\" viewBox=\"0 0 14 14\" fill=\"none\">\n <path d=\"M3 7.2l2.6 2.6L11 4.4\" stroke=\"white\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n </svg>\n `\n : html`\n <svg width=\"14\" height=\"14\" viewBox=\"0 0 14 14\" fill=\"none\">\n <path d=\"M3.5 3.5l7 7M10.5 3.5l-7 7\" stroke=\"white\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n </svg>\n `}\n </span>\n <bd-p variant=\"regular\" class=\"bd-comparisonpanel-text\">${item}</bd-p>\n </li>\n `\n )}\n </ul>\n\n <slot name=\"${slotName}\"></slot>\n </div>\n `;\n }\n\n render() {\n return html`\n <div class=\"bd-ensemble bd-comparisonpanel-wrapper\">\n ${this.title\n ? html`\n <bd-h as=\"h2\" class=\"bd-comparisonpanel-title\">\n <slot name=\"title\">${this.title}</slot>\n </bd-h>\n `\n : nothing}\n\n ${this.description\n ? html`\n <bd-p variant=\"large\" class=\"bd-comparisonpanel-description\">\n <slot name=\"description\">${this.description}</slot>\n </bd-p>\n `\n : nothing}\n\n <div class=\"bd-comparisonpanel-columns\">\n ${this._renderColumn(\"positive\", this.positiveTitle, this.positiveItems, \"positive\")}\n ${this._renderColumn(\"negative\", this.negativeTitle, this.negativeItems, \"negative\")}\n </div>\n </div>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"bd-comparison-panel\": ComparisonPanel;\n }\n}"],"mappings":"A,2aAaA,IACMI,EADN,cAC8BC,CAAW,C,8BAI/B,KAAA,MAAA,GAEM,KAAA,YAAA,GAEE,KAAA,cAAA,GAEA,KAAA,cAAA,GAEU,KAAA,cAAA,CAAC,EAED,KAAA,cAAA,CAAC,EAKR,KAAA,QAAA,O,QAlBH,KAAA,OAAA,CAACE,EAAaP,CAAkB,C,CAoBhD,cAAc,EAAkB,EAAkB,EAAiB,EAAkB,CACnF,IAAMQ,EAAaC,IAAS,WAC5B,MAAO,EAAI;;UAELC,EACE,CAAI;;8BAEcC,EAAS,UAAUD,EAAS;;cAG9CE,EAAQ;;;YAGRC,EAAM,IACL,GAAS,CAAI;;;mDAGyBL,EAAa,oCAAsC,oCAAoC;;;oBAGtHA,EACE,CAAI;;;;wBAKJ,CAAI;;;;wBAIF;;0EAEkDM,EAAK;;aAGrE,EAAE;;;sBAGUH,EAAS;;KAG7B,CAEA,QAAS,CACP,MAAO,EAAI;;UAEL,KA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