@leonardaustin/ui 0.25.0 → 0.26.1
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/README.md +11 -0
- package/dist/components/app-shell/AppShell.d.ts +3 -3
- package/dist/components/app-shell/AppShell.js +82 -0
- package/dist/components/app-shell/AuthLayout.d.ts +3 -3
- package/dist/components/app-shell/AuthLayout.js +16 -0
- package/dist/components/app-shell/BackLink.d.ts +3 -3
- package/dist/components/app-shell/BackLink.js +19 -0
- package/dist/components/app-shell/BottomNav.d.ts +3 -2
- package/dist/components/app-shell/BottomNav.js +37 -0
- package/dist/components/app-shell/Breadcrumbs.d.ts +3 -2
- package/dist/components/app-shell/Breadcrumbs.js +46 -0
- package/dist/components/app-shell/CommandPalette.d.ts +3 -2
- package/dist/components/app-shell/CommandPalette.js +119 -0
- package/dist/components/app-shell/MobileDrawer.d.ts +3 -3
- package/dist/components/app-shell/MobileDrawer.js +128 -0
- package/dist/components/app-shell/Sidebar.d.ts +3 -3
- package/dist/components/app-shell/Sidebar.js +355 -0
- package/dist/components/app-shell/ThemeMenu.d.ts +3 -2
- package/dist/components/app-shell/ThemeMenu.js +273 -0
- package/dist/components/app-shell/TopBar.d.ts +3 -3
- package/dist/components/app-shell/TopBar.js +129 -0
- package/dist/components/app-shell/commandPaletteEvents.js +16 -0
- package/dist/components/app-shell/navigation.js +21 -0
- package/dist/components/app-shell/themeMenuEvents.js +7 -0
- package/dist/components/charts/AreaChart.d.ts +4 -3
- package/dist/components/charts/AreaChart.js +217 -0
- package/dist/components/charts/BarChart.d.ts +4 -3
- package/dist/components/charts/BarChart.js +91 -0
- package/dist/components/charts/DonutChart.d.ts +4 -3
- package/dist/components/charts/DonutChart.js +172 -0
- package/dist/components/charts/RadarChart.d.ts +4 -3
- package/dist/components/charts/RadarChart.js +142 -0
- package/dist/components/charts/RadialBarChart.d.ts +4 -3
- package/dist/components/charts/RadialBarChart.js +219 -0
- package/dist/components/charts/SparkLine.d.ts +4 -3
- package/dist/components/charts/SparkLine.js +39 -0
- package/dist/components/charts/StackedBarChart.d.ts +4 -3
- package/dist/components/charts/StackedBarChart.js +249 -0
- package/dist/components/charts/VerticalBarChart.d.ts +4 -3
- package/dist/components/charts/VerticalBarChart.js +143 -0
- package/dist/components/charts/chartUtils.js +68 -0
- package/dist/components/tables/ColumnPicker.d.ts +3 -3
- package/dist/components/tables/ColumnPicker.js +59 -0
- package/dist/components/tables/Pagination.d.ts +3 -3
- package/dist/components/tables/Pagination.js +56 -0
- package/dist/components/tables/ResourceTable.d.ts +3 -3
- package/dist/components/tables/ResourceTable.js +88 -0
- package/dist/components/tables/Table.js +95 -0
- package/dist/components/tables/sortRows.js +11 -0
- package/dist/components/ui/Accordion.d.ts +2 -1
- package/dist/components/ui/Accordion.js +35 -0
- package/dist/components/ui/Alert.d.ts +3 -2
- package/dist/components/ui/Alert.js +51 -0
- package/dist/components/ui/AttachmentList.d.ts +5 -5
- package/dist/components/ui/AttachmentList.js +90 -0
- package/dist/components/ui/AudioPlayer.d.ts +5 -2
- package/dist/components/ui/AudioPlayer.js +447 -0
- package/dist/components/ui/AuthCard.d.ts +3 -3
- package/dist/components/ui/AuthCard.js +39 -0
- package/dist/components/ui/AuthorByline.d.ts +3 -3
- package/dist/components/ui/AuthorByline.js +23 -0
- package/dist/components/ui/Avatar.d.ts +3 -2
- package/dist/components/ui/Avatar.js +36 -0
- package/dist/components/ui/Badge.d.ts +3 -2
- package/dist/components/ui/Badge.js +47 -0
- package/dist/components/ui/Button.d.ts +3 -3
- package/dist/components/ui/Button.js +83 -0
- package/dist/components/ui/Calendar.d.ts +3 -3
- package/dist/components/ui/Calendar.js +344 -0
- package/dist/components/ui/CalendarGrid.d.ts +3 -2
- package/dist/components/ui/CalendarGrid.js +136 -0
- package/dist/components/ui/Card.d.ts +6 -5
- package/dist/components/ui/Card.js +53 -0
- package/dist/components/ui/CharacterCount.d.ts +3 -3
- package/dist/components/ui/CharacterCount.js +27 -0
- package/dist/components/ui/Checkbox.d.ts +10 -8
- package/dist/components/ui/Checkbox.js +52 -0
- package/dist/components/ui/CodeInput.d.ts +7 -4
- package/dist/components/ui/CodeInput.js +97 -0
- package/dist/components/ui/Combobox.d.ts +8 -6
- package/dist/components/ui/Combobox.js +213 -0
- package/dist/components/ui/CopyButton.d.ts +1 -1
- package/dist/components/ui/CopyButton.js +57 -0
- package/dist/components/ui/DangerZone.d.ts +3 -3
- package/dist/components/ui/DangerZone.js +23 -0
- package/dist/components/ui/DatePartsInput.d.ts +6 -4
- package/dist/components/ui/DatePartsInput.js +138 -0
- package/dist/components/ui/DatePicker.d.ts +9 -4
- package/dist/components/ui/DatePicker.js +84 -0
- package/dist/components/ui/DateRangePicker.d.ts +7 -4
- package/dist/components/ui/DateRangePicker.js +143 -0
- package/dist/components/ui/DateTimePicker.d.ts +7 -4
- package/dist/components/ui/DateTimePicker.js +267 -0
- package/dist/components/ui/DetailPanel.d.ts +3 -3
- package/dist/components/ui/DetailPanel.js +183 -0
- package/dist/components/ui/Dialog.d.ts +3 -3
- package/dist/components/ui/Dialog.js +411 -0
- package/dist/components/ui/DialogActions.d.ts +3 -3
- package/dist/components/ui/DialogActions.js +35 -0
- package/dist/components/ui/Disclosure.d.ts +3 -3
- package/dist/components/ui/Disclosure.js +45 -0
- package/dist/components/ui/DividerLabel.d.ts +3 -3
- package/dist/components/ui/DividerLabel.js +20 -0
- package/dist/components/ui/DropdownMenu.d.ts +3 -3
- package/dist/components/ui/DropdownMenu.js +229 -0
- package/dist/components/ui/EmptyState.d.ts +3 -3
- package/dist/components/ui/EmptyState.js +31 -0
- package/dist/components/ui/ErrorBoundary.js +46 -0
- package/dist/components/ui/FieldContext.js +8 -0
- package/dist/components/ui/Fieldset.d.ts +2 -2
- package/dist/components/ui/Fieldset.js +39 -0
- package/dist/components/ui/FilterButton.d.ts +4 -7
- package/dist/components/ui/FilterButton.js +17 -0
- package/dist/components/ui/FilterDropdown.d.ts +4 -4
- package/dist/components/ui/FilterDropdown.js +18 -0
- package/dist/components/ui/FormField.d.ts +4 -4
- package/dist/components/ui/FormField.js +68 -0
- package/dist/components/ui/Grid.d.ts +1 -1
- package/dist/components/ui/Grid.js +19 -0
- package/dist/components/ui/GridItem.d.ts +1 -1
- package/dist/components/ui/GridItem.js +16 -0
- package/dist/components/ui/Inline.d.ts +1 -1
- package/dist/components/ui/Inline.js +24 -0
- package/dist/components/ui/Kbd.d.ts +3 -2
- package/dist/components/ui/Kbd.js +13 -0
- package/dist/components/ui/ListItemLink.d.ts +3 -3
- package/dist/components/ui/ListItemLink.js +44 -0
- package/dist/components/ui/LoadingSpinner.d.ts +3 -2
- package/dist/components/ui/LoadingSpinner.js +19 -0
- package/dist/components/ui/MessageBubble.d.ts +2 -2
- package/dist/components/ui/MessageBubble.js +41 -0
- package/dist/components/ui/MetadataGrid.d.ts +5 -3
- package/dist/components/ui/MetadataGrid.js +76 -0
- package/dist/components/ui/MetricCard.d.ts +3 -3
- package/dist/components/ui/MetricCard.js +51 -0
- package/dist/components/ui/NavTabs.d.ts +2 -2
- package/dist/components/ui/NavTabs.js +29 -0
- package/dist/components/ui/OAuthButton.d.ts +2 -2
- package/dist/components/ui/OAuthButton.js +55 -0
- package/dist/components/ui/OverlineLabel.d.ts +3 -3
- package/dist/components/ui/OverlineLabel.js +13 -0
- package/dist/components/ui/PageHeader.d.ts +3 -3
- package/dist/components/ui/PageHeader.js +33 -0
- package/dist/components/ui/PageSection.d.ts +3 -3
- package/dist/components/ui/PageSection.js +31 -0
- package/dist/components/ui/PaginationBar.d.ts +3 -3
- package/dist/components/ui/PaginationBar.js +62 -0
- package/dist/components/ui/PasswordInput.d.ts +3 -3
- package/dist/components/ui/PasswordInput.js +62 -0
- package/dist/components/ui/PasswordRequirements.d.ts +3 -2
- package/dist/components/ui/PasswordRequirements.js +34 -0
- package/dist/components/ui/Popover.d.ts +3 -3
- package/dist/components/ui/Popover.js +53 -0
- package/dist/components/ui/ProfileHeader.d.ts +3 -3
- package/dist/components/ui/ProfileHeader.js +54 -0
- package/dist/components/ui/ProgressBar.d.ts +3 -3
- package/dist/components/ui/ProgressBar.js +42 -0
- package/dist/components/ui/ProseContent.d.ts +3 -3
- package/dist/components/ui/ProseContent.js +13 -0
- package/dist/components/ui/QrCode.d.ts +3 -3
- package/dist/components/ui/QrCode.js +47 -0
- package/dist/components/ui/Radio.d.ts +9 -6
- package/dist/components/ui/Radio.js +58 -0
- package/dist/components/ui/RadioPill.d.ts +7 -4
- package/dist/components/ui/RadioPill.js +53 -0
- package/dist/components/ui/ReorderList.d.ts +3 -3
- package/dist/components/ui/ReorderList.js +123 -0
- package/dist/components/ui/SearchInput.d.ts +7 -5
- package/dist/components/ui/SearchInput.js +49 -0
- package/dist/components/ui/SectionHeader.d.ts +3 -3
- package/dist/components/ui/SectionHeader.js +13 -0
- package/dist/components/ui/Select.d.ts +4 -4
- package/dist/components/ui/Select.js +117 -0
- package/dist/components/ui/SelectDropdown.d.ts +8 -3
- package/dist/components/ui/SelectDropdown.js +206 -0
- package/dist/components/ui/SettingRow.d.ts +5 -5
- package/dist/components/ui/SettingRow.js +25 -0
- package/dist/components/ui/SideSheet.d.ts +3 -3
- package/dist/components/ui/SideSheet.js +164 -0
- package/dist/components/ui/Skeleton.d.ts +3 -3
- package/dist/components/ui/Skeleton.js +18 -0
- package/dist/components/ui/Slider.d.ts +11 -6
- package/dist/components/ui/Slider.js +58 -0
- package/dist/components/ui/SplitPaneLayout.d.ts +5 -5
- package/dist/components/ui/SplitPaneLayout.js +22 -0
- package/dist/components/ui/Stack.d.ts +1 -1
- package/dist/components/ui/Stack.js +18 -0
- package/dist/components/ui/StatusDot.d.ts +3 -2
- package/dist/components/ui/StatusDot.js +24 -0
- package/dist/components/ui/StepProgress.d.ts +3 -2
- package/dist/components/ui/StepProgress.js +33 -0
- package/dist/components/ui/Tabs.d.ts +5 -5
- package/dist/components/ui/Tabs.js +63 -0
- package/dist/components/ui/TextInput.d.ts +4 -4
- package/dist/components/ui/TextInput.js +57 -0
- package/dist/components/ui/Textarea.d.ts +3 -3
- package/dist/components/ui/Textarea.js +59 -0
- package/dist/components/ui/ThemePreview.d.ts +3 -3
- package/dist/components/ui/ThemePreview.js +28 -0
- package/dist/components/ui/TimeInput.d.ts +7 -6
- package/dist/components/ui/TimeInput.js +22 -0
- package/dist/components/ui/Timeline.d.ts +3 -2
- package/dist/components/ui/Timeline.js +29 -0
- package/dist/components/ui/Toast.js +121 -0
- package/dist/components/ui/Toggle.d.ts +5 -3
- package/dist/components/ui/Toggle.js +34 -0
- package/dist/components/ui/Toolbar.d.ts +3 -3
- package/dist/components/ui/Toolbar.js +70 -0
- package/dist/components/ui/Tooltip.js +91 -0
- package/dist/components/ui/TranscriptLine.d.ts +3 -3
- package/dist/components/ui/TranscriptLine.js +40 -0
- package/dist/components/ui/UploadDropzone.d.ts +3 -5
- package/dist/components/ui/UploadDropzone.js +55 -0
- package/dist/components/ui/badgeColors.js +5 -0
- package/dist/components/ui/calendar/AgendaView.js +140 -0
- package/dist/components/ui/calendar/MonthView.js +321 -0
- package/dist/components/ui/calendar/TimeGrid.js +501 -0
- package/dist/components/ui/calendar/TimelineView.js +311 -0
- package/dist/components/ui/calendar/context.js +10 -0
- package/dist/components/ui/calendar/items.js +152 -0
- package/dist/components/ui/calendar/types.js +38 -0
- package/dist/components/ui/calendar/useGridInteraction.js +393 -0
- package/dist/components/ui/useFieldControl.d.ts +1 -1
- package/dist/components/ui/useFieldControl.js +17 -0
- package/dist/config/theme.js +219 -0
- package/dist/core.css +2933 -0
- package/dist/hooks/useAnchoredPopup.js +162 -0
- package/dist/hooks/useApplyTheme.js +16 -0
- package/dist/hooks/useControllableState.d.ts +14 -0
- package/dist/hooks/useControllableState.js +10 -0
- package/dist/hooks/useDismiss.js +24 -0
- package/dist/hooks/useFocusTrap.js +42 -0
- package/dist/hooks/useOverlayStack.js +23 -0
- package/dist/hooks/usePopover.js +47 -0
- package/dist/hooks/usePortalContainer.js +14 -0
- package/dist/hooks/useSettings.js +8 -0
- package/dist/hooks/useTheme.js +8 -0
- package/dist/hooks/useTypeahead.js +19 -0
- package/dist/index.js +133 -12884
- package/dist/lib/anchorPlacement.js +75 -0
- package/dist/lib/calendar.js +666 -0
- package/dist/lib/cn.js +228 -0
- package/dist/lib/codeInput.js +51 -0
- package/dist/lib/dateParts.js +31 -0
- package/dist/lib/dialogDrag.js +45 -0
- package/dist/lib/dialogResize.js +47 -0
- package/dist/lib/formatDate.js +29 -0
- package/dist/lib/formatMediaTime.js +7 -0
- package/dist/lib/layout.js +29 -0
- package/dist/lib/math.js +6 -0
- package/dist/lib/mergeRefs.d.ts +6 -0
- package/dist/lib/mergeRefs.js +17 -0
- package/dist/lib/months.js +30 -0
- package/dist/lib/overlayStack.js +47 -0
- package/dist/lib/panelResize.js +8 -0
- package/dist/lib/passwordRequirements.js +23 -0
- package/dist/lib/qrCode.js +570 -0
- package/dist/lib/tones.js +104 -0
- package/dist/lib/typeahead.js +31 -0
- package/dist/providers/ControlSizeContext.js +9 -0
- package/dist/providers/ControlSizeProvider.js +11 -0
- package/dist/providers/SettingsContext.js +53 -0
- package/dist/providers/SettingsProvider.js +249 -0
- package/dist/providers/ThemeContext.js +5 -0
- package/dist/providers/ThemeProvider.js +17 -0
- package/dist/providers/accentColors.js +75 -0
- package/dist/providers/themeClasses.d.ts +1 -0
- package/dist/providers/themeClasses.js +20 -0
- package/dist/styles.css +228 -176
- package/dist/themes/cyber-brutal-dark.css +53 -0
- package/dist/themes/cyber-brutal-light.css +75 -0
- package/dist/themes/glass-dark.css +217 -0
- package/dist/themes/glass-light.css +215 -0
- package/dist/themes/hashi.css +66 -0
- package/dist/themes/light-inverted.css +32 -0
- package/dist/themes/light.css +1 -0
- package/dist/themes/monokai.css +51 -0
- package/dist/themes/solarized.css +55 -0
- package/package.json +3 -1
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
import { cn as e } from "../../lib/cn.js";
|
|
2
|
+
import { estimateTooltipWidth as t, formatCompactValue as n, getLabelIndices as r, getSvgTooltipPosition as i } from "./chartUtils.js";
|
|
3
|
+
import { useState as a } from "react";
|
|
4
|
+
import { Fragment as o, jsx as s, jsxs as c } from "react/jsx-runtime";
|
|
5
|
+
//#region src/components/charts/StackedBarChart.tsx
|
|
6
|
+
var l = {
|
|
7
|
+
top: 20,
|
|
8
|
+
right: 12,
|
|
9
|
+
bottom: 30,
|
|
10
|
+
left: 48
|
|
11
|
+
}, u = 600, d = 4;
|
|
12
|
+
function f(e) {
|
|
13
|
+
let t = /^(\d{4})-(\d{2})-(\d{2})T(\d{2})/.exec(e);
|
|
14
|
+
if (t) {
|
|
15
|
+
let [, e, n, r, i] = t;
|
|
16
|
+
return new Date(Date.UTC(Number(e), Number(n) - 1, Number(r), Number(i))).toLocaleString(void 0, {
|
|
17
|
+
month: "short",
|
|
18
|
+
day: "numeric",
|
|
19
|
+
hour: "numeric",
|
|
20
|
+
timeZone: "UTC"
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
let n = /^(\d{4})-(\d{2})-(\d{2})/.exec(e);
|
|
24
|
+
if (!n) return e;
|
|
25
|
+
let [, r, i, a] = n;
|
|
26
|
+
return new Date(Date.UTC(Number(r), Number(i) - 1, Number(a))).toLocaleDateString(void 0, {
|
|
27
|
+
month: "short",
|
|
28
|
+
day: "numeric",
|
|
29
|
+
timeZone: "UTC"
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
function p(e, t) {
|
|
33
|
+
let n = e[t];
|
|
34
|
+
if (typeof n == "number") return Number.isFinite(n) ? n : 0;
|
|
35
|
+
if (typeof n == "string") {
|
|
36
|
+
let e = Number(n);
|
|
37
|
+
return Number.isFinite(e) ? e : 0;
|
|
38
|
+
}
|
|
39
|
+
return 0;
|
|
40
|
+
}
|
|
41
|
+
function m(e, t) {
|
|
42
|
+
return t.reduce((t, n) => t + Math.max(0, p(e, n.key)), 0);
|
|
43
|
+
}
|
|
44
|
+
function h(e, t, n, r, i) {
|
|
45
|
+
let a = Math.min(i, Math.max(0, n / 2), Math.max(0, r));
|
|
46
|
+
return a <= 0 ? `M ${e} ${t} H ${e + n} V ${t + r} H ${e} Z` : [
|
|
47
|
+
`M ${e} ${t + r}`,
|
|
48
|
+
`V ${t + a}`,
|
|
49
|
+
`Q ${e} ${t} ${e + a} ${t}`,
|
|
50
|
+
`H ${e + n - a}`,
|
|
51
|
+
`Q ${e + n} ${t} ${e + n} ${t + a}`,
|
|
52
|
+
`V ${t + r}`,
|
|
53
|
+
"Z"
|
|
54
|
+
].join(" ");
|
|
55
|
+
}
|
|
56
|
+
function g({ data: g, segments: _, height: v = 220, "aria-label": y = "Stacked bar chart", tooltipRows: b, valueFormatter: x, tooltipValueFormatter: S, xLabelCount: C = 6, barGap: w, minBarWidth: T = 1, className: E, ref: D, ...O }) {
|
|
57
|
+
let [k, A] = a(null), j = Math.max(l.top + l.bottom + 1, v), M = u - l.left - l.right, N = Math.max(1, j - l.top - l.bottom), P = g.reduce((e, t) => Math.max(e, m(t, _)), 1), F = Math.ceil(P / 2), I = F > 0 && F < P, L = w ?? (g.length > 60 ? 2 : g.length > 30 ? 3 : 6), R = Math.max(1, T), z = g.length > 1 ? Math.max(0, (M - g.length * R) / Math.max(g.length - 1, 1)) : 0, B = g.length > 1 ? Math.min(Math.max(0, L), z) : 0, V = g.length > 0 ? (M - B * Math.max(g.length - 1, 0)) / g.length : 0, H = new Set(r(g.length, C)), U = k === null ? null : g[k], W = x ?? n, G = S ?? ((e) => e.toLocaleString());
|
|
58
|
+
function K(e) {
|
|
59
|
+
return l.left + e * (V + B);
|
|
60
|
+
}
|
|
61
|
+
function q(e) {
|
|
62
|
+
return e / P * N;
|
|
63
|
+
}
|
|
64
|
+
return /* @__PURE__ */ c("svg", {
|
|
65
|
+
ref: D,
|
|
66
|
+
...O,
|
|
67
|
+
width: "100%",
|
|
68
|
+
viewBox: `0 0 ${u} ${j}`,
|
|
69
|
+
className: e("select-none", E),
|
|
70
|
+
role: "img",
|
|
71
|
+
"aria-label": y,
|
|
72
|
+
children: [
|
|
73
|
+
/* @__PURE__ */ s("text", {
|
|
74
|
+
x: l.left - 8,
|
|
75
|
+
y: l.top,
|
|
76
|
+
textAnchor: "end",
|
|
77
|
+
dominantBaseline: "central",
|
|
78
|
+
fill: "var(--text-tertiary)",
|
|
79
|
+
fontSize: 10,
|
|
80
|
+
children: W(P)
|
|
81
|
+
}),
|
|
82
|
+
I && /* @__PURE__ */ s("text", {
|
|
83
|
+
x: l.left - 8,
|
|
84
|
+
y: l.top + N / 2,
|
|
85
|
+
textAnchor: "end",
|
|
86
|
+
dominantBaseline: "central",
|
|
87
|
+
fill: "var(--text-tertiary)",
|
|
88
|
+
fontSize: 10,
|
|
89
|
+
children: W(F)
|
|
90
|
+
}),
|
|
91
|
+
/* @__PURE__ */ s("text", {
|
|
92
|
+
x: l.left - 8,
|
|
93
|
+
y: l.top + N,
|
|
94
|
+
textAnchor: "end",
|
|
95
|
+
dominantBaseline: "central",
|
|
96
|
+
fill: "var(--text-tertiary)",
|
|
97
|
+
fontSize: 10,
|
|
98
|
+
children: "0"
|
|
99
|
+
}),
|
|
100
|
+
/* @__PURE__ */ s("line", {
|
|
101
|
+
x1: l.left,
|
|
102
|
+
y1: l.top + N,
|
|
103
|
+
x2: l.left + M,
|
|
104
|
+
y2: l.top + N,
|
|
105
|
+
stroke: "var(--border)",
|
|
106
|
+
strokeWidth: 1
|
|
107
|
+
}),
|
|
108
|
+
/* @__PURE__ */ s("line", {
|
|
109
|
+
x1: l.left,
|
|
110
|
+
y1: l.top + N / 2,
|
|
111
|
+
x2: l.left + M,
|
|
112
|
+
y2: l.top + N / 2,
|
|
113
|
+
stroke: "var(--border)",
|
|
114
|
+
strokeWidth: 1,
|
|
115
|
+
strokeDasharray: "3 3",
|
|
116
|
+
opacity: .5
|
|
117
|
+
}),
|
|
118
|
+
g.map((e, t) => {
|
|
119
|
+
let n = K(t), r = k === t, i = 0, a = _.map((t) => ({
|
|
120
|
+
segment: t,
|
|
121
|
+
value: Math.max(0, p(e, t.key))
|
|
122
|
+
})).filter(({ value: e }) => e > 0);
|
|
123
|
+
return /* @__PURE__ */ c("g", {
|
|
124
|
+
onMouseEnter: () => A(t),
|
|
125
|
+
onMouseLeave: () => A(null),
|
|
126
|
+
onPointerEnter: () => A(t),
|
|
127
|
+
onPointerDown: () => A(t),
|
|
128
|
+
onPointerLeave: () => A(null),
|
|
129
|
+
onFocus: () => A(t),
|
|
130
|
+
onBlur: () => A(null),
|
|
131
|
+
tabIndex: 0,
|
|
132
|
+
role: "button",
|
|
133
|
+
"aria-label": `${f(e.date)}: ${G(m(e, _))}`,
|
|
134
|
+
children: [
|
|
135
|
+
/* @__PURE__ */ s("rect", {
|
|
136
|
+
x: n,
|
|
137
|
+
y: l.top,
|
|
138
|
+
width: V,
|
|
139
|
+
height: N,
|
|
140
|
+
fill: "transparent"
|
|
141
|
+
}),
|
|
142
|
+
a.map(({ segment: e, value: t }, o) => {
|
|
143
|
+
let c = q(t), u = l.top + N - i - c, f = o === a.length - 1;
|
|
144
|
+
return i += c, f ? /* @__PURE__ */ s("path", {
|
|
145
|
+
d: h(n, u, V, c, d),
|
|
146
|
+
fill: e.color,
|
|
147
|
+
opacity: r ? 1 : e.opacity ?? .9
|
|
148
|
+
}, e.key) : /* @__PURE__ */ s("rect", {
|
|
149
|
+
x: n,
|
|
150
|
+
y: u,
|
|
151
|
+
width: V,
|
|
152
|
+
height: c,
|
|
153
|
+
fill: e.color,
|
|
154
|
+
opacity: r ? 1 : e.opacity ?? .9
|
|
155
|
+
}, e.key);
|
|
156
|
+
}),
|
|
157
|
+
H.has(t) && /* @__PURE__ */ s("text", {
|
|
158
|
+
x: n + V / 2,
|
|
159
|
+
y: j - 5,
|
|
160
|
+
textAnchor: "middle",
|
|
161
|
+
fill: "var(--text-tertiary)",
|
|
162
|
+
fontSize: 10,
|
|
163
|
+
children: f(e.date)
|
|
164
|
+
})
|
|
165
|
+
]
|
|
166
|
+
}, `${e.date}-${t}`);
|
|
167
|
+
}),
|
|
168
|
+
U && k !== null && /* @__PURE__ */ s("g", {
|
|
169
|
+
pointerEvents: "none",
|
|
170
|
+
children: (() => {
|
|
171
|
+
let e = K(k) + V / 2, n = b?.(U) ?? _.map((e) => ({
|
|
172
|
+
color: e.color,
|
|
173
|
+
label: e.label,
|
|
174
|
+
value: p(U, e.key)
|
|
175
|
+
})), r = m(U, _), a = i(e, l.top + N - q(r), {
|
|
176
|
+
boundsHeight: j,
|
|
177
|
+
boundsWidth: u,
|
|
178
|
+
height: 28 + n.length * 15,
|
|
179
|
+
offset: 8,
|
|
180
|
+
width: t([f(U.date), ...n.map((e) => `${e.label} ${G(e.value)}`)], {
|
|
181
|
+
maxWidth: 240,
|
|
182
|
+
minWidth: 150
|
|
183
|
+
})
|
|
184
|
+
}), d = a.x + 10, h = a.x + a.width - 10;
|
|
185
|
+
return /* @__PURE__ */ c(o, { children: [
|
|
186
|
+
/* @__PURE__ */ s("line", {
|
|
187
|
+
x1: e,
|
|
188
|
+
y1: l.top,
|
|
189
|
+
x2: e,
|
|
190
|
+
y2: l.top + N,
|
|
191
|
+
stroke: "var(--border-strong)",
|
|
192
|
+
strokeWidth: 1,
|
|
193
|
+
strokeDasharray: "3 3"
|
|
194
|
+
}),
|
|
195
|
+
/* @__PURE__ */ s("rect", {
|
|
196
|
+
x: a.x,
|
|
197
|
+
y: a.y,
|
|
198
|
+
width: a.width,
|
|
199
|
+
height: a.height,
|
|
200
|
+
rx: 4,
|
|
201
|
+
fill: "var(--bg-tooltip, var(--bg-tertiary))",
|
|
202
|
+
stroke: "var(--border)",
|
|
203
|
+
strokeWidth: 1
|
|
204
|
+
}),
|
|
205
|
+
/* @__PURE__ */ s("text", {
|
|
206
|
+
x: d,
|
|
207
|
+
y: a.y + 14,
|
|
208
|
+
fill: "var(--text-primary)",
|
|
209
|
+
fontSize: 10,
|
|
210
|
+
fontWeight: 600,
|
|
211
|
+
children: f(U.date)
|
|
212
|
+
}),
|
|
213
|
+
n.map((e, t) => {
|
|
214
|
+
let n = a.y + 30 + t * 15;
|
|
215
|
+
return /* @__PURE__ */ c("g", { children: [
|
|
216
|
+
e.color && /* @__PURE__ */ s("rect", {
|
|
217
|
+
x: d,
|
|
218
|
+
y: n - 6,
|
|
219
|
+
width: 6,
|
|
220
|
+
height: 6,
|
|
221
|
+
rx: 1,
|
|
222
|
+
fill: e.color
|
|
223
|
+
}),
|
|
224
|
+
/* @__PURE__ */ s("text", {
|
|
225
|
+
x: e.color ? d + 12 : d,
|
|
226
|
+
y: n,
|
|
227
|
+
fill: "var(--text-secondary)",
|
|
228
|
+
fontSize: 10,
|
|
229
|
+
children: e.label
|
|
230
|
+
}),
|
|
231
|
+
/* @__PURE__ */ s("text", {
|
|
232
|
+
x: h,
|
|
233
|
+
y: n,
|
|
234
|
+
textAnchor: "end",
|
|
235
|
+
fill: "var(--text-primary)",
|
|
236
|
+
fontSize: 10,
|
|
237
|
+
fontWeight: 600,
|
|
238
|
+
children: G(e.value)
|
|
239
|
+
})
|
|
240
|
+
] }, e.label);
|
|
241
|
+
})
|
|
242
|
+
] });
|
|
243
|
+
})()
|
|
244
|
+
})
|
|
245
|
+
]
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
//#endregion
|
|
249
|
+
export { g as StackedBarChart };
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { type ComponentPropsWithRef } from "react";
|
|
1
2
|
export interface VerticalBarChartDatum {
|
|
2
3
|
color?: string;
|
|
3
4
|
label: string;
|
|
4
5
|
value: number;
|
|
5
6
|
}
|
|
6
|
-
export interface VerticalBarChartProps {
|
|
7
|
+
export interface VerticalBarChartProps extends Omit<ComponentPropsWithRef<"svg">, "children" | "viewBox" | "width"> {
|
|
7
8
|
/** Bars to draw left to right, each with a `label`, numeric `value`, and optional `color`. */
|
|
8
9
|
data: VerticalBarChartDatum[];
|
|
9
10
|
/** Chart height in SVG units; the width scales to the container. Defaults to 180. */
|
|
@@ -25,8 +26,8 @@ export interface VerticalBarChartProps {
|
|
|
25
26
|
/** Minimum bar width before the gap is reduced. */
|
|
26
27
|
minBarWidth?: number;
|
|
27
28
|
/** Accessible label for the chart. Defaults to "Vertical bar chart". */
|
|
28
|
-
|
|
29
|
+
"aria-label"?: string;
|
|
29
30
|
/** Extra classes for the `<svg>`. */
|
|
30
31
|
className?: string;
|
|
31
32
|
}
|
|
32
|
-
export declare function VerticalBarChart({ data, height, maxValue, valueFormatter, tooltipValueFormatter, labelFormatter, maxLabelLength, xLabelCount, barGap, minBarWidth, ariaLabel, className, }: VerticalBarChartProps): import("react/jsx-runtime").JSX.Element;
|
|
33
|
+
export declare function VerticalBarChart({ data, height, maxValue, valueFormatter, tooltipValueFormatter, labelFormatter, maxLabelLength, xLabelCount, barGap, minBarWidth, "aria-label": ariaLabel, className, ref, ...rest }: VerticalBarChartProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { cn as e } from "../../lib/cn.js";
|
|
2
|
+
import { clamp as t } from "../../lib/math.js";
|
|
3
|
+
import { estimateTooltipWidth as n, formatCompactValue as r, getLabelIndices as i, getPositiveValue as a, getSvgTooltipPosition as o, resolveChartColor as s, truncateChartLabel as c } from "./chartUtils.js";
|
|
4
|
+
import { useState as l } from "react";
|
|
5
|
+
import { Fragment as u, jsx as d, jsxs as f } from "react/jsx-runtime";
|
|
6
|
+
//#region src/components/charts/VerticalBarChart.tsx
|
|
7
|
+
var p = [
|
|
8
|
+
1,
|
|
9
|
+
.85,
|
|
10
|
+
.7,
|
|
11
|
+
.55,
|
|
12
|
+
.45,
|
|
13
|
+
.35,
|
|
14
|
+
.25
|
|
15
|
+
], m = {
|
|
16
|
+
top: 20,
|
|
17
|
+
right: 8,
|
|
18
|
+
bottom: 24,
|
|
19
|
+
left: 40
|
|
20
|
+
}, h = 600;
|
|
21
|
+
function g({ data: g, height: _ = 180, maxValue: v, valueFormatter: y, tooltipValueFormatter: b, labelFormatter: x, maxLabelLength: S, xLabelCount: C = 7, barGap: w = 6, minBarWidth: T = 4, "aria-label": E = "Vertical bar chart", className: D, ref: O, ...k }) {
|
|
22
|
+
let [A, j] = l(null), M = Math.max(m.top + m.bottom + 1, _), N = h - m.left - m.right, P = Math.max(1, M - m.top - m.bottom), F = v === void 0 ? Math.max(...g.map((e) => a(e.value)), 1) : Math.max(a(v), 1), I = Math.max(0, w), L = Math.max(1, T), R = g.length > 1 ? Math.max(0, (N - g.length * L) / Math.max(g.length - 1, 1)) : 0, z = g.length > 1 ? Math.min(I, R) : 0, B = g.length > 0 ? Math.max(0, (N - z * Math.max(g.length - 1, 0)) / g.length) : 0, V = y ?? r, H = b ?? ((e) => e.toLocaleString()), U = new Set(i(g.length, C));
|
|
23
|
+
return /* @__PURE__ */ f("svg", {
|
|
24
|
+
ref: O,
|
|
25
|
+
...k,
|
|
26
|
+
width: "100%",
|
|
27
|
+
viewBox: `0 0 ${h} ${M}`,
|
|
28
|
+
className: e("select-none", D),
|
|
29
|
+
role: "img",
|
|
30
|
+
"aria-label": E,
|
|
31
|
+
children: [
|
|
32
|
+
/* @__PURE__ */ d("text", {
|
|
33
|
+
x: m.left - 6,
|
|
34
|
+
y: m.top + 4,
|
|
35
|
+
textAnchor: "end",
|
|
36
|
+
fill: "var(--text-tertiary)",
|
|
37
|
+
fontSize: 10,
|
|
38
|
+
children: V(F)
|
|
39
|
+
}),
|
|
40
|
+
/* @__PURE__ */ d("text", {
|
|
41
|
+
x: m.left - 6,
|
|
42
|
+
y: m.top + P,
|
|
43
|
+
textAnchor: "end",
|
|
44
|
+
dominantBaseline: "central",
|
|
45
|
+
fill: "var(--text-tertiary)",
|
|
46
|
+
fontSize: 10,
|
|
47
|
+
children: "0"
|
|
48
|
+
}),
|
|
49
|
+
/* @__PURE__ */ d("line", {
|
|
50
|
+
x1: m.left,
|
|
51
|
+
y1: m.top + P,
|
|
52
|
+
x2: m.left + N,
|
|
53
|
+
y2: m.top + P,
|
|
54
|
+
stroke: "var(--border)",
|
|
55
|
+
strokeWidth: 1
|
|
56
|
+
}),
|
|
57
|
+
/* @__PURE__ */ d("line", {
|
|
58
|
+
x1: m.left,
|
|
59
|
+
y1: m.top + P / 2,
|
|
60
|
+
x2: m.left + N,
|
|
61
|
+
y2: m.top + P / 2,
|
|
62
|
+
stroke: "var(--border)",
|
|
63
|
+
strokeWidth: 1,
|
|
64
|
+
strokeDasharray: "3 3",
|
|
65
|
+
opacity: .5
|
|
66
|
+
}),
|
|
67
|
+
g.map((e, r) => {
|
|
68
|
+
let i = m.left + r * (B + z), l = t(a(e.value), 0, F) / F * P, g = m.top + P - l, _ = A === r, v = x?.(e.label, e, r) ?? e.label, y = c(v, S), b = y !== v, C = H(e.value);
|
|
69
|
+
return /* @__PURE__ */ f("g", {
|
|
70
|
+
onMouseEnter: () => j(r),
|
|
71
|
+
onMouseLeave: () => j(null),
|
|
72
|
+
onPointerEnter: () => j(r),
|
|
73
|
+
onPointerDown: () => j(r),
|
|
74
|
+
onPointerLeave: () => j(null),
|
|
75
|
+
onFocus: () => j(r),
|
|
76
|
+
onBlur: () => j(null),
|
|
77
|
+
tabIndex: 0,
|
|
78
|
+
role: "button",
|
|
79
|
+
"aria-label": `${v}: ${C}`,
|
|
80
|
+
children: [
|
|
81
|
+
/* @__PURE__ */ d("rect", {
|
|
82
|
+
x: i,
|
|
83
|
+
y: m.top,
|
|
84
|
+
width: B,
|
|
85
|
+
height: P,
|
|
86
|
+
fill: "transparent"
|
|
87
|
+
}),
|
|
88
|
+
/* @__PURE__ */ d("rect", {
|
|
89
|
+
x: i,
|
|
90
|
+
y: g,
|
|
91
|
+
width: B,
|
|
92
|
+
height: l,
|
|
93
|
+
fill: s(e.color),
|
|
94
|
+
rx: 6,
|
|
95
|
+
opacity: _ ? 1 : p[r % p.length],
|
|
96
|
+
style: { transition: "all 150ms" }
|
|
97
|
+
}),
|
|
98
|
+
U.has(r) && /* @__PURE__ */ f("text", {
|
|
99
|
+
x: i + B / 2,
|
|
100
|
+
y: M - 4,
|
|
101
|
+
textAnchor: "middle",
|
|
102
|
+
fill: "var(--text-tertiary)",
|
|
103
|
+
fontSize: 10,
|
|
104
|
+
children: [b && /* @__PURE__ */ d("title", { children: v }), y]
|
|
105
|
+
}),
|
|
106
|
+
_ && (() => {
|
|
107
|
+
let e = o(i + B / 2, g, {
|
|
108
|
+
boundsHeight: M,
|
|
109
|
+
boundsWidth: h,
|
|
110
|
+
height: 24,
|
|
111
|
+
offset: 8,
|
|
112
|
+
width: n([v, C], {
|
|
113
|
+
maxWidth: 180,
|
|
114
|
+
minWidth: 72
|
|
115
|
+
})
|
|
116
|
+
}), t = e.x + e.width / 2;
|
|
117
|
+
return /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ d("rect", {
|
|
118
|
+
x: e.x,
|
|
119
|
+
y: e.y,
|
|
120
|
+
width: e.width,
|
|
121
|
+
height: e.height,
|
|
122
|
+
rx: 4,
|
|
123
|
+
fill: "var(--bg-tooltip, var(--bg-tertiary))",
|
|
124
|
+
stroke: "var(--border)",
|
|
125
|
+
strokeWidth: 1
|
|
126
|
+
}), /* @__PURE__ */ d("text", {
|
|
127
|
+
x: t,
|
|
128
|
+
y: e.y + 15,
|
|
129
|
+
textAnchor: "middle",
|
|
130
|
+
fill: "var(--text-primary)",
|
|
131
|
+
fontSize: 10,
|
|
132
|
+
fontWeight: 600,
|
|
133
|
+
children: C
|
|
134
|
+
})] });
|
|
135
|
+
})()
|
|
136
|
+
]
|
|
137
|
+
}, e.label);
|
|
138
|
+
})
|
|
139
|
+
]
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
//#endregion
|
|
143
|
+
export { g as VerticalBarChart };
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { clamp as e } from "../../lib/math.js";
|
|
2
|
+
//#region src/components/charts/chartUtils.ts
|
|
3
|
+
var t = {
|
|
4
|
+
"text-accent": "var(--accent)",
|
|
5
|
+
"text-blue": "var(--blue)",
|
|
6
|
+
"text-green": "var(--green)",
|
|
7
|
+
"text-purple": "var(--purple)",
|
|
8
|
+
"text-red": "var(--red)",
|
|
9
|
+
"text-yellow": "var(--yellow)"
|
|
10
|
+
};
|
|
11
|
+
function n(e) {
|
|
12
|
+
let t = Math.abs(e);
|
|
13
|
+
return t >= 1e6 ? `${(e / 1e6).toFixed(1)}M` : t >= 1e3 ? `${(e / 1e3).toFixed(1)}k` : String(e);
|
|
14
|
+
}
|
|
15
|
+
function r(e) {
|
|
16
|
+
return e ? t[e] ?? e : "var(--accent)";
|
|
17
|
+
}
|
|
18
|
+
function i(e, t) {
|
|
19
|
+
if (e <= 0 || t <= 0) return [];
|
|
20
|
+
if (e === 1 || t === 1) return [0];
|
|
21
|
+
let n = Math.min(e, Math.max(2, Math.floor(t))), r = (e - 1) / (n - 1), i = /* @__PURE__ */ new Set();
|
|
22
|
+
for (let e = 0; e < n; e += 1) i.add(Math.round(e * r));
|
|
23
|
+
return i.add(e - 1), Array.from(i).sort((e, t) => e - t);
|
|
24
|
+
}
|
|
25
|
+
function a(e) {
|
|
26
|
+
return Number.isFinite(e) ? Math.max(0, e) : 0;
|
|
27
|
+
}
|
|
28
|
+
function o(e, t) {
|
|
29
|
+
let n = String(e ?? "");
|
|
30
|
+
return t === void 0 || t <= 0 || n.length <= t ? n : t <= 3 ? n.slice(0, t) : `${n.slice(0, t - 3)}...`;
|
|
31
|
+
}
|
|
32
|
+
function s(e, t = 10) {
|
|
33
|
+
let n = 0;
|
|
34
|
+
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
|
+
return Math.ceil(n);
|
|
36
|
+
}
|
|
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);
|
|
39
|
+
}
|
|
40
|
+
function l(t, n, { boundsHeight: r, boundsWidth: i, height: a, margin: o = 0, offset: s = 8, width: c }) {
|
|
41
|
+
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
|
+
return {
|
|
43
|
+
height: u,
|
|
44
|
+
placement: h,
|
|
45
|
+
width: l,
|
|
46
|
+
x: p,
|
|
47
|
+
y: h === "above" ? m : e(n + s, o, f)
|
|
48
|
+
};
|
|
49
|
+
}
|
|
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, {
|
|
52
|
+
boundsHeight: n,
|
|
53
|
+
boundsWidth: r,
|
|
54
|
+
height: i,
|
|
55
|
+
margin: a,
|
|
56
|
+
offset: o,
|
|
57
|
+
width: s
|
|
58
|
+
});
|
|
59
|
+
return {
|
|
60
|
+
left: c.x + c.width / 2,
|
|
61
|
+
minWidth: c.width,
|
|
62
|
+
top: c.y + c.height / 2,
|
|
63
|
+
transform: "translate(-50%, -50%)",
|
|
64
|
+
width: c.width
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
//#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 };
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* />
|
|
17
17
|
* ```
|
|
18
18
|
*/
|
|
19
|
-
import { type ElementType, type ReactNode } from "react";
|
|
19
|
+
import { type ComponentPropsWithRef, type ElementType, type ReactNode } from "react";
|
|
20
20
|
interface ColumnDef {
|
|
21
21
|
/** Unique column key. */
|
|
22
22
|
key: string;
|
|
@@ -27,7 +27,7 @@ interface ColumnDef {
|
|
|
27
27
|
/** Heading to list this column under; consecutive columns share one. */
|
|
28
28
|
group?: string;
|
|
29
29
|
}
|
|
30
|
-
export interface ColumnPickerProps {
|
|
30
|
+
export interface ColumnPickerProps extends Omit<ComponentPropsWithRef<"div">, "children" | "hidden" | "onToggle"> {
|
|
31
31
|
/** List of toggleable columns (exclude utility columns like select/actions). */
|
|
32
32
|
columns: ColumnDef[];
|
|
33
33
|
/** Set of currently hidden column keys. */
|
|
@@ -47,5 +47,5 @@ export interface ColumnPickerProps {
|
|
|
47
47
|
/** Content below the list, e.g. "Select all" actions. */
|
|
48
48
|
footer?: ReactNode;
|
|
49
49
|
}
|
|
50
|
-
export declare function ColumnPicker({ columns, hidden, onToggle, label, heading, icon, onOnly, onlyLabel, footer, }: ColumnPickerProps): import("react/jsx-runtime").JSX.Element;
|
|
50
|
+
export declare function ColumnPicker({ columns, hidden, onToggle, label, heading, icon, onOnly, onlyLabel, footer, className, ref, ...rest }: ColumnPickerProps): import("react/jsx-runtime").JSX.Element;
|
|
51
51
|
export {};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { cn as e } from "../../lib/cn.js";
|
|
2
|
+
import { mergeRefs as t } from "../../lib/mergeRefs.js";
|
|
3
|
+
import { useDismiss as n } from "../../hooks/useDismiss.js";
|
|
4
|
+
import { Checkbox as r } from "../ui/Checkbox.js";
|
|
5
|
+
import { FilterButton as i } from "../ui/FilterButton.js";
|
|
6
|
+
import { Fragment as a, useCallback as o, useMemo as s, useRef as c, useState as l } from "react";
|
|
7
|
+
import { jsx as u, jsxs as d } from "react/jsx-runtime";
|
|
8
|
+
import { Columns3 as f } from "lucide-react";
|
|
9
|
+
//#region src/components/tables/ColumnPicker.tsx
|
|
10
|
+
function p(e) {
|
|
11
|
+
return typeof e.header == "string" ? e.header : e.sortLabel ?? e.key;
|
|
12
|
+
}
|
|
13
|
+
function m({ columns: m, hidden: h, onToggle: g, label: _ = "Columns", heading: v = "Toggle columns", icon: y = f, onOnly: b, onlyLabel: x = "Only", footer: S, className: C, ref: w, ...T }) {
|
|
14
|
+
let [E, D] = l(!1), O = c(null), k = s(() => t(O, w), [w]);
|
|
15
|
+
return n(E, o(() => D(!1), []), [O]), /* @__PURE__ */ d("div", {
|
|
16
|
+
...T,
|
|
17
|
+
ref: k,
|
|
18
|
+
className: e("relative", C),
|
|
19
|
+
children: [/* @__PURE__ */ u(i, {
|
|
20
|
+
icon: y,
|
|
21
|
+
onClick: () => D(!E),
|
|
22
|
+
children: _
|
|
23
|
+
}), E && /* @__PURE__ */ d("div", {
|
|
24
|
+
className: e("ui-glass ui-glass-popover bg-bg-tertiary border-border-strong animate-scale-in absolute top-full right-0 z-[100] mt-1 rounded-md border py-1 shadow-lg", b ? "w-56" : "w-48"),
|
|
25
|
+
children: [m.map((e, t) => /* @__PURE__ */ d(a, { children: [(t === 0 || e.group !== m[t - 1].group) && /* @__PURE__ */ u("p", {
|
|
26
|
+
className: "text-2xs-f text-text-tertiary px-3 py-1.5 font-semibold tracking-wider uppercase",
|
|
27
|
+
children: e.group ?? v
|
|
28
|
+
}), /* @__PURE__ */ d("div", {
|
|
29
|
+
onClick: () => g(e.key),
|
|
30
|
+
className: "group text-text-secondary hover:text-text-primary hover:bg-bg-hover flex h-7 w-full cursor-pointer items-center gap-2.5 px-3 text-xs transition-colors duration-[100ms]",
|
|
31
|
+
children: [
|
|
32
|
+
/* @__PURE__ */ u(r, {
|
|
33
|
+
checked: !h.has(e.key),
|
|
34
|
+
onChange: () => {},
|
|
35
|
+
"aria-label": p(e)
|
|
36
|
+
}),
|
|
37
|
+
/* @__PURE__ */ u("span", {
|
|
38
|
+
className: "min-w-0 flex-1 truncate",
|
|
39
|
+
children: e.header
|
|
40
|
+
}),
|
|
41
|
+
b && /* @__PURE__ */ u("button", {
|
|
42
|
+
type: "button",
|
|
43
|
+
"aria-label": `${x}: ${p(e)}`,
|
|
44
|
+
onClick: (t) => {
|
|
45
|
+
t.stopPropagation(), b(e.key);
|
|
46
|
+
},
|
|
47
|
+
className: "text-text-tertiary hover:text-text-primary text-2xs opacity-0 transition-opacity duration-[100ms] group-hover:opacity-100 focus-visible:opacity-100",
|
|
48
|
+
children: x
|
|
49
|
+
})
|
|
50
|
+
]
|
|
51
|
+
})] }, e.key)), S && /* @__PURE__ */ u("div", {
|
|
52
|
+
className: "border-border mt-1 border-t px-3 pt-1",
|
|
53
|
+
children: S
|
|
54
|
+
})]
|
|
55
|
+
})]
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
//#endregion
|
|
59
|
+
export { m as ColumnPicker };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ReactNode } from "react";
|
|
2
|
-
export interface PaginationProps {
|
|
1
|
+
import type { ComponentPropsWithRef, ReactNode } from "react";
|
|
2
|
+
export interface PaginationProps extends Omit<ComponentPropsWithRef<"div">, "children"> {
|
|
3
3
|
/** Current page, 1-based. */
|
|
4
4
|
page: number;
|
|
5
5
|
/** Total pages. With no caption or loading state, hides when this is 1 or less. */
|
|
@@ -16,4 +16,4 @@ export interface PaginationProps {
|
|
|
16
16
|
*/
|
|
17
17
|
summary?: ReactNode | ((total: number | undefined) => ReactNode);
|
|
18
18
|
}
|
|
19
|
-
export declare function Pagination({ page, totalPages, onPageChange, loading, total, summary, }: PaginationProps): import("react/jsx-runtime").JSX.Element | null;
|
|
19
|
+
export declare function Pagination({ page, totalPages, onPageChange, loading, total, summary, className, ref, ...rest }: PaginationProps): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { cn as e } from "../../lib/cn.js";
|
|
2
|
+
import { Fragment as t, jsx as n, jsxs as r } from "react/jsx-runtime";
|
|
3
|
+
import { ChevronLeft as i, ChevronRight as a } from "lucide-react";
|
|
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
|
+
if (s <= 1 && !l && u === void 0 && d == null) return null;
|
|
7
|
+
let h = [];
|
|
8
|
+
for (let e = 1; e <= s; e++) e === 1 || e === s || e >= o - 1 && e <= o + 1 ? h.push(e) : h[h.length - 1] !== "ellipsis" && h.push("ellipsis");
|
|
9
|
+
return /* @__PURE__ */ r("div", {
|
|
10
|
+
ref: p,
|
|
11
|
+
...m,
|
|
12
|
+
className: e("flex items-center gap-1", f),
|
|
13
|
+
children: [d !== null && (l || u !== void 0 || d !== void 0) && /* @__PURE__ */ n("span", {
|
|
14
|
+
role: "status",
|
|
15
|
+
className: "text-text-tertiary text-xs",
|
|
16
|
+
children: l ? "Loading results..." : d === void 0 ? `${u} in total` : typeof d == "function" ? d(u) : d
|
|
17
|
+
}), s > 1 && /* @__PURE__ */ r(t, { children: [
|
|
18
|
+
/* @__PURE__ */ n("button", {
|
|
19
|
+
type: "button",
|
|
20
|
+
disabled: o === 1,
|
|
21
|
+
"aria-disabled": l || void 0,
|
|
22
|
+
onClick: () => {
|
|
23
|
+
l || c(o - 1);
|
|
24
|
+
},
|
|
25
|
+
className: e("text-text-tertiary hover:text-text-primary hover:bg-bg-hover flex h-7 w-7 cursor-pointer items-center justify-center rounded disabled:cursor-not-allowed disabled:opacity-30", l && "cursor-not-allowed opacity-30"),
|
|
26
|
+
"aria-label": "Previous page",
|
|
27
|
+
children: /* @__PURE__ */ n(i, { className: "h-3.5 w-3.5" })
|
|
28
|
+
}),
|
|
29
|
+
h.map((t, r) => t === "ellipsis" ? /* @__PURE__ */ n("span", {
|
|
30
|
+
className: "text-text-tertiary flex h-7 w-7 items-center justify-center text-xs",
|
|
31
|
+
children: "..."
|
|
32
|
+
}, `e${r}`) : /* @__PURE__ */ n("button", {
|
|
33
|
+
type: "button",
|
|
34
|
+
"aria-disabled": l || void 0,
|
|
35
|
+
onClick: () => {
|
|
36
|
+
l || c(t);
|
|
37
|
+
},
|
|
38
|
+
className: e("flex h-7 w-7 cursor-pointer items-center justify-center rounded text-xs font-medium", l && "cursor-not-allowed", "transition-colors duration-[100ms]", t === o ? "bg-accent text-text-on-accent" : "text-text-secondary hover:text-text-primary hover:bg-bg-hover"),
|
|
39
|
+
children: t
|
|
40
|
+
}, t)),
|
|
41
|
+
/* @__PURE__ */ n("button", {
|
|
42
|
+
type: "button",
|
|
43
|
+
disabled: o >= s,
|
|
44
|
+
"aria-disabled": l || void 0,
|
|
45
|
+
onClick: () => {
|
|
46
|
+
l || c(o + 1);
|
|
47
|
+
},
|
|
48
|
+
className: e("text-text-tertiary hover:text-text-primary hover:bg-bg-hover flex h-7 w-7 cursor-pointer items-center justify-center rounded disabled:cursor-not-allowed disabled:opacity-30", l && "cursor-not-allowed opacity-30"),
|
|
49
|
+
"aria-label": "Next page",
|
|
50
|
+
children: /* @__PURE__ */ n(a, { className: "h-3.5 w-3.5" })
|
|
51
|
+
})
|
|
52
|
+
] })]
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
//#endregion
|
|
56
|
+
export { o as Pagination };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type HTMLAttributes, type ReactNode, type TableHTMLAttributes } from "react";
|
|
1
|
+
import { type ComponentPropsWithRef, type HTMLAttributes, type ReactNode, type TableHTMLAttributes } from "react";
|
|
2
2
|
import { type SortDir } from "./sortRows";
|
|
3
3
|
export interface Column<T> {
|
|
4
4
|
/** Unique id for the column. Used as the React key and as the sort key. */
|
|
@@ -41,7 +41,7 @@ export interface Column<T> {
|
|
|
41
41
|
/** Renders the cell content for a row. */
|
|
42
42
|
render: (row: T) => ReactNode;
|
|
43
43
|
}
|
|
44
|
-
export interface ResourceTableProps<T> {
|
|
44
|
+
export interface ResourceTableProps<T> extends Omit<ComponentPropsWithRef<"div">, "children"> {
|
|
45
45
|
/** The rows to display. */
|
|
46
46
|
data: T[];
|
|
47
47
|
/** Column definitions, in display order. */
|
|
@@ -112,4 +112,4 @@ export interface ResourceTableProps<T> {
|
|
|
112
112
|
*
|
|
113
113
|
* Markup and base styling come from the shared {@link Table} parts.
|
|
114
114
|
*/
|
|
115
|
-
export declare function ResourceTable<T>({ data, columns, getRowId, onRowClick, emptyMessage, sortKey: controlledSortKey, sortDir: controlledSortDir, onSortChange, caption, loading, loadingMessage, className, tableProps, getRowProps, isRowSelected, }: ResourceTableProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
115
|
+
export declare function ResourceTable<T>({ data, columns, getRowId, onRowClick, emptyMessage, sortKey: controlledSortKey, sortDir: controlledSortDir, onSortChange, caption, loading, loadingMessage, className, tableProps, getRowProps, isRowSelected, ref, ...rest }: ResourceTableProps<T>): import("react/jsx-runtime").JSX.Element;
|