@ankhzet/graph 0.3.0 → 0.3.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ankhzet/graph",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "type": "module",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
@@ -31,9 +31,9 @@
31
31
  "mobx": "^6.15.4",
32
32
  "mobx-react-lite": "^4.1.1",
33
33
  "@ankhzet/eventual": "1.2.0",
34
- "@ankhzet/ui": "0.2.0",
35
- "@ankhzet/utils": "1.18.0",
36
- "@ankhzet/gcl": "1.2.0"
34
+ "@ankhzet/utils": "1.19.0",
35
+ "@ankhzet/gcl": "1.2.0",
36
+ "@ankhzet/ui": "0.3.0"
37
37
  },
38
38
  "peerDependencies": {
39
39
  "react": "^19.2.6"
@@ -46,6 +46,7 @@
46
46
  },
47
47
  "scripts": {
48
48
  "ai:checkts": "tsc --noEmit",
49
+ "clean": "rm -rf ./{build,dist,api} && rm -rf ./*.log",
49
50
  "build": "vite build"
50
51
  }
51
52
  }
@@ -1,13 +1,15 @@
1
1
  import { useMeasure, Styles } from '@ankhzet/ui';
2
- import { forwardRef, useEffect, useImperativeHandle } from 'react';
2
+ import { useEffect, useImperativeHandle, Ref } from 'react';
3
+ import { type Position } from './interfaces';
3
4
  import { type DragHandlers, useDraggable } from './useDraggable';
4
5
 
5
6
  interface ViewportProps {
7
+ ref?: Ref<{ reset: (pos: Position) => void; element: HTMLDivElement | null }>;
6
8
  handlers: DragHandlers;
7
9
  onResize: (rect: { width: number; height: number }) => void;
8
10
  }
9
11
 
10
- export const Viewport = forwardRef(({ handlers, onResize, ...props }: ViewportProps, ref) => {
12
+ export const Viewport = ({ ref, handlers, onResize, ...props }: ViewportProps) => {
11
13
  const [rect, measureRef] = useMeasure<HTMLDivElement>();
12
14
  const { bind, reset } = useDraggable<HTMLDivElement>(handlers);
13
15
 
@@ -19,12 +21,10 @@ export const Viewport = forwardRef(({ handlers, onResize, ...props }: ViewportPr
19
21
  }));
20
22
 
21
23
  useEffect(() => {
22
- if (rect) {
23
- onResize({
24
- width: ~~rect.width,
25
- height: ~~rect.height,
26
- });
27
- }
24
+ rect && onResize({
25
+ width: ~~rect.width,
26
+ height: ~~rect.height,
27
+ });
28
28
  }, [rect, onResize]);
29
29
 
30
30
  return (
@@ -32,7 +32,7 @@ export const Viewport = forwardRef(({ handlers, onResize, ...props }: ViewportPr
32
32
  <div style={styles.root} {...bind} {...props} />
33
33
  </div>
34
34
  );
35
- });
35
+ };
36
36
 
37
37
  const styles = Styles.of({
38
38
  root: {