@bemedev/mind-flow 0.0.1 → 0.1.1

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.
Files changed (45) hide show
  1. package/README.md +95 -0
  2. package/lib/helpers/createContext.d.ts +8 -11
  3. package/lib/helpers/createContext.d.ts.map +1 -1
  4. package/lib/index.cjs.js +1 -1
  5. package/lib/index.es.js +240 -235
  6. package/lib/server.cjs.js +181 -121
  7. package/lib/server.es.js +181 -121
  8. package/lib/services/main.machine.d.ts +7 -9
  9. package/lib/services/main.machine.d.ts.map +1 -1
  10. package/lib/services/main.typings.d.ts +3 -3
  11. package/lib/services/main.typings.d.ts.map +1 -1
  12. package/lib/ui/Flow.d.ts +2 -2
  13. package/lib/ui/Flow.d.ts.map +1 -1
  14. package/lib/ui/components/Bounds.d.ts +4 -4
  15. package/lib/ui/components/Bounds.d.ts.map +1 -1
  16. package/lib/ui/components/EdgeComponent.d.ts +2 -2
  17. package/lib/ui/components/EdgeComponent.d.ts.map +1 -1
  18. package/lib/ui/components/EdgesBoard.d.ts +2 -2
  19. package/lib/ui/components/EdgesBoard.d.ts.map +1 -1
  20. package/lib/ui/components/FlowChart.context.d.ts +10 -18
  21. package/lib/ui/components/FlowChart.context.d.ts.map +1 -1
  22. package/lib/ui/components/FlowChart.d.ts +4 -10
  23. package/lib/ui/components/FlowChart.d.ts.map +1 -1
  24. package/lib/ui/components/FlowChart.data.d.ts +10 -11
  25. package/lib/ui/components/FlowChart.data.d.ts.map +1 -1
  26. package/lib/ui/components/NodeComponent.d.ts +2 -2
  27. package/lib/ui/components/NodeComponent.d.ts.map +1 -1
  28. package/lib/ui/components/NodesBoard.d.ts +2 -2
  29. package/lib/ui/components/NodesBoard.d.ts.map +1 -1
  30. package/lib/ui/components/classes.d.ts +2 -2
  31. package/package.json +3 -9
  32. package/src/README.md +2 -2
  33. package/src/helpers/createContext.ts +8 -11
  34. package/src/services/main.machine.ts +18 -46
  35. package/src/services/main.typings.ts +3 -3
  36. package/src/ui/Flow.tsx +3 -2
  37. package/src/ui/components/Bounds.tsx +35 -44
  38. package/src/ui/components/EdgeComponent.tsx +7 -8
  39. package/src/ui/components/EdgesBoard.tsx +3 -2
  40. package/src/ui/components/FlowChart.context.ts +75 -82
  41. package/src/ui/components/FlowChart.data.ts +12 -15
  42. package/src/ui/components/FlowChart.tsx +6 -11
  43. package/src/ui/components/NodeComponent.tsx +13 -25
  44. package/src/ui/components/NodesBoard.tsx +120 -111
  45. package/src/ui/components/classes.ts +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"main.typings.d.ts","sourceRoot":"","sources":["../../src/services/main.typings.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAEnD,qDAAqD;AACrD,eAAO,MAAM,KAAK;;;EAAqC,CAAC;AAExD,uEAAuE;AACvE,MAAM,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,KAAK,CAAC,CAAC;AAEzC,oEAAoE;AACpE,eAAO,MAAM,UAAU;;;;;;;;;EAGpB,CAAC;AAEJ,6CAA6C;AAC7C,eAAO,MAAM,WAAW;;;EAAyC,CAAC;AAElE,gEAAgE;AAChE,eAAO,MAAM,QAAQ;;;;;;;;;;EAIlB,CAAC;AAEJ,gEAAgE;AAChE,eAAO,MAAM,QAAQ;;;EAAc,CAAC;AAEpC,+EAA+E;AAC/E,eAAO,MAAM,UAAU;;;;;;;;;;;;EAMpB,CAAC;AAEJ;;;GAGG;AACH,eAAO,MAAM,MAAM;;;;;EAKjB,CAAC;AAEH,yEAAyE;AACzE,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO,MAAM,CAAC,CAAC"}
1
+ {"version":3,"file":"main.typings.d.ts","sourceRoot":"","sources":["../../src/services/main.typings.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAEnD,qDAAqD;AACrD,eAAO,MAAM,KAAK;;;EAAqC,CAAC;AAExD,uEAAuE;AACvE,MAAM,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,KAAK,CAAC,CAAC;AAEzC,oEAAoE;AACpE,eAAO,MAAM,UAAU;;;;;;;;;EAGpB,CAAC;AAEJ,8CAA8C;AAC9C,eAAO,MAAM,WAAW;;;EAAyC,CAAC;AAElE,gEAAgE;AAChE,eAAO,MAAM,QAAQ;;;;;;;;;;EAIlB,CAAC;AAEJ,gEAAgE;AAChE,eAAO,MAAM,QAAQ;;;EAAc,CAAC;AAEpC,+EAA+E;AAC/E,eAAO,MAAM,UAAU;;;;;;;;;;;;EAMpB,CAAC;AAEJ;;;GAGG;AACH,eAAO,MAAM,MAAM;;;;;EAKjB,CAAC;AAEH,yEAAyE;AACzE,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO,MAAM,CAAC,CAAC"}
package/lib/ui/Flow.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { Component } from 'solid-js';
2
2
  import { FlowProps } from './components/FlowChart';
3
3
  /**
4
- * Root Flow component wrapping the {@linkcode FlowChart} inside the flow
5
- * context provider.
4
+ * Root Flow component wrapping the {@linkcode FlowChart} inside the flow context
5
+ * provider.
6
6
  *
7
7
  * @param props - Flow chart configuration and callbacks of type
8
8
  * {@linkcode FlowProps}.
@@ -1 +1 @@
1
- {"version":3,"file":"Flow.d.ts","sourceRoot":"","sources":["../../src/ui/Flow.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAa,KAAK,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAGnE;;;;;;;;GAQG;AACH,eAAO,MAAM,IAAI,EAAE,SAAS,CAAC,SAAS,CAIrC,CAAC"}
1
+ {"version":3,"file":"Flow.d.ts","sourceRoot":"","sources":["../../src/ui/Flow.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1C,OAAO,EAAa,KAAK,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAGnE;;;;;;;;GAQG;AACH,eAAO,MAAM,IAAI,EAAE,SAAS,CAAC,SAAS,CAIrC,CAAC"}
@@ -1,10 +1,10 @@
1
1
  import { Component } from 'solid-js';
2
2
  /**
3
- * Drag boundary transformer component that clamps draggable nodes within
4
- * container scroll bounds.
3
+ * Drag boundary transformer component that clamps draggable nodes within container
4
+ * scroll bounds.
5
5
  *
6
- * @returns `null` as this component performs side-effect transformer
7
- * registrations only.
6
+ * @returns `null` as this component performs side-effect transformer registrations
7
+ * only.
8
8
  */
9
9
  export declare const DragBounds: Component;
10
10
  //# sourceMappingURL=Bounds.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Bounds.d.ts","sourceRoot":"","sources":["../../../src/ui/components/Bounds.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,UAAU,CAAC;AAI1C;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,EAAE,SAuExB,CAAC"}
1
+ {"version":3,"file":"Bounds.d.ts","sourceRoot":"","sources":["../../../src/ui/components/Bounds.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,UAAU,CAAC;AAK1C;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,EAAE,SAgExB,CAAC"}
@@ -8,8 +8,8 @@ type Props = {
8
8
  isNew?: boolean;
9
9
  } & Vector;
10
10
  /**
11
- * SVG edge component rendering bezier curves and delete interaction
12
- * handles for node connections.
11
+ * SVG edge component rendering bezier curves and delete interaction handles for node
12
+ * connections.
13
13
  *
14
14
  * @param props - Edge properties of type {@linkcode Props}.
15
15
  *
@@ -1 +1 @@
1
- {"version":3,"file":"EdgeComponent.d.ts","sourceRoot":"","sources":["../../../src/ui/components/EdgeComponent.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAoC,MAAM,UAAU,CAAC;AACvE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAG1D,0EAA0E;AAC1E,KAAK,KAAK,GAAG;IACX,qCAAqC;IACrC,EAAE,EAAE,MAAM,CAAC;IACX,gEAAgE;IAChE,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,GAAG,MAAM,CAAC;AAuBX;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,EAAE,SAAS,CAAC,KAAK,CA+D1C,CAAC"}
1
+ {"version":3,"file":"EdgeComponent.d.ts","sourceRoot":"","sources":["../../../src/ui/components/EdgeComponent.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAoC,MAAM,UAAU,CAAC;AAEvE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAG1D,0EAA0E;AAC1E,KAAK,KAAK,GAAG;IACX,qCAAqC;IACrC,EAAE,EAAE,MAAM,CAAC;IACX,gEAAgE;IAChE,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,GAAG,MAAM,CAAC;AAuBX;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,EAAE,SAAS,CAAC,KAAK,CA6D1C,CAAC"}
@@ -1,7 +1,7 @@
1
1
  import { Component } from 'solid-js';
2
2
  /**
3
- * SVG board overlay component that renders all active connecting edges and
4
- * ongoing edge creation previews.
3
+ * SVG board overlay component that renders all active connecting edges and ongoing
4
+ * edge creation previews.
5
5
  *
6
6
  * @returns The rendered SVG JSX element.
7
7
  */
@@ -1 +1 @@
1
- {"version":3,"file":"EdgesBoard.d.ts","sourceRoot":"","sources":["../../../src/ui/components/EdgesBoard.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EAMV,MAAM,UAAU,CAAC;AAIlB;;;;;GAKG;AACH,eAAO,MAAM,UAAU,EAAE,SAsCxB,CAAC"}
1
+ {"version":3,"file":"EdgesBoard.d.ts","sourceRoot":"","sources":["../../../src/ui/components/EdgesBoard.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EAMV,MAAM,UAAU,CAAC;AAKlB;;;;;GAKG;AACH,eAAO,MAAM,UAAU,EAAE,SAsCxB,CAAC"}
@@ -1,4 +1,4 @@
1
- import { Point } from '../../services/main.typings';
1
+ import { Point, Vector } from '../../services/main.typings';
2
2
  /** Layout dimensions and handle offset coordinates for a flowchart node. */
3
3
  type Dimensions = {
4
4
  /** Node width in pixels. */
@@ -15,21 +15,13 @@ type Dimensions = {
15
15
  inputOffset?: Point;
16
16
  };
17
17
  /** Connection edge coordinate representation between two endpoints. */
18
- export type Edge = {
18
+ type Edge = {
19
19
  /** Source node identifier. */
20
20
  from: string;
21
- /** Starting X-coordinate. */
22
- x0: number;
23
- /** Starting Y-coordinate. */
24
- y0: number;
25
- /** Ending X-coordinate. */
26
- x1: number;
27
- /** Ending Y-coordinate. */
28
- y1: number;
29
- };
21
+ } & Vector;
30
22
  /**
31
- * Solid Context Provider component and hook for accessing flowchart board
32
- * state, services, and zoom.
23
+ * Solid Context Provider component and hook for accessing flowchart board state,
24
+ * services, and zoom.
33
25
  */
34
26
  export declare const Provider: import('solid-js').ParentComponent, useFlow: () => {
35
27
  readonly dimensions: readonly [import('solid-js').Accessor<Record<string, Dimensions>>, import('solid-js').Setter<Record<string, Dimensions>>];
@@ -67,17 +59,12 @@ export declare const Provider: import('solid-js').ParentComponent, useFlow: () =
67
59
  };
68
60
  readonly working: {
69
61
  readonly on: {
70
- readonly MOVE: {
71
- readonly actions: readonly ["moveNode", "buildUI"];
72
- readonly target: "/construction";
73
- };
74
62
  readonly MOVE_IMMEDIATE: {
75
63
  readonly actions: readonly [{
76
64
  readonly name: "buildImmediateUI";
77
65
  readonly description: "Must be in the ui";
78
66
  }];
79
67
  };
80
- readonly UPDATE_UI: "/construction";
81
68
  readonly ADD_CHILD: {
82
69
  readonly actions: readonly ["generateID", {
83
70
  readonly name: "placeChild";
@@ -99,6 +86,10 @@ export declare const Provider: import('solid-js').ParentComponent, useFlow: () =
99
86
  }, "linkSibling"];
100
87
  readonly target: "/construction";
101
88
  };
89
+ readonly MOVE: {
90
+ readonly actions: readonly ["moveNode", "buildUI"];
91
+ readonly target: "/construction";
92
+ };
102
93
  readonly ADD_EDGE: {
103
94
  readonly actions: readonly ["addEdge"];
104
95
  readonly target: "/construction";
@@ -1223,6 +1214,7 @@ export declare const Provider: import('solid-js').ParentComponent, useFlow: () =
1223
1214
  };
1224
1215
  }>>;
1225
1216
  readonly zoom: import('solid-js').Signal<number>;
1217
+ readonly clampPosition: (x: number, y: number, nodeWidth?: number, nodeHeight?: number) => Point;
1226
1218
  };
1227
1219
  export {};
1228
1220
  //# sourceMappingURL=FlowChart.context.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"FlowChart.context.d.ts","sourceRoot":"","sources":["../../../src/ui/components/FlowChart.context.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,KAAK,EAAU,MAAM,6BAA6B,CAAC;AAQjE,4EAA4E;AAC5E,KAAK,UAAU,GAAG;IAChB,4BAA4B;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,6BAA6B;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,iEAAiE;IACjE,MAAM,EAAE,KAAK,CAAC;IACd,gEAAgE;IAChE,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,qEAAqE;IACrE,YAAY,CAAC,EAAE,KAAK,CAAC;IACrB,oEAAoE;IACpE,WAAW,CAAC,EAAE,KAAK,CAAC;CACrB,CAAC;AAEF,uEAAuE;AACvE,MAAM,MAAM,IAAI,GAAG;IACjB,8BAA8B;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,6BAA6B;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,6BAA6B;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,2BAA2B;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,2BAA2B;IAC3B,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AAWF;;;GAGG;AACH,eAAO,MAAO,QAAQ,sCAAE,OAAO;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bemedev/app/typings';
2
2
  import { Component } from 'solid-js';
3
3
  import { edgeJSON, nodeJSON } from '../../services/main.typings';
4
- /**
5
- * Serialized node properties type inferred from schema
6
- * {@linkcode nodeJSON}.
7
- */
4
+ /** Serialized node properties type inferred from schema {@linkcode nodeJSON}. */
8
5
  export type NodeProps = inferT<typeof nodeJSON>;
9
- /**
10
- * Serialized edge properties type inferred from schema
11
- * {@linkcode edgeJSON}.
12
- */
6
+ /** Serialized edge properties type inferred from schema {@linkcode edgeJSON}. */
13
7
  export type EdgeProps = inferT<typeof edgeJSON>;
14
8
  /**
15
9
  * Configuration options and callback handlers for the {@linkcode FlowChart}
@@ -51,8 +45,8 @@ export type FlowProps = {
51
45
  onEdgeDeleted?: (edgeId: string) => void;
52
46
  };
53
47
  /**
54
- * Flowchart board canvas component that renders interactive nodes, edges,
55
- * pan/zoom, and toolbar controls.
48
+ * Flowchart board canvas component that renders interactive nodes, edges, pan/zoom,
49
+ * and toolbar controls.
56
50
  *
57
51
  * @param props - Flowchart configuration and event handlers of type
58
52
  * {@linkcode FlowProps}.
@@ -1 +1 @@
1
- {"version":3,"file":"FlowChart.d.ts","sourceRoot":"","sources":["../../../src/ui/components/FlowChart.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAsB,MAAM,UAAU,CAAC;AACzD,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAKtE;;;GAGG;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,OAAO,QAAQ,CAAC,CAAC;AAEhD;;;GAGG;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,OAAO,QAAQ,CAAC,CAAC;AAEhD;;;GAGG;AACH,MAAM,MAAM,SAAS,GAAG;IACtB,kEAAkE;IAClE,MAAM,CAAC,EAAE;QACP,KAAK,CAAC,EAAE,CAAC,SAAS,GAAG;YAA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EAAE,EAAE,MAAM,CAAA;SAAE,CAAC,EAAE,CAAC;KACxC,CAAC;IACF;;;;OAIG;IACH,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,SAAS,KAAK,IAAI,CAAC;IACxC;;;;OAIG;IACH,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC;;;;OAIG;IACH,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,SAAS,KAAK,IAAI,CAAC;IACxC;;;;OAIG;IACH,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;CAC1C,CAAC;AAIF;;;;;;;;GAQG;AACH,eAAO,MAAM,SAAS,EAAE,SAAS,CAAC,SAAS,CA6C1C,CAAC"}
@@ -1,8 +1,5 @@
1
1
  import { NodeProps } from './FlowChart';
2
- /**
3
- * Horizontal gap in pixels between a parent node and newly created child
4
- * node.
5
- */
2
+ /** Horizontal gap in pixels between a parent node and newly created child node. */
6
3
  export declare const PARENT_CHILD_GAP_WIDTH = 100;
7
4
  /** Border width in pixels for a node container. */
8
5
  export declare const NODE_BORDER_WIDTH = 1.5;
@@ -27,10 +24,7 @@ export declare const DEFAULT_INPUT_OFFSET: {
27
24
  x: number;
28
25
  y: number;
29
26
  };
30
- /**
31
- * Dimensions representing width and height of the flow chart container
32
- * canvas.
33
- */
27
+ /** Dimensions representing width and height of the flow chart container canvas. */
34
28
  export declare const CONTAINER_DIMENSIONS: {
35
29
  WIDTH: number;
36
30
  HEIGHT: number;
@@ -51,8 +45,8 @@ export declare const TOOLBAR_TOP_OFFSET = 30;
51
45
  /** Safety buffer in pixels applied above the toolbar. */
52
46
  export declare const TOOLBAR_BUFFER = 5;
53
47
  /**
54
- * Boundary padding constraints for node dragging and positioning within
55
- * the viewport.
48
+ * Boundary padding constraints for node dragging and positioning within the
49
+ * viewport.
56
50
  */
57
51
  export declare const BOUNDS_CONSTRAINTS: {
58
52
  horizontal: number;
@@ -60,7 +54,12 @@ export declare const BOUNDS_CONSTRAINTS: {
60
54
  };
61
55
  /** Multiplier factor used to compute canvas virtual scroll dimensions. */
62
56
  export declare const CANVAS_FACTOR = 5;
63
- /** Default node items provided when no initial configuration is given. */
57
+ /** Multiplier factor used to compute canvas scroll dimensions. */
58
+ export declare const SCROLL_MULTIPLIER = 3;
59
+ /**
60
+ * Default node items of type {@linkcode NodeProps} provided when no initial
61
+ * configuration is given.
62
+ */
64
63
  export declare const DEFAULT_NODES: (NodeProps & {
65
64
  id: string;
66
65
  })[];
@@ -1 +1 @@
1
- {"version":3,"file":"FlowChart.data.d.ts","sourceRoot":"","sources":["../../../src/ui/components/FlowChart.data.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C;;;GAGG;AACH,eAAO,MAAM,sBAAsB,MAAM,CAAC;AAG1C,mDAAmD;AACnD,eAAO,MAAM,iBAAiB,MAAM,CAAC;AAErC,sDAAsD;AACtD,eAAO,MAAM,WAAW,KAAK,CAAC;AAE9B,oDAAoD;AACpD,eAAO,MAAM,aAAa,QAAkB,CAAC;AAE7C,+DAA+D;AAC/D,eAAO,MAAM,iBAAiB,KAAK,CAAC;AAEpC,kEAAkE;AAClE,eAAO,MAAM,yBAAyB,KAAK,CAAC;AAE5C,sDAAsD;AACtD,eAAO,MAAM,eAAe,QAAoC,CAAC;AAEjE,mEAAmE;AACnE,eAAO,MAAM,sBAAsB,QAC4B,CAAC;AAEhE,+DAA+D;AAC/D,eAAO,MAAM,sBAAsB,QAA0B,CAAC;AAE9D,+DAA+D;AAC/D,eAAO,MAAM,sBAAsB,QAAkB,CAAC;AAEtD,kEAAkE;AAClE,eAAO,MAAM,oBAAoB;;;CAGhC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,oBAAoB;;;CAAgC,CAAC;AAElE;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB,GAAI,cAAS;;;CAG9C,CAAC;AAEH,qDAAqD;AACrD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CAAC;AAErC,yDAAyD;AACzD,eAAO,MAAM,cAAc,IAAI,CAAC;AAEhC;;;GAGG;AACH,eAAO,MAAM,kBAAkB;;;CAAmC,CAAC;AAEnE,0EAA0E;AAC1E,eAAO,MAAM,aAAa,IAAI,CAAC;AAE/B,kEAAkE;AAClE,eAAO,MAAM,iBAAiB,IAAI,CAAC;AAGnC;;;GAGG;AACH,eAAO,MAAM,aAAa,EAAE,CAAC,SAAS,GAAG;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC,EAOvD,CAAC"}
@@ -22,8 +22,8 @@ type Props = {
22
22
  input: boolean;
23
23
  };
24
24
  /**
25
- * Interactive flowchart node component supporting dragging, selection,
26
- * handle connections, and child/sibling creation.
25
+ * Interactive flowchart node component supporting dragging, selection, handle
26
+ * connections, and child/sibling creation.
27
27
  *
28
28
  * @param props - Node rendering properties of type {@linkcode Props}.
29
29
  *
@@ -1 +1 @@
1
- {"version":3,"file":"NodeComponent.d.ts","sourceRoot":"","sources":["../../../src/ui/components/NodeComponent.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAoC,MAAM,UAAU,CAAC;AAWvE,OAAO,QAAQ,UAAU,CAAC;IACxB,UAAU,GAAG,CAAC;QACZ,UAAU,UAAU;YAClB,SAAS,EAAE,GAAG,CAAC;SAChB;KACF;CACF;AAED,uEAAuE;AACvE,KAAK,KAAK,GAAG;IACX,qCAAqC;IACrC,EAAE,EAAE,MAAM,CAAC;IACX,4DAA4D;IAC5D,CAAC,EAAE,MAAM,CAAC;IACV,0DAA0D;IAC1D,CAAC,EAAE,MAAM,CAAC;IACV,0CAA0C;IAC1C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,qCAAqC;IACrC,OAAO,EAAE,MAAM,CAAC;IAChB,4CAA4C;IAC5C,KAAK,EAAE,OAAO,CAAC;CAChB,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,EAAE,SAAS,CAAC,KAAK,CAiP1C,CAAC"}
1
+ {"version":3,"file":"NodeComponent.d.ts","sourceRoot":"","sources":["../../../src/ui/components/NodeComponent.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAA+B,MAAM,UAAU,CAAC;AAYlE,OAAO,QAAQ,UAAU,CAAC;IACxB,UAAU,GAAG,CAAC;QACZ,UAAU,UAAU;YAClB,SAAS,EAAE,GAAG,CAAC;SAChB;KACF;CACF;AAED,uEAAuE;AACvE,KAAK,KAAK,GAAG;IACX,qCAAqC;IACrC,EAAE,EAAE,MAAM,CAAC;IACX,4DAA4D;IAC5D,CAAC,EAAE,MAAM,CAAC;IACV,0DAA0D;IAC1D,CAAC,EAAE,MAAM,CAAC;IACV,0CAA0C;IAC1C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,qCAAqC;IACrC,OAAO,EAAE,MAAM,CAAC;IAChB,4CAA4C;IAC5C,KAAK,EAAE,OAAO,CAAC;CAChB,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,EAAE,SAAS,CAAC,KAAK,CAoO1C,CAAC"}
@@ -1,7 +1,7 @@
1
1
  import { Component } from 'solid-js';
2
2
  /**
3
- * Interactive board component containing the drag-drop viewport, zoom
4
- * controls, panning gestures, and rendered nodes/edges.
3
+ * Interactive board component containing the drag-drop viewport, zoom controls,
4
+ * panning gestures, and rendered nodes/edges.
5
5
  *
6
6
  * @returns The rendered Solid component.
7
7
  */
@@ -1 +1 @@
1
- {"version":3,"file":"NodesBoard.d.ts","sourceRoot":"","sources":["../../../src/ui/components/NodesBoard.tsx"],"names":[],"mappings":"AAOA,OAAO,EACL,SAAS,EAOV,MAAM,UAAU,CAAC;AAOlB;;;;;GAKG;AACH,eAAO,MAAM,UAAU,EAAE,SA6QxB,CAAC"}
1
+ {"version":3,"file":"NodesBoard.d.ts","sourceRoot":"","sources":["../../../src/ui/components/NodesBoard.tsx"],"names":[],"mappings":"AAOA,OAAO,EAAE,SAAS,EAA6C,MAAM,UAAU,CAAC;AAQhF;;;;;GAKG;AACH,eAAO,MAAM,UAAU,EAAE,SA6RxB,CAAC"}
@@ -1,6 +1,6 @@
1
1
  /**
2
- * List of Tailwind CSS class names used across flowchart UI components to
3
- * ensure compilation safelist.
2
+ * List of Tailwind CSS class names used across flowchart UI components to ensure
3
+ * compilation safelist.
4
4
  */
5
5
  export declare const CLASSES: string[];
6
6
  //# sourceMappingURL=classes.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bemedev/mind-flow",
3
- "version": "0.0.1",
3
+ "version": "0.1.1",
4
4
  "description": "Flow Chart UI library for Solid.js applications",
5
5
  "keywords": [
6
6
  "diagram",
@@ -65,11 +65,7 @@
65
65
  "@bemedev/app": "^1.11.0",
66
66
  "@bemedev/app-cli": "^1.11.0",
67
67
  "@bemedev/app-solidjs": "^1.11.0",
68
- "@bemedev/fsf": "^1.0.1",
69
- "@bemedev/rollup-config": "^0.2.2",
70
- "@bemedev/vitest-alias": "^0.0.3",
71
- "@bemedev/vitest-exclude": "^0.1.1",
72
- "@bemedev/vitest-extended": "^1.5.3",
68
+ "@bemedev/dev-utils": "^1.2.0",
73
69
  "@rollup/plugin-babel": "^7.1.0",
74
70
  "@rollup/plugin-node-resolve": "^16.0.3",
75
71
  "@size-limit/file": "^13.0.3",
@@ -77,7 +73,6 @@
77
73
  "@tailwindcss/vite": "^4.3.3",
78
74
  "@types/node": "^26.2.0",
79
75
  "@vitest/coverage-v8": "^4.1.11",
80
- "babel-preset-solid": "^1.9.15",
81
76
  "glob": "^13.0.6",
82
77
  "globals": "^17.11.0",
83
78
  "husky": "^9.1.7",
@@ -86,7 +81,7 @@
86
81
  "oxlint": "^1.79.0",
87
82
  "pretty-quick": "^4.2.2",
88
83
  "rimraf": "^6.1.3",
89
- "rolldown": "^1.2.4",
84
+ "rolldown": "^1.2.5",
90
85
  "rollup": "^4.62.4",
91
86
  "rollup-preset-solid": "^3.0.0",
92
87
  "size-limit": "^13.0.3",
@@ -97,7 +92,6 @@
97
92
  "vite": "^8.2.1",
98
93
  "vite-plugin-dts": "^5.0.3",
99
94
  "vite-plugin-solid": "^2.11.14",
100
- "vite-tsconfig-paths": "^6.1.1",
101
95
  "vitest": "^4.1.11"
102
96
  },
103
97
  "peerDependencies": {
package/src/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Flow Chart UI Library
2
2
 
3
- This is a self-contained UI library for creating interactive flow charts in
4
- Solid.js applications.
3
+ This is a self-contained UI library for creating interactive flow charts in Solid.js
4
+ applications.
5
5
 
6
6
  ## Structure
7
7
 
@@ -4,23 +4,20 @@ import {
4
4
  type ParentComponent,
5
5
  } from 'solid-js';
6
6
 
7
- /** Context options type extracted from Solid's `createContext`. */
7
+ /** Context options type extracted from Solid's `createSolidContext`. */
8
8
  type Options = Parameters<typeof createSolidContext>[1];
9
9
 
10
10
  /**
11
- * Creates a Solid context provider component and a custom hook to consume
12
- * it.
11
+ * Creates a Solid context provider component and a custom hook to consume it.
13
12
  *
14
- * @template T - The type of the context value.
13
+ * @template `T` - The type of the context value.
15
14
  *
16
- * @param context - Factory function returning a non-nullable context value
17
- * of type `NonNullable<T>`.
18
- * @param options - Optional context configuration of type
19
- * {@linkcode Options}.
15
+ * @param context - Factory function returning a non-nullable context value of type
16
+ * `NonNullable<T>`.
17
+ * @param options - Optional context configuration of type {@linkcode Options}.
20
18
  *
21
- * @returns A tuple containing the Provider component of type
22
- * {@linkcode ParentComponent}, the accessor hook, and the Solid context
23
- * object.
19
+ * @returns A tuple containing the Provider component of interface
20
+ * {@linkcode ParentComponent}, the accessor hook, and the Solid context object.
24
21
  */
25
22
  export const createContext = <const T>(
26
23
  context: () => NonNullable<T>,
@@ -1,11 +1,11 @@
1
1
  import { createMachine } from '@bemedev/app';
2
2
  import { type } from '@bemedev/app/bemedev';
3
3
  import { nanoid } from 'nanoid';
4
+
4
5
  import { edgeJSON, extremities, nodeJSON } from './main.typings';
5
6
 
6
7
  /**
7
- * Constructs a unique edge identifier string from source and destination
8
- * node IDs.
8
+ * Constructs a unique edge identifier string from source and destination node IDs.
9
9
  *
10
10
  * @param out - The source node ID string.
11
11
  * @param _in - The destination node ID string.
@@ -28,8 +28,8 @@ export const buildNodeID = (generated?: string | null) => {
28
28
  };
29
29
 
30
30
  /**
31
- * State machine managing flowchart state transitions, nodes, edges,
32
- * selection, and layout actions.
31
+ * State machine managing flowchart state transitions, nodes, edges, selection, and
32
+ * layout actions.
33
33
  */
34
34
  export const machine = createMachine(
35
35
  {
@@ -42,27 +42,16 @@ export const machine = createMachine(
42
42
  },
43
43
  },
44
44
 
45
- construction: {
46
- always: { actions: ['buildUI'], target: '/working' },
47
- },
45
+ construction: { always: { actions: ['buildUI'], target: '/working' } },
48
46
 
49
47
  working: {
50
48
  on: {
51
- MOVE: {
52
- actions: ['moveNode', 'buildUI'],
53
- target: '/construction',
54
- },
55
49
  MOVE_IMMEDIATE: {
56
50
  actions: [
57
- {
58
- name: 'buildImmediateUI',
59
- description: 'Must be in the ui',
60
- },
51
+ { name: 'buildImmediateUI', description: 'Must be in the ui' },
61
52
  ],
62
53
  },
63
54
 
64
- UPDATE_UI: '/construction',
65
-
66
55
  ADD_CHILD: {
67
56
  actions: [
68
57
  'generateID',
@@ -90,12 +79,10 @@ export const machine = createMachine(
90
79
  target: '/construction',
91
80
  },
92
81
 
82
+ MOVE: { actions: ['moveNode', 'buildUI'], target: '/construction' },
93
83
  ADD_EDGE: { actions: ['addEdge'], target: '/construction' },
94
-
95
84
  DELETE: { actions: ['delete'], target: '/construction' },
96
-
97
85
  SELECT: { actions: ['select'] },
98
-
99
86
  DESELECT: { actions: ['deselect'] },
100
87
  },
101
88
  },
@@ -109,11 +96,8 @@ export const machine = createMachine(
109
96
  },
110
97
 
111
98
  CONFIGURE_EMPTY: 'never',
112
-
113
99
  MOVE: { id: 'string', x: 'number', y: 'number' },
114
-
115
100
  MOVE_IMMEDIATE: { id: 'string', x: 'number', y: 'number' },
116
-
117
101
  ADD_CHILD: 'string',
118
102
  ADD_PARENT: 'never',
119
103
  ADD_SIBLING: 'string',
@@ -123,9 +107,8 @@ export const machine = createMachine(
123
107
  ADD_EDGE: use(extremities),
124
108
  })),
125
109
 
126
- pContext: type(({ union }) => ({
127
- generatedId: union('string', 'null'),
128
- })),
110
+ sync: true,
111
+ pContext: type(({ union }) => ({ generatedId: union('string', 'null') })),
129
112
 
130
113
  context: type(({ optional, use, array }) => ({
131
114
  data: optional({
@@ -136,22 +119,13 @@ export const machine = createMachine(
136
119
  selected: optional('string'),
137
120
  updatingUI: optional('boolean'),
138
121
  })),
139
-
140
- sync: true,
141
122
  },
142
123
  ).provideOptions(({ assign, batch, erase }) => ({
143
124
  actions: {
144
125
  configure: batch(
145
126
  assign('context.data', () => ({ nodes: [], edges: [] })),
146
-
147
- assign('context.data.nodes', {
148
- CONFIGURE: ({ payload: { nodes } }) => nodes,
149
- }),
150
-
151
- assign('context.data.edges', {
152
- CONFIGURE: ({ payload: { edges } }) => edges,
153
- }),
154
-
127
+ assign('context.data.nodes', { CONFIGURE: ({ payload: { nodes } }) => nodes }),
128
+ assign('context.data.edges', { CONFIGURE: ({ payload: { edges } }) => edges }),
155
129
  assign('context.updatingUI', () => false),
156
130
  assign('pContext.generatedId', () => null),
157
131
  ),
@@ -183,10 +157,10 @@ export const machine = createMachine(
183
157
  const out = [...(edges ?? [])];
184
158
  const from = edges?.find(({ to }) => to === payload)?.from;
185
159
  if (!from) return out;
160
+
186
161
  const to = buildNodeID(generatedId);
187
162
  const id = buildEdgeId(from, to);
188
163
  out.push({ from, to, id });
189
-
190
164
  return out;
191
165
  },
192
166
  }),
@@ -196,9 +170,8 @@ export const machine = createMachine(
196
170
  ),
197
171
  ),
198
172
 
199
- selectParent: assign(
200
- 'context.selected',
201
- ({ pContext: { generatedId } }) => buildNodeID(generatedId),
173
+ selectParent: assign('context.selected', ({ pContext: { generatedId } }) =>
174
+ buildNodeID(generatedId),
202
175
  ),
203
176
 
204
177
  moveNode: assign('context.data.nodes', {
@@ -217,17 +190,15 @@ export const machine = createMachine(
217
190
  },
218
191
  }),
219
192
 
220
- select: assign('context.selected', {
221
- SELECT: ({ payload }) => payload,
222
- }),
193
+ select: assign('context.selected', { SELECT: ({ payload }) => payload }),
223
194
 
224
195
  delete: assign(['context.data.nodes', 'context.data.edges'], {
225
196
  DELETE: ({ context: { data }, payload }) => {
226
197
  const nodes = data?.nodes?.filter(({ id }) => id !== payload);
227
198
  const edges = data?.edges?.filter(
228
- ({ id, from, to }) =>
229
- id !== payload && from !== payload && to !== payload,
199
+ ({ id, from, to }) => id !== payload && from !== payload && to !== payload,
230
200
  );
201
+
231
202
  return [nodes, edges];
232
203
  },
233
204
  }),
@@ -237,6 +208,7 @@ export const machine = createMachine(
237
208
  const edges = context.data?.edges ?? [];
238
209
  const id = buildEdgeId(from, to);
239
210
  if (edges.some(e => e.id === id)) return edges;
211
+
240
212
  const out = [...edges, { id, from, to }];
241
213
  return out;
242
214
  },
@@ -13,7 +13,7 @@ export const nodeOffset = type(({ optional, use }) => ({
13
13
  output: use(point),
14
14
  }));
15
15
 
16
- /** Schema definition for edge extremities */
16
+ /** Schema definition for edge extremities. */
17
17
  export const extremities = type({ from: 'string', to: 'string' });
18
18
 
19
19
  /** Schema definition for a serialized flowchart node entity. */
@@ -36,8 +36,8 @@ export const dimensions = type(({ optional, use }) => ({
36
36
  }));
37
37
 
38
38
  /**
39
- * Schema definition for a 2D line vector representing edge coordinates
40
- * `(x0, y0)` to `(x1, y1)`.
39
+ * Schema definition for a 2D line vector representing edge coordinates `(x0, y0)` to
40
+ * `(x1, y1)`.
41
41
  */
42
42
  export const vector = type({
43
43
  x0: 'number',
package/src/ui/Flow.tsx CHANGED
@@ -1,10 +1,11 @@
1
1
  import type { Component } from 'solid-js';
2
+
2
3
  import { FlowChart, type FlowProps } from './components/FlowChart';
3
4
  import { Provider } from './components/FlowChart.context';
4
5
 
5
6
  /**
6
- * Root Flow component wrapping the {@linkcode FlowChart} inside the flow
7
- * context provider.
7
+ * Root Flow component wrapping the {@linkcode FlowChart} inside the flow context
8
+ * provider.
8
9
  *
9
10
  * @param props - Flow chart configuration and callbacks of type
10
11
  * {@linkcode FlowProps}.