@codefast/ui 0.5.0-canary.1 → 0.5.0-canary.3
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 +39 -0
- package/dist/components/attachment.d.mts +136 -0
- package/dist/components/attachment.mjs +112 -0
- package/dist/components/avatar.mjs +1 -1
- package/dist/components/bubble.d.mts +67 -0
- package/dist/components/bubble.mjs +58 -0
- package/dist/components/card.mjs +2 -2
- package/dist/components/carousel.mjs +12 -3
- package/dist/components/chart.mjs +2 -1
- package/dist/components/empty.mjs +1 -1
- package/dist/components/form.mjs +2 -1
- package/dist/components/marker.d.mts +49 -0
- package/dist/components/marker.mjs +42 -0
- package/dist/components/message-scroller.d.mts +89 -0
- package/dist/components/message-scroller.mjs +77 -0
- package/dist/components/message.d.mts +86 -0
- package/dist/components/message.mjs +66 -0
- package/dist/components/sidebar.mjs +6 -3
- package/dist/hooks/use-animated-value.mjs +3 -1
- package/dist/hooks/use-message-scroller-commands.d.mts +39 -0
- package/dist/hooks/use-message-scroller-commands.mjs +165 -0
- package/dist/hooks/use-message-scroller-controller.d.mts +19 -0
- package/dist/hooks/use-message-scroller-controller.mjs +382 -0
- package/dist/hooks/use-message-scroller-refs.d.mts +60 -0
- package/dist/hooks/use-message-scroller-refs.mjs +77 -0
- package/dist/hooks/use-pagination.mjs +18 -12
- package/dist/index.d.mts +11 -1
- package/dist/index.mjs +11 -2
- package/dist/lib/message-scroller/geometry.d.mts +136 -0
- package/dist/lib/message-scroller/geometry.mjs +199 -0
- package/dist/lib/message-scroller/stores.d.mts +21 -0
- package/dist/lib/message-scroller/stores.mjs +52 -0
- package/dist/lib/message-scroller/types.d.mts +171 -0
- package/dist/lib/message-scroller/types.mjs +53 -0
- package/dist/lib/message-scroller/utils.d.mts +7 -0
- package/dist/lib/message-scroller/utils.mjs +12 -0
- package/dist/lib/use-render.d.mts +43 -0
- package/dist/lib/use-render.mjs +84 -0
- package/dist/primitives/checkbox-group.mjs +20 -10
- package/dist/primitives/message-scroller.d.mts +88 -0
- package/dist/primitives/message-scroller.mjs +240 -0
- package/dist/variants/attachment.d.mts +42 -0
- package/dist/variants/attachment.mjs +42 -0
- package/dist/variants/bubble.d.mts +45 -0
- package/dist/variants/bubble.mjs +45 -0
- package/dist/variants/marker.d.mts +21 -0
- package/dist/variants/marker.mjs +18 -0
- package/package.json +57 -11
- package/src/components/attachment.tsx +284 -0
- package/src/components/avatar.tsx +1 -1
- package/src/components/bubble.tsx +116 -0
- package/src/components/card.tsx +2 -2
- package/src/components/carousel.tsx +12 -3
- package/src/components/empty.tsx +1 -1
- package/src/components/marker.tsx +94 -0
- package/src/components/message-scroller.tsx +213 -0
- package/src/components/message.tsx +173 -0
- package/src/components/sidebar.tsx +11 -4
- package/src/css/foundation/tokens.css +6 -18
- package/src/css/foundation/utilities.css +451 -0
- package/src/css/preset.css +2 -1
- package/src/hooks/use-message-scroller-commands.ts +312 -0
- package/src/hooks/use-message-scroller-controller.ts +651 -0
- package/src/hooks/use-message-scroller-refs.ts +168 -0
- package/src/index.ts +72 -0
- package/src/lib/message-scroller/geometry.ts +398 -0
- package/src/lib/message-scroller/stores.ts +89 -0
- package/src/lib/message-scroller/types.ts +310 -0
- package/src/lib/message-scroller/utils.ts +15 -0
- package/src/lib/use-render.ts +202 -0
- package/src/primitives/message-scroller.tsx +399 -0
- package/src/variants/attachment.ts +73 -0
- package/src/variants/bubble.ts +81 -0
- package/src/variants/marker.ts +38 -0
package/dist/index.mjs
CHANGED
|
@@ -5,6 +5,8 @@ import { buttonVariants } from "./variants/button.mjs";
|
|
|
5
5
|
import { Button } from "./components/button.mjs";
|
|
6
6
|
import { AlertDialog, AlertDialogAction, AlertDialogBody, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogMedia, AlertDialogTitle, AlertDialogTrigger } from "./components/alert-dialog.mjs";
|
|
7
7
|
import { AspectRatio } from "./components/aspect-ratio.mjs";
|
|
8
|
+
import { attachmentMediaVariants, attachmentVariants } from "./variants/attachment.mjs";
|
|
9
|
+
import { Attachment, AttachmentAction, AttachmentActions, AttachmentContent, AttachmentDescription, AttachmentGroup, AttachmentMedia, AttachmentTitle, AttachmentTrigger } from "./components/attachment.mjs";
|
|
8
10
|
import { Avatar, AvatarBadge, AvatarFallback, AvatarGroup, AvatarGroupCount, AvatarImage } from "./components/avatar.mjs";
|
|
9
11
|
import { badgeVariants } from "./variants/badge.mjs";
|
|
10
12
|
import { Badge } from "./components/badge.mjs";
|
|
@@ -13,8 +15,11 @@ import { Separator, SeparatorItem } from "./components/separator.mjs";
|
|
|
13
15
|
import { buttonGroupVariants } from "./variants/button-group.mjs";
|
|
14
16
|
import { ButtonGroup, ButtonGroupSeparator, ButtonGroupText } from "./components/button-group.mjs";
|
|
15
17
|
import { Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator } from "./components/breadcrumb.mjs";
|
|
18
|
+
import { bubbleReactionsVariants, bubbleVariants } from "./variants/bubble.mjs";
|
|
19
|
+
import { Bubble, BubbleContent, BubbleGroup, BubbleReactions } from "./components/bubble.mjs";
|
|
16
20
|
import { Calendar, CalendarDayButton } from "./components/calendar.mjs";
|
|
17
21
|
import { Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from "./components/card.mjs";
|
|
22
|
+
import { DirectionProvider, useDirection } from "./components/direction.mjs";
|
|
18
23
|
import { Carousel, CarouselContent, CarouselItem, CarouselNext, CarouselPrevious, createCarouselScope } from "./components/carousel.mjs";
|
|
19
24
|
import { ChartContainer, ChartLegend, ChartLegendContent, ChartStyle, ChartTooltip, ChartTooltipContent, createChartScope } from "./components/chart.mjs";
|
|
20
25
|
import { Checkbox } from "./components/checkbox.mjs";
|
|
@@ -29,7 +34,6 @@ import { inputGroupAddonVariants, inputGroupButtonVariants, inputGroupVariants }
|
|
|
29
34
|
import { InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupText, InputGroupTextarea } from "./components/input-group.mjs";
|
|
30
35
|
import { Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandLoading, CommandSeparator, CommandShortcut } from "./components/command.mjs";
|
|
31
36
|
import { ContextMenu, ContextMenuArrow, ContextMenuCheckboxItem, ContextMenuContent, ContextMenuGroup, ContextMenuItem, ContextMenuLabel, ContextMenuRadioGroup, ContextMenuRadioItem, ContextMenuSeparator, ContextMenuShortcut, ContextMenuSub, ContextMenuSubContent, ContextMenuSubTrigger, ContextMenuTrigger } from "./components/context-menu.mjs";
|
|
32
|
-
import { DirectionProvider, useDirection } from "./components/direction.mjs";
|
|
33
37
|
import { Drawer, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerTitle, DrawerTrigger } from "./components/drawer.mjs";
|
|
34
38
|
import { DropdownMenu, DropdownMenuArrow, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger } from "./components/dropdown-menu.mjs";
|
|
35
39
|
import { emptyMediaVariants } from "./variants/empty.mjs";
|
|
@@ -46,7 +50,12 @@ import { InputSearch } from "./components/input-search.mjs";
|
|
|
46
50
|
import { Kbd, KbdGroup } from "./components/kbd.mjs";
|
|
47
51
|
import { itemMediaVariants, itemVariants } from "./variants/item.mjs";
|
|
48
52
|
import { Item, ItemActions, ItemContent, ItemDescription, ItemFooter, ItemGroup, ItemHeader, ItemMedia, ItemSeparator, ItemTitle } from "./components/item.mjs";
|
|
53
|
+
import { markerVariants } from "./variants/marker.mjs";
|
|
54
|
+
import { Marker, MarkerContent, MarkerIcon } from "./components/marker.mjs";
|
|
49
55
|
import { Menubar, MenubarArrow, MenubarCheckboxItem, MenubarContent, MenubarGroup, MenubarItem, MenubarLabel, MenubarMenu, MenubarRadioGroup, MenubarRadioItem, MenubarSeparator, MenubarShortcut, MenubarSub, MenubarSubContent, MenubarSubTrigger, MenubarTrigger } from "./components/menubar.mjs";
|
|
56
|
+
import { Message, MessageAvatar, MessageContent, MessageFooter, MessageGroup, MessageHeader } from "./components/message.mjs";
|
|
57
|
+
import { useMessageScroller, useMessageScrollerScrollable, useMessageScrollerVisibility } from "./primitives/message-scroller.mjs";
|
|
58
|
+
import { MessageScroller, MessageScrollerButton, MessageScrollerContent, MessageScrollerItem, MessageScrollerProvider, MessageScrollerViewport } from "./components/message-scroller.mjs";
|
|
50
59
|
import { navigationMenuTriggerVariants } from "./variants/navigation-menu.mjs";
|
|
51
60
|
import { NavigationMenu, NavigationMenuContent, NavigationMenuIndicator, NavigationMenuItem, NavigationMenuLink, NavigationMenuList, NavigationMenuTrigger, NavigationMenuViewport } from "./components/navigation-menu.mjs";
|
|
52
61
|
import { NativeSelect, NativeSelectOptGroup, NativeSelectOption } from "./components/native-select.mjs";
|
|
@@ -83,4 +92,4 @@ import { ToggleGroup, ToggleGroupItem } from "./components/toggle-group.mjs";
|
|
|
83
92
|
import { useCopyToClipboard } from "./hooks/use-copy-to-clipboard.mjs";
|
|
84
93
|
import { useMutationObserver } from "./hooks/use-mutation-observer.mjs";
|
|
85
94
|
import { ELLIPSIS, usePagination } from "./hooks/use-pagination.mjs";
|
|
86
|
-
export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, Alert, AlertAction, AlertDescription, AlertDialog, AlertDialogAction, AlertDialogBody, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogMedia, AlertDialogTitle, AlertDialogTrigger, AlertTitle, AspectRatio, Avatar, AvatarBadge, AvatarFallback, AvatarGroup, AvatarGroupCount, AvatarImage, Badge, Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, Button, ButtonGroup, ButtonGroupSeparator, ButtonGroupText, Calendar, CalendarDayButton, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Carousel, CarouselContent, CarouselItem, CarouselNext, CarouselPrevious, ChartContainer, ChartLegend, ChartLegendContent, ChartStyle, ChartTooltip, ChartTooltipContent, Checkbox, CheckboxCards, CheckboxCardsItem, CheckboxGroup, CheckboxGroupItem, Collapsible, CollapsibleContent, CollapsibleTrigger, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandLoading, CommandSeparator, CommandShortcut, ContextMenu, ContextMenuArrow, ContextMenuCheckboxItem, ContextMenuContent, ContextMenuGroup, ContextMenuItem, ContextMenuLabel, ContextMenuRadioGroup, ContextMenuRadioItem, ContextMenuSeparator, ContextMenuShortcut, ContextMenuSub, ContextMenuSubContent, ContextMenuSubTrigger, ContextMenuTrigger, Dialog, DialogBody, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger, DirectionProvider, Drawer, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerTitle, DrawerTrigger, DropdownMenu, DropdownMenuArrow, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, ELLIPSIS, Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle, Field, FieldContent, FieldDescription, FieldError, FieldGroup, FieldLabel, FieldLegend, FieldSeparator, FieldSet, FieldTitle, Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, HoverCard, HoverCardArrow, HoverCardContent, HoverCardTrigger, Input, InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupText, InputGroupTextarea, InputNumber, InputOTP, InputOTPGroup, InputOTPSeparator, InputOTPSlot, InputPassword, InputSearch, Item, ItemActions, ItemContent, ItemDescription, ItemFooter, ItemGroup, ItemHeader, ItemMedia, ItemSeparator, ItemTitle, Kbd, KbdGroup, Label, Menubar, MenubarArrow, MenubarCheckboxItem, MenubarContent, MenubarGroup, MenubarItem, MenubarLabel, MenubarMenu, MenubarRadioGroup, MenubarRadioItem, MenubarSeparator, MenubarShortcut, MenubarSub, MenubarSubContent, MenubarSubTrigger, MenubarTrigger, NativeSelect, NativeSelectOptGroup, NativeSelectOption, NavigationMenu, NavigationMenuContent, NavigationMenuIndicator, NavigationMenuItem, NavigationMenuLink, NavigationMenuList, NavigationMenuTrigger, NavigationMenuViewport, Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious, Popover, PopoverAnchor, PopoverArrow, PopoverContent, PopoverDescription, PopoverHeader, PopoverTitle, PopoverTrigger, Progress, ProgressCircle, REGEXP_ONLY_CHARS, REGEXP_ONLY_DIGITS, REGEXP_ONLY_DIGITS_AND_CHARS, Radio, RadioCards, RadioCardsItem, RadioGroup, RadioGroupItem, ResizableGroup, ResizablePanel, ResizableSeparator, ScrollArea, ScrollAreaScrollbar, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, SeparatorItem, Sheet, SheetBody, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, SheetTrigger, Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, Skeleton, Slider, Spinner, Switch, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, Textarea, Toaster, Toggle, ToggleGroup, ToggleGroupItem, Tooltip, TooltipArrow, TooltipContent, TooltipProvider, TooltipTrigger, alertVariants, badgeVariants, buttonGroupVariants, buttonVariants, createCarouselScope, createChartScope, createFormFieldScope, emptyMediaVariants, fieldVariants, inputGroupAddonVariants, inputGroupButtonVariants, inputGroupVariants, itemMediaVariants, itemVariants, navigationMenuTriggerVariants, progressCircleVariants, scrollAreaScrollbarVariants, separatorVariants, sheetContentVariants, sidebarMenuButtonVariants, tabsListVariants, toast, toggleVariants, useAnimatedValue, useCopyToClipboard, useDirection, useIsMobile, useMediaQuery, useMutationObserver, usePagination, useSidebar, useSonner };
|
|
95
|
+
export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, Alert, AlertAction, AlertDescription, AlertDialog, AlertDialogAction, AlertDialogBody, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogMedia, AlertDialogTitle, AlertDialogTrigger, AlertTitle, AspectRatio, Attachment, AttachmentAction, AttachmentActions, AttachmentContent, AttachmentDescription, AttachmentGroup, AttachmentMedia, AttachmentTitle, AttachmentTrigger, Avatar, AvatarBadge, AvatarFallback, AvatarGroup, AvatarGroupCount, AvatarImage, Badge, Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, Bubble, BubbleContent, BubbleGroup, BubbleReactions, Button, ButtonGroup, ButtonGroupSeparator, ButtonGroupText, Calendar, CalendarDayButton, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Carousel, CarouselContent, CarouselItem, CarouselNext, CarouselPrevious, ChartContainer, ChartLegend, ChartLegendContent, ChartStyle, ChartTooltip, ChartTooltipContent, Checkbox, CheckboxCards, CheckboxCardsItem, CheckboxGroup, CheckboxGroupItem, Collapsible, CollapsibleContent, CollapsibleTrigger, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandLoading, CommandSeparator, CommandShortcut, ContextMenu, ContextMenuArrow, ContextMenuCheckboxItem, ContextMenuContent, ContextMenuGroup, ContextMenuItem, ContextMenuLabel, ContextMenuRadioGroup, ContextMenuRadioItem, ContextMenuSeparator, ContextMenuShortcut, ContextMenuSub, ContextMenuSubContent, ContextMenuSubTrigger, ContextMenuTrigger, Dialog, DialogBody, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger, DirectionProvider, Drawer, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerTitle, DrawerTrigger, DropdownMenu, DropdownMenuArrow, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, ELLIPSIS, Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle, Field, FieldContent, FieldDescription, FieldError, FieldGroup, FieldLabel, FieldLegend, FieldSeparator, FieldSet, FieldTitle, Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, HoverCard, HoverCardArrow, HoverCardContent, HoverCardTrigger, Input, InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupText, InputGroupTextarea, InputNumber, InputOTP, InputOTPGroup, InputOTPSeparator, InputOTPSlot, InputPassword, InputSearch, Item, ItemActions, ItemContent, ItemDescription, ItemFooter, ItemGroup, ItemHeader, ItemMedia, ItemSeparator, ItemTitle, Kbd, KbdGroup, Label, Marker, MarkerContent, MarkerIcon, Menubar, MenubarArrow, MenubarCheckboxItem, MenubarContent, MenubarGroup, MenubarItem, MenubarLabel, MenubarMenu, MenubarRadioGroup, MenubarRadioItem, MenubarSeparator, MenubarShortcut, MenubarSub, MenubarSubContent, MenubarSubTrigger, MenubarTrigger, Message, MessageAvatar, MessageContent, MessageFooter, MessageGroup, MessageHeader, MessageScroller, MessageScrollerButton, MessageScrollerContent, MessageScrollerItem, MessageScrollerProvider, MessageScrollerViewport, NativeSelect, NativeSelectOptGroup, NativeSelectOption, NavigationMenu, NavigationMenuContent, NavigationMenuIndicator, NavigationMenuItem, NavigationMenuLink, NavigationMenuList, NavigationMenuTrigger, NavigationMenuViewport, Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious, Popover, PopoverAnchor, PopoverArrow, PopoverContent, PopoverDescription, PopoverHeader, PopoverTitle, PopoverTrigger, Progress, ProgressCircle, REGEXP_ONLY_CHARS, REGEXP_ONLY_DIGITS, REGEXP_ONLY_DIGITS_AND_CHARS, Radio, RadioCards, RadioCardsItem, RadioGroup, RadioGroupItem, ResizableGroup, ResizablePanel, ResizableSeparator, ScrollArea, ScrollAreaScrollbar, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, SeparatorItem, Sheet, SheetBody, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, SheetTrigger, Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, Skeleton, Slider, Spinner, Switch, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, Textarea, Toaster, Toggle, ToggleGroup, ToggleGroupItem, Tooltip, TooltipArrow, TooltipContent, TooltipProvider, TooltipTrigger, alertVariants, attachmentMediaVariants, attachmentVariants, badgeVariants, bubbleReactionsVariants, bubbleVariants, buttonGroupVariants, buttonVariants, createCarouselScope, createChartScope, createFormFieldScope, emptyMediaVariants, fieldVariants, inputGroupAddonVariants, inputGroupButtonVariants, inputGroupVariants, itemMediaVariants, itemVariants, markerVariants, navigationMenuTriggerVariants, progressCircleVariants, scrollAreaScrollbarVariants, separatorVariants, sheetContentVariants, sidebarMenuButtonVariants, tabsListVariants, toast, toggleVariants, useAnimatedValue, useCopyToClipboard, useDirection, useIsMobile, useMediaQuery, useMessageScroller, useMessageScrollerScrollable, useMessageScrollerVisibility, useMutationObserver, usePagination, useSidebar, useSonner };
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { MessageScrollerScrollAlign, MessageScrollerScrollable, MessageScrollerVisibilityState } from "./types.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/lib/message-scroller/geometry.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* @since 0.5.0-canary.3
|
|
6
|
+
*/
|
|
7
|
+
declare function getMessageScrollerScrollable({
|
|
8
|
+
content,
|
|
9
|
+
scrollEdgeThreshold,
|
|
10
|
+
spacer,
|
|
11
|
+
viewport
|
|
12
|
+
}: {
|
|
13
|
+
content: HTMLElement | null;
|
|
14
|
+
scrollEdgeThreshold: number;
|
|
15
|
+
spacer: HTMLElement | null;
|
|
16
|
+
viewport: HTMLElement | null;
|
|
17
|
+
}): MessageScrollerScrollable;
|
|
18
|
+
/**
|
|
19
|
+
* @since 0.5.0-canary.3
|
|
20
|
+
*/
|
|
21
|
+
declare function getMessageScrollerVisibilityState({
|
|
22
|
+
content,
|
|
23
|
+
scrollMargin,
|
|
24
|
+
scrollPreviousItemPeek,
|
|
25
|
+
spacer,
|
|
26
|
+
viewport,
|
|
27
|
+
visibleMessageIds
|
|
28
|
+
}: {
|
|
29
|
+
content: HTMLElement | null;
|
|
30
|
+
scrollMargin: number;
|
|
31
|
+
scrollPreviousItemPeek: number;
|
|
32
|
+
spacer: HTMLElement | null;
|
|
33
|
+
viewport: HTMLElement | null;
|
|
34
|
+
visibleMessageIds: Set<string>;
|
|
35
|
+
}): MessageScrollerVisibilityState;
|
|
36
|
+
/**
|
|
37
|
+
* @since 0.5.0-canary.3
|
|
38
|
+
*/
|
|
39
|
+
declare function getMessageScrollerItems(content: HTMLElement, spacer: HTMLElement | null): HTMLElement[];
|
|
40
|
+
/**
|
|
41
|
+
* @since 0.5.0-canary.3
|
|
42
|
+
*/
|
|
43
|
+
declare function getNewScrollAnchor(items: Array<HTMLElement>, previousItemCount: number): HTMLElement | null;
|
|
44
|
+
/**
|
|
45
|
+
* @since 0.5.0-canary.3
|
|
46
|
+
*/
|
|
47
|
+
declare function getUnanchoredScrollAnchor(items: Array<HTMLElement>, handledAnchors: {
|
|
48
|
+
has(element: HTMLElement): boolean;
|
|
49
|
+
}): HTMLElement | null;
|
|
50
|
+
/**
|
|
51
|
+
* @since 0.5.0-canary.3
|
|
52
|
+
*/
|
|
53
|
+
declare function hasMultipleNewScrollAnchors(items: Array<HTMLElement>, previousItemCount: number): boolean;
|
|
54
|
+
/**
|
|
55
|
+
* @since 0.5.0-canary.3
|
|
56
|
+
*/
|
|
57
|
+
declare function getLastScrollAnchor(items: Array<HTMLElement>): HTMLElement | null;
|
|
58
|
+
/**
|
|
59
|
+
* @since 0.5.0-canary.3
|
|
60
|
+
*/
|
|
61
|
+
declare function getFirstVisibleMessageItem({
|
|
62
|
+
content,
|
|
63
|
+
spacer,
|
|
64
|
+
viewport
|
|
65
|
+
}: {
|
|
66
|
+
content: HTMLElement;
|
|
67
|
+
spacer: HTMLElement | null;
|
|
68
|
+
viewport: HTMLElement;
|
|
69
|
+
}): HTMLElement | null;
|
|
70
|
+
/**
|
|
71
|
+
* @since 0.5.0-canary.3
|
|
72
|
+
*/
|
|
73
|
+
declare function getElementScrollTop({
|
|
74
|
+
align,
|
|
75
|
+
element,
|
|
76
|
+
scrollMargin,
|
|
77
|
+
spacer,
|
|
78
|
+
viewport
|
|
79
|
+
}: {
|
|
80
|
+
align: MessageScrollerScrollAlign;
|
|
81
|
+
element: HTMLElement;
|
|
82
|
+
scrollMargin: number;
|
|
83
|
+
spacer: HTMLElement | null;
|
|
84
|
+
viewport: HTMLElement;
|
|
85
|
+
}): number;
|
|
86
|
+
/**
|
|
87
|
+
* @since 0.5.0-canary.3
|
|
88
|
+
*/
|
|
89
|
+
declare function getElementTop(element: HTMLElement, viewport: HTMLElement): number;
|
|
90
|
+
/**
|
|
91
|
+
* @since 0.5.0-canary.3
|
|
92
|
+
*/
|
|
93
|
+
declare function getElementViewportTop(element: HTMLElement, viewport: HTMLElement): number;
|
|
94
|
+
/**
|
|
95
|
+
* @since 0.5.0-canary.3
|
|
96
|
+
*/
|
|
97
|
+
declare function getTailSpacerHeight({
|
|
98
|
+
content,
|
|
99
|
+
scrollTop,
|
|
100
|
+
spacer,
|
|
101
|
+
viewport
|
|
102
|
+
}: {
|
|
103
|
+
content: HTMLElement;
|
|
104
|
+
scrollTop: number;
|
|
105
|
+
spacer: HTMLElement | null;
|
|
106
|
+
viewport: HTMLElement;
|
|
107
|
+
}): number;
|
|
108
|
+
/**
|
|
109
|
+
* @since 0.5.0-canary.3
|
|
110
|
+
*/
|
|
111
|
+
declare function getContentBottom({
|
|
112
|
+
content,
|
|
113
|
+
spacer,
|
|
114
|
+
viewport
|
|
115
|
+
}: {
|
|
116
|
+
content: HTMLElement;
|
|
117
|
+
spacer: HTMLElement | null;
|
|
118
|
+
viewport: HTMLElement;
|
|
119
|
+
}): number;
|
|
120
|
+
/**
|
|
121
|
+
* @since 0.5.0-canary.3
|
|
122
|
+
*/
|
|
123
|
+
declare function getMaxScrollTop(viewport: HTMLElement): number;
|
|
124
|
+
/**
|
|
125
|
+
* @since 0.5.0-canary.3
|
|
126
|
+
*/
|
|
127
|
+
declare function getContentBlockPadding(spacer: HTMLElement | null): {
|
|
128
|
+
end: number;
|
|
129
|
+
start: number;
|
|
130
|
+
};
|
|
131
|
+
/**
|
|
132
|
+
* @since 0.5.0-canary.3
|
|
133
|
+
*/
|
|
134
|
+
declare function getFlexGap(element: HTMLElement | null): number;
|
|
135
|
+
//#endregion
|
|
136
|
+
export { getContentBlockPadding, getContentBottom, getElementScrollTop, getElementTop, getElementViewportTop, getFirstVisibleMessageItem, getFlexGap, getLastScrollAnchor, getMaxScrollTop, getMessageScrollerItems, getMessageScrollerScrollable, getMessageScrollerVisibilityState, getNewScrollAnchor, getTailSpacerHeight, getUnanchoredScrollAnchor, hasMultipleNewScrollAnchors };
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import { EMPTY_MESSAGE_SCROLLER_SCROLLABLE, EMPTY_MESSAGE_SCROLLER_VISIBILITY_STATE } from "./types.mjs";
|
|
2
|
+
//#region src/lib/message-scroller/geometry.ts
|
|
3
|
+
/**
|
|
4
|
+
* @since 0.5.0-canary.3
|
|
5
|
+
*/
|
|
6
|
+
function getMessageScrollerScrollable({ content, scrollEdgeThreshold, spacer, viewport }) {
|
|
7
|
+
if (!viewport || !content) return EMPTY_MESSAGE_SCROLLER_SCROLLABLE;
|
|
8
|
+
const contentBottom = getContentBottom({
|
|
9
|
+
content,
|
|
10
|
+
spacer,
|
|
11
|
+
viewport
|
|
12
|
+
});
|
|
13
|
+
return {
|
|
14
|
+
start: viewport.scrollTop > scrollEdgeThreshold,
|
|
15
|
+
end: contentBottom - viewport.scrollTop - viewport.clientHeight > scrollEdgeThreshold
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* @since 0.5.0-canary.3
|
|
20
|
+
*/
|
|
21
|
+
function getMessageScrollerVisibilityState({ content, scrollMargin, scrollPreviousItemPeek, spacer, viewport, visibleMessageIds }) {
|
|
22
|
+
if (!content || !viewport) return EMPTY_MESSAGE_SCROLLER_VISIBILITY_STATE;
|
|
23
|
+
const viewportRect = viewport.getBoundingClientRect();
|
|
24
|
+
const lineTop = viewportRect.top + scrollMargin + scrollPreviousItemPeek;
|
|
25
|
+
const trackByLayout = typeof IntersectionObserver === "undefined";
|
|
26
|
+
const visible = [];
|
|
27
|
+
let currentAnchorId = null;
|
|
28
|
+
for (const item of getMessageScrollerItems(content, spacer)) {
|
|
29
|
+
const messageId = item.dataset.messageId;
|
|
30
|
+
if (!messageId) continue;
|
|
31
|
+
const isAnchor = item.dataset.scrollAnchor === "true";
|
|
32
|
+
const rect = isAnchor || trackByLayout ? item.getBoundingClientRect() : null;
|
|
33
|
+
if (trackByLayout && rect ? rect.bottom > lineTop && rect.top < viewportRect.bottom : visibleMessageIds.has(messageId)) visible.push(messageId);
|
|
34
|
+
if (isAnchor && rect && rect.top <= lineTop + .5) currentAnchorId = messageId;
|
|
35
|
+
}
|
|
36
|
+
if (visible.length === 0 && currentAnchorId === null) return EMPTY_MESSAGE_SCROLLER_VISIBILITY_STATE;
|
|
37
|
+
return {
|
|
38
|
+
currentAnchorId,
|
|
39
|
+
visibleMessageIds: visible
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* @since 0.5.0-canary.3
|
|
44
|
+
*/
|
|
45
|
+
function getMessageScrollerItems(content, spacer) {
|
|
46
|
+
return Array.from(content.children).filter((child) => child instanceof HTMLElement && child !== spacer);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* @since 0.5.0-canary.3
|
|
50
|
+
*/
|
|
51
|
+
function getNewScrollAnchor(items, previousItemCount) {
|
|
52
|
+
for (let index = previousItemCount; index < items.length; index++) {
|
|
53
|
+
const item = items[index];
|
|
54
|
+
if (item?.dataset.scrollAnchor === "true") return item;
|
|
55
|
+
}
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* @since 0.5.0-canary.3
|
|
60
|
+
*/
|
|
61
|
+
function getUnanchoredScrollAnchor(items, handledAnchors) {
|
|
62
|
+
for (const item of items) if (item.dataset.scrollAnchor === "true" && !handledAnchors.has(item)) return item;
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* @since 0.5.0-canary.3
|
|
67
|
+
*/
|
|
68
|
+
function hasMultipleNewScrollAnchors(items, previousItemCount) {
|
|
69
|
+
let count = 0;
|
|
70
|
+
for (let index = previousItemCount; index < items.length; index++) {
|
|
71
|
+
if (items[index]?.dataset.scrollAnchor !== "true") continue;
|
|
72
|
+
count += 1;
|
|
73
|
+
if (count > 1) return true;
|
|
74
|
+
}
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* @since 0.5.0-canary.3
|
|
79
|
+
*/
|
|
80
|
+
function getLastScrollAnchor(items) {
|
|
81
|
+
for (let index = items.length - 1; index >= 0; index--) {
|
|
82
|
+
const item = items[index];
|
|
83
|
+
if (item?.dataset.scrollAnchor === "true") return item;
|
|
84
|
+
}
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* @since 0.5.0-canary.3
|
|
89
|
+
*/
|
|
90
|
+
function getFirstVisibleMessageItem({ content, spacer, viewport }) {
|
|
91
|
+
const viewportRect = viewport.getBoundingClientRect();
|
|
92
|
+
for (const item of getMessageScrollerItems(content, spacer)) {
|
|
93
|
+
if (!item.dataset.messageId) continue;
|
|
94
|
+
const rect = item.getBoundingClientRect();
|
|
95
|
+
if (rect.bottom > viewportRect.top && rect.top < viewportRect.bottom) return item;
|
|
96
|
+
}
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* @since 0.5.0-canary.3
|
|
101
|
+
*/
|
|
102
|
+
function getElementScrollTop({ align, element, scrollMargin, spacer, viewport }) {
|
|
103
|
+
const elementTop = getElementTop(element, viewport);
|
|
104
|
+
const elementHeight = element.getBoundingClientRect().height;
|
|
105
|
+
const contentPadding = getContentBlockPadding(spacer);
|
|
106
|
+
if (align === "center") {
|
|
107
|
+
const insetHeight = Math.max(0, viewport.clientHeight - contentPadding.start - contentPadding.end);
|
|
108
|
+
return elementTop - contentPadding.start - (insetHeight - elementHeight) / 2 - scrollMargin;
|
|
109
|
+
}
|
|
110
|
+
if (align === "end") return elementTop - viewport.clientHeight + elementHeight + contentPadding.end + scrollMargin;
|
|
111
|
+
if (align === "nearest") {
|
|
112
|
+
const elementBottom = elementTop + elementHeight;
|
|
113
|
+
const viewportTop = viewport.scrollTop + contentPadding.start;
|
|
114
|
+
const viewportBottom = viewport.scrollTop + viewport.clientHeight - contentPadding.end;
|
|
115
|
+
if (elementTop >= viewportTop && elementBottom <= viewportBottom) return viewport.scrollTop;
|
|
116
|
+
if (elementTop < viewportTop) return elementTop - contentPadding.start - scrollMargin;
|
|
117
|
+
return elementBottom - viewport.clientHeight + contentPadding.end + scrollMargin;
|
|
118
|
+
}
|
|
119
|
+
return elementTop - contentPadding.start - scrollMargin;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* @since 0.5.0-canary.3
|
|
123
|
+
*/
|
|
124
|
+
function getElementTop(element, viewport) {
|
|
125
|
+
const elementRect = element.getBoundingClientRect();
|
|
126
|
+
const viewportRect = viewport.getBoundingClientRect();
|
|
127
|
+
return elementRect.top - viewportRect.top + viewport.scrollTop;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* @since 0.5.0-canary.3
|
|
131
|
+
*/
|
|
132
|
+
function getElementViewportTop(element, viewport) {
|
|
133
|
+
return element.getBoundingClientRect().top - viewport.getBoundingClientRect().top;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* @since 0.5.0-canary.3
|
|
137
|
+
*/
|
|
138
|
+
function getTailSpacerHeight({ content, scrollTop, spacer, viewport }) {
|
|
139
|
+
const contentBottom = getContentBottom({
|
|
140
|
+
content,
|
|
141
|
+
spacer,
|
|
142
|
+
viewport
|
|
143
|
+
});
|
|
144
|
+
return scrollTop + viewport.clientHeight - contentBottom;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* @since 0.5.0-canary.3
|
|
148
|
+
*/
|
|
149
|
+
function getContentBottom({ content, spacer, viewport }) {
|
|
150
|
+
const items = getMessageScrollerItems(content, spacer);
|
|
151
|
+
const padding = getBlockPadding(content);
|
|
152
|
+
const viewportRect = viewport.getBoundingClientRect();
|
|
153
|
+
const scrollTop = viewport.scrollTop;
|
|
154
|
+
let contentBottom = padding.start + padding.end;
|
|
155
|
+
for (const item of items) {
|
|
156
|
+
const rect = item.getBoundingClientRect();
|
|
157
|
+
contentBottom = Math.max(contentBottom, rect.bottom - viewportRect.top + scrollTop + padding.end);
|
|
158
|
+
}
|
|
159
|
+
return contentBottom;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* @since 0.5.0-canary.3
|
|
163
|
+
*/
|
|
164
|
+
function getMaxScrollTop(viewport) {
|
|
165
|
+
return Math.max(0, viewport.scrollHeight - viewport.clientHeight);
|
|
166
|
+
}
|
|
167
|
+
function getBlockPadding(element) {
|
|
168
|
+
const style = window.getComputedStyle(element);
|
|
169
|
+
return {
|
|
170
|
+
end: readCssPixel(style.paddingBlockEnd || style.paddingBottom),
|
|
171
|
+
start: readCssPixel(style.paddingBlockStart || style.paddingTop)
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* @since 0.5.0-canary.3
|
|
176
|
+
*/
|
|
177
|
+
function getContentBlockPadding(spacer) {
|
|
178
|
+
const content = spacer?.parentElement;
|
|
179
|
+
if (!content) return {
|
|
180
|
+
end: 0,
|
|
181
|
+
start: 0
|
|
182
|
+
};
|
|
183
|
+
return getBlockPadding(content);
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* @since 0.5.0-canary.3
|
|
187
|
+
*/
|
|
188
|
+
function getFlexGap(element) {
|
|
189
|
+
if (!element) return 0;
|
|
190
|
+
const style = window.getComputedStyle(element);
|
|
191
|
+
return readCssPixel(style.rowGap === "normal" ? style.gap : style.rowGap);
|
|
192
|
+
}
|
|
193
|
+
function readCssPixel(value) {
|
|
194
|
+
if (!value) return 0;
|
|
195
|
+
const number = Number.parseFloat(value);
|
|
196
|
+
return Number.isFinite(number) ? number : 0;
|
|
197
|
+
}
|
|
198
|
+
//#endregion
|
|
199
|
+
export { getContentBlockPadding, getContentBottom, getElementScrollTop, getElementTop, getElementViewportTop, getFirstVisibleMessageItem, getFlexGap, getLastScrollAnchor, getMaxScrollTop, getMessageScrollerItems, getMessageScrollerScrollable, getMessageScrollerVisibilityState, getNewScrollAnchor, getTailSpacerHeight, getUnanchoredScrollAnchor, hasMultipleNewScrollAnchors };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { MessageScrollerScrollable, MessageScrollerStore, MessageScrollerVisibilityState, MessageScrollerVisibilityStore } from "./types.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/lib/message-scroller/stores.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* @since 0.5.0-canary.3
|
|
6
|
+
*/
|
|
7
|
+
declare function createMessageScrollerStore<T>(initialSnapshot: T, isEqual: (a: T, b: T) => boolean): MessageScrollerStore<T>;
|
|
8
|
+
/**
|
|
9
|
+
* @since 0.5.0-canary.3
|
|
10
|
+
*/
|
|
11
|
+
declare function createMessageScrollerVisibilityStore(): MessageScrollerVisibilityStore;
|
|
12
|
+
/**
|
|
13
|
+
* @since 0.5.0-canary.3
|
|
14
|
+
*/
|
|
15
|
+
declare function areScrollStatesEqual(current: MessageScrollerScrollable, next: MessageScrollerScrollable): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* @since 0.5.0-canary.3
|
|
18
|
+
*/
|
|
19
|
+
declare function areVisibilityStatesEqual(current: MessageScrollerVisibilityState, next: MessageScrollerVisibilityState): boolean;
|
|
20
|
+
//#endregion
|
|
21
|
+
export { areScrollStatesEqual, areVisibilityStatesEqual, createMessageScrollerStore, createMessageScrollerVisibilityStore };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { EMPTY_MESSAGE_SCROLLER_VISIBILITY_STATE } from "./types.mjs";
|
|
2
|
+
//#region src/lib/message-scroller/stores.ts
|
|
3
|
+
function createExternalStore(initialSnapshot, isEqual) {
|
|
4
|
+
let snapshot = initialSnapshot;
|
|
5
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
6
|
+
return {
|
|
7
|
+
getSnapshot: () => snapshot,
|
|
8
|
+
hasListeners: () => listeners.size > 0,
|
|
9
|
+
setSnapshot: (nextSnapshot) => {
|
|
10
|
+
if (isEqual(snapshot, nextSnapshot)) return;
|
|
11
|
+
snapshot = nextSnapshot;
|
|
12
|
+
listeners.forEach((listener) => listener());
|
|
13
|
+
},
|
|
14
|
+
subscribe: (listener, onFirstSubscribe, onLastUnsubscribe) => {
|
|
15
|
+
const wasEmpty = listeners.size === 0;
|
|
16
|
+
listeners.add(listener);
|
|
17
|
+
if (wasEmpty) onFirstSubscribe?.();
|
|
18
|
+
return () => {
|
|
19
|
+
listeners.delete(listener);
|
|
20
|
+
if (listeners.size === 0) onLastUnsubscribe?.();
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* @since 0.5.0-canary.3
|
|
27
|
+
*/
|
|
28
|
+
function createMessageScrollerStore(initialSnapshot, isEqual) {
|
|
29
|
+
return createExternalStore(initialSnapshot, isEqual);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* @since 0.5.0-canary.3
|
|
33
|
+
*/
|
|
34
|
+
function createMessageScrollerVisibilityStore() {
|
|
35
|
+
return createExternalStore(EMPTY_MESSAGE_SCROLLER_VISIBILITY_STATE, areVisibilityStatesEqual);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* @since 0.5.0-canary.3
|
|
39
|
+
*/
|
|
40
|
+
function areScrollStatesEqual(current, next) {
|
|
41
|
+
return current.start === next.start && current.end === next.end;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* @since 0.5.0-canary.3
|
|
45
|
+
*/
|
|
46
|
+
function areVisibilityStatesEqual(current, next) {
|
|
47
|
+
if (current.currentAnchorId !== next.currentAnchorId) return false;
|
|
48
|
+
if (current.visibleMessageIds.length !== next.visibleMessageIds.length) return false;
|
|
49
|
+
return current.visibleMessageIds.every((messageId, index) => messageId === next.visibleMessageIds[index]);
|
|
50
|
+
}
|
|
51
|
+
//#endregion
|
|
52
|
+
export { areScrollStatesEqual, areVisibilityStatesEqual, createMessageScrollerStore, createMessageScrollerVisibilityStore };
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { UseRenderComponentProps } from "../use-render.mjs";
|
|
2
|
+
import { ComponentProps, ReactNode, RefObject } from "react";
|
|
3
|
+
|
|
4
|
+
//#region src/lib/message-scroller/types.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* @since 0.5.0-canary.3
|
|
7
|
+
*/
|
|
8
|
+
declare const DEFAULT_SCROLL_EDGE_THRESHOLD = 8;
|
|
9
|
+
/**
|
|
10
|
+
* @since 0.5.0-canary.3
|
|
11
|
+
*/
|
|
12
|
+
declare const DEFAULT_SCROLL_PREVIOUS_ITEM_PEEK = 64;
|
|
13
|
+
/**
|
|
14
|
+
* @since 0.5.0-canary.3
|
|
15
|
+
*/
|
|
16
|
+
declare const DEFAULT_SCROLL_MARGIN = 0;
|
|
17
|
+
/**
|
|
18
|
+
* @since 0.5.0-canary.3
|
|
19
|
+
*/
|
|
20
|
+
declare const SCROLL_POSITION_EPSILON = 0.5;
|
|
21
|
+
/**
|
|
22
|
+
* @since 0.5.0-canary.3
|
|
23
|
+
*/
|
|
24
|
+
declare const AUTOSCROLLING_CLEAR_DELAY = 180;
|
|
25
|
+
/**
|
|
26
|
+
* @since 0.5.0-canary.3
|
|
27
|
+
*/
|
|
28
|
+
declare const USER_SCROLL_KEYS: Set<string>;
|
|
29
|
+
/**
|
|
30
|
+
* @since 0.5.0-canary.3
|
|
31
|
+
*/
|
|
32
|
+
type MessageScrollerMode = "following-bottom" | "free-scrolling" | "anchored-to-message" | "settling-jump";
|
|
33
|
+
/**
|
|
34
|
+
* @since 0.5.0-canary.3
|
|
35
|
+
*/
|
|
36
|
+
type MessageScrollerDefaultScrollPosition = "start" | "end" | "last-anchor";
|
|
37
|
+
/**
|
|
38
|
+
* @since 0.5.0-canary.3
|
|
39
|
+
*/
|
|
40
|
+
type MessageScrollerButtonDirection = "start" | "end";
|
|
41
|
+
/**
|
|
42
|
+
* @since 0.5.0-canary.3
|
|
43
|
+
*/
|
|
44
|
+
type MessageScrollerScrollAlign = "start" | "center" | "end" | "nearest";
|
|
45
|
+
/**
|
|
46
|
+
* @since 0.5.0-canary.3
|
|
47
|
+
*/
|
|
48
|
+
type MessageScrollerScrollOptions = {
|
|
49
|
+
align?: MessageScrollerScrollAlign;
|
|
50
|
+
behavior?: ScrollBehavior;
|
|
51
|
+
scrollMargin?: number;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* @since 0.5.0-canary.3
|
|
55
|
+
*/
|
|
56
|
+
type MessageScrollerScrollable = {
|
|
57
|
+
start: boolean;
|
|
58
|
+
end: boolean;
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* @since 0.5.0-canary.3
|
|
62
|
+
*/
|
|
63
|
+
type MessageScrollerVisibilityState = {
|
|
64
|
+
currentAnchorId: string | null;
|
|
65
|
+
visibleMessageIds: Array<string>;
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* @since 0.5.0-canary.3
|
|
69
|
+
*/
|
|
70
|
+
type MessageScrollerProviderProps = {
|
|
71
|
+
children?: ReactNode;
|
|
72
|
+
autoScroll?: boolean;
|
|
73
|
+
defaultScrollPosition?: MessageScrollerDefaultScrollPosition;
|
|
74
|
+
scrollEdgeThreshold?: number;
|
|
75
|
+
scrollPreviousItemPeek?: number;
|
|
76
|
+
scrollMargin?: number;
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* @since 0.5.0-canary.3
|
|
80
|
+
*/
|
|
81
|
+
type MessageScrollerProps = ComponentProps<"div">;
|
|
82
|
+
/**
|
|
83
|
+
* @since 0.5.0-canary.3
|
|
84
|
+
*/
|
|
85
|
+
type MessageScrollerViewportProps = ComponentProps<"div"> & {
|
|
86
|
+
preserveScrollOnPrepend?: boolean;
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* @since 0.5.0-canary.3
|
|
90
|
+
*/
|
|
91
|
+
type MessageScrollerContentProps = ComponentProps<"div"> & {
|
|
92
|
+
spacerClassName?: string;
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* @since 0.5.0-canary.3
|
|
96
|
+
*/
|
|
97
|
+
type MessageScrollerItemProps = ComponentProps<"div"> & {
|
|
98
|
+
messageId?: string;
|
|
99
|
+
scrollAnchor?: boolean;
|
|
100
|
+
};
|
|
101
|
+
/**
|
|
102
|
+
* @since 0.5.0-canary.3
|
|
103
|
+
*/
|
|
104
|
+
type MessageScrollerButtonRenderState = {
|
|
105
|
+
active: boolean;
|
|
106
|
+
direction: MessageScrollerButtonDirection;
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* @since 0.5.0-canary.3
|
|
110
|
+
*/
|
|
111
|
+
type MessageScrollerButtonProps = UseRenderComponentProps<"button", MessageScrollerButtonRenderState> & {
|
|
112
|
+
behavior?: ScrollBehavior;
|
|
113
|
+
direction?: MessageScrollerButtonDirection;
|
|
114
|
+
};
|
|
115
|
+
/**
|
|
116
|
+
* @since 0.5.0-canary.3
|
|
117
|
+
*/
|
|
118
|
+
type MessageScrollerStore<T> = {
|
|
119
|
+
getSnapshot: () => T;
|
|
120
|
+
setSnapshot: (nextSnapshot: T) => void;
|
|
121
|
+
subscribe: (listener: () => void) => () => void;
|
|
122
|
+
};
|
|
123
|
+
/**
|
|
124
|
+
* @since 0.5.0-canary.3
|
|
125
|
+
*/
|
|
126
|
+
type MessageScrollerVisibilityStore = {
|
|
127
|
+
getSnapshot: () => MessageScrollerVisibilityState;
|
|
128
|
+
hasListeners: () => boolean;
|
|
129
|
+
setSnapshot: (nextSnapshot: MessageScrollerVisibilityState) => void;
|
|
130
|
+
subscribe: (listener: () => void, onFirstSubscribe: () => void, onLastUnsubscribe: () => void) => () => void;
|
|
131
|
+
};
|
|
132
|
+
/**
|
|
133
|
+
* @since 0.5.0-canary.3
|
|
134
|
+
*/
|
|
135
|
+
type MessageScrollerRegisterMessage = (messageId: string, element: HTMLElement | null, removedElement?: HTMLElement | null) => void;
|
|
136
|
+
/**
|
|
137
|
+
* @since 0.5.0-canary.3
|
|
138
|
+
*/
|
|
139
|
+
type MessageScrollerContextValue = {
|
|
140
|
+
handleContentChange: () => void;
|
|
141
|
+
handleResize: () => void;
|
|
142
|
+
observeVisibility: () => void;
|
|
143
|
+
preserveScrollOnPrependRef: RefObject<boolean>;
|
|
144
|
+
scrollToEnd: (options?: MessageScrollerScrollOptions) => boolean;
|
|
145
|
+
scrollToMessage: (messageId: string, options?: MessageScrollerScrollOptions) => boolean;
|
|
146
|
+
scrollToStart: (options?: MessageScrollerScrollOptions) => boolean;
|
|
147
|
+
setContentElement: (element: HTMLDivElement | null) => void;
|
|
148
|
+
setRootElement: (element: HTMLDivElement | null) => void;
|
|
149
|
+
setSpacerElement: (element: HTMLDivElement | null) => void;
|
|
150
|
+
setViewportElement: (element: HTMLDivElement | null) => void;
|
|
151
|
+
stateStore: MessageScrollerStore<MessageScrollerScrollable>;
|
|
152
|
+
syncAfterScroll: () => void;
|
|
153
|
+
unobserveVisibility: () => void;
|
|
154
|
+
userScrollIntent: () => void;
|
|
155
|
+
viewportRef: RefObject<HTMLDivElement | null>;
|
|
156
|
+
visibilityStore: MessageScrollerVisibilityStore;
|
|
157
|
+
};
|
|
158
|
+
/**
|
|
159
|
+
* @since 0.5.0-canary.3
|
|
160
|
+
*/
|
|
161
|
+
declare const EMPTY_MESSAGE_SCROLLER_SCROLLABLE: MessageScrollerScrollable;
|
|
162
|
+
/**
|
|
163
|
+
* @since 0.5.0-canary.3
|
|
164
|
+
*/
|
|
165
|
+
declare const EMPTY_VISIBLE_MESSAGE_IDS: Array<string>;
|
|
166
|
+
/**
|
|
167
|
+
* @since 0.5.0-canary.3
|
|
168
|
+
*/
|
|
169
|
+
declare const EMPTY_MESSAGE_SCROLLER_VISIBILITY_STATE: MessageScrollerVisibilityState;
|
|
170
|
+
//#endregion
|
|
171
|
+
export { AUTOSCROLLING_CLEAR_DELAY, DEFAULT_SCROLL_EDGE_THRESHOLD, DEFAULT_SCROLL_MARGIN, DEFAULT_SCROLL_PREVIOUS_ITEM_PEEK, EMPTY_MESSAGE_SCROLLER_SCROLLABLE, EMPTY_MESSAGE_SCROLLER_VISIBILITY_STATE, EMPTY_VISIBLE_MESSAGE_IDS, type MessageScrollerButtonDirection, type MessageScrollerButtonProps, type MessageScrollerButtonRenderState, type MessageScrollerContentProps, type MessageScrollerContextValue, type MessageScrollerDefaultScrollPosition, type MessageScrollerItemProps, type MessageScrollerMode, type MessageScrollerProps, type MessageScrollerProviderProps, type MessageScrollerRegisterMessage, type MessageScrollerScrollAlign, type MessageScrollerScrollOptions, type MessageScrollerScrollable, type MessageScrollerStore, type MessageScrollerViewportProps, type MessageScrollerVisibilityState, type MessageScrollerVisibilityStore, SCROLL_POSITION_EPSILON, USER_SCROLL_KEYS };
|