@jbpark/use-hooks 2.10.0 → 3.0.0

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 (74) hide show
  1. package/dist/hooks/index.d.mts +12 -1
  2. package/dist/hooks/index.mjs +12 -1
  3. package/dist/hooks/use-click-outside.d.mts +9 -2
  4. package/dist/hooks/use-click-outside.mjs +27 -11
  5. package/dist/hooks/use-click-outside.mjs.map +1 -1
  6. package/dist/hooks/use-controllable-state.d.mts +4 -5
  7. package/dist/hooks/use-controllable-state.mjs +10 -4
  8. package/dist/hooks/use-controllable-state.mjs.map +1 -1
  9. package/dist/hooks/use-debounced-value.d.mts +5 -0
  10. package/dist/hooks/use-debounced-value.mjs +20 -0
  11. package/dist/hooks/use-debounced-value.mjs.map +1 -0
  12. package/dist/hooks/use-element-position.mjs +37 -8
  13. package/dist/hooks/use-element-position.mjs.map +1 -1
  14. package/dist/hooks/use-element-scroll.d.mts +6 -1
  15. package/dist/hooks/use-element-scroll.mjs +30 -8
  16. package/dist/hooks/use-element-scroll.mjs.map +1 -1
  17. package/dist/hooks/use-event-listener.d.mts +21 -0
  18. package/dist/hooks/use-event-listener.mjs +37 -0
  19. package/dist/hooks/use-event-listener.mjs.map +1 -0
  20. package/dist/hooks/use-file-drop.d.mts +14 -0
  21. package/dist/hooks/use-file-drop.mjs +85 -0
  22. package/dist/hooks/use-file-drop.mjs.map +1 -0
  23. package/dist/hooks/use-image.d.mts +2 -1
  24. package/dist/hooks/use-image.mjs +4 -3
  25. package/dist/hooks/use-image.mjs.map +1 -1
  26. package/dist/hooks/use-intersection-observer.d.mts +8 -1
  27. package/dist/hooks/use-intersection-observer.mjs +37 -5
  28. package/dist/hooks/use-intersection-observer.mjs.map +1 -1
  29. package/dist/hooks/use-interval.d.mts +5 -0
  30. package/dist/hooks/use-interval.mjs +20 -0
  31. package/dist/hooks/use-interval.mjs.map +1 -0
  32. package/dist/hooks/use-key-press.d.mts +14 -0
  33. package/dist/hooks/use-key-press.mjs +63 -0
  34. package/dist/hooks/use-key-press.mjs.map +1 -0
  35. package/dist/hooks/use-merged-ref.d.mts +8 -0
  36. package/dist/hooks/use-merged-ref.mjs +25 -0
  37. package/dist/hooks/use-merged-ref.mjs.map +1 -0
  38. package/dist/hooks/use-multi-select.mjs +14 -5
  39. package/dist/hooks/use-multi-select.mjs.map +1 -1
  40. package/dist/hooks/use-mutation-observer.d.mts +11 -0
  41. package/dist/hooks/use-mutation-observer.mjs +33 -0
  42. package/dist/hooks/use-mutation-observer.mjs.map +1 -0
  43. package/dist/hooks/use-previous.d.mts +5 -0
  44. package/dist/hooks/use-previous.mjs +14 -0
  45. package/dist/hooks/use-previous.mjs.map +1 -0
  46. package/dist/hooks/use-resize-observer.d.mts +12 -0
  47. package/dist/hooks/use-resize-observer.mjs +29 -0
  48. package/dist/hooks/use-resize-observer.mjs.map +1 -0
  49. package/dist/hooks/use-responsive-size.d.mts +1 -0
  50. package/dist/hooks/use-responsive-size.mjs +70 -54
  51. package/dist/hooks/use-responsive-size.mjs.map +1 -1
  52. package/dist/hooks/use-scroll-to-elements.d.mts +7 -5
  53. package/dist/hooks/use-scroll-to-elements.mjs +52 -27
  54. package/dist/hooks/use-scroll-to-elements.mjs.map +1 -1
  55. package/dist/hooks/use-throttle.d.mts +5 -1
  56. package/dist/hooks/use-throttle.mjs +6 -32
  57. package/dist/hooks/use-throttle.mjs.map +1 -1
  58. package/dist/hooks/use-throttled-callback.d.mts +12 -0
  59. package/dist/hooks/use-throttled-callback.mjs +54 -0
  60. package/dist/hooks/use-throttled-callback.mjs.map +1 -0
  61. package/dist/hooks/use-timeout.d.mts +8 -0
  62. package/dist/hooks/use-timeout.mjs +38 -0
  63. package/dist/hooks/use-timeout.mjs.map +1 -0
  64. package/dist/hooks/use-toggle.d.mts +5 -0
  65. package/dist/hooks/use-toggle.mjs +17 -0
  66. package/dist/hooks/use-toggle.mjs.map +1 -0
  67. package/dist/hooks/use-window-scroll.mjs +60 -38
  68. package/dist/hooks/use-window-scroll.mjs.map +1 -1
  69. package/dist/index.d.mts +13 -2
  70. package/dist/index.mjs +13 -2
  71. package/package.json +1 -1
  72. package/dist/hooks/use-timeline.d.mts +0 -50
  73. package/dist/hooks/use-timeline.mjs +0 -176
  74. package/dist/hooks/use-timeline.mjs.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-file-drop.mjs","names":[],"sources":["../../src/hooks/use-file-drop.ts"],"sourcesContent":["import { useCallback, useEffect, useRef, useState } from 'react';\n\ninterface Options {\n onDrop?: (files: File[]) => void;\n // Comma-separated list, same format as the native <input accept>\n // attribute: extensions ('.png'), MIME types ('image/png'), or\n // wildcard subtypes ('image/*'). Unset accepts everything.\n accept?: string;\n multiple?: boolean;\n disabled?: boolean;\n}\n\nconst matchesAccept = (file: File, accept?: string): boolean => {\n if (!accept) {\n return true;\n }\n\n const patterns = accept\n .split(',')\n .map(pattern => pattern.trim())\n .filter(Boolean);\n\n if (patterns.length === 0) {\n return true;\n }\n\n return patterns.some(pattern => {\n if (pattern.startsWith('.')) {\n return file.name.toLowerCase().endsWith(pattern.toLowerCase());\n }\n\n if (pattern.endsWith('/*')) {\n return file.type.startsWith(pattern.slice(0, -1));\n }\n\n return file.type === pattern;\n });\n};\n\n// Pairs with useFileToDataUrl to cover a drag-and-drop upload area\n// end to end: this gets from \"user dropped something\" to a filtered\n// File[], useFileToDataUrl takes it from there to a data URL.\nconst useFileDrop = <T extends HTMLElement = HTMLElement>(\n options: Options = {},\n) => {\n const { onDrop, accept, multiple = true, disabled = false } = options;\n\n const [isDragging, setIsDragging] = useState(false);\n // `dragleave` also fires when the pointer moves onto a child element\n // (which re-fires `dragenter` on the way back out), not just when it\n // truly leaves the drop target — an enter/leave counter (rather than a\n // plain boolean) is what avoids `isDragging` flickering off and back on\n // as the pointer crosses child element boundaries.\n const dragCounterRef = useRef(0);\n\n const onDropRef = useRef(onDrop);\n const acceptRef = useRef(accept);\n const multipleRef = useRef(multiple);\n const disabledRef = useRef(disabled);\n\n useEffect(() => {\n onDropRef.current = onDrop;\n acceptRef.current = accept;\n multipleRef.current = multiple;\n disabledRef.current = disabled;\n });\n\n useEffect(() => {\n if (disabled) {\n dragCounterRef.current = 0;\n setIsDragging(false);\n }\n }, [disabled]);\n\n const cleanupRef = useRef<(() => void) | null>(null);\n\n const dropRef = useCallback((node: T | null) => {\n cleanupRef.current?.();\n cleanupRef.current = null;\n\n if (!node) {\n return;\n }\n\n const onDragEnter = (event: DragEvent) => {\n if (disabledRef.current) {\n return;\n }\n event.preventDefault();\n dragCounterRef.current += 1;\n if (dragCounterRef.current === 1) {\n setIsDragging(true);\n }\n };\n\n const onDragLeave = (event: DragEvent) => {\n if (disabledRef.current) {\n return;\n }\n event.preventDefault();\n dragCounterRef.current = Math.max(0, dragCounterRef.current - 1);\n if (dragCounterRef.current === 0) {\n setIsDragging(false);\n }\n };\n\n // `preventDefault` here is what tells the browser this is a valid\n // drop target at all — without it, `drop` never fires.\n const onDragOver = (event: DragEvent) => {\n if (disabledRef.current) {\n return;\n }\n event.preventDefault();\n };\n\n const onDrop = (event: DragEvent) => {\n if (disabledRef.current) {\n return;\n }\n event.preventDefault();\n dragCounterRef.current = 0;\n setIsDragging(false);\n\n const fileList = event.dataTransfer?.files;\n\n if (!fileList || fileList.length === 0) {\n return;\n }\n\n let files = Array.from(fileList).filter(file =>\n matchesAccept(file, acceptRef.current),\n );\n\n if (!multipleRef.current) {\n files = files.slice(0, 1);\n }\n\n if (files.length > 0) {\n onDropRef.current?.(files);\n }\n };\n\n node.addEventListener('dragenter', onDragEnter);\n node.addEventListener('dragleave', onDragLeave);\n node.addEventListener('dragover', onDragOver);\n node.addEventListener('drop', onDrop);\n\n cleanupRef.current = () => {\n node.removeEventListener('dragenter', onDragEnter);\n node.removeEventListener('dragleave', onDragLeave);\n node.removeEventListener('dragover', onDragOver);\n node.removeEventListener('drop', onDrop);\n dragCounterRef.current = 0;\n };\n }, []);\n\n return { dropRef, isDragging };\n};\n\nexport default useFileDrop;\n"],"mappings":";;;AAYA,MAAM,iBAAiB,MAAY,WAA6B;AAC9D,KAAI,CAAC,OACH,QAAO;CAGT,MAAM,WAAW,OACd,MAAM,IAAI,CACV,KAAI,YAAW,QAAQ,MAAM,CAAC,CAC9B,OAAO,QAAQ;AAElB,KAAI,SAAS,WAAW,EACtB,QAAO;AAGT,QAAO,SAAS,MAAK,YAAW;AAC9B,MAAI,QAAQ,WAAW,IAAI,CACzB,QAAO,KAAK,KAAK,aAAa,CAAC,SAAS,QAAQ,aAAa,CAAC;AAGhE,MAAI,QAAQ,SAAS,KAAK,CACxB,QAAO,KAAK,KAAK,WAAW,QAAQ,MAAM,GAAG,GAAG,CAAC;AAGnD,SAAO,KAAK,SAAS;GACrB;;AAMJ,MAAM,eACJ,UAAmB,EAAE,KAClB;CACH,MAAM,EAAE,QAAQ,QAAQ,WAAW,MAAM,WAAW,UAAU;CAE9D,MAAM,CAAC,YAAY,iBAAiB,SAAS,MAAM;CAMnD,MAAM,iBAAiB,OAAO,EAAE;CAEhC,MAAM,YAAY,OAAO,OAAO;CAChC,MAAM,YAAY,OAAO,OAAO;CAChC,MAAM,cAAc,OAAO,SAAS;CACpC,MAAM,cAAc,OAAO,SAAS;AAEpC,iBAAgB;AACd,YAAU,UAAU;AACpB,YAAU,UAAU;AACpB,cAAY,UAAU;AACtB,cAAY,UAAU;GACtB;AAEF,iBAAgB;AACd,MAAI,UAAU;AACZ,kBAAe,UAAU;AACzB,iBAAc,MAAM;;IAErB,CAAC,SAAS,CAAC;CAEd,MAAM,aAAa,OAA4B,KAAK;AAkFpD,QAAO;EAAE,SAhFO,aAAa,SAAmB;AAC9C,cAAW,WAAW;AACtB,cAAW,UAAU;AAErB,OAAI,CAAC,KACH;GAGF,MAAM,eAAe,UAAqB;AACxC,QAAI,YAAY,QACd;AAEF,UAAM,gBAAgB;AACtB,mBAAe,WAAW;AAC1B,QAAI,eAAe,YAAY,EAC7B,eAAc,KAAK;;GAIvB,MAAM,eAAe,UAAqB;AACxC,QAAI,YAAY,QACd;AAEF,UAAM,gBAAgB;AACtB,mBAAe,UAAU,KAAK,IAAI,GAAG,eAAe,UAAU,EAAE;AAChE,QAAI,eAAe,YAAY,EAC7B,eAAc,MAAM;;GAMxB,MAAM,cAAc,UAAqB;AACvC,QAAI,YAAY,QACd;AAEF,UAAM,gBAAgB;;GAGxB,MAAM,UAAU,UAAqB;AACnC,QAAI,YAAY,QACd;AAEF,UAAM,gBAAgB;AACtB,mBAAe,UAAU;AACzB,kBAAc,MAAM;IAEpB,MAAM,WAAW,MAAM,cAAc;AAErC,QAAI,CAAC,YAAY,SAAS,WAAW,EACnC;IAGF,IAAI,QAAQ,MAAM,KAAK,SAAS,CAAC,QAAO,SACtC,cAAc,MAAM,UAAU,QAAQ,CACvC;AAED,QAAI,CAAC,YAAY,QACf,SAAQ,MAAM,MAAM,GAAG,EAAE;AAG3B,QAAI,MAAM,SAAS,EACjB,WAAU,UAAU,MAAM;;AAI9B,QAAK,iBAAiB,aAAa,YAAY;AAC/C,QAAK,iBAAiB,aAAa,YAAY;AAC/C,QAAK,iBAAiB,YAAY,WAAW;AAC7C,QAAK,iBAAiB,QAAQ,OAAO;AAErC,cAAW,gBAAgB;AACzB,SAAK,oBAAoB,aAAa,YAAY;AAClD,SAAK,oBAAoB,aAAa,YAAY;AAClD,SAAK,oBAAoB,YAAY,WAAW;AAChD,SAAK,oBAAoB,QAAQ,OAAO;AACxC,mBAAe,UAAU;;KAE1B,EAAE,CAAC;EAEY;EAAY"}
@@ -5,9 +5,10 @@ interface Options {
5
5
  }
6
6
  declare const useImage: (src: string, options?: Options) => {
7
7
  loading: boolean;
8
- error: string | Event | null;
8
+ error: Error | null;
9
9
  loaded: boolean;
10
10
  retry: () => void;
11
+ attemptCount: number;
11
12
  };
12
13
  //#endregion
13
14
  export { useImage };
@@ -26,11 +26,11 @@ const useImage = (src, options = {}) => {
26
26
  setLoaded(true);
27
27
  setError(null);
28
28
  };
29
- img.onerror = (err) => {
29
+ img.onerror = (event) => {
30
30
  if (cancelled) return;
31
31
  setLoading(false);
32
32
  setLoaded(false);
33
- setError(err);
33
+ setError(new Error(`Failed to load image: ${src}`, { cause: event }));
34
34
  if (attemptCount < retryCount) retryTimeoutId = setTimeout(() => {
35
35
  if (!cancelled) setAttemptCount((prev) => prev + 1);
36
36
  }, retryDelay);
@@ -55,7 +55,8 @@ const useImage = (src, options = {}) => {
55
55
  retry: useCallback(() => {
56
56
  setAttemptCount(0);
57
57
  setReloadToken((token) => token + 1);
58
- }, [])
58
+ }, []),
59
+ attemptCount
59
60
  };
60
61
  };
61
62
 
@@ -1 +1 @@
1
- {"version":3,"file":"use-image.mjs","names":[],"sources":["../../src/hooks/use-image.ts"],"sourcesContent":["import { useCallback, useEffect, useState } from 'react';\n\ninterface Options {\n retryCount?: number;\n retryDelay?: number;\n}\n\nconst useImage = (src: string, options: Options = {}) => {\n const { retryCount = 0, retryDelay = 1000 } = options;\n\n const [loading, setLoading] = useState(true);\n const [error, setError] = useState<string | Event | null>(null);\n const [loaded, setLoaded] = useState(false);\n const [attemptCount, setAttemptCount] = useState(0);\n const [reloadToken, setReloadToken] = useState(0);\n\n useEffect(() => {\n if (!src) {\n setLoading(false);\n setLoaded(false);\n return;\n }\n\n let cancelled = false;\n let retryTimeoutId: ReturnType<typeof setTimeout> | undefined;\n\n setLoading(true);\n setError(null);\n\n const img = new Image();\n img.src = src;\n\n img.onload = () => {\n if (cancelled) {\n return;\n }\n setLoading(false);\n setLoaded(true);\n setError(null);\n };\n\n img.onerror = err => {\n if (cancelled) {\n return;\n }\n setLoading(false);\n setLoaded(false);\n setError(err);\n\n if (attemptCount < retryCount) {\n retryTimeoutId = setTimeout(() => {\n if (!cancelled) {\n setAttemptCount(prev => prev + 1);\n }\n }, retryDelay);\n }\n };\n\n return () => {\n cancelled = true;\n img.onload = null;\n img.onerror = null;\n if (retryTimeoutId) {\n clearTimeout(retryTimeoutId);\n }\n };\n }, [src, attemptCount, retryCount, retryDelay, reloadToken]);\n\n const retry = useCallback(() => {\n setAttemptCount(0);\n setReloadToken(token => token + 1);\n }, []);\n\n return {\n loading,\n error,\n loaded,\n retry,\n };\n};\n\nexport default useImage;\n"],"mappings":";;;AAOA,MAAM,YAAY,KAAa,UAAmB,EAAE,KAAK;CACvD,MAAM,EAAE,aAAa,GAAG,aAAa,QAAS;CAE9C,MAAM,CAAC,SAAS,cAAc,SAAS,KAAK;CAC5C,MAAM,CAAC,OAAO,YAAY,SAAgC,KAAK;CAC/D,MAAM,CAAC,QAAQ,aAAa,SAAS,MAAM;CAC3C,MAAM,CAAC,cAAc,mBAAmB,SAAS,EAAE;CACnD,MAAM,CAAC,aAAa,kBAAkB,SAAS,EAAE;AAEjD,iBAAgB;AACd,MAAI,CAAC,KAAK;AACR,cAAW,MAAM;AACjB,aAAU,MAAM;AAChB;;EAGF,IAAI,YAAY;EAChB,IAAI;AAEJ,aAAW,KAAK;AAChB,WAAS,KAAK;EAEd,MAAM,MAAM,IAAI,OAAO;AACvB,MAAI,MAAM;AAEV,MAAI,eAAe;AACjB,OAAI,UACF;AAEF,cAAW,MAAM;AACjB,aAAU,KAAK;AACf,YAAS,KAAK;;AAGhB,MAAI,WAAU,QAAO;AACnB,OAAI,UACF;AAEF,cAAW,MAAM;AACjB,aAAU,MAAM;AAChB,YAAS,IAAI;AAEb,OAAI,eAAe,WACjB,kBAAiB,iBAAiB;AAChC,QAAI,CAAC,UACH,kBAAgB,SAAQ,OAAO,EAAE;MAElC,WAAW;;AAIlB,eAAa;AACX,eAAY;AACZ,OAAI,SAAS;AACb,OAAI,UAAU;AACd,OAAI,eACF,cAAa,eAAe;;IAG/B;EAAC;EAAK;EAAc;EAAY;EAAY;EAAY,CAAC;AAO5D,QAAO;EACL;EACA;EACA;EACA,OATY,kBAAkB;AAC9B,mBAAgB,EAAE;AAClB,mBAAe,UAAS,QAAQ,EAAE;KACjC,EAAE,CAAC;EAOL"}
1
+ {"version":3,"file":"use-image.mjs","names":[],"sources":["../../src/hooks/use-image.ts"],"sourcesContent":["import { useCallback, useEffect, useState } from 'react';\n\ninterface Options {\n retryCount?: number;\n retryDelay?: number;\n}\n\nconst useImage = (src: string, options: Options = {}) => {\n const { retryCount = 0, retryDelay = 1000 } = options;\n\n const [loading, setLoading] = useState(true);\n const [error, setError] = useState<Error | null>(null);\n const [loaded, setLoaded] = useState(false);\n const [attemptCount, setAttemptCount] = useState(0);\n const [reloadToken, setReloadToken] = useState(0);\n\n useEffect(() => {\n if (!src) {\n setLoading(false);\n setLoaded(false);\n return;\n }\n\n let cancelled = false;\n let retryTimeoutId: ReturnType<typeof setTimeout> | undefined;\n\n setLoading(true);\n setError(null);\n\n const img = new Image();\n img.src = src;\n\n img.onload = () => {\n if (cancelled) {\n return;\n }\n setLoading(false);\n setLoaded(true);\n setError(null);\n };\n\n img.onerror = event => {\n if (cancelled) {\n return;\n }\n setLoading(false);\n setLoaded(false);\n // `img.onerror`'s handler type is `OnErrorEventHandler`, so `event`\n // is typed `Event | string` even though the browser only ever\n // passes an `Event` here — that `Event` carries no useful failure\n // reason itself, so it's kept as `cause` rather than surfaced\n // directly as `error`.\n setError(new Error(`Failed to load image: ${src}`, { cause: event }));\n\n if (attemptCount < retryCount) {\n retryTimeoutId = setTimeout(() => {\n if (!cancelled) {\n setAttemptCount(prev => prev + 1);\n }\n }, retryDelay);\n }\n };\n\n return () => {\n cancelled = true;\n img.onload = null;\n img.onerror = null;\n if (retryTimeoutId) {\n clearTimeout(retryTimeoutId);\n }\n };\n }, [src, attemptCount, retryCount, retryDelay, reloadToken]);\n\n const retry = useCallback(() => {\n setAttemptCount(0);\n setReloadToken(token => token + 1);\n }, []);\n\n return {\n loading,\n error,\n loaded,\n retry,\n attemptCount,\n };\n};\n\nexport default useImage;\n"],"mappings":";;;AAOA,MAAM,YAAY,KAAa,UAAmB,EAAE,KAAK;CACvD,MAAM,EAAE,aAAa,GAAG,aAAa,QAAS;CAE9C,MAAM,CAAC,SAAS,cAAc,SAAS,KAAK;CAC5C,MAAM,CAAC,OAAO,YAAY,SAAuB,KAAK;CACtD,MAAM,CAAC,QAAQ,aAAa,SAAS,MAAM;CAC3C,MAAM,CAAC,cAAc,mBAAmB,SAAS,EAAE;CACnD,MAAM,CAAC,aAAa,kBAAkB,SAAS,EAAE;AAEjD,iBAAgB;AACd,MAAI,CAAC,KAAK;AACR,cAAW,MAAM;AACjB,aAAU,MAAM;AAChB;;EAGF,IAAI,YAAY;EAChB,IAAI;AAEJ,aAAW,KAAK;AAChB,WAAS,KAAK;EAEd,MAAM,MAAM,IAAI,OAAO;AACvB,MAAI,MAAM;AAEV,MAAI,eAAe;AACjB,OAAI,UACF;AAEF,cAAW,MAAM;AACjB,aAAU,KAAK;AACf,YAAS,KAAK;;AAGhB,MAAI,WAAU,UAAS;AACrB,OAAI,UACF;AAEF,cAAW,MAAM;AACjB,aAAU,MAAM;AAMhB,YAAS,IAAI,MAAM,yBAAyB,OAAO,EAAE,OAAO,OAAO,CAAC,CAAC;AAErE,OAAI,eAAe,WACjB,kBAAiB,iBAAiB;AAChC,QAAI,CAAC,UACH,kBAAgB,SAAQ,OAAO,EAAE;MAElC,WAAW;;AAIlB,eAAa;AACX,eAAY;AACZ,OAAI,SAAS;AACb,OAAI,UAAU;AACd,OAAI,eACF,cAAa,eAAe;;IAG/B;EAAC;EAAK;EAAc;EAAY;EAAY;EAAY,CAAC;AAO5D,QAAO;EACL;EACA;EACA;EACA,OATY,kBAAkB;AAC9B,mBAAgB,EAAE;AAClB,mBAAe,UAAS,QAAQ,EAAE;KACjC,EAAE,CAAC;EAOJ;EACD"}
@@ -1,5 +1,12 @@
1
1
  //#region src/hooks/use-intersection-observer.d.ts
2
- declare const useIntersectionObserver: <T extends Element = Element>(options?: IntersectionObserverInit) => [(node: T | null) => void, IntersectionObserverEntry | null];
2
+ interface Options extends IntersectionObserverInit {
3
+ freezeOnceVisible?: boolean;
4
+ }
5
+ interface Result {
6
+ entry: IntersectionObserverEntry | null;
7
+ isIntersecting: boolean;
8
+ }
9
+ declare const useIntersectionObserver: <T extends Element = Element>(options?: Options) => [(node: T | null) => void, Result];
3
10
  //#endregion
4
11
  export { useIntersectionObserver };
5
12
  //# sourceMappingURL=use-intersection-observer.d.mts.map
@@ -1,21 +1,53 @@
1
- import { useCallback, useRef, useState } from "react";
1
+ import { useCallback, useEffect, useRef, useState } from "react";
2
2
 
3
3
  //#region src/hooks/use-intersection-observer.ts
4
4
  const useIntersectionObserver = (options) => {
5
+ const { freezeOnceVisible = false, ...observerInit } = options ?? {};
5
6
  const [entry, setEntry] = useState(null);
6
7
  const observerRef = useRef(null);
7
- return [useCallback((node) => {
8
+ const nodeRef = useRef(null);
9
+ const frozenRef = useRef(false);
10
+ const observerInitKey = JSON.stringify(observerInit);
11
+ const observerInitRef = useRef(observerInit);
12
+ const freezeRef = useRef(freezeOnceVisible);
13
+ useEffect(() => {
14
+ observerInitRef.current = observerInit;
15
+ freezeRef.current = freezeOnceVisible;
16
+ });
17
+ const connect = useCallback(() => {
8
18
  if (observerRef.current) {
9
19
  observerRef.current.disconnect();
10
20
  observerRef.current = null;
11
21
  }
12
- if (!node || typeof IntersectionObserver === "undefined") return;
22
+ const node = nodeRef.current;
23
+ if (!node || typeof IntersectionObserver === "undefined" || frozenRef.current) return;
13
24
  const observer = new IntersectionObserver(([observedEntry]) => {
25
+ if (!observedEntry) return;
14
26
  setEntry(observedEntry);
15
- }, options);
27
+ if (observedEntry.isIntersecting && freezeRef.current) {
28
+ frozenRef.current = true;
29
+ observer.disconnect();
30
+ }
31
+ }, observerInitRef.current);
16
32
  observer.observe(node);
17
33
  observerRef.current = observer;
18
- }, []), entry];
34
+ }, []);
35
+ const ref = useCallback((node) => {
36
+ nodeRef.current = node;
37
+ connect();
38
+ }, []);
39
+ useEffect(() => {
40
+ connect();
41
+ }, [observerInitKey]);
42
+ useEffect(() => {
43
+ return () => {
44
+ observerRef.current?.disconnect();
45
+ };
46
+ }, []);
47
+ return [ref, {
48
+ entry,
49
+ isIntersecting: entry?.isIntersecting ?? false
50
+ }];
19
51
  };
20
52
 
21
53
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"use-intersection-observer.mjs","names":[],"sources":["../../src/hooks/use-intersection-observer.ts"],"sourcesContent":["import { useCallback, useRef, useState } from 'react';\n\nconst useIntersectionObserver = <T extends Element = Element>(\n options?: IntersectionObserverInit,\n): [(node: T | null) => void, IntersectionObserverEntry | null] => {\n const [entry, setEntry] = useState<IntersectionObserverEntry | null>(null);\n const observerRef = useRef<IntersectionObserver | null>(null);\n\n // `options` is typically re-created as a fresh object on every render by\n // callers (e.g. spreading caller-provided overrides into defaults), so it\n // intentionally isn't a dependency here — that would tear down and\n // recreate the observer on every render. The ref callback only re-runs\n // when the observed node itself changes, capturing whatever `options`\n // was current at that time (matching the common useIntersectionObserver\n // convention, e.g. @uidotdev/usehooks).\n const ref = useCallback((node: T | null) => {\n if (observerRef.current) {\n observerRef.current.disconnect();\n observerRef.current = null;\n }\n\n if (!node || typeof IntersectionObserver === 'undefined') {\n return;\n }\n\n const observer = new IntersectionObserver(([observedEntry]) => {\n setEntry(observedEntry);\n }, options);\n\n observer.observe(node);\n observerRef.current = observer;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n return [ref, entry];\n};\n\nexport default useIntersectionObserver;\n"],"mappings":";;;AAEA,MAAM,2BACJ,YACiE;CACjE,MAAM,CAAC,OAAO,YAAY,SAA2C,KAAK;CAC1E,MAAM,cAAc,OAAoC,KAAK;AA4B7D,QAAO,CAnBK,aAAa,SAAmB;AAC1C,MAAI,YAAY,SAAS;AACvB,eAAY,QAAQ,YAAY;AAChC,eAAY,UAAU;;AAGxB,MAAI,CAAC,QAAQ,OAAO,yBAAyB,YAC3C;EAGF,MAAM,WAAW,IAAI,sBAAsB,CAAC,mBAAmB;AAC7D,YAAS,cAAc;KACtB,QAAQ;AAEX,WAAS,QAAQ,KAAK;AACtB,cAAY,UAAU;IAErB,EAAE,CAAC,EAEO,MAAM"}
1
+ {"version":3,"file":"use-intersection-observer.mjs","names":[],"sources":["../../src/hooks/use-intersection-observer.ts"],"sourcesContent":["import { useCallback, useEffect, useRef, useState } from 'react';\n\ninterface Options extends IntersectionObserverInit {\n // Disconnects for good the first time the target becomes intersecting\n // — the common \"seen once, that's enough\" case (lazy loading, entrance\n // animations, infinite-scroll triggers) that otherwise needs the\n // consumer to track their own \"already fired\" flag.\n freezeOnceVisible?: boolean;\n}\n\ninterface Result {\n entry: IntersectionObserverEntry | null;\n isIntersecting: boolean;\n}\n\nconst useIntersectionObserver = <T extends Element = Element>(\n options?: Options,\n): [(node: T | null) => void, Result] => {\n const { freezeOnceVisible = false, ...observerInit } = options ?? {};\n\n const [entry, setEntry] = useState<IntersectionObserverEntry | null>(null);\n const observerRef = useRef<IntersectionObserver | null>(null);\n const nodeRef = useRef<T | null>(null);\n const frozenRef = useRef(false);\n\n // `options` is typically a fresh object literal at the call site —\n // serialize the IntersectionObserverInit part into a stable key so\n // reconnecting only happens when it actually changes, not on every\n // render (the previous version didn't reconnect on options changes at\n // all, so threshold/rootMargin could never be updated at runtime).\n const observerInitKey = JSON.stringify(observerInit);\n const observerInitRef = useRef(observerInit);\n const freezeRef = useRef(freezeOnceVisible);\n\n useEffect(() => {\n observerInitRef.current = observerInit;\n freezeRef.current = freezeOnceVisible;\n });\n\n const connect = useCallback(() => {\n if (observerRef.current) {\n observerRef.current.disconnect();\n observerRef.current = null;\n }\n\n const node = nodeRef.current;\n\n if (\n !node ||\n typeof IntersectionObserver === 'undefined' ||\n frozenRef.current\n ) {\n return;\n }\n\n const observer = new IntersectionObserver(([observedEntry]) => {\n if (!observedEntry) {\n return;\n }\n\n setEntry(observedEntry);\n\n if (observedEntry.isIntersecting && freezeRef.current) {\n frozenRef.current = true;\n observer.disconnect();\n }\n }, observerInitRef.current);\n\n observer.observe(node);\n observerRef.current = observer;\n }, []);\n\n const ref = useCallback((node: T | null) => {\n nodeRef.current = node;\n connect();\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n useEffect(() => {\n connect();\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [observerInitKey]);\n\n useEffect(() => {\n return () => {\n observerRef.current?.disconnect();\n };\n }, []);\n\n return [ref, { entry, isIntersecting: entry?.isIntersecting ?? false }];\n};\n\nexport default useIntersectionObserver;\n"],"mappings":";;;AAeA,MAAM,2BACJ,YACuC;CACvC,MAAM,EAAE,oBAAoB,OAAO,GAAG,iBAAiB,WAAW,EAAE;CAEpE,MAAM,CAAC,OAAO,YAAY,SAA2C,KAAK;CAC1E,MAAM,cAAc,OAAoC,KAAK;CAC7D,MAAM,UAAU,OAAiB,KAAK;CACtC,MAAM,YAAY,OAAO,MAAM;CAO/B,MAAM,kBAAkB,KAAK,UAAU,aAAa;CACpD,MAAM,kBAAkB,OAAO,aAAa;CAC5C,MAAM,YAAY,OAAO,kBAAkB;AAE3C,iBAAgB;AACd,kBAAgB,UAAU;AAC1B,YAAU,UAAU;GACpB;CAEF,MAAM,UAAU,kBAAkB;AAChC,MAAI,YAAY,SAAS;AACvB,eAAY,QAAQ,YAAY;AAChC,eAAY,UAAU;;EAGxB,MAAM,OAAO,QAAQ;AAErB,MACE,CAAC,QACD,OAAO,yBAAyB,eAChC,UAAU,QAEV;EAGF,MAAM,WAAW,IAAI,sBAAsB,CAAC,mBAAmB;AAC7D,OAAI,CAAC,cACH;AAGF,YAAS,cAAc;AAEvB,OAAI,cAAc,kBAAkB,UAAU,SAAS;AACrD,cAAU,UAAU;AACpB,aAAS,YAAY;;KAEtB,gBAAgB,QAAQ;AAE3B,WAAS,QAAQ,KAAK;AACtB,cAAY,UAAU;IACrB,EAAE,CAAC;CAEN,MAAM,MAAM,aAAa,SAAmB;AAC1C,UAAQ,UAAU;AAClB,WAAS;IAER,EAAE,CAAC;AAEN,iBAAgB;AACd,WAAS;IAER,CAAC,gBAAgB,CAAC;AAErB,iBAAgB;AACd,eAAa;AACX,eAAY,SAAS,YAAY;;IAElC,EAAE,CAAC;AAEN,QAAO,CAAC,KAAK;EAAE;EAAO,gBAAgB,OAAO,kBAAkB;EAAO,CAAC"}
@@ -0,0 +1,5 @@
1
+ //#region src/hooks/use-interval.d.ts
2
+ declare const useInterval: (callback: () => void, delay: number | null) => void;
3
+ //#endregion
4
+ export { useInterval };
5
+ //# sourceMappingURL=use-interval.d.mts.map
@@ -0,0 +1,20 @@
1
+ import { useEffect, useRef } from "react";
2
+
3
+ //#region src/hooks/use-interval.ts
4
+ const useInterval = (callback, delay) => {
5
+ const callbackRef = useRef(callback);
6
+ useEffect(() => {
7
+ callbackRef.current = callback;
8
+ });
9
+ useEffect(() => {
10
+ if (delay === null) return;
11
+ const id = setInterval(() => {
12
+ callbackRef.current();
13
+ }, delay);
14
+ return () => clearInterval(id);
15
+ }, [delay]);
16
+ };
17
+
18
+ //#endregion
19
+ export { useInterval as default };
20
+ //# sourceMappingURL=use-interval.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-interval.mjs","names":[],"sources":["../../src/hooks/use-interval.ts"],"sourcesContent":["import { useEffect, useRef } from 'react';\n\n// Dan Abramov's useInterval pattern: the callback lives in a ref so a\n// fresh function every render doesn't reset the interval — only `delay`\n// actually changing does that. `delay === null` pauses it (same rule as\n// useTimeout/useRecursiveTimeout); toggling back to a number resumes on\n// a fresh interval rather than trying to pick up mid-tick.\nconst useInterval = (callback: () => void, delay: number | null) => {\n const callbackRef = useRef(callback);\n\n useEffect(() => {\n callbackRef.current = callback;\n });\n\n useEffect(() => {\n if (delay === null) {\n return;\n }\n\n const id = setInterval(() => {\n callbackRef.current();\n }, delay);\n\n return () => clearInterval(id);\n }, [delay]);\n};\n\nexport default useInterval;\n"],"mappings":";;;AAOA,MAAM,eAAe,UAAsB,UAAyB;CAClE,MAAM,cAAc,OAAO,SAAS;AAEpC,iBAAgB;AACd,cAAY,UAAU;GACtB;AAEF,iBAAgB;AACd,MAAI,UAAU,KACZ;EAGF,MAAM,KAAK,kBAAkB;AAC3B,eAAY,SAAS;KACpB,MAAM;AAET,eAAa,cAAc,GAAG;IAC7B,CAAC,MAAM,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { RefObject } from "react";
2
+
3
+ //#region src/hooks/use-key-press.d.ts
4
+ type KeyPressTarget = RefObject<HTMLElement | null> | Window | Document | HTMLElement | null | undefined;
5
+ interface Options {
6
+ target?: KeyPressTarget;
7
+ enabled?: boolean;
8
+ preventDefault?: boolean;
9
+ ignore?: string;
10
+ }
11
+ declare const useKeyPress: (combo: string | string[], handler: (event: KeyboardEvent) => void, options?: Options) => void;
12
+ //#endregion
13
+ export { useKeyPress };
14
+ //# sourceMappingURL=use-key-press.d.mts.map
@@ -0,0 +1,63 @@
1
+ import { useEffect, useRef } from "react";
2
+
3
+ //#region src/hooks/use-key-press.ts
4
+ const isMac = () => typeof navigator !== "undefined" && /Mac|iPhone|iPad|iPod/.test(navigator.userAgent);
5
+ const parseCombo = (combo) => {
6
+ const parts = combo.split("+").map((part) => part.trim().toLowerCase());
7
+ const key = parts[parts.length - 1] ?? "";
8
+ const modifiers = parts.slice(0, -1);
9
+ let ctrl = modifiers.includes("ctrl");
10
+ let meta = modifiers.includes("meta") || modifiers.includes("cmd");
11
+ const shift = modifiers.includes("shift");
12
+ const alt = modifiers.includes("alt") || modifiers.includes("option");
13
+ if (modifiers.includes("mod")) if (isMac()) meta = true;
14
+ else ctrl = true;
15
+ return {
16
+ key,
17
+ ctrl,
18
+ meta,
19
+ shift,
20
+ alt
21
+ };
22
+ };
23
+ const matchesCombo = (event, combo) => event.key.toLowerCase() === combo.key && event.ctrlKey === combo.ctrl && event.metaKey === combo.meta && event.shiftKey === combo.shift && event.altKey === combo.alt;
24
+ const resolveTarget = (target) => {
25
+ if (!target) return typeof window === "undefined" ? null : window;
26
+ return "current" in target ? target.current : target;
27
+ };
28
+ const useKeyPress = (combo, handler, options = {}) => {
29
+ const { target, enabled = true, preventDefault = false, ignore } = options;
30
+ const handlerRef = useRef(handler);
31
+ useEffect(() => {
32
+ handlerRef.current = handler;
33
+ });
34
+ const combos = Array.isArray(combo) ? combo : [combo];
35
+ const parsedCombos = combos.map(parseCombo);
36
+ useEffect(() => {
37
+ if (!enabled) return;
38
+ const resolvedTarget = resolveTarget(target);
39
+ if (!resolvedTarget) return;
40
+ const onKeyDown = (event) => {
41
+ const keyboardEvent = event;
42
+ const eventTarget = keyboardEvent.target;
43
+ if (ignore && eventTarget?.closest(ignore)) return;
44
+ if (!parsedCombos.some((parsed) => matchesCombo(keyboardEvent, parsed))) return;
45
+ if (preventDefault) keyboardEvent.preventDefault();
46
+ handlerRef.current(keyboardEvent);
47
+ };
48
+ resolvedTarget.addEventListener("keydown", onKeyDown);
49
+ return () => {
50
+ resolvedTarget.removeEventListener("keydown", onKeyDown);
51
+ };
52
+ }, [
53
+ enabled,
54
+ combos.join(","),
55
+ target,
56
+ preventDefault,
57
+ ignore
58
+ ]);
59
+ };
60
+
61
+ //#endregion
62
+ export { useKeyPress as default };
63
+ //# sourceMappingURL=use-key-press.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-key-press.mjs","names":[],"sources":["../../src/hooks/use-key-press.ts"],"sourcesContent":["import { type RefObject, useEffect, useRef } from 'react';\n\ntype KeyPressTarget =\n | RefObject<HTMLElement | null>\n | Window\n | Document\n | HTMLElement\n | null\n | undefined;\n\ninterface Options {\n target?: KeyPressTarget;\n enabled?: boolean;\n preventDefault?: boolean;\n // CSS selector — a keydown whose target is inside a matching element is\n // ignored (e.g. don't hijack Cmd+Z while the user is typing in a code\n // editor that has its own undo).\n ignore?: string;\n}\n\ninterface ParsedCombo {\n key: string;\n ctrl: boolean;\n meta: boolean;\n shift: boolean;\n alt: boolean;\n}\n\nconst isMac = () =>\n typeof navigator !== 'undefined' &&\n /Mac|iPhone|iPad|iPod/.test(navigator.userAgent);\n\n// `mod` normalizes to the platform's usual \"primary\" modifier (Cmd on\n// macOS, Ctrl elsewhere) so a single combo string covers both without the\n// caller branching on platform themselves.\nconst parseCombo = (combo: string): ParsedCombo => {\n const parts = combo.split('+').map(part => part.trim().toLowerCase());\n const key = parts[parts.length - 1] ?? '';\n const modifiers = parts.slice(0, -1);\n\n let ctrl = modifiers.includes('ctrl');\n let meta = modifiers.includes('meta') || modifiers.includes('cmd');\n const shift = modifiers.includes('shift');\n const alt = modifiers.includes('alt') || modifiers.includes('option');\n\n if (modifiers.includes('mod')) {\n if (isMac()) {\n meta = true;\n } else {\n ctrl = true;\n }\n }\n\n return { key, ctrl, meta, shift, alt };\n};\n\n// Modifiers not named in the combo are required to be *absent*, not just\n// ignored — otherwise 'mod+z' and 'mod+shift+z' registered as separate\n// bindings (the exact motivating case for this hook) would both fire on\n// the same Cmd+Shift+Z keypress instead of only the latter.\nconst matchesCombo = (event: KeyboardEvent, combo: ParsedCombo) =>\n event.key.toLowerCase() === combo.key &&\n event.ctrlKey === combo.ctrl &&\n event.metaKey === combo.meta &&\n event.shiftKey === combo.shift &&\n event.altKey === combo.alt;\n\nconst resolveTarget = (target: KeyPressTarget): EventTarget | null => {\n if (!target) {\n return typeof window === 'undefined' ? null : window;\n }\n return 'current' in target ? target.current : target;\n};\n\nconst useKeyPress = (\n combo: string | string[],\n handler: (event: KeyboardEvent) => void,\n options: Options = {},\n) => {\n const { target, enabled = true, preventDefault = false, ignore } = options;\n\n const handlerRef = useRef(handler);\n\n useEffect(() => {\n handlerRef.current = handler;\n });\n\n const combos = Array.isArray(combo) ? combo : [combo];\n const parsedCombos = combos.map(parseCombo);\n // `combos` is typically a fresh array literal at the call site — depend\n // on a stable string proxy instead so this doesn't tear down and\n // re-register the listener on every render. `target` itself (a\n // RefObject, or window/document/an element variable) is normally\n // already stable across renders, so it's used directly below.\n const comboKey = combos.join(',');\n\n useEffect(() => {\n if (!enabled) {\n return;\n }\n\n const resolvedTarget = resolveTarget(target);\n\n if (!resolvedTarget) {\n return;\n }\n\n const onKeyDown = (event: Event) => {\n const keyboardEvent = event as KeyboardEvent;\n const eventTarget = keyboardEvent.target as HTMLElement | null;\n\n if (ignore && eventTarget?.closest(ignore)) {\n return;\n }\n\n if (!parsedCombos.some(parsed => matchesCombo(keyboardEvent, parsed))) {\n return;\n }\n\n if (preventDefault) {\n keyboardEvent.preventDefault();\n }\n\n handlerRef.current(keyboardEvent);\n };\n\n resolvedTarget.addEventListener('keydown', onKeyDown);\n\n return () => {\n resolvedTarget.removeEventListener('keydown', onKeyDown);\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [enabled, comboKey, target, preventDefault, ignore]);\n};\n\nexport default useKeyPress;\n"],"mappings":";;;AA4BA,MAAM,cACJ,OAAO,cAAc,eACrB,uBAAuB,KAAK,UAAU,UAAU;AAKlD,MAAM,cAAc,UAA+B;CACjD,MAAM,QAAQ,MAAM,MAAM,IAAI,CAAC,KAAI,SAAQ,KAAK,MAAM,CAAC,aAAa,CAAC;CACrE,MAAM,MAAM,MAAM,MAAM,SAAS,MAAM;CACvC,MAAM,YAAY,MAAM,MAAM,GAAG,GAAG;CAEpC,IAAI,OAAO,UAAU,SAAS,OAAO;CACrC,IAAI,OAAO,UAAU,SAAS,OAAO,IAAI,UAAU,SAAS,MAAM;CAClE,MAAM,QAAQ,UAAU,SAAS,QAAQ;CACzC,MAAM,MAAM,UAAU,SAAS,MAAM,IAAI,UAAU,SAAS,SAAS;AAErE,KAAI,UAAU,SAAS,MAAM,CAC3B,KAAI,OAAO,CACT,QAAO;KAEP,QAAO;AAIX,QAAO;EAAE;EAAK;EAAM;EAAM;EAAO;EAAK;;AAOxC,MAAM,gBAAgB,OAAsB,UAC1C,MAAM,IAAI,aAAa,KAAK,MAAM,OAClC,MAAM,YAAY,MAAM,QACxB,MAAM,YAAY,MAAM,QACxB,MAAM,aAAa,MAAM,SACzB,MAAM,WAAW,MAAM;AAEzB,MAAM,iBAAiB,WAA+C;AACpE,KAAI,CAAC,OACH,QAAO,OAAO,WAAW,cAAc,OAAO;AAEhD,QAAO,aAAa,SAAS,OAAO,UAAU;;AAGhD,MAAM,eACJ,OACA,SACA,UAAmB,EAAE,KAClB;CACH,MAAM,EAAE,QAAQ,UAAU,MAAM,iBAAiB,OAAO,WAAW;CAEnE,MAAM,aAAa,OAAO,QAAQ;AAElC,iBAAgB;AACd,aAAW,UAAU;GACrB;CAEF,MAAM,SAAS,MAAM,QAAQ,MAAM,GAAG,QAAQ,CAAC,MAAM;CACrD,MAAM,eAAe,OAAO,IAAI,WAAW;AAQ3C,iBAAgB;AACd,MAAI,CAAC,QACH;EAGF,MAAM,iBAAiB,cAAc,OAAO;AAE5C,MAAI,CAAC,eACH;EAGF,MAAM,aAAa,UAAiB;GAClC,MAAM,gBAAgB;GACtB,MAAM,cAAc,cAAc;AAElC,OAAI,UAAU,aAAa,QAAQ,OAAO,CACxC;AAGF,OAAI,CAAC,aAAa,MAAK,WAAU,aAAa,eAAe,OAAO,CAAC,CACnE;AAGF,OAAI,eACF,eAAc,gBAAgB;AAGhC,cAAW,QAAQ,cAAc;;AAGnC,iBAAe,iBAAiB,WAAW,UAAU;AAErD,eAAa;AACX,kBAAe,oBAAoB,WAAW,UAAU;;IAGzD;EAAC;EAtCa,OAAO,KAAK,IAAI;EAsCV;EAAQ;EAAgB;EAAO,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { RefObject } from "react";
2
+
3
+ //#region src/hooks/use-merged-ref.d.ts
4
+ type MergeableRef<T> = ((node: T | null) => void | (() => void)) | RefObject<T | null> | null | undefined;
5
+ declare const useMergedRef: <T>(...refs: MergeableRef<T>[]) => (node: T | null) => (() => void) | undefined;
6
+ //#endregion
7
+ export { useMergedRef };
8
+ //# sourceMappingURL=use-merged-ref.d.mts.map
@@ -0,0 +1,25 @@
1
+ import { useCallback } from "react";
2
+
3
+ //#region src/hooks/use-merged-ref.ts
4
+ const useMergedRef = (...refs) => {
5
+ return useCallback((node) => {
6
+ const cleanups = [];
7
+ refs.forEach((ref) => {
8
+ if (!ref) return;
9
+ if (typeof ref === "function") {
10
+ const cleanup = ref(node);
11
+ if (typeof cleanup === "function") cleanups.push(cleanup);
12
+ return;
13
+ }
14
+ ref.current = node;
15
+ });
16
+ if (cleanups.length === 0) return;
17
+ return () => {
18
+ cleanups.forEach((cleanup) => cleanup());
19
+ };
20
+ }, refs);
21
+ };
22
+
23
+ //#endregion
24
+ export { useMergedRef as default };
25
+ //# sourceMappingURL=use-merged-ref.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-merged-ref.mjs","names":[],"sources":["../../src/hooks/use-merged-ref.ts"],"sourcesContent":["import { type RefObject, useCallback } from 'react';\n\ntype MergeableRef<T> =\n | ((node: T | null) => void | (() => void))\n | RefObject<T | null>\n | null\n | undefined;\n\n// Merges any number of refs (forwarded function refs, RefObjects, or\n// either left null/undefined) into one callback ref that updates all of\n// them. Collects React 19's optional per-ref cleanup return values and\n// runs them together when the node detaches.\nconst useMergedRef = <T>(...refs: MergeableRef<T>[]) => {\n return useCallback((node: T | null) => {\n const cleanups: (() => void)[] = [];\n\n refs.forEach(ref => {\n if (!ref) {\n return;\n }\n\n if (typeof ref === 'function') {\n const cleanup = ref(node);\n\n if (typeof cleanup === 'function') {\n cleanups.push(cleanup);\n }\n return;\n }\n\n ref.current = node;\n });\n\n if (cleanups.length === 0) {\n return;\n }\n\n return () => {\n cleanups.forEach(cleanup => cleanup());\n };\n // The number of refs passed at a given call site is stable across\n // renders even though this array literal isn't — same pattern every\n // ref-merging hook of this shape relies on.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, refs);\n};\n\nexport default useMergedRef;\n"],"mappings":";;;AAYA,MAAM,gBAAmB,GAAG,SAA4B;AACtD,QAAO,aAAa,SAAmB;EACrC,MAAM,WAA2B,EAAE;AAEnC,OAAK,SAAQ,QAAO;AAClB,OAAI,CAAC,IACH;AAGF,OAAI,OAAO,QAAQ,YAAY;IAC7B,MAAM,UAAU,IAAI,KAAK;AAEzB,QAAI,OAAO,YAAY,WACrB,UAAS,KAAK,QAAQ;AAExB;;AAGF,OAAI,UAAU;IACd;AAEF,MAAI,SAAS,WAAW,EACtB;AAGF,eAAa;AACX,YAAS,SAAQ,YAAW,SAAS,CAAC;;IAMvC,KAAK"}
@@ -1,4 +1,4 @@
1
- import { useCallback, useMemo, useState } from "react";
1
+ import { useCallback, useEffect, useMemo, useState } from "react";
2
2
 
3
3
  //#region src/hooks/use-multi-select.ts
4
4
  const useMultiSelect = (count) => {
@@ -8,27 +8,36 @@ const useMultiSelect = (count) => {
8
8
  const next = new Set([...rawSelected].filter((index) => index < count));
9
9
  return next.size === rawSelected.size ? rawSelected : next;
10
10
  }, [rawSelected, count]);
11
+ useEffect(() => {
12
+ setRawSelected((prev) => {
13
+ const next = new Set([...prev].filter((index) => index < count));
14
+ return next.size === prev.size ? prev : next;
15
+ });
16
+ setAnchor((prev) => prev !== null && prev >= count ? null : prev);
17
+ }, [count]);
11
18
  const toggle = useCallback((index, shiftKey = false) => {
19
+ if (index < 0 || index >= count) return;
12
20
  setRawSelected((prev) => {
13
- const next = new Set(prev);
14
21
  if (shiftKey && anchor !== null) {
15
22
  const [start, end] = anchor < index ? [anchor, index] : [index, anchor];
23
+ const next = /* @__PURE__ */ new Set();
16
24
  for (let i = start; i <= end; i++) next.add(i);
17
25
  return next;
18
26
  }
27
+ const next = new Set(prev);
19
28
  if (next.has(index)) next.delete(index);
20
29
  else next.add(index);
21
30
  return next;
22
31
  });
23
32
  setAnchor(index);
24
- }, [anchor]);
33
+ }, [anchor, count]);
25
34
  const clear = useCallback(() => {
26
35
  setRawSelected(/* @__PURE__ */ new Set());
27
36
  setAnchor(null);
28
37
  }, []);
29
38
  const replace = useCallback((indices) => {
30
- setRawSelected(indices);
31
- }, []);
39
+ setRawSelected(new Set([...indices].filter((index) => index >= 0 && index < count)));
40
+ }, [count]);
32
41
  return {
33
42
  selected,
34
43
  isSelected: useCallback((index) => selected.has(index), [selected]),
@@ -1 +1 @@
1
- {"version":3,"file":"use-multi-select.mjs","names":[],"sources":["../../src/hooks/use-multi-select.ts"],"sourcesContent":["import { useCallback, useMemo, useState } from 'react';\n\nconst useMultiSelect = (count: number) => {\n const [rawSelected, setRawSelected] = useState<Set<number>>(new Set());\n const [anchor, setAnchor] = useState<number | null>(null);\n\n // Indices can outlive the item they pointed to (e.g. after the backing\n // list shrinks) — clamp against the current count on every render\n // instead of syncing state back via an effect.\n const selected = useMemo(() => {\n const next = new Set([...rawSelected].filter(index => index < count));\n return next.size === rawSelected.size ? rawSelected : next;\n }, [rawSelected, count]);\n\n const toggle = useCallback(\n (index: number, shiftKey = false) => {\n setRawSelected(prev => {\n const next = new Set(prev);\n\n if (shiftKey && anchor !== null) {\n const [start, end] =\n anchor < index ? [anchor, index] : [index, anchor];\n\n for (let i = start; i <= end; i++) {\n next.add(i);\n }\n return next;\n }\n\n if (next.has(index)) {\n next.delete(index);\n } else {\n next.add(index);\n }\n return next;\n });\n setAnchor(index);\n },\n [anchor],\n );\n\n const clear = useCallback(() => {\n setRawSelected(new Set());\n setAnchor(null);\n }, []);\n\n const replace = useCallback((indices: Set<number>) => {\n setRawSelected(indices);\n }, []);\n\n const isSelected = useCallback(\n (index: number) => selected.has(index),\n [selected],\n );\n\n return {\n selected,\n isSelected,\n toggle,\n clear,\n replace,\n } as const;\n};\n\nexport default useMultiSelect;\n"],"mappings":";;;AAEA,MAAM,kBAAkB,UAAkB;CACxC,MAAM,CAAC,aAAa,kBAAkB,yBAAsB,IAAI,KAAK,CAAC;CACtE,MAAM,CAAC,QAAQ,aAAa,SAAwB,KAAK;CAKzD,MAAM,WAAW,cAAc;EAC7B,MAAM,OAAO,IAAI,IAAI,CAAC,GAAG,YAAY,CAAC,QAAO,UAAS,QAAQ,MAAM,CAAC;AACrE,SAAO,KAAK,SAAS,YAAY,OAAO,cAAc;IACrD,CAAC,aAAa,MAAM,CAAC;CAExB,MAAM,SAAS,aACZ,OAAe,WAAW,UAAU;AACnC,kBAAe,SAAQ;GACrB,MAAM,OAAO,IAAI,IAAI,KAAK;AAE1B,OAAI,YAAY,WAAW,MAAM;IAC/B,MAAM,CAAC,OAAO,OACZ,SAAS,QAAQ,CAAC,QAAQ,MAAM,GAAG,CAAC,OAAO,OAAO;AAEpD,SAAK,IAAI,IAAI,OAAO,KAAK,KAAK,IAC5B,MAAK,IAAI,EAAE;AAEb,WAAO;;AAGT,OAAI,KAAK,IAAI,MAAM,CACjB,MAAK,OAAO,MAAM;OAElB,MAAK,IAAI,MAAM;AAEjB,UAAO;IACP;AACF,YAAU,MAAM;IAElB,CAAC,OAAO,CACT;CAED,MAAM,QAAQ,kBAAkB;AAC9B,iCAAe,IAAI,KAAK,CAAC;AACzB,YAAU,KAAK;IACd,EAAE,CAAC;CAEN,MAAM,UAAU,aAAa,YAAyB;AACpD,iBAAe,QAAQ;IACtB,EAAE,CAAC;AAON,QAAO;EACL;EACA,YAPiB,aAChB,UAAkB,SAAS,IAAI,MAAM,EACtC,CAAC,SAAS,CACX;EAKC;EACA;EACA;EACD"}
1
+ {"version":3,"file":"use-multi-select.mjs","names":[],"sources":["../../src/hooks/use-multi-select.ts"],"sourcesContent":["import { useCallback, useEffect, useMemo, useState } from 'react';\n\nconst useMultiSelect = (count: number) => {\n const [rawSelected, setRawSelected] = useState<Set<number>>(new Set());\n const [anchor, setAnchor] = useState<number | null>(null);\n\n const selected = useMemo(() => {\n const next = new Set([...rawSelected].filter(index => index < count));\n return next.size === rawSelected.size ? rawSelected : next;\n }, [rawSelected, count]);\n\n // Clamp `rawSelected`/`anchor` themselves (not just the derived\n // `selected` view above) whenever `count` shrinks — otherwise\n // out-of-range indices and a stale anchor keep accumulating in state\n // indefinitely instead of actually being dropped.\n useEffect(() => {\n setRawSelected(prev => {\n const next = new Set([...prev].filter(index => index < count));\n return next.size === prev.size ? prev : next;\n });\n setAnchor(prev => (prev !== null && prev >= count ? null : prev));\n }, [count]);\n\n const toggle = useCallback(\n (index: number, shiftKey = false) => {\n if (index < 0 || index >= count) {\n return;\n }\n\n setRawSelected(prev => {\n if (shiftKey && anchor !== null) {\n const [start, end] =\n anchor < index ? [anchor, index] : [index, anchor];\n\n // Range-select replaces the previous selection, matching the\n // usual file-explorer/table convention, instead of adding to\n // it — otherwise repeated shift-clicks just accumulate every\n // range ever selected rather than re-anchoring to the new one.\n const next = new Set<number>();\n for (let i = start; i <= end; i++) {\n next.add(i);\n }\n return next;\n }\n\n const next = new Set(prev);\n if (next.has(index)) {\n next.delete(index);\n } else {\n next.add(index);\n }\n return next;\n });\n setAnchor(index);\n },\n [anchor, count],\n );\n\n const clear = useCallback(() => {\n setRawSelected(new Set());\n setAnchor(null);\n }, []);\n\n const replace = useCallback(\n (indices: Set<number>) => {\n setRawSelected(\n new Set([...indices].filter(index => index >= 0 && index < count)),\n );\n },\n [count],\n );\n\n const isSelected = useCallback(\n (index: number) => selected.has(index),\n [selected],\n );\n\n return {\n selected,\n isSelected,\n toggle,\n clear,\n replace,\n } as const;\n};\n\nexport default useMultiSelect;\n"],"mappings":";;;AAEA,MAAM,kBAAkB,UAAkB;CACxC,MAAM,CAAC,aAAa,kBAAkB,yBAAsB,IAAI,KAAK,CAAC;CACtE,MAAM,CAAC,QAAQ,aAAa,SAAwB,KAAK;CAEzD,MAAM,WAAW,cAAc;EAC7B,MAAM,OAAO,IAAI,IAAI,CAAC,GAAG,YAAY,CAAC,QAAO,UAAS,QAAQ,MAAM,CAAC;AACrE,SAAO,KAAK,SAAS,YAAY,OAAO,cAAc;IACrD,CAAC,aAAa,MAAM,CAAC;AAMxB,iBAAgB;AACd,kBAAe,SAAQ;GACrB,MAAM,OAAO,IAAI,IAAI,CAAC,GAAG,KAAK,CAAC,QAAO,UAAS,QAAQ,MAAM,CAAC;AAC9D,UAAO,KAAK,SAAS,KAAK,OAAO,OAAO;IACxC;AACF,aAAU,SAAS,SAAS,QAAQ,QAAQ,QAAQ,OAAO,KAAM;IAChE,CAAC,MAAM,CAAC;CAEX,MAAM,SAAS,aACZ,OAAe,WAAW,UAAU;AACnC,MAAI,QAAQ,KAAK,SAAS,MACxB;AAGF,kBAAe,SAAQ;AACrB,OAAI,YAAY,WAAW,MAAM;IAC/B,MAAM,CAAC,OAAO,OACZ,SAAS,QAAQ,CAAC,QAAQ,MAAM,GAAG,CAAC,OAAO,OAAO;IAMpD,MAAM,uBAAO,IAAI,KAAa;AAC9B,SAAK,IAAI,IAAI,OAAO,KAAK,KAAK,IAC5B,MAAK,IAAI,EAAE;AAEb,WAAO;;GAGT,MAAM,OAAO,IAAI,IAAI,KAAK;AAC1B,OAAI,KAAK,IAAI,MAAM,CACjB,MAAK,OAAO,MAAM;OAElB,MAAK,IAAI,MAAM;AAEjB,UAAO;IACP;AACF,YAAU,MAAM;IAElB,CAAC,QAAQ,MAAM,CAChB;CAED,MAAM,QAAQ,kBAAkB;AAC9B,iCAAe,IAAI,KAAK,CAAC;AACzB,YAAU,KAAK;IACd,EAAE,CAAC;CAEN,MAAM,UAAU,aACb,YAAyB;AACxB,iBACE,IAAI,IAAI,CAAC,GAAG,QAAQ,CAAC,QAAO,UAAS,SAAS,KAAK,QAAQ,MAAM,CAAC,CACnE;IAEH,CAAC,MAAM,CACR;AAOD,QAAO;EACL;EACA,YAPiB,aAChB,UAAkB,SAAS,IAAI,MAAM,EACtC,CAAC,SAAS,CACX;EAKC;EACA;EACA;EACD"}
@@ -0,0 +1,11 @@
1
+ import { RefObject } from "react";
2
+
3
+ //#region src/hooks/use-mutation-observer.d.ts
4
+ type Target<T extends Node> = RefObject<T | null> | T | null | undefined;
5
+ interface Options extends MutationObserverInit {
6
+ enabled?: boolean;
7
+ }
8
+ declare const useMutationObserver: <T extends Node>(target: Target<T>, callback: MutationCallback, options?: Options) => void;
9
+ //#endregion
10
+ export { useMutationObserver };
11
+ //# sourceMappingURL=use-mutation-observer.d.mts.map
@@ -0,0 +1,33 @@
1
+ import { useEffect, useRef } from "react";
2
+
3
+ //#region src/hooks/use-mutation-observer.ts
4
+ const resolveTarget = (target) => {
5
+ if (!target) return null;
6
+ return "current" in target ? target.current : target;
7
+ };
8
+ const useMutationObserver = (target, callback, options = {}) => {
9
+ const { enabled = true, ...mutationOptions } = options;
10
+ const callbackRef = useRef(callback);
11
+ useEffect(() => {
12
+ callbackRef.current = callback;
13
+ });
14
+ useEffect(() => {
15
+ const node = resolveTarget(target);
16
+ if (!enabled || !node || typeof MutationObserver === "undefined") return;
17
+ const observer = new MutationObserver((mutations, obs) => {
18
+ callbackRef.current(mutations, obs);
19
+ });
20
+ observer.observe(node, mutationOptions);
21
+ return () => {
22
+ observer.disconnect();
23
+ };
24
+ }, [
25
+ target,
26
+ enabled,
27
+ JSON.stringify(mutationOptions)
28
+ ]);
29
+ };
30
+
31
+ //#endregion
32
+ export { useMutationObserver as default };
33
+ //# sourceMappingURL=use-mutation-observer.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-mutation-observer.mjs","names":[],"sources":["../../src/hooks/use-mutation-observer.ts"],"sourcesContent":["import { type RefObject, useEffect, useRef } from 'react';\n\ntype Target<T extends Node> = RefObject<T | null> | T | null | undefined;\n\ninterface Options extends MutationObserverInit {\n enabled?: boolean;\n}\n\nconst resolveTarget = <T extends Node>(target: Target<T>): T | null => {\n if (!target) {\n return null;\n }\n return 'current' in target ? target.current : target;\n};\n\n// Takes the target directly (a RefObject, or a plain Node like\n// document.head that isn't behind any React ref at all) rather than\n// producing its own — this and useResizeObserver together replace the\n// ResizeObserver+MutationObserver pair live-editor's iframe hand-rolls\n// for auto-sizing its preview content.\nconst useMutationObserver = <T extends Node>(\n target: Target<T>,\n callback: MutationCallback,\n options: Options = {},\n) => {\n const { enabled = true, ...mutationOptions } = options;\n\n const callbackRef = useRef(callback);\n\n useEffect(() => {\n callbackRef.current = callback;\n });\n\n // `mutationOptions` is typically a fresh object literal at the call\n // site — serialize it into a stable key instead of depending on the\n // object itself, which would tear down and recreate the observer on\n // every render.\n const optionsKey = JSON.stringify(mutationOptions);\n\n useEffect(() => {\n const node = resolveTarget(target);\n\n if (!enabled || !node || typeof MutationObserver === 'undefined') {\n return;\n }\n\n const observer = new MutationObserver((mutations, obs) => {\n callbackRef.current(mutations, obs);\n });\n\n observer.observe(node, mutationOptions);\n\n return () => {\n observer.disconnect();\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [target, enabled, optionsKey]);\n};\n\nexport default useMutationObserver;\n"],"mappings":";;;AAQA,MAAM,iBAAiC,WAAgC;AACrE,KAAI,CAAC,OACH,QAAO;AAET,QAAO,aAAa,SAAS,OAAO,UAAU;;AAQhD,MAAM,uBACJ,QACA,UACA,UAAmB,EAAE,KAClB;CACH,MAAM,EAAE,UAAU,MAAM,GAAG,oBAAoB;CAE/C,MAAM,cAAc,OAAO,SAAS;AAEpC,iBAAgB;AACd,cAAY,UAAU;GACtB;AAQF,iBAAgB;EACd,MAAM,OAAO,cAAc,OAAO;AAElC,MAAI,CAAC,WAAW,CAAC,QAAQ,OAAO,qBAAqB,YACnD;EAGF,MAAM,WAAW,IAAI,kBAAkB,WAAW,QAAQ;AACxD,eAAY,QAAQ,WAAW,IAAI;IACnC;AAEF,WAAS,QAAQ,MAAM,gBAAgB;AAEvC,eAAa;AACX,YAAS,YAAY;;IAGtB;EAAC;EAAQ;EAnBO,KAAK,UAAU,gBAAgB;EAmBlB,CAAC"}
@@ -0,0 +1,5 @@
1
+ //#region src/hooks/use-previous.d.ts
2
+ declare const usePrevious: <T>(value: T) => T | undefined;
3
+ //#endregion
4
+ export { usePrevious };
5
+ //# sourceMappingURL=use-previous.d.mts.map
@@ -0,0 +1,14 @@
1
+ import { useEffect, useRef } from "react";
2
+
3
+ //#region src/hooks/use-previous.ts
4
+ const usePrevious = (value) => {
5
+ const ref = useRef(void 0);
6
+ useEffect(() => {
7
+ ref.current = value;
8
+ });
9
+ return ref.current;
10
+ };
11
+
12
+ //#endregion
13
+ export { usePrevious as default };
14
+ //# sourceMappingURL=use-previous.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-previous.mjs","names":[],"sources":["../../src/hooks/use-previous.ts"],"sourcesContent":["import { useEffect, useRef } from 'react';\n\n// Returns the value from the *previous* render. Updated in an effect\n// (which runs after render/paint) rather than during render, so the\n// current render still reads whatever was current one render ago.\nconst usePrevious = <T>(value: T): T | undefined => {\n const ref = useRef<T | undefined>(undefined);\n\n useEffect(() => {\n ref.current = value;\n });\n\n return ref.current;\n};\n\nexport default usePrevious;\n"],"mappings":";;;AAKA,MAAM,eAAkB,UAA4B;CAClD,MAAM,MAAM,OAAsB,OAAU;AAE5C,iBAAgB;AACd,MAAI,UAAU;GACd;AAEF,QAAO,IAAI"}
@@ -0,0 +1,12 @@
1
+ //#region src/hooks/use-resize-observer.d.ts
2
+ interface Size {
3
+ width: number;
4
+ height: number;
5
+ }
6
+ interface Options {
7
+ box?: ResizeObserverBoxOptions;
8
+ }
9
+ declare const useResizeObserver: <T extends Element = Element>(options?: Options) => [(node: T | null) => void, Size | null];
10
+ //#endregion
11
+ export { useResizeObserver };
12
+ //# sourceMappingURL=use-resize-observer.d.mts.map
@@ -0,0 +1,29 @@
1
+ import { useCallback, useRef, useState } from "react";
2
+
3
+ //#region src/hooks/use-resize-observer.ts
4
+ const useResizeObserver = (options) => {
5
+ const [size, setSize] = useState(null);
6
+ const observerRef = useRef(null);
7
+ return [useCallback((node) => {
8
+ if (observerRef.current) {
9
+ observerRef.current.disconnect();
10
+ observerRef.current = null;
11
+ }
12
+ if (!node || typeof ResizeObserver === "undefined") return;
13
+ const box = options?.box ?? "content-box";
14
+ const observer = new ResizeObserver(([entry]) => {
15
+ if (!entry) return;
16
+ const [{ inlineSize, blockSize }] = box === "border-box" ? entry.borderBoxSize : entry.contentBoxSize;
17
+ setSize({
18
+ width: inlineSize,
19
+ height: blockSize
20
+ });
21
+ });
22
+ observer.observe(node, { box });
23
+ observerRef.current = observer;
24
+ }, []), size];
25
+ };
26
+
27
+ //#endregion
28
+ export { useResizeObserver as default };
29
+ //# sourceMappingURL=use-resize-observer.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-resize-observer.mjs","names":[],"sources":["../../src/hooks/use-resize-observer.ts"],"sourcesContent":["import { useCallback, useRef, useState } from 'react';\n\ninterface Size {\n width: number;\n height: number;\n}\n\ninterface Options {\n box?: ResizeObserverBoxOptions;\n}\n\n// The unprocessed version of useResponsiveSize/useElementScroll/\n// useElementPosition — those each return values shaped for their own\n// purpose (breakpoints, scroll position, a viewport-relative DOMRect).\n// This one just reports an element's own width/height.\nconst useResizeObserver = <T extends Element = Element>(\n options?: Options,\n): [(node: T | null) => void, Size | null] => {\n const [size, setSize] = useState<Size | null>(null);\n const observerRef = useRef<ResizeObserver | null>(null);\n\n // Same convention as useIntersectionObserver: `options` is typically a\n // fresh object literal at the call site, so it isn't a dependency here\n // — that would tear down and recreate the observer on every render. The\n // ref callback only re-runs when the observed node itself changes,\n // capturing whatever `options` was current at that time.\n const ref = useCallback((node: T | null) => {\n if (observerRef.current) {\n observerRef.current.disconnect();\n observerRef.current = null;\n }\n\n if (!node || typeof ResizeObserver === 'undefined') {\n return;\n }\n\n const box = options?.box ?? 'content-box';\n\n const observer = new ResizeObserver(([entry]) => {\n if (!entry) {\n return;\n }\n\n const [{ inlineSize, blockSize }] =\n box === 'border-box' ? entry.borderBoxSize : entry.contentBoxSize;\n\n setSize({ width: inlineSize, height: blockSize });\n });\n\n observer.observe(node, { box });\n observerRef.current = observer;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n return [ref, size];\n};\n\nexport default useResizeObserver;\n"],"mappings":";;;AAeA,MAAM,qBACJ,YAC4C;CAC5C,MAAM,CAAC,MAAM,WAAW,SAAsB,KAAK;CACnD,MAAM,cAAc,OAA8B,KAAK;AAmCvD,QAAO,CA5BK,aAAa,SAAmB;AAC1C,MAAI,YAAY,SAAS;AACvB,eAAY,QAAQ,YAAY;AAChC,eAAY,UAAU;;AAGxB,MAAI,CAAC,QAAQ,OAAO,mBAAmB,YACrC;EAGF,MAAM,MAAM,SAAS,OAAO;EAE5B,MAAM,WAAW,IAAI,gBAAgB,CAAC,WAAW;AAC/C,OAAI,CAAC,MACH;GAGF,MAAM,CAAC,EAAE,YAAY,eACnB,QAAQ,eAAe,MAAM,gBAAgB,MAAM;AAErD,WAAQ;IAAE,OAAO;IAAY,QAAQ;IAAW,CAAC;IACjD;AAEF,WAAS,QAAQ,MAAM,EAAE,KAAK,CAAC;AAC/B,cAAY,UAAU;IAErB,EAAE,CAAC,EAEO,KAAK"}
@@ -12,6 +12,7 @@ interface BreakpointInfo {
12
12
  interface Options {
13
13
  delay?: number;
14
14
  container?: HTMLElement | null;
15
+ viewport?: boolean;
15
16
  }
16
17
  declare const useResponsiveSize: <T extends HTMLElement>(options?: Options) => {
17
18
  size: {