@sqlrooms/schema-tree 0.24.14 → 0.24.16
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/dist/nodes/BaseTreeNode.js +1 -1
- package/dist/nodes/BaseTreeNode.js.map +1 -1
- package/dist/nodes/ColumnTreeNode.d.ts.map +1 -1
- package/dist/nodes/ColumnTreeNode.js +2 -1
- package/dist/nodes/ColumnTreeNode.js.map +1 -1
- package/dist/nodes/TableTreeNode.d.ts +1 -1
- package/dist/nodes/TableTreeNode.d.ts.map +1 -1
- package/dist/nodes/TableTreeNode.js +14 -9
- package/dist/nodes/TableTreeNode.js.map +1 -1
- package/package.json +6 -5
|
@@ -3,6 +3,6 @@ import { cn, Slot } from '@sqlrooms/ui';
|
|
|
3
3
|
export function BaseTreeNode(props) {
|
|
4
4
|
const { className, asChild, children } = props;
|
|
5
5
|
const Comp = asChild ? Slot : 'div';
|
|
6
|
-
return (_jsx(Comp, { className: cn('hover:bg-foreground/10 w-full flex-grow cursor-pointer rounded-sm p-[1px]
|
|
6
|
+
return (_jsx(Comp, { className: cn('hover:bg-foreground/10 h-[22px] w-full flex-grow cursor-pointer select-none rounded-sm p-[1px]', className), children: _jsx("div", { className: cn('group relative flex w-full items-center overflow-hidden', className), children: _jsx("div", { className: "absolute h-full w-full items-center", children: children }) }) }));
|
|
7
7
|
}
|
|
8
8
|
//# sourceMappingURL=BaseTreeNode.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseTreeNode.js","sourceRoot":"","sources":["../../src/nodes/BaseTreeNode.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,EAAE,EAAE,IAAI,EAAC,MAAM,cAAc,CAAC;AAGtC,MAAM,UAAU,YAAY,CAC1B,KAIE;IAEF,MAAM,EAAC,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAC,GAAG,KAAK,CAAC;IAC7C,MAAM,IAAI,GAAG,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;IACpC,OAAO,CACL,KAAC,IAAI,IACH,SAAS,EAAE,EAAE,CACX,
|
|
1
|
+
{"version":3,"file":"BaseTreeNode.js","sourceRoot":"","sources":["../../src/nodes/BaseTreeNode.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,EAAE,EAAE,IAAI,EAAC,MAAM,cAAc,CAAC;AAGtC,MAAM,UAAU,YAAY,CAC1B,KAIE;IAEF,MAAM,EAAC,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAC,GAAG,KAAK,CAAC;IAC7C,MAAM,IAAI,GAAG,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;IACpC,OAAO,CACL,KAAC,IAAI,IACH,SAAS,EAAE,EAAE,CACX,gGAAgG,EAChG,SAAS,CACV,YAED,cACE,SAAS,EAAE,EAAE,CACX,yDAAyD,EACzD,SAAS,CACV,YAED,cAAK,SAAS,EAAC,qCAAqC,YAAE,QAAQ,GAAO,GACjE,GACD,CACR,CAAC;AACJ,CAAC","sourcesContent":["import {cn, Slot} from '@sqlrooms/ui';\nimport {PropsWithChildren} from 'react';\n\nexport function BaseTreeNode<T>(\n props: PropsWithChildren<{\n className?: string;\n nodeObject: T;\n asChild?: boolean;\n }>,\n) {\n const {className, asChild, children} = props;\n const Comp = asChild ? Slot : 'div';\n return (\n <Comp\n className={cn(\n 'hover:bg-foreground/10 h-[22px] w-full flex-grow cursor-pointer select-none rounded-sm p-[1px]',\n className,\n )}\n >\n <div\n className={cn(\n 'group relative flex w-full items-center overflow-hidden',\n className,\n )}\n >\n <div className=\"absolute h-full w-full items-center\">{children}</div>\n </div>\n </Comp>\n );\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ColumnTreeNode.d.ts","sourceRoot":"","sources":["../../src/nodes/ColumnTreeNode.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAC,gBAAgB,EAAC,MAAM,kBAAkB,CAAC;AAElD,OAAO,EAAC,EAAE,EAAC,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"ColumnTreeNode.d.ts","sourceRoot":"","sources":["../../src/nodes/ColumnTreeNode.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAC,gBAAgB,EAAC,MAAM,kBAAkB,CAAC;AAElD,OAAO,EAAC,EAAE,EAAC,MAAM,OAAO,CAAC;AAQzB,eAAO,MAAM,cAAc,EAAE,EAAE,CAAC;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,gBAAgB,CAAC;IAC7B,mBAAmB,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CACvC,CA2BA,CAAC"}
|
|
@@ -4,8 +4,9 @@ import { ColumnTypeBadge } from '@sqlrooms/data-table';
|
|
|
4
4
|
import { CopyIcon } from 'lucide-react';
|
|
5
5
|
import { BaseTreeNode } from './BaseTreeNode';
|
|
6
6
|
import { TreeNodeActionsMenu, TreeNodeActionsMenuItem, } from './TreeNodeActionsMenu';
|
|
7
|
+
import { cn } from '@sqlrooms/ui';
|
|
7
8
|
export const ColumnTreeNode = (props) => {
|
|
8
9
|
const { className, nodeObject, additionalMenuItems } = props;
|
|
9
|
-
return (_jsxs(BaseTreeNode, { asChild: true, className: className, nodeObject: nodeObject, children: [_jsxs("div", { className: "flex w-full items-center space-x-2", children: [_jsx(ColumnTypeBadge, { className: "opacity-50", columnType: nodeObject.columnType, typeCategory: nodeObject.columnTypeCategory }), _jsx("span", { className: "text-xs", children: nodeObject.name })] }), _jsxs(TreeNodeActionsMenu, { children: [_jsxs(TreeNodeActionsMenuItem, { onClick: () => navigator.clipboard.writeText(nodeObject.name), children: [_jsx(CopyIcon, { width: "15px" }), "Copy column name"] }), additionalMenuItems] })] }));
|
|
10
|
+
return (_jsxs(BaseTreeNode, { asChild: true, className: cn(className, 'h-[18px]'), nodeObject: nodeObject, children: [_jsxs("div", { className: "flex w-full items-center space-x-2", children: [_jsx(ColumnTypeBadge, { className: "opacity-50", columnType: nodeObject.columnType, typeCategory: nodeObject.columnTypeCategory }), _jsx("span", { className: "text-xs", children: nodeObject.name })] }), _jsxs(TreeNodeActionsMenu, { children: [_jsxs(TreeNodeActionsMenuItem, { onClick: () => navigator.clipboard.writeText(nodeObject.name), children: [_jsx(CopyIcon, { width: "15px" }), "Copy column name"] }), additionalMenuItems] })] }));
|
|
10
11
|
};
|
|
11
12
|
//# sourceMappingURL=ColumnTreeNode.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ColumnTreeNode.js","sourceRoot":"","sources":["../../src/nodes/ColumnTreeNode.tsx"],"names":[],"mappings":";AAAA,4DAA4D;AAE5D,OAAO,EAAC,eAAe,EAAC,MAAM,sBAAsB,CAAC;AAErD,OAAO,EAAC,QAAQ,EAAC,MAAM,cAAc,CAAC;AAEtC,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EACL,mBAAmB,EACnB,uBAAuB,GACxB,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"ColumnTreeNode.js","sourceRoot":"","sources":["../../src/nodes/ColumnTreeNode.tsx"],"names":[],"mappings":";AAAA,4DAA4D;AAE5D,OAAO,EAAC,eAAe,EAAC,MAAM,sBAAsB,CAAC;AAErD,OAAO,EAAC,QAAQ,EAAC,MAAM,cAAc,CAAC;AAEtC,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EACL,mBAAmB,EACnB,uBAAuB,GACxB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAC,EAAE,EAAC,MAAM,cAAc,CAAC;AAEhC,MAAM,CAAC,MAAM,cAAc,GAItB,CAAC,KAAK,EAAE,EAAE;IACb,MAAM,EAAC,SAAS,EAAE,UAAU,EAAE,mBAAmB,EAAC,GAAG,KAAK,CAAC;IAC3D,OAAO,CACL,MAAC,YAAY,IACX,OAAO,QACP,SAAS,EAAE,EAAE,CAAC,SAAS,EAAE,UAAU,CAAC,EACpC,UAAU,EAAE,UAAU,aAEtB,eAAK,SAAS,EAAC,oCAAoC,aACjD,KAAC,eAAe,IACd,SAAS,EAAC,YAAY,EACtB,UAAU,EAAE,UAAU,CAAC,UAAU,EACjC,YAAY,EAAE,UAAU,CAAC,kBAAkB,GAC3C,EACF,eAAM,SAAS,EAAC,SAAS,YAAE,UAAU,CAAC,IAAI,GAAQ,IAC9C,EACN,MAAC,mBAAmB,eAClB,MAAC,uBAAuB,IACtB,OAAO,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,SAAS,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,aAE7D,KAAC,QAAQ,IAAC,KAAK,EAAC,MAAM,GAAG,wBAED,EACzB,mBAAmB,IACA,IACT,CAChB,CAAC;AACJ,CAAC,CAAC","sourcesContent":["// Copyright 2022 Foursquare Labs, Inc. All Rights Reserved.\n\nimport {ColumnTypeBadge} from '@sqlrooms/data-table';\nimport {ColumnNodeObject} from '@sqlrooms/duckdb';\nimport {CopyIcon} from 'lucide-react';\nimport {FC} from 'react';\nimport {BaseTreeNode} from './BaseTreeNode';\nimport {\n TreeNodeActionsMenu,\n TreeNodeActionsMenuItem,\n} from './TreeNodeActionsMenu';\nimport {cn} from '@sqlrooms/ui';\n\nexport const ColumnTreeNode: FC<{\n className?: string;\n nodeObject: ColumnNodeObject;\n additionalMenuItems?: React.ReactNode;\n}> = (props) => {\n const {className, nodeObject, additionalMenuItems} = props;\n return (\n <BaseTreeNode\n asChild\n className={cn(className, 'h-[18px]')}\n nodeObject={nodeObject}\n >\n <div className=\"flex w-full items-center space-x-2\">\n <ColumnTypeBadge\n className=\"opacity-50\"\n columnType={nodeObject.columnType}\n typeCategory={nodeObject.columnTypeCategory}\n />\n <span className=\"text-xs\">{nodeObject.name}</span>\n </div>\n <TreeNodeActionsMenu>\n <TreeNodeActionsMenuItem\n onClick={() => navigator.clipboard.writeText(nodeObject.name)}\n >\n <CopyIcon width=\"15px\" />\n Copy column name\n </TreeNodeActionsMenuItem>\n {additionalMenuItems}\n </TreeNodeActionsMenu>\n </BaseTreeNode>\n );\n};\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TableNodeObject } from '@sqlrooms/duckdb';
|
|
2
|
-
import { FC } from 'react';
|
|
3
2
|
import { useDisclosure } from '@sqlrooms/ui';
|
|
3
|
+
import { FC } from 'react';
|
|
4
4
|
export declare const defaultRenderTableNodeMenuItems: (nodeObject: TableNodeObject, viewTableModal?: ReturnType<typeof useDisclosure>) => import("react/jsx-runtime").JSX.Element;
|
|
5
5
|
export declare const TableTreeNode: FC<{
|
|
6
6
|
className?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableTreeNode.d.ts","sourceRoot":"","sources":["../../src/nodes/TableTreeNode.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"TableTreeNode.d.ts","sourceRoot":"","sources":["../../src/nodes/TableTreeNode.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAyB,eAAe,EAAC,MAAM,kBAAkB,CAAC;AACzE,OAAO,EAAC,aAAa,EAAC,MAAM,cAAc,CAAC;AAG3C,OAAO,EAAC,EAAE,EAAC,MAAM,OAAO,CAAC;AAOzB,eAAO,MAAM,+BAA+B,GAC1C,YAAY,eAAe,EAC3B,iBAAiB,UAAU,CAAC,OAAO,aAAa,CAAC,4CA4DlD,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,CA6CA,CAAC"}
|
|
@@ -1,13 +1,14 @@
|
|
|
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 { DataTableModal } from '@sqlrooms/data-table';
|
|
3
4
|
import { makeQualifiedTableName } from '@sqlrooms/duckdb';
|
|
4
|
-
import { CopyIcon, EyeIcon, SquareTerminalIcon, TableIcon } from 'lucide-react';
|
|
5
5
|
import { useDisclosure } from '@sqlrooms/ui';
|
|
6
|
-
import {
|
|
6
|
+
import { formatCount } from '@sqlrooms/utils';
|
|
7
|
+
import { CopyIcon, EyeIcon, TableIcon, ViewIcon } from 'lucide-react';
|
|
7
8
|
import { BaseTreeNode } from './BaseTreeNode';
|
|
8
9
|
import { TreeNodeActionsMenu, TreeNodeActionsMenuItem, } from './TreeNodeActionsMenu';
|
|
9
10
|
export const defaultRenderTableNodeMenuItems = (nodeObject, viewTableModal) => {
|
|
10
|
-
const { database, schema, name } = nodeObject;
|
|
11
|
+
const { database, schema, name, sql, isView } = nodeObject;
|
|
11
12
|
const qualifiedTableName = makeQualifiedTableName({
|
|
12
13
|
database,
|
|
13
14
|
schema,
|
|
@@ -15,24 +16,28 @@ export const defaultRenderTableNodeMenuItems = (nodeObject, viewTableModal) => {
|
|
|
15
16
|
});
|
|
16
17
|
return (_jsxs(_Fragment, { children: [viewTableModal && (_jsxs(TreeNodeActionsMenuItem, { onClick: () => {
|
|
17
18
|
viewTableModal.onOpen();
|
|
18
|
-
}, children: [_jsx(EyeIcon, { width: "15px" }), "View
|
|
19
|
+
}, children: [_jsx(EyeIcon, { width: "15px" }), "View data"] })), _jsxs(TreeNodeActionsMenuItem, { onClick: () => {
|
|
19
20
|
navigator.clipboard.writeText(qualifiedTableName.table);
|
|
20
|
-
}, children: [_jsx(CopyIcon, { width: "15px" }), "Copy table name"] }), _jsxs(TreeNodeActionsMenuItem, { onClick: () => {
|
|
21
|
+
}, children: [_jsx(CopyIcon, { width: "15px" }), "Copy ", isView ? 'view' : 'table', " name"] }), _jsxs(TreeNodeActionsMenuItem, { onClick: () => {
|
|
21
22
|
navigator.clipboard.writeText(qualifiedTableName.toString());
|
|
22
|
-
}, children: [_jsx(CopyIcon, { width: "15px" }), "Copy qualified table name"] }), _jsxs(TreeNodeActionsMenuItem, { onClick: () => {
|
|
23
|
+
}, children: [_jsx(CopyIcon, { width: "15px" }), "Copy qualified ", isView ? 'view' : 'table', " name"] }), _jsxs(TreeNodeActionsMenuItem, { onClick: () => {
|
|
23
24
|
navigator.clipboard.writeText(`SELECT * FROM ${qualifiedTableName}`);
|
|
24
|
-
}, children: [_jsx(
|
|
25
|
+
}, children: [_jsx(CopyIcon, { width: "15px" }), "Copy SELECT query"] }), _jsxs(TreeNodeActionsMenuItem, { onClick: () => {
|
|
26
|
+
if (sql) {
|
|
27
|
+
navigator.clipboard.writeText(sql);
|
|
28
|
+
}
|
|
29
|
+
}, disabled: !sql, children: [_jsx(CopyIcon, { width: "15px" }), "Copy CREATE ", isView ? 'VIEW' : 'TABLE'] })] }));
|
|
25
30
|
};
|
|
26
31
|
export const TableTreeNode = (props) => {
|
|
27
32
|
const { className, nodeObject, renderMenuItems = defaultRenderTableNodeMenuItems, } = props;
|
|
28
33
|
const tableModal = useDisclosure();
|
|
29
|
-
const { database, schema, name } = nodeObject;
|
|
34
|
+
const { database, schema, name, rowCount, isView } = nodeObject;
|
|
30
35
|
const qualifiedTableName = makeQualifiedTableName({
|
|
31
36
|
database,
|
|
32
37
|
schema,
|
|
33
38
|
table: name,
|
|
34
39
|
});
|
|
35
40
|
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:
|
|
41
|
+
return (_jsxs(_Fragment, { children: [_jsxs(BaseTreeNode, { asChild: true, className: className, nodeObject: nodeObject, children: [_jsxs("div", { className: "relative flex w-full items-center space-x-2", children: [isView ? (_jsx(ViewIcon, { size: "16px", className: "shrink-0 text-blue-500" })) : (_jsx(TableIcon, { size: "16px", className: "shrink-0 text-blue-500" })), _jsxs("div", { className: "flex w-full items-center justify-between gap-2", children: [_jsx("span", { className: "text-sm", children: name }), rowCount !== undefined && (_jsxs("span", { className: "text-muted-foreground/50 ml-1 whitespace-nowrap pr-5 text-xs", children: [formatCount(rowCount), " ", rowCount === 1 ? 'row' : 'rows'] }))] })] }), _jsx(TreeNodeActionsMenu, { children: renderMenuItems(nodeObject, tableModal) })] }), _jsx(DataTableModal, { title: qualifiedTableName.table, query: sqlQuery, tableModal: tableModal })] }));
|
|
37
42
|
};
|
|
38
43
|
//# sourceMappingURL=TableTreeNode.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableTreeNode.js","sourceRoot":"","sources":["../../src/nodes/TableTreeNode.tsx"],"names":[],"mappings":";AAAA,4DAA4D;AAE5D,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"TableTreeNode.js","sourceRoot":"","sources":["../../src/nodes/TableTreeNode.tsx"],"names":[],"mappings":";AAAA,4DAA4D;AAE5D,OAAO,EAAC,cAAc,EAAC,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAC,sBAAsB,EAAkB,MAAM,kBAAkB,CAAC;AACzE,OAAO,EAAC,aAAa,EAAC,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAC,WAAW,EAAC,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAC,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAC,MAAM,cAAc,CAAC;AAEpE,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EACL,mBAAmB,EACnB,uBAAuB,GACxB,MAAM,uBAAuB,CAAC;AAE/B,MAAM,CAAC,MAAM,+BAA+B,GAAG,CAC7C,UAA2B,EAC3B,cAAiD,EACjD,EAAE;I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AAC,KAAK,CAAC,CAAC,CAAC,MAAM,IACnD,CACR,IACG,IACF,EACN,KAAC,mBAAmB,cACjB,eAAe,CAAC,UAAU,EAAE,UAAU,CAAC,GACpB,IACT,EACf,KAAC,cAAc,IACb,KAAK,EAAE,kBAAkB,CAAC,KAAK,EAC/B,KAAK,EAAE,QAAQ,EACf,UAAU,EAAE,UAAU,GACtB,IACD,CACJ,CAAC;AACJ,CAAC,CAAC","sourcesContent":["// Copyright 2022 Foursquare Labs, Inc. All Rights Reserved.\n\nimport {DataTableModal} from '@sqlrooms/data-table';\nimport {makeQualifiedTableName, TableNodeObject} from '@sqlrooms/duckdb';\nimport {useDisclosure} from '@sqlrooms/ui';\nimport {formatCount} from '@sqlrooms/utils';\nimport {CopyIcon, EyeIcon, TableIcon, ViewIcon} from 'lucide-react';\nimport {FC} from 'react';\nimport {BaseTreeNode} from './BaseTreeNode';\nimport {\n TreeNodeActionsMenu,\n TreeNodeActionsMenuItem,\n} from './TreeNodeActionsMenu';\n\nexport const defaultRenderTableNodeMenuItems = (\n nodeObject: TableNodeObject,\n viewTableModal?: ReturnType<typeof useDisclosure>,\n) => {\n const {database, schema, name, sql, isView} = nodeObject;\n const qualifiedTableName = makeQualifiedTableName({\n database,\n schema,\n table: name,\n });\n return (\n <>\n {viewTableModal && (\n <TreeNodeActionsMenuItem\n onClick={() => {\n viewTableModal.onOpen();\n }}\n >\n <EyeIcon width=\"15px\" />\n View data\n </TreeNodeActionsMenuItem>\n )}\n <TreeNodeActionsMenuItem\n onClick={() => {\n navigator.clipboard.writeText(qualifiedTableName.table);\n }}\n >\n <CopyIcon width=\"15px\" />\n Copy {isView ? 'view' : 'table'} name\n </TreeNodeActionsMenuItem>\n\n <TreeNodeActionsMenuItem\n onClick={() => {\n navigator.clipboard.writeText(qualifiedTableName.toString());\n }}\n >\n <CopyIcon width=\"15px\" />\n Copy qualified {isView ? 'view' : 'table'} name\n </TreeNodeActionsMenuItem>\n\n <TreeNodeActionsMenuItem\n onClick={() => {\n navigator.clipboard.writeText(`SELECT * FROM ${qualifiedTableName}`);\n }}\n >\n <CopyIcon width=\"15px\" />\n Copy SELECT query\n </TreeNodeActionsMenuItem>\n\n <TreeNodeActionsMenuItem\n onClick={() => {\n if (sql) {\n navigator.clipboard.writeText(sql);\n }\n }}\n disabled={!sql}\n >\n <CopyIcon width=\"15px\" />\n Copy CREATE {isView ? 'VIEW' : 'TABLE'}\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, rowCount, isView} = 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=\"relative flex w-full items-center space-x-2\">\n {isView ? (\n <ViewIcon size=\"16px\" className=\"shrink-0 text-blue-500\" />\n ) : (\n <TableIcon size=\"16px\" className=\"shrink-0 text-blue-500\" />\n )}\n <div className=\"flex w-full items-center justify-between gap-2\">\n <span className=\"text-sm\">{name}</span>\n {rowCount !== undefined && (\n <span className=\"text-muted-foreground/50 ml-1 whitespace-nowrap pr-5 text-xs\">\n {formatCount(rowCount)} {rowCount === 1 ? 'row' : 'rows'}\n </span>\n )}\n </div>\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.16",
|
|
4
4
|
"author": "Ilya Boyandin <ilya@boyandin.me>",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -24,9 +24,10 @@
|
|
|
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.16",
|
|
28
|
+
"@sqlrooms/duckdb": "0.24.16",
|
|
29
|
+
"@sqlrooms/ui": "0.24.16",
|
|
30
|
+
"@sqlrooms/utils": "0.24.16",
|
|
30
31
|
"lucide-react": "^0.474.0"
|
|
31
32
|
},
|
|
32
33
|
"peerDependencies": {
|
|
@@ -37,5 +38,5 @@
|
|
|
37
38
|
"@types/react": "^19.1.7",
|
|
38
39
|
"@types/react-dom": "^19.1.6"
|
|
39
40
|
},
|
|
40
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "c445f6dce46c0f2974d12e75b6e7c4c36bf3c1bf"
|
|
41
42
|
}
|