@nccirtu/tablefy 0.6.2 → 0.6.3

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.
@@ -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,2 @@
1
+ export { TableSchema } from "./table-schema";
2
+ export { EmptyStateBuilder } from "./empty-state";
@@ -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 {};
@@ -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,2 @@
1
+ export { TableSchema } from "./table-schema";
2
+ export { EmptyStateBuilder } from "./empty-state";
@@ -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,6 +1,6 @@
1
1
  export { DataTable } from "./tablefy/data-table";
2
2
  export { DataTableSchema } from "./tablefy/data-table-schema";
3
- export { TableSchema, EmptyStateBuilder } from "./lib/builders";
3
+ export { TableSchema, EmptyStateBuilder } from "./builders";
4
4
  export { AvatarGroupColumn, AvatarGroupColumn as avatarGroupColumn, } from "./columns/avatar-group-column";
5
5
  export { BadgeColumn, BadgeColumn as badgeColumn, } from "./columns/badge-column";
6
6
  export { ButtonColumn, ButtonColumn as buttonColumn, } from "./columns/button-column";
@@ -16,4 +16,4 @@ export { ProgressColumn, ProgressColumn as progressColumn, } from "./columns/pro
16
16
  export { SelectColumn, SelectColumn as selectColumn, } from "./columns/select-column";
17
17
  export { TextColumn, TextColumn as textColumn } from "./columns/text-column";
18
18
  export { ActionsColumn } from "./columns/actions-column";
19
- export type { DataTableConfig, EmptyStateConfig, FilterConfig, HeaderAction, PaginationConfig, SearchConfig, } from "./lib/types";
19
+ export type { DataTableConfig, EmptyStateConfig, FilterConfig, HeaderAction, PaginationConfig, SearchConfig, } from "./types";
@@ -1,4 +1,4 @@
1
- import { EmptyStateConfig } from "../lib/types";
1
+ import { EmptyStateConfig } from "../types";
2
2
  interface DataTableEmptyProps {
3
3
  config: EmptyStateConfig;
4
4
  colSpan: number;
@@ -1,5 +1,5 @@
1
1
  import { Table as TanstackTable } from "@tanstack/react-table";
2
- import { HeaderAction, SearchConfig } from "../lib/types";
2
+ import { HeaderAction, SearchConfig } from "../types";
3
3
  interface DataTableHeaderProps<TData> {
4
4
  title?: string;
5
5
  description?: string;
@@ -1,5 +1,5 @@
1
1
  import { Table as TanstackTable } from "@tanstack/react-table";
2
- import { PaginationConfig } from "../lib/types";
2
+ import { PaginationConfig } from "../types";
3
3
  interface DataTablePaginationProps<TData> {
4
4
  table: TanstackTable<TData>;
5
5
  config?: PaginationConfig;
@@ -1,5 +1,5 @@
1
1
  import { ColumnDef } from "@tanstack/react-table";
2
- import { DataTableConfig } from "../lib/types";
2
+ import { DataTableConfig } from "../types";
3
3
  interface DataTableProps<TData, TValue> {
4
4
  columns: ColumnDef<TData, TValue>[];
5
5
  data: TData[];
@@ -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,4 @@
1
+ export type { HeaderAction } from "./actions";
2
+ export type { EmptyStateConfig } from "./empty-state";
3
+ export type { FilterConfig, SearchConfig } from "./filters";
4
+ export type { PaginationConfig, DataTableConfig } from "./table";
@@ -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;
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { DataTable } from "./tablefy/data-table";
2
2
  export { DataTableSchema } from "./tablefy/data-table-schema";
3
- export { TableSchema, EmptyStateBuilder } from "./lib/builders";
3
+ export { TableSchema, EmptyStateBuilder } from "./builders";
4
4
  export { AvatarGroupColumn, AvatarGroupColumn as avatarGroupColumn, } from "./columns/avatar-group-column";
5
5
  export { BadgeColumn, BadgeColumn as badgeColumn, } from "./columns/badge-column";
6
6
  export { ButtonColumn, ButtonColumn as buttonColumn, } from "./columns/button-column";
@@ -16,4 +16,4 @@ export { ProgressColumn, ProgressColumn as progressColumn, } from "./columns/pro
16
16
  export { SelectColumn, SelectColumn as selectColumn, } from "./columns/select-column";
17
17
  export { TextColumn, TextColumn as textColumn } from "./columns/text-column";
18
18
  export { ActionsColumn } from "./columns/actions-column";
19
- export type { DataTableConfig, EmptyStateConfig, FilterConfig, HeaderAction, PaginationConfig, SearchConfig, } from "./lib/types";
19
+ export type { DataTableConfig, EmptyStateConfig, FilterConfig, HeaderAction, PaginationConfig, SearchConfig, } from "./types";