update vc-pagination to 1.20.5
parent
445c21d9fd
commit
2852ea295a
|
@ -13790,7 +13790,7 @@ exports[`Locale Provider should display the text as pt-br 1`] = `
|
|||
<div tabindex="0" class="ant-select ant-select-enabled ant-pagination-options-size-changer">
|
||||
<div role="combobox" aria-autocomplete="list" aria-haspopup="true" aria-controls="test-uuid" class="ant-select-selection ant-select-selection--single">
|
||||
<div class="ant-select-selection__rendered">
|
||||
<div title="10 / páginas" class="ant-select-selection-selected-value" style="display: block; opacity: 1;">10 / páginas</div>
|
||||
<div title="10 / página" class="ant-select-selection-selected-value" style="display: block; opacity: 1;">10 / página</div>
|
||||
</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>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -5,8 +5,7 @@ import BaseMixin from '../_util/BaseMixin';
|
|||
export default {
|
||||
mixins: [BaseMixin],
|
||||
props: {
|
||||
rootPrefixCls: PropTypes.String,
|
||||
selectPrefixCls: PropTypes.String,
|
||||
disabled: PropTypes.bool,
|
||||
changeSize: PropTypes.func,
|
||||
quickGo: PropTypes.func,
|
||||
selectComponentClass: PropTypes.any,
|
||||
|
@ -15,6 +14,8 @@ export default {
|
|||
pageSize: PropTypes.number,
|
||||
buildOptionText: PropTypes.func,
|
||||
locale: PropTypes.object,
|
||||
rootPrefixCls: PropTypes.string,
|
||||
selectPrefixCls: PropTypes.string,
|
||||
goButton: PropTypes.any,
|
||||
},
|
||||
data() {
|
||||
|
@ -23,6 +24,10 @@ export default {
|
|||
};
|
||||
},
|
||||
methods: {
|
||||
getValidValue() {
|
||||
const { goInputText, current } = this;
|
||||
return isNaN(goInputText) ? current : Number(goInputText);
|
||||
},
|
||||
defaultBuildOptionText(opt) {
|
||||
return `${opt.value} ${this.locale.items_per_page}`;
|
||||
},
|
||||
|
@ -31,17 +36,23 @@ export default {
|
|||
goInputText: e.target.value,
|
||||
});
|
||||
},
|
||||
go(e) {
|
||||
let val = this.goInputText;
|
||||
if (val === '') {
|
||||
handleBlur() {
|
||||
const { goButton, quickGo } = this;
|
||||
if (goButton) {
|
||||
return;
|
||||
}
|
||||
quickGo(this.getValidValue());
|
||||
},
|
||||
go(e) {
|
||||
const { goInputText } = this;
|
||||
if (goInputText === '') {
|
||||
return;
|
||||
}
|
||||
val = isNaN(val) ? this.current : Number(val);
|
||||
if (e.keyCode === KEYCODE.ENTER || e.type === 'click') {
|
||||
this.setState({
|
||||
goInputText: '',
|
||||
});
|
||||
this.quickGo(val);
|
||||
this.quickGo(this.getValidValue());
|
||||
}
|
||||
},
|
||||
},
|
||||
|
@ -54,34 +65,38 @@ export default {
|
|||
goButton,
|
||||
selectComponentClass: Select,
|
||||
defaultBuildOptionText,
|
||||
selectPrefixCls,
|
||||
pageSize,
|
||||
pageSizeOptions,
|
||||
goInputText,
|
||||
disabled,
|
||||
} = this;
|
||||
const prefixCls = `${rootPrefixCls}-options`;
|
||||
let changeSelect = null;
|
||||
let goInput = null;
|
||||
let gotoButton = null;
|
||||
|
||||
if (!(changeSize || quickGo)) {
|
||||
if (!changeSize && !quickGo) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (changeSize && Select) {
|
||||
const Option = Select.Option;
|
||||
const pageSize = this.pageSize || this.pageSizeOptions[0];
|
||||
const buildOptionText = this.buildOptionText || defaultBuildOptionText;
|
||||
const options = this.pageSizeOptions.map((opt, i) => (
|
||||
<Option key={i} value={opt}>
|
||||
const options = pageSizeOptions.map((opt, i) => (
|
||||
<Select.Option key={i} value={opt}>
|
||||
{buildOptionText({ value: opt })}
|
||||
</Option>
|
||||
</Select.Option>
|
||||
));
|
||||
|
||||
changeSelect = (
|
||||
<Select
|
||||
prefixCls={this.selectPrefixCls}
|
||||
disabled={disabled}
|
||||
prefixCls={selectPrefixCls}
|
||||
showSearch={false}
|
||||
class={`${prefixCls}-size-changer`}
|
||||
optionLabelProp="children"
|
||||
dropdownMatchSelectWidth={false}
|
||||
value={pageSize.toString()}
|
||||
value={(pageSize || pageSizeOptions[0]).toString()}
|
||||
onChange={value => this.changeSize(Number(value))}
|
||||
getPopupContainer={triggerNode => triggerNode.parentNode}
|
||||
>
|
||||
|
@ -92,28 +107,27 @@ export default {
|
|||
|
||||
if (quickGo) {
|
||||
if (goButton) {
|
||||
if (typeof goButton === 'boolean') {
|
||||
gotoButton = (
|
||||
<button type="button" onClick={this.go} onKeyup={this.go}>
|
||||
gotoButton =
|
||||
typeof goButton === 'boolean' ? (
|
||||
<button type="button" onClick={this.go} onKeyup={this.go} disabled={disabled}>
|
||||
{locale.jump_to_confirm}
|
||||
</button>
|
||||
);
|
||||
} else {
|
||||
gotoButton = (
|
||||
) : (
|
||||
<span onClick={this.go} onKeyup={this.go}>
|
||||
{goButton}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
}
|
||||
goInput = (
|
||||
<div class={`${prefixCls}-quick-jumper`}>
|
||||
{locale.jump_to}
|
||||
<input
|
||||
disabled={disabled}
|
||||
type="text"
|
||||
value={this.goInputText}
|
||||
onInput={this.handleChange}
|
||||
value={goInputText}
|
||||
onChange={this.handleChange}
|
||||
onKeyup={this.go}
|
||||
onBlur={this.handleBlur}
|
||||
/>
|
||||
{locale.page}
|
||||
{gotoButton}
|
||||
|
|
|
@ -33,6 +33,7 @@ export default {
|
|||
event: 'change.current',
|
||||
},
|
||||
props: {
|
||||
disabled: PropTypes.bool,
|
||||
prefixCls: PropTypes.string.def('rc-pagination'),
|
||||
selectPrefixCls: PropTypes.string.def('rc-select'),
|
||||
current: PropTypes.number,
|
||||
|
@ -134,9 +135,29 @@ export default {
|
|||
);
|
||||
return iconNode;
|
||||
},
|
||||
getValidValue(e) {
|
||||
const inputValue = e.target.value;
|
||||
const { stateCurrentInputValue } = this.$data;
|
||||
let value;
|
||||
if (inputValue === '') {
|
||||
value = inputValue;
|
||||
} else if (isNaN(Number(inputValue))) {
|
||||
value = stateCurrentInputValue;
|
||||
} else {
|
||||
value = Number(inputValue);
|
||||
}
|
||||
return value;
|
||||
},
|
||||
isValid(page) {
|
||||
return isInteger(page) && page >= 1 && page !== this.stateCurrent;
|
||||
},
|
||||
shouldDisplayQuickJumper() {
|
||||
const { showQuickJumper, pageSize, total } = this.$props;
|
||||
if (total <= pageSize) {
|
||||
return false;
|
||||
}
|
||||
return showQuickJumper;
|
||||
},
|
||||
// calculatePage (p) {
|
||||
// let pageSize = p
|
||||
// if (typeof pageSize === 'undefined') {
|
||||
|
@ -154,14 +175,6 @@ export default {
|
|||
const stateCurrentInputValue = this.stateCurrentInputValue;
|
||||
let value;
|
||||
|
||||
if (inputValue === '') {
|
||||
value = inputValue;
|
||||
} else if (isNaN(Number(inputValue))) {
|
||||
value = stateCurrentInputValue;
|
||||
} else {
|
||||
value = Number(inputValue);
|
||||
}
|
||||
|
||||
if (value !== stateCurrentInputValue) {
|
||||
this.setState({
|
||||
stateCurrentInputValue: value,
|
||||
|
@ -206,8 +219,9 @@ export default {
|
|||
}
|
||||
},
|
||||
handleChange(p) {
|
||||
const { disabled } = this.$props;
|
||||
let page = p;
|
||||
if (this.isValid(page)) {
|
||||
if (this.isValid(page) && !disabled) {
|
||||
const currentPage = calculatePage(undefined, this.$data, this.$props);
|
||||
if (page > currentPage) {
|
||||
page = currentPage;
|
||||
|
@ -271,6 +285,8 @@ export default {
|
|||
},
|
||||
},
|
||||
render() {
|
||||
const { prefixCls, disabled } = this.$props;
|
||||
|
||||
// When hideOnSinglePage is true and there is only 1 page, hide the pager
|
||||
if (this.hideOnSinglePage === true && this.total <= this.statePageSize) {
|
||||
return null;
|
||||
|
@ -278,7 +294,6 @@ export default {
|
|||
const props = this.$props;
|
||||
const locale = this.locale;
|
||||
|
||||
const prefixCls = this.prefixCls;
|
||||
const allPages = calculatePage(undefined, this.$data, this.$props);
|
||||
const pagerList = [];
|
||||
let jumpPrev = null;
|
||||
|
@ -524,7 +539,7 @@ export default {
|
|||
totalText = (
|
||||
<li class={`${prefixCls}-total-text`}>
|
||||
{this.showTotal(this.total, [
|
||||
(stateCurrent - 1) * statePageSize + 1,
|
||||
this.total === 0 ? 0 : (stateCurrent - 1) * statePageSize + 1,
|
||||
stateCurrent * statePageSize > this.total ? this.total : stateCurrent * statePageSize,
|
||||
])}
|
||||
</li>
|
||||
|
@ -534,7 +549,11 @@ export default {
|
|||
const nextDisabled = !this.hasNext() || !allPages;
|
||||
const buildOptionText = this.buildOptionText || this.$scopedSlots.buildOptionText;
|
||||
return (
|
||||
<ul class={`${prefixCls}`} unselectable="unselectable" ref="paginationNode">
|
||||
<ul
|
||||
class={{ [`${prefixCls}`]: true, [`${prefixCls}-disabled`]: disabled }}
|
||||
unselectable="unselectable"
|
||||
ref="paginationNode"
|
||||
>
|
||||
{totalText}
|
||||
<li
|
||||
title={this.showTitle ? locale.prev_page : null}
|
||||
|
@ -558,6 +577,7 @@ export default {
|
|||
{this.itemRender(nextPage, 'next', this.getItemIcon('nextIcon'))}
|
||||
</li>
|
||||
<Options
|
||||
disabled={disabled}
|
||||
locale={locale}
|
||||
rootPrefixCls={prefixCls}
|
||||
selectComponentClass={this.selectComponentClass}
|
||||
|
@ -567,7 +587,7 @@ export default {
|
|||
pageSize={statePageSize}
|
||||
pageSizeOptions={this.pageSizeOptions}
|
||||
buildOptionText={buildOptionText || null}
|
||||
quickGo={this.showQuickJumper ? this.handleChange : null}
|
||||
quickGo={this.shouldDisplayQuickJumper() ? this.handleChange : null}
|
||||
goButton={goButton}
|
||||
/>
|
||||
</ul>
|
||||
|
|
|
@ -20,6 +20,7 @@ export default {
|
|||
},
|
||||
render () {
|
||||
return (
|
||||
<div>
|
||||
<VcPagination
|
||||
selectComponentClass={VcSelect}
|
||||
showQuickJumper
|
||||
|
@ -30,6 +31,19 @@ export default {
|
|||
onChange={this.onChange}
|
||||
total={450}
|
||||
/>
|
||||
<br/>
|
||||
<VcPagination
|
||||
selectComponentClass={VcSelect}
|
||||
showQuickJumper={{ goButton: true }}
|
||||
showSizeChanger
|
||||
defaultPageSize={20}
|
||||
defaultCurrent={5}
|
||||
onShowSizeChange={this.onShowSizeChange}
|
||||
onChange={this.onChange}
|
||||
total={450}
|
||||
disabled
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
},
|
||||
};
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
// based on rc-pagination 1.17.8
|
||||
// based on rc-pagination 1.20.5
|
||||
export { default } from './Pagination';
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
export default {
|
||||
// Options.jsx
|
||||
items_per_page: '/ str',
|
||||
jump_to: 'Idi na',
|
||||
jump_to_confirm: 'potvrdi',
|
||||
page: '',
|
||||
|
||||
// Pagination.jsx
|
||||
prev_page: 'Prijašnja stranica',
|
||||
next_page: 'Sljedeća stranica',
|
||||
prev_5: 'Prijašnjih 5 stranica',
|
||||
next_5: 'Sljedećih 5 stranica',
|
||||
prev_3: 'Prijašnje 3 stranice',
|
||||
next_3: 'Sljedeće 3 stranice',
|
||||
};
|
|
@ -0,0 +1,15 @@
|
|||
export default {
|
||||
// Options.jsx
|
||||
items_per_page: '/ lappuse',
|
||||
jump_to: 'iet uz',
|
||||
jump_to_confirm: 'apstiprināt',
|
||||
page: '',
|
||||
|
||||
// Pagination.jsx
|
||||
prev_page: 'Iepriekšējā lapa',
|
||||
next_page: 'Nākamā lapaspuse',
|
||||
prev_5: 'Iepriekšējās 5 lapas',
|
||||
next_5: 'Nākamās 5 lapas',
|
||||
prev_3: 'Iepriekšējās 3 lapas',
|
||||
next_3: 'Nākamās 3 lapas',
|
||||
};
|
|
@ -0,0 +1,15 @@
|
|||
export default {
|
||||
// Options.jsx
|
||||
items_per_page: '/ halaman',
|
||||
jump_to: 'Lompat ke',
|
||||
jump_to_confirm: 'Sahkan',
|
||||
page: '',
|
||||
|
||||
// Pagination.jsx
|
||||
prev_page: 'Halaman sebelumnya',
|
||||
next_page: 'Halam seterusnya',
|
||||
prev_5: '5 halaman sebelum',
|
||||
next_5: '5 halaman seterusnya',
|
||||
prev_3: '3 halaman sebelumnya',
|
||||
next_3: '3 halaman seterusnya',
|
||||
};
|
|
@ -1,6 +1,6 @@
|
|||
export default {
|
||||
// Options.jsx
|
||||
items_per_page: '/ páginas',
|
||||
items_per_page: '/ página',
|
||||
jump_to: 'Vá até',
|
||||
jump_to_confirm: 'confirme',
|
||||
page: '',
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
export default {
|
||||
// Options.jsx
|
||||
items_per_page: '/ பக்கம்',
|
||||
jump_to: 'அடுத்த',
|
||||
jump_to_confirm: 'உறுதிப்படுத்தவும்',
|
||||
page: '',
|
||||
|
||||
// Pagination.jsx
|
||||
prev_page: 'முந்தைய பக்கம்',
|
||||
next_page: 'அடுத்த பக்கம்',
|
||||
prev_5: 'முந்தைய 5 பக்கங்கள்',
|
||||
next_5: 'அடுத்த 5 பக்கங்கள்',
|
||||
prev_3: 'முந்தைய 3 பக்கங்கள்',
|
||||
next_3: 'அடுத்த 3 பக்கங்கள்',
|
||||
};
|
Loading…
Reference in New Issue