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.
- package/dist-cjs/index.d.ts +32 -34
- package/dist-cjs/index.js +7 -2
- package/dist-cjs/index.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/usePrefersReducedMotion.js +10 -1
- package/dist-cjs/lib/shapes/shared/usePrefersReducedMotion.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Translating.js.map +2 -2
- package/dist-cjs/lib/ui/components/AccessibilityMenu.js +35 -0
- package/dist-cjs/lib/ui/components/AccessibilityMenu.js.map +7 -0
- package/dist-cjs/lib/ui/components/MainMenu/DefaultMainMenuContent.js +3 -3
- package/dist-cjs/lib/ui/components/MainMenu/DefaultMainMenuContent.js.map +2 -2
- package/dist-cjs/lib/ui/components/StylePanel/DefaultStylePanel.js +2 -0
- package/dist-cjs/lib/ui/components/StylePanel/DefaultStylePanel.js.map +2 -2
- package/dist-cjs/lib/ui/components/StylePanel/DefaultStylePanelContent.js +168 -137
- package/dist-cjs/lib/ui/components/StylePanel/DefaultStylePanelContent.js.map +2 -2
- package/dist-cjs/lib/ui/components/Toolbar/OverflowingToolbar.js +3 -3
- package/dist-cjs/lib/ui/components/Toolbar/OverflowingToolbar.js.map +2 -2
- package/dist-cjs/lib/ui/components/Toolbar/ToggleToolLockedButton.js +3 -2
- package/dist-cjs/lib/ui/components/Toolbar/ToggleToolLockedButton.js.map +2 -2
- package/dist-cjs/lib/ui/components/menu-items.js +6 -0
- package/dist-cjs/lib/ui/components/menu-items.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/TldrawUiToolbar.js +11 -3
- package/dist-cjs/lib/ui/components/primitives/TldrawUiToolbar.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/TldrawUiTooltip.js +267 -0
- package/dist-cjs/lib/ui/components/primitives/TldrawUiTooltip.js.map +7 -0
- package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuItem.js +1 -149
- package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuItem.js.map +2 -2
- package/dist-cjs/lib/ui/context/TldrawUiContextProvider.js +3 -2
- package/dist-cjs/lib/ui/context/TldrawUiContextProvider.js.map +2 -2
- package/dist-cjs/lib/ui/context/actions.js +15 -0
- package/dist-cjs/lib/ui/context/actions.js.map +2 -2
- package/dist-cjs/lib/ui/context/events.js.map +1 -1
- package/dist-cjs/lib/ui/hooks/useTools.js +9 -76
- package/dist-cjs/lib/ui/hooks/useTools.js.map +2 -2
- package/dist-cjs/lib/ui/hooks/useTranslation/TLUiTranslationKey.js.map +1 -1
- package/dist-cjs/lib/ui/hooks/useTranslation/defaultTranslation.js +3 -0
- package/dist-cjs/lib/ui/hooks/useTranslation/defaultTranslation.js.map +2 -2
- package/dist-cjs/lib/ui/version.js +3 -3
- package/dist-cjs/lib/ui/version.js.map +1 -1
- package/dist-esm/index.d.mts +32 -34
- package/dist-esm/index.mjs +11 -3
- package/dist-esm/index.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/usePrefersReducedMotion.mjs +10 -1
- package/dist-esm/lib/shapes/shared/usePrefersReducedMotion.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Translating.mjs.map +2 -2
- package/dist-esm/lib/ui/components/AccessibilityMenu.mjs +19 -0
- package/dist-esm/lib/ui/components/AccessibilityMenu.mjs.map +7 -0
- package/dist-esm/lib/ui/components/MainMenu/DefaultMainMenuContent.mjs +3 -5
- package/dist-esm/lib/ui/components/MainMenu/DefaultMainMenuContent.mjs.map +2 -2
- package/dist-esm/lib/ui/components/StylePanel/DefaultStylePanel.mjs +3 -1
- package/dist-esm/lib/ui/components/StylePanel/DefaultStylePanel.mjs.map +2 -2
- package/dist-esm/lib/ui/components/StylePanel/DefaultStylePanelContent.mjs +168 -137
- package/dist-esm/lib/ui/components/StylePanel/DefaultStylePanelContent.mjs.map +2 -2
- package/dist-esm/lib/ui/components/Toolbar/OverflowingToolbar.mjs +3 -3
- package/dist-esm/lib/ui/components/Toolbar/OverflowingToolbar.mjs.map +2 -2
- package/dist-esm/lib/ui/components/Toolbar/ToggleToolLockedButton.mjs +3 -2
- package/dist-esm/lib/ui/components/Toolbar/ToggleToolLockedButton.mjs.map +2 -2
- package/dist-esm/lib/ui/components/menu-items.mjs +6 -0
- package/dist-esm/lib/ui/components/menu-items.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiToolbar.mjs +11 -3
- package/dist-esm/lib/ui/components/primitives/TldrawUiToolbar.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiTooltip.mjs +237 -0
- package/dist-esm/lib/ui/components/primitives/TldrawUiTooltip.mjs.map +7 -0
- package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuItem.mjs +3 -157
- package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuItem.mjs.map +2 -2
- package/dist-esm/lib/ui/context/TldrawUiContextProvider.mjs +3 -2
- package/dist-esm/lib/ui/context/TldrawUiContextProvider.mjs.map +2 -2
- package/dist-esm/lib/ui/context/actions.mjs +15 -0
- package/dist-esm/lib/ui/context/actions.mjs.map +2 -2
- package/dist-esm/lib/ui/context/events.mjs.map +1 -1
- package/dist-esm/lib/ui/hooks/useTools.mjs +10 -83
- package/dist-esm/lib/ui/hooks/useTools.mjs.map +2 -2
- package/dist-esm/lib/ui/hooks/useTranslation/defaultTranslation.mjs +3 -0
- package/dist-esm/lib/ui/hooks/useTranslation/defaultTranslation.mjs.map +2 -2
- package/dist-esm/lib/ui/version.mjs +3 -3
- package/dist-esm/lib/ui/version.mjs.map +1 -1
- package/package.json +3 -3
- package/src/index.ts +8 -2
- package/src/lib/shapes/shared/usePrefersReducedMotion.tsx +11 -1
- package/src/lib/tools/SelectTool/childStates/Translating.ts +1 -0
- package/src/lib/ui/components/AccessibilityMenu.tsx +20 -0
- package/src/lib/ui/components/MainMenu/DefaultMainMenuContent.tsx +4 -4
- package/src/lib/ui/components/StylePanel/DefaultStylePanel.tsx +3 -1
- package/src/lib/ui/components/StylePanel/DefaultStylePanelContent.tsx +171 -128
- package/src/lib/ui/components/Toolbar/OverflowingToolbar.tsx +3 -3
- package/src/lib/ui/components/Toolbar/ToggleToolLockedButton.tsx +14 -11
- package/src/lib/ui/components/menu-items.tsx +8 -0
- package/src/lib/ui/components/primitives/TldrawUiToolbar.tsx +19 -3
- package/src/lib/ui/components/primitives/TldrawUiTooltip.tsx +313 -0
- package/src/lib/ui/components/primitives/menus/TldrawUiMenuItem.tsx +2 -213
- package/src/lib/ui/context/TldrawUiContextProvider.tsx +23 -20
- package/src/lib/ui/context/actions.tsx +15 -0
- package/src/lib/ui/context/events.tsx +1 -1
- package/src/lib/ui/hooks/useTools.tsx +10 -118
- package/src/lib/ui/hooks/useTranslation/TLUiTranslationKey.ts +3 -0
- package/src/lib/ui/hooks/useTranslation/defaultTranslation.ts +3 -0
- package/src/lib/ui/version.ts +3 -3
- package/src/lib/ui.css +57 -1
- package/tldraw.css +59 -1
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
exhaustiveSwitchError,
|
|
4
|
-
getPointerInfo,
|
|
5
|
-
preventDefault,
|
|
6
|
-
useEditor,
|
|
7
|
-
Vec
|
|
8
|
-
} from "@tldraw/editor";
|
|
2
|
+
import { exhaustiveSwitchError, preventDefault } from "@tldraw/editor";
|
|
9
3
|
import { ContextMenu as _ContextMenu } from "radix-ui";
|
|
10
|
-
import {
|
|
4
|
+
import { useState } from "react";
|
|
11
5
|
import { unwrapLabel } from "../../../context/actions.mjs";
|
|
12
6
|
import { useReadonly } from "../../../hooks/useReadonly.mjs";
|
|
13
7
|
import { useTranslation } from "../../../hooks/useTranslation/useTranslation.mjs";
|
|
@@ -31,8 +25,7 @@ function TldrawUiMenuItem({
|
|
|
31
25
|
iconLeft,
|
|
32
26
|
onSelect,
|
|
33
27
|
noClose,
|
|
34
|
-
isSelected
|
|
35
|
-
onDragStart
|
|
28
|
+
isSelected
|
|
36
29
|
}) {
|
|
37
30
|
const { type: menuType, sourceId } = useTldrawUiMenuContext();
|
|
38
31
|
const msg = useTranslation();
|
|
@@ -146,21 +139,6 @@ function TldrawUiMenuItem({
|
|
|
146
139
|
] });
|
|
147
140
|
}
|
|
148
141
|
case "toolbar": {
|
|
149
|
-
if (onDragStart) {
|
|
150
|
-
return /* @__PURE__ */ jsx(
|
|
151
|
-
DraggableToolbarButton,
|
|
152
|
-
{
|
|
153
|
-
id,
|
|
154
|
-
icon,
|
|
155
|
-
onSelect,
|
|
156
|
-
onDragStart,
|
|
157
|
-
labelToUse,
|
|
158
|
-
titleStr,
|
|
159
|
-
disabled,
|
|
160
|
-
isSelected
|
|
161
|
-
}
|
|
162
|
-
);
|
|
163
|
-
}
|
|
164
142
|
return /* @__PURE__ */ jsx(
|
|
165
143
|
TldrawUiToolbarButton,
|
|
166
144
|
{
|
|
@@ -181,22 +159,6 @@ function TldrawUiMenuItem({
|
|
|
181
159
|
);
|
|
182
160
|
}
|
|
183
161
|
case "toolbar-overflow": {
|
|
184
|
-
if (onDragStart) {
|
|
185
|
-
return /* @__PURE__ */ jsx(
|
|
186
|
-
DraggableToolbarButton,
|
|
187
|
-
{
|
|
188
|
-
id,
|
|
189
|
-
icon,
|
|
190
|
-
onSelect,
|
|
191
|
-
onDragStart,
|
|
192
|
-
labelToUse,
|
|
193
|
-
titleStr,
|
|
194
|
-
disabled,
|
|
195
|
-
isSelected,
|
|
196
|
-
overflow: true
|
|
197
|
-
}
|
|
198
|
-
);
|
|
199
|
-
}
|
|
200
162
|
return /* @__PURE__ */ jsx(
|
|
201
163
|
TldrawUiToolbarButton,
|
|
202
164
|
{
|
|
@@ -219,122 +181,6 @@ function TldrawUiMenuItem({
|
|
|
219
181
|
}
|
|
220
182
|
}
|
|
221
183
|
}
|
|
222
|
-
function useDraggableEvents(onDragStart, onSelect) {
|
|
223
|
-
const editor = useEditor();
|
|
224
|
-
const events = useMemo(() => {
|
|
225
|
-
let state = { name: "idle" };
|
|
226
|
-
function handlePointerDown(e) {
|
|
227
|
-
state = {
|
|
228
|
-
name: "pointing",
|
|
229
|
-
start: editor.inputs.currentPagePoint.clone()
|
|
230
|
-
};
|
|
231
|
-
e.currentTarget.setPointerCapture(e.pointerId);
|
|
232
|
-
}
|
|
233
|
-
function handlePointerMove(e) {
|
|
234
|
-
if (e.isSpecialRedispatchedEvent) return;
|
|
235
|
-
if (state.name === "pointing") {
|
|
236
|
-
const distance = Vec.Dist2(state.start, editor.inputs.currentPagePoint);
|
|
237
|
-
if (distance > (editor.getInstanceState().isCoarsePointer ? editor.options.coarseDragDistanceSquared : editor.options.dragDistanceSquared)) {
|
|
238
|
-
const start = state.start;
|
|
239
|
-
state = {
|
|
240
|
-
name: "dragging",
|
|
241
|
-
start
|
|
242
|
-
};
|
|
243
|
-
editor.run(() => {
|
|
244
|
-
editor.dispatch({
|
|
245
|
-
type: "pointer",
|
|
246
|
-
target: "canvas",
|
|
247
|
-
name: "pointer_down",
|
|
248
|
-
...getPointerInfo(e),
|
|
249
|
-
point: start
|
|
250
|
-
});
|
|
251
|
-
editor.selectNone();
|
|
252
|
-
onDragStart?.("toolbar", {
|
|
253
|
-
type: "pointer",
|
|
254
|
-
target: "canvas",
|
|
255
|
-
name: "pointer_move",
|
|
256
|
-
...getPointerInfo(e)
|
|
257
|
-
});
|
|
258
|
-
});
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
function handlePointerUp(e) {
|
|
263
|
-
if (e.isSpecialRedispatchedEvent) return;
|
|
264
|
-
e.currentTarget.releasePointerCapture(e.pointerId);
|
|
265
|
-
editor.dispatch({
|
|
266
|
-
type: "pointer",
|
|
267
|
-
target: "canvas",
|
|
268
|
-
name: "pointer_up",
|
|
269
|
-
...getPointerInfo(e)
|
|
270
|
-
});
|
|
271
|
-
}
|
|
272
|
-
function handleClick() {
|
|
273
|
-
if (state.name === "dragging" || state.name === "dragged") {
|
|
274
|
-
state = { name: "idle" };
|
|
275
|
-
return true;
|
|
276
|
-
}
|
|
277
|
-
state = { name: "idle" };
|
|
278
|
-
onSelect?.("toolbar");
|
|
279
|
-
}
|
|
280
|
-
return {
|
|
281
|
-
onPointerDown: handlePointerDown,
|
|
282
|
-
onPointerMove: handlePointerMove,
|
|
283
|
-
onPointerUp: handlePointerUp,
|
|
284
|
-
onClick: handleClick
|
|
285
|
-
};
|
|
286
|
-
}, [onDragStart, editor, onSelect]);
|
|
287
|
-
return events;
|
|
288
|
-
}
|
|
289
|
-
function DraggableToolbarButton({
|
|
290
|
-
id,
|
|
291
|
-
labelToUse,
|
|
292
|
-
titleStr,
|
|
293
|
-
disabled,
|
|
294
|
-
isSelected,
|
|
295
|
-
icon,
|
|
296
|
-
onSelect,
|
|
297
|
-
onDragStart,
|
|
298
|
-
overflow
|
|
299
|
-
}) {
|
|
300
|
-
const events = useDraggableEvents(onDragStart, onSelect);
|
|
301
|
-
if (overflow) {
|
|
302
|
-
return /* @__PURE__ */ jsx(
|
|
303
|
-
TldrawUiToolbarButton,
|
|
304
|
-
{
|
|
305
|
-
"aria-label": labelToUse,
|
|
306
|
-
"aria-pressed": isSelected ? "true" : "false",
|
|
307
|
-
isActive: isSelected,
|
|
308
|
-
className: "tlui-button-grid__button",
|
|
309
|
-
"data-testid": `tools.more.${id}`,
|
|
310
|
-
"data-value": id,
|
|
311
|
-
disabled,
|
|
312
|
-
title: titleStr,
|
|
313
|
-
type: "icon",
|
|
314
|
-
...events,
|
|
315
|
-
children: /* @__PURE__ */ jsx(TldrawUiButtonIcon, { icon })
|
|
316
|
-
}
|
|
317
|
-
);
|
|
318
|
-
}
|
|
319
|
-
return /* @__PURE__ */ jsx(
|
|
320
|
-
TldrawUiToolbarButton,
|
|
321
|
-
{
|
|
322
|
-
"aria-label": labelToUse,
|
|
323
|
-
"aria-pressed": isSelected ? "true" : "false",
|
|
324
|
-
"data-testid": `tools.${id}`,
|
|
325
|
-
"data-value": id,
|
|
326
|
-
disabled,
|
|
327
|
-
onTouchStart: (e) => {
|
|
328
|
-
preventDefault(e);
|
|
329
|
-
onSelect("toolbar");
|
|
330
|
-
},
|
|
331
|
-
title: titleStr,
|
|
332
|
-
type: "tool",
|
|
333
|
-
...events,
|
|
334
|
-
children: /* @__PURE__ */ jsx(TldrawUiButtonIcon, { icon })
|
|
335
|
-
}
|
|
336
|
-
);
|
|
337
|
-
}
|
|
338
184
|
export {
|
|
339
185
|
TldrawUiMenuItem
|
|
340
186
|
};
|
|
@@ -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": "
|
|
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": "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",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { defaultUserPreferences, track, useMaybeEditor } from "@tldraw/editor";
|
|
3
3
|
import { useDefaultUiAssetUrlsWithOverrides } from "../assetUrls.mjs";
|
|
4
|
+
import { TldrawUiTooltipProvider } from "../components/primitives/TldrawUiTooltip.mjs";
|
|
4
5
|
import { ToolsProvider } from "../hooks/useTools.mjs";
|
|
5
6
|
import { TldrawUiTranslationProvider } from "../hooks/useTranslation/useTranslation.mjs";
|
|
6
7
|
import {
|
|
@@ -26,14 +27,14 @@ const TldrawUiContextProvider = track(function TldrawUiContextProvider2({
|
|
|
26
27
|
children
|
|
27
28
|
}) {
|
|
28
29
|
const editor = useMaybeEditor();
|
|
29
|
-
return /* @__PURE__ */ jsx(MimeTypeContext.Provider, { value: mediaMimeTypes, children: /* @__PURE__ */ jsx(AssetUrlsProvider, { assetUrls: useDefaultUiAssetUrlsWithOverrides(assetUrls), children: /* @__PURE__ */ jsx(
|
|
30
|
+
return /* @__PURE__ */ jsx(MimeTypeContext.Provider, { value: mediaMimeTypes, children: /* @__PURE__ */ jsx(TldrawUiTooltipProvider, { children: /* @__PURE__ */ jsx(AssetUrlsProvider, { assetUrls: useDefaultUiAssetUrlsWithOverrides(assetUrls), children: /* @__PURE__ */ jsx(
|
|
30
31
|
TldrawUiTranslationProvider,
|
|
31
32
|
{
|
|
32
33
|
overrides: useMergedTranslationOverrides(overrides),
|
|
33
34
|
locale: editor?.user.getLocale() ?? defaultUserPreferences.locale,
|
|
34
35
|
children: /* @__PURE__ */ jsx(TldrawUiEventsProvider, { onEvent: onUiEvent, children: /* @__PURE__ */ jsx(TldrawUiToastsProvider, { children: /* @__PURE__ */ jsx(TldrawUiDialogsProvider, { context: "tla", children: /* @__PURE__ */ jsx(TldrawUiA11yProvider, { children: /* @__PURE__ */ jsx(BreakPointProvider, { forceMobile, children: /* @__PURE__ */ jsx(TldrawUiComponentsProvider, { overrides: components, children: /* @__PURE__ */ jsx(InternalProviders, { overrides, children }) }) }) }) }) }) })
|
|
35
36
|
}
|
|
36
|
-
) }) });
|
|
37
|
+
) }) }) });
|
|
37
38
|
});
|
|
38
39
|
function InternalProviders({
|
|
39
40
|
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": "
|
|
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": "AAuFY;AAvFZ,SAA2B,wBAAwB,OAAO,sBAAsB;AAEhF,SAAwB,0CAA0C;AAClE,SAAS,+BAA+B;AACxC,SAAS,qBAAqB;AAC9B,SAAS,mCAAmC;AAC5C;AAAA,EACC;AAAA,EAEA;AAAA,EACA;AAAA,OACM;AACP,SAAS,4BAA4B;AACrC,SAAS,uBAAuB;AAChC,SAAS,yBAAyB;AAClC,SAAS,0BAA0B;AACnC,SAAyB,kCAAkC;AAC3D,SAAS,+BAA+B;AACxC,SAA2B,8BAA8B;AACzD,SAAS,8BAA8B;AAyChC,MAAM,0BAA0B,MAAM,SAASA,yBAAwB;AAAA,EAC7E;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAA6B;AAI5B,QAAM,SAAS,eAAe;AAC9B,SACC,oBAAC,gBAAgB,UAAhB,EAAyB,OAAO,gBAChC,8BAAC,2BACA,8BAAC,qBAAkB,WAAW,mCAAmC,SAAS,GACzE;AAAA,IAAC;AAAA;AAAA,MACA,WAAW,8BAA8B,SAAS;AAAA,MAClD,QAAQ,QAAQ,KAAK,UAAU,KAAK,uBAAuB;AAAA,MAE3D,8BAAC,0BAAuB,SAAS,WAChC,8BAAC,0BACA,8BAAC,2BAAwB,SAAS,OACjC,8BAAC,wBACA,8BAAC,sBAAmB,aACnB,8BAAC,8BAA2B,WAAW,YACtC,8BAAC,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,kBAAkB,mBAAmB,SAAS;AACpD,SACC,oBAAC,mBAAgB,WAAW,gBAAgB,SAC3C,8BAAC,iBAAc,WAAW,gBAAgB,OAAQ,UAAS,GAC5D;AAEF;",
|
|
6
6
|
"names": ["TldrawUiContextProvider"]
|
|
7
7
|
}
|
|
@@ -1124,6 +1124,21 @@ function ActionsProvider({ overrides, children }) {
|
|
|
1124
1124
|
},
|
|
1125
1125
|
checkbox: true
|
|
1126
1126
|
},
|
|
1127
|
+
{
|
|
1128
|
+
id: "toggle-ui-labels",
|
|
1129
|
+
label: {
|
|
1130
|
+
default: "action.toggle-ui-labels",
|
|
1131
|
+
menu: "action.toggle-ui-labels.menu"
|
|
1132
|
+
},
|
|
1133
|
+
readonlyOk: true,
|
|
1134
|
+
onSelect(source) {
|
|
1135
|
+
trackEvent("toggle-ui-labels", { source });
|
|
1136
|
+
editor.user.updateUserPreferences({
|
|
1137
|
+
showUiLabels: !editor.user.getShowUiLabels()
|
|
1138
|
+
});
|
|
1139
|
+
},
|
|
1140
|
+
checkbox: true
|
|
1141
|
+
},
|
|
1127
1142
|
{
|
|
1128
1143
|
id: "toggle-edge-scrolling",
|
|
1129
1144
|
label: {
|