@phreshos/react-ui 0.1.30 → 0.1.32
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 +162 -18
- package/dist/accordion.d.ts +45 -0
- package/dist/accordion.js +62 -0
- package/dist/alert-dialog.d.ts +0 -1
- package/dist/alert-dialog.js +0 -1
- package/dist/appearance.d.ts +6 -1
- package/dist/aria-direction.d.ts +9 -0
- package/dist/aria-direction.js +49 -0
- package/dist/calendar-layout.d.ts +8 -0
- package/dist/calendar-layout.js +103 -0
- package/dist/calendar-trigger.d.ts +5 -0
- package/dist/calendar-trigger.js +30 -0
- package/dist/calendar.d.ts +18 -0
- package/dist/calendar.js +13 -0
- package/dist/color.d.ts +16 -1
- package/dist/color.js +60 -11
- package/dist/combo-box.d.ts +20 -0
- package/dist/combo-box.js +68 -0
- package/dist/context-menu.d.ts +2 -4
- package/dist/context-menu.js +0 -1
- package/dist/control-surface.d.ts +2 -1
- package/dist/control-surface.js +2 -2
- package/dist/control.d.ts +1 -1
- package/dist/control.js +7 -8
- package/dist/date-control.d.ts +24 -0
- package/dist/date-control.js +69 -0
- package/dist/date-field.d.ts +19 -0
- package/dist/date-field.js +13 -0
- package/dist/date-picker.d.ts +19 -0
- package/dist/date-picker.js +16 -0
- package/dist/date-range-picker.d.ts +20 -0
- package/dist/date-range-picker.js +25 -0
- package/dist/date-range.d.ts +6 -0
- package/dist/date-range.js +0 -0
- package/dist/dialog.d.ts +4 -2
- package/dist/dialog.js +24 -7
- package/dist/disclosure.d.ts +42 -0
- package/dist/disclosure.js +97 -0
- package/dist/dropdown-menu.d.ts +0 -2
- package/dist/dropdown-menu.js +0 -1
- package/dist/list-box.d.ts +49 -0
- package/dist/list-box.js +129 -0
- package/dist/main.d.ts +27 -11
- package/dist/main.js +25 -9
- package/dist/material-paint.js +19 -1
- package/dist/menu.d.ts +22 -4
- package/dist/menu.js +25 -6
- package/dist/panel.d.ts +0 -1
- package/dist/panel.js +0 -1
- package/dist/popover.d.ts +0 -1
- package/dist/popover.js +13 -3
- package/dist/preferences.d.ts +8 -0
- package/dist/progress-bar.d.ts +22 -0
- package/dist/progress-bar.js +46 -0
- package/dist/radio.d.ts +5 -5
- package/dist/radio.js +8 -4
- package/dist/radius.js +1 -1
- package/dist/range-calendar.d.ts +19 -0
- package/dist/range-calendar.js +15 -0
- package/dist/scroll-area.d.ts +4 -1
- package/dist/scroll-area.js +3 -3
- package/dist/select.js +4 -14
- package/dist/selection.d.ts +18 -0
- package/dist/selection.js +28 -0
- package/dist/slider.js +1 -1
- package/dist/spacing.js +1 -1
- package/dist/table.d.ts +78 -0
- package/dist/table.js +148 -0
- package/dist/tabs.d.ts +45 -0
- package/dist/tabs.js +103 -0
- package/dist/time-field.d.ts +22 -0
- package/dist/time-field.js +13 -0
- package/dist/toggle-indicator.js +1 -1
- package/dist/toolbar.d.ts +46 -0
- package/dist/toolbar.js +121 -0
- package/dist/tooltip.d.ts +0 -1
- package/dist/tooltip.js +0 -1
- package/dist/tree.d.ts +56 -0
- package/dist/tree.js +134 -0
- package/dist/ui-provider.d.ts +4 -4
- package/dist/ui-provider.js +47 -8
- package/dist/window.d.ts +6 -3
- package/dist/window.js +10 -7
- package/package.json +4 -2
package/dist/dialog.js
CHANGED
|
@@ -3,8 +3,8 @@ import { forwardRef } from "react";
|
|
|
3
3
|
import { Dialog as AriaDialog, DialogTrigger as AriaDialogTrigger, Heading as AriaHeading, Modal as AriaModal, ModalOverlay as AriaModalOverlay, Text as AriaText } from "react-aria-components";
|
|
4
4
|
import { useAppearance } from "./ui-provider.js";
|
|
5
5
|
import { useResolvedAppearance } from "./appearance-context.js";
|
|
6
|
-
import { colorOpacity, orderColors } from "./color.js";
|
|
7
|
-
import { controlFontWeight, controlOpacity } from "./control.js";
|
|
6
|
+
import { colorOpacity, orderColors, resolveColor } from "./color.js";
|
|
7
|
+
import { controlFontSizes, controlFontWeight, controlOpacity } from "./control.js";
|
|
8
8
|
import { Button } from "./button.js";
|
|
9
9
|
import MotionStyle, { backdropMotionClass, overlayMotionClass, overlayTransition } from "./motion-style.js";
|
|
10
10
|
import { scale } from "./scale.js";
|
|
@@ -16,11 +16,14 @@ export function DialogRoot(properties) {
|
|
|
16
16
|
export const DialogTrigger = forwardRef(function DialogTrigger(properties, ref) {
|
|
17
17
|
return _jsx(Button, { ...properties, ref: ref });
|
|
18
18
|
});
|
|
19
|
-
export const DialogBackdrop = forwardRef(function DialogBackdrop({ className, style, ...properties }, ref) {
|
|
19
|
+
export const DialogBackdrop = forwardRef(function DialogBackdrop({ className, color, style, ...properties }, ref) {
|
|
20
20
|
const resolved = useResolvedAppearance();
|
|
21
21
|
const inset = scale(resolved.appearance.spacing, "medium");
|
|
22
22
|
const colors = resolved.colors;
|
|
23
|
-
const
|
|
23
|
+
const base = color === undefined
|
|
24
|
+
? orderColors(colors.background, colors.foreground).darker
|
|
25
|
+
: resolveColor(color, colors);
|
|
26
|
+
const backdrop = colorOpacity(base, 0.32);
|
|
24
27
|
const transition = overlayTransition(resolved.transaction, resolved.preferences.animations);
|
|
25
28
|
const direction = resolveDirection(properties.dir, useDirection());
|
|
26
29
|
return _jsxs(_Fragment, { children: [_jsx(MotionStyle, {}), _jsx(AriaModalOverlay, { ...properties, ref: ref, dir: direction, className: [backdropMotionClass, className].filter(Boolean).join(" "), style: {
|
|
@@ -68,10 +71,25 @@ export const DialogHeader = forwardRef(function DialogHeader({ style, ...propert
|
|
|
68
71
|
return _jsx("div", { ...properties, ref: ref, style: { display: "grid", gap, minWidth: 0, ...style } });
|
|
69
72
|
});
|
|
70
73
|
export const DialogTitle = forwardRef(function DialogTitle({ style, ...properties }, ref) {
|
|
71
|
-
|
|
74
|
+
// The modal is portalled: owned text parts set their relative scale directly,
|
|
75
|
+
// while Dialog.Body remains untouched for consumer-owned content and controls.
|
|
76
|
+
return _jsx(AriaHeading, { ...properties, ref: ref, slot: "title", style: {
|
|
77
|
+
margin: 0,
|
|
78
|
+
fontFamily: "inherit",
|
|
79
|
+
fontSize: controlFontSizes.medium,
|
|
80
|
+
fontWeight: controlFontWeight,
|
|
81
|
+
lineHeight: 1.5,
|
|
82
|
+
...style
|
|
83
|
+
} });
|
|
72
84
|
});
|
|
73
85
|
export const DialogDescription = forwardRef(function DialogDescription({ style, ...properties }, ref) {
|
|
74
|
-
return _jsx(AriaText, { ...properties, ref: ref, slot: "description", style: {
|
|
86
|
+
return _jsx(AriaText, { ...properties, ref: ref, slot: "description", style: {
|
|
87
|
+
margin: 0,
|
|
88
|
+
fontSize: controlFontSizes.medium,
|
|
89
|
+
lineHeight: 1.5,
|
|
90
|
+
opacity: controlOpacity.secondary,
|
|
91
|
+
...style
|
|
92
|
+
} });
|
|
75
93
|
});
|
|
76
94
|
export const DialogBody = forwardRef(function DialogBody({ style, ...properties }, ref) {
|
|
77
95
|
return _jsx("div", { ...properties, ref: ref, style: { minWidth: 0, minHeight: 0, ...style } });
|
|
@@ -85,7 +103,6 @@ export const DialogClose = forwardRef(function DialogClose(properties, ref) {
|
|
|
85
103
|
});
|
|
86
104
|
/** A modal dialog whose behavioral and structural roles remain independently composable. */
|
|
87
105
|
export const Dialog = Object.assign(DialogRoot, {
|
|
88
|
-
Root: DialogRoot,
|
|
89
106
|
Trigger: DialogTrigger,
|
|
90
107
|
Backdrop: DialogBackdrop,
|
|
91
108
|
Content: DialogContent,
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { CSSProperties, ReactElement, ReactNode } from "react";
|
|
2
|
+
import type { ButtonProps as AriaButtonProps, DisclosurePanelProps as AriaDisclosurePanelProps, DisclosureProps as AriaDisclosureProps } from "react-aria-components";
|
|
3
|
+
import type { ControlColor } from "./control.js";
|
|
4
|
+
import type { RadiusProps } from "./radius.js";
|
|
5
|
+
import type { ScaleLevel } from "./scale.js";
|
|
6
|
+
import { type Spacing } from "./spacing.js";
|
|
7
|
+
export interface DisclosureRootProps extends Omit<AriaDisclosureProps, "children" | "className" | "defaultExpanded" | "isDisabled" | "isExpanded" | "onExpandedChange" | "style">, RadiusProps {
|
|
8
|
+
readonly children?: ReactNode;
|
|
9
|
+
readonly className?: string;
|
|
10
|
+
readonly color?: ControlColor;
|
|
11
|
+
readonly defaultExpanded?: boolean;
|
|
12
|
+
readonly disabled?: boolean;
|
|
13
|
+
readonly expanded?: boolean;
|
|
14
|
+
readonly onChange?: (expanded: boolean) => void;
|
|
15
|
+
readonly size?: ScaleLevel;
|
|
16
|
+
readonly style?: CSSProperties;
|
|
17
|
+
}
|
|
18
|
+
/** One independently expandable region. */
|
|
19
|
+
export declare const DisclosureRoot: import("react").ForwardRefExoticComponent<DisclosureRootProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
20
|
+
export interface DisclosureTriggerProps extends Omit<AriaButtonProps, "children" | "className" | "isDisabled" | "onPress" | "style"> {
|
|
21
|
+
readonly children?: ReactNode;
|
|
22
|
+
readonly className?: string;
|
|
23
|
+
readonly style?: CSSProperties;
|
|
24
|
+
}
|
|
25
|
+
/** The control that changes the Disclosure's expansion state. */
|
|
26
|
+
export declare const DisclosureTrigger: import("react").ForwardRefExoticComponent<DisclosureTriggerProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
27
|
+
export interface DisclosureContentProps extends Omit<AriaDisclosurePanelProps, "className" | "style"> {
|
|
28
|
+
/** Space around the revealed content. */
|
|
29
|
+
readonly padding?: Spacing;
|
|
30
|
+
readonly className?: string;
|
|
31
|
+
readonly style?: CSSProperties;
|
|
32
|
+
}
|
|
33
|
+
/** Content revealed by a Disclosure trigger. */
|
|
34
|
+
export declare const DisclosureContent: import("react").ForwardRefExoticComponent<DisclosureContentProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
35
|
+
interface DisclosureComponent {
|
|
36
|
+
(properties: DisclosureRootProps): ReactElement | null;
|
|
37
|
+
readonly Trigger: typeof DisclosureTrigger;
|
|
38
|
+
readonly Content: typeof DisclosureContent;
|
|
39
|
+
}
|
|
40
|
+
export declare const Disclosure: DisclosureComponent;
|
|
41
|
+
export type DisclosureProps = DisclosureRootProps;
|
|
42
|
+
export {};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, forwardRef, useContext, useMemo } from "react";
|
|
3
|
+
import { Button as AriaButton, Disclosure as AriaDisclosure, DisclosurePanel as AriaDisclosurePanel, DisclosureStateContext } from "react-aria-components";
|
|
4
|
+
import { useResolvedAppearance } from "./appearance-context.js";
|
|
5
|
+
import { controlOpacity, useControlTheme } from "./control.js";
|
|
6
|
+
import { transitionTiming } from "./motion-style.js";
|
|
7
|
+
import { resolveSpacing } from "./spacing.js";
|
|
8
|
+
const DisclosureThemeContext = createContext(null);
|
|
9
|
+
/** One independently expandable region. */
|
|
10
|
+
export const DisclosureRoot = forwardRef(function DisclosureRoot({ children, className, color, defaultExpanded, disabled = false, expanded, onChange, radius = "medium", size = "medium", style, ...properties }, ref) {
|
|
11
|
+
const theme = useControlTheme({ color, radius, size });
|
|
12
|
+
const resolved = useResolvedAppearance();
|
|
13
|
+
const context = useMemo(() => ({
|
|
14
|
+
motion: transitionTiming(resolved.transaction, resolved.preferences.animations),
|
|
15
|
+
theme
|
|
16
|
+
}), [resolved.preferences.animations, resolved.transaction, theme]);
|
|
17
|
+
return _jsx(DisclosureThemeContext.Provider, { value: context, children: _jsx(AriaDisclosure, { ...properties, ...(expanded === undefined ? {} : { isExpanded: expanded }), ...(defaultExpanded === undefined ? {} : { defaultExpanded }), ref: ref, className: className, isDisabled: disabled, onExpandedChange: onChange, style: {
|
|
18
|
+
display: "grid",
|
|
19
|
+
minWidth: 0,
|
|
20
|
+
fontFamily: "inherit",
|
|
21
|
+
fontSize: theme.fontSize,
|
|
22
|
+
...style
|
|
23
|
+
}, children: children }) });
|
|
24
|
+
});
|
|
25
|
+
/** The control that changes the Disclosure's expansion state. */
|
|
26
|
+
export const DisclosureTrigger = forwardRef(function DisclosureTrigger({ children, className, style, ...properties }, ref) {
|
|
27
|
+
const { motion, theme } = useDisclosureTheme();
|
|
28
|
+
const disclosure = useDisclosureState();
|
|
29
|
+
return _jsxs(AriaButton, { ...properties, ref: ref, slot: "trigger", className: className, style: state => ({
|
|
30
|
+
...theme.transition,
|
|
31
|
+
appearance: "none",
|
|
32
|
+
display: "grid",
|
|
33
|
+
gridTemplateColumns: "minmax(0, 1fr) auto",
|
|
34
|
+
alignItems: "center",
|
|
35
|
+
gap: theme.gap,
|
|
36
|
+
width: "100%",
|
|
37
|
+
minWidth: 0,
|
|
38
|
+
minHeight: theme.height,
|
|
39
|
+
paddingBlock: theme.gap,
|
|
40
|
+
paddingInline: Math.max(8, theme.spacing),
|
|
41
|
+
boxSizing: "border-box",
|
|
42
|
+
border: 0,
|
|
43
|
+
borderRadius: theme.radius,
|
|
44
|
+
outline: state.isFocusVisible ? `1px solid ${theme.focusColor}` : "none",
|
|
45
|
+
outlineOffset: 1,
|
|
46
|
+
cursor: state.isDisabled ? "not-allowed" : "pointer",
|
|
47
|
+
opacity: state.isDisabled ? controlOpacity.disabled : 1,
|
|
48
|
+
font: "inherit",
|
|
49
|
+
lineHeight: 1.5,
|
|
50
|
+
textAlign: "start",
|
|
51
|
+
userSelect: "none",
|
|
52
|
+
WebkitTapHighlightColor: "transparent",
|
|
53
|
+
...(disclosure.isExpanded
|
|
54
|
+
? state.isPressed ? theme.paints.palette.pressed : state.isHovered ? theme.paints.palette.hover : theme.paints.palette.rest
|
|
55
|
+
: state.isPressed ? theme.paints.subtle.pressed : state.isHovered ? theme.paints.subtle.hover : { background: "transparent", color: "inherit" }),
|
|
56
|
+
...style
|
|
57
|
+
}), children: [_jsx("span", { style: { minWidth: 0 }, children: children }), _jsx("span", { "aria-hidden": "true", style: {
|
|
58
|
+
...motion,
|
|
59
|
+
transitionProperty: "transform",
|
|
60
|
+
width: "0.5em",
|
|
61
|
+
height: "0.5em",
|
|
62
|
+
marginInline: "0.25em",
|
|
63
|
+
borderInlineEnd: "1px solid currentColor",
|
|
64
|
+
borderBlockEnd: "1px solid currentColor",
|
|
65
|
+
transform: disclosure.isExpanded ? "rotate(225deg)" : "rotate(45deg)"
|
|
66
|
+
} })] });
|
|
67
|
+
});
|
|
68
|
+
/** Content revealed by a Disclosure trigger. */
|
|
69
|
+
export const DisclosureContent = forwardRef(function DisclosureContent({ children, className, padding = "small", style, ...properties }, ref) {
|
|
70
|
+
const { motion } = useDisclosureTheme();
|
|
71
|
+
const disclosure = useDisclosureState();
|
|
72
|
+
const { appearance } = useResolvedAppearance();
|
|
73
|
+
return _jsx(AriaDisclosurePanel, { ...properties, ref: ref, className: className, style: {
|
|
74
|
+
...motion,
|
|
75
|
+
transitionProperty: "height, opacity",
|
|
76
|
+
height: "var(--disclosure-panel-height)",
|
|
77
|
+
overflow: "clip",
|
|
78
|
+
opacity: disclosure.isExpanded ? 1 : 0,
|
|
79
|
+
...style
|
|
80
|
+
}, children: _jsx("div", { style: { minHeight: 0, overflow: "hidden" }, children: _jsx("div", { style: { padding: resolveSpacing(padding, appearance) }, children: children }) }) });
|
|
81
|
+
});
|
|
82
|
+
function useDisclosureState() {
|
|
83
|
+
const state = useContext(DisclosureStateContext);
|
|
84
|
+
if (state == null)
|
|
85
|
+
throw new Error("Disclosure parts must be used inside Disclosure");
|
|
86
|
+
return state;
|
|
87
|
+
}
|
|
88
|
+
function useDisclosureTheme() {
|
|
89
|
+
const context = useContext(DisclosureThemeContext);
|
|
90
|
+
if (context == null)
|
|
91
|
+
throw new Error("Disclosure parts must be used inside Disclosure");
|
|
92
|
+
return context;
|
|
93
|
+
}
|
|
94
|
+
export const Disclosure = Object.assign(DisclosureRoot, {
|
|
95
|
+
Trigger: DisclosureTrigger,
|
|
96
|
+
Content: DisclosureContent
|
|
97
|
+
});
|
package/dist/dropdown-menu.d.ts
CHANGED
|
@@ -7,11 +7,9 @@ export type DropdownMenuTriggerProps = ButtonProps;
|
|
|
7
7
|
export declare const DropdownMenuTrigger: import("react").ForwardRefExoticComponent<ButtonProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
8
8
|
/** A button-triggered overlay. Its Content owns positioning; Menu owns commands and selection. */
|
|
9
9
|
export declare const DropdownMenu: typeof DropdownMenuRoot & {
|
|
10
|
-
Root: typeof DropdownMenuRoot;
|
|
11
10
|
Trigger: import("react").ForwardRefExoticComponent<ButtonProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
12
11
|
Content: import("react").ForwardRefExoticComponent<import("./popover.js").PopoverContentProps & import("react").RefAttributes<HTMLElement>>;
|
|
13
12
|
Menu: import("./menu.js").MenuRootComponent & {
|
|
14
|
-
Root: import("./menu.js").MenuRootComponent;
|
|
15
13
|
Item: import("./menu.js").MenuItemComponent;
|
|
16
14
|
Section: <T>(props: import("react-aria-components").MenuSectionProps<T> & React.RefAttributes<HTMLElement>) => import("react").ReactElement<unknown, string | React.JSXElementConstructor<any>> | null;
|
|
17
15
|
Header: import("react").ForwardRefExoticComponent<import("react-aria-components").HeaderProps & import("react").RefAttributes<HTMLElement>>;
|
package/dist/dropdown-menu.js
CHANGED
|
@@ -12,7 +12,6 @@ export const DropdownMenuTrigger = forwardRef(function DropdownMenuTrigger(prope
|
|
|
12
12
|
});
|
|
13
13
|
/** A button-triggered overlay. Its Content owns positioning; Menu owns commands and selection. */
|
|
14
14
|
export const DropdownMenu = Object.assign(DropdownMenuRoot, {
|
|
15
|
-
Root: DropdownMenuRoot,
|
|
16
15
|
Trigger: DropdownMenuTrigger,
|
|
17
16
|
Content: PopoverContent,
|
|
18
17
|
Menu
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { CSSProperties, ReactElement, RefAttributes } from "react";
|
|
2
|
+
import type { HeaderProps as AriaHeaderProps, ListBoxItemProps as AriaListBoxItemProps, ListBoxProps as AriaListBoxProps, ListBoxSectionProps as AriaListBoxSectionProps } from "react-aria-components";
|
|
3
|
+
import type { ControlColor } from "./control.js";
|
|
4
|
+
import type { RadiusProps } from "./radius.js";
|
|
5
|
+
import type { ScaleLevel } from "./scale.js";
|
|
6
|
+
import { type MultipleStringSelection, type MultipleStringSelectionProps, type SingleStringSelectionProps } from "./selection.js";
|
|
7
|
+
type ListBoxRootBaseProps<T extends object> = Omit<AriaListBoxProps<T>, "className" | "defaultSelectedKeys" | "disabledKeys" | "onSelectionChange" | "selectedKeys" | "selectionMode" | "style"> & RadiusProps & Readonly<{
|
|
8
|
+
className?: string;
|
|
9
|
+
color?: ControlColor;
|
|
10
|
+
disabledValues?: readonly string[];
|
|
11
|
+
size?: ScaleLevel;
|
|
12
|
+
style?: CSSProperties;
|
|
13
|
+
}>;
|
|
14
|
+
export type ListBoxSingleSelectionProps = SingleStringSelectionProps & Readonly<{
|
|
15
|
+
selectionMode?: "single";
|
|
16
|
+
}>;
|
|
17
|
+
export type ListBoxMultipleValue = MultipleStringSelection;
|
|
18
|
+
export type ListBoxMultipleSelectionProps = MultipleStringSelectionProps & Readonly<{
|
|
19
|
+
selectionMode: "multiple";
|
|
20
|
+
}>;
|
|
21
|
+
/** Properties accepted by the selectable collection. Single selection is the default. */
|
|
22
|
+
export type ListBoxRootProps<T extends object = object> = ListBoxRootBaseProps<T> & (ListBoxSingleSelectionProps | ListBoxMultipleSelectionProps);
|
|
23
|
+
export type ListBoxRootComponent = <T extends object = object>(properties: ListBoxRootProps<T> & RefAttributes<HTMLDivElement>) => ReactElement | null;
|
|
24
|
+
export declare const ListBoxRoot: ListBoxRootComponent;
|
|
25
|
+
export interface ListBoxItemProps<T = object> extends Omit<AriaListBoxItemProps<T>, "className" | "id" | "isDisabled" | "style"> {
|
|
26
|
+
readonly className?: string;
|
|
27
|
+
readonly color?: ControlColor;
|
|
28
|
+
readonly disabled?: boolean;
|
|
29
|
+
readonly id: string;
|
|
30
|
+
readonly style?: CSSProperties;
|
|
31
|
+
}
|
|
32
|
+
export type ListBoxItemComponent = <T = object>(properties: ListBoxItemProps<T> & RefAttributes<HTMLDivElement>) => ReactElement | null;
|
|
33
|
+
export declare const ListBoxItem: ListBoxItemComponent;
|
|
34
|
+
export interface ListBoxSectionProps<T extends object = object> extends Omit<AriaListBoxSectionProps<T>, "className" | "style"> {
|
|
35
|
+
readonly className?: string;
|
|
36
|
+
readonly style?: CSSProperties;
|
|
37
|
+
}
|
|
38
|
+
export type ListBoxSectionComponent = <T extends object = object>(properties: ListBoxSectionProps<T> & RefAttributes<HTMLElement>) => ReactElement | null;
|
|
39
|
+
export declare const ListBoxSection: ListBoxSectionComponent;
|
|
40
|
+
export type ListBoxHeaderProps = AriaHeaderProps;
|
|
41
|
+
export declare const ListBoxHeader: import("react").ForwardRefExoticComponent<AriaHeaderProps & RefAttributes<HTMLElement>>;
|
|
42
|
+
/** A selectable collection whose items and groups remain independently composable. */
|
|
43
|
+
export declare const ListBox: ListBoxRootComponent & {
|
|
44
|
+
Item: ListBoxItemComponent;
|
|
45
|
+
Section: ListBoxSectionComponent;
|
|
46
|
+
Header: import("react").ForwardRefExoticComponent<AriaHeaderProps & RefAttributes<HTMLElement>>;
|
|
47
|
+
};
|
|
48
|
+
export type ListBoxProps<T extends object = object> = ListBoxRootProps<T>;
|
|
49
|
+
export {};
|
package/dist/list-box.js
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, forwardRef, useContext, useMemo } from "react";
|
|
3
|
+
import { Header as AriaHeader, ListBox as AriaListBox, ListBoxItem as AriaListBoxItem, ListBoxSection as AriaListBoxSection } from "react-aria-components";
|
|
4
|
+
import { controlFontWeight, controlOpacity, useControlTheme } from "./control.js";
|
|
5
|
+
import { resolveDirection, useDirection } from "./direction.js";
|
|
6
|
+
import { multipleSelection, singleSelection, toAriaSelection } from "./selection.js";
|
|
7
|
+
import { AriaDirectionBoundary } from "./aria-direction.js";
|
|
8
|
+
const ListBoxThemeContext = createContext(null);
|
|
9
|
+
const ListBoxRootImplementation = forwardRef(function ListBoxRoot(properties, ref) {
|
|
10
|
+
const { className, color, defaultValue, disabledValues, onChange, radius = "medium", selectionMode = "single", shouldFocusOnHover = false, size = "medium", style, value, ...native } = properties;
|
|
11
|
+
const theme = useControlTheme({ color, radius, size });
|
|
12
|
+
const context = useMemo(() => ({ color, radius, size, theme }), [color, radius, size, theme]);
|
|
13
|
+
const direction = resolveDirection(native.dir, useDirection());
|
|
14
|
+
const selection = selectionProperties(properties);
|
|
15
|
+
return _jsx(ListBoxThemeContext.Provider, { value: context, children: _jsx(AriaDirectionBoundary, { direction: direction, children: _jsx(AriaListBox, { ...native, ...selection, ref: ref, dir: direction, selectionMode: selectionMode, shouldFocusOnHover: shouldFocusOnHover, className: className, style: {
|
|
16
|
+
display: "grid",
|
|
17
|
+
gap: theme.gap,
|
|
18
|
+
minWidth: 0,
|
|
19
|
+
padding: theme.gap,
|
|
20
|
+
boxSizing: "border-box",
|
|
21
|
+
outline: "none",
|
|
22
|
+
fontFamily: "inherit",
|
|
23
|
+
fontSize: theme.fontSize,
|
|
24
|
+
...style
|
|
25
|
+
} }) }) });
|
|
26
|
+
});
|
|
27
|
+
export const ListBoxRoot = ListBoxRootImplementation;
|
|
28
|
+
function selectionProperties(properties) {
|
|
29
|
+
const selectedKeys = toAriaSelection(properties.value);
|
|
30
|
+
const defaultSelectedKeys = toAriaSelection(properties.defaultValue);
|
|
31
|
+
const disabledKeys = properties.disabledValues;
|
|
32
|
+
const onSelectionChange = properties.onChange == null
|
|
33
|
+
? undefined
|
|
34
|
+
: (selection) => {
|
|
35
|
+
if (properties.selectionMode === "multiple") {
|
|
36
|
+
properties.onChange?.(multipleSelection(selection));
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
properties.onChange?.(singleSelection(selection));
|
|
40
|
+
};
|
|
41
|
+
return {
|
|
42
|
+
...(selectedKeys !== undefined ? { selectedKeys } : {}),
|
|
43
|
+
...(defaultSelectedKeys !== undefined ? { defaultSelectedKeys } : {}),
|
|
44
|
+
...(disabledKeys !== undefined ? { disabledKeys } : {}),
|
|
45
|
+
...(onSelectionChange !== undefined ? { onSelectionChange } : {})
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
const ListBoxItemImplementation = forwardRef(function ListBoxItem({ children, className, color, disabled = false, style, ...properties }, ref) {
|
|
49
|
+
const inherited = useContext(ListBoxThemeContext);
|
|
50
|
+
const item = {
|
|
51
|
+
children,
|
|
52
|
+
className,
|
|
53
|
+
disabled,
|
|
54
|
+
properties: {
|
|
55
|
+
...properties,
|
|
56
|
+
textValue: properties.textValue ?? (typeof children === "string" ? children : undefined)
|
|
57
|
+
},
|
|
58
|
+
ref,
|
|
59
|
+
style
|
|
60
|
+
};
|
|
61
|
+
return inherited != null && color === undefined
|
|
62
|
+
? _jsx(ListBoxItemView, { ...item, theme: inherited.theme })
|
|
63
|
+
: _jsx(ResolvedListBoxItem, { ...item, color: color ?? inherited?.color, radius: inherited?.radius, size: inherited?.size });
|
|
64
|
+
});
|
|
65
|
+
function ResolvedListBoxItem({ color, radius, size, ...properties }) {
|
|
66
|
+
return _jsx(ListBoxItemView, { ...properties, theme: useControlTheme({ color, radius, size }) });
|
|
67
|
+
}
|
|
68
|
+
function ListBoxItemView({ children, className, disabled, properties, ref, style, theme }) {
|
|
69
|
+
return _jsx(AriaListBoxItem, { ...properties, ref: ref, className: className, isDisabled: disabled, style: state => ({
|
|
70
|
+
...theme.transition,
|
|
71
|
+
display: "flex",
|
|
72
|
+
alignItems: "center",
|
|
73
|
+
justifyContent: "space-between",
|
|
74
|
+
gap: theme.gap,
|
|
75
|
+
minWidth: 0,
|
|
76
|
+
minHeight: theme.height,
|
|
77
|
+
paddingInline: Math.max(8, theme.spacing),
|
|
78
|
+
boxSizing: "border-box",
|
|
79
|
+
borderRadius: theme.radius,
|
|
80
|
+
outline: state.isFocusVisible && !state.isSelected ? `1px solid ${theme.focusColor}` : "none",
|
|
81
|
+
outlineOffset: 1,
|
|
82
|
+
cursor: disabled ? "not-allowed" : "pointer",
|
|
83
|
+
opacity: disabled ? controlOpacity.disabled : 1,
|
|
84
|
+
userSelect: "none",
|
|
85
|
+
...(state.isSelected
|
|
86
|
+
? state.isPressed
|
|
87
|
+
? theme.paints.palette.pressed
|
|
88
|
+
: state.isHovered
|
|
89
|
+
? theme.paints.palette.hover
|
|
90
|
+
: theme.paints.palette.rest
|
|
91
|
+
: state.isHovered
|
|
92
|
+
? theme.paints.subtle.hover
|
|
93
|
+
: { background: "transparent", color: "inherit" }),
|
|
94
|
+
...style
|
|
95
|
+
}), children: state => _jsxs(_Fragment, { children: [typeof children === "function" ? children(state) : children, _jsx("span", { "aria-hidden": "true", style: { flexShrink: 0, width: "1em", textAlign: "center" }, children: state.isSelected ? "✓" : null })] }) });
|
|
96
|
+
}
|
|
97
|
+
export const ListBoxItem = ListBoxItemImplementation;
|
|
98
|
+
const ListBoxSectionImplementation = forwardRef(function ListBoxSection({ className, style, ...properties }, ref) {
|
|
99
|
+
const theme = useListBoxTheme();
|
|
100
|
+
return _jsx(AriaListBoxSection, { ...properties, ref: ref, className: className, style: {
|
|
101
|
+
display: "grid",
|
|
102
|
+
gap: theme.gap,
|
|
103
|
+
minWidth: 0,
|
|
104
|
+
...style
|
|
105
|
+
} });
|
|
106
|
+
});
|
|
107
|
+
export const ListBoxSection = ListBoxSectionImplementation;
|
|
108
|
+
export const ListBoxHeader = forwardRef(function ListBoxHeader({ style, ...properties }, ref) {
|
|
109
|
+
const theme = useListBoxTheme();
|
|
110
|
+
return _jsx(AriaHeader, { ...properties, ref: ref, style: {
|
|
111
|
+
paddingInline: Math.max(8, theme.spacing),
|
|
112
|
+
paddingBlock: theme.gap,
|
|
113
|
+
fontWeight: controlFontWeight,
|
|
114
|
+
opacity: controlOpacity.secondary,
|
|
115
|
+
...style
|
|
116
|
+
} });
|
|
117
|
+
});
|
|
118
|
+
function useListBoxTheme() {
|
|
119
|
+
const inherited = useContext(ListBoxThemeContext);
|
|
120
|
+
if (inherited == null)
|
|
121
|
+
throw new Error("ListBox parts must be used inside ListBox");
|
|
122
|
+
return inherited.theme;
|
|
123
|
+
}
|
|
124
|
+
/** A selectable collection whose items and groups remain independently composable. */
|
|
125
|
+
export const ListBox = Object.assign(ListBoxRoot, {
|
|
126
|
+
Item: ListBoxItem,
|
|
127
|
+
Section: ListBoxSection,
|
|
128
|
+
Header: ListBoxHeader
|
|
129
|
+
});
|
package/dist/main.d.ts
CHANGED
|
@@ -4,32 +4,48 @@
|
|
|
4
4
|
* Components enter this surface only after their implementation-independent
|
|
5
5
|
* behavior contract has been established by the package's tests.
|
|
6
6
|
*/
|
|
7
|
-
export { defaultAppearance, type Appearance, type AppearanceColor, type AppearanceColors, type AppearanceMaterial, type AppearanceShadow, type AppearanceTransaction, type Easing, type ThemedValue } from "./appearance.js";
|
|
7
|
+
export { defaultAppearance, type Appearance, type AppearanceUpdate, type AppearanceColor, type AppearanceColors, type AppearanceMaterial, type AppearanceShadow, type AppearanceTransaction, type Easing, type ThemedValue } from "./appearance.js";
|
|
8
8
|
export { UIProvider, useAppearance, useBrowserPreferences, useDirection, useDocumentDirection, usePreferences, useThemedValue, type UIProviderProps } from "./ui-provider.js";
|
|
9
|
-
export type { Preferences, Theme } from "./preferences.js";
|
|
9
|
+
export type { Preferences, PreferencesUpdate, Theme } from "./preferences.js";
|
|
10
10
|
export type { Direction } from "./direction.js";
|
|
11
11
|
export { Flex, type FlexProps } from "./flex.js";
|
|
12
12
|
export { Grid, type GridProps } from "./grid.js";
|
|
13
13
|
export { Surface, type MaterialMode, type MaterialOptions, type ShadowOptions, type SurfaceComponent, type SurfaceHost, type SurfaceHostProps, type SurfaceOwnProps, type SurfaceProps } from "./surface.js";
|
|
14
14
|
export { defaultColor, type Color, type ColorLevel, type ColorScale } from "./color.js";
|
|
15
|
-
export { Panel,
|
|
15
|
+
export { Panel, type PanelProps, type PanelHeaderProps, type PanelContentProps } from "./panel.js";
|
|
16
16
|
export { Window, type WindowProps, type WindowContentProps, type WindowHeaderProps, type WindowIdentityProps, type WindowCenterProps, type WindowActionsProps, type WindowActionProps, type WindowControlProps, type WindowMaximizeProps, type WindowCloseProps } from "./window.js";
|
|
17
17
|
export { Button, type ButtonColor, type ButtonProps } from "./button.js";
|
|
18
18
|
export { Input, type InputProps } from "./input.js";
|
|
19
19
|
export { Textarea, type TextareaProps } from "./textarea.js";
|
|
20
|
+
export { DateField, type DateFieldProps } from "./date-field.js";
|
|
21
|
+
export { TimeField, type TimeFieldProps } from "./time-field.js";
|
|
22
|
+
export { Calendar, type CalendarProps } from "./calendar.js";
|
|
23
|
+
export { RangeCalendar, type RangeCalendarProps } from "./range-calendar.js";
|
|
24
|
+
export { DatePicker, type DatePickerProps } from "./date-picker.js";
|
|
25
|
+
export { DateRangePicker, type DateRangePickerProps } from "./date-range-picker.js";
|
|
26
|
+
export type { DateRange } from "./date-range.js";
|
|
20
27
|
export { Checkbox, type CheckboxProps } from "./checkbox.js";
|
|
21
|
-
export {
|
|
28
|
+
export { RadioGroup, type RadioGroupProps, type RadioGroupItemProps } from "./radio.js";
|
|
22
29
|
export { Switch, type SwitchProps } from "./switch.js";
|
|
23
30
|
export { Select, type SelectProps, type SelectOption } from "./select.js";
|
|
31
|
+
export { ComboBox, type ComboBoxProps, type ComboBoxOption } from "./combo-box.js";
|
|
32
|
+
export { ListBox, type ListBoxProps, type ListBoxSingleSelectionProps, type ListBoxMultipleSelectionProps, type ListBoxMultipleValue, type ListBoxItemProps, type ListBoxSectionProps, type ListBoxHeaderProps } from "./list-box.js";
|
|
33
|
+
export { Tabs, type TabsProps, type TabsListProps, type TabsTabProps, type TabsPanelsProps, type TabsPanelProps } from "./tabs.js";
|
|
34
|
+
export { Table, type TableProps, type TableNoSelectionProps, type TableSingleSelectionProps, type TableMultipleSelectionProps, type TableMultipleValue, type TableSort, type TableSortDirection, type TableHeaderProps, type TableColumnProps, type TableBodyProps, type TableRowProps, type TableCellProps } from "./table.js";
|
|
35
|
+
export { Tree, type TreeProps, type TreeNoSelectionProps, type TreeSingleSelectionProps, type TreeMultipleSelectionProps, type TreeMultipleValue, type TreeItemProps, type TreeContentProps, type TreeCollectionProps } from "./tree.js";
|
|
24
36
|
export { Slider, type SliderProps } from "./slider.js";
|
|
37
|
+
export { ProgressBar, type ProgressBarProps } from "./progress-bar.js";
|
|
25
38
|
export { ScrollArea, type ScrollAreaAxis, type ScrollAreaProps } from "./scroll-area.js";
|
|
26
|
-
export {
|
|
27
|
-
export {
|
|
28
|
-
export {
|
|
29
|
-
export {
|
|
30
|
-
export {
|
|
31
|
-
export {
|
|
32
|
-
export {
|
|
39
|
+
export { Toolbar, type ToolbarProps, type ToolbarGroupProps, type ToolbarSeparatorProps } from "./toolbar.js";
|
|
40
|
+
export { Disclosure, type DisclosureProps, type DisclosureTriggerProps, type DisclosureContentProps } from "./disclosure.js";
|
|
41
|
+
export { Accordion, type AccordionProps, type AccordionSingleExpansionProps, type AccordionMultipleExpansionProps, type AccordionItemProps } from "./accordion.js";
|
|
42
|
+
export { Popover, type PopoverProps, type PopoverTriggerProps, type PopoverContentProps, type PopoverDialogProps, type PopoverTitleProps, type PopoverCloseProps } from "./popover.js";
|
|
43
|
+
export { Menu, type MenuProps, type MenuNoSelectionProps, type MenuSingleSelectionProps, type MenuMultipleSelectionProps, type MenuMultipleValue, type MenuItemProps, type MenuSectionProps, type MenuHeaderProps, type MenuSeparatorProps } from "./menu.js";
|
|
44
|
+
export { DropdownMenu, type DropdownMenuProps, type DropdownMenuTriggerProps } from "./dropdown-menu.js";
|
|
45
|
+
export { ContextMenu, type ContextMenuProps, type ContextMenuTriggerProps, type ContextMenuContentProps } from "./context-menu.js";
|
|
46
|
+
export { Dialog, type DialogProps, type DialogTriggerProps, type DialogBackdropProps, type DialogContentProps, type DialogHeaderProps, type DialogTitleProps, type DialogDescriptionProps, type DialogBodyProps, type DialogFooterProps, type DialogCloseProps } from "./dialog.js";
|
|
47
|
+
export { AlertDialog, type AlertDialogProps, type AlertDialogBackdropProps, type AlertDialogContentProps } from "./alert-dialog.js";
|
|
48
|
+
export { Tooltip, type TooltipProps, type TooltipTriggerProps, type TooltipContentProps } from "./tooltip.js";
|
|
33
49
|
export type { ControlColor } from "./control.js";
|
|
34
50
|
export type { LayoutAlignment, LayoutGap, LayoutJustification } from "./layout.js";
|
|
35
51
|
export { resolveRadius, type Radius, type RadiusProps } from "./radius.js";
|
package/dist/main.js
CHANGED
|
@@ -10,24 +10,40 @@ export { Flex } from "./flex.js";
|
|
|
10
10
|
export { Grid } from "./grid.js";
|
|
11
11
|
export { Surface } from "./surface.js";
|
|
12
12
|
export { defaultColor } from "./color.js";
|
|
13
|
-
|
|
13
|
+
// Context-dependent parts are public only through their owning component family.
|
|
14
|
+
export { Panel } from "./panel.js";
|
|
14
15
|
export { Window } from "./window.js";
|
|
15
16
|
export { Button } from "./button.js";
|
|
16
17
|
export { Input } from "./input.js";
|
|
17
18
|
export { Textarea } from "./textarea.js";
|
|
19
|
+
export { DateField } from "./date-field.js";
|
|
20
|
+
export { TimeField } from "./time-field.js";
|
|
21
|
+
export { Calendar } from "./calendar.js";
|
|
22
|
+
export { RangeCalendar } from "./range-calendar.js";
|
|
23
|
+
export { DatePicker } from "./date-picker.js";
|
|
24
|
+
export { DateRangePicker } from "./date-range-picker.js";
|
|
18
25
|
export { Checkbox } from "./checkbox.js";
|
|
19
|
-
export {
|
|
26
|
+
export { RadioGroup } from "./radio.js";
|
|
20
27
|
export { Switch } from "./switch.js";
|
|
21
28
|
export { Select } from "./select.js";
|
|
29
|
+
export { ComboBox } from "./combo-box.js";
|
|
30
|
+
export { ListBox } from "./list-box.js";
|
|
31
|
+
export { Tabs } from "./tabs.js";
|
|
32
|
+
export { Table } from "./table.js";
|
|
33
|
+
export { Tree } from "./tree.js";
|
|
22
34
|
export { Slider } from "./slider.js";
|
|
35
|
+
export { ProgressBar } from "./progress-bar.js";
|
|
23
36
|
export { ScrollArea } from "./scroll-area.js";
|
|
24
|
-
export {
|
|
25
|
-
export {
|
|
26
|
-
export {
|
|
27
|
-
export {
|
|
28
|
-
export {
|
|
29
|
-
export {
|
|
30
|
-
export {
|
|
37
|
+
export { Toolbar } from "./toolbar.js";
|
|
38
|
+
export { Disclosure } from "./disclosure.js";
|
|
39
|
+
export { Accordion } from "./accordion.js";
|
|
40
|
+
export { Popover } from "./popover.js";
|
|
41
|
+
export { Menu } from "./menu.js";
|
|
42
|
+
export { DropdownMenu } from "./dropdown-menu.js";
|
|
43
|
+
export { ContextMenu } from "./context-menu.js";
|
|
44
|
+
export { Dialog } from "./dialog.js";
|
|
45
|
+
export { AlertDialog } from "./alert-dialog.js";
|
|
46
|
+
export { Tooltip } from "./tooltip.js";
|
|
31
47
|
export { resolveRadius } from "./radius.js";
|
|
32
48
|
export { resolveSpacing } from "./spacing.js";
|
|
33
49
|
export { useColor } from "./color.js";
|
package/dist/material-paint.js
CHANGED
|
@@ -43,12 +43,28 @@ function DistortionFilter({ distortion, identity }) {
|
|
|
43
43
|
return _jsxs("filter", { id: `${identity}-distortion`, "data-material-distortion": "", x: "-20%", y: "-20%", width: "140%", height: "140%", colorInterpolationFilters: "sRGB", children: [_jsx("feTurbulence", { "data-material-distortion-noise": "", "data-material-distortion-field": "organic", type: "fractalNoise", baseFrequency: "0.008 0.008", numOctaves: 2, seed: 92, result: `${identity}-organic-noise` }), _jsx("feGaussianBlur", { in: `${identity}-organic-noise`, stdDeviation: 2, result: `${identity}-organic-noise-blurred` }), _jsx("feDisplacementMap", { "data-material-distortion-stage": "organic", in: "SourceGraphic", in2: `${identity}-organic-noise-blurred`, scale: distortion, xChannelSelector: "R", yChannelSelector: "G" })] });
|
|
44
44
|
}
|
|
45
45
|
function grainImage(seed, amount) {
|
|
46
|
+
const key = `${seed}:${amount}`;
|
|
47
|
+
const cached = grainResources.get(key);
|
|
48
|
+
if (cached !== undefined) {
|
|
49
|
+
grainResources.delete(key);
|
|
50
|
+
grainResources.set(key, cached);
|
|
51
|
+
return cached;
|
|
52
|
+
}
|
|
46
53
|
const paths = grainPaths(seed, amount)
|
|
47
54
|
.map((path, tone) => path
|
|
48
55
|
? `<path d="${path}" fill="rgb(${toneChannel(tone)} ${toneChannel(tone)} ${toneChannel(tone)})"/>`
|
|
49
56
|
: "")
|
|
50
57
|
.join("");
|
|
51
|
-
|
|
58
|
+
const resource = `url("data:image/svg+xml,${encodeURIComponent(`<svg xmlns="http://www.w3.org/2000/svg" width="${patternSize}" height="${patternSize}" viewBox="0 0 ${patternSize} ${patternSize}">${paths}</svg>`)}")`;
|
|
59
|
+
// Preserve the exact texture while avoiding the same expensive SVG generation
|
|
60
|
+
// for every Surface. The bound prevents live grain controls from growing it forever.
|
|
61
|
+
if (grainResources.size >= grainResourceLimit) {
|
|
62
|
+
const oldest = grainResources.keys().next().value;
|
|
63
|
+
if (oldest !== undefined)
|
|
64
|
+
grainResources.delete(oldest);
|
|
65
|
+
}
|
|
66
|
+
grainResources.set(key, resource);
|
|
67
|
+
return resource;
|
|
52
68
|
}
|
|
53
69
|
/** Preserve the original contract: amount is the monotonic density of visible grain pixels. */
|
|
54
70
|
function grainPaths(seed, amount) {
|
|
@@ -99,3 +115,5 @@ function clamp(value, minimum, maximum) {
|
|
|
99
115
|
const patternSize = 64;
|
|
100
116
|
const toneCount = 16;
|
|
101
117
|
const grainSeeds = [19, 47, 83, 131];
|
|
118
|
+
const grainResourceLimit = 64;
|
|
119
|
+
const grainResources = new Map();
|
package/dist/menu.d.ts
CHANGED
|
@@ -2,18 +2,36 @@ import type { CSSProperties, ReactElement, RefAttributes } from "react";
|
|
|
2
2
|
import type { HeaderProps as AriaHeaderProps, MenuItemProps as AriaMenuItemProps, MenuProps as AriaMenuProps, MenuSectionProps as AriaMenuSectionProps, SeparatorProps as AriaSeparatorProps } from "react-aria-components";
|
|
3
3
|
import { type ControlColor } from "./control.js";
|
|
4
4
|
import type { ScaleLevel } from "./scale.js";
|
|
5
|
-
|
|
5
|
+
import { type MultipleStringSelection, type MultipleStringSelectionProps, type SingleStringSelectionProps } from "./selection.js";
|
|
6
|
+
type MenuRootBaseProps<T extends object> = Omit<AriaMenuProps<T>, "className" | "defaultSelectedKeys" | "disabledKeys" | "onAction" | "onSelectionChange" | "selectedKeys" | "selectionMode" | "style"> & Readonly<{
|
|
6
7
|
readonly className?: string;
|
|
7
8
|
readonly color?: ControlColor;
|
|
9
|
+
readonly disabledValues?: readonly string[];
|
|
10
|
+
readonly onItemAction?: (value: string) => void;
|
|
8
11
|
readonly size?: ScaleLevel;
|
|
9
12
|
readonly style?: CSSProperties;
|
|
10
|
-
}
|
|
13
|
+
}>;
|
|
14
|
+
export type MenuNoSelectionProps = Readonly<{
|
|
15
|
+
selectionMode?: "none";
|
|
16
|
+
value?: never;
|
|
17
|
+
defaultValue?: never;
|
|
18
|
+
onChange?: never;
|
|
19
|
+
}>;
|
|
20
|
+
export type MenuSingleSelectionProps = SingleStringSelectionProps & Readonly<{
|
|
21
|
+
selectionMode: "single";
|
|
22
|
+
}>;
|
|
23
|
+
export type MenuMultipleValue = MultipleStringSelection;
|
|
24
|
+
export type MenuMultipleSelectionProps = MultipleStringSelectionProps & Readonly<{
|
|
25
|
+
selectionMode: "multiple";
|
|
26
|
+
}>;
|
|
27
|
+
export type MenuRootProps<T extends object = object> = MenuRootBaseProps<T> & (MenuNoSelectionProps | MenuSingleSelectionProps | MenuMultipleSelectionProps);
|
|
11
28
|
export type MenuRootComponent = <T extends object = object>(properties: MenuRootProps<T> & RefAttributes<HTMLDivElement>) => ReactElement | null;
|
|
12
29
|
export declare const MenuRoot: MenuRootComponent;
|
|
13
|
-
export interface MenuItemProps<T = object> extends Omit<AriaMenuItemProps<T>, "className" | "isDisabled" | "style"> {
|
|
30
|
+
export interface MenuItemProps<T = object> extends Omit<AriaMenuItemProps<T>, "className" | "id" | "isDisabled" | "style"> {
|
|
14
31
|
readonly className?: string;
|
|
15
32
|
readonly color?: ControlColor;
|
|
16
33
|
readonly disabled?: boolean;
|
|
34
|
+
readonly id?: string;
|
|
17
35
|
readonly style?: CSSProperties;
|
|
18
36
|
}
|
|
19
37
|
export type MenuItemComponent = <T = object>(properties: MenuItemProps<T> & RefAttributes<HTMLDivElement>) => ReactElement | null;
|
|
@@ -26,10 +44,10 @@ export type MenuSeparatorProps = AriaSeparatorProps;
|
|
|
26
44
|
export declare const MenuSeparator: import("react").ForwardRefExoticComponent<AriaSeparatorProps & RefAttributes<HTMLElement>>;
|
|
27
45
|
/** A keyboard-navigable collection of commands or selectable options. */
|
|
28
46
|
export declare const Menu: MenuRootComponent & {
|
|
29
|
-
Root: MenuRootComponent;
|
|
30
47
|
Item: MenuItemComponent;
|
|
31
48
|
Section: <T>(props: AriaMenuSectionProps<T> & React.RefAttributes<HTMLElement>) => ReactElement<unknown, string | React.JSXElementConstructor<any>> | null;
|
|
32
49
|
Header: import("react").ForwardRefExoticComponent<AriaHeaderProps & RefAttributes<HTMLElement>>;
|
|
33
50
|
Separator: import("react").ForwardRefExoticComponent<AriaSeparatorProps & RefAttributes<HTMLElement>>;
|
|
34
51
|
};
|
|
35
52
|
export type MenuProps<T extends object = object> = MenuRootProps<T>;
|
|
53
|
+
export {};
|