@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.
- package/CHANGELOG.md +24 -0
- package/README.md +129 -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 +15 -1
- package/dist/components/index.d.ts +3 -0
- package/dist/hooks/index.d.ts +3 -0
- package/dist/hooks/useAnyTable.d.ts +39 -1
- package/dist/hooks/useAnyTableColumnFilters.d.ts +19 -0
- package/dist/hooks/useAnyTableColumnVisibility.d.ts +17 -0
- package/dist/hooks/useAnyTableController.d.ts +9 -1
- package/dist/hooks/useAnyTableData.d.ts +2 -1
- package/dist/hooks/useAnyTableExpand.d.ts +15 -0
- package/dist/i18n/messages.d.ts +20 -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 +2684 -1625
- 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 +50 -0
- package/dist/types/table.types.d.ts +102 -0
- package/package.json +9 -2
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,30 @@ 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
|
+
|
|
7
31
|
## [1.3.0] - 2026-11-16
|
|
8
32
|
|
|
9
33
|
### 🌟 Enterprise Server-Side Export & 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)
|
|
@@ -1989,6 +1993,131 @@ export default function UsersPage() {
|
|
|
1989
1993
|
|
|
1990
1994
|
---
|
|
1991
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
|
+
|
|
1992
2121
|
## 📄 License
|
|
1993
2122
|
|
|
1994
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
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;
|
|
@@ -20,5 +21,18 @@ export interface TableToolbarProps {
|
|
|
20
21
|
isExporting?: boolean;
|
|
21
22
|
hasSelectedRows?: boolean;
|
|
22
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;
|
|
23
37
|
}
|
|
24
|
-
export declare function TableToolbar({ displayTitle, subtitle, isSearchEnabled, searchQuery, setSearch, clearSearch, isDebouncing, searchPlaceholder, headerActions, add, linkAdd, addHandler, messages, exportable, onExport, isExporting, hasSelectedRows, 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, ExportScope } 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> {
|
|
@@ -13,10 +13,14 @@ export interface UseAnyTableOptions<TData = any> {
|
|
|
13
13
|
manualLoading?: boolean;
|
|
14
14
|
onSelectionChange?: (selectedRows: TData[], selectedKeys: (string | number)[]) => void;
|
|
15
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;
|
|
@@ -60,5 +64,39 @@ export declare function useAnyTable<TData = any>(options?: UseAnyTableOptions<TD
|
|
|
60
64
|
allSelected: boolean;
|
|
61
65
|
isIndeterminate: boolean;
|
|
62
66
|
};
|
|
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
|
+
};
|
|
63
101
|
exportData: (format?: "csv" | "json", filename?: string, scopeOverride?: ExportScope) => Promise<void>;
|
|
64
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
|
+
};
|
|
@@ -17,5 +17,13 @@ export interface UseAnyTableControllerParams<TData = any> {
|
|
|
17
17
|
scrollToIndex?: (index: number, align?: "start" | "center" | "end" | "auto") => void;
|
|
18
18
|
exportData?: (format?: "csv" | "json", filename?: string, scope?: ExportScope) => Promise<void>;
|
|
19
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;
|
|
20
28
|
}
|
|
21
|
-
export declare function useAnyTableController<TData = any>({ tableRef, refresh, resetPagination, resetSearch, resetSorting, setPage, setPageSize, setSearch, setSorting, selectedRows, clearSelection, getState, scrollToIndex, exportData, isExporting, }: 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,7 +13,7 @@ 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[];
|
|
17
18
|
allFilteredRows: TData[];
|
|
18
19
|
totalRecords: number;
|
|
@@ -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
|
@@ -30,6 +30,26 @@ export interface TableMessages {
|
|
|
30
30
|
addRecord: string;
|
|
31
31
|
clearSearch: string;
|
|
32
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;
|
|
33
53
|
}
|
|
34
54
|
export declare const enMessages: TableMessages;
|
|
35
55
|
export declare const arMessages: TableMessages;
|