11import { useClickActionHelper } from "@mendix/widget-plugin-grid/helpers/ClickActionHelper" ;
22import { useFocusTargetController } from "@mendix/widget-plugin-grid/keyboard-navigation/useFocusTargetController" ;
33import { useSelectionHelper } from "@mendix/widget-plugin-grid/selection" ;
4+ import { useConst } from "@mendix/widget-plugin-mobx-kit/react/useConst" ;
45import { generateUUID } from "@mendix/widget-plugin-platform/framework/generate-uuid" ;
56import { ContainerProvider } from "brandi-react" ;
67import { observer } from "mobx-react-lite" ;
@@ -20,6 +21,7 @@ import {
2021import { useDataExport } from "./features/data-export/useDataExport" ;
2122import { useCellEventsController } from "./features/row-interaction/CellEventsController" ;
2223import { useCheckboxEventsController } from "./features/row-interaction/CheckboxEventsController" ;
24+ import { LegacyContext } from "./helpers/root-context" ;
2325import { useSelectActionHelper } from "./helpers/SelectActionHelper" ;
2426import { useDataGridJSActions } from "./helpers/useDataGridJSActions" ;
2527
@@ -64,67 +66,77 @@ const DatagridRoot = observer((props: DatagridContainerProps): ReactElement => {
6466 const checkboxEventsController = useCheckboxEventsController ( selectActionHelper , focusController ) ;
6567
6668 return (
67- < Widget
68- className = { props . class }
69- CellComponent = { Cell }
70- columnsDraggable = { props . columnsDraggable }
71- columnsFilterable = { props . columnsFilterable }
72- columnsHidable = { props . columnsHidable }
73- columnsResizable = { props . columnsResizable }
74- columnsSortable = { props . columnsSortable }
75- data = { items }
76- emptyPlaceholderRenderer = { useCallback (
77- ( renderWrapper : ( children : ReactNode ) => ReactElement ) =>
78- props . showEmptyPlaceholder === "custom" ? renderWrapper ( props . emptyPlaceholder ) : < div /> ,
79- [ props . emptyPlaceholder , props . showEmptyPlaceholder ]
80- ) }
81- filterRenderer = { useCallback (
82- ( renderWrapper , columnIndex ) => {
83- const columnFilter = columnsStore . columnFilters [ columnIndex ] ;
84- return renderWrapper ( columnFilter . renderFilterWidgets ( ) ) ;
85- } ,
86- [ columnsStore . columnFilters ]
87- ) }
88- headerTitle = { props . filterSectionTitle ?. value }
89- headerContent = {
90- props . filtersPlaceholder && (
91- < WidgetHeaderContext selectionHelper = { selectionHelper } >
92- { props . filtersPlaceholder }
93- </ WidgetHeaderContext >
94- )
95- }
96- hasMoreItems = { props . datasource . hasMoreItems ?? false }
97- headerWrapperRenderer = { useCallback ( ( _columnIndex : number , header : ReactElement ) => header , [ ] ) }
98- id = { useMemo ( ( ) => `DataGrid${ generateUUID ( ) } ` , [ ] ) }
99- numberOfItems = { props . datasource . totalCount }
100- onExportCancel = { abortExport }
101- page = { paginationService . currentPage }
102- pageSize = { props . pageSize }
103- paginationType = { props . pagination }
104- loadMoreButtonCaption = { props . loadMoreButtonCaption ?. value }
105- selectionCountPosition = { props . selectionCountPosition }
106- paging = { paginationService . showPagination }
107- pagingPosition = { props . pagingPosition }
108- showPagingButtons = { props . showPagingButtons }
109- rowClass = { useCallback ( ( value : any ) => props . rowClass ?. get ( value ) ?. value ?? "" , [ props . rowClass ] ) }
110- setPage = { paginationService . setPage }
111- styles = { props . style }
112- exporting = { exportProgress . exporting }
113- processedRows = { exportProgress . loaded }
114- visibleColumns = { columnsStore . visibleColumns }
115- availableColumns = { columnsStore . availableColumns }
116- setIsResizing = { ( status : boolean ) => columnsStore . setIsResizing ( status ) }
117- columnsSwap = { ( moved , [ target , placement ] ) => columnsStore . swapColumns ( moved , [ target , placement ] ) }
118- selectActionHelper = { selectActionHelper }
119- cellEventsController = { cellEventsController }
120- checkboxEventsController = { checkboxEventsController }
121- focusController = { focusController }
122- isFirstLoad = { loaderVM . isFirstLoad }
123- isFetchingNextBatch = { loaderVM . isFetchingNextBatch }
124- showRefreshIndicator = { loaderVM . showRefreshIndicator }
125- loadingType = { props . loadingType }
126- columnsLoading = { ! columnsStore . loaded }
127- />
69+ < LegacyContext . Provider
70+ value = { useConst ( {
71+ selectionHelper,
72+ selectActionHelper,
73+ cellEventsController,
74+ checkboxEventsController,
75+ focusController
76+ } ) }
77+ >
78+ < Widget
79+ className = { props . class }
80+ CellComponent = { Cell }
81+ columnsDraggable = { props . columnsDraggable }
82+ columnsFilterable = { props . columnsFilterable }
83+ columnsHidable = { props . columnsHidable }
84+ columnsResizable = { props . columnsResizable }
85+ columnsSortable = { props . columnsSortable }
86+ data = { items }
87+ emptyPlaceholderRenderer = { useCallback (
88+ ( renderWrapper : ( children : ReactNode ) => ReactElement ) =>
89+ props . showEmptyPlaceholder === "custom" ? renderWrapper ( props . emptyPlaceholder ) : < div /> ,
90+ [ props . emptyPlaceholder , props . showEmptyPlaceholder ]
91+ ) }
92+ filterRenderer = { useCallback (
93+ ( renderWrapper , columnIndex ) => {
94+ const columnFilter = columnsStore . columnFilters [ columnIndex ] ;
95+ return renderWrapper ( columnFilter . renderFilterWidgets ( ) ) ;
96+ } ,
97+ [ columnsStore . columnFilters ]
98+ ) }
99+ headerTitle = { props . filterSectionTitle ?. value }
100+ headerContent = {
101+ props . filtersPlaceholder && (
102+ < WidgetHeaderContext selectionHelper = { selectionHelper } >
103+ { props . filtersPlaceholder }
104+ </ WidgetHeaderContext >
105+ )
106+ }
107+ hasMoreItems = { props . datasource . hasMoreItems ?? false }
108+ headerWrapperRenderer = { useCallback ( ( _columnIndex : number , header : ReactElement ) => header , [ ] ) }
109+ id = { useMemo ( ( ) => `DataGrid${ generateUUID ( ) } ` , [ ] ) }
110+ numberOfItems = { props . datasource . totalCount }
111+ onExportCancel = { abortExport }
112+ page = { paginationService . currentPage }
113+ pageSize = { props . pageSize }
114+ paginationType = { props . pagination }
115+ loadMoreButtonCaption = { props . loadMoreButtonCaption ?. value }
116+ selectionCountPosition = { props . selectionCountPosition }
117+ paging = { paginationService . showPagination }
118+ pagingPosition = { props . pagingPosition }
119+ showPagingButtons = { props . showPagingButtons }
120+ rowClass = { useCallback ( ( value : any ) => props . rowClass ?. get ( value ) ?. value ?? "" , [ props . rowClass ] ) }
121+ setPage = { paginationService . setPage }
122+ styles = { props . style }
123+ exporting = { exportProgress . exporting }
124+ processedRows = { exportProgress . loaded }
125+ visibleColumns = { columnsStore . visibleColumns }
126+ availableColumns = { columnsStore . availableColumns }
127+ setIsResizing = { ( status : boolean ) => columnsStore . setIsResizing ( status ) }
128+ columnsSwap = { ( moved , [ target , placement ] ) => columnsStore . swapColumns ( moved , [ target , placement ] ) }
129+ selectActionHelper = { selectActionHelper }
130+ cellEventsController = { cellEventsController }
131+ checkboxEventsController = { checkboxEventsController }
132+ focusController = { focusController }
133+ isFirstLoad = { loaderVM . isFirstLoad }
134+ isFetchingNextBatch = { loaderVM . isFetchingNextBatch }
135+ showRefreshIndicator = { loaderVM . showRefreshIndicator }
136+ loadingType = { props . loadingType }
137+ columnsLoading = { ! columnsStore . loaded }
138+ />
139+ </ LegacyContext . Provider >
128140 ) ;
129141} ) ;
130142
@@ -134,7 +146,7 @@ export default function Datagrid(props: DatagridContainerProps): ReactElement |
134146 const container = useDatagridDepsContainer ( props ) ;
135147
136148 return (
137- < ContainerProvider container = { container } >
149+ < ContainerProvider container = { container } isolated >
138150 < DatagridRoot { ...props } />
139151 </ ContainerProvider >
140152 ) ;
0 commit comments