tldraw 3.16.0-canary.67f438ba104b → 3.16.0-canary.856874107ebd
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 +57 -3
- package/dist-cjs/index.js +10 -1
- package/dist-cjs/index.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/ArrowShapeUtil.js +3 -3
- package/dist-cjs/lib/shapes/arrow/ArrowShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/arrowTargetState.js +1 -1
- package/dist-cjs/lib/shapes/arrow/arrowTargetState.js.map +2 -2
- package/dist-cjs/lib/shapes/draw/DrawShapeUtil.js +3 -3
- package/dist-cjs/lib/shapes/draw/DrawShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/frame/FrameShapeUtil.js +12 -12
- package/dist-cjs/lib/shapes/frame/FrameShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/geo/GeoShapeUtil.js +2 -2
- package/dist-cjs/lib/shapes/geo/GeoShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/geo/components/GeoShapeBody.js +2 -1
- package/dist-cjs/lib/shapes/geo/components/GeoShapeBody.js.map +2 -2
- package/dist-cjs/lib/shapes/highlight/HighlightShapeUtil.js +5 -1
- package/dist-cjs/lib/shapes/highlight/HighlightShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/line/LineShapeUtil.js +5 -1
- package/dist-cjs/lib/shapes/line/LineShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/note/NoteShapeUtil.js +4 -4
- package/dist-cjs/lib/shapes/note/NoteShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/ShapeFill.js +5 -5
- package/dist-cjs/lib/shapes/shared/ShapeFill.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/shapes/text/TextShapeUtil.js +2 -2
- package/dist-cjs/lib/shapes/text/TextShapeUtil.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/ActionsMenu/DefaultActionsMenu.js +2 -1
- package/dist-cjs/lib/ui/components/ActionsMenu/DefaultActionsMenu.js.map +2 -2
- package/dist-cjs/lib/ui/components/DefaultMenuPanel.js +3 -2
- package/dist-cjs/lib/ui/components/DefaultMenuPanel.js.map +2 -2
- 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/MobileStylePanel.js +1 -1
- package/dist-cjs/lib/ui/components/MobileStylePanel.js.map +2 -2
- package/dist-cjs/lib/ui/components/NavigationPanel/DefaultNavigationPanel.js +1 -1
- package/dist-cjs/lib/ui/components/NavigationPanel/DefaultNavigationPanel.js.map +2 -2
- package/dist-cjs/lib/ui/components/PageMenu/DefaultPageMenu.js +2 -1
- package/dist-cjs/lib/ui/components/PageMenu/DefaultPageMenu.js.map +2 -2
- package/dist-cjs/lib/ui/components/SharePanel/PeopleMenuItem.js +3 -2
- package/dist-cjs/lib/ui/components/SharePanel/PeopleMenuItem.js.map +2 -2
- package/dist-cjs/lib/ui/components/SharePanel/UserPresenceColorPicker.js +2 -2
- package/dist-cjs/lib/ui/components/SharePanel/UserPresenceColorPicker.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 +171 -140
- package/dist-cjs/lib/ui/components/StylePanel/DefaultStylePanelContent.js.map +2 -2
- package/dist-cjs/lib/ui/components/StylePanel/DoubleDropdownPicker.js +3 -3
- package/dist-cjs/lib/ui/components/StylePanel/DoubleDropdownPicker.js.map +2 -2
- package/dist-cjs/lib/ui/components/StylePanel/DropdownPicker.js +26 -25
- package/dist-cjs/lib/ui/components/StylePanel/DropdownPicker.js.map +3 -3
- package/dist-cjs/lib/ui/components/Toolbar/DefaultToolbar.js +6 -5
- package/dist-cjs/lib/ui/components/Toolbar/DefaultToolbar.js.map +2 -2
- package/dist-cjs/lib/ui/components/Toolbar/OverflowingToolbar.js +9 -10
- package/dist-cjs/lib/ui/components/Toolbar/OverflowingToolbar.js.map +2 -2
- package/dist-cjs/lib/ui/components/Toolbar/ToggleToolLockedButton.js +5 -4
- 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/TldrawUiButtonPicker.js +5 -16
- package/dist-cjs/lib/ui/components/primitives/TldrawUiButtonPicker.js.map +3 -3
- package/dist-cjs/lib/ui/components/primitives/TldrawUiContextualToolbar.js +1 -1
- package/dist-cjs/lib/ui/components/primitives/TldrawUiContextualToolbar.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/TldrawUiPopover.js +3 -2
- package/dist-cjs/lib/ui/components/primitives/TldrawUiPopover.js.map +3 -3
- package/dist-cjs/lib/ui/components/primitives/TldrawUiToolbar.js +18 -7
- package/dist-cjs/lib/ui/components/primitives/TldrawUiToolbar.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/TldrawUiTooltip.js +284 -0
- package/dist-cjs/lib/ui/components/primitives/TldrawUiTooltip.js.map +7 -0
- package/dist-cjs/lib/ui/components/primitives/layout.js +51 -0
- package/dist-cjs/lib/ui/components/primitives/layout.js.map +7 -0
- package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuItem.js +10 -8
- 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 +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 +57 -3
- package/dist-esm/index.mjs +17 -1
- package/dist-esm/index.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/ArrowShapeUtil.mjs +4 -3
- package/dist-esm/lib/shapes/arrow/ArrowShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/arrowTargetState.mjs +1 -1
- package/dist-esm/lib/shapes/arrow/arrowTargetState.mjs.map +2 -2
- package/dist-esm/lib/shapes/draw/DrawShapeUtil.mjs +4 -3
- package/dist-esm/lib/shapes/draw/DrawShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/frame/FrameShapeUtil.mjs +13 -12
- package/dist-esm/lib/shapes/frame/FrameShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/geo/GeoShapeUtil.mjs +3 -2
- package/dist-esm/lib/shapes/geo/GeoShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/geo/components/GeoShapeBody.mjs +2 -1
- package/dist-esm/lib/shapes/geo/components/GeoShapeBody.mjs.map +2 -2
- package/dist-esm/lib/shapes/highlight/HighlightShapeUtil.mjs +6 -1
- package/dist-esm/lib/shapes/highlight/HighlightShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/line/LineShapeUtil.mjs +6 -1
- package/dist-esm/lib/shapes/line/LineShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/note/NoteShapeUtil.mjs +5 -4
- package/dist-esm/lib/shapes/note/NoteShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/ShapeFill.mjs +6 -5
- package/dist-esm/lib/shapes/shared/ShapeFill.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/shapes/text/TextShapeUtil.mjs +3 -2
- package/dist-esm/lib/shapes/text/TextShapeUtil.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/ActionsMenu/DefaultActionsMenu.mjs +2 -1
- package/dist-esm/lib/ui/components/ActionsMenu/DefaultActionsMenu.mjs.map +2 -2
- package/dist-esm/lib/ui/components/DefaultMenuPanel.mjs +3 -2
- package/dist-esm/lib/ui/components/DefaultMenuPanel.mjs.map +2 -2
- 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/MobileStylePanel.mjs +2 -1
- package/dist-esm/lib/ui/components/MobileStylePanel.mjs.map +2 -2
- package/dist-esm/lib/ui/components/NavigationPanel/DefaultNavigationPanel.mjs +1 -1
- package/dist-esm/lib/ui/components/NavigationPanel/DefaultNavigationPanel.mjs.map +2 -2
- package/dist-esm/lib/ui/components/PageMenu/DefaultPageMenu.mjs +2 -1
- package/dist-esm/lib/ui/components/PageMenu/DefaultPageMenu.mjs.map +2 -2
- package/dist-esm/lib/ui/components/SharePanel/PeopleMenuItem.mjs +3 -2
- package/dist-esm/lib/ui/components/SharePanel/PeopleMenuItem.mjs.map +2 -2
- package/dist-esm/lib/ui/components/SharePanel/UserPresenceColorPicker.mjs +2 -2
- package/dist-esm/lib/ui/components/SharePanel/UserPresenceColorPicker.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 +171 -140
- package/dist-esm/lib/ui/components/StylePanel/DefaultStylePanelContent.mjs.map +2 -2
- package/dist-esm/lib/ui/components/StylePanel/DoubleDropdownPicker.mjs +3 -3
- package/dist-esm/lib/ui/components/StylePanel/DoubleDropdownPicker.mjs.map +2 -2
- package/dist-esm/lib/ui/components/StylePanel/DropdownPicker.mjs +26 -25
- package/dist-esm/lib/ui/components/StylePanel/DropdownPicker.mjs.map +2 -2
- package/dist-esm/lib/ui/components/Toolbar/DefaultToolbar.mjs +6 -5
- package/dist-esm/lib/ui/components/Toolbar/DefaultToolbar.mjs.map +2 -2
- package/dist-esm/lib/ui/components/Toolbar/OverflowingToolbar.mjs +9 -10
- package/dist-esm/lib/ui/components/Toolbar/OverflowingToolbar.mjs.map +2 -2
- package/dist-esm/lib/ui/components/Toolbar/ToggleToolLockedButton.mjs +5 -4
- 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/TldrawUiButtonPicker.mjs +6 -6
- package/dist-esm/lib/ui/components/primitives/TldrawUiButtonPicker.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiContextualToolbar.mjs +1 -1
- package/dist-esm/lib/ui/components/primitives/TldrawUiContextualToolbar.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiPopover.mjs +3 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiPopover.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiToolbar.mjs +18 -7
- package/dist-esm/lib/ui/components/primitives/TldrawUiToolbar.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiTooltip.mjs +254 -0
- package/dist-esm/lib/ui/components/primitives/TldrawUiTooltip.mjs.map +7 -0
- package/dist-esm/lib/ui/components/primitives/layout.mjs +21 -0
- package/dist-esm/lib/ui/components/primitives/layout.mjs.map +7 -0
- package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuItem.mjs +10 -8
- 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 +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 +13 -0
- package/src/lib/shapes/arrow/ArrowShapeUtil.tsx +4 -3
- package/src/lib/shapes/arrow/arrowTargetState.ts +2 -1
- package/src/lib/shapes/draw/DrawShapeUtil.tsx +4 -3
- package/src/lib/shapes/frame/FrameShapeUtil.tsx +13 -14
- package/src/lib/shapes/geo/GeoShapeUtil.tsx +3 -2
- package/src/lib/shapes/geo/components/GeoShapeBody.tsx +2 -2
- package/src/lib/shapes/highlight/HighlightShapeUtil.tsx +7 -1
- package/src/lib/shapes/line/LineShapeUtil.tsx +6 -1
- package/src/lib/shapes/note/NoteShapeUtil.tsx +9 -4
- package/src/lib/shapes/shared/ShapeFill.tsx +6 -5
- package/src/lib/shapes/shared/usePrefersReducedMotion.tsx +11 -1
- package/src/lib/shapes/text/TextShapeUtil.tsx +3 -2
- package/src/lib/ui/components/AccessibilityMenu.tsx +20 -0
- package/src/lib/ui/components/ActionsMenu/DefaultActionsMenu.tsx +2 -1
- package/src/lib/ui/components/DefaultMenuPanel.tsx +4 -3
- package/src/lib/ui/components/MainMenu/DefaultMainMenuContent.tsx +4 -4
- package/src/lib/ui/components/MobileStylePanel.tsx +5 -3
- package/src/lib/ui/components/NavigationPanel/DefaultNavigationPanel.tsx +1 -1
- package/src/lib/ui/components/PageMenu/DefaultPageMenu.tsx +3 -2
- package/src/lib/ui/components/SharePanel/PeopleMenuItem.tsx +4 -3
- package/src/lib/ui/components/SharePanel/UserPresenceColorPicker.tsx +3 -3
- package/src/lib/ui/components/StylePanel/DefaultStylePanel.tsx +3 -1
- package/src/lib/ui/components/StylePanel/DefaultStylePanelContent.tsx +146 -107
- package/src/lib/ui/components/StylePanel/DoubleDropdownPicker.tsx +3 -3
- package/src/lib/ui/components/StylePanel/DropdownPicker.tsx +7 -6
- package/src/lib/ui/components/Toolbar/DefaultToolbar.tsx +7 -6
- package/src/lib/ui/components/Toolbar/OverflowingToolbar.tsx +10 -11
- 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/TldrawUiButtonPicker.tsx +40 -37
- package/src/lib/ui/components/primitives/TldrawUiContextualToolbar.tsx +1 -1
- package/src/lib/ui/components/primitives/TldrawUiPopover.tsx +4 -2
- package/src/lib/ui/components/primitives/TldrawUiToolbar.tsx +34 -12
- package/src/lib/ui/components/primitives/TldrawUiTooltip.tsx +332 -0
- package/src/lib/ui/components/primitives/layout.tsx +33 -0
- package/src/lib/ui/components/primitives/menus/TldrawUiMenuItem.tsx +13 -9
- 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 -0
- 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 +80 -69
- package/src/test/arrows-megabus.test.tsx +12 -6
- package/src/test/inner-outer-margin.test.ts +315 -0
- package/tldraw.css +82 -69
|
@@ -44,14 +44,15 @@ export const DefaultToolbar = memo(function DefaultToolbar({ children }: Default
|
|
|
44
44
|
: breakpoint < PORTRAIT_BREAKPOINT.TABLET
|
|
45
45
|
|
|
46
46
|
return (
|
|
47
|
-
<div ref={ref} className="tlui-toolbar">
|
|
48
|
-
<div className="tlui-toolbar__inner">
|
|
49
|
-
<div className="tlui-toolbar__left">
|
|
47
|
+
<div ref={ref} className="tlui-main-toolbar">
|
|
48
|
+
<div className="tlui-main-toolbar__inner">
|
|
49
|
+
<div className="tlui-main-toolbar__left">
|
|
50
50
|
{!isReadonlyMode && (
|
|
51
|
-
<div className="tlui-toolbar__extras">
|
|
51
|
+
<div className="tlui-main-toolbar__extras">
|
|
52
52
|
{showQuickActions && (
|
|
53
53
|
<TldrawUiToolbar
|
|
54
|
-
|
|
54
|
+
orientation="horizontal"
|
|
55
|
+
className="tlui-main-toolbar__extras__controls"
|
|
55
56
|
label={msg('actions-menu.title')}
|
|
56
57
|
>
|
|
57
58
|
{QuickActions && <QuickActions />}
|
|
@@ -64,7 +65,7 @@ export const DefaultToolbar = memo(function DefaultToolbar({ children }: Default
|
|
|
64
65
|
<OverflowingToolbar>{children ?? <DefaultToolbarContent />}</OverflowingToolbar>
|
|
65
66
|
</div>
|
|
66
67
|
{breakpoint < PORTRAIT_BREAKPOINT.TABLET_SM && !isReadonlyMode && (
|
|
67
|
-
<div className="tlui-toolbar__tools">
|
|
68
|
+
<div className="tlui-main-toolbar__tools">
|
|
68
69
|
<MobileStylePanel />
|
|
69
70
|
</div>
|
|
70
71
|
)}
|
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
TldrawUiPopoverTrigger,
|
|
21
21
|
} from '../primitives/TldrawUiPopover'
|
|
22
22
|
import { TldrawUiToolbar, TldrawUiToolbarButton } from '../primitives/TldrawUiToolbar'
|
|
23
|
+
import { TldrawUiRow } from '../primitives/layout'
|
|
23
24
|
import { TldrawUiMenuContextProvider } from '../primitives/menus/TldrawUiMenuContext'
|
|
24
25
|
|
|
25
26
|
export const IsInOverflowContext = createContext(false)
|
|
@@ -61,15 +62,12 @@ export function OverflowingToolbar({ children }: OverflowingToolbarProps) {
|
|
|
61
62
|
const activeCss = lastActiveOverflowItem ? `:not([data-value="${lastActiveOverflowItem}"])` : ''
|
|
62
63
|
|
|
63
64
|
return `
|
|
64
|
-
#${id}_main > *:nth-
|
|
65
|
+
#${id}_main > *:nth-of-type(n + ${overflowIndex + (lastActiveOverflowItem ? 1 : 2)}):not([data-radix-popper-content-wrapper])${activeCss} {
|
|
65
66
|
display: none;
|
|
66
67
|
}
|
|
67
|
-
#${id}_more > *:nth-
|
|
68
|
+
#${id}_more > *:nth-of-type(-n + ${overflowIndex}):not([data-radix-popper-content-wrapper]) {
|
|
68
69
|
display: none;
|
|
69
70
|
}
|
|
70
|
-
#${id}_more > *:nth-child(-n + ${overflowIndex + 4}) {
|
|
71
|
-
margin-top: 0;
|
|
72
|
-
}
|
|
73
71
|
`
|
|
74
72
|
}, [lastActiveOverflowItem, id, overflowIndex])
|
|
75
73
|
|
|
@@ -158,16 +156,17 @@ export function OverflowingToolbar({ children }: OverflowingToolbarProps) {
|
|
|
158
156
|
<>
|
|
159
157
|
<style nonce={editor.options.nonce}>{css}</style>
|
|
160
158
|
<TldrawUiToolbar
|
|
161
|
-
|
|
162
|
-
|
|
159
|
+
orientation="horizontal"
|
|
160
|
+
className={classNames('tlui-main-toolbar__tools', {
|
|
161
|
+
'tlui-main-toolbar__tools__mobile': breakpoint < PORTRAIT_BREAKPOINT.TABLET_SM,
|
|
163
162
|
})}
|
|
164
163
|
label={msg('tool-panel.title')}
|
|
165
164
|
>
|
|
166
|
-
<
|
|
165
|
+
<TldrawUiRow id={`${id}_main`} ref={mainToolsRef}>
|
|
167
166
|
<TldrawUiMenuContextProvider type="toolbar" sourceId="toolbar">
|
|
168
167
|
{children}
|
|
169
168
|
</TldrawUiMenuContextProvider>
|
|
170
|
-
</
|
|
169
|
+
</TldrawUiRow>
|
|
171
170
|
{/* There is a +1 because if the menu is just one item, it's not necessary. */}
|
|
172
171
|
{totalItems > overflowIndex + 1 && (
|
|
173
172
|
<IsInOverflowContext.Provider value={true}>
|
|
@@ -176,7 +175,7 @@ export function OverflowingToolbar({ children }: OverflowingToolbarProps) {
|
|
|
176
175
|
<TldrawUiToolbarButton
|
|
177
176
|
title={msg('tool-panel.more')}
|
|
178
177
|
type="tool"
|
|
179
|
-
className="tlui-toolbar__overflow"
|
|
178
|
+
className="tlui-main-toolbar__overflow"
|
|
180
179
|
data-testid="tools.more-button"
|
|
181
180
|
>
|
|
182
181
|
<TldrawUiButtonIcon icon="chevron-up" />
|
|
@@ -184,7 +183,7 @@ export function OverflowingToolbar({ children }: OverflowingToolbarProps) {
|
|
|
184
183
|
</TldrawUiPopoverTrigger>
|
|
185
184
|
<TldrawUiPopoverContent side="top" align="center">
|
|
186
185
|
<TldrawUiToolbar
|
|
187
|
-
|
|
186
|
+
orientation="grid"
|
|
188
187
|
data-testid="tools.more-content"
|
|
189
188
|
label={msg('tool-panel.more')}
|
|
190
189
|
id={`${id}_more`}
|
|
@@ -5,6 +5,7 @@ import { useBreakpoint } from '../../context/breakpoints'
|
|
|
5
5
|
import { useTranslation } from '../../hooks/useTranslation/useTranslation'
|
|
6
6
|
import { TldrawUiButton } from '../primitives/Button/TldrawUiButton'
|
|
7
7
|
import { TldrawUiButtonIcon } from '../primitives/Button/TldrawUiButtonIcon'
|
|
8
|
+
import { TldrawUiTooltip } from '../primitives/TldrawUiTooltip'
|
|
8
9
|
|
|
9
10
|
/** @public */
|
|
10
11
|
export interface ToggleToolLockedButtonProps {
|
|
@@ -25,16 +26,18 @@ export function ToggleToolLockedButton({ activeToolId }: ToggleToolLockedButtonP
|
|
|
25
26
|
if (!activeToolId || !tool.isLockable) return null
|
|
26
27
|
|
|
27
28
|
return (
|
|
28
|
-
<
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
'tlui-toolbar__lock-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
29
|
+
<TldrawUiTooltip content={msg('action.toggle-tool-lock')}>
|
|
30
|
+
<TldrawUiButton
|
|
31
|
+
type="normal"
|
|
32
|
+
title={msg('action.toggle-tool-lock')}
|
|
33
|
+
data-testid="tool-lock"
|
|
34
|
+
className={classNames('tlui-main-toolbar__lock-button', {
|
|
35
|
+
'tlui-main-toolbar__lock-button__mobile': breakpoint < PORTRAIT_BREAKPOINT.TABLET_SM,
|
|
36
|
+
})}
|
|
37
|
+
onClick={() => editor.updateInstanceState({ isToolLocked: !isToolLocked })}
|
|
38
|
+
>
|
|
39
|
+
<TldrawUiButtonIcon icon={isToolLocked ? 'lock' : 'unlock'} small />
|
|
40
|
+
</TldrawUiButton>
|
|
41
|
+
</TldrawUiTooltip>
|
|
39
42
|
)
|
|
40
43
|
}
|
|
@@ -651,6 +651,14 @@ export function ToggleKeyboardShortcutsItem() {
|
|
|
651
651
|
)
|
|
652
652
|
}
|
|
653
653
|
|
|
654
|
+
/** @public @react */
|
|
655
|
+
export function ToggleUiLabelsItem() {
|
|
656
|
+
const editor = useEditor()
|
|
657
|
+
const showUiLabels = useValue('showUiLabels', () => editor.user.getShowUiLabels(), [editor])
|
|
658
|
+
|
|
659
|
+
return <TldrawUiMenuActionCheckboxItem actionId="toggle-ui-labels" checked={showUiLabels} />
|
|
660
|
+
}
|
|
661
|
+
|
|
654
662
|
/** @public @react */
|
|
655
663
|
export function ToggleDebugModeItem() {
|
|
656
664
|
const editor = useEditor()
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
DefaultColorStyle,
|
|
3
|
+
getColorValue,
|
|
3
4
|
SharedStyle,
|
|
4
5
|
StyleProp,
|
|
5
6
|
TLDefaultColorStyle,
|
|
6
7
|
TLDefaultColorTheme,
|
|
7
8
|
useEditor,
|
|
8
9
|
} from '@tldraw/editor'
|
|
9
|
-
import
|
|
10
|
-
import { ReactElement, memo, useMemo, useRef } from 'react'
|
|
10
|
+
import { memo, ReactElement, useMemo, useRef } from 'react'
|
|
11
11
|
import { StyleValuesForUi } from '../../../styles'
|
|
12
12
|
import { PORTRAIT_BREAKPOINT } from '../../constants'
|
|
13
13
|
import { useBreakpoint } from '../../context/breakpoints'
|
|
@@ -15,6 +15,7 @@ import { TLUiTranslationKey } from '../../hooks/useTranslation/TLUiTranslationKe
|
|
|
15
15
|
import { useTranslation } from '../../hooks/useTranslation/useTranslation'
|
|
16
16
|
import { TldrawUiButtonIcon } from './Button/TldrawUiButtonIcon'
|
|
17
17
|
import { TldrawUiToolbarToggleGroup, TldrawUiToolbarToggleItem } from './TldrawUiToolbar'
|
|
18
|
+
import { TldrawUiGrid, TldrawUiRow } from './layout'
|
|
18
19
|
|
|
19
20
|
/** @public */
|
|
20
21
|
export interface TLUiButtonPickerProps<T extends string> {
|
|
@@ -116,41 +117,43 @@ export const TldrawUiButtonPicker = memo(function TldrawUiButtonPicker<T extends
|
|
|
116
117
|
}
|
|
117
118
|
}, [editor, breakpoint, value, onHistoryMark, onValueChange, style])
|
|
118
119
|
|
|
120
|
+
const Wrapper = items.length > 4 ? TldrawUiGrid : TldrawUiRow
|
|
121
|
+
|
|
119
122
|
return (
|
|
120
|
-
<
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
)
|
|
153
|
-
|
|
154
|
-
</
|
|
123
|
+
<Wrapper asChild>
|
|
124
|
+
<TldrawUiToolbarToggleGroup
|
|
125
|
+
data-testid={`style.${uiType}`}
|
|
126
|
+
type="single"
|
|
127
|
+
value={value.type === 'shared' ? value.value : undefined}
|
|
128
|
+
>
|
|
129
|
+
{items.map((item) => {
|
|
130
|
+
const label = title + ' — ' + msg(`${uiType}-style.${item.value}` as TLUiTranslationKey)
|
|
131
|
+
return (
|
|
132
|
+
<TldrawUiToolbarToggleItem
|
|
133
|
+
type="icon"
|
|
134
|
+
key={item.value}
|
|
135
|
+
data-id={item.value}
|
|
136
|
+
data-testid={`style.${uiType}.${item.value}`}
|
|
137
|
+
aria-label={label}
|
|
138
|
+
value={item.value}
|
|
139
|
+
data-state={value.type === 'shared' && value.value === item.value ? 'on' : 'off'}
|
|
140
|
+
data-isactive={value.type === 'shared' && value.value === item.value}
|
|
141
|
+
title={label}
|
|
142
|
+
style={
|
|
143
|
+
style === (DefaultColorStyle as StyleProp<unknown>)
|
|
144
|
+
? { color: getColorValue(theme, item.value as TLDefaultColorStyle, 'solid') }
|
|
145
|
+
: undefined
|
|
146
|
+
}
|
|
147
|
+
onPointerEnter={handleButtonPointerEnter}
|
|
148
|
+
onPointerDown={handleButtonPointerDown}
|
|
149
|
+
onPointerUp={handleButtonPointerUp}
|
|
150
|
+
onClick={handleButtonClick}
|
|
151
|
+
>
|
|
152
|
+
<TldrawUiButtonIcon icon={item.icon} />
|
|
153
|
+
</TldrawUiToolbarToggleItem>
|
|
154
|
+
)
|
|
155
|
+
})}
|
|
156
|
+
</TldrawUiToolbarToggleGroup>
|
|
157
|
+
</Wrapper>
|
|
155
158
|
)
|
|
156
159
|
}) as <T extends string>(props: TLUiButtonPickerProps<T>) => ReactElement
|
|
@@ -172,7 +172,7 @@ export const TldrawUiContextualToolbar = ({
|
|
|
172
172
|
className={classNames('tlui-contextual-toolbar', className)}
|
|
173
173
|
onPointerDown={stopEventPropagation}
|
|
174
174
|
>
|
|
175
|
-
<TldrawUiToolbar className="tlui-menu
|
|
175
|
+
<TldrawUiToolbar orientation="horizontal" className="tlui-menu" label={label}>
|
|
176
176
|
{children}
|
|
177
177
|
</TldrawUiToolbar>
|
|
178
178
|
</div>
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useContainer } from '@tldraw/editor'
|
|
2
|
+
import classNames from 'classnames'
|
|
2
3
|
import { Popover as _Popover } from 'radix-ui'
|
|
3
4
|
import React from 'react'
|
|
4
5
|
import { useMenuIsOpen } from '../../hooks/useMenuIsOpen'
|
|
@@ -9,15 +10,16 @@ export interface TLUiPopoverProps {
|
|
|
9
10
|
open?: boolean
|
|
10
11
|
children: React.ReactNode
|
|
11
12
|
onOpenChange?(isOpen: boolean): void
|
|
13
|
+
className?: string
|
|
12
14
|
}
|
|
13
15
|
|
|
14
16
|
/** @public @react */
|
|
15
|
-
export function TldrawUiPopover({ id, children, onOpenChange, open }: TLUiPopoverProps) {
|
|
17
|
+
export function TldrawUiPopover({ id, children, onOpenChange, open, className }: TLUiPopoverProps) {
|
|
16
18
|
const [isOpen, handleOpenChange] = useMenuIsOpen(id, onOpenChange)
|
|
17
19
|
|
|
18
20
|
return (
|
|
19
21
|
<_Popover.Root onOpenChange={handleOpenChange} open={open || isOpen /* allow debugging */}>
|
|
20
|
-
<div className=
|
|
22
|
+
<div className={classNames('tlui-popover', className)}>{children}</div>
|
|
21
23
|
</_Popover.Root>
|
|
22
24
|
)
|
|
23
25
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import classnames from 'classnames'
|
|
2
2
|
import { Toolbar as _Toolbar } from 'radix-ui'
|
|
3
3
|
import React from 'react'
|
|
4
|
+
import { TldrawUiGrid, TldrawUiRow } from './layout'
|
|
5
|
+
import { TldrawUiTooltip } from './TldrawUiTooltip'
|
|
4
6
|
|
|
5
7
|
/** @public */
|
|
6
8
|
export interface TLUiToolbarProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
@@ -8,20 +10,25 @@ export interface TLUiToolbarProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
8
10
|
className?: string
|
|
9
11
|
dir?: 'ltr' | 'rtl'
|
|
10
12
|
label: string
|
|
13
|
+
orientation?: 'horizontal' | 'grid'
|
|
11
14
|
}
|
|
12
15
|
|
|
13
16
|
/** @public @react */
|
|
14
17
|
export const TldrawUiToolbar = React.forwardRef<HTMLDivElement, TLUiToolbarProps>(
|
|
15
|
-
({ children, className, label, ...props }: TLUiToolbarProps, ref) => {
|
|
18
|
+
({ children, className, label, orientation = 'horizontal', ...props }: TLUiToolbarProps, ref) => {
|
|
19
|
+
const Layout = orientation === 'grid' ? TldrawUiGrid : TldrawUiRow
|
|
16
20
|
return (
|
|
17
|
-
<
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
<Layout asChild>
|
|
22
|
+
<_Toolbar.Root
|
|
23
|
+
ref={ref}
|
|
24
|
+
{...props}
|
|
25
|
+
className={classnames('tlui-toolbar', className)}
|
|
26
|
+
aria-label={label}
|
|
27
|
+
orientation={orientation === 'grid' ? 'horizontal' : orientation}
|
|
28
|
+
>
|
|
29
|
+
{children}
|
|
30
|
+
</_Toolbar.Root>
|
|
31
|
+
</Layout>
|
|
25
32
|
)
|
|
26
33
|
}
|
|
27
34
|
)
|
|
@@ -34,23 +41,30 @@ export interface TLUiToolbarButtonProps extends React.HTMLAttributes<HTMLButtonE
|
|
|
34
41
|
disabled?: boolean
|
|
35
42
|
isActive?: boolean
|
|
36
43
|
type: 'icon' | 'tool' | 'menu'
|
|
44
|
+
tooltip?: string
|
|
37
45
|
}
|
|
38
46
|
|
|
39
47
|
/** @public @react */
|
|
40
48
|
export const TldrawUiToolbarButton = React.forwardRef<HTMLButtonElement, TLUiToolbarButtonProps>(
|
|
41
|
-
({ asChild, children, type, isActive, ...props }: TLUiToolbarButtonProps, ref) => {
|
|
42
|
-
|
|
49
|
+
({ asChild, children, type, isActive, tooltip, ...props }: TLUiToolbarButtonProps, ref) => {
|
|
50
|
+
const button = (
|
|
43
51
|
<_Toolbar.Button
|
|
44
52
|
ref={ref}
|
|
45
53
|
asChild={asChild}
|
|
46
54
|
draggable={false}
|
|
47
55
|
data-isactive={isActive}
|
|
48
56
|
{...props}
|
|
57
|
+
// The tooltip takes care of this.
|
|
58
|
+
title={undefined}
|
|
49
59
|
className={classnames('tlui-button', `tlui-button__${type}`, props.className)}
|
|
50
60
|
>
|
|
51
61
|
{children}
|
|
52
62
|
</_Toolbar.Button>
|
|
53
63
|
)
|
|
64
|
+
|
|
65
|
+
const tooltipContent = tooltip || props.title
|
|
66
|
+
|
|
67
|
+
return <TldrawUiTooltip content={tooltipContent}>{button}</TldrawUiTooltip>
|
|
54
68
|
}
|
|
55
69
|
)
|
|
56
70
|
|
|
@@ -93,6 +107,7 @@ export interface TLUiToolbarToggleItemProps extends React.HTMLAttributes<HTMLBut
|
|
|
93
107
|
className?: string
|
|
94
108
|
type: 'icon' | 'tool'
|
|
95
109
|
value: string
|
|
110
|
+
tooltip?: string
|
|
96
111
|
}
|
|
97
112
|
|
|
98
113
|
/** @public @react */
|
|
@@ -101,11 +116,14 @@ export const TldrawUiToolbarToggleItem = ({
|
|
|
101
116
|
className,
|
|
102
117
|
type,
|
|
103
118
|
value,
|
|
119
|
+
tooltip,
|
|
104
120
|
...props
|
|
105
121
|
}: TLUiToolbarToggleItemProps) => {
|
|
106
|
-
|
|
122
|
+
const toggleItem = (
|
|
107
123
|
<_Toolbar.ToggleItem
|
|
108
124
|
{...props}
|
|
125
|
+
// The tooltip takes care of this.
|
|
126
|
+
title={undefined}
|
|
109
127
|
className={classnames(
|
|
110
128
|
'tlui-button',
|
|
111
129
|
`tlui-button__${type}`,
|
|
@@ -117,4 +135,8 @@ export const TldrawUiToolbarToggleItem = ({
|
|
|
117
135
|
{children}
|
|
118
136
|
</_Toolbar.ToggleItem>
|
|
119
137
|
)
|
|
138
|
+
|
|
139
|
+
const tooltipContent = tooltip || props.title
|
|
140
|
+
|
|
141
|
+
return <TldrawUiTooltip content={tooltipContent}>{toggleItem}</TldrawUiTooltip>
|
|
120
142
|
}
|