@objectifthunes/whiteboard 0.3.0 → 0.5.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.
package/README.md CHANGED
@@ -63,11 +63,28 @@ Every component is driven by `--wb-*` CSS custom properties. Override on `:root`
63
63
 
64
64
  - **Canvas:** `WhiteboardShell`, `FloatingPanel`, `Minimap`, `ZoomBar`, `ConfirmDialog`, `PanelErrorBoundary`
65
65
  - **Store / hooks:** `useWhiteboardStore`, `useWhiteboardLayout`, `computeWhiteboardFit`, `computeWhiteboardRectFocus`, `usePanelRect`, `belowPanel`, `snapToWhiteboardGrid`, `WHITEBOARD_GRID`, `cn`
66
- - **Primitives:** `Button`, `ButtonRow`, `PanelCloseButton`, `ThemeToggle`, `OverlayIconButton`, `Field`, `Label`, `Input`, `Textarea`, `Select`, `CoordGrid`, `CoordInput`, `Alert`, `Pill`, `Chip`, `TagRow`, `LoadingState`, `GeneratingOverlay`, `EmptyState`, `Stack`, `Inline`, `TitleRow`, `SplitLayout`, `IconText`, `PageShell`, `PageCard`, `PageTitle`, `CardTitle`, `SectionTitle`, `SectionDescription`, `MutedText`, `ItemCard`, `ItemList`, `List`, `PickerCard`, `PickerGrid`, `ChoiceCard`, `ChoiceGroup`, `VerticalToolbar`, `AvatarBadge`, `CanvasStage`, `ImageThumb`, `PanelSection`, `PanelTitle`
66
+ - **Primitives:** `Button`, `ButtonRow`, `PanelCloseButton`, `ThemeToggle`, `OverlayIconButton`, `Field`, `Label`, `Input`, `Textarea`, `Select`, `CoordGrid`, `CoordInput`, `Alert`, `Pill`, `Chip`, `TagRow`, `LoadingState`, `GeneratingOverlay`, `EmptyState`, `Stack`, `Inline`, `TitleRow`, `SplitLayout`, `IconText`, `PageShell`, `PageCard`, `PageTitle`, `CardTitle`, `SectionTitle`, `SectionDescription`, `MutedText`, `ItemCard`, `ItemList`, `List`, `PickerCard`, `PickerGrid`, `ChoiceCard`, `ChoiceGroup`, `VerticalToolbar`, `AvatarBadge`, `CanvasStage`, `ImageThumb`, `PanelSection`, `PanelTitle`, `Checkbox`, `Switch`, `Slider`, `NumberField`, `Toolbar`, `Surface`, `Tooltip`, `Kbd`, `Divider`
67
67
  - **Skeletons:** `Skeleton`, `LineSkeleton`, `TitleSkeleton`, `ButtonSkeleton`, `IconButtonSkeleton`, `InputSkeleton`, `SelectSkeleton`, `TextareaSkeleton`, `ChipSkeleton`, `ThumbSkeleton`, `AvatarSkeleton`, `CanvasSkeleton`, `PanelFormSkeleton`, `CardSkeleton`, `PickerGridSkeleton`, `ChoiceGroupSkeleton`
68
68
 
69
69
  See the live demo for the full prop reference and copy-pasteable examples per component.
70
70
 
71
+ ## New in 0.5
72
+
73
+ - **`Draggable` / `DraggableSurface`** — screen-space dragging for overlay chrome, no `WhiteboardShell` required. Keep your CSS anchoring; the drag is a `translate()` delta on top, so layouts stay responsive. Drags from any non-interactive area, snaps to the whiteboard grid on release, honours the global `whiteboard-snap-now` event, persists per `id` in localStorage. Double-click resets one element; `resetDraggables()` resets all.
74
+ - `Toolbar` reads slightly larger (roomier padding, `--wb-fs-md` buttons) — it's app chrome, not a panel row.
75
+
76
+ ## New in 0.4
77
+
78
+ Battle-tested additions from building a real app on the kit:
79
+
80
+ - **`Checkbox` / `Switch`** — labeled boolean rows; the input pins its own size so host globals can never stretch it.
81
+ - **`Slider`** — label left, live readout right, themed range underneath. Returns numbers.
82
+ - **`NumberField`** — labeled numeric input; clamps to min/max, never emits NaN.
83
+ - **`Toolbar`** — horizontal sibling of `VerticalToolbar` for app-chrome bars (`position="top" | "bottom" | "static"`, `end` slot).
84
+ - **`Surface`** — the plain floating overlay container (selection menus, legends, log panes) for overlays living outside a `WhiteboardShell`.
85
+ - **`Tooltip`** — CSS-only, shows on hover and keyboard focus. `Kbd` for shortcut hints, `Divider` (h/v) for separation.
86
+ - **Hardening** — `PickerCard` declares its own column layout (the global `button` style can no longer collapse it into a clipped row); native text/number inputs are now styled like `select` out of the box.
87
+
71
88
  ## Build size
72
89
 
73
90
  42 KB JS raw / ~10 KB gzip, single 30 KB CSS file. No runtime CSS-in-JS.
package/dist/index.d.ts CHANGED
@@ -92,6 +92,20 @@ declare interface CardTitleProps extends TypographyProps {
92
92
  clamp?: boolean;
93
93
  }
94
94
 
95
+ /**
96
+ * A labeled checkbox row. The input pins its own size and flex so host
97
+ * (or kit) globals like `input { flex: 1 }` can never stretch it across
98
+ * the row.
99
+ */
100
+ export declare function Checkbox({ label, hint, className, ...props }: CheckboxProps): JSX_2.Element;
101
+
102
+ declare interface CheckboxProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'type'> {
103
+ /** Sentence-case text rendered next to the box. */
104
+ label?: ReactNode;
105
+ /** Muted addition after the label, e.g. "(dirty scans)". */
106
+ hint?: ReactNode;
107
+ }
108
+
95
109
  export declare function Chip({ className, ...props }: ChipProps): JSX_2.Element;
96
110
 
97
111
  declare type ChipProps = HTMLAttributes<HTMLSpanElement>;
@@ -173,6 +187,47 @@ declare interface CoordInputProps extends Omit<InputHTMLAttributes<HTMLInputElem
173
187
  axis: string;
174
188
  }
175
189
 
190
+ /** Hairline separator; vertical inside toolbars/inlines, horizontal in stacks. */
191
+ export declare function Divider({ orientation, className, ...props }: DividerProps): JSX_2.Element;
192
+
193
+ declare interface DividerProps extends HTMLAttributes<HTMLElement> {
194
+ orientation?: 'horizontal' | 'vertical';
195
+ }
196
+
197
+ /**
198
+ * Screen-space dragging for overlay chrome — toolbars, legends, log
199
+ * panes — WITHOUT a WhiteboardShell. Keep your CSS anchoring (top/right/
200
+ * bottom/left, even percentage centring on a parent): the drag is a
201
+ * translate() delta on top of it, so layouts stay responsive and reset
202
+ * is just "delta = 0".
203
+ *
204
+ * - drags from any non-interactive area (inputs, buttons, canvases keep
205
+ * their own pointer behaviour)
206
+ * - snaps to WHITEBOARD_GRID on release; honours the global
207
+ * `whiteboard-snap-now` event dispatched by ZoomBar
208
+ * - double-click an empty area to reset one element;
209
+ * `resetDraggables()` resets them all
210
+ * - position persists per `id` in localStorage
211
+ */
212
+ export declare function Draggable({ id, snap, persist, disabled, className, style, children, ...props }: DraggableProps): JSX_2.Element;
213
+
214
+ declare interface DraggableProps extends HTMLAttributes<HTMLDivElement> {
215
+ /** Stable id — keys persistence and the reset registry. */
216
+ id: string;
217
+ /** Snap the offset to the whiteboard grid on release. Default true. */
218
+ snap?: boolean;
219
+ /** Remember the offset in localStorage. Default true. */
220
+ persist?: boolean;
221
+ disabled?: boolean;
222
+ }
223
+
224
+ /** A Surface you can drag — the overlay-panel workhorse. */
225
+ export declare function DraggableSurface({ padding, className, ...props }: DraggableSurfaceProps): JSX_2.Element;
226
+
227
+ declare interface DraggableSurfaceProps extends DraggableProps {
228
+ padding?: 'none' | 'sm' | 'md';
229
+ }
230
+
176
231
  export declare function EmptyState({ title, description, action }: EmptyStateProps): JSX_2.Element;
177
232
 
178
233
  declare interface EmptyStateProps {
@@ -265,6 +320,9 @@ declare interface ItemListProps extends HTMLAttributes<HTMLElement> {
265
320
  as?: ElementType;
266
321
  }
267
322
 
323
+ /** Keyboard-key chip for shortcut hints: <Kbd>esc</Kbd> <Kbd>⌫</Kbd>. */
324
+ export declare function Kbd({ className, ...props }: HTMLAttributes<HTMLElement>): JSX_2.Element;
325
+
268
326
  export declare function Label({ className, ...props }: LabelProps): JSX_2.Element;
269
327
 
270
328
  declare type LabelProps = LabelHTMLAttributes<HTMLLabelElement>;
@@ -297,6 +355,20 @@ export declare function MutedText({ as, size, className, ...props }: TypographyP
297
355
 
298
356
  declare type MutedTextSize = 'xs' | 'sm' | 'md';
299
357
 
358
+ /**
359
+ * Labeled numeric input. Values come back as numbers, clamped to
360
+ * [min, max] when provided; non-numeric keystrokes are ignored rather
361
+ * than emitted as NaN.
362
+ */
363
+ export declare function NumberField({ label, hint, value, onChange, min, max, step, id, className, ...props }: NumberFieldProps): JSX_2.Element;
364
+
365
+ declare interface NumberFieldProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'value' | 'onChange' | 'type'> {
366
+ label?: ReactNode;
367
+ hint?: ReactNode;
368
+ value: number;
369
+ onChange: (value: number) => void;
370
+ }
371
+
300
372
  export declare function OverlayIconButton({ className, placement, onPointerDown, onWheel, onContextMenu, ...props }: OverlayIconButtonProps): JSX_2.Element;
301
373
 
302
374
  declare interface OverlayIconButtonProps extends Omit<ComponentProps<typeof Button>, 'variant' | 'iconOnly'> {
@@ -457,6 +529,9 @@ declare interface Props_6 {
457
529
  fallbackMessage?: string;
458
530
  }
459
531
 
532
+ /** Snap every Draggable back to its anchored position (and clear persistence). */
533
+ export declare function resetDraggables(): void;
534
+
460
535
  export declare function SectionDescription({ as, className, ...props }: TypographyProps): ReactElement<any, string | JSXElementConstructor<any>>;
461
536
 
462
537
  export declare function SectionTitle({ as, className, ...props }: TypographyProps): ReactElement<any, string | JSXElementConstructor<any>>;
@@ -476,6 +551,21 @@ declare interface SkeletonProps extends HTMLAttributes<HTMLElement> {
476
551
 
477
552
  declare type SkeletonRadius = 'sm' | 'md' | 'pill';
478
553
 
554
+ /**
555
+ * The settings-panel slider pattern: label left, live readout right,
556
+ * range underneath. Numbers come back as numbers.
557
+ */
558
+ export declare function Slider({ label, display, value, onChange, className, ...props }: SliderProps): JSX_2.Element;
559
+
560
+ declare interface SliderProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'type' | 'value' | 'onChange'> {
561
+ /** Uppercase header on the left (rendered like a widget label). */
562
+ label?: ReactNode;
563
+ /** Right-aligned readout; defaults to the raw value. */
564
+ display?: ReactNode;
565
+ value: number;
566
+ onChange: (value: number) => void;
567
+ }
568
+
479
569
  export declare function snapToWhiteboardGrid(value: number): number;
480
570
 
481
571
  /**
@@ -506,6 +596,22 @@ declare interface State {
506
596
  error: Error | null;
507
597
  }
508
598
 
599
+ /**
600
+ * The plain floating surface: --wb-surface background, border, radius,
601
+ * soft shadow. For overlays that live OUTSIDE a WhiteboardShell —
602
+ * selection menus, legends, log panes — where FloatingPanel's canvas
603
+ * coupling would be wrong.
604
+ */
605
+ export declare function Surface({ as, padding, className, ...props }: SurfaceProps): ReactElement<any, string | JSXElementConstructor<any>>;
606
+
607
+ declare interface SurfaceProps extends HTMLAttributes<HTMLElement> {
608
+ as?: ElementType;
609
+ padding?: 'none' | 'sm' | 'md';
610
+ }
611
+
612
+ /** A labeled on/off switch — same API as Checkbox, slider visuals. */
613
+ export declare function Switch({ label, hint, className, ...props }: CheckboxProps): JSX_2.Element;
614
+
509
615
  /**
510
616
  * A horizontal wrapping row for chips/tags/pills/small items.
511
617
  * Replaces `<div className="element-tags-row">`, `<div className="chip-row">`,
@@ -547,6 +653,32 @@ declare interface TitleRowProps extends HTMLAttributes<HTMLDivElement> {
547
653
 
548
654
  export declare function TitleSkeleton(props: HTMLAttributes<HTMLDivElement>): JSX_2.Element;
549
655
 
656
+ /**
657
+ * Horizontal sibling of VerticalToolbar — same surface, same rhythm.
658
+ * The app-chrome bar: title, file chip, navigation, primary action.
659
+ */
660
+ export declare function Toolbar({ children, end, position, className, ...props }: ToolbarProps): JSX_2.Element;
661
+
662
+ declare interface ToolbarProps extends HTMLAttributes<HTMLElement> {
663
+ /** 'top' (fixed, centered) · 'bottom' · 'static' (position it yourself). */
664
+ position?: 'top' | 'bottom' | 'static';
665
+ /** Actions pinned to the end of the bar after a divider gap. */
666
+ end?: ReactNode;
667
+ }
668
+
669
+ /**
670
+ * CSS-only tooltip: shows on hover and on keyboard focus, no JS, no
671
+ * portal. Wraps its child inline.
672
+ */
673
+ export declare function Tooltip({ label, placement, className, children, ...props }: TooltipProps): JSX_2.Element;
674
+
675
+ declare interface TooltipProps extends HTMLAttributes<HTMLSpanElement> {
676
+ /** Bubble content. Keep it to a few words. */
677
+ label: ReactNode;
678
+ placement?: 'top' | 'bottom';
679
+ children: ReactNode;
680
+ }
681
+
550
682
  declare interface TypographyProps extends HTMLAttributes<HTMLElement> {
551
683
  as?: ElementType;
552
684
  }