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,194 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useRef } from "react";
|
|
4
|
+
function rgb(hex) {
|
|
5
|
+
const v = hex.replace("#", "");
|
|
6
|
+
const full = v.length === 3 ? v.replace(/./g, (c) => c + c) : v.slice(0, 6);
|
|
7
|
+
const n = parseInt(full, 16);
|
|
8
|
+
return [n >> 16 & 255, n >> 8 & 255, n & 255];
|
|
9
|
+
}
|
|
10
|
+
function InteractiveGrid({
|
|
11
|
+
cellSize = 28,
|
|
12
|
+
gap = 2,
|
|
13
|
+
colors = ["#73eff7", "#41a6f6", "#3b5dc9", "#29366f"],
|
|
14
|
+
cellColor = "#1f2236",
|
|
15
|
+
backgroundColor = "#14151f",
|
|
16
|
+
trail = 700,
|
|
17
|
+
brush = 0,
|
|
18
|
+
ripple = true,
|
|
19
|
+
rippleSpeed = 24,
|
|
20
|
+
autopilot = true,
|
|
21
|
+
className = "",
|
|
22
|
+
style
|
|
23
|
+
}) {
|
|
24
|
+
const wrapRef = useRef(null);
|
|
25
|
+
const canvasRef = useRef(null);
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
const wrap = wrapRef.current;
|
|
28
|
+
const canvas = canvasRef.current;
|
|
29
|
+
const ctx = canvas.getContext("2d");
|
|
30
|
+
const reduced = window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;
|
|
31
|
+
const ramp = colors.map(rgb);
|
|
32
|
+
const base = rgb(cellColor);
|
|
33
|
+
let cols = 0;
|
|
34
|
+
let rows = 0;
|
|
35
|
+
let dpr = 1;
|
|
36
|
+
let heat = new Float32Array(0);
|
|
37
|
+
let frame = 0;
|
|
38
|
+
let visible = true;
|
|
39
|
+
let last = performance.now();
|
|
40
|
+
let pointer = null;
|
|
41
|
+
let lastActive = -Infinity;
|
|
42
|
+
let ripples = [];
|
|
43
|
+
let pilotT = Math.random() * 100;
|
|
44
|
+
let pilotCell = null;
|
|
45
|
+
const light = (c, r) => {
|
|
46
|
+
for (let y = r - brush; y <= r + brush; y++) {
|
|
47
|
+
for (let x = c - brush; x <= c + brush; x++) {
|
|
48
|
+
if (x < 0 || y < 0 || x >= cols || y >= rows) continue;
|
|
49
|
+
if (brush && (x - c) ** 2 + (y - r) ** 2 > (brush + 0.5) ** 2) continue;
|
|
50
|
+
heat[y * cols + x] = 1;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
const stroke = (from, to) => {
|
|
55
|
+
let [x0, y0] = from ?? to;
|
|
56
|
+
const [x1, y1] = to;
|
|
57
|
+
const dx = Math.abs(x1 - x0);
|
|
58
|
+
const dy = -Math.abs(y1 - y0);
|
|
59
|
+
const sx = x0 < x1 ? 1 : -1;
|
|
60
|
+
const sy = y0 < y1 ? 1 : -1;
|
|
61
|
+
let err = dx + dy;
|
|
62
|
+
for (let n = 0; n < 512; n++) {
|
|
63
|
+
light(x0, y0);
|
|
64
|
+
if (x0 === x1 && y0 === y1) break;
|
|
65
|
+
const e2 = 2 * err;
|
|
66
|
+
if (e2 >= dy) {
|
|
67
|
+
err += dy;
|
|
68
|
+
x0 += sx;
|
|
69
|
+
}
|
|
70
|
+
if (e2 <= dx) {
|
|
71
|
+
err += dx;
|
|
72
|
+
y0 += sy;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
const layout = () => {
|
|
77
|
+
dpr = Math.min(2, window.devicePixelRatio || 1);
|
|
78
|
+
canvas.width = Math.round(wrap.clientWidth * dpr);
|
|
79
|
+
canvas.height = Math.round(wrap.clientHeight * dpr);
|
|
80
|
+
cols = Math.max(1, Math.ceil(wrap.clientWidth / cellSize));
|
|
81
|
+
rows = Math.max(1, Math.ceil(wrap.clientHeight / cellSize));
|
|
82
|
+
heat = new Float32Array(cols * rows);
|
|
83
|
+
pointer = null;
|
|
84
|
+
draw();
|
|
85
|
+
};
|
|
86
|
+
const draw = () => {
|
|
87
|
+
const cell = cellSize * dpr;
|
|
88
|
+
const inset = gap * dpr;
|
|
89
|
+
ctx.fillStyle = backgroundColor;
|
|
90
|
+
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
91
|
+
for (let r = 0; r < rows; r++) {
|
|
92
|
+
for (let c = 0; c < cols; c++) {
|
|
93
|
+
let h = heat[r * cols + c];
|
|
94
|
+
for (const rp of ripples) {
|
|
95
|
+
const ring = 1 - Math.abs(Math.hypot(c - rp.x, r - rp.y) - rp.r) / 1.5;
|
|
96
|
+
if (ring > 0) h = Math.max(h, ring * (1 - rp.r / rp.max));
|
|
97
|
+
}
|
|
98
|
+
if (h <= 0) {
|
|
99
|
+
ctx.fillStyle = cellColor;
|
|
100
|
+
} else {
|
|
101
|
+
const pos = (1 - h) * (ramp.length - 1);
|
|
102
|
+
const i = Math.max(0, Math.min(ramp.length - 2, Math.floor(pos)));
|
|
103
|
+
const t = ramp.length > 1 ? pos - i : 0;
|
|
104
|
+
const a = ramp[i];
|
|
105
|
+
const b = ramp[Math.min(ramp.length - 1, i + 1)];
|
|
106
|
+
const alpha = Math.min(1, h * 1.4);
|
|
107
|
+
const mix = (k) => Math.round(base[k] + (a[k] + (b[k] - a[k]) * t - base[k]) * alpha);
|
|
108
|
+
ctx.fillStyle = `rgb(${mix(0)},${mix(1)},${mix(2)})`;
|
|
109
|
+
}
|
|
110
|
+
ctx.fillRect(c * cell + inset / 2, r * cell + inset / 2, cell - inset, cell - inset);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
const tick = (now) => {
|
|
115
|
+
frame = 0;
|
|
116
|
+
const dt = Math.min(0.1, (now - last) / 1e3);
|
|
117
|
+
last = now;
|
|
118
|
+
const fade = reduced ? 1 : dt * 1e3 / trail;
|
|
119
|
+
let hot = false;
|
|
120
|
+
for (let i = 0; i < heat.length; i++) {
|
|
121
|
+
if (heat[i] > 0) {
|
|
122
|
+
heat[i] = Math.max(0, heat[i] - fade);
|
|
123
|
+
hot = true;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
ripples = ripples.filter((rp) => {
|
|
127
|
+
rp.r += rippleSpeed * dt;
|
|
128
|
+
return rp.r < rp.max;
|
|
129
|
+
});
|
|
130
|
+
if (autopilot && !reduced && now - lastActive > 2e3) {
|
|
131
|
+
pilotT += dt * 0.6;
|
|
132
|
+
const cell = [Math.round(((Math.sin(pilotT * 1.3) + Math.sin(pilotT * 0.7 + 1)) / 4 + 0.5) * (cols - 1)), Math.round(((Math.cos(pilotT * 0.9) + Math.sin(pilotT * 1.7)) / 4 + 0.5) * (rows - 1))];
|
|
133
|
+
stroke(pilotCell, cell);
|
|
134
|
+
pilotCell = cell;
|
|
135
|
+
hot = true;
|
|
136
|
+
} else pilotCell = null;
|
|
137
|
+
draw();
|
|
138
|
+
if (visible && (hot || ripples.length)) frame = requestAnimationFrame(tick);
|
|
139
|
+
};
|
|
140
|
+
const wake = () => {
|
|
141
|
+
if (frame || !visible) return;
|
|
142
|
+
last = performance.now();
|
|
143
|
+
frame = requestAnimationFrame(tick);
|
|
144
|
+
};
|
|
145
|
+
const cellAt = (event) => {
|
|
146
|
+
const rect = wrap.getBoundingClientRect();
|
|
147
|
+
const x = event.clientX - rect.left;
|
|
148
|
+
const y = event.clientY - rect.top;
|
|
149
|
+
if (x < 0 || y < 0 || x >= rect.width || y >= rect.height) return null;
|
|
150
|
+
return [Math.floor(x / cellSize), Math.floor(y / cellSize)];
|
|
151
|
+
};
|
|
152
|
+
const onMove = (event) => {
|
|
153
|
+
const cell = cellAt(event);
|
|
154
|
+
if (!cell) {
|
|
155
|
+
pointer = null;
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
lastActive = performance.now();
|
|
159
|
+
if (reduced) heat.fill(0);
|
|
160
|
+
stroke(reduced ? null : pointer, cell);
|
|
161
|
+
pointer = cell;
|
|
162
|
+
if (reduced) draw();
|
|
163
|
+
else wake();
|
|
164
|
+
};
|
|
165
|
+
const onDown = (event) => {
|
|
166
|
+
if (!ripple || reduced) return;
|
|
167
|
+
const cell = cellAt(event);
|
|
168
|
+
if (!cell) return;
|
|
169
|
+
ripples.push({ x: cell[0], y: cell[1], r: 0, max: Math.hypot(cols, rows) * 0.8 });
|
|
170
|
+
wake();
|
|
171
|
+
};
|
|
172
|
+
const resize = new ResizeObserver(layout);
|
|
173
|
+
resize.observe(wrap);
|
|
174
|
+
const io = new IntersectionObserver(([entry]) => {
|
|
175
|
+
visible = entry.isIntersecting;
|
|
176
|
+
if (visible && autopilot && !reduced) wake();
|
|
177
|
+
});
|
|
178
|
+
io.observe(wrap);
|
|
179
|
+
window.addEventListener("pointermove", onMove, { passive: true });
|
|
180
|
+
window.addEventListener("pointerdown", onDown, { passive: true });
|
|
181
|
+
layout();
|
|
182
|
+
return () => {
|
|
183
|
+
cancelAnimationFrame(frame);
|
|
184
|
+
resize.disconnect();
|
|
185
|
+
io.disconnect();
|
|
186
|
+
window.removeEventListener("pointermove", onMove);
|
|
187
|
+
window.removeEventListener("pointerdown", onDown);
|
|
188
|
+
};
|
|
189
|
+
}, [cellSize, gap, colors.join(), cellColor, backgroundColor, trail, brush, ripple, rippleSpeed, autopilot]);
|
|
190
|
+
return /* @__PURE__ */ jsx("div", { ref: wrapRef, className, "aria-hidden": "true", style: { position: "relative", width: "100%", height: "100%", overflow: "hidden", ...style }, children: /* @__PURE__ */ jsx("canvas", { ref: canvasRef, style: { position: "absolute", inset: 0, width: "100%", height: "100%" } }) });
|
|
191
|
+
}
|
|
192
|
+
export {
|
|
193
|
+
InteractiveGrid as default
|
|
194
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { type CSSProperties, type ReactNode } from 'react';
|
|
2
|
+
export type Rarity = 'common' | 'uncommon' | 'rare' | 'epic' | 'legendary';
|
|
3
|
+
export interface InventoryItem {
|
|
4
|
+
/** Items with the same id stack. */
|
|
5
|
+
id: string;
|
|
6
|
+
name: string;
|
|
7
|
+
icon?: ReactNode;
|
|
8
|
+
count?: number;
|
|
9
|
+
rarity?: Rarity;
|
|
10
|
+
/** Shown in the tooltip. */
|
|
11
|
+
description?: ReactNode;
|
|
12
|
+
}
|
|
13
|
+
export type InventorySlot = InventoryItem | null;
|
|
14
|
+
export type MoveAction = 'moved' | 'merged' | 'swapped';
|
|
15
|
+
export interface InventoryGridProps {
|
|
16
|
+
/** Slots, left to right; null is an empty slot. */
|
|
17
|
+
items?: InventorySlot[];
|
|
18
|
+
columns?: number;
|
|
19
|
+
/** Slot size, in px (shrinks to fit narrow containers). */
|
|
20
|
+
slotSize?: number;
|
|
21
|
+
/** Same-id items merge up to this count; the rest stays behind. */
|
|
22
|
+
maxStack?: number;
|
|
23
|
+
panelColor?: string;
|
|
24
|
+
slotColor?: string;
|
|
25
|
+
hoverColor?: string;
|
|
26
|
+
/** Highlight for the held item. */
|
|
27
|
+
accentColor?: string;
|
|
28
|
+
/** Accessible name of the grid. */
|
|
29
|
+
label?: string;
|
|
30
|
+
fontFamily?: string;
|
|
31
|
+
/** Called after every move. */
|
|
32
|
+
onChange?: (slots: InventorySlot[], move: {
|
|
33
|
+
from: number;
|
|
34
|
+
to: number;
|
|
35
|
+
action: MoveAction;
|
|
36
|
+
}) => void;
|
|
37
|
+
className?: string;
|
|
38
|
+
style?: CSSProperties;
|
|
39
|
+
}
|
|
40
|
+
export declare const RARITY_COLORS: Record<Rarity, string>;
|
|
41
|
+
export declare function moveItem(slots: InventorySlot[], from: number, to: number, maxStack?: number): {
|
|
42
|
+
slots: InventorySlot[];
|
|
43
|
+
action: MoveAction | null;
|
|
44
|
+
};
|
|
45
|
+
export default function InventoryGrid({ items, columns, slotSize, maxStack, panelColor, slotColor, hoverColor, accentColor, label, fontFamily, onChange, className, style }: InventoryGridProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useCallback, useEffect, useInsertionEffect, useRef, useState } from "react";
|
|
4
|
+
const STYLE_ID = "bl-inventory";
|
|
5
|
+
const CSS = `
|
|
6
|
+
.bl-inv { position: relative; display: inline-grid; max-width: 100%; gap: 6px; padding: 12px; background: var(--bl-panel); font-family: var(--bl-font, "Press Start 2P", ui-monospace, monospace);
|
|
7
|
+
grid-template-columns: repeat(var(--bl-cols), var(--bl-fit)); touch-action: none;
|
|
8
|
+
box-shadow: 0 -4px 0 0 #0b0b14, 0 4px 0 0 #0b0b14, -4px 0 0 0 #0b0b14, 4px 0 0 0 #0b0b14, 8px 8px 0 4px rgba(11,11,20,0.4); }
|
|
9
|
+
.bl-inv__slot { position: relative; display: grid; place-items: center; width: var(--bl-fit); height: var(--bl-fit); padding: 0; border: 0; background: var(--bl-slot-bg); cursor: grab;
|
|
10
|
+
box-shadow: inset 3px 3px 0 0 rgba(0,0,0,0.45), inset -3px -3px 0 0 rgba(255,255,255,0.08), inset 0 0 0 3px var(--bl-rarity, transparent); }
|
|
11
|
+
.bl-inv__slot[data-empty] { cursor: default; }
|
|
12
|
+
.bl-inv__slot:focus-visible { outline: 3px solid #f4f4f4; outline-offset: 1px; z-index: 1; }
|
|
13
|
+
.bl-inv__slot[data-over] { background: var(--bl-hover); }
|
|
14
|
+
.bl-inv__slot[data-source] > .bl-inv__item { opacity: 0.25; }
|
|
15
|
+
.bl-inv__slot[data-held] { box-shadow: inset 0 0 0 3px var(--bl-accent); animation: bl-inv-held 0.6s steps(2) infinite; }
|
|
16
|
+
.bl-inv__slot[data-landed] > .bl-inv__item { animation: bl-inv-pop 260ms steps(4); }
|
|
17
|
+
.bl-inv__slot[data-rarity="legendary"]::after { content: ""; position: absolute; inset: 3px; pointer-events: none; background: linear-gradient(115deg, transparent 35%, rgba(255,205,117,0.35) 50%, transparent 65%); background-size: 250% 100%; animation: bl-inv-shine 2.4s steps(12) infinite; }
|
|
18
|
+
.bl-inv__item { display: grid; place-items: center; width: 78%; height: 78%; pointer-events: none; }
|
|
19
|
+
.bl-inv__item > * { max-width: 100%; max-height: 100%; }
|
|
20
|
+
.bl-inv__count { position: absolute; right: 4px; bottom: 3px; color: #f4f4f4; font-size: 10px; line-height: 1; text-shadow: 2px 2px 0 #0b0b14; pointer-events: none; }
|
|
21
|
+
.bl-inv__ghost { position: fixed; z-index: 9999; display: grid; place-items: center; width: var(--bl-fit); height: var(--bl-fit); pointer-events: none; transform: translate(-50%, -50%) scale(1.15); filter: drop-shadow(4px 4px 0 rgba(11,11,20,0.55)); }
|
|
22
|
+
.bl-inv__tip { position: absolute; z-index: 2; min-width: 180px; max-width: 240px; padding: 10px 12px; background: #0b0b14; color: #f4f4f4; pointer-events: none;
|
|
23
|
+
box-shadow: 0 0 0 3px var(--bl-tip-border, #5d275d); transform: translate(-50%, calc(-100% - 10px)); }
|
|
24
|
+
.bl-inv__tip-name { margin: 0 0 6px; font-size: 10px; line-height: 1.4; color: var(--bl-tip-color, #f4f4f4); text-transform: uppercase; }
|
|
25
|
+
.bl-inv__tip-meta { margin: 0 0 6px; font-size: 8px; color: #94b0c2; text-transform: uppercase; }
|
|
26
|
+
.bl-inv__tip-desc { margin: 0; font: 13px/1.35 var(--bl-body, ui-monospace, monospace); color: #94b0c2; }
|
|
27
|
+
.bl-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
|
|
28
|
+
@keyframes bl-inv-pop { 0% { transform: scale(0.6); } 60% { transform: scale(1.2); } 100% { transform: scale(1); } }
|
|
29
|
+
@keyframes bl-inv-held { 50% { box-shadow: inset 0 0 0 3px transparent; } }
|
|
30
|
+
@keyframes bl-inv-shine { from { background-position: 150% 0; } to { background-position: -150% 0; } }
|
|
31
|
+
@media (prefers-reduced-motion: reduce) {
|
|
32
|
+
.bl-inv__slot[data-held], .bl-inv__slot[data-landed] > .bl-inv__item, .bl-inv__slot[data-rarity="legendary"]::after { animation: none; }
|
|
33
|
+
}
|
|
34
|
+
`;
|
|
35
|
+
function useStyles() {
|
|
36
|
+
useInsertionEffect(() => {
|
|
37
|
+
if (typeof document === "undefined") return;
|
|
38
|
+
const style = document.getElementById(STYLE_ID) ?? Object.assign(document.createElement("style"), { id: STYLE_ID });
|
|
39
|
+
style.textContent = CSS;
|
|
40
|
+
if (!style.isConnected) document.head.appendChild(style);
|
|
41
|
+
}, []);
|
|
42
|
+
}
|
|
43
|
+
const RARITY_COLORS = { common: "#94b0c2", uncommon: "#38b764", rare: "#41a6f6", epic: "#c447a6", legendary: "#ffcd75" };
|
|
44
|
+
const describe = (item) => item ? `${item.name}${item.count > 1 ? ` \xD7${item.count}` : ""}${item.rarity ? `, ${item.rarity}` : ""}` : "empty";
|
|
45
|
+
function moveItem(slots, from, to, maxStack = 64) {
|
|
46
|
+
const next = [...slots];
|
|
47
|
+
const source = next[from];
|
|
48
|
+
const target = next[to];
|
|
49
|
+
if (!source || from === to) return { slots, action: null };
|
|
50
|
+
if (!target) {
|
|
51
|
+
next[to] = source;
|
|
52
|
+
next[from] = null;
|
|
53
|
+
return { slots: next, action: "moved" };
|
|
54
|
+
}
|
|
55
|
+
if (target.id === source.id && (target.count ?? 1) < maxStack) {
|
|
56
|
+
const total = (target.count ?? 1) + (source.count ?? 1);
|
|
57
|
+
next[to] = { ...target, count: Math.min(maxStack, total) };
|
|
58
|
+
next[from] = total > maxStack ? { ...source, count: total - maxStack } : null;
|
|
59
|
+
return { slots: next, action: "merged" };
|
|
60
|
+
}
|
|
61
|
+
next[to] = source;
|
|
62
|
+
next[from] = target;
|
|
63
|
+
return { slots: next, action: "swapped" };
|
|
64
|
+
}
|
|
65
|
+
function InventoryGrid({
|
|
66
|
+
items = [],
|
|
67
|
+
columns = 6,
|
|
68
|
+
slotSize = 64,
|
|
69
|
+
maxStack = 64,
|
|
70
|
+
panelColor = "#333c57",
|
|
71
|
+
slotColor = "#1a1c2c",
|
|
72
|
+
hoverColor = "#29366f",
|
|
73
|
+
accentColor = "#ffcd75",
|
|
74
|
+
label = "Inventory",
|
|
75
|
+
fontFamily,
|
|
76
|
+
onChange,
|
|
77
|
+
className = "",
|
|
78
|
+
style
|
|
79
|
+
}) {
|
|
80
|
+
useStyles();
|
|
81
|
+
const [slots, setSlots] = useState(items);
|
|
82
|
+
const [focus, setFocus] = useState(0);
|
|
83
|
+
const [held, setHeld] = useState(null);
|
|
84
|
+
const [drag, setDrag] = useState(null);
|
|
85
|
+
const [over, setOver] = useState(null);
|
|
86
|
+
const [landed, setLanded] = useState({ index: null, key: 0 });
|
|
87
|
+
const [hover, setHover] = useState(null);
|
|
88
|
+
const [announcement, setAnnouncement] = useState("");
|
|
89
|
+
const gridRef = useRef(null);
|
|
90
|
+
const slotRefs = useRef([]);
|
|
91
|
+
useEffect(() => setSlots(items), [items]);
|
|
92
|
+
const [fit, setFit] = useState(slotSize);
|
|
93
|
+
useEffect(() => {
|
|
94
|
+
const parent = gridRef.current?.parentElement;
|
|
95
|
+
if (!parent) return void 0;
|
|
96
|
+
const measure = () => {
|
|
97
|
+
const available = parent.clientWidth - 24 - 8 - (columns - 1) * 6;
|
|
98
|
+
setFit(Math.max(28, Math.min(slotSize, Math.floor(available / columns))));
|
|
99
|
+
};
|
|
100
|
+
const observer = new ResizeObserver(measure);
|
|
101
|
+
observer.observe(parent);
|
|
102
|
+
measure();
|
|
103
|
+
return () => observer.disconnect();
|
|
104
|
+
}, [slotSize, columns]);
|
|
105
|
+
const commit = useCallback(
|
|
106
|
+
(from, to) => {
|
|
107
|
+
const { slots: next, action } = moveItem(slots, from, to, maxStack);
|
|
108
|
+
if (!action) return;
|
|
109
|
+
setSlots(next);
|
|
110
|
+
setLanded((current) => ({ index: to, key: current.key + 1 }));
|
|
111
|
+
setAnnouncement(`${slots[from]?.name} ${action} to slot ${to + 1}.`);
|
|
112
|
+
onChange?.(next, { from, to, action });
|
|
113
|
+
},
|
|
114
|
+
[slots, maxStack, onChange]
|
|
115
|
+
);
|
|
116
|
+
const focusSlot = (index) => {
|
|
117
|
+
setFocus(index);
|
|
118
|
+
slotRefs.current[index]?.focus();
|
|
119
|
+
};
|
|
120
|
+
const onKeyDown = (event, index) => {
|
|
121
|
+
const moves = { ArrowRight: 1, ArrowLeft: -1, ArrowDown: columns, ArrowUp: -columns };
|
|
122
|
+
if (moves[event.key] !== void 0) {
|
|
123
|
+
event.preventDefault();
|
|
124
|
+
const next = index + moves[event.key];
|
|
125
|
+
if (next >= 0 && next < slots.length) focusSlot(next);
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
if (event.key === "Home" || event.key === "End") {
|
|
129
|
+
event.preventDefault();
|
|
130
|
+
focusSlot(event.key === "Home" ? 0 : slots.length - 1);
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
134
|
+
event.preventDefault();
|
|
135
|
+
if (held === null) {
|
|
136
|
+
if (!slots[index]) return;
|
|
137
|
+
setHeld(index);
|
|
138
|
+
setAnnouncement(`Picked up ${describe(slots[index])}. Move with arrow keys, press Enter to drop.`);
|
|
139
|
+
} else {
|
|
140
|
+
commit(held, index);
|
|
141
|
+
if (held === index) setAnnouncement("Put back.");
|
|
142
|
+
setHeld(null);
|
|
143
|
+
}
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
if (event.key === "Escape" && held !== null) {
|
|
147
|
+
setHeld(null);
|
|
148
|
+
setAnnouncement("Cancelled.");
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
const onPointerDown = (event, index) => {
|
|
152
|
+
if (!slots[index] || event.button > 0) return;
|
|
153
|
+
const startX = event.clientX;
|
|
154
|
+
const startY = event.clientY;
|
|
155
|
+
const el = event.currentTarget;
|
|
156
|
+
el.setPointerCapture(event.pointerId);
|
|
157
|
+
let dragging = false;
|
|
158
|
+
const slotAt = (x, y) => {
|
|
159
|
+
const target = document.elementFromPoint(x, y)?.closest("[data-slot-index]");
|
|
160
|
+
return target && gridRef.current?.contains(target) ? Number(target.dataset.slotIndex) : null;
|
|
161
|
+
};
|
|
162
|
+
const move = (e) => {
|
|
163
|
+
if (!dragging && Math.hypot(e.clientX - startX, e.clientY - startY) < 5) return;
|
|
164
|
+
dragging = true;
|
|
165
|
+
setDrag({ index, x: e.clientX, y: e.clientY });
|
|
166
|
+
setOver(slotAt(e.clientX, e.clientY));
|
|
167
|
+
setHover(null);
|
|
168
|
+
};
|
|
169
|
+
const up = (e) => {
|
|
170
|
+
el.removeEventListener("pointermove", move);
|
|
171
|
+
el.removeEventListener("pointerup", up);
|
|
172
|
+
el.removeEventListener("pointercancel", up);
|
|
173
|
+
if (dragging) {
|
|
174
|
+
const to = e.type === "pointerup" ? slotAt(e.clientX, e.clientY) : null;
|
|
175
|
+
if (to !== null) commit(index, to);
|
|
176
|
+
}
|
|
177
|
+
setDrag(null);
|
|
178
|
+
setOver(null);
|
|
179
|
+
};
|
|
180
|
+
el.addEventListener("pointermove", move);
|
|
181
|
+
el.addEventListener("pointerup", up);
|
|
182
|
+
el.addEventListener("pointercancel", up);
|
|
183
|
+
};
|
|
184
|
+
const tipItem = hover !== null && !drag ? slots[hover] : null;
|
|
185
|
+
const tipEl = hover !== null ? slotRefs.current[hover] : null;
|
|
186
|
+
const gridRect = gridRef.current?.getBoundingClientRect();
|
|
187
|
+
const tipRect = tipEl?.getBoundingClientRect();
|
|
188
|
+
return /* @__PURE__ */ jsxs(
|
|
189
|
+
"div",
|
|
190
|
+
{
|
|
191
|
+
ref: gridRef,
|
|
192
|
+
role: "grid",
|
|
193
|
+
"aria-label": label,
|
|
194
|
+
className: `bl-inv ${className}`,
|
|
195
|
+
style: {
|
|
196
|
+
"--bl-cols": columns,
|
|
197
|
+
"--bl-fit": `${fit}px`,
|
|
198
|
+
"--bl-panel": panelColor,
|
|
199
|
+
"--bl-slot-bg": slotColor,
|
|
200
|
+
"--bl-hover": hoverColor,
|
|
201
|
+
"--bl-accent": accentColor,
|
|
202
|
+
...fontFamily ? { "--bl-font": fontFamily } : null,
|
|
203
|
+
...style
|
|
204
|
+
},
|
|
205
|
+
children: [
|
|
206
|
+
slots.map((item, index) => /* @__PURE__ */ jsxs(
|
|
207
|
+
"button",
|
|
208
|
+
{
|
|
209
|
+
ref: (el) => {
|
|
210
|
+
slotRefs.current[index] = el;
|
|
211
|
+
},
|
|
212
|
+
type: "button",
|
|
213
|
+
role: "gridcell",
|
|
214
|
+
className: "bl-inv__slot",
|
|
215
|
+
"data-slot-index": index,
|
|
216
|
+
"data-empty": !item || void 0,
|
|
217
|
+
"data-rarity": item?.rarity,
|
|
218
|
+
"data-over": drag && over === index || void 0,
|
|
219
|
+
"data-source": drag?.index === index || void 0,
|
|
220
|
+
"data-held": held === index || void 0,
|
|
221
|
+
"data-landed": landed.index === index ? landed.key : void 0,
|
|
222
|
+
tabIndex: focus === index ? 0 : -1,
|
|
223
|
+
"aria-label": `Slot ${index + 1}: ${describe(item)}`,
|
|
224
|
+
style: { "--bl-rarity": item?.rarity ? RARITY_COLORS[item.rarity] : void 0 },
|
|
225
|
+
onFocus: () => {
|
|
226
|
+
setFocus(index);
|
|
227
|
+
setHover(index);
|
|
228
|
+
},
|
|
229
|
+
onBlur: () => setHover((current) => current === index ? null : current),
|
|
230
|
+
onPointerEnter: () => setHover(index),
|
|
231
|
+
onPointerLeave: () => setHover((current) => current === index ? null : current),
|
|
232
|
+
onPointerDown: (event) => onPointerDown(event, index),
|
|
233
|
+
onKeyDown: (event) => onKeyDown(event, index),
|
|
234
|
+
children: [
|
|
235
|
+
item && /* @__PURE__ */ jsx("span", { className: "bl-inv__item", children: item.icon }, landed.index === index ? landed.key : "item"),
|
|
236
|
+
item?.count > 1 && /* @__PURE__ */ jsx("span", { className: "bl-inv__count", children: item.count })
|
|
237
|
+
]
|
|
238
|
+
},
|
|
239
|
+
index
|
|
240
|
+
)),
|
|
241
|
+
tipItem && tipRect && gridRect && /* @__PURE__ */ jsxs(
|
|
242
|
+
"div",
|
|
243
|
+
{
|
|
244
|
+
className: "bl-inv__tip",
|
|
245
|
+
role: "tooltip",
|
|
246
|
+
style: {
|
|
247
|
+
left: tipRect.left - gridRect.left + tipRect.width / 2,
|
|
248
|
+
top: tipRect.top - gridRect.top,
|
|
249
|
+
"--bl-tip-color": RARITY_COLORS[tipItem.rarity] ?? "#f4f4f4",
|
|
250
|
+
"--bl-tip-border": RARITY_COLORS[tipItem.rarity] ?? "#5d275d"
|
|
251
|
+
},
|
|
252
|
+
children: [
|
|
253
|
+
/* @__PURE__ */ jsx("p", { className: "bl-inv__tip-name", children: tipItem.name }),
|
|
254
|
+
/* @__PURE__ */ jsxs("p", { className: "bl-inv__tip-meta", children: [
|
|
255
|
+
tipItem.rarity ?? "common",
|
|
256
|
+
tipItem.count > 1 ? ` \xB7 \xD7${tipItem.count}` : ""
|
|
257
|
+
] }),
|
|
258
|
+
tipItem.description && /* @__PURE__ */ jsx("p", { className: "bl-inv__tip-desc", children: tipItem.description })
|
|
259
|
+
]
|
|
260
|
+
}
|
|
261
|
+
),
|
|
262
|
+
drag && slots[drag.index] && /* @__PURE__ */ jsx("div", { className: "bl-inv__ghost", style: { left: drag.x, top: drag.y }, "aria-hidden": "true", children: /* @__PURE__ */ jsx("span", { className: "bl-inv__item", children: slots[drag.index].icon }) }),
|
|
263
|
+
/* @__PURE__ */ jsx("span", { className: "bl-sr", "aria-live": "assertive", children: announcement })
|
|
264
|
+
]
|
|
265
|
+
}
|
|
266
|
+
);
|
|
267
|
+
}
|
|
268
|
+
export {
|
|
269
|
+
RARITY_COLORS,
|
|
270
|
+
InventoryGrid as default,
|
|
271
|
+
moveItem
|
|
272
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type ButtonHTMLAttributes, type CSSProperties, type MouseEvent as ReactMouseEvent, type ReactNode } from 'react';
|
|
2
|
+
export interface JellyBlobProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'onClick' | 'type' | 'children' | 'style' | 'color'> {
|
|
3
|
+
children?: ReactNode;
|
|
4
|
+
onClick?: (event: ReactMouseEvent<HTMLButtonElement>) => void;
|
|
5
|
+
/** The resting pill, in px. */
|
|
6
|
+
width?: number;
|
|
7
|
+
height?: number;
|
|
8
|
+
/** Springs around the outline; more is smoother. */
|
|
9
|
+
points?: number;
|
|
10
|
+
/** How far the edge reaches toward the pointer, in px. */
|
|
11
|
+
bulge?: number;
|
|
12
|
+
/** How flat a press makes it, in px. */
|
|
13
|
+
squash?: number;
|
|
14
|
+
stiffness?: number;
|
|
15
|
+
damping?: number;
|
|
16
|
+
/** Gentle breathing at rest (paused off-screen). */
|
|
17
|
+
idle?: boolean;
|
|
18
|
+
color?: string;
|
|
19
|
+
pressedColor?: string;
|
|
20
|
+
textColor?: string;
|
|
21
|
+
/** Focus ring. */
|
|
22
|
+
accentColor?: string;
|
|
23
|
+
fontSize?: number;
|
|
24
|
+
fontFamily?: string;
|
|
25
|
+
type?: 'button' | 'submit' | 'reset';
|
|
26
|
+
disabled?: boolean;
|
|
27
|
+
className?: string;
|
|
28
|
+
style?: CSSProperties;
|
|
29
|
+
}
|
|
30
|
+
export default function JellyBlob({ children, onClick, width, height, points, bulge, squash, stiffness, damping, idle, color, pressedColor, textColor, accentColor, fontSize, fontFamily, type, disabled, className, style, ...rest }: JellyBlobProps): import("react").JSX.Element;
|