@sqlrooms/cosmos 0.24.15 → 0.24.17

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.
@@ -49,7 +49,7 @@ export declare const useHoverState: (calcRelativeCoordinates: ReturnType<typeof
49
49
  hoveredPoint: HoverState;
50
50
  /** Event handlers for hover-related graph interactions */
51
51
  eventHandlers: {
52
- onPointMouseOver: (index: number, pointPosition: [number, number], event: MouseEvent | D3DragEvent<HTMLCanvasElement, undefined, import("@cosmograph/cosmos/dist/modules/Store").Hovered> | D3ZoomEvent<HTMLCanvasElement, undefined> | undefined) => void;
52
+ onPointMouseOver: (index: number, pointPosition: [number, number], event: MouseEvent | import("d3-drag").D3DragEvent<HTMLCanvasElement, undefined, import("@cosmograph/cosmos/dist/modules/Store").Hovered> | import("d3-zoom").D3ZoomEvent<HTMLCanvasElement, undefined> | undefined) => void;
53
53
  onPointMouseOut: () => void;
54
54
  onZoomStart: () => void;
55
55
  onDragStart: () => void;
@@ -1 +1 @@
1
- {"version":3,"file":"useHoverState.d.ts","sourceRoot":"","sources":["../../src/hooks/useHoverState.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,sBAAsB,EAAC,MAAM,cAAc,CAAC;AAKpD;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,6DAA6D;IAC7D,KAAK,EAAE,MAAM,CAAC;IACd,4EAA4E;IAC5E,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC5B,GAAG,IAAI,CAAC;AAET;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,eAAO,MAAM,aAAa,GACxB,yBAAyB,UAAU,CAAC,OAAO,sBAAsB,CAAC;IAkChE,sHAAsH;;IAEtH,0DAA0D;;;;;;;CAG7D,CAAC"}
1
+ {"version":3,"file":"useHoverState.d.ts","sourceRoot":"","sources":["../../src/hooks/useHoverState.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,sBA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IAErE,MAAM,aAAa,GAAG,OAAO,CAC3B,GAAG,EAAE,CAAC,CAAC;QACL,gBAAgB;QAChB,eAAe,EAAE,eAAe;QAChC,WAAW,EAAE,eAAe;QAC5B,WAAW,EAAE,eAAe;KAC7B,CAAC,EACF,CAAC,gBAAgB,EAAE,eAAe,CAAC,CACpC,CAAC;IAEF,OAAO;QACL,sHAAsH;QACtH,YAAY;QACZ,0DAA0D;QAC1D,aAAa;KACd,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import {useRelativeCoordinates} from '@sqlrooms/ui';\nimport {useState, useCallback, useMemo} from 'react';\nimport {hasClientCoordinates} from '../utils/coordinates';\nimport {GraphConfigInterface} from '@cosmograph/cosmos';\n\n/**\n * Represents the state of a hovered point in the graph.\n * When a point is hovered, contains its index and position coordinates.\n * When no point is hovered, the state is null.\n */\nexport type HoverState = {\n /** The index of the hovered point in the graph data array */\n index: number;\n /** The [x, y] coordinates of the hovered point relative to the container */\n position: [number, number];\n} | null;\n\n/**\n * A custom hook that manages hover state for graph points.\n *\n * This hook provides functionality to:\n * - Track which point is currently being hovered\n * - Store the hover position coordinates\n * - Clear the hover state\n * - Provide event handlers for hover-related graph interactions\n *\n * @example\n * ```tsx\n * const Graph = () => {\n * const calcRelativeCoords = useRelativeCoordinates(containerRef);\n * const { hoveredPoint, eventHandlers } = useHoverState(calcRelativeCoords);\n *\n * return (\n * <div ref={containerRef}>\n * <CosmosGraph\n * config={eventHandlers}\n * />\n * {hoveredPoint && (\n * <Tooltip\n * x={hoveredPoint.position[0]}\n * y={hoveredPoint.position[1]}\n * />\n * )}\n * </div>\n * );\n * };\n * ```\n *\n * @param calcRelativeCoordinates - A function that converts client coordinates to container-relative coordinates\n * @returns An object containing the hover state and event handlers for the graph\n */\nexport const useHoverState = (\n calcRelativeCoordinates: ReturnType<typeof useRelativeCoordinates>,\n) => {\n const [hoveredPoint, setHoveredPoint] = useState<HoverState>(null);\n\n const onPointMouseOver: GraphConfigInterface['onPointMouseOver'] =\n useCallback(\n (\n index: number,\n _pointPosition: [number, number],\n event: MouseEvent | TouchEvent,\n ) => {\n if (hasClientCoordinates(event)) {\n setHoveredPoint({\n index,\n position: calcRelativeCoordinates(event.clientX, event.clientY),\n });\n }\n },\n [calcRelativeCoordinates],\n );\n\n const clearHoverState = useCallback(() => setHoveredPoint(null), []);\n\n const eventHandlers = useMemo(\n () => ({\n onPointMouseOver,\n onPointMouseOut: clearHoverState,\n onZoomStart: clearHoverState,\n onDragStart: clearHoverState,\n }),\n [onPointMouseOver, clearHoverState],\n );\n\n return {\n /** The current hover state, containing the index and position of the hovered point, or null if no point is hovered */\n hoveredPoint,\n /** Event handlers for hover-related graph interactions */\n eventHandlers,\n };\n};\n"]}
1
+ {"version":3,"file":"useHoverState.js","sourceRoot":"","sources":["../../src/hooks/useHoverState.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,QAAQ,EAAE,WAAW,EAAE,OAAO,EAAC,MAAM,OAAO,CAAC;AACrD,OAAO,EAAC,oBAAoB,EAAC,MAAM,sBAAsB,CAAC;AAe1D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAC3B,uBAAkE,EAClE,EAAE;IACF,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,CAAa,IAAI,CAAC,CAAC;IAEnE,MAAM,gBAAgB,GAAG,WAAW,CAGlC,CAAC,KAAK,EAAE,cAAc,EAAE,KAAK,EAAE,EAAE;QAC/B,IAAI,oBAAoB,CAAC,KAAK,CAAC,EAAE,CAAC;YAChC,eAAe,CAAC;gBACd,KAAK;gBACL,QAAQ,EAAE,uBAAuB,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC;aAChE,CAAC,CAAC;QACL,CAAC;IACH,CAAC,EACD,CAAC,uBAAuB,CAAC,CAC1B,CAAC;IAEF,MAAM,eAAe,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC;IAErE,MAAM,aAAa,GAAG,OAAO,CAC3B,GAAG,EAAE,CAAC,CAAC;QACL,gBAAgB;QAChB,eAAe,EAAE,eAAe;QAChC,WAAW,EAAE,eAAe;QAC5B,WAAW,EAAE,eAAe;KAC7B,CAAC,EACF,CAAC,gBAAgB,EAAE,eAAe,CAAC,CACpC,CAAC;IAEF,OAAO;QACL,sHAAsH;QACtH,YAAY;QACZ,0DAA0D;QAC1D,aAAa;KACd,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import {useRelativeCoordinates} from '@sqlrooms/ui';\nimport {useState, useCallback, useMemo} from 'react';\nimport {hasClientCoordinates} from '../utils/coordinates';\nimport {GraphConfigInterface} from '@cosmograph/cosmos';\n\n/**\n * Represents the state of a hovered point in the graph.\n * When a point is hovered, contains its index and position coordinates.\n * When no point is hovered, the state is null.\n */\nexport type HoverState = {\n /** The index of the hovered point in the graph data array */\n index: number;\n /** The [x, y] coordinates of the hovered point relative to the container */\n position: [number, number];\n} | null;\n\n/**\n * A custom hook that manages hover state for graph points.\n *\n * This hook provides functionality to:\n * - Track which point is currently being hovered\n * - Store the hover position coordinates\n * - Clear the hover state\n * - Provide event handlers for hover-related graph interactions\n *\n * @example\n * ```tsx\n * const Graph = () => {\n * const calcRelativeCoords = useRelativeCoordinates(containerRef);\n * const { hoveredPoint, eventHandlers } = useHoverState(calcRelativeCoords);\n *\n * return (\n * <div ref={containerRef}>\n * <CosmosGraph\n * config={eventHandlers}\n * />\n * {hoveredPoint && (\n * <Tooltip\n * x={hoveredPoint.position[0]}\n * y={hoveredPoint.position[1]}\n * />\n * )}\n * </div>\n * );\n * };\n * ```\n *\n * @param calcRelativeCoordinates - A function that converts client coordinates to container-relative coordinates\n * @returns An object containing the hover state and event handlers for the graph\n */\nexport const useHoverState = (\n calcRelativeCoordinates: ReturnType<typeof useRelativeCoordinates>,\n) => {\n const [hoveredPoint, setHoveredPoint] = useState<HoverState>(null);\n\n const onPointMouseOver = useCallback<\n Required<GraphConfigInterface>['onPointMouseOver']\n >(\n (index, _pointPosition, event) => {\n if (hasClientCoordinates(event)) {\n setHoveredPoint({\n index,\n position: calcRelativeCoordinates(event.clientX, event.clientY),\n });\n }\n },\n [calcRelativeCoordinates],\n );\n\n const clearHoverState = useCallback(() => setHoveredPoint(null), []);\n\n const eventHandlers = useMemo(\n () => ({\n onPointMouseOver,\n onPointMouseOut: clearHoverState,\n onZoomStart: clearHoverState,\n onDragStart: clearHoverState,\n }),\n [onPointMouseOver, clearHoverState],\n );\n\n return {\n /** The current hover state, containing the index and position of the hovered point, or null if no point is hovered */\n hoveredPoint,\n /** Event handlers for hover-related graph interactions */\n eventHandlers,\n };\n};\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sqlrooms/cosmos",
3
- "version": "0.24.15",
3
+ "version": "0.24.17",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "module": "dist/index.js",
@@ -19,9 +19,9 @@
19
19
  },
20
20
  "dependencies": {
21
21
  "@cosmograph/cosmos": "2.0.0-beta.22",
22
- "@sqlrooms/room-config": "0.24.15",
23
- "@sqlrooms/room-shell": "0.24.15",
24
- "@sqlrooms/ui": "0.24.15",
22
+ "@sqlrooms/room-config": "0.24.17",
23
+ "@sqlrooms/room-shell": "0.24.17",
24
+ "@sqlrooms/ui": "0.24.17",
25
25
  "immer": "^10.1.1",
26
26
  "lucide-react": "^0.474.0",
27
27
  "zod": "^3.25.73",
@@ -38,5 +38,5 @@
38
38
  "typecheck": "tsc --noEmit",
39
39
  "typedoc": "typedoc"
40
40
  },
41
- "gitHead": "9388ad51033a365069bad9a14df24a0688b6a592"
41
+ "gitHead": "31b706c4687780cefa92bc9e715f2839dbe4ee49"
42
42
  }