@zendeskgarden/react-pagination 9.0.0-next.7 → 9.0.0-next.8
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/esm/elements/CursorPagination/CursorPagination.js +32 -0
- package/dist/esm/elements/CursorPagination/components/First.js +33 -0
- package/dist/esm/elements/CursorPagination/components/Last.js +34 -0
- package/dist/esm/elements/CursorPagination/components/Next.js +34 -0
- package/dist/esm/elements/CursorPagination/components/Previous.js +34 -0
- package/dist/esm/elements/OffsetPagination/OffsetPagination.js +163 -0
- package/dist/esm/elements/OffsetPagination/components/Gap.js +29 -0
- package/dist/esm/elements/OffsetPagination/components/Next.js +35 -0
- package/dist/esm/elements/OffsetPagination/components/Page.js +31 -0
- package/dist/esm/elements/OffsetPagination/components/Previous.js +35 -0
- package/dist/esm/index.js +8 -0
- package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/16/chevron-double-left-stroke.svg.js +25 -0
- package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/16/chevron-double-right-stroke.svg.js +25 -0
- package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/16/chevron-left-stroke.svg.js +25 -0
- package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/16/chevron-right-stroke.svg.js +25 -0
- package/dist/esm/styled/CursorPagination/StyledCursor.js +24 -0
- package/dist/esm/styled/CursorPagination/StyledCursorPagination.js +22 -0
- package/dist/esm/styled/CursorPagination/StyledIcon.js +36 -0
- package/dist/esm/styled/OffsetPagination/StyledGapListItem.js +32 -0
- package/dist/esm/styled/OffsetPagination/StyledList.js +22 -0
- package/dist/esm/styled/OffsetPagination/StyledListItem.js +22 -0
- package/dist/esm/styled/OffsetPagination/StyledNav.js +22 -0
- package/dist/esm/styled/OffsetPagination/StyledNavigation.js +23 -0
- package/dist/esm/styled/OffsetPagination/StyledPage.js +27 -0
- package/dist/esm/styled/OffsetPagination/StyledPageBase.js +44 -0
- package/dist/index.cjs.js +24 -40
- package/package.json +5 -5
- package/dist/index.esm.js +0 -518
package/dist/index.esm.js
DELETED
|
@@ -1,518 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright Zendesk, Inc.
|
|
3
|
-
*
|
|
4
|
-
* Use of this source code is governed under the Apache License, Version 2.0
|
|
5
|
-
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import * as React from 'react';
|
|
9
|
-
import React__default, { cloneElement, Children, forwardRef, useContext, useState, useCallback } from 'react';
|
|
10
|
-
import PropTypes from 'prop-types';
|
|
11
|
-
import { getControlledValue } from '@zendeskgarden/container-utilities';
|
|
12
|
-
import { getColorV8, retrieveComponentStyles, DEFAULT_THEME, focusStyles, getLineHeight, useText } from '@zendeskgarden/react-theming';
|
|
13
|
-
import styled, { css, ThemeContext } from 'styled-components';
|
|
14
|
-
import { math } from 'polished';
|
|
15
|
-
|
|
16
|
-
function _extends$4() {
|
|
17
|
-
_extends$4 = Object.assign ? Object.assign.bind() : function (target) {
|
|
18
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
19
|
-
var source = arguments[i];
|
|
20
|
-
for (var key in source) {
|
|
21
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
22
|
-
target[key] = source[key];
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
return target;
|
|
27
|
-
};
|
|
28
|
-
return _extends$4.apply(this, arguments);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const COMPONENT_ID$8 = 'pagination.list';
|
|
32
|
-
const StyledList = styled.ul.attrs({
|
|
33
|
-
'data-garden-id': COMPONENT_ID$8,
|
|
34
|
-
'data-garden-version': '9.0.0-next.7'
|
|
35
|
-
}).withConfig({
|
|
36
|
-
displayName: "StyledList",
|
|
37
|
-
componentId: "sc-1uz2jxo-0"
|
|
38
|
-
})(["direction:", ";display:flex;justify-content:center;margin:0;padding:0;list-style:none;white-space:nowrap;color:", ";:focus{outline:none;}", ";"], props => props.theme.rtl && 'rtl', props => getColorV8('neutralHue', 600, props.theme), props => retrieveComponentStyles(COMPONENT_ID$8, props));
|
|
39
|
-
StyledList.defaultProps = {
|
|
40
|
-
theme: DEFAULT_THEME
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
const COMPONENT_ID$7 = 'pagination.list_item';
|
|
44
|
-
const StyledListItem = styled.li.attrs({
|
|
45
|
-
'data-garden-id': COMPONENT_ID$7,
|
|
46
|
-
'data-garden-version': '9.0.0-next.7'
|
|
47
|
-
}).withConfig({
|
|
48
|
-
displayName: "StyledListItem",
|
|
49
|
-
componentId: "sc-16j4sju-0"
|
|
50
|
-
})(["box-sizing:border-box;margin-left:", ";user-select:none;&", "{margin-left:0;}", ";"], props => `${props.theme.space.base}px`, props => props.theme.rtl ? ':last-of-type' : ':first-of-type', props => retrieveComponentStyles(COMPONENT_ID$7, props));
|
|
51
|
-
StyledListItem.defaultProps = {
|
|
52
|
-
theme: DEFAULT_THEME
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
const COMPONENT_ID$6 = 'pagination.page';
|
|
56
|
-
const colorStyles = props => {
|
|
57
|
-
const defaultColor = getColorV8('neutralHue', 600, props.theme);
|
|
58
|
-
const hoverForegroundColor = getColorV8('neutralHue', 700, props.theme);
|
|
59
|
-
const hoverBackgroundColor = getColorV8('primaryHue', 600, props.theme, 0.08);
|
|
60
|
-
const activeForegroundColor = getColorV8('neutralHue', 800, props.theme);
|
|
61
|
-
const activeBackgroundColor = getColorV8('primaryHue', 600, props.theme, 0.2);
|
|
62
|
-
const currentForegroundColor = activeForegroundColor;
|
|
63
|
-
const currentBackgroundColor = hoverBackgroundColor;
|
|
64
|
-
const currentHoverBackgroundColor = getColorV8('primaryHue', 600, props.theme, 0.16);
|
|
65
|
-
const currentActiveBackgroundColor = getColorV8('primaryHue', 600, props.theme, 0.28);
|
|
66
|
-
return css(["border:none;background:transparent;color:", ";&:hover{background-color:", ";color:", ";}", " &:active,&:focus-visible:active{background-color:", ";color:", ";}&[aria-current='page']{background-color:", ";color:", ";}&[aria-current='page']:hover{background-color:", ";}&[aria-current='page']:active{background-color:", ";}:disabled,[aria-disabled='true']{background-color:transparent;color:", ";}"], defaultColor, hoverBackgroundColor, hoverForegroundColor, focusStyles({
|
|
67
|
-
theme: props.theme,
|
|
68
|
-
inset: true
|
|
69
|
-
}), activeBackgroundColor, activeForegroundColor, currentBackgroundColor, currentForegroundColor, currentHoverBackgroundColor, currentActiveBackgroundColor, getColorV8('grey', 300, props.theme));
|
|
70
|
-
};
|
|
71
|
-
const sizeStyles$2 = props => {
|
|
72
|
-
const fontSize = props.theme.fontSizes.md;
|
|
73
|
-
const height = `${props.theme.space.base * 8}px`;
|
|
74
|
-
const lineHeight = getLineHeight(height, fontSize);
|
|
75
|
-
const padding = `${props.theme.space.base * 1.5}px`;
|
|
76
|
-
return css(["padding:0 ", ";height:", ";line-height:", ";font-size:", ";"], padding, height, lineHeight, fontSize);
|
|
77
|
-
};
|
|
78
|
-
const StyledPageBase = styled.button.attrs({
|
|
79
|
-
'data-garden-id': COMPONENT_ID$6,
|
|
80
|
-
'data-garden-version': '9.0.0-next.7'
|
|
81
|
-
}).withConfig({
|
|
82
|
-
displayName: "StyledPageBase",
|
|
83
|
-
componentId: "sc-ttwj4u-0"
|
|
84
|
-
})(["box-sizing:border-box;display:inline-block;transition:box-shadow 0.1s ease-in-out,background-color 0.25s ease-in-out,color 0.25s ease-in-out;visibility:", ";border-radius:", ";cursor:pointer;overflow:hidden;text-align:center;text-overflow:ellipsis;font-family:inherit;user-select:none;", ";&[aria-current='page']{font-weight:", ";}&::-moz-focus-inner{border:0;}:disabled,[aria-disabled='true']{cursor:default;}", ";", ";"], props => props.hidden && 'hidden', props => props.theme.borderRadii.md, props => sizeStyles$2(props), props => props.theme.fontWeights.semibold, props => colorStyles(props), props => retrieveComponentStyles(COMPONENT_ID$6, props));
|
|
85
|
-
StyledPageBase.defaultProps = {
|
|
86
|
-
theme: DEFAULT_THEME
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
const COMPONENT_ID$5 = 'pagination.page';
|
|
90
|
-
const sizeStyles$1 = props => {
|
|
91
|
-
const height = props.theme.space.base * 8;
|
|
92
|
-
return css(["min-width:", "px;max-width:", "px;&[aria-current='true']{max-width:none;}"], height, height * 2);
|
|
93
|
-
};
|
|
94
|
-
const StyledPage = styled(StyledPageBase).attrs({
|
|
95
|
-
'data-garden-id': COMPONENT_ID$5,
|
|
96
|
-
'data-garden-version': '9.0.0-next.7'
|
|
97
|
-
}).withConfig({
|
|
98
|
-
displayName: "StyledPage",
|
|
99
|
-
componentId: "sc-sxjfwy-0"
|
|
100
|
-
})(["", ";&[aria-current=\"true\"]{font-weight:", ";}", ";"], props => sizeStyles$1(props), props => props.theme.fontWeights.semibold, props => retrieveComponentStyles(COMPONENT_ID$5, props));
|
|
101
|
-
StyledPage.defaultProps = {
|
|
102
|
-
theme: DEFAULT_THEME
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
const COMPONENT_ID$4 = 'cursor_pagination';
|
|
106
|
-
const StyledCursorPagination = styled.nav.attrs({
|
|
107
|
-
'data-garden-id': COMPONENT_ID$4,
|
|
108
|
-
'data-garden-version': '9.0.0-next.7'
|
|
109
|
-
}).withConfig({
|
|
110
|
-
displayName: "StyledCursorPagination",
|
|
111
|
-
componentId: "sc-qmfecg-0"
|
|
112
|
-
})(["display:flex;justify-content:center;", ";"], props => retrieveComponentStyles(COMPONENT_ID$4, props));
|
|
113
|
-
StyledCursorPagination.defaultProps = {
|
|
114
|
-
theme: DEFAULT_THEME
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
const COMPONENT_ID$3 = 'cursor_pagination.cursor';
|
|
118
|
-
const StyledCursor = styled(StyledPageBase).attrs({
|
|
119
|
-
'data-garden-id': COMPONENT_ID$3,
|
|
120
|
-
'data-garden-version': '9.0.0-next.7',
|
|
121
|
-
as: 'button'
|
|
122
|
-
}).withConfig({
|
|
123
|
-
displayName: "StyledCursor",
|
|
124
|
-
componentId: "sc-507ee-0"
|
|
125
|
-
})(["display:flex;align-items:center;border:none;background:transparent;padding:", ";overflow:visible;&:not(", "-of-type){margin-right:", "px;}", ";"], props => `0px ${props.theme.space.base * 2}px`, props => props.theme.rtl ? ':first' : ':last', props => props.theme.space.base, props => retrieveComponentStyles(COMPONENT_ID$3, props));
|
|
126
|
-
StyledCursor.defaultProps = {
|
|
127
|
-
theme: DEFAULT_THEME
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
const marginStyles = props => {
|
|
131
|
-
const {
|
|
132
|
-
type,
|
|
133
|
-
theme
|
|
134
|
-
} = props;
|
|
135
|
-
const margin = theme.space.base;
|
|
136
|
-
if (theme.rtl) {
|
|
137
|
-
return css(["margin-", ":", "px;"], type === 'last' || type === 'next' ? 'right' : 'left', margin);
|
|
138
|
-
}
|
|
139
|
-
return css(["margin-", ":", "px;"], type === 'first' || type === 'previous' ? 'right' : 'left', margin);
|
|
140
|
-
};
|
|
141
|
-
const StyledIcon = styled(_ref => {
|
|
142
|
-
let {
|
|
143
|
-
children,
|
|
144
|
-
...props
|
|
145
|
-
} = _ref;
|
|
146
|
-
return cloneElement(Children.only(children), props);
|
|
147
|
-
}).withConfig({
|
|
148
|
-
displayName: "StyledIcon",
|
|
149
|
-
componentId: "sc-2vzk6e-0"
|
|
150
|
-
})(["", " transform:", ";"], marginStyles, props => props.theme.rtl && 'rotate(180deg)');
|
|
151
|
-
StyledIcon.defaultProps = {
|
|
152
|
-
theme: DEFAULT_THEME
|
|
153
|
-
};
|
|
154
|
-
|
|
155
|
-
const COMPONENT_ID$2 = 'pagination.gap';
|
|
156
|
-
const sizeStyles = props => {
|
|
157
|
-
const shift = 2;
|
|
158
|
-
const fontSize = math(`${props.theme.fontSizes.md} + ${shift}`);
|
|
159
|
-
const height = `${props.theme.space.base * 8}px`;
|
|
160
|
-
const lineHeight = getLineHeight(height, fontSize);
|
|
161
|
-
const padding = `${props.theme.space.base * 1.5}px`;
|
|
162
|
-
return css(["padding:0 ", ";min-width:", ";max-width:", ";height:", ";line-height:", ";font-size:", ";"], padding, height, math(`${height} * 2`), height, lineHeight, fontSize);
|
|
163
|
-
};
|
|
164
|
-
const StyledGapListItem = styled(StyledListItem).attrs({
|
|
165
|
-
'data-garden-id': COMPONENT_ID$2,
|
|
166
|
-
'data-garden-version': '9.0.0-next.7'
|
|
167
|
-
}).withConfig({
|
|
168
|
-
displayName: "StyledGapListItem",
|
|
169
|
-
componentId: "sc-10wd0iz-0"
|
|
170
|
-
})(["display:inline-block;text-align:center;color:", ";", ";&:hover{color:inherit;}", ";"], p => getColorV8('neutralHue', 600, p.theme), props => sizeStyles(props), props => retrieveComponentStyles(COMPONENT_ID$2, props));
|
|
171
|
-
StyledGapListItem.defaultProps = {
|
|
172
|
-
theme: DEFAULT_THEME
|
|
173
|
-
};
|
|
174
|
-
|
|
175
|
-
const COMPONENT_ID$1 = 'pagination.navigation';
|
|
176
|
-
const StyledNavigation = styled(StyledPage).attrs({
|
|
177
|
-
'data-garden-id': COMPONENT_ID$1,
|
|
178
|
-
'data-garden-version': '9.0.0-next.7'
|
|
179
|
-
}).withConfig({
|
|
180
|
-
displayName: "StyledNavigation",
|
|
181
|
-
componentId: "sc-1lpl8pp-0"
|
|
182
|
-
})(["display:flex;align-items:center;justify-content:center;", ";"], props => retrieveComponentStyles(COMPONENT_ID$1, props));
|
|
183
|
-
StyledNavigation.defaultProps = {
|
|
184
|
-
theme: DEFAULT_THEME
|
|
185
|
-
};
|
|
186
|
-
|
|
187
|
-
const COMPONENT_ID = 'pagination.pagination_view';
|
|
188
|
-
const StyledNav = styled.nav.attrs({
|
|
189
|
-
'data-garden-id': COMPONENT_ID,
|
|
190
|
-
'data-garden-version': '9.0.0-next.7'
|
|
191
|
-
}).withConfig({
|
|
192
|
-
displayName: "StyledNav",
|
|
193
|
-
componentId: "sc-ppnpkw-0"
|
|
194
|
-
})(["", ";"], props => retrieveComponentStyles(COMPONENT_ID, props));
|
|
195
|
-
StyledNav.defaultProps = {
|
|
196
|
-
theme: DEFAULT_THEME
|
|
197
|
-
};
|
|
198
|
-
|
|
199
|
-
var _path$3;
|
|
200
|
-
function _extends$3() { _extends$3 = 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$3.apply(this, arguments); }
|
|
201
|
-
var SvgChevronLeftStroke = function SvgChevronLeftStroke(props) {
|
|
202
|
-
return /*#__PURE__*/React.createElement("svg", _extends$3({
|
|
203
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
204
|
-
width: 16,
|
|
205
|
-
height: 16,
|
|
206
|
-
focusable: "false",
|
|
207
|
-
viewBox: "0 0 16 16",
|
|
208
|
-
"aria-hidden": "true"
|
|
209
|
-
}, props), _path$3 || (_path$3 = /*#__PURE__*/React.createElement("path", {
|
|
210
|
-
fill: "currentColor",
|
|
211
|
-
d: "M10.39 12.688a.5.5 0 01-.718.69l-.062-.066-4-5a.5.5 0 01-.054-.542l.054-.082 4-5a.5.5 0 01.83.55l-.05.074L6.641 8l3.75 4.688z"
|
|
212
|
-
})));
|
|
213
|
-
};
|
|
214
|
-
|
|
215
|
-
var _path$2;
|
|
216
|
-
function _extends$2() { _extends$2 = 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$2.apply(this, arguments); }
|
|
217
|
-
var SvgChevronRightStroke = function SvgChevronRightStroke(props) {
|
|
218
|
-
return /*#__PURE__*/React.createElement("svg", _extends$2({
|
|
219
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
220
|
-
width: 16,
|
|
221
|
-
height: 16,
|
|
222
|
-
focusable: "false",
|
|
223
|
-
viewBox: "0 0 16 16",
|
|
224
|
-
"aria-hidden": "true"
|
|
225
|
-
}, props), _path$2 || (_path$2 = /*#__PURE__*/React.createElement("path", {
|
|
226
|
-
fill: "currentColor",
|
|
227
|
-
d: "M5.61 3.312a.5.5 0 01.718-.69l.062.066 4 5a.5.5 0 01.054.542l-.054.082-4 5a.5.5 0 01-.83-.55l.05-.074L9.359 8l-3.75-4.688z"
|
|
228
|
-
})));
|
|
229
|
-
};
|
|
230
|
-
|
|
231
|
-
const PreviousComponent$1 = forwardRef((props, ref) => {
|
|
232
|
-
const ariaLabel = useText(PreviousComponent$1, props, 'aria-label', 'Previous page');
|
|
233
|
-
const theme = useContext(ThemeContext);
|
|
234
|
-
return React__default.createElement(StyledNavigation, _extends$4({
|
|
235
|
-
type: "button"
|
|
236
|
-
}, props, {
|
|
237
|
-
"aria-label": ariaLabel,
|
|
238
|
-
ref: ref
|
|
239
|
-
}), theme.rtl ? React__default.createElement(SvgChevronRightStroke, null) : React__default.createElement(SvgChevronLeftStroke, null));
|
|
240
|
-
});
|
|
241
|
-
PreviousComponent$1.displayName = 'Pagination.Previous';
|
|
242
|
-
const Previous$1 = PreviousComponent$1;
|
|
243
|
-
|
|
244
|
-
const NextComponent$1 = forwardRef((props, ref) => {
|
|
245
|
-
const ariaLabel = useText(NextComponent$1, props, 'aria-label', 'Next page');
|
|
246
|
-
const theme = useContext(ThemeContext);
|
|
247
|
-
return React__default.createElement(StyledNavigation, _extends$4({
|
|
248
|
-
type: "button"
|
|
249
|
-
}, props, {
|
|
250
|
-
"aria-label": ariaLabel,
|
|
251
|
-
ref: ref
|
|
252
|
-
}), theme.rtl ? React__default.createElement(SvgChevronLeftStroke, null) : React__default.createElement(SvgChevronRightStroke, null));
|
|
253
|
-
});
|
|
254
|
-
NextComponent$1.displayName = 'Pagination.Next';
|
|
255
|
-
const Next$1 = NextComponent$1;
|
|
256
|
-
|
|
257
|
-
const PageComponent = forwardRef((props, ref) => {
|
|
258
|
-
const ariaLabel = useText(PageComponent, props, 'aria-label', `Page ${props.children}`);
|
|
259
|
-
return React__default.createElement(StyledPage, _extends$4({
|
|
260
|
-
type: "button"
|
|
261
|
-
}, props, {
|
|
262
|
-
"aria-label": ariaLabel,
|
|
263
|
-
ref: ref
|
|
264
|
-
}));
|
|
265
|
-
});
|
|
266
|
-
PageComponent.displayName = 'Pagination.Page';
|
|
267
|
-
const Page = PageComponent;
|
|
268
|
-
|
|
269
|
-
const GapComponent = forwardRef((props, ref) => {
|
|
270
|
-
const ariaLabel = useText(GapComponent, props, 'aria-label', 'Ellipsis indicating non-visible pages');
|
|
271
|
-
return React__default.createElement(StyledGapListItem, _extends$4({}, props, {
|
|
272
|
-
"aria-label": ariaLabel,
|
|
273
|
-
ref: ref
|
|
274
|
-
}), "\u2026");
|
|
275
|
-
});
|
|
276
|
-
GapComponent.displayName = 'Pagination.Gap';
|
|
277
|
-
const Gap = GapComponent;
|
|
278
|
-
|
|
279
|
-
const PREVIOUS_KEY = 'previous';
|
|
280
|
-
const NEXT_KEY = 'next';
|
|
281
|
-
const OffsetPagination = forwardRef((_ref, ref) => {
|
|
282
|
-
let {
|
|
283
|
-
currentPage: controlledCurrentPage,
|
|
284
|
-
totalPages,
|
|
285
|
-
pagePadding,
|
|
286
|
-
pageGap,
|
|
287
|
-
onChange,
|
|
288
|
-
'aria-label': ariaLabel,
|
|
289
|
-
labels,
|
|
290
|
-
...otherProps
|
|
291
|
-
} = _ref;
|
|
292
|
-
const [focusedItem, setFocusedItem] = useState();
|
|
293
|
-
const [internalCurrentPage, setInternalCurrentPage] = useState(1);
|
|
294
|
-
const navigationLabel = useText(OffsetPagination, {
|
|
295
|
-
'aria-label': ariaLabel
|
|
296
|
-
}, 'aria-label', 'Pagination');
|
|
297
|
-
const currentPage = getControlledValue(controlledCurrentPage, internalCurrentPage);
|
|
298
|
-
const handleFocus = useCallback(item => {
|
|
299
|
-
setFocusedItem(item);
|
|
300
|
-
}, []);
|
|
301
|
-
const handleSelect = useCallback(item => {
|
|
302
|
-
let updatedCurrentPage = item;
|
|
303
|
-
let updatedFocusedKey = focusedItem;
|
|
304
|
-
if (updatedCurrentPage === PREVIOUS_KEY && currentPage > 1) {
|
|
305
|
-
updatedCurrentPage = currentPage - 1;
|
|
306
|
-
if (updatedCurrentPage === 1 && focusedItem === PREVIOUS_KEY) {
|
|
307
|
-
updatedFocusedKey = 1;
|
|
308
|
-
}
|
|
309
|
-
} else if (updatedCurrentPage === NEXT_KEY && currentPage < totalPages) {
|
|
310
|
-
updatedCurrentPage = currentPage + 1;
|
|
311
|
-
if (updatedCurrentPage === totalPages && updatedFocusedKey === NEXT_KEY) {
|
|
312
|
-
updatedFocusedKey = totalPages;
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
if (onChange && updatedCurrentPage !== undefined) {
|
|
316
|
-
onChange(updatedCurrentPage);
|
|
317
|
-
}
|
|
318
|
-
setFocusedItem(updatedFocusedKey);
|
|
319
|
-
setInternalCurrentPage(updatedCurrentPage);
|
|
320
|
-
}, [currentPage, focusedItem, onChange, totalPages]);
|
|
321
|
-
const renderPreviousPage = () => {
|
|
322
|
-
const isFirstPageSelected = totalPages > 0 && currentPage === 1;
|
|
323
|
-
return React__default.createElement(StyledListItem, null, React__default.createElement(Previous$1, {
|
|
324
|
-
hidden: isFirstPageSelected,
|
|
325
|
-
onFocus: () => handleFocus('previous'),
|
|
326
|
-
onClick: () => handleSelect('previous'),
|
|
327
|
-
"aria-label": labels?.previous
|
|
328
|
-
}));
|
|
329
|
-
};
|
|
330
|
-
const renderNextPage = () => {
|
|
331
|
-
const isLastPageSelected = currentPage === totalPages;
|
|
332
|
-
return React__default.createElement(StyledListItem, null, React__default.createElement(Next$1, {
|
|
333
|
-
hidden: isLastPageSelected,
|
|
334
|
-
onFocus: () => handleFocus('next'),
|
|
335
|
-
onClick: () => handleSelect('next'),
|
|
336
|
-
"aria-label": labels?.next
|
|
337
|
-
}));
|
|
338
|
-
};
|
|
339
|
-
const createGap = pageIndex => React__default.createElement(Gap, {
|
|
340
|
-
key: `gap-${pageIndex}`,
|
|
341
|
-
"aria-label": labels?.gap
|
|
342
|
-
});
|
|
343
|
-
const createPage = pageIndex => {
|
|
344
|
-
return React__default.createElement(StyledListItem, {
|
|
345
|
-
key: pageIndex
|
|
346
|
-
}, React__default.createElement(Page, {
|
|
347
|
-
onFocus: () => handleFocus(pageIndex),
|
|
348
|
-
onClick: () => handleSelect(pageIndex),
|
|
349
|
-
"aria-current": currentPage === pageIndex ? 'page' : undefined,
|
|
350
|
-
"aria-label": labels?.renderPage?.(pageIndex)
|
|
351
|
-
}, pageIndex));
|
|
352
|
-
};
|
|
353
|
-
const renderPages = () => {
|
|
354
|
-
const pages = [];
|
|
355
|
-
const PADDING = pagePadding;
|
|
356
|
-
const GAP = pageGap;
|
|
357
|
-
for (let pageIndex = 1; pageIndex <= totalPages; pageIndex++) {
|
|
358
|
-
if (pageIndex === currentPage || pageIndex < GAP || pageIndex > totalPages - GAP + 1) {
|
|
359
|
-
pages.push(createPage(pageIndex));
|
|
360
|
-
continue;
|
|
361
|
-
}
|
|
362
|
-
let minimum;
|
|
363
|
-
let maximum;
|
|
364
|
-
if (currentPage <= GAP + PADDING) {
|
|
365
|
-
minimum = GAP + 1;
|
|
366
|
-
maximum = minimum + PADDING * 2;
|
|
367
|
-
} else if (currentPage >= totalPages - GAP - PADDING) {
|
|
368
|
-
maximum = totalPages - GAP;
|
|
369
|
-
minimum = maximum - PADDING * 2;
|
|
370
|
-
} else {
|
|
371
|
-
minimum = currentPage - PADDING;
|
|
372
|
-
maximum = currentPage + PADDING;
|
|
373
|
-
}
|
|
374
|
-
if (pageIndex >= minimum && pageIndex <= currentPage || pageIndex >= currentPage && pageIndex <= maximum) {
|
|
375
|
-
pages.push(createPage(pageIndex));
|
|
376
|
-
continue;
|
|
377
|
-
}
|
|
378
|
-
if (pageIndex === GAP) {
|
|
379
|
-
if (minimum > GAP + 1 && currentPage > GAP + PADDING + 1) {
|
|
380
|
-
pages.push(createGap(pageIndex));
|
|
381
|
-
} else {
|
|
382
|
-
pages.push(createPage(pageIndex));
|
|
383
|
-
}
|
|
384
|
-
continue;
|
|
385
|
-
}
|
|
386
|
-
if (pageIndex === totalPages - GAP + 1) {
|
|
387
|
-
if (maximum < totalPages - GAP && currentPage < totalPages - GAP - PADDING) {
|
|
388
|
-
pages.push(createGap(pageIndex));
|
|
389
|
-
} else {
|
|
390
|
-
pages.push(createPage(pageIndex));
|
|
391
|
-
}
|
|
392
|
-
continue;
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
return pages;
|
|
396
|
-
};
|
|
397
|
-
return React__default.createElement(StyledNav, {
|
|
398
|
-
"aria-label": navigationLabel
|
|
399
|
-
}, React__default.createElement(StyledList, _extends$4({}, otherProps, {
|
|
400
|
-
ref: ref
|
|
401
|
-
}), renderPreviousPage(), totalPages > 0 && renderPages(), renderNextPage()));
|
|
402
|
-
});
|
|
403
|
-
OffsetPagination.propTypes = {
|
|
404
|
-
currentPage: PropTypes.number.isRequired,
|
|
405
|
-
totalPages: PropTypes.number.isRequired,
|
|
406
|
-
pagePadding: PropTypes.number,
|
|
407
|
-
pageGap: PropTypes.number,
|
|
408
|
-
onChange: PropTypes.func,
|
|
409
|
-
labels: PropTypes.any
|
|
410
|
-
};
|
|
411
|
-
OffsetPagination.defaultProps = {
|
|
412
|
-
pagePadding: 2,
|
|
413
|
-
pageGap: 2
|
|
414
|
-
};
|
|
415
|
-
OffsetPagination.displayName = 'OffsetPagination';
|
|
416
|
-
|
|
417
|
-
var _path$1;
|
|
418
|
-
function _extends$1() { _extends$1 = 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$1.apply(this, arguments); }
|
|
419
|
-
var SvgChevronDoubleLeftStroke = function SvgChevronDoubleLeftStroke(props) {
|
|
420
|
-
return /*#__PURE__*/React.createElement("svg", _extends$1({
|
|
421
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
422
|
-
width: 16,
|
|
423
|
-
height: 16,
|
|
424
|
-
focusable: "false",
|
|
425
|
-
viewBox: "0 0 16 16",
|
|
426
|
-
"aria-hidden": "true"
|
|
427
|
-
}, props), _path$1 || (_path$1 = /*#__PURE__*/React.createElement("path", {
|
|
428
|
-
fill: "currentColor",
|
|
429
|
-
d: "M7.812 13.39a.5.5 0 01-.64-.012l-.062-.066-4-5a.5.5 0 01-.054-.542l.054-.082 4-5a.5.5 0 01.83.55l-.05.074L4.141 8l3.75 4.688a.5.5 0 01-.079.702zm5 0a.5.5 0 01-.64-.012l-.062-.066-4-5a.5.5 0 01-.054-.542l.054-.082 4-5a.5.5 0 01.83.55l-.05.074L9.141 8l3.75 4.688a.5.5 0 01-.079.702z"
|
|
430
|
-
})));
|
|
431
|
-
};
|
|
432
|
-
|
|
433
|
-
const FirstComponent = forwardRef((_ref, ref) => {
|
|
434
|
-
let {
|
|
435
|
-
children,
|
|
436
|
-
...other
|
|
437
|
-
} = _ref;
|
|
438
|
-
return React__default.createElement(StyledCursor, _extends$4({
|
|
439
|
-
ref: ref
|
|
440
|
-
}, other), React__default.createElement(StyledIcon, {
|
|
441
|
-
type: "first"
|
|
442
|
-
}, React__default.createElement(SvgChevronDoubleLeftStroke, null)), React__default.createElement("span", null, children));
|
|
443
|
-
});
|
|
444
|
-
FirstComponent.displayName = 'CursorPagination.First';
|
|
445
|
-
const First = FirstComponent;
|
|
446
|
-
|
|
447
|
-
const NextComponent = forwardRef((_ref, ref) => {
|
|
448
|
-
let {
|
|
449
|
-
children,
|
|
450
|
-
...other
|
|
451
|
-
} = _ref;
|
|
452
|
-
return React__default.createElement(StyledCursor, _extends$4({
|
|
453
|
-
ref: ref,
|
|
454
|
-
as: "button"
|
|
455
|
-
}, other), React__default.createElement("span", null, children), React__default.createElement(StyledIcon, {
|
|
456
|
-
type: "next"
|
|
457
|
-
}, React__default.createElement(SvgChevronRightStroke, null)));
|
|
458
|
-
});
|
|
459
|
-
NextComponent.displayName = 'CursorPagination.Next';
|
|
460
|
-
const Next = NextComponent;
|
|
461
|
-
|
|
462
|
-
const PreviousComponent = forwardRef((_ref, ref) => {
|
|
463
|
-
let {
|
|
464
|
-
children,
|
|
465
|
-
...other
|
|
466
|
-
} = _ref;
|
|
467
|
-
return React__default.createElement(StyledCursor, _extends$4({
|
|
468
|
-
ref: ref,
|
|
469
|
-
as: "button"
|
|
470
|
-
}, other), React__default.createElement(StyledIcon, {
|
|
471
|
-
type: "previous"
|
|
472
|
-
}, React__default.createElement(SvgChevronLeftStroke, null)), React__default.createElement("span", null, children));
|
|
473
|
-
});
|
|
474
|
-
PreviousComponent.displayName = 'CursorPagination.Previous';
|
|
475
|
-
const Previous = PreviousComponent;
|
|
476
|
-
|
|
477
|
-
var _path;
|
|
478
|
-
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); }
|
|
479
|
-
var SvgChevronDoubleRightStroke = function SvgChevronDoubleRightStroke(props) {
|
|
480
|
-
return /*#__PURE__*/React.createElement("svg", _extends({
|
|
481
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
482
|
-
width: 16,
|
|
483
|
-
height: 16,
|
|
484
|
-
focusable: "false",
|
|
485
|
-
viewBox: "0 0 16 16",
|
|
486
|
-
"aria-hidden": "true"
|
|
487
|
-
}, props), _path || (_path = /*#__PURE__*/React.createElement("path", {
|
|
488
|
-
fill: "currentColor",
|
|
489
|
-
d: "M8.188 2.61a.5.5 0 01.64.013l.062.065 4 5a.5.5 0 01.054.542l-.054.082-4 5a.5.5 0 01-.83-.55l.05-.074L11.859 8l-3.75-4.688a.5.5 0 01.079-.702zm-5 0a.5.5 0 01.64.013l.062.065 4 5a.5.5 0 01.054.542l-.054.082-4 5a.5.5 0 01-.83-.55l.05-.074L6.859 8l-3.75-4.688a.5.5 0 01.079-.702z"
|
|
490
|
-
})));
|
|
491
|
-
};
|
|
492
|
-
|
|
493
|
-
const LastComponent = forwardRef((_ref, ref) => {
|
|
494
|
-
let {
|
|
495
|
-
children,
|
|
496
|
-
...other
|
|
497
|
-
} = _ref;
|
|
498
|
-
return React__default.createElement(StyledCursor, _extends$4({
|
|
499
|
-
ref: ref,
|
|
500
|
-
as: "button"
|
|
501
|
-
}, other), React__default.createElement("span", null, children), React__default.createElement(StyledIcon, {
|
|
502
|
-
type: "last"
|
|
503
|
-
}, React__default.createElement(SvgChevronDoubleRightStroke, null)));
|
|
504
|
-
});
|
|
505
|
-
LastComponent.displayName = 'CursorPagination.Last';
|
|
506
|
-
const Last = LastComponent;
|
|
507
|
-
|
|
508
|
-
const CursorPaginationComponent = forwardRef((props, ref) => React__default.createElement(StyledCursorPagination, _extends$4({
|
|
509
|
-
ref: ref
|
|
510
|
-
}, props)));
|
|
511
|
-
CursorPaginationComponent.displayName = 'CursorPagination';
|
|
512
|
-
const CursorPagination = CursorPaginationComponent;
|
|
513
|
-
CursorPagination.First = First;
|
|
514
|
-
CursorPagination.Next = Next;
|
|
515
|
-
CursorPagination.Previous = Previous;
|
|
516
|
-
CursorPagination.Last = Last;
|
|
517
|
-
|
|
518
|
-
export { CursorPagination, OffsetPagination };
|