@sqlrooms/schema-tree 0.24.26 → 0.24.28-rc.1

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 +1 @@
1
- {"version":3,"file":"TableSchemaTree.d.ts","sourceRoot":"","sources":["../src/TableSchemaTree.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EAAC,EAAE,EAAC,MAAM,OAAO,CAAC;AAMzB,eAAO,MAAM,4BAA4B,GAAI,MAAM,YAAY,mDAc9D,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,EAAE,CAAC;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,YAAY,EAAE,CAAC;IAC5B,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,YAAY,EAAE,MAAM,EAAE,OAAO,KAAK,KAAK,CAAC,SAAS,CAAC;IACtE,0BAA0B,CAAC,EAAE,OAAO,CAAC;CACtC,CA2BA,CAAC"}
1
+ {"version":3,"file":"TableSchemaTree.d.ts","sourceRoot":"","sources":["../src/TableSchemaTree.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EAAC,EAAE,EAAC,MAAM,OAAO,CAAC;AAMzB,eAAO,MAAM,4BAA4B,GAAI,MAAM,YAAY,mDAc9D,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,EAAE,CAAC;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,YAAY,EAAE,CAAC;IAC5B,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,YAAY,EAAE,MAAM,EAAE,OAAO,KAAK,KAAK,CAAC,SAAS,CAAC;IACtE,0BAA0B,CAAC,EAAE,OAAO,CAAC;CACtC,CA8BA,CAAC"}
@@ -27,6 +27,6 @@ export const TableSchemaTree = ({ className, schemaTrees, renderNode = defaultRe
27
27
  ? schemaTrees[0].children
28
28
  : schemaTrees[0]?.children?.[0]?.children
29
29
  : schemaTrees;
30
- return (_jsx("div", { className: cn('flex h-full flex-col gap-2 overflow-auto p-0', className), children: trees?.map((subtree) => (_jsx(Tree, { treeData: subtree, renderNode: renderNode }, subtree.object.name))) }));
30
+ return (_jsx("div", { className: cn('flex h-full flex-col gap-2 overflow-auto p-0 text-sm', className), children: trees?.map((subtree) => (_jsx(Tree, { treeData: subtree, renderNode: renderNode }, subtree.object.name))) }));
31
31
  };
32
32
  //# sourceMappingURL=TableSchemaTree.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"TableSchemaTree.js","sourceRoot":"","sources":["../src/TableSchemaTree.tsx"],"names":[],"mappings":";AACA,OAAO,EAAC,EAAE,EAAE,IAAI,EAAC,MAAM,cAAc,CAAC;AAEtC,OAAO,EAAC,cAAc,EAAC,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAC,gBAAgB,EAAC,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAC,cAAc,EAAC,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAC,aAAa,EAAC,MAAM,uBAAuB,CAAC;AAEpD,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,IAAkB,EAAE,EAAE;IACjE,MAAM,EAAC,MAAM,EAAE,UAAU,EAAC,GAAG,IAAI,CAAC;IAClC,QAAQ,UAAU,CAAC,IAAI,EAAE,CAAC;QACxB,KAAK,UAAU;YACb,OAAO,KAAC,gBAAgB,IAAC,UAAU,EAAE,UAAU,GAAI,CAAC;QACtD,KAAK,QAAQ;YACX,OAAO,KAAC,cAAc,IAAC,UAAU,EAAE,UAAU,GAAI,CAAC;QACpD,KAAK,OAAO;YACV,OAAO,KAAC,aAAa,IAAC,UAAU,EAAE,UAAU,GAAI,CAAC;QACnD,KAAK,QAAQ;YACX,OAAO,KAAC,cAAc,IAAC,UAAU,EAAE,UAAU,GAAI,CAAC;QACpD;YACE,OAAO,IAAI,CAAC;IAChB,CAAC;AACH,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAKvB,CAAC,EACJ,SAAS,EACT,WAAW,EACX,UAAU,GAAG,4BAA4B,EACzC,0BAA0B,GAAG,KAAK,GACnC,EAAE,EAAE;IACH,MAAM,KAAK,GAAG,0BAA0B;QACtC,CAAC,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC;YACtB,CAAC,CAAC,WAAW;YACb,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,QAAQ,IAAI,WAAW,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,GAAG,CAAC;gBAChE,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,QAAQ;gBACzB,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,QAAQ;QAC7C,CAAC,CAAC,WAAW,CAAC;IAEhB,OAAO,CACL,cACE,SAAS,EAAE,EAAE,CAAC,8CAA8C,EAAE,SAAS,CAAC,YAEvE,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CACvB,KAAC,IAAI,IAEH,QAAQ,EAAE,OAAO,EACjB,UAAU,EAAE,UAAU,IAFjB,OAAO,CAAC,MAAM,CAAC,IAAI,CAGxB,CACH,CAAC,GACE,CACP,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import {DbSchemaNode} from '@sqlrooms/duckdb';\nimport {cn, Tree} from '@sqlrooms/ui';\nimport {FC} from 'react';\nimport {ColumnTreeNode} from './nodes/ColumnTreeNode';\nimport {DatabaseTreeNode} from './nodes/DatabaseTreeNode';\nimport {SchemaTreeNode} from './nodes/SchemaTreeNode';\nimport {TableTreeNode} from './nodes/TableTreeNode';\n\nexport const defaultRenderTableSchemaNode = (node: DbSchemaNode) => {\n const {object: nodeObject} = node;\n switch (nodeObject.type) {\n case 'database':\n return <DatabaseTreeNode nodeObject={nodeObject} />;\n case 'schema':\n return <SchemaTreeNode nodeObject={nodeObject} />;\n case 'table':\n return <TableTreeNode nodeObject={nodeObject} />;\n case 'column':\n return <ColumnTreeNode nodeObject={nodeObject} />;\n default:\n return null;\n }\n};\n\nexport const TableSchemaTree: FC<{\n className?: string;\n schemaTrees: DbSchemaNode[];\n renderNode?: (node: DbSchemaNode, isOpen: boolean) => React.ReactNode;\n skipSingleDatabaseOrSchema?: boolean;\n}> = ({\n className,\n schemaTrees,\n renderNode = defaultRenderTableSchemaNode,\n skipSingleDatabaseOrSchema = false,\n}) => {\n const trees = skipSingleDatabaseOrSchema\n ? schemaTrees.length > 1\n ? schemaTrees\n : schemaTrees[0]?.children && schemaTrees[0]?.children?.length > 1\n ? schemaTrees[0].children\n : schemaTrees[0]?.children?.[0]?.children\n : schemaTrees;\n\n return (\n <div\n className={cn('flex h-full flex-col gap-2 overflow-auto p-0', className)}\n >\n {trees?.map((subtree) => (\n <Tree\n key={subtree.object.name}\n treeData={subtree}\n renderNode={renderNode}\n />\n ))}\n </div>\n );\n};\n"]}
1
+ {"version":3,"file":"TableSchemaTree.js","sourceRoot":"","sources":["../src/TableSchemaTree.tsx"],"names":[],"mappings":";AACA,OAAO,EAAC,EAAE,EAAE,IAAI,EAAC,MAAM,cAAc,CAAC;AAEtC,OAAO,EAAC,cAAc,EAAC,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAC,gBAAgB,EAAC,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAC,cAAc,EAAC,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAC,aAAa,EAAC,MAAM,uBAAuB,CAAC;AAEpD,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,IAAkB,EAAE,EAAE;IACjE,MAAM,EAAC,MAAM,EAAE,UAAU,EAAC,GAAG,IAAI,CAAC;IAClC,QAAQ,UAAU,CAAC,IAAI,EAAE,CAAC;QACxB,KAAK,UAAU;YACb,OAAO,KAAC,gBAAgB,IAAC,UAAU,EAAE,UAAU,GAAI,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from './nodes/ColumnTreeNode';\nimport {DatabaseTreeNode} from './nodes/DatabaseTreeNode';\nimport {SchemaTreeNode} from './nodes/SchemaTreeNode';\nimport {TableTreeNode} from './nodes/TableTreeNode';\n\nexport const defaultRenderTableSchemaNode = (node: DbSchemaNode) => {\n const {object: nodeObject} = node;\n switch (nodeObject.type) {\n case 'database':\n return <DatabaseTreeNode nodeObject={nodeObject} />;\n case 'schema':\n return <SchemaTreeNode nodeObject={nodeObject} />;\n case 'table':\n return <TableTreeNode nodeObject={nodeObject} />;\n case 'column':\n return <ColumnTreeNode nodeObject={nodeObject} />;\n default:\n return null;\n }\n};\n\nexport const TableSchemaTree: FC<{\n className?: string;\n schemaTrees: DbSchemaNode[];\n renderNode?: (node: DbSchemaNode, isOpen: boolean) => React.ReactNode;\n skipSingleDatabaseOrSchema?: boolean;\n}> = ({\n className,\n schemaTrees,\n renderNode = defaultRenderTableSchemaNode,\n skipSingleDatabaseOrSchema = false,\n}) => {\n const trees = skipSingleDatabaseOrSchema\n ? schemaTrees.length > 1\n ? schemaTrees\n : schemaTrees[0]?.children && schemaTrees[0]?.children?.length > 1\n ? schemaTrees[0].children\n : schemaTrees[0]?.children?.[0]?.children\n : schemaTrees;\n\n return (\n <div\n className={cn(\n 'flex h-full flex-col gap-2 overflow-auto p-0 text-sm',\n className,\n )}\n >\n {trees?.map((subtree) => (\n <Tree\n key={subtree.object.name}\n treeData={subtree}\n renderNode={renderNode}\n />\n ))}\n </div>\n );\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"BaseTreeNode.d.ts","sourceRoot":"","sources":["../../src/nodes/BaseTreeNode.tsx"],"names":[],"mappings":"AACA,OAAO,EAAC,iBAAiB,EAAC,MAAM,OAAO,CAAC;AAExC,wBAAgB,YAAY,CAAC,CAAC,EAC5B,KAAK,EAAE,iBAAiB,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,CAAC,CAAC;IACd,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC,2CAqBH"}
1
+ {"version":3,"file":"BaseTreeNode.d.ts","sourceRoot":"","sources":["../../src/nodes/BaseTreeNode.tsx"],"names":[],"mappings":"AACA,OAAO,EAAC,iBAAiB,EAAC,MAAM,OAAO,CAAC;AAExC,wBAAgB,YAAY,CAAC,CAAC,EAC5B,KAAK,EAAE,iBAAiB,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,CAAC,CAAC;IACd,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC,2CAuBH"}
@@ -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 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 }) }) }));
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 flex 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,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
+ {"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,0CAA0C,YACtD,QAAQ,GACL,GACF,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 flex h-full w-full items-center\">\n {children}\n </div>\n </div>\n </Comp>\n );\n}\n"]}
@@ -4,6 +4,6 @@ import { BaseTreeNode } from './BaseTreeNode';
4
4
  import { TreeNodeActionsMenu, TreeNodeActionsMenuItem, } from './TreeNodeActionsMenu';
5
5
  export const DatabaseTreeNode = (props) => {
6
6
  const { className, nodeObject, additionalMenuItems } = props;
7
- return (_jsxs(BaseTreeNode, { asChild: true, className: className, nodeObject: nodeObject, children: [_jsxs("div", { className: "flex w-full items-center space-x-2", children: [_jsx(DatabaseIcon, { size: "16px", className: "shrink-0 text-green-500" }), _jsx("span", { className: "text-sm", children: nodeObject.name })] }), _jsxs(TreeNodeActionsMenu, { children: [_jsxs(TreeNodeActionsMenuItem, { onClick: () => navigator.clipboard.writeText(nodeObject.name), children: [_jsx(CopyIcon, { width: "15px" }), "Copy database name"] }), additionalMenuItems] })] }));
7
+ return (_jsxs(BaseTreeNode, { asChild: true, className: className, nodeObject: nodeObject, children: [_jsxs("div", { className: "flex w-full items-center space-x-2", children: [_jsx(DatabaseIcon, { size: "16px", className: "shrink-0 text-green-500" }), _jsx("span", { children: nodeObject.name })] }), _jsxs(TreeNodeActionsMenu, { children: [_jsxs(TreeNodeActionsMenuItem, { onClick: () => navigator.clipboard.writeText(nodeObject.name), children: [_jsx(CopyIcon, { width: "15px" }), "Copy database name"] }), additionalMenuItems] })] }));
8
8
  };
9
9
  //# sourceMappingURL=DatabaseTreeNode.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"DatabaseTreeNode.js","sourceRoot":"","sources":["../../src/nodes/DatabaseTreeNode.tsx"],"names":[],"mappings":";AAGA,OAAO,EAAC,QAAQ,EAAE,YAAY,EAAC,MAAM,cAAc,CAAC;AAEpD,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EACL,mBAAmB,EACnB,uBAAuB,GACxB,MAAM,uBAAuB,CAAC;AAE/B,MAAM,CAAC,MAAM,gBAAgB,GAIxB,CAAC,KAAK,EAAE,EAAE;IACb,MAAM,EAAC,SAAS,EAAE,UAAU,EAAE,mBAAmB,EAAC,GAAG,KAAK,CAAC;IAC3D,OAAO,CACL,MAAC,YAAY,IAAC,OAAO,QAAC,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,aAChE,eAAK,SAAS,EAAC,oCAAoC,aACjD,KAAC,YAAY,IAAC,IAAI,EAAC,MAAM,EAAC,SAAS,EAAC,yBAAyB,GAAG,EAChE,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,0BAED,EACzB,mBAAmB,IACA,IACT,CAChB,CAAC;AACJ,CAAC,CAAC","sourcesContent":["// Copyright 2022 Foursquare Labs, Inc. All Rights Reserved.\n\nimport {DatabaseNodeObject} from '@sqlrooms/duckdb';\nimport {CopyIcon, DatabaseIcon} from 'lucide-react';\nimport {FC} from 'react';\nimport {BaseTreeNode} from './BaseTreeNode';\nimport {\n TreeNodeActionsMenu,\n TreeNodeActionsMenuItem,\n} from './TreeNodeActionsMenu';\n\nexport const DatabaseTreeNode: FC<{\n className?: string;\n nodeObject: DatabaseNodeObject;\n additionalMenuItems?: React.ReactNode;\n}> = (props) => {\n const {className, nodeObject, additionalMenuItems} = props;\n return (\n <BaseTreeNode asChild className={className} nodeObject={nodeObject}>\n <div className=\"flex w-full items-center space-x-2\">\n <DatabaseIcon size=\"16px\" className=\"shrink-0 text-green-500\" />\n <span className=\"text-sm\">{nodeObject.name}</span>\n </div>\n <TreeNodeActionsMenu>\n <TreeNodeActionsMenuItem\n onClick={() => navigator.clipboard.writeText(nodeObject.name)}\n >\n <CopyIcon width=\"15px\" />\n Copy database name\n </TreeNodeActionsMenuItem>\n {additionalMenuItems}\n </TreeNodeActionsMenu>\n </BaseTreeNode>\n );\n};\n"]}
1
+ {"version":3,"file":"DatabaseTreeNode.js","sourceRoot":"","sources":["../../src/nodes/DatabaseTreeNode.tsx"],"names":[],"mappings":";AAGA,OAAO,EAAC,QAAQ,EAAE,YAAY,EAAC,MAAM,cAAc,CAAC;AAEpD,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EACL,mBAAmB,EACnB,uBAAuB,GACxB,MAAM,uBAAuB,CAAC;AAE/B,MAAM,CAAC,MAAM,gBAAgB,GAIxB,CAAC,KAAK,EAAE,EAAE;IACb,MAAM,EAAC,SAAS,EAAE,UAAU,EAAE,mBAAmB,EAAC,GAAG,KAAK,CAAC;IAC3D,OAAO,CACL,MAAC,YAAY,IAAC,OAAO,QAAC,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,aAChE,eAAK,SAAS,EAAC,oCAAoC,aACjD,KAAC,YAAY,IAAC,IAAI,EAAC,MAAM,EAAC,SAAS,EAAC,yBAAyB,GAAG,EAChE,yBAAO,UAAU,CAAC,IAAI,GAAQ,IAC1B,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,0BAED,EACzB,mBAAmB,IACA,IACT,CAChB,CAAC;AACJ,CAAC,CAAC","sourcesContent":["// Copyright 2022 Foursquare Labs, Inc. All Rights Reserved.\n\nimport {DatabaseNodeObject} from '@sqlrooms/duckdb';\nimport {CopyIcon, DatabaseIcon} from 'lucide-react';\nimport {FC} from 'react';\nimport {BaseTreeNode} from './BaseTreeNode';\nimport {\n TreeNodeActionsMenu,\n TreeNodeActionsMenuItem,\n} from './TreeNodeActionsMenu';\n\nexport const DatabaseTreeNode: FC<{\n className?: string;\n nodeObject: DatabaseNodeObject;\n additionalMenuItems?: React.ReactNode;\n}> = (props) => {\n const {className, nodeObject, additionalMenuItems} = props;\n return (\n <BaseTreeNode asChild className={className} nodeObject={nodeObject}>\n <div className=\"flex w-full items-center space-x-2\">\n <DatabaseIcon size=\"16px\" className=\"shrink-0 text-green-500\" />\n <span>{nodeObject.name}</span>\n </div>\n <TreeNodeActionsMenu>\n <TreeNodeActionsMenuItem\n onClick={() => navigator.clipboard.writeText(nodeObject.name)}\n >\n <CopyIcon width=\"15px\" />\n Copy database name\n </TreeNodeActionsMenuItem>\n {additionalMenuItems}\n </TreeNodeActionsMenu>\n </BaseTreeNode>\n );\n};\n"]}
@@ -4,6 +4,6 @@ import { BaseTreeNode } from './BaseTreeNode';
4
4
  import { TreeNodeActionsMenu, TreeNodeActionsMenuItem, } from './TreeNodeActionsMenu';
5
5
  export const SchemaTreeNode = (props) => {
6
6
  const { className, nodeObject, additionalMenuItems } = props;
7
- return (_jsxs(BaseTreeNode, { asChild: true, className: className, nodeObject: nodeObject, children: [_jsxs("div", { className: "flex w-full items-center space-x-2", children: [_jsx(FolderIcon, { size: "16px", className: "shrink-0 text-yellow-500" }), _jsx("span", { className: "text-sm", children: nodeObject.name })] }), _jsxs(TreeNodeActionsMenu, { children: [_jsxs(TreeNodeActionsMenuItem, { onClick: () => navigator.clipboard.writeText(nodeObject.name), children: [_jsx(CopyIcon, { width: "15px" }), "Copy schema name"] }), additionalMenuItems] })] }));
7
+ return (_jsxs(BaseTreeNode, { asChild: true, className: className, nodeObject: nodeObject, children: [_jsxs("div", { className: "flex w-full items-center space-x-2", children: [_jsx(FolderIcon, { size: "16px", className: "shrink-0 text-yellow-500" }), _jsx("span", { children: nodeObject.name })] }), _jsxs(TreeNodeActionsMenu, { children: [_jsxs(TreeNodeActionsMenuItem, { onClick: () => navigator.clipboard.writeText(nodeObject.name), children: [_jsx(CopyIcon, { width: "15px" }), "Copy schema name"] }), additionalMenuItems] })] }));
8
8
  };
9
9
  //# sourceMappingURL=SchemaTreeNode.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaTreeNode.js","sourceRoot":"","sources":["../../src/nodes/SchemaTreeNode.tsx"],"names":[],"mappings":";AAGA,OAAO,EAAC,QAAQ,EAAE,UAAU,EAAC,MAAM,cAAc,CAAC;AAElD,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EACL,mBAAmB,EACnB,uBAAuB,GACxB,MAAM,uBAAuB,CAAC;AAE/B,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,IAAC,OAAO,QAAC,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,aAChE,eAAK,SAAS,EAAC,oCAAoC,aACjD,KAAC,UAAU,IAAC,IAAI,EAAC,MAAM,EAAC,SAAS,EAAC,0BAA0B,GAAG,EAC/D,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 {SchemaNodeObject} from '@sqlrooms/duckdb';\nimport {CopyIcon, FolderIcon} from 'lucide-react';\nimport {FC} from 'react';\nimport {BaseTreeNode} from './BaseTreeNode';\nimport {\n TreeNodeActionsMenu,\n TreeNodeActionsMenuItem,\n} from './TreeNodeActionsMenu';\n\nexport const SchemaTreeNode: FC<{\n className?: string;\n nodeObject: SchemaNodeObject;\n additionalMenuItems?: React.ReactNode;\n}> = (props) => {\n const {className, nodeObject, additionalMenuItems} = props;\n return (\n <BaseTreeNode asChild className={className} nodeObject={nodeObject}>\n <div className=\"flex w-full items-center space-x-2\">\n <FolderIcon size=\"16px\" className=\"shrink-0 text-yellow-500\" />\n <span className=\"text-sm\">{nodeObject.name}</span>\n </div>\n <TreeNodeActionsMenu>\n <TreeNodeActionsMenuItem\n onClick={() => navigator.clipboard.writeText(nodeObject.name)}\n >\n <CopyIcon width=\"15px\" />\n Copy schema name\n </TreeNodeActionsMenuItem>\n {additionalMenuItems}\n </TreeNodeActionsMenu>\n </BaseTreeNode>\n );\n};\n"]}
1
+ {"version":3,"file":"SchemaTreeNode.js","sourceRoot":"","sources":["../../src/nodes/SchemaTreeNode.tsx"],"names":[],"mappings":";AAGA,OAAO,EAAC,QAAQ,EAAE,UAAU,EAAC,MAAM,cAAc,CAAC;AAElD,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EACL,mBAAmB,EACnB,uBAAuB,GACxB,MAAM,uBAAuB,CAAC;AAE/B,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,IAAC,OAAO,QAAC,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,aAChE,eAAK,SAAS,EAAC,oCAAoC,aACjD,KAAC,UAAU,IAAC,IAAI,EAAC,MAAM,EAAC,SAAS,EAAC,0BAA0B,GAAG,EAC/D,yBAAO,UAAU,CAAC,IAAI,GAAQ,IAC1B,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 {SchemaNodeObject} from '@sqlrooms/duckdb';\nimport {CopyIcon, FolderIcon} from 'lucide-react';\nimport {FC} from 'react';\nimport {BaseTreeNode} from './BaseTreeNode';\nimport {\n TreeNodeActionsMenu,\n TreeNodeActionsMenuItem,\n} from './TreeNodeActionsMenu';\n\nexport const SchemaTreeNode: FC<{\n className?: string;\n nodeObject: SchemaNodeObject;\n additionalMenuItems?: React.ReactNode;\n}> = (props) => {\n const {className, nodeObject, additionalMenuItems} = props;\n return (\n <BaseTreeNode asChild className={className} nodeObject={nodeObject}>\n <div className=\"flex w-full items-center space-x-2\">\n <FolderIcon size=\"16px\" className=\"shrink-0 text-yellow-500\" />\n <span>{nodeObject.name}</span>\n </div>\n <TreeNodeActionsMenu>\n <TreeNodeActionsMenuItem\n onClick={() => navigator.clipboard.writeText(nodeObject.name)}\n >\n <CopyIcon width=\"15px\" />\n Copy schema name\n </TreeNodeActionsMenuItem>\n {additionalMenuItems}\n </TreeNodeActionsMenu>\n </BaseTreeNode>\n );\n};\n"]}
@@ -38,6 +38,6 @@ export const TableTreeNode = (props) => {
38
38
  table: name,
39
39
  });
40
40
  const sqlQuery = `SELECT * FROM ${qualifiedTableName}`;
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 })] }));
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", { 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 })] }));
42
42
  };
43
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,cAAc,EAAC,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAC,sBAAsB,EAAkB,MAAM,kBAAkB,CAAC;AACzE,OAAO,EAAC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AI,EAAC,MAAM,EAAC,SAAS,EAAC,wBAAwB,GAAG,CAC5D,CAAC,CAAC,CAAC,CACF,KAAC,SAAS,IAAC,IAAI,EAAC,MAAM,EAAC,SAAS,EAAC,wBAAwB,GAAG,CAC7D,EACD,eAAK,SAAS,EAAC,gDAAgD,aAC7D,eAAM,SAAS,EAAC,SAAS,YAAE,IAAI,GAAQ,EACtC,QAAQ,KAAK,SAAS,IAAI,CACzB,gBAAM,SAAS,EAAC,8DAA8D,aAC3E,WAAW,CAAC,QAAQ,CAAC,OAAG,QAAQ,KAAK,CAAC,CAAC,CAAC,CAAC,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"]}
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;IACF,MAAM,EAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,EAAC,GAAG,UAAU,CAAC;IACzD,MAAM,kBAAkB,GAAG,sBAAsB,CAAC;QAChD,QAAQ;QACR,MAAM;QACN,KAAK,EAAE,IAAI;KACZ,CAAC,CAAC;IACH,OAAO,CACL,8BACG,cAAc,IAAI,CACjB,MAAC,uBAAuB,IACtB,OAAO,EAAE,GAAG,EAAE;oBACZ,cAAc,CAAC,MAAM,EAAE,CAAC;gBAC1B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\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>{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.26",
3
+ "version": "0.24.28-rc.1",
4
4
  "author": "Ilya Boyandin <ilya@boyandin.me>",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -24,10 +24,10 @@
24
24
  "typedoc": "typedoc"
25
25
  },
26
26
  "dependencies": {
27
- "@sqlrooms/data-table": "0.24.26",
28
- "@sqlrooms/duckdb": "0.24.26",
29
- "@sqlrooms/ui": "0.24.26",
30
- "@sqlrooms/utils": "0.24.26",
27
+ "@sqlrooms/data-table": "0.24.28-rc.1",
28
+ "@sqlrooms/duckdb": "0.24.28-rc.1",
29
+ "@sqlrooms/ui": "0.24.28-rc.1",
30
+ "@sqlrooms/utils": "0.24.28-rc.1",
31
31
  "lucide-react": "^0.474.0"
32
32
  },
33
33
  "peerDependencies": {
@@ -38,5 +38,5 @@
38
38
  "@types/react": "^19.1.7",
39
39
  "@types/react-dom": "^19.1.6"
40
40
  },
41
- "gitHead": "1a14d45223319a46b818f9a2b35eb0655f72f6ed"
41
+ "gitHead": "660a717f42062c62335ecc9929f5dc60f00fa99d"
42
42
  }