@ratio-ui/core 0.1.1 → 0.2.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/README.md +2 -0
- package/dist/catalogue.json +1719 -43
- package/dist/components/app-shell/AppShell.d.ts +22 -0
- package/dist/components/app-shell/AppShell.js +39 -0
- package/dist/components/app-shell/context.js +5 -0
- package/dist/components/app-shell/index.d.ts +2 -0
- package/dist/components/app-shell/index.js +1 -0
- package/dist/components/avatar/Avatar.d.ts +22 -0
- package/dist/components/avatar/Avatar.js +38 -0
- package/dist/components/avatar/index.d.ts +2 -0
- package/dist/components/avatar/index.js +1 -0
- package/dist/components/button/Button.d.ts +37 -0
- package/dist/components/button/Button.js +41 -0
- package/dist/components/button/index.d.ts +2 -0
- package/dist/components/button/index.js +1 -0
- package/dist/components/card/Card.d.ts +33 -0
- package/dist/components/card/Card.js +53 -0
- package/dist/components/card/index.d.ts +2 -0
- package/dist/components/card/index.js +1 -0
- package/dist/components/checkbox/Checkbox.d.ts +10 -0
- package/dist/components/checkbox/Checkbox.js +28 -0
- package/dist/components/checkbox/index.d.ts +2 -0
- package/dist/components/checkbox/index.js +1 -0
- package/dist/components/data-table/DataTable.d.ts +65 -0
- package/dist/components/data-table/DataTable.js +141 -0
- package/dist/components/data-table/index.d.ts +2 -0
- package/dist/components/data-table/index.js +1 -0
- package/dist/components/definition/Definition.d.ts +14 -0
- package/dist/components/definition/Definition.js +29 -0
- package/dist/components/definition/index.d.ts +2 -0
- package/dist/components/definition/index.js +1 -0
- package/dist/components/dialog/Dialog.d.ts +44 -0
- package/dist/components/dialog/Dialog.js +79 -0
- package/dist/components/dialog/index.d.ts +2 -0
- package/dist/components/dialog/index.js +1 -0
- package/dist/components/dropdown-menu/DropdownMenu.d.ts +73 -0
- package/dist/components/dropdown-menu/DropdownMenu.js +116 -0
- package/dist/components/dropdown-menu/index.d.ts +2 -0
- package/dist/components/dropdown-menu/index.js +1 -0
- package/dist/components/empty-state/EmptyState.d.ts +15 -0
- package/dist/components/empty-state/EmptyState.js +30 -0
- package/dist/components/empty-state/index.d.ts +2 -0
- package/dist/components/empty-state/index.js +1 -0
- package/dist/components/filter-tabs/FilterTabs.d.ts +28 -0
- package/dist/components/filter-tabs/FilterTabs.js +37 -0
- package/dist/components/filter-tabs/index.d.ts +2 -0
- package/dist/components/filter-tabs/index.js +1 -0
- package/dist/components/global-search/GlobalSearch.d.ts +51 -0
- package/dist/components/global-search/GlobalSearch.js +144 -0
- package/dist/components/global-search/index.d.ts +2 -0
- package/dist/components/global-search/index.js +1 -0
- package/dist/components/icon/registry.d.ts +3 -2
- package/dist/components/icon/registry.js +53 -1
- package/dist/components/input/Input.d.ts +19 -0
- package/dist/components/input/Input.js +26 -0
- package/dist/components/input/index.d.ts +2 -0
- package/dist/components/input/index.js +1 -0
- package/dist/components/input-group/InputGroup.d.ts +42 -0
- package/dist/components/input-group/InputGroup.js +83 -0
- package/dist/components/input-group/index.d.ts +2 -0
- package/dist/components/input-group/index.js +1 -0
- package/dist/components/kbd/Kbd.d.ts +17 -0
- package/dist/components/kbd/Kbd.js +21 -0
- package/dist/components/kbd/index.d.ts +2 -0
- package/dist/components/kbd/index.js +1 -0
- package/dist/components/link-provider/LinkProvider.d.ts +29 -0
- package/dist/components/link-provider/LinkProvider.js +15 -0
- package/dist/components/link-provider/RatioLink.js +18 -0
- package/dist/components/link-provider/context.js +4 -0
- package/dist/components/link-provider/index.d.ts +2 -0
- package/dist/components/link-provider/index.js +1 -0
- package/dist/components/metric-strip/MetricStrip.d.ts +23 -0
- package/dist/components/metric-strip/MetricStrip.js +39 -0
- package/dist/components/metric-strip/index.d.ts +2 -0
- package/dist/components/metric-strip/index.js +1 -0
- package/dist/components/page-header/PageHeader.d.ts +37 -0
- package/dist/components/page-header/PageHeader.js +62 -0
- package/dist/components/page-header/index.d.ts +2 -0
- package/dist/components/page-header/index.js +1 -0
- package/dist/components/pagination/Pagination.d.ts +18 -0
- package/dist/components/pagination/Pagination.js +59 -0
- package/dist/components/pagination/index.d.ts +2 -0
- package/dist/components/pagination/index.js +1 -0
- package/dist/components/popover/Popover.d.ts +27 -0
- package/dist/components/popover/Popover.js +47 -0
- package/dist/components/popover/index.d.ts +2 -0
- package/dist/components/popover/index.js +1 -0
- package/dist/components/search-field/SearchField.d.ts +23 -0
- package/dist/components/search-field/SearchField.js +66 -0
- package/dist/components/search-field/index.d.ts +2 -0
- package/dist/components/search-field/index.js +1 -0
- package/dist/components/side-nav/SideNav.d.ts +64 -0
- package/dist/components/side-nav/SideNav.js +194 -0
- package/dist/components/side-nav/index.d.ts +2 -0
- package/dist/components/side-nav/index.js +1 -0
- package/dist/components/skeleton/Skeleton.d.ts +13 -0
- package/dist/components/skeleton/Skeleton.js +21 -0
- package/dist/components/skeleton/index.d.ts +2 -0
- package/dist/components/skeleton/index.js +1 -0
- package/dist/components/spinner/Spinner.d.ts +11 -0
- package/dist/components/spinner/Spinner.js +16 -0
- package/dist/components/spinner/index.d.ts +2 -0
- package/dist/components/spinner/index.js +1 -0
- package/dist/components/status-pill/StatusPill.d.ts +14 -0
- package/dist/components/status-pill/StatusPill.js +19 -0
- package/dist/components/status-pill/index.d.ts +2 -0
- package/dist/components/status-pill/index.js +1 -0
- package/dist/components/table/Table.d.ts +46 -0
- package/dist/components/table/Table.js +87 -0
- package/dist/components/table/index.d.ts +2 -0
- package/dist/components/table/index.js +1 -0
- package/dist/components/table-loader/TableLoader.d.ts +31 -0
- package/dist/components/table-loader/TableLoader.js +35 -0
- package/dist/components/table-loader/index.d.ts +2 -0
- package/dist/components/table-loader/index.js +1 -0
- package/dist/components/tabs/Tabs.d.ts +23 -0
- package/dist/components/tabs/Tabs.js +41 -0
- package/dist/components/tabs/index.d.ts +2 -0
- package/dist/components/tabs/index.js +1 -0
- package/dist/components/toaster/Toaster.d.ts +32 -0
- package/dist/components/toaster/Toaster.js +89 -0
- package/dist/components/toaster/index.d.ts +2 -0
- package/dist/components/toaster/index.js +1 -0
- package/dist/components/tooltip/Tooltip.d.ts +18 -0
- package/dist/components/tooltip/Tooltip.js +35 -0
- package/dist/components/tooltip/index.d.ts +2 -0
- package/dist/components/tooltip/index.js +1 -0
- package/dist/components/top-bar/StoreSwitcher.d.ts +26 -0
- package/dist/components/top-bar/StoreSwitcher.js +48 -0
- package/dist/components/top-bar/TopBar.d.ts +24 -0
- package/dist/components/top-bar/TopBar.js +53 -0
- package/dist/components/top-bar/index.d.ts +3 -0
- package/dist/components/top-bar/index.js +3 -0
- package/dist/index.d.ts +65 -1
- package/dist/index.js +35 -2
- package/dist/lib/cn.js +32 -27
- package/dist/lib/format.d.ts +31 -0
- package/dist/lib/format.js +65 -0
- package/dist/styles.css +1 -1
- package/package.json +128 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Definition } from "./Definition.js";
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { ComponentProps, JSX } from "react";
|
|
2
|
+
import { Dialog } from "@base-ui/react/dialog";
|
|
3
|
+
/**
|
|
4
|
+
* The root of a dialog. It holds the open state and renders nothing itself. Pass `open` and `onOpenChange` to control it,
|
|
5
|
+
* or `defaultOpen` to leave it uncontrolled. The page behind is inert while it is open, with no scrim over it.
|
|
6
|
+
*/
|
|
7
|
+
declare function Dialog$1(props: Dialog.Root.Props): JSX.Element;
|
|
8
|
+
/** Props of DialogTrigger. */
|
|
9
|
+
export type DialogTriggerProps = Omit<Dialog.Trigger.Props, 'className' | 'style'>;
|
|
10
|
+
/** The button that opens the dialog. */
|
|
11
|
+
export declare function DialogTrigger(props: DialogTriggerProps): JSX.Element;
|
|
12
|
+
/** Props of DialogClose. */
|
|
13
|
+
export type DialogCloseProps = Omit<Dialog.Close.Props, 'className' | 'style'>;
|
|
14
|
+
/** A button that closes the dialog, such as Cancel in the footer. */
|
|
15
|
+
export declare function DialogClose(props: DialogCloseProps): JSX.Element;
|
|
16
|
+
/** Props of DialogContent. */
|
|
17
|
+
export interface DialogContentProps extends Omit<Dialog.Popup.Props, 'className' | 'style'> {
|
|
18
|
+
/** Whether the corner close button shows. Defaults to true. */
|
|
19
|
+
showCloseButton?: boolean;
|
|
20
|
+
/** The accessible name of the corner close button. Defaults to Close. */
|
|
21
|
+
closeLabel?: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The panel: 480px wide, white, drawn with the ring outline and no shadow, with no scrim behind it. Put DialogHeader,
|
|
25
|
+
* the form and DialogFooter inside.
|
|
26
|
+
*/
|
|
27
|
+
export declare function DialogContent({ children, showCloseButton, closeLabel, ...props }: DialogContentProps): JSX.Element;
|
|
28
|
+
/** Props of DialogHeader. */
|
|
29
|
+
export type DialogHeaderProps = Omit<ComponentProps<'div'>, 'className' | 'style'>;
|
|
30
|
+
/** The title and description, stacked. */
|
|
31
|
+
export declare function DialogHeader(props: DialogHeaderProps): JSX.Element;
|
|
32
|
+
/** Props of DialogFooter. */
|
|
33
|
+
export type DialogFooterProps = Omit<ComponentProps<'div'>, 'className' | 'style'>;
|
|
34
|
+
/** The row of actions at the bottom, aligned to the end. */
|
|
35
|
+
export declare function DialogFooter(props: DialogFooterProps): JSX.Element;
|
|
36
|
+
/** Props of DialogTitle. */
|
|
37
|
+
export type DialogTitleProps = Omit<Dialog.Title.Props, 'className' | 'style'>;
|
|
38
|
+
/** The dialog's name, in the b4 style. It names the dialog for assistive technology. */
|
|
39
|
+
export declare function DialogTitle(props: DialogTitleProps): JSX.Element;
|
|
40
|
+
/** Props of DialogDescription. */
|
|
41
|
+
export type DialogDescriptionProps = Omit<Dialog.Description.Props, 'className' | 'style'>;
|
|
42
|
+
/** One line that says what the dialog is for, in subdued body text. */
|
|
43
|
+
export declare function DialogDescription(props: DialogDescriptionProps): JSX.Element;
|
|
44
|
+
export { Dialog$1 as Dialog };
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { cn } from "../../lib/cn.js";
|
|
2
|
+
import { Icon } from "../icon/Icon.js";
|
|
3
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
import { Dialog } from "@base-ui/react/dialog";
|
|
5
|
+
// src/components/dialog/Dialog.tsx
|
|
6
|
+
/**
|
|
7
|
+
* The root of a dialog. It holds the open state and renders nothing itself. Pass `open` and `onOpenChange` to control it,
|
|
8
|
+
* or `defaultOpen` to leave it uncontrolled. The page behind is inert while it is open, with no scrim over it.
|
|
9
|
+
*/
|
|
10
|
+
function Dialog$1(props) {
|
|
11
|
+
return /* @__PURE__ */ jsx(Dialog.Root, { ...props });
|
|
12
|
+
}
|
|
13
|
+
/** The button that opens the dialog. */
|
|
14
|
+
function DialogTrigger(props) {
|
|
15
|
+
return /* @__PURE__ */ jsx(Dialog.Trigger, {
|
|
16
|
+
"data-slot": "dialog-trigger",
|
|
17
|
+
...props
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
/** A button that closes the dialog, such as Cancel in the footer. */
|
|
21
|
+
function DialogClose(props) {
|
|
22
|
+
return /* @__PURE__ */ jsx(Dialog.Close, {
|
|
23
|
+
"data-slot": "dialog-close",
|
|
24
|
+
...props
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The panel: 480px wide, white, drawn with the ring outline and no shadow, with no scrim behind it. Put DialogHeader,
|
|
29
|
+
* the form and DialogFooter inside.
|
|
30
|
+
*/
|
|
31
|
+
function DialogContent({ children, showCloseButton = true, closeLabel = "Close", ...props }) {
|
|
32
|
+
return /* @__PURE__ */ jsx(Dialog.Portal, { children: /* @__PURE__ */ jsxs(Dialog.Popup, {
|
|
33
|
+
"data-slot": "dialog-content",
|
|
34
|
+
className: "rt:fixed rt:inset-0 rt:z-50 rt:m-auto rt:flex rt:h-fit rt:max-h-full rt:w-120 rt:max-w-full rt:overflow-y-auto rt:flex-col rt:gap-6 rt:rounded-lg rt:bg-popover rt:p-6 rt:text-b3 rt:text-popover-foreground rt:shadow-ring-strong rt:forced-outline rt:focus-visible:focus-ring",
|
|
35
|
+
...props,
|
|
36
|
+
children: [children, showCloseButton && /* @__PURE__ */ jsx(Dialog.Close, {
|
|
37
|
+
"data-slot": "dialog-close",
|
|
38
|
+
"aria-label": closeLabel,
|
|
39
|
+
className: "rt:absolute rt:top-4 rt:right-4 rt:flex rt:size-7 rt:items-center rt:justify-center rt:rounded-md rt:text-icon rt:transition-colors rt:hover:bg-primary-tint rt:focus-visible:focus-ring",
|
|
40
|
+
children: /* @__PURE__ */ jsx(Icon, {
|
|
41
|
+
name: "x",
|
|
42
|
+
size: 12
|
|
43
|
+
})
|
|
44
|
+
})]
|
|
45
|
+
}) });
|
|
46
|
+
}
|
|
47
|
+
/** The title and description, stacked. */
|
|
48
|
+
function DialogHeader(props) {
|
|
49
|
+
return /* @__PURE__ */ jsx("div", {
|
|
50
|
+
"data-slot": "dialog-header",
|
|
51
|
+
className: "rt:flex rt:flex-col rt:gap-1",
|
|
52
|
+
...props
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
/** The row of actions at the bottom, aligned to the end. */
|
|
56
|
+
function DialogFooter(props) {
|
|
57
|
+
return /* @__PURE__ */ jsx("div", {
|
|
58
|
+
"data-slot": "dialog-footer",
|
|
59
|
+
className: "rt:flex rt:items-center rt:justify-end rt:gap-2",
|
|
60
|
+
...props
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
/** The dialog's name, in the b4 style. It names the dialog for assistive technology. */
|
|
64
|
+
function DialogTitle(props) {
|
|
65
|
+
return /* @__PURE__ */ jsx(Dialog.Title, {
|
|
66
|
+
"data-slot": "dialog-title",
|
|
67
|
+
className: cn("rt:text-b4 rt:text-foreground-strong"),
|
|
68
|
+
...props
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
/** One line that says what the dialog is for, in subdued body text. */
|
|
72
|
+
function DialogDescription(props) {
|
|
73
|
+
return /* @__PURE__ */ jsx(Dialog.Description, {
|
|
74
|
+
"data-slot": "dialog-description",
|
|
75
|
+
className: "rt:text-b3 rt:text-foreground-subdued",
|
|
76
|
+
...props
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
export { Dialog$1 as Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { Dialog, DialogClose, DialogCloseProps, DialogContent, DialogContentProps, DialogDescription, DialogDescriptionProps, DialogFooter, DialogFooterProps, DialogHeader, DialogHeaderProps, DialogTitle, DialogTitleProps, DialogTrigger, DialogTriggerProps } from "./Dialog.js";
|
|
2
|
+
export { Dialog, DialogClose, type DialogCloseProps, DialogContent, type DialogContentProps, DialogDescription, type DialogDescriptionProps, DialogFooter, type DialogFooterProps, DialogHeader, type DialogHeaderProps, DialogTitle, type DialogTitleProps, DialogTrigger, type DialogTriggerProps };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger } from "./Dialog.js";
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { JSX, ReactNode } from "react";
|
|
2
|
+
import { Menu } from "@base-ui/react/menu";
|
|
3
|
+
/** Props of DropdownMenu, the root that holds the open state. It renders no element. */
|
|
4
|
+
export type DropdownMenuProps = Menu.Root.Props;
|
|
5
|
+
/** The root of a menu of actions that opens from a trigger. Compose it with DropdownMenuTrigger and DropdownMenuContent. */
|
|
6
|
+
export declare function DropdownMenu(props: DropdownMenuProps): JSX.Element;
|
|
7
|
+
/** Props of DropdownMenuTrigger. The trigger is a button; pass `render` to draw another element. */
|
|
8
|
+
export type DropdownMenuTriggerProps = Omit<Menu.Trigger.Props, 'className' | 'style'>;
|
|
9
|
+
/** The control that opens the menu. It is a button, and carries aria-expanded and aria-haspopup. */
|
|
10
|
+
export declare function DropdownMenuTrigger(props: DropdownMenuTriggerProps): JSX.Element;
|
|
11
|
+
/** Props of DropdownMenuContent. */
|
|
12
|
+
export interface DropdownMenuContentProps extends Omit<Menu.Popup.Props, 'className' | 'style'> {
|
|
13
|
+
/** Which side of the trigger the menu opens on. Defaults to bottom. */
|
|
14
|
+
side?: Menu.Positioner.Props['side'];
|
|
15
|
+
/** How the menu lines up with the trigger along that side. Defaults to start. */
|
|
16
|
+
align?: Menu.Positioner.Props['align'];
|
|
17
|
+
/** The gap between the trigger and the menu in px. Defaults to 4. */
|
|
18
|
+
sideOffset?: number;
|
|
19
|
+
/** A shift along the side in px. Defaults to 0. */
|
|
20
|
+
alignOffset?: number;
|
|
21
|
+
}
|
|
22
|
+
/** The menu panel: a white popup with a hairline ring, 8px corners and no shadow. It opens in a portal. */
|
|
23
|
+
export declare function DropdownMenuContent({ side, align, sideOffset, alignOffset, ...props }: DropdownMenuContentProps): JSX.Element;
|
|
24
|
+
/** Props of DropdownMenuGroup: Base UI's group props, except className and style. */
|
|
25
|
+
export type DropdownMenuGroupProps = Omit<Menu.Group.Props, 'className' | 'style'>;
|
|
26
|
+
/** Groups items under one DropdownMenuLabel, so assistive technology announces the label with the group. */
|
|
27
|
+
export declare function DropdownMenuGroup(props: DropdownMenuGroupProps): JSX.Element;
|
|
28
|
+
/** Props of DropdownMenuLabel. */
|
|
29
|
+
export type DropdownMenuLabelProps = Omit<Menu.GroupLabel.Props, 'className' | 'style'>;
|
|
30
|
+
/** The caption of a group, in the design system's label style: 12px, uppercase, subdued. Place it inside DropdownMenuGroup. */
|
|
31
|
+
export declare function DropdownMenuLabel(props: DropdownMenuLabelProps): JSX.Element;
|
|
32
|
+
/** Props of DropdownMenuItem. */
|
|
33
|
+
export interface DropdownMenuItemProps extends Omit<Menu.Item.Props, 'className' | 'style'> {
|
|
34
|
+
/** What the item means. destructive is drawn in the destructive token; a delete action also needs a confirm step. Defaults to default. */
|
|
35
|
+
variant?: 'default' | 'destructive';
|
|
36
|
+
}
|
|
37
|
+
/** One action in the menu. It runs onClick and closes the menu; disabled is drawn at half opacity and cannot be chosen. */
|
|
38
|
+
export declare function DropdownMenuItem({ variant, ...props }: DropdownMenuItemProps): JSX.Element;
|
|
39
|
+
/** Props of DropdownMenuShortcut. */
|
|
40
|
+
export interface DropdownMenuShortcutProps {
|
|
41
|
+
/** The key hint, such as ⌘E. It is text only and does not bind a key. */
|
|
42
|
+
children: ReactNode;
|
|
43
|
+
}
|
|
44
|
+
/** A key hint pushed to the end of an item. It is a hint only: the host binds the key. */
|
|
45
|
+
export declare function DropdownMenuShortcut({ children }: DropdownMenuShortcutProps): JSX.Element;
|
|
46
|
+
/** Props of DropdownMenuSeparator. */
|
|
47
|
+
export type DropdownMenuSeparatorProps = Omit<Menu.Separator.Props, 'className' | 'style'>;
|
|
48
|
+
/** A hairline between groups of items. */
|
|
49
|
+
export declare function DropdownMenuSeparator(props: DropdownMenuSeparatorProps): JSX.Element;
|
|
50
|
+
/** Props of DropdownMenuSub, the root of a submenu. It renders no element. */
|
|
51
|
+
export type DropdownMenuSubProps = Menu.SubmenuRoot.Props;
|
|
52
|
+
/** The root of a nested menu. Hold a DropdownMenuSubTrigger and a DropdownMenuSubContent. */
|
|
53
|
+
export declare function DropdownMenuSub(props: DropdownMenuSubProps): JSX.Element;
|
|
54
|
+
/** Props of DropdownMenuSubTrigger. */
|
|
55
|
+
export type DropdownMenuSubTriggerProps = Omit<Menu.SubmenuTrigger.Props, 'className' | 'style'>;
|
|
56
|
+
/** The item that opens a submenu, on hover, click or ArrowRight. A chevron at its end marks it. */
|
|
57
|
+
export declare function DropdownMenuSubTrigger({ children, ...props }: DropdownMenuSubTriggerProps): JSX.Element;
|
|
58
|
+
/** Props of DropdownMenuSubContent. */
|
|
59
|
+
export type DropdownMenuSubContentProps = DropdownMenuContentProps;
|
|
60
|
+
/** The panel of a submenu. It opens to the side of its trigger. */
|
|
61
|
+
export declare function DropdownMenuSubContent({ side, alignOffset, sideOffset, ...props }: DropdownMenuSubContentProps): JSX.Element;
|
|
62
|
+
/** Props of DropdownMenuCheckboxItem. */
|
|
63
|
+
export type DropdownMenuCheckboxItemProps = Omit<Menu.CheckboxItem.Props, 'className' | 'style'>;
|
|
64
|
+
/** An item that toggles an option. A check shows at its start while it is on and keeps the menu open, so several options can be changed in one visit. */
|
|
65
|
+
export declare function DropdownMenuCheckboxItem({ children, ...props }: DropdownMenuCheckboxItemProps): JSX.Element;
|
|
66
|
+
/** Props of DropdownMenuRadioGroup: Base UI's radio group props, except className and style. */
|
|
67
|
+
export type DropdownMenuRadioGroupProps = Omit<Menu.RadioGroup.Props, 'className' | 'style'>;
|
|
68
|
+
/** Holds radio items and the one chosen value. */
|
|
69
|
+
export declare function DropdownMenuRadioGroup(props: DropdownMenuRadioGroupProps): JSX.Element;
|
|
70
|
+
/** Props of DropdownMenuRadioItem. */
|
|
71
|
+
export type DropdownMenuRadioItemProps = Omit<Menu.RadioItem.Props, 'className' | 'style'>;
|
|
72
|
+
/** One choice of a DropdownMenuRadioGroup. A dot shows at its start while it is the chosen value. */
|
|
73
|
+
export declare function DropdownMenuRadioItem({ children, ...props }: DropdownMenuRadioItemProps): JSX.Element;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { cn } from "../../lib/cn.js";
|
|
2
|
+
import { Icon } from "../icon/Icon.js";
|
|
3
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
import { Menu } from "@base-ui/react/menu";
|
|
5
|
+
// src/components/dropdown-menu/DropdownMenu.tsx
|
|
6
|
+
/** The root of a menu of actions that opens from a trigger. Compose it with DropdownMenuTrigger and DropdownMenuContent. */
|
|
7
|
+
function DropdownMenu(props) {
|
|
8
|
+
return /* @__PURE__ */ jsx(Menu.Root, { ...props });
|
|
9
|
+
}
|
|
10
|
+
/** The control that opens the menu. It is a button, and carries aria-expanded and aria-haspopup. */
|
|
11
|
+
function DropdownMenuTrigger(props) {
|
|
12
|
+
return /* @__PURE__ */ jsx(Menu.Trigger, { ...props });
|
|
13
|
+
}
|
|
14
|
+
const POPUP = "rt:z-50 rt:max-h-80 rt:min-w-40 rt:overflow-y-auto rt:rounded-lg rt:bg-popover rt:py-1.5 rt:text-popover-foreground rt:shadow-ring-strong rt:forced-outline rt:outline-none";
|
|
15
|
+
/** The menu panel: a white popup with a hairline ring, 8px corners and no shadow. It opens in a portal. */
|
|
16
|
+
function DropdownMenuContent({ side = "bottom", align = "start", sideOffset = 4, alignOffset = 0, ...props }) {
|
|
17
|
+
return /* @__PURE__ */ jsx(Menu.Portal, { children: /* @__PURE__ */ jsx(Menu.Positioner, {
|
|
18
|
+
className: "rt:isolate rt:z-50 rt:outline-none",
|
|
19
|
+
side,
|
|
20
|
+
align,
|
|
21
|
+
sideOffset,
|
|
22
|
+
alignOffset,
|
|
23
|
+
children: /* @__PURE__ */ jsx(Menu.Popup, {
|
|
24
|
+
className: POPUP,
|
|
25
|
+
...props
|
|
26
|
+
})
|
|
27
|
+
}) });
|
|
28
|
+
}
|
|
29
|
+
/** Groups items under one DropdownMenuLabel, so assistive technology announces the label with the group. */
|
|
30
|
+
function DropdownMenuGroup(props) {
|
|
31
|
+
return /* @__PURE__ */ jsx(Menu.Group, { ...props });
|
|
32
|
+
}
|
|
33
|
+
/** The caption of a group, in the design system's label style: 12px, uppercase, subdued. Place it inside DropdownMenuGroup. */
|
|
34
|
+
function DropdownMenuLabel(props) {
|
|
35
|
+
return /* @__PURE__ */ jsx(Menu.GroupLabel, {
|
|
36
|
+
className: "rt:px-3 rt:py-1 rt:text-label rt:uppercase rt:text-foreground-subdued",
|
|
37
|
+
...props
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
const ROW = "rt:relative rt:flex rt:h-7 rt:cursor-default rt:items-center rt:gap-2 rt:px-3 rt:text-b3 rt:text-foreground rt:outline-none rt:select-none rt:transition-colors rt:data-highlighted:bg-accent rt:data-highlighted:text-accent-foreground rt:data-disabled:pointer-events-none rt:data-disabled:opacity-50";
|
|
41
|
+
/** One action in the menu. It runs onClick and closes the menu; disabled is drawn at half opacity and cannot be chosen. */
|
|
42
|
+
function DropdownMenuItem({ variant = "default", ...props }) {
|
|
43
|
+
return /* @__PURE__ */ jsx(Menu.Item, {
|
|
44
|
+
"data-variant": variant,
|
|
45
|
+
className: cn(ROW, variant === "destructive" && "rt:text-destructive-foreground rt:data-highlighted:bg-destructive-hover rt:data-highlighted:text-destructive-foreground"),
|
|
46
|
+
...props
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
/** A key hint pushed to the end of an item. It is a hint only: the host binds the key. */
|
|
50
|
+
function DropdownMenuShortcut({ children }) {
|
|
51
|
+
return /* @__PURE__ */ jsx("span", {
|
|
52
|
+
className: "rt:ml-auto rt:text-c1 rt:text-foreground-subdued",
|
|
53
|
+
children
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
/** A hairline between groups of items. */
|
|
57
|
+
function DropdownMenuSeparator(props) {
|
|
58
|
+
return /* @__PURE__ */ jsx(Menu.Separator, {
|
|
59
|
+
className: "rt:my-1.5 rt:h-px rt:bg-divider",
|
|
60
|
+
...props
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
/** The root of a nested menu. Hold a DropdownMenuSubTrigger and a DropdownMenuSubContent. */
|
|
64
|
+
function DropdownMenuSub(props) {
|
|
65
|
+
return /* @__PURE__ */ jsx(Menu.SubmenuRoot, { ...props });
|
|
66
|
+
}
|
|
67
|
+
/** The item that opens a submenu, on hover, click or ArrowRight. A chevron at its end marks it. */
|
|
68
|
+
function DropdownMenuSubTrigger({ children, ...props }) {
|
|
69
|
+
return /* @__PURE__ */ jsxs(Menu.SubmenuTrigger, {
|
|
70
|
+
className: cn(ROW, "rt:data-popup-open:bg-accent"),
|
|
71
|
+
...props,
|
|
72
|
+
children: [children, /* @__PURE__ */ jsx("span", {
|
|
73
|
+
className: "rt:ml-auto rt:flex",
|
|
74
|
+
children: /* @__PURE__ */ jsx(Icon, {
|
|
75
|
+
name: "chevron-right",
|
|
76
|
+
size: 8
|
|
77
|
+
})
|
|
78
|
+
})]
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
/** The panel of a submenu. It opens to the side of its trigger. */
|
|
82
|
+
function DropdownMenuSubContent({ side = "right", alignOffset = -6, sideOffset = 0, ...props }) {
|
|
83
|
+
return /* @__PURE__ */ jsx(DropdownMenuContent, {
|
|
84
|
+
side,
|
|
85
|
+
alignOffset,
|
|
86
|
+
sideOffset,
|
|
87
|
+
...props
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
/** An item that toggles an option. A check shows at its start while it is on and keeps the menu open, so several options can be changed in one visit. */
|
|
91
|
+
function DropdownMenuCheckboxItem({ children, ...props }) {
|
|
92
|
+
return /* @__PURE__ */ jsxs(Menu.CheckboxItem, {
|
|
93
|
+
className: cn(ROW, "rt:pl-8"),
|
|
94
|
+
...props,
|
|
95
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
96
|
+
className: "rt:absolute rt:left-3 rt:flex",
|
|
97
|
+
children: /* @__PURE__ */ jsx(Menu.CheckboxItemIndicator, { children: /* @__PURE__ */ jsx(Icon, { name: "check" }) })
|
|
98
|
+
}), children]
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
/** Holds radio items and the one chosen value. */
|
|
102
|
+
function DropdownMenuRadioGroup(props) {
|
|
103
|
+
return /* @__PURE__ */ jsx(Menu.RadioGroup, { ...props });
|
|
104
|
+
}
|
|
105
|
+
/** One choice of a DropdownMenuRadioGroup. A dot shows at its start while it is the chosen value. */
|
|
106
|
+
function DropdownMenuRadioItem({ children, ...props }) {
|
|
107
|
+
return /* @__PURE__ */ jsxs(Menu.RadioItem, {
|
|
108
|
+
className: cn(ROW, "rt:pl-8"),
|
|
109
|
+
...props,
|
|
110
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
111
|
+
className: "rt:absolute rt:left-3 rt:flex",
|
|
112
|
+
children: /* @__PURE__ */ jsx(Menu.RadioItemIndicator, { children: /* @__PURE__ */ jsx("span", { className: "rt:block rt:size-1.5 rt:rounded-3xl rt:bg-current" }) })
|
|
113
|
+
}), children]
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
export { DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuCheckboxItemProps, DropdownMenuContent, DropdownMenuContentProps, DropdownMenuGroup, DropdownMenuGroupProps, DropdownMenuItem, DropdownMenuItemProps, DropdownMenuLabel, DropdownMenuLabelProps, DropdownMenuProps, DropdownMenuRadioGroup, DropdownMenuRadioGroupProps, DropdownMenuRadioItem, DropdownMenuRadioItemProps, DropdownMenuSeparator, DropdownMenuSeparatorProps, DropdownMenuShortcut, DropdownMenuShortcutProps, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubContentProps, DropdownMenuSubProps, DropdownMenuSubTrigger, DropdownMenuSubTriggerProps, DropdownMenuTrigger, DropdownMenuTriggerProps } from "./DropdownMenu.js";
|
|
2
|
+
export { DropdownMenu, DropdownMenuCheckboxItem, type DropdownMenuCheckboxItemProps, DropdownMenuContent, type DropdownMenuContentProps, DropdownMenuGroup, type DropdownMenuGroupProps, DropdownMenuItem, type DropdownMenuItemProps, DropdownMenuLabel, type DropdownMenuLabelProps, type DropdownMenuProps, DropdownMenuRadioGroup, type DropdownMenuRadioGroupProps, DropdownMenuRadioItem, type DropdownMenuRadioItemProps, DropdownMenuSeparator, type DropdownMenuSeparatorProps, DropdownMenuShortcut, type DropdownMenuShortcutProps, DropdownMenuSub, DropdownMenuSubContent, type DropdownMenuSubContentProps, type DropdownMenuSubProps, DropdownMenuSubTrigger, type DropdownMenuSubTriggerProps, DropdownMenuTrigger, type DropdownMenuTriggerProps };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger } from "./DropdownMenu.js";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { HTMLAttributes, JSX, ReactNode } from "react";
|
|
2
|
+
/** The props of EmptyState: the HTML attributes of its div, except className, style, children and title. */
|
|
3
|
+
export type EmptyStateProps = Omit<HTMLAttributes<HTMLDivElement>, 'className' | 'style' | 'children' | 'title'> & {
|
|
4
|
+
/** One clause that says why nothing is shown, in sentence case with no period. */
|
|
5
|
+
title: ReactNode;
|
|
6
|
+
/** An optional second clause that says what to do next. */
|
|
7
|
+
description?: ReactNode;
|
|
8
|
+
/** An optional action, usually one Button. */
|
|
9
|
+
action?: ReactNode;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* What a list, table or panel shows when it has nothing to show: one clause and an optional action, centred in a
|
|
13
|
+
* hairline container.
|
|
14
|
+
*/
|
|
15
|
+
export declare function EmptyState({ title, description, action, ...rest }: EmptyStateProps): JSX.Element;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Text } from "../text/Text.js";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
// src/components/empty-state/EmptyState.tsx
|
|
4
|
+
/**
|
|
5
|
+
* What a list, table or panel shows when it has nothing to show: one clause and an optional action, centred in a
|
|
6
|
+
* hairline container.
|
|
7
|
+
*/
|
|
8
|
+
function EmptyState({ title, description, action, ...rest }) {
|
|
9
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
10
|
+
"data-slot": "empty-state",
|
|
11
|
+
...rest,
|
|
12
|
+
className: "rt:flex rt:w-full rt:min-w-0 rt:flex-col rt:items-center rt:justify-center rt:gap-6 rt:rounded-lg rt:border rt:border-border rt:bg-background rt:p-6 rt:text-center",
|
|
13
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
14
|
+
className: "rt:flex rt:flex-col rt:items-center rt:gap-1",
|
|
15
|
+
children: [/* @__PURE__ */ jsx(Text, {
|
|
16
|
+
as: "p",
|
|
17
|
+
variant: "b4",
|
|
18
|
+
children: title
|
|
19
|
+
}), description ? /* @__PURE__ */ jsx(Text, {
|
|
20
|
+
as: "p",
|
|
21
|
+
tone: "subdued",
|
|
22
|
+
children: description
|
|
23
|
+
}) : null]
|
|
24
|
+
}), action ? /* @__PURE__ */ jsx("div", {
|
|
25
|
+
"data-slot": "empty-state-action",
|
|
26
|
+
children: action
|
|
27
|
+
}) : null]
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
export { EmptyState };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { EmptyState } from "./EmptyState.js";
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ComponentProps, JSX } from "react";
|
|
2
|
+
/** One choice of FilterTabs. */
|
|
3
|
+
export type FilterTabsItem = {
|
|
4
|
+
/** The value reported when the item is chosen. Unique in the list. */
|
|
5
|
+
value: string;
|
|
6
|
+
/** The text of the chip, one or two words in sentence case. */
|
|
7
|
+
label: string;
|
|
8
|
+
/** Stops the item being chosen and dims it to 50%. Defaults to false. */
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
};
|
|
11
|
+
/** The props of FilterTabs. */
|
|
12
|
+
export type FilterTabsProps = Omit<ComponentProps<'div'>, 'className' | 'style' | 'children' | 'defaultValue' | 'onChange'> & {
|
|
13
|
+
/** The choices, in order. */
|
|
14
|
+
items: FilterTabsItem[];
|
|
15
|
+
/** The chosen value when controlled. */
|
|
16
|
+
value?: string;
|
|
17
|
+
/** The chosen value at the start when uncontrolled. Defaults to the first item. */
|
|
18
|
+
defaultValue?: string;
|
|
19
|
+
/** Called with the new value when another item is chosen. Choosing the chosen item again does nothing. */
|
|
20
|
+
onValueChange?: (value: string) => void;
|
|
21
|
+
/** Disables every item. Defaults to false. */
|
|
22
|
+
disabled?: boolean;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* A single choice that filters a list, such as All, Active and Inactive above a table: the design system's Tab chips in a
|
|
26
|
+
* row with an 8px gap. One item is always chosen. For sections of a page use Tabs instead.
|
|
27
|
+
*/
|
|
28
|
+
export declare function FilterTabs({ items, value, defaultValue, onValueChange, disabled, ...rest }: FilterTabsProps): JSX.Element;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { cn } from "../../lib/cn.js";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
import { Toggle } from "@base-ui/react/toggle";
|
|
5
|
+
import { ToggleGroup } from "@base-ui/react/toggle-group";
|
|
6
|
+
// src/components/filter-tabs/FilterTabs.tsx
|
|
7
|
+
/**
|
|
8
|
+
* A single choice that filters a list, such as All, Active and Inactive above a table: the design system's Tab chips in a
|
|
9
|
+
* row with an 8px gap. One item is always chosen. For sections of a page use Tabs instead.
|
|
10
|
+
*/
|
|
11
|
+
function FilterTabs({ items, value, defaultValue, onValueChange, disabled, ...rest }) {
|
|
12
|
+
const [inner, setInner] = useState(defaultValue ?? items[0]?.value);
|
|
13
|
+
const wanted = value ?? inner;
|
|
14
|
+
const chosen = items.some((item) => item.value === wanted) ? wanted : items[0]?.value;
|
|
15
|
+
const handle = (next) => {
|
|
16
|
+
const picked = next[0];
|
|
17
|
+
if (picked === void 0) return;
|
|
18
|
+
setInner(picked);
|
|
19
|
+
onValueChange?.(picked);
|
|
20
|
+
};
|
|
21
|
+
return /* @__PURE__ */ jsx(ToggleGroup, {
|
|
22
|
+
"data-slot": "filter-tabs",
|
|
23
|
+
className: cn("rt:flex rt:flex-wrap rt:items-center rt:gap-2"),
|
|
24
|
+
disabled,
|
|
25
|
+
value: chosen === void 0 ? [] : [chosen],
|
|
26
|
+
onValueChange: handle,
|
|
27
|
+
...rest,
|
|
28
|
+
children: items.map((item) => /* @__PURE__ */ jsx(Toggle, {
|
|
29
|
+
value: item.value,
|
|
30
|
+
disabled: item.disabled,
|
|
31
|
+
"data-slot": "filter-tabs-item",
|
|
32
|
+
className: cn("rt:inline-flex rt:h-9 rt:cursor-pointer rt:items-center rt:justify-center rt:rounded-lg rt:whitespace-nowrap", "rt:bg-background rt:text-b3 rt:transition-colors rt:forced-outline", "rt:border rt:border-border rt:px-3 rt:text-tab-inactive rt:hover:bg-primary-tint", "rt:data-pressed:border-0 rt:data-pressed:px-2.75 rt:data-pressed:font-semibold rt:data-pressed:text-primary", "rt:data-pressed:shadow-ring-accent-hairline", "rt:focus-visible:focus-ring rt:data-disabled:cursor-default rt:data-disabled:opacity-50"),
|
|
33
|
+
children: item.label
|
|
34
|
+
}, item.value))
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
export { FilterTabs };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { FilterTabs } from "./FilterTabs.js";
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { IconName } from "../icon/registry.js";
|
|
2
|
+
import "../icon/index.js";
|
|
3
|
+
import { JSX } from "react";
|
|
4
|
+
/** One result row: what it is called, a line of detail and an optional icon. */
|
|
5
|
+
export interface GlobalSearchResult {
|
|
6
|
+
/** A stable id, unique across all groups. */
|
|
7
|
+
id: string;
|
|
8
|
+
/** The name shown on the row. */
|
|
9
|
+
label: string;
|
|
10
|
+
/** A second line of detail, such as a SKU or an order status. */
|
|
11
|
+
description?: string;
|
|
12
|
+
/** An icon drawn before the label. */
|
|
13
|
+
icon?: IconName;
|
|
14
|
+
}
|
|
15
|
+
/** A group of results, such as Products or Orders. The app fills it. */
|
|
16
|
+
export interface GlobalSearchGroup {
|
|
17
|
+
/** A stable id for the group. */
|
|
18
|
+
id: string;
|
|
19
|
+
/** The heading of the group. */
|
|
20
|
+
label: string;
|
|
21
|
+
/** The results to show, already limited by the app. */
|
|
22
|
+
items: GlobalSearchResult[];
|
|
23
|
+
/** How many results exist in all. When it is above items.length, a "+N more" row follows the items. */
|
|
24
|
+
total?: number;
|
|
25
|
+
}
|
|
26
|
+
/** The props of GlobalSearch. */
|
|
27
|
+
export interface GlobalSearchProps {
|
|
28
|
+
/** The accessible name of the field, such as "Search the dashboard". */
|
|
29
|
+
label: string;
|
|
30
|
+
/** The text typed in the field. */
|
|
31
|
+
value: string;
|
|
32
|
+
/** Called on every change of the text. Debounce and fetch in the app. */
|
|
33
|
+
onValueChange: (value: string) => void;
|
|
34
|
+
/** The results for the current text, grouped. The app supplies them; nothing is filtered here. */
|
|
35
|
+
groups: GlobalSearchGroup[];
|
|
36
|
+
/** Recent items, shown under "Recent" while the field is empty. */
|
|
37
|
+
recent?: GlobalSearchResult[];
|
|
38
|
+
/** Called when a result is chosen by click or Enter. */
|
|
39
|
+
onSelect?: (result: GlobalSearchResult) => void;
|
|
40
|
+
/** Called when a "+N more" row is chosen, with its group. */
|
|
41
|
+
onShowMore?: (group: GlobalSearchGroup) => void;
|
|
42
|
+
/** The placeholder of the field. Defaults to "Search". */
|
|
43
|
+
placeholder?: string;
|
|
44
|
+
/** The copy when the text matches nothing. Defaults to "No results". */
|
|
45
|
+
emptyText?: string;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* The search in the top bar. Typing opens a panel of grouped results that the app supplies, an empty field shows recent
|
|
49
|
+
* items, and the arrow keys, Enter and Escape work the list. Cmd+K or Ctrl+K focuses the field from anywhere.
|
|
50
|
+
*/
|
|
51
|
+
export declare function GlobalSearch({ label, value, onValueChange, groups, recent, onSelect, onShowMore, placeholder, emptyText }: GlobalSearchProps): JSX.Element;
|