@zvk/ui 0.1.3 → 0.1.6
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 +41 -0
- package/README.md +5 -5
- package/dist/components/accordion/accordion.js +4 -4
- package/dist/components/alert/alert.d.ts +5 -0
- package/dist/components/alert/alert.js +8 -4
- package/dist/components/alert/index.d.ts +1 -1
- package/dist/components/alert-dialog/alert-dialog.d.ts +8 -5
- package/dist/components/alert-dialog/alert-dialog.js +26 -13
- package/dist/components/avatar/avatar.js +1 -1
- package/dist/components/badge/badge.js +1 -1
- package/dist/components/breadcrumbs/breadcrumbs.js +3 -3
- package/dist/components/button/button.d.ts +3 -2
- package/dist/components/button/button.js +50 -2
- package/dist/components/calendar/calendar.d.ts +40 -5
- package/dist/components/calendar/calendar.js +17 -5
- package/dist/components/calendar/index.d.ts +1 -1
- package/dist/components/card/card.d.ts +5 -0
- package/dist/components/card/card.js +11 -7
- package/dist/components/card/index.d.ts +1 -1
- package/dist/components/carousel/carousel.js +7 -7
- package/dist/components/checkbox/checkbox.js +4 -4
- package/dist/components/code-block/code-block.js +2 -2
- package/dist/components/collapsible/collapsible.d.ts +3 -2
- package/dist/components/collapsible/collapsible.js +8 -4
- package/dist/components/combobox/combobox.js +6 -5
- package/dist/components/command/command-filter.d.ts +0 -1
- package/dist/components/command/command-filter.js +0 -3
- package/dist/components/command/command.d.ts +11 -4
- package/dist/components/command/command.js +28 -17
- package/dist/components/command/index.d.ts +1 -1
- package/dist/components/context-menu/context-menu.d.ts +17 -6
- package/dist/components/context-menu/context-menu.js +142 -39
- package/dist/components/conversation/conversation.js +11 -11
- package/dist/components/copy-button/copy-button.js +2 -2
- package/dist/components/date-picker/date-picker.js +1 -1
- package/dist/components/dialog/dialog.d.ts +6 -4
- package/dist/components/dialog/dialog.js +22 -12
- package/dist/components/dropdown-menu/dropdown-menu.d.ts +13 -7
- package/dist/components/dropdown-menu/dropdown-menu.js +137 -78
- package/dist/components/empty-state/empty-state.js +1 -1
- package/dist/components/error-boundary/error-boundary.js +1 -1
- package/dist/components/field/field.js +4 -4
- package/dist/components/file-upload-input/file-upload-input.js +2 -2
- package/dist/components/form/form.js +6 -6
- package/dist/components/hover-card/hover-card.d.ts +8 -2
- package/dist/components/hover-card/hover-card.js +13 -7
- package/dist/components/icon-button/icon-button.js +19 -1
- package/dist/components/index.d.ts +10 -10
- package/dist/components/index.js +1 -1
- package/dist/components/input/input.js +1 -1
- package/dist/components/label/label.js +1 -1
- package/dist/components/menubar/menubar.d.ts +24 -5
- package/dist/components/menubar/menubar.js +186 -37
- package/dist/components/pagination/pagination.js +12 -12
- package/dist/components/popover/popover.d.ts +8 -3
- package/dist/components/popover/popover.js +40 -8
- package/dist/components/progress/progress.js +3 -3
- package/dist/components/radio-group/radio-group.js +3 -3
- package/dist/components/responsive-container/responsive-container.js +1 -1
- package/dist/components/scroll-area/scroll-area.js +4 -4
- package/dist/components/sectioned-sidebar-nav/sectioned-sidebar-nav.js +7 -7
- package/dist/components/select/select.js +66 -13
- package/dist/components/separator/separator.js +1 -1
- package/dist/components/sheet/sheet.d.ts +6 -4
- package/dist/components/sheet/sheet.js +29 -16
- package/dist/components/sidebar-shell/sidebar-shell.js +6 -6
- package/dist/components/skeleton/skeleton.js +1 -1
- package/dist/components/slider/slider.js +1 -1
- package/dist/components/spinner/spinner.js +1 -1
- package/dist/components/stat/stat.js +1 -1
- package/dist/components/switch/switch.js +3 -3
- package/dist/components/table/index.d.ts +1 -1
- package/dist/components/table/table.d.ts +5 -0
- package/dist/components/table/table.js +12 -8
- package/dist/components/tabs/tabs.js +4 -4
- package/dist/components/tabs-with-sidebar/tabs-with-sidebar.js +3 -3
- package/dist/components/textarea/textarea.js +1 -1
- package/dist/components/toast/index.d.ts +2 -2
- package/dist/components/toast/index.js +1 -1
- package/dist/components/toast/toast.d.ts +16 -2
- package/dist/components/toast/toast.js +49 -7
- package/dist/components/toggle/toggle.js +1 -1
- package/dist/components/toggle-group/toggle-group.js +1 -1
- package/dist/components/tooltip/tooltip.d.ts +8 -2
- package/dist/components/tooltip/tooltip.js +12 -6
- package/dist/hooks/index.d.ts +2 -2
- package/dist/hooks/use-composed-refs.d.ts +2 -2
- package/dist/hooks/use-controllable-state.d.ts +2 -2
- package/dist/internal/floating/compute-position.js +13 -8
- package/dist/internal/floating/floating-types.d.ts +1 -0
- package/dist/internal/floating/index.d.ts +1 -0
- package/dist/internal/floating/placement-aliases.d.ts +7 -0
- package/dist/internal/floating/placement-aliases.js +13 -0
- package/dist/internal/floating/use-floating-position.js +6 -4
- package/dist/internal/overlay-stack/overlay-stack.js +4 -1
- package/dist/internal/slot/index.d.ts +2 -0
- package/dist/internal/slot/index.js +1 -0
- package/dist/internal/slot/slot.d.ts +6 -0
- package/dist/internal/slot/slot.js +53 -0
- package/dist/styles.css +2079 -2015
- package/dist/tokens/index.d.ts +2 -2
- package/dist/tokens/index.js +1 -1
- package/dist/tokens/token-types.d.ts +5 -5
- package/dist/tokens/tokens.d.ts +16 -10
- package/dist/tokens/tokens.js +16 -10
- package/dist/utils/cn.d.ts +2 -2
- package/dist/utils/index.d.ts +1 -1
- package/package.json +13 -12
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { Accordion } from "./accordion/index.js";
|
|
2
2
|
export type { AccordionContentProps, AccordionItemProps, AccordionProps, AccordionTriggerProps, AccordionType, AccordionValue } from "./accordion/index.js";
|
|
3
3
|
export { Alert } from "./alert/index.js";
|
|
4
|
-
export type { AlertDescriptionProps, AlertProps, AlertRoot, AlertTitleProps, AlertTone } from "./alert/index.js";
|
|
4
|
+
export type { AlertActionProps, AlertDescriptionProps, AlertProps, AlertRoot, AlertTitleProps, AlertTone } from "./alert/index.js";
|
|
5
5
|
export { Avatar } from "./avatar/index.js";
|
|
6
6
|
export type { AvatarProps, AvatarShape, AvatarSize } from "./avatar/index.js";
|
|
7
7
|
export { Badge } from "./badge/index.js";
|
|
@@ -11,9 +11,9 @@ export type { BreadcrumbsItemProps, BreadcrumbsProps } from "./breadcrumbs/index
|
|
|
11
11
|
export { Button } from "./button/index.js";
|
|
12
12
|
export type { ButtonProps, ButtonSize, ButtonVariant } from "./button/index.js";
|
|
13
13
|
export { Card } from "./card/index.js";
|
|
14
|
-
export type { CardDescriptionProps, CardPadding, CardProps, CardSlotProps, CardTitleProps, CardVariant } from "./card/index.js";
|
|
14
|
+
export type { CardActionProps, CardDescriptionProps, CardPadding, CardProps, CardSlotProps, CardTitleProps, CardVariant } from "./card/index.js";
|
|
15
15
|
export { Calendar } from "./calendar/index.js";
|
|
16
|
-
export type { CalendarProps } from "./calendar/index.js";
|
|
16
|
+
export type { CalendarClassNames, CalendarMode, CalendarNativeProps, CalendarProps, CalendarSingleProps } from "./calendar/index.js";
|
|
17
17
|
export { Carousel } from "./carousel/index.js";
|
|
18
18
|
export type { CarouselApi, CarouselButtonProps, CarouselOrientation, CarouselPageProps, CarouselProps, CarouselSlideProps, CarouselTrackProps, CarouselViewportProps } from "./carousel/index.js";
|
|
19
19
|
export { Checkbox } from "./checkbox/index.js";
|
|
@@ -29,7 +29,7 @@ export type { DatePickerProps } from "./date-picker/index.js";
|
|
|
29
29
|
export { Dialog } from "./dialog/index.js";
|
|
30
30
|
export type { DialogCloseProps, DialogContentProps, DialogDescriptionProps, DialogFooterProps, DialogHeaderProps, DialogOverlayProps, DialogProps, DialogTitleProps, DialogTriggerProps } from "./dialog/index.js";
|
|
31
31
|
export { DropdownMenu } from "./dropdown-menu/index.js";
|
|
32
|
-
export type { DropdownMenuContentProps, DropdownMenuItemProps, DropdownMenuProps, DropdownMenuSeparatorProps, DropdownMenuTriggerProps } from "./dropdown-menu/index.js";
|
|
32
|
+
export type { DropdownMenuCheckboxItemProps, DropdownMenuContentProps, DropdownMenuItemProps, DropdownMenuLabelProps, DropdownMenuProps, DropdownMenuRadioGroupProps, DropdownMenuRadioItemProps, DropdownMenuSeparatorProps, DropdownMenuShortcutProps, DropdownMenuSubProps, DropdownMenuTriggerProps } from "./dropdown-menu/index.js";
|
|
33
33
|
export { AlertDialog } from "./alert-dialog/index.js";
|
|
34
34
|
export type { AlertDialogActionProps, AlertDialogCancelProps, AlertDialogContentProps, AlertDialogDescriptionProps, AlertDialogFooterProps, AlertDialogProps, AlertDialogTitleProps, AlertDialogTriggerProps } from "./alert-dialog/index.js";
|
|
35
35
|
export { Sheet } from "./sheet/index.js";
|
|
@@ -37,13 +37,13 @@ export type { SheetCloseProps, SheetContentProps, SheetDescriptionProps, SheetFo
|
|
|
37
37
|
export { ScrollArea } from "./scroll-area/index.js";
|
|
38
38
|
export type { ScrollAreaOrientation, ScrollAreaProps, ScrollAreaType, ScrollBarProps } from "./scroll-area/index.js";
|
|
39
39
|
export { Command, CommandDialog } from "./command/index.js";
|
|
40
|
-
export type { CommandDialogProps, CommandEmptyProps, CommandGroupProps, CommandInputProps, CommandItemProps, CommandListProps, CommandProps, CommandSeparatorProps } from "./command/index.js";
|
|
40
|
+
export type { CommandDialogProps, CommandEmptyProps, CommandGroupProps, CommandInputProps, CommandItemProps, CommandListProps, CommandProps, CommandSeparatorProps, CommandShortcutProps } from "./command/index.js";
|
|
41
41
|
export { Combobox } from "./combobox/index.js";
|
|
42
42
|
export type { ComboboxOption, ComboboxProps } from "./combobox/index.js";
|
|
43
43
|
export { ContextMenu } from "./context-menu/index.js";
|
|
44
|
-
export type { ContextMenuContentProps, ContextMenuItemProps, ContextMenuProps, ContextMenuSeparatorProps, ContextMenuTriggerProps } from "./context-menu/index.js";
|
|
44
|
+
export type { ContextMenuCheckboxItemProps, ContextMenuContentProps, ContextMenuItemProps, ContextMenuLabelProps, ContextMenuProps, ContextMenuSeparatorProps, ContextMenuTriggerProps } from "./context-menu/index.js";
|
|
45
45
|
export { Menubar } from "./menubar/index.js";
|
|
46
|
-
export type { MenubarContentProps, MenubarItemProps, MenubarMenuProps, MenubarProps, MenubarSeparatorProps, MenubarTriggerProps } from "./menubar/index.js";
|
|
46
|
+
export type { MenubarContentProps, MenubarItemProps, MenubarLabelProps, MenubarMenuProps, MenubarProps, MenubarSeparatorProps, MenubarShortcutProps, MenubarTriggerProps } from "./menubar/index.js";
|
|
47
47
|
export { EmptyState } from "./empty-state/index.js";
|
|
48
48
|
export type { EmptyStateAlign, EmptyStateProps, EmptyStateSize } from "./empty-state/index.js";
|
|
49
49
|
export { ErrorBoundary, ErrorFallback } from "./error-boundary/index.js";
|
|
@@ -91,15 +91,15 @@ export type { StatProps, StatSize, StatTone } from "./stat/index.js";
|
|
|
91
91
|
export { Switch } from "./switch/index.js";
|
|
92
92
|
export type { SwitchProps, SwitchSize } from "./switch/index.js";
|
|
93
93
|
export { Table } from "./table/index.js";
|
|
94
|
-
export type { TableBodyProps, TableCaptionProps, TableCellProps, TableFooterProps, TableHeadProps, TableHeaderProps, TableProps, TableRowProps } from "./table/index.js";
|
|
94
|
+
export type { TableBodyProps, TableCaptionProps, TableCellProps, TableContainerProps, TableFooterProps, TableHeadProps, TableHeaderProps, TableProps, TableRowProps } from "./table/index.js";
|
|
95
95
|
export { Tabs } from "./tabs/index.js";
|
|
96
96
|
export type { TabsActivationMode, TabsContentProps, TabsListProps, TabsOrientation, TabsProps, TabsTriggerProps } from "./tabs/index.js";
|
|
97
97
|
export { TabsWithSidebar } from "./tabs-with-sidebar/index.js";
|
|
98
98
|
export type { TabsWithSidebarPanelProps, TabsWithSidebarProps, TabsWithSidebarSidebarProps, TabsWithSidebarWidth } from "./tabs-with-sidebar/index.js";
|
|
99
99
|
export { Textarea } from "./textarea/index.js";
|
|
100
100
|
export type { TextareaProps, TextareaSize } from "./textarea/index.js";
|
|
101
|
-
export { createToastController, Toast, ToastProvider, ToastViewport, useToast } from "./toast/index.js";
|
|
102
|
-
export type { ToastActionProps, ToastCloseProps, ToastController, ToastInput, ToastOptions, ToastPlacement, ToastProviderProps, ToastProps, ToastTextProps, ToastTone, ToastViewportProps } from "./toast/index.js";
|
|
101
|
+
export { createToastController, toast, Toast, Toaster, ToastProvider, ToastViewport, useToast } from "./toast/index.js";
|
|
102
|
+
export type { ToasterPosition, ToasterProps, ToastActionInput, ToastActionProps, ToastCloseProps, ToastController, ToastInput, ToastOptions, ToastPlacement, ToastProviderProps, ToastProps, ToastTextProps, ToastTone, ToastViewportProps } from "./toast/index.js";
|
|
103
103
|
export { Tooltip } from "./tooltip/index.js";
|
|
104
104
|
export type { TooltipProps } from "./tooltip/index.js";
|
|
105
105
|
export { Toggle } from "./toggle/index.js";
|
package/dist/components/index.js
CHANGED
|
@@ -48,7 +48,7 @@ export { Table } from "./table/index.js";
|
|
|
48
48
|
export { Tabs } from "./tabs/index.js";
|
|
49
49
|
export { TabsWithSidebar } from "./tabs-with-sidebar/index.js";
|
|
50
50
|
export { Textarea } from "./textarea/index.js";
|
|
51
|
-
export { createToastController, Toast, ToastProvider, ToastViewport, useToast } from "./toast/index.js";
|
|
51
|
+
export { createToastController, toast, Toast, Toaster, ToastProvider, ToastViewport, useToast } from "./toast/index.js";
|
|
52
52
|
export { Tooltip } from "./tooltip/index.js";
|
|
53
53
|
export { Toggle } from "./toggle/index.js";
|
|
54
54
|
export { ToggleGroup } from "./toggle-group/index.js";
|
|
@@ -19,7 +19,7 @@ export function Input({ "aria-describedby": ariaDescribedBy, className, descript
|
|
|
19
19
|
const descriptionId = hasDescription ? `${inputId}-description` : undefined;
|
|
20
20
|
const errorId = hasError ? `${inputId}-error` : undefined;
|
|
21
21
|
const describedBy = joinIds(ariaDescribedBy, descriptionId, errorId);
|
|
22
|
-
const input = (_jsx("input", { ...props, ref: ref, "aria-describedby": describedBy, "aria-invalid": invalidState ? true : undefined, className: cn("
|
|
22
|
+
const input = (_jsx("input", { ...props, ref: ref, "aria-describedby": describedBy, "aria-invalid": invalidState ? true : undefined, className: cn("zvk-ui-input", className), "data-disabled": disabled ? "true" : undefined, "data-invalid": invalidState ? "true" : undefined, "data-required": required ? "true" : undefined, "data-size": size, disabled: disabled, id: inputId, required: required }));
|
|
23
23
|
if (!hasLabel && !hasDescription && !hasError) {
|
|
24
24
|
return input;
|
|
25
25
|
}
|
|
@@ -2,5 +2,5 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import { cn } from "../../utils/cn.js";
|
|
4
4
|
export function Label({ children, className, disabled, ref, required, size = "md", ...props }) {
|
|
5
|
-
return (_jsx("label", { ...props, ref: ref, className: cn("
|
|
5
|
+
return (_jsx("label", { ...props, ref: ref, className: cn("zvk-ui-label", className), "data-disabled": disabled ? "true" : undefined, "data-required": required ? "true" : undefined, "data-size": size, children: children }));
|
|
6
6
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
+
import type { FloatingAlign, FloatingSide } from "../../internal/floating/placement-aliases.js";
|
|
2
3
|
export interface MenubarProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
3
4
|
defaultValue?: string;
|
|
4
5
|
onValueChange?: (value: string | undefined) => void;
|
|
@@ -10,14 +11,28 @@ export interface MenubarMenuProps {
|
|
|
10
11
|
value: string;
|
|
11
12
|
}
|
|
12
13
|
export interface MenubarTriggerProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
13
|
-
|
|
14
|
+
asChild?: boolean;
|
|
15
|
+
ref?: React.Ref<HTMLButtonElement | HTMLElement>;
|
|
14
16
|
}
|
|
15
17
|
export interface MenubarContentProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
18
|
+
side?: FloatingSide;
|
|
19
|
+
align?: FloatingAlign;
|
|
20
|
+
alignOffset?: number;
|
|
21
|
+
sideOffset?: number;
|
|
16
22
|
ref?: React.Ref<HTMLDivElement>;
|
|
17
23
|
}
|
|
18
24
|
export interface MenubarItemProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
25
|
+
asChild?: boolean;
|
|
19
26
|
onSelect?: (event: React.SyntheticEvent<HTMLElement>) => void;
|
|
20
|
-
ref?: React.Ref<HTMLButtonElement>;
|
|
27
|
+
ref?: React.Ref<HTMLButtonElement | HTMLElement>;
|
|
28
|
+
}
|
|
29
|
+
export interface MenubarCheckboxItemProps extends MenubarItemProps {
|
|
30
|
+
checked?: boolean;
|
|
31
|
+
defaultChecked?: boolean;
|
|
32
|
+
onCheckedChange?: (checked: boolean) => void;
|
|
33
|
+
}
|
|
34
|
+
export interface MenubarRadioItemProps extends MenubarItemProps {
|
|
35
|
+
checked?: boolean;
|
|
21
36
|
}
|
|
22
37
|
export interface MenubarSeparatorProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
23
38
|
ref?: React.Ref<HTMLDivElement>;
|
|
@@ -30,17 +45,21 @@ export interface MenubarShortcutProps extends React.HTMLAttributes<HTMLSpanEleme
|
|
|
30
45
|
}
|
|
31
46
|
declare function MenubarRoot({ children, className, defaultValue, onKeyDown, onValueChange, ref, value, ...props }: MenubarProps): React.JSX.Element;
|
|
32
47
|
declare function MenubarMenu({ children, value }: MenubarMenuProps): React.JSX.Element;
|
|
33
|
-
declare function MenubarTrigger({ children, className, disabled, onClick, onKeyDown, ref, type, ...props }: MenubarTriggerProps): React.JSX.Element;
|
|
34
|
-
declare function MenubarContent({ children, className, onKeyDown, ref, ...props }: MenubarContentProps): React.JSX.Element | null;
|
|
35
|
-
declare function MenubarItem({ children, className, disabled, onClick, onKeyDown, onSelect, ref, type, ...props }: MenubarItemProps): React.JSX.Element;
|
|
48
|
+
declare function MenubarTrigger({ asChild, children, className, disabled, onClick, onKeyDown, ref, type, ...props }: MenubarTriggerProps): React.JSX.Element;
|
|
49
|
+
declare function MenubarContent({ align, alignOffset: _alignOffset, children, className, onKeyDown, ref, side, sideOffset: _sideOffset, ...props }: MenubarContentProps): React.JSX.Element | null;
|
|
50
|
+
declare function MenubarItem({ asChild, children, className, disabled, onClick, onKeyDown, onSelect, ref, type, ...props }: MenubarItemProps): React.JSX.Element;
|
|
51
|
+
declare function MenubarCheckboxItem({ asChild, checked, children, className, defaultChecked, disabled, onCheckedChange, onClick, onKeyDown, onSelect, ref, type, ...props }: MenubarCheckboxItemProps): React.JSX.Element;
|
|
52
|
+
declare function MenubarRadioItem({ asChild, checked, children, className, disabled, onClick, onKeyDown, onSelect, ref, type, ...props }: MenubarRadioItemProps): React.JSX.Element;
|
|
36
53
|
declare function MenubarSeparator({ className, ref, ...props }: MenubarSeparatorProps): React.JSX.Element;
|
|
37
54
|
declare function MenubarLabel({ className, ref, ...props }: MenubarLabelProps): React.JSX.Element;
|
|
38
55
|
declare function MenubarShortcut({ className, ref, ...props }: MenubarShortcutProps): React.JSX.Element;
|
|
39
56
|
type MenubarComponent = typeof MenubarRoot & {
|
|
57
|
+
CheckboxItem: typeof MenubarCheckboxItem;
|
|
40
58
|
Content: typeof MenubarContent;
|
|
41
59
|
Item: typeof MenubarItem;
|
|
42
60
|
Label: typeof MenubarLabel;
|
|
43
61
|
Menu: typeof MenubarMenu;
|
|
62
|
+
RadioItem: typeof MenubarRadioItem;
|
|
44
63
|
Separator: typeof MenubarSeparator;
|
|
45
64
|
Shortcut: typeof MenubarShortcut;
|
|
46
65
|
Trigger: typeof MenubarTrigger;
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import { composeEventHandlers } from "../../utils/compose-event-handlers.js";
|
|
5
5
|
import { cn } from "../../utils/cn.js";
|
|
6
6
|
import { useControllableState } from "../../hooks/use-controllable-state.js";
|
|
7
7
|
import { createCollection } from "../../internal/collection/index.js";
|
|
8
8
|
import { DismissableLayer } from "../../internal/dismissable-layer/index.js";
|
|
9
|
+
import { placementFromSideAlign, placementParts } from "../../internal/floating/placement-aliases.js";
|
|
9
10
|
import { Portal } from "../../internal/portal/index.js";
|
|
11
|
+
import { Slot } from "../../internal/slot/index.js";
|
|
10
12
|
const MenubarContext = React.createContext(null);
|
|
11
13
|
const MenuContext = React.createContext(null);
|
|
12
14
|
function useMenubarContext(calledBy) {
|
|
@@ -44,6 +46,18 @@ function activeIndex(records) {
|
|
|
44
46
|
const enabled = records.filter((record) => record.data.disabled !== true && record.data.ref !== null);
|
|
45
47
|
return enabled.findIndex((record) => record.data.ref === document.activeElement);
|
|
46
48
|
}
|
|
49
|
+
function setComposedRef(internalRef, externalRef, node) {
|
|
50
|
+
internalRef.current = node;
|
|
51
|
+
if (typeof externalRef === "function") {
|
|
52
|
+
externalRef(node);
|
|
53
|
+
}
|
|
54
|
+
else if (externalRef !== undefined && externalRef !== null) {
|
|
55
|
+
externalRef.current = node;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
function isActivationKey(key) {
|
|
59
|
+
return key === "Enter" || key === " " || key === "Space" || key === "Spacebar";
|
|
60
|
+
}
|
|
47
61
|
function MenubarRoot({ children, className, defaultValue, onKeyDown, onValueChange, ref, value, ...props }) {
|
|
48
62
|
const [openValue, setOpenValue] = useControllableState({
|
|
49
63
|
...(value !== undefined ? { value } : {}),
|
|
@@ -65,7 +79,7 @@ function MenubarRoot({ children, className, defaultValue, onKeyDown, onValueChan
|
|
|
65
79
|
setOpenValue,
|
|
66
80
|
unregisterTrigger
|
|
67
81
|
}), [getTriggers, openValue, registerTrigger, setOpenValue, unregisterTrigger]);
|
|
68
|
-
return (_jsx(MenubarContext.Provider, { value: contextValue, children: _jsx("div", { ...props, ref: ref, role: "menubar", className: cn("
|
|
82
|
+
return (_jsx(MenubarContext.Provider, { value: contextValue, children: _jsx("div", { ...props, ref: ref, role: "menubar", className: cn("zvk-ui-menubar", className), onKeyDown: composeEventHandlers(onKeyDown, (event) => {
|
|
69
83
|
const triggers = getTriggers();
|
|
70
84
|
const index = activeIndex(triggers);
|
|
71
85
|
if (event.key === "ArrowRight") {
|
|
@@ -112,7 +126,7 @@ function MenubarMenu({ children, value }) {
|
|
|
112
126
|
}, [getItems, open]);
|
|
113
127
|
return _jsx(MenuContext.Provider, { value: contextValue, children: children });
|
|
114
128
|
}
|
|
115
|
-
function MenubarTrigger({ children, className, disabled, onClick, onKeyDown, ref, type = "button", ...props }) {
|
|
129
|
+
function MenubarTrigger({ asChild = false, children, className, disabled, onClick, onKeyDown, ref, type = "button", ...props }) {
|
|
116
130
|
const menubar = useMenubarContext("Menubar.Trigger");
|
|
117
131
|
const menu = useMenuContext("Menubar.Trigger");
|
|
118
132
|
const triggerRef = React.useRef(null);
|
|
@@ -123,32 +137,50 @@ function MenubarTrigger({ children, className, disabled, onClick, onKeyDown, ref
|
|
|
123
137
|
menubar.registerTrigger(itemId, { disabled, ref: triggerRef.current, value: menu.value });
|
|
124
138
|
return () => menubar.unregisterTrigger(itemId);
|
|
125
139
|
}, [disabled, itemId, label, menu, menubar]);
|
|
140
|
+
const handleClick = () => {
|
|
141
|
+
if (!disabled) {
|
|
142
|
+
menubar.setOpenValue(menu.open ? undefined : menu.value);
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
const handleKeyDown = (event) => {
|
|
146
|
+
if (event.key === "ArrowDown" || isActivationKey(event.key)) {
|
|
147
|
+
event.preventDefault();
|
|
148
|
+
menubar.setOpenValue(menu.value);
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
const triggerProps = {
|
|
152
|
+
...props,
|
|
153
|
+
ref: (node) => {
|
|
154
|
+
setComposedRef(triggerRef, ref, node);
|
|
155
|
+
},
|
|
156
|
+
id: menu.triggerId,
|
|
157
|
+
role: "menuitem",
|
|
158
|
+
"aria-controls": menu.contentId,
|
|
159
|
+
"aria-disabled": disabled ? true : undefined,
|
|
160
|
+
"aria-expanded": menu.open,
|
|
161
|
+
"aria-haspopup": "menu",
|
|
162
|
+
className: cn("zvk-ui-menubar__trigger", className),
|
|
163
|
+
"data-disabled": disabled ? "true" : undefined,
|
|
164
|
+
"data-state": menu.open ? "open" : "closed",
|
|
165
|
+
onClick: composeEventHandlers(onClick, handleClick),
|
|
166
|
+
onKeyDown: composeEventHandlers(onKeyDown, handleKeyDown)
|
|
167
|
+
};
|
|
168
|
+
if (asChild) {
|
|
169
|
+
return _jsx(Slot, { ...triggerProps, children: children });
|
|
170
|
+
}
|
|
126
171
|
return (_jsx("button", { ...props, ref: (node) => {
|
|
127
|
-
triggerRef
|
|
128
|
-
|
|
129
|
-
ref(node);
|
|
130
|
-
}
|
|
131
|
-
else if (ref) {
|
|
132
|
-
ref.current = node;
|
|
133
|
-
}
|
|
134
|
-
}, id: menu.triggerId, type: type, role: "menuitem", disabled: disabled, "aria-controls": menu.contentId, "aria-expanded": menu.open ? "true" : "false", "aria-haspopup": "menu", className: cn("liano-menubar__trigger", className), "data-state": menu.open ? "open" : "closed", onClick: composeEventHandlers(onClick, () => {
|
|
135
|
-
if (!disabled) {
|
|
136
|
-
menubar.setOpenValue(menu.open ? undefined : menu.value);
|
|
137
|
-
}
|
|
138
|
-
}), onKeyDown: composeEventHandlers(onKeyDown, (event) => {
|
|
139
|
-
if (event.key === "ArrowDown" || event.key === "Enter" || event.key === " ") {
|
|
140
|
-
event.preventDefault();
|
|
141
|
-
menubar.setOpenValue(menu.value);
|
|
142
|
-
}
|
|
143
|
-
}), children: children }));
|
|
172
|
+
setComposedRef(triggerRef, ref, node);
|
|
173
|
+
}, id: menu.triggerId, type: type, role: "menuitem", disabled: disabled, "aria-controls": menu.contentId, "aria-expanded": menu.open ? "true" : "false", "aria-haspopup": "menu", className: cn("zvk-ui-menubar__trigger", className), "data-disabled": disabled ? "true" : undefined, "data-state": menu.open ? "open" : "closed", onClick: triggerProps.onClick, onKeyDown: triggerProps.onKeyDown, children: children }));
|
|
144
174
|
}
|
|
145
|
-
function MenubarContent({ children, className, onKeyDown, ref, ...props }) {
|
|
175
|
+
function MenubarContent({ align, alignOffset: _alignOffset, children, className, onKeyDown, ref, side, sideOffset: _sideOffset, ...props }) {
|
|
146
176
|
const menubar = useMenubarContext("Menubar.Content");
|
|
147
177
|
const menu = useMenuContext("Menubar.Content");
|
|
178
|
+
const contentPlacement = placementFromSideAlign(side, align, "bottom-start");
|
|
179
|
+
const contentPlacementParts = placementParts(contentPlacement);
|
|
148
180
|
if (!menu.open) {
|
|
149
181
|
return null;
|
|
150
182
|
}
|
|
151
|
-
return (_jsx(Portal, { children: _jsx(DismissableLayer, { open: menu.open, onDismiss: () => menubar.setOpenValue(undefined), children: _jsx("div", { ...props, ref: ref, id: menu.contentId, role: "menu", "aria-label": menu.label, "aria-labelledby": menu.triggerId, className: cn("
|
|
183
|
+
return (_jsx(Portal, { children: _jsx(DismissableLayer, { open: menu.open, onDismiss: () => menubar.setOpenValue(undefined), children: _jsx("div", { ...props, ref: ref, id: menu.contentId, role: "menu", "aria-label": menu.label, "aria-labelledby": menu.triggerId, className: cn("zvk-ui-menubar__content", className), "data-align": contentPlacementParts.align, "data-side": contentPlacementParts.side, onKeyDown: composeEventHandlers(onKeyDown, (event) => {
|
|
152
184
|
const items = menu.getItems();
|
|
153
185
|
const index = activeIndex(items);
|
|
154
186
|
if (event.key === "ArrowDown") {
|
|
@@ -166,7 +198,7 @@ function MenubarContent({ children, className, onKeyDown, ref, ...props }) {
|
|
|
166
198
|
}
|
|
167
199
|
}), children: children }) }) }));
|
|
168
200
|
}
|
|
169
|
-
function MenubarItem({ children, className, disabled, onClick, onKeyDown, onSelect, ref, type = "button", ...props }) {
|
|
201
|
+
function MenubarItem({ asChild = false, children, className, disabled, onClick, onKeyDown, onSelect, ref, type = "button", ...props }) {
|
|
170
202
|
const menubar = useMenubarContext("Menubar.Item");
|
|
171
203
|
const menu = useMenuContext("Menubar.Item");
|
|
172
204
|
const { getItems, open, registerItem, unregisterItem } = menu;
|
|
@@ -185,37 +217,154 @@ function MenubarItem({ children, className, disabled, onClick, onKeyDown, onSele
|
|
|
185
217
|
return;
|
|
186
218
|
}
|
|
187
219
|
onSelect?.(event);
|
|
188
|
-
|
|
220
|
+
if (!event.defaultPrevented) {
|
|
221
|
+
menubar.setOpenValue(undefined);
|
|
222
|
+
}
|
|
189
223
|
};
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
224
|
+
const itemProps = {
|
|
225
|
+
...props,
|
|
226
|
+
ref: (node) => {
|
|
227
|
+
setComposedRef(itemRef, ref, node);
|
|
228
|
+
},
|
|
229
|
+
role: "menuitem",
|
|
230
|
+
"aria-disabled": disabled ? true : undefined,
|
|
231
|
+
className: cn("zvk-ui-menubar__item", className),
|
|
232
|
+
"data-disabled": disabled ? "true" : undefined,
|
|
233
|
+
onClick: composeEventHandlers(onClick, select),
|
|
234
|
+
onKeyDown: composeEventHandlers(onKeyDown, (event) => {
|
|
235
|
+
if (isActivationKey(event.key)) {
|
|
236
|
+
select(event);
|
|
237
|
+
event.preventDefault();
|
|
197
238
|
}
|
|
198
|
-
}
|
|
199
|
-
|
|
239
|
+
})
|
|
240
|
+
};
|
|
241
|
+
if (asChild) {
|
|
242
|
+
return _jsx(Slot, { ...itemProps, children: children });
|
|
243
|
+
}
|
|
244
|
+
return (_jsx("button", { ...props, ref: (node) => {
|
|
245
|
+
setComposedRef(itemRef, ref, node);
|
|
246
|
+
}, type: type, role: "menuitem", disabled: disabled, "aria-disabled": itemProps["aria-disabled"], className: itemProps.className, "data-disabled": itemProps["data-disabled"], onClick: itemProps.onClick, onKeyDown: itemProps.onKeyDown, children: children }));
|
|
247
|
+
}
|
|
248
|
+
function MenubarCheckboxItem({ asChild = false, checked, children, className, defaultChecked = false, disabled, onCheckedChange, onClick, onKeyDown, onSelect, ref, type = "button", ...props }) {
|
|
249
|
+
const menubar = useMenubarContext("Menubar.CheckboxItem");
|
|
250
|
+
const menu = useMenuContext("Menubar.CheckboxItem");
|
|
251
|
+
const { getItems, open, registerItem, unregisterItem } = menu;
|
|
252
|
+
const itemId = React.useId();
|
|
253
|
+
const itemRef = React.useRef(null);
|
|
254
|
+
const [currentChecked, setCurrentChecked] = useControllableState({
|
|
255
|
+
...(checked !== undefined ? { value: checked } : {}),
|
|
256
|
+
defaultValue: defaultChecked,
|
|
257
|
+
...(onCheckedChange ? { onChange: onCheckedChange } : {})
|
|
258
|
+
});
|
|
259
|
+
React.useLayoutEffect(() => {
|
|
260
|
+
registerItem(itemId, { disabled, ref: itemRef.current });
|
|
261
|
+
const firstEnabled = getItems().find((item) => item.data.disabled !== true && item.data.ref !== null);
|
|
262
|
+
if (open && firstEnabled?.id === itemId) {
|
|
263
|
+
itemRef.current?.focus();
|
|
264
|
+
}
|
|
265
|
+
return () => unregisterItem(itemId);
|
|
266
|
+
}, [disabled, getItems, itemId, open, registerItem, unregisterItem]);
|
|
267
|
+
const select = (event) => {
|
|
268
|
+
if (disabled) {
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
onSelect?.(event);
|
|
272
|
+
if (!event.defaultPrevented) {
|
|
273
|
+
setCurrentChecked((value) => !value);
|
|
274
|
+
menubar.setOpenValue(undefined);
|
|
275
|
+
}
|
|
276
|
+
};
|
|
277
|
+
const itemProps = {
|
|
278
|
+
...props,
|
|
279
|
+
ref: (node) => {
|
|
280
|
+
setComposedRef(itemRef, ref, node);
|
|
281
|
+
},
|
|
282
|
+
role: "menuitemcheckbox",
|
|
283
|
+
"aria-checked": currentChecked,
|
|
284
|
+
"aria-disabled": disabled ? true : undefined,
|
|
285
|
+
className: cn("zvk-ui-menubar__item", "zvk-ui-menubar__checkbox-item", className),
|
|
286
|
+
"data-checked": currentChecked ? "true" : undefined,
|
|
287
|
+
"data-disabled": disabled ? "true" : undefined,
|
|
288
|
+
onClick: composeEventHandlers(onClick, select),
|
|
289
|
+
onKeyDown: composeEventHandlers(onKeyDown, (event) => {
|
|
290
|
+
if (isActivationKey(event.key)) {
|
|
291
|
+
select(event);
|
|
200
292
|
event.preventDefault();
|
|
293
|
+
}
|
|
294
|
+
})
|
|
295
|
+
};
|
|
296
|
+
if (asChild) {
|
|
297
|
+
return _jsx(Slot, { ...itemProps, children: children });
|
|
298
|
+
}
|
|
299
|
+
return (_jsxs("button", { ...props, ref: (node) => {
|
|
300
|
+
setComposedRef(itemRef, ref, node);
|
|
301
|
+
}, type: type, role: "menuitemcheckbox", disabled: disabled, "aria-checked": itemProps["aria-checked"], "aria-disabled": itemProps["aria-disabled"], className: itemProps.className, "data-checked": itemProps["data-checked"], "data-disabled": itemProps["data-disabled"], onClick: itemProps.onClick, onKeyDown: itemProps.onKeyDown, children: [_jsx("span", { className: "zvk-ui-menubar__item-indicator", "aria-hidden": "true", children: currentChecked ? "✓" : "" }), _jsx("span", { className: "zvk-ui-menubar__item-label", children: children })] }));
|
|
302
|
+
}
|
|
303
|
+
function MenubarRadioItem({ asChild = false, checked = false, children, className, disabled, onClick, onKeyDown, onSelect, ref, type = "button", ...props }) {
|
|
304
|
+
const menubar = useMenubarContext("Menubar.RadioItem");
|
|
305
|
+
const menu = useMenuContext("Menubar.RadioItem");
|
|
306
|
+
const { getItems, open, registerItem, unregisterItem } = menu;
|
|
307
|
+
const itemId = React.useId();
|
|
308
|
+
const itemRef = React.useRef(null);
|
|
309
|
+
React.useLayoutEffect(() => {
|
|
310
|
+
registerItem(itemId, { disabled, ref: itemRef.current });
|
|
311
|
+
const firstEnabled = getItems().find((item) => item.data.disabled !== true && item.data.ref !== null);
|
|
312
|
+
if (open && firstEnabled?.id === itemId) {
|
|
313
|
+
itemRef.current?.focus();
|
|
314
|
+
}
|
|
315
|
+
return () => unregisterItem(itemId);
|
|
316
|
+
}, [disabled, getItems, itemId, open, registerItem, unregisterItem]);
|
|
317
|
+
const select = (event) => {
|
|
318
|
+
if (disabled) {
|
|
319
|
+
return;
|
|
320
|
+
}
|
|
321
|
+
onSelect?.(event);
|
|
322
|
+
if (!event.defaultPrevented) {
|
|
323
|
+
menubar.setOpenValue(undefined);
|
|
324
|
+
}
|
|
325
|
+
};
|
|
326
|
+
const itemProps = {
|
|
327
|
+
...props,
|
|
328
|
+
ref: (node) => {
|
|
329
|
+
setComposedRef(itemRef, ref, node);
|
|
330
|
+
},
|
|
331
|
+
role: "menuitemradio",
|
|
332
|
+
"aria-checked": checked,
|
|
333
|
+
"aria-disabled": disabled ? true : undefined,
|
|
334
|
+
className: cn("zvk-ui-menubar__item", "zvk-ui-menubar__radio-item", className),
|
|
335
|
+
"data-checked": checked ? "true" : undefined,
|
|
336
|
+
"data-disabled": disabled ? "true" : undefined,
|
|
337
|
+
onClick: composeEventHandlers(onClick, select),
|
|
338
|
+
onKeyDown: composeEventHandlers(onKeyDown, (event) => {
|
|
339
|
+
if (isActivationKey(event.key)) {
|
|
201
340
|
select(event);
|
|
341
|
+
event.preventDefault();
|
|
202
342
|
}
|
|
203
|
-
})
|
|
343
|
+
})
|
|
344
|
+
};
|
|
345
|
+
if (asChild) {
|
|
346
|
+
return _jsx(Slot, { ...itemProps, children: children });
|
|
347
|
+
}
|
|
348
|
+
return (_jsxs("button", { ...props, ref: (node) => {
|
|
349
|
+
setComposedRef(itemRef, ref, node);
|
|
350
|
+
}, type: type, role: "menuitemradio", disabled: disabled, "aria-checked": itemProps["aria-checked"], "aria-disabled": itemProps["aria-disabled"], className: itemProps.className, "data-checked": itemProps["data-checked"], "data-disabled": itemProps["data-disabled"], onClick: itemProps.onClick, onKeyDown: itemProps.onKeyDown, children: [_jsx("span", { className: "zvk-ui-menubar__item-indicator", "aria-hidden": "true", children: checked ? "●" : "" }), _jsx("span", { className: "zvk-ui-menubar__item-label", children: children })] }));
|
|
204
351
|
}
|
|
205
352
|
function MenubarSeparator({ className, ref, ...props }) {
|
|
206
|
-
return _jsx("div", { ...props, ref: ref, role: "separator", "aria-hidden": "true", className: cn("
|
|
353
|
+
return _jsx("div", { ...props, ref: ref, role: "separator", "aria-hidden": "true", className: cn("zvk-ui-menubar__separator", className) });
|
|
207
354
|
}
|
|
208
355
|
function MenubarLabel({ className, ref, ...props }) {
|
|
209
|
-
return _jsx("div", { ...props, ref: ref, className: cn("
|
|
356
|
+
return _jsx("div", { ...props, ref: ref, className: cn("zvk-ui-menubar__label", className) });
|
|
210
357
|
}
|
|
211
358
|
function MenubarShortcut({ className, ref, ...props }) {
|
|
212
|
-
return _jsx("span", { ...props, ref: ref, className: cn("
|
|
359
|
+
return _jsx("span", { ...props, ref: ref, className: cn("zvk-ui-menubar__shortcut", className) });
|
|
213
360
|
}
|
|
214
361
|
export const Menubar = Object.assign(MenubarRoot, {
|
|
362
|
+
CheckboxItem: MenubarCheckboxItem,
|
|
215
363
|
Content: MenubarContent,
|
|
216
364
|
Item: MenubarItem,
|
|
217
365
|
Label: MenubarLabel,
|
|
218
366
|
Menu: MenubarMenu,
|
|
367
|
+
RadioItem: MenubarRadioItem,
|
|
219
368
|
Separator: MenubarSeparator,
|
|
220
369
|
Shortcut: MenubarShortcut,
|
|
221
370
|
Trigger: MenubarTrigger
|
|
@@ -48,45 +48,45 @@ export function getPaginationRange({ page, pageCount, siblingCount = 1, boundary
|
|
|
48
48
|
function renderPrevious({ hasHrefMode, page, label, pageCount, onPageChange, getPageHref }) {
|
|
49
49
|
const targetPage = page - 1;
|
|
50
50
|
if (hasHrefMode && targetPage >= 1) {
|
|
51
|
-
return (_jsx("a", { className: "
|
|
51
|
+
return (_jsx("a", { className: "zvk-ui-pagination__item", href: getPageHref?.(targetPage), children: label }));
|
|
52
52
|
}
|
|
53
53
|
if (hasHrefMode && targetPage < 1) {
|
|
54
|
-
return (_jsx("span", { className: "
|
|
54
|
+
return (_jsx("span", { className: "zvk-ui-pagination__item zvk-ui-pagination__item--disabled", "aria-hidden": "true", children: label }));
|
|
55
55
|
}
|
|
56
|
-
return (_jsx("button", { className: "
|
|
56
|
+
return (_jsx("button", { className: "zvk-ui-pagination__item", disabled: targetPage < 1, onClick: () => onPageChange?.(Math.max(1, targetPage)), type: "button", children: label }));
|
|
57
57
|
}
|
|
58
58
|
function renderNext({ hasHrefMode, page, label, pageCount, onPageChange, getPageHref }) {
|
|
59
59
|
const targetPage = page + 1;
|
|
60
60
|
if (hasHrefMode && targetPage <= pageCount) {
|
|
61
|
-
return (_jsx("a", { className: "
|
|
61
|
+
return (_jsx("a", { className: "zvk-ui-pagination__item", href: getPageHref?.(targetPage), children: label }));
|
|
62
62
|
}
|
|
63
63
|
if (hasHrefMode && targetPage > pageCount) {
|
|
64
|
-
return (_jsx("span", { className: "
|
|
64
|
+
return (_jsx("span", { className: "zvk-ui-pagination__item zvk-ui-pagination__item--disabled", "aria-hidden": "true", children: label }));
|
|
65
65
|
}
|
|
66
|
-
return (_jsx("button", { className: "
|
|
66
|
+
return (_jsx("button", { className: "zvk-ui-pagination__item", disabled: targetPage > pageCount, onClick: () => onPageChange?.(Math.min(pageCount, targetPage)), type: "button", children: label }));
|
|
67
67
|
}
|
|
68
68
|
function renderPageItem({ hasHrefMode, item, page, onPageChange, getPageHref }) {
|
|
69
69
|
if (item === page) {
|
|
70
70
|
if (hasHrefMode) {
|
|
71
|
-
return (_jsx("a", { "aria-current": "page", className: "
|
|
71
|
+
return (_jsx("a", { "aria-current": "page", className: "zvk-ui-pagination__item zvk-ui-pagination__item--current", href: getPageHref?.(item), children: item }));
|
|
72
72
|
}
|
|
73
|
-
return (_jsx("button", { "aria-current": "page", className: "
|
|
73
|
+
return (_jsx("button", { "aria-current": "page", className: "zvk-ui-pagination__item zvk-ui-pagination__item--current", disabled: true, type: "button", children: item }));
|
|
74
74
|
}
|
|
75
75
|
if (hasHrefMode) {
|
|
76
|
-
return (_jsx("a", { className: "
|
|
76
|
+
return (_jsx("a", { className: "zvk-ui-pagination__item", href: getPageHref?.(item), children: item }));
|
|
77
77
|
}
|
|
78
|
-
return (_jsx("button", { className: "
|
|
78
|
+
return (_jsx("button", { className: "zvk-ui-pagination__item", onClick: () => onPageChange?.(item), type: "button", children: item }));
|
|
79
79
|
}
|
|
80
80
|
export function Pagination({ className, label = "Pagination", onPageChange, getPageHref, page, pageCount, siblingCount = 1, boundaryCount = 1, previousLabel = "Previous", nextLabel = "Next", ref, ...props }) {
|
|
81
81
|
const safePageCount = Math.max(normalizeCount(pageCount, 1), 0);
|
|
82
82
|
const safePage = Math.max(1, Math.min(clamp(page), safePageCount || 1));
|
|
83
83
|
const range = getPaginationRange({ page, pageCount, siblingCount, boundaryCount });
|
|
84
84
|
const isLinkMode = typeof getPageHref === "function";
|
|
85
|
-
return (_jsx("nav", { ...props, ref: ref, "aria-label": props["aria-label"] ?? label, className: cn("
|
|
85
|
+
return (_jsx("nav", { ...props, ref: ref, "aria-label": props["aria-label"] ?? label, className: cn("zvk-ui-pagination", className), children: _jsxs("ol", { className: "zvk-ui-pagination__list", children: [_jsx("li", { children: renderPrevious({ hasHrefMode: isLinkMode, label: previousLabel, onPageChange, page: safePage, pageCount: safePageCount, getPageHref }) }), range.map((item) => (_jsx("li", { children: typeof item === "number" ? (renderPageItem({
|
|
86
86
|
getPageHref,
|
|
87
87
|
hasHrefMode: isLinkMode,
|
|
88
88
|
item,
|
|
89
89
|
onPageChange,
|
|
90
90
|
page: safePage
|
|
91
|
-
})) : (_jsx("span", { "aria-hidden": "true", className: "
|
|
91
|
+
})) : (_jsx("span", { "aria-hidden": "true", className: "zvk-ui-pagination__ellipsis", children: "\u2026" })) }, `${item}-${typeof item === "number" ? item : item}`))), _jsx("li", { children: renderNext({ hasHrefMode: isLinkMode, label: nextLabel, onPageChange, page: safePage, pageCount: safePageCount, getPageHref }) })] }) }));
|
|
92
92
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import type { PortalProps } from "../../internal/portal/index.js";
|
|
3
3
|
import type { FloatingPlacement } from "../../internal/floating/floating-types.js";
|
|
4
|
+
import type { FloatingAlign, FloatingSide } from "../../internal/floating/placement-aliases.js";
|
|
4
5
|
export interface PopoverProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
5
6
|
open?: boolean;
|
|
6
7
|
defaultOpen?: boolean;
|
|
@@ -10,10 +11,14 @@ export interface PopoverProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
10
11
|
ref?: React.Ref<HTMLDivElement>;
|
|
11
12
|
}
|
|
12
13
|
export interface PopoverTriggerProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
13
|
-
|
|
14
|
+
asChild?: boolean;
|
|
15
|
+
ref?: React.Ref<HTMLButtonElement | HTMLElement>;
|
|
14
16
|
}
|
|
15
17
|
export interface PopoverContentProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
16
18
|
placement?: FloatingPlacement;
|
|
19
|
+
side?: FloatingSide;
|
|
20
|
+
align?: FloatingAlign;
|
|
21
|
+
alignOffset?: number;
|
|
17
22
|
sideOffset?: number;
|
|
18
23
|
collisionPadding?: number;
|
|
19
24
|
matchTriggerWidth?: boolean;
|
|
@@ -24,8 +29,8 @@ export interface PopoverContentProps extends React.HTMLAttributes<HTMLDivElement
|
|
|
24
29
|
ref?: React.Ref<HTMLDivElement>;
|
|
25
30
|
}
|
|
26
31
|
declare function PopoverRoot({ children, className, defaultOpen, modal, onOpenChange, open, placement, ref, ...props }: PopoverProps): React.JSX.Element;
|
|
27
|
-
declare function PopoverTrigger({ className, onClick, ref, type, ...props }: PopoverTriggerProps): React.JSX.Element;
|
|
28
|
-
declare function PopoverContent({ className, container, forceMount, id, disableEscapeKeyDown, disableOutsidePointerDown, ref, placement, sideOffset, collisionPadding, matchTriggerWidth, style, ...props }: PopoverContentProps): React.JSX.Element | null;
|
|
32
|
+
declare function PopoverTrigger({ asChild, className, disabled, onClick, ref, type, ...props }: PopoverTriggerProps): React.JSX.Element;
|
|
33
|
+
declare function PopoverContent({ align, alignOffset, className, container, forceMount, id, disableEscapeKeyDown, disableOutsidePointerDown, ref, placement, side, sideOffset, collisionPadding, matchTriggerWidth, style, ...props }: PopoverContentProps): React.JSX.Element | null;
|
|
29
34
|
export declare const Popover: typeof PopoverRoot & {
|
|
30
35
|
Trigger: typeof PopoverTrigger;
|
|
31
36
|
Content: typeof PopoverContent;
|