@drawback/ui 0.0.0-stage → 0.1.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 (38) hide show
  1. package/README.md +22 -2
  2. package/dist/i18n-BZnCrD-C.d.mts +265 -0
  3. package/dist/index.d.mts +588 -0
  4. package/dist/index.mjs +4821 -0
  5. package/dist/locales/de.d.mts +3 -0
  6. package/dist/locales/de.mjs +231 -0
  7. package/package.json +69 -4
  8. package/src/app/default-editor.tsx +371 -0
  9. package/src/components/color-picker/color-picker.tsx +341 -0
  10. package/src/components/color-picker/colors.ts +135 -0
  11. package/src/components/font-picker/font-picker.tsx +298 -0
  12. package/src/components/icons.tsx +222 -0
  13. package/src/components/primitives.tsx +565 -0
  14. package/src/components/style-icons.tsx +172 -0
  15. package/src/features/canvas-commands/canvas-commands.tsx +173 -0
  16. package/src/features/context-menu/context-menu.tsx +354 -0
  17. package/src/features/controls/controls.tsx +281 -0
  18. package/src/features/export/export-dialog.tsx +164 -0
  19. package/src/features/layers/layers-tree.ts +335 -0
  20. package/src/features/layers/layers.tsx +858 -0
  21. package/src/features/links/links.tsx +268 -0
  22. package/src/features/main-menu/canvas-properties.tsx +121 -0
  23. package/src/features/main-menu/main-menu.tsx +215 -0
  24. package/src/features/minimap/minimap.tsx +69 -0
  25. package/src/features/properties/linear-properties.tsx +169 -0
  26. package/src/features/properties/properties.tsx +573 -0
  27. package/src/features/shortcuts/shortcuts-dialog.tsx +120 -0
  28. package/src/features/toolbar/toolbar.tsx +216 -0
  29. package/src/hooks/use-latest.ts +16 -0
  30. package/src/index.ts +138 -0
  31. package/src/lib/commands.ts +14 -0
  32. package/src/lib/download.ts +8 -0
  33. package/src/lib/i18n.ts +350 -0
  34. package/src/lib/locales/de.ts +231 -0
  35. package/src/lib/plugins.tsx +92 -0
  36. package/src/lib/registry.ts +140 -0
  37. package/src/stores/ui-context.tsx +253 -0
  38. package/src/styles.css +1366 -0
@@ -0,0 +1,588 @@
1
+ import { CanvasRenderer, CanvasView, MountCanvasOptions } from "@drawback/canvas";
2
+ import { AnyEditor, ElementId, ElementRecord, FontId, GroupId, GroupRecord, LayerId, LayerRecord, Point } from "@drawback/core";
3
+ import { ComponentType, ReactNode, RefObject } from "react";
4
+ import { a as Translate, c as createTranslator, d as needsMessages, i as Messages, l as en, n as LanguageInfo, o as TranslateValues, r as MessageKey, s as builtinMessages, t as LANGUAGES, u as loadMessages } from "./i18n-BZnCrD-C.mjs";
5
+ interface ToolbarItem {
6
+ readonly id: string;
7
+ /** Position among tools; built-ins use 100–1000 in steps of 100. */
8
+ readonly order: number;
9
+ render(): ReactNode;
10
+ }
11
+ interface PropertyEditorProps {
12
+ readonly editor: AnyEditor;
13
+ /** Selected elements of the editor's type. */
14
+ readonly elements: readonly ElementRecord[];
15
+ }
16
+ interface ContextMenuContext {
17
+ readonly editor: AnyEditor;
18
+ /** Element under the pointer, if any (already selected by the menu). */
19
+ readonly element?: ElementRecord;
20
+ readonly selection: readonly ElementId[];
21
+ readonly world: Point;
22
+ readonly t: Translate;
23
+ }
24
+ interface ContextMenuItem {
25
+ readonly id: string;
26
+ /** Lower numbers come first; built-ins use 100–1000. Items with equal `group` are separated from others. */
27
+ readonly order?: number;
28
+ readonly group?: string;
29
+ readonly label: string | ((context: ContextMenuContext) => string);
30
+ readonly shortcut?: string;
31
+ readonly danger?: boolean;
32
+ when?(context: ContextMenuContext): boolean;
33
+ enabled?(context: ContextMenuContext): boolean;
34
+ /** Makes the item a toggle: rendered as a checkbox item with a check mark while true. */
35
+ checked?(context: ContextMenuContext): boolean;
36
+ run(context: ContextMenuContext): void;
37
+ }
38
+ type IconComponent = ComponentType<{
39
+ readonly size?: number;
40
+ /** Lucide-style stroke width on a 24-unit grid (1px on screen); custom icons may ignore it. */
41
+ readonly strokeWidth?: number;
42
+ readonly 'aria-hidden'?: boolean;
43
+ }>;
44
+ interface Collection<Value> {
45
+ register(value: Value): () => void;
46
+ list(): readonly Value[];
47
+ }
48
+ interface UiRegistry {
49
+ readonly toolbar: Collection<ToolbarItem>;
50
+ readonly contextMenu: Collection<ContextMenuItem>;
51
+ readonly propertyEditors: {
52
+ register(type: string, component: ComponentType<PropertyEditorProps>): () => void;
53
+ get(type: string): ComponentType<PropertyEditorProps> | undefined;
54
+ types(): readonly string[];
55
+ };
56
+ readonly icons: {
57
+ register(id: string, component: IconComponent): () => void;
58
+ get(id: string): IconComponent | undefined;
59
+ };
60
+ /** Bumps on every registration change. */
61
+ version(): number;
62
+ subscribe(listener: () => void): () => void;
63
+ }
64
+ /** Per-editor registrations for toolbar items, context menu items, property editors and icons. */
65
+ export declare function createUiRegistry(): UiRegistry;
66
+ /** Sorts by `order`, then id, so equal orders are deterministic. */
67
+ export declare function byOrder<Value extends {
68
+ readonly id: string;
69
+ readonly order?: number;
70
+ }>(values: readonly Value[]): Value[];
71
+ type ThemeSetting = 'light' | 'dark' | 'system';
72
+ type ResolvedTheme = 'light' | 'dark';
73
+ type PanelId = 'layers' | 'canvas' | 'shortcuts' | 'export' | 'mainMenu' | 'link' | 'minimap';
74
+ interface ContextMenuRequest {
75
+ readonly clientX: number;
76
+ readonly clientY: number;
77
+ /** Element the menu is about; it is selected when the menu opens. */
78
+ readonly elementId?: ElementId;
79
+ readonly world?: Point;
80
+ }
81
+ interface UiContextValue {
82
+ readonly t: Translate;
83
+ readonly registry: UiRegistry;
84
+ /** Changes whenever the registry changes, so consumers re-render. */
85
+ readonly registryVersion: number;
86
+ /** Whether a control id was hidden by the host. */
87
+ isHidden(id: string): boolean;
88
+ readonly theme: ResolvedTheme;
89
+ readonly themeSetting: ThemeSetting;
90
+ setTheme(theme: ThemeSetting): void;
91
+ readonly locale: string;
92
+ setLocale(locale: string): void;
93
+ /** Element menus, tooltips and dialogs portal into. */
94
+ readonly portalContainer: HTMLElement | null;
95
+ readonly dir: 'ltr' | 'rtl';
96
+ isOpen(panel: PanelId): boolean;
97
+ setOpen(panel: PanelId, open: boolean): void;
98
+ readonly contextMenu: ContextMenuRequest | undefined;
99
+ openContextMenu(request: ContextMenuRequest | undefined): void;
100
+ }
101
+ interface UiProviderProps {
102
+ /** Overrides on top of the built-in catalog for `locale`. */
103
+ readonly messages?: Messages;
104
+ /** Controlled locale; without `onLocaleChange` the provider keeps its own state. */
105
+ readonly locale?: string;
106
+ readonly onLocaleChange?: (locale: string) => void;
107
+ readonly dir?: 'ltr' | 'rtl';
108
+ readonly registry?: UiRegistry;
109
+ readonly hidden?: readonly string[];
110
+ /** Controlled theme; without `onThemeChange` the provider keeps its own state. */
111
+ readonly theme?: ThemeSetting;
112
+ readonly onThemeChange?: (theme: ThemeSetting) => void;
113
+ readonly portalContainer?: HTMLElement | null;
114
+ readonly initialOpen?: readonly PanelId[];
115
+ readonly children?: ReactNode;
116
+ }
117
+ /** Resolves `'system'` through `prefers-color-scheme`, following changes. */
118
+ export declare function useResolvedTheme(setting: ThemeSetting): ResolvedTheme;
119
+ /**
120
+ * Strings, registrations, hidden controls, theme and panel state for UI components.
121
+ * `<DefaultEditor>` renders one; hosts placing components themselves can render their own.
122
+ */
123
+ export declare function UiProvider({ messages, locale, onLocaleChange, dir, registry, hidden, theme, onThemeChange, portalContainer, initialOpen, children }: UiProviderProps): ReactNode;
124
+ export declare function useUi(): UiContextValue;
125
+ export declare function useT(): Translate;
126
+ export declare function UndoRedo(): ReactNode;
127
+ interface ZoomControlsProps {
128
+ /** Shown above the controls while the minimap toggle is pressed; without it there is no toggle. */
129
+ readonly minimap?: ReactNode;
130
+ }
131
+ export declare function ZoomControls({ minimap }?: ZoomControlsProps): ReactNode;
132
+ export declare function ScrollToContent(): ReactNode;
133
+ export declare function LaserButton(): ReactNode;
134
+ export declare function ZenToggle(): ReactNode;
135
+ export declare function GridControls(): ReactNode;
136
+ interface DefaultEditorComponents {
137
+ readonly Toolbar?: ComponentType;
138
+ readonly PropertiesPanel?: ComponentType;
139
+ readonly LayersPanel?: ComponentType<{
140
+ readonly onClose?: () => void;
141
+ }>;
142
+ readonly MainMenu?: ComponentType;
143
+ readonly ZoomControls?: ComponentType<ZoomControlsProps>;
144
+ readonly UndoRedo?: ComponentType;
145
+ readonly Minimap?: ComponentType;
146
+ readonly ContextMenu?: ComponentType;
147
+ }
148
+ interface DefaultEditorSlots {
149
+ readonly topLeft?: ReactNode;
150
+ readonly topRight?: ReactNode;
151
+ readonly bottomLeft?: ReactNode;
152
+ readonly bottomRight?: ReactNode;
153
+ readonly toolbarStart?: ReactNode;
154
+ readonly toolbarEnd?: ReactNode;
155
+ readonly mainMenuItems?: ReactNode;
156
+ }
157
+ interface DefaultEditorProps {
158
+ readonly editor: AnyEditor;
159
+ /** `light`, `dark` or `system` (default). Controlled when `onThemeChange` is set. */
160
+ readonly theme?: ThemeSetting;
161
+ readonly onThemeChange?: (theme: ThemeSetting) => void;
162
+ readonly messages?: Messages;
163
+ /** UI language (`en`, `de`). Controlled when `onLocaleChange` is set. */
164
+ readonly locale?: string;
165
+ readonly onLocaleChange?: (locale: string) => void;
166
+ readonly dir?: 'ltr' | 'rtl';
167
+ /** Control ids to hide (`toolbar`, `tool:<id>`, `properties`, `layers`, `minimap`, …). */
168
+ readonly hidden?: readonly string[];
169
+ readonly components?: DefaultEditorComponents;
170
+ readonly registry?: UiRegistry;
171
+ readonly slots?: DefaultEditorSlots;
172
+ /** Canvas mount options (renderers, fonts, images, …). */
173
+ readonly canvas?: MountCanvasOptions;
174
+ /** Renderers whose `minimap` hook the minimap uses (default: `canvas.renderers`). */
175
+ readonly minimapRenderers?: readonly CanvasRenderer[];
176
+ /** Panels open on first render (e.g. `['layers']`). */
177
+ readonly initialOpen?: readonly PanelId[];
178
+ /** Base name for saved and exported files. */
179
+ readonly fileName?: string;
180
+ readonly className?: string;
181
+ /** Called once the canvas view is mounted and sized. */
182
+ readonly onMount?: (view: CanvasView) => void;
183
+ }
184
+ /**
185
+ * Complete editor: canvas plus the default controls inside the given container. Renders its own
186
+ * `EditorProvider` and `UiProvider`; every control can be hidden, replaced or extended.
187
+ */
188
+ export declare function DefaultEditor({ editor, theme, onThemeChange, messages, locale, onLocaleChange, dir, hidden, components, registry, slots, canvas, minimapRenderers, initialOpen, fileName, className, onMount }: DefaultEditorProps): ReactNode;
189
+ /**
190
+ * Scoped root element for UI components: carries the theme, direction and the `.nx-editor`
191
+ * class all styles are scoped to. Opens the shortcut reference on `?`.
192
+ */
193
+ export declare function EditorRoot({ ref, className, dir, children }: {
194
+ readonly ref?: (element: HTMLDivElement | null) => void;
195
+ readonly className?: string | undefined;
196
+ readonly dir?: 'ltr' | 'rtl';
197
+ readonly children?: ReactNode;
198
+ }): ReactNode;
199
+ export declare const builtinIcons: Readonly<Record<string, IconComponent>>;
200
+ interface IconProps {
201
+ readonly name: string;
202
+ /** Pixel size (default 16). */
203
+ readonly size?: number;
204
+ /**
205
+ * Stroke width in screen pixels (default 1), whatever the size. Lucide measures strokes on
206
+ * its 24-unit grid, where 1 at 16px would draw 0.67px lines that blur into grey.
207
+ */
208
+ readonly strokeWidth?: number;
209
+ }
210
+ /** Renders an icon by id: registry override, then built-in, then a generic shape. */
211
+ export declare function Icon({ name, size, strokeWidth }: IconProps): ReactNode;
212
+ interface ToolButtonProps {
213
+ readonly id: string;
214
+ /** Overrides the catalog label `tool.<id>`. */
215
+ readonly label?: string;
216
+ /** Used when the catalog has no `tool.<id>` entry (e.g. the tool definition's label). */
217
+ readonly fallbackLabel?: string;
218
+ readonly icon?: string;
219
+ /** Primary shortcut, shown as the hint on the button. */
220
+ readonly shortcut?: string;
221
+ /** All shortcuts for the tooltip ("R or 2"); defaults to `shortcut`. */
222
+ readonly shortcuts?: readonly string[];
223
+ readonly showShortcut?: boolean;
224
+ }
225
+ export declare function ToolButton({ id, label, fallbackLabel, icon, shortcut, shortcuts, showShortcut }: ToolButtonProps): ReactNode;
226
+ export declare function ToolLockButton(): ReactNode;
227
+ interface ToolbarProps {
228
+ readonly start?: ReactNode;
229
+ readonly end?: ReactNode;
230
+ }
231
+ /**
232
+ * Available tools in a fixed group order (unknown custom tools after the built-ins), plus
233
+ * registered toolbar items placed by `order`. Arrow keys move between buttons.
234
+ */
235
+ export declare function Toolbar({ start, end }: ToolbarProps): ReactNode;
236
+ /**
237
+ * Styles of the selection (or of the active drawing tool's defaults), element actions and
238
+ * registered custom property editors. Mixed values show no selected option.
239
+ */
240
+ export declare function PropertiesPanel(): ReactNode;
241
+ /** Shared canvas background and grid settings (grid visibility and snapping are view toggles). */
242
+ export declare function CanvasPropertiesPanel(): ReactNode;
243
+ /**
244
+ * Excalidraw-style link editor: a popover above the single selected element. It shows the
245
+ * element's link (click to open) with edit and remove buttons, or an input while editing
246
+ * (Mod+K, "Edit link…" in the context menu, the properties action). Enter or clicking away
247
+ * saves, Escape cancels, an empty link removes it.
248
+ */
249
+ export declare function LinkEditor(): ReactNode;
250
+ /** @deprecated Renamed to {@link LinkEditor}; links are edited in a popover now. */
251
+ export declare const LinkDialog: typeof LinkEditor;
252
+ /** Edits the link of the single selected element (Mod+K). */
253
+ export declare const LINK_COMMAND = "ui.link.edit";
254
+ /** Copies the selection (or the whole drawing) to the system clipboard as a PNG image. */
255
+ export declare const COPY_AS_PNG_COMMAND = "ui.copyAsPng";
256
+ /** Copies the selection (or the whole drawing) to the system clipboard as SVG markup. */
257
+ export declare const COPY_AS_SVG_COMMAND = "ui.copyAsSvg";
258
+ /** Copies a URL that points at the single selected element (`links.elementUrl`). */
259
+ export declare const COPY_ELEMENT_LINK_COMMAND = "ui.copyElementLink";
260
+ /** Shows or hides the minimap. */
261
+ export declare const MINIMAP_COMMAND = "ui.minimap.toggle";
262
+ /** Opens or closes the main menu, which holds the canvas settings. */
263
+ export declare const CANVAS_PROPERTIES_COMMAND = "ui.canvasProperties.toggle";
264
+ interface LayersPanelProps {
265
+ /** Draw small element previews (default false). */
266
+ readonly thumbnails?: boolean;
267
+ readonly onClose?: () => void;
268
+ }
269
+ /**
270
+ * Layers, groups and elements as a virtualized tree: selection sync, rename, visibility and
271
+ * lock toggles, search, drag-and-drop reordering and moving between layers.
272
+ */
273
+ export declare function LayersPanel({ thumbnails, onClose }: LayersPanelProps): ReactNode;
274
+ interface RowBase {
275
+ /** Stable key, also used for expansion state. */
276
+ readonly key: string;
277
+ readonly depth: number;
278
+ readonly expandable: boolean;
279
+ readonly expanded: boolean;
280
+ }
281
+ interface LayerRow extends RowBase {
282
+ readonly kind: 'layer';
283
+ readonly record: LayerRecord;
284
+ readonly active: boolean;
285
+ }
286
+ interface GroupRow extends RowBase {
287
+ readonly kind: 'group';
288
+ readonly record: GroupRecord;
289
+ readonly layerId: LayerId;
290
+ readonly members: readonly ElementId[];
291
+ }
292
+ interface ElementRow extends RowBase {
293
+ readonly kind: 'element';
294
+ readonly record: ElementRecord;
295
+ readonly label: string;
296
+ readonly icon: string;
297
+ }
298
+ type TreeRow = LayerRow | GroupRow | ElementRow;
299
+ interface LayerTreeSource {
300
+ readonly layers: readonly {
301
+ readonly layer: LayerRecord;
302
+ readonly children: readonly LayerTreeSourceNode[];
303
+ }[];
304
+ readonly activeLayer: LayerId | undefined;
305
+ /** Elements of a layer from top to bottom. */
306
+ elementsOf(layerId: LayerId): readonly ElementRecord[];
307
+ /** Group chain of an element, innermost first. */
308
+ groupsOf(elementId: ElementId): readonly GroupId[];
309
+ group(id: GroupId): GroupRecord | undefined;
310
+ describe(element: ElementRecord): {
311
+ readonly label: string;
312
+ readonly icon: string;
313
+ };
314
+ }
315
+ interface LayerTreeSourceNode {
316
+ readonly layer: LayerRecord;
317
+ readonly children: readonly LayerTreeSourceNode[];
318
+ }
319
+ interface BuildOptions {
320
+ /** Keys of expanded rows; layers are expanded unless listed in `collapsed`. */
321
+ readonly expanded: ReadonlySet<string>;
322
+ readonly collapsed: ReadonlySet<string>;
323
+ /** Case-insensitive name filter; matching rows and their parents stay visible and expanded. */
324
+ readonly query?: string;
325
+ readonly type?: string;
326
+ }
327
+ /**
328
+ * Flattens layers (top layer first), groups and elements (topmost first) into visible rows.
329
+ * A group appears in each layer that holds some of its members, at its topmost member.
330
+ */
331
+ export declare function buildLayerRows(source: LayerTreeSource, options: BuildOptions): TreeRow[];
332
+ /** Index range of rows to render for a scroll position (inclusive start, exclusive end). */
333
+ export declare function visibleRange(scrollTop: number, viewportHeight: number, rowHeight: number, count: number, overscan?: number): {
334
+ readonly start: number;
335
+ readonly end: number;
336
+ };
337
+ /** Tree source backed by the public editor API. */
338
+ export declare function editorTreeSource(editor: AnyEditor): LayerTreeSource;
339
+ /**
340
+ * Registers the UI-level commands the context menu and shortcuts use: copy as PNG
341
+ * (Shift+Alt+C) / SVG, copy link to object (with a short confirmation), the minimap toggle and opening the canvas settings in the main menu (Alt+/).
342
+ * `<DefaultEditor>` renders it; custom layouts can render it too.
343
+ */
344
+ export declare function CanvasCommands(): ReactNode;
345
+ /** UI state the built-in toggles reflect; optional so hosts can build the list without it. */
346
+ interface BuiltinContextMenuState {
347
+ isOpen(panel: PanelId): boolean;
348
+ }
349
+ /**
350
+ * Built-in context menu entries, in Excalidraw's order; `t` resolves labels at render time.
351
+ * On an element: clipboard, copy as image, styles, grouping, stacking, flipping, link /
352
+ * duplicate / lock, delete. On the canvas: paste, copy as image, select all, view toggles.
353
+ */
354
+ export declare function builtinContextMenuItems(t: Translate, ui?: BuiltinContextMenuState): readonly ContextMenuItem[];
355
+ /** Menu for the current context-menu request (right click on the canvas or a panel row). */
356
+ export declare function ContextMenu(): ReactNode;
357
+ export declare function useContextMenuForCanvas(): (info: {
358
+ readonly clientX: number;
359
+ readonly clientY: number;
360
+ readonly world: {
361
+ readonly x: number;
362
+ readonly y: number;
363
+ };
364
+ readonly elementId?: ElementId;
365
+ }) => void;
366
+ /** PNG/SVG export with a preview: format, selection only, background, grid, scale, padding. */
367
+ export declare function ExportDialog({ fileName }: {
368
+ readonly fileName?: string;
369
+ }): ReactNode;
370
+ /** Opens a document file or bundle chosen by the user (replace import). */
371
+ export declare function openFile(editor: AnyEditor, file: Blob): Promise<void>;
372
+ interface MainMenuProps {
373
+ readonly items?: ReactNode;
374
+ readonly fileName?: string;
375
+ }
376
+ /** Hamburger menu: open and save files, export, shortcuts, reset, then theme and canvas settings inline. */
377
+ export declare function MainMenu({ items, fileName }: MainMenuProps): ReactNode;
378
+ /** Searchable list of tool shortcuts and keymap bindings with command labels. */
379
+ export declare function ShortcutsDialog(): ReactNode;
380
+ interface MinimapProps {
381
+ readonly width?: number;
382
+ readonly height?: number;
383
+ /** Renderers whose `minimap` hook draws custom representations. */
384
+ readonly renderers?: readonly CanvasRenderer[] | undefined;
385
+ }
386
+ /** Overview of the document; click or drag to navigate. */
387
+ export declare function Minimap({ width, height, renderers }: MinimapProps): ReactNode;
388
+ /**
389
+ * Color palette for the color picker, laid out like Excalidraw's: a 5×3 grid of color families
390
+ * picked with the keys q–t / a–g / z–b, each family (except transparent, white and black) with five
391
+ * shades picked with Shift+1–5. Shades are the open-color scale (MIT).
392
+ */
393
+ type ShadedFamily = 'gray' | 'bronze' | 'cyan' | 'blue' | 'violet' | 'grape' | 'pink' | 'green' | 'teal' | 'yellow' | 'orange' | 'red';
394
+ type ColorFamily = 'transparent' | 'white' | 'black' | ShadedFamily;
395
+ /** Lightest to darkest. */
396
+ export declare const COLOR_SHADES: Readonly<Record<ShadedFamily, readonly string[]>>;
397
+ /** The picker grid, row by row, with each cell's hotkey. */
398
+ export declare const COLOR_GRID: readonly {
399
+ readonly key: string;
400
+ readonly family: ColorFamily;
401
+ }[];
402
+ /** Shade index the grid shows for strokes (darkest) and backgrounds (light). */
403
+ export declare const DEFAULT_SHADE: {
404
+ readonly stroke: 4;
405
+ readonly background: 1;
406
+ };
407
+ type ColorKind = keyof typeof DEFAULT_SHADE;
408
+ /** Quick picks shown next to the picker button, as in Excalidraw. */
409
+ export declare const STROKE_COLORS: string[];
410
+ export declare const FILL_COLORS: string[];
411
+ /** The color a grid cell stands for at a shade index (solid families ignore it). */
412
+ export declare function familyColor(family: ColorFamily, shade: number): string;
413
+ /** The family (and shade index, for shaded families) a color belongs to, if it is in the palette. */
414
+ export declare function familyOf(color: string | undefined): {
415
+ readonly family: ColorFamily;
416
+ readonly shade: number | undefined;
417
+ } | undefined;
418
+ /** `#rgb`/`#rrggbb` (the `#` optional) as lower-case `#rrggbb`; `undefined` when invalid. */
419
+ export declare function normalizeHex(input: string): string | undefined;
420
+ /** A color chip; transparent shows a checkerboard, `undefined` (mixed values) a hatch. */
421
+ export declare function Swatch({ color }: {
422
+ readonly color: string | undefined;
423
+ }): ReactNode;
424
+ interface ColorPickerProps {
425
+ readonly label: string;
426
+ /** Current color; `undefined` when the selection has mixed values. */
427
+ readonly value: string | undefined;
428
+ /** Which shade the grid offers: dark for strokes, light for backgrounds. */
429
+ readonly kind: ColorKind;
430
+ readonly onChange: (value: string) => void;
431
+ }
432
+ /**
433
+ * Excalidraw-style color picker: the color grid (keys q–t, a–g, z–b), the active color's
434
+ * shades (Shift+1–5; none for transparent, white and black) and a hex code input with a
435
+ * pipette that copies a color from the screen (EyeDropper, where the browser has it).
436
+ */
437
+ export declare function ColorPicker({ label, value, kind, onChange }: ColorPickerProps): ReactNode;
438
+ interface ColorFieldProps {
439
+ readonly label: string;
440
+ /** Current color; `undefined` when mixed. */
441
+ readonly value: string | undefined;
442
+ /** Quick picks next to the picker button (e.g. `STROKE_COLORS`, `FILL_COLORS`). */
443
+ readonly palette: readonly string[];
444
+ readonly onChange: (value: string) => void;
445
+ /** Which shades the picker grid offers (default `'stroke'`). */
446
+ readonly kind?: ColorKind;
447
+ readonly testId?: string;
448
+ readonly disabled?: boolean;
449
+ }
450
+ /**
451
+ * Quick-pick swatches, then the current color as a button that opens the {@link ColorPicker}
452
+ * (Excalidraw's stroke and background controls).
453
+ */
454
+ export declare function ColorField({ label, value, palette, onChange, kind, testId, disabled }: ColorFieldProps): ReactNode;
455
+ /** The three quick picks next to the font picker, like Excalidraw's. */
456
+ export declare const QUICK_FONTS: readonly {
457
+ readonly id: FontId;
458
+ readonly icon: string;
459
+ }[];
460
+ type Translate$1 = ReturnType<typeof useUi>['t'];
461
+ /** Role name of a built-in id ("Hand-drawn"), else the font's own name. */
462
+ export declare function fontRoleLabel(editor: AnyEditor, t: Translate$1, id: FontId): string;
463
+ interface FontPickerProps {
464
+ /** Current font; `undefined` when mixed. */
465
+ readonly value: FontId | undefined;
466
+ readonly onChange: (id: FontId) => void;
467
+ }
468
+ /**
469
+ * Searchable list of every registered font, with the fonts the document uses first. Each name
470
+ * is drawn in its own font. Arrow keys move, Enter picks.
471
+ */
472
+ export declare function FontPicker({ value, onChange }: FontPickerProps): ReactNode;
473
+ interface FontFamilyFieldProps {
474
+ readonly value: FontId | undefined;
475
+ readonly onChange: (id: FontId) => void;
476
+ readonly testId?: string;
477
+ }
478
+ /**
479
+ * Quick picks for the hand-drawn, normal and code fonts, then a button that opens the
480
+ * {@link FontPicker}. The button is highlighted while any other font is set.
481
+ */
482
+ export declare function FontFamilyField({ value, onChange, testId }: FontFamilyFieldProps): ReactNode;
483
+ interface IconButtonProps {
484
+ readonly icon: string;
485
+ readonly label: string;
486
+ /** Shortcut(s) for the tooltip; several are joined ("R or 2"). Formatted for the platform. */
487
+ readonly shortcut?: string | readonly string[] | undefined;
488
+ readonly onClick?: () => void;
489
+ readonly pressed?: boolean;
490
+ readonly disabled?: boolean;
491
+ readonly danger?: boolean;
492
+ readonly testId?: string;
493
+ readonly className?: string;
494
+ readonly tabIndex?: number;
495
+ readonly children?: ReactNode;
496
+ }
497
+ /** Square icon button with an accessible label and a tooltip that shows the shortcut. */
498
+ export declare function IconButton({ icon, label, shortcut, onClick, pressed, disabled, danger, testId, className, tabIndex, children }: IconButtonProps): ReactNode;
499
+ export declare function Island({ children, className, label, testId, role }: {
500
+ readonly children?: ReactNode;
501
+ readonly className?: string;
502
+ readonly label?: string;
503
+ readonly testId?: string;
504
+ readonly role?: string;
505
+ }): ReactNode;
506
+ /** Formats `Mod+Shift+Z` for the platform (⌘⇧Z on macOS). */
507
+ export declare function formatShortcut(shortcut: string | undefined): string | undefined;
508
+ interface PopoverProps {
509
+ readonly open: boolean;
510
+ readonly onClose: () => void;
511
+ readonly anchor: RefObject<HTMLElement | null>;
512
+ readonly placement?: 'bottom-start' | 'bottom-end' | 'right-start' | 'top-start';
513
+ readonly label: string;
514
+ readonly role?: 'dialog' | 'menu';
515
+ readonly testId?: string;
516
+ readonly children: ReactNode;
517
+ }
518
+ /** Floating panel next to an anchor, portaled into the editor root. */
519
+ export declare function Popover({ open, onClose, anchor, placement, label, role, testId, children }: PopoverProps): ReactNode;
520
+ interface MenuEntry {
521
+ readonly id: string;
522
+ readonly label: string;
523
+ readonly icon?: string;
524
+ readonly shortcut?: string | undefined;
525
+ readonly disabled?: boolean;
526
+ readonly danger?: boolean;
527
+ readonly separatorBefore?: boolean;
528
+ /** Set for toggle items: shows a check mark while true. */
529
+ readonly checked?: boolean;
530
+ readonly onSelect: () => void;
531
+ }
532
+ export declare function MenuItems({ entries, onDone }: {
533
+ readonly entries: readonly MenuEntry[];
534
+ readonly onDone: () => void;
535
+ }): ReactNode;
536
+ interface DialogProps {
537
+ readonly open: boolean;
538
+ readonly onClose: () => void;
539
+ readonly title: string;
540
+ readonly testId?: string;
541
+ readonly wide?: boolean;
542
+ readonly children: ReactNode;
543
+ }
544
+ /** Modal dialog inside the editor: traps focus, closes on Escape, restores focus. */
545
+ export declare function Dialog({ open, onClose, title, testId, wide, children }: DialogProps): ReactNode;
546
+ interface ChoiceOption<Value extends string | number> {
547
+ readonly value: Value;
548
+ /** Accessible name and tooltip. */
549
+ readonly label: string;
550
+ readonly icon?: string;
551
+ /** Short text shown in a square button instead of an icon (e.g. "S", "XL"). */
552
+ readonly glyph?: string;
553
+ readonly swatch?: string;
554
+ }
555
+ /** Row of toggle buttons for one value; `undefined` value shows no selection (mixed). */
556
+ export declare function Choice<Value extends string | number>({ label, value, options, onChange, testId, disabled }: {
557
+ readonly label: string;
558
+ readonly value: Value | undefined;
559
+ readonly options: readonly ChoiceOption<Value>[];
560
+ readonly onChange: (value: Value) => void;
561
+ readonly testId?: string;
562
+ readonly disabled?: boolean | undefined;
563
+ }): ReactNode;
564
+ export declare function Section({ title, children }: {
565
+ readonly title: string;
566
+ readonly children: ReactNode;
567
+ }): ReactNode;
568
+ /** What a plugin adds to the default UI. */
569
+ interface UiPluginFacet {
570
+ readonly toolbar?: readonly ToolbarItem[];
571
+ readonly contextMenu?: readonly ContextMenuItem[];
572
+ /** Property editors by element type. */
573
+ readonly propertyEditors?: Readonly<Record<string, ComponentType<PropertyEditorProps>>>;
574
+ /** Icons by id (tool ids, `describe` icons). */
575
+ readonly icons?: Readonly<Record<string, IconComponent>>;
576
+ }
577
+ declare module '@drawback/core' {
578
+ interface PluginFacets {
579
+ /** Installed by the default UI of an editor with this plugin. */
580
+ readonly ui: UiPluginFacet;
581
+ }
582
+ }
583
+ /**
584
+ * Installs the `ui` facets of the editor's plugins into the UI registry and follows later
585
+ * installs and uninstalls. `<DefaultEditor>` renders it; custom layouts can render it too.
586
+ */
587
+ export declare function UiPlugins(): null;
588
+ export { type BuildOptions, type BuiltinContextMenuState, type ChoiceOption, type ColorFamily, type ColorFieldProps, type ColorKind, type ColorPickerProps, type ContextMenuContext, type ContextMenuItem, type ContextMenuRequest, type DefaultEditorComponents, type DefaultEditorProps, type DefaultEditorSlots, type DialogProps, type ElementRow, type FontFamilyFieldProps, type FontPickerProps, type GroupRow, type IconButtonProps, type IconComponent, type IconProps, LANGUAGES, type LanguageInfo, type LayerRow, type LayerTreeSource, type LayerTreeSourceNode, type LayersPanelProps, type MainMenuProps, type MenuEntry, type MessageKey, type Messages, type MinimapProps, type PanelId, type PopoverProps, type PropertyEditorProps, type ResolvedTheme, type ShadedFamily, type ThemeSetting, type ToolButtonProps, type ToolbarItem, type ToolbarProps, type Translate, type TranslateValues, type TreeRow, type UiContextValue, type UiPluginFacet, type UiProviderProps, type UiRegistry, type ZoomControlsProps, builtinMessages, createTranslator, en, loadMessages, needsMessages };