@benchlabs/ui 0.0.0-stage → 1.2.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/LICENSE +48 -0
- package/README.md +42 -2
- package/dist/bench/filter.d.ts +15 -0
- package/dist/bench/filter.js +161 -0
- package/dist/bench/page-tabs.d.ts +4 -0
- package/dist/bench/page-tabs.js +18 -0
- package/dist/bench/plot-figure.d.ts +19 -0
- package/dist/bench/plot-figure.js +78 -0
- package/dist/bench/toolbar.d.ts +9 -0
- package/dist/bench/toolbar.js +16 -0
- package/dist/components/alert-dialog.d.ts +18 -0
- package/dist/components/alert-dialog.js +41 -0
- package/dist/components/alert.d.ts +9 -0
- package/dist/components/alert.js +24 -0
- package/dist/components/avatar.d.ts +11 -0
- package/dist/components/avatar.js +22 -0
- package/dist/components/badge.d.ts +9 -0
- package/dist/components/badge.js +28 -0
- package/dist/components/breadcrumb.d.ts +11 -0
- package/dist/components/breadcrumb.js +27 -0
- package/dist/components/button-group.d.ts +11 -0
- package/dist/components/button-group.js +27 -0
- package/dist/components/button.d.ts +10 -0
- package/dist/components/button.js +35 -0
- package/dist/components/calendar.d.ts +8 -0
- package/dist/components/calendar.js +76 -0
- package/dist/components/card.d.ts +9 -0
- package/dist/components/card.js +24 -0
- package/dist/components/checkbox.d.ts +4 -0
- package/dist/components/checkbox.js +9 -0
- package/dist/components/collapsible.d.ts +5 -0
- package/dist/components/collapsible.js +12 -0
- package/dist/components/command.d.ts +18 -0
- package/dist/components/command.js +34 -0
- package/dist/components/dialog.d.ts +17 -0
- package/dist/components/dialog.js +41 -0
- package/dist/components/dropdown-menu.d.ts +25 -0
- package/dist/components/dropdown-menu.js +50 -0
- package/dist/components/empty.d.ts +11 -0
- package/dist/components/empty.js +33 -0
- package/dist/components/hover-card.d.ts +6 -0
- package/dist/components/hover-card.js +14 -0
- package/dist/components/input.d.ts +3 -0
- package/dist/components/input.js +6 -0
- package/dist/components/label.d.ts +4 -0
- package/dist/components/label.js +7 -0
- package/dist/components/popover.d.ts +10 -0
- package/dist/components/popover.js +26 -0
- package/dist/components/resizable.d.ts +7 -0
- package/dist/components/resizable.js +15 -0
- package/dist/components/scroll-area.d.ts +5 -0
- package/dist/components/scroll-area.js +13 -0
- package/dist/components/select.d.ts +15 -0
- package/dist/components/select.js +38 -0
- package/dist/components/separator.d.ts +4 -0
- package/dist/components/separator.js +7 -0
- package/dist/components/sheet.d.ts +15 -0
- package/dist/components/sheet.js +48 -0
- package/dist/components/skeleton.d.ts +2 -0
- package/dist/components/skeleton.js +6 -0
- package/dist/components/slider.d.ts +4 -0
- package/dist/components/slider.js +14 -0
- package/dist/components/spinner.d.ts +2 -0
- package/dist/components/spinner.js +7 -0
- package/dist/components/switch.d.ts +6 -0
- package/dist/components/switch.js +8 -0
- package/dist/components/table.d.ts +10 -0
- package/dist/components/table.js +27 -0
- package/dist/components/tabs.d.ts +11 -0
- package/dist/components/tabs.js +29 -0
- package/dist/components/textarea.d.ts +3 -0
- package/dist/components/textarea.js +6 -0
- package/dist/components/toggle-group.d.ts +9 -0
- package/dist/components/toggle-group.js +22 -0
- package/dist/components/toggle.d.ts +9 -0
- package/dist/components/toggle.js +26 -0
- package/dist/components/tooltip.d.ts +8 -0
- package/dist/components/tooltip.js +17 -0
- package/dist/index.d.ts +40 -0
- package/dist/index.js +40 -0
- package/dist/lib/utils.d.ts +2 -0
- package/dist/lib/utils.js +9 -0
- package/package.json +69 -4
- package/src/theme.css +165 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Bench Labs, Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
The components in src/components are adapted from shadcn/ui (https://ui.shadcn.com),
|
|
26
|
+
used under its license:
|
|
27
|
+
|
|
28
|
+
MIT License
|
|
29
|
+
|
|
30
|
+
Copyright (c) 2023 shadcn
|
|
31
|
+
|
|
32
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
33
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
34
|
+
in the Software without restriction, including without limitation the rights
|
|
35
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
36
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
37
|
+
furnished to do so, subject to the following conditions:
|
|
38
|
+
|
|
39
|
+
The above copyright notice and this permission notice shall be included in all
|
|
40
|
+
copies or substantial portions of the Software.
|
|
41
|
+
|
|
42
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
43
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
44
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
45
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
46
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
47
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
48
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,43 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @benchlabs/ui
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Bench's look for apps. Components, the theme, and four pieces that read `bench.json` through `@benchlabs/sdk`. Released
|
|
4
|
+
with the SDK under one version number; nothing is removed within major 1.
|
|
5
|
+
|
|
6
|
+
```tsx
|
|
7
|
+
import '@benchlabs/ui/theme.css';
|
|
8
|
+
import { Toolbar, Filter, PlotFigure, Badge } from '@benchlabs/ui';
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
- **Bench's pieces:** `PageTabs` (pages as tabs, the page in the link, a tab change closes what's open; nothing for one
|
|
12
|
+
page), `Toolbar` (tabs left, children right; nothing when there are neither), `Filter name` (date, relation or
|
|
13
|
+
column, from its declaration alone), `PlotFigure` (fits its width, the theme's colours and grid; marks are the
|
|
14
|
+
app's own).
|
|
15
|
+
- **Components:** every component takes `className` (the app's classes win) and passes other props through.
|
|
16
|
+
- **No component fetches data**; data lives in the SDK.
|
|
17
|
+
|
|
18
|
+
## The theme
|
|
19
|
+
|
|
20
|
+
`src/theme.css`: tokens on `:root` and `[data-theme=dark]` (the build sets the attribute from `bench.json`'s `theme`),
|
|
21
|
+
the chart palette `chart-1…8` and `chart-other`, status `good` / `warning` / `bad`, and seven sizes: `text-hero` 40,
|
|
22
|
+
`text-figure` 26, `text-title` 19, `text-heading` 15, `text-body` 13, `text-small` 12, `text-caption` 11. Bench's build
|
|
23
|
+
compiles Tailwind over this file with the classes found in the app and the kit; an app's own CSS never goes through
|
|
24
|
+
Tailwind.
|
|
25
|
+
|
|
26
|
+
## Differences from bench-app's `components/ui/`, at the copy (2026-11-19)
|
|
27
|
+
|
|
28
|
+
A copy, not shared. Compare by hand when useful; bench-app never imports from here, nor this from bench-app.
|
|
29
|
+
|
|
30
|
+
- **Sizes:** `text-sm` / `text-xs` / `text-base` / `text-lg` become `text-small` / `text-caption` / `text-body` /
|
|
31
|
+
`text-heading`; `cn()` (`lib/utils.ts`) knows the seven names, or `tailwind-merge` drops a colour beside one.
|
|
32
|
+
- **Focus:** `ring-2 ring-ring/30` instead of `ring-[3px] ring-ring/50`.
|
|
33
|
+
- **Button:** no `ai` variant; `outline` has no shadow and hovers to `muted`.
|
|
34
|
+
- **Badge:** adds `good`, `warning`, `bad`, `muted`.
|
|
35
|
+
- **Table:** heads in `muted-foreground`, cells `tabular-nums`, a selected row (`data-state=selected`) gets a 2px
|
|
36
|
+
marker on its left edge.
|
|
37
|
+
- **Tabs:** `line` (an underline) is the default variant; inactive tabs in `muted-foreground` (AA contrast).
|
|
38
|
+
- **Sheet:** not modal by default: no overlay, the page stays usable, nothing steals focus. `modal` dims as before.
|
|
39
|
+
- **Dark:** `dark:` keys on `[data-theme=dark]`, not a `.dark` class or the OS setting.
|
|
40
|
+
- **Added from shadcn:** card (flat, 8px radius, no shadow), empty, switch, toggle, toggle-group, slider, scroll-area,
|
|
41
|
+
resizable (⚠ `react-resizable-panels` v4: a number is pixels, `"36%"` is percent), breadcrumb, skeleton.
|
|
42
|
+
|
|
43
|
+
`npm run build` (`tsc` to `dist/`, which apps are typechecked against) · `npm test` · `npm run typecheck`.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
type Align = 'start' | 'end';
|
|
3
|
+
type Props = {
|
|
4
|
+
name: string;
|
|
5
|
+
className?: string;
|
|
6
|
+
align?: Align;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* The control for one `bench.json` data filter, by name: date presets and a custom range; a searchable multi-select
|
|
10
|
+
* for a relation or a list column; a min/max range for a number column. Its value lives in the link.
|
|
11
|
+
*/
|
|
12
|
+
export declare function Filter({ name, className, align }: Props): React.JSX.Element | null;
|
|
13
|
+
/** A date token as a person reads it: "Last 90 days", "Sep 2026", "2026 Q3", "Aug 10, 2026 – Sep 20, 2026". */
|
|
14
|
+
export declare function dateLabel(token: string | null): string;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { CheckIcon, ChevronDownIcon, XIcon } from 'lucide-react';
|
|
4
|
+
import { DATE_TOKENS, useBenchConfig, useFilterValues, useLinkState } from '@benchlabs/sdk';
|
|
5
|
+
import { format, parseISO } from 'date-fns';
|
|
6
|
+
import { Popover, PopoverContent, PopoverTrigger } from '../components/popover';
|
|
7
|
+
import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList } from '../components/command';
|
|
8
|
+
import { Calendar } from '../components/calendar';
|
|
9
|
+
import { Button } from '../components/button';
|
|
10
|
+
import { Input } from '../components/input';
|
|
11
|
+
import { cn } from '../lib/utils';
|
|
12
|
+
/**
|
|
13
|
+
* The control for one `bench.json` data filter, by name: date presets and a custom range; a searchable multi-select
|
|
14
|
+
* for a relation or a list column; a min/max range for a number column. Its value lives in the link.
|
|
15
|
+
*/
|
|
16
|
+
export function Filter({ name, className, align = 'start' }) {
|
|
17
|
+
const config = useBenchConfig();
|
|
18
|
+
const decl = config?.dataFilters && Object.hasOwn(config.dataFilters, name) ? config.dataFilters[name] : undefined;
|
|
19
|
+
if (!config)
|
|
20
|
+
return null;
|
|
21
|
+
if (!decl)
|
|
22
|
+
throw new Error(`<Filter name="${name}">: "${name}" is not declared in bench.json's dataFilters.`);
|
|
23
|
+
if ('date' in decl)
|
|
24
|
+
return _jsx(DateFilter, { name: name, label: decl.label, className: className, align: align });
|
|
25
|
+
return _jsx(ValuesFilter, { name: name, decl: decl, className: className, align: align });
|
|
26
|
+
}
|
|
27
|
+
const Trigger = React.forwardRef(({ label, value, active, className, ...props }, ref) => (_jsxs(Button, { ref: ref, variant: "outline", size: "sm", className: cn('h-8 max-w-[280px] gap-1.5 px-2.5 text-small font-normal print:hidden', className), "aria-label": `${label}: ${value}`, ...props, children: [_jsx("span", { className: "text-muted-foreground", children: label }), _jsx("span", { className: cn('truncate', active ? 'font-medium text-foreground' : 'text-muted-foreground'), children: value }), _jsx(ChevronDownIcon, { className: "size-3.5 text-muted-foreground" })] })));
|
|
28
|
+
Trigger.displayName = 'FilterTrigger';
|
|
29
|
+
function Failed({ retry }) {
|
|
30
|
+
return (_jsxs("div", { className: "flex items-center justify-between gap-2 px-3 py-3 text-small text-muted-foreground", children: ["Couldn't load", _jsx(Button, { variant: "ghost", size: "xs", onClick: retry, children: "Retry" })] }));
|
|
31
|
+
}
|
|
32
|
+
// ── dates ─────────────────────────────────────────────────────────────────────────────────────────
|
|
33
|
+
const TOKEN_LABELS = {
|
|
34
|
+
today: 'Today',
|
|
35
|
+
this_week: 'This week',
|
|
36
|
+
last_week: 'Last week',
|
|
37
|
+
this_month: 'This month',
|
|
38
|
+
last_month: 'Last month',
|
|
39
|
+
this_quarter: 'This quarter',
|
|
40
|
+
last_quarter: 'Last quarter',
|
|
41
|
+
this_year: 'This year',
|
|
42
|
+
last_year: 'Last year',
|
|
43
|
+
last_7d: 'Last 7 days',
|
|
44
|
+
last_30d: 'Last 30 days',
|
|
45
|
+
last_90d: 'Last 90 days',
|
|
46
|
+
last_365d: 'Last 365 days',
|
|
47
|
+
all: 'All time',
|
|
48
|
+
};
|
|
49
|
+
const day = (iso) => format(parseISO(iso), 'MMM d, yyyy');
|
|
50
|
+
/** A date token as a person reads it: "Last 90 days", "Sep 2026", "2026 Q3", "Aug 10, 2026 – Sep 20, 2026". */
|
|
51
|
+
export function dateLabel(token) {
|
|
52
|
+
if (!token)
|
|
53
|
+
return TOKEN_LABELS.all;
|
|
54
|
+
if (Object.hasOwn(TOKEN_LABELS, token))
|
|
55
|
+
return TOKEN_LABELS[token];
|
|
56
|
+
const range = /^(\d{4}-\d{2}-\d{2})\.\.(\d{4}-\d{2}-\d{2})$/.exec(token);
|
|
57
|
+
if (range)
|
|
58
|
+
return `${day(range[1])} – ${day(range[2])}`;
|
|
59
|
+
if (/^\d{4}-\d{2}$/.test(token))
|
|
60
|
+
return format(parseISO(`${token}-01`), 'MMM yyyy');
|
|
61
|
+
const quarter = /^(\d{4})-Q([1-4])$/.exec(token);
|
|
62
|
+
if (quarter)
|
|
63
|
+
return `${quarter[1]} Q${quarter[2]}`;
|
|
64
|
+
return token;
|
|
65
|
+
}
|
|
66
|
+
function DateFilter({ name, label, className, align }) {
|
|
67
|
+
const [value, setValue] = useLinkState(name);
|
|
68
|
+
const [open, setOpen] = React.useState(false);
|
|
69
|
+
const [draft, setDraft] = React.useState();
|
|
70
|
+
const current = /^(\d{4}-\d{2}-\d{2})\.\.(\d{4}-\d{2}-\d{2})$/.exec(value ?? '');
|
|
71
|
+
const shown = draft ?? (current ? { from: parseISO(current[1]), to: parseISO(current[2]) } : undefined);
|
|
72
|
+
// Closing from inside (a preset, Cancel, Apply) never reaches `onOpenChange`: every close goes through here.
|
|
73
|
+
const openChange = (next) => {
|
|
74
|
+
setOpen(next);
|
|
75
|
+
setDraft(undefined);
|
|
76
|
+
};
|
|
77
|
+
const choose = (token) => {
|
|
78
|
+
setValue(token);
|
|
79
|
+
openChange(false);
|
|
80
|
+
};
|
|
81
|
+
return (_jsxs(Popover, { open: open, onOpenChange: openChange, children: [_jsx(PopoverTrigger, { asChild: true, children: _jsx(Trigger, { label: label, value: dateLabel(value), active: !!value && value !== 'all', className: className }) }), _jsxs(PopoverContent, { align: align, className: "flex w-auto p-0", children: [_jsx("div", { className: "flex w-36 flex-col gap-0.5 border-r p-1.5", children: DATE_TOKENS.map((token) => (_jsx("button", { "aria-pressed": (value ?? 'all') === token, onClick: () => choose(token), className: cn('rounded-sm px-2 py-1.5 text-left text-small hover:bg-muted focus-visible:ring-2 focus-visible:ring-ring/30 focus-visible:outline-none', (value ?? 'all') === token && 'bg-muted font-medium'), children: TOKEN_LABELS[token] }, token))) }), _jsxs("div", { className: "flex flex-col", children: [_jsx(Calendar, { mode: "range", numberOfMonths: 1, defaultMonth: shown?.to, selected: shown, onSelect: (r) => setDraft(r), className: "p-2" }), _jsxs("div", { className: "flex items-center justify-end gap-2 border-t p-2", children: [_jsx(Button, { variant: "ghost", size: "xs", onClick: () => openChange(false), children: "Cancel" }), _jsx(Button, { size: "xs", disabled: !draft?.from || !draft?.to, onClick: () => choose(`${format(draft.from, 'yyyy-MM-dd')}..${format(draft.to, 'yyyy-MM-dd')}`), children: "Apply" })] })] })] })] }));
|
|
82
|
+
}
|
|
83
|
+
const isRange = (v) => !!v && !Array.isArray(v);
|
|
84
|
+
/** Types as a person types, asks as they pause. */
|
|
85
|
+
function useDebounced(value, ms = 250) {
|
|
86
|
+
const [settled, setSettled] = React.useState(value);
|
|
87
|
+
React.useEffect(() => {
|
|
88
|
+
const timer = setTimeout(() => setSettled(value), ms);
|
|
89
|
+
return () => clearTimeout(timer);
|
|
90
|
+
}, [value, ms]);
|
|
91
|
+
return settled;
|
|
92
|
+
}
|
|
93
|
+
const rangeText = (r) => (r.min !== undefined && r.max !== undefined ? `${r.min} – ${r.max}` : r.min !== undefined ? `≥ ${r.min}` : `≤ ${r.max}`);
|
|
94
|
+
function ValuesFilter({ name, decl, className, align }) {
|
|
95
|
+
const relation = 'relation' in decl;
|
|
96
|
+
const [value, setValue] = useLinkState(name);
|
|
97
|
+
const [open, setOpen] = React.useState(false);
|
|
98
|
+
const [typed, setTyped] = React.useState('');
|
|
99
|
+
const search = useDebounced(typed);
|
|
100
|
+
const choices = useFilterValues(name, { search, enabled: open });
|
|
101
|
+
const committed = isRange(value) ? [] : (value ?? []).map(String);
|
|
102
|
+
// Picks are staged while the picker is open and reach the link once, on close: each link change re-runs the measures.
|
|
103
|
+
const [staged, setStaged] = React.useState(null);
|
|
104
|
+
const selected = staged ?? committed;
|
|
105
|
+
// A shared link holds relation ids; names come from Bench. A column value is its own label.
|
|
106
|
+
const named = useFilterValues(name, { ids: committed, enabled: relation && committed.length > 0 });
|
|
107
|
+
// Every label seen, so a pick made from search results keeps its name once the search clears.
|
|
108
|
+
const seen = React.useMemo(() => new Map(), [name]);
|
|
109
|
+
const labels = React.useMemo(() => {
|
|
110
|
+
for (const v of [...choices.values, ...named.values])
|
|
111
|
+
seen.set(v.id, v.label);
|
|
112
|
+
return new Map(seen);
|
|
113
|
+
}, [seen, choices.values, named.values]);
|
|
114
|
+
const labelOf = (id) => (relation ? labels.get(id) : id);
|
|
115
|
+
const summary = isRange(value)
|
|
116
|
+
? rangeText(value)
|
|
117
|
+
: committed.length === 0
|
|
118
|
+
? 'All'
|
|
119
|
+
: committed.length <= 2
|
|
120
|
+
? committed.map((id) => labelOf(id) ?? id).join(', ')
|
|
121
|
+
: `${labelOf(committed[0]) ?? committed[0]} +${committed.length - 1}`;
|
|
122
|
+
const ranged = isRange(value) || choices.kind === 'range';
|
|
123
|
+
return (_jsxs(Popover, { open: open, onOpenChange: (next) => {
|
|
124
|
+
setOpen(next);
|
|
125
|
+
if (next)
|
|
126
|
+
return;
|
|
127
|
+
setTyped('');
|
|
128
|
+
if (staged && staged.join('\u0000') !== committed.join('\u0000'))
|
|
129
|
+
setValue(staged.length ? staged : null);
|
|
130
|
+
setStaged(null);
|
|
131
|
+
}, children: [_jsx(PopoverTrigger, { asChild: true, children: _jsx(Trigger, { label: decl.label, value: summary, active: value !== null, className: className }) }), _jsx(PopoverContent, { align: align, className: cn('p-0', ranged ? 'w-60' : 'w-64'), children: choices.error ? (_jsx(Failed, { retry: choices.refetch })) : ranged ? (_jsx(RangePicker, { value: isRange(value) ? value : null, bounds: choices, onApply: (r) => { setValue(r); setOpen(false); } })) : (_jsx(ValuesPicker, { label: decl.label, typed: typed, onType: setTyped, choices: choices, selected: selected, labelOf: labelOf, onChange: setStaged })) })] }));
|
|
132
|
+
}
|
|
133
|
+
function ValuesPicker({ label, typed, onType, choices, selected, labelOf, onChange }) {
|
|
134
|
+
const toggle = (id) => onChange(selected.includes(id) ? selected.filter((s) => s !== id) : [...selected, id]);
|
|
135
|
+
const onScroll = (e) => {
|
|
136
|
+
const el = e.currentTarget;
|
|
137
|
+
if (choices.hasMore && el.scrollTop + el.clientHeight > el.scrollHeight - 40)
|
|
138
|
+
choices.fetchMore();
|
|
139
|
+
};
|
|
140
|
+
const browsing = !typed;
|
|
141
|
+
return (_jsxs(Command, { shouldFilter: false, children: [_jsx(CommandInput, { placeholder: `Search ${label.toLowerCase()}…`, value: typed, onValueChange: onType, className: "text-small" }), _jsxs(CommandList, { onScroll: onScroll, className: "max-h-64", children: [!choices.isLoading && _jsx(CommandEmpty, { className: "py-4 text-center text-small text-muted-foreground", children: "No matches" }), browsing && selected.length > 0 && (_jsx(CommandGroup, { heading: "Selected", children: selected.map((id) => (_jsx(Choice, { id: id, label: labelOf(id), on: true, onToggle: toggle }, id))) })), _jsxs(CommandGroup, { heading: browsing && selected.length > 0 ? 'All' : undefined, children: [choices.values
|
|
142
|
+
.filter((c) => !browsing || !selected.includes(c.id))
|
|
143
|
+
.map((c) => (_jsx(Choice, { id: c.id, label: c.label, on: selected.includes(c.id), onToggle: toggle }, c.id))), (choices.hasMore || choices.isLoading) && _jsx("div", { className: "px-2 py-1.5 text-caption text-muted-foreground", children: "Loading\u2026" })] })] }), selected.length > 0 && (_jsxs("div", { className: "flex items-center justify-between border-t px-2 py-1.5", children: [_jsxs("span", { className: "text-caption text-muted-foreground", children: [selected.length, " selected"] }), _jsxs(Button, { variant: "ghost", size: "xs", onClick: () => onChange([]), children: [_jsx(XIcon, {}), "Clear"] })] }))] }));
|
|
144
|
+
}
|
|
145
|
+
/** One choice; a selected id with no label (merged away, or out of the viewer's sight) shows the raw id, greyed. */
|
|
146
|
+
function Choice({ id, label, on, onToggle }) {
|
|
147
|
+
return (_jsxs(CommandItem, { value: id, onSelect: () => onToggle(id), className: "gap-2 text-small", children: [_jsx("span", { className: cn('flex size-3.5 shrink-0 items-center justify-center rounded-[3px] border', on ? 'border-primary bg-primary text-primary-foreground' : 'border-input'), children: on && _jsx(CheckIcon, { className: "size-2.5" }) }), _jsx("span", { className: cn('truncate', label === undefined && 'text-muted-foreground'), children: label ?? id })] }));
|
|
148
|
+
}
|
|
149
|
+
function RangePicker({ value, bounds, onApply }) {
|
|
150
|
+
const [min, setMin] = React.useState(value?.min?.toString() ?? '');
|
|
151
|
+
const [max, setMax] = React.useState(value?.max?.toString() ?? '');
|
|
152
|
+
const num = (text) => (text.trim() === '' || !Number.isFinite(Number(text)) ? undefined : Number(text));
|
|
153
|
+
const apply = () => {
|
|
154
|
+
const range = { min: num(min), max: num(max) };
|
|
155
|
+
onApply(range.min === undefined && range.max === undefined ? null : range);
|
|
156
|
+
};
|
|
157
|
+
return (_jsxs("form", { className: "flex flex-col gap-2 p-3", onSubmit: (e) => {
|
|
158
|
+
e.preventDefault();
|
|
159
|
+
apply();
|
|
160
|
+
}, children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Input, { "aria-label": "Minimum", inputMode: "decimal", value: min, onChange: (e) => setMin(e.target.value), placeholder: bounds.min?.toString() ?? 'Min', className: "h-8 text-small" }), _jsx("span", { className: "text-small text-muted-foreground", children: "\u2013" }), _jsx(Input, { "aria-label": "Maximum", inputMode: "decimal", value: max, onChange: (e) => setMax(e.target.value), placeholder: bounds.max?.toString() ?? 'Max', className: "h-8 text-small" })] }), _jsxs("div", { className: "flex justify-end gap-2", children: [_jsx(Button, { type: "button", variant: "ghost", size: "xs", onClick: () => onApply(null), children: "Clear" }), _jsx(Button, { type: "submit", size: "xs", children: "Apply" })] })] }));
|
|
161
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useBenchConfig, useLinkState } from '@benchlabs/sdk';
|
|
3
|
+
import { cn } from '../lib/utils';
|
|
4
|
+
import { Tabs, TabsList, TabsTrigger } from '../components/tabs';
|
|
5
|
+
/** `bench.json`'s pages as tabs, the current one in the link. Nothing for an app with one page. */
|
|
6
|
+
export function PageTabs({ className }) {
|
|
7
|
+
const config = useBenchConfig();
|
|
8
|
+
const [page, setPage] = useLinkState('page');
|
|
9
|
+
const [, setItem] = useLinkState('item');
|
|
10
|
+
if (!config || config.pages.length < 2)
|
|
11
|
+
return null;
|
|
12
|
+
// What's open belongs to the page it was opened on; both change in one link message, so one Back step.
|
|
13
|
+
const go = (next) => {
|
|
14
|
+
setPage(next);
|
|
15
|
+
setItem(null);
|
|
16
|
+
};
|
|
17
|
+
return (_jsx(Tabs, { value: page, onValueChange: go, className: cn('self-stretch print:hidden', className), children: _jsx(TabsList, { className: "h-full min-h-12 items-stretch", children: config.pages.map((p) => (_jsx(TabsTrigger, { value: p.id, "aria-controls": "root", className: "h-full group-data-[orientation=horizontal]/tabs:after:-bottom-px", children: p.label }, p.id))) }) }));
|
|
18
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import * as Plot from '@observablehq/plot';
|
|
3
|
+
export type PlotFigureProps = Plot.PlotOptions & {
|
|
4
|
+
/** What the chart shows, for a screen reader: the SVG itself is hidden. */
|
|
5
|
+
label: string;
|
|
6
|
+
height?: number;
|
|
7
|
+
loading?: boolean;
|
|
8
|
+
error?: unknown;
|
|
9
|
+
className?: string;
|
|
10
|
+
/** The datum under the pointer when clicked; needs a mark with `tip` or a pointer transform. */
|
|
11
|
+
onClick?: (datum: unknown) => void;
|
|
12
|
+
/** With `error`: a Retry button that calls it (the measure's `refetch`). */
|
|
13
|
+
onRetry?: () => void;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* A Plot chart in Bench's look: fits its width, the theme's colours, font and grid, keeps its height while loading,
|
|
17
|
+
* says so when it fails. Marks are the app's own; nothing here changes them.
|
|
18
|
+
*/
|
|
19
|
+
export declare function PlotFigure({ label, height, loading, error, className, onClick, onRetry, ...plotOptions }: PlotFigureProps): React.JSX.Element;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import * as Plot from '@observablehq/plot';
|
|
4
|
+
import { cn } from '../lib/utils';
|
|
5
|
+
import { Skeleton } from '../components/skeleton';
|
|
6
|
+
import { Button } from '../components/button';
|
|
7
|
+
/** The chart palette, in order, as CSS variables: light and dark follow the theme. */
|
|
8
|
+
const chartColors = [1, 2, 3, 4, 5, 6, 7, 8].map((i) => `var(--color-chart-${i})`);
|
|
9
|
+
/**
|
|
10
|
+
* A Plot chart in Bench's look: fits its width, the theme's colours, font and grid, keeps its height while loading,
|
|
11
|
+
* says so when it fails. Marks are the app's own; nothing here changes them.
|
|
12
|
+
*/
|
|
13
|
+
export function PlotFigure({ label, height = 240, loading, error, className, onClick, onRetry, ...plotOptions }) {
|
|
14
|
+
const ref = React.useRef(null);
|
|
15
|
+
const [width, setWidth] = React.useState(0);
|
|
16
|
+
// Redrawn only when an option changes, compared one level deep: inline `x={{ label: null }}` or `domain: [0, 1]` is
|
|
17
|
+
// stable; functions and the marks inside `marks` compare by identity (`useMemo` over the rows).
|
|
18
|
+
const options = useStableOptions(plotOptions);
|
|
19
|
+
const clicked = React.useRef(onClick);
|
|
20
|
+
React.useLayoutEffect(() => {
|
|
21
|
+
clicked.current = onClick;
|
|
22
|
+
});
|
|
23
|
+
const clickable = !!onClick;
|
|
24
|
+
React.useLayoutEffect(() => {
|
|
25
|
+
const el = ref.current;
|
|
26
|
+
const ro = new ResizeObserver(([entry]) => setWidth(Math.floor(entry.contentRect.width)));
|
|
27
|
+
ro.observe(el);
|
|
28
|
+
return () => ro.disconnect();
|
|
29
|
+
}, []);
|
|
30
|
+
React.useEffect(() => {
|
|
31
|
+
if (!width || loading || error)
|
|
32
|
+
return;
|
|
33
|
+
const chart = Plot.plot({
|
|
34
|
+
width,
|
|
35
|
+
height,
|
|
36
|
+
style: { fontFamily: 'inherit', fontSize: '11px', color: 'hsl(var(--muted-foreground))', background: 'transparent', overflow: 'visible' },
|
|
37
|
+
...(options.axis === null || options.margin !== undefined || options.marginLeft !== undefined ? {} : { marginLeft: 44 }),
|
|
38
|
+
...options,
|
|
39
|
+
color: { range: chartColors, unknown: 'var(--color-chart-other)', ...options.color },
|
|
40
|
+
x: { tickSize: 0, ...options.x },
|
|
41
|
+
y: { tickSize: 0, grid: true, ...options.y },
|
|
42
|
+
});
|
|
43
|
+
chart.setAttribute('aria-hidden', 'true');
|
|
44
|
+
if (clickable) {
|
|
45
|
+
chart.addEventListener('click', () => {
|
|
46
|
+
const value = chart.value;
|
|
47
|
+
if (value != null)
|
|
48
|
+
clicked.current?.(value);
|
|
49
|
+
});
|
|
50
|
+
chart.style.cursor = 'pointer';
|
|
51
|
+
}
|
|
52
|
+
ref.current.replaceChildren(chart);
|
|
53
|
+
return () => chart.remove();
|
|
54
|
+
}, [width, height, loading, error, options, clickable]);
|
|
55
|
+
return (_jsxs("div", { "data-slot": "plot-figure", className: cn('relative w-full', className), style: { minHeight: height }, children: [loading && _jsx(Skeleton, { className: "absolute inset-0 rounded-md" }), !!error && !loading && (_jsxs("div", { role: "status", className: "absolute inset-0 flex items-center justify-center gap-3 text-small text-muted-foreground", children: [label, ": couldn't load", onRetry && (_jsx(Button, { variant: "outline", size: "sm", className: "print:hidden", onClick: () => onRetry(), children: "Retry" }))] })), _jsx("div", { ref: ref, role: "img", "aria-label": label, "aria-busy": loading || undefined, className: cn('[&_[aria-label$=grid]]:stroke-border [&_[aria-label$=grid]]:stroke-opacity-100 [&_[aria-label=tip]]:text-foreground', (loading || !!error) && 'invisible') })] }));
|
|
56
|
+
}
|
|
57
|
+
const isPlain = (v) => !!v && typeof v === 'object' && Object.getPrototypeOf(v) === Object.prototype;
|
|
58
|
+
/** Equal by identity, or element by element for two arrays, or key by key for two plain objects. */
|
|
59
|
+
function sameOption(a, b) {
|
|
60
|
+
if (Object.is(a, b))
|
|
61
|
+
return true;
|
|
62
|
+
if (Array.isArray(a) && Array.isArray(b))
|
|
63
|
+
return a.length === b.length && a.every((v, i) => Object.is(v, b[i]));
|
|
64
|
+
if (!isPlain(a) || !isPlain(b))
|
|
65
|
+
return false;
|
|
66
|
+
const keys = Object.keys(b);
|
|
67
|
+
return Object.keys(a).length === keys.length && keys.every((k) => Object.is(a[k], b[k]) || (Array.isArray(a[k]) && sameOption(a[k], b[k])));
|
|
68
|
+
}
|
|
69
|
+
/** The same object while every option is the same, so an inline `x={{…}}` doesn't redraw the chart. */
|
|
70
|
+
function useStableOptions(value) {
|
|
71
|
+
const kept = React.useRef(value);
|
|
72
|
+
const prev = kept.current;
|
|
73
|
+
const next = value;
|
|
74
|
+
const same = Object.keys(prev).length === Object.keys(next).length && Object.keys(next).every((k) => sameOption(prev[k], next[k]));
|
|
75
|
+
if (!same)
|
|
76
|
+
kept.current = value;
|
|
77
|
+
return kept.current;
|
|
78
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* The app's first row: `PageTabs` on the left, `children` (filters, options) on the right, a hairline below. Nothing
|
|
4
|
+
* when the app has one page and no children.
|
|
5
|
+
*/
|
|
6
|
+
export declare function Toolbar({ className, children }: {
|
|
7
|
+
className?: string;
|
|
8
|
+
children?: React.ReactNode;
|
|
9
|
+
}): React.JSX.Element | null;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { useBenchConfig } from '@benchlabs/sdk';
|
|
4
|
+
import { cn } from '../lib/utils';
|
|
5
|
+
import { PageTabs } from './page-tabs';
|
|
6
|
+
/**
|
|
7
|
+
* The app's first row: `PageTabs` on the left, `children` (filters, options) on the right, a hairline below. Nothing
|
|
8
|
+
* when the app has one page and no children.
|
|
9
|
+
*/
|
|
10
|
+
export function Toolbar({ className, children }) {
|
|
11
|
+
const config = useBenchConfig();
|
|
12
|
+
const tabs = !!config && config.pages.length > 1;
|
|
13
|
+
if (!tabs && React.Children.toArray(children).length === 0)
|
|
14
|
+
return null;
|
|
15
|
+
return (_jsxs("div", { className: cn('flex min-h-12 flex-wrap items-stretch justify-between gap-x-4 border-b bg-background px-6 print:hidden', className), children: [tabs ? _jsx(PageTabs, {}) : _jsx("span", {}), _jsx("div", { className: "flex flex-wrap items-center justify-end gap-2 py-2", children: children })] }));
|
|
16
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { AlertDialog as AlertDialogPrimitive } from "radix-ui";
|
|
3
|
+
import { Button } from "./button";
|
|
4
|
+
declare function AlertDialog({ ...props }: React.ComponentProps<typeof AlertDialogPrimitive.Root>): React.JSX.Element;
|
|
5
|
+
declare function AlertDialogTrigger({ ...props }: React.ComponentProps<typeof AlertDialogPrimitive.Trigger>): React.JSX.Element;
|
|
6
|
+
declare function AlertDialogPortal({ ...props }: React.ComponentProps<typeof AlertDialogPrimitive.Portal>): React.JSX.Element;
|
|
7
|
+
declare function AlertDialogOverlay({ className, ...props }: React.ComponentProps<typeof AlertDialogPrimitive.Overlay>): React.JSX.Element;
|
|
8
|
+
declare function AlertDialogContent({ className, size, ...props }: React.ComponentProps<typeof AlertDialogPrimitive.Content> & {
|
|
9
|
+
size?: "default" | "sm";
|
|
10
|
+
}): React.JSX.Element;
|
|
11
|
+
declare function AlertDialogHeader({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
12
|
+
declare function AlertDialogFooter({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
13
|
+
declare function AlertDialogTitle({ className, ...props }: React.ComponentProps<typeof AlertDialogPrimitive.Title>): React.JSX.Element;
|
|
14
|
+
declare function AlertDialogDescription({ className, ...props }: React.ComponentProps<typeof AlertDialogPrimitive.Description>): React.JSX.Element;
|
|
15
|
+
declare function AlertDialogMedia({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
16
|
+
declare function AlertDialogAction({ className, variant, size, ...props }: React.ComponentProps<typeof AlertDialogPrimitive.Action> & Pick<React.ComponentProps<typeof Button>, "variant" | "size">): React.JSX.Element;
|
|
17
|
+
declare function AlertDialogCancel({ className, variant, size, ...props }: React.ComponentProps<typeof AlertDialogPrimitive.Cancel> & Pick<React.ComponentProps<typeof Button>, "variant" | "size">): React.JSX.Element;
|
|
18
|
+
export { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogMedia, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { AlertDialog as AlertDialogPrimitive } from "radix-ui";
|
|
3
|
+
import { cn } from "../lib/utils";
|
|
4
|
+
import { Button } from "./button";
|
|
5
|
+
function AlertDialog({ ...props }) {
|
|
6
|
+
return _jsx(AlertDialogPrimitive.Root, { "data-slot": "alert-dialog", ...props });
|
|
7
|
+
}
|
|
8
|
+
function AlertDialogTrigger({ ...props }) {
|
|
9
|
+
return (_jsx(AlertDialogPrimitive.Trigger, { "data-slot": "alert-dialog-trigger", ...props }));
|
|
10
|
+
}
|
|
11
|
+
function AlertDialogPortal({ ...props }) {
|
|
12
|
+
return (_jsx(AlertDialogPrimitive.Portal, { "data-slot": "alert-dialog-portal", ...props }));
|
|
13
|
+
}
|
|
14
|
+
function AlertDialogOverlay({ className, ...props }) {
|
|
15
|
+
return (_jsx(AlertDialogPrimitive.Overlay, { "data-slot": "alert-dialog-overlay", className: cn("fixed inset-0 z-50 bg-black/50 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0", className), ...props }));
|
|
16
|
+
}
|
|
17
|
+
function AlertDialogContent({ className, size = "default", ...props }) {
|
|
18
|
+
return (_jsxs(AlertDialogPortal, { children: [_jsx(AlertDialogOverlay, {}), _jsx(AlertDialogPrimitive.Content, { "data-slot": "alert-dialog-content", "data-size": size, className: cn("group/alert-dialog-content fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border bg-background p-6 shadow-lg duration-200 data-[size=sm]:max-w-xs data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 data-[size=default]:sm:max-w-lg", className), ...props })] }));
|
|
19
|
+
}
|
|
20
|
+
function AlertDialogHeader({ className, ...props }) {
|
|
21
|
+
return (_jsx("div", { "data-slot": "alert-dialog-header", className: cn("grid grid-rows-[auto_1fr] place-items-center gap-1.5 text-center has-data-[slot=alert-dialog-media]:grid-rows-[auto_auto_1fr] has-data-[slot=alert-dialog-media]:gap-x-6 sm:group-data-[size=default]/alert-dialog-content:place-items-start sm:group-data-[size=default]/alert-dialog-content:text-left sm:group-data-[size=default]/alert-dialog-content:has-data-[slot=alert-dialog-media]:grid-rows-[auto_1fr]", className), ...props }));
|
|
22
|
+
}
|
|
23
|
+
function AlertDialogFooter({ className, ...props }) {
|
|
24
|
+
return (_jsx("div", { "data-slot": "alert-dialog-footer", className: cn("flex flex-col-reverse gap-2 group-data-[size=sm]/alert-dialog-content:grid group-data-[size=sm]/alert-dialog-content:grid-cols-2 sm:flex-row sm:justify-end", className), ...props }));
|
|
25
|
+
}
|
|
26
|
+
function AlertDialogTitle({ className, ...props }) {
|
|
27
|
+
return (_jsx(AlertDialogPrimitive.Title, { "data-slot": "alert-dialog-title", className: cn("text-heading font-semibold sm:group-data-[size=default]/alert-dialog-content:group-has-data-[slot=alert-dialog-media]/alert-dialog-content:col-start-2", className), ...props }));
|
|
28
|
+
}
|
|
29
|
+
function AlertDialogDescription({ className, ...props }) {
|
|
30
|
+
return (_jsx(AlertDialogPrimitive.Description, { "data-slot": "alert-dialog-description", className: cn("text-small text-muted-foreground", className), ...props }));
|
|
31
|
+
}
|
|
32
|
+
function AlertDialogMedia({ className, ...props }) {
|
|
33
|
+
return (_jsx("div", { "data-slot": "alert-dialog-media", className: cn("mb-2 inline-flex size-16 items-center justify-center rounded-md bg-muted sm:group-data-[size=default]/alert-dialog-content:row-span-2 *:[svg:not([class*='size-'])]:size-8", className), ...props }));
|
|
34
|
+
}
|
|
35
|
+
function AlertDialogAction({ className, variant = "default", size = "default", ...props }) {
|
|
36
|
+
return (_jsx(Button, { variant: variant, size: size, asChild: true, children: _jsx(AlertDialogPrimitive.Action, { "data-slot": "alert-dialog-action", className: cn(className), ...props }) }));
|
|
37
|
+
}
|
|
38
|
+
function AlertDialogCancel({ className, variant = "outline", size = "default", ...props }) {
|
|
39
|
+
return (_jsx(Button, { variant: variant, size: size, asChild: true, children: _jsx(AlertDialogPrimitive.Cancel, { "data-slot": "alert-dialog-cancel", className: cn(className), ...props }) }));
|
|
40
|
+
}
|
|
41
|
+
export { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogMedia, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { type VariantProps } from "class-variance-authority";
|
|
3
|
+
declare const alertVariants: (props?: ({
|
|
4
|
+
variant?: "default" | "destructive" | null | undefined;
|
|
5
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
6
|
+
declare function Alert({ className, variant, ...props }: React.ComponentProps<"div"> & VariantProps<typeof alertVariants>): React.JSX.Element;
|
|
7
|
+
declare function AlertTitle({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
8
|
+
declare function AlertDescription({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
9
|
+
export { Alert, AlertTitle, AlertDescription };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cva } from "class-variance-authority";
|
|
3
|
+
import { cn } from "../lib/utils";
|
|
4
|
+
const alertVariants = cva("relative grid w-full grid-cols-[0_1fr] items-start gap-y-0.5 rounded-lg border px-4 py-3 text-small has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] has-[>svg]:gap-x-3 [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current", {
|
|
5
|
+
variants: {
|
|
6
|
+
variant: {
|
|
7
|
+
default: "bg-card text-card-foreground",
|
|
8
|
+
destructive: "bg-card text-destructive *:data-[slot=alert-description]:text-destructive/90 [&>svg]:text-current",
|
|
9
|
+
},
|
|
10
|
+
},
|
|
11
|
+
defaultVariants: {
|
|
12
|
+
variant: "default",
|
|
13
|
+
},
|
|
14
|
+
});
|
|
15
|
+
function Alert({ className, variant, ...props }) {
|
|
16
|
+
return (_jsx("div", { "data-slot": "alert", role: "alert", className: cn(alertVariants({ variant }), className), ...props }));
|
|
17
|
+
}
|
|
18
|
+
function AlertTitle({ className, ...props }) {
|
|
19
|
+
return (_jsx("div", { "data-slot": "alert-title", className: cn("col-start-2 line-clamp-1 min-h-4 font-medium tracking-tight", className), ...props }));
|
|
20
|
+
}
|
|
21
|
+
function AlertDescription({ className, ...props }) {
|
|
22
|
+
return (_jsx("div", { "data-slot": "alert-description", className: cn("col-start-2 grid justify-items-start gap-1 text-small text-muted-foreground [&_p]:leading-relaxed", className), ...props }));
|
|
23
|
+
}
|
|
24
|
+
export { Alert, AlertTitle, AlertDescription };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { Avatar as AvatarPrimitive } from "radix-ui";
|
|
3
|
+
declare function Avatar({ className, size, ...props }: React.ComponentProps<typeof AvatarPrimitive.Root> & {
|
|
4
|
+
size?: "default" | "sm" | "lg";
|
|
5
|
+
}): React.JSX.Element;
|
|
6
|
+
declare function AvatarImage({ className, ...props }: React.ComponentProps<typeof AvatarPrimitive.Image>): React.JSX.Element;
|
|
7
|
+
declare function AvatarFallback({ className, ...props }: React.ComponentProps<typeof AvatarPrimitive.Fallback>): React.JSX.Element;
|
|
8
|
+
declare function AvatarBadge({ className, ...props }: React.ComponentProps<"span">): React.JSX.Element;
|
|
9
|
+
declare function AvatarGroup({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
10
|
+
declare function AvatarGroupCount({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
11
|
+
export { Avatar, AvatarImage, AvatarFallback, AvatarBadge, AvatarGroup, AvatarGroupCount, };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Avatar as AvatarPrimitive } from "radix-ui";
|
|
3
|
+
import { cn } from "../lib/utils";
|
|
4
|
+
function Avatar({ className, size = "default", ...props }) {
|
|
5
|
+
return (_jsx(AvatarPrimitive.Root, { "data-slot": "avatar", "data-size": size, className: cn("group/avatar relative flex size-8 shrink-0 overflow-hidden rounded-full select-none data-[size=lg]:size-10 data-[size=sm]:size-6", className), ...props }));
|
|
6
|
+
}
|
|
7
|
+
function AvatarImage({ className, ...props }) {
|
|
8
|
+
return (_jsx(AvatarPrimitive.Image, { "data-slot": "avatar-image", className: cn("aspect-square size-full", className), ...props }));
|
|
9
|
+
}
|
|
10
|
+
function AvatarFallback({ className, ...props }) {
|
|
11
|
+
return (_jsx(AvatarPrimitive.Fallback, { "data-slot": "avatar-fallback", className: cn("flex size-full items-center justify-center rounded-full bg-muted text-small text-muted-foreground group-data-[size=sm]/avatar:text-caption", className), ...props }));
|
|
12
|
+
}
|
|
13
|
+
function AvatarBadge({ className, ...props }) {
|
|
14
|
+
return (_jsx("span", { "data-slot": "avatar-badge", className: cn("absolute right-0 bottom-0 z-10 inline-flex items-center justify-center rounded-full bg-primary text-primary-foreground ring-2 ring-background select-none", "group-data-[size=sm]/avatar:size-2 group-data-[size=sm]/avatar:[&>svg]:hidden", "group-data-[size=default]/avatar:size-2.5 group-data-[size=default]/avatar:[&>svg]:size-2", "group-data-[size=lg]/avatar:size-3 group-data-[size=lg]/avatar:[&>svg]:size-2", className), ...props }));
|
|
15
|
+
}
|
|
16
|
+
function AvatarGroup({ className, ...props }) {
|
|
17
|
+
return (_jsx("div", { "data-slot": "avatar-group", className: cn("group/avatar-group flex -space-x-2 *:data-[slot=avatar]:ring-2 *:data-[slot=avatar]:ring-background", className), ...props }));
|
|
18
|
+
}
|
|
19
|
+
function AvatarGroupCount({ className, ...props }) {
|
|
20
|
+
return (_jsx("div", { "data-slot": "avatar-group-count", className: cn("relative flex size-8 shrink-0 items-center justify-center rounded-full bg-muted text-small text-muted-foreground ring-2 ring-background group-has-data-[size=lg]/avatar-group:size-10 group-has-data-[size=sm]/avatar-group:size-6 [&>svg]:size-4 group-has-data-[size=lg]/avatar-group:[&>svg]:size-5 group-has-data-[size=sm]/avatar-group:[&>svg]:size-3", className), ...props }));
|
|
21
|
+
}
|
|
22
|
+
export { Avatar, AvatarImage, AvatarFallback, AvatarBadge, AvatarGroup, AvatarGroupCount, };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { type VariantProps } from "class-variance-authority";
|
|
3
|
+
declare const badgeVariants: (props?: ({
|
|
4
|
+
variant?: "link" | "default" | "destructive" | "outline" | "secondary" | "ghost" | "good" | "warning" | "bad" | "muted" | null | undefined;
|
|
5
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
6
|
+
declare function Badge({ className, variant, asChild, ...props }: React.ComponentProps<"span"> & VariantProps<typeof badgeVariants> & {
|
|
7
|
+
asChild?: boolean;
|
|
8
|
+
}): React.JSX.Element;
|
|
9
|
+
export { Badge, badgeVariants };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cva } from "class-variance-authority";
|
|
3
|
+
import { Slot } from "radix-ui";
|
|
4
|
+
import { cn } from "../lib/utils";
|
|
5
|
+
const badgeVariants = cva("inline-flex w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-full border border-transparent px-2 py-0.5 text-caption font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/30 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3", {
|
|
6
|
+
variants: {
|
|
7
|
+
variant: {
|
|
8
|
+
default: "bg-primary text-primary-foreground [a&]:hover:bg-primary/90",
|
|
9
|
+
secondary: "bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",
|
|
10
|
+
destructive: "bg-destructive text-white focus-visible:ring-destructive/20 dark:bg-destructive/60 dark:focus-visible:ring-destructive/40 [a&]:hover:bg-destructive/90",
|
|
11
|
+
good: "border-transparent bg-[hsl(var(--good)/.12)] text-good",
|
|
12
|
+
warning: "border-transparent bg-[hsl(var(--warning)/.14)] text-warning",
|
|
13
|
+
bad: "border-transparent bg-[hsl(var(--bad)/.12)] text-bad",
|
|
14
|
+
muted: "border-transparent bg-muted text-muted-foreground",
|
|
15
|
+
outline: "border-border text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground",
|
|
16
|
+
ghost: "[a&]:hover:bg-accent [a&]:hover:text-accent-foreground",
|
|
17
|
+
link: "text-primary underline-offset-4 [a&]:hover:underline",
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
defaultVariants: {
|
|
21
|
+
variant: "default",
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
function Badge({ className, variant = "default", asChild = false, ...props }) {
|
|
25
|
+
const Comp = asChild ? Slot.Root : "span";
|
|
26
|
+
return (_jsx(Comp, { "data-slot": "badge", "data-variant": variant, className: cn(badgeVariants({ variant }), className), ...props }));
|
|
27
|
+
}
|
|
28
|
+
export { Badge, badgeVariants };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
declare function Breadcrumb({ ...props }: React.ComponentProps<"nav">): React.JSX.Element;
|
|
3
|
+
declare function BreadcrumbList({ className, ...props }: React.ComponentProps<"ol">): React.JSX.Element;
|
|
4
|
+
declare function BreadcrumbItem({ className, ...props }: React.ComponentProps<"li">): React.JSX.Element;
|
|
5
|
+
declare function BreadcrumbLink({ asChild, className, ...props }: React.ComponentProps<"a"> & {
|
|
6
|
+
asChild?: boolean;
|
|
7
|
+
}): React.JSX.Element;
|
|
8
|
+
declare function BreadcrumbPage({ className, ...props }: React.ComponentProps<"span">): React.JSX.Element;
|
|
9
|
+
declare function BreadcrumbSeparator({ children, className, ...props }: React.ComponentProps<"li">): React.JSX.Element;
|
|
10
|
+
declare function BreadcrumbEllipsis({ className, ...props }: React.ComponentProps<"span">): React.JSX.Element;
|
|
11
|
+
export { Breadcrumb, BreadcrumbList, BreadcrumbItem, BreadcrumbLink, BreadcrumbPage, BreadcrumbSeparator, BreadcrumbEllipsis, };
|