@sqlrooms/canvas 0.28.0 → 0.29.0-rc.0
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 +5 -95
- package/dist/Canvas.d.ts.map +1 -1
- package/dist/Canvas.js +72 -14
- package/dist/Canvas.js.map +1 -1
- package/dist/CanvasSlice.d.ts +42 -93
- package/dist/CanvasSlice.d.ts.map +1 -1
- package/dist/CanvasSlice.js +183 -305
- package/dist/CanvasSlice.js.map +1 -1
- package/dist/crdt.d.ts +5 -16
- package/dist/crdt.d.ts.map +1 -1
- package/dist/crdt.js +41 -28
- package/dist/crdt.js.map +1 -1
- package/dist/edgeUtils.d.ts +3 -0
- package/dist/edgeUtils.d.ts.map +1 -0
- package/dist/edgeUtils.js +7 -0
- package/dist/edgeUtils.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/nodes/AddNodePopover.d.ts.map +1 -1
- package/dist/nodes/AddNodePopover.js +16 -9
- package/dist/nodes/AddNodePopover.js.map +1 -1
- package/dist/nodes/CanvasNodeContainer.d.ts.map +1 -1
- package/dist/nodes/CanvasNodeContainer.js +5 -9
- package/dist/nodes/CanvasNodeContainer.js.map +1 -1
- package/package.json +8 -10
- package/dist/CanvasAssistantDrawer.d.ts +0 -3
- package/dist/CanvasAssistantDrawer.d.ts.map +0 -1
- package/dist/CanvasAssistantDrawer.js +0 -14
- package/dist/CanvasAssistantDrawer.js.map +0 -1
- package/dist/dag.d.ts +0 -53
- package/dist/dag.d.ts.map +0 -1
- package/dist/dag.js +0 -124
- package/dist/dag.js.map +0 -1
- package/dist/nodes/SqlNode.d.ts +0 -11
- package/dist/nodes/SqlNode.d.ts.map +0 -1
- package/dist/nodes/SqlNode.js +0 -52
- package/dist/nodes/SqlNode.js.map +0 -1
- package/dist/nodes/VegaNode.d.ts +0 -11
- package/dist/nodes/VegaNode.d.ts.map +0 -1
- package/dist/nodes/VegaNode.js +0 -12
- package/dist/nodes/VegaNode.js.map +0 -1
package/dist/dag.js
DELETED
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Build a forward adjacency list for a directed graph.
|
|
3
|
-
* Ensures that every node id exists in the adjacency map, even if it has no outgoing edges.
|
|
4
|
-
*
|
|
5
|
-
* @param nodes - The set of nodes to include in the graph.
|
|
6
|
-
* @param edges - Directed edges where `source` points to `target`.
|
|
7
|
-
* @returns A mapping from node id to an array of child node ids.
|
|
8
|
-
*/
|
|
9
|
-
export function buildAdjacency(nodes, edges) {
|
|
10
|
-
const adjacency = {};
|
|
11
|
-
for (const n of nodes)
|
|
12
|
-
adjacency[n.id] = [];
|
|
13
|
-
for (const e of edges) {
|
|
14
|
-
const list = adjacency[e.source] || (adjacency[e.source] = []);
|
|
15
|
-
list.push(e.target);
|
|
16
|
-
}
|
|
17
|
-
return adjacency;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Find a node by id in a list of nodes.
|
|
21
|
-
*
|
|
22
|
-
* @param nodes - Array of nodes with an `id` field.
|
|
23
|
-
* @param id - The node id to find.
|
|
24
|
-
* @returns The node if found, otherwise undefined.
|
|
25
|
-
*/
|
|
26
|
-
export function findNodeById(nodes, id) {
|
|
27
|
-
return nodes.find((n) => n.id === id);
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Topologically sort all nodes in the graph using Kahn's algorithm.
|
|
31
|
-
* If a cycle is detected, the remaining nodes are appended in arbitrary order,
|
|
32
|
-
* and a warning is logged.
|
|
33
|
-
*
|
|
34
|
-
* @param nodes - The set of nodes to sort.
|
|
35
|
-
* @param edges - Directed edges defining dependencies.
|
|
36
|
-
* @returns An array of node ids in dependency order (parents before children).
|
|
37
|
-
*/
|
|
38
|
-
export function topoSortAll(nodes, edges) {
|
|
39
|
-
const adjacency = buildAdjacency(nodes, edges);
|
|
40
|
-
const inDegree = {};
|
|
41
|
-
for (const n of nodes)
|
|
42
|
-
inDegree[n.id] = 0;
|
|
43
|
-
for (const e of edges) {
|
|
44
|
-
inDegree[e.target] = (inDegree[e.target] ?? 0) + 1;
|
|
45
|
-
}
|
|
46
|
-
const queue = Object.keys(inDegree).filter((id) => (inDegree[id] ?? 0) === 0);
|
|
47
|
-
const order = [];
|
|
48
|
-
while (queue.length) {
|
|
49
|
-
const cur = queue.shift();
|
|
50
|
-
order.push(cur);
|
|
51
|
-
const neighbors = adjacency[cur] || [];
|
|
52
|
-
for (const nb of neighbors) {
|
|
53
|
-
inDegree[nb] = (inDegree[nb] ?? 0) - 1;
|
|
54
|
-
if (inDegree[nb] === 0)
|
|
55
|
-
queue.push(nb);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
if (order.length < nodes.length) {
|
|
59
|
-
const remaining = nodes
|
|
60
|
-
.map((n) => n.id)
|
|
61
|
-
.filter((id) => !order.includes(id));
|
|
62
|
-
console.warn('[dag.topoSortAll] Cycle detected; appending remaining nodes arbitrarily:', remaining);
|
|
63
|
-
order.push(...remaining);
|
|
64
|
-
}
|
|
65
|
-
return order;
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Get a topological order for the downstream subgraph reachable from `startId`.
|
|
69
|
-
* Only nodes reachable from the start are included (the starting node is excluded).
|
|
70
|
-
* If a cycle exists within the reachable subgraph, the remaining nodes are appended
|
|
71
|
-
* at the end in arbitrary order and a warning is logged.
|
|
72
|
-
*
|
|
73
|
-
* @param startId - The node id to start traversal from.
|
|
74
|
-
* @param nodes - The set of nodes in the full graph.
|
|
75
|
-
* @param edges - Directed edges defining the full graph dependencies.
|
|
76
|
-
* @returns Node ids reachable from `startId`, in dependency order.
|
|
77
|
-
*/
|
|
78
|
-
export function topoSortDownstream(startId, nodes, edges) {
|
|
79
|
-
const adjacency = buildAdjacency(nodes, edges);
|
|
80
|
-
// Collect reachable nodes from startId (excluding start)
|
|
81
|
-
const reachable = new Set();
|
|
82
|
-
const queue = [...(adjacency[startId] || [])];
|
|
83
|
-
while (queue.length) {
|
|
84
|
-
const cur = queue.shift();
|
|
85
|
-
if (reachable.has(cur))
|
|
86
|
-
continue;
|
|
87
|
-
reachable.add(cur);
|
|
88
|
-
const neighbors = adjacency[cur] || [];
|
|
89
|
-
for (const nb of neighbors)
|
|
90
|
-
queue.push(nb);
|
|
91
|
-
}
|
|
92
|
-
if (reachable.size === 0)
|
|
93
|
-
return [];
|
|
94
|
-
// Kahn's algorithm for topological sort within subgraph
|
|
95
|
-
const inDegree = {};
|
|
96
|
-
for (const id of reachable)
|
|
97
|
-
inDegree[id] = 0;
|
|
98
|
-
for (const e of edges) {
|
|
99
|
-
if (reachable.has(e.source) && reachable.has(e.target)) {
|
|
100
|
-
inDegree[e.target] = (inDegree[e.target] ?? 0) + 1;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
const queue2 = Array.from(reachable).filter((id) => (inDegree[id] ?? 0) === 0);
|
|
104
|
-
const order = [];
|
|
105
|
-
while (queue2.length) {
|
|
106
|
-
const cur = queue2.shift();
|
|
107
|
-
order.push(cur);
|
|
108
|
-
const neighbors = adjacency[cur] || [];
|
|
109
|
-
for (const nb of neighbors) {
|
|
110
|
-
if (!reachable.has(nb))
|
|
111
|
-
continue;
|
|
112
|
-
inDegree[nb] = (inDegree[nb] ?? 0) - 1;
|
|
113
|
-
if (inDegree[nb] === 0)
|
|
114
|
-
queue2.push(nb);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
if (order.length < reachable.size) {
|
|
118
|
-
const remaining = Array.from(reachable).filter((id) => !order.includes(id));
|
|
119
|
-
console.warn('[dag.topoSortDownstream] Cycle detected in downstream graph:', remaining);
|
|
120
|
-
order.push(...remaining);
|
|
121
|
-
}
|
|
122
|
-
return order;
|
|
123
|
-
}
|
|
124
|
-
//# sourceMappingURL=dag.js.map
|
package/dist/dag.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dag.js","sour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CAClC,CAAC;IACF,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,OAAO,MAAM,CAAC,MAAM,EAAE,CAAC;QACrB,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,EAAY,CAAC;QACrC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAChB,MAAM,SAAS,GAAG,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;QACvC,KAAK,MAAM,EAAE,IAAI,SAAS,EAAE,CAAC;YAC3B,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC;gBAAE,SAAS;YACjC,QAAQ,CAAC,EAAE,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;YACvC,IAAI,QAAQ,CAAC,EAAE,CAAC,KAAK,CAAC;gBAAE,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC1C,CAAC;IACH,CAAC;IACD,IAAI,KAAK,CAAC,MAAM,GAAG,SAAS,CAAC,IAAI,EAAE,CAAC;QAClC,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;QAC5E,OAAO,CAAC,IAAI,CACV,8DAA8D,EAC9D,SAAS,CACV,CAAC;QACF,KAAK,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC,CAAC;IAC3B,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["/** A minimal graph node with an `id`. */\nexport type DagNode = {id: string};\n/** A directed edge from `source` to `target`. */\nexport type DagEdge = {source: string; target: string};\n/** Forward adjacency list mapping node id to its child node ids. */\nexport type Adjacency = Record<string, string[]>;\n\n/**\n * Build a forward adjacency list for a directed graph.\n * Ensures that every node id exists in the adjacency map, even if it has no outgoing edges.\n *\n * @param nodes - The set of nodes to include in the graph.\n * @param edges - Directed edges where `source` points to `target`.\n * @returns A mapping from node id to an array of child node ids.\n */\nexport function buildAdjacency(nodes: DagNode[], edges: DagEdge[]): Adjacency {\n const adjacency: Adjacency = {};\n for (const n of nodes) adjacency[n.id] = [];\n for (const e of edges) {\n const list = adjacency[e.source] || (adjacency[e.source] = []);\n list.push(e.target);\n }\n return adjacency;\n}\n\n/**\n * Find a node by id in a list of nodes.\n *\n * @param nodes - Array of nodes with an `id` field.\n * @param id - The node id to find.\n * @returns The node if found, otherwise undefined.\n */\nexport function findNodeById<T extends {id: string}>(\n nodes: T[],\n id: string,\n): T | undefined {\n return nodes.find((n) => n.id === id);\n}\n\n/**\n * Topologically sort all nodes in the graph using Kahn's algorithm.\n * If a cycle is detected, the remaining nodes are appended in arbitrary order,\n * and a warning is logged.\n *\n * @param nodes - The set of nodes to sort.\n * @param edges - Directed edges defining dependencies.\n * @returns An array of node ids in dependency order (parents before children).\n */\nexport function topoSortAll(nodes: DagNode[], edges: DagEdge[]): string[] {\n const adjacency = buildAdjacency(nodes, edges);\n const inDegree: Record<string, number> = {};\n for (const n of nodes) inDegree[n.id] = 0;\n for (const e of edges) {\n inDegree[e.target] = (inDegree[e.target] ?? 0) + 1;\n }\n\n const queue: string[] = Object.keys(inDegree).filter(\n (id) => (inDegree[id] ?? 0) === 0,\n );\n const order: string[] = [];\n while (queue.length) {\n const cur = queue.shift() as string;\n order.push(cur);\n const neighbors = adjacency[cur] || [];\n for (const nb of neighbors) {\n inDegree[nb] = (inDegree[nb] ?? 0) - 1;\n if (inDegree[nb] === 0) queue.push(nb);\n }\n }\n\n if (order.length < nodes.length) {\n const remaining = nodes\n .map((n) => n.id)\n .filter((id) => !order.includes(id));\n console.warn(\n '[dag.topoSortAll] Cycle detected; appending remaining nodes arbitrarily:',\n remaining,\n );\n order.push(...remaining);\n }\n return order;\n}\n\n/**\n * Get a topological order for the downstream subgraph reachable from `startId`.\n * Only nodes reachable from the start are included (the starting node is excluded).\n * If a cycle exists within the reachable subgraph, the remaining nodes are appended\n * at the end in arbitrary order and a warning is logged.\n *\n * @param startId - The node id to start traversal from.\n * @param nodes - The set of nodes in the full graph.\n * @param edges - Directed edges defining the full graph dependencies.\n * @returns Node ids reachable from `startId`, in dependency order.\n */\nexport function topoSortDownstream(\n startId: string,\n nodes: DagNode[],\n edges: DagEdge[],\n): string[] {\n const adjacency = buildAdjacency(nodes, edges);\n // Collect reachable nodes from startId (excluding start)\n const reachable = new Set<string>();\n const queue: string[] = [...(adjacency[startId] || [])];\n while (queue.length) {\n const cur = queue.shift() as string;\n if (reachable.has(cur)) continue;\n reachable.add(cur);\n const neighbors = adjacency[cur] || [];\n for (const nb of neighbors) queue.push(nb);\n }\n if (reachable.size === 0) return [];\n\n // Kahn's algorithm for topological sort within subgraph\n const inDegree: Record<string, number> = {};\n for (const id of reachable) inDegree[id] = 0;\n for (const e of edges) {\n if (reachable.has(e.source) && reachable.has(e.target)) {\n inDegree[e.target] = (inDegree[e.target] ?? 0) + 1;\n }\n }\n const queue2: string[] = Array.from(reachable).filter(\n (id) => (inDegree[id] ?? 0) === 0,\n );\n const order: string[] = [];\n while (queue2.length) {\n const cur = queue2.shift() as string;\n order.push(cur);\n const neighbors = adjacency[cur] || [];\n for (const nb of neighbors) {\n if (!reachable.has(nb)) continue;\n inDegree[nb] = (inDegree[nb] ?? 0) - 1;\n if (inDegree[nb] === 0) queue2.push(nb);\n }\n }\n if (order.length < reachable.size) {\n const remaining = Array.from(reachable).filter((id) => !order.includes(id));\n console.warn(\n '[dag.topoSortDownstream] Cycle detected in downstream graph:',\n remaining,\n );\n order.push(...remaining);\n }\n return order;\n}\n"]}
|
package/dist/nodes/SqlNode.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { FC } from 'react';
|
|
2
|
-
import { CanvasNodeData } from '../CanvasSlice';
|
|
3
|
-
type SqlData = Extract<CanvasNodeData, {
|
|
4
|
-
type: 'sql';
|
|
5
|
-
}>;
|
|
6
|
-
export declare const SqlNode: FC<{
|
|
7
|
-
id: string;
|
|
8
|
-
data: SqlData;
|
|
9
|
-
}>;
|
|
10
|
-
export {};
|
|
11
|
-
//# sourceMappingURL=SqlNode.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SqlNode.d.ts","sourceRoot":"","sources":["../../src/nodes/SqlNode.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAC,EAAE,EAAoB,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAC,cAAc,EAAqB,MAAM,gBAAgB,CAAC;AAelE,KAAK,OAAO,GAAG,OAAO,CAAC,cAAc,EAAE;IAAC,IAAI,EAAE,KAAK,CAAA;CAAC,CAAC,CAAC;AAEtD,eAAO,MAAM,OAAO,EAAE,EAAE,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,OAAO,CAAA;CAAC,CAgGnD,CAAC"}
|
package/dist/nodes/SqlNode.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { QueryDataTable } from '@sqlrooms/data-table';
|
|
3
|
-
import { SqlMonacoEditor } from '@sqlrooms/sql-editor';
|
|
4
|
-
import { Button, useToast } from '@sqlrooms/ui';
|
|
5
|
-
import { useMemo, useState } from 'react';
|
|
6
|
-
import { useStoreWithCanvas } from '../CanvasSlice';
|
|
7
|
-
import { CanvasNodeContainer } from './CanvasNodeContainer';
|
|
8
|
-
// import type * as Monaco from 'monaco-editor';
|
|
9
|
-
// type EditorInstance = Monaco.editor.IStandaloneCodeEditor;
|
|
10
|
-
// type MonacoInstance = typeof Monaco;
|
|
11
|
-
const EDITOR_OPTIONS = {
|
|
12
|
-
minimap: { enabled: false },
|
|
13
|
-
lineNumbers: 'off',
|
|
14
|
-
scrollbar: {
|
|
15
|
-
handleMouseWheel: false,
|
|
16
|
-
},
|
|
17
|
-
fixedOverflowWidgets: false,
|
|
18
|
-
};
|
|
19
|
-
export const SqlNode = ({ id, data }) => {
|
|
20
|
-
const sql = data.sql || '';
|
|
21
|
-
const updateNode = useStoreWithCanvas((s) => s.canvas.updateNode);
|
|
22
|
-
const tables = useStoreWithCanvas((s) => s.db.tables);
|
|
23
|
-
const execute = useStoreWithCanvas((s) => s.canvas.executeSqlNodeQuery);
|
|
24
|
-
const result = useStoreWithCanvas((s) => s.canvas.sqlResults[id]);
|
|
25
|
-
const { toast } = useToast();
|
|
26
|
-
// const handleEditorMount = useCallback(
|
|
27
|
-
// (editor: EditorInstance, monaco: MonacoInstance) => {
|
|
28
|
-
// editor.addCommand(monaco.KeyMod.CtrlCmd | monaco.KeyCode.Enter, () => {
|
|
29
|
-
// if (editor.hasTextFocus()) {
|
|
30
|
-
// execute(id);
|
|
31
|
-
// }
|
|
32
|
-
// });
|
|
33
|
-
// },
|
|
34
|
-
// [execute],
|
|
35
|
-
// );
|
|
36
|
-
// const reactFlowContainerRef = useRef<HTMLDivElement>(null);
|
|
37
|
-
// useEffect(() => {
|
|
38
|
-
// reactFlowContainerRef.current = document.querySelector<HTMLDivElement>(
|
|
39
|
-
// '.react-flow__renderer',
|
|
40
|
-
// );
|
|
41
|
-
// }, []);
|
|
42
|
-
const [overflowWidgetsDomNode, setOverflowWidgetsDomNode] = useState(null);
|
|
43
|
-
const editorOptions = useMemo(() => overflowWidgetsDomNode
|
|
44
|
-
? {
|
|
45
|
-
...EDITOR_OPTIONS,
|
|
46
|
-
overflowWidgetsDomNode: overflowWidgetsDomNode ?? undefined,
|
|
47
|
-
fixedOverflowWidgets: false,
|
|
48
|
-
}
|
|
49
|
-
: EDITOR_OPTIONS, [overflowWidgetsDomNode]);
|
|
50
|
-
return (_jsx(CanvasNodeContainer, { id: id, headerRight: _jsxs(_Fragment, { children: [_jsx(Button, { size: "sm", variant: "secondary", onClick: () => execute(id), children: "Run" }), _jsx("span", { className: "text-[10px] text-gray-500 uppercase", children: "SQL" })] }), children: _jsxs("div", { className: "flex h-full w-full flex-col", children: [_jsx("div", { className: "relative flex-1", children: _jsx(SqlMonacoEditor, { className: "absolute inset-0 p-1", value: sql, options: editorOptions, onChange: (v) => updateNode(id, (d) => ({ ...d, sql: v || '' })), tableSchemas: tables }) }), result?.status === 'error' && (_jsx("div", { className: "flex-1 overflow-auto border-t p-4 font-mono text-xs whitespace-pre-wrap text-red-600", children: result.error })), result?.status === 'success' && (_jsx("div", { className: "flex-2 overflow-hidden border-t", children: _jsx(QueryDataTable, { query: `SELECT * FROM ${result.tableName}`, fontSize: "text-xs" }) }))] }) }));
|
|
51
|
-
};
|
|
52
|
-
//# sourceMappingURL=SqlNode.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SqlNode.js","sourceRoot":"","sources":["../../src/nodes/SqlNode.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAC,eAAe,EAAC,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAC,MAAM,EAAE,QAAQ,EAAC,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAK,OAAO,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAiB,kBAAkB,EAAC,MAAM,gBAAgB,CAAC;AAClE,OAAO,EAAC,mBAAmB,EAAC,MAAM,uBAAuB,CAAC;AAC1D,gDAAgD;AAChD,6DAA6D;AAC7D,uCAAuC;AAEvC,MAAM,cAAc,GAAqD;IACvE,OAAO,EAAE,EAAC,OAAO,EAAE,KAAK,EAAC;IACzB,WAAW,EAAE,KAAK;IAClB,SAAS,EAAE;QACT,gBAAgB,EAAE,KAAK;KACxB;IACD,oBAAoB,EAAE,KAAK;CAC5B,CAAC;AAIF,MAAM,CAAC,MAAM,OAAO,GAAoC,CAAC,EAAC,EAAE,EAAE,IAAI,EAAC,EAAE,EAAE;IACrE,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,IAA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,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,oBAEvD,EACT,eAAM,SAAS,EAAC,qCAAqC,oBAAW,IAC/D,YAGL,eAAK,SAAS,EAAC,6BAA6B,aAC1C,cAAK,SAAS,EAAC,iBAAiB,YAC9B,KAAC,eAAe,IACd,SAAS,EAAC,sBAAsB,EAChC,KAAK,EAAE,GAAG,EACV,OAAO,EAAE,aAAa,EACtB,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CACd,UAAU,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAC,GAAI,CAAa,EAAE,GAAG,EAAE,CAAC,IAAI,EAAE,EAAC,CAAC,CAAC,EAE5D,YAAY,EAAE,MAAM,GAEpB,GACE,EACL,MAAM,EAAE,MAAM,KAAK,OAAO,IAAI,CAC7B,cAAK,SAAS,EAAC,sFAAsF,YAClG,MAAM,CAAC,KAAK,GACT,CACP,EACA,MAAM,EAAE,MAAM,KAAK,SAAS,IAAI,CAC/B,cAAK,SAAS,EAAC,iCAAiC,YAC9C,KAAC,cAAc,IACb,KAAK,EAAE,iBAAiB,MAAM,CAAC,SAAS,EAAE,EAC1C,QAAQ,EAAC,SAAS,GAClB,GACE,CACP,IACG,GAgBc,CACvB,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import {QueryDataTable} from '@sqlrooms/data-table';\nimport {SqlMonacoEditor} from '@sqlrooms/sql-editor';\nimport {Button, useToast} from '@sqlrooms/ui';\nimport {FC, useMemo, useState} from 'react';\nimport {CanvasNodeData, useStoreWithCanvas} from '../CanvasSlice';\nimport {CanvasNodeContainer} from './CanvasNodeContainer';\n// import type * as Monaco from 'monaco-editor';\n// type EditorInstance = Monaco.editor.IStandaloneCodeEditor;\n// type MonacoInstance = typeof Monaco;\n\nconst EDITOR_OPTIONS: Parameters<typeof SqlMonacoEditor>[0]['options'] = {\n minimap: {enabled: false},\n lineNumbers: 'off',\n scrollbar: {\n handleMouseWheel: false,\n },\n fixedOverflowWidgets: false,\n};\n\ntype SqlData = Extract<CanvasNodeData, {type: 'sql'}>;\n\nexport const SqlNode: FC<{id: string; data: SqlData}> = ({id, data}) => {\n const sql = data.sql || '';\n const updateNode = useStoreWithCanvas((s) => s.canvas.updateNode);\n const tables = useStoreWithCanvas((s) => s.db.tables);\n const execute = useStoreWithCanvas((s) => s.canvas.executeSqlNodeQuery);\n const result = useStoreWithCanvas((s) => s.canvas.sqlResults[id]);\n const {toast} = useToast();\n\n // const handleEditorMount = useCallback(\n // (editor: EditorInstance, monaco: MonacoInstance) => {\n // editor.addCommand(monaco.KeyMod.CtrlCmd | monaco.KeyCode.Enter, () => {\n // if (editor.hasTextFocus()) {\n // execute(id);\n // }\n // });\n // },\n // [execute],\n // );\n\n // const reactFlowContainerRef = useRef<HTMLDivElement>(null);\n // useEffect(() => {\n // reactFlowContainerRef.current = document.querySelector<HTMLDivElement>(\n // '.react-flow__renderer',\n // );\n // }, []);\n const [overflowWidgetsDomNode, setOverflowWidgetsDomNode] =\n useState<HTMLDivElement | null>(null);\n\n const editorOptions = useMemo(\n (): typeof EDITOR_OPTIONS =>\n overflowWidgetsDomNode\n ? {\n ...EDITOR_OPTIONS,\n overflowWidgetsDomNode: overflowWidgetsDomNode ?? undefined,\n fixedOverflowWidgets: false,\n }\n : EDITOR_OPTIONS,\n [overflowWidgetsDomNode],\n );\n\n return (\n <CanvasNodeContainer\n id={id}\n headerRight={\n <>\n <Button size=\"sm\" variant=\"secondary\" onClick={() => execute(id)}>\n Run\n </Button>\n <span className=\"text-[10px] text-gray-500 uppercase\">SQL</span>\n </>\n }\n >\n <div className=\"flex h-full w-full flex-col\">\n <div className=\"relative flex-1\">\n <SqlMonacoEditor\n className=\"absolute inset-0 p-1\"\n value={sql}\n options={editorOptions}\n onChange={(v) =>\n updateNode(id, (d) => ({...(d as SqlData), sql: v || ''}))\n }\n tableSchemas={tables}\n // onMount={handleEditorMount}\n />\n </div>\n {result?.status === 'error' && (\n <div className=\"flex-1 overflow-auto border-t p-4 font-mono text-xs whitespace-pre-wrap text-red-600\">\n {result.error}\n </div>\n )}\n {result?.status === 'success' && (\n <div className=\"flex-2 overflow-hidden border-t\">\n <QueryDataTable\n query={`SELECT * FROM ${result.tableName}`}\n fontSize=\"text-xs\"\n />\n </div>\n )}\n </div>\n {/* {reactFlowContainerRef.current &&\n createPortal(\n <div\n ref={(node) => {\n if (node && !overflowWidgetsDomNode) {\n setOverflowWidgetsDomNode(node);\n }\n }}\n // CRITICAL: You must re-apply the monaco class here!\n className=\"monaco-editor\"\n // CRITICAL: Styles to ensure overlays position correctly relative to window\n style={{position: 'absolute', top: 0, left: 0}}\n />,\n reactFlowContainerRef.current,\n )} */}\n </CanvasNodeContainer>\n );\n};\n"]}
|
package/dist/nodes/VegaNode.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { FC } from 'react';
|
|
2
|
-
import { CanvasNodeData } from '../CanvasSlice';
|
|
3
|
-
type VegaData = Extract<CanvasNodeData, {
|
|
4
|
-
type: 'vega';
|
|
5
|
-
}>;
|
|
6
|
-
export declare const VegaNode: FC<{
|
|
7
|
-
id: string;
|
|
8
|
-
data: VegaData;
|
|
9
|
-
}>;
|
|
10
|
-
export {};
|
|
11
|
-
//# sourceMappingURL=VegaNode.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"VegaNode.d.ts","sourceRoot":"","sources":["../../src/nodes/VegaNode.tsx"],"names":[],"mappings":"AACA,OAAO,EAAC,EAAE,EAAC,MAAM,OAAO,CAAC;AACzB,OAAO,EAAC,cAAc,EAAC,MAAM,gBAAgB,CAAC;AAG9C,KAAK,QAAQ,GAAG,OAAO,CAAC,cAAc,EAAE;IAAC,IAAI,EAAE,MAAM,CAAA;CAAC,CAAC,CAAC;AAExD,eAAO,MAAM,QAAQ,EAAE,EAAE,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,QAAQ,CAAA;CAAC,CA2BrD,CAAC"}
|
package/dist/nodes/VegaNode.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { VegaLiteChart } from '@sqlrooms/vega';
|
|
3
|
-
import { CanvasNodeContainer } from './CanvasNodeContainer';
|
|
4
|
-
export const VegaNode = ({ id, data }) => {
|
|
5
|
-
const spec = (data.vegaSpec || {
|
|
6
|
-
mark: 'point',
|
|
7
|
-
data: { values: [] },
|
|
8
|
-
});
|
|
9
|
-
const { vegaSpec, sql } = data;
|
|
10
|
-
return (_jsx(CanvasNodeContainer, { id: id, headerRight: _jsx("span", { className: "text-[10px] uppercase text-gray-500", children: "Vega" }), children: _jsx("div", { className: "h-full flex-1 overflow-hidden p-2", children: sql && vegaSpec ? (_jsx(VegaLiteChart, { spec: vegaSpec, sqlQuery: sql, aspectRatio: 16 / 9, className: "h-full" })) : null }) }));
|
|
11
|
-
};
|
|
12
|
-
//# sourceMappingURL=VegaNode.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"VegaNode.js","sourceRoot":"","sources":["../../src/nodes/VegaNode.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,aAAa,EAAyB,MAAM,gBAAgB,CAAC;AAGrE,OAAO,EAAC,mBAAmB,EAAC,MAAM,uBAAuB,CAAC;AAI1D,MAAM,CAAC,MAAM,QAAQ,GAAqC,CAAC,EAAC,EAAE,EAAE,IAAI,EAAC,EAAE,EAAE;IACvE,MAAM,IAAI,GAAG,CAAC,IAAI,CAAC,QAAQ,IAAI;QAC7B,IAAI,EAAE,OAAO;QACb,IAAI,EAAE,EAAC,MAAM,EAAE,EAAE,EAAC;KACnB,CAAsB,CAAC;IAExB,MAAM,EAAC,QAAQ,EAAE,GAAG,EAAC,GAAG,IAAI,CAAC;IAE7B,OAAO,CACL,KAAC,mBAAmB,IAClB,EAAE,EAAE,EAAE,EACN,WAAW,EACT,eAAM,SAAS,EAAC,qCAAqC,qBAAY,YAGnE,cAAK,SAAS,EAAC,mCAAmC,YAC/C,GAAG,IAAI,QAAQ,CAAC,CAAC,CAAC,CACjB,KAAC,aAAa,IACZ,IAAI,EAAE,QAAQ,EACd,QAAQ,EAAE,GAAG,EACb,WAAW,EAAE,EAAE,GAAG,CAAC,EACnB,SAAS,EAAC,QAAQ,GAClB,CACH,CAAC,CAAC,CAAC,IAAI,GACJ,GACc,CACvB,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import {VegaLiteChart, type VisualizationSpec} from '@sqlrooms/vega';\nimport {FC} from 'react';\nimport {CanvasNodeData} from '../CanvasSlice';\nimport {CanvasNodeContainer} from './CanvasNodeContainer';\n\ntype VegaData = Extract<CanvasNodeData, {type: 'vega'}>;\n\nexport const VegaNode: FC<{id: string; data: VegaData}> = ({id, data}) => {\n const spec = (data.vegaSpec || {\n mark: 'point',\n data: {values: []},\n }) as VisualizationSpec;\n\n const {vegaSpec, sql} = data;\n\n return (\n <CanvasNodeContainer\n id={id}\n headerRight={\n <span className=\"text-[10px] uppercase text-gray-500\">Vega</span>\n }\n >\n <div className=\"h-full flex-1 overflow-hidden p-2\">\n {sql && vegaSpec ? (\n <VegaLiteChart\n spec={vegaSpec}\n sqlQuery={sql}\n aspectRatio={16 / 9}\n className=\"h-full\"\n />\n ) : null}\n </div>\n </CanvasNodeContainer>\n );\n};\n"]}
|