@nous-research/ui 0.1.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/README.md +49 -0
- package/dist/assets/filler-bg0.jpg +0 -0
- package/dist/fonts/Collapse-Bold.woff2 +0 -0
- package/dist/fonts/Collapse-BoldItalic.woff2 +0 -0
- package/dist/fonts/Collapse-Italic.woff2 +0 -0
- package/dist/fonts/Collapse-Light.woff2 +0 -0
- package/dist/fonts/Collapse-LightItalic.woff2 +0 -0
- package/dist/fonts/Collapse-Regular.woff2 +0 -0
- package/dist/fonts/Collapse-Thin.woff2 +0 -0
- package/dist/fonts/Collapse-ThinItalic.woff2 +0 -0
- package/dist/fonts/Mondwest-Regular.woff2 +0 -0
- package/dist/fonts/Neuebit-Bold.woff2 +0 -0
- package/dist/fonts/RulesCompressed-Medium.woff2 +0 -0
- package/dist/fonts/RulesCompressed-Regular.woff2 +0 -0
- package/dist/fonts/RulesExpanded-Bold.woff2 +0 -0
- package/dist/fonts/RulesExpanded-Regular.woff2 +0 -0
- package/dist/fonts.d.ts +6 -0
- package/dist/fonts.js +7 -0
- package/dist/fonts.js.map +1 -0
- package/dist/hooks/use-capped-frame.d.ts +2 -0
- package/dist/hooks/use-capped-frame.js +15 -0
- package/dist/hooks/use-capped-frame.js.map +1 -0
- package/dist/hooks/use-css-var-dims.d.ts +1 -0
- package/dist/hooks/use-css-var-dims.js +23 -0
- package/dist/hooks/use-css-var-dims.js.map +1 -0
- package/dist/hooks/use-gpu-tier.d.ts +10 -0
- package/dist/hooks/use-gpu-tier.js +92 -0
- package/dist/hooks/use-gpu-tier.js.map +1 -0
- package/dist/hooks/use-smooth-controls.d.ts +16 -0
- package/dist/hooks/use-smooth-controls.js +202 -0
- package/dist/hooks/use-smooth-controls.js.map +1 -0
- package/dist/index.d.ts +45 -0
- package/dist/index.js +48 -0
- package/dist/index.js.map +1 -0
- package/dist/ui/basic-page.d.ts +7 -0
- package/dist/ui/basic-page.js +9 -0
- package/dist/ui/basic-page.js.map +1 -0
- package/dist/ui/components/animated-count.d.ts +10 -0
- package/dist/ui/components/animated-count.js +88 -0
- package/dist/ui/components/animated-count.js.map +1 -0
- package/dist/ui/components/ascii.d.ts +10 -0
- package/dist/ui/components/ascii.js +62 -0
- package/dist/ui/components/ascii.js.map +1 -0
- package/dist/ui/components/badge.d.ts +2 -0
- package/dist/ui/components/badge.js +5 -0
- package/dist/ui/components/badge.js.map +1 -0
- package/dist/ui/components/badges/nous-girl.d.ts +2 -0
- package/dist/ui/components/badges/nous-girl.js +5 -0
- package/dist/ui/components/badges/nous-girl.js.map +1 -0
- package/dist/ui/components/blend-mode.d.ts +28 -0
- package/dist/ui/components/blend-mode.js +76 -0
- package/dist/ui/components/blend-mode.js.map +1 -0
- package/dist/ui/components/blink.d.ts +6 -0
- package/dist/ui/components/blink.js +7 -0
- package/dist/ui/components/blink.js.map +1 -0
- package/dist/ui/components/button.d.ts +11 -0
- package/dist/ui/components/button.js +52 -0
- package/dist/ui/components/button.js.map +1 -0
- package/dist/ui/components/cursor.d.ts +3 -0
- package/dist/ui/components/cursor.js +57 -0
- package/dist/ui/components/cursor.js.map +1 -0
- package/dist/ui/components/dropdown-menu.d.ts +12 -0
- package/dist/ui/components/dropdown-menu.js +53 -0
- package/dist/ui/components/dropdown-menu.js.map +1 -0
- package/dist/ui/components/fit-text/fit-text.css +42 -0
- package/dist/ui/components/fit-text/index.d.ts +9 -0
- package/dist/ui/components/fit-text/index.js +16 -0
- package/dist/ui/components/fit-text/index.js.map +1 -0
- package/dist/ui/components/graphs/bar-chart.d.ts +12 -0
- package/dist/ui/components/graphs/bar-chart.js +75 -0
- package/dist/ui/components/graphs/bar-chart.js.map +1 -0
- package/dist/ui/components/graphs/index.d.ts +3 -0
- package/dist/ui/components/graphs/index.js +4 -0
- package/dist/ui/components/graphs/index.js.map +1 -0
- package/dist/ui/components/graphs/line-chart.d.ts +14 -0
- package/dist/ui/components/graphs/line-chart.js +117 -0
- package/dist/ui/components/graphs/line-chart.js.map +1 -0
- package/dist/ui/components/graphs/utils.d.ts +52 -0
- package/dist/ui/components/graphs/utils.js +128 -0
- package/dist/ui/components/graphs/utils.js.map +1 -0
- package/dist/ui/components/grid/grid.css +78 -0
- package/dist/ui/components/grid/index.d.ts +2 -0
- package/dist/ui/components/grid/index.js +13 -0
- package/dist/ui/components/grid/index.js.map +1 -0
- package/dist/ui/components/hover-bg.d.ts +1 -0
- package/dist/ui/components/hover-bg.js +8 -0
- package/dist/ui/components/hover-bg.js.map +1 -0
- package/dist/ui/components/icons/arrow.d.ts +6 -0
- package/dist/ui/components/icons/arrow.js +6 -0
- package/dist/ui/components/icons/arrow.js.map +1 -0
- package/dist/ui/components/icons/chevron.d.ts +6 -0
- package/dist/ui/components/icons/chevron.js +6 -0
- package/dist/ui/components/icons/chevron.js.map +1 -0
- package/dist/ui/components/icons/eye.d.ts +2 -0
- package/dist/ui/components/icons/eye.js +5 -0
- package/dist/ui/components/icons/eye.js.map +1 -0
- package/dist/ui/components/icons/gear.d.ts +6 -0
- package/dist/ui/components/icons/gear.js +15 -0
- package/dist/ui/components/icons/gear.js.map +1 -0
- package/dist/ui/components/icons/heart.d.ts +2 -0
- package/dist/ui/components/icons/heart.js +5 -0
- package/dist/ui/components/icons/heart.js.map +1 -0
- package/dist/ui/components/icons/index.d.ts +8 -0
- package/dist/ui/components/icons/index.js +9 -0
- package/dist/ui/components/icons/index.js.map +1 -0
- package/dist/ui/components/icons/link.d.ts +2 -0
- package/dist/ui/components/icons/link.js +5 -0
- package/dist/ui/components/icons/link.js.map +1 -0
- package/dist/ui/components/icons/minus.d.ts +2 -0
- package/dist/ui/components/icons/minus.js +5 -0
- package/dist/ui/components/icons/minus.js.map +1 -0
- package/dist/ui/components/icons/search.d.ts +2 -0
- package/dist/ui/components/icons/search.js +5 -0
- package/dist/ui/components/icons/search.js.map +1 -0
- package/dist/ui/components/leva-client.d.ts +1 -0
- package/dist/ui/components/leva-client.js +12 -0
- package/dist/ui/components/leva-client.js.map +1 -0
- package/dist/ui/components/modal/index.d.ts +8 -0
- package/dist/ui/components/modal/index.js +15 -0
- package/dist/ui/components/modal/index.js.map +1 -0
- package/dist/ui/components/modal/modal.css +36 -0
- package/dist/ui/components/overlays/glitch.d.ts +6 -0
- package/dist/ui/components/overlays/glitch.js +191 -0
- package/dist/ui/components/overlays/glitch.js.map +1 -0
- package/dist/ui/components/overlays/greys.d.ts +6 -0
- package/dist/ui/components/overlays/greys.js +300 -0
- package/dist/ui/components/overlays/greys.js.map +1 -0
- package/dist/ui/components/overlays/index.d.ts +44 -0
- package/dist/ui/components/overlays/index.js +125 -0
- package/dist/ui/components/overlays/index.js.map +1 -0
- package/dist/ui/components/overlays/noise.d.ts +6 -0
- package/dist/ui/components/overlays/noise.js +115 -0
- package/dist/ui/components/overlays/noise.js.map +1 -0
- package/dist/ui/components/overlays/vignette.d.ts +6 -0
- package/dist/ui/components/overlays/vignette.js +40 -0
- package/dist/ui/components/overlays/vignette.js.map +1 -0
- package/dist/ui/components/progress.d.ts +9 -0
- package/dist/ui/components/progress.js +12 -0
- package/dist/ui/components/progress.js.map +1 -0
- package/dist/ui/components/scene-canvas.d.ts +15 -0
- package/dist/ui/components/scene-canvas.js +117 -0
- package/dist/ui/components/scene-canvas.js.map +1 -0
- package/dist/ui/components/scramble.d.ts +9 -0
- package/dist/ui/components/scramble.js +61 -0
- package/dist/ui/components/scramble.js.map +1 -0
- package/dist/ui/components/selection-switcher.d.ts +1 -0
- package/dist/ui/components/selection-switcher.js +29 -0
- package/dist/ui/components/selection-switcher.js.map +1 -0
- package/dist/ui/components/shader.d.ts +7 -0
- package/dist/ui/components/shader.js +41 -0
- package/dist/ui/components/shader.js.map +1 -0
- package/dist/ui/components/stats.d.ts +9 -0
- package/dist/ui/components/stats.js +7 -0
- package/dist/ui/components/stats.js.map +1 -0
- package/dist/ui/components/tv.d.ts +3 -0
- package/dist/ui/components/tv.js +163 -0
- package/dist/ui/components/tv.js.map +1 -0
- package/dist/ui/components/typography/h1.d.ts +11 -0
- package/dist/ui/components/typography/h1.js +8 -0
- package/dist/ui/components/typography/h1.js.map +1 -0
- package/dist/ui/components/typography/h2.d.ts +11 -0
- package/dist/ui/components/typography/h2.js +8 -0
- package/dist/ui/components/typography/h2.js.map +1 -0
- package/dist/ui/components/typography/index.d.ts +15 -0
- package/dist/ui/components/typography/index.js +29 -0
- package/dist/ui/components/typography/index.js.map +1 -0
- package/dist/ui/components/typography/legend.d.ts +6 -0
- package/dist/ui/components/typography/legend.js +7 -0
- package/dist/ui/components/typography/legend.js.map +1 -0
- package/dist/ui/components/typography/small.d.ts +2 -0
- package/dist/ui/components/typography/small.js +7 -0
- package/dist/ui/components/typography/small.js.map +1 -0
- package/dist/ui/components/watchlist.d.ts +11 -0
- package/dist/ui/components/watchlist.js +27 -0
- package/dist/ui/components/watchlist.js.map +1 -0
- package/dist/ui/fonts.css +63 -0
- package/dist/ui/footer.d.ts +1 -0
- package/dist/ui/footer.js +19 -0
- package/dist/ui/footer.js.map +1 -0
- package/dist/ui/globals.css +340 -0
- package/dist/ui/header.d.ts +1 -0
- package/dist/ui/header.js +22 -0
- package/dist/ui/header.js.map +1 -0
- package/dist/ui/layout-wrapper.d.ts +1 -0
- package/dist/ui/layout-wrapper.js +5 -0
- package/dist/ui/layout-wrapper.js.map +1 -0
- package/dist/utils/color.d.ts +4 -0
- package/dist/utils/color.js +14 -0
- package/dist/utils/color.js.map +1 -0
- package/dist/utils/index.d.ts +15 -0
- package/dist/utils/index.js +48 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/poly.d.ts +8 -0
- package/dist/utils/poly.js +3 -0
- package/dist/utils/poly.js.map +1 -0
- package/package.json +95 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cva } from 'class-variance-authority';
|
|
3
|
+
import { cloneElement } from 'react';
|
|
4
|
+
import { cn } from '../../utils';
|
|
5
|
+
import { Typography } from './typography';
|
|
6
|
+
const buttonVariants = cva([
|
|
7
|
+
'group relative grid cursor-pointer grid-cols-[auto_1fr_auto] items-center',
|
|
8
|
+
'px-[.9em_.75em] py-[1.25em]',
|
|
9
|
+
'leading-0 font-bold tracking-[0.2em] uppercase',
|
|
10
|
+
'shadow-[inset_-1px_-1px_0_0_#00000080,inset_1px_1px_0_0_#ffffff80]',
|
|
11
|
+
'active:invert',
|
|
12
|
+
'disabled:pointer-events-none disabled:bg-midground/15 disabled:text-midground disabled:shadow-none'
|
|
13
|
+
], {
|
|
14
|
+
compoundVariants: [
|
|
15
|
+
{
|
|
16
|
+
class: 'bg-midground text-background-base',
|
|
17
|
+
invert: false,
|
|
18
|
+
outlined: false
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
class: 'bg-midground/15 text-midground',
|
|
22
|
+
invert: true,
|
|
23
|
+
outlined: false
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
class: 'shadow-midground',
|
|
27
|
+
invert: false,
|
|
28
|
+
outlined: true
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
class: 'shadow-[inset_-1px_-1px_0_0_#ffffff12,inset_1px_1px_0_0_#ffffff29]',
|
|
32
|
+
invert: true,
|
|
33
|
+
outlined: true
|
|
34
|
+
}
|
|
35
|
+
],
|
|
36
|
+
defaultVariants: { invert: false, outlined: false },
|
|
37
|
+
variants: {
|
|
38
|
+
invert: {
|
|
39
|
+
true: 'shadow-[inset_-1px_-1px_0_0_#00000080,inset_1px_1px_0_0_#ffffff29]'
|
|
40
|
+
},
|
|
41
|
+
outlined: {
|
|
42
|
+
true: 'text-midground bg-transparent'
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
const IconSlot = ({ icon, side }) => (_jsxs(_Fragment, { children: [_jsx("span", { className: "w-5" }), _jsx("span", { className: cn('absolute top-1/2 -translate-y-1/2', side === 'left' ? 'left-3' : 'right-3'), children: typeof icon === 'object'
|
|
47
|
+
? cloneElement(icon, {
|
|
48
|
+
className: 'size-3.5'
|
|
49
|
+
})
|
|
50
|
+
: icon })] }));
|
|
51
|
+
export const Button = ({ children, className, invert, outlined, prefix, suffix, ...props }) => (_jsxs(Typography, { as: "button", className: cn(buttonVariants({ invert, outlined }), className), mono: true, ...props, children: [_jsx("span", { "aria-hidden": true, className: "arc-border opacity-0 transition-opacity duration-200 group-hover:opacity-100 group-focus-visible:opacity-100 group-active:opacity-100" }), prefix && _jsx(IconSlot, { icon: prefix, side: "left" }), children, suffix && _jsx(IconSlot, { icon: suffix, side: "right" })] }));
|
|
52
|
+
//# sourceMappingURL=button.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"button.js","sourceRoot":"","sources":["../../../src/ui/components/button.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAqB,MAAM,0BAA0B,CAAA;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAA;AAEpC,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAA;AAEhC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAEzC,MAAM,cAAc,GAAG,GAAG,CACxB;IACE,2EAA2E;IAC3E,6BAA6B;IAC7B,gDAAgD;IAChD,oEAAoE;IACpE,eAAe;IACf,oGAAoG;CACrG,EACD;IACE,gBAAgB,EAAE;QAChB;YACE,KAAK,EAAE,mCAAmC;YAC1C,MAAM,EAAE,KAAK;YACb,QAAQ,EAAE,KAAK;SAChB;QACD;YACE,KAAK,EAAE,gCAAgC;YACvC,MAAM,EAAE,IAAI;YACZ,QAAQ,EAAE,KAAK;SAChB;QACD;YACE,KAAK,EAAE,kBAAkB;YACzB,MAAM,EAAE,KAAK;YACb,QAAQ,EAAE,IAAI;SACf;QACD;YACE,KAAK,EACH,oEAAoE;YACtE,MAAM,EAAE,IAAI;YACZ,QAAQ,EAAE,IAAI;SACf;KACF;IACD,eAAe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as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useRef } from 'react';
|
|
4
|
+
const INTERACTIVE = 'a, button, [role="button"], input, textarea, select, [data-cursor]';
|
|
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
|
+
export function Cursor({ scale = 0.8 }) {
|
|
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(document, 'mousemove', (e) => {
|
|
21
|
+
const { clientX: x, clientY: y } = e;
|
|
22
|
+
root.style.translate = `${x}px ${y}px`;
|
|
23
|
+
root.style.opacity = '1';
|
|
24
|
+
}, { passive: true }),
|
|
25
|
+
on(document, 'mouseover', (e) => {
|
|
26
|
+
const isPtr = !!e.target.closest?.(INTERACTIVE);
|
|
27
|
+
arrow.style.opacity = isPtr ? '0' : '1';
|
|
28
|
+
ptr.style.opacity = isPtr ? '1' : '0';
|
|
29
|
+
}, { passive: true }),
|
|
30
|
+
on(document, 'mousedown', () => {
|
|
31
|
+
root.style.transform = 'translate(1px, 1px)';
|
|
32
|
+
}),
|
|
33
|
+
on(document, 'mouseup', () => {
|
|
34
|
+
root.style.transform = '';
|
|
35
|
+
}),
|
|
36
|
+
on(document.documentElement, 'mouseleave', () => {
|
|
37
|
+
root.style.opacity = '0';
|
|
38
|
+
}),
|
|
39
|
+
on(document.documentElement, 'mouseenter', () => {
|
|
40
|
+
root.style.opacity = '1';
|
|
41
|
+
})
|
|
42
|
+
].reduce((_, fn) => fn, undefined);
|
|
43
|
+
}, []);
|
|
44
|
+
return (_jsxs("div", { "aria-hidden": true, ref: $root, style: {
|
|
45
|
+
filter: 'drop-shadow(1px 2px 0 #000)',
|
|
46
|
+
height: 32 * scale,
|
|
47
|
+
left: 0,
|
|
48
|
+
opacity: 0,
|
|
49
|
+
pointerEvents: 'none',
|
|
50
|
+
position: 'fixed',
|
|
51
|
+
top: 0,
|
|
52
|
+
width: 32 * scale,
|
|
53
|
+
willChange: 'translate',
|
|
54
|
+
zIndex: 9999
|
|
55
|
+
}, children: [_jsx("div", { ref: $arrow, style: { inset: 0, position: 'absolute' }, children: _jsx("svg", { viewBox: "0 0 16 16", children: _jsx("path", { d: "M1 1L1 14L5 10L8 15L10 14L7 9L12 9L1 1Z", fill: "#fff", stroke: "#000", strokeLinejoin: "round", strokeWidth: 1 }) }) }), _jsx("div", { ref: $ptr, style: { inset: 0, opacity: 0, position: 'absolute' }, children: _jsx("svg", { viewBox: "0 0 28 29", children: _jsx("path", { d: HAND, fill: "#fff", stroke: "#000", strokeLinejoin: "round", strokeWidth: 2, style: { paintOrder: 'stroke fill' } }) }) })] }));
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=cursor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cursor.js","sourceRoot":"","sources":["../../../src/ui/components/cursor.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;AAEzC,MAAM,WAAW,GACf,oEAAoE,CAAA;AAEtE,MAAM,IAAI,GACR,26BAA26B,CAAA;AAE76B,MAAM,UAAU,MAAM,CAAC,EAAE,KAAK,GAAG,GAAG,EAAsB;IACxD,MAAM,KAAK,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAA;IAC1C,MAAM,MAAM,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAA;IAC3C,MAAM,IAAI,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAA;IAEzC,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,CAAA;QAExE,IAAI,CAAC,IAAI,IAAI,CAAC,KAAK,IAAI,CAAC,GAAG,EAAE,CAAC;YAC5B,OAAM;QACR,CAAC;QAED,MAAM,EAAE,GAAG,CACT,EAAe,EACf,EAAU,EACV,EAA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AM,EACX,MAAM,EAAC,MAAM,EACb,cAAc,EAAC,OAAO,EACtB,WAAW,EAAE,CAAC,EACd,KAAK,EAAE,EAAE,UAAU,EAAE,aAAa,EAAE,GACpC,GACE,GACF,IACF,CACP,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
type Direction = 'down' | 'up' | 'left' | 'right';
|
|
2
|
+
export declare function DropdownMenu<T extends string>({ className, direction, onChange, options, value }: {
|
|
3
|
+
className?: string;
|
|
4
|
+
direction?: Direction;
|
|
5
|
+
onChange: (value: T) => void;
|
|
6
|
+
options: {
|
|
7
|
+
label: string;
|
|
8
|
+
value: T;
|
|
9
|
+
}[];
|
|
10
|
+
value: T;
|
|
11
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useId, useRef, useState } from 'react';
|
|
4
|
+
import { cn } from '../../utils';
|
|
5
|
+
const font = 'font-mondwest text-[.9375rem] leading-[1.4] tracking-[0.1875rem]';
|
|
6
|
+
export function DropdownMenu({ className, direction = 'down', onChange, options, value }) {
|
|
7
|
+
const id = useId();
|
|
8
|
+
const [open, setOpen] = useState(false);
|
|
9
|
+
const ref = useRef(null);
|
|
10
|
+
const anchor = `--dropdown-${id.replace(/:/g, '')}`;
|
|
11
|
+
const panelStyle = {
|
|
12
|
+
position: 'fixed',
|
|
13
|
+
positionAnchor: anchor,
|
|
14
|
+
positionTryFallbacks: direction === 'left' || direction === 'right'
|
|
15
|
+
? 'flip-inline, flip-block'
|
|
16
|
+
: 'flip-block, flip-inline',
|
|
17
|
+
...(direction === 'up' && {
|
|
18
|
+
left: 'calc(anchor(left) - 0.5rem)',
|
|
19
|
+
top: 'calc(anchor(top) + 1rem)',
|
|
20
|
+
transform: 'translateY(-100%)'
|
|
21
|
+
}),
|
|
22
|
+
...(direction === 'right' && {
|
|
23
|
+
left: 'calc(anchor(right))',
|
|
24
|
+
top: 'calc(anchor(top) - 0.5rem)'
|
|
25
|
+
}),
|
|
26
|
+
...(direction === 'left' && {
|
|
27
|
+
left: 'calc(anchor(left) - 1px)',
|
|
28
|
+
top: 'calc(anchor(top) - 0.5rem)',
|
|
29
|
+
transform: 'translateX(-100%)'
|
|
30
|
+
}),
|
|
31
|
+
...(direction === 'down' && {
|
|
32
|
+
left: 'calc(anchor(left) - 0.5rem)',
|
|
33
|
+
top: 'calc(anchor(top) - 0.5rem)'
|
|
34
|
+
})
|
|
35
|
+
};
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
if (!open) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
const ac = new AbortController();
|
|
41
|
+
document.addEventListener('mousedown', e => {
|
|
42
|
+
if (!ref.current?.contains(e.target)) {
|
|
43
|
+
setOpen(false);
|
|
44
|
+
}
|
|
45
|
+
}, { signal: ac.signal });
|
|
46
|
+
return () => ac.abort();
|
|
47
|
+
}, [open]);
|
|
48
|
+
return (_jsxs("span", { className: cn('relative inline-block align-top', className), ref: ref, children: [_jsxs("span", { className: cn(font, 'inline-block cursor-pointer hover:underline'), onClick: () => setOpen(!open), style: { anchorName: anchor }, children: [options.find(o => o.value === value)?.label ?? value, ' ', open ? '↑' : '↓'] }), open && (_jsx("div", { className: "bg-background-base z-50 flex flex-col", style: panelStyle, children: options.map(o => (_jsx("span", { className: cn(font, 'block cursor-pointer p-2 whitespace-nowrap', o.value === value ? 'underline' : 'hover:bg-midground/10'), onClick: () => {
|
|
49
|
+
onChange(o.value);
|
|
50
|
+
setOpen(false);
|
|
51
|
+
}, children: o.label }, o.value))) }))] }));
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=dropdown-menu.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dropdown-menu.js","sourceRoot":"","sources":["../../../src/ui/components/dropdown-menu.tsx"],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K,KAAK,KAAK,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,uBAAuB,CAC1D,EAED,OAAO,EAAE,GAAG,EAAE;wBACZ,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAA;wBACjB,OAAO,CAAC,KAAK,CAAC,CAAA;oBAChB,CAAC,YAEA,CAAC,CAAC,KAAK,IANH,CAAC,CAAC,KAAK,CAOP,CACR,CAAC,GACE,CACP,IACI,CACR,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
.fit-text {
|
|
2
|
+
--fit-captured-length: initial;
|
|
3
|
+
--fit-support-sentinel: var(--fit-captured-length, 9999px);
|
|
4
|
+
|
|
5
|
+
display: flex;
|
|
6
|
+
container-type: inline-size;
|
|
7
|
+
|
|
8
|
+
> [aria-hidden] {
|
|
9
|
+
visibility: hidden;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
> :not([aria-hidden]) {
|
|
13
|
+
flex-grow: 1;
|
|
14
|
+
container-type: inline-size;
|
|
15
|
+
|
|
16
|
+
--fit-captured-length: 100cqi;
|
|
17
|
+
--fit-available-space: var(--fit-captured-length);
|
|
18
|
+
|
|
19
|
+
> * {
|
|
20
|
+
--fit-support-sentinel: inherit;
|
|
21
|
+
--fit-captured-length: 100cqi;
|
|
22
|
+
--fit-ratio: tan(
|
|
23
|
+
atan2(
|
|
24
|
+
var(--fit-available-space),
|
|
25
|
+
var(--fit-available-space) - var(--fit-captured-length)
|
|
26
|
+
)
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
display: block;
|
|
30
|
+
inline-size: var(--fit-available-space);
|
|
31
|
+
font-size: clamp(
|
|
32
|
+
var(--fit-min, 1em),
|
|
33
|
+
1em * var(--fit-ratio),
|
|
34
|
+
var(--fit-max, infinity * 1px) - var(--fit-support-sentinel)
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
@container (inline-size > 0) {
|
|
38
|
+
white-space: nowrap;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type PolyProps } from '../../../utils';
|
|
2
|
+
export declare const FitText: import("../../..").PolyComponent<"span", OwnProps>;
|
|
3
|
+
interface OwnProps {
|
|
4
|
+
children: string;
|
|
5
|
+
max?: string;
|
|
6
|
+
min?: string;
|
|
7
|
+
}
|
|
8
|
+
export type FitTextProps<T extends React.ElementType = 'span'> = PolyProps<T, OwnProps>;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { createElement } from 'react';
|
|
4
|
+
import { cn, polyRef } from '../../../utils';
|
|
5
|
+
export const FitText = polyRef(({ as, children, className, max, min = '1em', style: baseStyle, ...rest }, ref) => {
|
|
6
|
+
if (typeof children !== 'string') {
|
|
7
|
+
return null;
|
|
8
|
+
}
|
|
9
|
+
const style = {
|
|
10
|
+
'--fit-max': max ?? 'infinity * 1px',
|
|
11
|
+
'--fit-min': min,
|
|
12
|
+
...baseStyle
|
|
13
|
+
};
|
|
14
|
+
return createElement((as ?? 'span'), { ...rest, className: cn('fit-text', className), ref, style }, _jsxs(_Fragment, { children: [_jsx("span", { children: _jsx("span", { children: children }) }), _jsx("span", { "aria-hidden": "true", children: children })] }));
|
|
15
|
+
});
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/ui/components/fit-text/index.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAErC,OAAO,EAAE,EAAE,EAAkB,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAE5D,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAC5B,CACE,EAAE,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,EAAE,GAAG,GAAG,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,EACxE,GAAG,EACH,EAAE;IACF,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE,CAAC;QACjC,OAAO,IAAI,CAAA;IACb,CAAC;IAED,MAAM,KAAK,GAAG;QACZ,WAAW,EAAE,GAAG,IAAI,gBAAgB;QACpC,WAAW,EAAE,GAAG;QAChB,GAAG,SAAS;KACU,CAAA;IAExB,OAAO,aAAa,CAClB,CAAC,EAAE,IAAI,MAAM,CAAsB,EACnC,EAAE,GAAG,IAAI,EAAE,SAAS,EAAE,EAAE,CAAC,UAAU,EAAE,SAAS,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,EAC7D,8BACE,yBACE,yBAAO,QAAQ,GAAQ,GAClB,EAEP,8BAAkB,MAAM,YAAE,QAAQ,GAAQ,IACzC,CACJ,CAAA;AACH,CAAC,CACF,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type ChartProps, type DataPoint } from './utils';
|
|
2
|
+
export declare const BarChart: {
|
|
3
|
+
(props: Omit<BarChartProps<DataPoint> & {
|
|
4
|
+
backgroundColor?: string;
|
|
5
|
+
color?: string;
|
|
6
|
+
}, keyof import("../blend-mode").BlendColors>): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
displayName: string;
|
|
8
|
+
};
|
|
9
|
+
interface BarChartProps<T extends DataPoint> extends ChartProps<T> {
|
|
10
|
+
xDomain?: [number, number];
|
|
11
|
+
}
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _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';
|
|
6
|
+
import { accessor, CHART_MARGINS, CHART_STYLE, Crosshair, setupCrosshair, stylePlot, useDims, withChartBlend } from './utils';
|
|
7
|
+
export const BarChart = withChartBlend(({ backgroundColor: _, className, color: fillColor, data = [], formatTooltip, formatX: formatXProp, formatY: formatYProp, x = 'label', xDomain, xTicks = [0, 50000, 100000], y = 'value', yDomain = [0, 10], yTicks = [10, 8, 4, 2], ...props }) => {
|
|
8
|
+
const ref = useRef(null);
|
|
9
|
+
const plotRef = useRef(null);
|
|
10
|
+
const [crosshair, setCrosshair] = useState({ x: null });
|
|
11
|
+
const dims = useDims(ref);
|
|
12
|
+
const formatX = useCallback((v) => formatXProp?.(v) ??
|
|
13
|
+
(typeof v === 'number' ? v.toLocaleString('en-US') : String(v)), [formatXProp]);
|
|
14
|
+
const formatY = useCallback((v) => formatYProp?.(v) ?? String(v), [formatYProp]);
|
|
15
|
+
const getX = useMemo(() => accessor(x), [x]);
|
|
16
|
+
const getY = useMemo(() => accessor(y), [y]);
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
if (!ref.current ||
|
|
19
|
+
!plotRef.current ||
|
|
20
|
+
!data.length ||
|
|
21
|
+
!dims.h ||
|
|
22
|
+
!dims.w) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
plotRef.current.innerHTML = '';
|
|
26
|
+
const [xMin, xMax] = [
|
|
27
|
+
xDomain?.[0] ?? 0,
|
|
28
|
+
xDomain?.[1] ?? Math.max(...data.map(d => getX(d)))
|
|
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
|
+
}, [
|
|
59
|
+
data,
|
|
60
|
+
dims.h,
|
|
61
|
+
dims.w,
|
|
62
|
+
fillColor,
|
|
63
|
+
formatTooltip,
|
|
64
|
+
formatX,
|
|
65
|
+
formatY,
|
|
66
|
+
getX,
|
|
67
|
+
getY,
|
|
68
|
+
xDomain,
|
|
69
|
+
xTicks,
|
|
70
|
+
yDomain,
|
|
71
|
+
yTicks
|
|
72
|
+
]);
|
|
73
|
+
return (_jsxs("div", { className: cn('relative aspect-4/1 w-full overflow-clip', className), ref: ref, ...props, children: [_jsx("div", { className: "absolute inset-0", ref: plotRef }), _jsx(Crosshair, { color: fillColor, containerWidth: dims.w, height: dims.h, ...crosshair })] }));
|
|
74
|
+
});
|
|
75
|
+
//# sourceMappingURL=bar-chart.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bar-chart.js","sourceRoot":"","sources":["../../../../src/ui/components/graphs/bar-chart.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,KAAK,IAAI,MAAM,oBAAoB,CAAA;AAC1C,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CA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AET,cAAK,SAAS,EAAC,kBAAkB,EAAC,GAAG,EAAE,OAAO,GAAI,EAElD,KAAC,SAAS,IACR,KAAK,EAAE,SAAS,EAChB,cAAc,EAAE,IAAI,CAAC,CAAC,EACtB,MAAM,EAAE,IAAI,CAAC,CAAC,KACV,SAAS,GACb,IACE,CACP,CAAA;AACH,CAAC,CACF,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/ui/components/graphs/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAExC,cAAc,SAAS,CAAA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type ChartProps, type DataPoint } from './utils';
|
|
2
|
+
export declare const LineChart: {
|
|
3
|
+
(props: Omit<LineChartProps<DataPoint> & {
|
|
4
|
+
backgroundColor?: string;
|
|
5
|
+
color?: string;
|
|
6
|
+
}, keyof import("../blend-mode").BlendColors>): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
displayName: string;
|
|
8
|
+
};
|
|
9
|
+
interface LineChartProps<T extends DataPoint> extends ChartProps<T> {
|
|
10
|
+
curve?: 'basis' | 'catmull-rom' | 'linear' | 'natural' | 'step';
|
|
11
|
+
series?: keyof T;
|
|
12
|
+
showArea?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _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';
|
|
6
|
+
import { accessor, CHART_MARGINS, CHART_STYLE, Crosshair, setupCrosshair, stylePlot, useDims, withChartBlend } from './utils';
|
|
7
|
+
export const LineChart = withChartBlend(({ backgroundColor: _, className, color: strokeColor, curve = 'natural', data = [], formatTooltip, formatX: formatXProp, formatY: formatYProp, series = 'series', showArea = false, x = 'label', xTicks, y = 'value', yDomain = [0, 0.5], yTicks = 4, ...props }) => {
|
|
8
|
+
const ref = useRef(null);
|
|
9
|
+
const plotRef = useRef(null);
|
|
10
|
+
const [hovered, setHovered] = useState(null);
|
|
11
|
+
const [crosshair, setCrosshair] = useState({ x: null });
|
|
12
|
+
const dims = useDims(ref);
|
|
13
|
+
const formatX = useCallback((v) => formatXProp?.(v) ??
|
|
14
|
+
(v >= 1e3 ? `${v / 1e3}k` : `${v}`), [formatXProp]);
|
|
15
|
+
const formatY = useCallback((v) => formatYProp?.(v) ?? `${Math.round(v * 100)}%`, [formatYProp]);
|
|
16
|
+
const getX = useMemo(() => accessor(x), [x]);
|
|
17
|
+
const getY = useMemo(() => accessor(y), [y]);
|
|
18
|
+
const getZ = useCallback((d) => d[series], [series]);
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
if (!ref.current ||
|
|
21
|
+
!plotRef.current ||
|
|
22
|
+
!data.length ||
|
|
23
|
+
!dims.h ||
|
|
24
|
+
!dims.w) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
plotRef.current.innerHTML = '';
|
|
28
|
+
const hasSeries = data.some(d => d[series] !== undefined);
|
|
29
|
+
const seriesIdx = hasSeries
|
|
30
|
+
? data.reduce((acc, d, i) => { var _a; return ((acc[_a = d[series]] ?? (acc[_a] = i)), acc); }, {})
|
|
31
|
+
: {};
|
|
32
|
+
const n = Object.keys(seriesIdx).length;
|
|
33
|
+
const opacity = (d) => {
|
|
34
|
+
if (!hasSeries) {
|
|
35
|
+
return 1;
|
|
36
|
+
}
|
|
37
|
+
if (hovered) {
|
|
38
|
+
return d[series] === hovered[series] ? 1 : 0.2;
|
|
39
|
+
}
|
|
40
|
+
return 1 - (seriesIdx[d[series]] / Math.max(n - 1, 1)) * 0.2;
|
|
41
|
+
};
|
|
42
|
+
const lineOpts = {
|
|
43
|
+
curve,
|
|
44
|
+
x: getX,
|
|
45
|
+
y: getY,
|
|
46
|
+
...(hasSeries && { z: getZ })
|
|
47
|
+
};
|
|
48
|
+
const plot = Plot.plot({
|
|
49
|
+
...CHART_MARGINS,
|
|
50
|
+
height: dims.h,
|
|
51
|
+
marks: [
|
|
52
|
+
...(showArea
|
|
53
|
+
? [
|
|
54
|
+
Plot.areaY(data, {
|
|
55
|
+
...lineOpts,
|
|
56
|
+
fill: strokeColor,
|
|
57
|
+
fillOpacity: 0.15,
|
|
58
|
+
y1: yDomain[0]
|
|
59
|
+
})
|
|
60
|
+
]
|
|
61
|
+
: []),
|
|
62
|
+
Plot.lineY(data, {
|
|
63
|
+
...lineOpts,
|
|
64
|
+
stroke: 'transparent',
|
|
65
|
+
strokeWidth: 16
|
|
66
|
+
}),
|
|
67
|
+
Plot.lineY(data, {
|
|
68
|
+
...lineOpts,
|
|
69
|
+
stroke: strokeColor,
|
|
70
|
+
strokeOpacity: opacity,
|
|
71
|
+
strokeWidth: 1.5
|
|
72
|
+
})
|
|
73
|
+
],
|
|
74
|
+
style: { ...CHART_STYLE, fontStretch: 'expanded' },
|
|
75
|
+
width: dims.w,
|
|
76
|
+
x: { label: null, tickFormat: formatX, ticks: xTicks },
|
|
77
|
+
y: {
|
|
78
|
+
domain: yDomain,
|
|
79
|
+
grid: true,
|
|
80
|
+
label: null,
|
|
81
|
+
tickFormat: formatY,
|
|
82
|
+
ticks: yTicks
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
plot.addEventListener('input', () => setHovered(plot.value));
|
|
86
|
+
stylePlot(plot);
|
|
87
|
+
plot.querySelectorAll('g[aria-label="line"] path').forEach(el => Object.assign(el.style, {
|
|
88
|
+
transition: 'stroke-opacity 0.2s'
|
|
89
|
+
}));
|
|
90
|
+
plotRef.current.appendChild(plot);
|
|
91
|
+
const cleanup = setupCrosshair(ref.current, data, d => getX(d), getY, yDomain, d => formatTooltip?.(d) ?? `${formatX(getX(d))}: ${formatY(getY(d))}`, setCrosshair, hasSeries ? d => getZ(d) : undefined);
|
|
92
|
+
return () => {
|
|
93
|
+
cleanup();
|
|
94
|
+
plot.parentNode && plot.remove();
|
|
95
|
+
};
|
|
96
|
+
}, [
|
|
97
|
+
curve,
|
|
98
|
+
data,
|
|
99
|
+
dims.h,
|
|
100
|
+
dims.w,
|
|
101
|
+
formatTooltip,
|
|
102
|
+
formatX,
|
|
103
|
+
formatY,
|
|
104
|
+
getX,
|
|
105
|
+
getY,
|
|
106
|
+
getZ,
|
|
107
|
+
hovered,
|
|
108
|
+
series,
|
|
109
|
+
showArea,
|
|
110
|
+
strokeColor,
|
|
111
|
+
xTicks,
|
|
112
|
+
yDomain,
|
|
113
|
+
yTicks
|
|
114
|
+
]);
|
|
115
|
+
return (_jsxs("div", { className: cn('relative aspect-4/1 w-full overflow-clip', className), ref: ref, ...props, children: [_jsx("div", { className: "absolute inset-0", ref: plotRef }), _jsx(Crosshair, { color: strokeColor, containerWidth: dims.w, height: dims.h, ...crosshair })] }));
|
|
116
|
+
});
|
|
117
|
+
//# sourceMappingURL=line-chart.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"line-chart.js","sourceRoot":"","sources":["../../../../src/ui/components/graphs/line-chart.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,KAAK,IAAI,MAAM,oBAAoB,CAAA;AAC1C,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAEzE,OAAO,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAA;AAEnC,OAAO,EACL,QAAQ,EACR,aAAa,EACb,WAAW,EAEX,SAAS,EAGT,cAAc,EACd,SAAS,EACT,OAAO,EACP,cAAc,EACf,MAAM,SAAS,CAAA;AAEhB,MAAM,CAAC,MAAM,SAAS,GAAG,cAAc,CACrC,CAAsB,EACpB,eAAe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AAC,CAAC;QACN,IAAI,CAAC,CAAC;QACN,aAAa;QACb,OAAO;QACP,OAAO;QACP,IAAI;QACJ,IAAI;QACJ,IAAI;QACJ,OAAO;QACP,MAAM;QACN,QAAQ;QACR,WAAW;QACX,MAAM;QACN,OAAO;QACP,MAAM;KACP,CAAC,CAAA;IAEF,OAAO,CACL,eACE,SAAS,EAAE,EAAE,CAAC,0CAA0C,EAAE,SAAS,CAAC,EACpE,GAAG,EAAE,GAAG,KACJ,KAAK,aAET,cAAK,SAAS,EAAC,kBAAkB,EAAC,GAAG,EAAE,OAAO,GAAI,EAElD,KAAC,SAAS,IACR,KAAK,EAAE,WAAW,EAClB,cAAc,EAAE,IAAI,CAAC,CAAC,EACtB,MAAM,EAAE,IAAI,CAAC,CAAC,KACV,SAAS,GACb,IACE,CACP,CAAA;AACH,CAAC,CACF,CAAA"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { type ComponentType, type HTMLAttributes, type RefObject } from 'react';
|
|
2
|
+
import { type BlendColors, type BlendModeProps } from '../blend-mode';
|
|
3
|
+
export declare const accessor: <T, R>(key: ((d: T) => R) | keyof T) => (d: T) => R;
|
|
4
|
+
export declare const CHART_MARGINS: {
|
|
5
|
+
readonly marginBottom: 24;
|
|
6
|
+
readonly marginLeft: 36;
|
|
7
|
+
readonly marginRight: 12;
|
|
8
|
+
readonly marginTop: 8;
|
|
9
|
+
};
|
|
10
|
+
export declare const CHART_STYLE: {
|
|
11
|
+
readonly background: "transparent";
|
|
12
|
+
readonly color: "var(--midground)";
|
|
13
|
+
readonly fontFamily: "var(--font-mono), monospace";
|
|
14
|
+
readonly fontSize: "11px";
|
|
15
|
+
readonly overflow: "hidden";
|
|
16
|
+
};
|
|
17
|
+
export declare const stylePlot: (plot: HTMLElement) => void;
|
|
18
|
+
export declare const useDims: (ref: RefObject<HTMLElement | null>) => {
|
|
19
|
+
h: number;
|
|
20
|
+
w: number;
|
|
21
|
+
};
|
|
22
|
+
export declare const Crosshair: ({ color, containerWidth, height, points, x }: CrosshairState & {
|
|
23
|
+
color?: string;
|
|
24
|
+
containerWidth: number;
|
|
25
|
+
height: number;
|
|
26
|
+
}) => import("react/jsx-runtime").JSX.Element | null;
|
|
27
|
+
export declare const setupCrosshair: <T extends DataPoint>(container: HTMLElement, data: T[], getX: (d: T) => number, getY: (d: T) => number, yDomain: [number, number], formatTooltip: (d: T) => string, onUpdate: (state: CrosshairState) => void, getZ?: (d: T) => unknown) => () => void;
|
|
28
|
+
export declare const withChartBlend: <P extends BlendModeProps>(Component: ComponentType<P>) => {
|
|
29
|
+
(props: Omit<P, keyof BlendColors>): import("react/jsx-runtime").JSX.Element;
|
|
30
|
+
displayName: string;
|
|
31
|
+
};
|
|
32
|
+
export type DataPoint = Record<string, unknown>;
|
|
33
|
+
export interface CrosshairPoint {
|
|
34
|
+
dotY: number;
|
|
35
|
+
tooltip: string;
|
|
36
|
+
}
|
|
37
|
+
export interface CrosshairState {
|
|
38
|
+
points?: CrosshairPoint[];
|
|
39
|
+
x: null | number;
|
|
40
|
+
}
|
|
41
|
+
export interface ChartProps<T = DataPoint> extends Omit<HTMLAttributes<HTMLDivElement>, 'children'> {
|
|
42
|
+
data?: T[];
|
|
43
|
+
formatTooltip?: (d: T) => string;
|
|
44
|
+
formatX?: (v: unknown) => string;
|
|
45
|
+
formatY?: (v: number) => string;
|
|
46
|
+
height?: number;
|
|
47
|
+
x?: ((d: T) => unknown) | keyof T;
|
|
48
|
+
xTicks?: number | number[];
|
|
49
|
+
y?: ((d: T) => number) | keyof T;
|
|
50
|
+
yDomain?: [number, number];
|
|
51
|
+
yTicks?: number | number[];
|
|
52
|
+
}
|