@douyinfe/semi-ui 2.39.1 → 2.39.2
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/dist/umd/semi-ui.js +47 -13
- package/dist/umd/semi-ui.js.map +1 -1
- package/dist/umd/semi-ui.min.js +1 -1
- package/dist/umd/semi-ui.min.js.map +1 -1
- package/lib/cjs/form/interface.d.ts +2 -2
- package/lib/cjs/pagination/index.d.ts +2 -0
- package/lib/cjs/pagination/index.js +28 -12
- package/lib/es/form/interface.d.ts +2 -2
- package/lib/es/pagination/index.d.ts +2 -0
- package/lib/es/pagination/index.js +28 -12
- package/package.json +8 -8
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { Subtract } from 'utility-types';
|
|
3
3
|
import type { RuleItem } from 'async-validator';
|
|
4
|
-
import type { Options as
|
|
4
|
+
import type { Options as ScrollIntoViewOptions } from 'scroll-into-view-if-needed';
|
|
5
5
|
import type { BaseFormApi as FormApi, FormState, WithFieldOption, AllErrors } from '@douyinfe/semi-foundation/lib/cjs/form/interface';
|
|
6
6
|
import type { SelectProps } from '../select/index';
|
|
7
7
|
import Option from '../select/option';
|
|
@@ -106,7 +106,7 @@ export interface BaseFormProps<Values extends Record<string, any> = any> extends
|
|
|
106
106
|
render?: (internalProps: FormFCChild) => React.ReactNode;
|
|
107
107
|
component?: React.FC<any> | React.ComponentClass<any>;
|
|
108
108
|
children?: React.ReactNode | ((internalProps: FormFCChild) => React.ReactNode);
|
|
109
|
-
autoScrollToError?: boolean |
|
|
109
|
+
autoScrollToError?: boolean | ScrollIntoViewOptions;
|
|
110
110
|
disabled?: boolean;
|
|
111
111
|
showValidateIcon?: boolean;
|
|
112
112
|
extraTextPosition?: 'middle' | 'bottom';
|
|
@@ -40,6 +40,7 @@ export interface PaginationState {
|
|
|
40
40
|
nextDisabled: boolean;
|
|
41
41
|
restLeftPageList: number[];
|
|
42
42
|
restRightPageList: number[];
|
|
43
|
+
allPageNumbers: number[];
|
|
43
44
|
}
|
|
44
45
|
export type PaginationLocale = Locale['Pagination'];
|
|
45
46
|
export type PopoverPosition = Position;
|
|
@@ -98,6 +99,7 @@ export default class Pagination extends BaseComponent<PaginationProps, Paginatio
|
|
|
98
99
|
renderQuickJump(locale: PaginationLocale): JSX.Element;
|
|
99
100
|
renderPageList(): JSX.Element[];
|
|
100
101
|
renderRestPageList(restList: ('...' | number)[]): JSX.Element;
|
|
102
|
+
renderSmallPageSelect(content: React.ReactNode): JSX.Element;
|
|
101
103
|
renderSmallPage(locale: PaginationLocale): JSX.Element;
|
|
102
104
|
renderDefaultPage(locale: PaginationLocale): JSX.Element;
|
|
103
105
|
render(): JSX.Element;
|
|
@@ -39,18 +39,25 @@ const {
|
|
|
39
39
|
class Pagination extends _baseComponent.default {
|
|
40
40
|
constructor(props) {
|
|
41
41
|
super(props);
|
|
42
|
+
const total = props.total;
|
|
43
|
+
const pageSize = props.pageSize || props.pageSizeOpts[0] || _constants.numbers.DEFAULT_PAGE_SIZE; // Use pageSize first, use the first of pageSizeOpts when not, use the default value when none
|
|
44
|
+
const shouldFillAllNumber = props.size === 'small' && props.hoverShowPageSelect && !props.disabled;
|
|
42
45
|
this.state = {
|
|
43
|
-
total
|
|
46
|
+
total,
|
|
44
47
|
showTotal: props.showTotal,
|
|
45
48
|
currentPage: props.currentPage || props.defaultCurrentPage,
|
|
46
|
-
pageSize
|
|
49
|
+
pageSize,
|
|
47
50
|
pageList: [],
|
|
48
51
|
prevDisabled: false,
|
|
49
52
|
nextDisabled: false,
|
|
50
53
|
restLeftPageList: [],
|
|
51
54
|
restRightPageList: [],
|
|
52
|
-
quickJumpPage: ''
|
|
55
|
+
quickJumpPage: '',
|
|
56
|
+
allPageNumbers: shouldFillAllNumber ? Array.from({
|
|
57
|
+
length: Math.ceil(total / pageSize)
|
|
58
|
+
}, (v, i) => i + 1) : [] // only need to count in smallPage mode, when props.size = small
|
|
53
59
|
};
|
|
60
|
+
|
|
54
61
|
this.foundation = new _foundation.default(this.adapter);
|
|
55
62
|
this.renderDefaultPage = this.renderDefaultPage.bind(this);
|
|
56
63
|
this.renderSmallPage = this.renderSmallPage.bind(this);
|
|
@@ -85,7 +92,9 @@ class Pagination extends _baseComponent.default {
|
|
|
85
92
|
updateQuickJumpPage: quickJumpPage => this.setState({
|
|
86
93
|
quickJumpPage
|
|
87
94
|
}),
|
|
88
|
-
|
|
95
|
+
updateAllPageNumbers: allPageNumbers => this.setState({
|
|
96
|
+
allPageNumbers
|
|
97
|
+
}),
|
|
89
98
|
setCurrentPage: pageIndex => {
|
|
90
99
|
this.setState({
|
|
91
100
|
currentPage: pageIndex
|
|
@@ -121,6 +130,7 @@ class Pagination extends _baseComponent.default {
|
|
|
121
130
|
pageSize: this.props.pageSize
|
|
122
131
|
};
|
|
123
132
|
let pagerHasChanged = false;
|
|
133
|
+
let allPageNumberNeedUpdate = false;
|
|
124
134
|
if (prevProps.currentPage !== this.props.currentPage) {
|
|
125
135
|
pagerHasChanged = true;
|
|
126
136
|
// this.foundation.updatePage(this.props.currentPage);
|
|
@@ -128,13 +138,18 @@ class Pagination extends _baseComponent.default {
|
|
|
128
138
|
|
|
129
139
|
if (prevProps.total !== this.props.total) {
|
|
130
140
|
pagerHasChanged = true;
|
|
141
|
+
allPageNumberNeedUpdate = true;
|
|
131
142
|
}
|
|
132
143
|
if (prevProps.pageSize !== this.props.pageSize) {
|
|
133
144
|
pagerHasChanged = true;
|
|
145
|
+
allPageNumberNeedUpdate = true;
|
|
134
146
|
}
|
|
135
147
|
if (pagerHasChanged) {
|
|
136
148
|
this.foundation.updatePage(pagerProps.currentPage, pagerProps.total, pagerProps.pageSize);
|
|
137
149
|
}
|
|
150
|
+
if (allPageNumberNeedUpdate) {
|
|
151
|
+
this.foundation.updateAllPageNumbers(pagerProps.total, pagerProps.pageSize);
|
|
152
|
+
}
|
|
138
153
|
}
|
|
139
154
|
renderPrevBtn() {
|
|
140
155
|
const {
|
|
@@ -337,6 +352,13 @@ class Pagination extends _baseComponent.default {
|
|
|
337
352
|
}, row)
|
|
338
353
|
);
|
|
339
354
|
}
|
|
355
|
+
renderSmallPageSelect(content) {
|
|
356
|
+
const allPageNumbers = this.state.allPageNumbers;
|
|
357
|
+
const pageList = this.renderRestPageList(allPageNumbers);
|
|
358
|
+
return /*#__PURE__*/_react.default.createElement(_index3.default, {
|
|
359
|
+
content: pageList
|
|
360
|
+
}, content);
|
|
361
|
+
}
|
|
340
362
|
renderSmallPage(locale) {
|
|
341
363
|
const _a = this.props,
|
|
342
364
|
{
|
|
@@ -360,24 +382,18 @@ class Pagination extends _baseComponent.default {
|
|
|
360
382
|
if (totalPageNum < 2 && hideOnSinglePage && !showSizeChanger) {
|
|
361
383
|
return null;
|
|
362
384
|
}
|
|
363
|
-
const pageNumbers = Array.from({
|
|
364
|
-
length: Math.ceil(total / pageSize)
|
|
365
|
-
}, (v, i) => i + 1);
|
|
366
|
-
const pageList = this.renderRestPageList(pageNumbers);
|
|
367
385
|
const pageCls = (0, _classnames.default)({
|
|
368
386
|
[`${prefixCls}-item`]: true,
|
|
369
387
|
[`${prefixCls}-item-small`]: true,
|
|
370
388
|
[`${prefixCls}-item-all-disabled`]: disabled
|
|
371
389
|
});
|
|
372
|
-
const
|
|
390
|
+
const content = /*#__PURE__*/_react.default.createElement("div", {
|
|
373
391
|
className: pageCls
|
|
374
392
|
}, currentPage, "/", totalPageNum, " ");
|
|
375
393
|
return /*#__PURE__*/_react.default.createElement("div", Object.assign({
|
|
376
394
|
className: paginationCls,
|
|
377
395
|
style: style
|
|
378
|
-
}, this.getDataAttr(rest)), this.renderPrevBtn(), hoverShowPageSelect && !disabled ?
|
|
379
|
-
content: pageList
|
|
380
|
-
}, page) : page, this.renderNextBtn(), this.renderQuickJump(locale));
|
|
396
|
+
}, this.getDataAttr(rest)), this.renderPrevBtn(), hoverShowPageSelect && !disabled ? this.renderSmallPageSelect(content) : content, this.renderNextBtn(), this.renderQuickJump(locale));
|
|
381
397
|
}
|
|
382
398
|
renderDefaultPage(locale) {
|
|
383
399
|
const {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { Subtract } from 'utility-types';
|
|
3
3
|
import type { RuleItem } from 'async-validator';
|
|
4
|
-
import type { Options as
|
|
4
|
+
import type { Options as ScrollIntoViewOptions } from 'scroll-into-view-if-needed';
|
|
5
5
|
import type { BaseFormApi as FormApi, FormState, WithFieldOption, AllErrors } from '@douyinfe/semi-foundation/lib/es/form/interface';
|
|
6
6
|
import type { SelectProps } from '../select/index';
|
|
7
7
|
import Option from '../select/option';
|
|
@@ -106,7 +106,7 @@ export interface BaseFormProps<Values extends Record<string, any> = any> extends
|
|
|
106
106
|
render?: (internalProps: FormFCChild) => React.ReactNode;
|
|
107
107
|
component?: React.FC<any> | React.ComponentClass<any>;
|
|
108
108
|
children?: React.ReactNode | ((internalProps: FormFCChild) => React.ReactNode);
|
|
109
|
-
autoScrollToError?: boolean |
|
|
109
|
+
autoScrollToError?: boolean | ScrollIntoViewOptions;
|
|
110
110
|
disabled?: boolean;
|
|
111
111
|
showValidateIcon?: boolean;
|
|
112
112
|
extraTextPosition?: 'middle' | 'bottom';
|
|
@@ -40,6 +40,7 @@ export interface PaginationState {
|
|
|
40
40
|
nextDisabled: boolean;
|
|
41
41
|
restLeftPageList: number[];
|
|
42
42
|
restRightPageList: number[];
|
|
43
|
+
allPageNumbers: number[];
|
|
43
44
|
}
|
|
44
45
|
export type PaginationLocale = Locale['Pagination'];
|
|
45
46
|
export type PopoverPosition = Position;
|
|
@@ -98,6 +99,7 @@ export default class Pagination extends BaseComponent<PaginationProps, Paginatio
|
|
|
98
99
|
renderQuickJump(locale: PaginationLocale): JSX.Element;
|
|
99
100
|
renderPageList(): JSX.Element[];
|
|
100
101
|
renderRestPageList(restList: ('...' | number)[]): JSX.Element;
|
|
102
|
+
renderSmallPageSelect(content: React.ReactNode): JSX.Element;
|
|
101
103
|
renderSmallPage(locale: PaginationLocale): JSX.Element;
|
|
102
104
|
renderDefaultPage(locale: PaginationLocale): JSX.Element;
|
|
103
105
|
render(): JSX.Element;
|
|
@@ -31,18 +31,25 @@ const {
|
|
|
31
31
|
export default class Pagination extends BaseComponent {
|
|
32
32
|
constructor(props) {
|
|
33
33
|
super(props);
|
|
34
|
+
const total = props.total;
|
|
35
|
+
const pageSize = props.pageSize || props.pageSizeOpts[0] || numbers.DEFAULT_PAGE_SIZE; // Use pageSize first, use the first of pageSizeOpts when not, use the default value when none
|
|
36
|
+
const shouldFillAllNumber = props.size === 'small' && props.hoverShowPageSelect && !props.disabled;
|
|
34
37
|
this.state = {
|
|
35
|
-
total
|
|
38
|
+
total,
|
|
36
39
|
showTotal: props.showTotal,
|
|
37
40
|
currentPage: props.currentPage || props.defaultCurrentPage,
|
|
38
|
-
pageSize
|
|
41
|
+
pageSize,
|
|
39
42
|
pageList: [],
|
|
40
43
|
prevDisabled: false,
|
|
41
44
|
nextDisabled: false,
|
|
42
45
|
restLeftPageList: [],
|
|
43
46
|
restRightPageList: [],
|
|
44
|
-
quickJumpPage: ''
|
|
47
|
+
quickJumpPage: '',
|
|
48
|
+
allPageNumbers: shouldFillAllNumber ? Array.from({
|
|
49
|
+
length: Math.ceil(total / pageSize)
|
|
50
|
+
}, (v, i) => i + 1) : [] // only need to count in smallPage mode, when props.size = small
|
|
45
51
|
};
|
|
52
|
+
|
|
46
53
|
this.foundation = new PaginationFoundation(this.adapter);
|
|
47
54
|
this.renderDefaultPage = this.renderDefaultPage.bind(this);
|
|
48
55
|
this.renderSmallPage = this.renderSmallPage.bind(this);
|
|
@@ -77,7 +84,9 @@ export default class Pagination extends BaseComponent {
|
|
|
77
84
|
updateQuickJumpPage: quickJumpPage => this.setState({
|
|
78
85
|
quickJumpPage
|
|
79
86
|
}),
|
|
80
|
-
|
|
87
|
+
updateAllPageNumbers: allPageNumbers => this.setState({
|
|
88
|
+
allPageNumbers
|
|
89
|
+
}),
|
|
81
90
|
setCurrentPage: pageIndex => {
|
|
82
91
|
this.setState({
|
|
83
92
|
currentPage: pageIndex
|
|
@@ -113,6 +122,7 @@ export default class Pagination extends BaseComponent {
|
|
|
113
122
|
pageSize: this.props.pageSize
|
|
114
123
|
};
|
|
115
124
|
let pagerHasChanged = false;
|
|
125
|
+
let allPageNumberNeedUpdate = false;
|
|
116
126
|
if (prevProps.currentPage !== this.props.currentPage) {
|
|
117
127
|
pagerHasChanged = true;
|
|
118
128
|
// this.foundation.updatePage(this.props.currentPage);
|
|
@@ -120,13 +130,18 @@ export default class Pagination extends BaseComponent {
|
|
|
120
130
|
|
|
121
131
|
if (prevProps.total !== this.props.total) {
|
|
122
132
|
pagerHasChanged = true;
|
|
133
|
+
allPageNumberNeedUpdate = true;
|
|
123
134
|
}
|
|
124
135
|
if (prevProps.pageSize !== this.props.pageSize) {
|
|
125
136
|
pagerHasChanged = true;
|
|
137
|
+
allPageNumberNeedUpdate = true;
|
|
126
138
|
}
|
|
127
139
|
if (pagerHasChanged) {
|
|
128
140
|
this.foundation.updatePage(pagerProps.currentPage, pagerProps.total, pagerProps.pageSize);
|
|
129
141
|
}
|
|
142
|
+
if (allPageNumberNeedUpdate) {
|
|
143
|
+
this.foundation.updateAllPageNumbers(pagerProps.total, pagerProps.pageSize);
|
|
144
|
+
}
|
|
130
145
|
}
|
|
131
146
|
renderPrevBtn() {
|
|
132
147
|
const {
|
|
@@ -329,6 +344,13 @@ export default class Pagination extends BaseComponent {
|
|
|
329
344
|
}, row)
|
|
330
345
|
);
|
|
331
346
|
}
|
|
347
|
+
renderSmallPageSelect(content) {
|
|
348
|
+
const allPageNumbers = this.state.allPageNumbers;
|
|
349
|
+
const pageList = this.renderRestPageList(allPageNumbers);
|
|
350
|
+
return /*#__PURE__*/React.createElement(Popover, {
|
|
351
|
+
content: pageList
|
|
352
|
+
}, content);
|
|
353
|
+
}
|
|
332
354
|
renderSmallPage(locale) {
|
|
333
355
|
const _a = this.props,
|
|
334
356
|
{
|
|
@@ -352,24 +374,18 @@ export default class Pagination extends BaseComponent {
|
|
|
352
374
|
if (totalPageNum < 2 && hideOnSinglePage && !showSizeChanger) {
|
|
353
375
|
return null;
|
|
354
376
|
}
|
|
355
|
-
const pageNumbers = Array.from({
|
|
356
|
-
length: Math.ceil(total / pageSize)
|
|
357
|
-
}, (v, i) => i + 1);
|
|
358
|
-
const pageList = this.renderRestPageList(pageNumbers);
|
|
359
377
|
const pageCls = classNames({
|
|
360
378
|
[`${prefixCls}-item`]: true,
|
|
361
379
|
[`${prefixCls}-item-small`]: true,
|
|
362
380
|
[`${prefixCls}-item-all-disabled`]: disabled
|
|
363
381
|
});
|
|
364
|
-
const
|
|
382
|
+
const content = /*#__PURE__*/React.createElement("div", {
|
|
365
383
|
className: pageCls
|
|
366
384
|
}, currentPage, "/", totalPageNum, " ");
|
|
367
385
|
return /*#__PURE__*/React.createElement("div", Object.assign({
|
|
368
386
|
className: paginationCls,
|
|
369
387
|
style: style
|
|
370
|
-
}, this.getDataAttr(rest)), this.renderPrevBtn(), hoverShowPageSelect && !disabled ?
|
|
371
|
-
content: pageList
|
|
372
|
-
}, page) : page, this.renderNextBtn(), this.renderQuickJump(locale));
|
|
388
|
+
}, this.getDataAttr(rest)), this.renderPrevBtn(), hoverShowPageSelect && !disabled ? this.renderSmallPageSelect(content) : content, this.renderNextBtn(), this.renderQuickJump(locale));
|
|
373
389
|
}
|
|
374
390
|
renderDefaultPage(locale) {
|
|
375
391
|
const {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@douyinfe/semi-ui",
|
|
3
|
-
"version": "2.39.
|
|
3
|
+
"version": "2.39.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/es/index.js",
|
|
@@ -17,12 +17,12 @@
|
|
|
17
17
|
"lib/*"
|
|
18
18
|
],
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@douyinfe/semi-animation": "2.39.
|
|
21
|
-
"@douyinfe/semi-animation-react": "2.39.
|
|
22
|
-
"@douyinfe/semi-foundation": "2.39.
|
|
23
|
-
"@douyinfe/semi-icons": "2.39.
|
|
24
|
-
"@douyinfe/semi-illustrations": "2.39.
|
|
25
|
-
"@douyinfe/semi-theme-default": "2.39.
|
|
20
|
+
"@douyinfe/semi-animation": "2.39.2",
|
|
21
|
+
"@douyinfe/semi-animation-react": "2.39.2",
|
|
22
|
+
"@douyinfe/semi-foundation": "2.39.2",
|
|
23
|
+
"@douyinfe/semi-icons": "2.39.2",
|
|
24
|
+
"@douyinfe/semi-illustrations": "2.39.2",
|
|
25
|
+
"@douyinfe/semi-theme-default": "2.39.2",
|
|
26
26
|
"async-validator": "^3.5.0",
|
|
27
27
|
"classnames": "^2.2.6",
|
|
28
28
|
"copy-text-to-clipboard": "^2.1.1",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
],
|
|
70
70
|
"author": "",
|
|
71
71
|
"license": "MIT",
|
|
72
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "4a5d81c6ff12a6ecf0a0f96b5a9ae96174dd12b7",
|
|
73
73
|
"devDependencies": {
|
|
74
74
|
"@babel/plugin-proposal-decorators": "^7.15.8",
|
|
75
75
|
"@babel/plugin-transform-runtime": "^7.15.8",
|