tldraw 3.16.0-canary.da3348c13973 → 3.16.0-canary.da857364642e

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 (168) hide show
  1. package/dist-cjs/index.d.ts +43 -4
  2. package/dist-cjs/index.js +4 -1
  3. package/dist-cjs/index.js.map +2 -2
  4. package/dist-cjs/lib/canvas/TldrawScribble.js +1 -1
  5. package/dist-cjs/lib/canvas/TldrawScribble.js.map +2 -2
  6. package/dist-cjs/lib/shapes/arrow/ArrowShapeUtil.js +3 -3
  7. package/dist-cjs/lib/shapes/arrow/ArrowShapeUtil.js.map +2 -2
  8. package/dist-cjs/lib/shapes/arrow/elbow/ElbowArrowDebug.js +3 -3
  9. package/dist-cjs/lib/shapes/arrow/elbow/ElbowArrowDebug.js.map +1 -1
  10. package/dist-cjs/lib/shapes/draw/DrawShapeUtil.js +3 -3
  11. package/dist-cjs/lib/shapes/draw/DrawShapeUtil.js.map +2 -2
  12. package/dist-cjs/lib/shapes/embed/EmbedShapeUtil.js +1 -1
  13. package/dist-cjs/lib/shapes/embed/EmbedShapeUtil.js.map +1 -1
  14. package/dist-cjs/lib/shapes/frame/FrameShapeUtil.js +12 -12
  15. package/dist-cjs/lib/shapes/frame/FrameShapeUtil.js.map +2 -2
  16. package/dist-cjs/lib/shapes/frame/components/FrameHeading.js +1 -1
  17. package/dist-cjs/lib/shapes/frame/components/FrameHeading.js.map +2 -2
  18. package/dist-cjs/lib/shapes/geo/GeoShapeUtil.js +2 -2
  19. package/dist-cjs/lib/shapes/geo/GeoShapeUtil.js.map +2 -2
  20. package/dist-cjs/lib/shapes/geo/components/GeoShapeBody.js +2 -1
  21. package/dist-cjs/lib/shapes/geo/components/GeoShapeBody.js.map +2 -2
  22. package/dist-cjs/lib/shapes/highlight/HighlightShapeUtil.js +5 -1
  23. package/dist-cjs/lib/shapes/highlight/HighlightShapeUtil.js.map +2 -2
  24. package/dist-cjs/lib/shapes/image/ImageShapeUtil.js +3 -3
  25. package/dist-cjs/lib/shapes/image/ImageShapeUtil.js.map +1 -1
  26. package/dist-cjs/lib/shapes/line/LineShapeUtil.js +5 -1
  27. package/dist-cjs/lib/shapes/line/LineShapeUtil.js.map +2 -2
  28. package/dist-cjs/lib/shapes/note/NoteShapeUtil.js +4 -4
  29. package/dist-cjs/lib/shapes/note/NoteShapeUtil.js.map +2 -2
  30. package/dist-cjs/lib/shapes/shared/ShapeFill.js +5 -5
  31. package/dist-cjs/lib/shapes/shared/ShapeFill.js.map +2 -2
  32. package/dist-cjs/lib/shapes/text/TextShapeUtil.js +2 -2
  33. package/dist-cjs/lib/shapes/text/TextShapeUtil.js.map +2 -2
  34. package/dist-cjs/lib/shapes/video/VideoShapeUtil.js +3 -3
  35. package/dist-cjs/lib/shapes/video/VideoShapeUtil.js.map +1 -1
  36. package/dist-cjs/lib/ui/TldrawUi.js +14 -0
  37. package/dist-cjs/lib/ui/TldrawUi.js.map +3 -3
  38. package/dist-cjs/lib/ui/components/ActionsMenu/DefaultActionsMenu.js +10 -2
  39. package/dist-cjs/lib/ui/components/ActionsMenu/DefaultActionsMenu.js.map +2 -2
  40. package/dist-cjs/lib/ui/components/Minimap/MinimapManager.js +4 -4
  41. package/dist-cjs/lib/ui/components/Minimap/MinimapManager.js.map +2 -2
  42. package/dist-cjs/lib/ui/components/MobileStylePanel.js +5 -3
  43. package/dist-cjs/lib/ui/components/MobileStylePanel.js.map +2 -2
  44. package/dist-cjs/lib/ui/components/Toolbar/DefaultImageToolbarContent.js +1 -1
  45. package/dist-cjs/lib/ui/components/Toolbar/DefaultImageToolbarContent.js.map +2 -2
  46. package/dist-cjs/lib/ui/components/Toolbar/DefaultToolbar.js +66 -22
  47. package/dist-cjs/lib/ui/components/Toolbar/DefaultToolbar.js.map +3 -3
  48. package/dist-cjs/lib/ui/components/Toolbar/OverflowingToolbar.js +188 -78
  49. package/dist-cjs/lib/ui/components/Toolbar/OverflowingToolbar.js.map +3 -3
  50. package/dist-cjs/lib/ui/components/primitives/TldrawUiButtonPicker.js +1 -1
  51. package/dist-cjs/lib/ui/components/primitives/TldrawUiButtonPicker.js.map +2 -2
  52. package/dist-cjs/lib/ui/components/primitives/TldrawUiToolbar.js +15 -3
  53. package/dist-cjs/lib/ui/components/primitives/TldrawUiToolbar.js.map +2 -2
  54. package/dist-cjs/lib/ui/components/primitives/TldrawUiTooltip.js +127 -158
  55. package/dist-cjs/lib/ui/components/primitives/TldrawUiTooltip.js.map +2 -2
  56. package/dist-cjs/lib/ui/components/primitives/layout.js +30 -5
  57. package/dist-cjs/lib/ui/components/primitives/layout.js.map +2 -2
  58. package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuContext.js.map +2 -2
  59. package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuGroup.js +25 -12
  60. package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuGroup.js.map +2 -2
  61. package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuItem.js +1 -18
  62. package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuItem.js.map +2 -2
  63. package/dist-cjs/lib/ui/hooks/useTools.js +21 -3
  64. package/dist-cjs/lib/ui/hooks/useTools.js.map +2 -2
  65. package/dist-cjs/lib/ui/version.js +3 -3
  66. package/dist-cjs/lib/ui/version.js.map +1 -1
  67. package/dist-esm/index.d.mts +43 -4
  68. package/dist-esm/index.mjs +8 -2
  69. package/dist-esm/index.mjs.map +2 -2
  70. package/dist-esm/lib/canvas/TldrawScribble.mjs +1 -1
  71. package/dist-esm/lib/canvas/TldrawScribble.mjs.map +2 -2
  72. package/dist-esm/lib/shapes/arrow/ArrowShapeUtil.mjs +4 -3
  73. package/dist-esm/lib/shapes/arrow/ArrowShapeUtil.mjs.map +2 -2
  74. package/dist-esm/lib/shapes/arrow/elbow/ElbowArrowDebug.mjs +3 -3
  75. package/dist-esm/lib/shapes/arrow/elbow/ElbowArrowDebug.mjs.map +1 -1
  76. package/dist-esm/lib/shapes/draw/DrawShapeUtil.mjs +4 -3
  77. package/dist-esm/lib/shapes/draw/DrawShapeUtil.mjs.map +2 -2
  78. package/dist-esm/lib/shapes/embed/EmbedShapeUtil.mjs +1 -1
  79. package/dist-esm/lib/shapes/embed/EmbedShapeUtil.mjs.map +1 -1
  80. package/dist-esm/lib/shapes/frame/FrameShapeUtil.mjs +13 -12
  81. package/dist-esm/lib/shapes/frame/FrameShapeUtil.mjs.map +2 -2
  82. package/dist-esm/lib/shapes/frame/components/FrameHeading.mjs +1 -1
  83. package/dist-esm/lib/shapes/frame/components/FrameHeading.mjs.map +2 -2
  84. package/dist-esm/lib/shapes/geo/GeoShapeUtil.mjs +3 -2
  85. package/dist-esm/lib/shapes/geo/GeoShapeUtil.mjs.map +2 -2
  86. package/dist-esm/lib/shapes/geo/components/GeoShapeBody.mjs +2 -1
  87. package/dist-esm/lib/shapes/geo/components/GeoShapeBody.mjs.map +2 -2
  88. package/dist-esm/lib/shapes/highlight/HighlightShapeUtil.mjs +6 -1
  89. package/dist-esm/lib/shapes/highlight/HighlightShapeUtil.mjs.map +2 -2
  90. package/dist-esm/lib/shapes/image/ImageShapeUtil.mjs +3 -3
  91. package/dist-esm/lib/shapes/image/ImageShapeUtil.mjs.map +1 -1
  92. package/dist-esm/lib/shapes/line/LineShapeUtil.mjs +6 -1
  93. package/dist-esm/lib/shapes/line/LineShapeUtil.mjs.map +2 -2
  94. package/dist-esm/lib/shapes/note/NoteShapeUtil.mjs +5 -4
  95. package/dist-esm/lib/shapes/note/NoteShapeUtil.mjs.map +2 -2
  96. package/dist-esm/lib/shapes/shared/ShapeFill.mjs +6 -5
  97. package/dist-esm/lib/shapes/shared/ShapeFill.mjs.map +2 -2
  98. package/dist-esm/lib/shapes/text/TextShapeUtil.mjs +3 -2
  99. package/dist-esm/lib/shapes/text/TextShapeUtil.mjs.map +2 -2
  100. package/dist-esm/lib/shapes/video/VideoShapeUtil.mjs +3 -3
  101. package/dist-esm/lib/shapes/video/VideoShapeUtil.mjs.map +1 -1
  102. package/dist-esm/lib/ui/TldrawUi.mjs +16 -2
  103. package/dist-esm/lib/ui/TldrawUi.mjs.map +3 -3
  104. package/dist-esm/lib/ui/components/ActionsMenu/DefaultActionsMenu.mjs +10 -2
  105. package/dist-esm/lib/ui/components/ActionsMenu/DefaultActionsMenu.mjs.map +2 -2
  106. package/dist-esm/lib/ui/components/Minimap/MinimapManager.mjs +4 -4
  107. package/dist-esm/lib/ui/components/Minimap/MinimapManager.mjs.map +2 -2
  108. package/dist-esm/lib/ui/components/MobileStylePanel.mjs +6 -3
  109. package/dist-esm/lib/ui/components/MobileStylePanel.mjs.map +2 -2
  110. package/dist-esm/lib/ui/components/Toolbar/DefaultImageToolbarContent.mjs +1 -1
  111. package/dist-esm/lib/ui/components/Toolbar/DefaultImageToolbarContent.mjs.map +2 -2
  112. package/dist-esm/lib/ui/components/Toolbar/DefaultToolbar.mjs +56 -22
  113. package/dist-esm/lib/ui/components/Toolbar/DefaultToolbar.mjs.map +2 -2
  114. package/dist-esm/lib/ui/components/Toolbar/OverflowingToolbar.mjs +192 -80
  115. package/dist-esm/lib/ui/components/Toolbar/OverflowingToolbar.mjs.map +3 -3
  116. package/dist-esm/lib/ui/components/primitives/TldrawUiButtonPicker.mjs +2 -1
  117. package/dist-esm/lib/ui/components/primitives/TldrawUiButtonPicker.mjs.map +2 -2
  118. package/dist-esm/lib/ui/components/primitives/TldrawUiToolbar.mjs +16 -4
  119. package/dist-esm/lib/ui/components/primitives/TldrawUiToolbar.mjs.map +2 -2
  120. package/dist-esm/lib/ui/components/primitives/TldrawUiTooltip.mjs +136 -160
  121. package/dist-esm/lib/ui/components/primitives/TldrawUiTooltip.mjs.map +2 -2
  122. package/dist-esm/lib/ui/components/primitives/layout.mjs +31 -6
  123. package/dist-esm/lib/ui/components/primitives/layout.mjs.map +2 -2
  124. package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuContext.mjs.map +2 -2
  125. package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuGroup.mjs +25 -12
  126. package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuGroup.mjs.map +2 -2
  127. package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuItem.mjs +1 -18
  128. package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuItem.mjs.map +2 -2
  129. package/dist-esm/lib/ui/hooks/useTools.mjs +22 -3
  130. package/dist-esm/lib/ui/hooks/useTools.mjs.map +2 -2
  131. package/dist-esm/lib/ui/version.mjs +3 -3
  132. package/dist-esm/lib/ui/version.mjs.map +1 -1
  133. package/package.json +3 -3
  134. package/src/index.ts +5 -0
  135. package/src/lib/canvas/TldrawScribble.tsx +1 -1
  136. package/src/lib/shapes/arrow/ArrowShapeUtil.tsx +4 -3
  137. package/src/lib/shapes/arrow/elbow/ElbowArrowDebug.tsx +3 -3
  138. package/src/lib/shapes/draw/DrawShapeUtil.tsx +4 -3
  139. package/src/lib/shapes/embed/EmbedShapeUtil.tsx +1 -1
  140. package/src/lib/shapes/frame/FrameShapeUtil.tsx +21 -14
  141. package/src/lib/shapes/frame/components/FrameHeading.tsx +1 -1
  142. package/src/lib/shapes/geo/GeoShapeUtil.tsx +3 -2
  143. package/src/lib/shapes/geo/components/GeoShapeBody.tsx +2 -2
  144. package/src/lib/shapes/highlight/HighlightShapeUtil.tsx +7 -1
  145. package/src/lib/shapes/image/ImageShapeUtil.tsx +3 -3
  146. package/src/lib/shapes/line/LineShapeUtil.tsx +6 -1
  147. package/src/lib/shapes/note/NoteShapeUtil.tsx +9 -4
  148. package/src/lib/shapes/shared/ShapeFill.tsx +6 -5
  149. package/src/lib/shapes/text/TextShapeUtil.tsx +3 -2
  150. package/src/lib/shapes/video/VideoShapeUtil.tsx +3 -3
  151. package/src/lib/ui/TldrawUi.tsx +17 -2
  152. package/src/lib/ui/components/ActionsMenu/DefaultActionsMenu.tsx +13 -2
  153. package/src/lib/ui/components/Minimap/MinimapManager.ts +4 -4
  154. package/src/lib/ui/components/MobileStylePanel.tsx +9 -6
  155. package/src/lib/ui/components/Toolbar/DefaultImageToolbarContent.tsx +1 -1
  156. package/src/lib/ui/components/Toolbar/DefaultToolbar.tsx +55 -24
  157. package/src/lib/ui/components/Toolbar/OverflowingToolbar.tsx +208 -56
  158. package/src/lib/ui/components/primitives/TldrawUiButtonPicker.tsx +3 -2
  159. package/src/lib/ui/components/primitives/TldrawUiToolbar.tsx +22 -5
  160. package/src/lib/ui/components/primitives/TldrawUiTooltip.tsx +145 -176
  161. package/src/lib/ui/components/primitives/layout.tsx +79 -5
  162. package/src/lib/ui/components/primitives/menus/TldrawUiMenuContext.tsx +0 -1
  163. package/src/lib/ui/components/primitives/menus/TldrawUiMenuGroup.tsx +29 -16
  164. package/src/lib/ui/components/primitives/menus/TldrawUiMenuItem.tsx +2 -16
  165. package/src/lib/ui/hooks/useTools.tsx +25 -3
  166. package/src/lib/ui/version.ts +3 -3
  167. package/src/lib/ui.css +346 -243
  168. package/tldraw.css +639 -533
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
5
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
8
  var __export = (target, all) => {
7
9
  for (var name in all)
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
15
17
  }
16
18
  return to;
17
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
+ ));
18
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
29
  var DefaultToolbar_exports = {};
20
30
  __export(DefaultToolbar_exports, {
@@ -23,6 +33,7 @@ __export(DefaultToolbar_exports, {
23
33
  module.exports = __toCommonJS(DefaultToolbar_exports);
24
34
  var import_jsx_runtime = require("react/jsx-runtime");
25
35
  var import_editor = require("@tldraw/editor");
36
+ var import_classnames = __toESM(require("classnames"));
26
37
  var import_react = require("react");
27
38
  var import_constants = require("../../constants");
28
39
  var import_breakpoints = require("../../context/breakpoints");
@@ -30,11 +41,19 @@ var import_components = require("../../context/components");
30
41
  var import_useReadonly = require("../../hooks/useReadonly");
31
42
  var import_useTranslation = require("../../hooks/useTranslation/useTranslation");
32
43
  var import_MobileStylePanel = require("../MobileStylePanel");
44
+ var import_layout = require("../primitives/layout");
33
45
  var import_TldrawUiToolbar = require("../primitives/TldrawUiToolbar");
34
46
  var import_DefaultToolbarContent = require("./DefaultToolbarContent");
35
47
  var import_OverflowingToolbar = require("./OverflowingToolbar");
36
48
  var import_ToggleToolLockedButton = require("./ToggleToolLockedButton");
37
- const DefaultToolbar = (0, import_react.memo)(function DefaultToolbar2({ children }) {
49
+ const DefaultToolbar = (0, import_react.memo)(function DefaultToolbar2({
50
+ children,
51
+ orientation = "horizontal",
52
+ minItems = 4,
53
+ minSizePx = 310,
54
+ maxItems = 8,
55
+ maxSizePx = 470
56
+ }) {
38
57
  const editor = (0, import_editor.useEditor)();
39
58
  const msg = (0, import_useTranslation.useTranslation)();
40
59
  const breakpoint = (0, import_breakpoints.useBreakpoint)();
@@ -44,26 +63,51 @@ const DefaultToolbar = (0, import_react.memo)(function DefaultToolbar2({ childre
44
63
  (0, import_editor.usePassThroughWheelEvents)(ref);
45
64
  const { ActionsMenu, QuickActions } = (0, import_components.useTldrawUiComponents)();
46
65
  const showQuickActions = editor.options.actionShortcutsLocation === "menu" ? false : editor.options.actionShortcutsLocation === "toolbar" ? true : breakpoint < import_constants.PORTRAIT_BREAKPOINT.TABLET;
47
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { ref, className: "tlui-main-toolbar", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "tlui-main-toolbar__inner", children: [
48
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "tlui-main-toolbar__left", children: [
49
- !isReadonlyMode && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "tlui-main-toolbar__extras", children: [
50
- showQuickActions && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
51
- import_TldrawUiToolbar.TldrawUiToolbar,
52
- {
53
- orientation: "horizontal",
54
- className: "tlui-main-toolbar__extras__controls",
55
- label: msg("actions-menu.title"),
56
- children: [
57
- QuickActions && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(QuickActions, {}),
58
- ActionsMenu && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ActionsMenu, {})
59
- ]
60
- }
61
- ),
62
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ToggleToolLockedButton.ToggleToolLockedButton, { activeToolId })
63
- ] }),
64
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_OverflowingToolbar.OverflowingToolbar, { children: children ?? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_DefaultToolbarContent.DefaultToolbarContent, {}) })
65
- ] }),
66
- breakpoint < import_constants.PORTRAIT_BREAKPOINT.TABLET_SM && !isReadonlyMode && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "tlui-main-toolbar__tools", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_MobileStylePanel.MobileStylePanel, {}) })
67
- ] }) });
66
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
67
+ import_layout.TldrawUiOrientationProvider,
68
+ {
69
+ orientation,
70
+ tooltipSide: orientation === "horizontal" ? "top" : "right",
71
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
72
+ "div",
73
+ {
74
+ ref,
75
+ className: (0, import_classnames.default)("tlui-main-toolbar", `tlui-main-toolbar--${orientation}`),
76
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "tlui-main-toolbar__inner", children: [
77
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "tlui-main-toolbar__left", children: [
78
+ !isReadonlyMode && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "tlui-main-toolbar__extras", children: [
79
+ showQuickActions && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
80
+ import_TldrawUiToolbar.TldrawUiToolbar,
81
+ {
82
+ orientation,
83
+ className: "tlui-main-toolbar__extras__controls",
84
+ label: msg("actions-menu.title"),
85
+ children: [
86
+ QuickActions && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(QuickActions, {}),
87
+ ActionsMenu && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ActionsMenu, {})
88
+ ]
89
+ }
90
+ ),
91
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ToggleToolLockedButton.ToggleToolLockedButton, { activeToolId })
92
+ ] }),
93
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
94
+ import_OverflowingToolbar.OverflowingToolbar,
95
+ {
96
+ orientation,
97
+ sizingParentClassName: "tlui-main-toolbar",
98
+ minItems,
99
+ maxItems,
100
+ minSizePx,
101
+ maxSizePx,
102
+ children: children ?? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_DefaultToolbarContent.DefaultToolbarContent, {})
103
+ }
104
+ )
105
+ ] }),
106
+ breakpoint < import_constants.PORTRAIT_BREAKPOINT.TABLET_SM && !isReadonlyMode && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "tlui-main-toolbar__tools tlui-main-toolbar__mobile-style-panel", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_MobileStylePanel.MobileStylePanel, {}) })
107
+ ] })
108
+ }
109
+ )
110
+ }
111
+ );
68
112
  });
69
113
  //# sourceMappingURL=DefaultToolbar.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/lib/ui/components/Toolbar/DefaultToolbar.tsx"],
4
- "sourcesContent": ["import { useEditor, usePassThroughWheelEvents, useValue } from '@tldraw/editor'\nimport { ReactNode, memo, useRef } from 'react'\nimport { PORTRAIT_BREAKPOINT } from '../../constants'\nimport { useBreakpoint } from '../../context/breakpoints'\nimport { useTldrawUiComponents } from '../../context/components'\nimport { useReadonly } from '../../hooks/useReadonly'\nimport { useTranslation } from '../../hooks/useTranslation/useTranslation'\nimport { MobileStylePanel } from '../MobileStylePanel'\nimport { TldrawUiToolbar } from '../primitives/TldrawUiToolbar'\nimport { DefaultToolbarContent } from './DefaultToolbarContent'\nimport { OverflowingToolbar } from './OverflowingToolbar'\nimport { ToggleToolLockedButton } from './ToggleToolLockedButton'\n\n/** @public */\nexport interface DefaultToolbarProps {\n\tchildren?: ReactNode\n}\n\n/**\n * The default toolbar for the editor. `children` defaults to the `DefaultToolbarContent` component.\n * Depending on the screen size, the children will overflow into a drop-down menu, with the most\n * recently active item from the overflow being shown in the main toolbar.\n *\n * @public\n * @react\n */\nexport const DefaultToolbar = memo(function DefaultToolbar({ children }: DefaultToolbarProps) {\n\tconst editor = useEditor()\n\tconst msg = useTranslation()\n\tconst breakpoint = useBreakpoint()\n\tconst isReadonlyMode = useReadonly()\n\tconst activeToolId = useValue('current tool id', () => editor.getCurrentToolId(), [editor])\n\n\tconst ref = useRef<HTMLDivElement>(null)\n\tusePassThroughWheelEvents(ref)\n\n\tconst { ActionsMenu, QuickActions } = useTldrawUiComponents()\n\n\tconst showQuickActions =\n\t\teditor.options.actionShortcutsLocation === 'menu'\n\t\t\t? false\n\t\t\t: editor.options.actionShortcutsLocation === 'toolbar'\n\t\t\t\t? true\n\t\t\t\t: breakpoint < PORTRAIT_BREAKPOINT.TABLET\n\n\treturn (\n\t\t<div ref={ref} className=\"tlui-main-toolbar\">\n\t\t\t<div className=\"tlui-main-toolbar__inner\">\n\t\t\t\t<div className=\"tlui-main-toolbar__left\">\n\t\t\t\t\t{!isReadonlyMode && (\n\t\t\t\t\t\t<div className=\"tlui-main-toolbar__extras\">\n\t\t\t\t\t\t\t{showQuickActions && (\n\t\t\t\t\t\t\t\t<TldrawUiToolbar\n\t\t\t\t\t\t\t\t\torientation=\"horizontal\"\n\t\t\t\t\t\t\t\t\tclassName=\"tlui-main-toolbar__extras__controls\"\n\t\t\t\t\t\t\t\t\tlabel={msg('actions-menu.title')}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{QuickActions && <QuickActions />}\n\t\t\t\t\t\t\t\t\t{ActionsMenu && <ActionsMenu />}\n\t\t\t\t\t\t\t\t</TldrawUiToolbar>\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t<ToggleToolLockedButton activeToolId={activeToolId} />\n\t\t\t\t\t\t</div>\n\t\t\t\t\t)}\n\t\t\t\t\t<OverflowingToolbar>{children ?? <DefaultToolbarContent />}</OverflowingToolbar>\n\t\t\t\t</div>\n\t\t\t\t{breakpoint < PORTRAIT_BREAKPOINT.TABLET_SM && !isReadonlyMode && (\n\t\t\t\t\t<div className=\"tlui-main-toolbar__tools\">\n\t\t\t\t\t\t<MobileStylePanel />\n\t\t\t\t\t</div>\n\t\t\t\t)}\n\t\t\t</div>\n\t\t</div>\n\t)\n})\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAoDQ;AApDR,oBAA+D;AAC/D,mBAAwC;AACxC,uBAAoC;AACpC,yBAA8B;AAC9B,wBAAsC;AACtC,yBAA4B;AAC5B,4BAA+B;AAC/B,8BAAiC;AACjC,6BAAgC;AAChC,mCAAsC;AACtC,gCAAmC;AACnC,oCAAuC;AAehC,MAAM,qBAAiB,mBAAK,SAASA,gBAAe,EAAE,SAAS,GAAwB;AAC7F,QAAM,aAAS,yBAAU;AACzB,QAAM,UAAM,sCAAe;AAC3B,QAAM,iBAAa,kCAAc;AACjC,QAAM,qBAAiB,gCAAY;AACnC,QAAM,mBAAe,wBAAS,mBAAmB,MAAM,OAAO,iBAAiB,GAAG,CAAC,MAAM,CAAC;AAE1F,QAAM,UAAM,qBAAuB,IAAI;AACvC,+CAA0B,GAAG;AAE7B,QAAM,EAAE,aAAa,aAAa,QAAI,yCAAsB;AAE5D,QAAM,mBACL,OAAO,QAAQ,4BAA4B,SACxC,QACA,OAAO,QAAQ,4BAA4B,YAC1C,OACA,aAAa,qCAAoB;AAEtC,SACC,4CAAC,SAAI,KAAU,WAAU,qBACxB,uDAAC,SAAI,WAAU,4BACd;AAAA,iDAAC,SAAI,WAAU,2BACb;AAAA,OAAC,kBACD,6CAAC,SAAI,WAAU,6BACb;AAAA,4BACA;AAAA,UAAC;AAAA;AAAA,YACA,aAAY;AAAA,YACZ,WAAU;AAAA,YACV,OAAO,IAAI,oBAAoB;AAAA,YAE9B;AAAA,8BAAgB,4CAAC,gBAAa;AAAA,cAC9B,eAAe,4CAAC,eAAY;AAAA;AAAA;AAAA,QAC9B;AAAA,QAED,4CAAC,wDAAuB,cAA4B;AAAA,SACrD;AAAA,MAED,4CAAC,gDAAoB,sBAAY,4CAAC,sDAAsB,GAAG;AAAA,OAC5D;AAAA,IACC,aAAa,qCAAoB,aAAa,CAAC,kBAC/C,4CAAC,SAAI,WAAU,4BACd,sDAAC,4CAAiB,GACnB;AAAA,KAEF,GACD;AAEF,CAAC;",
6
- "names": ["DefaultToolbar"]
4
+ "sourcesContent": ["import { useEditor, usePassThroughWheelEvents, useValue } from '@tldraw/editor'\nimport classNames from 'classnames'\nimport { ReactNode, memo, useRef } from 'react'\nimport { PORTRAIT_BREAKPOINT } from '../../constants'\nimport { useBreakpoint } from '../../context/breakpoints'\nimport { useTldrawUiComponents } from '../../context/components'\nimport { useReadonly } from '../../hooks/useReadonly'\nimport { useTranslation } from '../../hooks/useTranslation/useTranslation'\nimport { MobileStylePanel } from '../MobileStylePanel'\nimport { TldrawUiOrientationProvider } from '../primitives/layout'\nimport { TldrawUiToolbar } from '../primitives/TldrawUiToolbar'\nimport { DefaultToolbarContent } from './DefaultToolbarContent'\nimport { OverflowingToolbar } from './OverflowingToolbar'\nimport { ToggleToolLockedButton } from './ToggleToolLockedButton'\n\n/** @public */\nexport interface DefaultToolbarProps {\n\tchildren?: ReactNode\n\torientation?: 'horizontal' | 'vertical'\n\tminItems?: number\n\tminSizePx?: number\n\tmaxItems?: number\n\tmaxSizePx?: number\n}\n\n/**\n * The default toolbar for the editor. `children` defaults to the `DefaultToolbarContent` component.\n * Depending on the screen size, the children will overflow into a drop-down menu, with the most\n * recently active item from the overflow being shown in the main toolbar.\n *\n * @public\n * @react\n */\nexport const DefaultToolbar = memo(function DefaultToolbar({\n\tchildren,\n\torientation = 'horizontal',\n\tminItems = 4,\n\tminSizePx = 310,\n\tmaxItems = 8,\n\tmaxSizePx = 470,\n}: DefaultToolbarProps) {\n\tconst editor = useEditor()\n\tconst msg = useTranslation()\n\tconst breakpoint = useBreakpoint()\n\tconst isReadonlyMode = useReadonly()\n\tconst activeToolId = useValue('current tool id', () => editor.getCurrentToolId(), [editor])\n\n\tconst ref = useRef<HTMLDivElement>(null)\n\tusePassThroughWheelEvents(ref)\n\n\tconst { ActionsMenu, QuickActions } = useTldrawUiComponents()\n\n\tconst showQuickActions =\n\t\teditor.options.actionShortcutsLocation === 'menu'\n\t\t\t? false\n\t\t\t: editor.options.actionShortcutsLocation === 'toolbar'\n\t\t\t\t? true\n\t\t\t\t: breakpoint < PORTRAIT_BREAKPOINT.TABLET\n\n\treturn (\n\t\t<TldrawUiOrientationProvider\n\t\t\torientation={orientation}\n\t\t\ttooltipSide={orientation === 'horizontal' ? 'top' : 'right'}\n\t\t>\n\t\t\t<div\n\t\t\t\tref={ref}\n\t\t\t\tclassName={classNames('tlui-main-toolbar', `tlui-main-toolbar--${orientation}`)}\n\t\t\t>\n\t\t\t\t<div className=\"tlui-main-toolbar__inner\">\n\t\t\t\t\t<div className=\"tlui-main-toolbar__left\">\n\t\t\t\t\t\t{!isReadonlyMode && (\n\t\t\t\t\t\t\t<div className=\"tlui-main-toolbar__extras\">\n\t\t\t\t\t\t\t\t{showQuickActions && (\n\t\t\t\t\t\t\t\t\t<TldrawUiToolbar\n\t\t\t\t\t\t\t\t\t\torientation={orientation}\n\t\t\t\t\t\t\t\t\t\tclassName=\"tlui-main-toolbar__extras__controls\"\n\t\t\t\t\t\t\t\t\t\tlabel={msg('actions-menu.title')}\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{QuickActions && <QuickActions />}\n\t\t\t\t\t\t\t\t\t\t{ActionsMenu && <ActionsMenu />}\n\t\t\t\t\t\t\t\t\t</TldrawUiToolbar>\n\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t\t<ToggleToolLockedButton activeToolId={activeToolId} />\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t)}\n\t\t\t\t\t\t<OverflowingToolbar\n\t\t\t\t\t\t\torientation={orientation}\n\t\t\t\t\t\t\tsizingParentClassName=\"tlui-main-toolbar\"\n\t\t\t\t\t\t\tminItems={minItems}\n\t\t\t\t\t\t\tmaxItems={maxItems}\n\t\t\t\t\t\t\tminSizePx={minSizePx}\n\t\t\t\t\t\t\tmaxSizePx={maxSizePx}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{children ?? <DefaultToolbarContent />}\n\t\t\t\t\t\t</OverflowingToolbar>\n\t\t\t\t\t</div>\n\t\t\t\t\t{breakpoint < PORTRAIT_BREAKPOINT.TABLET_SM && !isReadonlyMode && (\n\t\t\t\t\t\t<div className=\"tlui-main-toolbar__tools tlui-main-toolbar__mobile-style-panel\">\n\t\t\t\t\t\t\t<MobileStylePanel />\n\t\t\t\t\t\t</div>\n\t\t\t\t\t)}\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</TldrawUiOrientationProvider>\n\t)\n})\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;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AAA,sBAC9B,eAAe,4CAAC,eAAY;AAAA;AAAA;AAAA,gBAC9B;AAAA,gBAED,4CAAC,wDAAuB,cAA4B;AAAA,iBACrD;AAAA,cAED;AAAA,gBAAC;AAAA;AAAA,kBACA;AAAA,kBACA,uBAAsB;AAAA,kBACtB;AAAA,kBACA;AAAA,kBACA;AAAA,kBACA;AAAA,kBAEC,sBAAY,4CAAC,sDAAsB;AAAA;AAAA,cACrC;AAAA,eACD;AAAA,YACC,aAAa,qCAAoB,aAAa,CAAC,kBAC/C,4CAAC,SAAI,WAAU,kEACd,sDAAC,4CAAiB,GACnB;AAAA,aAEF;AAAA;AAAA,MACD;AAAA;AAAA,EACD;AAEF,CAAC;",
6
+ "names": ["DefaultToolbar", "classNames"]
7
7
  }
@@ -59,52 +59,130 @@ const NUMBERED_SHORTCUT_KEYS = {
59
59
  "9": 8,
60
60
  "0": 9
61
61
  };
62
- function OverflowingToolbar({ children }) {
62
+ function OverflowingToolbar({
63
+ children,
64
+ orientation,
65
+ sizingParentClassName,
66
+ minItems,
67
+ minSizePx,
68
+ maxItems,
69
+ maxSizePx
70
+ }) {
63
71
  const editor = (0, import_editor.useEditor)();
64
72
  const id = (0, import_editor.useUniqueSafeId)();
65
73
  const breakpoint = (0, import_breakpoints.useBreakpoint)();
66
74
  const msg = (0, import_useTranslation.useTranslation)();
67
75
  const rButtons = (0, import_react.useRef)([]);
68
76
  const [isOpen, setIsOpen] = (0, import_react.useState)(false);
69
- const overflowIndex = Math.min(8, 5 + breakpoint);
70
- const [totalItems, setTotalItems] = (0, import_react.useState)(0);
71
77
  const mainToolsRef = (0, import_react.useRef)(null);
78
+ const [overflowTools, setOverflowTools] = (0, import_react.useState)(null);
72
79
  const [lastActiveOverflowItem, setLastActiveOverflowItem] = (0, import_react.useState)(null);
73
- const css = (0, import_react.useMemo)(() => {
74
- const activeCss = lastActiveOverflowItem ? `:not([data-value="${lastActiveOverflowItem}"])` : "";
75
- return `
76
- #${id}_main > *:nth-of-type(n + ${overflowIndex + (lastActiveOverflowItem ? 1 : 2)}):not([data-radix-popper-content-wrapper])${activeCss} {
77
- display: none;
78
- }
79
- #${id}_more > *:nth-of-type(-n + ${overflowIndex}):not([data-radix-popper-content-wrapper]) {
80
- display: none;
81
- }
82
- `;
83
- }, [lastActiveOverflowItem, id, overflowIndex]);
80
+ const [shouldShowOverflow, setShouldShowOverflow] = (0, import_react.useState)(false);
84
81
  const onDomUpdate = (0, import_editor.useEvent)(() => {
85
82
  if (!mainToolsRef.current) return;
86
- const children2 = Array.from(mainToolsRef.current.children);
87
- setTotalItems(children2.length);
88
- const lastActiveElementIdx = children2.findIndex(
89
- (el) => el.getAttribute("data-value") === lastActiveOverflowItem
90
- );
91
- if (lastActiveElementIdx <= overflowIndex) {
92
- setLastActiveOverflowItem(null);
83
+ const sizeProp = orientation === "horizontal" ? "offsetWidth" : "offsetHeight";
84
+ const mainItems = collectItems(mainToolsRef.current.children);
85
+ const overflowItems = overflowTools ? collectItems(overflowTools.children) : null;
86
+ function collectItems(collection) {
87
+ const items = [];
88
+ for (const child of collection) {
89
+ if (child.classList.contains("tlui-main-toolbar__group")) {
90
+ items.push({
91
+ type: "group",
92
+ items: collectItems(child.children),
93
+ element: child
94
+ });
95
+ } else {
96
+ items.push({ type: "item", element: child });
97
+ }
98
+ }
99
+ return items;
93
100
  }
94
- const activeElementIdx = Array.from(mainToolsRef.current.children).findIndex(
95
- (el) => el.getAttribute("aria-pressed") === "true"
101
+ const sizingParent = findParentWithClassName(mainToolsRef.current, sizingParentClassName);
102
+ const size = sizingParent[sizeProp];
103
+ const itemsToShow = Math.floor(
104
+ (0, import_editor.modulate)(size, [minSizePx, maxSizePx], [minItems, maxItems], true)
96
105
  );
97
- if (activeElementIdx === -1) return;
98
- if (activeElementIdx >= overflowIndex) {
99
- setLastActiveOverflowItem(children2[activeElementIdx].getAttribute("data-value"));
100
- }
101
- rButtons.current = Array.from(mainToolsRef.current?.children ?? []).filter(
102
- (el) => {
103
- if (!(el instanceof HTMLElement)) return false;
104
- if (el.tagName.toLowerCase() !== "button") return false;
105
- return !!(el.offsetWidth || el.offsetHeight);
106
+ let mainItemCount = 0;
107
+ let newActiveOverflowItem = null;
108
+ let shouldInvalidateLastActiveOverflowItem = false;
109
+ const numberedButtons = [];
110
+ function visitItems(mainItems2, overflowItems2) {
111
+ if (overflowItems2) (0, import_editor.assert)(mainItems2.length === overflowItems2.length);
112
+ let didShowAnyInMain = false;
113
+ let didShowAnyInOverflow2 = false;
114
+ for (let i = 0; i < mainItems2.length; i++) {
115
+ const mainItem = mainItems2[i];
116
+ const overflowItem = overflowItems2?.[i];
117
+ if (mainItem.type === "item") {
118
+ const isLastActiveOverflowItem = mainItem.element.getAttribute("data-value") === lastActiveOverflowItem;
119
+ let shouldShowInMain;
120
+ if (lastActiveOverflowItem) {
121
+ shouldShowInMain = mainItemCount < itemsToShow || isLastActiveOverflowItem;
122
+ } else {
123
+ shouldShowInMain = mainItemCount <= itemsToShow;
124
+ }
125
+ const shouldShowInOverflow = mainItemCount >= itemsToShow;
126
+ didShowAnyInMain ||= shouldShowInMain;
127
+ didShowAnyInOverflow2 ||= shouldShowInOverflow;
128
+ setAttribute(
129
+ mainItem.element,
130
+ "data-toolbar-visible",
131
+ shouldShowInMain ? "true" : "false"
132
+ );
133
+ if (overflowItem) {
134
+ (0, import_editor.assert)(overflowItem.type === "item");
135
+ setAttribute(
136
+ overflowItem.element,
137
+ "data-toolbar-visible",
138
+ shouldShowInOverflow ? "true" : "false"
139
+ );
140
+ }
141
+ if (shouldShowInOverflow && mainItem.element.getAttribute("aria-pressed") === "true") {
142
+ newActiveOverflowItem = mainItem.element.getAttribute("data-value");
143
+ }
144
+ if (shouldShowInMain && mainItem.element.tagName === "BUTTON") {
145
+ numberedButtons.push(mainItem.element);
146
+ }
147
+ if (!shouldShowInOverflow && isLastActiveOverflowItem) {
148
+ shouldInvalidateLastActiveOverflowItem = true;
149
+ }
150
+ mainItemCount++;
151
+ } else {
152
+ let result, overflowGroup;
153
+ if (overflowItem) {
154
+ (0, import_editor.assert)(overflowItem.type === "group");
155
+ overflowGroup = overflowItem;
156
+ result = visitItems(mainItem.items, overflowGroup.items);
157
+ } else {
158
+ result = visitItems(mainItem.items, null);
159
+ }
160
+ didShowAnyInMain ||= result.didShowAnyInMain;
161
+ didShowAnyInOverflow2 ||= result.didShowAnyInOverflow;
162
+ setAttribute(
163
+ mainItem.element,
164
+ "data-toolbar-visible",
165
+ result.didShowAnyInMain ? "true" : "false"
166
+ );
167
+ if (overflowGroup) {
168
+ setAttribute(
169
+ overflowGroup.element,
170
+ "data-toolbar-visible",
171
+ result.didShowAnyInOverflow ? "true" : "false"
172
+ );
173
+ }
174
+ }
106
175
  }
107
- );
176
+ return { didShowAnyInMain, didShowAnyInOverflow: didShowAnyInOverflow2 };
177
+ }
178
+ const { didShowAnyInOverflow } = visitItems(mainItems, overflowItems);
179
+ setShouldShowOverflow(didShowAnyInOverflow);
180
+ if (newActiveOverflowItem) {
181
+ setLastActiveOverflowItem(newActiveOverflowItem);
182
+ } else if (shouldInvalidateLastActiveOverflowItem) {
183
+ setLastActiveOverflowItem(null);
184
+ }
185
+ rButtons.current = numberedButtons;
108
186
  });
109
187
  (0, import_react.useLayoutEffect)(() => {
110
188
  onDomUpdate();
@@ -115,20 +193,26 @@ function OverflowingToolbar({ children }) {
115
193
  mutationObserver.observe(mainToolsRef.current, {
116
194
  childList: true,
117
195
  subtree: true,
118
- attributeFilter: ["data-value", "aria-pressed"]
196
+ attributes: true,
197
+ characterData: true
119
198
  });
199
+ const sizingParent = findParentWithClassName(mainToolsRef.current, sizingParentClassName);
200
+ const resizeObserver = new ResizeObserver(onDomUpdate);
201
+ resizeObserver.observe(sizingParent);
120
202
  return () => {
121
203
  mutationObserver.disconnect();
204
+ resizeObserver.disconnect();
122
205
  };
123
- }, [onDomUpdate]);
206
+ }, [onDomUpdate, sizingParentClassName]);
124
207
  (0, import_react.useEffect)(() => {
125
208
  if (!editor.options.enableToolbarKeyboardShortcuts) return;
126
209
  function handleKeyDown(event) {
127
210
  if ((0, import_useKeyboardShortcuts.areShortcutsDisabled)(editor) || (0, import_editor.activeElementShouldCaptureKeys)(
128
211
  true
129
212
  /* allow buttons */
130
- ))
213
+ )) {
131
214
  return;
215
+ }
132
216
  if (event.ctrlKey || event.metaKey || event.altKey || event.shiftKey) return;
133
217
  const index = NUMBERED_SHORTCUT_KEYS[event.key];
134
218
  if (typeof index === "number") {
@@ -142,50 +226,76 @@ function OverflowingToolbar({ children }) {
142
226
  };
143
227
  }, [editor]);
144
228
  const popoverId = "toolbar overflow";
145
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
146
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("style", { nonce: editor.options.nonce, children: css }),
147
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
148
- import_TldrawUiToolbar.TldrawUiToolbar,
149
- {
150
- orientation: "horizontal",
151
- className: (0, import_classnames.default)("tlui-main-toolbar__tools", {
152
- "tlui-main-toolbar__tools__mobile": breakpoint < import_constants.PORTRAIT_BREAKPOINT.TABLET_SM
153
- }),
154
- label: msg("tool-panel.title"),
155
- children: [
156
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_layout.TldrawUiRow, { id: `${id}_main`, ref: mainToolsRef, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_TldrawUiMenuContext.TldrawUiMenuContextProvider, { type: "toolbar", sourceId: "toolbar", children }) }),
157
- totalItems > overflowIndex + 1 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(IsInOverflowContext.Provider, { value: true, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_TldrawUiPopover.TldrawUiPopover, { id: popoverId, open: isOpen, onOpenChange: setIsOpen, children: [
158
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_TldrawUiPopover.TldrawUiPopoverTrigger, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
159
- import_TldrawUiToolbar.TldrawUiToolbarButton,
160
- {
161
- title: msg("tool-panel.more"),
162
- type: "tool",
163
- className: "tlui-main-toolbar__overflow",
164
- "data-testid": "tools.more-button",
165
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_TldrawUiButtonIcon.TldrawUiButtonIcon, { icon: "chevron-up" })
166
- }
167
- ) }),
168
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_TldrawUiPopover.TldrawUiPopoverContent, { side: "top", align: "center", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
169
- import_TldrawUiToolbar.TldrawUiToolbar,
170
- {
171
- orientation: "grid",
172
- "data-testid": "tools.more-content",
173
- label: msg("tool-panel.more"),
174
- id: `${id}_more`,
175
- onClick: () => {
176
- import_editor.tlmenus.deleteOpenMenu(popoverId, editor.contextId);
177
- setIsOpen(false);
178
- },
179
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_TldrawUiMenuContext.TldrawUiMenuContextProvider, { type: "toolbar-overflow", sourceId: "toolbar", children })
180
- }
181
- ) })
182
- ] }) })
183
- ]
184
- }
185
- )
186
- ] });
229
+ const Layout = orientation === "horizontal" ? import_layout.TldrawUiRow : import_layout.TldrawUiColumn;
230
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
231
+ import_TldrawUiToolbar.TldrawUiToolbar,
232
+ {
233
+ orientation,
234
+ className: (0, import_classnames.default)("tlui-main-toolbar__tools", {
235
+ "tlui-main-toolbar__tools__mobile": breakpoint < import_constants.PORTRAIT_BREAKPOINT.TABLET_SM
236
+ }),
237
+ label: msg("tool-panel.title"),
238
+ children: [
239
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Layout, { id: `${id}_main`, ref: mainToolsRef, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_TldrawUiMenuContext.TldrawUiMenuContextProvider, { type: "toolbar", sourceId: "toolbar", children }) }),
240
+ shouldShowOverflow && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(IsInOverflowContext.Provider, { value: true, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_TldrawUiPopover.TldrawUiPopover, { id: popoverId, open: isOpen, onOpenChange: setIsOpen, children: [
241
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_TldrawUiPopover.TldrawUiPopoverTrigger, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
242
+ import_TldrawUiToolbar.TldrawUiToolbarButton,
243
+ {
244
+ title: msg("tool-panel.more"),
245
+ type: "tool",
246
+ className: "tlui-main-toolbar__overflow",
247
+ "data-testid": "tools.more-button",
248
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
249
+ import_TldrawUiButtonIcon.TldrawUiButtonIcon,
250
+ {
251
+ icon: orientation === "horizontal" ? "chevron-up" : "chevron-right"
252
+ }
253
+ )
254
+ }
255
+ ) }),
256
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
257
+ import_TldrawUiPopover.TldrawUiPopoverContent,
258
+ {
259
+ side: orientation === "horizontal" ? "top" : "right",
260
+ align: orientation === "horizontal" ? "center" : "end",
261
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
262
+ import_TldrawUiToolbar.TldrawUiToolbar,
263
+ {
264
+ orientation: "grid",
265
+ className: "tlui-main-toolbar__overflow-content",
266
+ ref: setOverflowTools,
267
+ "data-testid": "tools.more-content",
268
+ label: msg("tool-panel.more"),
269
+ id: `${id}_more`,
270
+ onClick: () => {
271
+ import_editor.tlmenus.deleteOpenMenu(popoverId, editor.contextId);
272
+ setIsOpen(false);
273
+ },
274
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_TldrawUiMenuContext.TldrawUiMenuContextProvider, { type: "toolbar-overflow", sourceId: "toolbar", children })
275
+ }
276
+ )
277
+ }
278
+ )
279
+ ] }) })
280
+ ]
281
+ }
282
+ ) });
187
283
  }
188
284
  const isActiveTLUiToolItem = (item, activeToolId, geoState) => {
189
285
  return item.meta?.geo ? activeToolId === "geo" && geoState === item.meta?.geo : activeToolId === item.id;
190
286
  };
287
+ function findParentWithClassName(startingElement, className) {
288
+ let element = startingElement;
289
+ while (element) {
290
+ if (element.classList.contains(className)) {
291
+ return element;
292
+ }
293
+ element = element.parentElement;
294
+ }
295
+ throw new Error("Could not find parent with class name " + className);
296
+ }
297
+ function setAttribute(element, name, value) {
298
+ if (element.getAttribute(name) === value) return;
299
+ element.setAttribute(name, value);
300
+ }
191
301
  //# sourceMappingURL=OverflowingToolbar.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/lib/ui/components/Toolbar/OverflowingToolbar.tsx"],
4
- "sourcesContent": ["import {\n\tactiveElementShouldCaptureKeys,\n\tpreventDefault,\n\ttlmenus,\n\tuseEditor,\n\tuseEvent,\n\tuseUniqueSafeId,\n} from '@tldraw/editor'\nimport classNames from 'classnames'\nimport { createContext, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react'\nimport { PORTRAIT_BREAKPOINT } from '../../constants'\nimport { useBreakpoint } from '../../context/breakpoints'\nimport { areShortcutsDisabled } from '../../hooks/useKeyboardShortcuts'\nimport { TLUiToolItem } from '../../hooks/useTools'\nimport { useTranslation } from '../../hooks/useTranslation/useTranslation'\nimport { TldrawUiButtonIcon } from '../primitives/Button/TldrawUiButtonIcon'\nimport {\n\tTldrawUiPopover,\n\tTldrawUiPopoverContent,\n\tTldrawUiPopoverTrigger,\n} from '../primitives/TldrawUiPopover'\nimport { TldrawUiToolbar, TldrawUiToolbarButton } from '../primitives/TldrawUiToolbar'\nimport { TldrawUiRow } from '../primitives/layout'\nimport { TldrawUiMenuContextProvider } from '../primitives/menus/TldrawUiMenuContext'\n\nexport const IsInOverflowContext = createContext(false)\n\nconst NUMBERED_SHORTCUT_KEYS: Record<string, number> = {\n\t'1': 0,\n\t'2': 1,\n\t'3': 2,\n\t'4': 3,\n\t'5': 4,\n\t'6': 5,\n\t'7': 6,\n\t'8': 7,\n\t'9': 8,\n\t'0': 9,\n}\n\n/** @public */\nexport interface OverflowingToolbarProps {\n\tchildren: React.ReactNode\n}\n\n/** @public @react */\nexport function OverflowingToolbar({ children }: OverflowingToolbarProps) {\n\tconst editor = useEditor()\n\tconst id = useUniqueSafeId()\n\tconst breakpoint = useBreakpoint()\n\tconst msg = useTranslation()\n\tconst rButtons = useRef<HTMLElement[]>([])\n\tconst [isOpen, setIsOpen] = useState(false)\n\n\tconst overflowIndex = Math.min(8, 5 + breakpoint)\n\n\tconst [totalItems, setTotalItems] = useState(0)\n\tconst mainToolsRef = useRef<HTMLDivElement>(null)\n\tconst [lastActiveOverflowItem, setLastActiveOverflowItem] = useState<string | null>(null)\n\n\tconst css = useMemo(() => {\n\t\tconst activeCss = lastActiveOverflowItem ? `:not([data-value=\"${lastActiveOverflowItem}\"])` : ''\n\n\t\treturn `\n\t\t\t#${id}_main > *:nth-of-type(n + ${overflowIndex + (lastActiveOverflowItem ? 1 : 2)}):not([data-radix-popper-content-wrapper])${activeCss} {\n\t\t\t\tdisplay: none;\n\t\t\t}\n\t\t\t#${id}_more > *:nth-of-type(-n + ${overflowIndex}):not([data-radix-popper-content-wrapper]) {\n\t\t\t\tdisplay: none;\n\t\t\t}\n `\n\t}, [lastActiveOverflowItem, id, overflowIndex])\n\n\tconst onDomUpdate = useEvent(() => {\n\t\tif (!mainToolsRef.current) return\n\n\t\tconst children = Array.from(mainToolsRef.current.children)\n\t\tsetTotalItems(children.length)\n\n\t\t// If the last active overflow item is no longer in the overflow, clear it\n\t\tconst lastActiveElementIdx = children.findIndex(\n\t\t\t(el) => el.getAttribute('data-value') === lastActiveOverflowItem\n\t\t)\n\t\tif (lastActiveElementIdx <= overflowIndex) {\n\t\t\tsetLastActiveOverflowItem(null)\n\t\t}\n\n\t\t// But if there's a new active item...\n\t\tconst activeElementIdx = Array.from(mainToolsRef.current.children).findIndex(\n\t\t\t(el) => el.getAttribute('aria-pressed') === 'true'\n\t\t)\n\t\tif (activeElementIdx === -1) return\n\n\t\t// ...and it's in the overflow, set it as the last active overflow item\n\t\tif (activeElementIdx >= overflowIndex) {\n\t\t\tsetLastActiveOverflowItem(children[activeElementIdx].getAttribute('data-value'))\n\t\t}\n\n\t\t// Save the buttons that are actually visible\n\t\trButtons.current = Array.from(mainToolsRef.current?.children ?? []).filter(\n\t\t\t(el): el is HTMLElement => {\n\t\t\t\t// only count html elements...\n\t\t\t\tif (!(el instanceof HTMLElement)) return false\n\n\t\t\t\t// ...that are buttons...\n\t\t\t\tif (el.tagName.toLowerCase() !== 'button') return false\n\n\t\t\t\t// ...that are actually visible\n\t\t\t\treturn !!(el.offsetWidth || el.offsetHeight)\n\t\t\t}\n\t\t)\n\t})\n\n\tuseLayoutEffect(() => {\n\t\tonDomUpdate()\n\t})\n\n\tuseLayoutEffect(() => {\n\t\tif (!mainToolsRef.current) return\n\n\t\tconst mutationObserver = new MutationObserver(onDomUpdate)\n\t\tmutationObserver.observe(mainToolsRef.current, {\n\t\t\tchildList: true,\n\t\t\tsubtree: true,\n\t\t\tattributeFilter: ['data-value', 'aria-pressed'],\n\t\t})\n\n\t\treturn () => {\n\t\t\tmutationObserver.disconnect()\n\t\t}\n\t}, [onDomUpdate])\n\n\tuseEffect(() => {\n\t\tif (!editor.options.enableToolbarKeyboardShortcuts) return\n\n\t\tfunction handleKeyDown(event: KeyboardEvent) {\n\t\t\tif (areShortcutsDisabled(editor) || activeElementShouldCaptureKeys(true /* allow buttons */))\n\t\t\t\treturn\n\t\t\t// no accelerator keys\n\t\t\tif (event.ctrlKey || event.metaKey || event.altKey || event.shiftKey) return\n\t\t\tconst index = NUMBERED_SHORTCUT_KEYS[event.key]\n\t\t\tif (typeof index === 'number') {\n\t\t\t\tpreventDefault(event)\n\t\t\t\trButtons.current[index]?.click()\n\t\t\t}\n\t\t}\n\n\t\tdocument.addEventListener('keydown', handleKeyDown)\n\t\treturn () => {\n\t\t\tdocument.removeEventListener('keydown', handleKeyDown)\n\t\t}\n\t}, [editor])\n\n\tconst popoverId = 'toolbar overflow'\n\treturn (\n\t\t<>\n\t\t\t<style nonce={editor.options.nonce}>{css}</style>\n\t\t\t<TldrawUiToolbar\n\t\t\t\torientation=\"horizontal\"\n\t\t\t\tclassName={classNames('tlui-main-toolbar__tools', {\n\t\t\t\t\t'tlui-main-toolbar__tools__mobile': breakpoint < PORTRAIT_BREAKPOINT.TABLET_SM,\n\t\t\t\t})}\n\t\t\t\tlabel={msg('tool-panel.title')}\n\t\t\t>\n\t\t\t\t<TldrawUiRow id={`${id}_main`} ref={mainToolsRef}>\n\t\t\t\t\t<TldrawUiMenuContextProvider type=\"toolbar\" sourceId=\"toolbar\">\n\t\t\t\t\t\t{children}\n\t\t\t\t\t</TldrawUiMenuContextProvider>\n\t\t\t\t</TldrawUiRow>\n\t\t\t\t{/* There is a +1 because if the menu is just one item, it's not necessary. */}\n\t\t\t\t{totalItems > overflowIndex + 1 && (\n\t\t\t\t\t<IsInOverflowContext.Provider value={true}>\n\t\t\t\t\t\t<TldrawUiPopover id={popoverId} open={isOpen} onOpenChange={setIsOpen}>\n\t\t\t\t\t\t\t<TldrawUiPopoverTrigger>\n\t\t\t\t\t\t\t\t<TldrawUiToolbarButton\n\t\t\t\t\t\t\t\t\ttitle={msg('tool-panel.more')}\n\t\t\t\t\t\t\t\t\ttype=\"tool\"\n\t\t\t\t\t\t\t\t\tclassName=\"tlui-main-toolbar__overflow\"\n\t\t\t\t\t\t\t\t\tdata-testid=\"tools.more-button\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<TldrawUiButtonIcon icon=\"chevron-up\" />\n\t\t\t\t\t\t\t\t</TldrawUiToolbarButton>\n\t\t\t\t\t\t\t</TldrawUiPopoverTrigger>\n\t\t\t\t\t\t\t<TldrawUiPopoverContent side=\"top\" align=\"center\">\n\t\t\t\t\t\t\t\t<TldrawUiToolbar\n\t\t\t\t\t\t\t\t\torientation=\"grid\"\n\t\t\t\t\t\t\t\t\tdata-testid=\"tools.more-content\"\n\t\t\t\t\t\t\t\t\tlabel={msg('tool-panel.more')}\n\t\t\t\t\t\t\t\t\tid={`${id}_more`}\n\t\t\t\t\t\t\t\t\tonClick={() => {\n\t\t\t\t\t\t\t\t\t\ttlmenus.deleteOpenMenu(popoverId, editor.contextId)\n\t\t\t\t\t\t\t\t\t\tsetIsOpen(false)\n\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<TldrawUiMenuContextProvider type=\"toolbar-overflow\" sourceId=\"toolbar\">\n\t\t\t\t\t\t\t\t\t\t{children}\n\t\t\t\t\t\t\t\t\t</TldrawUiMenuContextProvider>\n\t\t\t\t\t\t\t\t</TldrawUiToolbar>\n\t\t\t\t\t\t\t</TldrawUiPopoverContent>\n\t\t\t\t\t\t</TldrawUiPopover>\n\t\t\t\t\t</IsInOverflowContext.Provider>\n\t\t\t\t)}\n\t\t\t</TldrawUiToolbar>\n\t\t</>\n\t)\n}\n\nexport const isActiveTLUiToolItem = (\n\titem: TLUiToolItem,\n\tactiveToolId: string | undefined,\n\tgeoState: string | null | undefined\n) => {\n\treturn item.meta?.geo\n\t\t? activeToolId === 'geo' && geoState === item.meta?.geo\n\t\t: activeToolId === item.id\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA2JE;AA3JF,oBAOO;AACP,wBAAuB;AACvB,mBAAqF;AACrF,uBAAoC;AACpC,yBAA8B;AAC9B,kCAAqC;AAErC,4BAA+B;AAC/B,gCAAmC;AACnC,6BAIO;AACP,6BAAuD;AACvD,oBAA4B;AAC5B,iCAA4C;AAErC,MAAM,0BAAsB,4BAAc,KAAK;AAEtD,MAAM,yBAAiD;AAAA,EACtD,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAA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classNames"]
4
+ "sourcesContent": ["import {\n\tactiveElementShouldCaptureKeys,\n\tassert,\n\tmodulate,\n\tpreventDefault,\n\ttlmenus,\n\tuseEditor,\n\tuseEvent,\n\tuseUniqueSafeId,\n} from '@tldraw/editor'\nimport classNames from 'classnames'\nimport { createContext, useEffect, useLayoutEffect, useRef, useState } from 'react'\nimport { PORTRAIT_BREAKPOINT } from '../../constants'\nimport { useBreakpoint } from '../../context/breakpoints'\nimport { areShortcutsDisabled } from '../../hooks/useKeyboardShortcuts'\nimport { TLUiToolItem } from '../../hooks/useTools'\nimport { useTranslation } from '../../hooks/useTranslation/useTranslation'\nimport { TldrawUiButtonIcon } from '../primitives/Button/TldrawUiButtonIcon'\nimport {\n\tTldrawUiPopover,\n\tTldrawUiPopoverContent,\n\tTldrawUiPopoverTrigger,\n} from '../primitives/TldrawUiPopover'\nimport { TldrawUiToolbar, TldrawUiToolbarButton } from '../primitives/TldrawUiToolbar'\nimport { TldrawUiColumn, TldrawUiRow } from '../primitives/layout'\nimport { TldrawUiMenuContextProvider } from '../primitives/menus/TldrawUiMenuContext'\n\nexport const IsInOverflowContext = createContext(false)\n\nconst NUMBERED_SHORTCUT_KEYS: Record<string, number> = {\n\t'1': 0,\n\t'2': 1,\n\t'3': 2,\n\t'4': 3,\n\t'5': 4,\n\t'6': 5,\n\t'7': 6,\n\t'8': 7,\n\t'9': 8,\n\t'0': 9,\n}\n\n/** @public */\nexport interface OverflowingToolbarProps {\n\tchildren: React.ReactNode\n\torientation: 'horizontal' | 'vertical'\n\tsizingParentClassName: string\n\tminItems: number\n\tminSizePx: number\n\tmaxItems: number\n\tmaxSizePx: number\n}\n\n/** @public @react */\nexport function OverflowingToolbar({\n\tchildren,\n\torientation,\n\tsizingParentClassName,\n\tminItems,\n\tminSizePx,\n\tmaxItems,\n\tmaxSizePx,\n}: OverflowingToolbarProps) {\n\tconst editor = useEditor()\n\tconst id = useUniqueSafeId()\n\tconst breakpoint = useBreakpoint()\n\tconst msg = useTranslation()\n\tconst rButtons = useRef<HTMLElement[]>([])\n\tconst [isOpen, setIsOpen] = useState(false)\n\n\tconst mainToolsRef = useRef<HTMLDivElement>(null)\n\n\t// we have to use state instead of a ref here so that we get\n\t// an update when the overflow popover mounts / unmounts\n\tconst [overflowTools, setOverflowTools] = useState<HTMLDivElement | null>(null)\n\tconst [lastActiveOverflowItem, setLastActiveOverflowItem] = useState<string | null>(null)\n\tconst [shouldShowOverflow, setShouldShowOverflow] = useState(false)\n\n\tconst onDomUpdate = useEvent(() => {\n\t\tif (!mainToolsRef.current) return\n\n\t\t// whenever we get an update, we need to re-calculate the number of items to show and update\n\t\t// the component accordingly.\n\t\tconst sizeProp = orientation === 'horizontal' ? 'offsetWidth' : 'offsetHeight'\n\n\t\t// toolbars can contain both single items and groups. we need to keep track of both.\n\t\ttype Items = (\n\t\t\t| { type: 'item'; element: HTMLElement }\n\t\t\t| { type: 'group'; items: Items; element: HTMLElement }\n\t\t)[]\n\n\t\t// walk through the dom and collect items so we can calculate what to show/hide\n\t\tconst mainItems = collectItems(mainToolsRef.current.children)\n\t\tconst overflowItems = overflowTools ? collectItems(overflowTools.children) : null\n\t\tfunction collectItems(collection: HTMLCollection) {\n\t\t\tconst items: Items = []\n\t\t\tfor (const child of collection) {\n\t\t\t\tif (child.classList.contains('tlui-main-toolbar__group')) {\n\t\t\t\t\titems.push({\n\t\t\t\t\t\ttype: 'group',\n\t\t\t\t\t\titems: collectItems(child.children),\n\t\t\t\t\t\telement: child as HTMLElement,\n\t\t\t\t\t})\n\t\t\t\t} else {\n\t\t\t\t\titems.push({ type: 'item', element: child as HTMLElement })\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn items\n\t\t}\n\n\t\t// the number of items to show is based on the space available to the toolbar.\n\t\tconst sizingParent = findParentWithClassName(mainToolsRef.current, sizingParentClassName)\n\t\tconst size = sizingParent[sizeProp]\n\t\tconst itemsToShow = Math.floor(\n\t\t\tmodulate(size, [minSizePx, maxSizePx], [minItems, maxItems], true)\n\t\t)\n\n\t\t// now we know how many items to show, we need to walk through the items we found and show /\n\t\t// hide them accordingly. We need to keep track of:\n\t\t// the number of item's we've shown in the main content so far\n\t\tlet mainItemCount = 0\n\t\t// the item that is currently active in the overflow content (if any)\n\t\tlet newActiveOverflowItem: string | null = null\n\t\t// whether the last active overflow item is actually still in the overflow content\n\t\tlet shouldInvalidateLastActiveOverflowItem = false\n\t\t// the buttons visible in the main content\n\t\tconst numberedButtons: HTMLButtonElement[] = []\n\t\tfunction visitItems(\n\t\t\tmainItems: Items,\n\t\t\toverflowItems: Items | null\n\t\t): {\n\t\t\t// for each group of items we visit, we need to know whether we showed anything in\n\t\t\t// either section\n\t\t\tdidShowAnyInMain: boolean\n\t\t\tdidShowAnyInOverflow: boolean\n\t\t} {\n\t\t\tif (overflowItems) assert(mainItems.length === overflowItems.length)\n\n\t\t\tlet didShowAnyInMain = false\n\t\t\tlet didShowAnyInOverflow = false\n\n\t\t\tfor (let i = 0; i < mainItems.length; i++) {\n\t\t\t\tconst mainItem = mainItems[i]\n\t\t\t\tconst overflowItem = overflowItems?.[i]\n\n\t\t\t\tif (mainItem.type === 'item') {\n\t\t\t\t\tconst isLastActiveOverflowItem =\n\t\t\t\t\t\tmainItem.element.getAttribute('data-value') === lastActiveOverflowItem\n\n\t\t\t\t\t// for single items, we show them in main if we have space, or if they're the\n\t\t\t\t\t// last-used item from the overflow.\n\t\t\t\t\tlet shouldShowInMain\n\t\t\t\t\tif (lastActiveOverflowItem) {\n\t\t\t\t\t\tshouldShowInMain = mainItemCount < itemsToShow || isLastActiveOverflowItem\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// we use <= here because if there is no last active overflow item, we want\n\t\t\t\t\t\t// to show at least one item in the main toolbar.\n\t\t\t\t\t\tshouldShowInMain = mainItemCount <= itemsToShow\n\t\t\t\t\t}\n\t\t\t\t\tconst shouldShowInOverflow = mainItemCount >= itemsToShow\n\n\t\t\t\t\tdidShowAnyInMain ||= shouldShowInMain\n\t\t\t\t\tdidShowAnyInOverflow ||= shouldShowInOverflow\n\n\t\t\t\t\tsetAttribute(\n\t\t\t\t\t\tmainItem.element,\n\t\t\t\t\t\t'data-toolbar-visible',\n\t\t\t\t\t\tshouldShowInMain ? 'true' : 'false'\n\t\t\t\t\t)\n\t\t\t\t\tif (overflowItem) {\n\t\t\t\t\t\tassert(overflowItem.type === 'item')\n\t\t\t\t\t\tsetAttribute(\n\t\t\t\t\t\t\toverflowItem.element,\n\t\t\t\t\t\t\t'data-toolbar-visible',\n\t\t\t\t\t\t\tshouldShowInOverflow ? 'true' : 'false'\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t\tif (shouldShowInOverflow && mainItem.element.getAttribute('aria-pressed') === 'true') {\n\t\t\t\t\t\tnewActiveOverflowItem = mainItem.element.getAttribute('data-value')\n\t\t\t\t\t}\n\t\t\t\t\tif (shouldShowInMain && mainItem.element.tagName === 'BUTTON') {\n\t\t\t\t\t\tnumberedButtons.push(mainItem.element as HTMLButtonElement)\n\t\t\t\t\t}\n\t\t\t\t\tif (!shouldShowInOverflow && isLastActiveOverflowItem) {\n\t\t\t\t\t\tshouldInvalidateLastActiveOverflowItem = true\n\t\t\t\t\t}\n\t\t\t\t\tmainItemCount++\n\t\t\t\t} else {\n\t\t\t\t\t// for groups, we show them in main if we have space, or if they're the\n\t\t\t\t\t// last-used item from the overflow.\n\t\t\t\t\tlet result, overflowGroup\n\t\t\t\t\tif (overflowItem) {\n\t\t\t\t\t\tassert(overflowItem.type === 'group')\n\t\t\t\t\t\toverflowGroup = overflowItem\n\t\t\t\t\t\tresult = visitItems(mainItem.items, overflowGroup.items)\n\t\t\t\t\t} else {\n\t\t\t\t\t\tresult = visitItems(mainItem.items, null)\n\t\t\t\t\t}\n\n\t\t\t\t\tdidShowAnyInMain ||= result.didShowAnyInMain\n\t\t\t\t\tdidShowAnyInOverflow ||= result.didShowAnyInOverflow\n\n\t\t\t\t\tsetAttribute(\n\t\t\t\t\t\tmainItem.element,\n\t\t\t\t\t\t'data-toolbar-visible',\n\t\t\t\t\t\tresult.didShowAnyInMain ? 'true' : 'false'\n\t\t\t\t\t)\n\t\t\t\t\tif (overflowGroup) {\n\t\t\t\t\t\tsetAttribute(\n\t\t\t\t\t\t\toverflowGroup.element,\n\t\t\t\t\t\t\t'data-toolbar-visible',\n\t\t\t\t\t\t\tresult.didShowAnyInOverflow ? 'true' : 'false'\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\treturn { didShowAnyInMain, didShowAnyInOverflow }\n\t\t}\n\n\t\tconst { didShowAnyInOverflow } = visitItems(mainItems, overflowItems)\n\t\tsetShouldShowOverflow(didShowAnyInOverflow)\n\t\tif (newActiveOverflowItem) {\n\t\t\tsetLastActiveOverflowItem(newActiveOverflowItem)\n\t\t} else if (shouldInvalidateLastActiveOverflowItem) {\n\t\t\tsetLastActiveOverflowItem(null)\n\t\t}\n\n\t\trButtons.current = numberedButtons\n\t})\n\n\tuseLayoutEffect(() => {\n\t\tonDomUpdate()\n\t})\n\n\tuseLayoutEffect(() => {\n\t\tif (!mainToolsRef.current) return\n\n\t\tconst mutationObserver = new MutationObserver(onDomUpdate)\n\t\tmutationObserver.observe(mainToolsRef.current, {\n\t\t\tchildList: true,\n\t\t\tsubtree: true,\n\t\t\tattributes: true,\n\t\t\tcharacterData: true,\n\t\t})\n\n\t\tconst sizingParent = findParentWithClassName(mainToolsRef.current, sizingParentClassName)\n\t\tconst resizeObserver = new ResizeObserver(onDomUpdate)\n\t\tresizeObserver.observe(sizingParent)\n\n\t\treturn () => {\n\t\t\tmutationObserver.disconnect()\n\t\t\tresizeObserver.disconnect()\n\t\t}\n\t}, [onDomUpdate, sizingParentClassName])\n\n\tuseEffect(() => {\n\t\tif (!editor.options.enableToolbarKeyboardShortcuts) return\n\n\t\tfunction handleKeyDown(event: KeyboardEvent) {\n\t\t\tif (\n\t\t\t\tareShortcutsDisabled(editor) ||\n\t\t\t\tactiveElementShouldCaptureKeys(true /* allow buttons */)\n\t\t\t) {\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\t// no accelerator keys\n\t\t\tif (event.ctrlKey || event.metaKey || event.altKey || event.shiftKey) return\n\t\t\tconst index = NUMBERED_SHORTCUT_KEYS[event.key]\n\t\t\tif (typeof index === 'number') {\n\t\t\t\tpreventDefault(event)\n\t\t\t\trButtons.current[index]?.click()\n\t\t\t}\n\t\t}\n\n\t\tdocument.addEventListener('keydown', handleKeyDown)\n\t\treturn () => {\n\t\t\tdocument.removeEventListener('keydown', handleKeyDown)\n\t\t}\n\t}, [editor])\n\n\tconst popoverId = 'toolbar overflow'\n\n\tconst Layout = orientation === 'horizontal' ? TldrawUiRow : TldrawUiColumn\n\treturn (\n\t\t<>\n\t\t\t<TldrawUiToolbar\n\t\t\t\torientation={orientation}\n\t\t\t\tclassName={classNames('tlui-main-toolbar__tools', {\n\t\t\t\t\t'tlui-main-toolbar__tools__mobile': breakpoint < PORTRAIT_BREAKPOINT.TABLET_SM,\n\t\t\t\t})}\n\t\t\t\tlabel={msg('tool-panel.title')}\n\t\t\t>\n\t\t\t\t<Layout id={`${id}_main`} ref={mainToolsRef}>\n\t\t\t\t\t<TldrawUiMenuContextProvider type=\"toolbar\" sourceId=\"toolbar\">\n\t\t\t\t\t\t{children}\n\t\t\t\t\t</TldrawUiMenuContextProvider>\n\t\t\t\t</Layout>\n\t\t\t\t{shouldShowOverflow && (\n\t\t\t\t\t<IsInOverflowContext.Provider value={true}>\n\t\t\t\t\t\t<TldrawUiPopover id={popoverId} open={isOpen} onOpenChange={setIsOpen}>\n\t\t\t\t\t\t\t<TldrawUiPopoverTrigger>\n\t\t\t\t\t\t\t\t<TldrawUiToolbarButton\n\t\t\t\t\t\t\t\t\ttitle={msg('tool-panel.more')}\n\t\t\t\t\t\t\t\t\ttype=\"tool\"\n\t\t\t\t\t\t\t\t\tclassName=\"tlui-main-toolbar__overflow\"\n\t\t\t\t\t\t\t\t\tdata-testid=\"tools.more-button\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<TldrawUiButtonIcon\n\t\t\t\t\t\t\t\t\t\ticon={orientation === 'horizontal' ? 'chevron-up' : 'chevron-right'}\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t</TldrawUiToolbarButton>\n\t\t\t\t\t\t\t</TldrawUiPopoverTrigger>\n\t\t\t\t\t\t\t<TldrawUiPopoverContent\n\t\t\t\t\t\t\t\tside={orientation === 'horizontal' ? 'top' : 'right'}\n\t\t\t\t\t\t\t\talign={orientation === 'horizontal' ? 'center' : 'end'}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<TldrawUiToolbar\n\t\t\t\t\t\t\t\t\torientation=\"grid\"\n\t\t\t\t\t\t\t\t\tclassName=\"tlui-main-toolbar__overflow-content\"\n\t\t\t\t\t\t\t\t\tref={setOverflowTools}\n\t\t\t\t\t\t\t\t\tdata-testid=\"tools.more-content\"\n\t\t\t\t\t\t\t\t\tlabel={msg('tool-panel.more')}\n\t\t\t\t\t\t\t\t\tid={`${id}_more`}\n\t\t\t\t\t\t\t\t\tonClick={() => {\n\t\t\t\t\t\t\t\t\t\ttlmenus.deleteOpenMenu(popoverId, editor.contextId)\n\t\t\t\t\t\t\t\t\t\tsetIsOpen(false)\n\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<TldrawUiMenuContextProvider type=\"toolbar-overflow\" sourceId=\"toolbar\">\n\t\t\t\t\t\t\t\t\t\t{children}\n\t\t\t\t\t\t\t\t\t</TldrawUiMenuContextProvider>\n\t\t\t\t\t\t\t\t</TldrawUiToolbar>\n\t\t\t\t\t\t\t</TldrawUiPopoverContent>\n\t\t\t\t\t\t</TldrawUiPopover>\n\t\t\t\t\t</IsInOverflowContext.Provider>\n\t\t\t\t)}\n\t\t\t</TldrawUiToolbar>\n\t\t</>\n\t)\n}\n\nexport const isActiveTLUiToolItem = (\n\titem: TLUiToolItem,\n\tactiveToolId: string | undefined,\n\tgeoState: string | null | undefined\n) => {\n\treturn item.meta?.geo\n\t\t? activeToolId === 'geo' && geoState === item.meta?.geo\n\t\t: activeToolId === item.id\n}\n\nfunction findParentWithClassName(startingElement: HTMLElement, className: string): HTMLElement {\n\tlet element: HTMLElement | null = startingElement\n\twhile (element) {\n\t\tif (element.classList.contains(className)) {\n\t\t\treturn element\n\t\t}\n\t\telement = element.parentElement\n\t}\n\tthrow new Error('Could not find parent with class name ' + className)\n}\n\nfunction setAttribute(element: HTMLElement, name: string, value: string) {\n\tif (element.getAttribute(name) === value) return\n\telement.setAttribute(name, value)\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA8RE;AA9RF,oBASO;AACP,wBAAuB;AACvB,mBAA4E;AAC5E,uBAAoC;AACpC,yBAA8B;AAC9B,kCAAqC;AAErC,4BAA+B;AAC/B,gCAAmC;AACnC,6BAIO;AACP,6BAAuD;AACvD,oBAA4C;AAC5C,iCAA4C;AAErC,MAAM,0BAAsB,4BAAc,KAAK;AAEtD,MAAM,yBAAiD;AAAA,EACtD,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AACN;AAcO,SAAS,mBAAmB;AAAA,EAClC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAA4B;AAC3B,QAAM,aAAS,yBAAU;AACzB,QAAM,SAAK,+BAAgB;AAC3B,QAAM,iBAAa,kCAAc;AACjC,QAAM,UAAM,sCAAe;AAC3B,QAAM,eAAW,qBAAsB,CAAC,CAAC;AACzC,QAAM,CAAC,QAAQ,SAAS,QAAI,uBAAS,KAAK;AAE1C,QAAM,mB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A;AAAA;AAAA,EAEF,GACD;AAEF;AAEO,MAAM,uBAAuB,CACnC,MACA,cACA,aACI;AACJ,SAAO,KAAK,MAAM,MACf,iBAAiB,SAAS,aAAa,KAAK,MAAM,MAClD,iBAAiB,KAAK;AAC1B;AAEA,SAAS,wBAAwB,iBAA8B,WAAgC;AAC9F,MAAI,UAA8B;AAClC,SAAO,SAAS;AACf,QAAI,QAAQ,UAAU,SAAS,SAAS,GAAG;AAC1C,aAAO;AAAA,IACR;AACA,cAAU,QAAQ;AAAA,EACnB;AACA,QAAM,IAAI,MAAM,2CAA2C,SAAS;AACrE;AAEA,SAAS,aAAa,SAAsB,MAAc,OAAe;AACxE,MAAI,QAAQ,aAAa,IAAI,MAAM,MAAO;AAC1C,UAAQ,aAAa,MAAM,KAAK;AACjC;",
6
+ "names": ["mainItems", "overflowItems", "didShowAnyInOverflow", "classNames"]
7
7
  }
@@ -115,7 +115,7 @@ const TldrawUiButtonPicker = (0, import_react.memo)(function TldrawUiButtonPicke
115
115
  "data-state": value.type === "shared" && value.value === item.value ? "on" : "off",
116
116
  "data-isactive": value.type === "shared" && value.value === item.value,
117
117
  title: label,
118
- style: style === import_editor.DefaultColorStyle ? { color: theme[item.value].solid } : void 0,
118
+ style: style === import_editor.DefaultColorStyle ? { color: (0, import_editor.getColorValue)(theme, item.value, "solid") } : void 0,
119
119
  onPointerEnter: handleButtonPointerEnter,
120
120
  onPointerDown: handleButtonPointerDown,
121
121
  onPointerUp: handleButtonPointerUp,