tldraw 3.16.0-next.282b7be564ae → 3.16.0-next.2f9d39693e4c

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 (291) hide show
  1. package/dist-cjs/index.d.ts +224 -102
  2. package/dist-cjs/index.js +33 -14
  3. package/dist-cjs/index.js.map +2 -2
  4. package/dist-cjs/lib/Tldraw.js +12 -2
  5. package/dist-cjs/lib/Tldraw.js.map +2 -2
  6. package/dist-cjs/lib/defaultExternalContentHandlers.js +5 -4
  7. package/dist-cjs/lib/defaultExternalContentHandlers.js.map +2 -2
  8. package/dist-cjs/lib/shapes/arrow/arrowLabel.js +6 -0
  9. package/dist-cjs/lib/shapes/arrow/arrowLabel.js.map +3 -3
  10. package/dist-cjs/lib/shapes/frame/FrameShapeUtil.js +6 -0
  11. package/dist-cjs/lib/shapes/frame/FrameShapeUtil.js.map +2 -2
  12. package/dist-cjs/lib/shapes/image/ImageShapeUtil.js +3 -0
  13. package/dist-cjs/lib/shapes/image/ImageShapeUtil.js.map +2 -2
  14. package/dist-cjs/lib/shapes/shared/PlainTextLabel.js +1 -3
  15. package/dist-cjs/lib/shapes/shared/PlainTextLabel.js.map +2 -2
  16. package/dist-cjs/lib/shapes/shared/freehand/svg.js.map +2 -2
  17. package/dist-cjs/lib/shapes/shared/useEditablePlainText.js +0 -2
  18. package/dist-cjs/lib/shapes/shared/useEditablePlainText.js.map +2 -2
  19. package/dist-cjs/lib/shapes/shared/useImageOrVideoAsset.js +0 -2
  20. package/dist-cjs/lib/shapes/shared/useImageOrVideoAsset.js.map +2 -2
  21. package/dist-cjs/lib/tools/EraserTool/childStates/Erasing.js +25 -1
  22. package/dist-cjs/lib/tools/EraserTool/childStates/Erasing.js.map +2 -2
  23. package/dist-cjs/lib/tools/EraserTool/childStates/Pointing.js +12 -0
  24. package/dist-cjs/lib/tools/EraserTool/childStates/Pointing.js.map +2 -2
  25. package/dist-cjs/lib/ui/TldrawUi.js +13 -12
  26. package/dist-cjs/lib/ui/TldrawUi.js.map +2 -2
  27. package/dist-cjs/lib/ui/assetUrls.js +13 -10
  28. package/dist-cjs/lib/ui/assetUrls.js.map +2 -2
  29. package/dist-cjs/lib/ui/components/{FollowingIndicator.js → DefaultFollowingIndicator.js} +6 -6
  30. package/dist-cjs/lib/ui/components/DefaultFollowingIndicator.js.map +7 -0
  31. package/dist-cjs/lib/ui/components/KeyboardShortcutsDialog/DefaultKeyboardShortcutsDialogContent.js +6 -6
  32. package/dist-cjs/lib/ui/components/KeyboardShortcutsDialog/DefaultKeyboardShortcutsDialogContent.js.map +1 -1
  33. package/dist-cjs/lib/ui/components/StylePanel/DefaultStylePanel.js +9 -4
  34. package/dist-cjs/lib/ui/components/StylePanel/DefaultStylePanel.js.map +2 -2
  35. package/dist-cjs/lib/ui/components/StylePanel/DefaultStylePanelContent.js +255 -316
  36. package/dist-cjs/lib/ui/components/StylePanel/DefaultStylePanelContent.js.map +2 -2
  37. package/dist-cjs/lib/ui/components/{primitives/TldrawUiButtonPicker.js → StylePanel/StylePanelButtonPicker.js} +52 -45
  38. package/dist-cjs/lib/ui/components/StylePanel/StylePanelButtonPicker.js.map +7 -0
  39. package/dist-cjs/lib/ui/components/StylePanel/StylePanelContext.js +68 -0
  40. package/dist-cjs/lib/ui/components/StylePanel/StylePanelContext.js.map +7 -0
  41. package/dist-cjs/lib/ui/components/StylePanel/{DoubleDropdownPicker.js → StylePanelDoubleDropdownPicker.js} +23 -22
  42. package/dist-cjs/lib/ui/components/StylePanel/StylePanelDoubleDropdownPicker.js.map +7 -0
  43. package/dist-cjs/lib/ui/components/StylePanel/{DropdownPicker.js → StylePanelDropdownPicker.js} +24 -21
  44. package/dist-cjs/lib/ui/components/StylePanel/StylePanelDropdownPicker.js.map +7 -0
  45. package/dist-cjs/lib/ui/components/StylePanel/StylePanelSubheading.js +28 -0
  46. package/dist-cjs/lib/ui/components/StylePanel/StylePanelSubheading.js.map +7 -0
  47. package/dist-cjs/lib/ui/components/Toolbar/AltTextEditor.js +3 -2
  48. package/dist-cjs/lib/ui/components/Toolbar/AltTextEditor.js.map +2 -2
  49. package/dist-cjs/lib/ui/components/Toolbar/DefaultImageToolbarContent.js +38 -9
  50. package/dist-cjs/lib/ui/components/Toolbar/DefaultImageToolbarContent.js.map +2 -2
  51. package/dist-cjs/lib/ui/components/Toolbar/DefaultVideoToolbarContent.js +15 -3
  52. package/dist-cjs/lib/ui/components/Toolbar/DefaultVideoToolbarContent.js.map +2 -2
  53. package/dist-cjs/lib/ui/components/Toolbar/LinkEditor.js +3 -3
  54. package/dist-cjs/lib/ui/components/Toolbar/LinkEditor.js.map +2 -2
  55. package/dist-cjs/lib/ui/components/primitives/TldrawUiContextualToolbar.js +10 -1
  56. package/dist-cjs/lib/ui/components/primitives/TldrawUiContextualToolbar.js.map +2 -2
  57. package/dist-cjs/lib/ui/components/primitives/TldrawUiSlider.js +17 -4
  58. package/dist-cjs/lib/ui/components/primitives/TldrawUiSlider.js.map +2 -2
  59. package/dist-cjs/lib/ui/components/primitives/TldrawUiToolbar.js +2 -0
  60. package/dist-cjs/lib/ui/components/primitives/TldrawUiToolbar.js.map +2 -2
  61. package/dist-cjs/lib/ui/components/primitives/TldrawUiTooltip.js +37 -36
  62. package/dist-cjs/lib/ui/components/primitives/TldrawUiTooltip.js.map +2 -2
  63. package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuItem.js +2 -1
  64. package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuItem.js.map +2 -2
  65. package/dist-cjs/lib/ui/context/actions.js +23 -10
  66. package/dist-cjs/lib/ui/context/actions.js.map +2 -2
  67. package/dist-cjs/lib/ui/context/components.js +2 -0
  68. package/dist-cjs/lib/ui/context/components.js.map +2 -2
  69. package/dist-cjs/lib/ui/context/events.js.map +1 -1
  70. package/dist-cjs/lib/ui/hooks/useExportAs.js +3 -2
  71. package/dist-cjs/lib/ui/hooks/useExportAs.js.map +2 -2
  72. package/dist-cjs/lib/ui/hooks/useTools.js +1 -1
  73. package/dist-cjs/lib/ui/hooks/useTools.js.map +2 -2
  74. package/dist-cjs/lib/ui/hooks/useTranslation/TLUiTranslationKey.js.map +1 -1
  75. package/dist-cjs/lib/ui/hooks/useTranslation/defaultTranslation.js +2 -0
  76. package/dist-cjs/lib/ui/hooks/useTranslation/defaultTranslation.js.map +2 -2
  77. package/dist-cjs/lib/ui/kbd-utils.js +9 -3
  78. package/dist-cjs/lib/ui/kbd-utils.js.map +2 -2
  79. package/dist-cjs/lib/ui/version.js +3 -3
  80. package/dist-cjs/lib/ui/version.js.map +1 -1
  81. package/dist-cjs/lib/utils/export/copyAs.js +1 -2
  82. package/dist-cjs/lib/utils/export/copyAs.js.map +2 -2
  83. package/dist-cjs/lib/utils/export/export.js +0 -20
  84. package/dist-cjs/lib/utils/export/export.js.map +2 -2
  85. package/dist-cjs/lib/utils/export/exportAs.js +1 -2
  86. package/dist-cjs/lib/utils/export/exportAs.js.map +2 -2
  87. package/dist-esm/index.d.mts +224 -102
  88. package/dist-esm/index.mjs +61 -29
  89. package/dist-esm/index.mjs.map +2 -2
  90. package/dist-esm/lib/Tldraw.mjs +14 -4
  91. package/dist-esm/lib/Tldraw.mjs.map +2 -2
  92. package/dist-esm/lib/defaultExternalContentHandlers.mjs +5 -4
  93. package/dist-esm/lib/defaultExternalContentHandlers.mjs.map +2 -2
  94. package/dist-esm/lib/shapes/arrow/arrowLabel.mjs +6 -0
  95. package/dist-esm/lib/shapes/arrow/arrowLabel.mjs.map +3 -3
  96. package/dist-esm/lib/shapes/frame/FrameShapeUtil.mjs +6 -0
  97. package/dist-esm/lib/shapes/frame/FrameShapeUtil.mjs.map +2 -2
  98. package/dist-esm/lib/shapes/image/ImageShapeUtil.mjs +3 -0
  99. package/dist-esm/lib/shapes/image/ImageShapeUtil.mjs.map +2 -2
  100. package/dist-esm/lib/shapes/shared/PlainTextLabel.mjs +1 -3
  101. package/dist-esm/lib/shapes/shared/PlainTextLabel.mjs.map +2 -2
  102. package/dist-esm/lib/shapes/shared/freehand/svg.mjs.map +2 -2
  103. package/dist-esm/lib/shapes/shared/useEditablePlainText.mjs +0 -2
  104. package/dist-esm/lib/shapes/shared/useEditablePlainText.mjs.map +2 -2
  105. package/dist-esm/lib/shapes/shared/useImageOrVideoAsset.mjs +0 -2
  106. package/dist-esm/lib/shapes/shared/useImageOrVideoAsset.mjs.map +2 -2
  107. package/dist-esm/lib/tools/EraserTool/childStates/Erasing.mjs +26 -1
  108. package/dist-esm/lib/tools/EraserTool/childStates/Erasing.mjs.map +2 -2
  109. package/dist-esm/lib/tools/EraserTool/childStates/Pointing.mjs +13 -0
  110. package/dist-esm/lib/tools/EraserTool/childStates/Pointing.mjs.map +2 -2
  111. package/dist-esm/lib/ui/TldrawUi.mjs +13 -12
  112. package/dist-esm/lib/ui/TldrawUi.mjs.map +2 -2
  113. package/dist-esm/lib/ui/assetUrls.mjs +13 -10
  114. package/dist-esm/lib/ui/assetUrls.mjs.map +2 -2
  115. package/dist-esm/lib/ui/components/{FollowingIndicator.mjs → DefaultFollowingIndicator.mjs} +3 -3
  116. package/dist-esm/lib/ui/components/DefaultFollowingIndicator.mjs.map +7 -0
  117. package/dist-esm/lib/ui/components/KeyboardShortcutsDialog/DefaultKeyboardShortcutsDialogContent.mjs +6 -6
  118. package/dist-esm/lib/ui/components/KeyboardShortcutsDialog/DefaultKeyboardShortcutsDialogContent.mjs.map +1 -1
  119. package/dist-esm/lib/ui/components/StylePanel/DefaultStylePanel.mjs +14 -5
  120. package/dist-esm/lib/ui/components/StylePanel/DefaultStylePanel.mjs.map +2 -2
  121. package/dist-esm/lib/ui/components/StylePanel/DefaultStylePanelContent.mjs +257 -320
  122. package/dist-esm/lib/ui/components/StylePanel/DefaultStylePanelContent.mjs.map +2 -2
  123. package/dist-esm/lib/ui/components/{primitives/TldrawUiButtonPicker.mjs → StylePanel/StylePanelButtonPicker.mjs} +54 -43
  124. package/dist-esm/lib/ui/components/StylePanel/StylePanelButtonPicker.mjs.map +7 -0
  125. package/dist-esm/lib/ui/components/StylePanel/StylePanelContext.mjs +48 -0
  126. package/dist-esm/lib/ui/components/StylePanel/StylePanelContext.mjs.map +7 -0
  127. package/dist-esm/lib/ui/components/StylePanel/{DoubleDropdownPicker.mjs → StylePanelDoubleDropdownPicker.mjs} +20 -19
  128. package/dist-esm/lib/ui/components/StylePanel/StylePanelDoubleDropdownPicker.mjs.map +7 -0
  129. package/dist-esm/lib/ui/components/StylePanel/{DropdownPicker.mjs → StylePanelDropdownPicker.mjs} +21 -18
  130. package/dist-esm/lib/ui/components/StylePanel/StylePanelDropdownPicker.mjs.map +7 -0
  131. package/dist-esm/lib/ui/components/StylePanel/StylePanelSubheading.mjs +8 -0
  132. package/dist-esm/lib/ui/components/StylePanel/StylePanelSubheading.mjs.map +7 -0
  133. package/dist-esm/lib/ui/components/Toolbar/AltTextEditor.mjs +3 -2
  134. package/dist-esm/lib/ui/components/Toolbar/AltTextEditor.mjs.map +2 -2
  135. package/dist-esm/lib/ui/components/Toolbar/DefaultImageToolbarContent.mjs +38 -9
  136. package/dist-esm/lib/ui/components/Toolbar/DefaultImageToolbarContent.mjs.map +2 -2
  137. package/dist-esm/lib/ui/components/Toolbar/DefaultVideoToolbarContent.mjs +15 -3
  138. package/dist-esm/lib/ui/components/Toolbar/DefaultVideoToolbarContent.mjs.map +2 -2
  139. package/dist-esm/lib/ui/components/Toolbar/LinkEditor.mjs +3 -3
  140. package/dist-esm/lib/ui/components/Toolbar/LinkEditor.mjs.map +2 -2
  141. package/dist-esm/lib/ui/components/primitives/TldrawUiContextualToolbar.mjs +10 -1
  142. package/dist-esm/lib/ui/components/primitives/TldrawUiContextualToolbar.mjs.map +2 -2
  143. package/dist-esm/lib/ui/components/primitives/TldrawUiSlider.mjs +17 -4
  144. package/dist-esm/lib/ui/components/primitives/TldrawUiSlider.mjs.map +2 -2
  145. package/dist-esm/lib/ui/components/primitives/TldrawUiToolbar.mjs +2 -0
  146. package/dist-esm/lib/ui/components/primitives/TldrawUiToolbar.mjs.map +2 -2
  147. package/dist-esm/lib/ui/components/primitives/TldrawUiTooltip.mjs +37 -36
  148. package/dist-esm/lib/ui/components/primitives/TldrawUiTooltip.mjs.map +2 -2
  149. package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuItem.mjs +2 -1
  150. package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuItem.mjs.map +2 -2
  151. package/dist-esm/lib/ui/context/actions.mjs +23 -10
  152. package/dist-esm/lib/ui/context/actions.mjs.map +2 -2
  153. package/dist-esm/lib/ui/context/components.mjs +2 -0
  154. package/dist-esm/lib/ui/context/components.mjs.map +2 -2
  155. package/dist-esm/lib/ui/context/events.mjs.map +1 -1
  156. package/dist-esm/lib/ui/hooks/useExportAs.mjs +3 -2
  157. package/dist-esm/lib/ui/hooks/useExportAs.mjs.map +2 -2
  158. package/dist-esm/lib/ui/hooks/useTools.mjs +1 -1
  159. package/dist-esm/lib/ui/hooks/useTools.mjs.map +2 -2
  160. package/dist-esm/lib/ui/hooks/useTranslation/defaultTranslation.mjs +2 -0
  161. package/dist-esm/lib/ui/hooks/useTranslation/defaultTranslation.mjs.map +2 -2
  162. package/dist-esm/lib/ui/kbd-utils.mjs +9 -3
  163. package/dist-esm/lib/ui/kbd-utils.mjs.map +2 -2
  164. package/dist-esm/lib/ui/version.mjs +3 -3
  165. package/dist-esm/lib/ui/version.mjs.map +1 -1
  166. package/dist-esm/lib/utils/export/copyAs.mjs +1 -2
  167. package/dist-esm/lib/utils/export/copyAs.mjs.map +2 -2
  168. package/dist-esm/lib/utils/export/export.mjs +0 -20
  169. package/dist-esm/lib/utils/export/export.mjs.map +2 -2
  170. package/dist-esm/lib/utils/export/exportAs.mjs +1 -2
  171. package/dist-esm/lib/utils/export/exportAs.mjs.map +2 -2
  172. package/package.json +11 -34
  173. package/src/index.ts +44 -22
  174. package/src/lib/Tldraw.tsx +15 -2
  175. package/src/lib/defaultExternalContentHandlers.ts +12 -4
  176. package/src/lib/shapes/arrow/ArrowShapeOptions.test.ts +2 -1
  177. package/src/lib/shapes/arrow/ArrowShapeTool.test.ts +4 -3
  178. package/src/lib/shapes/arrow/ArrowShapeUtil.test.ts +7 -6
  179. package/src/lib/shapes/arrow/arrowLabel.ts +8 -0
  180. package/src/lib/shapes/draw/DrawShapeTool.test.ts +0 -5
  181. package/src/lib/shapes/frame/FrameShapeUtil.tsx +8 -0
  182. package/src/lib/shapes/image/ImageShapeUtil.tsx +3 -0
  183. package/src/lib/shapes/line/LineShapeUtil.test.tsx +4 -3
  184. package/src/lib/shapes/line/__snapshots__/LineShapeUtil.test.tsx.snap +2 -2
  185. package/src/lib/shapes/shared/PlainTextLabel.tsx +0 -6
  186. package/src/lib/shapes/shared/freehand/svg.ts +2 -0
  187. package/src/lib/shapes/shared/useEditablePlainText.ts +0 -6
  188. package/src/lib/shapes/shared/useImageOrVideoAsset.ts +0 -7
  189. package/src/lib/shapes/text/TextShapeTool.test.ts +6 -5
  190. package/src/lib/tools/EraserTool/childStates/Erasing.ts +34 -1
  191. package/src/lib/tools/EraserTool/childStates/Pointing.ts +20 -0
  192. package/src/lib/ui/TldrawUi.tsx +16 -10
  193. package/src/lib/ui/assetUrls.ts +13 -10
  194. package/src/lib/ui/components/{FollowingIndicator.tsx → DefaultFollowingIndicator.tsx} +2 -1
  195. package/src/lib/ui/components/KeyboardShortcutsDialog/DefaultKeyboardShortcutsDialogContent.tsx +6 -6
  196. package/src/lib/ui/components/StylePanel/DefaultStylePanel.tsx +27 -13
  197. package/src/lib/ui/components/StylePanel/DefaultStylePanelContent.tsx +260 -381
  198. package/src/lib/ui/components/{primitives/TldrawUiButtonPicker.tsx → StylePanel/StylePanelButtonPicker.tsx} +63 -50
  199. package/src/lib/ui/components/StylePanel/StylePanelContext.tsx +63 -0
  200. package/src/lib/ui/components/StylePanel/{DoubleDropdownPicker.tsx → StylePanelDoubleDropdownPicker.tsx} +28 -19
  201. package/src/lib/ui/components/StylePanel/StylePanelDropdownPicker.tsx +119 -0
  202. package/src/lib/ui/components/StylePanel/StylePanelSubheading.tsx +9 -0
  203. package/src/lib/ui/components/Toolbar/AltTextEditor.tsx +4 -3
  204. package/src/lib/ui/components/Toolbar/DefaultImageToolbarContent.tsx +32 -15
  205. package/src/lib/ui/components/Toolbar/DefaultVideoToolbarContent.tsx +12 -4
  206. package/src/lib/ui/components/Toolbar/LinkEditor.tsx +5 -5
  207. package/src/lib/ui/components/primitives/TldrawUiContextualToolbar.tsx +6 -1
  208. package/src/lib/ui/components/primitives/TldrawUiSlider.tsx +50 -30
  209. package/src/lib/ui/components/primitives/TldrawUiToolbar.tsx +3 -0
  210. package/src/lib/ui/components/primitives/TldrawUiTooltip.tsx +29 -21
  211. package/src/lib/ui/components/primitives/menus/TldrawUiMenuItem.tsx +3 -2
  212. package/src/lib/ui/context/actions.tsx +23 -10
  213. package/src/lib/ui/context/components.tsx +3 -0
  214. package/src/lib/ui/context/events.tsx +1 -1
  215. package/src/lib/ui/hooks/useExportAs.ts +3 -2
  216. package/src/lib/ui/hooks/useTools.tsx +1 -1
  217. package/src/lib/ui/hooks/useTranslation/TLUiTranslationKey.ts +2 -0
  218. package/src/lib/ui/hooks/useTranslation/defaultTranslation.ts +2 -0
  219. package/src/lib/ui/kbd-utils.ts +10 -3
  220. package/src/lib/ui/version.ts +3 -3
  221. package/src/lib/ui.css +19 -2
  222. package/src/lib/utils/excalidraw/__snapshots__/putExcalidrawContent.test.tsx.snap +5 -5
  223. package/src/lib/utils/export/copyAs.ts +1 -24
  224. package/src/lib/utils/export/export.ts +0 -36
  225. package/src/lib/utils/export/exportAs.ts +1 -32
  226. package/src/lib/utils/tldr/__snapshots__/buildFromV1Document.test.ts.snap +4 -4
  227. package/src/test/A11y.test.tsx +3 -2
  228. package/src/test/ClickManager.test.ts +7 -6
  229. package/src/test/Editor.test.tsx +20 -19
  230. package/src/test/EraserTool.test.ts +184 -13
  231. package/src/test/HandTool.test.ts +10 -9
  232. package/src/test/HighlightShape.test.ts +2 -1
  233. package/src/test/SelectTool.test.ts +3 -2
  234. package/src/test/TLUserPreferences.test.ts +4 -3
  235. package/src/test/TestEditor.ts +13 -15
  236. package/src/test/TldrawEditor.test.tsx +11 -10
  237. package/src/test/ZoomTool.test.ts +7 -6
  238. package/src/test/__snapshots__/drawing.test.ts.snap +2 -2
  239. package/src/test/__snapshots__/groups.test.tsx.snap +6 -6
  240. package/src/test/__snapshots__/resizing.test.ts.snap +2 -2
  241. package/src/test/arrows-megabus.test.tsx +5 -4
  242. package/src/test/bindings.test.tsx +24 -37
  243. package/src/test/bookmark-shapes.test.ts +1 -8
  244. package/src/test/commands/__snapshots__/getSvgString.test.ts.snap +23 -7
  245. package/src/test/commands/__snapshots__/packShapes.test.ts.snap +8 -8
  246. package/src/test/commands/__snapshots__/zoomToFit.test.ts.snap +2 -2
  247. package/src/test/commands/alignShapes.test.tsx +25 -24
  248. package/src/test/commands/animationSpeed.test.ts +2 -1
  249. package/src/test/commands/centerOnPoint.test.ts +3 -2
  250. package/src/test/commands/clipboard.test.ts +3 -2
  251. package/src/test/commands/createShapes.test.ts +2 -1
  252. package/src/test/commands/deleteShapes.test.ts +2 -1
  253. package/src/test/commands/distributeShapes.test.tsx +11 -10
  254. package/src/test/commands/getSvgString.test.ts +2 -1
  255. package/src/test/commands/packShapes.test.ts +5 -4
  256. package/src/test/commands/resizeShape.test.ts +2 -1
  257. package/src/test/commands/rotateShapes.test.ts +7 -6
  258. package/src/test/commands/setCamera.test.ts +4 -3
  259. package/src/test/commands/setCurrentPage.test.ts +3 -2
  260. package/src/test/commands/stackShapes.test.ts +11 -10
  261. package/src/test/commands/stretch.test.tsx +13 -12
  262. package/src/test/createDeepLink.test.tsx +2 -1
  263. package/src/test/cropping.test.ts +3 -2
  264. package/src/test/custom-clipping.test.ts +436 -0
  265. package/src/test/drawing.test.ts +2 -1
  266. package/src/test/flipShapes.test.ts +4 -3
  267. package/src/test/frames.test.ts +25 -24
  268. package/src/test/getCulledShapes.test.tsx +3 -2
  269. package/src/test/groups.test.tsx +1 -1
  270. package/src/test/handleDeepLink.test.tsx +2 -1
  271. package/src/test/maxShapes.test.ts +3 -2
  272. package/src/test/modifiers.test.ts +5 -4
  273. package/src/test/navigation.test.ts +12 -11
  274. package/src/test/panning.test.ts +2 -1
  275. package/src/test/perf/perf.test.ts +2 -1
  276. package/src/test/registerDeepLinkListener.test.tsx +10 -9
  277. package/src/test/resizing.test.ts +39 -38
  278. package/src/test/select.test.tsx +4 -3
  279. package/src/test/selection-omnibus.test.ts +11 -10
  280. package/src/test/shapeutils.test.ts +4 -3
  281. package/src/test/translating.test.ts +9 -8
  282. package/tldraw.css +27 -2
  283. package/dist-cjs/lib/ui/components/FollowingIndicator.js.map +0 -7
  284. package/dist-cjs/lib/ui/components/StylePanel/DoubleDropdownPicker.js.map +0 -7
  285. package/dist-cjs/lib/ui/components/StylePanel/DropdownPicker.js.map +0 -7
  286. package/dist-cjs/lib/ui/components/primitives/TldrawUiButtonPicker.js.map +0 -7
  287. package/dist-esm/lib/ui/components/FollowingIndicator.mjs.map +0 -7
  288. package/dist-esm/lib/ui/components/StylePanel/DoubleDropdownPicker.mjs.map +0 -7
  289. package/dist-esm/lib/ui/components/StylePanel/DropdownPicker.mjs.map +0 -7
  290. package/dist-esm/lib/ui/components/primitives/TldrawUiButtonPicker.mjs.map +0 -7
  291. package/src/lib/ui/components/StylePanel/DropdownPicker.tsx +0 -110
@@ -13,312 +13,275 @@ import {
13
13
  DefaultVerticalAlignStyle,
14
14
  GeoShapeGeoStyle,
15
15
  LineShapeSplineStyle,
16
- getDefaultColorTheme,
17
16
  kickoutOccludedShapes,
18
17
  minBy,
19
18
  useEditor,
20
- useIsDarkMode,
21
19
  useValue
22
20
  } from "@tldraw/editor";
23
- import React, { useCallback } from "react";
21
+ import React from "react";
24
22
  import { STYLES } from "../../../styles.mjs";
25
23
  import { useUiEvents } from "../../context/events.mjs";
26
24
  import { useTranslation } from "../../hooks/useTranslation/useTranslation.mjs";
27
25
  import { TldrawUiButtonIcon } from "../primitives/Button/TldrawUiButtonIcon.mjs";
28
- import { TldrawUiButtonPicker } from "../primitives/TldrawUiButtonPicker.mjs";
29
26
  import { TldrawUiSlider } from "../primitives/TldrawUiSlider.mjs";
30
27
  import { TldrawUiToolbar, TldrawUiToolbarButton } from "../primitives/TldrawUiToolbar.mjs";
31
- import { DoubleDropdownPicker } from "./DoubleDropdownPicker.mjs";
32
- import { DropdownPicker } from "./DropdownPicker.mjs";
33
- function StylePanelSubheading({ children }) {
34
- return /* @__PURE__ */ jsx("h3", { className: "tlui-style-panel__subheading", children });
35
- }
36
- function DefaultStylePanelContent({ styles }) {
37
- const isDarkMode = useIsDarkMode();
38
- if (!styles) return null;
39
- const geo = styles.get(GeoShapeGeoStyle);
40
- const arrowheadEnd = styles.get(ArrowShapeArrowheadEndStyle);
41
- const arrowheadStart = styles.get(ArrowShapeArrowheadStartStyle);
42
- const arrowKind = styles.get(ArrowShapeKindStyle);
43
- const spline = styles.get(LineShapeSplineStyle);
44
- const font = styles.get(DefaultFontStyle);
45
- const hideGeo = geo === void 0;
46
- const hideArrowHeads = arrowheadEnd === void 0 && arrowheadStart === void 0;
47
- const hideSpline = spline === void 0;
48
- const hideArrowKind = arrowKind === void 0;
49
- const hideText = font === void 0;
50
- const theme = getDefaultColorTheme({ isDarkMode });
28
+ import { StylePanelButtonPicker } from "./StylePanelButtonPicker.mjs";
29
+ import { useStylePanelContext } from "./StylePanelContext.mjs";
30
+ import { StylePanelDoubleDropdownPicker } from "./StylePanelDoubleDropdownPicker.mjs";
31
+ import { StylePanelDropdownPicker } from "./StylePanelDropdownPicker.mjs";
32
+ import { StylePanelSubheading } from "./StylePanelSubheading.mjs";
33
+ function DefaultStylePanelContent() {
51
34
  return /* @__PURE__ */ jsxs(Fragment, { children: [
52
- /* @__PURE__ */ jsx(CommonStylePickerSet, { theme, styles }),
53
- !hideText && /* @__PURE__ */ jsx(TextStylePickerSet, { theme, styles }),
54
- !(hideGeo && hideArrowHeads && hideSpline && hideArrowKind) && /* @__PURE__ */ jsxs("div", { className: "tlui-style-panel__section", children: [
55
- /* @__PURE__ */ jsx(GeoStylePickerSet, { styles }),
56
- /* @__PURE__ */ jsx(ArrowStylePickerSet, { styles }),
57
- /* @__PURE__ */ jsx(ArrowheadStylePickerSet, { styles }),
58
- /* @__PURE__ */ jsx(SplineStylePickerSet, { styles })
35
+ /* @__PURE__ */ jsxs(StylePanelSection, { children: [
36
+ /* @__PURE__ */ jsx(StylePanelColorPicker, {}),
37
+ /* @__PURE__ */ jsx(StylePanelOpacityPicker, {})
38
+ ] }),
39
+ /* @__PURE__ */ jsxs(StylePanelSection, { children: [
40
+ /* @__PURE__ */ jsx(StylePanelFillPicker, {}),
41
+ /* @__PURE__ */ jsx(StylePanelDashPicker, {}),
42
+ /* @__PURE__ */ jsx(StylePanelSizePicker, {})
43
+ ] }),
44
+ /* @__PURE__ */ jsxs(StylePanelSection, { children: [
45
+ /* @__PURE__ */ jsx(StylePanelFontPicker, {}),
46
+ /* @__PURE__ */ jsx(StylePanelTextAlignPicker, {}),
47
+ /* @__PURE__ */ jsx(StylePanelLabelAlignPicker, {})
48
+ ] }),
49
+ /* @__PURE__ */ jsxs(StylePanelSection, { children: [
50
+ /* @__PURE__ */ jsx(StylePanelGeoShapePicker, {}),
51
+ /* @__PURE__ */ jsx(StylePanelArrowKindPicker, {}),
52
+ /* @__PURE__ */ jsx(StylePanelArrowheadPicker, {}),
53
+ /* @__PURE__ */ jsx(StylePanelSplinePicker, {})
59
54
  ] })
60
55
  ] });
61
56
  }
62
- function useStyleChangeCallback() {
57
+ function StylePanelSection({ children }) {
58
+ return /* @__PURE__ */ jsx("div", { className: "tlui-style-panel__section", children });
59
+ }
60
+ function StylePanelColorPicker() {
61
+ const { styles } = useStylePanelContext();
62
+ const msg = useTranslation();
63
+ const color = styles.get(DefaultColorStyle);
64
+ if (color === void 0) return null;
65
+ return /* @__PURE__ */ jsx(
66
+ StylePanelButtonPicker,
67
+ {
68
+ title: msg("style-panel.color"),
69
+ uiType: "color",
70
+ style: DefaultColorStyle,
71
+ items: STYLES.color,
72
+ value: color
73
+ }
74
+ );
75
+ }
76
+ const tldrawSupportedOpacities = [0.1, 0.25, 0.5, 0.75, 1];
77
+ function StylePanelOpacityPicker() {
63
78
  const editor = useEditor();
79
+ const { onHistoryMark, showUiLabels } = useStylePanelContext();
80
+ const opacity = useValue("opacity", () => editor.getSharedOpacity(), [editor]);
64
81
  const trackEvent = useUiEvents();
65
- return React.useMemo(
66
- () => (function handleStyleChange(style, value) {
82
+ const msg = useTranslation();
83
+ const handleOpacityValueChange = React.useCallback(
84
+ (value) => {
85
+ const item = tldrawSupportedOpacities[value];
67
86
  editor.run(() => {
68
87
  if (editor.isIn("select")) {
69
- editor.setStyleForSelectedShapes(style, value);
88
+ editor.setOpacityForSelectedShapes(item);
70
89
  }
71
- editor.setStyleForNextShapes(style, value);
90
+ editor.setOpacityForNextShapes(item);
72
91
  editor.updateInstanceState({ isChangingStyle: true });
73
92
  });
74
- trackEvent("set-style", { source: "style-panel", id: style.id, value });
75
- }),
93
+ trackEvent("set-style", { source: "style-panel", id: "opacity", value });
94
+ },
76
95
  [editor, trackEvent]
77
96
  );
97
+ if (opacity === void 0) return null;
98
+ const opacityIndex = opacity.type === "mixed" ? -1 : tldrawSupportedOpacities.indexOf(
99
+ minBy(
100
+ tldrawSupportedOpacities,
101
+ (supportedOpacity) => Math.abs(supportedOpacity - opacity.value)
102
+ )
103
+ );
104
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
105
+ showUiLabels && /* @__PURE__ */ jsx(StylePanelSubheading, { children: msg("style-panel.opacity") }),
106
+ /* @__PURE__ */ jsx(
107
+ TldrawUiSlider,
108
+ {
109
+ "data-testid": "style.opacity",
110
+ value: opacityIndex >= 0 ? opacityIndex : tldrawSupportedOpacities.length - 1,
111
+ label: opacity.type === "mixed" ? "style-panel.mixed" : `opacity-style.${opacity.value}`,
112
+ onValueChange: handleOpacityValueChange,
113
+ steps: tldrawSupportedOpacities.length - 1,
114
+ title: msg("style-panel.opacity"),
115
+ onHistoryMark,
116
+ ariaValueModifier: 25
117
+ }
118
+ )
119
+ ] });
78
120
  }
79
- function CommonStylePickerSet({ styles, theme }) {
121
+ function StylePanelFillPicker() {
122
+ const { styles } = useStylePanelContext();
80
123
  const msg = useTranslation();
81
- const editor = useEditor();
82
- const onHistoryMark = useCallback((id) => editor.markHistoryStoppingPoint(id), [editor]);
83
- const showUiLabels = useValue("showUiLabels", () => editor.user.getShowUiLabels(), [editor]);
84
- const handleValueChange = useStyleChangeCallback();
85
- const color = styles.get(DefaultColorStyle);
86
124
  const fill = styles.get(DefaultFillStyle);
125
+ if (fill === void 0) return null;
126
+ return /* @__PURE__ */ jsx(
127
+ StylePanelButtonPicker,
128
+ {
129
+ title: msg("style-panel.fill"),
130
+ uiType: "fill",
131
+ style: DefaultFillStyle,
132
+ items: STYLES.fill,
133
+ value: fill
134
+ }
135
+ );
136
+ }
137
+ function StylePanelDashPicker() {
138
+ const { styles } = useStylePanelContext();
139
+ const msg = useTranslation();
87
140
  const dash = styles.get(DefaultDashStyle);
141
+ if (dash === void 0) return null;
142
+ return /* @__PURE__ */ jsx(
143
+ StylePanelButtonPicker,
144
+ {
145
+ title: msg("style-panel.dash"),
146
+ uiType: "dash",
147
+ style: DefaultDashStyle,
148
+ items: STYLES.dash,
149
+ value: dash
150
+ }
151
+ );
152
+ }
153
+ function StylePanelSizePicker() {
154
+ const editor = useEditor();
155
+ const { styles, onValueChange } = useStylePanelContext();
156
+ const msg = useTranslation();
88
157
  const size = styles.get(DefaultSizeStyle);
89
- const showPickers = fill !== void 0 || dash !== void 0 || size !== void 0;
90
- return /* @__PURE__ */ jsxs(Fragment, { children: [
91
- /* @__PURE__ */ jsxs("div", { className: "tlui-style-panel__section__common", "data-testid": "style.panel", children: [
92
- color === void 0 ? null : /* @__PURE__ */ jsxs(Fragment, { children: [
93
- showUiLabels && /* @__PURE__ */ jsx(StylePanelSubheading, { children: msg("style-panel.color") }),
94
- /* @__PURE__ */ jsx(TldrawUiToolbar, { orientation: "horizontal", label: msg("style-panel.color"), children: /* @__PURE__ */ jsx(
95
- TldrawUiButtonPicker,
96
- {
97
- title: msg("style-panel.color"),
98
- uiType: "color",
99
- style: DefaultColorStyle,
100
- items: STYLES.color,
101
- value: color,
102
- onValueChange: handleValueChange,
103
- theme,
104
- onHistoryMark
105
- }
106
- ) })
107
- ] }),
108
- /* @__PURE__ */ jsx(OpacitySlider, {})
109
- ] }),
110
- showPickers && /* @__PURE__ */ jsxs("div", { className: "tlui-style-panel__section", children: [
111
- fill === void 0 ? null : /* @__PURE__ */ jsxs(Fragment, { children: [
112
- showUiLabels && /* @__PURE__ */ jsx(StylePanelSubheading, { children: msg("style-panel.fill") }),
113
- /* @__PURE__ */ jsx(TldrawUiToolbar, { orientation: "horizontal", label: msg("style-panel.fill"), children: /* @__PURE__ */ jsx(
114
- TldrawUiButtonPicker,
115
- {
116
- title: msg("style-panel.fill"),
117
- uiType: "fill",
118
- style: DefaultFillStyle,
119
- items: STYLES.fill,
120
- value: fill,
121
- onValueChange: handleValueChange,
122
- theme,
123
- onHistoryMark
124
- }
125
- ) })
126
- ] }),
127
- dash === void 0 ? null : /* @__PURE__ */ jsxs(Fragment, { children: [
128
- showUiLabels && /* @__PURE__ */ jsx(StylePanelSubheading, { children: msg("style-panel.dash") }),
129
- /* @__PURE__ */ jsx(TldrawUiToolbar, { orientation: "horizontal", label: msg("style-panel.dash"), children: /* @__PURE__ */ jsx(
130
- TldrawUiButtonPicker,
131
- {
132
- title: msg("style-panel.dash"),
133
- uiType: "dash",
134
- style: DefaultDashStyle,
135
- items: STYLES.dash,
136
- value: dash,
137
- onValueChange: handleValueChange,
138
- theme,
139
- onHistoryMark
140
- }
141
- ) })
142
- ] }),
143
- size === void 0 ? null : /* @__PURE__ */ jsxs(Fragment, { children: [
144
- showUiLabels && /* @__PURE__ */ jsx(StylePanelSubheading, { children: msg("style-panel.size") }),
145
- /* @__PURE__ */ jsx(TldrawUiToolbar, { orientation: "horizontal", label: msg("style-panel.size"), children: /* @__PURE__ */ jsx(
146
- TldrawUiButtonPicker,
147
- {
148
- title: msg("style-panel.size"),
149
- uiType: "size",
150
- style: DefaultSizeStyle,
151
- items: STYLES.size,
152
- value: size,
153
- onValueChange: (style, value) => {
154
- handleValueChange(style, value);
155
- const selectedShapeIds = editor.getSelectedShapeIds();
156
- if (selectedShapeIds.length > 0) {
157
- kickoutOccludedShapes(editor, selectedShapeIds);
158
- }
159
- },
160
- theme,
161
- onHistoryMark
162
- }
163
- ) })
164
- ] })
165
- ] })
166
- ] });
158
+ if (size === void 0) return null;
159
+ return /* @__PURE__ */ jsx(
160
+ StylePanelButtonPicker,
161
+ {
162
+ title: msg("style-panel.size"),
163
+ uiType: "size",
164
+ style: DefaultSizeStyle,
165
+ items: STYLES.size,
166
+ value: size,
167
+ onValueChange: (style, value) => {
168
+ onValueChange(style, value);
169
+ const selectedShapeIds = editor.getSelectedShapeIds();
170
+ if (selectedShapeIds.length > 0) {
171
+ kickoutOccludedShapes(editor, selectedShapeIds);
172
+ }
173
+ }
174
+ }
175
+ );
167
176
  }
168
- function TextStylePickerSet({ theme, styles }) {
177
+ function StylePanelFontPicker() {
178
+ const { styles } = useStylePanelContext();
169
179
  const msg = useTranslation();
170
- const handleValueChange = useStyleChangeCallback();
171
- const editor = useEditor();
172
- const onHistoryMark = useCallback((id) => editor.markHistoryStoppingPoint(id), [editor]);
173
- const showUiLabels = useValue("showUiLabels", () => editor.user.getShowUiLabels(), [editor]);
174
- const labelStr = showUiLabels && msg("style-panel.font");
175
180
  const font = styles.get(DefaultFontStyle);
181
+ if (font === void 0) return null;
182
+ return /* @__PURE__ */ jsx(
183
+ StylePanelButtonPicker,
184
+ {
185
+ title: msg("style-panel.font"),
186
+ uiType: "font",
187
+ style: DefaultFontStyle,
188
+ items: STYLES.font,
189
+ value: font
190
+ }
191
+ );
192
+ }
193
+ function StylePanelTextAlignPicker() {
194
+ const { styles } = useStylePanelContext();
195
+ const msg = useTranslation();
176
196
  const textAlign = styles.get(DefaultTextAlignStyle);
197
+ if (textAlign === void 0) return null;
198
+ return /* @__PURE__ */ jsxs(TldrawUiToolbar, { orientation: "horizontal", label: msg("style-panel.align"), children: [
199
+ /* @__PURE__ */ jsx(
200
+ StylePanelButtonPicker,
201
+ {
202
+ title: msg("style-panel.align"),
203
+ uiType: "align",
204
+ style: DefaultTextAlignStyle,
205
+ items: STYLES.textAlign,
206
+ value: textAlign
207
+ }
208
+ ),
209
+ /* @__PURE__ */ jsx(
210
+ TldrawUiToolbarButton,
211
+ {
212
+ type: "icon",
213
+ title: msg("style-panel.vertical-align"),
214
+ "data-testid": "vertical-align",
215
+ disabled: true,
216
+ children: /* @__PURE__ */ jsx(TldrawUiButtonIcon, { icon: "vertical-align-middle" })
217
+ }
218
+ )
219
+ ] });
220
+ }
221
+ function StylePanelLabelAlignPicker() {
222
+ const { styles } = useStylePanelContext();
223
+ const msg = useTranslation();
177
224
  const labelAlign = styles.get(DefaultHorizontalAlignStyle);
178
225
  const verticalLabelAlign = styles.get(DefaultVerticalAlignStyle);
179
- if (font === void 0 && labelAlign === void 0) {
180
- return null;
181
- }
182
- return /* @__PURE__ */ jsxs("div", { className: "tlui-style-panel__section", children: [
183
- font === void 0 ? null : /* @__PURE__ */ jsxs(Fragment, { children: [
184
- labelStr && /* @__PURE__ */ jsx(StylePanelSubheading, { children: labelStr }),
185
- /* @__PURE__ */ jsx(TldrawUiToolbar, { orientation: "horizontal", label: msg("style-panel.font"), children: /* @__PURE__ */ jsx(
186
- TldrawUiButtonPicker,
187
- {
188
- title: msg("style-panel.font"),
189
- uiType: "font",
190
- style: DefaultFontStyle,
191
- items: STYLES.font,
192
- value: font,
193
- onValueChange: handleValueChange,
194
- theme,
195
- onHistoryMark
196
- }
197
- ) })
198
- ] }),
199
- textAlign === void 0 ? null : /* @__PURE__ */ jsxs(Fragment, { children: [
200
- showUiLabels && /* @__PURE__ */ jsx(StylePanelSubheading, { children: msg("style-panel.align") }),
201
- /* @__PURE__ */ jsxs(TldrawUiToolbar, { orientation: "horizontal", label: msg("style-panel.align"), children: [
202
- /* @__PURE__ */ jsx(
203
- TldrawUiButtonPicker,
204
- {
205
- title: msg("style-panel.align"),
206
- uiType: "align",
207
- style: DefaultTextAlignStyle,
208
- items: STYLES.textAlign,
209
- value: textAlign,
210
- onValueChange: handleValueChange,
211
- theme,
212
- onHistoryMark
213
- }
214
- ),
215
- /* @__PURE__ */ jsx(
216
- TldrawUiToolbarButton,
217
- {
218
- type: "icon",
219
- title: msg("style-panel.vertical-align"),
220
- "data-testid": "vertical-align",
221
- disabled: true,
222
- children: /* @__PURE__ */ jsx(TldrawUiButtonIcon, { icon: "vertical-align-middle" })
223
- }
224
- )
225
- ] })
226
- ] }),
227
- labelAlign === void 0 ? null : /* @__PURE__ */ jsxs(Fragment, { children: [
228
- showUiLabels && /* @__PURE__ */ jsx(StylePanelSubheading, { children: msg("style-panel.label-align") }),
229
- /* @__PURE__ */ jsxs(TldrawUiToolbar, { orientation: "horizontal", label: msg("style-panel.label-align"), children: [
230
- /* @__PURE__ */ jsx(
231
- TldrawUiButtonPicker,
232
- {
233
- title: msg("style-panel.label-align"),
234
- uiType: "align",
235
- style: DefaultHorizontalAlignStyle,
236
- items: STYLES.horizontalAlign,
237
- value: labelAlign,
238
- onValueChange: handleValueChange,
239
- theme,
240
- onHistoryMark
241
- }
242
- ),
243
- verticalLabelAlign === void 0 ? /* @__PURE__ */ jsx(
244
- TldrawUiToolbarButton,
245
- {
246
- type: "icon",
247
- title: msg("style-panel.vertical-align"),
248
- "data-testid": "vertical-align",
249
- disabled: true,
250
- children: /* @__PURE__ */ jsx(TldrawUiButtonIcon, { icon: "vertical-align-middle" })
251
- }
252
- ) : /* @__PURE__ */ jsx(
253
- DropdownPicker,
254
- {
255
- type: "icon",
256
- id: "geo-vertical-alignment",
257
- uiType: "verticalAlign",
258
- stylePanelType: "vertical-align",
259
- style: DefaultVerticalAlignStyle,
260
- items: STYLES.verticalAlign,
261
- value: verticalLabelAlign,
262
- onValueChange: handleValueChange
263
- }
264
- )
265
- ] })
266
- ] })
226
+ if (labelAlign === void 0) return null;
227
+ return /* @__PURE__ */ jsxs(TldrawUiToolbar, { orientation: "horizontal", label: msg("style-panel.label-align"), children: [
228
+ /* @__PURE__ */ jsx(
229
+ StylePanelButtonPicker,
230
+ {
231
+ title: msg("style-panel.label-align"),
232
+ uiType: "align",
233
+ style: DefaultHorizontalAlignStyle,
234
+ items: STYLES.horizontalAlign,
235
+ value: labelAlign
236
+ }
237
+ ),
238
+ verticalLabelAlign === void 0 ? /* @__PURE__ */ jsx(
239
+ TldrawUiToolbarButton,
240
+ {
241
+ type: "icon",
242
+ title: msg("style-panel.vertical-align"),
243
+ "data-testid": "vertical-align",
244
+ disabled: true,
245
+ children: /* @__PURE__ */ jsx(TldrawUiButtonIcon, { icon: "vertical-align-middle" })
246
+ }
247
+ ) : /* @__PURE__ */ jsx(
248
+ StylePanelDropdownPicker,
249
+ {
250
+ type: "icon",
251
+ id: "geo-vertical-alignment",
252
+ uiType: "verticalAlign",
253
+ stylePanelType: "vertical-align",
254
+ style: DefaultVerticalAlignStyle,
255
+ items: STYLES.verticalAlign,
256
+ value: verticalLabelAlign
257
+ }
258
+ )
267
259
  ] });
268
260
  }
269
- function GeoStylePickerSet({ styles }) {
270
- const msg = useTranslation();
271
- const handleValueChange = useStyleChangeCallback();
261
+ function StylePanelGeoShapePicker() {
262
+ const { styles } = useStylePanelContext();
272
263
  const geo = styles.get(GeoShapeGeoStyle);
273
- if (geo === void 0) {
274
- return null;
275
- }
276
- return /* @__PURE__ */ jsx(TldrawUiToolbar, { orientation: "horizontal", label: msg("style-panel.geo"), children: /* @__PURE__ */ jsx(
277
- DropdownPicker,
264
+ if (geo === void 0) return null;
265
+ return /* @__PURE__ */ jsx(
266
+ StylePanelDropdownPicker,
278
267
  {
279
- id: "geo",
280
- type: "menu",
281
268
  label: "style-panel.geo",
269
+ type: "menu",
270
+ id: "geo",
282
271
  uiType: "geo",
283
272
  stylePanelType: "geo",
284
273
  style: GeoShapeGeoStyle,
285
274
  items: STYLES.geo,
286
- value: geo,
287
- onValueChange: handleValueChange
275
+ value: geo
288
276
  }
289
- ) });
290
- }
291
- function SplineStylePickerSet({ styles }) {
292
- const msg = useTranslation();
293
- const handleValueChange = useStyleChangeCallback();
294
- const spline = styles.get(LineShapeSplineStyle);
295
- if (spline === void 0) {
296
- return null;
297
- }
298
- return /* @__PURE__ */ jsx(TldrawUiToolbar, { orientation: "horizontal", label: msg("style-panel.spline"), children: /* @__PURE__ */ jsx(
299
- DropdownPicker,
300
- {
301
- id: "spline",
302
- type: "menu",
303
- label: "style-panel.spline",
304
- uiType: "spline",
305
- stylePanelType: "spline",
306
- style: LineShapeSplineStyle,
307
- items: STYLES.spline,
308
- value: spline,
309
- onValueChange: handleValueChange
310
- }
311
- ) });
277
+ );
312
278
  }
313
- function ArrowStylePickerSet({ styles }) {
314
- const msg = useTranslation();
315
- const handleValueChange = useStyleChangeCallback();
279
+ function StylePanelArrowKindPicker() {
280
+ const { styles } = useStylePanelContext();
316
281
  const arrowKind = styles.get(ArrowShapeKindStyle);
317
- if (arrowKind === void 0) {
318
- return null;
319
- }
320
- return /* @__PURE__ */ jsx(TldrawUiToolbar, { orientation: "horizontal", label: msg("style-panel.arrow-kind"), children: /* @__PURE__ */ jsx(
321
- DropdownPicker,
282
+ if (arrowKind === void 0) return null;
283
+ return /* @__PURE__ */ jsx(
284
+ StylePanelDropdownPicker,
322
285
  {
323
286
  id: "arrow-kind",
324
287
  type: "menu",
@@ -327,20 +290,17 @@ function ArrowStylePickerSet({ styles }) {
327
290
  stylePanelType: "arrow-kind",
328
291
  style: ArrowShapeKindStyle,
329
292
  items: STYLES.arrowKind,
330
- value: arrowKind,
331
- onValueChange: handleValueChange
293
+ value: arrowKind
332
294
  }
333
- ) });
295
+ );
334
296
  }
335
- function ArrowheadStylePickerSet({ styles }) {
336
- const handleValueChange = useStyleChangeCallback();
297
+ function StylePanelArrowheadPicker() {
298
+ const { styles } = useStylePanelContext();
337
299
  const arrowheadEnd = styles.get(ArrowShapeArrowheadEndStyle);
338
300
  const arrowheadStart = styles.get(ArrowShapeArrowheadStartStyle);
339
- if (!arrowheadEnd || !arrowheadStart) {
340
- return null;
341
- }
301
+ if (arrowheadEnd === void 0 || arrowheadStart === void 0) return null;
342
302
  return /* @__PURE__ */ jsx(
343
- DoubleDropdownPicker,
303
+ StylePanelDoubleDropdownPicker,
344
304
  {
345
305
  label: "style-panel.arrowheads",
346
306
  uiTypeA: "arrowheadStart",
@@ -351,66 +311,43 @@ function ArrowheadStylePickerSet({ styles }) {
351
311
  styleB: ArrowShapeArrowheadEndStyle,
352
312
  itemsB: STYLES.arrowheadEnd,
353
313
  valueB: arrowheadEnd,
354
- onValueChange: handleValueChange,
355
314
  labelA: "style-panel.arrowhead-start",
356
315
  labelB: "style-panel.arrowhead-end"
357
316
  }
358
317
  );
359
318
  }
360
- const tldrawSupportedOpacities = [0.1, 0.25, 0.5, 0.75, 1];
361
- function OpacitySlider() {
362
- const editor = useEditor();
363
- const onHistoryMark = useCallback((id) => editor.markHistoryStoppingPoint(id), [editor]);
364
- const showUiLabels = useValue("showUiLabels", () => editor.user.getShowUiLabels(), [editor]);
365
- const opacity = useValue("opacity", () => editor.getSharedOpacity(), [editor]);
366
- const trackEvent = useUiEvents();
367
- const msg = useTranslation();
368
- const handleOpacityValueChange = React.useCallback(
369
- (value) => {
370
- const item = tldrawSupportedOpacities[value];
371
- editor.run(() => {
372
- if (editor.isIn("select")) {
373
- editor.setOpacityForSelectedShapes(item);
374
- }
375
- editor.setOpacityForNextShapes(item);
376
- editor.updateInstanceState({ isChangingStyle: true });
377
- });
378
- trackEvent("set-style", { source: "style-panel", id: "opacity", value });
379
- },
380
- [editor, trackEvent]
381
- );
382
- if (opacity === void 0) return null;
383
- const opacityIndex = opacity.type === "mixed" ? -1 : tldrawSupportedOpacities.indexOf(
384
- minBy(
385
- tldrawSupportedOpacities,
386
- (supportedOpacity) => Math.abs(supportedOpacity - opacity.value)
387
- )
319
+ function StylePanelSplinePicker() {
320
+ const { styles } = useStylePanelContext();
321
+ const spline = styles.get(LineShapeSplineStyle);
322
+ if (spline === void 0) return null;
323
+ return /* @__PURE__ */ jsx(
324
+ StylePanelDropdownPicker,
325
+ {
326
+ type: "menu",
327
+ id: "spline",
328
+ uiType: "spline",
329
+ stylePanelType: "spline",
330
+ label: "style-panel.spline",
331
+ style: LineShapeSplineStyle,
332
+ items: STYLES.spline,
333
+ value: spline
334
+ }
388
335
  );
389
- return /* @__PURE__ */ jsxs(Fragment, { children: [
390
- showUiLabels && /* @__PURE__ */ jsx(StylePanelSubheading, { children: msg("style-panel.opacity") }),
391
- /* @__PURE__ */ jsx(
392
- TldrawUiSlider,
393
- {
394
- "data-testid": "style.opacity",
395
- value: opacityIndex >= 0 ? opacityIndex : tldrawSupportedOpacities.length - 1,
396
- label: opacity.type === "mixed" ? "style-panel.mixed" : `opacity-style.${opacity.value}`,
397
- onValueChange: handleOpacityValueChange,
398
- steps: tldrawSupportedOpacities.length - 1,
399
- title: msg("style-panel.opacity"),
400
- onHistoryMark,
401
- ariaValueModifier: 25
402
- }
403
- )
404
- ] });
405
336
  }
406
337
  export {
407
- ArrowStylePickerSet,
408
- ArrowheadStylePickerSet,
409
- CommonStylePickerSet,
410
338
  DefaultStylePanelContent,
411
- GeoStylePickerSet,
412
- OpacitySlider,
413
- SplineStylePickerSet,
414
- TextStylePickerSet
339
+ StylePanelArrowKindPicker,
340
+ StylePanelArrowheadPicker,
341
+ StylePanelColorPicker,
342
+ StylePanelDashPicker,
343
+ StylePanelFillPicker,
344
+ StylePanelFontPicker,
345
+ StylePanelGeoShapePicker,
346
+ StylePanelLabelAlignPicker,
347
+ StylePanelOpacityPicker,
348
+ StylePanelSection,
349
+ StylePanelSizePicker,
350
+ StylePanelSplinePicker,
351
+ StylePanelTextAlignPicker
415
352
  };
416
353
  //# sourceMappingURL=DefaultStylePanelContent.mjs.map