All files / hooks/use-disclosure/src types.ts

0% Statements 0/0
0% Branches 0/0
0% Functions 0/0
0% Lines 0/0

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36                                                                       
/**
 * Optional lifecycle callbacks for {@link useDisclosure}.
 */
export interface UseDisclosureOptions {
  /**
   * Called when the state transitions from closed to **open** (via `open()`, or
   * `toggle()` while closed). Not called if it was already open.
   */
  onOpen?: () => void;
 
  /**
   * Called when the state transitions from open to **closed** (via `close()`, or
   * `toggle()` while open). Not called if it was already closed.
   */
  onClose?: () => void;
}
 
/**
 * The control handlers returned by {@link useDisclosure}. Each has a stable
 * identity across renders, so they are safe to pass as props or effect
 * dependencies.
 */
export interface UseDisclosureHandlers {
  /** Open (set to `true`). Fires `onOpen` only on a real closed → open change. */
  open: () => void;
  /** Close (set to `false`). Fires `onClose` only on a real open → closed change. */
  close: () => void;
  /** Flip the current state, firing the matching `onOpen` / `onClose`. */
  toggle: () => void;
}
 
/**
 * Return value of {@link useDisclosure}: a `[opened, handlers]` tuple.
 */
export type UseDisclosureReturn = readonly [boolean, UseDisclosureHandlers];