@boxcustodia/library 2.0.0-alpha.19 → 2.0.0-alpha.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (265) hide show
  1. package/dist/components/button/button.cjs.js +1 -1
  2. package/dist/components/button/button.es.js +19 -18
  3. package/dist/components/button/components/base-button.cjs.js +1 -1
  4. package/dist/components/button/components/base-button.es.js +20 -20
  5. package/dist/components/calendar/calendar.cjs.js +1 -1
  6. package/dist/components/calendar/calendar.es.js +1 -0
  7. package/dist/components/date-picker/date-input.cjs.js +1 -1
  8. package/dist/components/date-picker/date-input.es.js +92 -75
  9. package/dist/components/date-picker/date-picker.cjs.js +1 -1
  10. package/dist/components/date-picker/date-picker.es.js +104 -95
  11. package/dist/components/date-picker/date-picker.utils.cjs.js +1 -1
  12. package/dist/components/date-picker/date-picker.utils.es.js +51 -43
  13. package/dist/components/date-picker/use-hidden-field-value.cjs.js +1 -0
  14. package/dist/components/date-picker/use-hidden-field-value.es.js +11 -0
  15. package/dist/components/menu/menu.es.js +1 -9
  16. package/dist/components/otp/otp.cjs.js +2 -0
  17. package/dist/components/otp/otp.es.js +93 -0
  18. package/dist/components/password/password.cjs.js +1 -1
  19. package/dist/components/password/password.es.js +2 -2
  20. package/dist/components/select/select.cjs.js +1 -1
  21. package/dist/components/select/select.es.js +68 -60
  22. package/dist/hooks/internal/is-apple-device.cjs.js +1 -0
  23. package/dist/hooks/internal/is-apple-device.es.js +9 -0
  24. package/dist/hooks/internal/use-latest-ref.cjs.js +1 -0
  25. package/dist/hooks/internal/use-latest-ref.es.js +11 -0
  26. package/dist/hooks/use-array/use-array.cjs.js +1 -1
  27. package/dist/hooks/use-array/use-array.es.js +54 -42
  28. package/dist/hooks/use-async/use-async.cjs.js +1 -1
  29. package/dist/hooks/use-async/use-async.es.js +53 -20
  30. package/dist/hooks/use-boolean/use-boolean.cjs.js +1 -0
  31. package/dist/hooks/use-boolean/use-boolean.es.js +25 -0
  32. package/dist/hooks/use-click-outside/use-click-outside.cjs.js +1 -1
  33. package/dist/hooks/use-click-outside/use-click-outside.es.js +26 -12
  34. package/dist/hooks/use-debounce-callback/use-debounced-callback.cjs.js +1 -1
  35. package/dist/hooks/use-debounce-callback/use-debounced-callback.es.js +27 -10
  36. package/dist/hooks/use-debounce-value/use-debounced-value.cjs.js +1 -1
  37. package/dist/hooks/use-debounce-value/use-debounced-value.es.js +7 -9
  38. package/dist/hooks/use-disclosure/use-disclosure.cjs.js +1 -1
  39. package/dist/hooks/use-disclosure/use-disclosure.es.js +21 -11
  40. package/dist/hooks/use-document-title/use-document-title.cjs.js +1 -1
  41. package/dist/hooks/use-document-title/use-document-title.es.js +14 -12
  42. package/dist/hooks/use-event-listener/use-event-listener.cjs.js +1 -1
  43. package/dist/hooks/use-event-listener/use-event-listener.es.js +17 -9
  44. package/dist/hooks/use-hotkey/use-hotkey.cjs.js +1 -1
  45. package/dist/hooks/use-hotkey/use-hotkey.es.js +30 -14
  46. package/dist/hooks/use-hotkey/utils/is-input-field.cjs.js +1 -1
  47. package/dist/hooks/use-hotkey/utils/is-input-field.es.js +4 -2
  48. package/dist/hooks/use-hotkey/utils/match-and-run.cjs.js +1 -0
  49. package/dist/hooks/use-hotkey/utils/match-and-run.es.js +12 -0
  50. package/dist/hooks/use-hotkey/utils/match-key-modifiers.cjs.js +1 -1
  51. package/dist/hooks/use-hotkey/utils/match-key-modifiers.es.js +13 -12
  52. package/dist/hooks/use-hover/use-hover.cjs.js +1 -1
  53. package/dist/hooks/use-hover/use-hover.es.js +32 -17
  54. package/dist/hooks/use-is-visible/use-is-visible.cjs.js +1 -1
  55. package/dist/hooks/use-is-visible/use-is-visible.es.js +31 -27
  56. package/dist/hooks/use-local-storage/use-local-storage.cjs.js +1 -1
  57. package/dist/hooks/use-local-storage/use-local-storage.es.js +52 -20
  58. package/dist/hooks/use-media-query/use-media-query.cjs.js +1 -1
  59. package/dist/hooks/use-media-query/use-media-query.es.js +21 -11
  60. package/dist/hooks/use-mutation/use-mutation.cjs.js +1 -1
  61. package/dist/hooks/use-mutation/use-mutation.es.js +36 -22
  62. package/dist/hooks/use-object/use-object.cjs.js +1 -1
  63. package/dist/hooks/use-object/use-object.es.js +26 -22
  64. package/dist/hooks/use-prevent-page-close/use-prevent-page-close.cjs.js +1 -0
  65. package/dist/hooks/use-prevent-page-close/use-prevent-page-close.es.js +14 -0
  66. package/dist/hooks/use-step/use-step.cjs.js +1 -1
  67. package/dist/hooks/use-step/use-step.es.js +25 -24
  68. package/dist/index.cjs.js +1 -1
  69. package/dist/index.es.js +308 -300
  70. package/dist/src/components/date-picker/date-picker.utils.d.ts +17 -0
  71. package/dist/src/components/date-picker/use-hidden-field-value.d.ts +12 -0
  72. package/dist/src/components/index.d.ts +1 -0
  73. package/dist/src/hooks/index.d.ts +2 -2
  74. package/dist/src/hooks/internal/index.d.ts +2 -0
  75. package/dist/src/hooks/internal/is-apple-device.d.ts +12 -0
  76. package/dist/src/hooks/internal/use-latest-ref.d.ts +12 -0
  77. package/dist/src/hooks/use-array/use-array.d.ts +24 -11
  78. package/dist/src/hooks/use-async/use-async.d.ts +16 -13
  79. package/dist/src/hooks/use-boolean/index.d.ts +1 -0
  80. package/dist/src/hooks/use-boolean/use-boolean.d.ts +15 -0
  81. package/dist/src/hooks/use-boolean/use-boolean.test.d.ts +1 -0
  82. package/dist/src/hooks/use-click-outside/use-click-outside.d.ts +23 -1
  83. package/dist/src/hooks/use-debounce-callback/use-debounced-callback.d.ts +19 -1
  84. package/dist/src/hooks/use-debounce-value/use-debounced-value.d.ts +10 -1
  85. package/dist/src/hooks/use-disclosure/use-disclosure.d.ts +17 -8
  86. package/dist/src/hooks/use-document-title/use-document-title.d.ts +11 -0
  87. package/dist/src/hooks/use-event-listener/use-event-listener.d.ts +18 -1
  88. package/dist/src/hooks/use-hotkey/index.d.ts +2 -1
  89. package/dist/src/hooks/use-hotkey/use-hotkey.d.ts +62 -5
  90. package/dist/src/hooks/use-hotkey/utils/index.d.ts +4 -3
  91. package/dist/src/hooks/use-hotkey/utils/is-input-field.d.ts +12 -2
  92. package/dist/src/hooks/use-hotkey/utils/is-input-field.test.d.ts +1 -0
  93. package/dist/src/hooks/use-hotkey/utils/match-and-run.d.ts +36 -0
  94. package/dist/src/hooks/use-hotkey/utils/match-and-run.test.d.ts +1 -0
  95. package/dist/src/hooks/use-hotkey/utils/match-key-modifiers.d.ts +20 -6
  96. package/dist/src/hooks/use-hotkey/utils/match-key-modifiers.test.d.ts +1 -0
  97. package/dist/src/hooks/use-hover/use-hover.d.ts +8 -4
  98. package/dist/src/hooks/use-is-visible/use-is-visible.d.ts +28 -4
  99. package/dist/src/hooks/use-local-storage/use-local-storage.d.ts +13 -2
  100. package/dist/src/hooks/use-media-query/use-media-query.d.ts +10 -1
  101. package/dist/src/hooks/use-media-query/use-media-query.test.d.ts +1 -0
  102. package/dist/src/hooks/use-mutation/use-mutation.d.ts +18 -11
  103. package/dist/src/hooks/use-object/use-object.d.ts +15 -6
  104. package/dist/src/hooks/use-prevent-page-close/index.d.ts +1 -0
  105. package/dist/src/hooks/use-prevent-page-close/use-prevent-page-close.d.ts +10 -0
  106. package/dist/src/hooks/use-prevent-page-close/use-prevent-page-close.test.d.ts +1 -0
  107. package/dist/src/hooks/use-step/use-step.d.ts +18 -11
  108. package/dist/src/utils/form.d.ts +10 -0
  109. package/package.json +1 -1
  110. package/src/components/alert-dialog/alert-dialog.test.tsx +13 -9
  111. package/src/components/auto-complete/auto-complete.test.tsx +4 -14
  112. package/src/components/avatar/avatar.test.tsx +7 -12
  113. package/src/components/button/button.test.tsx +10 -15
  114. package/src/components/button/button.tsx +14 -9
  115. package/src/components/button/components/base-button.tsx +2 -4
  116. package/src/components/calendar/calendar.test.tsx +12 -19
  117. package/src/components/calendar/calendar.tsx +4 -0
  118. package/src/components/card/card.test.tsx +4 -6
  119. package/src/components/checkbox/checkbox.test.tsx +12 -8
  120. package/src/components/checkbox-group/checkbox-group.test.tsx +7 -8
  121. package/src/components/combobox/combobox.test.tsx +24 -21
  122. package/src/components/date-picker/date-input-form.test.tsx +77 -0
  123. package/src/components/date-picker/date-input.stories.tsx +30 -18
  124. package/src/components/date-picker/date-input.tsx +77 -44
  125. package/src/components/date-picker/date-picker.stories.tsx +31 -1
  126. package/src/components/date-picker/date-picker.test.tsx +3 -13
  127. package/src/components/date-picker/date-picker.tsx +35 -16
  128. package/src/components/date-picker/date-picker.utils.test.ts +32 -14
  129. package/src/components/date-picker/date-picker.utils.ts +33 -0
  130. package/src/components/date-picker/use-date-input-popover.test.ts +3 -1
  131. package/src/components/date-picker/use-hidden-field-value.ts +23 -0
  132. package/src/components/dialog/dialog.test.tsx +10 -8
  133. package/src/components/dropzone/dropzone.test.tsx +11 -13
  134. package/src/components/empty/empty.test.tsx +4 -3
  135. package/src/components/field/field.test.tsx +12 -13
  136. package/src/components/form/form.stories.tsx +16 -1
  137. package/src/components/index.ts +1 -0
  138. package/src/components/label/label.test.tsx +3 -3
  139. package/src/components/menu/menu.tsx +1 -5
  140. package/src/components/number-input/number-input.test.tsx +6 -2
  141. package/src/components/password/password.test.tsx +20 -6
  142. package/src/components/password/password.tsx +2 -2
  143. package/src/components/popover/popover.test.tsx +4 -4
  144. package/src/components/progress/progress.test.tsx +7 -8
  145. package/src/components/radio-group/radio-group.test.tsx +17 -11
  146. package/src/components/select/select.test.tsx +10 -10
  147. package/src/components/select/select.tsx +9 -1
  148. package/src/components/stepper/stepper.stories.tsx +11 -15
  149. package/src/components/stepper/stepper.test.tsx +6 -4
  150. package/src/components/switch/switch.test.tsx +3 -3
  151. package/src/components/table/table.test.tsx +9 -3
  152. package/src/components/tabs/tabs.test.tsx +6 -2
  153. package/src/components/tag/tag.test.tsx +1 -3
  154. package/src/components/textarea/textarea.test.tsx +4 -1
  155. package/src/components/timeline/timeline.test.tsx +10 -5
  156. package/src/components/toast/toast.test.tsx +11 -14
  157. package/src/components/tooltip/tooltip.test.tsx +1 -5
  158. package/src/components/tree/tree.test.tsx +3 -1
  159. package/src/hooks/index.ts +2 -2
  160. package/src/hooks/internal/index.ts +2 -0
  161. package/src/hooks/internal/is-apple-device.test.ts +41 -0
  162. package/src/hooks/internal/is-apple-device.ts +33 -0
  163. package/src/hooks/internal/use-isomorphic-layout-effect.ts +3 -1
  164. package/src/hooks/internal/use-latest-ref.ts +21 -0
  165. package/src/hooks/use-array/use-array.stories.tsx +435 -64
  166. package/src/hooks/use-array/use-array.test.tsx +398 -15
  167. package/src/hooks/use-array/use-array.ts +105 -66
  168. package/src/hooks/use-async/use-async.stories.tsx +255 -131
  169. package/src/hooks/use-async/use-async.test.ts +397 -0
  170. package/src/hooks/use-async/use-async.ts +117 -39
  171. package/src/hooks/use-boolean/index.ts +1 -0
  172. package/src/hooks/use-boolean/use-boolean.stories.tsx +377 -0
  173. package/src/hooks/use-boolean/use-boolean.test.tsx +177 -0
  174. package/src/hooks/use-boolean/use-boolean.ts +50 -0
  175. package/src/hooks/use-click-outside/use-click-outside.stories.tsx +188 -18
  176. package/src/hooks/use-click-outside/use-click-outside.test.tsx +89 -10
  177. package/src/hooks/use-click-outside/use-click-outside.ts +62 -16
  178. package/src/hooks/use-debounce-callback/use-debounced-callback.stories.tsx +141 -41
  179. package/src/hooks/use-debounce-callback/use-debounced-callback.test.ts +217 -9
  180. package/src/hooks/use-debounce-callback/use-debounced-callback.ts +71 -11
  181. package/src/hooks/use-debounce-value/use-debounced-value.stories.tsx +247 -47
  182. package/src/hooks/use-debounce-value/use-debounced-value.test.ts +105 -10
  183. package/src/hooks/use-debounce-value/use-debounced-value.ts +19 -10
  184. package/src/hooks/use-disclosure/use-disclosure.stories.tsx +305 -14
  185. package/src/hooks/use-disclosure/use-disclosure.test.ts +198 -50
  186. package/src/hooks/use-disclosure/use-disclosure.ts +49 -29
  187. package/src/hooks/use-document-title/use-document-title.stories.tsx +54 -0
  188. package/src/hooks/use-document-title/use-document-title.test.tsx +26 -0
  189. package/src/hooks/use-document-title/{use-document-title.tsx → use-document-title.ts} +17 -3
  190. package/src/hooks/use-event-listener/use-event-listener.stories.tsx +105 -9
  191. package/src/hooks/use-event-listener/use-event-listener.test.tsx +77 -10
  192. package/src/hooks/use-event-listener/use-event-listener.ts +71 -11
  193. package/src/hooks/use-focus-trap/use-focus-trap.test.ts +31 -6
  194. package/src/hooks/use-focus-trap/use-focus-trap.ts +3 -2
  195. package/src/hooks/use-hotkey/index.ts +9 -1
  196. package/src/hooks/use-hotkey/use-hotkey.stories.tsx +279 -74
  197. package/src/hooks/use-hotkey/use-hotkey.test.tsx +286 -34
  198. package/src/hooks/use-hotkey/use-hotkey.ts +141 -17
  199. package/src/hooks/use-hotkey/utils/index.ts +8 -3
  200. package/src/hooks/use-hotkey/utils/is-input-field.test.ts +78 -0
  201. package/src/hooks/use-hotkey/utils/is-input-field.ts +31 -10
  202. package/src/hooks/use-hotkey/utils/match-and-run.test.ts +203 -0
  203. package/src/hooks/use-hotkey/utils/match-and-run.ts +62 -0
  204. package/src/hooks/use-hotkey/utils/match-key-modifiers.test.ts +65 -0
  205. package/src/hooks/use-hotkey/utils/match-key-modifiers.ts +39 -12
  206. package/src/hooks/use-hover/use-hover.stories.tsx +258 -80
  207. package/src/hooks/use-hover/use-hover.test.tsx +266 -26
  208. package/src/hooks/use-hover/use-hover.tsx +93 -28
  209. package/src/hooks/use-is-visible/use-is-visible.stories.tsx +193 -46
  210. package/src/hooks/use-is-visible/use-is-visible.test.tsx +235 -7
  211. package/src/hooks/use-is-visible/use-is-visible.ts +114 -0
  212. package/src/hooks/use-local-storage/use-local-storage.stories.tsx +129 -29
  213. package/src/hooks/use-local-storage/use-local-storage.test.ts +106 -41
  214. package/src/hooks/use-local-storage/use-local-storage.ts +100 -31
  215. package/src/hooks/use-media-query/use-media-query.stories.tsx +86 -26
  216. package/src/hooks/use-media-query/use-media-query.test.ts +132 -0
  217. package/src/hooks/use-media-query/use-media-query.ts +39 -14
  218. package/src/hooks/use-memoized-fn/use-memoized-fn.ts +0 -1
  219. package/src/hooks/use-mutation/use-mutation.stories.tsx +260 -94
  220. package/src/hooks/use-mutation/use-mutation.test.ts +359 -0
  221. package/src/hooks/use-mutation/use-mutation.ts +97 -0
  222. package/src/hooks/use-object/use-object.stories.tsx +310 -79
  223. package/src/hooks/use-object/use-object.test.tsx +235 -56
  224. package/src/hooks/use-object/use-object.ts +59 -0
  225. package/src/hooks/use-pagination/use-pagination.tsx +0 -1
  226. package/src/hooks/use-prevent-page-close/index.ts +1 -0
  227. package/src/hooks/use-prevent-page-close/use-prevent-page-close.stories.tsx +39 -0
  228. package/src/hooks/use-prevent-page-close/use-prevent-page-close.test.ts +89 -0
  229. package/src/hooks/use-prevent-page-close/use-prevent-page-close.ts +27 -0
  230. package/src/hooks/use-range-pagination/use-range-pagination.test.tsx +1 -1
  231. package/src/hooks/use-range-pagination/use-range-pagination.tsx +1 -1
  232. package/src/hooks/use-selection/use-selection.ts +0 -1
  233. package/src/hooks/use-step/use-step.stories.tsx +178 -65
  234. package/src/hooks/use-step/use-step.test.ts +178 -53
  235. package/src/hooks/use-step/use-step.ts +57 -49
  236. package/src/utils/form.test.tsx +13 -8
  237. package/src/utils/form.tsx +10 -0
  238. package/src/utils/functions/getFormData.test.ts +1 -1
  239. package/dist/hooks/use-hotkey/utils/create-hotkey-listener.cjs.js +0 -1
  240. package/dist/hooks/use-hotkey/utils/create-hotkey-listener.es.js +0 -10
  241. package/dist/hooks/use-prevent-close-window/use-prevent-close-window.cjs.js +0 -1
  242. package/dist/hooks/use-prevent-close-window/use-prevent-close-window.es.js +0 -15
  243. package/dist/hooks/use-toggle/use-toggle.cjs.js +0 -1
  244. package/dist/hooks/use-toggle/use-toggle.es.js +0 -10
  245. package/dist/src/hooks/use-hotkey/utils/create-hotkey-listener.d.ts +0 -1
  246. package/dist/src/hooks/use-prevent-close-window/index.d.ts +0 -1
  247. package/dist/src/hooks/use-prevent-close-window/use-prevent-close-window.d.ts +0 -13
  248. package/dist/src/hooks/use-toggle/index.d.ts +0 -1
  249. package/dist/src/hooks/use-toggle/use-toggle.d.ts +0 -3
  250. package/src/hooks/use-async/use-async.test.tsx +0 -68
  251. package/src/hooks/use-hotkey/utils/create-hotkey-listener.ts +0 -25
  252. package/src/hooks/use-is-visible/use-is-visible.tsx +0 -49
  253. package/src/hooks/use-mutation/use-mutation.test.tsx +0 -83
  254. package/src/hooks/use-mutation/use-mutation.tsx +0 -59
  255. package/src/hooks/use-object/use-object.tsx +0 -46
  256. package/src/hooks/use-prevent-close-window/index.ts +0 -1
  257. package/src/hooks/use-prevent-close-window/use-prevent-close-window.stories.tsx +0 -32
  258. package/src/hooks/use-prevent-close-window/use-prevent-close-window.test.ts +0 -79
  259. package/src/hooks/use-prevent-close-window/use-prevent-close-window.ts +0 -33
  260. package/src/hooks/use-toggle/index.ts +0 -1
  261. package/src/hooks/use-toggle/use-toggle.stories.tsx +0 -25
  262. package/src/hooks/use-toggle/use-toggle.test.tsx +0 -64
  263. package/src/hooks/use-toggle/use-toggle.ts +0 -14
  264. /package/dist/src/{hooks/use-prevent-close-window/use-prevent-close-window.test.d.ts → components/date-picker/date-input-form.test.d.ts} +0 -0
  265. /package/dist/src/hooks/{use-toggle/use-toggle.test.d.ts → internal/is-apple-device.test.d.ts} +0 -0
@@ -1,9 +1,26 @@
1
1
  import { DateRange } from './date-picker.model';
2
2
  export declare const DISPLAY_DATE_FORMAT = "dd/MM/yyyy";
3
3
  export declare const formatSingleDate: (date: Date | null | undefined, placeholder: string) => string;
4
+ /**
5
+ * ISO 8601 calendar date (`yyyy-MM-dd`) used as the form value — locale-agnostic,
6
+ * sortable, and parseable by `new Date()` / backends without a custom format.
7
+ * The display string keeps `DISPLAY_DATE_FORMAT`; this is the value layer.
8
+ */
9
+ export declare const formatISODate: (date: Date | null | undefined) => string;
4
10
  export declare const formatRangeDate: (range: DateRange | undefined, placeholder: string) => string;
5
11
  export declare const formatMultipleDates: (dates: Date[] | undefined, placeholder: string) => string;
6
12
  export declare const formatDate: (date: Date | null) => string;
13
+ /**
14
+ * Emits a native `input` event on a hidden form control so Base UI's Field
15
+ * re-runs validation. Base UI clears the error and re-validates only inside the
16
+ * control's `onChange`; assigning `value` via a React prop never fires a native
17
+ * event, so date changes driven from outside (calendar selection, typing into
18
+ * the visible input) would leave the field stuck in its invalid state.
19
+ *
20
+ * Sets the value through the prototype setter so React's value tracker detects
21
+ * the diff, then dispatches a bubbling `input` event React maps to `onChange`.
22
+ */
23
+ export declare const emitNativeInputChange: (input: HTMLInputElement | null, value: string) => void;
7
24
  export declare const parseInputToDate: (raw: string) => Date | null;
8
25
  export type DateMaskContext = {
9
26
  lastKey: string | null;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Drives a hidden Base UI `FieldControl` input from a derived form value.
3
+ *
4
+ * The input is left uncontrolled and updated imperatively so a native `input`
5
+ * event fires on every change. Base UI re-runs Field validation (and clears the
6
+ * error) only inside the control's `onChange` — never from a React `value` prop
7
+ * — so date changes coming from the calendar or the visible input must emit a
8
+ * real event for the invalid state to clear.
9
+ *
10
+ * Returns the ref to attach to the hidden input.
11
+ */
12
+ export declare function useHiddenFieldValue(value: string): import('react').RefObject<HTMLInputElement | null>;
@@ -23,6 +23,7 @@ export * from './label';
23
23
  export * from './loader';
24
24
  export * from './menu';
25
25
  export * from './number-input';
26
+ export * from './otp';
26
27
  export * from './pagination';
27
28
  export * from './password';
28
29
  export * from './popover';
@@ -1,6 +1,7 @@
1
1
  export { useControllableState } from '@radix-ui/react-use-controllable-state';
2
2
  export * from './use-array';
3
3
  export * from './use-async';
4
+ export * from './use-boolean';
4
5
  export * from './use-click-outside';
5
6
  export * from './use-clipboard';
6
7
  export * from './use-debounce-callback';
@@ -20,8 +21,7 @@ export * from './use-object';
20
21
  export * from './use-on-mount';
21
22
  export * from './use-pagination';
22
23
  export * from './use-portal';
23
- export * from './use-prevent-close-window';
24
+ export * from './use-prevent-page-close';
24
25
  export * from './use-range-pagination';
25
26
  export * from './use-selection';
26
27
  export * from './use-step';
27
- export * from './use-toggle';
@@ -1,2 +1,4 @@
1
+ export { isAppleDevice } from './is-apple-device';
1
2
  export { isBrowser } from './is-browser';
2
3
  export { useIsomorphicLayoutEffect } from './use-isomorphic-layout-effect';
4
+ export { useLatestRef } from './use-latest-ref';
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Lazily detects whether the current device is an Apple platform (macOS, iOS,
3
+ * iPadOS). Reads `navigator.userAgentData?.platform` when available, falling
4
+ * back to the legacy `navigator.platform`.
5
+ *
6
+ * SSR-safe: returns `false` when there is no `navigator` (e.g. on the server),
7
+ * so the `mod` hotkey modifier deterministically resolves to `ctrl` there.
8
+ *
9
+ * The check runs on every call (not memoized at module-eval) so it can be
10
+ * stubbed per-test and stays correct if the environment changes.
11
+ */
12
+ export declare const isAppleDevice: () => boolean;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Returns a ref whose `.current` always holds the latest value passed in.
3
+ *
4
+ * Internal building block for the handler-stable pattern: hooks that accept
5
+ * user callbacks should read them through a ref so listeners attached to
6
+ * `window`/`document`/elements never need to be re-attached when the consumer
7
+ * passes an inline function.
8
+ *
9
+ * Updates happen in a layout effect so the ref is current before any user
10
+ * effect or commit-phase work runs in the same render.
11
+ */
12
+ export declare const useLatestRef: <T>(value: T) => import('react').RefObject<T>;
@@ -1,11 +1,24 @@
1
- export declare function useArray<T>(defaultProp: T[]): readonly [T[], {
2
- readonly insertAt: (index: number, item: T) => void;
3
- readonly removeAt: (index: number) => void;
4
- readonly updateAt: (index: number, newItem: T) => void;
5
- readonly clear: () => void;
6
- readonly reset: () => void;
7
- readonly push: (item: T) => void;
8
- readonly set: (newList: T[]) => void;
9
- readonly pop: () => void;
10
- readonly update: (predicate: (item: T) => boolean, newItem: T | ((item: T) => T)) => void;
11
- }];
1
+ export interface UseArrayOptions<T> {
2
+ /** Called after every list change. NOT called on initial mount. */
3
+ onChange?: (items: T[]) => void;
4
+ }
5
+ export interface UseArrayActions<T> {
6
+ push(item: T): void;
7
+ pop(): void;
8
+ insertAt(index: number, item: T): void;
9
+ removeAt(index: number): void;
10
+ updateAt(index: number, item: T): void;
11
+ clear(): void;
12
+ reset(): void;
13
+ set(items: T[]): void;
14
+ move(from: number, to: number): void;
15
+ swap(indexA: number, indexB: number): void;
16
+ filter(predicate: (item: T, index: number, array: T[]) => boolean): void;
17
+ sort(compareFn?: (a: T, b: T) => number): void;
18
+ reverse(): void;
19
+ replace(predicate: (item: T) => boolean, newItem: T | ((item: T) => T)): void;
20
+ removeWhere(predicate: (item: T) => boolean): void;
21
+ pushMany(items: T[]): void;
22
+ find(predicate: (item: T, index: number, array: T[]) => boolean): T | undefined;
23
+ }
24
+ export declare function useArray<T>(initialValue: T[], options?: UseArrayOptions<T>): readonly [T[], UseArrayActions<T>];
@@ -1,18 +1,21 @@
1
- import { DependencyList } from 'react';
2
- interface UseAsyncOptions<T> {
3
- onError?: (error: Error) => void;
1
+ export type AsyncStatus = "idle" | "pending" | "success" | "error";
2
+ export interface UseAsyncOptions<T> {
3
+ fn: (signal: AbortSignal) => Promise<T>;
4
+ deps?: readonly unknown[];
5
+ enabled?: boolean;
6
+ keepPreviousData?: boolean;
4
7
  onSuccess?: (data: T) => void;
5
- onFinish?: () => void;
8
+ onError?: (error: Error) => void;
9
+ onSettled?: (data: T | null, error: Error | null) => void;
6
10
  }
7
- interface AsyncState<T> {
8
- loading: boolean;
9
- error: Error | null;
11
+ export interface UseAsyncReturn<T> {
10
12
  data: T | null;
13
+ error: Error | null;
14
+ status: AsyncStatus;
15
+ loading: boolean;
16
+ isIdle: boolean;
17
+ isSuccess: boolean;
18
+ isError: boolean;
11
19
  refetch: () => void;
12
20
  }
13
- interface Props<T> extends UseAsyncOptions<T> {
14
- fn: () => Promise<T>;
15
- dependencies?: DependencyList;
16
- }
17
- export declare function useAsync<T>({ fn, dependencies, onError, onSuccess, onFinish, }: Props<T>): AsyncState<T>;
18
- export {};
21
+ export declare function useAsync<T>({ fn, deps, enabled, keepPreviousData, onSuccess, onError, onSettled, }: UseAsyncOptions<T>): UseAsyncReturn<T>;
@@ -0,0 +1 @@
1
+ export * from './use-boolean';
@@ -0,0 +1,15 @@
1
+ export interface UseBooleanOptions {
2
+ /** Called after every value change. NOT called on initial mount. */
3
+ onChange?: (value: boolean) => void;
4
+ }
5
+ export interface UseBooleanActions {
6
+ /** Flip the current value. */
7
+ toggle(): void;
8
+ /** Force the value to true. */
9
+ setTrue(): void;
10
+ /** Force the value to false. */
11
+ setFalse(): void;
12
+ /** Set the value explicitly. */
13
+ set(value: boolean): void;
14
+ }
15
+ export declare function useBoolean(initialValue?: boolean, options?: UseBooleanOptions): readonly [boolean, UseBooleanActions];
@@ -0,0 +1 @@
1
+ export {};
@@ -1 +1,23 @@
1
- export declare const useClickOutside: <T extends HTMLElement = HTMLElement>(callback: () => void, watch?: boolean) => import('react').RefObject<T | null>;
1
+ import { RefObject } from 'react';
2
+ type UseClickOutsideOptions = {
3
+ /** Disable the listener without unmounting the hook. Defaults to `true`. */
4
+ enabled?: boolean;
5
+ /**
6
+ * Which DOM events trigger the outside check. Any DOM event names work;
7
+ * pass `null` to fall back to the default. Defaults to `["pointerdown"]`.
8
+ */
9
+ events?: string[] | null;
10
+ /**
11
+ * Return `true` to skip the callback for a given event. Useful for portals
12
+ * or popovers whose DOM lives outside the wrapped ref but should still count
13
+ * as "inside".
14
+ */
15
+ ignore?: (event: Event) => boolean;
16
+ /**
17
+ * Extra refs that also count as "inside". An event whose target lives in
18
+ * any of these elements will not fire the callback.
19
+ */
20
+ additionalRefs?: RefObject<HTMLElement | null>[];
21
+ };
22
+ export declare const useClickOutside: <T extends HTMLElement = HTMLElement>(callback: (event: Event) => void, options?: UseClickOutsideOptions) => RefObject<T | null>;
23
+ export {};
@@ -1 +1,19 @@
1
- export declare function useDebouncedCallback<T extends (...args: any[]) => any>(callback: T, delay: number): (...args: Parameters<T>) => void;
1
+ export interface DebouncedControls {
2
+ /** Cancel the pending invocation without calling the callback. No-op if nothing is pending. */
3
+ cancel: () => void;
4
+ /** Immediately invoke the callback with the last queued arguments, clearing the timer. No-op if nothing is pending. */
5
+ flush: () => void;
6
+ /** Reactive boolean: `true` while a debounced call is scheduled, `false` otherwise. */
7
+ isPending: boolean;
8
+ }
9
+ /**
10
+ * Returns a debounced version of `callback` together with a controls object.
11
+ *
12
+ * The returned `debounced` function has a **stable identity** — it is only
13
+ * recreated when `delay` changes, never when `callback` changes. This means
14
+ * passing an inline arrow function is safe: it will not reset a pending timer
15
+ * on re-render.
16
+ *
17
+ * @returns `[debounced, { cancel, flush, isPending }]`
18
+ */
19
+ export declare function useDebouncedCallback<T extends (...args: any[]) => any>(callback: T, delay: number): readonly [(...args: Parameters<T>) => void, DebouncedControls];
@@ -1 +1,10 @@
1
- export declare function useDebouncedValue<T>(value: T, delay: number): T;
1
+ import { DebouncedControls } from '../use-debounce-callback/use-debounced-callback';
2
+ /**
3
+ * Returns the debounced version of `value` together with a controls object.
4
+ *
5
+ * Delegates entirely to `useDebouncedCallback` — there is no duplicated timer
6
+ * logic in this hook.
7
+ *
8
+ * @returns `[debouncedValue, { cancel, flush, isPending }]`
9
+ */
10
+ export declare function useDebouncedValue<T>(value: T, delay: number): readonly [T, DebouncedControls];
@@ -1,8 +1,17 @@
1
- export declare function useDisclosure(initialState?: boolean, callbacks?: {
2
- onOpen?: () => void;
3
- onClose?: () => void;
4
- }): readonly [boolean, {
5
- readonly open: () => void;
6
- readonly close: () => void;
7
- readonly toggle: () => void;
8
- }];
1
+ export type UseDisclosureProps = {
2
+ /** Initial open value (default: false). */
3
+ defaultOpen?: boolean;
4
+ /** Called once per real state transition. Not called on no-op calls. */
5
+ onOpenChange?: (open: boolean) => void;
6
+ };
7
+ export type UseDisclosureActions = {
8
+ /** Transitions state to true. No-op (and onOpenChange not called) if already open. */
9
+ open: () => void;
10
+ /** Transitions state to false. No-op (and onOpenChange not called) if already closed. */
11
+ close: () => void;
12
+ /** Flips the current boolean state. */
13
+ toggle: () => void;
14
+ /** Sets state to the given value. No-op (and onOpenChange not called) if value is unchanged. */
15
+ setOpen: (open: boolean) => void;
16
+ };
17
+ export declare function useDisclosure(props?: UseDisclosureProps): readonly [boolean, UseDisclosureActions];
@@ -1,5 +1,16 @@
1
1
  export interface UseDocumentTitleInput {
2
2
  /** Restore the previous `document.title` when the component unmounts. Defaults to `false`. */
3
3
  restoreOnUnmount?: boolean;
4
+ /**
5
+ * Template applied to the title. The `%s` placeholder is replaced with
6
+ * the (trimmed) title value. Example: `"%s | Acme"` turns `"Inbox"`
7
+ * into `"Inbox | Acme"`. When omitted, the title is written as-is.
8
+ */
9
+ template?: string;
10
+ /**
11
+ * When `false`, the hook does not touch `document.title`. Defaults to
12
+ * `true`. Useful to conditionally own the title.
13
+ */
14
+ enabled?: boolean;
4
15
  }
5
16
  export declare function useDocumentTitle(title: string, options?: UseDocumentTitleInput): void;
@@ -1 +1,18 @@
1
- export declare function useEventListener<K extends keyof HTMLElementEventMap, T extends HTMLElement = HTMLElement>(type: K, listener: (this: T, ev: HTMLElementEventMap[K]) => void, options?: boolean | AddEventListenerOptions): import('react').RefObject<T | null>;
1
+ import { RefObject } from 'react';
2
+ /**
3
+ * Subscribe to a DOM event with automatic cleanup. The `listener` is read
4
+ * through an internal ref (handler-stable pattern), so passing an inline
5
+ * function never re-attaches the underlying listener on every render.
6
+ *
7
+ * The target is explicit and selected by overload:
8
+ * - omit it to listen on `window` (the default);
9
+ * - pass a `RefObject` or the element itself for an `HTMLElement`;
10
+ * - pass `document` for document-level events;
11
+ * - pass a `MediaQueryList` for media query changes.
12
+ *
13
+ * SSR-safe: the effect no-ops when there is no DOM.
14
+ */
15
+ export declare function useEventListener<K extends keyof WindowEventMap>(type: K, listener: (event: WindowEventMap[K]) => void, target?: Window | RefObject<Window | null> | null, options?: boolean | AddEventListenerOptions): void;
16
+ export declare function useEventListener<K extends keyof DocumentEventMap>(type: K, listener: (event: DocumentEventMap[K]) => void, target: Document | RefObject<Document | null>, options?: boolean | AddEventListenerOptions): void;
17
+ export declare function useEventListener<K extends keyof HTMLElementEventMap, T extends HTMLElement = HTMLElement>(type: K, listener: (event: HTMLElementEventMap[K]) => void, target: T | RefObject<T | null>, options?: boolean | AddEventListenerOptions): void;
18
+ export declare function useEventListener<K extends keyof MediaQueryListEventMap>(type: K, listener: (event: MediaQueryListEventMap[K]) => void, target: MediaQueryList | RefObject<MediaQueryList | null>, options?: boolean | AddEventListenerOptions): void;
@@ -1 +1,2 @@
1
- export * from './use-hotkey';
1
+ export type { HotkeyEventName, HotkeyItem, HotkeyItemOptions, HotkeyOptions, KeyboardEventLike, Keys, } from './use-hotkey';
2
+ export { getHotkeyHandler, useHotkey } from './use-hotkey';
@@ -1,9 +1,66 @@
1
+ import { HotkeyItem, HotkeyItemOptions, KeyboardEventLike } from './utils';
2
+ export type { HotkeyItem, HotkeyItemOptions, KeyboardEventLike };
3
+ /** A single key string or a list of key strings sharing one handler. */
1
4
  export type Keys = string | string[];
2
- export type HotkeyEventName = "keydown" | "keypress" | "keyup";
3
- export type HotkeyOptions = {
5
+ /** Supported listener event names. `"keypress"` is removed in v2. */
6
+ export type HotkeyEventName = "keydown" | "keyup";
7
+ /**
8
+ * Options for the single-binding `useHotkey(keys, handler, options)` form.
9
+ * Combines hook-level concerns (`watch`, `eventName`, `tagsToIgnore`) with the
10
+ * per-binding behavior (`preventDefault`, `triggerOnContentEditable`).
11
+ */
12
+ export type HotkeyOptions = HotkeyItemOptions & {
13
+ /** Listen while `true` (default). When `false`, no handler fires. */
4
14
  watch?: boolean;
15
+ /** DOM event to listen for. Default `"keydown"`. */
5
16
  eventName?: HotkeyEventName;
6
- preventDefault?: boolean;
7
- ignoreInputFields?: boolean;
17
+ /**
18
+ * Tag names whose events are ignored. Default
19
+ * `["INPUT", "TEXTAREA", "SELECT"]`. Pass `[]` to ignore nothing.
20
+ */
21
+ tagsToIgnore?: string[];
8
22
  };
9
- export declare function useHotkey(keys: string | string[], handler: (event: KeyboardEvent) => void, options?: HotkeyOptions): import('react').RefObject<HTMLElement | null>;
23
+ /**
24
+ * Bind one or more keyboard shortcuts at the `document` level.
25
+ *
26
+ * Two forms are supported:
27
+ *
28
+ * 1. Single binding — `useHotkey(keys, handler, options?)` where `keys` is a
29
+ * string or string array sharing one handler.
30
+ * 2. Multiple bindings — `useHotkey(bindings)` where `bindings` is a list of
31
+ * `[key, handler, options?]` tuples, each dispatched independently.
32
+ *
33
+ * Matching is strict: every required modifier (`shift`/`ctrl`/`alt`/`meta`)
34
+ * must be pressed and no other modifier may be. `mod` resolves to `meta` (⌘)
35
+ * on Apple platforms and `ctrl` elsewhere. Events originating in `tagsToIgnore`
36
+ * tags (or contentEditable regions) are suppressed unless opted out.
37
+ *
38
+ * The handler is read through a ref, so passing an inline function never
39
+ * re-attaches the underlying listener. SSR-safe: no DOM access on the server.
40
+ *
41
+ * @example
42
+ * useHotkey("mod+k", () => openPalette());
43
+ * useHotkey([["a", onA], ["b", onB, { preventDefault: false }]]);
44
+ */
45
+ export declare function useHotkey(keys: Keys, handler: (event: KeyboardEventLike) => void, options?: HotkeyOptions): void;
46
+ export declare function useHotkey(bindings: HotkeyItem[], options?: HotkeyOptions): void;
47
+ /**
48
+ * Build an element-scoped `onKeyDown` handler. Shares the same
49
+ * strict-modifier and `mod` behavior as {@link useHotkey}.
50
+ *
51
+ * Two forms are supported:
52
+ *
53
+ * 1. Single binding — `getHotkeyHandler(keys, handler, options?)`.
54
+ * 2. Multiple bindings — `getHotkeyHandler(bindings)` where `bindings` is a
55
+ * list of `[key, handler, options?]` tuples.
56
+ *
57
+ * Because it is attached to an element's `onKeyDown`, it applies NO tag
58
+ * suppression — it has no `tagsToIgnore` and matches regardless of the target
59
+ * tag (including the `<input>` it is attached to).
60
+ *
61
+ * @example
62
+ * <input onKeyDown={getHotkeyHandler("mod+enter", submit)} />
63
+ * <input onKeyDown={getHotkeyHandler([["mod+enter", submit], ["escape", cancel]])} />
64
+ */
65
+ export declare function getHotkeyHandler(keys: Keys, handler: (event: KeyboardEventLike) => void, options?: HotkeyItemOptions): (event: KeyboardEventLike) => void;
66
+ export declare function getHotkeyHandler(bindings: HotkeyItem[]): (event: KeyboardEventLike) => void;
@@ -1,3 +1,4 @@
1
- export * from './create-hotkey-listener';
2
- export * from './is-input-field';
3
- export * from './match-key-modifiers';
1
+ export { shouldIgnoreEvent } from './is-input-field';
2
+ export type { HotkeyItem, HotkeyItemOptions, KeyboardEventLike, } from './match-and-run';
3
+ export { matchAndRun } from './match-and-run';
4
+ export { getKeyModifiers, matchKeyModifiers } from './match-key-modifiers';
@@ -1,2 +1,12 @@
1
- export declare const isInputField: (element: HTMLElement) => boolean;
2
- export declare const shouldIgnoreEvent: (event: KeyboardEvent, ignoreInputFields: boolean) => boolean;
1
+ import { KeyboardEventLike } from './match-and-run';
2
+ /**
3
+ * Decides whether a keyboard event should be suppressed because it originated
4
+ * inside a form control or editable region.
5
+ *
6
+ * - Suppressed when the target's tag name is in `tagsToIgnore` (case-sensitive
7
+ * uppercase tag names, e.g. `["INPUT","TEXTAREA","SELECT"]`). An empty list
8
+ * suppresses nothing.
9
+ * - Suppressed when the target is `contentEditable`, unless
10
+ * `triggerOnContentEditable` is `true`.
11
+ */
12
+ export declare const shouldIgnoreEvent: (event: KeyboardEventLike, tagsToIgnore: string[], triggerOnContentEditable: boolean) => boolean;
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Structural subset of a keyboard event used by the matching core. Both the
3
+ * DOM `KeyboardEvent` (used by `useHotkey`) and React's synthetic
4
+ * `KeyboardEvent` (used by `getHotkeyHandler`) satisfy this shape, so the core
5
+ * stays React-free and requires no casts at either call site.
6
+ */
7
+ export type KeyboardEventLike = Pick<KeyboardEvent, "key" | "shiftKey" | "ctrlKey" | "altKey" | "metaKey"> & {
8
+ target: EventTarget | null;
9
+ preventDefault: () => void;
10
+ };
11
+ /**
12
+ * Per-binding options. Defaults: `preventDefault` true,
13
+ * `triggerOnContentEditable` false, `tagsToIgnore` is resolved by the caller
14
+ * (`useHotkey` passes its configured list; `getHotkeyHandler` passes `[]`).
15
+ */
16
+ export type HotkeyItemOptions = {
17
+ preventDefault?: boolean;
18
+ triggerOnContentEditable?: boolean;
19
+ };
20
+ /** A single hotkey binding: `[key, handler, options?]`. */
21
+ export type HotkeyItem = [
22
+ key: string,
23
+ handler: (event: KeyboardEventLike) => void,
24
+ options?: HotkeyItemOptions
25
+ ];
26
+ /**
27
+ * The shared matching engine. For each binding it:
28
+ * 1. skips the event if the target should be ignored (tag / contentEditable);
29
+ * 2. parses the binding key (resolving `mod` to `meta`/`ctrl` per platform);
30
+ * 3. strictly matches the main key and all four modifiers;
31
+ * 4. calls `preventDefault` (unless opted out) then the handler.
32
+ *
33
+ * `tagsToIgnore` is a core parameter: `useHotkey` passes its configured list,
34
+ * while `getHotkeyHandler` passes `[]` (element-scoped, so it ignores nothing).
35
+ */
36
+ export declare const matchAndRun: (event: KeyboardEventLike, items: HotkeyItem[], tagsToIgnore: string[]) => void;
@@ -1,8 +1,22 @@
1
- export declare const getKeyModifiers: (key: string) => {
1
+ import { KeyboardEventLike } from './match-and-run';
2
+ type ParsedKey = {
2
3
  mainKey: string;
3
- isShift: boolean;
4
- isCtrl: boolean;
5
- isAlt: boolean;
6
- isMeta: boolean;
4
+ shift: boolean;
5
+ ctrl: boolean;
6
+ alt: boolean;
7
+ meta: boolean;
7
8
  };
8
- export declare const matchKeyModifiers: (event: KeyboardEvent, key: string) => boolean;
9
+ /**
10
+ * Parses a hotkey string (e.g. `"mod+shift+k"`) into its main key and the
11
+ * exact set of required modifiers. `mod` resolves to `meta` on Apple platforms
12
+ * and `ctrl` elsewhere; the opposite modifier is then required to be absent
13
+ * (it stays `false` here, enforcing the strict exact-match rule).
14
+ */
15
+ export declare const getKeyModifiers: (key: string) => ParsedKey;
16
+ /**
17
+ * Returns `true` only when the event's main key matches AND every modifier
18
+ * state (shift/ctrl/alt/meta) exactly equals the parsed requirement. This is a
19
+ * strict match: any extra or missing modifier rejects the binding.
20
+ */
21
+ export declare const matchKeyModifiers: (event: KeyboardEventLike, key: string) => boolean;
22
+ export {};
@@ -1,9 +1,13 @@
1
1
  import { RefCallback } from 'react';
2
2
  export interface UseHoverInput {
3
- /** Fired when the pointer enters the target element. Receives the native MouseEvent. */
4
- onHoverStart?: (event: MouseEvent) => void;
5
- /** Fired when the pointer leaves the target element. Receives the native MouseEvent. */
6
- onHoverEnd?: (event: MouseEvent) => void;
3
+ /** Delay in ms before `hovered` becomes true after pointer enters. Default 0 (synchronous). */
4
+ openDelay?: number;
5
+ /** Delay in ms before `hovered` becomes false after pointer leaves. Default 0 (synchronous). */
6
+ closeDelay?: number;
7
+ /** Fired when the pointer enters the target element. Receives the native PointerEvent. */
8
+ onHoverStart?: (event: PointerEvent) => void;
9
+ /** Fired when the pointer leaves the target element. Receives the native PointerEvent. */
10
+ onHoverEnd?: (event: PointerEvent) => void;
7
11
  }
8
12
  export interface UseHoverReturnValue<T extends HTMLElement = HTMLElement> {
9
13
  hovered: boolean;
@@ -1,10 +1,34 @@
1
1
  import { RefObject } from 'react';
2
- interface UseIsVisibleProps extends IntersectionObserverInit {
2
+ export interface UseIsVisibleOptions extends IntersectionObserverInit {
3
+ /**
4
+ * Called once when the element first becomes visible.
5
+ * Stable — safe to pass an inline arrow function without causing observer re-attachment.
6
+ */
3
7
  onVisible?: () => void;
8
+ /**
9
+ * When true, the IntersectionObserver disconnects after the first positive intersection.
10
+ * `isVisible` latches to `true` and never flips back to `false`.
11
+ * The observer lifecycle is torn down early; no further intersection callbacks fire.
12
+ */
13
+ triggerOnce?: boolean;
14
+ /**
15
+ * When true, once `isVisible` becomes `true` it is never reset to `false`.
16
+ * The observer stays connected (unlike `triggerOnce`), so `entry` may continue updating.
17
+ */
18
+ freezeOnceVisible?: boolean;
4
19
  }
5
- interface UseIsVisibleReturn<T> {
20
+ export interface UseIsVisibleReturn<T extends HTMLElement> {
21
+ /** Attach to the DOM element you want to observe. */
6
22
  ref: RefObject<T | null>;
23
+ /**
24
+ * True when the observed element is intersecting the viewport (or root).
25
+ * Stays true permanently when `triggerOnce` or `freezeOnceVisible` has triggered.
26
+ */
7
27
  isVisible: boolean;
28
+ /**
29
+ * The latest IntersectionObserverEntry received.
30
+ * `null` until the first intersection event fires.
31
+ */
32
+ entry: IntersectionObserverEntry | null;
8
33
  }
9
- export declare function useIsVisible<T extends HTMLElement>({ onVisible, root, rootMargin, threshold, }?: UseIsVisibleProps): UseIsVisibleReturn<T>;
10
- export {};
34
+ export declare function useIsVisible<T extends HTMLElement>(options?: UseIsVisibleOptions): UseIsVisibleReturn<T>;
@@ -1,2 +1,13 @@
1
- export declare function useLocalStorage<T>(key: string): [T | undefined, (value: T) => void, () => void];
2
- export declare function useLocalStorage<T>(key: string, initialValue: T): [T, (value: T) => void, () => void];
1
+ export interface Serializer<T> {
2
+ read: (raw: string) => T;
3
+ write: (value: T) => string;
4
+ }
5
+ export interface UseLocalStorageOptions<T> {
6
+ serializer?: Serializer<T>;
7
+ }
8
+ export declare function useLocalStorage<T>(key: string): [
9
+ T | undefined,
10
+ (value: T | ((prev: T | undefined) => T)) => void,
11
+ () => void
12
+ ];
13
+ export declare function useLocalStorage<T>(key: string, initialValue: T, options?: UseLocalStorageOptions<T>): [T, (value: T | ((prev: T) => T)) => void, () => void];
@@ -1 +1,10 @@
1
- export declare const useMediaQuery: (query: string) => boolean;
1
+ export interface UseMediaQueryOptions {
2
+ /**
3
+ * Value returned during server render and on the first client render
4
+ * before `matchMedia` has been read. Use this to avoid hydration
5
+ * mismatches in SSR consumers that already know the breakpoint.
6
+ * @default false
7
+ */
8
+ defaultValue?: boolean;
9
+ }
10
+ export declare function useMediaQuery(query: string, options?: UseMediaQueryOptions): boolean;