@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
|
@@ -0,0 +1,27 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ColumnDef } from "@tanstack/react-table";
|
|
2
|
+
type ColumnBuilder<TData> = {
|
|
3
|
+
build(): ColumnDef<TData, unknown>;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* Table Schema Builder
|
|
7
|
+
* Fluent API for building table column definitions
|
|
8
|
+
*/
|
|
9
|
+
export declare class TableSchema<TData> {
|
|
10
|
+
private columnBuilders;
|
|
11
|
+
static make<TData>(): TableSchema<TData>;
|
|
12
|
+
columns(...builders: ColumnBuilder<TData>[]): this;
|
|
13
|
+
build(): ColumnDef<TData, unknown>[];
|
|
14
|
+
}
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { EmptyStateConfig } from "../types";
|
|
2
|
+
import React from "react";
|
|
3
|
+
export declare class EmptyStateBuilder {
|
|
4
|
+
private config;
|
|
5
|
+
static make(): EmptyStateBuilder;
|
|
6
|
+
title(title: string): this;
|
|
7
|
+
description(description: string): this;
|
|
8
|
+
icon(icon: React.ReactNode): this;
|
|
9
|
+
imageUrl(imageUrl: string): this;
|
|
10
|
+
action(label: string, onClick?: () => void, href?: string, icon?: React.ReactNode): this;
|
|
11
|
+
variant(variant: "default" | "search" | "filter" | "error" | "custom"): this;
|
|
12
|
+
error(params?: {
|
|
13
|
+
onRetry?: () => void;
|
|
14
|
+
}): this;
|
|
15
|
+
noSearchResults(params?: {
|
|
16
|
+
onClear?: () => void;
|
|
17
|
+
}): this;
|
|
18
|
+
noFilterResults(params?: {
|
|
19
|
+
onReset?: () => void;
|
|
20
|
+
}): this;
|
|
21
|
+
noData(): this;
|
|
22
|
+
build(): EmptyStateConfig;
|
|
23
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
export interface HeaderAction<TData = unknown> {
|
|
3
|
+
id: string;
|
|
4
|
+
label: string;
|
|
5
|
+
icon?: ReactNode;
|
|
6
|
+
variant?: "default" | "secondary" | "outline" | "ghost" | "destructive";
|
|
7
|
+
size?: "default" | "sm" | "lg" | "icon";
|
|
8
|
+
onClick?: () => void;
|
|
9
|
+
href?: string;
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
loading?: boolean;
|
|
12
|
+
bulk?: boolean;
|
|
13
|
+
bulkOnClick?: (selectedRows: TData[]) => void;
|
|
14
|
+
hidden?: boolean;
|
|
15
|
+
children?: Omit<HeaderAction<TData>, "children" | "bulk">[];
|
|
16
|
+
}
|
|
17
|
+
export interface EmptyStateConfig {
|
|
18
|
+
icon?: ReactNode;
|
|
19
|
+
imageUrl?: string;
|
|
20
|
+
title: string;
|
|
21
|
+
description?: string;
|
|
22
|
+
action?: {
|
|
23
|
+
label: string;
|
|
24
|
+
onClick?: () => void;
|
|
25
|
+
href?: string;
|
|
26
|
+
icon?: ReactNode;
|
|
27
|
+
};
|
|
28
|
+
variant?: "default" | "search" | "filter" | "error" | "custom";
|
|
29
|
+
}
|
|
30
|
+
export interface FilterConfig {
|
|
31
|
+
id: string;
|
|
32
|
+
label: string;
|
|
33
|
+
type: "text" | "select" | "multi-select" | "date" | "date-range" | "boolean";
|
|
34
|
+
column: string;
|
|
35
|
+
placeholder?: string;
|
|
36
|
+
options?: Array<{
|
|
37
|
+
label: string;
|
|
38
|
+
value: string;
|
|
39
|
+
}>;
|
|
40
|
+
}
|
|
41
|
+
export interface SearchConfig {
|
|
42
|
+
enabled: boolean;
|
|
43
|
+
placeholder?: string;
|
|
44
|
+
columns?: string[];
|
|
45
|
+
debounce?: number;
|
|
46
|
+
}
|
|
47
|
+
export interface PaginationConfig {
|
|
48
|
+
enabled: boolean;
|
|
49
|
+
pageSize?: number;
|
|
50
|
+
pageSizeOptions?: number[];
|
|
51
|
+
showPageInfo?: boolean;
|
|
52
|
+
showPageSizeSelector?: boolean;
|
|
53
|
+
}
|
|
54
|
+
export interface DataTableConfig<TData> {
|
|
55
|
+
title?: string;
|
|
56
|
+
description?: string;
|
|
57
|
+
headerActions?: HeaderAction<TData>[];
|
|
58
|
+
emptyState?: EmptyStateConfig;
|
|
59
|
+
searchEmptyState?: EmptyStateConfig;
|
|
60
|
+
filterEmptyState?: EmptyStateConfig;
|
|
61
|
+
search?: SearchConfig;
|
|
62
|
+
filters?: FilterConfig[];
|
|
63
|
+
pagination?: PaginationConfig;
|
|
64
|
+
enableRowSelection?: boolean;
|
|
65
|
+
enableMultiRowSelection?: boolean;
|
|
66
|
+
enableSorting?: boolean;
|
|
67
|
+
defaultSort?: {
|
|
68
|
+
id: string;
|
|
69
|
+
desc: boolean;
|
|
70
|
+
};
|
|
71
|
+
enableColumnVisibility?: boolean;
|
|
72
|
+
density?: "compact" | "default" | "comfortable";
|
|
73
|
+
bordered?: boolean;
|
|
74
|
+
striped?: boolean;
|
|
75
|
+
hoverable?: boolean;
|
|
76
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Header Action Configuration
|
|
4
|
+
* Defines actions that can be displayed in the table header
|
|
5
|
+
*/
|
|
6
|
+
export interface HeaderAction<TData = unknown> {
|
|
7
|
+
id: string;
|
|
8
|
+
label: string;
|
|
9
|
+
icon?: ReactNode;
|
|
10
|
+
variant?: "default" | "secondary" | "outline" | "ghost" | "destructive";
|
|
11
|
+
size?: "default" | "sm" | "lg" | "icon";
|
|
12
|
+
onClick?: () => void;
|
|
13
|
+
href?: string;
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
loading?: boolean;
|
|
16
|
+
bulk?: boolean;
|
|
17
|
+
bulkOnClick?: (selectedRows: TData[]) => void;
|
|
18
|
+
hidden?: boolean;
|
|
19
|
+
children?: Omit<HeaderAction<TData>, "children" | "bulk">[];
|
|
20
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Empty State Configuration
|
|
4
|
+
* Defines how empty states are displayed in the table
|
|
5
|
+
*/
|
|
6
|
+
export interface EmptyStateConfig {
|
|
7
|
+
icon?: ReactNode;
|
|
8
|
+
imageUrl?: string;
|
|
9
|
+
title: string;
|
|
10
|
+
description?: string;
|
|
11
|
+
action?: {
|
|
12
|
+
label: string;
|
|
13
|
+
onClick?: () => void;
|
|
14
|
+
href?: string;
|
|
15
|
+
icon?: ReactNode;
|
|
16
|
+
};
|
|
17
|
+
variant?: "default" | "search" | "filter" | "error" | "custom";
|
|
18
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Filter Configuration
|
|
3
|
+
* Defines filters that can be applied to table data
|
|
4
|
+
*/
|
|
5
|
+
export interface FilterConfig {
|
|
6
|
+
id: string;
|
|
7
|
+
label: string;
|
|
8
|
+
type: "text" | "select" | "multi-select" | "date" | "date-range" | "boolean";
|
|
9
|
+
column: string;
|
|
10
|
+
placeholder?: string;
|
|
11
|
+
options?: Array<{
|
|
12
|
+
label: string;
|
|
13
|
+
value: string;
|
|
14
|
+
}>;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Search Configuration
|
|
18
|
+
* Defines search functionality for the table
|
|
19
|
+
*/
|
|
20
|
+
export interface SearchConfig {
|
|
21
|
+
enabled: boolean;
|
|
22
|
+
placeholder?: string;
|
|
23
|
+
columns?: string[];
|
|
24
|
+
debounce?: number;
|
|
25
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { HeaderAction } from "./actions";
|
|
2
|
+
import { EmptyStateConfig } from "./empty-state";
|
|
3
|
+
import { FilterConfig, SearchConfig } from "./filters";
|
|
4
|
+
/**
|
|
5
|
+
* Pagination Configuration
|
|
6
|
+
* Defines pagination settings for the table
|
|
7
|
+
*/
|
|
8
|
+
export interface PaginationConfig {
|
|
9
|
+
enabled: boolean;
|
|
10
|
+
pageSize?: number;
|
|
11
|
+
pageSizeOptions?: number[];
|
|
12
|
+
showPageInfo?: boolean;
|
|
13
|
+
showPageSizeSelector?: boolean;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Complete Data Table Configuration
|
|
17
|
+
* Main configuration object for the data table component
|
|
18
|
+
*/
|
|
19
|
+
export interface DataTableConfig<TData> {
|
|
20
|
+
title?: string;
|
|
21
|
+
description?: string;
|
|
22
|
+
headerActions?: HeaderAction<TData>[];
|
|
23
|
+
emptyState?: EmptyStateConfig;
|
|
24
|
+
searchEmptyState?: EmptyStateConfig;
|
|
25
|
+
filterEmptyState?: EmptyStateConfig;
|
|
26
|
+
search?: SearchConfig;
|
|
27
|
+
filters?: FilterConfig[];
|
|
28
|
+
pagination?: PaginationConfig;
|
|
29
|
+
enableRowSelection?: boolean;
|
|
30
|
+
enableMultiRowSelection?: boolean;
|
|
31
|
+
enableSorting?: boolean;
|
|
32
|
+
defaultSort?: {
|
|
33
|
+
id: string;
|
|
34
|
+
desc: boolean;
|
|
35
|
+
};
|
|
36
|
+
enableColumnVisibility?: boolean;
|
|
37
|
+
density?: "compact" | "default" | "comfortable";
|
|
38
|
+
bordered?: boolean;
|
|
39
|
+
striped?: boolean;
|
|
40
|
+
hoverable?: boolean;
|
|
41
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function cn(...inputs: Array<string | boolean | undefined | null>): string;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { ColumnDef } from '@tanstack/react-table';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { DataTableConfig, EmptyStateConfig, HeaderAction } from '../types';
|
|
4
|
+
type ColumnBuilder<TData> = {
|
|
5
|
+
build(): ColumnDef<TData, unknown>;
|
|
6
|
+
};
|
|
7
|
+
export declare class DataTableSchema<TData> {
|
|
8
|
+
private config;
|
|
9
|
+
private columnBuilders;
|
|
10
|
+
static make<TData>(): DataTableSchema<TData>;
|
|
11
|
+
title(title: string): this;
|
|
12
|
+
description(description: string): this;
|
|
13
|
+
headerActions(builder: (b: HeaderActionsBuilder<TData>) => HeaderActionsBuilder<TData>): this;
|
|
14
|
+
emptyState(config: EmptyStateConfig): this;
|
|
15
|
+
searchEmptyState(config: EmptyStateConfig): this;
|
|
16
|
+
filterEmptyState(config: EmptyStateConfig): this;
|
|
17
|
+
searchable(config?: {
|
|
18
|
+
placeholder?: string;
|
|
19
|
+
columns?: string[];
|
|
20
|
+
debounce?: number;
|
|
21
|
+
}): this;
|
|
22
|
+
paginated(config?: {
|
|
23
|
+
pageSize?: number;
|
|
24
|
+
pageSizeOptions?: number[];
|
|
25
|
+
}): this;
|
|
26
|
+
selectable(multi?: boolean): this;
|
|
27
|
+
sortable(defaultSort?: {
|
|
28
|
+
id: string;
|
|
29
|
+
desc: boolean;
|
|
30
|
+
}): this;
|
|
31
|
+
bordered(bordered?: boolean): this;
|
|
32
|
+
striped(striped?: boolean): this;
|
|
33
|
+
hoverable(hoverable?: boolean): this;
|
|
34
|
+
density(density: 'compact' | 'default' | 'comfortable'): this;
|
|
35
|
+
columns(...builders: ColumnBuilder<TData>[]): this;
|
|
36
|
+
build(): {
|
|
37
|
+
columns: ColumnDef<TData, unknown>[];
|
|
38
|
+
config: DataTableConfig<TData>;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
declare class HeaderActionsBuilder<TData> {
|
|
42
|
+
private actions;
|
|
43
|
+
create(config: {
|
|
44
|
+
label: string;
|
|
45
|
+
href?: string;
|
|
46
|
+
onClick?: () => void;
|
|
47
|
+
icon?: ReactNode;
|
|
48
|
+
}): this;
|
|
49
|
+
export(config: {
|
|
50
|
+
label: string;
|
|
51
|
+
icon?: ReactNode;
|
|
52
|
+
formats?: Array<{
|
|
53
|
+
label: string;
|
|
54
|
+
onClick: () => void;
|
|
55
|
+
}>;
|
|
56
|
+
}): this;
|
|
57
|
+
import(config: {
|
|
58
|
+
label: string;
|
|
59
|
+
icon?: ReactNode;
|
|
60
|
+
onClick?: () => void;
|
|
61
|
+
}): this;
|
|
62
|
+
bulkExport(config: {
|
|
63
|
+
label: string;
|
|
64
|
+
icon?: ReactNode;
|
|
65
|
+
onExport: (rows: TData[]) => void;
|
|
66
|
+
}): this;
|
|
67
|
+
bulkDelete(config: {
|
|
68
|
+
label: string;
|
|
69
|
+
icon?: ReactNode;
|
|
70
|
+
onDelete: (rows: TData[]) => void;
|
|
71
|
+
}): this;
|
|
72
|
+
action(config: HeaderAction<TData>): this;
|
|
73
|
+
build(): HeaderAction<TData>[];
|
|
74
|
+
}
|
|
75
|
+
export { HeaderActionsBuilder };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { EmptyStateConfig } from '../types';
|
|
3
|
+
export declare class EmptyStateBuilder {
|
|
4
|
+
private config;
|
|
5
|
+
static make(): EmptyStateBuilder;
|
|
6
|
+
title(title: string): this;
|
|
7
|
+
description(description: string): this;
|
|
8
|
+
icon(icon: ReactNode): this;
|
|
9
|
+
imageUrl(imageUrl: string): this;
|
|
10
|
+
variant(variant: EmptyStateConfig['variant']): this;
|
|
11
|
+
action(config: {
|
|
12
|
+
label: string;
|
|
13
|
+
onClick?: () => void;
|
|
14
|
+
href?: string;
|
|
15
|
+
icon?: ReactNode;
|
|
16
|
+
}): this;
|
|
17
|
+
static noData(config?: {
|
|
18
|
+
title?: string;
|
|
19
|
+
description?: string;
|
|
20
|
+
createLabel?: string;
|
|
21
|
+
onCreate?: () => void;
|
|
22
|
+
createHref?: string;
|
|
23
|
+
}): EmptyStateBuilder;
|
|
24
|
+
static noSearchResults(config?: {
|
|
25
|
+
title?: string;
|
|
26
|
+
description?: string;
|
|
27
|
+
onClear?: () => void;
|
|
28
|
+
}): EmptyStateBuilder;
|
|
29
|
+
static noFilterResults(config?: {
|
|
30
|
+
title?: string;
|
|
31
|
+
description?: string;
|
|
32
|
+
onClear?: () => void;
|
|
33
|
+
}): EmptyStateBuilder;
|
|
34
|
+
static error(config?: {
|
|
35
|
+
title?: string;
|
|
36
|
+
description?: string;
|
|
37
|
+
onRetry?: () => void;
|
|
38
|
+
}): EmptyStateBuilder;
|
|
39
|
+
private createInboxIcon;
|
|
40
|
+
private createSearchIcon;
|
|
41
|
+
private createFilterIcon;
|
|
42
|
+
private createAlertIcon;
|
|
43
|
+
private createPlusIcon;
|
|
44
|
+
build(): EmptyStateConfig;
|
|
45
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { EmptyStateConfig } from '../types';
|
|
3
|
+
export declare class EmptyStateBuilder {
|
|
4
|
+
private config;
|
|
5
|
+
static make(): EmptyStateBuilder;
|
|
6
|
+
title(title: string): this;
|
|
7
|
+
description(description: string): this;
|
|
8
|
+
icon(icon: ReactNode): this;
|
|
9
|
+
variant(variant: EmptyStateConfig['variant']): this;
|
|
10
|
+
action(config: {
|
|
11
|
+
label: string;
|
|
12
|
+
onClick?: () => void;
|
|
13
|
+
href?: string;
|
|
14
|
+
icon?: ReactNode;
|
|
15
|
+
}): this;
|
|
16
|
+
static noData(config?: {
|
|
17
|
+
title?: string;
|
|
18
|
+
description?: string;
|
|
19
|
+
createLabel?: string;
|
|
20
|
+
onCreate?: () => void;
|
|
21
|
+
createHref?: string;
|
|
22
|
+
}): EmptyStateBuilder;
|
|
23
|
+
static noSearchResults(config?: {
|
|
24
|
+
title?: string;
|
|
25
|
+
description?: string;
|
|
26
|
+
onClear?: () => void;
|
|
27
|
+
}): EmptyStateBuilder;
|
|
28
|
+
static noFilterResults(config?: {
|
|
29
|
+
title?: string;
|
|
30
|
+
description?: string;
|
|
31
|
+
onClear?: () => void;
|
|
32
|
+
}): EmptyStateBuilder;
|
|
33
|
+
static error(config?: {
|
|
34
|
+
title?: string;
|
|
35
|
+
description?: string;
|
|
36
|
+
onRetry?: () => void;
|
|
37
|
+
}): EmptyStateBuilder;
|
|
38
|
+
private createInboxIcon;
|
|
39
|
+
private createSearchIcon;
|
|
40
|
+
private createFilterIcon;
|
|
41
|
+
private createAlertIcon;
|
|
42
|
+
private createPlusIcon;
|
|
43
|
+
build(): EmptyStateConfig;
|
|
44
|
+
}
|
package/dist/schema.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ColumnDef } from '@tanstack/react-table';
|
|
2
|
+
type ColumnBuilder<TData> = {
|
|
3
|
+
build(): ColumnDef<TData, unknown>;
|
|
4
|
+
};
|
|
5
|
+
export declare class TableSchema<TData> {
|
|
6
|
+
private columnBuilders;
|
|
7
|
+
static make<TData>(): TableSchema<TData>;
|
|
8
|
+
columns(...builders: ColumnBuilder<TData>[]): this;
|
|
9
|
+
build(): ColumnDef<TData, unknown>[];
|
|
10
|
+
}
|
|
11
|
+
export {};
|
|
@@ -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 };
|