bits-lab 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +57 -2
- package/dist/Accordion.d.ts +52 -0
- package/dist/Accordion.js +192 -0
- package/dist/AchievementToast.d.ts +36 -0
- package/dist/AchievementToast.js +162 -0
- package/dist/AgentCard.d.ts +41 -0
- package/dist/AgentCard.js +168 -0
- package/dist/ArcadeButtons.d.ts +23 -0
- package/dist/ArcadeButtons.js +169 -0
- package/dist/AuroraBands.d.ts +19 -0
- package/dist/AuroraBands.js +126 -0
- package/dist/AvatarTooltips.d.ts +32 -0
- package/dist/AvatarTooltips.js +121 -0
- package/dist/BarRace.d.ts +39 -0
- package/dist/BarRace.js +227 -0
- package/dist/BentoGrid.d.ts +50 -0
- package/dist/BentoGrid.js +145 -0
- package/dist/BootSequence.d.ts +48 -0
- package/dist/BootSequence.js +234 -0
- package/dist/BreadcrumbTrail.d.ts +31 -0
- package/dist/BreadcrumbTrail.js +181 -0
- package/dist/CRTPower.d.ts +30 -0
- package/dist/CRTPower.js +142 -0
- package/dist/CardDeck.d.ts +29 -0
- package/dist/CardDeck.js +154 -0
- package/dist/ChangelogTimeline.d.ts +35 -0
- package/dist/ChangelogTimeline.js +137 -0
- package/dist/ChapterProgress.d.ts +23 -0
- package/dist/ChapterProgress.js +211 -0
- package/dist/ChatBubbles.d.ts +42 -0
- package/dist/ChatBubbles.js +198 -0
- package/dist/ChiptuneKit.d.ts +158 -0
- package/dist/ChiptuneKit.js +207 -0
- package/dist/CipherCard.d.ts +22 -0
- package/dist/CipherCard.js +91 -0
- package/dist/CloudSky.d.ts +28 -0
- package/dist/CloudSky.js +222 -0
- package/dist/CodeRain.d.ts +24 -0
- package/dist/CodeRain.js +158 -0
- package/dist/CodeShowcase.d.ts +50 -0
- package/dist/CodeShowcase.js +307 -0
- package/dist/ColorDial.d.ts +42 -0
- package/dist/ColorDial.js +288 -0
- package/dist/CommandPalette.d.ts +59 -0
- package/dist/CommandPalette.js +349 -0
- package/dist/CompareSlider.d.ts +33 -0
- package/dist/CompareSlider.js +152 -0
- package/dist/Confetti.d.ts +61 -0
- package/dist/Confetti.js +176 -0
- package/dist/ConnectBeams.d.ts +39 -0
- package/dist/ConnectBeams.js +132 -0
- package/dist/ContextOrb.d.ts +34 -0
- package/dist/ContextOrb.js +269 -0
- package/dist/ContourLines.d.ts +20 -0
- package/dist/ContourLines.js +159 -0
- package/dist/Coverflow.d.ts +27 -0
- package/dist/Coverflow.js +167 -0
- package/dist/CursorAttractor.d.ts +21 -0
- package/dist/CursorAttractor.js +136 -0
- package/dist/CutReveal.d.ts +21 -0
- package/dist/CutReveal.js +116 -0
- package/dist/DateRange.d.ts +45 -0
- package/dist/DateRange.js +327 -0
- package/dist/DeviceFrame.d.ts +30 -0
- package/dist/DeviceFrame.js +145 -0
- package/dist/DiffReveal.d.ts +36 -0
- package/dist/DiffReveal.js +247 -0
- package/dist/DirectionHover.d.ts +15 -0
- package/dist/DirectionHover.js +90 -0
- package/dist/Discard.d.ts +18 -0
- package/dist/Discard.js +61 -0
- package/dist/DitherField.d.ts +15 -0
- package/dist/DitherField.js +157 -0
- package/dist/DotGlobe.d.ts +48 -0
- package/dist/DotGlobe.js +312 -0
- package/dist/DotMap.d.ts +47 -0
- package/dist/DotMap.js +172 -0
- package/dist/DropZone.d.ts +57 -0
- package/dist/DropZone.js +304 -0
- package/dist/DynamicIsland.d.ts +32 -0
- package/dist/DynamicIsland.js +92 -0
- package/dist/EdgeFX.d.ts +27 -0
- package/dist/EdgeFX.js +98 -0
- package/dist/ElasticString.d.ts +22 -0
- package/dist/ElasticString.js +127 -0
- package/dist/ExpandCard.d.ts +44 -0
- package/dist/ExpandCard.js +182 -0
- package/dist/FeatureTabs.d.ts +34 -0
- package/dist/FeatureTabs.js +169 -0
- package/dist/FeedList.d.ts +37 -0
- package/dist/FeedList.js +163 -0
- package/dist/FlickerGrid.d.ts +29 -0
- package/dist/FlickerGrid.js +156 -0
- package/dist/FocusGrid.d.ts +20 -0
- package/dist/FocusGrid.js +48 -0
- package/dist/FocusPull.d.ts +26 -0
- package/dist/FocusPull.js +106 -0
- package/dist/Footprints.d.ts +24 -0
- package/dist/Footprints.js +126 -0
- package/dist/FunnelFlow.d.ts +34 -0
- package/dist/FunnelFlow.js +267 -0
- package/dist/GameOver.d.ts +46 -0
- package/dist/GameOver.js +191 -0
- package/dist/GaugeMeter.d.ts +38 -0
- package/dist/GaugeMeter.js +195 -0
- package/dist/GlassPanel.d.ts +27 -0
- package/dist/GlassPanel.js +80 -0
- package/dist/GrainFX.d.ts +34 -0
- package/dist/GrainFX.js +122 -0
- package/dist/GravityBox.d.ts +30 -0
- package/dist/GravityBox.js +220 -0
- package/dist/HealthBar.d.ts +33 -0
- package/dist/HealthBar.js +140 -0
- package/dist/Heatmap.d.ts +42 -0
- package/dist/Heatmap.js +232 -0
- package/dist/HexField.d.ts +29 -0
- package/dist/HexField.js +188 -0
- package/dist/HoldToConfirm.d.ts +29 -0
- package/dist/HoldToConfirm.js +163 -0
- package/dist/HorizontalTrack.d.ts +28 -0
- package/dist/HorizontalTrack.js +195 -0
- package/dist/HotbarDock.d.ts +40 -0
- package/dist/HotbarDock.js +148 -0
- package/dist/InkText.d.ts +27 -0
- package/dist/InkText.js +65 -0
- package/dist/InlineEdit.d.ts +30 -0
- package/dist/InlineEdit.js +198 -0
- package/dist/InteractiveGrid.d.ts +25 -0
- package/dist/InteractiveGrid.js +194 -0
- package/dist/InventoryGrid.d.ts +45 -0
- package/dist/InventoryGrid.js +272 -0
- package/dist/JellyBlob.d.ts +30 -0
- package/dist/JellyBlob.js +209 -0
- package/dist/KineticHeadline.d.ts +30 -0
- package/dist/KineticHeadline.js +133 -0
- package/dist/LavaLamp.d.ts +21 -0
- package/dist/LavaLamp.js +133 -0
- package/dist/LetterSwap.d.ts +20 -0
- package/dist/LetterSwap.js +78 -0
- package/dist/LevelMap.d.ts +35 -0
- package/dist/LevelMap.js +189 -0
- package/dist/LightShafts.d.ts +22 -0
- package/dist/LightShafts.js +170 -0
- package/dist/LightboxGallery.d.ts +26 -0
- package/dist/LightboxGallery.js +327 -0
- package/dist/LinkPeek.d.ts +36 -0
- package/dist/LinkPeek.js +194 -0
- package/dist/LogoOrbit.d.ts +37 -0
- package/dist/LogoOrbit.js +117 -0
- package/dist/Marquee.d.ts +33 -0
- package/dist/Marquee.js +148 -0
- package/dist/MarqueeLine.d.ts +33 -0
- package/dist/MarqueeLine.js +167 -0
- package/dist/MasonryWall.d.ts +13 -0
- package/dist/MasonryWall.js +90 -0
- package/dist/MegaMenu.d.ts +32 -0
- package/dist/MegaMenu.js +280 -0
- package/dist/MeteorShower.d.ts +24 -0
- package/dist/MeteorShower.js +155 -0
- package/dist/Minimap.d.ts +21 -0
- package/dist/Minimap.js +236 -0
- package/dist/MobileTabBar.d.ts +38 -0
- package/dist/MobileTabBar.js +148 -0
- package/dist/MorphDialog.d.ts +34 -0
- package/dist/MorphDialog.js +199 -0
- package/dist/MorphPopover.d.ts +33 -0
- package/dist/MorphPopover.js +168 -0
- package/dist/MorphWords.d.ts +18 -0
- package/dist/MorphWords.js +136 -0
- package/dist/OTPInput.d.ts +43 -0
- package/dist/OTPInput.js +174 -0
- package/dist/OverlayKit.d.ts +97 -0
- package/dist/OverlayKit.js +466 -0
- package/dist/OverlayMenu.d.ts +32 -0
- package/dist/OverlayMenu.js +154 -0
- package/dist/ParallaxCollage.d.ts +41 -0
- package/dist/ParallaxCollage.js +143 -0
- package/dist/PasswordMeter.d.ts +44 -0
- package/dist/PasswordMeter.js +165 -0
- package/dist/PegBoard.d.ts +26 -0
- package/dist/PegBoard.js +184 -0
- package/dist/PinCard.d.ts +21 -0
- package/dist/PinCard.js +84 -0
- package/dist/PixelAvatar.d.ts +33 -0
- package/dist/PixelAvatar.js +144 -0
- package/dist/PixelButton.d.ts +20 -0
- package/dist/PixelButton.js +128 -0
- package/dist/PixelExplode.d.ts +31 -0
- package/dist/PixelExplode.js +164 -0
- package/dist/PixelLoader.d.ts +32 -0
- package/dist/PixelLoader.js +142 -0
- package/dist/PixelParallax.d.ts +41 -0
- package/dist/PixelParallax.js +151 -0
- package/dist/PixelSpinners.d.ts +21 -0
- package/dist/PixelSpinners.js +110 -0
- package/dist/PixelType.d.ts +26 -0
- package/dist/PixelType.js +220 -0
- package/dist/PointerKit.d.ts +23 -0
- package/dist/PointerKit.js +222 -0
- package/dist/Polaroids.d.ts +41 -0
- package/dist/Polaroids.js +293 -0
- package/dist/PressStart.d.ts +28 -0
- package/dist/PressStart.js +99 -0
- package/dist/PricingFlip.d.ts +52 -0
- package/dist/PricingFlip.js +190 -0
- package/dist/ProximityType.d.ts +26 -0
- package/dist/ProximityType.js +135 -0
- package/dist/QuestDialog.d.ts +50 -0
- package/dist/QuestDialog.js +204 -0
- package/dist/QuestLog.d.ts +39 -0
- package/dist/QuestLog.js +214 -0
- package/dist/RangeDual.d.ts +34 -0
- package/dist/RangeDual.js +238 -0
- package/dist/RatingPips.d.ts +25 -0
- package/dist/RatingPips.js +129 -0
- package/dist/RetroHorizon.d.ts +27 -0
- package/dist/RetroHorizon.js +169 -0
- package/dist/Reveal.d.ts +30 -0
- package/dist/Reveal.js +92 -0
- package/dist/RingProgress.d.ts +45 -0
- package/dist/RingProgress.js +180 -0
- package/dist/RollingNumber.d.ts +28 -0
- package/dist/RollingNumber.js +108 -0
- package/dist/ScanScope.d.ts +24 -0
- package/dist/ScanScope.js +164 -0
- package/dist/ScoreTicker.d.ts +32 -0
- package/dist/ScoreTicker.js +176 -0
- package/dist/ScreenScroller.d.ts +24 -0
- package/dist/ScreenScroller.js +138 -0
- package/dist/Screensaver.d.ts +31 -0
- package/dist/Screensaver.js +221 -0
- package/dist/ScrollTilt.d.ts +27 -0
- package/dist/ScrollTilt.js +100 -0
- package/dist/ScrollTypography.d.ts +26 -0
- package/dist/ScrollTypography.js +124 -0
- package/dist/ScrollZoom.d.ts +31 -0
- package/dist/ScrollZoom.js +123 -0
- package/dist/ScrubNumber.d.ts +29 -0
- package/dist/ScrubNumber.js +152 -0
- package/dist/ShadowStack.d.ts +28 -0
- package/dist/ShadowStack.js +116 -0
- package/dist/SideRail.d.ts +43 -0
- package/dist/SideRail.js +253 -0
- package/dist/SignalText.d.ts +25 -0
- package/dist/SignalText.js +178 -0
- package/dist/SkeletonShimmer.d.ts +18 -0
- package/dist/SkeletonShimmer.js +111 -0
- package/dist/SketchHighlight.d.ts +27 -0
- package/dist/SketchHighlight.js +180 -0
- package/dist/SlideTabs.d.ts +40 -0
- package/dist/SlideTabs.js +190 -0
- package/dist/SmartNavbar.d.ts +48 -0
- package/dist/SmartNavbar.js +188 -0
- package/dist/SparkChart.d.ts +41 -0
- package/dist/SparkChart.js +188 -0
- package/dist/Spoiler.d.ts +22 -0
- package/dist/Spoiler.js +97 -0
- package/dist/SpotlightTour.d.ts +38 -0
- package/dist/SpotlightTour.js +231 -0
- package/dist/SpringDrawer.d.ts +39 -0
- package/dist/SpringDrawer.js +360 -0
- package/dist/SpriteAnimator.d.ts +41 -0
- package/dist/SpriteAnimator.js +124 -0
- package/dist/StatCard.d.ts +43 -0
- package/dist/StatCard.js +168 -0
- package/dist/StepLoader.d.ts +41 -0
- package/dist/StepLoader.js +191 -0
- package/dist/StepperForm.d.ts +41 -0
- package/dist/StepperForm.js +206 -0
- package/dist/StickerBoard.d.ts +39 -0
- package/dist/StickerBoard.js +209 -0
- package/dist/StickyReveal.d.ts +42 -0
- package/dist/StickyReveal.js +181 -0
- package/dist/StoryViewer.d.ts +36 -0
- package/dist/StoryViewer.js +175 -0
- package/dist/StreamingText.d.ts +29 -0
- package/dist/StreamingText.js +271 -0
- package/dist/SuggestionChips.d.ts +32 -0
- package/dist/SuggestionChips.js +96 -0
- package/dist/SwipeActions.d.ts +30 -0
- package/dist/SwipeActions.js +141 -0
- package/dist/TagInput.d.ts +30 -0
- package/dist/TagInput.js +284 -0
- package/dist/TallyUp.d.ts +38 -0
- package/dist/TallyUp.js +157 -0
- package/dist/TerminalDemo.d.ts +63 -0
- package/dist/TerminalDemo.js +214 -0
- package/dist/TestimonialWall.d.ts +35 -0
- package/dist/TestimonialWall.js +131 -0
- package/dist/TextOnPath.d.ts +36 -0
- package/dist/TextOnPath.js +130 -0
- package/dist/ThinkingShimmer.d.ts +36 -0
- package/dist/ThinkingShimmer.js +132 -0
- package/dist/ToastStack.d.ts +62 -0
- package/dist/ToastStack.js +289 -0
- package/dist/ToggleGroup.d.ts +39 -0
- package/dist/ToggleGroup.js +190 -0
- package/dist/ToggleKit.d.ts +70 -0
- package/dist/ToggleKit.js +229 -0
- package/dist/TracingLine.d.ts +24 -0
- package/dist/TracingLine.js +139 -0
- package/dist/TradingCard.d.ts +30 -0
- package/dist/TradingCard.js +147 -0
- package/dist/VanishInput.d.ts +34 -0
- package/dist/VanishInput.js +190 -0
- package/dist/VideoHero.d.ts +32 -0
- package/dist/VideoHero.js +207 -0
- package/dist/VoiceOrb.d.ts +23 -0
- package/dist/VoiceOrb.js +182 -0
- package/dist/VoxelTiles.d.ts +38 -0
- package/dist/VoxelTiles.js +201 -0
- package/dist/WarpField.d.ts +18 -0
- package/dist/WarpField.js +160 -0
- package/dist/WebcamPixels.d.ts +38 -0
- package/dist/WebcamPixels.js +292 -0
- package/dist/WheelPicker.d.ts +29 -0
- package/dist/WheelPicker.js +199 -0
- package/dist/WobbleCard.d.ts +23 -0
- package/dist/WobbleCard.js +112 -0
- package/dist/index.d.ts +158 -0
- package/dist/index.js +159 -0
- package/package.json +58 -4
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useId, useInsertionEffect, useRef, useState } from "react";
|
|
4
|
+
const STYLE_ID = "bl-thinking";
|
|
5
|
+
const CSS = `
|
|
6
|
+
.bl-think { width: 100%; max-width: var(--bl-w); color: var(--bl-ink); font-family: var(--bl-font); font-size: 14px; }
|
|
7
|
+
.bl-think__head { display: inline-flex; align-items: center; gap: 8px; padding: 6px 10px 6px 8px; margin-left: -8px; border: 0; border-radius: 8px; background: transparent; color: var(--bl-muted); font: inherit; cursor: pointer; }
|
|
8
|
+
.bl-think__head:hover { background: var(--bl-hover); color: var(--bl-ink); }
|
|
9
|
+
.bl-think__head:focus-visible { outline: 2px solid var(--bl-accent); outline-offset: 1px; }
|
|
10
|
+
.bl-think__shine { background: linear-gradient(90deg, var(--bl-muted) 0%, var(--bl-muted) 35%, var(--bl-shine) 50%, var(--bl-muted) 65%, var(--bl-muted) 100%); background-size: 250% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; animation: bl-think-shine var(--bl-speed) linear infinite; }
|
|
11
|
+
.bl-think__time { font-variant-numeric: tabular-nums; opacity: 0.8; }
|
|
12
|
+
.bl-think__chev { transition: transform 220ms cubic-bezier(.2,.9,.25,1); }
|
|
13
|
+
.bl-think__head[aria-expanded="true"] .bl-think__chev { transform: rotate(90deg); }
|
|
14
|
+
.bl-think__panel { display: grid; grid-template-rows: 0fr; transition: grid-template-rows 320ms cubic-bezier(.2,.9,.25,1); }
|
|
15
|
+
.bl-think__panel[data-open] { grid-template-rows: 1fr; }
|
|
16
|
+
.bl-think__panel > div { overflow: hidden; }
|
|
17
|
+
.bl-think__steps { margin: 6px 0 4px 4px; padding: 0 0 0 16px; border-left: 2px solid var(--bl-line); list-style: none; }
|
|
18
|
+
.bl-think__step { position: relative; display: grid; grid-template-columns: 18px 1fr; gap: 10px; padding: 6px 0; }
|
|
19
|
+
.bl-think__icon { display: grid; place-items: center; width: 18px; height: 18px; margin-top: 1px; color: var(--bl-muted); }
|
|
20
|
+
.bl-think__step[data-status="done"] .bl-think__icon { color: var(--bl-success); }
|
|
21
|
+
.bl-think__step[data-status="active"] .bl-think__icon { color: var(--bl-accent); }
|
|
22
|
+
.bl-think__step[data-status="pending"] { opacity: 0.55; }
|
|
23
|
+
.bl-think__label { line-height: 1.45; }
|
|
24
|
+
.bl-think__detail { display: block; margin-top: 2px; color: var(--bl-muted); font-size: 13px; line-height: 1.5; }
|
|
25
|
+
.bl-think__spin { width: 13px; height: 13px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: bl-think-spin 800ms linear infinite; }
|
|
26
|
+
.bl-think__dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
|
|
27
|
+
.bl-think__sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
|
|
28
|
+
@keyframes bl-think-shine { from { background-position: 100% 0; } to { background-position: -150% 0; } }
|
|
29
|
+
@keyframes bl-think-spin { to { transform: rotate(360deg); } }
|
|
30
|
+
@media (prefers-reduced-motion: reduce) { .bl-think__shine { animation: none; color: var(--bl-muted); background: none; } .bl-think__panel, .bl-think__chev { transition: none; } .bl-think__spin { animation-duration: 2.4s; } }
|
|
31
|
+
`;
|
|
32
|
+
function useStyles() {
|
|
33
|
+
useInsertionEffect(() => {
|
|
34
|
+
if (typeof document === "undefined") return;
|
|
35
|
+
const style = document.getElementById(STYLE_ID) ?? Object.assign(document.createElement("style"), { id: STYLE_ID });
|
|
36
|
+
style.textContent = CSS;
|
|
37
|
+
if (!style.isConnected) document.head.appendChild(style);
|
|
38
|
+
}, []);
|
|
39
|
+
}
|
|
40
|
+
const formatSeconds = (seconds) => seconds < 60 ? `${seconds}s` : `${Math.floor(seconds / 60)}m ${seconds % 60}s`;
|
|
41
|
+
function ThinkingShimmer({
|
|
42
|
+
thinking = true,
|
|
43
|
+
steps = [],
|
|
44
|
+
label = "Thinking",
|
|
45
|
+
doneLabel = (seconds) => `Thought for ${formatSeconds(seconds)}`,
|
|
46
|
+
startedAt,
|
|
47
|
+
showTimer = true,
|
|
48
|
+
defaultOpen = false,
|
|
49
|
+
open: controlledOpen,
|
|
50
|
+
onOpenChange,
|
|
51
|
+
shimmerSpeed = 1800,
|
|
52
|
+
width = 560,
|
|
53
|
+
textColor = "#f4f4f4",
|
|
54
|
+
mutedColor = "#94b0c2",
|
|
55
|
+
shineColor = "#f4f4f4",
|
|
56
|
+
lineColor = "rgba(255,255,255,0.12)",
|
|
57
|
+
hoverColor = "rgba(255,255,255,0.06)",
|
|
58
|
+
accentColor = "#73eff7",
|
|
59
|
+
successColor = "#38b764",
|
|
60
|
+
fontFamily = "ui-sans-serif, system-ui, sans-serif",
|
|
61
|
+
className = "",
|
|
62
|
+
style
|
|
63
|
+
}) {
|
|
64
|
+
useStyles();
|
|
65
|
+
const uid = useId().replace(/[^a-zA-Z0-9_-]/g, "");
|
|
66
|
+
const [innerOpen, setInnerOpen] = useState(defaultOpen);
|
|
67
|
+
const open = controlledOpen ?? innerOpen;
|
|
68
|
+
const began = useRef(startedAt ?? Date.now());
|
|
69
|
+
const [elapsed, setElapsed] = useState(0);
|
|
70
|
+
const [final, setFinal] = useState(null);
|
|
71
|
+
useEffect(() => {
|
|
72
|
+
if (startedAt) began.current = startedAt;
|
|
73
|
+
}, [startedAt]);
|
|
74
|
+
useEffect(() => {
|
|
75
|
+
if (!thinking) {
|
|
76
|
+
setFinal(Math.max(1, Math.round((Date.now() - began.current) / 1e3)));
|
|
77
|
+
return void 0;
|
|
78
|
+
}
|
|
79
|
+
if (final !== null) {
|
|
80
|
+
began.current = startedAt ?? Date.now();
|
|
81
|
+
setFinal(null);
|
|
82
|
+
}
|
|
83
|
+
const tick = () => setElapsed(Math.floor((Date.now() - began.current) / 1e3));
|
|
84
|
+
tick();
|
|
85
|
+
const timer = setInterval(tick, 1e3);
|
|
86
|
+
return () => clearInterval(timer);
|
|
87
|
+
}, [thinking]);
|
|
88
|
+
const toggle = () => {
|
|
89
|
+
if (controlledOpen === void 0) setInnerOpen((o) => !o);
|
|
90
|
+
onOpenChange?.(!open);
|
|
91
|
+
};
|
|
92
|
+
const icon = (status) => status === "done" ? /* @__PURE__ */ jsx("svg", { width: "14", height: "14", viewBox: "0 0 14 14", fill: "none", stroke: "currentColor", strokeWidth: "2.2", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ jsx("path", { d: "M2.5 7.5 5.5 10.5 11.5 3.5" }) }) : status === "active" ? /* @__PURE__ */ jsx("span", { className: "bl-think__spin" }) : /* @__PURE__ */ jsx("span", { className: "bl-think__dot" });
|
|
93
|
+
const headText = thinking ? `${label}\u2026` : doneLabel(final ?? elapsed);
|
|
94
|
+
return /* @__PURE__ */ jsxs(
|
|
95
|
+
"div",
|
|
96
|
+
{
|
|
97
|
+
className: `bl-think ${className}`,
|
|
98
|
+
style: {
|
|
99
|
+
"--bl-w": `${width}px`,
|
|
100
|
+
"--bl-ink": textColor,
|
|
101
|
+
"--bl-muted": mutedColor,
|
|
102
|
+
"--bl-shine": shineColor,
|
|
103
|
+
"--bl-line": lineColor,
|
|
104
|
+
"--bl-hover": hoverColor,
|
|
105
|
+
"--bl-accent": accentColor,
|
|
106
|
+
"--bl-success": successColor,
|
|
107
|
+
"--bl-speed": `${shimmerSpeed}ms`,
|
|
108
|
+
"--bl-font": fontFamily,
|
|
109
|
+
...style
|
|
110
|
+
},
|
|
111
|
+
children: [
|
|
112
|
+
/* @__PURE__ */ jsxs("button", { type: "button", className: "bl-think__head", "aria-expanded": open, "aria-controls": `${uid}-steps`, onClick: toggle, disabled: !steps.length, children: [
|
|
113
|
+
/* @__PURE__ */ jsx("svg", { className: "bl-think__chev", width: "12", height: "12", viewBox: "0 0 12 12", fill: "none", stroke: "currentColor", strokeWidth: "1.8", strokeLinecap: "round", "aria-hidden": "true", style: { opacity: steps.length ? 1 : 0 }, children: /* @__PURE__ */ jsx("path", { d: "M4.5 2.5 8 6l-3.5 3.5" }) }),
|
|
114
|
+
/* @__PURE__ */ jsx("span", { className: thinking ? "bl-think__shine" : void 0, children: headText }),
|
|
115
|
+
thinking && showTimer && /* @__PURE__ */ jsx("span", { className: "bl-think__time", children: formatSeconds(elapsed) })
|
|
116
|
+
] }),
|
|
117
|
+
/* @__PURE__ */ jsx("div", { id: `${uid}-steps`, className: "bl-think__panel", "data-open": open || void 0, inert: !open || void 0, children: /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx("ol", { className: "bl-think__steps", children: steps.map((step, i) => /* @__PURE__ */ jsxs("li", { className: "bl-think__step", "data-status": step.status ?? "pending", children: [
|
|
118
|
+
/* @__PURE__ */ jsx("span", { className: "bl-think__icon", "aria-hidden": "true", children: icon(step.status ?? "pending") }),
|
|
119
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
120
|
+
/* @__PURE__ */ jsx("span", { className: `bl-think__label ${step.status === "active" ? "bl-think__shine" : ""}`, children: step.label }),
|
|
121
|
+
/* @__PURE__ */ jsx("span", { className: "bl-think__sr", children: step.status === "done" ? " (done)" : step.status === "active" ? " (in progress)" : " (waiting)" }),
|
|
122
|
+
step.detail && /* @__PURE__ */ jsx("span", { className: "bl-think__detail", children: step.detail })
|
|
123
|
+
] })
|
|
124
|
+
] }, step.id ?? i)) }) }) }),
|
|
125
|
+
/* @__PURE__ */ jsx("span", { className: "bl-think__sr", role: "status", children: thinking ? "" : doneLabel(final ?? elapsed) })
|
|
126
|
+
]
|
|
127
|
+
}
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
export {
|
|
131
|
+
ThinkingShimmer as default
|
|
132
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { type CSSProperties, type ReactNode } from 'react';
|
|
2
|
+
export type ToastType = 'default' | 'success' | 'error' | 'info' | 'loading';
|
|
3
|
+
export interface ToastOptions {
|
|
4
|
+
/** Pass an existing id to update that toast in place. */
|
|
5
|
+
id?: number;
|
|
6
|
+
description?: ReactNode;
|
|
7
|
+
icon?: ReactNode;
|
|
8
|
+
/** Time on screen, in ms (Infinity to stay until dismissed). */
|
|
9
|
+
duration?: number;
|
|
10
|
+
/** A button on the toast; clicking it also dismisses the toast. */
|
|
11
|
+
action?: {
|
|
12
|
+
label: ReactNode;
|
|
13
|
+
onClick?: () => void;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export interface ToastData extends ToastOptions {
|
|
17
|
+
title?: ReactNode;
|
|
18
|
+
type?: ToastType;
|
|
19
|
+
}
|
|
20
|
+
export interface PromiseMessages<T> {
|
|
21
|
+
loading?: ReactNode;
|
|
22
|
+
success?: ReactNode | ((value: T) => ReactNode);
|
|
23
|
+
error?: ReactNode | ((error: unknown) => ReactNode);
|
|
24
|
+
}
|
|
25
|
+
/** Shows a toast; returns its id. Pass a title (any node) and options, or one ToastData object. */
|
|
26
|
+
export declare function toast(message: ReactNode | ToastData, options?: ToastOptions): number;
|
|
27
|
+
export declare namespace toast {
|
|
28
|
+
var success: (message: ReactNode | ToastData, options?: ToastOptions) => number;
|
|
29
|
+
var error: (message: ReactNode | ToastData, options?: ToastOptions) => number;
|
|
30
|
+
var info: (message: ReactNode | ToastData, options?: ToastOptions) => number;
|
|
31
|
+
var loading: (message: ReactNode | ToastData, options?: ToastOptions) => number;
|
|
32
|
+
var dismiss: (id?: number) => void;
|
|
33
|
+
var promise: <T>(promise: Promise<T> | T, messages: PromiseMessages<T>) => number;
|
|
34
|
+
}
|
|
35
|
+
export interface ToasterProps {
|
|
36
|
+
position?: 'bottom-right' | 'bottom-center' | 'bottom-left' | 'top-right' | 'top-center' | 'top-left';
|
|
37
|
+
/** Default time on screen, in ms. */
|
|
38
|
+
duration?: number;
|
|
39
|
+
/** How many show when stacked. */
|
|
40
|
+
visibleToasts?: number;
|
|
41
|
+
/** Always fan out instead of stacking. */
|
|
42
|
+
expand?: boolean;
|
|
43
|
+
gap?: number;
|
|
44
|
+
width?: number;
|
|
45
|
+
/** Distance from the edges, in px. */
|
|
46
|
+
offset?: number;
|
|
47
|
+
/** Position inside the nearest positioned parent instead of the window. */
|
|
48
|
+
contained?: boolean;
|
|
49
|
+
radius?: number;
|
|
50
|
+
backgroundColor?: string;
|
|
51
|
+
textColor?: string;
|
|
52
|
+
mutedColor?: string;
|
|
53
|
+
lineColor?: string;
|
|
54
|
+
accentColor?: string;
|
|
55
|
+
successColor?: string;
|
|
56
|
+
errorColor?: string;
|
|
57
|
+
infoColor?: string;
|
|
58
|
+
fontFamily?: string;
|
|
59
|
+
className?: string;
|
|
60
|
+
style?: CSSProperties;
|
|
61
|
+
}
|
|
62
|
+
export default function Toaster({ position, duration, visibleToasts, expand, gap, width, offset, contained, radius, backgroundColor, textColor, mutedColor, lineColor, accentColor, successColor, errorColor, infoColor, fontFamily, className, style }: ToasterProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useInsertionEffect, useLayoutEffect, useRef, useState, useSyncExternalStore } from "react";
|
|
4
|
+
const STYLE_ID = "bl-toast-stack";
|
|
5
|
+
const CSS = `
|
|
6
|
+
.bl-toaster { position: fixed; z-index: 1100; width: var(--bl-w); max-width: calc(100% - 32px); margin: 0; padding: 0; list-style: none; font-family: var(--bl-font); pointer-events: none; }
|
|
7
|
+
.bl-toaster[data-contained] { position: absolute; }
|
|
8
|
+
.bl-toaster[data-y="bottom"] { bottom: var(--bl-offset); }
|
|
9
|
+
.bl-toaster[data-y="top"] { top: var(--bl-offset); }
|
|
10
|
+
.bl-toaster[data-x="right"] { right: var(--bl-offset); }
|
|
11
|
+
.bl-toaster[data-x="left"] { left: var(--bl-offset); }
|
|
12
|
+
.bl-toaster[data-x="center"] { left: 50%; transform: translateX(-50%); }
|
|
13
|
+
.bl-toast { position: absolute; left: 0; right: 0; display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: var(--bl-radius); background: var(--bl-bg); color: var(--bl-ink); box-shadow: inset 0 0 0 1px var(--bl-line), 0 10px 30px -12px rgba(0,0,0,0.6); pointer-events: auto; touch-action: pan-y; user-select: none; transition: transform 380ms cubic-bezier(.2,.9,.25,1), opacity 380ms, height 380ms; will-change: transform; overflow: hidden; }
|
|
14
|
+
.bl-toaster[data-y="bottom"] .bl-toast { bottom: 0; transform-origin: 50% 100%; }
|
|
15
|
+
.bl-toaster[data-y="top"] .bl-toast { top: 0; transform-origin: 50% 0; }
|
|
16
|
+
.bl-toast[data-swiping] { transition: none; }
|
|
17
|
+
.bl-toast__icon { flex: 0 0 auto; display: grid; place-items: center; width: 22px; height: 22px; margin-top: 1px; border-radius: var(--bl-icon-radius); color: var(--bl-bg); font-size: 13px; font-weight: 800; }
|
|
18
|
+
.bl-toast__text { flex: 1; min-width: 0; }
|
|
19
|
+
.bl-toast__title { font-weight: 650; line-height: 1.35; }
|
|
20
|
+
.bl-toast__desc { margin-top: 3px; color: var(--bl-muted); font-size: 0.9em; line-height: 1.4; }
|
|
21
|
+
.bl-toast__action { flex: 0 0 auto; align-self: center; padding: 6px 10px; border: 0; border-radius: calc(var(--bl-radius) * 0.6); background: var(--bl-accent); color: var(--bl-bg); font: inherit; font-size: 0.85em; font-weight: 700; cursor: pointer; }
|
|
22
|
+
.bl-toast__close { flex: 0 0 auto; display: grid; place-items: center; width: 22px; height: 22px; border: 0; border-radius: 50%; background: transparent; color: var(--bl-muted); cursor: pointer; opacity: 0; transition: opacity 150ms; }
|
|
23
|
+
.bl-toast:hover .bl-toast__close, .bl-toast:focus-within .bl-toast__close { opacity: 1; }
|
|
24
|
+
.bl-toast button:focus-visible { outline: 2px solid var(--bl-accent); outline-offset: 2px; opacity: 1; }
|
|
25
|
+
.bl-toast__spinner { width: 16px; height: 16px; border: 2px solid var(--bl-line); border-top-color: var(--bl-accent); border-radius: 50%; animation: bl-toast-spin 700ms linear infinite; }
|
|
26
|
+
@keyframes bl-toast-spin { to { transform: rotate(360deg); } }
|
|
27
|
+
@media (prefers-reduced-motion: reduce) { .bl-toast { transition: opacity 200ms; } .bl-toast__spinner { animation-duration: 2s; } }
|
|
28
|
+
`;
|
|
29
|
+
function useStyles() {
|
|
30
|
+
useInsertionEffect(() => {
|
|
31
|
+
if (typeof document === "undefined") return;
|
|
32
|
+
const style = document.getElementById(STYLE_ID) ?? Object.assign(document.createElement("style"), { id: STYLE_ID });
|
|
33
|
+
style.textContent = CSS;
|
|
34
|
+
if (!style.isConnected) document.head.appendChild(style);
|
|
35
|
+
}, []);
|
|
36
|
+
}
|
|
37
|
+
let toasts = [];
|
|
38
|
+
let nextId = 1;
|
|
39
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
40
|
+
const emit = () => listeners.forEach((listener) => listener());
|
|
41
|
+
const subscribe = (listener) => {
|
|
42
|
+
listeners.add(listener);
|
|
43
|
+
return () => listeners.delete(listener);
|
|
44
|
+
};
|
|
45
|
+
const getSnapshot = () => toasts;
|
|
46
|
+
function upsert(data) {
|
|
47
|
+
const id = data.id ?? nextId++;
|
|
48
|
+
const existing = toasts.find((t) => t.id === id);
|
|
49
|
+
toasts = existing ? toasts.map((t) => t.id === id ? { ...t, ...data, id, updated: Date.now() } : t) : [{ type: "default", ...data, id, created: Date.now() }, ...toasts];
|
|
50
|
+
emit();
|
|
51
|
+
return id;
|
|
52
|
+
}
|
|
53
|
+
const normalize = (message, options) => typeof message === "object" && message !== null && !Array.isArray(message) && !message.$$typeof ? message : { title: message, ...options };
|
|
54
|
+
function toast(message, options) {
|
|
55
|
+
return upsert(normalize(message, options));
|
|
56
|
+
}
|
|
57
|
+
toast.success = (message, options) => upsert({ ...normalize(message, options), type: "success" });
|
|
58
|
+
toast.error = (message, options) => upsert({ ...normalize(message, options), type: "error" });
|
|
59
|
+
toast.info = (message, options) => upsert({ ...normalize(message, options), type: "info" });
|
|
60
|
+
toast.loading = (message, options) => upsert({ ...normalize(message, options), type: "loading" });
|
|
61
|
+
toast.dismiss = (id) => {
|
|
62
|
+
toasts = id == null ? toasts.map((t) => ({ ...t, leaving: true })) : toasts.map((t) => t.id === id ? { ...t, leaving: true } : t);
|
|
63
|
+
emit();
|
|
64
|
+
};
|
|
65
|
+
toast.promise = (promise, messages) => {
|
|
66
|
+
const id = upsert({ type: "loading", title: messages.loading ?? "Loading\u2026" });
|
|
67
|
+
const resolve = (value, key, type) => {
|
|
68
|
+
const message = typeof messages[key] === "function" ? messages[key](value) : messages[key];
|
|
69
|
+
upsert({ id, type, title: message ?? (type === "success" ? "Done" : "Something went wrong") });
|
|
70
|
+
};
|
|
71
|
+
Promise.resolve(promise).then(
|
|
72
|
+
(value) => resolve(value, "success", "success"),
|
|
73
|
+
(error) => resolve(error, "error", "error")
|
|
74
|
+
);
|
|
75
|
+
return id;
|
|
76
|
+
};
|
|
77
|
+
const remove = (id) => {
|
|
78
|
+
toasts = toasts.filter((t) => t.id !== id);
|
|
79
|
+
emit();
|
|
80
|
+
};
|
|
81
|
+
const ICONS = { success: "\u2713", error: "!", info: "i" };
|
|
82
|
+
function ToastItem({ item, index, expanded, offset, frontHeight, setHeight, duration, gap, colors, y, visibleCount, paused }) {
|
|
83
|
+
const ref = useRef(null);
|
|
84
|
+
const [mounted, setMounted] = useState(false);
|
|
85
|
+
const [swipe, setSwipe] = useState(0);
|
|
86
|
+
const drag = useRef(null);
|
|
87
|
+
const remaining = useRef(item.duration ?? duration);
|
|
88
|
+
const started = useRef(0);
|
|
89
|
+
useLayoutEffect(() => {
|
|
90
|
+
const el = ref.current;
|
|
91
|
+
const prev = el.style.height;
|
|
92
|
+
el.style.height = "auto";
|
|
93
|
+
setHeight(item.id, el.getBoundingClientRect().height);
|
|
94
|
+
el.style.height = prev;
|
|
95
|
+
});
|
|
96
|
+
useEffect(() => {
|
|
97
|
+
const frame = requestAnimationFrame(() => setMounted(true));
|
|
98
|
+
return () => cancelAnimationFrame(frame);
|
|
99
|
+
}, []);
|
|
100
|
+
useEffect(() => {
|
|
101
|
+
remaining.current = item.duration ?? duration;
|
|
102
|
+
}, [item.updated, item.duration, duration]);
|
|
103
|
+
useEffect(() => {
|
|
104
|
+
if (item.leaving) {
|
|
105
|
+
const timer2 = setTimeout(() => remove(item.id), 320);
|
|
106
|
+
return () => clearTimeout(timer2);
|
|
107
|
+
}
|
|
108
|
+
if (item.type === "loading" || paused || remaining.current === Infinity) return;
|
|
109
|
+
started.current = Date.now();
|
|
110
|
+
const timer = setTimeout(() => toast.dismiss(item.id), remaining.current);
|
|
111
|
+
return () => {
|
|
112
|
+
clearTimeout(timer);
|
|
113
|
+
remaining.current -= Date.now() - started.current;
|
|
114
|
+
};
|
|
115
|
+
}, [paused, item.leaving, item.type, item.updated, item.id]);
|
|
116
|
+
const onPointerDown = (event) => {
|
|
117
|
+
if (event.target.closest("button")) return;
|
|
118
|
+
drag.current = { x: event.clientX, t: performance.now() };
|
|
119
|
+
try {
|
|
120
|
+
ref.current.setPointerCapture(event.pointerId);
|
|
121
|
+
} catch {
|
|
122
|
+
}
|
|
123
|
+
ref.current.setAttribute("data-swiping", "");
|
|
124
|
+
};
|
|
125
|
+
const onPointerMove = (event) => {
|
|
126
|
+
if (drag.current) setSwipe(event.clientX - drag.current.x);
|
|
127
|
+
};
|
|
128
|
+
const onPointerUp = (event) => {
|
|
129
|
+
if (!drag.current) return;
|
|
130
|
+
const dx = event.clientX - drag.current.x;
|
|
131
|
+
const velocity = Math.abs(dx) / Math.max(1, performance.now() - drag.current.t);
|
|
132
|
+
drag.current = null;
|
|
133
|
+
ref.current.removeAttribute("data-swiping");
|
|
134
|
+
if (Math.abs(dx) > 90 || velocity > 0.6) {
|
|
135
|
+
setSwipe(Math.sign(dx || 1) * (ref.current.offsetWidth + 40));
|
|
136
|
+
toast.dismiss(item.id);
|
|
137
|
+
} else setSwipe(0);
|
|
138
|
+
};
|
|
139
|
+
const dir = y === "bottom" ? -1 : 1;
|
|
140
|
+
const hiddenBehind = index >= visibleCount;
|
|
141
|
+
const entering = !mounted;
|
|
142
|
+
const translateY = entering ? -dir * 24 : expanded ? dir * offset : dir * index * gap;
|
|
143
|
+
const scale = expanded || entering ? 1 : Math.max(0, 1 - index * 0.06);
|
|
144
|
+
const opacity = entering || item.leaving || hiddenBehind ? 0 : 1;
|
|
145
|
+
const accent = { success: colors.success, error: colors.error, info: colors.info }[item.type];
|
|
146
|
+
return /* @__PURE__ */ jsxs(
|
|
147
|
+
"li",
|
|
148
|
+
{
|
|
149
|
+
ref,
|
|
150
|
+
className: "bl-toast",
|
|
151
|
+
"data-type": item.type,
|
|
152
|
+
role: item.type === "error" ? "alert" : "status",
|
|
153
|
+
"aria-live": item.type === "error" ? "assertive" : "polite",
|
|
154
|
+
"aria-atomic": "true",
|
|
155
|
+
onPointerDown,
|
|
156
|
+
onPointerMove,
|
|
157
|
+
onPointerUp,
|
|
158
|
+
onPointerCancel: onPointerUp,
|
|
159
|
+
style: {
|
|
160
|
+
zIndex: 100 - index,
|
|
161
|
+
height: !expanded && index > 0 ? frontHeight : void 0,
|
|
162
|
+
opacity: swipe ? Math.max(0, 1 - Math.abs(swipe) / 260) * opacity : opacity,
|
|
163
|
+
transform: `translate(${swipe}px, ${translateY + (item.leaving && !swipe ? -dir * 12 : 0)}px) scale(${scale})`,
|
|
164
|
+
pointerEvents: hiddenBehind || item.leaving ? "none" : void 0
|
|
165
|
+
},
|
|
166
|
+
children: [
|
|
167
|
+
item.type === "loading" ? /* @__PURE__ */ jsx("span", { className: "bl-toast__spinner", "aria-hidden": "true" }) : accent && /* @__PURE__ */ jsx("span", { className: "bl-toast__icon", style: { background: accent }, "aria-hidden": "true", children: item.icon ?? ICONS[item.type] }),
|
|
168
|
+
item.type === "default" && item.icon && /* @__PURE__ */ jsx("span", { className: "bl-toast__icon", "aria-hidden": "true", children: item.icon }),
|
|
169
|
+
/* @__PURE__ */ jsxs("div", { className: "bl-toast__text", children: [
|
|
170
|
+
/* @__PURE__ */ jsx("div", { className: "bl-toast__title", children: item.title }),
|
|
171
|
+
item.description && /* @__PURE__ */ jsx("div", { className: "bl-toast__desc", children: item.description })
|
|
172
|
+
] }),
|
|
173
|
+
item.action && /* @__PURE__ */ jsx(
|
|
174
|
+
"button",
|
|
175
|
+
{
|
|
176
|
+
type: "button",
|
|
177
|
+
className: "bl-toast__action",
|
|
178
|
+
onClick: () => {
|
|
179
|
+
item.action.onClick?.();
|
|
180
|
+
toast.dismiss(item.id);
|
|
181
|
+
},
|
|
182
|
+
children: item.action.label
|
|
183
|
+
}
|
|
184
|
+
),
|
|
185
|
+
/* @__PURE__ */ jsx("button", { type: "button", className: "bl-toast__close", "aria-label": "Dismiss notification", onClick: () => toast.dismiss(item.id), children: /* @__PURE__ */ jsx("svg", { width: "10", height: "10", viewBox: "0 0 10 10", stroke: "currentColor", strokeWidth: "1.8", "aria-hidden": "true", children: /* @__PURE__ */ jsx("path", { d: "M1 1l8 8M9 1 1 9" }) }) })
|
|
186
|
+
]
|
|
187
|
+
}
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
function Toaster({
|
|
191
|
+
position = "bottom-right",
|
|
192
|
+
duration = 4e3,
|
|
193
|
+
visibleToasts = 3,
|
|
194
|
+
expand = false,
|
|
195
|
+
gap = 10,
|
|
196
|
+
width = 360,
|
|
197
|
+
offset = 24,
|
|
198
|
+
contained = false,
|
|
199
|
+
radius = 12,
|
|
200
|
+
backgroundColor = "#1a1c2c",
|
|
201
|
+
textColor = "#f4f4f4",
|
|
202
|
+
mutedColor = "#94b0c2",
|
|
203
|
+
lineColor = "rgba(255,255,255,0.12)",
|
|
204
|
+
accentColor = "#73eff7",
|
|
205
|
+
successColor = "#38b764",
|
|
206
|
+
errorColor = "#b13e53",
|
|
207
|
+
infoColor = "#41a6f6",
|
|
208
|
+
fontFamily = "ui-sans-serif, system-ui, sans-serif",
|
|
209
|
+
className = "",
|
|
210
|
+
style
|
|
211
|
+
}) {
|
|
212
|
+
useStyles();
|
|
213
|
+
const items = useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
|
|
214
|
+
const [heights, setHeights] = useState({});
|
|
215
|
+
const [hovered, setHovered] = useState(false);
|
|
216
|
+
const [focused, setFocused] = useState(false);
|
|
217
|
+
const [hidden, setHidden] = useState(false);
|
|
218
|
+
const [y, x] = position.split("-");
|
|
219
|
+
useEffect(() => {
|
|
220
|
+
const onVisibility = () => setHidden(document.hidden);
|
|
221
|
+
document.addEventListener("visibilitychange", onVisibility);
|
|
222
|
+
return () => document.removeEventListener("visibilitychange", onVisibility);
|
|
223
|
+
}, []);
|
|
224
|
+
const setHeight = (id, h) => setHeights((prev) => prev[id] === h ? prev : { ...prev, [id]: h });
|
|
225
|
+
const live = items.filter((t) => !t.leaving);
|
|
226
|
+
const expanded = expand || hovered || focused;
|
|
227
|
+
const front = live[0] ?? items[0];
|
|
228
|
+
const frontHeight = front ? heights[front.id] : void 0;
|
|
229
|
+
let running = 0;
|
|
230
|
+
const offsets = {};
|
|
231
|
+
for (const item of items) {
|
|
232
|
+
offsets[item.id] = running;
|
|
233
|
+
if (!item.leaving) running += (heights[item.id] ?? 64) + gap;
|
|
234
|
+
}
|
|
235
|
+
const stackHeight = expanded ? running : (frontHeight ?? 64) + Math.min(live.length - 1, visibleToasts - 1) * gap;
|
|
236
|
+
return /* @__PURE__ */ jsx(
|
|
237
|
+
"ol",
|
|
238
|
+
{
|
|
239
|
+
className: `bl-toaster ${className}`,
|
|
240
|
+
"data-x": x ?? "right",
|
|
241
|
+
"data-y": y,
|
|
242
|
+
"data-contained": contained || void 0,
|
|
243
|
+
"aria-label": "Notifications",
|
|
244
|
+
onPointerEnter: (event) => event.pointerType === "mouse" && setHovered(true),
|
|
245
|
+
onPointerLeave: () => setHovered(false),
|
|
246
|
+
onFocus: () => setFocused(true),
|
|
247
|
+
onBlur: (event) => !event.currentTarget.contains(event.relatedTarget) && setFocused(false),
|
|
248
|
+
style: {
|
|
249
|
+
"--bl-w": `${width}px`,
|
|
250
|
+
"--bl-offset": `${offset}px`,
|
|
251
|
+
"--bl-radius": `${radius}px`,
|
|
252
|
+
"--bl-icon-radius": radius ? "50%" : "0",
|
|
253
|
+
"--bl-bg": backgroundColor,
|
|
254
|
+
"--bl-ink": textColor,
|
|
255
|
+
"--bl-muted": mutedColor,
|
|
256
|
+
"--bl-line": lineColor,
|
|
257
|
+
"--bl-accent": accentColor,
|
|
258
|
+
"--bl-font": fontFamily,
|
|
259
|
+
height: items.length ? stackHeight : 0,
|
|
260
|
+
...style
|
|
261
|
+
},
|
|
262
|
+
children: items.map((item) => {
|
|
263
|
+
const index = live.indexOf(item);
|
|
264
|
+
return /* @__PURE__ */ jsx(
|
|
265
|
+
ToastItem,
|
|
266
|
+
{
|
|
267
|
+
item,
|
|
268
|
+
index: index < 0 ? 0 : index,
|
|
269
|
+
expanded,
|
|
270
|
+
offset: offsets[item.id],
|
|
271
|
+
frontHeight,
|
|
272
|
+
setHeight,
|
|
273
|
+
duration,
|
|
274
|
+
gap,
|
|
275
|
+
y,
|
|
276
|
+
visibleCount: expanded ? Infinity : visibleToasts,
|
|
277
|
+
colors: { success: successColor, error: errorColor, info: infoColor },
|
|
278
|
+
paused: hovered || focused || hidden
|
|
279
|
+
},
|
|
280
|
+
item.id
|
|
281
|
+
);
|
|
282
|
+
})
|
|
283
|
+
}
|
|
284
|
+
);
|
|
285
|
+
}
|
|
286
|
+
export {
|
|
287
|
+
Toaster as default,
|
|
288
|
+
toast
|
|
289
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { type CSSProperties, type ReactNode } from 'react';
|
|
2
|
+
export interface ToggleItem {
|
|
3
|
+
value: string;
|
|
4
|
+
label?: ReactNode;
|
|
5
|
+
icon?: ReactNode;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
/** Accessible name for icon-only options. */
|
|
8
|
+
ariaLabel?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface ToggleGroupProps {
|
|
11
|
+
items?: ToggleItem[];
|
|
12
|
+
/** A radio group with a sliding thumb, or toggle buttons whose neighbouring selections fuse. */
|
|
13
|
+
type?: 'single' | 'multiple';
|
|
14
|
+
/** Controlled value: a string in single mode, a string[] (in item order) in multiple mode. */
|
|
15
|
+
value?: string | string[];
|
|
16
|
+
defaultValue?: string | string[];
|
|
17
|
+
onChange?: (value: string | string[]) => void;
|
|
18
|
+
/** Accessible name of the group. */
|
|
19
|
+
label?: string;
|
|
20
|
+
/** Stretch options to fill the row. */
|
|
21
|
+
fullWidth?: boolean;
|
|
22
|
+
size?: 'sm' | 'md' | 'lg';
|
|
23
|
+
/** Thumb slide length, in ms. */
|
|
24
|
+
duration?: number;
|
|
25
|
+
radius?: number;
|
|
26
|
+
gap?: number;
|
|
27
|
+
padding?: number;
|
|
28
|
+
trackColor?: string;
|
|
29
|
+
lineColor?: string;
|
|
30
|
+
thumbColor?: string;
|
|
31
|
+
thumbTextColor?: string;
|
|
32
|
+
textColor?: string;
|
|
33
|
+
mutedColor?: string;
|
|
34
|
+
accentColor?: string;
|
|
35
|
+
fontFamily?: string;
|
|
36
|
+
className?: string;
|
|
37
|
+
style?: CSSProperties;
|
|
38
|
+
}
|
|
39
|
+
export default function ToggleGroup({ items, type, value, defaultValue, onChange, label, fullWidth, size, duration, radius, gap, padding, trackColor, lineColor, thumbColor, thumbTextColor, textColor, mutedColor, accentColor, fontFamily, className, style }: ToggleGroupProps): import("react").JSX.Element;
|