tldraw 3.16.0-canary.f60032f16651 → 3.16.0-canary.ffdf566dd0a8

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 (98) hide show
  1. package/dist-cjs/index.d.ts +32 -34
  2. package/dist-cjs/index.js +7 -2
  3. package/dist-cjs/index.js.map +2 -2
  4. package/dist-cjs/lib/shapes/shared/usePrefersReducedMotion.js +10 -1
  5. package/dist-cjs/lib/shapes/shared/usePrefersReducedMotion.js.map +2 -2
  6. package/dist-cjs/lib/tools/SelectTool/childStates/Translating.js.map +2 -2
  7. package/dist-cjs/lib/ui/components/AccessibilityMenu.js +35 -0
  8. package/dist-cjs/lib/ui/components/AccessibilityMenu.js.map +7 -0
  9. package/dist-cjs/lib/ui/components/MainMenu/DefaultMainMenuContent.js +3 -3
  10. package/dist-cjs/lib/ui/components/MainMenu/DefaultMainMenuContent.js.map +2 -2
  11. package/dist-cjs/lib/ui/components/StylePanel/DefaultStylePanel.js +2 -0
  12. package/dist-cjs/lib/ui/components/StylePanel/DefaultStylePanel.js.map +2 -2
  13. package/dist-cjs/lib/ui/components/StylePanel/DefaultStylePanelContent.js +168 -137
  14. package/dist-cjs/lib/ui/components/StylePanel/DefaultStylePanelContent.js.map +2 -2
  15. package/dist-cjs/lib/ui/components/Toolbar/OverflowingToolbar.js +3 -3
  16. package/dist-cjs/lib/ui/components/Toolbar/OverflowingToolbar.js.map +2 -2
  17. package/dist-cjs/lib/ui/components/Toolbar/ToggleToolLockedButton.js +3 -2
  18. package/dist-cjs/lib/ui/components/Toolbar/ToggleToolLockedButton.js.map +2 -2
  19. package/dist-cjs/lib/ui/components/menu-items.js +6 -0
  20. package/dist-cjs/lib/ui/components/menu-items.js.map +2 -2
  21. package/dist-cjs/lib/ui/components/primitives/TldrawUiToolbar.js +11 -3
  22. package/dist-cjs/lib/ui/components/primitives/TldrawUiToolbar.js.map +2 -2
  23. package/dist-cjs/lib/ui/components/primitives/TldrawUiTooltip.js +267 -0
  24. package/dist-cjs/lib/ui/components/primitives/TldrawUiTooltip.js.map +7 -0
  25. package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuItem.js +1 -149
  26. package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuItem.js.map +2 -2
  27. package/dist-cjs/lib/ui/context/TldrawUiContextProvider.js +3 -2
  28. package/dist-cjs/lib/ui/context/TldrawUiContextProvider.js.map +2 -2
  29. package/dist-cjs/lib/ui/context/actions.js +15 -0
  30. package/dist-cjs/lib/ui/context/actions.js.map +2 -2
  31. package/dist-cjs/lib/ui/context/events.js.map +1 -1
  32. package/dist-cjs/lib/ui/hooks/useTools.js +9 -76
  33. package/dist-cjs/lib/ui/hooks/useTools.js.map +2 -2
  34. package/dist-cjs/lib/ui/hooks/useTranslation/TLUiTranslationKey.js.map +1 -1
  35. package/dist-cjs/lib/ui/hooks/useTranslation/defaultTranslation.js +3 -0
  36. package/dist-cjs/lib/ui/hooks/useTranslation/defaultTranslation.js.map +2 -2
  37. package/dist-cjs/lib/ui/version.js +3 -3
  38. package/dist-cjs/lib/ui/version.js.map +1 -1
  39. package/dist-esm/index.d.mts +32 -34
  40. package/dist-esm/index.mjs +11 -3
  41. package/dist-esm/index.mjs.map +2 -2
  42. package/dist-esm/lib/shapes/shared/usePrefersReducedMotion.mjs +10 -1
  43. package/dist-esm/lib/shapes/shared/usePrefersReducedMotion.mjs.map +2 -2
  44. package/dist-esm/lib/tools/SelectTool/childStates/Translating.mjs.map +2 -2
  45. package/dist-esm/lib/ui/components/AccessibilityMenu.mjs +19 -0
  46. package/dist-esm/lib/ui/components/AccessibilityMenu.mjs.map +7 -0
  47. package/dist-esm/lib/ui/components/MainMenu/DefaultMainMenuContent.mjs +3 -5
  48. package/dist-esm/lib/ui/components/MainMenu/DefaultMainMenuContent.mjs.map +2 -2
  49. package/dist-esm/lib/ui/components/StylePanel/DefaultStylePanel.mjs +3 -1
  50. package/dist-esm/lib/ui/components/StylePanel/DefaultStylePanel.mjs.map +2 -2
  51. package/dist-esm/lib/ui/components/StylePanel/DefaultStylePanelContent.mjs +168 -137
  52. package/dist-esm/lib/ui/components/StylePanel/DefaultStylePanelContent.mjs.map +2 -2
  53. package/dist-esm/lib/ui/components/Toolbar/OverflowingToolbar.mjs +3 -3
  54. package/dist-esm/lib/ui/components/Toolbar/OverflowingToolbar.mjs.map +2 -2
  55. package/dist-esm/lib/ui/components/Toolbar/ToggleToolLockedButton.mjs +3 -2
  56. package/dist-esm/lib/ui/components/Toolbar/ToggleToolLockedButton.mjs.map +2 -2
  57. package/dist-esm/lib/ui/components/menu-items.mjs +6 -0
  58. package/dist-esm/lib/ui/components/menu-items.mjs.map +2 -2
  59. package/dist-esm/lib/ui/components/primitives/TldrawUiToolbar.mjs +11 -3
  60. package/dist-esm/lib/ui/components/primitives/TldrawUiToolbar.mjs.map +2 -2
  61. package/dist-esm/lib/ui/components/primitives/TldrawUiTooltip.mjs +237 -0
  62. package/dist-esm/lib/ui/components/primitives/TldrawUiTooltip.mjs.map +7 -0
  63. package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuItem.mjs +3 -157
  64. package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuItem.mjs.map +2 -2
  65. package/dist-esm/lib/ui/context/TldrawUiContextProvider.mjs +3 -2
  66. package/dist-esm/lib/ui/context/TldrawUiContextProvider.mjs.map +2 -2
  67. package/dist-esm/lib/ui/context/actions.mjs +15 -0
  68. package/dist-esm/lib/ui/context/actions.mjs.map +2 -2
  69. package/dist-esm/lib/ui/context/events.mjs.map +1 -1
  70. package/dist-esm/lib/ui/hooks/useTools.mjs +10 -83
  71. package/dist-esm/lib/ui/hooks/useTools.mjs.map +2 -2
  72. package/dist-esm/lib/ui/hooks/useTranslation/defaultTranslation.mjs +3 -0
  73. package/dist-esm/lib/ui/hooks/useTranslation/defaultTranslation.mjs.map +2 -2
  74. package/dist-esm/lib/ui/version.mjs +3 -3
  75. package/dist-esm/lib/ui/version.mjs.map +1 -1
  76. package/package.json +3 -3
  77. package/src/index.ts +8 -2
  78. package/src/lib/shapes/shared/usePrefersReducedMotion.tsx +11 -1
  79. package/src/lib/tools/SelectTool/childStates/Translating.ts +1 -0
  80. package/src/lib/ui/components/AccessibilityMenu.tsx +20 -0
  81. package/src/lib/ui/components/MainMenu/DefaultMainMenuContent.tsx +4 -4
  82. package/src/lib/ui/components/StylePanel/DefaultStylePanel.tsx +3 -1
  83. package/src/lib/ui/components/StylePanel/DefaultStylePanelContent.tsx +171 -128
  84. package/src/lib/ui/components/Toolbar/OverflowingToolbar.tsx +3 -3
  85. package/src/lib/ui/components/Toolbar/ToggleToolLockedButton.tsx +14 -11
  86. package/src/lib/ui/components/menu-items.tsx +8 -0
  87. package/src/lib/ui/components/primitives/TldrawUiToolbar.tsx +19 -3
  88. package/src/lib/ui/components/primitives/TldrawUiTooltip.tsx +313 -0
  89. package/src/lib/ui/components/primitives/menus/TldrawUiMenuItem.tsx +2 -213
  90. package/src/lib/ui/context/TldrawUiContextProvider.tsx +23 -20
  91. package/src/lib/ui/context/actions.tsx +15 -0
  92. package/src/lib/ui/context/events.tsx +1 -1
  93. package/src/lib/ui/hooks/useTools.tsx +10 -118
  94. package/src/lib/ui/hooks/useTranslation/TLUiTranslationKey.ts +3 -0
  95. package/src/lib/ui/hooks/useTranslation/defaultTranslation.ts +3 -0
  96. package/src/lib/ui/version.ts +3 -3
  97. package/src/lib/ui.css +57 -1
  98. package/tldraw.css +59 -1
@@ -0,0 +1,267 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var TldrawUiTooltip_exports = {};
30
+ __export(TldrawUiTooltip_exports, {
31
+ TldrawUiTooltip: () => TldrawUiTooltip,
32
+ TldrawUiTooltipProvider: () => TldrawUiTooltipProvider
33
+ });
34
+ module.exports = __toCommonJS(TldrawUiTooltip_exports);
35
+ var import_jsx_runtime = require("react/jsx-runtime");
36
+ var import_editor = require("@tldraw/editor");
37
+ var import_radix_ui = require("radix-ui");
38
+ var import_react = __toESM(require("react"));
39
+ var import_usePrefersReducedMotion = require("../../../shapes/shared/usePrefersReducedMotion");
40
+ const DEFAULT_TOOLTIP_DELAY_MS = 700;
41
+ class TooltipManager {
42
+ static instance = null;
43
+ currentTooltipId = null;
44
+ currentContent = "";
45
+ currentSide = "bottom";
46
+ currentSideOffset = 5;
47
+ destroyTimeoutId = null;
48
+ subscribers = /* @__PURE__ */ new Set();
49
+ activeElement = null;
50
+ editor = null;
51
+ static getInstance() {
52
+ if (!TooltipManager.instance) {
53
+ TooltipManager.instance = new TooltipManager();
54
+ }
55
+ return TooltipManager.instance;
56
+ }
57
+ setEditor(editor) {
58
+ this.editor = editor;
59
+ }
60
+ subscribe(callback) {
61
+ this.subscribers.add(callback);
62
+ return () => this.subscribers.delete(callback);
63
+ }
64
+ notify() {
65
+ this.subscribers.forEach((callback) => callback());
66
+ }
67
+ showTooltip(tooltipId, content, element, side = "bottom", sideOffset = 5) {
68
+ if (this.destroyTimeoutId) {
69
+ clearTimeout(this.destroyTimeoutId);
70
+ this.destroyTimeoutId = null;
71
+ }
72
+ this.currentTooltipId = tooltipId;
73
+ this.currentContent = content;
74
+ this.currentSide = side;
75
+ this.currentSideOffset = sideOffset;
76
+ this.activeElement = element;
77
+ this.notify();
78
+ }
79
+ hideTooltip(tooltipId) {
80
+ if (this.currentTooltipId === tooltipId) {
81
+ if (this.editor) {
82
+ this.destroyTimeoutId = this.editor.timers.setTimeout(() => {
83
+ this.currentTooltipId = null;
84
+ this.currentContent = "";
85
+ this.activeElement = null;
86
+ this.destroyTimeoutId = null;
87
+ this.notify();
88
+ }, 300);
89
+ }
90
+ }
91
+ }
92
+ getCurrentTooltipData() {
93
+ return {
94
+ id: this.currentTooltipId,
95
+ content: this.currentContent,
96
+ side: this.currentSide,
97
+ sideOffset: this.currentSideOffset,
98
+ element: this.activeElement
99
+ };
100
+ }
101
+ }
102
+ const tooltipManager = TooltipManager.getInstance();
103
+ const TooltipSingletonContext = (0, import_react.createContext)(false);
104
+ function TldrawUiTooltipProvider({ children }) {
105
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_radix_ui.Tooltip.Provider, { skipDelayDuration: 700, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(TooltipSingletonContext.Provider, { value: true, children: [
106
+ children,
107
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TooltipSingleton, {})
108
+ ] }) });
109
+ }
110
+ function TooltipSingleton() {
111
+ const editor = (0, import_editor.useMaybeEditor)();
112
+ const [, forceUpdate] = (0, import_react.useState)({});
113
+ const [isOpen, setIsOpen] = (0, import_react.useState)(false);
114
+ const triggerRef = (0, import_react.useRef)(null);
115
+ const previousPositionRef = (0, import_react.useRef)(null);
116
+ const prefersReducedMotion = (0, import_usePrefersReducedMotion.usePrefersReducedMotion)();
117
+ const [shouldAnimate, setShouldAnimate] = (0, import_react.useState)(false);
118
+ const isFirstShowRef = (0, import_react.useRef)(true);
119
+ const showTimeoutRef = (0, import_react.useRef)(null);
120
+ (0, import_react.useEffect)(() => {
121
+ tooltipManager.setEditor(editor);
122
+ }, [editor]);
123
+ (0, import_react.useEffect)(() => {
124
+ const unsubscribe = tooltipManager.subscribe(() => {
125
+ forceUpdate({});
126
+ });
127
+ return unsubscribe;
128
+ }, []);
129
+ const tooltipData = tooltipManager.getCurrentTooltipData();
130
+ (0, import_react.useEffect)(() => {
131
+ const shouldBeOpen = Boolean(tooltipData.id && tooltipData.element);
132
+ if (showTimeoutRef.current) {
133
+ clearTimeout(showTimeoutRef.current);
134
+ showTimeoutRef.current = null;
135
+ }
136
+ if (shouldBeOpen && tooltipData.element && triggerRef.current) {
137
+ const activeRect = tooltipData.element.getBoundingClientRect();
138
+ const trigger = triggerRef.current;
139
+ const newPosition = {
140
+ x: activeRect.left + activeRect.width / 2,
141
+ y: activeRect.top + activeRect.height / 2
142
+ };
143
+ let shouldAnimateCheck = false;
144
+ if (previousPositionRef.current) {
145
+ const isNearPrevious = import_editor.Vec.DistMin(previousPositionRef.current, newPosition, 200);
146
+ shouldAnimateCheck = !prefersReducedMotion && isNearPrevious && Math.abs(newPosition.y - previousPositionRef.current.y) < 50;
147
+ }
148
+ setShouldAnimate(isFirstShowRef.current ? false : shouldAnimateCheck);
149
+ previousPositionRef.current = newPosition;
150
+ trigger.style.position = "fixed";
151
+ trigger.style.left = `${activeRect.left}px`;
152
+ trigger.style.top = `${activeRect.top}px`;
153
+ trigger.style.width = `${activeRect.width}px`;
154
+ trigger.style.height = `${activeRect.height}px`;
155
+ trigger.style.pointerEvents = "none";
156
+ trigger.style.zIndex = "9999";
157
+ if (isFirstShowRef.current && editor) {
158
+ showTimeoutRef.current = editor.timers.setTimeout(() => {
159
+ setIsOpen(true);
160
+ isFirstShowRef.current = false;
161
+ }, editor.options.tooltipDelayMs);
162
+ } else {
163
+ setIsOpen(true);
164
+ }
165
+ } else if (!shouldBeOpen) {
166
+ setIsOpen(false);
167
+ previousPositionRef.current = null;
168
+ setShouldAnimate(false);
169
+ isFirstShowRef.current = true;
170
+ }
171
+ }, [tooltipData.id, tooltipData.element, editor, prefersReducedMotion]);
172
+ if (!tooltipData.id) {
173
+ return null;
174
+ }
175
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_radix_ui.Tooltip.Root, { open: isOpen, delayDuration: 0, children: [
176
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_radix_ui.Tooltip.Trigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { ref: triggerRef }) }),
177
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
178
+ import_radix_ui.Tooltip.Content,
179
+ {
180
+ className: "tlui-tooltip",
181
+ "data-should-animate": shouldAnimate,
182
+ side: tooltipData.side,
183
+ sideOffset: tooltipData.sideOffset,
184
+ avoidCollisions: true,
185
+ collisionPadding: 8,
186
+ dir: "ltr",
187
+ children: [
188
+ tooltipData.content,
189
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_radix_ui.Tooltip.Arrow, { className: "tlui-tooltip__arrow" })
190
+ ]
191
+ }
192
+ )
193
+ ] });
194
+ }
195
+ function TldrawUiTooltip({
196
+ children,
197
+ content,
198
+ side = "bottom",
199
+ sideOffset = 5,
200
+ disabled = false
201
+ }) {
202
+ const editor = (0, import_editor.useMaybeEditor)();
203
+ const tooltipId = (0, import_react.useRef)((0, import_editor.uniqueId)());
204
+ const hasProvider = (0, import_react.useContext)(TooltipSingletonContext);
205
+ if (disabled || !content) {
206
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children });
207
+ }
208
+ if (!hasProvider) {
209
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
210
+ import_radix_ui.Tooltip.Root,
211
+ {
212
+ delayDuration: editor?.options.tooltipDelayMs || DEFAULT_TOOLTIP_DELAY_MS,
213
+ disableHoverableContent: true,
214
+ children: [
215
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_radix_ui.Tooltip.Trigger, { asChild: true, children }),
216
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
217
+ import_radix_ui.Tooltip.Content,
218
+ {
219
+ className: "tlui-tooltip",
220
+ side,
221
+ sideOffset,
222
+ avoidCollisions: true,
223
+ collisionPadding: 8,
224
+ dir: "ltr",
225
+ children: [
226
+ content,
227
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_radix_ui.Tooltip.Arrow, { className: "tlui-tooltip__arrow" })
228
+ ]
229
+ }
230
+ )
231
+ ]
232
+ }
233
+ );
234
+ }
235
+ const handleMouseEnter = (event) => {
236
+ tooltipManager.showTooltip(
237
+ tooltipId.current,
238
+ content,
239
+ event.currentTarget,
240
+ side,
241
+ sideOffset
242
+ );
243
+ };
244
+ const handleMouseLeave = () => {
245
+ tooltipManager.hideTooltip(tooltipId.current);
246
+ };
247
+ const handleFocus = (event) => {
248
+ tooltipManager.showTooltip(
249
+ tooltipId.current,
250
+ content,
251
+ event.currentTarget,
252
+ side,
253
+ sideOffset
254
+ );
255
+ };
256
+ const handleBlur = () => {
257
+ tooltipManager.hideTooltip(tooltipId.current);
258
+ };
259
+ const childrenWithHandlers = import_react.default.cloneElement(children, {
260
+ onMouseEnter: handleMouseEnter,
261
+ onMouseLeave: handleMouseLeave,
262
+ onFocus: handleFocus,
263
+ onBlur: handleBlur
264
+ });
265
+ return childrenWithHandlers;
266
+ }
267
+ //# sourceMappingURL=TldrawUiTooltip.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/lib/ui/components/primitives/TldrawUiTooltip.tsx"],
4
+ "sourcesContent": ["import { Editor, uniqueId, useMaybeEditor, Vec } from '@tldraw/editor'\nimport { Tooltip as _Tooltip } from 'radix-ui'\nimport React, { createContext, useContext, useEffect, useRef, useState } from 'react'\nimport { usePrefersReducedMotion } from '../../../shapes/shared/usePrefersReducedMotion'\n\nconst DEFAULT_TOOLTIP_DELAY_MS = 700\n\n/** @public */\nexport interface TldrawUiTooltipProps {\n\tchildren: React.ReactNode\n\tcontent?: string | React.ReactNode\n\tside?: 'top' | 'right' | 'bottom' | 'left'\n\tsideOffset?: number\n\tdisabled?: boolean\n}\n\n// Singleton tooltip manager\nclass TooltipManager {\n\tprivate static instance: TooltipManager | null = null\n\tprivate currentTooltipId: string | null = null\n\tprivate currentContent: string | React.ReactNode = ''\n\tprivate currentSide: 'top' | 'right' | 'bottom' | 'left' = 'bottom'\n\tprivate currentSideOffset: number = 5\n\tprivate destroyTimeoutId: number | null = null\n\tprivate subscribers: Set<() => void> = new Set()\n\tprivate activeElement: HTMLElement | null = null\n\tprivate editor: Editor | null = null\n\n\tstatic getInstance(): TooltipManager {\n\t\tif (!TooltipManager.instance) {\n\t\t\tTooltipManager.instance = new TooltipManager()\n\t\t}\n\t\treturn TooltipManager.instance\n\t}\n\n\tsetEditor(editor: Editor | null) {\n\t\tthis.editor = editor\n\t}\n\n\tsubscribe(callback: () => void): () => void {\n\t\tthis.subscribers.add(callback)\n\t\treturn () => this.subscribers.delete(callback)\n\t}\n\n\tprivate notify() {\n\t\tthis.subscribers.forEach((callback) => callback())\n\t}\n\n\tshowTooltip(\n\t\ttooltipId: string,\n\t\tcontent: string | React.ReactNode,\n\t\telement: HTMLElement,\n\t\tside: 'top' | 'right' | 'bottom' | 'left' = 'bottom',\n\t\tsideOffset: number = 5\n\t) {\n\t\t// Clear any existing destroy timeout\n\t\tif (this.destroyTimeoutId) {\n\t\t\tclearTimeout(this.destroyTimeoutId)\n\t\t\tthis.destroyTimeoutId = null\n\t\t}\n\n\t\t// Update current tooltip\n\t\tthis.currentTooltipId = tooltipId\n\t\tthis.currentContent = content\n\t\tthis.currentSide = side\n\t\tthis.currentSideOffset = sideOffset\n\t\tthis.activeElement = element\n\n\t\tthis.notify()\n\t}\n\n\thideTooltip(tooltipId: string) {\n\t\t// Only hide if this is the current tooltip\n\t\tif (this.currentTooltipId === tooltipId) {\n\t\t\t// Start destroy timeout (1 second)\n\t\t\tif (this.editor) {\n\t\t\t\tthis.destroyTimeoutId = this.editor.timers.setTimeout(() => {\n\t\t\t\t\tthis.currentTooltipId = null\n\t\t\t\t\tthis.currentContent = ''\n\t\t\t\t\tthis.activeElement = null\n\t\t\t\t\tthis.destroyTimeoutId = null\n\t\t\t\t\tthis.notify()\n\t\t\t\t}, 300)\n\t\t\t}\n\t\t}\n\t}\n\n\tgetCurrentTooltipData() {\n\t\treturn {\n\t\t\tid: this.currentTooltipId,\n\t\t\tcontent: this.currentContent,\n\t\t\tside: this.currentSide,\n\t\t\tsideOffset: this.currentSideOffset,\n\t\t\telement: this.activeElement,\n\t\t}\n\t}\n}\n\nconst tooltipManager = TooltipManager.getInstance()\n\n// Context for the tooltip singleton\nconst TooltipSingletonContext = createContext<boolean>(false)\n\n/** @public */\nexport interface TldrawUiTooltipProviderProps {\n\tchildren: React.ReactNode\n}\n\n/** @public @react */\nexport function TldrawUiTooltipProvider({ children }: TldrawUiTooltipProviderProps) {\n\treturn (\n\t\t<_Tooltip.Provider skipDelayDuration={700}>\n\t\t\t<TooltipSingletonContext.Provider value={true}>\n\t\t\t\t{children}\n\t\t\t\t<TooltipSingleton />\n\t\t\t</TooltipSingletonContext.Provider>\n\t\t</_Tooltip.Provider>\n\t)\n}\n\n// The singleton tooltip component that renders once\nfunction TooltipSingleton() {\n\tconst editor = useMaybeEditor()\n\tconst [, forceUpdate] = useState({})\n\tconst [isOpen, setIsOpen] = useState(false)\n\tconst triggerRef = useRef<HTMLDivElement>(null)\n\tconst previousPositionRef = useRef<{ x: number; y: number } | null>(null)\n\tconst prefersReducedMotion = usePrefersReducedMotion()\n\tconst [shouldAnimate, setShouldAnimate] = useState(false)\n\tconst isFirstShowRef = useRef(true)\n\tconst showTimeoutRef = useRef<number | null>(null)\n\n\t// Set editor in tooltip manager\n\tuseEffect(() => {\n\t\ttooltipManager.setEditor(editor)\n\t}, [editor])\n\n\t// Subscribe to tooltip manager updates\n\tuseEffect(() => {\n\t\tconst unsubscribe = tooltipManager.subscribe(() => {\n\t\t\tforceUpdate({})\n\t\t})\n\t\treturn unsubscribe\n\t}, [])\n\n\tconst tooltipData = tooltipManager.getCurrentTooltipData()\n\n\t// Update open state and trigger position\n\tuseEffect(() => {\n\t\tconst shouldBeOpen = Boolean(tooltipData.id && tooltipData.element)\n\n\t\t// Clear any existing show timeout\n\t\tif (showTimeoutRef.current) {\n\t\t\tclearTimeout(showTimeoutRef.current)\n\t\t\tshowTimeoutRef.current = null\n\t\t}\n\n\t\tif (shouldBeOpen && tooltipData.element && triggerRef.current) {\n\t\t\t// Position the invisible trigger element over the active element\n\t\t\tconst activeRect = tooltipData.element.getBoundingClientRect()\n\t\t\tconst trigger = triggerRef.current\n\n\t\t\tconst newPosition = {\n\t\t\t\tx: activeRect.left + activeRect.width / 2,\n\t\t\t\ty: activeRect.top + activeRect.height / 2,\n\t\t\t}\n\n\t\t\t// Determine if we should animate\n\t\t\tlet shouldAnimateCheck = false\n\t\t\tif (previousPositionRef.current) {\n\t\t\t\tconst isNearPrevious = Vec.DistMin(previousPositionRef.current, newPosition, 200)\n\t\t\t\t// Only animate if the distance is less than 200px (nearby tooltips)\n\t\t\t\tshouldAnimateCheck =\n\t\t\t\t\t!prefersReducedMotion &&\n\t\t\t\t\tisNearPrevious &&\n\t\t\t\t\tMath.abs(newPosition.y - previousPositionRef.current.y) < 50\n\t\t\t}\n\t\t\t// Don't animate on initial show (previousPositionRef.current is null)\n\n\t\t\tsetShouldAnimate(isFirstShowRef.current ? false : shouldAnimateCheck)\n\t\t\tpreviousPositionRef.current = newPosition\n\n\t\t\ttrigger.style.position = 'fixed'\n\t\t\ttrigger.style.left = `${activeRect.left}px`\n\t\t\ttrigger.style.top = `${activeRect.top}px`\n\t\t\ttrigger.style.width = `${activeRect.width}px`\n\t\t\ttrigger.style.height = `${activeRect.height}px`\n\t\t\ttrigger.style.pointerEvents = 'none'\n\t\t\ttrigger.style.zIndex = '9999'\n\n\t\t\t// Handle delay for first show\n\t\t\tif (isFirstShowRef.current && editor) {\n\t\t\t\tshowTimeoutRef.current = editor.timers.setTimeout(() => {\n\t\t\t\t\tsetIsOpen(true)\n\t\t\t\t\tisFirstShowRef.current = false\n\t\t\t\t}, editor.options.tooltipDelayMs)\n\t\t\t} else {\n\t\t\t\t// Subsequent tooltips show immediately\n\t\t\t\tsetIsOpen(true)\n\t\t\t}\n\t\t} else if (!shouldBeOpen) {\n\t\t\t// Hide tooltip immediately\n\t\t\tsetIsOpen(false)\n\t\t\t// Reset position tracking when tooltip closes\n\t\t\tpreviousPositionRef.current = null\n\t\t\tsetShouldAnimate(false)\n\t\t\t// Reset first show state after tooltip is hidden\n\t\t\tisFirstShowRef.current = true\n\t\t}\n\t}, [tooltipData.id, tooltipData.element, editor, prefersReducedMotion])\n\n\tif (!tooltipData.id) {\n\t\treturn null\n\t}\n\n\treturn (\n\t\t<_Tooltip.Root open={isOpen} delayDuration={0}>\n\t\t\t<_Tooltip.Trigger asChild>\n\t\t\t\t<div ref={triggerRef} />\n\t\t\t</_Tooltip.Trigger>\n\t\t\t<_Tooltip.Content\n\t\t\t\tclassName=\"tlui-tooltip\"\n\t\t\t\tdata-should-animate={shouldAnimate}\n\t\t\t\tside={tooltipData.side}\n\t\t\t\tsideOffset={tooltipData.sideOffset}\n\t\t\t\tavoidCollisions\n\t\t\t\tcollisionPadding={8}\n\t\t\t\tdir=\"ltr\"\n\t\t\t>\n\t\t\t\t{tooltipData.content}\n\t\t\t\t<_Tooltip.Arrow className=\"tlui-tooltip__arrow\" />\n\t\t\t</_Tooltip.Content>\n\t\t</_Tooltip.Root>\n\t)\n}\n\n/** @public @react */\nexport function TldrawUiTooltip({\n\tchildren,\n\tcontent,\n\tside = 'bottom',\n\tsideOffset = 5,\n\tdisabled = false,\n}: TldrawUiTooltipProps) {\n\tconst editor = useMaybeEditor()\n\tconst tooltipId = useRef<string>(uniqueId())\n\tconst hasProvider = useContext(TooltipSingletonContext)\n\n\t// Don't show tooltip if disabled, no content, or UI labels are disabled\n\tif (disabled || !content) {\n\t\treturn <>{children}</>\n\t}\n\n\t// Fallback to old behavior if no provider\n\tif (!hasProvider) {\n\t\treturn (\n\t\t\t<_Tooltip.Root\n\t\t\t\tdelayDuration={editor?.options.tooltipDelayMs || DEFAULT_TOOLTIP_DELAY_MS}\n\t\t\t\tdisableHoverableContent\n\t\t\t>\n\t\t\t\t<_Tooltip.Trigger asChild>{children}</_Tooltip.Trigger>\n\t\t\t\t<_Tooltip.Content\n\t\t\t\t\tclassName=\"tlui-tooltip\"\n\t\t\t\t\tside={side}\n\t\t\t\t\tsideOffset={sideOffset}\n\t\t\t\t\tavoidCollisions\n\t\t\t\t\tcollisionPadding={8}\n\t\t\t\t\tdir=\"ltr\"\n\t\t\t\t>\n\t\t\t\t\t{content}\n\t\t\t\t\t<_Tooltip.Arrow className=\"tlui-tooltip__arrow\" />\n\t\t\t\t</_Tooltip.Content>\n\t\t\t</_Tooltip.Root>\n\t\t)\n\t}\n\n\tconst handleMouseEnter = (event: React.MouseEvent<HTMLElement>) => {\n\t\ttooltipManager.showTooltip(\n\t\t\ttooltipId.current,\n\t\t\tcontent,\n\t\t\tevent.currentTarget as HTMLElement,\n\t\t\tside,\n\t\t\tsideOffset\n\t\t)\n\t}\n\n\tconst handleMouseLeave = () => {\n\t\ttooltipManager.hideTooltip(tooltipId.current)\n\t}\n\n\tconst handleFocus = (event: React.FocusEvent<HTMLElement>) => {\n\t\ttooltipManager.showTooltip(\n\t\t\ttooltipId.current,\n\t\t\tcontent,\n\t\t\tevent.currentTarget as HTMLElement,\n\t\t\tside,\n\t\t\tsideOffset\n\t\t)\n\t}\n\n\tconst handleBlur = () => {\n\t\ttooltipManager.hideTooltip(tooltipId.current)\n\t}\n\n\tconst childrenWithHandlers = React.cloneElement(children as React.ReactElement, {\n\t\tonMouseEnter: handleMouseEnter,\n\t\tonMouseLeave: handleMouseLeave,\n\t\tonFocus: handleFocus,\n\t\tonBlur: handleBlur,\n\t})\n\n\treturn childrenWithHandlers\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAgHG;AAhHH,oBAAsD;AACtD,sBAAoC;AACpC,mBAA8E;AAC9E,qCAAwC;AAExC,MAAM,2BAA2B;AAYjC,MAAM,eAAe;AAAA,EACpB,OAAe,WAAkC;AAAA,EACzC,mBAAkC;AAAA,EAClC,iBAA2C;AAAA,EAC3C,cAAmD;AAAA,EACnD,oBAA4B;AAAA,EAC5B,mBAAkC;AAAA,EAClC,cAA+B,oBAAI,IAAI;AAAA,EACvC,gBAAoC;AAAA,EACpC,SAAwB;AAAA,EAEhC,OAAO,cAA8B;AACpC,QAAI,CAAC,eAAe,UAAU;AAC7B,qBAAe,WAAW,IAAI,eAAe;AAAA,IAC9C;AACA,WAAO,eAAe;AAAA,EACvB;AAAA,EAEA,UAAU,QAAuB;AAChC,SAAK,SAAS;AAAA,EACf;AAAA,EAEA,UAAU,UAAkC;AAC3C,SAAK,YAAY,IAAI,QAAQ;AAC7B,WAAO,MAAM,KAAK,YAAY,OAAO,QAAQ;AAAA,EAC9C;AAAA,EAEQ,SAAS;AAChB,SAAK,YAAY,QAAQ,CAAC,aAAa,SAAS,CAAC;AAAA,EAClD;AAAA,EAEA,YACC,WACA,SACA,SACA,OAA4C,UAC5C,aAAqB,GACpB;AAED,QAAI,KAAK,kBAAkB;AAC1B,mBAAa,KAAK,gBAAgB;AAClC,WAAK,mBAAmB;AAAA,IACzB;AAGA,SAAK,mBAAmB;AACxB,SAAK,iBAAiB;AACtB,SAAK,cAAc;AACnB,SAAK,oBAAoB;AACzB,SAAK,gBAAgB;AAErB,SAAK,OAAO;AAAA,E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A,QAAS;AAAA,YAAT;AAAA,cACA,WAAU;AAAA,cACV;AAAA,cACA;AAAA,cACA,iBAAe;AAAA,cACf,kBAAkB;AAAA,cAClB,KAAI;AAAA,cAEH;AAAA;AAAA,gBACD,4CAAC,gBAAAA,QAAS,OAAT,EAAe,WAAU,uBAAsB;AAAA;AAAA;AAAA,UACjD;AAAA;AAAA;AAAA,IACD;AAAA,EAEF;AAEA,QAAM,mBAAmB,CAAC,UAAyC;AAClE,mBAAe;AAAA,MACd,UAAU;AAAA,MACV;AAAA,MACA,MAAM;AAAA,MACN;AAAA,MACA;AAAA,IACD;AAAA,EACD;AAEA,QAAM,mBAAmB,MAAM;AAC9B,mBAAe,YAAY,UAAU,OAAO;AAAA,EAC7C;AAEA,QAAM,cAAc,CAAC,UAAyC;AAC7D,mBAAe;AAAA,MACd,UAAU;AAAA,MACV;AAAA,MACA,MAAM;AAAA,MACN;AAAA,MACA;AAAA,IACD;AAAA,EACD;AAEA,QAAM,aAAa,MAAM;AACxB,mBAAe,YAAY,UAAU,OAAO;AAAA,EAC7C;AAEA,QAAM,uBAAuB,aAAAC,QAAM,aAAa,UAAgC;AAAA,IAC/E,cAAc;AAAA,IACd,cAAc;AAAA,IACd,SAAS;AAAA,IACT,QAAQ;AAAA,EACT,CAAC;AAED,SAAO;AACR;",
6
+ "names": ["_Tooltip", "React"]
7
+ }
@@ -48,8 +48,7 @@ function TldrawUiMenuItem({
48
48
  iconLeft,
49
49
  onSelect,
50
50
  noClose,
51
- isSelected,
52
- onDragStart
51
+ isSelected
53
52
  }) {
54
53
  const { type: menuType, sourceId } = (0, import_TldrawUiMenuContext.useTldrawUiMenuContext)();
55
54
  const msg = (0, import_useTranslation.useTranslation)();
@@ -163,21 +162,6 @@ function TldrawUiMenuItem({
163
162
  ] });
164
163
  }
165
164
  case "toolbar": {
166
- if (onDragStart) {
167
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
168
- DraggableToolbarButton,
169
- {
170
- id,
171
- icon,
172
- onSelect,
173
- onDragStart,
174
- labelToUse,
175
- titleStr,
176
- disabled,
177
- isSelected
178
- }
179
- );
180
- }
181
165
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
182
166
  import_TldrawUiToolbar.TldrawUiToolbarButton,
183
167
  {
@@ -198,22 +182,6 @@ function TldrawUiMenuItem({
198
182
  );
199
183
  }
200
184
  case "toolbar-overflow": {
201
- if (onDragStart) {
202
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
203
- DraggableToolbarButton,
204
- {
205
- id,
206
- icon,
207
- onSelect,
208
- onDragStart,
209
- labelToUse,
210
- titleStr,
211
- disabled,
212
- isSelected,
213
- overflow: true
214
- }
215
- );
216
- }
217
185
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
218
186
  import_TldrawUiToolbar.TldrawUiToolbarButton,
219
187
  {
@@ -236,120 +204,4 @@ function TldrawUiMenuItem({
236
204
  }
237
205
  }
238
206
  }
239
- function useDraggableEvents(onDragStart, onSelect) {
240
- const editor = (0, import_editor.useEditor)();
241
- const events = (0, import_react.useMemo)(() => {
242
- let state = { name: "idle" };
243
- function handlePointerDown(e) {
244
- state = {
245
- name: "pointing",
246
- start: editor.inputs.currentPagePoint.clone()
247
- };
248
- e.currentTarget.setPointerCapture(e.pointerId);
249
- }
250
- function handlePointerMove(e) {
251
- if (e.isSpecialRedispatchedEvent) return;
252
- if (state.name === "pointing") {
253
- const distance = import_editor.Vec.Dist2(state.start, editor.inputs.currentPagePoint);
254
- if (distance > (editor.getInstanceState().isCoarsePointer ? editor.options.coarseDragDistanceSquared : editor.options.dragDistanceSquared)) {
255
- const start = state.start;
256
- state = {
257
- name: "dragging",
258
- start
259
- };
260
- editor.run(() => {
261
- editor.dispatch({
262
- type: "pointer",
263
- target: "canvas",
264
- name: "pointer_down",
265
- ...(0, import_editor.getPointerInfo)(e),
266
- point: start
267
- });
268
- editor.selectNone();
269
- onDragStart?.("toolbar", {
270
- type: "pointer",
271
- target: "canvas",
272
- name: "pointer_move",
273
- ...(0, import_editor.getPointerInfo)(e)
274
- });
275
- });
276
- }
277
- }
278
- }
279
- function handlePointerUp(e) {
280
- if (e.isSpecialRedispatchedEvent) return;
281
- e.currentTarget.releasePointerCapture(e.pointerId);
282
- editor.dispatch({
283
- type: "pointer",
284
- target: "canvas",
285
- name: "pointer_up",
286
- ...(0, import_editor.getPointerInfo)(e)
287
- });
288
- }
289
- function handleClick() {
290
- if (state.name === "dragging" || state.name === "dragged") {
291
- state = { name: "idle" };
292
- return true;
293
- }
294
- state = { name: "idle" };
295
- onSelect?.("toolbar");
296
- }
297
- return {
298
- onPointerDown: handlePointerDown,
299
- onPointerMove: handlePointerMove,
300
- onPointerUp: handlePointerUp,
301
- onClick: handleClick
302
- };
303
- }, [onDragStart, editor, onSelect]);
304
- return events;
305
- }
306
- function DraggableToolbarButton({
307
- id,
308
- labelToUse,
309
- titleStr,
310
- disabled,
311
- isSelected,
312
- icon,
313
- onSelect,
314
- onDragStart,
315
- overflow
316
- }) {
317
- const events = useDraggableEvents(onDragStart, onSelect);
318
- if (overflow) {
319
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
320
- import_TldrawUiToolbar.TldrawUiToolbarButton,
321
- {
322
- "aria-label": labelToUse,
323
- "aria-pressed": isSelected ? "true" : "false",
324
- isActive: isSelected,
325
- className: "tlui-button-grid__button",
326
- "data-testid": `tools.more.${id}`,
327
- "data-value": id,
328
- disabled,
329
- title: titleStr,
330
- type: "icon",
331
- ...events,
332
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_TldrawUiButtonIcon.TldrawUiButtonIcon, { icon })
333
- }
334
- );
335
- }
336
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
337
- import_TldrawUiToolbar.TldrawUiToolbarButton,
338
- {
339
- "aria-label": labelToUse,
340
- "aria-pressed": isSelected ? "true" : "false",
341
- "data-testid": `tools.${id}`,
342
- "data-value": id,
343
- disabled,
344
- onTouchStart: (e) => {
345
- (0, import_editor.preventDefault)(e);
346
- onSelect("toolbar");
347
- },
348
- title: titleStr,
349
- type: "tool",
350
- ...events,
351
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_TldrawUiButtonIcon.TldrawUiButtonIcon, { icon })
352
- }
353
- );
354
- }
355
207
  //# sourceMappingURL=TldrawUiMenuItem.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/lib/ui/components/primitives/menus/TldrawUiMenuItem.tsx"],
4
- "sourcesContent": ["import {\n\texhaustiveSwitchError,\n\tgetPointerInfo,\n\tpreventDefault,\n\tTLPointerEventInfo,\n\tuseEditor,\n\tVec,\n} from '@tldraw/editor'\nimport { ContextMenu as _ContextMenu } from 'radix-ui'\nimport { useMemo, useState } from 'react'\nimport { unwrapLabel } from '../../../context/actions'\nimport { TLUiEventSource } from '../../../context/events'\nimport { useReadonly } from '../../../hooks/useReadonly'\nimport { TLUiToolItem } from '../../../hooks/useTools'\nimport { TLUiTranslationKey } from '../../../hooks/useTranslation/TLUiTranslationKey'\nimport { useTranslation } from '../../../hooks/useTranslation/useTranslation'\nimport { kbdStr } from '../../../kbd-utils'\nimport { Spinner } from '../../Spinner'\nimport { TldrawUiButton } from '../Button/TldrawUiButton'\nimport { TldrawUiButtonIcon } from '../Button/TldrawUiButtonIcon'\nimport { TldrawUiButtonLabel } from '../Button/TldrawUiButtonLabel'\nimport { TldrawUiDropdownMenuItem } from '../TldrawUiDropdownMenu'\nimport { TLUiIconJsx } from '../TldrawUiIcon'\nimport { TldrawUiKbd } from '../TldrawUiKbd'\nimport { TldrawUiToolbarButton } from '../TldrawUiToolbar'\nimport { useTldrawUiMenuContext } from './TldrawUiMenuContext'\n\n/** @public */\nexport interface TLUiMenuItemProps<\n\tTranslationKey extends string = string,\n\tIconType extends string = string,\n> {\n\tid: string\n\t/**\n\t * The icon to display on the item. Icons are only shown in certain menu types.\n\t */\n\ticon?: IconType | TLUiIconJsx\n\t/**\n\t * An icon to display to the left of the menu item.\n\t */\n\ticonLeft?: IconType | TLUiIconJsx\n\t/**\n\t * The keyboard shortcut to display on the item.\n\t */\n\tkbd?: string\n\t/**\n\t * The label to display on the item. If it's a string, it will be translated. If it's an object, the keys will be used as the language keys and the values will be translated.\n\t */\n\tlabel?: TranslationKey | { [key: string]: TranslationKey }\n\t/**\n\t * If the editor is in readonly mode and the item is not marked as readonlyok, it will not be rendered.\n\t */\n\treadonlyOk?: boolean\n\t/**\n\t * The function to call when the item is clicked.\n\t */\n\tonSelect(source: TLUiEventSource): Promise<void> | void\n\t/**\n\t * Whether this item should be disabled.\n\t */\n\tdisabled?: boolean\n\t/**\n\t * Prevent the menu from closing when the item is clicked\n\t */\n\tnoClose?: boolean\n\t/**\n\t * Whether to show a spinner on the item.\n\t */\n\tspinner?: boolean\n\t/**\n\t * Whether the item is selected.\n\t */\n\tisSelected?: boolean\n\t/**\n\t * The function to call when the item is dragged. If this is provided, the item will be draggable.\n\t */\n\tonDragStart?(source: TLUiEventSource, info: TLPointerEventInfo): void\n}\n\n/** @public @react */\nexport function TldrawUiMenuItem<\n\tTranslationKey extends string = string,\n\tIconType extends string = string,\n>({\n\tdisabled = false,\n\tspinner = false,\n\treadonlyOk = false,\n\tid,\n\tkbd,\n\tlabel,\n\ticon,\n\ticonLeft,\n\tonSelect,\n\tnoClose,\n\tisSelected,\n\tonDragStart,\n}: TLUiMenuItemProps<TranslationKey, IconType>) {\n\tconst { type: menuType, sourceId } = useTldrawUiMenuContext()\n\n\tconst msg = useTranslation()\n\n\tconst [disableClicks, setDisableClicks] = useState(false)\n\n\tconst isReadonlyMode = useReadonly()\n\tif (isReadonlyMode && !readonlyOk) return null\n\n\tconst labelToUse = unwrapLabel(label, menuType)\n\tconst kbdToUse = kbd ? kbdStr(kbd) : undefined\n\n\tconst labelStr = labelToUse ? msg(labelToUse as TLUiTranslationKey) : undefined\n\tconst titleStr = labelStr && kbdToUse ? `${labelStr} ${kbdToUse}` : labelStr\n\n\tswitch (menuType) {\n\t\tcase 'menu': {\n\t\t\treturn (\n\t\t\t\t<TldrawUiDropdownMenuItem>\n\t\t\t\t\t<TldrawUiButton\n\t\t\t\t\t\ttype=\"menu\"\n\t\t\t\t\t\tdata-testid={`${sourceId}.${id}`}\n\t\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\t\ttitle={titleStr}\n\t\t\t\t\t\tonClick={(e) => {\n\t\t\t\t\t\t\tif (noClose) {\n\t\t\t\t\t\t\t\tpreventDefault(e)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (disableClicks) {\n\t\t\t\t\t\t\t\tsetDisableClicks(false)\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tonSelect(sourceId)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}}\n\t\t\t\t\t>\n\t\t\t\t\t\t{iconLeft && <TldrawUiButtonIcon icon={iconLeft} small />}\n\t\t\t\t\t\t<TldrawUiButtonLabel>{labelStr}</TldrawUiButtonLabel>\n\t\t\t\t\t\t{kbd && <TldrawUiKbd>{kbd}</TldrawUiKbd>}\n\t\t\t\t\t</TldrawUiButton>\n\t\t\t\t</TldrawUiDropdownMenuItem>\n\t\t\t)\n\t\t}\n\t\tcase 'context-menu': {\n\t\t\t// Hide disabled context menu items\n\t\t\tif (disabled) return null\n\n\t\t\treturn (\n\t\t\t\t<_ContextMenu.Item\n\t\t\t\t\tdir=\"ltr\"\n\t\t\t\t\ttitle={titleStr}\n\t\t\t\t\tdraggable={false}\n\t\t\t\t\tclassName=\"tlui-button tlui-button__menu\"\n\t\t\t\t\tdata-testid={`${sourceId}.${id}`}\n\t\t\t\t\tonSelect={(e) => {\n\t\t\t\t\t\tif (noClose) preventDefault(e)\n\t\t\t\t\t\tif (disableClicks) {\n\t\t\t\t\t\t\tsetDisableClicks(false)\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tonSelect(sourceId)\n\t\t\t\t\t\t}\n\t\t\t\t\t}}\n\t\t\t\t>\n\t\t\t\t\t<span className=\"tlui-button__label\" draggable={false}>\n\t\t\t\t\t\t{labelStr}\n\t\t\t\t\t</span>\n\t\t\t\t\t{iconLeft && <TldrawUiButtonIcon icon={iconLeft} small />}\n\t\t\t\t\t{kbd && <TldrawUiKbd>{kbd}</TldrawUiKbd>}\n\t\t\t\t\t{spinner && <Spinner />}\n\t\t\t\t</_ContextMenu.Item>\n\t\t\t)\n\t\t}\n\t\tcase 'panel': {\n\t\t\treturn (\n\t\t\t\t<TldrawUiButton\n\t\t\t\t\tdata-testid={`${sourceId}.${id}`}\n\t\t\t\t\ttype=\"menu\"\n\t\t\t\t\ttitle={titleStr}\n\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\tonClick={() => onSelect(sourceId)}\n\t\t\t\t>\n\t\t\t\t\t<TldrawUiButtonLabel>{labelStr}</TldrawUiButtonLabel>\n\t\t\t\t\t{spinner ? <Spinner /> : icon && <TldrawUiButtonIcon icon={icon} />}\n\t\t\t\t</TldrawUiButton>\n\t\t\t)\n\t\t}\n\t\tcase 'small-icons':\n\t\tcase 'icons': {\n\t\t\treturn (\n\t\t\t\t<TldrawUiToolbarButton\n\t\t\t\t\tdata-testid={`${sourceId}.${id}`}\n\t\t\t\t\ttype=\"icon\"\n\t\t\t\t\ttitle={titleStr}\n\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\tonClick={() => onSelect(sourceId)}\n\t\t\t\t>\n\t\t\t\t\t<TldrawUiButtonIcon icon={icon!} small />\n\t\t\t\t</TldrawUiToolbarButton>\n\t\t\t)\n\t\t}\n\t\tcase 'keyboard-shortcuts': {\n\t\t\tif (!kbd) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`Menu item '${label}' isn't shown in the keyboard shortcuts dialog because it doesn't have a keyboard shortcut.`\n\t\t\t\t)\n\t\t\t\treturn null\n\t\t\t}\n\n\t\t\treturn (\n\t\t\t\t<div className=\"tlui-shortcuts-dialog__key-pair\" data-testid={`${sourceId}.${id}`}>\n\t\t\t\t\t<div className=\"tlui-shortcuts-dialog__key-pair__key\">{labelStr}</div>\n\t\t\t\t\t<div className=\"tlui-shortcuts-dialog__key-pair__value\">\n\t\t\t\t\t\t<TldrawUiKbd visibleOnMobileLayout>{kbd}</TldrawUiKbd>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t)\n\t\t}\n\t\tcase 'helper-buttons': {\n\t\t\treturn (\n\t\t\t\t<TldrawUiButton type=\"low\" onClick={() => onSelect(sourceId)}>\n\t\t\t\t\t<TldrawUiButtonIcon icon={icon!} />\n\t\t\t\t\t<TldrawUiButtonLabel>{labelStr}</TldrawUiButtonLabel>\n\t\t\t\t</TldrawUiButton>\n\t\t\t)\n\t\t}\n\t\tcase 'toolbar': {\n\t\t\tif (onDragStart) {\n\t\t\t\treturn (\n\t\t\t\t\t<DraggableToolbarButton\n\t\t\t\t\t\tid={id}\n\t\t\t\t\t\ticon={icon}\n\t\t\t\t\t\tonSelect={onSelect}\n\t\t\t\t\t\tonDragStart={onDragStart}\n\t\t\t\t\t\tlabelToUse={labelToUse}\n\t\t\t\t\t\ttitleStr={titleStr}\n\t\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\t\tisSelected={isSelected}\n\t\t\t\t\t/>\n\t\t\t\t)\n\t\t\t}\n\t\t\treturn (\n\t\t\t\t<TldrawUiToolbarButton\n\t\t\t\t\taria-label={labelStr}\n\t\t\t\t\taria-pressed={isSelected ? 'true' : 'false'}\n\t\t\t\t\tdata-testid={`tools.${id}`}\n\t\t\t\t\tdata-value={id}\n\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\tonClick={() => onSelect('toolbar')}\n\t\t\t\t\tonTouchStart={(e) => {\n\t\t\t\t\t\tpreventDefault(e)\n\t\t\t\t\t\tonSelect('toolbar')\n\t\t\t\t\t}}\n\t\t\t\t\ttitle={titleStr}\n\t\t\t\t\ttype=\"tool\"\n\t\t\t\t>\n\t\t\t\t\t<TldrawUiButtonIcon icon={icon!} />\n\t\t\t\t</TldrawUiToolbarButton>\n\t\t\t)\n\t\t}\n\t\tcase 'toolbar-overflow': {\n\t\t\tif (onDragStart) {\n\t\t\t\treturn (\n\t\t\t\t\t<DraggableToolbarButton\n\t\t\t\t\t\tid={id}\n\t\t\t\t\t\ticon={icon}\n\t\t\t\t\t\tonSelect={onSelect}\n\t\t\t\t\t\tonDragStart={onDragStart}\n\t\t\t\t\t\tlabelToUse={labelToUse}\n\t\t\t\t\t\ttitleStr={titleStr}\n\t\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\t\tisSelected={isSelected}\n\t\t\t\t\t\toverflow\n\t\t\t\t\t/>\n\t\t\t\t)\n\t\t\t}\n\t\t\treturn (\n\t\t\t\t<TldrawUiToolbarButton\n\t\t\t\t\taria-label={labelStr}\n\t\t\t\t\taria-pressed={isSelected ? 'true' : 'false'}\n\t\t\t\t\tisActive={isSelected}\n\t\t\t\t\tclassName=\"tlui-button-grid__button\"\n\t\t\t\t\tdata-testid={`tools.more.${id}`}\n\t\t\t\t\tdata-value={id}\n\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\tonClick={() => onSelect('toolbar')}\n\t\t\t\t\ttitle={titleStr}\n\t\t\t\t\ttype=\"icon\"\n\t\t\t\t>\n\t\t\t\t\t<TldrawUiButtonIcon icon={icon!} />\n\t\t\t\t</TldrawUiToolbarButton>\n\t\t\t)\n\t\t}\n\t\tdefault: {\n\t\t\tthrow exhaustiveSwitchError(menuType)\n\t\t}\n\t}\n}\n\nfunction useDraggableEvents(\n\tonDragStart: TLUiToolItem['onDragStart'],\n\tonSelect: TLUiToolItem['onSelect']\n) {\n\tconst editor = useEditor()\n\tconst events = useMemo(() => {\n\t\tlet state = { name: 'idle' } as\n\t\t\t| {\n\t\t\t\t\tname: 'idle'\n\t\t\t }\n\t\t\t| {\n\t\t\t\t\tname: 'pointing'\n\t\t\t\t\tstart: Vec\n\t\t\t }\n\t\t\t| {\n\t\t\t\t\tname: 'dragging'\n\t\t\t\t\tstart: Vec\n\t\t\t }\n\t\t\t| {\n\t\t\t\t\tname: 'dragged'\n\t\t\t }\n\n\t\tfunction handlePointerDown(e: React.PointerEvent<HTMLButtonElement>) {\n\t\t\tstate = {\n\t\t\t\tname: 'pointing',\n\t\t\t\tstart: editor.inputs.currentPagePoint.clone(),\n\t\t\t}\n\n\t\t\te.currentTarget.setPointerCapture(e.pointerId)\n\t\t}\n\n\t\tfunction handlePointerMove(e: React.PointerEvent<HTMLButtonElement>) {\n\t\t\tif ((e as any).isSpecialRedispatchedEvent) return\n\n\t\t\tif (state.name === 'pointing') {\n\t\t\t\tconst distance = Vec.Dist2(state.start, editor.inputs.currentPagePoint)\n\t\t\t\tif (\n\t\t\t\t\tdistance >\n\t\t\t\t\t(editor.getInstanceState().isCoarsePointer\n\t\t\t\t\t\t? editor.options.coarseDragDistanceSquared\n\t\t\t\t\t\t: editor.options.dragDistanceSquared)\n\t\t\t\t) {\n\t\t\t\t\tconst start = state.start\n\t\t\t\t\tstate = {\n\t\t\t\t\t\tname: 'dragging',\n\t\t\t\t\t\tstart,\n\t\t\t\t\t}\n\n\t\t\t\t\teditor.run(() => {\n\t\t\t\t\t\t// Set origin point\n\t\t\t\t\t\teditor.dispatch({\n\t\t\t\t\t\t\ttype: 'pointer',\n\t\t\t\t\t\t\ttarget: 'canvas',\n\t\t\t\t\t\t\tname: 'pointer_down',\n\t\t\t\t\t\t\t...getPointerInfo(e),\n\t\t\t\t\t\t\tpoint: start,\n\t\t\t\t\t\t})\n\n\t\t\t\t\t\t// Pointer down potentially selects shapes, so we need to deselect them.\n\t\t\t\t\t\teditor.selectNone()\n\n\t\t\t\t\t\t// start drag\n\t\t\t\t\t\tonDragStart?.('toolbar', {\n\t\t\t\t\t\t\ttype: 'pointer',\n\t\t\t\t\t\t\ttarget: 'canvas',\n\t\t\t\t\t\t\tname: 'pointer_move',\n\t\t\t\t\t\t\t...getPointerInfo(e),\n\t\t\t\t\t\t})\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tfunction handlePointerUp(e: React.PointerEvent<HTMLButtonElement>) {\n\t\t\tif ((e as any).isSpecialRedispatchedEvent) return\n\n\t\t\te.currentTarget.releasePointerCapture(e.pointerId)\n\n\t\t\teditor.dispatch({\n\t\t\t\ttype: 'pointer',\n\t\t\t\ttarget: 'canvas',\n\t\t\t\tname: 'pointer_up',\n\t\t\t\t...getPointerInfo(e),\n\t\t\t})\n\t\t}\n\n\t\tfunction handleClick() {\n\t\t\tif (state.name === 'dragging' || state.name === 'dragged') {\n\t\t\t\tstate = { name: 'idle' }\n\t\t\t\treturn true\n\t\t\t}\n\n\t\t\tstate = { name: 'idle' }\n\t\t\tonSelect?.('toolbar')\n\t\t}\n\n\t\treturn {\n\t\t\tonPointerDown: handlePointerDown,\n\t\t\tonPointerMove: handlePointerMove,\n\t\t\tonPointerUp: handlePointerUp,\n\t\t\tonClick: handleClick,\n\t\t}\n\t}, [onDragStart, editor, onSelect])\n\n\treturn events\n}\n\nfunction DraggableToolbarButton({\n\tid,\n\tlabelToUse,\n\ttitleStr,\n\tdisabled,\n\tisSelected,\n\ticon,\n\tonSelect,\n\tonDragStart,\n\toverflow,\n}: {\n\tid: string\n\tdisabled: boolean\n\tlabelToUse?: string\n\ttitleStr?: string\n\tisSelected?: boolean\n\ticon: TLUiMenuItemProps['icon']\n\tonSelect: TLUiMenuItemProps['onSelect']\n\tonDragStart: TLUiMenuItemProps['onDragStart']\n\toverflow?: boolean\n}) {\n\tconst events = useDraggableEvents(onDragStart, onSelect)\n\n\tif (overflow) {\n\t\treturn (\n\t\t\t<TldrawUiToolbarButton\n\t\t\t\taria-label={labelToUse}\n\t\t\t\taria-pressed={isSelected ? 'true' : 'false'}\n\t\t\t\tisActive={isSelected}\n\t\t\t\tclassName=\"tlui-button-grid__button\"\n\t\t\t\tdata-testid={`tools.more.${id}`}\n\t\t\t\tdata-value={id}\n\t\t\t\tdisabled={disabled}\n\t\t\t\ttitle={titleStr}\n\t\t\t\ttype=\"icon\"\n\t\t\t\t{...events}\n\t\t\t>\n\t\t\t\t<TldrawUiButtonIcon icon={icon!} />\n\t\t\t</TldrawUiToolbarButton>\n\t\t)\n\t}\n\n\treturn (\n\t\t<TldrawUiToolbarButton\n\t\t\taria-label={labelToUse}\n\t\t\taria-pressed={isSelected ? 'true' : 'false'}\n\t\t\tdata-testid={`tools.${id}`}\n\t\t\tdata-value={id}\n\t\t\tdisabled={disabled}\n\t\t\tonTouchStart={(e) => {\n\t\t\t\tpreventDefault(e)\n\t\t\t\tonSelect('toolbar')\n\t\t\t}}\n\t\t\ttitle={titleStr}\n\t\t\ttype=\"tool\"\n\t\t\t{...events}\n\t\t>\n\t\t\t<TldrawUiButtonIcon icon={icon!} />\n\t\t</TldrawUiToolbarButton>\n\t)\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAoHK;AApHL,oBAOO;AACP,sBAA4C;AAC5C,mBAAkC;AAClC,qBAA4B;AAE5B,yBAA4B;AAG5B,4BAA+B;AAC/B,uBAAuB;AACvB,qBAAwB;AACxB,4BAA+B;AAC/B,gCAAmC;AACnC,iCAAoC;AACpC,kCAAyC;AAEzC,yBAA4B;AAC5B,6BAAsC;AACtC,iCAAuC;AAuDhC,SAAS,iBAGd;AAAA,EACD,WAAW;AAAA,EACX,UAAU;AAAA,EACV,aAAa;AAAA,EACb;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAAgD;AAC/C,QAAM,EAAE,MAAM,UAAU,SAAS,QAAI,mDAAuB;AAE5D,QAAM,UAAM,sCAAe;AAE3B,QAAM,CAAC,eAAe,gBAAgB,QAAI,uBAAS,KAAK;AAExD,QAAM,qBAAiB,gCAAY;AACnC,MAAI,kBAAkB,CAAC,WAAY,QAAO;AAE1C,QAAM,iBAAa,4BAAY,OAAO,QAAQ;AAC9C,QAAM,WAAW,UAAM,yBAAO,GAAG,IAAI;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V;AAAA,EACD,GAAG,CAAC,aAAa,QAAQ,QAAQ,CAAC;AAElC,SAAO;AACR;AAEA,SAAS,uBAAuB;AAAA,EAC/B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAUG;AACF,QAAM,SAAS,mBAAmB,aAAa,QAAQ;AAEvD,MAAI,UAAU;AACb,WACC;AAAA,MAAC;AAAA;AAAA,QACA,cAAY;AAAA,QACZ,gBAAc,aAAa,SAAS;AAAA,QACpC,UAAU;AAAA,QACV,WAAU;AAAA,QACV,eAAa,cAAc,EAAE;AAAA,QAC7B,cAAY;AAAA,QACZ;AAAA,QACA,OAAO;AAAA,QACP,MAAK;AAAA,QACJ,GAAG;AAAA,QAEJ,sDAAC,gDAAmB,MAAa;AAAA;AAAA,IAClC;AAAA,EAEF;AAEA,SACC;AAAA,IAAC;AAAA;AAAA,MACA,cAAY;AAAA,MACZ,gBAAc,aAAa,SAAS;AAAA,MACpC,eAAa,SAAS,EAAE;AAAA,MACxB,cAAY;AAAA,MACZ;AAAA,MACA,cAAc,CAAC,MAAM;AACpB,0CAAe,CAAC;AAChB,iBAAS,SAAS;AAAA,MACnB;AAAA,MACA,OAAO;AAAA,MACP,MAAK;AAAA,MACJ,GAAG;AAAA,MAEJ,sDAAC,gDAAmB,MAAa;AAAA;AAAA,EAClC;AAEF;",
4
+ "sourcesContent": ["import { exhaustiveSwitchError, preventDefault } from '@tldraw/editor'\nimport { ContextMenu as _ContextMenu } from 'radix-ui'\nimport { useState } from 'react'\nimport { unwrapLabel } from '../../../context/actions'\nimport { TLUiEventSource } from '../../../context/events'\nimport { useReadonly } from '../../../hooks/useReadonly'\nimport { TLUiTranslationKey } from '../../../hooks/useTranslation/TLUiTranslationKey'\nimport { useTranslation } from '../../../hooks/useTranslation/useTranslation'\nimport { kbdStr } from '../../../kbd-utils'\nimport { Spinner } from '../../Spinner'\nimport { TldrawUiButton } from '../Button/TldrawUiButton'\nimport { TldrawUiButtonIcon } from '../Button/TldrawUiButtonIcon'\nimport { TldrawUiButtonLabel } from '../Button/TldrawUiButtonLabel'\nimport { TldrawUiDropdownMenuItem } from '../TldrawUiDropdownMenu'\nimport { TLUiIconJsx } from '../TldrawUiIcon'\nimport { TldrawUiKbd } from '../TldrawUiKbd'\nimport { TldrawUiToolbarButton } from '../TldrawUiToolbar'\nimport { useTldrawUiMenuContext } from './TldrawUiMenuContext'\n\n/** @public */\nexport interface TLUiMenuItemProps<\n\tTranslationKey extends string = string,\n\tIconType extends string = string,\n> {\n\tid: string\n\t/**\n\t * The icon to display on the item. Icons are only shown in certain menu types.\n\t */\n\ticon?: IconType | TLUiIconJsx\n\t/**\n\t * An icon to display to the left of the menu item.\n\t */\n\ticonLeft?: IconType | TLUiIconJsx\n\t/**\n\t * The keyboard shortcut to display on the item.\n\t */\n\tkbd?: string\n\t/**\n\t * The label to display on the item. If it's a string, it will be translated. If it's an object, the keys will be used as the language keys and the values will be translated.\n\t */\n\tlabel?: TranslationKey | { [key: string]: TranslationKey }\n\t/**\n\t * If the editor is in readonly mode and the item is not marked as readonlyok, it will not be rendered.\n\t */\n\treadonlyOk?: boolean\n\t/**\n\t * The function to call when the item is clicked.\n\t */\n\tonSelect(source: TLUiEventSource): Promise<void> | void\n\t/**\n\t * Whether this item should be disabled.\n\t */\n\tdisabled?: boolean\n\t/**\n\t * Prevent the menu from closing when the item is clicked\n\t */\n\tnoClose?: boolean\n\t/**\n\t * Whether to show a spinner on the item.\n\t */\n\tspinner?: boolean\n\t/**\n\t * Whether the item is selected.\n\t */\n\tisSelected?: boolean\n}\n\n/** @public @react */\nexport function TldrawUiMenuItem<\n\tTranslationKey extends string = string,\n\tIconType extends string = string,\n>({\n\tdisabled = false,\n\tspinner = false,\n\treadonlyOk = false,\n\tid,\n\tkbd,\n\tlabel,\n\ticon,\n\ticonLeft,\n\tonSelect,\n\tnoClose,\n\tisSelected,\n}: TLUiMenuItemProps<TranslationKey, IconType>) {\n\tconst { type: menuType, sourceId } = useTldrawUiMenuContext()\n\n\tconst msg = useTranslation()\n\n\tconst [disableClicks, setDisableClicks] = useState(false)\n\n\tconst isReadonlyMode = useReadonly()\n\tif (isReadonlyMode && !readonlyOk) return null\n\n\tconst labelToUse = unwrapLabel(label, menuType)\n\tconst kbdToUse = kbd ? kbdStr(kbd) : undefined\n\n\tconst labelStr = labelToUse ? msg(labelToUse as TLUiTranslationKey) : undefined\n\tconst titleStr = labelStr && kbdToUse ? `${labelStr} ${kbdToUse}` : labelStr\n\n\tswitch (menuType) {\n\t\tcase 'menu': {\n\t\t\treturn (\n\t\t\t\t<TldrawUiDropdownMenuItem>\n\t\t\t\t\t<TldrawUiButton\n\t\t\t\t\t\ttype=\"menu\"\n\t\t\t\t\t\tdata-testid={`${sourceId}.${id}`}\n\t\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\t\ttitle={titleStr}\n\t\t\t\t\t\tonClick={(e) => {\n\t\t\t\t\t\t\tif (noClose) {\n\t\t\t\t\t\t\t\tpreventDefault(e)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (disableClicks) {\n\t\t\t\t\t\t\t\tsetDisableClicks(false)\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tonSelect(sourceId)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}}\n\t\t\t\t\t>\n\t\t\t\t\t\t{iconLeft && <TldrawUiButtonIcon icon={iconLeft} small />}\n\t\t\t\t\t\t<TldrawUiButtonLabel>{labelStr}</TldrawUiButtonLabel>\n\t\t\t\t\t\t{kbd && <TldrawUiKbd>{kbd}</TldrawUiKbd>}\n\t\t\t\t\t</TldrawUiButton>\n\t\t\t\t</TldrawUiDropdownMenuItem>\n\t\t\t)\n\t\t}\n\t\tcase 'context-menu': {\n\t\t\t// Hide disabled context menu items\n\t\t\tif (disabled) return null\n\n\t\t\treturn (\n\t\t\t\t<_ContextMenu.Item\n\t\t\t\t\tdir=\"ltr\"\n\t\t\t\t\ttitle={titleStr}\n\t\t\t\t\tdraggable={false}\n\t\t\t\t\tclassName=\"tlui-button tlui-button__menu\"\n\t\t\t\t\tdata-testid={`${sourceId}.${id}`}\n\t\t\t\t\tonSelect={(e) => {\n\t\t\t\t\t\tif (noClose) preventDefault(e)\n\t\t\t\t\t\tif (disableClicks) {\n\t\t\t\t\t\t\tsetDisableClicks(false)\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tonSelect(sourceId)\n\t\t\t\t\t\t}\n\t\t\t\t\t}}\n\t\t\t\t>\n\t\t\t\t\t<span className=\"tlui-button__label\" draggable={false}>\n\t\t\t\t\t\t{labelStr}\n\t\t\t\t\t</span>\n\t\t\t\t\t{iconLeft && <TldrawUiButtonIcon icon={iconLeft} small />}\n\t\t\t\t\t{kbd && <TldrawUiKbd>{kbd}</TldrawUiKbd>}\n\t\t\t\t\t{spinner && <Spinner />}\n\t\t\t\t</_ContextMenu.Item>\n\t\t\t)\n\t\t}\n\t\tcase 'panel': {\n\t\t\treturn (\n\t\t\t\t<TldrawUiButton\n\t\t\t\t\tdata-testid={`${sourceId}.${id}`}\n\t\t\t\t\ttype=\"menu\"\n\t\t\t\t\ttitle={titleStr}\n\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\tonClick={() => onSelect(sourceId)}\n\t\t\t\t>\n\t\t\t\t\t<TldrawUiButtonLabel>{labelStr}</TldrawUiButtonLabel>\n\t\t\t\t\t{spinner ? <Spinner /> : icon && <TldrawUiButtonIcon icon={icon} />}\n\t\t\t\t</TldrawUiButton>\n\t\t\t)\n\t\t}\n\t\tcase 'small-icons':\n\t\tcase 'icons': {\n\t\t\treturn (\n\t\t\t\t<TldrawUiToolbarButton\n\t\t\t\t\tdata-testid={`${sourceId}.${id}`}\n\t\t\t\t\ttype=\"icon\"\n\t\t\t\t\ttitle={titleStr}\n\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\tonClick={() => onSelect(sourceId)}\n\t\t\t\t>\n\t\t\t\t\t<TldrawUiButtonIcon icon={icon!} small />\n\t\t\t\t</TldrawUiToolbarButton>\n\t\t\t)\n\t\t}\n\t\tcase 'keyboard-shortcuts': {\n\t\t\tif (!kbd) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`Menu item '${label}' isn't shown in the keyboard shortcuts dialog because it doesn't have a keyboard shortcut.`\n\t\t\t\t)\n\t\t\t\treturn null\n\t\t\t}\n\n\t\t\treturn (\n\t\t\t\t<div className=\"tlui-shortcuts-dialog__key-pair\" data-testid={`${sourceId}.${id}`}>\n\t\t\t\t\t<div className=\"tlui-shortcuts-dialog__key-pair__key\">{labelStr}</div>\n\t\t\t\t\t<div className=\"tlui-shortcuts-dialog__key-pair__value\">\n\t\t\t\t\t\t<TldrawUiKbd visibleOnMobileLayout>{kbd}</TldrawUiKbd>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t)\n\t\t}\n\t\tcase 'helper-buttons': {\n\t\t\treturn (\n\t\t\t\t<TldrawUiButton type=\"low\" onClick={() => onSelect(sourceId)}>\n\t\t\t\t\t<TldrawUiButtonIcon icon={icon!} />\n\t\t\t\t\t<TldrawUiButtonLabel>{labelStr}</TldrawUiButtonLabel>\n\t\t\t\t</TldrawUiButton>\n\t\t\t)\n\t\t}\n\t\tcase 'toolbar': {\n\t\t\treturn (\n\t\t\t\t<TldrawUiToolbarButton\n\t\t\t\t\taria-label={labelStr}\n\t\t\t\t\taria-pressed={isSelected ? 'true' : 'false'}\n\t\t\t\t\tdata-testid={`tools.${id}`}\n\t\t\t\t\tdata-value={id}\n\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\tonClick={() => onSelect('toolbar')}\n\t\t\t\t\tonTouchStart={(e) => {\n\t\t\t\t\t\tpreventDefault(e)\n\t\t\t\t\t\tonSelect('toolbar')\n\t\t\t\t\t}}\n\t\t\t\t\ttitle={titleStr}\n\t\t\t\t\ttype=\"tool\"\n\t\t\t\t>\n\t\t\t\t\t<TldrawUiButtonIcon icon={icon!} />\n\t\t\t\t</TldrawUiToolbarButton>\n\t\t\t)\n\t\t}\n\t\tcase 'toolbar-overflow': {\n\t\t\treturn (\n\t\t\t\t<TldrawUiToolbarButton\n\t\t\t\t\taria-label={labelStr}\n\t\t\t\t\taria-pressed={isSelected ? 'true' : 'false'}\n\t\t\t\t\tisActive={isSelected}\n\t\t\t\t\tclassName=\"tlui-button-grid__button\"\n\t\t\t\t\tdata-testid={`tools.more.${id}`}\n\t\t\t\t\tdata-value={id}\n\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\tonClick={() => onSelect('toolbar')}\n\t\t\t\t\ttitle={titleStr}\n\t\t\t\t\ttype=\"icon\"\n\t\t\t\t>\n\t\t\t\t\t<TldrawUiButtonIcon icon={icon!} />\n\t\t\t\t</TldrawUiToolbarButton>\n\t\t\t)\n\t\t}\n\t\tdefault: {\n\t\t\tthrow exhaustiveSwitchError(menuType)\n\t\t}\n\t}\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAuGK;AAvGL,oBAAsD;AACtD,sBAA4C;AAC5C,mBAAyB;AACzB,qBAA4B;AAE5B,yBAA4B;AAE5B,4BAA+B;AAC/B,uBAAuB;AACvB,qBAAwB;AACxB,4BAA+B;AAC/B,gCAAmC;AACnC,iCAAoC;AACpC,kCAAyC;AAEzC,yBAA4B;AAC5B,6BAAsC;AACtC,iCAAuC;AAmDhC,SAAS,iBAGd;AAAA,EACD,WAAW;AAAA,EACX,UAAU;AAAA,EACV,aAAa;AAAA,EACb;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAAgD;AAC/C,QAAM,EAAE,MAAM,UAAU,SAAS,QAAI,mDAAuB;AAE5D,QAAM,UAAM,sCAAe;AAE3B,QAAM,CAAC,eAAe,gBAAgB,QAAI,uBAAS,KAAK;AAExD,QAAM,qBAAiB,gCAAY;AACnC,MAAI,kBAAkB,CAAC,W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ACA,KAAK,WAAW;AACf,aACC;AAAA,QAAC;AAAA;AAAA,UACA,cAAY;AAAA,UACZ,gBAAc,aAAa,SAAS;AAAA,UACpC,eAAa,SAAS,EAAE;AAAA,UACxB,cAAY;AAAA,UACZ;AAAA,UACA,SAAS,MAAM,SAAS,SAAS;AAAA,UACjC,cAAc,CAAC,MAAM;AACpB,8CAAe,CAAC;AAChB,qBAAS,SAAS;AAAA,UACnB;AAAA,UACA,OAAO;AAAA,UACP,MAAK;AAAA,UAEL,sDAAC,gDAAmB,MAAa;AAAA;AAAA,MAClC;AAAA,IAEF;AAAA,IACA,KAAK,oBAAoB;AACxB,aACC;AAAA,QAAC;AAAA;AAAA,UACA,cAAY;AAAA,UACZ,gBAAc,aAAa,SAAS;AAAA,UACpC,UAAU;AAAA,UACV,WAAU;AAAA,UACV,eAAa,cAAc,EAAE;AAAA,UAC7B,cAAY;AAAA,UACZ;AAAA,UACA,SAAS,MAAM,SAAS,SAAS;AAAA,UACjC,OAAO;AAAA,UACP,MAAK;AAAA,UAEL,sDAAC,gDAAmB,MAAa;AAAA;AAAA,MAClC;AAAA,IAEF;AAAA,IACA,SAAS;AACR,gBAAM,qCAAsB,QAAQ;AAAA,IACrC;AAAA,EACD;AACD;",
6
6
  "names": ["_ContextMenu"]
7
7
  }
@@ -24,6 +24,7 @@ module.exports = __toCommonJS(TldrawUiContextProvider_exports);
24
24
  var import_jsx_runtime = require("react/jsx-runtime");
25
25
  var import_editor = require("@tldraw/editor");
26
26
  var import_assetUrls = require("../assetUrls");
27
+ var import_TldrawUiTooltip = require("../components/primitives/TldrawUiTooltip");
27
28
  var import_useTools = require("../hooks/useTools");
28
29
  var import_useTranslation = require("../hooks/useTranslation/useTranslation");
29
30
  var import_overrides = require("../overrides");
@@ -45,14 +46,14 @@ const TldrawUiContextProvider = (0, import_editor.track)(function TldrawUiContex
45
46
  children
46
47
  }) {
47
48
  const editor = (0, import_editor.useMaybeEditor)();
48
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_overrides.MimeTypeContext.Provider, { value: mediaMimeTypes, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_asset_urls.AssetUrlsProvider, { assetUrls: (0, import_assetUrls.useDefaultUiAssetUrlsWithOverrides)(assetUrls), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
49
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_overrides.MimeTypeContext.Provider, { value: mediaMimeTypes, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_TldrawUiTooltip.TldrawUiTooltipProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_asset_urls.AssetUrlsProvider, { assetUrls: (0, import_assetUrls.useDefaultUiAssetUrlsWithOverrides)(assetUrls), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
49
50
  import_useTranslation.TldrawUiTranslationProvider,
50
51
  {
51
52
  overrides: (0, import_overrides.useMergedTranslationOverrides)(overrides),
52
53
  locale: editor?.user.getLocale() ?? import_editor.defaultUserPreferences.locale,
53
54
  children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_events.TldrawUiEventsProvider, { onEvent: onUiEvent, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_toasts.TldrawUiToastsProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dialogs.TldrawUiDialogsProvider, { context: "tla", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_a11y.TldrawUiA11yProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_breakpoints.BreakPointProvider, { forceMobile, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.TldrawUiComponentsProvider, { overrides: components, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(InternalProviders, { overrides, children }) }) }) }) }) }) })
54
55
  }
55
- ) }) });
56
+ ) }) }) });
56
57
  });
57
58
  function InternalProviders({
58
59
  overrides,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/lib/ui/context/TldrawUiContextProvider.tsx"],
4
- "sourcesContent": ["import { RecursivePartial, defaultUserPreferences, track, useMaybeEditor } from '@tldraw/editor'\nimport { ReactNode } from 'react'\nimport { TLUiAssetUrls, useDefaultUiAssetUrlsWithOverrides } from '../assetUrls'\nimport { ToolsProvider } from '../hooks/useTools'\nimport { TldrawUiTranslationProvider } from '../hooks/useTranslation/useTranslation'\nimport {\n\tMimeTypeContext,\n\tTLUiOverrides,\n\tuseMergedOverrides,\n\tuseMergedTranslationOverrides,\n} from '../overrides'\nimport { TldrawUiA11yProvider } from './a11y'\nimport { ActionsProvider } from './actions'\nimport { AssetUrlsProvider } from './asset-urls'\nimport { BreakPointProvider } from './breakpoints'\nimport { TLUiComponents, TldrawUiComponentsProvider } from './components'\nimport { TldrawUiDialogsProvider } from './dialogs'\nimport { TLUiEventHandler, TldrawUiEventsProvider } from './events'\nimport { TldrawUiToastsProvider } from './toasts'\n\n/** @public */\nexport interface TLUiContextProviderProps {\n\t/**\n\t * Urls for where to find fonts and other assets for the UI.\n\t */\n\tassetUrls?: RecursivePartial<TLUiAssetUrls>\n\n\t/**\n\t * Overrides for the UI.\n\t */\n\toverrides?: TLUiOverrides | TLUiOverrides[]\n\n\t/**\n\t * Overrides for the UI components.\n\t */\n\tcomponents?: TLUiComponents\n\n\t/**\n\t * Callback for when an event occurs in the UI.\n\t */\n\tonUiEvent?: TLUiEventHandler\n\n\t/**\n\t * Whether to always should the mobile breakpoints.\n\t */\n\tforceMobile?: boolean\n\n\t/**\n\t * The component's children.\n\t */\n\tchildren?: ReactNode\n\n\t/**\n\t * Supported mime types for media files.\n\t */\n\tmediaMimeTypes?: string[]\n}\n\n/** @public @react */\nexport const TldrawUiContextProvider = track(function TldrawUiContextProvider({\n\toverrides,\n\tcomponents,\n\tassetUrls,\n\tonUiEvent,\n\tforceMobile,\n\tmediaMimeTypes,\n\tchildren,\n}: TLUiContextProviderProps) {\n\t// To allow mounting the sidebar without an editor running, we use a 'maybe' editor here\n\t// The sidebar makes use of toasts and dialogs etc, which typically require an editor to be present\n\t// but we are overriding the providers to allow them to be used without an editor.\n\tconst editor = useMaybeEditor()\n\treturn (\n\t\t<MimeTypeContext.Provider value={mediaMimeTypes}>\n\t\t\t<AssetUrlsProvider assetUrls={useDefaultUiAssetUrlsWithOverrides(assetUrls)}>\n\t\t\t\t<TldrawUiTranslationProvider\n\t\t\t\t\toverrides={useMergedTranslationOverrides(overrides)}\n\t\t\t\t\tlocale={editor?.user.getLocale() ?? defaultUserPreferences.locale}\n\t\t\t\t>\n\t\t\t\t\t<TldrawUiEventsProvider onEvent={onUiEvent}>\n\t\t\t\t\t\t<TldrawUiToastsProvider>\n\t\t\t\t\t\t\t<TldrawUiDialogsProvider context={'tla'}>\n\t\t\t\t\t\t\t\t<TldrawUiA11yProvider>\n\t\t\t\t\t\t\t\t\t<BreakPointProvider forceMobile={forceMobile}>\n\t\t\t\t\t\t\t\t\t\t<TldrawUiComponentsProvider overrides={components}>\n\t\t\t\t\t\t\t\t\t\t\t<InternalProviders overrides={overrides}>{children}</InternalProviders>\n\t\t\t\t\t\t\t\t\t\t</TldrawUiComponentsProvider>\n\t\t\t\t\t\t\t\t\t</BreakPointProvider>\n\t\t\t\t\t\t\t\t</TldrawUiA11yProvider>\n\t\t\t\t\t\t\t</TldrawUiDialogsProvider>\n\t\t\t\t\t\t</TldrawUiToastsProvider>\n\t\t\t\t\t</TldrawUiEventsProvider>\n\t\t\t\t</TldrawUiTranslationProvider>\n\t\t\t</AssetUrlsProvider>\n\t\t</MimeTypeContext.Provider>\n\t)\n})\n\nfunction InternalProviders({\n\toverrides,\n\tchildren,\n}: Omit<TLUiContextProviderProps, 'assetBaseUrl'>) {\n\tconst mergedOverrides = useMergedOverrides(overrides)\n\treturn (\n\t\t<ActionsProvider overrides={mergedOverrides.actions}>\n\t\t\t<ToolsProvider overrides={mergedOverrides.tools}>{children}</ToolsProvider>\n\t\t</ActionsProvider>\n\t)\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAqFW;AArFX,oBAAgF;AAEhF,uBAAkE;AAClE,sBAA8B;AAC9B,4BAA4C;AAC5C,uBAKO;AACP,kBAAqC;AACrC,qBAAgC;AAChC,wBAAkC;AAClC,yBAAmC;AACnC,wBAA2D;AAC3D,qBAAwC;AACxC,oBAAyD;AACzD,oBAAuC;AAyChC,MAAM,8BAA0B,qBAAM,SAASA,yBAAwB;AAAA,EAC7E;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAA6B;AAI5B,QAAM,aAAS,8BAAe;AAC9B,SACC,4CAAC,iCAAgB,UAAhB,EAAyB,OAAO,gBAChC,sDAAC,uCAAkB,eAAW,qDAAmC,SAAS,GACzE;AAAA,IAAC;AAAA;AAAA,MACA,eAAW,gDAA8B,SAAS;AAAA,MAClD,QAAQ,QAAQ,KAAK,UAAU,KAAK,qCAAuB;AAAA,MAE3D,sDAAC,wCAAuB,SAAS,WAChC,sDAAC,wCACA,sDAAC,0CAAwB,SAAS,OACjC,sDAAC,oCACA,sDAAC,yCAAmB,aACnB,sDAAC,gDAA2B,WAAW,YACtC,sDAAC,qBAAkB,WAAuB,UAAS,GACpD,GACD,GACD,GACD,GACD,GACD;AAAA;AAAA,EACD,GACD,GACD;AAEF,CAAC;AAED,SAAS,kBAAkB;AAAA,EAC1B;AAAA,EACA;AACD,GAAmD;AAClD,QAAM,sBAAkB,qCAAmB,SAAS;AACpD,SACC,4CAAC,kCAAgB,WAAW,gBAAgB,SAC3C,sDAAC,iCAAc,WAAW,gBAAgB,OAAQ,UAAS,GAC5D;AAEF;",
4
+ "sourcesContent": ["import { RecursivePartial, defaultUserPreferences, track, useMaybeEditor } from '@tldraw/editor'\nimport { ReactNode } from 'react'\nimport { TLUiAssetUrls, useDefaultUiAssetUrlsWithOverrides } from '../assetUrls'\nimport { TldrawUiTooltipProvider } from '../components/primitives/TldrawUiTooltip'\nimport { ToolsProvider } from '../hooks/useTools'\nimport { TldrawUiTranslationProvider } from '../hooks/useTranslation/useTranslation'\nimport {\n\tMimeTypeContext,\n\tTLUiOverrides,\n\tuseMergedOverrides,\n\tuseMergedTranslationOverrides,\n} from '../overrides'\nimport { TldrawUiA11yProvider } from './a11y'\nimport { ActionsProvider } from './actions'\nimport { AssetUrlsProvider } from './asset-urls'\nimport { BreakPointProvider } from './breakpoints'\nimport { TLUiComponents, TldrawUiComponentsProvider } from './components'\nimport { TldrawUiDialogsProvider } from './dialogs'\nimport { TLUiEventHandler, TldrawUiEventsProvider } from './events'\nimport { TldrawUiToastsProvider } from './toasts'\n\n/** @public */\nexport interface TLUiContextProviderProps {\n\t/**\n\t * Urls for where to find fonts and other assets for the UI.\n\t */\n\tassetUrls?: RecursivePartial<TLUiAssetUrls>\n\n\t/**\n\t * Overrides for the UI.\n\t */\n\toverrides?: TLUiOverrides | TLUiOverrides[]\n\n\t/**\n\t * Overrides for the UI components.\n\t */\n\tcomponents?: TLUiComponents\n\n\t/**\n\t * Callback for when an event occurs in the UI.\n\t */\n\tonUiEvent?: TLUiEventHandler\n\n\t/**\n\t * Whether to always should the mobile breakpoints.\n\t */\n\tforceMobile?: boolean\n\n\t/**\n\t * The component's children.\n\t */\n\tchildren?: ReactNode\n\n\t/**\n\t * Supported mime types for media files.\n\t */\n\tmediaMimeTypes?: string[]\n}\n\n/** @public @react */\nexport const TldrawUiContextProvider = track(function TldrawUiContextProvider({\n\toverrides,\n\tcomponents,\n\tassetUrls,\n\tonUiEvent,\n\tforceMobile,\n\tmediaMimeTypes,\n\tchildren,\n}: TLUiContextProviderProps) {\n\t// To allow mounting the sidebar without an editor running, we use a 'maybe' editor here\n\t// The sidebar makes use of toasts and dialogs etc, which typically require an editor to be present\n\t// but we are overriding the providers to allow them to be used without an editor.\n\tconst editor = useMaybeEditor()\n\treturn (\n\t\t<MimeTypeContext.Provider value={mediaMimeTypes}>\n\t\t\t<TldrawUiTooltipProvider>\n\t\t\t\t<AssetUrlsProvider assetUrls={useDefaultUiAssetUrlsWithOverrides(assetUrls)}>\n\t\t\t\t\t<TldrawUiTranslationProvider\n\t\t\t\t\t\toverrides={useMergedTranslationOverrides(overrides)}\n\t\t\t\t\t\tlocale={editor?.user.getLocale() ?? defaultUserPreferences.locale}\n\t\t\t\t\t>\n\t\t\t\t\t\t<TldrawUiEventsProvider onEvent={onUiEvent}>\n\t\t\t\t\t\t\t<TldrawUiToastsProvider>\n\t\t\t\t\t\t\t\t<TldrawUiDialogsProvider context={'tla'}>\n\t\t\t\t\t\t\t\t\t<TldrawUiA11yProvider>\n\t\t\t\t\t\t\t\t\t\t<BreakPointProvider forceMobile={forceMobile}>\n\t\t\t\t\t\t\t\t\t\t\t<TldrawUiComponentsProvider overrides={components}>\n\t\t\t\t\t\t\t\t\t\t\t\t<InternalProviders overrides={overrides}>{children}</InternalProviders>\n\t\t\t\t\t\t\t\t\t\t\t</TldrawUiComponentsProvider>\n\t\t\t\t\t\t\t\t\t\t</BreakPointProvider>\n\t\t\t\t\t\t\t\t\t</TldrawUiA11yProvider>\n\t\t\t\t\t\t\t\t</TldrawUiDialogsProvider>\n\t\t\t\t\t\t\t</TldrawUiToastsProvider>\n\t\t\t\t\t\t</TldrawUiEventsProvider>\n\t\t\t\t\t</TldrawUiTranslationProvider>\n\t\t\t\t</AssetUrlsProvider>\n\t\t\t</TldrawUiTooltipProvider>\n\t\t</MimeTypeContext.Provider>\n\t)\n})\n\nfunction InternalProviders({\n\toverrides,\n\tchildren,\n}: Omit<TLUiContextProviderProps, 'assetBaseUrl'>) {\n\tconst mergedOverrides = useMergedOverrides(overrides)\n\treturn (\n\t\t<ActionsProvider overrides={mergedOverrides.actions}>\n\t\t\t<ToolsProvider overrides={mergedOverrides.tools}>{children}</ToolsProvider>\n\t\t</ActionsProvider>\n\t)\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAuFY;AAvFZ,oBAAgF;AAEhF,uBAAkE;AAClE,6BAAwC;AACxC,sBAA8B;AAC9B,4BAA4C;AAC5C,uBAKO;AACP,kBAAqC;AACrC,qBAAgC;AAChC,wBAAkC;AAClC,yBAAmC;AACnC,wBAA2D;AAC3D,qBAAwC;AACxC,oBAAyD;AACzD,oBAAuC;AAyChC,MAAM,8BAA0B,qBAAM,SAASA,yBAAwB;AAAA,EAC7E;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAA6B;AAI5B,QAAM,aAAS,8BAAe;AAC9B,SACC,4CAAC,iCAAgB,UAAhB,EAAyB,OAAO,gBAChC,sDAAC,kDACA,sDAAC,uCAAkB,eAAW,qDAAmC,SAAS,GACzE;AAAA,IAAC;AAAA;AAAA,MACA,eAAW,gDAA8B,SAAS;AAAA,MAClD,QAAQ,QAAQ,KAAK,UAAU,KAAK,qCAAuB;AAAA,MAE3D,sDAAC,wCAAuB,SAAS,WAChC,sDAAC,wCACA,sDAAC,0CAAwB,SAAS,OACjC,sDAAC,oCACA,sDAAC,yCAAmB,aACnB,sDAAC,gDAA2B,WAAW,YACtC,sDAAC,qBAAkB,WAAuB,UAAS,GACpD,GACD,GACD,GACD,GACD,GACD;AAAA;AAAA,EACD,GACD,GACD,GACD;AAEF,CAAC;AAED,SAAS,kBAAkB;AAAA,EAC1B;AAAA,EACA;AACD,GAAmD;AAClD,QAAM,sBAAkB,qCAAmB,SAAS;AACpD,SACC,4CAAC,kCAAgB,WAAW,gBAAgB,SAC3C,sDAAC,iCAAc,WAAW,gBAAgB,OAAQ,UAAS,GAC5D;AAEF;",
6
6
  "names": ["TldrawUiContextProvider"]
7
7
  }
@@ -1148,6 +1148,21 @@ function ActionsProvider({ overrides, children }) {
1148
1148
  },
1149
1149
  checkbox: true
1150
1150
  },
1151
+ {
1152
+ id: "toggle-ui-labels",
1153
+ label: {
1154
+ default: "action.toggle-ui-labels",
1155
+ menu: "action.toggle-ui-labels.menu"
1156
+ },
1157
+ readonlyOk: true,
1158
+ onSelect(source) {
1159
+ trackEvent("toggle-ui-labels", { source });
1160
+ editor.user.updateUserPreferences({
1161
+ showUiLabels: !editor.user.getShowUiLabels()
1162
+ });
1163
+ },
1164
+ checkbox: true
1165
+ },
1151
1166
  {
1152
1167
  id: "toggle-edge-scrolling",
1153
1168
  label: {