antd3-esm 1.0.1
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/LICENSE +21 -0
- package/dist/Checkbox.js +164 -0
- package/dist/CommonMixin.js +816 -0
- package/dist/Divider.js +646 -0
- package/dist/Notification.js +279 -0
- package/dist/Pagination.js +1106 -0
- package/dist/PortalWrapper.js +347 -0
- package/dist/RowContext.js +5 -0
- package/dist/Sider.js +533 -0
- package/dist/TextArea.js +432 -0
- package/dist/_arrayMap.js +68 -0
- package/dist/_assignValue.js +95 -0
- package/dist/_copyArray.js +31 -0
- package/dist/_hasPath.js +53 -0
- package/dist/_overArg.js +437 -0
- package/dist/_stringToArray.js +136 -0
- package/dist/antd/es/affix.js +12 -0
- package/dist/antd/es/alert.js +5 -0
- package/dist/antd/es/anchor.js +466 -0
- package/dist/antd/es/auto-complete.js +5 -0
- package/dist/antd/es/avatar.js +5 -0
- package/dist/antd/es/back-top.js +5 -0
- package/dist/antd/es/badge.js +5 -0
- package/dist/antd/es/breadcrumb.js +18 -0
- package/dist/antd/es/button.js +12 -0
- package/dist/antd/es/calendar.js +953 -0
- package/dist/antd/es/card.js +5 -0
- package/dist/antd/es/carousel.js +5 -0
- package/dist/antd/es/cascader.js +1275 -0
- package/dist/antd/es/checkbox.js +11 -0
- package/dist/antd/es/col.js +4 -0
- package/dist/antd/es/collapse.js +688 -0
- package/dist/antd/es/comment.js +5 -0
- package/dist/antd/es/config-provider.js +2 -0
- package/dist/antd/es/date-picker.js +4322 -0
- package/dist/antd/es/descriptions.js +342 -0
- package/dist/antd/es/divider.js +53 -0
- package/dist/antd/es/drawer.js +1115 -0
- package/dist/antd/es/dropdown.js +14 -0
- package/dist/antd/es/empty.js +6 -0
- package/dist/antd/es/form.js +5008 -0
- package/dist/antd/es/grid.js +13 -0
- package/dist/antd/es/icon.js +6 -0
- package/dist/antd/es/input-number.js +5 -0
- package/dist/antd/es/input.js +16 -0
- package/dist/antd/es/layout.js +14 -0
- package/dist/antd/es/list.js +5 -0
- package/dist/antd/es/locale/ar_EG.js +102 -0
- package/dist/antd/es/locale/bg_BG.js +98 -0
- package/dist/antd/es/locale/ca_ES.js +96 -0
- package/dist/antd/es/locale/cs_CZ.js +96 -0
- package/dist/antd/es/locale/da_DK.js +98 -0
- package/dist/antd/es/locale/de_DE.js +98 -0
- package/dist/antd/es/locale/default.js +2 -0
- package/dist/antd/es/locale/el_GR.js +98 -0
- package/dist/antd/es/locale/en_GB.js +98 -0
- package/dist/antd/es/locale/en_US.js +2 -0
- package/dist/antd/es/locale/es_ES.js +114 -0
- package/dist/antd/es/locale/et_EE.js +98 -0
- package/dist/antd/es/locale/fa_IR.js +98 -0
- package/dist/antd/es/locale/fi_FI.js +99 -0
- package/dist/antd/es/locale/fr_BE.js +102 -0
- package/dist/antd/es/locale/fr_FR.js +102 -0
- package/dist/antd/es/locale/ga_IE.js +99 -0
- package/dist/antd/es/locale/he_IL.js +99 -0
- package/dist/antd/es/locale/hi_IN.js +107 -0
- package/dist/antd/es/locale/hr_HR.js +113 -0
- package/dist/antd/es/locale/hu_HU.js +99 -0
- package/dist/antd/es/locale/hy_AM.js +109 -0
- package/dist/antd/es/locale/id_ID.js +101 -0
- package/dist/antd/es/locale/is_IS.js +98 -0
- package/dist/antd/es/locale/it_IT.js +111 -0
- package/dist/antd/es/locale/ja_JP.js +96 -0
- package/dist/antd/es/locale/kn_IN.js +107 -0
- package/dist/antd/es/locale/ko_KR.js +98 -0
- package/dist/antd/es/locale/ku_IQ.js +98 -0
- package/dist/antd/es/locale/lv_LV.js +98 -0
- package/dist/antd/es/locale/mk_MK.js +113 -0
- package/dist/antd/es/locale/mn_MN.js +99 -0
- package/dist/antd/es/locale/ms_MY.js +118 -0
- package/dist/antd/es/locale/nb_NO.js +97 -0
- package/dist/antd/es/locale/ne_NP.js +44 -0
- package/dist/antd/es/locale/nl_BE.js +98 -0
- package/dist/antd/es/locale/nl_NL.js +117 -0
- package/dist/antd/es/locale/pl_PL.js +98 -0
- package/dist/antd/es/locale/pt_BR.js +104 -0
- package/dist/antd/es/locale/pt_PT.js +127 -0
- package/dist/antd/es/locale/ro_RO.js +118 -0
- package/dist/antd/es/locale/ru_RU.js +110 -0
- package/dist/antd/es/locale/sk_SK.js +118 -0
- package/dist/antd/es/locale/sl_SI.js +96 -0
- package/dist/antd/es/locale/sr_RS.js +97 -0
- package/dist/antd/es/locale/sv_SE.js +101 -0
- package/dist/antd/es/locale/ta_IN.js +119 -0
- package/dist/antd/es/locale/th_TH.js +117 -0
- package/dist/antd/es/locale/tr_TR.js +112 -0
- package/dist/antd/es/locale/uk_UA.js +97 -0
- package/dist/antd/es/locale/vi_VN.js +99 -0
- package/dist/antd/es/locale/zh_CN.js +104 -0
- package/dist/antd/es/locale/zh_TW.js +100 -0
- package/dist/antd/es/locale-provider.js +6 -0
- package/dist/antd/es/mention.js +23215 -0
- package/dist/antd/es/mentions.js +961 -0
- package/dist/antd/es/menu.js +5 -0
- package/dist/antd/es/message.js +161 -0
- package/dist/antd/es/modal.js +885 -0
- package/dist/antd/es/notification.js +216 -0
- package/dist/antd/es/page-header.js +350 -0
- package/dist/antd/es/pagination.js +15 -0
- package/dist/antd/es/popconfirm.js +215 -0
- package/dist/antd/es/popover.js +5 -0
- package/dist/antd/es/progress.js +10 -0
- package/dist/antd/es/radio.js +10 -0
- package/dist/antd/es/rate.js +5 -0
- package/dist/antd/es/result.js +828 -0
- package/dist/antd/es/row.js +9 -0
- package/dist/antd/es/select.js +5 -0
- package/dist/antd/es/skeleton.js +370 -0
- package/dist/antd/es/slider.js +5 -0
- package/dist/antd/es/spin.js +11 -0
- package/dist/antd/es/statistic.js +650 -0
- package/dist/antd/es/steps.js +5 -0
- package/dist/antd/es/style.js +5 -0
- package/dist/antd/es/switch.js +5 -0
- package/dist/antd/es/table.js +7057 -0
- package/dist/antd/es/tabs.js +5 -0
- package/dist/antd/es/tag.js +12 -0
- package/dist/antd/es/time-picker.js +10 -0
- package/dist/antd/es/timeline.js +206 -0
- package/dist/antd/es/tooltip.js +9 -0
- package/dist/antd/es/transfer.js +2508 -0
- package/dist/antd/es/tree-select.js +5 -0
- package/dist/antd/es/tree.js +10 -0
- package/dist/antd/es/typography.js +1246 -0
- package/dist/antd/es/upload.js +3418 -0
- package/dist/antd/es/version.js +7 -0
- package/dist/col.js +142 -0
- package/dist/config-provider.js +6949 -0
- package/dist/dropdown.js +442 -0
- package/dist/get.js +1043 -0
- package/dist/icon.js +6138 -0
- package/dist/identity.js +230 -0
- package/dist/index.js +462 -0
- package/dist/index10.js +478 -0
- package/dist/index11.js +232 -0
- package/dist/index12.js +2766 -0
- package/dist/index13.js +422 -0
- package/dist/index14.js +283 -0
- package/dist/index15.js +1755 -0
- package/dist/index2.js +374 -0
- package/dist/index3.js +407 -0
- package/dist/index4.js +522 -0
- package/dist/index5.js +601 -0
- package/dist/index6.js +601 -0
- package/dist/index7.js +364 -0
- package/dist/index8.js +436 -0
- package/dist/index9.js +130 -0
- package/dist/input.js +475 -0
- package/dist/isLength.js +402 -0
- package/dist/keys.js +292 -0
- package/dist/menu.js +8138 -0
- package/dist/progress.js +852 -0
- package/dist/raf.js +34 -0
- package/dist/responsiveObserve.js +444 -0
- package/dist/row.js +173 -0
- package/dist/scrollTo.js +66 -0
- package/dist/toInteger.js +123 -0
- package/dist/toString.js +84 -0
- package/dist/transButton.js +121 -0
- package/dist/tree.js +3017 -0
- package/dist/warning.js +55 -0
- package/dist/wave.js +230 -0
- package/dist/zh_CN.js +17 -0
- package/package.json +160 -0
|
@@ -0,0 +1,1106 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import React__default from 'react';
|
|
3
|
+
import { d as _defineProperty, _ as _inherits$2, a as _classCallCheck$2, b as _possibleConstructorReturn$2, c as _createClass$2, e as _extends$2, I as Icon } from './icon.js';
|
|
4
|
+
import { c as classNames, P as PropTypes, C as ConfigConsumer, L as LocaleReceiver, k as Pagination$3 } from './config-provider.js';
|
|
5
|
+
import { P as Pagination$2 } from './zh_CN.js';
|
|
6
|
+
import { p as polyfill } from './menu.js';
|
|
7
|
+
import { S as Select } from './index12.js';
|
|
8
|
+
|
|
9
|
+
var Pager = function Pager(props) {
|
|
10
|
+
var _classNames;
|
|
11
|
+
|
|
12
|
+
var prefixCls = props.rootPrefixCls + '-item';
|
|
13
|
+
var cls = classNames(prefixCls, prefixCls + '-' + props.page, (_classNames = {}, _defineProperty(_classNames, prefixCls + '-active', props.active), _defineProperty(_classNames, props.className, !!props.className), _defineProperty(_classNames, prefixCls + '-disabled', !props.page), _classNames));
|
|
14
|
+
|
|
15
|
+
var handleClick = function handleClick() {
|
|
16
|
+
props.onClick(props.page);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
var handleKeyPress = function handleKeyPress(e) {
|
|
20
|
+
props.onKeyPress(e, props.onClick, props.page);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
return React__default.createElement(
|
|
24
|
+
'li',
|
|
25
|
+
{
|
|
26
|
+
title: props.showTitle ? props.page : null,
|
|
27
|
+
className: cls,
|
|
28
|
+
onClick: handleClick,
|
|
29
|
+
onKeyPress: handleKeyPress,
|
|
30
|
+
tabIndex: '0'
|
|
31
|
+
},
|
|
32
|
+
props.itemRender(props.page, 'page', React__default.createElement(
|
|
33
|
+
'a',
|
|
34
|
+
null,
|
|
35
|
+
props.page
|
|
36
|
+
))
|
|
37
|
+
);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
Pager.propTypes = {
|
|
41
|
+
page: PropTypes.number,
|
|
42
|
+
active: PropTypes.bool,
|
|
43
|
+
last: PropTypes.bool,
|
|
44
|
+
locale: PropTypes.object,
|
|
45
|
+
className: PropTypes.string,
|
|
46
|
+
showTitle: PropTypes.bool,
|
|
47
|
+
rootPrefixCls: PropTypes.string,
|
|
48
|
+
onClick: PropTypes.func,
|
|
49
|
+
onKeyPress: PropTypes.func,
|
|
50
|
+
itemRender: PropTypes.func
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
var KEYCODE = {
|
|
54
|
+
ENTER: 13,
|
|
55
|
+
|
|
56
|
+
ARROW_UP: 38,
|
|
57
|
+
ARROW_DOWN: 40
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
var Options = function (_React$Component) {
|
|
61
|
+
_inherits$2(Options, _React$Component);
|
|
62
|
+
|
|
63
|
+
function Options() {
|
|
64
|
+
var _ref;
|
|
65
|
+
|
|
66
|
+
var _temp, _this, _ret;
|
|
67
|
+
|
|
68
|
+
_classCallCheck$2(this, Options);
|
|
69
|
+
|
|
70
|
+
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
|
|
71
|
+
args[_key] = arguments[_key];
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return _ret = (_temp = (_this = _possibleConstructorReturn$2(this, (_ref = Options.__proto__ || Object.getPrototypeOf(Options)).call.apply(_ref, [this].concat(args))), _this), _this.state = {
|
|
75
|
+
goInputText: ''
|
|
76
|
+
}, _this.buildOptionText = function (value) {
|
|
77
|
+
return value + ' ' + _this.props.locale.items_per_page;
|
|
78
|
+
}, _this.changeSize = function (value) {
|
|
79
|
+
_this.props.changeSize(Number(value));
|
|
80
|
+
}, _this.handleChange = function (e) {
|
|
81
|
+
_this.setState({
|
|
82
|
+
goInputText: e.target.value
|
|
83
|
+
});
|
|
84
|
+
}, _this.handleBlur = function (e) {
|
|
85
|
+
var _this$props = _this.props,
|
|
86
|
+
goButton = _this$props.goButton,
|
|
87
|
+
quickGo = _this$props.quickGo,
|
|
88
|
+
rootPrefixCls = _this$props.rootPrefixCls;
|
|
89
|
+
|
|
90
|
+
if (goButton) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
if (e.relatedTarget && (e.relatedTarget.className.indexOf(rootPrefixCls + '-prev') >= 0 || e.relatedTarget.className.indexOf(rootPrefixCls + '-next') >= 0)) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
quickGo(_this.getValidValue());
|
|
97
|
+
}, _this.go = function (e) {
|
|
98
|
+
var goInputText = _this.state.goInputText;
|
|
99
|
+
|
|
100
|
+
if (goInputText === '') {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
if (e.keyCode === KEYCODE.ENTER || e.type === 'click') {
|
|
104
|
+
_this.setState({
|
|
105
|
+
goInputText: ''
|
|
106
|
+
});
|
|
107
|
+
_this.props.quickGo(_this.getValidValue());
|
|
108
|
+
}
|
|
109
|
+
}, _temp), _possibleConstructorReturn$2(_this, _ret);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
_createClass$2(Options, [{
|
|
113
|
+
key: 'getValidValue',
|
|
114
|
+
value: function getValidValue() {
|
|
115
|
+
var _state = this.state,
|
|
116
|
+
goInputText = _state.goInputText,
|
|
117
|
+
current = _state.current;
|
|
118
|
+
|
|
119
|
+
return !goInputText || isNaN(goInputText) ? current : Number(goInputText);
|
|
120
|
+
}
|
|
121
|
+
}, {
|
|
122
|
+
key: 'render',
|
|
123
|
+
value: function render() {
|
|
124
|
+
var _this2 = this;
|
|
125
|
+
|
|
126
|
+
var _props = this.props,
|
|
127
|
+
pageSize = _props.pageSize,
|
|
128
|
+
pageSizeOptions = _props.pageSizeOptions,
|
|
129
|
+
locale = _props.locale,
|
|
130
|
+
rootPrefixCls = _props.rootPrefixCls,
|
|
131
|
+
changeSize = _props.changeSize,
|
|
132
|
+
quickGo = _props.quickGo,
|
|
133
|
+
goButton = _props.goButton,
|
|
134
|
+
selectComponentClass = _props.selectComponentClass,
|
|
135
|
+
buildOptionText = _props.buildOptionText,
|
|
136
|
+
selectPrefixCls = _props.selectPrefixCls,
|
|
137
|
+
disabled = _props.disabled;
|
|
138
|
+
var goInputText = this.state.goInputText;
|
|
139
|
+
|
|
140
|
+
var prefixCls = rootPrefixCls + '-options';
|
|
141
|
+
var Select = selectComponentClass;
|
|
142
|
+
var changeSelect = null;
|
|
143
|
+
var goInput = null;
|
|
144
|
+
var gotoButton = null;
|
|
145
|
+
|
|
146
|
+
if (!changeSize && !quickGo) {
|
|
147
|
+
return null;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
if (changeSize && Select) {
|
|
151
|
+
var options = pageSizeOptions.map(function (opt, i) {
|
|
152
|
+
return React__default.createElement(
|
|
153
|
+
Select.Option,
|
|
154
|
+
{ key: i, value: opt },
|
|
155
|
+
(buildOptionText || _this2.buildOptionText)(opt)
|
|
156
|
+
);
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
changeSelect = React__default.createElement(
|
|
160
|
+
Select,
|
|
161
|
+
{
|
|
162
|
+
disabled: disabled,
|
|
163
|
+
prefixCls: selectPrefixCls,
|
|
164
|
+
showSearch: false,
|
|
165
|
+
className: prefixCls + '-size-changer',
|
|
166
|
+
optionLabelProp: 'children',
|
|
167
|
+
dropdownMatchSelectWidth: false,
|
|
168
|
+
value: (pageSize || pageSizeOptions[0]).toString(),
|
|
169
|
+
onChange: this.changeSize,
|
|
170
|
+
getPopupContainer: function getPopupContainer(triggerNode) {
|
|
171
|
+
return triggerNode.parentNode;
|
|
172
|
+
}
|
|
173
|
+
},
|
|
174
|
+
options
|
|
175
|
+
);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
if (quickGo) {
|
|
179
|
+
if (goButton) {
|
|
180
|
+
gotoButton = typeof goButton === 'boolean' ? React__default.createElement(
|
|
181
|
+
'button',
|
|
182
|
+
{
|
|
183
|
+
type: 'button',
|
|
184
|
+
onClick: this.go,
|
|
185
|
+
onKeyUp: this.go,
|
|
186
|
+
disabled: disabled
|
|
187
|
+
},
|
|
188
|
+
locale.jump_to_confirm
|
|
189
|
+
) : React__default.createElement(
|
|
190
|
+
'span',
|
|
191
|
+
{
|
|
192
|
+
onClick: this.go,
|
|
193
|
+
onKeyUp: this.go
|
|
194
|
+
},
|
|
195
|
+
goButton
|
|
196
|
+
);
|
|
197
|
+
}
|
|
198
|
+
goInput = React__default.createElement(
|
|
199
|
+
'div',
|
|
200
|
+
{ className: prefixCls + '-quick-jumper' },
|
|
201
|
+
locale.jump_to,
|
|
202
|
+
React__default.createElement('input', {
|
|
203
|
+
disabled: disabled,
|
|
204
|
+
type: 'text',
|
|
205
|
+
value: goInputText,
|
|
206
|
+
onChange: this.handleChange,
|
|
207
|
+
onKeyUp: this.go,
|
|
208
|
+
onBlur: this.handleBlur
|
|
209
|
+
}),
|
|
210
|
+
locale.page,
|
|
211
|
+
gotoButton
|
|
212
|
+
);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
return React__default.createElement(
|
|
216
|
+
'li',
|
|
217
|
+
{ className: '' + prefixCls },
|
|
218
|
+
changeSelect,
|
|
219
|
+
goInput
|
|
220
|
+
);
|
|
221
|
+
}
|
|
222
|
+
}]);
|
|
223
|
+
|
|
224
|
+
return Options;
|
|
225
|
+
}(React__default.Component);
|
|
226
|
+
|
|
227
|
+
Options.propTypes = {
|
|
228
|
+
disabled: PropTypes.bool,
|
|
229
|
+
changeSize: PropTypes.func,
|
|
230
|
+
quickGo: PropTypes.func,
|
|
231
|
+
selectComponentClass: PropTypes.func,
|
|
232
|
+
current: PropTypes.number,
|
|
233
|
+
pageSizeOptions: PropTypes.arrayOf(PropTypes.string),
|
|
234
|
+
pageSize: PropTypes.number,
|
|
235
|
+
buildOptionText: PropTypes.func,
|
|
236
|
+
locale: PropTypes.object,
|
|
237
|
+
rootPrefixCls: PropTypes.string,
|
|
238
|
+
selectPrefixCls: PropTypes.string,
|
|
239
|
+
goButton: PropTypes.oneOfType([PropTypes.bool, PropTypes.node])
|
|
240
|
+
};
|
|
241
|
+
Options.defaultProps = {
|
|
242
|
+
pageSizeOptions: ['10', '20', '30', '40']
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
function noop() {}
|
|
246
|
+
|
|
247
|
+
function isInteger(value) {
|
|
248
|
+
return typeof value === 'number' && isFinite(value) && Math.floor(value) === value;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
function defaultItemRender(page, type, element) {
|
|
252
|
+
return element;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
function calculatePage(p, state, props) {
|
|
256
|
+
var pageSize = p;
|
|
257
|
+
if (typeof pageSize === 'undefined') {
|
|
258
|
+
pageSize = state.pageSize;
|
|
259
|
+
}
|
|
260
|
+
return Math.floor((props.total - 1) / pageSize) + 1;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
var Pagination$1 = function (_React$Component) {
|
|
264
|
+
_inherits$2(Pagination, _React$Component);
|
|
265
|
+
|
|
266
|
+
function Pagination(props) {
|
|
267
|
+
_classCallCheck$2(this, Pagination);
|
|
268
|
+
|
|
269
|
+
var _this = _possibleConstructorReturn$2(this, (Pagination.__proto__ || Object.getPrototypeOf(Pagination)).call(this, props));
|
|
270
|
+
|
|
271
|
+
_initialiseProps.call(_this);
|
|
272
|
+
|
|
273
|
+
var hasOnChange = props.onChange !== noop;
|
|
274
|
+
var hasCurrent = 'current' in props;
|
|
275
|
+
if (hasCurrent && !hasOnChange) {
|
|
276
|
+
console.warn('Warning: You provided a `current` prop to a Pagination component without an `onChange` handler. This will render a read-only component.'); // eslint-disable-line
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
var current = props.defaultCurrent;
|
|
280
|
+
if ('current' in props) {
|
|
281
|
+
current = props.current;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
var pageSize = props.defaultPageSize;
|
|
285
|
+
if ('pageSize' in props) {
|
|
286
|
+
pageSize = props.pageSize;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
current = Math.min(current, calculatePage(pageSize, undefined, props));
|
|
290
|
+
|
|
291
|
+
_this.state = {
|
|
292
|
+
current: current,
|
|
293
|
+
currentInputValue: current,
|
|
294
|
+
pageSize: pageSize
|
|
295
|
+
};
|
|
296
|
+
return _this;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
_createClass$2(Pagination, [{
|
|
300
|
+
key: 'componentDidUpdate',
|
|
301
|
+
value: function componentDidUpdate(prevProps, prevState) {
|
|
302
|
+
// When current page change, fix focused style of prev item
|
|
303
|
+
// A hacky solution of https://github.com/ant-design/ant-design/issues/8948
|
|
304
|
+
var prefixCls = this.props.prefixCls;
|
|
305
|
+
|
|
306
|
+
if (prevState.current !== this.state.current && this.paginationNode) {
|
|
307
|
+
var lastCurrentNode = this.paginationNode.querySelector('.' + prefixCls + '-item-' + prevState.current);
|
|
308
|
+
if (lastCurrentNode && document.activeElement === lastCurrentNode) {
|
|
309
|
+
lastCurrentNode.blur();
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
}, {
|
|
314
|
+
key: 'getValidValue',
|
|
315
|
+
value: function getValidValue(e) {
|
|
316
|
+
var inputValue = e.target.value;
|
|
317
|
+
var allPages = calculatePage(undefined, this.state, this.props);
|
|
318
|
+
var currentInputValue = this.state.currentInputValue;
|
|
319
|
+
|
|
320
|
+
var value = void 0;
|
|
321
|
+
if (inputValue === '') {
|
|
322
|
+
value = inputValue;
|
|
323
|
+
} else if (isNaN(Number(inputValue))) {
|
|
324
|
+
value = currentInputValue;
|
|
325
|
+
} else if (inputValue >= allPages) {
|
|
326
|
+
value = allPages;
|
|
327
|
+
} else {
|
|
328
|
+
value = Number(inputValue);
|
|
329
|
+
}
|
|
330
|
+
return value;
|
|
331
|
+
}
|
|
332
|
+
}, {
|
|
333
|
+
key: 'render',
|
|
334
|
+
value: function render() {
|
|
335
|
+
var _props = this.props,
|
|
336
|
+
prefixCls = _props.prefixCls,
|
|
337
|
+
className = _props.className,
|
|
338
|
+
disabled = _props.disabled;
|
|
339
|
+
|
|
340
|
+
// When hideOnSinglePage is true and there is only 1 page, hide the pager
|
|
341
|
+
|
|
342
|
+
if (this.props.hideOnSinglePage === true && this.props.total <= this.state.pageSize) {
|
|
343
|
+
return null;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
var props = this.props;
|
|
347
|
+
var locale = props.locale;
|
|
348
|
+
|
|
349
|
+
var allPages = calculatePage(undefined, this.state, this.props);
|
|
350
|
+
var pagerList = [];
|
|
351
|
+
var jumpPrev = null;
|
|
352
|
+
var jumpNext = null;
|
|
353
|
+
var firstPager = null;
|
|
354
|
+
var lastPager = null;
|
|
355
|
+
var gotoButton = null;
|
|
356
|
+
|
|
357
|
+
var goButton = props.showQuickJumper && props.showQuickJumper.goButton;
|
|
358
|
+
var pageBufferSize = props.showLessItems ? 1 : 2;
|
|
359
|
+
var _state = this.state,
|
|
360
|
+
current = _state.current,
|
|
361
|
+
pageSize = _state.pageSize;
|
|
362
|
+
|
|
363
|
+
|
|
364
|
+
var prevPage = current - 1 > 0 ? current - 1 : 0;
|
|
365
|
+
var nextPage = current + 1 < allPages ? current + 1 : allPages;
|
|
366
|
+
|
|
367
|
+
var dataOrAriaAttributeProps = Object.keys(props).reduce(function (prev, key) {
|
|
368
|
+
if (key.substr(0, 5) === 'data-' || key.substr(0, 5) === 'aria-' || key === 'role') {
|
|
369
|
+
prev[key] = props[key];
|
|
370
|
+
}
|
|
371
|
+
return prev;
|
|
372
|
+
}, {});
|
|
373
|
+
|
|
374
|
+
if (props.simple) {
|
|
375
|
+
if (goButton) {
|
|
376
|
+
if (typeof goButton === 'boolean') {
|
|
377
|
+
gotoButton = React__default.createElement(
|
|
378
|
+
'button',
|
|
379
|
+
{
|
|
380
|
+
type: 'button',
|
|
381
|
+
onClick: this.handleGoTO,
|
|
382
|
+
onKeyUp: this.handleGoTO
|
|
383
|
+
},
|
|
384
|
+
locale.jump_to_confirm
|
|
385
|
+
);
|
|
386
|
+
} else {
|
|
387
|
+
gotoButton = React__default.createElement(
|
|
388
|
+
'span',
|
|
389
|
+
{
|
|
390
|
+
onClick: this.handleGoTO,
|
|
391
|
+
onKeyUp: this.handleGoTO
|
|
392
|
+
},
|
|
393
|
+
goButton
|
|
394
|
+
);
|
|
395
|
+
}
|
|
396
|
+
gotoButton = React__default.createElement(
|
|
397
|
+
'li',
|
|
398
|
+
{
|
|
399
|
+
title: props.showTitle ? '' + locale.jump_to + this.state.current + '/' + allPages : null,
|
|
400
|
+
className: prefixCls + '-simple-pager'
|
|
401
|
+
},
|
|
402
|
+
gotoButton
|
|
403
|
+
);
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
return React__default.createElement(
|
|
407
|
+
'ul',
|
|
408
|
+
_extends$2({
|
|
409
|
+
className: prefixCls + ' ' + prefixCls + '-simple ' + props.className,
|
|
410
|
+
style: props.style,
|
|
411
|
+
ref: this.savePaginationNode
|
|
412
|
+
}, dataOrAriaAttributeProps),
|
|
413
|
+
React__default.createElement(
|
|
414
|
+
'li',
|
|
415
|
+
{
|
|
416
|
+
title: props.showTitle ? locale.prev_page : null,
|
|
417
|
+
onClick: this.prev,
|
|
418
|
+
tabIndex: this.hasPrev() ? 0 : null,
|
|
419
|
+
onKeyPress: this.runIfEnterPrev,
|
|
420
|
+
className: (this.hasPrev() ? '' : prefixCls + '-disabled') + ' ' + prefixCls + '-prev',
|
|
421
|
+
'aria-disabled': !this.hasPrev()
|
|
422
|
+
},
|
|
423
|
+
props.itemRender(prevPage, 'prev', this.getItemIcon(props.prevIcon))
|
|
424
|
+
),
|
|
425
|
+
React__default.createElement(
|
|
426
|
+
'li',
|
|
427
|
+
{
|
|
428
|
+
title: props.showTitle ? this.state.current + '/' + allPages : null,
|
|
429
|
+
className: prefixCls + '-simple-pager'
|
|
430
|
+
},
|
|
431
|
+
React__default.createElement('input', {
|
|
432
|
+
type: 'text',
|
|
433
|
+
value: this.state.currentInputValue,
|
|
434
|
+
onKeyDown: this.handleKeyDown,
|
|
435
|
+
onKeyUp: this.handleKeyUp,
|
|
436
|
+
onChange: this.handleKeyUp,
|
|
437
|
+
size: '3'
|
|
438
|
+
}),
|
|
439
|
+
React__default.createElement(
|
|
440
|
+
'span',
|
|
441
|
+
{ className: prefixCls + '-slash' },
|
|
442
|
+
'/'
|
|
443
|
+
),
|
|
444
|
+
allPages
|
|
445
|
+
),
|
|
446
|
+
React__default.createElement(
|
|
447
|
+
'li',
|
|
448
|
+
{
|
|
449
|
+
title: props.showTitle ? locale.next_page : null,
|
|
450
|
+
onClick: this.next,
|
|
451
|
+
tabIndex: this.hasPrev() ? 0 : null,
|
|
452
|
+
onKeyPress: this.runIfEnterNext,
|
|
453
|
+
className: (this.hasNext() ? '' : prefixCls + '-disabled') + ' ' + prefixCls + '-next',
|
|
454
|
+
'aria-disabled': !this.hasNext()
|
|
455
|
+
},
|
|
456
|
+
props.itemRender(nextPage, 'next', this.getItemIcon(props.nextIcon))
|
|
457
|
+
),
|
|
458
|
+
gotoButton
|
|
459
|
+
);
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
if (allPages <= 5 + pageBufferSize * 2) {
|
|
463
|
+
var pagerProps = {
|
|
464
|
+
locale: locale,
|
|
465
|
+
rootPrefixCls: prefixCls,
|
|
466
|
+
onClick: this.handleChange,
|
|
467
|
+
onKeyPress: this.runIfEnter,
|
|
468
|
+
showTitle: props.showTitle,
|
|
469
|
+
itemRender: props.itemRender
|
|
470
|
+
};
|
|
471
|
+
if (!allPages) {
|
|
472
|
+
pagerList.push(React__default.createElement(Pager, _extends$2({}, pagerProps, {
|
|
473
|
+
key: 'noPager',
|
|
474
|
+
page: allPages,
|
|
475
|
+
className: prefixCls + '-disabled'
|
|
476
|
+
})));
|
|
477
|
+
}
|
|
478
|
+
for (var i = 1; i <= allPages; i++) {
|
|
479
|
+
var active = this.state.current === i;
|
|
480
|
+
pagerList.push(React__default.createElement(Pager, _extends$2({}, pagerProps, {
|
|
481
|
+
key: i,
|
|
482
|
+
page: i,
|
|
483
|
+
active: active
|
|
484
|
+
})));
|
|
485
|
+
}
|
|
486
|
+
} else {
|
|
487
|
+
var prevItemTitle = props.showLessItems ? locale.prev_3 : locale.prev_5;
|
|
488
|
+
var nextItemTitle = props.showLessItems ? locale.next_3 : locale.next_5;
|
|
489
|
+
if (props.showPrevNextJumpers) {
|
|
490
|
+
var jumpPrevClassString = prefixCls + '-jump-prev';
|
|
491
|
+
if (props.jumpPrevIcon) {
|
|
492
|
+
jumpPrevClassString += ' ' + prefixCls + '-jump-prev-custom-icon';
|
|
493
|
+
}
|
|
494
|
+
jumpPrev = React__default.createElement(
|
|
495
|
+
'li',
|
|
496
|
+
{
|
|
497
|
+
title: props.showTitle ? prevItemTitle : null,
|
|
498
|
+
key: 'prev',
|
|
499
|
+
onClick: this.jumpPrev,
|
|
500
|
+
tabIndex: '0',
|
|
501
|
+
onKeyPress: this.runIfEnterJumpPrev,
|
|
502
|
+
className: jumpPrevClassString
|
|
503
|
+
},
|
|
504
|
+
props.itemRender(this.getJumpPrevPage(), 'jump-prev', this.getItemIcon(props.jumpPrevIcon))
|
|
505
|
+
);
|
|
506
|
+
var jumpNextClassString = prefixCls + '-jump-next';
|
|
507
|
+
if (props.jumpNextIcon) {
|
|
508
|
+
jumpNextClassString += ' ' + prefixCls + '-jump-next-custom-icon';
|
|
509
|
+
}
|
|
510
|
+
jumpNext = React__default.createElement(
|
|
511
|
+
'li',
|
|
512
|
+
{
|
|
513
|
+
title: props.showTitle ? nextItemTitle : null,
|
|
514
|
+
key: 'next',
|
|
515
|
+
tabIndex: '0',
|
|
516
|
+
onClick: this.jumpNext,
|
|
517
|
+
onKeyPress: this.runIfEnterJumpNext,
|
|
518
|
+
className: jumpNextClassString
|
|
519
|
+
},
|
|
520
|
+
props.itemRender(this.getJumpNextPage(), 'jump-next', this.getItemIcon(props.jumpNextIcon))
|
|
521
|
+
);
|
|
522
|
+
}
|
|
523
|
+
lastPager = React__default.createElement(Pager, {
|
|
524
|
+
locale: props.locale,
|
|
525
|
+
last: true,
|
|
526
|
+
rootPrefixCls: prefixCls,
|
|
527
|
+
onClick: this.handleChange,
|
|
528
|
+
onKeyPress: this.runIfEnter,
|
|
529
|
+
key: allPages,
|
|
530
|
+
page: allPages,
|
|
531
|
+
active: false,
|
|
532
|
+
showTitle: props.showTitle,
|
|
533
|
+
itemRender: props.itemRender
|
|
534
|
+
});
|
|
535
|
+
firstPager = React__default.createElement(Pager, {
|
|
536
|
+
locale: props.locale,
|
|
537
|
+
rootPrefixCls: prefixCls,
|
|
538
|
+
onClick: this.handleChange,
|
|
539
|
+
onKeyPress: this.runIfEnter,
|
|
540
|
+
key: 1,
|
|
541
|
+
page: 1,
|
|
542
|
+
active: false,
|
|
543
|
+
showTitle: props.showTitle,
|
|
544
|
+
itemRender: props.itemRender
|
|
545
|
+
});
|
|
546
|
+
|
|
547
|
+
var left = Math.max(1, current - pageBufferSize);
|
|
548
|
+
var right = Math.min(current + pageBufferSize, allPages);
|
|
549
|
+
|
|
550
|
+
if (current - 1 <= pageBufferSize) {
|
|
551
|
+
right = 1 + pageBufferSize * 2;
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
if (allPages - current <= pageBufferSize) {
|
|
555
|
+
left = allPages - pageBufferSize * 2;
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
for (var _i = left; _i <= right; _i++) {
|
|
559
|
+
var _active = current === _i;
|
|
560
|
+
pagerList.push(React__default.createElement(Pager, {
|
|
561
|
+
locale: props.locale,
|
|
562
|
+
rootPrefixCls: prefixCls,
|
|
563
|
+
onClick: this.handleChange,
|
|
564
|
+
onKeyPress: this.runIfEnter,
|
|
565
|
+
key: _i,
|
|
566
|
+
page: _i,
|
|
567
|
+
active: _active,
|
|
568
|
+
showTitle: props.showTitle,
|
|
569
|
+
itemRender: props.itemRender
|
|
570
|
+
}));
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
if (current - 1 >= pageBufferSize * 2 && current !== 1 + 2) {
|
|
574
|
+
pagerList[0] = React__default.cloneElement(pagerList[0], {
|
|
575
|
+
className: prefixCls + '-item-after-jump-prev'
|
|
576
|
+
});
|
|
577
|
+
pagerList.unshift(jumpPrev);
|
|
578
|
+
}
|
|
579
|
+
if (allPages - current >= pageBufferSize * 2 && current !== allPages - 2) {
|
|
580
|
+
pagerList[pagerList.length - 1] = React__default.cloneElement(pagerList[pagerList.length - 1], {
|
|
581
|
+
className: prefixCls + '-item-before-jump-next'
|
|
582
|
+
});
|
|
583
|
+
pagerList.push(jumpNext);
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
if (left !== 1) {
|
|
587
|
+
pagerList.unshift(firstPager);
|
|
588
|
+
}
|
|
589
|
+
if (right !== allPages) {
|
|
590
|
+
pagerList.push(lastPager);
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
var totalText = null;
|
|
595
|
+
|
|
596
|
+
if (props.showTotal) {
|
|
597
|
+
totalText = React__default.createElement(
|
|
598
|
+
'li',
|
|
599
|
+
{ className: prefixCls + '-total-text' },
|
|
600
|
+
props.showTotal(props.total, [props.total === 0 ? 0 : (current - 1) * pageSize + 1, current * pageSize > props.total ? props.total : current * pageSize])
|
|
601
|
+
);
|
|
602
|
+
}
|
|
603
|
+
var prevDisabled = !this.hasPrev() || !allPages;
|
|
604
|
+
var nextDisabled = !this.hasNext() || !allPages;
|
|
605
|
+
return React__default.createElement(
|
|
606
|
+
'ul',
|
|
607
|
+
_extends$2({
|
|
608
|
+
className: classNames(prefixCls, className, _defineProperty({}, prefixCls + '-disabled', disabled)),
|
|
609
|
+
style: props.style,
|
|
610
|
+
unselectable: 'unselectable',
|
|
611
|
+
ref: this.savePaginationNode
|
|
612
|
+
}, dataOrAriaAttributeProps),
|
|
613
|
+
totalText,
|
|
614
|
+
React__default.createElement(
|
|
615
|
+
'li',
|
|
616
|
+
{
|
|
617
|
+
title: props.showTitle ? locale.prev_page : null,
|
|
618
|
+
onClick: this.prev,
|
|
619
|
+
tabIndex: prevDisabled ? null : 0,
|
|
620
|
+
onKeyPress: this.runIfEnterPrev,
|
|
621
|
+
className: (!prevDisabled ? '' : prefixCls + '-disabled') + ' ' + prefixCls + '-prev',
|
|
622
|
+
'aria-disabled': prevDisabled
|
|
623
|
+
},
|
|
624
|
+
props.itemRender(prevPage, 'prev', this.getItemIcon(props.prevIcon))
|
|
625
|
+
),
|
|
626
|
+
pagerList,
|
|
627
|
+
React__default.createElement(
|
|
628
|
+
'li',
|
|
629
|
+
{
|
|
630
|
+
title: props.showTitle ? locale.next_page : null,
|
|
631
|
+
onClick: this.next,
|
|
632
|
+
tabIndex: nextDisabled ? null : 0,
|
|
633
|
+
onKeyPress: this.runIfEnterNext,
|
|
634
|
+
className: (!nextDisabled ? '' : prefixCls + '-disabled') + ' ' + prefixCls + '-next',
|
|
635
|
+
'aria-disabled': nextDisabled
|
|
636
|
+
},
|
|
637
|
+
props.itemRender(nextPage, 'next', this.getItemIcon(props.nextIcon))
|
|
638
|
+
),
|
|
639
|
+
React__default.createElement(Options, {
|
|
640
|
+
disabled: disabled,
|
|
641
|
+
locale: props.locale,
|
|
642
|
+
rootPrefixCls: prefixCls,
|
|
643
|
+
selectComponentClass: props.selectComponentClass,
|
|
644
|
+
selectPrefixCls: props.selectPrefixCls,
|
|
645
|
+
changeSize: this.props.showSizeChanger ? this.changePageSize : null,
|
|
646
|
+
current: this.state.current,
|
|
647
|
+
pageSize: this.state.pageSize,
|
|
648
|
+
pageSizeOptions: this.props.pageSizeOptions,
|
|
649
|
+
quickGo: this.shouldDisplayQuickJumper() ? this.handleChange : null,
|
|
650
|
+
goButton: goButton
|
|
651
|
+
})
|
|
652
|
+
);
|
|
653
|
+
}
|
|
654
|
+
}], [{
|
|
655
|
+
key: 'getDerivedStateFromProps',
|
|
656
|
+
value: function getDerivedStateFromProps(props, prevState) {
|
|
657
|
+
var newState = {};
|
|
658
|
+
|
|
659
|
+
if ('current' in props) {
|
|
660
|
+
newState.current = props.current;
|
|
661
|
+
|
|
662
|
+
if (props.current !== prevState.current) {
|
|
663
|
+
newState.currentInputValue = newState.current;
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
if ('pageSize' in props && props.pageSize !== prevState.pageSize) {
|
|
668
|
+
var current = prevState.current;
|
|
669
|
+
var newCurrent = calculatePage(props.pageSize, prevState, props);
|
|
670
|
+
current = current > newCurrent ? newCurrent : current;
|
|
671
|
+
|
|
672
|
+
if (!('current' in props)) {
|
|
673
|
+
newState.current = current;
|
|
674
|
+
newState.currentInputValue = current;
|
|
675
|
+
}
|
|
676
|
+
newState.pageSize = props.pageSize;
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
return newState;
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
/**
|
|
683
|
+
* computed icon node that need to be rendered.
|
|
684
|
+
* @param {React.ReactNode | React.ComponentType<PaginationProps>} icon received icon.
|
|
685
|
+
* @returns {React.ReactNode}
|
|
686
|
+
*/
|
|
687
|
+
|
|
688
|
+
}]);
|
|
689
|
+
|
|
690
|
+
return Pagination;
|
|
691
|
+
}(React__default.Component);
|
|
692
|
+
|
|
693
|
+
Pagination$1.propTypes = {
|
|
694
|
+
disabled: PropTypes.bool,
|
|
695
|
+
prefixCls: PropTypes.string,
|
|
696
|
+
className: PropTypes.string,
|
|
697
|
+
current: PropTypes.number,
|
|
698
|
+
defaultCurrent: PropTypes.number,
|
|
699
|
+
total: PropTypes.number,
|
|
700
|
+
pageSize: PropTypes.number,
|
|
701
|
+
defaultPageSize: PropTypes.number,
|
|
702
|
+
onChange: PropTypes.func,
|
|
703
|
+
hideOnSinglePage: PropTypes.bool,
|
|
704
|
+
showSizeChanger: PropTypes.bool,
|
|
705
|
+
showLessItems: PropTypes.bool,
|
|
706
|
+
onShowSizeChange: PropTypes.func,
|
|
707
|
+
selectComponentClass: PropTypes.func,
|
|
708
|
+
showPrevNextJumpers: PropTypes.bool,
|
|
709
|
+
showQuickJumper: PropTypes.oneOfType([PropTypes.bool, PropTypes.object]),
|
|
710
|
+
showTitle: PropTypes.bool,
|
|
711
|
+
pageSizeOptions: PropTypes.arrayOf(PropTypes.string),
|
|
712
|
+
showTotal: PropTypes.func,
|
|
713
|
+
locale: PropTypes.object,
|
|
714
|
+
style: PropTypes.object,
|
|
715
|
+
itemRender: PropTypes.func,
|
|
716
|
+
prevIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.node]),
|
|
717
|
+
nextIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.node]),
|
|
718
|
+
jumpPrevIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.node]),
|
|
719
|
+
jumpNextIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.node])
|
|
720
|
+
};
|
|
721
|
+
Pagination$1.defaultProps = {
|
|
722
|
+
defaultCurrent: 1,
|
|
723
|
+
total: 0,
|
|
724
|
+
defaultPageSize: 10,
|
|
725
|
+
onChange: noop,
|
|
726
|
+
className: '',
|
|
727
|
+
selectPrefixCls: 'rc-select',
|
|
728
|
+
prefixCls: 'rc-pagination',
|
|
729
|
+
selectComponentClass: null,
|
|
730
|
+
hideOnSinglePage: false,
|
|
731
|
+
showPrevNextJumpers: true,
|
|
732
|
+
showQuickJumper: false,
|
|
733
|
+
showSizeChanger: false,
|
|
734
|
+
showLessItems: false,
|
|
735
|
+
showTitle: true,
|
|
736
|
+
onShowSizeChange: noop,
|
|
737
|
+
locale: Pagination$2,
|
|
738
|
+
style: {},
|
|
739
|
+
itemRender: defaultItemRender
|
|
740
|
+
};
|
|
741
|
+
|
|
742
|
+
var _initialiseProps = function _initialiseProps() {
|
|
743
|
+
var _this2 = this;
|
|
744
|
+
|
|
745
|
+
this.getJumpPrevPage = function () {
|
|
746
|
+
return Math.max(1, _this2.state.current - (_this2.props.showLessItems ? 3 : 5));
|
|
747
|
+
};
|
|
748
|
+
|
|
749
|
+
this.getJumpNextPage = function () {
|
|
750
|
+
return Math.min(calculatePage(undefined, _this2.state, _this2.props), _this2.state.current + (_this2.props.showLessItems ? 3 : 5));
|
|
751
|
+
};
|
|
752
|
+
|
|
753
|
+
this.getItemIcon = function (icon) {
|
|
754
|
+
var prefixCls = _this2.props.prefixCls;
|
|
755
|
+
|
|
756
|
+
var iconNode = icon || React__default.createElement('a', { className: prefixCls + '-item-link' });
|
|
757
|
+
if (typeof icon === 'function') {
|
|
758
|
+
iconNode = React__default.createElement(icon, _extends$2({}, _this2.props));
|
|
759
|
+
}
|
|
760
|
+
return iconNode;
|
|
761
|
+
};
|
|
762
|
+
|
|
763
|
+
this.savePaginationNode = function (node) {
|
|
764
|
+
_this2.paginationNode = node;
|
|
765
|
+
};
|
|
766
|
+
|
|
767
|
+
this.isValid = function (page) {
|
|
768
|
+
return isInteger(page) && page !== _this2.state.current;
|
|
769
|
+
};
|
|
770
|
+
|
|
771
|
+
this.shouldDisplayQuickJumper = function () {
|
|
772
|
+
var _props2 = _this2.props,
|
|
773
|
+
showQuickJumper = _props2.showQuickJumper,
|
|
774
|
+
pageSize = _props2.pageSize,
|
|
775
|
+
total = _props2.total;
|
|
776
|
+
|
|
777
|
+
if (total <= pageSize) {
|
|
778
|
+
return false;
|
|
779
|
+
}
|
|
780
|
+
return showQuickJumper;
|
|
781
|
+
};
|
|
782
|
+
|
|
783
|
+
this.handleKeyDown = function (e) {
|
|
784
|
+
if (e.keyCode === KEYCODE.ARROW_UP || e.keyCode === KEYCODE.ARROW_DOWN) {
|
|
785
|
+
e.preventDefault();
|
|
786
|
+
}
|
|
787
|
+
};
|
|
788
|
+
|
|
789
|
+
this.handleKeyUp = function (e) {
|
|
790
|
+
var value = _this2.getValidValue(e);
|
|
791
|
+
var currentInputValue = _this2.state.currentInputValue;
|
|
792
|
+
|
|
793
|
+
if (value !== currentInputValue) {
|
|
794
|
+
_this2.setState({
|
|
795
|
+
currentInputValue: value
|
|
796
|
+
});
|
|
797
|
+
}
|
|
798
|
+
if (e.keyCode === KEYCODE.ENTER) {
|
|
799
|
+
_this2.handleChange(value);
|
|
800
|
+
} else if (e.keyCode === KEYCODE.ARROW_UP) {
|
|
801
|
+
_this2.handleChange(value - 1);
|
|
802
|
+
} else if (e.keyCode === KEYCODE.ARROW_DOWN) {
|
|
803
|
+
_this2.handleChange(value + 1);
|
|
804
|
+
}
|
|
805
|
+
};
|
|
806
|
+
|
|
807
|
+
this.changePageSize = function (size) {
|
|
808
|
+
var current = _this2.state.current;
|
|
809
|
+
var newCurrent = calculatePage(size, _this2.state, _this2.props);
|
|
810
|
+
current = current > newCurrent ? newCurrent : current;
|
|
811
|
+
// fix the issue:
|
|
812
|
+
// Once 'total' is 0, 'current' in 'onShowSizeChange' is 0, which is not correct.
|
|
813
|
+
if (newCurrent === 0) {
|
|
814
|
+
current = _this2.state.current;
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
if (typeof size === 'number') {
|
|
818
|
+
if (!('pageSize' in _this2.props)) {
|
|
819
|
+
_this2.setState({
|
|
820
|
+
pageSize: size
|
|
821
|
+
});
|
|
822
|
+
}
|
|
823
|
+
if (!('current' in _this2.props)) {
|
|
824
|
+
_this2.setState({
|
|
825
|
+
current: current,
|
|
826
|
+
currentInputValue: current
|
|
827
|
+
});
|
|
828
|
+
}
|
|
829
|
+
}
|
|
830
|
+
_this2.props.onShowSizeChange(current, size);
|
|
831
|
+
};
|
|
832
|
+
|
|
833
|
+
this.handleChange = function (p) {
|
|
834
|
+
var disabled = _this2.props.disabled;
|
|
835
|
+
|
|
836
|
+
|
|
837
|
+
var page = p;
|
|
838
|
+
if (_this2.isValid(page) && !disabled) {
|
|
839
|
+
var currentPage = calculatePage(undefined, _this2.state, _this2.props);
|
|
840
|
+
if (page > currentPage) {
|
|
841
|
+
page = currentPage;
|
|
842
|
+
} else if (page < 1) {
|
|
843
|
+
page = 1;
|
|
844
|
+
}
|
|
845
|
+
|
|
846
|
+
if (!('current' in _this2.props)) {
|
|
847
|
+
_this2.setState({
|
|
848
|
+
current: page,
|
|
849
|
+
currentInputValue: page
|
|
850
|
+
});
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
var pageSize = _this2.state.pageSize;
|
|
854
|
+
_this2.props.onChange(page, pageSize);
|
|
855
|
+
|
|
856
|
+
return page;
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
return _this2.state.current;
|
|
860
|
+
};
|
|
861
|
+
|
|
862
|
+
this.prev = function () {
|
|
863
|
+
if (_this2.hasPrev()) {
|
|
864
|
+
_this2.handleChange(_this2.state.current - 1);
|
|
865
|
+
}
|
|
866
|
+
};
|
|
867
|
+
|
|
868
|
+
this.next = function () {
|
|
869
|
+
if (_this2.hasNext()) {
|
|
870
|
+
_this2.handleChange(_this2.state.current + 1);
|
|
871
|
+
}
|
|
872
|
+
};
|
|
873
|
+
|
|
874
|
+
this.jumpPrev = function () {
|
|
875
|
+
_this2.handleChange(_this2.getJumpPrevPage());
|
|
876
|
+
};
|
|
877
|
+
|
|
878
|
+
this.jumpNext = function () {
|
|
879
|
+
_this2.handleChange(_this2.getJumpNextPage());
|
|
880
|
+
};
|
|
881
|
+
|
|
882
|
+
this.hasPrev = function () {
|
|
883
|
+
return _this2.state.current > 1;
|
|
884
|
+
};
|
|
885
|
+
|
|
886
|
+
this.hasNext = function () {
|
|
887
|
+
return _this2.state.current < calculatePage(undefined, _this2.state, _this2.props);
|
|
888
|
+
};
|
|
889
|
+
|
|
890
|
+
this.runIfEnter = function (event, callback) {
|
|
891
|
+
for (var _len = arguments.length, restParams = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
892
|
+
restParams[_key - 2] = arguments[_key];
|
|
893
|
+
}
|
|
894
|
+
|
|
895
|
+
if (event.key === 'Enter' || event.charCode === 13) {
|
|
896
|
+
callback.apply(undefined, restParams);
|
|
897
|
+
}
|
|
898
|
+
};
|
|
899
|
+
|
|
900
|
+
this.runIfEnterPrev = function (e) {
|
|
901
|
+
_this2.runIfEnter(e, _this2.prev);
|
|
902
|
+
};
|
|
903
|
+
|
|
904
|
+
this.runIfEnterNext = function (e) {
|
|
905
|
+
_this2.runIfEnter(e, _this2.next);
|
|
906
|
+
};
|
|
907
|
+
|
|
908
|
+
this.runIfEnterJumpPrev = function (e) {
|
|
909
|
+
_this2.runIfEnter(e, _this2.jumpPrev);
|
|
910
|
+
};
|
|
911
|
+
|
|
912
|
+
this.runIfEnterJumpNext = function (e) {
|
|
913
|
+
_this2.runIfEnter(e, _this2.jumpNext);
|
|
914
|
+
};
|
|
915
|
+
|
|
916
|
+
this.handleGoTO = function (e) {
|
|
917
|
+
if (e.keyCode === KEYCODE.ENTER || e.type === 'click') {
|
|
918
|
+
_this2.handleChange(_this2.state.currentInputValue);
|
|
919
|
+
}
|
|
920
|
+
};
|
|
921
|
+
};
|
|
922
|
+
|
|
923
|
+
polyfill(Pagination$1);
|
|
924
|
+
|
|
925
|
+
function _typeof$1(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof$1 = function _typeof(obj) { return typeof obj; }; } else { _typeof$1 = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof$1(obj); }
|
|
926
|
+
|
|
927
|
+
function _extends$1() { _extends$1 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$1.apply(this, arguments); }
|
|
928
|
+
|
|
929
|
+
function _classCallCheck$1(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
930
|
+
|
|
931
|
+
function _defineProperties$1(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
932
|
+
|
|
933
|
+
function _createClass$1(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties$1(Constructor.prototype, protoProps); return Constructor; }
|
|
934
|
+
|
|
935
|
+
function _inherits$1(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf$1(subClass, superClass); }
|
|
936
|
+
|
|
937
|
+
function _setPrototypeOf$1(o, p) { _setPrototypeOf$1 = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf$1(o, p); }
|
|
938
|
+
|
|
939
|
+
function _createSuper$1(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$1(); return function _createSuperInternal() { var Super = _getPrototypeOf$1(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf$1(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn$1(this, result); }; }
|
|
940
|
+
|
|
941
|
+
function _possibleConstructorReturn$1(self, call) { if (call && (_typeof$1(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized$1(self); }
|
|
942
|
+
|
|
943
|
+
function _assertThisInitialized$1(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
944
|
+
|
|
945
|
+
function _isNativeReflectConstruct$1() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
|
|
946
|
+
|
|
947
|
+
function _getPrototypeOf$1(o) { _getPrototypeOf$1 = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf$1(o); }
|
|
948
|
+
|
|
949
|
+
var MiniSelect = /*#__PURE__*/function (_React$Component) {
|
|
950
|
+
_inherits$1(MiniSelect, _React$Component);
|
|
951
|
+
|
|
952
|
+
var _super = _createSuper$1(MiniSelect);
|
|
953
|
+
|
|
954
|
+
function MiniSelect() {
|
|
955
|
+
_classCallCheck$1(this, MiniSelect);
|
|
956
|
+
|
|
957
|
+
return _super.apply(this, arguments);
|
|
958
|
+
}
|
|
959
|
+
|
|
960
|
+
_createClass$1(MiniSelect, [{
|
|
961
|
+
key: "render",
|
|
962
|
+
value: function render() {
|
|
963
|
+
return /*#__PURE__*/React.createElement(Select, _extends$1({
|
|
964
|
+
size: "small"
|
|
965
|
+
}, this.props));
|
|
966
|
+
}
|
|
967
|
+
}]);
|
|
968
|
+
|
|
969
|
+
return MiniSelect;
|
|
970
|
+
}(React.Component);
|
|
971
|
+
MiniSelect.Option = Select.Option;
|
|
972
|
+
|
|
973
|
+
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
974
|
+
|
|
975
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
976
|
+
|
|
977
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
978
|
+
|
|
979
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
980
|
+
|
|
981
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); return Constructor; }
|
|
982
|
+
|
|
983
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
984
|
+
|
|
985
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
986
|
+
|
|
987
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
988
|
+
|
|
989
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
990
|
+
|
|
991
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
992
|
+
|
|
993
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
|
|
994
|
+
|
|
995
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
996
|
+
|
|
997
|
+
var __rest = undefined && undefined.__rest || function (s, e) {
|
|
998
|
+
var t = {};
|
|
999
|
+
|
|
1000
|
+
for (var p in s) {
|
|
1001
|
+
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
1002
|
+
}
|
|
1003
|
+
|
|
1004
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
1005
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
1006
|
+
}
|
|
1007
|
+
return t;
|
|
1008
|
+
};
|
|
1009
|
+
|
|
1010
|
+
var Pagination = /*#__PURE__*/function (_React$Component) {
|
|
1011
|
+
_inherits(Pagination, _React$Component);
|
|
1012
|
+
|
|
1013
|
+
var _super = _createSuper(Pagination);
|
|
1014
|
+
|
|
1015
|
+
function Pagination() {
|
|
1016
|
+
var _this;
|
|
1017
|
+
|
|
1018
|
+
_classCallCheck(this, Pagination);
|
|
1019
|
+
|
|
1020
|
+
_this = _super.apply(this, arguments);
|
|
1021
|
+
|
|
1022
|
+
_this.getIconsProps = function (prefixCls) {
|
|
1023
|
+
var prevIcon = /*#__PURE__*/React.createElement("a", {
|
|
1024
|
+
className: "".concat(prefixCls, "-item-link")
|
|
1025
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
1026
|
+
type: "left"
|
|
1027
|
+
}));
|
|
1028
|
+
var nextIcon = /*#__PURE__*/React.createElement("a", {
|
|
1029
|
+
className: "".concat(prefixCls, "-item-link")
|
|
1030
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
1031
|
+
type: "right"
|
|
1032
|
+
}));
|
|
1033
|
+
var jumpPrevIcon = /*#__PURE__*/React.createElement("a", {
|
|
1034
|
+
className: "".concat(prefixCls, "-item-link")
|
|
1035
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
1036
|
+
className: "".concat(prefixCls, "-item-container")
|
|
1037
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
1038
|
+
className: "".concat(prefixCls, "-item-link-icon"),
|
|
1039
|
+
type: "double-left"
|
|
1040
|
+
}), /*#__PURE__*/React.createElement("span", {
|
|
1041
|
+
className: "".concat(prefixCls, "-item-ellipsis")
|
|
1042
|
+
}, "\u2022\u2022\u2022")));
|
|
1043
|
+
var jumpNextIcon = /*#__PURE__*/React.createElement("a", {
|
|
1044
|
+
className: "".concat(prefixCls, "-item-link")
|
|
1045
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
1046
|
+
className: "".concat(prefixCls, "-item-container")
|
|
1047
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
1048
|
+
className: "".concat(prefixCls, "-item-link-icon"),
|
|
1049
|
+
type: "double-right"
|
|
1050
|
+
}), /*#__PURE__*/React.createElement("span", {
|
|
1051
|
+
className: "".concat(prefixCls, "-item-ellipsis")
|
|
1052
|
+
}, "\u2022\u2022\u2022")));
|
|
1053
|
+
return {
|
|
1054
|
+
prevIcon: prevIcon,
|
|
1055
|
+
nextIcon: nextIcon,
|
|
1056
|
+
jumpPrevIcon: jumpPrevIcon,
|
|
1057
|
+
jumpNextIcon: jumpNextIcon
|
|
1058
|
+
};
|
|
1059
|
+
};
|
|
1060
|
+
|
|
1061
|
+
_this.renderPagination = function (contextLocale) {
|
|
1062
|
+
var _a = _this.props,
|
|
1063
|
+
customizePrefixCls = _a.prefixCls,
|
|
1064
|
+
customizeSelectPrefixCls = _a.selectPrefixCls,
|
|
1065
|
+
className = _a.className,
|
|
1066
|
+
size = _a.size,
|
|
1067
|
+
customLocale = _a.locale,
|
|
1068
|
+
restProps = __rest(_a, ["prefixCls", "selectPrefixCls", "className", "size", "locale"]);
|
|
1069
|
+
|
|
1070
|
+
var locale = _extends(_extends({}, contextLocale), customLocale);
|
|
1071
|
+
|
|
1072
|
+
var isSmall = size === 'small';
|
|
1073
|
+
return /*#__PURE__*/React.createElement(ConfigConsumer, null, function (_ref) {
|
|
1074
|
+
var getPrefixCls = _ref.getPrefixCls;
|
|
1075
|
+
var prefixCls = getPrefixCls('pagination', customizePrefixCls);
|
|
1076
|
+
var selectPrefixCls = getPrefixCls('select', customizeSelectPrefixCls);
|
|
1077
|
+
return /*#__PURE__*/React.createElement(Pagination$1, _extends({}, restProps, {
|
|
1078
|
+
prefixCls: prefixCls,
|
|
1079
|
+
selectPrefixCls: selectPrefixCls
|
|
1080
|
+
}, _this.getIconsProps(prefixCls), {
|
|
1081
|
+
className: classNames(className, {
|
|
1082
|
+
mini: isSmall
|
|
1083
|
+
}),
|
|
1084
|
+
selectComponentClass: isSmall ? MiniSelect : Select,
|
|
1085
|
+
locale: locale
|
|
1086
|
+
}));
|
|
1087
|
+
});
|
|
1088
|
+
};
|
|
1089
|
+
|
|
1090
|
+
return _this;
|
|
1091
|
+
}
|
|
1092
|
+
|
|
1093
|
+
_createClass(Pagination, [{
|
|
1094
|
+
key: "render",
|
|
1095
|
+
value: function render() {
|
|
1096
|
+
return /*#__PURE__*/React.createElement(LocaleReceiver, {
|
|
1097
|
+
componentName: "Pagination",
|
|
1098
|
+
defaultLocale: Pagination$3
|
|
1099
|
+
}, this.renderPagination);
|
|
1100
|
+
}
|
|
1101
|
+
}]);
|
|
1102
|
+
|
|
1103
|
+
return Pagination;
|
|
1104
|
+
}(React.Component);
|
|
1105
|
+
|
|
1106
|
+
export { Pagination as P };
|