@zvndev/yable-react 0.4.0 → 0.5.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.d.cts CHANGED
@@ -1,10 +1,43 @@
1
- import { Table as Table$1, RowData, Cell, Header, Row, TableOptions, TableState, Updater, Column, ColumnDef, ColumnDefBase, SortDirection, CellContext, ClipboardOptions, CellFlashInfo } from '@zvndev/yable-core';
1
+ import { RowData, ColumnDefBase, ColumnDefExtensions, Row, ColumnDef, Table as Table$1, Cell, Header, TableOptions, SortingState, ColumnFiltersState, PaginationState, TableState, Updater, Column, SortDirection, CellContext, ClipboardOptions, CellFlashInfo } from '@zvndev/yable-core';
2
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
- import React__default, { HTMLAttributes, TdHTMLAttributes, ThHTMLAttributes, ReactNode } from 'react';
4
+ import React__default, { CSSProperties, HTMLAttributes, TdHTMLAttributes, ThHTMLAttributes, ReactNode } from 'react';
5
5
  import * as react_jsx_runtime from 'react/jsx-runtime';
6
6
  import { RowDragState } from '@zvndev/yable-core/features/rowDragging';
7
7
 
8
+ type YableTableVisualConfig = Partial<Pick<TableProps<any>, 'striped' | 'bordered' | 'compact' | 'stickyHeader' | 'theme' | 'direction' | 'ariaLabel' | 'clickableRows' | 'floatingFilters' | 'columnVirtualization' | 'columnVirtualizationOverscan' | 'statusBar' | 'sidebar' | 'sidebarPanels' | 'defaultSidebarPanel'>>;
9
+ type YableColumnConfig<TData extends RowData = any, TValue = unknown> = Partial<ColumnDefBase<TData, TValue>> & Partial<ColumnDefExtensions<TData, TValue>>;
10
+ interface YableRowConfig<TData extends RowData = any> {
11
+ className?: string | ((row: Row<TData>) => string | undefined);
12
+ style?: CSSProperties | ((row: Row<TData>) => CSSProperties);
13
+ }
14
+ type YableCellConfig<TData extends RowData = any, TValue = unknown> = Pick<YableColumnConfig<TData, TValue>, 'cell' | 'cellType' | 'cellTypeProps' | 'cellClassName' | 'cellStyle' | 'editable' | 'editConfig' | 'tooltip' | 'tooltipDelay'>;
15
+ interface YableColumnConfigSet<TData extends RowData = any> {
16
+ default?: YableColumnConfig<TData>;
17
+ byId?: Record<string, YableColumnConfig<TData>>;
18
+ }
19
+ interface YableCellConfigSet<TData extends RowData = any> {
20
+ default?: YableCellConfig<TData>;
21
+ named?: Record<string, YableCellConfig<TData>>;
22
+ byColumn?: Record<string, YableCellConfig<TData>>;
23
+ }
24
+ interface YableTableProfile<TData extends RowData = any> {
25
+ table?: YableTableVisualConfig;
26
+ columns?: YableColumnConfigSet<TData>;
27
+ rows?: YableRowConfig<TData>;
28
+ cells?: YableCellConfigSet<TData>;
29
+ }
30
+ interface YableConfig<TData extends RowData = any> extends YableTableProfile<TData> {
31
+ profiles?: Record<string, YableTableProfile<TData>>;
32
+ }
33
+ interface ResolvedYableProfile<TData extends RowData = any> extends YableTableProfile<TData> {
34
+ name: string;
35
+ }
36
+ declare function createYableConfig<TData extends RowData = any>(config: YableConfig<TData>): YableConfig<TData>;
37
+ declare function resolveYableProfile<TData extends RowData = any>(config?: YableConfig<TData>, profileName?: string): ResolvedYableProfile<TData>;
38
+ declare function getYableDefaultColumnDef<TData extends RowData>(profile?: YableTableProfile<TData>): YableColumnConfig<TData> | undefined;
39
+ declare function applyYableConfigToColumns<TData extends RowData>(columns: ColumnDef<TData, any>[], profile?: YableTableProfile<TData>): ColumnDef<TData, any>[];
40
+
8
41
  interface TableProps<TData extends RowData> extends Omit<HTMLAttributes<HTMLDivElement>, 'children'> {
9
42
  table: Table$1<TData>;
10
43
  /** Enable sticky header */
@@ -17,6 +50,10 @@ interface TableProps<TData extends RowData> extends Omit<HTMLAttributes<HTMLDivE
17
50
  compact?: boolean;
18
51
  /** Theme variant */
19
52
  theme?: string;
53
+ /** Named table profile from `YableProvider config` */
54
+ configProfile?: string;
55
+ /** Table-local config; overrides provider config for this component */
56
+ config?: YableConfig<TData>;
20
57
  /** Whether rows are clickable (adds cursor + hover) */
21
58
  clickableRows?: boolean;
22
59
  /** Show footer */
@@ -83,6 +120,12 @@ interface TableHeaderCellProps<TData extends RowData, TValue = unknown> extends
83
120
  header: Header<TData, TValue>;
84
121
  }
85
122
 
123
+ type UseTableOptions<TData extends RowData> = TableOptions<TData> & {
124
+ /** Table-local config; overrides provider config for this table instance. */
125
+ config?: YableConfig<TData>;
126
+ /** Named profile from `YableProvider config`; overrides provider `tableProfile`. */
127
+ configProfile?: string;
128
+ };
86
129
  /**
87
130
  * React hook that wraps the framework-agnostic core table engine.
88
131
  *
@@ -97,7 +140,61 @@ interface TableHeaderCellProps<TData extends RowData, TValue = unknown> extends
97
140
  * function identity from the parent is always invoked — even if every other
98
141
  * option key is shallow-equal to the previous render.
99
142
  */
100
- declare function useTable<TData extends RowData>(options: TableOptions<TData>): Table$1<TData>;
143
+ declare function useTable<TData extends RowData>(options: UseTableOptions<TData>): Table$1<TData>;
144
+
145
+ interface ServerTableFetchArgs {
146
+ sorting: SortingState;
147
+ columnFilters: ColumnFiltersState;
148
+ globalFilter: string;
149
+ pagination: PaginationState;
150
+ cursor: unknown;
151
+ signal: AbortSignal;
152
+ }
153
+ interface ServerTableFetchResult<TData extends RowData> {
154
+ rows: TData[];
155
+ cursor?: unknown;
156
+ hasMore?: boolean;
157
+ rowCount?: number;
158
+ pageCount?: number;
159
+ }
160
+ interface ServerTableUpdateArgs<TData extends RowData> {
161
+ rowId: string;
162
+ patch: Partial<TData>;
163
+ previousRow?: TData;
164
+ signal: AbortSignal;
165
+ }
166
+ interface UseServerTableOptions<TData extends RowData> extends Omit<UseTableOptions<TData>, 'data' | 'state' | 'manualSorting' | 'manualFiltering' | 'manualPagination' | 'onSortingChange' | 'onColumnFiltersChange' | 'onGlobalFilterChange' | 'onPaginationChange' | 'rowCount' | 'pageCount'> {
167
+ fetchData: (args: ServerTableFetchArgs) => Promise<ServerTableFetchResult<TData>>;
168
+ updateRow?: (args: ServerTableUpdateArgs<TData>) => Promise<TData | Partial<TData> | void>;
169
+ initialRows?: TData[];
170
+ initialCursor?: unknown;
171
+ initialHasMore?: boolean;
172
+ initialRowCount?: number;
173
+ initialPageCount?: number;
174
+ initialSorting?: SortingState;
175
+ initialColumnFilters?: ColumnFiltersState;
176
+ initialGlobalFilter?: string;
177
+ initialPagination?: PaginationState;
178
+ autoLoad?: boolean;
179
+ }
180
+ interface ServerTableController<TData extends RowData> {
181
+ table: Table$1<TData>;
182
+ rows: TData[];
183
+ loading: boolean;
184
+ error: unknown;
185
+ cursor: unknown;
186
+ hasMore: boolean;
187
+ rowCount?: number;
188
+ pageCount?: number;
189
+ sorting: SortingState;
190
+ columnFilters: ColumnFiltersState;
191
+ globalFilter: string;
192
+ pagination: PaginationState;
193
+ refresh: () => Promise<void>;
194
+ loadMore: () => Promise<void>;
195
+ updateRow: (rowId: string, patch: Partial<TData>) => Promise<void>;
196
+ }
197
+ declare function useServerTable<TData extends RowData>({ fetchData, updateRow, initialRows, initialCursor, initialHasMore, initialRowCount, initialPageCount, initialSorting, initialColumnFilters, initialGlobalFilter, initialPagination, autoLoad, getRowId, ...tableOptions }: UseServerTableOptions<TData>): ServerTableController<TData>;
101
198
 
102
199
  interface UseTablePersistenceOptions {
103
200
  /** Storage key used for getItem/setItem. */
@@ -222,6 +319,7 @@ interface UseColumnVirtualizationOptions<TData extends RowData> {
222
319
  columns: Column<TData, unknown>[];
223
320
  overscan?: number;
224
321
  enabled?: boolean;
322
+ sizingKey?: string;
225
323
  }
226
324
  interface UseColumnVirtualizationResult<TData extends RowData> {
227
325
  virtualColumns: VirtualColumn<TData>[];
@@ -234,7 +332,7 @@ interface UseColumnVirtualizationResult<TData extends RowData> {
234
332
  isVirtualized: boolean;
235
333
  scrollToIndex: (index: number) => void;
236
334
  }
237
- declare function useColumnVirtualization<TData extends RowData>({ containerRef, columns, overscan, enabled, }: UseColumnVirtualizationOptions<TData>): UseColumnVirtualizationResult<TData>;
335
+ declare function useColumnVirtualization<TData extends RowData>({ containerRef, columns, overscan, enabled, sizingKey, }: UseColumnVirtualizationOptions<TData>): UseColumnVirtualizationResult<TData>;
238
336
 
239
337
  interface CellMeasurement {
240
338
  /** Column ID */
@@ -479,10 +577,14 @@ declare function useTableContext<TData extends RowData>(): Table$1<TData>;
479
577
  * defaults.
480
578
  */
481
579
  interface YableDefaults {
580
+ /** Layered project config with default and named table/cell profiles */
581
+ config?: YableConfig;
582
+ /** Named config profile used by descendants unless overridden */
583
+ tableProfile?: string;
482
584
  /** Default props applied to every `<Table>` in the subtree */
483
585
  tableProps?: Partial<Pick<TableProps<any>, 'striped' | 'bordered' | 'compact' | 'stickyHeader' | 'theme' | 'direction' | 'ariaLabel'>>;
484
586
  /** Default column definition merged under every table's own `defaultColumnDef` */
485
- defaultColumnDef?: Partial<ColumnDefBase<any, unknown>>;
587
+ defaultColumnDef?: Partial<ColumnDefBase<any, unknown>> & Partial<ColumnDefExtensions<any, unknown>>;
486
588
  }
487
589
  /**
488
590
  * Read the nearest `YableProvider` defaults.
@@ -506,7 +608,7 @@ declare function useYableDefaults(): YableDefaults;
506
608
  * </YableProvider>
507
609
  * ```
508
610
  */
509
- declare function YableProvider({ children, defaultColumnDef, striped, stickyHeader, bordered, compact, theme, direction, ariaLabel, }: YableDefaults & {
611
+ declare function YableProvider({ children, config, tableProfile, defaultColumnDef, striped, stickyHeader, bordered, compact, theme, direction, ariaLabel, }: YableDefaults & {
510
612
  children: ReactNode;
511
613
  striped?: boolean;
512
614
  stickyHeader?: boolean;
@@ -517,7 +619,7 @@ declare function YableProvider({ children, defaultColumnDef, striped, stickyHead
517
619
  ariaLabel?: string;
518
620
  }): react_jsx_runtime.JSX.Element;
519
621
 
520
- declare function Table<TData extends RowData>({ table, stickyHeader: stickyHeaderProp, striped: stripedProp, bordered: borderedProp, compact: compactProp, theme: themeProp, clickableRows, footer, loading, loadingComponent, loadingText, emptyMessage, emptyComponent, emptyIcon, emptyDetail, renderEmpty, renderLoading, children, className, direction: directionProp, statusBar, statusBarPanels, sidebar, sidebarPanels, defaultSidebarPanel, floatingFilters, columnVirtualization, columnVirtualizationOverscan, ariaLabel: ariaLabelProp, ...rest }: TableProps<TData>): react_jsx_runtime.JSX.Element;
622
+ declare function Table<TData extends RowData>({ table, stickyHeader: stickyHeaderProp, striped: stripedProp, bordered: borderedProp, compact: compactProp, theme: themeProp, config, configProfile, clickableRows, footer, loading, loadingComponent, loadingText, emptyMessage, emptyComponent, emptyIcon, emptyDetail, renderEmpty, renderLoading, children, className, direction: directionProp, statusBar, statusBarPanels, sidebar, sidebarPanels, defaultSidebarPanel, floatingFilters, columnVirtualization, columnVirtualizationOverscan, ariaLabel: ariaLabelProp, ...rest }: TableProps<TData>): react_jsx_runtime.JSX.Element;
521
623
 
522
624
  interface TableHeaderProps<TData extends RowData> {
523
625
  table: Table$1<TData>;
@@ -1071,16 +1173,19 @@ interface ContextMenuProps<TData extends RowData> {
1071
1173
  y: number;
1072
1174
  onClose: () => void;
1073
1175
  table: Table$1<TData>;
1176
+ /** Column the menu was opened on (right-clicked header/cell). */
1177
+ targetColumnId?: string;
1074
1178
  customItems?: ContextMenuItemDef[];
1075
1179
  }
1076
- declare function ContextMenu<TData extends RowData>({ x, y, onClose, table, customItems, }: ContextMenuProps<TData>): react_jsx_runtime.JSX.Element;
1180
+ declare function ContextMenu<TData extends RowData>({ x, y, onClose, table, targetColumnId, customItems, }: ContextMenuProps<TData>): react_jsx_runtime.JSX.Element;
1077
1181
 
1078
1182
  declare function useContextMenu(): {
1079
1183
  isOpen: boolean;
1080
1184
  x: number;
1081
1185
  y: number;
1082
1186
  targetTable: Table$1<any> | null;
1083
- open: <TData extends RowData>(clientX: number, clientY: number, table: Table$1<TData>) => void;
1187
+ targetColumnId: string | undefined;
1188
+ open: <TData extends RowData>(clientX: number, clientY: number, table: Table$1<TData>, columnId?: string) => void;
1084
1189
  close: () => void;
1085
1190
  };
1086
1191
 
@@ -1097,7 +1202,7 @@ declare function Sidebar<TData extends RowData>({ table, open, onClose, panels,
1097
1202
  interface ColumnsPanelProps<TData extends RowData> {
1098
1203
  table: Table$1<TData>;
1099
1204
  }
1100
- declare function ColumnsPanel<TData extends RowData>({ table, }: ColumnsPanelProps<TData>): react_jsx_runtime.JSX.Element;
1205
+ declare function ColumnsPanel<TData extends RowData>({ table }: ColumnsPanelProps<TData>): react_jsx_runtime.JSX.Element;
1101
1206
 
1102
1207
  interface FiltersPanelProps<TData extends RowData> {
1103
1208
  table: Table$1<TData>;
@@ -1225,4 +1330,4 @@ declare function CellText({ children, variant, bold, truncate, size, }: CellText
1225
1330
  */
1226
1331
  declare function mergeEditChanges<TData>(data: TData[], changes: Record<string, Partial<TData>>, getRowId?: (row: TData, index: number) => string): TData[];
1227
1332
 
1228
- export { type ActionItem, type ActionsColumnOptions, 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, CellRow, type CellRowProps, CellSelect, CellStack, type CellStackProps, CellStatus, CellStatusBadge, type CellStatusBadgeProps, type CellStatusProps, CellText, type CellTextProps, CellToggle, CellWithIcon, type CellWithIconProps, ColumnsPanel, ContextMenu, ContextMenuItem, type ContextMenuItemDef, DEFAULT_TEXT_RECIPE, DragHandle, ErrorBoundary, type ExpandColumnOptions, 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, type RowNumberColumnOptions, type SelectColumnOptions, 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 UseTablePersistenceOptions, type UseTablePersistenceReturn, type UseTableRowHeightsOptions, type UseThemeOptions, type UseTooltipOptions, type UseVirtualizationOptions, type UseVirtualizationResult, type VirtualColumn, type VirtualRow, type YableDefaults, YableProvider, actionsColumn, expandColumn, getMeasureRecipeForCellType, getRegisteredCellTypes, mergeEditChanges, resolveMeasureRecipe, rowNumberColumn, selectColumn, useAutoMeasurements, useCellFlash, useClipboard, useColumnVirtualization, useContextMenu, useFillHandle, useKeyboardNavigation, usePretextMeasurement, usePrintLayout, useRowAnimation, useRowDrag, useTable, useTableContext, useTablePersistence, useTableRowHeights, useTheme, useTooltip, useVirtualization, useYableDefaults };
1333
+ export { type ActionItem, type ActionsColumnOptions, 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, CellRow, type CellRowProps, CellSelect, CellStack, type CellStackProps, CellStatus, CellStatusBadge, type CellStatusBadgeProps, type CellStatusProps, CellText, type CellTextProps, CellToggle, CellWithIcon, type CellWithIconProps, ColumnsPanel, ContextMenu, ContextMenuItem, type ContextMenuItemDef, DEFAULT_TEXT_RECIPE, DragHandle, ErrorBoundary, type ExpandColumnOptions, 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, type ResolvedYableProfile, type RowNumberColumnOptions, type SelectColumnOptions, type ServerTableController, type ServerTableFetchArgs, type ServerTableFetchResult, type ServerTableUpdateArgs, 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 UseServerTableOptions, type UseTableOptions, type UseTablePersistenceOptions, type UseTablePersistenceReturn, type UseTableRowHeightsOptions, type UseThemeOptions, type UseTooltipOptions, type UseVirtualizationOptions, type UseVirtualizationResult, type VirtualColumn, type VirtualRow, type YableCellConfig, type YableCellConfigSet, type YableColumnConfig, type YableColumnConfigSet, type YableConfig, type YableDefaults, YableProvider, type YableRowConfig, type YableTableProfile, type YableTableVisualConfig, actionsColumn, applyYableConfigToColumns, createYableConfig, expandColumn, getMeasureRecipeForCellType, getRegisteredCellTypes, getYableDefaultColumnDef, mergeEditChanges, resolveMeasureRecipe, resolveYableProfile, rowNumberColumn, selectColumn, useAutoMeasurements, useCellFlash, useClipboard, useColumnVirtualization, useContextMenu, useFillHandle, useKeyboardNavigation, usePretextMeasurement, usePrintLayout, useRowAnimation, useRowDrag, useServerTable, useTable, useTableContext, useTablePersistence, useTableRowHeights, useTheme, useTooltip, useVirtualization, useYableDefaults };
package/dist/index.d.ts CHANGED
@@ -1,10 +1,43 @@
1
- import { Table as Table$1, RowData, Cell, Header, Row, TableOptions, TableState, Updater, Column, ColumnDef, ColumnDefBase, SortDirection, CellContext, ClipboardOptions, CellFlashInfo } from '@zvndev/yable-core';
1
+ import { RowData, ColumnDefBase, ColumnDefExtensions, Row, ColumnDef, Table as Table$1, Cell, Header, TableOptions, SortingState, ColumnFiltersState, PaginationState, TableState, Updater, Column, SortDirection, CellContext, ClipboardOptions, CellFlashInfo } from '@zvndev/yable-core';
2
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
- import React__default, { HTMLAttributes, TdHTMLAttributes, ThHTMLAttributes, ReactNode } from 'react';
4
+ import React__default, { CSSProperties, HTMLAttributes, TdHTMLAttributes, ThHTMLAttributes, ReactNode } from 'react';
5
5
  import * as react_jsx_runtime from 'react/jsx-runtime';
6
6
  import { RowDragState } from '@zvndev/yable-core/features/rowDragging';
7
7
 
8
+ type YableTableVisualConfig = Partial<Pick<TableProps<any>, 'striped' | 'bordered' | 'compact' | 'stickyHeader' | 'theme' | 'direction' | 'ariaLabel' | 'clickableRows' | 'floatingFilters' | 'columnVirtualization' | 'columnVirtualizationOverscan' | 'statusBar' | 'sidebar' | 'sidebarPanels' | 'defaultSidebarPanel'>>;
9
+ type YableColumnConfig<TData extends RowData = any, TValue = unknown> = Partial<ColumnDefBase<TData, TValue>> & Partial<ColumnDefExtensions<TData, TValue>>;
10
+ interface YableRowConfig<TData extends RowData = any> {
11
+ className?: string | ((row: Row<TData>) => string | undefined);
12
+ style?: CSSProperties | ((row: Row<TData>) => CSSProperties);
13
+ }
14
+ type YableCellConfig<TData extends RowData = any, TValue = unknown> = Pick<YableColumnConfig<TData, TValue>, 'cell' | 'cellType' | 'cellTypeProps' | 'cellClassName' | 'cellStyle' | 'editable' | 'editConfig' | 'tooltip' | 'tooltipDelay'>;
15
+ interface YableColumnConfigSet<TData extends RowData = any> {
16
+ default?: YableColumnConfig<TData>;
17
+ byId?: Record<string, YableColumnConfig<TData>>;
18
+ }
19
+ interface YableCellConfigSet<TData extends RowData = any> {
20
+ default?: YableCellConfig<TData>;
21
+ named?: Record<string, YableCellConfig<TData>>;
22
+ byColumn?: Record<string, YableCellConfig<TData>>;
23
+ }
24
+ interface YableTableProfile<TData extends RowData = any> {
25
+ table?: YableTableVisualConfig;
26
+ columns?: YableColumnConfigSet<TData>;
27
+ rows?: YableRowConfig<TData>;
28
+ cells?: YableCellConfigSet<TData>;
29
+ }
30
+ interface YableConfig<TData extends RowData = any> extends YableTableProfile<TData> {
31
+ profiles?: Record<string, YableTableProfile<TData>>;
32
+ }
33
+ interface ResolvedYableProfile<TData extends RowData = any> extends YableTableProfile<TData> {
34
+ name: string;
35
+ }
36
+ declare function createYableConfig<TData extends RowData = any>(config: YableConfig<TData>): YableConfig<TData>;
37
+ declare function resolveYableProfile<TData extends RowData = any>(config?: YableConfig<TData>, profileName?: string): ResolvedYableProfile<TData>;
38
+ declare function getYableDefaultColumnDef<TData extends RowData>(profile?: YableTableProfile<TData>): YableColumnConfig<TData> | undefined;
39
+ declare function applyYableConfigToColumns<TData extends RowData>(columns: ColumnDef<TData, any>[], profile?: YableTableProfile<TData>): ColumnDef<TData, any>[];
40
+
8
41
  interface TableProps<TData extends RowData> extends Omit<HTMLAttributes<HTMLDivElement>, 'children'> {
9
42
  table: Table$1<TData>;
10
43
  /** Enable sticky header */
@@ -17,6 +50,10 @@ interface TableProps<TData extends RowData> extends Omit<HTMLAttributes<HTMLDivE
17
50
  compact?: boolean;
18
51
  /** Theme variant */
19
52
  theme?: string;
53
+ /** Named table profile from `YableProvider config` */
54
+ configProfile?: string;
55
+ /** Table-local config; overrides provider config for this component */
56
+ config?: YableConfig<TData>;
20
57
  /** Whether rows are clickable (adds cursor + hover) */
21
58
  clickableRows?: boolean;
22
59
  /** Show footer */
@@ -83,6 +120,12 @@ interface TableHeaderCellProps<TData extends RowData, TValue = unknown> extends
83
120
  header: Header<TData, TValue>;
84
121
  }
85
122
 
123
+ type UseTableOptions<TData extends RowData> = TableOptions<TData> & {
124
+ /** Table-local config; overrides provider config for this table instance. */
125
+ config?: YableConfig<TData>;
126
+ /** Named profile from `YableProvider config`; overrides provider `tableProfile`. */
127
+ configProfile?: string;
128
+ };
86
129
  /**
87
130
  * React hook that wraps the framework-agnostic core table engine.
88
131
  *
@@ -97,7 +140,61 @@ interface TableHeaderCellProps<TData extends RowData, TValue = unknown> extends
97
140
  * function identity from the parent is always invoked — even if every other
98
141
  * option key is shallow-equal to the previous render.
99
142
  */
100
- declare function useTable<TData extends RowData>(options: TableOptions<TData>): Table$1<TData>;
143
+ declare function useTable<TData extends RowData>(options: UseTableOptions<TData>): Table$1<TData>;
144
+
145
+ interface ServerTableFetchArgs {
146
+ sorting: SortingState;
147
+ columnFilters: ColumnFiltersState;
148
+ globalFilter: string;
149
+ pagination: PaginationState;
150
+ cursor: unknown;
151
+ signal: AbortSignal;
152
+ }
153
+ interface ServerTableFetchResult<TData extends RowData> {
154
+ rows: TData[];
155
+ cursor?: unknown;
156
+ hasMore?: boolean;
157
+ rowCount?: number;
158
+ pageCount?: number;
159
+ }
160
+ interface ServerTableUpdateArgs<TData extends RowData> {
161
+ rowId: string;
162
+ patch: Partial<TData>;
163
+ previousRow?: TData;
164
+ signal: AbortSignal;
165
+ }
166
+ interface UseServerTableOptions<TData extends RowData> extends Omit<UseTableOptions<TData>, 'data' | 'state' | 'manualSorting' | 'manualFiltering' | 'manualPagination' | 'onSortingChange' | 'onColumnFiltersChange' | 'onGlobalFilterChange' | 'onPaginationChange' | 'rowCount' | 'pageCount'> {
167
+ fetchData: (args: ServerTableFetchArgs) => Promise<ServerTableFetchResult<TData>>;
168
+ updateRow?: (args: ServerTableUpdateArgs<TData>) => Promise<TData | Partial<TData> | void>;
169
+ initialRows?: TData[];
170
+ initialCursor?: unknown;
171
+ initialHasMore?: boolean;
172
+ initialRowCount?: number;
173
+ initialPageCount?: number;
174
+ initialSorting?: SortingState;
175
+ initialColumnFilters?: ColumnFiltersState;
176
+ initialGlobalFilter?: string;
177
+ initialPagination?: PaginationState;
178
+ autoLoad?: boolean;
179
+ }
180
+ interface ServerTableController<TData extends RowData> {
181
+ table: Table$1<TData>;
182
+ rows: TData[];
183
+ loading: boolean;
184
+ error: unknown;
185
+ cursor: unknown;
186
+ hasMore: boolean;
187
+ rowCount?: number;
188
+ pageCount?: number;
189
+ sorting: SortingState;
190
+ columnFilters: ColumnFiltersState;
191
+ globalFilter: string;
192
+ pagination: PaginationState;
193
+ refresh: () => Promise<void>;
194
+ loadMore: () => Promise<void>;
195
+ updateRow: (rowId: string, patch: Partial<TData>) => Promise<void>;
196
+ }
197
+ declare function useServerTable<TData extends RowData>({ fetchData, updateRow, initialRows, initialCursor, initialHasMore, initialRowCount, initialPageCount, initialSorting, initialColumnFilters, initialGlobalFilter, initialPagination, autoLoad, getRowId, ...tableOptions }: UseServerTableOptions<TData>): ServerTableController<TData>;
101
198
 
102
199
  interface UseTablePersistenceOptions {
103
200
  /** Storage key used for getItem/setItem. */
@@ -222,6 +319,7 @@ interface UseColumnVirtualizationOptions<TData extends RowData> {
222
319
  columns: Column<TData, unknown>[];
223
320
  overscan?: number;
224
321
  enabled?: boolean;
322
+ sizingKey?: string;
225
323
  }
226
324
  interface UseColumnVirtualizationResult<TData extends RowData> {
227
325
  virtualColumns: VirtualColumn<TData>[];
@@ -234,7 +332,7 @@ interface UseColumnVirtualizationResult<TData extends RowData> {
234
332
  isVirtualized: boolean;
235
333
  scrollToIndex: (index: number) => void;
236
334
  }
237
- declare function useColumnVirtualization<TData extends RowData>({ containerRef, columns, overscan, enabled, }: UseColumnVirtualizationOptions<TData>): UseColumnVirtualizationResult<TData>;
335
+ declare function useColumnVirtualization<TData extends RowData>({ containerRef, columns, overscan, enabled, sizingKey, }: UseColumnVirtualizationOptions<TData>): UseColumnVirtualizationResult<TData>;
238
336
 
239
337
  interface CellMeasurement {
240
338
  /** Column ID */
@@ -479,10 +577,14 @@ declare function useTableContext<TData extends RowData>(): Table$1<TData>;
479
577
  * defaults.
480
578
  */
481
579
  interface YableDefaults {
580
+ /** Layered project config with default and named table/cell profiles */
581
+ config?: YableConfig;
582
+ /** Named config profile used by descendants unless overridden */
583
+ tableProfile?: string;
482
584
  /** Default props applied to every `<Table>` in the subtree */
483
585
  tableProps?: Partial<Pick<TableProps<any>, 'striped' | 'bordered' | 'compact' | 'stickyHeader' | 'theme' | 'direction' | 'ariaLabel'>>;
484
586
  /** Default column definition merged under every table's own `defaultColumnDef` */
485
- defaultColumnDef?: Partial<ColumnDefBase<any, unknown>>;
587
+ defaultColumnDef?: Partial<ColumnDefBase<any, unknown>> & Partial<ColumnDefExtensions<any, unknown>>;
486
588
  }
487
589
  /**
488
590
  * Read the nearest `YableProvider` defaults.
@@ -506,7 +608,7 @@ declare function useYableDefaults(): YableDefaults;
506
608
  * </YableProvider>
507
609
  * ```
508
610
  */
509
- declare function YableProvider({ children, defaultColumnDef, striped, stickyHeader, bordered, compact, theme, direction, ariaLabel, }: YableDefaults & {
611
+ declare function YableProvider({ children, config, tableProfile, defaultColumnDef, striped, stickyHeader, bordered, compact, theme, direction, ariaLabel, }: YableDefaults & {
510
612
  children: ReactNode;
511
613
  striped?: boolean;
512
614
  stickyHeader?: boolean;
@@ -517,7 +619,7 @@ declare function YableProvider({ children, defaultColumnDef, striped, stickyHead
517
619
  ariaLabel?: string;
518
620
  }): react_jsx_runtime.JSX.Element;
519
621
 
520
- declare function Table<TData extends RowData>({ table, stickyHeader: stickyHeaderProp, striped: stripedProp, bordered: borderedProp, compact: compactProp, theme: themeProp, clickableRows, footer, loading, loadingComponent, loadingText, emptyMessage, emptyComponent, emptyIcon, emptyDetail, renderEmpty, renderLoading, children, className, direction: directionProp, statusBar, statusBarPanels, sidebar, sidebarPanels, defaultSidebarPanel, floatingFilters, columnVirtualization, columnVirtualizationOverscan, ariaLabel: ariaLabelProp, ...rest }: TableProps<TData>): react_jsx_runtime.JSX.Element;
622
+ declare function Table<TData extends RowData>({ table, stickyHeader: stickyHeaderProp, striped: stripedProp, bordered: borderedProp, compact: compactProp, theme: themeProp, config, configProfile, clickableRows, footer, loading, loadingComponent, loadingText, emptyMessage, emptyComponent, emptyIcon, emptyDetail, renderEmpty, renderLoading, children, className, direction: directionProp, statusBar, statusBarPanels, sidebar, sidebarPanels, defaultSidebarPanel, floatingFilters, columnVirtualization, columnVirtualizationOverscan, ariaLabel: ariaLabelProp, ...rest }: TableProps<TData>): react_jsx_runtime.JSX.Element;
521
623
 
522
624
  interface TableHeaderProps<TData extends RowData> {
523
625
  table: Table$1<TData>;
@@ -1071,16 +1173,19 @@ interface ContextMenuProps<TData extends RowData> {
1071
1173
  y: number;
1072
1174
  onClose: () => void;
1073
1175
  table: Table$1<TData>;
1176
+ /** Column the menu was opened on (right-clicked header/cell). */
1177
+ targetColumnId?: string;
1074
1178
  customItems?: ContextMenuItemDef[];
1075
1179
  }
1076
- declare function ContextMenu<TData extends RowData>({ x, y, onClose, table, customItems, }: ContextMenuProps<TData>): react_jsx_runtime.JSX.Element;
1180
+ declare function ContextMenu<TData extends RowData>({ x, y, onClose, table, targetColumnId, customItems, }: ContextMenuProps<TData>): react_jsx_runtime.JSX.Element;
1077
1181
 
1078
1182
  declare function useContextMenu(): {
1079
1183
  isOpen: boolean;
1080
1184
  x: number;
1081
1185
  y: number;
1082
1186
  targetTable: Table$1<any> | null;
1083
- open: <TData extends RowData>(clientX: number, clientY: number, table: Table$1<TData>) => void;
1187
+ targetColumnId: string | undefined;
1188
+ open: <TData extends RowData>(clientX: number, clientY: number, table: Table$1<TData>, columnId?: string) => void;
1084
1189
  close: () => void;
1085
1190
  };
1086
1191
 
@@ -1097,7 +1202,7 @@ declare function Sidebar<TData extends RowData>({ table, open, onClose, panels,
1097
1202
  interface ColumnsPanelProps<TData extends RowData> {
1098
1203
  table: Table$1<TData>;
1099
1204
  }
1100
- declare function ColumnsPanel<TData extends RowData>({ table, }: ColumnsPanelProps<TData>): react_jsx_runtime.JSX.Element;
1205
+ declare function ColumnsPanel<TData extends RowData>({ table }: ColumnsPanelProps<TData>): react_jsx_runtime.JSX.Element;
1101
1206
 
1102
1207
  interface FiltersPanelProps<TData extends RowData> {
1103
1208
  table: Table$1<TData>;
@@ -1225,4 +1330,4 @@ declare function CellText({ children, variant, bold, truncate, size, }: CellText
1225
1330
  */
1226
1331
  declare function mergeEditChanges<TData>(data: TData[], changes: Record<string, Partial<TData>>, getRowId?: (row: TData, index: number) => string): TData[];
1227
1332
 
1228
- export { type ActionItem, type ActionsColumnOptions, 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, CellRow, type CellRowProps, CellSelect, CellStack, type CellStackProps, CellStatus, CellStatusBadge, type CellStatusBadgeProps, type CellStatusProps, CellText, type CellTextProps, CellToggle, CellWithIcon, type CellWithIconProps, ColumnsPanel, ContextMenu, ContextMenuItem, type ContextMenuItemDef, DEFAULT_TEXT_RECIPE, DragHandle, ErrorBoundary, type ExpandColumnOptions, 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, type RowNumberColumnOptions, type SelectColumnOptions, 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 UseTablePersistenceOptions, type UseTablePersistenceReturn, type UseTableRowHeightsOptions, type UseThemeOptions, type UseTooltipOptions, type UseVirtualizationOptions, type UseVirtualizationResult, type VirtualColumn, type VirtualRow, type YableDefaults, YableProvider, actionsColumn, expandColumn, getMeasureRecipeForCellType, getRegisteredCellTypes, mergeEditChanges, resolveMeasureRecipe, rowNumberColumn, selectColumn, useAutoMeasurements, useCellFlash, useClipboard, useColumnVirtualization, useContextMenu, useFillHandle, useKeyboardNavigation, usePretextMeasurement, usePrintLayout, useRowAnimation, useRowDrag, useTable, useTableContext, useTablePersistence, useTableRowHeights, useTheme, useTooltip, useVirtualization, useYableDefaults };
1333
+ export { type ActionItem, type ActionsColumnOptions, 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, CellRow, type CellRowProps, CellSelect, CellStack, type CellStackProps, CellStatus, CellStatusBadge, type CellStatusBadgeProps, type CellStatusProps, CellText, type CellTextProps, CellToggle, CellWithIcon, type CellWithIconProps, ColumnsPanel, ContextMenu, ContextMenuItem, type ContextMenuItemDef, DEFAULT_TEXT_RECIPE, DragHandle, ErrorBoundary, type ExpandColumnOptions, 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, type ResolvedYableProfile, type RowNumberColumnOptions, type SelectColumnOptions, type ServerTableController, type ServerTableFetchArgs, type ServerTableFetchResult, type ServerTableUpdateArgs, 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 UseServerTableOptions, type UseTableOptions, type UseTablePersistenceOptions, type UseTablePersistenceReturn, type UseTableRowHeightsOptions, type UseThemeOptions, type UseTooltipOptions, type UseVirtualizationOptions, type UseVirtualizationResult, type VirtualColumn, type VirtualRow, type YableCellConfig, type YableCellConfigSet, type YableColumnConfig, type YableColumnConfigSet, type YableConfig, type YableDefaults, YableProvider, type YableRowConfig, type YableTableProfile, type YableTableVisualConfig, actionsColumn, applyYableConfigToColumns, createYableConfig, expandColumn, getMeasureRecipeForCellType, getRegisteredCellTypes, getYableDefaultColumnDef, mergeEditChanges, resolveMeasureRecipe, resolveYableProfile, rowNumberColumn, selectColumn, useAutoMeasurements, useCellFlash, useClipboard, useColumnVirtualization, useContextMenu, useFillHandle, useKeyboardNavigation, usePretextMeasurement, usePrintLayout, useRowAnimation, useRowDrag, useServerTable, useTable, useTableContext, useTablePersistence, useTableRowHeights, useTheme, useTooltip, useVirtualization, useYableDefaults };