f1ow 0.1.1 → 0.1.3
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 +46 -39
- package/dist/components/Canvas/ConnectionPoints.d.ts +2 -0
- package/dist/components/Canvas/SelectionBox.d.ts +1 -0
- package/dist/components/StylePanel/ui.d.ts +6 -0
- package/dist/components/Toolbar/Toolbar.d.ts +1 -0
- package/dist/constants/index.d.ts +13 -0
- package/dist/f1ow.js +4250 -3812
- package/dist/f1ow.umd.cjs +9 -9
- package/dist/lib/FlowCanvasProps.d.ts +9 -0
- package/dist/types/index.d.ts +11 -0
- package/dist/utils/freehand.d.ts +58 -0
- package/package.json +10 -4
|
@@ -45,6 +45,15 @@ export interface FlowCanvasProps {
|
|
|
45
45
|
defaultStyle?: Partial<ElementStyle>;
|
|
46
46
|
/** Show/hide the toolbar */
|
|
47
47
|
showToolbar?: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Position of the toolbar:
|
|
50
|
+
* - `'bottom'` — floating at the bottom center, like tldraw (default)
|
|
51
|
+
* - `'top'` — floating at the top center, like Excalidraw
|
|
52
|
+
* - `'hidden'` — toolbar is not rendered (same as `showToolbar={false}`)
|
|
53
|
+
*/
|
|
54
|
+
toolbarPosition?: 'top' | 'bottom' | 'hidden';
|
|
55
|
+
/** Default active tool when the canvas mounts (default: 'select') */
|
|
56
|
+
defaultTool?: ToolType;
|
|
48
57
|
/** Show/hide the style panel */
|
|
49
58
|
showStylePanel?: boolean;
|
|
50
59
|
/** Show/hide the status bar */
|
package/dist/types/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export type ToolType = 'select' | 'hand' | 'rectangle' | 'ellipse' | 'diamond' |
|
|
|
2
2
|
export type ElementType = 'rectangle' | 'ellipse' | 'diamond' | 'line' | 'arrow' | 'freedraw' | 'text' | 'image';
|
|
3
3
|
export type Arrowhead = 'arrow' | 'triangle' | 'triangle_outline' | 'circle' | 'circle_outline' | 'diamond' | 'diamond_outline' | 'bar' | 'crowfoot_one' | 'crowfoot_many' | 'crowfoot_one_or_many';
|
|
4
4
|
export type LineType = 'sharp' | 'curved' | 'elbow';
|
|
5
|
+
export type FreehandStyle = 'standard' | 'pen' | 'brush' | 'pencil';
|
|
5
6
|
export interface ElementStyle {
|
|
6
7
|
strokeColor: string;
|
|
7
8
|
fillColor: string;
|
|
@@ -11,6 +12,7 @@ export interface ElementStyle {
|
|
|
11
12
|
roughness: number;
|
|
12
13
|
fontSize: number;
|
|
13
14
|
fontFamily: string;
|
|
15
|
+
freehandStyle?: FreehandStyle;
|
|
14
16
|
}
|
|
15
17
|
export interface BaseElement {
|
|
16
18
|
id: string;
|
|
@@ -143,6 +145,15 @@ export interface ArrowElement extends BaseElement {
|
|
|
143
145
|
export interface FreeDrawElement extends BaseElement {
|
|
144
146
|
type: 'freedraw';
|
|
145
147
|
points: number[];
|
|
148
|
+
/** Optional pressure values corresponding to each point (for pen/brush styles) */
|
|
149
|
+
pressures?: number[];
|
|
150
|
+
/**
|
|
151
|
+
* False while the stroke is actively being drawn — the bounding box
|
|
152
|
+
* (x, y, width, height) is set for spatial-index culling but the points
|
|
153
|
+
* are still in world coordinates (not yet normalised to be relative to x, y).
|
|
154
|
+
* Undefined / true means the stroke is finalised.
|
|
155
|
+
*/
|
|
156
|
+
isComplete?: boolean;
|
|
146
157
|
}
|
|
147
158
|
export type TextAlign = 'left' | 'center' | 'right';
|
|
148
159
|
export type VerticalAlign = 'top' | 'middle' | 'bottom';
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
export type Vec2 = [number, number];
|
|
2
|
+
export interface StrokeOptions {
|
|
3
|
+
size?: number;
|
|
4
|
+
thinning?: number;
|
|
5
|
+
smoothing?: number;
|
|
6
|
+
streamline?: number;
|
|
7
|
+
easing?: (pressure: number) => number;
|
|
8
|
+
simulatePressure?: boolean;
|
|
9
|
+
start?: {
|
|
10
|
+
cap?: boolean;
|
|
11
|
+
taper?: number | boolean;
|
|
12
|
+
easing?: (distance: number) => number;
|
|
13
|
+
};
|
|
14
|
+
end?: {
|
|
15
|
+
cap?: boolean;
|
|
16
|
+
taper?: number | boolean;
|
|
17
|
+
easing?: (distance: number) => number;
|
|
18
|
+
};
|
|
19
|
+
last?: boolean;
|
|
20
|
+
}
|
|
21
|
+
export interface StrokePoint {
|
|
22
|
+
point: Vec2;
|
|
23
|
+
pressure: number;
|
|
24
|
+
distance: number;
|
|
25
|
+
vector: Vec2;
|
|
26
|
+
runningLength: number;
|
|
27
|
+
}
|
|
28
|
+
export declare function getStroke(points: {
|
|
29
|
+
x: number;
|
|
30
|
+
y: number;
|
|
31
|
+
pressure?: number;
|
|
32
|
+
}[], options?: StrokeOptions): Vec2[];
|
|
33
|
+
/**
|
|
34
|
+
* Converts stroke outline points into an SVG path string.
|
|
35
|
+
* Uses M...Q...T pattern for smooth quadratic Bezier continuity.
|
|
36
|
+
* Ported from the freehand rendering helper.
|
|
37
|
+
*/
|
|
38
|
+
export declare function getSvgPathFromStroke(points: Vec2[], closed?: boolean): string;
|
|
39
|
+
/**
|
|
40
|
+
* Computes the axis-aligned bounding box of a flat freedraw point array
|
|
41
|
+
* `[x0, y0, x1, y1, …]`.
|
|
42
|
+
*
|
|
43
|
+
* Returns `width` / `height` clamped to a minimum of 1 so the element is
|
|
44
|
+
* always selectable even for a single-point dot.
|
|
45
|
+
*/
|
|
46
|
+
export declare function computeFreedrawBBox(points: number[]): {
|
|
47
|
+
minX: number;
|
|
48
|
+
minY: number;
|
|
49
|
+
maxX: number;
|
|
50
|
+
maxY: number;
|
|
51
|
+
width: number;
|
|
52
|
+
height: number;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Generates an SVG path string for a variable-width freehand stroke.
|
|
56
|
+
* Uses the freehand rendering helper ported for zero-dependency.
|
|
57
|
+
*/
|
|
58
|
+
export declare function getFreehandPath(points: number[], pressures: number[] | undefined, options?: StrokeOptions): string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "f1ow",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Interactive canvas drawing toolkit built on KonvaJS — drop-in React component for diagrams, sketches & whiteboards",
|
|
6
6
|
"author": "Nuumz <info@nuumz.com>",
|
|
@@ -44,9 +44,15 @@
|
|
|
44
44
|
"zustand": ">=5.0.0"
|
|
45
45
|
},
|
|
46
46
|
"peerDependenciesMeta": {
|
|
47
|
-
"konva": {
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
"konva": {
|
|
48
|
+
"optional": false
|
|
49
|
+
},
|
|
50
|
+
"react-konva": {
|
|
51
|
+
"optional": false
|
|
52
|
+
},
|
|
53
|
+
"zustand": {
|
|
54
|
+
"optional": false
|
|
55
|
+
}
|
|
50
56
|
},
|
|
51
57
|
"dependencies": {
|
|
52
58
|
"lucide-react": "^0.468.0",
|