@leonardaustin/ui 0.27.0 → 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.
- package/dist/components/charts/AreaChart.js +113 -114
- package/dist/components/charts/Heatmap.d.ts +20 -0
- package/dist/components/charts/Heatmap.js +46 -0
- package/dist/components/charts/chartUtils.d.ts +2 -0
- package/dist/components/charts/chartUtils.js +14 -9
- package/dist/components/charts/useChartSize.d.ts +5 -0
- package/dist/components/charts/useChartSize.js +18 -0
- package/dist/components/tables/Pagination.d.ts +3 -1
- package/dist/components/tables/Pagination.js +12 -12
- package/dist/components/tables/ResourceTable.d.ts +5 -0
- package/dist/components/tables/ResourceTable.js +11 -9
- package/dist/components/tables/Table.d.ts +22 -3
- package/dist/components/tables/Table.js +41 -35
- package/dist/components/ui/ActionLink.d.ts +14 -0
- package/dist/components/ui/ActionLink.js +12 -0
- package/dist/components/ui/DateRangePicker.js +107 -76
- package/dist/components/ui/EmptyState.d.ts +8 -6
- package/dist/components/ui/EmptyState.js +11 -10
- package/dist/components/ui/ErrorBoundary.d.ts +6 -0
- package/dist/components/ui/ErrorBoundary.js +11 -5
- package/dist/components/ui/Grid.d.ts +1 -1
- package/dist/components/ui/Icon.d.ts +91 -0
- package/dist/components/ui/Icon.js +98 -0
- package/dist/components/ui/Inline.d.ts +1 -1
- package/dist/components/ui/LoadingSpinner.d.ts +7 -3
- package/dist/components/ui/LoadingSpinner.js +19 -11
- package/dist/components/ui/Meter.d.ts +11 -0
- package/dist/components/ui/Meter.js +7 -0
- package/dist/components/ui/MetricCard.d.ts +11 -8
- package/dist/components/ui/MetricCard.js +18 -15
- package/dist/components/ui/PaginationBar.d.ts +3 -3
- package/dist/components/ui/PaginationBar.js +35 -33
- package/dist/components/ui/SideSheet.d.ts +4 -2
- package/dist/components/ui/SideSheet.js +64 -52
- package/dist/components/ui/Stack.d.ts +1 -1
- package/dist/components/ui/Tabs.d.ts +5 -1
- package/dist/components/ui/Tabs.js +23 -21
- package/dist/components/ui/Text.d.ts +19 -0
- package/dist/components/ui/Text.js +20 -0
- package/dist/components/ui/Toolbar.js +13 -13
- package/dist/core.css +105 -0
- package/dist/hooks/useFocusTrap.js +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.js +134 -129
- package/dist/styles.css +106 -0
- 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 {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
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
|
|
8
|
+
var h = {
|
|
8
9
|
top: 16,
|
|
9
10
|
right: 12,
|
|
10
11
|
bottom: 28,
|
|
11
12
|
left: 48
|
|
12
|
-
},
|
|
13
|
-
function
|
|
13
|
+
}, te = 600;
|
|
14
|
+
function g(e) {
|
|
14
15
|
return e === 0 ? 1 : Math.max(Math.abs(e) * .02, 1);
|
|
15
16
|
}
|
|
16
|
-
function
|
|
17
|
-
let
|
|
18
|
-
for (let e of
|
|
19
|
-
let
|
|
20
|
-
if (b && v === void 0 &&
|
|
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 =
|
|
23
|
-
v === void 0 && (
|
|
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
|
-
|
|
26
|
+
U === W && (W = U + 1);
|
|
26
27
|
}
|
|
27
|
-
let
|
|
28
|
-
function
|
|
29
|
-
return
|
|
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
|
|
32
|
-
return
|
|
32
|
+
function Y(e) {
|
|
33
|
+
return h.top + z - (e - U) / G * z;
|
|
33
34
|
}
|
|
34
|
-
let
|
|
35
|
-
`${
|
|
36
|
-
...
|
|
37
|
-
`${
|
|
38
|
-
].join(" ") : "", X =
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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
|
-
|
|
59
|
+
A(null);
|
|
60
60
|
}
|
|
61
|
-
return /* @__PURE__ */
|
|
62
|
-
...
|
|
63
|
-
ref:
|
|
61
|
+
return /* @__PURE__ */ m("svg", {
|
|
62
|
+
...oe,
|
|
63
|
+
ref: O,
|
|
64
64
|
width: "100%",
|
|
65
|
-
|
|
65
|
+
height: N,
|
|
66
|
+
viewBox: `0 0 ${M} ${P}`,
|
|
66
67
|
onPointerMove: (e) => {
|
|
67
|
-
|
|
68
|
+
ie?.(e), !e.defaultPrevented && de(e);
|
|
68
69
|
},
|
|
69
70
|
onPointerLeave: (e) => {
|
|
70
|
-
|
|
71
|
+
ae?.(e), !e.defaultPrevented && $();
|
|
71
72
|
},
|
|
72
|
-
className: e("select-none",
|
|
73
|
+
className: e("select-none", w),
|
|
73
74
|
role: "img",
|
|
74
|
-
"aria-label":
|
|
75
|
+
"aria-label": C,
|
|
75
76
|
children: [
|
|
76
|
-
/* @__PURE__ */
|
|
77
|
-
id:
|
|
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__ */
|
|
83
|
+
children: [/* @__PURE__ */ p("stop", {
|
|
83
84
|
offset: "0%",
|
|
84
85
|
stopColor: "var(--accent)",
|
|
85
86
|
stopOpacity: .3
|
|
86
|
-
}), /* @__PURE__ */
|
|
87
|
+
}), /* @__PURE__ */ p("stop", {
|
|
87
88
|
offset: "100%",
|
|
88
89
|
stopColor: "var(--accent)",
|
|
89
90
|
stopOpacity: 0
|
|
90
91
|
})]
|
|
91
92
|
}) }),
|
|
92
|
-
/* @__PURE__ */
|
|
93
|
-
x:
|
|
94
|
-
y:
|
|
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
|
|
100
|
+
children: K(W)
|
|
100
101
|
}),
|
|
101
|
-
/* @__PURE__ */
|
|
102
|
-
x:
|
|
103
|
-
y:
|
|
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:
|
|
109
|
+
children: K(U)
|
|
109
110
|
}),
|
|
110
|
-
/* @__PURE__ */
|
|
111
|
-
x1:
|
|
112
|
-
y1:
|
|
113
|
-
x2:
|
|
114
|
-
y2:
|
|
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
|
-
|
|
119
|
-
points:
|
|
120
|
-
fill: `url(#${
|
|
119
|
+
B && /* @__PURE__ */ p("polygon", {
|
|
120
|
+
points: ce,
|
|
121
|
+
fill: `url(#${E})`
|
|
121
122
|
}),
|
|
122
|
-
|
|
123
|
-
points:
|
|
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
|
-
|
|
131
|
-
cx:
|
|
132
|
-
cy:
|
|
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}: ${
|
|
138
|
-
onFocus: () =>
|
|
138
|
+
"aria-label": `${e.date}: ${q(e.value)}`,
|
|
139
|
+
onFocus: () => A(t),
|
|
139
140
|
onBlur: $
|
|
140
141
|
}, `${e.date}-${t}-hit`)),
|
|
141
|
-
|
|
142
|
-
x:
|
|
143
|
-
y:
|
|
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:
|
|
148
|
-
}, `${
|
|
149
|
-
|
|
150
|
-
/* @__PURE__ */
|
|
151
|
-
x1:
|
|
152
|
-
y1:
|
|
153
|
-
x2:
|
|
154
|
-
y2:
|
|
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__ */
|
|
160
|
-
cx:
|
|
161
|
-
cy:
|
|
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 =
|
|
169
|
-
|
|
170
|
-
|
|
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:
|
|
174
|
+
width: r([e, t], {
|
|
176
175
|
maxWidth: 180,
|
|
177
176
|
minWidth: 90
|
|
178
177
|
})
|
|
179
|
-
}),
|
|
180
|
-
return /* @__PURE__ */ f
|
|
181
|
-
/* @__PURE__ */
|
|
182
|
-
x:
|
|
183
|
-
y:
|
|
184
|
-
width:
|
|
185
|
-
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__ */
|
|
192
|
-
x:
|
|
193
|
-
y:
|
|
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:
|
|
197
|
+
children: e
|
|
199
198
|
}),
|
|
200
|
-
/* @__PURE__ */
|
|
201
|
-
x:
|
|
202
|
-
y:
|
|
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:
|
|
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 {
|
|
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
|
|
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
|
|
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
|
|
38
|
-
return e(t.reduce((e, t) => Math.max(e,
|
|
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
|
|
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
|
|
51
|
-
let c =
|
|
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,
|
|
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,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,
|
|
6
|
-
let
|
|
7
|
-
for (let e = 1; e <= s; e++) e === 1 || e === s || e >= o - 1 && e <= o + 1 ?
|
|
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:
|
|
10
|
-
...
|
|
11
|
-
className:
|
|
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:
|
|
15
|
-
children:
|
|
16
|
-
}),
|
|
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
|
-
|
|
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 {
|
|
3
|
-
import {
|
|
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 ? _ :
|
|
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(
|
|
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(
|
|
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(
|
|
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) ?? {},
|
|
65
|
-
return /* @__PURE__ */ l(
|
|
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(
|
|
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,
|