@wirekyt/dom 0.0.1 → 0.0.2
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.
- package/dist/anatomy-DMuSMbOP.d.cts +18 -0
- package/dist/anatomy-DMuSMbOP.d.ts +18 -0
- package/dist/anatomy.cjs +3 -0
- package/dist/anatomy.d.cts +2 -0
- package/dist/anatomy.d.ts +2 -0
- package/dist/anatomy.js +2 -0
- package/dist/angle-3hqP0Mp5.cjs +13 -0
- package/dist/angle-oNt8uGHQ.js +8 -0
- package/dist/aria-hidden-CEXexb2I.js +127 -0
- package/dist/aria-hidden-Y7iJHPMr.cjs +132 -0
- package/dist/aria-hidden.cjs +3 -0
- package/dist/aria-hidden.d.cts +10 -0
- package/dist/aria-hidden.d.ts +10 -0
- package/dist/aria-hidden.js +2 -0
- package/dist/array-BGtygd0o.cjs +198 -0
- package/dist/array-C4KbHsha.js +73 -0
- package/dist/auto-resize-5F5iiKZb.cjs +106 -0
- package/dist/auto-resize-KkNfCcBt.js +95 -0
- package/dist/auto-resize.cjs +4 -0
- package/dist/auto-resize.d.cts +7 -0
- package/dist/auto-resize.d.ts +7 -0
- package/dist/auto-resize.js +2 -0
- package/dist/caret-CHqaP4XG.cjs +30 -0
- package/dist/caret-aiDJ6mAS.js +19 -0
- package/dist/closest-Clo6ODcK.js +117 -0
- package/dist/closest-IiRz1GIJ.cjs +176 -0
- package/dist/collection-CJU0oDtX.js +1295 -0
- package/dist/collection-CwzUJwBJ.cjs +1342 -0
- package/dist/collection.cjs +15 -0
- package/dist/collection.d.cts +34 -0
- package/dist/collection.d.ts +34 -0
- package/dist/collection.js +3 -0
- package/dist/color-CsugZjq6.d.cts +60 -0
- package/dist/color-CsugZjq6.d.ts +60 -0
- package/dist/color-utils-DzeOVYlL.cjs +662 -0
- package/dist/color-utils-lDDg9FEh.js +639 -0
- package/dist/color-utils.cjs +6 -0
- package/dist/color-utils.d.cts +18 -0
- package/dist/color-utils.d.ts +18 -0
- package/dist/color-utils.js +2 -0
- package/dist/computed-style-B1MKlCoo.js +9 -0
- package/dist/computed-style-DLArEFNw.cjs +14 -0
- package/dist/controller-B8E8ZJCI.cjs +133 -0
- package/dist/controller-Dv7lWHDr.js +92 -0
- package/dist/core-BF6G2RiC.d.cts +1 -0
- package/dist/core-BNMw-JId.cjs +372 -0
- package/dist/core-BdeZuSX6.d.ts +1 -0
- package/dist/core-CJ0MZr3D.js +289 -0
- package/dist/core.cjs +19 -0
- package/dist/core.d.cts +3 -0
- package/dist/core.d.ts +3 -0
- package/dist/core.js +3 -0
- package/dist/create-anatomy-B2q3wiaw.js +22 -0
- package/dist/create-anatomy-BwDn25ph.cjs +27 -0
- package/dist/create-props-CgtcN_Qu.js +4 -0
- package/dist/create-props-CjLx2oS8.cjs +9 -0
- package/dist/data-url-C-Uk31Q9.cjs +42 -0
- package/dist/data-url-DHUHj7UF.js +37 -0
- package/dist/data-url-Gx_SWG-k.d.cts +10 -0
- package/dist/data-url-Gx_SWG-k.d.ts +10 -0
- package/dist/date-utils-D-JJHedx.cjs +868 -0
- package/dist/date-utils-D5zXW-Cs.js +569 -0
- package/dist/date-utils.cjs +52 -0
- package/dist/date-utils.d.cts +7 -0
- package/dist/date-utils.d.ts +7 -0
- package/dist/date-utils.js +2 -0
- package/dist/dismissable-C0bixtzl.cjs +348 -0
- package/dist/dismissable-KM1jPtNQ.js +337 -0
- package/dist/dismissable-layer-BTX5EvXw.d.ts +40 -0
- package/dist/dismissable-layer-Ch5niVaq.d.cts +40 -0
- package/dist/dismissable.cjs +4 -0
- package/dist/dismissable.d.cts +3 -0
- package/dist/dismissable.d.ts +3 -0
- package/dist/dismissable.js +2 -0
- package/dist/dom-query-CQzY93XU.cjs +488 -0
- package/dist/dom-query-e7fh0TEH.js +243 -0
- package/dist/dom-query.cjs +180 -0
- package/dist/dom-query.d.cts +142 -0
- package/dist/dom-query.d.ts +142 -0
- package/dist/dom-query.js +43 -0
- package/dist/equal-C927y7MN.cjs +30 -0
- package/dist/equal-DtrP8DPh.js +25 -0
- package/dist/event-DDz-mMhM.cjs +242 -0
- package/dist/event-bTItRgiw.js +117 -0
- package/dist/file-utils-6EXCdfHx.js +116 -0
- package/dist/file-utils-B7OJigQq.cjs +151 -0
- package/dist/file-utils.cjs +92 -0
- package/dist/file-utils.d.cts +40 -0
- package/dist/file-utils.d.ts +40 -0
- package/dist/file-utils.js +82 -0
- package/dist/focus-trap-89E5I9nm.js +487 -0
- package/dist/focus-trap-D7jKsfHW.cjs +498 -0
- package/dist/focus-trap.cjs +4 -0
- package/dist/focus-trap.d.cts +89 -0
- package/dist/focus-trap.d.ts +89 -0
- package/dist/focus-trap.js +2 -0
- package/dist/focus-visible-DWdQf__4.js +176 -0
- package/dist/focus-visible-G4cmlWqq.cjs +217 -0
- package/dist/focus-visible.cjs +9 -0
- package/dist/focus-visible.d.cts +32 -0
- package/dist/focus-visible.d.ts +32 -0
- package/dist/focus-visible.js +2 -0
- package/dist/form-B1DW_w_3.js +89 -0
- package/dist/form-CoupKpuP.cjs +130 -0
- package/dist/from-window-5ZhzSURC.js +68 -0
- package/dist/from-window-B9DKtaoR.cjs +115 -0
- package/dist/functions-isw5Ovcx.d.cts +16 -0
- package/dist/functions-isw5Ovcx.d.ts +16 -0
- package/dist/highlight-word.cjs +95 -0
- package/dist/highlight-word.d.cts +24 -0
- package/dist/highlight-word.d.ts +24 -0
- package/dist/highlight-word.js +94 -0
- package/dist/hotkeys.cjs +1183 -0
- package/dist/hotkeys.d.cts +199 -0
- package/dist/hotkeys.d.ts +199 -0
- package/dist/hotkeys.js +1173 -0
- package/dist/i18n-utils-BD4VtonY.cjs +345 -0
- package/dist/i18n-utils-C4FQZ39m.js +280 -0
- package/dist/i18n-utils.cjs +216 -0
- package/dist/i18n-utils.d.cts +71 -0
- package/dist/i18n-utils.d.ts +71 -0
- package/dist/i18n-utils.js +204 -0
- package/dist/index-3tNJficI.d.cts +117 -0
- package/dist/index-3tNJficI.d.ts +117 -0
- package/dist/index-BEfvdGE2.d.cts +116 -0
- package/dist/index-BEfvdGE2.d.ts +116 -0
- package/dist/index-BF6G2RiC.d.cts +1 -0
- package/dist/index-BKgxIVbE.d.cts +285 -0
- package/dist/index-BMtpmaRD.d.cts +16 -0
- package/dist/index-BMtpmaRD.d.ts +16 -0
- package/dist/index-BWiYePx8.d.cts +216 -0
- package/dist/index-BXfunVyD.d.cts +1342 -0
- package/dist/index-BXfunVyD.d.ts +1342 -0
- package/dist/index-BdeZuSX6.d.ts +1 -0
- package/dist/index-C2865AJq.d.cts +25 -0
- package/dist/index-C2865AJq.d.ts +25 -0
- package/dist/index-CFoN0L3C.d.ts +285 -0
- package/dist/index-vPrqYDHu.d.ts +216 -0
- package/dist/index.cjs +19 -0
- package/dist/index.d.cts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/initial-focus-BQxRRFPa.cjs +37 -0
- package/dist/initial-focus-BrN5tT2X.js +26 -0
- package/dist/interact-outside-BjqIunFx.js +211 -0
- package/dist/interact-outside-Dphjr2Zh.cjs +216 -0
- package/dist/interact-outside.cjs +3 -0
- package/dist/interact-outside.d.cts +2 -0
- package/dist/interact-outside.d.ts +2 -0
- package/dist/interact-outside.js +2 -0
- package/dist/json-tree-utils.cjs +1518 -0
- package/dist/json-tree-utils.d.cts +117 -0
- package/dist/json-tree-utils.d.ts +117 -0
- package/dist/json-tree-utils.js +1469 -0
- package/dist/list-collection-D_eNKrot.d.cts +60 -0
- package/dist/list-collection-RqYEWHb4.d.ts +60 -0
- package/dist/live-region-BD0OgmrH.cjs +68 -0
- package/dist/live-region-F8YMmbrY.js +63 -0
- package/dist/live-region.cjs +3 -0
- package/dist/live-region.d.cts +2 -0
- package/dist/live-region.d.ts +2 -0
- package/dist/live-region.js +2 -0
- package/dist/machines/accordion/index.cjs +328 -0
- package/dist/machines/accordion/index.d.cts +83 -0
- package/dist/machines/accordion/index.d.ts +83 -0
- package/dist/machines/accordion/index.js +321 -0
- package/dist/machines/angle-slider/index.cjs +420 -0
- package/dist/machines/angle-slider/index.d.cts +84 -0
- package/dist/machines/angle-slider/index.d.ts +84 -0
- package/dist/machines/angle-slider/index.js +415 -0
- package/dist/machines/async-list/index.cjs +310 -0
- package/dist/machines/async-list/index.d.cts +90 -0
- package/dist/machines/async-list/index.d.ts +90 -0
- package/dist/machines/async-list/index.js +308 -0
- package/dist/machines/avatar/index.cjs +165 -0
- package/dist/machines/avatar/index.d.cts +63 -0
- package/dist/machines/avatar/index.d.ts +63 -0
- package/dist/machines/avatar/index.js +160 -0
- package/dist/machines/carousel/index.cjs +929 -0
- package/dist/machines/carousel/index.d.cts +146 -0
- package/dist/machines/carousel/index.d.ts +146 -0
- package/dist/machines/carousel/index.js +920 -0
- package/dist/machines/cascade-select/index.cjs +1426 -0
- package/dist/machines/cascade-select/index.d.cts +167 -0
- package/dist/machines/cascade-select/index.d.ts +167 -0
- package/dist/machines/cascade-select/index.js +1419 -0
- package/dist/machines/checkbox/index.cjs +316 -0
- package/dist/machines/checkbox/index.d.cts +81 -0
- package/dist/machines/checkbox/index.d.ts +81 -0
- package/dist/machines/checkbox/index.js +311 -0
- package/dist/machines/clipboard/index.cjs +228 -0
- package/dist/machines/clipboard/index.d.cts +72 -0
- package/dist/machines/clipboard/index.d.ts +72 -0
- package/dist/machines/clipboard/index.js +221 -0
- package/dist/machines/collapsible/index.cjs +363 -0
- package/dist/machines/collapsible/index.d.cts +82 -0
- package/dist/machines/collapsible/index.d.ts +82 -0
- package/dist/machines/collapsible/index.js +358 -0
- package/dist/machines/color-picker/index.cjs +1534 -0
- package/dist/machines/color-picker/index.d.cts +207 -0
- package/dist/machines/color-picker/index.d.ts +207 -0
- package/dist/machines/color-picker/index.js +1518 -0
- package/dist/machines/combobox/index.cjs +1554 -0
- package/dist/machines/combobox/index.d.cts +219 -0
- package/dist/machines/combobox/index.d.ts +219 -0
- package/dist/machines/combobox/index.js +1542 -0
- package/dist/machines/date-input/index.cjs +1974 -0
- package/dist/machines/date-input/index.d.cts +230 -0
- package/dist/machines/date-input/index.d.ts +230 -0
- package/dist/machines/date-input/index.js +1958 -0
- package/dist/machines/date-picker/index.cjs +2424 -0
- package/dist/machines/date-picker/index.d.cts +378 -0
- package/dist/machines/date-picker/index.d.ts +378 -0
- package/dist/machines/date-picker/index.js +2408 -0
- package/dist/machines/dialog/index.cjs +378 -0
- package/dist/machines/dialog/index.d.cts +94 -0
- package/dist/machines/dialog/index.d.ts +94 -0
- package/dist/machines/dialog/index.js +373 -0
- package/dist/machines/drawer/index.cjs +2066 -0
- package/dist/machines/drawer/index.d.cts +334 -0
- package/dist/machines/drawer/index.d.ts +334 -0
- package/dist/machines/drawer/index.js +2059 -0
- package/dist/machines/editable/index.cjs +550 -0
- package/dist/machines/editable/index.d.cts +114 -0
- package/dist/machines/editable/index.d.ts +114 -0
- package/dist/machines/editable/index.js +545 -0
- package/dist/machines/file-upload/index.cjs +648 -0
- package/dist/machines/file-upload/index.d.cts +150 -0
- package/dist/machines/file-upload/index.d.ts +150 -0
- package/dist/machines/file-upload/index.js +641 -0
- package/dist/machines/floating-panel/index.cjs +1020 -0
- package/dist/machines/floating-panel/index.d.cts +149 -0
- package/dist/machines/floating-panel/index.d.ts +149 -0
- package/dist/machines/floating-panel/index.js +1012 -0
- package/dist/machines/hover-card/index.cjs +441 -0
- package/dist/machines/hover-card/index.d.cts +82 -0
- package/dist/machines/hover-card/index.d.ts +82 -0
- package/dist/machines/hover-card/index.js +436 -0
- package/dist/machines/image-cropper/index.cjs +2082 -0
- package/dist/machines/image-cropper/index.d.cts +182 -0
- package/dist/machines/image-cropper/index.d.ts +182 -0
- package/dist/machines/image-cropper/index.js +2076 -0
- package/dist/machines/listbox/index.cjs +873 -0
- package/dist/machines/listbox/index.d.cts +175 -0
- package/dist/machines/listbox/index.d.ts +175 -0
- package/dist/machines/listbox/index.js +860 -0
- package/dist/machines/marquee/index.cjs +387 -0
- package/dist/machines/marquee/index.d.cts +102 -0
- package/dist/machines/marquee/index.d.ts +102 -0
- package/dist/machines/marquee/index.js +382 -0
- package/dist/machines/menu/index.cjs +1562 -0
- package/dist/machines/menu/index.d.cts +188 -0
- package/dist/machines/menu/index.d.ts +188 -0
- package/dist/machines/menu/index.js +1549 -0
- package/dist/machines/navigation-menu/index.cjs +860 -0
- package/dist/machines/navigation-menu/index.d.cts +131 -0
- package/dist/machines/navigation-menu/index.d.ts +131 -0
- package/dist/machines/navigation-menu/index.js +855 -0
- package/dist/machines/number-input/index.cjs +1014 -0
- package/dist/machines/number-input/index.d.cts +136 -0
- package/dist/machines/number-input/index.d.ts +136 -0
- package/dist/machines/number-input/index.js +1009 -0
- package/dist/machines/pagination/index.cjs +413 -0
- package/dist/machines/pagination/index.d.cts +139 -0
- package/dist/machines/pagination/index.d.ts +139 -0
- package/dist/machines/pagination/index.js +404 -0
- package/dist/machines/password-input/index.cjs +224 -0
- package/dist/machines/password-input/index.d.cts +71 -0
- package/dist/machines/password-input/index.d.ts +71 -0
- package/dist/machines/password-input/index.js +219 -0
- package/dist/machines/pin-input/index.cjs +595 -0
- package/dist/machines/pin-input/index.d.cts +107 -0
- package/dist/machines/pin-input/index.d.ts +107 -0
- package/dist/machines/pin-input/index.js +590 -0
- package/dist/machines/popover/index.cjs +516 -0
- package/dist/machines/popover/index.d.cts +107 -0
- package/dist/machines/popover/index.d.ts +107 -0
- package/dist/machines/popover/index.js +511 -0
- package/dist/machines/presence/index.cjs +193 -0
- package/dist/machines/presence/index.d.cts +44 -0
- package/dist/machines/presence/index.d.ts +44 -0
- package/dist/machines/presence/index.js +190 -0
- package/dist/machines/progress/index.cjs +282 -0
- package/dist/machines/progress/index.d.cts +96 -0
- package/dist/machines/progress/index.d.ts +96 -0
- package/dist/machines/progress/index.js +277 -0
- package/dist/machines/qr-code/index.cjs +167 -0
- package/dist/machines/qr-code/index.d.cts +71 -0
- package/dist/machines/qr-code/index.d.ts +71 -0
- package/dist/machines/qr-code/index.js +162 -0
- package/dist/machines/radio-group/index.cjs +465 -0
- package/dist/machines/radio-group/index.d.cts +218 -0
- package/dist/machines/radio-group/index.d.ts +218 -0
- package/dist/machines/radio-group/index.js +458 -0
- package/dist/machines/rating-group/index.cjs +405 -0
- package/dist/machines/rating-group/index.d.cts +101 -0
- package/dist/machines/rating-group/index.d.ts +101 -0
- package/dist/machines/rating-group/index.js +398 -0
- package/dist/machines/scroll-area/index.cjs +865 -0
- package/dist/machines/scroll-area/index.d.cts +126 -0
- package/dist/machines/scroll-area/index.d.ts +126 -0
- package/dist/machines/scroll-area/index.js +860 -0
- package/dist/machines/select/index.cjs +1226 -0
- package/dist/machines/select/index.d.cts +190 -0
- package/dist/machines/select/index.d.ts +190 -0
- package/dist/machines/select/index.js +1214 -0
- package/dist/machines/signature-pad/index.cjs +337 -0
- package/dist/machines/signature-pad/index.d.cts +108 -0
- package/dist/machines/signature-pad/index.d.ts +108 -0
- package/dist/machines/signature-pad/index.js +330 -0
- package/dist/machines/slider/index.cjs +1103 -0
- package/dist/machines/slider/index.d.cts +154 -0
- package/dist/machines/slider/index.d.ts +154 -0
- package/dist/machines/slider/index.js +1094 -0
- package/dist/machines/splitter/index.cjs +1686 -0
- package/dist/machines/splitter/index.d.cts +282 -0
- package/dist/machines/splitter/index.d.ts +282 -0
- package/dist/machines/splitter/index.js +1675 -0
- package/dist/machines/steps/index.cjs +330 -0
- package/dist/machines/steps/index.d.cts +109 -0
- package/dist/machines/steps/index.d.ts +109 -0
- package/dist/machines/steps/index.js +325 -0
- package/dist/machines/switch/index.cjs +307 -0
- package/dist/machines/switch/index.d.cts +80 -0
- package/dist/machines/switch/index.d.ts +80 -0
- package/dist/machines/switch/index.js +302 -0
- package/dist/machines/tabs/index.cjs +542 -0
- package/dist/machines/tabs/index.d.cts +113 -0
- package/dist/machines/tabs/index.d.ts +113 -0
- package/dist/machines/tabs/index.js +533 -0
- package/dist/machines/tags-input/index.cjs +1151 -0
- package/dist/machines/tags-input/index.d.cts +182 -0
- package/dist/machines/tags-input/index.d.ts +182 -0
- package/dist/machines/tags-input/index.js +1144 -0
- package/dist/machines/timer/index.cjs +329 -0
- package/dist/machines/timer/index.d.cts +102 -0
- package/dist/machines/timer/index.d.ts +102 -0
- package/dist/machines/timer/index.js +323 -0
- package/dist/machines/toast/index.cjs +1185 -0
- package/dist/machines/toast/index.d.cts +204 -0
- package/dist/machines/toast/index.d.ts +204 -0
- package/dist/machines/toast/index.js +1180 -0
- package/dist/machines/toc/index.cjs +358 -0
- package/dist/machines/toc/index.d.cts +98 -0
- package/dist/machines/toc/index.d.ts +98 -0
- package/dist/machines/toc/index.js +351 -0
- package/dist/machines/toggle/index.cjs +99 -0
- package/dist/machines/toggle/index.d.cts +46 -0
- package/dist/machines/toggle/index.d.ts +46 -0
- package/dist/machines/toggle/index.js +94 -0
- package/dist/machines/toggle-group/index.cjs +329 -0
- package/dist/machines/toggle-group/index.d.cts +81 -0
- package/dist/machines/toggle-group/index.d.ts +81 -0
- package/dist/machines/toggle-group/index.js +322 -0
- package/dist/machines/tooltip/index.cjs +638 -0
- package/dist/machines/tooltip/index.d.cts +84 -0
- package/dist/machines/tooltip/index.d.ts +84 -0
- package/dist/machines/tooltip/index.js +633 -0
- package/dist/machines/tour/index.cjs +1123 -0
- package/dist/machines/tour/index.d.cts +207 -0
- package/dist/machines/tour/index.d.ts +207 -0
- package/dist/machines/tour/index.js +1115 -0
- package/dist/machines/tree-view/index.cjs +1288 -0
- package/dist/machines/tree-view/index.d.cts +221 -0
- package/dist/machines/tree-view/index.d.ts +221 -0
- package/dist/machines/tree-view/index.js +1279 -0
- package/dist/mutation-observer-_LbwtN3W.cjs +61 -0
- package/dist/mutation-observer-qObPUo3D.js +50 -0
- package/dist/navigate-CJOaL3vx.js +31 -0
- package/dist/navigate-uJG-006f.cjs +42 -0
- package/dist/overflow-BBihfMxX.cjs +67 -0
- package/dist/overflow-C-zO1CWA.js +44 -0
- package/dist/platform-BDB0wXUk.js +26 -0
- package/dist/platform-BZS-dkZN.cjs +109 -0
- package/dist/point-C9A4dk1i.js +27 -0
- package/dist/point-DxnCrJBy.cjs +32 -0
- package/dist/pointer-lock-BvfSjt_s.cjs +31 -0
- package/dist/pointer-lock-WezxTqu-.js +26 -0
- package/dist/pointer-move-CGzan38r.cjs +42 -0
- package/dist/pointer-move-Tijb8Ptk.js +37 -0
- package/dist/polygon-BvdwYRBw.js +76 -0
- package/dist/polygon-CTR1kEoU.cjs +93 -0
- package/dist/popper-DkAAS9VE.cjs +487 -0
- package/dist/popper-DzBZzAe4.js +464 -0
- package/dist/popper.cjs +6 -0
- package/dist/popper.d.cts +2 -0
- package/dist/popper.d.ts +2 -0
- package/dist/popper.js +2 -0
- package/dist/press-B7XLrLGR.js +65 -0
- package/dist/press-BdD5suLQ.cjs +70 -0
- package/dist/proxy-tab-focus-DWMXvAfO.js +54 -0
- package/dist/proxy-tab-focus-NthYgHdY.cjs +59 -0
- package/dist/raf-BSDcY4UD.cjs +85 -0
- package/dist/raf-DgINgykK.d.cts +15 -0
- package/dist/raf-DgINgykK.d.ts +15 -0
- package/dist/raf-Dhvm7f1e.js +62 -0
- package/dist/rect-utils-DiT4k3jS.cjs +548 -0
- package/dist/rect-utils-d_3gZVsc.js +459 -0
- package/dist/rect-utils.cjs +165 -0
- package/dist/rect-utils.d.cts +197 -0
- package/dist/rect-utils.d.ts +197 -0
- package/dist/rect-utils.js +116 -0
- package/dist/remove-scroll-DTVA5f4w.cjs +86 -0
- package/dist/remove-scroll-WEheFCiq.js +81 -0
- package/dist/remove-scroll.cjs +3 -0
- package/dist/remove-scroll.d.cts +4 -0
- package/dist/remove-scroll.d.ts +4 -0
- package/dist/remove-scroll.js +2 -0
- package/dist/rolldown-runtime-D6vf50IK.cjs +28 -0
- package/dist/scale-C5BBHVgH.js +17 -0
- package/dist/scale-C7iiUGhS.cjs +22 -0
- package/dist/scope-CysKlKe9.cjs +28 -0
- package/dist/scope-D1873Mzi.js +23 -0
- package/dist/scroll-CVJ40w2e.js +46 -0
- package/dist/scroll-Dyd1QLrc.cjs +63 -0
- package/dist/scroll-snap-Cuaqdevf.cjs +224 -0
- package/dist/scroll-snap-DqMiFASa.js +201 -0
- package/dist/scroll-snap.cjs +6 -0
- package/dist/scroll-snap.d.cts +14 -0
- package/dist/scroll-snap.d.ts +14 -0
- package/dist/scroll-snap.js +2 -0
- package/dist/selection-ClKhnWit.d.cts +49 -0
- package/dist/selection-DzLiSVkg.d.ts +49 -0
- package/dist/selection-map-962WvX2k.js +45 -0
- package/dist/selection-map-BwlZr1LH.cjs +68 -0
- package/dist/set-CFNGOW5W.js +50 -0
- package/dist/set-DrtWCLFb.cjs +73 -0
- package/dist/store-BLpJlMxz.js +257 -0
- package/dist/store-Btfrm2bs.cjs +47 -0
- package/dist/store-C5HvdLyc.js +42 -0
- package/dist/store-Wg8KVwNv.cjs +298 -0
- package/dist/store.cjs +9 -0
- package/dist/store.d.cts +26 -0
- package/dist/store.d.ts +26 -0
- package/dist/store.js +2 -0
- package/dist/stringify-state.cjs +48 -0
- package/dist/stringify-state.d.cts +8 -0
- package/dist/stringify-state.d.ts +8 -0
- package/dist/stringify-state.js +44 -0
- package/dist/tabbable-Bz1-1GAY.cjs +206 -0
- package/dist/tabbable-CDA1YMjZ.js +147 -0
- package/dist/text-selection-B3OQpQGy.cjs +75 -0
- package/dist/text-selection-DXvWvm6k.js +64 -0
- package/dist/timers-BRyPrXIX.js +82 -0
- package/dist/timers-Beu4SfAj.cjs +99 -0
- package/dist/tree-collection-3QX3EIhq.d.ts +77 -0
- package/dist/tree-collection-C6oDQGUJ.d.cts +77 -0
- package/dist/typeahead-DremEgML.d.cts +45 -0
- package/dist/typeahead-DremEgML.d.ts +45 -0
- package/dist/types-BFuHIo7S.js +10 -0
- package/dist/types-CczqoQLL.d.cts +57 -0
- package/dist/types-CczqoQLL.d.ts +57 -0
- package/dist/types-CjocssbC.d.cts +13 -0
- package/dist/types-CjocssbC.d.ts +13 -0
- package/dist/types-D7oF7eWh.d.cts +54 -0
- package/dist/types-D7oF7eWh.d.ts +54 -0
- package/dist/types-HCvp3Bhv.cjs +21 -0
- package/dist/types.cjs +14 -0
- package/dist/types.d.cts +6 -0
- package/dist/types.d.ts +6 -0
- package/dist/types.js +12 -0
- package/dist/utils-BH-oBBz2.cjs +614 -0
- package/dist/utils-Cht5XaHf.js +267 -0
- package/dist/utils.cjs +95 -0
- package/dist/utils.d.cts +144 -0
- package/dist/utils.d.ts +144 -0
- package/dist/utils.js +7 -0
- package/dist/visually-hidden-BgSCFLz_.cjs +29 -0
- package/dist/visually-hidden-yDJ517KZ.js +18 -0
- package/dist/wait-for-3n85JcCU.d.cts +15 -0
- package/dist/wait-for-3n85JcCU.d.ts +15 -0
- package/dist/wait-for-CI5Ye-Lo.js +69 -0
- package/dist/wait-for-Db73VpZQ.cjs +86 -0
- package/dist/warning-CrzBpWT1.js +19 -0
- package/dist/warning-HAmFXLHm.cjs +42 -0
- package/package.json +349 -6
|
@@ -0,0 +1,1675 @@
|
|
|
1
|
+
import { t as createAnatomy } from "../../create-anatomy-B2q3wiaw.js";
|
|
2
|
+
import { D as isElement, f as queryAll, g as getDocument, h as getAncestorElements, k as isHTMLElement, p as contains, r as resizeObserverBorderBox, y as getParentElement, z as dataAttr } from "../../dom-query-e7fh0TEH.js";
|
|
3
|
+
import { t as getComputedStyle } from "../../computed-style-B1MKlCoo.js";
|
|
4
|
+
import { i as getEventPoint, m as isLeftClick, r as getEventKey } from "../../event-bTItRgiw.js";
|
|
5
|
+
import { n as observeChildren } from "../../mutation-observer-qObPUo3D.js";
|
|
6
|
+
import { t as trackPointerMove } from "../../pointer-move-Tijb8Ptk.js";
|
|
7
|
+
import { g as prev, p as next } from "../../array-C4KbHsha.js";
|
|
8
|
+
import { t as isEqual } from "../../equal-DtrP8DPh.js";
|
|
9
|
+
import { J as hasProp, n as createSplitProps } from "../../utils-Cht5XaHf.js";
|
|
10
|
+
import { r as setRafTimeout } from "../../timers-BRyPrXIX.js";
|
|
11
|
+
import { n as ensureProps, t as ensure } from "../../warning-CrzBpWT1.js";
|
|
12
|
+
import { r as createMachine } from "../../core-CJ0MZr3D.js";
|
|
13
|
+
import { t as createProps } from "../../create-props-CgtcN_Qu.js";
|
|
14
|
+
//#region src/machines/splitter/anatomy.ts
|
|
15
|
+
const anatomy = createAnatomy("splitter").parts("root", "panel", "resizeTrigger", "resizeTriggerIndicator");
|
|
16
|
+
const parts = anatomy.build();
|
|
17
|
+
//#endregion
|
|
18
|
+
//#region src/machines/splitter/dom.ts
|
|
19
|
+
const getRootId = (ctx) => ctx.ids?.root ?? `splitter:${ctx.id}`;
|
|
20
|
+
const getResizeTriggerId = (ctx, id) => ctx.ids?.resizeTrigger?.(id) ?? `splitter:${ctx.id}:splitter:${id}`;
|
|
21
|
+
const getPanelId = (ctx, id) => ctx.ids?.panel?.(id) ?? `splitter:${ctx.id}:panel:${id}`;
|
|
22
|
+
const getGlobalCursorId = (ctx) => `splitter:${ctx.id}:global-cursor`;
|
|
23
|
+
const getRootEl = (ctx) => ctx.getById(getRootId(ctx));
|
|
24
|
+
const getResizeTriggerEl = (ctx, id) => id != null ? ctx.getById(getResizeTriggerId(ctx, id)) : null;
|
|
25
|
+
const getPanelIdFromEl = (el) => {
|
|
26
|
+
return isHTMLElement(el) && el.dataset.part === "panel" ? el.dataset.id : void 0;
|
|
27
|
+
};
|
|
28
|
+
const getPrevPanelId = (el) => {
|
|
29
|
+
let prev = el?.previousElementSibling ?? null;
|
|
30
|
+
while (prev) {
|
|
31
|
+
const id = getPanelIdFromEl(prev);
|
|
32
|
+
if (id) return id;
|
|
33
|
+
prev = prev.previousElementSibling;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
const getNextPanelId = (el) => {
|
|
37
|
+
let next = el?.nextElementSibling ?? null;
|
|
38
|
+
while (next) {
|
|
39
|
+
const id = getPanelIdFromEl(next);
|
|
40
|
+
if (id) return id;
|
|
41
|
+
next = next.nextElementSibling;
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
const resolveResizeTriggerId = (ctx, id) => {
|
|
45
|
+
const [beforeId, afterId] = id.split(":");
|
|
46
|
+
if (beforeId && afterId) return id;
|
|
47
|
+
const triggerEl = getResizeTriggerEl(ctx, id);
|
|
48
|
+
const resolvedBeforeId = beforeId || getPrevPanelId(triggerEl);
|
|
49
|
+
const resolvedAfterId = afterId || getNextPanelId(triggerEl);
|
|
50
|
+
return resolvedBeforeId && resolvedAfterId ? `${resolvedBeforeId}:${resolvedAfterId}` : null;
|
|
51
|
+
};
|
|
52
|
+
const getCursor = (state, x) => {
|
|
53
|
+
let cursor = x ? "col-resize" : "row-resize";
|
|
54
|
+
if (state.isAtMin) cursor = x ? "e-resize" : "s-resize";
|
|
55
|
+
if (state.isAtMax) cursor = x ? "w-resize" : "n-resize";
|
|
56
|
+
return cursor;
|
|
57
|
+
};
|
|
58
|
+
const getResizeTriggerEls = (ctx) => {
|
|
59
|
+
return queryAll(getRootEl(ctx), `[role=separator][data-ownedby='${CSS.escape(getRootId(ctx))}']`);
|
|
60
|
+
};
|
|
61
|
+
const getGlobalCursorEl = (ctx) => {
|
|
62
|
+
return ctx.getDoc().getElementById(getGlobalCursorId(ctx));
|
|
63
|
+
};
|
|
64
|
+
const setupGlobalCursor = (ctx, state, x, nonce) => {
|
|
65
|
+
const styleEl = getGlobalCursorEl(ctx);
|
|
66
|
+
const textContent = `* { cursor: ${getCursor(state, x)} !important; }`;
|
|
67
|
+
if (styleEl) styleEl.textContent = textContent;
|
|
68
|
+
else {
|
|
69
|
+
const style = ctx.getDoc().createElement("style");
|
|
70
|
+
if (nonce) style.nonce = nonce;
|
|
71
|
+
style.id = getGlobalCursorId(ctx);
|
|
72
|
+
style.textContent = textContent;
|
|
73
|
+
ctx.getDoc().head.appendChild(style);
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
const removeGlobalCursor = (ctx) => {
|
|
77
|
+
getGlobalCursorEl(ctx)?.remove();
|
|
78
|
+
};
|
|
79
|
+
//#endregion
|
|
80
|
+
//#region src/machines/splitter/utils/aria.ts
|
|
81
|
+
function calculateAriaValues({ size, panels, pivotIndices }) {
|
|
82
|
+
let currentMinSize = 0;
|
|
83
|
+
let currentMaxSize = 100;
|
|
84
|
+
let totalMinSize = 0;
|
|
85
|
+
let totalMaxSize = 0;
|
|
86
|
+
const firstIndex = pivotIndices[0];
|
|
87
|
+
ensure(firstIndex, () => "No pivot index found");
|
|
88
|
+
panels.forEach((panel, index) => {
|
|
89
|
+
const { maxSize = 100, minSize = 0 } = panel;
|
|
90
|
+
if (index === firstIndex) {
|
|
91
|
+
currentMinSize = minSize;
|
|
92
|
+
currentMaxSize = maxSize;
|
|
93
|
+
} else {
|
|
94
|
+
totalMinSize += minSize;
|
|
95
|
+
totalMaxSize += maxSize;
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
return {
|
|
99
|
+
valueMax: Math.min(currentMaxSize, 100 - totalMinSize),
|
|
100
|
+
valueMin: Math.max(currentMinSize, 100 - totalMaxSize),
|
|
101
|
+
valueNow: size[firstIndex]
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
function getAriaValue(size, panels, handleId) {
|
|
105
|
+
const [beforeId, afterId] = handleId.split(":");
|
|
106
|
+
const beforeIndex = panels.findIndex((panel) => panel.id === beforeId);
|
|
107
|
+
const afterIndex = panels.findIndex((panel) => panel.id === afterId);
|
|
108
|
+
if (beforeIndex === -1 || afterIndex === -1) return {
|
|
109
|
+
beforeId: beforeId || void 0,
|
|
110
|
+
afterId: afterId || void 0,
|
|
111
|
+
valueMax: void 0,
|
|
112
|
+
valueMin: void 0,
|
|
113
|
+
valueNow: void 0
|
|
114
|
+
};
|
|
115
|
+
const { valueMax, valueMin, valueNow } = calculateAriaValues({
|
|
116
|
+
size,
|
|
117
|
+
panels,
|
|
118
|
+
pivotIndices: [beforeIndex, afterIndex]
|
|
119
|
+
});
|
|
120
|
+
return {
|
|
121
|
+
beforeId,
|
|
122
|
+
afterId,
|
|
123
|
+
valueMax: Math.round(valueMax),
|
|
124
|
+
valueMin: Math.round(valueMin),
|
|
125
|
+
valueNow: valueNow != null ? Math.round(valueNow) : void 0
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
function fuzzyCompareNumbers(actual, expected, fractionDigits = 10) {
|
|
129
|
+
if (actual.toFixed(fractionDigits) === expected.toFixed(fractionDigits)) return 0;
|
|
130
|
+
else return actual > expected ? 1 : -1;
|
|
131
|
+
}
|
|
132
|
+
function fuzzyNumbersEqual(actual, expected, fractionDigits = 10) {
|
|
133
|
+
if (actual == null || expected == null) return false;
|
|
134
|
+
return fuzzyCompareNumbers(actual, expected, fractionDigits) === 0;
|
|
135
|
+
}
|
|
136
|
+
function fuzzySizeEqual(actual, expected, fractionDigits) {
|
|
137
|
+
if (actual.length !== expected.length) return false;
|
|
138
|
+
for (let index = 0; index < actual.length; index++) {
|
|
139
|
+
const actualSize = actual[index];
|
|
140
|
+
const expectedSize = expected[index];
|
|
141
|
+
if (!fuzzyNumbersEqual(actualSize, expectedSize, fractionDigits)) return false;
|
|
142
|
+
}
|
|
143
|
+
return true;
|
|
144
|
+
}
|
|
145
|
+
//#endregion
|
|
146
|
+
//#region src/machines/splitter/utils/size.ts
|
|
147
|
+
const sizeRegex = /^(-?\d*\.?\d+)(%|px|em|rem|vw|vh)?$/;
|
|
148
|
+
const percentRegex = /^(-?\d*\.?\d+)%$/;
|
|
149
|
+
function getRootSize(rootEl, orientation) {
|
|
150
|
+
if (!rootEl) return 0;
|
|
151
|
+
const rect = rootEl.getBoundingClientRect();
|
|
152
|
+
return orientation === "horizontal" ? rect.width : rect.height;
|
|
153
|
+
}
|
|
154
|
+
function getGroupSize(rootEl, orientation) {
|
|
155
|
+
return getRootSize(rootEl, orientation);
|
|
156
|
+
}
|
|
157
|
+
function toPixelValue(value, unit, rootEl) {
|
|
158
|
+
const win = rootEl.ownerDocument.defaultView;
|
|
159
|
+
if (!win) return void 0;
|
|
160
|
+
switch (unit) {
|
|
161
|
+
case "px": return value;
|
|
162
|
+
case "em": return value * Number.parseFloat(win.getComputedStyle(rootEl).fontSize);
|
|
163
|
+
case "rem": return value * Number.parseFloat(win.getComputedStyle(rootEl.ownerDocument.documentElement).fontSize);
|
|
164
|
+
case "vw": return value / 100 * win.innerWidth;
|
|
165
|
+
case "vh": return value / 100 * win.innerHeight;
|
|
166
|
+
default: return;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
function parsePanelSize(size, rootEl, orientation) {
|
|
170
|
+
if (size == null) return void 0;
|
|
171
|
+
if (typeof size === "number") return size;
|
|
172
|
+
const match = size.trim().match(sizeRegex);
|
|
173
|
+
if (!match) return void 0;
|
|
174
|
+
const value = Number.parseFloat(match[1]);
|
|
175
|
+
if (!Number.isFinite(value)) return void 0;
|
|
176
|
+
const unit = match[2];
|
|
177
|
+
if (unit == null || unit === "%") return value;
|
|
178
|
+
if (!rootEl) return void 0;
|
|
179
|
+
const rootSize = getRootSize(rootEl, orientation);
|
|
180
|
+
if (rootSize === 0) return void 0;
|
|
181
|
+
const px = toPixelValue(value, unit, rootEl);
|
|
182
|
+
return px == null ? void 0 : px / rootSize * 100;
|
|
183
|
+
}
|
|
184
|
+
function toCssPanelSize(size) {
|
|
185
|
+
if (size == null) return void 0;
|
|
186
|
+
if (typeof size === "number") return `${size}%`;
|
|
187
|
+
const trimmed = size.trim();
|
|
188
|
+
if (percentRegex.test(trimmed)) return trimmed;
|
|
189
|
+
const match = trimmed.match(sizeRegex);
|
|
190
|
+
if (!match) return void 0;
|
|
191
|
+
const value = Number.parseFloat(match[1]);
|
|
192
|
+
if (!Number.isFinite(value)) return void 0;
|
|
193
|
+
const unit = match[2];
|
|
194
|
+
return unit == null ? `${value}%` : `${value}${unit}`;
|
|
195
|
+
}
|
|
196
|
+
function resolvePanelSizes({ sizes, panels, rootEl, orientation }) {
|
|
197
|
+
const nextSize = Array(panels.length);
|
|
198
|
+
let remainingSize = 100;
|
|
199
|
+
let numPanelsWithSizes = 0;
|
|
200
|
+
for (let index = 0; index < panels.length; index++) {
|
|
201
|
+
const size = parsePanelSize(sizes?.[index], rootEl, orientation);
|
|
202
|
+
if (size == null) continue;
|
|
203
|
+
numPanelsWithSizes++;
|
|
204
|
+
nextSize[index] = size;
|
|
205
|
+
remainingSize -= size;
|
|
206
|
+
}
|
|
207
|
+
for (let index = 0; index < panels.length; index++) {
|
|
208
|
+
if (nextSize[index] != null) continue;
|
|
209
|
+
const numRemainingPanels = panels.length - numPanelsWithSizes;
|
|
210
|
+
const size = numRemainingPanels > 0 ? remainingSize / numRemainingPanels : 0;
|
|
211
|
+
numPanelsWithSizes++;
|
|
212
|
+
nextSize[index] = size;
|
|
213
|
+
remainingSize -= size;
|
|
214
|
+
}
|
|
215
|
+
return nextSize;
|
|
216
|
+
}
|
|
217
|
+
function normalizePanels(panels, rootEl, orientation) {
|
|
218
|
+
return panels.map((panel) => ({
|
|
219
|
+
...panel,
|
|
220
|
+
minSize: parsePanelSize(panel.minSize, rootEl, orientation),
|
|
221
|
+
maxSize: parsePanelSize(panel.maxSize, rootEl, orientation),
|
|
222
|
+
collapsedSize: parsePanelSize(panel.collapsedSize, rootEl, orientation)
|
|
223
|
+
}));
|
|
224
|
+
}
|
|
225
|
+
//#endregion
|
|
226
|
+
//#region src/machines/splitter/utils/panel.ts
|
|
227
|
+
function getPanelById(panels, id) {
|
|
228
|
+
const panel = panels.find((panel) => panel.id === id);
|
|
229
|
+
ensure(panel, () => `Panel data not found for id "${id}"`);
|
|
230
|
+
return panel;
|
|
231
|
+
}
|
|
232
|
+
function findPanelDataIndex(panels, panel) {
|
|
233
|
+
return panels.findIndex((prevPanel) => prevPanel === panel || prevPanel.id === panel.id);
|
|
234
|
+
}
|
|
235
|
+
function findPanelIndex(panels, id) {
|
|
236
|
+
return panels.findIndex((panel) => panel.id === id);
|
|
237
|
+
}
|
|
238
|
+
function panelDataHelper(panels, panel, sizes) {
|
|
239
|
+
const index = findPanelIndex(panels, panel.id);
|
|
240
|
+
const pivotIndices = index === panels.length - 1 ? [index - 1, index] : [index, index + 1];
|
|
241
|
+
const panelSize = sizes[index];
|
|
242
|
+
return {
|
|
243
|
+
...panel,
|
|
244
|
+
panelSize,
|
|
245
|
+
pivotIndices
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
function sortPanels(panels) {
|
|
249
|
+
return panels.sort((panelA, panelB) => {
|
|
250
|
+
const orderA = panelA.order;
|
|
251
|
+
const orderB = panelB.order;
|
|
252
|
+
if (orderA == null && orderB == null) return 0;
|
|
253
|
+
else if (orderA == null) return -1;
|
|
254
|
+
else if (orderB == null) return 1;
|
|
255
|
+
else return orderA - orderB;
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
function getPanelLayout(panels) {
|
|
259
|
+
return panels.map((panel) => panel.id).sort().join(":");
|
|
260
|
+
}
|
|
261
|
+
function serializePanels(panels) {
|
|
262
|
+
return panels.map((panel) => panel.id).sort().map((key) => {
|
|
263
|
+
const panel = panels.find((panel) => panel.id === key);
|
|
264
|
+
return JSON.stringify(panel);
|
|
265
|
+
}).join(",");
|
|
266
|
+
}
|
|
267
|
+
function getPanelFlexBoxStyle({ size, defaultSize, dragState, resolvedSizes, panels, panelIndex, horizontal, precision = 3 }) {
|
|
268
|
+
const resolvedSize = resolvedSizes[panelIndex];
|
|
269
|
+
const layoutSize = size ?? defaultSize;
|
|
270
|
+
const panel = panels[panelIndex];
|
|
271
|
+
let flexGrow;
|
|
272
|
+
let flexBasis;
|
|
273
|
+
let flexShrink = 1;
|
|
274
|
+
const constraintAxis = horizontal ? "Width" : "Height";
|
|
275
|
+
const minSize = panel ? toCssPanelSize(panel.minSize) : void 0;
|
|
276
|
+
const maxSize = panel ? toCssPanelSize(panel.maxSize) : void 0;
|
|
277
|
+
const layoutCssSize = toCssPanelSize(layoutSize);
|
|
278
|
+
if (resolvedSize == null) if (layoutCssSize != null) if (layoutCssSize.endsWith("%")) flexGrow = Number.parseFloat(layoutCssSize).toPrecision(precision);
|
|
279
|
+
else {
|
|
280
|
+
flexBasis = getClampedFlexBasis({
|
|
281
|
+
basis: layoutCssSize,
|
|
282
|
+
minSize,
|
|
283
|
+
maxSize
|
|
284
|
+
});
|
|
285
|
+
flexGrow = "0";
|
|
286
|
+
flexShrink = 0;
|
|
287
|
+
}
|
|
288
|
+
else flexGrow = "1";
|
|
289
|
+
else if (panels.length === 1) flexGrow = "1";
|
|
290
|
+
else flexGrow = resolvedSize.toPrecision(precision);
|
|
291
|
+
return {
|
|
292
|
+
flexBasis: flexBasis ?? 0,
|
|
293
|
+
flexGrow,
|
|
294
|
+
flexShrink,
|
|
295
|
+
...minSize ? { [`min${constraintAxis}`]: minSize } : {},
|
|
296
|
+
...maxSize ? { [`max${constraintAxis}`]: maxSize } : {},
|
|
297
|
+
overflow: "hidden",
|
|
298
|
+
pointerEvents: dragState !== null ? "none" : void 0
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
function getClampedFlexBasis({ basis, minSize, maxSize }) {
|
|
302
|
+
return `clamp(${minSize ?? "0%"}, ${basis}, ${maxSize ?? "100%"})`;
|
|
303
|
+
}
|
|
304
|
+
//#endregion
|
|
305
|
+
//#region src/machines/splitter/connect.ts
|
|
306
|
+
function connect(service, normalize) {
|
|
307
|
+
const { state, send, prop, computed, context, scope } = service;
|
|
308
|
+
const horizontal = computed("horizontal");
|
|
309
|
+
const dragging = state.matches("dragging");
|
|
310
|
+
const registry = prop("registry");
|
|
311
|
+
const orientation = prop("orientation");
|
|
312
|
+
const rawPanels = prop("panels");
|
|
313
|
+
const panels = context.get("panels");
|
|
314
|
+
const getResolvedSizes = () => {
|
|
315
|
+
const sizes = context.get("size");
|
|
316
|
+
if (sizes.length > 0) return sizes;
|
|
317
|
+
return resolvePanelSizes({
|
|
318
|
+
sizes: prop("size") ?? prop("defaultSize"),
|
|
319
|
+
panels: rawPanels,
|
|
320
|
+
rootEl: null,
|
|
321
|
+
orientation
|
|
322
|
+
});
|
|
323
|
+
};
|
|
324
|
+
const getPanelStyle = (id) => {
|
|
325
|
+
const panelIndex = rawPanels.findIndex((panel) => panel.id === id);
|
|
326
|
+
const size = prop("size")?.[panelIndex];
|
|
327
|
+
const defaultSize = prop("defaultSize")?.[panelIndex];
|
|
328
|
+
return getPanelFlexBoxStyle({
|
|
329
|
+
size,
|
|
330
|
+
defaultSize,
|
|
331
|
+
dragState: context.get("dragState"),
|
|
332
|
+
resolvedSizes: context.get("size"),
|
|
333
|
+
panels: rawPanels,
|
|
334
|
+
panelIndex,
|
|
335
|
+
horizontal
|
|
336
|
+
});
|
|
337
|
+
};
|
|
338
|
+
const resolveResizeTriggerId = (id) => {
|
|
339
|
+
const [beforeId, afterId] = id.split(":");
|
|
340
|
+
if (beforeId && afterId) return id;
|
|
341
|
+
if (beforeId) {
|
|
342
|
+
const index = rawPanels.findIndex((panel) => panel.id === beforeId);
|
|
343
|
+
const nextPanel = rawPanels[index + 1];
|
|
344
|
+
return nextPanel ? `${beforeId}:${nextPanel.id}` : id;
|
|
345
|
+
}
|
|
346
|
+
if (afterId) {
|
|
347
|
+
const index = rawPanels.findIndex((panel) => panel.id === afterId);
|
|
348
|
+
const prevPanel = rawPanels[index - 1];
|
|
349
|
+
return prevPanel ? `${prevPanel.id}:${afterId}` : id;
|
|
350
|
+
}
|
|
351
|
+
return id;
|
|
352
|
+
};
|
|
353
|
+
const getResizeTriggerState = (props) => {
|
|
354
|
+
const { id, disabled } = props;
|
|
355
|
+
const dragging = context.get("dragState")?.resizeTriggerId === id;
|
|
356
|
+
return {
|
|
357
|
+
dragging,
|
|
358
|
+
focused: dragging || state.matches("focused") && context.get("keyboardState")?.resizeTriggerId === id,
|
|
359
|
+
disabled: !!disabled
|
|
360
|
+
};
|
|
361
|
+
};
|
|
362
|
+
return {
|
|
363
|
+
dragging,
|
|
364
|
+
orientation,
|
|
365
|
+
getPanels() {
|
|
366
|
+
return rawPanels;
|
|
367
|
+
},
|
|
368
|
+
getPanelById(id) {
|
|
369
|
+
return getPanelById(rawPanels, id);
|
|
370
|
+
},
|
|
371
|
+
getItems() {
|
|
372
|
+
return rawPanels.flatMap((panel, index, arr) => {
|
|
373
|
+
const nextPanel = arr[index + 1];
|
|
374
|
+
if (panel && nextPanel) return [{
|
|
375
|
+
type: "panel",
|
|
376
|
+
id: panel.id
|
|
377
|
+
}, {
|
|
378
|
+
type: "handle",
|
|
379
|
+
id: `${panel.id}:${nextPanel.id}`
|
|
380
|
+
}];
|
|
381
|
+
return [{
|
|
382
|
+
type: "panel",
|
|
383
|
+
id: panel.id
|
|
384
|
+
}];
|
|
385
|
+
});
|
|
386
|
+
},
|
|
387
|
+
getSizes() {
|
|
388
|
+
return getResolvedSizes();
|
|
389
|
+
},
|
|
390
|
+
setSizes(size) {
|
|
391
|
+
send({
|
|
392
|
+
type: "SIZE.SET",
|
|
393
|
+
size
|
|
394
|
+
});
|
|
395
|
+
},
|
|
396
|
+
resetSizes() {
|
|
397
|
+
send({ type: "SIZE.RESET" });
|
|
398
|
+
},
|
|
399
|
+
collapsePanel(id) {
|
|
400
|
+
send({
|
|
401
|
+
type: "PANEL.COLLAPSE",
|
|
402
|
+
id
|
|
403
|
+
});
|
|
404
|
+
},
|
|
405
|
+
expandPanel(id, minSize) {
|
|
406
|
+
send({
|
|
407
|
+
type: "PANEL.EXPAND",
|
|
408
|
+
id,
|
|
409
|
+
minSize
|
|
410
|
+
});
|
|
411
|
+
},
|
|
412
|
+
resizePanel(id, unsafePanelSize) {
|
|
413
|
+
send({
|
|
414
|
+
type: "PANEL.RESIZE",
|
|
415
|
+
id,
|
|
416
|
+
size: unsafePanelSize
|
|
417
|
+
});
|
|
418
|
+
},
|
|
419
|
+
getPanelSize(id) {
|
|
420
|
+
const panels = context.get("panels");
|
|
421
|
+
const size = getResolvedSizes();
|
|
422
|
+
const panelData = getPanelById(panels, id);
|
|
423
|
+
const { panelSize } = panelDataHelper(panels, panelData, size);
|
|
424
|
+
ensure(panelSize != null, () => `Panel size not found for panel "${panelData.id}"`);
|
|
425
|
+
return panelSize;
|
|
426
|
+
},
|
|
427
|
+
isPanelCollapsed(id) {
|
|
428
|
+
const panels = context.get("panels");
|
|
429
|
+
const size = getResolvedSizes();
|
|
430
|
+
const panelData = getPanelById(panels, id);
|
|
431
|
+
const { collapsedSize = 0, collapsible, panelSize } = panelDataHelper(panels, panelData, size);
|
|
432
|
+
ensure(panelSize != null, () => `Panel size not found for panel "${panelData.id}"`);
|
|
433
|
+
return collapsible === true && fuzzyNumbersEqual(panelSize, collapsedSize);
|
|
434
|
+
},
|
|
435
|
+
isPanelExpanded(id) {
|
|
436
|
+
const panels = context.get("panels");
|
|
437
|
+
const size = getResolvedSizes();
|
|
438
|
+
const panelData = getPanelById(panels, id);
|
|
439
|
+
const { collapsedSize = 0, collapsible, panelSize } = panelDataHelper(panels, panelData, size);
|
|
440
|
+
ensure(panelSize != null, () => `Panel size not found for panel "${panelData.id}"`);
|
|
441
|
+
return !collapsible || fuzzyCompareNumbers(panelSize, collapsedSize) > 0;
|
|
442
|
+
},
|
|
443
|
+
getLayout() {
|
|
444
|
+
return getPanelLayout(prop("panels"));
|
|
445
|
+
},
|
|
446
|
+
getRootProps() {
|
|
447
|
+
return normalize.element({
|
|
448
|
+
...parts.root.attrs,
|
|
449
|
+
"data-orientation": orientation,
|
|
450
|
+
"data-dragging": dataAttr(dragging),
|
|
451
|
+
id: getRootId(scope),
|
|
452
|
+
dir: prop("dir"),
|
|
453
|
+
style: {
|
|
454
|
+
display: "flex",
|
|
455
|
+
flexDirection: horizontal ? "row" : "column",
|
|
456
|
+
height: "100%",
|
|
457
|
+
width: "100%",
|
|
458
|
+
overflow: "hidden"
|
|
459
|
+
}
|
|
460
|
+
});
|
|
461
|
+
},
|
|
462
|
+
getPanelProps(props) {
|
|
463
|
+
const { id } = props;
|
|
464
|
+
return normalize.element({
|
|
465
|
+
...parts.panel.attrs,
|
|
466
|
+
"data-orientation": orientation,
|
|
467
|
+
"data-dragging": dataAttr(dragging),
|
|
468
|
+
dir: prop("dir"),
|
|
469
|
+
"data-id": id,
|
|
470
|
+
"data-index": findPanelIndex(prop("panels"), id),
|
|
471
|
+
id: getPanelId(scope, id),
|
|
472
|
+
"data-ownedby": getRootId(scope),
|
|
473
|
+
style: getPanelStyle(id)
|
|
474
|
+
});
|
|
475
|
+
},
|
|
476
|
+
getResizeTriggerState,
|
|
477
|
+
getResizeTriggerIndicator(props) {
|
|
478
|
+
const triggerState = getResizeTriggerState(props);
|
|
479
|
+
return normalize.element({
|
|
480
|
+
...parts.resizeTriggerIndicator.attrs,
|
|
481
|
+
"data-orientation": orientation,
|
|
482
|
+
"data-focus": dataAttr(triggerState.focused),
|
|
483
|
+
"data-dragging": dataAttr(triggerState.dragging),
|
|
484
|
+
"data-disabled": dataAttr(triggerState.disabled),
|
|
485
|
+
"data-ownedby": getRootId(scope)
|
|
486
|
+
});
|
|
487
|
+
},
|
|
488
|
+
getResizeTriggerProps(props) {
|
|
489
|
+
const { id } = props;
|
|
490
|
+
const triggerState = getResizeTriggerState(props);
|
|
491
|
+
const resolvedId = resolveResizeTriggerId(id);
|
|
492
|
+
const aria = getAriaValue(getResolvedSizes(), panels, resolvedId);
|
|
493
|
+
return normalize.element({
|
|
494
|
+
...parts.resizeTrigger.attrs,
|
|
495
|
+
dir: prop("dir"),
|
|
496
|
+
id: getResizeTriggerId(scope, id),
|
|
497
|
+
role: "separator",
|
|
498
|
+
"data-id": id,
|
|
499
|
+
"data-ownedby": getRootId(scope),
|
|
500
|
+
tabIndex: triggerState.disabled ? void 0 : 0,
|
|
501
|
+
"aria-valuenow": aria.valueNow,
|
|
502
|
+
"aria-valuemin": aria.valueMin,
|
|
503
|
+
"aria-valuemax": aria.valueMax,
|
|
504
|
+
"data-orientation": orientation,
|
|
505
|
+
"aria-orientation": orientation,
|
|
506
|
+
"aria-controls": aria.beforeId && aria.afterId ? `${getPanelId(scope, aria.beforeId)} ${getPanelId(scope, aria.afterId)}` : void 0,
|
|
507
|
+
"data-focus": dataAttr(triggerState.focused),
|
|
508
|
+
"data-dragging": dataAttr(triggerState.dragging),
|
|
509
|
+
"data-disabled": dataAttr(triggerState.disabled),
|
|
510
|
+
style: {
|
|
511
|
+
touchAction: "none",
|
|
512
|
+
userSelect: "none",
|
|
513
|
+
WebkitUserSelect: "none",
|
|
514
|
+
flex: "0 0 auto",
|
|
515
|
+
pointerEvents: triggerState.disabled ? "none" : triggerState.dragging && !triggerState.focused ? "none" : void 0,
|
|
516
|
+
cursor: triggerState.disabled || registry ? void 0 : horizontal ? "col-resize" : "row-resize",
|
|
517
|
+
[horizontal ? "minHeight" : "minWidth"]: "0"
|
|
518
|
+
},
|
|
519
|
+
onPointerDown(event) {
|
|
520
|
+
if (!isLeftClick(event)) return;
|
|
521
|
+
if (triggerState.disabled) {
|
|
522
|
+
event.preventDefault();
|
|
523
|
+
return;
|
|
524
|
+
}
|
|
525
|
+
event.currentTarget.focus({ preventScroll: true });
|
|
526
|
+
if (registry) return;
|
|
527
|
+
const point = getEventPoint(event);
|
|
528
|
+
send({
|
|
529
|
+
type: "POINTER_DOWN",
|
|
530
|
+
id,
|
|
531
|
+
point
|
|
532
|
+
});
|
|
533
|
+
event.currentTarget.setPointerCapture(event.pointerId);
|
|
534
|
+
event.preventDefault();
|
|
535
|
+
event.stopPropagation();
|
|
536
|
+
},
|
|
537
|
+
onPointerUp(event) {
|
|
538
|
+
if (triggerState.disabled) return;
|
|
539
|
+
if (event.currentTarget.hasPointerCapture(event.pointerId)) event.currentTarget.releasePointerCapture(event.pointerId);
|
|
540
|
+
},
|
|
541
|
+
onPointerOver() {
|
|
542
|
+
if (triggerState.disabled || registry) return;
|
|
543
|
+
send({
|
|
544
|
+
type: "POINTER_OVER",
|
|
545
|
+
id
|
|
546
|
+
});
|
|
547
|
+
},
|
|
548
|
+
onPointerLeave() {
|
|
549
|
+
if (triggerState.disabled || registry) return;
|
|
550
|
+
send({
|
|
551
|
+
type: "POINTER_LEAVE",
|
|
552
|
+
id
|
|
553
|
+
});
|
|
554
|
+
},
|
|
555
|
+
onBlur() {
|
|
556
|
+
if (triggerState.disabled) return;
|
|
557
|
+
send({ type: "BLUR" });
|
|
558
|
+
},
|
|
559
|
+
onFocus() {
|
|
560
|
+
if (triggerState.disabled) return;
|
|
561
|
+
send({
|
|
562
|
+
type: "FOCUS",
|
|
563
|
+
id
|
|
564
|
+
});
|
|
565
|
+
},
|
|
566
|
+
onKeyDown(event) {
|
|
567
|
+
if (event.defaultPrevented) return;
|
|
568
|
+
if (triggerState.disabled) return;
|
|
569
|
+
const keyboardResizeBy = prop("keyboardResizeBy");
|
|
570
|
+
let delta = 0;
|
|
571
|
+
if (event.shiftKey) delta = 10;
|
|
572
|
+
else if (keyboardResizeBy != null) delta = keyboardResizeBy;
|
|
573
|
+
else delta = 1;
|
|
574
|
+
const exec = {
|
|
575
|
+
Enter() {
|
|
576
|
+
send({
|
|
577
|
+
type: "ENTER",
|
|
578
|
+
id
|
|
579
|
+
});
|
|
580
|
+
},
|
|
581
|
+
ArrowUp() {
|
|
582
|
+
send({
|
|
583
|
+
type: "KEYBOARD_MOVE",
|
|
584
|
+
id,
|
|
585
|
+
delta: horizontal ? 0 : -delta
|
|
586
|
+
});
|
|
587
|
+
},
|
|
588
|
+
ArrowDown() {
|
|
589
|
+
send({
|
|
590
|
+
type: "KEYBOARD_MOVE",
|
|
591
|
+
id,
|
|
592
|
+
delta: horizontal ? 0 : delta
|
|
593
|
+
});
|
|
594
|
+
},
|
|
595
|
+
ArrowLeft() {
|
|
596
|
+
send({
|
|
597
|
+
type: "KEYBOARD_MOVE",
|
|
598
|
+
id,
|
|
599
|
+
delta: horizontal ? -delta : 0
|
|
600
|
+
});
|
|
601
|
+
},
|
|
602
|
+
ArrowRight() {
|
|
603
|
+
send({
|
|
604
|
+
type: "KEYBOARD_MOVE",
|
|
605
|
+
id,
|
|
606
|
+
delta: horizontal ? delta : 0
|
|
607
|
+
});
|
|
608
|
+
},
|
|
609
|
+
Home() {
|
|
610
|
+
send({
|
|
611
|
+
type: "KEYBOARD_MOVE",
|
|
612
|
+
id,
|
|
613
|
+
delta: -100
|
|
614
|
+
});
|
|
615
|
+
},
|
|
616
|
+
End() {
|
|
617
|
+
send({
|
|
618
|
+
type: "KEYBOARD_MOVE",
|
|
619
|
+
id,
|
|
620
|
+
delta: 100
|
|
621
|
+
});
|
|
622
|
+
},
|
|
623
|
+
F6() {
|
|
624
|
+
send({
|
|
625
|
+
type: "FOCUS.CYCLE",
|
|
626
|
+
id,
|
|
627
|
+
shiftKey: event.shiftKey
|
|
628
|
+
});
|
|
629
|
+
}
|
|
630
|
+
}[getEventKey(event, {
|
|
631
|
+
dir: prop("dir"),
|
|
632
|
+
orientation
|
|
633
|
+
})];
|
|
634
|
+
if (exec) {
|
|
635
|
+
exec(event);
|
|
636
|
+
event.preventDefault();
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
});
|
|
640
|
+
}
|
|
641
|
+
};
|
|
642
|
+
}
|
|
643
|
+
//#endregion
|
|
644
|
+
//#region src/machines/splitter/utils/preserve-fixed-panel-sizes.ts
|
|
645
|
+
function preserveFixedPanelSizes({ panels, prevLayout, prevGroupSize, nextGroupSize }) {
|
|
646
|
+
if (prevGroupSize <= 0 || nextGroupSize <= 0) return prevLayout;
|
|
647
|
+
const nextLayout = [...prevLayout];
|
|
648
|
+
const relativeIndices = [];
|
|
649
|
+
let fixedTotal = 0;
|
|
650
|
+
let relativeTotal = 0;
|
|
651
|
+
panels.forEach((panel, index) => {
|
|
652
|
+
if (panel.resizeBehavior === "preserve-pixel-size") {
|
|
653
|
+
const nextPercentSize = prevLayout[index] / 100 * prevGroupSize / nextGroupSize * 100;
|
|
654
|
+
nextLayout[index] = nextPercentSize;
|
|
655
|
+
fixedTotal += nextPercentSize;
|
|
656
|
+
} else {
|
|
657
|
+
relativeIndices.push(index);
|
|
658
|
+
relativeTotal += prevLayout[index];
|
|
659
|
+
}
|
|
660
|
+
});
|
|
661
|
+
if (relativeIndices.length === 0) {
|
|
662
|
+
const total = nextLayout.reduce((accumulated, current) => accumulated + current, 0);
|
|
663
|
+
if (fuzzyNumbersEqual(total, 100)) return nextLayout;
|
|
664
|
+
if (total <= 0) return prevLayout;
|
|
665
|
+
const scale = 100 / total;
|
|
666
|
+
return nextLayout.map((size) => size * scale);
|
|
667
|
+
}
|
|
668
|
+
const remainingSize = 100 - fixedTotal;
|
|
669
|
+
if (remainingSize <= 0) {
|
|
670
|
+
const total = nextLayout.reduce((accumulated, current) => accumulated + current, 0);
|
|
671
|
+
if (fuzzyNumbersEqual(total, 100)) return nextLayout;
|
|
672
|
+
const scale = 100 / Math.max(total, 1);
|
|
673
|
+
return nextLayout.map((size) => size * scale);
|
|
674
|
+
}
|
|
675
|
+
if (fuzzyNumbersEqual(relativeTotal, 0)) {
|
|
676
|
+
const size = remainingSize / relativeIndices.length;
|
|
677
|
+
relativeIndices.forEach((index) => {
|
|
678
|
+
nextLayout[index] = size;
|
|
679
|
+
});
|
|
680
|
+
return nextLayout;
|
|
681
|
+
}
|
|
682
|
+
relativeIndices.forEach((index) => {
|
|
683
|
+
nextLayout[index] = prevLayout[index] / relativeTotal * remainingSize;
|
|
684
|
+
});
|
|
685
|
+
const total = nextLayout.reduce((accumulated, current) => accumulated + current, 0);
|
|
686
|
+
if (fuzzyNumbersEqual(total, 100)) return nextLayout;
|
|
687
|
+
const scale = 100 / total;
|
|
688
|
+
return nextLayout.map((size) => size * scale);
|
|
689
|
+
}
|
|
690
|
+
//#endregion
|
|
691
|
+
//#region src/machines/splitter/utils/resize-panel.ts
|
|
692
|
+
function resizePanel({ panels, index, size }) {
|
|
693
|
+
const panel = panels[index];
|
|
694
|
+
ensure(panel, () => `Panel data not found for index ${index}`);
|
|
695
|
+
let { collapsedSize = 0, collapsible, maxSize = 100, minSize = 0 } = panel;
|
|
696
|
+
if (fuzzyCompareNumbers(size, minSize) < 0) if (collapsible) {
|
|
697
|
+
const halfwayPoint = (collapsedSize + minSize) / 2;
|
|
698
|
+
if (fuzzyCompareNumbers(size, halfwayPoint) < 0) size = collapsedSize;
|
|
699
|
+
else size = minSize;
|
|
700
|
+
} else size = minSize;
|
|
701
|
+
size = Math.min(maxSize, size);
|
|
702
|
+
size = parseFloat(size.toFixed(10));
|
|
703
|
+
return size;
|
|
704
|
+
}
|
|
705
|
+
//#endregion
|
|
706
|
+
//#region src/machines/splitter/utils/resize-by-delta.ts
|
|
707
|
+
function resizeByDelta(props) {
|
|
708
|
+
let { delta, initialSize, panels, pivotIndices, prevSize, trigger } = props;
|
|
709
|
+
if (fuzzyNumbersEqual(delta, 0)) return initialSize;
|
|
710
|
+
const nextSize = [...initialSize];
|
|
711
|
+
const [firstPivotIndex, secondPivotIndex] = pivotIndices;
|
|
712
|
+
ensure(firstPivotIndex, () => "Invalid first pivot index");
|
|
713
|
+
ensure(secondPivotIndex, () => "Invalid second pivot index");
|
|
714
|
+
let deltaApplied = 0;
|
|
715
|
+
if (trigger === "keyboard") {
|
|
716
|
+
{
|
|
717
|
+
const index = delta < 0 ? secondPivotIndex : firstPivotIndex;
|
|
718
|
+
const panel = panels[index];
|
|
719
|
+
ensure(panel, () => `Panel data not found for index ${index}`);
|
|
720
|
+
const { collapsedSize = 0, collapsible, minSize = 0 } = panel;
|
|
721
|
+
if (collapsible) {
|
|
722
|
+
const prevSize = initialSize[index];
|
|
723
|
+
ensure(prevSize, () => `Previous size not found for panel index ${index}`);
|
|
724
|
+
if (fuzzyNumbersEqual(prevSize, collapsedSize)) {
|
|
725
|
+
const localDelta = minSize - prevSize;
|
|
726
|
+
if (fuzzyCompareNumbers(localDelta, Math.abs(delta)) > 0) delta = delta < 0 ? 0 - localDelta : localDelta;
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
{
|
|
731
|
+
const index = delta < 0 ? firstPivotIndex : secondPivotIndex;
|
|
732
|
+
const panel = panels[index];
|
|
733
|
+
ensure(panel, () => `No panel data found for index ${index}`);
|
|
734
|
+
const { collapsedSize = 0, collapsible, minSize = 0 } = panel;
|
|
735
|
+
if (collapsible) {
|
|
736
|
+
const prevSize = initialSize[index];
|
|
737
|
+
ensure(prevSize, () => `Previous size not found for panel index ${index}`);
|
|
738
|
+
if (fuzzyNumbersEqual(prevSize, minSize)) {
|
|
739
|
+
const localDelta = prevSize - collapsedSize;
|
|
740
|
+
if (fuzzyCompareNumbers(localDelta, Math.abs(delta)) > 0) delta = delta < 0 ? 0 - localDelta : localDelta;
|
|
741
|
+
}
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
{
|
|
746
|
+
const increment = delta < 0 ? 1 : -1;
|
|
747
|
+
let index = delta < 0 ? secondPivotIndex : firstPivotIndex;
|
|
748
|
+
let maxAvailableDelta = 0;
|
|
749
|
+
while (true) {
|
|
750
|
+
const prevSize = initialSize[index];
|
|
751
|
+
ensure(prevSize, () => `Previous size not found for panel index ${index}`);
|
|
752
|
+
const delta = resizePanel({
|
|
753
|
+
panels,
|
|
754
|
+
index,
|
|
755
|
+
size: 100
|
|
756
|
+
}) - prevSize;
|
|
757
|
+
maxAvailableDelta += delta;
|
|
758
|
+
index += increment;
|
|
759
|
+
if (index < 0 || index >= panels.length) break;
|
|
760
|
+
}
|
|
761
|
+
const minAbsDelta = Math.min(Math.abs(delta), Math.abs(maxAvailableDelta));
|
|
762
|
+
delta = delta < 0 ? 0 - minAbsDelta : minAbsDelta;
|
|
763
|
+
}
|
|
764
|
+
{
|
|
765
|
+
let index = delta < 0 ? firstPivotIndex : secondPivotIndex;
|
|
766
|
+
while (index >= 0 && index < panels.length) {
|
|
767
|
+
const deltaRemaining = Math.abs(delta) - Math.abs(deltaApplied);
|
|
768
|
+
const prevSize = initialSize[index];
|
|
769
|
+
ensure(prevSize, () => `Previous size not found for panel index ${index}`);
|
|
770
|
+
const unsafeSize = prevSize - deltaRemaining;
|
|
771
|
+
const safeSize = resizePanel({
|
|
772
|
+
panels,
|
|
773
|
+
index,
|
|
774
|
+
size: unsafeSize
|
|
775
|
+
});
|
|
776
|
+
if (!fuzzyNumbersEqual(prevSize, safeSize)) {
|
|
777
|
+
deltaApplied += prevSize - safeSize;
|
|
778
|
+
nextSize[index] = safeSize;
|
|
779
|
+
if (deltaApplied.toPrecision(3).localeCompare(Math.abs(delta).toPrecision(3), void 0, { numeric: true }) >= 0) break;
|
|
780
|
+
}
|
|
781
|
+
if (delta < 0) index--;
|
|
782
|
+
else index++;
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
if (fuzzySizeEqual(prevSize, nextSize)) return prevSize;
|
|
786
|
+
{
|
|
787
|
+
const pivotIndex = delta < 0 ? secondPivotIndex : firstPivotIndex;
|
|
788
|
+
const prevSize = initialSize[pivotIndex];
|
|
789
|
+
ensure(prevSize, () => `Previous size not found for panel index ${pivotIndex}`);
|
|
790
|
+
const unsafeSize = prevSize + deltaApplied;
|
|
791
|
+
const safeSize = resizePanel({
|
|
792
|
+
panels,
|
|
793
|
+
index: pivotIndex,
|
|
794
|
+
size: unsafeSize
|
|
795
|
+
});
|
|
796
|
+
nextSize[pivotIndex] = safeSize;
|
|
797
|
+
if (!fuzzyNumbersEqual(safeSize, unsafeSize)) {
|
|
798
|
+
let deltaRemaining = unsafeSize - safeSize;
|
|
799
|
+
let index = delta < 0 ? secondPivotIndex : firstPivotIndex;
|
|
800
|
+
while (index >= 0 && index < panels.length) {
|
|
801
|
+
const prevSize = nextSize[index];
|
|
802
|
+
ensure(prevSize, () => `Previous size not found for panel index ${index}`);
|
|
803
|
+
const unsafeSize = prevSize + deltaRemaining;
|
|
804
|
+
const safeSize = resizePanel({
|
|
805
|
+
panels,
|
|
806
|
+
index,
|
|
807
|
+
size: unsafeSize
|
|
808
|
+
});
|
|
809
|
+
if (!fuzzyNumbersEqual(prevSize, safeSize)) {
|
|
810
|
+
deltaRemaining -= safeSize - prevSize;
|
|
811
|
+
nextSize[index] = safeSize;
|
|
812
|
+
}
|
|
813
|
+
if (fuzzyNumbersEqual(deltaRemaining, 0)) break;
|
|
814
|
+
if (delta > 0) index--;
|
|
815
|
+
else index++;
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
if (!fuzzyNumbersEqual(nextSize.reduce((total, size) => size + total, 0), 100)) return prevSize;
|
|
820
|
+
return nextSize;
|
|
821
|
+
}
|
|
822
|
+
//#endregion
|
|
823
|
+
//#region src/machines/splitter/utils/validate-sizes.ts
|
|
824
|
+
function validateSizes({ size: prevSize, panels }) {
|
|
825
|
+
const nextSize = [...prevSize];
|
|
826
|
+
const nextSizeTotalSize = nextSize.reduce((accumulated, current) => accumulated + current, 0);
|
|
827
|
+
if (nextSize.length !== panels.length) throw Error(`Invalid ${panels.length} panel size: ${nextSize.map((size) => `${size}%`).join(", ")}`);
|
|
828
|
+
else if (!fuzzyNumbersEqual(nextSizeTotalSize, 100) && nextSize.length > 0) for (let index = 0; index < panels.length; index++) {
|
|
829
|
+
const unsafeSize = nextSize[index];
|
|
830
|
+
ensure(unsafeSize, () => `No size data found for index ${index}`);
|
|
831
|
+
nextSize[index] = 100 / nextSizeTotalSize * unsafeSize;
|
|
832
|
+
}
|
|
833
|
+
let remainingSize = 0;
|
|
834
|
+
for (let index = 0; index < panels.length; index++) {
|
|
835
|
+
const unsafeSize = nextSize[index];
|
|
836
|
+
ensure(unsafeSize, () => `No size data found for index ${index}`);
|
|
837
|
+
const safeSize = resizePanel({
|
|
838
|
+
panels,
|
|
839
|
+
index,
|
|
840
|
+
size: unsafeSize
|
|
841
|
+
});
|
|
842
|
+
if (unsafeSize != safeSize) {
|
|
843
|
+
remainingSize += unsafeSize - safeSize;
|
|
844
|
+
nextSize[index] = safeSize;
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
if (!fuzzyNumbersEqual(remainingSize, 0)) for (let index = 0; index < panels.length; index++) {
|
|
848
|
+
const prevSize = nextSize[index];
|
|
849
|
+
ensure(prevSize, () => `No size data found for index ${index}`);
|
|
850
|
+
const unsafeSize = prevSize + remainingSize;
|
|
851
|
+
const safeSize = resizePanel({
|
|
852
|
+
panels,
|
|
853
|
+
index,
|
|
854
|
+
size: unsafeSize
|
|
855
|
+
});
|
|
856
|
+
if (prevSize !== safeSize) {
|
|
857
|
+
remainingSize -= safeSize - prevSize;
|
|
858
|
+
nextSize[index] = safeSize;
|
|
859
|
+
if (fuzzyNumbersEqual(remainingSize, 0)) break;
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
return nextSize;
|
|
863
|
+
}
|
|
864
|
+
//#endregion
|
|
865
|
+
//#region src/machines/splitter/machine.ts
|
|
866
|
+
const machine = createMachine({
|
|
867
|
+
props({ props }) {
|
|
868
|
+
ensureProps(props, ["panels"]);
|
|
869
|
+
return {
|
|
870
|
+
orientation: "horizontal",
|
|
871
|
+
defaultSize: [],
|
|
872
|
+
dir: "ltr",
|
|
873
|
+
...props,
|
|
874
|
+
panels: sortPanels(props.panels)
|
|
875
|
+
};
|
|
876
|
+
},
|
|
877
|
+
initialState() {
|
|
878
|
+
return "idle";
|
|
879
|
+
},
|
|
880
|
+
context({ prop, bindable, getContext, getRefs }) {
|
|
881
|
+
return {
|
|
882
|
+
panels: bindable(() => ({ defaultValue: normalizePanels(prop("panels"), null, prop("orientation")) })),
|
|
883
|
+
size: bindable(() => ({
|
|
884
|
+
defaultValue: [],
|
|
885
|
+
isEqual(a, b) {
|
|
886
|
+
return b != null && fuzzySizeEqual(a, b);
|
|
887
|
+
},
|
|
888
|
+
onChange(value) {
|
|
889
|
+
const ctx = getContext();
|
|
890
|
+
const refs = getRefs();
|
|
891
|
+
if (refs.get("suppressOnResize")) return;
|
|
892
|
+
const sizesBeforeCollapse = refs.get("panelSizeBeforeCollapse");
|
|
893
|
+
const expandToSizes = Object.fromEntries(sizesBeforeCollapse.entries());
|
|
894
|
+
const resizeTriggerId = ctx.get("dragState")?.resizeTriggerId ?? null;
|
|
895
|
+
const layout = getPanelLayout(prop("panels"));
|
|
896
|
+
prop("onResize")?.({
|
|
897
|
+
size: value,
|
|
898
|
+
layout,
|
|
899
|
+
resizeTriggerId,
|
|
900
|
+
expandToSizes
|
|
901
|
+
});
|
|
902
|
+
}
|
|
903
|
+
})),
|
|
904
|
+
dragState: bindable(() => ({ defaultValue: null })),
|
|
905
|
+
keyboardState: bindable(() => ({ defaultValue: null }))
|
|
906
|
+
};
|
|
907
|
+
},
|
|
908
|
+
watch({ track, action, prop }) {
|
|
909
|
+
track([
|
|
910
|
+
() => serializePanels(prop("panels")),
|
|
911
|
+
() => JSON.stringify(prop("size") ?? []),
|
|
912
|
+
() => JSON.stringify(prop("defaultSize") ?? [])
|
|
913
|
+
], () => {
|
|
914
|
+
action(["syncSize"]);
|
|
915
|
+
});
|
|
916
|
+
},
|
|
917
|
+
refs() {
|
|
918
|
+
return {
|
|
919
|
+
panelSizeBeforeCollapse: /* @__PURE__ */ new Map(),
|
|
920
|
+
prevDelta: 0,
|
|
921
|
+
panelIdToLastNotifiedSizeMap: /* @__PURE__ */ new Map(),
|
|
922
|
+
initialSize: null,
|
|
923
|
+
prevInitialLayout: null,
|
|
924
|
+
prevGroupSize: null,
|
|
925
|
+
lastRequestedSize: null,
|
|
926
|
+
suppressOnResize: false
|
|
927
|
+
};
|
|
928
|
+
},
|
|
929
|
+
computed: { horizontal({ prop }) {
|
|
930
|
+
return prop("orientation") === "horizontal";
|
|
931
|
+
} },
|
|
932
|
+
on: {
|
|
933
|
+
"SIZE.SET": { actions: ["setSize"] },
|
|
934
|
+
"SIZE.RESET": { actions: ["resetSize"] },
|
|
935
|
+
"PANEL.COLLAPSE": { actions: ["collapsePanel"] },
|
|
936
|
+
"PANEL.EXPAND": { actions: ["expandPanel"] },
|
|
937
|
+
"PANEL.RESIZE": { actions: ["resizePanel"] },
|
|
938
|
+
"ROOT.RESIZE": { actions: ["syncSize"] }
|
|
939
|
+
},
|
|
940
|
+
entry: ["syncSize"],
|
|
941
|
+
exit: ["clearGlobalCursor"],
|
|
942
|
+
effects: ["trackResizeHandles", "trackRootResize"],
|
|
943
|
+
states: {
|
|
944
|
+
idle: {
|
|
945
|
+
entry: ["clearDraggingState", "clearKeyboardState"],
|
|
946
|
+
on: {
|
|
947
|
+
POINTER_OVER: {
|
|
948
|
+
target: "hover:temp",
|
|
949
|
+
actions: ["setKeyboardState"]
|
|
950
|
+
},
|
|
951
|
+
FOCUS: {
|
|
952
|
+
target: "focused",
|
|
953
|
+
actions: ["setKeyboardState"]
|
|
954
|
+
},
|
|
955
|
+
POINTER_DOWN: {
|
|
956
|
+
target: "dragging",
|
|
957
|
+
actions: ["setDraggingState"]
|
|
958
|
+
}
|
|
959
|
+
}
|
|
960
|
+
},
|
|
961
|
+
"hover:temp": {
|
|
962
|
+
effects: ["waitForHoverDelay"],
|
|
963
|
+
on: {
|
|
964
|
+
HOVER_DELAY: { target: "hover" },
|
|
965
|
+
POINTER_DOWN: {
|
|
966
|
+
target: "dragging",
|
|
967
|
+
actions: ["setDraggingState"]
|
|
968
|
+
},
|
|
969
|
+
POINTER_LEAVE: { target: "idle" }
|
|
970
|
+
}
|
|
971
|
+
},
|
|
972
|
+
hover: {
|
|
973
|
+
tags: ["focus"],
|
|
974
|
+
on: {
|
|
975
|
+
POINTER_DOWN: {
|
|
976
|
+
target: "dragging",
|
|
977
|
+
actions: ["setDraggingState"]
|
|
978
|
+
},
|
|
979
|
+
POINTER_LEAVE: { target: "idle" }
|
|
980
|
+
}
|
|
981
|
+
},
|
|
982
|
+
focused: {
|
|
983
|
+
tags: ["focus"],
|
|
984
|
+
on: {
|
|
985
|
+
BLUR: { target: "idle" },
|
|
986
|
+
ENTER: { actions: ["collapseOrExpandPanel"] },
|
|
987
|
+
POINTER_DOWN: {
|
|
988
|
+
target: "dragging",
|
|
989
|
+
actions: ["setDraggingState"]
|
|
990
|
+
},
|
|
991
|
+
KEYBOARD_MOVE: { actions: [
|
|
992
|
+
"invokeOnResizeStart",
|
|
993
|
+
"setKeyboardValue",
|
|
994
|
+
"invokeOnResizeEnd"
|
|
995
|
+
] },
|
|
996
|
+
"FOCUS.CYCLE": { actions: ["focusNextResizeTrigger"] }
|
|
997
|
+
}
|
|
998
|
+
},
|
|
999
|
+
dragging: {
|
|
1000
|
+
tags: ["focus"],
|
|
1001
|
+
effects: ["trackPointerMove"],
|
|
1002
|
+
entry: ["invokeOnResizeStart"],
|
|
1003
|
+
on: {
|
|
1004
|
+
POINTER_MOVE: { actions: ["setPointerValue", "setGlobalCursor"] },
|
|
1005
|
+
POINTER_UP: [{
|
|
1006
|
+
guard: "isResizeTriggerFocused",
|
|
1007
|
+
target: "focused",
|
|
1008
|
+
actions: [
|
|
1009
|
+
"invokeOnResizeEnd",
|
|
1010
|
+
"setKeyboardState",
|
|
1011
|
+
"clearDraggingState",
|
|
1012
|
+
"clearGlobalCursor"
|
|
1013
|
+
]
|
|
1014
|
+
}, {
|
|
1015
|
+
target: "idle",
|
|
1016
|
+
actions: ["invokeOnResizeEnd", "clearGlobalCursor"]
|
|
1017
|
+
}]
|
|
1018
|
+
}
|
|
1019
|
+
}
|
|
1020
|
+
},
|
|
1021
|
+
implementations: {
|
|
1022
|
+
guards: { isResizeTriggerFocused({ context, scope }) {
|
|
1023
|
+
const dragState = context.get("dragState");
|
|
1024
|
+
return scope.isActiveElement(getResizeTriggerEl(scope, dragState?.resizeTriggerId));
|
|
1025
|
+
} },
|
|
1026
|
+
effects: {
|
|
1027
|
+
trackResizeHandles: ({ prop, scope, send }) => {
|
|
1028
|
+
const registry = prop("registry");
|
|
1029
|
+
if (!registry) return;
|
|
1030
|
+
let cleanups = [];
|
|
1031
|
+
const exec = () => {
|
|
1032
|
+
cleanups.forEach((fn) => fn());
|
|
1033
|
+
cleanups = getResizeTriggerEls(scope).map((resizeTriggerEl) => {
|
|
1034
|
+
const id = resizeTriggerEl.dataset.id;
|
|
1035
|
+
if (!id) return;
|
|
1036
|
+
return registry.register({
|
|
1037
|
+
id: getResizeTriggerId(scope, id),
|
|
1038
|
+
element: resizeTriggerEl,
|
|
1039
|
+
orientation: prop("orientation"),
|
|
1040
|
+
onActivate(point) {
|
|
1041
|
+
send({
|
|
1042
|
+
type: "POINTER_DOWN",
|
|
1043
|
+
id,
|
|
1044
|
+
point
|
|
1045
|
+
});
|
|
1046
|
+
},
|
|
1047
|
+
onDeactivate() {
|
|
1048
|
+
send({ type: "POINTER_UP" });
|
|
1049
|
+
}
|
|
1050
|
+
});
|
|
1051
|
+
}).filter(Boolean);
|
|
1052
|
+
};
|
|
1053
|
+
exec();
|
|
1054
|
+
const observeCleanup = observeChildren(getRootEl(scope), { callback: exec });
|
|
1055
|
+
return () => {
|
|
1056
|
+
cleanups.forEach((fn) => fn());
|
|
1057
|
+
observeCleanup?.();
|
|
1058
|
+
};
|
|
1059
|
+
},
|
|
1060
|
+
trackRootResize: ({ scope, send }) => {
|
|
1061
|
+
const rootEl = getRootEl(scope);
|
|
1062
|
+
if (!rootEl) return;
|
|
1063
|
+
return resizeObserverBorderBox.observe(rootEl, () => {
|
|
1064
|
+
send({ type: "ROOT.RESIZE" });
|
|
1065
|
+
});
|
|
1066
|
+
},
|
|
1067
|
+
waitForHoverDelay: ({ send }) => {
|
|
1068
|
+
return setRafTimeout(() => {
|
|
1069
|
+
send({ type: "HOVER_DELAY" });
|
|
1070
|
+
}, 250);
|
|
1071
|
+
},
|
|
1072
|
+
trackPointerMove: ({ scope, send }) => {
|
|
1073
|
+
return trackPointerMove(scope.getDoc(), {
|
|
1074
|
+
onPointerMove(info) {
|
|
1075
|
+
send({
|
|
1076
|
+
type: "POINTER_MOVE",
|
|
1077
|
+
point: info.point
|
|
1078
|
+
});
|
|
1079
|
+
},
|
|
1080
|
+
onPointerUp() {
|
|
1081
|
+
send({ type: "POINTER_UP" });
|
|
1082
|
+
}
|
|
1083
|
+
});
|
|
1084
|
+
}
|
|
1085
|
+
},
|
|
1086
|
+
actions: {
|
|
1087
|
+
setSize(params) {
|
|
1088
|
+
const { context, event, prop, scope } = params;
|
|
1089
|
+
const unsafeSize = event.size;
|
|
1090
|
+
const prevSize = context.get("size");
|
|
1091
|
+
const panels = context.get("panels");
|
|
1092
|
+
const safeSize = validateSizes({
|
|
1093
|
+
size: resolvePanelSizes({
|
|
1094
|
+
sizes: unsafeSize,
|
|
1095
|
+
panels: prop("panels"),
|
|
1096
|
+
rootEl: getRootEl(scope),
|
|
1097
|
+
orientation: prop("orientation")
|
|
1098
|
+
}),
|
|
1099
|
+
panels
|
|
1100
|
+
});
|
|
1101
|
+
if (!isEqual(prevSize, safeSize)) setSize(params, safeSize);
|
|
1102
|
+
},
|
|
1103
|
+
resetSize(params) {
|
|
1104
|
+
const { refs, context, prop, scope } = params;
|
|
1105
|
+
setSize(params, refs.get("initialSize") ?? validateSizes({
|
|
1106
|
+
size: resolvePanelSizes({
|
|
1107
|
+
sizes: prop("size") ?? prop("defaultSize"),
|
|
1108
|
+
panels: prop("panels"),
|
|
1109
|
+
rootEl: getRootEl(scope),
|
|
1110
|
+
orientation: prop("orientation")
|
|
1111
|
+
}),
|
|
1112
|
+
panels: context.get("panels")
|
|
1113
|
+
}));
|
|
1114
|
+
},
|
|
1115
|
+
syncSize(params) {
|
|
1116
|
+
const { context, scope, prop, refs } = params;
|
|
1117
|
+
const rootEl = getRootEl(scope);
|
|
1118
|
+
if (!rootEl) return;
|
|
1119
|
+
const orientation = prop("orientation");
|
|
1120
|
+
const nextGroupSize = getGroupSize(rootEl, orientation);
|
|
1121
|
+
if (nextGroupSize <= 0) return;
|
|
1122
|
+
const panels = normalizePanels(prop("panels"), rootEl, prop("orientation"));
|
|
1123
|
+
context.set("panels", panels);
|
|
1124
|
+
const sizeSpec = prop("size") ?? prop("defaultSize");
|
|
1125
|
+
const initialLayout = `${getPanelLayout(prop("panels"))}:${JSON.stringify(prop("size") ?? [])}:${JSON.stringify(prop("defaultSize") ?? [])}`;
|
|
1126
|
+
const prevGroupSize = refs.get("prevGroupSize");
|
|
1127
|
+
const currentSize = context.get("size");
|
|
1128
|
+
const nextResolvedSize = resolvePanelSizes({
|
|
1129
|
+
sizes: sizeSpec,
|
|
1130
|
+
panels: prop("panels"),
|
|
1131
|
+
rootEl,
|
|
1132
|
+
orientation
|
|
1133
|
+
});
|
|
1134
|
+
const safeSize = validateSizes({
|
|
1135
|
+
size: prevGroupSize != null && prevGroupSize !== nextGroupSize && currentSize.length === panels.length ? preserveFixedPanelSizes({
|
|
1136
|
+
panels,
|
|
1137
|
+
prevLayout: currentSize,
|
|
1138
|
+
prevGroupSize,
|
|
1139
|
+
nextGroupSize
|
|
1140
|
+
}) : nextResolvedSize,
|
|
1141
|
+
panels
|
|
1142
|
+
});
|
|
1143
|
+
if (refs.get("prevInitialLayout") !== initialLayout) {
|
|
1144
|
+
refs.set("initialSize", safeSize);
|
|
1145
|
+
refs.set("prevInitialLayout", initialLayout);
|
|
1146
|
+
}
|
|
1147
|
+
const prevSize = context.get("size");
|
|
1148
|
+
if (!isEqual(prevSize, safeSize)) {
|
|
1149
|
+
refs.set("suppressOnResize", prop("size") != null || prevSize.length === 0);
|
|
1150
|
+
context.set("size", safeSize);
|
|
1151
|
+
refs.set("suppressOnResize", false);
|
|
1152
|
+
}
|
|
1153
|
+
refs.set("prevGroupSize", nextGroupSize);
|
|
1154
|
+
},
|
|
1155
|
+
setDraggingState({ context, event, prop, scope }) {
|
|
1156
|
+
const orientation = prop("orientation");
|
|
1157
|
+
const size = context.get("size");
|
|
1158
|
+
const resizeTriggerId = event.id;
|
|
1159
|
+
const resolvedResizeTriggerId = resolveResizeTriggerId(scope, resizeTriggerId);
|
|
1160
|
+
if (!resolvedResizeTriggerId) return;
|
|
1161
|
+
if (!getRootEl(scope)) return;
|
|
1162
|
+
const handleElement = getResizeTriggerEl(scope, resizeTriggerId);
|
|
1163
|
+
ensure(handleElement, () => `Drag handle element not found for id "${resizeTriggerId}"`);
|
|
1164
|
+
const initialCursorPosition = orientation === "horizontal" ? event.point.x : event.point.y;
|
|
1165
|
+
context.set("dragState", {
|
|
1166
|
+
resizeTriggerId: event.id,
|
|
1167
|
+
resolvedResizeTriggerId,
|
|
1168
|
+
resizeTriggerRect: handleElement.getBoundingClientRect(),
|
|
1169
|
+
initialCursorPosition,
|
|
1170
|
+
initialSize: size
|
|
1171
|
+
});
|
|
1172
|
+
},
|
|
1173
|
+
clearDraggingState({ context }) {
|
|
1174
|
+
context.set("dragState", null);
|
|
1175
|
+
},
|
|
1176
|
+
setKeyboardState({ context, event, scope }) {
|
|
1177
|
+
const id = event.id ?? context.get("dragState")?.resizeTriggerId;
|
|
1178
|
+
if (id == null) return;
|
|
1179
|
+
context.set("keyboardState", {
|
|
1180
|
+
resizeTriggerId: id,
|
|
1181
|
+
resolvedResizeTriggerId: resolveResizeTriggerId(scope, id)
|
|
1182
|
+
});
|
|
1183
|
+
},
|
|
1184
|
+
clearKeyboardState({ context }) {
|
|
1185
|
+
context.set("keyboardState", null);
|
|
1186
|
+
},
|
|
1187
|
+
collapsePanel(params) {
|
|
1188
|
+
const { context, event, refs } = params;
|
|
1189
|
+
const prevSize = context.get("size");
|
|
1190
|
+
const panels = context.get("panels");
|
|
1191
|
+
const panel = panels.find((panel) => panel.id === event.id);
|
|
1192
|
+
ensure(panel, () => `Panel data not found for id "${event.id}"`);
|
|
1193
|
+
if (panel.collapsible) {
|
|
1194
|
+
const { collapsedSize = 0, panelSize, pivotIndices } = panelDataHelper(panels, panel, prevSize);
|
|
1195
|
+
ensure(panelSize != null, () => `Panel size not found for panel "${panel.id}"`);
|
|
1196
|
+
if (!fuzzyNumbersEqual(panelSize, collapsedSize)) {
|
|
1197
|
+
refs.get("panelSizeBeforeCollapse").set(panel.id, panelSize);
|
|
1198
|
+
const nextSize = resizeByDelta({
|
|
1199
|
+
delta: findPanelDataIndex(panels, panel) === panels.length - 1 ? panelSize - collapsedSize : collapsedSize - panelSize,
|
|
1200
|
+
initialSize: prevSize,
|
|
1201
|
+
panels,
|
|
1202
|
+
pivotIndices,
|
|
1203
|
+
prevSize,
|
|
1204
|
+
trigger: "imperative-api"
|
|
1205
|
+
});
|
|
1206
|
+
if (!isEqual(prevSize, nextSize)) setSize(params, nextSize);
|
|
1207
|
+
}
|
|
1208
|
+
}
|
|
1209
|
+
},
|
|
1210
|
+
expandPanel(params) {
|
|
1211
|
+
const { context, event, refs } = params;
|
|
1212
|
+
const panels = context.get("panels");
|
|
1213
|
+
const prevSize = context.get("size");
|
|
1214
|
+
const panel = panels.find((panel) => panel.id === event.id);
|
|
1215
|
+
ensure(panel, () => `Panel data not found for id "${event.id}"`);
|
|
1216
|
+
if (panel.collapsible) {
|
|
1217
|
+
const { collapsedSize = 0, panelSize = 0, minSize: minSizeFromProps = 0, pivotIndices } = panelDataHelper(panels, panel, prevSize);
|
|
1218
|
+
const minSize = event.minSize ?? minSizeFromProps;
|
|
1219
|
+
if (fuzzyNumbersEqual(panelSize, collapsedSize)) {
|
|
1220
|
+
const prevPanelSize = refs.get("panelSizeBeforeCollapse").get(panel.id);
|
|
1221
|
+
const baseSize = prevPanelSize != null && prevPanelSize >= minSize ? prevPanelSize : minSize;
|
|
1222
|
+
const nextSize = resizeByDelta({
|
|
1223
|
+
delta: findPanelDataIndex(panels, panel) === panels.length - 1 ? panelSize - baseSize : baseSize - panelSize,
|
|
1224
|
+
initialSize: prevSize,
|
|
1225
|
+
panels,
|
|
1226
|
+
pivotIndices,
|
|
1227
|
+
prevSize,
|
|
1228
|
+
trigger: "imperative-api"
|
|
1229
|
+
});
|
|
1230
|
+
if (!isEqual(prevSize, nextSize)) setSize(params, nextSize);
|
|
1231
|
+
}
|
|
1232
|
+
}
|
|
1233
|
+
},
|
|
1234
|
+
resizePanel(params) {
|
|
1235
|
+
const { context, event } = params;
|
|
1236
|
+
const prevSize = context.get("size");
|
|
1237
|
+
const panels = context.get("panels");
|
|
1238
|
+
const panel = getPanelById(panels, event.id);
|
|
1239
|
+
const unsafePanelSize = event.size;
|
|
1240
|
+
const { panelSize, pivotIndices } = panelDataHelper(panels, panel, prevSize);
|
|
1241
|
+
ensure(panelSize != null, () => `Panel size not found for panel "${panel.id}"`);
|
|
1242
|
+
const nextSize = resizeByDelta({
|
|
1243
|
+
delta: findPanelDataIndex(panels, panel) === panels.length - 1 ? panelSize - unsafePanelSize : unsafePanelSize - panelSize,
|
|
1244
|
+
initialSize: prevSize,
|
|
1245
|
+
panels,
|
|
1246
|
+
pivotIndices,
|
|
1247
|
+
prevSize,
|
|
1248
|
+
trigger: "imperative-api"
|
|
1249
|
+
});
|
|
1250
|
+
if (!isEqual(prevSize, nextSize)) setSize(params, nextSize);
|
|
1251
|
+
},
|
|
1252
|
+
setPointerValue(params) {
|
|
1253
|
+
const { context, event, prop, scope } = params;
|
|
1254
|
+
const dragState = context.get("dragState");
|
|
1255
|
+
if (!dragState) return;
|
|
1256
|
+
const { resolvedResizeTriggerId, initialSize, initialCursorPosition } = dragState;
|
|
1257
|
+
const panels = context.get("panels");
|
|
1258
|
+
const panelGroupElement = getRootEl(scope);
|
|
1259
|
+
ensure(panelGroupElement, () => `Panel group element not found`);
|
|
1260
|
+
const pivotIndices = resolvedResizeTriggerId.split(":").map((id) => panels.findIndex((panel) => panel.id === id));
|
|
1261
|
+
const horizontal = prop("orientation") === "horizontal";
|
|
1262
|
+
const cursorPosition = horizontal ? event.point.x : event.point.y;
|
|
1263
|
+
const groupRect = panelGroupElement.getBoundingClientRect();
|
|
1264
|
+
const groupSizeInPixels = horizontal ? groupRect.width : groupRect.height;
|
|
1265
|
+
const offsetPercentage = (cursorPosition - initialCursorPosition) / groupSizeInPixels * 100;
|
|
1266
|
+
const prevSize = context.get("size");
|
|
1267
|
+
const nextSize = resizeByDelta({
|
|
1268
|
+
delta: offsetPercentage,
|
|
1269
|
+
initialSize: initialSize ?? prevSize,
|
|
1270
|
+
panels,
|
|
1271
|
+
pivotIndices,
|
|
1272
|
+
prevSize,
|
|
1273
|
+
trigger: "mouse-or-touch"
|
|
1274
|
+
});
|
|
1275
|
+
if (!isEqual(prevSize, nextSize)) setSize(params, nextSize);
|
|
1276
|
+
},
|
|
1277
|
+
setKeyboardValue(params) {
|
|
1278
|
+
const { context, event } = params;
|
|
1279
|
+
const panelDataArray = context.get("panels");
|
|
1280
|
+
const resizeTriggerId = resolveResizeTriggerId(params.scope, event.id);
|
|
1281
|
+
if (!resizeTriggerId) return;
|
|
1282
|
+
const delta = event.delta;
|
|
1283
|
+
const pivotIndices = resizeTriggerId.split(":").map((id) => panelDataArray.findIndex((panelData) => panelData.id === id));
|
|
1284
|
+
const prevSize = context.get("size");
|
|
1285
|
+
const nextSize = resizeByDelta({
|
|
1286
|
+
delta,
|
|
1287
|
+
initialSize: prevSize,
|
|
1288
|
+
panels: panelDataArray,
|
|
1289
|
+
pivotIndices,
|
|
1290
|
+
prevSize,
|
|
1291
|
+
trigger: "keyboard"
|
|
1292
|
+
});
|
|
1293
|
+
if (!isEqual(prevSize, nextSize)) setSize(params, nextSize);
|
|
1294
|
+
},
|
|
1295
|
+
invokeOnResizeEnd({ context, prop, refs }) {
|
|
1296
|
+
queueMicrotask(() => {
|
|
1297
|
+
const dragState = context.get("dragState");
|
|
1298
|
+
prop("onResizeEnd")?.({
|
|
1299
|
+
size: refs.get("lastRequestedSize") ?? context.get("size"),
|
|
1300
|
+
resizeTriggerId: dragState?.resizeTriggerId ?? null
|
|
1301
|
+
});
|
|
1302
|
+
});
|
|
1303
|
+
},
|
|
1304
|
+
invokeOnResizeStart({ prop }) {
|
|
1305
|
+
queueMicrotask(() => {
|
|
1306
|
+
prop("onResizeStart")?.();
|
|
1307
|
+
});
|
|
1308
|
+
},
|
|
1309
|
+
collapseOrExpandPanel(params) {
|
|
1310
|
+
const { context, refs } = params;
|
|
1311
|
+
const panelDataArray = context.get("panels");
|
|
1312
|
+
const sizes = context.get("size");
|
|
1313
|
+
const [idBefore, idAfter] = (context.get("keyboardState")?.resolvedResizeTriggerId)?.split(":") ?? [];
|
|
1314
|
+
const index = panelDataArray.findIndex((panelData) => panelData.id === idBefore);
|
|
1315
|
+
if (index === -1) return;
|
|
1316
|
+
const panelData = panelDataArray[index];
|
|
1317
|
+
ensure(panelData, () => `No panel data found for index ${index}`);
|
|
1318
|
+
const size = sizes[index];
|
|
1319
|
+
const { collapsedSize = 0, collapsible, minSize = 0 } = panelData;
|
|
1320
|
+
if (size != null && collapsible) {
|
|
1321
|
+
const pivotIndices = [idBefore, idAfter].map((id) => panelDataArray.findIndex((panelData) => panelData.id === id));
|
|
1322
|
+
const nextSize = resizeByDelta({
|
|
1323
|
+
delta: fuzzyNumbersEqual(size, collapsedSize) ? minSize - collapsedSize : collapsedSize - size,
|
|
1324
|
+
initialSize: refs.get("initialSize") ?? sizes,
|
|
1325
|
+
panels: panelDataArray,
|
|
1326
|
+
pivotIndices,
|
|
1327
|
+
prevSize: sizes,
|
|
1328
|
+
trigger: "keyboard"
|
|
1329
|
+
});
|
|
1330
|
+
if (!isEqual(sizes, nextSize)) setSize(params, nextSize);
|
|
1331
|
+
}
|
|
1332
|
+
},
|
|
1333
|
+
setGlobalCursor(params) {
|
|
1334
|
+
const { context, scope, prop } = params;
|
|
1335
|
+
if (prop("registry")) return;
|
|
1336
|
+
const dragState = context.get("dragState");
|
|
1337
|
+
if (!dragState) return;
|
|
1338
|
+
const panels = context.get("panels");
|
|
1339
|
+
const horizontal = prop("orientation") === "horizontal";
|
|
1340
|
+
const [idBefore] = dragState.resolvedResizeTriggerId.split(":");
|
|
1341
|
+
const panel = panels[panels.findIndex((panel) => panel.id === idBefore)];
|
|
1342
|
+
const aria = getAriaValue(context.get("size"), panels, dragState.resolvedResizeTriggerId);
|
|
1343
|
+
const cursorState = {
|
|
1344
|
+
isAtMin: fuzzyNumbersEqual(aria.valueNow, aria.valueMin) || fuzzyNumbersEqual(aria.valueNow, panel.collapsedSize),
|
|
1345
|
+
isAtMax: fuzzyNumbersEqual(aria.valueNow, aria.valueMax)
|
|
1346
|
+
};
|
|
1347
|
+
setupGlobalCursor(scope, cursorState, horizontal, prop("nonce"));
|
|
1348
|
+
},
|
|
1349
|
+
clearGlobalCursor({ scope }) {
|
|
1350
|
+
removeGlobalCursor(scope);
|
|
1351
|
+
},
|
|
1352
|
+
focusNextResizeTrigger({ event, scope }) {
|
|
1353
|
+
const resizeTriggers = getResizeTriggerEls(scope);
|
|
1354
|
+
const index = resizeTriggers.findIndex((el) => el.dataset.id === event.id);
|
|
1355
|
+
(event.shiftKey ? prev(resizeTriggers, index) : next(resizeTriggers, index))?.focus();
|
|
1356
|
+
}
|
|
1357
|
+
}
|
|
1358
|
+
}
|
|
1359
|
+
});
|
|
1360
|
+
function setSize(params, sizes) {
|
|
1361
|
+
const { refs, prop, context } = params;
|
|
1362
|
+
const panelsArray = context.get("panels");
|
|
1363
|
+
const onCollapse = prop("onCollapse");
|
|
1364
|
+
const onExpand = prop("onExpand");
|
|
1365
|
+
const onResize = prop("onResize");
|
|
1366
|
+
const onResizeStart = prop("onResizeStart");
|
|
1367
|
+
const onResizeEnd = prop("onResizeEnd");
|
|
1368
|
+
const panelIdToLastNotifiedSizeMap = refs.get("panelIdToLastNotifiedSizeMap");
|
|
1369
|
+
const dragState = context.get("dragState");
|
|
1370
|
+
const keyboardState = context.get("keyboardState");
|
|
1371
|
+
const isProgrammatic = dragState === null && keyboardState === null;
|
|
1372
|
+
refs.set("lastRequestedSize", sizes);
|
|
1373
|
+
if (isProgrammatic && onResizeStart) queueMicrotask(() => {
|
|
1374
|
+
onResizeStart();
|
|
1375
|
+
});
|
|
1376
|
+
if (prop("size") == null) context.set("size", sizes);
|
|
1377
|
+
else if (onResize) {
|
|
1378
|
+
const sizesBeforeCollapse = refs.get("panelSizeBeforeCollapse");
|
|
1379
|
+
const expandToSizes = Object.fromEntries(sizesBeforeCollapse.entries());
|
|
1380
|
+
const resizeTriggerId = dragState?.resizeTriggerId ?? null;
|
|
1381
|
+
onResize({
|
|
1382
|
+
size: sizes,
|
|
1383
|
+
layout: getPanelLayout(prop("panels")),
|
|
1384
|
+
resizeTriggerId,
|
|
1385
|
+
expandToSizes
|
|
1386
|
+
});
|
|
1387
|
+
}
|
|
1388
|
+
sizes.forEach((size, index) => {
|
|
1389
|
+
const panelData = panelsArray[index];
|
|
1390
|
+
ensure(panelData, () => `Panel data not found for index ${index}`);
|
|
1391
|
+
const { collapsedSize = 0, collapsible, id: panelId } = panelData;
|
|
1392
|
+
const lastNotifiedSize = panelIdToLastNotifiedSizeMap.get(panelId);
|
|
1393
|
+
if (lastNotifiedSize == null || size !== lastNotifiedSize) {
|
|
1394
|
+
panelIdToLastNotifiedSizeMap.set(panelId, size);
|
|
1395
|
+
if (collapsible && lastNotifiedSize != null && (onCollapse || onExpand)) {
|
|
1396
|
+
if (fuzzyNumbersEqual(lastNotifiedSize, collapsedSize) && !fuzzyNumbersEqual(size, collapsedSize)) onExpand?.({
|
|
1397
|
+
panelId,
|
|
1398
|
+
size
|
|
1399
|
+
});
|
|
1400
|
+
if (!fuzzyNumbersEqual(lastNotifiedSize, collapsedSize) && fuzzyNumbersEqual(size, collapsedSize)) onCollapse?.({
|
|
1401
|
+
panelId,
|
|
1402
|
+
size
|
|
1403
|
+
});
|
|
1404
|
+
}
|
|
1405
|
+
}
|
|
1406
|
+
});
|
|
1407
|
+
if (isProgrammatic && onResizeEnd) queueMicrotask(() => {
|
|
1408
|
+
onResizeEnd({
|
|
1409
|
+
size: sizes,
|
|
1410
|
+
resizeTriggerId: null
|
|
1411
|
+
});
|
|
1412
|
+
});
|
|
1413
|
+
}
|
|
1414
|
+
//#endregion
|
|
1415
|
+
//#region src/machines/splitter/props.ts
|
|
1416
|
+
const props = createProps()([
|
|
1417
|
+
"dir",
|
|
1418
|
+
"getRootNode",
|
|
1419
|
+
"id",
|
|
1420
|
+
"ids",
|
|
1421
|
+
"onResize",
|
|
1422
|
+
"onResizeStart",
|
|
1423
|
+
"onResizeEnd",
|
|
1424
|
+
"onCollapse",
|
|
1425
|
+
"onExpand",
|
|
1426
|
+
"orientation",
|
|
1427
|
+
"size",
|
|
1428
|
+
"defaultSize",
|
|
1429
|
+
"panels",
|
|
1430
|
+
"keyboardResizeBy",
|
|
1431
|
+
"nonce",
|
|
1432
|
+
"registry"
|
|
1433
|
+
]);
|
|
1434
|
+
const splitProps = createSplitProps(props);
|
|
1435
|
+
const panelProps = createProps()(["id"]);
|
|
1436
|
+
const splitPanelProps = createSplitProps(panelProps);
|
|
1437
|
+
const resizeTriggerProps = createProps()(["disabled", "id"]);
|
|
1438
|
+
const splitResizeTriggerProps = createSplitProps(resizeTriggerProps);
|
|
1439
|
+
//#endregion
|
|
1440
|
+
//#region src/machines/splitter/utils/intersects.ts
|
|
1441
|
+
function intersects(r1, r2, strict = false) {
|
|
1442
|
+
if (strict) return r1.x < r2.x + r2.width && r1.x + r1.width > r2.x && r1.y < r2.y + r2.height && r1.y + r1.height > r2.y;
|
|
1443
|
+
return r1.x <= r2.x + r2.width && r1.x + r1.width >= r2.x && r1.y <= r2.y + r2.height && r1.y + r1.height >= r2.y;
|
|
1444
|
+
}
|
|
1445
|
+
function toRect(r) {
|
|
1446
|
+
return {
|
|
1447
|
+
x: r.x,
|
|
1448
|
+
y: r.y,
|
|
1449
|
+
width: r.width,
|
|
1450
|
+
height: r.height
|
|
1451
|
+
};
|
|
1452
|
+
}
|
|
1453
|
+
//#endregion
|
|
1454
|
+
//#region src/machines/splitter/utils/stacking-order.ts
|
|
1455
|
+
function compareStackingOrder(a, b) {
|
|
1456
|
+
if (a === b) throw new Error("Cannot compare node with itself");
|
|
1457
|
+
const ancestors = {
|
|
1458
|
+
a: getAncestorElements(a),
|
|
1459
|
+
b: getAncestorElements(b)
|
|
1460
|
+
};
|
|
1461
|
+
let commonAncestor = null;
|
|
1462
|
+
while (ancestors.a.at(-1) === ancestors.b.at(-1)) {
|
|
1463
|
+
const currentA = ancestors.a.pop();
|
|
1464
|
+
ancestors.b.pop();
|
|
1465
|
+
commonAncestor = currentA;
|
|
1466
|
+
}
|
|
1467
|
+
ensure(commonAncestor, () => "[stacking-order] Stacking order can only be calculated for elements with a common ancestor");
|
|
1468
|
+
const zIndexes = {
|
|
1469
|
+
a: getZIndex(findStackingContext(ancestors.a)),
|
|
1470
|
+
b: getZIndex(findStackingContext(ancestors.b))
|
|
1471
|
+
};
|
|
1472
|
+
if (zIndexes.a === zIndexes.b) {
|
|
1473
|
+
const children = commonAncestor.childNodes;
|
|
1474
|
+
const furthestAncestors = {
|
|
1475
|
+
a: ancestors.a.at(-1),
|
|
1476
|
+
b: ancestors.b.at(-1)
|
|
1477
|
+
};
|
|
1478
|
+
let i = children.length;
|
|
1479
|
+
while (i--) {
|
|
1480
|
+
const child = children[i];
|
|
1481
|
+
if (child === furthestAncestors.a) return 1;
|
|
1482
|
+
if (child === furthestAncestors.b) return -1;
|
|
1483
|
+
}
|
|
1484
|
+
}
|
|
1485
|
+
return Math.sign(zIndexes.a - zIndexes.b);
|
|
1486
|
+
}
|
|
1487
|
+
const STACKING_PROPS_REGEX = /\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;
|
|
1488
|
+
function isFlexItem(node) {
|
|
1489
|
+
const display = getComputedStyle(getParentElement(node) ?? node).display;
|
|
1490
|
+
return display === "flex" || display === "inline-flex";
|
|
1491
|
+
}
|
|
1492
|
+
function createsStackingContext(node) {
|
|
1493
|
+
const style = getComputedStyle(node);
|
|
1494
|
+
if (style.position === "fixed") return true;
|
|
1495
|
+
if (style.zIndex !== "auto" && (style.position !== "static" || isFlexItem(node))) return true;
|
|
1496
|
+
if (+style.opacity < 1) return true;
|
|
1497
|
+
if (hasProp(style, "transform") && style.transform !== "none") return true;
|
|
1498
|
+
if (hasProp(style, "webkitTransform") && style.webkitTransform !== "none") return true;
|
|
1499
|
+
if (hasProp(style, "mixBlendMode") && style.mixBlendMode !== "normal") return true;
|
|
1500
|
+
if (hasProp(style, "filter") && style.filter !== "none") return true;
|
|
1501
|
+
if (hasProp(style, "webkitFilter") && style.webkitFilter !== "none") return true;
|
|
1502
|
+
if (hasProp(style, "isolation") && style.isolation === "isolate") return true;
|
|
1503
|
+
if (STACKING_PROPS_REGEX.test(style.willChange)) return true;
|
|
1504
|
+
if (style.webkitOverflowScrolling === "touch") return true;
|
|
1505
|
+
return false;
|
|
1506
|
+
}
|
|
1507
|
+
function findStackingContext(nodes) {
|
|
1508
|
+
let i = nodes.length;
|
|
1509
|
+
while (i--) {
|
|
1510
|
+
const node = nodes[i];
|
|
1511
|
+
ensure(node, () => "[stacking-order] missing node in findStackingContext");
|
|
1512
|
+
if (createsStackingContext(node)) return node;
|
|
1513
|
+
}
|
|
1514
|
+
return null;
|
|
1515
|
+
}
|
|
1516
|
+
const getZIndex = (node) => {
|
|
1517
|
+
return node && Number(getComputedStyle(node).zIndex) || 0;
|
|
1518
|
+
};
|
|
1519
|
+
//#endregion
|
|
1520
|
+
//#region src/machines/splitter/utils/registry.ts
|
|
1521
|
+
var SplitterRegistry = class {
|
|
1522
|
+
handles = /* @__PURE__ */ new Map();
|
|
1523
|
+
state = {
|
|
1524
|
+
activeHandleIds: /* @__PURE__ */ new Set(),
|
|
1525
|
+
isPointerDown: false
|
|
1526
|
+
};
|
|
1527
|
+
listenerAttached = false;
|
|
1528
|
+
options;
|
|
1529
|
+
constructor(options = {}) {
|
|
1530
|
+
this.options = {
|
|
1531
|
+
nonce: options.nonce ?? "",
|
|
1532
|
+
hitAreaMargins: {
|
|
1533
|
+
coarse: options.hitAreaMargins?.coarse ?? 15,
|
|
1534
|
+
fine: options.hitAreaMargins?.fine ?? 5
|
|
1535
|
+
}
|
|
1536
|
+
};
|
|
1537
|
+
}
|
|
1538
|
+
register(data) {
|
|
1539
|
+
this.handles.set(data.id, data);
|
|
1540
|
+
this.attachGlobalListeners();
|
|
1541
|
+
return () => {
|
|
1542
|
+
this.handles.delete(data.id);
|
|
1543
|
+
this.state.activeHandleIds.delete(data.id);
|
|
1544
|
+
if (this.handles.size === 0) this.detachGlobalListeners();
|
|
1545
|
+
};
|
|
1546
|
+
}
|
|
1547
|
+
attachGlobalListeners() {
|
|
1548
|
+
if (this.listenerAttached) return;
|
|
1549
|
+
this.doc.addEventListener("pointermove", this.handlePointerMove, true);
|
|
1550
|
+
this.doc.addEventListener("pointerdown", this.handlePointerDown, true);
|
|
1551
|
+
this.doc.addEventListener("pointerup", this.handlePointerUp, true);
|
|
1552
|
+
this.listenerAttached = true;
|
|
1553
|
+
}
|
|
1554
|
+
detachGlobalListeners() {
|
|
1555
|
+
if (!this.listenerAttached) return;
|
|
1556
|
+
this.doc.removeEventListener("pointermove", this.handlePointerMove, true);
|
|
1557
|
+
this.doc.removeEventListener("pointerdown", this.handlePointerDown, true);
|
|
1558
|
+
this.doc.removeEventListener("pointerup", this.handlePointerUp, true);
|
|
1559
|
+
this.listenerAttached = false;
|
|
1560
|
+
}
|
|
1561
|
+
getPointerType(event) {
|
|
1562
|
+
return event.pointerType === "touch" || event.pointerType === "pen" ? "coarse" : "fine";
|
|
1563
|
+
}
|
|
1564
|
+
get doc() {
|
|
1565
|
+
const firstHandle = this.handles.values().next().value;
|
|
1566
|
+
return getDocument(firstHandle?.element);
|
|
1567
|
+
}
|
|
1568
|
+
/**
|
|
1569
|
+
* Fast hit-test: only checks pointer proximity to handles (no stacking order).
|
|
1570
|
+
* Used for pointermove cursor feedback.
|
|
1571
|
+
*/
|
|
1572
|
+
findHitHandles(x, y, pointerType) {
|
|
1573
|
+
const intersecting = [];
|
|
1574
|
+
const margin = this.options.hitAreaMargins[pointerType];
|
|
1575
|
+
this.handles.forEach((handle) => {
|
|
1576
|
+
const rect = handle.element.getBoundingClientRect();
|
|
1577
|
+
if (x >= rect.left - margin && x <= rect.right + margin && y >= rect.top - margin && y <= rect.bottom + margin) intersecting.push(handle);
|
|
1578
|
+
});
|
|
1579
|
+
return intersecting;
|
|
1580
|
+
}
|
|
1581
|
+
/**
|
|
1582
|
+
* Full intersection check: hit-test + stacking order verification.
|
|
1583
|
+
* Used for pointerdown activation where correctness matters.
|
|
1584
|
+
*/
|
|
1585
|
+
findIntersectingHandles(x, y, pointerType, eventTarget) {
|
|
1586
|
+
const hits = this.findHitHandles(x, y, pointerType);
|
|
1587
|
+
const targetElement = isElement(eventTarget) ? eventTarget : null;
|
|
1588
|
+
if (!targetElement || !contains(this.doc, targetElement)) return hits;
|
|
1589
|
+
return hits.filter((handle) => {
|
|
1590
|
+
const dragHandleElement = handle.element;
|
|
1591
|
+
if (targetElement === dragHandleElement || contains(dragHandleElement, targetElement) || contains(targetElement, dragHandleElement)) return true;
|
|
1592
|
+
try {
|
|
1593
|
+
if (compareStackingOrder(targetElement, dragHandleElement) > 0) {
|
|
1594
|
+
const dragHandleRect = dragHandleElement.getBoundingClientRect();
|
|
1595
|
+
let currentElement = targetElement;
|
|
1596
|
+
while (currentElement) {
|
|
1597
|
+
if (currentElement.contains(dragHandleElement)) break;
|
|
1598
|
+
if (intersects(toRect(currentElement.getBoundingClientRect()), toRect(dragHandleRect), true)) return false;
|
|
1599
|
+
currentElement = getParentElement(currentElement);
|
|
1600
|
+
}
|
|
1601
|
+
}
|
|
1602
|
+
} catch {}
|
|
1603
|
+
return true;
|
|
1604
|
+
});
|
|
1605
|
+
}
|
|
1606
|
+
handlePointerMove = (event) => {
|
|
1607
|
+
if (this.state.isPointerDown) return;
|
|
1608
|
+
const pointerType = this.getPointerType(event);
|
|
1609
|
+
const intersecting = this.findHitHandles(event.clientX, event.clientY, pointerType);
|
|
1610
|
+
const newActiveIds = new Set(intersecting.map((h) => h.id));
|
|
1611
|
+
if (newActiveIds.size !== this.state.activeHandleIds.size || [...newActiveIds].some((id) => !this.state.activeHandleIds.has(id))) {
|
|
1612
|
+
this.state.activeHandleIds = newActiveIds;
|
|
1613
|
+
this.updateCursor(intersecting);
|
|
1614
|
+
}
|
|
1615
|
+
};
|
|
1616
|
+
handlePointerDown = (event) => {
|
|
1617
|
+
const pointerType = this.getPointerType(event);
|
|
1618
|
+
const intersecting = this.findIntersectingHandles(event.clientX, event.clientY, pointerType, event.target);
|
|
1619
|
+
if (intersecting.length > 0) {
|
|
1620
|
+
this.state.isPointerDown = true;
|
|
1621
|
+
this.state.activeHandleIds = new Set(intersecting.map((h) => h.id));
|
|
1622
|
+
const point = {
|
|
1623
|
+
x: event.clientX,
|
|
1624
|
+
y: event.clientY
|
|
1625
|
+
};
|
|
1626
|
+
intersecting.forEach((handle) => {
|
|
1627
|
+
handle.onActivate(point);
|
|
1628
|
+
});
|
|
1629
|
+
this.updateCursor(intersecting);
|
|
1630
|
+
}
|
|
1631
|
+
};
|
|
1632
|
+
handlePointerUp = (_event) => {
|
|
1633
|
+
if (this.state.isPointerDown) {
|
|
1634
|
+
this.state.isPointerDown = false;
|
|
1635
|
+
this.handles.forEach((handle) => {
|
|
1636
|
+
if (this.state.activeHandleIds.has(handle.id)) handle.onDeactivate();
|
|
1637
|
+
});
|
|
1638
|
+
this.state.activeHandleIds.clear();
|
|
1639
|
+
this.clearGlobalCursor();
|
|
1640
|
+
}
|
|
1641
|
+
};
|
|
1642
|
+
updateCursor(intersecting) {
|
|
1643
|
+
if (intersecting.length === 0) {
|
|
1644
|
+
this.clearGlobalCursor();
|
|
1645
|
+
return;
|
|
1646
|
+
}
|
|
1647
|
+
const hasHorizontal = intersecting.some((h) => h.orientation === "horizontal");
|
|
1648
|
+
const hasVertical = intersecting.some((h) => h.orientation === "vertical");
|
|
1649
|
+
let cursor = "default";
|
|
1650
|
+
if (hasHorizontal && hasVertical) cursor = "move";
|
|
1651
|
+
else if (hasHorizontal) cursor = "ew-resize";
|
|
1652
|
+
else if (hasVertical) cursor = "ns-resize";
|
|
1653
|
+
this.setGlobalCursor(cursor);
|
|
1654
|
+
}
|
|
1655
|
+
globalCursorId = "splitter-registry-cursor";
|
|
1656
|
+
setGlobalCursor(cursor) {
|
|
1657
|
+
const doc = this.doc;
|
|
1658
|
+
let styleEl = doc.getElementById(this.globalCursorId);
|
|
1659
|
+
const textContent = `* { cursor: ${cursor} !important; }`;
|
|
1660
|
+
if (styleEl) styleEl.textContent = textContent;
|
|
1661
|
+
else {
|
|
1662
|
+
styleEl = doc.createElement("style");
|
|
1663
|
+
styleEl.id = this.globalCursorId;
|
|
1664
|
+
styleEl.textContent = textContent;
|
|
1665
|
+
if (this.options.nonce) styleEl.nonce = this.options.nonce;
|
|
1666
|
+
doc.head.appendChild(styleEl);
|
|
1667
|
+
}
|
|
1668
|
+
}
|
|
1669
|
+
clearGlobalCursor() {
|
|
1670
|
+
this.doc.getElementById(this.globalCursorId)?.remove();
|
|
1671
|
+
}
|
|
1672
|
+
};
|
|
1673
|
+
const registry = (opts = {}) => new SplitterRegistry(opts);
|
|
1674
|
+
//#endregion
|
|
1675
|
+
export { anatomy, connect, getPanelLayout as layout, machine, panelProps, props, registry, resizeTriggerProps, splitPanelProps, splitProps, splitResizeTriggerProps };
|