f1ow 0.1.2 β†’ 0.1.4

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
@@ -37,14 +37,25 @@
37
37
  ## πŸ“¦ Installation
38
38
 
39
39
  ```bash
40
- npm install f1ow
41
- # or
42
- pnpm add f1ow
43
- # or
44
- yarn add f1ow
40
+ # npm
41
+ npm install f1ow konva react-konva zustand
42
+
43
+ # pnpm
44
+ pnpm add f1ow konva react-konva zustand
45
+
46
+ # yarn
47
+ yarn add f1ow konva react-konva zustand
45
48
  ```
46
49
 
47
- > **Peer dependencies:** `react` (β‰₯17), `react-dom` (β‰₯17), `konva` (β‰₯9), `react-konva` (β‰₯18), `zustand` (β‰₯5)
50
+ > `react` and `react-dom` are assumed to already be in your project. If not, add them too:
51
+ > ```bash
52
+ > npm install react react-dom
53
+ > ```
54
+
55
+ > **Optional β€” Collaboration only:** install these when using the `collaboration` prop:
56
+ > ```bash
57
+ > npm install yjs y-websocket
58
+ > ```
48
59
 
49
60
  ### Next.js / Non-Vite Bundlers
50
61
 
@@ -98,6 +109,7 @@ That's it β€” you get a full-featured canvas editor with a toolbar, style panel,
98
109
  | `width` / `height` | `number \| string` | `'100%'` | Canvas dimensions |
99
110
  | `tools` | `ToolType[]` | all | Visible tools in toolbar |
100
111
  | `defaultTool` | `ToolType` | `'select'` | Default active tool on mount |
112
+ | `defaultStyle` | `Partial<ElementStyle>` | β€” | Default drawing style for new elements |
101
113
  | `toolbarPosition` | `'top' \| 'bottom' \| 'hidden'` | `'bottom'` | Position of the main toolbar |
102
114
  | `showToolbar` | `boolean` | `true` | Show toolbar (legacy, use `toolbarPosition`) |
103
115
  | `showStylePanel` | `boolean` | `true` | Show style panel |
@@ -135,6 +147,7 @@ const ref = useRef<FlowCanvasRef>(null);
135
147
  | `setSelectedIds(ids)` | β€” | Set selection |
136
148
  | `clearSelection()` | β€” | Deselect all |
137
149
  | `setActiveTool(tool)` | β€” | Switch tool |
150
+ | `getActiveTool()` | `ToolType` | Get current active tool |
138
151
  | `undo()` / `redo()` | β€” | History navigation |
139
152
  | `zoomTo(scale)` | β€” | Set zoom level |
140
153
  | `resetView()` | β€” | Reset pan & zoom |
@@ -199,12 +212,23 @@ Append custom items or fully replace the built-in menu:
199
212
 
200
213
  ## 🀝 Collaboration (Experimental)
201
214
 
215
+ First install the optional peer dependencies:
216
+
217
+ ```bash
218
+ npm install yjs y-websocket
219
+ ```
220
+
221
+ Then pass a `CollaborationConfig` to the `collaboration` prop:
222
+
202
223
  ```tsx
203
224
  <FlowCanvas
204
225
  collaboration={{
205
- roomId: "my-room",
206
- wsUrl: "wss://my-yjs-server.example.com",
226
+ serverUrl: "wss://my-yjs-server.example.com",
227
+ roomName: "my-room",
207
228
  user: { id: "user-1", name: "Alice", color: "#e03131" },
229
+ // authToken: "...", // optional auth token
230
+ // syncDebounceMs: 50, // local→remote debounce (ms)
231
+ // awarenessThrottleMs: 100 // cursor sharing throttle (ms)
208
232
  }}
209
233
  />
210
234
  ```
@@ -8,6 +8,8 @@ interface Props {
8
8
  visible: boolean;
9
9
  /** Accent color */
10
10
  color?: string;
11
+ /** Current viewport scale for LOD */
12
+ viewportScale?: number;
11
13
  }
12
14
  declare const _default: React.NamedExoticComponent<Props>;
13
15
  export default _default;
@@ -7,6 +7,7 @@ interface Props {
7
7
  height: number;
8
8
  } | null;
9
9
  selectionColor?: string;
10
+ viewportScale?: number;
10
11
  }
11
12
  declare const _default: React.NamedExoticComponent<Props>;
12
13
  export default _default;
@@ -59,6 +59,10 @@ export declare const ButtonRow: React.FC<{
59
59
  children: React.ReactNode;
60
60
  gap?: number;
61
61
  wrap?: boolean;
62
+ /** Number of equal-width grid columns. Defaults to 4 so all button groups
63
+ * fill the full panel width without needing to specify it every time.
64
+ * Pass 0 (or false-y) to fall back to flex layout (e.g. for wrap rows). */
65
+ columns?: number;
62
66
  style?: React.CSSProperties;
63
67
  }>;
64
68
  export interface CompactPickerOption {
@@ -78,5 +82,7 @@ export interface CompactDropdownPickerProps {
78
82
  pickerRef: React.RefObject<HTMLDivElement | null>;
79
83
  /** Number of columns in the dropdown grid. Defaults to all items in a single row. */
80
84
  columns?: number;
85
+ /** Additional styles applied to the outer wrapper element */
86
+ style?: React.CSSProperties;
81
87
  }
82
88
  export declare const CompactDropdownPicker: React.FC<CompactDropdownPickerProps>;
@@ -30,6 +30,19 @@ export interface ArrowheadConfig {
30
30
  /** Small SVG-like preview character for UI */
31
31
  preview: string;
32
32
  }
33
+ export declare const FREEHAND_STYLES: readonly [{
34
+ readonly value: "standard";
35
+ readonly label: "Standard";
36
+ }, {
37
+ readonly value: "pen";
38
+ readonly label: "Pen";
39
+ }, {
40
+ readonly value: "pencil";
41
+ readonly label: "Pencil";
42
+ }, {
43
+ readonly value: "brush";
44
+ readonly label: "Brush";
45
+ }];
33
46
  export declare const ARROWHEAD_TYPES: ArrowheadConfig[];
34
47
  export interface LineTypeConfig {
35
48
  type: LineType;