@sqlrooms/schema-tree 0.24.4 → 0.24.6
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.
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { TableNodeObject } from '@sqlrooms/duckdb';
|
|
2
2
|
import { FC } from 'react';
|
|
3
|
-
|
|
3
|
+
import { useDisclosure } from '@sqlrooms/ui';
|
|
4
|
+
export declare const defaultRenderTableNodeMenuItems: (nodeObject: TableNodeObject, tableModal: ReturnType<typeof useDisclosure>) => import("react/jsx-runtime").JSX.Element;
|
|
4
5
|
export declare const TableTreeNode: FC<{
|
|
5
6
|
className?: string;
|
|
6
7
|
nodeObject: TableNodeObject;
|
|
7
|
-
renderMenuItems?: (nodeObject: TableNodeObject) => React.ReactNode;
|
|
8
|
+
renderMenuItems?: (nodeObject: TableNodeObject, tableModal: ReturnType<typeof useDisclosure>) => React.ReactNode;
|
|
8
9
|
}>;
|
|
9
10
|
//# sourceMappingURL=TableTreeNode.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableTreeNode.d.ts","sourceRoot":"","sources":["../../src/nodes/TableTreeNode.tsx"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"TableTreeNode.d.ts","sourceRoot":"","sources":["../../src/nodes/TableTreeNode.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAyB,eAAe,EAAC,MAAM,kBAAkB,CAAC;AAEzE,OAAO,EAAC,EAAE,EAAC,MAAM,OAAO,CAAC;AACzB,OAAO,EAAC,aAAa,EAAC,MAAM,cAAc,CAAC;AAQ3C,eAAO,MAAM,+BAA+B,GAC1C,YAAY,eAAe,EAC3B,YAAY,UAAU,CAAC,OAAO,aAAa,CAAC,4CA+C7C,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,EAAE,CAAC;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,eAAe,CAAC;IAC5B,eAAe,CAAC,EAAE,CAChB,UAAU,EAAE,eAAe,EAC3B,UAAU,EAAE,UAAU,CAAC,OAAO,aAAa,CAAC,KACzC,KAAK,CAAC,SAAS,CAAC;CACtB,CAkCA,CAAC"}
|
|
@@ -1,24 +1,38 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
|
|
2
|
+
// Copyright 2022 Foursquare Labs, Inc. All Rights Reserved.
|
|
3
|
+
import { makeQualifiedTableName } from '@sqlrooms/duckdb';
|
|
4
|
+
import { CopyIcon, EyeIcon, SquareTerminalIcon, TableIcon } from 'lucide-react';
|
|
5
|
+
import { useDisclosure } from '@sqlrooms/ui';
|
|
6
|
+
import DataTableModal from '@sqlrooms/data-table/src/DataTableModal';
|
|
3
7
|
import { BaseTreeNode } from './BaseTreeNode';
|
|
4
8
|
import { TreeNodeActionsMenu, TreeNodeActionsMenuItem, } from './TreeNodeActionsMenu';
|
|
5
|
-
export const defaultRenderTableNodeMenuItems = (nodeObject) => {
|
|
9
|
+
export const defaultRenderTableNodeMenuItems = (nodeObject, tableModal) => {
|
|
6
10
|
const { database, schema, name } = nodeObject;
|
|
11
|
+
const qualifiedTableName = makeQualifiedTableName({
|
|
12
|
+
database,
|
|
13
|
+
schema,
|
|
14
|
+
table: name,
|
|
15
|
+
});
|
|
7
16
|
return (_jsxs(_Fragment, { children: [_jsxs(TreeNodeActionsMenuItem, { onClick: () => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
17
|
+
tableModal.onOpen();
|
|
18
|
+
}, children: [_jsx(EyeIcon, { width: "15px" }), "View table"] }), _jsxs(TreeNodeActionsMenuItem, { onClick: () => {
|
|
19
|
+
navigator.clipboard.writeText(qualifiedTableName.table);
|
|
11
20
|
}, children: [_jsx(CopyIcon, { width: "15px" }), "Copy table name"] }), _jsxs(TreeNodeActionsMenuItem, { onClick: () => {
|
|
12
|
-
navigator.clipboard.writeText(
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
schema === 'main' ? '' : `${schema}.`,
|
|
16
|
-
name,
|
|
17
|
-
].join(''));
|
|
21
|
+
navigator.clipboard.writeText(qualifiedTableName.toString());
|
|
22
|
+
}, children: [_jsx(CopyIcon, { width: "15px" }), "Copy qualified table name"] }), _jsxs(TreeNodeActionsMenuItem, { onClick: () => {
|
|
23
|
+
navigator.clipboard.writeText(`SELECT * FROM ${qualifiedTableName}`);
|
|
18
24
|
}, children: [_jsx(SquareTerminalIcon, { width: "15px" }), "Copy SELECT query"] })] }));
|
|
19
25
|
};
|
|
20
26
|
export const TableTreeNode = (props) => {
|
|
21
27
|
const { className, nodeObject, renderMenuItems = defaultRenderTableNodeMenuItems, } = props;
|
|
22
|
-
|
|
28
|
+
const tableModal = useDisclosure();
|
|
29
|
+
const { database, schema, name } = nodeObject;
|
|
30
|
+
const qualifiedTableName = makeQualifiedTableName({
|
|
31
|
+
database,
|
|
32
|
+
schema,
|
|
33
|
+
table: name,
|
|
34
|
+
});
|
|
35
|
+
const sqlQuery = `SELECT * FROM ${qualifiedTableName}`;
|
|
36
|
+
return (_jsxs(_Fragment, { children: [_jsxs(BaseTreeNode, { asChild: true, className: className, nodeObject: nodeObject, children: [_jsxs("div", { className: "flex w-full items-center space-x-2", children: [_jsx(TableIcon, { size: "16px", className: "shrink-0 text-blue-500" }), _jsx("span", { className: "text-sm", children: nodeObject.name })] }), _jsx(TreeNodeActionsMenu, { children: renderMenuItems(nodeObject, tableModal) })] }), _jsx(DataTableModal, { title: qualifiedTableName.table, query: sqlQuery, tableModal: tableModal })] }));
|
|
23
37
|
};
|
|
24
38
|
//# sourceMappingURL=TableTreeNode.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableTreeNode.js","sourceRoot":"","sources":["../../src/nodes/TableTreeNode.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"TableTreeNode.js","sourceRoot":"","sources":["../../src/nodes/TableTreeN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{CopyIcon, EyeIcon, SquareTerminalIcon, TableIcon} from 'lucide-react';\nimport {FC} from 'react';\nimport {useDisclosure} from '@sqlrooms/ui';\nimport DataTableModal from '@sqlrooms/data-table/src/DataTableModal';\nimport {BaseTreeNode} from './BaseTreeNode';\nimport {\n TreeNodeActionsMenu,\n TreeNodeActionsMenuItem,\n} from './TreeNodeActionsMenu';\n\nexport const defaultRenderTableNodeMenuItems = (\n nodeObject: TableNodeObject,\n tableModal: ReturnType<typeof useDisclosure>,\n) => {\n const {database, schema, name} = nodeObject;\n const qualifiedTableName = makeQualifiedTableName({\n database,\n schema,\n table: name,\n });\n return (\n <>\n <TreeNodeActionsMenuItem\n onClick={() => {\n tableModal.onOpen();\n }}\n >\n <EyeIcon width=\"15px\" />\n View table\n </TreeNodeActionsMenuItem>\n\n <TreeNodeActionsMenuItem\n onClick={() => {\n navigator.clipboard.writeText(qualifiedTableName.table);\n }}\n >\n <CopyIcon width=\"15px\" />\n Copy table name\n </TreeNodeActionsMenuItem>\n\n <TreeNodeActionsMenuItem\n onClick={() => {\n navigator.clipboard.writeText(qualifiedTableName.toString());\n }}\n >\n <CopyIcon width=\"15px\" />\n Copy qualified table name\n </TreeNodeActionsMenuItem>\n\n <TreeNodeActionsMenuItem\n onClick={() => {\n navigator.clipboard.writeText(`SELECT * FROM ${qualifiedTableName}`);\n }}\n >\n <SquareTerminalIcon width=\"15px\" />\n Copy SELECT query\n </TreeNodeActionsMenuItem>\n </>\n );\n};\n\nexport const TableTreeNode: FC<{\n className?: string;\n nodeObject: TableNodeObject;\n renderMenuItems?: (\n nodeObject: TableNodeObject,\n tableModal: ReturnType<typeof useDisclosure>,\n ) => React.ReactNode;\n}> = (props) => {\n const {\n className,\n nodeObject,\n renderMenuItems = defaultRenderTableNodeMenuItems,\n } = props;\n\n const tableModal = useDisclosure();\n const {database, schema, name} = nodeObject;\n const qualifiedTableName = makeQualifiedTableName({\n database,\n schema,\n table: name,\n });\n const sqlQuery = `SELECT * FROM ${qualifiedTableName}`;\n\n return (\n <>\n <BaseTreeNode asChild className={className} nodeObject={nodeObject}>\n <div className=\"flex w-full items-center space-x-2\">\n <TableIcon size=\"16px\" className=\"shrink-0 text-blue-500\" />\n <span className=\"text-sm\">{nodeObject.name}</span>\n </div>\n <TreeNodeActionsMenu>\n {renderMenuItems(nodeObject, tableModal)}\n </TreeNodeActionsMenu>\n </BaseTreeNode>\n <DataTableModal\n title={qualifiedTableName.table}\n query={sqlQuery}\n tableModal={tableModal}\n />\n </>\n );\n};\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sqlrooms/schema-tree",
|
|
3
|
-
"version": "0.24.
|
|
3
|
+
"version": "0.24.6",
|
|
4
4
|
"author": "Ilya Boyandin <ilya@boyandin.me>",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -24,9 +24,9 @@
|
|
|
24
24
|
"typedoc": "typedoc"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@sqlrooms/data-table": "0.24.
|
|
28
|
-
"@sqlrooms/duckdb": "0.24.
|
|
29
|
-
"@sqlrooms/ui": "0.24.
|
|
27
|
+
"@sqlrooms/data-table": "0.24.6",
|
|
28
|
+
"@sqlrooms/duckdb": "0.24.6",
|
|
29
|
+
"@sqlrooms/ui": "0.24.6",
|
|
30
30
|
"lucide-react": "^0.474.0"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
@@ -37,5 +37,5 @@
|
|
|
37
37
|
"@types/react": "^19.1.7",
|
|
38
38
|
"@types/react-dom": "^19.1.6"
|
|
39
39
|
},
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "01a7755107ec723941119e24683b89a907817fc4"
|
|
41
41
|
}
|