

Custom hook that handles clicks outside a specified element.

## Usage [#usage]

```tsx
import { useOnClickOutside } from "@tilt-legal/cubitt-components/utilities/hooks";

const containerRef = useRef(null);
useOnClickOutside([containerRef], () => {
  // Handle clicks outside the container.
});
```

## API [#api]

### Signature [#signature]

```ts
declare function useOnClickOutside<T extends HTMLElement = HTMLElement>(ref: RefObject<T> | RefObject<T>[], handler: (event: MouseEvent | TouchEvent | FocusEvent) => void, eventType?: EventType, eventListenerOptions?: AddEventListenerOptions): void;
```

### Parameters [#parameters]

| Parameter                | Type                       | Description                                                                  | Default                                                                          |                                                                               |   |
| ------------------------ | -------------------------- | ---------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | ----------------------------------------------------------------------------- | - |
| `ref`                    | \`RefObject\<T>            | RefObject\<T>\[]\`                                                           | The React ref object(s) representing the element(s) to watch for outside clicks. | -                                                                             |   |
| `handler`                | \`(event: MouseEvent       | TouchEvent                                                                   | FocusEvent) => void\`                                                            | The callback function to be executed when a click outside the element occurs. | - |
| `[eventType]`            | `EventType`                | The mouse event type to listen for (optional, default is 'mousedown').       | -                                                                                |                                                                               |   |
| `[eventListenerOptions]` | `?AddEventListenerOptions` | The options object to be passed to the `addEventListener` method (optional). | -                                                                                |                                                                               |   |

### Return Value [#return-value]

| Value    | Type   | Description                 |
| -------- | ------ | --------------------------- |
| `return` | `void` | Value returned by the hook. |
