@oh-just-another/react-ui 0.60.0 → 0.62.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 (365) hide show
  1. package/CHANGELOG.md +137 -0
  2. package/README.md +3 -3
  3. package/dist/.tsbuildinfo +1 -1
  4. package/dist/{color-palette.d.ts → color/color-palette.d.ts} +5 -0
  5. package/dist/color/color-palette.d.ts.map +1 -0
  6. package/dist/{color-palette.js → color/color-palette.js} +5 -0
  7. package/dist/color/color-palette.js.map +1 -0
  8. package/dist/color/color-swatch-picker.d.ts.map +1 -0
  9. package/dist/{color-swatch-picker.js → color/color-swatch-picker.js} +8 -17
  10. package/dist/color/color-swatch-picker.js.map +1 -0
  11. package/dist/{constants.d.ts → core/constants.d.ts} +70 -21
  12. package/dist/core/constants.d.ts.map +1 -0
  13. package/dist/{constants.js → core/constants.js} +104 -16
  14. package/dist/core/constants.js.map +1 -0
  15. package/dist/core/context.d.ts.map +1 -0
  16. package/dist/core/context.js.map +1 -0
  17. package/dist/core/hooks.d.ts.map +1 -0
  18. package/dist/core/hooks.js.map +1 -0
  19. package/dist/core/portal-container.d.ts.map +1 -0
  20. package/dist/core/portal-container.js.map +1 -0
  21. package/dist/core/use-fullscreen.d.ts +14 -0
  22. package/dist/core/use-fullscreen.d.ts.map +1 -0
  23. package/dist/core/use-fullscreen.js +38 -0
  24. package/dist/core/use-fullscreen.js.map +1 -0
  25. package/dist/core/use-quiet-gesture.d.ts +11 -0
  26. package/dist/core/use-quiet-gesture.d.ts.map +1 -0
  27. package/dist/core/use-quiet-gesture.js +61 -0
  28. package/dist/core/use-quiet-gesture.js.map +1 -0
  29. package/dist/core/use-quiet-viewport.d.ts +10 -0
  30. package/dist/core/use-quiet-viewport.d.ts.map +1 -0
  31. package/dist/core/use-quiet-viewport.js +40 -0
  32. package/dist/core/use-quiet-viewport.js.map +1 -0
  33. package/dist/index.d.ts +55 -50
  34. package/dist/index.d.ts.map +1 -1
  35. package/dist/index.js +55 -50
  36. package/dist/index.js.map +1 -1
  37. package/dist/layout/diagram-bars.d.ts.map +1 -0
  38. package/dist/layout/diagram-bars.js.map +1 -0
  39. package/dist/layout/diagram-canvas.d.ts.map +1 -0
  40. package/dist/layout/diagram-canvas.js.map +1 -0
  41. package/dist/layout/diagram-root.d.ts.map +1 -0
  42. package/dist/{diagram-root.js → layout/diagram-root.js} +2 -2
  43. package/dist/layout/diagram-root.js.map +1 -0
  44. package/dist/{sidebar.d.ts → layout/sidebar.d.ts} +1 -0
  45. package/dist/layout/sidebar.d.ts.map +1 -0
  46. package/dist/layout/sidebar.js +38 -0
  47. package/dist/layout/sidebar.js.map +1 -0
  48. package/dist/layout/ui-layer.d.ts.map +1 -0
  49. package/dist/layout/ui-layer.js.map +1 -0
  50. package/dist/menus/command-palette.d.ts.map +1 -0
  51. package/dist/{command-palette.js → menus/command-palette.js} +3 -3
  52. package/dist/menus/command-palette.js.map +1 -0
  53. package/dist/menus/context-menu-controller.d.ts.map +1 -0
  54. package/dist/menus/context-menu-controller.js.map +1 -0
  55. package/dist/{context-menu.d.ts → menus/context-menu.d.ts} +12 -0
  56. package/dist/menus/context-menu.d.ts.map +1 -0
  57. package/dist/menus/context-menu.js +617 -0
  58. package/dist/menus/context-menu.js.map +1 -0
  59. package/dist/menus/link-drop-shape-menu.d.ts.map +1 -0
  60. package/dist/{link-drop-shape-menu.js → menus/link-drop-shape-menu.js} +4 -4
  61. package/dist/menus/link-drop-shape-menu.js.map +1 -0
  62. package/dist/{main-menu.d.ts → menus/main-menu.d.ts} +45 -2
  63. package/dist/menus/main-menu.d.ts.map +1 -0
  64. package/dist/menus/main-menu.js +260 -0
  65. package/dist/menus/main-menu.js.map +1 -0
  66. package/dist/overlays/file-drop-overlay.d.ts +15 -0
  67. package/dist/overlays/file-drop-overlay.d.ts.map +1 -0
  68. package/dist/overlays/file-drop-overlay.js +27 -0
  69. package/dist/overlays/file-drop-overlay.js.map +1 -0
  70. package/dist/overlays/frame-name-editor-overlay.d.ts.map +1 -0
  71. package/dist/{frame-name-editor-overlay.js → overlays/frame-name-editor-overlay.js} +1 -1
  72. package/dist/overlays/frame-name-editor-overlay.js.map +1 -0
  73. package/dist/overlays/help-button.d.ts.map +1 -0
  74. package/dist/{help-button.js → overlays/help-button.js} +3 -4
  75. package/dist/overlays/help-button.js.map +1 -0
  76. package/dist/overlays/help-dialog.d.ts.map +1 -0
  77. package/dist/{help-dialog.js → overlays/help-dialog.js} +4 -24
  78. package/dist/overlays/help-dialog.js.map +1 -0
  79. package/dist/overlays/link-badges.d.ts +14 -0
  80. package/dist/overlays/link-badges.d.ts.map +1 -0
  81. package/dist/overlays/link-badges.js +60 -0
  82. package/dist/overlays/link-badges.js.map +1 -0
  83. package/dist/overlays/link-caption-editor.d.ts.map +1 -0
  84. package/dist/{link-caption-editor.js → overlays/link-caption-editor.js} +3 -3
  85. package/dist/overlays/link-caption-editor.js.map +1 -0
  86. package/dist/overlays/link-hover-popup.d.ts.map +1 -0
  87. package/dist/{link-hover-popup.js → overlays/link-hover-popup.js} +5 -4
  88. package/dist/overlays/link-hover-popup.js.map +1 -0
  89. package/dist/overlays/merge-dialog.d.ts.map +1 -0
  90. package/dist/overlays/merge-dialog.js +39 -0
  91. package/dist/overlays/merge-dialog.js.map +1 -0
  92. package/dist/overlays/search-overlay.d.ts.map +1 -0
  93. package/dist/{search-overlay.js → overlays/search-overlay.js} +2 -2
  94. package/dist/overlays/search-overlay.js.map +1 -0
  95. package/dist/overlays/sticky-reactions.d.ts +2 -0
  96. package/dist/overlays/sticky-reactions.d.ts.map +1 -0
  97. package/dist/overlays/sticky-reactions.js +94 -0
  98. package/dist/overlays/sticky-reactions.js.map +1 -0
  99. package/dist/overlays/text-editor-overlay.d.ts.map +1 -0
  100. package/dist/{text-editor-overlay.js → overlays/text-editor-overlay.js} +37 -5
  101. package/dist/overlays/text-editor-overlay.js.map +1 -0
  102. package/dist/{comments-panel.d.ts → panels/comments-panel.d.ts} +4 -1
  103. package/dist/panels/comments-panel.d.ts.map +1 -0
  104. package/dist/panels/comments-panel.js +51 -0
  105. package/dist/panels/comments-panel.js.map +1 -0
  106. package/dist/panels/diff-panel.d.ts.map +1 -0
  107. package/dist/panels/diff-panel.js.map +1 -0
  108. package/dist/panels/drawing-panel.d.ts.map +1 -0
  109. package/dist/{drawing-panel.js → panels/drawing-panel.js} +3 -3
  110. package/dist/panels/drawing-panel.js.map +1 -0
  111. package/dist/panels/edge-style-panel.d.ts.map +1 -0
  112. package/dist/{edge-style-panel.js → panels/edge-style-panel.js} +1 -1
  113. package/dist/panels/edge-style-panel.js.map +1 -0
  114. package/dist/panels/frame-panel.d.ts.map +1 -0
  115. package/dist/{frame-panel.js → panels/frame-panel.js} +1 -1
  116. package/dist/panels/frame-panel.js.map +1 -0
  117. package/dist/{layer-panel.d.ts → panels/layer-panel.d.ts} +5 -1
  118. package/dist/panels/layer-panel.d.ts.map +1 -0
  119. package/dist/panels/layer-panel.js +52 -0
  120. package/dist/panels/layer-panel.js.map +1 -0
  121. package/dist/panels/library-panel.d.ts.map +1 -0
  122. package/dist/{library-panel.js → panels/library-panel.js} +4 -5
  123. package/dist/panels/library-panel.js.map +1 -0
  124. package/dist/panels/property-panel.d.ts.map +1 -0
  125. package/dist/panels/property-panel.js +1397 -0
  126. package/dist/panels/property-panel.js.map +1 -0
  127. package/dist/panels/selection-floating-panel.d.ts.map +1 -0
  128. package/dist/{selection-floating-panel.js → panels/selection-floating-panel.js} +24 -13
  129. package/dist/panels/selection-floating-panel.js.map +1 -0
  130. package/dist/panels/stats-panel.d.ts.map +1 -0
  131. package/dist/{stats-panel.js → panels/stats-panel.js} +1 -1
  132. package/dist/panels/stats-panel.js.map +1 -0
  133. package/dist/primitives/bottom-sheet.d.ts.map +1 -0
  134. package/dist/{bottom-sheet.js → primitives/bottom-sheet.js} +9 -22
  135. package/dist/primitives/bottom-sheet.js.map +1 -0
  136. package/dist/primitives/button-group.d.ts.map +1 -0
  137. package/dist/primitives/button-group.js.map +1 -0
  138. package/dist/primitives/css-var.d.ts +8 -0
  139. package/dist/primitives/css-var.d.ts.map +1 -0
  140. package/dist/primitives/css-var.js +11 -0
  141. package/dist/primitives/css-var.js.map +1 -0
  142. package/dist/primitives/float-panel.d.ts +35 -0
  143. package/dist/primitives/float-panel.d.ts.map +1 -0
  144. package/dist/primitives/float-panel.js +42 -0
  145. package/dist/primitives/float-panel.js.map +1 -0
  146. package/dist/primitives/icon-button.d.ts.map +1 -0
  147. package/dist/primitives/icon-button.js.map +1 -0
  148. package/dist/primitives/markdown.d.ts.map +1 -0
  149. package/dist/primitives/markdown.js.map +1 -0
  150. package/dist/primitives/modal.d.ts.map +1 -0
  151. package/dist/{modal.js → primitives/modal.js} +11 -9
  152. package/dist/primitives/modal.js.map +1 -0
  153. package/dist/{popover.d.ts → primitives/popover.d.ts} +1 -1
  154. package/dist/primitives/popover.d.ts.map +1 -0
  155. package/dist/{popover.js → primitives/popover.js} +7 -18
  156. package/dist/primitives/popover.js.map +1 -0
  157. package/dist/primitives/segmented-control.d.ts.map +1 -0
  158. package/dist/primitives/segmented-control.js.map +1 -0
  159. package/dist/primitives/slider.d.ts.map +1 -0
  160. package/dist/primitives/slider.js.map +1 -0
  161. package/dist/primitives/switch.d.ts +24 -0
  162. package/dist/primitives/switch.d.ts.map +1 -0
  163. package/dist/primitives/switch.js +17 -0
  164. package/dist/primitives/switch.js.map +1 -0
  165. package/dist/primitives/toast.d.ts.map +1 -0
  166. package/dist/{toast.js → primitives/toast.js} +12 -33
  167. package/dist/primitives/toast.js.map +1 -0
  168. package/dist/primitives/tooltip.d.ts.map +1 -0
  169. package/dist/{tooltip.js → primitives/tooltip.js} +3 -3
  170. package/dist/primitives/tooltip.js.map +1 -0
  171. package/dist/{palette.d.ts → toolbar/palette.d.ts} +6 -1
  172. package/dist/toolbar/palette.d.ts.map +1 -0
  173. package/dist/{palette.js → toolbar/palette.js} +39 -5
  174. package/dist/toolbar/palette.js.map +1 -0
  175. package/dist/{toolbar.d.ts → toolbar/toolbar.d.ts} +9 -0
  176. package/dist/toolbar/toolbar.d.ts.map +1 -0
  177. package/dist/{toolbar.js → toolbar/toolbar.js} +132 -62
  178. package/dist/toolbar/toolbar.js.map +1 -0
  179. package/dist/utils/format-time.d.ts.map +1 -0
  180. package/dist/utils/format-time.js.map +1 -0
  181. package/dist/utils/use-dismiss-timer.d.ts.map +1 -0
  182. package/dist/utils/use-dismiss-timer.js.map +1 -0
  183. package/dist/widgets/minimap.d.ts.map +1 -0
  184. package/dist/{minimap.js → widgets/minimap.js} +50 -36
  185. package/dist/widgets/minimap.js.map +1 -0
  186. package/dist/widgets/reset-to-content-button.d.ts +11 -0
  187. package/dist/widgets/reset-to-content-button.d.ts.map +1 -0
  188. package/dist/{reset-to-content-button.js → widgets/reset-to-content-button.js} +8 -9
  189. package/dist/widgets/reset-to-content-button.js.map +1 -0
  190. package/dist/widgets/versioning.d.ts.map +1 -0
  191. package/dist/{versioning.js → widgets/versioning.js} +4 -4
  192. package/dist/widgets/versioning.js.map +1 -0
  193. package/dist/widgets/zen-mode.d.ts.map +1 -0
  194. package/dist/widgets/zen-mode.js.map +1 -0
  195. package/package.json +9 -9
  196. package/src/styles.css +1622 -287
  197. package/dist/bottom-sheet.d.ts.map +0 -1
  198. package/dist/bottom-sheet.js.map +0 -1
  199. package/dist/button-group.d.ts.map +0 -1
  200. package/dist/button-group.js.map +0 -1
  201. package/dist/color-palette.d.ts.map +0 -1
  202. package/dist/color-palette.js.map +0 -1
  203. package/dist/color-swatch-picker.d.ts.map +0 -1
  204. package/dist/color-swatch-picker.js.map +0 -1
  205. package/dist/command-palette.d.ts.map +0 -1
  206. package/dist/command-palette.js.map +0 -1
  207. package/dist/comments-panel.d.ts.map +0 -1
  208. package/dist/comments-panel.js +0 -142
  209. package/dist/comments-panel.js.map +0 -1
  210. package/dist/constants.d.ts.map +0 -1
  211. package/dist/constants.js.map +0 -1
  212. package/dist/context-menu-controller.d.ts.map +0 -1
  213. package/dist/context-menu-controller.js.map +0 -1
  214. package/dist/context-menu.d.ts.map +0 -1
  215. package/dist/context-menu.js +0 -368
  216. package/dist/context-menu.js.map +0 -1
  217. package/dist/context.d.ts.map +0 -1
  218. package/dist/context.js.map +0 -1
  219. package/dist/diagram-bars.d.ts.map +0 -1
  220. package/dist/diagram-bars.js.map +0 -1
  221. package/dist/diagram-canvas.d.ts.map +0 -1
  222. package/dist/diagram-canvas.js.map +0 -1
  223. package/dist/diagram-root.d.ts.map +0 -1
  224. package/dist/diagram-root.js.map +0 -1
  225. package/dist/diff-panel.d.ts.map +0 -1
  226. package/dist/diff-panel.js.map +0 -1
  227. package/dist/drawing-panel.d.ts.map +0 -1
  228. package/dist/drawing-panel.js.map +0 -1
  229. package/dist/edge-style-panel.d.ts.map +0 -1
  230. package/dist/edge-style-panel.js.map +0 -1
  231. package/dist/format-time.d.ts.map +0 -1
  232. package/dist/format-time.js.map +0 -1
  233. package/dist/frame-name-editor-overlay.d.ts.map +0 -1
  234. package/dist/frame-name-editor-overlay.js.map +0 -1
  235. package/dist/frame-panel.d.ts.map +0 -1
  236. package/dist/frame-panel.js.map +0 -1
  237. package/dist/help-button.d.ts.map +0 -1
  238. package/dist/help-button.js.map +0 -1
  239. package/dist/help-dialog.d.ts.map +0 -1
  240. package/dist/help-dialog.js.map +0 -1
  241. package/dist/hooks.d.ts.map +0 -1
  242. package/dist/hooks.js.map +0 -1
  243. package/dist/icon-button.d.ts.map +0 -1
  244. package/dist/icon-button.js.map +0 -1
  245. package/dist/layer-panel.d.ts.map +0 -1
  246. package/dist/layer-panel.js +0 -117
  247. package/dist/layer-panel.js.map +0 -1
  248. package/dist/library-panel.d.ts.map +0 -1
  249. package/dist/library-panel.js.map +0 -1
  250. package/dist/link-caption-editor.d.ts.map +0 -1
  251. package/dist/link-caption-editor.js.map +0 -1
  252. package/dist/link-drop-shape-menu.d.ts.map +0 -1
  253. package/dist/link-drop-shape-menu.js.map +0 -1
  254. package/dist/link-hover-popup.d.ts.map +0 -1
  255. package/dist/link-hover-popup.js.map +0 -1
  256. package/dist/main-menu.d.ts.map +0 -1
  257. package/dist/main-menu.js +0 -249
  258. package/dist/main-menu.js.map +0 -1
  259. package/dist/markdown.d.ts.map +0 -1
  260. package/dist/markdown.js.map +0 -1
  261. package/dist/merge-dialog.d.ts.map +0 -1
  262. package/dist/merge-dialog.js +0 -50
  263. package/dist/merge-dialog.js.map +0 -1
  264. package/dist/minimap.d.ts.map +0 -1
  265. package/dist/minimap.js.map +0 -1
  266. package/dist/modal.d.ts.map +0 -1
  267. package/dist/modal.js.map +0 -1
  268. package/dist/palette.d.ts.map +0 -1
  269. package/dist/palette.js.map +0 -1
  270. package/dist/popover.d.ts.map +0 -1
  271. package/dist/popover.js.map +0 -1
  272. package/dist/portal-container.d.ts.map +0 -1
  273. package/dist/portal-container.js.map +0 -1
  274. package/dist/property-panel.d.ts.map +0 -1
  275. package/dist/property-panel.js +0 -917
  276. package/dist/property-panel.js.map +0 -1
  277. package/dist/reset-to-content-button.d.ts +0 -10
  278. package/dist/reset-to-content-button.d.ts.map +0 -1
  279. package/dist/reset-to-content-button.js.map +0 -1
  280. package/dist/search-overlay.d.ts.map +0 -1
  281. package/dist/search-overlay.js.map +0 -1
  282. package/dist/segmented-control.d.ts.map +0 -1
  283. package/dist/segmented-control.js.map +0 -1
  284. package/dist/selection-floating-panel.d.ts.map +0 -1
  285. package/dist/selection-floating-panel.js.map +0 -1
  286. package/dist/sidebar.d.ts.map +0 -1
  287. package/dist/sidebar.js +0 -68
  288. package/dist/sidebar.js.map +0 -1
  289. package/dist/slider.d.ts.map +0 -1
  290. package/dist/slider.js.map +0 -1
  291. package/dist/stats-panel.d.ts.map +0 -1
  292. package/dist/stats-panel.js.map +0 -1
  293. package/dist/text-editor-overlay.d.ts.map +0 -1
  294. package/dist/text-editor-overlay.js.map +0 -1
  295. package/dist/toast.d.ts.map +0 -1
  296. package/dist/toast.js.map +0 -1
  297. package/dist/toolbar.d.ts.map +0 -1
  298. package/dist/toolbar.js.map +0 -1
  299. package/dist/tooltip.d.ts.map +0 -1
  300. package/dist/tooltip.js.map +0 -1
  301. package/dist/ui-layer.d.ts.map +0 -1
  302. package/dist/ui-layer.js.map +0 -1
  303. package/dist/use-dismiss-timer.d.ts.map +0 -1
  304. package/dist/use-dismiss-timer.js.map +0 -1
  305. package/dist/versioning.d.ts.map +0 -1
  306. package/dist/versioning.js.map +0 -1
  307. package/dist/zen-mode.d.ts.map +0 -1
  308. package/dist/zen-mode.js.map +0 -1
  309. /package/dist/{color-swatch-picker.d.ts → color/color-swatch-picker.d.ts} +0 -0
  310. /package/dist/{context.d.ts → core/context.d.ts} +0 -0
  311. /package/dist/{context.js → core/context.js} +0 -0
  312. /package/dist/{hooks.d.ts → core/hooks.d.ts} +0 -0
  313. /package/dist/{hooks.js → core/hooks.js} +0 -0
  314. /package/dist/{portal-container.d.ts → core/portal-container.d.ts} +0 -0
  315. /package/dist/{portal-container.js → core/portal-container.js} +0 -0
  316. /package/dist/{diagram-bars.d.ts → layout/diagram-bars.d.ts} +0 -0
  317. /package/dist/{diagram-bars.js → layout/diagram-bars.js} +0 -0
  318. /package/dist/{diagram-canvas.d.ts → layout/diagram-canvas.d.ts} +0 -0
  319. /package/dist/{diagram-canvas.js → layout/diagram-canvas.js} +0 -0
  320. /package/dist/{diagram-root.d.ts → layout/diagram-root.d.ts} +0 -0
  321. /package/dist/{ui-layer.d.ts → layout/ui-layer.d.ts} +0 -0
  322. /package/dist/{ui-layer.js → layout/ui-layer.js} +0 -0
  323. /package/dist/{command-palette.d.ts → menus/command-palette.d.ts} +0 -0
  324. /package/dist/{context-menu-controller.d.ts → menus/context-menu-controller.d.ts} +0 -0
  325. /package/dist/{context-menu-controller.js → menus/context-menu-controller.js} +0 -0
  326. /package/dist/{link-drop-shape-menu.d.ts → menus/link-drop-shape-menu.d.ts} +0 -0
  327. /package/dist/{frame-name-editor-overlay.d.ts → overlays/frame-name-editor-overlay.d.ts} +0 -0
  328. /package/dist/{help-button.d.ts → overlays/help-button.d.ts} +0 -0
  329. /package/dist/{help-dialog.d.ts → overlays/help-dialog.d.ts} +0 -0
  330. /package/dist/{link-caption-editor.d.ts → overlays/link-caption-editor.d.ts} +0 -0
  331. /package/dist/{link-hover-popup.d.ts → overlays/link-hover-popup.d.ts} +0 -0
  332. /package/dist/{merge-dialog.d.ts → overlays/merge-dialog.d.ts} +0 -0
  333. /package/dist/{search-overlay.d.ts → overlays/search-overlay.d.ts} +0 -0
  334. /package/dist/{text-editor-overlay.d.ts → overlays/text-editor-overlay.d.ts} +0 -0
  335. /package/dist/{diff-panel.d.ts → panels/diff-panel.d.ts} +0 -0
  336. /package/dist/{diff-panel.js → panels/diff-panel.js} +0 -0
  337. /package/dist/{drawing-panel.d.ts → panels/drawing-panel.d.ts} +0 -0
  338. /package/dist/{edge-style-panel.d.ts → panels/edge-style-panel.d.ts} +0 -0
  339. /package/dist/{frame-panel.d.ts → panels/frame-panel.d.ts} +0 -0
  340. /package/dist/{library-panel.d.ts → panels/library-panel.d.ts} +0 -0
  341. /package/dist/{property-panel.d.ts → panels/property-panel.d.ts} +0 -0
  342. /package/dist/{selection-floating-panel.d.ts → panels/selection-floating-panel.d.ts} +0 -0
  343. /package/dist/{stats-panel.d.ts → panels/stats-panel.d.ts} +0 -0
  344. /package/dist/{bottom-sheet.d.ts → primitives/bottom-sheet.d.ts} +0 -0
  345. /package/dist/{button-group.d.ts → primitives/button-group.d.ts} +0 -0
  346. /package/dist/{button-group.js → primitives/button-group.js} +0 -0
  347. /package/dist/{icon-button.d.ts → primitives/icon-button.d.ts} +0 -0
  348. /package/dist/{icon-button.js → primitives/icon-button.js} +0 -0
  349. /package/dist/{markdown.d.ts → primitives/markdown.d.ts} +0 -0
  350. /package/dist/{markdown.js → primitives/markdown.js} +0 -0
  351. /package/dist/{modal.d.ts → primitives/modal.d.ts} +0 -0
  352. /package/dist/{segmented-control.d.ts → primitives/segmented-control.d.ts} +0 -0
  353. /package/dist/{segmented-control.js → primitives/segmented-control.js} +0 -0
  354. /package/dist/{slider.d.ts → primitives/slider.d.ts} +0 -0
  355. /package/dist/{slider.js → primitives/slider.js} +0 -0
  356. /package/dist/{toast.d.ts → primitives/toast.d.ts} +0 -0
  357. /package/dist/{tooltip.d.ts → primitives/tooltip.d.ts} +0 -0
  358. /package/dist/{format-time.d.ts → utils/format-time.d.ts} +0 -0
  359. /package/dist/{format-time.js → utils/format-time.js} +0 -0
  360. /package/dist/{use-dismiss-timer.d.ts → utils/use-dismiss-timer.d.ts} +0 -0
  361. /package/dist/{use-dismiss-timer.js → utils/use-dismiss-timer.js} +0 -0
  362. /package/dist/{minimap.d.ts → widgets/minimap.d.ts} +0 -0
  363. /package/dist/{versioning.d.ts → widgets/versioning.d.ts} +0 -0
  364. /package/dist/{zen-mode.d.ts → widgets/zen-mode.d.ts} +0 -0
  365. /package/dist/{zen-mode.js → widgets/zen-mode.js} +0 -0
@@ -0,0 +1,1397 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { isValidElement, useEffect, useRef, useState, } from "react";
3
+ import { AlignCenter, AlignCenterHorizontal, AlignEndHorizontal, AlignLeft, AlignRight, AlignStartHorizontal, Bold, CaseSensitive, Download, Circle, Crop, Diamond, FileText, Hexagon as HexagonIcon, Highlighter, Image as ImageIcon, IndentDecrease, IndentIncrease, Italic, Link as LinkIcon, List, ListFilter, ListOrdered, Lock as LockIcon, MessageCircle, Minus, MoreHorizontal, MoreVertical, MoveRight, Proportions, RectangleHorizontal, RectangleVertical, SmilePlus, Spline, Square, Squircle, Star as StarIcon, StickyNote, SquareDashed, SquareDot, Tag, Strikethrough, Trash2, Tv, Underline, Upload, UserRound, Waypoints, Triangle as TriangleIcon, } from "lucide-react";
4
+ import { getBinaryFile, isText, isImage, canCarryLabel, isSticky, isEmoji, isFrame, isRectangle, isEllipse, isBrush, isPolygon, sliceRuns, IMAGE_MASK_POLYGON_PRESETS, } from "@oh-just-another/scene";
5
+ import { FRAME_SIZE_PRESETS, LABEL_DEFAULT_FONT_SIZE, STICKY_SIZE_PRESETS, TEXT_DEFAULT_FONT_FAMILY, } from "@oh-just-another/state";
6
+ import { useDiagramOptional, useReadOnly, useScene, useSelectedLink, useSelection, } from "../core/hooks.js";
7
+ import { useEditorSelector } from "../core/context.js";
8
+ import { useContextMenuController } from "../menus/context-menu-controller.js";
9
+ import { ColorSwatchPicker } from "../color/color-swatch-picker.js";
10
+ import { Popover } from "../primitives/popover.js";
11
+ import { SegmentedControl } from "../primitives/segmented-control.js";
12
+ import { Slider } from "../primitives/slider.js";
13
+ import { BRUSH_WIDTH_MAX, BRUSH_WIDTH_MIN, TEXT_FONT_SIZE_MAX, TEXT_FONT_SIZE_MIN, TEXT_FONT_SIZE_PRESETS, TEXT_FONT_STACKS, EMOJI_QUICK_PICKS, IMAGE_MASK_DEFAULT_RADIUS, CONTROL_ICON, } from "../core/constants.js";
14
+ export const PropertyPanel = ({ style, className, mobile = false }) => {
15
+ const selection = useSelection();
16
+ const selectedLinkId = useSelectedLink();
17
+ const scene = useScene();
18
+ const readOnly = useReadOnly();
19
+ // Every control here mutates the selection (style / text / z-order / align /
20
+ // convert / delete / link). In read-only / view mode the whole panel is
21
+ // suppressed — the canvas is view-only, so there's nothing to edit.
22
+ if (readOnly)
23
+ return null;
24
+ // Dispatcher: edge wins only when no shape is selected — if both
25
+ // happen to be set (rare), the shape panel is more useful. Each branch
26
+ // splits its controls into `primary` (always visible) and `overflow`
27
+ // (behind the ⋮ on mobile; inline on desktop).
28
+ if (selection.size > 0) {
29
+ const shapes = [...selection]
30
+ .map((id) => scene.elements.get(id))
31
+ .filter((s) => s !== undefined);
32
+ if (shapes.length === 0)
33
+ return null;
34
+ const allText = shapes.every((s) => isText(s));
35
+ const allImage = shapes.every((s) => isImage(s));
36
+ const allBrush = shapes.every((s) => isBrush(s));
37
+ const allFrame = shapes.every((s) => isFrame(s));
38
+ const allSticky = shapes.every((s) => isSticky(s));
39
+ const allEmoji = shapes.every((s) => isEmoji(s));
40
+ // Branch layouts mirror the target design (design.md): per-type clusters
41
+ // separated by dividers, then a shared tail
42
+ // (`… | z-order | align | actions | comment | lock | ⋯`).
43
+ const primary = [];
44
+ const overflow = [];
45
+ // Shared head: the type switcher always leads the toolbar (the
46
+ // control renders nothing for kinds outside the switch-type matrix).
47
+ if (shapes.every((s) => isConvertible(s))) {
48
+ primary.push(_jsx(ConvertTypeControl, { shapes: shapes }, "convert"), _jsx(Divider, {}, "d-type"));
49
+ }
50
+ if (allSticky) {
51
+ // text (with Auto size) | size S/M/L | background | tags / author.
52
+ // Text controls always show — a note without text yet edits the
53
+ // defaults its first text will take (create-on-write in the editor).
54
+ {
55
+ const labelViews = shapes.map(labelView);
56
+ primary.push(_jsx(FontFamilyControl, { shapes: labelViews, labelMode: true }, "l-family"), _jsx(FontSizeControl, { shapes: labelViews, labelMode: true, allowAuto: true }, "l-size"), _jsx(TextDecorationControl, { shapes: labelViews, labelMode: true }, "l-decor"), _jsx(TextAlignControl, { shapes: labelViews, labelMode: true }, "l-align"), _jsx(Divider, {}, "d-sticky"));
57
+ }
58
+ primary.push(_jsx(StickySizeControl, { shapes: shapes }, "size"), _jsx(FillOpacityControl, { shapes: shapes }, "bg"));
59
+ overflow.push(_jsx(StickyTagControl, { shapes: shapes }, "tags"), _jsx(StickyAuthorControl, { shapes: shapes }, "author"));
60
+ }
61
+ else if (allEmoji) {
62
+ primary.push(_jsx(EmojiPickerControl, { shapes: shapes }, "glyph"));
63
+ }
64
+ else if (allFrame) {
65
+ // A frame's border is fixed chrome (dashed outline); only its body fill
66
+ // is user-configurable. No stroke / width / dash / roundness controls.
67
+ primary.push(_jsx(FillControl, { shapes: shapes }, "fill"));
68
+ if (shapes.length === 1) {
69
+ primary.push(_jsx(FrameRatioControl, { shapes: shapes }, "ratio"));
70
+ }
71
+ }
72
+ else if (allText) {
73
+ // font family | size | style | align | link — then colors.
74
+ primary.push(_jsx(FontFamilyControl, { shapes: shapes }, "family"), _jsx(FontSizeControl, { shapes: shapes }, "size"), _jsx(TextDecorationControl, { shapes: shapes }, "decor"), _jsx(TextAlignControl, { shapes: shapes }, "align"), _jsx(ListControl, { shapes: shapes }, "list"));
75
+ overflow.push(_jsx(LinkControl, { shapes: shapes }, "link"), _jsx(Divider, {}, "d-color"), _jsx(ColorOpacityControl, { shapes: shapes }, "color"), _jsx(HighlightControl, { shapes: shapes }, "highlight"));
76
+ }
77
+ else if (allImage) {
78
+ // An image's pixels are the content — fill/stroke make no sense.
79
+ // name | replace | download | alt | crop | opacity.
80
+ if (shapes.length === 1) {
81
+ primary.push(_jsx(ImageNameControl, { shapes: shapes }, "name"));
82
+ overflow.push(_jsx(ReplaceImageControl, { shapes: shapes }, "replace"), _jsx(DownloadImageControl, { shapes: shapes }, "download"), _jsx(ImageAltControl, { shapes: shapes }, "alt"), _jsx(Divider, {}, "d-crop"));
83
+ }
84
+ overflow.push(_jsx(CropControl, { shapes: shapes }, "crop"), _jsx(MaskControl, { shapes: shapes }, "mask"), _jsx(OpacityControl, { shapes: shapes }, "opacity"));
85
+ }
86
+ else if (selectionBuckets(shapes).size > 1) {
87
+ // MIXED types (reference behaviour): the toolbar SHRINKS to the
88
+ // shared tail below, plus a Filter that narrows the actual
89
+ // selection to one type bucket. Per-type controls come back once
90
+ // the selection is uniform again.
91
+ primary.push(_jsx(SelectionFilterControl, { shapes: shapes }, "filter"));
92
+ }
93
+ else {
94
+ // label text controls (for every shape type that can carry text, even
95
+ // before it has any) | border group (color / width / dash / corners) |
96
+ // fill group (color / opacity) | link.
97
+ if (shapes.every((s) => canCarryLabel(s))) {
98
+ // Pseudo-shapes exposing the LABEL's font + style so the text
99
+ // controls read label values; `labelMode` reroutes their writes
100
+ // through the label APIs.
101
+ const labelViews = shapes.map(labelView);
102
+ primary.push(_jsx(FontFamilyControl, { shapes: labelViews, labelMode: true }, "l-family"), _jsx(FontSizeControl, { shapes: labelViews, labelMode: true }, "l-size"), _jsx(TextDecorationControl, { shapes: labelViews, labelMode: true }, "l-decor"), _jsx(TextAlignControl, { shapes: labelViews, labelMode: true }, "l-align"), _jsx(ColorOpacityControl, { shapes: labelViews, labelMode: true }, "l-color"), _jsx(HighlightControl, { shapes: labelViews, labelMode: true }, "l-highlight"), _jsx(Divider, {}, "d-label"));
103
+ }
104
+ if (allBrush) {
105
+ // Brush widths are baked per point — `style.strokeWidth` has no
106
+ // effect, so brush-only selections get a slider that re-bases the
107
+ // baked widths, plus the plain stroke color picker.
108
+ primary.push(_jsx(StrokeControl, { shapes: shapes }, "stroke"), _jsx(BrushWidthControl, { shapes: shapes }, "width"));
109
+ }
110
+ else {
111
+ primary.push(_jsx(BorderGroupControl, { shapes: shapes }, "border"), _jsx(FillOpacityControl, { shapes: shapes }, "fill"));
112
+ }
113
+ // PanelShell already separates `primary` from `overflow`.
114
+ overflow.push(_jsx(LinkControl, { shapes: shapes }, "link"));
115
+ }
116
+ // Shared tail for every selection type:
117
+ // `link (frame / image) | comment | lock | ⋯`.
118
+ // Text and shapes carry their link control in the type cluster above;
119
+ // z-order, align / distribute, duplicate / delete, group / ungroup and
120
+ // flip all live in the context menu (⋯).
121
+ if (allFrame || allImage)
122
+ overflow.push(_jsx(LinkControl, { shapes: shapes }, "link"));
123
+ overflow.push(_jsx(CommentControl, { shapes: shapes }, "comment"), _jsx(Divider, {}, "d-lock"), _jsx(LockControl, {}, "lock"), _jsx(MoreButton, {}, "more"));
124
+ return (_jsx(PanelShell, { mobile: mobile, primary: primary, overflow: overflow, className: className, style: style }));
125
+ }
126
+ if (selectedLinkId !== null) {
127
+ const edge = scene.links.get(selectedLinkId);
128
+ if (!edge)
129
+ return null;
130
+ const primary = [
131
+ _jsx(LinkStrokeColorControl, { edge: edge }, "color"),
132
+ _jsx(LinkStrokeWidthControl, { edge: edge }, "width"),
133
+ _jsx(LinkArrowheadControl, { edge: edge, side: "to" }, "arrow-to"),
134
+ ];
135
+ const overflow = [
136
+ _jsx(LinkStrokeStyleControl, { edge: edge }, "dash"),
137
+ _jsx(LinkRoutingControl, { edge: edge }, "routing"),
138
+ _jsx(LinkLineKindControl, { edge: edge }, "kind"),
139
+ _jsx(LinkArrowheadControl, { edge: edge, side: "from" }, "arrow-from"),
140
+ _jsx(LinkAutoRouteControl, { edge: edge }, "auto"),
141
+ _jsx(LinkDeleteControl, {}, "delete"),
142
+ _jsx(MoreButton, {}, "more"),
143
+ ];
144
+ return (_jsx(PanelShell, { mobile: mobile, primary: primary, overflow: overflow, className: className, style: style }));
145
+ }
146
+ return null;
147
+ };
148
+ /**
149
+ * Lays out the primary / overflow control groups. Desktop = one floating
150
+ * pill row (primary · divider · overflow). Mobile = a primary row with a
151
+ * vertical-dots ⋮ that expands a wrapped overflow grid below it.
152
+ */
153
+ const PanelShell = ({ mobile, primary, overflow, className, style, }) => {
154
+ const [expanded, setExpanded] = useState(false);
155
+ const panelRef = useRef(null);
156
+ // Collapse the expanded overflow sheet on a tap outside the panel.
157
+ // The ⋮ button and the grabber collapse it directly; this covers taps
158
+ // on the canvas / elsewhere.
159
+ useEffect(() => {
160
+ if (!mobile || !expanded)
161
+ return undefined;
162
+ const onDown = (e) => {
163
+ const el = panelRef.current;
164
+ if (el && e.target instanceof Node && !el.contains(e.target))
165
+ setExpanded(false);
166
+ };
167
+ // `capture` so we see the tap even if something stops propagation.
168
+ document.addEventListener("pointerdown", onDown, true);
169
+ return () => {
170
+ document.removeEventListener("pointerdown", onDown, true);
171
+ };
172
+ }, [mobile, expanded]);
173
+ if (!mobile) {
174
+ return (_jsx("div", { className: `du-sel-panel ${className ?? ""}`.trim(), style: style, children: groupControls([...primary, _jsx(Divider, {}, "d-overflow"), ...overflow]) }));
175
+ }
176
+ return (_jsxs("div", { ref: panelRef, className: `du-sel-panel du-sel-panel-mobile ${className ?? ""}`.trim(), style: style, children: [_jsxs("div", { className: "du-sel-mobile-row", children: [_jsx("div", { className: "du-sel-mobile-primary", children: groupControls(primary) }), overflow.length > 0 ? (_jsx("button", { type: "button", className: `du-sel-icon-button du-sel-mobile-expand${expanded ? " is-active" : ""}`, "aria-expanded": expanded, "aria-label": expanded ? "Hide more properties" : "More properties", title: "More properties", onClick: () => {
177
+ setExpanded((v) => !v);
178
+ }, children: _jsx(MoreVertical, { ...CONTROL_ICON, "aria-hidden": true }) })) : null] }), expanded && overflow.length > 0 ? (_jsx("div", { className: "du-sel-mobile-overflow", children: groupControls(overflow) })) : null] }));
179
+ };
180
+ /**
181
+ * Element link control. One trigger (chain icon, active when a link is
182
+ * set) opens a popover with a URL field plus Save / Open / Remove. Works
183
+ * for any shape — the href lives on `ElementBase`. The URL is normalised
184
+ * (`normalizeHref`: adds `https://`, `mailto:`, rejects `javascript:`)
185
+ * before storing. Multi-select applies to all.
186
+ */
187
+ const LinkControl = ({ shapes }) => {
188
+ const editor = useDiagramOptional();
189
+ const inputRef = useRef(null);
190
+ if (!editor)
191
+ return null;
192
+ const ids = shapes.map((s) => s.id);
193
+ const current = sharedString(shapes, (s) => s.href);
194
+ const hasLink = shapes.some((s) => Boolean(s.href));
195
+ const save = (raw) => {
196
+ editor.setLink(ids, raw);
197
+ };
198
+ return (_jsx(Popover, { ariaLabel: "Link", trigger: _jsx("button", { type: "button", className: `du-sel-icon-button${hasLink ? " is-active" : ""}`, title: "Link", "aria-label": "Link", children: _jsx(LinkIcon, { ...CONTROL_ICON, "aria-hidden": true }) }), children: _jsxs("div", { className: "du-sel-popover-section", children: [_jsx("header", { className: "du-sel-popover-label", children: "Link" }), _jsx("input", { ref: inputRef, className: "du-sel-link-input", type: "text", placeholder: "https://\u2026 \u00B7 name@mail", defaultValue: current ?? "", "aria-label": "Link URL", onKeyDown: (ev) => {
199
+ if (ev.key === "Enter") {
200
+ ev.preventDefault();
201
+ save(ev.currentTarget.value);
202
+ }
203
+ } }), _jsxs("div", { style: { display: "flex", gap: 2 }, children: [_jsx("button", { type: "button", className: "du-sel-text-button", onClick: () => {
204
+ save(inputRef.current?.value ?? "");
205
+ }, children: "Save" }), hasLink ? (_jsx("button", { type: "button", className: "du-sel-text-button", onClick: () => {
206
+ editor.openLink(current);
207
+ }, children: "Open" })) : null, hasLink ? (_jsx("button", { type: "button", className: "du-sel-text-button", onClick: () => {
208
+ editor.setLink(ids, null);
209
+ }, children: "Remove" })) : null] })] }) }));
210
+ };
211
+ /**
212
+ * Start a comment thread on the selected element: adds an annotation pin
213
+ * anchored to the (first) selected shape and selects it, which opens the
214
+ * comment thread UI. Same backing model as the context menu's
215
+ * "Add comment" — this is just the toolbar affordance for it.
216
+ */
217
+ const CommentControl = ({ shapes }) => {
218
+ const editor = useDiagramOptional();
219
+ const first = shapes[0];
220
+ if (!editor || !first)
221
+ return null;
222
+ return (_jsx("button", { type: "button", className: "du-sel-icon-button", title: "Add comment", "aria-label": "Add comment", onClick: () => {
223
+ editor.addAnnotation({ position: { x: 0, y: 0 }, elementId: first.id });
224
+ }, children: _jsx(MessageCircle, { ...CONTROL_ICON, "aria-hidden": true }) }));
225
+ };
226
+ /**
227
+ * Lock the current selection. Locked shapes become click-through (the
228
+ * hit-test skips them), so locking also drops the selection and hides
229
+ * this panel; unlocking goes through the right-click context menu.
230
+ */
231
+ const LockControl = () => {
232
+ const editor = useDiagramOptional();
233
+ if (!editor)
234
+ return null;
235
+ return (_jsx("button", { type: "button", className: "du-sel-icon-button", title: "Lock", "aria-label": "Lock selection", onClick: () => {
236
+ editor.toggleLockSelection();
237
+ }, children: _jsx(LockIcon, { ...CONTROL_ICON, "aria-hidden": true }) }));
238
+ };
239
+ const MoreButton = () => {
240
+ const editor = useDiagramOptional();
241
+ const controller = useContextMenuController();
242
+ if (!editor || !controller)
243
+ return null;
244
+ return (_jsx("button", { type: "button", className: "du-sel-icon-button", title: "More actions", "aria-label": "More actions", onClick: (ev) => {
245
+ const rect = ev.currentTarget.getBoundingClientRect();
246
+ const screenPoint = { x: rect.left, y: rect.bottom + 4 };
247
+ const host = editor.hostElement;
248
+ const hostRect = host?.getBoundingClientRect();
249
+ const worldPoint = hostRect
250
+ ? editor.screenToWorld({
251
+ x: screenPoint.x - hostRect.left,
252
+ y: screenPoint.y - hostRect.top,
253
+ })
254
+ : { x: 0, y: 0 };
255
+ controller.open({ screenPoint, worldPoint });
256
+ }, children: _jsx(MoreHorizontal, { ...CONTROL_ICON, "aria-hidden": true }) }));
257
+ };
258
+ // ---------------------------------------------------------------------------
259
+ // Inline controls
260
+ // ---------------------------------------------------------------------------
261
+ /**
262
+ * Color trigger: a 24×24 square button with a colored fill plus an
263
+ * outer ring, opens the full swatch picker in a popover.
264
+ */
265
+ const ColorTrigger = ({ label, color, onChange, ariaLabel, onEyedrop, }) => (_jsx(Popover, { ariaLabel: ariaLabel, trigger: _jsx("button", { type: "button", className: "du-sel-color-trigger", title: label, "aria-label": ariaLabel, children: _jsx("span", { className: "du-sel-color-swatch", style: {
266
+ background: !color || color === "transparent"
267
+ ? "repeating-conic-gradient(#ccc 0% 25%, #fff 0% 50%) 50% / 6px 6px"
268
+ : color,
269
+ } }) }), children: _jsxs("div", { className: "du-sel-popover-section", children: [_jsx("header", { className: "du-sel-popover-label", children: label }), _jsx(ColorSwatchPicker, { value: color, onChange: onChange, ...(onEyedrop ? { onEyedrop } : {}) })] }) }));
270
+ const useTextRunRange = (shapes) => {
271
+ const editingId = useEditorSelector((e) => e.editingTextElement, null);
272
+ const sel = useEditorSelector((e) => e.editingTextSelection, null);
273
+ if (editingId === null || sel === null || sel.start === sel.end)
274
+ return null;
275
+ const target = shapes.find((s) => s.id === editingId);
276
+ if (target === undefined)
277
+ return null;
278
+ if (!isText(target) && !("text" in target && target.label !== undefined))
279
+ return null;
280
+ return {
281
+ target: target,
282
+ from: Math.min(sel.start, sel.end),
283
+ to: Math.max(sel.start, sel.end),
284
+ };
285
+ };
286
+ /**
287
+ * Combined color & opacity control — a single swatch trigger whose
288
+ * popover has both the palette and an opacity slider. Used for the text
289
+ * panel in place of separate Fill + Opacity triggers. Writes `fill` and
290
+ * `opacity` through `editor.updateStyle`.
291
+ */
292
+ const ColorOpacityControl = ({ shapes, labelMode, }) => {
293
+ const editor = useDiagramOptional();
294
+ const runRange = useTextRunRange(shapes);
295
+ if (!editor)
296
+ return null;
297
+ const ids = shapes.map((s) => s.id);
298
+ const color = sharedString(shapes, (s) => s.style.fill);
299
+ const opacity = sharedValue(shapes, (s) => s.style.opacity ?? 1);
300
+ const pct = opacity === null ? null : Math.round(opacity * 100);
301
+ const swatchBg = !color || color === "transparent"
302
+ ? "repeating-conic-gradient(#ccc 0% 25%, #fff 0% 50%) 50% / 6px 6px"
303
+ : color;
304
+ return (_jsx(Popover, { ariaLabel: "Text color and opacity", trigger: _jsx("button", { type: "button", className: "du-sel-color-trigger", title: "Text color & opacity", "aria-label": "Text color and opacity", children: _jsx("span", { className: "du-sel-color-swatch", style: { background: swatchBg, opacity: opacity ?? 1 } }) }), children: _jsxs("div", { className: "du-sel-popover-section", children: [_jsx("header", { className: "du-sel-popover-label", children: "Text color" }), _jsx(ColorSwatchPicker, { value: color, onChange: (v) => {
305
+ // In-edit text selection → colour just those characters (runs);
306
+ // otherwise colour the whole element(s) / label(s).
307
+ if (runRange) {
308
+ editor.applyTextStyleToRange(runRange.target.id, runRange.from, runRange.to, {
309
+ fill: v ?? "transparent",
310
+ });
311
+ }
312
+ else if (labelMode) {
313
+ editor.updateLabelStyle(ids, { fill: v ?? "transparent" });
314
+ }
315
+ else {
316
+ editor.updateStyle(ids, { fill: v ?? "transparent" });
317
+ }
318
+ }, onEyedrop: (cb) => {
319
+ editor.beginEyedropperPick(cb);
320
+ } }), _jsx("header", { className: "du-sel-popover-label", children: "Opacity" }), _jsx(Slider, { value: pct, min: 0, max: 100, step: 5, ariaLabel: "Opacity", valueLabel: pct === null ? "—" : `${pct}%`, onChange: (v) => {
321
+ if (labelMode)
322
+ editor.updateLabelStyle(ids, { opacity: v / 100 });
323
+ else
324
+ editor.updateStyle(ids, { opacity: v / 100 });
325
+ } })] }) }));
326
+ };
327
+ /** Sticky size presets (S / M / L squares). */
328
+ const StickySizeControl = ({ shapes }) => {
329
+ const editor = useDiagramOptional();
330
+ if (!editor)
331
+ return null;
332
+ const ids = shapes.map((s) => s.id);
333
+ const side = sharedValue(shapes, (s) => s.width);
334
+ return (_jsx(SegmentedControl, { ariaLabel: "Sticky size", value: side, options: STICKY_SIZE_PRESETS.map((p) => ({
335
+ value: p.side,
336
+ label: p.id.toUpperCase(),
337
+ icon: _jsx("span", { className: "du-sel-size-letter", children: p.id.toUpperCase() }),
338
+ })), onChange: (v) => {
339
+ editor.setStickySize(ids, v);
340
+ } }));
341
+ };
342
+ /** Tag editor for sticky notes: pills with remove + an input that adds on Enter. */
343
+ const StickyTagControl = ({ shapes }) => {
344
+ const editor = useDiagramOptional();
345
+ const first = shapes[0];
346
+ if (!editor || !first)
347
+ return null;
348
+ const tags = first.tags ?? [];
349
+ const ids = shapes.map((s) => s.id);
350
+ return (_jsx(Popover, { ariaLabel: "Tags", trigger: _jsx("button", { type: "button", className: "du-sel-icon-button", title: "Add tag", "aria-label": "Add tag", children: _jsx(Tag, { ...CONTROL_ICON, "aria-hidden": true }) }), children: _jsxs("div", { className: "du-sel-popover-section", children: [_jsx("header", { className: "du-sel-popover-label", children: "Tags" }), tags.length > 0 ? (_jsx("div", { className: "du-sel-tag-list", children: tags.map((tag) => (_jsxs("span", { className: "du-sel-tag-pill", children: [tag, _jsx("button", { type: "button", className: "du-sel-tag-remove", "aria-label": `Remove tag ${tag}`, onClick: () => {
351
+ editor.setStickyTags(ids, tags.filter((t) => t !== tag));
352
+ }, children: "\u00D7" })] }, tag))) })) : null, _jsx("input", { type: "text", className: "du-sel-name-input", placeholder: "Add tag\u2026", "aria-label": "New tag", onKeyDown: (ev) => {
353
+ if (ev.key !== "Enter")
354
+ return;
355
+ ev.preventDefault();
356
+ const value = ev.currentTarget.value.trim();
357
+ if (value === "" || tags.includes(value))
358
+ return;
359
+ editor.setStickyTags(ids, [...tags, value]);
360
+ ev.currentTarget.value = "";
361
+ } })] }) }));
362
+ };
363
+ /** Toggle the author-name strip along the sticky's bottom edge. */
364
+ const StickyAuthorControl = ({ shapes }) => {
365
+ const editor = useDiagramOptional();
366
+ if (!editor)
367
+ return null;
368
+ const ids = shapes.map((s) => s.id);
369
+ const on = shapes.every((s) => s.showAuthor === true);
370
+ return (_jsx("button", { type: "button", className: `du-sel-icon-button${on ? " is-active" : ""}`, title: "Show author", "aria-label": "Show author", "aria-pressed": on, onClick: () => {
371
+ editor.toggleStickyAuthor(ids);
372
+ }, children: _jsx(UserRound, { ...CONTROL_ICON, "aria-hidden": true }) }));
373
+ };
374
+ /** Emoji picker: replace the element's glyph with one of the presets. */
375
+ const EmojiPickerControl = ({ shapes }) => {
376
+ const editor = useDiagramOptional();
377
+ const first = shapes[0];
378
+ if (!editor || !first)
379
+ return null;
380
+ const current = first.glyph;
381
+ return (_jsx(Popover, { ariaLabel: "Choose emoji", trigger: _jsx("button", { type: "button", className: "du-sel-text-button", title: "Choose emoji", "aria-label": "Choose emoji", children: current }), children: _jsx("div", { className: "du-sel-emoji-grid", children: EMOJI_QUICK_PICKS.map((glyph) => (_jsx("button", { type: "button", className: "du-sel-emoji-item", "aria-label": `Emoji ${glyph}`, onClick: () => {
382
+ editor.setEmojiGlyph(shapes.map((s) => s.id), glyph);
383
+ }, children: glyph }, glyph))) }) }));
384
+ };
385
+ /**
386
+ * Grouped border editor: stroke color, width, dash style and corner
387
+ * rounding in ONE popover ("border style, opacity, corners and color").
388
+ * Every write goes through `editor.updateStyle` on the whole selection.
389
+ */
390
+ const BorderGroupControl = ({ shapes }) => {
391
+ const editor = useDiagramOptional();
392
+ if (!editor)
393
+ return null;
394
+ const ids = shapes.map((s) => s.id);
395
+ const stroke = sharedString(shapes, (s) => s.style.stroke);
396
+ const width = sharedValue(shapes, (s) => s.style.strokeWidth ?? 1);
397
+ const dash = sharedValue(shapes, (s) => {
398
+ const d = s.style.dashArray;
399
+ if (!d || d.length === 0)
400
+ return "solid";
401
+ return (d[0] ?? 0) <= 2 ? "dotted" : "dashed";
402
+ });
403
+ const round = sharedValue(shapes, (s) => s.style.roundness?.type ?? "sharp");
404
+ const roundable = shapes.some((s) => isRectangle(s));
405
+ return (_jsx(Popover, { ariaLabel: "Border style", trigger: _jsx("button", { type: "button", className: "du-sel-color-trigger", title: "Border style, corners and color", "aria-label": "Border style, corners and color", children: _jsx("span", { className: "du-sel-color-swatch du-sel-swatch-ring", style: { borderColor: stroke ?? "var(--menu-border)" } }) }), children: _jsxs("div", { className: "du-sel-popover-section", children: [_jsx("header", { className: "du-sel-popover-label", children: "Border color" }), _jsx(ColorSwatchPicker, { value: stroke, onChange: (v) => {
406
+ editor.updateStyle(ids, { stroke: v ?? "transparent" });
407
+ }, onEyedrop: (cb) => {
408
+ editor.beginEyedropperPick(cb);
409
+ } }), _jsx("header", { className: "du-sel-popover-label", children: "Width" }), _jsx(SegmentedControl, { ariaLabel: "Border width", value: width, options: [
410
+ { value: 1, label: "Thin", icon: _jsx(StrokeWidthIcon, { thickness: 1 }) },
411
+ { value: 2, label: "Medium", icon: _jsx(StrokeWidthIcon, { thickness: 2.5 }) },
412
+ { value: 4, label: "Thick", icon: _jsx(StrokeWidthIcon, { thickness: 4 }) },
413
+ ], onChange: (v) => {
414
+ editor.updateStyle(ids, { strokeWidth: v });
415
+ } }), _jsx("header", { className: "du-sel-popover-label", children: "Style" }), _jsx(SegmentedControl, { ariaLabel: "Border dash style", value: dash, options: [
416
+ { value: "solid", label: "Solid", icon: _jsx(Square, { ...CONTROL_ICON }) },
417
+ {
418
+ value: "dashed",
419
+ label: "Dashed",
420
+ icon: _jsx(SquareDashed, { ...CONTROL_ICON }),
421
+ },
422
+ { value: "dotted", label: "Dotted", icon: _jsx(SquareDot, { ...CONTROL_ICON }) },
423
+ ], onChange: (v) => {
424
+ editor.updateStyle(ids, {
425
+ dashArray: v === "solid" ? [] : v === "dashed" ? [8, 4] : [2, 4],
426
+ });
427
+ } }), roundable ? (_jsxs(_Fragment, { children: [_jsx("header", { className: "du-sel-popover-label", children: "Corners" }), _jsx(SegmentedControl, { ariaLabel: "Corner rounding", value: round, options: [
428
+ { value: "sharp", label: "Sharp", icon: _jsx(CornerIcon, { kind: "sharp" }) },
429
+ { value: "round", label: "Round", icon: _jsx(CornerIcon, { kind: "round" }) },
430
+ ], onChange: (v) => {
431
+ editor.updateStyle(ids, { roundness: { type: v } });
432
+ } })] })) : null] }) }));
433
+ };
434
+ /**
435
+ * Grouped fill editor: fill color + opacity in one popover
436
+ * ("set color and opacity").
437
+ */
438
+ const FillOpacityControl = ({ shapes }) => {
439
+ const editor = useDiagramOptional();
440
+ if (!editor || !shapes.some(hasFill))
441
+ return null;
442
+ const ids = shapes.map((s) => s.id);
443
+ const fill = sharedString(shapes, (s) => s.style.fill);
444
+ const opacity = sharedValue(shapes, (s) => s.style.opacity ?? 1);
445
+ const pct = opacity === null ? null : Math.round(opacity * 100);
446
+ const swatchBg = !fill || fill === "transparent"
447
+ ? "repeating-conic-gradient(#ccc 0% 25%, #fff 0% 50%) 50% / 6px 6px"
448
+ : fill;
449
+ return (_jsx(Popover, { ariaLabel: "Fill color and opacity", trigger: _jsx("button", { type: "button", className: "du-sel-color-trigger", title: "Fill color & opacity", "aria-label": "Fill color and opacity", children: _jsx("span", { className: "du-sel-color-swatch", style: { background: swatchBg, opacity: opacity ?? 1 } }) }), children: _jsxs("div", { className: "du-sel-popover-section", children: [_jsx("header", { className: "du-sel-popover-label", children: "Fill" }), _jsx(ColorSwatchPicker, { value: fill, onChange: (v) => {
450
+ editor.updateStyle(ids, { fill: v ?? "transparent" });
451
+ }, onEyedrop: (cb) => {
452
+ editor.beginEyedropperPick(cb);
453
+ } }), _jsx("header", { className: "du-sel-popover-label", children: "Opacity" }), _jsx(Slider, { value: pct, min: 0, max: 100, step: 5, ariaLabel: "Fill opacity", valueLabel: pct === null ? "—" : `${String(pct)}%`, onChange: (v) => {
454
+ editor.updateStyle(ids, { opacity: v / 100 });
455
+ } })] }) }));
456
+ };
457
+ /**
458
+ * Frame size presets (paper / screen ratios) as a dropdown. Applying one
459
+ * resizes the frame to the canonical size; free resize simply diverges
460
+ * (Custom is implicit — nothing is stored on the element).
461
+ */
462
+ const FrameRatioControl = ({ shapes }) => {
463
+ const editor = useDiagramOptional();
464
+ const first = shapes[0];
465
+ if (!editor || !first)
466
+ return null;
467
+ return (_jsx(Popover, { ariaLabel: "Frame size", trigger: _jsx("button", { type: "button", className: "du-sel-icon-button", title: "Frame size", "aria-label": "Frame size", children: _jsx(Proportions, { ...CONTROL_ICON, "aria-hidden": true }) }), children: _jsxs("div", { className: "du-sel-popover-section", children: [_jsx("header", { className: "du-sel-popover-label", children: "Frame size" }), _jsx("div", { className: "du-sel-preset-list", children: FRAME_SIZE_PRESETS.map((preset) => (_jsx("button", { type: "button", className: "du-sel-preset-item", onClick: () => {
468
+ editor.applyFramePreset(first.id, preset);
469
+ }, children: preset.label }, preset.id))) })] }) }));
470
+ };
471
+ /** The backing BinaryFile of a single-image selection, if any. */
472
+ const backingFile = (editor, shapes) => {
473
+ const first = shapes[0];
474
+ if (!first || !isImage(first) || first.fileId === undefined)
475
+ return null;
476
+ const file = getBinaryFile(editor.scene, first.fileId);
477
+ return file ? { elementId: first.id, fileId: first.fileId, file } : null;
478
+ };
479
+ /**
480
+ * File-name input for a single selected image backed by a registered
481
+ * binary file. Commits on Enter / blur through the editor (undoable);
482
+ * images without a file registry entry (raw `src`) hide the control.
483
+ */
484
+ const ImageNameControl = ({ shapes }) => {
485
+ const editor = useDiagramOptional();
486
+ if (!editor)
487
+ return null;
488
+ const backing = backingFile(editor, shapes);
489
+ if (!backing)
490
+ return null;
491
+ const commit = (value) => {
492
+ const trimmed = value.trim();
493
+ if (trimmed.length > 0)
494
+ editor.renameBinaryFile(backing.fileId, trimmed);
495
+ };
496
+ return (_jsx("input", { type: "text", className: "du-sel-name-input", defaultValue: backing.file.name ?? "", placeholder: "File name", "aria-label": "File name", onBlur: (ev) => {
497
+ commit(ev.currentTarget.value);
498
+ }, onKeyDown: (ev) => {
499
+ if (ev.key === "Enter") {
500
+ ev.preventDefault();
501
+ commit(ev.currentTarget.value);
502
+ ev.currentTarget.blur();
503
+ }
504
+ } }, backing.file.name ?? backing.fileId));
505
+ };
506
+ /**
507
+ * Pick a new media file (image / GIF / video) and swap it under the
508
+ * selected shape. Position and width are kept (height refits to the new
509
+ * aspect); the crop resets when the media kind changes.
510
+ */
511
+ const ReplaceImageControl = ({ shapes }) => {
512
+ const editor = useDiagramOptional();
513
+ const inputRef = useRef(null);
514
+ const first = shapes[0];
515
+ if (!editor || !first || !isImage(first))
516
+ return null;
517
+ return (_jsxs(_Fragment, { children: [_jsx("button", { type: "button", className: "du-sel-icon-button", title: "Replace media", "aria-label": "Replace media", onClick: () => {
518
+ inputRef.current?.click();
519
+ }, children: _jsx(Upload, { ...CONTROL_ICON, "aria-hidden": true }) }), _jsx("input", { ref: inputRef, type: "file", accept: "image/*,video/*,.gif,.mp4,.webm,.mov", style: { display: "none" }, onChange: (ev) => {
520
+ const file = ev.currentTarget.files?.[0];
521
+ ev.currentTarget.value = "";
522
+ if (file)
523
+ void editor.replaceImageFile(first.id, file, file.name);
524
+ } })] }));
525
+ };
526
+ /** Download the image's original bytes with their stored name / mime. */
527
+ const DownloadImageControl = ({ shapes }) => {
528
+ const editor = useDiagramOptional();
529
+ if (!editor)
530
+ return null;
531
+ const backing = backingFile(editor, shapes);
532
+ if (!backing)
533
+ return null;
534
+ return (_jsx("button", { type: "button", className: "du-sel-icon-button", title: "Download image", "aria-label": "Download image", onClick: () => {
535
+ const blob = new Blob([backing.file.data], { type: backing.file.mime });
536
+ const url = URL.createObjectURL(blob);
537
+ const a = document.createElement("a");
538
+ a.href = url;
539
+ a.download = backing.file.name ?? "image";
540
+ document.body.appendChild(a);
541
+ a.click();
542
+ document.body.removeChild(a);
543
+ URL.revokeObjectURL(url);
544
+ }, children: _jsx(Download, { ...CONTROL_ICON, "aria-hidden": true }) }));
545
+ };
546
+ /** Alt-text editor (accessible description) for the selected image. */
547
+ const ImageAltControl = ({ shapes }) => {
548
+ const editor = useDiagramOptional();
549
+ const first = shapes[0];
550
+ if (!editor || !first || !isImage(first))
551
+ return null;
552
+ const current = first.alt ?? "";
553
+ return (_jsx(Popover, { ariaLabel: "Alt text", trigger: _jsx("button", { type: "button", className: "du-sel-icon-button", title: "Alt text", "aria-label": "Alt text", children: _jsx(FileText, { ...CONTROL_ICON, "aria-hidden": true }) }), children: _jsxs("div", { className: "du-sel-popover-section", children: [_jsx("header", { className: "du-sel-popover-label", children: "Alt text" }), _jsx("textarea", { className: "du-sel-alt-input", defaultValue: current, rows: 3, placeholder: "Describe this image", "aria-label": "Alt text", onBlur: (ev) => {
554
+ const value = ev.currentTarget.value.trim();
555
+ if (value !== current)
556
+ editor.setImageAlt([first.id], value === "" ? null : value);
557
+ } })] }) }));
558
+ };
559
+ /**
560
+ * Text lists as a two-row dropdown block: list kind (bulleted / ordered)
561
+ * over nesting (decrease / increase indent). While inline-editing, the
562
+ * operations target the paragraphs under the caret / selection; otherwise
563
+ * the whole element. Clicking the active kind again clears it.
564
+ */
565
+ const ListControl = ({ shapes }) => {
566
+ const editor = useDiagramOptional();
567
+ if (!editor)
568
+ return null;
569
+ const ids = shapes.map((s) => s.id);
570
+ const kind = sharedValue(shapes, (s) => {
571
+ const paragraphs = s.paragraphs ?? [];
572
+ const first = paragraphs[0]?.list;
573
+ if (first === undefined)
574
+ return "none";
575
+ return paragraphs.every((p) => p.list === first) ? first : "none";
576
+ });
577
+ return (_jsx(Popover, { ariaLabel: "List", trigger: _jsx("button", { type: "button", className: "du-sel-icon-button", title: "List", "aria-label": "List", children: _jsx(List, { ...CONTROL_ICON, "aria-hidden": true }) }), children: _jsxs("div", { className: "du-sel-align-rows", children: [_jsx(SegmentedControl, { ariaLabel: "List kind", value: kind === "none" ? null : kind, options: [
578
+ {
579
+ value: "bullet",
580
+ label: "Bulleted list",
581
+ icon: _jsx(List, { ...CONTROL_ICON }),
582
+ },
583
+ {
584
+ value: "numbered",
585
+ label: "Ordered list",
586
+ icon: _jsx(ListOrdered, { ...CONTROL_ICON }),
587
+ },
588
+ ], onChange: (v) => {
589
+ editor.setParagraphList(ids, kind === v ? null : v);
590
+ } }), _jsxs("div", { className: "du-sel-align-rows-row", children: [_jsx("button", { type: "button", className: "du-sel-icon-button", title: "Decrease indent", "aria-label": "Decrease indent", onClick: () => {
591
+ editor.indentParagraphs(ids, -1);
592
+ }, children: _jsx(IndentDecrease, { ...CONTROL_ICON, "aria-hidden": true }) }), _jsx("button", { type: "button", className: "du-sel-icon-button", title: "Increase indent", "aria-label": "Increase indent", onClick: () => {
593
+ editor.indentParagraphs(ids, 1);
594
+ }, children: _jsx(IndentIncrease, { ...CONTROL_ICON, "aria-hidden": true }) })] })] }) }));
595
+ };
596
+ /**
597
+ * Marker-style text highlight (background behind glyphs). During inline
598
+ * editing with a selected range the highlight lands on just those
599
+ * characters (styled runs); otherwise on the whole element(s). Picking
600
+ * "no color" clears the highlight.
601
+ */
602
+ const HighlightControl = ({ shapes, labelMode, }) => {
603
+ const editor = useDiagramOptional();
604
+ const runRange = useTextRunRange(shapes);
605
+ if (!editor)
606
+ return null;
607
+ const ids = shapes.map((s) => s.id);
608
+ const value = sharedString(shapes, (s) => s.style.highlight);
609
+ return (_jsx(Popover, { ariaLabel: "Highlight color", trigger: _jsx("button", { type: "button", className: "du-sel-icon-button", title: "Highlight color", "aria-label": "Highlight color", children: _jsx(Highlighter, { ...CONTROL_ICON, "aria-hidden": true }) }), children: _jsxs("div", { className: "du-sel-popover-section", children: [_jsx("header", { className: "du-sel-popover-label", children: "Highlight" }), _jsx(ColorSwatchPicker, { value: value, onChange: (v) => {
610
+ const partial = { highlight: v ?? "transparent" };
611
+ if (runRange) {
612
+ editor.applyTextStyleToRange(runRange.target.id, runRange.from, runRange.to, partial);
613
+ }
614
+ else if (labelMode) {
615
+ editor.updateLabelStyle(ids, partial);
616
+ }
617
+ else {
618
+ editor.updateStyle(ids, partial);
619
+ }
620
+ }, onEyedrop: (cb) => {
621
+ editor.beginEyedropperPick(cb);
622
+ } })] }) }));
623
+ };
624
+ const FillControl = ({ shapes }) => {
625
+ const editor = useDiagramOptional();
626
+ if (!editor || !shapes.some(hasFill))
627
+ return null;
628
+ const value = sharedString(shapes, (s) => s.style.fill);
629
+ const ids = shapes.map((s) => s.id);
630
+ return (_jsx(ColorTrigger, { label: "Fill", ariaLabel: "Fill color", color: value, onChange: (v) => {
631
+ editor.updateStyle(ids, { fill: v ?? "transparent" });
632
+ }, onEyedrop: (cb) => {
633
+ editor.beginEyedropperPick(cb);
634
+ } }));
635
+ };
636
+ // ---------------------------------------------------------------------------
637
+ // Text controls — rendered only for a text-only selection (see the
638
+ // dispatcher in `PropertyPanel`). `fontSize` / `fontFamily` are
639
+ // top-level `TextElement` fields written via `editor.updateTextProps`;
640
+ // `textAlign` / `textBaseline` are `TextStyle` fields written via
641
+ // `editor.updateStyle`.
642
+ // ---------------------------------------------------------------------------
643
+ const FontSizeControl = ({ shapes, labelMode, allowAuto, }) => {
644
+ const editor = useDiagramOptional();
645
+ if (!editor)
646
+ return null;
647
+ const ids = shapes.map((s) => s.id);
648
+ const value = sharedValue(shapes,
649
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- cast asserts TextElement; non-text shapes lack fontSize at runtime
650
+ (s) => s.fontSize ?? null);
651
+ const auto = allowAuto === true && shapes.every((s) => s.label?.autoFit === true);
652
+ const presetValue = value !== null && TEXT_FONT_SIZE_PRESETS.some((p) => p.value === value) ? value : null;
653
+ return (_jsx(Popover, { ariaLabel: "Font size", trigger: _jsx("button", { type: "button", className: "du-sel-text-button", title: "Font size", "aria-label": `Font size ${auto ? "auto" : (value ?? "mixed")}`, children: auto ? "A" : value === null ? "—" : `${Math.round(value)}` }), children: _jsxs("div", { className: "du-sel-popover-section", children: [_jsx("header", { className: "du-sel-popover-label", children: "Font size" }), allowAuto === true ? (_jsx("button", { type: "button", className: `du-sel-icon-button du-sel-auto-size${auto ? " is-active" : ""}`, "aria-pressed": auto, title: "Auto \u2014 text size follows the sticky", onClick: () => {
654
+ editor.setLabelAutoFit(ids, !auto);
655
+ }, children: "Auto" })) : null, _jsx(SegmentedControl, { ariaLabel: "Font size preset", value: presetValue, options: TEXT_FONT_SIZE_PRESETS.map((p) => ({
656
+ value: p.value,
657
+ label: p.label,
658
+ icon: _jsx("span", { style: { fontSize: 11, fontWeight: 600 }, children: p.label }),
659
+ })), onChange: (v) => {
660
+ if (labelMode)
661
+ editor.updateLabelProps(ids, { fontSize: v });
662
+ else
663
+ editor.updateTextProps(ids, { fontSize: v });
664
+ } }), _jsx(Slider, { value: value, min: TEXT_FONT_SIZE_MIN, max: TEXT_FONT_SIZE_MAX, step: 1, ariaLabel: "Font size", valueLabel: value === null ? "—" : `${value}px`, onChange: (v) => {
665
+ if (labelMode)
666
+ editor.updateLabelProps(ids, { fontSize: v });
667
+ else
668
+ editor.updateTextProps(ids, { fontSize: v });
669
+ } })] }) }));
670
+ };
671
+ const FontFamilyControl = ({ shapes, labelMode, }) => {
672
+ const editor = useDiagramOptional();
673
+ if (!editor)
674
+ return null;
675
+ const ids = shapes.map((s) => s.id);
676
+ const value = sharedString(shapes, (s) => s.fontFamily);
677
+ const current = TEXT_FONT_STACKS.find((f) => f.value === value);
678
+ const label = value === null ? "Mixed" : (current?.label ?? "Custom");
679
+ return (_jsx(Popover, { ariaLabel: "Font family", trigger: _jsx("button", { type: "button", className: "du-sel-text-button", title: "Font family", "aria-label": `Font family ${label}`, style: value ? { fontFamily: value } : undefined, children: label }), children: _jsxs("div", { className: "du-sel-popover-section", children: [_jsx("header", { className: "du-sel-popover-label", children: "Font family" }), TEXT_FONT_STACKS.map((f) => (_jsx("button", { type: "button", role: "menuitemradio", "aria-checked": f.value === value, className: `du-sel-menu-row${f.value === value ? " is-active" : ""}`, style: { fontFamily: f.value }, onClick: () => {
680
+ if (labelMode)
681
+ editor.updateLabelProps(ids, { fontFamily: f.value });
682
+ else
683
+ editor.updateTextProps(ids, { fontFamily: f.value });
684
+ }, children: f.label }, f.value)))] }) }));
685
+ };
686
+ /**
687
+ * Text alignment as a two-row dropdown block: horizontal (left / center /
688
+ * right → `textAlign`) over vertical (top / middle / bottom →
689
+ * `textBaseline`). One trigger keeps the toolbar row compact and matches
690
+ * the target design's grouped alignment control.
691
+ */
692
+ const TextAlignControl = ({ shapes, labelMode, }) => {
693
+ const editor = useDiagramOptional();
694
+ if (!editor)
695
+ return null;
696
+ const ids = shapes.map((s) => s.id);
697
+ const value = sharedValue(shapes, (s) => s.style.textAlign ?? "left");
698
+ const valign = sharedValue(shapes, (s) => s.style.textBaseline ?? "top");
699
+ return (_jsx(Popover, { ariaLabel: "Text alignment", trigger: _jsx("button", { type: "button", className: "du-sel-icon-button", title: "Text alignment", "aria-label": "Text alignment", children: value === "right" ? (_jsx(AlignRight, { ...CONTROL_ICON, "aria-hidden": true })) : value === "center" ? (_jsx(AlignCenter, { ...CONTROL_ICON, "aria-hidden": true })) : (_jsx(AlignLeft, { ...CONTROL_ICON, "aria-hidden": true })) }), children: _jsxs("div", { className: "du-sel-align-rows", children: [_jsx(SegmentedControl, { ariaLabel: "Horizontal text alignment", value: value, options: [
700
+ { value: "left", label: "Left", icon: _jsx(AlignLeft, { ...CONTROL_ICON }) },
701
+ {
702
+ value: "center",
703
+ label: "Center",
704
+ icon: _jsx(AlignCenter, { ...CONTROL_ICON }),
705
+ },
706
+ { value: "right", label: "Right", icon: _jsx(AlignRight, { ...CONTROL_ICON }) },
707
+ ], onChange: (v) => {
708
+ if (labelMode)
709
+ editor.updateLabelStyle(ids, { textAlign: v });
710
+ else
711
+ editor.updateStyle(ids, { textAlign: v });
712
+ } }), _jsx(SegmentedControl, { ariaLabel: "Vertical text alignment", value: valign, options: [
713
+ {
714
+ value: "top",
715
+ label: "Top",
716
+ icon: _jsx(AlignStartHorizontal, { ...CONTROL_ICON }),
717
+ },
718
+ {
719
+ value: "middle",
720
+ label: "Middle",
721
+ icon: _jsx(AlignCenterHorizontal, { ...CONTROL_ICON }),
722
+ },
723
+ {
724
+ value: "bottom",
725
+ label: "Bottom",
726
+ icon: _jsx(AlignEndHorizontal, { ...CONTROL_ICON }),
727
+ },
728
+ ], onChange: (v) => {
729
+ if (labelMode)
730
+ editor.updateLabelStyle(ids, { textBaseline: v });
731
+ else
732
+ editor.updateStyle(ids, { textBaseline: v });
733
+ } })] }) }));
734
+ };
735
+ /**
736
+ * One decoration toggle inside {@link TextDecorationControl}'s popover.
737
+ * MUST stay a module-level component: defining it inside its parent would
738
+ * give it a fresh identity on every parent re-render, so React would
739
+ * remount the `<button>` each frame. During inline text editing the panel
740
+ * re-renders constantly (caret blink), and a remount between `mousedown`
741
+ * and `mouseup` swallows the synthesized `click` — the toggle would then
742
+ * silently never fire.
743
+ */
744
+ const TextStyleToggle = ({ active, label, icon, onClick, }) => (_jsx("button", { type: "button", className: `du-sel-icon-button${active ? " is-active" : ""}`, title: label, "aria-label": label, "aria-pressed": active, onClick: onClick, children: icon }));
745
+ /**
746
+ * Bold / Italic / Underline / Strikethrough. One trigger (Aa) opens a
747
+ * popover with four independent toggles. Each writes through
748
+ * `editor.updateStyle`: bold→`fontWeight`, italic→`fontStyle`,
749
+ * underline/strikethrough→merged `textDecoration`. Active = every
750
+ * selected shape already has that decoration on.
751
+ */
752
+ const TextDecorationControl = ({ shapes, labelMode, }) => {
753
+ const editor = useDiagramOptional();
754
+ const runRange = useTextRunRange(shapes);
755
+ if (!editor)
756
+ return null;
757
+ const ids = shapes.map((s) => s.id);
758
+ // Active state: over an in-edit range, read the effective per-run style
759
+ // (run overlay ?? element style); otherwise read the whole-element style.
760
+ const rangeSegs = runRange ? sliceRuns(runRange.target, runRange.from, runRange.to) : [];
761
+ const base = runRange?.target.style;
762
+ const segEvery = (pred) => rangeSegs.length > 0 && rangeSegs.every((r) => pred(r.style));
763
+ const allBold = runRange
764
+ ? segEvery((st) => (st?.fontWeight ?? base?.fontWeight) === "bold")
765
+ : shapes.every((s) => s.style?.fontWeight === "bold");
766
+ const allItalic = runRange
767
+ ? segEvery((st) => (st?.fontStyle ?? base?.fontStyle) === "italic")
768
+ : shapes.every((s) => s.style?.fontStyle === "italic");
769
+ const allUnderline = runRange
770
+ ? segEvery((st) => (st?.textDecoration ?? base?.textDecoration)?.underline === true)
771
+ : shapes.every((s) => s.style?.textDecoration?.underline === true);
772
+ const allStrike = runRange
773
+ ? segEvery((st) => (st?.textDecoration ?? base?.textDecoration)?.strikethrough === true)
774
+ : shapes.every((s) => s.style?.textDecoration?.strikethrough === true);
775
+ // Apply a partial text style to the in-edit range (rich text) or, with no
776
+ // active range, to the whole selected element(s).
777
+ const applyPartial = (partial) => {
778
+ if (runRange) {
779
+ editor.applyTextStyleToRange(runRange.target.id, runRange.from, runRange.to, partial);
780
+ }
781
+ else if (labelMode) {
782
+ editor.updateLabelStyle(ids, partial);
783
+ }
784
+ else {
785
+ editor.updateStyle(ids, partial);
786
+ }
787
+ };
788
+ // Toggling underline/strikethrough must preserve the other flag. Range mode
789
+ // replaces the whole `textDecoration`, so rebuild both flags from the
790
+ // range's current state; whole-element mode merges per shape.
791
+ const setDecoration = (key, on) => {
792
+ if (labelMode && !runRange) {
793
+ for (const s of shapes) {
794
+ const cur = s.style?.textDecoration ?? {};
795
+ editor.updateLabelStyle([s.id], { textDecoration: { ...cur, [key]: on } });
796
+ }
797
+ return;
798
+ }
799
+ if (runRange) {
800
+ editor.applyTextStyleToRange(runRange.target.id, runRange.from, runRange.to, {
801
+ textDecoration: { underline: allUnderline, strikethrough: allStrike, [key]: on },
802
+ });
803
+ }
804
+ else {
805
+ for (const s of shapes) {
806
+ const cur = s.style?.textDecoration ?? {};
807
+ editor.updateStyle([s.id], { textDecoration: { ...cur, [key]: on } });
808
+ }
809
+ }
810
+ };
811
+ return (_jsx(Popover, { ariaLabel: "Text style", trigger: _jsx("button", { type: "button", className: "du-sel-icon-button", title: "Text style (bold / italic / \u2026)", "aria-label": "Text style", children: _jsx(CaseSensitive, { ...CONTROL_ICON, "aria-hidden": true }) }), children: _jsxs("div", { className: "du-sel-popover-section", children: [_jsx("header", { className: "du-sel-popover-label", children: "Style" }), _jsxs("div", { style: { display: "flex", gap: 2 }, children: [_jsx(TextStyleToggle, { active: allBold, label: "Bold", icon: _jsx(Bold, { ...CONTROL_ICON }), onClick: () => {
812
+ applyPartial({ fontWeight: allBold ? "normal" : "bold" });
813
+ } }), _jsx(TextStyleToggle, { active: allItalic, label: "Italic", icon: _jsx(Italic, { ...CONTROL_ICON }), onClick: () => {
814
+ applyPartial({ fontStyle: allItalic ? "normal" : "italic" });
815
+ } }), _jsx(TextStyleToggle, { active: allUnderline, label: "Underline", icon: _jsx(Underline, { ...CONTROL_ICON }), onClick: () => {
816
+ setDecoration("underline", !allUnderline);
817
+ } }), _jsx(TextStyleToggle, { active: allStrike, label: "Strikethrough", icon: _jsx(Strikethrough, { ...CONTROL_ICON }), onClick: () => {
818
+ setDecoration("strikethrough", !allStrike);
819
+ } })] })] }) }));
820
+ };
821
+ const StrokeControl = ({ shapes }) => {
822
+ const editor = useDiagramOptional();
823
+ if (!editor || !shapes.some(hasStroke))
824
+ return null;
825
+ const value = sharedString(shapes, (s) => s.style.stroke);
826
+ const ids = shapes.map((s) => s.id);
827
+ return (_jsx(ColorTrigger, { label: "Stroke", ariaLabel: "Stroke color", color: value, onChange: (v) => {
828
+ editor.updateStyle(ids, { stroke: v ?? "transparent" });
829
+ }, onEyedrop: (cb) => {
830
+ editor.beginEyedropperPick(cb);
831
+ } }));
832
+ };
833
+ /**
834
+ * Width control for brush strokes: a popover with a range slider driving
835
+ * `editor.setBrushWidth`, which re-bases the baked per-point widths while
836
+ * keeping the stroke's pressure profile. Rendered instead of
837
+ * {@link StrokeWidthControl} when the whole selection is brush strokes.
838
+ */
839
+ const BrushWidthControl = ({ shapes }) => {
840
+ const editor = useDiagramOptional();
841
+ if (!editor)
842
+ return null;
843
+ const ids = shapes.map((s) => s.id);
844
+ const value = sharedValue(shapes, (s) => {
845
+ const brush = s;
846
+ const base = brush.baseWidth ?? brush.points.reduce((m, p) => Math.max(m, p.width), 0);
847
+ return base > 0 ? Math.round(base) : null;
848
+ });
849
+ return (_jsx(Popover, { ariaLabel: "Brush width", trigger: _jsx("button", { type: "button", className: "du-sel-icon-button", title: "Brush width", "aria-label": "Brush width", children: _jsx(StrokeWidthIcon, { thickness: 2.5 }) }), children: _jsxs("div", { className: "du-sel-popover-section", children: [_jsx("header", { className: "du-sel-popover-label", children: `Width ${value !== null ? String(value) : "mixed"}` }), _jsx("input", { type: "range", min: BRUSH_WIDTH_MIN, max: BRUSH_WIDTH_MAX, step: 1, value: value ?? BRUSH_WIDTH_MIN, onChange: (e) => {
850
+ editor.setBrushWidth(ids, e.currentTarget.valueAsNumber);
851
+ }, style: { width: "100%" }, "aria-label": "Brush width" })] }) }));
852
+ };
853
+ /**
854
+ * Opacity control: percentage badge button opens a popover with a
855
+ * slider. The trigger is always rendered (even at implicit opacity 1) so
856
+ * the user can jump to 50% without a multi-step interaction.
857
+ */
858
+ const OpacityControl = ({ shapes }) => {
859
+ const editor = useDiagramOptional();
860
+ if (!editor)
861
+ return null;
862
+ const value = sharedValue(shapes, (s) => s.style.opacity ?? 1);
863
+ const ids = shapes.map((s) => s.id);
864
+ const percent = value === null ? null : Math.round(value * 100);
865
+ const label = percent === null ? "—" : `${percent}%`;
866
+ return (_jsx(Popover, { ariaLabel: "Opacity", trigger: _jsx("button", { type: "button", className: "du-sel-text-button", title: "Opacity", "aria-label": `Opacity ${label}`, children: label }), children: _jsxs("div", { className: "du-sel-popover-section", children: [_jsx("header", { className: "du-sel-popover-label", children: "Opacity" }), _jsx(Slider, { value: percent, min: 0, max: 100, step: 5, ariaLabel: "Opacity", valueLabel: label, onChange: (v) => {
867
+ editor.updateStyle(ids, { opacity: v / 100 });
868
+ } })] }) }));
869
+ };
870
+ /**
871
+ * Convert-type control (F9): switch every selected rectangle / ellipse /
872
+ * diamond to another of those types, preserving position, size and style.
873
+ * Renders only when every selected shape is convertible. The active type is
874
+ * shown as the pressed segment (or `null` for a mixed selection).
875
+ */
876
+ /**
877
+ * Selection-filter buckets (reference grouping): coarse type groups the
878
+ * Filter menu offers, keyed by bucket id. `types` maps element `type`
879
+ * strings into the bucket.
880
+ */
881
+ const SELECTION_BUCKETS = [
882
+ {
883
+ id: "shapes",
884
+ label: "Shapes",
885
+ icon: Square,
886
+ types: ["rectangle", "ellipse", "polygon", "path", "block-arrow"],
887
+ },
888
+ { id: "sticky", label: "Sticky notes", icon: StickyNote, types: ["sticky"] },
889
+ { id: "text", label: "Text", icon: CaseSensitive, types: ["text"] },
890
+ { id: "image", label: "Images", icon: ImageIcon, types: ["image"] },
891
+ { id: "frame", label: "Frames", icon: Proportions, types: ["frame"] },
892
+ { id: "brush", label: "Drawings", icon: Spline, types: ["brush"] },
893
+ { id: "emoji", label: "Emoji", icon: SmilePlus, types: ["emoji"] },
894
+ { id: "other", label: "Other", icon: MoreHorizontal, types: [] },
895
+ ];
896
+ const bucketIdOf = (type) => SELECTION_BUCKETS.find((b) => b.types.includes(type))?.id ?? "other";
897
+ /** Group a selection's shapes into type buckets (insertion-ordered). */
898
+ const selectionBuckets = (shapes) => {
899
+ const out = new Map();
900
+ for (const shape of shapes) {
901
+ const id = bucketIdOf(shape.type);
902
+ const list = out.get(id);
903
+ if (list)
904
+ list.push(shape);
905
+ else
906
+ out.set(id, [shape]);
907
+ }
908
+ return out;
909
+ };
910
+ /**
911
+ * Filter control for MIXED selections (reference behaviour): a popover
912
+ * listing the selection's type buckets with counts; picking one NARROWS
913
+ * THE ACTUAL SELECTION to that bucket's elements (the per-type toolbar
914
+ * then takes over). Single bucket per pick — no multi-filter.
915
+ */
916
+ const SelectionFilterControl = ({ shapes }) => {
917
+ const editor = useDiagramOptional();
918
+ if (!editor)
919
+ return null;
920
+ const buckets = selectionBuckets(shapes);
921
+ return (_jsx(Popover, { ariaLabel: "Filter selection", trigger: _jsx("button", { type: "button", className: "du-sel-icon-button", title: "Filter selection by type", "aria-label": "Filter selection by type", children: _jsx(ListFilter, { ...CONTROL_ICON, "aria-hidden": true }) }), children: _jsxs("div", { className: "du-sel-popover-section", children: [_jsx("header", { className: "du-sel-popover-label", children: "Select only" }), _jsx("div", { className: "du-sel-mask-list", role: "menu", "aria-label": "Selection type filter", children: [...buckets.entries()].map(([id, members]) => {
922
+ const bucket = SELECTION_BUCKETS.find((b) => b.id === id);
923
+ if (!bucket)
924
+ return null;
925
+ const Icon = bucket.icon;
926
+ return (_jsxs("button", { type: "button", role: "menuitem", className: "du-sel-mask-row", "aria-label": `Select only ${bucket.label}`, onClick: () => {
927
+ editor.setSelection(members.map((m) => m.id));
928
+ }, children: [_jsx(Icon, { ...CONTROL_ICON, "aria-hidden": true }), _jsx("span", { children: bucket.label }), _jsx("span", { className: "du-sel-mask-ratio", children: members.length })] }, id));
929
+ }) })] }) }));
930
+ };
931
+ /**
932
+ * Switch-type targets offered by {@link ConvertTypeControl}, in menu
933
+ * order. Every listed kind converts to every other one (shape kinds ↔
934
+ * text ↔ sticky).
935
+ */
936
+ const CONVERT_TARGETS = [
937
+ { value: "rectangle", label: "Rectangle", icon: Square },
938
+ { value: "ellipse", label: "Ellipse", icon: Circle },
939
+ { value: "polygon", label: "Diamond", icon: Diamond },
940
+ { value: "text", label: "Text", icon: CaseSensitive },
941
+ { value: "sticky", label: "Sticky note", icon: StickyNote },
942
+ ];
943
+ /** Kinds inside the switch-type matrix — the only ones the picker handles. */
944
+ const isConvertible = (s) => isRectangle(s) || isEllipse(s) || isPolygon(s) || isText(s) || isSticky(s);
945
+ const convertTargetOf = (s) => isRectangle(s)
946
+ ? "rectangle"
947
+ : isEllipse(s)
948
+ ? "ellipse"
949
+ : isText(s)
950
+ ? "text"
951
+ : isSticky(s)
952
+ ? "sticky"
953
+ : "polygon";
954
+ /**
955
+ * Switch-type picker: one trigger showing the selection's current kind
956
+ * that opens a menu of every target kind. Picking a row converts the
957
+ * selection in place and closes the menu.
958
+ */
959
+ const ConvertTypeControl = ({ shapes }) => {
960
+ const editor = useDiagramOptional();
961
+ const [open, setOpen] = useState(false);
962
+ if (!editor)
963
+ return null;
964
+ const value = sharedValue(shapes, convertTargetOf);
965
+ const current = CONVERT_TARGETS.find((t) => t.value === value);
966
+ const TriggerIcon = current?.icon ?? Square;
967
+ return (_jsx(Popover, { ariaLabel: "Switch type", open: open, onOpenChange: setOpen, trigger: _jsx("button", { type: "button", className: "du-sel-icon-button", title: "Switch type", "aria-label": "Switch type", children: _jsx(TriggerIcon, { ...CONTROL_ICON, "aria-hidden": true }) }), children: _jsxs("div", { className: "du-sel-popover-section", children: [_jsx("header", { className: "du-sel-popover-label", children: "Switch type" }), _jsx("div", { className: "du-sel-mask-list", role: "menu", "aria-label": "Switch type targets", children: CONVERT_TARGETS.map((target) => {
968
+ const Icon = target.icon;
969
+ const active = target.value === value;
970
+ return (_jsxs("button", { type: "button", role: "menuitemradio", "aria-checked": active, className: `du-sel-mask-row${active ? " is-active" : ""}`, "aria-label": target.label, onClick: () => {
971
+ editor.convertSelection(target.value);
972
+ setOpen(false);
973
+ }, children: [_jsx(Icon, { ...CONTROL_ICON, "aria-hidden": true }), _jsx("span", { children: target.label })] }, target.value));
974
+ }) })] }) }));
975
+ };
976
+ /**
977
+ * Mask presets offered by {@link MaskControl}: `null` = no mask, plus
978
+ * the two parametric kinds and the built-in polygon rings. `radius`
979
+ * default for round-rect comes from `IMAGE_MASK_DEFAULT_RADIUS`.
980
+ */
981
+ const MASK_TILES = [
982
+ { key: "none", label: "No mask", icon: Square, mask: null },
983
+ { key: "ellipse", label: "Ellipse mask", icon: Circle, mask: { kind: "ellipse" } },
984
+ {
985
+ key: "round-rect",
986
+ label: "Rounded mask",
987
+ icon: Squircle,
988
+ mask: { kind: "round-rect", radius: IMAGE_MASK_DEFAULT_RADIUS },
989
+ },
990
+ ...[
991
+ ["diamond", "Diamond mask", Diamond],
992
+ ["triangle", "Triangle mask", TriangleIcon],
993
+ ["hexagon", "Hexagon mask", HexagonIcon],
994
+ ["star", "Star mask", StarIcon],
995
+ ].map(([key, label, icon]) => ({
996
+ key,
997
+ label,
998
+ icon,
999
+ mask: {
1000
+ kind: "polygon",
1001
+ points: IMAGE_MASK_POLYGON_PRESETS[key] ?? [],
1002
+ },
1003
+ })),
1004
+ ];
1005
+ /**
1006
+ * Aspect-preset tiles (reference mask list): momentary actions, not
1007
+ * stored kinds — Custom enters the free-crop mode, Original resets
1008
+ * crop + mask to the source's natural aspect, the rest centre-crop to
1009
+ * the ratio via `Editor.setImageAspectPreset` (Circle also installs an
1010
+ * ellipse mask on the square box).
1011
+ */
1012
+ const ASPECT_TILES = [
1013
+ { key: "custom", label: "Custom", icon: Crop },
1014
+ { key: "original", label: "Original", icon: ImageIcon },
1015
+ { key: "circle", label: "Circle", icon: Circle },
1016
+ { key: "square", label: "Square", icon: Square },
1017
+ { key: "portrait", label: "Portrait", icon: RectangleVertical, ratio: "3:4" },
1018
+ { key: "landscape", label: "Landscape", icon: RectangleHorizontal, ratio: "4:3" },
1019
+ { key: "wide", label: "Wide", icon: Tv, ratio: "16:9" },
1020
+ ];
1021
+ /** The tile a shape's current mask corresponds to (for the pressed state). */
1022
+ const maskTileKey = (mask) => {
1023
+ if (!mask)
1024
+ return "none";
1025
+ if (mask.kind === "polygon") {
1026
+ for (const [name, ring] of Object.entries(IMAGE_MASK_POLYGON_PRESETS)) {
1027
+ if (ring.length === mask.points.length &&
1028
+ ring.every((p, i) => {
1029
+ const q = mask.points[i];
1030
+ return q?.x === p.x && q.y === p.y;
1031
+ })) {
1032
+ return name;
1033
+ }
1034
+ }
1035
+ return "polygon";
1036
+ }
1037
+ return mask.kind;
1038
+ };
1039
+ /**
1040
+ * Shape-mask picker for image selections: a popover of shape tiles
1041
+ * (None / Ellipse / Rounded / polygon presets) applied instantly, plus a
1042
+ * corner-radius slider when the rounded mask is active. The canvas
1043
+ * renderer clips through `RenderTarget.clip`, so the mask reaches every
1044
+ * backend and PNG / SVG exports.
1045
+ */
1046
+ const MaskControl = ({ shapes }) => {
1047
+ const editor = useDiagramOptional();
1048
+ if (!editor)
1049
+ return null;
1050
+ const images = shapes.filter((s) => isImage(s));
1051
+ if (images.length === 0)
1052
+ return null;
1053
+ const ids = images.map((s) => s.id);
1054
+ const current = sharedValue(images, (s) => maskTileKey(s.mask));
1055
+ const firstMask = images[0]?.mask;
1056
+ const radius = firstMask?.kind === "round-rect" ? firstMask.radius : null;
1057
+ return (_jsx(Popover, { ariaLabel: "Image mask", trigger: _jsx("button", { type: "button", className: "du-sel-icon-button", title: "Mask", "aria-label": "Image mask", children: _jsx(Squircle, { ...CONTROL_ICON, "aria-hidden": true }) }), children: _jsxs("div", { className: "du-sel-popover-section", children: [_jsx("header", { className: "du-sel-popover-label", children: "Mask" }), _jsx("div", { className: "du-sel-mask-list", role: "menu", "aria-label": "Aspect presets", children: ASPECT_TILES.map((tile) => {
1058
+ const Icon = tile.icon;
1059
+ return (_jsxs("button", { type: "button", role: "menuitem", className: "du-sel-mask-row", "aria-label": tile.label, onClick: () => {
1060
+ if (tile.key === "custom") {
1061
+ const first = ids[0];
1062
+ if (first !== undefined)
1063
+ editor.beginImageCrop(first);
1064
+ }
1065
+ else {
1066
+ editor.setImageAspectPreset(ids, tile.key);
1067
+ }
1068
+ }, children: [_jsx(Icon, { ...CONTROL_ICON, "aria-hidden": true }), _jsx("span", { children: tile.label }), tile.ratio !== undefined ? (_jsx("span", { className: "du-sel-mask-ratio", children: tile.ratio })) : null] }, tile.key));
1069
+ }) }), _jsx("div", { className: "du-sel-mask-tiles", children: MASK_TILES.map((tile) => {
1070
+ const Icon = tile.icon;
1071
+ const active = current === tile.key;
1072
+ return (_jsx("button", { type: "button", className: `du-sel-icon-button${active ? " is-active" : ""}`, title: tile.label, "aria-label": tile.label, "aria-pressed": active, onClick: () => {
1073
+ editor.setImageMask(ids, tile.mask);
1074
+ }, children: _jsx(Icon, { ...CONTROL_ICON, "aria-hidden": true }) }, tile.key));
1075
+ }) }), radius !== null ? (_jsx(Slider, { value: Math.round(radius * 100), min: 0, max: 50, step: 5, ariaLabel: "Corner radius", valueLabel: `${String(Math.round(radius * 100))}%`, onChange: (v) => {
1076
+ editor.setImageMask(ids, { kind: "round-rect", radius: v / 100 });
1077
+ } })) : null] }) }));
1078
+ };
1079
+ /**
1080
+ * Crop control (F10): a button that enters image-crop mode for the single
1081
+ * selected image. Renders only for a lone image selection (crop is
1082
+ * single-target). Double-clicking the image on the canvas does the same.
1083
+ */
1084
+ const CropControl = ({ shapes }) => {
1085
+ const editor = useDiagramOptional();
1086
+ if (!editor)
1087
+ return null;
1088
+ const only = shapes.length === 1 ? shapes[0] : undefined;
1089
+ if (only === undefined || !isImage(only))
1090
+ return null;
1091
+ const id = only.id;
1092
+ return (_jsx("button", { type: "button", className: "du-sel-icon-button", title: "Crop image (double-click)", "aria-label": "Crop image", onClick: () => {
1093
+ editor.beginImageCrop(id);
1094
+ }, children: _jsx(Crop, { ...CONTROL_ICON, "aria-hidden": true }) }));
1095
+ };
1096
+ // ---------------------------------------------------------------------------
1097
+ // Link controls — horizontal compact set used when an edge (not a
1098
+ // shape) is the active selection. Mirrors the shape control surface
1099
+ // (color triggers + segmented row controls) so the floating panel
1100
+ // reads consistently regardless of selection type.
1101
+ // ---------------------------------------------------------------------------
1102
+ const LinkStrokeColorControl = ({ edge }) => {
1103
+ const editor = useDiagramOptional();
1104
+ if (!editor)
1105
+ return null;
1106
+ const color = typeof edge.style.stroke === "string" ? edge.style.stroke : null;
1107
+ return (_jsx(ColorTrigger, { label: "Stroke", ariaLabel: "Link stroke color", color: color, onChange: (v) => {
1108
+ editor.updateSelectedLink((e) => ({
1109
+ ...e,
1110
+ style: { ...e.style, stroke: v ?? "transparent" },
1111
+ }));
1112
+ }, onEyedrop: (cb) => {
1113
+ editor.beginEyedropperPick(cb);
1114
+ } }));
1115
+ };
1116
+ const LinkStrokeWidthControl = ({ edge }) => {
1117
+ const editor = useDiagramOptional();
1118
+ if (!editor)
1119
+ return null;
1120
+ const value = typeof edge.style.strokeWidth === "number" ? edge.style.strokeWidth : null;
1121
+ return (_jsx(SegmentedControl, { ariaLabel: "Link stroke width", value: value, options: [
1122
+ { value: 1, label: "Thin", icon: _jsx(StrokeWidthIcon, { thickness: 1 }) },
1123
+ { value: 2, label: "Medium", icon: _jsx(StrokeWidthIcon, { thickness: 2.5 }) },
1124
+ { value: 4, label: "Thick", icon: _jsx(StrokeWidthIcon, { thickness: 4 }) },
1125
+ ], onChange: (v) => {
1126
+ editor.updateSelectedLink((e) => ({
1127
+ ...e,
1128
+ style: { ...e.style, strokeWidth: v },
1129
+ }));
1130
+ } }));
1131
+ };
1132
+ const LinkStrokeStyleControl = ({ edge }) => {
1133
+ const editor = useDiagramOptional();
1134
+ if (!editor)
1135
+ return null;
1136
+ const da = edge.style.dashArray;
1137
+ const value = (() => {
1138
+ if (!da || da.length === 0)
1139
+ return "solid";
1140
+ const first = da[0] ?? 0;
1141
+ return first <= 3 ? "dotted" : "dashed";
1142
+ })();
1143
+ return (_jsx(SegmentedControl, { ariaLabel: "Link stroke style", value: value, options: [
1144
+ { value: "solid", label: "Solid", icon: _jsx(Square, { ...CONTROL_ICON }) },
1145
+ { value: "dashed", label: "Dashed", icon: _jsx(SquareDashed, { ...CONTROL_ICON }) },
1146
+ { value: "dotted", label: "Dotted", icon: _jsx(SquareDot, { ...CONTROL_ICON }) },
1147
+ ], onChange: (v) => {
1148
+ const dashArray = v === "solid" ? [] : v === "dashed" ? [8, 4] : [2, 4];
1149
+ editor.updateSelectedLink((e) => ({
1150
+ ...e,
1151
+ style: { ...e.style, dashArray },
1152
+ }));
1153
+ } }));
1154
+ };
1155
+ const LinkLineKindControl = ({ edge }) => {
1156
+ const editor = useDiagramOptional();
1157
+ if (!editor)
1158
+ return null;
1159
+ const value = edge.lineKind ?? "line";
1160
+ return (_jsx(SegmentedControl, { ariaLabel: "Link body", value: value, options: [
1161
+ { value: "line", label: "Line", icon: _jsx(Minus, { ...CONTROL_ICON }) },
1162
+ {
1163
+ value: "block-arrow",
1164
+ label: "Block arrow",
1165
+ icon: _jsx(MoveRight, { ...CONTROL_ICON }),
1166
+ },
1167
+ ], onChange: (v) => {
1168
+ editor.updateSelectedLink((e) => ({ ...e, lineKind: v }));
1169
+ } }));
1170
+ };
1171
+ const LinkRoutingControl = ({ edge }) => {
1172
+ const editor = useDiagramOptional();
1173
+ if (!editor)
1174
+ return null;
1175
+ const value = edge.routing ?? "straight";
1176
+ return (_jsx(SegmentedControl, { ariaLabel: "Link routing", value: value, options: [
1177
+ { value: "straight", label: "Straight", icon: _jsx(RoutingIcon, { kind: "straight" }) },
1178
+ { value: "orthogonal", label: "Elbow", icon: _jsx(RoutingIcon, { kind: "orthogonal" }) },
1179
+ { value: "bezier", label: "Curved", icon: _jsx(Spline, { ...CONTROL_ICON }) },
1180
+ ], onChange: (v) => {
1181
+ editor.updateSelectedLink((e) => ({ ...e, routing: v }));
1182
+ } }));
1183
+ };
1184
+ const LinkArrowheadControl = ({ edge, side, }) => {
1185
+ const editor = useDiagramOptional();
1186
+ const [showErd, setShowErd] = useState(false);
1187
+ if (!editor)
1188
+ return null;
1189
+ const current = edge.arrowheads?.[side] ?? "none";
1190
+ const pick = (style) => {
1191
+ editor.updateSelectedLink((e) => ({
1192
+ ...e,
1193
+ arrowheads: { ...(e.arrowheads ?? {}), [side]: style },
1194
+ }));
1195
+ };
1196
+ const Option = ({ style }) => (_jsx("button", { type: "button", className: `du-arrowhead-option${style === current ? " du-arrowhead-option--active" : ""}`, title: ARROWHEAD_LABELS[style], "aria-label": ARROWHEAD_LABELS[style], "aria-pressed": style === current, onClick: () => {
1197
+ pick(style);
1198
+ }, children: style === "none" ? (_jsx("span", { className: "du-arrowhead-none", children: "\u2205" })) : arrowheadGlyphFamily(style) === "none" ? (_jsx("span", { className: "du-arrowhead-erd-label", children: ARROWHEAD_LABELS[style].replace(/^ERD /, "") })) : (_jsx(ArrowheadGlyph, { kind: style, side: side })) }));
1199
+ return (_jsx(Popover, { trigger: _jsx("button", { type: "button", className: "du-sel-icon-button", title: `Arrow ${side}: ${ARROWHEAD_LABELS[current]}`, "aria-label": `Arrow ${side}`, children: _jsx(ArrowheadGlyph, { kind: current, side: side }) }), children: _jsxs("div", { className: "du-sel-popover-section", children: [_jsxs("header", { className: "du-sel-popover-label", children: ["Arrow ", side] }), _jsx("div", { className: "du-arrowhead-grid", children: BASIC_ARROWHEADS.map((s) => (_jsx(Option, { style: s }, s))) }), _jsxs("button", { type: "button", className: "du-arrowhead-erd-toggle", "aria-expanded": showErd, onClick: () => {
1200
+ setShowErd((v) => !v);
1201
+ }, children: [showErd ? "▾" : "▸", " ER diagram"] }), showErd && (_jsx("div", { className: "du-arrowhead-grid", children: ERD_ARROWHEADS.map((s) => (_jsx(Option, { style: s }, s))) }))] }) }));
1202
+ };
1203
+ const LinkAutoRouteControl = ({ edge }) => {
1204
+ const editor = useDiagramOptional();
1205
+ if (!editor)
1206
+ return null;
1207
+ // Obstacle-avoidance produces an orthogonal path, so it only makes sense
1208
+ // for straight / elbow links — a curved (bezier) link can't carry the
1209
+ // routed polyline. Hide the toggle for curved.
1210
+ const routing = edge.routing ?? "straight";
1211
+ if (routing === "bezier")
1212
+ return null;
1213
+ const on = edge.avoidObstacles === true;
1214
+ return (_jsx("button", { type: "button", className: `du-sel-icon-button${on ? " is-active" : ""}`, title: "Route around shapes", "aria-label": "Route around shapes", "aria-pressed": on, onClick: () => {
1215
+ editor.setSelectedLinkAvoidObstacles(!on);
1216
+ }, children: _jsx(Waypoints, { ...CONTROL_ICON, "aria-hidden": true }) }));
1217
+ };
1218
+ const LinkDeleteControl = () => {
1219
+ const editor = useDiagramOptional();
1220
+ if (!editor)
1221
+ return null;
1222
+ return (_jsx("button", { type: "button", className: "du-sel-icon-button", title: "Delete edge", "aria-label": "Delete edge", onClick: () => {
1223
+ editor.deleteSelected();
1224
+ }, children: _jsx(Trash2, { ...CONTROL_ICON, "aria-hidden": true }) }));
1225
+ };
1226
+ // Inline SVG glyph for routing variant — Lucide has `Spline` for the
1227
+ // curve but no clean "straight" / "elbow" line variants.
1228
+ const RoutingIcon = ({ kind }) => {
1229
+ if (kind === "straight") {
1230
+ return (_jsx("svg", { width: 14, height: 14, viewBox: "0 0 14 14", fill: "none", "aria-hidden": true, children: _jsx("line", { x1: 2, y1: 11, x2: 12, y2: 3, stroke: "currentColor", strokeWidth: 1.5, strokeLinecap: "round" }) }));
1231
+ }
1232
+ // orthogonal (elbow)
1233
+ return (_jsx("svg", { width: 14, height: 14, viewBox: "0 0 14 14", fill: "none", "aria-hidden": true, children: _jsx("path", { d: "M 2 11 L 2 7 L 12 7 L 12 3", stroke: "currentColor", strokeWidth: 1.5, fill: "none", strokeLinecap: "round", strokeLinejoin: "round" }) }));
1234
+ };
1235
+ // Which compact glyph family renders a given arrowhead style.
1236
+ const arrowheadGlyphFamily = (kind) => {
1237
+ switch (kind) {
1238
+ case "arrow":
1239
+ case "openArrow":
1240
+ case "roundedArrow":
1241
+ case "arcArrow":
1242
+ return "open";
1243
+ case "triangle":
1244
+ case "filledArrow":
1245
+ return "triangle";
1246
+ case "diamond":
1247
+ case "rhombus":
1248
+ case "filledRhombus":
1249
+ return "diamond";
1250
+ case "circle":
1251
+ case "filledCircle":
1252
+ return "circle";
1253
+ default:
1254
+ return "none"; // none + ERD caps (labelled by name in the picker)
1255
+ }
1256
+ };
1257
+ // Picker option sets. ERD caps are gated behind a toggle.
1258
+ const BASIC_ARROWHEADS = [
1259
+ "none",
1260
+ "arrow",
1261
+ "openArrow",
1262
+ "roundedArrow",
1263
+ "arcArrow",
1264
+ "filledArrow",
1265
+ "triangle",
1266
+ "circle",
1267
+ "filledCircle",
1268
+ "rhombus",
1269
+ "filledRhombus",
1270
+ ];
1271
+ const ERD_ARROWHEADS = [
1272
+ "erdOne",
1273
+ "erdOnlyOne",
1274
+ "erdMany",
1275
+ "erdOneOrMany",
1276
+ "erdZeroOrOne",
1277
+ "erdZeroOrMany",
1278
+ ];
1279
+ const ARROWHEAD_LABELS = {
1280
+ none: "None",
1281
+ arrow: "Arrow",
1282
+ openArrow: "Open arrow",
1283
+ roundedArrow: "Rounded arrow",
1284
+ arcArrow: "Arc arrow",
1285
+ triangle: "Triangle",
1286
+ filledArrow: "Filled arrow",
1287
+ circle: "Circle",
1288
+ filledCircle: "Filled circle",
1289
+ diamond: "Diamond",
1290
+ rhombus: "Rhombus",
1291
+ filledRhombus: "Filled rhombus",
1292
+ erdOne: "ERD one",
1293
+ erdOnlyOne: "ERD only one",
1294
+ erdMany: "ERD many",
1295
+ erdOneOrMany: "ERD one or many",
1296
+ erdZeroOrOne: "ERD zero or one",
1297
+ erdZeroOrMany: "ERD zero or many",
1298
+ };
1299
+ const ArrowheadGlyph = ({ kind, side, }) => {
1300
+ // Build a 14×14 horizontal line with the head at right (for `to`) or
1301
+ // left (for `from`), all in stroke / fill currentColor.
1302
+ const flipped = side === "from";
1303
+ const lineX1 = flipped ? 12 : 2;
1304
+ const lineX2 = flipped ? 5 : 9;
1305
+ const headCx = flipped ? 3 : 11;
1306
+ const headBase = flipped ? 5 : 9;
1307
+ const stroke = (_jsx("line", { x1: lineX1, y1: 7, x2: lineX2, y2: 7, stroke: "currentColor", strokeWidth: 1.5, strokeLinecap: "round" }));
1308
+ // Map the full vocabulary onto the four drawable glyph families. ERD caps
1309
+ // have no compact glyph — they fall through to a bare line; the picker
1310
+ // labels them by name so they stay distinguishable.
1311
+ const fam = arrowheadGlyphFamily(kind);
1312
+ let head = null;
1313
+ if (fam === "open") {
1314
+ head = (_jsx("polyline", { points: flipped
1315
+ ? `${headCx + 3},4 ${headCx},7 ${headCx + 3},10`
1316
+ : `${headCx - 3},4 ${headCx},7 ${headCx - 3},10`, stroke: "currentColor", strokeWidth: 1.5, fill: "none", strokeLinecap: "round", strokeLinejoin: "round" }));
1317
+ }
1318
+ else if (fam === "triangle") {
1319
+ head = (_jsx("polygon", { points: flipped
1320
+ ? `${headCx},7 ${headBase},4 ${headBase},10`
1321
+ : `${headCx},7 ${headBase},4 ${headBase},10`, fill: "currentColor" }));
1322
+ }
1323
+ else if (fam === "diamond") {
1324
+ head = (_jsx("polygon", { points: `${headCx},4 ${headCx + (flipped ? -3 : 3)},7 ${headCx},10 ${headCx + (flipped ? 3 : -3)},7`, fill: kind === "filledRhombus" ? "currentColor" : "none", stroke: "currentColor", strokeWidth: 1.2 }));
1325
+ }
1326
+ else if (fam === "circle") {
1327
+ head = (_jsx("circle", { cx: headCx, cy: 7, r: 2.2, fill: kind === "filledCircle" ? "currentColor" : "none", stroke: "currentColor", strokeWidth: 1.2 }));
1328
+ }
1329
+ return (_jsxs("svg", { width: 14, height: 14, viewBox: "0 0 14 14", fill: "none", "aria-hidden": true, children: [stroke, head] }));
1330
+ };
1331
+ // ---------------------------------------------------------------------------
1332
+ // Layout primitives
1333
+ // ---------------------------------------------------------------------------
1334
+ const Divider = () => _jsx("span", { className: "du-sel-divider", "aria-hidden": true });
1335
+ /**
1336
+ * Pseudo-shape exposing a shape's LABEL as if it were a text element, so
1337
+ * the text controls read label values. A shape without a label yet shows
1338
+ * the defaults its first text will take (`seedLabel` in the editor).
1339
+ */
1340
+ const labelView = (s) => ({
1341
+ ...s,
1342
+ style: s.label?.style ?? {},
1343
+ fontSize: s.label?.fontSize ?? LABEL_DEFAULT_FONT_SIZE,
1344
+ fontFamily: s.label?.fontFamily ?? TEXT_DEFAULT_FONT_FAMILY,
1345
+ text: s.label?.text ?? "",
1346
+ runs: s.label?.runs,
1347
+ });
1348
+ /**
1349
+ * Split the control list on `<Divider />` markers into `.du-sel-group`
1350
+ * clusters. The separators themselves are CSS: a group draws one before
1351
+ * itself only when a NON-EMPTY group precedes it, so an optional cluster
1352
+ * whose controls all render `null` for this selection (no label text, no
1353
+ * crop, …) never leaves a stray or doubled divider.
1354
+ */
1355
+ const groupControls = (nodes) => {
1356
+ const groups = [[]];
1357
+ for (const node of nodes) {
1358
+ if (isValidElement(node) && node.type === Divider)
1359
+ groups.push([]);
1360
+ else
1361
+ groups[groups.length - 1]?.push(node);
1362
+ }
1363
+ return groups
1364
+ .filter((g) => g.length > 0)
1365
+ .map((g, i) => (_jsx("span", { className: "du-sel-group", children: g }, `g-${String(i)}`)));
1366
+ };
1367
+ // ---------------------------------------------------------------------------
1368
+ // Inline SVG glyphs
1369
+ // ---------------------------------------------------------------------------
1370
+ const StrokeWidthIcon = ({ thickness }) => (_jsx("svg", { width: 14, height: 14, viewBox: "0 0 14 14", fill: "none", "aria-hidden": true, children: _jsx("line", { x1: 2, y1: 7, x2: 12, y2: 7, stroke: "currentColor", strokeWidth: thickness, strokeLinecap: "round" }) }));
1371
+ const CornerIcon = ({ kind }) => {
1372
+ if (kind === "sharp") {
1373
+ return _jsx(Square, { ...CONTROL_ICON, "aria-hidden": true });
1374
+ }
1375
+ return (_jsx("svg", { width: 14, height: 14, viewBox: "0 0 14 14", fill: "none", "aria-hidden": true, children: _jsx("rect", { x: 2, y: 2, width: 10, height: 10, rx: 3, ry: 3, stroke: "currentColor", strokeWidth: 1.5 }) }));
1376
+ };
1377
+ // ---------------------------------------------------------------------------
1378
+ // Helpers
1379
+ // ---------------------------------------------------------------------------
1380
+ const sharedValue = (elements, pick) => {
1381
+ const set = new Set();
1382
+ for (const s of elements)
1383
+ set.add(pick(s));
1384
+ if (set.size !== 1)
1385
+ return null;
1386
+ const v = set.values().next().value;
1387
+ return v ?? null;
1388
+ };
1389
+ const sharedString = (elements, pick) => {
1390
+ const value = sharedValue(elements, (s) => pick(s));
1391
+ return typeof value === "string" ? value : null;
1392
+ };
1393
+ // Frames are always fillable (white by default) even when `style.fill` is
1394
+ // unset.
1395
+ const hasFill = (shape) => shape.style.fill !== undefined || isFrame(shape);
1396
+ const hasStroke = (shape) => shape.style.stroke !== undefined;
1397
+ //# sourceMappingURL=property-panel.js.map