@kareemelbalshe/any-table 1.1.0 → 1.3.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 ADDED
@@ -0,0 +1,87 @@
1
+ # 📝 AnyTable Changelog
2
+
3
+ All notable changes to **AnyTable** (`@kareemelbalshe/any-table`) are documented in this file in adherence with [Semantic Versioning (SemVer)](https://semver.org/).
4
+
5
+ ---
6
+
7
+ ## [1.3.0] - 2026-11-16
8
+
9
+ ### 🌟 Enterprise Server-Side Export & Enhancements
10
+ - 📊 **Server-Side Pagination Export (`fetchAllRows`)**:
11
+ - Full support for exporting **all filtered rows** rather than only the current page when server-side pagination is active.
12
+ - 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.
13
+ - 🚀 **Full-Control Custom Export (`onExport`)**:
14
+ - Added `exportable.onExport?: (format, context) => Promise<void> | void` for enterprise streaming downloads or delegating report generation to backend endpoints.
15
+ - đŸŽ¯ **Client-Side Export Enhancement**:
16
+ - Client-side tables now automatically export **all filtered & sorted records** across pages by default instead of only the active page slice.
17
+ - 📐 **Granular Export Scopes & Column Control**:
18
+ - Added `scope?: "all" | "current-page" | "selected" | "auto"`.
19
+ - Added `showScopeOptions?: boolean` to provide scope sub-options in the toolbar dropdown.
20
+ - Added `col.exportable?: boolean` to exclude specific columns from exports.
21
+ - Added `col.exportFormatter?: (value, row) => string` for custom cell values during export without altering React UI renderers.
22
+ - âŗ **Reactive Export State**:
23
+ - Added `isExporting` state with animated spinner and disabled state on the toolbar button to prevent duplicate export submissions. Exposed on `TableInstance` and `useAnyTable`.
24
+ - đŸ›Ąī¸ **API Stability**:
25
+ - Secured `useAnyTableData` with `apiRef` to prevent re-fetch loops when `api={{ fetcher }}` is defined inline.
26
+
27
+ ---
28
+
29
+ ## [1.1.0] - 2026-10-13
30
+
31
+ ### 🌟 New Features & Enhancements
32
+ - 📊 **Native Zero-Dependency Export Engine**:
33
+ - Export data to **CSV** and **JSON** right from the table toolbar or programmatically.
34
+ - **UTF-8 BOM (`\uFEFF`)** prepended to ensure Microsoft Excel correctly displays Arabic, international characters, and UTF-8 symbols without character corruption.
35
+ - Added `exportable` prop supporting `{ csv: boolean, json: boolean, filename: string }`.
36
+ - Exposed imperative `tableRef.current.exportData(format, filename)` controller method.
37
+ - 🌍 **First-Class Internationalization (i18n) & RTL Support**:
38
+ - Full bidirectional support with `dir="ltr" | "rtl" | "auto"` and `locale="ar" | "en" | string`.
39
+ - Built-in English and Arabic dictionary presets covering search placeholders, empty states, error messages, and pagination controls.
40
+ - Automatic layout mirroring for headers, action buttons, pagination pills, and sort indicators when RTL is active.
41
+ - Custom dictionary overrides via `messages` prop.
42
+ - 📌 **Column Pinning (Sticky Columns)**:
43
+ - Added `pinned: "left" | "right"` support in `ColumnDef`.
44
+ - Sticky offsets calculated dynamically for multi-column horizontal scrolling, with persistent shadows and background opacity.
45
+ - â†”ī¸ **Interactive Column Resizing**:
46
+ - Added `resizableColumns` table prop and `col.resizable` flag.
47
+ - Smooth mouse-drag handles on table header cells with min-width constraints.
48
+ - 🧩 **Standalone Headless Hook (`useAnyTable`)**:
49
+ - Introduced `useAnyTable()` headless hook enabling developers to consume table state, smart auto-columns, API pagination, and sorting with 100% custom UI components (e.g., Shadcn UI, Chakra, Tailwind).
50
+ - đŸˇī¸ **npm Metadata & SEO Expansion**:
51
+ - Expanded keywords and enriched package description for enhanced discoverability on npm registry and GitHub search.
52
+
53
+ ---
54
+
55
+ ## [1.0.4] - 2026-10-12
56
+
57
+ ### ⚡ Architectural Breakthroughs
58
+ - 🚀 **Native Zero-Dependency DOM Virtualization**:
59
+ - Handles **100,000+ rows** with continuous 60fps scrolling and zero frame drops.
60
+ - Renders only visible viewport rows (~25 elements) without external dependencies (`0 KB` runtime overhead).
61
+ - Smooth programmatic scrolling via `tableRef.current.scrollToIndex(index, align)`.
62
+ - 🌐 **Universal React Compatibility**:
63
+ - Fully verified and tested against React 16.8+, React 17, React 18, and React 19.
64
+ - Zero peer dependency warnings.
65
+ - đŸ“Ļ **Zero Runtime Dependencies**:
66
+ - Purged all external runtime libraries (`dependencies: 0`).
67
+ - đŸ•šī¸ **Imperative Controller API**:
68
+ - Seamless support for both `ref={tableRef}` and `tableRef={tableRef}` with full TypeScript generics `<TData>`.
69
+ - â˜‘ī¸ **Cross-Page Selection Persistence**:
70
+ - Retains checked item states across pagination pages.
71
+
72
+ ---
73
+
74
+ ## [1.0.0] - 2026-10-10
75
+
76
+ ### 🚀 Initial Public Release
77
+ - 🧠 **3-Tier Smart REST API Adapter**:
78
+ - Level 1: Automatic zero-config array detection.
79
+ - Level 2: Dot-notation response mapping (`data.records`, `pagination.total`).
80
+ - Level 3: Custom response transformer.
81
+ - 🔍 **Dynamic Columns & Type Inference**:
82
+ - Automatic key extraction and data type detection (currency, dates, badges, boolean switches, avatars, phone numbers).
83
+ - 🎨 **Theme Engine & 8 Presets**:
84
+ - `default`, `midnight`, `emerald`, `ocean`, `luxury`, `crimson`, `minimal`, and `corporate`.
85
+ - Complete Dark Mode support and CSS variables customization.
86
+ - 🔄 **Row Actions & Instant PATCH Switches**:
87
+ - In-place toggle switches for quick server updates.
package/README.md CHANGED
@@ -8,11 +8,34 @@
8
8
  [![TypeScript](https://img.shields.io/badge/TypeScript-Strict%205.0%2B-blue)](https://www.typescriptlang.org/)
9
9
  [![React](https://img.shields.io/badge/React-16.8%2B%20%7C%2017%20%7C%2018%20%7C%2019-61dafb)](https://react.dev/)
10
10
  [![Dependencies](https://img.shields.io/badge/Dependencies-0%20(Zero)-success)](package.json)
11
+ [![RTL & Arabic](https://img.shields.io/badge/RTL%20%26%20Arabic-First--Class-emerald)](https://github.com/kareemelbalshe/anyTable)
12
+
13
+ ---
14
+
15
+ ## 💎 Why AnyTable? (The Value Proposition & Competitive Edge)
16
+
17
+ Building table grids in React is notoriously painful: either you write 100+ lines of TanStack Table boilerplate just to render a simple searchable paginated table, or you import massive enterprise grids (AG-Grid, MUI DataGrid) that bloat your bundle size and lock advanced features behind paid enterprise licenses.
18
+
19
+ **AnyTable solves this once and for all:**
20
+
21
+ | Feature / Metric | 🚀 **AnyTable** | đŸĸ TanStack Table | đŸ’ŧ AG-Grid | 🎨 MUI DataGrid |
22
+ | :--- | :--- | :--- | :--- | :--- |
23
+ | **Setup Boilerplate** | **0 lines** (`<AnyTable data={d} />`) | 80–150+ lines boilerplate | 40+ lines config | 30+ lines config |
24
+ | **Runtime Dependencies** | **0 (Zero Dependencies)** | Depends on core hooks | Heavy (~300KB–1.2MB) | Heavy (MUI ecosystem) |
25
+ | **DOM Virtualization (100k+ rows)** | **Built-in (Native 60fps)** | Requires `@tanstack/react-virtual` | Paid Enterprise / Heavy | Paid Pro / Heavy |
26
+ | **REST API 3-Tier Auto Normalizer** | **Built-in Auto-Detect** | Manual wiring | Manual | Manual |
27
+ | **Native CSV & Excel Export** | **Built-in (UTF-8 BOM)** | Needs external library | Paid Enterprise | Paid Pro |
28
+ | **First-Class Arabic & RTL Support** | **Built-in (`dir="rtl"`)** | Manual CSS overrides | Basic | Basic |
29
+ | **Column Resizing & Pinning** | **Built-in** | Complex manual setup | Enterprise | Pro only |
30
+ | **Headless Mode Available** | **Yes (`useAnyTable()`)** | Yes | No (Strict UI) | No (Strict UI) |
31
+ | **React Compatibility** | **React 16.8+ to 19+** | React 18+ mostly | React 17+ | React 17+ |
32
+ | **License** | **100% Free MIT** | MIT (headless only) | Free / $$ Enterprise | Free / $$ Commercial |
11
33
 
12
34
  ---
13
35
 
14
36
  ## 📑 Table of Contents (ŲŲ‡ØąØŗ Ø§Ų„Ų…Ø­ØĒŲˆŲŠØ§ØĒ)
15
37
 
38
+ - [💎 Why AnyTable? (The Value Proposition)](#-why-anytable-the-value-proposition--competitive-edge)
16
39
  - [🌟 Core Philosophy & Architecture](#-core-philosophy--architecture)
17
40
  - [đŸ“Ļ Installation & Setup](#-installation--setup)
18
41
  - [⚡ Quick Start Guide (Ø¯Ų„ŲŠŲ„ Ø§Ų„Ø¨Ø¯ØĄ Ø§Ų„ØŗØąŲŠØš)](#-quick-start-guide)
@@ -22,10 +45,11 @@
22
45
  - [Level 1: Auto (Zero-Config Array Detection)](#level-1-auto-zero-config-array-detection)
23
46
  - [Level 2: Dot-Notation Path Mapping](#level-2-dot-notation-path-mapping)
24
47
  - [Level 3: Custom Response Transformer](#level-3-custom-response-transformer)
48
+ - [📊 Built-in CSV & Excel Export Engine](#-built-in-csv--excel-export-engine)
49
+ - [🌍 First-Class RTL & Internationalization (Arabic & English)](#-first-class-rtl--internationalization-arabic--english)
50
+ - [📌 Column Pinning & Interactive Resizing](#-column-pinning--interactive-resizing)
51
+ - [🧩 Standalone Headless Hook (`useAnyTable`)](#-standalone-headless-hook-useanytable)
25
52
  - [đŸŽ¯ Row Actions & Instant PATCH Switches](#-row-actions--instant-patch-switches)
26
- - [Action Buttons & Modal Triggers](#1-action-buttons)
27
- - [Instant PATCH / PUT Toggle Switch](#2-instant-patch--put-toggle-switch)
28
- - [Destructive Actions with Confirmation Modal](#3-destructive-actions-with-confirmation-modal)
29
53
  - [đŸ› ī¸ Column Types & Smart Renderers](#ī¸-column-types--smart-renderers)
30
54
  - [đŸ•šī¸ Imperative Controller API (`tableRef`)](#ī¸-imperative-controller-api-tableref)
31
55
  - [⚡ High-Performance DOM Virtualization (100,000+ Rows)](#-high-performance-dom-virtualization-100000-rows)
@@ -230,6 +254,170 @@ For legacy endpoints or GraphQL formats that require custom parsing:
230
254
 
231
255
  ---
232
256
 
257
+ ## 📊 Built-in CSV & Excel Export Engine
258
+
259
+ Export your data to **CSV** or **JSON** instantly with zero external dependencies. AnyTable automatically injects the **UTF-8 BOM (`\uFEFF`)** byte mark, guaranteeing that Microsoft Excel opens files with Arabic, UTF-8 symbols, and special characters cleanly without broken encoding!
260
+
261
+ ```tsx
262
+ <AnyTable
263
+ data={employees}
264
+ exportable={{
265
+ csv: true,
266
+ json: true,
267
+ filename: "employees-report-2026",
268
+ }}
269
+ />
270
+ ```
271
+
272
+ Or trigger downloads programmatically via the imperative ref:
273
+ ```tsx
274
+ const tableRef = useRef<TableInstance>(null);
275
+
276
+ // In your custom button:
277
+ tableRef.current?.exportData("csv", "quarterly-report");
278
+ ```
279
+
280
+ ### ⚡ Server-Side Pagination & Exporting All Filtered Rows
281
+
282
+ 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**:
283
+
284
+ #### Pattern 1: `fetchAllRows` (Fetch full dataset & let AnyTable generate Excel CSV)
285
+ 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:
286
+
287
+ ```tsx
288
+ <AnyTable<User>
289
+ api={{
290
+ fetcher: fetchUsersApi, // server-side pagination (10 per page)
291
+ }}
292
+ exportable={{
293
+ csv: true,
294
+ filename: "filtered-users",
295
+ fetchAllRows: async ({ search, sortBy, sortOrder }) => {
296
+ // Calls your endpoint without pagination limit:
297
+ const res = await axios.get("/api/users/all", {
298
+ params: { search, sortBy, sortOrder },
299
+ });
300
+ return res.data;
301
+ },
302
+ }}
303
+ />
304
+ ```
305
+
306
+ #### Pattern 2: `onExport` (Backend Streaming / Full Control)
307
+ For massive datasets (e.g. 100,000+ rows) where generating in browser memory isn't ideal, delegate the export to your backend:
308
+
309
+ ```tsx
310
+ <AnyTable<Order>
311
+ api={{ fetcher: fetchOrdersApi }}
312
+ exportable={{
313
+ onExport: async (format, context) => {
314
+ const { search, sortBy, sortOrder, totalRecords } = context;
315
+ // Trigger backend report generation or streaming download:
316
+ window.open(`/api/reports/export?format=${format}&search=${search}&sortBy=${sortBy}`);
317
+ },
318
+ }}
319
+ />
320
+ ```
321
+
322
+ #### Advanced Export Options
323
+ - **`scope`**: `"all"` (all filtered rows, default in client mode & when fetchAllRows is set) | `"current-page"` (active page only) | `"selected"` (checkbox-selected rows).
324
+ - **`showScopeOptions: true`**: Exposes scope choices ("All Filtered", "Current Page", "Selected") in the toolbar dropdown.
325
+ - **`col.exportable: false`**: Exclude specific columns (e.g. actions, internal IDs) from the exported file.
326
+ - **`col.exportFormatter: (value, row) => string`**: Custom cell formatting specifically for CSV/Excel without affecting UI renderers.
327
+ - **`isExporting`**: Reactive loading indicator exposed via `useAnyTable` and `tableRef.current?.isExporting`.
328
+
329
+ ---
330
+
331
+ ## 🌍 First-Class RTL & Internationalization (Arabic & English)
332
+
333
+ AnyTable is built from the ground up with bidirectional **RTL-First** architecture. Simply pass `dir="rtl"` or `locale="ar"`:
334
+
335
+ ```tsx
336
+ <AnyTable
337
+ data={users}
338
+ dir="rtl"
339
+ locale="ar"
340
+ title="Ų‚Ø§ØĻŲ…ØŠ Ø§Ų„Ų…ØŗØĒØŽØ¯Ų…ŲŠŲ† ŲˆØ§Ų„Ų…ŲˆØ¸ŲŲŠŲ†"
341
+ />
342
+ ```
343
+
344
+ - **Automatic Mirroring**: Headers, actions column, search bar, sort indicators, and pagination arrows flip to Arabic RTL layout automatically.
345
+ - **Built-in Dictionaries**: Full presets for English (`"en"`) and Arabic (`"ar"`).
346
+ - **Custom Messages**: Override any label via the `messages` prop:
347
+ ```tsx
348
+ <AnyTable
349
+ data={orders}
350
+ locale="ar"
351
+ messages={{
352
+ searchPlaceholder: "ابحØĢ Ø¨ØąŲ‚Ų… Ø§Ų„ØˇŲ„Ø¨ ØŖŲˆ Ø§Ų„ØšŲ…ŲŠŲ„...",
353
+ exportCsv: "ØĒØ­Ų…ŲŠŲ„ ØĒŲ‚ØąŲŠØą ØĨŲƒØŗŲ„",
354
+ }}
355
+ />
356
+ ```
357
+
358
+ ---
359
+
360
+ ## 📌 Column Pinning & Interactive Resizing
361
+
362
+ For dense tables with many columns, pin critical columns to the left or right edge, and allow users to resize column widths dynamically:
363
+
364
+ ```tsx
365
+ <AnyTable
366
+ data={orders}
367
+ resizableColumns={true} // Enables draggable column resize handles
368
+ columns={[
369
+ { key: "id", title: "Order ID", width: 90, pinned: "left" }, // Sticky Left
370
+ { key: "customer.name", title: "Customer", width: 180 },
371
+ { key: "total", title: "Amount", width: 120 },
372
+ { key: "status", title: "Status", width: 130, pinned: "right" }, // Sticky Right
373
+ ]}
374
+ />
375
+ ```
376
+
377
+ ---
378
+
379
+ ## 🧩 Standalone Headless Hook (`useAnyTable`)
380
+
381
+ Want 100% custom UI styling (e.g. Shadcn UI, Radix, Tailwind CSS) while leveraging AnyTable's smart auto-columns, 3-tier API detector, server/client pagination, debounced search, sorting, and export engine?
382
+
383
+ Use the headless hook:
384
+
385
+ ```tsx
386
+ import { useAnyTable } from "@kareemelbalshe/any-table";
387
+
388
+ export function CustomGrid() {
389
+ const {
390
+ rows,
391
+ columns,
392
+ totalRecords,
393
+ loading,
394
+ search,
395
+ sorting,
396
+ pagination,
397
+ selection,
398
+ exportData,
399
+ } = useAnyTable({
400
+ data: myData,
401
+ pagination: { defaultPageSize: 10 },
402
+ });
403
+
404
+ return (
405
+ <div>
406
+ <input
407
+ value={search.query}
408
+ onChange={(e) => search.setSearch(e.target.value)}
409
+ placeholder="Type to search..."
410
+ />
411
+ <button onClick={() => exportData("csv")}>Export to Excel</button>
412
+
413
+ {/* Render your custom table or card grid */}
414
+ </div>
415
+ );
416
+ }
417
+ ```
418
+
419
+ ---
420
+
233
421
  ## 🌐 Real-World External Public API Recipes
234
422
 
235
423
  AnyTable connects seamlessly to any external public REST API with zero boilerplate:
@@ -1,3 +1,4 @@
1
1
  export * from './typeDetector';
2
2
  export * from './autoColumns';
3
3
  export * from './columnResolver';
4
+ export * from './pinningUtils';
@@ -0,0 +1,17 @@
1
+ import { default as React } from 'react';
2
+ import { ColumnDef } from '../types/column.types';
3
+ export interface PinningOptions {
4
+ selectable?: boolean;
5
+ hasActions?: boolean;
6
+ actionsWidth?: number | string;
7
+ columnWidths?: Record<string, number>;
8
+ isRtl?: boolean;
9
+ }
10
+ /**
11
+ * Parses width string or number into pixel numeric value if possible.
12
+ */
13
+ export declare function parsePixelWidth(width?: string | number): number;
14
+ /**
15
+ * Computes sticky positioning styles for pinned columns (left or right).
16
+ */
17
+ export declare function computePinnedStyles<TData = any>(columns: ColumnDef<TData>[], options?: PinningOptions): Record<string, React.CSSProperties>;
@@ -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 { TableMessages } from '../i18n';
4
5
  export interface TableBodyProps<TData = any> {
5
6
  rows: TData[];
6
7
  columns: ColumnDef<TData>[];
@@ -18,5 +19,10 @@ export interface TableBodyProps<TData = any> {
18
19
  paddingTop?: number;
19
20
  paddingBottom?: number;
20
21
  startIndex?: number;
22
+ pinnedStyles?: Record<string, React.CSSProperties>;
23
+ columnWidths?: Record<string, number>;
24
+ dir?: "ltr" | "rtl" | "auto";
25
+ actionsWidth?: string | number;
26
+ messages?: TableMessages;
21
27
  }
22
- export declare function TableBody<TData = any>({ rows, columns, actions, actionContext, rowKeyResolver, selectable, selectedKeys, onToggleSelectRow, onRowClick, striped, hoverable, rowClassName, isVirtualized, paddingTop, paddingBottom, startIndex, }: TableBodyProps<TData>): React.JSX.Element;
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;
@@ -1,9 +1,11 @@
1
1
  import { default as React } from 'react';
2
+ import { TableMessages } from '../i18n';
2
3
  export interface TableEmptyStateProps {
3
4
  title?: string;
4
5
  description?: string;
5
6
  isSearchActive?: boolean;
6
7
  onClearSearch?: () => void;
7
8
  colSpan?: number;
9
+ messages?: TableMessages;
8
10
  }
9
- export declare function TableEmptyState({ title, description, isSearchActive, onClearSearch, colSpan, }: TableEmptyStateProps): React.JSX.Element;
11
+ export declare function TableEmptyState({ title, description, isSearchActive, onClearSearch, colSpan, messages, }: TableEmptyStateProps): React.JSX.Element;
@@ -1,6 +1,8 @@
1
1
  import { default as React } from 'react';
2
+ import { TableMessages } from '../i18n';
2
3
  export interface TableErrorStateProps {
3
4
  error: any;
4
5
  onRetry?: () => void;
6
+ messages?: TableMessages;
5
7
  }
6
- export declare function TableErrorState({ error, onRetry }: TableErrorStateProps): React.JSX.Element;
8
+ export declare function TableErrorState({ error, onRetry, messages, }: TableErrorStateProps): React.JSX.Element;
@@ -1,5 +1,6 @@
1
1
  import { default as React } from 'react';
2
2
  import { ColumnDef, SortDirection } from '../types/column.types';
3
+ import { TableMessages } from '../i18n';
3
4
  export interface TableHeaderProps<TData = any> {
4
5
  columns: ColumnDef<TData>[];
5
6
  hasActions?: boolean;
@@ -14,5 +15,11 @@ export interface TableHeaderProps<TData = any> {
14
15
  onToggleSelectAll?: () => void;
15
16
  headerClassName?: string;
16
17
  sticky?: boolean;
18
+ messages?: TableMessages;
19
+ dir?: "ltr" | "rtl" | "auto";
20
+ resizableColumns?: boolean;
21
+ columnWidths?: Record<string, number>;
22
+ onResizeColumn?: (key: string, width: number) => void;
23
+ pinnedStyles?: Record<string, React.CSSProperties>;
17
24
  }
18
- export declare function TableHeader<TData = any>({ columns, hasActions, actionsTitle, actionsWidth, sortBy, sortOrder, onSort, selectable, allSelected, isIndeterminate, onToggleSelectAll, headerClassName, sticky, }: TableHeaderProps<TData>): React.JSX.Element;
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;
@@ -1,4 +1,5 @@
1
1
  import { default as React } from 'react';
2
+ import { TableMessages } from '../i18n';
2
3
  export interface TablePaginationProps {
3
4
  page: number;
4
5
  pageSize: number;
@@ -10,5 +11,7 @@ export interface TablePaginationProps {
10
11
  showPageSizeSelector?: boolean;
11
12
  showTotalCount?: boolean;
12
13
  pageWindow: number[];
14
+ messages?: TableMessages;
15
+ dir?: "ltr" | "rtl" | "auto";
13
16
  }
14
- export declare function TablePagination({ page, pageSize, totalRecords, totalPages, pageSizeOptions, onPageChange, onPageSizeChange, showPageSizeSelector, showTotalCount, pageWindow, }: TablePaginationProps): React.JSX.Element;
17
+ export declare function TablePagination({ page, pageSize, totalRecords, totalPages, pageSizeOptions, onPageChange, onPageSizeChange, showPageSizeSelector, showTotalCount, pageWindow, messages, dir, }: TablePaginationProps): React.JSX.Element;
@@ -1,4 +1,6 @@
1
1
  import { default as React } from 'react';
2
+ import { TableMessages } from '../i18n';
3
+ import { ExportConfig, ExportScope } from '../types/table.types';
2
4
  export interface TableToolbarProps {
3
5
  displayTitle?: React.ReactNode;
4
6
  subtitle?: React.ReactNode;
@@ -12,5 +14,11 @@ export interface TableToolbarProps {
12
14
  add?: boolean;
13
15
  linkAdd?: string;
14
16
  addHandler?: () => void;
17
+ messages?: TableMessages;
18
+ exportable?: boolean | ExportConfig;
19
+ onExport?: (format: "csv" | "json", scope?: ExportScope) => void;
20
+ isExporting?: boolean;
21
+ hasSelectedRows?: boolean;
22
+ dir?: "ltr" | "rtl" | "auto";
15
23
  }
16
- export declare function TableToolbar({ displayTitle, subtitle, isSearchEnabled, searchQuery, setSearch, clearSearch, isDebouncing, searchPlaceholder, headerActions, add, linkAdd, addHandler, }: TableToolbarProps): React.JSX.Element | null;
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;
@@ -0,0 +1,26 @@
1
+ import { ColumnDef } from '../types/column.types';
2
+ export interface ExportOptions<TData = any> {
3
+ filename?: string;
4
+ columns?: ColumnDef<TData>[];
5
+ includeHidden?: boolean;
6
+ }
7
+ /**
8
+ * Escapes a cell string for safe CSV inclusion (RFC 4180 standard).
9
+ */
10
+ export declare function escapeCsvValue(val: any): string;
11
+ /**
12
+ * Converts table data rows and columns definition into RFC 4180 compliant CSV string with UTF-8 BOM.
13
+ */
14
+ export declare function generateCsvContent<TData = any>(data: TData[], columns: ColumnDef<TData>[]): string;
15
+ /**
16
+ * Triggers a native browser file download using a Blob and anchor element.
17
+ */
18
+ export declare function triggerDownload(content: string | Blob, filename: string, mimeType: string): void;
19
+ /**
20
+ * Exports table data to CSV file with UTF-8 BOM.
21
+ */
22
+ export declare function exportToCsv<TData = any>(data: TData[], columns: ColumnDef<TData>[], filename?: string): void;
23
+ /**
24
+ * Exports table data to formatted JSON file.
25
+ */
26
+ export declare function exportToJson<TData = any>(data: TData[], filename?: string): void;
@@ -0,0 +1 @@
1
+ export * from './exportEngine';
@@ -5,3 +5,4 @@ export * from './useAnyTableData';
5
5
  export * from './useAnyTableController';
6
6
  export * from './useAnyTableSelection';
7
7
  export * from './useAnyTableVirtualizer';
8
+ export * from './useAnyTable';
@@ -0,0 +1,64 @@
1
+ import { RowKeyResolver, SearchConfig, SortingConfig, PaginationConfig, ExportConfig, ExportScope } from '../types/table.types';
2
+ import { ColumnDef } from '../types/column.types';
3
+ import { ApiConfig } from '../types/api.types';
4
+ export interface UseAnyTableOptions<TData = any> {
5
+ data?: TData[];
6
+ api?: ApiConfig<TData>;
7
+ columns?: (ColumnDef<TData> | (keyof TData & string))[];
8
+ autoColumns?: boolean;
9
+ rowKey?: RowKeyResolver<TData>;
10
+ search?: boolean | SearchConfig<TData>;
11
+ sorting?: boolean | SortingConfig<TData>;
12
+ pagination?: boolean | PaginationConfig;
13
+ manualLoading?: boolean;
14
+ onSelectionChange?: (selectedRows: TData[], selectedKeys: (string | number)[]) => void;
15
+ exportable?: boolean | ExportConfig<TData>;
16
+ }
17
+ export declare function useAnyTable<TData = any>(options?: UseAnyTableOptions<TData>): {
18
+ rows: TData[];
19
+ columns: ColumnDef<TData, any>[];
20
+ totalRecords: number;
21
+ loading: boolean;
22
+ error: any;
23
+ isServerMode: boolean;
24
+ isExporting: boolean;
25
+ refresh: () => Promise<void>;
26
+ reset: () => void;
27
+ search: {
28
+ enabled: boolean;
29
+ query: string;
30
+ isDebouncing: boolean;
31
+ setSearch: (val: string) => void;
32
+ clearSearch: () => void;
33
+ placeholder: string | undefined;
34
+ };
35
+ sorting: {
36
+ enabled: boolean;
37
+ sortBy: string | null;
38
+ sortOrder: import('..').SortDirection;
39
+ toggleSort: (columnKey: string) => void;
40
+ setSorting: (newSortBy: string | null, newSortOrder: import('..').SortDirection) => void;
41
+ resetSorting: () => void;
42
+ };
43
+ pagination: {
44
+ enabled: boolean;
45
+ page: number;
46
+ pageSize: number;
47
+ totalPages: number;
48
+ pageSizeOptions: number[];
49
+ setPage: (newPage: number) => void;
50
+ setPageSize: (newSize: number) => void;
51
+ resetPagination: () => void;
52
+ getPageWindow: (maxVisible?: number) => number[];
53
+ };
54
+ selection: {
55
+ selectedKeys: Set<string | number>;
56
+ selectedRows: NonNullable<TData>[];
57
+ toggleSelectRow: (key: string | number, row: TData) => void;
58
+ toggleSelectAll: () => void;
59
+ clearSelection: () => void;
60
+ allSelected: boolean;
61
+ isIndeterminate: boolean;
62
+ };
63
+ exportData: (format?: "csv" | "json", filename?: string, scopeOverride?: ExportScope) => Promise<void>;
64
+ };
@@ -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,5 +15,7 @@ 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, scope?: ExportScope) => Promise<void>;
19
+ isExporting?: boolean;
18
20
  }
19
- export declare function useAnyTableController<TData = any>({ tableRef, refresh, resetPagination, resetSearch, resetSorting, setPage, setPageSize, setSearch, setSorting, selectedRows, clearSelection, getState, scrollToIndex, }: UseAnyTableControllerParams<TData>): void;
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;
@@ -14,6 +14,7 @@ export interface UseAnyTableDataParams<TData = any> {
14
14
  }
15
15
  export declare function useAnyTableData<TData = any>({ data: directData, api, columns, searchQuery, sortBy, sortOrder, page, pageSize, paginationEnabled, manualLoading, }: UseAnyTableDataParams<TData>): {
16
16
  rows: TData[];
17
+ allFilteredRows: TData[];
17
18
  totalRecords: number;
18
19
  loading: boolean;
19
20
  error: any;
@@ -0,0 +1 @@
1
+ export * from './messages';
@@ -0,0 +1,36 @@
1
+ export interface TableMessages {
2
+ searchPlaceholder: string;
3
+ noRecordsTitle: string;
4
+ noRecordsDescription: string;
5
+ errorTitle: string;
6
+ errorDescription: string;
7
+ retry: string;
8
+ showing: string;
9
+ to: string;
10
+ of: string;
11
+ results: string;
12
+ page: string;
13
+ rowsPerPage: string;
14
+ actions: string;
15
+ export: string;
16
+ exportCsv: string;
17
+ exportJson: string;
18
+ exportSuccess: string;
19
+ exporting: string;
20
+ exportAll: string;
21
+ exportCurrentPage: string;
22
+ exportSelected: string;
23
+ selectAll: string;
24
+ selectRow: string;
25
+ prevPage: string;
26
+ nextPage: string;
27
+ confirmTitle: string;
28
+ confirmButton: string;
29
+ cancelButton: string;
30
+ addRecord: string;
31
+ clearSearch: string;
32
+ loading: string;
33
+ }
34
+ export declare const enMessages: TableMessages;
35
+ export declare const arMessages: TableMessages;
36
+ export declare function resolveMessages(locale?: string, customMessages?: Partial<TableMessages>): TableMessages;