@leonardaustin/ui 0.26.2 → 0.28.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.
Files changed (53) hide show
  1. package/dist/components/charts/AreaChart.js +113 -114
  2. package/dist/components/charts/Heatmap.d.ts +20 -0
  3. package/dist/components/charts/Heatmap.js +46 -0
  4. package/dist/components/charts/chartUtils.d.ts +2 -0
  5. package/dist/components/charts/chartUtils.js +14 -9
  6. package/dist/components/charts/useChartSize.d.ts +5 -0
  7. package/dist/components/charts/useChartSize.js +18 -0
  8. package/dist/components/tables/Pagination.d.ts +3 -1
  9. package/dist/components/tables/Pagination.js +12 -12
  10. package/dist/components/tables/ResourceTable.d.ts +5 -0
  11. package/dist/components/tables/ResourceTable.js +11 -9
  12. package/dist/components/tables/Table.d.ts +22 -3
  13. package/dist/components/tables/Table.js +41 -35
  14. package/dist/components/ui/ActionLink.d.ts +14 -0
  15. package/dist/components/ui/ActionLink.js +12 -0
  16. package/dist/components/ui/CalendarGrid.js +10 -10
  17. package/dist/components/ui/DatePicker.d.ts +1 -1
  18. package/dist/components/ui/DatePicker.js +5 -10
  19. package/dist/components/ui/DateRangePicker.d.ts +3 -1
  20. package/dist/components/ui/DateRangePicker.js +105 -80
  21. package/dist/components/ui/DateTimePicker.js +20 -20
  22. package/dist/components/ui/EmptyState.d.ts +8 -6
  23. package/dist/components/ui/EmptyState.js +11 -10
  24. package/dist/components/ui/ErrorBoundary.d.ts +6 -0
  25. package/dist/components/ui/ErrorBoundary.js +11 -5
  26. package/dist/components/ui/Grid.d.ts +1 -1
  27. package/dist/components/ui/Icon.d.ts +91 -0
  28. package/dist/components/ui/Icon.js +98 -0
  29. package/dist/components/ui/Inline.d.ts +1 -1
  30. package/dist/components/ui/LoadingSpinner.d.ts +7 -3
  31. package/dist/components/ui/LoadingSpinner.js +19 -11
  32. package/dist/components/ui/Meter.d.ts +11 -0
  33. package/dist/components/ui/Meter.js +7 -0
  34. package/dist/components/ui/MetricCard.d.ts +11 -8
  35. package/dist/components/ui/MetricCard.js +18 -15
  36. package/dist/components/ui/PaginationBar.d.ts +3 -3
  37. package/dist/components/ui/PaginationBar.js +35 -33
  38. package/dist/components/ui/SideSheet.d.ts +4 -2
  39. package/dist/components/ui/SideSheet.js +64 -52
  40. package/dist/components/ui/Stack.d.ts +1 -1
  41. package/dist/components/ui/Tabs.d.ts +5 -1
  42. package/dist/components/ui/Tabs.js +23 -21
  43. package/dist/components/ui/Text.d.ts +19 -0
  44. package/dist/components/ui/Text.js +20 -0
  45. package/dist/components/ui/Toolbar.js +13 -13
  46. package/dist/core.css +105 -0
  47. package/dist/hooks/useFocusTrap.js +1 -1
  48. package/dist/index.d.ts +5 -0
  49. package/dist/index.js +134 -129
  50. package/dist/lib/calendar.d.ts +2 -0
  51. package/dist/lib/calendar.js +234 -229
  52. package/dist/styles.css +106 -0
  53. package/package.json +1 -1
@@ -1,211 +1,210 @@
1
1
  import { cn as e } from "../../lib/cn.js";
2
2
  import { mergeRefs as t } from "../../lib/mergeRefs.js";
3
- import { estimateTooltipWidth as n, formatCompactValue as r, getLabelIndices as i, getSvgTooltipPosition as a } from "./chartUtils.js";
4
- import { useId as o, useMemo as s, useRef as c, useState as l } from "react";
5
- import { Fragment as u, jsx as d, jsxs as f } from "react/jsx-runtime";
3
+ import { estimateTextWidth as n, estimateTooltipWidth as r, formatCompactValue as i, getFittingLabelCount as a, getLabelIndices as o, getSvgTooltipPosition as ee } from "./chartUtils.js";
4
+ import { useChartSize as s } from "./useChartSize.js";
5
+ import { useId as c, useMemo as l, useRef as u, useState as d } from "react";
6
+ import { Fragment as f, jsx as p, jsxs as m } from "react/jsx-runtime";
6
7
  //#region src/components/charts/AreaChart.tsx
7
- var p = {
8
+ var h = {
8
9
  top: 16,
9
10
  right: 12,
10
11
  bottom: 28,
11
12
  left: 48
12
- }, m = 600;
13
- function h(e) {
13
+ }, te = 600;
14
+ function g(e) {
14
15
  return e === 0 ? 1 : Math.max(Math.abs(e) * .02, 1);
15
16
  }
16
- function g({ data: g, height: _ = 240, minValue: v, maxValue: y, startAtZero: b = !1, valueFormatter: x, tooltipValueFormatter: S, xLabelCount: C = 5, "aria-label": w = "Area chart", className: T, onPointerMove: E, onPointerLeave: D, ref: O, ...k }) {
17
- let A = o(), j = c(null), M = s(() => t(j, O), [O]), [N, P] = l(null), F = Math.max(p.top + p.bottom + 1, _), I = m - p.left - p.right, L = Math.max(1, F - p.top - p.bottom), R = g.length > 0, z = g[0]?.value ?? 0, B = g[0]?.value ?? 0;
18
- for (let e of g) e.value < z && (z = e.value), e.value > B && (B = e.value);
19
- let V = v ?? z, H = y ?? B;
20
- if (b && v === void 0 && z >= 0 && (V = 0), V === H) {
17
+ function _({ data: _, height: ne = 240, minValue: v, maxValue: y, startAtZero: b = !1, valueFormatter: x, tooltipValueFormatter: re, xLabelCount: S = 5, "aria-label": C = "Area chart", className: w, onPointerMove: ie, onPointerLeave: ae, ref: T, ...oe }) {
18
+ let E = c(), D = u(null), O = l(() => t(D, T), [T]), [k, A] = d(null), j = s(D), M = j?.width ?? te, N = Math.max(h.top + h.bottom + 1, ne), P = j?.height ?? N, F = (e, t) => j && e && S > 0 ? Math.max(t, n(e) / 2 + 4) : t, I = F(_[0]?.date, h.left), L = F(_.at(-1)?.date, h.right), R = Math.max(1, M - I - L), z = Math.max(1, P - h.top - h.bottom), B = _.length > 0, V = _[0]?.value ?? 0, H = _[0]?.value ?? 0;
19
+ for (let e of _) e.value < V && (V = e.value), e.value > H && (H = e.value);
20
+ let U = v ?? V, W = y ?? H;
21
+ if (b && v === void 0 && V >= 0 && (U = 0), U === W) {
21
22
  if (b || v !== void 0 || y !== void 0) {
22
- let e = h(B);
23
- v === void 0 && (V = b && z >= 0 ? 0 : z >= 0 ? Math.max(0, z - e) : z - e), y === void 0 && (H = B + e);
23
+ let e = g(H);
24
+ v === void 0 && (U = b && V >= 0 ? 0 : V >= 0 ? Math.max(0, V - e) : V - e), y === void 0 && (W = H + e);
24
25
  }
25
- V === H && (H = V + 1);
26
+ U === W && (W = U + 1);
26
27
  }
27
- let U = H - V, W = x ?? r, G = S ?? x ?? ((e) => e.toLocaleString());
28
- function K(e) {
29
- return p.left + e / Math.max(g.length - 1, 1) * I;
28
+ let G = W - U, K = x ?? i, q = re ?? x ?? ((e) => e.toLocaleString());
29
+ function J(e) {
30
+ return I + e / Math.max(_.length - 1, 1) * R;
30
31
  }
31
- function q(e) {
32
- return p.top + L - (e - V) / U * L;
32
+ function Y(e) {
33
+ return h.top + z - (e - U) / G * z;
33
34
  }
34
- let J = g.map((e, t) => `${K(t)},${q(e.value)}`).join(" "), Y = R ? [
35
- `${K(0)},${p.top + L}`,
36
- ...g.map((e, t) => `${K(t)},${q(e.value)}`),
37
- `${K(g.length - 1)},${p.top + L}`
38
- ].join(" ") : "", X = i(g.length, C);
39
- function Z(e) {
40
- let t = j.current;
41
- if (!t || g.length === 0) return;
42
- let n = t.getBoundingClientRect();
43
- if (n.width <= 0) return;
44
- let r = ((e.clientX - n.left) / n.width * m - p.left) / I, i = Math.round(r * (g.length - 1)), a = Math.max(0, Math.min(g.length - 1, i));
45
- P({
46
- x: K(a),
47
- y: q(g[a].value),
48
- index: a
49
- });
50
- }
51
- function Q(e) {
52
- P({
53
- x: K(e),
54
- y: q(g[e].value),
55
- index: e
56
- });
35
+ let se = _.map((e, t) => `${J(t)},${Y(e.value)}`).join(" "), ce = B ? [
36
+ `${J(0)},${h.top + z}`,
37
+ ..._.map((e, t) => `${J(t)},${Y(e.value)}`),
38
+ `${J(_.length - 1)},${h.top + z}`
39
+ ].join(" ") : "", X = l(() => _.reduce((e, { date: t }) => Math.max(e, n(t)), 0), [_]), le = j ? Math.min(S, a(_.length, R, X)) : S, ue = o(_.length, le), Z = k === null ? void 0 : _[k], Q = Z && k !== null ? {
40
+ x: J(k),
41
+ y: Y(Z.value)
42
+ } : null;
43
+ function de(e) {
44
+ let t = D.current;
45
+ if (!t || _.length === 0) return;
46
+ let n = t.getScreenCTM(), r;
47
+ if (n) {
48
+ let i = t.createSVGPoint();
49
+ i.x = e.clientX, i.y = e.clientY, r = i.matrixTransform(n.inverse()).x;
50
+ } else {
51
+ let n = t.getBoundingClientRect();
52
+ if (n.width <= 0) return;
53
+ r = (e.clientX - n.left) / n.width * M;
54
+ }
55
+ let i = (r - I) / R, a = Math.round(i * (_.length - 1));
56
+ A(Math.max(0, Math.min(_.length - 1, a)));
57
57
  }
58
58
  function $() {
59
- P(null);
59
+ A(null);
60
60
  }
61
- return /* @__PURE__ */ f("svg", {
62
- ...k,
63
- ref: M,
61
+ return /* @__PURE__ */ m("svg", {
62
+ ...oe,
63
+ ref: O,
64
64
  width: "100%",
65
- viewBox: `0 0 ${m} ${F}`,
65
+ height: N,
66
+ viewBox: `0 0 ${M} ${P}`,
66
67
  onPointerMove: (e) => {
67
- E?.(e), !e.defaultPrevented && Z(e);
68
+ ie?.(e), !e.defaultPrevented && de(e);
68
69
  },
69
70
  onPointerLeave: (e) => {
70
- D?.(e), !e.defaultPrevented && $();
71
+ ae?.(e), !e.defaultPrevented && $();
71
72
  },
72
- className: e("select-none", T),
73
+ className: e("select-none", w),
73
74
  role: "img",
74
- "aria-label": w,
75
+ "aria-label": C,
75
76
  children: [
76
- /* @__PURE__ */ d("defs", { children: /* @__PURE__ */ f("linearGradient", {
77
- id: A,
77
+ /* @__PURE__ */ p("defs", { children: /* @__PURE__ */ m("linearGradient", {
78
+ id: E,
78
79
  x1: "0",
79
80
  y1: "0",
80
81
  x2: "0",
81
82
  y2: "1",
82
- children: [/* @__PURE__ */ d("stop", {
83
+ children: [/* @__PURE__ */ p("stop", {
83
84
  offset: "0%",
84
85
  stopColor: "var(--accent)",
85
86
  stopOpacity: .3
86
- }), /* @__PURE__ */ d("stop", {
87
+ }), /* @__PURE__ */ p("stop", {
87
88
  offset: "100%",
88
89
  stopColor: "var(--accent)",
89
90
  stopOpacity: 0
90
91
  })]
91
92
  }) }),
92
- /* @__PURE__ */ d("text", {
93
- x: p.left - 8,
94
- y: p.top,
93
+ /* @__PURE__ */ p("text", {
94
+ x: I - 8,
95
+ y: h.top,
95
96
  textAnchor: "end",
96
97
  dominantBaseline: "central",
97
98
  fill: "var(--text-tertiary)",
98
99
  fontSize: 10,
99
- children: W(H)
100
+ children: K(W)
100
101
  }),
101
- /* @__PURE__ */ d("text", {
102
- x: p.left - 8,
103
- y: p.top + L,
102
+ /* @__PURE__ */ p("text", {
103
+ x: I - 8,
104
+ y: h.top + z,
104
105
  textAnchor: "end",
105
106
  dominantBaseline: "central",
106
107
  fill: "var(--text-tertiary)",
107
108
  fontSize: 10,
108
- children: W(V)
109
+ children: K(U)
109
110
  }),
110
- /* @__PURE__ */ d("line", {
111
- x1: p.left,
112
- y1: p.top + L,
113
- x2: p.left + I,
114
- y2: p.top + L,
111
+ /* @__PURE__ */ p("line", {
112
+ x1: I,
113
+ y1: h.top + z,
114
+ x2: I + R,
115
+ y2: h.top + z,
115
116
  stroke: "var(--border)",
116
117
  strokeWidth: 1
117
118
  }),
118
- R && /* @__PURE__ */ d("polygon", {
119
- points: Y,
120
- fill: `url(#${A})`
119
+ B && /* @__PURE__ */ p("polygon", {
120
+ points: ce,
121
+ fill: `url(#${E})`
121
122
  }),
122
- R && /* @__PURE__ */ d("polyline", {
123
- points: J,
123
+ B && /* @__PURE__ */ p("polyline", {
124
+ points: se,
124
125
  fill: "none",
125
126
  stroke: "var(--accent)",
126
127
  strokeWidth: 2,
127
128
  strokeLinecap: "round",
128
129
  strokeLinejoin: "round"
129
130
  }),
130
- g.map((e, t) => /* @__PURE__ */ d("circle", {
131
- cx: K(t),
132
- cy: q(e.value),
131
+ _.map((e, t) => /* @__PURE__ */ p("circle", {
132
+ cx: J(t),
133
+ cy: Y(e.value),
133
134
  r: 8,
134
135
  fill: "transparent",
135
136
  tabIndex: 0,
136
137
  role: "button",
137
- "aria-label": `${e.date}: ${G(e.value)}`,
138
- onFocus: () => Q(t),
138
+ "aria-label": `${e.date}: ${q(e.value)}`,
139
+ onFocus: () => A(t),
139
140
  onBlur: $
140
141
  }, `${e.date}-${t}-hit`)),
141
- X.map((e) => /* @__PURE__ */ d("text", {
142
- x: K(e),
143
- y: F - 4,
142
+ ue.map((e) => /* @__PURE__ */ p("text", {
143
+ x: J(e),
144
+ y: P - 4,
144
145
  textAnchor: "middle",
145
146
  fill: "var(--text-tertiary)",
146
147
  fontSize: 10,
147
- children: g[e].date
148
- }, `${g[e].date}-${e}`)),
149
- N && /* @__PURE__ */ f(u, { children: [
150
- /* @__PURE__ */ d("line", {
151
- x1: N.x,
152
- y1: p.top,
153
- x2: N.x,
154
- y2: p.top + L,
148
+ children: _[e].date
149
+ }, `${_[e].date}-${e}`)),
150
+ Q && Z && /* @__PURE__ */ m(f, { children: [
151
+ /* @__PURE__ */ p("line", {
152
+ x1: Q.x,
153
+ y1: h.top,
154
+ x2: Q.x,
155
+ y2: h.top + z,
155
156
  stroke: "var(--border-strong)",
156
157
  strokeWidth: 1,
157
158
  strokeDasharray: "3 3"
158
159
  }),
159
- /* @__PURE__ */ d("circle", {
160
- cx: N.x,
161
- cy: N.y,
160
+ /* @__PURE__ */ p("circle", {
161
+ cx: Q.x,
162
+ cy: Q.y,
162
163
  r: 4,
163
164
  fill: "var(--accent)",
164
165
  stroke: "var(--bg-secondary)",
165
166
  strokeWidth: 2
166
167
  }),
167
168
  (() => {
168
- let e = g[N.index];
169
- if (!e) return null;
170
- let t = e.date, r = G(e.value), i = a(N.x, N.y, {
171
- boundsHeight: F,
172
- boundsWidth: m,
169
+ let e = Z.date, t = q(Z.value), n = ee(Q.x, Q.y, {
170
+ boundsHeight: P,
171
+ boundsWidth: M,
173
172
  height: 28,
174
173
  offset: 10,
175
- width: n([t, r], {
174
+ width: r([e, t], {
176
175
  maxWidth: 180,
177
176
  minWidth: 90
178
177
  })
179
- }), o = i.x + i.width / 2;
180
- return /* @__PURE__ */ f(u, { children: [
181
- /* @__PURE__ */ d("rect", {
182
- x: i.x,
183
- y: i.y,
184
- width: i.width,
185
- height: i.height,
178
+ }), i = n.x + n.width / 2;
179
+ return /* @__PURE__ */ m(f, { children: [
180
+ /* @__PURE__ */ p("rect", {
181
+ x: n.x,
182
+ y: n.y,
183
+ width: n.width,
184
+ height: n.height,
186
185
  rx: 4,
187
186
  fill: "var(--bg-tooltip, var(--bg-tertiary))",
188
187
  stroke: "var(--border)",
189
188
  strokeWidth: 1
190
189
  }),
191
- /* @__PURE__ */ d("text", {
192
- x: o,
193
- y: i.y + 10,
190
+ /* @__PURE__ */ p("text", {
191
+ x: i,
192
+ y: n.y + 10,
194
193
  textAnchor: "middle",
195
194
  dominantBaseline: "central",
196
195
  fill: "var(--text-secondary)",
197
196
  fontSize: 9,
198
- children: t
197
+ children: e
199
198
  }),
200
- /* @__PURE__ */ d("text", {
201
- x: o,
202
- y: i.y + 22,
199
+ /* @__PURE__ */ p("text", {
200
+ x: i,
201
+ y: n.y + 22,
203
202
  textAnchor: "middle",
204
203
  dominantBaseline: "central",
205
204
  fill: "var(--text-primary)",
206
205
  fontSize: 11,
207
206
  fontWeight: 600,
208
- children: r
207
+ children: t
209
208
  })
210
209
  ] });
211
210
  })()
@@ -214,4 +213,4 @@ function g({ data: g, height: _ = 240, minValue: v, maxValue: y, startAtZero: b
214
213
  });
215
214
  }
216
215
  //#endregion
217
- export { g as AreaChart };
216
+ export { _ as AreaChart };
@@ -0,0 +1,20 @@
1
+ import type { ComponentPropsWithRef } from "react";
2
+ export interface HeatmapProps extends Omit<ComponentPropsWithRef<"figure">, "children"> {
3
+ /** Visible table caption and accessible name of the scrolling region. */
4
+ caption: string;
5
+ /** Labels down the left edge, in matrix order. */
6
+ rowLabels: readonly string[];
7
+ /** Labels across the top, in matrix order. */
8
+ columnLabels: readonly string[];
9
+ /** Non-negative readings by row and column. Missing rows, short rows and null readings display a dash for each absent value. */
10
+ values: readonly (readonly (number | null | undefined)[] | undefined)[];
11
+ /** Optional heading above the row labels. */
12
+ rowHeading?: string;
13
+ /** Positive upper bound for the four colour bands; higher readings use the top band. Defaults to the largest reading. */
14
+ max?: number;
15
+ /** Tooltip and accessible name for a numeric cell. Defaults to the displayed number. */
16
+ valueLabel?: (value: number, row: string, column: string) => string;
17
+ /** Tooltip and accessible name for an absent reading. */
18
+ missingLabel?: string;
19
+ }
20
+ export declare function Heatmap({ caption, rowLabels, columnLabels, values, rowHeading, max, valueLabel, missingLabel, className, ...props }: HeatmapProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,46 @@
1
+ import { cn as e } from "../../lib/cn.js";
2
+ import { Table as t, TableBody as n, TableCell as r, TableHead as i, TableHeaderCell as a, TableRow as o } from "../tables/Table.js";
3
+ import { jsx as s, jsxs as c } from "react/jsx-runtime";
4
+ //#region src/components/charts/Heatmap.tsx
5
+ function l(e) {
6
+ let t = 0;
7
+ for (let n of e) if (n !== void 0) for (let e of n) t = Math.max(t, e ?? 0);
8
+ return t;
9
+ }
10
+ function u({ caption: u, rowLabels: d, columnLabels: f, values: p, rowHeading: m, max: h, valueLabel: g, missingLabel: _ = "Unavailable", className: v, ...y }) {
11
+ let b = h ?? l(p);
12
+ return /* @__PURE__ */ c("figure", {
13
+ ...y,
14
+ className: e("min-w-0", v),
15
+ children: [/* @__PURE__ */ c(t, {
16
+ caption: u,
17
+ className: "ui-heatmap",
18
+ wrapperProps: {
19
+ role: "region",
20
+ tabIndex: 0,
21
+ "aria-label": u
22
+ },
23
+ children: [/* @__PURE__ */ s(i, { children: /* @__PURE__ */ c(o, { children: [m ? /* @__PURE__ */ s(a, { children: m }) : /* @__PURE__ */ s("td", {}), f.map((e, t) => /* @__PURE__ */ s(a, { children: e }, t))] }) }), /* @__PURE__ */ s(n, { children: d.map((e, t) => /* @__PURE__ */ c(o, { children: [/* @__PURE__ */ s(a, {
24
+ scope: "row",
25
+ children: e
26
+ }), f.map((n, i) => {
27
+ let a = p[t]?.[i], o = a == null ? _ : g?.(a, e, n) ?? String(a);
28
+ return /* @__PURE__ */ s(r, {
29
+ "data-intensity": a == null ? "missing" : a <= 0 ? 0 : Math.min(4, Math.ceil(4 * a / b)),
30
+ "aria-label": o,
31
+ title: o,
32
+ children: a ?? "—"
33
+ }, i);
34
+ })] }, t)) })]
35
+ }), /* @__PURE__ */ c("figcaption", {
36
+ className: "text-xs text-text-secondary",
37
+ children: [
38
+ "Colour scale from 0 to ",
39
+ b,
40
+ "."
41
+ ]
42
+ })]
43
+ });
44
+ }
45
+ //#endregion
46
+ export { u as Heatmap };
@@ -1,6 +1,8 @@
1
1
  export declare function formatCompactValue(value: number): string;
2
2
  export declare function resolveChartColor(color: string | undefined): string;
3
3
  export declare function getLabelIndices(length: number, labelCount: number): number[];
4
+ /** Limit evenly sampled ticks to whole intervals that fit a label plus a gap. */
5
+ export declare function getFittingLabelCount(length: number, plotWidth: number, labelWidth: number): number;
4
6
  export declare function getPositiveValue(value: number): number;
5
7
  export interface ChartTooltipPosition {
6
8
  height: number;
@@ -22,22 +22,27 @@ function i(e, t) {
22
22
  for (let e = 0; e < n; e += 1) i.add(Math.round(e * r));
23
23
  return i.add(e - 1), Array.from(i).sort((e, t) => e - t);
24
24
  }
25
- function a(e) {
25
+ function a(e, t, n) {
26
+ if (e < 2) return e;
27
+ let r = t / (e - 1), i = Math.max(1, Math.ceil((n + 12) / r));
28
+ return 1 + Math.floor((e - 1) / i);
29
+ }
30
+ function o(e) {
26
31
  return Number.isFinite(e) ? Math.max(0, e) : 0;
27
32
  }
28
- function o(e, t) {
33
+ function s(e, t) {
29
34
  let n = String(e ?? "");
30
35
  return t === void 0 || t <= 0 || n.length <= t ? n : t <= 3 ? n.slice(0, t) : `${n.slice(0, t - 3)}...`;
31
36
  }
32
- function s(e, t = 10) {
37
+ function c(e, t = 10) {
33
38
  let n = 0;
34
39
  for (let r of e) r === " " ? n += t * .32 : /[A-Z0-9]/.test(r) ? n += t * .62 : /[il.,:;|'`]/.test(r) ? n += t * .28 : /[MW@#%&]/.test(r) ? n += t * .82 : n += t * .54;
35
40
  return Math.ceil(n);
36
41
  }
37
- function c(t, { maxWidth: n = 220, minWidth: r = 72, paddingX: i = 20 } = {}) {
38
- return e(t.reduce((e, t) => Math.max(e, s(t, 11)), 0) + i, r, n);
42
+ function l(t, { maxWidth: n = 220, minWidth: r = 72, paddingX: i = 20 } = {}) {
43
+ return e(t.reduce((e, t) => Math.max(e, c(t, 11)), 0) + i, r, n);
39
44
  }
40
- function l(t, n, { boundsHeight: r, boundsWidth: i, height: a, margin: o = 0, offset: s = 8, width: c }) {
45
+ function u(t, n, { boundsHeight: r, boundsWidth: i, height: a, margin: o = 0, offset: s = 8, width: c }) {
41
46
  let l = Math.max(1, Math.min(c, i - o * 2)), u = Math.max(1, Math.min(a, r - o * 2)), d = Math.max(o, i - l - o), f = Math.max(o, r - u - o), p = e(t - l / 2, o, d), m = n - u - s, h = m >= o ? "above" : "below";
42
47
  return {
43
48
  height: u,
@@ -47,8 +52,8 @@ function l(t, n, { boundsHeight: r, boundsWidth: i, height: a, margin: o = 0, of
47
52
  y: h === "above" ? m : e(n + s, o, f)
48
53
  };
49
54
  }
50
- function u({ anchorX: e, anchorY: t, boundsHeight: n, boundsWidth: r, height: i, margin: a = 0, offset: o = 8, width: s }) {
51
- let c = l(e, t, {
55
+ function d({ anchorX: e, anchorY: t, boundsHeight: n, boundsWidth: r, height: i, margin: a = 0, offset: o = 8, width: s }) {
56
+ let c = u(e, t, {
52
57
  boundsHeight: n,
53
58
  boundsWidth: r,
54
59
  height: i,
@@ -65,4 +70,4 @@ function u({ anchorX: e, anchorY: t, boundsHeight: n, boundsWidth: r, height: i,
65
70
  };
66
71
  }
67
72
  //#endregion
68
- export { c as estimateTooltipWidth, n as formatCompactValue, u as getFloatingTooltipStyle, i as getLabelIndices, a as getPositiveValue, l as getSvgTooltipPosition, r as resolveChartColor, o as truncateChartLabel };
73
+ export { c as estimateTextWidth, l as estimateTooltipWidth, n as formatCompactValue, a as getFittingLabelCount, d as getFloatingTooltipStyle, i as getLabelIndices, o as getPositiveValue, u as getSvgTooltipPosition, r as resolveChartColor, s as truncateChartLabel };
@@ -0,0 +1,5 @@
1
+ import { type RefObject } from "react";
2
+ export declare function useChartSize(ref: RefObject<SVGSVGElement | null>): {
3
+ width: number;
4
+ height: number;
5
+ } | undefined;
@@ -0,0 +1,18 @@
1
+ import { useEffect as e, useState as t } from "react";
2
+ //#region src/components/charts/useChartSize.ts
3
+ function n(n) {
4
+ let [r, i] = t();
5
+ return e(() => {
6
+ if (!n.current || typeof ResizeObserver > "u") return;
7
+ let e = new ResizeObserver(([e]) => {
8
+ let { width: t, height: n } = e.contentRect;
9
+ t > 0 && n > 0 && i({
10
+ width: t,
11
+ height: n
12
+ });
13
+ });
14
+ return e.observe(n.current), () => e.disconnect();
15
+ }, [n]), r;
16
+ }
17
+ //#endregion
18
+ export { n as useChartSize };
@@ -8,6 +8,8 @@ export interface PaginationProps extends Omit<ComponentPropsWithRef<"div">, "chi
8
8
  onPageChange: (page: number) => void;
9
9
  /** Disable navigation while the next page is loading. */
10
10
  loading?: boolean;
11
+ /** Keep arrows visible past the last page and focusable during a refetch. */
12
+ keepNavigation?: boolean;
11
13
  /** Optional item total, displayed as “N in total”. */
12
14
  total?: number;
13
15
  /**
@@ -16,4 +18,4 @@ export interface PaginationProps extends Omit<ComponentPropsWithRef<"div">, "chi
16
18
  */
17
19
  summary?: ReactNode | ((total: number | undefined) => ReactNode);
18
20
  }
19
- export declare function Pagination({ page, totalPages, onPageChange, loading, total, summary, className, ref, ...rest }: PaginationProps): import("react/jsx-runtime").JSX.Element;
21
+ export declare function Pagination({ page, totalPages, onPageChange, loading, keepNavigation, total, summary, className, ref, ...rest }: PaginationProps): import("react/jsx-runtime").JSX.Element;
@@ -2,21 +2,21 @@ import { cn as e } from "../../lib/cn.js";
2
2
  import { Fragment as t, jsx as n, jsxs as r } from "react/jsx-runtime";
3
3
  import { ChevronLeft as i, ChevronRight as a } from "lucide-react";
4
4
  //#region src/components/tables/Pagination.tsx
5
- function o({ page: o, totalPages: s, onPageChange: c, loading: l = !1, total: u, summary: d, className: f, ref: p, ...m }) {
6
- let h = s <= 1 && !l && u === void 0 && d == null, g = d !== null && (l || u !== void 0 || d !== void 0), _ = [];
7
- for (let e = 1; e <= s; e++) e === 1 || e === s || e >= o - 1 && e <= o + 1 ? _.push(e) : _[_.length - 1] !== "ellipsis" && _.push("ellipsis");
5
+ function o({ page: o, totalPages: s, onPageChange: c, loading: l = !1, keepNavigation: u = !1, total: d, summary: f, className: p, ref: m, ...h }) {
6
+ let g = s > 1 || u && o > 1, _ = !g && !l && d === void 0 && f == null, v = f !== null && (l || d !== void 0 || f !== void 0), y = [];
7
+ for (let e = 1; e <= s; e++) e === 1 || e === s || e >= o - 1 && e <= o + 1 ? y.push(e) : y[y.length - 1] !== "ellipsis" && y.push("ellipsis");
8
8
  return /* @__PURE__ */ r("div", {
9
- ref: p,
10
- ...m,
11
- className: h ? "contents" : e("flex items-center gap-1", f),
9
+ ref: m,
10
+ ...h,
11
+ className: _ ? "contents" : e("flex items-center gap-1", p),
12
12
  children: [/* @__PURE__ */ n("span", {
13
13
  role: "status",
14
- className: g ? "text-text-tertiary text-xs" : "sr-only",
15
- children: g && (l ? "Loading results..." : d === void 0 ? `${u} in total` : typeof d == "function" ? d(u) : d)
16
- }), s > 1 && /* @__PURE__ */ r(t, { children: [
14
+ className: v ? "text-text-tertiary text-xs" : "sr-only",
15
+ children: v && (l ? "Loading results..." : f === void 0 ? `${d} in total` : typeof f == "function" ? f(d) : f)
16
+ }), g && /* @__PURE__ */ r(t, { children: [
17
17
  /* @__PURE__ */ n("button", {
18
18
  type: "button",
19
- disabled: o === 1,
19
+ disabled: !(u && l) && o === 1,
20
20
  "aria-disabled": l || void 0,
21
21
  onClick: () => {
22
22
  l || c(o - 1);
@@ -25,7 +25,7 @@ function o({ page: o, totalPages: s, onPageChange: c, loading: l = !1, total: u,
25
25
  "aria-label": "Previous page",
26
26
  children: /* @__PURE__ */ n(i, { className: "h-3.5 w-3.5" })
27
27
  }),
28
- _.map((t, r) => t === "ellipsis" ? /* @__PURE__ */ n("span", {
28
+ y.map((t, r) => t === "ellipsis" ? /* @__PURE__ */ n("span", {
29
29
  className: "text-text-tertiary flex h-7 w-7 items-center justify-center text-xs",
30
30
  children: "..."
31
31
  }, `e${r}`) : /* @__PURE__ */ n("button", {
@@ -39,7 +39,7 @@ function o({ page: o, totalPages: s, onPageChange: c, loading: l = !1, total: u,
39
39
  }, t)),
40
40
  /* @__PURE__ */ n("button", {
41
41
  type: "button",
42
- disabled: o >= s,
42
+ disabled: !(u && l) && o >= s,
43
43
  "aria-disabled": l || void 0,
44
44
  onClick: () => {
45
45
  l || c(o + 1);
@@ -10,6 +10,11 @@ export interface Column<T> {
10
10
  * screen readers (for example "Sort by name"). Only used when `sortable`.
11
11
  */
12
12
  sortLabel?: string;
13
+ /**
14
+ * Hide this column at wrapper widths of 32rem or less.
15
+ * Hiding uses a container query, so place the table in a block-level parent; shrink-to-fit parents such as inline-block collapse it.
16
+ */
17
+ lowPriority?: boolean;
13
18
  /** CSS width of the column, such as "120px" or "20%". */
14
19
  width?: string;
15
20
  /**
@@ -1,13 +1,13 @@
1
1
  import { cn as e } from "../../lib/cn.js";
2
- import { sortRows as t } from "./sortRows.js";
3
- import { Table as n, TableBody as r, TableCell as i, TableEmptyRow as a, TableHead as o, TableHeaderCell as s, TableRow as c } from "./Table.js";
2
+ import { Table as t, TableBody as n, TableCell as r, TableEmptyRow as i, TableHead as a, TableHeaderCell as o, TableRow as s } from "./Table.js";
3
+ import { sortRows as c } from "./sortRows.js";
4
4
  import { createElement as l, useMemo as u, useState as d } from "react";
5
5
  import { jsx as f, jsxs as p } from "react/jsx-runtime";
6
6
  import { ArrowDown as m, ArrowUp as h } from "lucide-react";
7
7
  //#region src/components/tables/ResourceTable.tsx
8
8
  var g = { "--ui-table-cell-padding-y": "0px" };
9
9
  function _({ data: _, columns: v, getRowId: y, onRowClick: b, emptyMessage: x = "No data", sortKey: S, sortDir: C, onSortChange: w, caption: T, loading: E = !1, loadingMessage: D = "Loading…", className: O, tableProps: k, getRowProps: A, isRowSelected: j, ref: M, ...N }) {
10
- let P = w !== void 0, [F, I] = d(null), [L, R] = d("asc"), z = P ? S ?? null : F, B = P ? C ?? "asc" : L, V = u(() => P ? _ : t(_, v, z, B), [
10
+ let P = w !== void 0, [F, I] = d(null), [L, R] = d("asc"), z = P ? S ?? null : F, B = P ? C ?? "asc" : L, V = u(() => P ? _ : c(_, v, z, B), [
11
11
  P,
12
12
  _,
13
13
  v,
@@ -22,7 +22,7 @@ function _({ data: _, columns: v, getRowId: y, onRowClick: b, emptyMessage: x =
22
22
  }
23
23
  I(e), R(t);
24
24
  }
25
- return /* @__PURE__ */ p(n, {
25
+ return /* @__PURE__ */ p(t, {
26
26
  ...k,
27
27
  wrapperProps: {
28
28
  ...N,
@@ -42,7 +42,8 @@ function _({ data: _, columns: v, getRowId: y, onRowClick: b, emptyMessage: x =
42
42
  ...g,
43
43
  ...k?.style
44
44
  },
45
- children: [/* @__PURE__ */ f(o, { children: /* @__PURE__ */ f(c, { children: v.map((t) => /* @__PURE__ */ f(s, {
45
+ children: [/* @__PURE__ */ f(a, { children: /* @__PURE__ */ f(s, { children: v.map((t) => /* @__PURE__ */ f(o, {
46
+ lowPriority: t.lowPriority,
46
47
  className: e("text-2xs h-7", t.sortable && "hover:text-text-table-header-hover cursor-pointer select-none"),
47
48
  style: { width: t.width },
48
49
  sort: t.sortable ? z === t.key ? B === "asc" ? "ascending" : "descending" : "none" : void 0,
@@ -56,13 +57,13 @@ function _({ data: _, columns: v, getRowId: y, onRowClick: b, emptyMessage: x =
56
57
  className: "h-3 w-3"
57
58
  })]
58
59
  }) : t.header
59
- }, t.key)) }) }), /* @__PURE__ */ f(r, { children: V.length === 0 ? /* @__PURE__ */ f(a, {
60
+ }, t.key)) }) }), /* @__PURE__ */ f(n, { children: V.length === 0 ? /* @__PURE__ */ f(i, {
60
61
  colSpan: v.length,
61
62
  cellClassName: "h-32 px-0 text-center",
62
63
  children: E ? D : x
63
64
  }) : V.map((t) => {
64
- let n = A?.(t) ?? {}, r = j?.(t) ?? n["aria-selected"], a = r === !0 || r === "true";
65
- return /* @__PURE__ */ l(c, {
65
+ let n = A?.(t) ?? {}, i = j?.(t) ?? n["aria-selected"], a = i === !0 || i === "true";
66
+ return /* @__PURE__ */ l(s, {
66
67
  tabIndex: b ? 0 : void 0,
67
68
  ...n,
68
69
  key: y(t),
@@ -75,7 +76,8 @@ function _({ data: _, columns: v, getRowId: y, onRowClick: b, emptyMessage: x =
75
76
  onKeyDown: (e) => {
76
77
  n.onKeyDown?.(e), !(!b || e.defaultPrevented || e.repeat || e.target !== e.currentTarget || e.key !== "Enter" && e.key !== " ") && (e.preventDefault(), b(t));
77
78
  }
78
- }, v.map((e) => /* @__PURE__ */ f(i, {
79
+ }, v.map((e) => /* @__PURE__ */ f(r, {
80
+ lowPriority: e.lowPriority,
79
81
  nowrap: !0,
80
82
  className: e.cellClassName,
81
83
  onClick: e.interactive ? (e) => e.stopPropagation() : void 0,