@wallarm-org/design-system 0.72.3 → 0.73.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/components/Table/TableContext/TableProvider.js +5 -3
- package/dist/components/Table/TableContext/types.d.ts +1 -0
- package/dist/components/Table/TableSettingsMenu/TableSettingsMenu.js +6 -2
- package/dist/components/Table/types.d.ts +8 -0
- package/dist/metadata/components.json +2 -2
- package/package.json +1 -1
|
@@ -8,7 +8,7 @@ import { useTableState } from "../hooks/index.js";
|
|
|
8
8
|
import { TABLE_EXPAND_COLUMN_ID, TABLE_MIN_COLUMN_WIDTH, TABLE_SELECT_COLUMN_ID, TABLE_SKELETON_ROWS, TABLE_VIRTUALIZATION_OVERSCAN, createExpandColumn, createSelectionColumn } from "../lib/index.js";
|
|
9
9
|
import { TableContext } from "./TableContext.js";
|
|
10
10
|
const TableProvider = (props)=>{
|
|
11
|
-
const { data, columns, isLoading = false, isLoadingPrevious = false, skeletonCount = TABLE_SKELETON_ROWS, children, getRowId, sorting: sortingProp, onSortingChange, manualSorting = false, rowSelection: rowSelectionProp, onRowSelectionChange, columnSizing: columnSizingProp, onColumnSizingChange, columnPinning: columnPinningProp, onColumnPinningChange, columnOrder: columnOrderProp, onColumnOrderChange, grouping: groupingProp, onGroupingChange, expanded: expandedProp, onExpandedChange, renderGroupRow, getSubRows, renderExpandedRow, columnVisibility: columnVisibilityProp, onColumnVisibilityChange, defaultColumnVisibility, defaultColumnOrder, virtualized, estimateRowHeight, overscan = TABLE_VIRTUALIZATION_OVERSCAN, onEndReached, onEndReachedThreshold, onStartReached, onStartReachedThreshold, initialScrollToRowId, onMasterCellClick, activeRowId: activeRowIdProp } = props;
|
|
11
|
+
const { data, columns, isLoading = false, isLoadingPrevious = false, skeletonCount = TABLE_SKELETON_ROWS, children, getRowId, sorting: sortingProp, onSortingChange, manualSorting = false, rowSelection: rowSelectionProp, onRowSelectionChange, columnSizing: columnSizingProp, onColumnSizingChange, columnPinning: columnPinningProp, onColumnPinningChange, columnOrder: columnOrderProp, onColumnOrderChange, grouping: groupingProp, onGroupingChange, expanded: expandedProp, onExpandedChange, renderGroupRow, getSubRows, renderExpandedRow, columnVisibility: columnVisibilityProp, onColumnVisibilityChange, defaultColumnVisibility, defaultColumnOrder, virtualized, estimateRowHeight, overscan = TABLE_VIRTUALIZATION_OVERSCAN, onEndReached, onEndReachedThreshold, onStartReached, onStartReachedThreshold, initialScrollToRowId, onMasterCellClick, activeRowId: activeRowIdProp, onSettingsOpenChange } = props;
|
|
12
12
|
const masterCellActiveRowId = activeRowIdProp ?? null;
|
|
13
13
|
const sortingEnabled = !!onSortingChange;
|
|
14
14
|
const selectionEnabled = !!onRowSelectionChange;
|
|
@@ -218,7 +218,8 @@ const TableProvider = (props)=>{
|
|
|
218
218
|
onStartReachedThreshold,
|
|
219
219
|
initialScrollToRowId,
|
|
220
220
|
onMasterCellClick,
|
|
221
|
-
activeRowId: masterCellActiveRowId
|
|
221
|
+
activeRowId: masterCellActiveRowId,
|
|
222
|
+
onSettingsOpenChange
|
|
222
223
|
}), [
|
|
223
224
|
table,
|
|
224
225
|
isLoading,
|
|
@@ -248,7 +249,8 @@ const TableProvider = (props)=>{
|
|
|
248
249
|
onStartReachedThreshold,
|
|
249
250
|
initialScrollToRowId,
|
|
250
251
|
masterCellActiveRowId,
|
|
251
|
-
onMasterCellClick
|
|
252
|
+
onMasterCellClick,
|
|
253
|
+
onSettingsOpenChange
|
|
252
254
|
]);
|
|
253
255
|
useEffect(()=>{
|
|
254
256
|
if (!selectionEnabled) return;
|
|
@@ -42,6 +42,7 @@ export interface TableContextValue<T> {
|
|
|
42
42
|
initialScrollToRowId?: string;
|
|
43
43
|
onMasterCellClick?: (rowId: string) => void;
|
|
44
44
|
activeRowId: string | null;
|
|
45
|
+
onSettingsOpenChange?: (open: boolean) => void;
|
|
45
46
|
}
|
|
46
47
|
export interface TableProviderProps<T> extends Omit<TableProps<T>, 'children' | 'aria-label'> {
|
|
47
48
|
children: ReactNode;
|
|
@@ -24,10 +24,14 @@ const TableSettingsMenu = ({ 'data-testid': testIdProp, children, ...rest })=>{
|
|
|
24
24
|
const testId = useTestId('settings-menu', testIdProp);
|
|
25
25
|
const { anchorNode } = useTableSettingsMenuContext();
|
|
26
26
|
const ctx = useTableContext();
|
|
27
|
-
const { table, alwaysPinnedLeft, masterColumnId } = ctx;
|
|
27
|
+
const { table, alwaysPinnedLeft, masterColumnId, onSettingsOpenChange } = ctx;
|
|
28
28
|
const hasTextDescription = table.getAllLeafColumns().some((col)=>col.columnDef.meta?.description?.type === 'text');
|
|
29
29
|
const [search, setSearch] = useState('');
|
|
30
30
|
const [menuOpen, setMenuOpen] = useState(false);
|
|
31
|
+
const handleOpenChange = (open)=>{
|
|
32
|
+
setMenuOpen(open);
|
|
33
|
+
onSettingsOpenChange?.(open);
|
|
34
|
+
};
|
|
31
35
|
const allColumns = table.getAllLeafColumns().filter((col)=>col.id !== TABLE_SELECT_COLUMN_ID && col.id !== TABLE_EXPAND_COLUMN_ID);
|
|
32
36
|
const filteredColumns = useMemo(()=>{
|
|
33
37
|
if (!search) return allColumns;
|
|
@@ -111,7 +115,7 @@ const TableSettingsMenu = ({ 'data-testid': testIdProp, children, ...rest })=>{
|
|
|
111
115
|
children: /*#__PURE__*/ jsx("span", {
|
|
112
116
|
className: "inline-flex",
|
|
113
117
|
children: /*#__PURE__*/ jsxs(DropdownMenu, {
|
|
114
|
-
onOpenChange:
|
|
118
|
+
onOpenChange: handleOpenChange,
|
|
115
119
|
children: [
|
|
116
120
|
/*#__PURE__*/ jsx(DropdownMenuTrigger, {
|
|
117
121
|
asChild: true,
|
|
@@ -190,6 +190,14 @@ export interface TableProps<T> extends TestableProps {
|
|
|
190
190
|
onColumnVisibilityChange?: TableOnChangeFn<TableVisibilityState>;
|
|
191
191
|
defaultColumnVisibility?: TableVisibilityState;
|
|
192
192
|
defaultColumnOrder?: string[];
|
|
193
|
+
/**
|
|
194
|
+
* Fired when the built-in column-settings menu opens (`true`) or closes
|
|
195
|
+
* (`false`). The menu's open state otherwise lives inside the DS and is not
|
|
196
|
+
* observable, so consumers that want to defer expensive work — e.g. refetch
|
|
197
|
+
* once with the final column selection instead of on every toggle — can hook
|
|
198
|
+
* the close edge here.
|
|
199
|
+
*/
|
|
200
|
+
onSettingsOpenChange?: (open: boolean) => void;
|
|
193
201
|
/** Enable row virtualization. `'container'` virtualizes within the scroll container; `'window'` virtualizes against the browser window. */
|
|
194
202
|
virtualized?: TableVirtualized;
|
|
195
203
|
estimateRowHeight?: (index: number) => number;
|