@mantine/hooks 9.3.2 → 9.4.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 (122) hide show
  1. package/cjs/use-click-outside/use-click-outside.cjs.map +1 -1
  2. package/cjs/use-clipboard/use-clipboard.cjs.map +1 -1
  3. package/cjs/use-collapse/use-collapse.cjs.map +1 -1
  4. package/cjs/use-collapse/use-horizontal-collapse.cjs.map +1 -1
  5. package/cjs/use-counter/use-counter.cjs.map +1 -1
  6. package/cjs/use-debounced-callback/use-debounced-callback.cjs.map +1 -1
  7. package/cjs/use-debounced-state/use-debounced-state.cjs.map +1 -1
  8. package/cjs/use-debounced-value/use-debounced-value.cjs.map +1 -1
  9. package/cjs/use-did-update/use-did-update.cjs.map +1 -1
  10. package/cjs/use-disclosure/use-disclosure.cjs.map +1 -1
  11. package/cjs/use-document-title/use-document-title.cjs.map +1 -1
  12. package/cjs/use-document-visibility/use-document-visibility.cjs.map +1 -1
  13. package/cjs/use-drag/use-drag.cjs.map +1 -1
  14. package/cjs/use-event-listener/use-event-listener.cjs.map +1 -1
  15. package/cjs/use-eye-dropper/use-eye-dropper.cjs.map +1 -1
  16. package/cjs/use-favicon/use-favicon.cjs.map +1 -1
  17. package/cjs/use-fetch/use-fetch.cjs.map +1 -1
  18. package/cjs/use-file-dialog/use-file-dialog.cjs.map +1 -1
  19. package/cjs/use-floating-window/use-floating-window.cjs.map +1 -1
  20. package/cjs/use-focus-return/use-focus-return.cjs.map +1 -1
  21. package/cjs/use-focus-trap/scope-tab.cjs.map +1 -1
  22. package/cjs/use-focus-trap/tabbable.cjs.map +1 -1
  23. package/cjs/use-focus-trap/use-focus-trap.cjs.map +1 -1
  24. package/cjs/use-focus-within/use-focus-within.cjs.map +1 -1
  25. package/cjs/use-force-update/use-force-update.cjs.map +1 -1
  26. package/cjs/use-fullscreen/use-fullscreen.cjs.map +1 -1
  27. package/cjs/use-hash/use-hash.cjs.map +1 -1
  28. package/cjs/use-headroom/use-headroom.cjs.map +1 -1
  29. package/cjs/use-hotkeys/parse-hotkey.cjs.map +1 -1
  30. package/cjs/use-hotkeys/use-hotkeys.cjs.map +1 -1
  31. package/cjs/use-hover/use-hover.cjs.map +1 -1
  32. package/cjs/use-id/use-id.cjs.map +1 -1
  33. package/cjs/use-idle/use-idle.cjs.map +1 -1
  34. package/cjs/use-in-viewport/use-in-viewport.cjs.map +1 -1
  35. package/cjs/use-input-state/use-input-state.cjs.map +1 -1
  36. package/cjs/use-intersection/use-intersection.cjs.map +1 -1
  37. package/cjs/use-interval/use-interval.cjs.map +1 -1
  38. package/cjs/use-is-first-render/use-is-first-render.cjs.map +1 -1
  39. package/cjs/use-list-state/use-list-state.cjs.map +1 -1
  40. package/cjs/use-local-storage/create-storage.cjs.map +1 -1
  41. package/cjs/use-local-storage/use-local-storage.cjs.map +1 -1
  42. package/cjs/use-logger/use-logger.cjs.map +1 -1
  43. package/cjs/use-long-press/use-long-press.cjs.map +1 -1
  44. package/cjs/use-map/use-map.cjs.map +1 -1
  45. package/cjs/use-mask/use-mask.cjs.map +1 -1
  46. package/cjs/use-media-query/use-media-query.cjs.map +1 -1
  47. package/cjs/use-merged-ref/use-merged-ref.cjs.map +1 -1
  48. package/cjs/use-mounted/use-mounted.cjs.map +1 -1
  49. package/cjs/use-mouse/use-mouse.cjs.map +1 -1
  50. package/cjs/use-move/use-move.cjs.map +1 -1
  51. package/cjs/use-mutation-observer/use-mutation-observer.cjs.map +1 -1
  52. package/cjs/use-network/use-network.cjs.map +1 -1
  53. package/cjs/use-orientation/use-orientation.cjs.map +1 -1
  54. package/cjs/use-os/use-os.cjs.map +1 -1
  55. package/cjs/use-page-leave/use-page-leave.cjs.map +1 -1
  56. package/cjs/use-pagination/use-pagination.cjs.map +1 -1
  57. package/cjs/use-previous/use-previous.cjs.map +1 -1
  58. package/cjs/use-queue/use-queue.cjs.map +1 -1
  59. package/cjs/use-radial-move/use-radial-move.cjs.map +1 -1
  60. package/cjs/use-resize-observer/use-resize-observer.cjs.map +1 -1
  61. package/cjs/use-roving-index/use-roving-index.cjs.map +1 -1
  62. package/cjs/use-scroll-direction/use-scroll-direction.cjs.map +1 -1
  63. package/cjs/use-scroll-into-view/use-scroll-into-view.cjs.map +1 -1
  64. package/cjs/use-scroll-spy/use-scroll-spy.cjs.map +1 -1
  65. package/cjs/use-scroller/use-scroller.cjs.map +1 -1
  66. package/cjs/use-selection/use-selection.cjs.map +1 -1
  67. package/cjs/use-session-storage/use-session-storage.cjs.map +1 -1
  68. package/cjs/use-set/use-set.cjs.map +1 -1
  69. package/cjs/use-set-state/use-set-state.cjs.map +1 -1
  70. package/cjs/use-shallow-effect/use-shallow-effect.cjs.map +1 -1
  71. package/cjs/use-splitter/use-splitter.cjs +226 -55
  72. package/cjs/use-splitter/use-splitter.cjs.map +1 -1
  73. package/cjs/use-state-history/use-state-history.cjs.map +1 -1
  74. package/cjs/use-text-selection/use-text-selection.cjs.map +1 -1
  75. package/cjs/use-throttled-callback/use-throttled-callback.cjs.map +1 -1
  76. package/cjs/use-throttled-state/use-throttled-state.cjs.map +1 -1
  77. package/cjs/use-throttled-value/use-throttled-value.cjs.map +1 -1
  78. package/cjs/use-timeout/use-timeout.cjs.map +1 -1
  79. package/cjs/use-toggle/use-toggle.cjs.map +1 -1
  80. package/cjs/use-uncontrolled/use-uncontrolled.cjs.map +1 -1
  81. package/cjs/use-validated-state/use-validated-state.cjs.map +1 -1
  82. package/cjs/use-viewport-size/use-viewport-size.cjs.map +1 -1
  83. package/cjs/use-window-event/use-window-event.cjs.map +1 -1
  84. package/cjs/use-window-scroll/use-window-scroll.cjs.map +1 -1
  85. package/cjs/utils/lower-first/lower-first.cjs.map +1 -1
  86. package/cjs/utils/random-id/random-id.cjs.map +1 -1
  87. package/cjs/utils/shallow-equal/shallow-equal.cjs.map +1 -1
  88. package/cjs/utils/upper-first/upper-first.cjs.map +1 -1
  89. package/cjs/utils/use-callback-ref/use-callback-ref.cjs.map +1 -1
  90. package/esm/use-clipboard/use-clipboard.mjs.map +1 -1
  91. package/esm/use-document-title/use-document-title.mjs.map +1 -1
  92. package/esm/use-eye-dropper/use-eye-dropper.mjs.map +1 -1
  93. package/esm/use-favicon/use-favicon.mjs.map +1 -1
  94. package/esm/use-fetch/use-fetch.mjs.map +1 -1
  95. package/esm/use-floating-window/use-floating-window.mjs.map +1 -1
  96. package/esm/use-focus-trap/scope-tab.mjs.map +1 -1
  97. package/esm/use-focus-trap/tabbable.mjs.map +1 -1
  98. package/esm/use-hotkeys/parse-hotkey.mjs.map +1 -1
  99. package/esm/use-hotkeys/use-hotkeys.mjs.map +1 -1
  100. package/esm/use-id/use-id.mjs.map +1 -1
  101. package/esm/use-local-storage/create-storage.mjs.map +1 -1
  102. package/esm/use-local-storage/use-local-storage.mjs.map +1 -1
  103. package/esm/use-mask/use-mask.mjs.map +1 -1
  104. package/esm/use-media-query/use-media-query.mjs.map +1 -1
  105. package/esm/use-move/use-move.mjs.map +1 -1
  106. package/esm/use-radial-move/use-radial-move.mjs.map +1 -1
  107. package/esm/use-scroll-into-view/use-scroll-into-view.mjs.map +1 -1
  108. package/esm/use-scroll-spy/use-scroll-spy.mjs.map +1 -1
  109. package/esm/use-scroller/use-scroller.mjs.map +1 -1
  110. package/esm/use-session-storage/use-session-storage.mjs.map +1 -1
  111. package/esm/use-set/use-set.mjs.map +1 -1
  112. package/esm/use-splitter/use-splitter.mjs +226 -55
  113. package/esm/use-splitter/use-splitter.mjs.map +1 -1
  114. package/esm/use-toggle/use-toggle.mjs.map +1 -1
  115. package/esm/utils/lower-first/lower-first.mjs.map +1 -1
  116. package/esm/utils/random-id/random-id.mjs.map +1 -1
  117. package/esm/utils/shallow-equal/shallow-equal.mjs.map +1 -1
  118. package/esm/utils/upper-first/upper-first.mjs.map +1 -1
  119. package/lib/index.d.mts +1 -1
  120. package/lib/index.d.ts +1 -1
  121. package/lib/use-splitter/use-splitter.d.ts +48 -22
  122. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"use-splitter.cjs","names":["useUncontrolled"],"sources":["../../src/use-splitter/use-splitter.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-deprecated */\nimport { useCallback, useEffect, useRef, useState } from 'react';\nimport { useUncontrolled } from '../use-uncontrolled/use-uncontrolled';\n\nexport interface UseSplitterPanel {\n /** Initial size as percentage (0-100). All panels must sum to 100. */\n defaultSize: number;\n /** Minimum size percentage, `0` by default */\n min?: number;\n /** Maximum size percentage, `100` by default */\n max?: number;\n /** Whether this panel can be collapsed, `false` by default */\n collapsible?: boolean;\n /** Size below which the panel snaps to collapsed (percentage), defaults to `min` */\n collapseThreshold?: number;\n}\n\nexport interface UseSplitterRedistributeInput {\n /** Current sizes before applying delta */\n sizes: number[];\n /** Panel configurations */\n panels: UseSplitterPanel[];\n /** Index of the handle being dragged */\n handleIndex: number;\n /** Requested size change in percentage (positive = grow before-panel) */\n delta: number;\n}\n\nexport type UseSplitterRedistributeFn = (input: UseSplitterRedistributeInput) => number[];\n\nexport interface UseSplitterOptions {\n /** Panel configuration array (minimum 2 panels) */\n panels: UseSplitterPanel[];\n /** Layout direction, `'horizontal'` by default */\n orientation?: 'horizontal' | 'vertical';\n /** Controlled sizes (percentages summing to 100) */\n sizes?: number[];\n /** Called during resize with updated sizes */\n onSizeChange?: (sizes: number[]) => void;\n /** Called when drag starts */\n onResizeStart?: (handleIndex: number) => void;\n /** Called when drag ends */\n onResizeEnd?: (handleIndex: number, sizes: number[]) => void;\n /** Called when a panel collapses or expands */\n onCollapseChange?: (panelIndex: number, collapsed: boolean) => void;\n /** How to borrow space from non-adjacent panels when the immediate neighbor is at its min/max.\n * `'nearest'` takes from the nearest panel in the drag direction first.\n * `'equal'` distributes equally among all panels in the drag direction.\n * A function receives sizes, panels, handleIndex and delta, and returns new sizes.\n * When not set, only the two adjacent panels are affected. */\n redistribute?: 'nearest' | 'equal' | UseSplitterRedistributeFn;\n /** Keyboard step size in percentage, `1` by default */\n step?: number;\n /** Shift+arrow step size in percentage, `10` by default */\n shiftStep?: number;\n /** Text direction for keyboard nav, `'ltr'` by default */\n dir?: 'ltr' | 'rtl';\n /** Restore the two panels adjacent to a handle to their default ratio (preserving their combined size) when the handle is double-clicked, `true` by default */\n resetOnDoubleClick?: boolean;\n /** Enable/disable the hook, `true` by default */\n enabled?: boolean;\n}\n\nexport interface UseSplitterReturnValue<T extends HTMLElement = any> {\n /** Ref callback for the container element */\n ref: React.RefCallback<T | null>;\n /** Current panel sizes as percentages */\n sizes: number[];\n /** Which panels are currently collapsed */\n collapsed: boolean[];\n /** Index of handle being dragged, or -1 */\n activeHandle: number;\n /** Get props to spread on each resize handle */\n getHandleProps: (input: { index: number }) => {\n ref: React.RefCallback<HTMLElement>;\n role: 'separator';\n 'aria-orientation': 'horizontal' | 'vertical';\n 'aria-valuenow': number;\n 'aria-valuemin': number;\n 'aria-valuemax': number;\n tabIndex: number;\n onKeyDown: React.KeyboardEventHandler;\n onDoubleClick: React.MouseEventHandler;\n 'data-active': boolean | undefined;\n 'data-orientation': 'horizontal' | 'vertical';\n };\n /** Programmatically set sizes */\n setSizes: (sizes: number[]) => void;\n /** Collapse a panel */\n collapse: (panelIndex: number) => void;\n /** Expand a collapsed panel */\n expand: (panelIndex: number) => void;\n /** Toggle collapse of a panel */\n toggleCollapse: (panelIndex: number) => void;\n /** Reset the two panels adjacent to a handle to their default ratio, preserving\n * their combined size */\n reset: (handleIndex: number) => void;\n}\n\nfunction clamp(value: number, min: number, max: number): number {\n return Math.min(Math.max(value, min), max);\n}\n\nfunction getMin(panel: UseSplitterPanel): number {\n return panel.min ?? 0;\n}\n\nfunction getMax(panel: UseSplitterPanel): number {\n return panel.max ?? 100;\n}\n\nfunction getCollapseThreshold(panel: UseSplitterPanel): number {\n return panel.collapseThreshold ?? getMin(panel);\n}\n\ninterface SplitterInternalState {\n isDragging: boolean;\n handleIndex: number;\n startPointer: number;\n containerSize: number;\n startSizes: number[];\n preCollapseSizes: number[];\n}\n\nfunction createInitialInternalState(): SplitterInternalState {\n return {\n isDragging: false,\n handleIndex: -1,\n startPointer: 0,\n containerSize: 0,\n startSizes: [],\n preCollapseSizes: [],\n };\n}\n\nfunction checkCollapse(\n sizes: number[],\n panels: UseSplitterPanel[],\n handleIndex: number,\n delta: number\n): number[] | null {\n const beforeIdx = handleIndex;\n const afterIdx = handleIndex + 1;\n const beforePanel = panels[beforeIdx];\n const afterPanel = panels[afterIdx];\n\n const rawBefore = sizes[beforeIdx] + delta;\n const rawAfter = sizes[afterIdx] - delta;\n\n if (\n beforePanel.collapsible &&\n rawBefore < getCollapseThreshold(beforePanel) &&\n rawBefore < sizes[beforeIdx]\n ) {\n const result = [...sizes];\n result[afterIdx] += result[beforeIdx];\n result[beforeIdx] = 0;\n return result;\n }\n\n if (\n afterPanel.collapsible &&\n rawAfter < getCollapseThreshold(afterPanel) &&\n rawAfter < sizes[afterIdx]\n ) {\n const result = [...sizes];\n result[beforeIdx] += result[afterIdx];\n result[afterIdx] = 0;\n return result;\n }\n\n return null;\n}\n\nfunction applyAdjacentOnly(\n sizes: number[],\n panels: UseSplitterPanel[],\n handleIndex: number,\n delta: number\n): number[] {\n const result = [...sizes];\n const beforeIdx = handleIndex;\n const afterIdx = handleIndex + 1;\n\n const total = result[beforeIdx] + result[afterIdx];\n const effectiveBeforeMax = Math.min(getMax(panels[beforeIdx]), total - getMin(panels[afterIdx]));\n const effectiveBeforeMin = Math.max(getMin(panels[beforeIdx]), total - getMax(panels[afterIdx]));\n const newBefore = clamp(result[beforeIdx] + delta, effectiveBeforeMin, effectiveBeforeMax);\n result[beforeIdx] = newBefore;\n result[afterIdx] = total - newBefore;\n return result;\n}\n\nfunction redistributeNearest(\n sizes: number[],\n panels: UseSplitterPanel[],\n handleIndex: number,\n delta: number\n): number[] {\n const result = [...sizes];\n\n if (delta > 0) {\n const growIdx = handleIndex;\n const maxGrow = getMax(panels[growIdx]) - result[growIdx];\n const wantedGrow = Math.min(delta, maxGrow);\n\n let taken = 0;\n for (let i = handleIndex + 1; i < result.length && taken < wantedGrow; i += 1) {\n const canGive = result[i] - getMin(panels[i]);\n const take = Math.min(canGive, wantedGrow - taken);\n result[i] -= take;\n taken += take;\n }\n\n result[growIdx] += taken;\n } else if (delta < 0) {\n const growIdx = handleIndex + 1;\n const maxGrow = getMax(panels[growIdx]) - result[growIdx];\n const wantedGrow = Math.min(Math.abs(delta), maxGrow);\n\n let taken = 0;\n for (let i = handleIndex; i >= 0 && taken < wantedGrow; i -= 1) {\n const canGive = result[i] - getMin(panels[i]);\n const take = Math.min(canGive, wantedGrow - taken);\n result[i] -= take;\n taken += take;\n }\n\n result[growIdx] += taken;\n }\n\n return result;\n}\n\nfunction redistributeEqual(\n sizes: number[],\n panels: UseSplitterPanel[],\n handleIndex: number,\n delta: number\n): number[] {\n const result = [...sizes];\n\n if (delta > 0) {\n const growIdx = handleIndex;\n const maxGrow = getMax(panels[growIdx]) - result[growIdx];\n const wantedGrow = Math.min(delta, maxGrow);\n\n const donors: number[] = [];\n for (let i = handleIndex + 1; i < result.length; i += 1) {\n if (result[i] > getMin(panels[i])) {\n donors.push(i);\n }\n }\n\n let remaining = wantedGrow;\n while (remaining > 0.001 && donors.length > 0) {\n const perDonor = remaining / donors.length;\n const exhausted: number[] = [];\n\n for (let d = 0; d < donors.length; d += 1) {\n const idx = donors[d];\n const canGive = result[idx] - getMin(panels[idx]);\n const take = Math.min(canGive, perDonor);\n result[idx] -= take;\n remaining -= take;\n if (canGive <= perDonor + 0.001) {\n exhausted.push(d);\n }\n }\n\n for (let i = exhausted.length - 1; i >= 0; i -= 1) {\n donors.splice(exhausted[i], 1);\n }\n\n if (exhausted.length === 0) {\n break;\n }\n }\n\n result[growIdx] += wantedGrow - remaining;\n } else if (delta < 0) {\n const growIdx = handleIndex + 1;\n const maxGrow = getMax(panels[growIdx]) - result[growIdx];\n const wantedGrow = Math.min(Math.abs(delta), maxGrow);\n\n const donors: number[] = [];\n for (let i = handleIndex; i >= 0; i -= 1) {\n if (result[i] > getMin(panels[i])) {\n donors.push(i);\n }\n }\n\n let remaining = wantedGrow;\n while (remaining > 0.001 && donors.length > 0) {\n const perDonor = remaining / donors.length;\n const exhausted: number[] = [];\n\n for (let d = 0; d < donors.length; d += 1) {\n const idx = donors[d];\n const canGive = result[idx] - getMin(panels[idx]);\n const take = Math.min(canGive, perDonor);\n result[idx] -= take;\n remaining -= take;\n if (canGive <= perDonor + 0.001) {\n exhausted.push(d);\n }\n }\n\n for (let i = exhausted.length - 1; i >= 0; i -= 1) {\n donors.splice(exhausted[i], 1);\n }\n\n if (exhausted.length === 0) {\n break;\n }\n }\n\n result[growIdx] += wantedGrow - remaining;\n }\n\n return result;\n}\n\nfunction applyConstraints(\n sizes: number[],\n panels: UseSplitterPanel[],\n handleIndex: number,\n delta: number,\n redistribute?: 'nearest' | 'equal' | UseSplitterRedistributeFn\n): number[] {\n if (typeof redistribute === 'function') {\n return redistribute({ sizes: [...sizes], panels, handleIndex, delta });\n }\n\n if (redistribute === 'nearest' || redistribute === 'equal') {\n const strategy = redistribute === 'nearest' ? redistributeNearest : redistributeEqual;\n const result = strategy(sizes, panels, handleIndex, delta);\n\n const beforeIdx = handleIndex;\n const afterIdx = handleIndex + 1;\n const beforePanel = panels[beforeIdx];\n const afterPanel = panels[afterIdx];\n\n if (\n beforePanel.collapsible &&\n result[beforeIdx] < getCollapseThreshold(beforePanel) &&\n result[beforeIdx] < sizes[beforeIdx]\n ) {\n const freed = result[beforeIdx];\n result[afterIdx] += freed;\n result[beforeIdx] = 0;\n } else if (\n afterPanel.collapsible &&\n result[afterIdx] < getCollapseThreshold(afterPanel) &&\n result[afterIdx] < sizes[afterIdx]\n ) {\n const freed = result[afterIdx];\n result[beforeIdx] += freed;\n result[afterIdx] = 0;\n }\n\n return result;\n }\n\n const collapsed = checkCollapse(sizes, panels, handleIndex, delta);\n if (collapsed) {\n return collapsed;\n }\n\n return applyAdjacentOnly(sizes, panels, handleIndex, delta);\n}\n\nexport function useSplitter<T extends HTMLElement = any>(\n options: UseSplitterOptions\n): UseSplitterReturnValue<T> {\n const {\n panels,\n orientation = 'horizontal',\n sizes: controlledSizes,\n onSizeChange,\n onCollapseChange,\n redistribute,\n step = 1,\n shiftStep = 10,\n dir = 'ltr',\n resetOnDoubleClick = true,\n enabled = true,\n } = options;\n\n const defaultSizes = panels.map((p) => p.defaultSize);\n\n const [currentSizes, setCurrentSizes] = useUncontrolled({\n value: controlledSizes,\n defaultValue: defaultSizes,\n finalValue: defaultSizes,\n onChange: onSizeChange,\n });\n\n const [activeHandle, setActiveHandle] = useState(-1);\n\n const optionsRef = useRef(options);\n optionsRef.current = options;\n\n const internalStateRef = useRef<SplitterInternalState>(createInitialInternalState());\n const containerRef = useRef<T | null>(null);\n const documentControllerRef = useRef<AbortController | null>(null);\n const frameRef = useRef(0);\n const currentSizesRef = useRef(currentSizes);\n currentSizesRef.current = currentSizes;\n\n const preCollapseSizesRef = useRef<number[]>(defaultSizes);\n\n const collapsed = currentSizes.map((size) => size === 0);\n\n const updateSizes = useCallback(\n (newSizes: number[]) => {\n currentSizesRef.current = newSizes;\n setCurrentSizes(newSizes);\n },\n [setCurrentSizes]\n );\n\n const collapsePanel = useCallback(\n (panelIndex: number) => {\n if (!panels[panelIndex]?.collapsible) {\n return;\n }\n const sizes = currentSizesRef.current;\n if (sizes[panelIndex] === 0) {\n return;\n }\n\n preCollapseSizesRef.current = [...sizes];\n const newSizes = [...sizes];\n const freedSize = newSizes[panelIndex];\n newSizes[panelIndex] = 0;\n\n const neighbor = panelIndex === 0 ? 1 : panelIndex - 1;\n newSizes[neighbor] += freedSize;\n\n updateSizes(newSizes);\n onCollapseChange?.(panelIndex, true);\n },\n [panels, updateSizes, onCollapseChange]\n );\n\n const expandPanel = useCallback(\n (panelIndex: number) => {\n if (!panels[panelIndex]?.collapsible) {\n return;\n }\n const sizes = currentSizesRef.current;\n if (sizes[panelIndex] !== 0) {\n return;\n }\n\n const preCollapse = preCollapseSizesRef.current;\n const restoreSize = preCollapse[panelIndex] || panels[panelIndex].defaultSize;\n const newSizes = [...sizes];\n\n const neighbor = panelIndex === 0 ? 1 : panelIndex - 1;\n const available = Math.max(0, newSizes[neighbor] - getMin(panels[neighbor]));\n const actualRestore = Math.min(restoreSize, available);\n\n if (actualRestore <= 0) {\n return;\n }\n\n newSizes[panelIndex] = actualRestore;\n newSizes[neighbor] -= actualRestore;\n\n updateSizes(newSizes);\n onCollapseChange?.(panelIndex, false);\n },\n [panels, updateSizes, onCollapseChange]\n );\n\n const toggleCollapsePanel = useCallback(\n (panelIndex: number) => {\n if (currentSizesRef.current[panelIndex] === 0) {\n expandPanel(panelIndex);\n } else {\n collapsePanel(panelIndex);\n }\n },\n [collapsePanel, expandPanel]\n );\n\n const emitCollapseTransitions = useCallback(\n (prev: number[], next: number[], indices: number[], preCollapseSnapshot: number[]) => {\n const onChange = optionsRef.current.onCollapseChange;\n for (const idx of indices) {\n const wasCollapsed = prev[idx] === 0;\n const nowCollapsed = next[idx] === 0;\n if (!wasCollapsed && nowCollapsed) {\n preCollapseSizesRef.current = [...preCollapseSnapshot];\n onChange?.(idx, true);\n } else if (wasCollapsed && !nowCollapsed) {\n onChange?.(idx, false);\n }\n }\n },\n []\n );\n\n const reset = useCallback(\n (handleIndex: number) => {\n const prev = currentSizesRef.current;\n const currentPanels = optionsRef.current.panels;\n\n const beforeIdx = handleIndex;\n const afterIdx = handleIndex + 1;\n if (beforeIdx < 0 || afterIdx >= prev.length) {\n return;\n }\n\n const total = prev[beforeIdx] + prev[afterIdx];\n const defBefore = currentPanels[beforeIdx].defaultSize;\n const defAfter = currentPanels[afterIdx].defaultSize;\n const defTotal = defBefore + defAfter;\n const targetBefore = defTotal === 0 ? total / 2 : total * (defBefore / defTotal);\n\n const next = applyAdjacentOnly(\n prev,\n currentPanels,\n beforeIdx,\n targetBefore - prev[beforeIdx]\n );\n emitCollapseTransitions(prev, next, [beforeIdx, afterIdx], prev);\n updateSizes(next);\n },\n [emitCollapseTransitions, updateSizes]\n );\n\n const containerRefCallback: React.RefCallback<T | null> = useCallback((node) => {\n containerRef.current = node;\n }, []);\n\n const handleRefCallbacks = useRef<Map<number, (node: HTMLElement | null) => void>>(new Map());\n const handleElementControllers = useRef<Map<number, AbortController>>(new Map());\n\n const getHandleRefCallback = useCallback(\n (handleIndex: number): React.RefCallback<HTMLElement> => {\n if (handleRefCallbacks.current.has(handleIndex)) {\n return handleRefCallbacks.current.get(handleIndex)!;\n }\n\n const callback = (node: HTMLElement | null) => {\n const existingController = handleElementControllers.current.get(handleIndex);\n if (existingController) {\n existingController.abort();\n handleElementControllers.current.delete(handleIndex);\n }\n\n if (!node) {\n return;\n }\n\n const elementController = new AbortController();\n handleElementControllers.current.set(handleIndex, elementController);\n\n const onPointerDown = (event: PointerEvent) => {\n if (optionsRef.current.enabled === false) {\n return;\n }\n if (event.button !== 0) {\n return;\n }\n\n const container = containerRef.current;\n if (!container) {\n return;\n }\n\n const rect = container.getBoundingClientRect();\n const isHorizontal = (optionsRef.current.orientation ?? 'horizontal') === 'horizontal';\n const containerSize = isHorizontal ? rect.width : rect.height;\n const pointerPos = isHorizontal ? event.clientX : event.clientY;\n\n const s = internalStateRef.current;\n s.isDragging = true;\n s.handleIndex = handleIndex;\n s.startPointer = pointerPos;\n s.containerSize = containerSize;\n s.startSizes = [...currentSizesRef.current];\n s.preCollapseSizes = [...preCollapseSizesRef.current];\n\n setActiveHandle(handleIndex);\n document.body.style.userSelect = 'none';\n document.body.style.webkitUserSelect = 'none';\n document.body.style.cursor = isHorizontal ? 'col-resize' : 'row-resize';\n\n optionsRef.current.onResizeStart?.(handleIndex);\n\n documentControllerRef.current?.abort();\n documentControllerRef.current = new AbortController();\n const sig = documentControllerRef.current.signal;\n\n document.addEventListener('pointermove', onPointerMove, { signal: sig });\n document.addEventListener('pointerup', onPointerUp, { signal: sig });\n document.addEventListener('pointercancel', onPointerUp, { signal: sig });\n };\n\n const flushResize = (pointerEvent: PointerEvent) => {\n const s = internalStateRef.current;\n if (!s.containerSize) {\n return;\n }\n const isHorizontal = (optionsRef.current.orientation ?? 'horizontal') === 'horizontal';\n const isRtl = isHorizontal && optionsRef.current.dir === 'rtl';\n const pointerPos = isHorizontal ? pointerEvent.clientX : pointerEvent.clientY;\n const pixelDelta = pointerPos - s.startPointer;\n const percentDelta = ((isRtl ? -pixelDelta : pixelDelta) / s.containerSize) * 100;\n\n const opts = optionsRef.current;\n const newSizes = applyConstraints(\n s.startSizes,\n opts.panels,\n s.handleIndex,\n percentDelta,\n opts.redistribute\n );\n\n const prevSizes = currentSizesRef.current;\n emitCollapseTransitions(\n prevSizes,\n newSizes,\n [s.handleIndex, s.handleIndex + 1],\n s.startSizes\n );\n\n currentSizesRef.current = newSizes;\n setCurrentSizes(newSizes);\n };\n\n const onPointerMove = (event: PointerEvent) => {\n const s = internalStateRef.current;\n if (!s.isDragging) {\n return;\n }\n\n cancelAnimationFrame(frameRef.current);\n frameRef.current = requestAnimationFrame(() => {\n flushResize(event);\n });\n };\n\n const onPointerUp = (event: PointerEvent) => {\n const s = internalStateRef.current;\n if (!s.isDragging) {\n return;\n }\n\n cancelAnimationFrame(frameRef.current);\n flushResize(event);\n\n s.isDragging = false;\n const finishedHandle = s.handleIndex;\n s.handleIndex = -1;\n\n setActiveHandle(-1);\n document.body.style.userSelect = '';\n document.body.style.webkitUserSelect = '';\n document.body.style.cursor = '';\n\n documentControllerRef.current?.abort();\n documentControllerRef.current = null;\n\n optionsRef.current.onResizeEnd?.(finishedHandle, [...currentSizesRef.current]);\n };\n\n node.addEventListener('pointerdown', onPointerDown, {\n signal: elementController.signal,\n });\n };\n\n handleRefCallbacks.current.set(handleIndex, callback);\n return callback;\n },\n [setCurrentSizes]\n );\n\n const getHandleProps = useCallback(\n (input: { index: number }) => {\n const { index } = input;\n const orient = orientation;\n const beforeSize = currentSizes[index] ?? 0;\n const beforePanel = panels[index];\n const afterPanel = panels[index + 1];\n\n return {\n ref: getHandleRefCallback(index),\n role: 'separator' as const,\n 'aria-orientation': orient,\n 'aria-valuenow': Math.round(beforeSize),\n 'aria-valuemin': Math.round(getMin(beforePanel)),\n 'aria-valuemax': Math.round(getMax(beforePanel)),\n tabIndex: 0,\n onKeyDown: (event: React.KeyboardEvent) => {\n if (!enabled) {\n return;\n }\n\n const isHorizontal = orient === 'horizontal';\n const isRtl = dir === 'rtl';\n\n let delta = 0;\n const currentStep = event.shiftKey ? shiftStep : step;\n\n switch (event.key) {\n case 'ArrowLeft': {\n if (!isHorizontal) {\n return;\n }\n delta = isRtl ? currentStep : -currentStep;\n break;\n }\n case 'ArrowRight': {\n if (!isHorizontal) {\n return;\n }\n delta = isRtl ? -currentStep : currentStep;\n break;\n }\n case 'ArrowUp': {\n if (isHorizontal) {\n return;\n }\n delta = -currentStep;\n break;\n }\n case 'ArrowDown': {\n if (isHorizontal) {\n return;\n }\n delta = currentStep;\n break;\n }\n case 'Home': {\n delta = -(currentSizes[index] - getMin(beforePanel));\n break;\n }\n case 'End': {\n delta = getMax(beforePanel) - currentSizes[index];\n break;\n }\n case 'Enter': {\n const beforeCollapsible = beforePanel?.collapsible;\n const afterCollapsible = afterPanel?.collapsible;\n\n if (beforeCollapsible && currentSizes[index] <= currentSizes[index + 1]) {\n toggleCollapsePanel(index);\n event.preventDefault();\n return;\n }\n if (afterCollapsible) {\n toggleCollapsePanel(index + 1);\n event.preventDefault();\n return;\n }\n if (beforeCollapsible) {\n toggleCollapsePanel(index);\n event.preventDefault();\n return;\n }\n return;\n }\n default:\n return;\n }\n\n event.preventDefault();\n\n if (delta !== 0) {\n const newSizes = applyConstraints(currentSizes, panels, index, delta, redistribute);\n emitCollapseTransitions(currentSizes, newSizes, [index, index + 1], currentSizes);\n updateSizes(newSizes);\n }\n },\n onDoubleClick: () => {\n if (!enabled || !resetOnDoubleClick) {\n return;\n }\n reset(index);\n },\n 'data-active': activeHandle === index || undefined,\n 'data-orientation': orient,\n };\n },\n [\n orientation,\n currentSizes,\n panels,\n enabled,\n dir,\n step,\n shiftStep,\n resetOnDoubleClick,\n activeHandle,\n redistribute,\n getHandleRefCallback,\n toggleCollapsePanel,\n updateSizes,\n emitCollapseTransitions,\n reset,\n ]\n );\n\n useEffect(\n () => () => {\n documentControllerRef.current?.abort();\n documentControllerRef.current = null;\n handleElementControllers.current.forEach((controller) => controller.abort());\n handleElementControllers.current.clear();\n cancelAnimationFrame(frameRef.current);\n\n if (internalStateRef.current.isDragging) {\n internalStateRef.current.isDragging = false;\n document.body.style.userSelect = '';\n document.body.style.webkitUserSelect = '';\n document.body.style.cursor = '';\n }\n },\n []\n );\n\n return {\n ref: containerRefCallback,\n sizes: currentSizes,\n collapsed,\n activeHandle,\n getHandleProps,\n setSizes: updateSizes,\n collapse: collapsePanel,\n expand: expandPanel,\n toggleCollapse: toggleCollapsePanel,\n reset,\n };\n}\n\nexport namespace useSplitter {\n export type Panel = UseSplitterPanel;\n export type Options = UseSplitterOptions;\n export type RedistributeInput = UseSplitterRedistributeInput;\n export type RedistributeFn = UseSplitterRedistributeFn;\n export type ReturnValue<T extends HTMLElement = any> = UseSplitterReturnValue<T>;\n}\n"],"mappings":";;;;AAmGA,SAAS,MAAM,OAAe,KAAa,KAAqB;CAC9D,OAAO,KAAK,IAAI,KAAK,IAAI,OAAO,GAAG,GAAG,GAAG;AAC3C;AAEA,SAAS,OAAO,OAAiC;CAC/C,OAAO,MAAM,OAAO;AACtB;AAEA,SAAS,OAAO,OAAiC;CAC/C,OAAO,MAAM,OAAO;AACtB;AAEA,SAAS,qBAAqB,OAAiC;CAC7D,OAAO,MAAM,qBAAqB,OAAO,KAAK;AAChD;AAWA,SAAS,6BAAoD;CAC3D,OAAO;EACL,YAAY;EACZ,aAAa;EACb,cAAc;EACd,eAAe;EACf,YAAY,CAAC;EACb,kBAAkB,CAAC;CACrB;AACF;AAEA,SAAS,cACP,OACA,QACA,aACA,OACiB;CACjB,MAAM,YAAY;CAClB,MAAM,WAAW,cAAc;CAC/B,MAAM,cAAc,OAAO;CAC3B,MAAM,aAAa,OAA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BAAkB;OACpB,oBAAoB,QAAQ,CAAC;OAC7B,MAAM,eAAe;OACrB;MACF;MACA,IAAI,mBAAmB;OACrB,oBAAoB,KAAK;OACzB,MAAM,eAAe;OACrB;MACF;MACA;KACF;KACA,SACE;IACJ;IAEA,MAAM,eAAe;IAErB,IAAI,UAAU,GAAG;KACf,MAAM,WAAW,iBAAiB,cAAc,QAAQ,OAAO,OAAO,YAAY;KAClF,wBAAwB,cAAc,UAAU,CAAC,OAAO,QAAQ,CAAC,GAAG,YAAY;KAChF,YAAY,QAAQ;IACtB;GACF;GACA,qBAAqB;IACnB,IAAI,CAAC,WAAW,CAAC,oBACf;IAEF,MAAM,KAAK;GACb;GACA,eAAe,iBAAiB,SAAS,KAAA;GACzC,oBAAoB;EACtB;CACF,GACA;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CACF;CAEA,CAAA,GAAA,MAAA,uBACc;EACV,sBAAsB,SAAS,MAAM;EACrC,sBAAsB,UAAU;EAChC,yBAAyB,QAAQ,SAAS,eAAe,WAAW,MAAM,CAAC;EAC3E,yBAAyB,QAAQ,MAAM;EACvC,qBAAqB,SAAS,OAAO;EAErC,IAAI,iBAAiB,QAAQ,YAAY;GACvC,iBAAiB,QAAQ,aAAa;GACtC,SAAS,KAAK,MAAM,aAAa;GACjC,SAAS,KAAK,MAAM,mBAAmB;GACvC,SAAS,KAAK,MAAM,SAAS;EAC/B;CACF,GACA,CAAC,CACH;CAEA,OAAO;EACL,KAAK;EACL,OAAO;EACP;EACA;EACA;EACA,UAAU;EACV,UAAU;EACV,QAAQ;EACR,gBAAgB;EAChB;CACF;AACF"}
1
+ {"version":3,"file":"use-splitter.cjs","names":["useUncontrolled"],"sources":["../../src/use-splitter/use-splitter.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-deprecated */\nimport { useCallback, useEffect, useRef, useState } from 'react';\nimport { useUncontrolled } from '../use-uncontrolled/use-uncontrolled';\n\n/** Pane size expressed in CSS units. A bare `number` or `%` string is a flexible size (shares\n * the leftover space), `px`/`rem` strings are fixed sizes that keep their pixel size when the\n * container is resized. */\nexport type SplitterPaneSize = number | `${number}%` | `${number}px` | `${number}rem`;\n\n/** Keyboard step expressed in CSS units. A bare `number` or `%` string is a percentage of the\n * container, `px`/`rem` strings are resolved to pixels. */\nexport type SplitterStep = number | `${number}%` | `${number}px` | `${number}rem`;\n\nexport interface UseSplitterPanel {\n /** Initial size, a `number`/`%` is a flexible size, `px`/`rem` is a fixed size. A bare number is treated as a percentage. */\n defaultSize: SplitterPaneSize;\n /** Minimum size in the same units as `defaultSize`, `0` by default */\n min?: SplitterPaneSize;\n /** Maximum size in the same units as `defaultSize`, no limit by default */\n max?: SplitterPaneSize;\n /** Whether this panel can be collapsed, `false` by default */\n collapsible?: boolean;\n /** Size below which the panel snaps to collapsed, defaults to `min` */\n collapseThreshold?: SplitterPaneSize;\n}\n\n/** Panel configuration resolved to numeric units (percent or pixels) passed to redistribute functions */\nexport interface UseSplitterResolvedPanel {\n /** Resolved default size in the same units as redistribute sizes */\n defaultSize: number;\n /** Resolved minimum size */\n min?: number;\n /** Resolved maximum size */\n max?: number;\n /** Whether this panel can be collapsed */\n collapsible?: boolean;\n /** Resolved collapse threshold */\n collapseThreshold?: number;\n}\n\nexport interface UseSplitterRedistributeInput {\n /** Current sizes before applying delta, in resolved units (percent or pixels) */\n sizes: number[];\n /** Resolved panel configurations, in the same units as `sizes` */\n panels: UseSplitterResolvedPanel[];\n /** Index of the handle being dragged */\n handleIndex: number;\n /** Requested size change in resolved units (positive = grow before-panel) */\n delta: number;\n}\n\nexport type UseSplitterRedistributeFn = (input: UseSplitterRedistributeInput) => number[];\n\nexport interface UseSplitterOptions {\n /** Panel configuration array (minimum 2 panels) */\n panels: UseSplitterPanel[];\n /** Layout direction, `'horizontal'` by default */\n orientation?: 'horizontal' | 'vertical';\n /** Controlled sizes, each value keeps the unit it was declared in */\n sizes?: SplitterPaneSize[];\n /** Called during resize with updated sizes, each value keeps its declared unit */\n onSizeChange?: (sizes: SplitterPaneSize[]) => void;\n /** Called when drag starts */\n onResizeStart?: (handleIndex: number) => void;\n /** Called when drag ends */\n onResizeEnd?: (handleIndex: number, sizes: SplitterPaneSize[]) => void;\n /** Called when a panel collapses or expands */\n onCollapseChange?: (panelIndex: number, collapsed: boolean) => void;\n /** How to borrow space from non-adjacent panels when the immediate neighbor is at its min/max.\n * `'nearest'` takes from the nearest panel in the drag direction first.\n * `'equal'` distributes equally among all panels in the drag direction.\n * A function receives sizes, panels, handleIndex and delta, and returns new sizes.\n * When not set, only the two adjacent panels are affected. */\n redistribute?: 'nearest' | 'equal' | UseSplitterRedistributeFn;\n /** Keyboard step size, a `number`/`%` is a percentage, `px`/`rem` is resolved to pixels, `1` by default */\n step?: SplitterStep;\n /** Shift+arrow step size, a `number`/`%` is a percentage, `px`/`rem` is resolved to pixels, `10` by default */\n shiftStep?: SplitterStep;\n /** Text direction for keyboard nav, `'ltr'` by default */\n dir?: 'ltr' | 'rtl';\n /** Restore the two panels adjacent to a handle to their default ratio (preserving their combined size) when the handle is double-clicked, `true` by default */\n resetOnDoubleClick?: boolean;\n /** Enable/disable the hook, `true` by default */\n enabled?: boolean;\n}\n\nexport interface UseSplitterReturnValue<T extends HTMLElement = any> {\n /** Ref callback for the container element */\n ref: React.RefCallback<T | null>;\n /** Current panel sizes, each value keeps the unit it was declared in */\n sizes: SplitterPaneSize[];\n /** Whether sizes are tracked in pixels because any pane size, `min`, `max`, `step`, `shiftStep`\n * or `collapseThreshold` uses a fixed `px`/`rem` unit */\n pixelMode: boolean;\n /** Which panels are currently collapsed */\n collapsed: boolean[];\n /** Index of handle being dragged, or -1 */\n activeHandle: number;\n /** Get props to spread on each resize handle */\n getHandleProps: (input: { index: number }) => {\n ref: React.RefCallback<HTMLElement>;\n role: 'separator';\n 'aria-orientation': 'horizontal' | 'vertical';\n 'aria-valuenow': number;\n 'aria-valuemin': number;\n 'aria-valuemax': number;\n tabIndex: number;\n onKeyDown: React.KeyboardEventHandler;\n onDoubleClick: React.MouseEventHandler;\n 'data-active': boolean | undefined;\n 'data-orientation': 'horizontal' | 'vertical';\n };\n /** Programmatically set sizes, each value keeps its declared unit */\n setSizes: (sizes: SplitterPaneSize[]) => void;\n /** Collapse a panel */\n collapse: (panelIndex: number) => void;\n /** Expand a collapsed panel */\n expand: (panelIndex: number) => void;\n /** Toggle collapse of a panel */\n toggleCollapse: (panelIndex: number) => void;\n /** Reset the two panels adjacent to a handle to their default ratio, preserving\n * their combined size */\n reset: (handleIndex: number) => void;\n}\n\nconst PX_RE = /^(-?[\\d.]+)px$/;\nconst REM_RE = /^(-?[\\d.]+)rem$/;\nconst PERCENT_RE = /^(-?[\\d.]+)%$/;\n\nfunction isFixedSize(size: SplitterPaneSize | undefined): boolean {\n return typeof size === 'string' && (PX_RE.test(size) || REM_RE.test(size));\n}\n\nfunction sizeMagnitude(size: SplitterPaneSize): number {\n return typeof size === 'number' ? size : parseFloat(size);\n}\n\nfunction detectPixelMode(options: UseSplitterOptions): boolean {\n return (\n options.panels.some(\n (panel) =>\n isFixedSize(panel.defaultSize) ||\n isFixedSize(panel.min) ||\n isFixedSize(panel.max) ||\n isFixedSize(panel.collapseThreshold)\n ) ||\n isFixedSize(options.step) ||\n isFixedSize(options.shiftStep) ||\n (options.sizes?.some(isFixedSize) ?? false)\n );\n}\n\nfunction getRootFontSize(): number {\n if (typeof window === 'undefined') {\n return 16;\n }\n const fontSize = parseFloat(getComputedStyle(document.documentElement).fontSize);\n return Number.isFinite(fontSize) && fontSize > 0 ? fontSize : 16;\n}\n\nfunction resolveSize(\n size: SplitterPaneSize,\n pixelMode: boolean,\n containerPx: number,\n rootFontSize: number\n): number {\n if (!pixelMode) {\n return sizeMagnitude(size);\n }\n\n if (typeof size === 'number') {\n return (size / 100) * containerPx;\n }\n\n const percent = PERCENT_RE.exec(size);\n if (percent) {\n return (parseFloat(percent[1]) / 100) * containerPx;\n }\n\n const rem = REM_RE.exec(size);\n if (rem) {\n return parseFloat(rem[1]) * rootFontSize;\n }\n\n const px = PX_RE.exec(size);\n if (px) {\n return parseFloat(px[1]);\n }\n\n return 0;\n}\n\n/** Down-scaling factor applied to fixed panes when their combined pixel size overflows the\n * container, so they shrink to fit (matching `resolveWorkingSizes`). Returns `1` when nothing\n * overflows or the layout is not in pixel mode. Encoders divide by this to invert the scaling and\n * persist the original absolute sizes instead of the shrunk-to-fit ones. */\nfunction getFixedScale(\n sizes: SplitterPaneSize[],\n pixelMode: boolean,\n containerPx: number,\n rootFontSize: number\n): number {\n if (!pixelMode) {\n return 1;\n }\n\n let fixedTotal = 0;\n sizes.forEach((size) => {\n if (isFixedSize(size)) {\n fixedTotal += resolveSize(size, true, containerPx, rootFontSize);\n }\n });\n\n return fixedTotal > containerPx && fixedTotal > 0 ? containerPx / fixedTotal : 1;\n}\n\n/** Resolves all sizes to pixels at once. Fixed panes get their absolute pixel size, flexible panes\n * share the leftover space by their weight ratio – matching how the layout is rendered with\n * `flex-grow`, so drag math operates on the same pixel sizes the user sees. */\nfunction resolveWorkingSizes(\n sizes: SplitterPaneSize[],\n pixelMode: boolean,\n containerPx: number,\n rootFontSize: number\n): number[] {\n if (!pixelMode) {\n return sizes.map((size) => sizeMagnitude(size));\n }\n\n let fixedTotal = 0;\n let flexibleWeight = 0;\n sizes.forEach((size) => {\n if (isFixedSize(size)) {\n fixedTotal += resolveSize(size, true, containerPx, rootFontSize);\n } else {\n flexibleWeight += sizeMagnitude(size);\n }\n });\n\n const leftover = Math.max(0, containerPx - fixedTotal);\n const fixedScale = getFixedScale(sizes, pixelMode, containerPx, rootFontSize);\n\n return sizes.map((size) => {\n if (isFixedSize(size)) {\n return resolveSize(size, true, containerPx, rootFontSize) * fixedScale;\n }\n return flexibleWeight > 0 ? (sizeMagnitude(size) / flexibleWeight) * leftover : 0;\n });\n}\n\nfunction encodeSize(\n value: number,\n original: SplitterPaneSize,\n pixelMode: boolean,\n containerPx: number,\n rootFontSize: number,\n fixedScale: number = 1\n): SplitterPaneSize {\n if (!pixelMode) {\n return typeof original === 'string' && PERCENT_RE.test(original) ? `${value}%` : value;\n }\n\n if (typeof original === 'number') {\n return containerPx > 0 ? (value / containerPx) * 100 : original;\n }\n\n if (PERCENT_RE.test(original)) {\n return `${containerPx > 0 ? (value / containerPx) * 100 : parseFloat(original)}%`;\n }\n\n const absolute = fixedScale > 0 ? value / fixedScale : value;\n\n if (REM_RE.test(original)) {\n return `${rootFontSize > 0 ? absolute / rootFontSize : 0}rem`;\n }\n\n return `${absolute}px`;\n}\n\n/** Encodes working pixel sizes back to raw sizes after a resize, keeping the unit each pane was\n * declared in. Panes whose working size did not change keep their original raw value. When fixed\n * panes overflow the container they render down-scaled, so their working sizes are scaled back up to\n * absolute sizes (preserving their declared sizes). If the resize instead hands space to a flexible\n * pane the overflow clears and the layout leaves the down-scaled regime: every pane is then encoded\n * from its current working size – including untouched fixed panes (so they do not jump back to their\n * over-sized value) and untouched flexible panes (so a pane that was squeezed to `0` does not keep a\n * stale weight and steal the freed space on the next render). */\nfunction encodeWorkingSizes(\n nextWorking: number[],\n baseWorking: number[],\n baseRaw: SplitterPaneSize[],\n pixelMode: boolean,\n containerPx: number,\n rootFontSize: number\n): SplitterPaneSize[] {\n const fixedScale = getFixedScale(baseRaw, pixelMode, containerPx, rootFontSize);\n\n let fixedWorkingSum = 0;\n nextWorking.forEach((value, i) => {\n if (isFixedSize(baseRaw[i])) {\n fixedWorkingSum += value;\n }\n });\n const overflowCleared = fixedScale < 1 && fixedWorkingSum < containerPx - 1e-6;\n const encodeScale = overflowCleared ? 1 : fixedScale;\n\n return nextWorking.map((value, i) =>\n overflowCleared || Math.abs(value - baseWorking[i]) > 1e-6\n ? encodeSize(value, baseRaw[i], pixelMode, containerPx, rootFontSize, encodeScale)\n : baseRaw[i]\n );\n}\n\nfunction resolvePanel(\n panel: UseSplitterPanel,\n pixelMode: boolean,\n containerPx: number,\n rootFontSize: number\n): UseSplitterResolvedPanel {\n return {\n defaultSize: resolveSize(panel.defaultSize, pixelMode, containerPx, rootFontSize),\n min: panel.min != null ? resolveSize(panel.min, pixelMode, containerPx, rootFontSize) : 0,\n max:\n panel.max != null\n ? resolveSize(panel.max, pixelMode, containerPx, rootFontSize)\n : pixelMode\n ? containerPx\n : 100,\n collapseThreshold:\n panel.collapseThreshold != null\n ? resolveSize(panel.collapseThreshold, pixelMode, containerPx, rootFontSize)\n : undefined,\n collapsible: panel.collapsible,\n };\n}\n\nfunction resolveStep(\n step: SplitterStep,\n pixelMode: boolean,\n containerPx: number,\n rootFontSize: number\n): number {\n return resolveSize(step, pixelMode, containerPx, rootFontSize);\n}\n\nfunction clamp(value: number, min: number, max: number): number {\n return Math.min(Math.max(value, min), max);\n}\n\nfunction getMin(panel: UseSplitterResolvedPanel): number {\n return panel.min ?? 0;\n}\n\nfunction getMax(panel: UseSplitterResolvedPanel): number {\n return panel.max ?? Infinity;\n}\n\nfunction getCollapseThreshold(panel: UseSplitterResolvedPanel): number {\n return panel.collapseThreshold ?? getMin(panel);\n}\n\ninterface SplitterInternalState {\n isDragging: boolean;\n handleIndex: number;\n startPointer: number;\n containerSize: number;\n rootFontSize: number;\n pixelMode: boolean;\n startSizes: number[];\n startRaw: SplitterPaneSize[];\n preCollapseSizes: SplitterPaneSize[];\n}\n\nfunction createInitialInternalState(): SplitterInternalState {\n return {\n isDragging: false,\n handleIndex: -1,\n startPointer: 0,\n containerSize: 0,\n rootFontSize: 16,\n pixelMode: false,\n startSizes: [],\n startRaw: [],\n preCollapseSizes: [],\n };\n}\n\nfunction checkCollapse(\n sizes: number[],\n panels: UseSplitterResolvedPanel[],\n handleIndex: number,\n delta: number\n): number[] | null {\n const beforeIdx = handleIndex;\n const afterIdx = handleIndex + 1;\n const beforePanel = panels[beforeIdx];\n const afterPanel = panels[afterIdx];\n\n const rawBefore = sizes[beforeIdx] + delta;\n const rawAfter = sizes[afterIdx] - delta;\n\n if (\n beforePanel.collapsible &&\n rawBefore < getCollapseThreshold(beforePanel) &&\n rawBefore < sizes[beforeIdx]\n ) {\n const result = [...sizes];\n result[afterIdx] += result[beforeIdx];\n result[beforeIdx] = 0;\n return result;\n }\n\n if (\n afterPanel.collapsible &&\n rawAfter < getCollapseThreshold(afterPanel) &&\n rawAfter < sizes[afterIdx]\n ) {\n const result = [...sizes];\n result[beforeIdx] += result[afterIdx];\n result[afterIdx] = 0;\n return result;\n }\n\n return null;\n}\n\nfunction applyAdjacentOnly(\n sizes: number[],\n panels: UseSplitterResolvedPanel[],\n handleIndex: number,\n delta: number\n): number[] {\n const result = [...sizes];\n const beforeIdx = handleIndex;\n const afterIdx = handleIndex + 1;\n\n const total = result[beforeIdx] + result[afterIdx];\n const effectiveBeforeMax = Math.min(getMax(panels[beforeIdx]), total - getMin(panels[afterIdx]));\n const effectiveBeforeMin = Math.max(getMin(panels[beforeIdx]), total - getMax(panels[afterIdx]));\n const newBefore = clamp(result[beforeIdx] + delta, effectiveBeforeMin, effectiveBeforeMax);\n result[beforeIdx] = newBefore;\n result[afterIdx] = total - newBefore;\n return result;\n}\n\nfunction redistributeNearest(\n sizes: number[],\n panels: UseSplitterResolvedPanel[],\n handleIndex: number,\n delta: number\n): number[] {\n const result = [...sizes];\n\n if (delta > 0) {\n const growIdx = handleIndex;\n const maxGrow = getMax(panels[growIdx]) - result[growIdx];\n const wantedGrow = Math.min(delta, maxGrow);\n\n let taken = 0;\n for (let i = handleIndex + 1; i < result.length && taken < wantedGrow; i += 1) {\n const canGive = result[i] - getMin(panels[i]);\n const take = Math.min(canGive, wantedGrow - taken);\n result[i] -= take;\n taken += take;\n }\n\n result[growIdx] += taken;\n } else if (delta < 0) {\n const growIdx = handleIndex + 1;\n const maxGrow = getMax(panels[growIdx]) - result[growIdx];\n const wantedGrow = Math.min(Math.abs(delta), maxGrow);\n\n let taken = 0;\n for (let i = handleIndex; i >= 0 && taken < wantedGrow; i -= 1) {\n const canGive = result[i] - getMin(panels[i]);\n const take = Math.min(canGive, wantedGrow - taken);\n result[i] -= take;\n taken += take;\n }\n\n result[growIdx] += taken;\n }\n\n return result;\n}\n\nfunction redistributeEqual(\n sizes: number[],\n panels: UseSplitterResolvedPanel[],\n handleIndex: number,\n delta: number\n): number[] {\n const result = [...sizes];\n\n if (delta > 0) {\n const growIdx = handleIndex;\n const maxGrow = getMax(panels[growIdx]) - result[growIdx];\n const wantedGrow = Math.min(delta, maxGrow);\n\n const donors: number[] = [];\n for (let i = handleIndex + 1; i < result.length; i += 1) {\n if (result[i] > getMin(panels[i])) {\n donors.push(i);\n }\n }\n\n let remaining = wantedGrow;\n while (remaining > 0.001 && donors.length > 0) {\n const perDonor = remaining / donors.length;\n const exhausted: number[] = [];\n\n for (let d = 0; d < donors.length; d += 1) {\n const idx = donors[d];\n const canGive = result[idx] - getMin(panels[idx]);\n const take = Math.min(canGive, perDonor);\n result[idx] -= take;\n remaining -= take;\n if (canGive <= perDonor + 0.001) {\n exhausted.push(d);\n }\n }\n\n for (let i = exhausted.length - 1; i >= 0; i -= 1) {\n donors.splice(exhausted[i], 1);\n }\n\n if (exhausted.length === 0) {\n break;\n }\n }\n\n result[growIdx] += wantedGrow - remaining;\n } else if (delta < 0) {\n const growIdx = handleIndex + 1;\n const maxGrow = getMax(panels[growIdx]) - result[growIdx];\n const wantedGrow = Math.min(Math.abs(delta), maxGrow);\n\n const donors: number[] = [];\n for (let i = handleIndex; i >= 0; i -= 1) {\n if (result[i] > getMin(panels[i])) {\n donors.push(i);\n }\n }\n\n let remaining = wantedGrow;\n while (remaining > 0.001 && donors.length > 0) {\n const perDonor = remaining / donors.length;\n const exhausted: number[] = [];\n\n for (let d = 0; d < donors.length; d += 1) {\n const idx = donors[d];\n const canGive = result[idx] - getMin(panels[idx]);\n const take = Math.min(canGive, perDonor);\n result[idx] -= take;\n remaining -= take;\n if (canGive <= perDonor + 0.001) {\n exhausted.push(d);\n }\n }\n\n for (let i = exhausted.length - 1; i >= 0; i -= 1) {\n donors.splice(exhausted[i], 1);\n }\n\n if (exhausted.length === 0) {\n break;\n }\n }\n\n result[growIdx] += wantedGrow - remaining;\n }\n\n return result;\n}\n\nfunction applyConstraints(\n sizes: number[],\n panels: UseSplitterResolvedPanel[],\n handleIndex: number,\n delta: number,\n redistribute?: 'nearest' | 'equal' | UseSplitterRedistributeFn\n): number[] {\n if (typeof redistribute === 'function') {\n return redistribute({ sizes: [...sizes], panels, handleIndex, delta });\n }\n\n if (redistribute === 'nearest' || redistribute === 'equal') {\n const strategy = redistribute === 'nearest' ? redistributeNearest : redistributeEqual;\n const result = strategy(sizes, panels, handleIndex, delta);\n\n const beforeIdx = handleIndex;\n const afterIdx = handleIndex + 1;\n const beforePanel = panels[beforeIdx];\n const afterPanel = panels[afterIdx];\n\n if (\n beforePanel.collapsible &&\n result[beforeIdx] < getCollapseThreshold(beforePanel) &&\n result[beforeIdx] < sizes[beforeIdx]\n ) {\n const freed = result[beforeIdx];\n result[afterIdx] += freed;\n result[beforeIdx] = 0;\n } else if (\n afterPanel.collapsible &&\n result[afterIdx] < getCollapseThreshold(afterPanel) &&\n result[afterIdx] < sizes[afterIdx]\n ) {\n const freed = result[afterIdx];\n result[beforeIdx] += freed;\n result[afterIdx] = 0;\n }\n\n return result;\n }\n\n const collapsed = checkCollapse(sizes, panels, handleIndex, delta);\n if (collapsed) {\n return collapsed;\n }\n\n return applyAdjacentOnly(sizes, panels, handleIndex, delta);\n}\n\nexport function useSplitter<T extends HTMLElement = any>(\n options: UseSplitterOptions\n): UseSplitterReturnValue<T> {\n const {\n panels,\n orientation = 'horizontal',\n sizes: controlledSizes,\n onSizeChange,\n onCollapseChange,\n redistribute,\n step = 1,\n shiftStep = 10,\n dir = 'ltr',\n resetOnDoubleClick = true,\n enabled = true,\n } = options;\n\n const pixelMode = detectPixelMode(options);\n\n const defaultSizes = panels.map((panel) => panel.defaultSize);\n\n const [currentSizes, setCurrentSizes] = useUncontrolled<SplitterPaneSize[]>({\n value: controlledSizes,\n defaultValue: defaultSizes,\n finalValue: defaultSizes,\n onChange: onSizeChange,\n });\n\n const [activeHandle, setActiveHandle] = useState(-1);\n const [containerSize, setContainerSize] = useState(0);\n\n const optionsRef = useRef(options);\n optionsRef.current = options;\n\n const internalStateRef = useRef<SplitterInternalState>(createInitialInternalState());\n const containerRef = useRef<T | null>(null);\n const containerSizeRef = useRef(0);\n const rootFontSizeRef = useRef(16);\n const documentControllerRef = useRef<AbortController | null>(null);\n const frameRef = useRef(0);\n const currentSizesRef = useRef(currentSizes);\n currentSizesRef.current = currentSizes;\n\n const preCollapseSizesRef = useRef<SplitterPaneSize[]>(defaultSizes);\n\n const collapsed = currentSizes.map((size) => sizeMagnitude(size) === 0);\n\n const measureContainer = useCallback(() => {\n const node = containerRef.current;\n if (!node) {\n return 0;\n }\n const rect = node.getBoundingClientRect();\n return (optionsRef.current.orientation ?? 'horizontal') === 'horizontal'\n ? rect.width\n : rect.height;\n }, []);\n\n const updateSizes = useCallback(\n (newSizes: SplitterPaneSize[]) => {\n currentSizesRef.current = newSizes;\n setCurrentSizes(newSizes);\n },\n [setCurrentSizes]\n );\n\n const collapsePanel = useCallback(\n (panelIndex: number) => {\n if (!panels[panelIndex]?.collapsible) {\n return;\n }\n const raw = currentSizesRef.current;\n if (sizeMagnitude(raw[panelIndex]) === 0) {\n return;\n }\n\n const container = pixelMode ? containerSizeRef.current || measureContainer() : 0;\n const rootFontSize = rootFontSizeRef.current;\n const working = resolveWorkingSizes(raw, pixelMode, container, rootFontSize);\n\n preCollapseSizesRef.current = [...raw];\n const freedSize = working[panelIndex];\n working[panelIndex] = 0;\n\n const neighbor = panelIndex === 0 ? 1 : panelIndex - 1;\n working[neighbor] += freedSize;\n\n updateSizes(\n working.map((value, i) => encodeSize(value, raw[i], pixelMode, container, rootFontSize))\n );\n onCollapseChange?.(panelIndex, true);\n },\n [panels, pixelMode, measureContainer, updateSizes, onCollapseChange]\n );\n\n const expandPanel = useCallback(\n (panelIndex: number) => {\n if (!panels[panelIndex]?.collapsible) {\n return;\n }\n const raw = currentSizesRef.current;\n if (sizeMagnitude(raw[panelIndex]) !== 0) {\n return;\n }\n\n const container = pixelMode ? containerSizeRef.current || measureContainer() : 0;\n const rootFontSize = rootFontSizeRef.current;\n const working = resolveWorkingSizes(raw, pixelMode, container, rootFontSize);\n\n const preCollapse = preCollapseSizesRef.current;\n const restoreSource =\n preCollapse[panelIndex] != null && sizeMagnitude(preCollapse[panelIndex]) !== 0\n ? preCollapse[panelIndex]\n : panels[panelIndex].defaultSize;\n const restoreSize = resolveSize(restoreSource, pixelMode, container, rootFontSize);\n\n const neighbor = panelIndex === 0 ? 1 : panelIndex - 1;\n const neighborMin =\n panels[neighbor].min != null\n ? resolveSize(panels[neighbor].min!, pixelMode, container, rootFontSize)\n : 0;\n const available = Math.max(0, working[neighbor] - neighborMin);\n const actualRestore = Math.min(restoreSize, available);\n\n if (actualRestore <= 0) {\n return;\n }\n\n working[panelIndex] = actualRestore;\n working[neighbor] -= actualRestore;\n\n updateSizes(\n working.map((value, i) => encodeSize(value, raw[i], pixelMode, container, rootFontSize))\n );\n onCollapseChange?.(panelIndex, false);\n },\n [panels, pixelMode, measureContainer, updateSizes, onCollapseChange]\n );\n\n const toggleCollapsePanel = useCallback(\n (panelIndex: number) => {\n if (sizeMagnitude(currentSizesRef.current[panelIndex]) === 0) {\n expandPanel(panelIndex);\n } else {\n collapsePanel(panelIndex);\n }\n },\n [collapsePanel, expandPanel]\n );\n\n const emitCollapseTransitions = useCallback(\n (\n prev: SplitterPaneSize[],\n next: number[],\n indices: number[],\n preCollapseSnapshot: SplitterPaneSize[]\n ) => {\n const onChange = optionsRef.current.onCollapseChange;\n for (const idx of indices) {\n const wasCollapsed = sizeMagnitude(prev[idx]) === 0;\n const nowCollapsed = next[idx] === 0;\n if (!wasCollapsed && nowCollapsed) {\n preCollapseSizesRef.current = [...preCollapseSnapshot];\n onChange?.(idx, true);\n } else if (wasCollapsed && !nowCollapsed) {\n onChange?.(idx, false);\n }\n }\n },\n []\n );\n\n const reset = useCallback(\n (handleIndex: number) => {\n const raw = currentSizesRef.current;\n\n const beforeIdx = handleIndex;\n const afterIdx = handleIndex + 1;\n if (beforeIdx < 0 || afterIdx >= raw.length) {\n return;\n }\n\n const container = pixelMode ? containerSizeRef.current || measureContainer() : 0;\n const rootFontSize = rootFontSizeRef.current;\n const working = resolveWorkingSizes(raw, pixelMode, container, rootFontSize);\n const resolvedPanels = optionsRef.current.panels.map((panel) =>\n resolvePanel(panel, pixelMode, container, rootFontSize)\n );\n\n const total = working[beforeIdx] + working[afterIdx];\n const defBefore = resolvedPanels[beforeIdx].defaultSize;\n const defAfter = resolvedPanels[afterIdx].defaultSize;\n const defTotal = defBefore + defAfter;\n const targetBefore = defTotal === 0 ? total / 2 : total * (defBefore / defTotal);\n\n const next = applyAdjacentOnly(\n working,\n resolvedPanels,\n beforeIdx,\n targetBefore - working[beforeIdx]\n );\n emitCollapseTransitions(raw, next, [beforeIdx, afterIdx], raw);\n updateSizes(encodeWorkingSizes(next, working, raw, pixelMode, container, rootFontSize));\n },\n [emitCollapseTransitions, updateSizes, pixelMode, measureContainer]\n );\n\n const containerRefCallback: React.RefCallback<T | null> = useCallback((node) => {\n containerRef.current = node;\n }, []);\n\n useEffect(() => {\n if (!pixelMode || typeof ResizeObserver === 'undefined') {\n return undefined;\n }\n\n const node = containerRef.current;\n if (!node) {\n return undefined;\n }\n\n let frame = 0;\n const update = () => {\n const rect = node.getBoundingClientRect();\n const size =\n (optionsRef.current.orientation ?? 'horizontal') === 'horizontal'\n ? rect.width\n : rect.height;\n rootFontSizeRef.current = getRootFontSize();\n containerSizeRef.current = size;\n setContainerSize((prev) => (prev !== size ? size : prev));\n };\n\n const observer = new ResizeObserver(() => {\n cancelAnimationFrame(frame);\n frame = requestAnimationFrame(update);\n });\n\n observer.observe(node);\n update();\n\n return () => {\n cancelAnimationFrame(frame);\n observer.disconnect();\n };\n }, [pixelMode, orientation]);\n\n const handleRefCallbacks = useRef<Map<number, (node: HTMLElement | null) => void>>(new Map());\n const handleElementControllers = useRef<Map<number, AbortController>>(new Map());\n\n const getHandleRefCallback = useCallback(\n (handleIndex: number): React.RefCallback<HTMLElement> => {\n if (handleRefCallbacks.current.has(handleIndex)) {\n return handleRefCallbacks.current.get(handleIndex)!;\n }\n\n const callback = (node: HTMLElement | null) => {\n const existingController = handleElementControllers.current.get(handleIndex);\n if (existingController) {\n existingController.abort();\n handleElementControllers.current.delete(handleIndex);\n }\n\n if (!node) {\n return;\n }\n\n const elementController = new AbortController();\n handleElementControllers.current.set(handleIndex, elementController);\n\n const onPointerDown = (event: PointerEvent) => {\n if (optionsRef.current.enabled === false) {\n return;\n }\n if (event.button !== 0) {\n return;\n }\n\n const container = containerRef.current;\n if (!container) {\n return;\n }\n\n const opts = optionsRef.current;\n const isHorizontal = (opts.orientation ?? 'horizontal') === 'horizontal';\n const rect = container.getBoundingClientRect();\n const containerSizePx = isHorizontal ? rect.width : rect.height;\n const pointerPos = isHorizontal ? event.clientX : event.clientY;\n const isPixelMode = detectPixelMode(opts);\n const rootFontSize = getRootFontSize();\n\n const s = internalStateRef.current;\n s.isDragging = true;\n s.handleIndex = handleIndex;\n s.startPointer = pointerPos;\n s.containerSize = containerSizePx;\n s.rootFontSize = rootFontSize;\n s.pixelMode = isPixelMode;\n s.startRaw = [...currentSizesRef.current];\n s.startSizes = resolveWorkingSizes(\n s.startRaw,\n isPixelMode,\n containerSizePx,\n rootFontSize\n );\n s.preCollapseSizes = [...preCollapseSizesRef.current];\n\n setActiveHandle(handleIndex);\n document.body.style.userSelect = 'none';\n document.body.style.webkitUserSelect = 'none';\n document.body.style.cursor = isHorizontal ? 'col-resize' : 'row-resize';\n\n opts.onResizeStart?.(handleIndex);\n\n documentControllerRef.current?.abort();\n documentControllerRef.current = new AbortController();\n const sig = documentControllerRef.current.signal;\n\n document.addEventListener('pointermove', onPointerMove, { signal: sig });\n document.addEventListener('pointerup', onPointerUp, { signal: sig });\n document.addEventListener('pointercancel', onPointerUp, { signal: sig });\n };\n\n const flushResize = (pointerEvent: PointerEvent) => {\n const s = internalStateRef.current;\n if (!s.containerSize) {\n return;\n }\n const opts = optionsRef.current;\n const isHorizontal = (opts.orientation ?? 'horizontal') === 'horizontal';\n const isRtl = isHorizontal && opts.dir === 'rtl';\n const pointerPos = isHorizontal ? pointerEvent.clientX : pointerEvent.clientY;\n const pixelDelta = (isRtl ? -1 : 1) * (pointerPos - s.startPointer);\n const delta = s.pixelMode ? pixelDelta : (pixelDelta / s.containerSize) * 100;\n\n const resolvedPanels = opts.panels.map((panel) =>\n resolvePanel(panel, s.pixelMode, s.containerSize, s.rootFontSize)\n );\n\n const newSizes = applyConstraints(\n s.startSizes,\n resolvedPanels,\n s.handleIndex,\n delta,\n opts.redistribute\n );\n\n const prevSizes = currentSizesRef.current;\n emitCollapseTransitions(\n prevSizes,\n newSizes,\n [s.handleIndex, s.handleIndex + 1],\n s.startRaw\n );\n\n const encoded = encodeWorkingSizes(\n newSizes,\n s.startSizes,\n s.startRaw,\n s.pixelMode,\n s.containerSize,\n s.rootFontSize\n );\n currentSizesRef.current = encoded;\n setCurrentSizes(encoded);\n };\n\n const onPointerMove = (event: PointerEvent) => {\n const s = internalStateRef.current;\n if (!s.isDragging) {\n return;\n }\n\n cancelAnimationFrame(frameRef.current);\n frameRef.current = requestAnimationFrame(() => {\n flushResize(event);\n });\n };\n\n const onPointerUp = (event: PointerEvent) => {\n const s = internalStateRef.current;\n if (!s.isDragging) {\n return;\n }\n\n cancelAnimationFrame(frameRef.current);\n flushResize(event);\n\n s.isDragging = false;\n const finishedHandle = s.handleIndex;\n s.handleIndex = -1;\n\n setActiveHandle(-1);\n document.body.style.userSelect = '';\n document.body.style.webkitUserSelect = '';\n document.body.style.cursor = '';\n\n documentControllerRef.current?.abort();\n documentControllerRef.current = null;\n\n optionsRef.current.onResizeEnd?.(finishedHandle, [...currentSizesRef.current]);\n };\n\n node.addEventListener('pointerdown', onPointerDown, {\n signal: elementController.signal,\n });\n };\n\n handleRefCallbacks.current.set(handleIndex, callback);\n return callback;\n },\n [setCurrentSizes]\n );\n\n const getHandleProps = useCallback(\n (input: { index: number }) => {\n const { index } = input;\n const orient = orientation;\n const rootFontSize = rootFontSizeRef.current;\n const working = resolveWorkingSizes(currentSizes, pixelMode, containerSize, rootFontSize);\n const resolvedPanels = panels.map((panel) =>\n resolvePanel(panel, pixelMode, containerSize, rootFontSize)\n );\n const beforeSize = working[index] ?? 0;\n const beforePanel = resolvedPanels[index];\n\n return {\n ref: getHandleRefCallback(index),\n role: 'separator' as const,\n 'aria-orientation': orient,\n 'aria-valuenow': Math.round(beforeSize),\n 'aria-valuemin': Math.round(getMin(beforePanel)),\n 'aria-valuemax': Math.round(getMax(beforePanel)),\n tabIndex: 0,\n onKeyDown: (event: React.KeyboardEvent) => {\n if (!enabled) {\n return;\n }\n\n const isHorizontal = orient === 'horizontal';\n const isRtl = dir === 'rtl';\n\n const container = pixelMode ? containerSizeRef.current || measureContainer() : 0;\n const liveRootFontSize = rootFontSizeRef.current;\n const liveWorking = resolveWorkingSizes(\n currentSizes,\n pixelMode,\n container,\n liveRootFontSize\n );\n const livePanels = panels.map((panel) =>\n resolvePanel(panel, pixelMode, container, liveRootFontSize)\n );\n const liveBeforePanel = livePanels[index];\n const liveAfterPanel = livePanels[index + 1];\n\n let delta = 0;\n const currentStep = resolveStep(\n event.shiftKey ? shiftStep : step,\n pixelMode,\n container,\n liveRootFontSize\n );\n\n switch (event.key) {\n case 'ArrowLeft': {\n if (!isHorizontal) {\n return;\n }\n delta = isRtl ? currentStep : -currentStep;\n break;\n }\n case 'ArrowRight': {\n if (!isHorizontal) {\n return;\n }\n delta = isRtl ? -currentStep : currentStep;\n break;\n }\n case 'ArrowUp': {\n if (isHorizontal) {\n return;\n }\n delta = -currentStep;\n break;\n }\n case 'ArrowDown': {\n if (isHorizontal) {\n return;\n }\n delta = currentStep;\n break;\n }\n case 'Home': {\n delta = -(liveWorking[index] - getMin(liveBeforePanel));\n break;\n }\n case 'End': {\n delta = getMax(liveBeforePanel) - liveWorking[index];\n break;\n }\n case 'Enter': {\n const beforeCollapsible = liveBeforePanel?.collapsible;\n const afterCollapsible = liveAfterPanel?.collapsible;\n\n if (beforeCollapsible && liveWorking[index] <= liveWorking[index + 1]) {\n toggleCollapsePanel(index);\n event.preventDefault();\n return;\n }\n if (afterCollapsible) {\n toggleCollapsePanel(index + 1);\n event.preventDefault();\n return;\n }\n if (beforeCollapsible) {\n toggleCollapsePanel(index);\n event.preventDefault();\n return;\n }\n return;\n }\n default:\n return;\n }\n\n event.preventDefault();\n\n if (delta !== 0) {\n const newSizes = applyConstraints(liveWorking, livePanels, index, delta, redistribute);\n emitCollapseTransitions(currentSizes, newSizes, [index, index + 1], currentSizes);\n updateSizes(\n encodeWorkingSizes(\n newSizes,\n liveWorking,\n currentSizes,\n pixelMode,\n container,\n liveRootFontSize\n )\n );\n }\n },\n onDoubleClick: () => {\n if (!enabled || !resetOnDoubleClick) {\n return;\n }\n reset(index);\n },\n 'data-active': activeHandle === index || undefined,\n 'data-orientation': orient,\n };\n },\n [\n orientation,\n currentSizes,\n panels,\n pixelMode,\n containerSize,\n enabled,\n dir,\n step,\n shiftStep,\n resetOnDoubleClick,\n activeHandle,\n redistribute,\n measureContainer,\n getHandleRefCallback,\n toggleCollapsePanel,\n updateSizes,\n emitCollapseTransitions,\n reset,\n ]\n );\n\n useEffect(\n () => () => {\n documentControllerRef.current?.abort();\n documentControllerRef.current = null;\n handleElementControllers.current.forEach((controller) => controller.abort());\n handleElementControllers.current.clear();\n cancelAnimationFrame(frameRef.current);\n\n if (internalStateRef.current.isDragging) {\n internalStateRef.current.isDragging = false;\n document.body.style.userSelect = '';\n document.body.style.webkitUserSelect = '';\n document.body.style.cursor = '';\n }\n },\n []\n );\n\n return {\n ref: containerRefCallback,\n sizes: currentSizes,\n pixelMode,\n collapsed,\n activeHandle,\n getHandleProps,\n setSizes: updateSizes,\n collapse: collapsePanel,\n expand: expandPanel,\n toggleCollapse: toggleCollapsePanel,\n reset,\n };\n}\n\nexport namespace useSplitter {\n export type Panel = UseSplitterPanel;\n export type Options = UseSplitterOptions;\n export type RedistributeInput = UseSplitterRedistributeInput;\n export type RedistributeFn = UseSplitterRedistributeFn;\n export type ResolvedPanel = UseSplitterResolvedPanel;\n export type ReturnValue<T extends HTMLElement = any> = UseSplitterReturnValue<T>;\n export type PaneSize = SplitterPaneSize;\n export type Step = SplitterStep;\n}\n"],"mappings":";;;;AA6HA,MAAM,QAAQ;AACd,MAAM,SAAS;AACf,MAAM,aAAa;AAEnB,SAAS,YAAY,MAA6C;CAChE,OAAO,OAAO,SAAS,aAAa,MAAM,KAAK,IAAI,KAAK,OAAO,KAAK,IAAI;AAC1E;AAEA,SAAS,cAAc,MAAgC;CACrD,OAAO,OAAO,SAAS,WAAW,OAAO,WAAW,IAAI;AAC1D;AAEA,SAAS,gBAAgB,SAAsC;CAC7D,OACE,QAAQ,OAAO,MACZ,UACC,YAAY,MAAM,WAAW,KAC7B,YAAY,MAAM,GAAG,KACrB,YAAY,MAAM,GAAG,KACrB,YAAY,MAAM,iBAAiB,CACvC,KACA,YAAY,QAAQ,IAAI,KACxB,YAAY,QAAQ,SAAS,MAC5B,QAAQ,OAAO,KAAK,WAAW,KAAK;AAEzC;AAEA,SAAS,kBAA0B;CACjC,IAAI,OAAO,WAAW,aACpB,OAAO;CAET,MAAM,WAAW,WAAW,iBAAiB,SAAS,eAAe,CAAC,CAAC,QAAQ;CAC/E,OAAO,OAAO,SAAS,QAAQ,KAAK,WAAW,IAAI,WAAW;AAChE;AAEA,SAAS,YACP,MACA,WACA,aACA,cACQ;CACR,IAAI,CAAC,WACH,OAAO,cAAc,IAAI;CAG3B,IAAI,OAAO,SAAS,UAClB,OAAQ,OAAO,MAAO;CAGxB,MAAM,UAAU,WAAW,KAAK,IAAI;CACpC,IAAI,SACF,OAAQ,WAAW,QAAQ,EAAE,IAAI,MAAO;CAG1C,MAAM,MAAM,OAAO,KAAK,IAAI;CAC5B,IAAI,KACF,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ACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CACF;CAEA,CAAA,GAAA,MAAA,UAAA,aACc;EACV,sBAAsB,SAAS,MAAM;EACrC,sBAAsB,UAAU;EAChC,yBAAyB,QAAQ,SAAS,eAAe,WAAW,MAAM,CAAC;EAC3E,yBAAyB,QAAQ,MAAM;EACvC,qBAAqB,SAAS,OAAO;EAErC,IAAI,iBAAiB,QAAQ,YAAY;GACvC,iBAAiB,QAAQ,aAAa;GACtC,SAAS,KAAK,MAAM,aAAa;GACjC,SAAS,KAAK,MAAM,mBAAmB;GACvC,SAAS,KAAK,MAAM,SAAS;EAC/B;CACF,GACA,CAAC,CACH;CAEA,OAAO;EACL,KAAK;EACL,OAAO;EACP;EACA;EACA;EACA;EACA,UAAU;EACV,UAAU;EACV,QAAQ;EACR,gBAAgB;EAChB;CACF;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"use-state-history.cjs","names":[],"sources":["../../src/use-state-history/use-state-history.ts"],"sourcesContent":["import { useCallback, useMemo, useState } from 'react';\n\nexport interface UseStateHistoryHandlers<T> {\n set: (value: T) => void;\n back: (steps?: number) => void;\n forward: (steps?: number) => void;\n reset: () => void;\n}\n\nexport interface UseStateHistoryValue<T> {\n history: T[];\n current: number;\n}\n\nexport type UseStateHistoryReturnValue<T> = [\n T,\n UseStateHistoryHandlers<T>,\n UseStateHistoryValue<T>,\n];\n\nexport function useStateHistory<T>(initialValue: T): UseStateHistoryReturnValue<T> {\n const [state, setState] = useState<UseStateHistoryValue<T>>({\n history: [initialValue],\n current: 0,\n });\n\n const set = useCallback(\n (val: T) =>\n setState((currentState) => {\n const nextState = [...currentState.history.slice(0, currentState.current + 1), val];\n return {\n history: nextState,\n current: nextState.length - 1,\n };\n }),\n []\n );\n\n const back = useCallback(\n (steps = 1) =>\n setState((currentState) => ({\n history: currentState.history,\n current: Math.max(0, currentState.current - steps),\n })),\n []\n );\n\n const forward = useCallback(\n (steps = 1) =>\n setState((currentState) => ({\n history: currentState.history,\n current: Math.min(currentState.history.length - 1, currentState.current + steps),\n })),\n []\n );\n\n const reset = useCallback(() => {\n setState({ history: [initialValue], current: 0 });\n }, [initialValue]);\n\n const handlers = useMemo(() => ({ back, forward, reset, set }), [back, forward, reset, set]);\n\n return [state.history[state.current], handlers, state];\n}\n\nexport namespace useStateHistory {\n export type Handlers<T> = UseStateHistoryHandlers<T>;\n export type Value<T> = UseStateHistoryValue<T>;\n export type ReturnValue<T> = UseStateHistoryReturnValue<T>;\n}\n"],"mappings":";;;AAoBA,SAAgB,gBAAmB,cAAgD;CACjF,MAAM,CAAC,OAAO,aAAA,GAAA,MAAA,UAA8C;EAC1D,SAAS,CAAC,YAAY;EACtB,SAAS;CACX,CAAC;CAED,MAAM,OAAA,GAAA,MAAA,cACH,QACC,UAAU,iBAAiB;EACzB,MAAM,YAAY,CAAC,GAAG,aAAa,QAAQ,MAAM,GAAG,aAAa,UAAU,CAAC,GAAG,GAAG;EAClF,OAAO;GACL,SAAS;GACT,SAAS,UAAU,SAAS;EAC9B;CACF,CAAC,GACH,CAAC,CACH;CAEA,MAAM,QAAA,GAAA,MAAA,cACH,QAAQ,MACP,UAAU,kBAAkB;EAC1B,SAAS,aAAa;EACtB,SAAS,KAAK,IAAI,GAAG,aAAa,UAAU,KAAK;CACnD,EAAE,GACJ,CAAC,CACH;CAEA,MAAM,WAAA,GAAA,MAAA,cACH,QAAQ,MACP,UAAU,kBAAkB;EAC1B,SAAS,aAAa;EACtB,SAAS,KAAK,IAAI,aAAa,QAAQ,SAAS,GAAG,aAAa,UAAU,KAAK;CACjF,EAAE,GACJ,CAAC,CACH;CAEA,MAAM,SAAA,GAAA,MAAA,mBAA0B;EAC9B,SAAS;GAAE,SAAS,CAAC,YAAY;GAAG,SAAS;EAAE,CAAC;CAClD,GAAG,CAAC,YAAY,CAAC;CAEjB,MAAM,YAAA,GAAA,MAAA,gBAA0B;EAAE;EAAM;EAAS;EAAO;CAAI,IAAI;EAAC;EAAM;EAAS;EAAO;CAAG,CAAC;CAE3F,OAAO;EAAC,MAAM,QAAQ,MAAM;EAAU;EAAU;CAAK;AACvD"}
1
+ {"version":3,"file":"use-state-history.cjs","names":[],"sources":["../../src/use-state-history/use-state-history.ts"],"sourcesContent":["import { useCallback, useMemo, useState } from 'react';\n\nexport interface UseStateHistoryHandlers<T> {\n set: (value: T) => void;\n back: (steps?: number) => void;\n forward: (steps?: number) => void;\n reset: () => void;\n}\n\nexport interface UseStateHistoryValue<T> {\n history: T[];\n current: number;\n}\n\nexport type UseStateHistoryReturnValue<T> = [\n T,\n UseStateHistoryHandlers<T>,\n UseStateHistoryValue<T>,\n];\n\nexport function useStateHistory<T>(initialValue: T): UseStateHistoryReturnValue<T> {\n const [state, setState] = useState<UseStateHistoryValue<T>>({\n history: [initialValue],\n current: 0,\n });\n\n const set = useCallback(\n (val: T) =>\n setState((currentState) => {\n const nextState = [...currentState.history.slice(0, currentState.current + 1), val];\n return {\n history: nextState,\n current: nextState.length - 1,\n };\n }),\n []\n );\n\n const back = useCallback(\n (steps = 1) =>\n setState((currentState) => ({\n history: currentState.history,\n current: Math.max(0, currentState.current - steps),\n })),\n []\n );\n\n const forward = useCallback(\n (steps = 1) =>\n setState((currentState) => ({\n history: currentState.history,\n current: Math.min(currentState.history.length - 1, currentState.current + steps),\n })),\n []\n );\n\n const reset = useCallback(() => {\n setState({ history: [initialValue], current: 0 });\n }, [initialValue]);\n\n const handlers = useMemo(() => ({ back, forward, reset, set }), [back, forward, reset, set]);\n\n return [state.history[state.current], handlers, state];\n}\n\nexport namespace useStateHistory {\n export type Handlers<T> = UseStateHistoryHandlers<T>;\n export type Value<T> = UseStateHistoryValue<T>;\n export type ReturnValue<T> = UseStateHistoryReturnValue<T>;\n}\n"],"mappings":";;;AAoBA,SAAgB,gBAAmB,cAAgD;CACjF,MAAM,CAAC,OAAO,aAAA,GAAA,MAAA,SAAA,CAA8C;EAC1D,SAAS,CAAC,YAAY;EACtB,SAAS;CACX,CAAC;CAED,MAAM,OAAA,GAAA,MAAA,YAAA,EACH,QACC,UAAU,iBAAiB;EACzB,MAAM,YAAY,CAAC,GAAG,aAAa,QAAQ,MAAM,GAAG,aAAa,UAAU,CAAC,GAAG,GAAG;EAClF,OAAO;GACL,SAAS;GACT,SAAS,UAAU,SAAS;EAC9B;CACF,CAAC,GACH,CAAC,CACH;CAEA,MAAM,QAAA,GAAA,MAAA,YAAA,EACH,QAAQ,MACP,UAAU,kBAAkB;EAC1B,SAAS,aAAa;EACtB,SAAS,KAAK,IAAI,GAAG,aAAa,UAAU,KAAK;CACnD,EAAE,GACJ,CAAC,CACH;CAEA,MAAM,WAAA,GAAA,MAAA,YAAA,EACH,QAAQ,MACP,UAAU,kBAAkB;EAC1B,SAAS,aAAa;EACtB,SAAS,KAAK,IAAI,aAAa,QAAQ,SAAS,GAAG,aAAa,UAAU,KAAK;CACjF,EAAE,GACJ,CAAC,CACH;CAEA,MAAM,SAAA,GAAA,MAAA,YAAA,OAA0B;EAC9B,SAAS;GAAE,SAAS,CAAC,YAAY;GAAG,SAAS;EAAE,CAAC;CAClD,GAAG,CAAC,YAAY,CAAC;CAEjB,MAAM,YAAA,GAAA,MAAA,QAAA,QAA0B;EAAE;EAAM;EAAS;EAAO;CAAI,IAAI;EAAC;EAAM;EAAS;EAAO;CAAG,CAAC;CAE3F,OAAO;EAAC,MAAM,QAAQ,MAAM;EAAU;EAAU;CAAK;AACvD"}
@@ -1 +1 @@
1
- {"version":3,"file":"use-text-selection.cjs","names":["useForceUpdate"],"sources":["../../src/use-text-selection/use-text-selection.ts"],"sourcesContent":["import { useEffect, useEffectEvent, useState } from 'react';\nimport { useForceUpdate } from '../use-force-update/use-force-update';\n\nexport function useTextSelection(): Selection | null {\n const forceUpdate = useForceUpdate();\n const [selection, setSelection] = useState<Selection | null>(null);\n\n const handleSelectionChange = useEffectEvent(() => {\n setSelection(document.getSelection());\n forceUpdate();\n });\n\n useEffect(() => {\n setSelection(document.getSelection());\n document.addEventListener('selectionchange', handleSelectionChange);\n return () => document.removeEventListener('selectionchange', handleSelectionChange);\n }, []);\n\n return selection;\n}\n"],"mappings":";;;;AAGA,SAAgB,mBAAqC;CACnD,MAAM,cAAcA,yBAAAA,eAAe;CACnC,MAAM,CAAC,WAAW,iBAAA,GAAA,MAAA,UAA2C,IAAI;CAEjE,MAAM,yBAAA,GAAA,MAAA,sBAA6C;EACjD,aAAa,SAAS,aAAa,CAAC;EACpC,YAAY;CACd,CAAC;CAED,CAAA,GAAA,MAAA,iBAAgB;EACd,aAAa,SAAS,aAAa,CAAC;EACpC,SAAS,iBAAiB,mBAAmB,qBAAqB;EAClE,aAAa,SAAS,oBAAoB,mBAAmB,qBAAqB;CACpF,GAAG,CAAC,CAAC;CAEL,OAAO;AACT"}
1
+ {"version":3,"file":"use-text-selection.cjs","names":["useForceUpdate"],"sources":["../../src/use-text-selection/use-text-selection.ts"],"sourcesContent":["import { useEffect, useEffectEvent, useState } from 'react';\nimport { useForceUpdate } from '../use-force-update/use-force-update';\n\nexport function useTextSelection(): Selection | null {\n const forceUpdate = useForceUpdate();\n const [selection, setSelection] = useState<Selection | null>(null);\n\n const handleSelectionChange = useEffectEvent(() => {\n setSelection(document.getSelection());\n forceUpdate();\n });\n\n useEffect(() => {\n setSelection(document.getSelection());\n document.addEventListener('selectionchange', handleSelectionChange);\n return () => document.removeEventListener('selectionchange', handleSelectionChange);\n }, []);\n\n return selection;\n}\n"],"mappings":";;;;AAGA,SAAgB,mBAAqC;CACnD,MAAM,cAAcA,yBAAAA,eAAe;CACnC,MAAM,CAAC,WAAW,iBAAA,GAAA,MAAA,SAAA,CAA2C,IAAI;CAEjE,MAAM,yBAAA,GAAA,MAAA,eAAA,OAA6C;EACjD,aAAa,SAAS,aAAa,CAAC;EACpC,YAAY;CACd,CAAC;CAED,CAAA,GAAA,MAAA,UAAA,OAAgB;EACd,aAAa,SAAS,aAAa,CAAC;EACpC,SAAS,iBAAiB,mBAAmB,qBAAqB;EAClE,aAAa,SAAS,oBAAoB,mBAAmB,qBAAqB;CACpF,GAAG,CAAC,CAAC;CAEL,OAAO;AACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"use-throttled-callback.cjs","names":["useCallbackRef"],"sources":["../../src/use-throttled-callback/use-throttled-callback.ts"],"sourcesContent":["import { useCallback, useEffect, useRef } from 'react';\nimport { useCallbackRef } from '../utils';\n\nexport function useThrottledCallbackWithClearTimeout<T extends (...args: any[]) => any>(\n callback: T,\n wait: number\n) {\n const handleCallback = useCallbackRef(callback);\n const latestInArgsRef = useRef<Parameters<T>>(null);\n const latestOutArgsRef = useRef<Parameters<T>>(null);\n const active = useRef(true);\n const waitRef = useRef(wait);\n const timeoutRef = useRef<number>(-1);\n\n const clearTimeout = () => window.clearTimeout(timeoutRef.current);\n\n const callThrottledCallback = useCallback(\n (...args: Parameters<T>) => {\n handleCallback(...args);\n latestInArgsRef.current = args;\n latestOutArgsRef.current = args;\n active.current = false;\n },\n [handleCallback]\n );\n\n const timerCallback = useCallback(() => {\n if (latestInArgsRef.current && latestInArgsRef.current !== latestOutArgsRef.current) {\n callThrottledCallback(...latestInArgsRef.current);\n\n timeoutRef.current = window.setTimeout(timerCallback, waitRef.current);\n } else {\n active.current = true;\n }\n }, [callThrottledCallback]);\n\n const throttled = useCallback(\n (...args: Parameters<T>) => {\n if (active.current) {\n callThrottledCallback(...args);\n timeoutRef.current = window.setTimeout(timerCallback, waitRef.current);\n } else {\n latestInArgsRef.current = args;\n }\n },\n [callThrottledCallback, timerCallback]\n );\n\n useEffect(() => {\n waitRef.current = wait;\n }, [wait]);\n\n return [throttled, clearTimeout] as const;\n}\n\nexport function useThrottledCallback<T extends (...args: any[]) => any>(callback: T, wait: number) {\n const [throttled, clearTimeout] = useThrottledCallbackWithClearTimeout(callback, wait);\n useEffect(() => clearTimeout, []);\n return throttled;\n}\n"],"mappings":";;;;AAGA,SAAgB,qCACd,UACA,MACA;CACA,MAAM,iBAAiB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":["../../src/use-throttled-callback/use-throttled-callback.ts"],"sourcesContent":["import { useCallback, useEffect, useRef } from 'react';\nimport { useCallbackRef } from '../utils';\n\nexport function useThrottledCallbackWithClearTimeout<T extends (...args: any[]) => any>(\n callback: T,\n wait: number\n) {\n const handleCallback = useCallbackRef(callback);\n const latestInArgsRef = useRef<Parameters<T>>(null);\n const latestOutArgsRef = useRef<Parameters<T>>(null);\n const active = useRef(true);\n const waitRef = useRef(wait);\n const timeoutRef = useRef<number>(-1);\n\n const clearTimeout = () => window.clearTimeout(timeoutRef.current);\n\n const callThrottledCallback = useCallback(\n (...args: Parameters<T>) => {\n handleCallback(...args);\n latestInArgsRef.current = args;\n latestOutArgsRef.current = args;\n active.current = false;\n },\n [handleCallback]\n );\n\n const timerCallback = useCallback(() => {\n if (latestInArgsRef.current && latestInArgsRef.current !== latestOutArgsRef.current) {\n callThrottledCallback(...latestInArgsRef.current);\n\n timeoutRef.current = window.setTimeout(timerCallback, waitRef.current);\n } else {\n active.current = true;\n }\n }, [callThrottledCallback]);\n\n const throttled = useCallback(\n (...args: Parameters<T>) => {\n if (active.current) {\n callThrottledCallback(...args);\n timeoutRef.current = window.setTimeout(timerCallback, waitRef.current);\n } else {\n latestInArgsRef.current = args;\n }\n },\n [callThrottledCallback, timerCallback]\n );\n\n useEffect(() => {\n waitRef.current = wait;\n }, [wait]);\n\n return [throttled, clearTimeout] as const;\n}\n\nexport function useThrottledCallback<T extends (...args: any[]) => any>(callback: T, wait: number) {\n const [throttled, clearTimeout] = useThrottledCallbackWithClearTimeout(callback, wait);\n useEffect(() => clearTimeout, []);\n return throttled;\n}\n"],"mappings":";;;;AAGA,SAAgB,qCACd,UACA,MACA;CACA,MAAM,iBAAiBA,yBAAAA,eAAe,QAAQ;CAC9C,MAAM,mBAAA,GAAA,MAAA,OAAA,CAAwC,IAAI;CAClD,MAAM,oBAAA,GAAA,MAAA,OAAA,CAAyC,IAAI;CACnD,MAAM,UAAA,GAAA,MAAA,OAAA,CAAgB,IAAI;CAC1B,MAAM,WAAA,GAAA,MAAA,OAAA,CAAiB,IAAI;CAC3B,MAAM,cAAA,GAAA,MAAA,OAAA,CAA4B,EAAE;CAEpC,MAAM,qBAAqB,OAAO,aAAa,WAAW,OAAO;CAEjE,MAAM,yBAAA,GAAA,MAAA,YAAA,EACH,GAAG,SAAwB;EAC1B,eAAe,GAAG,IAAI;EACtB,gBAAgB,UAAU;EAC1B,iBAAiB,UAAU;EAC3B,OAAO,UAAU;CACnB,GACA,CAAC,cAAc,CACjB;CAEA,MAAM,iBAAA,GAAA,MAAA,YAAA,OAAkC;EACtC,IAAI,gBAAgB,WAAW,gBAAgB,YAAY,iBAAiB,SAAS;GACnF,sBAAsB,GAAG,gBAAgB,OAAO;GAEhD,WAAW,UAAU,OAAO,WAAW,eAAe,QAAQ,OAAO;EACvE,OACE,OAAO,UAAU;CAErB,GAAG,CAAC,qBAAqB,CAAC;CAE1B,MAAM,aAAA,GAAA,MAAA,YAAA,EACH,GAAG,SAAwB;EAC1B,IAAI,OAAO,SAAS;GAClB,sBAAsB,GAAG,IAAI;GAC7B,WAAW,UAAU,OAAO,WAAW,eAAe,QAAQ,OAAO;EACvE,OACE,gBAAgB,UAAU;CAE9B,GACA,CAAC,uBAAuB,aAAa,CACvC;CAEA,CAAA,GAAA,MAAA,UAAA,OAAgB;EACd,QAAQ,UAAU;CACpB,GAAG,CAAC,IAAI,CAAC;CAET,OAAO,CAAC,WAAW,YAAY;AACjC;AAEA,SAAgB,qBAAwD,UAAa,MAAc;CACjG,MAAM,CAAC,WAAW,gBAAgB,qCAAqC,UAAU,IAAI;CACrF,CAAA,GAAA,MAAA,UAAA,OAAgB,cAAc,CAAC,CAAC;CAChC,OAAO;AACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"use-throttled-state.cjs","names":["useThrottledCallbackWithClearTimeout"],"sources":["../../src/use-throttled-state/use-throttled-state.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\nimport { useThrottledCallbackWithClearTimeout } from '../use-throttled-callback/use-throttled-callback';\n\nexport function useThrottledState<T = any>(defaultValue: T, wait: number) {\n const [value, setValue] = useState(defaultValue);\n\n const [setThrottledValue, clearTimeout] = useThrottledCallbackWithClearTimeout(setValue, wait);\n\n useEffect(() => clearTimeout, []);\n\n return [value, setThrottledValue] as const;\n}\n"],"mappings":";;;;AAGA,SAAgB,kBAA2B,cAAiB,MAAc;CACxE,MAAM,CAAC,OAAO,aAAA,GAAA,MAAA,UAAqB,YAAY;CAE/C,MAAM,CAAC,mBAAmB,gBAAgBA,+BAAAA,qCAAqC,UAAU,IAAI;CAE7F,CAAA,GAAA,MAAA,iBAAgB,cAAc,CAAC,CAAC;CAEhC,OAAO,CAAC,OAAO,iBAAiB;AAClC"}
1
+ {"version":3,"file":"use-throttled-state.cjs","names":["useThrottledCallbackWithClearTimeout"],"sources":["../../src/use-throttled-state/use-throttled-state.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\nimport { useThrottledCallbackWithClearTimeout } from '../use-throttled-callback/use-throttled-callback';\n\nexport function useThrottledState<T = any>(defaultValue: T, wait: number) {\n const [value, setValue] = useState(defaultValue);\n\n const [setThrottledValue, clearTimeout] = useThrottledCallbackWithClearTimeout(setValue, wait);\n\n useEffect(() => clearTimeout, []);\n\n return [value, setThrottledValue] as const;\n}\n"],"mappings":";;;;AAGA,SAAgB,kBAA2B,cAAiB,MAAc;CACxE,MAAM,CAAC,OAAO,aAAA,GAAA,MAAA,SAAA,CAAqB,YAAY;CAE/C,MAAM,CAAC,mBAAmB,gBAAgBA,+BAAAA,qCAAqC,UAAU,IAAI;CAE7F,CAAA,GAAA,MAAA,UAAA,OAAgB,cAAc,CAAC,CAAC;CAEhC,OAAO,CAAC,OAAO,iBAAiB;AAClC"}
@@ -1 +1 @@
1
- {"version":3,"file":"use-throttled-value.cjs","names":["useThrottledCallbackWithClearTimeout"],"sources":["../../src/use-throttled-value/use-throttled-value.ts"],"sourcesContent":["import { useEffect, useRef, useState } from 'react';\nimport { useThrottledCallbackWithClearTimeout } from '../use-throttled-callback/use-throttled-callback';\n\nexport function useThrottledValue<T>(value: T, wait: number) {\n const [throttledValue, setThrottledValue] = useState(value);\n const valueRef = useRef(value);\n\n const [throttledSetValue, clearTimeout] = useThrottledCallbackWithClearTimeout(\n setThrottledValue,\n wait\n );\n\n useEffect(() => {\n if (value !== valueRef.current) {\n valueRef.current = value;\n throttledSetValue(value);\n }\n }, [throttledSetValue, value]);\n\n useEffect(() => clearTimeout, []);\n\n return throttledValue;\n}\n"],"mappings":";;;;AAGA,SAAgB,kBAAqB,OAAU,MAAc;CAC3D,MAAM,CAAC,gBAAgB,sBAAA,GAAA,MAAA,UAA8B,KAAK;CAC1D,MAAM,YAAA,GAAA,MAAA,QAAkB,KAAK;CAE7B,MAAM,CAAC,mBAAmB,gBAAgBA,+BAAAA,qCACxC,mBACA,IACF;CAEA,CAAA,GAAA,MAAA,iBAAgB;EACd,IAAI,UAAU,SAAS,SAAS;GAC9B,SAAS,UAAU;GACnB,kBAAkB,KAAK;EACzB;CACF,GAAG,CAAC,mBAAmB,KAAK,CAAC;CAE7B,CAAA,GAAA,MAAA,iBAAgB,cAAc,CAAC,CAAC;CAEhC,OAAO;AACT"}
1
+ {"version":3,"file":"use-throttled-value.cjs","names":["useThrottledCallbackWithClearTimeout"],"sources":["../../src/use-throttled-value/use-throttled-value.ts"],"sourcesContent":["import { useEffect, useRef, useState } from 'react';\nimport { useThrottledCallbackWithClearTimeout } from '../use-throttled-callback/use-throttled-callback';\n\nexport function useThrottledValue<T>(value: T, wait: number) {\n const [throttledValue, setThrottledValue] = useState(value);\n const valueRef = useRef(value);\n\n const [throttledSetValue, clearTimeout] = useThrottledCallbackWithClearTimeout(\n setThrottledValue,\n wait\n );\n\n useEffect(() => {\n if (value !== valueRef.current) {\n valueRef.current = value;\n throttledSetValue(value);\n }\n }, [throttledSetValue, value]);\n\n useEffect(() => clearTimeout, []);\n\n return throttledValue;\n}\n"],"mappings":";;;;AAGA,SAAgB,kBAAqB,OAAU,MAAc;CAC3D,MAAM,CAAC,gBAAgB,sBAAA,GAAA,MAAA,SAAA,CAA8B,KAAK;CAC1D,MAAM,YAAA,GAAA,MAAA,OAAA,CAAkB,KAAK;CAE7B,MAAM,CAAC,mBAAmB,gBAAgBA,+BAAAA,qCACxC,mBACA,IACF;CAEA,CAAA,GAAA,MAAA,UAAA,OAAgB;EACd,IAAI,UAAU,SAAS,SAAS;GAC9B,SAAS,UAAU;GACnB,kBAAkB,KAAK;EACzB;CACF,GAAG,CAAC,mBAAmB,KAAK,CAAC;CAE7B,CAAA,GAAA,MAAA,UAAA,OAAgB,cAAc,CAAC,CAAC;CAEhC,OAAO;AACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"use-timeout.cjs","names":["useCallbackRef"],"sources":["../../src/use-timeout/use-timeout.ts"],"sourcesContent":["import { useCallback, useEffect, useRef } from 'react';\nimport { useCallbackRef } from '../utils';\n\nexport interface UseTimeoutOptions {\n autoInvoke: boolean;\n}\n\nexport interface UseTimeoutReturnValue {\n start: (...args: any[]) => void;\n clear: () => void;\n}\n\nexport function useTimeout(\n callback: (...args: any[]) => void,\n delay: number,\n options: UseTimeoutOptions = { autoInvoke: false }\n): UseTimeoutReturnValue {\n const timeoutRef = useRef<number | null>(null);\n const handleCallback = useCallbackRef(callback);\n\n const start = useCallback(\n (...args: any[]) => {\n if (!timeoutRef.current) {\n timeoutRef.current = window.setTimeout(() => {\n handleCallback(...args);\n timeoutRef.current = null;\n }, delay);\n }\n },\n [delay]\n );\n\n const clear = useCallback(() => {\n if (timeoutRef.current) {\n window.clearTimeout(timeoutRef.current);\n timeoutRef.current = null;\n }\n }, []);\n\n useEffect(() => {\n if (options.autoInvoke) {\n start();\n }\n\n return clear;\n }, [clear, start]);\n\n return { start, clear };\n}\n\nexport namespace useTimeout {\n export type Options = UseTimeoutOptions;\n export type ReturnValue = UseTimeoutReturnValue;\n}\n"],"mappings":";;;;AAYA,SAAgB,WACd,UACA,OACA,UAA6B,EAAE,YAAY,MAAM,GAC1B;CACvB,MAAM,cAAA,GAAA,MAAA,QAAmC,IAAI;CAC7C,MAAM,iBAAiBA,yBAAAA,eAAe,QAAQ;CAE9C,MAAM,SAAA,GAAA,MAAA,cACH,GAAG,SAAgB;EAClB,IAAI,CAAC,WAAW,SACd,WAAW,UAAU,OAAO,iBAAiB;GAC3C,eAAe,GAAG,IAAI;GACtB,WAAW,UAAU;EACvB,GAAG,KAAK;CAEZ,GACA,CAAC,KAAK,CACR;CAEA,MAAM,SAAA,GAAA,MAAA,mBAA0B;EAC9B,IAAI,WAAW,SAAS;GACtB,OAAO,aAAa,WAAW,OAAO;GACtC,WAAW,UAAU;EACvB;CACF,GAAG,CAAC,CAAC;CAEL,CAAA,GAAA,MAAA,iBAAgB;EACd,IAAI,QAAQ,YACV,MAAM;EAGR,OAAO;CACT,GAAG,CAAC,OAAO,KAAK,CAAC;CAEjB,OAAO;EAAE;EAAO;CAAM;AACxB"}
1
+ {"version":3,"file":"use-timeout.cjs","names":["useCallbackRef"],"sources":["../../src/use-timeout/use-timeout.ts"],"sourcesContent":["import { useCallback, useEffect, useRef } from 'react';\nimport { useCallbackRef } from '../utils';\n\nexport interface UseTimeoutOptions {\n autoInvoke: boolean;\n}\n\nexport interface UseTimeoutReturnValue {\n start: (...args: any[]) => void;\n clear: () => void;\n}\n\nexport function useTimeout(\n callback: (...args: any[]) => void,\n delay: number,\n options: UseTimeoutOptions = { autoInvoke: false }\n): UseTimeoutReturnValue {\n const timeoutRef = useRef<number | null>(null);\n const handleCallback = useCallbackRef(callback);\n\n const start = useCallback(\n (...args: any[]) => {\n if (!timeoutRef.current) {\n timeoutRef.current = window.setTimeout(() => {\n handleCallback(...args);\n timeoutRef.current = null;\n }, delay);\n }\n },\n [delay]\n );\n\n const clear = useCallback(() => {\n if (timeoutRef.current) {\n window.clearTimeout(timeoutRef.current);\n timeoutRef.current = null;\n }\n }, []);\n\n useEffect(() => {\n if (options.autoInvoke) {\n start();\n }\n\n return clear;\n }, [clear, start]);\n\n return { start, clear };\n}\n\nexport namespace useTimeout {\n export type Options = UseTimeoutOptions;\n export type ReturnValue = UseTimeoutReturnValue;\n}\n"],"mappings":";;;;AAYA,SAAgB,WACd,UACA,OACA,UAA6B,EAAE,YAAY,MAAM,GAC1B;CACvB,MAAM,cAAA,GAAA,MAAA,OAAA,CAAmC,IAAI;CAC7C,MAAM,iBAAiBA,yBAAAA,eAAe,QAAQ;CAE9C,MAAM,SAAA,GAAA,MAAA,YAAA,EACH,GAAG,SAAgB;EAClB,IAAI,CAAC,WAAW,SACd,WAAW,UAAU,OAAO,iBAAiB;GAC3C,eAAe,GAAG,IAAI;GACtB,WAAW,UAAU;EACvB,GAAG,KAAK;CAEZ,GACA,CAAC,KAAK,CACR;CAEA,MAAM,SAAA,GAAA,MAAA,YAAA,OAA0B;EAC9B,IAAI,WAAW,SAAS;GACtB,OAAO,aAAa,WAAW,OAAO;GACtC,WAAW,UAAU;EACvB;CACF,GAAG,CAAC,CAAC;CAEL,CAAA,GAAA,MAAA,UAAA,OAAgB;EACd,IAAI,QAAQ,YACV,MAAM;EAGR,OAAO;CACT,GAAG,CAAC,OAAO,KAAK,CAAC;CAEjB,OAAO;EAAE;EAAO;CAAM;AACxB"}
@@ -1 +1 @@
1
- {"version":3,"file":"use-toggle.cjs","names":[],"sources":["../../src/use-toggle/use-toggle.ts"],"sourcesContent":["import { useReducer } from 'react';\n\ntype UseToggleAction<T> = (value?: React.SetStateAction<T>) => void;\nexport type UseToggleReturnValue<T> = [T, UseToggleAction<T>];\n\nexport function useToggle<T = boolean>(\n options: readonly T[] = [false, true] as any\n): UseToggleReturnValue<T> {\n const [[option], toggle] = useReducer((state: T[], action: React.SetStateAction<T>) => {\n const value = action instanceof Function ? action(state[0]) : action;\n const index = Math.abs(state.indexOf(value));\n\n return state.slice(index).concat(state.slice(0, index));\n }, options as T[]);\n\n return [option, toggle as UseToggleAction<T>];\n}\n\nexport namespace useToggle {\n export type ReturnValue<T> = UseToggleReturnValue<T>;\n}\n"],"mappings":";;;AAKA,SAAgB,UACd,UAAwB,CAAC,OAAO,IAAI,GACX;CACzB,MAAM,CAAC,CAAC,SAAS,WAAA,GAAA,MAAA,aAAsB,OAAY,WAAoC;EACrF,MAAM,QAAQ,kBAAkB,WAAW,OAAO,MAAM,EAAE,IAAI;EAC9D,MAAM,QAAQ,KAAK,IAAI,MAAM,QAAQ,KAAK,CAAC;EAE3C,OAAO,MAAM,MAAM,KAAK,EAAE,OAAO,MAAM,MAAM,GAAG,KAAK,CAAC;CACxD,GAAG,OAAc;CAEjB,OAAO,CAAC,QAAQ,MAA4B;AAC9C"}
1
+ {"version":3,"file":"use-toggle.cjs","names":[],"sources":["../../src/use-toggle/use-toggle.ts"],"sourcesContent":["import { useReducer } from 'react';\n\ntype UseToggleAction<T> = (value?: React.SetStateAction<T>) => void;\nexport type UseToggleReturnValue<T> = [T, UseToggleAction<T>];\n\nexport function useToggle<T = boolean>(\n options: readonly T[] = [false, true] as any\n): UseToggleReturnValue<T> {\n const [[option], toggle] = useReducer((state: T[], action: React.SetStateAction<T>) => {\n const value = action instanceof Function ? action(state[0]) : action;\n const index = Math.abs(state.indexOf(value));\n\n return state.slice(index).concat(state.slice(0, index));\n }, options as T[]);\n\n return [option, toggle as UseToggleAction<T>];\n}\n\nexport namespace useToggle {\n export type ReturnValue<T> = UseToggleReturnValue<T>;\n}\n"],"mappings":";;;AAKA,SAAgB,UACd,UAAwB,CAAC,OAAO,IAAI,GACX;CACzB,MAAM,CAAC,CAAC,SAAS,WAAA,GAAA,MAAA,WAAA,EAAsB,OAAY,WAAoC;EACrF,MAAM,QAAQ,kBAAkB,WAAW,OAAO,MAAM,EAAE,IAAI;EAC9D,MAAM,QAAQ,KAAK,IAAI,MAAM,QAAQ,KAAK,CAAC;EAE3C,OAAO,MAAM,MAAM,KAAK,CAAC,CAAC,OAAO,MAAM,MAAM,GAAG,KAAK,CAAC;CACxD,GAAG,OAAc;CAEjB,OAAO,CAAC,QAAQ,MAA4B;AAC9C"}
@@ -1 +1 @@
1
- {"version":3,"file":"use-uncontrolled.cjs","names":[],"sources":["../../src/use-uncontrolled/use-uncontrolled.ts"],"sourcesContent":["import { useState } from 'react';\n\nexport interface UseUncontrolledOptions<T> {\n /** Value for controlled state */\n value?: T;\n\n /** Initial value for uncontrolled state */\n defaultValue?: T;\n\n /** Final value for uncontrolled state when value and defaultValue are not provided */\n finalValue?: T;\n\n /** Controlled state onChange handler */\n onChange?: (value: T, ...payload: any[]) => void;\n}\n\nexport type UseUncontrolledReturnValue<T> = [\n /** Current value */\n T,\n\n /** Handler to update the state, passes `value` and `payload` to `onChange` */\n (value: T, ...payload: any[]) => void,\n\n /** True if the state is controlled, false if uncontrolled */\n boolean,\n];\n\nexport function useUncontrolled<T>({\n value,\n defaultValue,\n finalValue,\n onChange = () => {},\n}: UseUncontrolledOptions<T>): UseUncontrolledReturnValue<T> {\n const [uncontrolledValue, setUncontrolledValue] = useState(\n defaultValue !== undefined ? defaultValue : finalValue\n );\n\n const handleUncontrolledChange = (val: T, ...payload: any[]) => {\n setUncontrolledValue(val);\n onChange?.(val, ...payload);\n };\n\n if (value !== undefined) {\n return [value as T, onChange, true];\n }\n\n return [uncontrolledValue as T, handleUncontrolledChange, false];\n}\n\nexport namespace useUncontrolled {\n export type Options<T> = UseUncontrolledOptions<T>;\n export type ReturnValue<T> = UseUncontrolledReturnValue<T>;\n}\n"],"mappings":";;;AA2BA,SAAgB,gBAAmB,EACjC,OACA,cACA,YACA,iBAAiB,CAAC,KACyC;CAC3D,MAAM,CAAC,mBAAmB,yBAAA,GAAA,MAAA,UACxB,iBAAiB,KAAA,IAAY,eAAe,UAC9C;CAEA,MAAM,4BAA4B,KAAQ,GAAG,YAAmB;EAC9D,qBAAqB,GAAG;EACxB,WAAW,KAAK,GAAG,OAAO;CAC5B;CAEA,IAAI,UAAU,KAAA,GACZ,OAAO;EAAC;EAAY;EAAU;CAAI;CAGpC,OAAO;EAAC;EAAwB;EAA0B;CAAK;AACjE"}
1
+ {"version":3,"file":"use-uncontrolled.cjs","names":[],"sources":["../../src/use-uncontrolled/use-uncontrolled.ts"],"sourcesContent":["import { useState } from 'react';\n\nexport interface UseUncontrolledOptions<T> {\n /** Value for controlled state */\n value?: T;\n\n /** Initial value for uncontrolled state */\n defaultValue?: T;\n\n /** Final value for uncontrolled state when value and defaultValue are not provided */\n finalValue?: T;\n\n /** Controlled state onChange handler */\n onChange?: (value: T, ...payload: any[]) => void;\n}\n\nexport type UseUncontrolledReturnValue<T> = [\n /** Current value */\n T,\n\n /** Handler to update the state, passes `value` and `payload` to `onChange` */\n (value: T, ...payload: any[]) => void,\n\n /** True if the state is controlled, false if uncontrolled */\n boolean,\n];\n\nexport function useUncontrolled<T>({\n value,\n defaultValue,\n finalValue,\n onChange = () => {},\n}: UseUncontrolledOptions<T>): UseUncontrolledReturnValue<T> {\n const [uncontrolledValue, setUncontrolledValue] = useState(\n defaultValue !== undefined ? defaultValue : finalValue\n );\n\n const handleUncontrolledChange = (val: T, ...payload: any[]) => {\n setUncontrolledValue(val);\n onChange?.(val, ...payload);\n };\n\n if (value !== undefined) {\n return [value as T, onChange, true];\n }\n\n return [uncontrolledValue as T, handleUncontrolledChange, false];\n}\n\nexport namespace useUncontrolled {\n export type Options<T> = UseUncontrolledOptions<T>;\n export type ReturnValue<T> = UseUncontrolledReturnValue<T>;\n}\n"],"mappings":";;;AA2BA,SAAgB,gBAAmB,EACjC,OACA,cACA,YACA,iBAAiB,CAAC,KACyC;CAC3D,MAAM,CAAC,mBAAmB,yBAAA,GAAA,MAAA,SAAA,CACxB,iBAAiB,KAAA,IAAY,eAAe,UAC9C;CAEA,MAAM,4BAA4B,KAAQ,GAAG,YAAmB;EAC9D,qBAAqB,GAAG;EACxB,WAAW,KAAK,GAAG,OAAO;CAC5B;CAEA,IAAI,UAAU,KAAA,GACZ,OAAO;EAAC;EAAY;EAAU;CAAI;CAGpC,OAAO;EAAC;EAAwB;EAA0B;CAAK;AACjE"}
@@ -1 +1 @@
1
- {"version":3,"file":"use-validated-state.cjs","names":[],"sources":["../../src/use-validated-state/use-validated-state.ts"],"sourcesContent":["import { useState } from 'react';\n\nexport interface UseValidatedStateValue<T> {\n /** Current value */\n value: T;\n\n /** Last valid value */\n lastValidValue: T | undefined;\n\n /** True if the current value is valid, false otherwise */\n valid: boolean;\n}\n\nexport type UseValidatedStateReturnValue<T> = [\n /** Current value */\n UseValidatedStateValue<T>,\n /** Handler to update the state, passes `value` and `payload` to `onChange` */\n (value: T) => void,\n];\n\nexport function useValidatedState<T>(\n initialValue: T,\n validate: (value: T) => boolean,\n initialValidationState?: boolean\n): UseValidatedStateReturnValue<T> {\n const [value, setValue] = useState<T>(initialValue);\n const [lastValidValue, setLastValidValue] = useState<T | undefined>(\n validate(initialValue) ? initialValue : undefined\n );\n const [valid, setValid] = useState<boolean>(\n typeof initialValidationState === 'boolean' ? initialValidationState : validate(initialValue)\n );\n\n const onChange = (val: T) => {\n if (validate(val)) {\n setLastValidValue(val);\n setValid(true);\n } else {\n setValid(false);\n }\n\n setValue(val);\n };\n\n return [{ value, lastValidValue, valid }, onChange] as const;\n}\n\nexport namespace useValidatedState {\n export type ReturnValue<T> = UseValidatedStateReturnValue<T>;\n}\n"],"mappings":";;;AAoBA,SAAgB,kBACd,cACA,UACA,wBACiC;CACjC,MAAM,CAAC,OAAO,aAAA,GAAA,MAAA,UAAwB,YAAY;CAClD,MAAM,CAAC,gBAAgB,sBAAA,GAAA,MAAA,UACrB,SAAS,YAAY,IAAI,eAAe,KAAA,CAC1C;CACA,MAAM,CAAC,OAAO,aAAA,GAAA,MAAA,UACZ,OAAO,2BAA2B,YAAY,yBAAyB,SAAS,YAAY,CAC9F;CAEA,MAAM,YAAY,QAAW;EAC3B,IAAI,SAAS,GAAG,GAAG;GACjB,kBAAkB,GAAG;GACrB,SAAS,IAAI;EACf,OACE,SAAS,KAAK;EAGhB,SAAS,GAAG;CACd;CAEA,OAAO,CAAC;EAAE;EAAO;EAAgB;CAAM,GAAG,QAAQ;AACpD"}
1
+ {"version":3,"file":"use-validated-state.cjs","names":[],"sources":["../../src/use-validated-state/use-validated-state.ts"],"sourcesContent":["import { useState } from 'react';\n\nexport interface UseValidatedStateValue<T> {\n /** Current value */\n value: T;\n\n /** Last valid value */\n lastValidValue: T | undefined;\n\n /** True if the current value is valid, false otherwise */\n valid: boolean;\n}\n\nexport type UseValidatedStateReturnValue<T> = [\n /** Current value */\n UseValidatedStateValue<T>,\n /** Handler to update the state, passes `value` and `payload` to `onChange` */\n (value: T) => void,\n];\n\nexport function useValidatedState<T>(\n initialValue: T,\n validate: (value: T) => boolean,\n initialValidationState?: boolean\n): UseValidatedStateReturnValue<T> {\n const [value, setValue] = useState<T>(initialValue);\n const [lastValidValue, setLastValidValue] = useState<T | undefined>(\n validate(initialValue) ? initialValue : undefined\n );\n const [valid, setValid] = useState<boolean>(\n typeof initialValidationState === 'boolean' ? initialValidationState : validate(initialValue)\n );\n\n const onChange = (val: T) => {\n if (validate(val)) {\n setLastValidValue(val);\n setValid(true);\n } else {\n setValid(false);\n }\n\n setValue(val);\n };\n\n return [{ value, lastValidValue, valid }, onChange] as const;\n}\n\nexport namespace useValidatedState {\n export type ReturnValue<T> = UseValidatedStateReturnValue<T>;\n}\n"],"mappings":";;;AAoBA,SAAgB,kBACd,cACA,UACA,wBACiC;CACjC,MAAM,CAAC,OAAO,aAAA,GAAA,MAAA,SAAA,CAAwB,YAAY;CAClD,MAAM,CAAC,gBAAgB,sBAAA,GAAA,MAAA,SAAA,CACrB,SAAS,YAAY,IAAI,eAAe,KAAA,CAC1C;CACA,MAAM,CAAC,OAAO,aAAA,GAAA,MAAA,SAAA,CACZ,OAAO,2BAA2B,YAAY,yBAAyB,SAAS,YAAY,CAC9F;CAEA,MAAM,YAAY,QAAW;EAC3B,IAAI,SAAS,GAAG,GAAG;GACjB,kBAAkB,GAAG;GACrB,SAAS,IAAI;EACf,OACE,SAAS,KAAK;EAGhB,SAAS,GAAG;CACd;CAEA,OAAO,CAAC;EAAE;EAAO;EAAgB;CAAM,GAAG,QAAQ;AACpD"}
@@ -1 +1 @@
1
- {"version":3,"file":"use-viewport-size.cjs","names":[],"sources":["../../src/use-viewport-size/use-viewport-size.ts"],"sourcesContent":["import { useCallback, useEffect, useState } from 'react';\nimport { useWindowEvent } from '../use-window-event/use-window-event';\n\nconst eventListenerOptions = {\n passive: true,\n};\n\nexport function useViewportSize() {\n const [windowSize, setWindowSize] = useState({\n width: 0,\n height: 0,\n });\n\n const setSize = useCallback(() => {\n setWindowSize({ width: window.innerWidth || 0, height: window.innerHeight || 0 });\n }, []);\n\n useWindowEvent('resize', setSize, eventListenerOptions);\n useWindowEvent('orientationchange', setSize, eventListenerOptions);\n useEffect(setSize, []);\n\n return windowSize;\n}\n"],"mappings":";;;;AAGA,MAAM,uBAAuB,EAC3B,SAAS,KACX;AAEA,SAAgB,kBAAkB;CAChC,MAAM,CAAC,YAAY,kBAAA,GAAA,MAAA,UAA0B;EAC3C,OAAO;EACP,QAAQ;CACV,CAAC;CAED,MAAM,WAAA,GAAA,MAAA,mBAA4B;EAChC,cAAc;GAAE,OAAO,OAAO,cAAc;GAAG,QAAQ,OAAO,eAAe;EAAE,CAAC;CAClF,GAAG,CAAC,CAAC;CAEL,yBAAA,eAAe,UAAU,SAAS,oBAAoB;CACtD,yBAAA,eAAe,qBAAqB,SAAS,oBAAoB;CACjE,CAAA,GAAA,MAAA,WAAU,SAAS,CAAC,CAAC;CAErB,OAAO;AACT"}
1
+ {"version":3,"file":"use-viewport-size.cjs","names":[],"sources":["../../src/use-viewport-size/use-viewport-size.ts"],"sourcesContent":["import { useCallback, useEffect, useState } from 'react';\nimport { useWindowEvent } from '../use-window-event/use-window-event';\n\nconst eventListenerOptions = {\n passive: true,\n};\n\nexport function useViewportSize() {\n const [windowSize, setWindowSize] = useState({\n width: 0,\n height: 0,\n });\n\n const setSize = useCallback(() => {\n setWindowSize({ width: window.innerWidth || 0, height: window.innerHeight || 0 });\n }, []);\n\n useWindowEvent('resize', setSize, eventListenerOptions);\n useWindowEvent('orientationchange', setSize, eventListenerOptions);\n useEffect(setSize, []);\n\n return windowSize;\n}\n"],"mappings":";;;;AAGA,MAAM,uBAAuB,EAC3B,SAAS,KACX;AAEA,SAAgB,kBAAkB;CAChC,MAAM,CAAC,YAAY,kBAAA,GAAA,MAAA,SAAA,CAA0B;EAC3C,OAAO;EACP,QAAQ;CACV,CAAC;CAED,MAAM,WAAA,GAAA,MAAA,YAAA,OAA4B;EAChC,cAAc;GAAE,OAAO,OAAO,cAAc;GAAG,QAAQ,OAAO,eAAe;EAAE,CAAC;CAClF,GAAG,CAAC,CAAC;CAEL,yBAAA,eAAe,UAAU,SAAS,oBAAoB;CACtD,yBAAA,eAAe,qBAAqB,SAAS,oBAAoB;CACjE,CAAA,GAAA,MAAA,UAAA,CAAU,SAAS,CAAC,CAAC;CAErB,OAAO;AACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"use-window-event.cjs","names":[],"sources":["../../src/use-window-event/use-window-event.ts"],"sourcesContent":["import { useEffect, useEffectEvent } from 'react';\n\nexport function useWindowEvent<K extends string>(\n type: K,\n listener: K extends keyof WindowEventMap\n ? (this: Window, ev: WindowEventMap[K]) => void\n : (this: Window, ev: CustomEvent) => void,\n options?: boolean | AddEventListenerOptions\n) {\n const stableListener = useEffectEvent(listener);\n\n useEffect(() => {\n window.addEventListener(type as any, stableListener, options);\n return () => window.removeEventListener(type as any, stableListener, options);\n }, [type]);\n}\n"],"mappings":";;;AAEA,SAAgB,eACd,MACA,UAGA,SACA;CACA,MAAM,kBAAA,GAAA,MAAA,gBAAgC,QAAQ;CAE9C,CAAA,GAAA,MAAA,iBAAgB;EACd,OAAO,iBAAiB,MAAa,gBAAgB,OAAO;EAC5D,aAAa,OAAO,oBAAoB,MAAa,gBAAgB,OAAO;CAC9E,GAAG,CAAC,IAAI,CAAC;AACX"}
1
+ {"version":3,"file":"use-window-event.cjs","names":[],"sources":["../../src/use-window-event/use-window-event.ts"],"sourcesContent":["import { useEffect, useEffectEvent } from 'react';\n\nexport function useWindowEvent<K extends string>(\n type: K,\n listener: K extends keyof WindowEventMap\n ? (this: Window, ev: WindowEventMap[K]) => void\n : (this: Window, ev: CustomEvent) => void,\n options?: boolean | AddEventListenerOptions\n) {\n const stableListener = useEffectEvent(listener);\n\n useEffect(() => {\n window.addEventListener(type as any, stableListener, options);\n return () => window.removeEventListener(type as any, stableListener, options);\n }, [type]);\n}\n"],"mappings":";;;AAEA,SAAgB,eACd,MACA,UAGA,SACA;CACA,MAAM,kBAAA,GAAA,MAAA,eAAA,CAAgC,QAAQ;CAE9C,CAAA,GAAA,MAAA,UAAA,OAAgB;EACd,OAAO,iBAAiB,MAAa,gBAAgB,OAAO;EAC5D,aAAa,OAAO,oBAAoB,MAAa,gBAAgB,OAAO;CAC9E,GAAG,CAAC,IAAI,CAAC;AACX"}
@@ -1 +1 @@
1
- {"version":3,"file":"use-window-scroll.cjs","names":[],"sources":["../../src/use-window-scroll/use-window-scroll.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\nimport { useWindowEvent } from '../use-window-event/use-window-event';\n\nexport interface UseWindowScrollPosition {\n x: number;\n y: number;\n}\n\nexport type UseWindowScrollTo = (position: Partial<UseWindowScrollPosition>) => void;\nexport type UseWindowScrollReturnValue = [UseWindowScrollPosition, UseWindowScrollTo];\n\nfunction getScrollPosition(): UseWindowScrollPosition {\n return typeof window !== 'undefined' ? { x: window.scrollX, y: window.scrollY } : { x: 0, y: 0 };\n}\n\nfunction scrollTo({ x, y }: Partial<UseWindowScrollPosition>) {\n if (typeof window !== 'undefined') {\n const scrollOptions: ScrollToOptions = { behavior: 'smooth' };\n\n if (typeof x === 'number') {\n scrollOptions.left = x;\n }\n\n if (typeof y === 'number') {\n scrollOptions.top = y;\n }\n\n window.scrollTo(scrollOptions);\n }\n}\n\nexport function useWindowScroll(): UseWindowScrollReturnValue {\n const [position, setPosition] = useState<UseWindowScrollPosition>({ x: 0, y: 0 });\n\n useWindowEvent('scroll', () => setPosition(getScrollPosition()), { passive: true });\n useWindowEvent('resize', () => setPosition(getScrollPosition()), { passive: true });\n\n useEffect(() => {\n setPosition(getScrollPosition());\n }, []);\n\n return [position, scrollTo] as const;\n}\n\nexport namespace useWindowScroll {\n export type Position = UseWindowScrollPosition;\n export type ScrollTo = UseWindowScrollTo;\n export type ReturnValue = UseWindowScrollReturnValue;\n}\n"],"mappings":";;;;AAWA,SAAS,oBAA6C;CACpD,OAAO,OAAO,WAAW,cAAc;EAAE,GAAG,OAAO;EAAS,GAAG,OAAO;CAAQ,IAAI;EAAE,GAAG;EAAG,GAAG;CAAE;AACjG;AAEA,SAAS,SAAS,EAAE,GAAG,KAAuC;CAC5D,IAAI,OAAO,WAAW,aAAa;EACjC,MAAM,gBAAiC,EAAE,UAAU,SAAS;EAE5D,IAAI,OAAO,MAAM,UACf,cAAc,OAAO;EAGvB,IAAI,OAAO,MAAM,UACf,cAAc,MAAM;EAGtB,OAAO,SAAS,aAAa;CAC/B;AACF;AAEA,SAAgB,kBAA8C;CAC5D,MAAM,CAAC,UAAU,gBAAA,GAAA,MAAA,UAAiD;EAAE,GAAG;EAAG,GAAG;CAAE,CAAC;CAEhF,yBAAA,eAAe,gBAAgB,YAAY,kBAAkB,CAAC,GAAG,EAAE,SAAS,KAAK,CAAC;CAClF,yBAAA,eAAe,gBAAgB,YAAY,kBAAkB,CAAC,GAAG,EAAE,SAAS,KAAK,CAAC;CAElF,CAAA,GAAA,MAAA,iBAAgB;EACd,YAAY,kBAAkB,CAAC;CACjC,GAAG,CAAC,CAAC;CAEL,OAAO,CAAC,UAAU,QAAQ;AAC5B"}
1
+ {"version":3,"file":"use-window-scroll.cjs","names":[],"sources":["../../src/use-window-scroll/use-window-scroll.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\nimport { useWindowEvent } from '../use-window-event/use-window-event';\n\nexport interface UseWindowScrollPosition {\n x: number;\n y: number;\n}\n\nexport type UseWindowScrollTo = (position: Partial<UseWindowScrollPosition>) => void;\nexport type UseWindowScrollReturnValue = [UseWindowScrollPosition, UseWindowScrollTo];\n\nfunction getScrollPosition(): UseWindowScrollPosition {\n return typeof window !== 'undefined' ? { x: window.scrollX, y: window.scrollY } : { x: 0, y: 0 };\n}\n\nfunction scrollTo({ x, y }: Partial<UseWindowScrollPosition>) {\n if (typeof window !== 'undefined') {\n const scrollOptions: ScrollToOptions = { behavior: 'smooth' };\n\n if (typeof x === 'number') {\n scrollOptions.left = x;\n }\n\n if (typeof y === 'number') {\n scrollOptions.top = y;\n }\n\n window.scrollTo(scrollOptions);\n }\n}\n\nexport function useWindowScroll(): UseWindowScrollReturnValue {\n const [position, setPosition] = useState<UseWindowScrollPosition>({ x: 0, y: 0 });\n\n useWindowEvent('scroll', () => setPosition(getScrollPosition()), { passive: true });\n useWindowEvent('resize', () => setPosition(getScrollPosition()), { passive: true });\n\n useEffect(() => {\n setPosition(getScrollPosition());\n }, []);\n\n return [position, scrollTo] as const;\n}\n\nexport namespace useWindowScroll {\n export type Position = UseWindowScrollPosition;\n export type ScrollTo = UseWindowScrollTo;\n export type ReturnValue = UseWindowScrollReturnValue;\n}\n"],"mappings":";;;;AAWA,SAAS,oBAA6C;CACpD,OAAO,OAAO,WAAW,cAAc;EAAE,GAAG,OAAO;EAAS,GAAG,OAAO;CAAQ,IAAI;EAAE,GAAG;EAAG,GAAG;CAAE;AACjG;AAEA,SAAS,SAAS,EAAE,GAAG,KAAuC;CAC5D,IAAI,OAAO,WAAW,aAAa;EACjC,MAAM,gBAAiC,EAAE,UAAU,SAAS;EAE5D,IAAI,OAAO,MAAM,UACf,cAAc,OAAO;EAGvB,IAAI,OAAO,MAAM,UACf,cAAc,MAAM;EAGtB,OAAO,SAAS,aAAa;CAC/B;AACF;AAEA,SAAgB,kBAA8C;CAC5D,MAAM,CAAC,UAAU,gBAAA,GAAA,MAAA,SAAA,CAAiD;EAAE,GAAG;EAAG,GAAG;CAAE,CAAC;CAEhF,yBAAA,eAAe,gBAAgB,YAAY,kBAAkB,CAAC,GAAG,EAAE,SAAS,KAAK,CAAC;CAClF,yBAAA,eAAe,gBAAgB,YAAY,kBAAkB,CAAC,GAAG,EAAE,SAAS,KAAK,CAAC;CAElF,CAAA,GAAA,MAAA,UAAA,OAAgB;EACd,YAAY,kBAAkB,CAAC;CACjC,GAAG,CAAC,CAAC;CAEL,OAAO,CAAC,UAAU,QAAQ;AAC5B"}
@@ -1 +1 @@
1
- {"version":3,"file":"lower-first.cjs","names":[],"sources":["../../../src/utils/lower-first/lower-first.ts"],"sourcesContent":["export function lowerFirst(value: string) {\n return typeof value !== 'string' ? '' : value.charAt(0).toLowerCase() + value.slice(1);\n}\n"],"mappings":";;AAAA,SAAgB,WAAW,OAAe;CACxC,OAAO,OAAO,UAAU,WAAW,KAAK,MAAM,OAAO,CAAC,EAAE,YAAY,IAAI,MAAM,MAAM,CAAC;AACvF"}
1
+ {"version":3,"file":"lower-first.cjs","names":[],"sources":["../../../src/utils/lower-first/lower-first.ts"],"sourcesContent":["export function lowerFirst(value: string) {\n return typeof value !== 'string' ? '' : value.charAt(0).toLowerCase() + value.slice(1);\n}\n"],"mappings":";;AAAA,SAAgB,WAAW,OAAe;CACxC,OAAO,OAAO,UAAU,WAAW,KAAK,MAAM,OAAO,CAAC,CAAC,CAAC,YAAY,IAAI,MAAM,MAAM,CAAC;AACvF"}
@@ -1 +1 @@
1
- {"version":3,"file":"random-id.cjs","names":[],"sources":["../../../src/utils/random-id/random-id.ts"],"sourcesContent":["export function randomId(prefix = 'mantine-'): string {\n return `${prefix}${Math.random().toString(36).slice(2, 11)}`;\n}\n"],"mappings":";;AAAA,SAAgB,SAAS,SAAS,YAAoB;CACpD,OAAO,GAAG,SAAS,KAAK,OAAO,EAAE,SAAS,EAAE,EAAE,MAAM,GAAG,EAAE;AAC3D"}
1
+ {"version":3,"file":"random-id.cjs","names":[],"sources":["../../../src/utils/random-id/random-id.ts"],"sourcesContent":["export function randomId(prefix = 'mantine-'): string {\n return `${prefix}${Math.random().toString(36).slice(2, 11)}`;\n}\n"],"mappings":";;AAAA,SAAgB,SAAS,SAAS,YAAoB;CACpD,OAAO,GAAG,SAAS,KAAK,OAAO,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,MAAM,GAAG,EAAE;AAC3D"}
@@ -1 +1 @@
1
- {"version":3,"file":"shallow-equal.cjs","names":[],"sources":["../../../src/utils/shallow-equal/shallow-equal.ts"],"sourcesContent":["export function shallowEqual(a: any, b: any) {\n if (a === b) {\n return true;\n }\n\n if (Number.isNaN(a) && Number.isNaN(b)) {\n return true;\n }\n\n if (!(a instanceof Object) || !(b instanceof Object)) {\n return false;\n }\n\n const keys = Object.keys(a);\n const { length } = keys;\n\n if (length !== Object.keys(b).length) {\n return false;\n }\n\n for (let i = 0; i < length; i += 1) {\n const key = keys[i];\n\n if (!(key in b)) {\n return false;\n }\n\n if (a[key] !== b[key] && !(Number.isNaN(a[key]) && Number.isNaN(b[key]))) {\n return false;\n }\n }\n\n return true;\n}\n"],"mappings":";;AAAA,SAAgB,aAAa,GAAQ,GAAQ;CAC3C,IAAI,MAAM,GACR,OAAO;CAGT,IAAI,OAAO,MAAM,CAAC,KAAK,OAAO,MAAM,CAAC,GACnC,OAAO;CAGT,IAAI,EAAE,aAAa,WAAW,EAAE,aAAa,SAC3C,OAAO;CAGT,MAAM,OAAO,OAAO,KAAK,CAAC;CAC1B,MAAM,EAAE,WAAW;CAEnB,IAAI,WAAW,OAAO,KAAK,CAAC,EAAE,QAC5B,OAAO;CAGT,KAAK,IAAI,IAAI,GAAG,IAAI,QAAQ,KAAK,GAAG;EAClC,MAAM,MAAM,KAAK;EAEjB,IAAI,EAAE,OAAO,IACX,OAAO;EAGT,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,OAAO,MAAM,EAAE,IAAI,KAAK,OAAO,MAAM,EAAE,IAAI,IACpE,OAAO;CAEX;CAEA,OAAO;AACT"}
1
+ {"version":3,"file":"shallow-equal.cjs","names":[],"sources":["../../../src/utils/shallow-equal/shallow-equal.ts"],"sourcesContent":["export function shallowEqual(a: any, b: any) {\n if (a === b) {\n return true;\n }\n\n if (Number.isNaN(a) && Number.isNaN(b)) {\n return true;\n }\n\n if (!(a instanceof Object) || !(b instanceof Object)) {\n return false;\n }\n\n const keys = Object.keys(a);\n const { length } = keys;\n\n if (length !== Object.keys(b).length) {\n return false;\n }\n\n for (let i = 0; i < length; i += 1) {\n const key = keys[i];\n\n if (!(key in b)) {\n return false;\n }\n\n if (a[key] !== b[key] && !(Number.isNaN(a[key]) && Number.isNaN(b[key]))) {\n return false;\n }\n }\n\n return true;\n}\n"],"mappings":";;AAAA,SAAgB,aAAa,GAAQ,GAAQ;CAC3C,IAAI,MAAM,GACR,OAAO;CAGT,IAAI,OAAO,MAAM,CAAC,KAAK,OAAO,MAAM,CAAC,GACnC,OAAO;CAGT,IAAI,EAAE,aAAa,WAAW,EAAE,aAAa,SAC3C,OAAO;CAGT,MAAM,OAAO,OAAO,KAAK,CAAC;CAC1B,MAAM,EAAE,WAAW;CAEnB,IAAI,WAAW,OAAO,KAAK,CAAC,CAAC,CAAC,QAC5B,OAAO;CAGT,KAAK,IAAI,IAAI,GAAG,IAAI,QAAQ,KAAK,GAAG;EAClC,MAAM,MAAM,KAAK;EAEjB,IAAI,EAAE,OAAO,IACX,OAAO;EAGT,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,OAAO,MAAM,EAAE,IAAI,KAAK,OAAO,MAAM,EAAE,IAAI,IACpE,OAAO;CAEX;CAEA,OAAO;AACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"upper-first.cjs","names":[],"sources":["../../../src/utils/upper-first/upper-first.ts"],"sourcesContent":["export function upperFirst(value: string) {\n return typeof value !== 'string' ? '' : value.charAt(0).toUpperCase() + value.slice(1);\n}\n"],"mappings":";;AAAA,SAAgB,WAAW,OAAe;CACxC,OAAO,OAAO,UAAU,WAAW,KAAK,MAAM,OAAO,CAAC,EAAE,YAAY,IAAI,MAAM,MAAM,CAAC;AACvF"}
1
+ {"version":3,"file":"upper-first.cjs","names":[],"sources":["../../../src/utils/upper-first/upper-first.ts"],"sourcesContent":["export function upperFirst(value: string) {\n return typeof value !== 'string' ? '' : value.charAt(0).toUpperCase() + value.slice(1);\n}\n"],"mappings":";;AAAA,SAAgB,WAAW,OAAe;CACxC,OAAO,OAAO,UAAU,WAAW,KAAK,MAAM,OAAO,CAAC,CAAC,CAAC,YAAY,IAAI,MAAM,MAAM,CAAC;AACvF"}
@@ -1 +1 @@
1
- {"version":3,"file":"use-callback-ref.cjs","names":[],"sources":["../../../src/utils/use-callback-ref/use-callback-ref.ts"],"sourcesContent":["import { useEffect, useMemo, useRef } from 'react';\n\nexport function useCallbackRef<T extends (...args: any[]) => any>(callback: T | undefined): T {\n const callbackRef = useRef(callback);\n\n useEffect(() => {\n callbackRef.current = callback;\n });\n\n return useMemo(() => ((...args) => callbackRef.current?.(...args)) as T, []);\n}\n"],"mappings":";;;AAEA,SAAgB,eAAkD,UAA4B;CAC5F,MAAM,eAAA,GAAA,MAAA,QAAqB,QAAQ;CAEnC,CAAA,GAAA,MAAA,iBAAgB;EACd,YAAY,UAAU;CACxB,CAAC;CAED,QAAA,GAAA,MAAA,iBAAuB,GAAG,SAAS,YAAY,UAAU,GAAG,IAAI,IAAS,CAAC,CAAC;AAC7E"}
1
+ {"version":3,"file":"use-callback-ref.cjs","names":[],"sources":["../../../src/utils/use-callback-ref/use-callback-ref.ts"],"sourcesContent":["import { useEffect, useMemo, useRef } from 'react';\n\nexport function useCallbackRef<T extends (...args: any[]) => any>(callback: T | undefined): T {\n const callbackRef = useRef(callback);\n\n useEffect(() => {\n callbackRef.current = callback;\n });\n\n return useMemo(() => ((...args) => callbackRef.current?.(...args)) as T, []);\n}\n"],"mappings":";;;AAEA,SAAgB,eAAkD,UAA4B;CAC5F,MAAM,eAAA,GAAA,MAAA,OAAA,CAAqB,QAAQ;CAEnC,CAAA,GAAA,MAAA,UAAA,OAAgB;EACd,YAAY,UAAU;CACxB,CAAC;CAED,QAAA,GAAA,MAAA,QAAA,SAAuB,GAAG,SAAS,YAAY,UAAU,GAAG,IAAI,IAAS,CAAC,CAAC;AAC7E"}
@@ -1 +1 @@
1
- {"version":3,"file":"use-clipboard.mjs","names":[],"sources":["../../src/use-clipboard/use-clipboard.ts"],"sourcesContent":["import { useEffect, useRef, useState } from 'react';\n\nexport interface UseClipboardInput {\n /** Time in ms after which the copied state will reset, `2000` by default */\n timeout?: number;\n}\n\nexport interface UseClipboardReturnValue {\n /** Function to copy value to clipboard */\n copy: (value: any) => void;\n\n /** Function to reset copied state and error */\n reset: () => void;\n\n /** Error if copying failed */\n error: Error | null;\n\n /** Boolean indicating if the value was copied successfully */\n copied: boolean;\n}\n\nexport function useClipboard(options: UseClipboardInput = {}): UseClipboardReturnValue {\n const timeout = options.timeout ?? 2000;\n const [error, setError] = useState<Error | null>(null);\n const [copied, setCopied] = useState(false);\n const timeoutRef = useRef<number | null>(null);\n\n useEffect(\n () => () => {\n window.clearTimeout(timeoutRef.current!);\n },\n []\n );\n\n const handleCopyResult = (value: boolean) => {\n window.clearTimeout(timeoutRef.current!);\n timeoutRef.current = window.setTimeout(() => setCopied(false), timeout);\n setCopied(value);\n };\n\n const copy = (value: any) => {\n if ('clipboard' in navigator) {\n navigator.clipboard\n .writeText(value)\n .then(() => {\n setError(null);\n handleCopyResult(true);\n })\n .catch((err) => setError(err));\n } else {\n setError(new Error('useClipboard: navigator.clipboard is not supported'));\n }\n };\n\n const reset = () => {\n setCopied(false);\n setError(null);\n window.clearTimeout(timeoutRef.current!);\n };\n\n return { copy, reset, error, copied };\n}\n\nexport namespace useClipboard {\n export type Input = UseClipboardInput;\n export type ReturnValue = UseClipboardReturnValue;\n}\n"],"mappings":";;;AAqBA,SAAgB,aAAa,UAA6B,CAAC,GAA4B;CACrF,MAAM,UAAU,QAAQ,WAAW;CACnC,MAAM,CAAC,OAAO,YAAY,SAAuB,IAAI;CACrD,MAAM,CAAC,QAAQ,aAAa,SAAS,KAAK;CAC1C,MAAM,aAAa,OAAsB,IAAI;CAE7C,sBACc;EACV,OAAO,aAAa,WAAW,OAAQ;CACzC,GACA,CAAC,CACH;CAEA,MAAM,oBAAoB,UAAmB;EAC3C,OAAO,aAAa,WAAW,OAAQ;EACvC,WAAW,UAAU,OAAO,iBAAiB,UAAU,KAAK,GAAG,OAAO;EACtE,UAAU,KAAK;CACjB;CAEA,MAAM,QAAQ,UAAe;EAC3B,IAAI,eAAe,WACjB,UAAU,UACP,UAAU,KAAK,EACf,WAAW;GACV,SAAS,IAAI;GACb,iBAAiB,IAAI;EACvB,CAAC,EACA,OAAO,QAAQ,SAAS,GAAG,CAAC;OAE/B,yBAAS,IAAI,MAAM,oDAAoD,CAAC;CAE5E;CAEA,MAAM,cAAc;EAClB,UAAU,KAAK;EACf,SAAS,IAAI;EACb,OAAO,aAAa,WAAW,OAAQ;CACzC;CAEA,OAAO;EAAE;EAAM;EAAO;EAAO;CAAO;AACtC"}
1
+ {"version":3,"file":"use-clipboard.mjs","names":[],"sources":["../../src/use-clipboard/use-clipboard.ts"],"sourcesContent":["import { useEffect, useRef, useState } from 'react';\n\nexport interface UseClipboardInput {\n /** Time in ms after which the copied state will reset, `2000` by default */\n timeout?: number;\n}\n\nexport interface UseClipboardReturnValue {\n /** Function to copy value to clipboard */\n copy: (value: any) => void;\n\n /** Function to reset copied state and error */\n reset: () => void;\n\n /** Error if copying failed */\n error: Error | null;\n\n /** Boolean indicating if the value was copied successfully */\n copied: boolean;\n}\n\nexport function useClipboard(options: UseClipboardInput = {}): UseClipboardReturnValue {\n const timeout = options.timeout ?? 2000;\n const [error, setError] = useState<Error | null>(null);\n const [copied, setCopied] = useState(false);\n const timeoutRef = useRef<number | null>(null);\n\n useEffect(\n () => () => {\n window.clearTimeout(timeoutRef.current!);\n },\n []\n );\n\n const handleCopyResult = (value: boolean) => {\n window.clearTimeout(timeoutRef.current!);\n timeoutRef.current = window.setTimeout(() => setCopied(false), timeout);\n setCopied(value);\n };\n\n const copy = (value: any) => {\n if ('clipboard' in navigator) {\n navigator.clipboard\n .writeText(value)\n .then(() => {\n setError(null);\n handleCopyResult(true);\n })\n .catch((err) => setError(err));\n } else {\n setError(new Error('useClipboard: navigator.clipboard is not supported'));\n }\n };\n\n const reset = () => {\n setCopied(false);\n setError(null);\n window.clearTimeout(timeoutRef.current!);\n };\n\n return { copy, reset, error, copied };\n}\n\nexport namespace useClipboard {\n export type Input = UseClipboardInput;\n export type ReturnValue = UseClipboardReturnValue;\n}\n"],"mappings":";;;AAqBA,SAAgB,aAAa,UAA6B,CAAC,GAA4B;CACrF,MAAM,UAAU,QAAQ,WAAW;CACnC,MAAM,CAAC,OAAO,YAAY,SAAuB,IAAI;CACrD,MAAM,CAAC,QAAQ,aAAa,SAAS,KAAK;CAC1C,MAAM,aAAa,OAAsB,IAAI;CAE7C,sBACc;EACV,OAAO,aAAa,WAAW,OAAQ;CACzC,GACA,CAAC,CACH;CAEA,MAAM,oBAAoB,UAAmB;EAC3C,OAAO,aAAa,WAAW,OAAQ;EACvC,WAAW,UAAU,OAAO,iBAAiB,UAAU,KAAK,GAAG,OAAO;EACtE,UAAU,KAAK;CACjB;CAEA,MAAM,QAAQ,UAAe;EAC3B,IAAI,eAAe,WACjB,UAAU,UACP,UAAU,KAAK,CAAC,CAChB,WAAW;GACV,SAAS,IAAI;GACb,iBAAiB,IAAI;EACvB,CAAC,CAAC,CACD,OAAO,QAAQ,SAAS,GAAG,CAAC;OAE/B,yBAAS,IAAI,MAAM,oDAAoD,CAAC;CAE5E;CAEA,MAAM,cAAc;EAClB,UAAU,KAAK;EACf,SAAS,IAAI;EACb,OAAO,aAAa,WAAW,OAAQ;CACzC;CAEA,OAAO;EAAE;EAAM;EAAO;EAAO;CAAO;AACtC"}
@@ -1 +1 @@
1
- {"version":3,"file":"use-document-title.mjs","names":[],"sources":["../../src/use-document-title/use-document-title.ts"],"sourcesContent":["import { useIsomorphicEffect } from '../use-isomorphic-effect/use-isomorphic-effect';\n\nexport function useDocumentTitle(title: string) {\n useIsomorphicEffect(() => {\n if (typeof title === 'string' && title.trim().length > 0) {\n document.title = title.trim();\n }\n }, [title]);\n}\n"],"mappings":";;;AAEA,SAAgB,iBAAiB,OAAe;CAC9C,0BAA0B;EACxB,IAAI,OAAO,UAAU,YAAY,MAAM,KAAK,EAAE,SAAS,GACrD,SAAS,QAAQ,MAAM,KAAK;CAEhC,GAAG,CAAC,KAAK,CAAC;AACZ"}
1
+ {"version":3,"file":"use-document-title.mjs","names":[],"sources":["../../src/use-document-title/use-document-title.ts"],"sourcesContent":["import { useIsomorphicEffect } from '../use-isomorphic-effect/use-isomorphic-effect';\n\nexport function useDocumentTitle(title: string) {\n useIsomorphicEffect(() => {\n if (typeof title === 'string' && title.trim().length > 0) {\n document.title = title.trim();\n }\n }, [title]);\n}\n"],"mappings":";;;AAEA,SAAgB,iBAAiB,OAAe;CAC9C,0BAA0B;EACxB,IAAI,OAAO,UAAU,YAAY,MAAM,KAAK,CAAC,CAAC,SAAS,GACrD,SAAS,QAAQ,MAAM,KAAK;CAEhC,GAAG,CAAC,KAAK,CAAC;AACZ"}
@@ -1 +1 @@
1
- {"version":3,"file":"use-eye-dropper.mjs","names":[],"sources":["../../src/use-eye-dropper/use-eye-dropper.ts"],"sourcesContent":["import { useCallback, useState } from 'react';\nimport { useIsomorphicEffect } from '../use-isomorphic-effect/use-isomorphic-effect';\n\nexport interface EyeDropperOpenOptions {\n signal?: AbortSignal;\n}\n\nexport interface EyeDropperOpenReturnType {\n sRGBHex: string;\n}\n\nexport interface UseEyeDropperReturnValue {\n supported: boolean;\n open: (options?: EyeDropperOpenOptions) => Promise<EyeDropperOpenReturnType | undefined>;\n}\n\nexport function useEyeDropper(): UseEyeDropperReturnValue {\n const [supported, setSupported] = useState(false);\n\n useIsomorphicEffect(() => {\n setSupported(typeof window !== 'undefined' && !isOpera() && 'EyeDropper' in window);\n }, []);\n\n const open = useCallback(\n (options: EyeDropperOpenOptions = {}): Promise<EyeDropperOpenReturnType | undefined> => {\n if (supported) {\n const eyeDropper = new (window as any).EyeDropper();\n return eyeDropper.open(options);\n }\n\n return Promise.resolve(undefined);\n },\n [supported]\n );\n\n return { supported, open };\n}\n\nfunction isOpera() {\n return navigator.userAgent.includes('OPR');\n}\n"],"mappings":";;;;AAgBA,SAAgB,gBAA0C;CACxD,MAAM,CAAC,WAAW,gBAAgB,SAAS,KAAK;CAEhD,0BAA0B;EACxB,aAAa,OAAO,WAAW,eAAe,CAAC,QAAQ,KAAK,gBAAgB,MAAM;CACpF,GAAG,CAAC,CAAC;CAcL,OAAO;EAAE;EAAW,MAZP,aACV,UAAiC,CAAC,MAAqD;GACtF,IAAI,WAEF,OAAO,IADiB,OAAe,WACvB,EAAE,KAAK,OAAO;GAGhC,OAAO,QAAQ,QAAQ,KAAA,CAAS;EAClC,GACA,CAAC,SAAS,CAGW;CAAE;AAC3B;AAEA,SAAS,UAAU;CACjB,OAAO,UAAU,UAAU,SAAS,KAAK;AAC3C"}
1
+ {"version":3,"file":"use-eye-dropper.mjs","names":[],"sources":["../../src/use-eye-dropper/use-eye-dropper.ts"],"sourcesContent":["import { useCallback, useState } from 'react';\nimport { useIsomorphicEffect } from '../use-isomorphic-effect/use-isomorphic-effect';\n\nexport interface EyeDropperOpenOptions {\n signal?: AbortSignal;\n}\n\nexport interface EyeDropperOpenReturnType {\n sRGBHex: string;\n}\n\nexport interface UseEyeDropperReturnValue {\n supported: boolean;\n open: (options?: EyeDropperOpenOptions) => Promise<EyeDropperOpenReturnType | undefined>;\n}\n\nexport function useEyeDropper(): UseEyeDropperReturnValue {\n const [supported, setSupported] = useState(false);\n\n useIsomorphicEffect(() => {\n setSupported(typeof window !== 'undefined' && !isOpera() && 'EyeDropper' in window);\n }, []);\n\n const open = useCallback(\n (options: EyeDropperOpenOptions = {}): Promise<EyeDropperOpenReturnType | undefined> => {\n if (supported) {\n const eyeDropper = new (window as any).EyeDropper();\n return eyeDropper.open(options);\n }\n\n return Promise.resolve(undefined);\n },\n [supported]\n );\n\n return { supported, open };\n}\n\nfunction isOpera() {\n return navigator.userAgent.includes('OPR');\n}\n"],"mappings":";;;;AAgBA,SAAgB,gBAA0C;CACxD,MAAM,CAAC,WAAW,gBAAgB,SAAS,KAAK;CAEhD,0BAA0B;EACxB,aAAa,OAAO,WAAW,eAAe,CAAC,QAAQ,KAAK,gBAAgB,MAAM;CACpF,GAAG,CAAC,CAAC;CAcL,OAAO;EAAE;EAAW,MAZP,aACV,UAAiC,CAAC,MAAqD;GACtF,IAAI,WAEF,OAAO,IADiB,OAAe,WACvB,CAAC,CAAC,KAAK,OAAO;GAGhC,OAAO,QAAQ,QAAQ,KAAA,CAAS;EAClC,GACA,CAAC,SAAS,CAGW;CAAE;AAC3B;AAEA,SAAS,UAAU;CACjB,OAAO,UAAU,UAAU,SAAS,KAAK;AAC3C"}
@@ -1 +1 @@
1
- {"version":3,"file":"use-favicon.mjs","names":[],"sources":["../../src/use-favicon/use-favicon.ts"],"sourcesContent":["import { useRef } from 'react';\nimport { useIsomorphicEffect } from '../use-isomorphic-effect/use-isomorphic-effect';\n\nconst MIME_TYPES: Record<string, string> = {\n ico: 'image/x-icon',\n png: 'image/png',\n svg: 'image/svg+xml',\n gif: 'image/gif',\n};\n\nexport function useFavicon(url: string) {\n const link = useRef<HTMLLinkElement>(null);\n\n useIsomorphicEffect(() => {\n if (!url) {\n return;\n }\n\n if (!link.current) {\n const existingElements = document.querySelectorAll<HTMLLinkElement>('link[rel*=\"icon\"]');\n existingElements.forEach((element) => document.head.removeChild(element));\n\n const element = document.createElement('link');\n element.rel = 'shortcut icon';\n link.current = element;\n document.querySelector('head')!.appendChild(element);\n }\n\n const splittedUrl = url.split('.');\n const extension = splittedUrl[splittedUrl.length - 1].toLowerCase();\n const mimeType = MIME_TYPES[extension];\n\n if (mimeType) {\n link.current.setAttribute('type', mimeType);\n } else {\n link.current.removeAttribute('type');\n }\n\n link.current.setAttribute('href', url);\n }, [url]);\n}\n"],"mappings":";;;;AAGA,MAAM,aAAqC;CACzC,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;AACP;AAEA,SAAgB,WAAW,KAAa;CACtC,MAAM,OAAO,OAAwB,IAAI;CAEzC,0BAA0B;EACxB,IAAI,CAAC,KACH;EAGF,IAAI,CAAC,KAAK,SAAS;GAEjB,SADkC,iBAAkC,qBACrD,EAAE,SAAS,YAAY,SAAS,KAAK,YAAY,OAAO,CAAC;GAExE,MAAM,UAAU,SAAS,cAAc,MAAM;GAC7C,QAAQ,MAAM;GACd,KAAK,UAAU;GACf,SAAS,cAAc,MAAM,EAAG,YAAY,OAAO;EACrD;EAEA,MAAM,cAAc,IAAI,MAAM,GAAG;EAEjC,MAAM,WAAW,WADC,YAAY,YAAY,SAAS,GAAG,YAClB;EAEpC,IAAI,UACF,KAAK,QAAQ,aAAa,QAAQ,QAAQ;OAE1C,KAAK,QAAQ,gBAAgB,MAAM;EAGrC,KAAK,QAAQ,aAAa,QAAQ,GAAG;CACvC,GAAG,CAAC,GAAG,CAAC;AACV"}
1
+ {"version":3,"file":"use-favicon.mjs","names":[],"sources":["../../src/use-favicon/use-favicon.ts"],"sourcesContent":["import { useRef } from 'react';\nimport { useIsomorphicEffect } from '../use-isomorphic-effect/use-isomorphic-effect';\n\nconst MIME_TYPES: Record<string, string> = {\n ico: 'image/x-icon',\n png: 'image/png',\n svg: 'image/svg+xml',\n gif: 'image/gif',\n};\n\nexport function useFavicon(url: string) {\n const link = useRef<HTMLLinkElement>(null);\n\n useIsomorphicEffect(() => {\n if (!url) {\n return;\n }\n\n if (!link.current) {\n const existingElements = document.querySelectorAll<HTMLLinkElement>('link[rel*=\"icon\"]');\n existingElements.forEach((element) => document.head.removeChild(element));\n\n const element = document.createElement('link');\n element.rel = 'shortcut icon';\n link.current = element;\n document.querySelector('head')!.appendChild(element);\n }\n\n const splittedUrl = url.split('.');\n const extension = splittedUrl[splittedUrl.length - 1].toLowerCase();\n const mimeType = MIME_TYPES[extension];\n\n if (mimeType) {\n link.current.setAttribute('type', mimeType);\n } else {\n link.current.removeAttribute('type');\n }\n\n link.current.setAttribute('href', url);\n }, [url]);\n}\n"],"mappings":";;;;AAGA,MAAM,aAAqC;CACzC,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;AACP;AAEA,SAAgB,WAAW,KAAa;CACtC,MAAM,OAAO,OAAwB,IAAI;CAEzC,0BAA0B;EACxB,IAAI,CAAC,KACH;EAGF,IAAI,CAAC,KAAK,SAAS;GAEjB,SADkC,iBAAkC,qBACrD,CAAC,CAAC,SAAS,YAAY,SAAS,KAAK,YAAY,OAAO,CAAC;GAExE,MAAM,UAAU,SAAS,cAAc,MAAM;GAC7C,QAAQ,MAAM;GACd,KAAK,UAAU;GACf,SAAS,cAAc,MAAM,CAAC,CAAE,YAAY,OAAO;EACrD;EAEA,MAAM,cAAc,IAAI,MAAM,GAAG;EAEjC,MAAM,WAAW,WADC,YAAY,YAAY,SAAS,EAAE,CAAC,YAClB;EAEpC,IAAI,UACF,KAAK,QAAQ,aAAa,QAAQ,QAAQ;OAE1C,KAAK,QAAQ,gBAAgB,MAAM;EAGrC,KAAK,QAAQ,aAAa,QAAQ,GAAG;CACvC,GAAG,CAAC,GAAG,CAAC;AACV"}
@@ -1 +1 @@
1
- {"version":3,"file":"use-fetch.mjs","names":[],"sources":["../../src/use-fetch/use-fetch.ts"],"sourcesContent":["import { useCallback, useEffect, useRef, useState } from 'react';\n\nexport interface UseFetchOptions extends RequestInit {\n autoInvoke?: boolean;\n}\n\nexport interface UseFetchReturnValue<T> {\n data: T | null;\n loading: boolean;\n error: Error | null;\n refetch: () => Promise<any>;\n abort: () => void;\n}\n\nexport function useFetch<T>(\n url: string,\n { autoInvoke = true, ...options }: UseFetchOptions = {}\n): UseFetchReturnValue<T> {\n const [data, setData] = useState<T | null>(null);\n const [loading, setLoading] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n const controller = useRef<AbortController | null>(null);\n\n const refetch = useCallback(() => {\n if (controller.current) {\n controller.current.abort();\n }\n\n controller.current = new AbortController();\n\n setLoading(true);\n\n return fetch(url, { ...options, signal: controller.current.signal })\n .then((res) => {\n if (!res.ok) {\n throw new Error(`Request failed with status ${res.status}`);\n }\n return res.json();\n })\n .then((res) => {\n setData(res);\n setLoading(false);\n return res as T;\n })\n .catch((err) => {\n setLoading(false);\n\n if (err.name !== 'AbortError') {\n setError(err);\n }\n\n return err;\n });\n }, [url, JSON.stringify(options)]);\n\n const abort = useCallback(() => {\n if (controller.current) {\n controller.current?.abort('');\n }\n }, []);\n\n useEffect(() => {\n if (autoInvoke) {\n refetch();\n }\n\n return () => {\n if (controller.current) {\n controller.current.abort('');\n }\n };\n }, [refetch, autoInvoke]);\n\n return { data, loading, error, refetch, abort };\n}\n\nexport namespace useFetch {\n export type Options = UseFetchOptions;\n export type ReturnValue<T> = UseFetchReturnValue<T>;\n}\n"],"mappings":";;;AAcA,SAAgB,SACd,KACA,EAAE,aAAa,MAAM,GAAG,YAA6B,CAAC,GAC9B;CACxB,MAAM,CAAC,MAAM,WAAW,SAAmB,IAAI;CAC/C,MAAM,CAAC,SAAS,cAAc,SAAS,KAAK;CAC5C,MAAM,CAAC,OAAO,YAAY,SAAuB,IAAI;CACrD,MAAM,aAAa,OAA+B,IAAI;CAEtD,MAAM,UAAU,kBAAkB;EAChC,IAAI,WAAW,SACb,WAAW,QAAQ,MAAM;EAG3B,WAAW,UAAU,IAAI,gBAAgB;EAEzC,WAAW,IAAI;EAEf,OAAO,MAAM,KAAK;GAAE,GAAG;GAAS,QAAQ,WAAW,QAAQ;EAAO,CAAC,EAChE,MAAM,QAAQ;GACb,IAAI,CAAC,IAAI,IACP,MAAM,IAAI,MAAM,8BAA8B,IAAI,QAAQ;GAE5D,OAAO,IAAI,KAAK;EAClB,CAAC,EACA,MAAM,QAAQ;GACb,QAAQ,GAAG;GACX,WAAW,KAAK;GAChB,OAAO;EACT,CAAC,EACA,OAAO,QAAQ;GACd,WAAW,KAAK;GAEhB,IAAI,IAAI,SAAS,cACf,SAAS,GAAG;GAGd,OAAO;EACT,CAAC;CACL,GAAG,CAAC,KAAK,KAAK,UAAU,OAAO,CAAC,CAAC;CAEjC,MAAM,QAAQ,kBAAkB;EAC9B,IAAI,WAAW,SACb,WAAW,SAAS,MAAM,EAAE;CAEhC,GAAG,CAAC,CAAC;CAEL,gBAAgB;EACd,IAAI,YACF,QAAQ;EAGV,aAAa;GACX,IAAI,WAAW,SACb,WAAW,QAAQ,MAAM,EAAE;EAE/B;CACF,GAAG,CAAC,SAAS,UAAU,CAAC;CAExB,OAAO;EAAE;EAAM;EAAS;EAAO;EAAS;CAAM;AAChD"}
1
+ {"version":3,"file":"use-fetch.mjs","names":[],"sources":["../../src/use-fetch/use-fetch.ts"],"sourcesContent":["import { useCallback, useEffect, useRef, useState } from 'react';\n\nexport interface UseFetchOptions extends RequestInit {\n autoInvoke?: boolean;\n}\n\nexport interface UseFetchReturnValue<T> {\n data: T | null;\n loading: boolean;\n error: Error | null;\n refetch: () => Promise<any>;\n abort: () => void;\n}\n\nexport function useFetch<T>(\n url: string,\n { autoInvoke = true, ...options }: UseFetchOptions = {}\n): UseFetchReturnValue<T> {\n const [data, setData] = useState<T | null>(null);\n const [loading, setLoading] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n const controller = useRef<AbortController | null>(null);\n\n const refetch = useCallback(() => {\n if (controller.current) {\n controller.current.abort();\n }\n\n controller.current = new AbortController();\n\n setLoading(true);\n\n return fetch(url, { ...options, signal: controller.current.signal })\n .then((res) => {\n if (!res.ok) {\n throw new Error(`Request failed with status ${res.status}`);\n }\n return res.json();\n })\n .then((res) => {\n setData(res);\n setLoading(false);\n return res as T;\n })\n .catch((err) => {\n setLoading(false);\n\n if (err.name !== 'AbortError') {\n setError(err);\n }\n\n return err;\n });\n }, [url, JSON.stringify(options)]);\n\n const abort = useCallback(() => {\n if (controller.current) {\n controller.current?.abort('');\n }\n }, []);\n\n useEffect(() => {\n if (autoInvoke) {\n refetch();\n }\n\n return () => {\n if (controller.current) {\n controller.current.abort('');\n }\n };\n }, [refetch, autoInvoke]);\n\n return { data, loading, error, refetch, abort };\n}\n\nexport namespace useFetch {\n export type Options = UseFetchOptions;\n export type ReturnValue<T> = UseFetchReturnValue<T>;\n}\n"],"mappings":";;;AAcA,SAAgB,SACd,KACA,EAAE,aAAa,MAAM,GAAG,YAA6B,CAAC,GAC9B;CACxB,MAAM,CAAC,MAAM,WAAW,SAAmB,IAAI;CAC/C,MAAM,CAAC,SAAS,cAAc,SAAS,KAAK;CAC5C,MAAM,CAAC,OAAO,YAAY,SAAuB,IAAI;CACrD,MAAM,aAAa,OAA+B,IAAI;CAEtD,MAAM,UAAU,kBAAkB;EAChC,IAAI,WAAW,SACb,WAAW,QAAQ,MAAM;EAG3B,WAAW,UAAU,IAAI,gBAAgB;EAEzC,WAAW,IAAI;EAEf,OAAO,MAAM,KAAK;GAAE,GAAG;GAAS,QAAQ,WAAW,QAAQ;EAAO,CAAC,CAAC,CACjE,MAAM,QAAQ;GACb,IAAI,CAAC,IAAI,IACP,MAAM,IAAI,MAAM,8BAA8B,IAAI,QAAQ;GAE5D,OAAO,IAAI,KAAK;EAClB,CAAC,CAAC,CACD,MAAM,QAAQ;GACb,QAAQ,GAAG;GACX,WAAW,KAAK;GAChB,OAAO;EACT,CAAC,CAAC,CACD,OAAO,QAAQ;GACd,WAAW,KAAK;GAEhB,IAAI,IAAI,SAAS,cACf,SAAS,GAAG;GAGd,OAAO;EACT,CAAC;CACL,GAAG,CAAC,KAAK,KAAK,UAAU,OAAO,CAAC,CAAC;CAEjC,MAAM,QAAQ,kBAAkB;EAC9B,IAAI,WAAW,SACb,WAAW,SAAS,MAAM,EAAE;CAEhC,GAAG,CAAC,CAAC;CAEL,gBAAgB;EACd,IAAI,YACF,QAAQ;EAGV,aAAa;GACX,IAAI,WAAW,SACb,WAAW,QAAQ,MAAM,EAAE;EAE/B;CACF,GAAG,CAAC,SAAS,UAAU,CAAC;CAExB,OAAO;EAAE;EAAM;EAAS;EAAO;EAAS;CAAM;AAChD"}
@@ -1 +1 @@
1
- {"version":3,"file":"use-floating-window.mjs","names":[],"sources":["../../src/use-floating-window/use-floating-window.ts"],"sourcesContent":["// Required to disable for webkit-user-select, although deprecated, it is still required for Safari support\nimport { RefCallback, useCallback, useEffect, useRef, useState } from 'react';\n\nfunction useRefValue<T>(value: T) {\n const ref = useRef(value);\n ref.current = value;\n return ref;\n}\n\ninterface FloatingWindowPositionConfig {\n top?: number;\n left?: number;\n right?: number;\n bottom?: number;\n}\n\ninterface FloatingWindowPosition {\n /** Element offset from the left side of the viewport */\n x: number;\n\n /** Element offset from the top side of the viewport */\n y: number;\n}\n\nexport interface UseFloatingWindowOptions {\n /** If `false`, the element can not be dragged. */\n enabled?: boolean;\n\n /** If `true`, the element can only move within the current viewport boundaries. */\n constrainToViewport?: boolean;\n\n /** The offset from the viewport edges when constraining the element. Requires `constrainToViewport: true`. */\n constrainOffset?: number;\n\n /** Selector of an element that should be used to drag floating window. If not specified, the entire root element is used as a drag target. */\n dragHandleSelector?: string;\n\n /** Selector of an element within `dragHandleSelector` that should be excluded from the drag event. */\n excludeDragHandleSelector?: string;\n\n /** If set, restricts movement to the specified axis */\n axis?: 'x' | 'y';\n\n /** Initial position. If not set, calculated from element styles. */\n initialPosition?: FloatingWindowPositionConfig;\n\n /** Called when the element position changes */\n onPositionChange?: (pos: FloatingWindowPosition) => void;\n\n /** Called when the drag starts */\n onDragStart?: () => void;\n\n /** Called when the drag stops */\n onDragEnd?: () => void;\n}\n\nexport type SetFloatingWindowPosition = (position: FloatingWindowPositionConfig) => void;\n\nexport interface UseFloatingWindowReturnValue<T extends HTMLElement> {\n /** Ref to the element that should be draggable */\n ref: RefCallback<T | null>;\n\n /** Function to set the position of the element */\n setPosition: SetFloatingWindowPosition;\n\n /** `true` if the element is currently being dragged */\n isDragging: boolean;\n}\n\nexport function useFloatingWindow<T extends HTMLElement>(\n options: UseFloatingWindowOptions = {}\n): UseFloatingWindowReturnValue<T> {\n const [element, setElement] = useState<T | null>(null);\n const ref = useRef<T>(null);\n const pos = useRef({ x: 0, y: 0 });\n const offset = useRef({ x: 0, y: 0 });\n const [isDragging, setIsDragging] = useState(false);\n const isDraggingRef = useRef(false);\n const initialized = useRef(false);\n const enabledRef = useRefValue(options.enabled);\n\n const setDragging = useCallback((value: boolean) => {\n setIsDragging(value);\n isDraggingRef.current = value;\n }, []);\n\n const assignRef = useCallback((node: T | null) => {\n if (node) {\n ref.current = node;\n setElement(node);\n } else {\n ref.current = null;\n setElement(null);\n }\n }, []);\n\n useEffect(() => {\n const el = ref.current;\n if (!initialized.current && el) {\n initialized.current = true;\n pos.current = calculateInitialPosition(el, options);\n el.style.left = `${pos.current.x}px`;\n el.style.top = `${pos.current.y}px`;\n el.style.right = 'unset';\n el.style.bottom = 'unset';\n }\n\n return () => {\n initialized.current = false;\n };\n }, [\n element,\n options.constrainOffset,\n options.initialPosition?.top,\n options.initialPosition?.left,\n options.initialPosition?.right,\n options.initialPosition?.bottom,\n options.constrainToViewport,\n ]);\n\n useEffect(() => {\n const el = ref.current;\n if (!el) {\n return;\n }\n\n const controller = new AbortController();\n const signal = controller.signal;\n\n const onStart = (e: MouseEvent | TouchEvent) => {\n if (enabledRef.current === false) {\n return;\n }\n\n const point = 'touches' in e ? e.touches[0] : e;\n\n if ('button' in e && e.button !== 0) {\n return;\n }\n\n if (!getHandle(el, e.target, options)) {\n return;\n }\n\n setDragging(true);\n document.body.style.userSelect = 'none';\n document.body.style.webkitUserSelect = 'none';\n\n const rect = el.getBoundingClientRect();\n\n offset.current = {\n x: point.clientX - rect.left,\n y: point.clientY - rect.top,\n };\n\n options.onDragStart?.();\n\n document.addEventListener('mousemove', onMove, { signal });\n document.addEventListener('mouseup', onEnd, { signal });\n document.addEventListener('touchmove', onMove, { signal, passive: false });\n document.addEventListener('touchend', onEnd, { signal });\n };\n\n const onMove = (e: MouseEvent | TouchEvent) => {\n if (!isDraggingRef.current) {\n return;\n }\n\n const point = 'touches' in e ? e.touches[0] : e;\n e.preventDefault();\n\n let x = point.clientX - offset.current.x;\n let y = point.clientY - offset.current.y;\n\n const constrained = getConstrainedPosition(el, { x, y }, options);\n if (options.axis === 'x') {\n x = constrained.x;\n y = pos.current.y;\n } else if (options.axis === 'y') {\n x = pos.current.x;\n y = constrained.y;\n } else {\n x = constrained.x;\n y = constrained.y;\n }\n\n pos.current = { x, y };\n\n if (ref.current) {\n ref.current.style.left = `${x}px`;\n ref.current.style.top = `${y}px`;\n }\n\n options.onPositionChange?.({ x, y });\n };\n\n const onEnd = () => {\n if (isDraggingRef.current) {\n setDragging(false);\n document.body.style.userSelect = '';\n document.body.style.webkitUserSelect = '';\n options.onDragEnd?.();\n }\n };\n\n el.addEventListener('mousedown', onStart, { signal });\n el.addEventListener('touchstart', onStart, { signal, passive: false });\n\n return () => {\n controller.abort();\n };\n }, [\n options.constrainToViewport,\n options.constrainOffset,\n options.dragHandleSelector,\n options.axis,\n options.onPositionChange,\n options.onDragStart,\n options.onDragEnd,\n options.initialPosition?.top,\n options.initialPosition?.left,\n options.initialPosition?.right,\n options.initialPosition?.bottom,\n element,\n ]);\n\n useEffect(() => {\n const el = ref.current;\n if (!el) {\n return;\n }\n\n const observer = new ResizeObserver(() => {\n // Re-clamp current position if element size changes\n const constrained = getConstrainedPosition(el, pos.current, options);\n pos.current = constrained;\n el.style.left = `${constrained.x}px`;\n el.style.top = `${constrained.y}px`;\n });\n\n observer.observe(el);\n\n return () => {\n observer.disconnect();\n };\n }, [options.constrainToViewport, options.constrainOffset]);\n\n const setPosition = useCallback(\n (position: FloatingWindowPositionConfig) => {\n const el = ref.current;\n if (!el) {\n return;\n }\n\n const offset = options.constrainOffset ?? 0;\n const rect = el.getBoundingClientRect();\n\n let x: number | undefined;\n let y: number | undefined;\n\n if (position.left != null) {\n x = position.left;\n } else if (position.right != null) {\n x = window.innerWidth - rect.width - position.right;\n }\n\n if (position.top != null) {\n y = position.top;\n } else if (position.bottom != null) {\n y = window.innerHeight - rect.height - position.bottom;\n }\n\n x = x ?? pos.current.x;\n y = y ?? pos.current.y;\n\n if (options.constrainToViewport) {\n const clamped = clampToViewport(x, y, el, offset);\n x = clamped.x;\n y = clamped.y;\n }\n\n pos.current = { x, y };\n el.style.left = `${x}px`;\n el.style.top = `${y}px`;\n options.onPositionChange?.({ x, y });\n },\n [options.constrainToViewport, options.constrainOffset, options.onPositionChange]\n );\n\n return {\n ref: assignRef,\n setPosition,\n isDragging,\n };\n}\n\n// -------------------------------------------------------\n// Helper functions\n// -------------------------------------------------------\n\nfunction px(v: string) {\n return v.endsWith('px') ? parseFloat(v) : 0;\n}\n\nfunction calculateInitialPosition(\n el: HTMLElement,\n options: UseFloatingWindowOptions\n): { x: number; y: number } {\n const rect = el.getBoundingClientRect();\n const offset = options.constrainOffset ?? 0;\n const winW = window.innerWidth;\n const winH = window.innerHeight;\n const style = window.getComputedStyle(el);\n const top = options.initialPosition?.top;\n const left = options.initialPosition?.left;\n const right = options.initialPosition?.right;\n const bottom = options.initialPosition?.bottom;\n\n let x = offset;\n let y = offset;\n\n if (left != null) {\n x = left;\n } else if (right != null) {\n x = winW - rect.width - right;\n } else {\n x = px(style.left) || winW - rect.width - px(style.right) || offset;\n }\n\n if (top != null) {\n y = top;\n } else if (bottom != null) {\n y = winH - rect.height - bottom;\n } else {\n y = px(style.top) || winH - rect.height - px(style.bottom) || offset;\n }\n\n return options.constrainToViewport\n ? clampToViewport(x, y, el, options.constrainOffset)\n : { x, y };\n}\n\nfunction getConstrainedPosition(\n el: HTMLElement,\n pos: FloatingWindowPosition,\n options: UseFloatingWindowOptions\n) {\n if (!options.constrainToViewport || !el) {\n return pos;\n }\n\n const rect = el.getBoundingClientRect();\n const offset = options.constrainOffset ?? 0;\n const maxX = window.innerWidth - rect.width - offset;\n const maxY = window.innerHeight - rect.height - offset;\n\n return {\n x: Math.min(Math.max(offset, pos.x), maxX),\n y: Math.min(Math.max(offset, pos.y), maxY),\n };\n}\n\nfunction matchesExcludeSelector(target: Node, excludeSelector?: string): boolean {\n if (!excludeSelector) {\n return false;\n }\n if (!(target instanceof Element)) {\n return false;\n }\n\n return Boolean(target.closest(excludeSelector));\n}\n\nfunction getHandle(\n el: HTMLElement,\n target: EventTarget | null,\n options: UseFloatingWindowOptions\n): boolean {\n if (!(target instanceof Node)) {\n return false;\n }\n\n // If no drag handle selector, allow dragging from entire element\n if (!options.dragHandleSelector) {\n return !matchesExcludeSelector(target, options.excludeDragHandleSelector);\n }\n\n const handles = Array.from(el.querySelectorAll(options.dragHandleSelector));\n return handles.some(\n (handle) =>\n handle.contains(target) && !matchesExcludeSelector(target, options.excludeDragHandleSelector)\n );\n}\n\nfunction clampToViewport(\n x: number,\n y: number,\n el: HTMLElement,\n offset: number = 0\n): { x: number; y: number } {\n const rect = el.getBoundingClientRect();\n const maxX = window.innerWidth - rect.width - offset;\n const maxY = window.innerHeight - rect.height - offset;\n\n return {\n x: Math.min(Math.max(offset, x), maxX),\n y: Math.min(Math.max(offset, y), maxY),\n };\n}\n\nexport namespace useFloatingWindow {\n export type Options = UseFloatingWindowOptions;\n export type Position = FloatingWindowPosition;\n export type SetPosition = SetFloatingWindowPosition;\n export type ReturnValue<T extends HTMLElement> = UseFloatingWindowReturnValue<T>;\n}\n"],"mappings":";;;AAGA,SAAS,YAAe,OAAU;CAChC,MAAM,MAAM,OAAO,KAAK;CACxB,IAAI,UAAU;CACd,OAAO;AACT;AA8DA,SAAgB,kBACd,UAAoC,CAAC,GACJ;CACjC,MAAM,CAAC,SAAS,cAAc,SAAmB,IAAI;CACrD,MAAM,MAAM,OAAU,IAAI;CAC1B,MAAM,MAAM,OAAO;EAAE,GAAG;EAAG,GAAG;CAAE,CAAC;CACjC,MAAM,SAAS,OAAO;EAAE,GAAG;EAAG,GAAG;CAAE,CAAC;CACpC,MAAM,CAAC,YAAY,iBAAiB,SAAS,KAAK;CAClD,MAAM,gBAAgB,OAAO,KAAK;CAClC,MAAM,cAAc,OAAO,KAAK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,aAAa,KAAK,QAAQ;CAC9C,MAAM,OAAO,OAAO,cAAc,KAAK,SAAS;CAEhD,OAAO;EACL,GAAG,KAAK,IAAI,KAAK,IAAI,QAAQ,IAAI,CAAC,GAAG,IAAI;EACzC,GAAG,KAAK,IAAI,KAAK,IAAI,QAAQ,IAAI,CAAC,GAAG,IAAI;CAC3C;AACF;AAEA,SAAS,uBAAuB,QAAc,iBAAmC;CAC/E,IAAI,CAAC,iBACH,OAAO;CAET,IAAI,EAAE,kBAAkB,UACtB,OAAO;CAGT,OAAO,QAAQ,OAAO,QAAQ,eAAe,CAAC;AAChD;AAEA,SAAS,UACP,IACA,QACA,SACS;CACT,IAAI,EAAE,kBAAkB,OACtB,OAAO;CAIT,IAAI,CAAC,QAAQ,oBACX,OAAO,CAAC,uBAAuB,QAAQ,QAAQ,yBAAyB;CAI1E,OADgB,MAAM,KAAK,GAAG,iBAAiB,QAAQ,kBAAkB,CAC5D,EAAE,MACZ,WACC,OAAO,SAAS,MAAM,KAAK,CAAC,uBAAuB,QAAQ,QAAQ,yBAAyB,CAChG;AACF;AAEA,SAAS,gBACP,GACA,GACA,IACA,SAAiB,GACS;CAC1B,MAAM,OAAO,GAAG,sBAAsB;CACtC,MAAM,OAAO,OAAO,aAAa,KAAK,QAAQ;CAC9C,MAAM,OAAO,OAAO,cAAc,KAAK,SAAS;CAEhD,OAAO;EACL,GAAG,KAAK,IAAI,KAAK,IAAI,QAAQ,CAAC,GAAG,IAAI;EACrC,GAAG,KAAK,IAAI,KAAK,IAAI,QAAQ,CAAC,GAAG,IAAI;CACvC;AACF"}
1
+ {"version":3,"file":"use-floating-window.mjs","names":[],"sources":["../../src/use-floating-window/use-floating-window.ts"],"sourcesContent":["// Required to disable for webkit-user-select, although deprecated, it is still required for Safari support\nimport { RefCallback, useCallback, useEffect, useRef, useState } from 'react';\n\nfunction useRefValue<T>(value: T) {\n const ref = useRef(value);\n ref.current = value;\n return ref;\n}\n\ninterface FloatingWindowPositionConfig {\n top?: number;\n left?: number;\n right?: number;\n bottom?: number;\n}\n\ninterface FloatingWindowPosition {\n /** Element offset from the left side of the viewport */\n x: number;\n\n /** Element offset from the top side of the viewport */\n y: number;\n}\n\nexport interface UseFloatingWindowOptions {\n /** If `false`, the element can not be dragged. */\n enabled?: boolean;\n\n /** If `true`, the element can only move within the current viewport boundaries. */\n constrainToViewport?: boolean;\n\n /** The offset from the viewport edges when constraining the element. Requires `constrainToViewport: true`. */\n constrainOffset?: number;\n\n /** Selector of an element that should be used to drag floating window. If not specified, the entire root element is used as a drag target. */\n dragHandleSelector?: string;\n\n /** Selector of an element within `dragHandleSelector` that should be excluded from the drag event. */\n excludeDragHandleSelector?: string;\n\n /** If set, restricts movement to the specified axis */\n axis?: 'x' | 'y';\n\n /** Initial position. If not set, calculated from element styles. */\n initialPosition?: FloatingWindowPositionConfig;\n\n /** Called when the element position changes */\n onPositionChange?: (pos: FloatingWindowPosition) => void;\n\n /** Called when the drag starts */\n onDragStart?: () => void;\n\n /** Called when the drag stops */\n onDragEnd?: () => void;\n}\n\nexport type SetFloatingWindowPosition = (position: FloatingWindowPositionConfig) => void;\n\nexport interface UseFloatingWindowReturnValue<T extends HTMLElement> {\n /** Ref to the element that should be draggable */\n ref: RefCallback<T | null>;\n\n /** Function to set the position of the element */\n setPosition: SetFloatingWindowPosition;\n\n /** `true` if the element is currently being dragged */\n isDragging: boolean;\n}\n\nexport function useFloatingWindow<T extends HTMLElement>(\n options: UseFloatingWindowOptions = {}\n): UseFloatingWindowReturnValue<T> {\n const [element, setElement] = useState<T | null>(null);\n const ref = useRef<T>(null);\n const pos = useRef({ x: 0, y: 0 });\n const offset = useRef({ x: 0, y: 0 });\n const [isDragging, setIsDragging] = useState(false);\n const isDraggingRef = useRef(false);\n const initialized = useRef(false);\n const enabledRef = useRefValue(options.enabled);\n\n const setDragging = useCallback((value: boolean) => {\n setIsDragging(value);\n isDraggingRef.current = value;\n }, []);\n\n const assignRef = useCallback((node: T | null) => {\n if (node) {\n ref.current = node;\n setElement(node);\n } else {\n ref.current = null;\n setElement(null);\n }\n }, []);\n\n useEffect(() => {\n const el = ref.current;\n if (!initialized.current && el) {\n initialized.current = true;\n pos.current = calculateInitialPosition(el, options);\n el.style.left = `${pos.current.x}px`;\n el.style.top = `${pos.current.y}px`;\n el.style.right = 'unset';\n el.style.bottom = 'unset';\n }\n\n return () => {\n initialized.current = false;\n };\n }, [\n element,\n options.constrainOffset,\n options.initialPosition?.top,\n options.initialPosition?.left,\n options.initialPosition?.right,\n options.initialPosition?.bottom,\n options.constrainToViewport,\n ]);\n\n useEffect(() => {\n const el = ref.current;\n if (!el) {\n return;\n }\n\n const controller = new AbortController();\n const signal = controller.signal;\n\n const onStart = (e: MouseEvent | TouchEvent) => {\n if (enabledRef.current === false) {\n return;\n }\n\n const point = 'touches' in e ? e.touches[0] : e;\n\n if ('button' in e && e.button !== 0) {\n return;\n }\n\n if (!getHandle(el, e.target, options)) {\n return;\n }\n\n setDragging(true);\n document.body.style.userSelect = 'none';\n document.body.style.webkitUserSelect = 'none';\n\n const rect = el.getBoundingClientRect();\n\n offset.current = {\n x: point.clientX - rect.left,\n y: point.clientY - rect.top,\n };\n\n options.onDragStart?.();\n\n document.addEventListener('mousemove', onMove, { signal });\n document.addEventListener('mouseup', onEnd, { signal });\n document.addEventListener('touchmove', onMove, { signal, passive: false });\n document.addEventListener('touchend', onEnd, { signal });\n };\n\n const onMove = (e: MouseEvent | TouchEvent) => {\n if (!isDraggingRef.current) {\n return;\n }\n\n const point = 'touches' in e ? e.touches[0] : e;\n e.preventDefault();\n\n let x = point.clientX - offset.current.x;\n let y = point.clientY - offset.current.y;\n\n const constrained = getConstrainedPosition(el, { x, y }, options);\n if (options.axis === 'x') {\n x = constrained.x;\n y = pos.current.y;\n } else if (options.axis === 'y') {\n x = pos.current.x;\n y = constrained.y;\n } else {\n x = constrained.x;\n y = constrained.y;\n }\n\n pos.current = { x, y };\n\n if (ref.current) {\n ref.current.style.left = `${x}px`;\n ref.current.style.top = `${y}px`;\n }\n\n options.onPositionChange?.({ x, y });\n };\n\n const onEnd = () => {\n if (isDraggingRef.current) {\n setDragging(false);\n document.body.style.userSelect = '';\n document.body.style.webkitUserSelect = '';\n options.onDragEnd?.();\n }\n };\n\n el.addEventListener('mousedown', onStart, { signal });\n el.addEventListener('touchstart', onStart, { signal, passive: false });\n\n return () => {\n controller.abort();\n };\n }, [\n options.constrainToViewport,\n options.constrainOffset,\n options.dragHandleSelector,\n options.axis,\n options.onPositionChange,\n options.onDragStart,\n options.onDragEnd,\n options.initialPosition?.top,\n options.initialPosition?.left,\n options.initialPosition?.right,\n options.initialPosition?.bottom,\n element,\n ]);\n\n useEffect(() => {\n const el = ref.current;\n if (!el) {\n return;\n }\n\n const observer = new ResizeObserver(() => {\n // Re-clamp current position if element size changes\n const constrained = getConstrainedPosition(el, pos.current, options);\n pos.current = constrained;\n el.style.left = `${constrained.x}px`;\n el.style.top = `${constrained.y}px`;\n });\n\n observer.observe(el);\n\n return () => {\n observer.disconnect();\n };\n }, [options.constrainToViewport, options.constrainOffset]);\n\n const setPosition = useCallback(\n (position: FloatingWindowPositionConfig) => {\n const el = ref.current;\n if (!el) {\n return;\n }\n\n const offset = options.constrainOffset ?? 0;\n const rect = el.getBoundingClientRect();\n\n let x: number | undefined;\n let y: number | undefined;\n\n if (position.left != null) {\n x = position.left;\n } else if (position.right != null) {\n x = window.innerWidth - rect.width - position.right;\n }\n\n if (position.top != null) {\n y = position.top;\n } else if (position.bottom != null) {\n y = window.innerHeight - rect.height - position.bottom;\n }\n\n x = x ?? pos.current.x;\n y = y ?? pos.current.y;\n\n if (options.constrainToViewport) {\n const clamped = clampToViewport(x, y, el, offset);\n x = clamped.x;\n y = clamped.y;\n }\n\n pos.current = { x, y };\n el.style.left = `${x}px`;\n el.style.top = `${y}px`;\n options.onPositionChange?.({ x, y });\n },\n [options.constrainToViewport, options.constrainOffset, options.onPositionChange]\n );\n\n return {\n ref: assignRef,\n setPosition,\n isDragging,\n };\n}\n\n// -------------------------------------------------------\n// Helper functions\n// -------------------------------------------------------\n\nfunction px(v: string) {\n return v.endsWith('px') ? parseFloat(v) : 0;\n}\n\nfunction calculateInitialPosition(\n el: HTMLElement,\n options: UseFloatingWindowOptions\n): { x: number; y: number } {\n const rect = el.getBoundingClientRect();\n const offset = options.constrainOffset ?? 0;\n const winW = window.innerWidth;\n const winH = window.innerHeight;\n const style = window.getComputedStyle(el);\n const top = options.initialPosition?.top;\n const left = options.initialPosition?.left;\n const right = options.initialPosition?.right;\n const bottom = options.initialPosition?.bottom;\n\n let x = offset;\n let y = offset;\n\n if (left != null) {\n x = left;\n } else if (right != null) {\n x = winW - rect.width - right;\n } else {\n x = px(style.left) || winW - rect.width - px(style.right) || offset;\n }\n\n if (top != null) {\n y = top;\n } else if (bottom != null) {\n y = winH - rect.height - bottom;\n } else {\n y = px(style.top) || winH - rect.height - px(style.bottom) || offset;\n }\n\n return options.constrainToViewport\n ? clampToViewport(x, y, el, options.constrainOffset)\n : { x, y };\n}\n\nfunction getConstrainedPosition(\n el: HTMLElement,\n pos: FloatingWindowPosition,\n options: UseFloatingWindowOptions\n) {\n if (!options.constrainToViewport || !el) {\n return pos;\n }\n\n const rect = el.getBoundingClientRect();\n const offset = options.constrainOffset ?? 0;\n const maxX = window.innerWidth - rect.width - offset;\n const maxY = window.innerHeight - rect.height - offset;\n\n return {\n x: Math.min(Math.max(offset, pos.x), maxX),\n y: Math.min(Math.max(offset, pos.y), maxY),\n };\n}\n\nfunction matchesExcludeSelector(target: Node, excludeSelector?: string): boolean {\n if (!excludeSelector) {\n return false;\n }\n if (!(target instanceof Element)) {\n return false;\n }\n\n return Boolean(target.closest(excludeSelector));\n}\n\nfunction getHandle(\n el: HTMLElement,\n target: EventTarget | null,\n options: UseFloatingWindowOptions\n): boolean {\n if (!(target instanceof Node)) {\n return false;\n }\n\n // If no drag handle selector, allow dragging from entire element\n if (!options.dragHandleSelector) {\n return !matchesExcludeSelector(target, options.excludeDragHandleSelector);\n }\n\n const handles = Array.from(el.querySelectorAll(options.dragHandleSelector));\n return handles.some(\n (handle) =>\n handle.contains(target) && !matchesExcludeSelector(target, options.excludeDragHandleSelector)\n );\n}\n\nfunction clampToViewport(\n x: number,\n y: number,\n el: HTMLElement,\n offset: number = 0\n): { x: number; y: number } {\n const rect = el.getBoundingClientRect();\n const maxX = window.innerWidth - rect.width - offset;\n const maxY = window.innerHeight - rect.height - offset;\n\n return {\n x: Math.min(Math.max(offset, x), maxX),\n y: Math.min(Math.max(offset, y), maxY),\n };\n}\n\nexport namespace useFloatingWindow {\n export type Options = UseFloatingWindowOptions;\n export type Position = FloatingWindowPosition;\n export type SetPosition = SetFloatingWindowPosition;\n export type ReturnValue<T extends HTMLElement> = UseFloatingWindowReturnValue<T>;\n}\n"],"mappings":";;;AAGA,SAAS,YAAe,OAAU;CAChC,MAAM,MAAM,OAAO,KAAK;CACxB,IAAI,UAAU;CACd,OAAO;AACT;AA8DA,SAAgB,kBACd,UAAoC,CAAC,GACJ;CACjC,MAAM,CAAC,SAAS,cAAc,SAAmB,IAAI;CACrD,MAAM,MAAM,OAAU,IAAI;CAC1B,MAAM,MAAM,OAAO;EAAE,GAAG;EAAG,GAAG;CAAE,CAAC;CACjC,MAAM,SAAS,OAAO;EAAE,GAAG;EAAG,GAAG;CAAE,CAAC;CACpC,MAAM,CAAC,YAAY,iBAAiB,SAAS,KAAK;CAClD,MAAM,gBAAgB,OAAO,KAAK;CAClC,MAAM,cAAc,OAAO,KAAK;CAChC,MAAM,aAAa,YAAY,QAAQ,OAAO;CAE9C,MAAM,cAAc,aAAa,UAAmB;EAClD,cAAc,KAAK;EACnB,cAAc,UAAU;CAC1B,GAAG,CAAC,CAAC;CAEL,MAAM,YAAY,aAAa,SAAmB;EAChD,IAAI,MAAM;GACR,IAAI,UAAU;GACd,WAAW,IAAI;EACjB,OAAO;GACL,IAAI,UAAU;GACd,WAAW,IAAI;EACjB;CACF,GAAG,CAAC,CAAC;CAEL,gBAAgB;EACd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