@gv-tech/design-system 2.26.2 → 2.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/alert.cjs +1 -1
- package/dist/alert.cjs.map +1 -1
- package/dist/alert.mjs +3 -1
- package/dist/alert.mjs.map +1 -1
- package/dist/design-system.css +1 -1
- package/dist/packages/ui-web/src/__contracts.d.ts +270 -0
- package/dist/packages/ui-web/src/alert.d.ts +1 -1
- package/dist/packages/ui-web/src/hooks/use-theme.test.d.ts +1 -0
- package/dist/packages/ui-web/src/theme-provider.test.d.ts +1 -0
- package/dist/table-of-contents.cjs +1 -1
- package/dist/table-of-contents.cjs.map +1 -1
- package/dist/table-of-contents.mjs +2 -2
- package/dist/table-of-contents.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1,271 @@
|
|
|
1
|
+
import { AccordionBaseProps, AccordionContentBaseProps, AccordionItemBaseProps, AccordionTriggerBaseProps, AlertBaseProps, AlertDescriptionBaseProps, AlertDialogActionBaseProps, AlertDialogBaseProps, AlertDialogCancelBaseProps, AlertDialogContentBaseProps, AlertDialogDescriptionBaseProps, AlertDialogFooterBaseProps, AlertDialogHeaderBaseProps, AlertDialogTitleBaseProps, AlertDialogTriggerBaseProps, AlertTitleBaseProps, AspectRatioBaseProps, AvatarBaseProps, AvatarFallbackBaseProps, AvatarImageBaseProps, BadgeBaseProps, BreadcrumbBaseProps, BreadcrumbEllipsisBaseProps, BreadcrumbItemBaseProps, BreadcrumbLinkBaseProps, BreadcrumbListBaseProps, BreadcrumbPageBaseProps, BreadcrumbSeparatorBaseProps, ButtonBaseProps, ButtonGroupBaseProps, ButtonGroupSeparatorBaseProps, ButtonGroupTextBaseProps, CalendarBaseProps, CardBaseProps, CarouselBaseProps, CarouselContentBaseProps, CarouselItemBaseProps, CarouselNextBaseProps, CarouselPreviousBaseProps, ChartContainerBaseProps, ChartLegendContentBaseProps, ChartTooltipContentBaseProps, CheckboxBaseProps, CollapsibleBaseProps, CollapsibleContentBaseProps, CollapsibleTriggerBaseProps, ComboboxChipBaseProps, ComboboxChipsBaseProps, ComboboxChipsInputBaseProps, ComboboxCollectionBaseProps, ComboboxContentBaseProps, ComboboxEmptyBaseProps, ComboboxGroupBaseProps, ComboboxInputBaseProps, ComboboxItemBaseProps, ComboboxLabelBaseProps, ComboboxListBaseProps, ComboboxSeparatorBaseProps, ComboboxTriggerBaseProps, ComboboxValueBaseProps, CommandBaseProps, CommandEmptyBaseProps, CommandGroupBaseProps, CommandInputBaseProps, CommandItemBaseProps, CommandListBaseProps, CommandSeparatorBaseProps, CommandShortcutBaseProps, ContextMenuBaseProps, ContextMenuCheckboxItemBaseProps, ContextMenuContentBaseProps, ContextMenuGroupBaseProps, ContextMenuItemBaseProps, ContextMenuLabelBaseProps, ContextMenuRadioGroupBaseProps, ContextMenuRadioItemBaseProps, ContextMenuSeparatorBaseProps, ContextMenuShortcutBaseProps, ContextMenuSubBaseProps, ContextMenuSubContentBaseProps, ContextMenuSubTriggerBaseProps, ContextMenuTriggerBaseProps, DialogBaseProps, DialogContentBaseProps, DirectionProviderBaseProps, DrawerBaseProps, DrawerCloseBaseProps, DrawerContentBaseProps, DrawerDescriptionBaseProps, DrawerFooterBaseProps, DrawerHeaderBaseProps, DrawerTitleBaseProps, DrawerTriggerBaseProps, DropdownMenuBaseProps, DropdownMenuCheckboxItemBaseProps, DropdownMenuContentBaseProps, DropdownMenuGroupBaseProps, DropdownMenuItemBaseProps, DropdownMenuLabelBaseProps, DropdownMenuRadioGroupBaseProps, DropdownMenuRadioItemBaseProps, DropdownMenuSeparatorBaseProps, DropdownMenuShortcutBaseProps, DropdownMenuSubBaseProps, DropdownMenuSubContentBaseProps, DropdownMenuSubTriggerBaseProps, DropdownMenuTriggerBaseProps, EmptyBaseProps, EmptyMediaBaseProps, FieldBaseProps, FieldContentBaseProps, FieldDescriptionBaseProps, FieldErrorBaseProps, FieldGroupBaseProps, FieldLabelBaseProps, FieldLegendBaseProps, FieldSeparatorBaseProps, FieldSetBaseProps, FieldTitleBaseProps, FormBaseProps, FormDescriptionBaseProps, FormItemBaseProps, FormLabelBaseProps, FormMessageBaseProps, HoverCardBaseProps, HoverCardContentBaseProps, HoverCardTriggerBaseProps, InputBaseProps, InputGroupAddonBaseProps, InputGroupBaseProps, InputGroupButtonBaseProps, InputGroupInputBaseProps, InputGroupTextBaseProps, InputGroupTextareaBaseProps, InputOTPBaseProps, InputOTPGroupBaseProps, InputOTPSeparatorBaseProps, InputOTPSlotBaseProps, ItemActionsBaseProps, ItemBaseProps, ItemContentBaseProps, ItemDescriptionBaseProps, ItemFooterBaseProps, ItemGroupBaseProps, ItemHeaderBaseProps, ItemMediaBaseProps, ItemSeparatorBaseProps, ItemTitleBaseProps, KbdBaseProps, KbdGroupBaseProps, LabelBaseProps, MenubarBaseProps, MenubarCheckboxItemBaseProps, MenubarContentBaseProps, MenubarItemBaseProps, MenubarLabelBaseProps, MenubarMenuBaseProps, MenubarRadioItemBaseProps, MenubarSeparatorBaseProps, MenubarShortcutBaseProps, MenubarSubBaseProps, MenubarSubContentBaseProps, MenubarSubTriggerBaseProps, MenubarTriggerBaseProps, NativeSelectBaseProps, NativeSelectOptGroupBaseProps, NativeSelectOptionBaseProps, NavigationMenuBaseProps, NavigationMenuContentBaseProps, NavigationMenuIndicatorBaseProps, NavigationMenuItemBaseProps, NavigationMenuLinkBaseProps, NavigationMenuListBaseProps, NavigationMenuTriggerBaseProps, NavigationMenuViewportBaseProps, PaginationBaseProps, PaginationContentBaseProps, PaginationEllipsisBaseProps, PaginationItemBaseProps, PaginationLinkBaseProps, PaginationNextBaseProps, PaginationPreviousBaseProps, PopoverAnchorBaseProps, PopoverBaseProps, PopoverContentBaseProps, PopoverTriggerBaseProps, ProgressBaseProps, RadioGroupBaseProps, RadioGroupItemBaseProps, ResizableHandleBaseProps, ResizablePanelBaseProps, ResizablePanelGroupBaseProps, ScrollAreaBaseProps, ScrollBarBaseProps, ScrollToTopBaseProps, SearchBaseProps, SearchTriggerBaseProps, SelectBaseProps, SelectContentBaseProps, SelectGroupBaseProps, SelectItemBaseProps, SelectLabelBaseProps, SelectScrollDownButtonBaseProps, SelectScrollUpButtonBaseProps, SelectSeparatorBaseProps, SelectTriggerBaseProps, SelectValueBaseProps, SeparatorBaseProps, SheetBaseProps, SheetCloseBaseProps, SheetContentBaseProps, SheetDescriptionBaseProps, SheetFooterBaseProps, SheetHeaderBaseProps, SheetTitleBaseProps, SheetTriggerBaseProps, SidebarBaseProps, SidebarContentBaseProps, SidebarFooterBaseProps, SidebarGroupActionBaseProps, SidebarGroupBaseProps, SidebarGroupContentBaseProps, SidebarGroupLabelBaseProps, SidebarHeaderBaseProps, SidebarInputBaseProps, SidebarInsetBaseProps, SidebarMenuActionBaseProps, SidebarMenuBadgeBaseProps, SidebarMenuBaseProps, SidebarMenuButtonBaseProps, SidebarMenuItemBaseProps, SidebarMenuSkeletonBaseProps, SidebarMenuSubBaseProps, SidebarMenuSubButtonBaseProps, SidebarMenuSubItemBaseProps, SidebarProviderBaseProps, SidebarRailBaseProps, SidebarSeparatorBaseProps, SidebarTriggerBaseProps, SkeletonBaseProps, SliderBaseProps, SpinnerBaseProps, SwitchBaseProps, TableBaseProps, TableBodyBaseProps, TableCaptionBaseProps, TableCellBaseProps, TableFooterBaseProps, TableHeadBaseProps, TableHeaderBaseProps, TableOfContentsBaseProps, TableRowBaseProps, TabsBaseProps, TabsContentBaseProps, TabsListBaseProps, TabsTriggerBaseProps, TextBaseProps, TextareaBaseProps, ThemeProviderBaseProps, ThemeToggleBaseProps, ToastBaseProps, ToasterBaseProps, ToggleBaseProps, ToggleGroupBaseProps, ToggleGroupItemBaseProps, TooltipBaseProps, TooltipContentBaseProps, TooltipProviderBaseProps, TooltipTriggerBaseProps } from '../../ui-core/src';
|
|
2
|
+
export declare const _test_Accordion: AccordionBaseProps;
|
|
3
|
+
export declare const _test_AccordionContent: AccordionContentBaseProps;
|
|
4
|
+
export declare const _test_AccordionItem: AccordionItemBaseProps;
|
|
5
|
+
export declare const _test_AccordionTrigger: AccordionTriggerBaseProps;
|
|
6
|
+
export declare const _test_Alert: AlertBaseProps;
|
|
7
|
+
export declare const _test_AlertDescription: AlertDescriptionBaseProps;
|
|
8
|
+
export declare const _test_AlertTitle: AlertTitleBaseProps;
|
|
9
|
+
export declare const _test_AlertDialogAction: AlertDialogActionBaseProps;
|
|
10
|
+
export declare const _test_AlertDialog: AlertDialogBaseProps;
|
|
11
|
+
export declare const _test_AlertDialogCancel: AlertDialogCancelBaseProps;
|
|
12
|
+
export declare const _test_AlertDialogContent: AlertDialogContentBaseProps;
|
|
13
|
+
export declare const _test_AlertDialogDescription: AlertDialogDescriptionBaseProps;
|
|
14
|
+
export declare const _test_AlertDialogFooter: AlertDialogFooterBaseProps;
|
|
15
|
+
export declare const _test_AlertDialogHeader: AlertDialogHeaderBaseProps;
|
|
16
|
+
export declare const _test_AlertDialogTitle: AlertDialogTitleBaseProps;
|
|
17
|
+
export declare const _test_AlertDialogTrigger: AlertDialogTriggerBaseProps;
|
|
18
|
+
export declare const _test_AspectRatio: AspectRatioBaseProps;
|
|
19
|
+
export declare const _test_Avatar: AvatarBaseProps;
|
|
20
|
+
export declare const _test_AvatarFallback: AvatarFallbackBaseProps;
|
|
21
|
+
export declare const _test_AvatarImage: AvatarImageBaseProps;
|
|
22
|
+
export declare const _test_Badge: BadgeBaseProps;
|
|
23
|
+
export declare const _test_Breadcrumb: BreadcrumbBaseProps;
|
|
24
|
+
export declare const _test_BreadcrumbEllipsis: BreadcrumbEllipsisBaseProps;
|
|
25
|
+
export declare const _test_BreadcrumbItem: BreadcrumbItemBaseProps;
|
|
26
|
+
export declare const _test_BreadcrumbLink: BreadcrumbLinkBaseProps;
|
|
27
|
+
export declare const _test_BreadcrumbList: BreadcrumbListBaseProps;
|
|
28
|
+
export declare const _test_BreadcrumbPage: BreadcrumbPageBaseProps;
|
|
29
|
+
export declare const _test_BreadcrumbSeparator: BreadcrumbSeparatorBaseProps;
|
|
30
|
+
export declare const _test_Button: ButtonBaseProps;
|
|
31
|
+
export declare const _test_Calendar: CalendarBaseProps;
|
|
32
|
+
export declare const _test_Card: CardBaseProps;
|
|
33
|
+
export declare const _test_Carousel: CarouselBaseProps;
|
|
34
|
+
export declare const _test_CarouselContent: CarouselContentBaseProps;
|
|
35
|
+
export declare const _test_CarouselItem: CarouselItemBaseProps;
|
|
36
|
+
export declare const _test_CarouselNext: CarouselNextBaseProps;
|
|
37
|
+
export declare const _test_CarouselPrevious: CarouselPreviousBaseProps;
|
|
38
|
+
export declare const _test_ChartContainer: ChartContainerBaseProps;
|
|
39
|
+
export declare const _test_ChartLegendContent: ChartLegendContentBaseProps;
|
|
40
|
+
export declare const _test_ChartTooltipContent: ChartTooltipContentBaseProps;
|
|
41
|
+
export declare const _test_Checkbox: CheckboxBaseProps;
|
|
42
|
+
export declare const _test_Collapsible: CollapsibleBaseProps;
|
|
43
|
+
export declare const _test_CollapsibleContent: CollapsibleContentBaseProps;
|
|
44
|
+
export declare const _test_CollapsibleTrigger: CollapsibleTriggerBaseProps;
|
|
45
|
+
export declare const _test_Command: CommandBaseProps;
|
|
46
|
+
export declare const _test_CommandEmpty: CommandEmptyBaseProps;
|
|
47
|
+
export declare const _test_CommandGroup: CommandGroupBaseProps;
|
|
48
|
+
export declare const _test_CommandInput: CommandInputBaseProps;
|
|
49
|
+
export declare const _test_CommandItem: CommandItemBaseProps;
|
|
50
|
+
export declare const _test_CommandList: CommandListBaseProps;
|
|
51
|
+
export declare const _test_CommandSeparator: CommandSeparatorBaseProps;
|
|
52
|
+
export declare const _test_CommandShortcut: CommandShortcutBaseProps;
|
|
53
|
+
export declare const _test_ContextMenu: ContextMenuBaseProps;
|
|
54
|
+
export declare const _test_ContextMenuCheckboxItem: ContextMenuCheckboxItemBaseProps;
|
|
55
|
+
export declare const _test_ContextMenuContent: ContextMenuContentBaseProps;
|
|
56
|
+
export declare const _test_ContextMenuGroup: ContextMenuGroupBaseProps;
|
|
57
|
+
export declare const _test_ContextMenuItem: ContextMenuItemBaseProps;
|
|
58
|
+
export declare const _test_ContextMenuLabel: ContextMenuLabelBaseProps;
|
|
59
|
+
export declare const _test_ContextMenuRadioGroup: ContextMenuRadioGroupBaseProps;
|
|
60
|
+
export declare const _test_ContextMenuRadioItem: ContextMenuRadioItemBaseProps;
|
|
61
|
+
export declare const _test_ContextMenuSeparator: ContextMenuSeparatorBaseProps;
|
|
62
|
+
export declare const _test_ContextMenuShortcut: ContextMenuShortcutBaseProps;
|
|
63
|
+
export declare const _test_ContextMenuSub: ContextMenuSubBaseProps;
|
|
64
|
+
export declare const _test_ContextMenuSubContent: ContextMenuSubContentBaseProps;
|
|
65
|
+
export declare const _test_ContextMenuSubTrigger: ContextMenuSubTriggerBaseProps;
|
|
66
|
+
export declare const _test_ContextMenuTrigger: ContextMenuTriggerBaseProps;
|
|
67
|
+
export declare const _test_Dialog: DialogBaseProps;
|
|
68
|
+
export declare const _test_DialogContent: DialogContentBaseProps;
|
|
69
|
+
export declare const _test_Drawer: DrawerBaseProps;
|
|
70
|
+
export declare const _test_DrawerClose: DrawerCloseBaseProps;
|
|
71
|
+
export declare const _test_DrawerContent: DrawerContentBaseProps;
|
|
72
|
+
export declare const _test_DrawerDescription: DrawerDescriptionBaseProps;
|
|
73
|
+
export declare const _test_DrawerFooter: DrawerFooterBaseProps;
|
|
74
|
+
export declare const _test_DrawerHeader: DrawerHeaderBaseProps;
|
|
75
|
+
export declare const _test_DrawerTitle: DrawerTitleBaseProps;
|
|
76
|
+
export declare const _test_DrawerTrigger: DrawerTriggerBaseProps;
|
|
77
|
+
export declare const _test_DropdownMenu: DropdownMenuBaseProps;
|
|
78
|
+
export declare const _test_DropdownMenuCheckboxItem: DropdownMenuCheckboxItemBaseProps;
|
|
79
|
+
export declare const _test_DropdownMenuContent: DropdownMenuContentBaseProps;
|
|
80
|
+
export declare const _test_DropdownMenuGroup: DropdownMenuGroupBaseProps;
|
|
81
|
+
export declare const _test_DropdownMenuItem: DropdownMenuItemBaseProps;
|
|
82
|
+
export declare const _test_DropdownMenuLabel: DropdownMenuLabelBaseProps;
|
|
83
|
+
export declare const _test_DropdownMenuRadioGroup: DropdownMenuRadioGroupBaseProps;
|
|
84
|
+
export declare const _test_DropdownMenuRadioItem: DropdownMenuRadioItemBaseProps;
|
|
85
|
+
export declare const _test_DropdownMenuSeparator: DropdownMenuSeparatorBaseProps;
|
|
86
|
+
export declare const _test_DropdownMenuShortcut: DropdownMenuShortcutBaseProps;
|
|
87
|
+
export declare const _test_DropdownMenuSub: DropdownMenuSubBaseProps;
|
|
88
|
+
export declare const _test_DropdownMenuSubContent: DropdownMenuSubContentBaseProps;
|
|
89
|
+
export declare const _test_DropdownMenuSubTrigger: DropdownMenuSubTriggerBaseProps;
|
|
90
|
+
export declare const _test_DropdownMenuTrigger: DropdownMenuTriggerBaseProps;
|
|
91
|
+
export declare const _test_Form: FormBaseProps;
|
|
92
|
+
export declare const _test_FormDescription: FormDescriptionBaseProps;
|
|
93
|
+
export declare const _test_FormItem: FormItemBaseProps;
|
|
94
|
+
export declare const _test_FormLabel: FormLabelBaseProps;
|
|
95
|
+
export declare const _test_FormMessage: FormMessageBaseProps;
|
|
96
|
+
export declare const _test_HoverCard: HoverCardBaseProps;
|
|
97
|
+
export declare const _test_HoverCardContent: HoverCardContentBaseProps;
|
|
98
|
+
export declare const _test_HoverCardTrigger: HoverCardTriggerBaseProps;
|
|
99
|
+
export declare const _test_Input: InputBaseProps;
|
|
100
|
+
export declare const _test_Label: LabelBaseProps;
|
|
101
|
+
export declare const _test_Menubar: MenubarBaseProps;
|
|
102
|
+
export declare const _test_MenubarCheckboxItem: MenubarCheckboxItemBaseProps;
|
|
103
|
+
export declare const _test_MenubarContent: MenubarContentBaseProps;
|
|
104
|
+
export declare const _test_MenubarItem: MenubarItemBaseProps;
|
|
105
|
+
export declare const _test_MenubarLabel: MenubarLabelBaseProps;
|
|
106
|
+
export declare const _test_MenubarMenu: MenubarMenuBaseProps;
|
|
107
|
+
export declare const _test_MenubarRadioItem: MenubarRadioItemBaseProps;
|
|
108
|
+
export declare const _test_MenubarSeparator: MenubarSeparatorBaseProps;
|
|
109
|
+
export declare const _test_MenubarShortcut: MenubarShortcutBaseProps;
|
|
110
|
+
export declare const _test_MenubarSub: MenubarSubBaseProps;
|
|
111
|
+
export declare const _test_MenubarSubContent: MenubarSubContentBaseProps;
|
|
112
|
+
export declare const _test_MenubarSubTrigger: MenubarSubTriggerBaseProps;
|
|
113
|
+
export declare const _test_MenubarTrigger: MenubarTriggerBaseProps;
|
|
114
|
+
export declare const _test_NavigationMenu: NavigationMenuBaseProps;
|
|
115
|
+
export declare const _test_NavigationMenuContent: NavigationMenuContentBaseProps;
|
|
116
|
+
export declare const _test_NavigationMenuIndicator: NavigationMenuIndicatorBaseProps;
|
|
117
|
+
export declare const _test_NavigationMenuItem: NavigationMenuItemBaseProps;
|
|
118
|
+
export declare const _test_NavigationMenuLink: NavigationMenuLinkBaseProps;
|
|
119
|
+
export declare const _test_NavigationMenuList: NavigationMenuListBaseProps;
|
|
120
|
+
export declare const _test_NavigationMenuTrigger: NavigationMenuTriggerBaseProps;
|
|
121
|
+
export declare const _test_NavigationMenuViewport: NavigationMenuViewportBaseProps;
|
|
122
|
+
export declare const _test_Pagination: PaginationBaseProps;
|
|
123
|
+
export declare const _test_PaginationContent: PaginationContentBaseProps;
|
|
124
|
+
export declare const _test_PaginationEllipsis: PaginationEllipsisBaseProps;
|
|
125
|
+
export declare const _test_PaginationItem: PaginationItemBaseProps;
|
|
126
|
+
export declare const _test_PaginationLink: PaginationLinkBaseProps;
|
|
127
|
+
export declare const _test_PaginationNext: PaginationNextBaseProps;
|
|
128
|
+
export declare const _test_PaginationPrevious: PaginationPreviousBaseProps;
|
|
129
|
+
export declare const _test_PopoverAnchor: PopoverAnchorBaseProps;
|
|
130
|
+
export declare const _test_Popover: PopoverBaseProps;
|
|
131
|
+
export declare const _test_PopoverContent: PopoverContentBaseProps;
|
|
132
|
+
export declare const _test_PopoverTrigger: PopoverTriggerBaseProps;
|
|
133
|
+
export declare const _test_Progress: ProgressBaseProps;
|
|
134
|
+
export declare const _test_RadioGroup: RadioGroupBaseProps;
|
|
135
|
+
export declare const _test_RadioGroupItem: RadioGroupItemBaseProps;
|
|
136
|
+
export declare const _test_ResizableHandle: ResizableHandleBaseProps;
|
|
137
|
+
export declare const _test_ResizablePanel: ResizablePanelBaseProps;
|
|
138
|
+
export declare const _test_ResizablePanelGroup: ResizablePanelGroupBaseProps;
|
|
139
|
+
export declare const _test_ScrollArea: ScrollAreaBaseProps;
|
|
140
|
+
export declare const _test_ScrollBar: ScrollBarBaseProps;
|
|
141
|
+
export declare const _test_ScrollToTop: ScrollToTopBaseProps;
|
|
142
|
+
export declare const _test_Search: SearchBaseProps;
|
|
143
|
+
export declare const _test_SearchTrigger: SearchTriggerBaseProps;
|
|
144
|
+
export declare const _test_Select: SelectBaseProps;
|
|
145
|
+
export declare const _test_SelectContent: SelectContentBaseProps;
|
|
146
|
+
export declare const _test_SelectGroup: SelectGroupBaseProps;
|
|
147
|
+
export declare const _test_SelectItem: SelectItemBaseProps;
|
|
148
|
+
export declare const _test_SelectLabel: SelectLabelBaseProps;
|
|
149
|
+
export declare const _test_SelectScrollDownButton: SelectScrollDownButtonBaseProps;
|
|
150
|
+
export declare const _test_SelectScrollUpButton: SelectScrollUpButtonBaseProps;
|
|
151
|
+
export declare const _test_SelectSeparator: SelectSeparatorBaseProps;
|
|
152
|
+
export declare const _test_SelectTrigger: SelectTriggerBaseProps;
|
|
153
|
+
export declare const _test_SelectValue: SelectValueBaseProps;
|
|
154
|
+
export declare const _test_Separator: SeparatorBaseProps;
|
|
155
|
+
export declare const _test_Sheet: SheetBaseProps;
|
|
156
|
+
export declare const _test_SheetClose: SheetCloseBaseProps;
|
|
157
|
+
export declare const _test_SheetContent: SheetContentBaseProps;
|
|
158
|
+
export declare const _test_SheetDescription: SheetDescriptionBaseProps;
|
|
159
|
+
export declare const _test_SheetFooter: SheetFooterBaseProps;
|
|
160
|
+
export declare const _test_SheetHeader: SheetHeaderBaseProps;
|
|
161
|
+
export declare const _test_SheetTitle: SheetTitleBaseProps;
|
|
162
|
+
export declare const _test_SheetTrigger: SheetTriggerBaseProps;
|
|
163
|
+
export declare const _test_Skeleton: SkeletonBaseProps;
|
|
164
|
+
export declare const _test_Slider: SliderBaseProps;
|
|
165
|
+
export declare const _test_Switch: SwitchBaseProps;
|
|
166
|
+
export declare const _test_Table: TableBaseProps;
|
|
167
|
+
export declare const _test_TableBody: TableBodyBaseProps;
|
|
168
|
+
export declare const _test_TableCaption: TableCaptionBaseProps;
|
|
169
|
+
export declare const _test_TableCell: TableCellBaseProps;
|
|
170
|
+
export declare const _test_TableFooter: TableFooterBaseProps;
|
|
171
|
+
export declare const _test_TableHead: TableHeadBaseProps;
|
|
172
|
+
export declare const _test_TableHeader: TableHeaderBaseProps;
|
|
173
|
+
export declare const _test_TableRow: TableRowBaseProps;
|
|
174
|
+
export declare const _test_Tabs: TabsBaseProps;
|
|
175
|
+
export declare const _test_TabsContent: TabsContentBaseProps;
|
|
176
|
+
export declare const _test_TabsList: TabsListBaseProps;
|
|
177
|
+
export declare const _test_TabsTrigger: TabsTriggerBaseProps;
|
|
178
|
+
export declare const _test_Text: TextBaseProps;
|
|
179
|
+
export declare const _test_Textarea: TextareaBaseProps;
|
|
180
|
+
export declare const _test_Toggle: ToggleBaseProps;
|
|
181
|
+
export declare const _test_ToggleGroup: ToggleGroupBaseProps;
|
|
182
|
+
export declare const _test_ToggleGroupItem: ToggleGroupItemBaseProps;
|
|
183
|
+
export declare const _test_Tooltip: TooltipBaseProps;
|
|
184
|
+
export declare const _test_TooltipContent: TooltipContentBaseProps;
|
|
185
|
+
export declare const _test_TooltipProvider: TooltipProviderBaseProps;
|
|
186
|
+
export declare const _test_TooltipTrigger: TooltipTriggerBaseProps;
|
|
187
|
+
export declare const _test_Toast: ToastBaseProps;
|
|
188
|
+
export declare const _test_ThemeProvider: ThemeProviderBaseProps;
|
|
189
|
+
export declare const _test_ThemeToggle: ThemeToggleBaseProps;
|
|
190
|
+
export declare const _test_Toaster: ToasterBaseProps;
|
|
191
|
+
export declare const _test_TableOfContents: TableOfContentsBaseProps;
|
|
192
|
+
export declare const _test_ButtonGroup: ButtonGroupBaseProps;
|
|
193
|
+
export declare const _test_ButtonGroupSeparator: ButtonGroupSeparatorBaseProps;
|
|
194
|
+
export declare const _test_ButtonGroupText: ButtonGroupTextBaseProps;
|
|
195
|
+
export declare const _test_DirectionProvider: DirectionProviderBaseProps;
|
|
196
|
+
export declare const _test_Empty: EmptyBaseProps;
|
|
197
|
+
export declare const _test_EmptyMedia: EmptyMediaBaseProps;
|
|
198
|
+
export declare const _test_Spinner: SpinnerBaseProps;
|
|
199
|
+
export declare const _test_Field: FieldBaseProps;
|
|
200
|
+
export declare const _test_FieldContent: FieldContentBaseProps;
|
|
201
|
+
export declare const _test_FieldDescription: FieldDescriptionBaseProps;
|
|
202
|
+
export declare const _test_FieldError: FieldErrorBaseProps;
|
|
203
|
+
export declare const _test_FieldGroup: FieldGroupBaseProps;
|
|
204
|
+
export declare const _test_FieldLabel: FieldLabelBaseProps;
|
|
205
|
+
export declare const _test_FieldLegend: FieldLegendBaseProps;
|
|
206
|
+
export declare const _test_FieldSeparator: FieldSeparatorBaseProps;
|
|
207
|
+
export declare const _test_FieldSet: FieldSetBaseProps;
|
|
208
|
+
export declare const _test_FieldTitle: FieldTitleBaseProps;
|
|
209
|
+
export declare const _test_InputGroupAddon: InputGroupAddonBaseProps;
|
|
210
|
+
export declare const _test_InputGroup: InputGroupBaseProps;
|
|
211
|
+
export declare const _test_InputGroupButton: InputGroupButtonBaseProps;
|
|
212
|
+
export declare const _test_InputGroupInput: InputGroupInputBaseProps;
|
|
213
|
+
export declare const _test_InputGroupText: InputGroupTextBaseProps;
|
|
214
|
+
export declare const _test_InputGroupTextarea: InputGroupTextareaBaseProps;
|
|
215
|
+
export declare const _test_NativeSelect: NativeSelectBaseProps;
|
|
216
|
+
export declare const _test_NativeSelectOptGroup: NativeSelectOptGroupBaseProps;
|
|
217
|
+
export declare const _test_NativeSelectOption: NativeSelectOptionBaseProps;
|
|
218
|
+
export declare const _test_Kbd: KbdBaseProps;
|
|
219
|
+
export declare const _test_KbdGroup: KbdGroupBaseProps;
|
|
220
|
+
export declare const _test_ItemActions: ItemActionsBaseProps;
|
|
221
|
+
export declare const _test_Item: ItemBaseProps;
|
|
222
|
+
export declare const _test_ItemContent: ItemContentBaseProps;
|
|
223
|
+
export declare const _test_ItemDescription: ItemDescriptionBaseProps;
|
|
224
|
+
export declare const _test_ItemFooter: ItemFooterBaseProps;
|
|
225
|
+
export declare const _test_ItemGroup: ItemGroupBaseProps;
|
|
226
|
+
export declare const _test_ItemHeader: ItemHeaderBaseProps;
|
|
227
|
+
export declare const _test_ItemMedia: ItemMediaBaseProps;
|
|
228
|
+
export declare const _test_ItemSeparator: ItemSeparatorBaseProps;
|
|
229
|
+
export declare const _test_ItemTitle: ItemTitleBaseProps;
|
|
230
|
+
export declare const _test_ComboboxChip: ComboboxChipBaseProps;
|
|
231
|
+
export declare const _test_ComboboxChips: ComboboxChipsBaseProps;
|
|
232
|
+
export declare const _test_ComboboxChipsInput: ComboboxChipsInputBaseProps;
|
|
233
|
+
export declare const _test_ComboboxCollection: ComboboxCollectionBaseProps;
|
|
234
|
+
export declare const _test_ComboboxContent: ComboboxContentBaseProps;
|
|
235
|
+
export declare const _test_ComboboxEmpty: ComboboxEmptyBaseProps;
|
|
236
|
+
export declare const _test_ComboboxGroup: ComboboxGroupBaseProps;
|
|
237
|
+
export declare const _test_ComboboxInput: ComboboxInputBaseProps;
|
|
238
|
+
export declare const _test_ComboboxItem: ComboboxItemBaseProps;
|
|
239
|
+
export declare const _test_ComboboxLabel: ComboboxLabelBaseProps;
|
|
240
|
+
export declare const _test_ComboboxList: ComboboxListBaseProps;
|
|
241
|
+
export declare const _test_ComboboxSeparator: ComboboxSeparatorBaseProps;
|
|
242
|
+
export declare const _test_ComboboxTrigger: ComboboxTriggerBaseProps;
|
|
243
|
+
export declare const _test_ComboboxValue: ComboboxValueBaseProps;
|
|
244
|
+
export declare const _test_InputOTP: InputOTPBaseProps;
|
|
245
|
+
export declare const _test_InputOTPGroup: InputOTPGroupBaseProps;
|
|
246
|
+
export declare const _test_InputOTPSeparator: InputOTPSeparatorBaseProps;
|
|
247
|
+
export declare const _test_InputOTPSlot: InputOTPSlotBaseProps;
|
|
248
|
+
export declare const _test_Sidebar: SidebarBaseProps;
|
|
249
|
+
export declare const _test_SidebarContent: SidebarContentBaseProps;
|
|
250
|
+
export declare const _test_SidebarFooter: SidebarFooterBaseProps;
|
|
251
|
+
export declare const _test_SidebarGroupAction: SidebarGroupActionBaseProps;
|
|
252
|
+
export declare const _test_SidebarGroup: SidebarGroupBaseProps;
|
|
253
|
+
export declare const _test_SidebarGroupContent: SidebarGroupContentBaseProps;
|
|
254
|
+
export declare const _test_SidebarGroupLabel: SidebarGroupLabelBaseProps;
|
|
255
|
+
export declare const _test_SidebarHeader: SidebarHeaderBaseProps;
|
|
256
|
+
export declare const _test_SidebarInput: SidebarInputBaseProps;
|
|
257
|
+
export declare const _test_SidebarInset: SidebarInsetBaseProps;
|
|
258
|
+
export declare const _test_SidebarMenuAction: SidebarMenuActionBaseProps;
|
|
259
|
+
export declare const _test_SidebarMenuBadge: SidebarMenuBadgeBaseProps;
|
|
260
|
+
export declare const _test_SidebarMenu: SidebarMenuBaseProps;
|
|
261
|
+
export declare const _test_SidebarMenuButton: SidebarMenuButtonBaseProps;
|
|
262
|
+
export declare const _test_SidebarMenuItem: SidebarMenuItemBaseProps;
|
|
263
|
+
export declare const _test_SidebarMenuSkeleton: SidebarMenuSkeletonBaseProps;
|
|
264
|
+
export declare const _test_SidebarMenuSub: SidebarMenuSubBaseProps;
|
|
265
|
+
export declare const _test_SidebarMenuSubButton: SidebarMenuSubButtonBaseProps;
|
|
266
|
+
export declare const _test_SidebarMenuSubItem: SidebarMenuSubItemBaseProps;
|
|
267
|
+
export declare const _test_SidebarProvider: SidebarProviderBaseProps;
|
|
268
|
+
export declare const _test_SidebarRail: SidebarRailBaseProps;
|
|
269
|
+
export declare const _test_SidebarSeparator: SidebarSeparatorBaseProps;
|
|
270
|
+
export declare const _test_SidebarTrigger: SidebarTriggerBaseProps;
|
|
1
271
|
export {};
|
|
@@ -3,7 +3,7 @@ import { AlertBaseProps } from '../../ui-core/src';
|
|
|
3
3
|
import { ClassProp } from 'class-variance-authority/types';
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
declare const alertVariants: (props?: ({
|
|
6
|
-
variant?: "default" | "destructive" | null | undefined;
|
|
6
|
+
variant?: "default" | "destructive" | "warning" | "info" | null | undefined;
|
|
7
7
|
} & ClassProp) | undefined) => string;
|
|
8
8
|
declare function Alert({ className, variant, ...props }: React.ComponentProps<'div'> & VariantProps<typeof alertVariants>): import("react/jsx-runtime").JSX.Element;
|
|
9
9
|
declare function AlertTitle({ className, ...props }: React.ComponentProps<'div'>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";"use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./rolldown-runtime-mLOUI7ql.js"),t=require("./vendor-UfQavLF9.js"),n=require("./utils-D7tt_q-u.js");let r=require("react");r=e.r(r);var i=t.Jr(),a=r.createContext(null);function o(){let e=r.useContext(a);if(!e)throw Error(`TOC components must be used within a TableOfContents provider`);return e}function s({children:e,className:t,activeId:o,minLevel:s=1,maxLevel:u=4,selector:d=`h1, h2, h3, h4, h5, h6`}){let[f,p]=r.useState([]),[m,h]=r.useState(null),g=r.useMemo(()=>f.find(e=>e.id===m)?.text||null,[f,m]),_=r.useCallback(e=>{p(t=>JSON.stringify(t)===JSON.stringify(e)?t:e)},[]),v=r.useMemo(()=>({headings:f,activeId:o||m,activeHeadingText:g,registerHeadings:_,setActiveId:h,config:{minLevel:s,maxLevel:u,selector:d,className:t}}),[f,m,o,g,_,s,u,d,t]);return(0,i.jsx)(a.Provider,{value:v,children:(0,i.jsx)(`div`,{className:n.t(`relative`,t),children:e||(0,i.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,i.jsx)(c,{}),(0,i.jsx)(l,{children:null})]})})})}function c({className:e}){let{headings:t,activeId:a,activeHeadingText:s}=o(),[c,l]=r.useState(!1);if(r.useEffect(()=>{if(!c)return;let e=()=>{l(!1)};return window.addEventListener(`scroll`,e,{passive:!0}),()=>window.removeEventListener(`scroll`,e)},[c]),t.length===0)return null;let u=Math.min(...t.map(e=>e.level)),d=(0,i.jsx)(`ul`,{className:`m-0 list-none text-sm`,children:t.map(e=>{let t=a===e.id,r=`${(e.level-u)*1}rem`;return(0,i.jsx)(`li`,{className:`mt-0 pt-2`,children:(0,i.jsx)(`a`,{href:`#${e.id}`,onClick:()=>l(!1),className:n.t(`hover:text-foreground inline-block no-underline transition-colors`,t?`text-primary font-medium`:`text-muted-foreground`),style:{paddingLeft:r},children:e.text})},e.id)})});return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(`div`,{className:n.t(`bg-background/95 sticky top-0 z-40 border-b backdrop-blur
|
|
1
|
+
"use client";"use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./rolldown-runtime-mLOUI7ql.js"),t=require("./vendor-UfQavLF9.js"),n=require("./utils-D7tt_q-u.js");let r=require("react");r=e.r(r);var i=t.Jr(),a=r.createContext(null);function o(){let e=r.useContext(a);if(!e)throw Error(`TOC components must be used within a TableOfContents provider`);return e}function s({children:e,className:t,activeId:o,minLevel:s=1,maxLevel:u=4,selector:d=`h1, h2, h3, h4, h5, h6`}){let[f,p]=r.useState([]),[m,h]=r.useState(null),g=r.useMemo(()=>f.find(e=>e.id===m)?.text||null,[f,m]),_=r.useCallback(e=>{p(t=>JSON.stringify(t)===JSON.stringify(e)?t:e)},[]),v=r.useMemo(()=>({headings:f,activeId:o||m,activeHeadingText:g,registerHeadings:_,setActiveId:h,config:{minLevel:s,maxLevel:u,selector:d,className:t}}),[f,m,o,g,_,s,u,d,t]);return(0,i.jsx)(a.Provider,{value:v,children:(0,i.jsx)(`div`,{className:n.t(`relative`,t),children:e||(0,i.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,i.jsx)(c,{}),(0,i.jsx)(l,{children:null})]})})})}function c({className:e}){let{headings:t,activeId:a,activeHeadingText:s}=o(),[c,l]=r.useState(!1);if(r.useEffect(()=>{if(!c)return;let e=()=>{l(!1)};return window.addEventListener(`scroll`,e,{passive:!0}),()=>window.removeEventListener(`scroll`,e)},[c]),t.length===0)return null;let u=Math.min(...t.map(e=>e.level)),d=(0,i.jsx)(`ul`,{className:`m-0 list-none text-sm`,children:t.map(e=>{let t=a===e.id,r=`${(e.level-u)*1}rem`;return(0,i.jsx)(`li`,{className:`mt-0 pt-2`,children:(0,i.jsx)(`a`,{href:`#${e.id}`,onClick:()=>l(!1),className:n.t(`hover:text-foreground inline-block no-underline transition-colors`,t?`text-primary font-medium`:`text-muted-foreground`),style:{paddingLeft:r},children:e.text})},e.id)})});return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(`div`,{className:n.t(`bg-background/95 sticky top-0 z-40 border-b backdrop-blur lg:hidden`,e),children:[(0,i.jsxs)(`button`,{onClick:()=>l(!c),className:`flex w-full items-center justify-between px-4 py-3 text-left`,children:[(0,i.jsxs)(`div`,{className:`flex items-center gap-2 overflow-hidden`,children:[(0,i.jsx)(`span`,{className:`text-muted-foreground text-xs font-semibold tracking-wider uppercase`,children:`On this page:`}),(0,i.jsx)(`span`,{className:`truncate text-sm font-medium`,children:s||`Overview`})]}),(0,i.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,className:n.t(`shrink-0 transition-transform duration-200`,c&&`rotate-180`),children:(0,i.jsx)(`path`,{d:`m6 9 6 6 6-6`})})]}),c&&(0,i.jsx)(`div`,{className:`bg-background border-t px-4 pt-2 pb-6`,children:(0,i.jsx)(`nav`,{"aria-label":`Table of contents mobile`,children:d})})]}),(0,i.jsx)(`nav`,{className:n.t(`hidden lg:block`,e),"aria-label":`Table of contents`,children:d})]})}function l({children:e,className:t}){let{registerHeadings:a,setActiveId:s,config:c}=o(),l=r.useRef(null);return r.useEffect(()=>{let e=l.current;if(!e)return;let t=()=>{let t=Array.from(e.querySelectorAll(c.selector||`h1, h2, h3, h4, h5, h6`)).filter(e=>{let t=parseInt(e.tagName.charAt(1),10);return t>=(c.minLevel??1)&&t<=(c.maxLevel??4)});return a(t.map(e=>(e.id||=n.n(e.textContent||`heading`),{id:e.id,text:e.textContent||``,level:parseInt(e.tagName.charAt(1),10)}))),t},r=t(),i=new IntersectionObserver(e=>{e.forEach(e=>{e.isIntersecting&&s(e.target.id)})},{rootMargin:`0px 0px -80% 0px`,threshold:.1});r.forEach(e=>i.observe(e));let o=new MutationObserver(()=>{let e=t();i.disconnect(),e.forEach(e=>i.observe(e))});return o.observe(e,{childList:!0,subtree:!0,characterData:!0}),()=>{i.disconnect(),o.disconnect()}},[c.selector,c.minLevel,c.maxLevel,a,s]),(0,i.jsx)(`div`,{ref:l,className:t,children:e})}s.List=c,s.Content=l,exports.TableOfContents=s,exports.TableOfContentsContent=l,exports.TableOfContentsList=c;
|
|
2
2
|
//# sourceMappingURL=table-of-contents.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table-of-contents.cjs","names":[],"sources":["../packages/ui-web/src/table-of-contents.tsx"],"sourcesContent":["'use client';\n\nimport {\n HeadingItem,\n TableOfContentsBaseProps,\n TableOfContentsContentBaseProps,\n TableOfContentsListBaseProps,\n TableOfContentsRootBaseProps,\n} from '@gv-tech/ui-core';\nimport * as React from 'react';\nimport { cn, slugify } from './lib/utils';\n\n// Context for sharing heading data\ninterface TOCContextValue {\n headings: HeadingItem[];\n activeId: string | null;\n activeHeadingText: string | null;\n registerHeadings: (headings: HeadingItem[]) => void;\n setActiveId: (id: string | null) => void;\n config: TableOfContentsBaseProps;\n}\n\nconst TOCContext = React.createContext<TOCContextValue | null>(null);\n\nfunction useTOC() {\n const context = React.useContext(TOCContext);\n if (!context) {\n throw new Error('TOC components must be used within a TableOfContents provider');\n }\n return context;\n}\n\nexport type TableOfContentsProps = TableOfContentsRootBaseProps;\n\n/**\n * Root component that provides the Table of Contents context.\n * Can be used as a wrapper OR standalone.\n * If used as a wrapper: <TableOfContents><List /><Content>{children}</Content></TableOfContents>\n * If used standalone: <TableOfContents /> (requires container ref or defaults to document)\n */\nfunction TableOfContents({\n children,\n className,\n activeId: activeIdOverride,\n minLevel = 1,\n maxLevel = 4,\n selector = 'h1, h2, h3, h4, h5, h6',\n}: TableOfContentsProps) {\n const [headings, setHeadings] = React.useState<HeadingItem[]>([]);\n const [activeId, setActiveId] = React.useState<string | null>(null);\n\n const activeHeadingText = React.useMemo(() => {\n return headings.find((h) => h.id === activeId)?.text || null;\n }, [headings, activeId]);\n\n const registerHeadings = React.useCallback((newHeadings: HeadingItem[]) => {\n setHeadings((prev) => {\n if (JSON.stringify(prev) === JSON.stringify(newHeadings)) {\n return prev;\n }\n return newHeadings;\n });\n }, []);\n\n const value = React.useMemo(\n () => ({\n headings,\n activeId: activeIdOverride || activeId,\n activeHeadingText,\n registerHeadings,\n setActiveId,\n config: { minLevel, maxLevel, selector, className },\n }),\n [\n headings,\n activeId,\n activeIdOverride,\n activeHeadingText,\n registerHeadings,\n minLevel,\n maxLevel,\n selector,\n className,\n ],\n );\n\n return (\n <TOCContext.Provider value={value}>\n <div className={cn('relative', className)}>\n {children || (\n <div className=\"flex flex-col gap-4\">\n <TableOfContentsList />\n <TableOfContentsContent>{null}</TableOfContentsContent>\n </div>\n )}\n </div>\n </TOCContext.Provider>\n );\n}\n\n/**\n * Renders the actual list of links.\n */\nfunction TableOfContentsList({ className }: TableOfContentsListBaseProps) {\n const { headings, activeId, activeHeadingText } = useTOC();\n const [isOpen, setIsOpen] = React.useState(false);\n\n // Auto-collapse on scroll\n React.useEffect(() => {\n if (!isOpen) {\n return;\n }\n\n const handleScroll = () => {\n setIsOpen(false);\n };\n\n window.addEventListener('scroll', handleScroll, { passive: true });\n return () => window.removeEventListener('scroll', handleScroll);\n }, [isOpen]);\n\n if (headings.length === 0) {\n return null;\n }\n\n const currentMinLevel = Math.min(...headings.map((h) => h.level));\n\n const listContent = (\n <ul className=\"m-0 list-none text-sm\">\n {headings.map((heading) => {\n const isActive = activeId === heading.id;\n const paddingLeft = `${(heading.level - currentMinLevel) * 1}rem`;\n\n return (\n <li key={heading.id} className=\"mt-0 pt-2\">\n <a\n href={`#${heading.id}`}\n onClick={() => setIsOpen(false)}\n className={cn(\n 'hover:text-foreground inline-block no-underline transition-colors',\n isActive ? 'text-primary font-medium' : 'text-muted-foreground',\n )}\n style={{ paddingLeft }}\n >\n {heading.text}\n </a>\n </li>\n );\n })}\n </ul>\n );\n\n return (\n <>\n {/* Mobile Sticky Header */}\n <div className={cn('bg-background/95 sticky top-0 z-40 border-b backdrop-blur xl:hidden', className)}>\n <button\n onClick={() => setIsOpen(!isOpen)}\n className=\"flex w-full items-center justify-between px-4 py-3 text-left\"\n >\n <div className=\"flex items-center gap-2 overflow-hidden\">\n <span className=\"text-muted-foreground text-xs font-semibold tracking-wider uppercase\">On this page:</span>\n <span className=\"truncate text-sm font-medium\">{activeHeadingText || 'Overview'}</span>\n </div>\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n className={cn('shrink-0 transition-transform duration-200', isOpen && 'rotate-180')}\n >\n <path d=\"m6 9 6 6 6-6\" />\n </svg>\n </button>\n\n {isOpen && (\n <div className=\"bg-background border-t px-4 pt-2 pb-6\">\n <nav aria-label=\"Table of contents mobile\">{listContent}</nav>\n </div>\n )}\n </div>\n\n {/* Desktop Hidden List */}\n <nav className={cn('hidden xl:block', className)} aria-label=\"Table of contents\">\n {listContent}\n </nav>\n </>\n );\n}\n\n/**\n * Wraps the content area and automatically detects headings within it.\n */\nfunction TableOfContentsContent({ children, className }: TableOfContentsContentBaseProps) {\n const { registerHeadings, setActiveId, config } = useTOC();\n const contentRef = React.useRef<HTMLDivElement>(null);\n\n React.useEffect(() => {\n const root = contentRef.current;\n if (!root) {\n return;\n }\n\n const queryHeadings = () => {\n const elements = Array.from(root.querySelectorAll(config.selector || 'h1, h2, h3, h4, h5, h6')).filter(\n (element) => {\n const level = parseInt(element.tagName.charAt(1), 10);\n return level >= (config.minLevel ?? 1) && level <= (config.maxLevel ?? 4);\n },\n );\n\n const headingItems: HeadingItem[] = elements.map((element) => {\n if (!element.id) {\n element.id = slugify(element.textContent || 'heading');\n }\n return {\n id: element.id,\n text: element.textContent || '',\n level: parseInt(element.tagName.charAt(1), 10),\n };\n });\n\n registerHeadings(headingItems);\n return elements;\n };\n\n // Initial query\n const elements = queryHeadings();\n\n // Intersection Observer for active ID\n const observer = new IntersectionObserver(\n (entries) => {\n entries.forEach((entry) => {\n if (entry.isIntersecting) {\n setActiveId(entry.target.id);\n }\n });\n },\n {\n rootMargin: '0px 0px -80% 0px',\n threshold: 0.1,\n },\n );\n\n elements.forEach((el) => observer.observe(el));\n\n // Mutation Observer for dynamic content\n const mutationObserver = new MutationObserver(() => {\n const newElements = queryHeadings();\n observer.disconnect();\n newElements.forEach((el) => observer.observe(el));\n });\n\n mutationObserver.observe(root, {\n childList: true,\n subtree: true,\n characterData: true,\n });\n\n return () => {\n observer.disconnect();\n mutationObserver.disconnect();\n };\n }, [config.selector, config.minLevel, config.maxLevel, registerHeadings, setActiveId]);\n\n return (\n <div ref={contentRef} className={className}>\n {children}\n </div>\n );\n}\n\nTableOfContents.List = TableOfContentsList;\nTableOfContents.Content = TableOfContentsContent;\n\nexport type {\n TableOfContentsContentBaseProps as TableOfContentsContentProps,\n TableOfContentsListBaseProps as TableOfContentsListProps,\n} from '@gv-tech/ui-core';\nexport { TableOfContents, TableOfContentsContent, TableOfContentsList };\n"],"mappings":"+PAsBM,EAAa,EAAM,cAAsC,IAAI,EAEnE,SAAS,GAAS,CAChB,IAAM,EAAU,EAAM,WAAW,CAAU,EAC3C,GAAI,CAAC,EACH,MAAU,MAAM,+DAA+D,EAEjF,OAAO,CACT,CAUA,SAAS,EAAgB,CACvB,WACA,YACA,SAAU,EACV,WAAW,EACX,WAAW,EACX,WAAW,0BACY,CACvB,GAAM,CAAC,EAAU,GAAe,EAAM,SAAwB,CAAC,CAAC,EAC1D,CAAC,EAAU,GAAe,EAAM,SAAwB,IAAI,EAE5D,EAAoB,EAAM,YACvB,EAAS,KAAM,GAAM,EAAE,KAAO,CAAQ,GAAG,MAAQ,KACvD,CAAC,EAAU,CAAQ,CAAC,EAEjB,EAAmB,EAAM,YAAa,GAA+B,CACzE,EAAa,GACP,KAAK,UAAU,CAAI,IAAM,KAAK,UAAU,CAAW,EAC9C,EAEF,CACR,CACH,EAAG,CAAC,CAAC,EAEC,EAAQ,EAAM,aACX,CACL,WACA,SAAU,GAAoB,EAC9B,oBACA,mBACA,cACA,OAAQ,CAAE,WAAU,WAAU,WAAU,WAAU,CACpD,GACA,CACE,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,CACF,CACF,EAEA,OACE,EAAA,EAAA,KAAC,EAAW,SAAZ,CAA4B,kBAC1B,EAAA,EAAA,KAAC,MAAD,CAAK,UAAW,EAAA,EAAG,WAAY,CAAS,WACrC,IACC,EAAA,EAAA,MAAC,MAAD,CAAK,UAAU,+BAAf,EACE,EAAA,EAAA,KAAC,EAAD,CAAsB,CAAA,GACtB,EAAA,EAAA,KAAC,EAAD,CAAA,SAAyB,IAA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EAGM,EAAW,EAAc,EAGzB,EAAW,IAAI,qBAClB,GAAY,CACX,EAAQ,QAAS,GAAU,CACrB,EAAM,gBACR,EAAY,EAAM,OAAO,EAAE,CAE/B,CAAC,CACH,EACA,CACE,WAAY,mBACZ,UAAW,EACb,CACF,EAEA,EAAS,QAAS,GAAO,EAAS,QAAQ,CAAE,CAAC,EAG7C,IAAM,EAAmB,IAAI,qBAAuB,CAClD,IAAM,EAAc,EAAc,EAClC,EAAS,WAAW,EACpB,EAAY,QAAS,GAAO,EAAS,QAAQ,CAAE,CAAC,CAClD,CAAC,EAQD,OANA,EAAiB,QAAQ,EAAM,CAC7B,UAAW,GACX,QAAS,GACT,cAAe,EACjB,CAAC,MAEY,CACX,EAAS,WAAW,EACpB,EAAiB,WAAW,CAC9B,CACF,EAAG,CAAC,EAAO,SAAU,EAAO,SAAU,EAAO,SAAU,EAAkB,CAAW,CAAC,GAGnF,EAAA,EAAA,KAAC,MAAD,CAAK,IAAK,EAAuB,YAC9B,UACE,CAAA,CAET,CAEA,EAAgB,KAAO,EACvB,EAAgB,QAAU"}
|
|
1
|
+
{"version":3,"file":"table-of-contents.cjs","names":[],"sources":["../packages/ui-web/src/table-of-contents.tsx"],"sourcesContent":["'use client';\n\nimport {\n HeadingItem,\n TableOfContentsBaseProps,\n TableOfContentsContentBaseProps,\n TableOfContentsListBaseProps,\n TableOfContentsRootBaseProps,\n} from '@gv-tech/ui-core';\nimport * as React from 'react';\nimport { cn, slugify } from './lib/utils';\n\n// Context for sharing heading data\ninterface TOCContextValue {\n headings: HeadingItem[];\n activeId: string | null;\n activeHeadingText: string | null;\n registerHeadings: (headings: HeadingItem[]) => void;\n setActiveId: (id: string | null) => void;\n config: TableOfContentsBaseProps;\n}\n\nconst TOCContext = React.createContext<TOCContextValue | null>(null);\n\nfunction useTOC() {\n const context = React.useContext(TOCContext);\n if (!context) {\n throw new Error('TOC components must be used within a TableOfContents provider');\n }\n return context;\n}\n\nexport type TableOfContentsProps = TableOfContentsRootBaseProps;\n\n/**\n * Root component that provides the Table of Contents context.\n * Can be used as a wrapper OR standalone.\n * If used as a wrapper: <TableOfContents><List /><Content>{children}</Content></TableOfContents>\n * If used standalone: <TableOfContents /> (requires container ref or defaults to document)\n */\nfunction TableOfContents({\n children,\n className,\n activeId: activeIdOverride,\n minLevel = 1,\n maxLevel = 4,\n selector = 'h1, h2, h3, h4, h5, h6',\n}: TableOfContentsProps) {\n const [headings, setHeadings] = React.useState<HeadingItem[]>([]);\n const [activeId, setActiveId] = React.useState<string | null>(null);\n\n const activeHeadingText = React.useMemo(() => {\n return headings.find((h) => h.id === activeId)?.text || null;\n }, [headings, activeId]);\n\n const registerHeadings = React.useCallback((newHeadings: HeadingItem[]) => {\n setHeadings((prev) => {\n if (JSON.stringify(prev) === JSON.stringify(newHeadings)) {\n return prev;\n }\n return newHeadings;\n });\n }, []);\n\n const value = React.useMemo(\n () => ({\n headings,\n activeId: activeIdOverride || activeId,\n activeHeadingText,\n registerHeadings,\n setActiveId,\n config: { minLevel, maxLevel, selector, className },\n }),\n [\n headings,\n activeId,\n activeIdOverride,\n activeHeadingText,\n registerHeadings,\n minLevel,\n maxLevel,\n selector,\n className,\n ],\n );\n\n return (\n <TOCContext.Provider value={value}>\n <div className={cn('relative', className)}>\n {children || (\n <div className=\"flex flex-col gap-4\">\n <TableOfContentsList />\n <TableOfContentsContent>{null}</TableOfContentsContent>\n </div>\n )}\n </div>\n </TOCContext.Provider>\n );\n}\n\n/**\n * Renders the actual list of links.\n */\nfunction TableOfContentsList({ className }: TableOfContentsListBaseProps) {\n const { headings, activeId, activeHeadingText } = useTOC();\n const [isOpen, setIsOpen] = React.useState(false);\n\n // Auto-collapse on scroll\n React.useEffect(() => {\n if (!isOpen) {\n return;\n }\n\n const handleScroll = () => {\n setIsOpen(false);\n };\n\n window.addEventListener('scroll', handleScroll, { passive: true });\n return () => window.removeEventListener('scroll', handleScroll);\n }, [isOpen]);\n\n if (headings.length === 0) {\n return null;\n }\n\n const currentMinLevel = Math.min(...headings.map((h) => h.level));\n\n const listContent = (\n <ul className=\"m-0 list-none text-sm\">\n {headings.map((heading) => {\n const isActive = activeId === heading.id;\n const paddingLeft = `${(heading.level - currentMinLevel) * 1}rem`;\n\n return (\n <li key={heading.id} className=\"mt-0 pt-2\">\n <a\n href={`#${heading.id}`}\n onClick={() => setIsOpen(false)}\n className={cn(\n 'hover:text-foreground inline-block no-underline transition-colors',\n isActive ? 'text-primary font-medium' : 'text-muted-foreground',\n )}\n style={{ paddingLeft }}\n >\n {heading.text}\n </a>\n </li>\n );\n })}\n </ul>\n );\n\n return (\n <>\n {/* Mobile Sticky Header */}\n <div className={cn('bg-background/95 sticky top-0 z-40 border-b backdrop-blur lg:hidden', className)}>\n <button\n onClick={() => setIsOpen(!isOpen)}\n className=\"flex w-full items-center justify-between px-4 py-3 text-left\"\n >\n <div className=\"flex items-center gap-2 overflow-hidden\">\n <span className=\"text-muted-foreground text-xs font-semibold tracking-wider uppercase\">On this page:</span>\n <span className=\"truncate text-sm font-medium\">{activeHeadingText || 'Overview'}</span>\n </div>\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n className={cn('shrink-0 transition-transform duration-200', isOpen && 'rotate-180')}\n >\n <path d=\"m6 9 6 6 6-6\" />\n </svg>\n </button>\n\n {isOpen && (\n <div className=\"bg-background border-t px-4 pt-2 pb-6\">\n <nav aria-label=\"Table of contents mobile\">{listContent}</nav>\n </div>\n )}\n </div>\n\n {/* Desktop Hidden List */}\n <nav className={cn('hidden lg:block', className)} aria-label=\"Table of contents\">\n {listContent}\n </nav>\n </>\n );\n}\n\n/**\n * Wraps the content area and automatically detects headings within it.\n */\nfunction TableOfContentsContent({ children, className }: TableOfContentsContentBaseProps) {\n const { registerHeadings, setActiveId, config } = useTOC();\n const contentRef = React.useRef<HTMLDivElement>(null);\n\n React.useEffect(() => {\n const root = contentRef.current;\n if (!root) {\n return;\n }\n\n const queryHeadings = () => {\n const elements = Array.from(root.querySelectorAll(config.selector || 'h1, h2, h3, h4, h5, h6')).filter(\n (element) => {\n const level = parseInt(element.tagName.charAt(1), 10);\n return level >= (config.minLevel ?? 1) && level <= (config.maxLevel ?? 4);\n },\n );\n\n const headingItems: HeadingItem[] = elements.map((element) => {\n if (!element.id) {\n element.id = slugify(element.textContent || 'heading');\n }\n return {\n id: element.id,\n text: element.textContent || '',\n level: parseInt(element.tagName.charAt(1), 10),\n };\n });\n\n registerHeadings(headingItems);\n return elements;\n };\n\n // Initial query\n const elements = queryHeadings();\n\n // Intersection Observer for active ID\n const observer = new IntersectionObserver(\n (entries) => {\n entries.forEach((entry) => {\n if (entry.isIntersecting) {\n setActiveId(entry.target.id);\n }\n });\n },\n {\n rootMargin: '0px 0px -80% 0px',\n threshold: 0.1,\n },\n );\n\n elements.forEach((el) => observer.observe(el));\n\n // Mutation Observer for dynamic content\n const mutationObserver = new MutationObserver(() => {\n const newElements = queryHeadings();\n observer.disconnect();\n newElements.forEach((el) => observer.observe(el));\n });\n\n mutationObserver.observe(root, {\n childList: true,\n subtree: true,\n characterData: true,\n });\n\n return () => {\n observer.disconnect();\n mutationObserver.disconnect();\n };\n }, [config.selector, config.minLevel, config.maxLevel, registerHeadings, setActiveId]);\n\n return (\n <div ref={contentRef} className={className}>\n {children}\n </div>\n );\n}\n\nTableOfContents.List = TableOfContentsList;\nTableOfContents.Content = TableOfContentsContent;\n\nexport type {\n TableOfContentsContentBaseProps as TableOfContentsContentProps,\n TableOfContentsListBaseProps as TableOfContentsListProps,\n} from '@gv-tech/ui-core';\nexport { TableOfContents, TableOfContentsContent, TableOfContentsList };\n"],"mappings":"+PAsBM,EAAa,EAAM,cAAsC,IAAI,EAEnE,SAAS,GAAS,CAChB,IAAM,EAAU,EAAM,WAAW,CAAU,EAC3C,GAAI,CAAC,EACH,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AE,CAAC,CAClD,CAAC,EAQD,OANA,EAAiB,QAAQ,EAAM,CAC7B,UAAW,GACX,QAAS,GACT,cAAe,EACjB,CAAC,MAEY,CACX,EAAS,WAAW,EACpB,EAAiB,WAAW,CAC9B,CACF,EAAG,CAAC,EAAO,SAAU,EAAO,SAAU,EAAO,SAAU,EAAkB,CAAW,CAAC,GAGnF,EAAA,EAAA,KAAC,MAAD,CAAK,IAAK,EAAuB,YAC9B,UACE,CAAA,CAET,CAEA,EAAgB,KAAO,EACvB,EAAgB,QAAU"}
|
|
@@ -73,7 +73,7 @@ function c({ className: e }) {
|
|
|
73
73
|
})
|
|
74
74
|
});
|
|
75
75
|
return /* @__PURE__ */ (0, i.jsxs)(i.Fragment, { children: [/* @__PURE__ */ (0, i.jsxs)("div", {
|
|
76
|
-
className: n("bg-background/95 sticky top-0 z-40 border-b backdrop-blur
|
|
76
|
+
className: n("bg-background/95 sticky top-0 z-40 border-b backdrop-blur lg:hidden", e),
|
|
77
77
|
children: [/* @__PURE__ */ (0, i.jsxs)("button", {
|
|
78
78
|
onClick: () => l(!c),
|
|
79
79
|
className: "flex w-full items-center justify-between px-4 py-3 text-left",
|
|
@@ -107,7 +107,7 @@ function c({ className: e }) {
|
|
|
107
107
|
})
|
|
108
108
|
})]
|
|
109
109
|
}), /* @__PURE__ */ (0, i.jsx)("nav", {
|
|
110
|
-
className: n("hidden
|
|
110
|
+
className: n("hidden lg:block", e),
|
|
111
111
|
"aria-label": "Table of contents",
|
|
112
112
|
children: d
|
|
113
113
|
})] });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table-of-contents.mjs","names":[],"sources":["../packages/ui-web/src/table-of-contents.tsx"],"sourcesContent":["'use client';\n\nimport {\n HeadingItem,\n TableOfContentsBaseProps,\n TableOfContentsContentBaseProps,\n TableOfContentsListBaseProps,\n TableOfContentsRootBaseProps,\n} from '@gv-tech/ui-core';\nimport * as React from 'react';\nimport { cn, slugify } from './lib/utils';\n\n// Context for sharing heading data\ninterface TOCContextValue {\n headings: HeadingItem[];\n activeId: string | null;\n activeHeadingText: string | null;\n registerHeadings: (headings: HeadingItem[]) => void;\n setActiveId: (id: string | null) => void;\n config: TableOfContentsBaseProps;\n}\n\nconst TOCContext = React.createContext<TOCContextValue | null>(null);\n\nfunction useTOC() {\n const context = React.useContext(TOCContext);\n if (!context) {\n throw new Error('TOC components must be used within a TableOfContents provider');\n }\n return context;\n}\n\nexport type TableOfContentsProps = TableOfContentsRootBaseProps;\n\n/**\n * Root component that provides the Table of Contents context.\n * Can be used as a wrapper OR standalone.\n * If used as a wrapper: <TableOfContents><List /><Content>{children}</Content></TableOfContents>\n * If used standalone: <TableOfContents /> (requires container ref or defaults to document)\n */\nfunction TableOfContents({\n children,\n className,\n activeId: activeIdOverride,\n minLevel = 1,\n maxLevel = 4,\n selector = 'h1, h2, h3, h4, h5, h6',\n}: TableOfContentsProps) {\n const [headings, setHeadings] = React.useState<HeadingItem[]>([]);\n const [activeId, setActiveId] = React.useState<string | null>(null);\n\n const activeHeadingText = React.useMemo(() => {\n return headings.find((h) => h.id === activeId)?.text || null;\n }, [headings, activeId]);\n\n const registerHeadings = React.useCallback((newHeadings: HeadingItem[]) => {\n setHeadings((prev) => {\n if (JSON.stringify(prev) === JSON.stringify(newHeadings)) {\n return prev;\n }\n return newHeadings;\n });\n }, []);\n\n const value = React.useMemo(\n () => ({\n headings,\n activeId: activeIdOverride || activeId,\n activeHeadingText,\n registerHeadings,\n setActiveId,\n config: { minLevel, maxLevel, selector, className },\n }),\n [\n headings,\n activeId,\n activeIdOverride,\n activeHeadingText,\n registerHeadings,\n minLevel,\n maxLevel,\n selector,\n className,\n ],\n );\n\n return (\n <TOCContext.Provider value={value}>\n <div className={cn('relative', className)}>\n {children || (\n <div className=\"flex flex-col gap-4\">\n <TableOfContentsList />\n <TableOfContentsContent>{null}</TableOfContentsContent>\n </div>\n )}\n </div>\n </TOCContext.Provider>\n );\n}\n\n/**\n * Renders the actual list of links.\n */\nfunction TableOfContentsList({ className }: TableOfContentsListBaseProps) {\n const { headings, activeId, activeHeadingText } = useTOC();\n const [isOpen, setIsOpen] = React.useState(false);\n\n // Auto-collapse on scroll\n React.useEffect(() => {\n if (!isOpen) {\n return;\n }\n\n const handleScroll = () => {\n setIsOpen(false);\n };\n\n window.addEventListener('scroll', handleScroll, { passive: true });\n return () => window.removeEventListener('scroll', handleScroll);\n }, [isOpen]);\n\n if (headings.length === 0) {\n return null;\n }\n\n const currentMinLevel = Math.min(...headings.map((h) => h.level));\n\n const listContent = (\n <ul className=\"m-0 list-none text-sm\">\n {headings.map((heading) => {\n const isActive = activeId === heading.id;\n const paddingLeft = `${(heading.level - currentMinLevel) * 1}rem`;\n\n return (\n <li key={heading.id} className=\"mt-0 pt-2\">\n <a\n href={`#${heading.id}`}\n onClick={() => setIsOpen(false)}\n className={cn(\n 'hover:text-foreground inline-block no-underline transition-colors',\n isActive ? 'text-primary font-medium' : 'text-muted-foreground',\n )}\n style={{ paddingLeft }}\n >\n {heading.text}\n </a>\n </li>\n );\n })}\n </ul>\n );\n\n return (\n <>\n {/* Mobile Sticky Header */}\n <div className={cn('bg-background/95 sticky top-0 z-40 border-b backdrop-blur xl:hidden', className)}>\n <button\n onClick={() => setIsOpen(!isOpen)}\n className=\"flex w-full items-center justify-between px-4 py-3 text-left\"\n >\n <div className=\"flex items-center gap-2 overflow-hidden\">\n <span className=\"text-muted-foreground text-xs font-semibold tracking-wider uppercase\">On this page:</span>\n <span className=\"truncate text-sm font-medium\">{activeHeadingText || 'Overview'}</span>\n </div>\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n className={cn('shrink-0 transition-transform duration-200', isOpen && 'rotate-180')}\n >\n <path d=\"m6 9 6 6 6-6\" />\n </svg>\n </button>\n\n {isOpen && (\n <div className=\"bg-background border-t px-4 pt-2 pb-6\">\n <nav aria-label=\"Table of contents mobile\">{listContent}</nav>\n </div>\n )}\n </div>\n\n {/* Desktop Hidden List */}\n <nav className={cn('hidden xl:block', className)} aria-label=\"Table of contents\">\n {listContent}\n </nav>\n </>\n );\n}\n\n/**\n * Wraps the content area and automatically detects headings within it.\n */\nfunction TableOfContentsContent({ children, className }: TableOfContentsContentBaseProps) {\n const { registerHeadings, setActiveId, config } = useTOC();\n const contentRef = React.useRef<HTMLDivElement>(null);\n\n React.useEffect(() => {\n const root = contentRef.current;\n if (!root) {\n return;\n }\n\n const queryHeadings = () => {\n const elements = Array.from(root.querySelectorAll(config.selector || 'h1, h2, h3, h4, h5, h6')).filter(\n (element) => {\n const level = parseInt(element.tagName.charAt(1), 10);\n return level >= (config.minLevel ?? 1) && level <= (config.maxLevel ?? 4);\n },\n );\n\n const headingItems: HeadingItem[] = elements.map((element) => {\n if (!element.id) {\n element.id = slugify(element.textContent || 'heading');\n }\n return {\n id: element.id,\n text: element.textContent || '',\n level: parseInt(element.tagName.charAt(1), 10),\n };\n });\n\n registerHeadings(headingItems);\n return elements;\n };\n\n // Initial query\n const elements = queryHeadings();\n\n // Intersection Observer for active ID\n const observer = new IntersectionObserver(\n (entries) => {\n entries.forEach((entry) => {\n if (entry.isIntersecting) {\n setActiveId(entry.target.id);\n }\n });\n },\n {\n rootMargin: '0px 0px -80% 0px',\n threshold: 0.1,\n },\n );\n\n elements.forEach((el) => observer.observe(el));\n\n // Mutation Observer for dynamic content\n const mutationObserver = new MutationObserver(() => {\n const newElements = queryHeadings();\n observer.disconnect();\n newElements.forEach((el) => observer.observe(el));\n });\n\n mutationObserver.observe(root, {\n childList: true,\n subtree: true,\n characterData: true,\n });\n\n return () => {\n observer.disconnect();\n mutationObserver.disconnect();\n };\n }, [config.selector, config.minLevel, config.maxLevel, registerHeadings, setActiveId]);\n\n return (\n <div ref={contentRef} className={className}>\n {children}\n </div>\n );\n}\n\nTableOfContents.List = TableOfContentsList;\nTableOfContents.Content = TableOfContentsContent;\n\nexport type {\n TableOfContentsContentBaseProps as TableOfContentsContentProps,\n TableOfContentsListBaseProps as TableOfContentsListProps,\n} from '@gv-tech/ui-core';\nexport { TableOfContents, TableOfContentsContent, TableOfContentsList };\n"],"mappings":";;;;;;aAsBM,IAAa,EAAM,cAAsC,IAAI;AAEnE,SAAS,IAAS;CAChB,IAAM,IAAU,EAAM,WAAW,CAAU;CAC3C,IAAI,CAAC,GACH,MAAU,MAAM,+DAA+D;CAEjF,OAAO;AACT;AAUA,SAAS,EAAgB,EACvB,aACA,cACA,UAAU,GACV,cAAW,GACX,cAAW,GACX,cAAW,4BACY;CACvB,IAAM,CAAC,GAAU,KAAe,EAAM,SAAwB,CAAC,CAAC,GAC1D,CAAC,GAAU,KAAe,EAAM,SAAwB,IAAI,GAE5D,IAAoB,EAAM,cACvB,EAAS,MAAM,MAAM,EAAE,OAAO,CAAQ,GAAG,QAAQ,MACvD,CAAC,GAAU,CAAQ,CAAC,GAEjB,IAAmB,EAAM,aAAa,MAA+B;EACzE,GAAa,MACP,KAAK,UAAU,CAAI,MAAM,KAAK,UAAU,CAAW,IAC9C,IAEF,CACR;CACH,GAAG,CAAC,CAAC,GAEC,IAAQ,EAAM,eACX;EACL;EACA,UAAU,KAAoB;EAC9B;EACA;EACA;EACA,QAAQ;GAAE;GAAU;GAAU;GAAU;EAAU;CACpD,IACA;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CACF;CAEA,OACE,iBAAA,GAAA,EAAA,KAAC,EAAW,UAAZ;EAA4B;YAC1B,iBAAA,GAAA,EAAA,KAAC,OAAD;GAAK,WAAW,EAAG,YAAY,CAAS;aACrC,KACC,iBAAA,GAAA,EAAA,MAAC,OAAD;IAAK,WAAU;cAAf,CACE,iBAAA,GAAA,EAAA,KAAC,GAAD,CAAsB,CAAA,GACtB,iBAAA,GAAA,EAAA,KAAC,GAAD,EAAA,UAAyB,KAA6B,CAAA,C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,OAAO,CAAC,GAAG,EAAE;GAC/C,EAGe,CAAY,GACtB;EACT,GAGM,IAAW,EAAc,GAGzB,IAAW,IAAI,sBAClB,MAAY;GACX,EAAQ,SAAS,MAAU;IACzB,AAAI,EAAM,kBACR,EAAY,EAAM,OAAO,EAAE;GAE/B,CAAC;EACH,GACA;GACE,YAAY;GACZ,WAAW;EACb,CACF;EAEA,EAAS,SAAS,MAAO,EAAS,QAAQ,CAAE,CAAC;EAG7C,IAAM,IAAmB,IAAI,uBAAuB;GAClD,IAAM,IAAc,EAAc;GAElC,AADA,EAAS,WAAW,GACpB,EAAY,SAAS,MAAO,EAAS,QAAQ,CAAE,CAAC;EAClD,CAAC;EAQD,OANA,EAAiB,QAAQ,GAAM;GAC7B,WAAW;GACX,SAAS;GACT,eAAe;EACjB,CAAC,SAEY;GAEX,AADA,EAAS,WAAW,GACpB,EAAiB,WAAW;EAC9B;CACF,GAAG;EAAC,EAAO;EAAU,EAAO;EAAU,EAAO;EAAU;EAAkB;CAAW,CAAC,GAGnF,iBAAA,GAAA,EAAA,KAAC,OAAD;EAAK,KAAK;EAAuB;EAC9B;CACE,CAAA;AAET;AAEA,EAAgB,OAAO,GACvB,EAAgB,UAAU"}
|
|
1
|
+
{"version":3,"file":"table-of-contents.mjs","names":[],"sources":["../packages/ui-web/src/table-of-contents.tsx"],"sourcesContent":["'use client';\n\nimport {\n HeadingItem,\n TableOfContentsBaseProps,\n TableOfContentsContentBaseProps,\n TableOfContentsListBaseProps,\n TableOfContentsRootBaseProps,\n} from '@gv-tech/ui-core';\nimport * as React from 'react';\nimport { cn, slugify } from './lib/utils';\n\n// Context for sharing heading data\ninterface TOCContextValue {\n headings: HeadingItem[];\n activeId: string | null;\n activeHeadingText: string | null;\n registerHeadings: (headings: HeadingItem[]) => void;\n setActiveId: (id: string | null) => void;\n config: TableOfContentsBaseProps;\n}\n\nconst TOCContext = React.createContext<TOCContextValue | null>(null);\n\nfunction useTOC() {\n const context = React.useContext(TOCContext);\n if (!context) {\n throw new Error('TOC components must be used within a TableOfContents provider');\n }\n return context;\n}\n\nexport type TableOfContentsProps = TableOfContentsRootBaseProps;\n\n/**\n * Root component that provides the Table of Contents context.\n * Can be used as a wrapper OR standalone.\n * If used as a wrapper: <TableOfContents><List /><Content>{children}</Content></TableOfContents>\n * If used standalone: <TableOfContents /> (requires container ref or defaults to document)\n */\nfunction TableOfContents({\n children,\n className,\n activeId: activeIdOverride,\n minLevel = 1,\n maxLevel = 4,\n selector = 'h1, h2, h3, h4, h5, h6',\n}: TableOfContentsProps) {\n const [headings, setHeadings] = React.useState<HeadingItem[]>([]);\n const [activeId, setActiveId] = React.useState<string | null>(null);\n\n const activeHeadingText = React.useMemo(() => {\n return headings.find((h) => h.id === activeId)?.text || null;\n }, [headings, activeId]);\n\n const registerHeadings = React.useCallback((newHeadings: HeadingItem[]) => {\n setHeadings((prev) => {\n if (JSON.stringify(prev) === JSON.stringify(newHeadings)) {\n return prev;\n }\n return newHeadings;\n });\n }, []);\n\n const value = React.useMemo(\n () => ({\n headings,\n activeId: activeIdOverride || activeId,\n activeHeadingText,\n registerHeadings,\n setActiveId,\n config: { minLevel, maxLevel, selector, className },\n }),\n [\n headings,\n activeId,\n activeIdOverride,\n activeHeadingText,\n registerHeadings,\n minLevel,\n maxLevel,\n selector,\n className,\n ],\n );\n\n return (\n <TOCContext.Provider value={value}>\n <div className={cn('relative', className)}>\n {children || (\n <div className=\"flex flex-col gap-4\">\n <TableOfContentsList />\n <TableOfContentsContent>{null}</TableOfContentsContent>\n </div>\n )}\n </div>\n </TOCContext.Provider>\n );\n}\n\n/**\n * Renders the actual list of links.\n */\nfunction TableOfContentsList({ className }: TableOfContentsListBaseProps) {\n const { headings, activeId, activeHeadingText } = useTOC();\n const [isOpen, setIsOpen] = React.useState(false);\n\n // Auto-collapse on scroll\n React.useEffect(() => {\n if (!isOpen) {\n return;\n }\n\n const handleScroll = () => {\n setIsOpen(false);\n };\n\n window.addEventListener('scroll', handleScroll, { passive: true });\n return () => window.removeEventListener('scroll', handleScroll);\n }, [isOpen]);\n\n if (headings.length === 0) {\n return null;\n }\n\n const currentMinLevel = Math.min(...headings.map((h) => h.level));\n\n const listContent = (\n <ul className=\"m-0 list-none text-sm\">\n {headings.map((heading) => {\n const isActive = activeId === heading.id;\n const paddingLeft = `${(heading.level - currentMinLevel) * 1}rem`;\n\n return (\n <li key={heading.id} className=\"mt-0 pt-2\">\n <a\n href={`#${heading.id}`}\n onClick={() => setIsOpen(false)}\n className={cn(\n 'hover:text-foreground inline-block no-underline transition-colors',\n isActive ? 'text-primary font-medium' : 'text-muted-foreground',\n )}\n style={{ paddingLeft }}\n >\n {heading.text}\n </a>\n </li>\n );\n })}\n </ul>\n );\n\n return (\n <>\n {/* Mobile Sticky Header */}\n <div className={cn('bg-background/95 sticky top-0 z-40 border-b backdrop-blur lg:hidden', className)}>\n <button\n onClick={() => setIsOpen(!isOpen)}\n className=\"flex w-full items-center justify-between px-4 py-3 text-left\"\n >\n <div className=\"flex items-center gap-2 overflow-hidden\">\n <span className=\"text-muted-foreground text-xs font-semibold tracking-wider uppercase\">On this page:</span>\n <span className=\"truncate text-sm font-medium\">{activeHeadingText || 'Overview'}</span>\n </div>\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n className={cn('shrink-0 transition-transform duration-200', isOpen && 'rotate-180')}\n >\n <path d=\"m6 9 6 6 6-6\" />\n </svg>\n </button>\n\n {isOpen && (\n <div className=\"bg-background border-t px-4 pt-2 pb-6\">\n <nav aria-label=\"Table of contents mobile\">{listContent}</nav>\n </div>\n )}\n </div>\n\n {/* Desktop Hidden List */}\n <nav className={cn('hidden lg:block', className)} aria-label=\"Table of contents\">\n {listContent}\n </nav>\n </>\n );\n}\n\n/**\n * Wraps the content area and automatically detects headings within it.\n */\nfunction TableOfContentsContent({ children, className }: TableOfContentsContentBaseProps) {\n const { registerHeadings, setActiveId, config } = useTOC();\n const contentRef = React.useRef<HTMLDivElement>(null);\n\n React.useEffect(() => {\n const root = contentRef.current;\n if (!root) {\n return;\n }\n\n const queryHeadings = () => {\n const elements = Array.from(root.querySelectorAll(config.selector || 'h1, h2, h3, h4, h5, h6')).filter(\n (element) => {\n const level = parseInt(element.tagName.charAt(1), 10);\n return level >= (config.minLevel ?? 1) && level <= (config.maxLevel ?? 4);\n },\n );\n\n const headingItems: HeadingItem[] = elements.map((element) => {\n if (!element.id) {\n element.id = slugify(element.textContent || 'heading');\n }\n return {\n id: element.id,\n text: element.textContent || '',\n level: parseInt(element.tagName.charAt(1), 10),\n };\n });\n\n registerHeadings(headingItems);\n return elements;\n };\n\n // Initial query\n const elements = queryHeadings();\n\n // Intersection Observer for active ID\n const observer = new IntersectionObserver(\n (entries) => {\n entries.forEach((entry) => {\n if (entry.isIntersecting) {\n setActiveId(entry.target.id);\n }\n });\n },\n {\n rootMargin: '0px 0px -80% 0px',\n threshold: 0.1,\n },\n );\n\n elements.forEach((el) => observer.observe(el));\n\n // Mutation Observer for dynamic content\n const mutationObserver = new MutationObserver(() => {\n const newElements = queryHeadings();\n observer.disconnect();\n newElements.forEach((el) => observer.observe(el));\n });\n\n mutationObserver.observe(root, {\n childList: true,\n subtree: true,\n characterData: true,\n });\n\n return () => {\n observer.disconnect();\n mutationObserver.disconnect();\n };\n }, [config.selector, config.minLevel, config.maxLevel, registerHeadings, setActiveId]);\n\n return (\n <div ref={contentRef} className={className}>\n {children}\n </div>\n );\n}\n\nTableOfContents.List = TableOfContentsList;\nTableOfContents.Content = TableOfContentsContent;\n\nexport type {\n TableOfContentsContentBaseProps as TableOfContentsContentProps,\n TableOfContentsListBaseProps as TableOfContentsListProps,\n} from '@gv-tech/ui-core';\nexport { TableOfContents, TableOfContentsContent, TableOfContentsList };\n"],"mappings":";;;;;;aAsBM,IAAa,EAAM,cAAsC,I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