Initial commit

This commit is contained in:
Igor Martyniuk
2026-06-25 15:53:49 +03:00
commit 1bb0b7e68a
1517 changed files with 218469 additions and 0 deletions
@@ -0,0 +1,54 @@
# useDisclosure
Manages a boolean open/closed state — useful for modals, drawers, dropdowns, and any show/hide UI pattern.
## Signature
```ts
function useDisclosure(initial?: boolean): UseDisclosureControl;
```
| Parameter | Type | Default | Description |
| --------- | --------- | ------- | ------------------------- |
| `initial` | `boolean` | `false` | Initial open/closed state |
### Returns
```ts
interface UseDisclosureControl {
isOpen: boolean;
open: () => void;
close: () => void;
toggle: () => void;
}
```
| Property | Type | Description |
| -------- | ------------ | ------------------------- |
| `isOpen` | `boolean` | Current open/closed state |
| `open` | `() => void` | Sets `isOpen` to `true` |
| `close` | `() => void` | Sets `isOpen` to `false` |
| `toggle` | `() => void` | Flips the current state |
## Usage
```tsx
function ConfirmDialog() {
const { isOpen, open, close } = useDisclosure();
return (
<>
<button onClick={open}>Delete account</button>
<Dialog open={isOpen} onClose={close}>
<p>Are you sure?</p>
<button onClick={close}>Cancel</button>
</Dialog>
</>
);
}
```
## Notes
- `open`, `close`, and `toggle` are stable references (`useCallback`) and safe to pass as props without causing unnecessary re-renders.
- Client-only (`'use client'`).