diff --git a/packages/react-datagrid/src/grid/createControlledDataGrid.tsx b/packages/react-datagrid/src/grid/createControlledDataGrid.tsx index 92733f1cf..37c5ca1dd 100644 --- a/packages/react-datagrid/src/grid/createControlledDataGrid.tsx +++ b/packages/react-datagrid/src/grid/createControlledDataGrid.tsx @@ -2,6 +2,7 @@ import { Component } from '@contember/react-binding' import { ComponentType } from 'react' import { DataGridColumns, DataGridMethods, DataGridState } from '../types' import { ControlledDataView, DataViewInfo } from '@contember/react-dataview' +import { DataGridColumnsContext } from '../internal/contexts' export type ControlledDataGridProps = & { @@ -14,6 +15,8 @@ export type ControlledDataGridProps = export const createControlledDataGrid =

(Renderer: ComponentType

) => Component(({ state, methods, info, columns, ...props }) => { const renderer = return ( - + + + ) -}) +}, () => null) diff --git a/packages/react-datagrid/src/grid/createDataGrid.tsx b/packages/react-datagrid/src/grid/createDataGrid.tsx index a9edc97ad..27562daf3 100644 --- a/packages/react-datagrid/src/grid/createDataGrid.tsx +++ b/packages/react-datagrid/src/grid/createDataGrid.tsx @@ -1,11 +1,7 @@ -import { Component, Environment, Filter, QueryLanguage, SugaredQualifiedEntityList } from '@contember/react-binding' +import { Component, SugaredQualifiedEntityList } from '@contember/react-binding' import { ComponentType, ReactNode } from 'react' -import { DataGridMethods, DataGridState } from '../types' import { ControlledDataGridProps, createControlledDataGrid } from './createControlledDataGrid' -import { extractDataGridColumns } from '../internal/gridTemplateAnalyzer' import { useDataGrid } from './useDataGrid' -import { DataGridColumnsContext } from '../internal/contexts' -import { replaceGraphQlLiteral } from '@contember/client' export type DataGridProps

= & { @@ -22,62 +18,7 @@ export const createDataGrid =

(Renderer: ComponentType

>(props => { const dataGridProps = useDataGrid(props) return ( - - - + ) - }, (props, environment) => { - const fakeState = createInitialState(props, environment) - const columns = extractDataGridColumns(props.children, environment) - return - }) -} - -const dummyInfo = { paging: { pagesCount: undefined, totalCount: undefined } } -const dummyStateMethods: DataGridMethods = { - - filtering: { - setFilter: () => null, - }, - sorting: { - setOrderBy: () => null, - }, - paging: { - goToPage: () => null, - setItemsPerPage: () => null, - }, - selection: { - setLayout: () => null, - setVisibility: () => null, - }, -} - -const createInitialState = (props: DataGridProps<{}>, environment: Environment): DataGridState => { - - const entities = QueryLanguage.desugarQualifiedEntityList({ entities: props.entities }, environment) - const filter = resolveFilter({ and: [entities.filter ?? {}] }) - return { - key: '_', - paging: { - itemsPerPage: props.itemsPerPage ?? 50, - pageIndex: 0, - }, - filtering: { - filter: filter, - artifact: {}, - filterTypes: {}, - }, - selection: { - values: {}, - layouts: [], - }, - sorting: { - orderBy: [], - directions: {}, - }, - entities: entities, - } -} -const resolveFilter = (input?: Filter): Filter => { - return replaceGraphQlLiteral(input) as Filter + }, () => null) }