@mantine/hooks 9.3.1 → 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 +250 -70
  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 +250 -70
  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 +54 -22
  122. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"use-splitter.mjs","names":[],"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 /** 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 '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}\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 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 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 const beforeWasCollapsed = prevSizes[s.handleIndex] === 0;\n const afterWasCollapsed = prevSizes[s.handleIndex + 1] === 0;\n const beforeNowCollapsed = newSizes[s.handleIndex] === 0;\n const afterNowCollapsed = newSizes[s.handleIndex + 1] === 0;\n\n if (!beforeWasCollapsed && beforeNowCollapsed) {\n preCollapseSizesRef.current = [...s.startSizes];\n opts.onCollapseChange?.(s.handleIndex, true);\n } else if (beforeWasCollapsed && !beforeNowCollapsed) {\n opts.onCollapseChange?.(s.handleIndex, false);\n }\n\n if (!afterWasCollapsed && afterNowCollapsed) {\n preCollapseSizesRef.current = [...s.startSizes];\n opts.onCollapseChange?.(s.handleIndex + 1, true);\n } else if (afterWasCollapsed && !afterNowCollapsed) {\n opts.onCollapseChange?.(s.handleIndex + 1, false);\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 const beforeWas = currentSizes[index] === 0;\n const afterWas = currentSizes[index + 1] === 0;\n const beforeNow = newSizes[index] === 0;\n const afterNow = newSizes[index + 1] === 0;\n\n if (!beforeWas && beforeNow) {\n preCollapseSizesRef.current = [...currentSizes];\n onCollapseChange?.(index, true);\n } else if (beforeWas && !beforeNow) {\n onCollapseChange?.(index, false);\n }\n\n if (!afterWas && afterNow) {\n preCollapseSizesRef.current = [...currentSizes];\n onCollapseChange?.(index + 1, true);\n } else if (afterWas && !afterNow) {\n onCollapseChange?.(index + 1, false);\n }\n\n updateSizes(newSizes);\n }\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 activeHandle,\n redistribute,\n getHandleRefCallback,\n toggleCollapsePanel,\n updateSizes,\n onCollapseChange,\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 };\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":";;;;AA6FA,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,OAAO;CAE1B,MAAM,YAAY,MAAM,aAAa;CACrC,MAAM,WAAW,MAAM,YAAY;CAEnC,IACE,YAAY,eACZ,YAAY,qBAAqB,WAAW,KAC5C,YAAY,MAAM,YAClB;EACA,MAAM,SAAS,CAAC,GAAG,KAAK;EACxB,OAAO,aAAa,OAAO;EAC3B,OAAO,aAAa;EACpB,OAAO;CACT;CAEA,IACE,WAAW,eACX,WAAW,qBAAqB,UAAU,KAC1C,WAAW,MAAM,WACjB;EACA,MAAM,SAAS,CAAC,GAAG,KAAK;EACxB,OAAO,cAAc,OAAO;EAC5B,O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B,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;CAClB;AACF"}
1
+ {"version":3,"file":"use-splitter.mjs","names":[],"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,iBA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A,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;EACA;EACA;EACA;CACF,CACF;CAEA,sBACc;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-toggle.mjs","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,UAAU,YAAY,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.mjs","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,UAAU,YAAY,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":"lower-first.mjs","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.mjs","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.mjs","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.mjs","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.mjs","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.mjs","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.mjs","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.mjs","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"}
package/lib/index.d.mts CHANGED
@@ -133,4 +133,4 @@ export type { UseHorizontalCollapseInput, UseHorizontalCollapseReturnValue, UseH
133
133
  export type { UseMaskOptions, UseMaskReturnValue, MaskState } from './use-mask/use-mask';
134
134
  export type { UseRovingIndexInput, UseRovingIndexGetItemPropsInput, UseRovingIndexReturnValue, } from './use-roving-index/use-roving-index';
135
135
  export type { UseDragState, UseDragOptions, UseDragReturnValue } from './use-drag/use-drag';
136
- export type { UseSplitterPanel, UseSplitterOptions, UseSplitterReturnValue, UseSplitterRedistributeInput, UseSplitterRedistributeFn, } from './use-splitter/use-splitter';
136
+ export type { UseSplitterPanel, UseSplitterOptions, UseSplitterReturnValue, UseSplitterRedistributeInput, UseSplitterRedistributeFn, UseSplitterResolvedPanel, SplitterPaneSize, SplitterStep, } from './use-splitter/use-splitter';
package/lib/index.d.ts CHANGED
@@ -133,4 +133,4 @@ export type { UseHorizontalCollapseInput, UseHorizontalCollapseReturnValue, UseH
133
133
  export type { UseMaskOptions, UseMaskReturnValue, MaskState } from './use-mask/use-mask';
134
134
  export type { UseRovingIndexInput, UseRovingIndexGetItemPropsInput, UseRovingIndexReturnValue, } from './use-roving-index/use-roving-index';
135
135
  export type { UseDragState, UseDragOptions, UseDragReturnValue } from './use-drag/use-drag';
136
- export type { UseSplitterPanel, UseSplitterOptions, UseSplitterReturnValue, UseSplitterRedistributeInput, UseSplitterRedistributeFn, } from './use-splitter/use-splitter';
136
+ export type { UseSplitterPanel, UseSplitterOptions, UseSplitterReturnValue, UseSplitterRedistributeInput, UseSplitterRedistributeFn, UseSplitterResolvedPanel, SplitterPaneSize, SplitterStep, } from './use-splitter/use-splitter';
@@ -1,23 +1,43 @@
1
+ /** Pane size expressed in CSS units. A bare `number` or `%` string is a flexible size (shares
2
+ * the leftover space), `px`/`rem` strings are fixed sizes that keep their pixel size when the
3
+ * container is resized. */
4
+ export type SplitterPaneSize = number | `${number}%` | `${number}px` | `${number}rem`;
5
+ /** Keyboard step expressed in CSS units. A bare `number` or `%` string is a percentage of the
6
+ * container, `px`/`rem` strings are resolved to pixels. */
7
+ export type SplitterStep = number | `${number}%` | `${number}px` | `${number}rem`;
1
8
  export interface UseSplitterPanel {
2
- /** Initial size as percentage (0-100). All panels must sum to 100. */
9
+ /** Initial size, a `number`/`%` is a flexible size, `px`/`rem` is a fixed size. A bare number is treated as a percentage. */
10
+ defaultSize: SplitterPaneSize;
11
+ /** Minimum size in the same units as `defaultSize`, `0` by default */
12
+ min?: SplitterPaneSize;
13
+ /** Maximum size in the same units as `defaultSize`, no limit by default */
14
+ max?: SplitterPaneSize;
15
+ /** Whether this panel can be collapsed, `false` by default */
16
+ collapsible?: boolean;
17
+ /** Size below which the panel snaps to collapsed, defaults to `min` */
18
+ collapseThreshold?: SplitterPaneSize;
19
+ }
20
+ /** Panel configuration resolved to numeric units (percent or pixels) passed to redistribute functions */
21
+ export interface UseSplitterResolvedPanel {
22
+ /** Resolved default size in the same units as redistribute sizes */
3
23
  defaultSize: number;
4
- /** Minimum size percentage, `0` by default */
24
+ /** Resolved minimum size */
5
25
  min?: number;
6
- /** Maximum size percentage, `100` by default */
26
+ /** Resolved maximum size */
7
27
  max?: number;
8
- /** Whether this panel can be collapsed, `false` by default */
28
+ /** Whether this panel can be collapsed */
9
29
  collapsible?: boolean;
10
- /** Size below which the panel snaps to collapsed (percentage), defaults to `min` */
30
+ /** Resolved collapse threshold */
11
31
  collapseThreshold?: number;
12
32
  }
13
33
  export interface UseSplitterRedistributeInput {
14
- /** Current sizes before applying delta */
34
+ /** Current sizes before applying delta, in resolved units (percent or pixels) */
15
35
  sizes: number[];
16
- /** Panel configurations */
17
- panels: UseSplitterPanel[];
36
+ /** Resolved panel configurations, in the same units as `sizes` */
37
+ panels: UseSplitterResolvedPanel[];
18
38
  /** Index of the handle being dragged */
19
39
  handleIndex: number;
20
- /** Requested size change in percentage (positive = grow before-panel) */
40
+ /** Requested size change in resolved units (positive = grow before-panel) */
21
41
  delta: number;
22
42
  }
23
43
  export type UseSplitterRedistributeFn = (input: UseSplitterRedistributeInput) => number[];
@@ -26,14 +46,14 @@ export interface UseSplitterOptions {
26
46
  panels: UseSplitterPanel[];
27
47
  /** Layout direction, `'horizontal'` by default */
28
48
  orientation?: 'horizontal' | 'vertical';
29
- /** Controlled sizes (percentages summing to 100) */
30
- sizes?: number[];
31
- /** Called during resize with updated sizes */
32
- onSizeChange?: (sizes: number[]) => void;
49
+ /** Controlled sizes, each value keeps the unit it was declared in */
50
+ sizes?: SplitterPaneSize[];
51
+ /** Called during resize with updated sizes, each value keeps its declared unit */
52
+ onSizeChange?: (sizes: SplitterPaneSize[]) => void;
33
53
  /** Called when drag starts */
34
54
  onResizeStart?: (handleIndex: number) => void;
35
55
  /** Called when drag ends */
36
- onResizeEnd?: (handleIndex: number, sizes: number[]) => void;
56
+ onResizeEnd?: (handleIndex: number, sizes: SplitterPaneSize[]) => void;
37
57
  /** Called when a panel collapses or expands */
38
58
  onCollapseChange?: (panelIndex: number, collapsed: boolean) => void;
39
59
  /** How to borrow space from non-adjacent panels when the immediate neighbor is at its min/max.
@@ -42,20 +62,25 @@ export interface UseSplitterOptions {
42
62
  * A function receives sizes, panels, handleIndex and delta, and returns new sizes.
43
63
  * When not set, only the two adjacent panels are affected. */
44
64
  redistribute?: 'nearest' | 'equal' | UseSplitterRedistributeFn;
45
- /** Keyboard step size in percentage, `1` by default */
46
- step?: number;
47
- /** Shift+arrow step size in percentage, `10` by default */
48
- shiftStep?: number;
65
+ /** Keyboard step size, a `number`/`%` is a percentage, `px`/`rem` is resolved to pixels, `1` by default */
66
+ step?: SplitterStep;
67
+ /** Shift+arrow step size, a `number`/`%` is a percentage, `px`/`rem` is resolved to pixels, `10` by default */
68
+ shiftStep?: SplitterStep;
49
69
  /** Text direction for keyboard nav, `'ltr'` by default */
50
70
  dir?: 'ltr' | 'rtl';
71
+ /** 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 */
72
+ resetOnDoubleClick?: boolean;
51
73
  /** Enable/disable the hook, `true` by default */
52
74
  enabled?: boolean;
53
75
  }
54
76
  export interface UseSplitterReturnValue<T extends HTMLElement = any> {
55
77
  /** Ref callback for the container element */
56
78
  ref: React.RefCallback<T | null>;
57
- /** Current panel sizes as percentages */
58
- sizes: number[];
79
+ /** Current panel sizes, each value keeps the unit it was declared in */
80
+ sizes: SplitterPaneSize[];
81
+ /** Whether sizes are tracked in pixels because any pane size, `min`, `max`, `step`, `shiftStep`
82
+ * or `collapseThreshold` uses a fixed `px`/`rem` unit */
83
+ pixelMode: boolean;
59
84
  /** Which panels are currently collapsed */
60
85
  collapsed: boolean[];
61
86
  /** Index of handle being dragged, or -1 */
@@ -72,17 +97,21 @@ export interface UseSplitterReturnValue<T extends HTMLElement = any> {
72
97
  'aria-valuemax': number;
73
98
  tabIndex: number;
74
99
  onKeyDown: React.KeyboardEventHandler;
100
+ onDoubleClick: React.MouseEventHandler;
75
101
  'data-active': boolean | undefined;
76
102
  'data-orientation': 'horizontal' | 'vertical';
77
103
  };
78
- /** Programmatically set sizes */
79
- setSizes: (sizes: number[]) => void;
104
+ /** Programmatically set sizes, each value keeps its declared unit */
105
+ setSizes: (sizes: SplitterPaneSize[]) => void;
80
106
  /** Collapse a panel */
81
107
  collapse: (panelIndex: number) => void;
82
108
  /** Expand a collapsed panel */
83
109
  expand: (panelIndex: number) => void;
84
110
  /** Toggle collapse of a panel */
85
111
  toggleCollapse: (panelIndex: number) => void;
112
+ /** Reset the two panels adjacent to a handle to their default ratio, preserving
113
+ * their combined size */
114
+ reset: (handleIndex: number) => void;
86
115
  }
87
116
  export declare function useSplitter<T extends HTMLElement = any>(options: UseSplitterOptions): UseSplitterReturnValue<T>;
88
117
  export declare namespace useSplitter {
@@ -90,5 +119,8 @@ export declare namespace useSplitter {
90
119
  type Options = UseSplitterOptions;
91
120
  type RedistributeInput = UseSplitterRedistributeInput;
92
121
  type RedistributeFn = UseSplitterRedistributeFn;
122
+ type ResolvedPanel = UseSplitterResolvedPanel;
93
123
  type ReturnValue<T extends HTMLElement = any> = UseSplitterReturnValue<T>;
124
+ type PaneSize = SplitterPaneSize;
125
+ type Step = SplitterStep;
94
126
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mantine/hooks",
3
- "version": "9.3.1",
3
+ "version": "9.4.0",
4
4
  "description": "A collection of 50+ hooks for state and UI management",
5
5
  "homepage": "https://mantine.dev",
6
6
  "license": "MIT",