Skip to content

Commit 2852ea2

Browse files
committed
update vc-pagination to 1.20.5
1 parent 445c21d commit 2852ea2

File tree

10 files changed

+147
-39
lines changed

10 files changed

+147
-39
lines changed

components/locale-provider/__tests__/__snapshots__/index.test.js.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13790,7 +13790,7 @@ exports[`Locale Provider should display the text as pt-br 1`] = `
1379013790
<div tabindex="0" class="ant-select ant-select-enabled ant-pagination-options-size-changer">
1379113791
<div role="combobox" aria-autocomplete="list" aria-haspopup="true" aria-controls="test-uuid" class="ant-select-selection ant-select-selection--single">
1379213792
<div class="ant-select-selection__rendered">
13793-
<div title="10 / páginas" class="ant-select-selection-selected-value" style="display: block; opacity: 1;">10 / páginas</div>
13793+
<div title="10 / página" class="ant-select-selection-selected-value" style="display: block; opacity: 1;">10 / página</div>
1379413794
</div><span unselectable="on" class="ant-select-arrow" style="user-select: none;"><i aria-label="icon: down" class="ant-select-arrow-icon anticon anticon-down"><svg viewBox="64 64 896 896" data-icon="down" width="1em" height="1em" fill="currentColor" aria-hidden="true" class=""><path d="M884 256h-75c-5.1 0-9.9 2.5-12.9 6.6L512 654.2 227.9 262.6c-3-4.1-7.8-6.6-12.9-6.6h-75c-6.5 0-10.3 7.4-6.5 12.7l352.6 486.1c12.8 17.6 39 17.6 51.7 0l352.6-486.1c3.9-5.3.1-12.7-6.4-12.7z"></path></svg></i></span>
1379513795
</div>
1379613796
</div>

components/vc-pagination/Options.jsx

Lines changed: 37 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ import BaseMixin from '../_util/BaseMixin';
55
export default {
66
mixins: [BaseMixin],
77
props: {
8-
rootPrefixCls: PropTypes.String,
9-
selectPrefixCls: PropTypes.String,
8+
disabled: PropTypes.bool,
109
changeSize: PropTypes.func,
1110
quickGo: PropTypes.func,
1211
selectComponentClass: PropTypes.any,
@@ -15,6 +14,8 @@ export default {
1514
pageSize: PropTypes.number,
1615
buildOptionText: PropTypes.func,
1716
locale: PropTypes.object,
17+
rootPrefixCls: PropTypes.string,
18+
selectPrefixCls: PropTypes.string,
1819
goButton: PropTypes.any,
1920
},
2021
data() {
@@ -23,6 +24,10 @@ export default {
2324
};
2425
},
2526
methods: {
27+
getValidValue() {
28+
const { goInputText, current } = this;
29+
return isNaN(goInputText) ? current : Number(goInputText);
30+
},
2631
defaultBuildOptionText(opt) {
2732
return `${opt.value} ${this.locale.items_per_page}`;
2833
},
@@ -31,17 +36,23 @@ export default {
3136
goInputText: e.target.value,
3237
});
3338
},
39+
handleBlur() {
40+
const { goButton, quickGo } = this;
41+
if (goButton) {
42+
return;
43+
}
44+
quickGo(this.getValidValue());
45+
},
3446
go(e) {
35-
let val = this.goInputText;
36-
if (val === '') {
47+
const { goInputText } = this;
48+
if (goInputText === '') {
3749
return;
3850
}
39-
val = isNaN(val) ? this.current : Number(val);
4051
if (e.keyCode === KEYCODE.ENTER || e.type === 'click') {
4152
this.setState({
4253
goInputText: '',
4354
});
44-
this.quickGo(val);
55+
this.quickGo(this.getValidValue());
4556
}
4657
},
4758
},
@@ -54,34 +65,38 @@ export default {
5465
goButton,
5566
selectComponentClass: Select,
5667
defaultBuildOptionText,
68+
selectPrefixCls,
69+
pageSize,
70+
pageSizeOptions,
71+
goInputText,
72+
disabled,
5773
} = this;
5874
const prefixCls = `${rootPrefixCls}-options`;
5975
let changeSelect = null;
6076
let goInput = null;
6177
let gotoButton = null;
6278

63-
if (!(changeSize || quickGo)) {
79+
if (!changeSize && !quickGo) {
6480
return null;
6581
}
6682

6783
if (changeSize && Select) {
68-
const Option = Select.Option;
69-
const pageSize = this.pageSize || this.pageSizeOptions[0];
7084
const buildOptionText = this.buildOptionText || defaultBuildOptionText;
71-
const options = this.pageSizeOptions.map((opt, i) => (
72-
<Option key={i} value={opt}>
85+
const options = pageSizeOptions.map((opt, i) => (
86+
<Select.Option key={i} value={opt}>
7387
{buildOptionText({ value: opt })}
74-
</Option>
88+
</Select.Option>
7589
));
7690

7791
changeSelect = (
7892
<Select
79-
prefixCls={this.selectPrefixCls}
93+
disabled={disabled}
94+
prefixCls={selectPrefixCls}
8095
showSearch={false}
8196
class={`${prefixCls}-size-changer`}
8297
optionLabelProp="children"
8398
dropdownMatchSelectWidth={false}
84-
value={pageSize.toString()}
99+
value={(pageSize || pageSizeOptions[0]).toString()}
85100
onChange={value => this.changeSize(Number(value))}
86101
getPopupContainer={triggerNode => triggerNode.parentNode}
87102
>
@@ -92,28 +107,27 @@ export default {
92107

93108
if (quickGo) {
94109
if (goButton) {
95-
if (typeof goButton === 'boolean') {
96-
gotoButton = (
97-
<button type="button" onClick={this.go} onKeyup={this.go}>
110+
gotoButton =
111+
typeof goButton === 'boolean' ? (
112+
<button type="button" onClick={this.go} onKeyup={this.go} disabled={disabled}>
98113
{locale.jump_to_confirm}
99114
</button>
100-
);
101-
} else {
102-
gotoButton = (
115+
) : (
103116
<span onClick={this.go} onKeyup={this.go}>
104117
{goButton}
105118
</span>
106119
);
107-
}
108120
}
109121
goInput = (
110122
<div class={`${prefixCls}-quick-jumper`}>
111123
{locale.jump_to}
112124
<input
125+
disabled={disabled}
113126
type="text"
114-
value={this.goInputText}
115-
onInput={this.handleChange}
127+
value={goInputText}
128+
onChange={this.handleChange}
116129
onKeyup={this.go}
130+
onBlur={this.handleBlur}
117131
/>
118132
{locale.page}
119133
{gotoButton}

components/vc-pagination/Pagination.jsx

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export default {
3333
event: 'change.current',
3434
},
3535
props: {
36+
disabled: PropTypes.bool,
3637
prefixCls: PropTypes.string.def('rc-pagination'),
3738
selectPrefixCls: PropTypes.string.def('rc-select'),
3839
current: PropTypes.number,
@@ -134,9 +135,29 @@ export default {
134135
);
135136
return iconNode;
136137
},
138+
getValidValue(e) {
139+
const inputValue = e.target.value;
140+
const { stateCurrentInputValue } = this.$data;
141+
let value;
142+
if (inputValue === '') {
143+
value = inputValue;
144+
} else if (isNaN(Number(inputValue))) {
145+
value = stateCurrentInputValue;
146+
} else {
147+
value = Number(inputValue);
148+
}
149+
return value;
150+
},
137151
isValid(page) {
138152
return isInteger(page) && page >= 1 && page !== this.stateCurrent;
139153
},
154+
shouldDisplayQuickJumper() {
155+
const { showQuickJumper, pageSize, total } = this.$props;
156+
if (total <= pageSize) {
157+
return false;
158+
}
159+
return showQuickJumper;
160+
},
140161
// calculatePage (p) {
141162
// let pageSize = p
142163
// if (typeof pageSize === 'undefined') {
@@ -154,14 +175,6 @@ export default {
154175
const stateCurrentInputValue = this.stateCurrentInputValue;
155176
let value;
156177

157-
if (inputValue === '') {
158-
value = inputValue;
159-
} else if (isNaN(Number(inputValue))) {
160-
value = stateCurrentInputValue;
161-
} else {
162-
value = Number(inputValue);
163-
}
164-
165178
if (value !== stateCurrentInputValue) {
166179
this.setState({
167180
stateCurrentInputValue: value,
@@ -206,8 +219,9 @@ export default {
206219
}
207220
},
208221
handleChange(p) {
222+
const { disabled } = this.$props;
209223
let page = p;
210-
if (this.isValid(page)) {
224+
if (this.isValid(page) && !disabled) {
211225
const currentPage = calculatePage(undefined, this.$data, this.$props);
212226
if (page > currentPage) {
213227
page = currentPage;
@@ -271,14 +285,15 @@ export default {
271285
},
272286
},
273287
render() {
288+
const { prefixCls, disabled } = this.$props;
289+
274290
// When hideOnSinglePage is true and there is only 1 page, hide the pager
275291
if (this.hideOnSinglePage === true && this.total <= this.statePageSize) {
276292
return null;
277293
}
278294
const props = this.$props;
279295
const locale = this.locale;
280296

281-
const prefixCls = this.prefixCls;
282297
const allPages = calculatePage(undefined, this.$data, this.$props);
283298
const pagerList = [];
284299
let jumpPrev = null;
@@ -524,7 +539,7 @@ export default {
524539
totalText = (
525540
<li class={`${prefixCls}-total-text`}>
526541
{this.showTotal(this.total, [
527-
(stateCurrent - 1) * statePageSize + 1,
542+
this.total === 0 ? 0 : (stateCurrent - 1) * statePageSize + 1,
528543
stateCurrent * statePageSize > this.total ? this.total : stateCurrent * statePageSize,
529544
])}
530545
</li>
@@ -534,7 +549,11 @@ export default {
534549
const nextDisabled = !this.hasNext() || !allPages;
535550
const buildOptionText = this.buildOptionText || this.$scopedSlots.buildOptionText;
536551
return (
537-
<ul class={`${prefixCls}`} unselectable="unselectable" ref="paginationNode">
552+
<ul
553+
class={{ [`${prefixCls}`]: true, [`${prefixCls}-disabled`]: disabled }}
554+
unselectable="unselectable"
555+
ref="paginationNode"
556+
>
538557
{totalText}
539558
<li
540559
title={this.showTitle ? locale.prev_page : null}
@@ -558,6 +577,7 @@ export default {
558577
{this.itemRender(nextPage, 'next', this.getItemIcon('nextIcon'))}
559578
</li>
560579
<Options
580+
disabled={disabled}
561581
locale={locale}
562582
rootPrefixCls={prefixCls}
563583
selectComponentClass={this.selectComponentClass}
@@ -567,7 +587,7 @@ export default {
567587
pageSize={statePageSize}
568588
pageSizeOptions={this.pageSizeOptions}
569589
buildOptionText={buildOptionText || null}
570-
quickGo={this.showQuickJumper ? this.handleChange : null}
590+
quickGo={this.shouldDisplayQuickJumper() ? this.handleChange : null}
571591
goButton={goButton}
572592
/>
573593
</ul>

components/vc-pagination/demo/jumper.vue

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export default {
2020
},
2121
render () {
2222
return (
23+
<div>
2324
<VcPagination
2425
selectComponentClass={VcSelect}
2526
showQuickJumper
@@ -30,6 +31,19 @@ export default {
3031
onChange={this.onChange}
3132
total={450}
3233
/>
34+
<br/>
35+
<VcPagination
36+
selectComponentClass={VcSelect}
37+
showQuickJumper={{ goButton: true }}
38+
showSizeChanger
39+
defaultPageSize={20}
40+
defaultCurrent={5}
41+
onShowSizeChange={this.onShowSizeChange}
42+
onChange={this.onChange}
43+
total={450}
44+
disabled
45+
/>
46+
</div>
3347
);
3448
},
3549
};

components/vc-pagination/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
// based on rc-pagination 1.17.8
1+
// based on rc-pagination 1.20.5
22
export { default } from './Pagination';
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
export default {
2+
// Options.jsx
3+
items_per_page: '/ str',
4+
jump_to: 'Idi na',
5+
jump_to_confirm: 'potvrdi',
6+
page: '',
7+
8+
// Pagination.jsx
9+
prev_page: 'Prijašnja stranica',
10+
next_page: 'Sljedeća stranica',
11+
prev_5: 'Prijašnjih 5 stranica',
12+
next_5: 'Sljedećih 5 stranica',
13+
prev_3: 'Prijašnje 3 stranice',
14+
next_3: 'Sljedeće 3 stranice',
15+
};
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
export default {
2+
// Options.jsx
3+
items_per_page: '/ lappuse',
4+
jump_to: 'iet uz',
5+
jump_to_confirm: 'apstiprināt',
6+
page: '',
7+
8+
// Pagination.jsx
9+
prev_page: 'Iepriekšējā lapa',
10+
next_page: 'Nākamā lapaspuse',
11+
prev_5: 'Iepriekšējās 5 lapas',
12+
next_5: 'Nākamās 5 lapas',
13+
prev_3: 'Iepriekšējās 3 lapas',
14+
next_3: 'Nākamās 3 lapas',
15+
};
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
export default {
2+
// Options.jsx
3+
items_per_page: '/ halaman',
4+
jump_to: 'Lompat ke',
5+
jump_to_confirm: 'Sahkan',
6+
page: '',
7+
8+
// Pagination.jsx
9+
prev_page: 'Halaman sebelumnya',
10+
next_page: 'Halam seterusnya',
11+
prev_5: '5 halaman sebelum',
12+
next_5: '5 halaman seterusnya',
13+
prev_3: '3 halaman sebelumnya',
14+
next_3: '3 halaman seterusnya',
15+
};

components/vc-pagination/locale/pt_BR.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export default {
22
// Options.jsx
3-
items_per_page: '/ páginas',
3+
items_per_page: '/ página',
44
jump_to: 'Vá até',
55
jump_to_confirm: 'confirme',
66
page: '',
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
export default {
2+
// Options.jsx
3+
items_per_page: '/ பக்கம்',
4+
jump_to: 'அடுத்த',
5+
jump_to_confirm: 'உறுதிப்படுத்தவும்',
6+
page: '',
7+
8+
// Pagination.jsx
9+
prev_page: 'முந்தைய பக்கம்',
10+
next_page: 'அடுத்த பக்கம்',
11+
prev_5: 'முந்தைய 5 பக்கங்கள்',
12+
next_5: 'அடுத்த 5 பக்கங்கள்',
13+
prev_3: 'முந்தைய 3 பக்கங்கள்',
14+
next_3: 'அடுத்த 3 பக்கங்கள்',
15+
};

0 commit comments

Comments
 (0)