@akshar-technosoft/ui 1.1.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -146,6 +146,8 @@ Required: `placeholder`, plus either `key` (path filter) or `id` + `filterFn` (c
146
146
  onExternalSearch={(values) => setSearchFilters(values)} // feed your query params
147
147
  ```
148
148
 
149
+ **Why one table-level callback and not per-filter?** A server query is ONE request carrying all params. Every commit hands you the **complete staged map** — with two external filters (say `Date` and `PartyName`), picking a date fires `{ Date: {...} }`, then typing a party fires `{ Date: {...}, PartyName: "xy" }`: both values together, every time. The page builds params in one place and runs one query; any number of external filters just adds keys to the same map. Clearing fires `{}`.
150
+
149
151
  Local and external filters mix freely on one table: external narrows what you fetch, local narrows the fetched rows.
150
152
 
151
153
  ### Global search & the field picker
@@ -295,7 +297,26 @@ onExport={(data, view) => buildQcExcel(view)} // Settings menu > Export (item
295
297
  const view = getTableExportView(table);
296
298
  ```
297
299
 
298
- `TableExportView` = `columns` (visible, display+pin order, select/serial excluded) + `rows` (cell values in column order, native types preserved so writers can format real numbers/dates) + `originals` (filtered+sorted row objects). Rows come from the pre-pagination model: filtered and sorted, ALL pages.
300
+ **What the two arguments are:**
301
+
302
+ - `data: T[]` — the filtered + sorted **row originals** (your objects, all pages, not just the visible one). It is literally `view.originals` — kept as the first arg so simple handlers can ignore `view`.
303
+ - `view: TableExportView<T>` — the ready-to-write snapshot:
304
+
305
+ ```ts
306
+ {
307
+ columns: [ // VISIBLE columns only, in display + pin order,
308
+ { id: "FullCPOSrNo", header: "Order No." }, // select/serialNumber excluded;
309
+ { id: "Qty", header: "Qty" }, // header = exportHeader ?? string header ?? id
310
+ ],
311
+ rows: [ // one array per row, values in `columns` order,
312
+ ["CPO-101", 250], // native types kept (number/Date/boolean — real
313
+ ["CPO-102", 480], // Excel cells, not strings)
314
+ ],
315
+ originals: [ {...}, {...} ], // same rows as objects, same order as `rows`
316
+ }
317
+ ```
318
+
319
+ Rows come from the pre-pagination model: filtered and sorted, ALL pages. Typical writer: header row from `view.columns.map(c => c.header)`, data rows straight from `view.rows`; reach into `view.originals` when the sheet needs fields that aren't visible columns.
299
320
 
300
321
  A column is included when it has an accessor or `exportValue`. Display-only columns are skipped unless `exportValue` supplies a flat value — also the tool for JSX composite cells:
301
322
 
@@ -338,7 +359,56 @@ Taxonomy: `show*` = a UI element/region is visible · `enable*` = a capability i
338
359
  | `toolbarPosition` | `'default'` | `'above-header'` / `'below-header'` |
339
360
  | `groupedFilterLabel` | `"Global"` | Field picker "all" label |
340
361
 
341
- Remaining props: `header` (node or `{ content, align, className, showOnEmpty }` — a sticky title band inside the card), `footer` (sticky full-width bottom band), `maxHeight` (scroll container, default `"100%"`), `loading` (overlay), `error` + `onRefresh` (error card with Try Again), `emptyMessage`, `rowClassName={(row) => class}` (status-based row colouring), `onTableReady={(table) => …}` (imperative escape hatch — fires once per table instance), `children={(table) => …}` (render-prop, e.g. the action bar).
362
+ ## Complete props reference
363
+
364
+ Every prop `DataTable` accepts — this is the whole surface, nothing else exists:
365
+
366
+ | Prop | Type | Default | What it does |
367
+ |---|---|---|---|
368
+ | `data` | `T[]` | required | Row data, rendered client-side |
369
+ | `columns` | `GroupColumnDef<T>[]` | required | Column defs ([Columns](#columns)) |
370
+ | `filters` | `FilterConfig<T>[]` | — | Toolbar filter controls ([Filters](#filters--the-full-story)) |
371
+ | `pagination` | `PaginationConfig` | — | Presence enables paging ([Pagination](#pagination)) |
372
+ | `settings` | `TableSettings` | `{}` | Feature/presentation toggles (table above) |
373
+ | `header` | node or `{ content, align, className, showOnEmpty }` | — | Sticky title band inside the card; `showOnEmpty` (default true) keeps it on empty data |
374
+ | `footer` | `ReactNode` | — | Sticky full-width bottom band |
375
+ | `className` | `string` | — | Outer wrapper classes |
376
+ | `maxHeight` | `string` | `"100%"` | Scroll container cap — what makes header/footer sticky |
377
+ | `loading` | `boolean` | `false` | Spinner overlay over the card |
378
+ | `error` | `string` | — | Replaces the table with an error card (+ Try Again when `onRefresh` given) |
379
+ | `emptyMessage` | `string` | `"No data available"` | Empty-state text |
380
+ | `onRowSelectionChange` | `(rows: T[]) => void` | — | Selected originals on every change ([Selection](#selection)) |
381
+ | `onExport` | `(data, view) => void` | — | Enables the Settings-menu Export item ([Export](#export)) |
382
+ | `onRefresh` | `() => void` | — | Toolbar Refresh button + error-card Try Again |
383
+ | `onTableReady` | `(table) => void` | — | TanStack instance escape hatch; fires once per instance |
384
+ | `children` | `(table) => ReactNode` | — | Render-prop (action bar etc.) |
385
+ | `isRowSelectable` | `(row: T) => boolean` | — | Row-level selection gate |
386
+ | `getRowId` | `(row, index) => string` | — | Stable row identity ([Selection](#selection)) |
387
+ | `defaultSelectedRows` | `(row: T) => boolean` | — | Uncontrolled selection prefill, seeded once |
388
+ | `onExternalSearch` | `(values) => void` | — | Server-filter commit callback ([External filters](#external-server-filters)) |
389
+ | `aggregations` | `AggregationConfigMap<T>` | `{}` | Footer computations ([Aggregations](#aggregations)) |
390
+ | `onAggregationChange` | `(columnId, config) => void` | — | Enables the toolbar Aggregations menu |
391
+ | `rowClassName` | `(row: Row<T>) => string` | — | Per-row classes (status colouring) |
392
+ | `persist` | `string \| PersistConfig` | — | State persistence ([Persist](#persist)) |
393
+
394
+ `FilterConfig` fields (per filter):
395
+
396
+ | Field | Required | Notes |
397
+ |---|---|---|
398
+ | `placeholder` | yes | Label everywhere: control, chip, field picker |
399
+ | `key` | one of | Data dot-path (path filter) |
400
+ | `id` + `filterFn(row, value)` | one of | Custom predicate filter |
401
+ | `type` | no (`"text"`) | `text` / `select` / `date` / `daterange` / `number` |
402
+ | `options` | with `select` | `{ label, value }[]` |
403
+ | `placement` | no (`"bar"`) | `"menu"` = behind the field picker + chip |
404
+ | `externalSearch` | no (`false`) | Server-side |
405
+ | `width`, `icon`, `dateFormat` | no | Cosmetic |
406
+ | `shared` | no | Group-wide value slot (needs `persist.group`) |
407
+ | `persist` | no (`true`) | `false` = exclude from persistence |
408
+
409
+ `GroupColumnDef` extras beyond TanStack: `headerAlign`, `columns`, `enablePinning`, `customFooter`, `exportValue`, `exportHeader` ([Columns](#columns)). `PersistConfig`: `key` (required), `group`, `local`, `pagination` ([Persist](#persist)). `AggregationConfig`: `enabled`, `functions`, `format`, `accessor` ([Aggregations](#aggregations)). `PaginationConfig`: `pageSize`, `pageSizeOptions`, `showInfo`, `showPageNumbers` ([Pagination](#pagination)).
410
+
411
+ Action bar: `DataTableActionBar` takes `table`, `visible` (default: auto — shown while anything selected), `container` (portal target, default `document.body`) plus `motion.div` props; `DataTableActionBarAction` takes Button props plus `tooltip` and `isPending`; `DataTableActionBarSelection` takes `table`.
342
412
 
343
413
  ## Troubleshooting
344
414
 
@@ -369,7 +439,9 @@ DataTable's sibling for card/grid layouts: same toolbar/search/filter/pagination
369
439
  />
370
440
  ```
371
441
 
372
- `onTemplateReady` / `children` receive a controller (`getSelectedItems`, `selectAll`, `clearSelection`, `getFilteredData`, `refresh`, `exportData`…), and it has its own `DataTemplateActionBar` family.
442
+ `onTemplateReady` / `children` receive a controller (`getSelectedItems`, `selectAll`, `clearSelection`, `getFilteredData`, `getTotalCount`, `getVisibleCount`, `refresh`, `exportData`), and it has its own `DataTemplateActionBar` family.
443
+
444
+ Full surface — props: `data`, `template`, `fields` (`{ key, label, type?, sortable?, filterable?, searchable? }`), `filters` (`{ key, label, type, options?, placeholder?, icon? }`), `pagination`, `settings`, `header`, `footer`, `className`, `loading`, `error`, `emptyMessage`, `emptyIcon`, `onSelectionChange`, `onExport(data)`, `onRefresh`, `onTemplateReady`, `children`. Settings: `enableSorting`, `enableFiltering`, `enableGlobalSearch`, `enableSelection` (default OFF), `enableExport`, `showToolbar` (default ON), `selectionMode`, `gridCols`, `gap`, `aspectRatio`, `minCardWidth`, `maxCardWidth`.
373
445
 
374
446
  ---
375
447