@brightspot/ui 1.8.0 → 1.10.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/dist/LucideDynamicLoader.js +1 -1
- package/dist/LucideDynamicLoader.js.map +1 -1
- package/dist/LucideDynamicLoader.ts +1 -1
- package/dist/components/copy-to-clipboard/CopyToClipboard.d.ts.map +1 -1
- package/dist/components/copy-to-clipboard/CopyToClipboard.js +4 -0
- package/dist/components/copy-to-clipboard/CopyToClipboard.js.map +1 -1
- package/dist/components/icon/Icon.d.ts +1 -0
- package/dist/components/icon/Icon.d.ts.map +1 -1
- package/dist/components/icon/Icon.js +2 -1
- package/dist/components/icon/Icon.js.map +1 -1
- package/dist/components/switch/Switch.d.ts +92 -0
- package/dist/components/switch/Switch.d.ts.map +1 -0
- package/dist/components/switch/Switch.js +189 -0
- package/dist/components/switch/Switch.js.map +1 -0
- package/dist/custom-elements.json +510 -204
- package/dist/effects/celebrate.d.ts +18 -0
- package/dist/effects/celebrate.d.ts.map +1 -0
- package/dist/effects/celebrate.js +81 -0
- package/dist/effects/celebrate.js.map +1 -0
- package/dist/effects/ripple.d.ts +31 -0
- package/dist/effects/ripple.d.ts.map +1 -0
- package/dist/effects/ripple.js +131 -0
- package/dist/effects/ripple.js.map +1 -0
- package/dist/effects/sparkle-worklet.d.ts +7 -0
- package/dist/effects/sparkle-worklet.d.ts.map +1 -0
- package/dist/effects/sparkle-worklet.js +211 -0
- package/dist/effects/sparkle-worklet.js.map +1 -0
- package/dist/effects/sparkle.d.ts +6 -0
- package/dist/effects/sparkle.d.ts.map +1 -0
- package/dist/effects/sparkle.js +91 -0
- package/dist/effects/sparkle.js.map +1 -0
- package/dist/storybook/BSPLogoMark.svg +3 -0
- package/dist/storybook/WelcomeBG.svg +292 -0
- package/dist/storybook/assets/{Avatar.stories-XfJUoW42.js → Avatar.stories-B26mRkkZ.js} +1 -1
- package/dist/storybook/assets/{AvatarGroup.stories-CPkv0mVI.js → AvatarGroup.stories-J7lVGsMY.js} +1 -1
- package/dist/storybook/assets/{Badge.stories-Z42hQyzK.js → Badge.stories-BpTIV61M.js} +1 -1
- package/dist/storybook/assets/Button-Dg-fIrzT.js +10 -0
- package/dist/storybook/assets/Button.stories-gPKRVbxk.js +54 -0
- package/dist/storybook/assets/Celebrate.stories-DbY-sKEe.js +184 -0
- package/dist/storybook/assets/{CircularProgress.stories-B59nHh_k.js → CircularProgress.stories-DeH5JYX_.js} +1 -1
- package/dist/storybook/assets/{ClipboardMixin.stories-C6DraZ93.js → ClipboardMixin.stories-C-lZ4uuw.js} +1 -1
- package/dist/storybook/assets/Color-6BZIO3FS-Cu6zVIuG.js +1 -0
- package/dist/storybook/assets/{Colors.stories-B3Capc8F.js → Colors.stories-D6XYMrTD.js} +1 -1
- package/dist/storybook/assets/CombinedEffects.stories-jFekKTYg.js +355 -0
- package/dist/storybook/assets/{ComponentStatesMixin-DRalOmcW.js → ComponentStatesMixin-g50hRCPT.js} +1 -1
- package/dist/storybook/assets/{ComponentStatesMixin.stories-TKD7YrVe.js → ComponentStatesMixin.stories-D3Q5pR38.js} +1 -1
- package/dist/storybook/assets/{CopyToClipboard.stories-Bv8jZ7TL.js → CopyToClipboard.stories-COZZ1VC2.js} +1 -1
- package/dist/storybook/assets/{Debounce.stories-CLwXI3OZ.js → Debounce.stories-Dl10LAnx.js} +1 -1
- package/dist/storybook/assets/DocsRenderer-LL677BLK-CFLtMbUx.js +10 -0
- package/dist/storybook/assets/{Dropdown.stories-D7X0Dbnt.js → Dropdown.stories-Drwq-0Z2.js} +1 -1
- package/dist/storybook/assets/{Events.stories-Dgn1N8jT.js → Events.stories-dODeR-g-.js} +1 -1
- package/dist/storybook/assets/{Heading.stories-BcciQ3Ug.js → Heading.stories-CH7_-_q3.js} +1 -1
- package/dist/storybook/assets/HueRipple.stories-CH1Y739k.js +310 -0
- package/dist/storybook/assets/{Icon.stories-BWqJoZUM.js → Icon.stories-CPjM-jTU.js} +32 -13
- package/dist/storybook/assets/{IconButton.stories-BrMDAi9q.js → IconButton.stories-DuzqvcnN.js} +1 -1
- package/dist/storybook/assets/{LinearProgress.stories-INijWBr_.js → LinearProgress.stories-C7IdnJd3.js} +1 -1
- package/dist/storybook/assets/{Pagination.stories-CrExaWpC.js → Pagination.stories-C4cLjS_9.js} +1 -1
- package/dist/storybook/assets/{Popover.stories-Bh6IUPG_.js → Popover.stories-Ca1F-wrI.js} +3 -11
- package/dist/storybook/assets/{ReadyMixin-C1lZU7vt.js → ReadyMixin-DNZ5dCsZ.js} +1 -1
- package/dist/storybook/assets/{Rtc.stories-BHqFwgR7.js → Rtc.stories-BVJc1vCA.js} +1 -1
- package/dist/storybook/assets/{ScrollShadow.stories-DnIj5cZF.js → ScrollShadow.stories-C3W5o9ZW.js} +1 -1
- package/dist/storybook/assets/Switch.stories-BEEHP8mD.js +312 -0
- package/dist/storybook/assets/{Throttle.stories-Dilsv90H.js → Throttle.stories-C4xsYeAb.js} +1 -1
- package/dist/storybook/assets/{Tooltip.stories-Dnb76OXa.js → Tooltip.stories-Ccm4AnSv.js} +3 -7
- package/dist/storybook/assets/Welcome.stories-Degjk-M0.js +215 -0
- package/dist/storybook/assets/{Widget.stories-Cl-3dv15.js → Widget.stories-OKnZ9sDs.js} +1 -1
- package/dist/storybook/assets/WithTooltip-65CFNBJE-CXL3TyJ2.js +9 -0
- package/dist/storybook/assets/blocks-DLdUKG_W.js +707 -0
- package/dist/storybook/assets/celebrate-KwPoF1K3.js +21 -0
- package/dist/storybook/assets/formatter-EIJCOSYU-29NCxjfM.js +1 -0
- package/dist/storybook/assets/if-defined-BZFPaJjl.js +1 -0
- package/dist/storybook/assets/iframe-BqvwP3or.js +1104 -0
- package/dist/storybook/assets/{iframe-CNxIA3cQ.css → iframe-C5bIZMJ5.css} +1 -1
- package/dist/storybook/assets/index-BIyTv1BF.js +1 -0
- package/dist/storybook/assets/onFind-1l3EPW-I.js +1 -0
- package/dist/storybook/assets/{onFind.stories-CGeGoVR6.js → onFind.stories-D64-QZqf.js} +2 -2
- package/dist/storybook/assets/{onRemove.stories-DXOwfv14.js → onRemove.stories-BICsnIJL.js} +1 -1
- package/dist/storybook/assets/{onVisible.stories-DNzXceKW.js → onVisible.stories-DpDZP9_5.js} +2 -2
- package/dist/storybook/assets/position-CFNQy3J6.js +1 -0
- package/dist/storybook/assets/ripple-DQbyyRUw.js +251 -0
- package/dist/storybook/assets/{style-map-kcS06w9f.js → style-map-CBrSnxRe.js} +1 -1
- package/dist/storybook/assets/syntaxhighlighter-ED5Y7EFY-Bz_DuQj8.js +6 -0
- package/dist/storybook/brightspot-logo.svg +19 -0
- package/dist/storybook/iframe.html +23 -3
- package/dist/storybook/index.html +42 -1
- package/dist/storybook/index.json +1 -1
- package/dist/storybook/project.json +1 -1
- package/dist/storybook/sb-addons/storybook-3/manager-bundle.js +3 -0
- package/dist/tailwind-plugin-switch.d.ts +2 -0
- package/dist/tailwind-plugin-switch.d.ts.map +1 -0
- package/dist/tailwind-plugin-switch.js +223 -0
- package/dist/tailwind-plugin-switch.js.map +1 -0
- package/dist/tailwind-plugin-switch.ts +252 -0
- package/dist/util/EventEmitterMixin.d.ts +5 -0
- package/dist/util/EventEmitterMixin.d.ts.map +1 -1
- package/dist/util/EventEmitterMixin.js.map +1 -1
- package/dist/util/position.d.ts +9 -0
- package/dist/util/position.d.ts.map +1 -0
- package/dist/util/position.js +11 -0
- package/dist/util/position.js.map +1 -0
- package/docs/components/Icon.md +6 -5
- package/docs/components/README.md +1 -0
- package/docs/components/Switch.md +79 -0
- package/package.json +2 -1
- package/dist/storybook/assets/Button.stories-DTcnCrp-.js +0 -63
- package/dist/storybook/assets/Color-6BZIO3FS-BuNGIaf5.js +0 -1
- package/dist/storybook/assets/DocsRenderer-LL677BLK-DjMDalQg.js +0 -758
- package/dist/storybook/assets/WithTooltip-65CFNBJE-Bq21jhKM.js +0 -9
- package/dist/storybook/assets/_commonjsHelpers-CqkleIqs.js +0 -1
- package/dist/storybook/assets/formatter-EIJCOSYU-CwrejIu0.js +0 -1
- package/dist/storybook/assets/if-defined-D1UQmdjo.js +0 -1
- package/dist/storybook/assets/iframe-CsKt54V3.js +0 -1061
- package/dist/storybook/assets/index-DQ0xe06s.js +0 -1
- package/dist/storybook/assets/onFind-DqriYjEB.js +0 -1
- package/dist/storybook/assets/syntaxhighlighter-ED5Y7EFY-BnpaJz4a.js +0 -6
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
import{g as k,x as c}from"./iframe-BqvwP3or.js";import{o as s}from"./if-defined-BZFPaJjl.js";import{o as f}from"./style-map-CBrSnxRe.js";import{L as w}from"./LucideDynamicLoader-jmdq8YDM.js";import"./preload-helper-PPVm8Dsz.js";const{events:v,args:y,argTypes:g}=k("btu-switch"),x={customColorOn:"--switch-color-track-on",customColorOff:"--switch-color-track-off",customKnobColor:"--switch-color-knob",customLabelSpacing:"--switch-label-spacing",customIconSize:"--switch-track-icon-size"},S=e=>Object.entries(x).reduce((o,[t,n])=>(e[t]&&(o[n]=e[t]),o),{}),L={title:"Components/Switch",component:"btu-switch",tags:["autodocs"],parameters:{docs:{subtitle:"A toggle switch for binary on/off states",description:{component:`
|
|
2
|
+
<h3>When to use:</h3>
|
|
3
|
+
<ul>
|
|
4
|
+
<li>For toggling a setting or preference on/off</li>
|
|
5
|
+
<li>When the effect of the change is immediate or near-immediate</li>
|
|
6
|
+
<li>As an alternative to a single checkbox for boolean options</li>
|
|
7
|
+
</ul>
|
|
8
|
+
|
|
9
|
+
<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:v},controls:{expanded:!0}},args:{...y,label:"Label",checked:!1},argTypes:{...g,"--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":{...g["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'+w+" are supported."},"off-icon":{...g["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'+w+" 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
|
+
<btu-switch
|
|
12
|
+
size=${e.size??"small"}
|
|
13
|
+
label=${s(e.label)}
|
|
14
|
+
description=${s(e.description)}
|
|
15
|
+
label-position=${e["label-position"]??"end"}
|
|
16
|
+
on-icon=${s(e["on-icon"])}
|
|
17
|
+
off-icon=${s(e["off-icon"])}
|
|
18
|
+
name=${s(e.name)}
|
|
19
|
+
.checked=${e.checked??!1}
|
|
20
|
+
?disabled=${e.disabled}
|
|
21
|
+
style=${f(S(e))}
|
|
22
|
+
></btu-switch>
|
|
23
|
+
`},i={args:{}},a={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)."}}}},r={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."}}}},l={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`."}}}},d={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."}}}},h={args:{label:"Label on the left","label-position":"start"},parameters:{docs:{description:{story:'Place the label before the switch using `label-position="start"`.'}}}},u={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`)."}}}},m={render:()=>c`
|
|
24
|
+
<div style="display: flex; flex-direction: column; gap: 1rem;">
|
|
25
|
+
${["small","medium","large"].map(e=>c`
|
|
26
|
+
<btu-switch size=${e} label="${e} with icons" on-icon="check" off-icon="x" checked></btu-switch>
|
|
27
|
+
`)}
|
|
28
|
+
</div>
|
|
29
|
+
`,parameters:{docs:{description:{story:"Track icons scale automatically with the switch size."}}}},b={render:()=>c`
|
|
30
|
+
<div style="display: flex; flex-direction: column; gap: 1rem;">
|
|
31
|
+
${["small","medium","large"].map(e=>c` <btu-switch size=${e} label="${e} size" checked></btu-switch> `)}
|
|
32
|
+
</div>
|
|
33
|
+
`,parameters:{docs:{description:{story:"The three available size variants: `small` (default), `medium`, and `large`."}}}},p={render:()=>c`
|
|
34
|
+
<div class="flex flex-col gap-6">
|
|
35
|
+
<div class="flex flex-col gap-2">
|
|
36
|
+
<strong>Custom colors:</strong>
|
|
37
|
+
<div class="flex items-center gap-6">
|
|
38
|
+
<btu-switch
|
|
39
|
+
label="Success"
|
|
40
|
+
checked
|
|
41
|
+
style=${f({"--switch-color-track-on":"oklch(var(--btu-theme-success-600))"})}
|
|
42
|
+
></btu-switch>
|
|
43
|
+
<btu-switch
|
|
44
|
+
label="Warning"
|
|
45
|
+
checked
|
|
46
|
+
style=${f({"--switch-color-track-on":"oklch(var(--btu-theme-warning-500))"})}
|
|
47
|
+
></btu-switch>
|
|
48
|
+
<btu-switch
|
|
49
|
+
label="Error"
|
|
50
|
+
checked
|
|
51
|
+
style=${f({"--switch-color-track-on":"oklch(var(--btu-theme-error-600))"})}
|
|
52
|
+
></btu-switch>
|
|
53
|
+
</div>
|
|
54
|
+
</div>
|
|
55
|
+
|
|
56
|
+
<div class="flex flex-col gap-2">
|
|
57
|
+
<strong>Event handling:</strong>
|
|
58
|
+
<btu-switch
|
|
59
|
+
label="Toggle me"
|
|
60
|
+
description="Check the Actions panel to see events"
|
|
61
|
+
@btu-switch-change=${e=>{const t=e.target.querySelector(".btu-switch-description");t&&(t.textContent=e.detail.checked?"Switch is ON":"Switch is OFF")}}
|
|
62
|
+
></btu-switch>
|
|
63
|
+
</div>
|
|
64
|
+
|
|
65
|
+
<div class="flex flex-col gap-2">
|
|
66
|
+
<strong>Form participation:</strong>
|
|
67
|
+
<form
|
|
68
|
+
class="flex flex-col gap-3 rounded-lg border border-gray-200 bg-gray-50 p-4"
|
|
69
|
+
@submit=${e=>{e.preventDefault();const o=e.target,t=new FormData(o),n=o.querySelector(".form-output");n&&(n.textContent=JSON.stringify(Object.fromEntries(t),null,2))}}
|
|
70
|
+
>
|
|
71
|
+
<btu-switch label="Email notifications" name="email" checked></btu-switch>
|
|
72
|
+
<btu-switch label="SMS notifications" name="sms"></btu-switch>
|
|
73
|
+
<btu-switch label="Push notifications" name="push" checked></btu-switch>
|
|
74
|
+
<button type="submit" class="btu-button btu-button-sm w-fit">Submit</button>
|
|
75
|
+
<pre class="form-output text-xs text-gray-600"></pre>
|
|
76
|
+
</form>
|
|
77
|
+
</div>
|
|
78
|
+
|
|
79
|
+
<div class="flex flex-col gap-2">
|
|
80
|
+
<strong>Track icons:</strong>
|
|
81
|
+
<div class="flex items-center gap-6">
|
|
82
|
+
<btu-switch label="Check / X" on-icon="check" off-icon="x" checked></btu-switch>
|
|
83
|
+
<btu-switch label="Lock" on-icon="lock-open" off-icon="lock"></btu-switch>
|
|
84
|
+
<btu-switch label="Sound" on-icon="volume-2" off-icon="volume-off" checked></btu-switch>
|
|
85
|
+
</div>
|
|
86
|
+
</div>
|
|
87
|
+
|
|
88
|
+
<div class="flex flex-col gap-2">
|
|
89
|
+
<strong>Programmatic control:</strong>
|
|
90
|
+
<div class="flex items-center gap-4">
|
|
91
|
+
<btu-switch id="programmatic-switch" label="Controlled switch" size="medium"></btu-switch>
|
|
92
|
+
<button
|
|
93
|
+
class="btu-button btu-button-sm"
|
|
94
|
+
@click=${()=>{const e=document.getElementById("programmatic-switch");e&&(e.checked=!e.checked)}}
|
|
95
|
+
>
|
|
96
|
+
Toggle externally
|
|
97
|
+
</button>
|
|
98
|
+
</div>
|
|
99
|
+
</div>
|
|
100
|
+
</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."}}}};i.parameters={...i.parameters,docs:{...i.parameters?.docs,source:{originalSource:`{
|
|
102
|
+
args: {}
|
|
103
|
+
}`,...i.parameters?.docs?.source}}};a.parameters={...a.parameters,docs:{...a.parameters?.docs,source:{originalSource:`{
|
|
104
|
+
args: {
|
|
105
|
+
checked: true,
|
|
106
|
+
label: 'Enabled'
|
|
107
|
+
},
|
|
108
|
+
parameters: {
|
|
109
|
+
docs: {
|
|
110
|
+
description: {
|
|
111
|
+
story: 'Switch in the checked/on state. The track uses \`--switch-color-track-on\` (defaults to primary-700).'
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}`,...a.parameters?.docs?.source}}};r.parameters={...r.parameters,docs:{...r.parameters?.docs,source:{originalSource:`{
|
|
116
|
+
args: {
|
|
117
|
+
label: 'Enable notifications',
|
|
118
|
+
description: 'Receive updates via email',
|
|
119
|
+
checked: true
|
|
120
|
+
},
|
|
121
|
+
parameters: {
|
|
122
|
+
docs: {
|
|
123
|
+
description: {
|
|
124
|
+
story: 'Switch with both a primary label and a secondary description.'
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}`,...r.parameters?.docs?.source}}};l.parameters={...l.parameters,docs:{...l.parameters?.docs,source:{originalSource:`{
|
|
129
|
+
args: {
|
|
130
|
+
label: 'Unavailable option',
|
|
131
|
+
disabled: true
|
|
132
|
+
},
|
|
133
|
+
parameters: {
|
|
134
|
+
docs: {
|
|
135
|
+
description: {
|
|
136
|
+
story: 'Disabled state via the \`disabled\` attribute. The track opacity is reduced and the wrapper cursor changes to \`not-allowed\`.'
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}`,...l.parameters?.docs?.source}}};d.parameters={...d.parameters,docs:{...d.parameters?.docs,source:{originalSource:`{
|
|
141
|
+
args: {
|
|
142
|
+
label: 'Previously enabled',
|
|
143
|
+
disabled: true,
|
|
144
|
+
checked: true
|
|
145
|
+
},
|
|
146
|
+
parameters: {
|
|
147
|
+
docs: {
|
|
148
|
+
description: {
|
|
149
|
+
story: 'Disabled switch in the checked state. Useful for showing a locked-on setting.'
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}`,...d.parameters?.docs?.source}}};h.parameters={...h.parameters,docs:{...h.parameters?.docs,source:{originalSource:`{
|
|
154
|
+
args: {
|
|
155
|
+
label: 'Label on the left',
|
|
156
|
+
'label-position': 'start'
|
|
157
|
+
},
|
|
158
|
+
parameters: {
|
|
159
|
+
docs: {
|
|
160
|
+
description: {
|
|
161
|
+
story: 'Place the label before the switch using \`label-position="start"\`.'
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}`,...h.parameters?.docs?.source}}};u.parameters={...u.parameters,docs:{...u.parameters?.docs,source:{originalSource:`{
|
|
166
|
+
args: {
|
|
167
|
+
label: 'Notifications',
|
|
168
|
+
checked: true,
|
|
169
|
+
'on-icon': 'check',
|
|
170
|
+
'off-icon': 'x'
|
|
171
|
+
},
|
|
172
|
+
parameters: {
|
|
173
|
+
docs: {
|
|
174
|
+
description: {
|
|
175
|
+
story: 'Track icons via \`on-icon\` and \`off-icon\` attributes. Icons use Lucide names (e.g., \`check\`, \`x\`, \`bell\`, \`bell-off\`).'
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}`,...u.parameters?.docs?.source}}};m.parameters={...m.parameters,docs:{...m.parameters?.docs,source:{originalSource:`{
|
|
180
|
+
render: () => html\`
|
|
181
|
+
<div style="display: flex; flex-direction: column; gap: 1rem;">
|
|
182
|
+
\${(['small', 'medium', 'large'] as const).map(size => html\`
|
|
183
|
+
<btu-switch size=\${size} label="\${size} with icons" on-icon="check" off-icon="x" checked></btu-switch>
|
|
184
|
+
\`)}
|
|
185
|
+
</div>
|
|
186
|
+
\`,
|
|
187
|
+
parameters: {
|
|
188
|
+
docs: {
|
|
189
|
+
description: {
|
|
190
|
+
story: 'Track icons scale automatically with the switch size.'
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}`,...m.parameters?.docs?.source}}};b.parameters={...b.parameters,docs:{...b.parameters?.docs,source:{originalSource:`{
|
|
195
|
+
render: () => html\`
|
|
196
|
+
<div style="display: flex; flex-direction: column; gap: 1rem;">
|
|
197
|
+
\${(['small', 'medium', 'large'] as const).map(size => html\` <btu-switch size=\${size} label="\${size} size" checked></btu-switch> \`)}
|
|
198
|
+
</div>
|
|
199
|
+
\`,
|
|
200
|
+
parameters: {
|
|
201
|
+
docs: {
|
|
202
|
+
description: {
|
|
203
|
+
story: 'The three available size variants: \`small\` (default), \`medium\`, and \`large\`.'
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}`,...b.parameters?.docs?.source}}};p.parameters={...p.parameters,docs:{...p.parameters?.docs,source:{originalSource:`{
|
|
208
|
+
render: () => html\`
|
|
209
|
+
<div class="flex flex-col gap-6">
|
|
210
|
+
<div class="flex flex-col gap-2">
|
|
211
|
+
<strong>Custom colors:</strong>
|
|
212
|
+
<div class="flex items-center gap-6">
|
|
213
|
+
<btu-switch
|
|
214
|
+
label="Success"
|
|
215
|
+
checked
|
|
216
|
+
style=\${styleMap({
|
|
217
|
+
'--switch-color-track-on': 'oklch(var(--btu-theme-success-600))'
|
|
218
|
+
})}
|
|
219
|
+
></btu-switch>
|
|
220
|
+
<btu-switch
|
|
221
|
+
label="Warning"
|
|
222
|
+
checked
|
|
223
|
+
style=\${styleMap({
|
|
224
|
+
'--switch-color-track-on': 'oklch(var(--btu-theme-warning-500))'
|
|
225
|
+
})}
|
|
226
|
+
></btu-switch>
|
|
227
|
+
<btu-switch
|
|
228
|
+
label="Error"
|
|
229
|
+
checked
|
|
230
|
+
style=\${styleMap({
|
|
231
|
+
'--switch-color-track-on': 'oklch(var(--btu-theme-error-600))'
|
|
232
|
+
})}
|
|
233
|
+
></btu-switch>
|
|
234
|
+
</div>
|
|
235
|
+
</div>
|
|
236
|
+
|
|
237
|
+
<div class="flex flex-col gap-2">
|
|
238
|
+
<strong>Event handling:</strong>
|
|
239
|
+
<btu-switch
|
|
240
|
+
label="Toggle me"
|
|
241
|
+
description="Check the Actions panel to see events"
|
|
242
|
+
@btu-switch-change=\${(e: CustomEvent<{
|
|
243
|
+
checked: boolean;
|
|
244
|
+
}>) => {
|
|
245
|
+
const el = e.target as HTMLElement;
|
|
246
|
+
const label = el.querySelector('.btu-switch-description');
|
|
247
|
+
if (label) label.textContent = e.detail.checked ? 'Switch is ON' : 'Switch is OFF';
|
|
248
|
+
}}
|
|
249
|
+
></btu-switch>
|
|
250
|
+
</div>
|
|
251
|
+
|
|
252
|
+
<div class="flex flex-col gap-2">
|
|
253
|
+
<strong>Form participation:</strong>
|
|
254
|
+
<form
|
|
255
|
+
class="flex flex-col gap-3 rounded-lg border border-gray-200 bg-gray-50 p-4"
|
|
256
|
+
@submit=\${(e: Event) => {
|
|
257
|
+
e.preventDefault();
|
|
258
|
+
const form = e.target as HTMLFormElement;
|
|
259
|
+
const data = new FormData(form);
|
|
260
|
+
const output = form.querySelector('.form-output');
|
|
261
|
+
if (output) output.textContent = JSON.stringify(Object.fromEntries(data), null, 2);
|
|
262
|
+
}}
|
|
263
|
+
>
|
|
264
|
+
<btu-switch label="Email notifications" name="email" checked></btu-switch>
|
|
265
|
+
<btu-switch label="SMS notifications" name="sms"></btu-switch>
|
|
266
|
+
<btu-switch label="Push notifications" name="push" checked></btu-switch>
|
|
267
|
+
<button type="submit" class="btu-button btu-button-sm w-fit">Submit</button>
|
|
268
|
+
<pre class="form-output text-xs text-gray-600"></pre>
|
|
269
|
+
</form>
|
|
270
|
+
</div>
|
|
271
|
+
|
|
272
|
+
<div class="flex flex-col gap-2">
|
|
273
|
+
<strong>Track icons:</strong>
|
|
274
|
+
<div class="flex items-center gap-6">
|
|
275
|
+
<btu-switch label="Check / X" on-icon="check" off-icon="x" checked></btu-switch>
|
|
276
|
+
<btu-switch label="Lock" on-icon="lock-open" off-icon="lock"></btu-switch>
|
|
277
|
+
<btu-switch label="Sound" on-icon="volume-2" off-icon="volume-off" checked></btu-switch>
|
|
278
|
+
</div>
|
|
279
|
+
</div>
|
|
280
|
+
|
|
281
|
+
<div class="flex flex-col gap-2">
|
|
282
|
+
<strong>Programmatic control:</strong>
|
|
283
|
+
<div class="flex items-center gap-4">
|
|
284
|
+
<btu-switch id="programmatic-switch" label="Controlled switch" size="medium"></btu-switch>
|
|
285
|
+
<button
|
|
286
|
+
class="btu-button btu-button-sm"
|
|
287
|
+
@click=\${() => {
|
|
288
|
+
const sw = document.getElementById('programmatic-switch') as HTMLElement & {
|
|
289
|
+
checked: boolean;
|
|
290
|
+
};
|
|
291
|
+
if (sw) sw.checked = !sw.checked;
|
|
292
|
+
}}
|
|
293
|
+
>
|
|
294
|
+
Toggle externally
|
|
295
|
+
</button>
|
|
296
|
+
</div>
|
|
297
|
+
</div>
|
|
298
|
+
</div>
|
|
299
|
+
\`,
|
|
300
|
+
parameters: {
|
|
301
|
+
docs: {
|
|
302
|
+
description: {
|
|
303
|
+
story: \`
|
|
304
|
+
- **Custom colors** via CSS custom properties (\\\`--switch-color-track-on\\\`, \\\`--switch-color-track-off\\\`) using theme tokens.
|
|
305
|
+
- **Event handling** with the \\\`btu-switch-change\\\` event, which provides \\\`{ checked: boolean }\\\` in its detail.
|
|
306
|
+
- **Form participation** using the \\\`name\\\` attribute — the hidden checkbox participates in native form submission.
|
|
307
|
+
- **Track icons** via \\\`on-icon\\\` and \\\`off-icon\\\` attributes using Lucide icon names (e.g., \\\`check\\\`, \\\`x\\\`, \\\`lock\\\`, \\\`volume-2\\\`).
|
|
308
|
+
- **Programmatic control** by setting the \\\`checked\\\` property directly from JavaScript.\`
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
}`,...p.parameters?.docs?.source}}};const D=["Default","Checked","WithDescription","Disabled","DisabledChecked","LabelStart","WithIcons","WithIconsSizes","Sizes","AdvancedUsage"];export{p as AdvancedUsage,a as Checked,i as Default,l as Disabled,d as DisabledChecked,h as LabelStart,b as Sizes,r as WithDescription,u as WithIcons,m as WithIconsSizes,D as __namedExportsOrder,L as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{x as u}from"./iframe-
|
|
1
|
+
import{x as u}from"./iframe-BqvwP3or.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 h=document.getElementById(`${t}-normal-count`),m=document.getElementById(`${t}-throttled-count`);h&&(h.textContent=String(n)),m&&(m.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">
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{a as v,u as x,x as c,i as w}from"./iframe-BqvwP3or.js";import{t as E}from"./custom-element-UsVr97OX.js";import{o as T}from"./if-defined-BZFPaJjl.js";import{o as k}from"./style-map-CBrSnxRe.js";import{E as C,R as L}from"./ReadyMixin-DNZ5dCsZ.js";import"./preload-helper-PPVm8Dsz.js";const S={attribute:!0,type:String,converter:x,reflect:!1,hasChanged:v},D=(o=S,i,l)=>{const{kind:t,metadata:e}=l;let s=globalThis.litPropertyMetadata.get(e);if(s===void 0&&globalThis.litPropertyMetadata.set(e,s=new Map),t==="setter"&&((o=Object.create(o)).wrapped=!0),s.set(l.name,o),t==="accessor"){const{name:r}=l;return{set(n){const g=i.get.call(this);i.set.call(this,n),this.requestUpdate(r,g,o)},init(n){return n!==void 0&&this.C(r,void 0,o,n),n}}}if(t==="setter"){const{name:r}=l;return function(n){const g=this[r];i.call(this,n),this.requestUpdate(r,g,o)}}throw Error("Unsupported decorator location: "+t)};function p(o){return(i,l)=>typeof l=="object"?D(o,i,l):((t,e,s)=>{const r=e.hasOwnProperty(s);return e.constructor.createProperty(s,t),r?Object.getOwnPropertyDescriptor(e,s):void 0})(o,i,l)}var A=Object.defineProperty,a=(o,i,l,t)=>{for(var e=void 0,s=o.length-1,r;s>=0;s--)(r=o[s])&&(e=r(i,l,e)||e);return e&&A(i,l,e),e};const M={top:"btu-tooltip-top",bottom:"btu-tooltip-bottom",left:"btu-tooltip-left",right:"btu-tooltip-right"},_={sm:"btu-tooltip-offset-sm",md:"btu-tooltip-offset-md",lg:"btu-tooltip-offset-lg",xl:"btu-tooltip-offset-xl"},O=o=>{class i extends o{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",M[this.tooltipPosition]];return this.tooltipOffset&&_[this.tooltipOffset]&&t.push(_[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 e of this._activeTriggers)t.has(e)||console.warn(`[btu-tooltip] Unrecognized tooltip-trigger value: "${e}". 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 e=t.composedPath();!e.includes(this)&&(!this._tooltipEl||!e.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:e}=t;this._isVisible=e==="open",this.dispatchEvent(new CustomEvent(this._isVisible?"btu-tooltip-show":"btu-tooltip-hide",{bubbles:!0,composed:!0}))}_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 e=t.split(/\s+/).filter(s=>s!==this._tooltipId).join(" ").trim();e?this.setAttribute("aria-describedby",e):this.removeAttribute("aria-describedby")}}return a([p({attribute:"tooltip"})],i.prototype,"tooltip"),a([p({attribute:"tooltip-position"})],i.prototype,"tooltipPosition"),a([p({attribute:"tooltip-delay",type:Number})],i.prototype,"tooltipDelay"),a([p({attribute:"tooltip-offset"})],i.prototype,"tooltipOffset"),a([p({attribute:"tooltip-no-arrow",type:Boolean})],i.prototype,"tooltipNoArrow"),a([p({attribute:"tooltip-trigger"})],i.prototype,"tooltipTrigger"),i};var P=Object.defineProperty,$=Object.getOwnPropertyDescriptor,y=(o,i,l,t)=>{for(var e=t>1?void 0:t?$(i,l):i,s=o.length-1,r;s>=0;s--)(r=o[s])&&(e=(t?r(i,l,e):r(e))||e);return t&&e&&P(i,l,e),e};let b=class extends O(C(L(w))){constructor(){super(...arguments),this.label="Hover me",this.initialClasses=[]}connectedCallback(){super.connectedCallback(),this.className&&(this.initialClasses=this.className.split(" ").filter(o=>o.trim()))}createRenderRoot(){return this}willUpdate(){const o=[...this.initialClasses,"tooltip-demo"];this.className=o.filter(Boolean).join(" ")}render(){return c`${this.label}`}};y([p({type:String})],b.prototype,"label",2);b=y([E("tooltip-demo")],b);const f=`
|
|
2
2
|
.tooltip-demo {
|
|
3
3
|
display: inline-flex;
|
|
4
4
|
align-items: center;
|
|
@@ -61,7 +61,7 @@ class MyComponent extends TooltipMixin(EventEmitterMixin(ReadyMixin(LitElement))
|
|
|
61
61
|
<tooltip-demo tooltip="Left tooltip" tooltip-position="left" label="Left"></tooltip-demo>
|
|
62
62
|
<tooltip-demo tooltip="Right tooltip" tooltip-position="right" label="Right"></tooltip-demo>
|
|
63
63
|
</div>
|
|
64
|
-
`,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."}
|
|
64
|
+
`,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."}}}},m={render:()=>c`
|
|
65
65
|
<style>
|
|
66
66
|
${f}
|
|
67
67
|
</style>
|
|
@@ -97,10 +97,6 @@ class MyComponent extends TooltipMixin(EventEmitterMixin(ReadyMixin(LitElement))
|
|
|
97
97
|
docs: {
|
|
98
98
|
description: {
|
|
99
99
|
story: 'Tooltips support four positions: \`top\`, \`bottom\`, \`left\`, and \`right\`. Each position auto-flips to the opposite side if constrained by the viewport.'
|
|
100
|
-
},
|
|
101
|
-
story: {
|
|
102
|
-
inline: false,
|
|
103
|
-
iframeHeight: 300
|
|
104
100
|
}
|
|
105
101
|
}
|
|
106
102
|
}
|
|
@@ -140,4 +136,4 @@ class MyComponent extends TooltipMixin(EventEmitterMixin(ReadyMixin(LitElement))
|
|
|
140
136
|
}
|
|
141
137
|
}
|
|
142
138
|
}
|
|
143
|
-
}`,...u.parameters?.docs?.source}}};const
|
|
139
|
+
}`,...u.parameters?.docs?.source}}};const U=["Default","Positions","Offset","ClickTrigger"];export{u as ClickTrigger,d as Default,m as Offset,h as Positions,U as __namedExportsOrder,V as default};
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import{S as U}from"./blocks-DLdUKG_W.js";import{e as X,f as _,E as B,r as j,x as A}from"./iframe-BqvwP3or.js";import"./preload-helper-PPVm8Dsz.js";const C=()=>new J;class J{}const w=new WeakMap,k=X(class extends _{render(e){return B}update(e,[o]){const t=o!==this.G;return t&&this.G!==void 0&&this.rt(void 0),(t||this.lt!==this.ct)&&(this.G=o,this.ht=e.options?.host,this.rt(this.ct=e.element)),B}rt(e){if(this.isConnected||(e=void 0),typeof this.G=="function"){const o=this.ht??globalThis;let t=w.get(o);t===void 0&&(t=new WeakMap,w.set(o,t)),t.get(this.G)!==void 0&&this.G.call(this.ht,void 0),t.set(this.G,e),e!==void 0&&this.G.call(this.ht,e)}else this.G.value=e}get lt(){return typeof this.G=="function"?w.get(this.ht??globalThis)?.get(this.G):this.G?.value}disconnected(){this.lt===this.ct&&this.rt(void 0)}reconnected(){this.rt(this.ct)}}),ee={title:"Welcome",tags:["autodocs","!dev"],parameters:{layout:"fullscreen",controls:{disable:!0},actions:{disable:!0},options:{showPanel:!1},docs:{page:()=>j.createElement("div",{className:"welcome-docs"},j.createElement(U))}}},$=[[13,52,158],[19,183,158],[99,43,176],[95,233,208],[240,67,62],[83,36,148]],d=(e,o)=>e+Math.random()*(o-e),M=e=>e[Math.floor(Math.random()*e.length)];function I(e,o){if(matchMedia("(prefers-reduced-motion: reduce)").matches)return;const t=e.getContext("2d"),l=Array.from({length:3},()=>({x:0,y:0,rgb:M($),opacity:0,radius:d(250,350)}));let h=null;function O(){const s=5*devicePixelRatio,n=Object.assign(document.createElement("canvas"),{width:s,height:s}),r=n.getContext("2d");r.fillStyle="#000",r.arc(s/2,s/2,1.6*devicePixelRatio,0,Math.PI*2),r.fill(),h=t.createPattern(n,"repeat")}function R(){const{width:s,height:n}=e.getBoundingClientRect();e.width=s*devicePixelRatio,e.height=n*devicePixelRatio,t.setTransform(devicePixelRatio,0,0,devicePixelRatio,0,0),O()}R(),addEventListener("resize",R);const a=o?l[0]:null;a&&(a.rgb=M($),a.radius=300),(function s(){if(!e.isConnected)return;const n=e.width/devicePixelRatio,r=e.height/devicePixelRatio;t.clearRect(0,0,n,r),a&&o&&(o.active?(a.x+=(o.tx-a.x)*.06,a.y+=(o.ty-a.y)*.06,a.opacity+=(.35-a.opacity)*.08):a.opacity+=(0-a.opacity)*.04);for(const i of l){if(i.opacity<=0)continue;const[u,p,b]=i.rgb,c=t.createRadialGradient(i.x,i.y,0,i.x,i.y,i.radius);c.addColorStop(0,`rgba(${u},${p},${b},${i.opacity})`),c.addColorStop(1,`rgba(${u},${p},${b},0)`),t.fillStyle=c,t.fillRect(i.x-i.radius,i.y-i.radius,i.radius*2,i.radius*2)}h&&(t.globalCompositeOperation="destination-in",t.fillStyle=h,t.fillRect(0,0,n,r),t.globalCompositeOperation="source-over"),requestAnimationFrame(s)})();function S(s){if(!e.isConnected)return;const{width:n,height:r}=e.getBoundingClientRect(),i=300,u=m=>m<2?{x:d(.15*n,.85*n),y:m===0?-i:r+i}:{x:m===2?-i:n+i,y:d(.15*r,.85*r)},p=Math.floor(Math.random()*4),b=(p+(Math.random()<.5?2:[1,3][Math.floor(Math.random()*2)]))%4,c=u(p),z=u(b),y=z.x-c.x,x=z.y-c.y,E=Math.hypot(y,x)||1,Y=Math.min(n,r)*d(.15,.35),D=d(1.2,2.2);s.rgb=M($),s.radius=d(250,350);let P=null;const F=d(6e3,7500);(function m(G){if(!e.isConnected)return;P??=G;const f=Math.min((G-P)/F,1),L=.5-.5*Math.cos(f*Math.PI),T=Math.sin(f*D*Math.PI)*Y;s.x=c.x+y*L+-x/E*T,s.y=c.y+x*L+y/E*T,s.opacity=.35*Math.min(f/.2,1)*Math.min((1-f)/.2,1),f<1?requestAnimationFrame(m):s.opacity=0})(performance.now())}(o?l.slice(1):l).forEach((s,n)=>setTimeout(()=>{S(s),setInterval(()=>e.isConnected&&S(s),7500)},1e3+n*2500))}const q="position:absolute;inset:0;width:100%;height:100%;pointer-events:none;",N=C(),W=C(),H=C(),v={active:!1,tx:0,ty:0},g={render:()=>(queueMicrotask(()=>{const e=N.value;e&&!e.dataset.init&&(e.dataset.init="1",I(e));const o=W.value;o&&!o.dataset.init&&(o.dataset.init="1",I(o,v));const t=H.value;t&&!t.dataset.init&&(t.dataset.init="1",t.addEventListener("mousemove",l=>{const h=t.getBoundingClientRect();v.tx=l.clientX-h.left,v.ty=l.clientY-h.top,v.active=!0}),t.addEventListener("mouseleave",()=>{v.active=!1}))}),A`
|
|
2
|
+
<div
|
|
3
|
+
${k(H)}
|
|
4
|
+
style="
|
|
5
|
+
position: relative;
|
|
6
|
+
display: flex;
|
|
7
|
+
flex-direction: column;
|
|
8
|
+
align-items: center;
|
|
9
|
+
justify-content: flex-end;
|
|
10
|
+
min-height: 100vh;
|
|
11
|
+
padding: 40px 24px;
|
|
12
|
+
font-family: 'Noto Sans', 'Helvetica Neue', Arial, sans-serif;
|
|
13
|
+
overflow: hidden;
|
|
14
|
+
background-color: var(--btu-theme-white);
|
|
15
|
+
"
|
|
16
|
+
>
|
|
17
|
+
<canvas ${k(N)} aria-hidden="true" style="${q}z-index:0;"></canvas>
|
|
18
|
+
|
|
19
|
+
<img
|
|
20
|
+
src="/WelcomeBG.svg"
|
|
21
|
+
aria-hidden="true"
|
|
22
|
+
style="
|
|
23
|
+
position: absolute;
|
|
24
|
+
inset: 0;
|
|
25
|
+
width: 100%;
|
|
26
|
+
height: 100%;
|
|
27
|
+
object-fit: cover;
|
|
28
|
+
object-position: center;
|
|
29
|
+
pointer-events: none;
|
|
30
|
+
user-select: none;
|
|
31
|
+
z-index: 1;
|
|
32
|
+
"
|
|
33
|
+
/>
|
|
34
|
+
|
|
35
|
+
<canvas ${k(W)} aria-hidden="true" style="${q}z-index:2;"></canvas>
|
|
36
|
+
|
|
37
|
+
<div style="position: relative; z-index: 3; display: flex; flex-direction: column; align-items: center;">
|
|
38
|
+
<div
|
|
39
|
+
style="
|
|
40
|
+
display: flex;
|
|
41
|
+
flex-wrap: wrap;
|
|
42
|
+
gap: 16px;
|
|
43
|
+
width: 100%;
|
|
44
|
+
height: 100%;
|
|
45
|
+
"
|
|
46
|
+
>
|
|
47
|
+
${[{label:"Components",path:"?path=/docs/components-avatar--docs"},{label:"CSS Plugins",path:"?path=/docs/css-plugins-button--docs"},{label:"Design System",path:"?path=/docs/design-system-colors--docs"},{label:"Utilities",path:"?path=/docs/utilities-debounce--docs"}].map(e=>A`
|
|
48
|
+
<div
|
|
49
|
+
style="
|
|
50
|
+
padding: 20px 24px;
|
|
51
|
+
border: 1px solid oklch(var(--btu-theme-gray-200));
|
|
52
|
+
border-radius: 10px;
|
|
53
|
+
background: color-mix(in oklch, var(--btu-theme-white) 85%, transparent);
|
|
54
|
+
backdrop-filter: blur(8px);
|
|
55
|
+
cursor: pointer;
|
|
56
|
+
transition: box-shadow 0.2s cubic-bezier(0.4, 0, 0.2, 1), border-color 0.2s cubic-bezier(0.4, 0, 0.2, 1), transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
|
|
57
|
+
"
|
|
58
|
+
@mouseenter=${o=>{const t=o.currentTarget;t.style.borderColor="oklch(var(--btu-theme-primary-700))",t.style.transform="translateY(-2px)",t.classList.add("shadow-md")}}
|
|
59
|
+
@mouseleave=${o=>{const t=o.currentTarget;t.style.borderColor="oklch(var(--btu-theme-gray-200))",t.style.transform="none",t.classList.remove("shadow-md")}}
|
|
60
|
+
@click=${()=>{window.top.location.search=e.path}}
|
|
61
|
+
>
|
|
62
|
+
<div
|
|
63
|
+
style="
|
|
64
|
+
font-size: 0.9375rem;
|
|
65
|
+
font-weight: 600;
|
|
66
|
+
color: oklch(var(--btu-theme-gray-900));
|
|
67
|
+
margin-bottom: 4px;
|
|
68
|
+
"
|
|
69
|
+
>
|
|
70
|
+
${e.label}
|
|
71
|
+
</div>
|
|
72
|
+
<div style="font-size: 0.8125rem; color: oklch(var(--btu-theme-gray-500));">
|
|
73
|
+
Browse ${e.label.toLowerCase()}
|
|
74
|
+
</div>
|
|
75
|
+
</div>
|
|
76
|
+
`)}
|
|
77
|
+
</div>
|
|
78
|
+
</div>
|
|
79
|
+
</div>
|
|
80
|
+
`)};g.parameters={...g.parameters,docs:{...g.parameters?.docs,source:{originalSource:`{
|
|
81
|
+
render: () => {
|
|
82
|
+
queueMicrotask(() => {
|
|
83
|
+
// Init back canvas (auto-swoop only)
|
|
84
|
+
const back = backRef.value;
|
|
85
|
+
if (back && !back.dataset.init) {
|
|
86
|
+
back.dataset.init = '1';
|
|
87
|
+
initSwoop(back);
|
|
88
|
+
}
|
|
89
|
+
// Init front canvas (mouse-follow on blob[0] + auto-swoop on rest)
|
|
90
|
+
const front = frontRef.value;
|
|
91
|
+
if (front && !front.dataset.init) {
|
|
92
|
+
front.dataset.init = '1';
|
|
93
|
+
initSwoop(front, mouse);
|
|
94
|
+
}
|
|
95
|
+
// Mouse events on container (covers full area including over cards)
|
|
96
|
+
const ctr = containerRef.value;
|
|
97
|
+
if (ctr && !ctr.dataset.init) {
|
|
98
|
+
ctr.dataset.init = '1';
|
|
99
|
+
ctr.addEventListener('mousemove', (e: MouseEvent) => {
|
|
100
|
+
const rect = ctr.getBoundingClientRect();
|
|
101
|
+
mouse.tx = e.clientX - rect.left;
|
|
102
|
+
mouse.ty = e.clientY - rect.top;
|
|
103
|
+
mouse.active = true;
|
|
104
|
+
});
|
|
105
|
+
ctr.addEventListener('mouseleave', () => {
|
|
106
|
+
mouse.active = false;
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
return html\`
|
|
111
|
+
<div
|
|
112
|
+
\${ref(containerRef)}
|
|
113
|
+
style="
|
|
114
|
+
position: relative;
|
|
115
|
+
display: flex;
|
|
116
|
+
flex-direction: column;
|
|
117
|
+
align-items: center;
|
|
118
|
+
justify-content: flex-end;
|
|
119
|
+
min-height: 100vh;
|
|
120
|
+
padding: 40px 24px;
|
|
121
|
+
font-family: 'Noto Sans', 'Helvetica Neue', Arial, sans-serif;
|
|
122
|
+
overflow: hidden;
|
|
123
|
+
background-color: var(--btu-theme-white);
|
|
124
|
+
"
|
|
125
|
+
>
|
|
126
|
+
<canvas \${ref(backRef)} aria-hidden="true" style="\${canvasStyle}z-index:0;"></canvas>
|
|
127
|
+
|
|
128
|
+
<img
|
|
129
|
+
src="/WelcomeBG.svg"
|
|
130
|
+
aria-hidden="true"
|
|
131
|
+
style="
|
|
132
|
+
position: absolute;
|
|
133
|
+
inset: 0;
|
|
134
|
+
width: 100%;
|
|
135
|
+
height: 100%;
|
|
136
|
+
object-fit: cover;
|
|
137
|
+
object-position: center;
|
|
138
|
+
pointer-events: none;
|
|
139
|
+
user-select: none;
|
|
140
|
+
z-index: 1;
|
|
141
|
+
"
|
|
142
|
+
/>
|
|
143
|
+
|
|
144
|
+
<canvas \${ref(frontRef)} aria-hidden="true" style="\${canvasStyle}z-index:2;"></canvas>
|
|
145
|
+
|
|
146
|
+
<div style="position: relative; z-index: 3; display: flex; flex-direction: column; align-items: center;">
|
|
147
|
+
<div
|
|
148
|
+
style="
|
|
149
|
+
display: flex;
|
|
150
|
+
flex-wrap: wrap;
|
|
151
|
+
gap: 16px;
|
|
152
|
+
width: 100%;
|
|
153
|
+
height: 100%;
|
|
154
|
+
"
|
|
155
|
+
>
|
|
156
|
+
\${([{
|
|
157
|
+
label: 'Components',
|
|
158
|
+
path: '?path=/docs/components-avatar--docs'
|
|
159
|
+
}, {
|
|
160
|
+
label: 'CSS Plugins',
|
|
161
|
+
path: '?path=/docs/css-plugins-button--docs'
|
|
162
|
+
}, {
|
|
163
|
+
label: 'Design System',
|
|
164
|
+
path: '?path=/docs/design-system-colors--docs'
|
|
165
|
+
}, {
|
|
166
|
+
label: 'Utilities',
|
|
167
|
+
path: '?path=/docs/utilities-debounce--docs'
|
|
168
|
+
}] as const).map(section => html\`
|
|
169
|
+
<div
|
|
170
|
+
style="
|
|
171
|
+
padding: 20px 24px;
|
|
172
|
+
border: 1px solid oklch(var(--btu-theme-gray-200));
|
|
173
|
+
border-radius: 10px;
|
|
174
|
+
background: color-mix(in oklch, var(--btu-theme-white) 85%, transparent);
|
|
175
|
+
backdrop-filter: blur(8px);
|
|
176
|
+
cursor: pointer;
|
|
177
|
+
transition: box-shadow 0.2s cubic-bezier(0.4, 0, 0.2, 1), border-color 0.2s cubic-bezier(0.4, 0, 0.2, 1), transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
|
|
178
|
+
"
|
|
179
|
+
@mouseenter=\${(e: Event) => {
|
|
180
|
+
const el = e.currentTarget as HTMLElement;
|
|
181
|
+
el.style.borderColor = 'oklch(var(--btu-theme-primary-700))';
|
|
182
|
+
el.style.transform = 'translateY(-2px)';
|
|
183
|
+
el.classList.add('shadow-md');
|
|
184
|
+
}}
|
|
185
|
+
@mouseleave=\${(e: Event) => {
|
|
186
|
+
const el = e.currentTarget as HTMLElement;
|
|
187
|
+
el.style.borderColor = 'oklch(var(--btu-theme-gray-200))';
|
|
188
|
+
el.style.transform = 'none';
|
|
189
|
+
el.classList.remove('shadow-md');
|
|
190
|
+
}}
|
|
191
|
+
@click=\${() => {
|
|
192
|
+
window.top!.location.search = section.path;
|
|
193
|
+
}}
|
|
194
|
+
>
|
|
195
|
+
<div
|
|
196
|
+
style="
|
|
197
|
+
font-size: 0.9375rem;
|
|
198
|
+
font-weight: 600;
|
|
199
|
+
color: oklch(var(--btu-theme-gray-900));
|
|
200
|
+
margin-bottom: 4px;
|
|
201
|
+
"
|
|
202
|
+
>
|
|
203
|
+
\${section.label}
|
|
204
|
+
</div>
|
|
205
|
+
<div style="font-size: 0.8125rem; color: oklch(var(--btu-theme-gray-500));">
|
|
206
|
+
Browse \${section.label.toLowerCase()}
|
|
207
|
+
</div>
|
|
208
|
+
</div>
|
|
209
|
+
\`)}
|
|
210
|
+
</div>
|
|
211
|
+
</div>
|
|
212
|
+
</div>
|
|
213
|
+
\`;
|
|
214
|
+
}
|
|
215
|
+
}`,...g.parameters?.docs?.source}}};const te=["Page"];export{g as Page,te as __namedExportsOrder,ee as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{g as h,x as l}from"./iframe-
|
|
1
|
+
import{g as h,x as l}from"./iframe-BqvwP3or.js";import{o as m}from"./style-map-CBrSnxRe.js";import"./preload-helper-PPVm8Dsz.js";const{events:y,args:w,argTypes:a}=h("btu-widget"),$={title:"Components/Widget",component:"btu-widget",tags:["autodocs"],parameters:{docs:{subtitle:"btu-widget",description:{component:`
|
|
2
2
|
<h3>When to use:</h3>
|
|
3
3
|
<ul>
|
|
4
4
|
<li>To display content in a structured widget layout</li>
|