lite-table-js 1.0.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/README.md +71 -0
- package/dist/index.js +3874 -0
- package/dist/index.js.map +1 -0
- package/package.json +61 -0
- package/types/index.d.ts +174 -0
package/package.json
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "lite-table-js",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Enterprise-grade React data table with sorting, filtering, pagination, editing, theming, charts, virtualization, and more",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"module": "dist/index.js",
|
|
8
|
+
"types": "types/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"types": "./types/index.d.ts"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"types",
|
|
18
|
+
"README.md",
|
|
19
|
+
"LICENSE"
|
|
20
|
+
],
|
|
21
|
+
"scripts": {
|
|
22
|
+
"build": "vite build",
|
|
23
|
+
"prepublishOnly": "npm run build"
|
|
24
|
+
},
|
|
25
|
+
"peerDependencies": {
|
|
26
|
+
"react": ">=18.0.0",
|
|
27
|
+
"react-dom": ">=18.0.0"
|
|
28
|
+
},
|
|
29
|
+
"peerDependenciesMeta": {
|
|
30
|
+
"recharts": {
|
|
31
|
+
"optional": true
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"optionalDependencies": {
|
|
35
|
+
"xlsx": ">=0.18.0"
|
|
36
|
+
},
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"lucide-react": ">=0.300.0"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"vite": "^8.0.1",
|
|
42
|
+
"@vitejs/plugin-react": "^6.0.1",
|
|
43
|
+
"react": "^19.2.4",
|
|
44
|
+
"react-dom": "^19.2.4"
|
|
45
|
+
},
|
|
46
|
+
"keywords": [
|
|
47
|
+
"react",
|
|
48
|
+
"table",
|
|
49
|
+
"datatable",
|
|
50
|
+
"data-grid",
|
|
51
|
+
"sorting",
|
|
52
|
+
"filtering",
|
|
53
|
+
"pagination",
|
|
54
|
+
"virtualization",
|
|
55
|
+
"theming",
|
|
56
|
+
"charts",
|
|
57
|
+
"editing"
|
|
58
|
+
],
|
|
59
|
+
"license": "MIT",
|
|
60
|
+
"sideEffects": false
|
|
61
|
+
}
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { ReactNode, ComponentType, CSSProperties, RefObject } from 'react';
|
|
2
|
+
|
|
3
|
+
// ─── Core Types ───────────────────────────────────────────────────────
|
|
4
|
+
export type SortDirection = 'asc' | 'desc' | null;
|
|
5
|
+
export type FilterType = 'text' | 'number' | 'date' | 'select' | 'multi-select' | 'custom';
|
|
6
|
+
export type ViewMode = 'table' | 'grid' | 'list';
|
|
7
|
+
export type SelectionMode = 'single' | 'multiple' | 'none';
|
|
8
|
+
export type DataMode = 'client' | 'server';
|
|
9
|
+
export type PinPosition = 'left' | 'right' | null;
|
|
10
|
+
export type ExportFormat = 'csv' | 'excel' | 'pdf';
|
|
11
|
+
export type RowPinPosition = 'top' | 'bottom' | null;
|
|
12
|
+
export type AggregationType = 'sum' | 'avg' | 'count' | 'min' | 'max' | 'first' | 'last';
|
|
13
|
+
export type ChartType = 'bar' | 'line' | 'pie' | 'area';
|
|
14
|
+
export type SidebarPanelType = 'columns' | 'filters' | 'custom';
|
|
15
|
+
|
|
16
|
+
export interface ColumnDef<T = any> {
|
|
17
|
+
id: string;
|
|
18
|
+
header: string;
|
|
19
|
+
accessorKey?: string;
|
|
20
|
+
accessorFn?: (row: T) => any;
|
|
21
|
+
width?: number;
|
|
22
|
+
minWidth?: number;
|
|
23
|
+
maxWidth?: number;
|
|
24
|
+
sortable?: boolean;
|
|
25
|
+
sortFn?: (a: T, b: T, direction: SortDirection) => number;
|
|
26
|
+
filterable?: boolean;
|
|
27
|
+
filterType?: FilterType;
|
|
28
|
+
filterOptions?: { label: string; value: string }[];
|
|
29
|
+
filterComponent?: ComponentType<any>;
|
|
30
|
+
cell?: (props: CellRenderProps<T>) => ReactNode;
|
|
31
|
+
headerCell?: (props: HeaderRenderProps<T>) => ReactNode;
|
|
32
|
+
visible?: boolean;
|
|
33
|
+
pin?: PinPosition;
|
|
34
|
+
resizable?: boolean;
|
|
35
|
+
editable?: boolean;
|
|
36
|
+
editCell?: (props: EditCellProps<T>) => ReactNode;
|
|
37
|
+
validation?: CellValidationRule<T>;
|
|
38
|
+
align?: 'left' | 'center' | 'right';
|
|
39
|
+
className?: string;
|
|
40
|
+
group?: string;
|
|
41
|
+
aggregateFn?: (values: any[]) => any;
|
|
42
|
+
tooltip?: boolean | ((props: CellRenderProps<T>) => string);
|
|
43
|
+
rowSpan?: (row: T, rowIndex: number, data: T[]) => number;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface CellRenderProps<T = any> { value: any; row: T; rowIndex: number; column: ColumnDef<T>; }
|
|
47
|
+
export interface HeaderRenderProps<T = any> { column: ColumnDef<T>; sortDirection: SortDirection; onSort: () => void; }
|
|
48
|
+
export interface EditCellProps<T = any> { value: any; row: T; column: ColumnDef<T>; onSave: (value: any) => void; onCancel: () => void; error?: string | null; validating?: boolean; }
|
|
49
|
+
export interface CellValidationRule<T = any> { validate: (value: any, row: T, column: ColumnDef<T>) => string | null | undefined; }
|
|
50
|
+
export interface SortState { columnId: string; direction: SortDirection; }
|
|
51
|
+
export interface FilterValue { columnId: string; value: any; operator?: string; }
|
|
52
|
+
export interface FilterPreset { id: string; name: string; filters: FilterValue[]; globalSearch?: string; }
|
|
53
|
+
|
|
54
|
+
export interface SortConfig { multi?: boolean; defaultSort?: SortState[]; sort?: SortState[]; onSortChange?: (sort: SortState[]) => void; }
|
|
55
|
+
export interface FilterConfig { filters?: FilterValue[]; onFilterChange?: (filters: FilterValue[]) => void; globalSearch?: string; onGlobalSearchChange?: (value: string) => void; searchDebounce?: number; presets?: FilterPreset[]; onPresetSave?: (preset: FilterPreset) => void; onPresetDelete?: (presetId: string) => void; }
|
|
56
|
+
export interface PaginationConfig { page?: number; pageSize?: number; pageSizeOptions?: number[]; totalItems?: number; onPageChange?: (page: number) => void; onPageSizeChange?: (size: number) => void; infinite?: boolean; onLoadMore?: () => void; hasMore?: boolean; }
|
|
57
|
+
export interface SelectionConfig<T = any> { mode?: SelectionMode; selectedKeys?: string[]; onSelectionChange?: (keys: string[], rows: T[]) => void; rowKey?: string | ((row: T) => string); showCheckbox?: boolean; }
|
|
58
|
+
export interface ExpandableConfig<T = any> { enabled?: boolean; render: (row: T) => ReactNode; expandedKeys?: string[]; onExpandChange?: (keys: string[]) => void; }
|
|
59
|
+
export interface RowAction<T = any> { id: string; label: string; icon?: ReactNode; onClick: (row: T) => void; hidden?: (row: T) => boolean; disabled?: (row: T) => boolean; variant?: 'default' | 'danger'; }
|
|
60
|
+
export interface BulkAction<T = any> { id: string; label: string; icon?: ReactNode; onClick: (selectedRows: T[]) => void; variant?: 'default' | 'danger'; }
|
|
61
|
+
export interface DataTableTheme { wrapper?: string; table?: string; headerRow?: string; headerCell?: string; bodyRow?: string; bodyCell?: string; selectedRow?: string; hoverRow?: string; stripedRow?: string; gridCard?: string; listItem?: string; toolbar?: string; }
|
|
62
|
+
export interface ThemeColors { background: string; foreground: string; primary: string; primaryLight: string; border: string; muted: string; hover: string; selected: string; surface: string; textSecondary: string; }
|
|
63
|
+
export interface ThemeTypography { fontFamily: string; fontSize: string; headerFontSize: string; headerFontWeight: number; }
|
|
64
|
+
export interface ThemeSpacing { cellPaddingX: string; cellPaddingY: string; compactCellPaddingY: string; rowHeight: string; }
|
|
65
|
+
export interface TableThemeConfig { name: string; colors?: ThemeColors; typography?: ThemeTypography; spacing?: ThemeSpacing; header: CSSProperties; row: CSSProperties; cell: CSSProperties; selectedRow?: CSSProperties; hoverRow?: CSSProperties; stripedRow?: CSSProperties; toolbar?: CSSProperties; pagination?: CSSProperties; tooltip?: CSSProperties; conditionalRules?: any[]; rowRules?: any[]; cssVariables?: Record<string, string>; }
|
|
66
|
+
export interface ChartConfig { id?: string; type: ChartType; labelColumn: string; dataColumns: string[]; title?: string; groupBy?: string; aggregation?: string; colors?: string[]; showLegend?: boolean; showTooltip?: boolean; stacked?: boolean; height?: number; }
|
|
67
|
+
export interface ChartInstance { id: string; config: ChartConfig; createdAt: number; }
|
|
68
|
+
export interface VirtualizationConfig { enabled: boolean; rowHeight: number; overscan?: number; }
|
|
69
|
+
export interface DataTablePlugin<T = any> { name: string; processData?: (data: T[], state: any) => T[]; renderToolbar?: (state: any) => ReactNode; renderFooter?: (state: any) => ReactNode; renderRow?: (row: T, defaultRender: () => ReactNode) => ReactNode; }
|
|
70
|
+
export interface ServerSideConfig { onFetch: (params: any) => Promise<{ data: any[]; totalItems: number }>; }
|
|
71
|
+
|
|
72
|
+
export interface DataTableProps<T = any> {
|
|
73
|
+
data: T[];
|
|
74
|
+
columns: ColumnDef<T>[];
|
|
75
|
+
mode?: DataMode;
|
|
76
|
+
serverSide?: ServerSideConfig;
|
|
77
|
+
loading?: boolean;
|
|
78
|
+
error?: string | null;
|
|
79
|
+
onRetry?: () => void;
|
|
80
|
+
sorting?: SortConfig;
|
|
81
|
+
filtering?: FilterConfig;
|
|
82
|
+
pagination?: PaginationConfig;
|
|
83
|
+
selection?: SelectionConfig<T>;
|
|
84
|
+
expandable?: ExpandableConfig<T>;
|
|
85
|
+
rowActions?: RowAction<T>[];
|
|
86
|
+
bulkActions?: BulkAction<T>[];
|
|
87
|
+
onRowClick?: (row: T) => void;
|
|
88
|
+
onRowDoubleClick?: (row: T) => void;
|
|
89
|
+
rowClassName?: string | ((row: T) => string);
|
|
90
|
+
viewMode?: ViewMode;
|
|
91
|
+
onViewModeChange?: (mode: ViewMode) => void;
|
|
92
|
+
views?: ViewMode[];
|
|
93
|
+
renderGridCard?: (row: T) => ReactNode;
|
|
94
|
+
renderListItem?: (row: T) => ReactNode;
|
|
95
|
+
columnVisibility?: boolean;
|
|
96
|
+
columnResizing?: boolean;
|
|
97
|
+
columnReordering?: boolean;
|
|
98
|
+
onCellEdit?: (rowKey: string, columnId: string, value: any) => void;
|
|
99
|
+
floatingFilters?: boolean;
|
|
100
|
+
exportFormats?: ExportFormat[];
|
|
101
|
+
onExport?: (format: ExportFormat, data: T[]) => void;
|
|
102
|
+
theme?: DataTableTheme;
|
|
103
|
+
striped?: boolean;
|
|
104
|
+
bordered?: boolean;
|
|
105
|
+
compact?: boolean;
|
|
106
|
+
stickyHeader?: boolean;
|
|
107
|
+
maxHeight?: string | number;
|
|
108
|
+
emptyText?: string;
|
|
109
|
+
emptyIcon?: ComponentType<any>;
|
|
110
|
+
plugins?: DataTablePlugin<T>[];
|
|
111
|
+
persistKey?: string;
|
|
112
|
+
syncUrl?: boolean;
|
|
113
|
+
ariaLabel?: string;
|
|
114
|
+
ariaDescribedBy?: string;
|
|
115
|
+
className?: string;
|
|
116
|
+
themeConfig?: TableThemeConfig;
|
|
117
|
+
rowGrouping?: any;
|
|
118
|
+
treeData?: any;
|
|
119
|
+
rowPinning?: any;
|
|
120
|
+
masterDetail?: any;
|
|
121
|
+
contextMenu?: any[];
|
|
122
|
+
sidebarPanels?: any[];
|
|
123
|
+
virtualization?: VirtualizationConfig;
|
|
124
|
+
enableTooltips?: boolean;
|
|
125
|
+
statusBar?: any;
|
|
126
|
+
rowEditing?: any;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// ─── Main Component ───────────────────────────────────────────────────
|
|
130
|
+
export function DataTable<T = any>(props: DataTableProps<T>): ReactNode;
|
|
131
|
+
|
|
132
|
+
// ─── Hooks ────────────────────────────────────────────────────────────
|
|
133
|
+
export function useDataTable<T = any>(props: DataTableProps<T>): any;
|
|
134
|
+
export function useSorting(options: any): any;
|
|
135
|
+
export function useFilters(options: any): any;
|
|
136
|
+
export function usePagination(options: any): any;
|
|
137
|
+
export function useSelection(options: any): any;
|
|
138
|
+
export function useColumnManager(options: any): any;
|
|
139
|
+
export function usePersistence(options: any): any;
|
|
140
|
+
export function usePresets(options: any): any;
|
|
141
|
+
export function useTheme(options: any): any;
|
|
142
|
+
export function useVirtualization(options: any): any;
|
|
143
|
+
export function useRowGrouping(options: any): any;
|
|
144
|
+
export function useTreeData(options: any): any;
|
|
145
|
+
export function useEditing(options: any): any;
|
|
146
|
+
export function useChartData(options: any): any;
|
|
147
|
+
export function useChartConfig(options?: any): any;
|
|
148
|
+
|
|
149
|
+
// ─── Themes ───────────────────────────────────────────────────────────
|
|
150
|
+
export const lightTheme: TableThemeConfig;
|
|
151
|
+
export const darkTheme: TableThemeConfig;
|
|
152
|
+
export const quartzTheme: TableThemeConfig;
|
|
153
|
+
export const alpineTheme: TableThemeConfig;
|
|
154
|
+
export const builtInThemes: Record<string, TableThemeConfig>;
|
|
155
|
+
export function createTheme(base: TableThemeConfig, overrides: Partial<TableThemeConfig>): TableThemeConfig;
|
|
156
|
+
|
|
157
|
+
// ─── Utilities ────────────────────────────────────────────────────────
|
|
158
|
+
export function getNestedValue(obj: any, path: string): any;
|
|
159
|
+
export function getCellValue<T>(row: T, column: ColumnDef<T>): any;
|
|
160
|
+
export function getRowKey<T>(row: T, rowKey: string | ((row: T) => string) | undefined, index: number): string;
|
|
161
|
+
export function sortData<T>(data: T[], sorts: SortState[], columns: ColumnDef<T>[]): T[];
|
|
162
|
+
export function filterData<T>(data: T[], filters: FilterValue[], globalSearch: string, columns: ColumnDef<T>[]): T[];
|
|
163
|
+
export function paginateData<T>(data: T[], page: number, pageSize: number): T[];
|
|
164
|
+
export function groupData<T>(data: T[], groupBy: string): Map<any, T[]>;
|
|
165
|
+
export function handleExport<T>(format: ExportFormat, data: T[], columns: ColumnDef<T>[], onExport?: Function): void;
|
|
166
|
+
export function reorderArray<T>(arr: T[], fromIndex: number, toIndex: number): T[];
|
|
167
|
+
export function exportToCSV<T>(data: T[], columns: ColumnDef<T>[], columnIds?: string[], filename?: string): void;
|
|
168
|
+
export function exportToExcel<T>(data: T[], columns: ColumnDef<T>[], columnIds?: string[], filename?: string, sheetName?: string): Promise<void>;
|
|
169
|
+
|
|
170
|
+
// ─── Plugins ──────────────────────────────────────────────────────────
|
|
171
|
+
export function createRowNumberPlugin(): DataTablePlugin;
|
|
172
|
+
export function createGroupingPlugin<T>(groupByField: string, renderGroupHeader?: Function): DataTablePlugin<T>;
|
|
173
|
+
export function createSelectionSummaryPlugin<T>(): DataTablePlugin<T>;
|
|
174
|
+
export function createTransformPlugin<T>(name: string, transform: (data: T[]) => T[]): DataTablePlugin<T>;
|