tldraw 3.16.0-canary.f56a36d13420 → 3.16.0-canary.f5bf2b535ea7

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 (274) hide show
  1. package/dist-cjs/index.d.ts +223 -109
  2. package/dist-cjs/index.js +29 -14
  3. package/dist-cjs/index.js.map +2 -2
  4. package/dist-cjs/lib/defaultExternalContentHandlers.js +10 -0
  5. package/dist-cjs/lib/defaultExternalContentHandlers.js.map +2 -2
  6. package/dist-cjs/lib/shapes/arrow/arrow-types.js.map +1 -1
  7. package/dist-cjs/lib/shapes/arrow/arrowLabel.js +6 -0
  8. package/dist-cjs/lib/shapes/arrow/arrowLabel.js.map +3 -3
  9. package/dist-cjs/lib/shapes/arrow/arrowTargetState.js +3 -2
  10. package/dist-cjs/lib/shapes/arrow/arrowTargetState.js.map +2 -2
  11. package/dist-cjs/lib/shapes/arrow/toolStates/Pointing.js +1 -1
  12. package/dist-cjs/lib/shapes/arrow/toolStates/Pointing.js.map +2 -2
  13. package/dist-cjs/lib/shapes/bookmark/BookmarkShapeUtil.js +4 -4
  14. package/dist-cjs/lib/shapes/bookmark/BookmarkShapeUtil.js.map +2 -2
  15. package/dist-cjs/lib/shapes/frame/FrameShapeUtil.js +2 -1
  16. package/dist-cjs/lib/shapes/frame/FrameShapeUtil.js.map +2 -2
  17. package/dist-cjs/lib/shapes/frame/components/FrameLabelInput.js +8 -2
  18. package/dist-cjs/lib/shapes/frame/components/FrameLabelInput.js.map +2 -2
  19. package/dist-cjs/lib/shapes/geo/GeoShapeUtil.js +1 -0
  20. package/dist-cjs/lib/shapes/geo/GeoShapeUtil.js.map +2 -2
  21. package/dist-cjs/lib/shapes/note/NoteShapeUtil.js +2 -1
  22. package/dist-cjs/lib/shapes/note/NoteShapeUtil.js.map +2 -2
  23. package/dist-cjs/lib/shapes/shared/HyperlinkButton.js +4 -4
  24. package/dist-cjs/lib/shapes/shared/HyperlinkButton.js.map +2 -2
  25. package/dist-cjs/lib/shapes/shared/PlainTextLabel.js +1 -3
  26. package/dist-cjs/lib/shapes/shared/PlainTextLabel.js.map +2 -2
  27. package/dist-cjs/lib/shapes/shared/useEditablePlainText.js +3 -5
  28. package/dist-cjs/lib/shapes/shared/useEditablePlainText.js.map +2 -2
  29. package/dist-cjs/lib/shapes/shared/useImageOrVideoAsset.js +0 -2
  30. package/dist-cjs/lib/shapes/shared/useImageOrVideoAsset.js.map +2 -2
  31. package/dist-cjs/lib/shapes/text/PlainTextArea.js +3 -2
  32. package/dist-cjs/lib/shapes/text/PlainTextArea.js.map +2 -2
  33. package/dist-cjs/lib/shapes/text/RichTextArea.js +3 -3
  34. package/dist-cjs/lib/shapes/text/RichTextArea.js.map +2 -2
  35. package/dist-cjs/lib/tools/SelectTool/childStates/DraggingHandle.js +3 -1
  36. package/dist-cjs/lib/tools/SelectTool/childStates/DraggingHandle.js.map +2 -2
  37. package/dist-cjs/lib/ui/components/A11y.js +1 -1
  38. package/dist-cjs/lib/ui/components/A11y.js.map +2 -2
  39. package/dist-cjs/lib/ui/components/LanguageMenu.js +1 -0
  40. package/dist-cjs/lib/ui/components/LanguageMenu.js.map +2 -2
  41. package/dist-cjs/lib/ui/components/Minimap/DefaultMinimap.js +2 -1
  42. package/dist-cjs/lib/ui/components/Minimap/DefaultMinimap.js.map +2 -2
  43. package/dist-cjs/lib/ui/components/PageMenu/DefaultPageMenu.js +1 -1
  44. package/dist-cjs/lib/ui/components/PageMenu/DefaultPageMenu.js.map +2 -2
  45. package/dist-cjs/lib/ui/components/StylePanel/DefaultStylePanel.js +9 -4
  46. package/dist-cjs/lib/ui/components/StylePanel/DefaultStylePanel.js.map +2 -2
  47. package/dist-cjs/lib/ui/components/StylePanel/DefaultStylePanelContent.js +255 -316
  48. package/dist-cjs/lib/ui/components/StylePanel/DefaultStylePanelContent.js.map +2 -2
  49. package/dist-cjs/lib/ui/components/StylePanel/StylePanelButtonPicker.js +147 -0
  50. package/dist-cjs/lib/ui/components/StylePanel/StylePanelButtonPicker.js.map +7 -0
  51. package/dist-cjs/lib/ui/components/StylePanel/StylePanelContext.js +68 -0
  52. package/dist-cjs/lib/ui/components/StylePanel/StylePanelContext.js.map +7 -0
  53. package/dist-cjs/lib/ui/components/StylePanel/{DoubleDropdownPicker.js → StylePanelDoubleDropdownPicker.js} +23 -22
  54. package/dist-cjs/lib/ui/components/StylePanel/StylePanelDoubleDropdownPicker.js.map +7 -0
  55. package/dist-cjs/lib/ui/components/StylePanel/{DropdownPicker.js → StylePanelDropdownPicker.js} +23 -20
  56. package/dist-cjs/lib/ui/components/StylePanel/StylePanelDropdownPicker.js.map +7 -0
  57. package/dist-cjs/lib/ui/components/StylePanel/StylePanelSubheading.js +28 -0
  58. package/dist-cjs/lib/ui/components/StylePanel/StylePanelSubheading.js.map +7 -0
  59. package/dist-cjs/lib/ui/components/Toolbar/AltTextEditor.js +2 -0
  60. package/dist-cjs/lib/ui/components/Toolbar/AltTextEditor.js.map +2 -2
  61. package/dist-cjs/lib/ui/components/Toolbar/DefaultImageToolbarContent.js +38 -9
  62. package/dist-cjs/lib/ui/components/Toolbar/DefaultImageToolbarContent.js.map +2 -2
  63. package/dist-cjs/lib/ui/components/Toolbar/DefaultVideoToolbarContent.js +15 -3
  64. package/dist-cjs/lib/ui/components/Toolbar/DefaultVideoToolbarContent.js.map +2 -2
  65. package/dist-cjs/lib/ui/components/Toolbar/LinkEditor.js +2 -1
  66. package/dist-cjs/lib/ui/components/Toolbar/LinkEditor.js.map +2 -2
  67. package/dist-cjs/lib/ui/components/Toolbar/OverflowingToolbar.js +1 -1
  68. package/dist-cjs/lib/ui/components/Toolbar/OverflowingToolbar.js.map +2 -2
  69. package/dist-cjs/lib/ui/components/Toolbar/ToggleToolLockedButton.js +6 -2
  70. package/dist-cjs/lib/ui/components/Toolbar/ToggleToolLockedButton.js.map +2 -2
  71. package/dist-cjs/lib/ui/components/primitives/TldrawUiContextualToolbar.js +11 -2
  72. package/dist-cjs/lib/ui/components/primitives/TldrawUiContextualToolbar.js.map +2 -2
  73. package/dist-cjs/lib/ui/components/primitives/TldrawUiInput.js +5 -3
  74. package/dist-cjs/lib/ui/components/primitives/TldrawUiInput.js.map +2 -2
  75. package/dist-cjs/lib/ui/components/primitives/TldrawUiSlider.js +18 -5
  76. package/dist-cjs/lib/ui/components/primitives/TldrawUiSlider.js.map +2 -2
  77. package/dist-cjs/lib/ui/components/primitives/TldrawUiToolbar.js +3 -0
  78. package/dist-cjs/lib/ui/components/primitives/TldrawUiToolbar.js.map +2 -2
  79. package/dist-cjs/lib/ui/components/primitives/TldrawUiTooltip.js +47 -3
  80. package/dist-cjs/lib/ui/components/primitives/TldrawUiTooltip.js.map +2 -2
  81. package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuCheckboxItem.js +3 -0
  82. package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuCheckboxItem.js.map +2 -2
  83. package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuItem.js +8 -8
  84. package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuItem.js.map +2 -2
  85. package/dist-cjs/lib/ui/context/actions.js +13 -8
  86. package/dist-cjs/lib/ui/context/actions.js.map +2 -2
  87. package/dist-cjs/lib/ui/hooks/useClipboardEvents.js +1 -1
  88. package/dist-cjs/lib/ui/hooks/useClipboardEvents.js.map +2 -2
  89. package/dist-cjs/lib/ui/hooks/useExportAs.js +3 -2
  90. package/dist-cjs/lib/ui/hooks/useExportAs.js.map +2 -2
  91. package/dist-cjs/lib/ui/hooks/useTools.js +1 -1
  92. package/dist-cjs/lib/ui/hooks/useTools.js.map +2 -2
  93. package/dist-cjs/lib/ui/hooks/useTranslation/TLUiTranslationKey.js.map +1 -1
  94. package/dist-cjs/lib/ui/hooks/useTranslation/defaultTranslation.js +5 -2
  95. package/dist-cjs/lib/ui/hooks/useTranslation/defaultTranslation.js.map +2 -2
  96. package/dist-cjs/lib/ui/version.js +3 -3
  97. package/dist-cjs/lib/ui/version.js.map +1 -1
  98. package/dist-cjs/lib/utils/export/copyAs.js +1 -2
  99. package/dist-cjs/lib/utils/export/copyAs.js.map +2 -2
  100. package/dist-cjs/lib/utils/export/export.js +0 -20
  101. package/dist-cjs/lib/utils/export/export.js.map +2 -2
  102. package/dist-cjs/lib/utils/export/exportAs.js +1 -2
  103. package/dist-cjs/lib/utils/export/exportAs.js.map +2 -2
  104. package/dist-esm/index.d.mts +223 -109
  105. package/dist-esm/index.mjs +59 -28
  106. package/dist-esm/index.mjs.map +2 -2
  107. package/dist-esm/lib/defaultExternalContentHandlers.mjs +10 -0
  108. package/dist-esm/lib/defaultExternalContentHandlers.mjs.map +2 -2
  109. package/dist-esm/lib/shapes/arrow/arrowLabel.mjs +6 -0
  110. package/dist-esm/lib/shapes/arrow/arrowLabel.mjs.map +3 -3
  111. package/dist-esm/lib/shapes/arrow/arrowTargetState.mjs +3 -2
  112. package/dist-esm/lib/shapes/arrow/arrowTargetState.mjs.map +2 -2
  113. package/dist-esm/lib/shapes/arrow/toolStates/Pointing.mjs +1 -1
  114. package/dist-esm/lib/shapes/arrow/toolStates/Pointing.mjs.map +2 -2
  115. package/dist-esm/lib/shapes/bookmark/BookmarkShapeUtil.mjs +4 -5
  116. package/dist-esm/lib/shapes/bookmark/BookmarkShapeUtil.mjs.map +2 -2
  117. package/dist-esm/lib/shapes/frame/FrameShapeUtil.mjs +2 -1
  118. package/dist-esm/lib/shapes/frame/FrameShapeUtil.mjs.map +2 -2
  119. package/dist-esm/lib/shapes/frame/components/FrameLabelInput.mjs +9 -3
  120. package/dist-esm/lib/shapes/frame/components/FrameLabelInput.mjs.map +2 -2
  121. package/dist-esm/lib/shapes/geo/GeoShapeUtil.mjs +1 -0
  122. package/dist-esm/lib/shapes/geo/GeoShapeUtil.mjs.map +2 -2
  123. package/dist-esm/lib/shapes/note/NoteShapeUtil.mjs +2 -1
  124. package/dist-esm/lib/shapes/note/NoteShapeUtil.mjs.map +2 -2
  125. package/dist-esm/lib/shapes/shared/HyperlinkButton.mjs +5 -5
  126. package/dist-esm/lib/shapes/shared/HyperlinkButton.mjs.map +2 -2
  127. package/dist-esm/lib/shapes/shared/PlainTextLabel.mjs +1 -3
  128. package/dist-esm/lib/shapes/shared/PlainTextLabel.mjs.map +2 -2
  129. package/dist-esm/lib/shapes/shared/useEditablePlainText.mjs +3 -6
  130. package/dist-esm/lib/shapes/shared/useEditablePlainText.mjs.map +2 -2
  131. package/dist-esm/lib/shapes/shared/useImageOrVideoAsset.mjs +0 -2
  132. package/dist-esm/lib/shapes/shared/useImageOrVideoAsset.mjs.map +2 -2
  133. package/dist-esm/lib/shapes/text/PlainTextArea.mjs +4 -3
  134. package/dist-esm/lib/shapes/text/PlainTextArea.mjs.map +2 -2
  135. package/dist-esm/lib/shapes/text/RichTextArea.mjs +3 -4
  136. package/dist-esm/lib/shapes/text/RichTextArea.mjs.map +2 -2
  137. package/dist-esm/lib/tools/SelectTool/childStates/DraggingHandle.mjs +3 -1
  138. package/dist-esm/lib/tools/SelectTool/childStates/DraggingHandle.mjs.map +2 -2
  139. package/dist-esm/lib/ui/components/A11y.mjs +1 -2
  140. package/dist-esm/lib/ui/components/A11y.mjs.map +2 -2
  141. package/dist-esm/lib/ui/components/LanguageMenu.mjs +1 -0
  142. package/dist-esm/lib/ui/components/LanguageMenu.mjs.map +2 -2
  143. package/dist-esm/lib/ui/components/Minimap/DefaultMinimap.mjs +2 -1
  144. package/dist-esm/lib/ui/components/Minimap/DefaultMinimap.mjs.map +2 -2
  145. package/dist-esm/lib/ui/components/PageMenu/DefaultPageMenu.mjs +1 -2
  146. package/dist-esm/lib/ui/components/PageMenu/DefaultPageMenu.mjs.map +2 -2
  147. package/dist-esm/lib/ui/components/StylePanel/DefaultStylePanel.mjs +14 -5
  148. package/dist-esm/lib/ui/components/StylePanel/DefaultStylePanel.mjs.map +2 -2
  149. package/dist-esm/lib/ui/components/StylePanel/DefaultStylePanelContent.mjs +257 -320
  150. package/dist-esm/lib/ui/components/StylePanel/DefaultStylePanelContent.mjs.map +2 -2
  151. package/dist-esm/lib/ui/components/StylePanel/StylePanelButtonPicker.mjs +135 -0
  152. package/dist-esm/lib/ui/components/StylePanel/StylePanelButtonPicker.mjs.map +7 -0
  153. package/dist-esm/lib/ui/components/StylePanel/StylePanelContext.mjs +48 -0
  154. package/dist-esm/lib/ui/components/StylePanel/StylePanelContext.mjs.map +7 -0
  155. package/dist-esm/lib/ui/components/StylePanel/{DoubleDropdownPicker.mjs → StylePanelDoubleDropdownPicker.mjs} +20 -19
  156. package/dist-esm/lib/ui/components/StylePanel/StylePanelDoubleDropdownPicker.mjs.map +7 -0
  157. package/dist-esm/lib/ui/components/StylePanel/{DropdownPicker.mjs → StylePanelDropdownPicker.mjs} +20 -17
  158. package/dist-esm/lib/ui/components/StylePanel/StylePanelDropdownPicker.mjs.map +7 -0
  159. package/dist-esm/lib/ui/components/StylePanel/StylePanelSubheading.mjs +8 -0
  160. package/dist-esm/lib/ui/components/StylePanel/StylePanelSubheading.mjs.map +7 -0
  161. package/dist-esm/lib/ui/components/Toolbar/AltTextEditor.mjs +2 -0
  162. package/dist-esm/lib/ui/components/Toolbar/AltTextEditor.mjs.map +2 -2
  163. package/dist-esm/lib/ui/components/Toolbar/DefaultImageToolbarContent.mjs +38 -9
  164. package/dist-esm/lib/ui/components/Toolbar/DefaultImageToolbarContent.mjs.map +2 -2
  165. package/dist-esm/lib/ui/components/Toolbar/DefaultVideoToolbarContent.mjs +15 -3
  166. package/dist-esm/lib/ui/components/Toolbar/DefaultVideoToolbarContent.mjs.map +2 -2
  167. package/dist-esm/lib/ui/components/Toolbar/LinkEditor.mjs +2 -1
  168. package/dist-esm/lib/ui/components/Toolbar/LinkEditor.mjs.map +2 -2
  169. package/dist-esm/lib/ui/components/Toolbar/OverflowingToolbar.mjs +1 -1
  170. package/dist-esm/lib/ui/components/Toolbar/OverflowingToolbar.mjs.map +2 -2
  171. package/dist-esm/lib/ui/components/Toolbar/ToggleToolLockedButton.mjs +6 -2
  172. package/dist-esm/lib/ui/components/Toolbar/ToggleToolLockedButton.mjs.map +2 -2
  173. package/dist-esm/lib/ui/components/primitives/TldrawUiContextualToolbar.mjs +11 -3
  174. package/dist-esm/lib/ui/components/primitives/TldrawUiContextualToolbar.mjs.map +2 -2
  175. package/dist-esm/lib/ui/components/primitives/TldrawUiInput.mjs +6 -4
  176. package/dist-esm/lib/ui/components/primitives/TldrawUiInput.mjs.map +2 -2
  177. package/dist-esm/lib/ui/components/primitives/TldrawUiSlider.mjs +18 -5
  178. package/dist-esm/lib/ui/components/primitives/TldrawUiSlider.mjs.map +2 -2
  179. package/dist-esm/lib/ui/components/primitives/TldrawUiToolbar.mjs +3 -0
  180. package/dist-esm/lib/ui/components/primitives/TldrawUiToolbar.mjs.map +2 -2
  181. package/dist-esm/lib/ui/components/primitives/TldrawUiTooltip.mjs +48 -3
  182. package/dist-esm/lib/ui/components/primitives/TldrawUiTooltip.mjs.map +2 -2
  183. package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuCheckboxItem.mjs +3 -0
  184. package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuCheckboxItem.mjs.map +2 -2
  185. package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuItem.mjs +8 -8
  186. package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuItem.mjs.map +2 -2
  187. package/dist-esm/lib/ui/context/actions.mjs +13 -8
  188. package/dist-esm/lib/ui/context/actions.mjs.map +2 -2
  189. package/dist-esm/lib/ui/hooks/useClipboardEvents.mjs +1 -2
  190. package/dist-esm/lib/ui/hooks/useClipboardEvents.mjs.map +2 -2
  191. package/dist-esm/lib/ui/hooks/useExportAs.mjs +3 -2
  192. package/dist-esm/lib/ui/hooks/useExportAs.mjs.map +2 -2
  193. package/dist-esm/lib/ui/hooks/useTools.mjs +1 -1
  194. package/dist-esm/lib/ui/hooks/useTools.mjs.map +2 -2
  195. package/dist-esm/lib/ui/hooks/useTranslation/defaultTranslation.mjs +5 -2
  196. package/dist-esm/lib/ui/hooks/useTranslation/defaultTranslation.mjs.map +2 -2
  197. package/dist-esm/lib/ui/version.mjs +3 -3
  198. package/dist-esm/lib/ui/version.mjs.map +1 -1
  199. package/dist-esm/lib/utils/export/copyAs.mjs +1 -2
  200. package/dist-esm/lib/utils/export/copyAs.mjs.map +2 -2
  201. package/dist-esm/lib/utils/export/export.mjs +0 -20
  202. package/dist-esm/lib/utils/export/export.mjs.map +2 -2
  203. package/dist-esm/lib/utils/export/exportAs.mjs +1 -2
  204. package/dist-esm/lib/utils/export/exportAs.mjs.map +2 -2
  205. package/package.json +3 -3
  206. package/src/index.ts +45 -21
  207. package/src/lib/defaultExternalContentHandlers.ts +14 -0
  208. package/src/lib/shapes/arrow/ArrowShapeOptions.test.ts +83 -13
  209. package/src/lib/shapes/arrow/ArrowShapeTool.test.ts +99 -5
  210. package/src/lib/shapes/arrow/ArrowShapeUtil.test.ts +41 -0
  211. package/src/lib/shapes/arrow/arrow-types.ts +3 -5
  212. package/src/lib/shapes/arrow/arrowLabel.ts +8 -0
  213. package/src/lib/shapes/arrow/arrowTargetState.ts +34 -3
  214. package/src/lib/shapes/arrow/toolStates/Pointing.tsx +1 -1
  215. package/src/lib/shapes/bookmark/BookmarkShapeUtil.tsx +4 -5
  216. package/src/lib/shapes/frame/FrameShapeUtil.tsx +1 -0
  217. package/src/lib/shapes/frame/components/FrameLabelInput.tsx +10 -3
  218. package/src/lib/shapes/geo/GeoShapeUtil.tsx +1 -0
  219. package/src/lib/shapes/note/NoteShapeUtil.tsx +1 -0
  220. package/src/lib/shapes/shared/HyperlinkButton.tsx +5 -5
  221. package/src/lib/shapes/shared/PlainTextLabel.tsx +0 -6
  222. package/src/lib/shapes/shared/useEditablePlainText.ts +3 -10
  223. package/src/lib/shapes/shared/useImageOrVideoAsset.ts +0 -7
  224. package/src/lib/shapes/text/PlainTextArea.tsx +4 -3
  225. package/src/lib/shapes/text/RichTextArea.tsx +3 -4
  226. package/src/lib/tools/SelectTool/childStates/DraggingHandle.tsx +6 -2
  227. package/src/lib/ui/components/A11y.tsx +1 -2
  228. package/src/lib/ui/components/LanguageMenu.tsx +1 -0
  229. package/src/lib/ui/components/Minimap/DefaultMinimap.tsx +2 -1
  230. package/src/lib/ui/components/PageMenu/DefaultPageMenu.tsx +1 -2
  231. package/src/lib/ui/components/StylePanel/DefaultStylePanel.tsx +27 -13
  232. package/src/lib/ui/components/StylePanel/DefaultStylePanelContent.tsx +260 -381
  233. package/src/lib/ui/components/{primitives/TldrawUiButtonPicker.tsx → StylePanel/StylePanelButtonPicker.tsx} +70 -50
  234. package/src/lib/ui/components/StylePanel/StylePanelContext.tsx +63 -0
  235. package/src/lib/ui/components/StylePanel/{DoubleDropdownPicker.tsx → StylePanelDoubleDropdownPicker.tsx} +28 -19
  236. package/src/lib/ui/components/StylePanel/StylePanelDropdownPicker.tsx +119 -0
  237. package/src/lib/ui/components/StylePanel/StylePanelSubheading.tsx +9 -0
  238. package/src/lib/ui/components/Toolbar/AltTextEditor.tsx +2 -0
  239. package/src/lib/ui/components/Toolbar/DefaultImageToolbarContent.tsx +32 -15
  240. package/src/lib/ui/components/Toolbar/DefaultVideoToolbarContent.tsx +12 -4
  241. package/src/lib/ui/components/Toolbar/LinkEditor.tsx +1 -0
  242. package/src/lib/ui/components/Toolbar/OverflowingToolbar.tsx +1 -1
  243. package/src/lib/ui/components/Toolbar/ToggleToolLockedButton.tsx +9 -2
  244. package/src/lib/ui/components/primitives/TldrawUiContextualToolbar.tsx +7 -3
  245. package/src/lib/ui/components/primitives/TldrawUiInput.tsx +6 -3
  246. package/src/lib/ui/components/primitives/TldrawUiSlider.tsx +52 -32
  247. package/src/lib/ui/components/primitives/TldrawUiToolbar.tsx +5 -1
  248. package/src/lib/ui/components/primitives/TldrawUiTooltip.tsx +67 -13
  249. package/src/lib/ui/components/primitives/menus/TldrawUiMenuCheckboxItem.tsx +4 -0
  250. package/src/lib/ui/components/primitives/menus/TldrawUiMenuItem.tsx +9 -9
  251. package/src/lib/ui/context/actions.tsx +20 -8
  252. package/src/lib/ui/hooks/useClipboardEvents.ts +1 -2
  253. package/src/lib/ui/hooks/useExportAs.ts +3 -2
  254. package/src/lib/ui/hooks/useTools.tsx +1 -1
  255. package/src/lib/ui/hooks/useTranslation/TLUiTranslationKey.ts +3 -0
  256. package/src/lib/ui/hooks/useTranslation/defaultTranslation.ts +5 -2
  257. package/src/lib/ui/version.ts +3 -3
  258. package/src/lib/ui.css +40 -3
  259. package/src/lib/utils/export/copyAs.ts +1 -24
  260. package/src/lib/utils/export/export.ts +0 -36
  261. package/src/lib/utils/export/exportAs.ts +1 -32
  262. package/src/test/TestEditor.ts +8 -2
  263. package/src/test/frames.test.ts +15 -0
  264. package/src/test/getCulledShapes.test.tsx +71 -2
  265. package/tldraw.css +48 -6
  266. package/dist-cjs/lib/ui/components/StylePanel/DoubleDropdownPicker.js.map +0 -7
  267. package/dist-cjs/lib/ui/components/StylePanel/DropdownPicker.js.map +0 -7
  268. package/dist-cjs/lib/ui/components/primitives/TldrawUiButtonPicker.js +0 -131
  269. package/dist-cjs/lib/ui/components/primitives/TldrawUiButtonPicker.js.map +0 -7
  270. package/dist-esm/lib/ui/components/StylePanel/DoubleDropdownPicker.mjs.map +0 -7
  271. package/dist-esm/lib/ui/components/StylePanel/DropdownPicker.mjs.map +0 -7
  272. package/dist-esm/lib/ui/components/primitives/TldrawUiButtonPicker.mjs +0 -115
  273. package/dist-esm/lib/ui/components/primitives/TldrawUiButtonPicker.mjs.map +0 -7
  274. package/src/lib/ui/components/StylePanel/DropdownPicker.tsx +0 -110
package/src/lib/ui.css CHANGED
@@ -168,7 +168,7 @@
168
168
  min-height: 40px;
169
169
  width: 100%;
170
170
  gap: 8px;
171
- margin: -4px 0px;
171
+ margin-top: -4px;
172
172
  }
173
173
 
174
174
  .tlui-button__menu::after {
@@ -494,6 +494,10 @@
494
494
  -webkit-user-select: auto !important;
495
495
  }
496
496
 
497
+ .tlui-input::placeholder {
498
+ color: var(--tl-color-text-3);
499
+ }
500
+
497
501
  .tlui-input__wrapper {
498
502
  width: 100%;
499
503
  height: 44px;
@@ -578,6 +582,12 @@
578
582
  box-shadow: var(--tl-shadow-3);
579
583
  }
580
584
 
585
+ @media (max-height: 600px) {
586
+ .tlui-menu {
587
+ max-height: 70vh;
588
+ }
589
+ }
590
+
581
591
  .tlui-menu::-webkit-scrollbar {
582
592
  display: none;
583
593
  }
@@ -1007,21 +1017,48 @@
1007
1017
  flex-direction: column;
1008
1018
  }
1009
1019
 
1010
- .tlui-style-panel__section:nth-of-type(n + 2):not(:last-child) {
1020
+ /*
1021
+ add a border to the bottom of all but the last section. we have to handle empty sections too, which
1022
+ are hidden and shouldn't be counted
1023
+ */
1024
+ .tlui-style-panel__section:not(:nth-last-child(-n + 1 of .tlui-style-panel__section:not(:empty))) {
1011
1025
  border-bottom: 1px solid var(--tl-color-divider);
1012
1026
  }
1027
+ /*
1028
+ if a section ends with a slider and we're adding a border, we need some extra space for visual
1029
+ balance. we need to handle empty sections as above. is this the most complex css selector in all of
1030
+ tldraw? probably.
1031
+ */
1032
+ .tlui-style-panel__section:has(.tlui-slider__container:last-child):not(
1033
+ :nth-last-child(-n + 1 of .tlui-style-panel__section:not(:empty))
1034
+ ) {
1035
+ margin-bottom: 7px;
1036
+ }
1013
1037
 
1014
1038
  .tlui-style-panel__section:empty {
1015
1039
  display: none;
1016
1040
  }
1017
1041
 
1042
+ /*
1043
+ * This is used in a couple places, like Align and Vertical Align.
1044
+ * It's because we have a toolbar with a Toggle Group but then an adjacent button
1045
+ * next to it that opens a popup.
1046
+ */
1047
+ .tlui-style-panel__section .tlui-toolbar:has(.tlui-toolbar) {
1048
+ flex-wrap: wrap;
1049
+ }
1050
+
1051
+ .tlui-style-panel__section .tlui-toolbar:has(.tlui-toolbar) .tlui-style-panel__subheading {
1052
+ margin-left: -2px;
1053
+ }
1054
+
1018
1055
  .tlui-style-panel__section__common:not(:only-child) {
1019
1056
  margin-bottom: 7px;
1020
1057
  border-bottom: 1px solid var(--tl-color-divider);
1021
1058
  }
1022
1059
 
1023
1060
  .tlui-style-panel__dropdown-picker:only-child {
1024
- width: 100%;
1061
+ flex: 1;
1025
1062
  }
1026
1063
 
1027
1064
  .tlui-style-panel__double-select-picker {
@@ -31,30 +31,7 @@ export interface CopyAsOptions extends TLImageExportOptions {
31
31
  *
32
32
  * @public
33
33
  */
34
- export function copyAs(editor: Editor, ids: TLShapeId[], opts: CopyAsOptions): Promise<void>
35
- /**
36
- * @deprecated The format parameter is now part of the opts object.
37
- * @public
38
- */
39
- export function copyAs(
40
- editor: Editor,
41
- ids: TLShapeId[],
42
- format: TLCopyType,
43
- opts?: TLImageExportOptions & { format?: undefined }
44
- ): Promise<void>
45
- export function copyAs(
46
- ...args:
47
- | [editor: Editor, ids: TLShapeId[], opts: TLImageExportOptions & { format: TLCopyType }]
48
- | [
49
- editor: Editor,
50
- ids: TLShapeId[],
51
- format: TLCopyType,
52
- opts?: TLImageExportOptions & { format?: undefined },
53
- ]
54
- ) {
55
- const [editor, ids, opts] =
56
- typeof args[2] === 'string' ? [args[0], args[1], { ...args[3], format: args[2] }] : args
57
-
34
+ export function copyAs(editor: Editor, ids: TLShapeId[], opts: CopyAsOptions): Promise<void> {
58
35
  // Note: it's important that this function itself isn't async and doesn't really use promises -
59
36
  // we need to create the relevant `ClipboardItem`s and call navigator.clipboard.write
60
37
  // synchronously to make sure safari knows that the user _wants_ to copy See
@@ -1,7 +1,6 @@
1
1
  import {
2
2
  Editor,
3
3
  FileHelpers,
4
- TLExportType,
5
4
  TLImageExportOptions,
6
5
  TLShapeId,
7
6
  exhaustiveSwitchError,
@@ -35,41 +34,6 @@ export async function exportToString(
35
34
  }
36
35
  }
37
36
 
38
- /**
39
- * Export the given shapes as a blob.
40
- * @param editor - The editor instance.
41
- * @param ids - The ids of the shapes to export.
42
- * @param format - The format to export as.
43
- * @param opts - Rendering options.
44
- * @returns A promise that resolves to a blob.
45
- * @deprecated Use {@link @tldraw/editor#Editor.toImage} instead.
46
- * @public
47
- */
48
- export async function exportToBlob({
49
- editor,
50
- ids,
51
- format,
52
- opts = {},
53
- }: {
54
- editor: Editor
55
- ids: TLShapeId[]
56
- format: TLExportType
57
- opts?: TLImageExportOptions
58
- }): Promise<Blob> {
59
- const idsToUse = ids?.length ? ids : [...editor.getCurrentPageShapeIds()]
60
- switch (format) {
61
- case 'jpeg':
62
- case 'png':
63
- case 'webp':
64
- case 'svg': {
65
- return (await editor.toImage(idsToUse, { ...opts, format })).blob
66
- }
67
- default: {
68
- exhaustiveSwitchError(format)
69
- }
70
- }
71
- }
72
-
73
37
  const clipboardMimeTypesByFormat = {
74
38
  jpeg: 'image/jpeg',
75
39
  png: 'image/png',
@@ -28,38 +28,7 @@ export async function exportAs(
28
28
  editor: Editor,
29
29
  ids: TLShapeId[],
30
30
  opts: ExportAsOptions
31
- ): Promise<void>
32
- /**
33
- * @deprecated The format & name parameters are now part of the opts object.
34
- * @public
35
- */
36
- export async function exportAs(
37
- editor: Editor,
38
- ids: TLShapeId[],
39
- format?: TLExportType,
40
- name?: string,
41
- opts?: TLImageExportOptions
42
- ): Promise<void>
43
- export async function exportAs(
44
- ...args:
45
- | [
46
- editor: Editor,
47
- ids: TLShapeId[],
48
- opts: TLImageExportOptions & { format: TLExportType; name?: string },
49
- ]
50
- | [
51
- editor: Editor,
52
- ids: TLShapeId[],
53
- format?: TLExportType,
54
- name?: string,
55
- opts?: TLImageExportOptions,
56
- ]
57
- ) {
58
- const [editor, ids, opts] =
59
- typeof args[2] === 'object'
60
- ? args
61
- : [args[0], args[1], { ...args[4], format: args[2] ?? 'png', name: args[3] }]
62
-
31
+ ): Promise<void> {
63
32
  // If we don't get name then use a predefined one
64
33
  let name = opts.name
65
34
  if (!name) {
@@ -86,8 +86,14 @@ export class TestEditor extends Editor {
86
86
  elm.tabIndex = 0
87
87
  elm.getBoundingClientRect = () => bounds as DOMRect
88
88
 
89
- const shapeUtilsWithDefaults = [...defaultShapeUtils, ...(options.shapeUtils ?? [])]
90
- const bindingUtilsWithDefaults = [...defaultBindingUtils, ...(options.bindingUtils ?? [])]
89
+ const shapeUtilsWithDefaults = [
90
+ ...defaultShapeUtils.filter((s) => !options.shapeUtils?.some((su) => su.type === s.type)),
91
+ ...(options.shapeUtils ?? []),
92
+ ]
93
+ const bindingUtilsWithDefaults = [
94
+ ...defaultBindingUtils.filter((b) => !options.bindingUtils?.some((bu) => bu.type === b.type)),
95
+ ...(options.bindingUtils ?? []),
96
+ ]
91
97
 
92
98
  super({
93
99
  ...options,
@@ -1680,3 +1680,18 @@ it('drops into the top-most frame, if there is one', () => {
1680
1680
 
1681
1681
  expect(editor.getShape(rect)?.parentId).toBe(editor.getCurrentPageId())
1682
1682
  })
1683
+
1684
+ it('does not get drop children of nested frame if they are occluded from the outer frame', () => {
1685
+ const frame1Id = dragCreateFrame({ down: [100, 100], move: [300, 300], up: [300, 300] })
1686
+ const frame2Id = dragCreateFrame({ down: [150, 150], move: [290, 290], up: [290, 290] })
1687
+
1688
+ const rect1 = createRect({ pos: [280, 160], size: [10, 30] })
1689
+
1690
+ expect(editor.getShape(rect1)?.parentId).toBe(frame2Id)
1691
+ expect(editor.getShape(frame2Id)?.parentId).toBe(frame1Id)
1692
+
1693
+ editor.select(frame2Id)
1694
+ editor.translateSelection(30, 0)
1695
+
1696
+ expect(editor.getShape(rect1)?.parentId).toBe(frame2Id)
1697
+ })
@@ -1,12 +1,50 @@
1
- import { Box, TLShapeId, createShapeId } from '@tldraw/editor'
1
+ import {
2
+ BaseBoxShapeUtil,
3
+ Box,
4
+ RecordProps,
5
+ T,
6
+ TLBaseShape,
7
+ TLShapeId,
8
+ createShapeId,
9
+ } from '@tldraw/editor'
2
10
  import { vi } from 'vitest'
3
11
  import { TestEditor } from './TestEditor'
4
12
  import { TL } from './test-jsx'
5
13
 
14
+ // Custom uncullable shape type for testing canCull override
15
+ type UncullableShape = TLBaseShape<'uncullable', { w: number; h: number }>
16
+
17
+ class UncullableShapeUtil extends BaseBoxShapeUtil<UncullableShape> {
18
+ static override type = 'uncullable' as const
19
+ static override props: RecordProps<UncullableShape> = {
20
+ w: T.number,
21
+ h: T.number,
22
+ }
23
+
24
+ override canCull() {
25
+ return false
26
+ }
27
+
28
+ override getDefaultProps(): UncullableShape['props'] {
29
+ return {
30
+ w: 100,
31
+ h: 100,
32
+ }
33
+ }
34
+
35
+ override component() {
36
+ return <div>Uncullable shape</div>
37
+ }
38
+
39
+ override indicator() {
40
+ return <div>Uncullable shape</div>
41
+ }
42
+ }
43
+
6
44
  let editor: TestEditor
7
45
 
8
46
  beforeEach(() => {
9
- editor = new TestEditor()
47
+ editor = new TestEditor({ shapeUtils: [UncullableShapeUtil] })
10
48
  editor.setScreenBounds({ x: 0, y: 0, w: 1800, h: 900 })
11
49
  })
12
50
 
@@ -203,3 +241,34 @@ it('works for shapes that are outside of the viewport, but are then moved inside
203
241
  // Arrow should also not be culled
204
242
  expect(editor.getCulledShapes()).toEqual(new Set())
205
243
  })
244
+
245
+ it('respects canCull override - shapes that cannot be culled are never culled', () => {
246
+ const cullableShapeId = createShapeId()
247
+ const uncullableShapeId = createShapeId()
248
+
249
+ // Create both shapes outside the viewport
250
+ editor.createShapes([
251
+ {
252
+ id: cullableShapeId,
253
+ type: 'geo',
254
+ x: -2000, // Way outside viewport
255
+ y: -2000,
256
+ props: { w: 100, h: 100 },
257
+ },
258
+ {
259
+ id: uncullableShapeId,
260
+ type: 'uncullable',
261
+ x: -2000, // Way outside viewport
262
+ y: -2000,
263
+ props: { w: 100, h: 100 },
264
+ },
265
+ ])
266
+
267
+ const culledShapes = editor.getCulledShapes()
268
+
269
+ // The regular geo shape should be culled since it's outside the viewport
270
+ expect(culledShapes).toContain(cullableShapeId)
271
+
272
+ // The uncullable shape should NOT be culled even though it's outside the viewport
273
+ expect(culledShapes).not.toContain(uncullableShapeId)
274
+ })
package/tldraw.css CHANGED
@@ -693,11 +693,17 @@ input,
693
693
  }
694
694
 
695
695
  .tl-text-measure {
696
- position: absolute;
697
696
  z-index: var(--tl-layer-canvas-hidden);
697
+ opacity: 0;
698
+ visibility: hidden;
699
+
700
+ /* pointer-events: all; */
701
+ /* opacity: 1; */
702
+ /* z-index: 99999; */
703
+
704
+ position: absolute;
698
705
  top: 0px;
699
706
  left: 0px;
700
- opacity: 0;
701
707
  width: max-content;
702
708
  box-sizing: border-box;
703
709
  pointer-events: none;
@@ -708,7 +714,6 @@ input,
708
714
  border: none;
709
715
  user-select: none;
710
716
  contain: style paint;
711
- visibility: hidden;
712
717
  /* N.B. This property, while discouraged ("intended for Document Type Definition (DTD) designers") is necessary for ensuring correct mixed RTL/LTR behavior when exporting SVGs. */
713
718
  unicode-bidi: plaintext;
714
719
  -webkit-user-select: none;
@@ -1959,7 +1964,7 @@ it from receiving any pointer events or affecting the cursor. */
1959
1964
  min-height: 40px;
1960
1965
  width: 100%;
1961
1966
  gap: 8px;
1962
- margin: -4px 0px;
1967
+ margin-top: -4px;
1963
1968
  }
1964
1969
 
1965
1970
  .tlui-button__menu::after {
@@ -2285,6 +2290,10 @@ it from receiving any pointer events or affecting the cursor. */
2285
2290
  -webkit-user-select: auto !important;
2286
2291
  }
2287
2292
 
2293
+ .tlui-input::placeholder {
2294
+ color: var(--tl-color-text-3);
2295
+ }
2296
+
2288
2297
  .tlui-input__wrapper {
2289
2298
  width: 100%;
2290
2299
  height: 44px;
@@ -2369,6 +2378,12 @@ it from receiving any pointer events or affecting the cursor. */
2369
2378
  box-shadow: var(--tl-shadow-3);
2370
2379
  }
2371
2380
 
2381
+ @media (max-height: 600px) {
2382
+ .tlui-menu {
2383
+ max-height: 70vh;
2384
+ }
2385
+ }
2386
+
2372
2387
  .tlui-menu::-webkit-scrollbar {
2373
2388
  display: none;
2374
2389
  }
@@ -2798,21 +2813,48 @@ it from receiving any pointer events or affecting the cursor. */
2798
2813
  flex-direction: column;
2799
2814
  }
2800
2815
 
2801
- .tlui-style-panel__section:nth-of-type(n + 2):not(:last-child) {
2816
+ /*
2817
+ add a border to the bottom of all but the last section. we have to handle empty sections too, which
2818
+ are hidden and shouldn't be counted
2819
+ */
2820
+ .tlui-style-panel__section:not(:nth-last-child(-n + 1 of .tlui-style-panel__section:not(:empty))) {
2802
2821
  border-bottom: 1px solid var(--tl-color-divider);
2803
2822
  }
2823
+ /*
2824
+ if a section ends with a slider and we're adding a border, we need some extra space for visual
2825
+ balance. we need to handle empty sections as above. is this the most complex css selector in all of
2826
+ tldraw? probably.
2827
+ */
2828
+ .tlui-style-panel__section:has(.tlui-slider__container:last-child):not(
2829
+ :nth-last-child(-n + 1 of .tlui-style-panel__section:not(:empty))
2830
+ ) {
2831
+ margin-bottom: 7px;
2832
+ }
2804
2833
 
2805
2834
  .tlui-style-panel__section:empty {
2806
2835
  display: none;
2807
2836
  }
2808
2837
 
2838
+ /*
2839
+ * This is used in a couple places, like Align and Vertical Align.
2840
+ * It's because we have a toolbar with a Toggle Group but then an adjacent button
2841
+ * next to it that opens a popup.
2842
+ */
2843
+ .tlui-style-panel__section .tlui-toolbar:has(.tlui-toolbar) {
2844
+ flex-wrap: wrap;
2845
+ }
2846
+
2847
+ .tlui-style-panel__section .tlui-toolbar:has(.tlui-toolbar) .tlui-style-panel__subheading {
2848
+ margin-left: -2px;
2849
+ }
2850
+
2809
2851
  .tlui-style-panel__section__common:not(:only-child) {
2810
2852
  margin-bottom: 7px;
2811
2853
  border-bottom: 1px solid var(--tl-color-divider);
2812
2854
  }
2813
2855
 
2814
2856
  .tlui-style-panel__dropdown-picker:only-child {
2815
- width: 100%;
2857
+ flex: 1;
2816
2858
  }
2817
2859
 
2818
2860
  .tlui-style-panel__double-select-picker {
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../../src/lib/ui/components/StylePanel/DoubleDropdownPicker.tsx"],
4
- "sourcesContent": ["import { SharedStyle, StyleProp, tlmenus, useEditor } from '@tldraw/editor'\nimport * as React from 'react'\nimport { StyleValuesForUi } from '../../../styles'\nimport { TLUiTranslationKey } from '../../hooks/useTranslation/TLUiTranslationKey'\nimport { useTranslation } from '../../hooks/useTranslation/useTranslation'\nimport { TldrawUiButtonIcon } from '../primitives/Button/TldrawUiButtonIcon'\nimport {\n\tTldrawUiPopover,\n\tTldrawUiPopoverContent,\n\tTldrawUiPopoverTrigger,\n} from '../primitives/TldrawUiPopover'\nimport { TldrawUiToolbar, TldrawUiToolbarButton } from '../primitives/TldrawUiToolbar'\nimport { TldrawUiMenuContextProvider } from '../primitives/menus/TldrawUiMenuContext'\n\ninterface DoubleDropdownPickerProps<T extends string> {\n\tuiTypeA: string\n\tuiTypeB: string\n\tlabel: TLUiTranslationKey | Exclude<string, TLUiTranslationKey>\n\tlabelA: TLUiTranslationKey | Exclude<string, TLUiTranslationKey>\n\tlabelB: TLUiTranslationKey | Exclude<string, TLUiTranslationKey>\n\titemsA: StyleValuesForUi<T>\n\titemsB: StyleValuesForUi<T>\n\tstyleA: StyleProp<T>\n\tstyleB: StyleProp<T>\n\tvalueA: SharedStyle<T>\n\tvalueB: SharedStyle<T>\n\tonValueChange(style: StyleProp<T>, value: T): void\n}\n\nfunction DoubleDropdownPickerInner<T extends string>({\n\tlabel,\n\tuiTypeA,\n\tuiTypeB,\n\tlabelA,\n\tlabelB,\n\titemsA,\n\titemsB,\n\tstyleA,\n\tstyleB,\n\tvalueA,\n\tvalueB,\n\tonValueChange,\n}: DoubleDropdownPickerProps<T>) {\n\tconst editor = useEditor()\n\tconst msg = useTranslation()\n\tconst [isOpenA, setIsOpenA] = React.useState(false)\n\tconst [isOpenB, setIsOpenB] = React.useState(false)\n\n\tconst iconA = React.useMemo(\n\t\t() =>\n\t\t\titemsA.find((item) => valueA.type === 'shared' && valueA.value === item.value)?.icon ??\n\t\t\t'mixed',\n\t\t[itemsA, valueA]\n\t)\n\tconst iconB = React.useMemo(\n\t\t() =>\n\t\t\titemsB.find((item) => valueB.type === 'shared' && valueB.value === item.value)?.icon ??\n\t\t\t'mixed',\n\t\t[itemsB, valueB]\n\t)\n\n\tif (valueA === undefined && valueB === undefined) return null\n\n\tconst idA = `style panel ${uiTypeA} A`\n\tconst idB = `style panel ${uiTypeB} B`\n\treturn (\n\t\t<div className=\"tlui-style-panel__double-select-picker\">\n\t\t\t<div title={msg(label)} className=\"tlui-style-panel__double-select-picker-label\">\n\t\t\t\t{msg(label)}\n\t\t\t</div>\n\t\t\t<TldrawUiToolbar orientation=\"horizontal\" label={msg(label)}>\n\t\t\t\t<TldrawUiPopover id={idA} open={isOpenA} onOpenChange={setIsOpenA}>\n\t\t\t\t\t<TldrawUiPopoverTrigger>\n\t\t\t\t\t\t<TldrawUiToolbarButton\n\t\t\t\t\t\t\ttype=\"icon\"\n\t\t\t\t\t\t\tdata-testid={`style.${uiTypeA}`}\n\t\t\t\t\t\t\ttitle={\n\t\t\t\t\t\t\t\tmsg(labelA) +\n\t\t\t\t\t\t\t\t' \u2014 ' +\n\t\t\t\t\t\t\t\t(valueA === null || valueA.type === 'mixed'\n\t\t\t\t\t\t\t\t\t? msg('style-panel.mixed')\n\t\t\t\t\t\t\t\t\t: msg(`${uiTypeA}-style.${valueA.value}` as TLUiTranslationKey))\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<TldrawUiButtonIcon icon={iconA} small invertIcon />\n\t\t\t\t\t\t</TldrawUiToolbarButton>\n\t\t\t\t\t</TldrawUiPopoverTrigger>\n\t\t\t\t\t<TldrawUiPopoverContent side=\"left\" align=\"center\" sideOffset={80} alignOffset={0}>\n\t\t\t\t\t\t<TldrawUiToolbar orientation=\"grid\" label={msg(labelA)}>\n\t\t\t\t\t\t\t<TldrawUiMenuContextProvider type=\"icons\" sourceId=\"style-panel\">\n\t\t\t\t\t\t\t\t{itemsA.map((item) => {\n\t\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t\t<TldrawUiToolbarButton\n\t\t\t\t\t\t\t\t\t\t\tdata-testid={`style.${uiTypeA}.${item.value}`}\n\t\t\t\t\t\t\t\t\t\t\ttype=\"icon\"\n\t\t\t\t\t\t\t\t\t\t\tkey={item.value}\n\t\t\t\t\t\t\t\t\t\t\tonClick={() => {\n\t\t\t\t\t\t\t\t\t\t\t\tonValueChange(styleA, item.value)\n\t\t\t\t\t\t\t\t\t\t\t\ttlmenus.deleteOpenMenu(idA, editor.contextId)\n\t\t\t\t\t\t\t\t\t\t\t\tsetIsOpenA(false)\n\t\t\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\t\t\ttitle={`${msg(labelA)} \u2014 ${msg(`${uiTypeA}-style.${item.value}`)}`}\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t<TldrawUiButtonIcon icon={item.icon} invertIcon />\n\t\t\t\t\t\t\t\t\t\t</TldrawUiToolbarButton>\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t})}\n\t\t\t\t\t\t\t</TldrawUiMenuContextProvider>\n\t\t\t\t\t\t</TldrawUiToolbar>\n\t\t\t\t\t</TldrawUiPopoverContent>\n\t\t\t\t</TldrawUiPopover>\n\t\t\t\t<TldrawUiPopover id={idB} open={isOpenB} onOpenChange={setIsOpenB}>\n\t\t\t\t\t<TldrawUiPopoverTrigger>\n\t\t\t\t\t\t<TldrawUiToolbarButton\n\t\t\t\t\t\t\ttype=\"icon\"\n\t\t\t\t\t\t\tdata-testid={`style.${uiTypeB}`}\n\t\t\t\t\t\t\ttitle={\n\t\t\t\t\t\t\t\tmsg(labelB) +\n\t\t\t\t\t\t\t\t' \u2014 ' +\n\t\t\t\t\t\t\t\t(valueB === null || valueB.type === 'mixed'\n\t\t\t\t\t\t\t\t\t? msg('style-panel.mixed')\n\t\t\t\t\t\t\t\t\t: msg(`${uiTypeB}-style.${valueB.value}` as TLUiTranslationKey))\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<TldrawUiButtonIcon icon={iconB} small />\n\t\t\t\t\t\t</TldrawUiToolbarButton>\n\t\t\t\t\t</TldrawUiPopoverTrigger>\n\t\t\t\t\t<TldrawUiPopoverContent side=\"left\" align=\"center\" sideOffset={116} alignOffset={0}>\n\t\t\t\t\t\t<TldrawUiToolbar orientation=\"grid\" label={msg(labelB)}>\n\t\t\t\t\t\t\t<TldrawUiMenuContextProvider type=\"icons\" sourceId=\"style-panel\">\n\t\t\t\t\t\t\t\t{itemsB.map((item) => {\n\t\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t\t<TldrawUiToolbarButton\n\t\t\t\t\t\t\t\t\t\t\tkey={item.value}\n\t\t\t\t\t\t\t\t\t\t\ttype=\"icon\"\n\t\t\t\t\t\t\t\t\t\t\ttitle={`${msg(labelB)} \u2014 ${msg(`${uiTypeB}-style.${item.value}` as TLUiTranslationKey)}`}\n\t\t\t\t\t\t\t\t\t\t\tdata-testid={`style.${uiTypeB}.${item.value}`}\n\t\t\t\t\t\t\t\t\t\t\tonClick={() => {\n\t\t\t\t\t\t\t\t\t\t\t\tonValueChange(styleB, item.value)\n\t\t\t\t\t\t\t\t\t\t\t\ttlmenus.deleteOpenMenu(idB, editor.contextId)\n\t\t\t\t\t\t\t\t\t\t\t\tsetIsOpenB(false)\n\t\t\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t<TldrawUiButtonIcon icon={item.icon} />\n\t\t\t\t\t\t\t\t\t\t</TldrawUiToolbarButton>\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t})}\n\t\t\t\t\t\t\t</TldrawUiMenuContextProvider>\n\t\t\t\t\t\t</TldrawUiToolbar>\n\t\t\t\t\t</TldrawUiPopoverContent>\n\t\t\t\t</TldrawUiPopover>\n\t\t\t</TldrawUiToolbar>\n\t\t</div>\n\t)\n}\n\n// need to memo like this to get generics\nexport const DoubleDropdownPicker = React.memo(\n\tDoubleDropdownPickerInner\n) as typeof DoubleDropdownPickerInner\n"],
5
- "mappings": ";;;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AAAA,QACA,4CAAC,iDAAuB,MAAK,QAAO,OAAM,UAAS,YAAY,KAAK,aAAa,GAChF,sDAAC,0CAAgB,aAAY,QAAO,OAAO,IAAI,MAAM,GACpD,sDAAC,0DAA4B,MAAK,SAAQ,UAAS,eACjD,iBAAO,IAAI,CAAC,SAAS;AACrB,iBACC;AAAA,YAAC;AAAA;AAAA,cAEA,MAAK;AAAA,cACL,OAAO,GAAG,IAAI,MAAM,CAAC,WAAM,IAAI,GAAG,OAAO,UAAU,KAAK,KAAK,EAAwB,CAAC;AAAA,cACtF,eAAa,SAAS,OAAO,IAAI,KAAK,KAAK;AAAA,cAC3C,SAAS,MAAM;AACd,8BAAc,QAAQ,KAAK,KAAK;AAChC,sCAAQ,eAAe,KAAK,OAAO,SAAS;AAC5C,2BAAW,KAAK;AAAA,cACjB;AAAA,cAEA,sDAAC,gDAAmB,MAAM,KAAK,MAAM;AAAA;AAAA,YAVhC,KAAK;AAAA,UAWX;AAAA,QAEF,CAAC,GACF,GACD,GACD;AAAA,SACD;AAAA,OACD;AAAA,KACD;AAEF;AAGO,MAAM,uBAAuB,MAAM;AAAA,EACzC;AACD;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../../src/lib/ui/components/StylePanel/DropdownPicker.tsx"],
4
- "sourcesContent": ["import { SharedStyle, StyleProp, tlmenus, useEditor } from '@tldraw/editor'\nimport * as React from 'react'\nimport { StyleValuesForUi } from '../../../styles'\nimport { TLUiTranslationKey } from '../../hooks/useTranslation/TLUiTranslationKey'\nimport { useTranslation } from '../../hooks/useTranslation/useTranslation'\nimport { TLUiIconType } from '../../icon-types'\nimport { TldrawUiButtonIcon } from '../primitives/Button/TldrawUiButtonIcon'\nimport { TldrawUiButtonLabel } from '../primitives/Button/TldrawUiButtonLabel'\nimport {\n\tTldrawUiPopover,\n\tTldrawUiPopoverContent,\n\tTldrawUiPopoverTrigger,\n} from '../primitives/TldrawUiPopover'\nimport { TldrawUiToolbar, TldrawUiToolbarButton } from '../primitives/TldrawUiToolbar'\nimport { TldrawUiMenuContextProvider } from '../primitives/menus/TldrawUiMenuContext'\n\ninterface DropdownPickerProps<T extends string> {\n\tid: string\n\tlabel?: TLUiTranslationKey | Exclude<string, TLUiTranslationKey>\n\tuiType: string\n\tstylePanelType: string\n\tstyle: StyleProp<T>\n\tvalue: SharedStyle<T>\n\titems: StyleValuesForUi<T>\n\ttype: 'icon' | 'tool' | 'menu'\n\tonValueChange(style: StyleProp<T>, value: T): void\n}\n\nfunction DropdownPickerInner<T extends string>({\n\tid,\n\tlabel,\n\tuiType,\n\tstylePanelType,\n\tstyle,\n\titems,\n\ttype,\n\tvalue,\n\tonValueChange,\n}: DropdownPickerProps<T>) {\n\tconst msg = useTranslation()\n\tconst editor = useEditor()\n\tconst [isOpen, setIsOpen] = React.useState(false)\n\n\tconst icon = React.useMemo(\n\t\t() => items.find((item) => value.type === 'shared' && item.value === value.value)?.icon,\n\t\t[items, value]\n\t)\n\n\tconst stylePanelName = msg(`style-panel.${stylePanelType}` as TLUiTranslationKey)\n\n\tconst titleStr =\n\t\tvalue.type === 'mixed'\n\t\t\t? msg('style-panel.mixed')\n\t\t\t: stylePanelName + ' \u2014 ' + msg(`${uiType}-style.${value.value}` as TLUiTranslationKey)\n\tconst labelStr = label ? msg(label) : ''\n\n\tconst popoverId = `style panel ${id}`\n\treturn (\n\t\t<TldrawUiPopover\n\t\t\tid={popoverId}\n\t\t\topen={isOpen}\n\t\t\tonOpenChange={setIsOpen}\n\t\t\tclassName=\"tlui-style-panel__dropdown-picker\"\n\t\t>\n\t\t\t<TldrawUiPopoverTrigger>\n\t\t\t\t<TldrawUiToolbarButton\n\t\t\t\t\ttype={type}\n\t\t\t\t\tdata-testid={`style.${uiType}`}\n\t\t\t\t\tdata-direction=\"left\"\n\t\t\t\t\ttitle={titleStr}\n\t\t\t\t>\n\t\t\t\t\t{labelStr && <TldrawUiButtonLabel>{labelStr}</TldrawUiButtonLabel>}\n\t\t\t\t\t<TldrawUiButtonIcon icon={(icon as TLUiIconType) ?? 'mixed'} />\n\t\t\t\t</TldrawUiToolbarButton>\n\t\t\t</TldrawUiPopoverTrigger>\n\t\t\t<TldrawUiPopoverContent side=\"left\" align=\"center\">\n\t\t\t\t<TldrawUiToolbar orientation={items.length > 4 ? 'grid' : 'horizontal'} label={labelStr}>\n\t\t\t\t\t<TldrawUiMenuContextProvider type=\"icons\" sourceId=\"style-panel\">\n\t\t\t\t\t\t{items.map((item) => {\n\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t<TldrawUiToolbarButton\n\t\t\t\t\t\t\t\t\tkey={item.value}\n\t\t\t\t\t\t\t\t\ttype=\"icon\"\n\t\t\t\t\t\t\t\t\tdata-testid={`style.${uiType}.${item.value}`}\n\t\t\t\t\t\t\t\t\ttitle={\n\t\t\t\t\t\t\t\t\t\tstylePanelName +\n\t\t\t\t\t\t\t\t\t\t' \u2014 ' +\n\t\t\t\t\t\t\t\t\t\tmsg(`${uiType}-style.${item.value}` as TLUiTranslationKey)\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tisActive={icon === item.icon}\n\t\t\t\t\t\t\t\t\tonClick={() => {\n\t\t\t\t\t\t\t\t\t\teditor.markHistoryStoppingPoint('select style dropdown item')\n\t\t\t\t\t\t\t\t\t\tonValueChange(style, item.value)\n\t\t\t\t\t\t\t\t\t\ttlmenus.deleteOpenMenu(popoverId, editor.contextId)\n\t\t\t\t\t\t\t\t\t\tsetIsOpen(false)\n\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<TldrawUiButtonIcon icon={item.icon} />\n\t\t\t\t\t\t\t\t</TldrawUiToolbarButton>\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t})}\n\t\t\t\t\t</TldrawUiMenuContextProvider>\n\t\t\t\t</TldrawUiToolbar>\n\t\t\t</TldrawUiPopoverContent>\n\t\t</TldrawUiPopover>\n\t)\n}\n\n// need to export like this to get generics\nexport const DropdownPicker = React.memo(DropdownPickerInner) as typeof DropdownPickerInner\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAiEI;AAjEJ,oBAA2D;AAC3D,YAAuB;AAGvB,4BAA+B;AAE/B,gCAAmC;AACnC,iCAAoC;AACpC,6BAIO;AACP,6BAAuD;AACvD,iCAA4C;AAc5C,SAAS,oBAAsC;AAAA,EAC9C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAA2B;AAC1B,QAAM,UAAM,sCAAe;AAC3B,QAAM,aAAS,yBAAU;AACzB,QAAM,CAAC,QAAQ,SAAS,IAAI,MAAM,SAAS,KAAK;AAEhD,QAAM,OAAO,MAAM;AAAA,IAClB,MAAM,MAAM,KAAK,CAAC,SAAS,MAAM,SAAS,YAAY,KAAK,UAAU,MAAM,KAAK,GAAG;AAAA,IACnF,CAAC,OAAO,KAAK;AAAA,EACd;AAEA,QAAM,iBAAiB,IAAI,eAAe,cAAc,EAAwB;AAEhF,QAAM,WACL,MAAM,SAAS,UACZ,IAAI,mBAAmB,IACvB,iBAAiB,aAAQ,IAAI,GAAG,MAAM,UAAU,MAAM,KAAK,EAAwB;AACvF,QAAM,WAAW,QAAQ,IAAI,KAAK,IAAI;AAEtC,QAAM,YAAY,eAAe,EAAE;AACnC,SACC;AAAA,IAAC;AAAA;AAAA,MACA,IAAI;AAAA,MACJ,MAAM;AAAA,MACN,cAAc;AAAA,MACd,WAAU;AAAA,MAEV;AAAA,oDAAC,iDACA;AAAA,UAAC;AAAA;AAAA,YACA;AAAA,YACA,eAAa,SAAS,MAAM;AAAA,YAC5B,kBAAe;AAAA,YACf,OAAO;AAAA,YAEN;AAAA,0BAAY,4CAAC,kDAAqB,oBAAS;AAAA,cAC5C,4CAAC,gDAAmB,MAAO,QAAyB,SAAS;AAAA;AAAA;AAAA,QAC9D,GACD;AAAA,QACA,4CAAC,iDAAuB,MAAK,QAAO,OAAM,UACzC,sDAAC,0CAAgB,aAAa,MAAM,SAAS,IAAI,SAAS,cAAc,OAAO,UAC9E,sDAAC,0DAA4B,MAAK,SAAQ,UAAS,eACjD,gBAAM,IAAI,CAAC,SAAS;AACpB,iBACC;AAAA,YAAC;AAAA;AAAA,cAEA,MAAK;AAAA,cACL,eAAa,SAAS,MAAM,IAAI,KAAK,KAAK;AAAA,cAC1C,OACC,iBACA,aACA,IAAI,GAAG,MAAM,UAAU,KAAK,KAAK,EAAwB;AAAA,cAE1D,UAAU,SAAS,KAAK;AAAA,cACxB,SAAS,MAAM;AACd,uBAAO,yBAAyB,4BAA4B;AAC5D,8BAAc,OAAO,KAAK,KAAK;AAC/B,sCAAQ,eAAe,WAAW,OAAO,SAAS;AAClD,0BAAU,KAAK;AAAA,cAChB;AAAA,cAEA,sDAAC,gDAAmB,MAAM,KAAK,MAAM;AAAA;AAAA,YAhBhC,KAAK;AAAA,UAiBX;AAAA,QAEF,CAAC,GACF,GACD,GACD;AAAA;AAAA;AAAA,EACD;AAEF;AAGO,MAAM,iBAAiB,MAAM,KAAK,mBAAmB;",
6
- "names": []
7
- }
@@ -1,131 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var TldrawUiButtonPicker_exports = {};
20
- __export(TldrawUiButtonPicker_exports, {
21
- TldrawUiButtonPicker: () => TldrawUiButtonPicker
22
- });
23
- module.exports = __toCommonJS(TldrawUiButtonPicker_exports);
24
- var import_jsx_runtime = require("react/jsx-runtime");
25
- var import_editor = require("@tldraw/editor");
26
- var import_react = require("react");
27
- var import_constants = require("../../constants");
28
- var import_breakpoints = require("../../context/breakpoints");
29
- var import_useTranslation = require("../../hooks/useTranslation/useTranslation");
30
- var import_TldrawUiButtonIcon = require("./Button/TldrawUiButtonIcon");
31
- var import_TldrawUiToolbar = require("./TldrawUiToolbar");
32
- var import_layout = require("./layout");
33
- const TldrawUiButtonPicker = (0, import_react.memo)(function TldrawUiButtonPicker2(props) {
34
- const {
35
- uiType,
36
- items,
37
- title,
38
- style,
39
- value,
40
- // columns = clamp(items.length, 2, 4),
41
- onValueChange,
42
- onHistoryMark,
43
- theme
44
- } = props;
45
- const editor = (0, import_editor.useEditor)();
46
- const msg = (0, import_useTranslation.useTranslation)();
47
- const breakpoint = (0, import_breakpoints.useBreakpoint)();
48
- const rPointing = (0, import_react.useRef)(false);
49
- const rPointingOriginalActiveElement = (0, import_react.useRef)(null);
50
- const {
51
- handleButtonClick,
52
- handleButtonPointerDown,
53
- handleButtonPointerEnter,
54
- handleButtonPointerUp
55
- } = (0, import_react.useMemo)(() => {
56
- const handlePointerUp = () => {
57
- rPointing.current = false;
58
- window.removeEventListener("pointerup", handlePointerUp);
59
- const origActiveEl = rPointingOriginalActiveElement.current;
60
- if (origActiveEl && (["TEXTAREA", "INPUT"].includes(origActiveEl.nodeName) || origActiveEl.isContentEditable)) {
61
- origActiveEl.focus();
62
- } else if (breakpoint >= import_constants.PORTRAIT_BREAKPOINT.TABLET_SM) {
63
- editor.getContainer().focus();
64
- }
65
- rPointingOriginalActiveElement.current = null;
66
- };
67
- const handleButtonClick2 = (e) => {
68
- const { id } = e.currentTarget.dataset;
69
- if (value.type === "shared" && value.value === id) return;
70
- onHistoryMark?.("point picker item");
71
- onValueChange(style, id);
72
- };
73
- const handleButtonPointerDown2 = (e) => {
74
- const { id } = e.currentTarget.dataset;
75
- onHistoryMark?.("point picker item");
76
- onValueChange(style, id);
77
- rPointing.current = true;
78
- rPointingOriginalActiveElement.current = document.activeElement;
79
- window.addEventListener("pointerup", handlePointerUp);
80
- };
81
- const handleButtonPointerEnter2 = (e) => {
82
- if (!rPointing.current) return;
83
- const { id } = e.currentTarget.dataset;
84
- onValueChange(style, id);
85
- };
86
- const handleButtonPointerUp2 = (e) => {
87
- const { id } = e.currentTarget.dataset;
88
- if (value.type === "shared" && value.value === id) return;
89
- onValueChange(style, id);
90
- };
91
- return {
92
- handleButtonClick: handleButtonClick2,
93
- handleButtonPointerDown: handleButtonPointerDown2,
94
- handleButtonPointerEnter: handleButtonPointerEnter2,
95
- handleButtonPointerUp: handleButtonPointerUp2
96
- };
97
- }, [editor, breakpoint, value, onHistoryMark, onValueChange, style]);
98
- const Wrapper = items.length > 4 ? import_layout.TldrawUiGrid : import_layout.TldrawUiRow;
99
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Wrapper, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
100
- import_TldrawUiToolbar.TldrawUiToolbarToggleGroup,
101
- {
102
- "data-testid": `style.${uiType}`,
103
- type: "single",
104
- value: value.type === "shared" ? value.value : void 0,
105
- children: items.map((item) => {
106
- const label = title + " \u2014 " + msg(`${uiType}-style.${item.value}`);
107
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
108
- import_TldrawUiToolbar.TldrawUiToolbarToggleItem,
109
- {
110
- type: "icon",
111
- "data-id": item.value,
112
- "data-testid": `style.${uiType}.${item.value}`,
113
- "aria-label": label,
114
- value: item.value,
115
- "data-state": value.type === "shared" && value.value === item.value ? "on" : "off",
116
- "data-isactive": value.type === "shared" && value.value === item.value,
117
- title: label,
118
- style: style === import_editor.DefaultColorStyle ? { color: (0, import_editor.getColorValue)(theme, item.value, "solid") } : void 0,
119
- onPointerEnter: handleButtonPointerEnter,
120
- onPointerDown: handleButtonPointerDown,
121
- onPointerUp: handleButtonPointerUp,
122
- onClick: handleButtonClick,
123
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_TldrawUiButtonIcon.TldrawUiButtonIcon, { icon: item.icon })
124
- },
125
- item.value
126
- );
127
- })
128
- }
129
- ) });
130
- });
131
- //# sourceMappingURL=TldrawUiButtonPicker.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../../src/lib/ui/components/primitives/TldrawUiButtonPicker.tsx"],
4
- "sourcesContent": ["import {\n\tDefaultColorStyle,\n\tgetColorValue,\n\tSharedStyle,\n\tStyleProp,\n\tTLDefaultColorStyle,\n\tTLDefaultColorTheme,\n\tuseEditor,\n} from '@tldraw/editor'\nimport { memo, ReactElement, useMemo, useRef } from 'react'\nimport { StyleValuesForUi } from '../../../styles'\nimport { PORTRAIT_BREAKPOINT } from '../../constants'\nimport { useBreakpoint } from '../../context/breakpoints'\nimport { TLUiTranslationKey } from '../../hooks/useTranslation/TLUiTranslationKey'\nimport { useTranslation } from '../../hooks/useTranslation/useTranslation'\nimport { TldrawUiButtonIcon } from './Button/TldrawUiButtonIcon'\nimport { TldrawUiToolbarToggleGroup, TldrawUiToolbarToggleItem } from './TldrawUiToolbar'\nimport { TldrawUiGrid, TldrawUiRow } from './layout'\n\n/** @public */\nexport interface TLUiButtonPickerProps<T extends string> {\n\ttitle: string\n\tuiType: string\n\tstyle: StyleProp<T>\n\tvalue: SharedStyle<T>\n\titems: StyleValuesForUi<T>\n\ttheme: TLDefaultColorTheme\n\tonValueChange(style: StyleProp<T>, value: T): void\n\tonHistoryMark?(id: string): void\n}\n\n/** @public */\nexport const TldrawUiButtonPicker = memo(function TldrawUiButtonPicker<T extends string>(\n\tprops: TLUiButtonPickerProps<T>\n) {\n\tconst {\n\t\tuiType,\n\t\titems,\n\t\ttitle,\n\t\tstyle,\n\t\tvalue,\n\t\t// columns = clamp(items.length, 2, 4),\n\t\tonValueChange,\n\t\tonHistoryMark,\n\t\ttheme,\n\t} = props\n\tconst editor = useEditor()\n\tconst msg = useTranslation()\n\tconst breakpoint = useBreakpoint()\n\n\tconst rPointing = useRef(false)\n\tconst rPointingOriginalActiveElement = useRef<HTMLElement | null>(null)\n\n\tconst {\n\t\thandleButtonClick,\n\t\thandleButtonPointerDown,\n\t\thandleButtonPointerEnter,\n\t\thandleButtonPointerUp,\n\t} = useMemo(() => {\n\t\tconst handlePointerUp = () => {\n\t\t\trPointing.current = false\n\t\t\twindow.removeEventListener('pointerup', handlePointerUp)\n\n\t\t\t// This is fun little micro-optimization to make sure that the focus\n\t\t\t// is retained on a text label. That way, you can continue typing\n\t\t\t// after selecting a style.\n\t\t\tconst origActiveEl = rPointingOriginalActiveElement.current\n\t\t\tif (\n\t\t\t\torigActiveEl &&\n\t\t\t\t(['TEXTAREA', 'INPUT'].includes(origActiveEl.nodeName) || origActiveEl.isContentEditable)\n\t\t\t) {\n\t\t\t\torigActiveEl.focus()\n\t\t\t} else if (breakpoint >= PORTRAIT_BREAKPOINT.TABLET_SM) {\n\t\t\t\teditor.getContainer().focus()\n\t\t\t}\n\t\t\trPointingOriginalActiveElement.current = null\n\t\t}\n\n\t\tconst handleButtonClick = (e: React.PointerEvent<HTMLButtonElement>) => {\n\t\t\tconst { id } = e.currentTarget.dataset\n\t\t\tif (value.type === 'shared' && value.value === id) return\n\n\t\t\tonHistoryMark?.('point picker item')\n\t\t\tonValueChange(style, id as T)\n\t\t}\n\n\t\tconst handleButtonPointerDown = (e: React.PointerEvent<HTMLButtonElement>) => {\n\t\t\tconst { id } = e.currentTarget.dataset\n\n\t\t\tonHistoryMark?.('point picker item')\n\t\t\tonValueChange(style, id as T)\n\n\t\t\trPointing.current = true\n\t\t\trPointingOriginalActiveElement.current = document.activeElement as HTMLElement\n\t\t\twindow.addEventListener('pointerup', handlePointerUp) // see TLD-658\n\t\t}\n\n\t\tconst handleButtonPointerEnter = (e: React.PointerEvent<HTMLButtonElement>) => {\n\t\t\tif (!rPointing.current) return\n\n\t\t\tconst { id } = e.currentTarget.dataset\n\t\t\tonValueChange(style, id as T)\n\t\t}\n\n\t\tconst handleButtonPointerUp = (e: React.PointerEvent<HTMLButtonElement>) => {\n\t\t\tconst { id } = e.currentTarget.dataset\n\t\t\tif (value.type === 'shared' && value.value === id) return\n\n\t\t\tonValueChange(style, id as T)\n\t\t}\n\n\t\treturn {\n\t\t\thandleButtonClick,\n\t\t\thandleButtonPointerDown,\n\t\t\thandleButtonPointerEnter,\n\t\t\thandleButtonPointerUp,\n\t\t}\n\t}, [editor, breakpoint, value, onHistoryMark, onValueChange, style])\n\n\tconst Wrapper = items.length > 4 ? TldrawUiGrid : TldrawUiRow\n\n\treturn (\n\t\t<Wrapper asChild>\n\t\t\t<TldrawUiToolbarToggleGroup\n\t\t\t\tdata-testid={`style.${uiType}`}\n\t\t\t\ttype=\"single\"\n\t\t\t\tvalue={value.type === 'shared' ? value.value : undefined}\n\t\t\t>\n\t\t\t\t{items.map((item) => {\n\t\t\t\t\tconst label = title + ' \u2014 ' + msg(`${uiType}-style.${item.value}` as TLUiTranslationKey)\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<TldrawUiToolbarToggleItem\n\t\t\t\t\t\t\ttype=\"icon\"\n\t\t\t\t\t\t\tkey={item.value}\n\t\t\t\t\t\t\tdata-id={item.value}\n\t\t\t\t\t\t\tdata-testid={`style.${uiType}.${item.value}`}\n\t\t\t\t\t\t\taria-label={label}\n\t\t\t\t\t\t\tvalue={item.value}\n\t\t\t\t\t\t\tdata-state={value.type === 'shared' && value.value === item.value ? 'on' : 'off'}\n\t\t\t\t\t\t\tdata-isactive={value.type === 'shared' && value.value === item.value}\n\t\t\t\t\t\t\ttitle={label}\n\t\t\t\t\t\t\tstyle={\n\t\t\t\t\t\t\t\tstyle === (DefaultColorStyle as StyleProp<unknown>)\n\t\t\t\t\t\t\t\t\t? { color: getColorValue(theme, item.value as TLDefaultColorStyle, 'solid') }\n\t\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tonPointerEnter={handleButtonPointerEnter}\n\t\t\t\t\t\t\tonPointerDown={handleButtonPointerDown}\n\t\t\t\t\t\t\tonPointerUp={handleButtonPointerUp}\n\t\t\t\t\t\t\tonClick={handleButtonClick}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<TldrawUiButtonIcon icon={item.icon} />\n\t\t\t\t\t\t</TldrawUiToolbarToggleItem>\n\t\t\t\t\t)\n\t\t\t\t})}\n\t\t\t</TldrawUiToolbarToggleGroup>\n\t\t</Wrapper>\n\t)\n}) as <T extends string>(props: TLUiButtonPickerProps<T>) => ReactElement\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAuJO;AAvJP,oBAQO;AACP,mBAAoD;AAEpD,uBAAoC;AACpC,yBAA8B;AAE9B,4BAA+B;AAC/B,gCAAmC;AACnC,6BAAsE;AACtE,oBAA0C;AAenC,MAAM,2BAAuB,mBAAK,SAASA,sBACjD,OACC;AACD,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAAA,IAEA;AAAA,IACA;AAAA,IACA;AAAA,EACD,IAAI;AACJ,QAAM,aAAS,yBAAU;AACzB,QAAM,UAAM,sCAAe;AAC3B,QAAM,iBAAa,kCAAc;AAEjC,QAAM,gBAAY,qBAAO,KAAK;AAC9B,QAAM,qCAAiC,qBAA2B,IAAI;AAEtE,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,QAAI,sBAAQ,MAAM;AACjB,UAAM,kBAAkB,MAAM;AAC7B,gBAAU,UAAU;AACpB,aAAO,oBAAoB,aAAa,eAAe;AAKvD,YAAM,eAAe,+BAA+B;AACpD,UACC,iBACC,C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