@qsxy/element-plus-react 1.0.0-next.17 → 1.0.0-next.18
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/CheckboxGroup/CheckboxGroup.js +1 -0
- package/dist/ConfigProvider/ConfigProvider.d.ts +2 -0
- package/dist/ConfigProvider/ConfigProvider.js +5 -1
- package/dist/ConfigProvider/index.d.ts +1 -1
- package/dist/ConfigProvider/index.js +1 -1
- package/dist/DateTimePicker/DateTimePicker.d.ts +1 -1
- package/dist/Form/Form.d.ts +1 -1
- package/dist/MessageBox/MessageBox.js +1 -0
- package/dist/MessageBox/typings.d.ts +1 -0
- package/dist/Pagination/Options.d.ts +7 -2
- package/dist/Pagination/Options.js +68 -53
- package/dist/Pagination/Pager.js +10 -10
- package/dist/Pagination/Pagination.js +288 -318
- package/dist/Pagination/typings.d.ts +27 -28
- package/dist/Select/SelectCore.js +6 -5
- package/dist/Select/SelectDropdown.js +65 -15
- package/dist/Select/typings.d.ts +5 -0
- package/dist/Table/Table.d.ts +1 -1
- package/dist/Table/hooks/useSelection.d.ts +3 -3
- package/dist/Table/util.d.ts +2 -4
- package/dist/Transfer/ListBody.js +1 -1
- package/dist/TreeSelect/TreeSelect.d.ts +1 -1
- package/dist/index.css +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -0
- package/dist/locale/en.d.ts +179 -0
- package/dist/locale/en.js +178 -0
- package/dist/locale/i18n.d.ts +2 -0
- package/dist/locale/i18n.js +44 -0
- package/dist/locale/zhCn.d.ts +178 -0
- package/dist/locale/zhCn.js +177 -0
- package/package.json +4 -1
- package/theme-chalk/pagination/index.scss +227 -439
- package/theme-chalk/select/index.scss +10 -7
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
-
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12
|
|
3
|
-
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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); }
|
|
4
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
5
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
2
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12;
|
|
6
3
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
7
4
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
8
5
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
@@ -15,28 +12,28 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
|
|
|
15
12
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
16
13
|
import { useMount } from 'ahooks';
|
|
17
14
|
import classNames from 'classnames';
|
|
18
|
-
import React, {
|
|
19
|
-
import
|
|
15
|
+
import React, { forwardRef, isValidElement, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
|
|
16
|
+
import { useTranslation } from 'react-i18next';
|
|
17
|
+
import { useConfigProvider } from "../ConfigProvider";
|
|
20
18
|
import Icon from "../Icon/Icon";
|
|
21
|
-
import { mergeDefaultProps } from "../Util";
|
|
19
|
+
import { isNotEmpty, mergeDefaultProps } from "../Util";
|
|
22
20
|
import { useClassNames, useControlled } from "../hooks";
|
|
23
21
|
import Options from "./Options";
|
|
24
22
|
import Pager from "./Pager";
|
|
25
23
|
import { calculatePage, isValid } from "./util";
|
|
26
24
|
var Pagination = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
27
|
-
var _ref;
|
|
28
25
|
props = mergeDefaultProps({
|
|
29
|
-
|
|
26
|
+
defaultCurrentPage: 1,
|
|
30
27
|
total: 0,
|
|
28
|
+
size: 'default',
|
|
31
29
|
defaultPageSize: 10,
|
|
32
30
|
hideOnSinglePage: false,
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
31
|
+
// showQuickJumper: false,
|
|
32
|
+
pageSizes: [10, 20, 30, 40, 50, 100],
|
|
33
|
+
pagerCount: 7,
|
|
34
|
+
layout: 'prev, pager, next, jumper, ->, total',
|
|
35
|
+
prevIcon: 'angle-left',
|
|
36
|
+
nextIcon: 'angle-right'
|
|
40
37
|
}, props);
|
|
41
38
|
var _props = props,
|
|
42
39
|
_props$classPrefix = _props.classPrefix,
|
|
@@ -46,21 +43,29 @@ var Pagination = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
46
43
|
disabled = _props.disabled,
|
|
47
44
|
hideOnSinglePage = _props.hideOnSinglePage,
|
|
48
45
|
total = _props.total,
|
|
49
|
-
showQuickJumper = _props.showQuickJumper,
|
|
50
|
-
showLessItems = _props.showLessItems,
|
|
51
46
|
size = _props.size,
|
|
52
|
-
|
|
47
|
+
prevText = _props.prevText,
|
|
48
|
+
prevIcon = _props.prevIcon,
|
|
49
|
+
pagerCount = _props.pagerCount,
|
|
50
|
+
nextText = _props.nextText,
|
|
51
|
+
nextIcon = _props.nextIcon,
|
|
53
52
|
showTotal = _props.showTotal,
|
|
53
|
+
layout = _props.layout,
|
|
54
54
|
simple = _props.simple,
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
pageSizeOptions = _props.pageSizeOptions,
|
|
58
|
-
showSizeChanger = _props.showSizeChanger,
|
|
55
|
+
background = _props.background,
|
|
56
|
+
pageSizes = _props.pageSizes,
|
|
59
57
|
onChange = _props.onChange,
|
|
60
|
-
|
|
58
|
+
onSizeChange = _props.onSizeChange;
|
|
61
59
|
var _useClassNames = useClassNames(classPrefix),
|
|
62
|
-
b = _useClassNames.b
|
|
63
|
-
|
|
60
|
+
b = _useClassNames.b,
|
|
61
|
+
is = _useClassNames.is,
|
|
62
|
+
m = _useClassNames.m,
|
|
63
|
+
e = _useClassNames.e;
|
|
64
|
+
var _useTranslation = useTranslation(),
|
|
65
|
+
t = _useTranslation.t;
|
|
66
|
+
var _useConfigProvider = useConfigProvider(),
|
|
67
|
+
locale = _useConfigProvider.locale;
|
|
68
|
+
var _useControlled = useControlled(props.currentPage, props.defaultCurrentPage),
|
|
64
69
|
_useControlled2 = _slicedToArray(_useControlled, 2),
|
|
65
70
|
current = _useControlled2[0],
|
|
66
71
|
setCurrent = _useControlled2[1];
|
|
@@ -81,43 +86,12 @@ var Pagination = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
81
86
|
inputValue = _useState6[0],
|
|
82
87
|
setInputValue = _useState6[1];
|
|
83
88
|
var containerRef = useRef(null);
|
|
84
|
-
var prevIcon = useMemo(function () {
|
|
85
|
-
return /*#__PURE__*/React.createElement(Button, {
|
|
86
|
-
className: b(_templateObject || (_templateObject = _taggedTemplateLiteral(["item-link"])))
|
|
87
|
-
}, /*#__PURE__*/React.createElement(Icon, {
|
|
88
|
-
name: "angle-left",
|
|
89
|
-
prefix: "fal"
|
|
90
|
-
}));
|
|
91
|
-
}, [b]);
|
|
92
|
-
var nextIcon = useMemo(function () {
|
|
93
|
-
return /*#__PURE__*/React.createElement(Button, {
|
|
94
|
-
className: b(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["item-link"])))
|
|
95
|
-
}, /*#__PURE__*/React.createElement(Icon, {
|
|
96
|
-
name: "angle-right",
|
|
97
|
-
prefix: "fal"
|
|
98
|
-
}));
|
|
99
|
-
}, [b]);
|
|
100
|
-
var jumpPrevIcon = useMemo(function () {
|
|
101
|
-
return /*#__PURE__*/React.createElement(Icon, {
|
|
102
|
-
name: "ellipsis",
|
|
103
|
-
className: b(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["item-link"])))
|
|
104
|
-
});
|
|
105
|
-
}, [b]);
|
|
106
|
-
var jumpNextIcon = useMemo(function () {
|
|
107
|
-
return /*#__PURE__*/React.createElement(Icon, {
|
|
108
|
-
name: "ellipsis",
|
|
109
|
-
className: b(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["item-link"])))
|
|
110
|
-
});
|
|
111
|
-
}, [b]);
|
|
112
|
-
|
|
113
|
-
// const paginationNode = useRef<HTMLUListElement>(null);
|
|
114
|
-
|
|
115
89
|
useMount(function () {
|
|
116
90
|
var hasOnChange = !!onChange;
|
|
117
|
-
var hasCurrent = ('
|
|
91
|
+
var hasCurrent = ('currentPage' in props);
|
|
118
92
|
if (hasCurrent && !hasOnChange) {
|
|
119
93
|
// eslint-disable-next-line no-console
|
|
120
|
-
console.warn('Warning: You provided a `
|
|
94
|
+
console.warn('Warning: You provided a `currentPage` prop to a Pagination component without an `onChange` handler. This will render a read-only component.');
|
|
121
95
|
}
|
|
122
96
|
var _current = Math.min(current, calculatePage(pageSize, undefined, total));
|
|
123
97
|
if (_current <= 0) {
|
|
@@ -152,14 +126,6 @@ var Pagination = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
152
126
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
153
127
|
}, [pageSize, total]);
|
|
154
128
|
|
|
155
|
-
/** 页码按钮 */
|
|
156
|
-
var getItemIcon = useCallback(function (icon) {
|
|
157
|
-
return typeof icon === 'function' ? /*#__PURE__*/createElement(icon, _objectSpread({}, props)) : icon || /*#__PURE__*/React.createElement("button", {
|
|
158
|
-
type: "button",
|
|
159
|
-
className: b(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["item-link"])))
|
|
160
|
-
});
|
|
161
|
-
}, [b, props]);
|
|
162
|
-
|
|
163
129
|
/** 是否有上一页 */
|
|
164
130
|
var hasPrev = useMemo(function () {
|
|
165
131
|
return current > 1;
|
|
@@ -171,57 +137,17 @@ var Pagination = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
171
137
|
pageSize: pageSize
|
|
172
138
|
}, total);
|
|
173
139
|
}, [current, pageSize, total]);
|
|
174
|
-
|
|
175
|
-
/** 向前快速跳转几页页码 */
|
|
176
|
-
var jumpPrevPage = useMemo(function () {
|
|
177
|
-
return Math.max(1, current - (showLessItems ? 3 : 5));
|
|
178
|
-
}, [current, showLessItems]);
|
|
179
|
-
|
|
180
|
-
/** 向后快速跳转几页页码 */
|
|
181
|
-
var jumpNextPage = useMemo(function () {
|
|
182
|
-
return Math.min(calculatePage(undefined, {
|
|
183
|
-
pageSize: pageSize
|
|
184
|
-
}, total), current + (showLessItems ? 3 : 5));
|
|
185
|
-
}, [current, pageSize, total, showLessItems]);
|
|
186
140
|
var allPages = useMemo(function () {
|
|
187
141
|
return calculatePage(undefined, {
|
|
188
142
|
pageSize: pageSize
|
|
189
143
|
}, total);
|
|
190
144
|
}, [pageSize, total]);
|
|
191
|
-
|
|
192
|
-
/** 上一页按钮 */
|
|
193
|
-
var prevPage = useMemo(function () {
|
|
194
|
-
var prev = current - 1 > 0 ? current - 1 : 0;
|
|
195
|
-
var prevButton = itemRender === null || itemRender === void 0 ? void 0 : itemRender(prev, 'prev', getItemIcon(prevIcon));
|
|
196
|
-
return /*#__PURE__*/isValidElement(prevButton) ? /*#__PURE__*/cloneElement(prevButton, {
|
|
197
|
-
disabled: !hasPrev
|
|
198
|
-
}) : prevButton;
|
|
199
|
-
}, [current, getItemIcon, hasPrev, itemRender, prevIcon]);
|
|
200
|
-
|
|
201
|
-
/** 下一页按钮 */
|
|
202
|
-
var nextPage = useMemo(function () {
|
|
203
|
-
var next = current + 1 < allPages ? current + 1 : allPages;
|
|
204
|
-
var nextButton = itemRender === null || itemRender === void 0 ? void 0 : itemRender(next, 'next', getItemIcon(nextIcon));
|
|
205
|
-
return /*#__PURE__*/isValidElement(nextButton) ? /*#__PURE__*/cloneElement(nextButton, {
|
|
206
|
-
disabled: !hasNext
|
|
207
|
-
}) : nextButton;
|
|
208
|
-
}, [allPages, current, getItemIcon, hasNext, itemRender, nextIcon]);
|
|
209
|
-
|
|
210
|
-
/** 分页描述 */
|
|
211
|
-
var totalText = useMemo(function () {
|
|
212
|
-
return typeof showTotal === 'function' ? /*#__PURE__*/React.createElement("li", {
|
|
213
|
-
className: b(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["total-text"])))
|
|
214
|
-
}, showTotal(total, [total === 0 ? 0 : (current - 1) * pageSize + 1, current * pageSize > total ? total : current * pageSize])) : null;
|
|
215
|
-
}, [b, current, pageSize, showTotal, total]);
|
|
216
145
|
var prevDisabled = useMemo(function () {
|
|
217
|
-
return !hasPrev || !allPages;
|
|
218
|
-
}, [allPages, hasPrev]);
|
|
146
|
+
return !hasPrev || !allPages || disabled;
|
|
147
|
+
}, [allPages, disabled, hasPrev]);
|
|
219
148
|
var nextDisabled = useMemo(function () {
|
|
220
|
-
return !hasNext || !allPages;
|
|
221
|
-
}, [allPages, hasNext]);
|
|
222
|
-
var pageBufferSize = useMemo(function () {
|
|
223
|
-
return showLessItems ? 1 : 2;
|
|
224
|
-
}, [showLessItems]);
|
|
149
|
+
return !hasNext || !allPages || disabled;
|
|
150
|
+
}, [allPages, disabled, hasNext]);
|
|
225
151
|
var handleChange = useCallback(function (p) {
|
|
226
152
|
var page = p;
|
|
227
153
|
if (isValid(page, current, total) && !disabled) {
|
|
@@ -240,12 +166,12 @@ var Pagination = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
240
166
|
}
|
|
241
167
|
return current;
|
|
242
168
|
}, [current, disabled, onChange, pageSize, setCurrent, total]);
|
|
243
|
-
var
|
|
169
|
+
var handlePrev = useCallback(function () {
|
|
244
170
|
if (hasPrev) {
|
|
245
171
|
handleChange(current - 1);
|
|
246
172
|
}
|
|
247
173
|
}, [current, handleChange, hasPrev]);
|
|
248
|
-
var
|
|
174
|
+
var handleNext = useCallback(function () {
|
|
249
175
|
if (hasNext) {
|
|
250
176
|
handleChange(current + 1);
|
|
251
177
|
}
|
|
@@ -255,12 +181,6 @@ var Pagination = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
255
181
|
handleChange(+inputValue || current);
|
|
256
182
|
}
|
|
257
183
|
}, [current, handleChange, inputValue]);
|
|
258
|
-
var shouldDisplayQuickJumper = useMemo(function () {
|
|
259
|
-
if (total <= pageSize) {
|
|
260
|
-
return false;
|
|
261
|
-
}
|
|
262
|
-
return showQuickJumper;
|
|
263
|
-
}, [pageSize, showQuickJumper, total]);
|
|
264
184
|
|
|
265
185
|
/** 改变每页条数 */
|
|
266
186
|
var changePageSize = useCallback(function (_size) {
|
|
@@ -269,7 +189,7 @@ var Pagination = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
269
189
|
}, total);
|
|
270
190
|
var _current = current > newCurrent ? newCurrent : current;
|
|
271
191
|
// // fix the issue:
|
|
272
|
-
// // Once 'total' is 0, 'current' in '
|
|
192
|
+
// // Once 'total' is 0, 'current' in 'onSizeChange' is 0, which is not correct.
|
|
273
193
|
if (newCurrent === 0) {
|
|
274
194
|
_current = current;
|
|
275
195
|
}
|
|
@@ -282,21 +202,13 @@ var Pagination = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
282
202
|
setInputValue(_current);
|
|
283
203
|
}
|
|
284
204
|
}
|
|
285
|
-
|
|
205
|
+
onSizeChange === null || onSizeChange === void 0 || onSizeChange(_size, _current);
|
|
286
206
|
onChange === null || onChange === void 0 || onChange(_current, _size);
|
|
287
|
-
}, [current, onChange,
|
|
288
|
-
|
|
289
|
-
/** 是否展示 pageSize 切换器,当 total 大于 50 时默认为 true */
|
|
290
|
-
var getShowSizeChanger = useMemo(function () {
|
|
291
|
-
if (typeof showSizeChanger !== 'undefined') {
|
|
292
|
-
return showSizeChanger;
|
|
293
|
-
}
|
|
294
|
-
return total > 50;
|
|
295
|
-
}, [showSizeChanger, total]);
|
|
207
|
+
}, [current, onChange, onSizeChange, pageSize, props, setCurrent, setPageSize, total]);
|
|
296
208
|
|
|
297
209
|
/** 获取输入的跳转页码 */
|
|
298
|
-
var getValidValue = useCallback(function (
|
|
299
|
-
var inputVal =
|
|
210
|
+
var getValidValue = useCallback(function (event) {
|
|
211
|
+
var inputVal = event.target.value;
|
|
300
212
|
var _allPages = calculatePage(undefined, {
|
|
301
213
|
pageSize: pageSize
|
|
302
214
|
}, total);
|
|
@@ -313,26 +225,26 @@ var Pagination = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
313
225
|
}
|
|
314
226
|
return value;
|
|
315
227
|
}, [current, pageSize, total]);
|
|
316
|
-
var handleKeyDown = useCallback(function (
|
|
317
|
-
if (!['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'ArrowLeft', 'ArrowRight', 'Backspace', 'Delete'].includes(
|
|
318
|
-
|
|
228
|
+
var handleKeyDown = useCallback(function (event) {
|
|
229
|
+
if (!['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'ArrowLeft', 'ArrowRight', 'Backspace', 'Delete'].includes(event.key)) {
|
|
230
|
+
event.preventDefault();
|
|
319
231
|
}
|
|
320
232
|
}, []);
|
|
321
|
-
var handleKeyUp = useCallback(function (
|
|
322
|
-
var value = getValidValue(
|
|
233
|
+
var handleKeyUp = useCallback(function (event) {
|
|
234
|
+
var value = getValidValue(event);
|
|
323
235
|
if (value !== inputValue) {
|
|
324
236
|
setInputValue(value === 0 ? 1 : value);
|
|
325
237
|
}
|
|
326
|
-
if (
|
|
238
|
+
if (event.key === 'Enter') {
|
|
327
239
|
handleChange(value);
|
|
328
|
-
} else if (
|
|
240
|
+
} else if (event.key === 'ArrowDown') {
|
|
329
241
|
handleChange(value - 1);
|
|
330
|
-
} else if (
|
|
242
|
+
} else if (event.key === 'ArrowUp') {
|
|
331
243
|
handleChange(value + 1);
|
|
332
244
|
}
|
|
333
245
|
}, [getValidValue, handleChange, inputValue]);
|
|
334
|
-
var handleBlur = useCallback(function (
|
|
335
|
-
var value = getValidValue(
|
|
246
|
+
var handleBlur = useCallback(function (event) {
|
|
247
|
+
var value = getValidValue(event);
|
|
336
248
|
handleChange(value);
|
|
337
249
|
}, [getValidValue, handleChange]);
|
|
338
250
|
useImperativeHandle(ref, function () {
|
|
@@ -344,205 +256,263 @@ var Pagination = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
344
256
|
};
|
|
345
257
|
});
|
|
346
258
|
|
|
259
|
+
/** 上一页按钮 */
|
|
260
|
+
var prevPage = useMemo(function () {
|
|
261
|
+
var comp = null;
|
|
262
|
+
if (isNotEmpty(prevIcon)) {
|
|
263
|
+
if (typeof prevIcon === 'string') {
|
|
264
|
+
comp = /*#__PURE__*/React.createElement(Icon, {
|
|
265
|
+
name: prevIcon,
|
|
266
|
+
prefix: "fal"
|
|
267
|
+
});
|
|
268
|
+
} else if ( /*#__PURE__*/isValidElement(prevIcon)) {
|
|
269
|
+
comp = prevIcon;
|
|
270
|
+
}
|
|
271
|
+
} else if (isNotEmpty(prevText)) {
|
|
272
|
+
comp = prevText;
|
|
273
|
+
}
|
|
274
|
+
return /*#__PURE__*/React.createElement("button", {
|
|
275
|
+
key: "btn-prev",
|
|
276
|
+
onClick: handlePrev,
|
|
277
|
+
className: classNames('btn-prev', b(_templateObject || (_templateObject = _taggedTemplateLiteral(["item"])))),
|
|
278
|
+
"aria-disabled": prevDisabled,
|
|
279
|
+
disabled: prevDisabled
|
|
280
|
+
}, comp);
|
|
281
|
+
}, [b, handlePrev, prevDisabled, prevIcon, prevText]);
|
|
282
|
+
|
|
283
|
+
/** 下一页按钮 */
|
|
284
|
+
var nextPage = useMemo(function () {
|
|
285
|
+
var comp = null;
|
|
286
|
+
if (isNotEmpty(nextIcon)) {
|
|
287
|
+
if (typeof nextIcon === 'string') {
|
|
288
|
+
comp = /*#__PURE__*/React.createElement(Icon, {
|
|
289
|
+
name: nextIcon,
|
|
290
|
+
prefix: "fal"
|
|
291
|
+
});
|
|
292
|
+
} else if ( /*#__PURE__*/isValidElement(nextIcon)) {
|
|
293
|
+
comp = nextIcon;
|
|
294
|
+
}
|
|
295
|
+
} else if (isNotEmpty(nextText)) {
|
|
296
|
+
comp = nextText;
|
|
297
|
+
}
|
|
298
|
+
return /*#__PURE__*/React.createElement("button", {
|
|
299
|
+
key: "btn-next",
|
|
300
|
+
onClick: handleNext,
|
|
301
|
+
className: classNames('btn-next', b(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["item"])))),
|
|
302
|
+
"aria-disabled": nextDisabled,
|
|
303
|
+
disabled: nextDisabled
|
|
304
|
+
}, comp);
|
|
305
|
+
}, [b, handleNext, nextDisabled, nextIcon, nextText]);
|
|
306
|
+
|
|
307
|
+
/** 分页描述 */
|
|
308
|
+
var totalText = useMemo(function () {
|
|
309
|
+
return typeof showTotal === 'function' ? /*#__PURE__*/React.createElement("span", {
|
|
310
|
+
className: classNames(e(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["total"]))), b(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["item"]))))
|
|
311
|
+
}, showTotal(total, [total === 0 ? 0 : (current - 1) * pageSize + 1, current * pageSize > total ? total : current * pageSize])) : /*#__PURE__*/React.createElement("span", {
|
|
312
|
+
className: classNames(e(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["total"]))), b(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["item"]))))
|
|
313
|
+
}, t('el.pagination.total', {
|
|
314
|
+
lng: locale,
|
|
315
|
+
total: total
|
|
316
|
+
}));
|
|
317
|
+
}, [b, current, e, locale, pageSize, showTotal, t, total]);
|
|
318
|
+
|
|
347
319
|
/** 页码 */
|
|
348
320
|
var pagerList = useMemo(function () {
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
if (!allPages) {
|
|
356
|
-
return [/*#__PURE__*/React.createElement(Pager, _extends({}, pagerProps, {
|
|
357
|
-
key: "noPager",
|
|
358
|
-
page: 1,
|
|
359
|
-
className: b(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["item-disabled"])))
|
|
360
|
-
}))];
|
|
321
|
+
var halfPagerCount = (pagerCount - 1) / 2;
|
|
322
|
+
var showPrevMore = false;
|
|
323
|
+
var showNextMore = false;
|
|
324
|
+
if (allPages > pagerCount) {
|
|
325
|
+
if (current > pagerCount - halfPagerCount) {
|
|
326
|
+
showPrevMore = true;
|
|
361
327
|
}
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
}) : jumpNextIcon)));
|
|
410
|
-
var lastPager = /*#__PURE__*/React.createElement(Pager, {
|
|
411
|
-
onClick: handleChange,
|
|
412
|
-
key: allPages,
|
|
413
|
-
page: allPages,
|
|
414
|
-
active: false,
|
|
415
|
-
showTitle: showTitle,
|
|
416
|
-
itemRender: itemRender
|
|
417
|
-
});
|
|
418
|
-
var firstPager = /*#__PURE__*/React.createElement(Pager, {
|
|
328
|
+
if (current < allPages - halfPagerCount) {
|
|
329
|
+
showNextMore = true;
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
var jumpPrev = /*#__PURE__*/React.createElement("li", {
|
|
333
|
+
key: "prev",
|
|
334
|
+
onClick: function onClick() {
|
|
335
|
+
return handleChange(current - (pagerCount - 2));
|
|
336
|
+
},
|
|
337
|
+
tabIndex: 0,
|
|
338
|
+
className: classNames(b(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["jump-prev"]))), b(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["jump-prev-custom-icon"]))), is({
|
|
339
|
+
disabled: disabled
|
|
340
|
+
})),
|
|
341
|
+
onMouseEnter: function onMouseEnter() {
|
|
342
|
+
return setHoverJumpPrev(true);
|
|
343
|
+
},
|
|
344
|
+
onMouseLeave: function onMouseLeave() {
|
|
345
|
+
return setHoverJumpPrev(false);
|
|
346
|
+
}
|
|
347
|
+
}, hoverJumpPrev ? /*#__PURE__*/React.createElement(Icon, {
|
|
348
|
+
name: "angles-left"
|
|
349
|
+
}) : /*#__PURE__*/React.createElement(Icon, {
|
|
350
|
+
name: "ellipsis"
|
|
351
|
+
}));
|
|
352
|
+
var jumpNext = /*#__PURE__*/React.createElement("li", {
|
|
353
|
+
key: "next",
|
|
354
|
+
tabIndex: 0,
|
|
355
|
+
onClick: function onClick() {
|
|
356
|
+
return handleChange(current + pagerCount - 2);
|
|
357
|
+
},
|
|
358
|
+
className: classNames(b(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["jump-next"]))), b(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["jump-next-custom-icon"]))), is({
|
|
359
|
+
disabled: disabled
|
|
360
|
+
})),
|
|
361
|
+
onMouseEnter: function onMouseEnter() {
|
|
362
|
+
return setHoverJumpNext(true);
|
|
363
|
+
},
|
|
364
|
+
onMouseLeave: function onMouseLeave() {
|
|
365
|
+
return setHoverJumpNext(false);
|
|
366
|
+
}
|
|
367
|
+
}, hoverJumpNext ? /*#__PURE__*/React.createElement(Icon, {
|
|
368
|
+
name: "angles-right"
|
|
369
|
+
}) : /*#__PURE__*/React.createElement(Icon, {
|
|
370
|
+
name: "ellipsis"
|
|
371
|
+
}));
|
|
372
|
+
var _pagerList = [];
|
|
373
|
+
if (allPages > 0) {
|
|
374
|
+
_pagerList.push( /*#__PURE__*/React.createElement(Pager, {
|
|
419
375
|
onClick: handleChange,
|
|
420
376
|
key: 1,
|
|
421
377
|
page: 1,
|
|
422
|
-
active:
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
}
|
|
431
|
-
if (allPages - current <= pageBufferSize) {
|
|
432
|
-
left = allPages - pageBufferSize * 2;
|
|
433
|
-
}
|
|
434
|
-
for (var i = left; i <= right; i += 1) {
|
|
378
|
+
active: current === 1,
|
|
379
|
+
disabled: disabled
|
|
380
|
+
}));
|
|
381
|
+
}
|
|
382
|
+
if (showPrevMore && !showNextMore) {
|
|
383
|
+
_pagerList.push(jumpPrev);
|
|
384
|
+
var startPage = allPages - (pagerCount - 2);
|
|
385
|
+
for (var i = startPage; i < allPages; i++) {
|
|
435
386
|
var active = current === i;
|
|
436
387
|
_pagerList.push( /*#__PURE__*/React.createElement(Pager, {
|
|
437
388
|
onClick: handleChange,
|
|
438
389
|
key: i,
|
|
439
390
|
page: i,
|
|
440
391
|
active: active,
|
|
441
|
-
|
|
442
|
-
itemRender: itemRender
|
|
392
|
+
disabled: disabled
|
|
443
393
|
}));
|
|
444
394
|
}
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
});
|
|
455
|
-
showPrevNextJumpers && _pagerList.push(jumpNext);
|
|
395
|
+
} else if (!showPrevMore && showNextMore) {
|
|
396
|
+
for (var _i = 2; _i < pagerCount; _i++) {
|
|
397
|
+
var _active = current === _i;
|
|
398
|
+
_pagerList.push( /*#__PURE__*/React.createElement(Pager, {
|
|
399
|
+
onClick: handleChange,
|
|
400
|
+
key: _i,
|
|
401
|
+
page: _i,
|
|
402
|
+
active: _active,
|
|
403
|
+
disabled: disabled
|
|
404
|
+
}));
|
|
456
405
|
}
|
|
457
|
-
|
|
458
|
-
|
|
406
|
+
_pagerList.push(jumpNext);
|
|
407
|
+
} else if (showPrevMore && showNextMore) {
|
|
408
|
+
_pagerList.push(jumpPrev);
|
|
409
|
+
var offset = Math.floor(pagerCount / 2) - 1;
|
|
410
|
+
for (var _i2 = current - offset; _i2 <= current + offset; _i2++) {
|
|
411
|
+
var _active2 = current === _i2;
|
|
412
|
+
_pagerList.push( /*#__PURE__*/React.createElement(Pager, {
|
|
413
|
+
onClick: handleChange,
|
|
414
|
+
key: _i2,
|
|
415
|
+
page: _i2,
|
|
416
|
+
active: _active2,
|
|
417
|
+
disabled: disabled
|
|
418
|
+
}));
|
|
459
419
|
}
|
|
460
|
-
|
|
461
|
-
|
|
420
|
+
_pagerList.push(jumpNext);
|
|
421
|
+
} else {
|
|
422
|
+
for (var _i3 = 2; _i3 < allPages; _i3++) {
|
|
423
|
+
var _active3 = current === _i3;
|
|
424
|
+
_pagerList.push( /*#__PURE__*/React.createElement(Pager, {
|
|
425
|
+
onClick: handleChange,
|
|
426
|
+
key: _i3,
|
|
427
|
+
page: _i3,
|
|
428
|
+
active: _active3,
|
|
429
|
+
disabled: disabled
|
|
430
|
+
}));
|
|
462
431
|
}
|
|
463
|
-
return _pagerList;
|
|
464
432
|
}
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
}, "\u786E\u5B9A");
|
|
475
|
-
} else if (showQuickJumper !== null && showQuickJumper !== void 0 && showQuickJumper.goButton) {
|
|
476
|
-
return /*#__PURE__*/React.createElement("span", {
|
|
477
|
-
onClick: handleGoTO,
|
|
478
|
-
onKeyUp: handleGoTO
|
|
479
|
-
}, showQuickJumper.goButton);
|
|
480
|
-
}
|
|
481
|
-
return /*#__PURE__*/React.createElement("li", {
|
|
482
|
-
title: showTitle ? "\u8DF3\u81F3".concat(current, "/").concat(allPages) : undefined,
|
|
483
|
-
className: b(_templateObject16 || (_templateObject16 = _taggedTemplateLiteral(["simple-pager"])))
|
|
484
|
-
}, gotoButton);
|
|
433
|
+
if (allPages > 1) {
|
|
434
|
+
var _active4 = current === allPages;
|
|
435
|
+
_pagerList.push( /*#__PURE__*/React.createElement(Pager, {
|
|
436
|
+
onClick: handleChange,
|
|
437
|
+
key: allPages,
|
|
438
|
+
page: allPages,
|
|
439
|
+
active: _active4,
|
|
440
|
+
disabled: disabled
|
|
441
|
+
}));
|
|
485
442
|
}
|
|
486
|
-
}, [allPages, b, current, handleGoTO, showQuickJumper, showTitle, simple]);
|
|
487
|
-
if (hideOnSinglePage === true && total <= pageSize) {
|
|
488
|
-
return null;
|
|
489
|
-
}
|
|
490
|
-
|
|
491
|
-
// 简单分页
|
|
492
|
-
if (simple) {
|
|
493
443
|
return /*#__PURE__*/React.createElement("ul", {
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
className: classNames(b(_templateObject19 || (_templateObject19 = _taggedTemplateLiteral(["prev"]))), _defineProperty({}, b(_templateObject20 || (_templateObject20 = _taggedTemplateLiteral(["disabled"]))), !hasPrev))
|
|
501
|
-
}, prevPage), /*#__PURE__*/React.createElement("li", {
|
|
502
|
-
title: showTitle ? "".concat(current, "/").concat(allPages) : undefined,
|
|
503
|
-
className: b(_templateObject21 || (_templateObject21 = _taggedTemplateLiteral(["simple-pager"])))
|
|
504
|
-
}, /*#__PURE__*/React.createElement("input", {
|
|
505
|
-
type: "text",
|
|
506
|
-
value: inputValue,
|
|
444
|
+
key: "pager",
|
|
445
|
+
className: b('pager', false)
|
|
446
|
+
}, _pagerList);
|
|
447
|
+
}, [pagerCount, allPages, b, is, disabled, hoverJumpPrev, hoverJumpNext, current, handleChange]);
|
|
448
|
+
var sizes = useCallback(function (type) {
|
|
449
|
+
return /*#__PURE__*/React.createElement(Options, {
|
|
507
450
|
disabled: disabled,
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
451
|
+
rootPrefixCls: classPrefix,
|
|
452
|
+
changeSize: changePageSize,
|
|
453
|
+
current: current,
|
|
454
|
+
pageSize: pageSize,
|
|
455
|
+
pageSizeOptions: pageSizes,
|
|
456
|
+
quickGo: handleChange,
|
|
457
|
+
size: size,
|
|
458
|
+
simple: simple,
|
|
459
|
+
type: type
|
|
460
|
+
});
|
|
461
|
+
}, [changePageSize, classPrefix, current, disabled, handleChange, pageSize, pageSizes, simple, size]);
|
|
462
|
+
var content = useMemo(function () {
|
|
463
|
+
var haveRightWrapper = false;
|
|
464
|
+
var rootChildren = [];
|
|
465
|
+
var rightWrapperChildren = [];
|
|
466
|
+
var components = layout.split(',').filter(function (item) {
|
|
467
|
+
return !!item;
|
|
468
|
+
}).map(function (item) {
|
|
469
|
+
switch (item.trim()) {
|
|
470
|
+
case 'prev':
|
|
471
|
+
return prevPage;
|
|
472
|
+
case 'pager':
|
|
473
|
+
return pagerList;
|
|
474
|
+
case 'next':
|
|
475
|
+
return nextPage;
|
|
476
|
+
case 'total':
|
|
477
|
+
return totalText;
|
|
478
|
+
case 'sizes':
|
|
479
|
+
return sizes('sizes');
|
|
480
|
+
case 'jumper':
|
|
481
|
+
return sizes('jumper');
|
|
482
|
+
case '->':
|
|
483
|
+
return '->';
|
|
484
|
+
default:
|
|
485
|
+
return null;
|
|
486
|
+
}
|
|
487
|
+
});
|
|
488
|
+
components.forEach(function (c) {
|
|
489
|
+
if (c === '->') {
|
|
490
|
+
haveRightWrapper = true;
|
|
491
|
+
return;
|
|
492
|
+
}
|
|
493
|
+
if (!haveRightWrapper) {
|
|
494
|
+
rootChildren.push(c);
|
|
495
|
+
} else {
|
|
496
|
+
rightWrapperChildren.push(c);
|
|
497
|
+
}
|
|
498
|
+
});
|
|
499
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, rootChildren, rightWrapperChildren.length > 0 ? /*#__PURE__*/React.createElement("div", {
|
|
500
|
+
className: e(_templateObject11 || (_templateObject11 = _taggedTemplateLiteral(["rightwrapper"])))
|
|
501
|
+
}, rightWrapperChildren) : null);
|
|
502
|
+
}, [e, layout, nextPage, pagerList, prevPage, sizes, totalText]);
|
|
503
|
+
var simplePage = useMemo(function () {
|
|
504
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, prevPage, sizes('jumper'), nextPage);
|
|
505
|
+
}, [nextPage, prevPage, sizes]);
|
|
506
|
+
if (hideOnSinglePage === true && total <= pageSize) {
|
|
507
|
+
return null;
|
|
520
508
|
}
|
|
521
|
-
return /*#__PURE__*/React.createElement("
|
|
522
|
-
className: classNames(b(), className, _defineProperty(
|
|
509
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
510
|
+
className: classNames(b(), className, _defineProperty({}, b(_templateObject12 || (_templateObject12 = _taggedTemplateLiteral(["disabled"]))), disabled || total === 0), is({
|
|
511
|
+
background: background
|
|
512
|
+
}), m(size)),
|
|
523
513
|
style: style,
|
|
524
514
|
ref: containerRef
|
|
525
|
-
},
|
|
526
|
-
title: showTitle ? '上一页' : undefined,
|
|
527
|
-
onClick: prev,
|
|
528
|
-
className: classNames(b(_templateObject26 || (_templateObject26 = _taggedTemplateLiteral(["prev"]))), _defineProperty({}, b(_templateObject27 || (_templateObject27 = _taggedTemplateLiteral(["disabled"]))), prevDisabled)),
|
|
529
|
-
"aria-disabled": prevDisabled
|
|
530
|
-
}, prevPage), pagerList, /*#__PURE__*/React.createElement("li", {
|
|
531
|
-
title: showTitle ? '下一页' : undefined,
|
|
532
|
-
onClick: next,
|
|
533
|
-
className: classNames(b(_templateObject28 || (_templateObject28 = _taggedTemplateLiteral(["next"]))), _defineProperty({}, b(_templateObject29 || (_templateObject29 = _taggedTemplateLiteral(["disabled"]))), nextDisabled)),
|
|
534
|
-
"aria-disabled": nextDisabled
|
|
535
|
-
}, nextPage), /*#__PURE__*/React.createElement(Options, {
|
|
536
|
-
disabled: disabled,
|
|
537
|
-
rootPrefixCls: classPrefix,
|
|
538
|
-
changeSize: getShowSizeChanger ? changePageSize : null,
|
|
539
|
-
current: current,
|
|
540
|
-
pageSize: pageSize,
|
|
541
|
-
pageSizeOptions: pageSizeOptions,
|
|
542
|
-
quickGo: shouldDisplayQuickJumper ? handleChange : undefined,
|
|
543
|
-
goButton: (_ref = typeof showQuickJumper !== 'boolean' && (showQuickJumper === null || showQuickJumper === void 0 ? void 0 : showQuickJumper.goButton)) !== null && _ref !== void 0 ? _ref : false,
|
|
544
|
-
mini: size === 'small'
|
|
545
|
-
}));
|
|
515
|
+
}, simple ? simplePage : content);
|
|
546
516
|
});
|
|
547
|
-
Pagination.displayName = '
|
|
517
|
+
Pagination.displayName = 'ElPagination';
|
|
548
518
|
export default Pagination;
|