@omer-x/tailwind-ui-kit 1.0.0-alpha.4 → 1.0.0-alpha.40
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/MIGRATION.md +283 -0
- package/README.md +1440 -0
- package/dist/components/button/BaseButton.d.ts +40 -12
- package/dist/components/button/BaseButton.js +35 -51
- package/dist/components/button/BaseToggle.d.ts +35 -0
- package/dist/components/button/BaseToggle.js +23 -0
- package/dist/components/button/BaseToggleGroup.d.ts +26 -0
- package/dist/components/button/BaseToggleGroup.js +12 -0
- package/dist/components/button/buttonStyles.d.ts +3 -0
- package/dist/components/button/buttonStyles.js +29 -0
- package/dist/components/button/index.d.ts +4 -4
- package/dist/components/button/index.js +4 -4
- package/dist/components/dialog/BaseAlertDialog.d.ts +49 -0
- package/dist/components/dialog/BaseAlertDialog.js +27 -0
- package/dist/components/dialog/BaseAlertDialogTrigger.d.ts +16 -0
- package/dist/components/dialog/BaseAlertDialogTrigger.js +11 -0
- package/dist/components/dialog/BaseDialog.d.ts +58 -0
- package/dist/components/dialog/BaseDialog.js +24 -0
- package/dist/components/dialog/BaseDialogClose.d.ts +13 -0
- package/dist/components/dialog/BaseDialogClose.js +7 -0
- package/dist/components/dialog/BaseDialogDescription.d.ts +8 -0
- package/dist/components/dialog/BaseDialogDescription.js +7 -0
- package/dist/components/dialog/BaseDialogPopup.d.ts +41 -0
- package/dist/components/dialog/BaseDialogPopup.js +29 -0
- package/dist/components/dialog/BaseDialogTitle.d.ts +8 -0
- package/dist/components/dialog/BaseDialogTitle.js +11 -0
- package/dist/components/dialog/BaseDialogTrigger.d.ts +20 -0
- package/dist/components/dialog/BaseDialogTrigger.js +11 -0
- package/dist/components/dialog/createAlertDialogHandle.d.ts +14 -0
- package/dist/components/dialog/createAlertDialogHandle.js +11 -0
- package/dist/components/dialog/createDialogHandle.d.ts +36 -0
- package/dist/components/dialog/createDialogHandle.js +31 -0
- package/dist/components/dialog/index.d.ts +8 -5
- package/dist/components/dialog/index.js +5 -8
- package/dist/components/disclosure/BaseAccordion.d.ts +48 -0
- package/dist/components/disclosure/BaseAccordion.js +18 -0
- package/dist/components/disclosure/BaseAccordionItem.d.ts +20 -0
- package/dist/components/disclosure/BaseAccordionItem.js +10 -0
- package/dist/components/disclosure/BaseAccordionPanel.d.ts +20 -0
- package/dist/components/disclosure/BaseAccordionPanel.js +15 -0
- package/dist/components/disclosure/BaseAccordionTrigger.d.ts +22 -0
- package/dist/components/disclosure/BaseAccordionTrigger.js +23 -0
- package/dist/components/disclosure/BaseCollapsible.d.ts +33 -0
- package/dist/components/disclosure/BaseCollapsible.js +16 -0
- package/dist/components/disclosure/BaseCollapsiblePanel.d.ts +20 -0
- package/dist/components/disclosure/BaseCollapsiblePanel.js +15 -0
- package/dist/components/disclosure/BaseCollapsibleTrigger.d.ts +15 -0
- package/dist/components/disclosure/BaseCollapsibleTrigger.js +16 -0
- package/dist/components/disclosure/index.d.ts +6 -0
- package/dist/components/disclosure/index.js +3 -0
- package/dist/components/disclosure/panelTransition.d.ts +7 -0
- package/dist/components/disclosure/panelTransition.js +9 -0
- package/dist/components/display/BaseAvatar.d.ts +24 -0
- package/dist/components/display/BaseAvatar.js +35 -0
- package/dist/components/display/BaseAvatarFallback.d.ts +14 -0
- package/dist/components/display/BaseAvatarFallback.js +14 -0
- package/dist/components/display/BaseAvatarImage.d.ts +23 -0
- package/dist/components/display/BaseAvatarImage.js +14 -0
- package/dist/components/display/BaseMeter.d.ts +60 -0
- package/dist/components/display/BaseMeter.js +45 -0
- package/dist/components/display/BaseMeterIndicator.d.ts +9 -0
- package/dist/components/display/BaseMeterIndicator.js +12 -0
- package/dist/components/display/BaseMeterLabel.d.ts +9 -0
- package/dist/components/display/BaseMeterLabel.js +7 -0
- package/dist/components/display/BaseMeterTrack.d.ts +12 -0
- package/dist/components/display/BaseMeterTrack.js +12 -0
- package/dist/components/display/BaseMeterValue.d.ts +14 -0
- package/dist/components/display/BaseMeterValue.js +10 -0
- package/dist/components/display/barStyles.d.ts +5 -0
- package/dist/components/display/barStyles.js +20 -0
- package/dist/components/display/index.d.ts +4 -0
- package/dist/components/display/index.js +3 -0
- package/dist/components/elements/JustAnchor.d.ts +7 -0
- package/dist/components/elements/JustAnchor.js +11 -0
- package/dist/components/elements/JustButton.d.ts +7 -0
- package/dist/components/elements/JustButton.js +11 -0
- package/dist/components/elements/JustDiv.d.ts +7 -0
- package/dist/components/elements/JustDiv.js +11 -0
- package/dist/components/elements/JustInput.d.ts +7 -0
- package/dist/components/elements/JustInput.js +11 -0
- package/dist/components/elements/JustSpan.d.ts +7 -0
- package/dist/components/elements/JustSpan.js +11 -0
- package/dist/components/elements/index.d.ts +6 -0
- package/dist/components/elements/index.js +6 -0
- package/dist/components/form/BaseAutocomplete.d.ts +198 -0
- package/dist/components/form/BaseAutocomplete.js +49 -0
- package/dist/components/form/BaseAutocompleteClear.d.ts +18 -0
- package/dist/components/form/BaseAutocompleteClear.js +7 -0
- package/dist/components/form/BaseAutocompleteCollection.d.ts +8 -0
- package/dist/components/form/BaseAutocompleteCollection.js +7 -0
- package/dist/components/form/BaseAutocompleteEmpty.d.ts +11 -0
- package/dist/components/form/BaseAutocompleteEmpty.js +10 -0
- package/dist/components/form/BaseAutocompleteGroup.d.ts +10 -0
- package/dist/components/form/BaseAutocompleteGroup.js +7 -0
- package/dist/components/form/BaseAutocompleteGroupLabel.d.ts +8 -0
- package/dist/components/form/BaseAutocompleteGroupLabel.js +7 -0
- package/dist/components/form/BaseAutocompleteIcon.d.ts +8 -0
- package/dist/components/form/BaseAutocompleteIcon.js +7 -0
- package/dist/components/form/BaseAutocompleteInput.d.ts +12 -0
- package/dist/components/form/BaseAutocompleteInput.js +12 -0
- package/dist/components/form/BaseAutocompleteInputGroup.d.ts +9 -0
- package/dist/components/form/BaseAutocompleteInputGroup.js +11 -0
- package/dist/components/form/BaseAutocompleteItem.d.ts +20 -0
- package/dist/components/form/BaseAutocompleteItem.js +11 -0
- package/dist/components/form/BaseAutocompleteList.d.ts +14 -0
- package/dist/components/form/BaseAutocompleteList.js +11 -0
- package/dist/components/form/BaseAutocompletePopup.d.ts +111 -0
- package/dist/components/form/BaseAutocompletePopup.js +45 -0
- package/dist/components/form/BaseAutocompleteRow.d.ts +8 -0
- package/dist/components/form/BaseAutocompleteRow.js +7 -0
- package/dist/components/form/BaseAutocompleteSeparator.d.ts +13 -0
- package/dist/components/form/BaseAutocompleteSeparator.js +7 -0
- package/dist/components/form/BaseAutocompleteStatus.d.ts +11 -0
- package/dist/components/form/BaseAutocompleteStatus.js +10 -0
- package/dist/components/form/BaseAutocompleteTrigger.d.ts +11 -0
- package/dist/components/form/BaseAutocompleteTrigger.js +7 -0
- package/dist/components/form/BaseAutocompleteValue.d.ts +8 -0
- package/dist/components/form/BaseAutocompleteValue.js +7 -0
- package/dist/components/form/BaseCheckbox.d.ts +49 -0
- package/dist/components/form/BaseCheckbox.js +31 -0
- package/dist/components/form/BaseCheckboxGroup.d.ts +24 -0
- package/dist/components/form/BaseCheckboxGroup.js +20 -0
- package/dist/components/form/BaseFieldset.d.ts +21 -0
- package/dist/components/form/BaseFieldset.js +18 -0
- package/dist/components/form/BaseForm.d.ts +13 -0
- package/dist/components/form/BaseForm.js +78 -0
- package/dist/components/form/BaseFormField.d.ts +33 -0
- package/dist/components/form/BaseFormField.js +33 -0
- package/dist/components/form/BaseInput.d.ts +8 -0
- package/dist/components/form/BaseInput.js +12 -0
- package/dist/components/form/BaseRadio.d.ts +30 -0
- package/dist/components/form/BaseRadio.js +22 -0
- package/dist/components/form/BaseRadioGroup.d.ts +28 -0
- package/dist/components/form/BaseRadioGroup.js +21 -0
- package/dist/components/form/BaseSwitch.d.ts +35 -0
- package/dist/components/form/BaseSwitch.js +21 -0
- package/dist/components/form/ClientSideError.d.ts +9 -0
- package/dist/components/form/ClientSideError.js +39 -0
- package/dist/components/form/FieldRoot.d.ts +8 -0
- package/dist/components/form/FieldRoot.js +25 -0
- package/dist/components/form/FormContext.d.ts +28 -0
- package/dist/components/form/FormContext.js +12 -0
- package/dist/components/form/InsideFieldContext.d.ts +2 -0
- package/dist/components/form/InsideFieldContext.js +5 -0
- package/dist/components/form/ServerSideError.d.ts +8 -0
- package/dist/components/form/ServerSideError.js +15 -0
- package/dist/components/form/autocompleteTypes.d.ts +16 -0
- package/dist/components/form/autocompleteTypes.js +1 -0
- package/dist/components/form/index.d.ts +21 -0
- package/dist/components/form/index.js +13 -0
- package/dist/components/form/inputSizes.d.ts +11 -0
- package/dist/components/form/inputSizes.js +19 -0
- package/dist/components/form/useAutocompleteFilter.d.ts +19 -0
- package/dist/components/form/useAutocompleteFilter.js +12 -0
- package/dist/components/form/useFormMessages.d.ts +10 -0
- package/dist/components/form/useFormMessages.js +16 -0
- package/dist/components/layout/Container.d.ts +4 -10
- package/dist/components/layout/Container.js +9 -10
- package/dist/components/layout/index.d.ts +2 -3
- package/dist/components/layout/index.js +1 -4
- package/dist/components/menu/BaseContextMenu.d.ts +150 -0
- package/dist/components/menu/BaseContextMenu.js +38 -0
- package/dist/components/menu/BaseContextMenuTrigger.d.ts +15 -0
- package/dist/components/menu/BaseContextMenuTrigger.js +10 -0
- package/dist/components/menu/BaseMenu.d.ts +171 -0
- package/dist/components/menu/BaseMenu.js +62 -0
- package/dist/components/menu/BaseMenuArrow.d.ts +19 -0
- package/dist/components/menu/BaseMenuArrow.js +10 -0
- package/dist/components/menu/BaseMenuCheckboxItem.d.ts +37 -0
- package/dist/components/menu/BaseMenuCheckboxItem.js +25 -0
- package/dist/components/menu/BaseMenuClear.d.ts +16 -0
- package/dist/components/menu/BaseMenuClear.js +10 -0
- package/dist/components/menu/BaseMenuEmpty.d.ts +8 -0
- package/dist/components/menu/BaseMenuEmpty.js +7 -0
- package/dist/components/menu/BaseMenuGroup.d.ts +8 -0
- package/dist/components/menu/BaseMenuGroup.js +7 -0
- package/dist/components/menu/BaseMenuGroupLabel.d.ts +8 -0
- package/dist/components/menu/BaseMenuGroupLabel.js +11 -0
- package/dist/components/menu/BaseMenuInput.d.ts +15 -0
- package/dist/components/menu/BaseMenuInput.js +10 -0
- package/dist/components/menu/BaseMenuItem.d.ts +24 -0
- package/dist/components/menu/BaseMenuItem.js +12 -0
- package/dist/components/menu/BaseMenuLinkItem.d.ts +20 -0
- package/dist/components/menu/BaseMenuLinkItem.js +12 -0
- package/dist/components/menu/BaseMenuList.d.ts +11 -0
- package/dist/components/menu/BaseMenuList.js +14 -0
- package/dist/components/menu/BaseMenuPopup.d.ts +116 -0
- package/dist/components/menu/BaseMenuPopup.js +42 -0
- package/dist/components/menu/BaseMenuRadioGroup.d.ts +19 -0
- package/dist/components/menu/BaseMenuRadioGroup.js +10 -0
- package/dist/components/menu/BaseMenuRadioItem.d.ts +36 -0
- package/dist/components/menu/BaseMenuRadioItem.js +24 -0
- package/dist/components/menu/BaseMenuSeparator.d.ts +11 -0
- package/dist/components/menu/BaseMenuSeparator.js +11 -0
- package/dist/components/menu/BaseMenuSubmenu.d.ts +13 -0
- package/dist/components/menu/BaseMenuSubmenu.js +22 -0
- package/dist/components/menu/BaseMenuSubmenuTrigger.d.ts +43 -0
- package/dist/components/menu/BaseMenuSubmenuTrigger.js +20 -0
- package/dist/components/menu/BaseMenuTrigger.d.ts +26 -0
- package/dist/components/menu/BaseMenuTrigger.js +11 -0
- package/dist/components/menu/BaseMenuViewport.d.ts +18 -0
- package/dist/components/menu/BaseMenuViewport.js +11 -0
- package/dist/components/menu/BaseMenubar.d.ts +187 -0
- package/dist/components/menu/BaseMenubar.js +18 -0
- package/dist/components/menu/createMenuHandle.d.ts +30 -0
- package/dist/components/menu/createMenuHandle.js +27 -0
- package/dist/components/menu/index.d.ts +20 -0
- package/dist/components/menu/index.js +5 -0
- package/dist/components/menu/menuItemStyles.d.ts +6 -0
- package/dist/components/menu/menuItemStyles.js +27 -0
- package/dist/components/menu/menuTypes.d.ts +69 -0
- package/dist/components/menu/menuTypes.js +16 -0
- package/dist/components/page/Pagination.d.ts +27 -0
- package/dist/components/page/Pagination.js +68 -0
- package/dist/components/page/index.d.ts +3 -0
- package/dist/components/page/index.js +3 -0
- package/dist/components/page/usePagination.d.ts +30 -0
- package/dist/components/page/usePagination.js +41 -0
- package/dist/components/table/TableCell.d.ts +13 -0
- package/dist/components/table/TableCell.js +17 -0
- package/dist/components/table/Tdx.d.ts +6 -10
- package/dist/components/table/Tdx.js +11 -9
- package/dist/components/table/index.d.ts +3 -3
- package/dist/components/table/index.js +3 -4
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/index.js +1 -0
- package/dist/hooks/useRipples.d.ts +2 -5
- package/dist/hooks/useRipples.js +44 -32
- package/dist/utils/cn.d.ts +6 -5
- package/dist/utils/cn.js +8 -6
- package/dist/utils/dirty-form.d.ts +7 -0
- package/dist/utils/dirty-form.js +40 -0
- package/dist/utils/index.d.ts +3 -2
- package/dist/utils/index.js +2 -3
- package/dist/utils/render.d.ts +31 -0
- package/dist/utils/render.js +24 -0
- package/dist/utils/split-class-name.d.ts +15 -0
- package/dist/utils/split-class-name.js +18 -0
- package/package.json +64 -26
- package/typescript-badge.d.ts +4 -0
- package/dist/components/button/PulseButton.d.ts +0 -10
- package/dist/components/button/PulseButton.js +0 -24
- package/dist/components/dialog/AnimatedPopup.d.ts +0 -6
- package/dist/components/dialog/AnimatedPopup.js +0 -34
- package/dist/components/dialog/DialogBackdrop.d.ts +0 -6
- package/dist/components/dialog/DialogBackdrop.js +0 -26
- package/dist/components/dialog/DialogTitle.d.ts +0 -6
- package/dist/components/dialog/DialogTitle.js +0 -19
- package/dist/styles/ripple.module.css +0 -10
- package/dist/styles/ripple.module.d.ts +0 -2
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { RenderProp } from "../../utils/render.js";
|
|
2
|
+
import { ComponentProps, ReactNode } from "react";
|
|
3
|
+
export type MenuCheckboxItemState = {
|
|
4
|
+
checked: boolean;
|
|
5
|
+
disabled: boolean;
|
|
6
|
+
/** Whether the item is highlighted by the pointer or the keyboard. */
|
|
7
|
+
highlighted: boolean;
|
|
8
|
+
};
|
|
9
|
+
type BaseMenuCheckboxItemProps = Omit<ComponentProps<"div">, "defaultChecked"> & {
|
|
10
|
+
render?: RenderProp<"div", MenuCheckboxItemState>;
|
|
11
|
+
checked?: boolean;
|
|
12
|
+
defaultChecked?: boolean;
|
|
13
|
+
/** Called with the new state and the DOM event that changed it. */
|
|
14
|
+
onCheckedChange?: (checked: boolean, event: Event) => void;
|
|
15
|
+
/** Shown before the text when checked, e.g. a check mark. */
|
|
16
|
+
indicator?: ReactNode;
|
|
17
|
+
renderIndicator?: RenderProp<"span", MenuCheckboxItemState>;
|
|
18
|
+
/** Keeps the indicator in the DOM when unchecked, e.g. to animate it out with CSS. */
|
|
19
|
+
keepIndicatorMounted?: boolean;
|
|
20
|
+
/** Ignores user interaction. */
|
|
21
|
+
disabled?: boolean;
|
|
22
|
+
/** The text used by keyboard text navigation. Defaults to the item's text. */
|
|
23
|
+
label?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Closes the menu when the item is clicked.
|
|
26
|
+
* @default false
|
|
27
|
+
*/
|
|
28
|
+
closeOnClick?: boolean;
|
|
29
|
+
/** Set to `true` when `render` renders a `<button>`. */
|
|
30
|
+
nativeButton?: boolean;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* An item that toggles a setting. Renders a `<div>` with `role="menuitemcheckbox"`,
|
|
34
|
+
* `data-checked` / `data-unchecked`, `data-highlighted` and `data-disabled`.
|
|
35
|
+
*/
|
|
36
|
+
declare const BaseMenuCheckboxItem: ({ indicator, renderIndicator, keepIndicatorMounted, onCheckedChange, className, children, ...otherProps }: BaseMenuCheckboxItemProps) => import("react").JSX.Element;
|
|
37
|
+
export { BaseMenuCheckboxItem as default };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Menu } from "@base-ui/react/menu";
|
|
3
|
+
import { cn } from "cn";
|
|
4
|
+
import { menuIndicatorClassNames, menuIndicatorItemClassNames, menuIndicatorLabelClassNames, menuItemClassNames } from "./menuItemStyles.js";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
// src/components/menu/BaseMenuCheckboxItem.tsx
|
|
7
|
+
/**
|
|
8
|
+
* An item that toggles a setting. Renders a `<div>` with `role="menuitemcheckbox"`,
|
|
9
|
+
* `data-checked` / `data-unchecked`, `data-highlighted` and `data-disabled`.
|
|
10
|
+
*/
|
|
11
|
+
const BaseMenuCheckboxItem = ({ indicator, renderIndicator, keepIndicatorMounted, onCheckedChange, className, children, ...otherProps }) => /* @__PURE__ */ jsxs(Menu.CheckboxItem, {
|
|
12
|
+
...otherProps,
|
|
13
|
+
onCheckedChange: onCheckedChange && ((checked, details) => onCheckedChange(checked, details.event)),
|
|
14
|
+
className: cn(menuItemClassNames, menuIndicatorItemClassNames, className),
|
|
15
|
+
children: [/* @__PURE__ */ jsx(Menu.CheckboxItemIndicator, {
|
|
16
|
+
keepMounted: keepIndicatorMounted,
|
|
17
|
+
render: renderIndicator,
|
|
18
|
+
className: cn(menuIndicatorClassNames),
|
|
19
|
+
children: indicator
|
|
20
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
21
|
+
className: cn(menuIndicatorLabelClassNames),
|
|
22
|
+
children
|
|
23
|
+
})]
|
|
24
|
+
});
|
|
25
|
+
export { BaseMenuCheckboxItem as default };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { RenderProp } from "../../utils/render.js";
|
|
2
|
+
import { ComponentProps } from "react";
|
|
3
|
+
export type MenuClearState = {
|
|
4
|
+
disabled: boolean;
|
|
5
|
+
};
|
|
6
|
+
type BaseMenuClearProps = ComponentProps<"button"> & {
|
|
7
|
+
render?: RenderProp<"button", MenuClearState>;
|
|
8
|
+
/** Set to `false` when `render` doesn't render a `<button>`. */
|
|
9
|
+
nativeButton?: boolean;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* A button that clears the search box of a `filterable` menu. Renders a `<button>`, only while there's a query.
|
|
13
|
+
* It's a pointer shortcut: out of the tab order and hidden from assistive technology (`aria-hidden`).
|
|
14
|
+
*/
|
|
15
|
+
declare const BaseMenuClear: (props: BaseMenuClearProps) => import("react").JSX.Element;
|
|
16
|
+
export { BaseMenuClear as default };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Menu } from "@base-ui/react/menu";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
// src/components/menu/BaseMenuClear.tsx
|
|
5
|
+
/**
|
|
6
|
+
* A button that clears the search box of a `filterable` menu. Renders a `<button>`, only while there's a query.
|
|
7
|
+
* It's a pointer shortcut: out of the tab order and hidden from assistive technology (`aria-hidden`).
|
|
8
|
+
*/
|
|
9
|
+
const BaseMenuClear = (props) => /* @__PURE__ */ jsx(Menu.Clear, { ...props });
|
|
10
|
+
export { BaseMenuClear as default };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { RenderProp } from "../../utils/render.js";
|
|
2
|
+
import { ComponentProps } from "react";
|
|
3
|
+
type BaseMenuEmptyProps = ComponentProps<"div"> & {
|
|
4
|
+
render?: RenderProp<"div">;
|
|
5
|
+
};
|
|
6
|
+
/** Shown only when no item of a `filterable` menu matches. Renders a `<div>` with `role="status"`, only then. */
|
|
7
|
+
declare const BaseMenuEmpty: (props: BaseMenuEmptyProps) => import("react").JSX.Element;
|
|
8
|
+
export { BaseMenuEmpty as default };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Menu } from "@base-ui/react/menu";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
// src/components/menu/BaseMenuEmpty.tsx
|
|
5
|
+
/** Shown only when no item of a `filterable` menu matches. Renders a `<div>` with `role="status"`, only then. */
|
|
6
|
+
const BaseMenuEmpty = (props) => /* @__PURE__ */ jsx(Menu.Empty, { ...props });
|
|
7
|
+
export { BaseMenuEmpty as default };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { RenderProp } from "../../utils/render.js";
|
|
2
|
+
import { ComponentProps } from "react";
|
|
3
|
+
type BaseMenuGroupProps = ComponentProps<"div"> & {
|
|
4
|
+
render?: RenderProp<"div">;
|
|
5
|
+
};
|
|
6
|
+
/** Groups related items. Label it with a `GroupLabel` inside. Renders a `<div>` with `role="group"`. */
|
|
7
|
+
declare const BaseMenuGroup: (props: BaseMenuGroupProps) => import("react").JSX.Element;
|
|
8
|
+
export { BaseMenuGroup as default };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Menu } from "@base-ui/react/menu";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
// src/components/menu/BaseMenuGroup.tsx
|
|
5
|
+
/** Groups related items. Label it with a `GroupLabel` inside. Renders a `<div>` with `role="group"`. */
|
|
6
|
+
const BaseMenuGroup = (props) => /* @__PURE__ */ jsx(Menu.Group, { ...props });
|
|
7
|
+
export { BaseMenuGroup as default };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { RenderProp } from "../../utils/render.js";
|
|
2
|
+
import { ComponentProps } from "react";
|
|
3
|
+
type BaseMenuGroupLabelProps = ComponentProps<"div"> & {
|
|
4
|
+
render?: RenderProp<"div">;
|
|
5
|
+
};
|
|
6
|
+
/** Names the group it's in. Renders a `<div>`. */
|
|
7
|
+
declare const BaseMenuGroupLabel: ({ className, ...otherProps }: BaseMenuGroupLabelProps) => import("react").JSX.Element;
|
|
8
|
+
export { BaseMenuGroupLabel as default };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Menu } from "@base-ui/react/menu";
|
|
3
|
+
import { cn } from "cn";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
// src/components/menu/BaseMenuGroupLabel.tsx
|
|
6
|
+
/** Names the group it's in. Renders a `<div>`. */
|
|
7
|
+
const BaseMenuGroupLabel = ({ className, ...otherProps }) => /* @__PURE__ */ jsx(Menu.GroupLabel, {
|
|
8
|
+
...otherProps,
|
|
9
|
+
className: cn("px-3", "py-1.5", "text-xs", "font-medium", "select-none", className)
|
|
10
|
+
});
|
|
11
|
+
export { BaseMenuGroupLabel as default };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { RenderProp } from "../../utils/render.js";
|
|
2
|
+
import { ComponentProps } from "react";
|
|
3
|
+
export type MenuInputState = {
|
|
4
|
+
/** Whether the input shows its focus. Cleared while an item is highlighted with the arrow keys. */
|
|
5
|
+
highlighted: boolean;
|
|
6
|
+
};
|
|
7
|
+
type BaseMenuInputProps = Omit<ComponentProps<"input">, "value" | "defaultValue"> & {
|
|
8
|
+
render?: RenderProp<"input", MenuInputState>;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* The search box of a `filterable` menu: put it in the popup, outside the `List`. Typing filters the items.
|
|
12
|
+
* Renders an `<input>`, with `data-highlighted` while it has the visual focus.
|
|
13
|
+
*/
|
|
14
|
+
declare const BaseMenuInput: (props: BaseMenuInputProps) => import("react").JSX.Element;
|
|
15
|
+
export { BaseMenuInput as default };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Menu } from "@base-ui/react/menu";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
// src/components/menu/BaseMenuInput.tsx
|
|
5
|
+
/**
|
|
6
|
+
* The search box of a `filterable` menu: put it in the popup, outside the `List`. Typing filters the items.
|
|
7
|
+
* Renders an `<input>`, with `data-highlighted` while it has the visual focus.
|
|
8
|
+
*/
|
|
9
|
+
const BaseMenuInput = (props) => /* @__PURE__ */ jsx(Menu.Input, { ...props });
|
|
10
|
+
export { BaseMenuInput as default };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { RenderProp } from "../../utils/render.js";
|
|
2
|
+
import { ComponentProps } from "react";
|
|
3
|
+
export type MenuItemState = {
|
|
4
|
+
disabled: boolean;
|
|
5
|
+
/** Whether the item is highlighted by the pointer or the keyboard. */
|
|
6
|
+
highlighted: boolean;
|
|
7
|
+
};
|
|
8
|
+
type BaseMenuItemProps = ComponentProps<"div"> & {
|
|
9
|
+
render?: RenderProp<"div", MenuItemState>;
|
|
10
|
+
/** Ignores user interaction. */
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
/** The text used by keyboard text navigation. Defaults to the item's text. */
|
|
13
|
+
label?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Closes the menu when the item is clicked.
|
|
16
|
+
* @default true
|
|
17
|
+
*/
|
|
18
|
+
closeOnClick?: boolean;
|
|
19
|
+
/** Set to `true` when `render` renders a `<button>`. */
|
|
20
|
+
nativeButton?: boolean;
|
|
21
|
+
};
|
|
22
|
+
/** An action in a menu. Renders a `<div>`, with `data-highlighted` and `data-disabled`. */
|
|
23
|
+
declare const BaseMenuItem: ({ className, ...otherProps }: BaseMenuItemProps) => import("react").JSX.Element;
|
|
24
|
+
export { BaseMenuItem as default };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Menu } from "@base-ui/react/menu";
|
|
3
|
+
import { cn } from "cn";
|
|
4
|
+
import { menuItemClassNames } from "./menuItemStyles.js";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
// src/components/menu/BaseMenuItem.tsx
|
|
7
|
+
/** An action in a menu. Renders a `<div>`, with `data-highlighted` and `data-disabled`. */
|
|
8
|
+
const BaseMenuItem = ({ className, ...otherProps }) => /* @__PURE__ */ jsx(Menu.Item, {
|
|
9
|
+
...otherProps,
|
|
10
|
+
className: cn(menuItemClassNames, className)
|
|
11
|
+
});
|
|
12
|
+
export { BaseMenuItem as default };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { RenderProp } from "../../utils/render.js";
|
|
2
|
+
import { ComponentProps } from "react";
|
|
3
|
+
export type MenuLinkItemState = {
|
|
4
|
+
/** Whether the item is highlighted by the pointer or the keyboard. */
|
|
5
|
+
highlighted: boolean;
|
|
6
|
+
};
|
|
7
|
+
type BaseMenuLinkItemProps = ComponentProps<"a"> & {
|
|
8
|
+
/** Replaces the `<a>`, e.g. with your router's link component. */
|
|
9
|
+
render?: RenderProp<"a", MenuLinkItemState>;
|
|
10
|
+
/** The text used by keyboard text navigation. Defaults to the item's text. */
|
|
11
|
+
label?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Closes the menu when the link is clicked.
|
|
14
|
+
* @default false
|
|
15
|
+
*/
|
|
16
|
+
closeOnClick?: boolean;
|
|
17
|
+
};
|
|
18
|
+
/** A link in a menu. Renders an `<a>`, with `data-highlighted`. */
|
|
19
|
+
declare const BaseMenuLinkItem: ({ className, ...otherProps }: BaseMenuLinkItemProps) => import("react").JSX.Element;
|
|
20
|
+
export { BaseMenuLinkItem as default };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Menu } from "@base-ui/react/menu";
|
|
3
|
+
import { cn } from "cn";
|
|
4
|
+
import { menuItemClassNames } from "./menuItemStyles.js";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
// src/components/menu/BaseMenuLinkItem.tsx
|
|
7
|
+
/** A link in a menu. Renders an `<a>`, with `data-highlighted`. */
|
|
8
|
+
const BaseMenuLinkItem = ({ className, ...otherProps }) => /* @__PURE__ */ jsx(Menu.LinkItem, {
|
|
9
|
+
...otherProps,
|
|
10
|
+
className: cn(menuItemClassNames, className)
|
|
11
|
+
});
|
|
12
|
+
export { BaseMenuLinkItem as default };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { RenderProp } from "../../utils/render.js";
|
|
2
|
+
import { ComponentProps } from "react";
|
|
3
|
+
type BaseMenuListProps = ComponentProps<"div"> & {
|
|
4
|
+
render?: RenderProp<"div">;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Holds the items when the popup has other content too, like the search box of a `filterable` menu.
|
|
8
|
+
* Scrolls when the popup runs out of space. Renders a `<div>`.
|
|
9
|
+
*/
|
|
10
|
+
declare const BaseMenuList: ({ className, ...otherProps }: BaseMenuListProps) => import("react").JSX.Element;
|
|
11
|
+
export { BaseMenuList as default };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Menu } from "@base-ui/react/menu";
|
|
3
|
+
import { cn } from "cn";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
// src/components/menu/BaseMenuList.tsx
|
|
6
|
+
/**
|
|
7
|
+
* Holds the items when the popup has other content too, like the search box of a `filterable` menu.
|
|
8
|
+
* Scrolls when the popup runs out of space. Renders a `<div>`.
|
|
9
|
+
*/
|
|
10
|
+
const BaseMenuList = ({ className, ...otherProps }) => /* @__PURE__ */ jsx(Menu.List, {
|
|
11
|
+
...otherProps,
|
|
12
|
+
className: cn("min-h-0 flex-1 overflow-y-auto overscroll-contain", className)
|
|
13
|
+
});
|
|
14
|
+
export { BaseMenuList as default };
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { RenderProp } from "../../utils/render.js";
|
|
2
|
+
import { ComponentProps, RefObject } from "react";
|
|
3
|
+
export type MenuSide = "top" | "bottom" | "left" | "right" | "inline-start" | "inline-end";
|
|
4
|
+
export type MenuAlign = "start" | "center" | "end";
|
|
5
|
+
export type MenuPopupState = {
|
|
6
|
+
open: boolean;
|
|
7
|
+
side: MenuSide;
|
|
8
|
+
align: MenuAlign;
|
|
9
|
+
/** Whether the popup belongs to a submenu. */
|
|
10
|
+
nested: boolean;
|
|
11
|
+
};
|
|
12
|
+
export type MenuPositionerState = MenuPopupState & {
|
|
13
|
+
/** Whether the anchor is scrolled out of view. */
|
|
14
|
+
anchorHidden: boolean;
|
|
15
|
+
};
|
|
16
|
+
export type MenuBackdropState = {
|
|
17
|
+
open: boolean;
|
|
18
|
+
};
|
|
19
|
+
/** How the menu was closed. Empty when it's unknown. */
|
|
20
|
+
export type MenuInteractionType = "mouse" | "touch" | "pen" | "keyboard" | "";
|
|
21
|
+
/**
|
|
22
|
+
* - `true`: the default (the trigger, or the element focused before the menu opened).
|
|
23
|
+
* - `false`: don't move focus.
|
|
24
|
+
* - a ref: focus that element.
|
|
25
|
+
* - a function: return an element, `true` / `null` for the default, or `false` / `undefined` to not move focus.
|
|
26
|
+
*/
|
|
27
|
+
export type MenuFocusTarget = boolean | RefObject<HTMLElement | null> | ((interactionType: MenuInteractionType) => boolean | HTMLElement | null | void);
|
|
28
|
+
/** Computes an offset from the popup's placement and the sizes of the anchor and the popup. */
|
|
29
|
+
export type MenuOffsetFunction = (data: {
|
|
30
|
+
side: MenuSide;
|
|
31
|
+
align: MenuAlign;
|
|
32
|
+
anchor: {
|
|
33
|
+
width: number;
|
|
34
|
+
height: number;
|
|
35
|
+
};
|
|
36
|
+
positioner: {
|
|
37
|
+
width: number;
|
|
38
|
+
height: number;
|
|
39
|
+
};
|
|
40
|
+
}) => number;
|
|
41
|
+
/** How the popup avoids the edges of `collisionBoundary`. */
|
|
42
|
+
export type MenuCollisionAvoidance = {
|
|
43
|
+
side?: "flip" | "none";
|
|
44
|
+
align?: "flip" | "shift" | "none";
|
|
45
|
+
fallbackAxisSide?: "start" | "end" | "none";
|
|
46
|
+
} | {
|
|
47
|
+
side?: "shift" | "none";
|
|
48
|
+
align?: "shift" | "none";
|
|
49
|
+
fallbackAxisSide?: "start" | "end" | "none";
|
|
50
|
+
};
|
|
51
|
+
type Rect = {
|
|
52
|
+
x: number;
|
|
53
|
+
y: number;
|
|
54
|
+
width: number;
|
|
55
|
+
height: number;
|
|
56
|
+
};
|
|
57
|
+
type BaseMenuPopupProps = ComponentProps<"div"> & {
|
|
58
|
+
render?: RenderProp<"div", MenuPopupState>;
|
|
59
|
+
/** The side of the anchor the popup is placed on. It flips when there's no room. Submenus default to `"inline-end"`. */
|
|
60
|
+
side?: MenuSide;
|
|
61
|
+
/** How the popup is aligned to that side. Submenus default to `"start"`. */
|
|
62
|
+
align?: MenuAlign;
|
|
63
|
+
/** The gap between the anchor and the popup, in pixels, or a function of the placement and sizes. */
|
|
64
|
+
sideOffset?: number | MenuOffsetFunction;
|
|
65
|
+
/** Moves the popup along the anchor's side, in pixels, or a function of the placement and sizes. */
|
|
66
|
+
alignOffset?: number | MenuOffsetFunction;
|
|
67
|
+
/**
|
|
68
|
+
* The space kept between the popup and the edges of the viewport, in pixels.
|
|
69
|
+
* @default 5
|
|
70
|
+
*/
|
|
71
|
+
collisionPadding?: number | {
|
|
72
|
+
top?: number;
|
|
73
|
+
right?: number;
|
|
74
|
+
bottom?: number;
|
|
75
|
+
left?: number;
|
|
76
|
+
};
|
|
77
|
+
/** The area the popup stays inside. @default "clipping-ancestors" */
|
|
78
|
+
collisionBoundary?: "clipping-ancestors" | Element | Element[] | Rect;
|
|
79
|
+
collisionAvoidance?: MenuCollisionAvoidance;
|
|
80
|
+
/** The element the popup is placed against. Defaults to the trigger. */
|
|
81
|
+
anchor?: Element | RefObject<Element | null> | (() => Element | null) | null;
|
|
82
|
+
/** Stops following the anchor when it moves (e.g. on scroll). */
|
|
83
|
+
disableAnchorTracking?: boolean;
|
|
84
|
+
/**
|
|
85
|
+
* The minimum distance between an `Arrow` and the popup's corners, in pixels.
|
|
86
|
+
* @default 5
|
|
87
|
+
*/
|
|
88
|
+
arrowPadding?: number;
|
|
89
|
+
/** Keeps the popup in view while its anchor scrolls out of view. */
|
|
90
|
+
sticky?: boolean;
|
|
91
|
+
/**
|
|
92
|
+
* The CSS `position` of the positioner. Use `"fixed"` when the anchor is inside a fixed container.
|
|
93
|
+
* @default "absolute"
|
|
94
|
+
*/
|
|
95
|
+
positionMethod?: "absolute" | "fixed";
|
|
96
|
+
/** Classes for the positioner, the `<div>` around the popup that places it. */
|
|
97
|
+
positionerClassName?: string;
|
|
98
|
+
/** Style or replace the positioner. A `className` on the element wins over the kit's conflicting classes. */
|
|
99
|
+
renderPositioner?: RenderProp<"div", MenuPositionerState>;
|
|
100
|
+
/** The element focused when the menu closes. */
|
|
101
|
+
finalFocus?: MenuFocusTarget;
|
|
102
|
+
/** Where the popup is portaled to. Defaults to `<body>`. */
|
|
103
|
+
container?: HTMLElement | ShadowRoot | RefObject<HTMLElement | ShadowRoot | null> | null;
|
|
104
|
+
/** Keeps the popup in the DOM while the menu is closed. */
|
|
105
|
+
keepMounted?: boolean;
|
|
106
|
+
/** Renders a backdrop behind the popup. It is a transparent full-screen layer until you style it. */
|
|
107
|
+
backdrop?: boolean;
|
|
108
|
+
/** Style or replace the backdrop. A `className` on the element wins over the kit's conflicting classes. */
|
|
109
|
+
renderBackdrop?: RenderProp<"div", MenuBackdropState>;
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* The menu's popup, with its portal and positioner (and an optional backdrop).
|
|
113
|
+
* Renders a `<div>` with `data-side`, `data-align`, `data-open` / `data-closed` and transition attributes.
|
|
114
|
+
*/
|
|
115
|
+
declare const BaseMenuPopup: ({ side, align, sideOffset, alignOffset, collisionPadding, collisionBoundary, collisionAvoidance, anchor, disableAnchorTracking, arrowPadding, sticky, positionMethod, positionerClassName, renderPositioner, container, keepMounted, backdrop, renderBackdrop, className, ...otherProps }: BaseMenuPopupProps) => import("react").JSX.Element;
|
|
116
|
+
export { BaseMenuPopup as default };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Menu } from "@base-ui/react/menu";
|
|
3
|
+
import { cn } from "cn";
|
|
4
|
+
import { splitClassName } from "../../utils/split-class-name.js";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
// src/components/menu/BaseMenuPopup.tsx
|
|
7
|
+
/**
|
|
8
|
+
* The menu's popup, with its portal and positioner (and an optional backdrop).
|
|
9
|
+
* Renders a `<div>` with `data-side`, `data-align`, `data-open` / `data-closed` and transition attributes.
|
|
10
|
+
*/
|
|
11
|
+
const BaseMenuPopup = ({ side, align, sideOffset, alignOffset, collisionPadding, collisionBoundary, collisionAvoidance, anchor, disableAnchorTracking, arrowPadding, sticky, positionMethod, positionerClassName, renderPositioner, container, keepMounted, backdrop = false, renderBackdrop, className, ...otherProps }) => {
|
|
12
|
+
const backdropElement = splitClassName(renderBackdrop);
|
|
13
|
+
const positionerElement = splitClassName(renderPositioner);
|
|
14
|
+
return /* @__PURE__ */ jsxs(Menu.Portal, {
|
|
15
|
+
container,
|
|
16
|
+
keepMounted,
|
|
17
|
+
children: [backdrop && /* @__PURE__ */ jsx(Menu.Backdrop, {
|
|
18
|
+
render: backdropElement.render,
|
|
19
|
+
className: cn("fixed", "inset-0", backdropElement.className)
|
|
20
|
+
}), /* @__PURE__ */ jsx(Menu.Positioner, {
|
|
21
|
+
side,
|
|
22
|
+
align,
|
|
23
|
+
sideOffset,
|
|
24
|
+
alignOffset,
|
|
25
|
+
collisionPadding,
|
|
26
|
+
collisionBoundary,
|
|
27
|
+
collisionAvoidance,
|
|
28
|
+
anchor,
|
|
29
|
+
disableAnchorTracking,
|
|
30
|
+
arrowPadding,
|
|
31
|
+
sticky,
|
|
32
|
+
positionMethod,
|
|
33
|
+
render: positionerElement.render,
|
|
34
|
+
className: cn("z-50", "outline-hidden", positionerClassName, positionerElement.className),
|
|
35
|
+
children: /* @__PURE__ */ jsx(Menu.Popup, {
|
|
36
|
+
...otherProps,
|
|
37
|
+
className: cn("max-h-(--available-height)", "min-w-32", "origin-(--transform-origin)", "overflow-y-auto", "py-1", "outline-hidden", "transition-[scale,opacity]", "duration-100", "ease-out", "data-ending-style:scale-95", "data-ending-style:opacity-0", "data-starting-style:scale-95", "data-starting-style:opacity-0", className)
|
|
38
|
+
})
|
|
39
|
+
})]
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
export { BaseMenuPopup as default };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { RenderProp } from "../../utils/render.js";
|
|
2
|
+
import { ComponentProps } from "react";
|
|
3
|
+
export type MenuRadioGroupState = {
|
|
4
|
+
disabled: boolean;
|
|
5
|
+
};
|
|
6
|
+
type BaseMenuRadioGroupProps<Value = unknown> = Omit<ComponentProps<"div">, "defaultValue"> & {
|
|
7
|
+
render?: RenderProp<"div", MenuRadioGroupState>;
|
|
8
|
+
/** The value of the selected item (controlled). */
|
|
9
|
+
value?: Value;
|
|
10
|
+
/** The value of the item selected at first. */
|
|
11
|
+
defaultValue?: Value;
|
|
12
|
+
/** Called with the selected item's value and the DOM event that selected it. */
|
|
13
|
+
onValueChange?: (value: Value, event: Event) => void;
|
|
14
|
+
/** Ignores user interaction on every item. */
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
};
|
|
17
|
+
/** Groups `RadioItem`s, of which one is selected. Renders a `<div>` with `role="group"`. */
|
|
18
|
+
declare const BaseMenuRadioGroup: <Value>({ onValueChange, ...otherProps }: BaseMenuRadioGroupProps<Value>) => import("react").JSX.Element;
|
|
19
|
+
export { BaseMenuRadioGroup as default };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Menu } from "@base-ui/react/menu";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
// src/components/menu/BaseMenuRadioGroup.tsx
|
|
5
|
+
/** Groups `RadioItem`s, of which one is selected. Renders a `<div>` with `role="group"`. */
|
|
6
|
+
const BaseMenuRadioGroup = ({ onValueChange, ...otherProps }) => /* @__PURE__ */ jsx(Menu.RadioGroup, {
|
|
7
|
+
...otherProps,
|
|
8
|
+
onValueChange: onValueChange && ((value, details) => onValueChange(value, details.event))
|
|
9
|
+
});
|
|
10
|
+
export { BaseMenuRadioGroup as default };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { RenderProp } from "../../utils/render.js";
|
|
2
|
+
import { ComponentProps, ReactNode } from "react";
|
|
3
|
+
export type MenuRadioItemState = {
|
|
4
|
+
/** Whether the item is the selected one. */
|
|
5
|
+
checked: boolean;
|
|
6
|
+
disabled: boolean;
|
|
7
|
+
/** Whether the item is highlighted by the pointer or the keyboard. */
|
|
8
|
+
highlighted: boolean;
|
|
9
|
+
};
|
|
10
|
+
type BaseMenuRadioItemProps<Value = unknown> = ComponentProps<"div"> & {
|
|
11
|
+
/** The value the `RadioGroup` gets when this item is selected. */
|
|
12
|
+
value: Value;
|
|
13
|
+
render?: RenderProp<"div", MenuRadioItemState>;
|
|
14
|
+
/** Shown before the text when selected, e.g. a dot. */
|
|
15
|
+
indicator?: ReactNode;
|
|
16
|
+
renderIndicator?: RenderProp<"span", MenuRadioItemState>;
|
|
17
|
+
/** Keeps the indicator in the DOM when not selected, e.g. to animate it out with CSS. */
|
|
18
|
+
keepIndicatorMounted?: boolean;
|
|
19
|
+
/** Ignores user interaction. */
|
|
20
|
+
disabled?: boolean;
|
|
21
|
+
/** The text used by keyboard text navigation. Defaults to the item's text. */
|
|
22
|
+
label?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Closes the menu when the item is clicked.
|
|
25
|
+
* @default false
|
|
26
|
+
*/
|
|
27
|
+
closeOnClick?: boolean;
|
|
28
|
+
/** Set to `true` when `render` renders a `<button>`. */
|
|
29
|
+
nativeButton?: boolean;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* An option in a `RadioGroup`. Renders a `<div>` with `role="menuitemradio"`,
|
|
33
|
+
* `data-checked` / `data-unchecked`, `data-highlighted` and `data-disabled`.
|
|
34
|
+
*/
|
|
35
|
+
declare const BaseMenuRadioItem: <Value>({ indicator, renderIndicator, keepIndicatorMounted, className, children, ...otherProps }: BaseMenuRadioItemProps<Value>) => import("react").JSX.Element;
|
|
36
|
+
export { BaseMenuRadioItem as default };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Menu } from "@base-ui/react/menu";
|
|
3
|
+
import { cn } from "cn";
|
|
4
|
+
import { menuIndicatorClassNames, menuIndicatorItemClassNames, menuIndicatorLabelClassNames, menuItemClassNames } from "./menuItemStyles.js";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
// src/components/menu/BaseMenuRadioItem.tsx
|
|
7
|
+
/**
|
|
8
|
+
* An option in a `RadioGroup`. Renders a `<div>` with `role="menuitemradio"`,
|
|
9
|
+
* `data-checked` / `data-unchecked`, `data-highlighted` and `data-disabled`.
|
|
10
|
+
*/
|
|
11
|
+
const BaseMenuRadioItem = ({ indicator, renderIndicator, keepIndicatorMounted, className, children, ...otherProps }) => /* @__PURE__ */ jsxs(Menu.RadioItem, {
|
|
12
|
+
...otherProps,
|
|
13
|
+
className: cn(menuItemClassNames, menuIndicatorItemClassNames, className),
|
|
14
|
+
children: [/* @__PURE__ */ jsx(Menu.RadioItemIndicator, {
|
|
15
|
+
keepMounted: keepIndicatorMounted,
|
|
16
|
+
render: renderIndicator,
|
|
17
|
+
className: cn(menuIndicatorClassNames),
|
|
18
|
+
children: indicator
|
|
19
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
20
|
+
className: cn(menuIndicatorLabelClassNames),
|
|
21
|
+
children
|
|
22
|
+
})]
|
|
23
|
+
});
|
|
24
|
+
export { BaseMenuRadioItem as default };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { RenderProp } from "../../utils/render.js";
|
|
2
|
+
import { ComponentProps } from "react";
|
|
3
|
+
export type MenuSeparatorState = {
|
|
4
|
+
orientation: "horizontal" | "vertical";
|
|
5
|
+
};
|
|
6
|
+
type BaseMenuSeparatorProps = ComponentProps<"div"> & {
|
|
7
|
+
render?: RenderProp<"div", MenuSeparatorState>;
|
|
8
|
+
};
|
|
9
|
+
/** A line between items. Renders a `<div>` with `role="separator"`. Give it a color with `className`. */
|
|
10
|
+
declare const BaseMenuSeparator: ({ className, ...otherProps }: BaseMenuSeparatorProps) => import("react").JSX.Element;
|
|
11
|
+
export { BaseMenuSeparator as default };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Separator } from "@base-ui/react/separator";
|
|
3
|
+
import { cn } from "cn";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
// src/components/menu/BaseMenuSeparator.tsx
|
|
6
|
+
/** A line between items. Renders a `<div>` with `role="separator"`. Give it a color with `className`. */
|
|
7
|
+
const BaseMenuSeparator = ({ className, ...otherProps }) => /* @__PURE__ */ jsx(Separator, {
|
|
8
|
+
...otherProps,
|
|
9
|
+
className: cn("my-1", "h-px", className)
|
|
10
|
+
});
|
|
11
|
+
export { BaseMenuSeparator as default };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { MenuRootSharedProps } from "./menuTypes.js";
|
|
2
|
+
import { ReactNode } from "react";
|
|
3
|
+
type BaseMenuSubmenuProps = MenuRootSharedProps & {
|
|
4
|
+
/** Called with the new state and the DOM event that changed it (none when it was changed from code). */
|
|
5
|
+
onOpenChange?: (open: boolean, event: Event | undefined) => void;
|
|
6
|
+
/** Closes the whole menu on Escape, instead of only the submenu. */
|
|
7
|
+
closeParentOnEsc?: boolean;
|
|
8
|
+
/** A `SubmenuTrigger` and a `Popup`. */
|
|
9
|
+
children?: ReactNode;
|
|
10
|
+
};
|
|
11
|
+
/** Groups a submenu's trigger and popup. Put it among the items of a menu. Renders no element. */
|
|
12
|
+
declare const BaseMenuSubmenu: (props: BaseMenuSubmenuProps) => import("react").JSX.Element;
|
|
13
|
+
export { BaseMenuSubmenu as default };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Menu } from "@base-ui/react/menu";
|
|
3
|
+
import { splitFilterProps } from "./menuTypes.js";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
// src/components/menu/BaseMenuSubmenu.tsx
|
|
6
|
+
/** Groups a submenu's trigger and popup. Put it among the items of a menu. Renders no element. */
|
|
7
|
+
const BaseMenuSubmenu = (props) => {
|
|
8
|
+
const { filterProps, rootProps: { onOpenChange, onItemHighlighted, ...otherProps } } = splitFilterProps(props);
|
|
9
|
+
const root = /* @__PURE__ */ jsx(Menu.SubmenuRoot, {
|
|
10
|
+
...otherProps,
|
|
11
|
+
onOpenChange: onOpenChange && ((open, details) => onOpenChange(open, details.event)),
|
|
12
|
+
onItemHighlighted: onItemHighlighted && ((item, details) => onItemHighlighted(item, {
|
|
13
|
+
reason: details.reason,
|
|
14
|
+
label: details.label
|
|
15
|
+
}))
|
|
16
|
+
});
|
|
17
|
+
return filterProps ? /* @__PURE__ */ jsx(Menu.FilterProvider, {
|
|
18
|
+
...filterProps,
|
|
19
|
+
children: root
|
|
20
|
+
}) : root;
|
|
21
|
+
};
|
|
22
|
+
export { BaseMenuSubmenu as default };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { RenderProp } from "../../utils/render.js";
|
|
2
|
+
import { ComponentProps, ReactNode } from "react";
|
|
3
|
+
export type MenuSubmenuTriggerState = {
|
|
4
|
+
disabled: boolean;
|
|
5
|
+
/** Whether the item is highlighted by the pointer or the keyboard. */
|
|
6
|
+
highlighted: boolean;
|
|
7
|
+
/** Whether its submenu is open. */
|
|
8
|
+
open: boolean;
|
|
9
|
+
};
|
|
10
|
+
type BaseMenuSubmenuTriggerProps = ComponentProps<"div"> & {
|
|
11
|
+
render?: RenderProp<"div", MenuSubmenuTriggerState>;
|
|
12
|
+
/** Shown at the end of the item, e.g. a chevron. */
|
|
13
|
+
icon?: ReactNode;
|
|
14
|
+
/** Classes for the `<span>` around the icon. */
|
|
15
|
+
iconClassName?: string;
|
|
16
|
+
/** Ignores user interaction. */
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
/** The text used by keyboard text navigation. Defaults to the item's text. */
|
|
19
|
+
label?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Opens the submenu when the pointer rests on the item.
|
|
22
|
+
* @default true
|
|
23
|
+
*/
|
|
24
|
+
openOnHover?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* How long the pointer rests on the item before the submenu opens, in milliseconds.
|
|
27
|
+
* @default 100
|
|
28
|
+
*/
|
|
29
|
+
delay?: number;
|
|
30
|
+
/**
|
|
31
|
+
* How long the submenu stays open after the pointer leaves, in milliseconds.
|
|
32
|
+
* @default 0
|
|
33
|
+
*/
|
|
34
|
+
closeDelay?: number;
|
|
35
|
+
/** Set to `true` when `render` renders a `<button>`. */
|
|
36
|
+
nativeButton?: boolean;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* The item that opens a submenu. Put it inside a `Submenu`.
|
|
40
|
+
* Renders a `<div>` with `data-popup-open` while the submenu is open, `data-highlighted` and `data-disabled`.
|
|
41
|
+
*/
|
|
42
|
+
declare const BaseMenuSubmenuTrigger: ({ icon, iconClassName, className, children, ...otherProps }: BaseMenuSubmenuTriggerProps) => import("react").JSX.Element;
|
|
43
|
+
export { BaseMenuSubmenuTrigger as default };
|