@sqlrooms/cosmos 0.29.0-rc.0 → 0.29.0-rc.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/README.md +20 -16
- package/dist/CosmosGraphControls.js +1 -1
- package/dist/CosmosGraphControls.js.map +1 -1
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -31,7 +31,11 @@ export const {roomStore, useRoomStore} = createRoomStore<RoomState>(
|
|
|
31
31
|
## Render a graph
|
|
32
32
|
|
|
33
33
|
```tsx
|
|
34
|
-
import {
|
|
34
|
+
import {
|
|
35
|
+
CosmosGraph,
|
|
36
|
+
CosmosGraphControls,
|
|
37
|
+
CosmosSimulationControls,
|
|
38
|
+
} from '@sqlrooms/cosmos';
|
|
35
39
|
import {GraphConfigInterface} from '@cosmos.gl/graph';
|
|
36
40
|
|
|
37
41
|
const config: GraphConfigInterface = {
|
|
@@ -43,20 +47,16 @@ const config: GraphConfigInterface = {
|
|
|
43
47
|
};
|
|
44
48
|
|
|
45
49
|
const pointPositions = new Float32Array([
|
|
46
|
-
0,
|
|
47
|
-
|
|
48
|
-
|
|
50
|
+
0,
|
|
51
|
+
0, // node 0
|
|
52
|
+
1,
|
|
53
|
+
0, // node 1
|
|
54
|
+
0.5,
|
|
55
|
+
1, // node 2
|
|
49
56
|
]);
|
|
50
57
|
const pointSizes = new Float32Array([5, 5, 5]);
|
|
51
|
-
const pointColors = new Float32Array([
|
|
52
|
-
|
|
53
|
-
0, 1, 0, 1,
|
|
54
|
-
0, 0, 1, 1,
|
|
55
|
-
]);
|
|
56
|
-
const linkIndexes = new Float32Array([
|
|
57
|
-
0, 1,
|
|
58
|
-
1, 2,
|
|
59
|
-
]);
|
|
58
|
+
const pointColors = new Float32Array([1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1]);
|
|
59
|
+
const linkIndexes = new Float32Array([0, 1, 1, 2]);
|
|
60
60
|
|
|
61
61
|
export function GraphView() {
|
|
62
62
|
return (
|
|
@@ -69,7 +69,7 @@ export function GraphView() {
|
|
|
69
69
|
renderPointTooltip={(index) => `Node ${index}`}
|
|
70
70
|
>
|
|
71
71
|
<CosmosGraphControls />
|
|
72
|
-
<CosmosSimulationControls className="absolute
|
|
72
|
+
<CosmosSimulationControls className="absolute top-2 right-2" />
|
|
73
73
|
</CosmosGraph>
|
|
74
74
|
);
|
|
75
75
|
}
|
|
@@ -82,7 +82,9 @@ import {useRoomStore} from './store';
|
|
|
82
82
|
import {Button} from '@sqlrooms/ui';
|
|
83
83
|
|
|
84
84
|
function SimulationButtons() {
|
|
85
|
-
const toggleSimulation = useRoomStore(
|
|
85
|
+
const toggleSimulation = useRoomStore(
|
|
86
|
+
(state) => state.cosmos.toggleSimulation,
|
|
87
|
+
);
|
|
86
88
|
const fitView = useRoomStore((state) => state.cosmos.fitView);
|
|
87
89
|
const updateSimulationConfig = useRoomStore(
|
|
88
90
|
(state) => state.cosmos.updateSimulationConfig,
|
|
@@ -92,7 +94,9 @@ function SimulationButtons() {
|
|
|
92
94
|
<div className="flex gap-2">
|
|
93
95
|
<Button onClick={toggleSimulation}>Toggle simulation</Button>
|
|
94
96
|
<Button onClick={fitView}>Fit view</Button>
|
|
95
|
-
<Button
|
|
97
|
+
<Button
|
|
98
|
+
onClick={() => updateSimulationConfig({simulationRepulsion: 1.5})}
|
|
99
|
+
>
|
|
96
100
|
Stronger repulsion
|
|
97
101
|
</Button>
|
|
98
102
|
</div>
|
|
@@ -36,6 +36,6 @@ import { useStoreWithCosmos } from './CosmosSlice';
|
|
|
36
36
|
*/
|
|
37
37
|
export const CosmosGraphControls = ({ className, children }) => {
|
|
38
38
|
const { fitView } = useStoreWithCosmos((s) => s.cosmos);
|
|
39
|
-
return (_jsxs("div", { className: cn('absolute
|
|
39
|
+
return (_jsxs("div", { className: cn('absolute top-1 left-1 flex gap-2', className), children: [_jsx(Button, { onClick: fitView, variant: "outline", size: "sm", children: _jsx(Maximize2, { className: "h-4 w-4" }) }), children] }));
|
|
40
40
|
};
|
|
41
41
|
//# sourceMappingURL=CosmosGraphControls.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CosmosGraphControls.js","sourceRoot":"","sources":["../src/CosmosGraphControls.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,MAAM,EAAE,EAAE,EAAC,MAAM,cAAc,CAAC;AACxC,OAAO,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AAEvC,OAAO,EAAC,kBAAkB,EAAC,MAAM,eAAe,CAAC;AAejD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAE5B,CAAC,EAAC,SAAS,EAAE,QAAQ,EAAC,EAAE,EAAE;IAC5B,MAAM,EAAC,OAAO,EAAC,GAAG,kBAAkB,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;IAEtD,OAAO,CACL,eAAK,SAAS,EAAE,EAAE,CAAC,kCAAkC,EAAE,SAAS,CAAC,aAC/D,KAAC,MAAM,IAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAC,SAAS,EAAC,IAAI,EAAC,IAAI,YACnD,KAAC,SAAS,IAAC,SAAS,EAAC,SAAS,GAAG,GAC1B,EACR,QAAQ,IACL,CACP,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import {Button, cn} from '@sqlrooms/ui';\nimport {Maximize2} from 'lucide-react';\nimport {FC, PropsWithChildren} from 'react';\nimport {useStoreWithCosmos} from './CosmosSlice';\n\ninterface CosmosGraphControlsProps {\n /**\n * Optional className to override the default positioning and styling of the controls container.\n * By default, controls are positioned at the top-left corner.\n * @example\n * ```tsx\n * // Position controls at the bottom-right\n * <CosmosGraphControls className=\"absolute bottom-4 right-4\" />\n * ```\n */\n className?: string;\n}\n\n/**\n * A flexible control panel component for CosmosGraph that provides view controls.\n * Must be used within a CosmosGraph component as it relies on the graph state from the store.\n *\n * The component shows the default fit view control and allows adding custom controls as children.\n * For simulation controls, use the CosmosSimulationControls component.\n *\n * @example Default usage\n * ```tsx\n * <CosmosGraph {...graphProps}>\n * <CosmosGraphControls />\n * </CosmosGraph>\n * ```\n *\n * @example Custom positioning\n * ```tsx\n * <CosmosGraph {...graphProps}>\n * <CosmosGraphControls className=\"absolute bottom-4 right-4\" />\n * </CosmosGraph>\n * ```\n *\n * @example Adding custom controls\n * ```tsx\n * <CosmosGraph {...graphProps}>\n * <CosmosGraphControls>\n * <Button onClick={handleExport}>\n * <Download className=\"h-4 w-4\" />\n * </Button>\n * </CosmosGraphControls>\n * </CosmosGraph>\n * ```\n */\nexport const CosmosGraphControls: FC<\n PropsWithChildren<CosmosGraphControlsProps>\n> = ({className, children}) => {\n const {fitView} = useStoreWithCosmos((s) => s.cosmos);\n\n return (\n <div className={cn('absolute
|
|
1
|
+
{"version":3,"file":"CosmosGraphControls.js","sourceRoot":"","sources":["../src/CosmosGraphControls.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,MAAM,EAAE,EAAE,EAAC,MAAM,cAAc,CAAC;AACxC,OAAO,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AAEvC,OAAO,EAAC,kBAAkB,EAAC,MAAM,eAAe,CAAC;AAejD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAE5B,CAAC,EAAC,SAAS,EAAE,QAAQ,EAAC,EAAE,EAAE;IAC5B,MAAM,EAAC,OAAO,EAAC,GAAG,kBAAkB,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;IAEtD,OAAO,CACL,eAAK,SAAS,EAAE,EAAE,CAAC,kCAAkC,EAAE,SAAS,CAAC,aAC/D,KAAC,MAAM,IAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAC,SAAS,EAAC,IAAI,EAAC,IAAI,YACnD,KAAC,SAAS,IAAC,SAAS,EAAC,SAAS,GAAG,GAC1B,EACR,QAAQ,IACL,CACP,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import {Button, cn} from '@sqlrooms/ui';\nimport {Maximize2} from 'lucide-react';\nimport {FC, PropsWithChildren} from 'react';\nimport {useStoreWithCosmos} from './CosmosSlice';\n\ninterface CosmosGraphControlsProps {\n /**\n * Optional className to override the default positioning and styling of the controls container.\n * By default, controls are positioned at the top-left corner.\n * @example\n * ```tsx\n * // Position controls at the bottom-right\n * <CosmosGraphControls className=\"absolute bottom-4 right-4\" />\n * ```\n */\n className?: string;\n}\n\n/**\n * A flexible control panel component for CosmosGraph that provides view controls.\n * Must be used within a CosmosGraph component as it relies on the graph state from the store.\n *\n * The component shows the default fit view control and allows adding custom controls as children.\n * For simulation controls, use the CosmosSimulationControls component.\n *\n * @example Default usage\n * ```tsx\n * <CosmosGraph {...graphProps}>\n * <CosmosGraphControls />\n * </CosmosGraph>\n * ```\n *\n * @example Custom positioning\n * ```tsx\n * <CosmosGraph {...graphProps}>\n * <CosmosGraphControls className=\"absolute bottom-4 right-4\" />\n * </CosmosGraph>\n * ```\n *\n * @example Adding custom controls\n * ```tsx\n * <CosmosGraph {...graphProps}>\n * <CosmosGraphControls>\n * <Button onClick={handleExport}>\n * <Download className=\"h-4 w-4\" />\n * </Button>\n * </CosmosGraphControls>\n * </CosmosGraph>\n * ```\n */\nexport const CosmosGraphControls: FC<\n PropsWithChildren<CosmosGraphControlsProps>\n> = ({className, children}) => {\n const {fitView} = useStoreWithCosmos((s) => s.cosmos);\n\n return (\n <div className={cn('absolute top-1 left-1 flex gap-2', className)}>\n <Button onClick={fitView} variant=\"outline\" size=\"sm\">\n <Maximize2 className=\"h-4 w-4\" />\n </Button>\n {children}\n </div>\n );\n};\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sqlrooms/cosmos",
|
|
3
|
-
"version": "0.29.0-rc.
|
|
3
|
+
"version": "0.29.0-rc.2",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"repository": {
|
|
12
12
|
"type": "git",
|
|
13
|
-
"url": "https://github.com/sqlrooms/sqlrooms.git"
|
|
13
|
+
"url": "git+https://github.com/sqlrooms/sqlrooms.git"
|
|
14
14
|
},
|
|
15
15
|
"files": [
|
|
16
16
|
"dist"
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@cosmos.gl/graph": "^2.6.4",
|
|
23
|
-
"@sqlrooms/room-shell": "0.29.0-rc.
|
|
24
|
-
"@sqlrooms/ui": "0.29.0-rc.
|
|
23
|
+
"@sqlrooms/room-shell": "0.29.0-rc.2",
|
|
24
|
+
"@sqlrooms/ui": "0.29.0-rc.2",
|
|
25
25
|
"immer": "^11.0.1",
|
|
26
26
|
"lucide-react": "^0.556.0",
|
|
27
27
|
"zod": "^4.1.8",
|
|
@@ -38,5 +38,5 @@
|
|
|
38
38
|
"typecheck": "tsc --noEmit",
|
|
39
39
|
"typedoc": "typedoc"
|
|
40
40
|
},
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "5d511631992c1af8852ea79ced488867aad4a555"
|
|
42
42
|
}
|