tldraw 3.16.0-canary.5170ef6b6e20 → 3.16.0-canary.54408756ac9c

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 (118) hide show
  1. package/dist-cjs/index.d.ts +131 -100
  2. package/dist-cjs/index.js +25 -14
  3. package/dist-cjs/index.js.map +2 -2
  4. package/dist-cjs/lib/shapes/arrow/arrowLabel.js +6 -0
  5. package/dist-cjs/lib/shapes/arrow/arrowLabel.js.map +3 -3
  6. package/dist-cjs/lib/shapes/shared/PlainTextLabel.js +1 -3
  7. package/dist-cjs/lib/shapes/shared/PlainTextLabel.js.map +2 -2
  8. package/dist-cjs/lib/shapes/shared/useEditablePlainText.js +0 -2
  9. package/dist-cjs/lib/shapes/shared/useEditablePlainText.js.map +2 -2
  10. package/dist-cjs/lib/shapes/shared/useImageOrVideoAsset.js +0 -2
  11. package/dist-cjs/lib/shapes/shared/useImageOrVideoAsset.js.map +2 -2
  12. package/dist-cjs/lib/ui/components/StylePanel/DefaultStylePanel.js +9 -4
  13. package/dist-cjs/lib/ui/components/StylePanel/DefaultStylePanel.js.map +2 -2
  14. package/dist-cjs/lib/ui/components/StylePanel/DefaultStylePanelContent.js +255 -316
  15. package/dist-cjs/lib/ui/components/StylePanel/DefaultStylePanelContent.js.map +2 -2
  16. package/dist-cjs/lib/ui/components/{primitives/TldrawUiButtonPicker.js → StylePanel/StylePanelButtonPicker.js} +52 -45
  17. package/dist-cjs/lib/ui/components/StylePanel/StylePanelButtonPicker.js.map +7 -0
  18. package/dist-cjs/lib/ui/components/StylePanel/StylePanelContext.js +68 -0
  19. package/dist-cjs/lib/ui/components/StylePanel/StylePanelContext.js.map +7 -0
  20. package/dist-cjs/lib/ui/components/StylePanel/{DoubleDropdownPicker.js → StylePanelDoubleDropdownPicker.js} +23 -22
  21. package/dist-cjs/lib/ui/components/StylePanel/StylePanelDoubleDropdownPicker.js.map +7 -0
  22. package/dist-cjs/lib/ui/components/StylePanel/{DropdownPicker.js → StylePanelDropdownPicker.js} +23 -20
  23. package/dist-cjs/lib/ui/components/StylePanel/StylePanelDropdownPicker.js.map +7 -0
  24. package/dist-cjs/lib/ui/components/StylePanel/StylePanelSubheading.js +28 -0
  25. package/dist-cjs/lib/ui/components/StylePanel/StylePanelSubheading.js.map +7 -0
  26. package/dist-cjs/lib/ui/components/primitives/TldrawUiToolbar.js +2 -0
  27. package/dist-cjs/lib/ui/components/primitives/TldrawUiToolbar.js.map +2 -2
  28. package/dist-cjs/lib/ui/components/primitives/TldrawUiTooltip.js +7 -4
  29. package/dist-cjs/lib/ui/components/primitives/TldrawUiTooltip.js.map +2 -2
  30. package/dist-cjs/lib/ui/context/actions.js +7 -8
  31. package/dist-cjs/lib/ui/context/actions.js.map +2 -2
  32. package/dist-cjs/lib/ui/hooks/useExportAs.js +3 -2
  33. package/dist-cjs/lib/ui/hooks/useExportAs.js.map +2 -2
  34. package/dist-cjs/lib/ui/hooks/useTools.js +1 -1
  35. package/dist-cjs/lib/ui/hooks/useTools.js.map +2 -2
  36. package/dist-cjs/lib/ui/version.js +3 -3
  37. package/dist-cjs/lib/ui/version.js.map +1 -1
  38. package/dist-cjs/lib/utils/export/copyAs.js +1 -2
  39. package/dist-cjs/lib/utils/export/copyAs.js.map +2 -2
  40. package/dist-cjs/lib/utils/export/export.js +0 -20
  41. package/dist-cjs/lib/utils/export/export.js.map +2 -2
  42. package/dist-cjs/lib/utils/export/exportAs.js +1 -2
  43. package/dist-cjs/lib/utils/export/exportAs.js.map +2 -2
  44. package/dist-esm/index.d.mts +131 -100
  45. package/dist-esm/index.mjs +51 -28
  46. package/dist-esm/index.mjs.map +2 -2
  47. package/dist-esm/lib/shapes/arrow/arrowLabel.mjs +6 -0
  48. package/dist-esm/lib/shapes/arrow/arrowLabel.mjs.map +3 -3
  49. package/dist-esm/lib/shapes/shared/PlainTextLabel.mjs +1 -3
  50. package/dist-esm/lib/shapes/shared/PlainTextLabel.mjs.map +2 -2
  51. package/dist-esm/lib/shapes/shared/useEditablePlainText.mjs +0 -2
  52. package/dist-esm/lib/shapes/shared/useEditablePlainText.mjs.map +2 -2
  53. package/dist-esm/lib/shapes/shared/useImageOrVideoAsset.mjs +0 -2
  54. package/dist-esm/lib/shapes/shared/useImageOrVideoAsset.mjs.map +2 -2
  55. package/dist-esm/lib/ui/components/StylePanel/DefaultStylePanel.mjs +14 -5
  56. package/dist-esm/lib/ui/components/StylePanel/DefaultStylePanel.mjs.map +2 -2
  57. package/dist-esm/lib/ui/components/StylePanel/DefaultStylePanelContent.mjs +257 -320
  58. package/dist-esm/lib/ui/components/StylePanel/DefaultStylePanelContent.mjs.map +2 -2
  59. package/dist-esm/lib/ui/components/{primitives/TldrawUiButtonPicker.mjs → StylePanel/StylePanelButtonPicker.mjs} +54 -43
  60. package/dist-esm/lib/ui/components/StylePanel/StylePanelButtonPicker.mjs.map +7 -0
  61. package/dist-esm/lib/ui/components/StylePanel/StylePanelContext.mjs +48 -0
  62. package/dist-esm/lib/ui/components/StylePanel/StylePanelContext.mjs.map +7 -0
  63. package/dist-esm/lib/ui/components/StylePanel/{DoubleDropdownPicker.mjs → StylePanelDoubleDropdownPicker.mjs} +20 -19
  64. package/dist-esm/lib/ui/components/StylePanel/StylePanelDoubleDropdownPicker.mjs.map +7 -0
  65. package/dist-esm/lib/ui/components/StylePanel/{DropdownPicker.mjs → StylePanelDropdownPicker.mjs} +20 -17
  66. package/dist-esm/lib/ui/components/StylePanel/StylePanelDropdownPicker.mjs.map +7 -0
  67. package/dist-esm/lib/ui/components/StylePanel/StylePanelSubheading.mjs +8 -0
  68. package/dist-esm/lib/ui/components/StylePanel/StylePanelSubheading.mjs.map +7 -0
  69. package/dist-esm/lib/ui/components/primitives/TldrawUiToolbar.mjs +2 -0
  70. package/dist-esm/lib/ui/components/primitives/TldrawUiToolbar.mjs.map +2 -2
  71. package/dist-esm/lib/ui/components/primitives/TldrawUiTooltip.mjs +7 -4
  72. package/dist-esm/lib/ui/components/primitives/TldrawUiTooltip.mjs.map +2 -2
  73. package/dist-esm/lib/ui/context/actions.mjs +7 -8
  74. package/dist-esm/lib/ui/context/actions.mjs.map +2 -2
  75. package/dist-esm/lib/ui/hooks/useExportAs.mjs +3 -2
  76. package/dist-esm/lib/ui/hooks/useExportAs.mjs.map +2 -2
  77. package/dist-esm/lib/ui/hooks/useTools.mjs +1 -1
  78. package/dist-esm/lib/ui/hooks/useTools.mjs.map +2 -2
  79. package/dist-esm/lib/ui/version.mjs +3 -3
  80. package/dist-esm/lib/ui/version.mjs.map +1 -1
  81. package/dist-esm/lib/utils/export/copyAs.mjs +1 -2
  82. package/dist-esm/lib/utils/export/copyAs.mjs.map +2 -2
  83. package/dist-esm/lib/utils/export/export.mjs +0 -20
  84. package/dist-esm/lib/utils/export/export.mjs.map +2 -2
  85. package/dist-esm/lib/utils/export/exportAs.mjs +1 -2
  86. package/dist-esm/lib/utils/export/exportAs.mjs.map +2 -2
  87. package/package.json +3 -3
  88. package/src/index.ts +38 -21
  89. package/src/lib/shapes/arrow/arrowLabel.ts +8 -0
  90. package/src/lib/shapes/shared/PlainTextLabel.tsx +0 -6
  91. package/src/lib/shapes/shared/useEditablePlainText.ts +0 -6
  92. package/src/lib/shapes/shared/useImageOrVideoAsset.ts +0 -7
  93. package/src/lib/ui/components/StylePanel/DefaultStylePanel.tsx +27 -13
  94. package/src/lib/ui/components/StylePanel/DefaultStylePanelContent.tsx +260 -381
  95. package/src/lib/ui/components/{primitives/TldrawUiButtonPicker.tsx → StylePanel/StylePanelButtonPicker.tsx} +63 -50
  96. package/src/lib/ui/components/StylePanel/StylePanelContext.tsx +63 -0
  97. package/src/lib/ui/components/StylePanel/{DoubleDropdownPicker.tsx → StylePanelDoubleDropdownPicker.tsx} +28 -19
  98. package/src/lib/ui/components/StylePanel/StylePanelDropdownPicker.tsx +119 -0
  99. package/src/lib/ui/components/StylePanel/StylePanelSubheading.tsx +9 -0
  100. package/src/lib/ui/components/primitives/TldrawUiToolbar.tsx +3 -0
  101. package/src/lib/ui/components/primitives/TldrawUiTooltip.tsx +10 -6
  102. package/src/lib/ui/context/actions.tsx +7 -8
  103. package/src/lib/ui/hooks/useExportAs.ts +3 -2
  104. package/src/lib/ui/hooks/useTools.tsx +1 -1
  105. package/src/lib/ui/version.ts +3 -3
  106. package/src/lib/ui.css +16 -2
  107. package/src/lib/utils/export/copyAs.ts +1 -24
  108. package/src/lib/utils/export/export.ts +0 -36
  109. package/src/lib/utils/export/exportAs.ts +1 -32
  110. package/src/test/getCulledShapes.test.tsx +71 -2
  111. package/tldraw.css +24 -5
  112. package/dist-cjs/lib/ui/components/StylePanel/DoubleDropdownPicker.js.map +0 -7
  113. package/dist-cjs/lib/ui/components/StylePanel/DropdownPicker.js.map +0 -7
  114. package/dist-cjs/lib/ui/components/primitives/TldrawUiButtonPicker.js.map +0 -7
  115. package/dist-esm/lib/ui/components/StylePanel/DoubleDropdownPicker.mjs.map +0 -7
  116. package/dist-esm/lib/ui/components/StylePanel/DropdownPicker.mjs.map +0 -7
  117. package/dist-esm/lib/ui/components/primitives/TldrawUiButtonPicker.mjs.map +0 -7
  118. package/src/lib/ui/components/StylePanel/DropdownPicker.tsx +0 -110
@@ -28,14 +28,20 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
29
  var DefaultStylePanelContent_exports = {};
30
30
  __export(DefaultStylePanelContent_exports, {
31
- ArrowStylePickerSet: () => ArrowStylePickerSet,
32
- ArrowheadStylePickerSet: () => ArrowheadStylePickerSet,
33
- CommonStylePickerSet: () => CommonStylePickerSet,
34
31
  DefaultStylePanelContent: () => DefaultStylePanelContent,
35
- GeoStylePickerSet: () => GeoStylePickerSet,
36
- OpacitySlider: () => OpacitySlider,
37
- SplineStylePickerSet: () => SplineStylePickerSet,
38
- TextStylePickerSet: () => TextStylePickerSet
32
+ StylePanelArrowKindPicker: () => StylePanelArrowKindPicker,
33
+ StylePanelArrowheadPicker: () => StylePanelArrowheadPicker,
34
+ StylePanelColorPicker: () => StylePanelColorPicker,
35
+ StylePanelDashPicker: () => StylePanelDashPicker,
36
+ StylePanelFillPicker: () => StylePanelFillPicker,
37
+ StylePanelFontPicker: () => StylePanelFontPicker,
38
+ StylePanelGeoShapePicker: () => StylePanelGeoShapePicker,
39
+ StylePanelLabelAlignPicker: () => StylePanelLabelAlignPicker,
40
+ StylePanelOpacityPicker: () => StylePanelOpacityPicker,
41
+ StylePanelSection: () => StylePanelSection,
42
+ StylePanelSizePicker: () => StylePanelSizePicker,
43
+ StylePanelSplinePicker: () => StylePanelSplinePicker,
44
+ StylePanelTextAlignPicker: () => StylePanelTextAlignPicker
39
45
  });
40
46
  module.exports = __toCommonJS(DefaultStylePanelContent_exports);
41
47
  var import_jsx_runtime = require("react/jsx-runtime");
@@ -45,300 +51,265 @@ var import_styles = require("../../../styles");
45
51
  var import_events = require("../../context/events");
46
52
  var import_useTranslation = require("../../hooks/useTranslation/useTranslation");
47
53
  var import_TldrawUiButtonIcon = require("../primitives/Button/TldrawUiButtonIcon");
48
- var import_TldrawUiButtonPicker = require("../primitives/TldrawUiButtonPicker");
49
54
  var import_TldrawUiSlider = require("../primitives/TldrawUiSlider");
50
55
  var import_TldrawUiToolbar = require("../primitives/TldrawUiToolbar");
51
- var import_DoubleDropdownPicker = require("./DoubleDropdownPicker");
52
- var import_DropdownPicker = require("./DropdownPicker");
53
- function StylePanelSubheading({ children }) {
54
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", { className: "tlui-style-panel__subheading", children });
55
- }
56
- function DefaultStylePanelContent({ styles }) {
57
- const isDarkMode = (0, import_editor.useIsDarkMode)();
58
- if (!styles) return null;
59
- const geo = styles.get(import_editor.GeoShapeGeoStyle);
60
- const arrowheadEnd = styles.get(import_editor.ArrowShapeArrowheadEndStyle);
61
- const arrowheadStart = styles.get(import_editor.ArrowShapeArrowheadStartStyle);
62
- const arrowKind = styles.get(import_editor.ArrowShapeKindStyle);
63
- const spline = styles.get(import_editor.LineShapeSplineStyle);
64
- const font = styles.get(import_editor.DefaultFontStyle);
65
- const hideGeo = geo === void 0;
66
- const hideArrowHeads = arrowheadEnd === void 0 && arrowheadStart === void 0;
67
- const hideSpline = spline === void 0;
68
- const hideArrowKind = arrowKind === void 0;
69
- const hideText = font === void 0;
70
- const theme = (0, import_editor.getDefaultColorTheme)({ isDarkMode });
56
+ var import_StylePanelButtonPicker = require("./StylePanelButtonPicker");
57
+ var import_StylePanelContext = require("./StylePanelContext");
58
+ var import_StylePanelDoubleDropdownPicker = require("./StylePanelDoubleDropdownPicker");
59
+ var import_StylePanelDropdownPicker = require("./StylePanelDropdownPicker");
60
+ var import_StylePanelSubheading = require("./StylePanelSubheading");
61
+ function DefaultStylePanelContent() {
71
62
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
72
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CommonStylePickerSet, { theme, styles }),
73
- !hideText && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TextStylePickerSet, { theme, styles }),
74
- !(hideGeo && hideArrowHeads && hideSpline && hideArrowKind) && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "tlui-style-panel__section", children: [
75
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(GeoStylePickerSet, { styles }),
76
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ArrowStylePickerSet, { styles }),
77
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ArrowheadStylePickerSet, { styles }),
78
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SplineStylePickerSet, { styles })
63
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(StylePanelSection, { children: [
64
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StylePanelColorPicker, {}),
65
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StylePanelOpacityPicker, {})
66
+ ] }),
67
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(StylePanelSection, { children: [
68
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StylePanelFillPicker, {}),
69
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StylePanelDashPicker, {}),
70
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StylePanelSizePicker, {})
71
+ ] }),
72
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(StylePanelSection, { children: [
73
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StylePanelFontPicker, {}),
74
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StylePanelTextAlignPicker, {}),
75
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StylePanelLabelAlignPicker, {})
76
+ ] }),
77
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(StylePanelSection, { children: [
78
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StylePanelGeoShapePicker, {}),
79
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StylePanelArrowKindPicker, {}),
80
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StylePanelArrowheadPicker, {}),
81
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StylePanelSplinePicker, {})
79
82
  ] })
80
83
  ] });
81
84
  }
82
- function useStyleChangeCallback() {
85
+ function StylePanelSection({ children }) {
86
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "tlui-style-panel__section", children });
87
+ }
88
+ function StylePanelColorPicker() {
89
+ const { styles } = (0, import_StylePanelContext.useStylePanelContext)();
90
+ const msg = (0, import_useTranslation.useTranslation)();
91
+ const color = styles.get(import_editor.DefaultColorStyle);
92
+ if (color === void 0) return null;
93
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
94
+ import_StylePanelButtonPicker.StylePanelButtonPicker,
95
+ {
96
+ title: msg("style-panel.color"),
97
+ uiType: "color",
98
+ style: import_editor.DefaultColorStyle,
99
+ items: import_styles.STYLES.color,
100
+ value: color
101
+ }
102
+ );
103
+ }
104
+ const tldrawSupportedOpacities = [0.1, 0.25, 0.5, 0.75, 1];
105
+ function StylePanelOpacityPicker() {
83
106
  const editor = (0, import_editor.useEditor)();
107
+ const { onHistoryMark, showUiLabels } = (0, import_StylePanelContext.useStylePanelContext)();
108
+ const opacity = (0, import_editor.useValue)("opacity", () => editor.getSharedOpacity(), [editor]);
84
109
  const trackEvent = (0, import_events.useUiEvents)();
85
- return import_react.default.useMemo(
86
- () => function handleStyleChange(style, value) {
110
+ const msg = (0, import_useTranslation.useTranslation)();
111
+ const handleOpacityValueChange = import_react.default.useCallback(
112
+ (value) => {
113
+ const item = tldrawSupportedOpacities[value];
87
114
  editor.run(() => {
88
115
  if (editor.isIn("select")) {
89
- editor.setStyleForSelectedShapes(style, value);
116
+ editor.setOpacityForSelectedShapes(item);
90
117
  }
91
- editor.setStyleForNextShapes(style, value);
118
+ editor.setOpacityForNextShapes(item);
92
119
  editor.updateInstanceState({ isChangingStyle: true });
93
120
  });
94
- trackEvent("set-style", { source: "style-panel", id: style.id, value });
121
+ trackEvent("set-style", { source: "style-panel", id: "opacity", value });
95
122
  },
96
123
  [editor, trackEvent]
97
124
  );
125
+ if (opacity === void 0) return null;
126
+ const opacityIndex = opacity.type === "mixed" ? -1 : tldrawSupportedOpacities.indexOf(
127
+ (0, import_editor.minBy)(
128
+ tldrawSupportedOpacities,
129
+ (supportedOpacity) => Math.abs(supportedOpacity - opacity.value)
130
+ )
131
+ );
132
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
133
+ showUiLabels && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_StylePanelSubheading.StylePanelSubheading, { children: msg("style-panel.opacity") }),
134
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
135
+ import_TldrawUiSlider.TldrawUiSlider,
136
+ {
137
+ "data-testid": "style.opacity",
138
+ value: opacityIndex >= 0 ? opacityIndex : tldrawSupportedOpacities.length - 1,
139
+ label: opacity.type === "mixed" ? "style-panel.mixed" : `opacity-style.${opacity.value}`,
140
+ onValueChange: handleOpacityValueChange,
141
+ steps: tldrawSupportedOpacities.length - 1,
142
+ title: msg("style-panel.opacity"),
143
+ onHistoryMark,
144
+ ariaValueModifier: 25
145
+ }
146
+ )
147
+ ] });
98
148
  }
99
- function CommonStylePickerSet({ styles, theme }) {
149
+ function StylePanelFillPicker() {
150
+ const { styles } = (0, import_StylePanelContext.useStylePanelContext)();
100
151
  const msg = (0, import_useTranslation.useTranslation)();
101
- const editor = (0, import_editor.useEditor)();
102
- const onHistoryMark = (0, import_react.useCallback)((id) => editor.markHistoryStoppingPoint(id), [editor]);
103
- const showUiLabels = (0, import_editor.useValue)("showUiLabels", () => editor.user.getShowUiLabels(), [editor]);
104
- const handleValueChange = useStyleChangeCallback();
105
- const color = styles.get(import_editor.DefaultColorStyle);
106
152
  const fill = styles.get(import_editor.DefaultFillStyle);
153
+ if (fill === void 0) return null;
154
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
155
+ import_StylePanelButtonPicker.StylePanelButtonPicker,
156
+ {
157
+ title: msg("style-panel.fill"),
158
+ uiType: "fill",
159
+ style: import_editor.DefaultFillStyle,
160
+ items: import_styles.STYLES.fill,
161
+ value: fill
162
+ }
163
+ );
164
+ }
165
+ function StylePanelDashPicker() {
166
+ const { styles } = (0, import_StylePanelContext.useStylePanelContext)();
167
+ const msg = (0, import_useTranslation.useTranslation)();
107
168
  const dash = styles.get(import_editor.DefaultDashStyle);
169
+ if (dash === void 0) return null;
170
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
171
+ import_StylePanelButtonPicker.StylePanelButtonPicker,
172
+ {
173
+ title: msg("style-panel.dash"),
174
+ uiType: "dash",
175
+ style: import_editor.DefaultDashStyle,
176
+ items: import_styles.STYLES.dash,
177
+ value: dash
178
+ }
179
+ );
180
+ }
181
+ function StylePanelSizePicker() {
182
+ const editor = (0, import_editor.useEditor)();
183
+ const { styles, onValueChange } = (0, import_StylePanelContext.useStylePanelContext)();
184
+ const msg = (0, import_useTranslation.useTranslation)();
108
185
  const size = styles.get(import_editor.DefaultSizeStyle);
109
- const showPickers = fill !== void 0 || dash !== void 0 || size !== void 0;
110
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
111
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "tlui-style-panel__section__common", "data-testid": "style.panel", children: [
112
- color === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
113
- showUiLabels && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StylePanelSubheading, { children: msg("style-panel.color") }),
114
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_TldrawUiToolbar.TldrawUiToolbar, { orientation: "horizontal", label: msg("style-panel.color"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
115
- import_TldrawUiButtonPicker.TldrawUiButtonPicker,
116
- {
117
- title: msg("style-panel.color"),
118
- uiType: "color",
119
- style: import_editor.DefaultColorStyle,
120
- items: import_styles.STYLES.color,
121
- value: color,
122
- onValueChange: handleValueChange,
123
- theme,
124
- onHistoryMark
125
- }
126
- ) })
127
- ] }),
128
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(OpacitySlider, {})
129
- ] }),
130
- showPickers && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "tlui-style-panel__section", children: [
131
- fill === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
132
- showUiLabels && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StylePanelSubheading, { children: msg("style-panel.fill") }),
133
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_TldrawUiToolbar.TldrawUiToolbar, { orientation: "horizontal", label: msg("style-panel.fill"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
134
- import_TldrawUiButtonPicker.TldrawUiButtonPicker,
135
- {
136
- title: msg("style-panel.fill"),
137
- uiType: "fill",
138
- style: import_editor.DefaultFillStyle,
139
- items: import_styles.STYLES.fill,
140
- value: fill,
141
- onValueChange: handleValueChange,
142
- theme,
143
- onHistoryMark
144
- }
145
- ) })
146
- ] }),
147
- dash === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
148
- showUiLabels && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StylePanelSubheading, { children: msg("style-panel.dash") }),
149
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_TldrawUiToolbar.TldrawUiToolbar, { orientation: "horizontal", label: msg("style-panel.dash"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
150
- import_TldrawUiButtonPicker.TldrawUiButtonPicker,
151
- {
152
- title: msg("style-panel.dash"),
153
- uiType: "dash",
154
- style: import_editor.DefaultDashStyle,
155
- items: import_styles.STYLES.dash,
156
- value: dash,
157
- onValueChange: handleValueChange,
158
- theme,
159
- onHistoryMark
160
- }
161
- ) })
162
- ] }),
163
- size === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
164
- showUiLabels && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StylePanelSubheading, { children: msg("style-panel.size") }),
165
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_TldrawUiToolbar.TldrawUiToolbar, { orientation: "horizontal", label: msg("style-panel.size"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
166
- import_TldrawUiButtonPicker.TldrawUiButtonPicker,
167
- {
168
- title: msg("style-panel.size"),
169
- uiType: "size",
170
- style: import_editor.DefaultSizeStyle,
171
- items: import_styles.STYLES.size,
172
- value: size,
173
- onValueChange: (style, value) => {
174
- handleValueChange(style, value);
175
- const selectedShapeIds = editor.getSelectedShapeIds();
176
- if (selectedShapeIds.length > 0) {
177
- (0, import_editor.kickoutOccludedShapes)(editor, selectedShapeIds);
178
- }
179
- },
180
- theme,
181
- onHistoryMark
182
- }
183
- ) })
184
- ] })
185
- ] })
186
- ] });
186
+ if (size === void 0) return null;
187
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
188
+ import_StylePanelButtonPicker.StylePanelButtonPicker,
189
+ {
190
+ title: msg("style-panel.size"),
191
+ uiType: "size",
192
+ style: import_editor.DefaultSizeStyle,
193
+ items: import_styles.STYLES.size,
194
+ value: size,
195
+ onValueChange: (style, value) => {
196
+ onValueChange(style, value);
197
+ const selectedShapeIds = editor.getSelectedShapeIds();
198
+ if (selectedShapeIds.length > 0) {
199
+ (0, import_editor.kickoutOccludedShapes)(editor, selectedShapeIds);
200
+ }
201
+ }
202
+ }
203
+ );
187
204
  }
188
- function TextStylePickerSet({ theme, styles }) {
205
+ function StylePanelFontPicker() {
206
+ const { styles } = (0, import_StylePanelContext.useStylePanelContext)();
189
207
  const msg = (0, import_useTranslation.useTranslation)();
190
- const handleValueChange = useStyleChangeCallback();
191
- const editor = (0, import_editor.useEditor)();
192
- const onHistoryMark = (0, import_react.useCallback)((id) => editor.markHistoryStoppingPoint(id), [editor]);
193
- const showUiLabels = (0, import_editor.useValue)("showUiLabels", () => editor.user.getShowUiLabels(), [editor]);
194
- const labelStr = showUiLabels && msg("style-panel.font");
195
208
  const font = styles.get(import_editor.DefaultFontStyle);
209
+ if (font === void 0) return null;
210
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
211
+ import_StylePanelButtonPicker.StylePanelButtonPicker,
212
+ {
213
+ title: msg("style-panel.font"),
214
+ uiType: "font",
215
+ style: import_editor.DefaultFontStyle,
216
+ items: import_styles.STYLES.font,
217
+ value: font
218
+ }
219
+ );
220
+ }
221
+ function StylePanelTextAlignPicker() {
222
+ const { styles } = (0, import_StylePanelContext.useStylePanelContext)();
223
+ const msg = (0, import_useTranslation.useTranslation)();
196
224
  const textAlign = styles.get(import_editor.DefaultTextAlignStyle);
225
+ if (textAlign === void 0) return null;
226
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_TldrawUiToolbar.TldrawUiToolbar, { orientation: "horizontal", label: msg("style-panel.align"), children: [
227
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
228
+ import_StylePanelButtonPicker.StylePanelButtonPicker,
229
+ {
230
+ title: msg("style-panel.align"),
231
+ uiType: "align",
232
+ style: import_editor.DefaultTextAlignStyle,
233
+ items: import_styles.STYLES.textAlign,
234
+ value: textAlign
235
+ }
236
+ ),
237
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
238
+ import_TldrawUiToolbar.TldrawUiToolbarButton,
239
+ {
240
+ type: "icon",
241
+ title: msg("style-panel.vertical-align"),
242
+ "data-testid": "vertical-align",
243
+ disabled: true,
244
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_TldrawUiButtonIcon.TldrawUiButtonIcon, { icon: "vertical-align-middle" })
245
+ }
246
+ )
247
+ ] });
248
+ }
249
+ function StylePanelLabelAlignPicker() {
250
+ const { styles } = (0, import_StylePanelContext.useStylePanelContext)();
251
+ const msg = (0, import_useTranslation.useTranslation)();
197
252
  const labelAlign = styles.get(import_editor.DefaultHorizontalAlignStyle);
198
253
  const verticalLabelAlign = styles.get(import_editor.DefaultVerticalAlignStyle);
199
- if (font === void 0 && labelAlign === void 0) {
200
- return null;
201
- }
202
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "tlui-style-panel__section", children: [
203
- font === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
204
- labelStr && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StylePanelSubheading, { children: labelStr }),
205
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_TldrawUiToolbar.TldrawUiToolbar, { orientation: "horizontal", label: msg("style-panel.font"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
206
- import_TldrawUiButtonPicker.TldrawUiButtonPicker,
207
- {
208
- title: msg("style-panel.font"),
209
- uiType: "font",
210
- style: import_editor.DefaultFontStyle,
211
- items: import_styles.STYLES.font,
212
- value: font,
213
- onValueChange: handleValueChange,
214
- theme,
215
- onHistoryMark
216
- }
217
- ) })
218
- ] }),
219
- textAlign === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
220
- showUiLabels && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StylePanelSubheading, { children: msg("style-panel.align") }),
221
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_TldrawUiToolbar.TldrawUiToolbar, { orientation: "horizontal", label: msg("style-panel.align"), children: [
222
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
223
- import_TldrawUiButtonPicker.TldrawUiButtonPicker,
224
- {
225
- title: msg("style-panel.align"),
226
- uiType: "align",
227
- style: import_editor.DefaultTextAlignStyle,
228
- items: import_styles.STYLES.textAlign,
229
- value: textAlign,
230
- onValueChange: handleValueChange,
231
- theme,
232
- onHistoryMark
233
- }
234
- ),
235
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
236
- import_TldrawUiToolbar.TldrawUiToolbarButton,
237
- {
238
- type: "icon",
239
- title: msg("style-panel.vertical-align"),
240
- "data-testid": "vertical-align",
241
- disabled: true,
242
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_TldrawUiButtonIcon.TldrawUiButtonIcon, { icon: "vertical-align-middle" })
243
- }
244
- )
245
- ] })
246
- ] }),
247
- labelAlign === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
248
- showUiLabels && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StylePanelSubheading, { children: msg("style-panel.label-align") }),
249
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_TldrawUiToolbar.TldrawUiToolbar, { orientation: "horizontal", label: msg("style-panel.label-align"), children: [
250
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
251
- import_TldrawUiButtonPicker.TldrawUiButtonPicker,
252
- {
253
- title: msg("style-panel.label-align"),
254
- uiType: "align",
255
- style: import_editor.DefaultHorizontalAlignStyle,
256
- items: import_styles.STYLES.horizontalAlign,
257
- value: labelAlign,
258
- onValueChange: handleValueChange,
259
- theme,
260
- onHistoryMark
261
- }
262
- ),
263
- verticalLabelAlign === void 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
264
- import_TldrawUiToolbar.TldrawUiToolbarButton,
265
- {
266
- type: "icon",
267
- title: msg("style-panel.vertical-align"),
268
- "data-testid": "vertical-align",
269
- disabled: true,
270
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_TldrawUiButtonIcon.TldrawUiButtonIcon, { icon: "vertical-align-middle" })
271
- }
272
- ) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
273
- import_DropdownPicker.DropdownPicker,
274
- {
275
- type: "icon",
276
- id: "geo-vertical-alignment",
277
- uiType: "verticalAlign",
278
- stylePanelType: "vertical-align",
279
- style: import_editor.DefaultVerticalAlignStyle,
280
- items: import_styles.STYLES.verticalAlign,
281
- value: verticalLabelAlign,
282
- onValueChange: handleValueChange
283
- }
284
- )
285
- ] })
286
- ] })
254
+ if (labelAlign === void 0) return null;
255
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_TldrawUiToolbar.TldrawUiToolbar, { orientation: "horizontal", label: msg("style-panel.label-align"), children: [
256
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
257
+ import_StylePanelButtonPicker.StylePanelButtonPicker,
258
+ {
259
+ title: msg("style-panel.label-align"),
260
+ uiType: "align",
261
+ style: import_editor.DefaultHorizontalAlignStyle,
262
+ items: import_styles.STYLES.horizontalAlign,
263
+ value: labelAlign
264
+ }
265
+ ),
266
+ verticalLabelAlign === void 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
267
+ import_TldrawUiToolbar.TldrawUiToolbarButton,
268
+ {
269
+ type: "icon",
270
+ title: msg("style-panel.vertical-align"),
271
+ "data-testid": "vertical-align",
272
+ disabled: true,
273
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_TldrawUiButtonIcon.TldrawUiButtonIcon, { icon: "vertical-align-middle" })
274
+ }
275
+ ) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
276
+ import_StylePanelDropdownPicker.StylePanelDropdownPicker,
277
+ {
278
+ type: "icon",
279
+ id: "geo-vertical-alignment",
280
+ uiType: "verticalAlign",
281
+ stylePanelType: "vertical-align",
282
+ style: import_editor.DefaultVerticalAlignStyle,
283
+ items: import_styles.STYLES.verticalAlign,
284
+ value: verticalLabelAlign
285
+ }
286
+ )
287
287
  ] });
288
288
  }
289
- function GeoStylePickerSet({ styles }) {
290
- const msg = (0, import_useTranslation.useTranslation)();
291
- const handleValueChange = useStyleChangeCallback();
289
+ function StylePanelGeoShapePicker() {
290
+ const { styles } = (0, import_StylePanelContext.useStylePanelContext)();
292
291
  const geo = styles.get(import_editor.GeoShapeGeoStyle);
293
- if (geo === void 0) {
294
- return null;
295
- }
296
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_TldrawUiToolbar.TldrawUiToolbar, { orientation: "horizontal", label: msg("style-panel.geo"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
297
- import_DropdownPicker.DropdownPicker,
292
+ if (geo === void 0) return null;
293
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
294
+ import_StylePanelDropdownPicker.StylePanelDropdownPicker,
298
295
  {
299
- id: "geo",
300
- type: "menu",
301
296
  label: "style-panel.geo",
297
+ type: "menu",
298
+ id: "geo",
302
299
  uiType: "geo",
303
300
  stylePanelType: "geo",
304
301
  style: import_editor.GeoShapeGeoStyle,
305
302
  items: import_styles.STYLES.geo,
306
- value: geo,
307
- onValueChange: handleValueChange
303
+ value: geo
308
304
  }
309
- ) });
310
- }
311
- function SplineStylePickerSet({ styles }) {
312
- const msg = (0, import_useTranslation.useTranslation)();
313
- const handleValueChange = useStyleChangeCallback();
314
- const spline = styles.get(import_editor.LineShapeSplineStyle);
315
- if (spline === void 0) {
316
- return null;
317
- }
318
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_TldrawUiToolbar.TldrawUiToolbar, { orientation: "horizontal", label: msg("style-panel.spline"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
319
- import_DropdownPicker.DropdownPicker,
320
- {
321
- id: "spline",
322
- type: "menu",
323
- label: "style-panel.spline",
324
- uiType: "spline",
325
- stylePanelType: "spline",
326
- style: import_editor.LineShapeSplineStyle,
327
- items: import_styles.STYLES.spline,
328
- value: spline,
329
- onValueChange: handleValueChange
330
- }
331
- ) });
305
+ );
332
306
  }
333
- function ArrowStylePickerSet({ styles }) {
334
- const msg = (0, import_useTranslation.useTranslation)();
335
- const handleValueChange = useStyleChangeCallback();
307
+ function StylePanelArrowKindPicker() {
308
+ const { styles } = (0, import_StylePanelContext.useStylePanelContext)();
336
309
  const arrowKind = styles.get(import_editor.ArrowShapeKindStyle);
337
- if (arrowKind === void 0) {
338
- return null;
339
- }
340
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_TldrawUiToolbar.TldrawUiToolbar, { orientation: "horizontal", label: msg("style-panel.arrow-kind"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
341
- import_DropdownPicker.DropdownPicker,
310
+ if (arrowKind === void 0) return null;
311
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
312
+ import_StylePanelDropdownPicker.StylePanelDropdownPicker,
342
313
  {
343
314
  id: "arrow-kind",
344
315
  type: "menu",
@@ -347,20 +318,17 @@ function ArrowStylePickerSet({ styles }) {
347
318
  stylePanelType: "arrow-kind",
348
319
  style: import_editor.ArrowShapeKindStyle,
349
320
  items: import_styles.STYLES.arrowKind,
350
- value: arrowKind,
351
- onValueChange: handleValueChange
321
+ value: arrowKind
352
322
  }
353
- ) });
323
+ );
354
324
  }
355
- function ArrowheadStylePickerSet({ styles }) {
356
- const handleValueChange = useStyleChangeCallback();
325
+ function StylePanelArrowheadPicker() {
326
+ const { styles } = (0, import_StylePanelContext.useStylePanelContext)();
357
327
  const arrowheadEnd = styles.get(import_editor.ArrowShapeArrowheadEndStyle);
358
328
  const arrowheadStart = styles.get(import_editor.ArrowShapeArrowheadStartStyle);
359
- if (!arrowheadEnd || !arrowheadStart) {
360
- return null;
361
- }
329
+ if (arrowheadEnd === void 0 || arrowheadStart === void 0) return null;
362
330
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
363
- import_DoubleDropdownPicker.DoubleDropdownPicker,
331
+ import_StylePanelDoubleDropdownPicker.StylePanelDoubleDropdownPicker,
364
332
  {
365
333
  label: "style-panel.arrowheads",
366
334
  uiTypeA: "arrowheadStart",
@@ -371,56 +339,27 @@ function ArrowheadStylePickerSet({ styles }) {
371
339
  styleB: import_editor.ArrowShapeArrowheadEndStyle,
372
340
  itemsB: import_styles.STYLES.arrowheadEnd,
373
341
  valueB: arrowheadEnd,
374
- onValueChange: handleValueChange,
375
342
  labelA: "style-panel.arrowhead-start",
376
343
  labelB: "style-panel.arrowhead-end"
377
344
  }
378
345
  );
379
346
  }
380
- const tldrawSupportedOpacities = [0.1, 0.25, 0.5, 0.75, 1];
381
- function OpacitySlider() {
382
- const editor = (0, import_editor.useEditor)();
383
- const onHistoryMark = (0, import_react.useCallback)((id) => editor.markHistoryStoppingPoint(id), [editor]);
384
- const showUiLabels = (0, import_editor.useValue)("showUiLabels", () => editor.user.getShowUiLabels(), [editor]);
385
- const opacity = (0, import_editor.useValue)("opacity", () => editor.getSharedOpacity(), [editor]);
386
- const trackEvent = (0, import_events.useUiEvents)();
387
- const msg = (0, import_useTranslation.useTranslation)();
388
- const handleOpacityValueChange = import_react.default.useCallback(
389
- (value) => {
390
- const item = tldrawSupportedOpacities[value];
391
- editor.run(() => {
392
- if (editor.isIn("select")) {
393
- editor.setOpacityForSelectedShapes(item);
394
- }
395
- editor.setOpacityForNextShapes(item);
396
- editor.updateInstanceState({ isChangingStyle: true });
397
- });
398
- trackEvent("set-style", { source: "style-panel", id: "opacity", value });
399
- },
400
- [editor, trackEvent]
401
- );
402
- if (opacity === void 0) return null;
403
- const opacityIndex = opacity.type === "mixed" ? -1 : tldrawSupportedOpacities.indexOf(
404
- (0, import_editor.minBy)(
405
- tldrawSupportedOpacities,
406
- (supportedOpacity) => Math.abs(supportedOpacity - opacity.value)
407
- )
347
+ function StylePanelSplinePicker() {
348
+ const { styles } = (0, import_StylePanelContext.useStylePanelContext)();
349
+ const spline = styles.get(import_editor.LineShapeSplineStyle);
350
+ if (spline === void 0) return null;
351
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
352
+ import_StylePanelDropdownPicker.StylePanelDropdownPicker,
353
+ {
354
+ type: "menu",
355
+ id: "spline",
356
+ uiType: "spline",
357
+ stylePanelType: "spline",
358
+ label: "style-panel.spline",
359
+ style: import_editor.LineShapeSplineStyle,
360
+ items: import_styles.STYLES.spline,
361
+ value: spline
362
+ }
408
363
  );
409
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
410
- showUiLabels && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StylePanelSubheading, { children: msg("style-panel.opacity") }),
411
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
412
- import_TldrawUiSlider.TldrawUiSlider,
413
- {
414
- "data-testid": "style.opacity",
415
- value: opacityIndex >= 0 ? opacityIndex : tldrawSupportedOpacities.length - 1,
416
- label: opacity.type === "mixed" ? "style-panel.mixed" : `opacity-style.${opacity.value}`,
417
- onValueChange: handleOpacityValueChange,
418
- steps: tldrawSupportedOpacities.length - 1,
419
- title: msg("style-panel.opacity"),
420
- onHistoryMark,
421
- ariaValueModifier: 25
422
- }
423
- )
424
- ] });
425
364
  }
426
365
  //# sourceMappingURL=DefaultStylePanelContent.js.map