panelui-web 0.4.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/avatar/index.d.ts +66 -0
- package/dist/components/avatar/index.js +251 -0
- package/dist/components/button/index.d.ts +111 -0
- package/dist/components/button/index.js +45 -0
- package/dist/components/flow/index.d.ts +26 -4
- package/dist/components/flow/index.js +81 -20
- package/dist/components/input/index.d.ts +55 -0
- package/dist/components/input/index.js +89 -0
- package/dist/components/label/index.d.ts +89 -0
- package/dist/components/label/index.js +64 -0
- package/dist/components/menu/index.d.ts +202 -0
- package/dist/components/menu/index.js +188 -0
- package/dist/components/message/index.d.ts +161 -0
- package/dist/components/message/index.js +295 -0
- package/dist/components/planet/index.js +4 -1
- package/dist/components/prompt/index.d.ts +414 -0
- package/dist/components/prompt/index.js +779 -0
- package/dist/components/select/index.d.ts +134 -0
- package/dist/components/select/index.js +164 -0
- package/dist/components/sheet/index.d.ts +43 -4
- package/dist/components/sheet/index.js +121 -12
- package/dist/components/switch/index.d.ts +51 -0
- package/dist/components/switch/index.js +88 -0
- package/dist/components/tabs/index.d.ts +94 -0
- package/dist/components/tabs/index.js +196 -0
- package/dist/components/textarea/index.d.ts +43 -0
- package/dist/components/textarea/index.js +101 -0
- package/dist/index.d.ts +12 -1
- package/dist/index.js +12 -1
- package/package.json +1 -1
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Menu — a list of actions that opens from a button.
|
|
3
|
+
*
|
|
4
|
+
* ```tsx
|
|
5
|
+
* <Menu>
|
|
6
|
+
* <Menu.Trigger render={<Button variant="outline" />}>Options</Menu.Trigger>
|
|
7
|
+
* <Menu.Content>
|
|
8
|
+
* <Menu.Item onClick={rename}>
|
|
9
|
+
* <PencilIcon /> Rename <Menu.Shortcut>⌘R</Menu.Shortcut>
|
|
10
|
+
* </Menu.Item>
|
|
11
|
+
* <Menu.Sub>
|
|
12
|
+
* <Menu.SubTrigger><ShareIcon /> Share</Menu.SubTrigger>
|
|
13
|
+
* <Menu.SubContent>
|
|
14
|
+
* <Menu.Item>Copy link</Menu.Item>
|
|
15
|
+
* </Menu.SubContent>
|
|
16
|
+
* </Menu.Sub>
|
|
17
|
+
* <Menu.Separator />
|
|
18
|
+
* <Menu.CheckboxItem checked={pinned} onCheckedChange={setPinned}>Pinned</Menu.CheckboxItem>
|
|
19
|
+
* <Menu.Item variant="destructive">Delete</Menu.Item>
|
|
20
|
+
* </Menu.Content>
|
|
21
|
+
* </Menu>
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* ## One row shape
|
|
25
|
+
*
|
|
26
|
+
* Every row is the same: an icon, the label, and whatever belongs at the end
|
|
27
|
+
* of it, a shortcut, a badge, a check or the chevron of a submenu. Icons are
|
|
28
|
+
* written as the row's first child and sized by the row, so rows with and
|
|
29
|
+
* without them still line up when every row in a group has one.
|
|
30
|
+
*
|
|
31
|
+
* ## Submenus
|
|
32
|
+
*
|
|
33
|
+
* A submenu opens to the side when its row is hovered or pressed, or with
|
|
34
|
+
* the right arrow key, and closes with the left one. The pointer can cross
|
|
35
|
+
* diagonally to it without closing it on the way.
|
|
36
|
+
*
|
|
37
|
+
* ## Items that stay open
|
|
38
|
+
*
|
|
39
|
+
* Pressing an item closes the menu. A check item or a radio item keeps it
|
|
40
|
+
* open, so several can be switched in a row; pass `closeOnClick` to change
|
|
41
|
+
* either.
|
|
42
|
+
*/
|
|
43
|
+
import { Menu as BaseMenu } from '@base-ui/react/menu';
|
|
44
|
+
import type { ComponentProps, ReactNode } from 'react';
|
|
45
|
+
export interface MenuProps extends BaseMenu.Root.Props {
|
|
46
|
+
}
|
|
47
|
+
/** Holds whether the menu is open. Takes `open`/`onOpenChange`, `defaultOpen` and `modal`. */
|
|
48
|
+
declare function MenuRoot(props: MenuProps): import("react").JSX.Element;
|
|
49
|
+
declare namespace MenuRoot {
|
|
50
|
+
var displayName: string;
|
|
51
|
+
}
|
|
52
|
+
export interface MenuTriggerProps extends BaseMenu.Trigger.Props {
|
|
53
|
+
}
|
|
54
|
+
/** The button that opens the menu. `render` draws it as another element, such as a `Button`. */
|
|
55
|
+
declare function MenuTrigger(props: MenuTriggerProps): import("react").JSX.Element;
|
|
56
|
+
declare namespace MenuTrigger {
|
|
57
|
+
var displayName: string;
|
|
58
|
+
}
|
|
59
|
+
interface PlacementProps {
|
|
60
|
+
/** Which side of the trigger it opens on. Default `bottom`; a submenu opens to the side. */
|
|
61
|
+
side?: BaseMenu.Positioner.Props['side'];
|
|
62
|
+
/** How it lines up with the trigger along that side. Default `start`. */
|
|
63
|
+
align?: BaseMenu.Positioner.Props['align'];
|
|
64
|
+
/** The gap between the trigger and the menu, in pixels. Default `6`. */
|
|
65
|
+
sideOffset?: number;
|
|
66
|
+
/** Moves it along the side, in pixels. */
|
|
67
|
+
alignOffset?: number;
|
|
68
|
+
}
|
|
69
|
+
export interface MenuContentProps extends BaseMenu.Popup.Props, PlacementProps {
|
|
70
|
+
/** Where in the document the menu is put. Default `document.body`. */
|
|
71
|
+
container?: BaseMenu.Portal.Props['container'];
|
|
72
|
+
/** What it is placed against instead of the trigger: an element or a ref to one. */
|
|
73
|
+
anchor?: BaseMenu.Positioner.Props['anchor'];
|
|
74
|
+
className?: string;
|
|
75
|
+
}
|
|
76
|
+
/** The list, opened in a layer over the page. It moves to the other side when there is no room. */
|
|
77
|
+
declare function MenuContent({ side, align, sideOffset, alignOffset, container, anchor, className, ...props }: MenuContentProps): import("react").JSX.Element;
|
|
78
|
+
declare namespace MenuContent {
|
|
79
|
+
var displayName: string;
|
|
80
|
+
}
|
|
81
|
+
export interface MenuItemProps extends BaseMenu.Item.Props {
|
|
82
|
+
/** `destructive` draws it in the destructive colour, for an action that cannot be undone. Default `default`. */
|
|
83
|
+
variant?: 'default' | 'destructive';
|
|
84
|
+
className?: string;
|
|
85
|
+
}
|
|
86
|
+
/** One action. Put an icon first, then the label, then a `Menu.Shortcut` or `Menu.Badge` if it has one. */
|
|
87
|
+
declare function MenuItem({ variant, className, ...props }: MenuItemProps): import("react").JSX.Element;
|
|
88
|
+
declare namespace MenuItem {
|
|
89
|
+
var displayName: string;
|
|
90
|
+
}
|
|
91
|
+
export interface MenuCheckboxItemProps extends BaseMenu.CheckboxItem.Props {
|
|
92
|
+
className?: string;
|
|
93
|
+
}
|
|
94
|
+
/** An item that is switched on and off, with a check at its end while on. The menu stays open. */
|
|
95
|
+
declare function MenuCheckboxItem({ className, children, ...props }: MenuCheckboxItemProps): import("react").JSX.Element;
|
|
96
|
+
declare namespace MenuCheckboxItem {
|
|
97
|
+
var displayName: string;
|
|
98
|
+
}
|
|
99
|
+
export interface MenuRadioGroupProps extends BaseMenu.RadioGroup.Props {
|
|
100
|
+
className?: string;
|
|
101
|
+
}
|
|
102
|
+
/** Radio items of which one is chosen. Takes `value` and `onValueChange`. */
|
|
103
|
+
declare function MenuRadioGroup({ className, ...props }: MenuRadioGroupProps): import("react").JSX.Element;
|
|
104
|
+
declare namespace MenuRadioGroup {
|
|
105
|
+
var displayName: string;
|
|
106
|
+
}
|
|
107
|
+
export interface MenuRadioItemProps extends BaseMenu.RadioItem.Props {
|
|
108
|
+
className?: string;
|
|
109
|
+
}
|
|
110
|
+
/** One choice in a radio group, with a check at its end while chosen. */
|
|
111
|
+
declare function MenuRadioItem({ className, children, ...props }: MenuRadioItemProps): import("react").JSX.Element;
|
|
112
|
+
declare namespace MenuRadioItem {
|
|
113
|
+
var displayName: string;
|
|
114
|
+
}
|
|
115
|
+
export interface MenuSubProps extends BaseMenu.SubmenuRoot.Props {
|
|
116
|
+
}
|
|
117
|
+
/** A submenu: a `Menu.SubTrigger` row and the `Menu.SubContent` it opens. */
|
|
118
|
+
declare function MenuSub(props: MenuSubProps): import("react").JSX.Element;
|
|
119
|
+
declare namespace MenuSub {
|
|
120
|
+
var displayName: string;
|
|
121
|
+
}
|
|
122
|
+
export interface MenuSubTriggerProps extends BaseMenu.SubmenuTrigger.Props {
|
|
123
|
+
className?: string;
|
|
124
|
+
/** Something before the chevron, such as a `Menu.Badge`. */
|
|
125
|
+
end?: ReactNode;
|
|
126
|
+
}
|
|
127
|
+
/** The row that opens a submenu, with a chevron at its end. It opens on hover as well as on press. */
|
|
128
|
+
declare function MenuSubTrigger({ className, children, end, openOnHover, delay, ...props }: MenuSubTriggerProps): import("react").JSX.Element;
|
|
129
|
+
declare namespace MenuSubTrigger {
|
|
130
|
+
var displayName: string;
|
|
131
|
+
}
|
|
132
|
+
export interface MenuSubContentProps extends Omit<MenuContentProps, 'side'> {
|
|
133
|
+
/** Default `inline-end`: to the right in a left-to-right page. */
|
|
134
|
+
side?: BaseMenu.Positioner.Props['side'];
|
|
135
|
+
}
|
|
136
|
+
/** The submenu's list, opened beside its row with the first item level with it. */
|
|
137
|
+
declare function MenuSubContent({ side, align, sideOffset, alignOffset, ...props }: MenuSubContentProps): import("react").JSX.Element;
|
|
138
|
+
declare namespace MenuSubContent {
|
|
139
|
+
var displayName: string;
|
|
140
|
+
}
|
|
141
|
+
export interface MenuGroupProps extends BaseMenu.Group.Props {
|
|
142
|
+
className?: string;
|
|
143
|
+
}
|
|
144
|
+
/** Items that belong together, under a `Menu.GroupLabel`. */
|
|
145
|
+
declare function MenuGroup({ className, ...props }: MenuGroupProps): import("react").JSX.Element;
|
|
146
|
+
declare namespace MenuGroup {
|
|
147
|
+
var displayName: string;
|
|
148
|
+
}
|
|
149
|
+
export interface MenuGroupLabelProps extends BaseMenu.GroupLabel.Props {
|
|
150
|
+
className?: string;
|
|
151
|
+
}
|
|
152
|
+
/** The heading of a group. Screen readers announce the group by it. */
|
|
153
|
+
declare function MenuGroupLabel({ className, ...props }: MenuGroupLabelProps): import("react").JSX.Element;
|
|
154
|
+
declare namespace MenuGroupLabel {
|
|
155
|
+
var displayName: string;
|
|
156
|
+
}
|
|
157
|
+
export interface MenuSeparatorProps extends ComponentProps<'div'> {
|
|
158
|
+
}
|
|
159
|
+
/** A rule between groups of items. */
|
|
160
|
+
declare function MenuSeparator({ className, ...props }: MenuSeparatorProps): import("react").JSX.Element;
|
|
161
|
+
declare namespace MenuSeparator {
|
|
162
|
+
var displayName: string;
|
|
163
|
+
}
|
|
164
|
+
export interface MenuDescriptionProps extends ComponentProps<'span'> {
|
|
165
|
+
}
|
|
166
|
+
/** What an item does, in quieter words after its label. */
|
|
167
|
+
declare function MenuDescription({ className, ...props }: MenuDescriptionProps): import("react").JSX.Element;
|
|
168
|
+
declare namespace MenuDescription {
|
|
169
|
+
var displayName: string;
|
|
170
|
+
}
|
|
171
|
+
export interface MenuShortcutProps extends ComponentProps<'kbd'> {
|
|
172
|
+
}
|
|
173
|
+
/** The keys for an item, at its end. It only shows them: wire the keys up where the action lives. */
|
|
174
|
+
declare function MenuShortcut({ className, ...props }: MenuShortcutProps): import("react").JSX.Element;
|
|
175
|
+
declare namespace MenuShortcut {
|
|
176
|
+
var displayName: string;
|
|
177
|
+
}
|
|
178
|
+
export interface MenuBadgeProps extends ComponentProps<'span'> {
|
|
179
|
+
}
|
|
180
|
+
/** A small count or flag at an item's end: how many need attention, or that something is new. */
|
|
181
|
+
declare function MenuBadge({ className, ...props }: MenuBadgeProps): import("react").JSX.Element;
|
|
182
|
+
declare namespace MenuBadge {
|
|
183
|
+
var displayName: string;
|
|
184
|
+
}
|
|
185
|
+
export declare const Menu: typeof MenuRoot & {
|
|
186
|
+
Trigger: typeof MenuTrigger;
|
|
187
|
+
Content: typeof MenuContent;
|
|
188
|
+
Item: typeof MenuItem;
|
|
189
|
+
CheckboxItem: typeof MenuCheckboxItem;
|
|
190
|
+
RadioGroup: typeof MenuRadioGroup;
|
|
191
|
+
RadioItem: typeof MenuRadioItem;
|
|
192
|
+
Sub: typeof MenuSub;
|
|
193
|
+
SubTrigger: typeof MenuSubTrigger;
|
|
194
|
+
SubContent: typeof MenuSubContent;
|
|
195
|
+
Group: typeof MenuGroup;
|
|
196
|
+
GroupLabel: typeof MenuGroupLabel;
|
|
197
|
+
Separator: typeof MenuSeparator;
|
|
198
|
+
Description: typeof MenuDescription;
|
|
199
|
+
Shortcut: typeof MenuShortcut;
|
|
200
|
+
Badge: typeof MenuBadge;
|
|
201
|
+
};
|
|
202
|
+
export { MenuTrigger, MenuContent, MenuItem, MenuCheckboxItem, MenuRadioGroup, MenuRadioItem, MenuSub, MenuSubTrigger, MenuSubContent, MenuGroup, MenuGroupLabel, MenuSeparator, MenuDescription, MenuShortcut, MenuBadge, };
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
/**
|
|
4
|
+
* Menu — a list of actions that opens from a button.
|
|
5
|
+
*
|
|
6
|
+
* ```tsx
|
|
7
|
+
* <Menu>
|
|
8
|
+
* <Menu.Trigger render={<Button variant="outline" />}>Options</Menu.Trigger>
|
|
9
|
+
* <Menu.Content>
|
|
10
|
+
* <Menu.Item onClick={rename}>
|
|
11
|
+
* <PencilIcon /> Rename <Menu.Shortcut>⌘R</Menu.Shortcut>
|
|
12
|
+
* </Menu.Item>
|
|
13
|
+
* <Menu.Sub>
|
|
14
|
+
* <Menu.SubTrigger><ShareIcon /> Share</Menu.SubTrigger>
|
|
15
|
+
* <Menu.SubContent>
|
|
16
|
+
* <Menu.Item>Copy link</Menu.Item>
|
|
17
|
+
* </Menu.SubContent>
|
|
18
|
+
* </Menu.Sub>
|
|
19
|
+
* <Menu.Separator />
|
|
20
|
+
* <Menu.CheckboxItem checked={pinned} onCheckedChange={setPinned}>Pinned</Menu.CheckboxItem>
|
|
21
|
+
* <Menu.Item variant="destructive">Delete</Menu.Item>
|
|
22
|
+
* </Menu.Content>
|
|
23
|
+
* </Menu>
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* ## One row shape
|
|
27
|
+
*
|
|
28
|
+
* Every row is the same: an icon, the label, and whatever belongs at the end
|
|
29
|
+
* of it, a shortcut, a badge, a check or the chevron of a submenu. Icons are
|
|
30
|
+
* written as the row's first child and sized by the row, so rows with and
|
|
31
|
+
* without them still line up when every row in a group has one.
|
|
32
|
+
*
|
|
33
|
+
* ## Submenus
|
|
34
|
+
*
|
|
35
|
+
* A submenu opens to the side when its row is hovered or pressed, or with
|
|
36
|
+
* the right arrow key, and closes with the left one. The pointer can cross
|
|
37
|
+
* diagonally to it without closing it on the way.
|
|
38
|
+
*
|
|
39
|
+
* ## Items that stay open
|
|
40
|
+
*
|
|
41
|
+
* Pressing an item closes the menu. A check item or a radio item keeps it
|
|
42
|
+
* open, so several can be switched in a row; pass `closeOnClick` to change
|
|
43
|
+
* either.
|
|
44
|
+
*/
|
|
45
|
+
import { Menu as BaseMenu } from '@base-ui/react/menu';
|
|
46
|
+
import { tv } from 'tailwind-variants';
|
|
47
|
+
const menuVariants = tv({
|
|
48
|
+
slots: {
|
|
49
|
+
positioner: 'z-50 outline-none',
|
|
50
|
+
popup: [
|
|
51
|
+
'min-w-48 origin-(--transform-origin) rounded-xl border bg-popover p-1 text-popover-foreground shadow-lg outline-none',
|
|
52
|
+
'max-h-(--available-height) overflow-y-auto [scrollbar-color:var(--border)_transparent] [scrollbar-width:thin]',
|
|
53
|
+
'transition-[opacity,scale] duration-150 ease-out',
|
|
54
|
+
'data-starting-style:scale-95 data-starting-style:opacity-0 data-ending-style:scale-95 data-ending-style:opacity-0',
|
|
55
|
+
'motion-reduce:transition-none',
|
|
56
|
+
],
|
|
57
|
+
item: [
|
|
58
|
+
// The label never wraps; a description beside it is cut short instead.
|
|
59
|
+
'flex min-h-8 cursor-default items-center gap-2.5 whitespace-nowrap rounded-lg px-2 py-1.5 text-sm outline-none select-none',
|
|
60
|
+
'data-highlighted:bg-accent data-highlighted:text-accent-foreground',
|
|
61
|
+
'data-disabled:pointer-events-none data-disabled:opacity-50',
|
|
62
|
+
// A submenu's row stays lit while its submenu is open, so it is clear what it belongs to.
|
|
63
|
+
'data-popup-open:bg-accent',
|
|
64
|
+
'[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*=size-])]:size-4',
|
|
65
|
+
'[&>svg:first-child]:text-muted-foreground data-highlighted:[&>svg:first-child]:text-current',
|
|
66
|
+
],
|
|
67
|
+
end: 'ms-auto flex items-center ps-3',
|
|
68
|
+
check: 'ms-auto flex size-4 items-center justify-center ps-0 text-foreground',
|
|
69
|
+
description: 'min-w-0 truncate text-muted-foreground',
|
|
70
|
+
shortcut: 'ms-auto ps-3 text-xs tracking-wide text-muted-foreground',
|
|
71
|
+
badge: 'ms-auto inline-flex h-5 items-center gap-1 rounded-md bg-muted px-1.5 text-xs font-medium tabular-nums text-muted-foreground [&_svg:not([class*=size-])]:size-3',
|
|
72
|
+
chevron: 'ms-auto text-muted-foreground',
|
|
73
|
+
group: 'flex flex-col',
|
|
74
|
+
groupLabel: 'px-2 pb-1 pt-2 text-xs font-medium text-muted-foreground',
|
|
75
|
+
separator: 'mx-2 my-1 h-px bg-border',
|
|
76
|
+
},
|
|
77
|
+
variants: {
|
|
78
|
+
variant: {
|
|
79
|
+
default: {},
|
|
80
|
+
destructive: {
|
|
81
|
+
item: 'text-destructive data-highlighted:bg-destructive/10 data-highlighted:text-destructive [&>svg:first-child]:text-destructive',
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
/** Holds whether the menu is open. Takes `open`/`onOpenChange`, `defaultOpen` and `modal`. */
|
|
87
|
+
function MenuRoot(props) {
|
|
88
|
+
return _jsx(BaseMenu.Root, { ...props });
|
|
89
|
+
}
|
|
90
|
+
MenuRoot.displayName = 'Menu';
|
|
91
|
+
/** The button that opens the menu. `render` draws it as another element, such as a `Button`. */
|
|
92
|
+
function MenuTrigger(props) {
|
|
93
|
+
return _jsx(BaseMenu.Trigger, { "data-slot": "menu-trigger", ...props });
|
|
94
|
+
}
|
|
95
|
+
MenuTrigger.displayName = 'Menu.Trigger';
|
|
96
|
+
/** The list, opened in a layer over the page. It moves to the other side when there is no room. */
|
|
97
|
+
function MenuContent({ side = 'bottom', align = 'start', sideOffset = 6, alignOffset, container, anchor, className, ...props }) {
|
|
98
|
+
const slots = menuVariants();
|
|
99
|
+
return (_jsx(BaseMenu.Portal, { container: container, children: _jsx(BaseMenu.Positioner, { side: side, align: align, sideOffset: sideOffset, alignOffset: alignOffset, anchor: anchor, className: slots.positioner(), children: _jsx(BaseMenu.Popup, { "data-slot": "menu-content", className: slots.popup({ className }), ...props }) }) }));
|
|
100
|
+
}
|
|
101
|
+
MenuContent.displayName = 'Menu.Content';
|
|
102
|
+
/** One action. Put an icon first, then the label, then a `Menu.Shortcut` or `Menu.Badge` if it has one. */
|
|
103
|
+
function MenuItem({ variant, className, ...props }) {
|
|
104
|
+
return _jsx(BaseMenu.Item, { "data-slot": "menu-item", className: menuVariants({ variant }).item({ className }), ...props });
|
|
105
|
+
}
|
|
106
|
+
MenuItem.displayName = 'Menu.Item';
|
|
107
|
+
const Check = () => (_jsx("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.25", strokeLinecap: "round", strokeLinejoin: "round", children: _jsx("path", { d: "M20 6 9 17l-5-5" }) }));
|
|
108
|
+
/** An item that is switched on and off, with a check at its end while on. The menu stays open. */
|
|
109
|
+
function MenuCheckboxItem({ className, children, ...props }) {
|
|
110
|
+
const slots = menuVariants();
|
|
111
|
+
return (_jsxs(BaseMenu.CheckboxItem, { "data-slot": "menu-checkbox-item", className: slots.item({ className }), ...props, children: [children, _jsx("span", { className: slots.check(), children: _jsx(BaseMenu.CheckboxItemIndicator, { className: "flex", children: _jsx(Check, {}) }) })] }));
|
|
112
|
+
}
|
|
113
|
+
MenuCheckboxItem.displayName = 'Menu.CheckboxItem';
|
|
114
|
+
/** Radio items of which one is chosen. Takes `value` and `onValueChange`. */
|
|
115
|
+
function MenuRadioGroup({ className, ...props }) {
|
|
116
|
+
return _jsx(BaseMenu.RadioGroup, { "data-slot": "menu-radio-group", className: menuVariants().group({ className }), ...props });
|
|
117
|
+
}
|
|
118
|
+
MenuRadioGroup.displayName = 'Menu.RadioGroup';
|
|
119
|
+
/** One choice in a radio group, with a check at its end while chosen. */
|
|
120
|
+
function MenuRadioItem({ className, children, ...props }) {
|
|
121
|
+
const slots = menuVariants();
|
|
122
|
+
return (_jsxs(BaseMenu.RadioItem, { "data-slot": "menu-radio-item", className: slots.item({ className }), ...props, children: [children, _jsx("span", { className: slots.check(), children: _jsx(BaseMenu.RadioItemIndicator, { className: "flex", children: _jsx(Check, {}) }) })] }));
|
|
123
|
+
}
|
|
124
|
+
MenuRadioItem.displayName = 'Menu.RadioItem';
|
|
125
|
+
/** A submenu: a `Menu.SubTrigger` row and the `Menu.SubContent` it opens. */
|
|
126
|
+
function MenuSub(props) {
|
|
127
|
+
return _jsx(BaseMenu.SubmenuRoot, { ...props });
|
|
128
|
+
}
|
|
129
|
+
MenuSub.displayName = 'Menu.Sub';
|
|
130
|
+
/** The row that opens a submenu, with a chevron at its end. It opens on hover as well as on press. */
|
|
131
|
+
function MenuSubTrigger({ className, children, end, openOnHover = true, delay = 80, ...props }) {
|
|
132
|
+
const slots = menuVariants();
|
|
133
|
+
return (_jsxs(BaseMenu.SubmenuTrigger, { "data-slot": "menu-sub-trigger", openOnHover: openOnHover, delay: delay, className: slots.item({ className }), ...props, children: [children, _jsxs("span", { className: slots.end(), children: [end, _jsx("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", className: slots.chevron({ className: end ? 'ms-2' : undefined }), children: _jsx("path", { d: "m9 18 6-6-6-6" }) })] })] }));
|
|
134
|
+
}
|
|
135
|
+
MenuSubTrigger.displayName = 'Menu.SubTrigger';
|
|
136
|
+
/** The submenu's list, opened beside its row with the first item level with it. */
|
|
137
|
+
function MenuSubContent({ side = 'inline-end', align = 'start', sideOffset = 6, alignOffset = -5, ...props }) {
|
|
138
|
+
return _jsx(MenuContent, { side: side, align: align, sideOffset: sideOffset, alignOffset: alignOffset, ...props });
|
|
139
|
+
}
|
|
140
|
+
MenuSubContent.displayName = 'Menu.SubContent';
|
|
141
|
+
/** Items that belong together, under a `Menu.GroupLabel`. */
|
|
142
|
+
function MenuGroup({ className, ...props }) {
|
|
143
|
+
return _jsx(BaseMenu.Group, { "data-slot": "menu-group", className: menuVariants().group({ className }), ...props });
|
|
144
|
+
}
|
|
145
|
+
MenuGroup.displayName = 'Menu.Group';
|
|
146
|
+
/** The heading of a group. Screen readers announce the group by it. */
|
|
147
|
+
function MenuGroupLabel({ className, ...props }) {
|
|
148
|
+
return _jsx(BaseMenu.GroupLabel, { "data-slot": "menu-group-label", className: menuVariants().groupLabel({ className }), ...props });
|
|
149
|
+
}
|
|
150
|
+
MenuGroupLabel.displayName = 'Menu.GroupLabel';
|
|
151
|
+
/** A rule between groups of items. */
|
|
152
|
+
function MenuSeparator({ className, ...props }) {
|
|
153
|
+
return _jsx("div", { role: "separator", "data-slot": "menu-separator", className: menuVariants().separator({ className }), ...props });
|
|
154
|
+
}
|
|
155
|
+
MenuSeparator.displayName = 'Menu.Separator';
|
|
156
|
+
/** What an item does, in quieter words after its label. */
|
|
157
|
+
function MenuDescription({ className, ...props }) {
|
|
158
|
+
return _jsx("span", { "data-slot": "menu-description", className: menuVariants().description({ className }), ...props });
|
|
159
|
+
}
|
|
160
|
+
MenuDescription.displayName = 'Menu.Description';
|
|
161
|
+
/** The keys for an item, at its end. It only shows them: wire the keys up where the action lives. */
|
|
162
|
+
function MenuShortcut({ className, ...props }) {
|
|
163
|
+
return _jsx("kbd", { "data-slot": "menu-shortcut", className: menuVariants().shortcut({ className }), ...props });
|
|
164
|
+
}
|
|
165
|
+
MenuShortcut.displayName = 'Menu.Shortcut';
|
|
166
|
+
/** A small count or flag at an item's end: how many need attention, or that something is new. */
|
|
167
|
+
function MenuBadge({ className, ...props }) {
|
|
168
|
+
return _jsx("span", { "data-slot": "menu-badge", className: menuVariants().badge({ className }), ...props });
|
|
169
|
+
}
|
|
170
|
+
MenuBadge.displayName = 'Menu.Badge';
|
|
171
|
+
export const Menu = Object.assign(MenuRoot, {
|
|
172
|
+
Trigger: MenuTrigger,
|
|
173
|
+
Content: MenuContent,
|
|
174
|
+
Item: MenuItem,
|
|
175
|
+
CheckboxItem: MenuCheckboxItem,
|
|
176
|
+
RadioGroup: MenuRadioGroup,
|
|
177
|
+
RadioItem: MenuRadioItem,
|
|
178
|
+
Sub: MenuSub,
|
|
179
|
+
SubTrigger: MenuSubTrigger,
|
|
180
|
+
SubContent: MenuSubContent,
|
|
181
|
+
Group: MenuGroup,
|
|
182
|
+
GroupLabel: MenuGroupLabel,
|
|
183
|
+
Separator: MenuSeparator,
|
|
184
|
+
Description: MenuDescription,
|
|
185
|
+
Shortcut: MenuShortcut,
|
|
186
|
+
Badge: MenuBadge,
|
|
187
|
+
});
|
|
188
|
+
export { MenuTrigger, MenuContent, MenuItem, MenuCheckboxItem, MenuRadioGroup, MenuRadioItem, MenuSub, MenuSubTrigger, MenuSubContent, MenuGroup, MenuGroupLabel, MenuSeparator, MenuDescription, MenuShortcut, MenuBadge, };
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { type ComponentProps, type ReactNode } from 'react';
|
|
2
|
+
export type MessageFrom = 'user' | 'assistant';
|
|
3
|
+
export interface MessageProps extends ComponentProps<'div'> {
|
|
4
|
+
/** Who wrote it. A person's turn is a bubble on the trailing side; the assistant's is prose. */
|
|
5
|
+
from?: MessageFrom;
|
|
6
|
+
/** Still being written: a caret follows the last word and the turn is marked busy. */
|
|
7
|
+
streaming?: boolean;
|
|
8
|
+
}
|
|
9
|
+
/** One turn. Put `Message.Avatar` and `Message.Content` in it. */
|
|
10
|
+
declare function MessageRoot({ from: fromProp, streaming, className, ...props }: MessageProps): import("react").JSX.Element;
|
|
11
|
+
declare namespace MessageRoot {
|
|
12
|
+
var displayName: string;
|
|
13
|
+
}
|
|
14
|
+
export interface MessageGroupProps extends ComponentProps<'div'> {
|
|
15
|
+
/** Who wrote every turn in it. */
|
|
16
|
+
from?: MessageFrom;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Turns in a row from the same side, set closer together. Give the avatar to
|
|
20
|
+
* the first and an empty `Message.Avatar` to the rest, so they line up.
|
|
21
|
+
*/
|
|
22
|
+
declare function MessageGroup({ from, className, ...props }: MessageGroupProps): import("react").JSX.Element;
|
|
23
|
+
declare namespace MessageGroup {
|
|
24
|
+
var displayName: string;
|
|
25
|
+
}
|
|
26
|
+
export interface MessageAvatarProps extends ComponentProps<'div'> {
|
|
27
|
+
}
|
|
28
|
+
/** Who it is from, beside the turn's first line. Leave it empty to keep the space. */
|
|
29
|
+
declare function MessageAvatar({ className, ...props }: MessageAvatarProps): import("react").JSX.Element;
|
|
30
|
+
declare namespace MessageAvatar {
|
|
31
|
+
var displayName: string;
|
|
32
|
+
}
|
|
33
|
+
export interface MessageContentProps extends ComponentProps<'div'> {
|
|
34
|
+
}
|
|
35
|
+
/** The column with the header, the bubble, the attachments and the actions. */
|
|
36
|
+
declare function MessageContent({ className, ...props }: MessageContentProps): import("react").JSX.Element;
|
|
37
|
+
declare namespace MessageContent {
|
|
38
|
+
var displayName: string;
|
|
39
|
+
}
|
|
40
|
+
export interface MessageHeaderProps extends ComponentProps<'div'> {
|
|
41
|
+
}
|
|
42
|
+
/** A line above the turn: a name in `<strong>`, a time, a model. */
|
|
43
|
+
declare function MessageHeader({ className, ...props }: MessageHeaderProps): import("react").JSX.Element;
|
|
44
|
+
declare namespace MessageHeader {
|
|
45
|
+
var displayName: string;
|
|
46
|
+
}
|
|
47
|
+
export interface MessageBubbleProps extends ComponentProps<'div'> {
|
|
48
|
+
}
|
|
49
|
+
/** The surface of a person's turn. On the assistant's it draws nothing, and the text is the page's. */
|
|
50
|
+
declare function MessageBubble({ className, ...props }: MessageBubbleProps): import("react").JSX.Element;
|
|
51
|
+
declare namespace MessageBubble {
|
|
52
|
+
var displayName: string;
|
|
53
|
+
}
|
|
54
|
+
export interface MessageBubbleContentProps extends ComponentProps<'div'> {
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* The text. Paragraphs, lists, inline code, code blocks and headings inside
|
|
58
|
+
* it are set as prose, so rendered Markdown can go straight in.
|
|
59
|
+
*/
|
|
60
|
+
declare function MessageBubbleContent({ className, children, ...props }: MessageBubbleContentProps): import("react").JSX.Element;
|
|
61
|
+
declare namespace MessageBubbleContent {
|
|
62
|
+
var displayName: string;
|
|
63
|
+
}
|
|
64
|
+
export interface MessageFooterProps extends ComponentProps<'div'> {
|
|
65
|
+
}
|
|
66
|
+
/** A line under the turn: sent, read, a model and how long it took. */
|
|
67
|
+
declare function MessageFooter({ className, ...props }: MessageFooterProps): import("react").JSX.Element;
|
|
68
|
+
declare namespace MessageFooter {
|
|
69
|
+
var displayName: string;
|
|
70
|
+
}
|
|
71
|
+
export interface MessageActionsProps extends ComponentProps<'div'> {
|
|
72
|
+
/**
|
|
73
|
+
* `always`, the default, for the latest answer. `hover` for earlier ones:
|
|
74
|
+
* hidden until the turn is hovered or focused, and always shown on touch.
|
|
75
|
+
*/
|
|
76
|
+
reveal?: 'always' | 'hover';
|
|
77
|
+
}
|
|
78
|
+
/** The row of actions under a turn. */
|
|
79
|
+
declare function MessageActions({ reveal, className, ...props }: MessageActionsProps): import("react").JSX.Element;
|
|
80
|
+
declare namespace MessageActions {
|
|
81
|
+
var displayName: string;
|
|
82
|
+
}
|
|
83
|
+
export interface MessageActionProps extends Omit<ComponentProps<'button'>, 'children'> {
|
|
84
|
+
/** Said by a screen reader and shown in the tooltip. Required, since the button is an icon. */
|
|
85
|
+
label: string;
|
|
86
|
+
/** The icon. Optional when `copy` is set, which draws its own. */
|
|
87
|
+
children?: ReactNode;
|
|
88
|
+
/**
|
|
89
|
+
* Text to put on the clipboard when pressed. The icon turns to a check for
|
|
90
|
+
* a moment, and the label to "Copied".
|
|
91
|
+
*/
|
|
92
|
+
copy?: string | (() => string);
|
|
93
|
+
/** For a toggle such as a thumbs-up: whether it is on. */
|
|
94
|
+
pressed?: boolean;
|
|
95
|
+
}
|
|
96
|
+
/** An icon button with a tooltip: copy, retry, rate, share. */
|
|
97
|
+
declare function MessageAction({ label, children, copy, pressed, onClick, className, ...props }: MessageActionProps): import("react").JSX.Element;
|
|
98
|
+
declare namespace MessageAction {
|
|
99
|
+
var displayName: string;
|
|
100
|
+
}
|
|
101
|
+
export interface MessageBranchProps extends Omit<ComponentProps<'div'>, 'onChange'> {
|
|
102
|
+
/** How many versions of the answer there are. */
|
|
103
|
+
count: number;
|
|
104
|
+
/** Which one is shown, from 0. */
|
|
105
|
+
index: number;
|
|
106
|
+
/** Called with the index of the version asked for. */
|
|
107
|
+
onIndexChange: (index: number) => void;
|
|
108
|
+
}
|
|
109
|
+
/** "‹ 2 / 3 ›": steps between the versions of an answer that was retried or edited. */
|
|
110
|
+
declare function MessageBranch({ count, index, onIndexChange, className, ...props }: MessageBranchProps): import("react").JSX.Element;
|
|
111
|
+
declare namespace MessageBranch {
|
|
112
|
+
var displayName: string;
|
|
113
|
+
}
|
|
114
|
+
export interface MessageStatusProps extends ComponentProps<'div'> {
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* What the assistant is doing before its first word: "Thinking", "Reading 4
|
|
118
|
+
* files". Announced as it changes. Replace it with the text once that arrives.
|
|
119
|
+
*/
|
|
120
|
+
declare function MessageStatus({ className, ...props }: MessageStatusProps): import("react").JSX.Element;
|
|
121
|
+
declare namespace MessageStatus {
|
|
122
|
+
var displayName: string;
|
|
123
|
+
}
|
|
124
|
+
export interface MessageAttachmentsProps extends ComponentProps<'div'> {
|
|
125
|
+
}
|
|
126
|
+
/** The files sent with a turn, above its bubble. */
|
|
127
|
+
declare function MessageAttachments({ className, ...props }: MessageAttachmentsProps): import("react").JSX.Element;
|
|
128
|
+
declare namespace MessageAttachments {
|
|
129
|
+
var displayName: string;
|
|
130
|
+
}
|
|
131
|
+
export interface MessageAttachmentProps extends Omit<ComponentProps<'div'>, 'children'> {
|
|
132
|
+
/** The file's name. */
|
|
133
|
+
name: string;
|
|
134
|
+
/** A picture to show in place of the file's card. */
|
|
135
|
+
src?: string;
|
|
136
|
+
/** A line under the name: its type and size. */
|
|
137
|
+
meta?: string;
|
|
138
|
+
/** The glyph on a file's card. A page outline when left out. */
|
|
139
|
+
icon?: ReactNode;
|
|
140
|
+
}
|
|
141
|
+
/** One sent file: a picture, or a card with a glyph, the name and its size. */
|
|
142
|
+
declare function MessageAttachment({ name, src, meta, icon, className, ...props }: MessageAttachmentProps): import("react").JSX.Element;
|
|
143
|
+
declare namespace MessageAttachment {
|
|
144
|
+
var displayName: string;
|
|
145
|
+
}
|
|
146
|
+
export declare const Message: typeof MessageRoot & {
|
|
147
|
+
Group: typeof MessageGroup;
|
|
148
|
+
Avatar: typeof MessageAvatar;
|
|
149
|
+
Content: typeof MessageContent;
|
|
150
|
+
Header: typeof MessageHeader;
|
|
151
|
+
Bubble: typeof MessageBubble;
|
|
152
|
+
BubbleContent: typeof MessageBubbleContent;
|
|
153
|
+
Footer: typeof MessageFooter;
|
|
154
|
+
Actions: typeof MessageActions;
|
|
155
|
+
Action: typeof MessageAction;
|
|
156
|
+
Branch: typeof MessageBranch;
|
|
157
|
+
Status: typeof MessageStatus;
|
|
158
|
+
Attachments: typeof MessageAttachments;
|
|
159
|
+
Attachment: typeof MessageAttachment;
|
|
160
|
+
};
|
|
161
|
+
export { MessageGroup, MessageAvatar, MessageContent, MessageHeader, MessageBubble, MessageBubbleContent, MessageFooter, MessageActions, MessageAction, MessageBranch, MessageStatus, MessageAttachments, MessageAttachment, };
|