tldraw 3.16.0-internal.51e99e128bd4 → 3.16.0-internal.a478398270c6

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 (517) hide show
  1. package/dist-cjs/index.d.ts +23 -297
  2. package/dist-cjs/index.js +2 -30
  3. package/dist-cjs/index.js.map +2 -2
  4. package/dist-cjs/lib/TldrawImage.js +2 -5
  5. package/dist-cjs/lib/TldrawImage.js.map +3 -3
  6. package/dist-cjs/lib/canvas/TldrawCropHandles.js +1 -1
  7. package/dist-cjs/lib/canvas/TldrawCropHandles.js.map +2 -2
  8. package/dist-cjs/lib/canvas/TldrawHandles.js +1 -1
  9. package/dist-cjs/lib/canvas/TldrawHandles.js.map +2 -2
  10. package/dist-cjs/lib/canvas/TldrawOverlays.js +1 -1
  11. package/dist-cjs/lib/canvas/TldrawOverlays.js.map +2 -2
  12. package/dist-cjs/lib/canvas/TldrawScribble.js +1 -1
  13. package/dist-cjs/lib/canvas/TldrawScribble.js.map +2 -2
  14. package/dist-cjs/lib/canvas/TldrawSelectionForeground.js +271 -279
  15. package/dist-cjs/lib/canvas/TldrawSelectionForeground.js.map +2 -2
  16. package/dist-cjs/lib/defaultExternalContentHandlers.js +0 -1
  17. package/dist-cjs/lib/defaultExternalContentHandlers.js.map +2 -2
  18. package/dist-cjs/lib/shapes/arrow/ArrowShapeUtil.js +44 -27
  19. package/dist-cjs/lib/shapes/arrow/ArrowShapeUtil.js.map +2 -2
  20. package/dist-cjs/lib/shapes/arrow/arrowLabel.js +4 -16
  21. package/dist-cjs/lib/shapes/arrow/arrowLabel.js.map +2 -2
  22. package/dist-cjs/lib/shapes/arrow/arrowTargetState.js +1 -1
  23. package/dist-cjs/lib/shapes/arrow/arrowTargetState.js.map +2 -2
  24. package/dist-cjs/lib/shapes/arrow/elbow/ElbowArrowDebug.js +3 -3
  25. package/dist-cjs/lib/shapes/arrow/elbow/ElbowArrowDebug.js.map +1 -1
  26. package/dist-cjs/lib/shapes/arrow/toolStates/Pointing.js +0 -3
  27. package/dist-cjs/lib/shapes/arrow/toolStates/Pointing.js.map +2 -2
  28. package/dist-cjs/lib/shapes/draw/DrawShapeUtil.js +6 -3
  29. package/dist-cjs/lib/shapes/draw/DrawShapeUtil.js.map +2 -2
  30. package/dist-cjs/lib/shapes/embed/EmbedShapeUtil.js +1 -1
  31. package/dist-cjs/lib/shapes/embed/EmbedShapeUtil.js.map +1 -1
  32. package/dist-cjs/lib/shapes/frame/FrameShapeUtil.js +17 -17
  33. package/dist-cjs/lib/shapes/frame/FrameShapeUtil.js.map +2 -2
  34. package/dist-cjs/lib/shapes/frame/components/FrameHeading.js +1 -1
  35. package/dist-cjs/lib/shapes/frame/components/FrameHeading.js.map +2 -2
  36. package/dist-cjs/lib/shapes/geo/GeoShapeUtil.js +2 -2
  37. package/dist-cjs/lib/shapes/geo/GeoShapeUtil.js.map +2 -2
  38. package/dist-cjs/lib/shapes/geo/components/GeoShapeBody.js +1 -2
  39. package/dist-cjs/lib/shapes/geo/components/GeoShapeBody.js.map +2 -2
  40. package/dist-cjs/lib/shapes/highlight/HighlightShapeUtil.js +4 -5
  41. package/dist-cjs/lib/shapes/highlight/HighlightShapeUtil.js.map +2 -2
  42. package/dist-cjs/lib/shapes/image/ImageShapeUtil.js +3 -3
  43. package/dist-cjs/lib/shapes/image/ImageShapeUtil.js.map +1 -1
  44. package/dist-cjs/lib/shapes/line/LineShapeUtil.js +5 -20
  45. package/dist-cjs/lib/shapes/line/LineShapeUtil.js.map +2 -2
  46. package/dist-cjs/lib/shapes/note/NoteShapeUtil.js +5 -6
  47. package/dist-cjs/lib/shapes/note/NoteShapeUtil.js.map +2 -2
  48. package/dist-cjs/lib/shapes/shared/PathBuilder.js +3 -21
  49. package/dist-cjs/lib/shapes/shared/PathBuilder.js.map +2 -2
  50. package/dist-cjs/lib/shapes/shared/PlainTextLabel.js +0 -1
  51. package/dist-cjs/lib/shapes/shared/PlainTextLabel.js.map +2 -2
  52. package/dist-cjs/lib/shapes/shared/RichTextLabel.js +2 -5
  53. package/dist-cjs/lib/shapes/shared/RichTextLabel.js.map +2 -2
  54. package/dist-cjs/lib/shapes/shared/ShapeFill.js +4 -4
  55. package/dist-cjs/lib/shapes/shared/ShapeFill.js.map +2 -2
  56. package/dist-cjs/lib/shapes/shared/SvgTextLabel.js +3 -4
  57. package/dist-cjs/lib/shapes/shared/SvgTextLabel.js.map +2 -2
  58. package/dist-cjs/lib/shapes/shared/freehand/svg.js.map +2 -2
  59. package/dist-cjs/lib/shapes/shared/usePrefersReducedMotion.js +1 -10
  60. package/dist-cjs/lib/shapes/shared/usePrefersReducedMotion.js.map +2 -2
  61. package/dist-cjs/lib/shapes/text/TextShapeUtil.js +13 -7
  62. package/dist-cjs/lib/shapes/text/TextShapeUtil.js.map +2 -2
  63. package/dist-cjs/lib/shapes/video/VideoShapeUtil.js +3 -3
  64. package/dist-cjs/lib/shapes/video/VideoShapeUtil.js.map +1 -1
  65. package/dist-cjs/lib/styles.js.map +2 -2
  66. package/dist-cjs/lib/tools/EraserTool/childStates/Erasing.js +1 -25
  67. package/dist-cjs/lib/tools/EraserTool/childStates/Erasing.js.map +2 -2
  68. package/dist-cjs/lib/tools/EraserTool/childStates/Pointing.js +0 -12
  69. package/dist-cjs/lib/tools/EraserTool/childStates/Pointing.js.map +2 -2
  70. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.js +1 -7
  71. package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.js.map +2 -2
  72. package/dist-cjs/lib/tools/SelectTool/childStates/DraggingHandle.js +22 -43
  73. package/dist-cjs/lib/tools/SelectTool/childStates/DraggingHandle.js.map +2 -2
  74. package/dist-cjs/lib/tools/SelectTool/childStates/Idle.js +15 -2
  75. package/dist-cjs/lib/tools/SelectTool/childStates/Idle.js.map +2 -2
  76. package/dist-cjs/lib/tools/SelectTool/childStates/PointingShape.js +0 -5
  77. package/dist-cjs/lib/tools/SelectTool/childStates/PointingShape.js.map +2 -2
  78. package/dist-cjs/lib/tools/SelectTool/childStates/Resizing.js +0 -8
  79. package/dist-cjs/lib/tools/SelectTool/childStates/Resizing.js.map +2 -2
  80. package/dist-cjs/lib/tools/SelectTool/childStates/Rotating.js +0 -8
  81. package/dist-cjs/lib/tools/SelectTool/childStates/Rotating.js.map +2 -2
  82. package/dist-cjs/lib/tools/SelectTool/childStates/Translating.js +0 -8
  83. package/dist-cjs/lib/tools/SelectTool/childStates/Translating.js.map +2 -2
  84. package/dist-cjs/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.js.map +2 -2
  85. package/dist-cjs/lib/ui/TldrawUi.js +0 -14
  86. package/dist-cjs/lib/ui/TldrawUi.js.map +3 -3
  87. package/dist-cjs/lib/ui/components/A11y.js +12 -14
  88. package/dist-cjs/lib/ui/components/A11y.js.map +2 -2
  89. package/dist-cjs/lib/ui/components/ActionsMenu/DefaultActionsMenu.js +3 -12
  90. package/dist-cjs/lib/ui/components/ActionsMenu/DefaultActionsMenu.js.map +2 -2
  91. package/dist-cjs/lib/ui/components/DefaultMenuPanel.js +2 -3
  92. package/dist-cjs/lib/ui/components/DefaultMenuPanel.js.map +2 -2
  93. package/dist-cjs/lib/ui/components/KeyboardShortcutsDialog/DefaultKeyboardShortcutsDialogContent.js +1 -51
  94. package/dist-cjs/lib/ui/components/KeyboardShortcutsDialog/DefaultKeyboardShortcutsDialogContent.js.map +2 -2
  95. package/dist-cjs/lib/ui/components/MainMenu/DefaultMainMenuContent.js +2 -3
  96. package/dist-cjs/lib/ui/components/MainMenu/DefaultMainMenuContent.js.map +2 -2
  97. package/dist-cjs/lib/ui/components/Minimap/MinimapManager.js +4 -4
  98. package/dist-cjs/lib/ui/components/Minimap/MinimapManager.js.map +2 -2
  99. package/dist-cjs/lib/ui/components/MobileStylePanel.js +3 -5
  100. package/dist-cjs/lib/ui/components/MobileStylePanel.js.map +2 -2
  101. package/dist-cjs/lib/ui/components/NavigationPanel/DefaultNavigationPanel.js +5 -4
  102. package/dist-cjs/lib/ui/components/NavigationPanel/DefaultNavigationPanel.js.map +2 -2
  103. package/dist-cjs/lib/ui/components/PageMenu/DefaultPageMenu.js +1 -2
  104. package/dist-cjs/lib/ui/components/PageMenu/DefaultPageMenu.js.map +2 -2
  105. package/dist-cjs/lib/ui/components/SharePanel/PeopleMenuItem.js +2 -3
  106. package/dist-cjs/lib/ui/components/SharePanel/PeopleMenuItem.js.map +2 -2
  107. package/dist-cjs/lib/ui/components/SharePanel/UserPresenceColorPicker.js +2 -2
  108. package/dist-cjs/lib/ui/components/SharePanel/UserPresenceColorPicker.js.map +2 -2
  109. package/dist-cjs/lib/ui/components/Spinner.js +25 -2
  110. package/dist-cjs/lib/ui/components/Spinner.js.map +2 -2
  111. package/dist-cjs/lib/ui/components/StylePanel/DefaultStylePanel.js +0 -2
  112. package/dist-cjs/lib/ui/components/StylePanel/DefaultStylePanel.js.map +2 -2
  113. package/dist-cjs/lib/ui/components/StylePanel/DefaultStylePanelContent.js +139 -171
  114. package/dist-cjs/lib/ui/components/StylePanel/DefaultStylePanelContent.js.map +2 -2
  115. package/dist-cjs/lib/ui/components/StylePanel/DoubleDropdownPicker.js +3 -3
  116. package/dist-cjs/lib/ui/components/StylePanel/DoubleDropdownPicker.js.map +2 -2
  117. package/dist-cjs/lib/ui/components/StylePanel/DropdownPicker.js +25 -26
  118. package/dist-cjs/lib/ui/components/StylePanel/DropdownPicker.js.map +3 -3
  119. package/dist-cjs/lib/ui/components/Toolbar/DefaultImageToolbar.js +7 -21
  120. package/dist-cjs/lib/ui/components/Toolbar/DefaultImageToolbar.js.map +3 -3
  121. package/dist-cjs/lib/ui/components/Toolbar/DefaultImageToolbarContent.js +1 -1
  122. package/dist-cjs/lib/ui/components/Toolbar/DefaultImageToolbarContent.js.map +2 -2
  123. package/dist-cjs/lib/ui/components/Toolbar/DefaultToolbar.js +21 -66
  124. package/dist-cjs/lib/ui/components/Toolbar/DefaultToolbar.js.map +3 -3
  125. package/dist-cjs/lib/ui/components/Toolbar/OverflowingToolbar.js +80 -189
  126. package/dist-cjs/lib/ui/components/Toolbar/OverflowingToolbar.js.map +3 -3
  127. package/dist-cjs/lib/ui/components/Toolbar/ToggleToolLockedButton.js +4 -5
  128. package/dist-cjs/lib/ui/components/Toolbar/ToggleToolLockedButton.js.map +2 -2
  129. package/dist-cjs/lib/ui/components/menu-items.js +0 -22
  130. package/dist-cjs/lib/ui/components/menu-items.js.map +2 -2
  131. package/dist-cjs/lib/ui/components/primitives/Button/TldrawUiButtonIcon.js.map +2 -2
  132. package/dist-cjs/lib/ui/components/primitives/TldrawUiButtonPicker.js +16 -7
  133. package/dist-cjs/lib/ui/components/primitives/TldrawUiButtonPicker.js.map +3 -3
  134. package/dist-cjs/lib/ui/components/primitives/TldrawUiContextualToolbar.js +1 -1
  135. package/dist-cjs/lib/ui/components/primitives/TldrawUiContextualToolbar.js.map +2 -2
  136. package/dist-cjs/lib/ui/components/primitives/TldrawUiDialog.js +1 -1
  137. package/dist-cjs/lib/ui/components/primitives/TldrawUiDialog.js.map +2 -2
  138. package/dist-cjs/lib/ui/components/primitives/TldrawUiIcon.js +1 -35
  139. package/dist-cjs/lib/ui/components/primitives/TldrawUiIcon.js.map +2 -2
  140. package/dist-cjs/lib/ui/components/primitives/TldrawUiPopover.js +2 -3
  141. package/dist-cjs/lib/ui/components/primitives/TldrawUiPopover.js.map +3 -3
  142. package/dist-cjs/lib/ui/components/primitives/TldrawUiSlider.js +2 -6
  143. package/dist-cjs/lib/ui/components/primitives/TldrawUiSlider.js.map +2 -2
  144. package/dist-cjs/lib/ui/components/primitives/TldrawUiToolbar.js +7 -31
  145. package/dist-cjs/lib/ui/components/primitives/TldrawUiToolbar.js.map +2 -2
  146. package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuCheckboxItem.js.map +2 -2
  147. package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuContext.js.map +2 -2
  148. package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuGroup.js +12 -25
  149. package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuGroup.js.map +2 -2
  150. package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuItem.js +22 -154
  151. package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuItem.js.map +2 -2
  152. package/dist-cjs/lib/ui/context/TldrawUiContextProvider.js +2 -3
  153. package/dist-cjs/lib/ui/context/TldrawUiContextProvider.js.map +2 -2
  154. package/dist-cjs/lib/ui/context/actions.js +8 -57
  155. package/dist-cjs/lib/ui/context/actions.js.map +2 -2
  156. package/dist-cjs/lib/ui/context/events.js.map +2 -2
  157. package/dist-cjs/lib/ui/hooks/menu-hooks.js.map +2 -2
  158. package/dist-cjs/lib/ui/hooks/useKeyboardShortcuts.js +2 -2
  159. package/dist-cjs/lib/ui/hooks/useKeyboardShortcuts.js.map +2 -2
  160. package/dist-cjs/lib/ui/hooks/useTools.js +9 -94
  161. package/dist-cjs/lib/ui/hooks/useTools.js.map +2 -2
  162. package/dist-cjs/lib/ui/hooks/useTranslation/TLUiTranslationKey.js.map +1 -1
  163. package/dist-cjs/lib/ui/hooks/useTranslation/defaultTranslation.js +0 -11
  164. package/dist-cjs/lib/ui/hooks/useTranslation/defaultTranslation.js.map +2 -2
  165. package/dist-cjs/lib/ui/kbd-utils.js +1 -2
  166. package/dist-cjs/lib/ui/kbd-utils.js.map +2 -2
  167. package/dist-cjs/lib/ui/version.js +3 -3
  168. package/dist-cjs/lib/ui/version.js.map +1 -1
  169. package/dist-cjs/lib/utils/excalidraw/putExcalidrawContent.js +1 -1
  170. package/dist-cjs/lib/utils/excalidraw/putExcalidrawContent.js.map +2 -2
  171. package/dist-cjs/lib/utils/tldr/buildFromV1Document.js +2 -3
  172. package/dist-cjs/lib/utils/tldr/buildFromV1Document.js.map +2 -2
  173. package/dist-esm/index.d.mts +23 -297
  174. package/dist-esm/index.mjs +4 -51
  175. package/dist-esm/index.mjs.map +2 -2
  176. package/dist-esm/lib/TldrawImage.mjs +2 -5
  177. package/dist-esm/lib/TldrawImage.mjs.map +2 -2
  178. package/dist-esm/lib/canvas/TldrawCropHandles.mjs +1 -1
  179. package/dist-esm/lib/canvas/TldrawCropHandles.mjs.map +2 -2
  180. package/dist-esm/lib/canvas/TldrawHandles.mjs +1 -1
  181. package/dist-esm/lib/canvas/TldrawHandles.mjs.map +2 -2
  182. package/dist-esm/lib/canvas/TldrawOverlays.mjs +1 -1
  183. package/dist-esm/lib/canvas/TldrawOverlays.mjs.map +2 -2
  184. package/dist-esm/lib/canvas/TldrawScribble.mjs +1 -1
  185. package/dist-esm/lib/canvas/TldrawScribble.mjs.map +2 -2
  186. package/dist-esm/lib/canvas/TldrawSelectionForeground.mjs +271 -279
  187. package/dist-esm/lib/canvas/TldrawSelectionForeground.mjs.map +2 -2
  188. package/dist-esm/lib/defaultExternalContentHandlers.mjs +0 -1
  189. package/dist-esm/lib/defaultExternalContentHandlers.mjs.map +2 -2
  190. package/dist-esm/lib/shapes/arrow/ArrowShapeUtil.mjs +44 -30
  191. package/dist-esm/lib/shapes/arrow/ArrowShapeUtil.mjs.map +2 -2
  192. package/dist-esm/lib/shapes/arrow/arrowLabel.mjs +5 -19
  193. package/dist-esm/lib/shapes/arrow/arrowLabel.mjs.map +2 -2
  194. package/dist-esm/lib/shapes/arrow/arrowTargetState.mjs +1 -1
  195. package/dist-esm/lib/shapes/arrow/arrowTargetState.mjs.map +2 -2
  196. package/dist-esm/lib/shapes/arrow/elbow/ElbowArrowDebug.mjs +3 -3
  197. package/dist-esm/lib/shapes/arrow/elbow/ElbowArrowDebug.mjs.map +1 -1
  198. package/dist-esm/lib/shapes/arrow/toolStates/Pointing.mjs +0 -3
  199. package/dist-esm/lib/shapes/arrow/toolStates/Pointing.mjs.map +2 -2
  200. package/dist-esm/lib/shapes/draw/DrawShapeUtil.mjs +6 -4
  201. package/dist-esm/lib/shapes/draw/DrawShapeUtil.mjs.map +2 -2
  202. package/dist-esm/lib/shapes/embed/EmbedShapeUtil.mjs +1 -1
  203. package/dist-esm/lib/shapes/embed/EmbedShapeUtil.mjs.map +1 -1
  204. package/dist-esm/lib/shapes/frame/FrameShapeUtil.mjs +17 -18
  205. package/dist-esm/lib/shapes/frame/FrameShapeUtil.mjs.map +2 -2
  206. package/dist-esm/lib/shapes/frame/components/FrameHeading.mjs +1 -1
  207. package/dist-esm/lib/shapes/frame/components/FrameHeading.mjs.map +2 -2
  208. package/dist-esm/lib/shapes/geo/GeoShapeUtil.mjs +2 -3
  209. package/dist-esm/lib/shapes/geo/GeoShapeUtil.mjs.map +2 -2
  210. package/dist-esm/lib/shapes/geo/components/GeoShapeBody.mjs +1 -2
  211. package/dist-esm/lib/shapes/geo/components/GeoShapeBody.mjs.map +2 -2
  212. package/dist-esm/lib/shapes/highlight/HighlightShapeUtil.mjs +4 -6
  213. package/dist-esm/lib/shapes/highlight/HighlightShapeUtil.mjs.map +2 -2
  214. package/dist-esm/lib/shapes/image/ImageShapeUtil.mjs +3 -3
  215. package/dist-esm/lib/shapes/image/ImageShapeUtil.mjs.map +1 -1
  216. package/dist-esm/lib/shapes/line/LineShapeUtil.mjs +5 -21
  217. package/dist-esm/lib/shapes/line/LineShapeUtil.mjs.map +2 -2
  218. package/dist-esm/lib/shapes/note/NoteShapeUtil.mjs +5 -7
  219. package/dist-esm/lib/shapes/note/NoteShapeUtil.mjs.map +2 -2
  220. package/dist-esm/lib/shapes/shared/PathBuilder.mjs +3 -22
  221. package/dist-esm/lib/shapes/shared/PathBuilder.mjs.map +2 -2
  222. package/dist-esm/lib/shapes/shared/PlainTextLabel.mjs +0 -1
  223. package/dist-esm/lib/shapes/shared/PlainTextLabel.mjs.map +2 -2
  224. package/dist-esm/lib/shapes/shared/RichTextLabel.mjs +2 -5
  225. package/dist-esm/lib/shapes/shared/RichTextLabel.mjs.map +2 -2
  226. package/dist-esm/lib/shapes/shared/ShapeFill.mjs +4 -5
  227. package/dist-esm/lib/shapes/shared/ShapeFill.mjs.map +2 -2
  228. package/dist-esm/lib/shapes/shared/SvgTextLabel.mjs +3 -4
  229. package/dist-esm/lib/shapes/shared/SvgTextLabel.mjs.map +2 -2
  230. package/dist-esm/lib/shapes/shared/freehand/svg.mjs.map +2 -2
  231. package/dist-esm/lib/shapes/shared/usePrefersReducedMotion.mjs +1 -10
  232. package/dist-esm/lib/shapes/shared/usePrefersReducedMotion.mjs.map +2 -2
  233. package/dist-esm/lib/shapes/text/TextShapeUtil.mjs +13 -8
  234. package/dist-esm/lib/shapes/text/TextShapeUtil.mjs.map +2 -2
  235. package/dist-esm/lib/shapes/video/VideoShapeUtil.mjs +3 -3
  236. package/dist-esm/lib/shapes/video/VideoShapeUtil.mjs.map +1 -1
  237. package/dist-esm/lib/styles.mjs.map +2 -2
  238. package/dist-esm/lib/tools/EraserTool/childStates/Erasing.mjs +1 -26
  239. package/dist-esm/lib/tools/EraserTool/childStates/Erasing.mjs.map +2 -2
  240. package/dist-esm/lib/tools/EraserTool/childStates/Pointing.mjs +0 -13
  241. package/dist-esm/lib/tools/EraserTool/childStates/Pointing.mjs.map +2 -2
  242. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.mjs +1 -7
  243. package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.mjs.map +2 -2
  244. package/dist-esm/lib/tools/SelectTool/childStates/DraggingHandle.mjs +22 -43
  245. package/dist-esm/lib/tools/SelectTool/childStates/DraggingHandle.mjs.map +2 -2
  246. package/dist-esm/lib/tools/SelectTool/childStates/Idle.mjs +15 -2
  247. package/dist-esm/lib/tools/SelectTool/childStates/Idle.mjs.map +2 -2
  248. package/dist-esm/lib/tools/SelectTool/childStates/PointingShape.mjs +0 -5
  249. package/dist-esm/lib/tools/SelectTool/childStates/PointingShape.mjs.map +2 -2
  250. package/dist-esm/lib/tools/SelectTool/childStates/Resizing.mjs +0 -8
  251. package/dist-esm/lib/tools/SelectTool/childStates/Resizing.mjs.map +2 -2
  252. package/dist-esm/lib/tools/SelectTool/childStates/Rotating.mjs +0 -8
  253. package/dist-esm/lib/tools/SelectTool/childStates/Rotating.mjs.map +2 -2
  254. package/dist-esm/lib/tools/SelectTool/childStates/Translating.mjs +0 -8
  255. package/dist-esm/lib/tools/SelectTool/childStates/Translating.mjs.map +2 -2
  256. package/dist-esm/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.mjs.map +2 -2
  257. package/dist-esm/lib/ui/TldrawUi.mjs +2 -16
  258. package/dist-esm/lib/ui/TldrawUi.mjs.map +3 -3
  259. package/dist-esm/lib/ui/components/A11y.mjs +12 -14
  260. package/dist-esm/lib/ui/components/A11y.mjs.map +2 -2
  261. package/dist-esm/lib/ui/components/ActionsMenu/DefaultActionsMenu.mjs +3 -12
  262. package/dist-esm/lib/ui/components/ActionsMenu/DefaultActionsMenu.mjs.map +2 -2
  263. package/dist-esm/lib/ui/components/DefaultMenuPanel.mjs +2 -3
  264. package/dist-esm/lib/ui/components/DefaultMenuPanel.mjs.map +2 -2
  265. package/dist-esm/lib/ui/components/KeyboardShortcutsDialog/DefaultKeyboardShortcutsDialogContent.mjs +1 -51
  266. package/dist-esm/lib/ui/components/KeyboardShortcutsDialog/DefaultKeyboardShortcutsDialogContent.mjs.map +2 -2
  267. package/dist-esm/lib/ui/components/MainMenu/DefaultMainMenuContent.mjs +3 -3
  268. package/dist-esm/lib/ui/components/MainMenu/DefaultMainMenuContent.mjs.map +2 -2
  269. package/dist-esm/lib/ui/components/Minimap/MinimapManager.mjs +4 -4
  270. package/dist-esm/lib/ui/components/Minimap/MinimapManager.mjs.map +2 -2
  271. package/dist-esm/lib/ui/components/MobileStylePanel.mjs +3 -6
  272. package/dist-esm/lib/ui/components/MobileStylePanel.mjs.map +2 -2
  273. package/dist-esm/lib/ui/components/NavigationPanel/DefaultNavigationPanel.mjs +5 -4
  274. package/dist-esm/lib/ui/components/NavigationPanel/DefaultNavigationPanel.mjs.map +2 -2
  275. package/dist-esm/lib/ui/components/PageMenu/DefaultPageMenu.mjs +1 -2
  276. package/dist-esm/lib/ui/components/PageMenu/DefaultPageMenu.mjs.map +2 -2
  277. package/dist-esm/lib/ui/components/SharePanel/PeopleMenuItem.mjs +2 -3
  278. package/dist-esm/lib/ui/components/SharePanel/PeopleMenuItem.mjs.map +2 -2
  279. package/dist-esm/lib/ui/components/SharePanel/UserPresenceColorPicker.mjs +2 -2
  280. package/dist-esm/lib/ui/components/SharePanel/UserPresenceColorPicker.mjs.map +2 -2
  281. package/dist-esm/lib/ui/components/Spinner.mjs +26 -3
  282. package/dist-esm/lib/ui/components/Spinner.mjs.map +2 -2
  283. package/dist-esm/lib/ui/components/StylePanel/DefaultStylePanel.mjs +1 -3
  284. package/dist-esm/lib/ui/components/StylePanel/DefaultStylePanel.mjs.map +2 -2
  285. package/dist-esm/lib/ui/components/StylePanel/DefaultStylePanelContent.mjs +139 -171
  286. package/dist-esm/lib/ui/components/StylePanel/DefaultStylePanelContent.mjs.map +2 -2
  287. package/dist-esm/lib/ui/components/StylePanel/DoubleDropdownPicker.mjs +3 -3
  288. package/dist-esm/lib/ui/components/StylePanel/DoubleDropdownPicker.mjs.map +2 -2
  289. package/dist-esm/lib/ui/components/StylePanel/DropdownPicker.mjs +25 -26
  290. package/dist-esm/lib/ui/components/StylePanel/DropdownPicker.mjs.map +2 -2
  291. package/dist-esm/lib/ui/components/Toolbar/DefaultImageToolbar.mjs +9 -23
  292. package/dist-esm/lib/ui/components/Toolbar/DefaultImageToolbar.mjs.map +3 -3
  293. package/dist-esm/lib/ui/components/Toolbar/DefaultImageToolbarContent.mjs +1 -1
  294. package/dist-esm/lib/ui/components/Toolbar/DefaultImageToolbarContent.mjs.map +2 -2
  295. package/dist-esm/lib/ui/components/Toolbar/DefaultToolbar.mjs +21 -56
  296. package/dist-esm/lib/ui/components/Toolbar/DefaultToolbar.mjs.map +2 -2
  297. package/dist-esm/lib/ui/components/Toolbar/OverflowingToolbar.mjs +81 -192
  298. package/dist-esm/lib/ui/components/Toolbar/OverflowingToolbar.mjs.map +3 -3
  299. package/dist-esm/lib/ui/components/Toolbar/ToggleToolLockedButton.mjs +4 -5
  300. package/dist-esm/lib/ui/components/Toolbar/ToggleToolLockedButton.mjs.map +2 -2
  301. package/dist-esm/lib/ui/components/menu-items.mjs +0 -22
  302. package/dist-esm/lib/ui/components/menu-items.mjs.map +2 -2
  303. package/dist-esm/lib/ui/components/primitives/Button/TldrawUiButtonIcon.mjs.map +2 -2
  304. package/dist-esm/lib/ui/components/primitives/TldrawUiButtonPicker.mjs +6 -8
  305. package/dist-esm/lib/ui/components/primitives/TldrawUiButtonPicker.mjs.map +2 -2
  306. package/dist-esm/lib/ui/components/primitives/TldrawUiContextualToolbar.mjs +1 -1
  307. package/dist-esm/lib/ui/components/primitives/TldrawUiContextualToolbar.mjs.map +2 -2
  308. package/dist-esm/lib/ui/components/primitives/TldrawUiDialog.mjs +1 -1
  309. package/dist-esm/lib/ui/components/primitives/TldrawUiDialog.mjs.map +2 -2
  310. package/dist-esm/lib/ui/components/primitives/TldrawUiIcon.mjs +2 -36
  311. package/dist-esm/lib/ui/components/primitives/TldrawUiIcon.mjs.map +2 -2
  312. package/dist-esm/lib/ui/components/primitives/TldrawUiPopover.mjs +2 -3
  313. package/dist-esm/lib/ui/components/primitives/TldrawUiPopover.mjs.map +2 -2
  314. package/dist-esm/lib/ui/components/primitives/TldrawUiSlider.mjs +2 -6
  315. package/dist-esm/lib/ui/components/primitives/TldrawUiSlider.mjs.map +2 -2
  316. package/dist-esm/lib/ui/components/primitives/TldrawUiToolbar.mjs +7 -31
  317. package/dist-esm/lib/ui/components/primitives/TldrawUiToolbar.mjs.map +2 -2
  318. package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuCheckboxItem.mjs.map +2 -2
  319. package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuContext.mjs.map +2 -2
  320. package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuGroup.mjs +12 -25
  321. package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuGroup.mjs.map +2 -2
  322. package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuItem.mjs +24 -162
  323. package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuItem.mjs.map +2 -2
  324. package/dist-esm/lib/ui/context/TldrawUiContextProvider.mjs +2 -3
  325. package/dist-esm/lib/ui/context/TldrawUiContextProvider.mjs.map +2 -2
  326. package/dist-esm/lib/ui/context/actions.mjs +8 -57
  327. package/dist-esm/lib/ui/context/actions.mjs.map +2 -2
  328. package/dist-esm/lib/ui/context/events.mjs.map +2 -2
  329. package/dist-esm/lib/ui/hooks/menu-hooks.mjs.map +2 -2
  330. package/dist-esm/lib/ui/hooks/useKeyboardShortcuts.mjs +2 -2
  331. package/dist-esm/lib/ui/hooks/useKeyboardShortcuts.mjs.map +2 -2
  332. package/dist-esm/lib/ui/hooks/useTools.mjs +10 -102
  333. package/dist-esm/lib/ui/hooks/useTools.mjs.map +2 -2
  334. package/dist-esm/lib/ui/hooks/useTranslation/defaultTranslation.mjs +0 -11
  335. package/dist-esm/lib/ui/hooks/useTranslation/defaultTranslation.mjs.map +2 -2
  336. package/dist-esm/lib/ui/kbd-utils.mjs +1 -2
  337. package/dist-esm/lib/ui/kbd-utils.mjs.map +2 -2
  338. package/dist-esm/lib/ui/version.mjs +3 -3
  339. package/dist-esm/lib/ui/version.mjs.map +1 -1
  340. package/dist-esm/lib/utils/excalidraw/putExcalidrawContent.mjs +1 -1
  341. package/dist-esm/lib/utils/excalidraw/putExcalidrawContent.mjs.map +2 -2
  342. package/dist-esm/lib/utils/tldr/buildFromV1Document.mjs +2 -3
  343. package/dist-esm/lib/utils/tldr/buildFromV1Document.mjs.map +2 -2
  344. package/package.json +34 -12
  345. package/src/index.ts +2 -39
  346. package/src/lib/TldrawImage.tsx +2 -6
  347. package/src/lib/canvas/TldrawCropHandles.tsx +1 -3
  348. package/src/lib/canvas/TldrawHandles.tsx +1 -5
  349. package/src/lib/canvas/TldrawOverlays.tsx +1 -1
  350. package/src/lib/canvas/TldrawScribble.tsx +1 -1
  351. package/src/lib/canvas/TldrawSelectionForeground.tsx +1 -5
  352. package/src/lib/defaultExternalContentHandlers.ts +1 -2
  353. package/src/lib/shapes/arrow/ArrowShapeOptions.test.ts +1 -2
  354. package/src/lib/shapes/arrow/ArrowShapeTool.test.ts +3 -4
  355. package/src/lib/shapes/arrow/ArrowShapeUtil.test.ts +11 -12
  356. package/src/lib/shapes/arrow/ArrowShapeUtil.tsx +46 -30
  357. package/src/lib/shapes/arrow/arrowLabel.ts +3 -23
  358. package/src/lib/shapes/arrow/arrowTargetState.ts +1 -2
  359. package/src/lib/shapes/arrow/elbow/ElbowArrowDebug.tsx +3 -3
  360. package/src/lib/shapes/arrow/toolStates/Pointing.tsx +0 -3
  361. package/src/lib/shapes/draw/DrawShapeTool.test.ts +5 -0
  362. package/src/lib/shapes/draw/DrawShapeUtil.tsx +7 -4
  363. package/src/lib/shapes/embed/EmbedShapeUtil.tsx +1 -1
  364. package/src/lib/shapes/frame/FrameShapeUtil.tsx +21 -26
  365. package/src/lib/shapes/frame/components/FrameHeading.tsx +1 -1
  366. package/src/lib/shapes/geo/GeoShapeUtil.tsx +2 -3
  367. package/src/lib/shapes/geo/components/GeoShapeBody.tsx +2 -2
  368. package/src/lib/shapes/highlight/HighlightShapeUtil.tsx +4 -7
  369. package/src/lib/shapes/image/ImageShapeUtil.tsx +3 -3
  370. package/src/lib/shapes/line/LineShapeUtil.test.tsx +3 -4
  371. package/src/lib/shapes/line/LineShapeUtil.tsx +6 -25
  372. package/src/lib/shapes/line/__snapshots__/LineShapeUtil.test.tsx.snap +2 -2
  373. package/src/lib/shapes/note/NoteShapeUtil.tsx +4 -10
  374. package/src/lib/shapes/shared/PathBuilder.test.tsx +1 -1
  375. package/src/lib/shapes/shared/PathBuilder.tsx +1 -35
  376. package/src/lib/shapes/shared/PlainTextLabel.tsx +0 -1
  377. package/src/lib/shapes/shared/RichTextLabel.tsx +0 -4
  378. package/src/lib/shapes/shared/ShapeFill.tsx +4 -5
  379. package/src/lib/shapes/shared/SvgTextLabel.tsx +2 -4
  380. package/src/lib/shapes/shared/freehand/svg.ts +0 -2
  381. package/src/lib/shapes/shared/usePrefersReducedMotion.tsx +1 -11
  382. package/src/lib/shapes/text/TextShapeTool.test.ts +5 -6
  383. package/src/lib/shapes/text/TextShapeUtil.tsx +14 -8
  384. package/src/lib/shapes/video/VideoShapeUtil.tsx +3 -3
  385. package/src/lib/styles.tsx +1 -3
  386. package/src/lib/tools/EraserTool/childStates/Erasing.ts +1 -34
  387. package/src/lib/tools/EraserTool/childStates/Pointing.ts +0 -20
  388. package/src/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.ts +1 -8
  389. package/src/lib/tools/SelectTool/childStates/DraggingHandle.tsx +30 -54
  390. package/src/lib/tools/SelectTool/childStates/Idle.ts +24 -2
  391. package/src/lib/tools/SelectTool/childStates/PointingShape.ts +0 -7
  392. package/src/lib/tools/SelectTool/childStates/Resizing.ts +1 -12
  393. package/src/lib/tools/SelectTool/childStates/Rotating.ts +0 -11
  394. package/src/lib/tools/SelectTool/childStates/Translating.ts +1 -11
  395. package/src/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.ts +0 -1
  396. package/src/lib/ui/TldrawUi.tsx +2 -17
  397. package/src/lib/ui/components/A11y.tsx +13 -15
  398. package/src/lib/ui/components/ActionsMenu/DefaultActionsMenu.tsx +3 -15
  399. package/src/lib/ui/components/DefaultMenuPanel.tsx +3 -4
  400. package/src/lib/ui/components/KeyboardShortcutsDialog/DefaultKeyboardShortcutsDialogContent.tsx +0 -40
  401. package/src/lib/ui/components/MainMenu/DefaultMainMenuContent.tsx +2 -4
  402. package/src/lib/ui/components/Minimap/MinimapManager.ts +4 -4
  403. package/src/lib/ui/components/MobileStylePanel.tsx +6 -9
  404. package/src/lib/ui/components/NavigationPanel/DefaultNavigationPanel.tsx +5 -4
  405. package/src/lib/ui/components/PageMenu/DefaultPageMenu.tsx +2 -3
  406. package/src/lib/ui/components/SharePanel/PeopleMenuItem.tsx +3 -4
  407. package/src/lib/ui/components/SharePanel/UserPresenceColorPicker.tsx +3 -3
  408. package/src/lib/ui/components/Spinner.tsx +24 -2
  409. package/src/lib/ui/components/StylePanel/DefaultStylePanel.tsx +1 -3
  410. package/src/lib/ui/components/StylePanel/DefaultStylePanelContent.tsx +106 -146
  411. package/src/lib/ui/components/StylePanel/DoubleDropdownPicker.tsx +3 -3
  412. package/src/lib/ui/components/StylePanel/DropdownPicker.tsx +6 -7
  413. package/src/lib/ui/components/Toolbar/DefaultImageToolbar.tsx +9 -25
  414. package/src/lib/ui/components/Toolbar/DefaultImageToolbarContent.tsx +1 -1
  415. package/src/lib/ui/components/Toolbar/DefaultToolbar.tsx +23 -55
  416. package/src/lib/ui/components/Toolbar/OverflowingToolbar.tsx +61 -212
  417. package/src/lib/ui/components/Toolbar/ToggleToolLockedButton.tsx +12 -17
  418. package/src/lib/ui/components/menu-items.tsx +0 -25
  419. package/src/lib/ui/components/primitives/Button/TldrawUiButtonIcon.tsx +2 -2
  420. package/src/lib/ui/components/primitives/TldrawUiButtonPicker.tsx +35 -40
  421. package/src/lib/ui/components/primitives/TldrawUiContextualToolbar.tsx +1 -1
  422. package/src/lib/ui/components/primitives/TldrawUiDialog.tsx +1 -1
  423. package/src/lib/ui/components/primitives/TldrawUiIcon.tsx +3 -41
  424. package/src/lib/ui/components/primitives/TldrawUiPopover.tsx +2 -4
  425. package/src/lib/ui/components/primitives/TldrawUiSlider.tsx +1 -6
  426. package/src/lib/ui/components/primitives/TldrawUiToolbar.tsx +12 -56
  427. package/src/lib/ui/components/primitives/menus/TldrawUiMenuCheckboxItem.tsx +2 -2
  428. package/src/lib/ui/components/primitives/menus/TldrawUiMenuContext.tsx +1 -0
  429. package/src/lib/ui/components/primitives/menus/TldrawUiMenuGroup.tsx +16 -29
  430. package/src/lib/ui/components/primitives/menus/TldrawUiMenuItem.tsx +23 -224
  431. package/src/lib/ui/context/TldrawUiContextProvider.tsx +20 -23
  432. package/src/lib/ui/context/actions.tsx +9 -59
  433. package/src/lib/ui/context/events.tsx +2 -6
  434. package/src/lib/ui/hooks/menu-hooks.ts +0 -1
  435. package/src/lib/ui/hooks/useKeyboardShortcuts.ts +2 -3
  436. package/src/lib/ui/hooks/useTools.tsx +11 -142
  437. package/src/lib/ui/hooks/useTranslation/TLUiTranslationKey.ts +0 -11
  438. package/src/lib/ui/hooks/useTranslation/defaultTranslation.ts +0 -11
  439. package/src/lib/ui/kbd-utils.ts +1 -2
  440. package/src/lib/ui/version.ts +3 -3
  441. package/src/lib/ui.css +314 -414
  442. package/src/lib/utils/excalidraw/__snapshots__/putExcalidrawContent.test.tsx.snap +7 -21
  443. package/src/lib/utils/excalidraw/putExcalidrawContent.ts +1 -1
  444. package/src/lib/utils/tldr/__snapshots__/buildFromV1Document.test.ts.snap +7 -28
  445. package/src/lib/utils/tldr/buildFromV1Document.ts +1 -2
  446. package/src/test/A11y.test.tsx +2 -3
  447. package/src/test/ClickManager.test.ts +6 -7
  448. package/src/test/Editor.test.tsx +20 -21
  449. package/src/test/EraserTool.test.ts +13 -184
  450. package/src/test/HandTool.test.ts +9 -10
  451. package/src/test/HighlightShape.test.ts +1 -2
  452. package/src/test/SelectTool.test.ts +13 -40
  453. package/src/test/TLUserPreferences.test.ts +3 -4
  454. package/src/test/TestEditor.ts +15 -13
  455. package/src/test/TldrawEditor.test.tsx +10 -11
  456. package/src/test/ZoomTool.test.ts +6 -7
  457. package/src/test/__snapshots__/drawing.test.ts.snap +2 -2
  458. package/src/test/__snapshots__/groups.test.tsx.snap +6 -6
  459. package/src/test/__snapshots__/resizing.test.ts.snap +2 -2
  460. package/src/test/arrows-megabus.test.tsx +10 -17
  461. package/src/test/bindings.test.tsx +37 -24
  462. package/src/test/bookmark-shapes.test.ts +8 -1
  463. package/src/test/commands/__snapshots__/getSvgString.test.ts.snap +7 -23
  464. package/src/test/commands/__snapshots__/packShapes.test.ts.snap +8 -8
  465. package/src/test/commands/__snapshots__/zoomToFit.test.ts.snap +2 -2
  466. package/src/test/commands/alignShapes.test.tsx +24 -25
  467. package/src/test/commands/animationSpeed.test.ts +1 -2
  468. package/src/test/commands/centerOnPoint.test.ts +2 -3
  469. package/src/test/commands/clipboard.test.ts +2 -3
  470. package/src/test/commands/createShapes.test.ts +1 -2
  471. package/src/test/commands/deletePage.test.ts +1 -84
  472. package/src/test/commands/deleteShapes.test.ts +1 -2
  473. package/src/test/commands/distributeShapes.test.tsx +10 -11
  474. package/src/test/commands/getSvgString.test.ts +1 -2
  475. package/src/test/commands/packShapes.test.ts +4 -5
  476. package/src/test/commands/resizeShape.test.ts +1 -2
  477. package/src/test/commands/rotateShapes.test.ts +6 -7
  478. package/src/test/commands/setCamera.test.ts +3 -4
  479. package/src/test/commands/setCurrentPage.test.ts +2 -3
  480. package/src/test/commands/stackShapes.test.ts +10 -11
  481. package/src/test/commands/stretch.test.tsx +12 -13
  482. package/src/test/createDeepLink.test.tsx +1 -2
  483. package/src/test/cropping.test.ts +2 -3
  484. package/src/test/drawing.test.ts +1 -2
  485. package/src/test/flipShapes.test.ts +3 -4
  486. package/src/test/frames.test.ts +24 -25
  487. package/src/test/getCulledShapes.test.tsx +2 -3
  488. package/src/test/groups.test.tsx +2 -2
  489. package/src/test/handleDeepLink.test.tsx +1 -2
  490. package/src/test/maxShapes.test.ts +2 -3
  491. package/src/test/modifiers.test.ts +4 -5
  492. package/src/test/navigation.test.ts +9 -264
  493. package/src/test/panning.test.ts +1 -2
  494. package/src/test/perf/perf.test.ts +1 -2
  495. package/src/test/registerDeepLinkListener.test.tsx +9 -10
  496. package/src/test/resizing.test.ts +38 -39
  497. package/src/test/select.test.tsx +3 -4
  498. package/src/test/selection-omnibus.test.ts +10 -11
  499. package/src/test/shapeutils.test.ts +48 -398
  500. package/src/test/translating.test.ts +9 -10
  501. package/tldraw.css +627 -726
  502. package/dist-cjs/lib/ui/components/AccessibilityMenu.js +0 -35
  503. package/dist-cjs/lib/ui/components/AccessibilityMenu.js.map +0 -7
  504. package/dist-cjs/lib/ui/components/primitives/TldrawUiTooltip.js +0 -268
  505. package/dist-cjs/lib/ui/components/primitives/TldrawUiTooltip.js.map +0 -7
  506. package/dist-cjs/lib/ui/components/primitives/layout.js +0 -76
  507. package/dist-cjs/lib/ui/components/primitives/layout.js.map +0 -7
  508. package/dist-esm/lib/ui/components/AccessibilityMenu.mjs +0 -19
  509. package/dist-esm/lib/ui/components/AccessibilityMenu.mjs.map +0 -7
  510. package/dist-esm/lib/ui/components/primitives/TldrawUiTooltip.mjs +0 -245
  511. package/dist-esm/lib/ui/components/primitives/TldrawUiTooltip.mjs.map +0 -7
  512. package/dist-esm/lib/ui/components/primitives/layout.mjs +0 -46
  513. package/dist-esm/lib/ui/components/primitives/layout.mjs.map +0 -7
  514. package/src/lib/ui/components/AccessibilityMenu.tsx +0 -20
  515. package/src/lib/ui/components/primitives/TldrawUiTooltip.tsx +0 -327
  516. package/src/lib/ui/components/primitives/layout.tsx +0 -107
  517. package/src/test/inner-outer-margin.test.ts +0 -315
@@ -1,7 +1,5 @@
1
1
  import {
2
2
  activeElementShouldCaptureKeys,
3
- assert,
4
- modulate,
5
3
  preventDefault,
6
4
  tlmenus,
7
5
  useEditor,
@@ -9,7 +7,7 @@ import {
9
7
  useUniqueSafeId,
10
8
  } from '@tldraw/editor'
11
9
  import classNames from 'classnames'
12
- import { createContext, useEffect, useLayoutEffect, useRef, useState } from 'react'
10
+ import { createContext, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react'
13
11
  import { PORTRAIT_BREAKPOINT } from '../../constants'
14
12
  import { useBreakpoint } from '../../context/breakpoints'
15
13
  import { areShortcutsDisabled } from '../../hooks/useKeyboardShortcuts'
@@ -22,7 +20,6 @@ import {
22
20
  TldrawUiPopoverTrigger,
23
21
  } from '../primitives/TldrawUiPopover'
24
22
  import { TldrawUiToolbar, TldrawUiToolbarButton } from '../primitives/TldrawUiToolbar'
25
- import { TldrawUiColumn, TldrawUiRow } from '../primitives/layout'
26
23
  import { TldrawUiMenuContextProvider } from '../primitives/menus/TldrawUiMenuContext'
27
24
 
28
25
  export const IsInOverflowContext = createContext(false)
@@ -43,24 +40,10 @@ const NUMBERED_SHORTCUT_KEYS: Record<string, number> = {
43
40
  /** @public */
44
41
  export interface OverflowingToolbarProps {
45
42
  children: React.ReactNode
46
- orientation: 'horizontal' | 'vertical'
47
- sizingParentClassName: string
48
- minItems: number
49
- minSizePx: number
50
- maxItems: number
51
- maxSizePx: number
52
43
  }
53
44
 
54
45
  /** @public @react */
55
- export function OverflowingToolbar({
56
- children,
57
- orientation,
58
- sizingParentClassName,
59
- minItems,
60
- minSizePx,
61
- maxItems,
62
- maxSizePx,
63
- }: OverflowingToolbarProps) {
46
+ export function OverflowingToolbar({ children }: OverflowingToolbarProps) {
64
47
  const editor = useEditor()
65
48
  const id = useUniqueSafeId()
66
49
  const breakpoint = useBreakpoint()
@@ -68,165 +51,66 @@ export function OverflowingToolbar({
68
51
  const rButtons = useRef<HTMLElement[]>([])
69
52
  const [isOpen, setIsOpen] = useState(false)
70
53
 
71
- const mainToolsRef = useRef<HTMLDivElement>(null)
54
+ const overflowIndex = Math.min(8, 5 + breakpoint)
72
55
 
73
- // we have to use state instead of a ref here so that we get
74
- // an update when the overflow popover mounts / unmounts
75
- const [overflowTools, setOverflowTools] = useState<HTMLDivElement | null>(null)
56
+ const [totalItems, setTotalItems] = useState(0)
57
+ const mainToolsRef = useRef<HTMLDivElement>(null)
76
58
  const [lastActiveOverflowItem, setLastActiveOverflowItem] = useState<string | null>(null)
77
- const [shouldShowOverflow, setShouldShowOverflow] = useState(false)
59
+
60
+ const css = useMemo(() => {
61
+ const activeCss = lastActiveOverflowItem ? `:not([data-value="${lastActiveOverflowItem}"])` : ''
62
+
63
+ return `
64
+ #${id}_main > *:nth-child(n + ${overflowIndex + (lastActiveOverflowItem ? 1 : 2)})${activeCss} {
65
+ display: none;
66
+ }
67
+ #${id}_more > *:nth-child(-n + ${overflowIndex}) {
68
+ display: none;
69
+ }
70
+ #${id}_more > *:nth-child(-n + ${overflowIndex + 4}) {
71
+ margin-top: 0;
72
+ }
73
+ `
74
+ }, [lastActiveOverflowItem, id, overflowIndex])
78
75
 
79
76
  const onDomUpdate = useEvent(() => {
80
77
  if (!mainToolsRef.current) return
81
78
 
82
- // whenever we get an update, we need to re-calculate the number of items to show and update
83
- // the component accordingly.
84
- const sizeProp = orientation === 'horizontal' ? 'offsetWidth' : 'offsetHeight'
79
+ const children = Array.from(mainToolsRef.current.children)
80
+ setTotalItems(children.length)
85
81
 
86
- // toolbars can contain both single items and groups. we need to keep track of both.
87
- type Items = (
88
- | { type: 'item'; element: HTMLElement }
89
- | { type: 'group'; items: Items; element: HTMLElement }
90
- )[]
91
-
92
- // walk through the dom and collect items so we can calculate what to show/hide
93
- const mainItems = collectItems(mainToolsRef.current.children)
94
- const overflowItems = overflowTools ? collectItems(overflowTools.children) : null
95
- function collectItems(collection: HTMLCollection) {
96
- const items: Items = []
97
- for (const child of collection) {
98
- if (child.classList.contains('tlui-main-toolbar__group')) {
99
- items.push({
100
- type: 'group',
101
- items: collectItems(child.children),
102
- element: child as HTMLElement,
103
- })
104
- } else {
105
- items.push({ type: 'item', element: child as HTMLElement })
106
- }
107
- }
108
-
109
- return items
82
+ // If the last active overflow item is no longer in the overflow, clear it
83
+ const lastActiveElementIdx = children.findIndex(
84
+ (el) => el.getAttribute('data-value') === lastActiveOverflowItem
85
+ )
86
+ if (lastActiveElementIdx <= overflowIndex) {
87
+ setLastActiveOverflowItem(null)
110
88
  }
111
89
 
112
- // the number of items to show is based on the space available to the toolbar.
113
- const sizingParent = findParentWithClassName(mainToolsRef.current, sizingParentClassName)
114
- const size = sizingParent[sizeProp]
115
- const itemsToShow = Math.floor(
116
- modulate(size, [minSizePx, maxSizePx], [minItems, maxItems], true)
90
+ // But if there's a new active item...
91
+ const activeElementIdx = Array.from(mainToolsRef.current.children).findIndex(
92
+ (el) => el.getAttribute('aria-pressed') === 'true'
117
93
  )
94
+ if (activeElementIdx === -1) return
118
95
 
119
- // now we know how many items to show, we need to walk through the items we found and show /
120
- // hide them accordingly. We need to keep track of:
121
- // the number of item's we've shown in the main content so far
122
- let mainItemCount = 0
123
- // the item that is currently active in the overflow content (if any)
124
- let newActiveOverflowItem: string | null = null
125
- // whether the last active overflow item is actually still in the overflow content
126
- let shouldInvalidateLastActiveOverflowItem = false
127
- // the buttons visible in the main content
128
- const numberedButtons: HTMLButtonElement[] = []
129
- function visitItems(
130
- mainItems: Items,
131
- overflowItems: Items | null
132
- ): {
133
- // for each group of items we visit, we need to know whether we showed anything in
134
- // either section
135
- didShowAnyInMain: boolean
136
- didShowAnyInOverflow: boolean
137
- } {
138
- if (overflowItems) assert(mainItems.length === overflowItems.length)
139
-
140
- let didShowAnyInMain = false
141
- let didShowAnyInOverflow = false
142
-
143
- for (let i = 0; i < mainItems.length; i++) {
144
- const mainItem = mainItems[i]
145
- const overflowItem = overflowItems?.[i]
146
-
147
- if (mainItem.type === 'item') {
148
- const isLastActiveOverflowItem =
149
- mainItem.element.getAttribute('data-value') === lastActiveOverflowItem
150
-
151
- // for single items, we show them in main if we have space, or if they're the
152
- // last-used item from the overflow.
153
- let shouldShowInMain
154
- if (lastActiveOverflowItem) {
155
- shouldShowInMain = mainItemCount < itemsToShow || isLastActiveOverflowItem
156
- } else {
157
- // we use <= here because if there is no last active overflow item, we want
158
- // to show at least one item in the main toolbar.
159
- shouldShowInMain = mainItemCount <= itemsToShow
160
- }
161
- const shouldShowInOverflow = mainItemCount >= itemsToShow
162
-
163
- didShowAnyInMain ||= shouldShowInMain
164
- didShowAnyInOverflow ||= shouldShowInOverflow
96
+ // ...and it's in the overflow, set it as the last active overflow item
97
+ if (activeElementIdx >= overflowIndex) {
98
+ setLastActiveOverflowItem(children[activeElementIdx].getAttribute('data-value'))
99
+ }
165
100
 
166
- setAttribute(
167
- mainItem.element,
168
- 'data-toolbar-visible',
169
- shouldShowInMain ? 'true' : 'false'
170
- )
171
- if (overflowItem) {
172
- assert(overflowItem.type === 'item')
173
- setAttribute(
174
- overflowItem.element,
175
- 'data-toolbar-visible',
176
- shouldShowInOverflow ? 'true' : 'false'
177
- )
178
- }
179
- if (shouldShowInOverflow && mainItem.element.getAttribute('aria-pressed') === 'true') {
180
- newActiveOverflowItem = mainItem.element.getAttribute('data-value')
181
- }
182
- if (shouldShowInMain && mainItem.element.tagName === 'BUTTON') {
183
- numberedButtons.push(mainItem.element as HTMLButtonElement)
184
- }
185
- if (!shouldShowInOverflow && isLastActiveOverflowItem) {
186
- shouldInvalidateLastActiveOverflowItem = true
187
- }
188
- mainItemCount++
189
- } else {
190
- // for groups, we show them in main if we have space, or if they're the
191
- // last-used item from the overflow.
192
- let result, overflowGroup
193
- if (overflowItem) {
194
- assert(overflowItem.type === 'group')
195
- overflowGroup = overflowItem
196
- result = visitItems(mainItem.items, overflowGroup.items)
197
- } else {
198
- result = visitItems(mainItem.items, null)
199
- }
101
+ // Save the buttons that are actually visible
102
+ rButtons.current = Array.from(mainToolsRef.current?.children ?? []).filter(
103
+ (el): el is HTMLElement => {
104
+ // only count html elements...
105
+ if (!(el instanceof HTMLElement)) return false
200
106
 
201
- didShowAnyInMain ||= result.didShowAnyInMain
202
- didShowAnyInOverflow ||= result.didShowAnyInOverflow
107
+ // ...that are buttons...
108
+ if (el.tagName.toLowerCase() !== 'button') return false
203
109
 
204
- setAttribute(
205
- mainItem.element,
206
- 'data-toolbar-visible',
207
- result.didShowAnyInMain ? 'true' : 'false'
208
- )
209
- if (overflowGroup) {
210
- setAttribute(
211
- overflowGroup.element,
212
- 'data-toolbar-visible',
213
- result.didShowAnyInOverflow ? 'true' : 'false'
214
- )
215
- }
216
- }
110
+ // ...that are actually visible
111
+ return !!(el.offsetWidth || el.offsetHeight)
217
112
  }
218
- return { didShowAnyInMain, didShowAnyInOverflow }
219
- }
220
-
221
- const { didShowAnyInOverflow } = visitItems(mainItems, overflowItems)
222
- setShouldShowOverflow(didShowAnyInOverflow)
223
- if (newActiveOverflowItem) {
224
- setLastActiveOverflowItem(newActiveOverflowItem)
225
- } else if (shouldInvalidateLastActiveOverflowItem) {
226
- setLastActiveOverflowItem(null)
227
- }
228
-
229
- rButtons.current = numberedButtons
113
+ )
230
114
  })
231
115
 
232
116
  useLayoutEffect(() => {
@@ -240,31 +124,20 @@ export function OverflowingToolbar({
240
124
  mutationObserver.observe(mainToolsRef.current, {
241
125
  childList: true,
242
126
  subtree: true,
243
- attributes: true,
244
- characterData: true,
127
+ attributeFilter: ['data-value', 'aria-pressed'],
245
128
  })
246
129
 
247
- const sizingParent = findParentWithClassName(mainToolsRef.current, sizingParentClassName)
248
- const resizeObserver = new ResizeObserver(onDomUpdate)
249
- resizeObserver.observe(sizingParent)
250
-
251
130
  return () => {
252
131
  mutationObserver.disconnect()
253
- resizeObserver.disconnect()
254
132
  }
255
- }, [onDomUpdate, sizingParentClassName])
133
+ }, [onDomUpdate])
256
134
 
257
135
  useEffect(() => {
258
136
  if (!editor.options.enableToolbarKeyboardShortcuts) return
259
137
 
260
138
  function handleKeyDown(event: KeyboardEvent) {
261
- if (
262
- areShortcutsDisabled(editor) ||
263
- activeElementShouldCaptureKeys(true /* allow buttons */)
264
- ) {
139
+ if (areShortcutsDisabled(editor) || activeElementShouldCaptureKeys(true /* allow buttons */))
265
140
  return
266
- }
267
-
268
141
  // no accelerator keys
269
142
  if (event.ctrlKey || event.metaKey || event.altKey || event.shiftKey) return
270
143
  const index = NUMBERED_SHORTCUT_KEYS[event.key]
@@ -281,45 +154,37 @@ export function OverflowingToolbar({
281
154
  }, [editor])
282
155
 
283
156
  const popoverId = 'toolbar overflow'
284
-
285
- const Layout = orientation === 'horizontal' ? TldrawUiRow : TldrawUiColumn
286
157
  return (
287
158
  <>
159
+ <style nonce={editor.options.nonce}>{css}</style>
288
160
  <TldrawUiToolbar
289
- orientation={orientation}
290
- className={classNames('tlui-main-toolbar__tools', {
291
- 'tlui-main-toolbar__tools__mobile': breakpoint < PORTRAIT_BREAKPOINT.TABLET_SM,
161
+ className={classNames('tlui-toolbar__tools', {
162
+ 'tlui-toolbar__tools__mobile': breakpoint < PORTRAIT_BREAKPOINT.TABLET_SM,
292
163
  })}
293
164
  label={msg('tool-panel.title')}
294
165
  >
295
- <Layout id={`${id}_main`} ref={mainToolsRef}>
166
+ <div id={`${id}_main`} ref={mainToolsRef} className="tlui-toolbar__tools__list">
296
167
  <TldrawUiMenuContextProvider type="toolbar" sourceId="toolbar">
297
168
  {children}
298
169
  </TldrawUiMenuContextProvider>
299
- </Layout>
300
- {shouldShowOverflow && (
170
+ </div>
171
+ {/* There is a +1 because if the menu is just one item, it's not necessary. */}
172
+ {totalItems > overflowIndex + 1 && (
301
173
  <IsInOverflowContext.Provider value={true}>
302
174
  <TldrawUiPopover id={popoverId} open={isOpen} onOpenChange={setIsOpen}>
303
175
  <TldrawUiPopoverTrigger>
304
176
  <TldrawUiToolbarButton
305
177
  title={msg('tool-panel.more')}
306
178
  type="tool"
307
- className="tlui-main-toolbar__overflow"
179
+ className="tlui-toolbar__overflow"
308
180
  data-testid="tools.more-button"
309
181
  >
310
- <TldrawUiButtonIcon
311
- icon={orientation === 'horizontal' ? 'chevron-up' : 'chevron-right'}
312
- />
182
+ <TldrawUiButtonIcon icon="chevron-up" />
313
183
  </TldrawUiToolbarButton>
314
184
  </TldrawUiPopoverTrigger>
315
- <TldrawUiPopoverContent
316
- side={orientation === 'horizontal' ? 'top' : 'right'}
317
- align={orientation === 'horizontal' ? 'center' : 'end'}
318
- >
185
+ <TldrawUiPopoverContent side="top" align="center">
319
186
  <TldrawUiToolbar
320
- orientation="grid"
321
- className="tlui-main-toolbar__overflow-content"
322
- ref={setOverflowTools}
187
+ className="tlui-buttons__grid"
323
188
  data-testid="tools.more-content"
324
189
  label={msg('tool-panel.more')}
325
190
  id={`${id}_more`}
@@ -350,19 +215,3 @@ export const isActiveTLUiToolItem = (
350
215
  ? activeToolId === 'geo' && geoState === item.meta?.geo
351
216
  : activeToolId === item.id
352
217
  }
353
-
354
- function findParentWithClassName(startingElement: HTMLElement, className: string): HTMLElement {
355
- let element: HTMLElement | null = startingElement
356
- while (element) {
357
- if (element.classList.contains(className)) {
358
- return element
359
- }
360
- element = element.parentElement
361
- }
362
- throw new Error('Could not find parent with class name ' + className)
363
- }
364
-
365
- function setAttribute(element: HTMLElement, name: string, value: string) {
366
- if (element.getAttribute(name) === value) return
367
- element.setAttribute(name, value)
368
- }
@@ -5,14 +5,11 @@ import { useBreakpoint } from '../../context/breakpoints'
5
5
  import { useTranslation } from '../../hooks/useTranslation/useTranslation'
6
6
  import { TldrawUiButton } from '../primitives/Button/TldrawUiButton'
7
7
  import { TldrawUiButtonIcon } from '../primitives/Button/TldrawUiButtonIcon'
8
- import { TldrawUiTooltip } from '../primitives/TldrawUiTooltip'
9
8
 
10
- /** @public */
11
- export interface ToggleToolLockedButtonProps {
9
+ interface ToggleToolLockedButtonProps {
12
10
  activeToolId?: string
13
11
  }
14
12
 
15
- /** @public @react */
16
13
  export function ToggleToolLockedButton({ activeToolId }: ToggleToolLockedButtonProps) {
17
14
  const editor = useEditor()
18
15
  const breakpoint = useBreakpoint()
@@ -26,18 +23,16 @@ export function ToggleToolLockedButton({ activeToolId }: ToggleToolLockedButtonP
26
23
  if (!activeToolId || !tool.isLockable) return null
27
24
 
28
25
  return (
29
- <TldrawUiTooltip content={msg('action.toggle-tool-lock')}>
30
- <TldrawUiButton
31
- type="normal"
32
- title={msg('action.toggle-tool-lock')}
33
- data-testid="tool-lock"
34
- className={classNames('tlui-main-toolbar__lock-button', {
35
- 'tlui-main-toolbar__lock-button__mobile': breakpoint < PORTRAIT_BREAKPOINT.TABLET_SM,
36
- })}
37
- onClick={() => editor.updateInstanceState({ isToolLocked: !isToolLocked })}
38
- >
39
- <TldrawUiButtonIcon icon={isToolLocked ? 'lock' : 'unlock'} small />
40
- </TldrawUiButton>
41
- </TldrawUiTooltip>
26
+ <TldrawUiButton
27
+ type="normal"
28
+ title={msg('action.toggle-tool-lock')}
29
+ data-testid="tool-lock"
30
+ className={classNames('tlui-toolbar__lock-button', {
31
+ 'tlui-toolbar__lock-button__mobile': breakpoint < PORTRAIT_BREAKPOINT.TABLET_SM,
32
+ })}
33
+ onClick={() => editor.updateInstanceState({ isToolLocked: !isToolLocked })}
34
+ >
35
+ <TldrawUiButtonIcon icon={isToolLocked ? 'lock' : 'unlock'} small />
36
+ </TldrawUiButton>
42
37
  )
43
38
  }
@@ -634,31 +634,6 @@ export function ToggleReduceMotionItem() {
634
634
  )
635
635
  }
636
636
 
637
- /** @public @react */
638
- export function ToggleKeyboardShortcutsItem() {
639
- const editor = useEditor()
640
- const keyboardShortcuts = useValue(
641
- 'keyboardShortcuts',
642
- () => editor.user.getAreKeyboardShortcutsEnabled(),
643
- [editor]
644
- )
645
-
646
- return (
647
- <TldrawUiMenuActionCheckboxItem
648
- actionId="toggle-keyboard-shortcuts"
649
- checked={keyboardShortcuts}
650
- />
651
- )
652
- }
653
-
654
- /** @public @react */
655
- export function ToggleUiLabelsItem() {
656
- const editor = useEditor()
657
- const showUiLabels = useValue('showUiLabels', () => editor.user.getShowUiLabels(), [editor])
658
-
659
- return <TldrawUiMenuActionCheckboxItem actionId="toggle-ui-labels" checked={showUiLabels} />
660
- }
661
-
662
637
  /** @public @react */
663
638
  export function ToggleDebugModeItem() {
664
639
  const editor = useEditor()
@@ -1,8 +1,8 @@
1
- import { TldrawUiIcon, TLUiIconJsx } from '../TldrawUiIcon'
1
+ import { TldrawUiIcon } from '../TldrawUiIcon'
2
2
 
3
3
  /** @public */
4
4
  export interface TLUiButtonIconProps {
5
- icon: string | TLUiIconJsx
5
+ icon: string
6
6
  small?: boolean
7
7
  invertIcon?: boolean
8
8
  }
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  DefaultColorStyle,
3
- getColorValue,
4
3
  SharedStyle,
5
4
  StyleProp,
6
5
  TLDefaultColorStyle,
7
6
  TLDefaultColorTheme,
8
7
  useEditor,
9
8
  } from '@tldraw/editor'
10
- import { memo, ReactElement, useMemo, useRef } from 'react'
9
+ import classNames from 'classnames'
10
+ import { ReactElement, memo, useMemo, useRef } from 'react'
11
11
  import { StyleValuesForUi } from '../../../styles'
12
12
  import { PORTRAIT_BREAKPOINT } from '../../constants'
13
13
  import { useBreakpoint } from '../../context/breakpoints'
@@ -15,7 +15,6 @@ import { TLUiTranslationKey } from '../../hooks/useTranslation/TLUiTranslationKe
15
15
  import { useTranslation } from '../../hooks/useTranslation/useTranslation'
16
16
  import { TldrawUiButtonIcon } from './Button/TldrawUiButtonIcon'
17
17
  import { TldrawUiToolbarToggleGroup, TldrawUiToolbarToggleItem } from './TldrawUiToolbar'
18
- import { TldrawUiGrid, TldrawUiRow } from './layout'
19
18
 
20
19
  /** @public */
21
20
  export interface TLUiButtonPickerProps<T extends string> {
@@ -117,43 +116,39 @@ export const TldrawUiButtonPicker = memo(function TldrawUiButtonPicker<T extends
117
116
  }
118
117
  }, [editor, breakpoint, value, onHistoryMark, onValueChange, style])
119
118
 
120
- const Wrapper = items.length > 4 ? TldrawUiGrid : TldrawUiRow
121
-
122
119
  return (
123
- <Wrapper asChild>
124
- <TldrawUiToolbarToggleGroup
125
- data-testid={`style.${uiType}`}
126
- type="single"
127
- value={value.type === 'shared' ? value.value : undefined}
128
- >
129
- {items.map((item) => {
130
- const label = title + ' — ' + msg(`${uiType}-style.${item.value}` as TLUiTranslationKey)
131
- return (
132
- <TldrawUiToolbarToggleItem
133
- type="icon"
134
- key={item.value}
135
- data-id={item.value}
136
- data-testid={`style.${uiType}.${item.value}`}
137
- aria-label={label}
138
- value={item.value}
139
- data-state={value.type === 'shared' && value.value === item.value ? 'on' : 'off'}
140
- data-isactive={value.type === 'shared' && value.value === item.value}
141
- title={label}
142
- style={
143
- style === (DefaultColorStyle as StyleProp<unknown>)
144
- ? { color: getColorValue(theme, item.value as TLDefaultColorStyle, 'solid') }
145
- : undefined
146
- }
147
- onPointerEnter={handleButtonPointerEnter}
148
- onPointerDown={handleButtonPointerDown}
149
- onPointerUp={handleButtonPointerUp}
150
- onClick={handleButtonClick}
151
- >
152
- <TldrawUiButtonIcon icon={item.icon} />
153
- </TldrawUiToolbarToggleItem>
154
- )
155
- })}
156
- </TldrawUiToolbarToggleGroup>
157
- </Wrapper>
120
+ <TldrawUiToolbarToggleGroup
121
+ data-testid={`style.${uiType}`}
122
+ type="single"
123
+ className={classNames('tlui-buttons__grid')}
124
+ >
125
+ {items.map((item) => {
126
+ const label = title + ' — ' + msg(`${uiType}-style.${item.value}` as TLUiTranslationKey)
127
+ return (
128
+ <TldrawUiToolbarToggleItem
129
+ type="icon"
130
+ key={item.value}
131
+ data-id={item.value}
132
+ data-testid={`style.${uiType}.${item.value}`}
133
+ aria-label={label}
134
+ value={item.value}
135
+ data-isactive={value.type === 'shared' && value.value === item.value}
136
+ title={label}
137
+ className={classNames('tlui-button-grid__button')}
138
+ style={
139
+ style === (DefaultColorStyle as StyleProp<unknown>)
140
+ ? { color: theme[item.value as TLDefaultColorStyle].solid }
141
+ : undefined
142
+ }
143
+ onPointerEnter={handleButtonPointerEnter}
144
+ onPointerDown={handleButtonPointerDown}
145
+ onPointerUp={handleButtonPointerUp}
146
+ onClick={handleButtonClick}
147
+ >
148
+ <TldrawUiButtonIcon icon={item.icon} />
149
+ </TldrawUiToolbarToggleItem>
150
+ )
151
+ })}
152
+ </TldrawUiToolbarToggleGroup>
158
153
  )
159
154
  }) as <T extends string>(props: TLUiButtonPickerProps<T>) => ReactElement
@@ -172,7 +172,7 @@ export const TldrawUiContextualToolbar = ({
172
172
  className={classNames('tlui-contextual-toolbar', className)}
173
173
  onPointerDown={stopEventPropagation}
174
174
  >
175
- <TldrawUiToolbar orientation="horizontal" className="tlui-menu" label={label}>
175
+ <TldrawUiToolbar className="tlui-menu tlui-buttons__horizontal" label={label}>
176
176
  {children}
177
177
  </TldrawUiToolbar>
178
178
  </div>
@@ -65,7 +65,7 @@ export interface TLUiDialogBodyProps {
65
65
  /** @public @react */
66
66
  export function TldrawUiDialogBody({ className, children, style }: TLUiDialogBodyProps) {
67
67
  return (
68
- <div className={classNames('tlui-dialog__body', className)} style={style} tabIndex={0}>
68
+ <div className={classNames('tlui-dialog__body', className)} style={style}>
69
69
  {children}
70
70
  </div>
71
71
  )
@@ -1,14 +1,11 @@
1
1
  import classNames from 'classnames'
2
- import { cloneElement, memo, ReactElement, useLayoutEffect, useRef } from 'react'
2
+ import { memo, useLayoutEffect, useRef } from 'react'
3
3
  import { useAssetUrls } from '../../context/asset-urls'
4
4
  import { TLUiIconType } from '../../icon-types'
5
5
 
6
- /** @public */
7
- export type TLUiIconJsx = ReactElement<React.HTMLAttributes<HTMLDivElement>>
8
-
9
6
  /** @public */
10
7
  export interface TLUiIconProps extends React.HTMLAttributes<HTMLDivElement> {
11
- icon: TLUiIconType | Exclude<string, TLUiIconType> | TLUiIconJsx
8
+ icon: TLUiIconType | Exclude<string, TLUiIconType>
12
9
  label: string
13
10
  small?: boolean
14
11
  color?: string
@@ -27,41 +24,6 @@ export const TldrawUiIcon = memo(function TldrawUiIcon({
27
24
  className,
28
25
  ...props
29
26
  }: TLUiIconProps) {
30
- if (typeof icon === 'string') {
31
- return (
32
- <TldrawUIIconInner
33
- label={label}
34
- small={small}
35
- invertIcon={invertIcon}
36
- icon={icon}
37
- color={color}
38
- className={className}
39
- {...props}
40
- />
41
- )
42
- }
43
-
44
- return cloneElement(icon, {
45
- ...props,
46
- className: classNames({ 'tlui-icon__small': small }, className, icon.props.className),
47
- 'aria-label': label,
48
- style: {
49
- color,
50
- transform: invertIcon ? 'scale(-1, 1)' : undefined,
51
- ...icon.props.style,
52
- },
53
- })
54
- })
55
-
56
- function TldrawUIIconInner({
57
- label,
58
- small,
59
- invertIcon,
60
- icon,
61
- color,
62
- className,
63
- ...props
64
- }: TLUiIconProps & { icon: TLUiIconType | Exclude<string, TLUiIconType> }) {
65
27
  const assetUrls = useAssetUrls()
66
28
  const asset = assetUrls.icons[icon as TLUiIconType] ?? assetUrls.icons['question-mark-circle']
67
29
  const ref = useRef<HTMLDivElement>(null)
@@ -107,4 +69,4 @@ function TldrawUIIconInner({
107
69
  }}
108
70
  />
109
71
  )
110
- }
72
+ })
@@ -1,5 +1,4 @@
1
1
  import { useContainer } from '@tldraw/editor'
2
- import classNames from 'classnames'
3
2
  import { Popover as _Popover } from 'radix-ui'
4
3
  import React from 'react'
5
4
  import { useMenuIsOpen } from '../../hooks/useMenuIsOpen'
@@ -10,16 +9,15 @@ export interface TLUiPopoverProps {
10
9
  open?: boolean
11
10
  children: React.ReactNode
12
11
  onOpenChange?(isOpen: boolean): void
13
- className?: string
14
12
  }
15
13
 
16
14
  /** @public @react */
17
- export function TldrawUiPopover({ id, children, onOpenChange, open, className }: TLUiPopoverProps) {
15
+ export function TldrawUiPopover({ id, children, onOpenChange, open }: TLUiPopoverProps) {
18
16
  const [isOpen, handleOpenChange] = useMenuIsOpen(id, onOpenChange)
19
17
 
20
18
  return (
21
19
  <_Popover.Root onOpenChange={handleOpenChange} open={open || isOpen /* allow debugging */}>
22
- <div className={classNames('tlui-popover', className)}>{children}</div>
20
+ <div className="tlui-popover">{children}</div>
23
21
  </_Popover.Root>
24
22
  )
25
23
  }