index.d.ts 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. import * as React from "react";
  2. import { DismissableLayer } from "@radix-ui/react-dismissable-layer";
  3. import { FocusScope } from "@radix-ui/react-focus-scope";
  4. import * as PopperPrimitive from "@radix-ui/react-popper";
  5. import { Portal as _Portal1 } from "@radix-ui/react-portal";
  6. import * as Radix from "@radix-ui/react-primitive";
  7. import { Primitive } from "@radix-ui/react-primitive";
  8. import * as RovingFocusGroup from "@radix-ui/react-roving-focus";
  9. type Direction = 'ltr' | 'rtl';
  10. export const createMenuScope: import("@radix-ui/react-context").CreateScope;
  11. export interface MenuProps {
  12. children?: React.ReactNode;
  13. open?: boolean;
  14. onOpenChange?(open: boolean): void;
  15. dir?: Direction;
  16. modal?: boolean;
  17. }
  18. export const Menu: React.FC<MenuProps>;
  19. type PopperAnchorProps = Radix.ComponentPropsWithoutRef<typeof PopperPrimitive.Anchor>;
  20. export interface MenuAnchorProps extends PopperAnchorProps {
  21. }
  22. export const MenuAnchor: React.ForwardRefExoticComponent<MenuAnchorProps & React.RefAttributes<HTMLDivElement>>;
  23. type PortalProps = React.ComponentPropsWithoutRef<typeof _Portal1>;
  24. export interface MenuPortalProps {
  25. children?: React.ReactNode;
  26. /**
  27. * Specify a container element to portal the content into.
  28. */
  29. container?: PortalProps['container'];
  30. /**
  31. * Used to force mounting when more control is needed. Useful when
  32. * controlling animation with React animation libraries.
  33. */
  34. forceMount?: true;
  35. }
  36. export const MenuPortal: React.FC<MenuPortalProps>;
  37. /**
  38. * We purposefully don't union MenuRootContent and MenuSubContent props here because
  39. * they have conflicting prop types. We agreed that we would allow MenuSubContent to
  40. * accept props that it would just ignore.
  41. */
  42. export interface MenuContentProps extends MenuRootContentTypeProps {
  43. /**
  44. * Used to force mounting when more control is needed. Useful when
  45. * controlling animation with React animation libraries.
  46. */
  47. forceMount?: true;
  48. }
  49. export const MenuContent: React.ForwardRefExoticComponent<MenuContentProps & React.RefAttributes<HTMLDivElement>>;
  50. interface MenuRootContentTypeProps extends Omit<MenuContentImplProps, keyof MenuContentImplPrivateProps> {
  51. }
  52. type FocusScopeProps = Radix.ComponentPropsWithoutRef<typeof FocusScope>;
  53. type DismissableLayerProps = Radix.ComponentPropsWithoutRef<typeof DismissableLayer>;
  54. type RovingFocusGroupProps = Radix.ComponentPropsWithoutRef<typeof RovingFocusGroup.Root>;
  55. type PopperContentProps = Radix.ComponentPropsWithoutRef<typeof PopperPrimitive.Content>;
  56. type MenuContentImplPrivateProps = {
  57. onOpenAutoFocus?: FocusScopeProps['onMountAutoFocus'];
  58. onDismiss?: DismissableLayerProps['onDismiss'];
  59. disableOutsidePointerEvents?: DismissableLayerProps['disableOutsidePointerEvents'];
  60. /**
  61. * Whether scrolling outside the `MenuContent` should be prevented
  62. * (default: `false`)
  63. */
  64. disableOutsideScroll?: boolean;
  65. /**
  66. * Whether focus should be trapped within the `MenuContent`
  67. * (default: false)
  68. */
  69. trapFocus?: FocusScopeProps['trapped'];
  70. };
  71. interface MenuContentImplProps extends MenuContentImplPrivateProps, Omit<PopperContentProps, 'dir' | 'onPlaced'> {
  72. /**
  73. * Event handler called when auto-focusing on close.
  74. * Can be prevented.
  75. */
  76. onCloseAutoFocus?: FocusScopeProps['onUnmountAutoFocus'];
  77. /**
  78. * Whether keyboard navigation should loop around
  79. * @defaultValue false
  80. */
  81. loop?: RovingFocusGroupProps['loop'];
  82. onEntryFocus?: RovingFocusGroupProps['onEntryFocus'];
  83. onEscapeKeyDown?: DismissableLayerProps['onEscapeKeyDown'];
  84. onPointerDownOutside?: DismissableLayerProps['onPointerDownOutside'];
  85. onFocusOutside?: DismissableLayerProps['onFocusOutside'];
  86. onInteractOutside?: DismissableLayerProps['onInteractOutside'];
  87. }
  88. type PrimitiveDivProps = Radix.ComponentPropsWithoutRef<typeof Primitive.div>;
  89. export interface MenuGroupProps extends PrimitiveDivProps {
  90. }
  91. export const MenuGroup: React.ForwardRefExoticComponent<MenuGroupProps & React.RefAttributes<HTMLDivElement>>;
  92. export interface MenuLabelProps extends PrimitiveDivProps {
  93. }
  94. export const MenuLabel: React.ForwardRefExoticComponent<MenuLabelProps & React.RefAttributes<HTMLDivElement>>;
  95. export interface MenuItemProps extends Omit<MenuItemImplProps, 'onSelect'> {
  96. onSelect?: (event: Event) => void;
  97. }
  98. export const MenuItem: React.ForwardRefExoticComponent<MenuItemProps & React.RefAttributes<HTMLDivElement>>;
  99. interface MenuItemImplProps extends PrimitiveDivProps {
  100. disabled?: boolean;
  101. textValue?: string;
  102. }
  103. type CheckedState = boolean | 'indeterminate';
  104. export interface MenuCheckboxItemProps extends MenuItemProps {
  105. checked?: CheckedState;
  106. onCheckedChange?: (checked: boolean) => void;
  107. }
  108. export const MenuCheckboxItem: React.ForwardRefExoticComponent<MenuCheckboxItemProps & React.RefAttributes<HTMLDivElement>>;
  109. export interface MenuRadioGroupProps extends MenuGroupProps {
  110. value?: string;
  111. onValueChange?: (value: string) => void;
  112. }
  113. export const MenuRadioGroup: React.ForwardRefExoticComponent<MenuRadioGroupProps & React.RefAttributes<HTMLDivElement>>;
  114. export interface MenuRadioItemProps extends MenuItemProps {
  115. value: string;
  116. }
  117. export const MenuRadioItem: React.ForwardRefExoticComponent<MenuRadioItemProps & React.RefAttributes<HTMLDivElement>>;
  118. type PrimitiveSpanProps = Radix.ComponentPropsWithoutRef<typeof Primitive.span>;
  119. export interface MenuItemIndicatorProps extends PrimitiveSpanProps {
  120. /**
  121. * Used to force mounting when more control is needed. Useful when
  122. * controlling animation with React animation libraries.
  123. */
  124. forceMount?: true;
  125. }
  126. export const MenuItemIndicator: React.ForwardRefExoticComponent<MenuItemIndicatorProps & React.RefAttributes<HTMLSpanElement>>;
  127. export interface MenuSeparatorProps extends PrimitiveDivProps {
  128. }
  129. export const MenuSeparator: React.ForwardRefExoticComponent<MenuSeparatorProps & React.RefAttributes<HTMLDivElement>>;
  130. type PopperArrowProps = Radix.ComponentPropsWithoutRef<typeof PopperPrimitive.Arrow>;
  131. export interface MenuArrowProps extends PopperArrowProps {
  132. }
  133. export const MenuArrow: React.ForwardRefExoticComponent<MenuArrowProps & React.RefAttributes<SVGSVGElement>>;
  134. export interface MenuSubProps {
  135. children?: React.ReactNode;
  136. open?: boolean;
  137. onOpenChange?(open: boolean): void;
  138. }
  139. export const MenuSub: React.FC<MenuSubProps>;
  140. export interface MenuSubTriggerProps extends MenuItemImplProps {
  141. }
  142. export const MenuSubTrigger: React.ForwardRefExoticComponent<MenuSubTriggerProps & React.RefAttributes<HTMLDivElement>>;
  143. export interface MenuSubContentProps extends Omit<MenuContentImplProps, keyof MenuContentImplPrivateProps | 'onCloseAutoFocus' | 'onEntryFocus' | 'side' | 'align'> {
  144. /**
  145. * Used to force mounting when more control is needed. Useful when
  146. * controlling animation with React animation libraries.
  147. */
  148. forceMount?: true;
  149. }
  150. export const MenuSubContent: React.ForwardRefExoticComponent<MenuSubContentProps & React.RefAttributes<HTMLDivElement>>;
  151. export const Root: React.FC<MenuProps>;
  152. export const Anchor: React.ForwardRefExoticComponent<MenuAnchorProps & React.RefAttributes<HTMLDivElement>>;
  153. export const Portal: React.FC<MenuPortalProps>;
  154. export const Content: React.ForwardRefExoticComponent<MenuContentProps & React.RefAttributes<HTMLDivElement>>;
  155. export const Group: React.ForwardRefExoticComponent<MenuGroupProps & React.RefAttributes<HTMLDivElement>>;
  156. export const Label: React.ForwardRefExoticComponent<MenuLabelProps & React.RefAttributes<HTMLDivElement>>;
  157. export const Item: React.ForwardRefExoticComponent<MenuItemProps & React.RefAttributes<HTMLDivElement>>;
  158. export const CheckboxItem: React.ForwardRefExoticComponent<MenuCheckboxItemProps & React.RefAttributes<HTMLDivElement>>;
  159. export const RadioGroup: React.ForwardRefExoticComponent<MenuRadioGroupProps & React.RefAttributes<HTMLDivElement>>;
  160. export const RadioItem: React.ForwardRefExoticComponent<MenuRadioItemProps & React.RefAttributes<HTMLDivElement>>;
  161. export const ItemIndicator: React.ForwardRefExoticComponent<MenuItemIndicatorProps & React.RefAttributes<HTMLSpanElement>>;
  162. export const Separator: React.ForwardRefExoticComponent<MenuSeparatorProps & React.RefAttributes<HTMLDivElement>>;
  163. export const Arrow: React.ForwardRefExoticComponent<MenuArrowProps & React.RefAttributes<SVGSVGElement>>;
  164. export const Sub: React.FC<MenuSubProps>;
  165. export const SubTrigger: React.ForwardRefExoticComponent<MenuSubTriggerProps & React.RefAttributes<HTMLDivElement>>;
  166. export const SubContent: React.ForwardRefExoticComponent<MenuSubContentProps & React.RefAttributes<HTMLDivElement>>;
  167. //# sourceMappingURL=index.d.ts.map