@redsift/ds-mcp-server 12.5.0 → 12.5.1-muiv6-alpha.2
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/data/demos/patterns/_shared/StateDebugPanel.tsx +2 -2
- package/data/demos/patterns/_shared/columns.tsx +3 -12
- package/data/demos/patterns/_shared/defaults.ts +1 -1
- package/data/demos/patterns/_shared/filter-helpers.ts +1 -1
- package/data/demos/patterns/_shared/helpers.tsx +1 -1
- package/data/demos/patterns/_shared/server-logic.ts +1 -1
- package/data/demos/patterns/_shared/story-helpers.ts +23 -54
- package/data/demos/patterns/crossfiltered-datagrid-server-side/example.tsx +10 -10
- package/data/demos/patterns/drilldowned-datagrid-client-side/example.tsx +1 -1
- package/data/demos/patterns/drilldowned-datagrid-server-side/example.tsx +1 -1
- package/data/demos/patterns/single-datagrid-client-side/SingleDatagridClientSide.interaction.stories.tsx +1 -1
- package/data/demos/patterns/single-datagrid-client-side/example.tsx +4 -4
- package/data/demos/patterns/single-datagrid-server-side/SingleDatagridServerSide.interaction.stories.tsx +1 -1
- package/data/demos/patterns/single-datagrid-server-side/example.tsx +4 -4
- package/data/demos/patterns/stateful-single-datagrid-client-side/StatefulSingleDatagridClientSide.interaction.stories.tsx +1 -1
- package/data/demos/patterns/stateful-single-datagrid-client-side/example.tsx +4 -4
- package/data/demos/patterns/stateful-single-datagrid-server-side/StatefulSingleDatagridServerSide.interaction.stories.tsx +1 -1
- package/data/demos/patterns/stateful-single-datagrid-server-side/example.tsx +4 -4
- package/data/demos/patterns/tabbed-datagrid-server-side/example.tsx +1 -1
- package/data/docs/components/dashboard/Dashboard.json +2 -2
- package/data/docs/components/table/DataGrid.json +7 -7
- package/data/docs/components/table/GridToolbarFilterSemanticField.json +1 -1
- package/data/docs/components/table/StatefulDataGrid.json +7 -7
- package/data/docs/components/table/Toolbar.json +2 -8
- package/data/docs/components.json +21 -27
- package/data/docs/llms-full.txt +44 -44
- package/data/docs/llms.txt +4 -4
- package/data/docs/patterns-catalog.md +25 -24
- package/data/docs/patterns.json +4 -4
- package/data/metadata.json +2 -2
- package/data/patterns/crossfiltered-datagrid-server-side.mdx +1 -1
- package/data/patterns/drilldowned-datagrid-client-side.mdx +1 -1
- package/data/patterns/drilldowned-datagrid-server-side.mdx +1 -1
- package/data/patterns/single-datagrid-client-side.mdx +7 -7
- package/data/patterns/single-datagrid-server-side.mdx +4 -4
- package/data/patterns/stateful-single-datagrid-client-side.mdx +1 -1
- package/data/patterns/tabbed-datagrid-server-side.mdx +1 -1
- package/package.json +2 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useCallback, useEffect, useState } from 'react';
|
|
2
|
-
import type {
|
|
2
|
+
import type { GridApiPro } from '@mui/x-data-grid-pro/models/gridApiPro';
|
|
3
3
|
|
|
4
4
|
// localStorage key categories — must match @redsift/table internals
|
|
5
5
|
const LS_CATEGORIES = [
|
|
@@ -13,7 +13,7 @@ const LS_CATEGORIES = [
|
|
|
13
13
|
];
|
|
14
14
|
|
|
15
15
|
interface StateDebugPanelProps {
|
|
16
|
-
apiRef: React.MutableRefObject<
|
|
16
|
+
apiRef: React.MutableRefObject<GridApiPro>;
|
|
17
17
|
useRouter: () => { pathname: string; search: string; historyReplace: (newSearch: string) => void };
|
|
18
18
|
localStorageVersion?: number;
|
|
19
19
|
}
|
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { createColumn, TextCell } from '@redsift/table';
|
|
3
3
|
import { Flexbox, Icon, IconButtonLink, Pill } from '@redsift/design-system';
|
|
4
4
|
import { mdiArrowRight, mdiCheck, mdiClose } from '@redsift/icons';
|
|
5
|
-
import { GridColDef, GridRenderCellParams } from '@mui/x-data-grid-
|
|
5
|
+
import { GridColDef, GridRenderCellParams } from '@mui/x-data-grid-pro';
|
|
6
6
|
import { Row } from './data';
|
|
7
7
|
|
|
8
8
|
// -- Option constants -------------------------------------------------------
|
|
@@ -80,7 +80,6 @@ export const columns: GridColDef<Row>[] = [
|
|
|
80
80
|
field: 'Items',
|
|
81
81
|
headerName: 'Item',
|
|
82
82
|
flex: 1,
|
|
83
|
-
display: 'flex',
|
|
84
83
|
...createColumn('string'),
|
|
85
84
|
renderCell: ({ value }: GridRenderCellParams) => <TextCell>{value}</TextCell>,
|
|
86
85
|
},
|
|
@@ -89,7 +88,6 @@ export const columns: GridColDef<Row>[] = [
|
|
|
89
88
|
field: 'Category',
|
|
90
89
|
headerName: 'Category',
|
|
91
90
|
width: 120,
|
|
92
|
-
display: 'flex',
|
|
93
91
|
...createColumn('singleSelect'),
|
|
94
92
|
valueOptions: CATEGORY_OPTIONS,
|
|
95
93
|
renderCell: ({ value }: GridRenderCellParams) => <Pill color={categoryColor(value)}>{value}</Pill>,
|
|
@@ -99,7 +97,6 @@ export const columns: GridColDef<Row>[] = [
|
|
|
99
97
|
field: 'Paid',
|
|
100
98
|
headerName: 'Price',
|
|
101
99
|
width: 100,
|
|
102
|
-
display: 'flex',
|
|
103
100
|
...createColumn('number'),
|
|
104
101
|
renderCell: ({ value }: GridRenderCellParams) => <TextCell>{formatCurrency(value as number)}</TextCell>,
|
|
105
102
|
},
|
|
@@ -108,9 +105,8 @@ export const columns: GridColDef<Row>[] = [
|
|
|
108
105
|
field: 'Date',
|
|
109
106
|
headerName: 'Date',
|
|
110
107
|
width: 140,
|
|
111
|
-
display: 'flex',
|
|
112
108
|
...createColumn('date'),
|
|
113
|
-
valueGetter: (
|
|
109
|
+
valueGetter: (params: any) => parseDate(params.value),
|
|
114
110
|
renderCell: ({ value }: GridRenderCellParams) => <TextCell>{value ? formatDate(value as Date) : '—'}</TextCell>,
|
|
115
111
|
},
|
|
116
112
|
// DateTime
|
|
@@ -118,9 +114,8 @@ export const columns: GridColDef<Row>[] = [
|
|
|
118
114
|
field: 'DateTime',
|
|
119
115
|
headerName: 'Date & Time',
|
|
120
116
|
width: 180,
|
|
121
|
-
display: 'flex',
|
|
122
117
|
...createColumn('dateTime'),
|
|
123
|
-
valueGetter: (
|
|
118
|
+
valueGetter: (params: any) => parseDate(params.value),
|
|
124
119
|
renderCell: ({ value }: GridRenderCellParams) => <TextCell>{value ? formatDateTime(value as Date) : '—'}</TextCell>,
|
|
125
120
|
},
|
|
126
121
|
// Boolean — in stock
|
|
@@ -128,7 +123,6 @@ export const columns: GridColDef<Row>[] = [
|
|
|
128
123
|
field: 'InStock',
|
|
129
124
|
headerName: 'In Stock',
|
|
130
125
|
width: 90,
|
|
131
|
-
display: 'flex',
|
|
132
126
|
type: 'boolean',
|
|
133
127
|
renderCell: ({ value }: GridRenderCellParams) =>
|
|
134
128
|
value ? (
|
|
@@ -142,7 +136,6 @@ export const columns: GridColDef<Row>[] = [
|
|
|
142
136
|
field: 'Allergens',
|
|
143
137
|
headerName: 'Allergens',
|
|
144
138
|
flex: 1,
|
|
145
|
-
display: 'flex',
|
|
146
139
|
...createColumn('multiSelect'),
|
|
147
140
|
valueOptions: ALLERGEN_OPTIONS,
|
|
148
141
|
sortable: false,
|
|
@@ -165,7 +158,6 @@ export const columns: GridColDef<Row>[] = [
|
|
|
165
158
|
field: 'Tags',
|
|
166
159
|
headerName: 'Tags',
|
|
167
160
|
flex: 1,
|
|
168
|
-
display: 'flex',
|
|
169
161
|
...createColumn('tags'),
|
|
170
162
|
valueOptions: TAG_OPTIONS,
|
|
171
163
|
sortable: false,
|
|
@@ -188,7 +180,6 @@ export const columns: GridColDef<Row>[] = [
|
|
|
188
180
|
field: 'actions',
|
|
189
181
|
headerName: '',
|
|
190
182
|
width: 56,
|
|
191
|
-
display: 'flex',
|
|
192
183
|
hideable: false,
|
|
193
184
|
sortable: false,
|
|
194
185
|
filterable: false,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GridFilterModel, GridSortModel } from '@mui/x-data-grid-
|
|
1
|
+
import { GridFilterModel, GridSortModel } from '@mui/x-data-grid-pro';
|
|
2
2
|
import { Row, allRows } from './data';
|
|
3
3
|
import { Aggregates, computeAggregates, applyFilters } from './filter-helpers';
|
|
4
4
|
|
|
@@ -320,34 +320,25 @@ export const clickHeaderCheckbox = async (canvasElement: HTMLElement) => {
|
|
|
320
320
|
const headerCheckbox = canvasElement.querySelector('.MuiDataGrid-columnHeaderCheckbox input[type="checkbox"]');
|
|
321
321
|
expect(headerCheckbox).toBeTruthy();
|
|
322
322
|
},
|
|
323
|
-
{ timeout:
|
|
323
|
+
{ timeout: 3000 }
|
|
324
324
|
);
|
|
325
325
|
// Small yield to let React finish any pending microtask re-renders
|
|
326
326
|
await new Promise((resolve) => setTimeout(resolve, 200));
|
|
327
327
|
const headerCheckbox = canvasElement.querySelector('.MuiDataGrid-columnHeaderCheckbox input[type="checkbox"]')!;
|
|
328
|
-
|
|
329
|
-
// checkbox input doesn't trigger the native change event in Playwright/Chromium,
|
|
330
|
-
// causing server-side pagination grids to miss the selection update.
|
|
331
|
-
await userEvent.click(headerCheckbox);
|
|
328
|
+
fireEvent.click(headerCheckbox);
|
|
332
329
|
// Wait for React and MUI DataGrid to process the selection change
|
|
333
330
|
await new Promise((resolve) => setTimeout(resolve, 200));
|
|
334
331
|
};
|
|
335
332
|
|
|
336
333
|
/** Click a row checkbox by row index (0-based, within the visible page). */
|
|
337
334
|
export const clickRowCheckbox = async (canvasElement: HTMLElement, rowIndex: number) => {
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
const rows = canvasElement.querySelectorAll('.MuiDataGrid-row');
|
|
343
|
-
expect(rows.length).toBeGreaterThan(rowIndex);
|
|
344
|
-
const cb = rows[rowIndex].querySelector('input[type="checkbox"]');
|
|
345
|
-
expect(cb).toBeTruthy();
|
|
346
|
-
},
|
|
347
|
-
{ timeout: 5000 }
|
|
348
|
-
);
|
|
335
|
+
await waitFor(() => {
|
|
336
|
+
const rows = canvasElement.querySelectorAll('.MuiDataGrid-row');
|
|
337
|
+
expect(rows.length).toBeGreaterThan(rowIndex);
|
|
338
|
+
});
|
|
349
339
|
const rows = canvasElement.querySelectorAll('.MuiDataGrid-row');
|
|
350
|
-
const checkbox = rows[rowIndex].querySelector('input[type="checkbox"]')
|
|
340
|
+
const checkbox = rows[rowIndex].querySelector('input[type="checkbox"]');
|
|
341
|
+
if (!checkbox) throw new Error(`Could not find checkbox in row ${rowIndex}`);
|
|
351
342
|
await userEvent.click(checkbox);
|
|
352
343
|
// Wait for React and MUI DataGrid to process the selection change
|
|
353
344
|
await new Promise((resolve) => setTimeout(resolve, 200));
|
|
@@ -916,39 +907,18 @@ export const waitForPaginationEnabled = async (canvasElement: HTMLElement, direc
|
|
|
916
907
|
|
|
917
908
|
/**
|
|
918
909
|
* Change the page size via the MUI pagination "Rows per page" select.
|
|
919
|
-
*
|
|
920
|
-
* Select wrapper, NOT the inner display div that has the `onMouseDown` handler.
|
|
921
|
-
* We target `[role="combobox"]` inside the pagination toolbar instead, which is
|
|
922
|
-
* the actual interactive element rendered by `SelectInput`.
|
|
923
|
-
* `userEvent.click` in the Storybook Playwright runner doesn't reliably
|
|
924
|
-
* trigger mouseDown on MUI Select, so we use `fireEvent.mouseDown` directly,
|
|
925
|
-
* then `userEvent.click` to select the option in the dropdown.
|
|
910
|
+
* The dropdown menu renders as a portal on document.body.
|
|
926
911
|
*/
|
|
927
912
|
export const changePageSize = async (canvasElement: HTMLElement, newSize: number) => {
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
);
|
|
936
|
-
|
|
937
|
-
const select = canvasElement.querySelector('.MuiTablePagination-toolbar [role="combobox"]') as HTMLElement;
|
|
938
|
-
|
|
939
|
-
// Use fireEvent.mouseDown to reliably open MUI v7 Select dropdown
|
|
940
|
-
fireEvent.mouseDown(select);
|
|
941
|
-
|
|
942
|
-
// Wait for the dropdown to render (MUI uses a portal on document.body)
|
|
943
|
-
await waitFor(
|
|
944
|
-
() => {
|
|
945
|
-
const options = document.querySelectorAll('[role="option"]');
|
|
946
|
-
expect(options.length).toBeGreaterThan(0);
|
|
947
|
-
},
|
|
948
|
-
{ timeout: 5000 }
|
|
949
|
-
);
|
|
950
|
-
|
|
951
|
-
const options = document.querySelectorAll('[role="option"]');
|
|
913
|
+
const select = canvasElement.querySelector('.MuiTablePagination-select') as HTMLElement | null;
|
|
914
|
+
if (!select) throw new Error('Could not find page size select');
|
|
915
|
+
await userEvent.click(select);
|
|
916
|
+
// The menu renders as a MUI Popper on document.body
|
|
917
|
+
await waitFor(() => {
|
|
918
|
+
const options = document.querySelectorAll('li[role="option"]');
|
|
919
|
+
expect(options.length).toBeGreaterThan(0);
|
|
920
|
+
});
|
|
921
|
+
const options = document.querySelectorAll('li[role="option"]');
|
|
952
922
|
const target = Array.from(options).find((opt) => opt.textContent === String(newSize));
|
|
953
923
|
if (!target) throw new Error(`Could not find page size option "${newSize}"`);
|
|
954
924
|
await userEvent.click(target);
|
|
@@ -967,18 +937,17 @@ export const openColumnsPanel = async (canvasElement: HTMLElement) => {
|
|
|
967
937
|
await userEvent.click(btn);
|
|
968
938
|
// Wait for the panel to appear on document.body
|
|
969
939
|
await waitFor(() => {
|
|
970
|
-
const panel = document.querySelector('.MuiDataGrid-
|
|
940
|
+
const panel = document.querySelector('.MuiDataGrid-columnsPanel');
|
|
971
941
|
expect(panel).toBeTruthy();
|
|
972
942
|
});
|
|
973
943
|
};
|
|
974
944
|
|
|
975
945
|
/** Toggle a column's visibility in the columns panel by its label text. */
|
|
976
946
|
export const toggleColumnInPanel = async (fieldLabel: string) => {
|
|
977
|
-
const panel = document.querySelector('.MuiDataGrid-
|
|
947
|
+
const panel = document.querySelector('.MuiDataGrid-columnsPanel');
|
|
978
948
|
if (!panel) throw new Error('Columns panel is not open');
|
|
979
|
-
|
|
980
|
-
const
|
|
981
|
-
const target = rows.find((row) => row.textContent?.includes(fieldLabel));
|
|
949
|
+
const labels = Array.from(panel.querySelectorAll('.MuiFormControlLabel-root'));
|
|
950
|
+
const target = labels.find((label) => label.textContent?.includes(fieldLabel));
|
|
982
951
|
if (!target) throw new Error(`Could not find column "${fieldLabel}" in columns panel`);
|
|
983
952
|
const checkbox = target.querySelector('input[type="checkbox"]') as HTMLElement | null;
|
|
984
953
|
if (!checkbox) throw new Error(`Could not find checkbox for column "${fieldLabel}"`);
|
|
@@ -990,7 +959,7 @@ export const closeColumnsPanel = async () => {
|
|
|
990
959
|
// Press Escape to close the panel
|
|
991
960
|
await userEvent.keyboard('{Escape}');
|
|
992
961
|
await waitFor(() => {
|
|
993
|
-
const panel = document.querySelector('.MuiDataGrid-
|
|
962
|
+
const panel = document.querySelector('.MuiDataGrid-columnsPanel');
|
|
994
963
|
expect(panel).toBeFalsy();
|
|
995
964
|
});
|
|
996
965
|
};
|
|
@@ -2,9 +2,9 @@ import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
|
|
2
2
|
import { DataGrid } from '@redsift/table';
|
|
3
3
|
import { Flexbox } from '@redsift/design-system';
|
|
4
4
|
import { DataCard, DataRow } from '@redsift/dashboard';
|
|
5
|
-
import { BarChart, PieChart
|
|
5
|
+
import { BarChart, PieChart } from '@redsift/charts';
|
|
6
6
|
import { mdiShapeOutline, mdiToggleSwitch, mdiFoodOff } from '@redsift/icons';
|
|
7
|
-
import { GridFilterModel, GridSortModel } from '@mui/x-data-grid-
|
|
7
|
+
import { GridFilterModel, GridSortModel } from '@mui/x-data-grid-pro';
|
|
8
8
|
import { Row } from '../_shared/data';
|
|
9
9
|
import { columns, CATEGORY_OPTIONS, ALLERGEN_OPTIONS } from '../_shared/columns';
|
|
10
10
|
import { fetchBakeryData, FetchResult } from '../_shared/api-client';
|
|
@@ -207,8 +207,8 @@ export default () => {
|
|
|
207
207
|
}}
|
|
208
208
|
data={itemsChartData}
|
|
209
209
|
sliceRole="option"
|
|
210
|
-
onSliceClick={(datum:
|
|
211
|
-
const key = datum.data.key;
|
|
210
|
+
onSliceClick={(datum: any) => {
|
|
211
|
+
const key = datum.data.key as string;
|
|
212
212
|
setFilterModel((prev) => {
|
|
213
213
|
const selected = getSelectedFromFilterModel(prev, 'Items');
|
|
214
214
|
const next = selected.includes(key) ? selected.filter((v) => v !== key) : [...selected, key];
|
|
@@ -216,8 +216,8 @@ export default () => {
|
|
|
216
216
|
});
|
|
217
217
|
setPage(0);
|
|
218
218
|
}}
|
|
219
|
-
isSliceSelected={(datum:
|
|
220
|
-
itemsSelection.length === 0 || itemsSelection.includes(datum.data.key)
|
|
219
|
+
isSliceSelected={(datum: any) =>
|
|
220
|
+
itemsSelection.length === 0 || itemsSelection.includes(datum.data.key as string)
|
|
221
221
|
}
|
|
222
222
|
/>
|
|
223
223
|
|
|
@@ -238,8 +238,8 @@ export default () => {
|
|
|
238
238
|
barProps={{ gap: 20 }}
|
|
239
239
|
data={tagsChartData}
|
|
240
240
|
barRole="option"
|
|
241
|
-
onBarClick={(datum:
|
|
242
|
-
const key =
|
|
241
|
+
onBarClick={(datum: any) => {
|
|
242
|
+
const key = datum.data.key as string;
|
|
243
243
|
setFilterModel((prev) => {
|
|
244
244
|
const selected = getSelectedFromFilterModel(prev, 'Tags');
|
|
245
245
|
const next = selected.includes(key) ? selected.filter((v) => v !== key) : [...selected, key];
|
|
@@ -247,8 +247,8 @@ export default () => {
|
|
|
247
247
|
});
|
|
248
248
|
setPage(0);
|
|
249
249
|
}}
|
|
250
|
-
isBarSelected={(datum:
|
|
251
|
-
tagsSelection.length === 0 || tagsSelection.includes(
|
|
250
|
+
isBarSelected={(datum: any) =>
|
|
251
|
+
tagsSelection.length === 0 || tagsSelection.includes(datum.data.key as string)
|
|
252
252
|
}
|
|
253
253
|
/>
|
|
254
254
|
</Flexbox>
|
|
@@ -3,7 +3,7 @@ import { DataGrid } from '@redsift/table';
|
|
|
3
3
|
import { Flexbox } from '@redsift/design-system';
|
|
4
4
|
import { DataCard, DataRow } from '@redsift/dashboard';
|
|
5
5
|
import { mdiShapeOutline, mdiToggleSwitch, mdiFoodOff } from '@redsift/icons';
|
|
6
|
-
import { GridFilterModel } from '@mui/x-data-grid-
|
|
6
|
+
import { GridFilterModel } from '@mui/x-data-grid-pro';
|
|
7
7
|
import { rows } from '../_shared/data';
|
|
8
8
|
import { columns, CATEGORY_OPTIONS, ALLERGEN_OPTIONS } from '../_shared/columns';
|
|
9
9
|
import { CustomToolbar } from '../_shared/helpers';
|
|
@@ -3,7 +3,7 @@ import { DataGrid } from '@redsift/table';
|
|
|
3
3
|
import { Flexbox } from '@redsift/design-system';
|
|
4
4
|
import { DataCard, DataRow } from '@redsift/dashboard';
|
|
5
5
|
import { mdiShapeOutline, mdiToggleSwitch, mdiFoodOff } from '@redsift/icons';
|
|
6
|
-
import { GridFilterModel, GridSortModel } from '@mui/x-data-grid-
|
|
6
|
+
import { GridFilterModel, GridSortModel } from '@mui/x-data-grid-pro';
|
|
7
7
|
import { Row } from '../_shared/data';
|
|
8
8
|
import { columns, CATEGORY_OPTIONS, ALLERGEN_OPTIONS } from '../_shared/columns';
|
|
9
9
|
import { fetchBakeryData, FetchResult } from '../_shared/api-client';
|
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import type { Meta, StoryObj } from '@storybook/react';
|
|
3
3
|
import { within, userEvent } from '@storybook/testing-library';
|
|
4
4
|
import { expect } from '@storybook/jest';
|
|
5
|
-
import { GridFilterModel } from '@mui/x-data-grid-
|
|
5
|
+
import { GridFilterModel } from '@mui/x-data-grid-pro';
|
|
6
6
|
|
|
7
7
|
import Example from './example';
|
|
8
8
|
import WithLoadingExample from './with-loading';
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
|
-
import { DataGrid
|
|
2
|
+
import { DataGrid } from '@redsift/table';
|
|
3
3
|
import { Flexbox } from '@redsift/design-system';
|
|
4
|
-
import { GridFilterModel, GridRowSelectionModel } from '@mui/x-data-grid-
|
|
4
|
+
import { GridFilterModel, GridRowSelectionModel } from '@mui/x-data-grid-pro';
|
|
5
5
|
import { rows } from '../_shared/data';
|
|
6
6
|
import { columns } from '../_shared/columns';
|
|
7
7
|
import { CustomToolbar, BulkActionBar } from '../_shared/helpers';
|
|
8
8
|
import { DEFAULT_FILTER_MODEL, DEFAULT_SORT_MODEL } from '../_shared/defaults';
|
|
9
9
|
|
|
10
10
|
export default ({ initialFilterModel }: { initialFilterModel?: GridFilterModel }) => {
|
|
11
|
-
const [selectionModel, setSelectionModel] = useState<GridRowSelectionModel>(
|
|
11
|
+
const [selectionModel, setSelectionModel] = useState<GridRowSelectionModel>([]);
|
|
12
12
|
|
|
13
13
|
return (
|
|
14
14
|
<div style={{ width: '100%' }}>
|
|
15
15
|
<Flexbox flexDirection="column" gap="0px">
|
|
16
16
|
<BulkActionBar
|
|
17
|
-
count={
|
|
17
|
+
count={selectionModel.length}
|
|
18
18
|
onLog={() => console.log('Selected:', selectionModel)}
|
|
19
19
|
onDelete={() => console.log('Delete:', selectionModel)}
|
|
20
20
|
/>
|
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import type { Meta, StoryObj } from '@storybook/react';
|
|
3
3
|
import { within, userEvent } from '@storybook/testing-library';
|
|
4
4
|
import { expect } from '@storybook/jest';
|
|
5
|
-
import { GridFilterModel } from '@mui/x-data-grid-
|
|
5
|
+
import { GridFilterModel } from '@mui/x-data-grid-pro';
|
|
6
6
|
|
|
7
7
|
import Example from './example';
|
|
8
8
|
import WithLoadingExample from './with-loading';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
2
|
-
import { DataGrid
|
|
2
|
+
import { DataGrid } from '@redsift/table';
|
|
3
3
|
import { Flexbox } from '@redsift/design-system';
|
|
4
|
-
import { GridFilterModel, GridRowSelectionModel, GridSortModel } from '@mui/x-data-grid-
|
|
4
|
+
import { GridFilterModel, GridRowSelectionModel, GridSortModel } from '@mui/x-data-grid-pro';
|
|
5
5
|
import { Row } from '../_shared/data';
|
|
6
6
|
import { columns } from '../_shared/columns';
|
|
7
7
|
import { fetchBakeryData } from '../_shared/api-client';
|
|
@@ -16,7 +16,7 @@ export default ({ initialFilterModel }: { initialFilterModel?: GridFilterModel }
|
|
|
16
16
|
const [pageSize, setPageSize] = useState(10);
|
|
17
17
|
const [sortModel, setSortModel] = useState<GridSortModel>(DEFAULT_SORT_MODEL);
|
|
18
18
|
const [filterModel, setFilterModel] = useState<GridFilterModel>(initialFilterModel ?? DEFAULT_FILTER_MODEL);
|
|
19
|
-
const [selectionModel, setSelectionModel] = useState<GridRowSelectionModel>(
|
|
19
|
+
const [selectionModel, setSelectionModel] = useState<GridRowSelectionModel>([]);
|
|
20
20
|
|
|
21
21
|
const quickFilterText = (filterModel as { quickFilterValues?: string[] }).quickFilterValues?.join(' ') || '';
|
|
22
22
|
const debounceRef = useRef<ReturnType<typeof setTimeout>>();
|
|
@@ -54,7 +54,7 @@ export default ({ initialFilterModel }: { initialFilterModel?: GridFilterModel }
|
|
|
54
54
|
<div style={{ width: '100%' }}>
|
|
55
55
|
<Flexbox flexDirection="column" gap="0px">
|
|
56
56
|
<BulkActionBar
|
|
57
|
-
count={
|
|
57
|
+
count={selectionModel.length}
|
|
58
58
|
onLog={() => console.log('Selected:', selectionModel)}
|
|
59
59
|
onDelete={() => console.log('Delete:', selectionModel)}
|
|
60
60
|
/>
|
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import type { Meta, StoryObj } from '@storybook/react';
|
|
3
3
|
import { within, userEvent } from '@storybook/testing-library';
|
|
4
4
|
import { expect } from '@storybook/jest';
|
|
5
|
-
import { GridFilterModel } from '@mui/x-data-grid-
|
|
5
|
+
import { GridFilterModel } from '@mui/x-data-grid-pro';
|
|
6
6
|
|
|
7
7
|
import Example from './example';
|
|
8
8
|
import WithLoadingExample from './with-loading';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
|
-
import { StatefulDataGrid
|
|
2
|
+
import { StatefulDataGrid } from '@redsift/table';
|
|
3
3
|
import { Flexbox } from '@redsift/design-system';
|
|
4
|
-
import { GridFilterModel, GridRowSelectionModel, useGridApiRef } from '@mui/x-data-grid-
|
|
4
|
+
import { GridFilterModel, GridRowSelectionModel, useGridApiRef } from '@mui/x-data-grid-pro';
|
|
5
5
|
import { rows } from '../_shared/data';
|
|
6
6
|
import { columns } from '../_shared/columns';
|
|
7
7
|
import { CustomToolbar, BulkActionBar } from '../_shared/helpers';
|
|
@@ -16,14 +16,14 @@ interface Props {
|
|
|
16
16
|
|
|
17
17
|
export default ({ initialFilterModel, useRouter = useRouterAdapter }: Props) => {
|
|
18
18
|
const apiRef = useGridApiRef();
|
|
19
|
-
const [selectionModel, setSelectionModel] = useState<GridRowSelectionModel>(
|
|
19
|
+
const [selectionModel, setSelectionModel] = useState<GridRowSelectionModel>([]);
|
|
20
20
|
|
|
21
21
|
return (
|
|
22
22
|
<div style={{ width: '100%' }}>
|
|
23
23
|
<StateDebugPanel apiRef={apiRef} useRouter={useRouter} localStorageVersion={1} />
|
|
24
24
|
<Flexbox flexDirection="column" gap="0px">
|
|
25
25
|
<BulkActionBar
|
|
26
|
-
count={
|
|
26
|
+
count={selectionModel.length}
|
|
27
27
|
onLog={() => console.log('Selected:', selectionModel)}
|
|
28
28
|
onDelete={() => console.log('Delete:', selectionModel)}
|
|
29
29
|
/>
|
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import type { Meta, StoryObj } from '@storybook/react';
|
|
3
3
|
import { within, userEvent } from '@storybook/testing-library';
|
|
4
4
|
import { expect } from '@storybook/jest';
|
|
5
|
-
import { GridFilterModel } from '@mui/x-data-grid-
|
|
5
|
+
import { GridFilterModel } from '@mui/x-data-grid-pro';
|
|
6
6
|
|
|
7
7
|
import Example from './example';
|
|
8
8
|
import WithLoadingExample from './with-loading';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
2
|
-
import { StatefulDataGrid
|
|
2
|
+
import { StatefulDataGrid } from '@redsift/table';
|
|
3
3
|
import { Flexbox } from '@redsift/design-system';
|
|
4
|
-
import { GridFilterModel, GridRowSelectionModel, GridSortModel, useGridApiRef } from '@mui/x-data-grid-
|
|
4
|
+
import { GridFilterModel, GridRowSelectionModel, GridSortModel, useGridApiRef } from '@mui/x-data-grid-pro';
|
|
5
5
|
import { Row } from '../_shared/data';
|
|
6
6
|
import { columns } from '../_shared/columns';
|
|
7
7
|
import { fetchBakeryData } from '../_shared/api-client';
|
|
@@ -20,7 +20,7 @@ export default ({ initialFilterModel, useRouter = useRouterAdapter }: Props) =>
|
|
|
20
20
|
const [rows, setRows] = useState<Row[]>([]);
|
|
21
21
|
const [totalRows, setTotalRows] = useState(0);
|
|
22
22
|
const [loading, setLoading] = useState(true);
|
|
23
|
-
const [selectionModel, setSelectionModel] = useState<GridRowSelectionModel>(
|
|
23
|
+
const [selectionModel, setSelectionModel] = useState<GridRowSelectionModel>([]);
|
|
24
24
|
|
|
25
25
|
// Refs track the latest model values so fetchData() always reads current state.
|
|
26
26
|
// StatefulDataGrid manages filter/sort/pagination internally — we use callbacks
|
|
@@ -55,7 +55,7 @@ export default ({ initialFilterModel, useRouter = useRouterAdapter }: Props) =>
|
|
|
55
55
|
<StateDebugPanel apiRef={apiRef} useRouter={useRouter} localStorageVersion={1} />
|
|
56
56
|
<Flexbox flexDirection="column" gap="0px">
|
|
57
57
|
<BulkActionBar
|
|
58
|
-
count={
|
|
58
|
+
count={selectionModel.length}
|
|
59
59
|
onLog={() => console.log('Selected:', selectionModel)}
|
|
60
60
|
onDelete={() => console.log('Delete:', selectionModel)}
|
|
61
61
|
/>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
2
2
|
import { DataGrid } from '@redsift/table';
|
|
3
3
|
import { Flexbox, Pill, Number, Text, Tabs, Tab } from '@redsift/design-system';
|
|
4
|
-
import { GridFilterModel, GridSortModel } from '@mui/x-data-grid-
|
|
4
|
+
import { GridFilterModel, GridSortModel } from '@mui/x-data-grid-pro';
|
|
5
5
|
import { Row } from '../_shared/data';
|
|
6
6
|
import { columns, CATEGORY_OPTIONS } from '../_shared/columns';
|
|
7
7
|
import { fetchBakeryData } from '../_shared/api-client';
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
},
|
|
15
15
|
{
|
|
16
16
|
"name": "dataGridApiRef",
|
|
17
|
-
"description": "Datagrid API Ref.
|
|
18
|
-
"type": "MutableRefObject<
|
|
17
|
+
"description": "Datagrid API Ref.",
|
|
18
|
+
"type": "MutableRefObject<GridApiPro>",
|
|
19
19
|
"required": false,
|
|
20
20
|
"defaultValue": null,
|
|
21
21
|
"category": "props"
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
{
|
|
56
56
|
"name": "paginationProps",
|
|
57
57
|
"description": "Props to forward to the pagination component.",
|
|
58
|
-
"type": "Omit<TablePaginationProps, \"paginationMode\" | \"component\" | \"
|
|
58
|
+
"type": "Omit<TablePaginationProps, \"paginationMode\" | \"component\" | \"page\" | \"count\" | \"onPageChange\" | \"onRowsPerPageChange\" | \"rowsPerPage\" | \"rowsPerPageOptions\">",
|
|
59
59
|
"required": false,
|
|
60
60
|
"defaultValue": null,
|
|
61
61
|
"category": "props"
|
|
@@ -72,17 +72,17 @@
|
|
|
72
72
|
"category": "props"
|
|
73
73
|
},
|
|
74
74
|
{
|
|
75
|
-
"name": "
|
|
76
|
-
"description": "
|
|
77
|
-
"type": "
|
|
75
|
+
"name": "className",
|
|
76
|
+
"description": "",
|
|
77
|
+
"type": "string",
|
|
78
78
|
"required": false,
|
|
79
79
|
"defaultValue": null,
|
|
80
80
|
"category": "props"
|
|
81
81
|
},
|
|
82
82
|
{
|
|
83
|
-
"name": "
|
|
84
|
-
"description": "
|
|
85
|
-
"type": "
|
|
83
|
+
"name": "style",
|
|
84
|
+
"description": "",
|
|
85
|
+
"type": "CSSProperties",
|
|
86
86
|
"required": false,
|
|
87
87
|
"defaultValue": null,
|
|
88
88
|
"category": "props"
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
{
|
|
80
80
|
"name": "paginationProps",
|
|
81
81
|
"description": "Props to forward to the pagination component.",
|
|
82
|
-
"type": "Omit<TablePaginationProps, \"paginationMode\" | \"component\" | \"
|
|
82
|
+
"type": "Omit<TablePaginationProps, \"paginationMode\" | \"component\" | \"page\" | \"count\" | \"onPageChange\" | \"onRowsPerPageChange\" | \"rowsPerPage\" | \"rowsPerPageOptions\">",
|
|
83
83
|
"required": false,
|
|
84
84
|
"defaultValue": null,
|
|
85
85
|
"category": "props"
|
|
@@ -96,17 +96,17 @@
|
|
|
96
96
|
"category": "props"
|
|
97
97
|
},
|
|
98
98
|
{
|
|
99
|
-
"name": "
|
|
100
|
-
"description": "
|
|
101
|
-
"type": "
|
|
99
|
+
"name": "className",
|
|
100
|
+
"description": "",
|
|
101
|
+
"type": "string",
|
|
102
102
|
"required": false,
|
|
103
103
|
"defaultValue": null,
|
|
104
104
|
"category": "props"
|
|
105
105
|
},
|
|
106
106
|
{
|
|
107
|
-
"name": "
|
|
108
|
-
"description": "
|
|
109
|
-
"type": "
|
|
107
|
+
"name": "style",
|
|
108
|
+
"description": "",
|
|
109
|
+
"type": "CSSProperties",
|
|
110
110
|
"required": false,
|
|
111
111
|
"defaultValue": null,
|
|
112
112
|
"category": "props"
|
|
@@ -7,10 +7,7 @@
|
|
|
7
7
|
{
|
|
8
8
|
"name": "columnsButtonProps",
|
|
9
9
|
"description": "Props to forward to the column button.",
|
|
10
|
-
"type":
|
|
11
|
-
"GridToolbarColumnsButtonProps",
|
|
12
|
-
"GridToolbarColumnsButtonProps & RefAttributes<HTMLButtonElement>"
|
|
13
|
-
],
|
|
10
|
+
"type": "GridToolbarColumnsProps",
|
|
14
11
|
"required": false,
|
|
15
12
|
"defaultValue": null,
|
|
16
13
|
"category": "props"
|
|
@@ -26,10 +23,7 @@
|
|
|
26
23
|
{
|
|
27
24
|
"name": "densityButtonProps",
|
|
28
25
|
"description": "Props to forward to the density button.",
|
|
29
|
-
"type":
|
|
30
|
-
"GridToolbarDensitySelectorProps",
|
|
31
|
-
"GridToolbarDensitySelectorProps & RefAttributes<HTMLButtonElement>"
|
|
32
|
-
],
|
|
26
|
+
"type": "GridToolbarDensityProps",
|
|
33
27
|
"required": false,
|
|
34
28
|
"defaultValue": null,
|
|
35
29
|
"category": "props"
|