tldraw 3.16.0-canary.2b8b5023f0a5 → 3.16.0-canary.2b8e5b0ef726

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 (431) hide show
  1. package/dist-cjs/index.d.ts +274 -110
  2. package/dist-cjs/index.js +36 -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/canvas/TldrawScribble.js +1 -1
  7. package/dist-cjs/lib/canvas/TldrawScribble.js.map +2 -2
  8. package/dist-cjs/lib/defaultExternalContentHandlers.js +15 -4
  9. package/dist-cjs/lib/defaultExternalContentHandlers.js.map +2 -2
  10. package/dist-cjs/lib/shapes/arrow/arrowLabel.js +6 -0
  11. package/dist-cjs/lib/shapes/arrow/arrowLabel.js.map +3 -3
  12. package/dist-cjs/lib/shapes/arrow/elbow/ElbowArrowDebug.js +3 -3
  13. package/dist-cjs/lib/shapes/arrow/elbow/ElbowArrowDebug.js.map +1 -1
  14. package/dist-cjs/lib/shapes/bookmark/BookmarkShapeUtil.js +4 -4
  15. package/dist-cjs/lib/shapes/bookmark/BookmarkShapeUtil.js.map +2 -2
  16. package/dist-cjs/lib/shapes/embed/EmbedShapeUtil.js +1 -1
  17. package/dist-cjs/lib/shapes/embed/EmbedShapeUtil.js.map +1 -1
  18. package/dist-cjs/lib/shapes/frame/FrameShapeUtil.js +12 -5
  19. package/dist-cjs/lib/shapes/frame/FrameShapeUtil.js.map +2 -2
  20. package/dist-cjs/lib/shapes/frame/components/FrameHeading.js +1 -1
  21. package/dist-cjs/lib/shapes/frame/components/FrameHeading.js.map +2 -2
  22. package/dist-cjs/lib/shapes/frame/components/FrameLabelInput.js +2 -2
  23. package/dist-cjs/lib/shapes/frame/components/FrameLabelInput.js.map +2 -2
  24. package/dist-cjs/lib/shapes/geo/GeoShapeUtil.js +1 -0
  25. package/dist-cjs/lib/shapes/geo/GeoShapeUtil.js.map +2 -2
  26. package/dist-cjs/lib/shapes/image/ImageShapeUtil.js +6 -3
  27. package/dist-cjs/lib/shapes/image/ImageShapeUtil.js.map +2 -2
  28. package/dist-cjs/lib/shapes/note/NoteShapeUtil.js +2 -1
  29. package/dist-cjs/lib/shapes/note/NoteShapeUtil.js.map +2 -2
  30. package/dist-cjs/lib/shapes/shared/HyperlinkButton.js +4 -4
  31. package/dist-cjs/lib/shapes/shared/HyperlinkButton.js.map +2 -2
  32. package/dist-cjs/lib/shapes/shared/PlainTextLabel.js +1 -3
  33. package/dist-cjs/lib/shapes/shared/PlainTextLabel.js.map +2 -2
  34. package/dist-cjs/lib/shapes/shared/ShapeFill.js +1 -1
  35. package/dist-cjs/lib/shapes/shared/ShapeFill.js.map +2 -2
  36. package/dist-cjs/lib/shapes/shared/freehand/svg.js.map +2 -2
  37. package/dist-cjs/lib/shapes/shared/useEditablePlainText.js +3 -4
  38. package/dist-cjs/lib/shapes/shared/useEditablePlainText.js.map +2 -2
  39. package/dist-cjs/lib/shapes/shared/useImageOrVideoAsset.js +0 -2
  40. package/dist-cjs/lib/shapes/shared/useImageOrVideoAsset.js.map +2 -2
  41. package/dist-cjs/lib/shapes/text/PlainTextArea.js +2 -2
  42. package/dist-cjs/lib/shapes/text/PlainTextArea.js.map +2 -2
  43. package/dist-cjs/lib/shapes/text/RichTextArea.js +3 -3
  44. package/dist-cjs/lib/shapes/text/RichTextArea.js.map +2 -2
  45. package/dist-cjs/lib/shapes/video/VideoShapeUtil.js +3 -3
  46. package/dist-cjs/lib/shapes/video/VideoShapeUtil.js.map +1 -1
  47. package/dist-cjs/lib/tools/EraserTool/childStates/Erasing.js +25 -1
  48. package/dist-cjs/lib/tools/EraserTool/childStates/Erasing.js.map +2 -2
  49. package/dist-cjs/lib/tools/EraserTool/childStates/Pointing.js +12 -0
  50. package/dist-cjs/lib/tools/EraserTool/childStates/Pointing.js.map +2 -2
  51. package/dist-cjs/lib/ui/TldrawUi.js +27 -12
  52. package/dist-cjs/lib/ui/TldrawUi.js.map +3 -3
  53. package/dist-cjs/lib/ui/assetUrls.js +13 -10
  54. package/dist-cjs/lib/ui/assetUrls.js.map +2 -2
  55. package/dist-cjs/lib/ui/components/A11y.js +1 -1
  56. package/dist-cjs/lib/ui/components/A11y.js.map +2 -2
  57. package/dist-cjs/lib/ui/components/ActionsMenu/DefaultActionsMenu.js +10 -2
  58. package/dist-cjs/lib/ui/components/ActionsMenu/DefaultActionsMenu.js.map +2 -2
  59. package/dist-cjs/lib/ui/components/{FollowingIndicator.js → DefaultFollowingIndicator.js} +6 -6
  60. package/dist-cjs/lib/ui/components/DefaultFollowingIndicator.js.map +7 -0
  61. package/dist-cjs/lib/ui/components/KeyboardShortcutsDialog/DefaultKeyboardShortcutsDialogContent.js +6 -6
  62. package/dist-cjs/lib/ui/components/KeyboardShortcutsDialog/DefaultKeyboardShortcutsDialogContent.js.map +1 -1
  63. package/dist-cjs/lib/ui/components/LanguageMenu.js +1 -0
  64. package/dist-cjs/lib/ui/components/LanguageMenu.js.map +2 -2
  65. package/dist-cjs/lib/ui/components/Minimap/DefaultMinimap.js +1 -0
  66. package/dist-cjs/lib/ui/components/Minimap/DefaultMinimap.js.map +2 -2
  67. package/dist-cjs/lib/ui/components/Minimap/MinimapManager.js +4 -4
  68. package/dist-cjs/lib/ui/components/Minimap/MinimapManager.js.map +2 -2
  69. package/dist-cjs/lib/ui/components/MobileStylePanel.js +4 -2
  70. package/dist-cjs/lib/ui/components/MobileStylePanel.js.map +2 -2
  71. package/dist-cjs/lib/ui/components/PageMenu/DefaultPageMenu.js +1 -1
  72. package/dist-cjs/lib/ui/components/PageMenu/DefaultPageMenu.js.map +2 -2
  73. package/dist-cjs/lib/ui/components/StylePanel/DefaultStylePanel.js +9 -4
  74. package/dist-cjs/lib/ui/components/StylePanel/DefaultStylePanel.js.map +2 -2
  75. package/dist-cjs/lib/ui/components/StylePanel/DefaultStylePanelContent.js +255 -316
  76. package/dist-cjs/lib/ui/components/StylePanel/DefaultStylePanelContent.js.map +2 -2
  77. package/dist-cjs/lib/ui/components/StylePanel/StylePanelButtonPicker.js +147 -0
  78. package/dist-cjs/lib/ui/components/StylePanel/StylePanelButtonPicker.js.map +7 -0
  79. package/dist-cjs/lib/ui/components/StylePanel/StylePanelContext.js +68 -0
  80. package/dist-cjs/lib/ui/components/StylePanel/StylePanelContext.js.map +7 -0
  81. package/dist-cjs/lib/ui/components/StylePanel/{DoubleDropdownPicker.js → StylePanelDoubleDropdownPicker.js} +23 -22
  82. package/dist-cjs/lib/ui/components/StylePanel/StylePanelDoubleDropdownPicker.js.map +7 -0
  83. package/dist-cjs/lib/ui/components/StylePanel/{DropdownPicker.js → StylePanelDropdownPicker.js} +24 -21
  84. package/dist-cjs/lib/ui/components/StylePanel/StylePanelDropdownPicker.js.map +7 -0
  85. package/dist-cjs/lib/ui/components/StylePanel/StylePanelSubheading.js +28 -0
  86. package/dist-cjs/lib/ui/components/StylePanel/StylePanelSubheading.js.map +7 -0
  87. package/dist-cjs/lib/ui/components/Toolbar/AltTextEditor.js +4 -2
  88. package/dist-cjs/lib/ui/components/Toolbar/AltTextEditor.js.map +2 -2
  89. package/dist-cjs/lib/ui/components/Toolbar/DefaultImageToolbarContent.js +39 -10
  90. package/dist-cjs/lib/ui/components/Toolbar/DefaultImageToolbarContent.js.map +2 -2
  91. package/dist-cjs/lib/ui/components/Toolbar/DefaultToolbar.js +66 -22
  92. package/dist-cjs/lib/ui/components/Toolbar/DefaultToolbar.js.map +3 -3
  93. package/dist-cjs/lib/ui/components/Toolbar/DefaultVideoToolbarContent.js +15 -3
  94. package/dist-cjs/lib/ui/components/Toolbar/DefaultVideoToolbarContent.js.map +2 -2
  95. package/dist-cjs/lib/ui/components/Toolbar/LinkEditor.js +5 -4
  96. package/dist-cjs/lib/ui/components/Toolbar/LinkEditor.js.map +2 -2
  97. package/dist-cjs/lib/ui/components/Toolbar/OverflowingToolbar.js +188 -78
  98. package/dist-cjs/lib/ui/components/Toolbar/OverflowingToolbar.js.map +3 -3
  99. package/dist-cjs/lib/ui/components/primitives/TldrawUiContextualToolbar.js +11 -2
  100. package/dist-cjs/lib/ui/components/primitives/TldrawUiContextualToolbar.js.map +2 -2
  101. package/dist-cjs/lib/ui/components/primitives/TldrawUiInput.js +2 -2
  102. package/dist-cjs/lib/ui/components/primitives/TldrawUiInput.js.map +2 -2
  103. package/dist-cjs/lib/ui/components/primitives/TldrawUiSlider.js +18 -5
  104. package/dist-cjs/lib/ui/components/primitives/TldrawUiSlider.js.map +2 -2
  105. package/dist-cjs/lib/ui/components/primitives/TldrawUiToolbar.js +18 -3
  106. package/dist-cjs/lib/ui/components/primitives/TldrawUiToolbar.js.map +2 -2
  107. package/dist-cjs/lib/ui/components/primitives/TldrawUiTooltip.js +186 -165
  108. package/dist-cjs/lib/ui/components/primitives/TldrawUiTooltip.js.map +2 -2
  109. package/dist-cjs/lib/ui/components/primitives/layout.js +30 -5
  110. package/dist-cjs/lib/ui/components/primitives/layout.js.map +2 -2
  111. package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuCheckboxItem.js +3 -0
  112. package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuCheckboxItem.js.map +2 -2
  113. package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuContext.js.map +2 -2
  114. package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuGroup.js +25 -12
  115. package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuGroup.js.map +2 -2
  116. package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuItem.js +8 -24
  117. package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuItem.js.map +2 -2
  118. package/dist-cjs/lib/ui/context/actions.js +29 -10
  119. package/dist-cjs/lib/ui/context/actions.js.map +2 -2
  120. package/dist-cjs/lib/ui/context/components.js +2 -0
  121. package/dist-cjs/lib/ui/context/components.js.map +2 -2
  122. package/dist-cjs/lib/ui/context/events.js.map +1 -1
  123. package/dist-cjs/lib/ui/hooks/useClipboardEvents.js +1 -1
  124. package/dist-cjs/lib/ui/hooks/useClipboardEvents.js.map +2 -2
  125. package/dist-cjs/lib/ui/hooks/useExportAs.js +3 -2
  126. package/dist-cjs/lib/ui/hooks/useExportAs.js.map +2 -2
  127. package/dist-cjs/lib/ui/hooks/useTools.js +22 -4
  128. package/dist-cjs/lib/ui/hooks/useTools.js.map +2 -2
  129. package/dist-cjs/lib/ui/hooks/useTranslation/TLUiTranslationKey.js.map +1 -1
  130. package/dist-cjs/lib/ui/hooks/useTranslation/defaultTranslation.js +6 -2
  131. package/dist-cjs/lib/ui/hooks/useTranslation/defaultTranslation.js.map +2 -2
  132. package/dist-cjs/lib/ui/kbd-utils.js +9 -3
  133. package/dist-cjs/lib/ui/kbd-utils.js.map +2 -2
  134. package/dist-cjs/lib/ui/version.js +3 -3
  135. package/dist-cjs/lib/ui/version.js.map +1 -1
  136. package/dist-cjs/lib/utils/export/copyAs.js +1 -2
  137. package/dist-cjs/lib/utils/export/copyAs.js.map +2 -2
  138. package/dist-cjs/lib/utils/export/export.js +0 -20
  139. package/dist-cjs/lib/utils/export/export.js.map +2 -2
  140. package/dist-cjs/lib/utils/export/exportAs.js +1 -2
  141. package/dist-cjs/lib/utils/export/exportAs.js.map +2 -2
  142. package/dist-esm/index.d.mts +274 -110
  143. package/dist-esm/index.mjs +68 -30
  144. package/dist-esm/index.mjs.map +2 -2
  145. package/dist-esm/lib/Tldraw.mjs +14 -4
  146. package/dist-esm/lib/Tldraw.mjs.map +2 -2
  147. package/dist-esm/lib/canvas/TldrawScribble.mjs +1 -1
  148. package/dist-esm/lib/canvas/TldrawScribble.mjs.map +2 -2
  149. package/dist-esm/lib/defaultExternalContentHandlers.mjs +15 -4
  150. package/dist-esm/lib/defaultExternalContentHandlers.mjs.map +2 -2
  151. package/dist-esm/lib/shapes/arrow/arrowLabel.mjs +6 -0
  152. package/dist-esm/lib/shapes/arrow/arrowLabel.mjs.map +3 -3
  153. package/dist-esm/lib/shapes/arrow/elbow/ElbowArrowDebug.mjs +3 -3
  154. package/dist-esm/lib/shapes/arrow/elbow/ElbowArrowDebug.mjs.map +1 -1
  155. package/dist-esm/lib/shapes/bookmark/BookmarkShapeUtil.mjs +5 -5
  156. package/dist-esm/lib/shapes/bookmark/BookmarkShapeUtil.mjs.map +2 -2
  157. package/dist-esm/lib/shapes/embed/EmbedShapeUtil.mjs +1 -1
  158. package/dist-esm/lib/shapes/embed/EmbedShapeUtil.mjs.map +1 -1
  159. package/dist-esm/lib/shapes/frame/FrameShapeUtil.mjs +12 -5
  160. package/dist-esm/lib/shapes/frame/FrameShapeUtil.mjs.map +2 -2
  161. package/dist-esm/lib/shapes/frame/components/FrameHeading.mjs +1 -1
  162. package/dist-esm/lib/shapes/frame/components/FrameHeading.mjs.map +2 -2
  163. package/dist-esm/lib/shapes/frame/components/FrameLabelInput.mjs +3 -3
  164. package/dist-esm/lib/shapes/frame/components/FrameLabelInput.mjs.map +2 -2
  165. package/dist-esm/lib/shapes/geo/GeoShapeUtil.mjs +1 -0
  166. package/dist-esm/lib/shapes/geo/GeoShapeUtil.mjs.map +2 -2
  167. package/dist-esm/lib/shapes/image/ImageShapeUtil.mjs +6 -3
  168. package/dist-esm/lib/shapes/image/ImageShapeUtil.mjs.map +2 -2
  169. package/dist-esm/lib/shapes/note/NoteShapeUtil.mjs +2 -1
  170. package/dist-esm/lib/shapes/note/NoteShapeUtil.mjs.map +2 -2
  171. package/dist-esm/lib/shapes/shared/HyperlinkButton.mjs +5 -5
  172. package/dist-esm/lib/shapes/shared/HyperlinkButton.mjs.map +2 -2
  173. package/dist-esm/lib/shapes/shared/PlainTextLabel.mjs +1 -3
  174. package/dist-esm/lib/shapes/shared/PlainTextLabel.mjs.map +2 -2
  175. package/dist-esm/lib/shapes/shared/ShapeFill.mjs +1 -1
  176. package/dist-esm/lib/shapes/shared/ShapeFill.mjs.map +2 -2
  177. package/dist-esm/lib/shapes/shared/freehand/svg.mjs.map +2 -2
  178. package/dist-esm/lib/shapes/shared/useEditablePlainText.mjs +4 -5
  179. package/dist-esm/lib/shapes/shared/useEditablePlainText.mjs.map +2 -2
  180. package/dist-esm/lib/shapes/shared/useImageOrVideoAsset.mjs +0 -2
  181. package/dist-esm/lib/shapes/shared/useImageOrVideoAsset.mjs.map +2 -2
  182. package/dist-esm/lib/shapes/text/PlainTextArea.mjs +3 -3
  183. package/dist-esm/lib/shapes/text/PlainTextArea.mjs.map +2 -2
  184. package/dist-esm/lib/shapes/text/RichTextArea.mjs +3 -4
  185. package/dist-esm/lib/shapes/text/RichTextArea.mjs.map +2 -2
  186. package/dist-esm/lib/shapes/video/VideoShapeUtil.mjs +3 -3
  187. package/dist-esm/lib/shapes/video/VideoShapeUtil.mjs.map +1 -1
  188. package/dist-esm/lib/tools/EraserTool/childStates/Erasing.mjs +26 -1
  189. package/dist-esm/lib/tools/EraserTool/childStates/Erasing.mjs.map +2 -2
  190. package/dist-esm/lib/tools/EraserTool/childStates/Pointing.mjs +13 -0
  191. package/dist-esm/lib/tools/EraserTool/childStates/Pointing.mjs.map +2 -2
  192. package/dist-esm/lib/ui/TldrawUi.mjs +29 -14
  193. package/dist-esm/lib/ui/TldrawUi.mjs.map +3 -3
  194. package/dist-esm/lib/ui/assetUrls.mjs +13 -10
  195. package/dist-esm/lib/ui/assetUrls.mjs.map +2 -2
  196. package/dist-esm/lib/ui/components/A11y.mjs +2 -2
  197. package/dist-esm/lib/ui/components/A11y.mjs.map +2 -2
  198. package/dist-esm/lib/ui/components/ActionsMenu/DefaultActionsMenu.mjs +10 -2
  199. package/dist-esm/lib/ui/components/ActionsMenu/DefaultActionsMenu.mjs.map +2 -2
  200. package/dist-esm/lib/ui/components/{FollowingIndicator.mjs → DefaultFollowingIndicator.mjs} +3 -3
  201. package/dist-esm/lib/ui/components/DefaultFollowingIndicator.mjs.map +7 -0
  202. package/dist-esm/lib/ui/components/KeyboardShortcutsDialog/DefaultKeyboardShortcutsDialogContent.mjs +6 -6
  203. package/dist-esm/lib/ui/components/KeyboardShortcutsDialog/DefaultKeyboardShortcutsDialogContent.mjs.map +1 -1
  204. package/dist-esm/lib/ui/components/LanguageMenu.mjs +1 -0
  205. package/dist-esm/lib/ui/components/LanguageMenu.mjs.map +2 -2
  206. package/dist-esm/lib/ui/components/Minimap/DefaultMinimap.mjs +1 -0
  207. package/dist-esm/lib/ui/components/Minimap/DefaultMinimap.mjs.map +2 -2
  208. package/dist-esm/lib/ui/components/Minimap/MinimapManager.mjs +4 -4
  209. package/dist-esm/lib/ui/components/Minimap/MinimapManager.mjs.map +2 -2
  210. package/dist-esm/lib/ui/components/MobileStylePanel.mjs +4 -2
  211. package/dist-esm/lib/ui/components/MobileStylePanel.mjs.map +2 -2
  212. package/dist-esm/lib/ui/components/PageMenu/DefaultPageMenu.mjs +2 -2
  213. package/dist-esm/lib/ui/components/PageMenu/DefaultPageMenu.mjs.map +2 -2
  214. package/dist-esm/lib/ui/components/StylePanel/DefaultStylePanel.mjs +14 -5
  215. package/dist-esm/lib/ui/components/StylePanel/DefaultStylePanel.mjs.map +2 -2
  216. package/dist-esm/lib/ui/components/StylePanel/DefaultStylePanelContent.mjs +257 -320
  217. package/dist-esm/lib/ui/components/StylePanel/DefaultStylePanelContent.mjs.map +2 -2
  218. package/dist-esm/lib/ui/components/StylePanel/StylePanelButtonPicker.mjs +135 -0
  219. package/dist-esm/lib/ui/components/StylePanel/StylePanelButtonPicker.mjs.map +7 -0
  220. package/dist-esm/lib/ui/components/StylePanel/StylePanelContext.mjs +48 -0
  221. package/dist-esm/lib/ui/components/StylePanel/StylePanelContext.mjs.map +7 -0
  222. package/dist-esm/lib/ui/components/StylePanel/{DoubleDropdownPicker.mjs → StylePanelDoubleDropdownPicker.mjs} +20 -19
  223. package/dist-esm/lib/ui/components/StylePanel/StylePanelDoubleDropdownPicker.mjs.map +7 -0
  224. package/dist-esm/lib/ui/components/StylePanel/{DropdownPicker.mjs → StylePanelDropdownPicker.mjs} +21 -18
  225. package/dist-esm/lib/ui/components/StylePanel/StylePanelDropdownPicker.mjs.map +7 -0
  226. package/dist-esm/lib/ui/components/StylePanel/StylePanelSubheading.mjs +8 -0
  227. package/dist-esm/lib/ui/components/StylePanel/StylePanelSubheading.mjs.map +7 -0
  228. package/dist-esm/lib/ui/components/Toolbar/AltTextEditor.mjs +4 -2
  229. package/dist-esm/lib/ui/components/Toolbar/AltTextEditor.mjs.map +2 -2
  230. package/dist-esm/lib/ui/components/Toolbar/DefaultImageToolbarContent.mjs +39 -10
  231. package/dist-esm/lib/ui/components/Toolbar/DefaultImageToolbarContent.mjs.map +2 -2
  232. package/dist-esm/lib/ui/components/Toolbar/DefaultToolbar.mjs +56 -22
  233. package/dist-esm/lib/ui/components/Toolbar/DefaultToolbar.mjs.map +2 -2
  234. package/dist-esm/lib/ui/components/Toolbar/DefaultVideoToolbarContent.mjs +15 -3
  235. package/dist-esm/lib/ui/components/Toolbar/DefaultVideoToolbarContent.mjs.map +2 -2
  236. package/dist-esm/lib/ui/components/Toolbar/LinkEditor.mjs +5 -4
  237. package/dist-esm/lib/ui/components/Toolbar/LinkEditor.mjs.map +2 -2
  238. package/dist-esm/lib/ui/components/Toolbar/OverflowingToolbar.mjs +192 -80
  239. package/dist-esm/lib/ui/components/Toolbar/OverflowingToolbar.mjs.map +3 -3
  240. package/dist-esm/lib/ui/components/primitives/TldrawUiContextualToolbar.mjs +12 -3
  241. package/dist-esm/lib/ui/components/primitives/TldrawUiContextualToolbar.mjs.map +2 -2
  242. package/dist-esm/lib/ui/components/primitives/TldrawUiInput.mjs +3 -3
  243. package/dist-esm/lib/ui/components/primitives/TldrawUiInput.mjs.map +2 -2
  244. package/dist-esm/lib/ui/components/primitives/TldrawUiSlider.mjs +18 -5
  245. package/dist-esm/lib/ui/components/primitives/TldrawUiSlider.mjs.map +2 -2
  246. package/dist-esm/lib/ui/components/primitives/TldrawUiToolbar.mjs +19 -4
  247. package/dist-esm/lib/ui/components/primitives/TldrawUiToolbar.mjs.map +2 -2
  248. package/dist-esm/lib/ui/components/primitives/TldrawUiTooltip.mjs +196 -167
  249. package/dist-esm/lib/ui/components/primitives/TldrawUiTooltip.mjs.map +2 -2
  250. package/dist-esm/lib/ui/components/primitives/layout.mjs +31 -6
  251. package/dist-esm/lib/ui/components/primitives/layout.mjs.map +2 -2
  252. package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuCheckboxItem.mjs +3 -0
  253. package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuCheckboxItem.mjs.map +2 -2
  254. package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuContext.mjs.map +2 -2
  255. package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuGroup.mjs +25 -12
  256. package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuGroup.mjs.map +2 -2
  257. package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuItem.mjs +8 -24
  258. package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuItem.mjs.map +2 -2
  259. package/dist-esm/lib/ui/context/actions.mjs +29 -10
  260. package/dist-esm/lib/ui/context/actions.mjs.map +2 -2
  261. package/dist-esm/lib/ui/context/components.mjs +2 -0
  262. package/dist-esm/lib/ui/context/components.mjs.map +2 -2
  263. package/dist-esm/lib/ui/context/events.mjs.map +1 -1
  264. package/dist-esm/lib/ui/hooks/useClipboardEvents.mjs +2 -2
  265. package/dist-esm/lib/ui/hooks/useClipboardEvents.mjs.map +2 -2
  266. package/dist-esm/lib/ui/hooks/useExportAs.mjs +3 -2
  267. package/dist-esm/lib/ui/hooks/useExportAs.mjs.map +2 -2
  268. package/dist-esm/lib/ui/hooks/useTools.mjs +23 -4
  269. package/dist-esm/lib/ui/hooks/useTools.mjs.map +2 -2
  270. package/dist-esm/lib/ui/hooks/useTranslation/defaultTranslation.mjs +6 -2
  271. package/dist-esm/lib/ui/hooks/useTranslation/defaultTranslation.mjs.map +2 -2
  272. package/dist-esm/lib/ui/kbd-utils.mjs +9 -3
  273. package/dist-esm/lib/ui/kbd-utils.mjs.map +2 -2
  274. package/dist-esm/lib/ui/version.mjs +3 -3
  275. package/dist-esm/lib/ui/version.mjs.map +1 -1
  276. package/dist-esm/lib/utils/export/copyAs.mjs +1 -2
  277. package/dist-esm/lib/utils/export/copyAs.mjs.map +2 -2
  278. package/dist-esm/lib/utils/export/export.mjs +0 -20
  279. package/dist-esm/lib/utils/export/export.mjs.map +2 -2
  280. package/dist-esm/lib/utils/export/exportAs.mjs +1 -2
  281. package/dist-esm/lib/utils/export/exportAs.mjs.map +2 -2
  282. package/package.json +11 -34
  283. package/src/index.ts +49 -22
  284. package/src/lib/Tldraw.tsx +15 -2
  285. package/src/lib/canvas/TldrawScribble.tsx +1 -1
  286. package/src/lib/defaultExternalContentHandlers.ts +26 -4
  287. package/src/lib/shapes/arrow/ArrowShapeOptions.test.ts +2 -1
  288. package/src/lib/shapes/arrow/ArrowShapeTool.test.ts +6 -5
  289. package/src/lib/shapes/arrow/ArrowShapeUtil.test.ts +48 -6
  290. package/src/lib/shapes/arrow/arrowLabel.ts +8 -0
  291. package/src/lib/shapes/arrow/elbow/ElbowArrowDebug.tsx +3 -3
  292. package/src/lib/shapes/bookmark/BookmarkShapeUtil.tsx +5 -5
  293. package/src/lib/shapes/draw/DrawShapeTool.test.ts +0 -5
  294. package/src/lib/shapes/embed/EmbedShapeUtil.tsx +1 -1
  295. package/src/lib/shapes/frame/FrameShapeUtil.tsx +21 -4
  296. package/src/lib/shapes/frame/components/FrameHeading.tsx +1 -1
  297. package/src/lib/shapes/frame/components/FrameLabelInput.tsx +3 -3
  298. package/src/lib/shapes/geo/GeoShapeUtil.tsx +1 -0
  299. package/src/lib/shapes/image/ImageShapeUtil.tsx +6 -3
  300. package/src/lib/shapes/line/LineShapeUtil.test.tsx +4 -3
  301. package/src/lib/shapes/line/__snapshots__/LineShapeUtil.test.tsx.snap +2 -2
  302. package/src/lib/shapes/note/NoteShapeUtil.tsx +1 -0
  303. package/src/lib/shapes/shared/HyperlinkButton.tsx +5 -5
  304. package/src/lib/shapes/shared/PlainTextLabel.tsx +0 -6
  305. package/src/lib/shapes/shared/ShapeFill.tsx +1 -1
  306. package/src/lib/shapes/shared/freehand/svg.ts +2 -0
  307. package/src/lib/shapes/shared/useEditablePlainText.ts +5 -9
  308. package/src/lib/shapes/shared/useImageOrVideoAsset.ts +0 -7
  309. package/src/lib/shapes/text/PlainTextArea.tsx +3 -3
  310. package/src/lib/shapes/text/RichTextArea.tsx +3 -4
  311. package/src/lib/shapes/text/TextShapeTool.test.ts +6 -5
  312. package/src/lib/shapes/video/VideoShapeUtil.tsx +3 -3
  313. package/src/lib/tools/EraserTool/childStates/Erasing.ts +34 -1
  314. package/src/lib/tools/EraserTool/childStates/Pointing.ts +20 -0
  315. package/src/lib/ui/TldrawUi.tsx +33 -12
  316. package/src/lib/ui/assetUrls.ts +13 -10
  317. package/src/lib/ui/components/A11y.tsx +2 -2
  318. package/src/lib/ui/components/ActionsMenu/DefaultActionsMenu.tsx +13 -2
  319. package/src/lib/ui/components/{FollowingIndicator.tsx → DefaultFollowingIndicator.tsx} +2 -1
  320. package/src/lib/ui/components/KeyboardShortcutsDialog/DefaultKeyboardShortcutsDialogContent.tsx +6 -6
  321. package/src/lib/ui/components/LanguageMenu.tsx +1 -0
  322. package/src/lib/ui/components/Minimap/DefaultMinimap.tsx +1 -0
  323. package/src/lib/ui/components/Minimap/MinimapManager.ts +4 -4
  324. package/src/lib/ui/components/MobileStylePanel.tsx +4 -3
  325. package/src/lib/ui/components/PageMenu/DefaultPageMenu.tsx +2 -2
  326. package/src/lib/ui/components/StylePanel/DefaultStylePanel.tsx +27 -13
  327. package/src/lib/ui/components/StylePanel/DefaultStylePanelContent.tsx +260 -381
  328. package/src/lib/ui/components/{primitives/TldrawUiButtonPicker.tsx → StylePanel/StylePanelButtonPicker.tsx} +70 -50
  329. package/src/lib/ui/components/StylePanel/StylePanelContext.tsx +63 -0
  330. package/src/lib/ui/components/StylePanel/{DoubleDropdownPicker.tsx → StylePanelDoubleDropdownPicker.tsx} +28 -19
  331. package/src/lib/ui/components/StylePanel/StylePanelDropdownPicker.tsx +119 -0
  332. package/src/lib/ui/components/StylePanel/StylePanelSubheading.tsx +9 -0
  333. package/src/lib/ui/components/Toolbar/AltTextEditor.tsx +5 -3
  334. package/src/lib/ui/components/Toolbar/DefaultImageToolbarContent.tsx +33 -16
  335. package/src/lib/ui/components/Toolbar/DefaultToolbar.tsx +55 -24
  336. package/src/lib/ui/components/Toolbar/DefaultVideoToolbarContent.tsx +12 -4
  337. package/src/lib/ui/components/Toolbar/LinkEditor.tsx +6 -5
  338. package/src/lib/ui/components/Toolbar/OverflowingToolbar.tsx +208 -56
  339. package/src/lib/ui/components/primitives/TldrawUiContextualToolbar.tsx +8 -3
  340. package/src/lib/ui/components/primitives/TldrawUiInput.tsx +3 -3
  341. package/src/lib/ui/components/primitives/TldrawUiSlider.tsx +52 -32
  342. package/src/lib/ui/components/primitives/TldrawUiToolbar.tsx +27 -6
  343. package/src/lib/ui/components/primitives/TldrawUiTooltip.tsx +231 -185
  344. package/src/lib/ui/components/primitives/layout.tsx +79 -5
  345. package/src/lib/ui/components/primitives/menus/TldrawUiMenuCheckboxItem.tsx +4 -0
  346. package/src/lib/ui/components/primitives/menus/TldrawUiMenuContext.tsx +0 -1
  347. package/src/lib/ui/components/primitives/menus/TldrawUiMenuGroup.tsx +29 -16
  348. package/src/lib/ui/components/primitives/menus/TldrawUiMenuItem.tsx +11 -24
  349. package/src/lib/ui/context/actions.tsx +36 -10
  350. package/src/lib/ui/context/components.tsx +3 -0
  351. package/src/lib/ui/context/events.tsx +1 -1
  352. package/src/lib/ui/hooks/useClipboardEvents.ts +2 -2
  353. package/src/lib/ui/hooks/useExportAs.ts +3 -2
  354. package/src/lib/ui/hooks/useTools.tsx +26 -4
  355. package/src/lib/ui/hooks/useTranslation/TLUiTranslationKey.ts +4 -0
  356. package/src/lib/ui/hooks/useTranslation/defaultTranslation.ts +6 -2
  357. package/src/lib/ui/kbd-utils.ts +10 -3
  358. package/src/lib/ui/version.ts +3 -3
  359. package/src/lib/ui.css +375 -245
  360. package/src/lib/utils/excalidraw/__snapshots__/putExcalidrawContent.test.tsx.snap +5 -5
  361. package/src/lib/utils/export/copyAs.ts +1 -24
  362. package/src/lib/utils/export/export.ts +0 -36
  363. package/src/lib/utils/export/exportAs.ts +1 -32
  364. package/src/lib/utils/tldr/__snapshots__/buildFromV1Document.test.ts.snap +4 -4
  365. package/src/test/A11y.test.tsx +3 -2
  366. package/src/test/ClickManager.test.ts +7 -6
  367. package/src/test/Editor.test.tsx +20 -19
  368. package/src/test/EraserTool.test.ts +184 -13
  369. package/src/test/HandTool.test.ts +10 -9
  370. package/src/test/HighlightShape.test.ts +2 -1
  371. package/src/test/SelectTool.test.ts +3 -2
  372. package/src/test/TLUserPreferences.test.ts +4 -3
  373. package/src/test/TestEditor.ts +13 -15
  374. package/src/test/TldrawEditor.test.tsx +11 -10
  375. package/src/test/ZoomTool.test.ts +7 -6
  376. package/src/test/__snapshots__/drawing.test.ts.snap +2 -2
  377. package/src/test/__snapshots__/groups.test.tsx.snap +6 -6
  378. package/src/test/__snapshots__/resizing.test.ts.snap +2 -2
  379. package/src/test/arrows-megabus.test.tsx +5 -4
  380. package/src/test/bindings.test.tsx +24 -37
  381. package/src/test/bookmark-shapes.test.ts +1 -8
  382. package/src/test/commands/__snapshots__/getSvgString.test.ts.snap +23 -7
  383. package/src/test/commands/__snapshots__/packShapes.test.ts.snap +8 -8
  384. package/src/test/commands/__snapshots__/zoomToFit.test.ts.snap +2 -2
  385. package/src/test/commands/alignShapes.test.tsx +25 -24
  386. package/src/test/commands/animationSpeed.test.ts +2 -1
  387. package/src/test/commands/centerOnPoint.test.ts +3 -2
  388. package/src/test/commands/clipboard.test.ts +3 -2
  389. package/src/test/commands/createShapes.test.ts +2 -1
  390. package/src/test/commands/deleteShapes.test.ts +2 -1
  391. package/src/test/commands/distributeShapes.test.tsx +11 -10
  392. package/src/test/commands/getSvgString.test.ts +2 -1
  393. package/src/test/commands/packShapes.test.ts +5 -4
  394. package/src/test/commands/resizeShape.test.ts +2 -1
  395. package/src/test/commands/rotateShapes.test.ts +7 -6
  396. package/src/test/commands/setCamera.test.ts +4 -3
  397. package/src/test/commands/setCurrentPage.test.ts +3 -2
  398. package/src/test/commands/stackShapes.test.ts +11 -10
  399. package/src/test/commands/stretch.test.tsx +13 -12
  400. package/src/test/createDeepLink.test.tsx +2 -1
  401. package/src/test/cropping.test.ts +3 -2
  402. package/src/test/custom-clipping.test.ts +436 -0
  403. package/src/test/drawing.test.ts +2 -1
  404. package/src/test/flipShapes.test.ts +4 -3
  405. package/src/test/frames.test.ts +25 -24
  406. package/src/test/getCulledShapes.test.tsx +74 -4
  407. package/src/test/groups.test.tsx +1 -1
  408. package/src/test/handleDeepLink.test.tsx +2 -1
  409. package/src/test/maxShapes.test.ts +3 -2
  410. package/src/test/modifiers.test.ts +5 -4
  411. package/src/test/navigation.test.ts +12 -11
  412. package/src/test/panning.test.ts +2 -1
  413. package/src/test/perf/perf.test.ts +2 -1
  414. package/src/test/registerDeepLinkListener.test.tsx +10 -9
  415. package/src/test/resizing.test.ts +39 -38
  416. package/src/test/select.test.tsx +4 -3
  417. package/src/test/selection-omnibus.test.ts +11 -10
  418. package/src/test/shapeutils.test.ts +4 -3
  419. package/src/test/translating.test.ts +9 -8
  420. package/tldraw.css +683 -537
  421. package/dist-cjs/lib/ui/components/FollowingIndicator.js.map +0 -7
  422. package/dist-cjs/lib/ui/components/StylePanel/DoubleDropdownPicker.js.map +0 -7
  423. package/dist-cjs/lib/ui/components/StylePanel/DropdownPicker.js.map +0 -7
  424. package/dist-cjs/lib/ui/components/primitives/TldrawUiButtonPicker.js +0 -131
  425. package/dist-cjs/lib/ui/components/primitives/TldrawUiButtonPicker.js.map +0 -7
  426. package/dist-esm/lib/ui/components/FollowingIndicator.mjs.map +0 -7
  427. package/dist-esm/lib/ui/components/StylePanel/DoubleDropdownPicker.mjs.map +0 -7
  428. package/dist-esm/lib/ui/components/StylePanel/DropdownPicker.mjs.map +0 -7
  429. package/dist-esm/lib/ui/components/primitives/TldrawUiButtonPicker.mjs +0 -115
  430. package/dist-esm/lib/ui/components/primitives/TldrawUiButtonPicker.mjs.map +0 -7
  431. package/src/lib/ui/components/StylePanel/DropdownPicker.tsx +0 -110
@@ -32,9 +32,11 @@ __export(TldrawUiSlider_exports, {
32
32
  });
33
33
  module.exports = __toCommonJS(TldrawUiSlider_exports);
34
34
  var import_jsx_runtime = require("react/jsx-runtime");
35
+ var import_editor = require("@tldraw/editor");
35
36
  var import_radix_ui = require("radix-ui");
36
37
  var import_react = __toESM(require("react"));
37
38
  var import_useTranslation = require("../../hooks/useTranslation/useTranslation");
39
+ var import_TldrawUiTooltip = require("./TldrawUiTooltip");
38
40
  const TldrawUiSlider = import_react.default.forwardRef(function Slider({
39
41
  onHistoryMark,
40
42
  title,
@@ -47,6 +49,7 @@ const TldrawUiSlider = import_react.default.forwardRef(function Slider({
47
49
  ariaValueModifier = 1
48
50
  }, ref) {
49
51
  const msg = (0, import_useTranslation.useTranslation)();
52
+ const [titleAndLabel, setTitleAndLabel] = (0, import_react.useState)("");
50
53
  const [tabIndex, setTabIndex] = (0, import_react.useState)(-1);
51
54
  (0, import_react.useEffect)(() => {
52
55
  setTabIndex(0);
@@ -58,14 +61,25 @@ const TldrawUiSlider = import_react.default.forwardRef(function Slider({
58
61
  [onValueChange]
59
62
  );
60
63
  const handlePointerDown = (0, import_react.useCallback)(() => {
61
- onHistoryMark("click slider");
64
+ import_TldrawUiTooltip.tooltipManager.hideAllTooltips();
65
+ onHistoryMark?.("click slider");
62
66
  }, [onHistoryMark]);
67
+ (0, import_react.useEffect)(() => {
68
+ const timeout = import_editor.tltime.setTimeout(
69
+ "set title and label",
70
+ () => {
71
+ setTitleAndLabel(title + " \u2014 " + msg(label));
72
+ },
73
+ 0
74
+ );
75
+ return () => clearTimeout(timeout);
76
+ }, [label, msg, title]);
63
77
  const handleKeyEvent = (0, import_react.useCallback)((event) => {
64
78
  if (event.key === "Tab") {
65
79
  event.stopPropagation();
66
80
  }
67
81
  }, []);
68
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "tlui-slider__container", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
82
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "tlui-slider__container", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_TldrawUiTooltip.TldrawUiTooltip, { content: titleAndLabel, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
69
83
  import_radix_ui.Slider.Root,
70
84
  {
71
85
  "data-testid": testId,
@@ -79,7 +93,6 @@ const TldrawUiSlider = import_react.default.forwardRef(function Slider({
79
93
  onValueChange: handleValueChange,
80
94
  onKeyDownCapture: handleKeyEvent,
81
95
  onKeyUpCapture: handleKeyEvent,
82
- title: title + " \u2014 " + msg(label),
83
96
  children: [
84
97
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_radix_ui.Slider.Track, { className: "tlui-slider__track", dir: "ltr", children: value !== null && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_radix_ui.Slider.Range, { className: "tlui-slider__range", dir: "ltr" }) }),
85
98
  value !== null && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
@@ -88,7 +101,7 @@ const TldrawUiSlider = import_react.default.forwardRef(function Slider({
88
101
  "aria-valuemin": (min ?? 0) * ariaValueModifier,
89
102
  "aria-valuenow": value * ariaValueModifier,
90
103
  "aria-valuemax": steps * ariaValueModifier,
91
- "aria-label": title + " \u2014 " + msg(label),
104
+ "aria-label": titleAndLabel,
92
105
  className: "tlui-slider__thumb",
93
106
  dir: "ltr",
94
107
  ref,
@@ -97,6 +110,6 @@ const TldrawUiSlider = import_react.default.forwardRef(function Slider({
97
110
  )
98
111
  ]
99
112
  }
100
- ) });
113
+ ) }) });
101
114
  });
102
115
  //# sourceMappingURL=TldrawUiSlider.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/lib/ui/components/primitives/TldrawUiSlider.tsx"],
4
- "sourcesContent": ["import { Slider as _Slider } from 'radix-ui'\nimport React, { useCallback, useEffect, useState } from 'react'\nimport { TLUiTranslationKey } from '../../hooks/useTranslation/TLUiTranslationKey'\nimport { useTranslation } from '../../hooks/useTranslation/useTranslation'\n\n/** @public */\nexport interface TLUiSliderProps {\n\tmin?: number\n\tsteps: number\n\tvalue: number | null\n\tlabel: string\n\ttitle: string\n\tonValueChange(value: number): void\n\tonHistoryMark(id: string): void\n\t'data-testid'?: string\n\tariaValueModifier?: number\n}\n\n/** @public @react */\nexport const TldrawUiSlider = React.forwardRef<HTMLDivElement, TLUiSliderProps>(function Slider(\n\t{\n\t\tonHistoryMark,\n\t\ttitle,\n\t\tmin,\n\t\tsteps,\n\t\tvalue,\n\t\tlabel,\n\t\tonValueChange,\n\t\t['data-testid']: testId,\n\t\tariaValueModifier = 1,\n\t}: TLUiSliderProps,\n\tref\n) {\n\tconst msg = useTranslation()\n\n\t// XXX: Radix starts out our slider with a tabIndex of 0\n\t// This causes some tab focusing issues, most prevelant in MobileStylePanel,\n\t// where it grabs the focus. This works around it.\n\tconst [tabIndex, setTabIndex] = useState(-1)\n\tuseEffect(() => {\n\t\tsetTabIndex(0)\n\t}, [])\n\n\tconst handleValueChange = useCallback(\n\t\t(value: number[]) => {\n\t\t\tonValueChange(value[0])\n\t\t},\n\t\t[onValueChange]\n\t)\n\n\tconst handlePointerDown = useCallback(() => {\n\t\tonHistoryMark('click slider')\n\t}, [onHistoryMark])\n\n\t// N.B. Annoying. For a11y purposes, we need Tab to work.\n\t// For some reason, Radix has some custom behavior here\n\t// that interferes with tabbing past the slider and then\n\t// you get stuck in the slider.\n\tconst handleKeyEvent = useCallback((event: React.KeyboardEvent) => {\n\t\tif (event.key === 'Tab') {\n\t\t\tevent.stopPropagation()\n\t\t}\n\t}, [])\n\n\treturn (\n\t\t<div className=\"tlui-slider__container\">\n\t\t\t<_Slider.Root\n\t\t\t\tdata-testid={testId}\n\t\t\t\tclassName=\"tlui-slider\"\n\t\t\t\tdir=\"ltr\"\n\t\t\t\tmin={min ?? 0}\n\t\t\t\tmax={steps}\n\t\t\t\tstep={1}\n\t\t\t\tvalue={value !== null ? [value] : undefined}\n\t\t\t\tonPointerDown={handlePointerDown}\n\t\t\t\tonValueChange={handleValueChange}\n\t\t\t\tonKeyDownCapture={handleKeyEvent}\n\t\t\t\tonKeyUpCapture={handleKeyEvent}\n\t\t\t\ttitle={title + ' \u2014 ' + msg(label as TLUiTranslationKey)}\n\t\t\t>\n\t\t\t\t<_Slider.Track className=\"tlui-slider__track\" dir=\"ltr\">\n\t\t\t\t\t{value !== null && <_Slider.Range className=\"tlui-slider__range\" dir=\"ltr\" />}\n\t\t\t\t</_Slider.Track>\n\t\t\t\t{value !== null && (\n\t\t\t\t\t<_Slider.Thumb\n\t\t\t\t\t\taria-valuemin={(min ?? 0) * ariaValueModifier}\n\t\t\t\t\t\taria-valuenow={value * ariaValueModifier}\n\t\t\t\t\t\taria-valuemax={steps * ariaValueModifier}\n\t\t\t\t\t\taria-label={title + ' \u2014 ' + msg(label as TLUiTranslationKey)}\n\t\t\t\t\t\tclassName=\"tlui-slider__thumb\"\n\t\t\t\t\t\tdir=\"ltr\"\n\t\t\t\t\t\tref={ref}\n\t\t\t\t\t\ttabIndex={tabIndex}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t\t</_Slider.Root>\n\t\t</div>\n\t)\n})\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAkEG;AAlEH,sBAAkC;AAClC,mBAAwD;AAExD,4BAA+B;AAgBxB,MAAM,iBAAiB,aAAAA,QAAM,WAA4C,SAAS,OACxF;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,CAAC,aAAa,GAAG;AAAA,EACjB,oBAAoB;AACrB,GACA,KACC;AACD,QAAM,UAAM,sCAAe;AAK3B,QAAM,CAAC,UAAU,WAAW,QAAI,uBAAS,EAAE;AAC3C,8BAAU,MAAM;AACf,gBAAY,CAAC;AAAA,EACd,GAAG,CAAC,CAAC;AAEL,QAAM,wBAAoB;AAAA,IACzB,CAACC,WAAoB;AACpB,oBAAcA,OAAM,CAAC,CAAC;AAAA,IACvB;AAAA,IACA,CAAC,aAAa;AAAA,EACf;AAEA,QAAM,wBAAoB,0BAAY,MAAM;AAC3C,kBAAc,cAAc;AAAA,EAC7B,GAAG,CAAC,aAAa,CAAC;AAMlB,QAAM,qBAAiB,0BAAY,CAAC,UAA+B;AAClE,QAAI,MAAM,QAAQ,OAAO;AACxB,YAAM,gBAAgB;AAAA,IACvB;AAAA,EACD,GAAG,CAAC,CAAC;AAEL,SACC,4CAAC,SAAI,WAAU,0BACd;AAAA,IAAC,gBAAAC,OAAQ;AAAA,IAAR;AAAA,MACA,eAAa;AAAA,MACb,WAAU;AAAA,MACV,KAAI;AAAA,MACJ,KAAK,OAAO;AAAA,MACZ,KAAK;AAAA,MACL,MAAM;AAAA,MACN,OAAO,UAAU,OAAO,CAAC,KAAK,IAAI;AAAA,MAClC,eAAe;AAAA,MACf,eAAe;AAAA,MACf,kBAAkB;AAAA,MAClB,gBAAgB;AAAA,MAChB,OAAO,QAAQ,aAAQ,IAAI,KAA2B;AAAA,MAEtD;AAAA,oDAAC,gBAAAA,OAAQ,OAAR,EAAc,WAAU,sBAAqB,KAAI,OAChD,oBAAU,QAAQ,4CAAC,gBAAAA,OAAQ,OAAR,EAAc,WAAU,sBAAqB,KAAI,OAAM,GAC5E;AAAA,QACC,UAAU,QACV;AAAA,UAAC,gBAAAA,OAAQ;AAAA,UAAR;AAAA,YACA,kBAAgB,OAAO,KAAK;AAAA,YAC5B,iBAAe,QAAQ;AAAA,YACvB,iBAAe,QAAQ;AAAA,YACvB,cAAY,QAAQ,aAAQ,IAAI,KAA2B;AAAA,YAC3D,WAAU;AAAA,YACV,KAAI;AAAA,YACJ;AAAA,YACA;AAAA;AAAA,QACD;AAAA;AAAA;AAAA,EAEF,GACD;AAEF,CAAC;",
4
+ "sourcesContent": ["import { tltime } from '@tldraw/editor'\nimport { Slider as _Slider } from 'radix-ui'\nimport React, { useCallback, useEffect, useState } from 'react'\nimport { TLUiTranslationKey } from '../../hooks/useTranslation/TLUiTranslationKey'\nimport { useTranslation } from '../../hooks/useTranslation/useTranslation'\nimport { TldrawUiTooltip, tooltipManager } from './TldrawUiTooltip'\n\n/** @public */\nexport interface TLUiSliderProps {\n\tmin?: number\n\tsteps: number\n\tvalue: number | null\n\tlabel: string\n\ttitle: string\n\tonValueChange(value: number): void\n\tonHistoryMark?(id: string): void\n\t'data-testid'?: string\n\tariaValueModifier?: number\n}\n\n/** @public @react */\nexport const TldrawUiSlider = React.forwardRef<HTMLDivElement, TLUiSliderProps>(function Slider(\n\t{\n\t\tonHistoryMark,\n\t\ttitle,\n\t\tmin,\n\t\tsteps,\n\t\tvalue,\n\t\tlabel,\n\t\tonValueChange,\n\t\t['data-testid']: testId,\n\t\tariaValueModifier = 1,\n\t}: TLUiSliderProps,\n\tref\n) {\n\tconst msg = useTranslation()\n\tconst [titleAndLabel, setTitleAndLabel] = useState('')\n\n\t// XXX: Radix starts out our slider with a tabIndex of 0\n\t// This causes some tab focusing issues, most prevelant in MobileStylePanel,\n\t// where it grabs the focus. This works around it.\n\tconst [tabIndex, setTabIndex] = useState(-1)\n\tuseEffect(() => {\n\t\tsetTabIndex(0)\n\t}, [])\n\n\tconst handleValueChange = useCallback(\n\t\t(value: number[]) => {\n\t\t\tonValueChange(value[0])\n\t\t},\n\t\t[onValueChange]\n\t)\n\n\tconst handlePointerDown = useCallback(() => {\n\t\ttooltipManager.hideAllTooltips()\n\t\tonHistoryMark?.('click slider')\n\t}, [onHistoryMark])\n\n\t// N.B. This is a bit silly. The Radix slider auto-focuses which\n\t// triggers TldrawUiTooltip handleFocus when we dbl-click to edit an image,\n\t// which in turn makes the tooltip display prematurely.\n\t// This makes it wait until we've focused to show the tooltip.\n\tuseEffect(() => {\n\t\tconst timeout = tltime.setTimeout(\n\t\t\t'set title and label',\n\t\t\t() => {\n\t\t\t\tsetTitleAndLabel(title + ' \u2014 ' + msg(label as TLUiTranslationKey))\n\t\t\t},\n\t\t\t0\n\t\t)\n\t\treturn () => clearTimeout(timeout)\n\t}, [label, msg, title])\n\n\t// N.B. Annoying. For a11y purposes, we need Tab to work.\n\t// For some reason, Radix has some custom behavior here\n\t// that interferes with tabbing past the slider and then\n\t// you get stuck in the slider.\n\tconst handleKeyEvent = useCallback((event: React.KeyboardEvent) => {\n\t\tif (event.key === 'Tab') {\n\t\t\tevent.stopPropagation()\n\t\t}\n\t}, [])\n\n\treturn (\n\t\t<div className=\"tlui-slider__container\">\n\t\t\t<TldrawUiTooltip content={titleAndLabel}>\n\t\t\t\t<_Slider.Root\n\t\t\t\t\tdata-testid={testId}\n\t\t\t\t\tclassName=\"tlui-slider\"\n\t\t\t\t\tdir=\"ltr\"\n\t\t\t\t\tmin={min ?? 0}\n\t\t\t\t\tmax={steps}\n\t\t\t\t\tstep={1}\n\t\t\t\t\tvalue={value !== null ? [value] : undefined}\n\t\t\t\t\tonPointerDown={handlePointerDown}\n\t\t\t\t\tonValueChange={handleValueChange}\n\t\t\t\t\tonKeyDownCapture={handleKeyEvent}\n\t\t\t\t\tonKeyUpCapture={handleKeyEvent}\n\t\t\t\t>\n\t\t\t\t\t<_Slider.Track className=\"tlui-slider__track\" dir=\"ltr\">\n\t\t\t\t\t\t{value !== null && <_Slider.Range className=\"tlui-slider__range\" dir=\"ltr\" />}\n\t\t\t\t\t</_Slider.Track>\n\t\t\t\t\t{value !== null && (\n\t\t\t\t\t\t<_Slider.Thumb\n\t\t\t\t\t\t\taria-valuemin={(min ?? 0) * ariaValueModifier}\n\t\t\t\t\t\t\taria-valuenow={value * ariaValueModifier}\n\t\t\t\t\t\t\taria-valuemax={steps * ariaValueModifier}\n\t\t\t\t\t\t\taria-label={titleAndLabel}\n\t\t\t\t\t\t\tclassName=\"tlui-slider__thumb\"\n\t\t\t\t\t\t\tdir=\"ltr\"\n\t\t\t\t\t\t\tref={ref}\n\t\t\t\t\t\t\ttabIndex={tabIndex}\n\t\t\t\t\t\t/>\n\t\t\t\t\t)}\n\t\t\t\t</_Slider.Root>\n\t\t\t</TldrawUiTooltip>\n\t\t</div>\n\t)\n})\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAsFI;AAtFJ,oBAAuB;AACvB,sBAAkC;AAClC,mBAAwD;AAExD,4BAA+B;AAC/B,6BAAgD;AAgBzC,MAAM,iBAAiB,aAAAA,QAAM,WAA4C,SAAS,OACxF;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,CAAC,aAAa,GAAG;AAAA,EACjB,oBAAoB;AACrB,GACA,KACC;AACD,QAAM,UAAM,sCAAe;AAC3B,QAAM,CAAC,eAAe,gBAAgB,QAAI,uBAAS,EAAE;AAKrD,QAAM,CAAC,UAAU,WAAW,QAAI,uBAAS,EAAE;AAC3C,8BAAU,MAAM;AACf,gBAAY,CAAC;AAAA,EACd,GAAG,CAAC,CAAC;AAEL,QAAM,wBAAoB;AAAA,IACzB,CAACC,WAAoB;AACpB,oBAAcA,OAAM,CAAC,CAAC;AAAA,IACvB;AAAA,IACA,CAAC,aAAa;AAAA,EACf;AAEA,QAAM,wBAAoB,0BAAY,MAAM;AAC3C,0CAAe,gBAAgB;AAC/B,oBAAgB,cAAc;AAAA,EAC/B,GAAG,CAAC,aAAa,CAAC;AAMlB,8BAAU,MAAM;AACf,UAAM,UAAU,qBAAO;AAAA,MACtB;AAAA,MACA,MAAM;AACL,yBAAiB,QAAQ,aAAQ,IAAI,KAA2B,CAAC;AAAA,MAClE;AAAA,MACA;AAAA,IACD;AACA,WAAO,MAAM,aAAa,OAAO;AAAA,EAClC,GAAG,CAAC,OAAO,KAAK,KAAK,CAAC;AAMtB,QAAM,qBAAiB,0BAAY,CAAC,UAA+B;AAClE,QAAI,MAAM,QAAQ,OAAO;AACxB,YAAM,gBAAgB;AAAA,IACvB;AAAA,EACD,GAAG,CAAC,CAAC;AAEL,SACC,4CAAC,SAAI,WAAU,0BACd,sDAAC,0CAAgB,SAAS,eACzB;AAAA,IAAC,gBAAAC,OAAQ;AAAA,IAAR;AAAA,MACA,eAAa;AAAA,MACb,WAAU;AAAA,MACV,KAAI;AAAA,MACJ,KAAK,OAAO;AAAA,MACZ,KAAK;AAAA,MACL,MAAM;AAAA,MACN,OAAO,UAAU,OAAO,CAAC,KAAK,IAAI;AAAA,MAClC,eAAe;AAAA,MACf,eAAe;AAAA,MACf,kBAAkB;AAAA,MAClB,gBAAgB;AAAA,MAEhB;AAAA,oDAAC,gBAAAA,OAAQ,OAAR,EAAc,WAAU,sBAAqB,KAAI,OAChD,oBAAU,QAAQ,4CAAC,gBAAAA,OAAQ,OAAR,EAAc,WAAU,sBAAqB,KAAI,OAAM,GAC5E;AAAA,QACC,UAAU,QACV;AAAA,UAAC,gBAAAA,OAAQ;AAAA,UAAR;AAAA,YACA,kBAAgB,OAAO,KAAK;AAAA,YAC5B,iBAAe,QAAQ;AAAA,YACvB,iBAAe,QAAQ;AAAA,YACvB,cAAY;AAAA,YACZ,WAAU;AAAA,YACV,KAAI;AAAA,YACJ;AAAA,YACA;AAAA;AAAA,QACD;AAAA;AAAA;AAAA,EAEF,GACD,GACD;AAEF,CAAC;",
6
6
  "names": ["React", "value", "_Slider"]
7
7
  }
@@ -40,10 +40,22 @@ var import_radix_ui = require("radix-ui");
40
40
  var import_react = __toESM(require("react"));
41
41
  var import_layout = require("./layout");
42
42
  var import_TldrawUiTooltip = require("./TldrawUiTooltip");
43
+ const LayoutByOrientation = {
44
+ horizontal: import_layout.TldrawUiRow,
45
+ vertical: import_layout.TldrawUiColumn,
46
+ grid: import_layout.TldrawUiGrid
47
+ };
43
48
  const TldrawUiToolbar = import_react.default.forwardRef(
44
- ({ children, className, label, orientation = "horizontal", ...props }, ref) => {
45
- const Layout = orientation === "grid" ? import_layout.TldrawUiGrid : import_layout.TldrawUiRow;
46
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Layout, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
49
+ ({
50
+ children,
51
+ className,
52
+ label,
53
+ orientation = "horizontal",
54
+ tooltipSide,
55
+ ...props
56
+ }, ref) => {
57
+ const Layout = LayoutByOrientation[orientation];
58
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Layout, { asChild: true, tooltipSide, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
47
59
  import_radix_ui.Toolbar.Root,
48
60
  {
49
61
  ref,
@@ -66,6 +78,7 @@ const TldrawUiToolbarButton = import_react.default.forwardRef(
66
78
  draggable: false,
67
79
  "data-isactive": isActive,
68
80
  ...props,
81
+ "aria-label": props.title,
69
82
  title: void 0,
70
83
  className: (0, import_classnames.default)("tlui-button", `tlui-button__${type}`, props.className),
71
84
  children
@@ -79,11 +92,13 @@ const TldrawUiToolbarToggleGroup = ({
79
92
  children,
80
93
  className,
81
94
  type,
95
+ asChild,
82
96
  ...props
83
97
  }) => {
84
98
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
85
99
  import_radix_ui.Toolbar.ToggleGroup,
86
100
  {
101
+ asChild,
87
102
  type,
88
103
  ...props,
89
104
  role: "radiogroup",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/lib/ui/components/primitives/TldrawUiToolbar.tsx"],
4
- "sourcesContent": ["import classnames from 'classnames'\nimport { Toolbar as _Toolbar } from 'radix-ui'\nimport React from 'react'\nimport { TldrawUiGrid, TldrawUiRow } from './layout'\nimport { TldrawUiTooltip } from './TldrawUiTooltip'\n\n/** @public */\nexport interface TLUiToolbarProps extends React.HTMLAttributes<HTMLDivElement> {\n\tchildren?: React.ReactNode\n\tclassName?: string\n\tdir?: 'ltr' | 'rtl'\n\tlabel: string\n\torientation?: 'horizontal' | 'grid'\n}\n\n/** @public @react */\nexport const TldrawUiToolbar = React.forwardRef<HTMLDivElement, TLUiToolbarProps>(\n\t({ children, className, label, orientation = 'horizontal', ...props }: TLUiToolbarProps, ref) => {\n\t\tconst Layout = orientation === 'grid' ? TldrawUiGrid : TldrawUiRow\n\t\treturn (\n\t\t\t<Layout asChild>\n\t\t\t\t<_Toolbar.Root\n\t\t\t\t\tref={ref}\n\t\t\t\t\t{...props}\n\t\t\t\t\tclassName={classnames('tlui-toolbar', className)}\n\t\t\t\t\taria-label={label}\n\t\t\t\t\torientation={orientation === 'grid' ? 'horizontal' : orientation}\n\t\t\t\t>\n\t\t\t\t\t{children}\n\t\t\t\t</_Toolbar.Root>\n\t\t\t</Layout>\n\t\t)\n\t}\n)\n\n/** @public */\nexport interface TLUiToolbarButtonProps extends React.HTMLAttributes<HTMLButtonElement> {\n\tasChild?: boolean\n\tchildren?: React.ReactNode\n\tclassName?: string\n\tdisabled?: boolean\n\tisActive?: boolean\n\ttype: 'icon' | 'tool' | 'menu'\n\ttooltip?: string\n}\n\n/** @public @react */\nexport const TldrawUiToolbarButton = React.forwardRef<HTMLButtonElement, TLUiToolbarButtonProps>(\n\t({ asChild, children, type, isActive, tooltip, ...props }: TLUiToolbarButtonProps, ref) => {\n\t\tconst button = (\n\t\t\t<_Toolbar.Button\n\t\t\t\tref={ref}\n\t\t\t\tasChild={asChild}\n\t\t\t\tdraggable={false}\n\t\t\t\tdata-isactive={isActive}\n\t\t\t\t{...props}\n\t\t\t\t// The tooltip takes care of this.\n\t\t\t\ttitle={undefined}\n\t\t\t\tclassName={classnames('tlui-button', `tlui-button__${type}`, props.className)}\n\t\t\t>\n\t\t\t\t{children}\n\t\t\t</_Toolbar.Button>\n\t\t)\n\n\t\tconst tooltipContent = tooltip || props.title\n\n\t\treturn <TldrawUiTooltip content={tooltipContent}>{button}</TldrawUiTooltip>\n\t}\n)\n\n/** @public */\nexport interface TLUiToolbarToggleGroupProps extends React.HTMLAttributes<HTMLDivElement> {\n\tchildren?: React.ReactNode\n\tclassName?: string\n\tdir?: 'ltr' | 'rtl'\n\tvalue: any\n\t// TODO: fix up this type later\n\tdefaultValue?: any\n\ttype: 'single' | 'multiple'\n}\n\n/** @public @react */\nexport const TldrawUiToolbarToggleGroup = ({\n\tchildren,\n\tclassName,\n\ttype,\n\t...props\n}: TLUiToolbarToggleGroupProps) => {\n\treturn (\n\t\t<_Toolbar.ToggleGroup\n\t\t\ttype={type}\n\t\t\t{...props}\n\t\t\t// TODO: this fixes a bug in Radix until they fix it.\n\t\t\t// https://github.com/radix-ui/primitives/issues/3188\n\t\t\t// https://github.com/radix-ui/primitives/pull/3189\n\t\t\trole=\"radiogroup\"\n\t\t\tclassName={classnames('tlui-toolbar-toggle-group', className)}\n\t\t>\n\t\t\t{children}\n\t\t</_Toolbar.ToggleGroup>\n\t)\n}\n\n/** @public */\nexport interface TLUiToolbarToggleItemProps extends React.HTMLAttributes<HTMLButtonElement> {\n\tchildren?: React.ReactNode\n\tclassName?: string\n\ttype: 'icon' | 'tool'\n\tvalue: string\n\ttooltip?: string\n}\n\n/** @public @react */\nexport const TldrawUiToolbarToggleItem = ({\n\tchildren,\n\tclassName,\n\ttype,\n\tvalue,\n\ttooltip,\n\t...props\n}: TLUiToolbarToggleItemProps) => {\n\tconst toggleItem = (\n\t\t<_Toolbar.ToggleItem\n\t\t\t{...props}\n\t\t\t// The tooltip takes care of this.\n\t\t\ttitle={undefined}\n\t\t\tclassName={classnames(\n\t\t\t\t'tlui-button',\n\t\t\t\t`tlui-button__${type}`,\n\t\t\t\t'tlui-toolbar-toggle-group-item',\n\t\t\t\tclassName\n\t\t\t)}\n\t\t\tvalue={value}\n\t\t>\n\t\t\t{children}\n\t\t</_Toolbar.ToggleItem>\n\t)\n\n\tconst tooltipContent = tooltip || props.title\n\n\treturn <TldrawUiTooltip content={tooltipContent}>{toggleItem}</TldrawUiTooltip>\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAqBI;AArBJ,wBAAuB;AACvB,sBAAoC;AACpC,mBAAkB;AAClB,oBAA0C;AAC1C,6BAAgC;AAYzB,MAAM,kBAAkB,aAAAA,QAAM;AAAA,EACpC,CAAC,EAAE,UAAU,WAAW,OAAO,cAAc,cAAc,GAAG,MAAM,GAAqB,QAAQ;AAChG,UAAM,SAAS,gBAAgB,SAAS,6BAAe;AACvD,WACC,4CAAC,UAAO,SAAO,MACd;AAAA,MAAC,gBAAAC,QAAS;AAAA,MAAT;AAAA,QACA;AAAA,QACC,GAAG;AAAA,QACJ,eAAW,kBAAAC,SAAW,gBAAgB,SAAS;AAAA,QAC/C,cAAY;AAAA,QACZ,aAAa,gBAAgB,SAAS,eAAe;AAAA,QAEpD;AAAA;AAAA,IACF,GACD;AAAA,EAEF;AACD;AAcO,MAAM,wBAAwB,aAAAF,QAAM;AAAA,EAC1C,CAAC,EAAE,SAAS,UAAU,MAAM,UAAU,SAAS,GAAG,MAAM,GAA2B,QAAQ;AAC1F,UAAM,SACL;AAAA,MAAC,gBAAAC,QAAS;AAAA,MAAT;AAAA,QACA;AAAA,QACA;AAAA,QACA,WAAW;AAAA,QACX,iBAAe;AAAA,QACd,GAAG;AAAA,QAEJ,OAAO;AAAA,QACP,eAAW,kBAAAC,SAAW,eAAe,gBAAgB,IAAI,IAAI,MAAM,SAAS;AAAA,QAE3E;AAAA;AAAA,IACF;AAGD,UAAM,iBAAiB,WAAW,MAAM;AAExC,WAAO,4CAAC,0CAAgB,SAAS,gBAAiB,kBAAO;AAAA,EAC1D;AACD;AAcO,MAAM,6BAA6B,CAAC;AAAA,EAC1C;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACJ,MAAmC;AAClC,SACC;AAAA,IAAC,gBAAAD,QAAS;AAAA,IAAT;AAAA,MACA;AAAA,MACC,GAAG;AAAA,MAIJ,MAAK;AAAA,MACL,eAAW,kBAAAC,SAAW,6BAA6B,SAAS;AAAA,MAE3D;AAAA;AAAA,EACF;AAEF;AAYO,MAAM,4BAA4B,CAAC;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACJ,MAAkC;AACjC,QAAM,aACL;AAAA,IAAC,gBAAAD,QAAS;AAAA,IAAT;AAAA,MACC,GAAG;AAAA,MAEJ,OAAO;AAAA,MACP,eAAW,kBAAAC;AAAA,QACV;AAAA,QACA,gBAAgB,IAAI;AAAA,QACpB;AAAA,QACA;AAAA,MACD;AAAA,MACA;AAAA,MAEC;AAAA;AAAA,EACF;AAGD,QAAM,iBAAiB,WAAW,MAAM;AAExC,SAAO,4CAAC,0CAAgB,SAAS,gBAAiB,sBAAW;AAC9D;",
4
+ "sourcesContent": ["import classnames from 'classnames'\nimport { Toolbar as _Toolbar } from 'radix-ui'\nimport React from 'react'\nimport { TldrawUiColumn, TldrawUiGrid, TldrawUiRow } from './layout'\nimport { TldrawUiTooltip } from './TldrawUiTooltip'\n\n/** @public */\nexport interface TLUiToolbarProps extends React.HTMLAttributes<HTMLDivElement> {\n\tchildren?: React.ReactNode\n\tclassName?: string\n\tdir?: 'ltr' | 'rtl'\n\tlabel: string\n\torientation?: 'horizontal' | 'vertical' | 'grid'\n\ttooltipSide?: 'top' | 'right' | 'bottom' | 'left'\n}\n\nconst LayoutByOrientation = {\n\thorizontal: TldrawUiRow,\n\tvertical: TldrawUiColumn,\n\tgrid: TldrawUiGrid,\n}\n\n/** @public @react */\nexport const TldrawUiToolbar = React.forwardRef<HTMLDivElement, TLUiToolbarProps>(\n\t(\n\t\t{\n\t\t\tchildren,\n\t\t\tclassName,\n\t\t\tlabel,\n\t\t\torientation = 'horizontal',\n\t\t\ttooltipSide,\n\t\t\t...props\n\t\t}: TLUiToolbarProps,\n\t\tref\n\t) => {\n\t\tconst Layout = LayoutByOrientation[orientation]\n\t\treturn (\n\t\t\t<Layout asChild tooltipSide={tooltipSide}>\n\t\t\t\t<_Toolbar.Root\n\t\t\t\t\tref={ref}\n\t\t\t\t\t{...props}\n\t\t\t\t\tclassName={classnames('tlui-toolbar', className)}\n\t\t\t\t\taria-label={label}\n\t\t\t\t\torientation={orientation === 'grid' ? 'horizontal' : orientation}\n\t\t\t\t>\n\t\t\t\t\t{children}\n\t\t\t\t</_Toolbar.Root>\n\t\t\t</Layout>\n\t\t)\n\t}\n)\n\n/** @public */\nexport interface TLUiToolbarButtonProps extends React.HTMLAttributes<HTMLButtonElement> {\n\tasChild?: boolean\n\tchildren?: React.ReactNode\n\tclassName?: string\n\tdisabled?: boolean\n\tisActive?: boolean\n\ttype: 'icon' | 'tool' | 'menu'\n\ttooltip?: string\n}\n\n/** @public @react */\nexport const TldrawUiToolbarButton = React.forwardRef<HTMLButtonElement, TLUiToolbarButtonProps>(\n\t({ asChild, children, type, isActive, tooltip, ...props }: TLUiToolbarButtonProps, ref) => {\n\t\tconst button = (\n\t\t\t<_Toolbar.Button\n\t\t\t\tref={ref}\n\t\t\t\tasChild={asChild}\n\t\t\t\tdraggable={false}\n\t\t\t\tdata-isactive={isActive}\n\t\t\t\t{...props}\n\t\t\t\taria-label={props.title}\n\t\t\t\t// The tooltip takes care of this.\n\t\t\t\ttitle={undefined}\n\t\t\t\tclassName={classnames('tlui-button', `tlui-button__${type}`, props.className)}\n\t\t\t>\n\t\t\t\t{children}\n\t\t\t</_Toolbar.Button>\n\t\t)\n\n\t\tconst tooltipContent = tooltip || props.title\n\n\t\treturn <TldrawUiTooltip content={tooltipContent}>{button}</TldrawUiTooltip>\n\t}\n)\n\n/** @public */\nexport interface TLUiToolbarToggleGroupProps extends React.HTMLAttributes<HTMLDivElement> {\n\tchildren?: React.ReactNode\n\tclassName?: string\n\tdir?: 'ltr' | 'rtl'\n\tvalue: any\n\t// TODO: fix up this type later\n\tdefaultValue?: any\n\ttype: 'single' | 'multiple'\n\tasChild?: boolean\n}\n\n/** @public @react */\nexport const TldrawUiToolbarToggleGroup = ({\n\tchildren,\n\tclassName,\n\ttype,\n\tasChild,\n\t...props\n}: TLUiToolbarToggleGroupProps) => {\n\treturn (\n\t\t<_Toolbar.ToggleGroup\n\t\t\tasChild={asChild}\n\t\t\ttype={type}\n\t\t\t{...props}\n\t\t\t// TODO: this fixes a bug in Radix until they fix it.\n\t\t\t// https://github.com/radix-ui/primitives/issues/3188\n\t\t\t// https://github.com/radix-ui/primitives/pull/3189\n\t\t\trole=\"radiogroup\"\n\t\t\tclassName={classnames('tlui-toolbar-toggle-group', className)}\n\t\t>\n\t\t\t{children}\n\t\t</_Toolbar.ToggleGroup>\n\t)\n}\n\n/** @public */\nexport interface TLUiToolbarToggleItemProps extends React.HTMLAttributes<HTMLButtonElement> {\n\tchildren?: React.ReactNode\n\tclassName?: string\n\ttype: 'icon' | 'tool'\n\tvalue: string\n\ttooltip?: React.ReactNode\n}\n\n/** @public @react */\nexport const TldrawUiToolbarToggleItem = ({\n\tchildren,\n\tclassName,\n\ttype,\n\tvalue,\n\ttooltip,\n\t...props\n}: TLUiToolbarToggleItemProps) => {\n\tconst toggleItem = (\n\t\t<_Toolbar.ToggleItem\n\t\t\t{...props}\n\t\t\t// The tooltip takes care of this.\n\t\t\ttitle={undefined}\n\t\t\tclassName={classnames(\n\t\t\t\t'tlui-button',\n\t\t\t\t`tlui-button__${type}`,\n\t\t\t\t'tlui-toolbar-toggle-group-item',\n\t\t\t\tclassName\n\t\t\t)}\n\t\t\tvalue={value}\n\t\t>\n\t\t\t{children}\n\t\t</_Toolbar.ToggleItem>\n\t)\n\n\tconst tooltipContent = tooltip || props.title\n\n\treturn <TldrawUiTooltip content={tooltipContent}>{toggleItem}</TldrawUiTooltip>\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAsCI;AAtCJ,wBAAuB;AACvB,sBAAoC;AACpC,mBAAkB;AAClB,oBAA0D;AAC1D,6BAAgC;AAYhC,MAAM,sBAAsB;AAAA,EAC3B,YAAY;AAAA,EACZ,UAAU;AAAA,EACV,MAAM;AACP;AAGO,MAAM,kBAAkB,aAAAA,QAAM;AAAA,EACpC,CACC;AAAA,IACC;AAAA,IACA;AAAA,IACA;AAAA,IACA,cAAc;AAAA,IACd;AAAA,IACA,GAAG;AAAA,EACJ,GACA,QACI;AACJ,UAAM,SAAS,oBAAoB,WAAW;AAC9C,WACC,4CAAC,UAAO,SAAO,MAAC,aACf;AAAA,MAAC,gBAAAC,QAAS;AAAA,MAAT;AAAA,QACA;AAAA,QACC,GAAG;AAAA,QACJ,eAAW,kBAAAC,SAAW,gBAAgB,SAAS;AAAA,QAC/C,cAAY;AAAA,QACZ,aAAa,gBAAgB,SAAS,eAAe;AAAA,QAEpD;AAAA;AAAA,IACF,GACD;AAAA,EAEF;AACD;AAcO,MAAM,wBAAwB,aAAAF,QAAM;AAAA,EAC1C,CAAC,EAAE,SAAS,UAAU,MAAM,UAAU,SAAS,GAAG,MAAM,GAA2B,QAAQ;AAC1F,UAAM,SACL;AAAA,MAAC,gBAAAC,QAAS;AAAA,MAAT;AAAA,QACA;AAAA,QACA;AAAA,QACA,WAAW;AAAA,QACX,iBAAe;AAAA,QACd,GAAG;AAAA,QACJ,cAAY,MAAM;AAAA,QAElB,OAAO;AAAA,QACP,eAAW,kBAAAC,SAAW,eAAe,gBAAgB,IAAI,IAAI,MAAM,SAAS;AAAA,QAE3E;AAAA;AAAA,IACF;AAGD,UAAM,iBAAiB,WAAW,MAAM;AAExC,WAAO,4CAAC,0CAAgB,SAAS,gBAAiB,kBAAO;AAAA,EAC1D;AACD;AAeO,MAAM,6BAA6B,CAAC;AAAA,EAC1C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACJ,MAAmC;AAClC,SACC;AAAA,IAAC,gBAAAD,QAAS;AAAA,IAAT;AAAA,MACA;AAAA,MACA;AAAA,MACC,GAAG;AAAA,MAIJ,MAAK;AAAA,MACL,eAAW,kBAAAC,SAAW,6BAA6B,SAAS;AAAA,MAE3D;AAAA;AAAA,EACF;AAEF;AAYO,MAAM,4BAA4B,CAAC;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACJ,MAAkC;AACjC,QAAM,aACL;AAAA,IAAC,gBAAAD,QAAS;AAAA,IAAT;AAAA,MACC,GAAG;AAAA,MAEJ,OAAO;AAAA,MACP,eAAW,kBAAAC;AAAA,QACV;AAAA,QACA,gBAAgB,IAAI;AAAA,QACpB;AAAA,QACA;AAAA,MACD;AAAA,MACA;AAAA,MAEC;AAAA;AAAA,EACF;AAGD,QAAM,iBAAiB,WAAW,MAAM;AAExC,SAAO,4CAAC,0CAAgB,SAAS,gBAAiB,sBAAW;AAC9D;",
6
6
  "names": ["React", "_Toolbar", "classnames"]
7
7
  }
@@ -37,77 +37,75 @@ var import_jsx_runtime = require("react/jsx-runtime");
37
37
  var import_editor = require("@tldraw/editor");
38
38
  var import_radix_ui = require("radix-ui");
39
39
  var import_react = __toESM(require("react"));
40
- var import_usePrefersReducedMotion = require("../../../shapes/shared/usePrefersReducedMotion");
40
+ var import_layout = require("./layout");
41
41
  const DEFAULT_TOOLTIP_DELAY_MS = 700;
42
42
  class TooltipManager {
43
43
  static instance = null;
44
- currentTooltipId = null;
45
- currentContent = "";
46
- currentSide = "bottom";
47
- currentSideOffset = 5;
44
+ currentTooltip = (0, import_editor.atom)("current tooltip", null);
48
45
  destroyTimeoutId = null;
49
- subscribers = /* @__PURE__ */ new Set();
50
- activeElement = null;
51
- editor = null;
52
46
  static getInstance() {
53
47
  if (!TooltipManager.instance) {
54
48
  TooltipManager.instance = new TooltipManager();
55
49
  }
56
50
  return TooltipManager.instance;
57
51
  }
58
- setEditor(editor) {
59
- this.editor = editor;
60
- }
61
- subscribe(callback) {
62
- this.subscribers.add(callback);
63
- return () => this.subscribers.delete(callback);
64
- }
65
- notify() {
66
- this.subscribers.forEach((callback) => callback());
67
- }
68
- showTooltip(tooltipId, content, element, side = "bottom", sideOffset = 5) {
52
+ showTooltip(tooltipId, content, targetElement, side, sideOffset, showOnMobile, delayDuration) {
69
53
  if (this.destroyTimeoutId) {
70
54
  clearTimeout(this.destroyTimeoutId);
71
55
  this.destroyTimeoutId = null;
72
56
  }
73
- this.currentTooltipId = tooltipId;
74
- this.currentContent = content;
75
- this.currentSide = side;
76
- this.currentSideOffset = sideOffset;
77
- this.activeElement = element;
78
- this.notify();
57
+ this.currentTooltip.set({
58
+ id: tooltipId,
59
+ content,
60
+ side,
61
+ sideOffset,
62
+ showOnMobile,
63
+ targetElement,
64
+ delayDuration
65
+ });
79
66
  }
80
- hideTooltip(tooltipId, instant = false) {
67
+ updateCurrentTooltip(tooltipId, update) {
68
+ this.currentTooltip.update((tooltip) => {
69
+ if (tooltip?.id === tooltipId) {
70
+ return update(tooltip);
71
+ }
72
+ return tooltip;
73
+ });
74
+ }
75
+ hideTooltip(editor, tooltipId, instant = false) {
81
76
  const hide = () => {
82
- if (this.currentTooltipId === tooltipId) {
83
- this.currentTooltipId = null;
84
- this.currentContent = "";
85
- this.activeElement = null;
77
+ if (this.currentTooltip.get()?.id === tooltipId) {
78
+ this.currentTooltip.set(null);
86
79
  this.destroyTimeoutId = null;
87
- this.notify();
88
80
  }
89
81
  };
90
- if (instant) {
82
+ if (editor && !instant) {
83
+ this.destroyTimeoutId = editor.timers.setTimeout(hide, 300);
84
+ } else {
91
85
  hide();
92
- } else if (this.editor) {
93
- this.destroyTimeoutId = this.editor.timers.setTimeout(hide, 300);
94
86
  }
95
87
  }
96
88
  hideAllTooltips() {
97
- this.currentTooltipId = null;
98
- this.currentContent = "";
99
- this.activeElement = null;
89
+ this.currentTooltip.set(null);
100
90
  this.destroyTimeoutId = null;
101
- this.notify();
102
91
  }
103
92
  getCurrentTooltipData() {
104
- return {
105
- id: this.currentTooltipId,
106
- content: this.currentContent,
107
- side: this.currentSide,
108
- sideOffset: this.currentSideOffset,
109
- element: this.activeElement
110
- };
93
+ const currentTooltip = this.currentTooltip.get();
94
+ if (!currentTooltip) return null;
95
+ if (!this.supportsHover() && !currentTooltip.showOnMobile) return null;
96
+ return currentTooltip;
97
+ }
98
+ supportsHoverAtom = null;
99
+ supportsHover() {
100
+ if (!this.supportsHoverAtom) {
101
+ const mediaQuery = window.matchMedia("(hover: hover)");
102
+ const supportsHover = (0, import_editor.atom)("has hover", mediaQuery.matches);
103
+ this.supportsHoverAtom = supportsHover;
104
+ mediaQuery.addEventListener("change", (e) => {
105
+ supportsHover.set(e.matches);
106
+ });
107
+ }
108
+ return this.supportsHoverAtom.get();
111
109
  }
112
110
  }
113
111
  const tooltipManager = TooltipManager.getInstance();
@@ -119,45 +117,37 @@ function TldrawUiTooltipProvider({ children }) {
119
117
  ] }) });
120
118
  }
121
119
  function TooltipSingleton() {
122
- const editor = (0, import_editor.useMaybeEditor)();
123
- const [, forceUpdate] = (0, import_react.useState)({});
124
120
  const [isOpen, setIsOpen] = (0, import_react.useState)(false);
125
121
  const triggerRef = (0, import_react.useRef)(null);
126
- const previousPositionRef = (0, import_react.useRef)(null);
127
- const prefersReducedMotion = (0, import_usePrefersReducedMotion.usePrefersReducedMotion)();
128
- const [shouldAnimate, setShouldAnimate] = (0, import_react.useState)(false);
129
122
  const isFirstShowRef = (0, import_react.useRef)(true);
130
- const showTimeoutRef = (0, import_react.useRef)(null);
131
- (0, import_react.useEffect)(() => {
132
- tooltipManager.setEditor(editor);
133
- }, [editor]);
123
+ const editor = (0, import_editor.useMaybeEditor)();
124
+ const currentTooltip = (0, import_editor.useValue)(
125
+ "current tooltip",
126
+ () => tooltipManager.getCurrentTooltipData(),
127
+ []
128
+ );
129
+ const cameraState = (0, import_editor.useValue)("camera state", () => editor?.getCameraState(), [editor]);
134
130
  (0, import_react.useEffect)(() => {
135
- const unsubscribe = tooltipManager.subscribe(() => {
136
- forceUpdate({});
137
- });
138
- return unsubscribe;
139
- }, []);
140
- const tooltipData = tooltipManager.getCurrentTooltipData();
131
+ if (cameraState === "moving" && isOpen && currentTooltip) {
132
+ tooltipManager.hideTooltip(editor, currentTooltip.id, true);
133
+ }
134
+ }, [cameraState, isOpen, currentTooltip, editor]);
141
135
  (0, import_react.useEffect)(() => {
142
- const shouldBeOpen = Boolean(tooltipData.id && tooltipData.element);
143
- if (showTimeoutRef.current) {
144
- clearTimeout(showTimeoutRef.current);
145
- showTimeoutRef.current = null;
136
+ function handleKeyDown(event) {
137
+ if (event.key === "Escape" && currentTooltip) {
138
+ tooltipManager.hideTooltip(editor, currentTooltip.id);
139
+ }
146
140
  }
147
- if (shouldBeOpen && tooltipData.element && triggerRef.current) {
148
- const activeRect = tooltipData.element.getBoundingClientRect();
141
+ document.addEventListener("keydown", handleKeyDown);
142
+ return () => {
143
+ document.removeEventListener("keydown", handleKeyDown);
144
+ };
145
+ }, [editor, currentTooltip]);
146
+ (0, import_react.useEffect)(() => {
147
+ let timer = null;
148
+ if (currentTooltip && triggerRef.current) {
149
+ const activeRect = currentTooltip.targetElement.getBoundingClientRect();
149
150
  const trigger = triggerRef.current;
150
- const newPosition = {
151
- x: activeRect.left + activeRect.width / 2,
152
- y: activeRect.top + activeRect.height / 2
153
- };
154
- let shouldAnimateCheck = false;
155
- if (previousPositionRef.current) {
156
- const isNearPrevious = import_editor.Vec.DistMin(previousPositionRef.current, newPosition, 200);
157
- shouldAnimateCheck = !prefersReducedMotion && isNearPrevious && Math.abs(newPosition.y - previousPositionRef.current.y) < 50;
158
- }
159
- setShouldAnimate(isFirstShowRef.current ? false : shouldAnimateCheck);
160
- previousPositionRef.current = newPosition;
161
151
  trigger.style.position = "fixed";
162
152
  trigger.style.left = `${activeRect.left}px`;
163
153
  trigger.style.top = `${activeRect.top}px`;
@@ -165,22 +155,25 @@ function TooltipSingleton() {
165
155
  trigger.style.height = `${activeRect.height}px`;
166
156
  trigger.style.pointerEvents = "none";
167
157
  trigger.style.zIndex = "9999";
168
- if (isFirstShowRef.current && editor) {
169
- showTimeoutRef.current = editor.timers.setTimeout(() => {
158
+ if (isFirstShowRef.current) {
159
+ timer = setTimeout(() => {
170
160
  setIsOpen(true);
171
161
  isFirstShowRef.current = false;
172
- }, editor.options.tooltipDelayMs);
162
+ }, currentTooltip.delayDuration);
173
163
  } else {
174
164
  setIsOpen(true);
175
165
  }
176
- } else if (!shouldBeOpen) {
166
+ } else {
177
167
  setIsOpen(false);
178
- previousPositionRef.current = null;
179
- setShouldAnimate(false);
180
168
  isFirstShowRef.current = true;
181
169
  }
182
- }, [tooltipData.id, tooltipData.element, editor, prefersReducedMotion]);
183
- if (!tooltipData.id) {
170
+ return () => {
171
+ if (timer !== null) {
172
+ clearTimeout(timer);
173
+ }
174
+ };
175
+ }, [currentTooltip]);
176
+ if (!currentTooltip) {
184
177
  return null;
185
178
  }
186
179
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_radix_ui.Tooltip.Root, { open: isOpen, delayDuration: 0, children: [
@@ -189,96 +182,124 @@ function TooltipSingleton() {
189
182
  import_radix_ui.Tooltip.Content,
190
183
  {
191
184
  className: "tlui-tooltip",
192
- "data-should-animate": shouldAnimate,
193
- side: tooltipData.side,
194
- sideOffset: tooltipData.sideOffset,
185
+ side: currentTooltip.side,
186
+ sideOffset: currentTooltip.sideOffset,
195
187
  avoidCollisions: true,
196
188
  collisionPadding: 8,
197
189
  dir: "ltr",
198
190
  children: [
199
- tooltipData.content,
191
+ currentTooltip.content,
200
192
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_radix_ui.Tooltip.Arrow, { className: "tlui-tooltip__arrow" })
201
193
  ]
202
194
  }
203
195
  )
204
196
  ] });
205
197
  }
206
- function TldrawUiTooltip({
207
- children,
208
- content,
209
- side = "bottom",
210
- sideOffset = 5,
211
- disabled = false
212
- }) {
213
- const editor = (0, import_editor.useMaybeEditor)();
214
- const tooltipId = (0, import_react.useRef)((0, import_editor.uniqueId)());
215
- const hasProvider = (0, import_react.useContext)(TooltipSingletonContext);
216
- if (disabled || !content) {
217
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children });
218
- }
219
- if (!hasProvider) {
220
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
221
- import_radix_ui.Tooltip.Root,
222
- {
223
- delayDuration: editor?.options.tooltipDelayMs || DEFAULT_TOOLTIP_DELAY_MS,
224
- disableHoverableContent: true,
225
- children: [
226
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_radix_ui.Tooltip.Trigger, { asChild: true, children }),
227
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
228
- import_radix_ui.Tooltip.Content,
229
- {
230
- className: "tlui-tooltip",
231
- side,
232
- sideOffset,
233
- avoidCollisions: true,
234
- collisionPadding: 8,
235
- dir: "ltr",
236
- children: [
237
- content,
238
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_radix_ui.Tooltip.Arrow, { className: "tlui-tooltip__arrow" })
239
- ]
240
- }
241
- )
242
- ]
198
+ const TldrawUiTooltip = (0, import_react.forwardRef)(
199
+ ({
200
+ children,
201
+ content,
202
+ side,
203
+ sideOffset = 5,
204
+ disabled = false,
205
+ showOnMobile = false,
206
+ delayDuration
207
+ }, ref) => {
208
+ const editor = (0, import_editor.useMaybeEditor)();
209
+ const tooltipId = (0, import_react.useRef)((0, import_editor.uniqueId)());
210
+ const hasProvider = (0, import_react.useContext)(TooltipSingletonContext);
211
+ const showUiLabels = (0, import_editor.useValue)("showUiLabels", () => editor?.user.getShowUiLabels(), [editor]);
212
+ const orientationCtx = (0, import_layout.useTldrawUiOrientation)();
213
+ const sideToUse = side ?? orientationCtx.tooltipSide;
214
+ (0, import_react.useEffect)(() => {
215
+ const currentTooltipId = tooltipId.current;
216
+ return () => {
217
+ if (hasProvider) {
218
+ tooltipManager.hideTooltip(editor, currentTooltipId, true);
219
+ }
220
+ };
221
+ }, [editor, hasProvider]);
222
+ (0, import_react.useLayoutEffect)(() => {
223
+ if (hasProvider && tooltipManager.getCurrentTooltipData()?.id === tooltipId.current) {
224
+ tooltipManager.updateCurrentTooltip(tooltipId.current, (tooltip) => ({
225
+ ...tooltip,
226
+ content,
227
+ side: sideToUse,
228
+ sideOffset,
229
+ showOnMobile
230
+ }));
243
231
  }
244
- );
232
+ }, [content, sideToUse, sideOffset, showOnMobile, hasProvider]);
233
+ if (disabled || !content) {
234
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children });
235
+ }
236
+ let delayDurationToUse;
237
+ if (showUiLabels) {
238
+ delayDurationToUse = 0;
239
+ } else {
240
+ delayDurationToUse = delayDuration ?? (editor?.options.tooltipDelayMs || DEFAULT_TOOLTIP_DELAY_MS);
241
+ }
242
+ if (!hasProvider) {
243
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_radix_ui.Tooltip.Root, { delayDuration: delayDurationToUse, disableHoverableContent: true, children: [
244
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_radix_ui.Tooltip.Trigger, { asChild: true, ref, children }),
245
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
246
+ import_radix_ui.Tooltip.Content,
247
+ {
248
+ className: "tlui-tooltip",
249
+ side: sideToUse,
250
+ sideOffset,
251
+ avoidCollisions: true,
252
+ collisionPadding: 8,
253
+ dir: "ltr",
254
+ children: [
255
+ content,
256
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_radix_ui.Tooltip.Arrow, { className: "tlui-tooltip__arrow" })
257
+ ]
258
+ }
259
+ )
260
+ ] });
261
+ }
262
+ const child = import_react.default.Children.only(children);
263
+ (0, import_editor.assert)(import_react.default.isValidElement(child), "TldrawUiTooltip children must be a single element");
264
+ const handleMouseEnter = (event) => {
265
+ child.props.onMouseEnter?.(event);
266
+ tooltipManager.showTooltip(
267
+ tooltipId.current,
268
+ content,
269
+ event.currentTarget,
270
+ sideToUse,
271
+ sideOffset,
272
+ showOnMobile,
273
+ delayDurationToUse
274
+ );
275
+ };
276
+ const handleMouseLeave = (event) => {
277
+ child.props.onMouseLeave?.(event);
278
+ tooltipManager.hideTooltip(editor, tooltipId.current);
279
+ };
280
+ const handleFocus = (event) => {
281
+ child.props.onFocus?.(event);
282
+ tooltipManager.showTooltip(
283
+ tooltipId.current,
284
+ content,
285
+ event.currentTarget,
286
+ sideToUse,
287
+ sideOffset,
288
+ showOnMobile,
289
+ delayDurationToUse
290
+ );
291
+ };
292
+ const handleBlur = (event) => {
293
+ child.props.onBlur?.(event);
294
+ tooltipManager.hideTooltip(editor, tooltipId.current);
295
+ };
296
+ const childrenWithHandlers = import_react.default.cloneElement(children, {
297
+ onMouseEnter: handleMouseEnter,
298
+ onMouseLeave: handleMouseLeave,
299
+ onFocus: handleFocus,
300
+ onBlur: handleBlur
301
+ });
302
+ return childrenWithHandlers;
245
303
  }
246
- const child = import_react.default.Children.only(children);
247
- (0, import_editor.assert)(import_react.default.isValidElement(child), "TldrawUiTooltip children must be a single element");
248
- const handleMouseEnter = (event) => {
249
- child.props.onMouseEnter?.(event);
250
- tooltipManager.showTooltip(
251
- tooltipId.current,
252
- content,
253
- event.currentTarget,
254
- side,
255
- sideOffset
256
- );
257
- };
258
- const handleMouseLeave = (event) => {
259
- child.props.onMouseLeave?.(event);
260
- tooltipManager.hideTooltip(tooltipId.current);
261
- };
262
- const handleFocus = (event) => {
263
- child.props.onFocus?.(event);
264
- tooltipManager.showTooltip(
265
- tooltipId.current,
266
- content,
267
- event.currentTarget,
268
- side,
269
- sideOffset
270
- );
271
- };
272
- const handleBlur = (event) => {
273
- child.props.onBlur?.(event);
274
- tooltipManager.hideTooltip(tooltipId.current);
275
- };
276
- const childrenWithHandlers = import_react.default.cloneElement(children, {
277
- onMouseEnter: handleMouseEnter,
278
- onMouseLeave: handleMouseLeave,
279
- onFocus: handleFocus,
280
- onBlur: handleBlur
281
- });
282
- return childrenWithHandlers;
283
- }
304
+ );
284
305
  //# sourceMappingURL=TldrawUiTooltip.js.map