@benchlabs/ui 1.1.0 → 1.3.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.
@@ -24,7 +24,7 @@ export function Filter({ name, className, align = 'start' }) {
24
24
  return _jsx(DateFilter, { name: name, label: decl.label, className: className, align: align });
25
25
  return _jsx(ValuesFilter, { name: name, decl: decl, className: className, align: align });
26
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', 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" })] })));
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
28
  Trigger.displayName = 'FilterTrigger';
29
29
  function Failed({ retry }) {
30
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" })] }));
@@ -14,5 +14,5 @@ export function PageTabs({ className }) {
14
14
  setPage(next);
15
15
  setItem(null);
16
16
  };
17
- return (_jsx(Tabs, { value: page, onValueChange: go, className: cn('self-stretch', 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))) }) }));
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
18
  }
@@ -52,7 +52,7 @@ export function PlotFigure({ label, height = 240, loading, error, className, onC
52
52
  ref.current.replaceChildren(chart);
53
53
  return () => chart.remove();
54
54
  }, [width, height, loading, error, options, clickable]);
55
- return (_jsxs("div", { 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", 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') })] }));
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
56
  }
57
57
  const isPlain = (v) => !!v && typeof v === 'object' && Object.getPrototypeOf(v) === Object.prototype;
58
58
  /** Equal by identity, or element by element for two arrays, or key by key for two plain objects. */
@@ -12,5 +12,5 @@ export function Toolbar({ className, children }) {
12
12
  const tabs = !!config && config.pages.length > 1;
13
13
  if (!tabs && React.Children.toArray(children).length === 0)
14
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', className), children: [tabs ? _jsx(PageTabs, {}) : _jsx("span", {}), _jsx("div", { className: "flex flex-wrap items-center justify-end gap-2 py-2", children: children })] }));
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
16
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@benchlabs/ui",
3
- "version": "1.1.0",
3
+ "version": "1.3.0",
4
4
  "description": "Bench's look for apps: components, the theme, and four pieces that read bench.json (PageTabs, Toolbar, Filter, PlotFigure).",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -35,7 +35,7 @@
35
35
  "test": "vitest run"
36
36
  },
37
37
  "peerDependencies": {
38
- "@benchlabs/sdk": "1.1.0",
38
+ "@benchlabs/sdk": "1.3.0",
39
39
  "@fontsource-variable/inter": "5.3.0",
40
40
  "@observablehq/plot": "0.6.19",
41
41
  "cmdk": "1.1.1",
package/src/theme.css CHANGED
@@ -141,3 +141,25 @@
141
141
  body { @apply bg-background text-foreground font-sans text-body antialiased; }
142
142
  button:not(:disabled), [role='button']:not([aria-disabled='true']) { cursor: pointer; }
143
143
  }
144
+
145
+ /* Paper: only what can't print as it is, never a restyle. `!important` beats the inline styles Radix and the resizable
146
+ panels set. Margins, page numbers, colour and the light theme come from Bench's print page, for every app. */
147
+ @media print {
148
+ html, body, #root { height: auto !important; }
149
+ [data-slot='scroll-area'], [data-slot='scroll-area-viewport'], [data-slot='resizable-panel-group'], [data-slot='resizable-panel'],
150
+ [data-slot='table-container'], .overflow-auto, .overflow-y-auto, .overflow-scroll {
151
+ height: auto !important;
152
+ max-height: none !important;
153
+ overflow: visible !important;
154
+ }
155
+ [data-slot='scroll-area-scrollbar'], [data-slot='resizable-handle'],
156
+ [data-slot$='-overlay'], [data-slot='sheet-content'], [data-slot='dialog-content'], [data-slot='alert-dialog-content'],
157
+ [data-slot='popover-content'], [data-slot='select-content'], [data-slot='dropdown-menu-content'], [data-slot='tooltip-content'] {
158
+ display: none !important;
159
+ }
160
+ .sticky { position: static !important; }
161
+ /* A drawn chart scales down to the paper's width; the height it holds on screen would leave a gap below it. */
162
+ [data-slot='plot-figure']:has(svg) { min-height: 0 !important; }
163
+ thead { display: table-header-group; }
164
+ tr, [data-slot='card'] { break-inside: avoid; }
165
+ }