@oh-just-another/react-ui 0.57.3 → 0.58.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/CHANGELOG.md +63 -0
- package/README.md +114 -14
- package/dist/.tsbuildinfo +1 -1
- package/dist/bottom-sheet.d.ts.map +1 -1
- package/dist/bottom-sheet.js +2 -2
- package/dist/bottom-sheet.js.map +1 -1
- package/dist/color-palette.d.ts +5 -5
- package/dist/color-palette.js +8 -8
- package/dist/command-palette.d.ts.map +1 -1
- package/dist/command-palette.js +25 -4
- package/dist/command-palette.js.map +1 -1
- package/dist/comments-panel.d.ts.map +1 -1
- package/dist/comments-panel.js +1 -6
- package/dist/comments-panel.js.map +1 -1
- package/dist/context-menu-controller.d.ts +3 -8
- package/dist/context-menu-controller.d.ts.map +1 -1
- package/dist/context-menu-controller.js.map +1 -1
- package/dist/context-menu.d.ts +22 -9
- package/dist/context-menu.d.ts.map +1 -1
- package/dist/context-menu.js +47 -8
- package/dist/context-menu.js.map +1 -1
- package/dist/diagram-root.d.ts.map +1 -1
- package/dist/diagram-root.js +1 -10
- package/dist/diagram-root.js.map +1 -1
- package/dist/format-time.d.ts +3 -0
- package/dist/format-time.d.ts.map +1 -0
- package/dist/format-time.js +8 -0
- package/dist/format-time.js.map +1 -0
- package/dist/frame-panel.d.ts.map +1 -1
- package/dist/frame-panel.js +2 -2
- package/dist/frame-panel.js.map +1 -1
- package/dist/help-dialog.d.ts.map +1 -1
- package/dist/help-dialog.js +1 -0
- package/dist/help-dialog.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/link-caption-editor.d.ts.map +1 -1
- package/dist/link-caption-editor.js +3 -1
- package/dist/link-caption-editor.js.map +1 -1
- package/dist/link-drop-shape-menu.d.ts.map +1 -1
- package/dist/link-drop-shape-menu.js +3 -1
- package/dist/link-drop-shape-menu.js.map +1 -1
- package/dist/link-hover-popup.d.ts.map +1 -1
- package/dist/link-hover-popup.js +13 -20
- package/dist/link-hover-popup.js.map +1 -1
- package/dist/main-menu.d.ts +2 -1
- package/dist/main-menu.d.ts.map +1 -1
- package/dist/palette.d.ts.map +1 -1
- package/dist/palette.js +4 -9
- package/dist/palette.js.map +1 -1
- package/dist/popover.d.ts.map +1 -1
- package/dist/popover.js +3 -1
- package/dist/popover.js.map +1 -1
- package/dist/portal-container.d.ts +8 -0
- package/dist/portal-container.d.ts.map +1 -0
- package/dist/portal-container.js +17 -0
- package/dist/portal-container.js.map +1 -0
- package/dist/property-panel.d.ts +1 -5
- package/dist/property-panel.d.ts.map +1 -1
- package/dist/property-panel.js +61 -12
- package/dist/property-panel.js.map +1 -1
- package/dist/selection-floating-panel.d.ts +0 -2
- package/dist/selection-floating-panel.d.ts.map +1 -1
- package/dist/selection-floating-panel.js +4 -2
- package/dist/selection-floating-panel.js.map +1 -1
- package/dist/toolbar.d.ts +0 -9
- package/dist/toolbar.d.ts.map +1 -1
- package/dist/toolbar.js +1 -1
- package/dist/toolbar.js.map +1 -1
- package/dist/tooltip.d.ts.map +1 -1
- package/dist/tooltip.js +3 -1
- package/dist/tooltip.js.map +1 -1
- package/dist/use-dismiss-timer.d.ts +6 -0
- package/dist/use-dismiss-timer.d.ts.map +1 -0
- package/dist/use-dismiss-timer.js +23 -0
- package/dist/use-dismiss-timer.js.map +1 -0
- package/dist/versioning.d.ts.map +1 -1
- package/dist/versioning.js +2 -7
- package/dist/versioning.js.map +1 -1
- package/package.json +19 -19
- package/src/styles.css +29 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,68 @@
|
|
|
1
1
|
# @oh-just-another/react-ui
|
|
2
2
|
|
|
3
|
+
## 0.58.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- b4b252b: Arrange operations for the selection. **Flip** mirrors the selection about its bounding-box centre — horizontal (`Shift+H`) and vertical (`Shift+V`); a single shape flips about its own centre. **Align** flushes two or more shapes to the left / right / top / bottom edge or the horizontal / vertical centre of their bounding box (`Alt+←/→/↑/↓` for the four edges; centres via the panel / menu). **Distribute** evenly spaces three or more shapes so the gaps between them are equal, on the horizontal (`Alt+H`) or vertical (`Alt+V`) axis, keeping the outermost shapes fixed. All three are available from the selection property panel and the right-click menu. New engine API: `Editor.flipSelection(axis)`, `Editor.alignSelection(edge)`, and `Editor.distributeSelection(axis)`.
|
|
8
|
+
- 578e728: Clear the whole canvas with `Cmd/Ctrl+Delete` (or `Backspace`), from the command palette, or the right-click menu. Because it wipes every shape and isn't undoable, it always asks for confirmation first.
|
|
9
|
+
- d20d50a: Copy and paste a shape's visual style. `Cmd/Ctrl+Alt+C` captures the fill / stroke / dash / opacity of the selected shape into an in-editor buffer; `Cmd/Ctrl+Alt+V` applies it to the current selection (one undo step). Also available from the right-click menu. New engine API: `Editor.copySelectionStyle()` / `Editor.pasteSelectionStyle()` and the `hasStyleClipboard` flag.
|
|
10
|
+
- 09a096c: Add `PortalContainerProvider` / `usePortalContainer` — floating UI (tooltips, popovers, context menus, hover chips) now portals into a configurable container instead of always `document.body`. Defaults to `document.body`, so existing usage is unchanged; a host mounting the editor in a shadow root points it at a node inside the root so portaled content stays styled.
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- 7217cac: The canvas surface no longer draws a focus ring on a mouse click. The surface
|
|
15
|
+
takes focus on press (so keyboard shortcuts work right after clicking), which
|
|
16
|
+
made it light up with an outline like a focused text input. The ring is now
|
|
17
|
+
gated on `:focus-visible`, so it appears only for keyboard focus (Tab) and never
|
|
18
|
+
for a pointer press.
|
|
19
|
+
- 60e315e: Fix the context menu (and any chrome reading the legacy `--menu-*` / `--panel` /
|
|
20
|
+
`--text` aliases) ignoring an explicit app theme. The aliases forward to the
|
|
21
|
+
`--du-*` theme variables via `var()`, but were declared only on `:root` — and a
|
|
22
|
+
`var()` inside a custom property resolves on the element where it's declared. So
|
|
23
|
+
under an OS dark preference the alias baked in `:root`'s dark value and inherited
|
|
24
|
+
that frozen colour straight past a `[data-theme="light"]` override, leaving a
|
|
25
|
+
dark menu on a light app. The aliases are now declared at every theme scope
|
|
26
|
+
(`:root`, `[data-theme="light"]`, `[data-theme="dark"]`) so each re-resolves
|
|
27
|
+
against the scoped `--du-*`.
|
|
28
|
+
- 60e315e: Fix floating chrome ignoring the app theme. The selection / property panel,
|
|
29
|
+
popovers, tooltips and the right-click context menu portal out of the editor
|
|
30
|
+
root, which also escaped the `data-theme` set there — so under an OS dark
|
|
31
|
+
preference they showed a dark surface even when the app was set to light (and
|
|
32
|
+
vice-versa). They now portal into a wrapper that mirrors the editor's theme, so
|
|
33
|
+
they always match the app. The context menu additionally portals into that
|
|
34
|
+
wrapper and its colours forward to the `--du-*` theme variables (no more
|
|
35
|
+
hard-coded dark fallbacks / hover).
|
|
36
|
+
- Updated dependencies [b4b252b]
|
|
37
|
+
- Updated dependencies [1c7cc6c]
|
|
38
|
+
- Updated dependencies [d20d50a]
|
|
39
|
+
- Updated dependencies [0152ed6]
|
|
40
|
+
- Updated dependencies [938e7c8]
|
|
41
|
+
- Updated dependencies [9673846]
|
|
42
|
+
- Updated dependencies [f370dba]
|
|
43
|
+
- Updated dependencies [1c7cc6c]
|
|
44
|
+
- Updated dependencies [e1fd495]
|
|
45
|
+
- Updated dependencies [8f00738]
|
|
46
|
+
- Updated dependencies [1c7cc6c]
|
|
47
|
+
- Updated dependencies [ff90a95]
|
|
48
|
+
- Updated dependencies [da91d59]
|
|
49
|
+
- Updated dependencies [3152317]
|
|
50
|
+
- Updated dependencies [fc47ecc]
|
|
51
|
+
- Updated dependencies [8fc6b69]
|
|
52
|
+
- Updated dependencies [f98730f]
|
|
53
|
+
- Updated dependencies [904cc09]
|
|
54
|
+
- Updated dependencies [edde5d0]
|
|
55
|
+
- Updated dependencies [1c7cc6c]
|
|
56
|
+
- Updated dependencies [c5be6e5]
|
|
57
|
+
- @oh-just-another/state@0.59.0
|
|
58
|
+
- @oh-just-another/renderer-canvas@0.59.0
|
|
59
|
+
- @oh-just-another/scene@0.59.0
|
|
60
|
+
- @oh-just-another/renderer-core@0.58.0
|
|
61
|
+
- @oh-just-another/math@0.58.0
|
|
62
|
+
- @oh-just-another/renderer-svg@0.57.2
|
|
63
|
+
- @oh-just-another/templates@0.57.2
|
|
64
|
+
- @oh-just-another/versioning@0.57.2
|
|
65
|
+
|
|
3
66
|
## 0.57.3
|
|
4
67
|
|
|
5
68
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
React 18+ wrappers around the editor — `DiagramCanvas`, `Toolbar`, `Palette`, `PropertyPanel`, plus a small set of hooks. Mount it with three lines of JSX, customize with hooks for everything else.
|
|
4
4
|
|
|
5
|
+
The React binding layer (L5) over `@oh-just-another/state`; needs React + DOM. For a single drop-in component, use `@oh-just-another/editor`.
|
|
6
|
+
|
|
5
7
|
## Install
|
|
6
8
|
|
|
7
9
|
```bash
|
|
@@ -30,25 +32,123 @@ export const App = () => (
|
|
|
30
32
|
|
|
31
33
|
`DiagramCanvas` constructs the underlying `Editor` and supplies it to every descendant via context. Toolbar / Palette / PropertyPanel are independent — drop them anywhere in the subtree, layered with normal CSS.
|
|
32
34
|
|
|
33
|
-
##
|
|
35
|
+
## Components
|
|
36
|
+
|
|
37
|
+
Every component reads the editor from context, so most take no required props.
|
|
38
|
+
|
|
39
|
+
### Mounting & layout
|
|
40
|
+
|
|
41
|
+
| Name | Purpose |
|
|
42
|
+
| -------------------------------- | ---------------------------------------------------------------- |
|
|
43
|
+
| `DiagramCanvas` | Mounts a host element, instantiates `Editor`, provides context. |
|
|
44
|
+
| `DiagramRoot` / `DiagramSurface` | Lower-level split of the canvas: provider root + render surface. |
|
|
45
|
+
| `DiagramProvider` | Standalone provider for hosts that build their own editor. |
|
|
46
|
+
| `UILayer` | Positioned overlay layer for placing chrome over the canvas. |
|
|
47
|
+
| `TopBar` / `BottomBar` | Edge-anchored bars for toolbars and status chrome. |
|
|
48
|
+
| `Sidebar` | Collapsible side container for panels. |
|
|
49
|
+
| `BottomSheet` | Sliding bottom container (touch / mobile layouts). |
|
|
50
|
+
|
|
51
|
+
### Toolbar & zoom
|
|
52
|
+
|
|
53
|
+
| Name | Purpose |
|
|
54
|
+
| ---------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- |
|
|
55
|
+
| `Toolbar` / `DEFAULT_TOOLBAR` / `DEFAULT_VERTICAL_TOOLBAR` | Declarative tool/action bar. Items: `mode`, `action`, `divider`, `undo`, `redo`. |
|
|
56
|
+
| `openImageFilePicker` | Opens the OS file picker and inserts the chosen image. |
|
|
57
|
+
| `ZoomWidget` / `FloatingZoomControls` | Composite zoom controls. |
|
|
58
|
+
| `ZoomInButton` / `ZoomOutButton` / `ResetZoomButton` / `ZoomToFitButton` / `ZoomDisplay` | Individual zoom controls. |
|
|
59
|
+
| `ResetToContentButton` | Recenters the viewport on scene content. |
|
|
60
|
+
|
|
61
|
+
### Palettes & shape catalog
|
|
62
|
+
|
|
63
|
+
| Name | Purpose |
|
|
64
|
+
| ------------------------------------------------------------------------------------------------- | -------------------------------------------------- |
|
|
65
|
+
| `Palette` | Drag-and-drop catalog of templates. |
|
|
66
|
+
| `LibraryPanel` | Browsable template library panel. |
|
|
67
|
+
| `ColorSwatchPicker` | Color swatch grid picker. |
|
|
68
|
+
| `ELEMENT_PALETTE_LIGHT` / `ELEMENT_PALETTE_DARK` / `CANVAS_PALETTE_LIGHT` / `CANVAS_PALETTE_DARK` | Built-in color palettes. |
|
|
69
|
+
| `resolvePaletteTheme` | Picks the light/dark palette for the active theme. |
|
|
70
|
+
|
|
71
|
+
### Inspectors & property panels
|
|
72
|
+
|
|
73
|
+
| Name | Purpose |
|
|
74
|
+
| ------------------------ | -------------------------------------------- |
|
|
75
|
+
| `PropertyPanel` | Inspector for the current selection. |
|
|
76
|
+
| `LinkStylePanel` | Edge/link styling controls. |
|
|
77
|
+
| `LayerPanel` | Layer list with visibility / ordering. |
|
|
78
|
+
| `FramePanel` | Frame list and controls. |
|
|
79
|
+
| `SelectionFloatingPanel` | Floating controls anchored to the selection. |
|
|
80
|
+
|
|
81
|
+
### Menus, dialogs & overlays
|
|
82
|
+
|
|
83
|
+
| Name | Purpose |
|
|
84
|
+
| -------------------------------------- | -------------------------------------------------- |
|
|
85
|
+
| `MainMenu` | Top-level application menu with submenus. |
|
|
86
|
+
| `ContextMenu` / `DEFAULT_CONTEXT_MENU` | Right-click menu over the canvas. |
|
|
87
|
+
| `CommandPalette` | Searchable command launcher. |
|
|
88
|
+
| `Modal` / `Popover` | Generic modal dialog and anchored popover. |
|
|
89
|
+
| `Tooltip` / `TooltipProvider` | Hover tooltips (wrap the subtree in the provider). |
|
|
90
|
+
| `HelpButton` / `HelpDialog` | Keyboard-shortcut / help dialog and its trigger. |
|
|
91
|
+
| `ToastHost` | Renders transient toasts; pair with `useToast`. |
|
|
92
|
+
|
|
93
|
+
### Collaboration & versioning
|
|
94
|
+
|
|
95
|
+
| Name | Purpose |
|
|
96
|
+
| ----------------------------------- | ----------------------------------------- |
|
|
97
|
+
| `CommentsPanel` / `CommentsPopover` | Thread list and anchored comment popover. |
|
|
98
|
+
| `VersionPanel` | Snapshot history browser. |
|
|
99
|
+
| `MergeDialog` | Resolve conflicts when merging versions. |
|
|
100
|
+
| `DiffPanel` | Visual diff between two scenes. |
|
|
101
|
+
|
|
102
|
+
### Editing overlays
|
|
103
|
+
|
|
104
|
+
| Name | Purpose |
|
|
105
|
+
| ------------------------------------------------------------ | -------------------------------------- |
|
|
106
|
+
| `TextEditorOverlay` / `FrameNameEditorOverlay` | In-place text editors over the canvas. |
|
|
107
|
+
| `LinkHoverPopup` / `LinkDropShapeMenu` / `LinkCaptionEditor` | Link interaction overlays. |
|
|
108
|
+
| `Markdown` | Renders markdown (comments, captions). |
|
|
109
|
+
|
|
110
|
+
### Primitives
|
|
111
|
+
|
|
112
|
+
| Name | Purpose |
|
|
113
|
+
| ----------------------------- | ---------------------------------- |
|
|
114
|
+
| `IconButton` / `ButtonGroup` | Buttons and grouped button rows. |
|
|
115
|
+
| `SegmentedControl` / `Slider` | Segmented toggle and range slider. |
|
|
116
|
+
|
|
117
|
+
## Hooks
|
|
118
|
+
|
|
119
|
+
| Name | Purpose |
|
|
120
|
+
| ------------------------------------------------------------------------ | -------------------------------------------------------------- |
|
|
121
|
+
| `useDiagram()` / `useDiagramOptional()` | Live `Editor` (imperative; no re-render on change). |
|
|
122
|
+
| `useDiagramContext()` / `useDiagramContextOptional()` | Raw context value. |
|
|
123
|
+
| `useEditorSelector(select)` | Custom selector — re-renders when the projected value changes. |
|
|
124
|
+
| `useScene()` / `useSelection()` / `useMode()` | Reactive slices of editor state. |
|
|
125
|
+
| `useHistory()` | `canUndo` / `canRedo` + `undo` / `redo`. |
|
|
126
|
+
| `useLayers()` / `useActiveLayerId()` | Layer list and active layer. |
|
|
127
|
+
| `useAnnotations()` / `useSelectedAnnotation()` / `useSelectedLink()` | Annotation and link selection state. |
|
|
128
|
+
| `useMobileLayout()` | Whether the compact / touch layout is active. |
|
|
129
|
+
| `useToast()` / `useToastOptional()` / `useEphemeralToast()` | Toast API (pair with `ToastHost`). |
|
|
130
|
+
| `useSnapshotStore()` | Snapshot store backing `VersionPanel`. |
|
|
131
|
+
| `useHelpDialogHotkey()` | Wires the help-dialog hotkey. |
|
|
132
|
+
| `useContextMenuController()` / `ContextMenuControllerProvider` | Imperative control of `ContextMenu`. |
|
|
133
|
+
| `usePaletteDropHandler()` / `usePalettePlacement()` / `usePaletteDrag()` | Palette drop / placement / drag wiring. |
|
|
134
|
+
| `getActivePaletteDrag()` / `subscribePaletteDrag()` | Read/observe the active palette drag outside React. |
|
|
135
|
+
|
|
136
|
+
## Layout constants
|
|
137
|
+
|
|
138
|
+
Tunable sizes for the built-in panels and toolbar:
|
|
139
|
+
`PALETTE_WIDTH`, `PALETTE_ITEM_SIZE`, `PROPERTY_PANEL_WIDTH`, `PROPERTY_SWATCH_SIZE`,
|
|
140
|
+
`LAYER_PANEL_WIDTH`, `LAYER_TOGGLE_ICON_SIZE`, `LAYER_SWATCH_SIZE`,
|
|
141
|
+
`COMMENTS_PANEL_WIDTH`, `TOOLBAR_SEPARATOR_HEIGHT`.
|
|
34
142
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
| `DiagramProvider` (+ `useDiagramContext`) | Standalone provider for advanced hosts that build their own editor. |
|
|
39
|
-
| `useDiagram()` | Live `Editor`. Imperative access (no re-render on change). |
|
|
40
|
-
| `useScene()` / `useSelection()` / `useMode()` / `useHistory()` | Reactive slices. `useHistory` exposes `canUndo` / `canRedo` + `undo` / `redo`. |
|
|
41
|
-
| `useEditorSelector(select)` | Build your own selector — re-renders when the projected value changes. |
|
|
42
|
-
| `Toolbar` / `DEFAULT_TOOLBAR` / `ToolbarItem` | Items: `mode`, `action`, `divider`, `undo`, `redo`. Action items receive the live editor. |
|
|
43
|
-
| `Palette` / `PaletteProps` | Drag-and-drop catalog of templates. Defaults to `defaultRegistry`. |
|
|
44
|
-
| `usePaletteDropHandler()` | Convert an HTML5 drop event on any element into `editor.addShape(template.factory(...))`. |
|
|
45
|
-
| `PropertyPanel` / `PropertyPanelProps` | Read-only inspector for the current selection. |
|
|
143
|
+
Each component also exports its `*Props` type (e.g. `ToolbarProps`, `PaletteProps`); menu, toast,
|
|
144
|
+
help, and context-menu modules additionally export their item/section types (`ToolbarItem`,
|
|
145
|
+
`ContextMenuItem`, `ToastKind`, `HelpRow`, etc.).
|
|
46
146
|
|
|
47
147
|
## Design notes
|
|
48
148
|
|
|
49
149
|
- **`<DiagramCanvas>` owns the editor's lifetime.** Created in `useLayoutEffect` so children's effects see the provider value on first paint; disposed on unmount. `initialScene` and `initialMode` are read once — runtime updates go through the editor API (`editor.loadScene`, `editor.setMode`).
|
|
50
|
-
- **Hooks subscribe via the editor's `subscribe`.**
|
|
150
|
+
- **Hooks subscribe via the editor's `subscribe`.** `Editor.setMode` calls `notify()` so `useMode` (and similar bespoke selectors) re-render on mode changes.
|
|
51
151
|
- **No global state.** Every editor instance is independent — composition via context lets multiple canvases live on the same page (useful for diff viewers, presentation modes).
|
|
52
152
|
- **Toolbar item kinds are a discriminated union.** Hosts can mix builtin `mode` / `undo` / `redo` items with arbitrary `action` items in one declarative array.
|
|
53
|
-
- **Palette uses SVG icons through `dangerouslySetInnerHTML`.** Template authors define the icon markup; same SVG goes through the canvas renderer's SVG
|
|
153
|
+
- **Palette uses SVG icons through `dangerouslySetInnerHTML`.** Template authors define the icon markup; the same SVG goes through the canvas renderer's SVG parser, so palette and canvas stay visually identical.
|
|
54
154
|
- **Tests run under `jsdom`.** `tests/setup.ts` stubs `HTMLCanvasElement.prototype.getContext`, pointer-capture, and `ResizeObserver` — enough for the editor to mount without pulling the native `canvas` npm package.
|