@zvndev/yable-react 0.1.1 → 0.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/dist/index.cjs +796 -175
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +81 -13
- package/dist/index.d.ts +81 -13
- package/dist/index.js +760 -178
- package/dist/index.js.map +1 -1
- package/package.json +14 -5
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Table as Table$1, RowData, Cell, Header, Row, TableOptions, ColumnDef, SortDirection, CellContext, ClipboardOptions, CellFlashInfo } from '@zvndev/yable-core';
|
|
2
|
-
export { AccessorFnColumnDef, AccessorKeyColumnDef, AggregationFn, Cell, CellStatus as CellCommitStatus, CellContext, CellFlashEvent, CellPatch, ClipboardOptions, Column, ColumnDef, ColumnDefBase, ColumnFiltersState, ColumnMeta, ColumnOrderState, ColumnPinningState, ColumnSizingInfoState, ColumnSizingState, CommitError, CommitErrorCells, CommitRecord, CommitResult, CommitsSlice, DisplayColumnDef, EditingState, ExpandedState, FillHandleState, FilterFn, FormulaState, GroupColumnDef, Header, HeaderContext, HeaderGroup, KeyboardNavigationAction, KeyboardNavigationCell, KeyboardNavigationDirection, KeyboardNavigationState, OnChangeFn, OnCommitFn, PaginationState, PartialLocale, PivotConfig, PivotState, Row, RowData, RowDragEndEvent, RowDragEvent, RowDragState, RowEditCommitEvent, RowEditEvent, RowPinningState, RowReorderEvent, RowSelectionState, SortDirection, SortingFn, SortingState, Table as TableInstance, TableOptions, TableOptionsResolved, TableState, UndoAction, UndoRedoState, Updater, VisibilityState, YableLocale, aggregationFns, createColumnHelper, createLocale, en, filterFns, functionalUpdate, getDefaultLocale, resetLocale, setDefaultLocale, sortingFns } from '@zvndev/yable-core';
|
|
1
|
+
import { Table as Table$1, RowData, Cell, Header, Row, TableOptions, Column, ColumnDef, SortDirection, CellContext, ClipboardOptions, CellFlashInfo } from '@zvndev/yable-core';
|
|
2
|
+
export { AccessorFnColumnDef, AccessorKeyColumnDef, AggregationFn, Cell, CellStatus as CellCommitStatus, CellContext, CellFlashEvent, CellPatch, ClipboardOptions, Column, ColumnDef, ColumnDefBase, ColumnFiltersState, ColumnMeta, ColumnOrderState, ColumnPinningState, ColumnSizingInfoState, ColumnSizingState, CommitError, CommitErrorCells, CommitRecord, CommitResult, CommitsSlice, DisplayColumnDef, EditingState, ExpandedState, FillHandleState, FilterFn, FormulaEngine, FormulaError, FormulaFunction, FormulaState, GroupColumnDef, Header, HeaderContext, HeaderGroup, KeyboardNavigationAction, KeyboardNavigationCell, KeyboardNavigationDirection, KeyboardNavigationState, OnChangeFn, OnCommitFn, PaginationState, PartialLocale, PivotColumn, PivotConfig, PivotEngine, PivotFieldConfig, PivotRow, PivotState, PivotValueConfig, Row, RowData, RowDragEndEvent, RowDragEvent, RowDragState, RowEditCommitEvent, RowEditEvent, RowPinningState, RowReorderEvent, RowSelectionState, SortDirection, SortingFn, SortingState, Table as TableInstance, TableOptions, TableOptionsResolved, TableState, UndoAction, UndoRedoOptions, UndoRedoState, UndoStack, Updater, VisibilityState, YableLocale, aggregationFns, createColumnHelper, createLocale, createUndoRedoIntegration, en, filterFns, formulaFunctions, functionalUpdate, generatePivotColumnDefs, getDefaultLocale, getInitialPivotState, getPivotRowModel, resetLocale, setDefaultLocale, sortingFns } from '@zvndev/yable-core';
|
|
3
3
|
import * as React$1 from 'react';
|
|
4
4
|
import React__default, { HTMLAttributes, TdHTMLAttributes, ThHTMLAttributes } from 'react';
|
|
5
5
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
@@ -53,6 +53,14 @@ interface TableProps<TData extends RowData> extends Omit<HTMLAttributes<HTMLDivE
|
|
|
53
53
|
sidebarPanels?: ('columns' | 'filters')[];
|
|
54
54
|
/** Default sidebar panel */
|
|
55
55
|
defaultSidebarPanel?: 'columns' | 'filters';
|
|
56
|
+
/** Render a second header row with per-column floating filters */
|
|
57
|
+
floatingFilters?: boolean;
|
|
58
|
+
/** Virtualize wide tables horizontally when safe to do so */
|
|
59
|
+
columnVirtualization?: boolean;
|
|
60
|
+
/** Additional columns rendered beyond the viewport when column virtualization is enabled */
|
|
61
|
+
columnVirtualizationOverscan?: number;
|
|
62
|
+
/** Accessible label for the grid container. Default: "Data table" */
|
|
63
|
+
ariaLabel?: string;
|
|
56
64
|
}
|
|
57
65
|
/** Status bar panel configuration */
|
|
58
66
|
interface StatusBarPanelConfig {
|
|
@@ -75,6 +83,20 @@ interface TableHeaderCellProps<TData extends RowData, TValue = unknown> extends
|
|
|
75
83
|
header: Header<TData, TValue>;
|
|
76
84
|
}
|
|
77
85
|
|
|
86
|
+
/**
|
|
87
|
+
* React hook that wraps the framework-agnostic core table engine.
|
|
88
|
+
*
|
|
89
|
+
* Returns a stable {@link Table} instance whose `state` reflects either
|
|
90
|
+
* the consumer's controlled `options.state` or the hook's internal state.
|
|
91
|
+
*
|
|
92
|
+
* Re-renders are triggered by `setState` from the default `onStateChange`
|
|
93
|
+
* implementation. Consumers may pass their own `onStateChange` to control
|
|
94
|
+
* state externally.
|
|
95
|
+
*
|
|
96
|
+
* Gotcha: `options.onStateChange` is captured via a latest-ref, so a fresh
|
|
97
|
+
* function identity from the parent is always invoked — even if every other
|
|
98
|
+
* option key is shallow-equal to the previous render.
|
|
99
|
+
*/
|
|
78
100
|
declare function useTable<TData extends RowData>(options: TableOptions<TData>): Table$1<TData>;
|
|
79
101
|
|
|
80
102
|
interface VirtualRow {
|
|
@@ -104,10 +126,40 @@ interface UseVirtualizationResult {
|
|
|
104
126
|
* Computes which rows are visible in a scrollable container and returns
|
|
105
127
|
* positioning data so only those rows (plus an overscan buffer) are rendered.
|
|
106
128
|
*
|
|
107
|
-
*
|
|
129
|
+
* Returns `{ virtualRows, totalHeight, startIndex, endIndex, scrollTo }`.
|
|
130
|
+
* Re-renders are triggered by scroll (rAF-throttled) and ResizeObserver
|
|
131
|
+
* container resize. Supports fixed, variable, and Pretext-pre-measured heights.
|
|
132
|
+
*
|
|
133
|
+
* Gotcha: variable-height mode caches measured heights per index — pass new
|
|
134
|
+
* `pretextHeights` arrays (or change `totalRows`) to invalidate the cache.
|
|
108
135
|
*/
|
|
109
136
|
declare function useVirtualization({ containerRef, totalRows, rowHeight, overscan, estimateRowHeight: _estimateRowHeight, pretextHeights, pretextPrefixSums, }: UseVirtualizationOptions): UseVirtualizationResult;
|
|
110
137
|
|
|
138
|
+
interface VirtualColumn<TData extends RowData> {
|
|
139
|
+
column: Column<TData, unknown>;
|
|
140
|
+
index: number;
|
|
141
|
+
start: number;
|
|
142
|
+
size: number;
|
|
143
|
+
}
|
|
144
|
+
interface UseColumnVirtualizationOptions<TData extends RowData> {
|
|
145
|
+
containerRef: React.RefObject<HTMLElement | null>;
|
|
146
|
+
columns: Column<TData, unknown>[];
|
|
147
|
+
overscan?: number;
|
|
148
|
+
enabled?: boolean;
|
|
149
|
+
}
|
|
150
|
+
interface UseColumnVirtualizationResult<TData extends RowData> {
|
|
151
|
+
virtualColumns: VirtualColumn<TData>[];
|
|
152
|
+
startOffset: number;
|
|
153
|
+
endOffset: number;
|
|
154
|
+
totalWidth: number;
|
|
155
|
+
visibleWidth: number;
|
|
156
|
+
startIndex: number;
|
|
157
|
+
endIndex: number;
|
|
158
|
+
isVirtualized: boolean;
|
|
159
|
+
scrollToIndex: (index: number) => void;
|
|
160
|
+
}
|
|
161
|
+
declare function useColumnVirtualization<TData extends RowData>({ containerRef, columns, overscan, enabled, }: UseColumnVirtualizationOptions<TData>): UseColumnVirtualizationResult<TData>;
|
|
162
|
+
|
|
111
163
|
interface CellMeasurement {
|
|
112
164
|
/** Column ID */
|
|
113
165
|
columnId: string;
|
|
@@ -154,11 +206,15 @@ interface UsePretextMeasurementResult {
|
|
|
154
206
|
}
|
|
155
207
|
/**
|
|
156
208
|
* Pre-computes exact pixel heights for every row using Pretext's
|
|
157
|
-
* DOM-free text measurement.
|
|
158
|
-
* access by the virtualizer.
|
|
209
|
+
* DOM-free text measurement.
|
|
159
210
|
*
|
|
160
|
-
*
|
|
161
|
-
*
|
|
211
|
+
* Returns `{ rowHeights, prefixSums, totalHeight, ready, ... }` as typed
|
|
212
|
+
* arrays for cache-friendly access by the virtualizer. `prepare()` re-runs
|
|
213
|
+
* when `data` or fonts change; `layout()` re-runs only when column widths
|
|
214
|
+
* change (pure math, ~0.0003ms per cell).
|
|
215
|
+
*
|
|
216
|
+
* Gotcha: pretext is loaded lazily — `ready` flips to true on the first
|
|
217
|
+
* render after the dynamic import resolves and heights are computed.
|
|
162
218
|
*/
|
|
163
219
|
declare function usePretextMeasurement({ data, columns, getCellText, minRowHeight, enabled, }: UsePretextMeasurementOptions): UsePretextMeasurementResult;
|
|
164
220
|
|
|
@@ -337,18 +393,19 @@ declare function getRegisteredCellTypes(): readonly string[];
|
|
|
337
393
|
declare const TableProvider: React$1.Provider<Table$1<any> | null>;
|
|
338
394
|
declare function useTableContext<TData extends RowData>(): Table$1<TData>;
|
|
339
395
|
|
|
340
|
-
declare function Table<TData extends RowData>({ table, stickyHeader, striped, bordered, compact, theme, clickableRows, footer, loading, loadingComponent, loadingText, emptyMessage, emptyComponent, emptyIcon, emptyDetail, renderEmpty, renderLoading, children, className, direction, statusBar, statusBarPanels, sidebar, sidebarPanels, defaultSidebarPanel, ...rest }: TableProps<TData>): react_jsx_runtime.JSX.Element;
|
|
396
|
+
declare function Table<TData extends RowData>({ table, stickyHeader, striped, bordered, compact, theme, clickableRows, footer, loading, loadingComponent, loadingText, emptyMessage, emptyComponent, emptyIcon, emptyDetail, renderEmpty, renderLoading, children, className, direction, statusBar, statusBarPanels, sidebar, sidebarPanels, defaultSidebarPanel, floatingFilters, columnVirtualization, columnVirtualizationOverscan, ariaLabel, ...rest }: TableProps<TData>): react_jsx_runtime.JSX.Element;
|
|
341
397
|
|
|
342
398
|
interface TableHeaderProps<TData extends RowData> {
|
|
343
399
|
table: Table$1<TData>;
|
|
400
|
+
floatingFilters?: boolean;
|
|
344
401
|
}
|
|
345
|
-
declare function TableHeader<TData extends RowData>({ table, }: TableHeaderProps<TData>): react_jsx_runtime.JSX.Element;
|
|
402
|
+
declare function TableHeader<TData extends RowData>({ table, floatingFilters, }: TableHeaderProps<TData>): react_jsx_runtime.JSX.Element;
|
|
346
403
|
|
|
347
404
|
interface TableBodyProps<TData extends RowData> {
|
|
348
405
|
table: Table$1<TData>;
|
|
349
406
|
clickableRows?: boolean;
|
|
350
407
|
}
|
|
351
|
-
declare function TableBody<TData extends RowData>({ table, clickableRows
|
|
408
|
+
declare function TableBody<TData extends RowData>({ table, clickableRows }: TableBodyProps<TData>): react_jsx_runtime.JSX.Element;
|
|
352
409
|
|
|
353
410
|
interface TableCellProps<TData extends RowData> {
|
|
354
411
|
cell: Cell<TData, unknown>;
|
|
@@ -363,7 +420,7 @@ declare function TableCell<TData extends RowData>({ cell, table, rowIndex, colum
|
|
|
363
420
|
interface TableFooterProps<TData extends RowData> {
|
|
364
421
|
table: Table$1<TData>;
|
|
365
422
|
}
|
|
366
|
-
declare function TableFooter<TData extends RowData>({ table
|
|
423
|
+
declare function TableFooter<TData extends RowData>({ table }: TableFooterProps<TData>): react_jsx_runtime.JSX.Element | null;
|
|
367
424
|
|
|
368
425
|
interface PaginationProps<TData extends RowData> {
|
|
369
426
|
table: Table$1<TData>;
|
|
@@ -389,6 +446,17 @@ interface GlobalFilterProps<TData extends RowData> {
|
|
|
389
446
|
}
|
|
390
447
|
declare function GlobalFilter<TData extends RowData>({ table, placeholder, debounce, className, }: GlobalFilterProps<TData>): react_jsx_runtime.JSX.Element;
|
|
391
448
|
|
|
449
|
+
interface FloatingFilterProps<TData extends RowData> {
|
|
450
|
+
column: Column<TData, unknown>;
|
|
451
|
+
}
|
|
452
|
+
declare function FloatingFilter<TData extends RowData>({ column }: FloatingFilterProps<TData>): react_jsx_runtime.JSX.Element;
|
|
453
|
+
|
|
454
|
+
interface SetFilterProps<TData extends RowData> {
|
|
455
|
+
column: Column<TData, unknown>;
|
|
456
|
+
className?: string;
|
|
457
|
+
}
|
|
458
|
+
declare function SetFilter<TData extends RowData>({ column, className }: SetFilterProps<TData>): react_jsx_runtime.JSX.Element;
|
|
459
|
+
|
|
392
460
|
interface SortIndicatorProps {
|
|
393
461
|
direction: SortDirection | false;
|
|
394
462
|
index?: number;
|
|
@@ -933,7 +1001,7 @@ interface UsePrintLayoutOptions {
|
|
|
933
1001
|
*/
|
|
934
1002
|
additionalCSS?: string;
|
|
935
1003
|
}
|
|
936
|
-
declare function usePrintLayout<TData extends RowData>(
|
|
1004
|
+
declare function usePrintLayout<TData extends RowData>(_table: Table$1<TData>, options?: UsePrintLayoutOptions): {
|
|
937
1005
|
preparePrint: () => void;
|
|
938
1006
|
isPrinting: boolean;
|
|
939
1007
|
};
|
|
@@ -954,4 +1022,4 @@ declare function useTheme(options?: UseThemeOptions): {
|
|
|
954
1022
|
containerRef: React$1.RefObject<HTMLElement | null>;
|
|
955
1023
|
};
|
|
956
1024
|
|
|
957
|
-
export { type AutoMeasurementsOptions, CellBadge, type CellBadgeProps, CellBoolean, type CellBooleanProps, CellCheckbox, CellCurrency, type CellCurrencyProps, CellDate, CellDatePicker, type CellDateProps, CellErrorBoundary, CellInput, CellLink, type CellLinkProps, type CellMeasureRecipe, type CellMeasurement, CellNumeric, type CellNumericProps, CellProgress, type CellProgressProps, CellRating, type CellRatingProps, CellSelect, CellStatus, CellStatusBadge, type CellStatusBadgeProps, type CellStatusProps, CellToggle, ColumnsPanel, ContextMenu, ContextMenuItem, type ContextMenuItemDef, DEFAULT_TEXT_RECIPE, DragHandle, ErrorBoundary, ExpandIcon, FillHandle, type FillHandleDragState, type FillHandleProps, FiltersPanel, FlashCell, GlobalFilter, LoadingOverlay, type LoadingOverlayProps, MasterDetail, NoRowsOverlay, type NoRowsOverlayProps, Pagination, PivotConfigPanel, type PivotConfigProps, type PivotFieldItem, type PivotValueItem, PrintLayout, Sidebar, SortIndicator, StatusBar, StatusBarPanelComponent, type StatusBarPanelComponentProps, type StatusBarPanelConfig, type StatusBarPanelProps, Table, TableBody, TableCell, type TableCellProps$1 as TableCellProps, TableFooter, TableHeader, type TableHeaderCellProps, type TableProps, TableProvider, type TableRowProps, Tooltip, type TooltipPosition, type TooltipProps, TreeToggle, type UseCellFlashOptions, type UseClipboardOptions, type UseFillHandleOptions, type UseFillHandleReturn, type UseKeyboardNavigationOptions, type UsePretextMeasurementOptions, type UsePretextMeasurementResult, type UsePrintLayoutOptions, type UseRowAnimationOptions, type UseRowDragOptions, type UseRowDragReturn, type UseTableRowHeightsOptions, type UseThemeOptions, type UseTooltipOptions, type UseVirtualizationOptions, type UseVirtualizationResult, type VirtualRow, getMeasureRecipeForCellType, getRegisteredCellTypes, resolveMeasureRecipe, useAutoMeasurements, useCellFlash, useClipboard, useContextMenu, useFillHandle, useKeyboardNavigation, usePretextMeasurement, usePrintLayout, useRowAnimation, useRowDrag, useTable, useTableContext, useTableRowHeights, useTheme, useTooltip, useVirtualization };
|
|
1025
|
+
export { type AutoMeasurementsOptions, CellBadge, type CellBadgeProps, CellBoolean, type CellBooleanProps, CellCheckbox, CellCurrency, type CellCurrencyProps, CellDate, CellDatePicker, type CellDateProps, CellErrorBoundary, CellInput, CellLink, type CellLinkProps, type CellMeasureRecipe, type CellMeasurement, CellNumeric, type CellNumericProps, CellProgress, type CellProgressProps, CellRating, type CellRatingProps, CellSelect, CellStatus, CellStatusBadge, type CellStatusBadgeProps, type CellStatusProps, CellToggle, ColumnsPanel, ContextMenu, ContextMenuItem, type ContextMenuItemDef, DEFAULT_TEXT_RECIPE, DragHandle, ErrorBoundary, ExpandIcon, FillHandle, type FillHandleDragState, type FillHandleProps, FiltersPanel, FlashCell, FloatingFilter, GlobalFilter, LoadingOverlay, type LoadingOverlayProps, MasterDetail, NoRowsOverlay, type NoRowsOverlayProps, Pagination, PivotConfigPanel, type PivotConfigProps, type PivotFieldItem, type PivotValueItem, PrintLayout, SetFilter, Sidebar, SortIndicator, StatusBar, StatusBarPanelComponent, type StatusBarPanelComponentProps, type StatusBarPanelConfig, type StatusBarPanelProps, Table, TableBody, TableCell, type TableCellProps$1 as TableCellProps, TableFooter, TableHeader, type TableHeaderCellProps, type TableProps, TableProvider, type TableRowProps, Tooltip, type TooltipPosition, type TooltipProps, TreeToggle, type UseCellFlashOptions, type UseClipboardOptions, type UseColumnVirtualizationOptions, type UseColumnVirtualizationResult, type UseFillHandleOptions, type UseFillHandleReturn, type UseKeyboardNavigationOptions, type UsePretextMeasurementOptions, type UsePretextMeasurementResult, type UsePrintLayoutOptions, type UseRowAnimationOptions, type UseRowDragOptions, type UseRowDragReturn, type UseTableRowHeightsOptions, type UseThemeOptions, type UseTooltipOptions, type UseVirtualizationOptions, type UseVirtualizationResult, type VirtualColumn, type VirtualRow, getMeasureRecipeForCellType, getRegisteredCellTypes, resolveMeasureRecipe, useAutoMeasurements, useCellFlash, useClipboard, useColumnVirtualization, useContextMenu, useFillHandle, useKeyboardNavigation, usePretextMeasurement, usePrintLayout, useRowAnimation, useRowDrag, useTable, useTableContext, useTableRowHeights, useTheme, useTooltip, useVirtualization };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Table as Table$1, RowData, Cell, Header, Row, TableOptions, ColumnDef, SortDirection, CellContext, ClipboardOptions, CellFlashInfo } from '@zvndev/yable-core';
|
|
2
|
-
export { AccessorFnColumnDef, AccessorKeyColumnDef, AggregationFn, Cell, CellStatus as CellCommitStatus, CellContext, CellFlashEvent, CellPatch, ClipboardOptions, Column, ColumnDef, ColumnDefBase, ColumnFiltersState, ColumnMeta, ColumnOrderState, ColumnPinningState, ColumnSizingInfoState, ColumnSizingState, CommitError, CommitErrorCells, CommitRecord, CommitResult, CommitsSlice, DisplayColumnDef, EditingState, ExpandedState, FillHandleState, FilterFn, FormulaState, GroupColumnDef, Header, HeaderContext, HeaderGroup, KeyboardNavigationAction, KeyboardNavigationCell, KeyboardNavigationDirection, KeyboardNavigationState, OnChangeFn, OnCommitFn, PaginationState, PartialLocale, PivotConfig, PivotState, Row, RowData, RowDragEndEvent, RowDragEvent, RowDragState, RowEditCommitEvent, RowEditEvent, RowPinningState, RowReorderEvent, RowSelectionState, SortDirection, SortingFn, SortingState, Table as TableInstance, TableOptions, TableOptionsResolved, TableState, UndoAction, UndoRedoState, Updater, VisibilityState, YableLocale, aggregationFns, createColumnHelper, createLocale, en, filterFns, functionalUpdate, getDefaultLocale, resetLocale, setDefaultLocale, sortingFns } from '@zvndev/yable-core';
|
|
1
|
+
import { Table as Table$1, RowData, Cell, Header, Row, TableOptions, Column, ColumnDef, SortDirection, CellContext, ClipboardOptions, CellFlashInfo } from '@zvndev/yable-core';
|
|
2
|
+
export { AccessorFnColumnDef, AccessorKeyColumnDef, AggregationFn, Cell, CellStatus as CellCommitStatus, CellContext, CellFlashEvent, CellPatch, ClipboardOptions, Column, ColumnDef, ColumnDefBase, ColumnFiltersState, ColumnMeta, ColumnOrderState, ColumnPinningState, ColumnSizingInfoState, ColumnSizingState, CommitError, CommitErrorCells, CommitRecord, CommitResult, CommitsSlice, DisplayColumnDef, EditingState, ExpandedState, FillHandleState, FilterFn, FormulaEngine, FormulaError, FormulaFunction, FormulaState, GroupColumnDef, Header, HeaderContext, HeaderGroup, KeyboardNavigationAction, KeyboardNavigationCell, KeyboardNavigationDirection, KeyboardNavigationState, OnChangeFn, OnCommitFn, PaginationState, PartialLocale, PivotColumn, PivotConfig, PivotEngine, PivotFieldConfig, PivotRow, PivotState, PivotValueConfig, Row, RowData, RowDragEndEvent, RowDragEvent, RowDragState, RowEditCommitEvent, RowEditEvent, RowPinningState, RowReorderEvent, RowSelectionState, SortDirection, SortingFn, SortingState, Table as TableInstance, TableOptions, TableOptionsResolved, TableState, UndoAction, UndoRedoOptions, UndoRedoState, UndoStack, Updater, VisibilityState, YableLocale, aggregationFns, createColumnHelper, createLocale, createUndoRedoIntegration, en, filterFns, formulaFunctions, functionalUpdate, generatePivotColumnDefs, getDefaultLocale, getInitialPivotState, getPivotRowModel, resetLocale, setDefaultLocale, sortingFns } from '@zvndev/yable-core';
|
|
3
3
|
import * as React$1 from 'react';
|
|
4
4
|
import React__default, { HTMLAttributes, TdHTMLAttributes, ThHTMLAttributes } from 'react';
|
|
5
5
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
@@ -53,6 +53,14 @@ interface TableProps<TData extends RowData> extends Omit<HTMLAttributes<HTMLDivE
|
|
|
53
53
|
sidebarPanels?: ('columns' | 'filters')[];
|
|
54
54
|
/** Default sidebar panel */
|
|
55
55
|
defaultSidebarPanel?: 'columns' | 'filters';
|
|
56
|
+
/** Render a second header row with per-column floating filters */
|
|
57
|
+
floatingFilters?: boolean;
|
|
58
|
+
/** Virtualize wide tables horizontally when safe to do so */
|
|
59
|
+
columnVirtualization?: boolean;
|
|
60
|
+
/** Additional columns rendered beyond the viewport when column virtualization is enabled */
|
|
61
|
+
columnVirtualizationOverscan?: number;
|
|
62
|
+
/** Accessible label for the grid container. Default: "Data table" */
|
|
63
|
+
ariaLabel?: string;
|
|
56
64
|
}
|
|
57
65
|
/** Status bar panel configuration */
|
|
58
66
|
interface StatusBarPanelConfig {
|
|
@@ -75,6 +83,20 @@ interface TableHeaderCellProps<TData extends RowData, TValue = unknown> extends
|
|
|
75
83
|
header: Header<TData, TValue>;
|
|
76
84
|
}
|
|
77
85
|
|
|
86
|
+
/**
|
|
87
|
+
* React hook that wraps the framework-agnostic core table engine.
|
|
88
|
+
*
|
|
89
|
+
* Returns a stable {@link Table} instance whose `state` reflects either
|
|
90
|
+
* the consumer's controlled `options.state` or the hook's internal state.
|
|
91
|
+
*
|
|
92
|
+
* Re-renders are triggered by `setState` from the default `onStateChange`
|
|
93
|
+
* implementation. Consumers may pass their own `onStateChange` to control
|
|
94
|
+
* state externally.
|
|
95
|
+
*
|
|
96
|
+
* Gotcha: `options.onStateChange` is captured via a latest-ref, so a fresh
|
|
97
|
+
* function identity from the parent is always invoked — even if every other
|
|
98
|
+
* option key is shallow-equal to the previous render.
|
|
99
|
+
*/
|
|
78
100
|
declare function useTable<TData extends RowData>(options: TableOptions<TData>): Table$1<TData>;
|
|
79
101
|
|
|
80
102
|
interface VirtualRow {
|
|
@@ -104,10 +126,40 @@ interface UseVirtualizationResult {
|
|
|
104
126
|
* Computes which rows are visible in a scrollable container and returns
|
|
105
127
|
* positioning data so only those rows (plus an overscan buffer) are rendered.
|
|
106
128
|
*
|
|
107
|
-
*
|
|
129
|
+
* Returns `{ virtualRows, totalHeight, startIndex, endIndex, scrollTo }`.
|
|
130
|
+
* Re-renders are triggered by scroll (rAF-throttled) and ResizeObserver
|
|
131
|
+
* container resize. Supports fixed, variable, and Pretext-pre-measured heights.
|
|
132
|
+
*
|
|
133
|
+
* Gotcha: variable-height mode caches measured heights per index — pass new
|
|
134
|
+
* `pretextHeights` arrays (or change `totalRows`) to invalidate the cache.
|
|
108
135
|
*/
|
|
109
136
|
declare function useVirtualization({ containerRef, totalRows, rowHeight, overscan, estimateRowHeight: _estimateRowHeight, pretextHeights, pretextPrefixSums, }: UseVirtualizationOptions): UseVirtualizationResult;
|
|
110
137
|
|
|
138
|
+
interface VirtualColumn<TData extends RowData> {
|
|
139
|
+
column: Column<TData, unknown>;
|
|
140
|
+
index: number;
|
|
141
|
+
start: number;
|
|
142
|
+
size: number;
|
|
143
|
+
}
|
|
144
|
+
interface UseColumnVirtualizationOptions<TData extends RowData> {
|
|
145
|
+
containerRef: React.RefObject<HTMLElement | null>;
|
|
146
|
+
columns: Column<TData, unknown>[];
|
|
147
|
+
overscan?: number;
|
|
148
|
+
enabled?: boolean;
|
|
149
|
+
}
|
|
150
|
+
interface UseColumnVirtualizationResult<TData extends RowData> {
|
|
151
|
+
virtualColumns: VirtualColumn<TData>[];
|
|
152
|
+
startOffset: number;
|
|
153
|
+
endOffset: number;
|
|
154
|
+
totalWidth: number;
|
|
155
|
+
visibleWidth: number;
|
|
156
|
+
startIndex: number;
|
|
157
|
+
endIndex: number;
|
|
158
|
+
isVirtualized: boolean;
|
|
159
|
+
scrollToIndex: (index: number) => void;
|
|
160
|
+
}
|
|
161
|
+
declare function useColumnVirtualization<TData extends RowData>({ containerRef, columns, overscan, enabled, }: UseColumnVirtualizationOptions<TData>): UseColumnVirtualizationResult<TData>;
|
|
162
|
+
|
|
111
163
|
interface CellMeasurement {
|
|
112
164
|
/** Column ID */
|
|
113
165
|
columnId: string;
|
|
@@ -154,11 +206,15 @@ interface UsePretextMeasurementResult {
|
|
|
154
206
|
}
|
|
155
207
|
/**
|
|
156
208
|
* Pre-computes exact pixel heights for every row using Pretext's
|
|
157
|
-
* DOM-free text measurement.
|
|
158
|
-
* access by the virtualizer.
|
|
209
|
+
* DOM-free text measurement.
|
|
159
210
|
*
|
|
160
|
-
*
|
|
161
|
-
*
|
|
211
|
+
* Returns `{ rowHeights, prefixSums, totalHeight, ready, ... }` as typed
|
|
212
|
+
* arrays for cache-friendly access by the virtualizer. `prepare()` re-runs
|
|
213
|
+
* when `data` or fonts change; `layout()` re-runs only when column widths
|
|
214
|
+
* change (pure math, ~0.0003ms per cell).
|
|
215
|
+
*
|
|
216
|
+
* Gotcha: pretext is loaded lazily — `ready` flips to true on the first
|
|
217
|
+
* render after the dynamic import resolves and heights are computed.
|
|
162
218
|
*/
|
|
163
219
|
declare function usePretextMeasurement({ data, columns, getCellText, minRowHeight, enabled, }: UsePretextMeasurementOptions): UsePretextMeasurementResult;
|
|
164
220
|
|
|
@@ -337,18 +393,19 @@ declare function getRegisteredCellTypes(): readonly string[];
|
|
|
337
393
|
declare const TableProvider: React$1.Provider<Table$1<any> | null>;
|
|
338
394
|
declare function useTableContext<TData extends RowData>(): Table$1<TData>;
|
|
339
395
|
|
|
340
|
-
declare function Table<TData extends RowData>({ table, stickyHeader, striped, bordered, compact, theme, clickableRows, footer, loading, loadingComponent, loadingText, emptyMessage, emptyComponent, emptyIcon, emptyDetail, renderEmpty, renderLoading, children, className, direction, statusBar, statusBarPanels, sidebar, sidebarPanels, defaultSidebarPanel, ...rest }: TableProps<TData>): react_jsx_runtime.JSX.Element;
|
|
396
|
+
declare function Table<TData extends RowData>({ table, stickyHeader, striped, bordered, compact, theme, clickableRows, footer, loading, loadingComponent, loadingText, emptyMessage, emptyComponent, emptyIcon, emptyDetail, renderEmpty, renderLoading, children, className, direction, statusBar, statusBarPanels, sidebar, sidebarPanels, defaultSidebarPanel, floatingFilters, columnVirtualization, columnVirtualizationOverscan, ariaLabel, ...rest }: TableProps<TData>): react_jsx_runtime.JSX.Element;
|
|
341
397
|
|
|
342
398
|
interface TableHeaderProps<TData extends RowData> {
|
|
343
399
|
table: Table$1<TData>;
|
|
400
|
+
floatingFilters?: boolean;
|
|
344
401
|
}
|
|
345
|
-
declare function TableHeader<TData extends RowData>({ table, }: TableHeaderProps<TData>): react_jsx_runtime.JSX.Element;
|
|
402
|
+
declare function TableHeader<TData extends RowData>({ table, floatingFilters, }: TableHeaderProps<TData>): react_jsx_runtime.JSX.Element;
|
|
346
403
|
|
|
347
404
|
interface TableBodyProps<TData extends RowData> {
|
|
348
405
|
table: Table$1<TData>;
|
|
349
406
|
clickableRows?: boolean;
|
|
350
407
|
}
|
|
351
|
-
declare function TableBody<TData extends RowData>({ table, clickableRows
|
|
408
|
+
declare function TableBody<TData extends RowData>({ table, clickableRows }: TableBodyProps<TData>): react_jsx_runtime.JSX.Element;
|
|
352
409
|
|
|
353
410
|
interface TableCellProps<TData extends RowData> {
|
|
354
411
|
cell: Cell<TData, unknown>;
|
|
@@ -363,7 +420,7 @@ declare function TableCell<TData extends RowData>({ cell, table, rowIndex, colum
|
|
|
363
420
|
interface TableFooterProps<TData extends RowData> {
|
|
364
421
|
table: Table$1<TData>;
|
|
365
422
|
}
|
|
366
|
-
declare function TableFooter<TData extends RowData>({ table
|
|
423
|
+
declare function TableFooter<TData extends RowData>({ table }: TableFooterProps<TData>): react_jsx_runtime.JSX.Element | null;
|
|
367
424
|
|
|
368
425
|
interface PaginationProps<TData extends RowData> {
|
|
369
426
|
table: Table$1<TData>;
|
|
@@ -389,6 +446,17 @@ interface GlobalFilterProps<TData extends RowData> {
|
|
|
389
446
|
}
|
|
390
447
|
declare function GlobalFilter<TData extends RowData>({ table, placeholder, debounce, className, }: GlobalFilterProps<TData>): react_jsx_runtime.JSX.Element;
|
|
391
448
|
|
|
449
|
+
interface FloatingFilterProps<TData extends RowData> {
|
|
450
|
+
column: Column<TData, unknown>;
|
|
451
|
+
}
|
|
452
|
+
declare function FloatingFilter<TData extends RowData>({ column }: FloatingFilterProps<TData>): react_jsx_runtime.JSX.Element;
|
|
453
|
+
|
|
454
|
+
interface SetFilterProps<TData extends RowData> {
|
|
455
|
+
column: Column<TData, unknown>;
|
|
456
|
+
className?: string;
|
|
457
|
+
}
|
|
458
|
+
declare function SetFilter<TData extends RowData>({ column, className }: SetFilterProps<TData>): react_jsx_runtime.JSX.Element;
|
|
459
|
+
|
|
392
460
|
interface SortIndicatorProps {
|
|
393
461
|
direction: SortDirection | false;
|
|
394
462
|
index?: number;
|
|
@@ -933,7 +1001,7 @@ interface UsePrintLayoutOptions {
|
|
|
933
1001
|
*/
|
|
934
1002
|
additionalCSS?: string;
|
|
935
1003
|
}
|
|
936
|
-
declare function usePrintLayout<TData extends RowData>(
|
|
1004
|
+
declare function usePrintLayout<TData extends RowData>(_table: Table$1<TData>, options?: UsePrintLayoutOptions): {
|
|
937
1005
|
preparePrint: () => void;
|
|
938
1006
|
isPrinting: boolean;
|
|
939
1007
|
};
|
|
@@ -954,4 +1022,4 @@ declare function useTheme(options?: UseThemeOptions): {
|
|
|
954
1022
|
containerRef: React$1.RefObject<HTMLElement | null>;
|
|
955
1023
|
};
|
|
956
1024
|
|
|
957
|
-
export { type AutoMeasurementsOptions, CellBadge, type CellBadgeProps, CellBoolean, type CellBooleanProps, CellCheckbox, CellCurrency, type CellCurrencyProps, CellDate, CellDatePicker, type CellDateProps, CellErrorBoundary, CellInput, CellLink, type CellLinkProps, type CellMeasureRecipe, type CellMeasurement, CellNumeric, type CellNumericProps, CellProgress, type CellProgressProps, CellRating, type CellRatingProps, CellSelect, CellStatus, CellStatusBadge, type CellStatusBadgeProps, type CellStatusProps, CellToggle, ColumnsPanel, ContextMenu, ContextMenuItem, type ContextMenuItemDef, DEFAULT_TEXT_RECIPE, DragHandle, ErrorBoundary, ExpandIcon, FillHandle, type FillHandleDragState, type FillHandleProps, FiltersPanel, FlashCell, GlobalFilter, LoadingOverlay, type LoadingOverlayProps, MasterDetail, NoRowsOverlay, type NoRowsOverlayProps, Pagination, PivotConfigPanel, type PivotConfigProps, type PivotFieldItem, type PivotValueItem, PrintLayout, Sidebar, SortIndicator, StatusBar, StatusBarPanelComponent, type StatusBarPanelComponentProps, type StatusBarPanelConfig, type StatusBarPanelProps, Table, TableBody, TableCell, type TableCellProps$1 as TableCellProps, TableFooter, TableHeader, type TableHeaderCellProps, type TableProps, TableProvider, type TableRowProps, Tooltip, type TooltipPosition, type TooltipProps, TreeToggle, type UseCellFlashOptions, type UseClipboardOptions, type UseFillHandleOptions, type UseFillHandleReturn, type UseKeyboardNavigationOptions, type UsePretextMeasurementOptions, type UsePretextMeasurementResult, type UsePrintLayoutOptions, type UseRowAnimationOptions, type UseRowDragOptions, type UseRowDragReturn, type UseTableRowHeightsOptions, type UseThemeOptions, type UseTooltipOptions, type UseVirtualizationOptions, type UseVirtualizationResult, type VirtualRow, getMeasureRecipeForCellType, getRegisteredCellTypes, resolveMeasureRecipe, useAutoMeasurements, useCellFlash, useClipboard, useContextMenu, useFillHandle, useKeyboardNavigation, usePretextMeasurement, usePrintLayout, useRowAnimation, useRowDrag, useTable, useTableContext, useTableRowHeights, useTheme, useTooltip, useVirtualization };
|
|
1025
|
+
export { type AutoMeasurementsOptions, CellBadge, type CellBadgeProps, CellBoolean, type CellBooleanProps, CellCheckbox, CellCurrency, type CellCurrencyProps, CellDate, CellDatePicker, type CellDateProps, CellErrorBoundary, CellInput, CellLink, type CellLinkProps, type CellMeasureRecipe, type CellMeasurement, CellNumeric, type CellNumericProps, CellProgress, type CellProgressProps, CellRating, type CellRatingProps, CellSelect, CellStatus, CellStatusBadge, type CellStatusBadgeProps, type CellStatusProps, CellToggle, ColumnsPanel, ContextMenu, ContextMenuItem, type ContextMenuItemDef, DEFAULT_TEXT_RECIPE, DragHandle, ErrorBoundary, ExpandIcon, FillHandle, type FillHandleDragState, type FillHandleProps, FiltersPanel, FlashCell, FloatingFilter, GlobalFilter, LoadingOverlay, type LoadingOverlayProps, MasterDetail, NoRowsOverlay, type NoRowsOverlayProps, Pagination, PivotConfigPanel, type PivotConfigProps, type PivotFieldItem, type PivotValueItem, PrintLayout, SetFilter, Sidebar, SortIndicator, StatusBar, StatusBarPanelComponent, type StatusBarPanelComponentProps, type StatusBarPanelConfig, type StatusBarPanelProps, Table, TableBody, TableCell, type TableCellProps$1 as TableCellProps, TableFooter, TableHeader, type TableHeaderCellProps, type TableProps, TableProvider, type TableRowProps, Tooltip, type TooltipPosition, type TooltipProps, TreeToggle, type UseCellFlashOptions, type UseClipboardOptions, type UseColumnVirtualizationOptions, type UseColumnVirtualizationResult, type UseFillHandleOptions, type UseFillHandleReturn, type UseKeyboardNavigationOptions, type UsePretextMeasurementOptions, type UsePretextMeasurementResult, type UsePrintLayoutOptions, type UseRowAnimationOptions, type UseRowDragOptions, type UseRowDragReturn, type UseTableRowHeightsOptions, type UseThemeOptions, type UseTooltipOptions, type UseVirtualizationOptions, type UseVirtualizationResult, type VirtualColumn, type VirtualRow, getMeasureRecipeForCellType, getRegisteredCellTypes, resolveMeasureRecipe, useAutoMeasurements, useCellFlash, useClipboard, useColumnVirtualization, useContextMenu, useFillHandle, useKeyboardNavigation, usePretextMeasurement, usePrintLayout, useRowAnimation, useRowDrag, useTable, useTableContext, useTableRowHeights, useTheme, useTooltip, useVirtualization };
|