index.d.ts 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. import React from "react";
  2. import * as Radix from "@radix-ui/react-primitive";
  3. import { Primitive } from "@radix-ui/react-primitive";
  4. import * as RovingFocusGroup from "@radix-ui/react-roving-focus";
  5. import { Toggle } from "@radix-ui/react-toggle";
  6. export const createToggleGroupScope: import("@radix-ui/react-context").CreateScope;
  7. export interface ToggleGroupSingleProps extends ToggleGroupImplSingleProps {
  8. type: 'single';
  9. }
  10. export interface ToggleGroupMultipleProps extends ToggleGroupImplMultipleProps {
  11. type: 'multiple';
  12. }
  13. export const ToggleGroup: React.ForwardRefExoticComponent<(ToggleGroupSingleProps | ToggleGroupMultipleProps) & React.RefAttributes<HTMLDivElement>>;
  14. interface ToggleGroupImplSingleProps extends ToggleGroupImplProps {
  15. /**
  16. * The controlled stateful value of the item that is pressed.
  17. */
  18. value?: string;
  19. /**
  20. * The value of the item that is pressed when initially rendered. Use
  21. * `defaultValue` if you do not need to control the state of a toggle group.
  22. */
  23. defaultValue?: string;
  24. /**
  25. * The callback that fires when the value of the toggle group changes.
  26. */
  27. onValueChange?(value: string): void;
  28. }
  29. interface ToggleGroupImplMultipleProps extends ToggleGroupImplProps {
  30. /**
  31. * The controlled stateful value of the items that are pressed.
  32. */
  33. value?: string[];
  34. /**
  35. * The value of the items that are pressed when initially rendered. Use
  36. * `defaultValue` if you do not need to control the state of a toggle group.
  37. */
  38. defaultValue?: string[];
  39. /**
  40. * The callback that fires when the state of the toggle group changes.
  41. */
  42. onValueChange?(value: string[]): void;
  43. }
  44. type RovingFocusGroupProps = Radix.ComponentPropsWithoutRef<typeof RovingFocusGroup.Root>;
  45. type PrimitiveDivProps = Radix.ComponentPropsWithoutRef<typeof Primitive.div>;
  46. interface ToggleGroupImplProps extends PrimitiveDivProps {
  47. /**
  48. * Whether the group is disabled from user interaction.
  49. * @defaultValue false
  50. */
  51. disabled?: boolean;
  52. /**
  53. * Whether the group should maintain roving focus of its buttons.
  54. * @defaultValue true
  55. */
  56. rovingFocus?: boolean;
  57. loop?: RovingFocusGroupProps['loop'];
  58. orientation?: RovingFocusGroupProps['orientation'];
  59. dir?: RovingFocusGroupProps['dir'];
  60. }
  61. export interface ToggleGroupItemProps extends Omit<ToggleGroupItemImplProps, 'pressed'> {
  62. }
  63. export const ToggleGroupItem: React.ForwardRefExoticComponent<ToggleGroupItemProps & React.RefAttributes<HTMLButtonElement>>;
  64. type ToggleProps = Radix.ComponentPropsWithoutRef<typeof Toggle>;
  65. interface ToggleGroupItemImplProps extends Omit<ToggleProps, 'defaultPressed' | 'onPressedChange'> {
  66. /**
  67. * A string value for the toggle group item. All items within a toggle group should use a unique value.
  68. */
  69. value: string;
  70. }
  71. export const Root: React.ForwardRefExoticComponent<(ToggleGroupSingleProps | ToggleGroupMultipleProps) & React.RefAttributes<HTMLDivElement>>;
  72. export const Item: React.ForwardRefExoticComponent<ToggleGroupItemProps & React.RefAttributes<HTMLButtonElement>>;
  73. //# sourceMappingURL=index.d.ts.map