@gm-pc/react 1.26.1-beta.1 → 1.27.0

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gm-pc/react",
3
- "version": "1.26.1-beta.1",
3
+ "version": "1.27.0",
4
4
  "description": "观麦前端基础组件库",
5
5
  "author": "liyatang <liyatang@qq.com>",
6
6
  "homepage": "https://github.com/gmfe/gm-pc#readme",
@@ -24,7 +24,7 @@
24
24
  "dependencies": {
25
25
  "@gm-common/hooks": "^2.10.0",
26
26
  "@gm-common/tool": "^2.10.0",
27
- "@gm-pc/locales": "^1.26.1-beta.1",
27
+ "@gm-pc/locales": "^1.27.0",
28
28
  "big.js": "^6.0.1",
29
29
  "classnames": "^2.2.5",
30
30
  "lodash": "^4.17.19",
@@ -48,5 +48,5 @@
48
48
  "react-router-dom": "^5.2.0",
49
49
  "react-window": "^1.8.5"
50
50
  },
51
- "gitHead": "f099578979fed42106b76ad690796d07dfd5cd15"
51
+ "gitHead": "8382eb70be310e125ec7e14a918c2ae359dc075a"
52
52
  }
@@ -5,18 +5,22 @@ import { PaginationProps } from './types'
5
5
  import _ from 'lodash'
6
6
  import { getLocale } from '@gm-pc/locales'
7
7
 
8
- function getLimitData(limit: number) {
8
+ function getLimitData(limit: number, pageSizeOptions?: string[]) {
9
9
  const limitData = [
10
10
  { value: limit, text: limit + '' },
11
11
  { value: 10, text: '10' },
12
12
  { value: 20, text: '20' },
13
13
  { value: 50, text: '50' },
14
+ ...(pageSizeOptions?.map((v) => ({ value: Number(v), text: v })) || []),
14
15
  ]
15
16
 
16
- return _.uniqBy(limitData, (v) => v.value)
17
+ return _.orderBy(
18
+ _.uniqBy(limitData, (v) => v.value),
19
+ ['value']
20
+ )
17
21
  }
18
22
 
19
- const Left: FC<PaginationProps> = ({ paging, onChange }) => {
23
+ const Left: FC<PaginationProps> = ({ paging, pageSizeOptions, onChange }) => {
20
24
  const { need_count, count, limit } = paging
21
25
 
22
26
  const handleChange = (limit: number) => {
@@ -39,7 +43,7 @@ const Left: FC<PaginationProps> = ({ paging, onChange }) => {
39
43
  )}
40
44
  <span>{getLocale('每页')}&nbsp;</span>
41
45
  <Select
42
- data={getLimitData(limit)}
46
+ data={getLimitData(limit, pageSizeOptions)}
43
47
  value={limit}
44
48
  onChange={handleChange}
45
49
  style={{ width: '60px' }}
@@ -6,10 +6,10 @@ import PageWithoutCount from './page_without_count'
6
6
  import { PaginationProps } from './types'
7
7
  import { Flex } from '../flex'
8
8
 
9
- const Pagination: FC<PaginationProps> = ({ paging, onChange }) => {
9
+ const Pagination: FC<PaginationProps> = ({ paging, pageSizeOptions, onChange }) => {
10
10
  return (
11
11
  <Flex wrap className='gm-pagination'>
12
- <Left paging={paging} onChange={onChange} />
12
+ <Left pageSizeOptions={pageSizeOptions} paging={paging} onChange={onChange} />
13
13
  {paging.need_count ? (
14
14
  <PageWithCount paging={paging} onChange={onChange} />
15
15
  ) : (
@@ -50,6 +50,7 @@ export const ComPagination = () => (
50
50
  <div>without count</div>
51
51
  <Pagination
52
52
  paging={oStore.paging}
53
+ pageSizeOptions={['100']}
53
54
  onChange={(paging) => {
54
55
  oStore.setPaging(paging)
55
56
  }}
@@ -10,6 +10,8 @@ interface PaginationPaging {
10
10
 
11
11
  interface PaginationProps {
12
12
  paging: PaginationPaging
13
+ // 指定每页可以显示多少条
14
+ pageSizeOptions?: string[]
13
15
  onChange(paging: PaginationPaging): void
14
16
  }
15
17