5
5
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
6
*/
7
7
8
- import 'ag-grid-community/styles/ag-grid.css' ;
9
- import 'ag-grid-community/styles/ag-theme-alpine.css' ;
10
-
11
8
import {
12
9
ForwardedRef ,
13
10
forwardRef ,
@@ -19,18 +16,10 @@ import {
19
16
useImperativeHandle ,
20
17
useRef ,
21
18
} from 'react' ;
22
- import { Box , useTheme } from '@mui/material' ;
23
19
import { AgGridReact } from 'ag-grid-react' ;
24
- import { useIntl } from 'react-intl' ;
25
- import { LANG_FRENCH } from '@gridsuite/commons-ui' ;
26
- import { AG_GRID_LOCALE_FR } from '../../translations/ag-grid/locales' ;
27
- import { GridOptions } from 'ag-grid-community' ;
20
+ import { CustomAGGrid , type CustomAGGridProps } from '@gridsuite/commons-ui' ;
28
21
import { useDebugRender } from '../../utils/hooks' ;
29
22
30
- const messages : Record < string , Record < string , string > > = {
31
- [ LANG_FRENCH ] : AG_GRID_LOCALE_FR ,
32
- } ;
33
-
34
23
type AccessibleAgGridReact < TData > = Omit <
35
24
AgGridReact < TData > ,
36
25
'apiListeners' | 'setGridApi' //private in class
@@ -47,12 +36,13 @@ export type AgGridRef<TData, TContext extends {}> = {
47
36
type ForwardRef < Props , Ref > = typeof forwardRef < Props , Ref > ;
48
37
type ForwardRefComponent < Props , Ref > = ReturnType < ForwardRef < Props , Ref > > ;
49
38
50
- interface AgGridWithRef extends FunctionComponent < GridOptions < unknown > > {
39
+ interface AgGridWithRef extends FunctionComponent < CustomAGGridProps < unknown > > {
51
40
< TData , TContext extends { } > (
52
- props : PropsWithoutRef < GridOptions < TData > > & RefAttributes < AgGridRef < TData , TContext > >
53
- ) : ReturnType < ForwardRefComponent < GridOptions < TData > , AgGridRef < TData , TContext > > > ;
41
+ props : PropsWithoutRef < CustomAGGridProps < TData > > & RefAttributes < AgGridRef < TData , TContext > >
42
+ ) : ReturnType < ForwardRefComponent < CustomAGGridProps < TData > , AgGridRef < TData , TContext > > > ;
54
43
}
55
44
45
+ // TODO move&merge to commons-ui
56
46
const style = {
57
47
// default overridable style
58
48
width : '100%' ,
@@ -62,13 +52,12 @@ const style = {
62
52
} ,
63
53
} ;
64
54
55
+ // TODO move type generic restoration to commons-ui
56
+ // TODO move useDebug feature from env to commons-ui
65
57
export const AgGrid : AgGridWithRef = forwardRef ( function AgGrid < TData , TContext extends { } = { } > (
66
- props : GridOptions < TData > ,
58
+ props : CustomAGGridProps < TData > ,
67
59
gridRef ?: ForwardedRef < AgGridRef < TData , TContext > >
68
60
) : ReactNode {
69
- const intl = useIntl ( ) ;
70
- const theme = useTheme ( ) ;
71
-
72
61
const id = useId ( ) ;
73
62
useDebugRender ( `ag-grid(${ id } ) ${ props . gridId } ` ) ;
74
63
@@ -84,15 +73,12 @@ export const AgGrid: AgGridWithRef = forwardRef(function AgGrid<TData, TContext
84
73
) ;
85
74
86
75
return (
87
- // wrapping container with theme & size
88
- < Box component = "div" className = { theme . agGridTheme } sx = { style } >
89
- < AgGridReact < TData >
90
- ref = { agGridRef }
91
- localeText = { messages [ intl . locale ] ?? messages [ intl . defaultLocale ] ?? undefined }
92
- { ...props } //destruct props to optimize react props change detection
93
- debug = { import . meta. env . VITE_DEBUG_AGGRID === 'true' || props . debug }
94
- />
95
- </ Box >
76
+ < CustomAGGrid //TODO <TData>
77
+ ref = { agGridRef }
78
+ { ...props } //destruct props to optimize react props change detection
79
+ debug = { import . meta. env . VITE_DEBUG_AGGRID === 'true' || props . debug }
80
+ sx = { style }
81
+ />
96
82
) ;
97
83
} ) ;
98
84
export default AgGrid ;
0 commit comments