@tablecraft/table 0.1.0 → 0.1.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.
package/README.md ADDED
@@ -0,0 +1,140 @@
1
+ # @tablecraft/table
2
+
3
+ Schema-driven data table for React — built on TanStack Table + Shadcn UI with native TableCraft engine support.
4
+
5
+ ## Links
6
+
7
+ - [GitHub](https://github.com/jacksonkasi1/TableCraft)
8
+ - [Documentation](https://jacksonkasi.gitbook.io/tablecraft/)
9
+
10
+ ## Install
11
+
12
+ ```bash
13
+ bun add @tablecraft/table
14
+ # or
15
+ npm install @tablecraft/table
16
+ # or
17
+ yarn add @tablecraft/table
18
+ # or
19
+ pnpm add @tablecraft/table
20
+ ```
21
+
22
+ ## Peer Dependencies
23
+
24
+ ```bash
25
+ bun add @tanstack/react-table react react-dom
26
+ ```
27
+
28
+ ## Features
29
+
30
+ - **Auto-generated columns** — Columns generated from your table config metadata
31
+ - **Built-in filtering** — Advanced filter UI with date presets, multi-select, and custom operators
32
+ - **Sorting & pagination** — Client-side or server-side with URL state sync
33
+ - **Export** — CSV, JSON, and Excel export built-in
34
+ - **Responsive** — Mobile-friendly with collapsible columns
35
+ - **Accessible** — WCAG compliant with keyboard navigation
36
+ - **Theming** — Dark mode support via Tailwind CSS
37
+
38
+ ## Quick Example
39
+
40
+ ```tsx
41
+ import { DataTable, useTablecraftAdapter } from '@tablecraft/table';
42
+ import { client } from './client';
43
+
44
+ function UsersPage() {
45
+ const adapter = useTablecraftAdapter({
46
+ client,
47
+ table: 'users',
48
+ });
49
+
50
+ return (
51
+ <DataTable
52
+ adapter={adapter}
53
+ columns={[
54
+ { id: 'name', header: 'Name', sortable: true, searchable: true },
55
+ { id: 'email', header: 'Email', sortable: true },
56
+ { id: 'status', header: 'Status', filterable: true },
57
+ { id: 'createdAt', header: 'Created', sortable: true },
58
+ ]}
59
+ features={{
60
+ search: true,
61
+ filters: true,
62
+ sort: true,
63
+ pagination: true,
64
+ export: true,
65
+ columnVisibility: true,
66
+ }}
67
+ />
68
+ );
69
+ }
70
+ ```
71
+
72
+ ## Static Data Example
73
+
74
+ ```tsx
75
+ import { DataTable, useStaticAdapter } from '@tablecraft/table';
76
+
77
+ function UsersTable({ users }: { users: User[] }) {
78
+ const adapter = useStaticAdapter({
79
+ data: users,
80
+ pageSize: 25,
81
+ });
82
+
83
+ return (
84
+ <DataTable
85
+ adapter={adapter}
86
+ columns={[
87
+ { id: 'name', header: 'Name' },
88
+ { id: 'email', header: 'Email' },
89
+ { id: 'status', header: 'Status', filterable: true },
90
+ ]}
91
+ features={{
92
+ search: true,
93
+ filters: true,
94
+ pagination: true,
95
+ }}
96
+ />
97
+ );
98
+ }
99
+ ```
100
+
101
+ ## Column Renderers
102
+
103
+ Built-in renderers for common data types:
104
+
105
+ ```tsx
106
+ import { renderers } from '@tablecraft/table';
107
+
108
+ const columns = [
109
+ { id: 'name', header: 'Name', cell: renderers.text() },
110
+ { id: 'avatar', header: 'Avatar', cell: renderers.image() },
111
+ { id: 'email', header: 'Email', cell: renderers.link({ href: (row) => `mailto:${row.email}` }) },
112
+ { id: 'status', header: 'Status', cell: renderers.badge({ variants: { active: 'success' } }) },
113
+ { id: 'progress', header: 'Progress', cell: renderers.progress() },
114
+ { id: 'createdAt', header: 'Created', cell: renderers.date({ format: 'MMM d, yyyy' }) },
115
+ { id: 'isActive', header: 'Active', cell: renderers.boolean() },
116
+ ];
117
+ ```
118
+
119
+ ## URL State Sync
120
+
121
+ Automatic URL synchronization for filters, sorting, and pagination:
122
+
123
+ ```tsx
124
+ import { DataTable, useTablecraftAdapter, useUrlState } from '@tablecraft/table';
125
+
126
+ function UsersPage() {
127
+ const urlState = useUrlState();
128
+ const adapter = useTablecraftAdapter({
129
+ client,
130
+ table: 'users',
131
+ initialState: urlState,
132
+ });
133
+
134
+ return <DataTable adapter={adapter} />;
135
+ }
136
+ ```
137
+
138
+ ## License
139
+
140
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tablecraft/table",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Schema-driven data table for React — built on TanStack Table + Shadcn UI with native TableCraft engine support",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -13,7 +13,8 @@
13
13
  }
14
14
  },
15
15
  "files": [
16
- "dist"
16
+ "dist",
17
+ "README.md"
17
18
  ],
18
19
  "scripts": {
19
20
  "build": "bun run --bun tsc",
@@ -65,5 +66,14 @@
65
66
  "shadcn",
66
67
  "data-table"
67
68
  ],
69
+ "repository": {
70
+ "type": "git",
71
+ "url": "git+https://github.com/jacksonkasi1/TableCraft.git",
72
+ "directory": "packages/table"
73
+ },
74
+ "homepage": "https://github.com/jacksonkasi1/TableCraft#readme",
75
+ "bugs": {
76
+ "url": "https://github.com/jacksonkasi1/TableCraft/issues"
77
+ },
68
78
  "license": "MIT"
69
79
  }
@@ -1,10 +0,0 @@
1
- import type { Row } from "@tanstack/react-table";
2
- interface DataTableRowActionsProps<TData> {
3
- row: Row<TData>;
4
- onEdit?: (data: TData) => void;
5
- onCopy?: (data: TData) => void;
6
- onDelete?: (data: TData) => void;
7
- }
8
- export declare function DataTableRowActions<TData>({ row, onEdit, onCopy, onDelete, }: DataTableRowActionsProps<TData>): import("react/jsx-runtime").JSX.Element;
9
- export {};
10
- //# sourceMappingURL=row-actions.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"row-actions.d.ts","sourceRoot":"","sources":["../src/row-actions.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAiBjD,UAAU,wBAAwB,CAAC,KAAK;IACtC,GAAG,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC;IAChB,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,KAAK,KAAK,IAAI,CAAC;IAC/B,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,KAAK,KAAK,IAAI,CAAC;IAC/B,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,KAAK,KAAK,IAAI,CAAC;CAClC;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,EACzC,GAAG,EACH,MAAM,EACN,MAAM,EACN,QAAQ,GACT,EAAE,wBAAwB,CAAC,KAAK,CAAC,2CAyDjC"}
@@ -1,36 +0,0 @@
1
- "use client";
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- // ** import core packages
4
- import { MoreHorizontal, Pencil, Copy, Trash2 } from "lucide-react";
5
- // ** import components
6
- import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger, } from "./components/table-dropdown";
7
- // ** import utils
8
- import { cn } from "./utils/cn";
9
- export function DataTableRowActions({ row, onEdit, onCopy, onDelete, }) {
10
- const handleEdit = () => {
11
- if (onEdit) {
12
- onEdit(row.original);
13
- }
14
- else {
15
- console.log("Edit:", row.original);
16
- }
17
- };
18
- const handleCopy = () => {
19
- if (onCopy) {
20
- onCopy(row.original);
21
- }
22
- else {
23
- console.log("Copy:", row.original);
24
- }
25
- };
26
- const handleDelete = () => {
27
- if (onDelete) {
28
- onDelete(row.original);
29
- }
30
- else {
31
- console.log("Delete:", row.original);
32
- }
33
- };
34
- return (_jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsxs("button", { className: cn("inline-flex h-8 w-8 items-center justify-center rounded-md text-sm font-medium", "hover:bg-accent hover:text-accent-foreground transition-colors", "focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring", "data-[state=open]:bg-muted"), children: [_jsx(MoreHorizontal, { className: "h-4 w-4" }), _jsx("span", { className: "sr-only", children: "Open menu" })] }) }), _jsxs(DropdownMenuContent, { align: "end", className: "w-[160px]", children: [_jsxs(DropdownMenuItem, { onClick: handleEdit, children: [_jsx(Pencil, { className: "mr-2 h-3.5 w-3.5 text-muted-foreground/70" }), "Edit"] }), _jsxs(DropdownMenuItem, { onClick: handleCopy, children: [_jsx(Copy, { className: "mr-2 h-3.5 w-3.5 text-muted-foreground/70" }), "Copy"] }), _jsx(DropdownMenuSeparator, {}), _jsxs(DropdownMenuItem, { onClick: handleDelete, children: [_jsx(Trash2, { className: "mr-2 h-3.5 w-3.5 text-muted-foreground/70" }), "Delete"] })] })] }));
35
- }
36
- //# sourceMappingURL=row-actions.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"row-actions.js","sourceRoot":"","sources":["../src/row-actions.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAKb,0BAA0B;AAC1B,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEpE,uBAAuB;AACvB,OAAO,EACL,YAAY,EACZ,mBAAmB,EACnB,gBAAgB,EAChB,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,6BAA6B,CAAC;AAErC,kBAAkB;AAClB,OAAO,EAAE,EAAE,EAAE,MAAM,YAAY,CAAC;AAShC,MAAM,UAAU,mBAAmB,CAAQ,EACzC,GAAG,EACH,MAAM,EACN,MAAM,EACN,QAAQ,GACwB;IAChC,MAAM,UAAU,GAAG,GAAG,EAAE;QACtB,IAAI,MAAM,EAAE,CAAC;YACX,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QACvB,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,QAAQ,CAAC,CAAC;QACrC,CAAC;IACH,CAAC,CAAC;IAEF,MAAM,UAAU,GAAG,GAAG,EAAE;QACtB,IAAI,MAAM,EAAE,CAAC;YACX,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QACvB,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,QAAQ,CAAC,CAAC;QACrC,CAAC;IACH,CAAC,CAAC;IAEF,MAAM,YAAY,GAAG,GAAG,EAAE;QACxB,IAAI,QAAQ,EAAE,CAAC;YACb,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QACzB,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,GAAG,CAAC,QAAQ,CAAC,CAAC;QACvC,CAAC;IACH,CAAC,CAAC;IAEF,OAAO,CACL,MAAC,YAAY,eACX,KAAC,mBAAmB,IAAC,OAAO,kBAC1B,kBACE,SAAS,EAAE,EAAE,CACX,gFAAgF,EAChF,gEAAgE,EAChE,yEAAyE,EACzE,4BAA4B,CAC7B,aAED,KAAC,cAAc,IAAC,SAAS,EAAC,SAAS,GAAG,EACtC,eAAM,SAAS,EAAC,SAAS,0BAAiB,IACnC,GACW,EACtB,MAAC,mBAAmB,IAAC,KAAK,EAAC,KAAK,EAAC,SAAS,EAAC,WAAW,aACpD,MAAC,gBAAgB,IAAC,OAAO,EAAE,UAAU,aACnC,KAAC,MAAM,IAAC,SAAS,EAAC,2CAA2C,GAAG,YAE/C,EACnB,MAAC,gBAAgB,IAAC,OAAO,EAAE,UAAU,aACnC,KAAC,IAAI,IAAC,SAAS,EAAC,2CAA2C,GAAG,YAE7C,EACnB,KAAC,qBAAqB,KAAG,EACzB,MAAC,gBAAgB,IAAC,OAAO,EAAE,YAAY,aACrC,KAAC,MAAM,IAAC,SAAS,EAAC,2CAA2C,GAAG,cAE/C,IACC,IACT,CAChB,CAAC;AACJ,CAAC"}
@@ -1,15 +0,0 @@
1
- /**
2
- * Size variant utility functions for consistent component sizing across the table package
3
- */
4
- export type SizeVariant = 'sm' | 'default' | 'lg';
5
- /**
6
- * Get the appropriate height class for input elements based on size variant
7
- */
8
- export declare const getInputSizeClass: (size: SizeVariant) => string;
9
- /**
10
- * Get the appropriate size classes for button elements
11
- * @param size - The size variant to apply
12
- * @param isIcon - Whether this is an icon-only button (affects width)
13
- */
14
- export declare const getButtonSizeClass: (size: SizeVariant, isIcon?: boolean) => string;
15
- //# sourceMappingURL=size-variants.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"size-variants.d.ts","sourceRoot":"","sources":["../../src/utils/size-variants.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,MAAM,WAAW,GAAG,IAAI,GAAG,SAAS,GAAG,IAAI,CAAC;AAElD;;GAEG;AACH,eAAO,MAAM,iBAAiB,GAAI,MAAM,WAAW,KAAG,MASrD,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,GAAI,MAAM,WAAW,EAAE,gBAAc,KAAG,MAmBtE,CAAC"}
@@ -1,42 +0,0 @@
1
- /**
2
- * Size variant utility functions for consistent component sizing across the table package
3
- */
4
- /**
5
- * Get the appropriate height class for input elements based on size variant
6
- */
7
- export const getInputSizeClass = (size) => {
8
- switch (size) {
9
- case 'sm':
10
- return 'h-8';
11
- case 'lg':
12
- return 'h-11';
13
- default:
14
- return '';
15
- }
16
- };
17
- /**
18
- * Get the appropriate size classes for button elements
19
- * @param size - The size variant to apply
20
- * @param isIcon - Whether this is an icon-only button (affects width)
21
- */
22
- export const getButtonSizeClass = (size, isIcon = false) => {
23
- if (isIcon) {
24
- switch (size) {
25
- case 'sm':
26
- return 'h-8 w-8';
27
- case 'lg':
28
- return 'h-11 w-11';
29
- default:
30
- return '';
31
- }
32
- }
33
- switch (size) {
34
- case 'sm':
35
- return 'h-8 px-3';
36
- case 'lg':
37
- return 'h-11 px-5';
38
- default:
39
- return '';
40
- }
41
- };
42
- //# sourceMappingURL=size-variants.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"size-variants.js","sourceRoot":"","sources":["../../src/utils/size-variants.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,IAAiB,EAAU,EAAE;IAC7D,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,IAAI;YACP,OAAO,KAAK,CAAC;QACf,KAAK,IAAI;YACP,OAAO,MAAM,CAAC;QAChB;YACE,OAAO,EAAE,CAAC;IACd,CAAC;AACH,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,IAAiB,EAAE,MAAM,GAAG,KAAK,EAAU,EAAE;IAC9E,IAAI,MAAM,EAAE,CAAC;QACX,QAAQ,IAAI,EAAE,CAAC;YACb,KAAK,IAAI;gBACP,OAAO,SAAS,CAAC;YACnB,KAAK,IAAI;gBACP,OAAO,WAAW,CAAC;YACrB;gBACE,OAAO,EAAE,CAAC;QACd,CAAC;IACH,CAAC;IACD,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,IAAI;YACP,OAAO,UAAU,CAAC;QACpB,KAAK,IAAI;YACP,OAAO,WAAW,CAAC;QACrB;YACE,OAAO,EAAE,CAAC;IACd,CAAC;AACH,CAAC,CAAC"}