@kareemelbalshe/any-table 1.3.0 → 1.4.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.
@@ -11,6 +11,7 @@ export interface ExportContext<TData = any> {
11
11
  search: string;
12
12
  sortBy: string | null;
13
13
  sortOrder: SortDirection;
14
+ filters?: Record<string, any>;
14
15
  params?: Record<string, any>;
15
16
  currentPageRows: TData[];
16
17
  selectedRows: TData[];
@@ -98,6 +99,47 @@ export interface VirtualizedConfig {
98
99
  */
99
100
  overscan?: number;
100
101
  }
102
+ export interface ColumnVisibilityConfig {
103
+ enabled?: boolean;
104
+ storageKey?: string;
105
+ defaultHiddenColumns?: string[];
106
+ onVisibilityChange?: (hiddenColumns: string[], visibleColumns: string[]) => void;
107
+ allowReset?: boolean;
108
+ }
109
+ export interface ColumnFiltersConfig {
110
+ enabled?: boolean;
111
+ mode?: "client" | "server" | "auto";
112
+ defaultFilters?: Record<string, any>;
113
+ defaultOpen?: boolean;
114
+ onFilterChange?: (filters: Record<string, any>) => void;
115
+ showClearAll?: boolean;
116
+ }
117
+ export interface ExpandableConfig<TData = any> {
118
+ render: (row: TData, index: number) => React.ReactNode;
119
+ rowExpandable?: (row: TData, index: number) => boolean;
120
+ defaultExpandedKeys?: (string | number)[];
121
+ expandRowByClick?: boolean;
122
+ accordion?: boolean;
123
+ onExpandChange?: (expandedKeys: (string | number)[]) => void;
124
+ }
125
+ export interface CellEditParams<TData = any> {
126
+ row: TData;
127
+ rowKey: string | number;
128
+ columnKey: string;
129
+ oldValue: any;
130
+ newValue: any;
131
+ rowIndex: number;
132
+ }
133
+ export interface BulkAction<TData = any> {
134
+ id: string;
135
+ label: string;
136
+ icon?: React.ReactNode;
137
+ variant?: "primary" | "danger" | "warning" | "success" | "neutral";
138
+ onClick: (selectedRows: TData[], selectedKeys: (string | number)[], context: {
139
+ clearSelection: () => void;
140
+ refresh: () => Promise<void>;
141
+ }) => Promise<void> | void;
142
+ }
101
143
  export interface TableState<TData = any> {
102
144
  data: TData[];
103
145
  loading: boolean;
@@ -109,6 +151,9 @@ export interface TableState<TData = any> {
109
151
  search: string;
110
152
  sortBy: string | null;
111
153
  sortOrder: SortDirection;
154
+ filters?: Record<string, any>;
155
+ hiddenColumns?: string[];
156
+ expandedRowKeys?: (string | number)[];
112
157
  selectedRowKeys: (string | number)[];
113
158
  selectedRows: TData[];
114
159
  isServerMode: boolean;
@@ -175,6 +220,38 @@ export interface TableInstance<TData = any> {
175
220
  * Whether an export operation is currently fetching data or generating a file.
176
221
  */
177
222
  isExporting?: boolean;
223
+ /**
224
+ * Programmatically sets a single column filter value.
225
+ */
226
+ setColumnFilter?: (key: string, value: any) => void;
227
+ /**
228
+ * Clears all active per-column filters.
229
+ */
230
+ clearColumnFilters?: () => void;
231
+ /**
232
+ * Toggles visibility of a column by its key.
233
+ */
234
+ toggleColumnVisibility?: (key: string) => void;
235
+ /**
236
+ * Sets the list of hidden column keys directly.
237
+ */
238
+ setHiddenColumns?: (keys: string[]) => void;
239
+ /**
240
+ * Resets column visibility to initial defaults and clears persisted storage.
241
+ */
242
+ resetColumnVisibility?: () => void;
243
+ /**
244
+ * Toggles expansion state of a row by its key.
245
+ */
246
+ toggleExpandRow?: (key: string | number) => void;
247
+ /**
248
+ * Expands all currently loaded rows.
249
+ */
250
+ expandAllRows?: () => void;
251
+ /**
252
+ * Collapses all expanded rows.
253
+ */
254
+ collapseAllRows?: () => void;
178
255
  }
179
256
  export interface AnyTableProps<TData = any> {
180
257
  /**
@@ -345,6 +422,31 @@ export interface AnyTableProps<TData = any> {
345
422
  * Enables interactive column width resizing handles on the table header. Defaults to false.
346
423
  */
347
424
  resizableColumns?: boolean;
425
+ /**
426
+ * Enables column visibility toggle menu in the toolbar with optional localStorage persistence.
427
+ */
428
+ columnVisibility?: boolean | ColumnVisibilityConfig;
429
+ /**
430
+ * Enables smart per-column filter inputs/dropdowns below the header row.
431
+ */
432
+ columnFilters?: boolean | ColumnFiltersConfig;
433
+ /**
434
+ * Enables expandable Master-Detail rows with custom detail panel rendering.
435
+ */
436
+ expandable?: ExpandableConfig<TData>;
437
+ /**
438
+ * Callback invoked when an editable cell value is committed (double-click or Enter).
439
+ * Return `false` or reject to cancel the edit.
440
+ */
441
+ onCellEdit?: (params: CellEditParams<TData>) => Promise<void | boolean> | void | boolean;
442
+ /**
443
+ * Contextual bulk action buttons rendered when rows are selected (`selectable=true`).
444
+ */
445
+ bulkActions?: BulkAction<TData>[];
446
+ /**
447
+ * Controls whether the summary/aggregation footer row renders when columns define `summary`. Defaults to true.
448
+ */
449
+ showSummary?: boolean;
348
450
  thead?: string[];
349
451
  headerData?: string[];
350
452
  tbodys?: TData[];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kareemelbalshe/any-table",
3
- "version": "1.3.0",
4
- "description": "Zero-config, zero-dependency smart data table for React (16.8+ to 19+) with 100k+ DOM virtualization, 3-tier REST API auto-detection, built-in CSV/Excel export, first-class RTL & Arabic, column resizing, pinning, and headless hook.",
3
+ "version": "1.4.0",
4
+ "description": "Zero-config, zero-dependency smart data table for React (16.8+ to 19+) with 100k+ DOM virtualization, 3-tier REST API auto-detection, per-column filters, column visibility persistence, expandable rows, inline cell editing, bulk actions, summary footer, CSV/Excel export, and first-class RTL & Arabic.",
5
5
  "keywords": [
6
6
  "react",
7
7
  "table",
@@ -12,6 +12,13 @@
12
12
  "pagination",
13
13
  "sorting",
14
14
  "search",
15
+ "column-filters",
16
+ "column-visibility",
17
+ "expandable-rows",
18
+ "master-detail",
19
+ "inline-editing",
20
+ "bulk-actions",
21
+ "table-aggregation",
15
22
  "auto-columns",
16
23
  "typescript",
17
24
  "react-table",