@nccirtu/tablefy 0.1.0
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/LICENSE +21 -0
- package/README.md +236 -0
- package/dist/columns/actions-column.d.ts +26 -0
- package/dist/columns/avatar-group-column.d.ts +38 -0
- package/dist/columns/badge-column.d.ts +22 -0
- package/dist/columns/base-column.d.ts +19 -0
- package/dist/columns/button-column.d.ts +14 -0
- package/dist/columns/checkbox-column.d.ts +5 -0
- package/dist/columns/date-column.d.ts +24 -0
- package/dist/columns/dropdown-column.d.ts +17 -0
- package/dist/columns/icon-column.d.ts +58 -0
- package/dist/columns/image-column.d.ts +21 -0
- package/dist/columns/index.d.ts +13 -0
- package/dist/columns/input-column.d.ts +14 -0
- package/dist/columns/link-column.d.ts +27 -0
- package/dist/columns/number-column.d.ts +23 -0
- package/dist/columns/progress-column.d.ts +30 -0
- package/dist/columns/select-column.d.ts +19 -0
- package/dist/columns/text-column.d.ts +14 -0
- package/dist/columns/types.d.ts +37 -0
- package/dist/components/animata/list/avatar-list.d.ts +12 -0
- package/dist/components/ui/badge.d.ts +9 -0
- package/dist/components/ui/button.d.ts +10 -0
- package/dist/components/ui/checkbox.d.ts +4 -0
- package/dist/components/ui/data-table/data-table-empty.d.ts +8 -0
- package/dist/components/ui/data-table/data-table-header.d.ts +15 -0
- package/dist/components/ui/data-table/data-table-pagination.d.ts +9 -0
- package/dist/components/ui/data-table/data-table-schema.d.ts +5 -0
- package/dist/components/ui/data-table/data-table.d.ts +13 -0
- package/dist/components/ui/dropdown-menu.d.ts +25 -0
- package/dist/components/ui/input.d.ts +3 -0
- package/dist/components/ui/progress.d.ts +4 -0
- package/dist/components/ui/select.d.ts +15 -0
- package/dist/components/ui/table.d.ts +10 -0
- package/dist/components/ui/tooltip.d.ts +7 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.esm.js +10260 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.js +10294 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/builders/empty-state.d.ts +27 -0
- package/dist/lib/builders/index.d.ts +2 -0
- package/dist/lib/builders/table-schema.d.ts +15 -0
- package/dist/lib/table/schema/empty-state.d.ts +23 -0
- package/dist/lib/table/types.d.ts +76 -0
- package/dist/lib/types/actions.d.ts +20 -0
- package/dist/lib/types/empty-state.d.ts +18 -0
- package/dist/lib/types/filters.d.ts +25 -0
- package/dist/lib/types/index.d.ts +4 -0
- package/dist/lib/types/table.d.ts +41 -0
- package/dist/lib/utils.d.ts +1 -0
- package/dist/schema/data-table-schema.d.ts +75 -0
- package/dist/schema/empty-state.d.ts +45 -0
- package/dist/schema/table-schema.d.ts +44 -0
- package/dist/schema.d.ts +11 -0
- package/dist/src/columns/actions-column.d.ts +26 -0
- package/dist/src/columns/avatar-group-column.d.ts +38 -0
- package/dist/src/columns/badge-column.d.ts +22 -0
- package/dist/src/columns/base-column.d.ts +19 -0
- package/dist/src/columns/button-column.d.ts +14 -0
- package/dist/src/columns/checkbox-column.d.ts +5 -0
- package/dist/src/columns/date-column.d.ts +24 -0
- package/dist/src/columns/dropdown-column.d.ts +17 -0
- package/dist/src/columns/icon-column.d.ts +58 -0
- package/dist/src/columns/image-column.d.ts +21 -0
- package/dist/src/columns/index.d.ts +13 -0
- package/dist/src/columns/input-column.d.ts +14 -0
- package/dist/src/columns/link-column.d.ts +27 -0
- package/dist/src/columns/number-column.d.ts +23 -0
- package/dist/src/columns/progress-column.d.ts +30 -0
- package/dist/src/columns/select-column.d.ts +19 -0
- package/dist/src/columns/text-column.d.ts +14 -0
- package/dist/src/columns/types.d.ts +37 -0
- package/dist/src/components/animata/list/avatar-list.d.ts +12 -0
- package/dist/src/components/ui/badge.d.ts +9 -0
- package/dist/src/components/ui/button.d.ts +10 -0
- package/dist/src/components/ui/checkbox.d.ts +4 -0
- package/dist/src/components/ui/data-table/data-table-empty.d.ts +8 -0
- package/dist/src/components/ui/data-table/data-table-header.d.ts +15 -0
- package/dist/src/components/ui/data-table/data-table-pagination.d.ts +9 -0
- package/dist/src/components/ui/data-table/data-table-schema.d.ts +5 -0
- package/dist/src/components/ui/data-table/data-table.d.ts +13 -0
- package/dist/src/components/ui/dropdown-menu.d.ts +25 -0
- package/dist/src/components/ui/input.d.ts +3 -0
- package/dist/src/components/ui/progress.d.ts +4 -0
- package/dist/src/components/ui/select.d.ts +15 -0
- package/dist/src/components/ui/table.d.ts +10 -0
- package/dist/src/components/ui/tooltip.d.ts +7 -0
- package/dist/src/index.d.ts +15 -0
- package/dist/src/lib/table/schema/empty-state.d.ts +23 -0
- package/dist/src/lib/table/types.d.ts +76 -0
- package/dist/src/lib/utils.d.ts +1 -0
- package/dist/src/schema/data-table-schema.d.ts +75 -0
- package/dist/src/schema/empty-state.d.ts +45 -0
- package/dist/src/schema/table-schema.d.ts +44 -0
- package/dist/src/schema.d.ts +11 -0
- package/dist/src/types.d.ts +76 -0
- package/dist/types.d.ts +76 -0
- package/package.json +73 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Cirtu Cristian
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
# Tablefy
|
|
2
|
+
|
|
3
|
+
A powerful, type-safe React table package built with TanStack Table and shadcn/ui components. Create beautiful, feature-rich data tables with a fluent, chainable API.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Beautiful UI** - Built on shadcn/ui components with Tailwind CSS
|
|
8
|
+
- **Search & Filter** - Built-in search and advanced filtering
|
|
9
|
+
- **Sorting & Pagination** - Full sorting and pagination support
|
|
10
|
+
- **Type-Safe** - Complete TypeScript support with type inference
|
|
11
|
+
- **Fluent API** - Chainable builder pattern for easy configuration
|
|
12
|
+
- **Responsive** - Mobile-friendly responsive design
|
|
13
|
+
- **Rich Columns** - 12+ specialized column types with custom builders
|
|
14
|
+
- **Performance** - Optimized for large datasets
|
|
15
|
+
- **Customizable** - Extensive theming and styling options
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install tablefy
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### Prerequisites
|
|
24
|
+
|
|
25
|
+
Tablefy requires the following peer dependencies:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npm install @tanstack/react-table lucide-react class-variance-authority clsx tailwind-merge
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Quick Start
|
|
32
|
+
|
|
33
|
+
```tsx
|
|
34
|
+
import {
|
|
35
|
+
DataTable,
|
|
36
|
+
TableSchema,
|
|
37
|
+
TextColumn,
|
|
38
|
+
BadgeColumn,
|
|
39
|
+
DateColumn,
|
|
40
|
+
} from "tablefy";
|
|
41
|
+
|
|
42
|
+
type User = {
|
|
43
|
+
id: string;
|
|
44
|
+
name: string;
|
|
45
|
+
email: string;
|
|
46
|
+
status: "active" | "inactive";
|
|
47
|
+
createdAt: Date;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const columns = TableSchema.make<User>()
|
|
51
|
+
.columns(
|
|
52
|
+
TextColumn.make("name").label("Name").sortable(),
|
|
53
|
+
|
|
54
|
+
TextColumn.make("email").label("Email").limit(30),
|
|
55
|
+
|
|
56
|
+
BadgeColumn.make("status").label("Status").variants({
|
|
57
|
+
active: "success",
|
|
58
|
+
inactive: "secondary",
|
|
59
|
+
}),
|
|
60
|
+
|
|
61
|
+
DateColumn.make("createdAt").label("Created").relative(),
|
|
62
|
+
)
|
|
63
|
+
.build();
|
|
64
|
+
|
|
65
|
+
function UsersTable({ users }: { users: User[] }) {
|
|
66
|
+
return (
|
|
67
|
+
<DataTable
|
|
68
|
+
columns={columns}
|
|
69
|
+
data={users}
|
|
70
|
+
config={{
|
|
71
|
+
search: { enabled: true },
|
|
72
|
+
pagination: { enabled: true },
|
|
73
|
+
}}
|
|
74
|
+
/>
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Column Types
|
|
80
|
+
|
|
81
|
+
Tablefy provides 12+ specialized column types, each with their own builder methods:
|
|
82
|
+
|
|
83
|
+
| Column Type | Description | Key Methods |
|
|
84
|
+
| ------------------- | -------------------- | ------------------------------------------------------------------------- |
|
|
85
|
+
| `TextColumn` | Simple text display | `sortable()`, `prefix()`, `suffix()`, `limit()`, `uppercase()` |
|
|
86
|
+
| `NumberColumn` | Numbers & currency | `money()`, `percent()`, `decimals()`, `locale()` |
|
|
87
|
+
| `DateColumn` | Dates & times | `short()`, `long()`, `relative()`, `datetime()`, `withIcon()` |
|
|
88
|
+
| `BadgeColumn` | Status badges | `variants()`, `boolean()`, `status()` |
|
|
89
|
+
| `LinkColumn` | Clickable links | `href()`, `external()`, `underline()`, `openInNewTab()` |
|
|
90
|
+
| `ProgressColumn` | Progress bars | `max()`, `colorByThreshold()`, `showPercentage()`, `format()` |
|
|
91
|
+
| `AvatarGroupColumn` | Avatar groups | `maxVisible()`, `size()`, `overlap()`, `fields()`, `showNames()` |
|
|
92
|
+
| `IconColumn` | Status icons | `boolean()`, `priority()`, `onlineStatus()`, `verification()`, `states()` |
|
|
93
|
+
| `ImageColumn` | Single images | `size()`, `rounded()`, `circular()`, `fallback()` |
|
|
94
|
+
| `CheckboxColumn` | Selection checkboxes | — |
|
|
95
|
+
| `ActionsColumn` | Dropdown menus | `view()`, `edit()`, `delete()`, `action()`, `link()` |
|
|
96
|
+
|
|
97
|
+
## Example: Project Management Table
|
|
98
|
+
|
|
99
|
+
```tsx
|
|
100
|
+
import {
|
|
101
|
+
TableSchema,
|
|
102
|
+
CheckboxColumn,
|
|
103
|
+
TextColumn,
|
|
104
|
+
LinkColumn,
|
|
105
|
+
ProgressColumn,
|
|
106
|
+
AvatarGroupColumn,
|
|
107
|
+
IconColumn,
|
|
108
|
+
DateColumn,
|
|
109
|
+
ActionsColumn,
|
|
110
|
+
} from "tablefy";
|
|
111
|
+
|
|
112
|
+
type Project = {
|
|
113
|
+
id: string;
|
|
114
|
+
name: string;
|
|
115
|
+
url: string;
|
|
116
|
+
progress: number;
|
|
117
|
+
priority: "low" | "medium" | "high" | "critical";
|
|
118
|
+
status: "active" | "inactive";
|
|
119
|
+
isPublic: boolean;
|
|
120
|
+
team: Array<{ name: string; avatar?: string }>;
|
|
121
|
+
deadline: Date;
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
export const projectColumns = TableSchema.make<Project>()
|
|
125
|
+
.columns(
|
|
126
|
+
CheckboxColumn.make(),
|
|
127
|
+
|
|
128
|
+
LinkColumn.make("name")
|
|
129
|
+
.label("Project")
|
|
130
|
+
.sortable()
|
|
131
|
+
.href((row) => `/projects/${row.id}`)
|
|
132
|
+
.underline("hover"),
|
|
133
|
+
|
|
134
|
+
LinkColumn.make("url").label("Website").external().limit(30),
|
|
135
|
+
|
|
136
|
+
ProgressColumn.make("progress")
|
|
137
|
+
.label("Progress")
|
|
138
|
+
.sortable()
|
|
139
|
+
.colorByThreshold(30, 15)
|
|
140
|
+
.showPercentage(),
|
|
141
|
+
|
|
142
|
+
IconColumn.make("priority")
|
|
143
|
+
.label("Priority")
|
|
144
|
+
.sortable()
|
|
145
|
+
.priority()
|
|
146
|
+
.withBackground(),
|
|
147
|
+
|
|
148
|
+
IconColumn.make("status").label("Status").activeInactive(),
|
|
149
|
+
|
|
150
|
+
IconColumn.make("isPublic")
|
|
151
|
+
.label("Visibility")
|
|
152
|
+
.boolean({
|
|
153
|
+
trueLabel: "Public",
|
|
154
|
+
falseLabel: "Private",
|
|
155
|
+
})
|
|
156
|
+
.showLabel(),
|
|
157
|
+
|
|
158
|
+
AvatarGroupColumn.make("team")
|
|
159
|
+
.label("Team")
|
|
160
|
+
.maxVisible(3)
|
|
161
|
+
.size("sm")
|
|
162
|
+
.fields({ name: "name", src: "avatar" }),
|
|
163
|
+
|
|
164
|
+
DateColumn.make("deadline").label("Deadline").sortable().relative(),
|
|
165
|
+
|
|
166
|
+
ActionsColumn.make<Project>()
|
|
167
|
+
.view((row) => (window.location.href = `/projects/${row.id}`))
|
|
168
|
+
.edit((row) => console.log("Edit", row.id))
|
|
169
|
+
.delete((row) => console.log("Delete", row.id)),
|
|
170
|
+
)
|
|
171
|
+
.build();
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
## Documentation
|
|
175
|
+
|
|
176
|
+
- [Installation Guide](./docs/INSTALLATION.md) - Detailed installation instructions
|
|
177
|
+
- [Usage Guide](./docs/USAGE.md) - Complete API reference and examples
|
|
178
|
+
- [Column Types](./docs/USAGE.md#column-types) - All column types and their methods
|
|
179
|
+
|
|
180
|
+
## Advanced Features
|
|
181
|
+
|
|
182
|
+
### Empty States
|
|
183
|
+
|
|
184
|
+
```tsx
|
|
185
|
+
import { EmptyStateBuilder } from "tablefy";
|
|
186
|
+
|
|
187
|
+
const emptyState = EmptyStateBuilder.make()
|
|
188
|
+
.title("No projects found")
|
|
189
|
+
.description("Get started by creating your first project")
|
|
190
|
+
.action("Create Project", () => createProject())
|
|
191
|
+
.build();
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
### Search & Filters
|
|
195
|
+
|
|
196
|
+
```tsx
|
|
197
|
+
<DataTable
|
|
198
|
+
columns={columns}
|
|
199
|
+
data={data}
|
|
200
|
+
config={{
|
|
201
|
+
search: {
|
|
202
|
+
enabled: true,
|
|
203
|
+
placeholder: "Search projects...",
|
|
204
|
+
columns: ["name", "url"],
|
|
205
|
+
},
|
|
206
|
+
filters: [
|
|
207
|
+
{
|
|
208
|
+
id: "status",
|
|
209
|
+
label: "Status",
|
|
210
|
+
type: "select",
|
|
211
|
+
column: "status",
|
|
212
|
+
options: [
|
|
213
|
+
{ label: "Active", value: "active" },
|
|
214
|
+
{ label: "Inactive", value: "inactive" },
|
|
215
|
+
],
|
|
216
|
+
},
|
|
217
|
+
],
|
|
218
|
+
}}
|
|
219
|
+
/>
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
## Contributing
|
|
223
|
+
|
|
224
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
225
|
+
|
|
226
|
+
## License
|
|
227
|
+
|
|
228
|
+
MIT Tablefy Contributors
|
|
229
|
+
|
|
230
|
+
## Acknowledgments
|
|
231
|
+
|
|
232
|
+
Built with:
|
|
233
|
+
|
|
234
|
+
- [TanStack Table](https://tanstack.com/table) - Headless table library
|
|
235
|
+
- [shadcn/ui](https://ui.shadcn.com/) - Beautiful UI components
|
|
236
|
+
- [Tailwind CSS](https://tailwindcss.com/) - Utility-first CSS framework
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ColumnDef } from '@tanstack/react-table';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
interface ActionItem<TData> {
|
|
4
|
+
label: string;
|
|
5
|
+
icon?: ReactNode;
|
|
6
|
+
onClick?: (row: TData) => void;
|
|
7
|
+
href?: (row: TData) => string;
|
|
8
|
+
variant?: 'default' | 'destructive';
|
|
9
|
+
separator?: boolean;
|
|
10
|
+
hidden?: (row: TData) => boolean;
|
|
11
|
+
disabled?: (row: TData) => boolean;
|
|
12
|
+
}
|
|
13
|
+
export declare class ActionsColumn<TData> {
|
|
14
|
+
private config;
|
|
15
|
+
static make<TData>(): ActionsColumn<TData>;
|
|
16
|
+
label(label: string): this;
|
|
17
|
+
triggerIcon(icon: ReactNode): this;
|
|
18
|
+
action(action: ActionItem<TData>): this;
|
|
19
|
+
view(onClick: (row: TData) => void): this;
|
|
20
|
+
edit(onClick: (row: TData) => void): this;
|
|
21
|
+
delete(onClick: (row: TData) => void): this;
|
|
22
|
+
link(label: string, href: (row: TData) => string): this;
|
|
23
|
+
separator(): this;
|
|
24
|
+
build(): ColumnDef<TData, unknown>;
|
|
25
|
+
}
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { ColumnDef } from "@tanstack/react-table";
|
|
2
|
+
import { BaseColumn } from "./base-column";
|
|
3
|
+
import { BaseColumnConfig } from "./types";
|
|
4
|
+
interface AvatarItem {
|
|
5
|
+
src?: string;
|
|
6
|
+
name: string;
|
|
7
|
+
fallback?: string;
|
|
8
|
+
}
|
|
9
|
+
interface AvatarGroupColumnConfig<TData> extends BaseColumnConfig<TData> {
|
|
10
|
+
maxVisible?: number;
|
|
11
|
+
size?: "xs" | "sm" | "md" | "lg";
|
|
12
|
+
overlap?: "none" | "sm" | "md" | "lg";
|
|
13
|
+
showTooltip?: boolean;
|
|
14
|
+
nameField?: keyof TData | ((row: TData) => AvatarItem[]);
|
|
15
|
+
srcField?: string;
|
|
16
|
+
fallbackField?: string;
|
|
17
|
+
showNames?: boolean;
|
|
18
|
+
maxNames?: number;
|
|
19
|
+
}
|
|
20
|
+
export declare class AvatarGroupColumn<TData> extends BaseColumn<TData, AvatarGroupColumnConfig<TData>> {
|
|
21
|
+
constructor(accessor: keyof TData | string);
|
|
22
|
+
static make<TData>(accessor: keyof TData | string): AvatarGroupColumn<TData>;
|
|
23
|
+
maxVisible(max: number): this;
|
|
24
|
+
size(size: "xs" | "sm" | "md" | "lg"): this;
|
|
25
|
+
overlap(overlap: "none" | "sm" | "md" | "lg"): this;
|
|
26
|
+
noOverlap(): this;
|
|
27
|
+
hideTooltip(): this;
|
|
28
|
+
fields(config: {
|
|
29
|
+
src?: string;
|
|
30
|
+
name: string;
|
|
31
|
+
fallback?: string;
|
|
32
|
+
}): this;
|
|
33
|
+
mapItems(fn: (row: TData) => AvatarItem[]): this;
|
|
34
|
+
showNames(show?: boolean, max?: number): this;
|
|
35
|
+
private toContactItems;
|
|
36
|
+
build(): ColumnDef<TData, unknown>;
|
|
37
|
+
}
|
|
38
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ColumnDef } from "@tanstack/react-table";
|
|
2
|
+
import { ReactNode } from "react";
|
|
3
|
+
import { BaseColumn } from "./base-column";
|
|
4
|
+
import { BadgeColumnConfig } from "./types";
|
|
5
|
+
type BadgeVariant = "default" | "secondary" | "destructive" | "outline" | "success" | "warning" | "info" | "muted";
|
|
6
|
+
interface VariantConfig {
|
|
7
|
+
label?: string;
|
|
8
|
+
variant?: BadgeVariant;
|
|
9
|
+
className?: string;
|
|
10
|
+
icon?: ReactNode;
|
|
11
|
+
}
|
|
12
|
+
export declare class BadgeColumn<TData> extends BaseColumn<TData, BadgeColumnConfig<TData>> {
|
|
13
|
+
static make<TData>(accessor: keyof TData | string): BadgeColumn<TData>;
|
|
14
|
+
variants(variants: Record<string, VariantConfig>): this;
|
|
15
|
+
boolean(trueLabel?: string, falseLabel?: string): this;
|
|
16
|
+
status(statuses: Record<string, {
|
|
17
|
+
label: string;
|
|
18
|
+
color: string;
|
|
19
|
+
}>): this;
|
|
20
|
+
build(): ColumnDef<TData, unknown>;
|
|
21
|
+
}
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ColumnDef } from '@tanstack/react-table';
|
|
2
|
+
import { BaseColumnConfig } from './types';
|
|
3
|
+
export declare abstract class BaseColumn<TData, TConfig extends BaseColumnConfig<TData>> {
|
|
4
|
+
protected config: TConfig;
|
|
5
|
+
constructor(accessor: keyof TData | string);
|
|
6
|
+
label(label: string): this;
|
|
7
|
+
sortable(sortable?: boolean): this;
|
|
8
|
+
searchable(searchable?: boolean): this;
|
|
9
|
+
hidden(hidden?: boolean): this;
|
|
10
|
+
alignLeft(): this;
|
|
11
|
+
alignCenter(): this;
|
|
12
|
+
alignRight(): this;
|
|
13
|
+
width(width: string | number): this;
|
|
14
|
+
className(className: string): this;
|
|
15
|
+
headerClassName(className: string): this;
|
|
16
|
+
cellClassName(className: string): this;
|
|
17
|
+
abstract build(): ColumnDef<TData, unknown>;
|
|
18
|
+
protected getAlignmentClass(): string;
|
|
19
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
interface ButtonColumnConfig {
|
|
2
|
+
accessorKey?: string;
|
|
3
|
+
header?: string;
|
|
4
|
+
label?: string;
|
|
5
|
+
onClick?: (data: any) => void;
|
|
6
|
+
}
|
|
7
|
+
export declare const ButtonColumn: (config: ButtonColumnConfig) => {
|
|
8
|
+
accessorKey: string;
|
|
9
|
+
header: string;
|
|
10
|
+
cell: ({ row }: {
|
|
11
|
+
row: any;
|
|
12
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
};
|
|
14
|
+
export { ButtonColumn as buttonColumn };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ColumnDef } from '@tanstack/react-table';
|
|
2
|
+
import { BaseColumn } from './base-column';
|
|
3
|
+
import { BaseColumnConfig } from './types';
|
|
4
|
+
interface DateColumnConfig<TData> extends BaseColumnConfig<TData> {
|
|
5
|
+
format?: 'short' | 'long' | 'relative' | 'time' | 'datetime' | string;
|
|
6
|
+
locale?: string;
|
|
7
|
+
showIcon?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare class DateColumn<TData> extends BaseColumn<TData, DateColumnConfig<TData>> {
|
|
10
|
+
constructor(accessor: keyof TData | string);
|
|
11
|
+
static make<TData>(accessor: keyof TData | string): DateColumn<TData>;
|
|
12
|
+
format(format: 'short' | 'long' | 'relative' | 'time' | 'datetime'): this;
|
|
13
|
+
locale(locale: string): this;
|
|
14
|
+
withIcon(show?: boolean): this;
|
|
15
|
+
short(): this;
|
|
16
|
+
long(): this;
|
|
17
|
+
relative(): this;
|
|
18
|
+
time(): this;
|
|
19
|
+
datetime(): this;
|
|
20
|
+
private formatDate;
|
|
21
|
+
private getRelativeTime;
|
|
22
|
+
build(): ColumnDef<TData, unknown>;
|
|
23
|
+
}
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
interface DropdownOption {
|
|
2
|
+
label: string;
|
|
3
|
+
onClick?: (data: any) => void;
|
|
4
|
+
}
|
|
5
|
+
interface DropdownColumnConfig {
|
|
6
|
+
accessorKey?: string;
|
|
7
|
+
header?: string;
|
|
8
|
+
options: DropdownOption[];
|
|
9
|
+
}
|
|
10
|
+
export declare const DropdownColumn: (config: DropdownColumnConfig) => {
|
|
11
|
+
accessorKey: string;
|
|
12
|
+
header: string;
|
|
13
|
+
cell: ({ row }: {
|
|
14
|
+
row: any;
|
|
15
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
};
|
|
17
|
+
export { DropdownColumn as dropdownColumn };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { ColumnDef } from '@tanstack/react-table';
|
|
2
|
+
import { LucideIcon } from 'lucide-react';
|
|
3
|
+
import { ReactNode } from 'react';
|
|
4
|
+
import { BaseColumn } from './base-column';
|
|
5
|
+
import { BaseColumnConfig } from './types';
|
|
6
|
+
interface IconState {
|
|
7
|
+
icon: ReactNode | LucideIcon;
|
|
8
|
+
label?: string;
|
|
9
|
+
color?: string;
|
|
10
|
+
bgColor?: string;
|
|
11
|
+
tooltip?: string;
|
|
12
|
+
}
|
|
13
|
+
interface IconColumnConfig<TData> extends BaseColumnConfig<TData> {
|
|
14
|
+
states?: Record<string, IconState>;
|
|
15
|
+
size?: 'xs' | 'sm' | 'md' | 'lg';
|
|
16
|
+
showLabel?: boolean;
|
|
17
|
+
showTooltip?: boolean;
|
|
18
|
+
withBackground?: boolean;
|
|
19
|
+
defaultIcon?: ReactNode;
|
|
20
|
+
defaultLabel?: string;
|
|
21
|
+
}
|
|
22
|
+
export declare class IconColumn<TData> extends BaseColumn<TData, IconColumnConfig<TData>> {
|
|
23
|
+
constructor(accessor: keyof TData | string);
|
|
24
|
+
static make<TData>(accessor: keyof TData | string): IconColumn<TData>;
|
|
25
|
+
state(value: string, config: IconState): this;
|
|
26
|
+
states(states: Record<string, IconState>): this;
|
|
27
|
+
size(size: 'xs' | 'sm' | 'md' | 'lg'): this;
|
|
28
|
+
showLabel(show?: boolean): this;
|
|
29
|
+
hideTooltip(): this;
|
|
30
|
+
withBackground(show?: boolean): this;
|
|
31
|
+
default(icon: ReactNode, label?: string): this;
|
|
32
|
+
boolean(config?: {
|
|
33
|
+
trueIcon?: ReactNode;
|
|
34
|
+
falseIcon?: ReactNode;
|
|
35
|
+
trueLabel?: string;
|
|
36
|
+
falseLabel?: string;
|
|
37
|
+
trueColor?: string;
|
|
38
|
+
falseColor?: string;
|
|
39
|
+
trueBgColor?: string;
|
|
40
|
+
falseBgColor?: string;
|
|
41
|
+
}): this;
|
|
42
|
+
activeInactive(): this;
|
|
43
|
+
onlineStatus(): this;
|
|
44
|
+
priority(): this;
|
|
45
|
+
verification(): this;
|
|
46
|
+
private createCheckIcon;
|
|
47
|
+
private createXIcon;
|
|
48
|
+
private createCircleIcon;
|
|
49
|
+
private createArrowUpIcon;
|
|
50
|
+
private createArrowDownIcon;
|
|
51
|
+
private createMinusIcon;
|
|
52
|
+
private createAlertIcon;
|
|
53
|
+
private createShieldCheckIcon;
|
|
54
|
+
private createShieldXIcon;
|
|
55
|
+
private createClockIcon;
|
|
56
|
+
build(): ColumnDef<TData, unknown>;
|
|
57
|
+
}
|
|
58
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ColumnDef } from '@tanstack/react-table';
|
|
2
|
+
import { BaseColumn } from './base-column';
|
|
3
|
+
import { BaseColumnConfig } from './types';
|
|
4
|
+
interface ImageColumnConfig<TData> extends BaseColumnConfig<TData> {
|
|
5
|
+
size?: 'sm' | 'md' | 'lg';
|
|
6
|
+
rounded?: 'none' | 'sm' | 'md' | 'lg' | 'full';
|
|
7
|
+
fallback?: string;
|
|
8
|
+
alt?: (row: TData) => string;
|
|
9
|
+
}
|
|
10
|
+
export declare class ImageColumn<TData> extends BaseColumn<TData, ImageColumnConfig<TData>> {
|
|
11
|
+
constructor(accessor: keyof TData | string);
|
|
12
|
+
static make<TData>(accessor: keyof TData | string): ImageColumn<TData>;
|
|
13
|
+
size(size: 'sm' | 'md' | 'lg'): this;
|
|
14
|
+
rounded(rounded: 'none' | 'sm' | 'md' | 'lg' | 'full'): this;
|
|
15
|
+
circular(): this;
|
|
16
|
+
square(): this;
|
|
17
|
+
fallback(url: string): this;
|
|
18
|
+
alt(fn: (row: TData) => string): this;
|
|
19
|
+
build(): ColumnDef<TData, unknown>;
|
|
20
|
+
}
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export { TableSchema } from "../schema";
|
|
2
|
+
export { ActionsColumn } from "./actions-column";
|
|
3
|
+
export { AvatarGroupColumn } from "./avatar-group-column";
|
|
4
|
+
export { BadgeColumn } from "./badge-column";
|
|
5
|
+
export { CheckboxColumn } from "./checkbox-column";
|
|
6
|
+
export { DateColumn } from "./date-column";
|
|
7
|
+
export { IconColumn } from "./icon-column";
|
|
8
|
+
export { ImageColumn } from "./image-column";
|
|
9
|
+
export { LinkColumn } from "./link-column";
|
|
10
|
+
export { NumberColumn } from "./number-column";
|
|
11
|
+
export { ProgressColumn } from "./progress-column";
|
|
12
|
+
export { TextColumn } from "./text-column";
|
|
13
|
+
export type { ActionConfig, BadgeColumnConfig, BaseColumnConfig, FormattedColumnConfig, } from "./types";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
interface InputColumnConfig {
|
|
2
|
+
accessorKey?: string;
|
|
3
|
+
header?: string;
|
|
4
|
+
placeholder?: string;
|
|
5
|
+
onChange?: (data: any, value: string) => void;
|
|
6
|
+
}
|
|
7
|
+
export declare const InputColumn: (config: InputColumnConfig) => {
|
|
8
|
+
accessorKey: string;
|
|
9
|
+
header: string;
|
|
10
|
+
cell: ({ row }: {
|
|
11
|
+
row: any;
|
|
12
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
};
|
|
14
|
+
export { InputColumn as inputColumn };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ColumnDef } from '@tanstack/react-table';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { BaseColumn } from './base-column';
|
|
4
|
+
import { BaseColumnConfig } from './types';
|
|
5
|
+
interface LinkColumnConfig<TData> extends BaseColumnConfig<TData> {
|
|
6
|
+
href?: string | ((row: TData) => string);
|
|
7
|
+
external?: boolean;
|
|
8
|
+
icon?: ReactNode;
|
|
9
|
+
showExternalIcon?: boolean;
|
|
10
|
+
underline?: 'always' | 'hover' | 'never';
|
|
11
|
+
openInNewTab?: boolean;
|
|
12
|
+
onClick?: (row: TData) => void;
|
|
13
|
+
}
|
|
14
|
+
export declare class LinkColumn<TData> extends BaseColumn<TData, LinkColumnConfig<TData>> {
|
|
15
|
+
constructor(accessor: keyof TData | string);
|
|
16
|
+
static make<TData>(accessor: keyof TData | string): LinkColumn<TData>;
|
|
17
|
+
href(href: string | ((row: TData) => string)): this;
|
|
18
|
+
urlFromField(field: keyof TData): this;
|
|
19
|
+
external(external?: boolean): this;
|
|
20
|
+
icon(icon: ReactNode): this;
|
|
21
|
+
showExternalIcon(show?: boolean): this;
|
|
22
|
+
underline(style: 'always' | 'hover' | 'never'): this;
|
|
23
|
+
openInNewTab(open?: boolean): this;
|
|
24
|
+
onClick(handler: (row: TData) => void): this;
|
|
25
|
+
build(): ColumnDef<TData, unknown>;
|
|
26
|
+
}
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ColumnDef } from '@tanstack/react-table';
|
|
2
|
+
import { BaseColumn } from './base-column';
|
|
3
|
+
import { BaseColumnConfig } from './types';
|
|
4
|
+
interface NumberColumnConfig<TData> extends BaseColumnConfig<TData> {
|
|
5
|
+
decimals?: number;
|
|
6
|
+
locale?: string;
|
|
7
|
+
currency?: string;
|
|
8
|
+
percent?: boolean;
|
|
9
|
+
prefix?: string;
|
|
10
|
+
suffix?: string;
|
|
11
|
+
}
|
|
12
|
+
export declare class NumberColumn<TData> extends BaseColumn<TData, NumberColumnConfig<TData>> {
|
|
13
|
+
constructor(accessor: keyof TData | string);
|
|
14
|
+
static make<TData>(accessor: keyof TData | string): NumberColumn<TData>;
|
|
15
|
+
decimals(decimals: number): this;
|
|
16
|
+
locale(locale: string): this;
|
|
17
|
+
money(currency?: string): this;
|
|
18
|
+
percent(): this;
|
|
19
|
+
prefix(prefix: string): this;
|
|
20
|
+
suffix(suffix: string): this;
|
|
21
|
+
build(): ColumnDef<TData, unknown>;
|
|
22
|
+
}
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ColumnDef } from '@tanstack/react-table';
|
|
2
|
+
import { BaseColumn } from './base-column';
|
|
3
|
+
import { BaseColumnConfig } from './types';
|
|
4
|
+
interface ProgressColumnConfig<TData> extends BaseColumnConfig<TData> {
|
|
5
|
+
max?: number;
|
|
6
|
+
showValue?: boolean;
|
|
7
|
+
showPercentage?: boolean;
|
|
8
|
+
size?: 'sm' | 'md' | 'lg';
|
|
9
|
+
color?: 'default' | 'success' | 'warning' | 'danger' | ((value: number, max: number) => string);
|
|
10
|
+
thresholds?: {
|
|
11
|
+
warning?: number;
|
|
12
|
+
danger?: number;
|
|
13
|
+
};
|
|
14
|
+
format?: (value: number, max: number) => string;
|
|
15
|
+
}
|
|
16
|
+
export declare class ProgressColumn<TData> extends BaseColumn<TData, ProgressColumnConfig<TData>> {
|
|
17
|
+
constructor(accessor: keyof TData | string);
|
|
18
|
+
static make<TData>(accessor: keyof TData | string): ProgressColumn<TData>;
|
|
19
|
+
max(max: number): this;
|
|
20
|
+
showValue(show?: boolean): this;
|
|
21
|
+
showPercentage(show?: boolean): this;
|
|
22
|
+
hideLabel(): this;
|
|
23
|
+
size(size: 'sm' | 'md' | 'lg'): this;
|
|
24
|
+
color(color: 'default' | 'success' | 'warning' | 'danger'): this;
|
|
25
|
+
colorByThreshold(warning?: number, danger?: number): this;
|
|
26
|
+
colorByThresholdInverse(warning?: number, danger?: number): this;
|
|
27
|
+
format(fn: (value: number, max: number) => string): this;
|
|
28
|
+
build(): ColumnDef<TData, unknown>;
|
|
29
|
+
}
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
interface SelectOption {
|
|
2
|
+
label: string;
|
|
3
|
+
value: string;
|
|
4
|
+
}
|
|
5
|
+
interface SelectColumnConfig {
|
|
6
|
+
accessorKey?: string;
|
|
7
|
+
header?: string;
|
|
8
|
+
placeholder?: string;
|
|
9
|
+
options: SelectOption[];
|
|
10
|
+
onChange?: (data: any, value: string) => void;
|
|
11
|
+
}
|
|
12
|
+
export declare const SelectColumn: (config: SelectColumnConfig) => {
|
|
13
|
+
accessorKey: string;
|
|
14
|
+
header: string;
|
|
15
|
+
cell: ({ row }: {
|
|
16
|
+
row: any;
|
|
17
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
};
|
|
19
|
+
export { SelectColumn as selectColumn };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ColumnDef, Row } from '@tanstack/react-table';
|
|
2
|
+
import { BaseColumn } from './base-column';
|
|
3
|
+
import { FormattedColumnConfig } from './types';
|
|
4
|
+
export declare class TextColumn<TData> extends BaseColumn<TData, FormattedColumnConfig<TData>> {
|
|
5
|
+
static make<TData>(accessor: keyof TData | string): TextColumn<TData>;
|
|
6
|
+
formatter(fn: (value: unknown, row: Row<TData>) => React.ReactNode): this;
|
|
7
|
+
prefix(prefix: string): this;
|
|
8
|
+
suffix(suffix: string): this;
|
|
9
|
+
placeholder(placeholder: string): this;
|
|
10
|
+
uppercase(): this;
|
|
11
|
+
lowercase(): this;
|
|
12
|
+
limit(chars: number): this;
|
|
13
|
+
build(): ColumnDef<TData, unknown>;
|
|
14
|
+
}
|