@openwarelabs/ui 0.14.0 → 0.15.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.
Files changed (33) hide show
  1. package/README.md +5 -5
  2. package/dist/components/InlineEdit/InlineEdit.d.cts +8 -0
  3. package/dist/components/InlineEdit/InlineEdit.d.ts +8 -0
  4. package/dist/components/InlineEdit/InlineEdit.types.d.cts +74 -0
  5. package/dist/components/InlineEdit/InlineEdit.types.d.ts +74 -0
  6. package/dist/components/NavigationMenu/NavigationMenu.d.cts +14 -0
  7. package/dist/components/NavigationMenu/NavigationMenu.d.ts +14 -0
  8. package/dist/components/NavigationMenu/NavigationMenu.types.d.cts +84 -0
  9. package/dist/components/NavigationMenu/NavigationMenu.types.d.ts +84 -0
  10. package/dist/components/SortableList/SortableList.d.cts +7 -0
  11. package/dist/components/SortableList/SortableList.d.ts +7 -0
  12. package/dist/components/SortableList/SortableList.types.d.cts +82 -0
  13. package/dist/components/SortableList/SortableList.types.d.ts +82 -0
  14. package/dist/components/TreeView/TreeView.d.cts +8 -0
  15. package/dist/components/TreeView/TreeView.d.ts +8 -0
  16. package/dist/components/TreeView/TreeView.types.d.cts +88 -0
  17. package/dist/components/TreeView/TreeView.types.d.ts +88 -0
  18. package/dist/components/VirtualList/VirtualList.d.cts +9 -0
  19. package/dist/components/VirtualList/VirtualList.d.ts +9 -0
  20. package/dist/components/VirtualList/VirtualList.types.d.cts +80 -0
  21. package/dist/components/VirtualList/VirtualList.types.d.ts +80 -0
  22. package/dist/components/VirtualList/useVirtualizer.d.cts +60 -0
  23. package/dist/components/VirtualList/useVirtualizer.d.ts +60 -0
  24. package/dist/components.css +637 -0
  25. package/dist/index.cjs +2732 -1328
  26. package/dist/index.cjs.map +4 -4
  27. package/dist/index.d.cts +12 -0
  28. package/dist/index.d.ts +12 -0
  29. package/dist/index.js +2695 -1267
  30. package/dist/index.js.map +4 -4
  31. package/dist/openware-ui.iife.js +9 -8
  32. package/dist/styles.css +637 -0
  33. package/package.json +1 -1
package/README.md CHANGED
@@ -58,17 +58,17 @@ import { Button, Field, Input, Toaster, toast } from "@openwarelabs/ui";
58
58
 
59
59
  | Group | Components |
60
60
  | --- | --- |
61
- | Typography | `Text` (each style on the Typography page as a variant: hero to caption, code and kbd; tones, `truncate`, `as`), `Link`, `Kbd`, `Code`, `CodeBlock`, `Snippet`, `Prose` (styles rendered Markdown or HTML, at chat or article size) |
61
+ | Typography | `Text` (each style on the Typography page as a variant: hero to caption, code and kbd; tones, `truncate`, `as`), `Link`, `Kbd`, `Code`, `CodeBlock`, `Snippet`, `Prose` (styles rendered Markdown or HTML, at chat or article size), `InlineEdit` (text you click to edit in place; Enter saves, Escape cancels, async saves) |
62
62
  | Actions | `Button` (primary, secondary, ghost, danger; sm, md, lg; `loading`; `shape="pill"`), `buttonClassName()` for links, `ButtonGroup`, `CloseButton`, `CopyButton`, `ToggleButton`, `SegmentedControl`, `ToggleButtonGroup` (one or several on), `Toolbar` + `ToolbarSeparator` (arrow keys across its controls) |
63
63
  | Inputs | `Form` (the browser's checks, your own and the server's errors, under each field; `useFormStatus`), `Field`, `Fieldset`, `Input` (start and end content), `Textarea` (`autoGrow`), `NumberField`, `SearchField`, `InputOTP`, `ColorField`, `DateField` and `TimeField` (typed in segments, in the locale's order), `TagInput` (several values as tags, typed or picked from suggestions), `PasswordInput` (show and hide, a strength meter, a checklist of rules; `passwordStrength()`) |
64
- | Choices | `Checkbox`, `CheckboxGroup`, `RadioGroup` (plain or cards), `Switch`, `Select`, `Combobox`, `Slider` (one value or a range), `Rating` (pick a score or show one), `ChoiceCard`, `ListBox` (one or many, on the page) |
64
+ | Choices | `Checkbox`, `CheckboxGroup`, `RadioGroup` (plain or cards), `Switch`, `Select`, `Combobox`, `Slider` (one value or a range), `Rating` (pick a score or show one), `ChoiceCard`, `ListBox` (one or many, on the page), `TreeView` (rows that open, select or check, with children loaded on demand) |
65
65
  | Pickers | `Calendar`, `DatePicker`, `RangeCalendar`, `DateRangePicker` (with presets), `ColorPicker`, `ColorArea`, `ColorSlider`, `ColorSwatchPicker`, `FileDropZone` |
66
66
  | Feedback | `Alert`, `Badge`, `ProgressBar`, `ProgressCircle`, `Meter` (an amount in a range, toned by thresholds), `Spinner`, `Skeleton`, `SkeletonRows`, `Toaster` + `toast()` (sonner: stacked, swipeable, with actions and promises), `Tooltip`, `Banner` (an announcement bar across the top, dismissible and remembered) |
67
- | Overlays | `Dialog`, `ConfirmDialog`, `Drawer`, `Popover`, `HoverCard` (a preview when the pointer rests on a link), `Menu` + `MenuItem`, `CommandPalette`, `ContextMenu` (right-click, long press or Shift+F10, with the same items), `Tour` (steps that point at parts of the page, with an optional spotlight) + `Coachmark` |
67
+ | Overlays | `Dialog`, `ConfirmDialog`, `Drawer`, `Popover`, `HoverCard` (a preview when the pointer rests on a link), `Menu` + `MenuItem`, `CommandPalette`, `ContextMenu` (right-click, long press or Shift+F10, with the same items), `Tour` (steps that point at parts of the page, with an optional spotlight) + `Coachmark`, `NavigationMenu` + `NavigationMenuItem` + `NavigationMenuLink` (a site's top nav with dropdown panels and mega-menus) |
68
68
  | Navigation | `Tabs`, `Accordion`, `Disclosure`, `Breadcrumbs`, `Pagination`, `Steps`, `NavList` + `NavItem` |
69
- | Data display | `Table` (sorting, selection), `Stat`, `FileTree`, `EmptyState`, `Tag`, `ColorSwatch`, `Avatar`, `AvatarGroup`, `User`, `Image` (a placeholder while it loads, a fallback if it fails, `ratio`, `caption`), `Timeline` + `TimelineItem`, `DescriptionList` + `DescriptionItem`, `Carousel` + `CarouselSlide` (scroll-snap, arrows, dots, autoplay) |
69
+ | Data display | `Table` (sorting, selection), `Stat`, `FileTree`, `EmptyState`, `Tag`, `ColorSwatch`, `Avatar`, `AvatarGroup`, `User`, `Image` (a placeholder while it loads, a fallback if it fails, `ratio`, `caption`), `Timeline` + `TimelineItem`, `DescriptionList` + `DescriptionItem`, `Carousel` + `CarouselSlide` (scroll-snap, arrows, dots, autoplay), `SortableList` (reorder by dragging or with the keyboard) |
70
70
  | AI | `PromptInput` (attachments, stop while streaming) + `PromptSuggestion`, `ChatConversation` (follows the newest message, jump to latest), `ChatMessage` + `ChatMessageActions`, `ChatLoader`, `ChatTool` (a tool call with its status, input, output and approval), `ChainOfThought`, `ChatSource` + `ChatSources`, `TextShimmer` |
71
- | Layout | `Card`, `SettingsRow`, `Stack`, `Separator`, `ScrollShadow`, `VisuallyHidden`, `AspectRatio`, `Splitter` + `SplitterPanel` + `SplitterHandle` (panels you resize by dragging or with the arrow keys, collapsible, remembered) |
71
+ | Layout | `Card`, `SettingsRow`, `Stack`, `Separator`, `ScrollShadow`, `VisuallyHidden`, `AspectRatio`, `Splitter` + `SplitterPanel` + `SplitterHandle` (panels you resize by dragging or with the arrow keys, collapsible, remembered), `VirtualList` (renders only the rows in view, for 10,000 rows, logs and infinite feeds) |
72
72
  | Marketing | `SiteHeader`, `SectionHeading`, `Chip`, `DotGrid` |
73
73
 
74
74
  Hooks for your own components: `useControllableState`, `useFloating` (top-layer positioning that flips), `usePresence` (keeps a layer mounted while it animates out), `useDismiss`, `useModalDialog`, `useMenuKeyboard`. Every prop is typed and described, so your editor explains it on hover.
@@ -0,0 +1,8 @@
1
+ import type { InlineEditProps } from "./InlineEdit.types.cjs";
2
+ export type { InlineEditLabels, InlineEditProps } from "./InlineEdit.types.cjs";
3
+ /**
4
+ * Text that people click, or focus and press Enter, to edit where it is: a project's name, a title, a value in a
5
+ * settings row. Enter saves and Escape cancels; focus goes back to the text either way. `onSave` can return a Promise:
6
+ * the editor stays open while it runs, and shows its error if it fails.
7
+ */
8
+ export declare function InlineEdit({ value, defaultValue, onSave, onCancel, label, placeholder, multiline, validate, required, maxLength, textVariant, saveOnBlur, showActions, editing, defaultEditing, onEditingChange, selectOnFocus, disabled, readOnly, labels: labelsProp, id, className, }: InlineEditProps): import("react").JSX.Element;
@@ -0,0 +1,8 @@
1
+ import type { InlineEditProps } from "./InlineEdit.types.js";
2
+ export type { InlineEditLabels, InlineEditProps } from "./InlineEdit.types.js";
3
+ /**
4
+ * Text that people click, or focus and press Enter, to edit where it is: a project's name, a title, a value in a
5
+ * settings row. Enter saves and Escape cancels; focus goes back to the text either way. `onSave` can return a Promise:
6
+ * the editor stays open while it runs, and shows its error if it fails.
7
+ */
8
+ export declare function InlineEdit({ value, defaultValue, onSave, onCancel, label, placeholder, multiline, validate, required, maxLength, textVariant, saveOnBlur, showActions, editing, defaultEditing, onEditingChange, selectOnFocus, disabled, readOnly, labels: labelsProp, id, className, }: InlineEditProps): import("react").JSX.Element;
@@ -0,0 +1,74 @@
1
+ import type { TextVariant } from "../Text/Text.cjs";
2
+ export interface InlineEditLabels {
3
+ /** Names the text's button, given `label`. @default (label) => `Edit ${label.toLowerCase()}` */
4
+ edit?(label: string): string;
5
+ /** The Save button, with `showActions`. @default "Save" */
6
+ save?: string;
7
+ /** The Cancel button, with `showActions`. @default "Cancel" */
8
+ cancel?: string;
9
+ /** Read out while a slow `onSave` runs. @default "Saving" */
10
+ saving?: string;
11
+ /** Shown when a `required` value is left empty. @default "This can't be empty." */
12
+ required?: string;
13
+ /** Shown when `onSave` fails without a message of its own. @default "Couldn't save. Try again." */
14
+ failed?: string;
15
+ }
16
+ export interface InlineEditProps {
17
+ /** The text, when you control it. Update it in `onSave`. */
18
+ value?: string;
19
+ /** The text at first, when it keeps the text itself.
20
+ * @default "" */
21
+ defaultValue?: string;
22
+ /**
23
+ * Called with the new text when people save a change (not when they save it unchanged). Return a Promise to keep
24
+ * the editor open, showing that it's saving, until it settles; if it rejects or throws, its message is shown and
25
+ * the editor stays open to try again.
26
+ */
27
+ onSave?(value: string): void | Promise<unknown>;
28
+ /** Called when people cancel an edit, with Escape, the Cancel button or, without `saveOnBlur`, by leaving it. */
29
+ onCancel?(): void;
30
+ /** What the text is, such as "Project name": the editor's name, and the button's ("Edit project name"). Required. */
31
+ label: string;
32
+ /** Shown, muted, when the text is empty, and in the empty editor.
33
+ * @default label */
34
+ placeholder?: string;
35
+ /** Edits in a Textarea that grows with the text: Enter adds a line, and Ctrl+Enter or ⌘Enter saves.
36
+ * @default false */
37
+ multiline?: boolean;
38
+ /** Checks the text before it's saved; return a message to show instead of saving, or undefined when it's fine. */
39
+ validate?(value: string): string | undefined;
40
+ /** Refuses to save empty text (or only spaces), with `labels.required`.
41
+ * @default false */
42
+ required?: boolean;
43
+ /** The most characters it takes. */
44
+ maxLength?: number;
45
+ /** A Text style for the text and the editor, so it can be a heading or a caption. Left out, it takes the font around it. */
46
+ textVariant?: TextVariant;
47
+ /** Leaving the editor saves. When false, leaving it cancels.
48
+ * @default true */
49
+ saveOnBlur?: boolean;
50
+ /** Shows Save and Cancel buttons beside the editor.
51
+ * @default false */
52
+ showActions?: boolean;
53
+ /** Whether it's editing, when you control it. */
54
+ editing?: boolean;
55
+ /** Whether it starts out editing, when it controls that itself.
56
+ * @default false */
57
+ defaultEditing?: boolean;
58
+ /** Called when it starts or stops editing. */
59
+ onEditingChange?(editing: boolean): void;
60
+ /** Selects all the text when the editor opens, to type over it. Otherwise the caret goes at the end.
61
+ * @default false */
62
+ selectOnFocus?: boolean;
63
+ /** Shows the text dimmed, and it can't be edited or focused.
64
+ * @default false */
65
+ disabled?: boolean;
66
+ /** Shows the text plainly, as text, with nothing to click.
67
+ * @default false */
68
+ readOnly?: boolean;
69
+ /** The words it uses, for other languages. */
70
+ labels?: InlineEditLabels;
71
+ /** The display button's id. */
72
+ id?: string;
73
+ className?: string;
74
+ }
@@ -0,0 +1,74 @@
1
+ import type { TextVariant } from "../Text/Text.js";
2
+ export interface InlineEditLabels {
3
+ /** Names the text's button, given `label`. @default (label) => `Edit ${label.toLowerCase()}` */
4
+ edit?(label: string): string;
5
+ /** The Save button, with `showActions`. @default "Save" */
6
+ save?: string;
7
+ /** The Cancel button, with `showActions`. @default "Cancel" */
8
+ cancel?: string;
9
+ /** Read out while a slow `onSave` runs. @default "Saving" */
10
+ saving?: string;
11
+ /** Shown when a `required` value is left empty. @default "This can't be empty." */
12
+ required?: string;
13
+ /** Shown when `onSave` fails without a message of its own. @default "Couldn't save. Try again." */
14
+ failed?: string;
15
+ }
16
+ export interface InlineEditProps {
17
+ /** The text, when you control it. Update it in `onSave`. */
18
+ value?: string;
19
+ /** The text at first, when it keeps the text itself.
20
+ * @default "" */
21
+ defaultValue?: string;
22
+ /**
23
+ * Called with the new text when people save a change (not when they save it unchanged). Return a Promise to keep
24
+ * the editor open, showing that it's saving, until it settles; if it rejects or throws, its message is shown and
25
+ * the editor stays open to try again.
26
+ */
27
+ onSave?(value: string): void | Promise<unknown>;
28
+ /** Called when people cancel an edit, with Escape, the Cancel button or, without `saveOnBlur`, by leaving it. */
29
+ onCancel?(): void;
30
+ /** What the text is, such as "Project name": the editor's name, and the button's ("Edit project name"). Required. */
31
+ label: string;
32
+ /** Shown, muted, when the text is empty, and in the empty editor.
33
+ * @default label */
34
+ placeholder?: string;
35
+ /** Edits in a Textarea that grows with the text: Enter adds a line, and Ctrl+Enter or ⌘Enter saves.
36
+ * @default false */
37
+ multiline?: boolean;
38
+ /** Checks the text before it's saved; return a message to show instead of saving, or undefined when it's fine. */
39
+ validate?(value: string): string | undefined;
40
+ /** Refuses to save empty text (or only spaces), with `labels.required`.
41
+ * @default false */
42
+ required?: boolean;
43
+ /** The most characters it takes. */
44
+ maxLength?: number;
45
+ /** A Text style for the text and the editor, so it can be a heading or a caption. Left out, it takes the font around it. */
46
+ textVariant?: TextVariant;
47
+ /** Leaving the editor saves. When false, leaving it cancels.
48
+ * @default true */
49
+ saveOnBlur?: boolean;
50
+ /** Shows Save and Cancel buttons beside the editor.
51
+ * @default false */
52
+ showActions?: boolean;
53
+ /** Whether it's editing, when you control it. */
54
+ editing?: boolean;
55
+ /** Whether it starts out editing, when it controls that itself.
56
+ * @default false */
57
+ defaultEditing?: boolean;
58
+ /** Called when it starts or stops editing. */
59
+ onEditingChange?(editing: boolean): void;
60
+ /** Selects all the text when the editor opens, to type over it. Otherwise the caret goes at the end.
61
+ * @default false */
62
+ selectOnFocus?: boolean;
63
+ /** Shows the text dimmed, and it can't be edited or focused.
64
+ * @default false */
65
+ disabled?: boolean;
66
+ /** Shows the text plainly, as text, with nothing to click.
67
+ * @default false */
68
+ readOnly?: boolean;
69
+ /** The words it uses, for other languages. */
70
+ labels?: InlineEditLabels;
71
+ /** The display button's id. */
72
+ id?: string;
73
+ className?: string;
74
+ }
@@ -0,0 +1,14 @@
1
+ import type { NavigationMenuGroupProps, NavigationMenuItemProps, NavigationMenuLinkProps, NavigationMenuProps } from "./NavigationMenu.types.cjs";
2
+ export type { NavigationMenuGroupProps, NavigationMenuItemProps, NavigationMenuLinkProps, NavigationMenuProps } from "./NavigationMenu.types.cjs";
3
+ /**
4
+ * A site's top navigation: buttons that open panels of links (with icons, descriptions and columns, up to full-width
5
+ * mega-menus), and plain links. It's the disclosure pattern, not a menu: each trigger is a button with aria-expanded,
6
+ * and its panel follows it in the Tab order.
7
+ */
8
+ export declare function NavigationMenu({ label, landmark, value, defaultValue, onValueChange, panelWidth, openDelay, closeDelay, children, className, }: NavigationMenuProps): import("react").JSX.Element;
9
+ /** A top-level item: a button that opens a panel of links, or a plain link when given an `href`. */
10
+ export declare function NavigationMenuItem({ trigger, value, href, active, columns, width, children, className }: NavigationMenuItemProps): import("react").JSX.Element;
11
+ /** A link in a panel, with an optional icon and a line of description. */
12
+ export declare function NavigationMenuLink({ title, description, icon, active, featured, className, ...props }: NavigationMenuLinkProps): import("react").JSX.Element;
13
+ /** A titled column of links in a panel. */
14
+ export declare function NavigationMenuGroup({ title, children, className }: NavigationMenuGroupProps): import("react").JSX.Element;
@@ -0,0 +1,14 @@
1
+ import type { NavigationMenuGroupProps, NavigationMenuItemProps, NavigationMenuLinkProps, NavigationMenuProps } from "./NavigationMenu.types.js";
2
+ export type { NavigationMenuGroupProps, NavigationMenuItemProps, NavigationMenuLinkProps, NavigationMenuProps } from "./NavigationMenu.types.js";
3
+ /**
4
+ * A site's top navigation: buttons that open panels of links (with icons, descriptions and columns, up to full-width
5
+ * mega-menus), and plain links. It's the disclosure pattern, not a menu: each trigger is a button with aria-expanded,
6
+ * and its panel follows it in the Tab order.
7
+ */
8
+ export declare function NavigationMenu({ label, landmark, value, defaultValue, onValueChange, panelWidth, openDelay, closeDelay, children, className, }: NavigationMenuProps): import("react").JSX.Element;
9
+ /** A top-level item: a button that opens a panel of links, or a plain link when given an `href`. */
10
+ export declare function NavigationMenuItem({ trigger, value, href, active, columns, width, children, className }: NavigationMenuItemProps): import("react").JSX.Element;
11
+ /** A link in a panel, with an optional icon and a line of description. */
12
+ export declare function NavigationMenuLink({ title, description, icon, active, featured, className, ...props }: NavigationMenuLinkProps): import("react").JSX.Element;
13
+ /** A titled column of links in a panel. */
14
+ export declare function NavigationMenuGroup({ title, children, className }: NavigationMenuGroupProps): import("react").JSX.Element;
@@ -0,0 +1,84 @@
1
+ import type { AnchorHTMLAttributes, MutableRefObject, ReactNode, RefObject } from "react";
2
+ export interface NavigationMenuProps {
3
+ /** Names the navigation for screen readers, such as "Main". */
4
+ label?: string;
5
+ /** Renders a `<nav>` landmark. Turn it off when it already sits in one, like SiteHeader's `nav` slot, so screen
6
+ * readers don't hear two.
7
+ * @default true */
8
+ landmark?: boolean;
9
+ /** The open item's `value`, or null when every panel is closed, when you control it. */
10
+ value?: string | null;
11
+ /** The item open at first, when it controls itself.
12
+ * @default null */
13
+ defaultValue?: string | null;
14
+ /** Called with the item that opens, or null when its panel closes. */
15
+ onValueChange?(value: string | null): void;
16
+ /** How wide panels are: as wide as their content (`"auto"`), or as wide as the header the menu sits in (or the
17
+ * menu itself, outside a header) for mega-menus (`"full"`). An item's own `width` wins.
18
+ * @default "auto" */
19
+ panelWidth?: "auto" | "full";
20
+ /** How long the pointer rests on a trigger before its panel opens, in milliseconds.
21
+ * @default 150 */
22
+ openDelay?: number;
23
+ /** How long a panel opened by hovering stays after the pointer leaves, so it can cross the gap into it.
24
+ * @default 300 */
25
+ closeDelay?: number;
26
+ /** The NavigationMenuItems. */
27
+ children: ReactNode;
28
+ className?: string;
29
+ }
30
+ export interface NavigationMenuItemProps {
31
+ /** The words on the top-level button, or on the link when there's an `href`. */
32
+ trigger: ReactNode;
33
+ /** Names the item for `value` and `onValueChange`. Defaults to a generated id. */
34
+ value?: string;
35
+ /** Makes it a plain top-level link instead of a button with a panel. */
36
+ href?: string;
37
+ /** Marks a plain link (or a trigger whose panel holds the current page) as where the person is. */
38
+ active?: boolean;
39
+ /** The panel's columns, side by side; they stack on narrow screens.
40
+ * @default 1 */
41
+ columns?: number;
42
+ /** This panel's width: pixels, any CSS width, or `"full"` to match the header. Defaults to the menu's `panelWidth`. */
43
+ width?: number | string;
44
+ /** The panel's content: NavigationMenuLinks, NavigationMenuGroups, or anything else. */
45
+ children?: ReactNode;
46
+ className?: string;
47
+ }
48
+ export interface NavigationMenuLinkProps extends Omit<AnchorHTMLAttributes<HTMLAnchorElement>, "title"> {
49
+ href: string;
50
+ /** The link's name. */
51
+ title: ReactNode;
52
+ /** A line under the title on what's there. */
53
+ description?: ReactNode;
54
+ /** An icon before the title, such as a lucide-react icon at size 18. */
55
+ icon?: ReactNode;
56
+ /** The page the person is on: sets aria-current="page". */
57
+ active?: boolean;
58
+ /** Shows it as a tinted card that fills its column, to feature one page in a mega-menu. */
59
+ featured?: boolean;
60
+ }
61
+ export interface NavigationMenuGroupProps {
62
+ /** A few words over the column, such as "Resources". */
63
+ title: ReactNode;
64
+ /** Its NavigationMenuLinks. */
65
+ children: ReactNode;
66
+ className?: string;
67
+ }
68
+ /** What a NavigationMenu shares with its items. Internal. */
69
+ export interface NavigationMenuContextValue {
70
+ value: string | null;
71
+ /** Opens an item (or closes with null); `hover` marks a panel that closes again when the pointer leaves. */
72
+ open(value: string | null, hover?: boolean): void;
73
+ /** Opens an item after the open delay, or closes after the close delay with null. */
74
+ soon(value: string | null): void;
75
+ /** Cancels a pending open or close. */
76
+ cancel(): void;
77
+ /** A click on a trigger: opens its panel, or closes it, but keeps a panel the pointer just opened by hovering. */
78
+ toggle(value: string): void;
79
+ rootRef: RefObject<HTMLElement | null>;
80
+ triggers: MutableRefObject<Map<string, HTMLElement>>;
81
+ /** The item whose panel should take focus once it opens (Down on its trigger). */
82
+ focusInto: MutableRefObject<string | null>;
83
+ panelWidth: "auto" | "full";
84
+ }
@@ -0,0 +1,84 @@
1
+ import type { AnchorHTMLAttributes, MutableRefObject, ReactNode, RefObject } from "react";
2
+ export interface NavigationMenuProps {
3
+ /** Names the navigation for screen readers, such as "Main". */
4
+ label?: string;
5
+ /** Renders a `<nav>` landmark. Turn it off when it already sits in one, like SiteHeader's `nav` slot, so screen
6
+ * readers don't hear two.
7
+ * @default true */
8
+ landmark?: boolean;
9
+ /** The open item's `value`, or null when every panel is closed, when you control it. */
10
+ value?: string | null;
11
+ /** The item open at first, when it controls itself.
12
+ * @default null */
13
+ defaultValue?: string | null;
14
+ /** Called with the item that opens, or null when its panel closes. */
15
+ onValueChange?(value: string | null): void;
16
+ /** How wide panels are: as wide as their content (`"auto"`), or as wide as the header the menu sits in (or the
17
+ * menu itself, outside a header) for mega-menus (`"full"`). An item's own `width` wins.
18
+ * @default "auto" */
19
+ panelWidth?: "auto" | "full";
20
+ /** How long the pointer rests on a trigger before its panel opens, in milliseconds.
21
+ * @default 150 */
22
+ openDelay?: number;
23
+ /** How long a panel opened by hovering stays after the pointer leaves, so it can cross the gap into it.
24
+ * @default 300 */
25
+ closeDelay?: number;
26
+ /** The NavigationMenuItems. */
27
+ children: ReactNode;
28
+ className?: string;
29
+ }
30
+ export interface NavigationMenuItemProps {
31
+ /** The words on the top-level button, or on the link when there's an `href`. */
32
+ trigger: ReactNode;
33
+ /** Names the item for `value` and `onValueChange`. Defaults to a generated id. */
34
+ value?: string;
35
+ /** Makes it a plain top-level link instead of a button with a panel. */
36
+ href?: string;
37
+ /** Marks a plain link (or a trigger whose panel holds the current page) as where the person is. */
38
+ active?: boolean;
39
+ /** The panel's columns, side by side; they stack on narrow screens.
40
+ * @default 1 */
41
+ columns?: number;
42
+ /** This panel's width: pixels, any CSS width, or `"full"` to match the header. Defaults to the menu's `panelWidth`. */
43
+ width?: number | string;
44
+ /** The panel's content: NavigationMenuLinks, NavigationMenuGroups, or anything else. */
45
+ children?: ReactNode;
46
+ className?: string;
47
+ }
48
+ export interface NavigationMenuLinkProps extends Omit<AnchorHTMLAttributes<HTMLAnchorElement>, "title"> {
49
+ href: string;
50
+ /** The link's name. */
51
+ title: ReactNode;
52
+ /** A line under the title on what's there. */
53
+ description?: ReactNode;
54
+ /** An icon before the title, such as a lucide-react icon at size 18. */
55
+ icon?: ReactNode;
56
+ /** The page the person is on: sets aria-current="page". */
57
+ active?: boolean;
58
+ /** Shows it as a tinted card that fills its column, to feature one page in a mega-menu. */
59
+ featured?: boolean;
60
+ }
61
+ export interface NavigationMenuGroupProps {
62
+ /** A few words over the column, such as "Resources". */
63
+ title: ReactNode;
64
+ /** Its NavigationMenuLinks. */
65
+ children: ReactNode;
66
+ className?: string;
67
+ }
68
+ /** What a NavigationMenu shares with its items. Internal. */
69
+ export interface NavigationMenuContextValue {
70
+ value: string | null;
71
+ /** Opens an item (or closes with null); `hover` marks a panel that closes again when the pointer leaves. */
72
+ open(value: string | null, hover?: boolean): void;
73
+ /** Opens an item after the open delay, or closes after the close delay with null. */
74
+ soon(value: string | null): void;
75
+ /** Cancels a pending open or close. */
76
+ cancel(): void;
77
+ /** A click on a trigger: opens its panel, or closes it, but keeps a panel the pointer just opened by hovering. */
78
+ toggle(value: string): void;
79
+ rootRef: RefObject<HTMLElement | null>;
80
+ triggers: MutableRefObject<Map<string, HTMLElement>>;
81
+ /** The item whose panel should take focus once it opens (Down on its trigger). */
82
+ focusInto: MutableRefObject<string | null>;
83
+ panelWidth: "auto" | "full";
84
+ }
@@ -0,0 +1,7 @@
1
+ import type { SortableListProps } from "./SortableList.types.cjs";
2
+ export type { SortableListItemState, SortableListLabels, SortableListProps } from "./SortableList.types.cjs";
3
+ /**
4
+ * A list people put in order: drag an item (by the whole row, or by its grip with `handle`) and the others move to
5
+ * make room, or focus it, press Space, move it with the arrow keys and press Space again. Each step is read out.
6
+ */
7
+ export declare function SortableList<Item>({ items, defaultItems, onReorder, renderItem, getKey, itemLabel, label, handle, orientation, disabled, labels: labelsProp, className, ...props }: SortableListProps<Item>): import("react").JSX.Element;
@@ -0,0 +1,7 @@
1
+ import type { SortableListProps } from "./SortableList.types.js";
2
+ export type { SortableListItemState, SortableListLabels, SortableListProps } from "./SortableList.types.js";
3
+ /**
4
+ * A list people put in order: drag an item (by the whole row, or by its grip with `handle`) and the others move to
5
+ * make room, or focus it, press Space, move it with the arrow keys and press Space again. Each step is read out.
6
+ */
7
+ export declare function SortableList<Item>({ items, defaultItems, onReorder, renderItem, getKey, itemLabel, label, handle, orientation, disabled, labels: labelsProp, className, ...props }: SortableListProps<Item>): import("react").JSX.Element;
@@ -0,0 +1,82 @@
1
+ import type { HTMLAttributes, Key, ReactNode } from "react";
2
+ export interface SortableListLabels {
3
+ /** Read out when an item is picked up.
4
+ * @default (item, position, total) => `Picked up ${item}. Position ${position} of ${total}.` */
5
+ pickedUp?(item: string, position: number, total: number): string;
6
+ /** Read out at each step while it's carried.
7
+ * @default (item, position, total) => `${item}, position ${position} of ${total}.` */
8
+ moved?(item: string, position: number, total: number): string;
9
+ /** Read out when it's put down.
10
+ * @default (item, position, total) => `Dropped ${item} at position ${position} of ${total}.` */
11
+ dropped?(item: string, position: number, total: number): string;
12
+ /** Read out when Escape puts it back.
13
+ * @default (item, position, total) => `Cancelled. ${item} is back at position ${position} of ${total}.` */
14
+ cancelled?(item: string, position: number, total: number): string;
15
+ /** Each item's description, telling screen reader users how to move it.
16
+ * @default "Press Space to pick up, the arrow keys to move, Space to drop, Escape to cancel." */
17
+ instructions?: string;
18
+ /** The grip's name, before the item's own text: "Reorder Columns".
19
+ * @default "Reorder" */
20
+ handle?: string;
21
+ }
22
+ export interface SortableListItemState {
23
+ /** Where the item is in the list, from 0. */
24
+ index: number;
25
+ /** It's picked up: being dragged, or carried with the keyboard. */
26
+ isDragging: boolean;
27
+ }
28
+ export interface SortableListProps<Item> extends Omit<HTMLAttributes<HTMLOListElement>, "children" | "onChange" | "defaultValue"> {
29
+ /** The items in order, when you control them. */
30
+ items?: Item[];
31
+ /** The items at first, when it keeps the order itself.
32
+ * @default [] */
33
+ defaultItems?: Item[];
34
+ /** Called with the items in their new order, and where the moved one was and went (indexes from 0). */
35
+ onReorder?(items: Item[], move: {
36
+ from: number;
37
+ to: number;
38
+ }): void;
39
+ /** What each item shows. */
40
+ renderItem(item: Item, state: SortableListItemState): ReactNode;
41
+ /** Gives each item a unique key.
42
+ * @default (item) => item.id, or the item itself when it's a string or a number */
43
+ getKey?(item: Item): Key;
44
+ /** Names an item in what's read out as it moves ("Picked up Email"). Defaults to the item when it's a string
45
+ * or a number, else the text it shows. */
46
+ itemLabel?(item: Item): string;
47
+ /** Names the list for screen readers: "Column order". Required unless `aria-labelledby` points at a heading. */
48
+ label?: string;
49
+ /**
50
+ * Only a grip at the start of each row picks it up, rather than the whole row. Use it when rows hold their own
51
+ * buttons, switches or links, or on long lists people scroll by touch.
52
+ * @default false
53
+ */
54
+ handle?: boolean;
55
+ /** `horizontal` lays the items in a row that scrolls sideways; the arrow keys follow the text direction.
56
+ * @default "vertical" */
57
+ orientation?: "vertical" | "horizontal";
58
+ /** @default false */
59
+ disabled?: boolean;
60
+ /** The words it reads out, for other languages. */
61
+ labels?: SortableListLabels;
62
+ }
63
+ /** Where the items were when the drag started, along the list's axis, in viewport pixels. Internal. */
64
+ export interface SortableGeometry {
65
+ lo: number[];
66
+ hi: number[];
67
+ /** -1 when the list runs backwards on screen: a row in right-to-left text. */
68
+ dir: number;
69
+ /** How far the others move to make room: the picked-up item's size and the gap after it. */
70
+ step: number;
71
+ scroller: Element;
72
+ scroll: number;
73
+ }
74
+ /** A drag in progress, by pointer or keyboard. Internal. */
75
+ export interface SortableDrag {
76
+ from: number;
77
+ to: number;
78
+ /** How far a dragged item has followed the pointer. */
79
+ offset: number;
80
+ keyboard: boolean;
81
+ geo: SortableGeometry;
82
+ }
@@ -0,0 +1,82 @@
1
+ import type { HTMLAttributes, Key, ReactNode } from "react";
2
+ export interface SortableListLabels {
3
+ /** Read out when an item is picked up.
4
+ * @default (item, position, total) => `Picked up ${item}. Position ${position} of ${total}.` */
5
+ pickedUp?(item: string, position: number, total: number): string;
6
+ /** Read out at each step while it's carried.
7
+ * @default (item, position, total) => `${item}, position ${position} of ${total}.` */
8
+ moved?(item: string, position: number, total: number): string;
9
+ /** Read out when it's put down.
10
+ * @default (item, position, total) => `Dropped ${item} at position ${position} of ${total}.` */
11
+ dropped?(item: string, position: number, total: number): string;
12
+ /** Read out when Escape puts it back.
13
+ * @default (item, position, total) => `Cancelled. ${item} is back at position ${position} of ${total}.` */
14
+ cancelled?(item: string, position: number, total: number): string;
15
+ /** Each item's description, telling screen reader users how to move it.
16
+ * @default "Press Space to pick up, the arrow keys to move, Space to drop, Escape to cancel." */
17
+ instructions?: string;
18
+ /** The grip's name, before the item's own text: "Reorder Columns".
19
+ * @default "Reorder" */
20
+ handle?: string;
21
+ }
22
+ export interface SortableListItemState {
23
+ /** Where the item is in the list, from 0. */
24
+ index: number;
25
+ /** It's picked up: being dragged, or carried with the keyboard. */
26
+ isDragging: boolean;
27
+ }
28
+ export interface SortableListProps<Item> extends Omit<HTMLAttributes<HTMLOListElement>, "children" | "onChange" | "defaultValue"> {
29
+ /** The items in order, when you control them. */
30
+ items?: Item[];
31
+ /** The items at first, when it keeps the order itself.
32
+ * @default [] */
33
+ defaultItems?: Item[];
34
+ /** Called with the items in their new order, and where the moved one was and went (indexes from 0). */
35
+ onReorder?(items: Item[], move: {
36
+ from: number;
37
+ to: number;
38
+ }): void;
39
+ /** What each item shows. */
40
+ renderItem(item: Item, state: SortableListItemState): ReactNode;
41
+ /** Gives each item a unique key.
42
+ * @default (item) => item.id, or the item itself when it's a string or a number */
43
+ getKey?(item: Item): Key;
44
+ /** Names an item in what's read out as it moves ("Picked up Email"). Defaults to the item when it's a string
45
+ * or a number, else the text it shows. */
46
+ itemLabel?(item: Item): string;
47
+ /** Names the list for screen readers: "Column order". Required unless `aria-labelledby` points at a heading. */
48
+ label?: string;
49
+ /**
50
+ * Only a grip at the start of each row picks it up, rather than the whole row. Use it when rows hold their own
51
+ * buttons, switches or links, or on long lists people scroll by touch.
52
+ * @default false
53
+ */
54
+ handle?: boolean;
55
+ /** `horizontal` lays the items in a row that scrolls sideways; the arrow keys follow the text direction.
56
+ * @default "vertical" */
57
+ orientation?: "vertical" | "horizontal";
58
+ /** @default false */
59
+ disabled?: boolean;
60
+ /** The words it reads out, for other languages. */
61
+ labels?: SortableListLabels;
62
+ }
63
+ /** Where the items were when the drag started, along the list's axis, in viewport pixels. Internal. */
64
+ export interface SortableGeometry {
65
+ lo: number[];
66
+ hi: number[];
67
+ /** -1 when the list runs backwards on screen: a row in right-to-left text. */
68
+ dir: number;
69
+ /** How far the others move to make room: the picked-up item's size and the gap after it. */
70
+ step: number;
71
+ scroller: Element;
72
+ scroll: number;
73
+ }
74
+ /** A drag in progress, by pointer or keyboard. Internal. */
75
+ export interface SortableDrag {
76
+ from: number;
77
+ to: number;
78
+ /** How far a dragged item has followed the pointer. */
79
+ offset: number;
80
+ keyboard: boolean;
81
+ geo: SortableGeometry;
82
+ }
@@ -0,0 +1,8 @@
1
+ import type { TreeViewProps } from "./TreeView.types.cjs";
2
+ export type { TreeItem, TreeViewLabels, TreeViewProps, TreeViewSelectionMode } from "./TreeView.types.cjs";
3
+ /**
4
+ * A tree of rows that open and close, for categories, org charts, permissions, nested settings or navigation. Rows can
5
+ * be selected (one or many), checked with tri-state parents, activated, and their children fetched when they first open.
6
+ * It's one tab stop: the arrow keys move and open, Home/End jump, typing finds a row, Space selects and Enter activates.
7
+ */
8
+ export declare function TreeView({ items, label, "aria-labelledby": ariaLabelledBy, expanded, defaultExpanded, onExpandedChange, selectionMode, selected, defaultSelected, onSelectedChange, checkboxes, loadChildren, onAction, renderLabel, labels: labelsProp, className, }: TreeViewProps): import("react").JSX.Element;
@@ -0,0 +1,8 @@
1
+ import type { TreeViewProps } from "./TreeView.types.js";
2
+ export type { TreeItem, TreeViewLabels, TreeViewProps, TreeViewSelectionMode } from "./TreeView.types.js";
3
+ /**
4
+ * A tree of rows that open and close, for categories, org charts, permissions, nested settings or navigation. Rows can
5
+ * be selected (one or many), checked with tri-state parents, activated, and their children fetched when they first open.
6
+ * It's one tab stop: the arrow keys move and open, Home/End jump, typing finds a row, Space selects and Enter activates.
7
+ */
8
+ export declare function TreeView({ items, label, "aria-labelledby": ariaLabelledBy, expanded, defaultExpanded, onExpandedChange, selectionMode, selected, defaultSelected, onSelectedChange, checkboxes, loadChildren, onAction, renderLabel, labels: labelsProp, className, }: TreeViewProps): import("react").JSX.Element;