@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,162 @@
|
|
|
1
|
+
import { placePopup as e, roomOnSide as t } from "../lib/anchorPlacement.js";
|
|
2
|
+
import { useLayoutEffect as n, useRef as r } from "react";
|
|
3
|
+
//#region src/hooks/useAnchoredPopup.ts
|
|
4
|
+
function i(e, t) {
|
|
5
|
+
let n = {
|
|
6
|
+
left: Math.max(e.left, t.left),
|
|
7
|
+
top: Math.max(e.top, t.top),
|
|
8
|
+
right: Math.min(e.right, t.right),
|
|
9
|
+
bottom: Math.min(e.bottom, t.bottom)
|
|
10
|
+
};
|
|
11
|
+
return n.left < n.right && n.top < n.bottom ? n : null;
|
|
12
|
+
}
|
|
13
|
+
function a(e, t) {
|
|
14
|
+
let n = i(e.getBoundingClientRect(), t), r = e.ownerDocument.defaultView;
|
|
15
|
+
for (let t = e.parentElement; n && t && t !== e.ownerDocument.documentElement; t = t.parentElement) {
|
|
16
|
+
let e = r?.getComputedStyle(t);
|
|
17
|
+
e && (e.overflowX !== "visible" || e.overflowY !== "visible") && (n = i(n, t.getBoundingClientRect()));
|
|
18
|
+
}
|
|
19
|
+
return n !== null;
|
|
20
|
+
}
|
|
21
|
+
function o(e) {
|
|
22
|
+
let t = e.createElement("div");
|
|
23
|
+
return t.setAttribute("aria-hidden", "true"), t.style.cssText = "position:fixed;left:0;top:0;width:0;height:0;visibility:hidden;pointer-events:none", t;
|
|
24
|
+
}
|
|
25
|
+
function s(e) {
|
|
26
|
+
let t = null;
|
|
27
|
+
return {
|
|
28
|
+
measure() {
|
|
29
|
+
let n = e.parentElement;
|
|
30
|
+
if (!n) return {
|
|
31
|
+
left: 0,
|
|
32
|
+
top: 0
|
|
33
|
+
};
|
|
34
|
+
t?.parentElement !== n && (t?.remove(), t = o(e.ownerDocument), n.appendChild(t));
|
|
35
|
+
let { left: r, top: i } = t.getBoundingClientRect();
|
|
36
|
+
return {
|
|
37
|
+
left: r,
|
|
38
|
+
top: i
|
|
39
|
+
};
|
|
40
|
+
},
|
|
41
|
+
release() {
|
|
42
|
+
t?.remove(), t = null;
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
var c = (e, t) => e.length !== t.length || e.some((e, n) => Math.abs(e - t[n]) > .5);
|
|
47
|
+
function l(i, o, l, { side: u, align: d = "center", gap: f = 4, margin: p = 8, onAnchorHidden: m, matchAnchorWidth: h = !1, flip: g = !0, minSize: _ = 120 }) {
|
|
48
|
+
let v = r(m);
|
|
49
|
+
n(() => {
|
|
50
|
+
v.current = m;
|
|
51
|
+
}), n(() => {
|
|
52
|
+
let n = l.current;
|
|
53
|
+
if (!i || !n) return;
|
|
54
|
+
let r = n.ownerDocument, m = r.defaultView ?? window, y = s(n), b = [], x = (e) => {
|
|
55
|
+
let t = e.getBoundingClientRect(), n = y.measure();
|
|
56
|
+
return [
|
|
57
|
+
t.left,
|
|
58
|
+
t.top,
|
|
59
|
+
t.width,
|
|
60
|
+
t.height,
|
|
61
|
+
n.left,
|
|
62
|
+
n.top
|
|
63
|
+
];
|
|
64
|
+
}, S = (i) => {
|
|
65
|
+
let s = o.current;
|
|
66
|
+
if (!s) return;
|
|
67
|
+
let c = r.documentElement, l = {
|
|
68
|
+
left: 0,
|
|
69
|
+
top: 0,
|
|
70
|
+
right: c.clientWidth || m.innerWidth,
|
|
71
|
+
bottom: c.clientHeight || m.innerHeight
|
|
72
|
+
};
|
|
73
|
+
if (i && v.current && !a(s, l)) {
|
|
74
|
+
v.current();
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
let y = s.getBoundingClientRect();
|
|
78
|
+
if (h) {
|
|
79
|
+
let e = s instanceof HTMLElement ? s.offsetWidth : y.width;
|
|
80
|
+
n.style.width = `${e}px`;
|
|
81
|
+
}
|
|
82
|
+
let S = u === "top" || u === "bottom";
|
|
83
|
+
if (!g) {
|
|
84
|
+
let e = t(y, l, u) - f - p;
|
|
85
|
+
n.style[S ? "maxHeight" : "maxWidth"] = `${Math.max(Math.floor(e), _)}px`;
|
|
86
|
+
}
|
|
87
|
+
let C = e(u, y, {
|
|
88
|
+
size: {
|
|
89
|
+
width: n.offsetWidth,
|
|
90
|
+
height: n.offsetHeight
|
|
91
|
+
},
|
|
92
|
+
bounds: l,
|
|
93
|
+
margin: p,
|
|
94
|
+
gap: f,
|
|
95
|
+
align: d,
|
|
96
|
+
flip: g
|
|
97
|
+
});
|
|
98
|
+
b = x(s), n.style.left = `${C.left - b[4]}px`, n.style.top = `${C.top - b[5]}px`, n.dataset.side = C.side;
|
|
99
|
+
}, C = () => {
|
|
100
|
+
let e = o.current;
|
|
101
|
+
e && c(x(e), b) && S(!1);
|
|
102
|
+
}, w = 0, T = () => {
|
|
103
|
+
C(), w = m.requestAnimationFrame(T);
|
|
104
|
+
}, E = (e) => {
|
|
105
|
+
e.target instanceof Node && n.contains(e.target) || S(!0);
|
|
106
|
+
}, D = () => S(!0);
|
|
107
|
+
S(!1), m.addEventListener("resize", D), m.addEventListener("scroll", E, !0);
|
|
108
|
+
let O = typeof ResizeObserver > "u" ? null : new ResizeObserver(() => S(!1));
|
|
109
|
+
return O?.observe(n), o.current && O?.observe(o.current), r.addEventListener("animationend", C, !0), r.addEventListener("transitionend", C, !0), w = m.requestAnimationFrame(T), () => {
|
|
110
|
+
m.removeEventListener("resize", D), m.removeEventListener("scroll", E, !0), r.removeEventListener("animationend", C, !0), r.removeEventListener("transitionend", C, !0), m.cancelAnimationFrame(w), O?.disconnect(), y.release(), g || (n.style.maxHeight = "", n.style.maxWidth = "");
|
|
111
|
+
};
|
|
112
|
+
}, [
|
|
113
|
+
i,
|
|
114
|
+
o,
|
|
115
|
+
l,
|
|
116
|
+
u,
|
|
117
|
+
d,
|
|
118
|
+
f,
|
|
119
|
+
p,
|
|
120
|
+
h,
|
|
121
|
+
g,
|
|
122
|
+
_
|
|
123
|
+
]);
|
|
124
|
+
}
|
|
125
|
+
function u(e, t, i, a) {
|
|
126
|
+
let o = r(a);
|
|
127
|
+
n(() => {
|
|
128
|
+
o.current = a;
|
|
129
|
+
}), n(() => {
|
|
130
|
+
let n = i.current;
|
|
131
|
+
if (!e || !n) return;
|
|
132
|
+
let r = n.ownerDocument, a = r.defaultView ?? window, l = s(n), u = [], d = () => {
|
|
133
|
+
let e = t.current;
|
|
134
|
+
if (!e) return;
|
|
135
|
+
let i = e.getBoundingClientRect(), s = l.measure(), d = [
|
|
136
|
+
i.left,
|
|
137
|
+
i.top,
|
|
138
|
+
i.width,
|
|
139
|
+
i.height,
|
|
140
|
+
s.left,
|
|
141
|
+
s.top
|
|
142
|
+
];
|
|
143
|
+
if (!c(d, u)) return;
|
|
144
|
+
u = d;
|
|
145
|
+
let f = r.documentElement.clientWidth || a.innerWidth, p = o.current(i, f);
|
|
146
|
+
n.style.left = `${p.left - s.left}px`, n.style.top = `${p.top - s.top}px`, p.width !== void 0 && (n.style.width = `${p.width}px`);
|
|
147
|
+
};
|
|
148
|
+
d();
|
|
149
|
+
let f = 0, p = () => {
|
|
150
|
+
d(), f = a.requestAnimationFrame(p);
|
|
151
|
+
};
|
|
152
|
+
return f = a.requestAnimationFrame(p), () => {
|
|
153
|
+
a.cancelAnimationFrame(f), l.release();
|
|
154
|
+
};
|
|
155
|
+
}, [
|
|
156
|
+
e,
|
|
157
|
+
t,
|
|
158
|
+
i
|
|
159
|
+
]);
|
|
160
|
+
}
|
|
161
|
+
//#endregion
|
|
162
|
+
export { l as useAnchoredPopup, u as useFixedPopupAt };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { isLightTheme as e } from "../config/theme.js";
|
|
2
|
+
import { useSettings as t } from "./useSettings.js";
|
|
3
|
+
import { useCallback as n } from "react";
|
|
4
|
+
//#region src/hooks/useApplyTheme.ts
|
|
5
|
+
function r() {
|
|
6
|
+
let { setPreferredDarkTheme: r, setPreferredLightTheme: i, setColorMode: a } = t();
|
|
7
|
+
return n((t) => {
|
|
8
|
+
e(t) ? (i(t), a("light")) : (r(t), a("dark"));
|
|
9
|
+
}, [
|
|
10
|
+
r,
|
|
11
|
+
i,
|
|
12
|
+
a
|
|
13
|
+
]);
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
export { r as useApplyTheme };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface UseControllableStateOptions<T> {
|
|
2
|
+
/** Controlled value. `undefined` means uncontrolled; `null` is a controlled value. */
|
|
3
|
+
value?: T;
|
|
4
|
+
/** Initial value when uncontrolled. */
|
|
5
|
+
defaultValue: T;
|
|
6
|
+
/** Called with every new value, controlled or not. */
|
|
7
|
+
onChange?: (value: T) => void;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* State that a parent may control through `value`, or leave to the component
|
|
11
|
+
* by passing only `defaultValue`. Returns the current value and a setter that
|
|
12
|
+
* updates internal state when uncontrolled and always calls `onChange`.
|
|
13
|
+
*/
|
|
14
|
+
export declare function useControllableState<T>({ value, defaultValue, onChange, }: UseControllableStateOptions<T>): [T, (next: T) => void];
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { useCallback as e, useState as t } from "react";
|
|
2
|
+
//#region src/hooks/useControllableState.ts
|
|
3
|
+
function n({ value: n, defaultValue: r, onChange: i }) {
|
|
4
|
+
let [a, o] = t(() => r), s = n !== void 0, c = e((e) => {
|
|
5
|
+
s || o(() => e), i?.(e);
|
|
6
|
+
}, [s, i]);
|
|
7
|
+
return [s ? n : a, c];
|
|
8
|
+
}
|
|
9
|
+
//#endregion
|
|
10
|
+
export { n as useControllableState };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { useOverlayEscape as e } from "./useOverlayStack.js";
|
|
2
|
+
import { useEffect as t } from "react";
|
|
3
|
+
//#region src/hooks/useDismiss.ts
|
|
4
|
+
function n(n, r, i, a, o) {
|
|
5
|
+
let s = o?.outsideClick ?? !0;
|
|
6
|
+
return t(() => {
|
|
7
|
+
if (!n) return;
|
|
8
|
+
let e = (e) => {
|
|
9
|
+
let t = e.target;
|
|
10
|
+
a?.some((e) => e.current?.contains(t)) || i.every((e) => e.current && !e.current.contains(t)) && r("outside-click");
|
|
11
|
+
};
|
|
12
|
+
if (!s) return;
|
|
13
|
+
let t = new Set([document, i[0]?.current?.ownerDocument ?? document]);
|
|
14
|
+
return t.forEach((t) => t.addEventListener("mousedown", e)), () => t.forEach((t) => t.removeEventListener("mousedown", e));
|
|
15
|
+
}, [
|
|
16
|
+
n,
|
|
17
|
+
r,
|
|
18
|
+
i,
|
|
19
|
+
a,
|
|
20
|
+
s
|
|
21
|
+
]), e(n, () => r("escape"), i[0]);
|
|
22
|
+
}
|
|
23
|
+
//#endregion
|
|
24
|
+
export { n as useDismiss };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { useEffect as e } from "react";
|
|
2
|
+
//#region src/hooks/useFocusTrap.ts
|
|
3
|
+
var t = "a[href], button:not([disabled]), input:not([disabled]):not([type=\"hidden\"]), textarea:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex=\"-1\"])";
|
|
4
|
+
function n(n, r, { initialFocusRef: i, returnFocusRef: a } = {}) {
|
|
5
|
+
e(() => {
|
|
6
|
+
let e = n.current;
|
|
7
|
+
if (!r || !e) return;
|
|
8
|
+
let o = e.ownerDocument, s = o.activeElement, c = a?.current, l = () => {
|
|
9
|
+
let n = Array.from(e.querySelectorAll(t)).filter((e) => e.tabIndex >= 0 && !e.matches(":disabled") && !e.closest("[hidden], [inert]") && e.getClientRects().length > 0);
|
|
10
|
+
return n.filter((e) => {
|
|
11
|
+
if (!e.matches("input[type=\"radio\"]")) return !0;
|
|
12
|
+
let t = e;
|
|
13
|
+
if (!t.name) return !0;
|
|
14
|
+
let r = n.filter((e) => e.matches("input[type=\"radio\"]") && e.name === t.name && e.form === t.form && e.getRootNode() === t.getRootNode());
|
|
15
|
+
return t === (r.find((e) => e.checked) ?? r[0]);
|
|
16
|
+
});
|
|
17
|
+
}, u = i?.current;
|
|
18
|
+
u && e.contains(u) ? u.focus() : (l()[0] ?? e).focus();
|
|
19
|
+
let d = (t) => {
|
|
20
|
+
if (t.key !== "Tab") return;
|
|
21
|
+
let n = l();
|
|
22
|
+
if (!n.length) {
|
|
23
|
+
t.preventDefault(), e.focus();
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
let r = n[0], i = n[n.length - 1];
|
|
27
|
+
t.shiftKey && (o.activeElement === r || !n.includes(o.activeElement)) ? (t.preventDefault(), i.focus()) : !t.shiftKey && (o.activeElement === i || !n.includes(o.activeElement)) && (t.preventDefault(), r.focus());
|
|
28
|
+
};
|
|
29
|
+
return o.addEventListener("keydown", d), () => {
|
|
30
|
+
o.removeEventListener("keydown", d);
|
|
31
|
+
let e = c ?? s;
|
|
32
|
+
e?.isConnected && e.focus();
|
|
33
|
+
};
|
|
34
|
+
}, [
|
|
35
|
+
r,
|
|
36
|
+
n,
|
|
37
|
+
i,
|
|
38
|
+
a
|
|
39
|
+
]);
|
|
40
|
+
}
|
|
41
|
+
//#endregion
|
|
42
|
+
export { n as useFocusTrap };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { createOverlayNode as e, lockBodyScroll as t, pushOverlay as n } from "../lib/overlayStack.js";
|
|
2
|
+
import { createContext as r, useContext as i, useEffect as a, useLayoutEffect as o, useRef as s, useState as c } from "react";
|
|
3
|
+
//#region src/hooks/useOverlayStack.ts
|
|
4
|
+
var l = r(null);
|
|
5
|
+
function u(t, r, u) {
|
|
6
|
+
let d = i(l), [f] = c(() => e(d)), p = s(r);
|
|
7
|
+
return o(() => {
|
|
8
|
+
p.current = r;
|
|
9
|
+
}), a(() => {
|
|
10
|
+
if (t) return n(f, (e) => p.current(e), u?.current?.ownerDocument ?? document);
|
|
11
|
+
}, [
|
|
12
|
+
t,
|
|
13
|
+
f,
|
|
14
|
+
u
|
|
15
|
+
]), f;
|
|
16
|
+
}
|
|
17
|
+
function d(e, n) {
|
|
18
|
+
a(() => {
|
|
19
|
+
if (e) return t(n?.current?.ownerDocument ?? document);
|
|
20
|
+
}, [e, n]);
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
export { l as OverlayContext, d as useBodyScrollLock, u as useOverlayEscape };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { useAnchoredPopup as e } from "./useAnchoredPopup.js";
|
|
2
|
+
import { useDismiss as t } from "./useDismiss.js";
|
|
3
|
+
import { useCallback as n, useId as r, useLayoutEffect as i, useRef as a, useState as o } from "react";
|
|
4
|
+
//#region src/hooks/usePopover.ts
|
|
5
|
+
var s = "ui-glass ui-glass-popover bg-bg-tertiary border-border-strong animate-scale-in fixed top-0 left-0 z-[100] rounded-md border shadow-lg";
|
|
6
|
+
function c({ haspopup: s, matchWidth: c = !1, disabled: l = !1, labelled: u = !1, flip: d = !0, onOpenChange: f }) {
|
|
7
|
+
let [p, m] = o(!1), h = a(!1), g = a(f);
|
|
8
|
+
i(() => {
|
|
9
|
+
g.current = f;
|
|
10
|
+
});
|
|
11
|
+
let _ = p && !l, v = a(null), y = a(null), b = a(null), x = a(null), S = r(), C = `${S}-label`, w = `${S}-trigger`, T = `${S}-popup`, E = n((e) => {
|
|
12
|
+
if (!h.current) return;
|
|
13
|
+
h.current = !1;
|
|
14
|
+
let t = x.current, n = t?.ownerDocument.activeElement ?? null, r = !!t && t.contains(n), i = !n || n === t?.ownerDocument.body;
|
|
15
|
+
m(!1), e === "escape" || e === "select" && (r || i) ? b.current?.focus() : e === "anchor-hidden" && r && b.current?.focus({ preventScroll: !0 }), g.current?.(!1, e ?? "blur");
|
|
16
|
+
}, []), D = n((e) => {
|
|
17
|
+
h.current || l || (h.current = !0, m(!0), g.current?.(!0, typeof e == "string" ? e : "toggle"));
|
|
18
|
+
}, [l]);
|
|
19
|
+
return t(_, E, [v]), e(_, y, x, {
|
|
20
|
+
side: "bottom",
|
|
21
|
+
align: "start",
|
|
22
|
+
gap: 4,
|
|
23
|
+
matchAnchorWidth: c,
|
|
24
|
+
flip: d,
|
|
25
|
+
onAnchorHidden: () => E("anchor-hidden")
|
|
26
|
+
}), {
|
|
27
|
+
open: _,
|
|
28
|
+
show: D,
|
|
29
|
+
close: E,
|
|
30
|
+
rootRef: v,
|
|
31
|
+
anchorRef: y,
|
|
32
|
+
triggerRef: b,
|
|
33
|
+
popupRef: x,
|
|
34
|
+
labelId: C,
|
|
35
|
+
triggerId: w,
|
|
36
|
+
popupId: T,
|
|
37
|
+
triggerAria: {
|
|
38
|
+
id: w,
|
|
39
|
+
"aria-haspopup": s,
|
|
40
|
+
"aria-expanded": _,
|
|
41
|
+
"aria-controls": _ ? T : void 0,
|
|
42
|
+
"aria-labelledby": u ? `${C} ${w}` : void 0
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
//#endregion
|
|
47
|
+
export { s as POPOVER_PANEL_CLASS, c as usePopover };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { createContext as e, useCallback as t, useContext as n, useState as r } from "react";
|
|
2
|
+
//#region src/hooks/usePortalContainer.ts
|
|
3
|
+
var i = e(null);
|
|
4
|
+
function a() {
|
|
5
|
+
return n(i);
|
|
6
|
+
}
|
|
7
|
+
function o(e) {
|
|
8
|
+
let [n, i] = r(null);
|
|
9
|
+
return [n, t((t) => {
|
|
10
|
+
e.current = t, i(t);
|
|
11
|
+
}, [e])];
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
export { i as PortalContainerContext, a as usePortalContainer, o as usePortalContainerRef };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { EMPTY_TYPEAHEAD as e, appendTypeahead as t, isTypeaheadActive as n, typeaheadNow as r } from "../lib/typeahead.js";
|
|
2
|
+
import { useRef as i } from "react";
|
|
3
|
+
//#region src/hooks/useTypeahead.ts
|
|
4
|
+
function a() {
|
|
5
|
+
let a = i(e);
|
|
6
|
+
return {
|
|
7
|
+
push(e) {
|
|
8
|
+
return a.current = t(a.current, e, r()), a.current.text;
|
|
9
|
+
},
|
|
10
|
+
active() {
|
|
11
|
+
return n(a.current, r());
|
|
12
|
+
},
|
|
13
|
+
clear() {
|
|
14
|
+
a.current = e;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
export { a as useTypeahead };
|