@repobit/dex-system-design 3.0.3 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -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.d.ts +1 -0
- package/dist/src/components/audience-card/audience-card.js +7 -7
- 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.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/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 +8 -8
- 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 +6 -6
- 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 +3 -3
- 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 +1 -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,7 +1,7 @@
|
|
|
1
|
-
import{defineElement as e}from"../shared/define-element.js";import
|
|
2
|
-
<div class="tile" role="group" aria-label="${this.label?`${this.label} ${this.caption}`.trim():
|
|
3
|
-
<p class="value" aria-hidden="${this.label?`true`:
|
|
4
|
-
${this.caption?
|
|
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{statTileCSS as n}from"./stat.css.js";import{LitElement as r,html as i,nothing as a}from"lit";import{property as o}from"lit/decorators.js";var s=class extends r{constructor(...e){super(...e),this.value=``,this.caption=``,this.label=``}static{this.styles=[n]}render(){return i`
|
|
2
|
+
<div class="tile" role="group" aria-label="${this.label?`${this.label} ${this.caption}`.trim():a}">
|
|
3
|
+
<p class="value" aria-hidden="${this.label?`true`:a}">${this.value}</p>
|
|
4
|
+
${this.caption?i`<p class="caption" aria-hidden="${this.label?`true`:a}">${this.caption}</p>`:a}
|
|
5
5
|
</div>
|
|
6
|
-
`}};
|
|
6
|
+
`}};t([o({type:String})],s.prototype,`value`,void 0),t([o({type:String})],s.prototype,`caption`,void 0),t([o({type:String})],s.prototype,`label`,void 0),s=t([e(`bd-stat-tile`)],s);export{s as StatTile};
|
|
7
7
|
//# sourceMappingURL=stat-tile.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stat-tile.js","names":["_decorate","__decorate","StatTile","LitElement","_args","
|
|
1
|
+
{"version":3,"file":"stat-tile.js","names":["_decorate","__decorate","StatTile","LitElement","_args","statTileCSS","nothing","property","defineElement"],"sources":["../../../../src/components/stat/stat-tile.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 { statTileCSS } from \"./stat.css.ts\";\n\n/**\n * One figure from the Why-trust stat grid: a display value over a short\n * caption, on surface/info. The caption is pinned to the tile's foot so a row\n * of tiles lines its captions up, whatever each value's length. Drawn in the\n * foundation Figma file as Stat tile.\n *\n * The value and caption are read as one statement -- \"580+ patents filed\" --\n * so the tile is a group named by both, and `label` can spell the value out\n * where its short form reads badly aloud (\"50 billion plus\").\n */\n@defineElement(\"bd-stat-tile\")\nexport class StatTile extends LitElement {\n @property({ type: String })\n value = \"\";\n @property({ type: String })\n caption = \"\";\n @property({ type: String })\n label = \"\";\n\n static styles = [statTileCSS];\n\n render() {\n return html`\n <div class=\"tile\" role=\"group\" aria-label=\"${this.label ? `${this.label} ${this.caption}`.trim() : nothing}\">\n <p class=\"value\" aria-hidden=\"${this.label ? \"true\" : nothing}\">${this.value}</p>\n ${this.caption\n ? html`<p class=\"caption\" aria-hidden=\"${this.label ? \"true\" : nothing}\">${this.caption}</p>`\n : nothing}\n </div>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"bd-stat-tile\": StatTile;\n }\n}\n"],"mappings":"A,sTAkBO,IAAME,EAAN,cAAuBC,CAAW,C,8BAE/B,KAAA,MAAA,GAEE,KAAA,QAAA,GAEF,KAAA,MAAA,E,QAEQ,KAAA,OAAA,CAACE,CAAW,C,CAE5B,QAAS,CACP,MAAO,EAAI;mDACoC,KAAK,MAAQ,GAAG,KAAK,MAAM,GAAG,KAAK,UAAU,KAAK,EAAIC,EAAQ;wCACzE,KAAK,MAAQ,OAASA,EAAQ,IAAI,KAAK,MAAM;UAC3E,KAAK,QACH,CAAI,mCAAmC,KAAK,MAAQ,OAASA,EAAQ,IAAI,KAAK,QAAQ,MACtFA,EAAQ;;KAGlB,CACF,EAnBGN,EAAA,CAAAO,EAAS,CAAE,KAAM,MAAO,CAAC,CAAA,EAAAL,EAAA,UAAA,QAAA,IAAA,EAAA,EAEzBF,EAAA,CAAAO,EAAS,CAAE,KAAM,MAAO,CAAC,CAAA,EAAAL,EAAA,UAAA,UAAA,IAAA,EAAA,EAEzBF,EAAA,CAAAO,EAAS,CAAE,KAAM,MAAO,CAAC,CAAA,EAAAL,EAAA,UAAA,QAAA,IAAA,EAAA,EAN3B,EAAAF,EAAA,CAAAQ,EAAc,cAAc,CAAA,EAAAN,CAAA,E"}
|
|
@@ -1,2 +1,2 @@
|
|
|
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{LitElement as n,css as r,html as i}from"lit";import{property as a}from"lit/decorators.js";var o=class extends n{constructor(...e){super(...e),this.color=``}static{this.styles=[r`:host{vertical-align:middle;width:8px;height:16px;display:inline-block}.bd-terminal-cursor{background:var(--bd-terminal-cursor-color,var(--color-brand-400));width:100%;height:100%;animation:1s step-end infinite bd-terminal-cursor-blink;display:block}@keyframes bd-terminal-cursor-blink{0%,50%{opacity:1}50.01%,to{opacity:0}}@media (prefers-reduced-motion:reduce){.bd-terminal-cursor{animation:none}}`]}render(){let e=this.color?`background: ${this.color};`:``;return i`<span class="bd-terminal-cursor" style="${e}"></span>`}};t([a({type:String})],o.prototype,`color`,void 0),o=t([e(`bd-terminal-cursor`)],o);
|
|
2
2
|
//# sourceMappingURL=terminal-cursor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"terminal-cursor.js","names":["_decorate","__decorate","TerminalCursor","LitElement","_args","
|
|
1
|
+
{"version":3,"file":"terminal-cursor.js","names":["_decorate","__decorate","TerminalCursor","LitElement","_args","style","property","defineElement"],"sources":["../../../../src/components/terminal/terminal-cursor.ts"],"sourcesContent":["import { LitElement, css, 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\";\n\n@defineElement(\"bd-terminal-cursor\")\nclass TerminalCursor extends LitElement {\n static styles = [\n css`\n :host {\n display: inline-block;\n width: 8px;\n height: 16px;\n vertical-align: middle;\n }\n\n .bd-terminal-cursor {\n width: 100%;\n height: 100%;\n background: var(--bd-terminal-cursor-color, var(--color-brand-400));\n animation: bd-terminal-cursor-blink 1s steps(1) infinite;\n display: block;\n }\n\n @keyframes bd-terminal-cursor-blink {\n 0%, 50% {\n opacity: 1;\n }\n 50.01%, 100% {\n opacity: 0;\n }\n }\n\n /* A cursor that blinks for as long as the page is open is exactly the\n motion the setting exists for, and this one had no guard: every\n other animated element in the package stops or softens under\n prefers-reduced-motion. Here it stops, and the cursor stays shown --\n a steady block still says \"this is where the terminal is\". */\n @media (prefers-reduced-motion: reduce) {\n .bd-terminal-cursor {\n animation: none;\n }\n }\n `\n ];\n\n @property({ type: String })\n color = \"\";\n\n render() {\n const style = this.color ? `background: ${this.color};` : \"\";\n return html`<span class=\"bd-terminal-cursor\" style=\"${style}\"></span>`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"bd-terminal-cursor\": TerminalCursor;\n }\n}\n"],"mappings":"A,sQAMA,IACME,EADN,cAC6BC,CAAW,C,8BAyC9B,KAAA,MAAA,E,QAxCQ,KAAA,OAAA,CACd,CAAG,iZAoCL,C,CAKA,QAAS,CACP,IAAME,EAAQ,KAAK,MAAQ,eAAe,KAAK,MAAM,GAAK,GAC1D,MAAO,EAAI,2CAA2CA,EAAM,UAC9D,CACF,EAPGL,EAAA,CAAAM,EAAS,CAAE,KAAM,MAAO,CAAC,CAAA,EAAAJ,EAAA,UAAA,QAAA,IAAA,EAAA,EAzC3B,EAAAF,EAAA,CAAAO,EAAc,oBAAoB,CAAA,EAAAL,CAAA"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { LitElement, nothing } from "lit";
|
|
2
|
+
import "../../tokens/tokens.js";
|
|
2
3
|
import "../heading/heading.js";
|
|
3
4
|
import "../list/list-item/list-item.js";
|
|
4
5
|
import "../list/list.js";
|
|
@@ -30,9 +31,9 @@ declare class TerminalMessage extends LitElement {
|
|
|
30
31
|
lines: TerminalLine[];
|
|
31
32
|
caption: string;
|
|
32
33
|
variant: Variant;
|
|
33
|
-
_renderTitlebar(): import("lit-html").TemplateResult<1
|
|
34
|
-
_renderHint(): import("lit-html").TemplateResult<1
|
|
35
|
-
_renderLines(): import("lit-html").TemplateResult<1
|
|
34
|
+
_renderTitlebar(): typeof nothing | import("lit-html").TemplateResult<1>;
|
|
35
|
+
_renderHint(): typeof nothing | import("lit-html").TemplateResult<1>;
|
|
36
|
+
_renderLines(): typeof nothing | import("lit-html").TemplateResult<1>;
|
|
36
37
|
render(): import("lit-html").TemplateResult<1>;
|
|
37
38
|
}
|
|
38
39
|
declare global {
|
|
@@ -1,68 +1,68 @@
|
|
|
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"../list/list-item/list-item.js";import"../list/list.js";import"./terminal-cursor.js";import n from"./terminal-message.css.js";import{LitElement as r,html as i,nothing as a}from"lit";import{property as o}from"lit/decorators.js";var s=class extends r{constructor(...e){super(...e),this.showTitlebar=!1,this.panelLabel=``,this.dimText=``,this.greeting=``,this.icon=``,this.intro=``,this.items=[],this.footer=``,this.footerBold=``,this.showCursor=!1,this.hint=``,this.lines=[],this.caption=``,this.variant=`default`}static{this.styles=[n]}_renderTitlebar(){return this.variant===`flush`||!this.showTitlebar?a:i`
|
|
2
2
|
<div class="bd-terminalmsg-titlebar">
|
|
3
3
|
<span class="bd-terminalmsg-dot bd-terminalmsg-dot--red"></span>
|
|
4
4
|
<span class="bd-terminalmsg-dot bd-terminalmsg-dot--yellow"></span>
|
|
5
5
|
<span class="bd-terminalmsg-dot bd-terminalmsg-dot--green"></span>
|
|
6
6
|
</div>
|
|
7
|
-
`}_renderHint(){if(!this.hint)return
|
|
7
|
+
`}_renderHint(){if(!this.hint)return a;let e=this.hint.split(/(\[[^\]]+\])/g);return i`
|
|
8
8
|
<span class="bd-terminalmsg-hint">
|
|
9
|
-
${e.map(e=>/^\[[^\]]+\]$/.test(e)?
|
|
9
|
+
${e.map(e=>/^\[[^\]]+\]$/.test(e)?i`<strong class="bd-terminalmsg-hint-key">${e}</strong>`:e)}
|
|
10
10
|
</span>
|
|
11
|
-
`}_renderLines(){return!this.lines||!this.lines.length?
|
|
11
|
+
`}_renderLines(){return!this.lines||!this.lines.length?a:i`
|
|
12
12
|
<div class="bd-terminalmsg-lines">
|
|
13
|
-
${this.lines.map(({type:e,text:t,label:n,badge:r,badgeColor:
|
|
13
|
+
${this.lines.map(({type:e,text:t,label:n,badge:r,badgeColor:o,live:s})=>{switch(e){case`sep`:return i`<hr class="bd-terminalmsg-l-sep" />`;case`space`:return i`<div class="bd-terminalmsg-l-space" aria-hidden="true"> </div>`;case`cmd`:return i`<div class="bd-terminalmsg-l-cmd">${t}</div>`;case`ok`:return i`<div class="bd-terminalmsg-l-ok">${t}</div>`;case`ask`:return i`<div class="bd-terminalmsg-l-ask">${t}</div>`;case`strong`:return i`<div class="bd-terminalmsg-l-strong">${t}</div>`;case`dim`:return i`<div class="bd-terminalmsg-l-dim">${t}</div>`;case`title`:return i`
|
|
14
14
|
<div class="bd-terminalmsg-l-title">
|
|
15
15
|
<span>${t}</span>
|
|
16
|
-
${s?
|
|
16
|
+
${s?i`<span class="bd-terminalmsg-live"><span class="bd-terminalmsg-live-dot"></span>LIVE</span>`:a}
|
|
17
17
|
</div>
|
|
18
|
-
`;case`row`:return
|
|
18
|
+
`;case`row`:return i`
|
|
19
19
|
<div class="bd-terminalmsg-l-row">
|
|
20
20
|
<span class="bd-terminalmsg-l-row-label">${n}</span>
|
|
21
21
|
<span class="bd-terminalmsg-l-row-text">${t}</span>
|
|
22
|
-
${r?
|
|
22
|
+
${r?i`<span class="bd-terminalmsg-badge bd-terminalmsg-badge--${o||`neutral`}">${r}</span>`:a}
|
|
23
23
|
</div>
|
|
24
|
-
`;default:return
|
|
24
|
+
`;default:return i`<div class="bd-terminalmsg-l-dim">${t}</div>`}})}
|
|
25
25
|
</div>
|
|
26
|
-
`}render(){return
|
|
26
|
+
`}render(){return i`
|
|
27
27
|
${this._renderTitlebar()}
|
|
28
28
|
|
|
29
29
|
<div class="bd-terminalmsg-panel">
|
|
30
|
-
${this.panelLabel?
|
|
30
|
+
${this.panelLabel?i`<span class="bd-terminalmsg-panel-label">${this.panelLabel}</span>`:a}
|
|
31
31
|
|
|
32
32
|
<div class="bd-terminalmsg-body">
|
|
33
33
|
${this._renderLines()}
|
|
34
34
|
|
|
35
|
-
${this.dimText?
|
|
35
|
+
${this.dimText?i`<bd-p variant="small" font-family="mono" paddingBottom="12" class="bd-terminalmsg-dim">${this.dimText}</bd-p>`:a}
|
|
36
36
|
|
|
37
|
-
${this.greeting?
|
|
37
|
+
${this.greeting?i`
|
|
38
38
|
<bd-p variant="regular" font-family="mono" paddingBottom="12" class="bd-terminalmsg-greeting">
|
|
39
|
-
${this.icon?
|
|
39
|
+
${this.icon?i`${this.icon} `:a}
|
|
40
40
|
<span class="bd-terminalmsg-greeting-text">${this.greeting}</span>
|
|
41
41
|
</bd-p>
|
|
42
|
-
`:
|
|
42
|
+
`:a}
|
|
43
43
|
|
|
44
|
-
${this.intro?
|
|
44
|
+
${this.intro?i`<bd-p variant="regular" font-family="mono" paddingBottom="12" class="bd-terminalmsg-intro">${this.intro}</bd-p>`:a}
|
|
45
45
|
|
|
46
|
-
${this.items&&this.items.length?
|
|
46
|
+
${this.items&&this.items.length?i`
|
|
47
47
|
<bd-list class="bd-terminalmsg-list">
|
|
48
|
-
${this.items.map(e=>
|
|
48
|
+
${this.items.map(e=>i`<bd-li variant="bullet" size="sm" color="inverse">${e}</bd-li>`)}
|
|
49
49
|
</bd-list>
|
|
50
|
-
`:
|
|
50
|
+
`:a}
|
|
51
51
|
|
|
52
|
-
${this.footer||this.footerBold?
|
|
52
|
+
${this.footer||this.footerBold?i`
|
|
53
53
|
<bd-p variant="regular" font-family="mono" class="bd-terminalmsg-footer">
|
|
54
|
-
${this.footerBold?
|
|
54
|
+
${this.footerBold?i`<strong>${this.footerBold}</strong> `:a}
|
|
55
55
|
${this.footer}
|
|
56
|
-
${this.showCursor?
|
|
56
|
+
${this.showCursor?i`<bd-terminal-cursor></bd-terminal-cursor>`:a}
|
|
57
57
|
</bd-p>
|
|
58
|
-
`:
|
|
58
|
+
`:a}
|
|
59
59
|
|
|
60
60
|
<slot></slot>
|
|
61
61
|
|
|
62
|
-
${this.caption?
|
|
62
|
+
${this.caption?i`<div class="bd-terminalmsg-caption">${this.caption}</div>`:a}
|
|
63
63
|
</div>
|
|
64
64
|
|
|
65
65
|
${this._renderHint()}
|
|
66
66
|
</div>
|
|
67
|
-
`}};
|
|
67
|
+
`}};t([o({type:Boolean,attribute:`show-titlebar`})],s.prototype,`showTitlebar`,void 0),t([o({type:String,attribute:`panel-label`})],s.prototype,`panelLabel`,void 0),t([o({type:String,attribute:`dim-text`})],s.prototype,`dimText`,void 0),t([o({type:String})],s.prototype,`greeting`,void 0),t([o({type:String})],s.prototype,`icon`,void 0),t([o({type:String})],s.prototype,`intro`,void 0),t([o({type:Array})],s.prototype,`items`,void 0),t([o({type:String})],s.prototype,`footer`,void 0),t([o({type:String,attribute:`footer-bold`})],s.prototype,`footerBold`,void 0),t([o({type:Boolean,attribute:`show-cursor`})],s.prototype,`showCursor`,void 0),t([o({type:String})],s.prototype,`hint`,void 0),t([o({type:Array})],s.prototype,`lines`,void 0),t([o({type:String})],s.prototype,`caption`,void 0),t([o({type:String,reflect:!0})],s.prototype,`variant`,void 0),s=t([e(`bd-terminal-message`)],s);
|
|
68
68
|
//# sourceMappingURL=terminal-message.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"terminal-message.js","names":["terminalMessageCSS","_decorate","__decorate","terminal_message_css_default","TerminalMessage","LitElement","_args","tokens","nothing","parts","part","type","text","live","label","badge","badgeColor","item","property","defineElement"],"sources":["../../../../src/components/terminal/terminal-message.ts"],"sourcesContent":["import { LitElement, html, nothing } from \"lit\";\nimport { property } from \"lit/decorators.js\";\nimport { defineElement } from \"#shared/define-element.ts\";\nimport { tokens } from \"#tokens/tokens.ts\";\nimport \"#components/heading/heading.ts\";\nimport \"#components/list/list-item/list-item.ts\";\nimport \"#components/list/list.ts\";\nimport \"#components/paragraph/paragraph.ts\";\nimport \"./terminal-cursor.ts\";\nimport terminalMessageCSS from \"./terminal-message.css.ts\";\n\ntype Variant = \"default\" | \"flush\";\ntype LineType = \"sep\" | \"space\" | \"cmd\" | \"ok\" | \"ask\" | \"strong\" | \"dim\" | \"title\" | \"row\";\n\ninterface TerminalLine {\n type? : LineType;\n text? : string;\n label? : string;\n badge? : string;\n badgeColor?: string;\n live? : boolean;\n}\n\n@defineElement(\"bd-terminal-message\")\nclass TerminalMessage extends LitElement {\n static styles = [tokens, terminalMessageCSS];\n\n @property({ type: Boolean, attribute: \"show-titlebar\" })\n showTitlebar = false;\n @property({ type: String, attribute: \"panel-label\" })\n panelLabel = \"\";\n @property({ type: String, attribute: \"dim-text\" })\n dimText = \"\";\n @property({ type: String })\n greeting = \"\";\n @property({ type: String })\n icon = \"\";\n @property({ type: String })\n intro = \"\";\n @property({ type: Array })\n items: string[] = [];\n @property({ type: String })\n footer = \"\";\n @property({ type: String, attribute: \"footer-bold\" })\n footerBold = \"\";\n @property({ type: Boolean, attribute: \"show-cursor\" })\n showCursor = false;\n @property({ type: String })\n hint = \"\";\n @property({ type: Array })\n lines: TerminalLine[] = [];\n @property({ type: String })\n caption = \"\";\n // \"default\" (existing look: optional titlebar dots, bordered panel,\n // standard host padding) | \"flush\" — used where the terminal sits over\n // decorative rings/a 3D scene (e.g. the VPN hero): hides the titlebar\n // dots regardless of show-titlebar, drops the inner panel's own\n // border (the host's outer box already reads as the terminal's edge),\n // gives each \"row\" line a hairline top border instead, and tightens\n // the host's own padding.\n @property({ type: String, reflect: true })\n variant: Variant = \"default\";\n\n _renderTitlebar() {\n if (this.variant === \"flush\") return nothing;\n if (!this.showTitlebar) return nothing;\n return html`\n <div class=\"bd-terminalmsg-titlebar\">\n <span class=\"bd-terminalmsg-dot bd-terminalmsg-dot--red\"></span>\n <span class=\"bd-terminalmsg-dot bd-terminalmsg-dot--yellow\"></span>\n <span class=\"bd-terminalmsg-dot bd-terminalmsg-dot--green\"></span>\n </div>\n `;\n }\n\n _renderHint() {\n if (!this.hint) return nothing;\n\n const parts = this.hint.split(/(\\[[^\\]]+\\])/g);\n\n return html`\n <span class=\"bd-terminalmsg-hint\">\n ${parts.map((part) =>\n /^\\[[^\\]]+\\]$/.test(part)\n ? html`<strong class=\"bd-terminalmsg-hint-key\">${part}</strong>`\n : part\n )}\n </span>\n `;\n }\n\n _renderLines() {\n if (!this.lines || !this.lines.length) return nothing;\n\n return html`\n <div class=\"bd-terminalmsg-lines\">\n ${this.lines.map(({ type, text, label, badge, badgeColor, live }) => {\n switch (type) {\n case \"sep\":\n return html`<hr class=\"bd-terminalmsg-l-sep\" />`;\n case \"space\":\n return html`<div class=\"bd-terminalmsg-l-space\" aria-hidden=\"true\"> </div>`;\n case \"cmd\":\n return html`<div class=\"bd-terminalmsg-l-cmd\">${text}</div>`;\n case \"ok\":\n return html`<div class=\"bd-terminalmsg-l-ok\">${text}</div>`;\n case \"ask\":\n return html`<div class=\"bd-terminalmsg-l-ask\">${text}</div>`;\n case \"strong\":\n return html`<div class=\"bd-terminalmsg-l-strong\">${text}</div>`;\n case \"dim\":\n return html`<div class=\"bd-terminalmsg-l-dim\">${text}</div>`;\n case \"title\":\n return html`\n <div class=\"bd-terminalmsg-l-title\">\n <span>${text}</span>\n ${live\n ? html`<span class=\"bd-terminalmsg-live\"><span class=\"bd-terminalmsg-live-dot\"></span>LIVE</span>`\n : nothing}\n </div>\n `;\n case \"row\":\n return html`\n <div class=\"bd-terminalmsg-l-row\">\n <span class=\"bd-terminalmsg-l-row-label\">${label}</span>\n <span class=\"bd-terminalmsg-l-row-text\">${text}</span>\n ${badge\n ? html`<span class=\"bd-terminalmsg-badge bd-terminalmsg-badge--${badgeColor || \"neutral\"}\">${badge}</span>`\n : nothing}\n </div>\n `;\n default:\n return html`<div class=\"bd-terminalmsg-l-dim\">${text}</div>`;\n }\n })}\n </div>\n `;\n }\n\n render() {\n return html`\n ${this._renderTitlebar()}\n\n <div class=\"bd-terminalmsg-panel\">\n ${this.panelLabel\n ? html`<span class=\"bd-terminalmsg-panel-label\">${this.panelLabel}</span>`\n : nothing}\n\n <div class=\"bd-terminalmsg-body\">\n ${this._renderLines()}\n\n ${this.dimText\n ? html`<bd-p variant=\"small\" font-family=\"mono\" paddingBottom=\"12\" class=\"bd-terminalmsg-dim\">${this.dimText}</bd-p>`\n : nothing}\n\n ${this.greeting\n ? html`\n <bd-p variant=\"regular\" font-family=\"mono\" paddingBottom=\"12\" class=\"bd-terminalmsg-greeting\">\n ${this.icon ? html`${this.icon} ` : nothing}\n <span class=\"bd-terminalmsg-greeting-text\">${this.greeting}</span>\n </bd-p>\n `\n : nothing}\n\n ${this.intro\n ? html`<bd-p variant=\"regular\" font-family=\"mono\" paddingBottom=\"12\" class=\"bd-terminalmsg-intro\">${this.intro}</bd-p>`\n : nothing}\n\n ${this.items && this.items.length\n ? html`\n <bd-list class=\"bd-terminalmsg-list\">\n ${this.items.map((item) => html`<bd-li variant=\"bullet\" size=\"sm\" color=\"inverse\">${item}</bd-li>`)}\n </bd-list>\n `\n : nothing}\n\n ${this.footer || this.footerBold\n ? html`\n <bd-p variant=\"regular\" font-family=\"mono\" class=\"bd-terminalmsg-footer\">\n ${this.footerBold\n ? html`<strong>${this.footerBold}</strong> `\n : nothing}\n ${this.footer}\n ${this.showCursor\n ? html`<bd-terminal-cursor></bd-terminal-cursor>`\n : nothing}\n </bd-p>\n `\n : nothing}\n\n <slot></slot>\n\n ${this.caption\n ? html`<div class=\"bd-terminalmsg-caption\">${this.caption}</div>`\n : nothing}\n </div>\n\n ${this._renderHint()}\n </div>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"bd-terminal-message\": TerminalMessage;\n }\n}\n"],"mappings":"A,geAuBA,IACMI,EADN,cAC8BC,CAAW,C,8BAIxB,KA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args","nothing","parts","part","type","text","live","label","badge","badgeColor","item","property","defineElement"],"sources":["../../../../src/components/terminal/terminal-message.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/list/list-item/list-item.ts\";\nimport \"#components/list/list.ts\";\nimport \"#components/paragraph/paragraph.ts\";\nimport \"./terminal-cursor.ts\";\nimport terminalMessageCSS from \"./terminal-message.css.ts\";\n\ntype Variant = \"default\" | \"flush\";\ntype LineType = \"sep\" | \"space\" | \"cmd\" | \"ok\" | \"ask\" | \"strong\" | \"dim\" | \"title\" | \"row\";\n\ninterface TerminalLine {\n type? : LineType;\n text? : string;\n label? : string;\n badge? : string;\n badgeColor?: string;\n live? : boolean;\n}\n\n@defineElement(\"bd-terminal-message\")\nclass TerminalMessage extends LitElement {\n static styles = [terminalMessageCSS];\n\n @property({ type: Boolean, attribute: \"show-titlebar\" })\n showTitlebar = false;\n @property({ type: String, attribute: \"panel-label\" })\n panelLabel = \"\";\n @property({ type: String, attribute: \"dim-text\" })\n dimText = \"\";\n @property({ type: String })\n greeting = \"\";\n @property({ type: String })\n icon = \"\";\n @property({ type: String })\n intro = \"\";\n @property({ type: Array })\n items: string[] = [];\n @property({ type: String })\n footer = \"\";\n @property({ type: String, attribute: \"footer-bold\" })\n footerBold = \"\";\n @property({ type: Boolean, attribute: \"show-cursor\" })\n showCursor = false;\n @property({ type: String })\n hint = \"\";\n @property({ type: Array })\n lines: TerminalLine[] = [];\n @property({ type: String })\n caption = \"\";\n // \"default\" (existing look: optional titlebar dots, bordered panel,\n // standard host padding) | \"flush\" — used where the terminal sits over\n // decorative rings/a 3D scene (e.g. the VPN hero): hides the titlebar\n // dots regardless of show-titlebar, drops the inner panel's own\n // border (the host's outer box already reads as the terminal's edge),\n // gives each \"row\" line a hairline top border instead, and tightens\n // the host's own padding.\n @property({ type: String, reflect: true })\n variant: Variant = \"default\";\n\n _renderTitlebar() {\n if (this.variant === \"flush\") return nothing;\n if (!this.showTitlebar) return nothing;\n return html`\n <div class=\"bd-terminalmsg-titlebar\">\n <span class=\"bd-terminalmsg-dot bd-terminalmsg-dot--red\"></span>\n <span class=\"bd-terminalmsg-dot bd-terminalmsg-dot--yellow\"></span>\n <span class=\"bd-terminalmsg-dot bd-terminalmsg-dot--green\"></span>\n </div>\n `;\n }\n\n _renderHint() {\n if (!this.hint) return nothing;\n\n const parts = this.hint.split(/(\\[[^\\]]+\\])/g);\n\n return html`\n <span class=\"bd-terminalmsg-hint\">\n ${parts.map((part) =>\n /^\\[[^\\]]+\\]$/.test(part)\n ? html`<strong class=\"bd-terminalmsg-hint-key\">${part}</strong>`\n : part\n )}\n </span>\n `;\n }\n\n _renderLines() {\n if (!this.lines || !this.lines.length) return nothing;\n\n return html`\n <div class=\"bd-terminalmsg-lines\">\n ${this.lines.map(({ type, text, label, badge, badgeColor, live }) => {\n switch (type) {\n case \"sep\":\n return html`<hr class=\"bd-terminalmsg-l-sep\" />`;\n case \"space\":\n return html`<div class=\"bd-terminalmsg-l-space\" aria-hidden=\"true\"> </div>`;\n case \"cmd\":\n return html`<div class=\"bd-terminalmsg-l-cmd\">${text}</div>`;\n case \"ok\":\n return html`<div class=\"bd-terminalmsg-l-ok\">${text}</div>`;\n case \"ask\":\n return html`<div class=\"bd-terminalmsg-l-ask\">${text}</div>`;\n case \"strong\":\n return html`<div class=\"bd-terminalmsg-l-strong\">${text}</div>`;\n case \"dim\":\n return html`<div class=\"bd-terminalmsg-l-dim\">${text}</div>`;\n case \"title\":\n return html`\n <div class=\"bd-terminalmsg-l-title\">\n <span>${text}</span>\n ${live\n ? html`<span class=\"bd-terminalmsg-live\"><span class=\"bd-terminalmsg-live-dot\"></span>LIVE</span>`\n : nothing}\n </div>\n `;\n case \"row\":\n return html`\n <div class=\"bd-terminalmsg-l-row\">\n <span class=\"bd-terminalmsg-l-row-label\">${label}</span>\n <span class=\"bd-terminalmsg-l-row-text\">${text}</span>\n ${badge\n ? html`<span class=\"bd-terminalmsg-badge bd-terminalmsg-badge--${badgeColor || \"neutral\"}\">${badge}</span>`\n : nothing}\n </div>\n `;\n default:\n return html`<div class=\"bd-terminalmsg-l-dim\">${text}</div>`;\n }\n })}\n </div>\n `;\n }\n\n render() {\n return html`\n ${this._renderTitlebar()}\n\n <div class=\"bd-terminalmsg-panel\">\n ${this.panelLabel\n ? html`<span class=\"bd-terminalmsg-panel-label\">${this.panelLabel}</span>`\n : nothing}\n\n <div class=\"bd-terminalmsg-body\">\n ${this._renderLines()}\n\n ${this.dimText\n ? html`<bd-p variant=\"small\" font-family=\"mono\" paddingBottom=\"12\" class=\"bd-terminalmsg-dim\">${this.dimText}</bd-p>`\n : nothing}\n\n ${this.greeting\n ? html`\n <bd-p variant=\"regular\" font-family=\"mono\" paddingBottom=\"12\" class=\"bd-terminalmsg-greeting\">\n ${this.icon ? html`${this.icon} ` : nothing}\n <span class=\"bd-terminalmsg-greeting-text\">${this.greeting}</span>\n </bd-p>\n `\n : nothing}\n\n ${this.intro\n ? html`<bd-p variant=\"regular\" font-family=\"mono\" paddingBottom=\"12\" class=\"bd-terminalmsg-intro\">${this.intro}</bd-p>`\n : nothing}\n\n ${this.items && this.items.length\n ? html`\n <bd-list class=\"bd-terminalmsg-list\">\n ${this.items.map((item) => html`<bd-li variant=\"bullet\" size=\"sm\" color=\"inverse\">${item}</bd-li>`)}\n </bd-list>\n `\n : nothing}\n\n ${this.footer || this.footerBold\n ? html`\n <bd-p variant=\"regular\" font-family=\"mono\" class=\"bd-terminalmsg-footer\">\n ${this.footerBold\n ? html`<strong>${this.footerBold}</strong> `\n : nothing}\n ${this.footer}\n ${this.showCursor\n ? html`<bd-terminal-cursor></bd-terminal-cursor>`\n : nothing}\n </bd-p>\n `\n : nothing}\n\n <slot></slot>\n\n ${this.caption\n ? html`<div class=\"bd-terminalmsg-caption\">${this.caption}</div>`\n : nothing}\n </div>\n\n ${this._renderHint()}\n </div>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"bd-terminal-message\": TerminalMessage;\n }\n}\n"],"mappings":"A,+cAwBA,IACMI,EADN,cAC8BC,CAAW,C,8BAIxB,KAAA,aAAA,GAEF,KAAA,WAAA,GAEH,KAAA,QAAA,GAEC,KAAA,SAAA,GAEJ,KAAA,KAAA,GAEC,KAAA,MAAA,GAEU,KAAA,MAAA,CAAC,EAEV,KAAA,OAAA,GAEI,KAAA,WAAA,GAEA,KAAA,WAAA,GAEN,KAAA,KAAA,GAEiB,KAAA,MAAA,CAAC,EAEf,KAAA,QAAA,GASS,KAAA,QAAA,S,QApCH,KAAA,OAAA,CAACL,CAAkB,C,CAsCnC,iBAAkB,CAGhB,OAFI,KAAK,UAAY,SACjB,CAAC,KAAK,aAAqBO,EACxB,CAAI;;;;;;KAOb,CAEA,aAAc,CACZ,GAAI,CAAC,KAAK,KAAM,OAAOA,EAEvB,IAAMC,EAAQ,KAAK,KAAK,MAAM,eAAe,EAE7C,MAAO,EAAI;;UAELA,EAAM,IAAK,GACX,eAAe,KAAKC,CAAI,EACpB,CAAI,2CAA2CA,EAAK,WACpDA,CACN,EAAE;;KAGR,CAEA,cAAe,CAGb,MAFI,CAAC,KAAK,OAAS,CAAC,KAAK,MAAM,OAAeF,EAEvC,CAAI;;UAEL,KAAK,MAAM,KAAK,CAAE,OAAM,OAAM,QAAO,QAAO,aAAY,UAAW,CACnE,OAAQG,EAAR,CACE,IAAK,MACH,MAAO,EAAI,sCACb,IAAK,QACH,MAAO,EAAI,sEACb,IAAK,MACH,MAAO,EAAI,qCAAqCC,EAAK,QACvD,IAAK,KACH,MAAO,EAAI,oCAAoCA,EAAK,QACtD,IAAK,MACH,MAAO,EAAI,qCAAqCA,EAAK,QACvD,IAAK,SACH,MAAO,EAAI,wCAAwCA,EAAK,QAC1D,IAAK,MACH,MAAO,EAAI,q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,EAAAb,EAAA,UAAA,UAAA,IAAA,EAAA,EArC1C,EAAAH,EAAA,CAAAiB,EAAc,qBAAqB,CAAA,EAAAd,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
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 n from"./tooltip.css.js";import{LitElement as r,html as i,nothing as a}from"lit";import{property as o,state as s}from"lit/decorators.js";var c=0,l=class extends r{constructor(...e){super(...e),this.text=``,this._dismissed=!1}static{this.styles=[n]}_margin(){let e=getComputedStyle(this).getPropertyValue(`--spacing-16`),t=parseFloat(e);return Number.isFinite(t)?e.includes(`rem`)?t*
|
|
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 n from"./tooltip.css.js";import{LitElement as r,html as i,nothing as a}from"lit";import{property as o,state as s}from"lit/decorators.js";var c=0,l=class extends r{constructor(...e){super(...e),this.text=``,this._dismissed=!1}static{this.styles=[n]}_margin(){let e=getComputedStyle(this).getPropertyValue(`--spacing-16`),t=parseFloat(e),n=parseFloat(getComputedStyle(document.documentElement).fontSize)||16;return Number.isFinite(t)?e.includes(`rem`)?t*n:t:16}_place(){let e=this.renderRoot?.querySelector(`.bubble`);if(!e)return;e.style.setProperty(`--bd-tooltip-shift`,`0px`);let t=e.getBoundingClientRect();if(t.width===0)return;let n=this._margin(),r=n-t.left,i=window.innerWidth-n-t.right,a=r>i?r:Math.min(Math.max(0,r),i);e.style.setProperty(`--bd-tooltip-shift`,`${Math.round(a)}px`)}firstUpdated(){this._place(),this._observe()}get _showing(){return!this._dismissed&&(this.matches(`:hover`)||this.matches(`:focus-within`))}_observe(){if(typeof ResizeObserver>`u`||this._ro)return;this._ro=new ResizeObserver(()=>this._place()),this._ro.observe(this);let e=this.renderRoot?.querySelector(`.bubble`);e&&this._ro.observe(e)}connectedCallback(){super.connectedCallback(),this.hasUpdated&&this._observe(),this._onShow=()=>this._place(),this.addEventListener(`mouseenter`,this._onShow),this.addEventListener(`focusin`,this._onShow),window.addEventListener(`resize`,this._onShow),this._onKeydown=e=>{e.key===`Escape`&&!e.defaultPrevented&&this._showing&&(e.preventDefault(),this._dismissed=!0)},this._onLeave=e=>{if(!this._dismissed)return;let t=e.type===`mouseleave`||!this.matches(`:hover`),n=e.type===`focusout`?!this.contains(e.relatedTarget)&&!this.shadowRoot.contains(e.relatedTarget):!this.matches(`:focus-within`);t&&n&&(this._dismissed=!1)},document.addEventListener(`keydown`,this._onKeydown,!0),this.addEventListener(`mouseleave`,this._onLeave),this.addEventListener(`focusout`,this._onLeave)}disconnectedCallback(){this.removeEventListener(`mouseenter`,this._onShow),this.removeEventListener(`focusin`,this._onShow),window.removeEventListener(`resize`,this._onShow),document.removeEventListener(`keydown`,this._onKeydown,!0),this.removeEventListener(`mouseleave`,this._onLeave),this.removeEventListener(`focusout`,this._onLeave),this._ro?.disconnect(),this._ro=void 0,super.disconnectedCallback()}_describe(){this._undescribe();let e=(this.shadowRoot?.querySelector(`slot`))?.assignedElements()[0];if(e&&this.text){if(e.localName.includes(`-`)&&!customElements.get(e.localName))customElements.whenDefined(e.localName).then(()=>this._describe());else{if(`description`in e&&e.localName.includes(`-`))e.description=this.text,this._described={trigger:e,kind:`property`};else if(!e.localName.includes(`-`)){let t=document.createElement(`span`);t.id=`bd-tooltip-description-${++c}`,t.slot=`description`,t.hidden=!0,t.textContent=this.text,this.append(t);let n=(e.getAttribute(`aria-describedby`)||``).split(/\s+/).filter(Boolean);e.setAttribute(`aria-describedby`,[...n,t.id].join(` `)),this._described={trigger:e,kind:`idref`,node:t}}this.requestUpdate()}}}_undescribe(){let e=this._described;if(e){if(e.kind===`property`)e.trigger.description=``;else{let t=(e.trigger.getAttribute(`aria-describedby`)||``).split(/\s+/).filter(t=>t&&t!==e.node.id);t.length?e.trigger.setAttribute(`aria-describedby`,t.join(` `)):e.trigger.removeAttribute(`aria-describedby`),e.node.remove()}this._described=null,this.requestUpdate()}}updated(e){e.has(`text`)&&this.hasUpdated&&this._describe()}render(){return i`
|
|
2
2
|
<slot @slotchange=${()=>this._describe()}></slot>
|
|
3
3
|
<!-- the trigger's description: hidden, but slotted, because a node
|
|
4
4
|
assigned to no slot is not in the flat tree and Chrome then drops
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tooltip.js","names":["_decorate","__decorate","tooltipCSS","descriptionIds","BdTooltip","LitElement","_args","raw","px","bubble","box","margin","minShift","maxShift","shift","pointerGone","focusGone","trigger","node","ids","d","changed","nothing","property","state","defineElement"],"sources":["../../../../src/components/tooltip/tooltip.ts"],"sourcesContent":["import { LitElement, html, nothing, type PropertyValues } 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 { tooltipCSS } from './tooltip.css.ts';\n\nlet descriptionIds = 0;\n\ntype Described =\n | { trigger: Element & { description: unknown }; kind: 'property' }\n | { trigger: Element; kind: 'idref'; node: HTMLSpanElement };\n\n@defineElement('bd-tooltip')\nexport class BdTooltip extends LitElement {\n static styles = [tooltipCSS];\n\n @property({ type: String })\n text = '';\n /* Set by Escape and cleared once neither the pointer nor focus is on the\n tooltip any more, so the next hover or focus shows it again. */\n @state()\n _dismissed = false;\n\n _ro? : ResizeObserver;\n _onShow! : () => void;\n _onKeydown!: (e: KeyboardEvent) => void;\n _onLeave! : (e: MouseEvent | FocusEvent) => void;\n _described?: Described | null;\n\n /* The bubble is centred on its trigger and is wider than it, so near a\n viewport edge part of it lands outside the page. No CSS can fix that --\n the browser cannot be asked \"where is my trigger\" from a stylesheet -- so\n the shift is measured here and handed back to CSS as a custom property.\n\n Deliberately additive: --bd-tooltip-shift defaults to 0 in the stylesheet,\n so a tooltip in a document where this never runs renders exactly as it did\n before. getBoundingClientRect and ResizeObserver are both already used by\n five components in this package; this is the same pattern, not a new one. */\n /**\n * The margin the bubble keeps from each viewport edge, read from the same\n * token the stylesheet subtracts. The cap there is `100vw - --spacing-32`,\n * which is that margin on each side, and the two numbers have to agree: the\n * previous version clamped to a hard-coded 8 while the stylesheet reserved\n * 16, so placement aimed at a boundary the width contract had not left room\n * for.\n */\n _margin() {\n const raw = getComputedStyle(this).getPropertyValue('--spacing-16');\n const px = parseFloat(raw);\n /* Tokens are installed in document scope and always resolve; the fallback\n is for a disconnected element, where getComputedStyle returns nothing. */\n return Number.isFinite(px) ? (raw.includes('rem') ? px * 16 : px) : 16;\n }\n\n /* The bubble is centred on its trigger and is wider than it, so near a\n viewport edge part of it lands outside the page. No CSS can fix that --\n the browser cannot be asked \"where is my trigger\" from a stylesheet -- so\n the shift is measured here and handed back to CSS as a custom property.\n\n Deliberately additive: --bd-tooltip-shift defaults to 0 in the stylesheet,\n so a tooltip in a document where this never runs renders exactly as it did\n before.\n\n Both edges, not one. The previous version corrected whichever edge it\n found outside first and stopped -- an `if` on the left and an `else if` on\n the right -- which is only sound while the bubble is narrower than the\n space between the margins. It was not: the border box ran 16px past its\n own cap, so pushing the left edge in pushed the right edge out and the\n `else if` never ran to notice.\n\n Now the two constraints are solved together. For a shift s the bubble\n lands at [left + s, right + s], and staying inside the margins means\n\n s >= M - left and s <= V - M - right\n\n so the centred position s = 0 is clamped into [minShift, maxShift]. With\n box-sizing: border-box the bubble is at most V - 2M wide, which is exactly\n the condition for that interval to be non-empty -- the width contract is\n what makes the placement solvable, which is why the box model had to be\n fixed first. */\n _place() {\n const bubble = this.renderRoot?.querySelector<HTMLElement>('.bubble');\n if (!bubble) return;\n bubble.style.setProperty('--bd-tooltip-shift', '0px');\n const box = bubble.getBoundingClientRect();\n if (box.width === 0) return;\n\n const margin = this._margin();\n const minShift = margin - box.left;\n const maxShift = window.innerWidth - margin - box.right;\n\n /* minShift > maxShift means the bubble is wider than the space between the\n margins, which the width cap should prevent. If a consuming page has\n overridden that cap, the left edge wins: the start of the text stays\n readable rather than the end of it. */\n const shift = minShift > maxShift\n ? minShift\n : Math.min(Math.max(0, minShift), maxShift);\n\n bubble.style.setProperty('--bd-tooltip-shift', `${Math.round(shift)}px`);\n }\n\n /* Placement runs once the bubble has a box, not only when it is revealed.\n The bubble is laid out at all times -- opacity: 0 hides it and\n pointer-events: none takes it out of the way, but neither takes it out of\n flow -- so an unplaced bubble on a trigger near the right edge widened the\n document: measured at 1440, the right-edge bubble in Atoms/Tooltip \"At the\n viewport edges\" ended at x=1622.5 and the page scrollWidth was 1623, a\n 183px horizontal scrollbar produced by something invisible.\n\n This is not the placement-on-first-update that P7F tried and reverted.\n That call ran the single-edge algorithm above on a content-box bubble, and\n it moved the overflow rather than removing it -- 183px at the right edge\n became 61px on Long Text at 320. Running it here is only correct because\n the width contract and the clamp were fixed first; the ordering is the\n fix, not the call site.\n\n One pass here is not enough on its own, and the observer below is why.\n Measured: this call alone left Long Text at 320 with shift 80px and 53px\n of overflow, where placing again after everything had settled produced\n shift 11px and none. The arithmetic was right both times -- the geometry\n was not final the first time. */\n firstUpdated() {\n this._place();\n /* The trigger is slotted light DOM and is usually a custom element of its\n own, so it upgrades and takes its real width AFTER this tooltip has\n rendered: the bubble is centred on a reference that has not finished\n existing. Observing both boxes covers that, and the font swap and any\n later content change with it, rather than guessing a delay.\n\n Both boxes, because they move for different reasons: the host changes\n when the trigger resizes, the bubble when its own text reflows.\n ResizeObserver fires once on observe, which is the settled first pass. */\n this._observe();\n }\n\n /* ESCAPE. WCAG 1.4.13 asks that content shown on hover or focus can be\n dismissed without moving the pointer or focus. The pointer may be over the\n trigger while focus is anywhere on the page, so the key is heard on the\n document, and only acted on while this bubble is actually showing.\n\n Capture phase, and the event is marked handled with preventDefault rather\n than stopped: a tooltip is the innermost thing that can be open, so its\n Escape should not also close a native <dialog> it sits in, and a dialog's\n cancel is exactly what preventDefault on that keydown withholds.\n Propagation is left alone, as bd-modal leaves it, so a page that wants to\n hear the key still does. */\n get _showing() {\n return !this._dismissed && (this.matches(':hover') || this.matches(':focus-within'));\n }\n\n /* Started on first render and again on every reconnect. It used to start\n only in firstUpdated, and disconnectedCallback tears it down, so a tooltip\n moved in the DOM -- removed and re-inserted, which a framework reordering\n a list does -- came back with no observer and never re-placed itself when\n its trigger or text changed size. */\n _observe() {\n if (typeof ResizeObserver === 'undefined' || this._ro) return;\n this._ro = new ResizeObserver(() => this._place());\n this._ro.observe(this);\n const bubble = this.renderRoot?.querySelector('.bubble');\n if (bubble) this._ro.observe(bubble);\n }\n\n connectedCallback() {\n super.connectedCallback();\n // a first connection is handled by firstUpdated, once the bubble exists\n if (this.hasUpdated) this._observe();\n this._onShow = () => this._place();\n /* Both reveals the stylesheet already honours, and resize because the\n measurement is only true for the width it was taken at. */\n this.addEventListener('mouseenter', this._onShow);\n this.addEventListener('focusin', this._onShow);\n window.addEventListener('resize', this._onShow);\n\n this._onKeydown = e => {\n if (e.key !== 'Escape' || e.defaultPrevented || !this._showing) return;\n e.preventDefault();\n this._dismissed = true;\n };\n /* Back to normal once the pointer and focus have both gone: a pointer\n leaving while focus stays inside keeps it dismissed, and the reverse. */\n this._onLeave = e => {\n if (!this._dismissed) return;\n const pointerGone = e.type === 'mouseleave' || !this.matches(':hover');\n const focusGone = e.type === 'focusout'\n ? !this.contains(e.relatedTarget as Node | null) && !this.shadowRoot!.contains(e.relatedTarget as Node | null)\n : !this.matches(':focus-within');\n if (pointerGone && focusGone) this._dismissed = false;\n };\n document.addEventListener('keydown', this._onKeydown, true);\n this.addEventListener('mouseleave', this._onLeave);\n this.addEventListener('focusout', this._onLeave);\n }\n\n disconnectedCallback() {\n this.removeEventListener('mouseenter', this._onShow);\n this.removeEventListener('focusin', this._onShow);\n window.removeEventListener('resize', this._onShow);\n document.removeEventListener('keydown', this._onKeydown, true);\n this.removeEventListener('mouseleave', this._onLeave);\n this.removeEventListener('focusout', this._onLeave);\n this._ro?.disconnect();\n this._ro = undefined;\n super.disconnectedCallback();\n }\n\n /* DESCRIBING THE TRIGGER.\n The bubble had role=\"tooltip\" and nothing pointed at it, so a screen\n reader landing on the trigger heard its name and not the tooltip, and\n the bubble's text sat in the page as a stray line. It cannot be pointed\n at directly: the bubble is in this shadow root and the trigger is not,\n and an id reference never crosses that boundary. So the trigger is\n described from its own side:\n\n a native control aria-describedby names a hidden copy of the text,\n kept as a child of this element in a hidden slot --\n the same tree as the trigger, so the reference\n resolves\n bd-button, the text goes to its description property, which\n bd-button-link, wires aria-describedby inside its own shadow root,\n bd-link where its real control is\n\n Once described, the bubble is hidden from assistive technology so the\n text is not read twice. Any other custom element as trigger keeps the\n bubble exposed and goes undescribed -- its control is out of reach. */\n _describe() {\n this._undescribe();\n const slot = this.shadowRoot?.querySelector('slot');\n const trigger = slot?.assignedElements()[0];\n if (!trigger || !this.text) return;\n\n // a custom element that has not upgraded yet has no description to set:\n // come back once it has\n if (trigger.localName.includes('-') && !customElements.get(trigger.localName)) {\n customElements.whenDefined(trigger.localName).then(() => this._describe());\n return;\n }\n\n if ('description' in trigger && trigger.localName.includes('-')) {\n trigger.description = this.text;\n this._described = { trigger, kind: 'property' };\n } else if (!trigger.localName.includes('-')) {\n const node = document.createElement('span');\n node.id = `bd-tooltip-description-${++descriptionIds}`;\n node.slot = 'description';\n node.hidden = true;\n node.textContent = this.text;\n this.append(node);\n const ids = (trigger.getAttribute('aria-describedby') || '').split(/\\s+/).filter(Boolean);\n trigger.setAttribute('aria-describedby', [...ids, node.id].join(' '));\n this._described = { trigger, kind: 'idref', node };\n }\n this.requestUpdate();\n }\n\n _undescribe() {\n const d = this._described;\n if (!d) return;\n if (d.kind === 'property') {\n d.trigger.description = '';\n } else {\n const ids = (d.trigger.getAttribute('aria-describedby') || '').split(/\\s+/).filter(t => t && t !== d.node.id);\n if (ids.length) d.trigger.setAttribute('aria-describedby', ids.join(' '));\n else d.trigger.removeAttribute('aria-describedby');\n d.node.remove();\n }\n this._described = null;\n this.requestUpdate();\n }\n\n updated(changed: PropertyValues<this>) {\n if (changed.has('text') && this.hasUpdated) this._describe();\n }\n\n render() {\n return html`\n <slot @slotchange=${() => this._describe()}></slot>\n <!-- the trigger's description: hidden, but slotted, because a node\n assigned to no slot is not in the flat tree and Chrome then drops\n an aria-describedby that points at it -->\n <span hidden><slot name=\"description\"></slot></span>\n <span\n class=\"bubble ${this._dismissed ? 'bubble--dismissed' : ''}\"\n role=\"tooltip\"\n aria-hidden=\"${this._described ? 'true' : nothing}\"\n >${this.text}</span>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'bd-tooltip': BdTooltip;\n }\n}\n"],"mappings":"A,qTAOA,IAAIG,EAAiB,EAORC,EAAN,cAAwBC,CAAW,C,8BAIjC,KAAA,KAAA,GAIM,KAAA,WAAA,E,QAPG,KAAA,OAAA,CAACH,CAAU,C,CAgC3B,SAAU,CACR,IAAMK,EAAM,iBAAiB,IAAI,CAAC,CAAC,iBAAiB,cAAc,EAC5DC,EAAK,WAAWD,CAAG,EAGzB,OAAO,OAAO,SAASC,CAAE,EAAKD,EAAI,SAAS,KAAK,EAAIC,EAAK,GAAKA,EAAM,EACtE,CA4BA,QAAS,CACP,IAAMC,EAAS,KAAK,YAAY,cAA2B,SAAS,EACpE,GAAI,CAACA,EAAQ,OACbA,EAAO,MAAM,YAAY,qBAAsB,KAAK,EACpD,IAAMC,EAAMD,EAAO,sBAAsB,EACzC,GAAIC,EAAI,QAAU,EAAG,OAErB,IAAMC,EAAS,KAAK,QAAQ,EACtBC,EAAWD,EAASD,EAAI,KACxBG,EAAW,OAAO,WAAaF,EAASD,EAAI,MAM5CI,EAAQF,EAAWC,EACrBD,EACA,KAAK,IAAI,KAAK,IAAI,EAAGA,CAAQ,EAAGC,CAAQ,EAE5CJ,EAAO,MAAM,YAAY,qBAAsB,GAAG,KAAK,MAAMK,CAAK,EAAE,GAAG,CACzE,CAsBA,cAAe,CACb,KAAK,OAAO,EAUZ,KAAK,SAAS,CAChB,CAaA,IAAI,UAAW,CACb,MAAO,CAAC,KAAK,a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,IAAMA,EAAE,KAAK,EAAE,EACxGD,EAAI,OAAQC,EAAE,QAAQ,aAAa,mBAAoBD,EAAI,KAAK,GAAG,CAAC,EACnEC,EAAE,QAAQ,gBAAgB,kBAAkB,EACjDA,EAAE,KAAK,OAAO,CAChB,CACA,KAAK,WAAa,KAClB,KAAK,cAAc,CAFnB,CAGF,CAEA,QAAQ,EAA+B,CACjCC,EAAQ,IAAI,MAAM,GAAK,KAAK,YAAY,KAAK,UAAU,CAC7D,CAEA,QAAS,CACP,MAAO,EAAI;8BACiB,KAAK,UAAU,EAAE;;;;;;wBAMzB,KAAK,WAAa,oBAAsB,GAAG;;uBAE5C,KAAK,WAAa,OAASC,EAAQ;SACjD,KAAK,KAAK;KAEjB,CACF,EAjRGtB,EAAA,CAAAuB,EAAS,CAAE,KAAM,MAAO,CAAC,CAAA,EAAAnB,EAAA,UAAA,OAAA,IAAA,EAAA,EAIzBJ,EAAA,CAAAwB,EAAM,CAAA,EAAApB,EAAA,UAAA,aAAA,IAAA,EAAA,EARR,EAAAJ,EAAA,CAAAyB,EAAc,YAAY,CAAA,EAAArB,CAAA,E"}
|
|
1
|
+
{"version":3,"file":"tooltip.js","names":["_decorate","__decorate","tooltipCSS","descriptionIds","BdTooltip","LitElement","_args","raw","px","rem","bubble","box","margin","minShift","maxShift","shift","pointerGone","focusGone","trigger","node","ids","d","changed","nothing","property","state","defineElement"],"sources":["../../../../src/components/tooltip/tooltip.ts"],"sourcesContent":["import { LitElement, html, nothing, type PropertyValues } 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 { tooltipCSS } from './tooltip.css.ts';\n\nlet descriptionIds = 0;\n\ntype Described =\n | { trigger: Element & { description: unknown }; kind: 'property' }\n | { trigger: Element; kind: 'idref'; node: HTMLSpanElement };\n\n@defineElement('bd-tooltip')\nexport class BdTooltip extends LitElement {\n static styles = [tooltipCSS];\n\n @property({ type: String })\n text = '';\n /* Set by Escape and cleared once neither the pointer nor focus is on the\n tooltip any more, so the next hover or focus shows it again. */\n @state()\n _dismissed = false;\n\n _ro? : ResizeObserver;\n _onShow! : () => void;\n _onKeydown!: (e: KeyboardEvent) => void;\n _onLeave! : (e: MouseEvent | FocusEvent) => void;\n _described?: Described | null;\n\n /* The bubble is centred on its trigger and is wider than it, so near a\n viewport edge part of it lands outside the page. No CSS can fix that --\n the browser cannot be asked \"where is my trigger\" from a stylesheet -- so\n the shift is measured here and handed back to CSS as a custom property.\n\n Deliberately additive: --bd-tooltip-shift defaults to 0 in the stylesheet,\n so a tooltip in a document where this never runs renders exactly as it did\n before. getBoundingClientRect and ResizeObserver are both already used by\n five components in this package; this is the same pattern, not a new one. */\n /**\n * The margin the bubble keeps from each viewport edge, read from the same\n * token the stylesheet subtracts. The cap there is `100vw - --spacing-32`,\n * which is that margin on each side, and the two numbers have to agree: the\n * previous version clamped to a hard-coded 8 while the stylesheet reserved\n * 16, so placement aimed at a boundary the width contract had not left room\n * for.\n */\n _margin() {\n const raw = getComputedStyle(this).getPropertyValue('--spacing-16');\n const px = parseFloat(raw);\n /* A custom property reads back as written, 1rem, so the rem is turned into\n pixels at the root's own size -- the one the stylesheet's cap resolves\n at. It was multiplied by 16, which is right only at the default size:\n a reader at 24px got a 24px cap and a 16px clamp. */\n const rem = parseFloat(getComputedStyle(document.documentElement).fontSize) || 16;\n /* Tokens are installed in document scope and always resolve; the fallback\n is for a disconnected element, where getComputedStyle returns nothing. */\n return Number.isFinite(px) ? (raw.includes('rem') ? px * rem : px) : 16;\n }\n\n /* The bubble is centred on its trigger and is wider than it, so near a\n viewport edge part of it lands outside the page. No CSS can fix that --\n the browser cannot be asked \"where is my trigger\" from a stylesheet -- so\n the shift is measured here and handed back to CSS as a custom property.\n\n Deliberately additive: --bd-tooltip-shift defaults to 0 in the stylesheet,\n so a tooltip in a document where this never runs renders exactly as it did\n before.\n\n Both edges, not one. The previous version corrected whichever edge it\n found outside first and stopped -- an `if` on the left and an `else if` on\n the right -- which is only sound while the bubble is narrower than the\n space between the margins. It was not: the border box ran 16px past its\n own cap, so pushing the left edge in pushed the right edge out and the\n `else if` never ran to notice.\n\n Now the two constraints are solved together. For a shift s the bubble\n lands at [left + s, right + s], and staying inside the margins means\n\n s >= M - left and s <= V - M - right\n\n so the centred position s = 0 is clamped into [minShift, maxShift]. With\n box-sizing: border-box the bubble is at most V - 2M wide, which is exactly\n the condition for that interval to be non-empty -- the width contract is\n what makes the placement solvable, which is why the box model had to be\n fixed first. */\n _place() {\n const bubble = this.renderRoot?.querySelector<HTMLElement>('.bubble');\n if (!bubble) return;\n bubble.style.setProperty('--bd-tooltip-shift', '0px');\n const box = bubble.getBoundingClientRect();\n if (box.width === 0) return;\n\n const margin = this._margin();\n const minShift = margin - box.left;\n const maxShift = window.innerWidth - margin - box.right;\n\n /* minShift > maxShift means the bubble is wider than the space between the\n margins, which the width cap should prevent. If a consuming page has\n overridden that cap, the left edge wins: the start of the text stays\n readable rather than the end of it. */\n const shift = minShift > maxShift\n ? minShift\n : Math.min(Math.max(0, minShift), maxShift);\n\n bubble.style.setProperty('--bd-tooltip-shift', `${Math.round(shift)}px`);\n }\n\n /* Placement runs once the bubble has a box, not only when it is revealed.\n The bubble is laid out at all times -- opacity: 0 hides it and\n pointer-events: none takes it out of the way, but neither takes it out of\n flow -- so an unplaced bubble on a trigger near the right edge widened the\n document: measured at 1440, the right-edge bubble in Atoms/Tooltip \"At the\n viewport edges\" ended at x=1622.5 and the page scrollWidth was 1623, a\n 183px horizontal scrollbar produced by something invisible.\n\n This is not the placement-on-first-update that P7F tried and reverted.\n That call ran the single-edge algorithm above on a content-box bubble, and\n it moved the overflow rather than removing it -- 183px at the right edge\n became 61px on Long Text at 320. Running it here is only correct because\n the width contract and the clamp were fixed first; the ordering is the\n fix, not the call site.\n\n One pass here is not enough on its own, and the observer below is why.\n Measured: this call alone left Long Text at 320 with shift 80px and 53px\n of overflow, where placing again after everything had settled produced\n shift 11px and none. The arithmetic was right both times -- the geometry\n was not final the first time. */\n firstUpdated() {\n this._place();\n /* The trigger is slotted light DOM and is usually a custom element of its\n own, so it upgrades and takes its real width AFTER this tooltip has\n rendered: the bubble is centred on a reference that has not finished\n existing. Observing both boxes covers that, and the font swap and any\n later content change with it, rather than guessing a delay.\n\n Both boxes, because they move for different reasons: the host changes\n when the trigger resizes, the bubble when its own text reflows.\n ResizeObserver fires once on observe, which is the settled first pass. */\n this._observe();\n }\n\n /* ESCAPE. WCAG 1.4.13 asks that content shown on hover or focus can be\n dismissed without moving the pointer or focus. The pointer may be over the\n trigger while focus is anywhere on the page, so the key is heard on the\n document, and only acted on while this bubble is actually showing.\n\n Capture phase, and the event is marked handled with preventDefault rather\n than stopped: a tooltip is the innermost thing that can be open, so its\n Escape should not also close a native <dialog> it sits in, and a dialog's\n cancel is exactly what preventDefault on that keydown withholds.\n Propagation is left alone, as bd-modal leaves it, so a page that wants to\n hear the key still does. */\n get _showing() {\n return !this._dismissed && (this.matches(':hover') || this.matches(':focus-within'));\n }\n\n /* Started on first render and again on every reconnect. It used to start\n only in firstUpdated, and disconnectedCallback tears it down, so a tooltip\n moved in the DOM -- removed and re-inserted, which a framework reordering\n a list does -- came back with no observer and never re-placed itself when\n its trigger or text changed size. */\n _observe() {\n if (typeof ResizeObserver === 'undefined' || this._ro) return;\n this._ro = new ResizeObserver(() => this._place());\n this._ro.observe(this);\n const bubble = this.renderRoot?.querySelector('.bubble');\n if (bubble) this._ro.observe(bubble);\n }\n\n connectedCallback() {\n super.connectedCallback();\n // a first connection is handled by firstUpdated, once the bubble exists\n if (this.hasUpdated) this._observe();\n this._onShow = () => this._place();\n /* Both reveals the stylesheet already honours, and resize because the\n measurement is only true for the width it was taken at. */\n this.addEventListener('mouseenter', this._onShow);\n this.addEventListener('focusin', this._onShow);\n window.addEventListener('resize', this._onShow);\n\n this._onKeydown = e => {\n if (e.key !== 'Escape' || e.defaultPrevented || !this._showing) return;\n e.preventDefault();\n this._dismissed = true;\n };\n /* Back to normal once the pointer and focus have both gone: a pointer\n leaving while focus stays inside keeps it dismissed, and the reverse. */\n this._onLeave = e => {\n if (!this._dismissed) return;\n const pointerGone = e.type === 'mouseleave' || !this.matches(':hover');\n const focusGone = e.type === 'focusout'\n ? !this.contains(e.relatedTarget as Node | null) && !this.shadowRoot!.contains(e.relatedTarget as Node | null)\n : !this.matches(':focus-within');\n if (pointerGone && focusGone) this._dismissed = false;\n };\n document.addEventListener('keydown', this._onKeydown, true);\n this.addEventListener('mouseleave', this._onLeave);\n this.addEventListener('focusout', this._onLeave);\n }\n\n disconnectedCallback() {\n this.removeEventListener('mouseenter', this._onShow);\n this.removeEventListener('focusin', this._onShow);\n window.removeEventListener('resize', this._onShow);\n document.removeEventListener('keydown', this._onKeydown, true);\n this.removeEventListener('mouseleave', this._onLeave);\n this.removeEventListener('focusout', this._onLeave);\n this._ro?.disconnect();\n this._ro = undefined;\n super.disconnectedCallback();\n }\n\n /* DESCRIBING THE TRIGGER.\n The bubble had role=\"tooltip\" and nothing pointed at it, so a screen\n reader landing on the trigger heard its name and not the tooltip, and\n the bubble's text sat in the page as a stray line. It cannot be pointed\n at directly: the bubble is in this shadow root and the trigger is not,\n and an id reference never crosses that boundary. So the trigger is\n described from its own side:\n\n a native control aria-describedby names a hidden copy of the text,\n kept as a child of this element in a hidden slot --\n the same tree as the trigger, so the reference\n resolves\n bd-button, the text goes to its description property, which\n bd-button-link, wires aria-describedby inside its own shadow root,\n bd-link where its real control is\n\n Once described, the bubble is hidden from assistive technology so the\n text is not read twice. Any other custom element as trigger keeps the\n bubble exposed and goes undescribed -- its control is out of reach. */\n _describe() {\n this._undescribe();\n const slot = this.shadowRoot?.querySelector('slot');\n const trigger = slot?.assignedElements()[0];\n if (!trigger || !this.text) return;\n\n // a custom element that has not upgraded yet has no description to set:\n // come back once it has\n if (trigger.localName.includes('-') && !customElements.get(trigger.localName)) {\n customElements.whenDefined(trigger.localName).then(() => this._describe());\n return;\n }\n\n if ('description' in trigger && trigger.localName.includes('-')) {\n trigger.description = this.text;\n this._described = { trigger, kind: 'property' };\n } else if (!trigger.localName.includes('-')) {\n const node = document.createElement('span');\n node.id = `bd-tooltip-description-${++descriptionIds}`;\n node.slot = 'description';\n node.hidden = true;\n node.textContent = this.text;\n this.append(node);\n const ids = (trigger.getAttribute('aria-describedby') || '').split(/\\s+/).filter(Boolean);\n trigger.setAttribute('aria-describedby', [...ids, node.id].join(' '));\n this._described = { trigger, kind: 'idref', node };\n }\n this.requestUpdate();\n }\n\n _undescribe() {\n const d = this._described;\n if (!d) return;\n if (d.kind === 'property') {\n d.trigger.description = '';\n } else {\n const ids = (d.trigger.getAttribute('aria-describedby') || '').split(/\\s+/).filter(t => t && t !== d.node.id);\n if (ids.length) d.trigger.setAttribute('aria-describedby', ids.join(' '));\n else d.trigger.removeAttribute('aria-describedby');\n d.node.remove();\n }\n this._described = null;\n this.requestUpdate();\n }\n\n updated(changed: PropertyValues<this>) {\n if (changed.has('text') && this.hasUpdated) this._describe();\n }\n\n render() {\n return html`\n <slot @slotchange=${() => this._describe()}></slot>\n <!-- the trigger's description: hidden, but slotted, because a node\n assigned to no slot is not in the flat tree and Chrome then drops\n an aria-describedby that points at it -->\n <span hidden><slot name=\"description\"></slot></span>\n <span\n class=\"bubble ${this._dismissed ? 'bubble--dismissed' : ''}\"\n role=\"tooltip\"\n aria-hidden=\"${this._described ? 'true' : nothing}\"\n >${this.text}</span>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'bd-tooltip': BdTooltip;\n }\n}\n"],"mappings":"A,qTAOA,IAAIG,EAAiB,EAORC,EAAN,cAAwBC,CAAW,C,8BAIjC,KAAA,KAAA,GAIM,KAAA,WAAA,E,QAPG,KAAA,OAAA,CAACH,CAAU,C,CAgC3B,SAAU,CACR,IAAMK,EAAM,iBAAiB,IAAI,CAAC,CAAC,iBAAiB,cAAc,EAC5DC,EAAK,WAAWD,CAAG,EAK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AAA,UAAA,OAAA,IAAA,EAAA,EAIzBJ,EAAA,CAAAyB,EAAM,CAAA,EAAArB,EAAA,UAAA,aAAA,IAAA,EAAA,EARR,EAAAJ,EAAA,CAAA0B,EAAc,YAAY,CAAA,EAAAtB,CAAA,E"}
|
|
@@ -1,31 +1,31 @@
|
|
|
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"../icons/arrow-right-icon.js";import"../link/link.js";import r from"./trust-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.eyebrow=``,this.title=``,this.description=``,this.linkLabel=``,this.linkHref=`#`,this.stats=[],this.cards=[]}static{this.styles=[n,r]}_renderCard(e,t){let n=`card-${t+1}-logos`;return a`
|
|
2
2
|
<div class="bd-trustpanel-card">
|
|
3
|
-
${e.eyebrow?
|
|
3
|
+
${e.eyebrow?a`<bd-p variant="eyebrow" class="bd-trustpanel-card-eyebrow">${e.eyebrow}</bd-p>`:o}
|
|
4
4
|
|
|
5
5
|
<div class="bd-trustpanel-card-logos">
|
|
6
6
|
<slot name="${n}"></slot>
|
|
7
7
|
</div>
|
|
8
8
|
|
|
9
|
-
${e.title?
|
|
9
|
+
${e.title?a`<bd-h as="h4" class="bd-trustpanel-card-title">${e.title}</bd-h>`:o}
|
|
10
10
|
|
|
11
|
-
${e.description?
|
|
11
|
+
${e.description?a`<bd-p variant="regular" class="bd-trustpanel-card-description">${e.description}</bd-p>`:o}
|
|
12
12
|
|
|
13
|
-
${e.linkLabel?
|
|
13
|
+
${e.linkLabel?a`
|
|
14
14
|
<a class="bd-trustpanel-card-link" href=${e.linkHref||`#`}>
|
|
15
15
|
${e.linkLabel} <bd-arrow-right-icon size="xs" aria-hidden="true"></bd-arrow-right-icon>
|
|
16
16
|
</a>
|
|
17
|
-
`:
|
|
17
|
+
`:o}
|
|
18
18
|
</div>
|
|
19
|
-
`}render(){return
|
|
19
|
+
`}render(){return a`
|
|
20
20
|
<div class="bd-ensemble bd-trustpanel-wrapper">
|
|
21
|
-
${this.eyebrow?
|
|
21
|
+
${this.eyebrow?a`<bd-p variant="eyebrow" class="bd-trustpanel-eyebrow"><slot name="eyebrow">${this.eyebrow}</slot></bd-p>`:o}
|
|
22
22
|
|
|
23
|
-
${this.title?
|
|
23
|
+
${this.title?a`<bd-h as="h2" class="bd-trustpanel-title"><slot name="title">${this.title}</slot></bd-h>`:o}
|
|
24
24
|
|
|
25
|
-
${this.description?
|
|
25
|
+
${this.description?a`
|
|
26
26
|
<bd-p variant="regular" class="bd-trustpanel-description">
|
|
27
27
|
<slot name="description">${this.description}</slot>
|
|
28
|
-
${this.linkLabel?
|
|
28
|
+
${this.linkLabel?a`
|
|
29
29
|
<bd-link
|
|
30
30
|
class="bd-trustpanel-inline-link"
|
|
31
31
|
href=${this.linkHref}
|
|
@@ -34,13 +34,13 @@ import{defineElement as e}from"../shared/define-element.js";import{tokens as t}f
|
|
|
34
34
|
>
|
|
35
35
|
${this.linkLabel} <bd-arrow-right-icon size="xs" aria-hidden="true"></bd-arrow-right-icon>
|
|
36
36
|
</bd-link>
|
|
37
|
-
`:
|
|
37
|
+
`:o}
|
|
38
38
|
</bd-p>
|
|
39
|
-
`:
|
|
39
|
+
`:o}
|
|
40
40
|
|
|
41
|
-
${this.stats&&this.stats.length?
|
|
41
|
+
${this.stats&&this.stats.length?a`
|
|
42
42
|
<div class="bd-trustpanel-stats">
|
|
43
|
-
${this.stats.map(e=>
|
|
43
|
+
${this.stats.map(e=>a`
|
|
44
44
|
<div class="bd-trustpanel-stat">
|
|
45
45
|
<div class="bd-trustpanel-stat-divider"></div>
|
|
46
46
|
<div class="bd-trustpanel-stat-value">${e.value}</div>
|
|
@@ -48,13 +48,13 @@ import{defineElement as e}from"../shared/define-element.js";import{tokens as t}f
|
|
|
48
48
|
</div>
|
|
49
49
|
`)}
|
|
50
50
|
</div>
|
|
51
|
-
`:
|
|
51
|
+
`:o}
|
|
52
52
|
|
|
53
|
-
${this.cards&&this.cards.length?
|
|
53
|
+
${this.cards&&this.cards.length?a`
|
|
54
54
|
<div class="bd-trustpanel-cards">
|
|
55
55
|
${this.cards.map((e,t)=>this._renderCard(e,t))}
|
|
56
56
|
</div>
|
|
57
|
-
`:
|
|
57
|
+
`:o}
|
|
58
58
|
</div>
|
|
59
|
-
`}};
|
|
59
|
+
`}};t([s({type:String})],c.prototype,`eyebrow`,void 0),t([s({type:String})],c.prototype,`title`,void 0),t([s({type:String})],c.prototype,`description`,void 0),t([s({type:String,attribute:`link-label`})],c.prototype,`linkLabel`,void 0),t([s({type:String,attribute:`link-href`})],c.prototype,`linkHref`,void 0),t([s({type:Array})],c.prototype,`stats`,void 0),t([s({type:Array})],c.prototype,`cards`,void 0),c=t([e(`bd-trust-panel`)],c);
|
|
60
60
|
//# sourceMappingURL=trust-panel.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trust-panel.js","names":["trustPanelCSS","_decorate","__decorate","trust_panel_css_default","TrustPanel","LitElement","_args","
|
|
1
|
+
{"version":3,"file":"trust-panel.js","names":["trustPanelCSS","_decorate","__decorate","trust_panel_css_default","TrustPanel","LitElement","_args","ensembleCSS","logoSlotName","index","card","nothing","stat","i","property","defineElement"],"sources":["../../../../src/components/trust-panel/trust-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/link/link.ts\";\nimport \"#components/paragraph/paragraph.ts\";\nimport trustPanelCSS from \"./trust-panel.css.ts\";\nimport { ensembleCSS } from \"#shared/ensemble.css.ts\";\nimport \"#components/icons/arrow-right-icon.ts\";\n\ninterface TrustStat {\n value: string;\n label: string;\n}\n\ninterface TrustCard {\n eyebrow? : string;\n title? : string;\n description?: string;\n linkLabel? : string;\n linkHref? : string;\n}\n\n@defineElement(\"bd-trust-panel\")\nclass TrustPanel extends LitElement {\n static styles = [ensembleCSS, trustPanelCSS];\n\n @property({ type: String })\n eyebrow = \"\";\n @property({ type: String })\n title = \"\";\n @property({ type: String })\n description = \"\";\n @property({ type: String, attribute: \"link-label\" })\n linkLabel = \"\";\n @property({ type: String, attribute: \"link-href\" })\n linkHref = \"#\";\n @property({ type: Array })\n stats: TrustStat[] = []; // [{ value: String, label: String }]\n @property({ type: Array })\n cards: TrustCard[] = []; // [{ eyebrow, title, description, linkLabel, linkHref }] — logos slotted per card\n\n _renderCard(card: TrustCard, index: number) {\n const logoSlotName = `card-${index + 1}-logos`;\n return html`\n <div class=\"bd-trustpanel-card\">\n ${card.eyebrow\n ? html`<bd-p variant=\"eyebrow\" class=\"bd-trustpanel-card-eyebrow\">${card.eyebrow}</bd-p>`\n : nothing}\n\n <div class=\"bd-trustpanel-card-logos\">\n <slot name=\"${logoSlotName}\"></slot>\n </div>\n\n ${card.title\n ? html`<bd-h as=\"h4\" class=\"bd-trustpanel-card-title\">${card.title}</bd-h>`\n : nothing}\n\n ${card.description\n ? html`<bd-p variant=\"regular\" class=\"bd-trustpanel-card-description\">${card.description}</bd-p>`\n : nothing}\n\n ${card.linkLabel\n ? html`\n <a class=\"bd-trustpanel-card-link\" href=${card.linkHref || \"#\"}>\n ${card.linkLabel} <bd-arrow-right-icon size=\"xs\" aria-hidden=\"true\"></bd-arrow-right-icon>\n </a>\n `\n : nothing}\n </div>\n `;\n }\n\n render() {\n return html`\n <div class=\"bd-ensemble bd-trustpanel-wrapper\">\n ${this.eyebrow\n ? html`<bd-p variant=\"eyebrow\" class=\"bd-trustpanel-eyebrow\"><slot name=\"eyebrow\">${this.eyebrow}</slot></bd-p>`\n : nothing}\n\n ${this.title\n ? html`<bd-h as=\"h2\" class=\"bd-trustpanel-title\"><slot name=\"title\">${this.title}</slot></bd-h>`\n : nothing}\n\n ${this.description\n ? html`\n <bd-p variant=\"regular\" class=\"bd-trustpanel-description\">\n <slot name=\"description\">${this.description}</slot>\n ${this.linkLabel\n ? html`\n <bd-link\n class=\"bd-trustpanel-inline-link\"\n href=${this.linkHref}\n underline\n font-size=\"inherit\"\n >\n ${this.linkLabel} <bd-arrow-right-icon size=\"xs\" aria-hidden=\"true\"></bd-arrow-right-icon>\n </bd-link>\n `\n : nothing}\n </bd-p>\n `\n : nothing}\n\n ${this.stats && this.stats.length\n ? html`\n <div class=\"bd-trustpanel-stats\">\n ${this.stats.map(\n (stat) => html`\n <div class=\"bd-trustpanel-stat\">\n <div class=\"bd-trustpanel-stat-divider\"></div>\n <div class=\"bd-trustpanel-stat-value\">${stat.value}</div>\n <div class=\"bd-trustpanel-stat-label\">${stat.label}</div>\n </div>\n `\n )}\n </div>\n `\n : nothing}\n\n ${this.cards && this.cards.length\n ? html`\n <div class=\"bd-trustpanel-cards\">\n ${this.cards.map((card, i) => this._renderCard(card, i))}\n </div>\n `\n : nothing}\n </div>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"bd-trust-panel\": TrustPanel;\n }\n}"],"mappings":"A,meAyBA,IACMI,EADN,cACyBC,CAAW,C,8BAIxB,KAAA,QAAA,GAEF,KAAA,MAAA,GAEM,KAAA,YAAA,GAEF,KAAA,UAAA,GAED,KAAA,SAAA,IAEU,KAAA,MAAA,CAAC,EAED,KAAA,MAAA,CAAC,C,QAfN,KAAA,OAAA,CAACE,EAAaP,CAAa,C,CAiB3C,YAAY,EAAiB,EAAe,CAC1C,IAAMQ,EAAe,QAAQC,EAAQ,EAAE,QACvC,MAAO,EAAI;;UAELC,EAAK,QACH,CAAI,8DAA8DA,EAAK,QAAQ,SAC/EC,EAAQ;;;wBAGIH,EAAa;;;UAG3BE,EAAK,M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,CAAE,KAAM,OAAQ,UAAW,WAAY,CAAC,CAAA,EAAAV,EAAA,UAAA,WAAA,IAAA,EAAA,EAEjDH,EAAA,CAAAa,EAAS,CAAE,KAAM,KAAM,CAAC,CAAA,EAAAV,EAAA,UAAA,QAAA,IAAA,EAAA,EAExBH,EAAA,CAAAa,EAAS,CAAE,KAAM,KAAM,CAAC,CAAA,EAAAV,EAAA,UAAA,QAAA,IAAA,EAAA,EAhB1B,EAAAH,EAAA,CAAAc,EAAc,gBAAgB,CAAA,EAAAX,CAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** One row of the registry: the tags a module registers, space-separated, and how to import it. */
|
|
2
|
+
export type RegistryRow = readonly [tags: string, load: () => Promise<unknown>];
|
|
3
|
+
export interface Loader {
|
|
4
|
+
/** Imports the module of every component in `target`; see loader.ts. */
|
|
5
|
+
load(target: ParentNode | Iterable<string>): Promise<void>;
|
|
6
|
+
/** `load(root)`, then again for whatever is added under `root`; see loader.ts. */
|
|
7
|
+
autoload(root?: ParentNode): () => void;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* The loader for a registry. loader.ts makes the package's one from the
|
|
11
|
+
* generated registry; this is separate so a test can hand it rows of its own.
|
|
12
|
+
*/
|
|
13
|
+
export declare function createLoader(rows: readonly RegistryRow[]): Loader;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
function e(e){let t=/* @__PURE__ */ new Map;for(let[n,r]of e)for(let e of n.split(` `))t.set(e,r);let n=/* @__PURE__ */ new Map,r=e=>{let t=n.get(e);return t||(t=e(),n.set(e,t),t.catch(()=>n.delete(e))),t},i=e=>{let t=(e.ownerDocument??e).defaultView;if(t&&t!==window)throw TypeError(`@repobit/dex-system-design: the loader defines components in its own window; import it in the iframe to load an iframe's`)},a=e=>{if(typeof e==`string`)return[e];let t=e;if(typeof t.nodeType!=`number`)return Array.from(e,a).flat();i(t);let n=t.nodeType===Node.ELEMENT_NODE?[t.localName]:[],r=t.querySelectorAll?Array.from(t.querySelectorAll(`:not(:defined)`),e=>e.localName):[];return[...n,...r]},o=async e=>{let n=/* @__PURE__ */ new Set;for(let r of a(e)){let e=t.get(r);e&&!customElements.get(r)&&n.add(e)}await Promise.all(Array.from(n,r))};return{load:o,autoload:(e=document.documentElement)=>{i(e);let t=e=>console.warn(`@repobit/dex-system-design: a component failed to load`,e);o(e).catch(t);let n=new MutationObserver(e=>{let n=e.flatMap(({addedNodes:e})=>[...e]);n.length&&o(n).catch(t)});return n.observe(e,{childList:!0,subtree:!0}),()=>n.disconnect()}}}export{e as createLoader};
|
|
2
|
+
//# sourceMappingURL=create-loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-loader.js","names":["createLoader","moduleOf","tags","load","rows","tag","imports","importOnce","pending","refuseForeign","view","node","tagsIn","target","own","under","el","modules","importer","root","report","error","observer","added","records","addedNodes"],"sources":["../../../src/loader/create-loader.ts"],"sourcesContent":["/** One row of the registry: the tags a module registers, space-separated, and how to import it. */\nexport type RegistryRow = readonly [tags: string, load: () => Promise<unknown>];\n\nexport interface Loader {\n /** Imports the module of every component in `target`; see loader.ts. */\n load(target: ParentNode | Iterable<string>): Promise<void>;\n /** `load(root)`, then again for whatever is added under `root`; see loader.ts. */\n autoload(root?: ParentNode): () => void;\n}\n\n/**\n * The loader for a registry. loader.ts makes the package's one from the\n * generated registry; this is separate so a test can hand it rows of its own.\n */\nexport function createLoader(rows: readonly RegistryRow[]): Loader {\n const moduleOf = new Map<string, RegistryRow[1]>();\n for (const [tags, load] of rows) for (const tag of tags.split(' ')) moduleOf.set(tag, load);\n\n /* Each module is imported once, however many callers ask for its tags and\n however many of its tags they ask for. A failed import is forgotten, so\n the next caller calls import() again rather than inheriting the failure.\n That retries only where the browser has not kept the failure itself: a\n module that threw while evaluating rejects with the same error for the\n life of the page, and so does a failed fetch in an engine whose module\n map caches it. */\n const imports = new Map<RegistryRow[1], Promise<unknown>>();\n const importOnce = (load: RegistryRow[1]) => {\n let pending = imports.get(load);\n if (!pending) {\n pending = load();\n imports.set(load, pending);\n pending.catch(() => imports.delete(load));\n }\n return pending;\n };\n\n /* The modules define their tags in this window's registry, and a document\n of another window (an iframe's) upgrades its elements from its own, which\n they never reach: load() would resolve with them still undefined, so it\n refuses them. A node of no window -- a template's content, a parsed\n document -- is let through: what it holds is defined here once adopted. */\n const refuseForeign = (node: Node) => {\n const view = (node.ownerDocument ?? (node as Document)).defaultView;\n if (view && view !== window) throw new TypeError('@repobit/dex-system-design: the loader defines components in its own window; import it in the iframe to load an iframe\\'s');\n };\n\n /* A node is told by its nodeType, not instanceof, so that one of another\n window is refused rather than read as a list; a list may hold nodes as\n well as tags, as a NodeList does. A node that holds no elements (text, a\n comment) adds none. */\n const tagsIn = (target: unknown): string[] => {\n if (typeof target === 'string') return [target];\n const node = target as Partial<Element>;\n if (typeof node.nodeType !== 'number') return Array.from(target as Iterable<unknown>, tagsIn).flat();\n refuseForeign(node as Element);\n const own = node.nodeType === Node.ELEMENT_NODE ? [node.localName!] : [];\n const under = node.querySelectorAll ? Array.from(node.querySelectorAll(':not(:defined)'), el => el.localName) : [];\n return [...own, ...under];\n };\n\n const load = async (target: unknown) => {\n const modules = new Set<RegistryRow[1]>();\n for (const tag of tagsIn(target)) {\n const importer = moduleOf.get(tag);\n if (importer && !customElements.get(tag)) modules.add(importer);\n }\n await Promise.all(Array.from(modules, importOnce));\n };\n\n const autoload = (root: ParentNode = document.documentElement) => {\n refuseForeign(root);\n const report = (error: unknown) => console.warn('@repobit/dex-system-design: a component failed to load', error);\n load(root).catch(report);\n /* One load() per delivery, for everything it added, not one per element:\n the parser adds each element of a page as a record of its own. It is\n handed the nodes, not their tags, so that one refused (moved into an\n iframe's document before the delivery) is reported, not thrown. */\n const observer = new MutationObserver(records => {\n const added = records.flatMap(({ addedNodes }) => [...addedNodes]);\n if (added.length) load(added).catch(report);\n });\n observer.observe(root, { childList: true, subtree: true });\n return () => observer.disconnect();\n };\n\n return { load, auto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,CACnD,EAkBA,MAAO,CAAE,OAAM,UAhBG,EAAmB,SAAS,kBAAoB,CAChEE,EAAcU,CAAI,EAClB,IAAMC,EAAU,GAAmB,QAAQ,KAAK,yDAA0DC,CAAK,EAC/GlB,EAAKgB,CAAI,CAAC,CAAC,MAAMC,CAAM,EAKvB,IAAME,EAAW,IAAI,iBAAiB,GAAW,CAC/C,IAAMC,EAAQC,EAAQ,SAAS,CAAE,gBAAiB,CAAC,GAAGC,CAAU,CAAC,EAC7DF,EAAM,QAAQpB,EAAKoB,CAAK,CAAC,CAAC,MAAMH,CAAM,CAC5C,CAAC,EAED,OADAE,EAAS,QAAQH,EAAM,CAAE,UAAW,GAAM,QAAS,EAAK,CAAC,MAC5CG,EAAS,WAAW,CACnC,CAEwB,CAC1B,C"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loads the components a page uses, and only those, without the page naming
|
|
3
|
+
* the module each one lives in.
|
|
4
|
+
*
|
|
5
|
+
* A page that imported components one by one had to know that bd-p is
|
|
6
|
+
* paragraph's, bd-button-link is button's and bd-li is list-item's, and its
|
|
7
|
+
* import list drifted from the tags it actually wrote. Here the package keeps
|
|
8
|
+
* that knowledge -- registry.ts, generated from the tags each module
|
|
9
|
+
* registers -- and a page says only where to look:
|
|
10
|
+
*
|
|
11
|
+
* import { load, autoload } from '@repobit/dex-system-design/loader';
|
|
12
|
+
*
|
|
13
|
+
* const layout = buildLayout(); // document.createElement('bd-…')
|
|
14
|
+
* await load(layout); // every component in it is defined
|
|
15
|
+
* block.replaceChildren(layout);
|
|
16
|
+
*
|
|
17
|
+
* autoload(); // and anything added to the page later
|
|
18
|
+
*
|
|
19
|
+
* Importing this module does nothing on its own: no import starts and no
|
|
20
|
+
* observer runs until load() or autoload() is called.
|
|
21
|
+
*/
|
|
22
|
+
import { type Loader } from "./create-loader.js";
|
|
23
|
+
/**
|
|
24
|
+
* Imports the module of every component in `target` and resolves once all of
|
|
25
|
+
* them are defined. `target` is an element or a fragment -- itself and
|
|
26
|
+
* everything under it, attached to the page or not -- or a list of tag names.
|
|
27
|
+
*
|
|
28
|
+
* Rejects if an import fails, so a caller can keep its fallback, and for a
|
|
29
|
+
* node of another window (an iframe's): the components are defined in this
|
|
30
|
+
* window, and an iframe's document is upgraded from its own registry, so the
|
|
31
|
+
* iframe imports the loader itself. A template's content is taken. A tag that
|
|
32
|
+
* is not this package's (`bd-context` is dex-store-elements') is ignored, and
|
|
33
|
+
* so is one already defined, by this copy of the package or another.
|
|
34
|
+
*/
|
|
35
|
+
export declare const load: Loader['load'];
|
|
36
|
+
/**
|
|
37
|
+
* `load(root)` now, then again for every element added under `root` later
|
|
38
|
+
* (default: the whole document). Nothing awaits it, so a failed import is
|
|
39
|
+
* reported, not thrown; a root of another window, which load() rejects,
|
|
40
|
+
* throws. It does not look inside shadow roots: a component
|
|
41
|
+
* imports what it renders there itself, and a shadow root of the page's own is
|
|
42
|
+
* `load()`ed by whoever attaches it. Returns a function that stops watching.
|
|
43
|
+
*/
|
|
44
|
+
export declare const autoload: Loader['autoload'];
|