@columenlabs/lumen-ui 0.1.130 → 0.1.131

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.
@@ -42,7 +42,7 @@ export function StackedColumns({ rows, x, parts, label, height = 220, tick = Str
42
42
  const total = (r) => parts.reduce((n, p) => n + (Number(r[p.key]) || 0), 0);
43
43
  // The highest part with a value carries the column's rounded cap.
44
44
  const top = (r) => parts.findLast((p) => Number(r[p.key]) > 0)?.key;
45
- const ticks = niceTicks(Math.max(0, ...rows.map(total)));
45
+ const ticks = niceTicks(Math.max(0, ...rows.map(total)), 4, rows.every((r) => Number.isInteger(total(r))));
46
46
  return (_jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(ChartContainer, { config: config, role: "img", "aria-label": label, className: "aspect-auto w-full", style: { height }, children: _jsxs(BarChart, { data: rows, margin: { left: 0, right: 0, top: 8, bottom: 0 }, children: [_jsx(CartesianGrid, { vertical: false, strokeDasharray: "3 3" }), _jsx(XAxis, { dataKey: x, tickLine: false, axisLine: false, tickMargin: 8, minTickGap: 12, tickFormatter: (v) => tick(String(v)) }), _jsx(YAxis, { tickLine: false, axisLine: false, domain: [0, ticks.at(-1) ?? 'auto'], ticks: ticks, width: axisWidth(ticks.map(fmt)), tick: axisTick(fmt) }), _jsx(ChartTooltip, { cursor: { fill: 'var(--muted)', opacity: 0.5 }, content: _jsx(ChartTooltipContent, { labelFormatter: (_, payload) => {
47
47
  const r = payload?.[0]?.payload;
48
48
  return r ? (_jsxs("span", { className: "flex w-full gap-3", children: [_jsx("span", { children: tick(String(r[x])) }), _jsx("span", { className: "num ml-auto", children: fmt(total(r)) })] })) : null;
@@ -54,7 +54,8 @@ export function TimeLines({ rows, x, lines, label, height = 220, tick = String,
54
54
  const config = Object.fromEntries(lines.map((l) => [l.key, { label: l.name, color: l.fill }]));
55
55
  const axis = (right) => {
56
56
  const keys = lines.filter((l) => !!l.right === right).map((l) => l.key);
57
- return niceTicks(Math.max(0, ...rows.flatMap((r) => keys.map((k) => Number(r[k]) || 0))));
57
+ const values = rows.flatMap((r) => keys.map((k) => Number(r[k]) || 0));
58
+ return niceTicks(Math.max(0, ...values), 4, values.every(Number.isInteger));
58
59
  };
59
60
  const left = axis(false);
60
61
  const hasRight = lines.some((l) => l.right);
@@ -113,14 +114,16 @@ export function AllocationBar({ items, total, config, tooltip, share, }) {
113
114
  }
114
115
  /**
115
116
  * Round axis steps (1, 2, 2.5 or 5 times a power of ten) from 0 to just above `max`, about four
116
- * of them, so a value axis reads 0, 100k, 200k, 300k rather than 95k, 190k, 285k.
117
+ * of them, so a value axis reads 0, 100k, 200k, 300k rather than 95k, 190k, 285k. When every value
118
+ * is a whole number (a count), so is every step: 0, 1, 2 rather than 0, 0.5, 1, 1.5.
117
119
  */
118
- function niceTicks(max, count = 4) {
120
+ function niceTicks(max, count = 4, whole = false) {
119
121
  if (!(max > 0))
120
122
  return [0, 1];
121
123
  const raw = max / count;
122
124
  const pow = 10 ** Math.floor(Math.log10(raw));
123
- const step = ([1, 2, 2.5, 5, 10].find((m) => m * pow >= raw) ?? 10) * pow;
125
+ const steps = whole ? [1, 2, 5, 10] : [1, 2, 2.5, 5, 10];
126
+ const step = Math.max(whole ? 1 : 0, (steps.find((m) => m * pow >= raw) ?? 10) * pow);
124
127
  const n = Math.ceil(max / step - 1e-9);
125
128
  return Array.from({ length: n + 1 }, (_, i) => Math.round(i * step * 1e6) / 1e6);
126
129
  }
package/dist/page.d.ts CHANGED
@@ -21,7 +21,10 @@ export interface PageHeaderProps {
21
21
  }
22
22
  /** The fixed-height header; `Page` renders it, or a page with several states renders it itself. */
23
23
  export declare function PageHeader({ crumbs, actions, layout, meta, status }: PageHeaderProps): import("react").JSX.Element;
24
- /** The page body: the shell's gutter, section gap and max width. */
24
+ /**
25
+ * The page body: the shell's gutter, section gap and max width. A plain block, since the shell's
26
+ * inset is the page's one `main` landmark.
27
+ */
25
28
  export declare function PageBody({ className, children }: {
26
29
  className?: string;
27
30
  children: ReactNode;
package/dist/page.js CHANGED
@@ -36,9 +36,12 @@ export function PageHeader({ crumbs, actions, layout, meta, status }) {
36
36
  isMobile &&
37
37
  '[&_[data-slot=button]]:size-8 [&_[data-slot=button]]:gap-0 [&_[data-slot=button]]:px-0 [&_[data-slot=button]]:text-[0px]'), children: [actions && (_jsxs(_Fragment, { children: [_jsx("div", { "data-slot": "shell-page-actions", className: "flex items-center gap-0.5", children: actions }), _jsx(Separator, { orientation: "vertical", className: "mx-2 data-vertical:h-5 data-vertical:self-center" })] })), _jsxs("div", { "data-slot": "shell-actions", className: "flex items-center gap-0.5", children: [layout, _jsx(LumenFinderButton, {}), hideAmounts && (_jsx(IconButton, { icon: hidden ? EyeOffIcon : EyeIcon, label: hidden ? 'Show amounts' : 'Hide amounts', "aria-pressed": hidden, onClick: () => setPref('hideAmounts', !hidden) })), refresh && (_jsx(IconButton, { icon: RefreshCwIcon, busy: refreshing, label: "Refresh (skip cache)", disabled: refreshing, onClick: () => void refresh() })), headerActions] })] })] }), status && statusSlot && createPortal(status, statusSlot)] }));
38
38
  }
39
- /** The page body: the shell's gutter, section gap and max width. */
39
+ /**
40
+ * The page body: the shell's gutter, section gap and max width. A plain block, since the shell's
41
+ * inset is the page's one `main` landmark.
42
+ */
40
43
  export function PageBody({ className, children }) {
41
- return (_jsx("main", { className: cn('mx-auto flex w-full max-w-(--shell-max-width) min-w-0 flex-1 flex-col gap-(--shell-section-gap) p-(--shell-gutter)', className), children: children }));
44
+ return (_jsx("div", { className: cn('mx-auto flex w-full max-w-(--shell-max-width) min-w-0 flex-1 flex-col gap-(--shell-section-gap) p-(--shell-gutter)', className), children: children }));
42
45
  }
43
46
  export function Page({ className, children, ...header }) {
44
47
  return (_jsxs(_Fragment, { children: [_jsx(PageHeader, { ...header }), _jsx(PageBody, { className: className, children: children })] }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@columenlabs/lumen-ui",
3
- "version": "0.1.130",
3
+ "version": "0.1.131",
4
4
  "description": "Lumen: shared React components (frame, views, widgets, charts, drawers).",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -49,7 +49,7 @@
49
49
  "@codemirror/lang-javascript": "6.2.5",
50
50
  "@codemirror/lang-json": "6.0.2",
51
51
  "@codemirror/lang-sql": "6.10.0",
52
- "@columenlabs/lumen-ui-types": "0.1.130",
52
+ "@columenlabs/lumen-ui-types": "0.1.131",
53
53
  "@dnd-kit/core": "6.3.1",
54
54
  "@dnd-kit/sortable": "10.0.0",
55
55
  "@dnd-kit/utilities": "3.2.2",