@codefast/ui 0.9.2 → 0.10.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/CHANGELOG.md +110 -0
- package/README.md +3 -0
- package/dist/components/accordion.js +1 -1
- package/dist/components/alert-dialog.d.ts +1 -1
- package/dist/components/alert-dialog.js +2 -2
- package/dist/components/alert.d.ts +1 -1
- package/dist/components/alert.js +2 -2
- package/dist/components/attachment.d.ts +2 -2
- package/dist/components/attachment.js +3 -3
- package/dist/components/avatar.js +1 -1
- package/dist/components/badge.d.ts +1 -1
- package/dist/components/badge.js +1 -1
- package/dist/components/breadcrumb.js +3 -3
- package/dist/components/bubble.d.ts +1 -1
- package/dist/components/bubble.js +2 -2
- package/dist/components/button-group.d.ts +2 -2
- package/dist/components/button-group.js +3 -3
- package/dist/components/button.d.ts +1 -1
- package/dist/components/button.js +1 -1
- package/dist/components/calendar.d.ts +1 -1
- package/dist/components/calendar.js +3 -3
- package/dist/components/card.js +1 -1
- package/dist/components/carousel.d.ts +1 -1
- package/dist/components/carousel.js +17 -26
- package/dist/components/chart.js +1 -1
- package/dist/components/checkbox-cards.d.ts +1 -1
- package/dist/components/checkbox-cards.js +3 -3
- package/dist/components/checkbox-group.d.ts +1 -1
- package/dist/components/checkbox-group.js +2 -2
- package/dist/components/checkbox.js +1 -1
- package/dist/components/command.d.ts +8 -2
- package/dist/components/command.js +5 -5
- package/dist/components/context-menu.js +1 -1
- package/dist/components/dialog.d.ts +14 -2
- package/dist/components/dialog.js +6 -6
- package/dist/components/drawer.d.ts +2 -2
- package/dist/components/drawer.js +2 -2
- package/dist/components/dropdown-menu.js +1 -1
- package/dist/components/empty.d.ts +1 -1
- package/dist/components/empty.js +2 -2
- package/dist/components/field.d.ts +2 -2
- package/dist/components/field.js +4 -4
- package/dist/components/form.js +2 -2
- package/dist/components/hover-card.js +1 -1
- package/dist/components/input-group.d.ts +4 -4
- package/dist/components/input-group.js +5 -5
- package/dist/components/input-number.d.ts +2 -2
- package/dist/components/input-number.js +6 -6
- package/dist/components/input-otp.js +1 -1
- package/dist/components/input-password.d.ts +16 -3
- package/dist/components/input-password.js +3 -3
- package/dist/components/input-search.d.ts +8 -2
- package/dist/components/input-search.js +3 -3
- package/dist/components/input.js +1 -1
- package/dist/components/item.d.ts +2 -2
- package/dist/components/item.js +3 -3
- package/dist/components/kbd.js +1 -1
- package/dist/components/label.js +1 -1
- package/dist/components/marker.d.ts +1 -1
- package/dist/components/marker.js +2 -2
- package/dist/components/menubar.js +1 -1
- package/dist/components/message-scroller.d.ts +3 -3
- package/dist/components/message-scroller.js +3 -3
- package/dist/components/message.js +1 -1
- package/dist/components/native-select.js +1 -1
- package/dist/components/navigation-menu.js +2 -2
- package/dist/components/pagination.d.ts +2 -2
- package/dist/components/pagination.js +3 -3
- package/dist/components/popover.js +1 -1
- package/dist/components/progress-circle.d.ts +2 -2
- package/dist/components/progress-circle.js +3 -3
- package/dist/components/progress.d.ts +6 -1
- package/dist/components/progress.js +12 -4
- package/dist/components/radio-cards.js +2 -2
- package/dist/components/radio-group.js +1 -1
- package/dist/components/radio.js +1 -1
- package/dist/components/resizable.js +1 -1
- package/dist/components/scroll-area.d.ts +1 -1
- package/dist/components/scroll-area.js +2 -2
- package/dist/components/select.js +1 -1
- package/dist/components/separator.d.ts +1 -1
- package/dist/components/separator.js +2 -2
- package/dist/components/sheet.d.ts +9 -3
- package/dist/components/sheet.js +5 -5
- package/dist/components/sidebar.d.ts +19 -7
- package/dist/components/sidebar.js +66 -32
- package/dist/components/skeleton.js +1 -1
- package/dist/components/slider.js +1 -1
- package/dist/components/spinner.js +1 -1
- package/dist/components/switch.js +1 -1
- package/dist/components/table.js +1 -1
- package/dist/components/tabs.d.ts +1 -1
- package/dist/components/tabs.js +2 -2
- package/dist/components/textarea.js +1 -1
- package/dist/components/toggle-group.d.ts +2 -2
- package/dist/components/toggle-group.js +2 -2
- package/dist/components/toggle.d.ts +1 -1
- package/dist/components/toggle.js +1 -1
- package/dist/components/tooltip.js +1 -1
- package/dist/hooks/use-is-mobile.js +1 -1
- package/dist/hooks/use-media-query.d.ts +3 -3
- package/dist/hooks/use-media-query.js +15 -32
- package/dist/hooks/use-message-scroller-commands.d.ts +2 -2
- package/dist/hooks/use-message-scroller-commands.js +2 -2
- package/dist/hooks/use-message-scroller-controller.d.ts +2 -2
- package/dist/hooks/use-message-scroller-controller.js +4 -4
- package/dist/hooks/use-message-scroller-refs.d.ts +1 -1
- package/dist/hooks/use-message-scroller-refs.js +3 -3
- package/dist/index.d.ts +180 -180
- package/dist/index.js +93 -93
- package/dist/lib/message-scroller/geometry.d.ts +1 -1
- package/dist/lib/message-scroller/geometry.js +1 -1
- package/dist/lib/message-scroller/stores.d.ts +1 -1
- package/dist/lib/message-scroller/stores.js +1 -1
- package/dist/lib/message-scroller/types.d.ts +1 -1
- package/dist/primitives/input-number.d.ts +6 -6
- package/dist/primitives/input-number.js +6 -6
- package/dist/primitives/message-scroller.d.ts +6 -6
- package/dist/primitives/message-scroller.js +3 -3
- package/dist/variants/alert.d.ts +1 -1
- package/dist/variants/alert.js +1 -1
- package/dist/variants/attachment.d.ts +1 -1
- package/dist/variants/attachment.js +1 -1
- package/dist/variants/badge.d.ts +1 -1
- package/dist/variants/badge.js +1 -1
- package/dist/variants/bubble.d.ts +1 -1
- package/dist/variants/bubble.js +1 -1
- package/dist/variants/button-group.d.ts +1 -1
- package/dist/variants/button-group.js +1 -1
- package/dist/variants/button.d.ts +1 -1
- package/dist/variants/button.js +1 -1
- package/dist/variants/empty.d.ts +1 -1
- package/dist/variants/empty.js +1 -1
- package/dist/variants/field.d.ts +1 -1
- package/dist/variants/field.js +1 -1
- package/dist/variants/input-group.d.ts +1 -1
- package/dist/variants/input-group.js +1 -1
- package/dist/variants/item.d.ts +1 -1
- package/dist/variants/item.js +1 -1
- package/dist/variants/marker.d.ts +1 -1
- package/dist/variants/marker.js +1 -1
- package/dist/variants/navigation-menu.d.ts +1 -1
- package/dist/variants/navigation-menu.js +1 -1
- package/dist/variants/progress-circle.d.ts +1 -1
- package/dist/variants/progress-circle.js +1 -1
- package/dist/variants/scroll-area.d.ts +1 -1
- package/dist/variants/scroll-area.js +1 -1
- package/dist/variants/separator.d.ts +1 -1
- package/dist/variants/separator.js +1 -1
- package/dist/variants/sheet.d.ts +1 -1
- package/dist/variants/sheet.js +1 -1
- package/dist/variants/sidebar.d.ts +1 -1
- package/dist/variants/sidebar.js +1 -1
- package/dist/variants/tabs.d.ts +1 -1
- package/dist/variants/tabs.js +1 -1
- package/dist/variants/toggle.d.ts +1 -1
- package/dist/variants/toggle.js +1 -1
- package/package.json +8 -7
- package/src/css/foundation/base.css +68 -0
- package/src/css/foundation/motion.css +65 -0
- package/src/css/foundation/source.css +14 -0
- package/src/css/foundation/tokens.css +83 -0
- package/src/css/foundation/utilities.css +451 -0
- package/src/css/foundation/variants.css +121 -0
- package/src/css/preset.css +14 -0
- package/src/css/style.css +11 -0
- package/src/css/themes/amber.css +105 -0
- package/src/css/themes/blue.css +105 -0
- package/src/css/themes/cyan.css +105 -0
- package/src/css/themes/emerald.css +105 -0
- package/src/css/themes/fuchsia.css +105 -0
- package/src/css/themes/gray.css +105 -0
- package/src/css/themes/green.css +105 -0
- package/src/css/themes/indigo.css +105 -0
- package/src/css/themes/lime.css +105 -0
- package/src/css/themes/neutral.css +105 -0
- package/src/css/themes/orange.css +105 -0
- package/src/css/themes/pink.css +105 -0
- package/src/css/themes/purple.css +105 -0
- package/src/css/themes/red.css +105 -0
- package/src/css/themes/rose.css +105 -0
- package/src/css/themes/sky.css +105 -0
- package/src/css/themes/slate.css +105 -0
- package/src/css/themes/stone.css +105 -0
- package/src/css/themes/teal.css +105 -0
- package/src/css/themes/violet.css +105 -0
- package/src/css/themes/yellow.css +105 -0
- package/src/css/themes/zinc.css +105 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import * as SeparatorPrimitive from "radix-ui/separator";
|
|
3
|
-
import { cn } from "
|
|
4
|
-
import { separatorVariants } from "
|
|
3
|
+
import { cn } from "#lib/utils";
|
|
4
|
+
import { separatorVariants } from "#variants/separator";
|
|
5
5
|
/**
|
|
6
6
|
* @since 0.3.16-canary.0
|
|
7
7
|
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as SheetPrimitive from "radix-ui/dialog";
|
|
2
2
|
import type { ComponentProps, JSX } from "react";
|
|
3
|
-
import type { ButtonVariants } from "
|
|
4
|
-
import type { SheetContentVariants } from "
|
|
3
|
+
import type { ButtonVariants } from "#variants/button";
|
|
4
|
+
import type { SheetContentVariants } from "#variants/sheet";
|
|
5
5
|
/**
|
|
6
6
|
* @since 0.3.16-canary.0
|
|
7
7
|
*/
|
|
@@ -22,12 +22,18 @@ declare function SheetTrigger({ ...props }: SheetTriggerProps): JSX.Element;
|
|
|
22
22
|
* @since 0.3.16-canary.0
|
|
23
23
|
*/
|
|
24
24
|
interface SheetContentProps extends ComponentProps<typeof SheetPrimitive.Content>, SheetContentVariants {
|
|
25
|
+
/**
|
|
26
|
+
* The accessible name of the built-in close button.
|
|
27
|
+
*
|
|
28
|
+
* @defaultValue `"Close"`
|
|
29
|
+
*/
|
|
30
|
+
closeLabel?: string | undefined;
|
|
25
31
|
showCloseButton?: boolean;
|
|
26
32
|
}
|
|
27
33
|
/**
|
|
28
34
|
* @since 0.3.16-canary.0
|
|
29
35
|
*/
|
|
30
|
-
declare function SheetContent({ children, className, showCloseButton, side, ...props }: SheetContentProps): JSX.Element;
|
|
36
|
+
declare function SheetContent({ children, className, closeLabel, showCloseButton, side, ...props }: SheetContentProps): JSX.Element;
|
|
31
37
|
/**
|
|
32
38
|
* @since 0.3.16-canary.0
|
|
33
39
|
*/
|
package/dist/components/sheet.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { XIcon } from "lucide-react";
|
|
3
3
|
import * as SheetPrimitive from "radix-ui/dialog";
|
|
4
|
-
import { cn } from "
|
|
5
|
-
import { buttonVariants } from "
|
|
6
|
-
import { sheetContentVariants } from "
|
|
4
|
+
import { cn } from "#lib/utils";
|
|
5
|
+
import { buttonVariants } from "#variants/button";
|
|
6
|
+
import { sheetContentVariants } from "#variants/sheet";
|
|
7
7
|
/**
|
|
8
8
|
* @since 0.3.16-canary.0
|
|
9
9
|
*/
|
|
@@ -19,12 +19,12 @@ function SheetTrigger({ ...props }) {
|
|
|
19
19
|
/**
|
|
20
20
|
* @since 0.3.16-canary.0
|
|
21
21
|
*/
|
|
22
|
-
function SheetContent({ children, className, showCloseButton = true, side = "right", ...props }) {
|
|
22
|
+
function SheetContent({ children, className, closeLabel = "Close", showCloseButton = true, side = "right", ...props }) {
|
|
23
23
|
return (_jsxs(SheetPrimitive.Portal, { "data-slot": "sheet-portal", children: [_jsx(SheetPrimitive.Overlay, { className: "fixed inset-0 z-50 bg-black/10 ease-gentle supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:animation-duration-panel-in data-open:fade-in-0 data-closed:animate-out data-closed:ease-exit data-closed:animation-duration-panel-out data-closed:fade-out-0", "data-slot": "sheet-overlay" }), _jsxs(SheetPrimitive.Content, { className: sheetContentVariants({ className, side }), "data-side": side, "data-slot": "sheet-content", ...props, children: [children, showCloseButton ? (_jsxs(SheetPrimitive.Close, { className: buttonVariants({
|
|
24
24
|
className: "absolute top-3 inset-e-3",
|
|
25
25
|
size: "icon-sm",
|
|
26
26
|
variant: "ghost",
|
|
27
|
-
}), "data-slot": "sheet-close", children: [_jsx(XIcon, {}), _jsx("span", { className: "sr-only", children:
|
|
27
|
+
}), "data-slot": "sheet-close", children: [_jsx(XIcon, {}), _jsx("span", { className: "sr-only", children: closeLabel })] })) : null] })] }));
|
|
28
28
|
}
|
|
29
29
|
/**
|
|
30
30
|
* @since 0.3.16-canary.0
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { ComponentProps, Dispatch, JSX, SetStateAction } from "react";
|
|
2
|
-
import { Button } from "
|
|
3
|
-
import { Input } from "
|
|
4
|
-
import { Separator } from "
|
|
5
|
-
import { TooltipContent } from "
|
|
6
|
-
import type { SidebarMenuButtonVariants } from "
|
|
2
|
+
import { Button } from "#components/button";
|
|
3
|
+
import { Input } from "#components/input";
|
|
4
|
+
import { Separator } from "#components/separator";
|
|
5
|
+
import { TooltipContent } from "#components/tooltip";
|
|
6
|
+
import type { SidebarMenuButtonVariants } from "#variants/sidebar";
|
|
7
7
|
interface SidebarContextValue {
|
|
8
8
|
isMobile: boolean;
|
|
9
9
|
open: boolean;
|
|
@@ -27,23 +27,35 @@ interface SidebarProviderProps extends ComponentProps<"div"> {
|
|
|
27
27
|
defaultOpen?: boolean;
|
|
28
28
|
onOpenChange?: (open: boolean) => void;
|
|
29
29
|
open?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* The key that toggles the sidebar together with ⌘ or Ctrl, or `false` for no shortcut.
|
|
32
|
+
*
|
|
33
|
+
* @defaultValue `"b"`
|
|
34
|
+
*/
|
|
35
|
+
shortcutKey?: string | false | undefined;
|
|
30
36
|
}
|
|
31
37
|
/**
|
|
32
38
|
* @since 0.3.16-canary.0
|
|
33
39
|
*/
|
|
34
|
-
declare function SidebarProvider({ children, className, defaultOpen, onOpenChange: setOpenProperty, open: openProperty, style, ...props }: SidebarProviderProps): JSX.Element;
|
|
40
|
+
declare function SidebarProvider({ children, className, defaultOpen, onOpenChange: setOpenProperty, open: openProperty, shortcutKey, style, ...props }: SidebarProviderProps): JSX.Element;
|
|
35
41
|
/**
|
|
36
42
|
* @since 0.3.16-canary.0
|
|
37
43
|
*/
|
|
38
44
|
interface SidebarProps extends ComponentProps<"div"> {
|
|
39
45
|
collapsible?: "icon" | "none" | "offcanvas";
|
|
46
|
+
/**
|
|
47
|
+
* The accessible name of the sheet the sidebar opens as on narrow screens.
|
|
48
|
+
*
|
|
49
|
+
* @defaultValue `"Sidebar"`
|
|
50
|
+
*/
|
|
51
|
+
mobileTitle?: string | undefined;
|
|
40
52
|
side?: "left" | "right";
|
|
41
53
|
variant?: "floating" | "inset" | "sidebar";
|
|
42
54
|
}
|
|
43
55
|
/**
|
|
44
56
|
* @since 0.3.16-canary.0
|
|
45
57
|
*/
|
|
46
|
-
declare function Sidebar({ children, className, collapsible, side, variant, ...props }: SidebarProps): JSX.Element;
|
|
58
|
+
declare function Sidebar({ children, className, collapsible, mobileTitle, side, variant, ...props }: SidebarProps): JSX.Element;
|
|
47
59
|
/**
|
|
48
60
|
* @since 0.3.16-canary.0
|
|
49
61
|
*/
|
|
@@ -2,22 +2,24 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { PanelLeftIcon } from "lucide-react";
|
|
3
3
|
import { Context } from "radix-ui/internal";
|
|
4
4
|
import * as Slot from "radix-ui/slot";
|
|
5
|
-
import { useCallback, useEffect, useId, useState } from "react";
|
|
6
|
-
import { Button } from "
|
|
7
|
-
import { Input } from "
|
|
8
|
-
import { Separator } from "
|
|
9
|
-
import { Sheet, SheetContent,
|
|
10
|
-
import { Skeleton } from "
|
|
11
|
-
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "
|
|
12
|
-
import {
|
|
13
|
-
import { cn } from "
|
|
14
|
-
import { sidebarMenuButtonVariants } from "
|
|
5
|
+
import { useCallback, useEffect, useEffectEvent, useId, useState } from "react";
|
|
6
|
+
import { Button } from "#components/button";
|
|
7
|
+
import { Input } from "#components/input";
|
|
8
|
+
import { Separator } from "#components/separator";
|
|
9
|
+
import { Sheet, SheetContent, SheetHeader, SheetTitle } from "#components/sheet";
|
|
10
|
+
import { Skeleton } from "#components/skeleton";
|
|
11
|
+
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "#components/tooltip";
|
|
12
|
+
import { useMediaQuery } from "#hooks/use-media-query";
|
|
13
|
+
import { cn } from "#lib/utils";
|
|
14
|
+
import { sidebarMenuButtonVariants } from "#variants/sidebar";
|
|
15
15
|
const SIDEBAR_COOKIE_NAME = "sidebar_state";
|
|
16
16
|
const SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7;
|
|
17
17
|
const SIDEBAR_WIDTH = "16rem";
|
|
18
18
|
const SIDEBAR_WIDTH_MOBILE = "18rem";
|
|
19
19
|
const SIDEBAR_WIDTH_ICON = "3.0625rem";
|
|
20
|
-
const
|
|
20
|
+
const SIDEBAR_SHORTCUT_KEY = "b";
|
|
21
|
+
// The preset's `--breakpoint-sidebar` default, for a page that has not loaded the preset.
|
|
22
|
+
const SIDEBAR_BREAKPOINT_FALLBACK = "48rem";
|
|
21
23
|
// ── Context: SidebarProvider ─────────────────────────────────────────────────────────────────────────────────────────
|
|
22
24
|
const SIDEBAR_PROVIDER_NAME = "SidebarProvider";
|
|
23
25
|
const [SidebarContextProvider, useSidebarContext] = Context.createContext(SIDEBAR_PROVIDER_NAME);
|
|
@@ -31,8 +33,8 @@ const useSidebar = useSidebarContext;
|
|
|
31
33
|
/**
|
|
32
34
|
* @since 0.3.16-canary.0
|
|
33
35
|
*/
|
|
34
|
-
function SidebarProvider({ children, className, defaultOpen = true, onOpenChange: setOpenProperty, open: openProperty, style, ...props }) {
|
|
35
|
-
const isMobile =
|
|
36
|
+
function SidebarProvider({ children, className, defaultOpen = true, onOpenChange: setOpenProperty, open: openProperty, shortcutKey = SIDEBAR_SHORTCUT_KEY, style, ...props }) {
|
|
37
|
+
const isMobile = useIsBelowSidebarBreakpoint();
|
|
36
38
|
const [openMobile, setOpenMobile] = useState(false);
|
|
37
39
|
// This is the internal state of the sidebar.
|
|
38
40
|
// We use openProp and setOpenProp for control from outside the component.
|
|
@@ -58,19 +60,24 @@ function SidebarProvider({ children, className, defaultOpen = true, onOpenChange
|
|
|
58
60
|
setOpen((currentValue) => !currentValue);
|
|
59
61
|
}
|
|
60
62
|
}, [isMobile, setOpen]);
|
|
63
|
+
// Reads the latest state through an Effect Event, so the listener stays registered across toggles and, with several
|
|
64
|
+
// providers mounted, the first one keeps the key while the rest see it already handled.
|
|
65
|
+
const onShortcutKeyDown = useEffectEvent((event) => {
|
|
66
|
+
if (shortcutKey !== false && isSidebarShortcut(event, shortcutKey)) {
|
|
67
|
+
event.preventDefault();
|
|
68
|
+
toggleSidebar();
|
|
69
|
+
}
|
|
70
|
+
});
|
|
61
71
|
// Adds a keyboard shortcut to toggle the sidebar.
|
|
62
72
|
useEffect(() => {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
window.addEventListener("keydown", handleKeyDown);
|
|
73
|
+
if (shortcutKey === false) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
window.addEventListener("keydown", onShortcutKeyDown);
|
|
70
77
|
return () => {
|
|
71
|
-
window.removeEventListener("keydown",
|
|
78
|
+
window.removeEventListener("keydown", onShortcutKeyDown);
|
|
72
79
|
};
|
|
73
|
-
}, [
|
|
80
|
+
}, [shortcutKey]);
|
|
74
81
|
// We add a state so that we can do data-state="expanded" or "collapsed".
|
|
75
82
|
// This makes it easier to style the sidebar with Tailwind classes.
|
|
76
83
|
const state = open ? "expanded" : "collapsed";
|
|
@@ -85,19 +92,19 @@ const SIDEBAR_NAME = "Sidebar";
|
|
|
85
92
|
/**
|
|
86
93
|
* @since 0.3.16-canary.0
|
|
87
94
|
*/
|
|
88
|
-
function Sidebar({ children, className, collapsible = "offcanvas", side = "left", variant = "sidebar", ...props }) {
|
|
95
|
+
function Sidebar({ children, className, collapsible = "offcanvas", mobileTitle = "Sidebar", side = "left", variant = "sidebar", ...props }) {
|
|
89
96
|
const { isMobile, openMobile, setOpenMobile, state } = useSidebar(SIDEBAR_NAME);
|
|
90
97
|
if (collapsible === "none") {
|
|
91
98
|
return (_jsx("div", { className: cn("flex h-full w-(--sidebar-width) flex-col bg-sidebar text-sidebar-foreground", className), "data-slot": "sidebar", ...props, children: children }));
|
|
92
99
|
}
|
|
93
100
|
if (isMobile) {
|
|
94
|
-
return (_jsx(Sheet, { open: openMobile, onOpenChange: setOpenMobile, ...props, children: _jsxs(SheetContent, { className: "w-(--sidebar-width) bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden", "data-mobile": "true", "data-sidebar": "sidebar", "data-slot": "sidebar", side: side, style: {
|
|
101
|
+
return (_jsx(Sheet, { open: openMobile, onOpenChange: setOpenMobile, ...props, children: _jsxs(SheetContent, { "aria-describedby": undefined, className: "w-(--sidebar-width) bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden", "data-mobile": "true", "data-sidebar": "sidebar", "data-slot": "sidebar", side: side, style: {
|
|
95
102
|
"--sidebar-width": SIDEBAR_WIDTH_MOBILE,
|
|
96
|
-
}, children: [
|
|
103
|
+
}, children: [_jsx(SheetHeader, { className: "sr-only", children: _jsx(SheetTitle, { children: mobileTitle }) }), _jsx("div", { className: "flex h-full w-full flex-col", children: children })] }) }));
|
|
97
104
|
}
|
|
98
|
-
return (_jsxs("div", { className: cn("group peer hidden text-sidebar-foreground
|
|
105
|
+
return (_jsxs("div", { className: cn("group peer hidden text-sidebar-foreground sidebar:block", className), "data-collapsible": state === "collapsed" ? collapsible : "", "data-side": side, "data-slot": "sidebar", "data-state": state, "data-variant": variant, children: [_jsx("div", { className: cn("relative w-(--sidebar-width) bg-transparent transition-[width] duration-200 ease-gentle group-data-[collapsible=offcanvas]:w-0 group-data-side-right:rotate-180", variant === "floating" || variant === "inset"
|
|
99
106
|
? "group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]"
|
|
100
|
-
: "group-data-[collapsible=icon]:w-(--sidebar-width-icon)"), "data-slot": "sidebar-gap" }), _jsx("div", { className: cn("fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-gentle
|
|
107
|
+
: "group-data-[collapsible=icon]:w-(--sidebar-width-icon)"), "data-slot": "sidebar-gap" }), _jsx("div", { className: cn("fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-gentle sidebar:flex data-side-right:right-0 data-side-right:group-data-[collapsible=offcanvas]:-right-(--sidebar-width) data-side-left:left-0 data-side-left:group-data-[collapsible=offcanvas]:-left-(--sidebar-width)", variant === "floating" || variant === "inset"
|
|
101
108
|
? "p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]"
|
|
102
109
|
: "group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-side-right:border-l group-data-side-left:border-r", className), "data-side": side, "data-slot": "sidebar-container", ...props, children: _jsx("div", { className: "flex size-full flex-col bg-sidebar group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:shadow-sm group-data-[variant=floating]:ring-1 group-data-[variant=floating]:ring-sidebar-border", "data-sidebar": "sidebar", "data-slot": "sidebar-inner", children: children }) })] }));
|
|
103
110
|
}
|
|
@@ -120,13 +127,13 @@ const SIDEBAR_RAIL_NAME = "SidebarRail";
|
|
|
120
127
|
*/
|
|
121
128
|
function SidebarRail({ className, ...props }) {
|
|
122
129
|
const { toggleSidebar } = useSidebar(SIDEBAR_RAIL_NAME);
|
|
123
|
-
return (_jsx("button", { className: cn("absolute inset-y-0 z-20 hidden w-4 transition-all ease-gentle group-data-[collapsible=offcanvas]:translate-x-0 group-data-side-right:left-0 group-data-side-left:-right-4 after:absolute after:inset-y-0 after:inset-s-1/2 after:w-0.5 group-data-[collapsible=offcanvas]:after:start-full hover:group-data-[collapsible=offcanvas]:bg-sidebar hover:after:bg-sidebar-border in-data-side-right:cursor-e-resize in-data-side-left:cursor-w-resize
|
|
130
|
+
return (_jsx("button", { className: cn("absolute inset-y-0 z-20 hidden w-4 transition-all ease-gentle group-data-[collapsible=offcanvas]:translate-x-0 group-data-side-right:left-0 group-data-side-left:-right-4 after:absolute after:inset-y-0 after:inset-s-1/2 after:w-0.5 group-data-[collapsible=offcanvas]:after:start-full hover:group-data-[collapsible=offcanvas]:bg-sidebar hover:after:bg-sidebar-border in-data-side-right:cursor-e-resize in-data-side-left:cursor-w-resize sidebar:flex ltr:-translate-x-1/2 rtl:-translate-x-1/2 rtl:group-data-[collapsible=offcanvas]:translate-x-0 rtl:in-data-side-right:cursor-w-resize rtl:in-data-side-left:cursor-e-resize [[data-side=left][data-collapsible=offcanvas]_&]:-right-2 [[data-side=left][data-state=collapsed]_&]:cursor-e-resize rtl:[[data-side=left][data-state=collapsed]_&]:cursor-w-resize [[data-side=right][data-collapsible=offcanvas]_&]:-left-2 [[data-side=right][data-state=collapsed]_&]:cursor-w-resize rtl:[[data-side=right][data-state=collapsed]_&]:cursor-e-resize", className), "data-sidebar": "rail", "data-slot": "sidebar-rail", title: "Toggle Sidebar", type: "button", onClick: toggleSidebar, ...props }));
|
|
124
131
|
}
|
|
125
132
|
/**
|
|
126
133
|
* @since 0.3.16-canary.0
|
|
127
134
|
*/
|
|
128
135
|
function SidebarInset({ className, ...props }) {
|
|
129
|
-
return (_jsx("main", { className: cn("relative flex w-full flex-1 flex-col bg-background
|
|
136
|
+
return (_jsx("main", { className: cn("relative flex w-full flex-1 flex-col bg-background sidebar:peer-data-[variant=inset]:m-2 sidebar:peer-data-[variant=inset]:ms-0 sidebar:peer-data-[variant=inset]:rounded-xl sidebar:peer-data-[variant=inset]:shadow-sm sidebar:peer-data-[variant=inset]:peer-data-collapsed:ms-2", className), "data-slot": "sidebar-inset", ...props }));
|
|
130
137
|
}
|
|
131
138
|
/**
|
|
132
139
|
* @since 0.3.16-canary.0
|
|
@@ -176,7 +183,7 @@ function SidebarGroupLabel({ asChild = false, className, ...props }) {
|
|
|
176
183
|
*/
|
|
177
184
|
function SidebarGroupAction({ asChild = false, className, ...props }) {
|
|
178
185
|
const Component = asChild ? Slot.Root : "button";
|
|
179
|
-
return (_jsx(Component, { className: cn("absolute inset-e-3 top-3.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground ring-sidebar-ring outline-hidden transition-transform group-data-[collapsible=icon]:hidden after:absolute after:-inset-2 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2
|
|
186
|
+
return (_jsx(Component, { className: cn("absolute inset-e-3 top-3.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground ring-sidebar-ring outline-hidden transition-transform group-data-[collapsible=icon]:hidden after:absolute after:-inset-2 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 sidebar:after:hidden [&>svg]:size-4 [&>svg]:shrink-0", className), "data-sidebar": "group-action", "data-slot": "sidebar-group-action", ...props }));
|
|
180
187
|
}
|
|
181
188
|
/**
|
|
182
189
|
* @since 0.3.16-canary.0
|
|
@@ -220,8 +227,8 @@ function SidebarMenuButton({ asChild = false, className, isActive = false, size
|
|
|
220
227
|
*/
|
|
221
228
|
function SidebarMenuAction({ asChild = false, className, showOnHover = false, ...props }) {
|
|
222
229
|
const Component = asChild ? Slot.Root : "button";
|
|
223
|
-
return (_jsx(Component, { className: cn("absolute inset-e-1 top-1.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground ring-sidebar-ring outline-hidden transition-transform group-data-[collapsible=icon]:hidden peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[size=default]/menu-button:top-1.5 peer-data-[size=lg]/menu-button:top-2.5 peer-data-[size=sm]/menu-button:top-1 after:absolute after:-inset-2 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2
|
|
224
|
-
"group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 peer-data-active/menu-button:text-sidebar-accent-foreground aria-expanded:opacity-100
|
|
230
|
+
return (_jsx(Component, { className: cn("absolute inset-e-1 top-1.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground ring-sidebar-ring outline-hidden transition-transform group-data-[collapsible=icon]:hidden peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[size=default]/menu-button:top-1.5 peer-data-[size=lg]/menu-button:top-2.5 peer-data-[size=sm]/menu-button:top-1 after:absolute after:-inset-2 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 sidebar:after:hidden [&>svg]:size-4 [&>svg]:shrink-0", showOnHover &&
|
|
231
|
+
"group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 peer-data-active/menu-button:text-sidebar-accent-foreground aria-expanded:opacity-100 sidebar:opacity-0", className), "data-sidebar": "menu-action", "data-slot": "sidebar-menu-action", ...props }));
|
|
225
232
|
}
|
|
226
233
|
/**
|
|
227
234
|
* @since 0.3.16-canary.0
|
|
@@ -263,5 +270,32 @@ function SidebarMenuSubButton({ asChild = false, className, isActive = false, si
|
|
|
263
270
|
const Component = asChild ? Slot.Root : "a";
|
|
264
271
|
return (_jsx(Component, { className: cn("flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground ring-sidebar-ring outline-hidden group-data-[collapsible=icon]:hidden hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[size=md]:text-sm data-[size=sm]:text-xs rtl:translate-x-px data-active:bg-sidebar-accent data-active:text-sidebar-accent-foreground [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground", className), "data-active": isActive, "data-sidebar": "menu-sub-button", "data-size": size, "data-slot": "sidebar-menu-sub-button", ...props }));
|
|
265
272
|
}
|
|
273
|
+
// ── Helpers ──────────────────────────────────────────────────────────────────────────────────────────────────────────
|
|
274
|
+
// The sheet takes over below the preset's `sidebar:` breakpoint, so JS matches the value that CSS resolved.
|
|
275
|
+
function useIsBelowSidebarBreakpoint() {
|
|
276
|
+
const [breakpoint] = useState(readSidebarBreakpoint);
|
|
277
|
+
return useMediaQuery(`(width < ${breakpoint})`);
|
|
278
|
+
}
|
|
279
|
+
function readSidebarBreakpoint() {
|
|
280
|
+
if (typeof document === "undefined") {
|
|
281
|
+
return SIDEBAR_BREAKPOINT_FALLBACK;
|
|
282
|
+
}
|
|
283
|
+
const breakpoint = getComputedStyle(document.documentElement).getPropertyValue("--sidebar-breakpoint").trim();
|
|
284
|
+
return breakpoint === "" ? SIDEBAR_BREAKPOINT_FALLBACK : breakpoint;
|
|
285
|
+
}
|
|
286
|
+
// Leaves the key to a handler that already took it, to an IME mid-composition, and to fields where it edits text.
|
|
287
|
+
function isSidebarShortcut(event, shortcutKey) {
|
|
288
|
+
if (event.defaultPrevented ||
|
|
289
|
+
event.isComposing ||
|
|
290
|
+
event.repeat ||
|
|
291
|
+
event.altKey ||
|
|
292
|
+
event.shiftKey ||
|
|
293
|
+
!(event.metaKey || event.ctrlKey) ||
|
|
294
|
+
event.key.toLowerCase() !== shortcutKey.toLowerCase()) {
|
|
295
|
+
return false;
|
|
296
|
+
}
|
|
297
|
+
const target = event.composedPath()[0];
|
|
298
|
+
return !(target instanceof HTMLElement && (target.isContentEditable || target.matches("input, select, textarea")));
|
|
299
|
+
}
|
|
266
300
|
// ── Exports ──────────────────────────────────────────────────────────────────────────────────────────────────────────
|
|
267
301
|
export { Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, useSidebar, };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import * as VisuallyHidden from "radix-ui/visually-hidden";
|
|
3
|
-
import { cn } from "
|
|
3
|
+
import { cn } from "#lib/utils";
|
|
4
4
|
// ── Component: Spinner ───────────────────────────────────────────────────────────────────────────────────────────────
|
|
5
5
|
const SPINNER_COUNT = 8;
|
|
6
6
|
/**
|
package/dist/components/table.js
CHANGED
package/dist/components/tabs.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import * as TabsPrimitive from "radix-ui/tabs";
|
|
3
|
-
import { cn } from "
|
|
4
|
-
import { tabsListVariants } from "
|
|
3
|
+
import { cn } from "#lib/utils";
|
|
4
|
+
import { tabsListVariants } from "#variants/tabs";
|
|
5
5
|
/**
|
|
6
6
|
* @since 0.3.16-canary.0
|
|
7
7
|
*/
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Context } from "radix-ui/internal";
|
|
2
2
|
import * as ToggleGroupPrimitive from "radix-ui/toggle-group";
|
|
3
3
|
import type { ComponentProps, JSX } from "react";
|
|
4
|
-
import type { VariantProps } from "
|
|
5
|
-
import { toggleVariants } from "
|
|
4
|
+
import type { VariantProps } from "#lib/utils";
|
|
5
|
+
import { toggleVariants } from "#variants/toggle";
|
|
6
6
|
type ScopedProps<P> = P & {
|
|
7
7
|
__scopeToggleGroup?: Context.Scope;
|
|
8
8
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Context } from "radix-ui/internal";
|
|
3
3
|
import * as ToggleGroupPrimitive from "radix-ui/toggle-group";
|
|
4
|
-
import { cn } from "
|
|
5
|
-
import { toggleVariants } from "
|
|
4
|
+
import { cn } from "#lib/utils";
|
|
5
|
+
import { toggleVariants } from "#variants/toggle";
|
|
6
6
|
// ── Context: ToggleGroup ─────────────────────────────────────────────────────────────────────────────────────────────
|
|
7
7
|
const TOGGLE_GROUP_NAME = "ToggleGroup";
|
|
8
8
|
const [createToggleGroupContext] = Context.createContextScope(TOGGLE_GROUP_NAME, [
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Subscribes to a CSS media query and returns whether it matches.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* Reports `false` during SSR and hydration, so the first client render matches the server markup, then the live
|
|
5
|
+
* match state, updating whenever the query flips.
|
|
6
6
|
*
|
|
7
7
|
* @param query - A valid media query string (e.g., "(max-width: 768px)").
|
|
8
8
|
* @returns true when the media query currently matches; otherwise false.
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useCallback, useSyncExternalStore } from "react";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Subscribes to a CSS media query and returns whether it matches.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
5
|
+
* Reports `false` during SSR and hydration, so the first client render matches the server markup, then the live
|
|
6
|
+
* match state, updating whenever the query flips.
|
|
7
7
|
*
|
|
8
8
|
* @param query - A valid media query string (e.g., "(max-width: 768px)").
|
|
9
9
|
* @returns true when the media query currently matches; otherwise false.
|
|
@@ -16,39 +16,22 @@ import { useEffect, useState } from "react";
|
|
|
16
16
|
* @since 0.3.16-canary.0
|
|
17
17
|
*/
|
|
18
18
|
export function useMediaQuery(query) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
*/
|
|
23
|
-
const [matches, setMatches] = useState(() => {
|
|
24
|
-
// Ensure initial state matches current media query status
|
|
25
|
-
if (typeof window !== "undefined" && typeof window.matchMedia === "function") {
|
|
26
|
-
return window.matchMedia(query).matches;
|
|
19
|
+
const subscribe = useCallback((onChange) => {
|
|
20
|
+
if (!canMatchMedia()) {
|
|
21
|
+
return () => { };
|
|
27
22
|
}
|
|
28
|
-
return false;
|
|
29
|
-
});
|
|
30
|
-
useEffect(() => {
|
|
31
|
-
// Only run in a browser environment where matchMedia is available
|
|
32
|
-
if (typeof window === "undefined") {
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* MediaQueryList to evaluate and observe the provided query.
|
|
37
|
-
*/
|
|
38
23
|
const mediaQueryList = window.matchMedia(query);
|
|
39
|
-
/**
|
|
40
|
-
* Update state when the media query status changes.
|
|
41
|
-
*/
|
|
42
|
-
const onChange = (event) => {
|
|
43
|
-
setMatches(event.matches);
|
|
44
|
-
};
|
|
45
24
|
mediaQueryList.addEventListener("change", onChange);
|
|
46
|
-
/**
|
|
47
|
-
* Removes the event listener on unmount or when the query changes.
|
|
48
|
-
*/
|
|
49
25
|
return () => {
|
|
50
26
|
mediaQueryList.removeEventListener("change", onChange);
|
|
51
27
|
};
|
|
52
28
|
}, [query]);
|
|
53
|
-
|
|
29
|
+
const getSnapshot = useCallback(() => canMatchMedia() && window.matchMedia(query).matches, [query]);
|
|
30
|
+
return useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
|
|
31
|
+
}
|
|
32
|
+
function getServerSnapshot() {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
function canMatchMedia() {
|
|
36
|
+
return typeof window !== "undefined" && typeof window.matchMedia === "function";
|
|
54
37
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { MessageScrollerRefs } from "
|
|
2
|
-
import type { MessageScrollerScrollOptions } from "
|
|
1
|
+
import type { MessageScrollerRefs } from "#hooks/use-message-scroller-refs";
|
|
2
|
+
import type { MessageScrollerScrollOptions } from "#lib/message-scroller/types";
|
|
3
3
|
/**
|
|
4
4
|
* Imperative scroll primitives, split from the controller so the move mechanics
|
|
5
5
|
* live apart from the policy that decides when to run them. Each command resolves
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// Callbacks read from stable refs; omitting them from deps is intentional and keeps identities stable.
|
|
2
2
|
/* oxlint-disable react-hooks/exhaustive-deps */
|
|
3
3
|
import { useCallback } from "react";
|
|
4
|
-
import { getElementScrollTop, getElementViewportTop, getMaxScrollTop, getTailSpacerHeight, } from "
|
|
5
|
-
import { AUTOSCROLLING_CLEAR_DELAY, SCROLL_POSITION_EPSILON } from "
|
|
4
|
+
import { getElementScrollTop, getElementViewportTop, getMaxScrollTop, getTailSpacerHeight, } from "#lib/message-scroller/geometry";
|
|
5
|
+
import { AUTOSCROLLING_CLEAR_DELAY, SCROLL_POSITION_EPSILON } from "#lib/message-scroller/types";
|
|
6
6
|
/**
|
|
7
7
|
* Imperative scroll primitives, split from the controller so the move mechanics
|
|
8
8
|
* live apart from the policy that decides when to run them. Each command resolves
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { MessageScrollerRefs } from "
|
|
2
|
-
import type { MessageScrollerContextValue, MessageScrollerProviderProps, MessageScrollerRegisterMessage } from "
|
|
1
|
+
import type { MessageScrollerRefs } from "#hooks/use-message-scroller-refs";
|
|
2
|
+
import type { MessageScrollerContextValue, MessageScrollerProviderProps, MessageScrollerRegisterMessage } from "#lib/message-scroller/types";
|
|
3
3
|
/**
|
|
4
4
|
* Orchestrator hook. Decides when to scroll and delegates the moves to
|
|
5
5
|
* useMessageScrollerCommands; state and visibility commits are coalesced on a
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// Callbacks read from stable refs; omitting them from deps is intentional and keeps identities stable.
|
|
2
2
|
/* oxlint-disable react-hooks/exhaustive-deps */
|
|
3
3
|
import { useCallback, useEffect, useLayoutEffect, useMemo, useRef } from "react";
|
|
4
|
-
import { useMessageScrollerCommands } from "
|
|
5
|
-
import { useMessageScrollerRefs } from "
|
|
6
|
-
import { getContentBottom, getElementTop, getElementViewportTop, getFirstVisibleMessageItem, getFlexGap, getLastScrollAnchor, getMessageScrollerItems, getMessageScrollerScrollable, getMessageScrollerVisibilityState, getNewScrollAnchor, getUnanchoredScrollAnchor, hasMultipleNewScrollAnchors, } from "
|
|
7
|
-
import { DEFAULT_SCROLL_EDGE_THRESHOLD, DEFAULT_SCROLL_MARGIN, DEFAULT_SCROLL_PREVIOUS_ITEM_PEEK, EMPTY_MESSAGE_SCROLLER_VISIBILITY_STATE, SCROLL_POSITION_EPSILON, } from "
|
|
4
|
+
import { useMessageScrollerCommands } from "#hooks/use-message-scroller-commands";
|
|
5
|
+
import { useMessageScrollerRefs } from "#hooks/use-message-scroller-refs";
|
|
6
|
+
import { getContentBottom, getElementTop, getElementViewportTop, getFirstVisibleMessageItem, getFlexGap, getLastScrollAnchor, getMessageScrollerItems, getMessageScrollerScrollable, getMessageScrollerVisibilityState, getNewScrollAnchor, getUnanchoredScrollAnchor, hasMultipleNewScrollAnchors, } from "#lib/message-scroller/geometry";
|
|
7
|
+
import { DEFAULT_SCROLL_EDGE_THRESHOLD, DEFAULT_SCROLL_MARGIN, DEFAULT_SCROLL_PREVIOUS_ITEM_PEEK, EMPTY_MESSAGE_SCROLLER_VISIBILITY_STATE, SCROLL_POSITION_EPSILON, } from "#lib/message-scroller/types";
|
|
8
8
|
// Builds a ref callback that stores the node and runs onMount once it attaches.
|
|
9
9
|
function useElementRef(elementRef, onMount) {
|
|
10
10
|
return useCallback((element) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { RefObject } from "react";
|
|
2
|
-
import type { MessageScrollerMode, MessageScrollerScrollable, MessageScrollerScrollOptions, MessageScrollerStore, MessageScrollerVisibilityStore } from "
|
|
2
|
+
import type { MessageScrollerMode, MessageScrollerScrollable, MessageScrollerScrollOptions, MessageScrollerStore, MessageScrollerVisibilityStore } from "#lib/message-scroller/types";
|
|
3
3
|
/**
|
|
4
4
|
* Shared mutable ref bag for one MessageScroller, closed over by both the
|
|
5
5
|
* controller and the commands so writes are visible across them without prop
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useRef, useState } from "react";
|
|
2
|
-
import { useLatest } from "
|
|
3
|
-
import { areScrollStatesEqual, createMessageScrollerStore, createMessageScrollerVisibilityStore, } from "
|
|
4
|
-
import { EMPTY_MESSAGE_SCROLLER_SCROLLABLE } from "
|
|
2
|
+
import { useLatest } from "#hooks/use-latest";
|
|
3
|
+
import { areScrollStatesEqual, createMessageScrollerStore, createMessageScrollerVisibilityStore, } from "#lib/message-scroller/stores";
|
|
4
|
+
import { EMPTY_MESSAGE_SCROLLER_SCROLLABLE } from "#lib/message-scroller/types";
|
|
5
5
|
/**
|
|
6
6
|
* Builds the per-instance ref bag: the two external stores constructed once, and
|
|
7
7
|
* the latest prop values mirrored onto refs at commit so callbacks stay stable.
|