@nccirtu/tablefy 0.6.2 → 0.6.4
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 +34 -0
- package/cli/templates/tablefy/data-table-empty.tsx +0 -1
- package/cli/templates/tablefy/data-table-header.tsx +0 -1
- package/cli/templates/tablefy/data-table-pagination.tsx +0 -1
- package/dist/builders/empty-state.d.ts +46 -0
- package/dist/builders/index.d.ts +2 -0
- package/dist/builders/table-schema.d.ts +84 -0
- package/dist/columns/actions-column.d.ts +3 -3
- package/dist/columns/base-column.d.ts +2 -2
- package/dist/columns/builders/empty-state.d.ts +46 -0
- package/dist/columns/builders/index.d.ts +2 -0
- package/dist/columns/builders/table-schema.d.ts +84 -0
- package/dist/columns/checkbox-column.d.ts +1 -1
- package/dist/columns/columns/actions-column.d.ts +3 -3
- package/dist/columns/columns/base-column.d.ts +2 -2
- package/dist/columns/columns/checkbox-column.d.ts +1 -1
- package/dist/columns/columns/date-column.d.ts +5 -5
- package/dist/columns/columns/icon-column.d.ts +7 -7
- package/dist/columns/columns/image-column.d.ts +7 -7
- package/dist/columns/columns/link-column.d.ts +6 -6
- package/dist/columns/columns/number-column.d.ts +3 -3
- package/dist/columns/columns/progress-column.d.ts +7 -7
- package/dist/columns/columns/text-column.d.ts +3 -3
- package/dist/columns/columns/types.d.ts +5 -5
- package/dist/columns/date-column.d.ts +5 -5
- package/dist/columns/icon-column.d.ts +7 -7
- package/dist/columns/image-column.d.ts +7 -7
- package/dist/columns/index.d.ts +2 -2
- package/dist/columns/index.esm.js +189 -167
- package/dist/columns/index.esm.js.map +1 -1
- package/dist/columns/index.js +189 -167
- package/dist/columns/index.js.map +1 -1
- package/dist/columns/link-column.d.ts +6 -6
- package/dist/columns/number-column.d.ts +3 -3
- package/dist/columns/progress-column.d.ts +7 -7
- package/dist/columns/tablefy/data-table-empty.d.ts +1 -1
- package/dist/columns/tablefy/data-table-header.d.ts +1 -1
- package/dist/columns/tablefy/data-table-pagination.d.ts +1 -1
- package/dist/columns/tablefy/data-table.d.ts +1 -1
- package/dist/columns/text-column.d.ts +3 -3
- package/dist/columns/types/actions.d.ts +20 -0
- package/dist/columns/types/empty-state.d.ts +18 -0
- package/dist/columns/types/filters.d.ts +25 -0
- package/dist/columns/types/index.d.ts +4 -0
- package/dist/columns/types/table.d.ts +41 -0
- package/dist/columns/types.d.ts +5 -5
- package/dist/columns/utils.d.ts +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.esm.js +189 -167
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +189 -167
- package/dist/index.js.map +1 -1
- package/dist/tablefy/data-table-empty.d.ts +1 -1
- package/dist/tablefy/data-table-header.d.ts +1 -1
- package/dist/tablefy/data-table-pagination.d.ts +1 -1
- package/dist/tablefy/data-table.d.ts +1 -1
- package/dist/types/actions.d.ts +20 -0
- package/dist/types/empty-state.d.ts +18 -0
- package/dist/types/filters.d.ts +25 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/table.d.ts +41 -0
- package/dist/utils.d.ts +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -22,6 +22,40 @@ npm install @nccirtu/tablefy
|
|
|
22
22
|
|
|
23
23
|
**⚠️ Important:** Tablefy requires additional setup steps to work correctly.
|
|
24
24
|
|
|
25
|
+
### Two Ways to Use Tablefy
|
|
26
|
+
|
|
27
|
+
Tablefy offers **two approaches** to fit your workflow:
|
|
28
|
+
|
|
29
|
+
#### 🚀 **Quick Start (Direct Import)**
|
|
30
|
+
|
|
31
|
+
Import components directly from the package - perfect for getting started quickly:
|
|
32
|
+
|
|
33
|
+
```tsx
|
|
34
|
+
import { DataTable, TableSchema, TextColumn } from "@nccirtu/tablefy";
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
✅ **Pros:** Zero setup, works immediately after installation
|
|
38
|
+
❌ **Cons:** Limited customization of internal components
|
|
39
|
+
|
|
40
|
+
#### 🛠️ **Full Control (CLI Installation)**
|
|
41
|
+
|
|
42
|
+
Copy components to your project for complete customization:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
npx tablefy init
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
This copies all components to your `components/tablefy/` directory, allowing you to:
|
|
49
|
+
|
|
50
|
+
- Customize styles and behavior
|
|
51
|
+
- Modify internal components
|
|
52
|
+
- Full control over the code
|
|
53
|
+
|
|
54
|
+
✅ **Pros:** Complete customization freedom
|
|
55
|
+
❌ **Cons:** Requires CLI setup step
|
|
56
|
+
|
|
57
|
+
**Choose the approach that fits your needs!** Most users start with direct imports and switch to CLI installation when they need customization.
|
|
58
|
+
|
|
25
59
|
### What you need to install
|
|
26
60
|
|
|
27
61
|
1. **Peer dependencies** (required libraries)
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { EmptyStateConfig } from "../types/empty-state";
|
|
2
|
+
import React from "react";
|
|
3
|
+
/**
|
|
4
|
+
* Empty State Builder
|
|
5
|
+
* Fluent API for building empty state configurations
|
|
6
|
+
*/
|
|
7
|
+
export declare class EmptyStateBuilder {
|
|
8
|
+
private config;
|
|
9
|
+
static make(): EmptyStateBuilder;
|
|
10
|
+
title(title: string): this;
|
|
11
|
+
description(description: string): this;
|
|
12
|
+
icon(icon: React.ReactNode): this;
|
|
13
|
+
imageUrl(imageUrl: string): this;
|
|
14
|
+
action(label: string, onClick?: () => void, href?: string, icon?: React.ReactNode): this;
|
|
15
|
+
variant(variant: "default" | "search" | "filter" | "error" | "custom"): this;
|
|
16
|
+
error(params?: {
|
|
17
|
+
onRetry?: () => void;
|
|
18
|
+
}): this;
|
|
19
|
+
noSearchResults(params?: {
|
|
20
|
+
onClear?: () => void;
|
|
21
|
+
}): this;
|
|
22
|
+
noFilterResults(params?: {
|
|
23
|
+
onReset?: () => void;
|
|
24
|
+
}): this;
|
|
25
|
+
noData(): this;
|
|
26
|
+
build(): EmptyStateConfig;
|
|
27
|
+
static noData(config: {
|
|
28
|
+
title: string;
|
|
29
|
+
description: string;
|
|
30
|
+
createLabel?: string;
|
|
31
|
+
createHref?: string;
|
|
32
|
+
createOnClick?: () => void;
|
|
33
|
+
}): EmptyStateConfig;
|
|
34
|
+
static noSearchResults(config: {
|
|
35
|
+
title: string;
|
|
36
|
+
description: string;
|
|
37
|
+
clearLabel?: string;
|
|
38
|
+
onClear?: () => void;
|
|
39
|
+
}): EmptyStateConfig;
|
|
40
|
+
static noFilterResults(config: {
|
|
41
|
+
title: string;
|
|
42
|
+
description: string;
|
|
43
|
+
resetLabel?: string;
|
|
44
|
+
onReset?: () => void;
|
|
45
|
+
}): EmptyStateConfig;
|
|
46
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { ColumnDef } from "@tanstack/react-table";
|
|
2
|
+
import { DataTableConfig } from "../types/table";
|
|
3
|
+
import { HeaderAction } from "../types/actions";
|
|
4
|
+
import { EmptyStateConfig } from "../types/empty-state";
|
|
5
|
+
import React from "react";
|
|
6
|
+
type ColumnBuilder<TData> = {
|
|
7
|
+
build(): ColumnDef<TData, unknown>;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Header Actions Builder
|
|
11
|
+
* Fluent API for building header actions
|
|
12
|
+
*/
|
|
13
|
+
declare class HeaderActionsBuilder<TData> {
|
|
14
|
+
private actions;
|
|
15
|
+
create(config: {
|
|
16
|
+
label: string;
|
|
17
|
+
href?: string;
|
|
18
|
+
onClick?: () => void;
|
|
19
|
+
icon?: React.ReactNode;
|
|
20
|
+
}): this;
|
|
21
|
+
export(config: {
|
|
22
|
+
label: string;
|
|
23
|
+
icon?: React.ReactNode;
|
|
24
|
+
formats?: Array<{
|
|
25
|
+
label: string;
|
|
26
|
+
onClick: () => void;
|
|
27
|
+
}>;
|
|
28
|
+
}): this;
|
|
29
|
+
import(config: {
|
|
30
|
+
label: string;
|
|
31
|
+
icon?: React.ReactNode;
|
|
32
|
+
onClick?: () => void;
|
|
33
|
+
}): this;
|
|
34
|
+
bulkExport(config: {
|
|
35
|
+
label: string;
|
|
36
|
+
icon?: React.ReactNode;
|
|
37
|
+
onExport: (rows: TData[]) => void;
|
|
38
|
+
}): this;
|
|
39
|
+
bulkDelete(config: {
|
|
40
|
+
label: string;
|
|
41
|
+
icon?: React.ReactNode;
|
|
42
|
+
onDelete: (rows: TData[]) => void;
|
|
43
|
+
}): this;
|
|
44
|
+
custom(action: HeaderAction<TData>): this;
|
|
45
|
+
build(): HeaderAction<TData>[];
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Table Schema Builder
|
|
49
|
+
* Fluent API for building complete table configurations
|
|
50
|
+
*/
|
|
51
|
+
export declare class TableSchema<TData> {
|
|
52
|
+
private columnBuilders;
|
|
53
|
+
private config;
|
|
54
|
+
static make<TData>(): TableSchema<TData>;
|
|
55
|
+
description(text: string): this;
|
|
56
|
+
title(text: string): this;
|
|
57
|
+
headerActions(builder: (b: HeaderActionsBuilder<TData>) => HeaderActionsBuilder<TData>): this;
|
|
58
|
+
emptyState(config: EmptyStateConfig): this;
|
|
59
|
+
searchEmptyState(config: EmptyStateConfig): this;
|
|
60
|
+
filterEmptyState(config: EmptyStateConfig): this;
|
|
61
|
+
searchable(config?: {
|
|
62
|
+
placeholder?: string;
|
|
63
|
+
} | boolean): this;
|
|
64
|
+
paginated(config?: {
|
|
65
|
+
pageSize?: number;
|
|
66
|
+
pageSizeOptions?: number[];
|
|
67
|
+
} | boolean): this;
|
|
68
|
+
selectable(multiSelect?: boolean): this;
|
|
69
|
+
sortable(defaultSort?: {
|
|
70
|
+
id: string;
|
|
71
|
+
desc: boolean;
|
|
72
|
+
}): this;
|
|
73
|
+
columnVisibility(enabled?: boolean): this;
|
|
74
|
+
bordered(enabled?: boolean): this;
|
|
75
|
+
striped(enabled?: boolean): this;
|
|
76
|
+
hoverable(enabled?: boolean): this;
|
|
77
|
+
density(density: "compact" | "default" | "comfortable"): this;
|
|
78
|
+
columns(...builders: ColumnBuilder<TData>[]): this;
|
|
79
|
+
build(): {
|
|
80
|
+
columns: ColumnDef<TData, unknown>[];
|
|
81
|
+
config: DataTableConfig<TData>;
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
export {};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { ColumnDef } from
|
|
2
|
-
import { ReactNode } from
|
|
1
|
+
import { ColumnDef } from "@tanstack/react-table";
|
|
2
|
+
import { ReactNode } from "react";
|
|
3
3
|
interface ActionItem<TData> {
|
|
4
4
|
label: string;
|
|
5
5
|
icon?: ReactNode;
|
|
6
6
|
onClick?: (row: TData) => void;
|
|
7
7
|
href?: (row: TData) => string;
|
|
8
|
-
variant?:
|
|
8
|
+
variant?: "default" | "destructive";
|
|
9
9
|
separator?: boolean;
|
|
10
10
|
hidden?: (row: TData) => boolean;
|
|
11
11
|
disabled?: (row: TData) => boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ColumnDef } from
|
|
2
|
-
import { BaseColumnConfig } from
|
|
1
|
+
import { ColumnDef } from "@tanstack/react-table";
|
|
2
|
+
import { BaseColumnConfig } from "./types";
|
|
3
3
|
export declare abstract class BaseColumn<TData, TConfig extends BaseColumnConfig<TData>> {
|
|
4
4
|
protected config: TConfig;
|
|
5
5
|
constructor(accessor: keyof TData | string);
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { EmptyStateConfig } from "../types/empty-state";
|
|
2
|
+
import React from "react";
|
|
3
|
+
/**
|
|
4
|
+
* Empty State Builder
|
|
5
|
+
* Fluent API for building empty state configurations
|
|
6
|
+
*/
|
|
7
|
+
export declare class EmptyStateBuilder {
|
|
8
|
+
private config;
|
|
9
|
+
static make(): EmptyStateBuilder;
|
|
10
|
+
title(title: string): this;
|
|
11
|
+
description(description: string): this;
|
|
12
|
+
icon(icon: React.ReactNode): this;
|
|
13
|
+
imageUrl(imageUrl: string): this;
|
|
14
|
+
action(label: string, onClick?: () => void, href?: string, icon?: React.ReactNode): this;
|
|
15
|
+
variant(variant: "default" | "search" | "filter" | "error" | "custom"): this;
|
|
16
|
+
error(params?: {
|
|
17
|
+
onRetry?: () => void;
|
|
18
|
+
}): this;
|
|
19
|
+
noSearchResults(params?: {
|
|
20
|
+
onClear?: () => void;
|
|
21
|
+
}): this;
|
|
22
|
+
noFilterResults(params?: {
|
|
23
|
+
onReset?: () => void;
|
|
24
|
+
}): this;
|
|
25
|
+
noData(): this;
|
|
26
|
+
build(): EmptyStateConfig;
|
|
27
|
+
static noData(config: {
|
|
28
|
+
title: string;
|
|
29
|
+
description: string;
|
|
30
|
+
createLabel?: string;
|
|
31
|
+
createHref?: string;
|
|
32
|
+
createOnClick?: () => void;
|
|
33
|
+
}): EmptyStateConfig;
|
|
34
|
+
static noSearchResults(config: {
|
|
35
|
+
title: string;
|
|
36
|
+
description: string;
|
|
37
|
+
clearLabel?: string;
|
|
38
|
+
onClear?: () => void;
|
|
39
|
+
}): EmptyStateConfig;
|
|
40
|
+
static noFilterResults(config: {
|
|
41
|
+
title: string;
|
|
42
|
+
description: string;
|
|
43
|
+
resetLabel?: string;
|
|
44
|
+
onReset?: () => void;
|
|
45
|
+
}): EmptyStateConfig;
|
|
46
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { ColumnDef } from "@tanstack/react-table";
|
|
2
|
+
import { DataTableConfig } from "../types/table";
|
|
3
|
+
import { HeaderAction } from "../types/actions";
|
|
4
|
+
import { EmptyStateConfig } from "../types/empty-state";
|
|
5
|
+
import React from "react";
|
|
6
|
+
type ColumnBuilder<TData> = {
|
|
7
|
+
build(): ColumnDef<TData, unknown>;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Header Actions Builder
|
|
11
|
+
* Fluent API for building header actions
|
|
12
|
+
*/
|
|
13
|
+
declare class HeaderActionsBuilder<TData> {
|
|
14
|
+
private actions;
|
|
15
|
+
create(config: {
|
|
16
|
+
label: string;
|
|
17
|
+
href?: string;
|
|
18
|
+
onClick?: () => void;
|
|
19
|
+
icon?: React.ReactNode;
|
|
20
|
+
}): this;
|
|
21
|
+
export(config: {
|
|
22
|
+
label: string;
|
|
23
|
+
icon?: React.ReactNode;
|
|
24
|
+
formats?: Array<{
|
|
25
|
+
label: string;
|
|
26
|
+
onClick: () => void;
|
|
27
|
+
}>;
|
|
28
|
+
}): this;
|
|
29
|
+
import(config: {
|
|
30
|
+
label: string;
|
|
31
|
+
icon?: React.ReactNode;
|
|
32
|
+
onClick?: () => void;
|
|
33
|
+
}): this;
|
|
34
|
+
bulkExport(config: {
|
|
35
|
+
label: string;
|
|
36
|
+
icon?: React.ReactNode;
|
|
37
|
+
onExport: (rows: TData[]) => void;
|
|
38
|
+
}): this;
|
|
39
|
+
bulkDelete(config: {
|
|
40
|
+
label: string;
|
|
41
|
+
icon?: React.ReactNode;
|
|
42
|
+
onDelete: (rows: TData[]) => void;
|
|
43
|
+
}): this;
|
|
44
|
+
custom(action: HeaderAction<TData>): this;
|
|
45
|
+
build(): HeaderAction<TData>[];
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Table Schema Builder
|
|
49
|
+
* Fluent API for building complete table configurations
|
|
50
|
+
*/
|
|
51
|
+
export declare class TableSchema<TData> {
|
|
52
|
+
private columnBuilders;
|
|
53
|
+
private config;
|
|
54
|
+
static make<TData>(): TableSchema<TData>;
|
|
55
|
+
description(text: string): this;
|
|
56
|
+
title(text: string): this;
|
|
57
|
+
headerActions(builder: (b: HeaderActionsBuilder<TData>) => HeaderActionsBuilder<TData>): this;
|
|
58
|
+
emptyState(config: EmptyStateConfig): this;
|
|
59
|
+
searchEmptyState(config: EmptyStateConfig): this;
|
|
60
|
+
filterEmptyState(config: EmptyStateConfig): this;
|
|
61
|
+
searchable(config?: {
|
|
62
|
+
placeholder?: string;
|
|
63
|
+
} | boolean): this;
|
|
64
|
+
paginated(config?: {
|
|
65
|
+
pageSize?: number;
|
|
66
|
+
pageSizeOptions?: number[];
|
|
67
|
+
} | boolean): this;
|
|
68
|
+
selectable(multiSelect?: boolean): this;
|
|
69
|
+
sortable(defaultSort?: {
|
|
70
|
+
id: string;
|
|
71
|
+
desc: boolean;
|
|
72
|
+
}): this;
|
|
73
|
+
columnVisibility(enabled?: boolean): this;
|
|
74
|
+
bordered(enabled?: boolean): this;
|
|
75
|
+
striped(enabled?: boolean): this;
|
|
76
|
+
hoverable(enabled?: boolean): this;
|
|
77
|
+
density(density: "compact" | "default" | "comfortable"): this;
|
|
78
|
+
columns(...builders: ColumnBuilder<TData>[]): this;
|
|
79
|
+
build(): {
|
|
80
|
+
columns: ColumnDef<TData, unknown>[];
|
|
81
|
+
config: DataTableConfig<TData>;
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
export {};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { ColumnDef } from
|
|
2
|
-
import { ReactNode } from
|
|
1
|
+
import { ColumnDef } from "@tanstack/react-table";
|
|
2
|
+
import { ReactNode } from "react";
|
|
3
3
|
interface ActionItem<TData> {
|
|
4
4
|
label: string;
|
|
5
5
|
icon?: ReactNode;
|
|
6
6
|
onClick?: (row: TData) => void;
|
|
7
7
|
href?: (row: TData) => string;
|
|
8
|
-
variant?:
|
|
8
|
+
variant?: "default" | "destructive";
|
|
9
9
|
separator?: boolean;
|
|
10
10
|
hidden?: (row: TData) => boolean;
|
|
11
11
|
disabled?: (row: TData) => boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ColumnDef } from
|
|
2
|
-
import { BaseColumnConfig } from
|
|
1
|
+
import { ColumnDef } from "@tanstack/react-table";
|
|
2
|
+
import { BaseColumnConfig } from "./types";
|
|
3
3
|
export declare abstract class BaseColumn<TData, TConfig extends BaseColumnConfig<TData>> {
|
|
4
4
|
protected config: TConfig;
|
|
5
5
|
constructor(accessor: keyof TData | string);
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { ColumnDef } from
|
|
2
|
-
import { BaseColumn } from
|
|
3
|
-
import { BaseColumnConfig } from
|
|
1
|
+
import { ColumnDef } from "@tanstack/react-table";
|
|
2
|
+
import { BaseColumn } from "./base-column";
|
|
3
|
+
import { BaseColumnConfig } from "./types";
|
|
4
4
|
interface DateColumnConfig<TData> extends BaseColumnConfig<TData> {
|
|
5
|
-
format?:
|
|
5
|
+
format?: "short" | "long" | "relative" | "time" | "datetime" | string;
|
|
6
6
|
locale?: string;
|
|
7
7
|
showIcon?: boolean;
|
|
8
8
|
}
|
|
9
9
|
export declare class DateColumn<TData> extends BaseColumn<TData, DateColumnConfig<TData>> {
|
|
10
10
|
constructor(accessor: keyof TData | string);
|
|
11
11
|
static make<TData>(accessor: keyof TData | string): DateColumn<TData>;
|
|
12
|
-
format(format:
|
|
12
|
+
format(format: "short" | "long" | "relative" | "time" | "datetime"): this;
|
|
13
13
|
locale(locale: string): this;
|
|
14
14
|
withIcon(show?: boolean): this;
|
|
15
15
|
short(): this;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { ColumnDef } from
|
|
2
|
-
import { LucideIcon } from
|
|
3
|
-
import { ReactNode } from
|
|
4
|
-
import { BaseColumn } from
|
|
5
|
-
import { BaseColumnConfig } from
|
|
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
6
|
interface IconState {
|
|
7
7
|
icon: ReactNode | LucideIcon;
|
|
8
8
|
label?: string;
|
|
@@ -12,7 +12,7 @@ interface IconState {
|
|
|
12
12
|
}
|
|
13
13
|
interface IconColumnConfig<TData> extends BaseColumnConfig<TData> {
|
|
14
14
|
states?: Record<string, IconState>;
|
|
15
|
-
size?:
|
|
15
|
+
size?: "xs" | "sm" | "md" | "lg";
|
|
16
16
|
showLabel?: boolean;
|
|
17
17
|
showTooltip?: boolean;
|
|
18
18
|
withBackground?: boolean;
|
|
@@ -24,7 +24,7 @@ export declare class IconColumn<TData> extends BaseColumn<TData, IconColumnConfi
|
|
|
24
24
|
static make<TData>(accessor: keyof TData | string): IconColumn<TData>;
|
|
25
25
|
state(value: string, config: IconState): this;
|
|
26
26
|
states(states: Record<string, IconState>): this;
|
|
27
|
-
size(size:
|
|
27
|
+
size(size: "xs" | "sm" | "md" | "lg"): this;
|
|
28
28
|
showLabel(show?: boolean): this;
|
|
29
29
|
hideTooltip(): this;
|
|
30
30
|
withBackground(show?: boolean): this;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { ColumnDef } from
|
|
2
|
-
import { BaseColumn } from
|
|
3
|
-
import { BaseColumnConfig } from
|
|
1
|
+
import { ColumnDef } from "@tanstack/react-table";
|
|
2
|
+
import { BaseColumn } from "./base-column";
|
|
3
|
+
import { BaseColumnConfig } from "./types";
|
|
4
4
|
interface ImageColumnConfig<TData> extends BaseColumnConfig<TData> {
|
|
5
|
-
size?:
|
|
6
|
-
rounded?:
|
|
5
|
+
size?: "sm" | "md" | "lg";
|
|
6
|
+
rounded?: "none" | "sm" | "md" | "lg" | "full";
|
|
7
7
|
fallback?: string;
|
|
8
8
|
alt?: (row: TData) => string;
|
|
9
9
|
}
|
|
10
10
|
export declare class ImageColumn<TData> extends BaseColumn<TData, ImageColumnConfig<TData>> {
|
|
11
11
|
constructor(accessor: keyof TData | string);
|
|
12
12
|
static make<TData>(accessor: keyof TData | string): ImageColumn<TData>;
|
|
13
|
-
size(size:
|
|
14
|
-
rounded(rounded:
|
|
13
|
+
size(size: "sm" | "md" | "lg"): this;
|
|
14
|
+
rounded(rounded: "none" | "sm" | "md" | "lg" | "full"): this;
|
|
15
15
|
circular(): this;
|
|
16
16
|
square(): this;
|
|
17
17
|
fallback(url: string): this;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { ColumnDef } from
|
|
2
|
-
import { ReactNode } from
|
|
3
|
-
import { BaseColumn } from
|
|
4
|
-
import { BaseColumnConfig } from
|
|
1
|
+
import { ColumnDef } from "@tanstack/react-table";
|
|
2
|
+
import { ReactNode } from "react";
|
|
3
|
+
import { BaseColumn } from "./base-column";
|
|
4
|
+
import { BaseColumnConfig } from "./types";
|
|
5
5
|
interface LinkColumnConfig<TData> extends BaseColumnConfig<TData> {
|
|
6
6
|
href?: string | ((row: TData) => string);
|
|
7
7
|
external?: boolean;
|
|
8
8
|
icon?: ReactNode;
|
|
9
9
|
showExternalIcon?: boolean;
|
|
10
|
-
underline?:
|
|
10
|
+
underline?: "always" | "hover" | "never";
|
|
11
11
|
openInNewTab?: boolean;
|
|
12
12
|
onClick?: (row: TData) => void;
|
|
13
13
|
}
|
|
@@ -19,7 +19,7 @@ export declare class LinkColumn<TData> extends BaseColumn<TData, LinkColumnConfi
|
|
|
19
19
|
external(external?: boolean): this;
|
|
20
20
|
icon(icon: ReactNode): this;
|
|
21
21
|
showExternalIcon(show?: boolean): this;
|
|
22
|
-
underline(style:
|
|
22
|
+
underline(style: "always" | "hover" | "never"): this;
|
|
23
23
|
openInNewTab(open?: boolean): this;
|
|
24
24
|
onClick(handler: (row: TData) => void): this;
|
|
25
25
|
build(): ColumnDef<TData, unknown>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ColumnDef } from
|
|
2
|
-
import { BaseColumn } from
|
|
3
|
-
import { BaseColumnConfig } from
|
|
1
|
+
import { ColumnDef } from "@tanstack/react-table";
|
|
2
|
+
import { BaseColumn } from "./base-column";
|
|
3
|
+
import { BaseColumnConfig } from "./types";
|
|
4
4
|
interface NumberColumnConfig<TData> extends BaseColumnConfig<TData> {
|
|
5
5
|
decimals?: number;
|
|
6
6
|
locale?: string;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { ColumnDef } from
|
|
2
|
-
import { BaseColumn } from
|
|
3
|
-
import { BaseColumnConfig } from
|
|
1
|
+
import { ColumnDef } from "@tanstack/react-table";
|
|
2
|
+
import { BaseColumn } from "./base-column";
|
|
3
|
+
import { BaseColumnConfig } from "./types";
|
|
4
4
|
interface ProgressColumnConfig<TData> extends BaseColumnConfig<TData> {
|
|
5
5
|
max?: number;
|
|
6
6
|
showValue?: boolean;
|
|
7
7
|
showPercentage?: boolean;
|
|
8
|
-
size?:
|
|
9
|
-
color?:
|
|
8
|
+
size?: "sm" | "md" | "lg";
|
|
9
|
+
color?: "default" | "success" | "warning" | "danger" | ((value: number, max: number) => string);
|
|
10
10
|
thresholds?: {
|
|
11
11
|
warning?: number;
|
|
12
12
|
danger?: number;
|
|
@@ -20,8 +20,8 @@ export declare class ProgressColumn<TData> extends BaseColumn<TData, ProgressCol
|
|
|
20
20
|
showValue(show?: boolean): this;
|
|
21
21
|
showPercentage(show?: boolean): this;
|
|
22
22
|
hideLabel(): this;
|
|
23
|
-
size(size:
|
|
24
|
-
color(color:
|
|
23
|
+
size(size: "sm" | "md" | "lg"): this;
|
|
24
|
+
color(color: "default" | "success" | "warning" | "danger"): this;
|
|
25
25
|
colorByThreshold(warning?: number, danger?: number): this;
|
|
26
26
|
colorByThresholdInverse(warning?: number, danger?: number): this;
|
|
27
27
|
format(fn: (value: number, max: number) => string): this;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ColumnDef, Row } from
|
|
2
|
-
import { BaseColumn } from
|
|
3
|
-
import { FormattedColumnConfig } from
|
|
1
|
+
import { ColumnDef, Row } from "@tanstack/react-table";
|
|
2
|
+
import { BaseColumn } from "./base-column";
|
|
3
|
+
import { FormattedColumnConfig } from "./types";
|
|
4
4
|
export declare class TextColumn<TData> extends BaseColumn<TData, FormattedColumnConfig<TData>> {
|
|
5
5
|
static make<TData>(accessor: keyof TData | string): TextColumn<TData>;
|
|
6
6
|
formatter(fn: (value: unknown, row: Row<TData>) => React.ReactNode): this;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { Row } from
|
|
2
|
-
import { ReactNode } from
|
|
1
|
+
import { Row } from "@tanstack/react-table";
|
|
2
|
+
import { ReactNode } from "react";
|
|
3
3
|
export interface BaseColumnConfig<TData> {
|
|
4
4
|
accessor: keyof TData | string;
|
|
5
5
|
label?: string;
|
|
6
6
|
sortable?: boolean;
|
|
7
7
|
searchable?: boolean;
|
|
8
8
|
hidden?: boolean;
|
|
9
|
-
align?:
|
|
9
|
+
align?: "left" | "center" | "right";
|
|
10
10
|
width?: string | number;
|
|
11
11
|
className?: string;
|
|
12
12
|
headerClassName?: string;
|
|
@@ -21,7 +21,7 @@ export interface FormattedColumnConfig<TData> extends BaseColumnConfig<TData> {
|
|
|
21
21
|
export interface BadgeColumnConfig<TData> extends BaseColumnConfig<TData> {
|
|
22
22
|
variants?: Record<string, {
|
|
23
23
|
label?: string;
|
|
24
|
-
variant?:
|
|
24
|
+
variant?: "default" | "secondary" | "destructive" | "outline" | "success" | "warning" | "info" | "muted";
|
|
25
25
|
className?: string;
|
|
26
26
|
icon?: ReactNode;
|
|
27
27
|
}>;
|
|
@@ -31,7 +31,7 @@ export interface ActionConfig<TData> {
|
|
|
31
31
|
icon?: ReactNode;
|
|
32
32
|
onClick?: (row: TData) => void;
|
|
33
33
|
href?: (row: TData) => string;
|
|
34
|
-
variant?:
|
|
34
|
+
variant?: "default" | "destructive" | "ghost";
|
|
35
35
|
hidden?: (row: TData) => boolean;
|
|
36
36
|
disabled?: (row: TData) => boolean;
|
|
37
37
|
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { ColumnDef } from
|
|
2
|
-
import { BaseColumn } from
|
|
3
|
-
import { BaseColumnConfig } from
|
|
1
|
+
import { ColumnDef } from "@tanstack/react-table";
|
|
2
|
+
import { BaseColumn } from "./base-column";
|
|
3
|
+
import { BaseColumnConfig } from "./types";
|
|
4
4
|
interface DateColumnConfig<TData> extends BaseColumnConfig<TData> {
|
|
5
|
-
format?:
|
|
5
|
+
format?: "short" | "long" | "relative" | "time" | "datetime" | string;
|
|
6
6
|
locale?: string;
|
|
7
7
|
showIcon?: boolean;
|
|
8
8
|
}
|
|
9
9
|
export declare class DateColumn<TData> extends BaseColumn<TData, DateColumnConfig<TData>> {
|
|
10
10
|
constructor(accessor: keyof TData | string);
|
|
11
11
|
static make<TData>(accessor: keyof TData | string): DateColumn<TData>;
|
|
12
|
-
format(format:
|
|
12
|
+
format(format: "short" | "long" | "relative" | "time" | "datetime"): this;
|
|
13
13
|
locale(locale: string): this;
|
|
14
14
|
withIcon(show?: boolean): this;
|
|
15
15
|
short(): this;
|