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,148 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useInsertionEffect, useRef, useState } from "react";
|
|
4
|
+
const STYLE_ID = "bl-hotbar-dock";
|
|
5
|
+
const CSS = `
|
|
6
|
+
.bl-hotbar { display: inline-flex; align-items: flex-end; gap: var(--bl-gap); padding: var(--bl-pad); border-radius: var(--bl-radius); background: var(--bl-bg); box-shadow: 0 0 0 3px var(--bl-line), 0 12px 28px -14px rgba(0,0,0,0.85); font-family: var(--bl-font); }
|
|
7
|
+
.bl-hotbar__slot { --m: 1; position: relative; display: grid; place-items: center; width: var(--bl-slot); height: var(--bl-slot); padding: 0; border: 0; border-radius: 6px; background: var(--bl-slot-bg); color: var(--bl-ink); box-shadow: inset 0 0 0 2px rgba(0,0,0,0.35); cursor: pointer; transform: scale(var(--m)); transform-origin: 50% 100%; margin: 0 calc((var(--m) - 1) * var(--bl-slot) / 2); transition: transform 90ms linear, margin 90ms linear; }
|
|
8
|
+
.bl-hotbar__slot:hover { background: var(--bl-hover); }
|
|
9
|
+
.bl-hotbar__slot:focus-visible { outline: 2px solid var(--bl-accent); outline-offset: 3px; }
|
|
10
|
+
.bl-hotbar__slot[aria-pressed="true"] { background: var(--bl-hover); box-shadow: inset 0 0 0 2px rgba(0,0,0,0.35), 0 0 0 3px var(--bl-select), 0 0 0 5px rgba(0,0,0,0.6); }
|
|
11
|
+
.bl-hotbar__icon { display: grid; place-items: center; width: 70%; height: 70%; pointer-events: none; }
|
|
12
|
+
.bl-hotbar__icon > img, .bl-hotbar__icon > svg { display: block; width: 100%; height: 100%; image-rendering: pixelated; }
|
|
13
|
+
.bl-hotbar__key { position: absolute; top: 2px; left: 4px; color: var(--bl-muted); font-size: 9px; line-height: 1; pointer-events: none; }
|
|
14
|
+
.bl-hotbar__count { position: absolute; right: 3px; bottom: 2px; color: var(--bl-ink); font-size: 11px; font-weight: 700; line-height: 1; text-shadow: 1px 1px 0 #000; pointer-events: none; }
|
|
15
|
+
.bl-hotbar__tip { position: absolute; bottom: calc(100% + 8px); left: 50%; padding: 4px 8px; border-radius: 6px; background: var(--bl-tip); color: var(--bl-ink); font-size: 12px; white-space: nowrap; transform: translateX(-50%) scale(calc(1 / var(--m))); transform-origin: 50% 100%; opacity: 0; pointer-events: none; transition: opacity 120ms steps(2); }
|
|
16
|
+
.bl-hotbar__slot:hover .bl-hotbar__tip, .bl-hotbar__slot:focus-visible .bl-hotbar__tip { opacity: 1; }
|
|
17
|
+
@media (prefers-reduced-motion: reduce) { .bl-hotbar__slot { transition: none; } }
|
|
18
|
+
`;
|
|
19
|
+
function useStyles() {
|
|
20
|
+
useInsertionEffect(() => {
|
|
21
|
+
if (typeof document === "undefined") return;
|
|
22
|
+
const style = document.getElementById(STYLE_ID) ?? Object.assign(document.createElement("style"), { id: STYLE_ID });
|
|
23
|
+
style.textContent = CSS;
|
|
24
|
+
if (!style.isConnected) document.head.appendChild(style);
|
|
25
|
+
}, []);
|
|
26
|
+
}
|
|
27
|
+
function HotbarDock({
|
|
28
|
+
items = [],
|
|
29
|
+
value,
|
|
30
|
+
defaultValue,
|
|
31
|
+
onChange,
|
|
32
|
+
magnify = 1.5,
|
|
33
|
+
range = 110,
|
|
34
|
+
hotkeys = true,
|
|
35
|
+
wheel = true,
|
|
36
|
+
label = "Hotbar",
|
|
37
|
+
slotSize = 52,
|
|
38
|
+
gap = 6,
|
|
39
|
+
padding = 8,
|
|
40
|
+
radius = 10,
|
|
41
|
+
backgroundColor = "#1a1c2c",
|
|
42
|
+
slotColor = "#333c57",
|
|
43
|
+
hoverColor = "#3d4766",
|
|
44
|
+
textColor = "#f4f4f4",
|
|
45
|
+
mutedColor = "#94b0c2",
|
|
46
|
+
lineColor = "#0b0b14",
|
|
47
|
+
selectColor = "#f4f4f4",
|
|
48
|
+
accentColor = "#73eff7",
|
|
49
|
+
tooltipColor = "#0b0b14",
|
|
50
|
+
fontFamily = "inherit",
|
|
51
|
+
className = "",
|
|
52
|
+
style
|
|
53
|
+
}) {
|
|
54
|
+
useStyles();
|
|
55
|
+
const [inner, setInner] = useState(defaultValue ?? items[0]?.id);
|
|
56
|
+
const selected = value ?? inner;
|
|
57
|
+
const barRef = useRef(null);
|
|
58
|
+
const [focusIndex, setFocusIndex] = useState(() => Math.max(0, items.findIndex((item) => item.id === (value ?? defaultValue ?? items[0]?.id))));
|
|
59
|
+
const pick = (id) => {
|
|
60
|
+
if (id === selected) return;
|
|
61
|
+
if (value === void 0) setInner(id);
|
|
62
|
+
onChange?.(id, items.find((item) => item.id === id));
|
|
63
|
+
};
|
|
64
|
+
const pickRef = useRef(pick);
|
|
65
|
+
pickRef.current = pick;
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
if (!hotkeys) return void 0;
|
|
68
|
+
const onKey = (event) => {
|
|
69
|
+
const t = event.target;
|
|
70
|
+
if (event.metaKey || event.ctrlKey || event.altKey || t.isContentEditable || /^(INPUT|TEXTAREA|SELECT)$/.test(t.tagName)) return;
|
|
71
|
+
const n = Number(event.key);
|
|
72
|
+
if (n >= 1 && n <= Math.min(9, items.length)) pickRef.current(items[n - 1].id);
|
|
73
|
+
};
|
|
74
|
+
window.addEventListener("keydown", onKey);
|
|
75
|
+
return () => window.removeEventListener("keydown", onKey);
|
|
76
|
+
}, [hotkeys, items]);
|
|
77
|
+
useEffect(() => {
|
|
78
|
+
const bar = barRef.current;
|
|
79
|
+
const slots = () => [...bar.querySelectorAll(".bl-hotbar__slot")];
|
|
80
|
+
const reduced = window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;
|
|
81
|
+
const onMove = (event) => {
|
|
82
|
+
if (reduced) return;
|
|
83
|
+
slots().forEach((slot) => {
|
|
84
|
+
const r = slot.getBoundingClientRect();
|
|
85
|
+
const d = Math.abs(event.clientX - (r.left + r.width / 2));
|
|
86
|
+
const k = Math.max(0, 1 - d / range);
|
|
87
|
+
slot.style.setProperty("--m", (1 + (magnify - 1) * k * k * (3 - 2 * k)).toFixed(3));
|
|
88
|
+
});
|
|
89
|
+
};
|
|
90
|
+
const onLeave = () => slots().forEach((slot) => slot.style.setProperty("--m", "1"));
|
|
91
|
+
const onWheel = (event) => {
|
|
92
|
+
if (!wheel || !items.length) return;
|
|
93
|
+
event.preventDefault();
|
|
94
|
+
const step = Math.sign(event.deltaY || event.deltaX);
|
|
95
|
+
const at = Math.max(0, items.findIndex((item) => item.id === selected));
|
|
96
|
+
pickRef.current(items[(at + step + items.length) % items.length].id);
|
|
97
|
+
};
|
|
98
|
+
bar.addEventListener("pointermove", onMove);
|
|
99
|
+
bar.addEventListener("pointerleave", onLeave);
|
|
100
|
+
bar.addEventListener("wheel", onWheel, { passive: false });
|
|
101
|
+
return () => {
|
|
102
|
+
bar.removeEventListener("pointermove", onMove);
|
|
103
|
+
bar.removeEventListener("pointerleave", onLeave);
|
|
104
|
+
bar.removeEventListener("wheel", onWheel);
|
|
105
|
+
};
|
|
106
|
+
}, [magnify, range, wheel, items, selected]);
|
|
107
|
+
const onKeyDown = (event) => {
|
|
108
|
+
const moves = { ArrowRight: 1, ArrowLeft: -1, Home: -1e9, End: 1e9 };
|
|
109
|
+
if (moves[event.key] === void 0) return;
|
|
110
|
+
event.preventDefault();
|
|
111
|
+
const next = Math.max(0, Math.min(items.length - 1, focusIndex + moves[event.key]));
|
|
112
|
+
setFocusIndex(next);
|
|
113
|
+
barRef.current.querySelectorAll(".bl-hotbar__slot")[next]?.focus();
|
|
114
|
+
};
|
|
115
|
+
return /* @__PURE__ */ jsx(
|
|
116
|
+
"div",
|
|
117
|
+
{
|
|
118
|
+
ref: barRef,
|
|
119
|
+
className: `bl-hotbar ${className}`,
|
|
120
|
+
role: "toolbar",
|
|
121
|
+
"aria-label": label,
|
|
122
|
+
onKeyDown,
|
|
123
|
+
style: { "--bl-slot": `${slotSize}px`, "--bl-gap": `${gap}px`, "--bl-pad": `${padding}px`, "--bl-radius": `${radius}px`, "--bl-bg": backgroundColor, "--bl-slot-bg": slotColor, "--bl-hover": hoverColor, "--bl-ink": textColor, "--bl-muted": mutedColor, "--bl-line": lineColor, "--bl-select": selectColor, "--bl-accent": accentColor, "--bl-tip": tooltipColor, "--bl-font": fontFamily, ...style },
|
|
124
|
+
children: items.map((item, i) => /* @__PURE__ */ jsxs(
|
|
125
|
+
"button",
|
|
126
|
+
{
|
|
127
|
+
type: "button",
|
|
128
|
+
className: "bl-hotbar__slot",
|
|
129
|
+
"aria-pressed": item.id === selected,
|
|
130
|
+
"aria-label": `${item.label}${item.count != null ? `, ${item.count}` : ""}${hotkeys && i < 9 ? ` (key ${i + 1})` : ""}`,
|
|
131
|
+
tabIndex: i === focusIndex ? 0 : -1,
|
|
132
|
+
onFocus: () => setFocusIndex(i),
|
|
133
|
+
onClick: () => pick(item.id),
|
|
134
|
+
children: [
|
|
135
|
+
hotkeys && i < 9 && /* @__PURE__ */ jsx("span", { className: "bl-hotbar__key", "aria-hidden": "true", children: i + 1 }),
|
|
136
|
+
/* @__PURE__ */ jsx("span", { className: "bl-hotbar__icon", "aria-hidden": "true", children: item.icon }),
|
|
137
|
+
item.count != null && /* @__PURE__ */ jsx("span", { className: "bl-hotbar__count", "aria-hidden": "true", children: item.count }),
|
|
138
|
+
/* @__PURE__ */ jsx("span", { className: "bl-hotbar__tip", "aria-hidden": "true", children: item.label })
|
|
139
|
+
]
|
|
140
|
+
},
|
|
141
|
+
item.id
|
|
142
|
+
))
|
|
143
|
+
}
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
export {
|
|
147
|
+
HotbarDock as default
|
|
148
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type CSSProperties, type ElementType, type ReactNode } from 'react';
|
|
2
|
+
export interface InkTextProps {
|
|
3
|
+
/** The text (or pass children). */
|
|
4
|
+
text?: string;
|
|
5
|
+
children?: ReactNode;
|
|
6
|
+
as?: ElementType;
|
|
7
|
+
/** A sweeping glint, flowing colours, a hollow stroke that floods on hover, or a panning picture. */
|
|
8
|
+
fill?: 'shimmer' | 'gradient' | 'outline' | 'image';
|
|
9
|
+
/** Gradient colours. */
|
|
10
|
+
colors?: string[];
|
|
11
|
+
/** Hard 8-bit bands instead of a smooth blend. */
|
|
12
|
+
stepped?: boolean;
|
|
13
|
+
/** Shimmer base, and the outline colour. */
|
|
14
|
+
baseColor?: string;
|
|
15
|
+
glintColor?: string;
|
|
16
|
+
/** Picture for the image fill. */
|
|
17
|
+
image?: string;
|
|
18
|
+
pixelated?: boolean;
|
|
19
|
+
strokeWidth?: number;
|
|
20
|
+
/** Keep the outline flooded. */
|
|
21
|
+
filled?: boolean;
|
|
22
|
+
/** Seconds per shimmer, flow or pan cycle. */
|
|
23
|
+
speed?: number;
|
|
24
|
+
className?: string;
|
|
25
|
+
style?: CSSProperties;
|
|
26
|
+
}
|
|
27
|
+
export default function InkText({ text, children, as: Tag, fill, colors, stepped, baseColor, glintColor, image, pixelated, strokeWidth, filled, speed, className, style }: InkTextProps): import("react").JSX.Element;
|
package/dist/InkText.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useInsertionEffect } from "react";
|
|
4
|
+
const STYLE_ID = "bl-ink-text";
|
|
5
|
+
const CSS = `
|
|
6
|
+
@property --bl-ink-level { syntax: "<percentage>"; inherits: true; initial-value: 0%; }
|
|
7
|
+
.bl-ink { margin: 0; color: transparent; background-clip: text; -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-repeat: no-repeat; }
|
|
8
|
+
.bl-ink[data-fill="shimmer"] { background-image: linear-gradient(100deg, var(--bl-base) 0 40%, var(--bl-glint) 50%, var(--bl-base) 60% 100%); background-size: 250% 100%; animation: bl-ink-sweep var(--bl-speed) linear infinite; }
|
|
9
|
+
.bl-ink[data-fill="gradient"] { background-image: linear-gradient(90deg, var(--bl-stops)); background-size: 300% 100%; background-repeat: repeat; animation: bl-ink-flow var(--bl-speed) linear infinite; }
|
|
10
|
+
.bl-ink[data-fill="outline"] { --bl-ink-level: 0%; background-image: linear-gradient(to top, var(--bl-base) var(--bl-ink-level), transparent var(--bl-ink-level)); -webkit-text-stroke: var(--bl-stroke) var(--bl-base); transition: --bl-ink-level 600ms cubic-bezier(.3,.8,.3,1); }
|
|
11
|
+
.bl-ink[data-fill="outline"]:hover, .bl-ink[data-fill="outline"]:focus-visible, .bl-ink[data-fill="outline"][data-filled] { --bl-ink-level: 100%; }
|
|
12
|
+
.bl-ink[data-fill="image"] { background-image: var(--bl-image); background-size: cover; background-position: 0% 50%; animation: bl-ink-pan var(--bl-speed) ease-in-out infinite alternate; }
|
|
13
|
+
.bl-ink[data-fill="image"][data-pixelated] { image-rendering: pixelated; }
|
|
14
|
+
@keyframes bl-ink-sweep { from { background-position: 100% 0; } to { background-position: -50% 0; } }
|
|
15
|
+
@keyframes bl-ink-flow { from { background-position: 0% 0; } to { background-position: 150% 0; } }
|
|
16
|
+
@keyframes bl-ink-pan { to { background-position: 100% 50%; } }
|
|
17
|
+
@media (prefers-reduced-motion: reduce) { .bl-ink { animation: none !important; transition: none !important; } .bl-ink[data-fill="shimmer"] { background-position: 50% 0; } }
|
|
18
|
+
`;
|
|
19
|
+
function useStyles() {
|
|
20
|
+
useInsertionEffect(() => {
|
|
21
|
+
if (typeof document === "undefined") return;
|
|
22
|
+
const style = document.getElementById(STYLE_ID) ?? Object.assign(document.createElement("style"), { id: STYLE_ID });
|
|
23
|
+
style.textContent = CSS;
|
|
24
|
+
if (!style.isConnected) document.head.appendChild(style);
|
|
25
|
+
}, []);
|
|
26
|
+
}
|
|
27
|
+
function gradientStops(colors, stepped) {
|
|
28
|
+
const list = [...colors, colors[0]];
|
|
29
|
+
if (!stepped) return list.join(", ");
|
|
30
|
+
const share = 100 / list.length;
|
|
31
|
+
return list.map((c, i) => `${c} ${(i * share).toFixed(2)}% ${((i + 1) * share).toFixed(2)}%`).join(", ");
|
|
32
|
+
}
|
|
33
|
+
function InkText({
|
|
34
|
+
text,
|
|
35
|
+
children,
|
|
36
|
+
as: Tag = "span",
|
|
37
|
+
fill = "shimmer",
|
|
38
|
+
colors = ["#ef7d57", "#ffcd75", "#a7f070", "#73eff7", "#41a6f6", "#b13e53"],
|
|
39
|
+
stepped = true,
|
|
40
|
+
baseColor = "#94b0c2",
|
|
41
|
+
glintColor = "#f4f4f4",
|
|
42
|
+
image,
|
|
43
|
+
pixelated = true,
|
|
44
|
+
strokeWidth = 1.5,
|
|
45
|
+
filled = false,
|
|
46
|
+
speed = 3,
|
|
47
|
+
className = "",
|
|
48
|
+
style
|
|
49
|
+
}) {
|
|
50
|
+
useStyles();
|
|
51
|
+
return /* @__PURE__ */ jsx(
|
|
52
|
+
Tag,
|
|
53
|
+
{
|
|
54
|
+
className: `bl-ink ${className}`,
|
|
55
|
+
"data-fill": fill,
|
|
56
|
+
"data-filled": filled || void 0,
|
|
57
|
+
"data-pixelated": pixelated || void 0,
|
|
58
|
+
style: { "--bl-base": baseColor, "--bl-glint": glintColor, "--bl-stops": gradientStops(colors, stepped), "--bl-image": image ? `url("${image}")` : "none", "--bl-stroke": `${strokeWidth}px`, "--bl-speed": `${speed}s`, ...style },
|
|
59
|
+
children: text ?? children
|
|
60
|
+
}
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
export {
|
|
64
|
+
InkText as default
|
|
65
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type CSSProperties } from 'react';
|
|
2
|
+
export interface InlineEditProps {
|
|
3
|
+
value?: string;
|
|
4
|
+
defaultValue?: string;
|
|
5
|
+
/** Return a promise to show "Saving…"; throw (or reject) with a message to keep editing. */
|
|
6
|
+
onSave?: (value: string) => void | Promise<unknown>;
|
|
7
|
+
/** Return a message to block the save. */
|
|
8
|
+
validate?: (value: string) => string | null | undefined;
|
|
9
|
+
placeholder?: string;
|
|
10
|
+
/** Accessible name of the field. */
|
|
11
|
+
label?: string;
|
|
12
|
+
/** Clicking away saves; false cancels instead. */
|
|
13
|
+
saveOnBlur?: boolean;
|
|
14
|
+
maxLength?: number;
|
|
15
|
+
minWidth?: number;
|
|
16
|
+
fontSize?: number;
|
|
17
|
+
radius?: number;
|
|
18
|
+
textColor?: string;
|
|
19
|
+
mutedColor?: string;
|
|
20
|
+
hoverColor?: string;
|
|
21
|
+
fieldColor?: string;
|
|
22
|
+
chipColor?: string;
|
|
23
|
+
accentColor?: string;
|
|
24
|
+
onAccentColor?: string;
|
|
25
|
+
errorColor?: string;
|
|
26
|
+
fontFamily?: string;
|
|
27
|
+
className?: string;
|
|
28
|
+
style?: CSSProperties;
|
|
29
|
+
}
|
|
30
|
+
export default function InlineEdit({ value: controlled, defaultValue, onSave, validate, placeholder, label, saveOnBlur, maxLength, minWidth, fontSize, radius, textColor, mutedColor, hoverColor, fieldColor, chipColor, accentColor, onAccentColor, errorColor, fontFamily, className, style }: InlineEditProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useId, useInsertionEffect, useLayoutEffect, useRef, useState } from "react";
|
|
4
|
+
const STYLE_ID = "bl-inline-edit";
|
|
5
|
+
const CSS = `
|
|
6
|
+
.bl-ie { position: relative; display: inline-flex; align-items: center; gap: 6px; max-width: 100%; font-family: var(--bl-font); font-size: var(--bl-size); color: var(--bl-ink); vertical-align: middle; }
|
|
7
|
+
.bl-ie__box { position: relative; box-sizing: border-box; width: var(--bl-box-w); max-width: 100%; min-width: var(--bl-min-w); transition: width 200ms cubic-bezier(.3,1.2,.5,1); }
|
|
8
|
+
.bl-ie__display { display: flex; align-items: center; gap: 8px; box-sizing: border-box; width: 100%; padding: 6px 10px; border: 0; border-radius: var(--bl-radius); background: transparent; color: inherit; font: inherit; text-align: left; cursor: text; transition: background-color 150ms; }
|
|
9
|
+
.bl-ie__display:hover { background: var(--bl-hover); }
|
|
10
|
+
.bl-ie__display:focus-visible { outline: 2px solid var(--bl-accent); outline-offset: 1px; }
|
|
11
|
+
.bl-ie__text { overflow: hidden; white-space: pre; text-overflow: ellipsis; }
|
|
12
|
+
.bl-ie__text[data-empty] { color: var(--bl-muted); font-style: italic; }
|
|
13
|
+
.bl-ie__pencil { flex: none; display: grid; color: var(--bl-muted); opacity: 0; transition: opacity 150ms; }
|
|
14
|
+
.bl-ie__display:hover .bl-ie__pencil, .bl-ie__display:focus-visible .bl-ie__pencil { opacity: 1; }
|
|
15
|
+
.bl-ie__input { display: block; box-sizing: border-box; width: 100%; margin: 0; padding: 6px 10px; border: 0; border-radius: var(--bl-radius); background: var(--bl-field); color: inherit; font: inherit; box-shadow: inset 0 0 0 2px var(--bl-accent); outline: none; }
|
|
16
|
+
.bl-ie[data-invalid] .bl-ie__input { box-shadow: inset 0 0 0 2px var(--bl-error); animation: bl-ie-shake 320ms; }
|
|
17
|
+
.bl-ie[data-busy] .bl-ie__input { opacity: 0.7; }
|
|
18
|
+
.bl-ie__btn { display: grid; place-items: center; flex: none; width: 30px; height: 30px; padding: 0; border: 0; border-radius: 8px; background: var(--bl-chip); color: var(--bl-ink); cursor: pointer; animation: bl-ie-pop 260ms cubic-bezier(.3,1.6,.5,1) both; }
|
|
19
|
+
.bl-ie__btn + .bl-ie__btn { animation-delay: 50ms; }
|
|
20
|
+
.bl-ie__btn:hover { background: var(--bl-hover); }
|
|
21
|
+
.bl-ie__btn:focus-visible { outline: 2px solid var(--bl-accent); outline-offset: 1px; }
|
|
22
|
+
.bl-ie__btn[data-save] { background: var(--bl-accent); color: var(--bl-on-accent); }
|
|
23
|
+
.bl-ie__btn:disabled { cursor: progress; opacity: 0.6; }
|
|
24
|
+
.bl-ie__msg { position: absolute; top: calc(100% + 4px); left: 0; font-size: 12px; white-space: nowrap; color: var(--bl-muted); }
|
|
25
|
+
.bl-ie__msg[data-error] { color: var(--bl-error); }
|
|
26
|
+
.bl-ie__measure { position: absolute; top: 0; left: 0; visibility: hidden; padding: 0 10px; white-space: pre; pointer-events: none; }
|
|
27
|
+
.bl-ie__sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
|
|
28
|
+
@keyframes bl-ie-pop { from { opacity: 0; transform: scale(0.4); } }
|
|
29
|
+
@keyframes bl-ie-shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
|
|
30
|
+
@media (prefers-reduced-motion: reduce) { .bl-ie__box { transition: none; } .bl-ie__btn, .bl-ie[data-invalid] .bl-ie__input { animation: none; } }
|
|
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
|
+
function InlineEdit({
|
|
41
|
+
value: controlled,
|
|
42
|
+
defaultValue = "",
|
|
43
|
+
onSave,
|
|
44
|
+
validate,
|
|
45
|
+
placeholder = "Click to edit",
|
|
46
|
+
label = "Text",
|
|
47
|
+
saveOnBlur = true,
|
|
48
|
+
maxLength,
|
|
49
|
+
minWidth = 60,
|
|
50
|
+
fontSize = 16,
|
|
51
|
+
radius = 8,
|
|
52
|
+
textColor = "#f4f4f4",
|
|
53
|
+
mutedColor = "#94b0c2",
|
|
54
|
+
hoverColor = "rgba(255,255,255,0.07)",
|
|
55
|
+
fieldColor = "#0b0b14",
|
|
56
|
+
chipColor = "#333c57",
|
|
57
|
+
accentColor = "#73eff7",
|
|
58
|
+
onAccentColor = "#0b0b14",
|
|
59
|
+
errorColor = "#ef7d57",
|
|
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 [inner, setInner] = useState(defaultValue);
|
|
67
|
+
const value = controlled ?? inner;
|
|
68
|
+
const [editing, setEditing] = useState(false);
|
|
69
|
+
const [draft, setDraft] = useState(value);
|
|
70
|
+
const [error, setError] = useState("");
|
|
71
|
+
const [busy, setBusy] = useState(false);
|
|
72
|
+
const [announce, setAnnounce] = useState("");
|
|
73
|
+
const [boxWidth, setBoxWidth] = useState(null);
|
|
74
|
+
const inputRef = useRef(null);
|
|
75
|
+
const displayRef = useRef(null);
|
|
76
|
+
const measureRef = useRef(null);
|
|
77
|
+
const rootRef = useRef(null);
|
|
78
|
+
const refocus = useRef(false);
|
|
79
|
+
const shown = editing ? draft : value;
|
|
80
|
+
useLayoutEffect(() => {
|
|
81
|
+
const width = measureRef.current.getBoundingClientRect().width;
|
|
82
|
+
setBoxWidth(Math.ceil(width + (editing ? 4 : 24)));
|
|
83
|
+
}, [shown, placeholder, editing, fontSize, fontFamily]);
|
|
84
|
+
useEffect(() => {
|
|
85
|
+
if (editing) {
|
|
86
|
+
inputRef.current?.focus();
|
|
87
|
+
inputRef.current?.select();
|
|
88
|
+
} else if (refocus.current) {
|
|
89
|
+
refocus.current = false;
|
|
90
|
+
displayRef.current?.focus();
|
|
91
|
+
}
|
|
92
|
+
}, [editing]);
|
|
93
|
+
const start = () => {
|
|
94
|
+
setDraft(value);
|
|
95
|
+
setError("");
|
|
96
|
+
setEditing(true);
|
|
97
|
+
};
|
|
98
|
+
const cancel = (focusBack = true) => {
|
|
99
|
+
refocus.current = focusBack;
|
|
100
|
+
setEditing(false);
|
|
101
|
+
setError("");
|
|
102
|
+
};
|
|
103
|
+
const save = async (focusBack = true) => {
|
|
104
|
+
if (busy) return;
|
|
105
|
+
const next = draft;
|
|
106
|
+
if (next === value) {
|
|
107
|
+
cancel(focusBack);
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
const problem = validate?.(next);
|
|
111
|
+
if (problem) {
|
|
112
|
+
setError(problem);
|
|
113
|
+
setAnnounce(problem);
|
|
114
|
+
inputRef.current?.focus();
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
try {
|
|
118
|
+
const result = onSave?.(next);
|
|
119
|
+
if (result && typeof result.then === "function") {
|
|
120
|
+
setBusy(true);
|
|
121
|
+
setAnnounce("Saving\u2026");
|
|
122
|
+
await result;
|
|
123
|
+
}
|
|
124
|
+
if (controlled === void 0) setInner(next);
|
|
125
|
+
setBusy(false);
|
|
126
|
+
refocus.current = focusBack;
|
|
127
|
+
setEditing(false);
|
|
128
|
+
setError("");
|
|
129
|
+
setAnnounce(`${label} saved: ${next || "empty"}.`);
|
|
130
|
+
} catch (err) {
|
|
131
|
+
setBusy(false);
|
|
132
|
+
const message = err?.message || "Couldn't save. Try again.";
|
|
133
|
+
setError(message);
|
|
134
|
+
setAnnounce(message);
|
|
135
|
+
inputRef.current?.focus();
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
const onBlur = (event) => {
|
|
139
|
+
if (rootRef.current.contains(event.relatedTarget)) return;
|
|
140
|
+
if (saveOnBlur) save(false);
|
|
141
|
+
else cancel(false);
|
|
142
|
+
};
|
|
143
|
+
return /* @__PURE__ */ jsxs(
|
|
144
|
+
"span",
|
|
145
|
+
{
|
|
146
|
+
ref: rootRef,
|
|
147
|
+
className: `bl-ie ${className}`,
|
|
148
|
+
"data-invalid": error || void 0,
|
|
149
|
+
"data-busy": busy || void 0,
|
|
150
|
+
style: { "--bl-size": `${fontSize}px`, "--bl-radius": `${radius}px`, "--bl-min-w": `${minWidth}px`, "--bl-box-w": boxWidth ? `${boxWidth}px` : "auto", "--bl-ink": textColor, "--bl-muted": mutedColor, "--bl-hover": hoverColor, "--bl-field": fieldColor, "--bl-chip": chipColor, "--bl-accent": accentColor, "--bl-on-accent": onAccentColor, "--bl-error": errorColor, "--bl-font": fontFamily, ...style },
|
|
151
|
+
children: [
|
|
152
|
+
/* @__PURE__ */ jsxs("span", { className: "bl-ie__box", children: [
|
|
153
|
+
editing ? /* @__PURE__ */ jsx(
|
|
154
|
+
"input",
|
|
155
|
+
{
|
|
156
|
+
ref: inputRef,
|
|
157
|
+
className: "bl-ie__input",
|
|
158
|
+
value: draft,
|
|
159
|
+
maxLength,
|
|
160
|
+
placeholder,
|
|
161
|
+
"aria-label": label,
|
|
162
|
+
"aria-invalid": error ? true : void 0,
|
|
163
|
+
"aria-describedby": error ? `${uid}-msg` : void 0,
|
|
164
|
+
readOnly: busy,
|
|
165
|
+
onChange: (event) => {
|
|
166
|
+
setDraft(event.target.value);
|
|
167
|
+
if (error) setError("");
|
|
168
|
+
},
|
|
169
|
+
onKeyDown: (event) => {
|
|
170
|
+
if (event.key === "Enter") {
|
|
171
|
+
event.preventDefault();
|
|
172
|
+
save();
|
|
173
|
+
} else if (event.key === "Escape") {
|
|
174
|
+
event.preventDefault();
|
|
175
|
+
cancel();
|
|
176
|
+
}
|
|
177
|
+
},
|
|
178
|
+
onBlur
|
|
179
|
+
}
|
|
180
|
+
) : /* @__PURE__ */ jsxs("button", { ref: displayRef, type: "button", className: "bl-ie__display", "aria-label": `Edit ${label}: ${value || "empty"}`, onClick: start, children: [
|
|
181
|
+
/* @__PURE__ */ jsx("span", { className: "bl-ie__text", "data-empty": value ? void 0 : "", children: value || placeholder }),
|
|
182
|
+
/* @__PURE__ */ jsx("span", { className: "bl-ie__pencil", "aria-hidden": "true", children: /* @__PURE__ */ jsx("svg", { width: "14", height: "14", viewBox: "0 0 14 14", fill: "none", stroke: "currentColor", strokeWidth: "1.6", strokeLinejoin: "round", children: /* @__PURE__ */ jsx("path", { d: "M2 12l.6-2.8L9.8 2 12 4.2 4.8 11.4z" }) }) })
|
|
183
|
+
] }),
|
|
184
|
+
/* @__PURE__ */ jsx("span", { ref: measureRef, className: "bl-ie__measure", "aria-hidden": "true", children: shown || placeholder })
|
|
185
|
+
] }),
|
|
186
|
+
editing && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
187
|
+
/* @__PURE__ */ jsx("button", { type: "button", className: "bl-ie__btn", "data-save": "", "aria-label": "Save", disabled: busy, onClick: () => save(), onBlur, children: /* @__PURE__ */ jsx("svg", { width: "14", height: "14", viewBox: "0 0 14 14", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: /* @__PURE__ */ jsx("path", { d: "M2.5 7.5l3 3 6-7" }) }) }),
|
|
188
|
+
/* @__PURE__ */ jsx("button", { type: "button", className: "bl-ie__btn", "aria-label": "Cancel", disabled: busy, onClick: () => cancel(), onBlur, children: /* @__PURE__ */ jsx("svg", { width: "12", height: "12", viewBox: "0 0 12 12", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", "aria-hidden": "true", children: /* @__PURE__ */ jsx("path", { d: "M2 2l8 8M10 2 2 10" }) }) })
|
|
189
|
+
] }),
|
|
190
|
+
(error || busy) && /* @__PURE__ */ jsx("span", { id: `${uid}-msg`, className: "bl-ie__msg", "data-error": error ? "" : void 0, children: error || "Saving\u2026" }),
|
|
191
|
+
/* @__PURE__ */ jsx("span", { className: "bl-ie__sr", "aria-live": "polite", children: announce })
|
|
192
|
+
]
|
|
193
|
+
}
|
|
194
|
+
);
|
|
195
|
+
}
|
|
196
|
+
export {
|
|
197
|
+
InlineEdit as default
|
|
198
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type CSSProperties } from 'react';
|
|
2
|
+
export interface InteractiveGridProps {
|
|
3
|
+
/** Cell pitch in px. */
|
|
4
|
+
cellSize?: number;
|
|
5
|
+
/** Gap (grid line) between cells in px. */
|
|
6
|
+
gap?: number;
|
|
7
|
+
/** The ramp a lit cell cools through as it fades, hottest first. */
|
|
8
|
+
colors?: string[];
|
|
9
|
+
cellColor?: string;
|
|
10
|
+
/** Grid-line colour. */
|
|
11
|
+
backgroundColor?: string;
|
|
12
|
+
/** Fade time in ms. */
|
|
13
|
+
trail?: number;
|
|
14
|
+
/** Cells lit around the pointer (radius). */
|
|
15
|
+
brush?: number;
|
|
16
|
+
/** A click sends a ring across the grid. */
|
|
17
|
+
ripple?: boolean;
|
|
18
|
+
/** Ripple speed in cells per second. */
|
|
19
|
+
rippleSpeed?: number;
|
|
20
|
+
/** A wandering trail while nobody is pointing. */
|
|
21
|
+
autopilot?: boolean;
|
|
22
|
+
className?: string;
|
|
23
|
+
style?: CSSProperties;
|
|
24
|
+
}
|
|
25
|
+
export default function InteractiveGrid({ cellSize, gap, colors, cellColor, backgroundColor, trail, brush, ripple, rippleSpeed, autopilot, className, style }: InteractiveGridProps): import("react").JSX.Element;
|