@sqlrooms/data-table 0.0.1 → 0.0.2

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,12 +1,41 @@
1
1
  import { FC } from 'react';
2
- type Props = {
2
+ /**
3
+ * A modal component for displaying a table with data from a SQL query.
4
+ *
5
+ * @component
6
+ * @param props - Component props
7
+ * @param props.title - The title of the table
8
+ * @param props.query - The SQL query to execute and display in the table
9
+ * @param props.tableModal - An object containing the modal's open state and close function
10
+ *
11
+ * @example
12
+ * ```tsx
13
+ * import { useState } from 'react';
14
+ * import { DataTableModal } from '@sqlrooms/data-table';
15
+ *
16
+ * const MyComponent = () => {
17
+ * const [isOpen, setIsOpen] = useState(false);
18
+ *
19
+ * return (
20
+ * <DataTableModal
21
+ * title="Users"
22
+ * query="SELECT * FROM users LIMIT 10"
23
+ * tableModal={{
24
+ * isOpen,
25
+ * onClose: () => setIsOpen(false)
26
+ * }}
27
+ * />
28
+ * );
29
+ * };
30
+ * ```
31
+ */
32
+ declare const DataTableModal: FC<{
3
33
  title: string | undefined;
4
34
  query: string | undefined;
5
35
  tableModal: {
6
36
  isOpen: boolean;
7
37
  onClose: () => void;
8
38
  };
9
- };
10
- declare const DataTableModal: FC<Props>;
39
+ }>;
11
40
  export default DataTableModal;
12
41
  //# sourceMappingURL=DataTableModal.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"DataTableModal.d.ts","sourceRoot":"","sources":["../src/DataTableModal.tsx"],"names":[],"mappings":"AAQA,OAAO,EAAC,EAAE,EAAC,MAAM,OAAO,CAAC;AAGzB,KAAK,KAAK,GAAG;IACX,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,UAAU,EAAE;QACV,MAAM,EAAE,OAAO,CAAC;QAChB,OAAO,EAAE,MAAM,IAAI,CAAC;KACrB,CAAC;CACH,CAAC;AAEF,QAAA,MAAM,cAAc,EAAE,EAAE,CAAC,KAAK,CAqB7B,CAAC;AAEF,eAAe,cAAc,CAAC"}
1
+ {"version":3,"file":"DataTableModal.d.ts","sourceRoot":"","sources":["../src/DataTableModal.tsx"],"names":[],"mappings":"AAQA,OAAO,EAAC,EAAE,EAAC,MAAM,OAAO,CAAC;AAGzB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,QAAA,MAAM,cAAc,EAAE,EAAE,CAAC;IACvB,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,UAAU,EAAE;QACV,MAAM,EAAE,OAAO,CAAC;QAChB,OAAO,EAAE,MAAM,IAAI,CAAC;KACrB,CAAC;CACH,CAwBA,CAAC;AAEF,eAAe,cAAc,CAAC"}
@@ -1,7 +1,37 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Button, Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle, } from '@sqlrooms/ui';
3
3
  import QueryDataTable from './QueryDataTable';
4
+ /**
5
+ * A modal component for displaying a table with data from a SQL query.
6
+ *
7
+ * @component
8
+ * @param props - Component props
9
+ * @param props.title - The title of the table
10
+ * @param props.query - The SQL query to execute and display in the table
11
+ * @param props.tableModal - An object containing the modal's open state and close function
12
+ *
13
+ * @example
14
+ * ```tsx
15
+ * import { useState } from 'react';
16
+ * import { DataTableModal } from '@sqlrooms/data-table';
17
+ *
18
+ * const MyComponent = () => {
19
+ * const [isOpen, setIsOpen] = useState(false);
20
+ *
21
+ * return (
22
+ * <DataTableModal
23
+ * title="Users"
24
+ * query="SELECT * FROM users LIMIT 10"
25
+ * tableModal={{
26
+ * isOpen,
27
+ * onClose: () => setIsOpen(false)
28
+ * }}
29
+ * />
30
+ * );
31
+ * };
32
+ * ```
33
+ */
4
34
  const DataTableModal = ({ title, query, tableModal }) => {
5
- return (_jsx(Dialog, { open: tableModal.isOpen, onOpenChange: (isOpen) => !isOpen && tableModal.onClose(), children: _jsxs(DialogContent, { className: "h-[80vh] max-w-[75vw]", children: [_jsx(DialogHeader, { children: _jsx(DialogTitle, { children: title ? `Table "${title}"` : '' }) }), _jsx("div", { className: "flex-1 bg-muted overflow-hidden", children: tableModal.isOpen && query ? _jsx(QueryDataTable, { query: query }) : null }), _jsx(DialogFooter, { children: _jsx(Button, { variant: "outline", onClick: tableModal.onClose, children: "Close" }) })] }) }));
35
+ return (_jsx(Dialog, { open: tableModal.isOpen, onOpenChange: (isOpen) => !isOpen && tableModal.onClose(), children: _jsxs(DialogContent, { className: "h-[80vh] max-w-[75vw]", "aria-describedby": "data-table-modal", children: [_jsx(DialogHeader, { children: _jsx(DialogTitle, { children: title ? `Table "${title}"` : '' }) }), _jsx("div", { className: "flex-1 bg-muted overflow-hidden", children: tableModal.isOpen && query ? _jsx(QueryDataTable, { query: query }) : null }), _jsx(DialogFooter, { children: _jsx(Button, { variant: "outline", onClick: tableModal.onClose, children: "Close" }) })] }) }));
6
36
  };
7
37
  export default DataTableModal;
@@ -40,15 +40,15 @@ export default function DataTablePaginated({ data, columns, pageCount, numRows,
40
40
  .meta;
41
41
  return (_jsx(TableHead, { colSpan: header.colSpan, className: `
42
42
  sticky top-0 w-auto whitespace-nowrap cursor-pointer py-2
43
- bg-background border-r hover:bg-muted/80 z-10
43
+ bg-background border-r hover:bg-muted z-10
44
44
  ${meta?.isNumeric ? 'text-right' : 'text-left'}
45
- `, onClick: header.column.getToggleSortingHandler(), children: _jsxs("div", { className: "flex gap-2 items-center", children: [header.isPlaceholder ? null : (_jsx("div", { children: flexRender(header.column.columnDef.header, header.getContext()) })), header.column.getIsSorted() ? (header.column.getIsSorted() === 'desc' ? (_jsx(ChevronDownIcon, { className: "h-4 w-4" })) : (_jsx(ChevronUpIcon, { className: "h-4 w-4" }))) : null, _jsx("div", { className: "flex-1" }), _jsx(Badge, { variant: "outline", className: "opacity-30 text-[9px] max-w-[70px] truncate", children: String(meta?.type) })] }) }, header.id));
46
- }), _jsx(TableHead, { className: "sticky top-0 w-full whitespace-nowrap py-2 bg-background border-r border-t" })] }, headerGroup.id))) }), _jsx(TableBody, { children: table.getRowModel().rows.map((row, i) => (_jsxs(TableRow, { className: "hover:bg-muted/50", children: [_jsx(TableCell, { className: "text-xs border-r bg-muted text-center text-muted-foreground sticky left-0", children: pagination
45
+ `, onClick: header.column.getToggleSortingHandler(), children: _jsxs("div", { className: "flex gap-2 items-center", children: [header.isPlaceholder ? null : (_jsx("div", { children: flexRender(header.column.columnDef.header, header.getContext()) })), header.column.getIsSorted() ? (header.column.getIsSorted() === 'desc' ? (_jsx(ChevronDownIcon, { className: "h-4 w-4" })) : (_jsx(ChevronUpIcon, { className: "h-4 w-4" }))) : null, _jsx("div", { className: "flex-1" }), _jsx(Badge, { variant: "outline", className: "opacity-30 text-xs truncate max-w-[400px]", children: String(meta?.type) })] }) }, header.id));
46
+ }), _jsx(TableHead, { className: "sticky top-0 w-full whitespace-nowrap py-2 bg-background border-r border-t" })] }, headerGroup.id))) }), _jsx(TableBody, { children: table.getRowModel().rows.map((row, i) => (_jsxs(TableRow, { className: "hover:bg-muted bg-background", children: [_jsx(TableCell, { className: "text-xs border-r text-center text-muted-foreground sticky left-0", children: pagination
47
47
  ? `${pagination.pageIndex * pagination.pageSize + i + 1}`
48
48
  : '' }), row.getVisibleCells().map((cell) => {
49
49
  const meta = cell.column.columnDef.meta;
50
50
  return (_jsx(TableCell, { className: `
51
- text-[11px] border-r max-w-[500px] overflow-hidden truncate px-7
51
+ text-xs border-r max-w-[500px] overflow-hidden truncate px-7
52
52
  ${meta?.isNumeric ? 'text-right' : 'text-left'}
53
53
  `, children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id));
54
54
  }), _jsx(TableCell, { className: "border-r", children: "\u00A0" })] }, row.id))) })] }) }) }), _jsxs("div", { className: "sticky bottom-0 left-0 bg-background p-2 flex gap-2 items-center flex-wrap border border-t-0", children: [_jsx(Button, { variant: "outline", size: "icon", onClick: () => table.setPageIndex(0), disabled: !table.getCanPreviousPage(), children: _jsx(ChevronDoubleLeftIcon, { className: "h-4 w-4" }) }), _jsx(Button, { variant: "outline", size: "icon", onClick: () => table.previousPage(), disabled: !table.getCanPreviousPage(), children: _jsx(ChevronLeftIcon, { className: "h-4 w-4" }) }), _jsxs("div", { className: "flex items-center text-sm ml-1 gap-1", children: [_jsx("div", { children: "Page" }), _jsx(Input, { type: "number", min: 1, max: table.getPageCount(), className: "w-16 h-8", value: internalPageIndex + 1, onChange: (e) => {
@@ -1,5 +1,5 @@
1
1
  import { ColumnDef } from '@tanstack/react-table';
2
- export type Props<Data extends object> = {
2
+ export type DataTableVirtualizedProps<Data extends object> = {
3
3
  data?: ArrayLike<Data>;
4
4
  columns?: ColumnDef<Data, any>[];
5
5
  isFetching?: boolean;
@@ -11,5 +11,5 @@ export type DataTableProps<Data extends object> = {
11
11
  columns: ColumnDef<Data, any>[];
12
12
  isPreview?: boolean;
13
13
  };
14
- export default function DataTableWithLoader<Data extends object>(props: Props<Data>): import("react/jsx-runtime").JSX.Element | null;
14
+ export default function DataTableWithLoader<Data extends object>(props: DataTableVirtualizedProps<Data>): import("react/jsx-runtime").JSX.Element | null;
15
15
  //# sourceMappingURL=DataTableVirtualized.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"DataTableVirtualized.d.ts","sourceRoot":"","sources":["../src/DataTableVirtualized.tsx"],"names":[],"mappings":"AAYA,OAAO,EACL,SAAS,EAMV,MAAM,uBAAuB,CAAC;AAI/B,MAAM,MAAM,KAAK,CAAC,IAAI,SAAS,MAAM,IAAI;IACvC,IAAI,CAAC,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC;IACvB,OAAO,CAAC,EAAE,SAAS,CAAC,IAAI,EAAE,GAAG,CAAC,EAAE,CAAC;IACjC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,cAAc,CAAC,IAAI,SAAS,MAAM,IAAI;IAChD,IAAI,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC;IACtB,OAAO,EAAE,SAAS,CAAC,IAAI,EAAE,GAAG,CAAC,EAAE,CAAC;IAChC,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC;AA0IF,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAAC,IAAI,SAAS,MAAM,EAC7D,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,kDAenB"}
1
+ {"version":3,"file":"DataTableVirtualized.d.ts","sourceRoot":"","sources":["../src/DataTableVirtualized.tsx"],"names":[],"mappings":"AAYA,OAAO,EACL,SAAS,EAMV,MAAM,uBAAuB,CAAC;AAI/B,MAAM,MAAM,yBAAyB,CAAC,IAAI,SAAS,MAAM,IAAI;IAC3D,IAAI,CAAC,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC;IACvB,OAAO,CAAC,EAAE,SAAS,CAAC,IAAI,EAAE,GAAG,CAAC,EAAE,CAAC;IACjC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,cAAc,CAAC,IAAI,SAAS,MAAM,IAAI;IAChD,IAAI,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC;IACtB,OAAO,EAAE,SAAS,CAAC,IAAI,EAAE,GAAG,CAAC,EAAE,CAAC;IAChC,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC;AA0IF,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAAC,IAAI,SAAS,MAAM,EAC7D,KAAK,EAAE,yBAAyB,CAAC,IAAI,CAAC,kDAevC"}
@@ -1,8 +1,8 @@
1
1
  import { FC } from 'react';
2
- type Props = {
2
+ export type QueryDataTableProps = {
3
3
  query: string;
4
- queryKeyComponents?: any[];
4
+ queryKeyComponents?: unknown[];
5
5
  };
6
- declare const QueryDataTableWithSuspense: FC<Props>;
6
+ declare const QueryDataTableWithSuspense: FC<QueryDataTableProps>;
7
7
  export default QueryDataTableWithSuspense;
8
8
  //# sourceMappingURL=QueryDataTable.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"QueryDataTable.d.ts","sourceRoot":"","sources":["../src/QueryDataTable.tsx"],"names":[],"mappings":"AASA,OAAO,EAAC,EAAE,EAAgC,MAAM,OAAO,CAAC;AAIxD,KAAK,KAAK,GAAG;IACX,KAAK,EAAE,MAAM,CAAC;IACd,kBAAkB,CAAC,EAAE,GAAG,EAAE,CAAC;CAC5B,CAAC;AAyFF,QAAA,MAAM,0BAA0B,EAAE,EAAE,CAAC,KAAK,CASzC,CAAC;AAEF,eAAe,0BAA0B,CAAC"}
1
+ {"version":3,"file":"QueryDataTable.d.ts","sourceRoot":"","sources":["../src/QueryDataTable.tsx"],"names":[],"mappings":"AASA,OAAO,EAAC,EAAE,EAAgC,MAAM,OAAO,CAAC;AAIxD,MAAM,MAAM,mBAAmB,GAAG;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,kBAAkB,CAAC,EAAE,OAAO,EAAE,CAAC;CAChC,CAAC;AAyFF,QAAA,MAAM,0BAA0B,EAAE,EAAE,CAAC,mBAAmB,CASvD,CAAC;AAEF,eAAe,0BAA0B,CAAC"}
package/package.json CHANGED
@@ -1,19 +1,22 @@
1
1
  {
2
2
  "name": "@sqlrooms/data-table",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "module": "dist/index.js",
7
7
  "type": "module",
8
8
  "private": false,
9
+ "files": [
10
+ "dist"
11
+ ],
9
12
  "publishConfig": {
10
13
  "access": "public"
11
14
  },
12
15
  "dependencies": {
13
16
  "@heroicons/react": "*",
14
- "@sqlrooms/duckdb": "0.0.1",
15
- "@sqlrooms/ui": "0.0.1",
16
- "@sqlrooms/utils": "0.0.1",
17
+ "@sqlrooms/duckdb": "0.0.2",
18
+ "@sqlrooms/ui": "0.0.2",
19
+ "@sqlrooms/utils": "0.0.2",
17
20
  "@tanstack/react-table": "^8.10.7",
18
21
  "@tanstack/table-core": "^8.10.7",
19
22
  "react-virtual": "2.10.4"
@@ -26,7 +29,8 @@
26
29
  "scripts": {
27
30
  "dev": "tsc -w",
28
31
  "build": "tsc",
29
- "lint": "eslint ."
32
+ "lint": "eslint .",
33
+ "typedoc": "typedoc"
30
34
  },
31
- "gitHead": "5d8893a604a91d109dc5b5f80b4a3e937b4cf520"
35
+ "gitHead": "32da0b35fe906bdcef42274624d069cc49425a74"
32
36
  }
package/CHANGELOG.md DELETED
@@ -1,14 +0,0 @@
1
- # Change Log
2
-
3
- All notable changes to this project will be documented in this file.
4
- See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
-
6
- ## [0.0.1](https://github.com/ilyabo/sqlrooms/compare/v0.0.1-alpha.0...v0.0.1) (2025-01-30)
7
-
8
- **Note:** Version bump only for package @sqlrooms/data-table
9
-
10
- ## 0.0.1-alpha.0 (2025-01-30)
11
-
12
- **Note:** Version bump only for package @sqlrooms/data-table
13
-
14
- **Note:** Version bump only for package @sqlrooms/data-table
@@ -1,18 +0,0 @@
1
- ## Package Structure
2
-
3
- SQLRooms is organized into several key packages:
4
-
5
- ### Core Packages
6
-
7
- - `@sqlrooms/project-builder`: Core framework and UI components
8
- - `@sqlrooms/project-config`: Configuration and type definitions
9
- - `@sqlrooms/layout`: Layout system and panel management
10
- - `@sqlrooms/ui`: Shared UI components and styling
11
-
12
- ### Feature Packages
13
-
14
- - `@sqlrooms/data-table`: Interactive data grid component for query results
15
- - `@sqlrooms/duckdb`: DuckDB-WASM integration and utilities
16
- - `@sqlrooms/dropzone`: File upload and drag-and-drop functionality
17
- - `@sqlrooms/s3-browser`: S3-compatible storage browser and file manager
18
- - `@sqlrooms/sql-editor`: SQL query editor with syntax highlighting and autocompletion