Skip to content

Commit 64362d6

Browse files
Alyar666pomahtri
andauthored
CardView: Implement Pager (#28782)
Co-authored-by: Roman Semenov <roman.semenov@devexpress.com>
1 parent 1cee130 commit 64362d6

File tree

13 files changed

+975
-6
lines changed

13 files changed

+975
-6
lines changed

packages/devextreme/js/__internal/grids/new/card_view/__snapshots__/widget.test.ts.snap

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ exports[`common initial render should be successfull 1`] = `
55
class="dx-widget dx-cardview"
66
>
77
8-
This is cardView
8+
<div>
9+
10+
</div>
911
</div>
1012
`;

packages/devextreme/js/__internal/grids/new/card_view/main_view.tsx

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,46 @@
22
/* eslint-disable @typescript-eslint/explicit-member-accessibility */
33
import { combined } from '@ts/core/reactive/index';
44
import { View } from '@ts/grids/new/grid_core/core/view';
5+
import { PagerView } from '@ts/grids/new/grid_core/pager/view';
56
import { ToolbarView } from '@ts/grids/new/grid_core/toolbar/view';
67
import type { ComponentType } from 'inferno';
78

89
// eslint-disable-next-line @typescript-eslint/no-empty-interface
910
interface MainViewProps {
1011
Toolbar: ComponentType;
12+
Pager: ComponentType;
1113
}
1214

13-
// eslint-disable-next-line no-empty-pattern
1415
function MainViewComponent({
15-
Toolbar,
16+
Toolbar, Pager,
1617
}: MainViewProps): JSX.Element {
1718
return (<>
1819
{/* @ts-expect-error */}
1920
<Toolbar/>
20-
This is cardView
21+
<div>
22+
{/*
23+
TODO:
24+
Pager, as renovated component, has strange disposing.
25+
See `inferno_renderer.remove` method.
26+
It somehow mutates $V prop of parent element.
27+
Without this div, CardView would be parent of Pager.
28+
In this case all `componentWillUnmount`s aren't called
29+
*/}
30+
{/* @ts-expect-error */}
31+
<Pager/>
32+
</div>
2133
</>);
2234
}
2335

2436
export class MainView extends View<MainViewProps> {
2537
protected override component = MainViewComponent;
2638

27-
public static dependencies = [ToolbarView] as const;
39+
public static dependencies = [
40+
PagerView, ToolbarView,
41+
] as const;
2842

2943
constructor(
44+
private readonly pager: PagerView,
3045
private readonly toolbar: ToolbarView,
3146
) {
3247
super();
@@ -37,6 +52,7 @@ export class MainView extends View<MainViewProps> {
3752
protected override getProps() {
3853
return combined({
3954
Toolbar: this.toolbar.asInferno(),
55+
Pager: this.pager.asInferno(),
4056
});
4157
}
4258
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import type { Properties as PaginationProperties } from '@js/ui/pagination';
2+
import dxPagination from '@js/ui/pagination';
3+
4+
import { InfernoWrapper } from './widget_wrapper';
5+
6+
export class Pager extends InfernoWrapper<PaginationProperties, dxPagination> {
7+
protected getComponentFabric(): typeof dxPagination {
8+
return dxPagination;
9+
}
10+
}

packages/devextreme/js/__internal/grids/new/grid_core/options.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import type { WidgetOptions } from '@js/ui/widget/ui.widget';
44

55
import * as columnsController from './columns_controller/index';
66
import * as dataController from './data_controller/index';
7-
import type * as toolbar from './toolbar';
7+
import * as pager from './pager/index';
8+
import type * as toolbar from './toolbar/index';
89
import type { GridCoreNew } from './widget';
910

1011
/**
@@ -13,12 +14,14 @@ import type { GridCoreNew } from './widget';
1314
export type Options =
1415
& WidgetOptions<GridCoreNew>
1516
& dataController.Options
17+
& pager.Options
1618
& columnsController.Options
1719
& toolbar.Options;
1820

1921
export const defaultOptions = {
2022
...dataController.defaultOptions,
2123
...columnsController.defaultOptions,
24+
...pager.defaultOptions,
2225
} satisfies Options;
2326

2427
// TODO: separate by modules

0 commit comments

Comments
 (0)