@azrico/reactgrid 1.5.1 → 1.5.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.
@@ -1,318 +1,362 @@
1
- import '@inovua/reactdatagrid-enterprise/index.css';
2
- import '../themes/base_styles.css';
3
- import '../themes/grid.css';
4
- import { get_default_key } from '../func/func_grid';
5
- import { ContextMenu } from '@azrico/controls/context-menu';
6
- import React from 'react';
7
- import { createTheme, ThemeProvider, useTheme } from '@mui/material/styles';
8
-
9
- import ReactDataGrid from '@inovua/reactdatagrid-enterprise';
10
- import clsx from 'clsx';
11
- import { useComponentSize } from 'react-use-size';
12
-
13
- import { AzGridOptions, AzGridProps, DataGridWrapperProps } from '../types/types';
14
- import { useGridEvents } from '../hooks/useGridEvents';
15
- import { useColumnData } from '../hooks/useColumnData';
16
- import { useDataSource } from '../hooks/useDatasource';
17
- import { useGridSearch } from '../hooks/useGridSearch';
18
- import { apply_column_a11y } from '../func/func_a11y';
19
- /* -------------------------------------------------------------------------- */
20
-
21
- /* -------------------------------------------------------------------------- */
22
-
23
- const defaultOptions: AzGridOptions = {
24
- //filterTypes: defaultfilterTypes,
25
- remoteFilter: false,
26
- remoteSort: false,
27
- editStartEvent: 'click',
28
- rowReorderColumn: false,
29
- resizable: true,
30
- columnUserSelect: true,
31
- rowIndexColumn: true,
32
- rowHeight: 35,
33
- };
34
- const forcedOptions: AzGridOptions = {
35
- idProperty: '__table_id',
36
- nodesProperty: '__children',
37
- theme: 'default-light',
38
- };
39
-
40
- const dynamic_option_names = ['selected', 'cellSelection', 'loading', 'limit', 'skip'];
41
- /* -------------------------------------------------------------------------- */
42
- export function AzGrid(props: AzGridProps) {
43
- const gridRefBackup = React.useRef<any>(null);
44
- const gridRef = props.gridRef || gridRefBackup;
45
- const liveGridRef = React.useRef<any>(null);
46
-
47
- /* -------------------------------------------------------------------------- */
48
- /* Columns */
49
- /* -------------------------------------------------------------------------- */
50
- const cached_columns = useColumnData(props);
51
- const dataSource = useDataSource(props.dataSource, props);
52
- const a11y_columns = React.useMemo(
53
- () => cached_columns.map((col) => apply_column_a11y(col, { gridEditable: !!props.editable })),
54
- [cached_columns, props.editable]
55
- );
56
- /* -------------------------------------------------------------------------- */
57
- /* Row changes */
58
- /* -------------------------------------------------------------------------- */
59
-
60
- const base_gridOptions = React.useMemo<AzGridOptions>(() => {
61
- const firstcolumn = cached_columns[0];
62
- const licenseKey = props.licenseKey || get_default_key();
63
- const events: AzGridOptions = {
64
- onSkipChange: props.onSkipChange,
65
- onLimitChange: props.onLimitChange,
66
- onEditComplete: props.onEditComplete,
67
- };
68
- const extra_ops: AzGridOptions = {
69
- onSelectionChange: props.onSelectionChange,
70
- onCellSelectionChange: props.onCellSelectionChange,
71
-
72
- licenseKey: licenseKey,
73
- editable: props.editable as any, //bug in types of the plugin
74
- treeColumn: props.allowChildRows ? firstcolumn.name : undefined,
75
- renderRowDetails: props.RowDetail,
76
- };
77
- return { ...defaultOptions, ...events, ...extra_ops };
78
- }, [
79
- cached_columns,
80
- props.allowChildRows,
81
- props.editable,
82
- props.RowDetail,
83
- props.onEditComplete,
84
- ]);
85
-
86
- const static_gridOptions = React.useMemo<AzGridOptions>(() => {
87
- const finalres = { ...base_gridOptions, ...props.gridOptions, ...forcedOptions };
88
-
89
- //append filter types instead of replacing it
90
- if (finalres.filterTypes)
91
- finalres.filterTypes = Object.assign(
92
- {},
93
- ReactDataGrid.defaultProps.filterTypes,
94
- finalres.filterTypes
95
- );
96
-
97
- return finalres;
98
- }, [props.gridOptions, base_gridOptions, forcedOptions]);
99
-
100
- const dynamic_gridOptions = React.useMemo<AzGridOptions>(
101
- () => {
102
- const res = {};
103
- dynamic_option_names.map((r) => {
104
- res[r] = props[r];
105
- });
106
- return res;
107
- },
108
- dynamic_option_names.map((r) => props[r])
109
- );
110
-
111
- return (
112
- <DataGridEventsWrapper
113
- {...props}
114
- gridRef={gridRef}
115
- liveGridRef={liveGridRef}
116
- static_gridOptions={static_gridOptions}
117
- dynamic_gridOptions={dynamic_gridOptions}
118
- columns={a11y_columns}
119
- dataSource={dataSource}
120
- highlightedRow={props.highlightedRow}
121
- />
122
- );
123
- }
124
-
125
- /* -------------------------------------------------------------------------- */
126
- /**
127
- * Wrapper for menu events
128
- * @param props
129
- * @returns
130
- */
131
- function DataGridEventsWrapper(props: DataGridWrapperProps) {
132
- const scopeRef = React.useRef<HTMLDivElement>(null);
133
- const hostTheme = useTheme();
134
- // Keep the existing context menu and its portal in this grid's CSS scope.
135
- const menuTheme = React.useMemo(
136
- () => createTheme(hostTheme, {
137
- components: { MuiPopper: { defaultProps: { container: () => scopeRef.current } } },
138
- }),
139
- [hostTheme]
140
- );
141
- const themeClass = `azgrid-theme-${props.theme ?? (props.dark ? 'dark' : 'light')}`;
142
- /* -------------------------------------------------------------------------- */
143
- const {
144
- onRowClick,
145
- onRowContextMenu,
146
- onRenderRow,
147
- update_menuRow,
148
- menuAnchorEl,
149
- menuRow,
150
- } = useGridEvents(props.gridRef.current, props);
151
- /* -------------------------------------------------------------------------- */
152
- /**
153
- * Merge click events into grid options
154
- */
155
- const static_gridOptions = React.useMemo<AzGridOptions>(() => {
156
- const opts: any = props.static_gridOptions || {};
157
- const events: AzGridOptions = {
158
- onRowClick: onRowClick,
159
- onRowContextMenu: onRowContextMenu,
160
- };
161
-
162
- // internal row attributes first, consumer's onRenderRow last so it can override them
163
- const consumerOnRenderRow = opts.onRenderRow;
164
- const renderProps: any = {
165
- onRenderRow: consumerOnRenderRow
166
- ? (rowProps) => {
167
- onRenderRow(rowProps);
168
- consumerOnRenderRow(rowProps);
169
- }
170
- : onRenderRow,
171
- };
172
-
173
- const gridEditable = !!props.editable;
174
- const a11yProps: any = {
175
- headerProps: { role: 'row', 'aria-rowindex': 1, ...opts.headerProps },
176
- rowIndexColumn: apply_column_a11y(
177
- typeof opts.rowIndexColumn === 'object' ? opts.rowIndexColumn : {},
178
- { role: 'rowheader', gridEditable }
179
- ),
180
- };
181
- if (opts.checkboxColumn)
182
- a11yProps.checkboxColumn = apply_column_a11y(
183
- typeof opts.checkboxColumn === 'object' ? opts.checkboxColumn : {},
184
- { gridEditable, markReadonly: false }
185
- );
186
-
187
- return {
188
- ...opts,
189
- ...events,
190
- ...renderProps,
191
- ...a11yProps,
192
- };
193
- }, [props.static_gridOptions, props.editable, onRowClick, onRowContextMenu, onRenderRow]);
194
-
195
- /* -------------------------------------------------------------------------- */
196
- //TODO ContextMenu not from mui...
197
- return (
198
- <div ref={scopeRef} className={clsx('azgrid-scope azgrid-flexed azgrid-flexlayout', themeClass)}>
199
- <ThemeProvider theme={menuTheme}>
200
- <ContextMenu
201
- classname="azgrid-context-menu"
202
- menuAnchorEl={menuAnchorEl}
203
- menuRow={menuRow}
204
- close={update_menuRow}
205
- dontAutoClose={false}
206
- menu_items={props.contextMenuItems as any}
207
- />
208
- </ThemeProvider>
209
- {props.details_dataSource ? (
210
- <DataGridDetailsWrapper {...props} static_gridOptions={static_gridOptions} />
211
- ) : (
212
- <DataGridSizeWrapper {...props} static_gridOptions={static_gridOptions} />
213
- )}
214
- </div>
215
- );
216
- }
217
-
218
- function DataGridDetailsWrapper(props: DataGridWrapperProps) {
219
- const cached_details_columns = useColumnData(props.details_columns);
220
- const details_dataSource = useDataSource(props.details_dataSource, props);
221
- const renderDetailsGrid = ({ data }) => {
222
- return (
223
- <ReactDataGrid
224
- theme="default-light"
225
- className={clsx('azgrid', `azgrid-theme-${props.theme ?? (props.dark ? 'dark' : 'light')}`)}
226
- defaultFilterValue={props.details_filter}
227
- dataSource={details_dataSource}
228
- columns={cached_details_columns}
229
- />
230
- );
231
- };
232
-
233
- /**
234
- * Merge details into grid
235
- */
236
- const static_gridOptions = React.useMemo<AzGridOptions>(() => {
237
- const finalresult = props.static_gridOptions || {};
238
- finalresult['renderDetailsGrid'] = renderDetailsGrid;
239
- return finalresult;
240
- }, [props.static_gridOptions, props.theme, props.dark]);
241
-
242
- return <DataGridSizeWrapper {...props} static_gridOptions={static_gridOptions} />;
243
- }
244
-
245
- function DataGridSizeWrapper(props: DataGridWrapperProps) {
246
- if (props.delayedSize) {
247
- return <DataGridDelayedSizeWrapper {...props} />;
248
- } else {
249
- return <DataGridNormalSizeWrapper {...props} />;
250
- }
251
- }
252
-
253
- /* -------------------------------------------------------------------------- */
254
- function DataGridNormalSizeWrapper(props: DataGridWrapperProps) {
255
- return props.advancedFilterFields ? (
256
- <DataGridSearchWrapper {...props} />
257
- ) : (
258
- <DataGridCore {...props} />
259
- );
260
- }
261
- function DataGridDelayedSizeWrapper(props: DataGridWrapperProps) {
262
- const { ref, height, width } = useComponentSize();
263
- return (
264
- <div ref={ref} className={'azgrid-filler azgrid-nooverflow '}>
265
- <div
266
- className={'azgrid-delayedresize azgrid-flexlayout'}
267
- style={{ height: height, width: width }}
268
- >
269
- {props.advancedFilterFields ? (
270
- <DataGridSearchWrapper {...props} />
271
- ) : (
272
- <DataGridCore {...props} />
273
- )}
274
- </div>
275
- </div>
276
- );
277
- }
278
- function DataGridSearchWrapper(props: DataGridWrapperProps) {
279
- const { element, filteredData } = useGridSearch(props.gridRef.current, props);
280
-
281
- return (
282
- <div className={'azgrid-flexed azgrid-flexlayout azgrid-nooverflow'}>
283
- {element}
284
- <DataGridCore {...props} dataSource={filteredData} />
285
- </div>
286
- );
287
- }
288
- function DataGridCore(props: DataGridWrapperProps) {
289
- return (
290
- <div className={clsx(props.className, 'azgrid-flexed', 'azgrid-flexlayout')}>
291
- <ReactDataGrid
292
- {...props.static_gridOptions}
293
- {...props.dynamic_gridOptions}
294
- rowIndexColumn={props.static_gridOptions.rowIndexColumn || true}
295
- handle={(ref) => {
296
- if (ref) props.gridRef.current = ref.current as any;
297
- if (props.liveGridRef) props.liveGridRef.current = ref as any;
298
- }}
299
- theme="default-light"
300
- className={clsx(
301
- 'azgrid azgrid-flexed',
302
- props.allowChildRows && 'azgrid-tree',
303
- `azgrid-theme-${props.theme ?? (props.dark ? 'dark' : 'light')}`
304
- )}
305
- columns={props.columns}
306
- dataSource={props.dataSource}
307
- />
308
- {props.children}
309
- </div>
310
- );
311
- }
312
- /* -------------------------------------------------------------------------- */
313
- /* -------------------------------------------------------------------------- */
314
- /* -------------------------------------------------------------------------- */
315
- /* -------------------------------------------------------------------------- */
316
-
317
- /* -------------------------------------------------------------------------- */
318
- export default AzGrid;
1
+ import '@inovua/reactdatagrid-enterprise/index.css';
2
+ import '../themes/base_styles.css';
3
+ import '../themes/grid.css';
4
+ import { get_default_key } from '../func/func_grid';
5
+ import { ContextMenu } from '@azrico/controls/context-menu';
6
+ import React from 'react';
7
+ import { createTheme, ThemeProvider, useTheme } from '@mui/material/styles';
8
+
9
+ import ReactDataGrid from '@inovua/reactdatagrid-enterprise';
10
+ import clsx from 'clsx';
11
+ import { useComponentSize } from 'react-use-size';
12
+
13
+ import { AzGridOptions, AzGridProps, DataGridWrapperProps } from '../types/types';
14
+ import { useGridEvents } from '../hooks/useGridEvents';
15
+ import { useColumnData } from '../hooks/useColumnData';
16
+ import { useDataSource } from '../hooks/useDatasource';
17
+ import { useGridSearch } from '../hooks/useGridSearch';
18
+ import { apply_column_a11y } from '../func/func_a11y';
19
+ /* -------------------------------------------------------------------------- */
20
+
21
+ /* -------------------------------------------------------------------------- */
22
+
23
+ const defaultOptions: AzGridOptions = {
24
+ //filterTypes: defaultfilterTypes,
25
+ remoteFilter: false,
26
+ remoteSort: false,
27
+ editStartEvent: 'click',
28
+ rowReorderColumn: false,
29
+ resizable: true,
30
+ columnUserSelect: true,
31
+ rowIndexColumn: true,
32
+ rowHeight: 35,
33
+ };
34
+ const forcedOptions: AzGridOptions = {
35
+ idProperty: '__table_id',
36
+ nodesProperty: '__children',
37
+ theme: 'default-light',
38
+ };
39
+
40
+ const dynamic_option_names = ['selected', 'cellSelection', 'loading', 'limit', 'skip'];
41
+ // consumer callbacks forwarded to the grid; wrapped so a new function doesn't re-render the grid
42
+ const callback_option_names = [
43
+ 'onSkipChange',
44
+ 'onLimitChange',
45
+ 'onEditComplete',
46
+ 'onSelectionChange',
47
+ 'onCellSelectionChange',
48
+ ];
49
+ // props DataGridCore renders from, other props don't need to re-render the grid
50
+ const core_prop_names = [
51
+ 'className',
52
+ 'static_gridOptions',
53
+ 'dynamic_gridOptions',
54
+ 'columns',
55
+ 'dataSource',
56
+ 'gridRef',
57
+ 'liveGridRef',
58
+ 'allowChildRows',
59
+ 'theme',
60
+ 'dark',
61
+ 'children',
62
+ ];
63
+ /* -------------------------------------------------------------------------- */
64
+ export function AzGrid(props: AzGridProps) {
65
+ const gridRefBackup = React.useRef<any>(null);
66
+ const gridRef = props.gridRef || gridRefBackup;
67
+ const liveGridRef = React.useRef<any>(null);
68
+ const latestProps = React.useRef(props);
69
+ latestProps.current = props;
70
+
71
+ /* -------------------------------------------------------------------------- */
72
+ /* Columns */
73
+ /* -------------------------------------------------------------------------- */
74
+ const cached_columns = useColumnData(props);
75
+ const dataSource = useDataSource(props.dataSource, props);
76
+ const a11y_columns = React.useMemo(
77
+ () => cached_columns.map((col) => apply_column_a11y(col, { gridEditable: !!props.editable })),
78
+ [cached_columns, props.editable]
79
+ );
80
+ /* -------------------------------------------------------------------------- */
81
+ /* Row changes */
82
+ /* -------------------------------------------------------------------------- */
83
+
84
+ const base_gridOptions = React.useMemo<AzGridOptions>(() => {
85
+ const firstcolumn = cached_columns[0];
86
+ const licenseKey = props.licenseKey || get_default_key();
87
+ // call the latest consumer callback, only passed when the consumer gave one
88
+ const events: AzGridOptions = {};
89
+ callback_option_names.forEach((name) => {
90
+ if (props[name])
91
+ events[name] = (...args: any[]) => latestProps.current[name]?.(...args);
92
+ });
93
+ const extra_ops: AzGridOptions = {
94
+ licenseKey: licenseKey,
95
+ editable: props.editable as any, //bug in types of the plugin
96
+ treeColumn: props.allowChildRows ? firstcolumn.name : undefined,
97
+ renderRowDetails: props.RowDetail,
98
+ };
99
+ return { ...defaultOptions, ...events, ...extra_ops };
100
+ }, [
101
+ cached_columns,
102
+ props.allowChildRows,
103
+ props.editable,
104
+ props.RowDetail,
105
+ props.licenseKey,
106
+ ...callback_option_names.map((name) => !!props[name]),
107
+ ]);
108
+
109
+ const static_gridOptions = React.useMemo<AzGridOptions>(() => {
110
+ const finalres = { ...base_gridOptions, ...props.gridOptions, ...forcedOptions };
111
+
112
+ //append filter types instead of replacing it
113
+ if (finalres.filterTypes)
114
+ finalres.filterTypes = Object.assign(
115
+ {},
116
+ ReactDataGrid.defaultProps.filterTypes,
117
+ finalres.filterTypes
118
+ );
119
+
120
+ return finalres;
121
+ }, [props.gridOptions, base_gridOptions, forcedOptions]);
122
+
123
+ const dynamic_gridOptions = React.useMemo<AzGridOptions>(
124
+ () => {
125
+ const res = {};
126
+ dynamic_option_names.map((r) => {
127
+ res[r] = props[r];
128
+ });
129
+ return res;
130
+ },
131
+ dynamic_option_names.map((r) => props[r])
132
+ );
133
+
134
+ return (
135
+ <DataGridEventsWrapper
136
+ {...props}
137
+ gridRef={gridRef}
138
+ liveGridRef={liveGridRef}
139
+ static_gridOptions={static_gridOptions}
140
+ dynamic_gridOptions={dynamic_gridOptions}
141
+ columns={a11y_columns}
142
+ dataSource={dataSource}
143
+ highlightedRow={props.highlightedRow}
144
+ />
145
+ );
146
+ }
147
+
148
+ /* -------------------------------------------------------------------------- */
149
+ /**
150
+ * Wrapper for menu events
151
+ * @param props
152
+ * @returns
153
+ */
154
+ function DataGridEventsWrapper(props: DataGridWrapperProps) {
155
+ const scopeRef = React.useRef<HTMLDivElement>(null);
156
+ const hostTheme = useTheme();
157
+ // Keep the existing context menu and its portal in this grid's CSS scope.
158
+ const menuTheme = React.useMemo(
159
+ () => createTheme(hostTheme, {
160
+ components: { MuiPopper: { defaultProps: { container: () => scopeRef.current } } },
161
+ }),
162
+ [hostTheme]
163
+ );
164
+ const themeClass = `azgrid-theme-${props.theme ?? (props.dark ? 'dark' : 'light')}`;
165
+ /* -------------------------------------------------------------------------- */
166
+ const {
167
+ onRowClick,
168
+ onRowContextMenu,
169
+ onRenderRow,
170
+ onRenderLoadMask,
171
+ update_menuRow,
172
+ menuAnchorEl,
173
+ menuRow,
174
+ } = useGridEvents(props.gridRef.current, props);
175
+ /* -------------------------------------------------------------------------- */
176
+ /**
177
+ * Merge click events into grid options
178
+ */
179
+ const static_gridOptions = React.useMemo<AzGridOptions>(() => {
180
+ const opts: any = props.static_gridOptions || {};
181
+ const events: AzGridOptions = {
182
+ onRowClick: onRowClick,
183
+ onRowContextMenu: onRowContextMenu,
184
+ };
185
+
186
+ // internal row attributes first, consumer's onRenderRow last so it can override them
187
+ const consumerOnRenderRow = opts.onRenderRow;
188
+ const renderProps: any = {
189
+ onRenderRow: consumerOnRenderRow
190
+ ? (rowProps) => {
191
+ onRenderRow(rowProps);
192
+ consumerOnRenderRow(rowProps);
193
+ }
194
+ : onRenderRow,
195
+ // track loading for aria-busy, the consumer's renderLoadMask (if any) still renders the mask
196
+ renderLoadMask: (maskProps) => {
197
+ onRenderLoadMask(maskProps);
198
+ return opts.renderLoadMask ? opts.renderLoadMask(maskProps) : undefined;
199
+ },
200
+ };
201
+
202
+ const gridEditable = !!props.editable;
203
+ const a11yProps: any = {
204
+ headerProps: { role: 'row', 'aria-rowindex': 1, ...opts.headerProps },
205
+ rowIndexColumn: apply_column_a11y(
206
+ typeof opts.rowIndexColumn === 'object' ? opts.rowIndexColumn : {},
207
+ { role: 'rowheader', gridEditable }
208
+ ),
209
+ };
210
+ if (opts.checkboxColumn)
211
+ a11yProps.checkboxColumn = apply_column_a11y(
212
+ typeof opts.checkboxColumn === 'object' ? opts.checkboxColumn : {},
213
+ { gridEditable, markReadonly: false }
214
+ );
215
+
216
+ return {
217
+ ...opts,
218
+ ...events,
219
+ ...renderProps,
220
+ ...a11yProps,
221
+ };
222
+ }, [
223
+ props.static_gridOptions,
224
+ props.editable,
225
+ onRowClick,
226
+ onRowContextMenu,
227
+ onRenderRow,
228
+ onRenderLoadMask,
229
+ ]);
230
+
231
+ /* -------------------------------------------------------------------------- */
232
+ //TODO ContextMenu not from mui...
233
+ return (
234
+ <div ref={scopeRef} className={clsx('azgrid-scope azgrid-flexed azgrid-flexlayout', themeClass)}>
235
+ <ThemeProvider theme={menuTheme}>
236
+ <ContextMenu
237
+ classname="azgrid-context-menu"
238
+ menuAnchorEl={menuAnchorEl}
239
+ menuRow={menuRow}
240
+ close={update_menuRow}
241
+ dontAutoClose={false}
242
+ menu_items={props.contextMenuItems as any}
243
+ />
244
+ </ThemeProvider>
245
+ {props.details_dataSource ? (
246
+ <DataGridDetailsWrapper {...props} static_gridOptions={static_gridOptions} />
247
+ ) : (
248
+ <DataGridSizeWrapper {...props} static_gridOptions={static_gridOptions} />
249
+ )}
250
+ </div>
251
+ );
252
+ }
253
+
254
+ function DataGridDetailsWrapper(props: DataGridWrapperProps) {
255
+ const cached_details_columns = useColumnData(props.details_columns);
256
+ const details_dataSource = useDataSource(props.details_dataSource, props);
257
+ const renderDetailsGrid = ({ data }) => {
258
+ return (
259
+ <ReactDataGrid
260
+ theme="default-light"
261
+ className={clsx('azgrid', `azgrid-theme-${props.theme ?? (props.dark ? 'dark' : 'light')}`)}
262
+ defaultFilterValue={props.details_filter}
263
+ dataSource={details_dataSource}
264
+ columns={cached_details_columns}
265
+ />
266
+ );
267
+ };
268
+
269
+ /**
270
+ * Merge details into grid
271
+ */
272
+ const static_gridOptions = React.useMemo<AzGridOptions>(() => {
273
+ const finalresult = props.static_gridOptions || {};
274
+ finalresult['renderDetailsGrid'] = renderDetailsGrid;
275
+ return finalresult;
276
+ }, [props.static_gridOptions, props.theme, props.dark]);
277
+
278
+ return <DataGridSizeWrapper {...props} static_gridOptions={static_gridOptions} />;
279
+ }
280
+
281
+ function DataGridSizeWrapper(props: DataGridWrapperProps) {
282
+ if (props.delayedSize) {
283
+ return <DataGridDelayedSizeWrapper {...props} />;
284
+ } else {
285
+ return <DataGridNormalSizeWrapper {...props} />;
286
+ }
287
+ }
288
+
289
+ /* -------------------------------------------------------------------------- */
290
+ function DataGridNormalSizeWrapper(props: DataGridWrapperProps) {
291
+ return props.advancedFilterFields ? (
292
+ <DataGridSearchWrapper {...props} />
293
+ ) : (
294
+ <DataGridCore {...props} />
295
+ );
296
+ }
297
+ function DataGridDelayedSizeWrapper(props: DataGridWrapperProps) {
298
+ const { ref, height, width } = useComponentSize();
299
+ return (
300
+ <div ref={ref} className={'azgrid-filler azgrid-nooverflow '}>
301
+ <div
302
+ className={'azgrid-delayedresize azgrid-flexlayout'}
303
+ style={{ height: height, width: width }}
304
+ >
305
+ {props.advancedFilterFields ? (
306
+ <DataGridSearchWrapper {...props} />
307
+ ) : (
308
+ <DataGridCore {...props} />
309
+ )}
310
+ </div>
311
+ </div>
312
+ );
313
+ }
314
+ function DataGridSearchWrapper(props: DataGridWrapperProps) {
315
+ const { element, filteredData } = useGridSearch(props);
316
+
317
+ return (
318
+ <div className={'azgrid-flexed azgrid-flexlayout azgrid-nooverflow'}>
319
+ {element}
320
+ <DataGridCore {...props} dataSource={filteredData} />
321
+ </div>
322
+ );
323
+ }
324
+ const DataGridCore = React.memo(DataGridCoreView, (prev, next) =>
325
+ core_prop_names.every((name) => prev[name] === next[name])
326
+ );
327
+ function DataGridCoreView(props: DataGridWrapperProps) {
328
+ const { gridRef, liveGridRef } = props;
329
+ const handle = React.useCallback(
330
+ (ref) => {
331
+ if (ref) gridRef.current = ref.current as any;
332
+ if (liveGridRef) liveGridRef.current = ref as any;
333
+ },
334
+ [gridRef, liveGridRef]
335
+ );
336
+ return (
337
+ <div className={clsx(props.className, 'azgrid-flexed', 'azgrid-flexlayout')}>
338
+ <ReactDataGrid
339
+ {...props.static_gridOptions}
340
+ {...props.dynamic_gridOptions}
341
+ rowIndexColumn={props.static_gridOptions.rowIndexColumn || true}
342
+ handle={handle}
343
+ theme="default-light"
344
+ className={clsx(
345
+ 'azgrid azgrid-flexed',
346
+ props.allowChildRows && 'azgrid-tree',
347
+ `azgrid-theme-${props.theme ?? (props.dark ? 'dark' : 'light')}`
348
+ )}
349
+ columns={props.columns}
350
+ dataSource={props.dataSource}
351
+ />
352
+ {props.children}
353
+ </div>
354
+ );
355
+ }
356
+ /* -------------------------------------------------------------------------- */
357
+ /* -------------------------------------------------------------------------- */
358
+ /* -------------------------------------------------------------------------- */
359
+ /* -------------------------------------------------------------------------- */
360
+
361
+ /* -------------------------------------------------------------------------- */
362
+ export default AzGrid;