@vendure-io/ui 2.0.0-beta.12 → 2.0.0-beta.13
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vendure-io/ui",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.13",
|
|
4
4
|
"description": "React component library for Vendure, built on shadcn/ui and Tailwind v4",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
6
6
|
"homepage": "https://github.com/vendurehq/design/tree/main/packages/ui",
|
|
@@ -229,6 +229,27 @@ export interface DataTableProps<TData> {
|
|
|
229
229
|
*/
|
|
230
230
|
setTableOptions?: (options: TableOptions<TData>) => TableOptions<TData>;
|
|
231
231
|
|
|
232
|
+
/**
|
|
233
|
+
* Receives the core's TanStack {@link Table} instance so consumers (saved-view
|
|
234
|
+
* controls, external toolbars) can drive it without rendering a slot to
|
|
235
|
+
* capture it — the supported alternative to reading `table` off the `toolbar`
|
|
236
|
+
* render-prop purely for its side effect.
|
|
237
|
+
*
|
|
238
|
+
* Fires from an effect after the first commit — never during render or SSR —
|
|
239
|
+
* so it is safe to call setState from here. `useReactTable` returns a
|
|
240
|
+
* referentially stable instance for the component's lifetime, so this fires
|
|
241
|
+
* once per mount (twice under React StrictMode in development, like any
|
|
242
|
+
* effect — keep the callback idempotent): never on a plain rerender, and not
|
|
243
|
+
* again when the callback prop's identity changes. Treat it as a "ready"
|
|
244
|
+
* capture, not a subscription — the latest callback as of that single fire is
|
|
245
|
+
* used (an inline function is fine), but a callback swapped in after mount is
|
|
246
|
+
* never invoked. TanStack mutates the instance in place as state changes, so
|
|
247
|
+
* the reference you capture here stays current — read live state through it
|
|
248
|
+
* (e.g. inside an event handler) rather than expecting a fresh object on each
|
|
249
|
+
* change.
|
|
250
|
+
*/
|
|
251
|
+
onTableReady?: (table: Table<TData>) => void;
|
|
252
|
+
|
|
232
253
|
/**
|
|
233
254
|
* The table's frame. `'card'` (default) renders the band anatomy on a real
|
|
234
255
|
* `Card`: a `CardHeader` (border-b) hosting the header/controls/chips zones,
|
|
@@ -142,6 +142,7 @@ function DataTable<TData>({
|
|
|
142
142
|
emptyState,
|
|
143
143
|
renderRow,
|
|
144
144
|
setTableOptions,
|
|
145
|
+
onTableReady,
|
|
145
146
|
frame = 'card',
|
|
146
147
|
footerRows,
|
|
147
148
|
labels,
|
|
@@ -311,6 +312,16 @@ function DataTable<TData>({
|
|
|
311
312
|
|
|
312
313
|
const table = useReactTable(setTableOptions ? setTableOptions(baseOptions) : baseOptions);
|
|
313
314
|
|
|
315
|
+
// Hand the table instance to the consumer once it exists. A ref holds the
|
|
316
|
+
// latest callback so the effect can key on `table` alone — do NOT add
|
|
317
|
+
// `onTableReady` to the deps: that would re-fire the "ready" notification
|
|
318
|
+
// whenever an inline callback gets a new identity on rerender.
|
|
319
|
+
const onTableReadyRef = React.useRef(onTableReady);
|
|
320
|
+
onTableReadyRef.current = onTableReady;
|
|
321
|
+
React.useEffect(() => {
|
|
322
|
+
onTableReadyRef.current?.(table);
|
|
323
|
+
}, [table]);
|
|
324
|
+
|
|
314
325
|
const selectionCache = useSelectionCache(table);
|
|
315
326
|
|
|
316
327
|
const bodyRows = table.getRowModel().rows;
|