@mintplayer/ng-bootstrap 21.31.0 → 21.33.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 (280) hide show
  1. package/package.json +1 -373
  2. package/fesm2022/mintplayer-ng-bootstrap-a11y.mjs +0 -455
  3. package/fesm2022/mintplayer-ng-bootstrap-a11y.mjs.map +0 -1
  4. package/fesm2022/mintplayer-ng-bootstrap-accordion.mjs +0 -94
  5. package/fesm2022/mintplayer-ng-bootstrap-accordion.mjs.map +0 -1
  6. package/fesm2022/mintplayer-ng-bootstrap-alert.mjs +0 -45
  7. package/fesm2022/mintplayer-ng-bootstrap-alert.mjs.map +0 -1
  8. package/fesm2022/mintplayer-ng-bootstrap-badge.mjs +0 -24
  9. package/fesm2022/mintplayer-ng-bootstrap-badge.mjs.map +0 -1
  10. package/fesm2022/mintplayer-ng-bootstrap-breadcrumb.mjs +0 -35
  11. package/fesm2022/mintplayer-ng-bootstrap-breadcrumb.mjs.map +0 -1
  12. package/fesm2022/mintplayer-ng-bootstrap-button-group.mjs +0 -21
  13. package/fesm2022/mintplayer-ng-bootstrap-button-group.mjs.map +0 -1
  14. package/fesm2022/mintplayer-ng-bootstrap-button-type.mjs +0 -36
  15. package/fesm2022/mintplayer-ng-bootstrap-button-type.mjs.map +0 -1
  16. package/fesm2022/mintplayer-ng-bootstrap-calendar-month.mjs +0 -136
  17. package/fesm2022/mintplayer-ng-bootstrap-calendar-month.mjs.map +0 -1
  18. package/fesm2022/mintplayer-ng-bootstrap-calendar.mjs +0 -210
  19. package/fesm2022/mintplayer-ng-bootstrap-calendar.mjs.map +0 -1
  20. package/fesm2022/mintplayer-ng-bootstrap-card.mjs +0 -33
  21. package/fesm2022/mintplayer-ng-bootstrap-card.mjs.map +0 -1
  22. package/fesm2022/mintplayer-ng-bootstrap-carousel.mjs +0 -270
  23. package/fesm2022/mintplayer-ng-bootstrap-carousel.mjs.map +0 -1
  24. package/fesm2022/mintplayer-ng-bootstrap-close.mjs +0 -25
  25. package/fesm2022/mintplayer-ng-bootstrap-close.mjs.map +0 -1
  26. package/fesm2022/mintplayer-ng-bootstrap-code-snippet.mjs +0 -44
  27. package/fesm2022/mintplayer-ng-bootstrap-code-snippet.mjs.map +0 -1
  28. package/fesm2022/mintplayer-ng-bootstrap-color-picker.mjs +0 -654
  29. package/fesm2022/mintplayer-ng-bootstrap-color-picker.mjs.map +0 -1
  30. package/fesm2022/mintplayer-ng-bootstrap-container.mjs +0 -18
  31. package/fesm2022/mintplayer-ng-bootstrap-container.mjs.map +0 -1
  32. package/fesm2022/mintplayer-ng-bootstrap-context-menu.mjs +0 -88
  33. package/fesm2022/mintplayer-ng-bootstrap-context-menu.mjs.map +0 -1
  34. package/fesm2022/mintplayer-ng-bootstrap-copy.mjs +0 -46
  35. package/fesm2022/mintplayer-ng-bootstrap-copy.mjs.map +0 -1
  36. package/fesm2022/mintplayer-ng-bootstrap-datatable.mjs +0 -181
  37. package/fesm2022/mintplayer-ng-bootstrap-datatable.mjs.map +0 -1
  38. package/fesm2022/mintplayer-ng-bootstrap-datepicker.mjs +0 -30
  39. package/fesm2022/mintplayer-ng-bootstrap-datepicker.mjs.map +0 -1
  40. package/fesm2022/mintplayer-ng-bootstrap-dock.mjs +0 -4101
  41. package/fesm2022/mintplayer-ng-bootstrap-dock.mjs.map +0 -1
  42. package/fesm2022/mintplayer-ng-bootstrap-dropdown-divider.mjs +0 -23
  43. package/fesm2022/mintplayer-ng-bootstrap-dropdown-divider.mjs.map +0 -1
  44. package/fesm2022/mintplayer-ng-bootstrap-dropdown-menu.mjs +0 -195
  45. package/fesm2022/mintplayer-ng-bootstrap-dropdown-menu.mjs.map +0 -1
  46. package/fesm2022/mintplayer-ng-bootstrap-dropdown.mjs +0 -326
  47. package/fesm2022/mintplayer-ng-bootstrap-dropdown.mjs.map +0 -1
  48. package/fesm2022/mintplayer-ng-bootstrap-enhanced-paste.mjs +0 -62
  49. package/fesm2022/mintplayer-ng-bootstrap-enhanced-paste.mjs.map +0 -1
  50. package/fesm2022/mintplayer-ng-bootstrap-enum.mjs +0 -38
  51. package/fesm2022/mintplayer-ng-bootstrap-enum.mjs.map +0 -1
  52. package/fesm2022/mintplayer-ng-bootstrap-file-upload.mjs +0 -135
  53. package/fesm2022/mintplayer-ng-bootstrap-file-upload.mjs.map +0 -1
  54. package/fesm2022/mintplayer-ng-bootstrap-floating-labels.mjs +0 -25
  55. package/fesm2022/mintplayer-ng-bootstrap-floating-labels.mjs.map +0 -1
  56. package/fesm2022/mintplayer-ng-bootstrap-font-color.mjs +0 -34
  57. package/fesm2022/mintplayer-ng-bootstrap-font-color.mjs.map +0 -1
  58. package/fesm2022/mintplayer-ng-bootstrap-for.mjs +0 -41
  59. package/fesm2022/mintplayer-ng-bootstrap-for.mjs.map +0 -1
  60. package/fesm2022/mintplayer-ng-bootstrap-form.mjs +0 -59
  61. package/fesm2022/mintplayer-ng-bootstrap-form.mjs.map +0 -1
  62. package/fesm2022/mintplayer-ng-bootstrap-grid.mjs +0 -122
  63. package/fesm2022/mintplayer-ng-bootstrap-grid.mjs.map +0 -1
  64. package/fesm2022/mintplayer-ng-bootstrap-has-id.mjs +0 -4
  65. package/fesm2022/mintplayer-ng-bootstrap-has-id.mjs.map +0 -1
  66. package/fesm2022/mintplayer-ng-bootstrap-has-overlay.mjs +0 -32
  67. package/fesm2022/mintplayer-ng-bootstrap-has-overlay.mjs.map +0 -1
  68. package/fesm2022/mintplayer-ng-bootstrap-has-property.mjs +0 -23
  69. package/fesm2022/mintplayer-ng-bootstrap-has-property.mjs.map +0 -1
  70. package/fesm2022/mintplayer-ng-bootstrap-in-list.mjs +0 -23
  71. package/fesm2022/mintplayer-ng-bootstrap-in-list.mjs.map +0 -1
  72. package/fesm2022/mintplayer-ng-bootstrap-input-group.mjs +0 -18
  73. package/fesm2022/mintplayer-ng-bootstrap-input-group.mjs.map +0 -1
  74. package/fesm2022/mintplayer-ng-bootstrap-instance-of.mjs +0 -183
  75. package/fesm2022/mintplayer-ng-bootstrap-instance-of.mjs.map +0 -1
  76. package/fesm2022/mintplayer-ng-bootstrap-let.mjs +0 -46
  77. package/fesm2022/mintplayer-ng-bootstrap-let.mjs.map +0 -1
  78. package/fesm2022/mintplayer-ng-bootstrap-linify.mjs +0 -28
  79. package/fesm2022/mintplayer-ng-bootstrap-linify.mjs.map +0 -1
  80. package/fesm2022/mintplayer-ng-bootstrap-list-group.mjs +0 -33
  81. package/fesm2022/mintplayer-ng-bootstrap-list-group.mjs.map +0 -1
  82. package/fesm2022/mintplayer-ng-bootstrap-markdown.mjs +0 -118
  83. package/fesm2022/mintplayer-ng-bootstrap-markdown.mjs.map +0 -1
  84. package/fesm2022/mintplayer-ng-bootstrap-marquee.mjs +0 -21
  85. package/fesm2022/mintplayer-ng-bootstrap-marquee.mjs.map +0 -1
  86. package/fesm2022/mintplayer-ng-bootstrap-modal.mjs +0 -240
  87. package/fesm2022/mintplayer-ng-bootstrap-modal.mjs.map +0 -1
  88. package/fesm2022/mintplayer-ng-bootstrap-multi-range.mjs +0 -693
  89. package/fesm2022/mintplayer-ng-bootstrap-multi-range.mjs.map +0 -1
  90. package/fesm2022/mintplayer-ng-bootstrap-multiselect.mjs +0 -136
  91. package/fesm2022/mintplayer-ng-bootstrap-multiselect.mjs.map +0 -1
  92. package/fesm2022/mintplayer-ng-bootstrap-navbar-toggler.mjs +0 -29
  93. package/fesm2022/mintplayer-ng-bootstrap-navbar-toggler.mjs.map +0 -1
  94. package/fesm2022/mintplayer-ng-bootstrap-navbar.mjs +0 -629
  95. package/fesm2022/mintplayer-ng-bootstrap-navbar.mjs.map +0 -1
  96. package/fesm2022/mintplayer-ng-bootstrap-navigation-lock.mjs +0 -205
  97. package/fesm2022/mintplayer-ng-bootstrap-navigation-lock.mjs.map +0 -1
  98. package/fesm2022/mintplayer-ng-bootstrap-no-noscript.mjs +0 -31
  99. package/fesm2022/mintplayer-ng-bootstrap-no-noscript.mjs.map +0 -1
  100. package/fesm2022/mintplayer-ng-bootstrap-offcanvas.mjs +0 -366
  101. package/fesm2022/mintplayer-ng-bootstrap-offcanvas.mjs.map +0 -1
  102. package/fesm2022/mintplayer-ng-bootstrap-ordinal-number.mjs +0 -36
  103. package/fesm2022/mintplayer-ng-bootstrap-ordinal-number.mjs.map +0 -1
  104. package/fesm2022/mintplayer-ng-bootstrap-pagination.mjs +0 -188
  105. package/fesm2022/mintplayer-ng-bootstrap-pagination.mjs.map +0 -1
  106. package/fesm2022/mintplayer-ng-bootstrap-parallax.mjs +0 -26
  107. package/fesm2022/mintplayer-ng-bootstrap-parallax.mjs.map +0 -1
  108. package/fesm2022/mintplayer-ng-bootstrap-placeholder.mjs +0 -64
  109. package/fesm2022/mintplayer-ng-bootstrap-placeholder.mjs.map +0 -1
  110. package/fesm2022/mintplayer-ng-bootstrap-playlist-toggler.mjs +0 -29
  111. package/fesm2022/mintplayer-ng-bootstrap-playlist-toggler.mjs.map +0 -1
  112. package/fesm2022/mintplayer-ng-bootstrap-popover.mjs +0 -246
  113. package/fesm2022/mintplayer-ng-bootstrap-popover.mjs.map +0 -1
  114. package/fesm2022/mintplayer-ng-bootstrap-priority-nav.mjs +0 -250
  115. package/fesm2022/mintplayer-ng-bootstrap-priority-nav.mjs.map +0 -1
  116. package/fesm2022/mintplayer-ng-bootstrap-progress-bar.mjs +0 -68
  117. package/fesm2022/mintplayer-ng-bootstrap-progress-bar.mjs.map +0 -1
  118. package/fesm2022/mintplayer-ng-bootstrap-range.mjs +0 -75
  119. package/fesm2022/mintplayer-ng-bootstrap-range.mjs.map +0 -1
  120. package/fesm2022/mintplayer-ng-bootstrap-rating.mjs +0 -79
  121. package/fesm2022/mintplayer-ng-bootstrap-rating.mjs.map +0 -1
  122. package/fesm2022/mintplayer-ng-bootstrap-reduced-motion.mjs +0 -59
  123. package/fesm2022/mintplayer-ng-bootstrap-reduced-motion.mjs.map +0 -1
  124. package/fesm2022/mintplayer-ng-bootstrap-resizable.mjs +0 -387
  125. package/fesm2022/mintplayer-ng-bootstrap-resizable.mjs.map +0 -1
  126. package/fesm2022/mintplayer-ng-bootstrap-scheduler.mjs +0 -237
  127. package/fesm2022/mintplayer-ng-bootstrap-scheduler.mjs.map +0 -1
  128. package/fesm2022/mintplayer-ng-bootstrap-scrollspy.mjs +0 -120
  129. package/fesm2022/mintplayer-ng-bootstrap-scrollspy.mjs.map +0 -1
  130. package/fesm2022/mintplayer-ng-bootstrap-searchbox.mjs +0 -194
  131. package/fesm2022/mintplayer-ng-bootstrap-searchbox.mjs.map +0 -1
  132. package/fesm2022/mintplayer-ng-bootstrap-select.mjs +0 -213
  133. package/fesm2022/mintplayer-ng-bootstrap-select.mjs.map +0 -1
  134. package/fesm2022/mintplayer-ng-bootstrap-select2.mjs +0 -205
  135. package/fesm2022/mintplayer-ng-bootstrap-select2.mjs.map +0 -1
  136. package/fesm2022/mintplayer-ng-bootstrap-shell.mjs +0 -52
  137. package/fesm2022/mintplayer-ng-bootstrap-shell.mjs.map +0 -1
  138. package/fesm2022/mintplayer-ng-bootstrap-signature-pad.mjs +0 -76
  139. package/fesm2022/mintplayer-ng-bootstrap-signature-pad.mjs.map +0 -1
  140. package/fesm2022/mintplayer-ng-bootstrap-slugify.mjs +0 -30
  141. package/fesm2022/mintplayer-ng-bootstrap-slugify.mjs.map +0 -1
  142. package/fesm2022/mintplayer-ng-bootstrap-spinner.mjs +0 -26
  143. package/fesm2022/mintplayer-ng-bootstrap-spinner.mjs.map +0 -1
  144. package/fesm2022/mintplayer-ng-bootstrap-split-string.mjs +0 -25
  145. package/fesm2022/mintplayer-ng-bootstrap-split-string.mjs.map +0 -1
  146. package/fesm2022/mintplayer-ng-bootstrap-sticky-footer.mjs +0 -46
  147. package/fesm2022/mintplayer-ng-bootstrap-sticky-footer.mjs.map +0 -1
  148. package/fesm2022/mintplayer-ng-bootstrap-tab-control.mjs +0 -124
  149. package/fesm2022/mintplayer-ng-bootstrap-tab-control.mjs.map +0 -1
  150. package/fesm2022/mintplayer-ng-bootstrap-table.mjs +0 -40
  151. package/fesm2022/mintplayer-ng-bootstrap-table.mjs.map +0 -1
  152. package/fesm2022/mintplayer-ng-bootstrap-tile-manager.mjs +0 -1446
  153. package/fesm2022/mintplayer-ng-bootstrap-tile-manager.mjs.map +0 -1
  154. package/fesm2022/mintplayer-ng-bootstrap-timepicker.mjs +0 -104
  155. package/fesm2022/mintplayer-ng-bootstrap-timepicker.mjs.map +0 -1
  156. package/fesm2022/mintplayer-ng-bootstrap-toast.mjs +0 -163
  157. package/fesm2022/mintplayer-ng-bootstrap-toast.mjs.map +0 -1
  158. package/fesm2022/mintplayer-ng-bootstrap-toggle-button.mjs +0 -236
  159. package/fesm2022/mintplayer-ng-bootstrap-toggle-button.mjs.map +0 -1
  160. package/fesm2022/mintplayer-ng-bootstrap-tooltip.mjs +0 -174
  161. package/fesm2022/mintplayer-ng-bootstrap-tooltip.mjs.map +0 -1
  162. package/fesm2022/mintplayer-ng-bootstrap-treeview.mjs +0 -100
  163. package/fesm2022/mintplayer-ng-bootstrap-treeview.mjs.map +0 -1
  164. package/fesm2022/mintplayer-ng-bootstrap-trust-html.mjs +0 -28
  165. package/fesm2022/mintplayer-ng-bootstrap-trust-html.mjs.map +0 -1
  166. package/fesm2022/mintplayer-ng-bootstrap-typeahead.mjs +0 -111
  167. package/fesm2022/mintplayer-ng-bootstrap-typeahead.mjs.map +0 -1
  168. package/fesm2022/mintplayer-ng-bootstrap-uc-first.mjs +0 -24
  169. package/fesm2022/mintplayer-ng-bootstrap-uc-first.mjs.map +0 -1
  170. package/fesm2022/mintplayer-ng-bootstrap-user-agent.mjs +0 -94
  171. package/fesm2022/mintplayer-ng-bootstrap-user-agent.mjs.map +0 -1
  172. package/fesm2022/mintplayer-ng-bootstrap-viewport.mjs +0 -48
  173. package/fesm2022/mintplayer-ng-bootstrap-viewport.mjs.map +0 -1
  174. package/fesm2022/mintplayer-ng-bootstrap-virtual-datatable.mjs +0 -282
  175. package/fesm2022/mintplayer-ng-bootstrap-virtual-datatable.mjs.map +0 -1
  176. package/fesm2022/mintplayer-ng-bootstrap-web-components-a11y.mjs +0 -74
  177. package/fesm2022/mintplayer-ng-bootstrap-web-components-a11y.mjs.map +0 -1
  178. package/fesm2022/mintplayer-ng-bootstrap-web-components-scheduler-core.mjs +0 -1356
  179. package/fesm2022/mintplayer-ng-bootstrap-web-components-scheduler-core.mjs.map +0 -1
  180. package/fesm2022/mintplayer-ng-bootstrap-web-components-scheduler.mjs +0 -5224
  181. package/fesm2022/mintplayer-ng-bootstrap-web-components-scheduler.mjs.map +0 -1
  182. package/fesm2022/mintplayer-ng-bootstrap-web-components-splitter.mjs +0 -923
  183. package/fesm2022/mintplayer-ng-bootstrap-web-components-splitter.mjs.map +0 -1
  184. package/fesm2022/mintplayer-ng-bootstrap-web-components-tab-control.mjs +0 -553
  185. package/fesm2022/mintplayer-ng-bootstrap-web-components-tab-control.mjs.map +0 -1
  186. package/fesm2022/mintplayer-ng-bootstrap-word-count.mjs +0 -34
  187. package/fesm2022/mintplayer-ng-bootstrap-word-count.mjs.map +0 -1
  188. package/types/mintplayer-ng-bootstrap-a11y.d.ts +0 -196
  189. package/types/mintplayer-ng-bootstrap-accordion.d.ts +0 -39
  190. package/types/mintplayer-ng-bootstrap-alert.d.ts +0 -21
  191. package/types/mintplayer-ng-bootstrap-badge.d.ts +0 -12
  192. package/types/mintplayer-ng-bootstrap-breadcrumb.d.ts +0 -14
  193. package/types/mintplayer-ng-bootstrap-button-group.d.ts +0 -9
  194. package/types/mintplayer-ng-bootstrap-button-type.d.ts +0 -12
  195. package/types/mintplayer-ng-bootstrap-calendar-month.d.ts +0 -54
  196. package/types/mintplayer-ng-bootstrap-calendar.d.ts +0 -57
  197. package/types/mintplayer-ng-bootstrap-card.d.ts +0 -15
  198. package/types/mintplayer-ng-bootstrap-carousel.d.ts +0 -121
  199. package/types/mintplayer-ng-bootstrap-close.d.ts +0 -10
  200. package/types/mintplayer-ng-bootstrap-code-snippet.d.ts +0 -20
  201. package/types/mintplayer-ng-bootstrap-color-picker.d.ts +0 -236
  202. package/types/mintplayer-ng-bootstrap-container.d.ts +0 -8
  203. package/types/mintplayer-ng-bootstrap-context-menu.d.ts +0 -21
  204. package/types/mintplayer-ng-bootstrap-copy.d.ts +0 -12
  205. package/types/mintplayer-ng-bootstrap-datatable.d.ts +0 -63
  206. package/types/mintplayer-ng-bootstrap-datepicker.d.ts +0 -13
  207. package/types/mintplayer-ng-bootstrap-dock.d.ts +0 -419
  208. package/types/mintplayer-ng-bootstrap-dropdown-divider.d.ts +0 -8
  209. package/types/mintplayer-ng-bootstrap-dropdown-menu.d.ts +0 -66
  210. package/types/mintplayer-ng-bootstrap-dropdown.d.ts +0 -102
  211. package/types/mintplayer-ng-bootstrap-enhanced-paste.d.ts +0 -20
  212. package/types/mintplayer-ng-bootstrap-enum.d.ts +0 -17
  213. package/types/mintplayer-ng-bootstrap-file-upload.d.ts +0 -51
  214. package/types/mintplayer-ng-bootstrap-floating-labels.d.ts +0 -9
  215. package/types/mintplayer-ng-bootstrap-font-color.d.ts +0 -10
  216. package/types/mintplayer-ng-bootstrap-for.d.ts +0 -13
  217. package/types/mintplayer-ng-bootstrap-form.d.ts +0 -24
  218. package/types/mintplayer-ng-bootstrap-grid.d.ts +0 -50
  219. package/types/mintplayer-ng-bootstrap-has-id.d.ts +0 -5
  220. package/types/mintplayer-ng-bootstrap-has-overlay.d.ts +0 -22
  221. package/types/mintplayer-ng-bootstrap-has-property.d.ts +0 -10
  222. package/types/mintplayer-ng-bootstrap-in-list.d.ts +0 -11
  223. package/types/mintplayer-ng-bootstrap-input-group.d.ts +0 -8
  224. package/types/mintplayer-ng-bootstrap-instance-of.d.ts +0 -74
  225. package/types/mintplayer-ng-bootstrap-let.d.ts +0 -44
  226. package/types/mintplayer-ng-bootstrap-linify.d.ts +0 -10
  227. package/types/mintplayer-ng-bootstrap-list-group.d.ts +0 -14
  228. package/types/mintplayer-ng-bootstrap-markdown.d.ts +0 -33
  229. package/types/mintplayer-ng-bootstrap-marquee.d.ts +0 -9
  230. package/types/mintplayer-ng-bootstrap-modal.d.ts +0 -82
  231. package/types/mintplayer-ng-bootstrap-multi-range.d.ts +0 -170
  232. package/types/mintplayer-ng-bootstrap-multiselect.d.ts +0 -58
  233. package/types/mintplayer-ng-bootstrap-navbar-toggler.d.ts +0 -13
  234. package/types/mintplayer-ng-bootstrap-navbar.d.ts +0 -189
  235. package/types/mintplayer-ng-bootstrap-navigation-lock.d.ts +0 -117
  236. package/types/mintplayer-ng-bootstrap-no-noscript.d.ts +0 -11
  237. package/types/mintplayer-ng-bootstrap-offcanvas.d.ts +0 -106
  238. package/types/mintplayer-ng-bootstrap-ordinal-number.d.ts +0 -12
  239. package/types/mintplayer-ng-bootstrap-pagination.d.ts +0 -40
  240. package/types/mintplayer-ng-bootstrap-parallax.d.ts +0 -11
  241. package/types/mintplayer-ng-bootstrap-placeholder.d.ts +0 -23
  242. package/types/mintplayer-ng-bootstrap-playlist-toggler.d.ts +0 -13
  243. package/types/mintplayer-ng-bootstrap-popover.d.ts +0 -67
  244. package/types/mintplayer-ng-bootstrap-priority-nav.d.ts +0 -64
  245. package/types/mintplayer-ng-bootstrap-progress-bar.d.ts +0 -27
  246. package/types/mintplayer-ng-bootstrap-range.d.ts +0 -28
  247. package/types/mintplayer-ng-bootstrap-rating.d.ts +0 -20
  248. package/types/mintplayer-ng-bootstrap-reduced-motion.d.ts +0 -36
  249. package/types/mintplayer-ng-bootstrap-resizable.d.ts +0 -89
  250. package/types/mintplayer-ng-bootstrap-scheduler.d.ts +0 -171
  251. package/types/mintplayer-ng-bootstrap-scrollspy.d.ts +0 -36
  252. package/types/mintplayer-ng-bootstrap-searchbox.d.ts +0 -65
  253. package/types/mintplayer-ng-bootstrap-select.d.ts +0 -65
  254. package/types/mintplayer-ng-bootstrap-select2.d.ts +0 -61
  255. package/types/mintplayer-ng-bootstrap-shell.d.ts +0 -26
  256. package/types/mintplayer-ng-bootstrap-signature-pad.d.ts +0 -36
  257. package/types/mintplayer-ng-bootstrap-slugify.d.ts +0 -10
  258. package/types/mintplayer-ng-bootstrap-spinner.d.ts +0 -14
  259. package/types/mintplayer-ng-bootstrap-split-string.d.ts +0 -10
  260. package/types/mintplayer-ng-bootstrap-sticky-footer.d.ts +0 -21
  261. package/types/mintplayer-ng-bootstrap-tab-control.d.ts +0 -50
  262. package/types/mintplayer-ng-bootstrap-table.d.ts +0 -24
  263. package/types/mintplayer-ng-bootstrap-tile-manager.d.ts +0 -304
  264. package/types/mintplayer-ng-bootstrap-timepicker.d.ts +0 -26
  265. package/types/mintplayer-ng-bootstrap-toast.d.ts +0 -67
  266. package/types/mintplayer-ng-bootstrap-toggle-button.d.ts +0 -57
  267. package/types/mintplayer-ng-bootstrap-tooltip.d.ts +0 -29
  268. package/types/mintplayer-ng-bootstrap-treeview.d.ts +0 -44
  269. package/types/mintplayer-ng-bootstrap-trust-html.d.ts +0 -12
  270. package/types/mintplayer-ng-bootstrap-typeahead.d.ts +0 -34
  271. package/types/mintplayer-ng-bootstrap-uc-first.d.ts +0 -10
  272. package/types/mintplayer-ng-bootstrap-user-agent.d.ts +0 -27
  273. package/types/mintplayer-ng-bootstrap-viewport.d.ts +0 -16
  274. package/types/mintplayer-ng-bootstrap-virtual-datatable.d.ts +0 -68
  275. package/types/mintplayer-ng-bootstrap-web-components-a11y.d.ts +0 -34
  276. package/types/mintplayer-ng-bootstrap-web-components-scheduler-core.d.ts +0 -914
  277. package/types/mintplayer-ng-bootstrap-web-components-scheduler.d.ts +0 -600
  278. package/types/mintplayer-ng-bootstrap-web-components-splitter.d.ts +0 -223
  279. package/types/mintplayer-ng-bootstrap-web-components-tab-control.d.ts +0 -95
  280. package/types/mintplayer-ng-bootstrap-word-count.d.ts +0 -10
@@ -1,4101 +0,0 @@
1
- import * as i0 from '@angular/core';
2
- import { input, viewChild, TemplateRef, ChangeDetectionStrategy, Component, computed, output, signal, contentChildren, inject, effect, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
3
- import { DOCUMENT, NgTemplateOutlet } from '@angular/common';
4
- import { html, unsafeCSS, LitElement } from 'lit';
5
- import '@mintplayer/ng-bootstrap/web-components/tab-control';
6
- import '@mintplayer/ng-bootstrap/web-components/splitter';
7
- import { LiveAnnouncerController } from '@mintplayer/ng-bootstrap/web-components/a11y';
8
-
9
- class BsDockPaneComponent {
10
- constructor() {
11
- this.name = input.required(...(ngDevMode ? [{ debugName: "name" }] : /* istanbul ignore next */ []));
12
- this.title = input(undefined, ...(ngDevMode ? [{ debugName: "title" }] : /* istanbul ignore next */ []));
13
- this.template = viewChild.required(TemplateRef);
14
- }
15
- ngAfterContentInit() {
16
- if (!this.name()) {
17
- throw new Error('bs-dock-pane requires a unique "name" input.');
18
- }
19
- }
20
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.11", ngImport: i0, type: BsDockPaneComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
21
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "21.2.11", type: BsDockPaneComponent, isStandalone: true, selector: "bs-dock-pane", inputs: { name: { classPropertyName: "name", publicName: "name", isSignal: true, isRequired: true, transformFunction: null }, title: { classPropertyName: "title", publicName: "title", isSignal: true, isRequired: false, transformFunction: null } }, viewQueries: [{ propertyName: "template", first: true, predicate: TemplateRef, descendants: true, isSignal: true }], ngImport: i0, template: `<ng-template><ng-content></ng-content></ng-template>`, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
22
- }
23
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.11", ngImport: i0, type: BsDockPaneComponent, decorators: [{
24
- type: Component,
25
- args: [{
26
- selector: 'bs-dock-pane',
27
- template: `<ng-template><ng-content></ng-content></ng-template>`,
28
- changeDetection: ChangeDetectionStrategy.OnPush,
29
- }]
30
- }], propDecorators: { name: [{ type: i0.Input, args: [{ isSignal: true, alias: "name", required: true }] }], title: [{ type: i0.Input, args: [{ isSignal: true, alias: "title", required: false }] }], template: [{ type: i0.ViewChild, args: [i0.forwardRef(() => TemplateRef), { isSignal: true }] }] } });
31
-
32
- // AUTO-GENERATED — do not edit by hand.
33
- // Source: mint-dock-manager.element.html + mint-dock-manager.element.scss
34
- // Regenerate with the codegen-wc Nx target.
35
- const template = html `<div class="dock-root">
36
- <div class="dock-docked"></div>
37
- <div class="dock-floating-layer"></div>
38
- <div class="dock-intersections-layer dock-intersection-layer"></div>
39
- </div>
40
- <div class="dock-drop-indicator"></div>
41
- <div class="dock-drop-joystick" data-visible="false">
42
- <div class="dock-drop-joystick__spacer"></div>
43
- <button
44
- class="dock-drop-joystick__button"
45
- type="button"
46
- data-zone="top"
47
- aria-label="Dock to top"
48
- >
49
- ↑
50
- </button>
51
- <div class="dock-drop-joystick__spacer"></div>
52
- <button
53
- class="dock-drop-joystick__button"
54
- type="button"
55
- data-zone="left"
56
- aria-label="Dock to left"
57
- >
58
- ←
59
- </button>
60
- <button
61
- class="dock-drop-joystick__button"
62
- type="button"
63
- data-zone="center"
64
- aria-label="Dock to center"
65
- >
66
- •
67
- </button>
68
- <button
69
- class="dock-drop-joystick__button"
70
- type="button"
71
- data-zone="right"
72
- aria-label="Dock to right"
73
- >
74
- →
75
- </button>
76
- <div class="dock-drop-joystick__spacer"></div>
77
- <button
78
- class="dock-drop-joystick__button"
79
- type="button"
80
- data-zone="bottom"
81
- aria-label="Dock to bottom"
82
- >
83
- ↓
84
- </button>
85
- <div class="dock-drop-joystick__spacer"></div>
86
- </div>`;
87
- const styles = unsafeCSS(`:host {
88
- display: block;
89
- position: relative;
90
- width: 100%;
91
- height: 100%;
92
- contain: layout paint size style;
93
- box-sizing: border-box;
94
- font-family: inherit;
95
- color: inherit;
96
- --dock-split-gap: 0.25rem;
97
- }
98
-
99
- .dock-root,
100
- .dock-docked,
101
- .dock-split,
102
- .dock-stack,
103
- .dock-stack__pane {
104
- box-sizing: border-box;
105
- min-width: 0;
106
- min-height: 0;
107
- }
108
-
109
- .dock-root {
110
- position: relative;
111
- width: 100%;
112
- height: 100%;
113
- }
114
-
115
- .dock-docked {
116
- position: absolute;
117
- inset: 0;
118
- display: flex;
119
- z-index: 0;
120
- }
121
-
122
- .dock-floating-layer {
123
- position: absolute;
124
- inset: 0;
125
- pointer-events: none;
126
- z-index: 5;
127
- }
128
-
129
- .dock-intersections-layer {
130
- position: absolute;
131
- inset: 0;
132
- pointer-events: none;
133
- z-index: 120;
134
- }
135
-
136
- .dock-floating {
137
- position: absolute;
138
- display: flex;
139
- flex-direction: column;
140
- pointer-events: auto;
141
- border: 1px solid var(--bs-border-color);
142
- border-radius: 0.5rem;
143
- background: var(--bs-body-bg);
144
- box-shadow: var(--bs-box-shadow-lg);
145
- overflow: hidden;
146
- min-width: 12rem;
147
- min-height: 8rem;
148
- }
149
-
150
- .dock-floating[data-dragging=true] {
151
- pointer-events: none;
152
- }
153
-
154
- .dock-floating__chrome {
155
- display: flex;
156
- align-items: center;
157
- gap: 0.5rem;
158
- padding: 0.35rem 0.75rem;
159
- cursor: move;
160
- touch-action: none;
161
- background: linear-gradient(to bottom, rgba(var(--bs-primary-rgb), 0.15), rgba(var(--bs-primary-rgb), 0.05));
162
- border-bottom: 1px solid var(--bs-primary-border-subtle);
163
- user-select: none;
164
- -webkit-user-select: none;
165
- }
166
-
167
- .dock-floating__title {
168
- flex: 1 1 auto;
169
- font-size: 0.875rem;
170
- font-weight: 500;
171
- color: var(--bs-body-color);
172
- overflow: hidden;
173
- text-overflow: ellipsis;
174
- white-space: nowrap;
175
- }
176
-
177
- .dock-floating__close {
178
- flex: 0 0 auto;
179
- appearance: none;
180
- background: transparent;
181
- border: 0;
182
- color: var(--bs-body-color);
183
- cursor: pointer;
184
- font-size: 1.25rem;
185
- line-height: 1;
186
- padding: 0 0.4rem;
187
- border-radius: 3px;
188
- margin-top: -1px;
189
- }
190
- .dock-floating__close:hover {
191
- background: rgba(var(--bs-primary-rgb), 0.15);
192
- }
193
- .dock-floating__close:focus-visible {
194
- outline: 2px solid var(--bs-primary);
195
- outline-offset: 1px;
196
- }
197
-
198
- .dock-floating > .dock-stack {
199
- flex: 1 1 auto;
200
- min-width: 12rem;
201
- min-height: 8rem;
202
- }
203
-
204
- .dock-floating__resizer {
205
- position: absolute;
206
- pointer-events: auto;
207
- z-index: 2;
208
- background: rgba(var(--bs-primary-rgb), 0.1);
209
- transition: background 120ms ease;
210
- touch-action: none;
211
- }
212
-
213
- .dock-floating__resizer:hover,
214
- .dock-floating__resizer[data-resizing=true] {
215
- background: rgba(var(--bs-primary-rgb), 0.3);
216
- }
217
-
218
- .dock-floating__resizer--top,
219
- .dock-floating__resizer--bottom {
220
- left: 0.75rem;
221
- right: 0.75rem;
222
- height: 0.5rem;
223
- }
224
-
225
- .dock-floating__resizer--top {
226
- top: 0;
227
- cursor: n-resize;
228
- }
229
-
230
- .dock-floating__resizer--bottom {
231
- bottom: 0;
232
- cursor: s-resize;
233
- }
234
-
235
- .dock-floating__resizer--left,
236
- .dock-floating__resizer--right {
237
- top: 1.75rem;
238
- bottom: 0.75rem;
239
- width: 0.5rem;
240
- }
241
-
242
- .dock-floating__resizer--left {
243
- left: 0;
244
- cursor: w-resize;
245
- }
246
-
247
- .dock-floating__resizer--right {
248
- right: 0;
249
- cursor: e-resize;
250
- }
251
-
252
- .dock-floating__resizer--top-left,
253
- .dock-floating__resizer--top-right,
254
- .dock-floating__resizer--bottom-left,
255
- .dock-floating__resizer--bottom-right {
256
- width: 0.75rem;
257
- height: 0.75rem;
258
- }
259
-
260
- .dock-floating__resizer--top-left {
261
- top: 0;
262
- left: 0;
263
- cursor: nw-resize;
264
- }
265
-
266
- .dock-floating__resizer--top-right {
267
- top: 0;
268
- right: 0;
269
- cursor: ne-resize;
270
- }
271
-
272
- .dock-floating__resizer--bottom-left {
273
- bottom: 0;
274
- left: 0;
275
- cursor: sw-resize;
276
- }
277
-
278
- .dock-floating__resizer--bottom-right {
279
- right: 0;
280
- bottom: 0;
281
- cursor: se-resize;
282
- }
283
-
284
- .dock-split {
285
- flex: 1 1 0;
286
- position: relative;
287
- }
288
-
289
- .dock-intersection-handle {
290
- position: absolute;
291
- width: 1rem;
292
- height: 1rem;
293
- margin-left: -0.5rem;
294
- margin-top: -0.5rem;
295
- border-radius: 0.375rem;
296
- background: var(--bs-primary-bg-subtle);
297
- border: 1px solid var(--bs-primary-border-subtle);
298
- box-shadow: var(--bs-box-shadow-sm);
299
- cursor: all-scroll;
300
- pointer-events: auto;
301
- touch-action: none;
302
- opacity: 0.45;
303
- transition: background 120ms ease, border-color 120ms ease, opacity 120ms ease;
304
- }
305
-
306
- .dock-intersection-handle:hover,
307
- .dock-intersection-handle:focus-visible,
308
- .dock-intersection-handle[data-visible=true],
309
- .dock-intersection-handle[data-resizing=true] {
310
- background: rgba(var(--bs-primary-rgb), 0.35);
311
- border-color: var(--bs-primary);
312
- opacity: 1;
313
- }
314
-
315
- .dock-intersection-handle:focus-visible {
316
- outline: 2px solid var(--bs-primary);
317
- outline-offset: 1px;
318
- }
319
-
320
- .dock-snap-marker {
321
- position: absolute;
322
- width: 6px;
323
- height: 6px;
324
- margin-left: -3px;
325
- margin-top: -3px;
326
- border-radius: 50%;
327
- background: var(--bs-primary);
328
- box-shadow: 0 0 0 2px var(--bs-primary-bg-subtle);
329
- pointer-events: none;
330
- z-index: 130;
331
- }
332
-
333
- .dock-stack {
334
- flex: 1 1 0;
335
- border: 1px solid var(--bs-border-color);
336
- border-radius: 0.25rem;
337
- background: var(--bs-body-bg);
338
- backdrop-filter: blur(4px);
339
- }
340
-
341
- .dock-tab {
342
- cursor: grab;
343
- display: block;
344
- padding: 0.5rem 1rem;
345
- margin: -0.5rem -1rem;
346
- touch-action: none;
347
- user-select: none;
348
- -webkit-user-select: none;
349
- -webkit-touch-callout: none;
350
- }
351
-
352
- .dock-tab:active {
353
- cursor: grabbing;
354
- }
355
-
356
- .dock-tab[data-pressing=true] {
357
- background-color: var(--bs-secondary-bg-subtle, rgba(0, 0, 0, 0.05));
358
- transform: scale(1.02);
359
- transition: background-color 100ms ease-out, transform 100ms ease-out;
360
- }
361
-
362
- .dock-stack__pane {
363
- position: relative;
364
- display: flex;
365
- flex-direction: column;
366
- overflow: hidden;
367
- height: 100%;
368
- }
369
-
370
- .dock-drop-indicator {
371
- position: absolute;
372
- pointer-events: none;
373
- border: 2px solid var(--bs-primary);
374
- background: rgba(var(--bs-primary-rgb), 0.2);
375
- border-radius: 0.25rem;
376
- opacity: 0;
377
- transition: opacity 120ms ease;
378
- z-index: 100;
379
- }
380
-
381
- .dock-drop-indicator[data-visible=true] {
382
- opacity: 1;
383
- }
384
-
385
- .dock-drop-joystick {
386
- position: absolute;
387
- display: grid;
388
- grid-template-columns: repeat(3, min-content);
389
- grid-template-rows: repeat(3, min-content);
390
- gap: 0.125rem;
391
- padding: 0.125rem;
392
- border-radius: 999px;
393
- background: var(--bs-tertiary-bg);
394
- box-shadow: var(--bs-box-shadow);
395
- pointer-events: none;
396
- transform: translate(-50%, -50%);
397
- z-index: 110;
398
- }
399
-
400
- .dock-drop-joystick__spacer {
401
- width: 1.75rem;
402
- height: 1.75rem;
403
- pointer-events: none;
404
- }
405
-
406
- .dock-drop-joystick__button {
407
- width: 1.75rem;
408
- height: 1.75rem;
409
- display: inline-flex;
410
- align-items: center;
411
- justify-content: center;
412
- border-radius: 0.375rem;
413
- border: 1px solid var(--bs-primary-border-subtle);
414
- background: var(--bs-body-bg);
415
- color: var(--bs-primary);
416
- font-size: 0.75rem;
417
- line-height: 1;
418
- font-weight: 600;
419
- pointer-events: auto;
420
- cursor: pointer;
421
- transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
422
- }
423
-
424
- .dock-drop-joystick__button[data-active=true],
425
- .dock-drop-joystick__button:hover,
426
- .dock-drop-joystick__button:focus-visible {
427
- background: var(--bs-primary-bg-subtle);
428
- border-color: var(--bs-primary);
429
- color: var(--bs-primary);
430
- }
431
-
432
- .dock-drop-joystick__button:focus-visible {
433
- outline: 2px solid var(--bs-primary);
434
- outline-offset: 1px;
435
- }
436
-
437
- .dock-drop-joystick__button[data-zone=center] {
438
- border-radius: 0.5rem;
439
- }
440
-
441
- ::slotted(*) {
442
- flex: 1 1 auto;
443
- display: block;
444
- min-width: 0;
445
- min-height: 0;
446
- }
447
-
448
- @media (prefers-reduced-motion: reduce) {
449
- .dock-floating,
450
- .dock-floating__resizer,
451
- .dock-floating__close,
452
- .dock-intersection-handle,
453
- .dock-drop-indicator,
454
- .dock-drop-joystick__button {
455
- transition: none !important;
456
- animation: none !important;
457
- }
458
- }`);
459
-
460
- class MintDockManagerElement extends LitElement {
461
- static { this.styles = [styles]; }
462
- static { this.documentRef = typeof document !== 'undefined' ? document : null; }
463
- static configureDocument(documentRef) {
464
- if (documentRef) {
465
- MintDockManagerElement.documentRef = documentRef;
466
- }
467
- }
468
- static get observedAttributes() {
469
- return [...(super.observedAttributes ?? []), 'layout', 'debug-layout-integrity'];
470
- }
471
- static { this.instanceCounter = 0; }
472
- // Touch tab-drag gesture: a finger that lands on a tab header must be able
473
- // to scroll the tabstrip natively. We require a stationary hold before
474
- // arming the drag, so a horizontal swipe scrolls instead of undocking.
475
- // See docs/prd/dock-touch-long-press-drag.md.
476
- static { this.TOUCH_LONG_PRESS_MS = 600; }
477
- static { this.TOUCH_LONG_PRESS_SLOP_PX = 10; }
478
- static { this.TOUCH_PRESS_FEEDBACK_DELAY_MS = 150; }
479
- renderSnapMarkersForCorner() {
480
- if (!this.showSnapMarkers)
481
- return;
482
- const layer = this.shadowRoot?.querySelector('.dock-intersections-layer, .dock-intersection-layer');
483
- if (!layer)
484
- return;
485
- Array.from(layer.querySelectorAll('.dock-snap-marker')).forEach((el) => el.remove());
486
- if (!this.cornerResizeState)
487
- return;
488
- const rootRect = this.rootEl.getBoundingClientRect();
489
- // Compute representative center lines from the dividers being resized.
490
- // st.{hs,vs}[i].container is the <mp-splitter>; the divider lives in its
491
- // shadow at getSplitterDividers(splitter)[index].
492
- let centerX = null;
493
- let centerY = null;
494
- const st = this.cornerResizeState;
495
- if (st.vs.length > 0) {
496
- const v0 = st.vs[0];
497
- const vDiv = this.getSplitterDividers(v0.container)[v0.index];
498
- const vRect = vDiv?.getBoundingClientRect();
499
- if (vRect)
500
- centerX = vRect.left + vRect.width / 2 - rootRect.left;
501
- }
502
- if (st.hs.length > 0) {
503
- const h0 = st.hs[0];
504
- const hDiv = this.getSplitterDividers(h0.container)[h0.index];
505
- const hRect = hDiv?.getBoundingClientRect();
506
- if (hRect)
507
- centerY = hRect.top + hRect.height / 2 - rootRect.top;
508
- }
509
- if (centerY != null) {
510
- this.cornerSnapXTargets.forEach((sx) => {
511
- const dot = this.documentRef.createElement('div');
512
- dot.className = 'dock-snap-marker';
513
- dot.style.left = `${sx}px`;
514
- dot.style.top = `${centerY}px`;
515
- layer.appendChild(dot);
516
- });
517
- }
518
- if (centerX != null) {
519
- this.cornerSnapYTargets.forEach((sy) => {
520
- const dot = this.documentRef.createElement('div');
521
- dot.className = 'dock-snap-marker';
522
- dot.style.left = `${centerX}px`;
523
- dot.style.top = `${sy}px`;
524
- layer.appendChild(dot);
525
- });
526
- }
527
- }
528
- clearSnapMarkers() {
529
- if (!this.showSnapMarkers)
530
- return;
531
- const layer = this.shadowRoot?.querySelector('.dock-intersections-layer, .dock-intersection-layer');
532
- if (!layer)
533
- return;
534
- Array.from(layer.querySelectorAll('.dock-snap-marker')).forEach((el) => el.remove());
535
- }
536
- constructor() {
537
- super();
538
- this.liveAnnouncer = new LiveAnnouncerController(this);
539
- /**
540
- * Active keyboard-driven pane move (Phase 7 of WC ARIA PRD). The user
541
- * pressed M on a focused tab; until they pick a destination key (T/R/B/L
542
- * to dock to a side, F to float) or Escape, we intercept letter keys and
543
- * route them to the synthetic-drop pipeline.
544
- */
545
- this.paneMoveMode = null;
546
- this.dropJoystickTarget = null;
547
- this.rootLayout = null;
548
- this.floatingLayouts = [];
549
- this.titles = {};
550
- this.pendingTabDragMetrics = null;
551
- this.dragState = null;
552
- this.floatingDragState = null;
553
- this.floatingResizeState = null;
554
- this.intersectionRaf = null;
555
- this.rootResizeObserver = null;
556
- this.dockedMutationObserver = null;
557
- this.cornerResizeState = null;
558
- this.pointerTrackingActive = false;
559
- this.dragPointerTrackingActive = false;
560
- this.lastDragPointerPosition = null;
561
- // Localized snapping while dragging an intersection handle
562
- this.cornerSnapXTargets = [];
563
- this.cornerSnapYTargets = [];
564
- // Debug: render snap markers while dragging
565
- this.showSnapMarkers = false;
566
- // Debug: assert every pane has a projection slot in shadow DOM after each
567
- // render. Off by default so production hosts pay no overhead; demo enables
568
- // it via the `debug-layout-integrity` attribute to catch layout-tree bugs
569
- // loudly during development.
570
- this.debugLayoutIntegrity = false;
571
- this.pendingDragEndTimeout = null;
572
- this.previousSplitSizes = new Map();
573
- this.instanceId = `mint-dock-${++MintDockManagerElement.instanceCounter}`;
574
- // Set windowRef eagerly so connectedCallback's window-level drag listeners
575
- // (added before firstUpdated runs) can actually attach. Without this,
576
- // win?.addEventListener was a silent no-op on first connect and HTML5
577
- // drag-to-detach gestures never reached the dock — the floating wrapper
578
- // was created but stayed at its conversion-time coordinates because the
579
- // 'drag' listener that updates its position was never attached.
580
- this.windowRef = typeof window !== 'undefined' ? window : null;
581
- this.onPointerMove = this.onPointerMove.bind(this);
582
- this.onPointerUp = this.onPointerUp.bind(this);
583
- this.onDragPointerMove = this.onDragPointerMove.bind(this);
584
- this.onDragPointerUp = this.onDragPointerUp.bind(this);
585
- this.onDragPointerCancel = this.onDragPointerCancel.bind(this);
586
- this.onSplitterResize = this.onSplitterResize.bind(this);
587
- }
588
- render() {
589
- return html `${template}${this.liveAnnouncer.template()}`;
590
- }
591
- firstUpdated() {
592
- // Resolve document and window now that we are connected.
593
- const documentRef = this.resolveDocument();
594
- this.documentRef = documentRef;
595
- this.windowRef = this.resolveWindow(documentRef);
596
- // Query the rendered shadow DOM for the dock skeleton.
597
- const shadowRoot = this.shadowRoot;
598
- const root = shadowRoot.querySelector('.dock-root');
599
- if (!root) {
600
- throw new Error('mint-dock-manager template is missing the root element.');
601
- }
602
- const docked = shadowRoot.querySelector('.dock-docked');
603
- if (!docked) {
604
- throw new Error('mint-dock-manager template is missing the docked surface element.');
605
- }
606
- const floatingLayer = shadowRoot.querySelector('.dock-floating-layer');
607
- if (!floatingLayer) {
608
- throw new Error('mint-dock-manager template is missing the floating layer element.');
609
- }
610
- const indicator = shadowRoot.querySelector('.dock-drop-indicator');
611
- if (!indicator) {
612
- throw new Error('mint-dock-manager template is missing the drop indicator element.');
613
- }
614
- const joystick = shadowRoot.querySelector('.dock-drop-joystick');
615
- if (!joystick) {
616
- throw new Error('mint-dock-manager template is missing the drop joystick element.');
617
- }
618
- const joystickButtons = Array.from(joystick.querySelectorAll('.dock-drop-joystick__button[data-zone]'));
619
- if (joystickButtons.length === 0) {
620
- throw new Error('mint-dock-manager template is missing drop joystick buttons.');
621
- }
622
- this.rootEl = root;
623
- this.dockedEl = docked;
624
- this.floatingLayerEl = floatingLayer;
625
- this.dropIndicator = indicator;
626
- this.dropJoystick = joystick;
627
- this.dropJoystickButtons = joystickButtons;
628
- // Tag the docked surface with a root path so it can act as
629
- // a drop target when the main layout is empty.
630
- this.dockedEl.dataset['path'] = this.formatPath({ type: 'docked', segments: [] });
631
- // Drop targeting (drop indicator + joystick zone selection) runs entirely
632
- // off pointer-based hit-testing in updatePaneDragDropTargetFromPoint and
633
- // findDropZoneByPoint — no HTML5 dragover/drop/dragleave listeners needed.
634
- // Keyboard pane-move (Phase 7). Capture phase so we run before mp-tab-control's
635
- // shadow-internal handlers preventDefault on Arrow / Home / End / Enter.
636
- root.addEventListener('keydown', (ev) => this.onRootKeyDown(ev), { capture: true });
637
- // Render any layout that was set before the shadow DOM existed.
638
- this.renderLayout();
639
- // Reactive triggers for intersection-handle re-rendering. Each observer
640
- // wakes scheduleRenderIntersectionHandles() (rAF-coalesced), which means
641
- // multiple notifications in the same frame collapse to one render and
642
- // the rAF tick gives <mp-splitter> elements time to populate their
643
- // shadow roots before we query their dividers.
644
- this.rootResizeObserver = new ResizeObserver(() => this.scheduleRenderIntersectionHandles());
645
- this.rootResizeObserver.observe(this.rootEl);
646
- this.dockedMutationObserver = new MutationObserver(() => this.scheduleRenderIntersectionHandles());
647
- this.dockedMutationObserver.observe(this.dockedEl, { childList: true, subtree: true });
648
- // mp-splitter dispatches bubbling 'resizing' / 'resize-end' on user drag;
649
- // delegating on dockedEl catches every nested splitter without per-instance wiring.
650
- this.dockedEl.addEventListener('resizing', this.onSplitterResize);
651
- this.dockedEl.addEventListener('resize-end', this.onSplitterResize);
652
- }
653
- connectedCallback() {
654
- super.connectedCallback();
655
- if (!this.hasAttribute('role')) {
656
- this.setAttribute('role', 'application');
657
- }
658
- }
659
- disconnectedCallback() {
660
- const win = this.windowRef;
661
- this.stopDragPointerTracking();
662
- win?.removeEventListener('pointermove', this.onPointerMove);
663
- win?.removeEventListener('pointerup', this.onPointerUp);
664
- this.pointerTrackingActive = false;
665
- this.rootResizeObserver?.disconnect();
666
- this.rootResizeObserver = null;
667
- this.dockedMutationObserver?.disconnect();
668
- this.dockedMutationObserver = null;
669
- this.dockedEl?.removeEventListener('resizing', this.onSplitterResize);
670
- this.dockedEl?.removeEventListener('resize-end', this.onSplitterResize);
671
- if (this.intersectionRaf !== null) {
672
- this.windowRef?.clearTimeout(this.intersectionRaf);
673
- this.intersectionRaf = null;
674
- }
675
- super.disconnectedCallback();
676
- }
677
- attributeChangedCallback(name, _oldValue, newValue) {
678
- super.attributeChangedCallback(name, _oldValue, newValue);
679
- if (name === 'layout') {
680
- this.layout = newValue ? this.parseLayout(newValue) : null;
681
- }
682
- else if (name === 'debug-snap-markers') {
683
- this.showSnapMarkers = !(newValue === null || newValue === 'false' || newValue === '0');
684
- if (!this.showSnapMarkers) {
685
- this.clearSnapMarkers();
686
- }
687
- }
688
- else if (name === 'debug-layout-integrity') {
689
- this.debugLayoutIntegrity = !(newValue === null || newValue === 'false' || newValue === '0');
690
- }
691
- }
692
- get layout() {
693
- return {
694
- root: this.cloneLayoutNode(this.rootLayout),
695
- floating: this.cloneFloatingArray(this.floatingLayouts),
696
- titles: { ...this.titles },
697
- };
698
- }
699
- set layout(value) {
700
- const snapshot = this.ensureSnapshot(value);
701
- // While a drag/resize is in flight, the dock manager is the source of
702
- // truth for layout state — its mid-drag mutations (e.g. floating bounds
703
- // updated every mousemove, or a stack split during a pane-drag-to-floating
704
- // conversion) race the host's two-way binding round-trip. The host re-
705
- // feeds the layout we *just* dispatched via `dock-layout-changed`, but by
706
- // the time the round-trip arrives the user has moved the cursor again, so
707
- // the structural-equality guard below would let it through and clobber the
708
- // in-progress state (e.g. snap a freshly-detached floating window back to
709
- // the converted-at coordinates instead of letting it follow the cursor).
710
- // Reject any external layout write during interaction; the host will sync
711
- // back to the dock's final state when interaction ends and the dock fires
712
- // a fresh dock-layout-changed event.
713
- if (this.isInteracting())
714
- return;
715
- // Skip renderLayout when the incoming layout is structurally identical
716
- // to the current state. After a divider drag the dock dispatches
717
- // dock-layout-changed; an Angular host doing two-way binding will feed
718
- // that snapshot right back through `[layout]` (and through the
719
- // `[attr.layout]` round-trip). Without this guard, every drag-end
720
- // tears down and rebuilds the whole splitter tree, giving a one-frame
721
- // flash of `flex: 1 1 0` equal-share before the pin restores sizes.
722
- const currentJson = JSON.stringify({
723
- root: this.rootLayout,
724
- floating: this.floatingLayouts,
725
- titles: this.titles,
726
- });
727
- const newJson = JSON.stringify(snapshot);
728
- if (currentJson === newJson)
729
- return;
730
- this.rootLayout = this.cloneLayoutNode(snapshot.root);
731
- this.floatingLayouts = this.cloneFloatingArray(snapshot.floating);
732
- this.titles = snapshot.titles ? { ...snapshot.titles } : {};
733
- // Sanitize whatever the host fed us: empty stacks, 0/1-child splits, and
734
- // nested same-direction splits get pruned/flattened before we render.
735
- this.normalizeAllLayouts();
736
- this.renderLayout();
737
- }
738
- /**
739
- * True while the user is actively interacting with the dock — pane drag,
740
- * floating window drag, floating window resize, or intersection corner
741
- * resize. The `set layout` setter consults this to refuse external
742
- * round-trips that would overwrite in-progress drag state.
743
- */
744
- isInteracting() {
745
- return !!(this.dragState ||
746
- this.floatingDragState ||
747
- this.floatingResizeState ||
748
- this.cornerResizeState);
749
- }
750
- get snapshot() {
751
- return this.layout;
752
- }
753
- toJSON() {
754
- return this.snapshot;
755
- }
756
- resolveDocument() {
757
- const staticDocument = MintDockManagerElement.documentRef;
758
- const ownerDocument = this.ownerDocument ?? null;
759
- const globalDocument = typeof document !== 'undefined' ? document : null;
760
- const resolvedDocument = staticDocument ?? ownerDocument ?? globalDocument;
761
- if (!resolvedDocument) {
762
- throw new Error('mint-dock-manager requires a Document to initialize.');
763
- }
764
- if (!MintDockManagerElement.documentRef) {
765
- MintDockManagerElement.documentRef = resolvedDocument;
766
- }
767
- return resolvedDocument;
768
- }
769
- resolveWindow(documentRef) {
770
- if (typeof window !== 'undefined') {
771
- return window;
772
- }
773
- return documentRef.defaultView ?? null;
774
- }
775
- parseLayout(value) {
776
- try {
777
- const parsed = JSON.parse(value);
778
- return this.ensureSnapshot(parsed);
779
- }
780
- catch (err) {
781
- console.warn('mint-dock-manager: failed to parse layout attribute', err);
782
- return null;
783
- }
784
- }
785
- ensureSnapshot(value) {
786
- if (!value) {
787
- return { root: null, floating: [], titles: {} };
788
- }
789
- if (value.kind) {
790
- return { root: value, floating: [], titles: {} };
791
- }
792
- const layout = value;
793
- return {
794
- root: layout.root ?? null,
795
- floating: Array.isArray(layout.floating)
796
- ? layout.floating.map((floating) => this.normalizeFloatingLayout(floating))
797
- : [],
798
- titles: layout.titles ? { ...layout.titles } : {},
799
- };
800
- }
801
- renderLayout() {
802
- // The layout setter may run before firstUpdated() has populated the
803
- // shadow-DOM fields (e.g. when an attribute is set on the markup).
804
- // Bail out; firstUpdated() will call renderLayout() once ready.
805
- if (!this.dockedEl)
806
- return;
807
- this.dockedEl.innerHTML = '';
808
- this.floatingLayerEl.innerHTML = '';
809
- this.hideDropIndicator();
810
- if (this.rootLayout) {
811
- const fragment = this.renderNode(this.rootLayout, []);
812
- this.dockedEl.appendChild(fragment);
813
- }
814
- this.renderFloatingPanes();
815
- // Note: intersection handles are repositioned reactively via observers
816
- // wired up in firstUpdated (rootResizeObserver, dockedMutationObserver,
817
- // and delegated 'resizing' / 'resize-end' events). The MutationObserver
818
- // on dockedEl fires when the renderNode subtree above is appended.
819
- this.verifyProjectionSlots();
820
- }
821
- renderNode(node, path, floatingIndex) {
822
- if (node.kind === 'split') {
823
- return this.renderSplit(node, path, floatingIndex);
824
- }
825
- return this.renderStack(node, path, floatingIndex);
826
- }
827
- renderFloatingPanes() {
828
- this.floatingLayerEl.innerHTML = '';
829
- this.floatingLayouts.forEach((floating, index) => {
830
- const wrapper = this.documentRef.createElement('div');
831
- wrapper.classList.add('dock-floating');
832
- wrapper.dataset['path'] = this.formatPath({
833
- type: 'floating',
834
- index,
835
- segments: [],
836
- });
837
- const titleText = this.getFloatingWindowTitle(floating);
838
- const titleId = `${this.instanceId}-floating-${index}-title`;
839
- // role=dialog announces the window-like region; aria-modal=false because
840
- // floating panes don't trap focus — users can still interact with docked
841
- // panes behind them.
842
- wrapper.setAttribute('role', 'dialog');
843
- wrapper.setAttribute('aria-labelledby', titleId);
844
- wrapper.setAttribute('aria-modal', 'false');
845
- const { left, top, width, height } = floating.bounds;
846
- wrapper.style.left = `${left}px`;
847
- wrapper.style.top = `${top}px`;
848
- wrapper.style.width = `${width}px`;
849
- wrapper.style.height = `${height}px`;
850
- const zIndex = this.getFloatingPaneZIndex(index);
851
- wrapper.style.zIndex = String(zIndex);
852
- const chrome = this.documentRef.createElement('div');
853
- chrome.classList.add('dock-floating__chrome');
854
- chrome.addEventListener('pointerdown', (event) => this.beginFloatingDrag(event, index, wrapper, chrome));
855
- const title = this.documentRef.createElement('div');
856
- title.classList.add('dock-floating__title');
857
- title.id = titleId;
858
- title.textContent = titleText;
859
- chrome.appendChild(title);
860
- const closeBtn = this.documentRef.createElement('button');
861
- closeBtn.type = 'button';
862
- closeBtn.classList.add('dock-floating__close');
863
- closeBtn.setAttribute('aria-label', `Close pane: ${titleText}`);
864
- closeBtn.textContent = '×';
865
- closeBtn.addEventListener('click', (ev) => {
866
- ev.stopPropagation();
867
- this.closeFloatingPane(index);
868
- });
869
- // The chrome's pointerdown otherwise begins a drag on the close button.
870
- closeBtn.addEventListener('pointerdown', (ev) => ev.stopPropagation());
871
- chrome.appendChild(closeBtn);
872
- wrapper.appendChild(chrome);
873
- if (floating.root) {
874
- const content = this.renderNode(floating.root, [], index);
875
- content.classList.add('dock-floating__stack');
876
- wrapper.appendChild(content);
877
- }
878
- else {
879
- const placeholder = this.documentRef.createElement('div');
880
- placeholder.classList.add('dock-stack');
881
- placeholder.dataset['path'] = this.formatPath({
882
- type: 'floating',
883
- index,
884
- segments: [],
885
- });
886
- const empty = this.documentRef.createElement('div');
887
- empty.classList.add('dock-stack__pane');
888
- empty.textContent = 'No panes configured';
889
- placeholder.appendChild(empty);
890
- wrapper.appendChild(placeholder);
891
- }
892
- const resizerConfigs = [
893
- {
894
- classes: ['dock-floating__resizer', 'dock-floating__resizer--top-left'],
895
- edges: { horizontal: 'left', vertical: 'top' },
896
- },
897
- {
898
- classes: ['dock-floating__resizer', 'dock-floating__resizer--top'],
899
- edges: { horizontal: 'none', vertical: 'top' },
900
- },
901
- {
902
- classes: ['dock-floating__resizer', 'dock-floating__resizer--top-right'],
903
- edges: { horizontal: 'right', vertical: 'top' },
904
- },
905
- {
906
- classes: ['dock-floating__resizer', 'dock-floating__resizer--right'],
907
- edges: { horizontal: 'right', vertical: 'none' },
908
- },
909
- {
910
- classes: ['dock-floating__resizer', 'dock-floating__resizer--bottom-right'],
911
- edges: { horizontal: 'right', vertical: 'bottom' },
912
- },
913
- {
914
- classes: ['dock-floating__resizer', 'dock-floating__resizer--bottom'],
915
- edges: { horizontal: 'none', vertical: 'bottom' },
916
- },
917
- {
918
- classes: ['dock-floating__resizer', 'dock-floating__resizer--bottom-left'],
919
- edges: { horizontal: 'left', vertical: 'bottom' },
920
- },
921
- {
922
- classes: ['dock-floating__resizer', 'dock-floating__resizer--left'],
923
- edges: { horizontal: 'left', vertical: 'none' },
924
- },
925
- ];
926
- resizerConfigs.forEach(({ classes, edges }) => {
927
- const resizer = this.documentRef.createElement('div');
928
- resizer.classList.add(...classes);
929
- resizer.setAttribute('role', 'separator');
930
- // For corner resizers (both axes), aria-orientation is omitted —
931
- // separator's default is "horizontal" but corner == both, so neither
932
- // value is correct. SR users still hear "separator" with the label.
933
- const isPureHorizontal = edges.horizontal === 'none' && edges.vertical !== 'none';
934
- const isPureVertical = edges.vertical === 'none' && edges.horizontal !== 'none';
935
- if (isPureHorizontal)
936
- resizer.setAttribute('aria-orientation', 'horizontal');
937
- else if (isPureVertical)
938
- resizer.setAttribute('aria-orientation', 'vertical');
939
- const labelParts = [];
940
- if (edges.vertical === 'top')
941
- labelParts.push('top');
942
- else if (edges.vertical === 'bottom')
943
- labelParts.push('bottom');
944
- if (edges.horizontal === 'left')
945
- labelParts.push('left');
946
- else if (edges.horizontal === 'right')
947
- labelParts.push('right');
948
- resizer.setAttribute('aria-label', `Resize pane ${labelParts.length === 2 ? 'corner ' : 'edge '}${labelParts.join('-')}`);
949
- resizer.addEventListener('pointerdown', (event) => this.beginFloatingResize(event, index, wrapper, resizer, edges));
950
- wrapper.appendChild(resizer);
951
- });
952
- this.floatingLayerEl.appendChild(wrapper);
953
- });
954
- }
955
- onSplitterResize() {
956
- // mp-splitter dispatches 'resizing' continuously during a divider drag
957
- // and 'resize-end' when the user releases. Both keep the handle glued
958
- // to the new intersection coordinate.
959
- this.scheduleRenderIntersectionHandles();
960
- }
961
- scheduleRenderIntersectionHandles() {
962
- if (this.intersectionRaf !== null)
963
- return;
964
- const win = this.windowRef;
965
- if (!win)
966
- return;
967
- // Defer with setTimeout(5) instead of rAF so we run AFTER any
968
- // flex-redistribution settles. Sequence we have to wait through:
969
- // (1) DOM mutation (e.g. panel removed by drop)
970
- // (2) microtasks: <mp-splitter>'s slotchange + size-pinning rAF
971
- // (3) layout flush
972
- // A bare rAF can fire before (2) resolves, so getBoundingClientRect on
973
- // the dividers reads a transient flex-distributed position and the
974
- // glyph lands ~tens of pixels off. 5ms is past the microtask queue and
975
- // past splitter's pinning rAF in practice, so the divider rects we
976
- // read are the settled, post-pin values.
977
- this.intersectionRaf = win.setTimeout(() => {
978
- this.intersectionRaf = null;
979
- this.renderIntersectionHandles();
980
- }, 5);
981
- }
982
- renderIntersectionHandles() {
983
- const layer = this.shadowRoot?.querySelector('.dock-intersections-layer, .dock-intersection-layer');
984
- if (!layer)
985
- return;
986
- const rootRect = this.rootEl.getBoundingClientRect();
987
- // Active corner-resize: keep st.handle alive (it owns pointer capture and
988
- // the cornerResizeState references it). Update its position from current
989
- // divider rects, drop every other handle by reference.
990
- if (this.cornerResizeState) {
991
- const st = this.cornerResizeState;
992
- const h0 = st.hs[0];
993
- const v0 = st.vs[0];
994
- const hSplitter = this.findSplitterByPath(h0.path.segments);
995
- const vSplitter = this.findSplitterByPath(v0.path.segments);
996
- const hDiv = hSplitter ? this.getSplitterDividers(hSplitter)[h0.index] : null;
997
- const vDiv = vSplitter ? this.getSplitterDividers(vSplitter)[v0.index] : null;
998
- if (hDiv && vDiv) {
999
- const hr = hDiv.getBoundingClientRect();
1000
- const vr = vDiv.getBoundingClientRect();
1001
- const x = vr.left + vr.width / 2 - rootRect.left;
1002
- const y = hr.top + hr.height / 2 - rootRect.top;
1003
- st.handle.style.left = `${x}px`;
1004
- st.handle.style.top = `${y}px`;
1005
- Array.from(layer.querySelectorAll('.dock-intersection-handle')).forEach((el) => {
1006
- if (el !== st.handle)
1007
- el.remove();
1008
- });
1009
- }
1010
- return;
1011
- }
1012
- // Idle path: full clear + rebuild. Cheaper to reason about than incremental
1013
- // diffing, and handles' positions are always derived from current divider
1014
- // rects so a layout change (drop, splitter restructure, flex redistribution)
1015
- // can never leave a stale glyph behind.
1016
- layer.replaceChildren();
1017
- const hDividers = [];
1018
- const vDividers = [];
1019
- const allSplitters = Array.from(this.shadowRoot?.querySelectorAll('.dock-split') ?? []);
1020
- allSplitters.forEach((splitter) => {
1021
- const direction = splitter.dataset['direction'];
1022
- const pathStr = splitter.dataset['path'] ?? '';
1023
- this.getSplitterDividers(splitter).forEach((el, index) => {
1024
- const info = { rect: el.getBoundingClientRect(), pathStr, index };
1025
- // direction='horizontal' means children flow left-to-right, so the
1026
- // divider bars between them are VERTICAL (and vice-versa).
1027
- if (direction === 'horizontal')
1028
- vDividers.push(info);
1029
- else if (direction === 'vertical')
1030
- hDividers.push(info);
1031
- });
1032
- });
1033
- // Group intersections that round to the same on-screen pixel, so two
1034
- // sibling splitters whose dividers happen to overlap share one handle.
1035
- const tol = 24;
1036
- const groups = new Map();
1037
- hDividers.forEach((h) => {
1038
- const hCenterY = h.rect.top + h.rect.height / 2;
1039
- vDividers.forEach((v) => {
1040
- const vCenterX = v.rect.left + v.rect.width / 2;
1041
- const dx = vCenterX < h.rect.left ? h.rect.left - vCenterX : vCenterX > h.rect.right ? vCenterX - h.rect.right : 0;
1042
- const dy = hCenterY < v.rect.top ? v.rect.top - hCenterY : hCenterY > v.rect.bottom ? hCenterY - v.rect.bottom : 0;
1043
- if (dx > tol || dy > tol)
1044
- return;
1045
- const x = vCenterX - rootRect.left;
1046
- const y = hCenterY - rootRect.top;
1047
- const gk = `${Math.round(x)}:${Math.round(y)}`;
1048
- const group = groups.get(gk) ?? { x, y, pairs: [] };
1049
- group.pairs.push({ h: { pathStr: h.pathStr, index: h.index }, v: { pathStr: v.pathStr, index: v.index } });
1050
- groups.set(gk, group);
1051
- });
1052
- });
1053
- groups.forEach((group, gk) => {
1054
- const handle = this.documentRef.createElement('div');
1055
- handle.classList.add('dock-intersection-handle', 'glyph');
1056
- handle.setAttribute('role', 'separator');
1057
- handle.setAttribute('aria-label', 'Resize split intersection');
1058
- // tabindex=0 — make the handle keyboard-reachable. Arrow keys then
1059
- // resize the underlying h/v dividers (handled in onIntersectionKeyDown).
1060
- handle.setAttribute('tabindex', '0');
1061
- const firstPair = group.pairs[0];
1062
- const key = `${firstPair.h.pathStr}:${firstPair.h.index}|${firstPair.v.pathStr}:${firstPair.v.index}`;
1063
- handle.dataset['key'] = key;
1064
- handle.dataset['pairs'] = JSON.stringify(group.pairs);
1065
- handle.style.left = `${group.x}px`;
1066
- handle.style.top = `${group.y}px`;
1067
- // beginCornerResize/onIntersectionDoubleClick read data-pairs to
1068
- // reconstruct the (h, v) pair list, so the (h, v) args we pass here
1069
- // are only used as a fallback when data-pairs is empty — safe to use
1070
- // the first pair's structure as the seed.
1071
- const seedH = { path: this.parsePath(firstPair.h.pathStr), index: firstPair.h.index, container: this.findSplitterByPath(this.parsePath(firstPair.h.pathStr)?.segments ?? []) ?? this.rootEl, rect: new DOMRect() };
1072
- const seedV = { path: this.parsePath(firstPair.v.pathStr), index: firstPair.v.index, container: this.findSplitterByPath(this.parsePath(firstPair.v.pathStr)?.segments ?? []) ?? this.rootEl, rect: new DOMRect() };
1073
- handle.addEventListener('pointerdown', (ev) => this.beginCornerResize(ev, seedH, seedV, handle));
1074
- handle.addEventListener('dblclick', (ev) => this.onIntersectionDoubleClick(ev, handle));
1075
- handle.addEventListener('keydown', (ev) => this.onIntersectionKeyDown(ev, handle));
1076
- layer.appendChild(handle);
1077
- });
1078
- }
1079
- /**
1080
- * Keyboard resize on a focused intersection handle. ArrowLeft/Right resize
1081
- * the vertical divider the handle sits on; ArrowUp/Down resize the
1082
- * horizontal divider. Home/End shrink/grow the leading panel of whichever
1083
- * axis is implied by the key. Shift = fine 1% step.
1084
- *
1085
- * Internally delegates to mp-splitter.resizeDividerBy() so the percent-step
1086
- * + clamp math lives in one place. If a 2D handle straddles multiple split
1087
- * pairs (sibling splitters whose dividers happen to overlap), the first
1088
- * pair drives — same precedence as the pointer drag path.
1089
- */
1090
- onIntersectionKeyDown(event, handle) {
1091
- const isVerticalAxis = event.key === 'ArrowLeft' || event.key === 'ArrowRight';
1092
- const isHorizontalAxis = event.key === 'ArrowUp' || event.key === 'ArrowDown';
1093
- const isHomeEnd = event.key === 'Home' || event.key === 'End';
1094
- if (!isVerticalAxis && !isHorizontalAxis && !isHomeEnd)
1095
- return;
1096
- const pairsJson = handle.dataset['pairs'];
1097
- if (!pairsJson)
1098
- return;
1099
- let pairs;
1100
- try {
1101
- pairs = JSON.parse(pairsJson);
1102
- }
1103
- catch {
1104
- return;
1105
- }
1106
- if (pairs.length === 0)
1107
- return;
1108
- event.preventDefault();
1109
- const fine = event.shiftKey;
1110
- // Which divider does this key drive? Arrow{Left,Right} → vertical
1111
- // (h-flow splitter, v-bar divider); Arrow{Up,Down} → horizontal. For
1112
- // Home/End, default to the vertical-axis divider (matches APG's "drive
1113
- // the splitter to its limit" convention on a horizontal layout).
1114
- const drivesVerticalDivider = isVerticalAxis || isHomeEnd;
1115
- const target = drivesVerticalDivider ? pairs[0].v : pairs[0].h;
1116
- const path = this.parsePath(target.pathStr);
1117
- const splitter = this.findSplitterByPath(path?.segments ?? []);
1118
- splitter?.resizeDividerBy?.(target.index, event.key, fine);
1119
- }
1120
- beginCornerResize(event, h, v, handle) {
1121
- event.preventDefault();
1122
- // Build pairs from dataset if available (grouped intersections), otherwise from the provided pair
1123
- const pairsRaw = handle.dataset['pairs'];
1124
- const parsed = pairsRaw ? JSON.parse(pairsRaw) : [];
1125
- const hs = [];
1126
- const vs = [];
1127
- const ensureHV = (pathStr, index, axis) => {
1128
- const path = this.parsePath(pathStr);
1129
- if (!path)
1130
- return;
1131
- const splitter = this.findSplitterByPath(path.segments);
1132
- if (!splitter)
1133
- return;
1134
- // Initial pixel sizes come from each panel-wrapper inside the splitter's
1135
- // shadow root. We capture them once on pointerdown and feed deltas to
1136
- // setPanelSizes() during the drag.
1137
- const panels = this.getSplitterPanels(splitter);
1138
- if (panels.length === 0)
1139
- return;
1140
- const dim = axis === 'h' ? 'height' : 'width';
1141
- const initial = panels.map((p) => p.getBoundingClientRect()[dim]);
1142
- const entry = { path, index, container: splitter, initialSizes: initial, before: initial[index], after: initial[index + 1] };
1143
- if (axis === 'h')
1144
- hs.push(entry);
1145
- else
1146
- vs.push(entry);
1147
- };
1148
- if (parsed.length > 0) {
1149
- parsed.forEach((p) => { ensureHV(p.h.pathStr, p.h.index, 'h'); ensureHV(p.v.pathStr, p.v.index, 'v'); });
1150
- }
1151
- else if (h.path && v.path) {
1152
- ensureHV(this.formatPath(h.path), h.index, 'h');
1153
- ensureHV(this.formatPath(v.path), v.index, 'v');
1154
- }
1155
- if (hs.length === 0 && vs.length === 0)
1156
- return;
1157
- try {
1158
- handle.setPointerCapture(event.pointerId);
1159
- handle.dataset['resizing'] = 'true';
1160
- handle.classList.add('hovering');
1161
- }
1162
- catch { }
1163
- this.cornerResizeState = {
1164
- pointerId: event.pointerId,
1165
- handle,
1166
- hs: hs.map((e) => ({ path: this.clonePath(e.path), index: e.index, container: e.container, beforeSize: e.before, afterSize: e.after, initialSizes: e.initialSizes, startY: event.clientY })),
1167
- vs: vs.map((e) => ({ path: this.clonePath(e.path), index: e.index, container: e.container, beforeSize: e.before, afterSize: e.after, initialSizes: e.initialSizes, startX: event.clientX })),
1168
- };
1169
- this.startPointerTracking();
1170
- // Ensure handle has a stable key (use group if present)
1171
- if (!handle.dataset['key']) {
1172
- handle.dataset['key'] = handle.dataset['group'] ?? '';
1173
- }
1174
- this.renderSnapMarkersForCorner();
1175
- // Compute localized snap targets for this intersection
1176
- try {
1177
- const rootRect = this.rootEl.getBoundingClientRect();
1178
- // Use first pair to define the crossing lines. Resolve dividers via
1179
- // each splitter's shadow root.
1180
- let centerX = null;
1181
- let centerY = null;
1182
- if (vs.length > 0) {
1183
- const vPair = vs[0];
1184
- const vDiv = this.getSplitterDividers(vPair.container)[vPair.index];
1185
- const vr = vDiv?.getBoundingClientRect();
1186
- if (vr)
1187
- centerX = vr.left + vr.width / 2;
1188
- }
1189
- if (hs.length > 0) {
1190
- const hPair = hs[0];
1191
- const hDiv = this.getSplitterDividers(hPair.container)[hPair.index];
1192
- const hr = hDiv?.getBoundingClientRect();
1193
- if (hr)
1194
- centerY = hr.top + hr.height / 2;
1195
- }
1196
- const xTargets = [];
1197
- const yTargets = [];
1198
- // Iterate every splitter, then flat-map its shadow dividers — a
1199
- // splitter's data-direction tells us whether its bars are vertical
1200
- // (horizontal split) or horizontal (vertical split).
1201
- const allSplitters = Array.from(this.shadowRoot?.querySelectorAll('.dock-split') ?? []);
1202
- allSplitters.forEach((splitter) => {
1203
- const direction = splitter.dataset['direction'] ?? undefined;
1204
- this.getSplitterDividers(splitter).forEach((el) => {
1205
- const r = el.getBoundingClientRect();
1206
- if (direction === 'horizontal' && centerY != null) {
1207
- // vertical bar → contributes X if it crosses centerY
1208
- if (centerY >= r.top && centerY <= r.bottom) {
1209
- xTargets.push(r.left + r.width / 2 - rootRect.left);
1210
- }
1211
- }
1212
- else if (direction === 'vertical' && centerX != null) {
1213
- // horizontal bar → contributes Y if it crosses centerX
1214
- if (centerX >= r.left && centerX <= r.right) {
1215
- yTargets.push(r.top + r.height / 2 - rootRect.top);
1216
- }
1217
- }
1218
- });
1219
- });
1220
- this.cornerSnapXTargets = xTargets;
1221
- this.cornerSnapYTargets = yTargets;
1222
- }
1223
- catch {
1224
- this.cornerSnapXTargets = [];
1225
- this.cornerSnapYTargets = [];
1226
- }
1227
- }
1228
- handleCornerResizeMove(event) {
1229
- const state = this.cornerResizeState;
1230
- if (!state || state.pointerId !== event.pointerId)
1231
- return;
1232
- const snapValue = (val, total, active) => {
1233
- if (!active || total <= 0)
1234
- return val;
1235
- const ratios = [1 / 3, 1 / 2, 2 / 3];
1236
- const r = val / total;
1237
- let best = ratios[0];
1238
- let d = Math.abs(r - best);
1239
- for (let i = 1; i < ratios.length; i++) {
1240
- const dd = Math.abs(r - ratios[i]);
1241
- if (dd < d) {
1242
- d = dd;
1243
- best = ratios[i];
1244
- }
1245
- }
1246
- return best * total;
1247
- };
1248
- // Axis snapping to nearby intersections
1249
- const tol = 10;
1250
- const rootRect = this.rootEl.getBoundingClientRect();
1251
- let clientX = event.clientX;
1252
- let clientY = event.clientY;
1253
- if (this.cornerSnapXTargets.length) {
1254
- let best = clientX, bestDist = tol + 1;
1255
- this.cornerSnapXTargets.forEach((sx) => {
1256
- const px = rootRect.left + sx;
1257
- const d = Math.abs(px - clientX);
1258
- if (d < bestDist) {
1259
- bestDist = d;
1260
- best = px;
1261
- }
1262
- });
1263
- if (bestDist <= tol)
1264
- clientX = best;
1265
- }
1266
- if (this.cornerSnapYTargets.length) {
1267
- let best = clientY, bestDist = tol + 1;
1268
- this.cornerSnapYTargets.forEach((sy) => {
1269
- const py = rootRect.top + sy;
1270
- const d = Math.abs(py - clientY);
1271
- if (d < bestDist) {
1272
- bestDist = d;
1273
- best = py;
1274
- }
1275
- });
1276
- if (bestDist <= tol)
1277
- clientY = best;
1278
- }
1279
- // Apply the new pair sizes to one splitter's panel-wrappers via
1280
- // mp-splitter's setPanelSizes(pixels) API. We persist the normalized
1281
- // ratios on the layout node so renderSplit's initial sizing stays in sync.
1282
- const applyPairSize = (entry, delta) => {
1283
- const node = this.resolveSplitNode(entry.path);
1284
- if (!node)
1285
- return;
1286
- const minSize = 48;
1287
- const pairTotal = entry.beforeSize + entry.afterSize;
1288
- let newBefore = Math.min(Math.max(entry.beforeSize + delta, minSize), pairTotal - minSize);
1289
- newBefore = snapValue(newBefore, pairTotal, event.shiftKey);
1290
- const newAfter = pairTotal - newBefore;
1291
- const sizesPx = [...entry.initialSizes];
1292
- sizesPx[entry.index] = newBefore;
1293
- sizesPx[entry.index + 1] = newAfter;
1294
- const total = sizesPx.reduce((a, s) => a + s, 0);
1295
- node.sizes = total > 0 ? sizesPx.map((s) => s / total) : [];
1296
- entry.container
1297
- .setPanelSizes?.(sizesPx);
1298
- };
1299
- // Update all horizontal bars (vertical splits) with Y delta, then all
1300
- // vertical bars (horizontal splits) with X delta.
1301
- state.hs.forEach((h) => applyPairSize(h, clientY - h.startY));
1302
- state.vs.forEach((v) => applyPairSize(v, clientX - v.startX));
1303
- this.dispatchLayoutChanged();
1304
- // setPanelSizes() is programmatic and doesn't fire 'resizing' events, so
1305
- // the delegated listener on dockedEl doesn't wake during a corner drag.
1306
- // Schedule the handle repositioning ourselves; renderIntersectionHandles
1307
- // has a fast-path for the active cornerResizeState that just updates
1308
- // left/top from the new divider rects.
1309
- this.scheduleRenderIntersectionHandles();
1310
- }
1311
- endCornerResize(pointerId) {
1312
- const state = this.cornerResizeState;
1313
- if (!state || pointerId !== state.pointerId)
1314
- return;
1315
- try {
1316
- state.handle.releasePointerCapture(state.pointerId);
1317
- }
1318
- catch { }
1319
- state.handle.dataset['resizing'] = 'false';
1320
- this.cornerResizeState = null;
1321
- // Re-render handles to account for new positions
1322
- this.scheduleRenderIntersectionHandles();
1323
- this.cornerSnapXTargets = [];
1324
- this.cornerSnapYTargets = [];
1325
- }
1326
- onIntersectionDoubleClick(event, handle) {
1327
- event.preventDefault();
1328
- const pairsRaw = handle.dataset['pairs'];
1329
- const parsed = pairsRaw ? JSON.parse(pairsRaw) : [];
1330
- if (!Array.isArray(parsed) || parsed.length === 0) {
1331
- const k = handle.dataset['key'] ?? '';
1332
- const parts = k.split('|');
1333
- if (parts.length === 2) {
1334
- const [hPart, vPart] = parts;
1335
- const hi = hPart.lastIndexOf(':');
1336
- const vi = vPart.lastIndexOf(':');
1337
- if (hi > 0 && vi > 0) {
1338
- const hPathStr = hPart.slice(0, hi);
1339
- const vPathStr = vPart.slice(0, vi);
1340
- const hIdx = Number.parseInt(hPart.slice(hi + 1), 10);
1341
- const vIdx = Number.parseInt(vPart.slice(vi + 1), 10);
1342
- parsed.push({ h: { pathStr: hPathStr, index: hIdx }, v: { pathStr: vPathStr, index: vIdx } });
1343
- }
1344
- }
1345
- }
1346
- if (parsed.length === 0)
1347
- return;
1348
- const splitKeys = new Set();
1349
- parsed.forEach((p) => { splitKeys.add(p.h.pathStr); splitKeys.add(p.v.pathStr); });
1350
- let hasStored = false;
1351
- splitKeys.forEach((k) => { if (this.previousSplitSizes.has(k))
1352
- hasStored = true; });
1353
- // Persist `node.sizes` (normalized) and push pixel sizes into the
1354
- // matching <mp-splitter> via setPanelSizes(). The splitter's panel
1355
- // wrappers live in its shadow DOM, so direct flex mutation is no
1356
- // longer an option.
1357
- const pushSizesToSplitter = (path, normalized) => {
1358
- const splitter = this.findSplitterByPath(path.segments);
1359
- if (!splitter)
1360
- return;
1361
- const direction = splitter.dataset['direction'] ?? 'horizontal';
1362
- const containerSize = direction === 'horizontal'
1363
- ? splitter.getBoundingClientRect().width
1364
- : splitter.getBoundingClientRect().height;
1365
- if (!Number.isFinite(containerSize) || containerSize <= 0)
1366
- return;
1367
- const totalWeight = normalized.reduce((s, w) => s + Math.max(w, 0), 0);
1368
- if (totalWeight <= 0)
1369
- return;
1370
- const px = normalized.map((w) => (Math.max(w, 0) / totalWeight) * containerSize);
1371
- splitter
1372
- .setPanelSizes?.(px);
1373
- };
1374
- const applySizes = (pathStr, dividerIndex, mutate) => {
1375
- const path = this.parsePath(pathStr);
1376
- if (!path)
1377
- return;
1378
- const node = this.resolveSplitNode(path);
1379
- if (!node)
1380
- return;
1381
- const sizes = this.normalizeSizesArray(node.sizes ?? [], node.children.length);
1382
- const newSizes = mutate([...sizes], dividerIndex);
1383
- node.sizes = newSizes;
1384
- pushSizesToSplitter(path, newSizes);
1385
- };
1386
- if (hasStored) {
1387
- // Restore stored sizes
1388
- this.previousSplitSizes.forEach((sizes, pathStr) => {
1389
- const path = this.parsePath(pathStr);
1390
- const node = path ? this.resolveSplitNode(path) : null;
1391
- if (!node || !path)
1392
- return;
1393
- const norm = this.normalizeSizesArray(sizes, node.children.length);
1394
- node.sizes = norm;
1395
- pushSizesToSplitter(path, norm);
1396
- });
1397
- this.previousSplitSizes.clear();
1398
- }
1399
- else {
1400
- // Equalize the two panes adjacent to each divider and store previous sizes
1401
- const touched = new Set();
1402
- parsed.forEach((p) => {
1403
- [p.h.pathStr, p.v.pathStr].forEach((key) => {
1404
- if (touched.has(key))
1405
- return;
1406
- const path = this.parsePath(key);
1407
- const node = path ? this.resolveSplitNode(path) : null;
1408
- if (node && Array.isArray(node.sizes)) {
1409
- this.previousSplitSizes.set(key, [...node.sizes]);
1410
- }
1411
- touched.add(key);
1412
- });
1413
- const equalize = (sizes, idx) => {
1414
- const total = (sizes[idx] ?? 0) + (sizes[idx + 1] ?? 0);
1415
- if (total <= 0)
1416
- return sizes;
1417
- sizes[idx] = total / 2;
1418
- sizes[idx + 1] = total / 2;
1419
- const sum = sizes.reduce((a, s) => a + s, 0);
1420
- return sum > 0 ? sizes.map((s) => s / sum) : sizes;
1421
- };
1422
- applySizes(p.h.pathStr, p.h.index, equalize);
1423
- applySizes(p.v.pathStr, p.v.index, equalize);
1424
- });
1425
- }
1426
- this.dispatchLayoutChanged();
1427
- this.scheduleRenderIntersectionHandles();
1428
- }
1429
- beginFloatingDrag(event, index, wrapper, handle) {
1430
- const floating = this.floatingLayouts[index];
1431
- if (!floating) {
1432
- return;
1433
- }
1434
- event.preventDefault();
1435
- event.stopPropagation();
1436
- const { left, top } = floating.bounds;
1437
- try {
1438
- handle.setPointerCapture(event.pointerId);
1439
- }
1440
- catch (err) {
1441
- /* no-op: pointer capture may not be supported in all environments */
1442
- }
1443
- this.promoteFloatingPane(index, wrapper);
1444
- this.floatingDragState = {
1445
- index,
1446
- pointerId: event.pointerId,
1447
- startX: event.clientX,
1448
- startY: event.clientY,
1449
- startLeft: left,
1450
- startTop: top,
1451
- wrapper,
1452
- handle,
1453
- };
1454
- this.startPointerTracking();
1455
- }
1456
- beginFloatingResize(event, index, wrapper, handle, edges) {
1457
- const floating = this.floatingLayouts[index];
1458
- if (!floating) {
1459
- return;
1460
- }
1461
- event.preventDefault();
1462
- event.stopPropagation();
1463
- try {
1464
- handle.setPointerCapture(event.pointerId);
1465
- handle.dataset['resizing'] = 'true';
1466
- }
1467
- catch (err) {
1468
- /* pointer capture may not be supported */
1469
- }
1470
- this.promoteFloatingPane(index, wrapper);
1471
- this.floatingResizeState = {
1472
- index,
1473
- pointerId: event.pointerId,
1474
- startX: event.clientX,
1475
- startY: event.clientY,
1476
- startWidth: floating.bounds.width,
1477
- startHeight: floating.bounds.height,
1478
- startLeft: floating.bounds.left,
1479
- startTop: floating.bounds.top,
1480
- wrapper,
1481
- handle,
1482
- edges,
1483
- };
1484
- this.startPointerTracking();
1485
- }
1486
- handleFloatingDragMove(event) {
1487
- const state = this.floatingDragState;
1488
- if (!state || event.pointerId !== state.pointerId) {
1489
- return;
1490
- }
1491
- const deltaX = event.clientX - state.startX;
1492
- const deltaY = event.clientY - state.startY;
1493
- const newLeft = state.startLeft + deltaX;
1494
- const newTop = state.startTop + deltaY;
1495
- state.wrapper.style.left = `${newLeft}px`;
1496
- state.wrapper.style.top = `${newTop}px`;
1497
- const floating = this.floatingLayouts[state.index];
1498
- if (floating) {
1499
- floating.bounds.left = newLeft;
1500
- floating.bounds.top = newTop;
1501
- }
1502
- this.updateFloatingDragDropTarget(event);
1503
- }
1504
- endFloatingDrag(pointerId) {
1505
- const state = this.floatingDragState;
1506
- if (!state || pointerId !== state.pointerId) {
1507
- return;
1508
- }
1509
- try {
1510
- state.handle.releasePointerCapture(state.pointerId);
1511
- }
1512
- catch (err) {
1513
- /* no-op */
1514
- }
1515
- // Clear outside the try so a thrown releasePointerCapture (capture
1516
- // already lost) doesn't strand the handle in its visual drag state.
1517
- delete state.handle.dataset['resizing'];
1518
- const dropHandled = state.dropTarget
1519
- ? this.handleFloatingStackDrop(state.index, state.dropTarget.path, state.dropTarget.zone)
1520
- : false;
1521
- this.floatingDragState = null;
1522
- this.hideDropIndicator();
1523
- if (!dropHandled) {
1524
- this.dispatchLayoutChanged();
1525
- }
1526
- }
1527
- updateFloatingDragDropTarget(event) {
1528
- const state = this.floatingDragState;
1529
- if (!state) {
1530
- return;
1531
- }
1532
- const stack = this.findStackAtPoint(event.clientX, event.clientY);
1533
- if (!stack) {
1534
- if (state.dropTarget) {
1535
- delete state.dropTarget;
1536
- this.hideDropIndicator();
1537
- }
1538
- return;
1539
- }
1540
- const path = this.parsePath(stack.dataset['path']);
1541
- if (!path || (path.type === 'floating' && path.index === state.index)) {
1542
- if (state.dropTarget) {
1543
- delete state.dropTarget;
1544
- this.hideDropIndicator();
1545
- }
1546
- return;
1547
- }
1548
- // Reset sticky zone when moving to another stack while dragging the
1549
- // floating window so the side doesn't carry over.
1550
- if (this.dropJoystickTarget && this.dropJoystickTarget !== stack) {
1551
- delete this.dropJoystick.dataset['zone'];
1552
- this.updateDropJoystickActiveZone(null);
1553
- }
1554
- const zone = this.computeDropZone(stack, event, this.extractDropZoneFromEvent(event));
1555
- if (zone) {
1556
- state.dropTarget = { path, zone };
1557
- }
1558
- else if (state.dropTarget) {
1559
- delete state.dropTarget;
1560
- }
1561
- this.showDropIndicator(stack, zone);
1562
- }
1563
- handleFloatingResizeMove(event) {
1564
- const state = this.floatingResizeState;
1565
- if (!state || event.pointerId !== state.pointerId) {
1566
- return;
1567
- }
1568
- const deltaX = event.clientX - state.startX;
1569
- const deltaY = event.clientY - state.startY;
1570
- const minWidth = 192;
1571
- const minHeight = 128;
1572
- let newWidth = state.startWidth;
1573
- let newHeight = state.startHeight;
1574
- let newLeft = state.startLeft;
1575
- let newTop = state.startTop;
1576
- if (state.edges.horizontal === 'right') {
1577
- newWidth = Math.max(minWidth, state.startWidth + deltaX);
1578
- }
1579
- else if (state.edges.horizontal === 'left') {
1580
- newWidth = Math.max(minWidth, state.startWidth - deltaX);
1581
- newLeft = state.startLeft + (state.startWidth - newWidth);
1582
- }
1583
- if (state.edges.vertical === 'bottom') {
1584
- newHeight = Math.max(minHeight, state.startHeight + deltaY);
1585
- }
1586
- else if (state.edges.vertical === 'top') {
1587
- newHeight = Math.max(minHeight, state.startHeight - deltaY);
1588
- newTop = state.startTop + (state.startHeight - newHeight);
1589
- }
1590
- state.wrapper.style.width = `${newWidth}px`;
1591
- state.wrapper.style.height = `${newHeight}px`;
1592
- state.wrapper.style.left = `${newLeft}px`;
1593
- state.wrapper.style.top = `${newTop}px`;
1594
- const floating = this.floatingLayouts[state.index];
1595
- if (floating) {
1596
- floating.bounds.width = newWidth;
1597
- floating.bounds.height = newHeight;
1598
- floating.bounds.left = newLeft;
1599
- floating.bounds.top = newTop;
1600
- }
1601
- }
1602
- endFloatingResize(pointerId) {
1603
- const state = this.floatingResizeState;
1604
- if (!state || pointerId !== state.pointerId) {
1605
- return;
1606
- }
1607
- try {
1608
- state.handle.releasePointerCapture(state.pointerId);
1609
- }
1610
- catch (err) {
1611
- /* no-op */
1612
- }
1613
- // Clear `data-resizing` outside the try — releasePointerCapture can
1614
- // throw if the capture was already lost (e.g., the pointer left the
1615
- // window), and we still need to drop the resizing attribute or the
1616
- // CSS rule `.dock-floating__resizer[data-resizing='true']` keeps the
1617
- // border dark-blue forever.
1618
- delete state.handle.dataset['resizing'];
1619
- this.floatingResizeState = null;
1620
- this.dispatchLayoutChanged();
1621
- }
1622
- getFloatingPaneZIndex(index) {
1623
- const floating = this.floatingLayouts[index];
1624
- if (!floating) {
1625
- return 10 + index;
1626
- }
1627
- const base = typeof floating.zIndex === 'number' && Number.isFinite(floating.zIndex)
1628
- ? floating.zIndex
1629
- : 10 + index;
1630
- return base;
1631
- }
1632
- promoteFloatingPane(index, wrapper) {
1633
- const floating = this.floatingLayouts[index];
1634
- if (!floating) {
1635
- return;
1636
- }
1637
- const maxExisting = this.floatingLayouts.reduce((max, layout, idx) => {
1638
- if (!layout) {
1639
- return max;
1640
- }
1641
- const z = idx === index ? Number.NEGATIVE_INFINITY : this.getFloatingPaneZIndex(idx);
1642
- return Math.max(max, z);
1643
- }, 0);
1644
- const nextZ = Math.max(maxExisting + 2, 12);
1645
- floating.zIndex = nextZ;
1646
- wrapper.style.zIndex = String(nextZ);
1647
- }
1648
- getFloatingWrapper(index) {
1649
- const selector = `.dock-floating[data-path="${this.formatPath({
1650
- type: 'floating',
1651
- index,
1652
- segments: [],
1653
- })}"]`;
1654
- return this.floatingLayerEl.querySelector(selector);
1655
- }
1656
- startPointerTracking() {
1657
- if (this.pointerTrackingActive) {
1658
- return;
1659
- }
1660
- const win = this.windowRef;
1661
- win?.addEventListener('pointermove', this.onPointerMove);
1662
- win?.addEventListener('pointerup', this.onPointerUp);
1663
- this.pointerTrackingActive = true;
1664
- }
1665
- stopPointerTrackingIfIdle() {
1666
- if (this.pointerTrackingActive &&
1667
- !this.floatingDragState &&
1668
- !this.floatingResizeState &&
1669
- !this.cornerResizeState) {
1670
- const win = this.windowRef;
1671
- win?.removeEventListener('pointermove', this.onPointerMove);
1672
- win?.removeEventListener('pointerup', this.onPointerUp);
1673
- this.pointerTrackingActive = false;
1674
- }
1675
- }
1676
- getFloatingWindowTitle(floating) {
1677
- const fallback = 'Floating Pane';
1678
- if (!floating || !floating.root) {
1679
- return fallback;
1680
- }
1681
- const preferred = floating.activePane ?? this.findFirstPaneName(floating.root);
1682
- if (!preferred) {
1683
- return fallback;
1684
- }
1685
- return this.titles[preferred] ?? preferred ?? fallback;
1686
- }
1687
- updateFloatingWindowTitle(index) {
1688
- const floating = this.floatingLayouts[index];
1689
- if (!floating) {
1690
- return;
1691
- }
1692
- const selector = `.dock-floating[data-path="${this.formatPath({
1693
- type: 'floating',
1694
- index,
1695
- segments: [],
1696
- })}"]`;
1697
- const wrapper = this.floatingLayerEl.querySelector(selector);
1698
- if (!wrapper) {
1699
- return;
1700
- }
1701
- const titleEl = wrapper.querySelector('.dock-floating__title');
1702
- if (!titleEl) {
1703
- return;
1704
- }
1705
- titleEl.textContent = this.getFloatingWindowTitle(floating);
1706
- }
1707
- renderSplit(node, path, floatingIndex) {
1708
- // Each DockSplitNode renders as <mp-splitter>. The dock keeps its `.dock-split`
1709
- // class on the host so existing `closest('.dock-split')` queries continue to
1710
- // resolve, and stamps `data-direction` / `data-path` for the tree-driven
1711
- // intersection-handle math.
1712
- const splitter = this.documentRef.createElement('mp-splitter');
1713
- splitter.classList.add('dock-split');
1714
- splitter.dataset['direction'] = node.direction;
1715
- splitter.dataset['path'] = path.join('/');
1716
- // mp-splitter uses 'horizontal' (left-right) and 'vertical' (top-bottom).
1717
- // The dock's DockSplitNode.direction matches that vocabulary 1:1.
1718
- splitter.setAttribute('orientation', node.direction);
1719
- const splitPath = typeof floatingIndex === 'number'
1720
- ? { type: 'floating', index: floatingIndex, segments: [...path] }
1721
- : { type: 'docked', segments: [...path] };
1722
- node.children.forEach((child, index) => {
1723
- // mp-splitter accepts direct children — it wraps each in a panel-wrapper
1724
- // inside its shadow DOM and projects via a named slot per index.
1725
- splitter.appendChild(this.renderNode(child, [...path, index], floatingIndex));
1726
- });
1727
- // Apply persisted sizes from the layout tree once mp-splitter has built
1728
- // its panel wrappers. mp-splitter's setPanelSizes interprets values as
1729
- // pixel widths/heights; the dock's saved sizes are flex weights, so
1730
- // convert using the splitter's measured cross-axis container size.
1731
- const sizes = Array.isArray(node.sizes) ? node.sizes : [];
1732
- if (sizes.length > 0) {
1733
- requestAnimationFrame(() => {
1734
- const totalWeight = sizes.reduce((s, w) => s + Math.max(w, 0), 0);
1735
- if (totalWeight <= 0)
1736
- return;
1737
- const containerSize = node.direction === 'horizontal'
1738
- ? splitter.getBoundingClientRect().width
1739
- : splitter.getBoundingClientRect().height;
1740
- if (!Number.isFinite(containerSize) || containerSize <= 0)
1741
- return;
1742
- const px = sizes.map((w) => (Math.max(w, 0) / totalWeight) * containerSize);
1743
- splitter
1744
- .setPanelSizes?.(px);
1745
- });
1746
- }
1747
- // mp-splitter fires resize-end with pixel sizes after a divider drag.
1748
- // Convert back to flex weights (sum to a stable total — keep current sum
1749
- // so future renders interpret consistently) and persist to the layout tree.
1750
- splitter.addEventListener('resize-end', (event) => {
1751
- // resize-end bubbles, so a nested mp-splitter's drag end would also
1752
- // reach this listener. Only react to events from THIS splitter, not
1753
- // from a descendant — otherwise we'd apply the inner's sizes to the
1754
- // outer's splitNode and mangle the outer's weights.
1755
- if (event.target !== splitter)
1756
- return;
1757
- const detail = event.detail;
1758
- if (!Array.isArray(detail?.sizes) || detail.sizes.length === 0)
1759
- return;
1760
- const splitNode = this.resolveSplitNode(splitPath);
1761
- if (!splitNode)
1762
- return;
1763
- const previousTotal = (splitNode.sizes ?? []).reduce((s, w) => s + Math.max(w, 0), 0);
1764
- const total = detail.sizes.reduce((s, v) => s + Math.max(v, 0), 0);
1765
- const targetTotal = previousTotal > 0 ? previousTotal : detail.sizes.length;
1766
- if (total > 0) {
1767
- splitNode.sizes = detail.sizes.map((px) => (Math.max(px, 0) / total) * targetTotal);
1768
- this.dispatchLayoutChanged();
1769
- }
1770
- });
1771
- return splitter;
1772
- }
1773
- renderStack(node, path, floatingIndex) {
1774
- // Dock stacks are rendered as <mp-tab-control>. The dock keeps `.dock-stack`
1775
- // as a class on the host so existing `closest('.dock-stack')` queries
1776
- // continue to resolve. The tab strip + body slot projection are owned by
1777
- // mp-tab-control; the dock just provides the slotted header/content
1778
- // elements and listens for tab-activate to drive layout-tree updates.
1779
- const stack = this.documentRef.createElement('mp-tab-control');
1780
- stack.classList.add('dock-stack');
1781
- // Dock controls activation; tell mp-tab-control not to auto-pick.
1782
- stack.setAttribute('select-first-tab', 'false');
1783
- // `border="top"` gives us the strip-cutout line under the tabs (so the
1784
- // active tab visually punches through into the body) without adding the
1785
- // full Bootstrap frame, which would double up with the dock's own outer
1786
- // chrome border on `.dock-stack` (and on `.dock-floating` for floating
1787
- // panels).
1788
- stack.setAttribute('border', 'top');
1789
- const location = typeof floatingIndex === 'number'
1790
- ? { type: 'floating', index: floatingIndex, segments: [...path] }
1791
- : { type: 'docked', segments: [...path] };
1792
- stack.dataset['path'] = this.formatPath(location);
1793
- const panes = Array.from(new Set(node.panes));
1794
- if (panes.length === 0) {
1795
- const emptyHeader = this.documentRef.createElement('span');
1796
- emptyHeader.setAttribute('slot', '__empty__-header');
1797
- emptyHeader.textContent = '(empty)';
1798
- const empty = this.documentRef.createElement('div');
1799
- empty.setAttribute('slot', '__empty__-content');
1800
- empty.classList.add('dock-stack__pane');
1801
- empty.textContent = 'No panes configured';
1802
- stack.append(emptyHeader, empty);
1803
- stack.setAttribute('active-tab', '__empty__');
1804
- return stack;
1805
- }
1806
- const activePane = panes.includes(node.activePane ?? '')
1807
- ? node.activePane
1808
- : panes[0];
1809
- const baseSlug = path.length ? path.join('-') : 'root';
1810
- const pathSlug = typeof floatingIndex === 'number' ? `f${floatingIndex}-${baseSlug}` : baseSlug;
1811
- panes.forEach((paneName) => {
1812
- const paneSlugRaw = paneName.replace(/[^a-zA-Z0-9_-]/g, '-');
1813
- const paneSlug = paneSlugRaw.length > 0 ? paneSlugRaw : 'pane';
1814
- const tabId = `${this.instanceId}-tab-${pathSlug}-${paneSlug}`;
1815
- const panelId = `${this.instanceId}-panel-${pathSlug}-${paneSlug}`;
1816
- // Header span — projected via mp-tab-control's `${tabId}-header` slot
1817
- // into the strip's button content. Carries the dock's drag handlers.
1818
- const headerSpan = this.documentRef.createElement('span');
1819
- headerSpan.setAttribute('slot', `${tabId}-header`);
1820
- headerSpan.classList.add('dock-tab');
1821
- headerSpan.dataset['pane'] = paneName;
1822
- headerSpan.dataset['tabId'] = tabId;
1823
- headerSpan.textContent = this.titles[paneName] ?? paneName;
1824
- // Pointer-only drag (no HTML5 dnd). pointerdown captures metrics + arms
1825
- // a threshold gesture; once the pointer moves >threshold pixels we
1826
- // promote it to a real pane drag via beginPaneDrag. Using pointer
1827
- // events sidesteps the entire class of HTML5 dnd quirks (cancellation
1828
- // when source DOM is removed mid-drag, suppressed mousemove, bogus 0/0
1829
- // coordinates in Firefox, browser-specific drag-image behavior).
1830
- headerSpan.addEventListener('pointerdown', (event) => {
1831
- this.captureTabDragMetrics(event, stack);
1832
- this.armPaneDragGesture(event, this.clonePath(location), paneName, stack);
1833
- event.stopPropagation();
1834
- // Do NOT call event.preventDefault() here. On touch, that suppresses
1835
- // the synthesized click on the parent .nav-link button — which is how
1836
- // mp-tab-control fires `tab-activate`. `touch-action: none` on
1837
- // `.dock-tab` already prevents the browser from arbitrating the
1838
- // gesture for scroll, so preventDefault would be redundant + harmful.
1839
- });
1840
- // Content wrapper — projected via mp-tab-control's `${tabId}-content`
1841
- // slot only when this tab is active. Holds the dock manager's per-pane
1842
- // <slot> for the consumer's content.
1843
- const paneHost = this.documentRef.createElement('div');
1844
- paneHost.setAttribute('slot', `${tabId}-content`);
1845
- paneHost.classList.add('dock-stack__pane');
1846
- paneHost.dataset['pane'] = paneName;
1847
- paneHost.dataset['tabId'] = tabId;
1848
- paneHost.id = panelId;
1849
- const slotEl = this.documentRef.createElement('slot');
1850
- slotEl.name = paneName;
1851
- paneHost.appendChild(slotEl);
1852
- stack.append(headerSpan, paneHost);
1853
- if (paneName === activePane) {
1854
- stack.setAttribute('active-tab', tabId);
1855
- }
1856
- });
1857
- stack.dataset['activePane'] = activePane;
1858
- // Drive activatePane from mp-tab-control's tab-activate event. We map the
1859
- // tabId back to the original paneName via the header span's data-pane.
1860
- stack.addEventListener('tab-activate', (event) => {
1861
- const detail = event.detail;
1862
- const headerSpan = stack.querySelector(`:scope > [data-tab-id="${detail.tabId}"]`);
1863
- const paneName = headerSpan?.dataset['pane'];
1864
- if (paneName) {
1865
- this.activatePane(stack, paneName, this.clonePath(location));
1866
- this.dispatchEvent(new CustomEvent('dock-pane-activated', {
1867
- detail: { pane: paneName },
1868
- bubbles: true,
1869
- composed: true,
1870
- }));
1871
- }
1872
- });
1873
- return stack;
1874
- }
1875
- /**
1876
- * Returns the strip (`.tsc`) element inside an `<mp-tab-control>`'s shadow
1877
- * DOM. Used by drag/drop logic that needs the strip's geometry instead of
1878
- * the host element's bounds.
1879
- */
1880
- getStackStripEl(stack) {
1881
- if (stack.tagName !== 'MP-TAB-CONTROL')
1882
- return null;
1883
- return stack.shadowRoot?.querySelector('.tsc') ?? null;
1884
- }
1885
- /**
1886
- * Returns the rendered tab buttons inside an `<mp-tab-control>`'s shadow
1887
- * strip — the light-DOM `.dock-tab` spans the dock owns are projected into
1888
- * these buttons via `<slot>`. Use these for geometry / position queries
1889
- * (insert-index computation, drop-indicator placement). Use the light-DOM
1890
- * `.dock-tab` spans for data queries (paneName, drag listeners).
1891
- */
1892
- getStackTabButtons(stack) {
1893
- if (stack.tagName !== 'MP-TAB-CONTROL')
1894
- return [];
1895
- return Array.from(stack.shadowRoot?.querySelectorAll('button.nav-link') ?? []);
1896
- }
1897
- /**
1898
- * Returns the dividers inside an `<mp-splitter>`'s shadow DOM, in DOM order.
1899
- * mp-splitter renders one `.divider` between each pair of adjacent panels,
1900
- * so for an N-child split, length N-1.
1901
- */
1902
- getSplitterDividers(splitter) {
1903
- if (splitter.tagName !== 'MP-SPLITTER')
1904
- return [];
1905
- return Array.from(splitter.shadowRoot?.querySelectorAll('.divider') ?? []);
1906
- }
1907
- /**
1908
- * Returns the panel wrappers inside an `<mp-splitter>`'s shadow DOM, in
1909
- * DOM order. These are the elements mp-splitter sizes (via setPanelSizes)
1910
- * during a divider drag — the dock reads their geometry for intersection
1911
- * handle math and snap markers.
1912
- */
1913
- getSplitterPanels(splitter) {
1914
- if (splitter.tagName !== 'MP-SPLITTER')
1915
- return [];
1916
- return Array.from(splitter.shadowRoot?.querySelectorAll('.panel-wrapper') ?? []);
1917
- }
1918
- /**
1919
- * Locate the rendered `<mp-splitter>` element for a given DockPath
1920
- * `segments` value (the split-tree path). Searches the dock's shadow.
1921
- */
1922
- findSplitterByPath(segments) {
1923
- return (this.shadowRoot?.querySelector(`.dock-split[data-path="${segments.join('/')}"]`) ?? null);
1924
- }
1925
- onPointerMove(event) {
1926
- if (this.cornerResizeState && event.pointerId === this.cornerResizeState.pointerId) {
1927
- this.handleCornerResizeMove(event);
1928
- }
1929
- if (this.floatingResizeState && event.pointerId === this.floatingResizeState.pointerId) {
1930
- this.handleFloatingResizeMove(event);
1931
- }
1932
- if (this.floatingDragState && event.pointerId === this.floatingDragState.pointerId) {
1933
- this.handleFloatingDragMove(event);
1934
- }
1935
- }
1936
- onPointerUp(event) {
1937
- if (this.cornerResizeState && event.pointerId === this.cornerResizeState.pointerId) {
1938
- this.endCornerResize(event.pointerId);
1939
- }
1940
- if (this.floatingDragState && event.pointerId === this.floatingDragState.pointerId) {
1941
- this.endFloatingDrag(event.pointerId);
1942
- }
1943
- if (this.floatingResizeState && event.pointerId === this.floatingResizeState.pointerId) {
1944
- this.endFloatingResize(event.pointerId);
1945
- }
1946
- this.stopPointerTrackingIfIdle();
1947
- }
1948
- captureTabDragMetrics(event, stackEl) {
1949
- if (!stackEl) {
1950
- this.pendingTabDragMetrics = null;
1951
- return;
1952
- }
1953
- if (!Number.isFinite(event.clientX) || !Number.isFinite(event.clientY)) {
1954
- this.pendingTabDragMetrics = null;
1955
- return;
1956
- }
1957
- const hostRect = this.getBoundingClientRect();
1958
- const stackRect = stackEl.getBoundingClientRect();
1959
- const pointerOffsetX = event.clientX - stackRect.left;
1960
- const pointerOffsetY = event.clientY - stackRect.top;
1961
- const left = stackRect.left - hostRect.left;
1962
- const top = stackRect.top - hostRect.top;
1963
- const width = Number.isFinite(stackRect.width) ? stackRect.width : 0;
1964
- const height = Number.isFinite(stackRect.height) ? stackRect.height : 0;
1965
- this.pendingTabDragMetrics = {
1966
- pointerOffsetX,
1967
- pointerOffsetY,
1968
- left,
1969
- top,
1970
- width,
1971
- height,
1972
- startClientX: event.clientX,
1973
- startClientY: event.clientY,
1974
- };
1975
- }
1976
- clearPendingTabDragMetrics() {
1977
- this.pendingTabDragMetrics = null;
1978
- }
1979
- /**
1980
- * Pointerdown handler arms a "may become a drag" gesture. Mouse / pen use a
1981
- * 5 px distance threshold and arm immediately; touch dispatches to
1982
- * {@link armPaneDragGestureTouch} which requires a 600 ms stationary hold
1983
- * (so the user can scroll the tabstrip natively without undocking).
1984
- * Once armed, both paths converge on {@link beginPaneDrag}. All listeners
1985
- * self-clean on resolve so the gesture stays scoped to a single pointerdown.
1986
- */
1987
- armPaneDragGesture(startEvent, path, pane, stackEl) {
1988
- if (startEvent.pointerType === 'touch') {
1989
- this.armPaneDragGestureTouch(startEvent, path, pane, stackEl);
1990
- return;
1991
- }
1992
- if (startEvent.pointerType === 'mouse' && startEvent.button !== 0)
1993
- return;
1994
- const win = this.windowRef;
1995
- if (!win)
1996
- return;
1997
- const startX = startEvent.clientX;
1998
- const startY = startEvent.clientY;
1999
- const pointerId = startEvent.pointerId;
2000
- const threshold = 5;
2001
- let resolved = false;
2002
- const cleanup = () => {
2003
- resolved = true;
2004
- win.removeEventListener('pointermove', onMove, true);
2005
- win.removeEventListener('pointerup', onRelease, true);
2006
- win.removeEventListener('pointercancel', onRelease, true);
2007
- };
2008
- const onMove = (event) => {
2009
- if (resolved || event.pointerId !== pointerId)
2010
- return;
2011
- const dx = event.clientX - startX;
2012
- const dy = event.clientY - startY;
2013
- if (Math.hypot(dx, dy) < threshold)
2014
- return;
2015
- cleanup();
2016
- this.beginPaneDrag(event, path, pane, stackEl);
2017
- };
2018
- const onRelease = (event) => {
2019
- if (resolved || event.pointerId !== pointerId)
2020
- return;
2021
- cleanup();
2022
- this.clearPendingTabDragMetrics();
2023
- };
2024
- win.addEventListener('pointermove', onMove, true);
2025
- win.addEventListener('pointerup', onRelease, true);
2026
- win.addEventListener('pointercancel', onRelease, true);
2027
- }
2028
- /**
2029
- * Touch-specific gesture arming. With `.dock-tab` set to `touch-action:
2030
- * none`, the browser never arbitrates the gesture itself, so JS owns it
2031
- * from frame 1. Three outcomes from the pending state:
2032
- *
2033
- * - User holds within {@link TOUCH_LONG_PRESS_SLOP_PX} for
2034
- * {@link TOUCH_LONG_PRESS_MS} → timer fires → drag arms via
2035
- * {@link beginPaneDrag}.
2036
- * - User moves past slop and the move is mostly horizontal, and the
2037
- * strip's `<ul>` is scrollable → enter `scrolling` mode and drive
2038
- * `ul.scrollLeft` from JS for the rest of the gesture (no drag, no
2039
- * momentum — direct 1:1 finger follow).
2040
- * - User moves past slop in any other direction, releases, or
2041
- * pointercancel fires → abandoned, no drag, no scroll. Releases
2042
- * under slop fire the synthesized click that drives `tab-activate`.
2043
- *
2044
- * `touch-action: pan-x` was the original PRD design but doesn't work:
2045
- * the policy is frozen at touchstart and `setPointerCapture` doesn't
2046
- * promote it, so first move after a long-press fires pointercancel and
2047
- * strands the panel. JS-driven scroll is the only model that holds.
2048
- */
2049
- armPaneDragGestureTouch(startEvent, path, pane, stackEl) {
2050
- const win = this.windowRef;
2051
- if (!win)
2052
- return;
2053
- const startX = startEvent.clientX;
2054
- const startY = startEvent.clientY;
2055
- const pointerId = startEvent.pointerId;
2056
- let latestX = startX;
2057
- let latestY = startY;
2058
- let lastScrollX = startX;
2059
- let resolved = false;
2060
- let scrolling = false;
2061
- let pressFeedbackApplied = false;
2062
- const tabSpan = startEvent.currentTarget instanceof HTMLElement
2063
- ? startEvent.currentTarget
2064
- : startEvent.target instanceof HTMLElement
2065
- ? startEvent.target.closest('.dock-tab')
2066
- : null;
2067
- const stripUl = stackEl
2068
- ? this.getStackStripEl(stackEl)?.querySelector('ul.nav.nav-tabs') ?? null
2069
- : null;
2070
- const cleanup = () => {
2071
- if (resolved)
2072
- return;
2073
- resolved = true;
2074
- win.clearTimeout(longPressTimeout);
2075
- win.clearTimeout(pressFeedbackTimeout);
2076
- win.removeEventListener('pointermove', onMove, true);
2077
- win.removeEventListener('pointerup', onRelease, true);
2078
- win.removeEventListener('pointercancel', onCancel, true);
2079
- if (pressFeedbackApplied && tabSpan) {
2080
- tabSpan.removeAttribute('data-pressing');
2081
- }
2082
- };
2083
- const onMove = (event) => {
2084
- if (resolved || event.pointerId !== pointerId)
2085
- return;
2086
- if (scrolling) {
2087
- const dx = event.clientX - lastScrollX;
2088
- lastScrollX = event.clientX;
2089
- if (stripUl)
2090
- stripUl.scrollLeft -= dx;
2091
- return;
2092
- }
2093
- latestX = event.clientX;
2094
- latestY = event.clientY;
2095
- const dx = event.clientX - startX;
2096
- const dy = event.clientY - startY;
2097
- if (Math.hypot(dx, dy) <= MintDockManagerElement.TOUCH_LONG_PRESS_SLOP_PX) {
2098
- return;
2099
- }
2100
- // Slop crossed before the long-press fired. If the move is mostly
2101
- // horizontal and the strip can scroll, take over scroll in JS;
2102
- // otherwise abandon (no drag — browser native UI is fully suppressed
2103
- // by `touch-action: none` so no fallback is needed).
2104
- const stripScrollable = !!stripUl && stripUl.scrollWidth > stripUl.clientWidth;
2105
- if (Math.abs(dx) > Math.abs(dy) && stripScrollable) {
2106
- win.clearTimeout(longPressTimeout);
2107
- win.clearTimeout(pressFeedbackTimeout);
2108
- if (pressFeedbackApplied && tabSpan) {
2109
- tabSpan.removeAttribute('data-pressing');
2110
- pressFeedbackApplied = false;
2111
- }
2112
- scrolling = true;
2113
- lastScrollX = event.clientX;
2114
- stripUl.scrollLeft -= dx;
2115
- this.clearPendingTabDragMetrics();
2116
- return;
2117
- }
2118
- cleanup();
2119
- this.clearPendingTabDragMetrics();
2120
- };
2121
- const onRelease = (event) => {
2122
- if (resolved || event.pointerId !== pointerId)
2123
- return;
2124
- cleanup();
2125
- this.clearPendingTabDragMetrics();
2126
- };
2127
- const onCancel = (event) => {
2128
- if (resolved || event.pointerId !== pointerId)
2129
- return;
2130
- cleanup();
2131
- this.clearPendingTabDragMetrics();
2132
- };
2133
- const longPressTimeout = win.setTimeout(() => {
2134
- if (resolved)
2135
- return;
2136
- cleanup();
2137
- try {
2138
- this.setPointerCapture(pointerId);
2139
- }
2140
- catch {
2141
- // setPointerCapture throws if the pointer is no longer active
2142
- // (e.g. timer raced a pointerup we didn't see). Drag will abort
2143
- // naturally on the next event.
2144
- }
2145
- if (typeof navigator !== 'undefined' && typeof navigator.vibrate === 'function') {
2146
- try {
2147
- navigator.vibrate(10);
2148
- }
2149
- catch {
2150
- // ignore
2151
- }
2152
- }
2153
- const synthEvent = new PointerEvent('pointermove', {
2154
- pointerId,
2155
- pointerType: 'touch',
2156
- isPrimary: true,
2157
- clientX: latestX,
2158
- clientY: latestY,
2159
- bubbles: false,
2160
- cancelable: false,
2161
- });
2162
- this.beginPaneDrag(synthEvent, path, pane, stackEl);
2163
- }, MintDockManagerElement.TOUCH_LONG_PRESS_MS);
2164
- const pressFeedbackTimeout = win.setTimeout(() => {
2165
- if (resolved || !tabSpan)
2166
- return;
2167
- pressFeedbackApplied = true;
2168
- tabSpan.setAttribute('data-pressing', 'true');
2169
- }, MintDockManagerElement.TOUCH_PRESS_FEEDBACK_DELAY_MS);
2170
- win.addEventListener('pointermove', onMove, true);
2171
- win.addEventListener('pointerup', onRelease, true);
2172
- win.addEventListener('pointercancel', onCancel, true);
2173
- }
2174
- beginPaneDrag(event, path, pane, stackEl) {
2175
- const { path: sourcePath, floatingIndex, pointerOffsetX, pointerOffsetY, } = this.preparePaneDragSource(path, pane, stackEl, event);
2176
- // Capture header bounds for detecting when to convert to floating.
2177
- // The strip lives inside the mp-tab-control's shadow as `.tsc`.
2178
- const headerEl = stackEl ? this.getStackStripEl(stackEl) : null;
2179
- const headerRect = headerEl ? headerEl.getBoundingClientRect() : null;
2180
- const headerBounds = headerRect
2181
- ? { left: headerRect.left, top: headerRect.top, right: headerRect.right, bottom: headerRect.bottom }
2182
- : null;
2183
- const metrics = this.pendingTabDragMetrics;
2184
- this.dragState = {
2185
- pane,
2186
- sourcePath: this.clonePath(sourcePath),
2187
- floatingIndex,
2188
- pointerOffsetX,
2189
- pointerOffsetY,
2190
- dropHandled: false,
2191
- sourceStackEl: stackEl,
2192
- sourceHeaderBounds: headerBounds,
2193
- startClientX: metrics && Number.isFinite(metrics.startClientX)
2194
- ? metrics.startClientX
2195
- : event.clientX,
2196
- startClientY: metrics && Number.isFinite(metrics.startClientY)
2197
- ? metrics.startClientY
2198
- : event.clientY,
2199
- };
2200
- this.lastDragPointerPosition = {
2201
- x: this.dragState.startClientX,
2202
- y: this.dragState.startClientY,
2203
- };
2204
- // pointerOffsetX/Y from preparePaneDragSource is the offset within the
2205
- // source stack rect captured at pointerdown by captureTabDragMetrics.
2206
- // Don't overwrite with event.offsetX/Y here — the threshold-trigger
2207
- // pointermove fired on window, so its offset is in window-local coords
2208
- // (≈ clientX/Y) which would crash the conversion math to ~(0,0).
2209
- this.updateDraggedFloatingPositionFromPoint(event.clientX, event.clientY);
2210
- this.startDragPointerTracking();
2211
- // Mark the source floating wrapper (if any) so its CSS rule kicks in and
2212
- // pointer-events:none lets findStackAtPoint see through to the docked
2213
- // stack underneath, enabling drop zones over the dock during the drag.
2214
- this.markDraggedFloatingWrapper();
2215
- // Preferred UX: if the dragged tab is the only one in its stack,
2216
- // immediately convert to a floating window unless it is already the
2217
- // only pane in a floating window (this case is handled by reuse logic).
2218
- if (this.dragState && this.dragState.floatingIndex !== null && this.dragState.floatingIndex < 0) {
2219
- const loc = this.resolveStackLocation(this.dragState.sourcePath);
2220
- if (loc && Array.isArray(loc.node.panes) && loc.node.panes.length === 1) {
2221
- let shouldConvert = false;
2222
- if (loc.context === 'docked') {
2223
- shouldConvert = true;
2224
- }
2225
- else if (loc.context === 'floating') {
2226
- const floating = this.floatingLayouts[loc.index];
2227
- const totalPanes = floating && floating.root ? this.countPanesInTree(floating.root) : 0;
2228
- shouldConvert = totalPanes > 1;
2229
- }
2230
- if (shouldConvert) {
2231
- this.convertPendingTabDragToFloating(event.clientX, event.clientY);
2232
- }
2233
- }
2234
- }
2235
- }
2236
- preparePaneDragSource(path, pane, stackEl, event) {
2237
- const location = this.resolveStackLocation(path);
2238
- if (!location || !location.node.panes.includes(pane)) {
2239
- return {
2240
- path,
2241
- floatingIndex: null,
2242
- pointerOffsetX: 0,
2243
- pointerOffsetY: 0,
2244
- };
2245
- }
2246
- const metrics = this.pendingTabDragMetrics;
2247
- const domHasSibling = !!stackEl &&
2248
- Array.from(stackEl.querySelectorAll('.dock-tab')).some((button) => button.dataset['pane'] && button.dataset['pane'] !== pane);
2249
- const hasSiblingInStack = location.node.panes.some((existing) => existing !== pane);
2250
- const floating = location.context === 'floating' ? this.floatingLayouts[location.index] : null;
2251
- const floatingPaneCount = floating && floating.root ? this.countPanesInTree(floating.root) : hasSiblingInStack ? 2 : 1;
2252
- const shouldReuseExistingWindow = location.context === 'floating' &&
2253
- !!floating &&
2254
- !hasSiblingInStack &&
2255
- !domHasSibling &&
2256
- floatingPaneCount <= 1;
2257
- if (shouldReuseExistingWindow) {
2258
- if (floating) {
2259
- floating.activePane = pane;
2260
- this.updateFloatingWindowTitle(location.index);
2261
- const wrapper = this.getFloatingWrapper(location.index);
2262
- if (wrapper) {
2263
- this.promoteFloatingPane(location.index, wrapper);
2264
- }
2265
- const hostRect = this.getBoundingClientRect();
2266
- const pointerOffsetX = metrics &&
2267
- Number.isFinite(metrics.pointerOffsetX) &&
2268
- Number.isFinite(metrics.left) &&
2269
- Number.isFinite(floating.bounds.left)
2270
- ? metrics.pointerOffsetX + (metrics.left - floating.bounds.left)
2271
- : Number.isFinite(event.clientX) && Number.isFinite(floating.bounds.left)
2272
- ? event.clientX - hostRect.left - floating.bounds.left
2273
- : floating.bounds.width / 2;
2274
- const pointerOffsetY = metrics &&
2275
- Number.isFinite(metrics.pointerOffsetY) &&
2276
- Number.isFinite(metrics.top) &&
2277
- Number.isFinite(floating.bounds.top)
2278
- ? metrics.pointerOffsetY + (metrics.top - floating.bounds.top)
2279
- : Number.isFinite(event.clientY) && Number.isFinite(floating.bounds.top)
2280
- ? event.clientY - hostRect.top - floating.bounds.top
2281
- : floating.bounds.height / 2;
2282
- return {
2283
- path,
2284
- floatingIndex: location.index,
2285
- pointerOffsetX,
2286
- pointerOffsetY,
2287
- };
2288
- }
2289
- return {
2290
- path,
2291
- floatingIndex: null,
2292
- pointerOffsetX: 0,
2293
- pointerOffsetY: 0,
2294
- };
2295
- }
2296
- // Do not convert to floating yet; allow in-header reordering first.
2297
- // We return placeholder values and will convert once the pointer leaves the tab header.
2298
- const pointerOffsetXVal = metrics && Number.isFinite(metrics.pointerOffsetX)
2299
- ? metrics.pointerOffsetX
2300
- : 0;
2301
- const pointerOffsetYVal = metrics && Number.isFinite(metrics.pointerOffsetY)
2302
- ? metrics.pointerOffsetY
2303
- : 0;
2304
- return {
2305
- path,
2306
- floatingIndex: -1,
2307
- pointerOffsetX: pointerOffsetXVal,
2308
- pointerOffsetY: pointerOffsetYVal,
2309
- };
2310
- }
2311
- endPaneDrag() {
2312
- this.clearPendingDragEndTimeout();
2313
- // Restore the dragged tab's `data-hidden` and remove the placeholder span
2314
- // BEFORE we null out dragState — clearHeaderDragPlaceholder reads
2315
- // `dragState.placeholderEl`, `dragState.placeholderHeader`, and
2316
- // `dragState.pane` to know what to restore. If dragState is nulled first,
2317
- // this becomes a silent no-op and the dragged pane stays hidden in its
2318
- // source stack while the placeholder span lingers in the strip — which
2319
- // is exactly the "Panel disappears, only a small tab-thumb remains"
2320
- // regression the multi-pane drag-out path can otherwise trigger when
2321
- // no renderLayout() runs between conversion and end (e.g. user releases
2322
- // outside any drop zone, or HTML5 dragend fires without a drop).
2323
- this.clearHeaderDragPlaceholder();
2324
- this.clearDraggedFloatingWrapperMarkers();
2325
- const state = this.dragState;
2326
- this.dragState = null;
2327
- this.hideDropIndicator();
2328
- this.stopDragPointerTracking();
2329
- this.lastDragPointerPosition = null;
2330
- if (state && state.floatingIndex !== null && !state.dropHandled) {
2331
- this.dispatchLayoutChanged();
2332
- }
2333
- }
2334
- updateDraggedFloatingPositionFromPoint(clientX, clientY) {
2335
- if (!this.dragState) {
2336
- return;
2337
- }
2338
- if (!Number.isFinite(clientX) || !Number.isFinite(clientY)) {
2339
- return;
2340
- }
2341
- // If still dragging a tab inside its header, only convert to floating once we leave the header.
2342
- if (this.dragState.floatingIndex !== null && this.dragState.floatingIndex < 0) {
2343
- const b = this.dragState.sourceHeaderBounds;
2344
- const sx = this.dragState.startClientX ?? clientX;
2345
- const sy = this.dragState.startClientY ?? clientY;
2346
- const dist = Math.hypot(clientX - sx, clientY - sy);
2347
- const threshold = 8; // pixels to move before converting (tuned up)
2348
- // Default to inside while bounds are unknown to avoid premature floating
2349
- let insideHeader = true;
2350
- const insideByBounds = b ? this.isPointWithinBounds(b, clientX, clientY) : true;
2351
- const insideByHitTest = this.isPointerOverSourceHeader(clientX, clientY);
2352
- insideHeader = insideByBounds || insideByHitTest;
2353
- if (!insideHeader && dist > threshold) {
2354
- // Convert to floating now using current pointer position
2355
- this.convertPendingTabDragToFloating(clientX, clientY);
2356
- }
2357
- }
2358
- this.updatePaneDragDropTargetFromPoint(clientX, clientY);
2359
- const { floatingIndex, pointerOffsetX, pointerOffsetY } = this.dragState;
2360
- if (floatingIndex === null || floatingIndex < 0) {
2361
- return;
2362
- }
2363
- const floating = this.floatingLayouts[floatingIndex];
2364
- if (!floating) {
2365
- return;
2366
- }
2367
- const hostRect = this.getBoundingClientRect();
2368
- const newLeft = clientX - hostRect.left - pointerOffsetX;
2369
- const newTop = clientY - hostRect.top - pointerOffsetY;
2370
- floating.bounds.left = newLeft;
2371
- floating.bounds.top = newTop;
2372
- const wrapper = this.getFloatingWrapper(floatingIndex);
2373
- if (wrapper) {
2374
- wrapper.style.left = `${newLeft}px`;
2375
- wrapper.style.top = `${newTop}px`;
2376
- }
2377
- }
2378
- updatePaneDragDropTargetFromPoint(clientX, clientY) {
2379
- if (!this.dragState) {
2380
- return;
2381
- }
2382
- const stack = this.findStackAtPoint(clientX, clientY);
2383
- const path = stack ? this.parsePath(stack.dataset['path']) : null;
2384
- if (!stack || !path) {
2385
- // While actively dragging, avoid hiding the indicator if it is visible.
2386
- // Transient misses from hit-testing are common near the joystick.
2387
- if (this.dropJoystick.dataset['visible'] !== 'true') {
2388
- this.hideDropIndicator();
2389
- }
2390
- // Also ensure any in-header placeholder is cleared when not over a stack
2391
- this.clearHeaderDragPlaceholder();
2392
- return;
2393
- }
2394
- // If we moved to a different target stack, reset any sticky zone so
2395
- // the new drop area doesn't inherit the previous side selection.
2396
- if (this.dropJoystickTarget && this.dropJoystickTarget !== stack) {
2397
- delete this.dropJoystick.dataset['zone'];
2398
- this.updateDropJoystickActiveZone(null);
2399
- }
2400
- // Previous behavior hid the indicator and returned early here; instead,
2401
- // allow the live-reorder branch below to handle in-header drags.
2402
- // While dragging within the same header, show a placeholder and suppress joystick/indicator
2403
- if (this.dragState &&
2404
- this.dragState.floatingIndex !== null &&
2405
- this.dragState.floatingIndex < 0 &&
2406
- path &&
2407
- this.pathsEqual(path, this.dragState.sourcePath)) {
2408
- const inHeaderByBounds = !!this.dragState.sourceHeaderBounds && this.isPointWithinBounds(this.dragState.sourceHeaderBounds, clientX, clientY);
2409
- const inHeaderByHitTest = this.isPointerOverSourceHeader(clientX, clientY);
2410
- if (inHeaderByBounds || inHeaderByHitTest) {
2411
- // Ensure placeholder exists and move it as the pointer moves.
2412
- // Placeholder management mutates the slotted children of the
2413
- // mp-tab-control stack; the WC re-renders the strip on slotchange.
2414
- this.ensureHeaderDragPlaceholder(stack, this.dragState.pane);
2415
- const idx = this.computeHeaderInsertIndex(stack, clientX);
2416
- if (this.dragState.liveReorderIndex !== idx) {
2417
- this.updateHeaderDragPlaceholderPosition(stack, idx);
2418
- // Keep model reordering until drop; only move the placeholder now
2419
- this.dragState.liveReorderIndex = idx;
2420
- }
2421
- this.hideDropIndicator();
2422
- return;
2423
- }
2424
- }
2425
- // Leaving the header: ensure any placeholder is removed immediately
2426
- this.clearHeaderDragPlaceholder();
2427
- const zoneHint = this.findDropZoneByPoint(clientX, clientY);
2428
- const zone = this.computeDropZone(stack, { clientX, clientY }, zoneHint);
2429
- this.showDropIndicator(stack, zone);
2430
- }
2431
- // Returns true when the pointer is currently over the source stack's header (tab strip).
2432
- // The strip lives inside the mp-tab-control's shadow as `.tsc`, so we test
2433
- // bounds directly rather than using elementsFromPoint(/contains) which won't
2434
- // pierce the shadow boundary cleanly.
2435
- isPointerOverSourceHeader(clientX, clientY) {
2436
- const state = this.dragState;
2437
- if (!state) {
2438
- return false;
2439
- }
2440
- const stackEl = state.sourceStackEl ?? null;
2441
- const strip = stackEl ? this.getStackStripEl(stackEl) : null;
2442
- if (!strip) {
2443
- // Be conservative: if we cannot resolve the strip, treat as inside
2444
- return true;
2445
- }
2446
- const r = strip.getBoundingClientRect();
2447
- return clientX >= r.left && clientX <= r.right && clientY >= r.top && clientY <= r.bottom;
2448
- }
2449
- isPointWithinBounds(bounds, x, y) {
2450
- return x >= bounds.left && x <= bounds.right && y >= bounds.top && y <= bounds.bottom;
2451
- }
2452
- // Ensure a placeholder tab exists during in-header drag and hide the real dragged tab visually.
2453
- // Operates on the mp-tab-control stack: the dragged content div gets `data-hidden`
2454
- // (mp-tab-control then skips its tab in the strip), and a placeholder header+content
2455
- // pair is appended as light-DOM children of the stack. mp-tab-control's mutation
2456
- // observer picks up the change and renders the placeholder as a tab.
2457
- ensureHeaderDragPlaceholder(stack, pane) {
2458
- if (stack.tagName !== 'MP-TAB-CONTROL')
2459
- return;
2460
- if (this.dragState?.placeholderHeader === stack && this.dragState.placeholderEl) {
2461
- return;
2462
- }
2463
- const draggedHeader = stack.querySelector(`:scope > .dock-tab[data-pane="${CSS.escape(pane)}"]`);
2464
- const draggedContent = stack.querySelector(`:scope > .dock-stack__pane[data-pane="${CSS.escape(pane)}"]`);
2465
- if (!draggedHeader || !draggedContent)
2466
- return;
2467
- // Measure the dragged tab's text-only width BEFORE hiding it. The
2468
- // `.dock-tab` rule applies padding (matching the strip button's padding so
2469
- // the span fills the button as a drag handle), so `offsetWidth` is
2470
- // text + padding — we subtract the span's own padding to get just the
2471
- // text width. That's the natural slot content width we want the
2472
- // placeholder to reserve; the placeholder span will re-apply the same
2473
- // padding on top, mirroring the original tab's geometry exactly.
2474
- const draggedCS = this.windowRef
2475
- ? this.windowRef.getComputedStyle(draggedHeader)
2476
- : globalThis.getComputedStyle(draggedHeader);
2477
- const draggedHorizontalPadding = parseFloat(draggedCS.paddingLeft) + parseFloat(draggedCS.paddingRight);
2478
- const slotContentWidth = Math.max(0, draggedHeader.offsetWidth - draggedHorizontalPadding);
2479
- // Hide the dragged tab from mp-tab-control's strip (frees up the slot).
2480
- draggedContent.setAttribute('data-hidden', '');
2481
- // Build placeholder header + content. The placeholder uses a unique tabId
2482
- // (`__dock-placeholder__`) so its slot names don't collide with real panes.
2483
- // We mirror the dragged tab's text into the placeholder (dimmed via opacity)
2484
- // so the strip reads as "this tab is being dragged" rather than "empty slot".
2485
- const placeholderTabId = '__dock-placeholder__';
2486
- const phHeader = this.documentRef.createElement('span');
2487
- phHeader.setAttribute('slot', `${placeholderTabId}-header`);
2488
- phHeader.classList.add('dock-tab');
2489
- phHeader.dataset['placeholder'] = 'true';
2490
- phHeader.dataset['tabId'] = placeholderTabId;
2491
- phHeader.setAttribute('aria-hidden', 'true');
2492
- phHeader.textContent = draggedHeader.textContent;
2493
- // `display: inline-block` is required for `min-width` to take effect on the
2494
- // span. Without it, an inline element ignores min-width and the placeholder
2495
- // collapses to its content width (or 0 if textContent is also empty),
2496
- // leaving a "mini-thumb" in the strip.
2497
- phHeader.style.display = 'inline-block';
2498
- phHeader.style.minWidth = `${slotContentWidth}px`;
2499
- phHeader.style.opacity = '0.5';
2500
- const phContent = this.documentRef.createElement('div');
2501
- phContent.setAttribute('slot', `${placeholderTabId}-content`);
2502
- phContent.classList.add('dock-stack__pane');
2503
- phContent.dataset['placeholder'] = 'true';
2504
- // Insert before the dragged header span so the placeholder appears in
2505
- // the dragged tab's original strip position. The mutation observer in
2506
- // mp-tab-control will refresh the tab list automatically.
2507
- stack.insertBefore(phHeader, draggedHeader);
2508
- stack.insertBefore(phContent, draggedContent);
2509
- if (this.dragState) {
2510
- this.dragState.placeholderHeader = stack;
2511
- this.dragState.placeholderEl = phHeader;
2512
- }
2513
- }
2514
- // Move the placeholder to the computed target index within the strip.
2515
- // We reorder light-DOM children (header span + matching content div); the
2516
- // mp-tab-control then re-renders the strip in the new order on slotchange.
2517
- updateHeaderDragPlaceholderPosition(stack, targetIndex) {
2518
- if (stack.tagName !== 'MP-TAB-CONTROL')
2519
- return;
2520
- const phHeader = this.dragState?.placeholderEl ?? null;
2521
- if (!phHeader)
2522
- return;
2523
- const draggedPane = this.dragState?.pane ?? null;
2524
- // Find all real header spans (excluding the placeholder + the hidden dragged one).
2525
- const realHeaders = Array.from(stack.querySelectorAll(':scope > .dock-tab')).filter((h) => h !== phHeader &&
2526
- (!draggedPane || h.dataset['pane'] !== draggedPane));
2527
- const clampedTarget = Math.max(0, Math.min(targetIndex, realHeaders.length));
2528
- const ref = realHeaders[clampedTarget] ?? null;
2529
- stack.insertBefore(phHeader, ref);
2530
- // Keep the placeholder content adjacent to its header so child-order
2531
- // remains predictable for slotchange-driven re-renders.
2532
- const phContent = stack.querySelector(`:scope > .dock-stack__pane[data-placeholder="true"]`);
2533
- if (phContent && phHeader.nextElementSibling !== phContent) {
2534
- stack.insertBefore(phContent, phHeader.nextElementSibling);
2535
- }
2536
- }
2537
- // Remove placeholder and restore the dragged tab's visibility.
2538
- clearHeaderDragPlaceholder() {
2539
- const ph = this.dragState?.placeholderEl ?? null;
2540
- const stack = this.dragState?.placeholderHeader ?? null;
2541
- if (stack) {
2542
- // Restore the dragged content div's visibility so its strip tab returns.
2543
- if (this.dragState?.pane) {
2544
- const draggedContent = stack.querySelector(`:scope > .dock-stack__pane[data-pane="${CSS.escape(this.dragState.pane)}"]`);
2545
- draggedContent?.removeAttribute('data-hidden');
2546
- }
2547
- // Remove the placeholder content div sibling.
2548
- const phContent = stack.querySelector(`:scope > .dock-stack__pane[data-placeholder="true"]`);
2549
- phContent?.remove();
2550
- }
2551
- if (ph && ph.parentElement) {
2552
- ph.parentElement.removeChild(ph);
2553
- }
2554
- if (this.dragState) {
2555
- this.dragState.placeholderEl = null;
2556
- this.dragState.placeholderHeader = null;
2557
- }
2558
- }
2559
- startDragPointerTracking() {
2560
- if (this.dragPointerTrackingActive) {
2561
- return;
2562
- }
2563
- this.lastDragPointerPosition = null;
2564
- const win = this.windowRef;
2565
- win?.addEventListener('pointermove', this.onDragPointerMove, true);
2566
- win?.addEventListener('pointerup', this.onDragPointerUp, true);
2567
- win?.addEventListener('pointercancel', this.onDragPointerCancel, true);
2568
- this.dragPointerTrackingActive = true;
2569
- }
2570
- stopDragPointerTracking() {
2571
- if (!this.dragPointerTrackingActive) {
2572
- return;
2573
- }
2574
- const win = this.windowRef;
2575
- win?.removeEventListener('pointermove', this.onDragPointerMove, true);
2576
- win?.removeEventListener('pointerup', this.onDragPointerUp, true);
2577
- win?.removeEventListener('pointercancel', this.onDragPointerCancel, true);
2578
- this.dragPointerTrackingActive = false;
2579
- this.lastDragPointerPosition = null;
2580
- this.clearPendingDragEndTimeout();
2581
- }
2582
- onDragPointerMove(event) {
2583
- if (!this.dragState) {
2584
- this.stopDragPointerTracking();
2585
- return;
2586
- }
2587
- this.lastDragPointerPosition = { x: event.clientX, y: event.clientY };
2588
- this.updateDraggedFloatingPositionFromPoint(event.clientX, event.clientY);
2589
- }
2590
- onDragPointerUp(event) {
2591
- // Commit the drop from pointer release; the pointer-up coordinates are
2592
- // authoritative for which stack/zone the user dropped into.
2593
- if (this.dragState) {
2594
- const x = Number.isFinite(event.clientX) ? event.clientX : this.lastDragPointerPosition?.x;
2595
- const y = Number.isFinite(event.clientY) ? event.clientY : this.lastDragPointerPosition?.y;
2596
- if (x !== undefined && y !== undefined) {
2597
- this.finalizeDropFromPoint(x, y);
2598
- }
2599
- }
2600
- this.handleDragPointerUpCommon();
2601
- }
2602
- onDragPointerCancel() {
2603
- // OS-level cancel (e.g. pointer capture lost): end the drag without
2604
- // committing a drop.
2605
- this.handleDragPointerUpCommon();
2606
- }
2607
- // Convert a currently in-header tab drag into a floating window
2608
- convertPendingTabDragToFloating(clientX, clientY) {
2609
- if (!this.dragState) {
2610
- return;
2611
- }
2612
- const state = this.dragState;
2613
- if (state.floatingIndex !== null && state.floatingIndex >= 0) {
2614
- return; // already floating
2615
- }
2616
- // Clean up any placeholder before converting
2617
- this.clearHeaderDragPlaceholder();
2618
- const location = this.resolveStackLocation(state.sourcePath);
2619
- if (!location) {
2620
- return;
2621
- }
2622
- const pane = state.pane;
2623
- const stackEl = state.sourceStackEl ?? null;
2624
- const hostRect = this.getBoundingClientRect();
2625
- const stackRect = stackEl?.getBoundingClientRect() ?? null;
2626
- const metrics = this.pendingTabDragMetrics;
2627
- const fallbackWidth = 320;
2628
- const fallbackHeight = 240;
2629
- const width = metrics && Number.isFinite(metrics.width) && metrics.width > 0
2630
- ? metrics.width
2631
- : stackRect && Number.isFinite(stackRect.width)
2632
- ? stackRect.width
2633
- : fallbackWidth;
2634
- const height = metrics && Number.isFinite(metrics.height) && metrics.height > 0
2635
- ? metrics.height
2636
- : stackRect && Number.isFinite(stackRect.height)
2637
- ? stackRect.height
2638
- : fallbackHeight;
2639
- // Place the floating wrapper exactly where the docked stack was, so the
2640
- // pane appears in-place at the moment of detach instead of jumping under
2641
- // the cursor. metrics.left/top are host-relative (captured at pointerdown
2642
- // in captureTabDragMetrics). Compensate for the floating wrapper's 1px
2643
- // border so the visible content edge lines up with the original stack's
2644
- // visible content edge (the docked .dock-stack also has a 1px border, so
2645
- // the inner content rectangles match after this offset).
2646
- const FLOATING_BORDER = 1;
2647
- const initialLeft = metrics && Number.isFinite(metrics.left)
2648
- ? metrics.left - FLOATING_BORDER
2649
- : Number.isFinite(clientX)
2650
- ? clientX - hostRect.left - width / 2
2651
- : 0;
2652
- const initialTop = metrics && Number.isFinite(metrics.top)
2653
- ? metrics.top - FLOATING_BORDER
2654
- : Number.isFinite(clientY)
2655
- ? clientY - hostRect.top - height / 2
2656
- : 0;
2657
- // Derive pointerOffset from the cursor's actual position relative to the
2658
- // freshly-placed wrapper (not from pointerdown metrics) so the very next
2659
- // pointermove translates into a wrapper move of exactly the cursor delta
2660
- // — no jump, no drift.
2661
- const pointerOffsetX = Number.isFinite(clientX)
2662
- ? clientX - hostRect.left - initialLeft
2663
- : width / 2;
2664
- const pointerOffsetY = Number.isFinite(clientY)
2665
- ? clientY - hostRect.top - initialTop
2666
- : height / 2;
2667
- // Remove pane from its current stack and create a new floating entry
2668
- this.removePaneFromLocation(location, pane);
2669
- const floatingStack = {
2670
- kind: 'stack',
2671
- panes: [pane],
2672
- activePane: pane,
2673
- };
2674
- const floatingLayout = {
2675
- bounds: {
2676
- left: initialLeft,
2677
- top: initialTop,
2678
- width,
2679
- height,
2680
- },
2681
- root: floatingStack,
2682
- activePane: pane,
2683
- };
2684
- this.floatingLayouts.push(floatingLayout);
2685
- const newIndex = this.floatingLayouts.length - 1;
2686
- this.renderLayout();
2687
- const wrapper = this.getFloatingWrapper(newIndex);
2688
- if (wrapper) {
2689
- this.promoteFloatingPane(newIndex, wrapper);
2690
- }
2691
- this.liveAnnouncer.announce(`Pane ${this.titles[pane] ?? pane} torn off into a floating window.`);
2692
- // Update drag state so subsequent moves reposition the floating window
2693
- state.sourcePath = { type: 'floating', index: newIndex, segments: [] };
2694
- state.floatingIndex = newIndex;
2695
- state.pointerOffsetX = pointerOffsetX;
2696
- state.pointerOffsetY = pointerOffsetY;
2697
- // Now that the wrapper exists, mark it so pointer-events:none kicks in
2698
- // and findStackAtPoint can see through to docked stacks underneath.
2699
- this.markDraggedFloatingWrapper();
2700
- this.dispatchLayoutChanged();
2701
- }
2702
- // Toggle data-dragging on the floating wrapper currently associated with
2703
- // the active pane drag (dragState.floatingIndex), if any. Used to make the
2704
- // wrapper transparent to elementsFromPoint so drop zones can be shown on
2705
- // stacks underneath. clearDraggedFloatingWrapper() is the inverse.
2706
- markDraggedFloatingWrapper() {
2707
- const fi = this.dragState?.floatingIndex;
2708
- if (fi === null || fi === undefined || fi < 0)
2709
- return;
2710
- const wrapper = this.getFloatingWrapper(fi);
2711
- if (wrapper)
2712
- wrapper.dataset['dragging'] = 'true';
2713
- }
2714
- clearDraggedFloatingWrapperMarkers() {
2715
- const layer = this.floatingLayerEl;
2716
- if (!layer)
2717
- return;
2718
- layer.querySelectorAll('.dock-floating[data-dragging="true"]').forEach((el) => {
2719
- delete el.dataset['dragging'];
2720
- });
2721
- }
2722
- // Compute the intended tab insert index within a stack's strip based on pointer X.
2723
- // Uses the rendered tab buttons inside mp-tab-control's shadow strip for geometry;
2724
- // the dragged tab is hidden during drag (its content has data-hidden), and the
2725
- // placeholder button (if present) gives us the dragged-position reference.
2726
- computeHeaderInsertIndex(stack, clientX) {
2727
- if (stack.tagName !== 'MP-TAB-CONTROL')
2728
- return 0;
2729
- const allTabButtons = this.getStackTabButtons(stack);
2730
- if (allTabButtons.length === 0) {
2731
- return 0;
2732
- }
2733
- const placeholderHeader = stack.querySelector(':scope > .dock-tab[data-placeholder="true"]');
2734
- const placeholderTabId = placeholderHeader?.dataset['tabId'];
2735
- const placeholderButton = placeholderTabId
2736
- ? allTabButtons.find((b) => b.id === `${placeholderTabId}-header-button`) ?? null
2737
- : null;
2738
- // The dragged pane's content is `data-hidden`, but mp-tab-control's strip
2739
- // re-render is async (its MutationObserver schedules a Lit microtask). When
2740
- // beginPaneDrag calls updateDraggedFloatingPositionFromPoint synchronously
2741
- // right after preparePaneDragSource, this runs before that re-render — so
2742
- // the dragged button is still in the strip's shadow. We must exclude it
2743
- // explicitly, otherwise the loop counts it as a real target and the
2744
- // placeholder gets appended past the live tabs (visible on touch
2745
- // long-press, where the finger doesn't move and the user sees the
2746
- // mis-positioned placeholder for the duration of the hold).
2747
- const draggedPane = this.dragState?.pane ?? null;
2748
- let draggedTabId = null;
2749
- if (draggedPane) {
2750
- for (const child of Array.from(stack.children)) {
2751
- if (child instanceof HTMLElement &&
2752
- child.classList.contains('dock-tab') &&
2753
- !child.hasAttribute('data-placeholder') &&
2754
- child.dataset['pane'] === draggedPane) {
2755
- draggedTabId = child.dataset['tabId'] ?? null;
2756
- break;
2757
- }
2758
- }
2759
- }
2760
- const draggedButton = draggedTabId
2761
- ? allTabButtons.find((b) => b.id === `${draggedTabId}-header-button`) ?? null
2762
- : null;
2763
- const targets = allTabButtons.filter((b) => b !== placeholderButton && b !== draggedButton);
2764
- if (targets.length === 0) {
2765
- return 0;
2766
- }
2767
- const rightBias = 12;
2768
- const leftBias = 0;
2769
- const baseRect = placeholderButton ? placeholderButton.getBoundingClientRect() : null;
2770
- const rectValid = !!baseRect && Number.isFinite(baseRect.width) && baseRect.width > 0;
2771
- const draggedCenter = rectValid && baseRect ? baseRect.left + baseRect.width / 2 : null;
2772
- for (let i = 0; i < targets.length; i += 1) {
2773
- const rect = targets[i].getBoundingClientRect();
2774
- const baseMid = rect.left + rect.width / 2;
2775
- const isRightOfDragged = draggedCenter !== null ? baseMid >= draggedCenter : false;
2776
- const mid = isRightOfDragged ? baseMid + rightBias : baseMid - leftBias;
2777
- if (clientX < mid) {
2778
- return i;
2779
- }
2780
- }
2781
- return targets.length;
2782
- }
2783
- reorderPaneInLocationAtIndex(location, pane, targetIndex) {
2784
- const panes = location.node.panes;
2785
- const currentIndex = panes.indexOf(pane);
2786
- if (currentIndex === -1) {
2787
- return;
2788
- }
2789
- const clampedTarget = Math.max(0, Math.min(targetIndex, panes.length - 1));
2790
- if (clampedTarget === currentIndex) {
2791
- return;
2792
- }
2793
- panes.splice(currentIndex, 1);
2794
- panes.splice(clampedTarget, 0, pane);
2795
- location.node.activePane = pane;
2796
- if (location.context === 'floating') {
2797
- const floating = this.floatingLayouts[location.index];
2798
- if (floating) {
2799
- floating.activePane = pane;
2800
- }
2801
- }
2802
- }
2803
- // Commit a drop using current pointer coordinates and joystick state
2804
- finalizeDropFromPoint(clientX, clientY) {
2805
- if (!this.dragState) {
2806
- return;
2807
- }
2808
- const stack = this.findStackAtPoint(clientX, clientY);
2809
- const stackPath = stack ? this.parsePath(stack.dataset['path']) : null;
2810
- const joystickVisible = this.dropJoystick.dataset['visible'] === 'true';
2811
- const joystickStoredPath = this.parsePath(this.dropJoystick.dataset['path']);
2812
- const joystickTarget = this.dropJoystickTarget;
2813
- const joystickTargetPath = joystickTarget ? this.parsePath(joystickTarget.dataset['path']) : null;
2814
- const path = (joystickVisible ? (joystickStoredPath ?? joystickTargetPath) : null) ?? stackPath;
2815
- const joystickZone = this.dropJoystick.dataset['zone'];
2816
- const zone = this.isDropZone(joystickZone)
2817
- ? joystickZone
2818
- : (stack ? this.computeDropZone(stack, { clientX, clientY }, null) : null);
2819
- // Same-header reorder case when no side zone is chosen
2820
- if (this.dragState &&
2821
- this.dragState.floatingIndex !== null &&
2822
- this.dragState.floatingIndex < 0 &&
2823
- stack &&
2824
- path &&
2825
- stackPath &&
2826
- this.pathsEqual(stackPath, this.dragState.sourcePath) &&
2827
- (!zone || zone === 'center')) {
2828
- const location = this.resolveStackLocation(path);
2829
- if (location) {
2830
- const idx = this.computeHeaderInsertIndex(stack, clientX);
2831
- this.reorderPaneInLocationAtIndex(location, this.dragState.pane, idx);
2832
- this.renderLayout();
2833
- this.dispatchLayoutChanged();
2834
- this.dragState.dropHandled = true;
2835
- return;
2836
- }
2837
- }
2838
- if (path && this.isDropZone(zone)) {
2839
- this.handleDrop(path, zone);
2840
- this.dragState.dropHandled = true;
2841
- }
2842
- }
2843
- clearPendingDragEndTimeout() {
2844
- if (this.pendingDragEndTimeout !== null) {
2845
- const win = this.windowRef;
2846
- if (win && typeof this.pendingDragEndTimeout === 'number') {
2847
- win.clearTimeout(this.pendingDragEndTimeout);
2848
- }
2849
- else {
2850
- globalThis.clearTimeout(this.pendingDragEndTimeout);
2851
- }
2852
- this.pendingDragEndTimeout = null;
2853
- }
2854
- }
2855
- scheduleDeferredDragEnd() {
2856
- if (this.pendingDragEndTimeout !== null) {
2857
- return;
2858
- }
2859
- const completeDrag = () => {
2860
- this.pendingDragEndTimeout = null;
2861
- this.hideDropIndicator();
2862
- if (!this.dragState) {
2863
- this.clearPendingTabDragMetrics();
2864
- return;
2865
- }
2866
- this.endPaneDrag();
2867
- this.clearPendingTabDragMetrics();
2868
- };
2869
- const win = this.windowRef;
2870
- this.pendingDragEndTimeout = win
2871
- ? win.setTimeout(completeDrag, 0)
2872
- : setTimeout(completeDrag, 0);
2873
- }
2874
- handleDrop(targetPath, zone) {
2875
- if (!this.dragState || !targetPath) {
2876
- return;
2877
- }
2878
- const { pane, sourcePath } = this.dragState;
2879
- const source = this.resolveStackLocation(sourcePath);
2880
- const target = this.resolveStackLocation(targetPath);
2881
- // Special case: allow dropping onto an empty main dock area (no root).
2882
- if (!target && targetPath.type === 'docked' && !this.rootLayout) {
2883
- if (!source) {
2884
- return;
2885
- }
2886
- this.removePaneFromLocation(source, pane, true);
2887
- const newRoot = {
2888
- kind: 'stack',
2889
- panes: [pane],
2890
- activePane: pane,
2891
- };
2892
- this.rootLayout = newRoot;
2893
- this.normalizeAllLayouts();
2894
- this.renderLayout();
2895
- this.dispatchLayoutChanged();
2896
- if (this.dragState) {
2897
- this.dragState.dropHandled = true;
2898
- }
2899
- return;
2900
- }
2901
- if (!source || !target) {
2902
- return;
2903
- }
2904
- if (zone === 'center' && this.pathsEqual(sourcePath, targetPath)) {
2905
- if (!source.node.panes.includes(pane)) {
2906
- return;
2907
- }
2908
- this.reorderPaneInLocation(source, pane);
2909
- this.normalizeAllLayouts();
2910
- this.renderLayout();
2911
- this.dispatchLayoutChanged();
2912
- if (this.dragState) {
2913
- this.dragState.dropHandled = true;
2914
- }
2915
- return;
2916
- }
2917
- this.removePaneFromLocation(source, pane, true);
2918
- if (zone === 'center') {
2919
- this.addPaneToLocation(target, pane);
2920
- this.setActivePaneForLocation(target, pane);
2921
- this.normalizeAllLayouts();
2922
- this.renderLayout();
2923
- this.dispatchLayoutChanged();
2924
- if (this.dragState) {
2925
- this.dragState.dropHandled = true;
2926
- }
2927
- return;
2928
- }
2929
- const newStack = {
2930
- kind: 'stack',
2931
- panes: [pane],
2932
- activePane: pane,
2933
- };
2934
- if (target.context === 'docked') {
2935
- this.rootLayout = this.dockNodeBeside(this.rootLayout, target.node, newStack, zone);
2936
- }
2937
- else {
2938
- const floating = this.floatingLayouts[target.index];
2939
- if (!floating) {
2940
- this.normalizeAllLayouts();
2941
- this.renderLayout();
2942
- this.dispatchLayoutChanged();
2943
- return;
2944
- }
2945
- floating.root = this.dockNodeBeside(floating.root, target.node, newStack, zone);
2946
- floating.activePane = pane;
2947
- }
2948
- this.normalizeAllLayouts();
2949
- this.renderLayout();
2950
- this.dispatchLayoutChanged();
2951
- if (this.dragState) {
2952
- this.dragState.dropHandled = true;
2953
- }
2954
- }
2955
- handleFloatingStackDrop(sourceIndex, targetPath, zone) {
2956
- const source = this.floatingLayouts[sourceIndex];
2957
- if (!source || !source.root) {
2958
- return false;
2959
- }
2960
- const target = this.resolveStackLocation(targetPath);
2961
- // Allow dropping an entire floating stack onto an empty main dock area
2962
- // (no existing root).
2963
- if (!target && targetPath.type === 'docked' && !this.rootLayout) {
2964
- this.rootLayout = this.cloneLayoutNode(source.root);
2965
- this.removeFloatingAt(sourceIndex);
2966
- this.normalizeAllLayouts();
2967
- this.renderLayout();
2968
- this.dispatchLayoutChanged();
2969
- return true;
2970
- }
2971
- if (!target) {
2972
- return false;
2973
- }
2974
- if (target.context === 'floating' && target.index === sourceIndex) {
2975
- return false;
2976
- }
2977
- if (zone === 'center') {
2978
- const panes = this.collectPaneNames(source.root);
2979
- if (panes.length === 0) {
2980
- return false;
2981
- }
2982
- panes.forEach((pane) => {
2983
- this.addPaneToLocation(target, pane);
2984
- });
2985
- const activePane = source.activePane && panes.includes(source.activePane)
2986
- ? source.activePane
2987
- : this.findFirstPaneName(source.root) ?? panes[0];
2988
- if (activePane) {
2989
- this.setActivePaneForLocation(target, activePane);
2990
- }
2991
- this.removeFloatingAt(sourceIndex);
2992
- this.normalizeAllLayouts();
2993
- this.renderLayout();
2994
- this.dispatchLayoutChanged();
2995
- return true;
2996
- }
2997
- if (target.context === 'floating') {
2998
- const floating = this.floatingLayouts[target.index];
2999
- if (!floating) {
3000
- return false;
3001
- }
3002
- floating.root = this.dockNodeBeside(floating.root, target.node, source.root, zone);
3003
- floating.activePane = source.activePane ?? this.findFirstPaneName(source.root) ?? undefined;
3004
- this.removeFloatingAt(sourceIndex);
3005
- this.normalizeAllLayouts();
3006
- this.renderLayout();
3007
- this.dispatchLayoutChanged();
3008
- return true;
3009
- }
3010
- this.rootLayout = this.dockNodeBeside(this.rootLayout, target.node, source.root, zone);
3011
- this.removeFloatingAt(sourceIndex);
3012
- this.normalizeAllLayouts();
3013
- this.renderLayout();
3014
- this.dispatchLayoutChanged();
3015
- return true;
3016
- }
3017
- insertWeight(sizes, index, totalChildren) {
3018
- const existingCount = totalChildren - 1;
3019
- const normalized = this.normalizeSizesArray(sizes, existingCount);
3020
- const newWeight = 1 / totalChildren;
3021
- const remaining = 1 - newWeight;
3022
- const result = [];
3023
- for (let i = 0; i < totalChildren; i += 1) {
3024
- if (i === index) {
3025
- result.push(newWeight);
3026
- }
3027
- else {
3028
- const sourceIndex = i < index ? i : i - 1;
3029
- result.push(normalized[sourceIndex] * remaining);
3030
- }
3031
- }
3032
- return result;
3033
- }
3034
- removePaneFromStack(stack, pane, skipCleanup = false) {
3035
- stack.panes = stack.panes.filter((p) => p !== pane);
3036
- if (!stack.panes.includes(stack.activePane ?? '')) {
3037
- if (stack.panes.length > 0) {
3038
- stack.activePane = stack.panes[0];
3039
- }
3040
- else {
3041
- delete stack.activePane;
3042
- }
3043
- }
3044
- if (stack.panes.length > 0) {
3045
- return false;
3046
- }
3047
- if (skipCleanup) {
3048
- return true;
3049
- }
3050
- this.normalizeAllLayouts();
3051
- return true;
3052
- }
3053
- findParentSplit(node, child) {
3054
- if (!node || node === child) {
3055
- return null;
3056
- }
3057
- if (node.kind !== 'split') {
3058
- return null;
3059
- }
3060
- const index = node.children.indexOf(child);
3061
- if (index !== -1) {
3062
- return { parent: node, index };
3063
- }
3064
- for (let i = 0; i < node.children.length; i += 1) {
3065
- const result = this.findParentSplit(node.children[i], child);
3066
- if (result) {
3067
- return result;
3068
- }
3069
- }
3070
- return null;
3071
- }
3072
- computeDropZone(stack, point, zoneHint) {
3073
- // Do not force a zone: even when the main area is empty we only
3074
- // activate a zone when the pointer is actually over a joystick button.
3075
- const hintedZone = this.isDropZone(zoneHint) ? zoneHint : null;
3076
- if (hintedZone) {
3077
- this.updateDropJoystickActiveZone(hintedZone);
3078
- return hintedZone;
3079
- }
3080
- const pointZone = point &&
3081
- Number.isFinite(point.clientX) &&
3082
- Number.isFinite(point.clientY)
3083
- ? this.findDropZoneByPoint(point.clientX, point.clientY)
3084
- : null;
3085
- if (pointZone) {
3086
- this.updateDropJoystickActiveZone(pointZone);
3087
- return pointZone;
3088
- }
3089
- if (this.dropJoystickTarget === stack) {
3090
- // Be sticky while hovering the joystick: if we recently had a zone
3091
- // selected, prefer keeping it instead of briefly clearing to null
3092
- // when the browser reports transient coordinates/targets during drag.
3093
- const sticky = this.dropJoystick.dataset['zone'];
3094
- if (this.isDropZone(sticky)) {
3095
- this.updateDropJoystickActiveZone(sticky);
3096
- return sticky;
3097
- }
3098
- this.updateDropJoystickActiveZone(null);
3099
- }
3100
- return null;
3101
- }
3102
- extractDropZoneFromEvent(event) {
3103
- if (!event) {
3104
- return null;
3105
- }
3106
- if (typeof event.composedPath === 'function') {
3107
- const path = event.composedPath();
3108
- const zone = this.findDropZoneInTargets(path);
3109
- if (zone) {
3110
- return zone;
3111
- }
3112
- }
3113
- if ('clientX' in event && 'clientY' in event) {
3114
- const pointEvent = event;
3115
- const zoneFromPoint = this.findDropZoneByPoint(pointEvent.clientX, pointEvent.clientY);
3116
- if (zoneFromPoint) {
3117
- return zoneFromPoint;
3118
- }
3119
- }
3120
- return null;
3121
- }
3122
- handleDragPointerUpCommon() {
3123
- if (!this.dragState) {
3124
- this.stopDragPointerTracking();
3125
- return;
3126
- }
3127
- this.scheduleDeferredDragEnd();
3128
- }
3129
- findDropZoneInTargets(targets) {
3130
- for (const target of targets) {
3131
- if (target instanceof HTMLElement &&
3132
- target.classList.contains('dock-drop-joystick__button')) {
3133
- const zone = target.dataset?.['zone'];
3134
- if (this.isDropZone(zone)) {
3135
- return zone;
3136
- }
3137
- }
3138
- }
3139
- return null;
3140
- }
3141
- findDropZoneByPoint(clientX, clientY) {
3142
- if (!this.dropJoystickButtons ||
3143
- this.dropJoystick.dataset['visible'] !== 'true' ||
3144
- !this.dropJoystickTarget) {
3145
- return null;
3146
- }
3147
- for (const button of this.dropJoystickButtons) {
3148
- // Skip hidden/inactive buttons (used in center-only mode)
3149
- if ((button.dataset['hidden'] === 'true') || button.style.visibility === 'hidden' || button.style.display === 'none') {
3150
- continue;
3151
- }
3152
- const rect = button.getBoundingClientRect();
3153
- if (clientX >= rect.left &&
3154
- clientX <= rect.right &&
3155
- clientY >= rect.top &&
3156
- clientY <= rect.bottom) {
3157
- const zone = button.dataset['zone'];
3158
- if (this.isDropZone(zone)) {
3159
- return zone;
3160
- }
3161
- }
3162
- }
3163
- return null;
3164
- }
3165
- updateDropJoystickActiveZone(zone) {
3166
- // If no zone is computed but the joystick is visible, keep the last
3167
- // known active zone to avoid visual jitter while dragging across
3168
- // small gaps where hit‑testing momentarily fails.
3169
- const visible = this.dropJoystick.dataset['visible'] === 'true';
3170
- const sticky = visible ? this.dropJoystick.dataset['zone'] : undefined;
3171
- const effectiveZone = zone ?? (this.isDropZone(sticky) ? sticky : null);
3172
- this.dropJoystickButtons.forEach((button) => {
3173
- const isActive = effectiveZone !== null && button.dataset['zone'] === effectiveZone;
3174
- if (isActive) {
3175
- button.dataset['active'] = 'true';
3176
- }
3177
- else {
3178
- delete button.dataset['active'];
3179
- }
3180
- });
3181
- if (effectiveZone) {
3182
- this.dropJoystick.dataset['zone'] = effectiveZone;
3183
- }
3184
- else {
3185
- delete this.dropJoystick.dataset['zone'];
3186
- }
3187
- }
3188
- isDropZone(value) {
3189
- return value === 'left' || value === 'right' || value === 'top' || value === 'bottom' || value === 'center';
3190
- }
3191
- showDropIndicator(stack, zone) {
3192
- const targetPath = this.parsePath(stack.dataset['path']);
3193
- const sourcePath = this.dragState?.sourcePath ?? null;
3194
- if (targetPath && sourcePath && this.isOrIsAncestorOf(targetPath, sourcePath)) {
3195
- // Don't show any drop indicators on the pane being dragged.
3196
- return;
3197
- }
3198
- const rect = stack.getBoundingClientRect();
3199
- const hostRect = this.getBoundingClientRect();
3200
- const indicator = this.dropIndicator;
3201
- const joystick = this.dropJoystick;
3202
- joystick.hidden = false;
3203
- const path = this.parsePath(stack.dataset['path']);
3204
- let overlayZ = 100;
3205
- if (path && path.type === 'floating') {
3206
- overlayZ = this.getFloatingPaneZIndex(path.index) + 100;
3207
- }
3208
- indicator.style.zIndex = String(overlayZ);
3209
- joystick.style.zIndex = String(overlayZ + 1);
3210
- let left = rect.left - hostRect.left;
3211
- let top = rect.top - hostRect.top;
3212
- let width = rect.width;
3213
- let height = rect.height;
3214
- const portion = 0.5;
3215
- if (zone) {
3216
- switch (zone) {
3217
- case 'left':
3218
- width = rect.width * portion;
3219
- break;
3220
- case 'right':
3221
- width = rect.width * portion;
3222
- left += rect.width * (1 - portion);
3223
- break;
3224
- case 'top':
3225
- height = rect.height * portion;
3226
- break;
3227
- case 'bottom':
3228
- height = rect.height * portion;
3229
- top += rect.height * (1 - portion);
3230
- break;
3231
- default:
3232
- break;
3233
- }
3234
- indicator.style.left = `${left}px`;
3235
- indicator.style.top = `${top}px`;
3236
- indicator.style.width = `${width}px`;
3237
- indicator.style.height = `${height}px`;
3238
- indicator.dataset['visible'] = 'true';
3239
- }
3240
- else {
3241
- indicator.dataset['visible'] = 'false';
3242
- }
3243
- joystick.style.left = `${rect.left - hostRect.left + rect.width / 2}px`;
3244
- joystick.style.top = `${rect.top - hostRect.top + rect.height / 2}px`;
3245
- joystick.dataset['visible'] = 'true';
3246
- this.dropJoystick.style.display = 'grid';
3247
- joystick.dataset['path'] = stack.dataset['path'] ?? '';
3248
- const changedTarget = this.dropJoystickTarget && this.dropJoystickTarget !== stack;
3249
- this.dropJoystickTarget = stack;
3250
- if (changedTarget) {
3251
- // New target stack: forget any previously sticky zone.
3252
- delete this.dropJoystick.dataset['zone'];
3253
- }
3254
- // If main dock area is empty, show only the center button and collapse the grid
3255
- const isEmptyMainArea = !this.rootLayout && (stack === this.dockedEl || (targetPath && targetPath.type === 'docked' && targetPath.segments.length === 0));
3256
- const spacers = Array.from(this.dropJoystick.querySelectorAll('.dock-drop-joystick__spacer'));
3257
- if (isEmptyMainArea) {
3258
- // Keep spacers visible so the joystick keeps its circular footprint.
3259
- spacers.forEach((s) => {
3260
- s.style.display = '';
3261
- });
3262
- this.dropJoystickButtons.forEach((btn) => {
3263
- const isCenter = btn.dataset['zone'] === 'center';
3264
- if (isCenter) {
3265
- btn.style.visibility = '';
3266
- btn.style.pointerEvents = '';
3267
- delete btn.dataset['hidden'];
3268
- btn.style.display = '';
3269
- }
3270
- else {
3271
- // Hide visually but keep layout space; also prevent interaction.
3272
- btn.style.visibility = 'hidden';
3273
- btn.style.pointerEvents = 'none';
3274
- btn.dataset['hidden'] = 'true';
3275
- btn.style.display = '';
3276
- }
3277
- });
3278
- // Keep default 3x3 grid so the circular background size stays the same.
3279
- this.dropJoystick.style.gridTemplateColumns = '';
3280
- this.dropJoystick.style.gridTemplateRows = '';
3281
- // Do not set an active zone automatically; users must hover the button.
3282
- }
3283
- else {
3284
- this.dropJoystickButtons.forEach((btn) => {
3285
- btn.style.visibility = '';
3286
- btn.style.pointerEvents = '';
3287
- delete btn.dataset['hidden'];
3288
- btn.style.display = '';
3289
- });
3290
- spacers.forEach((s) => (s.style.display = ''));
3291
- this.dropJoystick.style.gridTemplateColumns = '';
3292
- this.dropJoystick.style.gridTemplateRows = '';
3293
- }
3294
- this.updateDropJoystickActiveZone(zone);
3295
- }
3296
- hideDropIndicator() {
3297
- this.dropIndicator.dataset['visible'] = 'false';
3298
- this.dropJoystick.dataset['visible'] = 'false';
3299
- this.dropJoystick.style.display = 'none';
3300
- delete this.dropJoystick.dataset['path'];
3301
- this.dropJoystickTarget = null;
3302
- this.updateDropJoystickActiveZone(null);
3303
- // Restore joystick structure to default.
3304
- this.dropJoystickButtons.forEach((btn) => {
3305
- btn.style.display = '';
3306
- btn.style.visibility = '';
3307
- btn.style.pointerEvents = '';
3308
- delete btn.dataset['hidden'];
3309
- });
3310
- Array.from(this.dropJoystick.querySelectorAll('.dock-drop-joystick__spacer')).forEach((s) => (s.style.display = ''));
3311
- this.dropJoystick.style.gridTemplateColumns = '';
3312
- this.dropJoystick.style.gridTemplateRows = '';
3313
- }
3314
- findStackAtPoint(clientX, clientY) {
3315
- const shadow = this.shadowRoot;
3316
- if (!shadow) {
3317
- return null;
3318
- }
3319
- const elements = shadow.elementsFromPoint(clientX, clientY);
3320
- const stack = this.findStackInTargets(elements);
3321
- if (stack) {
3322
- return stack;
3323
- }
3324
- // If there are no docked stacks (all panes are floating), allow the
3325
- // docked surface itself to serve as a drop target for the main zone.
3326
- if (!this.rootLayout) {
3327
- const dockRect = this.dockedEl.getBoundingClientRect();
3328
- if (clientX >= dockRect.left &&
3329
- clientX <= dockRect.right &&
3330
- clientY >= dockRect.top &&
3331
- clientY <= dockRect.bottom) {
3332
- return this.dockedEl;
3333
- }
3334
- }
3335
- return null;
3336
- }
3337
- findStackInTargets(targets) {
3338
- for (const element of targets) {
3339
- if (!(element instanceof HTMLElement)) {
3340
- continue;
3341
- }
3342
- if (element.classList.contains('dock-stack')) {
3343
- return element;
3344
- }
3345
- if (this.dropJoystickTarget &&
3346
- (element.classList.contains('dock-drop-joystick') ||
3347
- element.classList.contains('dock-drop-joystick__button') ||
3348
- element.classList.contains('dock-drop-joystick__spacer'))) {
3349
- return this.dropJoystickTarget;
3350
- }
3351
- }
3352
- return null;
3353
- }
3354
- activatePane(stack, paneName, path) {
3355
- stack.dataset['activePane'] = paneName;
3356
- // Reflect to mp-tab-control's `active-tab` attribute. The WC handles
3357
- // strip button styling (active class, aria-selected) + body-slot
3358
- // projection automatically via the named-slot pattern.
3359
- if (stack.tagName === 'MP-TAB-CONTROL') {
3360
- const headerSpan = stack.querySelector(`:scope > .dock-tab[data-pane="${CSS.escape(paneName)}"]`);
3361
- const tabId = headerSpan?.dataset['tabId'];
3362
- if (tabId) {
3363
- stack.setAttribute('active-tab', tabId);
3364
- }
3365
- }
3366
- const location = this.resolveStackLocation(path);
3367
- if (!location) {
3368
- return;
3369
- }
3370
- location.node.activePane = paneName;
3371
- if (path.type === 'floating') {
3372
- const floating = this.floatingLayouts[path.index];
3373
- if (floating) {
3374
- floating.activePane = paneName;
3375
- }
3376
- this.updateFloatingWindowTitle(path.index);
3377
- }
3378
- this.dispatchLayoutChanged();
3379
- }
3380
- getNodeAtPath(root, path) {
3381
- if (!root) {
3382
- return null;
3383
- }
3384
- let current = root;
3385
- if (path.length === 0) {
3386
- return current;
3387
- }
3388
- for (const segment of path) {
3389
- if (!current || current.kind !== 'split') {
3390
- return null;
3391
- }
3392
- current = current.children[segment] ?? null;
3393
- }
3394
- return current;
3395
- }
3396
- resolveSplitNode(path) {
3397
- if (path.type === 'docked') {
3398
- const node = this.getNodeAtPath(this.rootLayout, path.segments);
3399
- return node && node.kind === 'split' ? node : null;
3400
- }
3401
- const floating = this.floatingLayouts[path.index];
3402
- if (!floating || !floating.root) {
3403
- return null;
3404
- }
3405
- const node = this.getNodeAtPath(floating.root, path.segments);
3406
- return node && node.kind === 'split' ? node : null;
3407
- }
3408
- replaceNodeInTree(root, target, replacement) {
3409
- if (!root) {
3410
- return replacement;
3411
- }
3412
- if (root === target) {
3413
- return replacement;
3414
- }
3415
- const parentInfo = this.findParentSplit(root, target);
3416
- if (!parentInfo) {
3417
- return root;
3418
- }
3419
- parentInfo.parent.children[parentInfo.index] = replacement;
3420
- this.normalizeSplitNode(parentInfo.parent);
3421
- return root;
3422
- }
3423
- dockNodeBeside(root, targetNode, newNode, zone) {
3424
- const orientation = zone === 'left' || zone === 'right' ? 'horizontal' : 'vertical';
3425
- const placeBefore = zone === 'left' || zone === 'top';
3426
- const parentInfo = this.findParentSplit(root, targetNode);
3427
- if (parentInfo && parentInfo.parent.direction === orientation) {
3428
- const insertIndex = placeBefore ? parentInfo.index : parentInfo.index + 1;
3429
- parentInfo.parent.children.splice(insertIndex, 0, newNode);
3430
- parentInfo.parent.sizes = this.insertWeight(parentInfo.parent.sizes, insertIndex, parentInfo.parent.children.length);
3431
- return root ?? newNode;
3432
- }
3433
- const split = {
3434
- kind: 'split',
3435
- direction: orientation,
3436
- children: placeBefore ? [newNode, targetNode] : [targetNode, newNode],
3437
- sizes: [0.5, 0.5],
3438
- };
3439
- return this.replaceNodeInTree(root, targetNode, split);
3440
- }
3441
- forEachStack(node, visitor, path = []) {
3442
- if (!node) {
3443
- return;
3444
- }
3445
- if (node.kind === 'stack') {
3446
- visitor(node, path);
3447
- return;
3448
- }
3449
- node.children.forEach((child, index) => this.forEachStack(child, visitor, [...path, index]));
3450
- }
3451
- findStackContainingPane(node, pane) {
3452
- let result = null;
3453
- this.forEachStack(node, (stack) => {
3454
- if (!result && stack.panes.includes(pane)) {
3455
- result = stack;
3456
- }
3457
- });
3458
- return result;
3459
- }
3460
- findFirstPaneName(node) {
3461
- let found = null;
3462
- this.forEachStack(node, (stack) => {
3463
- if (found || stack.panes.length === 0) {
3464
- return;
3465
- }
3466
- if (stack.activePane && stack.panes.includes(stack.activePane)) {
3467
- found = stack.activePane;
3468
- }
3469
- else {
3470
- found = stack.panes[0];
3471
- }
3472
- });
3473
- return found;
3474
- }
3475
- collectFloatingPaneMetadata(node) {
3476
- // Deprecated method retained temporarily for signature compatibility.
3477
- // Use collectPaneNames instead.
3478
- const panes = this.collectPaneNames(node);
3479
- const titles = {};
3480
- panes.forEach((p) => {
3481
- const t = this.titles[p];
3482
- if (t) {
3483
- titles[p] = t;
3484
- }
3485
- });
3486
- return { panes, titles };
3487
- }
3488
- collectPaneNames(node) {
3489
- const panes = [];
3490
- this.forEachStack(node, (stack) => {
3491
- stack.panes.forEach((pane) => panes.push(pane));
3492
- });
3493
- return panes;
3494
- }
3495
- normalizeFloatingLayout(layout) {
3496
- const bounds = layout.bounds ?? { left: 0, top: 0, width: 320, height: 200 };
3497
- const normalizedBounds = {
3498
- left: Number.isFinite(bounds.left) ? bounds.left : 0,
3499
- top: Number.isFinite(bounds.top) ? bounds.top : 0,
3500
- width: Number.isFinite(bounds.width) ? Math.max(bounds.width, 160) : 320,
3501
- height: Number.isFinite(bounds.height) ? Math.max(bounds.height, 120) : 200,
3502
- };
3503
- const root = layout.root ? this.cloneLayoutNode(layout.root) : null;
3504
- return {
3505
- id: layout.id,
3506
- bounds: normalizedBounds,
3507
- zIndex: layout.zIndex,
3508
- root,
3509
- activePane: layout.activePane,
3510
- };
3511
- }
3512
- formatPath(path) {
3513
- if (path.type === 'floating') {
3514
- const suffix = path.segments.length > 0
3515
- ? `/${path.segments.map((segment) => segment.toString()).join('/')}`
3516
- : '';
3517
- return `f:${path.index}${suffix}`;
3518
- }
3519
- const suffix = path.segments.join('/');
3520
- return suffix.length > 0 ? `d:${suffix}` : 'd:';
3521
- }
3522
- clonePath(path) {
3523
- if (path.type === 'floating') {
3524
- return { type: 'floating', index: path.index, segments: [...path.segments] };
3525
- }
3526
- return { type: 'docked', segments: [...path.segments] };
3527
- }
3528
- parsePath(path) {
3529
- // The root splitter is tagged with data-path="" (raw segments-join of an
3530
- // empty array) so empty string is a valid path representing root docked.
3531
- // Only null/undefined is "no path".
3532
- if (path == null) {
3533
- return null;
3534
- }
3535
- if (path.startsWith('f:')) {
3536
- const remainder = path.slice(2);
3537
- const [indexPart, ...segmentParts] = remainder.split('/');
3538
- const index = Number.parseInt(indexPart, 10);
3539
- if (!Number.isFinite(index)) {
3540
- return null;
3541
- }
3542
- const segments = segmentParts
3543
- .filter((segment) => segment.length > 0)
3544
- .map((segment) => Number.parseInt(segment, 10))
3545
- .filter((value) => Number.isFinite(value));
3546
- return { type: 'floating', index, segments };
3547
- }
3548
- const normalized = path.startsWith('d:') ? path.slice(2) : path;
3549
- if (normalized.length === 0) {
3550
- return { type: 'docked', segments: [] };
3551
- }
3552
- const segments = normalized
3553
- .split('/')
3554
- .filter((segment) => segment.length > 0)
3555
- .map((segment) => Number.parseInt(segment, 10))
3556
- .filter((value) => Number.isFinite(value));
3557
- return { type: 'docked', segments };
3558
- }
3559
- pathsEqual(a, b) {
3560
- if (a.type !== b.type) {
3561
- return false;
3562
- }
3563
- if (a.type === 'floating') {
3564
- const other = b;
3565
- if (a.index !== other.index) {
3566
- return false;
3567
- }
3568
- if (a.segments.length !== other.segments.length) {
3569
- return false;
3570
- }
3571
- return a.segments.every((value, index) => value === other.segments[index]);
3572
- }
3573
- const other = b;
3574
- if (a.segments.length !== other.segments.length) {
3575
- return false;
3576
- }
3577
- return a.segments.every((value, index) => value === other.segments[index]);
3578
- }
3579
- isOrIsAncestorOf(ancestor, descendant) {
3580
- if (ancestor.type !== descendant.type) {
3581
- return false;
3582
- }
3583
- if (ancestor.type === 'floating') {
3584
- if (descendant.index !== ancestor.index) {
3585
- return false;
3586
- }
3587
- }
3588
- if (ancestor.segments.length > descendant.segments.length) {
3589
- return false;
3590
- }
3591
- return ancestor.segments.every((segment, i) => segment === descendant.segments[i]);
3592
- }
3593
- countPanesInTree(node) {
3594
- if (!node) {
3595
- return 0;
3596
- }
3597
- if (node.kind === 'stack') {
3598
- return node.panes.length;
3599
- }
3600
- return node.children.reduce((total, child) => total + this.countPanesInTree(child), 0);
3601
- }
3602
- resolveStackLocation(path) {
3603
- if (path.type === 'floating') {
3604
- const layout = this.floatingLayouts[path.index];
3605
- if (!layout || !layout.root) {
3606
- return null;
3607
- }
3608
- const node = this.getNodeAtPath(layout.root, path.segments);
3609
- if (!node || node.kind !== 'stack') {
3610
- return null;
3611
- }
3612
- return { context: 'floating', index: path.index, path: [...path.segments], node };
3613
- }
3614
- const node = this.getNodeAtPath(this.rootLayout, path.segments);
3615
- if (!node || node.kind !== 'stack') {
3616
- return null;
3617
- }
3618
- return { context: 'docked', path: [...path.segments], node };
3619
- }
3620
- removePaneFromLocation(location, pane, skipCleanup = false) {
3621
- if (location.context === 'docked') {
3622
- return this.removePaneFromStack(location.node, pane, skipCleanup);
3623
- }
3624
- return this.removePaneFromFloating(location.index, location.path, pane, skipCleanup);
3625
- }
3626
- addPaneToLocation(location, pane) {
3627
- const panes = location.node.panes;
3628
- const existingIndex = panes.indexOf(pane);
3629
- if (existingIndex !== -1) {
3630
- panes.splice(existingIndex, 1);
3631
- }
3632
- panes.push(pane);
3633
- }
3634
- setActivePaneForLocation(location, pane) {
3635
- location.node.activePane = pane;
3636
- if (location.context === 'floating') {
3637
- const floating = this.floatingLayouts[location.index];
3638
- if (floating) {
3639
- floating.activePane = pane;
3640
- }
3641
- }
3642
- }
3643
- reorderPaneInLocation(location, pane) {
3644
- const panes = location.node.panes;
3645
- const index = panes.indexOf(pane);
3646
- if (index === -1) {
3647
- return;
3648
- }
3649
- panes.splice(index, 1);
3650
- panes.push(pane);
3651
- location.node.activePane = pane;
3652
- if (location.context === 'floating') {
3653
- const floating = this.floatingLayouts[location.index];
3654
- if (floating) {
3655
- floating.activePane = pane;
3656
- }
3657
- }
3658
- }
3659
- removeFloatingAt(index) {
3660
- if (index < 0 || index >= this.floatingLayouts.length) {
3661
- return;
3662
- }
3663
- this.floatingLayouts.splice(index, 1);
3664
- }
3665
- /**
3666
- * Keyboard handler on the dock root, registered in capture phase so it
3667
- * runs before mp-tab-control's shadow-internal handlers swallow Arrow /
3668
- * Home / End / Enter. M opens move mode on a focused tab; subsequent
3669
- * letter keys (T/R/B/L/F) commit the move; Escape cancels.
3670
- */
3671
- onRootKeyDown(event) {
3672
- if (this.paneMoveMode) {
3673
- this.handlePaneMoveModeKey(event);
3674
- return;
3675
- }
3676
- if (event.key !== 'm' && event.key !== 'M')
3677
- return;
3678
- const focused = this.findFocusedPaneOrigin();
3679
- if (!focused)
3680
- return;
3681
- event.preventDefault();
3682
- event.stopPropagation();
3683
- this.paneMoveMode = focused;
3684
- const title = this.titles[focused.paneName] ?? focused.paneName;
3685
- this.liveAnnouncer.announce(`Move mode for pane ${title}. Press T, R, B, or L to dock to top, right, bottom, or left of the current stack. Press F to float. Escape to cancel.`);
3686
- }
3687
- handlePaneMoveModeKey(event) {
3688
- if (event.key === 'Escape') {
3689
- event.preventDefault();
3690
- event.stopPropagation();
3691
- this.paneMoveMode = null;
3692
- this.liveAnnouncer.announce('Move cancelled.');
3693
- return;
3694
- }
3695
- const key = event.key.toLowerCase();
3696
- const zoneByKey = {
3697
- t: 'top', r: 'right', b: 'bottom', l: 'left', f: 'float',
3698
- };
3699
- const choice = zoneByKey[key];
3700
- if (!choice)
3701
- return;
3702
- event.preventDefault();
3703
- event.stopPropagation();
3704
- if (choice === 'float')
3705
- this.commitPaneMoveAsFloat();
3706
- else
3707
- this.commitPaneMoveToZone(choice);
3708
- }
3709
- /**
3710
- * Walk the focused element through nested shadow roots to find a focused
3711
- * tab button, then map it back to the dock's pane name + source path via
3712
- * the data attributes on the slotted .dock-tab span.
3713
- */
3714
- findFocusedPaneOrigin() {
3715
- if (!this.shadowRoot)
3716
- return null;
3717
- let active = this.shadowRoot.activeElement;
3718
- while (active && active.shadowRoot && active.shadowRoot.activeElement) {
3719
- active = active.shadowRoot.activeElement;
3720
- }
3721
- if (!active || active.getAttribute('role') !== 'tab')
3722
- return null;
3723
- // mp-tab-control assigns the role=tab button id `${tabId}-header-button`,
3724
- // while the dock's `.dock-tab` slot wrapper carries `data-tab-id=${tabId}`.
3725
- // Strip the suffix so the lookup matches the slot wrapper.
3726
- const tabId = active.id.replace(/-header-button$/, '');
3727
- const headerSpan = this.shadowRoot.querySelector(`.dock-tab[data-tab-id="${tabId}"]`);
3728
- if (!headerSpan)
3729
- return null;
3730
- const stack = headerSpan.closest('.dock-stack');
3731
- if (!stack)
3732
- return null;
3733
- const path = this.parsePath(stack.dataset['path']);
3734
- if (!path)
3735
- return null;
3736
- return { paneName: headerSpan.dataset['pane'], sourcePath: path };
3737
- }
3738
- /**
3739
- * Synthesise a minimal dragState so handleDrop's existing pipeline can
3740
- * commit the keyboard-driven move. handleDrop reads {pane, sourcePath,
3741
- * dropHandled} — the rest of dragState is pointer-drag bookkeeping that
3742
- * doesn't apply here.
3743
- */
3744
- synthesiseDragStateForKeyboardMove() {
3745
- if (!this.paneMoveMode)
3746
- return;
3747
- this.dragState = {
3748
- pane: this.paneMoveMode.paneName,
3749
- sourcePath: this.clonePath(this.paneMoveMode.sourcePath),
3750
- floatingIndex: this.paneMoveMode.sourcePath.type === 'floating'
3751
- ? this.paneMoveMode.sourcePath.index
3752
- : null,
3753
- pointerOffsetX: 0,
3754
- pointerOffsetY: 0,
3755
- dropHandled: false,
3756
- sourceStackEl: null,
3757
- sourceHeaderBounds: null,
3758
- startClientX: 0,
3759
- startClientY: 0,
3760
- };
3761
- }
3762
- commitPaneMoveToZone(zone) {
3763
- if (!this.paneMoveMode)
3764
- return;
3765
- const move = this.paneMoveMode;
3766
- this.synthesiseDragStateForKeyboardMove();
3767
- // Source stack is also the target stack — handleDrop creates a sibling
3768
- // split with the moved pane on the chosen side.
3769
- this.handleDrop(move.sourcePath, zone);
3770
- this.dragState = null;
3771
- this.paneMoveMode = null;
3772
- const title = this.titles[move.paneName] ?? move.paneName;
3773
- this.liveAnnouncer.announce(`Pane ${title} docked to ${zone}.`);
3774
- }
3775
- commitPaneMoveAsFloat() {
3776
- if (!this.paneMoveMode)
3777
- return;
3778
- const move = this.paneMoveMode;
3779
- const source = this.resolveStackLocation(move.sourcePath);
3780
- if (!source) {
3781
- this.paneMoveMode = null;
3782
- return;
3783
- }
3784
- this.removePaneFromLocation(source, move.paneName, true);
3785
- const floatingLayout = {
3786
- bounds: {
3787
- left: 100 + this.floatingLayouts.length * 24,
3788
- top: 100 + this.floatingLayouts.length * 24,
3789
- width: 320,
3790
- height: 200,
3791
- },
3792
- root: { kind: 'stack', panes: [move.paneName], activePane: move.paneName },
3793
- activePane: move.paneName,
3794
- };
3795
- this.floatingLayouts.push(floatingLayout);
3796
- this.normalizeAllLayouts();
3797
- this.renderLayout();
3798
- this.dispatchLayoutChanged();
3799
- this.paneMoveMode = null;
3800
- const title = this.titles[move.paneName] ?? move.paneName;
3801
- this.liveAnnouncer.announce(`Pane ${title} torn off into a floating window.`);
3802
- }
3803
- /**
3804
- * Close a floating pane via the chrome's close button (or any external
3805
- * caller). Announces the close to SR users, redraws the dock, and emits a
3806
- * layout-changed event. Phase 4 of the WC ARIA PRD — the floating chrome
3807
- * had no close affordance before this; users had to programmatically pop
3808
- * the pane out of `floatingLayouts`.
3809
- */
3810
- closeFloatingPane(index) {
3811
- const floating = this.floatingLayouts[index];
3812
- if (!floating)
3813
- return;
3814
- const title = this.getFloatingWindowTitle(floating);
3815
- this.removeFloatingAt(index);
3816
- this.renderLayout();
3817
- this.dispatchLayoutChanged();
3818
- this.liveAnnouncer.announce(`Closed floating pane ${title}.`);
3819
- }
3820
- removePaneFromFloating(index, path, pane, skipCleanup = false) {
3821
- const floating = this.floatingLayouts[index];
3822
- if (!floating || !floating.root) {
3823
- return false;
3824
- }
3825
- const node = this.getNodeAtPath(floating.root, path);
3826
- if (!node || node.kind !== 'stack') {
3827
- return false;
3828
- }
3829
- node.panes = node.panes.filter((p) => p !== pane);
3830
- if (!node.panes.includes(node.activePane ?? '')) {
3831
- if (node.panes.length > 0) {
3832
- node.activePane = node.panes[0];
3833
- }
3834
- else {
3835
- delete node.activePane;
3836
- }
3837
- }
3838
- if (floating.activePane === pane) {
3839
- const fallback = this.findFirstPaneName(floating.root);
3840
- if (fallback) {
3841
- floating.activePane = fallback;
3842
- }
3843
- else {
3844
- delete floating.activePane;
3845
- }
3846
- }
3847
- if (node.panes.length > 0) {
3848
- return false;
3849
- }
3850
- if (skipCleanup) {
3851
- return true;
3852
- }
3853
- this.normalizeAllLayouts();
3854
- return true;
3855
- }
3856
- normalizeSizesArray(sizes, count) {
3857
- if (count <= 0) {
3858
- return [];
3859
- }
3860
- if (!Array.isArray(sizes) || sizes.length !== count) {
3861
- return Array.from({ length: count }, () => 1 / count);
3862
- }
3863
- const normalized = sizes.map((value) => (Number.isFinite(value) ? Math.max(value, 0) : 0));
3864
- const total = normalized.reduce((acc, value) => acc + value, 0);
3865
- if (total <= 0) {
3866
- return Array.from({ length: count }, () => 1 / count);
3867
- }
3868
- return normalized.map((value) => value / total);
3869
- }
3870
- normalizeSplitNode(split) {
3871
- split.sizes = this.normalizeSizesArray(split.sizes, split.children.length);
3872
- }
3873
- /**
3874
- * Bottom-up layout sanitizer. Returns a normalized version of `node` where:
3875
- * - Empty stacks (panes.length === 0) are dropped (returned as null).
3876
- * - A stack's `activePane` is repaired if it no longer references one of `panes`.
3877
- * - Splits whose direction matches a child split are flattened, with sizes
3878
- * combined multiplicatively so the resulting on-screen pixel layout is
3879
- * identical to the pre-merge one.
3880
- * - Splits with 0 children become null. Splits with 1 child are unwrapped.
3881
- *
3882
- * Idempotent: passing the result back through this method yields the same
3883
- * structure. Mutates the input tree in place but only returns nodes that
3884
- * remain part of the layout.
3885
- */
3886
- normalizeLayoutNode(node) {
3887
- if (!node)
3888
- return null;
3889
- if (node.kind === 'stack') {
3890
- if (node.panes.length === 0)
3891
- return null;
3892
- if (!node.activePane || !node.panes.includes(node.activePane)) {
3893
- node.activePane = node.panes[0];
3894
- }
3895
- return node;
3896
- }
3897
- const slotSizes = this.normalizeSizesArray(node.sizes, node.children.length);
3898
- // Pair each child with its slot weight, drop nulls, then expand any
3899
- // same-direction child split into its grandchildren with sizes scaled
3900
- // multiplicatively. A 0.4 slot containing [0.3, 0.7] becomes [0.12, 0.28].
3901
- const survivors = node.children
3902
- .map((child, i) => ({ child: this.normalizeLayoutNode(child), slot: slotSizes[i] }))
3903
- .filter((p) => p.child !== null)
3904
- .flatMap(({ child, slot }) => {
3905
- if (child.kind === 'split' && child.direction === node.direction) {
3906
- const innerSizes = this.normalizeSizesArray(child.sizes, child.children.length);
3907
- return child.children.map((grandchild, idx) => ({
3908
- child: grandchild,
3909
- slot: slot * innerSizes[idx],
3910
- }));
3911
- }
3912
- return [{ child, slot }];
3913
- });
3914
- if (survivors.length === 0)
3915
- return null;
3916
- if (survivors.length === 1)
3917
- return survivors[0].child;
3918
- node.children = survivors.map((s) => s.child);
3919
- node.sizes = this.normalizeSizesArray(survivors.map((s) => s.slot), survivors.length);
3920
- return node;
3921
- }
3922
- /**
3923
- * Apply `normalizeLayoutNode` to `rootLayout` and every floating window's
3924
- * root, drop floating windows whose root collapses to null, and repair
3925
- * stale `activePane` references on each floating window. Run this at the
3926
- * end of every public mutation entry point (drop handlers, layout setter,
3927
- * pane removal) so the tree the renderer sees is always in canonical form.
3928
- */
3929
- normalizeAllLayouts() {
3930
- this.rootLayout = this.normalizeLayoutNode(this.rootLayout);
3931
- this.floatingLayouts = this.floatingLayouts
3932
- .map((floating) => {
3933
- floating.root = this.normalizeLayoutNode(floating.root);
3934
- if (!floating.root)
3935
- return null;
3936
- const panes = this.collectPaneNames(floating.root);
3937
- if (!floating.activePane || !panes.includes(floating.activePane)) {
3938
- const fallback = this.findFirstPaneName(floating.root);
3939
- if (fallback) {
3940
- floating.activePane = fallback;
3941
- }
3942
- else {
3943
- delete floating.activePane;
3944
- }
3945
- }
3946
- return floating;
3947
- })
3948
- .filter((f) => f !== null);
3949
- }
3950
- /**
3951
- * Dev-mode integrity guard: walks every pane referenced by the current
3952
- * layout and asserts that the rendered shadow DOM contains a matching
3953
- * `<slot name="${pane}">`. A missing slot means the layout tree got into
3954
- * a state the renderer can't display — typically a missed normalize() call
3955
- * or a render bug. Opt in via the `debug-layout-integrity` attribute or
3956
- * the `debugLayoutIntegrity` property; off by default.
3957
- */
3958
- verifyProjectionSlots() {
3959
- if (!this.debugLayoutIntegrity)
3960
- return;
3961
- const root = this.shadowRoot;
3962
- if (!root)
3963
- return;
3964
- // Collect every slot the renderer produced. Walking the rendered DOM
3965
- // (instead of building a CSS selector per pane) sidesteps environment
3966
- // differences — e.g. jsdom does not expose `CSS.escape`, which would
3967
- // crash the guard during unit tests before the assertion runs.
3968
- const slotNames = new Set(Array.from(root.querySelectorAll('slot'))
3969
- .map((slot) => slot.getAttribute('name'))
3970
- .filter((name) => !!name));
3971
- const panes = [
3972
- ...this.collectPaneNames(this.rootLayout),
3973
- ...this.floatingLayouts.flatMap((f) => this.collectPaneNames(f.root)),
3974
- ];
3975
- const missing = panes.find((pane) => !slotNames.has(pane));
3976
- if (missing) {
3977
- throw new Error(`mint-dock-manager: pane "${missing}" has no projection slot in the shadow DOM. ` +
3978
- `The layout tree got into a state the renderer can't display — likely a ` +
3979
- `missing normalize() call or a render bug.`);
3980
- }
3981
- }
3982
- dispatchLayoutChanged() {
3983
- this.dispatchEvent(new CustomEvent('dock-layout-changed', {
3984
- detail: this.snapshot,
3985
- bubbles: true,
3986
- composed: true,
3987
- }));
3988
- }
3989
- cloneLayoutNode(layout) {
3990
- if (!layout) {
3991
- return null;
3992
- }
3993
- return JSON.parse(JSON.stringify(layout));
3994
- }
3995
- cloneFloatingArray(layouts) {
3996
- return JSON.parse(JSON.stringify(layouts));
3997
- }
3998
- }
3999
- const tagName = 'mint-dock-manager';
4000
- if (typeof customElements !== 'undefined' && !customElements.get(tagName)) {
4001
- customElements.define(tagName, MintDockManagerElement);
4002
- }
4003
-
4004
- class BsDockManagerComponent {
4005
- get layoutSnapshot() {
4006
- if (!this._layout.root && this._layout.floating.length === 0) {
4007
- return null;
4008
- }
4009
- return this.cloneLayout(this._layout);
4010
- }
4011
- constructor() {
4012
- this.layout = input(null, ...(ngDevMode ? [{ debugName: "layout" }] : /* istanbul ignore next */ []));
4013
- /**
4014
- * Dev-mode integrity guard. When `true`, the inner web component throws
4015
- * after each render if any registered pane has no projection slot in the
4016
- * shadow DOM — a signal that the layout tree got corrupted. Off by default;
4017
- * enable in development to catch layout-logic bugs loudly.
4018
- */
4019
- this.debugLayoutIntegrity = input(false, ...(ngDevMode ? [{ debugName: "debugLayoutIntegrity" }] : /* istanbul ignore next */ []));
4020
- this.debugLayoutIntegrityAttr = computed(() => this.debugLayoutIntegrity() ? '' : null, ...(ngDevMode ? [{ debugName: "debugLayoutIntegrityAttr" }] : /* istanbul ignore next */ []));
4021
- this.layoutChange = output();
4022
- this.layoutSnapshotChange = output();
4023
- this.layoutString = signal(null, ...(ngDevMode ? [{ debugName: "layoutString" }] : /* istanbul ignore next */ []));
4024
- this.panes = contentChildren(BsDockPaneComponent, ...(ngDevMode ? [{ debugName: "panes" }] : /* istanbul ignore next */ []));
4025
- this.managerRef = viewChild('manager', ...(ngDevMode ? [{ debugName: "managerRef" }] : /* istanbul ignore next */ []));
4026
- this.trackByPane = (_, pane) => pane.name();
4027
- this._layout = { root: null, floating: [] };
4028
- const documentRef = inject(DOCUMENT);
4029
- if (documentRef) {
4030
- MintDockManagerElement.configureDocument(documentRef);
4031
- }
4032
- effect(() => {
4033
- const value = this.layout();
4034
- const snapshot = this.cloneLayout(this.ensureSnapshot(value));
4035
- this._layout = snapshot;
4036
- this.layoutString.set(this.stringifyLayout(snapshot));
4037
- this.applyLayout();
4038
- });
4039
- }
4040
- ngAfterViewInit() {
4041
- this.applyLayout();
4042
- }
4043
- captureLayout() {
4044
- const element = this.managerRef()?.nativeElement;
4045
- return element?.snapshot ?? { root: null, floating: [] };
4046
- }
4047
- onLayoutChanged(event) {
4048
- const snapshot = event.detail ?? {
4049
- root: null,
4050
- floating: [],
4051
- };
4052
- this._layout = this.cloneLayout(snapshot);
4053
- this.layoutString.set(this.stringifyLayout(this._layout));
4054
- this.layoutChange.emit(this.layoutSnapshot);
4055
- this.layoutSnapshotChange.emit(this.cloneLayout(snapshot));
4056
- }
4057
- applyLayout() {
4058
- const ref = this.managerRef();
4059
- if (!ref) {
4060
- return;
4061
- }
4062
- const element = ref.nativeElement;
4063
- const layout = this.layoutSnapshot;
4064
- element.layout = layout ?? null;
4065
- }
4066
- ensureSnapshot(value) {
4067
- if (!value) {
4068
- return { root: null, floating: [], titles: {} };
4069
- }
4070
- if ('kind' in value) {
4071
- return { root: value, floating: [], titles: {} };
4072
- }
4073
- return {
4074
- root: value.root ?? null,
4075
- floating: Array.isArray(value.floating) ? [...value.floating] : [],
4076
- titles: value.titles ? { ...value.titles } : {},
4077
- };
4078
- }
4079
- stringifyLayout(layout) {
4080
- if (!layout.root && layout.floating.length === 0) {
4081
- return null;
4082
- }
4083
- return JSON.stringify(layout);
4084
- }
4085
- cloneLayout(layout) {
4086
- return JSON.parse(JSON.stringify(layout));
4087
- }
4088
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.11", ngImport: i0, type: BsDockManagerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
4089
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.11", type: BsDockManagerComponent, isStandalone: true, selector: "bs-dock-manager", inputs: { layout: { classPropertyName: "layout", publicName: "layout", isSignal: true, isRequired: false, transformFunction: null }, debugLayoutIntegrity: { classPropertyName: "debugLayoutIntegrity", publicName: "debugLayoutIntegrity", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { layoutChange: "layoutChange", layoutSnapshotChange: "layoutSnapshotChange" }, queries: [{ propertyName: "panes", predicate: BsDockPaneComponent, isSignal: true }], viewQueries: [{ propertyName: "managerRef", first: true, predicate: ["manager"], descendants: true, isSignal: true }], ngImport: i0, template: "<mint-dock-manager\n #manager\n class=\"bs-dock-manager\"\n [attr.layout]=\"layoutString()\"\n [attr.debug-layout-integrity]=\"debugLayoutIntegrityAttr()\"\n (dock-layout-changed)=\"onLayoutChanged($event)\"\n >\n @for (pane of panes(); track trackByPane($index, pane)) {\n <div class=\"bs-dock-pane\" [attr.slot]=\"pane.name()\">\n <ng-container *ngTemplateOutlet=\"pane.template()\"></ng-container>\n </div>\n }\n</mint-dock-manager>\n", styles: [":host{display:block;width:100%;height:100%}.bs-dock-manager{display:block;width:100%;height:100%}.bs-dock-pane{display:contents}\n"], dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
4090
- }
4091
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.11", ngImport: i0, type: BsDockManagerComponent, decorators: [{
4092
- type: Component,
4093
- args: [{ selector: 'bs-dock-manager', imports: [NgTemplateOutlet], schemas: [CUSTOM_ELEMENTS_SCHEMA], changeDetection: ChangeDetectionStrategy.OnPush, template: "<mint-dock-manager\n #manager\n class=\"bs-dock-manager\"\n [attr.layout]=\"layoutString()\"\n [attr.debug-layout-integrity]=\"debugLayoutIntegrityAttr()\"\n (dock-layout-changed)=\"onLayoutChanged($event)\"\n >\n @for (pane of panes(); track trackByPane($index, pane)) {\n <div class=\"bs-dock-pane\" [attr.slot]=\"pane.name()\">\n <ng-container *ngTemplateOutlet=\"pane.template()\"></ng-container>\n </div>\n }\n</mint-dock-manager>\n", styles: [":host{display:block;width:100%;height:100%}.bs-dock-manager{display:block;width:100%;height:100%}.bs-dock-pane{display:contents}\n"] }]
4094
- }], ctorParameters: () => [], propDecorators: { layout: [{ type: i0.Input, args: [{ isSignal: true, alias: "layout", required: false }] }], debugLayoutIntegrity: [{ type: i0.Input, args: [{ isSignal: true, alias: "debugLayoutIntegrity", required: false }] }], layoutChange: [{ type: i0.Output, args: ["layoutChange"] }], layoutSnapshotChange: [{ type: i0.Output, args: ["layoutSnapshotChange"] }], panes: [{ type: i0.ContentChildren, args: [i0.forwardRef(() => BsDockPaneComponent), { isSignal: true }] }], managerRef: [{ type: i0.ViewChild, args: ['manager', { isSignal: true }] }] } });
4095
-
4096
- /**
4097
- * Generated bundle index. Do not edit.
4098
- */
4099
-
4100
- export { BsDockManagerComponent, BsDockPaneComponent, MintDockManagerElement };
4101
- //# sourceMappingURL=mintplayer-ng-bootstrap-dock.mjs.map