@nous-research/ui 0.13.2 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/filler-bg0.webp +0 -0
- package/dist/assets.d.ts +38 -0
- package/dist/fonts.d.ts +0 -1
- package/dist/fonts.js +5 -7
- package/dist/hooks/use-capped-frame.d.ts +0 -1
- package/dist/hooks/use-capped-frame.js +12 -13
- package/dist/hooks/use-css-var-dims.d.ts +0 -1
- package/dist/hooks/use-css-var-dims.js +26 -21
- package/dist/hooks/use-gpu-tier.d.ts +0 -1
- package/dist/hooks/use-gpu-tier.js +90 -110
- package/dist/hooks/use-render-loop.d.ts +0 -1
- package/dist/hooks/use-render-loop.js +58 -58
- package/dist/hooks/use-smooth-controls.d.ts +0 -1
- package/dist/hooks/use-smooth-controls.js +204 -206
- package/dist/index.d.ts +0 -1
- package/dist/index.js +84 -58
- package/dist/ui/basic-page.d.ts +1 -2
- package/dist/ui/basic-page.js +15 -7
- package/dist/ui/components/animated-count.d.ts +1 -2
- package/dist/ui/components/animated-count.js +109 -85
- package/dist/ui/components/ascii.d.ts +2 -3
- package/dist/ui/components/ascii.js +75 -59
- package/dist/ui/components/badge.d.ts +1 -2
- package/dist/ui/components/badge.js +35 -18
- package/dist/ui/components/badges/nous-girl.d.ts +1 -2
- package/dist/ui/components/badges/nous-girl.js +80 -3
- package/dist/ui/components/blend-mode.d.ts +1 -2
- package/dist/ui/components/blend-mode.js +55 -63
- package/dist/ui/components/blink.d.ts +1 -2
- package/dist/ui/components/blink.js +15 -6
- package/dist/ui/components/button.d.ts +2 -3
- package/dist/ui/components/button.js +139 -90
- package/dist/ui/components/command-block.d.ts +2 -3
- package/dist/ui/components/command-block.js +52 -24
- package/dist/ui/components/cursor.d.ts +1 -2
- package/dist/ui/components/cursor.js +93 -54
- package/dist/ui/components/dropdown-menu.d.ts +1 -2
- package/dist/ui/components/dropdown-menu.js +99 -51
- package/dist/ui/components/fit-text/index.d.ts +0 -1
- package/dist/ui/components/fit-text/index.js +21 -13
- package/dist/ui/components/graphs/bar-chart.d.ts +1 -2
- package/dist/ui/components/graphs/bar-chart.js +116 -63
- package/dist/ui/components/graphs/index.d.ts +0 -1
- package/dist/ui/components/graphs/index.js +3 -4
- package/dist/ui/components/graphs/line-chart.d.ts +1 -2
- package/dist/ui/components/graphs/line-chart.js +159 -102
- package/dist/ui/components/graphs/utils.d.ts +2 -3
- package/dist/ui/components/graphs/utils.js +147 -114
- package/dist/ui/components/grid/index.d.ts +0 -1
- package/dist/ui/components/grid/index.js +12 -9
- package/dist/ui/components/hover-bg.d.ts +0 -1
- package/dist/ui/components/hover-bg.js +11 -6
- package/dist/ui/components/icons/arrow.d.ts +1 -2
- package/dist/ui/components/icons/arrow.js +42 -5
- package/dist/ui/components/icons/chevron.d.ts +1 -2
- package/dist/ui/components/icons/chevron.js +49 -5
- package/dist/ui/components/icons/discord.d.ts +1 -2
- package/dist/ui/components/icons/discord.js +12 -4
- package/dist/ui/components/icons/eye.d.ts +1 -2
- package/dist/ui/components/icons/eye.js +5 -3
- package/dist/ui/components/icons/gear.d.ts +1 -2
- package/dist/ui/components/icons/gear.js +28 -14
- package/dist/ui/components/icons/github.d.ts +1 -2
- package/dist/ui/components/icons/github.js +12 -4
- package/dist/ui/components/icons/hamburger.d.ts +1 -2
- package/dist/ui/components/icons/hamburger.js +54 -5
- package/dist/ui/components/icons/heart.d.ts +1 -2
- package/dist/ui/components/icons/heart.js +8 -3
- package/dist/ui/components/icons/index.d.ts +0 -1
- package/dist/ui/components/icons/index.js +11 -12
- package/dist/ui/components/icons/link.d.ts +1 -2
- package/dist/ui/components/icons/link.js +10 -3
- package/dist/ui/components/icons/minus.d.ts +1 -2
- package/dist/ui/components/icons/minus.js +10 -3
- package/dist/ui/components/icons/search.d.ts +1 -2
- package/dist/ui/components/icons/search.js +30 -3
- package/dist/ui/components/image-distortion.d.ts +1 -2
- package/dist/ui/components/image-distortion.js +300 -265
- package/dist/ui/components/leva-client.d.ts +1 -2
- package/dist/ui/components/leva-client.js +9 -10
- package/dist/ui/components/list-item.d.ts +0 -1
- package/dist/ui/components/list-item.js +26 -10
- package/dist/ui/components/modal/index.d.ts +1 -2
- package/dist/ui/components/modal/index.js +33 -14
- package/dist/ui/components/overlays/blend-modes.d.ts +0 -1
- package/dist/ui/components/overlays/blend-modes.js +11 -12
- package/dist/ui/components/overlays/glitch.d.ts +1 -2
- package/dist/ui/components/overlays/glitch.js +115 -110
- package/dist/ui/components/overlays/greys.d.ts +1 -2
- package/dist/ui/components/overlays/greys.js +200 -179
- package/dist/ui/components/overlays/index.d.ts +1 -2
- package/dist/ui/components/overlays/index.js +31 -17
- package/dist/ui/components/overlays/lens-layers.d.ts +1 -2
- package/dist/ui/components/overlays/lens-layers.js +89 -65
- package/dist/ui/components/overlays/lens.d.ts +0 -1
- package/dist/ui/components/overlays/lens.js +46 -52
- package/dist/ui/components/overlays/noise.d.ts +1 -2
- package/dist/ui/components/overlays/noise.js +112 -113
- package/dist/ui/components/overlays/vignette.d.ts +1 -2
- package/dist/ui/components/overlays/vignette.js +44 -38
- package/dist/ui/components/poster.d.ts +1 -2
- package/dist/ui/components/poster.js +240 -87
- package/dist/ui/components/progress.d.ts +1 -2
- package/dist/ui/components/progress.js +52 -12
- package/dist/ui/components/scene-canvas.d.ts +1 -2
- package/dist/ui/components/scene-canvas.js +169 -119
- package/dist/ui/components/scramble.d.ts +1 -2
- package/dist/ui/components/scramble.js +60 -59
- package/dist/ui/components/segmented.d.ts +2 -3
- package/dist/ui/components/segmented.js +47 -12
- package/dist/ui/components/select.d.ts +1 -2
- package/dist/ui/components/select.js +207 -120
- package/dist/ui/components/selection-switcher.d.ts +0 -1
- package/dist/ui/components/selection-switcher.js +29 -25
- package/dist/ui/components/shader.d.ts +1 -2
- package/dist/ui/components/shader.js +56 -38
- package/dist/ui/components/socials.d.ts +1 -2
- package/dist/ui/components/socials.js +18 -7
- package/dist/ui/components/spinner.d.ts +1 -2
- package/dist/ui/components/spinner.js +36 -25
- package/dist/ui/components/stats.d.ts +1 -2
- package/dist/ui/components/stats.js +33 -9
- package/dist/ui/components/switch.d.ts +0 -1
- package/dist/ui/components/switch.js +35 -11
- package/dist/ui/components/tabs.d.ts +3 -4
- package/dist/ui/components/tabs.js +38 -12
- package/dist/ui/components/terminal-demo.d.ts +1 -2
- package/dist/ui/components/terminal-demo.js +119 -74
- package/dist/ui/components/theme-toggle.d.ts +1 -2
- package/dist/ui/components/theme-toggle.js +63 -8
- package/dist/ui/components/tier-card.d.ts +1 -2
- package/dist/ui/components/tier-card.js +144 -24
- package/dist/ui/components/tv.d.ts +1 -2
- package/dist/ui/components/tv.js +138 -90
- package/dist/ui/components/typography/h1.d.ts +0 -1
- package/dist/ui/components/typography/h1.js +17 -8
- package/dist/ui/components/typography/h2.d.ts +0 -1
- package/dist/ui/components/typography/h2.js +17 -8
- package/dist/ui/components/typography/index.d.ts +0 -1
- package/dist/ui/components/typography/index.js +35 -24
- package/dist/ui/components/typography/legend.d.ts +1 -2
- package/dist/ui/components/typography/legend.js +18 -6
- package/dist/ui/components/typography/small.d.ts +0 -1
- package/dist/ui/components/typography/small.js +8 -7
- package/dist/ui/components/watchlist.d.ts +1 -2
- package/dist/ui/components/watchlist.js +77 -25
- package/dist/ui/fonts.css +7 -7
- package/dist/ui/footer.d.ts +1 -2
- package/dist/ui/footer.js +61 -25
- package/dist/ui/header.d.ts +1 -2
- package/dist/ui/header.js +255 -60
- package/dist/ui/layout-wrapper.d.ts +1 -2
- package/dist/ui/layout-wrapper.js +5 -4
- package/dist/utils/color.d.ts +0 -1
- package/dist/utils/color.js +8 -9
- package/dist/utils/index.d.ts +0 -1
- package/dist/utils/index.js +37 -38
- package/dist/utils/poly.d.ts +0 -1
- package/dist/utils/poly.js +1 -2
- package/package.json +41 -24
- package/dist/assets/filler-bg0.jpg +0 -0
- package/dist/fonts.d.ts.map +0 -1
- package/dist/fonts.js.map +0 -1
- package/dist/hooks/use-capped-frame.d.ts.map +0 -1
- package/dist/hooks/use-capped-frame.js.map +0 -1
- package/dist/hooks/use-css-var-dims.d.ts.map +0 -1
- package/dist/hooks/use-css-var-dims.js.map +0 -1
- package/dist/hooks/use-gpu-tier.d.ts.map +0 -1
- package/dist/hooks/use-gpu-tier.js.map +0 -1
- package/dist/hooks/use-render-loop.d.ts.map +0 -1
- package/dist/hooks/use-render-loop.js.map +0 -1
- package/dist/hooks/use-smooth-controls.d.ts.map +0 -1
- package/dist/hooks/use-smooth-controls.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/ui/basic-page.d.ts.map +0 -1
- package/dist/ui/basic-page.js.map +0 -1
- package/dist/ui/components/animated-count.d.ts.map +0 -1
- package/dist/ui/components/animated-count.js.map +0 -1
- package/dist/ui/components/ascii.d.ts.map +0 -1
- package/dist/ui/components/ascii.js.map +0 -1
- package/dist/ui/components/badge.d.ts.map +0 -1
- package/dist/ui/components/badge.js.map +0 -1
- package/dist/ui/components/badges/nous-girl.d.ts.map +0 -1
- package/dist/ui/components/badges/nous-girl.js.map +0 -1
- package/dist/ui/components/blend-mode.d.ts.map +0 -1
- package/dist/ui/components/blend-mode.js.map +0 -1
- package/dist/ui/components/blink.d.ts.map +0 -1
- package/dist/ui/components/blink.js.map +0 -1
- package/dist/ui/components/button.d.ts.map +0 -1
- package/dist/ui/components/button.js.map +0 -1
- package/dist/ui/components/command-block.d.ts.map +0 -1
- package/dist/ui/components/command-block.js.map +0 -1
- package/dist/ui/components/cursor.d.ts.map +0 -1
- package/dist/ui/components/cursor.js.map +0 -1
- package/dist/ui/components/dropdown-menu.d.ts.map +0 -1
- package/dist/ui/components/dropdown-menu.js.map +0 -1
- package/dist/ui/components/fit-text/index.d.ts.map +0 -1
- package/dist/ui/components/fit-text/index.js.map +0 -1
- package/dist/ui/components/graphs/bar-chart.d.ts.map +0 -1
- package/dist/ui/components/graphs/bar-chart.js.map +0 -1
- package/dist/ui/components/graphs/index.d.ts.map +0 -1
- package/dist/ui/components/graphs/index.js.map +0 -1
- package/dist/ui/components/graphs/line-chart.d.ts.map +0 -1
- package/dist/ui/components/graphs/line-chart.js.map +0 -1
- package/dist/ui/components/graphs/utils.d.ts.map +0 -1
- package/dist/ui/components/graphs/utils.js.map +0 -1
- package/dist/ui/components/grid/index.d.ts.map +0 -1
- package/dist/ui/components/grid/index.js.map +0 -1
- package/dist/ui/components/hover-bg.d.ts.map +0 -1
- package/dist/ui/components/hover-bg.js.map +0 -1
- package/dist/ui/components/icons/arrow.d.ts.map +0 -1
- package/dist/ui/components/icons/arrow.js.map +0 -1
- package/dist/ui/components/icons/chevron.d.ts.map +0 -1
- package/dist/ui/components/icons/chevron.js.map +0 -1
- package/dist/ui/components/icons/discord.d.ts.map +0 -1
- package/dist/ui/components/icons/discord.js.map +0 -1
- package/dist/ui/components/icons/eye.d.ts.map +0 -1
- package/dist/ui/components/icons/eye.js.map +0 -1
- package/dist/ui/components/icons/gear.d.ts.map +0 -1
- package/dist/ui/components/icons/gear.js.map +0 -1
- package/dist/ui/components/icons/github.d.ts.map +0 -1
- package/dist/ui/components/icons/github.js.map +0 -1
- package/dist/ui/components/icons/hamburger.d.ts.map +0 -1
- package/dist/ui/components/icons/hamburger.js.map +0 -1
- package/dist/ui/components/icons/heart.d.ts.map +0 -1
- package/dist/ui/components/icons/heart.js.map +0 -1
- package/dist/ui/components/icons/index.d.ts.map +0 -1
- package/dist/ui/components/icons/index.js.map +0 -1
- package/dist/ui/components/icons/link.d.ts.map +0 -1
- package/dist/ui/components/icons/link.js.map +0 -1
- package/dist/ui/components/icons/minus.d.ts.map +0 -1
- package/dist/ui/components/icons/minus.js.map +0 -1
- package/dist/ui/components/icons/search.d.ts.map +0 -1
- package/dist/ui/components/icons/search.js.map +0 -1
- package/dist/ui/components/image-distortion.d.ts.map +0 -1
- package/dist/ui/components/image-distortion.js.map +0 -1
- package/dist/ui/components/leva-client.d.ts.map +0 -1
- package/dist/ui/components/leva-client.js.map +0 -1
- package/dist/ui/components/list-item.d.ts.map +0 -1
- package/dist/ui/components/list-item.js.map +0 -1
- package/dist/ui/components/modal/index.d.ts.map +0 -1
- package/dist/ui/components/modal/index.js.map +0 -1
- package/dist/ui/components/overlays/blend-modes.d.ts.map +0 -1
- package/dist/ui/components/overlays/blend-modes.js.map +0 -1
- package/dist/ui/components/overlays/glitch.d.ts.map +0 -1
- package/dist/ui/components/overlays/glitch.js.map +0 -1
- package/dist/ui/components/overlays/greys.d.ts.map +0 -1
- package/dist/ui/components/overlays/greys.js.map +0 -1
- package/dist/ui/components/overlays/index.d.ts.map +0 -1
- package/dist/ui/components/overlays/index.js.map +0 -1
- package/dist/ui/components/overlays/lens-layers.d.ts.map +0 -1
- package/dist/ui/components/overlays/lens-layers.js.map +0 -1
- package/dist/ui/components/overlays/lens.d.ts.map +0 -1
- package/dist/ui/components/overlays/lens.js.map +0 -1
- package/dist/ui/components/overlays/noise.d.ts.map +0 -1
- package/dist/ui/components/overlays/noise.js.map +0 -1
- package/dist/ui/components/overlays/vignette.d.ts.map +0 -1
- package/dist/ui/components/overlays/vignette.js.map +0 -1
- package/dist/ui/components/poster.d.ts.map +0 -1
- package/dist/ui/components/poster.js.map +0 -1
- package/dist/ui/components/progress.d.ts.map +0 -1
- package/dist/ui/components/progress.js.map +0 -1
- package/dist/ui/components/scene-canvas.d.ts.map +0 -1
- package/dist/ui/components/scene-canvas.js.map +0 -1
- package/dist/ui/components/scramble.d.ts.map +0 -1
- package/dist/ui/components/scramble.js.map +0 -1
- package/dist/ui/components/segmented.d.ts.map +0 -1
- package/dist/ui/components/segmented.js.map +0 -1
- package/dist/ui/components/select.d.ts.map +0 -1
- package/dist/ui/components/select.js.map +0 -1
- package/dist/ui/components/selection-switcher.d.ts.map +0 -1
- package/dist/ui/components/selection-switcher.js.map +0 -1
- package/dist/ui/components/shader.d.ts.map +0 -1
- package/dist/ui/components/shader.js.map +0 -1
- package/dist/ui/components/socials.d.ts.map +0 -1
- package/dist/ui/components/socials.js.map +0 -1
- package/dist/ui/components/spinner.d.ts.map +0 -1
- package/dist/ui/components/spinner.js.map +0 -1
- package/dist/ui/components/stats.d.ts.map +0 -1
- package/dist/ui/components/stats.js.map +0 -1
- package/dist/ui/components/switch.d.ts.map +0 -1
- package/dist/ui/components/switch.js.map +0 -1
- package/dist/ui/components/tabs.d.ts.map +0 -1
- package/dist/ui/components/tabs.js.map +0 -1
- package/dist/ui/components/terminal-demo.d.ts.map +0 -1
- package/dist/ui/components/terminal-demo.js.map +0 -1
- package/dist/ui/components/theme-toggle.d.ts.map +0 -1
- package/dist/ui/components/theme-toggle.js.map +0 -1
- package/dist/ui/components/tier-card.d.ts.map +0 -1
- package/dist/ui/components/tier-card.js.map +0 -1
- package/dist/ui/components/tv.d.ts.map +0 -1
- package/dist/ui/components/tv.js.map +0 -1
- package/dist/ui/components/typography/h1.d.ts.map +0 -1
- package/dist/ui/components/typography/h1.js.map +0 -1
- package/dist/ui/components/typography/h2.d.ts.map +0 -1
- package/dist/ui/components/typography/h2.js.map +0 -1
- package/dist/ui/components/typography/index.d.ts.map +0 -1
- package/dist/ui/components/typography/index.js.map +0 -1
- package/dist/ui/components/typography/legend.d.ts.map +0 -1
- package/dist/ui/components/typography/legend.js.map +0 -1
- package/dist/ui/components/typography/small.d.ts.map +0 -1
- package/dist/ui/components/typography/small.js.map +0 -1
- package/dist/ui/components/watchlist.d.ts.map +0 -1
- package/dist/ui/components/watchlist.js.map +0 -1
- package/dist/ui/footer.d.ts.map +0 -1
- package/dist/ui/footer.js.map +0 -1
- package/dist/ui/header.d.ts.map +0 -1
- package/dist/ui/header.js.map +0 -1
- package/dist/ui/layout-wrapper.d.ts.map +0 -1
- package/dist/ui/layout-wrapper.js.map +0 -1
- package/dist/utils/color.d.ts.map +0 -1
- package/dist/utils/color.js.map +0 -1
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/index.js.map +0 -1
- package/dist/utils/poly.d.ts.map +0 -1
- package/dist/utils/poly.js.map +0 -1
|
@@ -1,57 +1,96 @@
|
|
|
1
|
-
|
|
2
|
-
import { jsx
|
|
3
|
-
import { useEffect, useRef } from
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useRef } from "react";
|
|
4
4
|
const INTERACTIVE = 'a, button, [role="button"], input, textarea, select, [data-cursor]';
|
|
5
|
-
const HAND =
|
|
5
|
+
const HAND = "M6.84 21.83c-.47-.6-1.05-1.82-2.07-3.34-.58-.83-2.01-2.41-2.45-3.23a2.1 2.1 0 0 1-.25-1.67 2.2 2.2 0 0 1 2.39-1.67c.85.18 1.63.6 2.25 1.2.43.41.82.85 1.18 1.32.27.34.33.47.63.85.3.39.5.77.35.2-.11-.83-.31-2.23-.6-3.48-.21-.95-.26-1.1-.46-1.82s-.32-1.32-.54-2.13c-.2-.8-.35-1.62-.46-2.44a4.7 4.7 0 0 1 .43-3.08c.58-.55 1.44-.7 2.17-.37a4.4 4.4 0 0 1 1.57 2.17c.43 1.07.72 2.19.86 3.33.27 1.67.79 4.1.8 4.6 0-.61-.11-1.91 0-2.5.12-.6.54-1.1 1.12-1.33.5-.15 1.02-.19 1.53-.1.52.1.98.4 1.29.83.38.98.6 2 .63 3.05.04-.91.2-1.82.47-2.7.28-.39.68-.67 1.15-.8.55-.1 1.11-.1 1.66 0 .46.15.85.44 1.14.82.35.88.56 1.82.63 2.77 0 .23.12-.65.48-1.24a1.67 1.67 0 1 1 3.17 1.07v3.77c-.06.97-.2 1.94-.4 2.9-.29.85-.7 1.65-1.2 2.38-.8.9-1.48 1.92-1.98 3.02a6.67 6.67 0 0 0 .03 3.2c-.68.07-1.37.07-2.05 0-.65-.1-1.45-1.4-1.67-1.8a.63.63 0 0 0-1.13 0c-.37.64-1.18 1.79-1.75 1.85-1.12.14-3.42 0-5.23 0 0 0 .3-1.66-.39-2.27-.68-.6-1.38-1.3-1.9-1.76l-1.4-1.6Z";
|
|
6
6
|
export function Cursor({ scale = 0.8 }) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
7
|
+
const $root = useRef(null);
|
|
8
|
+
const $arrow = useRef(null);
|
|
9
|
+
const $ptr = useRef(null);
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
const [root, arrow, ptr] = [$root.current, $arrow.current, $ptr.current];
|
|
12
|
+
if (!root || !arrow || !ptr) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
const on = (el, ev, fn, opts) => {
|
|
16
|
+
el.addEventListener(ev, fn, opts);
|
|
17
|
+
return () => el.removeEventListener(ev, fn);
|
|
18
|
+
};
|
|
19
|
+
return [
|
|
20
|
+
on(
|
|
21
|
+
document,
|
|
22
|
+
"mousemove",
|
|
23
|
+
(e) => {
|
|
24
|
+
const { clientX: x, clientY: y } = e;
|
|
25
|
+
root.style.translate = `${x}px ${y}px`;
|
|
26
|
+
root.style.opacity = "1";
|
|
27
|
+
},
|
|
28
|
+
{ passive: true }
|
|
29
|
+
),
|
|
30
|
+
on(
|
|
31
|
+
document,
|
|
32
|
+
"mouseover",
|
|
33
|
+
(e) => {
|
|
34
|
+
const isPtr = !!e.target.closest?.(INTERACTIVE);
|
|
35
|
+
arrow.style.opacity = isPtr ? "0" : "1";
|
|
36
|
+
ptr.style.opacity = isPtr ? "1" : "0";
|
|
37
|
+
},
|
|
38
|
+
{ passive: true }
|
|
39
|
+
),
|
|
40
|
+
on(document, "mousedown", () => {
|
|
41
|
+
root.style.transform = "translate(1px, 1px)";
|
|
42
|
+
}),
|
|
43
|
+
on(document, "mouseup", () => {
|
|
44
|
+
root.style.transform = "";
|
|
45
|
+
}),
|
|
46
|
+
on(document.documentElement, "mouseleave", () => {
|
|
47
|
+
root.style.opacity = "0";
|
|
48
|
+
}),
|
|
49
|
+
on(document.documentElement, "mouseenter", () => {
|
|
50
|
+
root.style.opacity = "1";
|
|
51
|
+
})
|
|
52
|
+
].reduce((_, fn) => fn, void 0);
|
|
53
|
+
}, []);
|
|
54
|
+
return /* @__PURE__ */ jsxs(
|
|
55
|
+
"div",
|
|
56
|
+
{
|
|
57
|
+
"aria-hidden": true,
|
|
58
|
+
ref: $root,
|
|
59
|
+
style: {
|
|
60
|
+
filter: "drop-shadow(1px 2px 0 #000)",
|
|
61
|
+
height: 32 * scale,
|
|
62
|
+
left: 0,
|
|
63
|
+
opacity: 0,
|
|
64
|
+
pointerEvents: "none",
|
|
65
|
+
position: "fixed",
|
|
66
|
+
top: 0,
|
|
67
|
+
width: 32 * scale,
|
|
68
|
+
willChange: "translate",
|
|
69
|
+
zIndex: 9999
|
|
70
|
+
},
|
|
71
|
+
children: [
|
|
72
|
+
/* @__PURE__ */ jsx("div", { ref: $arrow, style: { inset: 0, position: "absolute" }, children: /* @__PURE__ */ jsx("svg", { viewBox: "0 0 16 16", children: /* @__PURE__ */ jsx(
|
|
73
|
+
"path",
|
|
74
|
+
{
|
|
75
|
+
d: "M1 1L1 14L5 10L8 15L10 14L7 9L12 9L1 1Z",
|
|
76
|
+
fill: "#fff",
|
|
77
|
+
stroke: "#000",
|
|
78
|
+
strokeLinejoin: "round",
|
|
79
|
+
strokeWidth: 1
|
|
80
|
+
}
|
|
81
|
+
) }) }),
|
|
82
|
+
/* @__PURE__ */ jsx("div", { ref: $ptr, style: { inset: 0, opacity: 0, position: "absolute" }, children: /* @__PURE__ */ jsx("svg", { viewBox: "0 0 28 29", children: /* @__PURE__ */ jsx(
|
|
83
|
+
"path",
|
|
84
|
+
{
|
|
85
|
+
d: HAND,
|
|
86
|
+
fill: "#fff",
|
|
87
|
+
stroke: "#000",
|
|
88
|
+
strokeLinejoin: "round",
|
|
89
|
+
strokeWidth: 2,
|
|
90
|
+
style: { paintOrder: "stroke fill" }
|
|
91
|
+
}
|
|
92
|
+
) }) })
|
|
93
|
+
]
|
|
94
|
+
}
|
|
95
|
+
);
|
|
56
96
|
}
|
|
57
|
-
//# sourceMappingURL=cursor.js.map
|
|
@@ -1,53 +1,101 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import { useEffect, useId, useRef, useState } from
|
|
4
|
-
import { cn } from
|
|
5
|
-
const font =
|
|
6
|
-
export function DropdownMenu({
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useId, useRef, useState } from "react";
|
|
4
|
+
import { cn } from "../../utils/index.js";
|
|
5
|
+
const font = "font-mondwest text-[.9375rem] leading-[1.4] tracking-[0.1875rem]";
|
|
6
|
+
export function DropdownMenu({
|
|
7
|
+
className,
|
|
8
|
+
direction = "down",
|
|
9
|
+
onChange,
|
|
10
|
+
options,
|
|
11
|
+
value
|
|
12
|
+
}) {
|
|
13
|
+
const id = useId();
|
|
14
|
+
const [open, setOpen] = useState(false);
|
|
15
|
+
const ref = useRef(null);
|
|
16
|
+
const anchor = `--dropdown-${id.replace(/:/g, "")}`;
|
|
17
|
+
const panelStyle = {
|
|
18
|
+
position: "fixed",
|
|
19
|
+
positionAnchor: anchor,
|
|
20
|
+
positionTryFallbacks: direction === "left" || direction === "right" ? "flip-inline, flip-block" : "flip-block, flip-inline",
|
|
21
|
+
...direction === "up" && {
|
|
22
|
+
left: "calc(anchor(left) - 0.5rem)",
|
|
23
|
+
top: "calc(anchor(top) + 1rem)",
|
|
24
|
+
transform: "translateY(-100%)"
|
|
25
|
+
},
|
|
26
|
+
...direction === "right" && {
|
|
27
|
+
left: "calc(anchor(right))",
|
|
28
|
+
top: "calc(anchor(top) - 0.5rem)"
|
|
29
|
+
},
|
|
30
|
+
...direction === "left" && {
|
|
31
|
+
left: "calc(anchor(left) - 1px)",
|
|
32
|
+
top: "calc(anchor(top) - 0.5rem)",
|
|
33
|
+
transform: "translateX(-100%)"
|
|
34
|
+
},
|
|
35
|
+
...direction === "down" && {
|
|
36
|
+
left: "calc(anchor(left) - 0.5rem)",
|
|
37
|
+
top: "calc(anchor(top) - 0.5rem)"
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
if (!open) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
const ac = new AbortController();
|
|
45
|
+
document.addEventListener(
|
|
46
|
+
"mousedown",
|
|
47
|
+
(e) => {
|
|
48
|
+
if (!ref.current?.contains(e.target)) {
|
|
49
|
+
setOpen(false);
|
|
39
50
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
51
|
+
},
|
|
52
|
+
{ signal: ac.signal }
|
|
53
|
+
);
|
|
54
|
+
return () => ac.abort();
|
|
55
|
+
}, [open]);
|
|
56
|
+
return /* @__PURE__ */ jsxs(
|
|
57
|
+
"span",
|
|
58
|
+
{
|
|
59
|
+
className: cn("relative inline-block align-top", className),
|
|
60
|
+
ref,
|
|
61
|
+
children: [
|
|
62
|
+
/* @__PURE__ */ jsxs(
|
|
63
|
+
"span",
|
|
64
|
+
{
|
|
65
|
+
className: cn(font, "inline-block cursor-pointer hover:underline"),
|
|
66
|
+
onClick: () => setOpen(!open),
|
|
67
|
+
style: { anchorName: anchor },
|
|
68
|
+
children: [
|
|
69
|
+
options.find((o) => o.value === value)?.label ?? value,
|
|
70
|
+
" ",
|
|
71
|
+
open ? "\u2191" : "\u2193"
|
|
72
|
+
]
|
|
73
|
+
}
|
|
74
|
+
),
|
|
75
|
+
open && /* @__PURE__ */ jsx(
|
|
76
|
+
"div",
|
|
77
|
+
{
|
|
78
|
+
className: "bg-background-base z-50 flex flex-col",
|
|
79
|
+
style: panelStyle,
|
|
80
|
+
children: options.map((o) => /* @__PURE__ */ jsx(
|
|
81
|
+
"span",
|
|
82
|
+
{
|
|
83
|
+
className: cn(
|
|
84
|
+
font,
|
|
85
|
+
"block cursor-pointer p-2 whitespace-nowrap",
|
|
86
|
+
o.value === value ? "underline" : "hover:bg-midground/10"
|
|
87
|
+
),
|
|
88
|
+
onClick: () => {
|
|
89
|
+
onChange(o.value);
|
|
90
|
+
setOpen(false);
|
|
91
|
+
},
|
|
92
|
+
children: o.label
|
|
93
|
+
},
|
|
94
|
+
o.value
|
|
95
|
+
))
|
|
96
|
+
}
|
|
97
|
+
)
|
|
98
|
+
]
|
|
99
|
+
}
|
|
100
|
+
);
|
|
52
101
|
}
|
|
53
|
-
//# sourceMappingURL=dropdown-menu.js.map
|
|
@@ -1,16 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import { createElement } from
|
|
4
|
-
import { cn, polyRef } from
|
|
5
|
-
export const FitText = polyRef(
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { createElement } from "react";
|
|
4
|
+
import { cn, polyRef } from "../../../utils/index.js";
|
|
5
|
+
export const FitText = polyRef(
|
|
6
|
+
({ as, children, className, max, min = "1em", style: baseStyle, ...rest }, ref) => {
|
|
7
|
+
if (typeof children !== "string") {
|
|
8
|
+
return null;
|
|
8
9
|
}
|
|
9
10
|
const style = {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
"--fit-max": max ?? "infinity * 1px",
|
|
12
|
+
"--fit-min": min,
|
|
13
|
+
...baseStyle
|
|
13
14
|
};
|
|
14
|
-
return createElement(
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
return createElement(
|
|
16
|
+
as ?? "span",
|
|
17
|
+
{ ...rest, className: cn("fit-text", className), ref, style },
|
|
18
|
+
/* @__PURE__ */ jsxs(Fragment, { children: [
|
|
19
|
+
/* @__PURE__ */ jsx("span", { children: /* @__PURE__ */ jsx("span", { children }) }),
|
|
20
|
+
/* @__PURE__ */ jsx("span", { "aria-hidden": "true", children })
|
|
21
|
+
] })
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
);
|
|
@@ -3,11 +3,10 @@ export declare const BarChart: {
|
|
|
3
3
|
(props: Omit<BarChartProps<DataPoint> & {
|
|
4
4
|
backgroundColor?: string;
|
|
5
5
|
color?: string;
|
|
6
|
-
}, keyof import("../blend-mode").BlendColors>): import("react
|
|
6
|
+
}, keyof import("../blend-mode").BlendColors>): import("react").JSX.Element;
|
|
7
7
|
displayName: string;
|
|
8
8
|
};
|
|
9
9
|
interface BarChartProps<T extends DataPoint> extends ChartProps<T> {
|
|
10
10
|
xDomain?: [number, number];
|
|
11
11
|
}
|
|
12
12
|
export {};
|
|
13
|
-
//# sourceMappingURL=bar-chart.d.ts.map
|
|
@@ -1,75 +1,128 @@
|
|
|
1
|
-
|
|
2
|
-
import { jsx
|
|
3
|
-
import * as Plot from
|
|
4
|
-
import { useCallback, useEffect, useMemo, useRef, useState } from
|
|
5
|
-
import { cn } from
|
|
6
|
-
import {
|
|
7
|
-
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as Plot from "@observablehq/plot";
|
|
4
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
5
|
+
import { cn } from "../../../utils/index.js";
|
|
6
|
+
import {
|
|
7
|
+
accessor,
|
|
8
|
+
CHART_MARGINS,
|
|
9
|
+
CHART_STYLE,
|
|
10
|
+
Crosshair,
|
|
11
|
+
setupCrosshair,
|
|
12
|
+
stylePlot,
|
|
13
|
+
useDims,
|
|
14
|
+
withChartBlend
|
|
15
|
+
} from "./utils.js";
|
|
16
|
+
export const BarChart = withChartBlend(
|
|
17
|
+
({
|
|
18
|
+
backgroundColor: _,
|
|
19
|
+
className,
|
|
20
|
+
color: fillColor,
|
|
21
|
+
data = [],
|
|
22
|
+
formatTooltip,
|
|
23
|
+
formatX: formatXProp,
|
|
24
|
+
formatY: formatYProp,
|
|
25
|
+
x = "label",
|
|
26
|
+
xDomain,
|
|
27
|
+
xTicks = [0, 5e4, 1e5],
|
|
28
|
+
y = "value",
|
|
29
|
+
yDomain = [0, 10],
|
|
30
|
+
yTicks = [10, 8, 4, 2],
|
|
31
|
+
...props
|
|
32
|
+
}) => {
|
|
8
33
|
const ref = useRef(null);
|
|
9
34
|
const plotRef = useRef(null);
|
|
10
35
|
const [crosshair, setCrosshair] = useState({ x: null });
|
|
11
36
|
const dims = useDims(ref);
|
|
12
|
-
const formatX = useCallback(
|
|
13
|
-
|
|
14
|
-
|
|
37
|
+
const formatX = useCallback(
|
|
38
|
+
(v) => formatXProp?.(v) ?? (typeof v === "number" ? v.toLocaleString("en-US") : String(v)),
|
|
39
|
+
[formatXProp]
|
|
40
|
+
);
|
|
41
|
+
const formatY = useCallback(
|
|
42
|
+
(v) => formatYProp?.(v) ?? String(v),
|
|
43
|
+
[formatYProp]
|
|
44
|
+
);
|
|
15
45
|
const getX = useMemo(() => accessor(x), [x]);
|
|
16
46
|
const getY = useMemo(() => accessor(y), [y]);
|
|
17
47
|
useEffect(() => {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
48
|
+
if (!ref.current || !plotRef.current || !data.length || !dims.h || !dims.w) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
plotRef.current.innerHTML = "";
|
|
52
|
+
const [xMin, xMax] = [
|
|
53
|
+
xDomain?.[0] ?? 0,
|
|
54
|
+
xDomain?.[1] ?? Math.max(...data.map((d) => getX(d)))
|
|
55
|
+
];
|
|
56
|
+
const plot = Plot.plot({
|
|
57
|
+
...CHART_MARGINS,
|
|
58
|
+
height: dims.h,
|
|
59
|
+
marks: [
|
|
60
|
+
Plot.rectY(data, {
|
|
61
|
+
fill: fillColor ?? "currentColor",
|
|
62
|
+
fillOpacity: 0.3,
|
|
63
|
+
interval: (xMax - xMin) / data.length,
|
|
64
|
+
x: getX,
|
|
65
|
+
y: getY
|
|
66
|
+
}),
|
|
67
|
+
Plot.axisX({ tickFormat: formatX, ticks: xTicks })
|
|
68
|
+
],
|
|
69
|
+
style: CHART_STYLE,
|
|
70
|
+
width: dims.w,
|
|
71
|
+
x: { domain: [xMin, xMax], label: null, type: "linear" },
|
|
72
|
+
y: {
|
|
73
|
+
domain: yDomain,
|
|
74
|
+
grid: true,
|
|
75
|
+
label: null,
|
|
76
|
+
tickFormat: formatY,
|
|
77
|
+
ticks: yTicks
|
|
24
78
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const plot = Plot.plot({
|
|
31
|
-
...CHART_MARGINS,
|
|
32
|
-
height: dims.h,
|
|
33
|
-
marks: [
|
|
34
|
-
Plot.rectY(data, {
|
|
35
|
-
fill: fillColor ?? 'currentColor',
|
|
36
|
-
fillOpacity: 0.3,
|
|
37
|
-
interval: (xMax - xMin) / data.length,
|
|
38
|
-
x: getX,
|
|
39
|
-
y: getY
|
|
40
|
-
}),
|
|
41
|
-
Plot.axisX({ tickFormat: formatX, ticks: xTicks })
|
|
42
|
-
],
|
|
43
|
-
style: CHART_STYLE,
|
|
44
|
-
width: dims.w,
|
|
45
|
-
x: { domain: [xMin, xMax], label: null, type: 'linear' },
|
|
46
|
-
y: {
|
|
47
|
-
domain: yDomain,
|
|
48
|
-
grid: true,
|
|
49
|
-
label: null,
|
|
50
|
-
tickFormat: formatY,
|
|
51
|
-
ticks: yTicks
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
stylePlot(plot);
|
|
55
|
-
plotRef.current.appendChild(plot);
|
|
56
|
-
const cleanup = setupCrosshair(ref.current, data, d => getX(d), getY, yDomain, d => formatTooltip?.(d) ?? `${formatX(getX(d))}: ${formatY(getY(d))}`, setCrosshair);
|
|
57
|
-
return cleanup;
|
|
58
|
-
}, [
|
|
79
|
+
});
|
|
80
|
+
stylePlot(plot);
|
|
81
|
+
plotRef.current.appendChild(plot);
|
|
82
|
+
const cleanup = setupCrosshair(
|
|
83
|
+
ref.current,
|
|
59
84
|
data,
|
|
60
|
-
|
|
61
|
-
dims.w,
|
|
62
|
-
fillColor,
|
|
63
|
-
formatTooltip,
|
|
64
|
-
formatX,
|
|
65
|
-
formatY,
|
|
66
|
-
getX,
|
|
85
|
+
(d) => getX(d),
|
|
67
86
|
getY,
|
|
68
|
-
xDomain,
|
|
69
|
-
xTicks,
|
|
70
87
|
yDomain,
|
|
71
|
-
|
|
88
|
+
(d) => formatTooltip?.(d) ?? `${formatX(getX(d))}: ${formatY(getY(d))}`,
|
|
89
|
+
setCrosshair
|
|
90
|
+
);
|
|
91
|
+
return cleanup;
|
|
92
|
+
}, [
|
|
93
|
+
data,
|
|
94
|
+
dims.h,
|
|
95
|
+
dims.w,
|
|
96
|
+
fillColor,
|
|
97
|
+
formatTooltip,
|
|
98
|
+
formatX,
|
|
99
|
+
formatY,
|
|
100
|
+
getX,
|
|
101
|
+
getY,
|
|
102
|
+
xDomain,
|
|
103
|
+
xTicks,
|
|
104
|
+
yDomain,
|
|
105
|
+
yTicks
|
|
72
106
|
]);
|
|
73
|
-
return
|
|
74
|
-
|
|
75
|
-
|
|
107
|
+
return /* @__PURE__ */ jsxs(
|
|
108
|
+
"div",
|
|
109
|
+
{
|
|
110
|
+
className: cn("relative aspect-4/1 w-full overflow-clip", className),
|
|
111
|
+
ref,
|
|
112
|
+
...props,
|
|
113
|
+
children: [
|
|
114
|
+
/* @__PURE__ */ jsx("div", { className: "absolute inset-0", ref: plotRef }),
|
|
115
|
+
/* @__PURE__ */ jsx(
|
|
116
|
+
Crosshair,
|
|
117
|
+
{
|
|
118
|
+
color: fillColor,
|
|
119
|
+
containerWidth: dims.w,
|
|
120
|
+
height: dims.h,
|
|
121
|
+
...crosshair
|
|
122
|
+
}
|
|
123
|
+
)
|
|
124
|
+
]
|
|
125
|
+
}
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
);
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export { BarChart } from
|
|
2
|
-
export { LineChart } from
|
|
3
|
-
export * from
|
|
4
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
export { BarChart } from "./bar-chart.js";
|
|
2
|
+
export { LineChart } from "./line-chart.js";
|
|
3
|
+
export * from "./utils.js";
|
|
@@ -3,7 +3,7 @@ export declare const LineChart: {
|
|
|
3
3
|
(props: Omit<LineChartProps<DataPoint> & {
|
|
4
4
|
backgroundColor?: string;
|
|
5
5
|
color?: string;
|
|
6
|
-
}, keyof import("../blend-mode").BlendColors>): import("react
|
|
6
|
+
}, keyof import("../blend-mode").BlendColors>): import("react").JSX.Element;
|
|
7
7
|
displayName: string;
|
|
8
8
|
};
|
|
9
9
|
interface LineChartProps<T extends DataPoint> extends ChartProps<T> {
|
|
@@ -12,4 +12,3 @@ interface LineChartProps<T extends DataPoint> extends ChartProps<T> {
|
|
|
12
12
|
showArea?: boolean;
|
|
13
13
|
}
|
|
14
14
|
export {};
|
|
15
|
-
//# sourceMappingURL=line-chart.d.ts.map
|