@drawback/ui 0.2.0-rc.20261201121350 → 0.2.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.
@@ -178,6 +178,7 @@ declare const en: {
178
178
  readonly 'layers.toggle': 'Layers';
179
179
  readonly 'layers.search': 'Search';
180
180
  readonly 'layers.add': 'Add layer';
181
+ readonly 'layers.addChild': 'Add layer inside';
181
182
  readonly 'layers.newName': 'Layer {number}';
182
183
  readonly 'layers.show': 'Show';
183
184
  readonly 'layers.hide': 'Hide';
@@ -235,31 +236,19 @@ interface LanguageInfo {
235
236
  /** Loads the catalog on first use (English is built in and has none). */
236
237
  readonly load?: () => Promise<Messages>;
237
238
  }
238
- /**
239
- * Built-in languages, offered in the main menu's language picker under their own names.
240
- * Catalogs other than English are separate chunks, loaded when a locale first needs them.
241
- */
239
+ /** Built-in languages; non-English catalogs are separate chunks loaded on first use. */
242
240
  declare const LANGUAGES: readonly LanguageInfo[];
243
- /**
244
- * Built-in catalog for a locale (`de-AT` falls back to `de`) once it has loaded, else
245
- * `undefined` (always for English). See {@link loadMessages}.
246
- */
241
+ /** Loaded built-in catalog (`de-AT` falls back to `de`), else `undefined` (always for English). */
247
242
  declare function builtinMessages(locale: string): Messages | undefined;
248
243
  /** Whether `locale` has a built-in catalog that is not loaded yet. */
249
244
  declare function needsMessages(locale: string): boolean;
250
- /**
251
- * Loads the built-in catalog for `locale` (once; later calls share the result). Await it
252
- * before mounting to render a non-English editor without first showing English.
253
- */
245
+ /** Loads a locale's built-in catalog once; await it before mounting to avoid an English flash. */
254
246
  declare function loadMessages(locale: string): Promise<Messages | undefined>;
255
247
  type Messages = { readonly [Key in MessageKey]?: string; } & {
256
248
  readonly [key: string]: string | undefined;
257
249
  };
258
250
  type TranslateValues = Readonly<Record<string, string | number>>;
259
251
  type Translate = (key: MessageKey | (string & {}), values?: TranslateValues) => string;
260
- /**
261
- * Translator over a message catalog: `{name}` interpolation and
262
- * `{count, plural, one {…} other {…}}` with `#` for the number (`Intl.PluralRules`).
263
- */
252
+ /** Translator with `{name}` interpolation and `{count, plural, …}` (`#` is the number). */
264
253
  declare function createTranslator(messages?: Messages, locale?: string): Translate;
265
254
  export { Translate as a, createTranslator as c, needsMessages as d, Messages as i, en as l, LanguageInfo as n, TranslateValues as o, MessageKey as r, builtinMessages as s, LANGUAGES as t, loadMessages as u };
package/dist/index.d.mts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { CanvasRenderer, CanvasView, MountCanvasOptions } from "@drawback/canvas";
2
2
  import { AnyEditor, ElementId, ElementRecord, FontId, GroupId, GroupRecord, LayerId, LayerRecord, Point } from "@drawback/core";
3
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";
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-B5Wcit0y.mjs";
5
5
  interface ToolbarItem {
6
6
  readonly id: string;
7
7
  /** Position among tools; built-ins use 100–1000 in steps of 100. */
@@ -116,10 +116,7 @@ interface UiProviderProps {
116
116
  }
117
117
  /** Resolves `'system'` through `prefers-color-scheme`, following changes. */
118
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
- */
119
+ /** UI strings, registrations, hidden controls, theme and panel state. */
123
120
  export declare function UiProvider({ messages, locale, onLocaleChange, dir, registry, hidden, theme, onThemeChange, portalContainer, initialOpen, children }: UiProviderProps): ReactNode;
124
121
  export declare function useUi(): UiContextValue;
125
122
  export declare function useT(): Translate;
@@ -181,15 +178,9 @@ interface DefaultEditorProps {
181
178
  /** Called once the canvas view is mounted and sized. */
182
179
  readonly onMount?: (view: CanvasView) => void;
183
180
  }
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
- */
181
+ /** Complete editor: canvas plus default controls, each of which can be hidden or replaced. */
188
182
  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 `.db-editor`
191
- * class all styles are scoped to. Opens the shortcut reference on `?`.
192
- */
183
+ /** Scoped root for UI components: theme, direction and `.db-editor`; `?` opens shortcuts. */
193
184
  export declare function EditorRoot({ ref, className, dir, children }: {
194
185
  readonly ref?: (element: HTMLDivElement | null) => void;
195
186
  readonly className?: string | undefined;
@@ -201,10 +192,7 @@ interface IconProps {
201
192
  readonly name: string;
202
193
  /** Pixel size (default 16). */
203
194
  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
- */
195
+ /** Screen-pixel stroke width (default 1); Lucide's 24-unit strokes would blur at 16px. */
208
196
  readonly strokeWidth?: number;
209
197
  }
210
198
  /** Renders an icon by id: registry override, then built-in, then a generic shape. */
@@ -228,24 +216,13 @@ interface ToolbarProps {
228
216
  readonly start?: ReactNode;
229
217
  readonly end?: ReactNode;
230
218
  }
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
- */
219
+ /** Tools in fixed group order plus custom items by `order`; arrow keys move between them. */
235
220
  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
- */
221
+ /** Selection styles (or tool defaults), actions and custom editors; mixed values show none. */
240
222
  export declare function PropertiesPanel(): ReactNode;
241
223
  /** Shared canvas background and grid settings (grid visibility and snapping are view toggles). */
242
224
  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
- */
225
+ /** Excalidraw-style link editor popover above the single selected element. */
249
226
  export declare function LinkEditor(): ReactNode;
250
227
  /** @deprecated Renamed to {@link LinkEditor}; links are edited in a popover now. */
251
228
  export declare const LinkDialog: typeof LinkEditor;
@@ -266,10 +243,7 @@ interface LayersPanelProps {
266
243
  readonly thumbnails?: boolean;
267
244
  readonly onClose?: () => void;
268
245
  }
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
- */
246
+ /** Virtualized layers tree with rename, toggles, search and drag-and-drop. */
273
247
  export declare function LayersPanel({ thumbnails, onClose }: LayersPanelProps): ReactNode;
274
248
  interface RowBase {
275
249
  /** Stable key, also used for expansion state. */
@@ -324,10 +298,7 @@ interface BuildOptions {
324
298
  readonly query?: string;
325
299
  readonly type?: string;
326
300
  }
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
- */
301
+ /** Visible rows, topmost first; a group shows in each layer at its topmost member. */
331
302
  export declare function buildLayerRows(source: LayerTreeSource, options: BuildOptions): TreeRow[];
332
303
  /** Index range of rows to render for a scroll position (inclusive start, exclusive end). */
333
304
  export declare function visibleRange(scrollTop: number, viewportHeight: number, rowHeight: number, count: number, overscan?: number): {
@@ -336,21 +307,13 @@ export declare function visibleRange(scrollTop: number, viewportHeight: number,
336
307
  };
337
308
  /** Tree source backed by the public editor API. */
338
309
  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
- */
310
+ /** Registers UI commands (copy as image, copy link, minimap, canvas settings). */
344
311
  export declare function CanvasCommands(): ReactNode;
345
312
  /** UI state the built-in toggles reflect; optional so hosts can build the list without it. */
346
313
  interface BuiltinContextMenuState {
347
314
  isOpen(panel: PanelId): boolean;
348
315
  }
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
- */
316
+ /** Built-in context menu entries in Excalidraw's order; `t` resolves labels at render time. */
354
317
  export declare function builtinContextMenuItems(t: Translate, ui?: BuiltinContextMenuState): readonly ContextMenuItem[];
355
318
  /** Menu for the current context-menu request (right click on the canvas or a panel row). */
356
319
  export declare function ContextMenu(): ReactNode;
@@ -385,11 +348,7 @@ interface MinimapProps {
385
348
  }
386
349
  /** Overview of the document; click or drag to navigate. */
387
350
  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
- */
351
+ /** Excalidraw-style palette: 5×3 families (q–t/a–g/z–b), five open-color shades each (MIT). */
393
352
  type ShadedFamily = 'gray' | 'bronze' | 'cyan' | 'blue' | 'violet' | 'grape' | 'pink' | 'green' | 'teal' | 'yellow' | 'orange' | 'red';
394
353
  type ColorFamily = 'transparent' | 'white' | 'black' | ShadedFamily;
395
354
  /** Lightest to darkest. */
@@ -429,11 +388,7 @@ interface ColorPickerProps {
429
388
  readonly kind: ColorKind;
430
389
  readonly onChange: (value: string) => void;
431
390
  }
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
- */
391
+ /** Excalidraw-style picker: grid (q–t/a–g/z–b), shades (Shift+1–5), hex input, pipette. */
437
392
  export declare function ColorPicker({ label, value, kind, onChange }: ColorPickerProps): ReactNode;
438
393
  interface ColorFieldProps {
439
394
  readonly label: string;
@@ -447,10 +402,7 @@ interface ColorFieldProps {
447
402
  readonly testId?: string;
448
403
  readonly disabled?: boolean;
449
404
  }
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
- */
405
+ /** Quick-pick swatches plus a button that opens the {@link ColorPicker}. */
454
406
  export declare function ColorField({ label, value, palette, onChange, kind, testId, disabled }: ColorFieldProps): ReactNode;
455
407
  /** The three quick picks next to the font picker, like Excalidraw's. */
456
408
  export declare const QUICK_FONTS: readonly {
@@ -465,20 +417,14 @@ interface FontPickerProps {
465
417
  readonly value: FontId | undefined;
466
418
  readonly onChange: (id: FontId) => void;
467
419
  }
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
- */
420
+ /** Searchable font list, document fonts first, each name drawn in its own font. */
472
421
  export declare function FontPicker({ value, onChange }: FontPickerProps): ReactNode;
473
422
  interface FontFamilyFieldProps {
474
423
  readonly value: FontId | undefined;
475
424
  readonly onChange: (id: FontId) => void;
476
425
  readonly testId?: string;
477
426
  }
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
- */
427
+ /** Hand/normal/code quick picks plus a {@link FontPicker} button, lit for any other font. */
482
428
  export declare function FontFamilyField({ value, onChange, testId }: FontFamilyFieldProps): ReactNode;
483
429
  interface IconButtonProps {
484
430
  readonly icon: string;
@@ -580,9 +526,6 @@ declare module '@drawback/core' {
580
526
  readonly ui: UiPluginFacet;
581
527
  }
582
528
  }
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
- */
529
+ /** Installs the editor plugins' `ui` facets into the registry and follows (un)installs. */
587
530
  export declare function UiPlugins(): null;
588
531
  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 };