@brightspot/ui 6.8.0 → 6.8.2
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 +661 -0
- package/README.md +18 -2
- package/dist/storybook/CHANGELOG.md +661 -0
- package/dist/storybook/README.md +195 -0
- package/dist/storybook/assets/{ActionBar.stories-CJBn-mku.js → ActionBar.stories-TlhuCumU.js} +31 -28
- package/dist/storybook/assets/ActionItem-CjtyGLd5.js +16 -0
- package/dist/storybook/assets/{ActionItem.stories-DXzC9C1u.js → ActionItem.stories-BVlNQvfP.js} +2 -2
- package/dist/storybook/assets/AiSparkle.stories-DMzc8JUe.js +73 -0
- package/dist/storybook/assets/Avatar-C6Li1sPI.js +4 -0
- package/dist/storybook/assets/Avatar.stories-COj6XrPn.js +213 -0
- package/dist/storybook/assets/AvatarGroup-DgxRTZBe.js +1 -0
- package/dist/storybook/assets/AvatarGroup.stories-Dh3e7iN2.js +225 -0
- package/dist/storybook/assets/Badge-bWrvpEgX.js +1 -0
- package/dist/storybook/assets/{Badge.stories-DEpoJpUZ.js → Badge.stories-KXpmEXpt.js} +4 -4
- package/dist/storybook/assets/Banner-FSFX1AIb.css +1 -0
- package/dist/storybook/assets/{Banner.stories--jeU6fKq.js → Banner.stories-Cnhm3dXK.js} +14 -14
- package/dist/storybook/assets/Button-DE0s-gat.js +10 -0
- package/dist/storybook/assets/Button.stories-Cwg1YZEb.js +54 -0
- package/dist/storybook/assets/ButtonGroup-CoLI5nGO.js +1 -0
- package/dist/storybook/assets/{ButtonGroup.stories-CerE_0AC.js → ButtonGroup.stories-VhnKPP1n.js} +7 -7
- package/dist/storybook/assets/Card-DyntwdY-.css +1 -0
- package/dist/storybook/assets/{Card.stories-5SxHtU3Y.js → Card.stories-BgpL90zB.js} +60 -29
- package/dist/storybook/assets/{Celebrate.stories-COS789GX.js → Celebrate.stories-D3NJgYcX.js} +5 -5
- package/dist/storybook/assets/Checkbox-BC1T_KxW.js +30 -0
- package/dist/storybook/assets/{Checkbox.stories-DuQu38Gv.js → Checkbox.stories-AFQNz7dQ.js} +10 -10
- package/dist/storybook/assets/CircularProgress-eqVb2jUD.js +42 -0
- package/dist/storybook/assets/{CircularProgress.stories-Lf2Ws46Y.js → CircularProgress.stories-B6t8VhmJ.js} +2 -2
- package/dist/storybook/assets/ClipboardMixin-DcxrOy5B.js +1 -0
- package/dist/storybook/assets/{ClipboardMixin.stories-BT5KfLZ_.js → ClipboardMixin.stories-BqtQMjmS.js} +6 -6
- package/dist/storybook/assets/{Color-6BZIO3FS-BNBxjqrS.js → Color-6BZIO3FS-CDluohEc.js} +1 -1
- package/dist/storybook/assets/{Colors.stories-Ck6bXbd0.js → Colors.stories-CqTniDIa.js} +1 -1
- package/dist/storybook/assets/{CombinedEffects.stories-DLELdAMr.js → CombinedEffects.stories-FwW0chy5.js} +2 -2
- package/dist/storybook/assets/{ComponentStatesMixin-B6uJL_2c.js → ComponentStatesMixin-hUqOL2aW.js} +1 -1
- package/dist/storybook/assets/{ComponentStatesMixin.stories-fiyrALkY.js → ComponentStatesMixin.stories-CwGoq685.js} +1 -1
- package/dist/storybook/assets/{CopyToClipboard.stories-2OfBH19_.js → CopyToClipboard.stories-DUGjgtQx.js} +18 -10
- package/dist/storybook/assets/{Debounce.stories-C9qo3lIN.js → Debounce.stories-CrWfXhKS.js} +1 -1
- package/dist/storybook/assets/{DocsRenderer-LL677BLK-CBVYZYjR.js → DocsRenderer-LL677BLK-9e51z9Xc.js} +3 -3
- package/dist/storybook/assets/{Dropdown.stories-15ZDMkRz.js → Dropdown.stories-BsBxV0wp.js} +2 -2
- package/dist/storybook/assets/DropdownMenu-B-LvOIGj.js +42 -0
- package/dist/storybook/assets/EmptyState-h0A4Qpiu.css +1 -0
- package/dist/storybook/assets/{EmptyState.stories-Bjb8hzYj.js → EmptyState.stories-CJ1w8Tp2.js} +33 -21
- package/dist/storybook/assets/EscaAvatar.stories-BoLLSj9q.js +140 -0
- package/dist/storybook/assets/{Events.stories-BV0vMF2I.js → Events.stories-C3sTBwPJ.js} +2 -2
- package/dist/storybook/assets/{Heading.stories-CEUJqUbQ.js → Heading.stories-jmXDRBmM.js} +1 -1
- package/dist/storybook/assets/{HueRipple.stories-CwvtcOM_.js → HueRipple.stories-BPx5aSYd.js} +2 -2
- package/dist/storybook/assets/Icon-CWyJRQf7.js +34409 -0
- package/dist/storybook/assets/{Icon.stories-AB_v-61c.js → Icon.stories-iYBxmv2x.js} +10 -10
- package/dist/storybook/assets/IconButton-Di5Rgs7F.js +12 -0
- package/dist/storybook/assets/{IconButton.stories-BHuHsM3k.js → IconButton.stories-DENLoxVk.js} +2 -2
- package/dist/storybook/assets/LinearProgress-D9ngIVlv.js +25 -0
- package/dist/storybook/assets/{LinearProgress.stories-BNN5SXe3.js → LinearProgress.stories-u90B_VJR.js} +2 -2
- package/dist/storybook/assets/Message-CM3eexdu.css +1 -0
- package/dist/storybook/assets/Message-nFAa55c_.js +28 -0
- package/dist/storybook/assets/{Message.stories-DdLhMXnb.js → Message.stories-B4rpz5rI.js} +2 -2
- package/dist/storybook/assets/OnFindMixin-oL1bvTFj.js +1 -0
- package/dist/storybook/assets/{OnFindMixin.stories-B-5TeBOF.js → OnFindMixin.stories-CdeS5sFA.js} +9 -9
- package/dist/storybook/assets/Pagination-CSWcjuDU.js +88 -0
- package/dist/storybook/assets/{Pagination.stories-C9zsOdb2.js → Pagination.stories-Da2WzJkv.js} +33 -33
- package/dist/storybook/assets/{Popover.stories-BiqIwebU.js → Popover.stories-CVljlVHc.js} +16 -16
- package/dist/storybook/assets/ProgressMixin-CeSrn0_P.js +1 -0
- package/dist/storybook/assets/Radio-rvfGhZwK.js +25 -0
- package/dist/storybook/assets/{Radio.stories-BmrEdPkm.js → Radio.stories-B0wHdJuc.js} +6 -6
- package/dist/storybook/assets/{RadioGroup.stories-ChARVXs3.js → RadioGroup.stories-D8krOSlP.js} +22 -22
- package/dist/storybook/assets/{ReadyMixin-BbuzH3uO.js → ReadyMixin-CvX_eidU.js} +1 -1
- package/dist/storybook/assets/RovingTabindexMixin-9z8lwaM9.js +1 -0
- package/dist/storybook/assets/{RovingTabindexMixin.stories-xm4b394_.js → RovingTabindexMixin.stories-Y8vBWjJp.js} +5 -5
- package/dist/storybook/assets/{Rtc.stories-DdcMaELA.js → Rtc.stories-D3Y-z8y_.js} +1 -1
- package/dist/storybook/assets/{ScrollShadow.stories-CI67Ougx.js → ScrollShadow.stories-1KD0lWHX.js} +1 -1
- package/dist/storybook/assets/{Switch.stories-DOqrRkxc.js → Switch.stories-Bsqvm_HE.js} +60 -27
- package/dist/storybook/assets/{Tab.stories-DN8o4cf_.js → Tab.stories-CzcTisNs.js} +7 -7
- package/dist/storybook/assets/Tabs-DdpYNZSW.js +17 -0
- package/dist/storybook/assets/{Tabs.stories-BEowfCcl.js → Tabs.stories-UOS3V0J4.js} +6 -6
- package/dist/storybook/assets/{Throttle.stories-BZ_nsuw1.js → Throttle.stories-C8jgzh6e.js} +1 -1
- package/dist/storybook/assets/Tooltip.stories-B5BoI0cH.js +143 -0
- package/dist/storybook/assets/TooltipMixin-CVKslCDt.js +1 -0
- package/dist/storybook/assets/{Upload.stories-sAEiabwq.js → Upload.stories-BsQDCDqo.js} +102 -52
- package/dist/storybook/assets/UploadItem-CYQqNwUF.js +54 -0
- package/dist/storybook/assets/{UploadItem.stories-C19JMfmB.js → UploadItem.stories-_le7XBTV.js} +4 -4
- package/dist/storybook/assets/{Welcome.stories-C30jg0r1.js → Welcome.stories-rramKkhd.js} +38 -8
- package/dist/storybook/assets/Widget-elBzGg8w.css +1 -0
- package/dist/storybook/assets/Widget.stories-DtbAaklk.js +279 -0
- package/dist/storybook/assets/{WithTooltip-65CFNBJE-PFRy5maL.js → WithTooltip-65CFNBJE-DK6GcBuR.js} +1 -1
- package/dist/storybook/assets/ai-sparkle-BZMJJAxY.js +1 -0
- package/dist/storybook/assets/aria-D5THOgos.js +1 -0
- package/dist/storybook/assets/{blocks-DLjjvsFT.js → blocks-DHnzPh43.js} +5 -5
- package/dist/storybook/assets/esca-glow-BwdhBvIX.js +2 -0
- package/dist/storybook/assets/esca-idle-B-fumiIb.js +1 -0
- package/dist/storybook/assets/esca-search-rwNfo19I.js +1 -0
- package/dist/storybook/assets/esca-task-complete-BAJP2dY2.js +1 -0
- package/dist/storybook/assets/esca-wave-Bjs4CUR7.js +1 -0
- package/dist/storybook/assets/{formatter-EIJCOSYU-D39uscG_.js → formatter-EIJCOSYU-qig-qWlG.js} +1 -1
- package/dist/storybook/assets/i18n-BQ-Uj-0B.js +1 -0
- package/dist/storybook/assets/if-defined-DerKRcyC.js +1 -0
- package/dist/storybook/assets/{iframe-B9buZjP7.js → iframe-DlBK9Drk.js} +24 -24
- package/dist/storybook/assets/{index-BdEHup-4.js → index-CItQyB37.js} +1 -1
- package/dist/storybook/assets/lottie_svg-C3v6xdng.js +2 -0
- package/dist/storybook/assets/{onFind-CGzSFqNN.js → onFind-Ci35eu2y.js} +1 -1
- package/dist/storybook/assets/{onFind.stories-Dq71qO14.js → onFind.stories-BmbwWWo1.js} +1 -1
- package/dist/storybook/assets/{onRemove.stories-B1GqLH_U.js → onRemove.stories-DFWCIgE4.js} +1 -1
- package/dist/storybook/assets/{onVisible.stories-BNKxOfLw.js → onVisible.stories-B-onpgE-.js} +1 -1
- package/dist/storybook/assets/property-Bmq4RTSP.js +1 -0
- package/dist/storybook/assets/ref-BhKk4SDh.js +1 -0
- package/dist/storybook/assets/state-DVIUS0Gf.js +1 -0
- package/dist/storybook/assets/{style-map-qCiIYcp5.js → style-map-DE4G47KD.js} +1 -1
- package/dist/storybook/assets/{syntaxhighlighter-ED5Y7EFY-CUM-CaRF.js → syntaxhighlighter-ED5Y7EFY-Dfgnal1d.js} +1 -1
- package/dist/storybook/custom-elements.json +11835 -0
- package/dist/storybook/docs/components/ActionBar.md +55 -0
- package/dist/storybook/docs/components/ActionItem.md +50 -0
- package/dist/storybook/docs/components/AiSparkle.md +33 -0
- package/dist/storybook/docs/components/Avatar.md +45 -0
- package/dist/storybook/docs/components/AvatarGroup.md +34 -0
- package/dist/storybook/docs/components/Badge.md +47 -0
- package/dist/storybook/docs/components/Banner.md +35 -0
- package/dist/storybook/docs/components/ButtonGroup.md +65 -0
- package/dist/storybook/docs/components/Card.md +67 -0
- package/dist/storybook/docs/components/Checkbox.md +49 -0
- package/dist/storybook/docs/components/CircularProgress.md +40 -0
- package/dist/storybook/docs/components/CopyToClipboard.md +51 -0
- package/dist/storybook/docs/components/Dropdown.md +74 -0
- package/dist/storybook/docs/components/DropdownItem.md +45 -0
- package/dist/storybook/docs/components/DropdownMenu.md +41 -0
- package/dist/storybook/docs/components/EmptyState.md +62 -0
- package/dist/storybook/docs/components/EscaAvatar.md +40 -0
- package/dist/storybook/docs/components/Icon.md +40 -0
- package/dist/storybook/docs/components/IconButton.md +36 -0
- package/dist/storybook/docs/components/LinearProgress.md +37 -0
- package/dist/storybook/docs/components/Message.md +50 -0
- package/dist/storybook/docs/components/Pagination.md +70 -0
- package/dist/storybook/docs/components/Popover.md +59 -0
- package/dist/storybook/docs/components/README.md +48 -0
- package/dist/storybook/docs/components/Radio.md +55 -0
- package/dist/storybook/docs/components/RadioGroup.md +34 -0
- package/dist/storybook/docs/components/Switch.md +48 -0
- package/dist/storybook/docs/components/Tab.md +40 -0
- package/dist/storybook/docs/components/Tabs.md +49 -0
- package/dist/storybook/docs/components/Upload.md +63 -0
- package/dist/storybook/docs/components/UploadItem.md +30 -0
- package/dist/storybook/docs/components/Widget.md +88 -0
- package/dist/storybook/docs/dari-elements.md +55 -0
- package/dist/storybook/iframe.html +1 -1
- package/dist/storybook/index.html +29 -2
- package/dist/storybook/llms-full.txt +1721 -0
- package/dist/storybook/llms.txt +65 -0
- package/dist/storybook/project.json +1 -1
- package/dist/storybook/robots.txt +7 -0
- package/dist/storybook/sb-addons/storybook-3/manager-bundle.js +1 -1
- package/dist/storybook/sitemap.xml +90 -0
- package/docs/components/ActionBar.md +41 -64
- package/docs/components/ActionItem.md +50 -96
- package/docs/components/AiSparkle.md +23 -60
- package/docs/components/Avatar.md +45 -88
- package/docs/components/AvatarGroup.md +24 -44
- package/docs/components/Badge.md +34 -62
- package/docs/components/Banner.md +25 -39
- package/docs/components/ButtonGroup.md +65 -99
- package/docs/components/Card.md +67 -83
- package/docs/components/Checkbox.md +49 -91
- package/docs/components/CircularProgress.md +40 -84
- package/docs/components/CopyToClipboard.md +35 -40
- package/docs/components/Dropdown.md +74 -120
- package/docs/components/DropdownItem.md +45 -81
- package/docs/components/DropdownMenu.md +30 -70
- package/docs/components/EmptyState.md +45 -62
- package/docs/components/EscaAvatar.md +30 -61
- package/docs/components/Icon.md +29 -62
- package/docs/components/IconButton.md +36 -83
- package/docs/components/LinearProgress.md +28 -70
- package/docs/components/Message.md +38 -63
- package/docs/components/Pagination.md +70 -100
- package/docs/components/Popover.md +46 -79
- package/docs/components/README.md +34 -40
- package/docs/components/Radio.md +55 -105
- package/docs/components/RadioGroup.md +26 -55
- package/docs/components/Switch.md +48 -84
- package/docs/components/Tab.md +30 -70
- package/docs/components/Tabs.md +49 -86
- package/docs/components/Upload.md +63 -112
- package/docs/components/UploadItem.md +22 -53
- package/docs/components/Widget.md +66 -67
- package/llms.txt +63 -0
- package/package.json +9 -6
- package/dist/storybook/assets/AiSparkle.stories-BfjT5jrJ.js +0 -72
- package/dist/storybook/assets/Avatar.stories-D8lnIZaY.js +0 -213
- package/dist/storybook/assets/AvatarGroup.stories-Cz9oVah0.js +0 -225
- package/dist/storybook/assets/Button-2ucj5lUP.js +0 -10
- package/dist/storybook/assets/Button.stories-ndl1RJd7.js +0 -54
- package/dist/storybook/assets/EscaAvatar.stories-Rc2MSzCX.js +0 -139
- package/dist/storybook/assets/LucideDynamicLoader-BuoNL33C.js +0 -1
- package/dist/storybook/assets/Tooltip.stories-3bar43ZN.js +0 -143
- package/dist/storybook/assets/Widget.stories-9-1XpZNl.js +0 -233
- package/dist/storybook/assets/if-defined-BwWBCoAU.js +0 -1
|
@@ -1,4 +1,37 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{i as z,E as d,x as c,g as I}from"./iframe-DlBK9Drk.js";import{o as a}from"./if-defined-DerKRcyC.js";import{o as y}from"./style-map-DE4G47KD.js";import{n as i}from"./property-Bmq4RTSP.js";import{E,R as _}from"./ReadyMixin-CvX_eidU.js";import{L as C}from"./Icon-CWyJRQf7.js";import"./preload-helper-PPVm8Dsz.js";var T=Object.defineProperty,n=(e,t,s,l)=>{for(var r=void 0,x=e.length-1,$;x>=0;x--)($=e[x])&&(r=$(t,s,r)||r);return r&&T(t,s,r),r};const L={md:"btu-switch-md",lg:"btu-switch-lg"};class o extends E(_(z)){constructor(){super(...arguments),this.size="sm",this.checked=!1,this.disabled=!1,this.labelPosition="end",this._userInitiated=!1,this.initialClasses=[],this._initialClassesCaptured=!1,this._descId=`switch-desc-${crypto.randomUUID()}`}connectedCallback(){super.connectedCallback(),this._initialClassesCaptured||(this.className&&(this.initialClasses=this.className.split(" ").filter(t=>t.trim())),this._initialClassesCaptured=!0)}createRenderRoot(){return this}willUpdate(t){super.willUpdate(t);const s=[...this.initialClasses,"btu-switch",L[this.size],this.labelPosition==="start"&&"btu-switch-label-start"];this.className=s.filter(Boolean).join(" ")}firstUpdated(t){super.firstUpdated(t),this.emit("btu-switch-ready")}updated(t){super.updated(t),this._userInitiated&&(this._userInitiated=!1,t.has("checked")&&this.emit("btu-switch-change",{checked:this.checked}))}_onInputChange(t){const s=t.target;this._userInitiated=!0,this.checked=s.checked}_onFocus(){this.emit("btu-switch-focus")}_toggleInput(){this.disabled||this.renderRoot.querySelector(".btu-switch-input")?.click()}render(){return c`
|
|
2
|
+
<input
|
|
3
|
+
type="checkbox"
|
|
4
|
+
role="switch"
|
|
5
|
+
class="btu-switch-input"
|
|
6
|
+
.checked=${this.checked}
|
|
7
|
+
?disabled=${this.disabled}
|
|
8
|
+
name=${a(this.name)}
|
|
9
|
+
aria-checked=${this.checked}
|
|
10
|
+
aria-label=${a(this.label)}
|
|
11
|
+
aria-describedby=${a(this.description?this._descId:void 0)}
|
|
12
|
+
@change=${this._onInputChange}
|
|
13
|
+
@focus=${this._onFocus}
|
|
14
|
+
/>
|
|
15
|
+
<span class="btu-switch-track" @click=${this._toggleInput}>
|
|
16
|
+
${this.onIcon?c`<btu-icon
|
|
17
|
+
class="btu-switch-track-icon-on"
|
|
18
|
+
symbol=${this.onIcon}
|
|
19
|
+
style="--icon-size: var(--switch-track-icon-size)"
|
|
20
|
+
></btu-icon>`:d}
|
|
21
|
+
<span class="btu-switch-knob"></span>
|
|
22
|
+
${this.offIcon?c`<btu-icon
|
|
23
|
+
class="btu-switch-track-icon-off"
|
|
24
|
+
symbol=${this.offIcon}
|
|
25
|
+
style="--icon-size: var(--switch-track-icon-size)"
|
|
26
|
+
></btu-icon>`:d}
|
|
27
|
+
</span>
|
|
28
|
+
${this.label||this.description?c`
|
|
29
|
+
<span class="btu-switch-text" @click=${this._toggleInput}>
|
|
30
|
+
${this.label?c`<span class="btu-switch-label">${this.label}</span>`:d}
|
|
31
|
+
${this.description?c`<span id=${this._descId} class="btu-switch-description">${this.description}</span>`:d}
|
|
32
|
+
</span>
|
|
33
|
+
`:d}
|
|
34
|
+
`}}n([i()],o.prototype,"size");n([i()],o.prototype,"label");n([i()],o.prototype,"description");n([i({type:Boolean})],o.prototype,"checked");n([i({type:Boolean})],o.prototype,"disabled");n([i()],o.prototype,"name");n([i({attribute:"label-position"})],o.prototype,"labelPosition");n([i({attribute:"on-icon"})],o.prototype,"onIcon");n([i({attribute:"off-icon"})],o.prototype,"offIcon");customElements.get("btu-switch")||customElements.define("btu-switch",o);const{events:D,args:O,argTypes:S}=I("btu-switch"),F={customColorOn:"--switch-color-track-on",customColorOff:"--switch-color-track-off",customKnobColor:"--switch-color-knob",customLabelSpacing:"--switch-label-spacing",customIconSize:"--switch-track-icon-size"},P=e=>Object.entries(F).reduce((t,[s,l])=>(e[s]&&(t[l]=e[s]),t),{}),j={title:"Components/Switch",component:"btu-switch",tags:["autodocs"],parameters:{docs:{subtitle:"A toggle switch for binary on/off states",description:{component:`
|
|
2
35
|
<h3>When to use:</h3>
|
|
3
36
|
<ul>
|
|
4
37
|
<li>For toggling a setting or preference on/off</li>
|
|
@@ -7,30 +40,30 @@ import{g as k,x as c}from"./iframe-B9buZjP7.js";import{o as s}from"./if-defined-
|
|
|
7
40
|
</ul>
|
|
8
41
|
|
|
9
42
|
<p>Track icons are powered by the <a href="?path=/docs/components-icon--docs">Icon component</a>. Visit its docs for all available icon names.</p>
|
|
10
|
-
`}},actions:{handles:
|
|
43
|
+
`}},actions:{handles:D},controls:{expanded:!0}},args:{...O,label:"Label",checked:!1},argTypes:{...S,"--switch-color-track-on":{table:{disable:!0}},"--switch-color-track-off":{table:{disable:!0}},"--switch-color-knob":{table:{disable:!0}},"--switch-label-spacing":{table:{disable:!0}},"--switch-icon-size":{table:{disable:!0}},"--switch-track-icon-size":{table:{disable:!0}},customColorOn:{name:"--switch-color-track-on",control:{type:"color"},description:"Background color when the toggle is checked",table:{category:"css properties"}},customColorOff:{name:"--switch-color-track-off",control:{type:"color"},description:"Background color when the toggle is unchecked",table:{category:"css properties"}},customKnobColor:{name:"--switch-color-knob",control:{type:"color"},description:"Color of the sliding circular handle",table:{category:"css properties"}},customLabelSpacing:{name:"--switch-label-spacing",control:{type:"text"},description:"Distance between the switch and the text label (default: 0.75rem)",table:{category:"css properties"}},"on-icon":{...S["on-icon"],control:{type:"text"},description:'<a href="https://lucide.dev/icons/" target="_blank">Lucide</a> icon name shown on the track when checked. Only icons available in Lucide v'+C+" are supported."},"off-icon":{...S["off-icon"],control:{type:"text"},description:'<a href="https://lucide.dev/icons/" target="_blank">Lucide</a> icon name shown on the track when unchecked. Only icons available in Lucide v'+C+" are supported."},customIconSize:{name:"--switch-track-icon-size",control:{type:"text"},description:"Size of the track icons (e.g., `0.5rem`, `0.75rem`, `1rem`). Defaults: sm `0.5rem`, md `0.625rem`, lg `0.75rem`.",table:{category:"css properties"}}},render:e=>c`
|
|
11
44
|
<btu-switch
|
|
12
45
|
size=${e.size??"sm"}
|
|
13
|
-
label=${
|
|
14
|
-
description=${
|
|
46
|
+
label=${a(e.label)}
|
|
47
|
+
description=${a(e.description)}
|
|
15
48
|
label-position=${e["label-position"]??"end"}
|
|
16
|
-
on-icon=${
|
|
17
|
-
off-icon=${
|
|
18
|
-
name=${
|
|
49
|
+
on-icon=${a(e["on-icon"])}
|
|
50
|
+
off-icon=${a(e["off-icon"])}
|
|
51
|
+
name=${a(e.name)}
|
|
19
52
|
.checked=${e.checked??!1}
|
|
20
53
|
?disabled=${e.disabled}
|
|
21
|
-
style=${
|
|
54
|
+
style=${y(P(e))}
|
|
22
55
|
></btu-switch>
|
|
23
|
-
`},
|
|
56
|
+
`},h={args:{}},u={args:{checked:!0,label:"Enabled"},parameters:{docs:{description:{story:"Switch in the checked/on state. The track uses `--switch-color-track-on` (defaults to primary-700)."}}}},p={args:{label:"Enable notifications",description:"Receive updates via email",checked:!0},parameters:{docs:{description:{story:"Switch with both a primary label and a secondary description."}}}},b={args:{label:"Unavailable option",disabled:!0},parameters:{docs:{description:{story:"Disabled state via the `disabled` attribute. The track opacity is reduced and the wrapper cursor changes to `not-allowed`."}}}},m={args:{label:"Previously enabled",disabled:!0,checked:!0},parameters:{docs:{description:{story:"Disabled switch in the checked state. Useful for showing a locked-on setting."}}}},f={args:{label:"Label on the left","label-position":"start"},parameters:{docs:{description:{story:'Place the label before the switch using `label-position="start"`.'}}}},g={args:{label:"Notifications",checked:!0,"on-icon":"check","off-icon":"x"},parameters:{docs:{description:{story:"Track icons via `on-icon` and `off-icon` attributes. Icons use Lucide names (e.g., `check`, `x`, `bell`, `bell-off`)."}}}},w={render:()=>c`
|
|
24
57
|
<div style="display: flex; flex-direction: column; gap: 1rem;">
|
|
25
58
|
${["sm","md","lg"].map(e=>c`
|
|
26
59
|
<btu-switch size=${e} label="${e} with icons" on-icon="check" off-icon="x" checked></btu-switch>
|
|
27
60
|
`)}
|
|
28
61
|
</div>
|
|
29
|
-
`,parameters:{docs:{description:{story:"Track icons scale automatically with the switch size."}}}},
|
|
62
|
+
`,parameters:{docs:{description:{story:"Track icons scale automatically with the switch size."}}}},k={render:()=>c`
|
|
30
63
|
<div style="display: flex; flex-direction: column; gap: 1rem;">
|
|
31
64
|
${["sm","md","lg"].map(e=>c` <btu-switch size=${e} label="${e} size" checked></btu-switch> `)}
|
|
32
65
|
</div>
|
|
33
|
-
`,parameters:{docs:{description:{story:"The three available size variants: `sm` (default), `md`, and `lg`."}}}},
|
|
66
|
+
`,parameters:{docs:{description:{story:"The three available size variants: `sm` (default), `md`, and `lg`."}}}},v={render:()=>c`
|
|
34
67
|
<div class="flex flex-col gap-6">
|
|
35
68
|
<div class="flex flex-col gap-2">
|
|
36
69
|
<strong>Custom colors:</strong>
|
|
@@ -38,17 +71,17 @@ import{g as k,x as c}from"./iframe-B9buZjP7.js";import{o as s}from"./if-defined-
|
|
|
38
71
|
<btu-switch
|
|
39
72
|
label="Success"
|
|
40
73
|
checked
|
|
41
|
-
style=${
|
|
74
|
+
style=${y({"--switch-color-track-on":"oklch(var(--btu-theme-success-600))"})}
|
|
42
75
|
></btu-switch>
|
|
43
76
|
<btu-switch
|
|
44
77
|
label="Warning"
|
|
45
78
|
checked
|
|
46
|
-
style=${
|
|
79
|
+
style=${y({"--switch-color-track-on":"oklch(var(--btu-theme-warning-500))"})}
|
|
47
80
|
></btu-switch>
|
|
48
81
|
<btu-switch
|
|
49
82
|
label="Error"
|
|
50
83
|
checked
|
|
51
|
-
style=${
|
|
84
|
+
style=${y({"--switch-color-track-on":"oklch(var(--btu-theme-error-600))"})}
|
|
52
85
|
></btu-switch>
|
|
53
86
|
</div>
|
|
54
87
|
</div>
|
|
@@ -58,7 +91,7 @@ import{g as k,x as c}from"./iframe-B9buZjP7.js";import{o as s}from"./if-defined-
|
|
|
58
91
|
<btu-switch
|
|
59
92
|
label="Toggle me"
|
|
60
93
|
description="Check the Actions panel to see events"
|
|
61
|
-
@btu-switch-change=${e=>{const
|
|
94
|
+
@btu-switch-change=${e=>{const s=e.target.querySelector(".btu-switch-description");s&&(s.textContent=e.detail.checked?"Switch is ON":"Switch is OFF")}}
|
|
62
95
|
></btu-switch>
|
|
63
96
|
</div>
|
|
64
97
|
|
|
@@ -66,7 +99,7 @@ import{g as k,x as c}from"./iframe-B9buZjP7.js";import{o as s}from"./if-defined-
|
|
|
66
99
|
<strong>Form participation:</strong>
|
|
67
100
|
<form
|
|
68
101
|
class="flex flex-col gap-3 rounded-lg border border-gray-200 bg-gray-50 p-4"
|
|
69
|
-
@submit=${e=>{e.preventDefault();const
|
|
102
|
+
@submit=${e=>{e.preventDefault();const t=e.target,s=new FormData(t),l=t.querySelector(".form-output");l&&(l.textContent=JSON.stringify(Object.fromEntries(s),null,2))}}
|
|
70
103
|
>
|
|
71
104
|
<btu-switch label="Email notifications" name="email" checked></btu-switch>
|
|
72
105
|
<btu-switch label="SMS notifications" name="sms"></btu-switch>
|
|
@@ -98,9 +131,9 @@ import{g as k,x as c}from"./iframe-B9buZjP7.js";import{o as s}from"./if-defined-
|
|
|
98
131
|
</div>
|
|
99
132
|
</div>
|
|
100
133
|
</div>
|
|
101
|
-
`,parameters:{docs:{description:{story:"\n- **Custom colors** via CSS custom properties (`--switch-color-track-on`, `--switch-color-track-off`) using theme tokens.\n- **Event handling** with the `btu-switch-change` event, which provides `{ checked: boolean }` in its detail.\n- **Form participation** using the `name` attribute — the hidden checkbox participates in native form submission.\n- **Track icons** via `on-icon` and `off-icon` attributes using Lucide icon names (e.g., `check`, `x`, `lock`, `volume-2`).\n- **Programmatic control** by setting the `checked` property directly from JavaScript."}}}};
|
|
134
|
+
`,parameters:{docs:{description:{story:"\n- **Custom colors** via CSS custom properties (`--switch-color-track-on`, `--switch-color-track-off`) using theme tokens.\n- **Event handling** with the `btu-switch-change` event, which provides `{ checked: boolean }` in its detail.\n- **Form participation** using the `name` attribute — the hidden checkbox participates in native form submission.\n- **Track icons** via `on-icon` and `off-icon` attributes using Lucide icon names (e.g., `check`, `x`, `lock`, `volume-2`).\n- **Programmatic control** by setting the `checked` property directly from JavaScript."}}}};h.parameters={...h.parameters,docs:{...h.parameters?.docs,source:{originalSource:`{
|
|
102
135
|
args: {}
|
|
103
|
-
}`,...
|
|
136
|
+
}`,...h.parameters?.docs?.source}}};u.parameters={...u.parameters,docs:{...u.parameters?.docs,source:{originalSource:`{
|
|
104
137
|
args: {
|
|
105
138
|
checked: true,
|
|
106
139
|
label: 'Enabled'
|
|
@@ -112,7 +145,7 @@ import{g as k,x as c}from"./iframe-B9buZjP7.js";import{o as s}from"./if-defined-
|
|
|
112
145
|
}
|
|
113
146
|
}
|
|
114
147
|
}
|
|
115
|
-
}`,...
|
|
148
|
+
}`,...u.parameters?.docs?.source}}};p.parameters={...p.parameters,docs:{...p.parameters?.docs,source:{originalSource:`{
|
|
116
149
|
args: {
|
|
117
150
|
label: 'Enable notifications',
|
|
118
151
|
description: 'Receive updates via email',
|
|
@@ -125,7 +158,7 @@ import{g as k,x as c}from"./iframe-B9buZjP7.js";import{o as s}from"./if-defined-
|
|
|
125
158
|
}
|
|
126
159
|
}
|
|
127
160
|
}
|
|
128
|
-
}`,...
|
|
161
|
+
}`,...p.parameters?.docs?.source}}};b.parameters={...b.parameters,docs:{...b.parameters?.docs,source:{originalSource:`{
|
|
129
162
|
args: {
|
|
130
163
|
label: 'Unavailable option',
|
|
131
164
|
disabled: true
|
|
@@ -137,7 +170,7 @@ import{g as k,x as c}from"./iframe-B9buZjP7.js";import{o as s}from"./if-defined-
|
|
|
137
170
|
}
|
|
138
171
|
}
|
|
139
172
|
}
|
|
140
|
-
}`,...
|
|
173
|
+
}`,...b.parameters?.docs?.source}}};m.parameters={...m.parameters,docs:{...m.parameters?.docs,source:{originalSource:`{
|
|
141
174
|
args: {
|
|
142
175
|
label: 'Previously enabled',
|
|
143
176
|
disabled: true,
|
|
@@ -150,7 +183,7 @@ import{g as k,x as c}from"./iframe-B9buZjP7.js";import{o as s}from"./if-defined-
|
|
|
150
183
|
}
|
|
151
184
|
}
|
|
152
185
|
}
|
|
153
|
-
}`,...
|
|
186
|
+
}`,...m.parameters?.docs?.source}}};f.parameters={...f.parameters,docs:{...f.parameters?.docs,source:{originalSource:`{
|
|
154
187
|
args: {
|
|
155
188
|
label: 'Label on the left',
|
|
156
189
|
'label-position': 'start'
|
|
@@ -162,7 +195,7 @@ import{g as k,x as c}from"./iframe-B9buZjP7.js";import{o as s}from"./if-defined-
|
|
|
162
195
|
}
|
|
163
196
|
}
|
|
164
197
|
}
|
|
165
|
-
}`,...
|
|
198
|
+
}`,...f.parameters?.docs?.source}}};g.parameters={...g.parameters,docs:{...g.parameters?.docs,source:{originalSource:`{
|
|
166
199
|
args: {
|
|
167
200
|
label: 'Notifications',
|
|
168
201
|
checked: true,
|
|
@@ -176,7 +209,7 @@ import{g as k,x as c}from"./iframe-B9buZjP7.js";import{o as s}from"./if-defined-
|
|
|
176
209
|
}
|
|
177
210
|
}
|
|
178
211
|
}
|
|
179
|
-
}`,...
|
|
212
|
+
}`,...g.parameters?.docs?.source}}};w.parameters={...w.parameters,docs:{...w.parameters?.docs,source:{originalSource:`{
|
|
180
213
|
render: () => html\`
|
|
181
214
|
<div style="display: flex; flex-direction: column; gap: 1rem;">
|
|
182
215
|
\${(['sm', 'md', 'lg'] as const).map(size => html\`
|
|
@@ -191,7 +224,7 @@ import{g as k,x as c}from"./iframe-B9buZjP7.js";import{o as s}from"./if-defined-
|
|
|
191
224
|
}
|
|
192
225
|
}
|
|
193
226
|
}
|
|
194
|
-
}`,...
|
|
227
|
+
}`,...w.parameters?.docs?.source}}};k.parameters={...k.parameters,docs:{...k.parameters?.docs,source:{originalSource:`{
|
|
195
228
|
render: () => html\`
|
|
196
229
|
<div style="display: flex; flex-direction: column; gap: 1rem;">
|
|
197
230
|
\${(['sm', 'md', 'lg'] as const).map(size => html\` <btu-switch size=\${size} label="\${size} size" checked></btu-switch> \`)}
|
|
@@ -204,7 +237,7 @@ import{g as k,x as c}from"./iframe-B9buZjP7.js";import{o as s}from"./if-defined-
|
|
|
204
237
|
}
|
|
205
238
|
}
|
|
206
239
|
}
|
|
207
|
-
}`,...
|
|
240
|
+
}`,...k.parameters?.docs?.source}}};v.parameters={...v.parameters,docs:{...v.parameters?.docs,source:{originalSource:`{
|
|
208
241
|
render: () => html\`
|
|
209
242
|
<div class="flex flex-col gap-6">
|
|
210
243
|
<div class="flex flex-col gap-2">
|
|
@@ -309,4 +342,4 @@ import{g as k,x as c}from"./iframe-B9buZjP7.js";import{o as s}from"./if-defined-
|
|
|
309
342
|
}
|
|
310
343
|
}
|
|
311
344
|
}
|
|
312
|
-
}`,...
|
|
345
|
+
}`,...v.parameters?.docs?.source}}};const q=["Default","Checked","WithDescription","Disabled","DisabledChecked","LabelStart","WithIcons","WithIconsSizes","Sizes","AdvancedUsage"];export{v as AdvancedUsage,u as Checked,h as Default,b as Disabled,m as DisabledChecked,f as LabelStart,k as Sizes,p as WithDescription,g as WithIcons,w as WithIconsSizes,q as __namedExportsOrder,j as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{g as u,x as e}from"./iframe-
|
|
1
|
+
import{g as u,x as e}from"./iframe-DlBK9Drk.js";import{o as d}from"./style-map-DE4G47KD.js";import"./Tabs-DdpYNZSW.js";import"./preload-helper-PPVm8Dsz.js";import"./property-Bmq4RTSP.js";import"./ReadyMixin-CvX_eidU.js";import"./Badge-bWrvpEgX.js";import"./Icon-CWyJRQf7.js";import"./RovingTabindexMixin-9z8lwaM9.js";import"./DropdownMenu-B-LvOIGj.js";import"./aria-D5THOgos.js";import"./TooltipMixin-CVKslCDt.js";const{events:c,args:m,argTypes:t}=u("btu-tab"),I={title:"Components/Tabs/Tab",component:"btu-tab",tags:["autodocs"],parameters:{docs:{subtitle:"btu-tab",description:{component:`
|
|
2
2
|
An individual tab within a \`btu-tabs\` group.
|
|
3
3
|
|
|
4
4
|
Renders a button with \`role="tab"\` that participates in keyboard navigation and selection state managed by the parent \`btu-tabs\` container.
|
|
@@ -20,7 +20,7 @@ Renders a button with \`role="tab"\` that participates in keyboard navigation an
|
|
|
20
20
|
></btu-tab>
|
|
21
21
|
<btu-tab name="other" label="Other"></btu-tab>
|
|
22
22
|
</btu-tabs>
|
|
23
|
-
`}},b={args:{}},
|
|
23
|
+
`}},b={args:{}},o={render:()=>e`
|
|
24
24
|
<div class="flex flex-col gap-8">
|
|
25
25
|
<btu-tabs size="md" active-tab="dashboard">
|
|
26
26
|
<btu-tab name="dashboard" label="Dashboard" symbol="layout-dashboard"></btu-tab>
|
|
@@ -33,7 +33,7 @@ Renders a button with \`role="tab"\` that participates in keyboard navigation an
|
|
|
33
33
|
<btu-tab name="settings" label="Settings" symbol="settings" icon-position="trailing"></btu-tab>
|
|
34
34
|
</btu-tabs>
|
|
35
35
|
</div>
|
|
36
|
-
`,parameters:{docs:{description:{story:"Set `symbol` to any Lucide icon name. Use `icon-position` to place the icon before (default) or after the label."}}}},
|
|
36
|
+
`,parameters:{docs:{description:{story:"Set `symbol` to any Lucide icon name. Use `icon-position` to place the icon before (default) or after the label."}}}},n={render:()=>e`
|
|
37
37
|
<btu-tabs size="md" active-tab="dashboard">
|
|
38
38
|
<btu-tab name="dashboard" label="Dashboard" symbol="layout-dashboard" icon-only></btu-tab>
|
|
39
39
|
<btu-tab name="search" label="Search" symbol="search" icon-only></btu-tab>
|
|
@@ -93,7 +93,7 @@ Renders a button with \`role="tab"\` that participates in keyboard navigation an
|
|
|
93
93
|
</div>
|
|
94
94
|
`,parameters:{docs:{description:{story:"Set `disabled` to make a tab non-interactive. Disabled tabs remain focusable for keyboard navigation but cannot be activated."}}}};b.parameters={...b.parameters,docs:{...b.parameters?.docs,source:{originalSource:`{
|
|
95
95
|
args: {}
|
|
96
|
-
}`,...b.parameters?.docs?.source}}};
|
|
96
|
+
}`,...b.parameters?.docs?.source}}};o.parameters={...o.parameters,docs:{...o.parameters?.docs,source:{originalSource:`{
|
|
97
97
|
render: () => html\`
|
|
98
98
|
<div class="flex flex-col gap-8">
|
|
99
99
|
<btu-tabs size="md" active-tab="dashboard">
|
|
@@ -115,7 +115,7 @@ Renders a button with \`role="tab"\` that participates in keyboard navigation an
|
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
|
-
}`,...
|
|
118
|
+
}`,...o.parameters?.docs?.source}}};n.parameters={...n.parameters,docs:{...n.parameters?.docs,source:{originalSource:`{
|
|
119
119
|
render: () => html\`
|
|
120
120
|
<btu-tabs size="md" active-tab="dashboard">
|
|
121
121
|
<btu-tab name="dashboard" label="Dashboard" symbol="layout-dashboard" icon-only></btu-tab>
|
|
@@ -131,7 +131,7 @@ Renders a button with \`role="tab"\` that participates in keyboard navigation an
|
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
|
-
}`,...
|
|
134
|
+
}`,...n.parameters?.docs?.source}}};r.parameters={...r.parameters,docs:{...r.parameters?.docs,source:{originalSource:`{
|
|
135
135
|
render: () => html\`
|
|
136
136
|
<btu-tabs size="md" active-tab="inbox">
|
|
137
137
|
<btu-tab name="inbox" label="Inbox" badge="12"></btu-tab>
|
|
@@ -215,4 +215,4 @@ Renders a button with \`role="tab"\` that participates in keyboard navigation an
|
|
|
215
215
|
}
|
|
216
216
|
}
|
|
217
217
|
}
|
|
218
|
-
}`,...l.parameters?.docs?.source}}};const
|
|
218
|
+
}`,...l.parameters?.docs?.source}}};const D=["Default","WithIcon","IconOnly","WithBadge","WithError","Disabled"];export{b as Default,l as Disabled,n as IconOnly,r as WithBadge,s as WithError,o as WithIcon,D as __namedExportsOrder,I as default};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import{i as c,x as d,E as r}from"./iframe-DlBK9Drk.js";import{n as a}from"./property-Bmq4RTSP.js";import{o as y}from"./style-map-DE4G47KD.js";import{E as p,R as f}from"./ReadyMixin-CvX_eidU.js";import"./Badge-bWrvpEgX.js";import"./Icon-CWyJRQf7.js";import{R as g}from"./RovingTabindexMixin-9z8lwaM9.js";import"./DropdownMenu-B-LvOIGj.js";var v=Object.defineProperty,l=(u,t,e,n)=>{for(var i=void 0,s=u.length-1,h;s>=0;s--)(h=u[s])&&(i=h(t,e,i)||i);return i&&v(t,e,i),i};class o extends p(f(c)){constructor(){super(...arguments),this.disabled=!1,this.iconPosition="leading",this.iconOnly=!1,this.error=!1,this._active=!1,this._tabindex=-1,this.size="md",this.initialClasses=[],this._initialClassesCaptured=!1}static get tagName(){return"BTU-TAB"}connectedCallback(){super.connectedCallback(),this._initialClassesCaptured||(this.className&&(this.initialClasses=this.className.split(" ").filter(t=>t.trim())),this._initialClassesCaptured=!0)}createRenderRoot(){return this}willUpdate(){this.className=[...this.initialClasses,"btu-tab"].filter(Boolean).join(" ")}firstUpdated(){this.emit("btu-tab-ready")}handleClick(){this.disabled||!this.name||this.emit("btu-tab-change",{name:this.name})}render(){const t=this.symbol?d`<btu-icon symbol="${this.symbol}" size="${this.size==="lg"?"md":"sm"}"></btu-icon>`:r,e=this.iconOnly&&this.symbol?r:d`<span>${this.label}</span>`,n=this.badge!=null?d`<btu-badge size="sm">${this.badge}</btu-badge>`:r,i=this.error?d`<btu-badge size="sm" variant="error">!</btu-badge>`:r,s=this._active&&!this.disabled?d`<span
|
|
2
|
+
class="btu-tab-indicator"
|
|
3
|
+
style=${y(this.error?{background:"oklch(var(--btu-theme-error-600))"}:{})}
|
|
4
|
+
></span>`:r;return d`<button
|
|
5
|
+
type="button"
|
|
6
|
+
role="tab"
|
|
7
|
+
class="btu-tab-button-${this.size} btu-tab-button"
|
|
8
|
+
aria-selected="${this._active}"
|
|
9
|
+
aria-disabled="${this.disabled||r}"
|
|
10
|
+
aria-description="${this.description||r}"
|
|
11
|
+
aria-label="${this.iconOnly&&this.label?this.label:r}"
|
|
12
|
+
tabindex="${this._tabindex}"
|
|
13
|
+
@click=${this.handleClick}
|
|
14
|
+
>
|
|
15
|
+
${this.iconPosition==="leading"?t:r} ${e}
|
|
16
|
+
${this.iconPosition==="trailing"?t:r} ${n} ${i} ${s}
|
|
17
|
+
</button>`}}l([a({type:String,attribute:"name",reflect:!0})],o.prototype,"name");l([a({type:String})],o.prototype,"label");l([a({type:String})],o.prototype,"description");l([a({type:Boolean,reflect:!0})],o.prototype,"disabled");l([a({type:String})],o.prototype,"symbol");l([a({type:String,attribute:"icon-position"})],o.prototype,"iconPosition");l([a({type:Boolean,attribute:"icon-only"})],o.prototype,"iconOnly");l([a({type:Boolean,attribute:"error"})],o.prototype,"error");l([a({attribute:"badge"})],o.prototype,"badge");customElements.get("btu-tab")||customElements.define("btu-tab",o);var T=Object.defineProperty,m=(u,t,e,n)=>{for(var i=void 0,s=u.length-1,h;s>=0;s--)(h=u[s])&&(i=h(t,e,i)||i);return i&&T(t,e,i),i};class b extends g(p(f(c))){constructor(){super(...arguments),this.size="md",this.variant="full",this.initialClasses=[],this._initialClassesCaptured=!1,this.boundHandleTabChange=this.handleTabChange.bind(this),this.boundHandleKeyDown=this.handleKeyDown.bind(this),this.rafId=null,this.menuWrapper=null,this.menuDropdown=null,this.menuLabel=null,this.menuIcon=null,this.menuErrorBadge=null}static get tagName(){return"BTU-TABS"}_getRovingTargets(){const t=[];for(const e of this.getTabs()){if(e.style.display==="none")continue;const n=e.querySelector("button");n&&t.push(n)}return t}get _dropdownSize(){return this.size==="xs"?"sm":this.size}get _menuIconSize(){return this.size==="lg"?"md":"sm"}connectedCallback(){super.connectedCallback(),this._initialClassesCaptured||(this.className&&(this.initialClasses=this.className.split(" ").filter(t=>t.trim())),this._initialClassesCaptured=!0),this.setAttribute("role","tablist"),this.addEventListener("btu-tab-change",this.boundHandleTabChange),this.addEventListener("keydown",this.boundHandleKeyDown)}disconnectedCallback(){super.disconnectedCallback(),this.rafId&&(cancelAnimationFrame(this.rafId),this.rafId=null),this.removeEventListener("btu-tab-change",this.boundHandleTabChange),this.removeEventListener("keydown",this.boundHandleKeyDown)}createRenderRoot(){return this}willUpdate(){this.className=[...this.initialClasses,"btu-tabs",`btu-tabs-${this.size}`,this.variant==="menu"?"btu-tabs-menu-mode":""].filter(Boolean).join(" ")}firstUpdated(){if(!this.activeTab){const t=this.getTabs().find(e=>!e.disabled);t&&(this.activeTab=t.name)}this.syncTabs(),this.syncPanels(),this.variant==="menu"?this.initMenu():this.emit("btu-tabs-ready")}updated(t){if(t.has("activeTab")&&!this.activeTab){const e=this.getTabs().find(n=>!n.disabled);e&&(this.activeTab=e.name)}(t.has("activeTab")||t.has("size"))&&this.syncTabs(),t.has("activeTab")&&this.syncPanels(),t.has("size")&&this.menuDropdown&&(this.menuDropdown.size=this._dropdownSize),t.has("variant")&&t.get("variant")!==void 0&&(this.teardownVariant(t.get("variant")),this.variant==="menu"&&this.initMenu())}teardownVariant(t){t==="menu"&&(this.menuWrapper?.remove(),this.menuWrapper=null,this.menuDropdown=null,this.menuLabel=null,this.menuIcon=null,this.menuErrorBadge=null,this.getTabs().forEach(e=>e.style.removeProperty("display")))}syncTabs(){this.getTabs().forEach(t=>{t.size=this.size,t._active=t.name===this.activeTab,t._tabindex=t.name===this.activeTab?0:-1,t.requestUpdate()}),this.variant==="menu"&&this.syncMenuState()}syncPanels(){!this.activeTab||!this.parentElement||Array.from(this.parentElement.children).forEach(t=>{if(t===this||!(t instanceof HTMLElement))return;const e=t.getAttribute("name")??t.dataset.tab;e&&(t.hidden=e!==this.activeTab)})}getTabs(){return Array.from(this.querySelectorAll("btu-tab"))}activateTab(t){const e=this.getTabs().find(i=>i.name===t);if(!e||e.disabled){const i=this.getTabs().map(s=>s.name).filter(Boolean);console.warn(`[btu-tabs] Tab "${t}" not found or is disabled. Available tabs: ${i.join(", ")}`);return}if(t===this.activeTab)return;const n=this.activeTab;n&&this.emit("btu-tabs-hide",{name:n}),this.activeTab=t,this.emit("btu-tabs-show",{name:t}),this.syncTabs(),this.syncPanels()}handleTabChange(t){this.activateTab(t.detail.name)}handleKeyDown(t){switch(t.key){case"ArrowRight":t.preventDefault(),this._rovingNext();break;case"ArrowLeft":t.preventDefault(),this._rovingPrev();break;case"Home":t.preventDefault(),this._rovingFirst();break;case"End":t.preventDefault(),this._rovingLast();break}}initMenu(){this.getTabs().forEach(i=>i.style.display="none");const t=this.getTabs().find(i=>i.name===this.activeTab);this.menuWrapper=document.createElement("div");const e=this.menuWrapper;e.className="btu-tab-menu-wrapper",this.menuIcon=document.createElement("btu-icon"),this.menuIcon.setAttribute("size",this._menuIconSize),this.menuIcon.setAttribute("symbol",t?.symbol??""),this.menuIcon.hidden=!t?.symbol,this.menuLabel=document.createElement("span"),this.menuLabel.className="btu-tab-menu-label",this.menuLabel.textContent=t?.label??"",t?.iconPosition==="trailing"?(e.appendChild(this.menuLabel),e.appendChild(this.menuIcon)):(e.appendChild(this.menuIcon),e.appendChild(this.menuLabel)),this.menuErrorBadge=document.createElement("btu-badge"),this.menuErrorBadge.setAttribute("size","sm"),this.menuErrorBadge.setAttribute("variant","error"),this.menuErrorBadge.textContent="!",this.menuErrorBadge.hidden=!t?.error,e.appendChild(this.menuErrorBadge);const n=document.createElement("btu-dropdown-menu");this.menuDropdown=document.createElement("btu-dropdown"),this.menuDropdown.label="Tabs",this.menuDropdown.iconOnly=!0,this.menuDropdown.noChevron=!1,this.menuDropdown.variant="tertiary",this.menuDropdown.placement="bottom-start",this.menuDropdown.size=this._dropdownSize,this.menuDropdown.appendChild(n),this.menuDropdown.addEventListener("btu-dropdown-item-select",i=>{i.stopPropagation();const h=i.target.closest("btu-dropdown-item")?.dataset.name;h&&this.activateTab(h)}),e.appendChild(this.menuDropdown),this.appendChild(e),this.rafId=requestAnimationFrame(()=>{this.rafId=null,this.updateMenuItems(),this.emit("btu-tabs-ready")})}updateMenuItems(){if(!this.isConnected)return;const t=this.menuDropdown?.querySelector("btu-dropdown-menu");if(!t)return;t.innerHTML="";const e=this.getTabs(),n=e.some(i=>!!i.symbol);e.forEach(i=>{const s=document.createElement("btu-dropdown-item");s.dataset.name=i.name??"",s.label=i.label??i.name??"",s.selected=i.name===this.activeTab,s.disabled=i.disabled,s.error=i.error,i.symbol&&(s.symbol=i.symbol),t.appendChild(s),s._configure({checkbox:!1,icon:n,symbol:"",favorites:!1,shortcuts:!1})})}syncMenuState(){const t=this.getTabs().find(e=>e.name===this.activeTab);if(this.menuLabel&&(this.menuLabel.textContent=t?.label??""),this.menuIcon){const e=t?.symbol??"";this.menuIcon.setAttribute("symbol",e),this.menuIcon.setAttribute("size",this._menuIconSize),this.menuIcon.hidden=!e;const n=this.menuIcon.parentElement;n&&this.menuLabel&&(t?.iconPosition==="trailing"?n.insertBefore(this.menuIcon,this.menuErrorBadge):n.insertBefore(this.menuIcon,this.menuLabel))}this.menuErrorBadge&&(this.menuErrorBadge.hidden=!t?.error),this.menuDropdown?.querySelectorAll("btu-dropdown-item").forEach(e=>{e.selected=e.dataset.name===this.activeTab})}render(){return d``}}m([a({type:String})],b.prototype,"size");m([a({type:String,attribute:"active-tab"})],b.prototype,"activeTab");m([a({type:String})],b.prototype,"variant");customElements.get("btu-tabs")||customElements.define("btu-tabs",b);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{g as b,E as i,x as s}from"./iframe-
|
|
1
|
+
import{g as b,E as i,x as s}from"./iframe-DlBK9Drk.js";import{o as c}from"./style-map-DE4G47KD.js";import"./Tabs-DdpYNZSW.js";import"./preload-helper-PPVm8Dsz.js";import"./property-Bmq4RTSP.js";import"./ReadyMixin-CvX_eidU.js";import"./Badge-bWrvpEgX.js";import"./Icon-CWyJRQf7.js";import"./RovingTabindexMixin-9z8lwaM9.js";import"./DropdownMenu-B-LvOIGj.js";import"./aria-D5THOgos.js";import"./TooltipMixin-CVKslCDt.js";const{events:d,args:u,argTypes:a}=b("btu-tabs"),C={title:"Components/Tabs",component:"btu-tabs",tags:["autodocs"],parameters:{docs:{subtitle:"btu-tabs",description:{component:`
|
|
2
2
|
A tab group component that manages selection state across a set of \`btu-tab\` children.
|
|
3
3
|
|
|
4
4
|
<h3>When to use:</h3>
|
|
@@ -74,7 +74,7 @@ A tab group component that manages selection state across a set of \`btu-tab\` c
|
|
|
74
74
|
</div>
|
|
75
75
|
</div>
|
|
76
76
|
</div>
|
|
77
|
-
`,parameters:{docs:{description:{story:'\nEach `btu-tab` has a `name` attribute. Direct siblings of `btu-tabs` that share the same `name` value are automatically shown when that tab is active — no event listener needed. Siblings with a non-matching `name` are hidden. Multiple siblings can share the same `name` value and all will be shown together. Only direct siblings are managed, so nested tab groups control their own panels independently.\n\nEach content panel should have `role="tabpanel"` for accessibility.\n\n```html\n<div>\n <btu-tabs active-tab="main">\n <btu-tab name="main" label="Main"></btu-tab>\n <btu-tab name="seo" label="SEO"></btu-tab>\n </btu-tabs>\n <div name="main" role="tabpanel">...</div>\n <div name="seo" role="tabpanel">...</div>\n</div>\n```\n '}}}},
|
|
77
|
+
`,parameters:{docs:{description:{story:'\nEach `btu-tab` has a `name` attribute. Direct siblings of `btu-tabs` that share the same `name` value are automatically shown when that tab is active — no event listener needed. Siblings with a non-matching `name` are hidden. Multiple siblings can share the same `name` value and all will be shown together. Only direct siblings are managed, so nested tab groups control their own panels independently.\n\nEach content panel should have `role="tabpanel"` for accessibility.\n\n```html\n<div>\n <btu-tabs active-tab="main">\n <btu-tab name="main" label="Main"></btu-tab>\n <btu-tab name="seo" label="SEO"></btu-tab>\n </btu-tabs>\n <div name="main" role="tabpanel">...</div>\n <div name="seo" role="tabpanel">...</div>\n</div>\n```\n '}}}},r={name:"Full Variant",render:()=>s`
|
|
78
78
|
<div
|
|
79
79
|
style="width: 420px; max-width: 100%; resize: horizontal; overflow: hidden; border: 1px solid oklch(var(--btu-theme-gray-200)); border-radius: 0.5rem; padding: 0.5rem;"
|
|
80
80
|
>
|
|
@@ -89,7 +89,7 @@ A tab group component that manages selection state across a set of \`btu-tab\` c
|
|
|
89
89
|
<btu-tab name="api" label="API"></btu-tab>
|
|
90
90
|
</btu-tabs>
|
|
91
91
|
</div>
|
|
92
|
-
`,parameters:{docs:{description:{story:'The default `variant="full"` scrolls horizontally when tabs overflow. Drag the resize handle on the container to see tabs scroll.'}}}},
|
|
92
|
+
`,parameters:{docs:{description:{story:'The default `variant="full"` scrolls horizontally when tabs overflow. Drag the resize handle on the container to see tabs scroll.'}}}},l={name:"Menu Variant",render:()=>s`
|
|
93
93
|
<btu-tabs size="md" variant="menu" active-tab="main">
|
|
94
94
|
<btu-tab name="main" label="Main"></btu-tab>
|
|
95
95
|
<btu-tab name="seo" label="SEO"></btu-tab>
|
|
@@ -164,7 +164,7 @@ Each content panel should have \\\`role="tabpanel"\\\` for accessibility.
|
|
|
164
164
|
}
|
|
165
165
|
}
|
|
166
166
|
}
|
|
167
|
-
}`,...o.parameters?.docs?.source}}};
|
|
167
|
+
}`,...o.parameters?.docs?.source}}};r.parameters={...r.parameters,docs:{...r.parameters?.docs,source:{originalSource:`{
|
|
168
168
|
name: 'Full Variant',
|
|
169
169
|
render: () => html\`
|
|
170
170
|
<div
|
|
@@ -189,7 +189,7 @@ Each content panel should have \\\`role="tabpanel"\\\` for accessibility.
|
|
|
189
189
|
}
|
|
190
190
|
}
|
|
191
191
|
}
|
|
192
|
-
}`,...
|
|
192
|
+
}`,...r.parameters?.docs?.source}}};l.parameters={...l.parameters,docs:{...l.parameters?.docs,source:{originalSource:`{
|
|
193
193
|
name: 'Menu Variant',
|
|
194
194
|
render: () => html\`
|
|
195
195
|
<btu-tabs size="md" variant="menu" active-tab="main">
|
|
@@ -208,4 +208,4 @@ Each content panel should have \\\`role="tabpanel"\\\` for accessibility.
|
|
|
208
208
|
}
|
|
209
209
|
}
|
|
210
210
|
}
|
|
211
|
-
}`,...
|
|
211
|
+
}`,...l.parameters?.docs?.source}}};const k=["Default","WithContent","FullVariant","MenuVariant"];export{n as Default,r as FullVariant,l as MenuVariant,o as WithContent,k as __namedExportsOrder,C as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{x as u}from"./iframe-
|
|
1
|
+
import{x as u}from"./iframe-DlBK9Drk.js";import"./preload-helper-PPVm8Dsz.js";function v(e,t){if(e<=0)return t;let n,o=0;return function(){if(n)return;const r=Date.now(),s=e-r+o;s<=0?(o=r,t.apply(this,[...arguments])):n=setTimeout(()=>{o=r,n=void 0,t.apply(this,[...arguments])},s)}}const x={title:"Utilities/Throttle",tags:["autodocs"],parameters:{docs:{subtitle:"The `throttle` utility function limits how often a function can execute, ensuring it runs at most once per specified interval. Useful for high-frequency events like scroll, resize, or mousemove."},controls:{expanded:!0}},argTypes:{interval:{control:{type:"number",min:0,max:2e3,step:50},description:"Throttle interval in milliseconds"}},args:{interval:200}},d={render:e=>{const t=`throttle-${Math.random().toString(36).substring(2,9)}`;let n=0,o=0;const r=()=>{const m=document.getElementById(`${t}-normal-count`),h=document.getElementById(`${t}-throttled-count`);m&&(m.textContent=String(n)),h&&(h.textContent=String(o))},s=v(e.interval,()=>{o++,r()}),a=()=>{n++,r()},l=()=>{a(),s()};return u`
|
|
2
2
|
<div class="space-y-4">
|
|
3
3
|
<div class="text-base">
|
|
4
4
|
<p class="mb-2">
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import{x as i,i as g}from"./iframe-DlBK9Drk.js";import{t as y}from"./custom-element-UsVr97OX.js";import{n as b}from"./property-Bmq4RTSP.js";import{o as h}from"./if-defined-DerKRcyC.js";import{o as x}from"./style-map-DE4G47KD.js";import{E as v,R as w}from"./ReadyMixin-CvX_eidU.js";import{T as k}from"./TooltipMixin-CVKslCDt.js";import"./preload-helper-PPVm8Dsz.js";var T=Object.defineProperty,C=Object.getOwnPropertyDescriptor,u=(t,o,c,l)=>{for(var e=l>1?void 0:l?C(o,c):o,d=t.length-1,m;d>=0;d--)(m=t[d])&&(e=(l?m(o,c,e):m(e))||e);return l&&e&&T(o,c,e),e};let f=class extends k(v(w(g))){constructor(){super(...arguments),this.label="Hover me",this.initialClasses=[]}connectedCallback(){super.connectedCallback(),this.className&&(this.initialClasses=this.className.split(" ").filter(t=>t.trim()))}createRenderRoot(){return this}willUpdate(){const t=[...this.initialClasses,"tooltip-demo"];this.className=t.filter(Boolean).join(" ")}render(){return i`${this.label}`}};u([b({type:String})],f.prototype,"label",2);f=u([y("tooltip-demo")],f);const a=`
|
|
2
|
+
.tooltip-demo {
|
|
3
|
+
display: inline-flex;
|
|
4
|
+
align-items: center;
|
|
5
|
+
justify-content: center;
|
|
6
|
+
padding: 0.5rem 1rem;
|
|
7
|
+
border-radius: 0.375rem;
|
|
8
|
+
background-color: oklch(var(--btu-theme-gray-100));
|
|
9
|
+
color: oklch(var(--btu-theme-gray-700));
|
|
10
|
+
font-weight: 500;
|
|
11
|
+
font-size: 0.875rem;
|
|
12
|
+
cursor: default;
|
|
13
|
+
user-select: none;
|
|
14
|
+
}
|
|
15
|
+
`,D={title:"Mixins/Tooltip",tags:["autodocs"],parameters:{docs:{subtitle:"Declarative tooltip support for any LitElement component",description:{component:`
|
|
16
|
+
\`TooltipMixin\` adds declarative tooltip support to any LitElement component using CSS anchor positioning and the Popover API.
|
|
17
|
+
|
|
18
|
+
<h3>Opt-in Pattern</h3>
|
|
19
|
+
|
|
20
|
+
\`\`\`typescript
|
|
21
|
+
class MyComponent extends TooltipMixin(EventEmitterMixin(ReadyMixin(LitElement))) {
|
|
22
|
+
// Component now supports tooltip attributes
|
|
23
|
+
}
|
|
24
|
+
\`\`\`
|
|
25
|
+
|
|
26
|
+
\`\`\`html
|
|
27
|
+
<my-component tooltip="Hello!" tooltip-position="bottom"></my-component>
|
|
28
|
+
\`\`\`
|
|
29
|
+
|
|
30
|
+
<h3>Appearance</h3>
|
|
31
|
+
|
|
32
|
+
The tooltip surface is inverted by default — a dark chip on light pages and a light chip on dark pages — using the mode-flipping black/white tokens. Recolor a specific tooltip via <code>--tooltip-color-background</code> / <code>--tooltip-color-text</code>.
|
|
33
|
+
|
|
34
|
+
<h3>Accessibility</h3>
|
|
35
|
+
<ul>
|
|
36
|
+
<li><code>role="tooltip"</code> on tooltip element</li>
|
|
37
|
+
<li><code>aria-describedby</code> on host links to tooltip (appends to existing value)</li>
|
|
38
|
+
<li>Shows on <code>focusin</code>, hides on <code>focusout</code> and <code>Escape</code></li>
|
|
39
|
+
<li><code>prefers-reduced-motion: reduce</code> disables slide animation</li>
|
|
40
|
+
</ul>
|
|
41
|
+
`}},controls:{expanded:!0}},args:{tooltip:"This is a tooltip","tooltip-position":"top","tooltip-delay":300,"tooltip-no-arrow":!1,"tooltip-trigger":"hover focus",label:"Hover me"},argTypes:{tooltip:{control:{type:"text"},description:"Tooltip text. No tooltip rendered when empty.",table:{category:"Attributes"}},"tooltip-position":{control:{type:"select"},options:["top","bottom","left","right"],description:"Preferred placement (auto-flips if viewport constrained)",table:{category:"Attributes"}},"tooltip-delay":{control:{type:"number"},description:"Delay before showing tooltip on hover (ms)",table:{category:"Attributes"}},"tooltip-offset":{control:{type:"select"},options:["sm","md","lg","xl"],description:"Gap between trigger and tooltip (sm=4px, md=8px, lg=12px, xl=16px)",table:{category:"Attributes"}},"tooltip-no-arrow":{control:{type:"boolean"},description:"Hide the arrow pseudo-element",table:{category:"Attributes"}},"tooltip-trigger":{control:{type:"select"},options:["hover focus","hover","focus","click","hover click"],description:"How the tooltip is activated (combinable triggers)",table:{category:"Attributes"}},label:{control:{type:"text"},description:"Demo button label text",table:{category:"Demo"}},customBg:{name:"--tooltip-color-background",control:{type:"color"},description:"Background color (default: inverted surface)",table:{category:"css properties",defaultValue:{summary:"var(--btu-theme-black)"}}},customTextColor:{name:"--tooltip-color-text",control:{type:"color"},description:"Text color (default: inverted surface)",table:{category:"css properties",defaultValue:{summary:"var(--btu-theme-white)"}}},customRadius:{name:"--tooltip-border-radius",control:{type:"select"},options:["0px","0.125rem","0.25rem","0.375rem","0.5rem","0.75rem","1rem","1.5rem","9999px"],labels:{"0px":"none (0px)","0.125rem":"sm (0.125rem)","0.25rem":"DEFAULT (0.25rem)","0.375rem":"md (0.375rem)","0.5rem":"lg (0.5rem)","0.75rem":"xl (0.75rem)","1rem":"2xl (1rem)","1.5rem":"3xl (1.5rem)","9999px":"full (9999px)"},description:"Border radius",table:{category:"css properties",defaultValue:{summary:"0.5rem (lg)"}}}},render:t=>{const o={};return t.customBg&&(o["--tooltip-color-background"]=t.customBg),t.customTextColor&&(o["--tooltip-color-text"]=t.customTextColor),t.customRadius&&(o["--tooltip-border-radius"]=t.customRadius),i`
|
|
42
|
+
<style>
|
|
43
|
+
${a}
|
|
44
|
+
</style>
|
|
45
|
+
<div style="display: flex; justify-content: center; padding: 6rem 2rem;">
|
|
46
|
+
<div style=${x(o)}>
|
|
47
|
+
<tooltip-demo
|
|
48
|
+
tooltip="${t.tooltip}"
|
|
49
|
+
tooltip-position="${t["tooltip-position"]}"
|
|
50
|
+
tooltip-delay="${t["tooltip-delay"]}"
|
|
51
|
+
tooltip-offset="${h(t["tooltip-offset"])}"
|
|
52
|
+
?tooltip-no-arrow="${t["tooltip-no-arrow"]}"
|
|
53
|
+
tooltip-trigger="${t["tooltip-trigger"]}"
|
|
54
|
+
label="${t.label}"
|
|
55
|
+
></tooltip-demo>
|
|
56
|
+
</div>
|
|
57
|
+
</div>
|
|
58
|
+
`}},r={args:{}},p={render:()=>i`
|
|
59
|
+
<style>
|
|
60
|
+
${a}
|
|
61
|
+
</style>
|
|
62
|
+
<div style="display: flex; gap: 2rem; justify-content: center; padding: 6rem 2rem; flex-wrap: wrap;">
|
|
63
|
+
<tooltip-demo tooltip="Top tooltip" tooltip-position="top" label="Top"></tooltip-demo>
|
|
64
|
+
<tooltip-demo tooltip="Bottom tooltip" tooltip-position="bottom" label="Bottom"></tooltip-demo>
|
|
65
|
+
<tooltip-demo tooltip="Left tooltip" tooltip-position="left" label="Left"></tooltip-demo>
|
|
66
|
+
<tooltip-demo tooltip="Right tooltip" tooltip-position="right" label="Right"></tooltip-demo>
|
|
67
|
+
</div>
|
|
68
|
+
`,parameters:{docs:{description:{story:"Tooltips support four positions: `top`, `bottom`, `left`, and `right`. Each position auto-flips to the opposite side if constrained by the viewport."}}}},s={render:()=>i`
|
|
69
|
+
<style>
|
|
70
|
+
${a}
|
|
71
|
+
</style>
|
|
72
|
+
<div style="display: flex; gap: 2rem; justify-content: center; padding: 4rem 2rem; flex-wrap: wrap;">
|
|
73
|
+
<tooltip-demo tooltip="Small offset (4px)" tooltip-offset="sm" label="sm"></tooltip-demo>
|
|
74
|
+
<tooltip-demo tooltip="Medium offset (8px)" tooltip-offset="md" label="md"></tooltip-demo>
|
|
75
|
+
<tooltip-demo tooltip="Large offset (12px)" tooltip-offset="lg" label="lg"></tooltip-demo>
|
|
76
|
+
<tooltip-demo tooltip="Extra large offset (16px)" tooltip-offset="xl" label="xl"></tooltip-demo>
|
|
77
|
+
</div>
|
|
78
|
+
`,parameters:{docs:{description:{story:"The `tooltip-offset` attribute controls the gap between trigger and tooltip using named sizes: `sm` (4px), `md` (8px), `lg` (12px), `xl` (16px)."}}}},n={render:()=>i`
|
|
79
|
+
<style>
|
|
80
|
+
${a}
|
|
81
|
+
</style>
|
|
82
|
+
<div style="display: flex; gap: 2rem; justify-content: center; padding: 4rem 2rem; flex-wrap: wrap;">
|
|
83
|
+
<tooltip-demo tooltip="Click-triggered tooltip" tooltip-trigger="click" label="Click me"></tooltip-demo>
|
|
84
|
+
<tooltip-demo tooltip="Hover or click" tooltip-trigger="hover click" label="Hover or click"></tooltip-demo>
|
|
85
|
+
</div>
|
|
86
|
+
`,parameters:{docs:{description:{story:"The `tooltip-trigger` attribute controls how the tooltip is activated. `click` toggles on click and dismisses on Escape. Triggers can be combined with spaces."}}}};r.parameters={...r.parameters,docs:{...r.parameters?.docs,source:{originalSource:`{
|
|
87
|
+
args: {}
|
|
88
|
+
}`,...r.parameters?.docs?.source}}};p.parameters={...p.parameters,docs:{...p.parameters?.docs,source:{originalSource:`{
|
|
89
|
+
render: () => html\`
|
|
90
|
+
<style>
|
|
91
|
+
\${demoStyle}
|
|
92
|
+
</style>
|
|
93
|
+
<div style="display: flex; gap: 2rem; justify-content: center; padding: 6rem 2rem; flex-wrap: wrap;">
|
|
94
|
+
<tooltip-demo tooltip="Top tooltip" tooltip-position="top" label="Top"></tooltip-demo>
|
|
95
|
+
<tooltip-demo tooltip="Bottom tooltip" tooltip-position="bottom" label="Bottom"></tooltip-demo>
|
|
96
|
+
<tooltip-demo tooltip="Left tooltip" tooltip-position="left" label="Left"></tooltip-demo>
|
|
97
|
+
<tooltip-demo tooltip="Right tooltip" tooltip-position="right" label="Right"></tooltip-demo>
|
|
98
|
+
</div>
|
|
99
|
+
\`,
|
|
100
|
+
parameters: {
|
|
101
|
+
docs: {
|
|
102
|
+
description: {
|
|
103
|
+
story: 'Tooltips support four positions: \`top\`, \`bottom\`, \`left\`, and \`right\`. Each position auto-flips to the opposite side if constrained by the viewport.'
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}`,...p.parameters?.docs?.source}}};s.parameters={...s.parameters,docs:{...s.parameters?.docs,source:{originalSource:`{
|
|
108
|
+
render: () => html\`
|
|
109
|
+
<style>
|
|
110
|
+
\${demoStyle}
|
|
111
|
+
</style>
|
|
112
|
+
<div style="display: flex; gap: 2rem; justify-content: center; padding: 4rem 2rem; flex-wrap: wrap;">
|
|
113
|
+
<tooltip-demo tooltip="Small offset (4px)" tooltip-offset="sm" label="sm"></tooltip-demo>
|
|
114
|
+
<tooltip-demo tooltip="Medium offset (8px)" tooltip-offset="md" label="md"></tooltip-demo>
|
|
115
|
+
<tooltip-demo tooltip="Large offset (12px)" tooltip-offset="lg" label="lg"></tooltip-demo>
|
|
116
|
+
<tooltip-demo tooltip="Extra large offset (16px)" tooltip-offset="xl" label="xl"></tooltip-demo>
|
|
117
|
+
</div>
|
|
118
|
+
\`,
|
|
119
|
+
parameters: {
|
|
120
|
+
docs: {
|
|
121
|
+
description: {
|
|
122
|
+
story: 'The \`tooltip-offset\` attribute controls the gap between trigger and tooltip using named sizes: \`sm\` (4px), \`md\` (8px), \`lg\` (12px), \`xl\` (16px).'
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}`,...s.parameters?.docs?.source}}};n.parameters={...n.parameters,docs:{...n.parameters?.docs,source:{originalSource:`{
|
|
127
|
+
render: () => html\`
|
|
128
|
+
<style>
|
|
129
|
+
\${demoStyle}
|
|
130
|
+
</style>
|
|
131
|
+
<div style="display: flex; gap: 2rem; justify-content: center; padding: 4rem 2rem; flex-wrap: wrap;">
|
|
132
|
+
<tooltip-demo tooltip="Click-triggered tooltip" tooltip-trigger="click" label="Click me"></tooltip-demo>
|
|
133
|
+
<tooltip-demo tooltip="Hover or click" tooltip-trigger="hover click" label="Hover or click"></tooltip-demo>
|
|
134
|
+
</div>
|
|
135
|
+
\`,
|
|
136
|
+
parameters: {
|
|
137
|
+
docs: {
|
|
138
|
+
description: {
|
|
139
|
+
story: 'The \`tooltip-trigger\` attribute controls how the tooltip is activated. \`click\` toggles on click and dismisses on Escape. Triggers can be combined with spaces.'
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}`,...n.parameters?.docs?.source}}};const L=["Default","Positions","Offset","ClickTrigger"];export{n as ClickTrigger,r as Default,s as Offset,p as Positions,L as __namedExportsOrder,D as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./iframe-DlBK9Drk.js";import{n as s}from"./property-Bmq4RTSP.js";var c=Object.defineProperty,l=(n,e,h,t)=>{for(var i=void 0,o=n.length-1,r;o>=0;o--)(r=n[o])&&(i=r(e,h,i)||i);return i&&c(e,h,i),i};const p={top:"btu-tooltip-top",bottom:"btu-tooltip-bottom",left:"btu-tooltip-left",right:"btu-tooltip-right"},a={sm:"btu-tooltip-offset-sm",md:"btu-tooltip-offset-md",lg:"btu-tooltip-offset-lg",xl:"btu-tooltip-offset-xl"},d=n=>{class e extends n{constructor(){super(...arguments),this.tooltip="",this.tooltipPosition="top",this.tooltipDelay=300,this.tooltipOffset=null,this.tooltipNoArrow=!1,this.tooltipTrigger="hover focus",this._tooltipEl=null,this._tooltipId=`btu-tooltip-${crypto.randomUUID()}`,this._anchorName=`--btu-trigger-${crypto.randomUUID()}`,this._showTimer=null,this._isVisible=!1,this._activeTriggers=new Set,this._onMouseEnter=this._handleMouseEnter.bind(this),this._onMouseLeave=this._handleMouseLeave.bind(this),this._onFocusIn=this._handleFocusIn.bind(this),this._onFocusOut=this._handleFocusOut.bind(this),this._onClick=this._handleClick.bind(this),this._onNativeToggle=this._handleNativeToggle.bind(this),this._onKeyDown=this._handleKeyDown.bind(this),this._onDocumentClick=null}connectedCallback(){super.connectedCallback(),this._bindTriggerListeners()}disconnectedCallback(){if(this._clearShowTimer(),this._removeDocumentClickListener(),this._unbindTriggerListeners(),this._tooltipEl){try{this._tooltipEl.hidePopover()}catch(t){t instanceof DOMException&&t.name==="InvalidStateError"||console.warn("[btu-tooltip] Failed to hide tooltip during disconnect:",t)}this._tooltipEl.removeEventListener("toggle",this._onNativeToggle),this._tooltipEl.remove(),this._tooltipEl=null}this._removeAriaDescribedBy(),this.style.removeProperty("anchor-name"),this._isVisible=!1,super.disconnectedCallback()}updated(t){super.updated(t),t.has("tooltipTrigger")&&(this._unbindTriggerListeners(),this._bindTriggerListeners(),this._tooltipEl&&(this._isVisible&&this._hide(),this._tooltipEl.setAttribute("popover",this._getPopoverMode()))),(t.has("tooltip")||t.has("tooltipPosition")||t.has("tooltipDelay")||t.has("tooltipOffset")||t.has("tooltipNoArrow"))&&this._syncTooltipElement()}_getPopoverMode(){return"manual"}_syncTooltipElement(){if(!this.tooltip){this._tooltipEl&&(this._hide(),this._tooltipEl.removeEventListener("toggle",this._onNativeToggle),this._tooltipEl.remove(),this._tooltipEl=null,this._removeAriaDescribedBy(),this.style.removeProperty("anchor-name"),document.removeEventListener("keydown",this._onKeyDown));return}this.style.setProperty("anchor-name",this._anchorName),this._tooltipEl||(this._tooltipEl=this._createTooltipElement(),this.appendChild(this._tooltipEl),this._appendAriaDescribedBy(),document.addEventListener("keydown",this._onKeyDown)),this._tooltipEl.textContent=this.tooltip,this._tooltipEl.className=this._buildTooltipClasses()}_createTooltipElement(){const t=document.createElement("div");return t.id=this._tooltipId,t.className=this._buildTooltipClasses(),t.setAttribute("role","tooltip"),t.setAttribute("data-tooltip-internal",""),t.setAttribute("popover",this._getPopoverMode()),t.style.setProperty("position-anchor",this._anchorName),t.textContent=this.tooltip,t.addEventListener("toggle",this._onNativeToggle),t}_buildTooltipClasses(){const t=["btu-tooltip",p[this.tooltipPosition]];return this.tooltipOffset&&a[this.tooltipOffset]&&t.push(a[this.tooltipOffset]),this.tooltipNoArrow&&t.push("btu-tooltip-no-arrow"),t.join(" ")}_hasTrigger(t){return this._activeTriggers.has(t)}_bindTriggerListeners(){const t=new Set(["hover","focus","click"]);this._activeTriggers=new Set(this.tooltipTrigger.trim().split(/\s+/));for(const i of this._activeTriggers)t.has(i)||console.warn(`[btu-tooltip] Unrecognized tooltip-trigger value: "${i}". Valid values: hover, focus, click.`);this._hasTrigger("hover")&&(this.addEventListener("mouseenter",this._onMouseEnter),this.addEventListener("mouseleave",this._onMouseLeave)),this._hasTrigger("focus")&&(this.addEventListener("focusin",this._onFocusIn),this.addEventListener("focusout",this._onFocusOut)),this._hasTrigger("click")&&this.addEventListener("click",this._onClick)}_unbindTriggerListeners(){this.removeEventListener("mouseenter",this._onMouseEnter),this.removeEventListener("mouseleave",this._onMouseLeave),this.removeEventListener("focusin",this._onFocusIn),this.removeEventListener("focusout",this._onFocusOut),this.removeEventListener("click",this._onClick),document.removeEventListener("keydown",this._onKeyDown)}_show(){if(!(this._isVisible||!this._tooltipEl)){try{this._tooltipEl.showPopover()}catch(t){t instanceof DOMException&&t.name==="InvalidStateError"||console.warn("[btu-tooltip] Failed to show tooltip:",t)}this._hasTrigger("click")&&setTimeout(()=>{this._removeDocumentClickListener(),this._onDocumentClick=t=>{const i=t.composedPath();!i.includes(this)&&(!this._tooltipEl||!i.includes(this._tooltipEl))&&this._hide()},document.addEventListener("click",this._onDocumentClick)},0)}}_hide(){if(this._clearShowTimer(),this._removeDocumentClickListener(),!(!this._isVisible||!this._tooltipEl))try{this._tooltipEl.hidePopover()}catch(t){t instanceof DOMException&&t.name==="InvalidStateError"||console.warn("[btu-tooltip] Failed to hide tooltip:",t)}}_removeDocumentClickListener(){this._onDocumentClick&&(document.removeEventListener("click",this._onDocumentClick),this._onDocumentClick=null)}_handleNativeToggle(t){const{newState:i}=t;this._isVisible=i==="open";const o=this._isVisible?"btu-tooltip-show":"btu-tooltip-hide",r=new CustomEvent(o,{bubbles:!0,composed:!0});this.dispatchEvent(r)}_handleKeyDown(t){t.key==="Escape"&&(this._clearShowTimer(),this._hide())}_clearShowTimer(){this._showTimer!==null&&(clearTimeout(this._showTimer),this._showTimer=null)}_handleMouseEnter(){this._clearShowTimer(),this._showTimer=setTimeout(()=>{this._show()},this.tooltipDelay)}_handleMouseLeave(){this._clearShowTimer(),this._hide()}_handleFocusIn(){this._clearShowTimer(),this._show()}_handleFocusOut(){this._clearShowTimer(),this._hide()}_handleClick(){this._clearShowTimer(),this._isVisible?this._hide():this._show()}_appendAriaDescribedBy(){const t=this.getAttribute("aria-describedby");t?t.includes(this._tooltipId)||this.setAttribute("aria-describedby",`${t} ${this._tooltipId}`):this.setAttribute("aria-describedby",this._tooltipId)}_removeAriaDescribedBy(){const t=this.getAttribute("aria-describedby");if(!t)return;const i=t.split(/\s+/).filter(o=>o!==this._tooltipId).join(" ").trim();i?this.setAttribute("aria-describedby",i):this.removeAttribute("aria-describedby")}}return l([s({attribute:"tooltip"})],e.prototype,"tooltip"),l([s({attribute:"tooltip-position"})],e.prototype,"tooltipPosition"),l([s({attribute:"tooltip-delay",type:Number})],e.prototype,"tooltipDelay"),l([s({attribute:"tooltip-offset"})],e.prototype,"tooltipOffset"),l([s({attribute:"tooltip-no-arrow",type:Boolean})],e.prototype,"tooltipNoArrow"),l([s({attribute:"tooltip-trigger"})],e.prototype,"tooltipTrigger"),e};export{d as T};
|