listpage-next 0.0.44 → 0.0.45

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.
@@ -28,7 +28,7 @@ function useData(props) {
28
28
  const onChange = (page, pageSize)=>{
29
29
  setParams({
30
30
  ...params,
31
- current: page,
31
+ current: pageSize !== params.pageSize ? 1 : page,
32
32
  pageSize
33
33
  });
34
34
  };
@@ -1,6 +1,21 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import { Card, Table } from "antd";
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { Card, Pagination, Table } from "antd";
3
+ import zh_CN from "antd/locale/zh_CN";
3
4
  import { useData } from "./hooks/useData.js";
5
+ import styled_components from "styled-components";
6
+ const PaginationContainer = styled_components.div`
7
+ padding: 12px 16px 12px 0;
8
+ border-top: 1px solid #f0f0f0;
9
+ `;
10
+ const TableContainer = styled_components.div`
11
+ table {
12
+ tr:last-child {
13
+ td {
14
+ border-bottom: none;
15
+ }
16
+ }
17
+ }
18
+ `;
4
19
  const DataTable = (props)=>{
5
20
  const { title, extra, dataSource, request, refreshDeps, ...restProps } = props;
6
21
  const { data, loading, pagination } = useData({
@@ -9,7 +24,7 @@ const DataTable = (props)=>{
9
24
  refreshDeps,
10
25
  pagination: restProps.pagination
11
26
  });
12
- return /*#__PURE__*/ jsx(Card, {
27
+ return /*#__PURE__*/ jsxs(Card, {
13
28
  title: title,
14
29
  extra: extra,
15
30
  styles: {
@@ -17,15 +32,29 @@ const DataTable = (props)=>{
17
32
  padding: 0
18
33
  }
19
34
  },
20
- children: /*#__PURE__*/ jsx(Table, {
21
- loading: loading,
22
- ...restProps,
23
- dataSource: data,
24
- pagination: {
25
- ...pagination,
26
- ...restProps?.pagination
27
- }
28
- })
35
+ children: [
36
+ /*#__PURE__*/ jsx(TableContainer, {
37
+ children: /*#__PURE__*/ jsx(Table, {
38
+ bordered: false,
39
+ loading: loading,
40
+ locale: zh_CN.Table,
41
+ ...restProps,
42
+ dataSource: data,
43
+ pagination: false
44
+ })
45
+ }),
46
+ /*#__PURE__*/ jsx(PaginationContainer, {
47
+ children: /*#__PURE__*/ jsx(Pagination, {
48
+ style: {
49
+ border: 'none'
50
+ },
51
+ align: "end",
52
+ locale: zh_CN.Pagination,
53
+ ...pagination,
54
+ ...restProps?.pagination
55
+ })
56
+ })
57
+ ]
29
58
  });
30
59
  };
31
60
  export { DataTable };
@@ -18,29 +18,28 @@ const columns = [
18
18
  key: 'address'
19
19
  }
20
20
  ];
21
+ const listdata = Array.from(new Array(100)).map((_, index)=>({
22
+ key: index,
23
+ name: `Edward King ${index}`,
24
+ age: 32,
25
+ address: `London, Park Lane no. ${index}`
26
+ }));
21
27
  const request = async (params)=>{
22
- console.log(params);
28
+ const { current, pageSize } = params;
29
+ const take = pageSize;
30
+ const skip = (current - 1) * take;
31
+ const list = listdata.slice(skip, skip + take);
23
32
  return {
24
- list: [
25
- {
26
- key: '1',
27
- name: 'John Brown',
28
- age: 32,
29
- address: 'New York No. 1 Lake Park'
30
- },
31
- {
32
- key: '2',
33
- name: 'Jim Green',
34
- age: 42,
35
- address: 'London No. 1 Lake Park'
36
- }
37
- ],
38
- total: 10,
39
- current: 1,
40
- pageSize: 2
33
+ list: list,
34
+ total: listdata.length,
35
+ current: current,
36
+ pageSize: pageSize
41
37
  };
42
38
  };
43
39
  const Demo6 = ()=>/*#__PURE__*/ jsx(DataTable, {
40
+ scroll: {
41
+ y: 300
42
+ },
44
43
  title: "测试标题",
45
44
  extra: /*#__PURE__*/ jsx(Button, {
46
45
  children: "操作"
@@ -49,7 +48,7 @@ const Demo6 = ()=>/*#__PURE__*/ jsx(DataTable, {
49
48
  request: request,
50
49
  pagination: {
51
50
  showSizeChanger: true,
52
- defaultPageSize: 2,
51
+ defaultPageSize: 10,
53
52
  showTotal (total, range) {
54
53
  return `共${total}条数据`;
55
54
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "listpage-next",
3
- "version": "0.0.44",
3
+ "version": "0.0.45",
4
4
  "description": "A React component library for creating filter forms with Ant Design",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",