@oh-just-another/react-ui 0.57.0

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 (186) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/LICENSE +21 -0
  3. package/README.md +54 -0
  4. package/dist/.tsbuildinfo +1 -0
  5. package/dist/bottom-sheet.d.ts +26 -0
  6. package/dist/bottom-sheet.d.ts.map +1 -0
  7. package/dist/bottom-sheet.js +87 -0
  8. package/dist/bottom-sheet.js.map +1 -0
  9. package/dist/button-group.d.ts +14 -0
  10. package/dist/button-group.d.ts.map +1 -0
  11. package/dist/button-group.js +3 -0
  12. package/dist/button-group.js.map +1 -0
  13. package/dist/color-palette.d.ts +34 -0
  14. package/dist/color-palette.d.ts.map +1 -0
  15. package/dist/color-palette.js +77 -0
  16. package/dist/color-palette.js.map +1 -0
  17. package/dist/color-swatch-picker.d.ts +29 -0
  18. package/dist/color-swatch-picker.d.ts.map +1 -0
  19. package/dist/color-swatch-picker.js +56 -0
  20. package/dist/color-swatch-picker.js.map +1 -0
  21. package/dist/command-palette.d.ts +13 -0
  22. package/dist/command-palette.d.ts.map +1 -0
  23. package/dist/command-palette.js +146 -0
  24. package/dist/command-palette.js.map +1 -0
  25. package/dist/comments-panel.d.ts +27 -0
  26. package/dist/comments-panel.d.ts.map +1 -0
  27. package/dist/comments-panel.js +139 -0
  28. package/dist/comments-panel.js.map +1 -0
  29. package/dist/constants.d.ts +112 -0
  30. package/dist/constants.d.ts.map +1 -0
  31. package/dist/constants.js +119 -0
  32. package/dist/constants.js.map +1 -0
  33. package/dist/context-menu-controller.d.ts +41 -0
  34. package/dist/context-menu-controller.d.ts.map +1 -0
  35. package/dist/context-menu-controller.js +26 -0
  36. package/dist/context-menu-controller.js.map +1 -0
  37. package/dist/context-menu.d.ts +53 -0
  38. package/dist/context-menu.d.ts.map +1 -0
  39. package/dist/context-menu.js +333 -0
  40. package/dist/context-menu.js.map +1 -0
  41. package/dist/context.d.ts +44 -0
  42. package/dist/context.d.ts.map +1 -0
  43. package/dist/context.js +95 -0
  44. package/dist/context.js.map +1 -0
  45. package/dist/diagram-bars.d.ts +21 -0
  46. package/dist/diagram-bars.d.ts.map +1 -0
  47. package/dist/diagram-bars.js +4 -0
  48. package/dist/diagram-bars.js.map +1 -0
  49. package/dist/diagram-canvas.d.ts +39 -0
  50. package/dist/diagram-canvas.d.ts.map +1 -0
  51. package/dist/diagram-canvas.js +9 -0
  52. package/dist/diagram-canvas.js.map +1 -0
  53. package/dist/diagram-root.d.ts +70 -0
  54. package/dist/diagram-root.d.ts.map +1 -0
  55. package/dist/diagram-root.js +180 -0
  56. package/dist/diagram-root.js.map +1 -0
  57. package/dist/diff-panel.d.ts +25 -0
  58. package/dist/diff-panel.d.ts.map +1 -0
  59. package/dist/diff-panel.js +77 -0
  60. package/dist/diff-panel.js.map +1 -0
  61. package/dist/edge-style-panel.d.ts +19 -0
  62. package/dist/edge-style-panel.d.ts.map +1 -0
  63. package/dist/edge-style-panel.js +120 -0
  64. package/dist/edge-style-panel.js.map +1 -0
  65. package/dist/frame-name-editor-overlay.d.ts +13 -0
  66. package/dist/frame-name-editor-overlay.d.ts.map +1 -0
  67. package/dist/frame-name-editor-overlay.js +84 -0
  68. package/dist/frame-name-editor-overlay.js.map +1 -0
  69. package/dist/frame-panel.d.ts +19 -0
  70. package/dist/frame-panel.d.ts.map +1 -0
  71. package/dist/frame-panel.js +66 -0
  72. package/dist/frame-panel.js.map +1 -0
  73. package/dist/help-button.d.ts +16 -0
  74. package/dist/help-button.d.ts.map +1 -0
  75. package/dist/help-button.js +14 -0
  76. package/dist/help-button.js.map +1 -0
  77. package/dist/help-dialog.d.ts +56 -0
  78. package/dist/help-dialog.d.ts.map +1 -0
  79. package/dist/help-dialog.js +142 -0
  80. package/dist/help-dialog.js.map +1 -0
  81. package/dist/hooks.d.ts +54 -0
  82. package/dist/hooks.d.ts.map +1 -0
  83. package/dist/hooks.js +85 -0
  84. package/dist/hooks.js.map +1 -0
  85. package/dist/icon-button.d.ts +28 -0
  86. package/dist/icon-button.d.ts.map +1 -0
  87. package/dist/icon-button.js +14 -0
  88. package/dist/icon-button.js.map +1 -0
  89. package/dist/index.d.ts +45 -0
  90. package/dist/index.d.ts.map +1 -0
  91. package/dist/index.js +46 -0
  92. package/dist/index.js.map +1 -0
  93. package/dist/layer-panel.d.ts +13 -0
  94. package/dist/layer-panel.d.ts.map +1 -0
  95. package/dist/layer-panel.js +109 -0
  96. package/dist/layer-panel.js.map +1 -0
  97. package/dist/library-panel.d.ts +33 -0
  98. package/dist/library-panel.d.ts.map +1 -0
  99. package/dist/library-panel.js +37 -0
  100. package/dist/library-panel.js.map +1 -0
  101. package/dist/link-caption-editor.d.ts +8 -0
  102. package/dist/link-caption-editor.d.ts.map +1 -0
  103. package/dist/link-caption-editor.js +65 -0
  104. package/dist/link-caption-editor.js.map +1 -0
  105. package/dist/link-drop-shape-menu.d.ts +12 -0
  106. package/dist/link-drop-shape-menu.d.ts.map +1 -0
  107. package/dist/link-drop-shape-menu.js +55 -0
  108. package/dist/link-drop-shape-menu.js.map +1 -0
  109. package/dist/link-hover-popup.d.ts +2 -0
  110. package/dist/link-hover-popup.d.ts.map +1 -0
  111. package/dist/link-hover-popup.js +96 -0
  112. package/dist/link-hover-popup.js.map +1 -0
  113. package/dist/main-menu.d.ts +67 -0
  114. package/dist/main-menu.d.ts.map +1 -0
  115. package/dist/main-menu.js +243 -0
  116. package/dist/main-menu.js.map +1 -0
  117. package/dist/markdown.d.ts +10 -0
  118. package/dist/markdown.d.ts.map +1 -0
  119. package/dist/markdown.js +131 -0
  120. package/dist/markdown.js.map +1 -0
  121. package/dist/merge-dialog.d.ts +22 -0
  122. package/dist/merge-dialog.d.ts.map +1 -0
  123. package/dist/merge-dialog.js +46 -0
  124. package/dist/merge-dialog.js.map +1 -0
  125. package/dist/modal.d.ts +19 -0
  126. package/dist/modal.d.ts.map +1 -0
  127. package/dist/modal.js +87 -0
  128. package/dist/modal.js.map +1 -0
  129. package/dist/palette.d.ts +73 -0
  130. package/dist/palette.d.ts.map +1 -0
  131. package/dist/palette.js +330 -0
  132. package/dist/palette.js.map +1 -0
  133. package/dist/popover.d.ts +33 -0
  134. package/dist/popover.d.ts.map +1 -0
  135. package/dist/popover.js +107 -0
  136. package/dist/popover.js.map +1 -0
  137. package/dist/property-panel.d.ts +32 -0
  138. package/dist/property-panel.d.ts.map +1 -0
  139. package/dist/property-panel.js +728 -0
  140. package/dist/property-panel.js.map +1 -0
  141. package/dist/reset-to-content-button.d.ts +10 -0
  142. package/dist/reset-to-content-button.d.ts.map +1 -0
  143. package/dist/reset-to-content-button.js +62 -0
  144. package/dist/reset-to-content-button.js.map +1 -0
  145. package/dist/segmented-control.d.ts +23 -0
  146. package/dist/segmented-control.d.ts.map +1 -0
  147. package/dist/segmented-control.js +5 -0
  148. package/dist/segmented-control.js.map +1 -0
  149. package/dist/selection-floating-panel.d.ts +56 -0
  150. package/dist/selection-floating-panel.d.ts.map +1 -0
  151. package/dist/selection-floating-panel.js +251 -0
  152. package/dist/selection-floating-panel.js.map +1 -0
  153. package/dist/sidebar.d.ts +31 -0
  154. package/dist/sidebar.d.ts.map +1 -0
  155. package/dist/sidebar.js +66 -0
  156. package/dist/sidebar.js.map +1 -0
  157. package/dist/slider.d.ts +20 -0
  158. package/dist/slider.d.ts.map +1 -0
  159. package/dist/slider.js +9 -0
  160. package/dist/slider.js.map +1 -0
  161. package/dist/text-editor-overlay.d.ts +16 -0
  162. package/dist/text-editor-overlay.d.ts.map +1 -0
  163. package/dist/text-editor-overlay.js +112 -0
  164. package/dist/text-editor-overlay.js.map +1 -0
  165. package/dist/toast.d.ts +34 -0
  166. package/dist/toast.d.ts.map +1 -0
  167. package/dist/toast.js +89 -0
  168. package/dist/toast.js.map +1 -0
  169. package/dist/toolbar.d.ts +149 -0
  170. package/dist/toolbar.d.ts.map +1 -0
  171. package/dist/toolbar.js +282 -0
  172. package/dist/toolbar.js.map +1 -0
  173. package/dist/tooltip.d.ts +21 -0
  174. package/dist/tooltip.d.ts.map +1 -0
  175. package/dist/tooltip.js +217 -0
  176. package/dist/tooltip.js.map +1 -0
  177. package/dist/ui-layer.d.ts +22 -0
  178. package/dist/ui-layer.d.ts.map +1 -0
  179. package/dist/ui-layer.js +3 -0
  180. package/dist/ui-layer.js.map +1 -0
  181. package/dist/versioning.d.ts +32 -0
  182. package/dist/versioning.d.ts.map +1 -0
  183. package/dist/versioning.js +206 -0
  184. package/dist/versioning.js.map +1 -0
  185. package/package.json +81 -0
  186. package/src/styles.css +1502 -0
@@ -0,0 +1,728 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { useEffect, useRef, useState } from "react";
3
+ import { AlignCenter, AlignLeft, AlignRight, Bold, CaseSensitive, ChevronsDown, ChevronsUp, Copy as CopyIcon, Group as GroupIcon, Italic, Link as LinkIcon, Minus, MoreHorizontal, MoreVertical, MoveDown, MoveRight, MoveUp, Spline, Square, SquareDashed, SquareDot, Strikethrough, Trash2, Underline, Ungroup as UngroupIcon, Waypoints, } from "lucide-react";
4
+ import { isGroup, } from "@oh-just-another/scene";
5
+ import { useDiagramOptional, useScene, useSelectedLink, useSelection } from "./hooks.js";
6
+ import { useContextMenuController } from "./context-menu-controller.js";
7
+ import { ColorSwatchPicker } from "./color-swatch-picker.js";
8
+ import { Popover } from "./popover.js";
9
+ import { SegmentedControl } from "./segmented-control.js";
10
+ import { Slider } from "./slider.js";
11
+ import { TEXT_FONT_SIZE_MAX, TEXT_FONT_SIZE_MIN, TEXT_FONT_SIZE_PRESETS, TEXT_FONT_STACKS, } from "./constants.js";
12
+ export const PropertyPanel = ({ style, className, mobile = false }) => {
13
+ const selection = useSelection();
14
+ const selectedLinkId = useSelectedLink();
15
+ const scene = useScene();
16
+ // Dispatcher: edge wins only when no shape is selected — if both
17
+ // happen to be set (rare), the shape panel is more useful. Each branch
18
+ // splits its controls into `primary` (always visible) and `overflow`
19
+ // (behind the ⋮ on mobile; inline on desktop).
20
+ if (selection.size > 0) {
21
+ const shapes = [...selection]
22
+ .map((id) => scene.elements.get(id))
23
+ .filter((s) => s !== undefined);
24
+ if (shapes.length === 0)
25
+ return null;
26
+ const allText = shapes.every((s) => s.type === "text");
27
+ const allImage = shapes.every((s) => s.type === "image");
28
+ const allFrame = shapes.every((s) => s.type === "frame");
29
+ const primary = [];
30
+ const overflow = [];
31
+ if (allFrame) {
32
+ // A frame's border is fixed chrome (dashed outline); only its body fill
33
+ // is user-configurable. No stroke / width / dash / roundness controls.
34
+ primary.push(_jsx(FillControl, { shapes: shapes }, "fill"));
35
+ }
36
+ else if (allText) {
37
+ primary.push(_jsx(FontSizeControl, { shapes: shapes }, "size"), _jsx(ColorOpacityControl, { shapes: shapes }, "color"), _jsx(TextAlignControl, { shapes: shapes }, "align"));
38
+ overflow.push(_jsx(FontFamilyControl, { shapes: shapes }, "family"), _jsx(TextDecorationControl, { shapes: shapes }, "decor"));
39
+ }
40
+ else if (allImage) {
41
+ // An image's pixels are the content — fill/stroke make no sense.
42
+ primary.push(_jsx(OpacityControl, { shapes: shapes }, "opacity"));
43
+ }
44
+ else {
45
+ primary.push(_jsx(FillControl, { shapes: shapes }, "fill"), _jsx(StrokeControl, { shapes: shapes }, "stroke"), _jsx(StrokeWidthControl, { shapes: shapes }, "width"));
46
+ overflow.push(_jsx(StrokeStyleControl, { shapes: shapes }, "dash"), _jsx(RoundnessControl, { shapes: shapes }, "round"), _jsx(OpacityControl, { shapes: shapes }, "opacity"));
47
+ }
48
+ // Common trailing controls for every shape type.
49
+ overflow.push(_jsx(ZOrderControl, {}, "z"), _jsx(LinkControl, { shapes: shapes }, "link"), _jsx(ActionsControl, { shapes: shapes }, "actions"), _jsx(MoreButton, {}, "more"));
50
+ return (_jsx(PanelShell, { mobile: mobile, primary: primary, overflow: overflow, className: className, style: style }));
51
+ }
52
+ if (selectedLinkId !== null) {
53
+ const edge = scene.links.get(selectedLinkId);
54
+ if (!edge)
55
+ return null;
56
+ const primary = [
57
+ _jsx(LinkStrokeColorControl, { edge: edge }, "color"),
58
+ _jsx(LinkStrokeWidthControl, { edge: edge }, "width"),
59
+ _jsx(LinkArrowheadControl, { edge: edge, side: "to" }, "arrow-to"),
60
+ ];
61
+ const overflow = [
62
+ _jsx(LinkStrokeStyleControl, { edge: edge }, "dash"),
63
+ _jsx(LinkRoutingControl, { edge: edge }, "routing"),
64
+ _jsx(LinkLineKindControl, { edge: edge }, "kind"),
65
+ _jsx(LinkArrowheadControl, { edge: edge, side: "from" }, "arrow-from"),
66
+ _jsx(LinkAutoRouteControl, { edge: edge }, "auto"),
67
+ _jsx(LinkDeleteControl, {}, "delete"),
68
+ _jsx(MoreButton, {}, "more"),
69
+ ];
70
+ return (_jsx(PanelShell, { mobile: mobile, primary: primary, overflow: overflow, className: className, style: style }));
71
+ }
72
+ return null;
73
+ };
74
+ /**
75
+ * Lays out the primary / overflow control groups. Desktop = one floating
76
+ * pill row (primary · divider · overflow). Mobile = a primary row with a
77
+ * vertical-dots ⋮ that expands a wrapped overflow grid below it.
78
+ */
79
+ const PanelShell = ({ mobile, primary, overflow, className, style, }) => {
80
+ const [expanded, setExpanded] = useState(false);
81
+ const panelRef = useRef(null);
82
+ // Collapse the expanded overflow sheet on a tap outside the panel.
83
+ // The ⋮ button and the grabber collapse it directly; this covers taps
84
+ // on the canvas / elsewhere.
85
+ useEffect(() => {
86
+ if (!mobile || !expanded)
87
+ return undefined;
88
+ const onDown = (e) => {
89
+ const el = panelRef.current;
90
+ if (el && e.target instanceof Node && !el.contains(e.target))
91
+ setExpanded(false);
92
+ };
93
+ // `capture` so we see the tap even if something stops propagation.
94
+ document.addEventListener("pointerdown", onDown, true);
95
+ return () => {
96
+ document.removeEventListener("pointerdown", onDown, true);
97
+ };
98
+ }, [mobile, expanded]);
99
+ if (!mobile) {
100
+ return (_jsxs("div", { className: `du-sel-panel ${className ?? ""}`.trim(), style: style, children: [primary, overflow.length > 0 ? _jsx(Divider, {}) : null, overflow] }));
101
+ }
102
+ return (_jsxs("div", { ref: panelRef, className: `du-sel-panel du-sel-panel-mobile ${className ?? ""}`.trim(), style: style, children: [_jsxs("div", { className: "du-sel-mobile-row", children: [_jsx("div", { className: "du-sel-mobile-primary", children: primary }), overflow.length > 0 ? (_jsx("button", { type: "button", className: `du-sel-icon-button du-sel-mobile-expand${expanded ? " is-active" : ""}`, "aria-expanded": expanded, "aria-label": expanded ? "Hide more properties" : "More properties", title: "More properties", onClick: () => {
103
+ setExpanded((v) => !v);
104
+ }, children: _jsx(MoreVertical, { size: 18, strokeWidth: 1.75, "aria-hidden": true }) })) : null] }), expanded && overflow.length > 0 ? (_jsx("div", { className: "du-sel-mobile-overflow", children: overflow })) : null] }));
105
+ };
106
+ /**
107
+ * Element link control. One trigger (chain icon, active when a link is
108
+ * set) opens a popover with a URL field plus Save / Open / Remove. Works
109
+ * for any shape — the href lives on `ElementBase`. The URL is normalised
110
+ * (`normalizeHref`: adds `https://`, `mailto:`, rejects `javascript:`)
111
+ * before storing. Multi-select applies to all.
112
+ */
113
+ const LinkControl = ({ shapes }) => {
114
+ const editor = useDiagramOptional();
115
+ const inputRef = useRef(null);
116
+ if (!editor)
117
+ return null;
118
+ const ids = shapes.map((s) => s.id);
119
+ const current = sharedString(shapes, (s) => s.href);
120
+ const hasLink = shapes.some((s) => Boolean(s.href));
121
+ const save = (raw) => {
122
+ editor.setLink(ids, raw);
123
+ };
124
+ return (_jsx(Popover, { ariaLabel: "Link", trigger: _jsx("button", { type: "button", className: `du-sel-icon-button${hasLink ? " is-active" : ""}`, title: "Link", "aria-label": "Link", children: _jsx(LinkIcon, { size: 14, strokeWidth: 1.75, "aria-hidden": true }) }), children: _jsxs("div", { className: "du-sel-popover-section", children: [_jsx("header", { className: "du-sel-popover-label", children: "Link" }), _jsx("input", { ref: inputRef, className: "du-sel-link-input", type: "text", placeholder: "https://\u2026 \u00B7 name@mail", defaultValue: current ?? "", "aria-label": "Link URL", onKeyDown: (ev) => {
125
+ if (ev.key === "Enter") {
126
+ ev.preventDefault();
127
+ save(ev.currentTarget.value);
128
+ }
129
+ } }), _jsxs("div", { style: { display: "flex", gap: 2 }, children: [_jsx("button", { type: "button", className: "du-sel-text-button", onClick: () => {
130
+ save(inputRef.current?.value ?? "");
131
+ }, children: "Save" }), hasLink ? (_jsx("button", { type: "button", className: "du-sel-text-button", onClick: () => {
132
+ editor.openLink(current);
133
+ }, children: "Open" })) : null, hasLink ? (_jsx("button", { type: "button", className: "du-sel-text-button", onClick: () => {
134
+ editor.setLink(ids, null);
135
+ }, children: "Remove" })) : null] })] }) }));
136
+ };
137
+ const MoreButton = () => {
138
+ const editor = useDiagramOptional();
139
+ const controller = useContextMenuController();
140
+ if (!editor || !controller)
141
+ return null;
142
+ return (_jsx("button", { type: "button", className: "du-sel-icon-button", title: "More actions", "aria-label": "More actions", onClick: (ev) => {
143
+ const rect = ev.currentTarget.getBoundingClientRect();
144
+ const screenPoint = { x: rect.left, y: rect.bottom + 4 };
145
+ const host = editor.hostElement;
146
+ const hostRect = host?.getBoundingClientRect();
147
+ const worldPoint = hostRect
148
+ ? editor.screenToWorld({
149
+ x: screenPoint.x - hostRect.left,
150
+ y: screenPoint.y - hostRect.top,
151
+ })
152
+ : { x: 0, y: 0 };
153
+ controller.open({ screenPoint, worldPoint });
154
+ }, children: _jsx(MoreHorizontal, { size: 14, strokeWidth: 1.75, "aria-hidden": true }) }));
155
+ };
156
+ // ---------------------------------------------------------------------------
157
+ // Inline controls
158
+ // ---------------------------------------------------------------------------
159
+ /**
160
+ * Color trigger: a 24×24 square button with a colored fill plus an
161
+ * outer ring, opens the full swatch picker in a popover.
162
+ */
163
+ const ColorTrigger = ({ label, color, onChange, ariaLabel, }) => (_jsx(Popover, { ariaLabel: ariaLabel, trigger: _jsx("button", { type: "button", className: "du-sel-color-trigger", title: label, "aria-label": ariaLabel, children: _jsx("span", { className: "du-sel-color-swatch", style: {
164
+ background: !color || color === "transparent"
165
+ ? "repeating-conic-gradient(#ccc 0% 25%, #fff 0% 50%) 50% / 6px 6px"
166
+ : color,
167
+ } }) }), children: _jsxs("div", { className: "du-sel-popover-section", children: [_jsx("header", { className: "du-sel-popover-label", children: label }), _jsx(ColorSwatchPicker, { value: color, onChange: onChange })] }) }));
168
+ /**
169
+ * Combined color & opacity control — a single swatch trigger whose
170
+ * popover has both the palette and an opacity slider. Used for the text
171
+ * panel in place of separate Fill + Opacity triggers. Writes `fill` and
172
+ * `opacity` through `editor.updateStyle`.
173
+ */
174
+ const ColorOpacityControl = ({ shapes }) => {
175
+ const editor = useDiagramOptional();
176
+ if (!editor)
177
+ return null;
178
+ const ids = shapes.map((s) => s.id);
179
+ const color = sharedString(shapes, (s) => s.style.fill);
180
+ const opacity = sharedValue(shapes, (s) => s.style.opacity ?? 1);
181
+ const pct = opacity === null ? null : Math.round(opacity * 100);
182
+ const swatchBg = !color || color === "transparent"
183
+ ? "repeating-conic-gradient(#ccc 0% 25%, #fff 0% 50%) 50% / 6px 6px"
184
+ : color;
185
+ return (_jsx(Popover, { ariaLabel: "Text color and opacity", trigger: _jsx("button", { type: "button", className: "du-sel-color-trigger", title: "Color & opacity", "aria-label": "Text color and opacity", children: _jsx("span", { className: "du-sel-color-swatch", style: { background: swatchBg, opacity: opacity ?? 1 } }) }), children: _jsxs("div", { className: "du-sel-popover-section", children: [_jsx("header", { className: "du-sel-popover-label", children: "Color" }), _jsx(ColorSwatchPicker, { value: color, onChange: (v) => {
186
+ editor.updateStyle(ids, { fill: v ?? "transparent" });
187
+ } }), _jsx("header", { className: "du-sel-popover-label", children: "Opacity" }), _jsx(Slider, { value: pct, min: 0, max: 100, step: 5, ariaLabel: "Opacity", valueLabel: pct === null ? "—" : `${pct}%`, onChange: (v) => {
188
+ editor.updateStyle(ids, { opacity: v / 100 });
189
+ } })] }) }));
190
+ };
191
+ const FillControl = ({ shapes }) => {
192
+ const editor = useDiagramOptional();
193
+ if (!editor || !shapes.some(hasFill))
194
+ return null;
195
+ const value = sharedString(shapes, (s) => s.style.fill);
196
+ const ids = shapes.map((s) => s.id);
197
+ return (_jsx(ColorTrigger, { label: "Fill", ariaLabel: "Fill color", color: value, onChange: (v) => {
198
+ editor.updateStyle(ids, { fill: v ?? "transparent" });
199
+ } }));
200
+ };
201
+ // ---------------------------------------------------------------------------
202
+ // Text controls — rendered only for a text-only selection (see the
203
+ // dispatcher in `PropertyPanel`). `fontSize` / `fontFamily` are
204
+ // top-level `TextElement` fields written via `editor.updateTextProps`;
205
+ // `textAlign` / `textBaseline` are `TextStyle` fields written via
206
+ // `editor.updateStyle`.
207
+ // ---------------------------------------------------------------------------
208
+ const FontSizeControl = ({ shapes }) => {
209
+ const editor = useDiagramOptional();
210
+ if (!editor)
211
+ return null;
212
+ const ids = shapes.map((s) => s.id);
213
+ const value = sharedValue(shapes,
214
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- cast asserts TextElement; non-text shapes lack fontSize at runtime
215
+ (s) => s.fontSize ?? null);
216
+ const presetValue = value !== null && TEXT_FONT_SIZE_PRESETS.some((p) => p.value === value) ? value : null;
217
+ return (_jsx(Popover, { ariaLabel: "Font size", trigger: _jsx("button", { type: "button", className: "du-sel-text-button", title: "Font size", "aria-label": `Font size ${value ?? "mixed"}`, children: value === null ? "—" : `${Math.round(value)}` }), children: _jsxs("div", { className: "du-sel-popover-section", children: [_jsx("header", { className: "du-sel-popover-label", children: "Font size" }), _jsx(SegmentedControl, { ariaLabel: "Font size preset", value: presetValue, options: TEXT_FONT_SIZE_PRESETS.map((p) => ({
218
+ value: p.value,
219
+ label: p.label,
220
+ icon: _jsx("span", { style: { fontSize: 11, fontWeight: 600 }, children: p.label }),
221
+ })), onChange: (v) => {
222
+ editor.updateTextProps(ids, { fontSize: v });
223
+ } }), _jsx(Slider, { value: value, min: TEXT_FONT_SIZE_MIN, max: TEXT_FONT_SIZE_MAX, step: 1, ariaLabel: "Font size", valueLabel: value === null ? "—" : `${value}px`, onChange: (v) => {
224
+ editor.updateTextProps(ids, { fontSize: v });
225
+ } })] }) }));
226
+ };
227
+ const FontFamilyControl = ({ shapes }) => {
228
+ const editor = useDiagramOptional();
229
+ if (!editor)
230
+ return null;
231
+ const ids = shapes.map((s) => s.id);
232
+ const value = sharedString(shapes, (s) => s.fontFamily);
233
+ const current = TEXT_FONT_STACKS.find((f) => f.value === value);
234
+ const label = value === null ? "Mixed" : (current?.label ?? "Custom");
235
+ return (_jsx(Popover, { ariaLabel: "Font family", trigger: _jsx("button", { type: "button", className: "du-sel-text-button", title: "Font family", "aria-label": `Font family ${label}`, style: value ? { fontFamily: value } : undefined, children: label }), children: _jsxs("div", { className: "du-sel-popover-section", children: [_jsx("header", { className: "du-sel-popover-label", children: "Font family" }), TEXT_FONT_STACKS.map((f) => (_jsx("button", { type: "button", role: "menuitemradio", "aria-checked": f.value === value, className: `du-sel-menu-row${f.value === value ? " is-active" : ""}`, style: { fontFamily: f.value }, onClick: () => {
236
+ editor.updateTextProps(ids, { fontFamily: f.value });
237
+ }, children: f.label }, f.value)))] }) }));
238
+ };
239
+ const TextAlignControl = ({ shapes }) => {
240
+ const editor = useDiagramOptional();
241
+ if (!editor)
242
+ return null;
243
+ const ids = shapes.map((s) => s.id);
244
+ const value = sharedValue(shapes, (s) => s.style.textAlign ?? "left");
245
+ return (_jsx(SegmentedControl, { ariaLabel: "Text alignment", value: value, options: [
246
+ { value: "left", label: "Left", icon: _jsx(AlignLeft, { size: 14, strokeWidth: 1.75 }) },
247
+ { value: "center", label: "Center", icon: _jsx(AlignCenter, { size: 14, strokeWidth: 1.75 }) },
248
+ { value: "right", label: "Right", icon: _jsx(AlignRight, { size: 14, strokeWidth: 1.75 }) },
249
+ ], onChange: (v) => {
250
+ editor.updateStyle(ids, { textAlign: v });
251
+ } }));
252
+ };
253
+ /**
254
+ * Bold / Italic / Underline / Strikethrough. One trigger (Aa) opens a
255
+ * popover with four independent toggles. Each writes through
256
+ * `editor.updateStyle`: bold→`fontWeight`, italic→`fontStyle`,
257
+ * underline/strikethrough→merged `textDecoration`. Active = every
258
+ * selected shape already has that decoration on.
259
+ */
260
+ const TextDecorationControl = ({ shapes }) => {
261
+ const editor = useDiagramOptional();
262
+ if (!editor)
263
+ return null;
264
+ const ids = shapes.map((s) => s.id);
265
+ const allBold = shapes.every((s) => s.style?.fontWeight === "bold");
266
+ const allItalic = shapes.every((s) => s.style?.fontStyle === "italic");
267
+ const allUnderline = shapes.every((s) => s.style?.textDecoration?.underline === true);
268
+ const allStrike = shapes.every((s) => s.style?.textDecoration?.strikethrough === true);
269
+ // Toggling underline/strikethrough must preserve the other flag per
270
+ // shape, so merge into each shape's current decoration individually.
271
+ const setDecoration = (key, on) => {
272
+ for (const s of shapes) {
273
+ const cur = s.style?.textDecoration ?? {};
274
+ editor.updateStyle([s.id], { textDecoration: { ...cur, [key]: on } });
275
+ }
276
+ };
277
+ const Toggle = ({ active, label, icon, onClick, }) => (_jsx("button", { type: "button", className: `du-sel-icon-button${active ? " is-active" : ""}`, title: label, "aria-label": label, "aria-pressed": active, onClick: onClick, children: icon }));
278
+ return (_jsx(Popover, { ariaLabel: "Text style", trigger: _jsx("button", { type: "button", className: "du-sel-icon-button", title: "Text style (bold / italic / \u2026)", "aria-label": "Text style", children: _jsx(CaseSensitive, { size: 16, strokeWidth: 1.75, "aria-hidden": true }) }), children: _jsxs("div", { className: "du-sel-popover-section", children: [_jsx("header", { className: "du-sel-popover-label", children: "Style" }), _jsxs("div", { style: { display: "flex", gap: 2 }, children: [_jsx(Toggle, { active: allBold, label: "Bold", icon: _jsx(Bold, { size: 14, strokeWidth: 1.75 }), onClick: () => {
279
+ editor.updateStyle(ids, { fontWeight: allBold ? "normal" : "bold" });
280
+ } }), _jsx(Toggle, { active: allItalic, label: "Italic", icon: _jsx(Italic, { size: 14, strokeWidth: 1.75 }), onClick: () => {
281
+ editor.updateStyle(ids, { fontStyle: allItalic ? "normal" : "italic" });
282
+ } }), _jsx(Toggle, { active: allUnderline, label: "Underline", icon: _jsx(Underline, { size: 14, strokeWidth: 1.75 }), onClick: () => {
283
+ setDecoration("underline", !allUnderline);
284
+ } }), _jsx(Toggle, { active: allStrike, label: "Strikethrough", icon: _jsx(Strikethrough, { size: 14, strokeWidth: 1.75 }), onClick: () => {
285
+ setDecoration("strikethrough", !allStrike);
286
+ } })] })] }) }));
287
+ };
288
+ const StrokeControl = ({ shapes }) => {
289
+ const editor = useDiagramOptional();
290
+ if (!editor || !shapes.some(hasStroke))
291
+ return null;
292
+ const value = sharedString(shapes, (s) => s.style.stroke);
293
+ const ids = shapes.map((s) => s.id);
294
+ return (_jsx(ColorTrigger, { label: "Stroke", ariaLabel: "Stroke color", color: value, onChange: (v) => {
295
+ editor.updateStyle(ids, { stroke: v ?? "transparent" });
296
+ } }));
297
+ };
298
+ const StrokeWidthControl = ({ shapes }) => {
299
+ const editor = useDiagramOptional();
300
+ if (!editor || !shapes.some((s) => s.style.stroke !== undefined))
301
+ return null;
302
+ const value = sharedValue(shapes, (s) => s.style.strokeWidth ?? null);
303
+ const ids = shapes.map((s) => s.id);
304
+ return (_jsx(SegmentedControl, { ariaLabel: "Stroke width", value: value, options: [
305
+ { value: 1, label: "Thin", icon: _jsx(StrokeWidthIcon, { thickness: 1 }) },
306
+ { value: 2, label: "Medium", icon: _jsx(StrokeWidthIcon, { thickness: 2.5 }) },
307
+ { value: 4, label: "Thick", icon: _jsx(StrokeWidthIcon, { thickness: 4 }) },
308
+ ], onChange: (v) => {
309
+ editor.updateStyle(ids, { strokeWidth: v });
310
+ } }));
311
+ };
312
+ const StrokeStyleControl = ({ shapes }) => {
313
+ const editor = useDiagramOptional();
314
+ if (!editor || !shapes.some(hasStroke))
315
+ return null;
316
+ // Tolerant detection: any 2-element array with first ≤ 3 → dotted;
317
+ // anything else with first > 3 → dashed. Lets the panel recognise
318
+ // template-authored arrays like `[6, 4]` (auto-grid frames) as
319
+ // "dashed" instead of "mixed".
320
+ const value = sharedValue(shapes, (s) => {
321
+ const da = s.style.dashArray;
322
+ if (!da || da.length === 0)
323
+ return "solid";
324
+ const first = da[0] ?? 0;
325
+ return first <= 3 ? "dotted" : "dashed";
326
+ });
327
+ const ids = shapes.map((s) => s.id);
328
+ return (_jsx(SegmentedControl, { ariaLabel: "Stroke style", value: value, options: [
329
+ { value: "solid", label: "Solid", icon: _jsx(Square, { size: 14, strokeWidth: 1.75 }) },
330
+ { value: "dashed", label: "Dashed", icon: _jsx(SquareDashed, { size: 14, strokeWidth: 1.75 }) },
331
+ { value: "dotted", label: "Dotted", icon: _jsx(SquareDot, { size: 14, strokeWidth: 1.75 }) },
332
+ ], onChange: (v) => {
333
+ // An empty `dashArray: []` renders solid (Canvas2D `setLineDash([])`),
334
+ // and an empty array is truthy in JS so the renderer's dash call still
335
+ // goes through. Always pass an array.
336
+ const dashArray = v === "solid" ? [] : v === "dashed" ? [8, 4] : [2, 4];
337
+ editor.updateStyle(ids, { dashArray });
338
+ } }));
339
+ };
340
+ /**
341
+ * Corner control: an icon button (sharp / round) opens a popover with
342
+ * the round-radius slider plus an auto checkbox. Renders nothing when no
343
+ * corner-capable shapes are selected.
344
+ */
345
+ const RoundnessControl = ({ shapes }) => {
346
+ const editor = useDiagramOptional();
347
+ if (!editor)
348
+ return null;
349
+ const supports = shapes.every((s) => s.type === "rectangle" || s.type === "container");
350
+ if (!supports)
351
+ return null;
352
+ const type = sharedValue(shapes, (s) => s.style.roundness?.type ?? "sharp");
353
+ const radius = sharedValue(shapes, (s) => s.style.roundness?.value ?? null);
354
+ const ids = shapes.map((s) => s.id);
355
+ const isAuto = radius === null;
356
+ return (_jsx(Popover, { ariaLabel: "Corners", trigger: _jsx("button", { type: "button", className: "du-sel-icon-button", title: "Corners", "aria-label": "Corners", children: _jsx(CornerIcon, { kind: type ?? "sharp" }) }), children: _jsxs("div", { className: "du-sel-popover-section", children: [_jsx("header", { className: "du-sel-popover-label", children: "Corners" }), _jsx(SegmentedControl, { ariaLabel: "Corner roundness", value: type, options: [
357
+ { value: "sharp", label: "Sharp", icon: _jsx(CornerIcon, { kind: "sharp" }) },
358
+ { value: "round", label: "Round", icon: _jsx(CornerIcon, { kind: "round" }) },
359
+ ], onChange: (v) => {
360
+ editor.updateStyle(ids, { roundness: { type: v } });
361
+ } }), type === "round" ? (_jsxs(_Fragment, { children: [_jsxs("label", { className: "du-prop-checkbox", children: [_jsx("input", { type: "checkbox", checked: isAuto, onChange: (ev) => {
362
+ if (ev.target.checked) {
363
+ editor.updateStyle(ids, { roundness: { type: "round" } });
364
+ }
365
+ else {
366
+ editor.updateStyle(ids, {
367
+ roundness: { type: "round", value: radius ?? 8 },
368
+ });
369
+ }
370
+ } }), _jsx("span", { children: "Auto radius" })] }), !isAuto ? (_jsx(Slider, { value: radius, min: 0, max: 64, step: 1, ariaLabel: "Corner radius", valueLabel: `${radius}px`, onChange: (v) => {
371
+ editor.updateStyle(ids, { roundness: { type: "round", value: v } });
372
+ } })) : null] })) : null] }) }));
373
+ };
374
+ /**
375
+ * Opacity control: percentage badge button opens a popover with a
376
+ * slider. The trigger is always rendered (even at implicit opacity 1) so
377
+ * the user can jump to 50% without a multi-step interaction.
378
+ */
379
+ const OpacityControl = ({ shapes }) => {
380
+ const editor = useDiagramOptional();
381
+ if (!editor)
382
+ return null;
383
+ const value = sharedValue(shapes, (s) => s.style.opacity ?? 1);
384
+ const ids = shapes.map((s) => s.id);
385
+ const percent = value === null ? null : Math.round(value * 100);
386
+ const label = percent === null ? "—" : `${percent}%`;
387
+ return (_jsx(Popover, { ariaLabel: "Opacity", trigger: _jsx("button", { type: "button", className: "du-sel-text-button", title: "Opacity", "aria-label": `Opacity ${label}`, children: label }), children: _jsxs("div", { className: "du-sel-popover-section", children: [_jsx("header", { className: "du-sel-popover-label", children: "Opacity" }), _jsx(Slider, { value: percent, min: 0, max: 100, step: 5, ariaLabel: "Opacity", valueLabel: label, onChange: (v) => {
388
+ editor.updateStyle(ids, { opacity: v / 100 });
389
+ } })] }) }));
390
+ };
391
+ const ZOrderControl = () => {
392
+ const editor = useDiagramOptional();
393
+ if (!editor)
394
+ return null;
395
+ return (_jsx(SegmentedControl, { ariaLabel: "Z-order", value: null, options: [
396
+ {
397
+ value: "back",
398
+ label: "Send to back",
399
+ icon: _jsx(ChevronsDown, { size: 14, strokeWidth: 1.75 }),
400
+ },
401
+ {
402
+ value: "backward",
403
+ label: "Send backward",
404
+ icon: _jsx(MoveDown, { size: 14, strokeWidth: 1.75 }),
405
+ },
406
+ { value: "forward", label: "Bring forward", icon: _jsx(MoveUp, { size: 14, strokeWidth: 1.75 }) },
407
+ {
408
+ value: "front",
409
+ label: "Bring to front",
410
+ icon: _jsx(ChevronsUp, { size: 14, strokeWidth: 1.75 }),
411
+ },
412
+ ], onChange: (v) => {
413
+ if (v === "back")
414
+ editor.sendToBack();
415
+ else if (v === "backward")
416
+ editor.sendBackward();
417
+ else if (v === "forward")
418
+ editor.bringForward();
419
+ else
420
+ editor.bringToFront();
421
+ } }));
422
+ };
423
+ const ActionsControl = ({ shapes }) => {
424
+ const editor = useDiagramOptional();
425
+ if (!editor)
426
+ return null;
427
+ const canGroup = shapes.length >= 2;
428
+ const canUngroup = shapes.some((s) => isGroup(s));
429
+ const options = [
430
+ { value: "duplicate", label: "Duplicate", icon: _jsx(CopyIcon, { size: 14, strokeWidth: 1.75 }) },
431
+ { value: "delete", label: "Delete", icon: _jsx(Trash2, { size: 14, strokeWidth: 1.75 }) },
432
+ ];
433
+ if (canGroup) {
434
+ options.push({
435
+ value: "group",
436
+ label: "Group",
437
+ icon: _jsx(GroupIcon, { size: 14, strokeWidth: 1.75 }),
438
+ });
439
+ }
440
+ if (canUngroup) {
441
+ options.push({
442
+ value: "ungroup",
443
+ label: "Ungroup",
444
+ icon: _jsx(UngroupIcon, { size: 14, strokeWidth: 1.75 }),
445
+ });
446
+ }
447
+ return (_jsx(SegmentedControl, { ariaLabel: "Element actions", value: null, options: options, onChange: (v) => {
448
+ if (v === "duplicate")
449
+ editor.duplicateSelected();
450
+ else if (v === "delete")
451
+ editor.deleteSelected();
452
+ else if (v === "group")
453
+ editor.groupSelected();
454
+ else
455
+ editor.ungroup();
456
+ } }));
457
+ };
458
+ // ---------------------------------------------------------------------------
459
+ // Link controls — horizontal compact set used when an edge (not a
460
+ // shape) is the active selection. Mirrors the shape control surface
461
+ // (color triggers + segmented row controls) so the floating panel
462
+ // reads consistently regardless of selection type.
463
+ // ---------------------------------------------------------------------------
464
+ const LinkStrokeColorControl = ({ edge }) => {
465
+ const editor = useDiagramOptional();
466
+ if (!editor)
467
+ return null;
468
+ const color = typeof edge.style.stroke === "string" ? edge.style.stroke : null;
469
+ return (_jsx(ColorTrigger, { label: "Stroke", ariaLabel: "Link stroke color", color: color, onChange: (v) => {
470
+ editor.updateSelectedLink((e) => ({
471
+ ...e,
472
+ style: { ...e.style, stroke: v ?? "transparent" },
473
+ }));
474
+ } }));
475
+ };
476
+ const LinkStrokeWidthControl = ({ edge }) => {
477
+ const editor = useDiagramOptional();
478
+ if (!editor)
479
+ return null;
480
+ const value = typeof edge.style.strokeWidth === "number" ? edge.style.strokeWidth : null;
481
+ return (_jsx(SegmentedControl, { ariaLabel: "Link stroke width", value: value, options: [
482
+ { value: 1, label: "Thin", icon: _jsx(StrokeWidthIcon, { thickness: 1 }) },
483
+ { value: 2, label: "Medium", icon: _jsx(StrokeWidthIcon, { thickness: 2.5 }) },
484
+ { value: 4, label: "Thick", icon: _jsx(StrokeWidthIcon, { thickness: 4 }) },
485
+ ], onChange: (v) => {
486
+ editor.updateSelectedLink((e) => ({
487
+ ...e,
488
+ style: { ...e.style, strokeWidth: v },
489
+ }));
490
+ } }));
491
+ };
492
+ const LinkStrokeStyleControl = ({ edge }) => {
493
+ const editor = useDiagramOptional();
494
+ if (!editor)
495
+ return null;
496
+ const da = edge.style.dashArray;
497
+ const value = (() => {
498
+ if (!da || da.length === 0)
499
+ return "solid";
500
+ const first = da[0] ?? 0;
501
+ return first <= 3 ? "dotted" : "dashed";
502
+ })();
503
+ return (_jsx(SegmentedControl, { ariaLabel: "Link stroke style", value: value, options: [
504
+ { value: "solid", label: "Solid", icon: _jsx(Square, { size: 14, strokeWidth: 1.75 }) },
505
+ { value: "dashed", label: "Dashed", icon: _jsx(SquareDashed, { size: 14, strokeWidth: 1.75 }) },
506
+ { value: "dotted", label: "Dotted", icon: _jsx(SquareDot, { size: 14, strokeWidth: 1.75 }) },
507
+ ], onChange: (v) => {
508
+ const dashArray = v === "solid" ? [] : v === "dashed" ? [8, 4] : [2, 4];
509
+ editor.updateSelectedLink((e) => ({
510
+ ...e,
511
+ style: { ...e.style, dashArray },
512
+ }));
513
+ } }));
514
+ };
515
+ const LinkLineKindControl = ({ edge }) => {
516
+ const editor = useDiagramOptional();
517
+ if (!editor)
518
+ return null;
519
+ const value = edge.lineKind ?? "line";
520
+ return (_jsx(SegmentedControl, { ariaLabel: "Link body", value: value, options: [
521
+ { value: "line", label: "Line", icon: _jsx(Minus, { size: 14, strokeWidth: 1.75 }) },
522
+ {
523
+ value: "block-arrow",
524
+ label: "Block arrow",
525
+ icon: _jsx(MoveRight, { size: 14, strokeWidth: 2.5 }),
526
+ },
527
+ ], onChange: (v) => {
528
+ editor.updateSelectedLink((e) => ({ ...e, lineKind: v }));
529
+ } }));
530
+ };
531
+ const LinkRoutingControl = ({ edge }) => {
532
+ const editor = useDiagramOptional();
533
+ if (!editor)
534
+ return null;
535
+ const value = edge.routing ?? "straight";
536
+ return (_jsx(SegmentedControl, { ariaLabel: "Link routing", value: value, options: [
537
+ { value: "straight", label: "Straight", icon: _jsx(RoutingIcon, { kind: "straight" }) },
538
+ { value: "orthogonal", label: "Elbow", icon: _jsx(RoutingIcon, { kind: "orthogonal" }) },
539
+ { value: "bezier", label: "Curved", icon: _jsx(Spline, { size: 14, strokeWidth: 1.75 }) },
540
+ ], onChange: (v) => {
541
+ editor.updateSelectedLink((e) => ({ ...e, routing: v }));
542
+ } }));
543
+ };
544
+ const LinkArrowheadControl = ({ edge, side, }) => {
545
+ const editor = useDiagramOptional();
546
+ const [showErd, setShowErd] = useState(false);
547
+ if (!editor)
548
+ return null;
549
+ const current = edge.arrowheads?.[side] ?? "none";
550
+ const pick = (style) => {
551
+ editor.updateSelectedLink((e) => ({
552
+ ...e,
553
+ arrowheads: { ...(e.arrowheads ?? {}), [side]: style },
554
+ }));
555
+ };
556
+ const Option = ({ style }) => (_jsx("button", { type: "button", className: `du-arrowhead-option${style === current ? " du-arrowhead-option--active" : ""}`, title: ARROWHEAD_LABELS[style], "aria-label": ARROWHEAD_LABELS[style], "aria-pressed": style === current, onClick: () => {
557
+ pick(style);
558
+ }, children: style === "none" ? (_jsx("span", { className: "du-arrowhead-none", children: "\u2205" })) : arrowheadGlyphFamily(style) === "none" ? (_jsx("span", { className: "du-arrowhead-erd-label", children: ARROWHEAD_LABELS[style].replace(/^ERD /, "") })) : (_jsx(ArrowheadGlyph, { kind: style, side: side })) }));
559
+ return (_jsx(Popover, { trigger: _jsx("button", { type: "button", className: "du-sel-icon-button", title: `Arrow ${side}: ${ARROWHEAD_LABELS[current]}`, "aria-label": `Arrow ${side}`, children: _jsx(ArrowheadGlyph, { kind: current, side: side }) }), children: _jsxs("div", { className: "du-sel-popover-section", children: [_jsxs("header", { className: "du-sel-popover-label", children: ["Arrow ", side] }), _jsx("div", { className: "du-arrowhead-grid", children: BASIC_ARROWHEADS.map((s) => (_jsx(Option, { style: s }, s))) }), _jsxs("button", { type: "button", className: "du-arrowhead-erd-toggle", "aria-expanded": showErd, onClick: () => {
560
+ setShowErd((v) => !v);
561
+ }, children: [showErd ? "▾" : "▸", " ER diagram"] }), showErd && (_jsx("div", { className: "du-arrowhead-grid", children: ERD_ARROWHEADS.map((s) => (_jsx(Option, { style: s }, s))) }))] }) }));
562
+ };
563
+ const LinkAutoRouteControl = ({ edge }) => {
564
+ const editor = useDiagramOptional();
565
+ if (!editor)
566
+ return null;
567
+ // Obstacle-avoidance produces an orthogonal path, so it only makes sense
568
+ // for straight / elbow links — a curved (bezier) link can't carry the
569
+ // routed polyline. Hide the toggle for curved.
570
+ const routing = edge.routing ?? "straight";
571
+ if (routing === "bezier")
572
+ return null;
573
+ const on = edge.avoidObstacles === true;
574
+ return (_jsx("button", { type: "button", className: `du-sel-icon-button${on ? " is-active" : ""}`, title: "Route around shapes", "aria-label": "Route around shapes", "aria-pressed": on, onClick: () => {
575
+ editor.setSelectedLinkAvoidObstacles(!on);
576
+ }, children: _jsx(Waypoints, { size: 14, strokeWidth: 1.75, "aria-hidden": true }) }));
577
+ };
578
+ const LinkDeleteControl = () => {
579
+ const editor = useDiagramOptional();
580
+ if (!editor)
581
+ return null;
582
+ return (_jsx("button", { type: "button", className: "du-sel-icon-button", title: "Delete edge", "aria-label": "Delete edge", onClick: () => {
583
+ editor.deleteSelected();
584
+ }, children: _jsx(Trash2, { size: 14, strokeWidth: 1.75, "aria-hidden": true }) }));
585
+ };
586
+ // Inline SVG glyph for routing variant — Lucide has `Spline` for the
587
+ // curve but no clean "straight" / "elbow" line variants.
588
+ const RoutingIcon = ({ kind }) => {
589
+ if (kind === "straight") {
590
+ return (_jsx("svg", { width: 14, height: 14, viewBox: "0 0 14 14", fill: "none", "aria-hidden": true, children: _jsx("line", { x1: 2, y1: 11, x2: 12, y2: 3, stroke: "currentColor", strokeWidth: 1.5, strokeLinecap: "round" }) }));
591
+ }
592
+ // orthogonal (elbow)
593
+ return (_jsx("svg", { width: 14, height: 14, viewBox: "0 0 14 14", fill: "none", "aria-hidden": true, children: _jsx("path", { d: "M 2 11 L 2 7 L 12 7 L 12 3", stroke: "currentColor", strokeWidth: 1.5, fill: "none", strokeLinecap: "round", strokeLinejoin: "round" }) }));
594
+ };
595
+ // Which compact glyph family renders a given arrowhead style.
596
+ const arrowheadGlyphFamily = (kind) => {
597
+ switch (kind) {
598
+ case "arrow":
599
+ case "openArrow":
600
+ case "roundedArrow":
601
+ case "arcArrow":
602
+ return "open";
603
+ case "triangle":
604
+ case "filledArrow":
605
+ return "triangle";
606
+ case "diamond":
607
+ case "rhombus":
608
+ case "filledRhombus":
609
+ return "diamond";
610
+ case "circle":
611
+ case "filledCircle":
612
+ return "circle";
613
+ default:
614
+ return "none"; // none + ERD caps (labelled by name in the picker)
615
+ }
616
+ };
617
+ // Picker option sets. ERD caps are gated behind a toggle.
618
+ const BASIC_ARROWHEADS = [
619
+ "none",
620
+ "arrow",
621
+ "openArrow",
622
+ "roundedArrow",
623
+ "arcArrow",
624
+ "filledArrow",
625
+ "triangle",
626
+ "circle",
627
+ "filledCircle",
628
+ "rhombus",
629
+ "filledRhombus",
630
+ ];
631
+ const ERD_ARROWHEADS = [
632
+ "erdOne",
633
+ "erdOnlyOne",
634
+ "erdMany",
635
+ "erdOneOrMany",
636
+ "erdZeroOrOne",
637
+ "erdZeroOrMany",
638
+ ];
639
+ const ARROWHEAD_LABELS = {
640
+ none: "None",
641
+ arrow: "Arrow",
642
+ openArrow: "Open arrow",
643
+ roundedArrow: "Rounded arrow",
644
+ arcArrow: "Arc arrow",
645
+ triangle: "Triangle",
646
+ filledArrow: "Filled arrow",
647
+ circle: "Circle",
648
+ filledCircle: "Filled circle",
649
+ diamond: "Diamond",
650
+ rhombus: "Rhombus",
651
+ filledRhombus: "Filled rhombus",
652
+ erdOne: "ERD one",
653
+ erdOnlyOne: "ERD only one",
654
+ erdMany: "ERD many",
655
+ erdOneOrMany: "ERD one or many",
656
+ erdZeroOrOne: "ERD zero or one",
657
+ erdZeroOrMany: "ERD zero or many",
658
+ };
659
+ const ArrowheadGlyph = ({ kind, side, }) => {
660
+ // Build a 14×14 horizontal line with the head at right (for `to`) or
661
+ // left (for `from`), all in stroke / fill currentColor.
662
+ const flipped = side === "from";
663
+ const lineX1 = flipped ? 12 : 2;
664
+ const lineX2 = flipped ? 5 : 9;
665
+ const headCx = flipped ? 3 : 11;
666
+ const headBase = flipped ? 5 : 9;
667
+ const stroke = (_jsx("line", { x1: lineX1, y1: 7, x2: lineX2, y2: 7, stroke: "currentColor", strokeWidth: 1.5, strokeLinecap: "round" }));
668
+ // Map the full vocabulary onto the four drawable glyph families. ERD caps
669
+ // have no compact glyph — they fall through to a bare line; the picker
670
+ // labels them by name so they stay distinguishable.
671
+ const fam = arrowheadGlyphFamily(kind);
672
+ let head = null;
673
+ if (fam === "open") {
674
+ head = (_jsx("polyline", { points: flipped
675
+ ? `${headCx + 3},4 ${headCx},7 ${headCx + 3},10`
676
+ : `${headCx - 3},4 ${headCx},7 ${headCx - 3},10`, stroke: "currentColor", strokeWidth: 1.5, fill: "none", strokeLinecap: "round", strokeLinejoin: "round" }));
677
+ }
678
+ else if (fam === "triangle") {
679
+ head = (_jsx("polygon", { points: flipped
680
+ ? `${headCx},7 ${headBase},4 ${headBase},10`
681
+ : `${headCx},7 ${headBase},4 ${headBase},10`, fill: "currentColor" }));
682
+ }
683
+ else if (fam === "diamond") {
684
+ head = (_jsx("polygon", { points: `${headCx},4 ${headCx + (flipped ? -3 : 3)},7 ${headCx},10 ${headCx + (flipped ? 3 : -3)},7`, fill: kind === "filledRhombus" ? "currentColor" : "none", stroke: "currentColor", strokeWidth: 1.2 }));
685
+ }
686
+ else if (fam === "circle") {
687
+ head = (_jsx("circle", { cx: headCx, cy: 7, r: 2.2, fill: kind === "filledCircle" ? "currentColor" : "none", stroke: "currentColor", strokeWidth: 1.2 }));
688
+ }
689
+ return (_jsxs("svg", { width: 14, height: 14, viewBox: "0 0 14 14", fill: "none", "aria-hidden": true, children: [stroke, head] }));
690
+ };
691
+ // ---------------------------------------------------------------------------
692
+ // Layout primitives
693
+ // ---------------------------------------------------------------------------
694
+ const Divider = () => _jsx("span", { className: "du-sel-divider", "aria-hidden": true });
695
+ // Section / Row kept as exports because tests may rely on them; they're
696
+ // no longer used internally.
697
+ export const Section = ({ label, children, }) => (_jsxs("section", { className: "du-prop-section", children: [_jsx("h3", { className: "du-prop-section-label", children: label }), children] }));
698
+ // ---------------------------------------------------------------------------
699
+ // Inline SVG glyphs
700
+ // ---------------------------------------------------------------------------
701
+ const StrokeWidthIcon = ({ thickness }) => (_jsx("svg", { width: 14, height: 14, viewBox: "0 0 14 14", fill: "none", "aria-hidden": true, children: _jsx("line", { x1: 2, y1: 7, x2: 12, y2: 7, stroke: "currentColor", strokeWidth: thickness, strokeLinecap: "round" }) }));
702
+ const CornerIcon = ({ kind }) => {
703
+ if (kind === "sharp") {
704
+ return _jsx(Square, { size: 14, strokeWidth: 1.75, "aria-hidden": true });
705
+ }
706
+ return (_jsx("svg", { width: 14, height: 14, viewBox: "0 0 14 14", fill: "none", "aria-hidden": true, children: _jsx("rect", { x: 2, y: 2, width: 10, height: 10, rx: 3, ry: 3, stroke: "currentColor", strokeWidth: 1.5 }) }));
707
+ };
708
+ // ---------------------------------------------------------------------------
709
+ // Helpers
710
+ // ---------------------------------------------------------------------------
711
+ const sharedValue = (elements, pick) => {
712
+ const set = new Set();
713
+ for (const s of elements)
714
+ set.add(pick(s));
715
+ if (set.size !== 1)
716
+ return null;
717
+ const v = set.values().next().value;
718
+ return v ?? null;
719
+ };
720
+ const sharedString = (elements, pick) => {
721
+ const value = sharedValue(elements, (s) => pick(s));
722
+ return typeof value === "string" ? value : null;
723
+ };
724
+ // Frames are always fillable (white by default) even when `style.fill` is
725
+ // unset.
726
+ const hasFill = (shape) => shape.style.fill !== undefined || shape.type === "frame";
727
+ const hasStroke = (shape) => shape.style.stroke !== undefined;
728
+ //# sourceMappingURL=property-panel.js.map