@zvndev/yable-react 0.6.0 → 0.6.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 +53 -35
- package/dist/index.cjs +325 -56
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +36 -5
- package/dist/index.d.ts +36 -5
- package/dist/index.js +325 -56
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { RowData, ColumnDefBase, ColumnDefExtensions, Row, ColumnDef, Table as Table$1, Cell, Header, TableOptions, SortingState, ColumnFiltersState, PaginationState, TableState, Updater,
|
|
1
|
+
import { RowData, ColumnDefBase, ColumnDefExtensions, Row, ColumnDef, Table as Table$1, Cell, Column, Header, TableOptions, SortingState, ColumnFiltersState, PaginationState, TableState, Updater, 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
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'>>;
|
|
8
|
+
type YableTableVisualConfig = Partial<Pick<TableProps<any>, 'striped' | 'bordered' | 'compact' | 'stickyHeader' | 'theme' | 'direction' | 'ariaLabel' | 'clickableRows' | 'floatingFilters' | 'columnVirtualization' | 'columnVirtualizationOverscan' | 'adaptiveLayout' | 'statusBar' | 'sidebar' | 'sidebarPanels' | 'defaultSidebarPanel'>>;
|
|
9
9
|
type YableColumnConfig<TData extends RowData = any, TValue = unknown> = Partial<ColumnDefBase<TData, TValue>> & Partial<ColumnDefExtensions<TData, TValue>>;
|
|
10
10
|
interface YableRowConfig<TData extends RowData = any> {
|
|
11
11
|
className?: string | ((row: Row<TData>) => string | undefined);
|
|
@@ -38,6 +38,35 @@ declare function resolveYableProfile<TData extends RowData = any>(config?: Yable
|
|
|
38
38
|
declare function getYableDefaultColumnDef<TData extends RowData>(profile?: YableTableProfile<TData>): YableColumnConfig<TData> | undefined;
|
|
39
39
|
declare function applyYableConfigToColumns<TData extends RowData>(columns: ColumnDef<TData, any>[], profile?: YableTableProfile<TData>): ColumnDef<TData, any>[];
|
|
40
40
|
|
|
41
|
+
type AdaptiveTableLayoutMode = 'auto' | 'table' | 'cards';
|
|
42
|
+
interface AdaptiveTableCardContext<TData extends RowData> {
|
|
43
|
+
table: Table$1<TData>;
|
|
44
|
+
row: Row<TData>;
|
|
45
|
+
rowIndex: number;
|
|
46
|
+
cells: Cell<TData, unknown>[];
|
|
47
|
+
primaryCell?: Cell<TData, unknown>;
|
|
48
|
+
secondaryCells: Cell<TData, unknown>[];
|
|
49
|
+
visibleColumns: Column<TData, unknown>[];
|
|
50
|
+
}
|
|
51
|
+
interface AdaptiveTableLayoutOptions<TData extends RowData> {
|
|
52
|
+
/**
|
|
53
|
+
* `auto` switches at the configured container breakpoint, `cards` forces the
|
|
54
|
+
* adaptive card surface, and `table` keeps the desktop grid surface.
|
|
55
|
+
*/
|
|
56
|
+
mode?: AdaptiveTableLayoutMode;
|
|
57
|
+
/** Container width in px where `auto` switches to cards. Default: 720. */
|
|
58
|
+
breakpoint?: number;
|
|
59
|
+
/** Column shown as the card title. Defaults to the first visible column. */
|
|
60
|
+
primaryColumnId?: string;
|
|
61
|
+
/** Ordered secondary columns. Defaults to all remaining visible columns. */
|
|
62
|
+
secondaryColumnIds?: string[];
|
|
63
|
+
/** Columns omitted from the adaptive card surface. */
|
|
64
|
+
hiddenColumnIds?: string[];
|
|
65
|
+
/** Caps secondary fields when no explicit `secondaryColumnIds` are provided. Default: 8. */
|
|
66
|
+
maxSecondaryColumns?: number;
|
|
67
|
+
/** Fully custom card renderer for product-specific mobile/tablet layouts. */
|
|
68
|
+
renderCard?: (context: AdaptiveTableCardContext<TData>) => React.ReactNode;
|
|
69
|
+
}
|
|
41
70
|
interface TableProps<TData extends RowData> extends Omit<HTMLAttributes<HTMLDivElement>, 'children'> {
|
|
42
71
|
table: Table$1<TData>;
|
|
43
72
|
/** Enable sticky header */
|
|
@@ -96,6 +125,8 @@ interface TableProps<TData extends RowData> extends Omit<HTMLAttributes<HTMLDivE
|
|
|
96
125
|
columnVirtualization?: boolean;
|
|
97
126
|
/** Additional columns rendered beyond the viewport when column virtualization is enabled */
|
|
98
127
|
columnVirtualizationOverscan?: number;
|
|
128
|
+
/** Render a structural card layout for tablet/mobile while reusing this table instance */
|
|
129
|
+
adaptiveLayout?: boolean | AdaptiveTableLayoutOptions<TData>;
|
|
99
130
|
/** Accessible label for the grid container. Default: "Data table" */
|
|
100
131
|
ariaLabel?: string;
|
|
101
132
|
}
|
|
@@ -582,7 +613,7 @@ interface YableDefaults {
|
|
|
582
613
|
/** Named config profile used by descendants unless overridden */
|
|
583
614
|
tableProfile?: string;
|
|
584
615
|
/** Default props applied to every `<Table>` in the subtree */
|
|
585
|
-
tableProps?: Partial<Pick<TableProps<any>, 'striped' | 'bordered' | 'compact' | 'stickyHeader' | 'theme' | 'direction' | 'ariaLabel'>>;
|
|
616
|
+
tableProps?: Partial<Pick<TableProps<any>, 'striped' | 'bordered' | 'compact' | 'stickyHeader' | 'theme' | 'direction' | 'ariaLabel' | 'adaptiveLayout'>>;
|
|
586
617
|
/** Default column definition merged under every table's own `defaultColumnDef` */
|
|
587
618
|
defaultColumnDef?: Partial<ColumnDefBase<any, unknown>> & Partial<ColumnDefExtensions<any, unknown>>;
|
|
588
619
|
}
|
|
@@ -619,7 +650,7 @@ declare function YableProvider({ children, config, tableProfile, defaultColumnDe
|
|
|
619
650
|
ariaLabel?: string;
|
|
620
651
|
}): react_jsx_runtime.JSX.Element;
|
|
621
652
|
|
|
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;
|
|
653
|
+
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, adaptiveLayout: adaptiveLayoutProp, ariaLabel: ariaLabelProp, ...rest }: TableProps<TData>): react_jsx_runtime.JSX.Element;
|
|
623
654
|
|
|
624
655
|
interface TableHeaderProps<TData extends RowData> {
|
|
625
656
|
table: Table$1<TData>;
|
|
@@ -1335,4 +1366,4 @@ declare function CellText({ children, variant, bold, truncate, size, }: CellText
|
|
|
1335
1366
|
*/
|
|
1336
1367
|
declare function mergeEditChanges<TData>(data: TData[], changes: Record<string, Partial<TData>>, getRowId?: (row: TData, index: number) => string): TData[];
|
|
1337
1368
|
|
|
1338
|
-
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 };
|
|
1369
|
+
export { type ActionItem, type ActionsColumnOptions, type AdaptiveTableCardContext, type AdaptiveTableLayoutMode, type AdaptiveTableLayoutOptions, 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,11 +1,11 @@
|
|
|
1
|
-
import { RowData, ColumnDefBase, ColumnDefExtensions, Row, ColumnDef, Table as Table$1, Cell, Header, TableOptions, SortingState, ColumnFiltersState, PaginationState, TableState, Updater,
|
|
1
|
+
import { RowData, ColumnDefBase, ColumnDefExtensions, Row, ColumnDef, Table as Table$1, Cell, Column, Header, TableOptions, SortingState, ColumnFiltersState, PaginationState, TableState, Updater, 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
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'>>;
|
|
8
|
+
type YableTableVisualConfig = Partial<Pick<TableProps<any>, 'striped' | 'bordered' | 'compact' | 'stickyHeader' | 'theme' | 'direction' | 'ariaLabel' | 'clickableRows' | 'floatingFilters' | 'columnVirtualization' | 'columnVirtualizationOverscan' | 'adaptiveLayout' | 'statusBar' | 'sidebar' | 'sidebarPanels' | 'defaultSidebarPanel'>>;
|
|
9
9
|
type YableColumnConfig<TData extends RowData = any, TValue = unknown> = Partial<ColumnDefBase<TData, TValue>> & Partial<ColumnDefExtensions<TData, TValue>>;
|
|
10
10
|
interface YableRowConfig<TData extends RowData = any> {
|
|
11
11
|
className?: string | ((row: Row<TData>) => string | undefined);
|
|
@@ -38,6 +38,35 @@ declare function resolveYableProfile<TData extends RowData = any>(config?: Yable
|
|
|
38
38
|
declare function getYableDefaultColumnDef<TData extends RowData>(profile?: YableTableProfile<TData>): YableColumnConfig<TData> | undefined;
|
|
39
39
|
declare function applyYableConfigToColumns<TData extends RowData>(columns: ColumnDef<TData, any>[], profile?: YableTableProfile<TData>): ColumnDef<TData, any>[];
|
|
40
40
|
|
|
41
|
+
type AdaptiveTableLayoutMode = 'auto' | 'table' | 'cards';
|
|
42
|
+
interface AdaptiveTableCardContext<TData extends RowData> {
|
|
43
|
+
table: Table$1<TData>;
|
|
44
|
+
row: Row<TData>;
|
|
45
|
+
rowIndex: number;
|
|
46
|
+
cells: Cell<TData, unknown>[];
|
|
47
|
+
primaryCell?: Cell<TData, unknown>;
|
|
48
|
+
secondaryCells: Cell<TData, unknown>[];
|
|
49
|
+
visibleColumns: Column<TData, unknown>[];
|
|
50
|
+
}
|
|
51
|
+
interface AdaptiveTableLayoutOptions<TData extends RowData> {
|
|
52
|
+
/**
|
|
53
|
+
* `auto` switches at the configured container breakpoint, `cards` forces the
|
|
54
|
+
* adaptive card surface, and `table` keeps the desktop grid surface.
|
|
55
|
+
*/
|
|
56
|
+
mode?: AdaptiveTableLayoutMode;
|
|
57
|
+
/** Container width in px where `auto` switches to cards. Default: 720. */
|
|
58
|
+
breakpoint?: number;
|
|
59
|
+
/** Column shown as the card title. Defaults to the first visible column. */
|
|
60
|
+
primaryColumnId?: string;
|
|
61
|
+
/** Ordered secondary columns. Defaults to all remaining visible columns. */
|
|
62
|
+
secondaryColumnIds?: string[];
|
|
63
|
+
/** Columns omitted from the adaptive card surface. */
|
|
64
|
+
hiddenColumnIds?: string[];
|
|
65
|
+
/** Caps secondary fields when no explicit `secondaryColumnIds` are provided. Default: 8. */
|
|
66
|
+
maxSecondaryColumns?: number;
|
|
67
|
+
/** Fully custom card renderer for product-specific mobile/tablet layouts. */
|
|
68
|
+
renderCard?: (context: AdaptiveTableCardContext<TData>) => React.ReactNode;
|
|
69
|
+
}
|
|
41
70
|
interface TableProps<TData extends RowData> extends Omit<HTMLAttributes<HTMLDivElement>, 'children'> {
|
|
42
71
|
table: Table$1<TData>;
|
|
43
72
|
/** Enable sticky header */
|
|
@@ -96,6 +125,8 @@ interface TableProps<TData extends RowData> extends Omit<HTMLAttributes<HTMLDivE
|
|
|
96
125
|
columnVirtualization?: boolean;
|
|
97
126
|
/** Additional columns rendered beyond the viewport when column virtualization is enabled */
|
|
98
127
|
columnVirtualizationOverscan?: number;
|
|
128
|
+
/** Render a structural card layout for tablet/mobile while reusing this table instance */
|
|
129
|
+
adaptiveLayout?: boolean | AdaptiveTableLayoutOptions<TData>;
|
|
99
130
|
/** Accessible label for the grid container. Default: "Data table" */
|
|
100
131
|
ariaLabel?: string;
|
|
101
132
|
}
|
|
@@ -582,7 +613,7 @@ interface YableDefaults {
|
|
|
582
613
|
/** Named config profile used by descendants unless overridden */
|
|
583
614
|
tableProfile?: string;
|
|
584
615
|
/** Default props applied to every `<Table>` in the subtree */
|
|
585
|
-
tableProps?: Partial<Pick<TableProps<any>, 'striped' | 'bordered' | 'compact' | 'stickyHeader' | 'theme' | 'direction' | 'ariaLabel'>>;
|
|
616
|
+
tableProps?: Partial<Pick<TableProps<any>, 'striped' | 'bordered' | 'compact' | 'stickyHeader' | 'theme' | 'direction' | 'ariaLabel' | 'adaptiveLayout'>>;
|
|
586
617
|
/** Default column definition merged under every table's own `defaultColumnDef` */
|
|
587
618
|
defaultColumnDef?: Partial<ColumnDefBase<any, unknown>> & Partial<ColumnDefExtensions<any, unknown>>;
|
|
588
619
|
}
|
|
@@ -619,7 +650,7 @@ declare function YableProvider({ children, config, tableProfile, defaultColumnDe
|
|
|
619
650
|
ariaLabel?: string;
|
|
620
651
|
}): react_jsx_runtime.JSX.Element;
|
|
621
652
|
|
|
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;
|
|
653
|
+
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, adaptiveLayout: adaptiveLayoutProp, ariaLabel: ariaLabelProp, ...rest }: TableProps<TData>): react_jsx_runtime.JSX.Element;
|
|
623
654
|
|
|
624
655
|
interface TableHeaderProps<TData extends RowData> {
|
|
625
656
|
table: Table$1<TData>;
|
|
@@ -1335,4 +1366,4 @@ declare function CellText({ children, variant, bold, truncate, size, }: CellText
|
|
|
1335
1366
|
*/
|
|
1336
1367
|
declare function mergeEditChanges<TData>(data: TData[], changes: Record<string, Partial<TData>>, getRowId?: (row: TData, index: number) => string): TData[];
|
|
1337
1368
|
|
|
1338
|
-
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 };
|
|
1369
|
+
export { type ActionItem, type ActionsColumnOptions, type AdaptiveTableCardContext, type AdaptiveTableLayoutMode, type AdaptiveTableLayoutOptions, 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.js
CHANGED
|
@@ -2213,6 +2213,62 @@ function FillHandle({
|
|
|
2213
2213
|
}
|
|
2214
2214
|
);
|
|
2215
2215
|
}
|
|
2216
|
+
function renderCellContent(cell, table) {
|
|
2217
|
+
const column = cell.column;
|
|
2218
|
+
const isEditing = cell.getIsEditing();
|
|
2219
|
+
const isAlwaysEditable = cell.getIsAlwaysEditable();
|
|
2220
|
+
const cellStatus = table.getCellStatus(cell.row.id, column.id);
|
|
2221
|
+
const overrideValue = cellStatus !== "idle" ? table.getCellRenderValue(cell.row.id, column.id) : void 0;
|
|
2222
|
+
let content;
|
|
2223
|
+
const cellDef = column.columnDef.cell;
|
|
2224
|
+
const cellType = column.columnDef.cellType;
|
|
2225
|
+
if (typeof cellDef === "function") {
|
|
2226
|
+
const ctx = cell.getContext();
|
|
2227
|
+
if (overrideValue !== void 0) {
|
|
2228
|
+
const overriddenCtx = {
|
|
2229
|
+
...ctx,
|
|
2230
|
+
getValue: () => overrideValue,
|
|
2231
|
+
renderValue: () => overrideValue
|
|
2232
|
+
};
|
|
2233
|
+
content = cellDef(overriddenCtx);
|
|
2234
|
+
} else {
|
|
2235
|
+
content = cellDef(ctx);
|
|
2236
|
+
}
|
|
2237
|
+
} else if (cellType && !(isEditing || isAlwaysEditable)) {
|
|
2238
|
+
content = resolveCellType(cellType, cell.getContext(), column.columnDef.cellTypeProps);
|
|
2239
|
+
} else {
|
|
2240
|
+
content = overrideValue !== void 0 ? overrideValue : cell.renderValue();
|
|
2241
|
+
}
|
|
2242
|
+
if (!cell.row.getIsGrouped()) return content;
|
|
2243
|
+
if (column.id === cell.row.groupingColumnId) {
|
|
2244
|
+
const expanded = cell.row.getIsExpanded();
|
|
2245
|
+
return /* @__PURE__ */ jsxs("span", { className: "yable-group-cell", style: { paddingLeft: cell.row.depth * 16 }, children: [
|
|
2246
|
+
/* @__PURE__ */ jsx(
|
|
2247
|
+
"button",
|
|
2248
|
+
{
|
|
2249
|
+
type: "button",
|
|
2250
|
+
className: "yable-group-toggle",
|
|
2251
|
+
"aria-label": expanded ? "Collapse group" : "Expand group",
|
|
2252
|
+
"aria-expanded": expanded,
|
|
2253
|
+
onClick: cell.row.getToggleExpandedHandler(),
|
|
2254
|
+
children: expanded ? "\u25BE" : "\u25B8"
|
|
2255
|
+
}
|
|
2256
|
+
),
|
|
2257
|
+
/* @__PURE__ */ jsx("span", { className: "yable-group-value", children: String(cell.row.groupingValue ?? "") }),
|
|
2258
|
+
/* @__PURE__ */ jsxs("span", { className: "yable-group-count", children: [
|
|
2259
|
+
"(",
|
|
2260
|
+
cell.row.getLeafRows().length,
|
|
2261
|
+
")"
|
|
2262
|
+
] })
|
|
2263
|
+
] });
|
|
2264
|
+
}
|
|
2265
|
+
const aggDef = column.columnDef.aggregatedCell;
|
|
2266
|
+
if (typeof aggDef === "function") {
|
|
2267
|
+
return aggDef(cell.getContext());
|
|
2268
|
+
}
|
|
2269
|
+
const aggVal = cell.getValue();
|
|
2270
|
+
return aggVal == null ? null : aggVal;
|
|
2271
|
+
}
|
|
2216
2272
|
function TableCell({
|
|
2217
2273
|
cell,
|
|
2218
2274
|
table,
|
|
@@ -2248,60 +2304,8 @@ function TableCell({
|
|
|
2248
2304
|
const selectionEdges = table.getCellSelectionEdges(rowIndex, columnIndex);
|
|
2249
2305
|
const isCellSelected = selectionEdges !== null;
|
|
2250
2306
|
const isMultiCellSelection = selectionRange !== null && (selectionRange.start.rowIndex !== selectionRange.end.rowIndex || selectionRange.start.columnIndex !== selectionRange.end.columnIndex);
|
|
2251
|
-
const overrideValue = cellStatus !== "idle" ? table.getCellRenderValue(cell.row.id, column.id) : void 0;
|
|
2252
|
-
let content;
|
|
2253
|
-
const cellDef = column.columnDef.cell;
|
|
2254
|
-
const cellType = column.columnDef.cellType;
|
|
2255
|
-
if (typeof cellDef === "function") {
|
|
2256
|
-
const ctx = cell.getContext();
|
|
2257
|
-
if (overrideValue !== void 0) {
|
|
2258
|
-
const overriddenCtx = {
|
|
2259
|
-
...ctx,
|
|
2260
|
-
getValue: () => overrideValue,
|
|
2261
|
-
renderValue: () => overrideValue
|
|
2262
|
-
};
|
|
2263
|
-
content = cellDef(overriddenCtx);
|
|
2264
|
-
} else {
|
|
2265
|
-
content = cellDef(ctx);
|
|
2266
|
-
}
|
|
2267
|
-
} else if (cellType && !(isEditing || isAlwaysEditable)) {
|
|
2268
|
-
content = resolveCellType(cellType, cell.getContext(), column.columnDef.cellTypeProps);
|
|
2269
|
-
} else {
|
|
2270
|
-
content = overrideValue !== void 0 ? overrideValue : cell.renderValue();
|
|
2271
|
-
}
|
|
2272
2307
|
const isGroupRow = cell.row.getIsGrouped();
|
|
2273
|
-
|
|
2274
|
-
if (column.id === cell.row.groupingColumnId) {
|
|
2275
|
-
const expanded = cell.row.getIsExpanded();
|
|
2276
|
-
content = /* @__PURE__ */ jsxs("span", { className: "yable-group-cell", style: { paddingLeft: cell.row.depth * 16 }, children: [
|
|
2277
|
-
/* @__PURE__ */ jsx(
|
|
2278
|
-
"button",
|
|
2279
|
-
{
|
|
2280
|
-
type: "button",
|
|
2281
|
-
className: "yable-group-toggle",
|
|
2282
|
-
"aria-label": expanded ? "Collapse group" : "Expand group",
|
|
2283
|
-
"aria-expanded": expanded,
|
|
2284
|
-
onClick: cell.row.getToggleExpandedHandler(),
|
|
2285
|
-
children: expanded ? "\u25BE" : "\u25B8"
|
|
2286
|
-
}
|
|
2287
|
-
),
|
|
2288
|
-
/* @__PURE__ */ jsx("span", { className: "yable-group-value", children: String(cell.row.groupingValue ?? "") }),
|
|
2289
|
-
/* @__PURE__ */ jsxs("span", { className: "yable-group-count", children: [
|
|
2290
|
-
"(",
|
|
2291
|
-
cell.row.getLeafRows().length,
|
|
2292
|
-
")"
|
|
2293
|
-
] })
|
|
2294
|
-
] });
|
|
2295
|
-
} else {
|
|
2296
|
-
const aggDef = column.columnDef.aggregatedCell;
|
|
2297
|
-
if (typeof aggDef === "function") {
|
|
2298
|
-
content = aggDef(cell.getContext());
|
|
2299
|
-
} else {
|
|
2300
|
-
const aggVal = cell.getValue();
|
|
2301
|
-
content = aggVal == null ? null : aggVal;
|
|
2302
|
-
}
|
|
2303
|
-
}
|
|
2304
|
-
}
|
|
2308
|
+
const content = renderCellContent(cell, table);
|
|
2305
2309
|
const handleClick = useCallback(
|
|
2306
2310
|
(e) => {
|
|
2307
2311
|
if (cell.row.getIsGrouped()) return;
|
|
@@ -2866,6 +2870,202 @@ function isInteractiveClickTarget2(target) {
|
|
|
2866
2870
|
target.closest('input, textarea, select, button, a[href], [contenteditable="true"]')
|
|
2867
2871
|
);
|
|
2868
2872
|
}
|
|
2873
|
+
function AdaptiveTableCards({
|
|
2874
|
+
table,
|
|
2875
|
+
layout,
|
|
2876
|
+
clickableRows
|
|
2877
|
+
}) {
|
|
2878
|
+
const rows = table.getRowModel().rows;
|
|
2879
|
+
const visibleColumns = table.getVisibleLeafColumns();
|
|
2880
|
+
return /* @__PURE__ */ jsx("div", { className: "yable-adaptive-cards", role: "rowgroup", children: rows.map((row, rowIndex) => /* @__PURE__ */ jsx(
|
|
2881
|
+
AdaptiveTableCard,
|
|
2882
|
+
{
|
|
2883
|
+
row,
|
|
2884
|
+
table,
|
|
2885
|
+
rowIndex,
|
|
2886
|
+
visibleColumns,
|
|
2887
|
+
layout,
|
|
2888
|
+
clickable: clickableRows
|
|
2889
|
+
},
|
|
2890
|
+
row.id
|
|
2891
|
+
)) });
|
|
2892
|
+
}
|
|
2893
|
+
function AdaptiveTableCard({
|
|
2894
|
+
row,
|
|
2895
|
+
table,
|
|
2896
|
+
rowIndex,
|
|
2897
|
+
visibleColumns,
|
|
2898
|
+
layout,
|
|
2899
|
+
clickable
|
|
2900
|
+
}) {
|
|
2901
|
+
const { cells, primaryCell, secondaryCells } = getAdaptiveCells(row, visibleColumns, layout);
|
|
2902
|
+
return /* @__PURE__ */ jsx(
|
|
2903
|
+
"article",
|
|
2904
|
+
{
|
|
2905
|
+
className: "yable-adaptive-card",
|
|
2906
|
+
role: "row",
|
|
2907
|
+
"data-selected": row.getIsSelected() || void 0,
|
|
2908
|
+
"data-expanded": row.getIsExpanded() || void 0,
|
|
2909
|
+
"data-clickable": clickable || void 0,
|
|
2910
|
+
"data-row-id": row.id,
|
|
2911
|
+
"data-row-index": rowIndex,
|
|
2912
|
+
"aria-selected": table.options.enableRowSelection ? row.getIsSelected() : void 0,
|
|
2913
|
+
onClick: (e) => {
|
|
2914
|
+
if (table.options.enableRowClickSelection && row.getCanSelect() && !isInteractiveClickTarget3(e.target)) {
|
|
2915
|
+
row.toggleSelected();
|
|
2916
|
+
}
|
|
2917
|
+
if (clickable) emitRowEvent(table, "row:click", row, e.nativeEvent);
|
|
2918
|
+
},
|
|
2919
|
+
onDoubleClick: (e) => emitRowEvent(table, "row:dblclick", row, e.nativeEvent),
|
|
2920
|
+
onContextMenu: (e) => emitRowEvent(table, "row:contextmenu", row, e.nativeEvent),
|
|
2921
|
+
children: layout.renderCard ? layout.renderCard({
|
|
2922
|
+
table,
|
|
2923
|
+
row,
|
|
2924
|
+
rowIndex,
|
|
2925
|
+
cells,
|
|
2926
|
+
primaryCell,
|
|
2927
|
+
secondaryCells,
|
|
2928
|
+
visibleColumns
|
|
2929
|
+
}) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2930
|
+
primaryCell && /* @__PURE__ */ jsx("div", { className: "yable-adaptive-card-header", children: /* @__PURE__ */ jsx("div", { className: "yable-adaptive-card-title", children: /* @__PURE__ */ jsx(
|
|
2931
|
+
AdaptiveTableCardCell,
|
|
2932
|
+
{
|
|
2933
|
+
cell: primaryCell,
|
|
2934
|
+
table,
|
|
2935
|
+
rowIndex,
|
|
2936
|
+
columnIndex: 0,
|
|
2937
|
+
primary: true
|
|
2938
|
+
}
|
|
2939
|
+
) }) }),
|
|
2940
|
+
secondaryCells.length > 0 && /* @__PURE__ */ jsx("div", { className: "yable-adaptive-card-fields", children: secondaryCells.map((cell, index) => /* @__PURE__ */ jsx(
|
|
2941
|
+
AdaptiveTableCardCell,
|
|
2942
|
+
{
|
|
2943
|
+
cell,
|
|
2944
|
+
table,
|
|
2945
|
+
rowIndex,
|
|
2946
|
+
columnIndex: index + 1
|
|
2947
|
+
},
|
|
2948
|
+
cell.id
|
|
2949
|
+
)) })
|
|
2950
|
+
] })
|
|
2951
|
+
}
|
|
2952
|
+
);
|
|
2953
|
+
}
|
|
2954
|
+
function emitRowEvent(table, event, row, originalEvent) {
|
|
2955
|
+
table.events.emit(event, {
|
|
2956
|
+
row,
|
|
2957
|
+
cells: row.getAllCells(),
|
|
2958
|
+
originalEvent
|
|
2959
|
+
});
|
|
2960
|
+
}
|
|
2961
|
+
function emitCellEvent(table, event, cell, originalEvent) {
|
|
2962
|
+
table.events.emit(event, {
|
|
2963
|
+
cell,
|
|
2964
|
+
row: cell.row,
|
|
2965
|
+
column: cell.column,
|
|
2966
|
+
originalEvent
|
|
2967
|
+
});
|
|
2968
|
+
}
|
|
2969
|
+
function AdaptiveTableCardCell({
|
|
2970
|
+
cell,
|
|
2971
|
+
table,
|
|
2972
|
+
rowIndex,
|
|
2973
|
+
columnIndex,
|
|
2974
|
+
primary
|
|
2975
|
+
}) {
|
|
2976
|
+
const column = cell.column;
|
|
2977
|
+
const isEditing = cell.getIsEditing();
|
|
2978
|
+
const isAlwaysEditable = cell.getIsAlwaysEditable();
|
|
2979
|
+
const cellStatus = table.getCellStatus(cell.row.id, column.id);
|
|
2980
|
+
const cellErrorMessage = table.getCellErrorMessage(cell.row.id, column.id);
|
|
2981
|
+
const cellConflictWith = table.getCellConflictWith(cell.row.id, column.id);
|
|
2982
|
+
const content = renderCellContent(cell, table);
|
|
2983
|
+
const header = column.columnDef.header;
|
|
2984
|
+
const label = typeof header === "string" ? header : column.id;
|
|
2985
|
+
return /* @__PURE__ */ jsx(CellErrorBoundary, { resetKeys: [cell.getValue(), cellStatus], children: /* @__PURE__ */ jsxs(
|
|
2986
|
+
"div",
|
|
2987
|
+
{
|
|
2988
|
+
className: primary ? "yable-adaptive-card-primary" : "yable-adaptive-card-cell",
|
|
2989
|
+
"data-column-id": column.id,
|
|
2990
|
+
"data-cell-status": cellStatus !== "idle" ? cellStatus : void 0,
|
|
2991
|
+
"data-row-index": rowIndex,
|
|
2992
|
+
"data-column-index": columnIndex,
|
|
2993
|
+
role: "gridcell",
|
|
2994
|
+
"aria-colindex": columnIndex + 1,
|
|
2995
|
+
onClick: (e) => {
|
|
2996
|
+
if (cell.row.getIsGrouped()) return;
|
|
2997
|
+
emitCellEvent(table, "cell:click", cell, e.nativeEvent);
|
|
2998
|
+
if (canCellEnterEditMode(table, cell.row, column) && !isAlwaysEditable && !isEditing && !e.shiftKey && !e.metaKey && !e.ctrlKey) {
|
|
2999
|
+
table.startEditing(cell.row.id, column.id);
|
|
3000
|
+
}
|
|
3001
|
+
},
|
|
3002
|
+
onDoubleClick: (e) => emitCellEvent(table, "cell:dblclick", cell, e.nativeEvent),
|
|
3003
|
+
onContextMenu: (e) => emitCellEvent(table, "cell:contextmenu", cell, e.nativeEvent),
|
|
3004
|
+
children: [
|
|
3005
|
+
!primary && /* @__PURE__ */ jsx("span", { className: "yable-adaptive-card-label", children: label }),
|
|
3006
|
+
/* @__PURE__ */ jsxs("span", { className: "yable-adaptive-card-value", children: [
|
|
3007
|
+
content,
|
|
3008
|
+
cellStatus === "error" && /* @__PURE__ */ jsx(
|
|
3009
|
+
CellStatusBadge,
|
|
3010
|
+
{
|
|
3011
|
+
status: "error",
|
|
3012
|
+
message: cellErrorMessage,
|
|
3013
|
+
onRetry: () => void table.retryCommit(cell.row.id, column.id),
|
|
3014
|
+
onDismiss: () => table.dismissCommit(cell.row.id, column.id)
|
|
3015
|
+
}
|
|
3016
|
+
),
|
|
3017
|
+
cellStatus === "conflict" && /* @__PURE__ */ jsx(
|
|
3018
|
+
CellStatusBadge,
|
|
3019
|
+
{
|
|
3020
|
+
status: "conflict",
|
|
3021
|
+
conflictWith: cellConflictWith,
|
|
3022
|
+
onRetry: () => void table.retryCommit(cell.row.id, column.id),
|
|
3023
|
+
onDismiss: () => table.dismissCommit(cell.row.id, column.id)
|
|
3024
|
+
}
|
|
3025
|
+
)
|
|
3026
|
+
] })
|
|
3027
|
+
]
|
|
3028
|
+
}
|
|
3029
|
+
) });
|
|
3030
|
+
}
|
|
3031
|
+
function getAdaptiveCells(row, visibleColumns, layout) {
|
|
3032
|
+
const hidden = new Set(layout.hiddenColumnIds ?? []);
|
|
3033
|
+
const allCellsByColumn = new Map(row.getAllCells().map((cell) => [cell.column.id, cell]));
|
|
3034
|
+
const visibleCells = [];
|
|
3035
|
+
for (const column of visibleColumns) {
|
|
3036
|
+
if (hidden.has(column.id)) continue;
|
|
3037
|
+
const cell = allCellsByColumn.get(column.id);
|
|
3038
|
+
if (cell) visibleCells.push(cell);
|
|
3039
|
+
}
|
|
3040
|
+
const cellsByColumn = new Map(visibleCells.map((cell) => [cell.column.id, cell]));
|
|
3041
|
+
const primaryCell = (layout.primaryColumnId ? cellsByColumn.get(layout.primaryColumnId) : void 0) ?? visibleCells[0];
|
|
3042
|
+
const primaryColumnId = primaryCell?.column.id;
|
|
3043
|
+
let secondaryCells;
|
|
3044
|
+
if (layout.secondaryColumnIds) {
|
|
3045
|
+
secondaryCells = [];
|
|
3046
|
+
for (const columnId of layout.secondaryColumnIds) {
|
|
3047
|
+
if (hidden.has(columnId) || columnId === primaryColumnId) continue;
|
|
3048
|
+
const cell = cellsByColumn.get(columnId);
|
|
3049
|
+
if (cell) secondaryCells.push(cell);
|
|
3050
|
+
}
|
|
3051
|
+
} else {
|
|
3052
|
+
secondaryCells = visibleCells.filter((cell) => cell.column.id !== primaryColumnId);
|
|
3053
|
+
if (secondaryCells.length > layout.maxSecondaryColumns) {
|
|
3054
|
+
secondaryCells = secondaryCells.slice(0, layout.maxSecondaryColumns);
|
|
3055
|
+
}
|
|
3056
|
+
}
|
|
3057
|
+
return {
|
|
3058
|
+
cells: visibleCells,
|
|
3059
|
+
primaryCell,
|
|
3060
|
+
secondaryCells
|
|
3061
|
+
};
|
|
3062
|
+
}
|
|
3063
|
+
function isInteractiveClickTarget3(target) {
|
|
3064
|
+
if (!(target instanceof HTMLElement)) return false;
|
|
3065
|
+
return Boolean(
|
|
3066
|
+
target.closest('input, textarea, select, button, a[href], [contenteditable="true"]')
|
|
3067
|
+
);
|
|
3068
|
+
}
|
|
2869
3069
|
function TableFooter({ table }) {
|
|
2870
3070
|
const footerGroups = table.getFooterGroups();
|
|
2871
3071
|
if (!footerGroups.length) return null;
|
|
@@ -4193,6 +4393,7 @@ function Table({
|
|
|
4193
4393
|
floatingFilters,
|
|
4194
4394
|
columnVirtualization,
|
|
4195
4395
|
columnVirtualizationOverscan,
|
|
4396
|
+
adaptiveLayout: adaptiveLayoutProp,
|
|
4196
4397
|
ariaLabel: ariaLabelProp,
|
|
4197
4398
|
...rest
|
|
4198
4399
|
}) {
|
|
@@ -4218,6 +4419,7 @@ function Table({
|
|
|
4218
4419
|
const resolvedFloatingFilters = floatingFilters ?? profileTableProps?.floatingFilters;
|
|
4219
4420
|
const resolvedColumnVirtualization = columnVirtualization ?? profileTableProps?.columnVirtualization;
|
|
4220
4421
|
const resolvedColumnVirtualizationOverscan = columnVirtualizationOverscan ?? profileTableProps?.columnVirtualizationOverscan;
|
|
4422
|
+
const resolvedAdaptiveLayout = adaptiveLayoutProp ?? profileTableProps?.adaptiveLayout ?? providerTableProps?.adaptiveLayout;
|
|
4221
4423
|
const [sidebarOpen, setSidebarOpen] = useState(false);
|
|
4222
4424
|
const [sidebarPanel, setSidebarPanel] = useState(
|
|
4223
4425
|
resolvedDefaultSidebarPanel ?? "columns"
|
|
@@ -4225,6 +4427,11 @@ function Table({
|
|
|
4225
4427
|
const containerRef = useRef(null);
|
|
4226
4428
|
const horizontalScrollRef = useRef(null);
|
|
4227
4429
|
const isRtl = direction === "rtl";
|
|
4430
|
+
const adaptiveLayout = useMemo(
|
|
4431
|
+
() => normalizeAdaptiveLayout(resolvedAdaptiveLayout),
|
|
4432
|
+
[resolvedAdaptiveLayout]
|
|
4433
|
+
);
|
|
4434
|
+
const adaptiveLayoutActive = useAdaptiveLayoutActive(containerRef, adaptiveLayout);
|
|
4228
4435
|
const classNames = [
|
|
4229
4436
|
"yable",
|
|
4230
4437
|
theme && `yable-theme-${theme}`,
|
|
@@ -4235,6 +4442,8 @@ function Table({
|
|
|
4235
4442
|
loading && "yable-loading",
|
|
4236
4443
|
isRtl && "yable--rtl",
|
|
4237
4444
|
sidebarOpen && "yable--sidebar-open",
|
|
4445
|
+
adaptiveLayout && adaptiveLayout.mode !== "table" && "yable--adaptive-layout",
|
|
4446
|
+
adaptiveLayoutActive && "yable--adaptive-cards-active",
|
|
4238
4447
|
className
|
|
4239
4448
|
].filter(Boolean).join(" ");
|
|
4240
4449
|
const rows = table.getRowModel().rows;
|
|
@@ -4244,7 +4453,7 @@ function Table({
|
|
|
4244
4453
|
const allVisibleColumns = table.getVisibleLeafColumns();
|
|
4245
4454
|
const hasPinnedColumns = table.getLeftVisibleLeafColumns().length > 0 || table.getRightVisibleLeafColumns().length > 0;
|
|
4246
4455
|
const hasGroupedHeaders = table.getHeaderGroups().length > 1;
|
|
4247
|
-
const canVirtualizeColumns = Boolean(resolvedColumnVirtualization) && !hasPinnedColumns && !hasGroupedHeaders && allVisibleColumns.length > 0;
|
|
4456
|
+
const canVirtualizeColumns = !adaptiveLayoutActive && Boolean(resolvedColumnVirtualization) && !hasPinnedColumns && !hasGroupedHeaders && allVisibleColumns.length > 0;
|
|
4248
4457
|
const allVisibleColumnSizeSignature = allVisibleColumns.map((column) => `${column.id}:${column.getSize()}`).join("|");
|
|
4249
4458
|
const columnVirtualState = useColumnVirtualization({
|
|
4250
4459
|
containerRef: horizontalScrollRef,
|
|
@@ -4360,7 +4569,7 @@ function Table({
|
|
|
4360
4569
|
columnVirtualState.startOffset,
|
|
4361
4570
|
visibleColumnTotalSize
|
|
4362
4571
|
]);
|
|
4363
|
-
const
|
|
4572
|
+
const desktopTableNode = /* @__PURE__ */ jsxs(
|
|
4364
4573
|
"table",
|
|
4365
4574
|
{
|
|
4366
4575
|
className: "yable-table",
|
|
@@ -4382,6 +4591,14 @@ function Table({
|
|
|
4382
4591
|
]
|
|
4383
4592
|
}
|
|
4384
4593
|
);
|
|
4594
|
+
const tableNode = adaptiveLayoutActive && adaptiveLayout ? /* @__PURE__ */ jsx(
|
|
4595
|
+
AdaptiveTableCards,
|
|
4596
|
+
{
|
|
4597
|
+
table,
|
|
4598
|
+
layout: adaptiveLayout,
|
|
4599
|
+
clickableRows: resolvedClickableRows
|
|
4600
|
+
}
|
|
4601
|
+
) : desktopTableNode;
|
|
4385
4602
|
return /* @__PURE__ */ jsx(TableProvider, { value: table, children: /* @__PURE__ */ jsxs(
|
|
4386
4603
|
"div",
|
|
4387
4604
|
{
|
|
@@ -4397,7 +4614,7 @@ function Table({
|
|
|
4397
4614
|
...rest,
|
|
4398
4615
|
children: [
|
|
4399
4616
|
/* @__PURE__ */ jsxs("div", { className: "yable-main", children: [
|
|
4400
|
-
showColumnVirtualizationShell ? /* @__PURE__ */ jsx(
|
|
4617
|
+
showColumnVirtualizationShell && !adaptiveLayoutActive ? /* @__PURE__ */ jsx(
|
|
4401
4618
|
"div",
|
|
4402
4619
|
{
|
|
4403
4620
|
ref: horizontalScrollRef,
|
|
@@ -4513,6 +4730,58 @@ function Table({
|
|
|
4513
4730
|
}
|
|
4514
4731
|
) });
|
|
4515
4732
|
}
|
|
4733
|
+
var DEFAULT_ADAPTIVE_BREAKPOINT = 720;
|
|
4734
|
+
var DEFAULT_ADAPTIVE_SECONDARY_COLUMNS = 8;
|
|
4735
|
+
function normalizeAdaptiveLayout(layout) {
|
|
4736
|
+
if (!layout) return null;
|
|
4737
|
+
if (layout === true) {
|
|
4738
|
+
return {
|
|
4739
|
+
mode: "auto",
|
|
4740
|
+
breakpoint: DEFAULT_ADAPTIVE_BREAKPOINT,
|
|
4741
|
+
maxSecondaryColumns: DEFAULT_ADAPTIVE_SECONDARY_COLUMNS
|
|
4742
|
+
};
|
|
4743
|
+
}
|
|
4744
|
+
return {
|
|
4745
|
+
mode: layout.mode ?? "auto",
|
|
4746
|
+
breakpoint: layout.breakpoint ?? DEFAULT_ADAPTIVE_BREAKPOINT,
|
|
4747
|
+
primaryColumnId: layout.primaryColumnId,
|
|
4748
|
+
secondaryColumnIds: layout.secondaryColumnIds,
|
|
4749
|
+
hiddenColumnIds: layout.hiddenColumnIds,
|
|
4750
|
+
maxSecondaryColumns: layout.maxSecondaryColumns ?? DEFAULT_ADAPTIVE_SECONDARY_COLUMNS,
|
|
4751
|
+
renderCard: layout.renderCard
|
|
4752
|
+
};
|
|
4753
|
+
}
|
|
4754
|
+
function useAdaptiveLayoutActive(containerRef, layout) {
|
|
4755
|
+
const [active, setActive] = useState(() => layout?.mode === "cards");
|
|
4756
|
+
useEffect(() => {
|
|
4757
|
+
if (!layout) {
|
|
4758
|
+
setActive(false);
|
|
4759
|
+
return;
|
|
4760
|
+
}
|
|
4761
|
+
if (layout.mode === "cards" || layout.mode === "table") {
|
|
4762
|
+
setActive(layout.mode === "cards");
|
|
4763
|
+
return;
|
|
4764
|
+
}
|
|
4765
|
+
const node = containerRef.current;
|
|
4766
|
+
if (!node) return;
|
|
4767
|
+
const update = (width) => {
|
|
4768
|
+
setActive(width <= layout.breakpoint);
|
|
4769
|
+
};
|
|
4770
|
+
update(node.getBoundingClientRect().width || node.clientWidth);
|
|
4771
|
+
if (typeof ResizeObserver === "undefined") {
|
|
4772
|
+
const handleResize = () => update(node.getBoundingClientRect().width || node.clientWidth);
|
|
4773
|
+
window.addEventListener("resize", handleResize);
|
|
4774
|
+
return () => window.removeEventListener("resize", handleResize);
|
|
4775
|
+
}
|
|
4776
|
+
const observer = new ResizeObserver((entries) => {
|
|
4777
|
+
const width = entries[0]?.contentRect.width ?? node.getBoundingClientRect().width;
|
|
4778
|
+
update(width);
|
|
4779
|
+
});
|
|
4780
|
+
observer.observe(node);
|
|
4781
|
+
return () => observer.disconnect();
|
|
4782
|
+
}, [containerRef, layout]);
|
|
4783
|
+
return active;
|
|
4784
|
+
}
|
|
4516
4785
|
function ChevronLeftIcon() {
|
|
4517
4786
|
return /* @__PURE__ */ jsx("svg", { width: "14", height: "14", viewBox: "0 0 14 14", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsx("path", { d: "M8.5 3L4.5 7L8.5 11", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) });
|
|
4518
4787
|
}
|