@sqlrooms/schema-tree 0.24.5 → 0.24.7

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
- export declare const defaultRenderTableNodeMenuItems: (nodeObject: TableNodeObject) => import("react/jsx-runtime").JSX.Element;
3
+ import { useDisclosure } from '@sqlrooms/ui';
4
+ export declare const defaultRenderTableNodeMenuItems: (nodeObject: TableNodeObject, viewTableModal?: 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,EAAC,eAAe,EAAC,MAAM,kBAAkB,CAAC;AAEjD,OAAO,EAAC,EAAE,EAAC,MAAM,OAAO,CAAC;AAOzB,eAAO,MAAM,+BAA+B,GAC1C,YAAY,eAAe,4CAmC5B,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,EAAE,CAAC;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,eAAe,CAAC;IAC5B,eAAe,CAAC,EAAE,CAAC,UAAU,EAAE,eAAe,KAAK,KAAK,CAAC,SAAS,CAAC;CACpE,CAeA,CAAC"}
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,iBAAiB,UAAU,CAAC,OAAO,aAAa,CAAC,4CAgDlD,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
- import { CopyIcon, SquareTerminalIcon, TableIcon } from 'lucide-react';
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, viewTableModal) => {
6
10
  const { database, schema, name } = nodeObject;
7
- return (_jsxs(_Fragment, { children: [_jsxs(TreeNodeActionsMenuItem, { onClick: () => {
8
- navigator.clipboard.writeText(nodeObject.schema == 'main'
9
- ? nodeObject.name
10
- : `${nodeObject.schema}.${nodeObject.name}`);
11
+ const qualifiedTableName = makeQualifiedTableName({
12
+ database,
13
+ schema,
14
+ table: name,
15
+ });
16
+ return (_jsxs(_Fragment, { children: [viewTableModal && (_jsxs(TreeNodeActionsMenuItem, { onClick: () => {
17
+ viewTableModal.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
- `SELECT * FROM `,
14
- database === 'memory' ? '' : `${database}.`,
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
- return (_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) })] }));
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":";AAGA,OAAO,EAAC,QAAQ,EAAE,kBAAkB,EAAE,SAAS,EAAC,MAAM,cAAc,CAAC;AAErE,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,EAAE;IACF,MAAM,EAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAC,GAAG,UAAU,CAAC;IAC5C,OAAO,CACL,8BACE,MAAC,uBAAuB,IACtB,OAAO,EAAE,GAAG,EAAE;oBACZ,SAAS,CAAC,SAAS,CAAC,SAAS,CAC3B,UAAU,CAAC,MAAM,IAAI,MAAM;wBACzB,CAAC,CAAC,UAAU,CAAC,IAAI;wBACjB,CAAC,CAAC,GAAG,UAAU,CAAC,MAAM,IAAI,UAAU,CAAC,IAAI,EAAE,CAC9C,CAAC;gBACJ,CAAC,aAED,KAAC,QAAQ,IAAC,KAAK,EAAC,MAAM,GAAG,uBAED,EAE1B,MAAC,uBAAuB,IACtB,OAAO,EAAE,GAAG,EAAE;oBACZ,SAAS,CAAC,SAAS,CAAC,SAAS,CAC3B;wBACE,gBAAgB;wBAChB,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,QAAQ,GAAG;wBAC3C,MAAM,KAAK,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,MAAM,GAAG;wBACrC,IAAI;qBACL,CAAC,IAAI,CAAC,EAAE,CAAC,CACX,CAAC;gBACJ,CAAC,aAED,KAAC,kBAAkB,IAAC,KAAK,EAAC,MAAM,GAAG,yBAEX,IACzB,CACJ,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAIrB,CAAC,KAAK,EAAE,EAAE;IACb,MAAM,EACJ,SAAS,EACT,UAAU,EACV,eAAe,GAAG,+BAA+B,GAClD,GAAG,KAAK,CAAC;IACV,OAAO,CACL,MAAC,YAAY,IAAC,OAAO,QAAC,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,aAChE,eAAK,SAAS,EAAC,oCAAoC,aACjD,KAAC,SAAS,IAAC,IAAI,EAAC,MAAM,EAAC,SAAS,EAAC,wBAAwB,GAAG,EAC5D,eAAM,SAAS,EAAC,SAAS,YAAE,UAAU,CAAC,IAAI,GAAQ,IAC9C,EACN,KAAC,mBAAmB,cAAE,eAAe,CAAC,UAAU,CAAC,GAAuB,IAC3D,CAChB,CAAC;AACJ,CAAC,CAAC","sourcesContent":["// Copyright 2022 Foursquare Labs, Inc. All Rights Reserved.\n\nimport {TableNodeObject} from '@sqlrooms/duckdb';\nimport {CopyIcon, SquareTerminalIcon, TableIcon} 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) => {\n const {database, schema, name} = nodeObject;\n return (\n <>\n <TreeNodeActionsMenuItem\n onClick={() => {\n navigator.clipboard.writeText(\n nodeObject.schema == 'main'\n ? nodeObject.name\n : `${nodeObject.schema}.${nodeObject.name}`,\n );\n }}\n >\n <CopyIcon width=\"15px\" />\n Copy table name\n </TreeNodeActionsMenuItem>\n\n <TreeNodeActionsMenuItem\n onClick={() => {\n navigator.clipboard.writeText(\n [\n `SELECT * FROM `,\n database === 'memory' ? '' : `${database}.`,\n schema === 'main' ? '' : `${schema}.`,\n name,\n ].join(''),\n );\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?: (nodeObject: TableNodeObject) => React.ReactNode;\n}> = (props) => {\n const {\n className,\n nodeObject,\n renderMenuItems = defaultRenderTableNodeMenuItems,\n } = props;\n return (\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>{renderMenuItems(nodeObject)}</TreeNodeActionsMenu>\n </BaseTreeNode>\n );\n};\n"]}
1
+ {"version":3,"file":"TableTreeNode.js","sourceRoot":"","sources":["../../src/nodes/TableTreeNode.tsx"],"names":[],"mappings":";AAAA,4DAA4D;AAE5D,OAAO,EAAC,sBAAsB,EAAkB,MAAM,kBAAkB,CAAC;AACzE,OAAO,EAAC,QAAQ,EAAE,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAAC,MAAM,cAAc,CAAC;AAE9E,OAAO,EAAC,aAAa,EAAC,MAAM,cAAc,CAAC;AAC3C,OAAO,cAAc,MAAM,yCAAyC,CAAC;AACrE,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;IACF,MAAM,EAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAC,GAAG,UAAU,CAAC;IAC5C,MAAM,kBAAkB,GAAG,sBAAsB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,KAAK,EAAE,IAAI;KACZ,CAAC,CAAC;IACH,MAAM,QAAQ,GAAG,iBAAiB,kBAAkB,EAAE,CAAC;IAEvD,OAAO,CACL,8BACE,MAAC,YAAY,IAAC,OAAO,QAAC,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,aAChE,eAAK,SAAS,EAAC,oCAAoC,aACjD,KAAC,SAAS,IAAC,IAAI,EAAC,MAAM,EAAC,SAAS,EAAC,wBAAwB,GAAG,EAC5D,eAAM,SAAS,EAAC,SAAS,YAAE,UAAU,CAAC,IAAI,GAAQ,IAC9C,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 {makeQualifiedTableName, TableNodeObject} from '@sqlrooms/duckdb';\nimport {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 viewTableModal?: 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 {viewTableModal && (\n <TreeNodeActionsMenuItem\n onClick={() => {\n viewTableModal.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.5",
3
+ "version": "0.24.7",
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.5",
28
- "@sqlrooms/duckdb": "0.24.5",
29
- "@sqlrooms/ui": "0.24.5",
27
+ "@sqlrooms/data-table": "0.24.7",
28
+ "@sqlrooms/duckdb": "0.24.7",
29
+ "@sqlrooms/ui": "0.24.7",
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": "393aee155a8954a9e5b7e792e6f98118182f2cc3"
40
+ "gitHead": "4ec3020db1bb9f6bda0fb0c2b24f07ed42cbb4e6"
41
41
  }