@kareemelbalshe/any-table 1.2.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.
- package/CHANGELOG.md +46 -0
- package/README.md +178 -0
- package/dist/adapters/columnFilterAdapter.d.ts +9 -0
- package/dist/adapters/index.d.ts +1 -0
- package/dist/columns/pinningUtils.d.ts +1 -0
- package/dist/components/TableBody.d.ts +7 -1
- package/dist/components/TableBulkBar.d.ts +13 -0
- package/dist/components/TableFooter.d.ts +15 -0
- package/dist/components/TableHeader.d.ts +7 -2
- package/dist/components/TableToolbar.d.ts +19 -3
- package/dist/components/index.d.ts +3 -0
- package/dist/hooks/index.d.ts +3 -0
- package/dist/hooks/useAnyTable.d.ts +42 -3
- package/dist/hooks/useAnyTableColumnFilters.d.ts +19 -0
- package/dist/hooks/useAnyTableColumnVisibility.d.ts +17 -0
- package/dist/hooks/useAnyTableController.d.ts +12 -3
- package/dist/hooks/useAnyTableData.d.ts +3 -1
- package/dist/hooks/useAnyTableExpand.d.ts +15 -0
- package/dist/i18n/messages.d.ts +24 -0
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3094 -1736
- package/dist/index.js.map +1 -1
- package/dist/style.css +1 -1
- package/dist/types/api.types.d.ts +2 -0
- package/dist/types/column.types.d.ts +58 -0
- package/dist/types/table.types.d.ts +151 -4
- package/package.json +9 -2
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,52 @@ All notable changes to **AnyTable** (`@kareemelbalshe/any-table`) are documented
|
|
|
4
4
|
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
+
## [1.4.0] - 2026-12-02
|
|
8
|
+
|
|
9
|
+
### 🌟 Enterprise Power Features & Workflow Suite (Zero Dependencies)
|
|
10
|
+
- 👁️ **Column Visibility Toggle & `localStorage` Persistence (`columnVisibility`)**:
|
|
11
|
+
- Toolbar **Columns** dropdown with checkboxes, `col.hideable: false` lock protection, `col.defaultHidden`, and one-click **Reset Columns**.
|
|
12
|
+
- Automatic `localStorage` persistence via `columnVisibility={{ storageKey: "..." }}` and imperative ref APIs (`toggleColumnVisibility`, `setHiddenColumns`, `resetColumnVisibility`).
|
|
13
|
+
- 🔍 **Smart Per-Column Filtering (`columnFilters`)**:
|
|
14
|
+
- Toggleable secondary filter row below table headers supporting **text**, **auto-populated status/select dropdowns**, **boolean**, **date**, and **numeric comparison operators** (`>=500`, `<=1000`, `>100`, `<50`, `=200`).
|
|
15
|
+
- Works seamlessly in both **Client Mode** and **Server Mode** (passes structured `filters` object to `api.fetcher` and automatically resets pagination to page 1).
|
|
16
|
+
- Imperative controls `setColumnFilter(key, val)` and `clearColumnFilters()`.
|
|
17
|
+
- 📂 **Expandable Master-Detail Rows (`expandable`)**:
|
|
18
|
+
- Render nested sub-tables, order items, or detail cards inside expandable row panels via `expandable={{ render: (row) => ... }}`.
|
|
19
|
+
- Supports `accordion` mode (single expanded row at a time), `rowExpandable` predicate, `expandRowByClick`, `defaultExpandedKeys`, and imperative `toggleExpandRow`, `expandAllRows`, `collapseAllRows`.
|
|
20
|
+
- ✏️ **Inline Cell Editing (`onCellEdit` + `col.editable`)**:
|
|
21
|
+
- Double-click any editable cell to edit inline using text, number, boolean, or select dropdown editors.
|
|
22
|
+
- Built-in validation (`col.validateEdit`), `Enter` to commit (async supported), `Escape` to cancel, and instant optimistic UI updates.
|
|
23
|
+
- ⚡ **Contextual Bulk Actions Bar (`bulkActions`) & Summary Footer (`col.summary`)**:
|
|
24
|
+
- Floating contextual **Bulk Actions Bar** (`TableBulkBar`) appears automatically when rows are selected (`selectable`), with per-action async loading states and `clearSelection` / `refresh` context.
|
|
25
|
+
- Built-in **Summary / Aggregation Footer** (`<tfoot>`) supporting `"sum"`, `"avg"`, `"min"`, `"max"`, `"count"`, and custom aggregation functions over filtered records.
|
|
26
|
+
- 🌍 **Full Arabic RTL & Headless Support**:
|
|
27
|
+
- Complete Arabic & English translations in `arMessages` / `enMessages` for all v1.4.0 controls, plus `columnVisibility`, `columnFilters`, and `expandable` exposed on `useAnyTable()`.
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## [1.3.0] - 2026-11-16
|
|
32
|
+
|
|
33
|
+
### 🌟 Enterprise Server-Side Export & Enhancements
|
|
34
|
+
- 📊 **Server-Side Pagination Export (`fetchAllRows`)**:
|
|
35
|
+
- Full support for exporting **all filtered rows** rather than only the current page when server-side pagination is active.
|
|
36
|
+
- Added `exportable.fetchAllRows?: boolean | ((params) => Promise<TData[]>)`. AnyTable automatically passes active search, sorting, and filter parameters to retrieve full filtered results and format them with UTF-8 BOM CSV / JSON.
|
|
37
|
+
- 🚀 **Full-Control Custom Export (`onExport`)**:
|
|
38
|
+
- Added `exportable.onExport?: (format, context) => Promise<void> | void` for enterprise streaming downloads or delegating report generation to backend endpoints.
|
|
39
|
+
- 🎯 **Client-Side Export Enhancement**:
|
|
40
|
+
- Client-side tables now automatically export **all filtered & sorted records** across pages by default instead of only the active page slice.
|
|
41
|
+
- 📐 **Granular Export Scopes & Column Control**:
|
|
42
|
+
- Added `scope?: "all" | "current-page" | "selected" | "auto"`.
|
|
43
|
+
- Added `showScopeOptions?: boolean` to provide scope sub-options in the toolbar dropdown.
|
|
44
|
+
- Added `col.exportable?: boolean` to exclude specific columns from exports.
|
|
45
|
+
- Added `col.exportFormatter?: (value, row) => string` for custom cell values during export without altering React UI renderers.
|
|
46
|
+
- ⏳ **Reactive Export State**:
|
|
47
|
+
- Added `isExporting` state with animated spinner and disabled state on the toolbar button to prevent duplicate export submissions. Exposed on `TableInstance` and `useAnyTable`.
|
|
48
|
+
- 🛡️ **API Stability**:
|
|
49
|
+
- Secured `useAnyTableData` with `apiRef` to prevent re-fetch loops when `api={{ fetcher }}` is defined inline.
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
7
53
|
## [1.1.0] - 2026-10-13
|
|
8
54
|
|
|
9
55
|
### 🌟 New Features & Enhancements
|
package/README.md
CHANGED
|
@@ -27,6 +27,9 @@ Building table grids in React is notoriously painful: either you write 100+ line
|
|
|
27
27
|
| **Native CSV & Excel Export** | **Built-in (UTF-8 BOM)** | Needs external library | Paid Enterprise | Paid Pro |
|
|
28
28
|
| **First-Class Arabic & RTL Support** | **Built-in (`dir="rtl"`)** | Manual CSS overrides | Basic | Basic |
|
|
29
29
|
| **Column Resizing & Pinning** | **Built-in** | Complex manual setup | Enterprise | Pro only |
|
|
30
|
+
| **Per-Column Filters & Visibility Persistence** | **Built-in (`columnFilters` & `columnVisibility`)** | Manual state + UI | Paid Enterprise | Paid Pro |
|
|
31
|
+
| **Expandable Rows & Inline Cell Editing** | **Built-in (`expandable` & `onCellEdit`)** | Manual boilerplate | Enterprise | Pro only |
|
|
32
|
+
| **Summary Footer & Bulk Actions Bar** | **Built-in (`col.summary` & `bulkActions`)** | Manual | Enterprise | Pro only |
|
|
30
33
|
| **Headless Mode Available** | **Yes (`useAnyTable()`)** | Yes | No (Strict UI) | No (Strict UI) |
|
|
31
34
|
| **React Compatibility** | **React 16.8+ to 19+** | React 18+ mostly | React 17+ | React 17+ |
|
|
32
35
|
| **License** | **100% Free MIT** | MIT (headless only) | Free / $$ Enterprise | Free / $$ Commercial |
|
|
@@ -48,6 +51,7 @@ Building table grids in React is notoriously painful: either you write 100+ line
|
|
|
48
51
|
- [📊 Built-in CSV & Excel Export Engine](#-built-in-csv--excel-export-engine)
|
|
49
52
|
- [🌍 First-Class RTL & Internationalization (Arabic & English)](#-first-class-rtl--internationalization-arabic--english)
|
|
50
53
|
- [📌 Column Pinning & Interactive Resizing](#-column-pinning--interactive-resizing)
|
|
54
|
+
- [🆕 v1.4.0 Enterprise Features (Filters, Visibility, Expandable Rows, Inline Edit, Bulk Actions & Summary)](#-v140-enterprise-features)
|
|
51
55
|
- [🧩 Standalone Headless Hook (`useAnyTable`)](#-standalone-headless-hook-useanytable)
|
|
52
56
|
- [🎯 Row Actions & Instant PATCH Switches](#-row-actions--instant-patch-switches)
|
|
53
57
|
- [🛠️ Column Types & Smart Renderers](#️-column-types--smart-renderers)
|
|
@@ -277,6 +281,55 @@ const tableRef = useRef<TableInstance>(null);
|
|
|
277
281
|
tableRef.current?.exportData("csv", "quarterly-report");
|
|
278
282
|
```
|
|
279
283
|
|
|
284
|
+
### ⚡ Server-Side Pagination & Exporting All Filtered Rows
|
|
285
|
+
|
|
286
|
+
When building admin panels with server-side pagination, the frontend only loads the active page (e.g. 10 or 25 rows) out of thousands of records. AnyTable gives you two enterprise-grade patterns to export **all filtered rows**:
|
|
287
|
+
|
|
288
|
+
#### Pattern 1: `fetchAllRows` (Fetch full dataset & let AnyTable generate Excel CSV)
|
|
289
|
+
Provide `fetchAllRows` in `exportable`. AnyTable automatically passes current `search`, `sortBy`, `sortOrder`, and extra parameters, displays a loading spinner on the button, generates the CSV with UTF-8 BOM, and triggers the download:
|
|
290
|
+
|
|
291
|
+
```tsx
|
|
292
|
+
<AnyTable<User>
|
|
293
|
+
api={{
|
|
294
|
+
fetcher: fetchUsersApi, // server-side pagination (10 per page)
|
|
295
|
+
}}
|
|
296
|
+
exportable={{
|
|
297
|
+
csv: true,
|
|
298
|
+
filename: "filtered-users",
|
|
299
|
+
fetchAllRows: async ({ search, sortBy, sortOrder }) => {
|
|
300
|
+
// Calls your endpoint without pagination limit:
|
|
301
|
+
const res = await axios.get("/api/users/all", {
|
|
302
|
+
params: { search, sortBy, sortOrder },
|
|
303
|
+
});
|
|
304
|
+
return res.data;
|
|
305
|
+
},
|
|
306
|
+
}}
|
|
307
|
+
/>
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
#### Pattern 2: `onExport` (Backend Streaming / Full Control)
|
|
311
|
+
For massive datasets (e.g. 100,000+ rows) where generating in browser memory isn't ideal, delegate the export to your backend:
|
|
312
|
+
|
|
313
|
+
```tsx
|
|
314
|
+
<AnyTable<Order>
|
|
315
|
+
api={{ fetcher: fetchOrdersApi }}
|
|
316
|
+
exportable={{
|
|
317
|
+
onExport: async (format, context) => {
|
|
318
|
+
const { search, sortBy, sortOrder, totalRecords } = context;
|
|
319
|
+
// Trigger backend report generation or streaming download:
|
|
320
|
+
window.open(`/api/reports/export?format=${format}&search=${search}&sortBy=${sortBy}`);
|
|
321
|
+
},
|
|
322
|
+
}}
|
|
323
|
+
/>
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
#### Advanced Export Options
|
|
327
|
+
- **`scope`**: `"all"` (all filtered rows, default in client mode & when fetchAllRows is set) | `"current-page"` (active page only) | `"selected"` (checkbox-selected rows).
|
|
328
|
+
- **`showScopeOptions: true`**: Exposes scope choices ("All Filtered", "Current Page", "Selected") in the toolbar dropdown.
|
|
329
|
+
- **`col.exportable: false`**: Exclude specific columns (e.g. actions, internal IDs) from the exported file.
|
|
330
|
+
- **`col.exportFormatter: (value, row) => string`**: Custom cell formatting specifically for CSV/Excel without affecting UI renderers.
|
|
331
|
+
- **`isExporting`**: Reactive loading indicator exposed via `useAnyTable` and `tableRef.current?.isExporting`.
|
|
332
|
+
|
|
280
333
|
---
|
|
281
334
|
|
|
282
335
|
## 🌍 First-Class RTL & Internationalization (Arabic & English)
|
|
@@ -1940,6 +1993,131 @@ export default function UsersPage() {
|
|
|
1940
1993
|
|
|
1941
1994
|
---
|
|
1942
1995
|
|
|
1996
|
+
### 🚀 الحالة 12: ميزات v1.4.0 المتقدمة (الفلاتر، إخفاء الأعمدة، الصفوف الموسّعة، التعديل المباشر، والإجماليات)
|
|
1997
|
+
```tsx
|
|
1998
|
+
<AnyTable
|
|
1999
|
+
locale="ar"
|
|
2000
|
+
dir="rtl"
|
|
2001
|
+
data={orders}
|
|
2002
|
+
selectable
|
|
2003
|
+
columnVisibility={{ storageKey: "ar_orders_cols" }}
|
|
2004
|
+
columnFilters={{ defaultOpen: true }}
|
|
2005
|
+
expandable={{
|
|
2006
|
+
render: (row) => <div>تفاصيل الطلب: {row.items.length} منتجات</div>,
|
|
2007
|
+
}}
|
|
2008
|
+
onCellEdit={async ({ row, columnKey, newValue }) => {
|
|
2009
|
+
await updateOrder(row.id, { [columnKey]: newValue });
|
|
2010
|
+
}}
|
|
2011
|
+
bulkActions={[
|
|
2012
|
+
{ id: "approve", label: "اعتماد المحدد", variant: "primary", onClick: (rows) => approveAll(rows) },
|
|
2013
|
+
]}
|
|
2014
|
+
columns={[
|
|
2015
|
+
{ key: "orderNumber", title: "رقم الطلب", hideable: false, summary: "count" },
|
|
2016
|
+
{ key: "totalAmount", title: "الإجمالي", type: "currency", currency: "EGP", editable: true, summary: "sum" },
|
|
2017
|
+
]}
|
|
2018
|
+
/>
|
|
2019
|
+
```
|
|
2020
|
+
|
|
2021
|
+
---
|
|
2022
|
+
|
|
2023
|
+
## 🆕 v1.4.0 Enterprise Features
|
|
2024
|
+
|
|
2025
|
+
### 1. Column Visibility Toggle & `localStorage` Persistence
|
|
2026
|
+
Let users show/hide columns from the toolbar with automatic persistence in `localStorage`:
|
|
2027
|
+
|
|
2028
|
+
```tsx
|
|
2029
|
+
<AnyTable
|
|
2030
|
+
data={orders}
|
|
2031
|
+
columnVisibility={{ storageKey: "orders_table_cols" }}
|
|
2032
|
+
columns={[
|
|
2033
|
+
{ key: "orderNumber", title: "Order #", hideable: false }, // locked
|
|
2034
|
+
{ key: "customer", title: "Customer" },
|
|
2035
|
+
{ key: "internalNotes", title: "Internal Notes", defaultHidden: true },
|
|
2036
|
+
]}
|
|
2037
|
+
/>
|
|
2038
|
+
```
|
|
2039
|
+
|
|
2040
|
+
### 2. Smart Per-Column Filtering (`columnFilters`)
|
|
2041
|
+
Adds a filter row below headers supporting text search, auto-derived status dropdowns, boolean selectors, dates, and numeric comparison operators (`>=500`, `<=1000`, `>100`, `<50`):
|
|
2042
|
+
|
|
2043
|
+
```tsx
|
|
2044
|
+
<AnyTable
|
|
2045
|
+
data={orders}
|
|
2046
|
+
columnFilters={{ defaultOpen: true }}
|
|
2047
|
+
columns={[
|
|
2048
|
+
{ key: "customer", title: "Customer" },
|
|
2049
|
+
{ key: "status", title: "Status", type: "status", statusMap: { Paid: { variant: "success" } } },
|
|
2050
|
+
{ key: "totalAmount", title: "Total", type: "currency", filterPlaceholder: "e.g. >=1000" },
|
|
2051
|
+
]}
|
|
2052
|
+
/>
|
|
2053
|
+
```
|
|
2054
|
+
In server mode (`api={{ fetcher }}`), active filters are passed directly as `params.filters`.
|
|
2055
|
+
|
|
2056
|
+
### 3. Expandable Master-Detail Rows (`expandable`)
|
|
2057
|
+
Render nested order items, breakdowns, or custom JSX panels per row:
|
|
2058
|
+
|
|
2059
|
+
```tsx
|
|
2060
|
+
<AnyTable
|
|
2061
|
+
data={orders}
|
|
2062
|
+
expandable={{
|
|
2063
|
+
accordion: true,
|
|
2064
|
+
rowExpandable: (row) => row.items.length > 0,
|
|
2065
|
+
render: (row) => <OrderItemsBreakdown items={row.items} />,
|
|
2066
|
+
}}
|
|
2067
|
+
/>
|
|
2068
|
+
```
|
|
2069
|
+
|
|
2070
|
+
### 4. Inline Cell Editing (`onCellEdit`)
|
|
2071
|
+
Double-click any cell marked `editable: true` to edit inline with validation (`validateEdit`), `Enter` to save, and `Escape` to cancel:
|
|
2072
|
+
|
|
2073
|
+
```tsx
|
|
2074
|
+
<AnyTable
|
|
2075
|
+
data={orders}
|
|
2076
|
+
onCellEdit={async ({ row, columnKey, newValue }) => {
|
|
2077
|
+
await api.patch(`/orders/${row.id}`, { [columnKey]: newValue });
|
|
2078
|
+
return true;
|
|
2079
|
+
}}
|
|
2080
|
+
columns={[
|
|
2081
|
+
{
|
|
2082
|
+
key: "totalAmount",
|
|
2083
|
+
title: "Total",
|
|
2084
|
+
type: "currency",
|
|
2085
|
+
editable: true,
|
|
2086
|
+
validateEdit: (val) => (Number(val) <= 0 ? "Amount must be positive" : true),
|
|
2087
|
+
},
|
|
2088
|
+
{ key: "status", title: "Status", type: "status", editable: true, editType: "select" },
|
|
2089
|
+
]}
|
|
2090
|
+
/>
|
|
2091
|
+
```
|
|
2092
|
+
|
|
2093
|
+
### 5. Contextual Bulk Actions Bar (`bulkActions`) & Summary Footer (`col.summary`)
|
|
2094
|
+
Display batch action buttons whenever rows are selected, plus automatic footer aggregations (`"sum"`, `"avg"`, `"min"`, `"max"`, `"count"`, or custom function):
|
|
2095
|
+
|
|
2096
|
+
```tsx
|
|
2097
|
+
<AnyTable
|
|
2098
|
+
data={orders}
|
|
2099
|
+
selectable
|
|
2100
|
+
bulkActions={[
|
|
2101
|
+
{
|
|
2102
|
+
id: "mark-shipped",
|
|
2103
|
+
label: "Mark Shipped",
|
|
2104
|
+
variant: "primary",
|
|
2105
|
+
onClick: async (selectedRows, keys, { clearSelection, refresh }) => {
|
|
2106
|
+
await bulkMarkShipped(keys);
|
|
2107
|
+
clearSelection();
|
|
2108
|
+
await refresh();
|
|
2109
|
+
},
|
|
2110
|
+
},
|
|
2111
|
+
]}
|
|
2112
|
+
columns={[
|
|
2113
|
+
{ key: "orderNumber", title: "Order #", summary: "count" },
|
|
2114
|
+
{ key: "totalAmount", title: "Total", type: "currency", currency: "EGP", summary: "sum" },
|
|
2115
|
+
]}
|
|
2116
|
+
/>
|
|
2117
|
+
```
|
|
2118
|
+
|
|
2119
|
+
---
|
|
2120
|
+
|
|
1943
2121
|
## 📄 License
|
|
1944
2122
|
|
|
1945
2123
|
Distributed under the **MIT License**. Created with ❤️ by [Kareem Elbalshe](https://github.com/kareemelbalshe).
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ColumnDef } from '../types/column.types';
|
|
2
|
+
/**
|
|
3
|
+
* Removes empty, null, or undefined filter entries.
|
|
4
|
+
*/
|
|
5
|
+
export declare function cleanActiveFilters(filters?: Record<string, any>): Record<string, any>;
|
|
6
|
+
/**
|
|
7
|
+
* Filters client-side rows using per-column filter values.
|
|
8
|
+
*/
|
|
9
|
+
export declare function filterRowsByColumns<TData = any>(rows: TData[], filters: Record<string, any>, columns: ColumnDef<TData>[]): TData[];
|
package/dist/adapters/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
import { ColumnDef } from '../types/column.types';
|
|
3
3
|
import { TableAction, ActionContext } from '../types/action.types';
|
|
4
|
+
import { ExpandableConfig, CellEditParams } from '../types/table.types';
|
|
4
5
|
import { TableMessages } from '../i18n';
|
|
5
6
|
export interface TableBodyProps<TData = any> {
|
|
6
7
|
rows: TData[];
|
|
@@ -24,5 +25,10 @@ export interface TableBodyProps<TData = any> {
|
|
|
24
25
|
dir?: "ltr" | "rtl" | "auto";
|
|
25
26
|
actionsWidth?: string | number;
|
|
26
27
|
messages?: TableMessages;
|
|
28
|
+
expandable?: ExpandableConfig<TData>;
|
|
29
|
+
expandedKeys?: Set<string | number>;
|
|
30
|
+
isRowExpandable?: (row: TData, index: number) => boolean;
|
|
31
|
+
onToggleExpandRow?: (key: string | number) => void;
|
|
32
|
+
onCellEdit?: (params: CellEditParams<TData>) => Promise<void | boolean> | void | boolean;
|
|
27
33
|
}
|
|
28
|
-
export declare function TableBody<TData = any>({ rows, columns, actions, actionContext, rowKeyResolver, selectable, selectedKeys, onToggleSelectRow, onRowClick, striped, hoverable, rowClassName, isVirtualized, paddingTop, paddingBottom, startIndex, pinnedStyles, columnWidths, dir, actionsWidth, messages, }: TableBodyProps<TData>): React.JSX.Element;
|
|
34
|
+
export declare function TableBody<TData = any>({ rows, columns, actions, actionContext, rowKeyResolver, selectable, selectedKeys, onToggleSelectRow, onRowClick, striped, hoverable, rowClassName, isVirtualized, paddingTop, paddingBottom, startIndex, pinnedStyles, columnWidths, dir, actionsWidth, messages, expandable, expandedKeys, isRowExpandable, onToggleExpandRow, onCellEdit, }: TableBodyProps<TData>): React.JSX.Element;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { BulkAction } from '../types/table.types';
|
|
3
|
+
import { TableMessages } from '../i18n';
|
|
4
|
+
export interface TableBulkBarProps<TData = any> {
|
|
5
|
+
selectedRows: TData[];
|
|
6
|
+
selectedKeys: (string | number)[];
|
|
7
|
+
bulkActions: BulkAction<TData>[];
|
|
8
|
+
onClearSelection: () => void;
|
|
9
|
+
onRefresh: () => Promise<void>;
|
|
10
|
+
messages?: TableMessages;
|
|
11
|
+
dir?: "ltr" | "rtl" | "auto";
|
|
12
|
+
}
|
|
13
|
+
export declare function TableBulkBar<TData = any>({ selectedRows, selectedKeys, bulkActions, onClearSelection, onRefresh, messages, dir, }: TableBulkBarProps<TData>): React.JSX.Element | null;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { ColumnDef } from '../types/column.types';
|
|
3
|
+
import { TableMessages } from '../i18n';
|
|
4
|
+
export interface TableFooterProps<TData = any> {
|
|
5
|
+
columns: ColumnDef<TData>[];
|
|
6
|
+
rows: TData[];
|
|
7
|
+
hasExpandable?: boolean;
|
|
8
|
+
selectable?: boolean;
|
|
9
|
+
hasActions?: boolean;
|
|
10
|
+
pinnedStyles?: Record<string, React.CSSProperties>;
|
|
11
|
+
columnWidths?: Record<string, number>;
|
|
12
|
+
dir?: "ltr" | "rtl" | "auto";
|
|
13
|
+
messages?: TableMessages;
|
|
14
|
+
}
|
|
15
|
+
export declare function TableFooter<TData = any>({ columns, rows, hasExpandable, selectable, hasActions, pinnedStyles, columnWidths, dir, messages, }: TableFooterProps<TData>): React.JSX.Element | null;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
|
-
import { ColumnDef, SortDirection } from '../types/column.types';
|
|
2
|
+
import { ColumnDef, ColumnFilterOption, SortDirection } from '../types/column.types';
|
|
3
3
|
import { TableMessages } from '../i18n';
|
|
4
4
|
export interface TableHeaderProps<TData = any> {
|
|
5
5
|
columns: ColumnDef<TData>[];
|
|
@@ -9,6 +9,7 @@ export interface TableHeaderProps<TData = any> {
|
|
|
9
9
|
sortBy?: string | null;
|
|
10
10
|
sortOrder?: SortDirection;
|
|
11
11
|
onSort?: (key: string) => void;
|
|
12
|
+
hasExpandable?: boolean;
|
|
12
13
|
selectable?: boolean;
|
|
13
14
|
allSelected?: boolean;
|
|
14
15
|
isIndeterminate?: boolean;
|
|
@@ -21,5 +22,9 @@ export interface TableHeaderProps<TData = any> {
|
|
|
21
22
|
columnWidths?: Record<string, number>;
|
|
22
23
|
onResizeColumn?: (key: string, width: number) => void;
|
|
23
24
|
pinnedStyles?: Record<string, React.CSSProperties>;
|
|
25
|
+
showColumnFilters?: boolean;
|
|
26
|
+
columnFilters?: Record<string, any>;
|
|
27
|
+
onColumnFilterChange?: (key: string, value: any) => void;
|
|
28
|
+
autoFilterOptionsByCol?: Record<string, ColumnFilterOption[]>;
|
|
24
29
|
}
|
|
25
|
-
export declare function TableHeader<TData = any>({ columns, hasActions, actionsTitle, actionsWidth, sortBy, sortOrder, onSort, selectable, allSelected, isIndeterminate, onToggleSelectAll, headerClassName, sticky, messages, dir, resizableColumns, columnWidths, onResizeColumn, pinnedStyles, }: TableHeaderProps<TData>): React.JSX.Element;
|
|
30
|
+
export declare function TableHeader<TData = any>({ columns, hasActions, actionsTitle, actionsWidth, sortBy, sortOrder, onSort, hasExpandable, selectable, allSelected, isIndeterminate, onToggleSelectAll, headerClassName, sticky, messages, dir, resizableColumns, columnWidths, onResizeColumn, pinnedStyles, showColumnFilters, columnFilters, onColumnFilterChange, autoFilterOptionsByCol, }: TableHeaderProps<TData>): React.JSX.Element;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
import { TableMessages } from '../i18n';
|
|
3
|
-
import { ExportConfig } from '../types/table.types';
|
|
3
|
+
import { ExportConfig, ExportScope } from '../types/table.types';
|
|
4
|
+
import { ColumnDef } from '../types/column.types';
|
|
4
5
|
export interface TableToolbarProps {
|
|
5
6
|
displayTitle?: React.ReactNode;
|
|
6
7
|
subtitle?: React.ReactNode;
|
|
@@ -16,7 +17,22 @@ export interface TableToolbarProps {
|
|
|
16
17
|
addHandler?: () => void;
|
|
17
18
|
messages?: TableMessages;
|
|
18
19
|
exportable?: boolean | ExportConfig;
|
|
19
|
-
onExport?: (format: "csv" | "json") => void;
|
|
20
|
+
onExport?: (format: "csv" | "json", scope?: ExportScope) => void;
|
|
21
|
+
isExporting?: boolean;
|
|
22
|
+
hasSelectedRows?: boolean;
|
|
20
23
|
dir?: "ltr" | "rtl" | "auto";
|
|
24
|
+
columnVisibilityEnabled?: boolean;
|
|
25
|
+
allColumns?: ColumnDef<any>[];
|
|
26
|
+
hiddenColumnKeys?: string[];
|
|
27
|
+
onToggleColumnVisibility?: (key: string) => void;
|
|
28
|
+
onResetColumnVisibility?: () => void;
|
|
29
|
+
allowResetColumns?: boolean;
|
|
30
|
+
isVisibilityModified?: boolean;
|
|
31
|
+
columnFiltersEnabled?: boolean;
|
|
32
|
+
isFilterRowOpen?: boolean;
|
|
33
|
+
onToggleFilterRow?: () => void;
|
|
34
|
+
activeFilterCount?: number;
|
|
35
|
+
onClearColumnFilters?: () => void;
|
|
36
|
+
showClearFilters?: boolean;
|
|
21
37
|
}
|
|
22
|
-
export declare function TableToolbar({ displayTitle, subtitle, isSearchEnabled, searchQuery, setSearch, clearSearch, isDebouncing, searchPlaceholder, headerActions, add, linkAdd, addHandler, messages, exportable, onExport, dir, }: TableToolbarProps): React.JSX.Element | null;
|
|
38
|
+
export declare function TableToolbar({ displayTitle, subtitle, isSearchEnabled, searchQuery, setSearch, clearSearch, isDebouncing, searchPlaceholder, headerActions, add, linkAdd, addHandler, messages, exportable, onExport, isExporting, hasSelectedRows, dir, columnVisibilityEnabled, allColumns, hiddenColumnKeys, onToggleColumnVisibility, onResetColumnVisibility, allowResetColumns, isVisibilityModified, columnFiltersEnabled, isFilterRowOpen, onToggleFilterRow, activeFilterCount, onClearColumnFilters, showClearFilters, }: TableToolbarProps): React.JSX.Element | null;
|
|
@@ -2,8 +2,11 @@ export * from './AnyTable';
|
|
|
2
2
|
export * from './TableHeader';
|
|
3
3
|
export * from './TableBody';
|
|
4
4
|
export * from './TableSearch';
|
|
5
|
+
export * from './TableToolbar';
|
|
5
6
|
export * from './TablePagination';
|
|
6
7
|
export * from './TableSkeleton';
|
|
7
8
|
export * from './TableEmptyState';
|
|
8
9
|
export * from './TableErrorState';
|
|
9
10
|
export * from './TableConfirmDialog';
|
|
11
|
+
export * from './TableBulkBar';
|
|
12
|
+
export * from './TableFooter';
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -5,4 +5,7 @@ export * from './useAnyTableData';
|
|
|
5
5
|
export * from './useAnyTableController';
|
|
6
6
|
export * from './useAnyTableSelection';
|
|
7
7
|
export * from './useAnyTableVirtualizer';
|
|
8
|
+
export * from './useAnyTableColumnVisibility';
|
|
9
|
+
export * from './useAnyTableColumnFilters';
|
|
10
|
+
export * from './useAnyTableExpand';
|
|
8
11
|
export * from './useAnyTable';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RowKeyResolver, SearchConfig, SortingConfig, PaginationConfig, ExportConfig } from '../types/table.types';
|
|
1
|
+
import { RowKeyResolver, SearchConfig, SortingConfig, PaginationConfig, ExportConfig, ExportScope, ColumnVisibilityConfig, ColumnFiltersConfig, ExpandableConfig } from '../types/table.types';
|
|
2
2
|
import { ColumnDef } from '../types/column.types';
|
|
3
3
|
import { ApiConfig } from '../types/api.types';
|
|
4
4
|
export interface UseAnyTableOptions<TData = any> {
|
|
@@ -12,15 +12,20 @@ export interface UseAnyTableOptions<TData = any> {
|
|
|
12
12
|
pagination?: boolean | PaginationConfig;
|
|
13
13
|
manualLoading?: boolean;
|
|
14
14
|
onSelectionChange?: (selectedRows: TData[], selectedKeys: (string | number)[]) => void;
|
|
15
|
-
exportable?: boolean | ExportConfig
|
|
15
|
+
exportable?: boolean | ExportConfig<TData>;
|
|
16
|
+
columnVisibility?: boolean | ColumnVisibilityConfig;
|
|
17
|
+
columnFilters?: boolean | ColumnFiltersConfig;
|
|
18
|
+
expandable?: ExpandableConfig<TData>;
|
|
16
19
|
}
|
|
17
20
|
export declare function useAnyTable<TData = any>(options?: UseAnyTableOptions<TData>): {
|
|
18
21
|
rows: TData[];
|
|
19
22
|
columns: ColumnDef<TData, any>[];
|
|
23
|
+
allColumns: ColumnDef<TData, any>[];
|
|
20
24
|
totalRecords: number;
|
|
21
25
|
loading: boolean;
|
|
22
26
|
error: any;
|
|
23
27
|
isServerMode: boolean;
|
|
28
|
+
isExporting: boolean;
|
|
24
29
|
refresh: () => Promise<void>;
|
|
25
30
|
reset: () => void;
|
|
26
31
|
search: {
|
|
@@ -59,5 +64,39 @@ export declare function useAnyTable<TData = any>(options?: UseAnyTableOptions<TD
|
|
|
59
64
|
allSelected: boolean;
|
|
60
65
|
isIndeterminate: boolean;
|
|
61
66
|
};
|
|
62
|
-
|
|
67
|
+
columnVisibility: {
|
|
68
|
+
enabled: boolean;
|
|
69
|
+
allowReset: boolean;
|
|
70
|
+
hiddenColumnKeys: string[];
|
|
71
|
+
visibleColumns: ColumnDef<TData, any>[];
|
|
72
|
+
allColumns: ColumnDef<TData, any>[];
|
|
73
|
+
toggleColumnVisibility: (key: string) => void;
|
|
74
|
+
setHiddenColumns: (keys: string[]) => void;
|
|
75
|
+
resetColumnVisibility: () => void;
|
|
76
|
+
isModified: boolean;
|
|
77
|
+
};
|
|
78
|
+
columnFilters: {
|
|
79
|
+
enabled: boolean;
|
|
80
|
+
mode: "server" | "client" | "auto";
|
|
81
|
+
showClearAll: boolean;
|
|
82
|
+
filters: Record<string, any>;
|
|
83
|
+
activeFilters: Record<string, any>;
|
|
84
|
+
debouncedActiveFilters: Record<string, any>;
|
|
85
|
+
activeFilterCount: number;
|
|
86
|
+
isFilterRowOpen: boolean;
|
|
87
|
+
setIsFilterRowOpen: import('react').Dispatch<import('react').SetStateAction<boolean>>;
|
|
88
|
+
toggleFilterRow: () => void;
|
|
89
|
+
setColumnFilter: (key: string, value: any) => void;
|
|
90
|
+
clearColumnFilters: () => void;
|
|
91
|
+
};
|
|
92
|
+
expandable: {
|
|
93
|
+
enabled: boolean;
|
|
94
|
+
expandedKeys: Set<string | number>;
|
|
95
|
+
expandedKeyList: (string | number)[];
|
|
96
|
+
isRowExpandable: (row: TData, index: number) => boolean;
|
|
97
|
+
toggleExpandRow: (key: string | number) => void;
|
|
98
|
+
expandAllRows: () => void;
|
|
99
|
+
collapseAllRows: () => void;
|
|
100
|
+
};
|
|
101
|
+
exportData: (format?: "csv" | "json", filename?: string, scopeOverride?: ExportScope) => Promise<void>;
|
|
63
102
|
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ColumnFiltersConfig } from '../types/table.types';
|
|
2
|
+
export interface UseAnyTableColumnFiltersParams {
|
|
3
|
+
config?: boolean | ColumnFiltersConfig;
|
|
4
|
+
debounceMs?: number;
|
|
5
|
+
}
|
|
6
|
+
export declare function useAnyTableColumnFilters({ config, debounceMs, }?: UseAnyTableColumnFiltersParams): {
|
|
7
|
+
enabled: boolean;
|
|
8
|
+
mode: "server" | "client" | "auto";
|
|
9
|
+
showClearAll: boolean;
|
|
10
|
+
filters: Record<string, any>;
|
|
11
|
+
activeFilters: Record<string, any>;
|
|
12
|
+
debouncedActiveFilters: Record<string, any>;
|
|
13
|
+
activeFilterCount: number;
|
|
14
|
+
isFilterRowOpen: boolean;
|
|
15
|
+
setIsFilterRowOpen: import('react').Dispatch<import('react').SetStateAction<boolean>>;
|
|
16
|
+
toggleFilterRow: () => void;
|
|
17
|
+
setColumnFilter: (key: string, value: any) => void;
|
|
18
|
+
clearColumnFilters: () => void;
|
|
19
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ColumnDef } from '../types/column.types';
|
|
2
|
+
import { ColumnVisibilityConfig } from '../types/table.types';
|
|
3
|
+
export interface UseAnyTableColumnVisibilityParams<TData = any> {
|
|
4
|
+
columns: ColumnDef<TData>[];
|
|
5
|
+
config?: boolean | ColumnVisibilityConfig;
|
|
6
|
+
}
|
|
7
|
+
export declare function useAnyTableColumnVisibility<TData = any>({ columns, config, }: UseAnyTableColumnVisibilityParams<TData>): {
|
|
8
|
+
enabled: boolean;
|
|
9
|
+
allowReset: boolean;
|
|
10
|
+
hiddenColumnKeys: string[];
|
|
11
|
+
visibleColumns: ColumnDef<TData, any>[];
|
|
12
|
+
allColumns: ColumnDef<TData, any>[];
|
|
13
|
+
toggleColumnVisibility: (key: string) => void;
|
|
14
|
+
setHiddenColumns: (keys: string[]) => void;
|
|
15
|
+
resetColumnVisibility: () => void;
|
|
16
|
+
isModified: boolean;
|
|
17
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
|
-
import { TableInstance, TableState } from '../types/table.types';
|
|
2
|
+
import { TableInstance, TableState, ExportScope } from '../types/table.types';
|
|
3
3
|
import { SortDirection } from '../types/column.types';
|
|
4
4
|
export interface UseAnyTableControllerParams<TData = any> {
|
|
5
5
|
tableRef?: React.Ref<TableInstance<TData>>;
|
|
@@ -15,6 +15,15 @@ export interface UseAnyTableControllerParams<TData = any> {
|
|
|
15
15
|
clearSelection: () => void;
|
|
16
16
|
getState: () => TableState<TData>;
|
|
17
17
|
scrollToIndex?: (index: number, align?: "start" | "center" | "end" | "auto") => void;
|
|
18
|
-
exportData?: (format?: "csv" | "json", filename?: string) => void
|
|
18
|
+
exportData?: (format?: "csv" | "json", filename?: string, scope?: ExportScope) => Promise<void>;
|
|
19
|
+
isExporting?: boolean;
|
|
20
|
+
setColumnFilter?: (key: string, value: any) => void;
|
|
21
|
+
clearColumnFilters?: () => void;
|
|
22
|
+
toggleColumnVisibility?: (key: string) => void;
|
|
23
|
+
setHiddenColumns?: (keys: string[]) => void;
|
|
24
|
+
resetColumnVisibility?: () => void;
|
|
25
|
+
toggleExpandRow?: (key: string | number) => void;
|
|
26
|
+
expandAllRows?: () => void;
|
|
27
|
+
collapseAllRows?: () => void;
|
|
19
28
|
}
|
|
20
|
-
export declare function useAnyTableController<TData = any>({ tableRef, refresh, resetPagination, resetSearch, resetSorting, setPage, setPageSize, setSearch, setSorting, selectedRows, clearSelection, getState, scrollToIndex, exportData, }: UseAnyTableControllerParams<TData>): void;
|
|
29
|
+
export declare function useAnyTableController<TData = any>({ tableRef, refresh, resetPagination, resetSearch, resetSorting, setPage, setPageSize, setSearch, setSorting, selectedRows, clearSelection, getState, scrollToIndex, exportData, isExporting, setColumnFilter, clearColumnFilters, toggleColumnVisibility, setHiddenColumns, resetColumnVisibility, toggleExpandRow, expandAllRows, collapseAllRows, }: UseAnyTableControllerParams<TData>): void;
|
|
@@ -5,6 +5,7 @@ export interface UseAnyTableDataParams<TData = any> {
|
|
|
5
5
|
api?: ApiConfig<TData>;
|
|
6
6
|
columns: ColumnDef<TData>[];
|
|
7
7
|
searchQuery: string;
|
|
8
|
+
columnFilters?: Record<string, any>;
|
|
8
9
|
sortBy: string | null;
|
|
9
10
|
sortOrder: SortDirection;
|
|
10
11
|
page: number;
|
|
@@ -12,8 +13,9 @@ export interface UseAnyTableDataParams<TData = any> {
|
|
|
12
13
|
paginationEnabled?: boolean;
|
|
13
14
|
manualLoading?: boolean;
|
|
14
15
|
}
|
|
15
|
-
export declare function useAnyTableData<TData = any>({ data: directData, api, columns, searchQuery, sortBy, sortOrder, page, pageSize, paginationEnabled, manualLoading, }: UseAnyTableDataParams<TData>): {
|
|
16
|
+
export declare function useAnyTableData<TData = any>({ data: directData, api, columns, searchQuery, columnFilters, sortBy, sortOrder, page, pageSize, paginationEnabled, manualLoading, }: UseAnyTableDataParams<TData>): {
|
|
16
17
|
rows: TData[];
|
|
18
|
+
allFilteredRows: TData[];
|
|
17
19
|
totalRecords: number;
|
|
18
20
|
loading: boolean;
|
|
19
21
|
error: any;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ExpandableConfig } from '../types/table.types';
|
|
2
|
+
export interface UseAnyTableExpandParams<TData = any> {
|
|
3
|
+
config?: ExpandableConfig<TData>;
|
|
4
|
+
rows: TData[];
|
|
5
|
+
rowKeyResolver: (row: TData, index: number) => string | number;
|
|
6
|
+
}
|
|
7
|
+
export declare function useAnyTableExpand<TData = any>({ config, rows, rowKeyResolver, }: UseAnyTableExpandParams<TData>): {
|
|
8
|
+
enabled: boolean;
|
|
9
|
+
expandedKeys: Set<string | number>;
|
|
10
|
+
expandedKeyList: (string | number)[];
|
|
11
|
+
isRowExpandable: (row: TData, index: number) => boolean;
|
|
12
|
+
toggleExpandRow: (key: string | number) => void;
|
|
13
|
+
expandAllRows: () => void;
|
|
14
|
+
collapseAllRows: () => void;
|
|
15
|
+
};
|
package/dist/i18n/messages.d.ts
CHANGED
|
@@ -16,6 +16,10 @@ export interface TableMessages {
|
|
|
16
16
|
exportCsv: string;
|
|
17
17
|
exportJson: string;
|
|
18
18
|
exportSuccess: string;
|
|
19
|
+
exporting: string;
|
|
20
|
+
exportAll: string;
|
|
21
|
+
exportCurrentPage: string;
|
|
22
|
+
exportSelected: string;
|
|
19
23
|
selectAll: string;
|
|
20
24
|
selectRow: string;
|
|
21
25
|
prevPage: string;
|
|
@@ -26,6 +30,26 @@ export interface TableMessages {
|
|
|
26
30
|
addRecord: string;
|
|
27
31
|
clearSearch: string;
|
|
28
32
|
loading: string;
|
|
33
|
+
columns: string;
|
|
34
|
+
resetColumns: string;
|
|
35
|
+
filters: string;
|
|
36
|
+
clearFilters: string;
|
|
37
|
+
filterPlaceholder: string;
|
|
38
|
+
filterAll: string;
|
|
39
|
+
filterTrue: string;
|
|
40
|
+
filterFalse: string;
|
|
41
|
+
expandRow: string;
|
|
42
|
+
collapseRow: string;
|
|
43
|
+
selectedCount: string;
|
|
44
|
+
clearSelection: string;
|
|
45
|
+
summaryTotal: string;
|
|
46
|
+
summarySum: string;
|
|
47
|
+
summaryAvg: string;
|
|
48
|
+
summaryMin: string;
|
|
49
|
+
summaryMax: string;
|
|
50
|
+
summaryCount: string;
|
|
51
|
+
editCellHint: string;
|
|
52
|
+
saving: string;
|
|
29
53
|
}
|
|
30
54
|
export declare const enMessages: TableMessages;
|
|
31
55
|
export declare const arMessages: TableMessages;
|