@object-ui/plugin-designer 3.3.2 → 3.4.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.
@@ -0,0 +1,42 @@
1
+ import { UndoRedoState } from '../hooks/useUndoRedo';
2
+ /**
3
+ * ObjectUI
4
+ * Copyright (c) 2024-present ObjectStack Inc.
5
+ *
6
+ * This source code is licensed under the MIT license found in the
7
+ * LICENSE file in the root directory of this source tree.
8
+ */
9
+ import * as React from 'react';
10
+ export interface HistoryPanelProps<T> {
11
+ /** The undo/redo state returned by `useUndoRedo` / `useDesignerHistory`. */
12
+ history: UndoRedoState<T>;
13
+ /**
14
+ * Render each entry's label. Receives the entry itself, its index in the
15
+ * combined `[past, current, future]` timeline, and a relative position
16
+ * (`-N` for past, `0` for current, `+N` for future).
17
+ */
18
+ renderLabel?: (entry: T, index: number, position: number) => React.ReactNode;
19
+ /** Optional title shown at the top of the panel. */
20
+ title?: string;
21
+ /** Compact / minimal mode hides the title and action buttons. */
22
+ compact?: boolean;
23
+ className?: string;
24
+ }
25
+ /**
26
+ * Visual timeline of recent operations, paired with `useUndoRedo`.
27
+ *
28
+ * Renders the combined past + current + future stack as a vertical list. Each
29
+ * entry is clickable and jumps the underlying state via `history.jumpTo()`.
30
+ * The current entry is highlighted; future entries are dimmed to show that
31
+ * they will be re-applied if selected.
32
+ *
33
+ * Example:
34
+ * ```tsx
35
+ * const history = useDesignerHistory(initialDraft, { persistKey: 'designer' });
36
+ * <HistoryPanel
37
+ * history={history}
38
+ * renderLabel={(draft, idx) => `Step ${idx + 1}: ${draft.lastAction ?? 'edit'}`}
39
+ * />
40
+ * ```
41
+ */
42
+ export declare function HistoryPanel<T>({ history, renderLabel, title, compact, className, }: HistoryPanelProps<T>): import("react/jsx-runtime").JSX.Element;
@@ -13,3 +13,5 @@ export { PropertyEditor } from './PropertyEditor';
13
13
  export type { PropertyEditorProps, PropertyField } from './PropertyEditor';
14
14
  export { VersionHistory } from './VersionHistory';
15
15
  export type { VersionHistoryProps, VersionEntry } from './VersionHistory';
16
+ export { HistoryPanel } from './HistoryPanel';
17
+ export type { HistoryPanelProps } from './HistoryPanel';
@@ -8,6 +8,23 @@
8
8
  export interface UndoRedoOptions {
9
9
  /** Maximum history size */
10
10
  maxHistory?: number;
11
+ /**
12
+ * When set, the history stack (past + current + future) is persisted to
13
+ * `sessionStorage` under this key and rehydrated on the next mount. Use a
14
+ * key that is unique per draft (e.g. `designer:draft:${draftId}`) so two
15
+ * tabs editing different drafts never overwrite each other.
16
+ */
17
+ persistKey?: string;
18
+ /**
19
+ * Storage backend. Defaults to `sessionStorage` (per-tab). Pass
20
+ * `localStorage` for cross-tab persistence, or your own implementation for
21
+ * tests / electron / mobile bridges.
22
+ */
23
+ storage?: {
24
+ getItem(k: string): string | null;
25
+ setItem(k: string, v: string): void;
26
+ removeItem(k: string): void;
27
+ };
11
28
  }
12
29
  export interface UndoRedoState<T> {
13
30
  /** Current state */
@@ -20,6 +37,14 @@ export interface UndoRedoState<T> {
20
37
  undoCount: number;
21
38
  /** Number of redo steps available */
22
39
  redoCount: number;
40
+ /**
41
+ * Snapshot of the full timeline as `[...past, current, ...future]`. The
42
+ * UI <HistoryPanel/> renders this as a vertical list so users can see
43
+ * (and jump to) any previous checkpoint.
44
+ */
45
+ timeline: T[];
46
+ /** Index of `current` within `timeline`. */
47
+ currentIndex: number;
23
48
  /** Push a new state (clears redo stack) */
24
49
  push: (state: T) => void;
25
50
  /** Undo to previous state */
@@ -28,9 +53,22 @@ export interface UndoRedoState<T> {
28
53
  redo: () => void;
29
54
  /** Reset to initial state, clearing all history */
30
55
  reset: (state: T) => void;
56
+ /**
57
+ * Jump directly to a specific timeline index. Equivalent to N undo() or
58
+ * redo() calls, but performed atomically so re-renders only fire once.
59
+ */
60
+ jumpTo: (index: number) => void;
61
+ /**
62
+ * Drop persisted history from the configured storage backend. Useful when
63
+ * the underlying draft is deleted or after a successful save.
64
+ */
65
+ clearPersisted: () => void;
31
66
  }
32
67
  /**
33
68
  * Hook for undo/redo functionality using command pattern with state history.
34
69
  * Maintains a stack of past states and future states for undo/redo operations.
70
+ *
71
+ * Pass `persistKey` to keep the stack alive across page reloads — the designer
72
+ * history survives a refresh, so users don't lose their unsaved progress.
35
73
  */
36
74
  export declare function useUndoRedo<T>(initialState: T, options?: UndoRedoOptions): UndoRedoState<T>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@object-ui/plugin-designer",
3
- "version": "3.3.2",
3
+ "version": "3.4.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "description": "Visual designer plugin for Object UI with page, data model, process, and report designers plus collaborative editing.",
@@ -30,17 +30,17 @@
30
30
  "@dnd-kit/sortable": "^10.0.0",
31
31
  "@dnd-kit/utilities": "^3.2.2",
32
32
  "clsx": "^2.1.1",
33
- "lucide-react": "^1.8.0",
33
+ "lucide-react": "^1.14.0",
34
34
  "sonner": "^2.0.7",
35
35
  "tailwind-merge": "^3.5.0",
36
- "@object-ui/components": "3.3.2",
37
- "@object-ui/core": "3.3.2",
38
- "@object-ui/fields": "3.3.2",
39
- "@object-ui/i18n": "3.3.2",
40
- "@object-ui/plugin-form": "3.3.2",
41
- "@object-ui/plugin-grid": "3.3.2",
42
- "@object-ui/react": "3.3.2",
43
- "@object-ui/types": "3.3.2"
36
+ "@object-ui/core": "3.4.0",
37
+ "@object-ui/components": "3.4.0",
38
+ "@object-ui/i18n": "3.4.0",
39
+ "@object-ui/plugin-grid": "3.4.0",
40
+ "@object-ui/plugin-form": "3.4.0",
41
+ "@object-ui/fields": "3.4.0",
42
+ "@object-ui/types": "3.4.0",
43
+ "@object-ui/react": "3.4.0"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@types/node": "^25.6.0",
@@ -48,7 +48,7 @@
48
48
  "@types/react-dom": "19.2.3",
49
49
  "@vitejs/plugin-react": "^6.0.1",
50
50
  "vite": "^8.0.10",
51
- "vite-plugin-dts": "^4.5.4",
51
+ "vite-plugin-dts": "^5.0.0",
52
52
  "vitest": "^4.1.5"
53
53
  },
54
54
  "keywords": [