panelui-native 0.71.0 → 0.75.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (306) hide show
  1. package/README.md +5 -2
  2. package/lib/module/components/accordion/index.js +10 -4
  3. package/lib/module/components/accordion/index.js.map +1 -1
  4. package/lib/module/components/area-chart/index.js +1 -0
  5. package/lib/module/components/area-chart/index.js.map +1 -1
  6. package/lib/module/components/avatar/avatar-group.js +64 -0
  7. package/lib/module/components/avatar/avatar-group.js.map +1 -0
  8. package/lib/module/components/avatar/index.js +84 -2
  9. package/lib/module/components/avatar/index.js.map +1 -1
  10. package/lib/module/components/breadcrumb/index.js +2 -1
  11. package/lib/module/components/breadcrumb/index.js.map +1 -1
  12. package/lib/module/components/button/index.js +7 -5
  13. package/lib/module/components/button/index.js.map +1 -1
  14. package/lib/module/components/carousel/index.js +1 -1
  15. package/lib/module/components/carousel/index.js.map +1 -1
  16. package/lib/module/components/chip/index.js +2 -2
  17. package/lib/module/components/chip/index.js.map +1 -1
  18. package/lib/module/components/code-block/index.js.map +1 -1
  19. package/lib/module/components/collapsible/index.js +5 -1
  20. package/lib/module/components/collapsible/index.js.map +1 -1
  21. package/lib/module/components/color-picker/color-picker-accessibility.js +12 -0
  22. package/lib/module/components/color-picker/color-picker-accessibility.js.map +1 -0
  23. package/lib/module/components/color-picker/index.js +9 -5
  24. package/lib/module/components/color-picker/index.js.map +1 -1
  25. package/lib/module/components/date-time-picker/index.js +11 -3
  26. package/lib/module/components/date-time-picker/index.js.map +1 -1
  27. package/lib/module/components/drawer/index.js +58 -13
  28. package/lib/module/components/drawer/index.js.map +1 -1
  29. package/lib/module/components/fab/index.js +7 -6
  30. package/lib/module/components/fab/index.js.map +1 -1
  31. package/lib/module/components/flow/index.js +1 -1
  32. package/lib/module/components/flow/index.js.map +1 -1
  33. package/lib/module/components/frame/index.js +2 -2
  34. package/lib/module/components/frame/index.js.map +1 -1
  35. package/lib/module/components/grid-item/index.js +2 -2
  36. package/lib/module/components/grid-item/index.js.map +1 -1
  37. package/lib/module/components/heatmap-chart/index.js +1 -0
  38. package/lib/module/components/heatmap-chart/index.js.map +1 -1
  39. package/lib/module/components/hex-chart/index.js +1 -0
  40. package/lib/module/components/hex-chart/index.js.map +1 -1
  41. package/lib/module/components/input/index.js +7 -4
  42. package/lib/module/components/input/index.js.map +1 -1
  43. package/lib/module/components/input/input-content-padding.js +6 -0
  44. package/lib/module/components/input/input-content-padding.js.map +1 -0
  45. package/lib/module/components/input-group/index.js +21 -11
  46. package/lib/module/components/input-group/index.js.map +1 -1
  47. package/lib/module/components/input-group/input-group-measurements.js +60 -0
  48. package/lib/module/components/input-group/input-group-measurements.js.map +1 -0
  49. package/lib/module/components/item/index.js +2 -2
  50. package/lib/module/components/item/index.js.map +1 -1
  51. package/lib/module/components/line-chart/index.js +1 -0
  52. package/lib/module/components/line-chart/index.js.map +1 -1
  53. package/lib/module/components/marker/index.js +2 -2
  54. package/lib/module/components/marker/index.js.map +1 -1
  55. package/lib/module/components/marquee/index.js +9 -12
  56. package/lib/module/components/marquee/index.js.map +1 -1
  57. package/lib/module/components/marquee/marquee-math.js +39 -0
  58. package/lib/module/components/marquee/marquee-math.js.map +1 -0
  59. package/lib/module/components/menu/index.js +11 -3
  60. package/lib/module/components/menu/index.js.map +1 -1
  61. package/lib/module/components/otp-input/index.js +3 -1
  62. package/lib/module/components/otp-input/index.js.map +1 -1
  63. package/lib/module/components/otp-input/otp-input-state.js +7 -0
  64. package/lib/module/components/otp-input/otp-input-state.js.map +1 -0
  65. package/lib/module/components/pagination/index.js +27 -11
  66. package/lib/module/components/pagination/index.js.map +1 -1
  67. package/lib/module/components/panelside/index.js +7 -2
  68. package/lib/module/components/panelside/index.js.map +1 -1
  69. package/lib/module/components/planner/index.js +46 -11
  70. package/lib/module/components/planner/index.js.map +1 -1
  71. package/lib/module/components/planner/planner-today.js +8 -0
  72. package/lib/module/components/planner/planner-today.js.map +1 -0
  73. package/lib/module/components/plot/index.js +113 -53
  74. package/lib/module/components/plot/index.js.map +1 -1
  75. package/lib/module/components/plot/plot-series-registry.js +32 -0
  76. package/lib/module/components/plot/plot-series-registry.js.map +1 -0
  77. package/lib/module/components/post/index.js +4 -4
  78. package/lib/module/components/post/index.js.map +1 -1
  79. package/lib/module/components/radio-group/index.js +2 -1
  80. package/lib/module/components/radio-group/index.js.map +1 -1
  81. package/lib/module/components/radio-group/radio-group-value.js +8 -0
  82. package/lib/module/components/radio-group/radio-group-value.js.map +1 -0
  83. package/lib/module/components/rating/index.js +7 -4
  84. package/lib/module/components/rating/index.js.map +1 -1
  85. package/lib/module/components/rating/rating-inputs.js +15 -0
  86. package/lib/module/components/rating/rating-inputs.js.map +1 -0
  87. package/lib/module/components/search-bar/index.js +331 -0
  88. package/lib/module/components/search-bar/index.js.map +1 -0
  89. package/lib/module/components/search-bar/search-bar-debounce.js +23 -0
  90. package/lib/module/components/search-bar/search-bar-debounce.js.map +1 -0
  91. package/lib/module/components/select/index.js +9 -1
  92. package/lib/module/components/select/index.js.map +1 -1
  93. package/lib/module/components/select/native-select-contract.js +11 -0
  94. package/lib/module/components/select/native-select-contract.js.map +1 -0
  95. package/lib/module/components/split-view/index.js +439 -0
  96. package/lib/module/components/split-view/index.js.map +1 -0
  97. package/lib/module/components/split-view/split-view-math.js +132 -0
  98. package/lib/module/components/split-view/split-view-math.js.map +1 -0
  99. package/lib/module/components/splitter/index.js +433 -0
  100. package/lib/module/components/splitter/index.js.map +1 -0
  101. package/lib/module/components/splitter/splitter-math.js +206 -0
  102. package/lib/module/components/splitter/splitter-math.js.map +1 -0
  103. package/lib/module/components/steps/index.js +16 -5
  104. package/lib/module/components/steps/index.js.map +1 -1
  105. package/lib/module/components/steps/steps-trigger.js +6 -0
  106. package/lib/module/components/steps/steps-trigger.js.map +1 -0
  107. package/lib/module/components/table/index.js +3 -4
  108. package/lib/module/components/table/index.js.map +1 -1
  109. package/lib/module/components/tag-input/index.js +15 -10
  110. package/lib/module/components/tag-input/index.js.map +1 -1
  111. package/lib/module/components/tag-input/tag-input-state.js +14 -0
  112. package/lib/module/components/tag-input/tag-input-state.js.map +1 -0
  113. package/lib/module/components/textarea/index.js +9 -4
  114. package/lib/module/components/textarea/index.js.map +1 -1
  115. package/lib/module/components/textarea/textarea-disabled.js +6 -0
  116. package/lib/module/components/textarea/textarea-disabled.js.map +1 -0
  117. package/lib/module/components/timeline/index.js +352 -47
  118. package/lib/module/components/timeline/index.js.map +1 -1
  119. package/lib/module/components/timeline/timeline-geometry.js +11 -0
  120. package/lib/module/components/timeline/timeline-geometry.js.map +1 -0
  121. package/lib/module/components/toast/index.js +18 -1
  122. package/lib/module/components/toast/index.js.map +1 -1
  123. package/lib/module/components/toast/toast-store.js +36 -4
  124. package/lib/module/components/toast/toast-store.js.map +1 -1
  125. package/lib/module/components/toggle-button/index.js +1 -1
  126. package/lib/module/components/toggle-button/index.js.map +1 -1
  127. package/lib/module/components/tour/index.js +4 -2
  128. package/lib/module/components/tour/index.js.map +1 -1
  129. package/lib/module/components/tour/tour-card-measurement.js +24 -0
  130. package/lib/module/components/tour/tour-card-measurement.js.map +1 -0
  131. package/lib/module/components/tree/index.js +13 -8
  132. package/lib/module/components/tree/index.js.map +1 -1
  133. package/lib/module/hooks/use-keyboard-avoidance.js.map +1 -1
  134. package/lib/module/index.js +3 -0
  135. package/lib/module/index.js.map +1 -1
  136. package/lib/module/utils/chart.js +50 -7
  137. package/lib/module/utils/chart.js.map +1 -1
  138. package/lib/typescript/src/components/accordion/index.d.ts +2 -2
  139. package/lib/typescript/src/components/accordion/index.d.ts.map +1 -1
  140. package/lib/typescript/src/components/area-chart/index.d.ts.map +1 -1
  141. package/lib/typescript/src/components/avatar/avatar-group.d.ts +46 -0
  142. package/lib/typescript/src/components/avatar/avatar-group.d.ts.map +1 -0
  143. package/lib/typescript/src/components/avatar/index.d.ts +23 -1
  144. package/lib/typescript/src/components/avatar/index.d.ts.map +1 -1
  145. package/lib/typescript/src/components/breadcrumb/index.d.ts.map +1 -1
  146. package/lib/typescript/src/components/button/index.d.ts.map +1 -1
  147. package/lib/typescript/src/components/code-block/index.d.ts +3 -3
  148. package/lib/typescript/src/components/code-block/index.d.ts.map +1 -1
  149. package/lib/typescript/src/components/collapsible/index.d.ts +2 -2
  150. package/lib/typescript/src/components/collapsible/index.d.ts.map +1 -1
  151. package/lib/typescript/src/components/color-picker/color-picker-accessibility.d.ts +8 -0
  152. package/lib/typescript/src/components/color-picker/color-picker-accessibility.d.ts.map +1 -0
  153. package/lib/typescript/src/components/color-picker/index.d.ts.map +1 -1
  154. package/lib/typescript/src/components/date-time-picker/index.d.ts.map +1 -1
  155. package/lib/typescript/src/components/drawer/index.d.ts.map +1 -1
  156. package/lib/typescript/src/components/fab/index.d.ts +4 -2
  157. package/lib/typescript/src/components/fab/index.d.ts.map +1 -1
  158. package/lib/typescript/src/components/heatmap-chart/index.d.ts.map +1 -1
  159. package/lib/typescript/src/components/hex-chart/index.d.ts.map +1 -1
  160. package/lib/typescript/src/components/input/index.d.ts.map +1 -1
  161. package/lib/typescript/src/components/input/input-content-padding.d.ts +2 -0
  162. package/lib/typescript/src/components/input/input-content-padding.d.ts.map +1 -0
  163. package/lib/typescript/src/components/input-group/index.d.ts.map +1 -1
  164. package/lib/typescript/src/components/input-group/input-group-measurements.d.ts +16 -0
  165. package/lib/typescript/src/components/input-group/input-group-measurements.d.ts.map +1 -0
  166. package/lib/typescript/src/components/line-chart/index.d.ts.map +1 -1
  167. package/lib/typescript/src/components/marquee/index.d.ts +1 -1
  168. package/lib/typescript/src/components/marquee/index.d.ts.map +1 -1
  169. package/lib/typescript/src/components/marquee/marquee-math.d.ts +21 -0
  170. package/lib/typescript/src/components/marquee/marquee-math.d.ts.map +1 -0
  171. package/lib/typescript/src/components/menu/index.d.ts +1 -1
  172. package/lib/typescript/src/components/menu/index.d.ts.map +1 -1
  173. package/lib/typescript/src/components/otp-input/index.d.ts.map +1 -1
  174. package/lib/typescript/src/components/otp-input/otp-input-state.d.ts +3 -0
  175. package/lib/typescript/src/components/otp-input/otp-input-state.d.ts.map +1 -0
  176. package/lib/typescript/src/components/pagination/index.d.ts.map +1 -1
  177. package/lib/typescript/src/components/panelside/index.d.ts +1 -1
  178. package/lib/typescript/src/components/panelside/index.d.ts.map +1 -1
  179. package/lib/typescript/src/components/plan/index.d.ts +2 -2
  180. package/lib/typescript/src/components/planner/index.d.ts.map +1 -1
  181. package/lib/typescript/src/components/planner/planner-today.d.ts +2 -0
  182. package/lib/typescript/src/components/planner/planner-today.d.ts.map +1 -0
  183. package/lib/typescript/src/components/plot/index.d.ts +60 -6
  184. package/lib/typescript/src/components/plot/index.d.ts.map +1 -1
  185. package/lib/typescript/src/components/plot/plot-series-registry.d.ts +8 -0
  186. package/lib/typescript/src/components/plot/plot-series-registry.d.ts.map +1 -0
  187. package/lib/typescript/src/components/radio-group/index.d.ts.map +1 -1
  188. package/lib/typescript/src/components/radio-group/radio-group-value.d.ts +2 -0
  189. package/lib/typescript/src/components/radio-group/radio-group-value.d.ts.map +1 -0
  190. package/lib/typescript/src/components/rating/index.d.ts.map +1 -1
  191. package/lib/typescript/src/components/rating/rating-inputs.d.ts +4 -0
  192. package/lib/typescript/src/components/rating/rating-inputs.d.ts.map +1 -0
  193. package/lib/typescript/src/components/search-bar/index.d.ts +216 -0
  194. package/lib/typescript/src/components/search-bar/index.d.ts.map +1 -0
  195. package/lib/typescript/src/components/search-bar/search-bar-debounce.d.ts +7 -0
  196. package/lib/typescript/src/components/search-bar/search-bar-debounce.d.ts.map +1 -0
  197. package/lib/typescript/src/components/select/index.d.ts.map +1 -1
  198. package/lib/typescript/src/components/select/native-select-contract.d.ts +11 -0
  199. package/lib/typescript/src/components/select/native-select-contract.d.ts.map +1 -0
  200. package/lib/typescript/src/components/split-view/index.d.ts +159 -0
  201. package/lib/typescript/src/components/split-view/index.d.ts.map +1 -0
  202. package/lib/typescript/src/components/split-view/split-view-math.d.ts +54 -0
  203. package/lib/typescript/src/components/split-view/split-view-math.d.ts.map +1 -0
  204. package/lib/typescript/src/components/splitter/index.d.ts +78 -0
  205. package/lib/typescript/src/components/splitter/index.d.ts.map +1 -0
  206. package/lib/typescript/src/components/splitter/splitter-math.d.ts +67 -0
  207. package/lib/typescript/src/components/splitter/splitter-math.d.ts.map +1 -0
  208. package/lib/typescript/src/components/steps/index.d.ts +2 -2
  209. package/lib/typescript/src/components/steps/index.d.ts.map +1 -1
  210. package/lib/typescript/src/components/steps/steps-trigger.d.ts +2 -0
  211. package/lib/typescript/src/components/steps/steps-trigger.d.ts.map +1 -0
  212. package/lib/typescript/src/components/tag-input/index.d.ts.map +1 -1
  213. package/lib/typescript/src/components/tag-input/tag-input-state.d.ts +12 -0
  214. package/lib/typescript/src/components/tag-input/tag-input-state.d.ts.map +1 -0
  215. package/lib/typescript/src/components/textarea/index.d.ts.map +1 -1
  216. package/lib/typescript/src/components/textarea/textarea-disabled.d.ts +2 -0
  217. package/lib/typescript/src/components/textarea/textarea-disabled.d.ts.map +1 -0
  218. package/lib/typescript/src/components/timeline/index.d.ts +36 -2
  219. package/lib/typescript/src/components/timeline/index.d.ts.map +1 -1
  220. package/lib/typescript/src/components/timeline/timeline-geometry.d.ts +4 -0
  221. package/lib/typescript/src/components/timeline/timeline-geometry.d.ts.map +1 -0
  222. package/lib/typescript/src/components/toast/index.d.ts.map +1 -1
  223. package/lib/typescript/src/components/toast/toast-store.d.ts +7 -2
  224. package/lib/typescript/src/components/toast/toast-store.d.ts.map +1 -1
  225. package/lib/typescript/src/components/tour/index.d.ts.map +1 -1
  226. package/lib/typescript/src/components/tour/tour-card-measurement.d.ts +14 -0
  227. package/lib/typescript/src/components/tour/tour-card-measurement.d.ts.map +1 -0
  228. package/lib/typescript/src/components/tree/index.d.ts +3 -4
  229. package/lib/typescript/src/components/tree/index.d.ts.map +1 -1
  230. package/lib/typescript/src/hooks/use-keyboard-avoidance.d.ts +2 -2
  231. package/lib/typescript/src/hooks/use-keyboard-avoidance.d.ts.map +1 -1
  232. package/lib/typescript/src/index.d.ts +5 -2
  233. package/lib/typescript/src/index.d.ts.map +1 -1
  234. package/lib/typescript/src/utils/chart.d.ts +28 -3
  235. package/lib/typescript/src/utils/chart.d.ts.map +1 -1
  236. package/package.json +1 -1
  237. package/src/components/accordion/index.tsx +17 -7
  238. package/src/components/area-chart/index.tsx +8 -0
  239. package/src/components/avatar/avatar-group.ts +78 -0
  240. package/src/components/avatar/index.tsx +121 -1
  241. package/src/components/breadcrumb/index.tsx +2 -1
  242. package/src/components/button/index.tsx +3 -2
  243. package/src/components/carousel/index.tsx +1 -1
  244. package/src/components/chip/index.tsx +2 -2
  245. package/src/components/code-block/index.tsx +3 -3
  246. package/src/components/collapsible/index.tsx +13 -4
  247. package/src/components/color-picker/color-picker-accessibility.ts +12 -0
  248. package/src/components/color-picker/index.tsx +30 -10
  249. package/src/components/date-time-picker/index.tsx +11 -3
  250. package/src/components/drawer/index.tsx +42 -14
  251. package/src/components/fab/index.tsx +21 -11
  252. package/src/components/flow/index.tsx +1 -1
  253. package/src/components/frame/index.tsx +2 -2
  254. package/src/components/grid-item/index.tsx +2 -2
  255. package/src/components/heatmap-chart/index.tsx +7 -1
  256. package/src/components/hex-chart/index.tsx +7 -1
  257. package/src/components/input/index.tsx +6 -2
  258. package/src/components/input/input-content-padding.ts +3 -0
  259. package/src/components/input-group/index.tsx +45 -12
  260. package/src/components/input-group/input-group-measurements.ts +98 -0
  261. package/src/components/item/index.tsx +2 -2
  262. package/src/components/line-chart/index.tsx +9 -0
  263. package/src/components/marker/index.tsx +2 -2
  264. package/src/components/marquee/index.tsx +14 -12
  265. package/src/components/marquee/marquee-math.ts +37 -0
  266. package/src/components/menu/index.tsx +11 -3
  267. package/src/components/otp-input/index.tsx +3 -1
  268. package/src/components/otp-input/otp-input-state.ts +7 -0
  269. package/src/components/pagination/index.tsx +26 -13
  270. package/src/components/panelside/index.tsx +7 -2
  271. package/src/components/plan/index.tsx +2 -2
  272. package/src/components/planner/index.tsx +44 -11
  273. package/src/components/planner/planner-today.ts +5 -0
  274. package/src/components/plot/index.tsx +199 -51
  275. package/src/components/plot/plot-series-registry.ts +41 -0
  276. package/src/components/post/index.tsx +4 -4
  277. package/src/components/radio-group/index.tsx +4 -1
  278. package/src/components/radio-group/radio-group-value.ts +9 -0
  279. package/src/components/rating/index.tsx +11 -4
  280. package/src/components/rating/rating-inputs.ts +19 -0
  281. package/src/components/search-bar/index.tsx +441 -0
  282. package/src/components/search-bar/search-bar-debounce.ts +35 -0
  283. package/src/components/select/index.tsx +10 -1
  284. package/src/components/select/native-select-contract.ts +12 -0
  285. package/src/components/split-view/index.tsx +565 -0
  286. package/src/components/split-view/split-view-math.ts +146 -0
  287. package/src/components/splitter/index.tsx +589 -0
  288. package/src/components/splitter/splitter-math.ts +244 -0
  289. package/src/components/steps/index.tsx +35 -9
  290. package/src/components/steps/steps-trigger.ts +6 -0
  291. package/src/components/table/index.tsx +2 -2
  292. package/src/components/tag-input/index.tsx +13 -11
  293. package/src/components/tag-input/tag-input-state.ts +18 -0
  294. package/src/components/textarea/index.tsx +8 -4
  295. package/src/components/textarea/textarea-disabled.ts +6 -0
  296. package/src/components/timeline/index.tsx +405 -46
  297. package/src/components/timeline/timeline-geometry.ts +9 -0
  298. package/src/components/toast/index.tsx +26 -1
  299. package/src/components/toast/toast-store.ts +43 -8
  300. package/src/components/toggle-button/index.tsx +1 -1
  301. package/src/components/tour/index.tsx +11 -3
  302. package/src/components/tour/tour-card-measurement.ts +29 -0
  303. package/src/components/tree/index.tsx +17 -12
  304. package/src/hooks/use-keyboard-avoidance.ts +7 -2
  305. package/src/index.ts +19 -0
  306. package/src/utils/chart.ts +66 -7
@@ -0,0 +1,433 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * Splitter — panes that share a container, with a seam between them the reader
5
+ * can drag.
6
+ *
7
+ * ```tsx
8
+ * <Splitter className="h-64" defaultLayout={[65, 35]}>
9
+ * <Splitter.Panel minSize={30}>{list}</Splitter.Panel>
10
+ * <Splitter.Handle />
11
+ * <Splitter.Panel minSize={20} collapsible>{detail}</Splitter.Panel>
12
+ * </Splitter>
13
+ * ```
14
+ *
15
+ * Sizes are percentages of the splitter, so a layout dragged in portrait is
16
+ * still the same layout in landscape. The splitter itself has no height of its
17
+ * own — give it one, or put it in something that does, or it collapses to
18
+ * nothing and takes its panes with it.
19
+ *
20
+ * The seams are drawn over the panes rather than between them. A handle that
21
+ * took layout space would have to be measured before the panes could be sized,
22
+ * which puts the whole layout downstream of a number nobody controls; floating
23
+ * it means the panes add up to exactly the container and the handle can be as
24
+ * wide a target as a finger needs without changing anything.
25
+ *
26
+ * Dragging runs on the UI thread. `onLayoutChange` fires when the seam is let
27
+ * go rather than on every frame, because a layout that round-trips through
28
+ * React sixty times a second is the one thing that makes this feel slow.
29
+ */
30
+ import { Children, createContext, isValidElement, useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react';
31
+ import { View } from 'react-native';
32
+ import { Gesture, GestureDetector } from 'react-native-gesture-handler';
33
+ import Animated, { runOnJS, useAnimatedStyle, useSharedValue } from 'react-native-reanimated';
34
+ import { tv } from 'tailwind-variants';
35
+ import { useDirectionSign } from "../../hooks/use-direction.js";
36
+ import { selectionTick } from "../../utils/haptics.js";
37
+ import { isCollapsed, layoutOffset, normalizeConstraint, resizeLayout, resolveLayout } from "./splitter-math.js";
38
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
39
+ /**
40
+ * How thick the seam's touch target is, in points. Wider than the line it
41
+ * draws, because the line is a hairline and a hairline is not a target.
42
+ */
43
+ const HANDLE_THICKNESS = 24;
44
+ const splitterVariants = tv({
45
+ slots: {
46
+ root: 'relative overflow-hidden',
47
+ panel: 'overflow-hidden',
48
+ handle: 'absolute items-center justify-center',
49
+ line: 'bg-border',
50
+ grip: 'absolute rounded-full bg-muted-foreground/30'
51
+ },
52
+ variants: {
53
+ orientation: {
54
+ horizontal: {
55
+ // `w-full`, because the panes are shares of a width the splitter has to
56
+ // already know. Left to size itself, a row asks its children how wide
57
+ // they are and the children answer with a share of that answer — a
58
+ // circle that resolves to zero and takes the whole splitter with it.
59
+ // Inside anything that centres its children, that is what happens.
60
+ root: 'w-full flex-row',
61
+ // Over the pane that follows it, not under. A seam is drawn between two
62
+ // panes but written between them too, and a later sibling paints on top
63
+ // — which left the outer half of every touch target dead.
64
+ handle: 'bottom-0 start-0 top-0 z-10 w-6',
65
+ line: 'h-full w-px',
66
+ grip: 'h-8 w-1'
67
+ },
68
+ vertical: {
69
+ root: 'flex-col',
70
+ handle: 'end-0 start-0 top-0 z-10 h-6',
71
+ line: 'h-px w-full',
72
+ grip: 'h-1 w-8'
73
+ }
74
+ }
75
+ },
76
+ defaultVariants: {
77
+ orientation: 'horizontal'
78
+ }
79
+ });
80
+ const SplitterContext = /*#__PURE__*/createContext(null);
81
+ const PanelIndexContext = /*#__PURE__*/createContext(0);
82
+ const BoundaryIndexContext = /*#__PURE__*/createContext(-1);
83
+ function useSplitter(component) {
84
+ const context = useContext(SplitterContext);
85
+ if (!context) throw new Error(`${component} must be used within a <Splitter>`);
86
+ return context;
87
+ }
88
+ function isElementOfType(child, type) {
89
+ return /*#__PURE__*/isValidElement(child) && child.type === type;
90
+ }
91
+ function SplitterRoot({
92
+ className,
93
+ orientation = 'horizontal',
94
+ layout: layoutProp,
95
+ defaultLayout,
96
+ onLayoutChange,
97
+ disabled = false,
98
+ step = 5,
99
+ children,
100
+ onLayout,
101
+ ...props
102
+ }) {
103
+ const horizontal = orientation === 'horizontal';
104
+ const sign = useDirectionSign();
105
+ const {
106
+ root
107
+ } = splitterVariants({
108
+ orientation
109
+ });
110
+ const items = Children.toArray(children);
111
+ const panels = items.filter(child => isElementOfType(child, SplitterPanel));
112
+
113
+ // The panes' limits are read straight off their elements rather than
114
+ // registered from an effect. A layout that is only correct after the children
115
+ // have mounted and reported in is a layout that is wrong on the first frame,
116
+ // and this one is knowable before any of them render.
117
+ const constraintsKey = JSON.stringify(panels.map(panel => [panel.props.minSize, panel.props.maxSize, panel.props.collapsible === true, panel.props.collapsedSize, panel.props.defaultSize]));
118
+ const constraints = useMemo(() => panels.map(panel => normalizeConstraint(panel.props)),
119
+ // eslint-disable-next-line react-hooks/exhaustive-deps
120
+ [constraintsKey]);
121
+ const sizesKey = JSON.stringify([layoutProp ?? null, defaultLayout ?? null, panels.map(panel => panel.props.defaultSize ?? null)]);
122
+ const resolved = useMemo(() => {
123
+ const declared = layoutProp ?? defaultLayout;
124
+ return resolveLayout(panels.map((panel, index) => declared?.[index] ?? panel.props.defaultSize), constraints);
125
+ // eslint-disable-next-line react-hooks/exhaustive-deps
126
+ }, [sizesKey, constraints]);
127
+ const layout = useSharedValue(resolved);
128
+ const available = useSharedValue(0);
129
+ const [measured, setMeasured] = useState(false);
130
+ const [settled, setSettled] = useState(resolved);
131
+ // Bumped when a controlled splitter is let go, so a caller that ignored the
132
+ // change gets the seam put back where its props still say it is.
133
+ const [syncToken, setSyncToken] = useState(0);
134
+ const controlled = layoutProp !== undefined;
135
+ const controlledRef = useRef(controlled);
136
+ controlledRef.current = controlled;
137
+ useEffect(() => {
138
+ layout.value = resolved;
139
+ setSettled(resolved);
140
+ }, [resolved, syncToken, layout]);
141
+ const commit = useCallback(next => {
142
+ if (controlledRef.current) setSyncToken(token => token + 1);else setSettled(next);
143
+ onLayoutChange?.(next);
144
+ }, [onLayoutChange]);
145
+ const handleLayout = useCallback(event => {
146
+ const box = event.nativeEvent.layout;
147
+ const size = horizontal ? box.width : box.height;
148
+ available.value = size;
149
+ if (size > 0) setMeasured(true);
150
+ onLayout?.(event);
151
+ }, [available, horizontal, onLayout]);
152
+ const context = useMemo(() => ({
153
+ orientation,
154
+ layout,
155
+ available,
156
+ measured,
157
+ settled,
158
+ initial: resolved,
159
+ constraints,
160
+ disabled,
161
+ // A step of zero or less is a seam that cannot be moved without a drag,
162
+ // which is the one thing the accessibility actions exist to avoid.
163
+ step: Number.isFinite(step) && step > 0 ? step : 5,
164
+ sign,
165
+ commit
166
+ }), [orientation, layout, available, measured, settled, resolved, constraints, disabled, step, sign, commit]);
167
+
168
+ // Panes learn their index and seams learn which pair they sit between from
169
+ // where they appear, so nothing has to be numbered by hand and a pane cannot
170
+ // be given the wrong one.
171
+ let panelIndex = -1;
172
+ const laidOut = items.map((child, index) => {
173
+ if (isElementOfType(child, SplitterPanel)) {
174
+ panelIndex += 1;
175
+ return /*#__PURE__*/_jsx(PanelIndexContext.Provider, {
176
+ value: panelIndex,
177
+ children: child
178
+ }, `panel-${panelIndex}`);
179
+ }
180
+ if (isElementOfType(child, SplitterHandle)) {
181
+ return /*#__PURE__*/_jsx(BoundaryIndexContext.Provider, {
182
+ value: panelIndex,
183
+ children: child
184
+ }, `handle-${index}`);
185
+ }
186
+ return child;
187
+ });
188
+ return /*#__PURE__*/_jsx(SplitterContext.Provider, {
189
+ value: context,
190
+ children: /*#__PURE__*/_jsx(View, {
191
+ className: root({
192
+ className
193
+ }),
194
+ onLayout: handleLayout,
195
+ ...props,
196
+ children: laidOut
197
+ })
198
+ });
199
+ }
200
+ /**
201
+ * One pane.
202
+ *
203
+ * It clips what is inside it, so a pane dragged narrower hides its content
204
+ * rather than pushing it into the pane beside it.
205
+ */
206
+ function SplitterPanel({
207
+ className,
208
+ children,
209
+ style,
210
+ ...props
211
+ }) {
212
+ const context = useSplitter('Splitter.Panel');
213
+ const index = useContext(PanelIndexContext);
214
+ const {
215
+ panel
216
+ } = splitterVariants({
217
+ orientation: context.orientation
218
+ });
219
+ const horizontal = context.orientation === 'horizontal';
220
+ const animatedStyle = useAnimatedStyle(() => {
221
+ const size = context.available.value * (context.layout.value[index] ?? 0) / 100;
222
+ return horizontal ? {
223
+ width: size
224
+ } : {
225
+ height: size
226
+ };
227
+ }, [index, horizontal]);
228
+
229
+ // Nothing is measured on the first frame, and a pane sized from a container of
230
+ // zero is a pane nobody can see. Until the measurement lands, a definite flex
231
+ // basis of zero takes precedence over that width and the shares below carry
232
+ // the layout — so the first frame is already in proportion, and the switch to
233
+ // measured points changes nothing anybody can see.
234
+ const unmeasured = {
235
+ flexGrow: context.settled[index] ?? 0,
236
+ flexBasis: 0,
237
+ flexShrink: 1
238
+ };
239
+ return /*#__PURE__*/_jsx(Animated.View, {
240
+ className: panel({
241
+ className
242
+ }),
243
+ style: [context.measured ? null : unmeasured, style, animatedStyle],
244
+ ...props,
245
+ children: children
246
+ });
247
+ }
248
+ /**
249
+ * The seam between two panes.
250
+ *
251
+ * Put one between each pair. It is `adjustable` to a screen reader, so the
252
+ * layout can be moved a step at a time without a drag, and a double tap puts
253
+ * the pair back where it started — the fastest way out of a pane dragged shut
254
+ * by accident.
255
+ */
256
+ function SplitterHandle({
257
+ className,
258
+ disabled,
259
+ withGrip = true,
260
+ accessibilityLabel = 'Resize panels',
261
+ ...props
262
+ }) {
263
+ const context = useSplitter('Splitter.Handle');
264
+ const boundary = useContext(BoundaryIndexContext);
265
+ const {
266
+ handle,
267
+ line,
268
+ grip
269
+ } = splitterVariants({
270
+ orientation: context.orientation
271
+ });
272
+ const horizontal = context.orientation === 'horizontal';
273
+ const frozen = context.disabled || disabled === true;
274
+ const {
275
+ layout,
276
+ available,
277
+ constraints,
278
+ sign,
279
+ commit
280
+ } = context;
281
+ const start = useSharedValue([]);
282
+ const collapsed = useSharedValue(false);
283
+ const moved = useSharedValue(false);
284
+ const pan = useMemo(() => {
285
+ const gesture = Gesture.Pan().enabled(!frozen && boundary >= 0).onBegin(() => {
286
+ start.value = layout.value.slice();
287
+ moved.value = false;
288
+ const constraint = constraints[boundary];
289
+ collapsed.value = constraint ? isCollapsed(layout.value[boundary] ?? 0, constraint) : false;
290
+ }).onUpdate(event => {
291
+ if (available.value <= 0) return;
292
+ const travelled = horizontal ? event.translationX * sign : event.translationY;
293
+ const delta = travelled / available.value * 100;
294
+ const next = resizeLayout(start.value, boundary, delta, constraints);
295
+ moved.value = true;
296
+ layout.value = next;
297
+
298
+ // The one moment in a drag worth feeling: a pane arriving at shut, or
299
+ // leaving it. Both are a jump the finger did not make, so the tick is
300
+ // what says the jump was the control and not a stutter.
301
+ const constraint = constraints[boundary];
302
+ if (constraint) {
303
+ const shut = isCollapsed(next[boundary] ?? 0, constraint);
304
+ if (shut !== collapsed.value) {
305
+ collapsed.value = shut;
306
+ runOnJS(selectionTick)();
307
+ }
308
+ }
309
+ })
310
+ // A seam that was pressed and not moved has nothing to report, and a
311
+ // layout change nobody made is a re-render nobody asked for.
312
+ .onFinalize(() => {
313
+ if (moved.value) runOnJS(commit)(layout.value.slice());
314
+ });
315
+
316
+ /*
317
+ * A seam only answers to the axis it moves on. Without that it claims any
318
+ * movement at all — which is a splitter inside a scroller taking the
319
+ * scroll, and a drag with no way to fail, which is the one thing the double
320
+ * tap behind it is waiting for.
321
+ */
322
+ return horizontal ? gesture.activeOffsetX([-8, 8]).failOffsetY([-16, 16]) : gesture.activeOffsetY([-8, 8]).failOffsetX([-16, 16]);
323
+ }, [available, boundary, collapsed, commit, constraints, frozen, horizontal, layout, moved, sign, start]);
324
+ const {
325
+ initial
326
+ } = context;
327
+ /**
328
+ * Puts this pair back to the proportions the splitter started with, without
329
+ * touching the panes further along — the two of them share exactly the room
330
+ * they already have between them.
331
+ */
332
+ const reset = useCallback(() => {
333
+ const pair = boundary >= 0 ? boundary : 0;
334
+ const next = layout.value.slice();
335
+ const room = (next[pair] ?? 0) + (next[pair + 1] ?? 0);
336
+ const first = initial[pair] ?? 0;
337
+ const span = first + (initial[pair + 1] ?? 0);
338
+ if (span <= 0) return;
339
+ next[pair] = first / span * room;
340
+ next[pair + 1] = room - next[pair];
341
+ layout.value = next;
342
+ commit(next);
343
+ }, [boundary, commit, initial, layout]);
344
+ const doubleTap = useMemo(() => Gesture.Tap().numberOfTaps(2)
345
+ // A tap that has travelled this far is a drag, and saying so is what
346
+ // lets it give up on the movement rather than on a timer.
347
+ .maxDistance(HANDLE_THICKNESS / 2).enabled(!frozen && boundary >= 0).onEnd((_event, success) => {
348
+ if (success) runOnJS(reset)();
349
+ }), [boundary, frozen, reset]);
350
+
351
+ /*
352
+ * The drag comes first, and the order is the whole of it.
353
+ *
354
+ * A race gives its first gesture the priority and makes the rest wait for it
355
+ * to fail. With the tap in front, every drag was held back until the tap gave
356
+ * up — which a two-tap gesture only does once its window has expired, half a
357
+ * second after the finger lands. A slow first drag outlasted that and worked;
358
+ * the quicker one after it did not, and the seam ignored it.
359
+ *
360
+ * Round this way the pan activates on movement, and a press that never moves
361
+ * fails it and hands the touch on, which is all the tap was waiting for.
362
+ */
363
+ const gesture = useMemo(() => Gesture.Race(pan, doubleTap), [doubleTap, pan]);
364
+ const animatedStyle = useAnimatedStyle(() => {
365
+ if (available.value <= 0) return {
366
+ opacity: 0
367
+ };
368
+ const seam = available.value * layoutOffset(layout.value, boundary) / 100;
369
+ const shift = seam - HANDLE_THICKNESS / 2;
370
+ return {
371
+ opacity: 1,
372
+ transform: horizontal ? [{
373
+ translateX: shift * sign
374
+ }] : [{
375
+ translateY: shift
376
+ }]
377
+ };
378
+ }, [boundary, horizontal, sign]);
379
+
380
+ // A step moves the seam along the layout, not along the screen, so it is the
381
+ // one piece of this that the reading direction does not touch: incrementing
382
+ // grows the pane that comes first either way.
383
+ const step = useCallback(direction => {
384
+ const next = resizeLayout(layout.value.slice(), boundary, direction * context.step, constraints);
385
+ layout.value = next;
386
+ commit(next);
387
+ }, [boundary, commit, constraints, context.step, layout]);
388
+ const onAccessibilityAction = useCallback(event => {
389
+ if (event.nativeEvent.actionName === 'increment') step(1);else if (event.nativeEvent.actionName === 'decrement') step(-1);
390
+ }, [step]);
391
+ const now = Math.round(layoutOffset(context.settled, boundary));
392
+ return /*#__PURE__*/_jsx(GestureDetector, {
393
+ gesture: gesture,
394
+ children: /*#__PURE__*/_jsxs(Animated.View, {
395
+ accessible: true,
396
+ accessibilityRole: "adjustable",
397
+ accessibilityLabel: accessibilityLabel,
398
+ accessibilityState: {
399
+ disabled: frozen
400
+ },
401
+ accessibilityValue: {
402
+ min: 0,
403
+ max: 100,
404
+ now
405
+ },
406
+ accessibilityActions: frozen ? undefined : [{
407
+ name: 'increment'
408
+ }, {
409
+ name: 'decrement'
410
+ }],
411
+ onAccessibilityAction: frozen ? undefined : onAccessibilityAction,
412
+ className: handle({
413
+ className
414
+ }),
415
+ style: animatedStyle,
416
+ ...props,
417
+ children: [/*#__PURE__*/_jsx(View, {
418
+ className: line()
419
+ }), withGrip ? /*#__PURE__*/_jsx(View, {
420
+ className: grip()
421
+ }) : null]
422
+ })
423
+ });
424
+ }
425
+ SplitterRoot.displayName = 'Splitter';
426
+ SplitterPanel.displayName = 'Splitter.Panel';
427
+ SplitterHandle.displayName = 'Splitter.Handle';
428
+ export const Splitter = Object.assign(SplitterRoot, {
429
+ Panel: SplitterPanel,
430
+ Handle: SplitterHandle
431
+ });
432
+ export { DEFAULT_MAX_SIZE, DEFAULT_MIN_SIZE, isCollapsed, layoutOffset, normalizeConstraint, panelFloor, resizeLayout, resolveLayout } from "./splitter-math.js";
433
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Children","createContext","isValidElement","useCallback","useContext","useEffect","useMemo","useRef","useState","View","Gesture","GestureDetector","Animated","runOnJS","useAnimatedStyle","useSharedValue","tv","useDirectionSign","selectionTick","isCollapsed","layoutOffset","normalizeConstraint","resizeLayout","resolveLayout","jsx","_jsx","jsxs","_jsxs","HANDLE_THICKNESS","splitterVariants","slots","root","panel","handle","line","grip","variants","orientation","horizontal","vertical","defaultVariants","SplitterContext","PanelIndexContext","BoundaryIndexContext","useSplitter","component","context","Error","isElementOfType","child","type","SplitterRoot","className","layout","layoutProp","defaultLayout","onLayoutChange","disabled","step","children","onLayout","props","sign","items","toArray","panels","filter","SplitterPanel","constraintsKey","JSON","stringify","map","minSize","maxSize","collapsible","collapsedSize","defaultSize","constraints","sizesKey","resolved","declared","index","available","measured","setMeasured","settled","setSettled","syncToken","setSyncToken","controlled","undefined","controlledRef","current","value","commit","next","token","handleLayout","event","box","nativeEvent","size","width","height","initial","Number","isFinite","panelIndex","laidOut","Provider","SplitterHandle","style","animatedStyle","unmeasured","flexGrow","flexBasis","flexShrink","withGrip","accessibilityLabel","boundary","frozen","start","collapsed","moved","pan","gesture","Pan","enabled","onBegin","slice","constraint","onUpdate","travelled","translationX","translationY","delta","shut","onFinalize","activeOffsetX","failOffsetY","activeOffsetY","failOffsetX","reset","pair","room","first","span","doubleTap","Tap","numberOfTaps","maxDistance","onEnd","_event","success","Race","opacity","seam","shift","transform","translateX","translateY","direction","onAccessibilityAction","actionName","now","Math","round","accessible","accessibilityRole","accessibilityState","accessibilityValue","min","max","accessibilityActions","name","displayName","Splitter","Object","assign","Panel","Handle","DEFAULT_MAX_SIZE","DEFAULT_MIN_SIZE","panelFloor"],"sourceRoot":"../../../../src","sources":["components/splitter/index.tsx"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SACEA,QAAQ,EACRC,aAAa,EACbC,cAAc,EACdC,WAAW,EACXC,UAAU,EACVC,SAAS,EACTC,OAAO,EACPC,MAAM,EACNC,QAAQ,QAGH,OAAO;AACd,SACEC,IAAI,QAIC,cAAc;AACrB,SAASC,OAAO,EAAEC,eAAe,QAAQ,8BAA8B;AACvE,OAAOC,QAAQ,IACbC,OAAO,EACPC,gBAAgB,EAChBC,cAAc,QAET,yBAAyB;AAChC,SAASC,EAAE,QAAQ,mBAAmB;AACtC,SAASC,gBAAgB,QAAQ,8BAA2B;AAC5D,SAASC,aAAa,QAAQ,wBAAqB;AACnD,SACEC,WAAW,EACXC,YAAY,EACZC,mBAAmB,EACnBC,YAAY,EACZC,aAAa,QAER,oBAAiB;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAIzB;AACA;AACA;AACA;AACA,MAAMC,gBAAgB,GAAG,EAAE;AAE3B,MAAMC,gBAAgB,GAAGb,EAAE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GC,MAAM,CAACC,MAAM,CAAC/H,YAAY,EAAE;EAClDgI,KAAK,EAAEhH,aAAa;EACpBiH,MAAM,EAAEtE;AACV,CAAC,CAAC;AAEF,SACEuE,gBAAgB,EAChBC,gBAAgB,EAChBnK,WAAW,EACXC,YAAY,EACZC,mBAAmB,EACnBkK,UAAU,EACVjK,YAAY,EACZC,aAAa,QAGR,oBAAiB","ignoreList":[]}
@@ -0,0 +1,206 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * The arithmetic a splitter runs while a seam is under a finger.
5
+ *
6
+ * Sizes are percentages of the whole splitter, never points, which is what
7
+ * makes a dragged layout survive a rotation or a window resize: the numbers
8
+ * mean the same thing at any container size, so nothing has to be re-measured
9
+ * and re-derived when one changes.
10
+ *
11
+ * It lives apart from the component for two reasons. It is the part with the
12
+ * edge cases — a pair of panels that cannot both honour their minimums, a
13
+ * collapse that has to decide between shut and its floor, a caller's sizes that
14
+ * do not add up — and it is the part that runs on the UI thread, where a wrong
15
+ * answer is a layout that sticks rather than an exception anybody sees.
16
+ */
17
+
18
+ /** How small a panel may get before its neighbour stops taking room, in percent. */
19
+ export const DEFAULT_MIN_SIZE = 10;
20
+ /** How large a panel may get, in percent. */
21
+ export const DEFAULT_MAX_SIZE = 100;
22
+ function clamp(value, low, high) {
23
+ 'worklet';
24
+
25
+ return Math.min(Math.max(value, low), high);
26
+ }
27
+ function finite(value, fallback) {
28
+ 'worklet';
29
+
30
+ return typeof value === 'number' && Number.isFinite(value) ? value : fallback;
31
+ }
32
+
33
+ /** The smallest share a panel can hold at all — its floor once shut, or its minimum. */
34
+ export function panelFloor(constraint) {
35
+ 'worklet';
36
+
37
+ return constraint.collapsible ? constraint.collapsedSize : constraint.minSize;
38
+ }
39
+
40
+ /**
41
+ * Fills a panel's declared limits in, in an order that cannot contradict
42
+ * itself: the maximum is never below the minimum, and a collapsed size is never
43
+ * above the minimum it exists to sit below.
44
+ */
45
+ export function normalizeConstraint(input) {
46
+ const minSize = clamp(finite(input?.minSize, DEFAULT_MIN_SIZE), 0, 100);
47
+ const maxSize = clamp(finite(input?.maxSize, DEFAULT_MAX_SIZE), minSize, 100);
48
+ const collapsible = input?.collapsible === true;
49
+ const collapsedSize = clamp(finite(input?.collapsedSize, 0), 0, minSize);
50
+ return {
51
+ minSize,
52
+ maxSize,
53
+ collapsible,
54
+ collapsedSize
55
+ };
56
+ }
57
+ function total(layout) {
58
+ 'worklet';
59
+
60
+ let sum = 0;
61
+ for (let index = 0; index < layout.length; index += 1) sum += layout[index];
62
+ return sum;
63
+ }
64
+
65
+ /**
66
+ * Pushes a layout onto exactly 100, moving each panel by its share of the room
67
+ * it has left in the direction the correction is going. Panels already against
68
+ * a limit therefore absorb none of it, which is what keeps a correction from
69
+ * quietly undoing the limit it just honoured.
70
+ *
71
+ * Four passes, because clamping after each one can hand the next a smaller
72
+ * remainder rather than none; it converges long before that in practice, and
73
+ * the bound is what stops a contradictory set of limits from spinning.
74
+ */
75
+ function settle(layout, constraints) {
76
+ 'worklet';
77
+
78
+ const next = layout.slice();
79
+ for (let pass = 0; pass < 4; pass += 1) {
80
+ const remainder = 100 - total(next);
81
+ if (Math.abs(remainder) < 1e-6) break;
82
+ let room = 0;
83
+ const headroom = [];
84
+ for (let index = 0; index < next.length; index += 1) {
85
+ const constraint = constraints[index];
86
+ const available = remainder > 0 ? constraint.maxSize - next[index] : next[index] - panelFloor(constraint);
87
+ headroom.push(Math.max(available, 0));
88
+ room += Math.max(available, 0);
89
+ }
90
+ if (room <= 1e-6) break;
91
+ for (let index = 0; index < next.length; index += 1) {
92
+ next[index] = clamp(next[index] + remainder * headroom[index] / room, panelFloor(constraints[index]), constraints[index].maxSize);
93
+ }
94
+ }
95
+
96
+ // Minimums that add up to more than the whole cannot all be honoured. Scaling
97
+ // the whole layout down is the failure that stays legible: every panel is
98
+ // smaller than it asked for, rather than the last one being pushed out of the
99
+ // container where nobody can see that it is there at all.
100
+ const sum = total(next);
101
+ if (sum > 100 + 1e-6) {
102
+ for (let index = 0; index < next.length; index += 1) {
103
+ next[index] = next[index] * 100 / sum;
104
+ }
105
+ }
106
+ return next;
107
+ }
108
+
109
+ /**
110
+ * Turns whatever sizes a caller gave into one layout that adds up.
111
+ *
112
+ * Panels with no size of their own split what the sized ones left over, so a
113
+ * three-pane splitter that only pins its sidebar gets the sensible reading of
114
+ * that: the sidebar keeps its number and the other two share the rest.
115
+ */
116
+ export function resolveLayout(sizes, constraints) {
117
+ if (constraints.length === 0) return [];
118
+ let claimed = 0;
119
+ let unsized = 0;
120
+ for (let index = 0; index < constraints.length; index += 1) {
121
+ const size = sizes[index];
122
+ if (typeof size === 'number' && Number.isFinite(size)) {
123
+ claimed += clamp(size, 0, 100);
124
+ } else {
125
+ unsized += 1;
126
+ }
127
+ }
128
+ const share = unsized > 0 ? Math.max(100 - claimed, 0) / unsized : 0;
129
+ const layout = [];
130
+ for (let index = 0; index < constraints.length; index += 1) {
131
+ const size = sizes[index];
132
+ const raw = typeof size === 'number' && Number.isFinite(size) ? clamp(size, 0, 100) : share;
133
+ layout.push(clamp(raw, panelFloor(constraints[index]), constraints[index].maxSize));
134
+ }
135
+ return settle(layout, constraints);
136
+ }
137
+
138
+ /**
139
+ * A panel's size once it is below its minimum: shut if it is collapsible and
140
+ * the drag has gone more than halfway there, and otherwise held at the minimum.
141
+ *
142
+ * The halfway point is what makes collapsing feel like a decision rather than
143
+ * an accident — a finger that grazes the minimum springs back, and one that
144
+ * keeps going shuts the panel.
145
+ */
146
+ function snapDown(size, constraint) {
147
+ 'worklet';
148
+
149
+ if (size >= constraint.minSize) return size;
150
+ if (!constraint.collapsible) return constraint.minSize;
151
+ return size < (constraint.collapsedSize + constraint.minSize) / 2 ? constraint.collapsedSize : constraint.minSize;
152
+ }
153
+
154
+ /**
155
+ * Moves one seam, in percent, and hands back the whole layout.
156
+ *
157
+ * Only the two panels either side of the seam change: a drag borrows from its
158
+ * neighbour and nobody else, so the panels further along stay exactly where the
159
+ * reader left them.
160
+ *
161
+ * Collapsing is only ever offered to the panel being shrunk. Both sides could
162
+ * technically be past their minimum at once at the end of a long drag, and
163
+ * shutting the panel that is currently growing is never what the drag meant.
164
+ */
165
+ export function resizeLayout(layout, boundary, delta, constraints) {
166
+ 'worklet';
167
+
168
+ const next = layout.slice();
169
+ if (boundary < 0 || boundary + 1 >= next.length) return next;
170
+ if (!Number.isFinite(delta)) return next;
171
+ const first = constraints[boundary];
172
+ const second = constraints[boundary + 1];
173
+ if (!first || !second) return next;
174
+ const pair = next[boundary] + next[boundary + 1];
175
+ let intended = next[boundary] + delta;
176
+ if (delta < 0) {
177
+ intended = snapDown(intended, first);
178
+ } else if (delta > 0) {
179
+ intended = pair - snapDown(pair - intended, second);
180
+ }
181
+ const low = Math.max(panelFloor(first), pair - second.maxSize);
182
+ const high = Math.min(first.maxSize, pair - panelFloor(second));
183
+ if (low > high) return next;
184
+ next[boundary] = clamp(intended, low, high);
185
+ next[boundary + 1] = pair - next[boundary];
186
+ return next;
187
+ }
188
+
189
+ /** Where a seam sits, in percent, measured from the start of the splitter. */
190
+ export function layoutOffset(layout, boundary) {
191
+ 'worklet';
192
+
193
+ let offset = 0;
194
+ for (let index = 0; index <= boundary && index < layout.length; index += 1) {
195
+ offset += layout[index];
196
+ }
197
+ return offset;
198
+ }
199
+
200
+ /** Whether a panel is currently shut rather than merely small. */
201
+ export function isCollapsed(size, constraint) {
202
+ 'worklet';
203
+
204
+ return constraint.collapsible && size <= constraint.collapsedSize + 1e-6;
205
+ }
206
+ //# sourceMappingURL=splitter-math.js.map