@atlaskit/pagination 14.5.3 → 14.6.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/CHANGELOG.md +12 -0
- package/dist/cjs/entry-points/types.js +1 -5
- package/dist/cjs/internal/components/navigator.js +8 -5
- package/dist/cjs/internal/components/render-ellipsis.js +6 -3
- package/dist/cjs/internal/utils/collapse-range.js +12 -4
- package/dist/cjs/pagination.js +27 -13
- package/dist/es2019/entry-points/types.js +0 -1
- package/dist/es2019/internal/components/navigator.js +8 -5
- package/dist/es2019/internal/components/render-ellipsis.js +6 -3
- package/dist/es2019/internal/utils/collapse-range.js +12 -4
- package/dist/es2019/pagination.js +26 -12
- package/dist/esm/entry-points/types.js +0 -1
- package/dist/esm/internal/components/navigator.js +8 -5
- package/dist/esm/internal/components/render-ellipsis.js +6 -3
- package/dist/esm/internal/utils/collapse-range.js +12 -4
- package/dist/esm/pagination.js +26 -12
- package/dist/types/internal/components/navigator.d.ts +0 -1
- package/dist/types/internal/components/render-ellipsis.d.ts +3 -1
- package/dist/types/internal/utils/collapse-range.d.ts +2 -0
- package/dist/types/types.d.ts +2 -0
- package/dist/types-ts4.5/internal/components/navigator.d.ts +0 -1
- package/dist/types-ts4.5/internal/components/render-ellipsis.d.ts +3 -1
- package/dist/types-ts4.5/internal/utils/collapse-range.d.ts +2 -0
- package/dist/types-ts4.5/types.d.ts +2 -0
- package/package.json +4 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/pagination
|
|
2
2
|
|
|
3
|
+
## 14.6.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#80972](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/80972) [`6ff808b4cb86`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/6ff808b4cb86) - Remove unused "pages" prop from Navigator buttons and replace usage of spread operator with individual props.
|
|
8
|
+
|
|
9
|
+
## 14.6.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [#72645](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/72645) [`10cdc9cadb00`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/10cdc9cadb00) - Accessibility fix. Fixed semantics for pagination buttons.
|
|
14
|
+
|
|
3
15
|
## 14.5.3
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -5,13 +5,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = Navigator;
|
|
8
|
-
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
8
|
var _react = _interopRequireDefault(require("react"));
|
|
10
9
|
var _standardButton = _interopRequireDefault(require("@atlaskit/button/standard-button"));
|
|
11
10
|
function Navigator(props) {
|
|
12
|
-
return /*#__PURE__*/_react.default.createElement(_standardButton.default
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
return /*#__PURE__*/_react.default.createElement(_standardButton.default, {
|
|
12
|
+
"aria-label": props['aria-label'],
|
|
13
|
+
isDisabled: props.isDisabled,
|
|
14
|
+
iconBefore: props.iconBefore,
|
|
15
|
+
testId: props.testId,
|
|
16
|
+
onClick: props.onClick,
|
|
17
|
+
component: props.component,
|
|
15
18
|
appearance: "subtle"
|
|
16
|
-
})
|
|
19
|
+
});
|
|
17
20
|
}
|
|
@@ -8,15 +8,18 @@ exports.default = renderEllipsis;
|
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _text = _interopRequireDefault(require("@atlaskit/ds-explorations/text"));
|
|
10
10
|
var _primitives = require("@atlaskit/primitives");
|
|
11
|
+
var _visuallyHidden = _interopRequireDefault(require("@atlaskit/visually-hidden"));
|
|
11
12
|
var containerStyles = (0, _primitives.xcss)({
|
|
12
13
|
display: 'flex',
|
|
13
14
|
position: 'relative'
|
|
14
15
|
});
|
|
15
16
|
function renderEllipsis(_ref) {
|
|
16
17
|
var key = _ref.key,
|
|
17
|
-
testId = _ref.testId
|
|
18
|
+
testId = _ref.testId,
|
|
19
|
+
from = _ref.from,
|
|
20
|
+
to = _ref.to;
|
|
18
21
|
return /*#__PURE__*/_react.default.createElement(_primitives.Box, {
|
|
19
|
-
as: "
|
|
22
|
+
as: "li",
|
|
20
23
|
testId: testId,
|
|
21
24
|
key: key,
|
|
22
25
|
xcss: containerStyles,
|
|
@@ -24,5 +27,5 @@ function renderEllipsis(_ref) {
|
|
|
24
27
|
}, /*#__PURE__*/_react.default.createElement(_text.default, {
|
|
25
28
|
testId: "".concat(testId, "-text"),
|
|
26
29
|
verticalAlign: "middle"
|
|
27
|
-
}, "\u2026"));
|
|
30
|
+
}, /*#__PURE__*/_react.default.createElement(_visuallyHidden.default, null, "Skipped pages from ", from, " to ", to), "\u2026"));
|
|
28
31
|
}
|
|
@@ -34,24 +34,32 @@ var collapseRange = function collapseRange(pages, current, _ref, testId) {
|
|
|
34
34
|
var _pageCount = max - 2;
|
|
35
35
|
return [].concat((0, _toConsumableArray2.default)(getPageComponents(0, 1)), [ellipsis({
|
|
36
36
|
key: 'ellipsis-1',
|
|
37
|
-
testId: "".concat(testId, "-ellipsis")
|
|
37
|
+
testId: "".concat(testId, "-ellipsis"),
|
|
38
|
+
from: 2,
|
|
39
|
+
to: total - _pageCount
|
|
38
40
|
})], (0, _toConsumableArray2.default)(getPageComponents(total - _pageCount)));
|
|
39
41
|
}
|
|
40
42
|
if (!hasStartEllipsis && hasEndEllipsis) {
|
|
41
43
|
var _pageCount2 = max - 2;
|
|
42
44
|
return [].concat((0, _toConsumableArray2.default)(getPageComponents(0, _pageCount2)), [ellipsis({
|
|
43
45
|
key: 'ellipsis-1',
|
|
44
|
-
testId: "".concat(testId, "-ellipsis")
|
|
46
|
+
testId: "".concat(testId, "-ellipsis"),
|
|
47
|
+
from: _pageCount2 + 1,
|
|
48
|
+
to: total - 1
|
|
45
49
|
})], (0, _toConsumableArray2.default)(getPageComponents(total - 1)));
|
|
46
50
|
}
|
|
47
51
|
// we have both start and end ellipsis
|
|
48
52
|
var pageCount = max - 4;
|
|
49
53
|
return [].concat((0, _toConsumableArray2.default)(getPageComponents(0, 1)), [ellipsis({
|
|
50
54
|
key: 'ellipsis-1',
|
|
51
|
-
testId: "".concat(testId, "-ellipsis")
|
|
55
|
+
testId: "".concat(testId, "-ellipsis"),
|
|
56
|
+
from: 2,
|
|
57
|
+
to: current - Math.floor(pageCount / 2)
|
|
52
58
|
})], (0, _toConsumableArray2.default)(getPageComponents(current - Math.floor(pageCount / 2), current + pageCount - 1)), [ellipsis({
|
|
53
59
|
key: 'ellipsis-2',
|
|
54
|
-
testId: "".concat(testId, "-ellipsis")
|
|
60
|
+
testId: "".concat(testId, "-ellipsis"),
|
|
61
|
+
from: current + 3,
|
|
62
|
+
to: total - 1
|
|
55
63
|
})], (0, _toConsumableArray2.default)(getPageComponents(total - 1)));
|
|
56
64
|
};
|
|
57
65
|
var _default = exports.default = collapseRange;
|
package/dist/cjs/pagination.js
CHANGED
|
@@ -20,15 +20,22 @@ var _page = _interopRequireDefault(require("./internal/components/page"));
|
|
|
20
20
|
var _renderEllipsis = _interopRequireDefault(require("./internal/components/render-ellipsis"));
|
|
21
21
|
var _constants = require("./internal/constants");
|
|
22
22
|
var _collapseRange = _interopRequireDefault(require("./internal/utils/collapse-range"));
|
|
23
|
-
function _getRequireWildcardCache(
|
|
24
|
-
function _interopRequireWildcard(
|
|
23
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
24
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
25
25
|
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; }
|
|
26
26
|
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) { (0, _defineProperty2.default)(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; }
|
|
27
27
|
var analyticsAttributes = {
|
|
28
28
|
componentName: 'pagination',
|
|
29
29
|
packageName: "@atlaskit/pagination",
|
|
30
|
-
packageVersion: "
|
|
30
|
+
packageVersion: "14.6.1"
|
|
31
31
|
};
|
|
32
|
+
var paginationMenuStyles = (0, _primitives.xcss)({
|
|
33
|
+
padding: 'space.0',
|
|
34
|
+
margin: 'space.0'
|
|
35
|
+
});
|
|
36
|
+
var paginationMenuItemStyles = (0, _primitives.xcss)({
|
|
37
|
+
marginBlockStart: 'space.0'
|
|
38
|
+
});
|
|
32
39
|
function InnerPagination(_ref, ref) {
|
|
33
40
|
var _ref$components = _ref.components,
|
|
34
41
|
components = _ref$components === void 0 ? _constants.emptyObject : _ref$components,
|
|
@@ -80,8 +87,12 @@ function InnerPagination(_ref, ref) {
|
|
|
80
87
|
var transform = function transform(page, currPageIndex, testId) {
|
|
81
88
|
var selectedPage = pages[selectedIndexValue];
|
|
82
89
|
var pageIndexLabel = "".concat(pageLabel, " ").concat(getPageLabel ? getPageLabel(page, currPageIndex) : page);
|
|
83
|
-
|
|
84
|
-
|
|
90
|
+
var isCurrentPage = page === selectedPage;
|
|
91
|
+
return /*#__PURE__*/_react.default.createElement(_primitives.Inline, {
|
|
92
|
+
as: "li",
|
|
93
|
+
xcss: paginationMenuItemStyles,
|
|
94
|
+
key: "page-".concat(getPageLabel ? getPageLabel(page, currPageIndex) : currPageIndex)
|
|
95
|
+
}, /*#__PURE__*/_react.default.createElement(_page.default, {
|
|
85
96
|
component: components.Page,
|
|
86
97
|
onClick: function onClick(event) {
|
|
87
98
|
return onChangeWithAnalytics({
|
|
@@ -89,13 +100,13 @@ function InnerPagination(_ref, ref) {
|
|
|
89
100
|
selectedPageIndex: currPageIndex
|
|
90
101
|
});
|
|
91
102
|
},
|
|
92
|
-
"aria-current":
|
|
103
|
+
"aria-current": isCurrentPage ? 'page' : undefined,
|
|
93
104
|
"aria-label": pageIndexLabel,
|
|
94
|
-
isSelected:
|
|
105
|
+
isSelected: isCurrentPage,
|
|
95
106
|
isDisabled: isDisabled,
|
|
96
107
|
page: page,
|
|
97
|
-
testId: testId && "".concat(testId, "--").concat(
|
|
98
|
-
}, getPageLabel ? getPageLabel(page, currPageIndex) : page);
|
|
108
|
+
testId: testId && "".concat(testId, "--").concat(isCurrentPage ? 'current-' : '', "page-").concat(currPageIndex)
|
|
109
|
+
}, getPageLabel ? getPageLabel(page, currPageIndex) : page));
|
|
99
110
|
};
|
|
100
111
|
return /*#__PURE__*/_react.default.createElement(_primitives.Box, {
|
|
101
112
|
testId: testId,
|
|
@@ -120,13 +131,17 @@ function InnerPagination(_ref, ref) {
|
|
|
120
131
|
label: ""
|
|
121
132
|
}),
|
|
122
133
|
"aria-label": previousLabel,
|
|
123
|
-
pages: pages,
|
|
124
134
|
testId: testId && "".concat(testId, "--left-navigator")
|
|
125
|
-
}),
|
|
135
|
+
}), /*#__PURE__*/_react.default.createElement(_primitives.Inline, {
|
|
136
|
+
space: "space.0",
|
|
137
|
+
alignBlock: "baseline",
|
|
138
|
+
as: "ul",
|
|
139
|
+
xcss: paginationMenuStyles
|
|
140
|
+
}, (0, _collapseRange.default)(pages, selectedIndexValue, {
|
|
126
141
|
max: max,
|
|
127
142
|
ellipsis: renderEllipsis,
|
|
128
143
|
transform: transform
|
|
129
|
-
}, testId), /*#__PURE__*/_react.default.createElement(_navigator.default, {
|
|
144
|
+
}, testId)), /*#__PURE__*/_react.default.createElement(_navigator.default, {
|
|
130
145
|
key: "right-navigator",
|
|
131
146
|
component: components.Next,
|
|
132
147
|
onClick: function onClick(event) {
|
|
@@ -140,7 +155,6 @@ function InnerPagination(_ref, ref) {
|
|
|
140
155
|
label: ""
|
|
141
156
|
}),
|
|
142
157
|
"aria-label": nextLabel,
|
|
143
|
-
pages: pages,
|
|
144
158
|
testId: testId && "".concat(testId, "--right-navigator")
|
|
145
159
|
})));
|
|
146
160
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
2
1
|
import React from 'react';
|
|
3
2
|
import Button from '@atlaskit/button/standard-button';
|
|
4
3
|
export default function Navigator(props) {
|
|
5
|
-
return /*#__PURE__*/React.createElement(Button
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
return /*#__PURE__*/React.createElement(Button, {
|
|
5
|
+
"aria-label": props['aria-label'],
|
|
6
|
+
isDisabled: props.isDisabled,
|
|
7
|
+
iconBefore: props.iconBefore,
|
|
8
|
+
testId: props.testId,
|
|
9
|
+
onClick: props.onClick,
|
|
10
|
+
component: props.component,
|
|
8
11
|
appearance: "subtle"
|
|
9
|
-
})
|
|
12
|
+
});
|
|
10
13
|
}
|
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import Text from '@atlaskit/ds-explorations/text';
|
|
3
3
|
import { Box, xcss } from '@atlaskit/primitives';
|
|
4
|
+
import VisuallyHidden from '@atlaskit/visually-hidden';
|
|
4
5
|
const containerStyles = xcss({
|
|
5
6
|
display: 'flex',
|
|
6
7
|
position: 'relative'
|
|
7
8
|
});
|
|
8
9
|
export default function renderEllipsis({
|
|
9
10
|
key,
|
|
10
|
-
testId
|
|
11
|
+
testId,
|
|
12
|
+
from,
|
|
13
|
+
to
|
|
11
14
|
}) {
|
|
12
15
|
return /*#__PURE__*/React.createElement(Box, {
|
|
13
|
-
as: "
|
|
16
|
+
as: "li",
|
|
14
17
|
testId: testId,
|
|
15
18
|
key: key,
|
|
16
19
|
xcss: containerStyles,
|
|
@@ -18,5 +21,5 @@ export default function renderEllipsis({
|
|
|
18
21
|
}, /*#__PURE__*/React.createElement(Text, {
|
|
19
22
|
testId: `${testId}-text`,
|
|
20
23
|
verticalAlign: "middle"
|
|
21
|
-
}, "\u2026"));
|
|
24
|
+
}, /*#__PURE__*/React.createElement(VisuallyHidden, null, "Skipped pages from ", from, " to ", to), "\u2026"));
|
|
22
25
|
}
|
|
@@ -24,24 +24,32 @@ const collapseRange = (pages, current, {
|
|
|
24
24
|
const pageCount = max - 2;
|
|
25
25
|
return [...getPageComponents(0, 1), ellipsis({
|
|
26
26
|
key: 'ellipsis-1',
|
|
27
|
-
testId: `${testId}-ellipsis
|
|
27
|
+
testId: `${testId}-ellipsis`,
|
|
28
|
+
from: 2,
|
|
29
|
+
to: total - pageCount
|
|
28
30
|
}), ...getPageComponents(total - pageCount)];
|
|
29
31
|
}
|
|
30
32
|
if (!hasStartEllipsis && hasEndEllipsis) {
|
|
31
33
|
const pageCount = max - 2;
|
|
32
34
|
return [...getPageComponents(0, pageCount), ellipsis({
|
|
33
35
|
key: 'ellipsis-1',
|
|
34
|
-
testId: `${testId}-ellipsis
|
|
36
|
+
testId: `${testId}-ellipsis`,
|
|
37
|
+
from: pageCount + 1,
|
|
38
|
+
to: total - 1
|
|
35
39
|
}), ...getPageComponents(total - 1)];
|
|
36
40
|
}
|
|
37
41
|
// we have both start and end ellipsis
|
|
38
42
|
const pageCount = max - 4;
|
|
39
43
|
return [...getPageComponents(0, 1), ellipsis({
|
|
40
44
|
key: 'ellipsis-1',
|
|
41
|
-
testId: `${testId}-ellipsis
|
|
45
|
+
testId: `${testId}-ellipsis`,
|
|
46
|
+
from: 2,
|
|
47
|
+
to: current - Math.floor(pageCount / 2)
|
|
42
48
|
}), ...getPageComponents(current - Math.floor(pageCount / 2), current + pageCount - 1), ellipsis({
|
|
43
49
|
key: 'ellipsis-2',
|
|
44
|
-
testId: `${testId}-ellipsis
|
|
50
|
+
testId: `${testId}-ellipsis`,
|
|
51
|
+
from: current + 3,
|
|
52
|
+
to: total - 1
|
|
45
53
|
}), ...getPageComponents(total - 1)];
|
|
46
54
|
};
|
|
47
55
|
export default collapseRange;
|
|
@@ -4,7 +4,7 @@ import noop from '@atlaskit/ds-lib/noop';
|
|
|
4
4
|
import useControlled from '@atlaskit/ds-lib/use-controlled';
|
|
5
5
|
import ChevronLeftLargeIcon from '@atlaskit/icon/glyph/chevron-left-large';
|
|
6
6
|
import ChevronRightLargeIcon from '@atlaskit/icon/glyph/chevron-right-large';
|
|
7
|
-
import { Box, Inline } from '@atlaskit/primitives';
|
|
7
|
+
import { Box, Inline, xcss } from '@atlaskit/primitives';
|
|
8
8
|
import Navigator from './internal/components/navigator';
|
|
9
9
|
import PageComponent from './internal/components/page';
|
|
10
10
|
import renderDefaultEllipsis from './internal/components/render-ellipsis';
|
|
@@ -13,8 +13,15 @@ import collapseRange from './internal/utils/collapse-range';
|
|
|
13
13
|
const analyticsAttributes = {
|
|
14
14
|
componentName: 'pagination',
|
|
15
15
|
packageName: "@atlaskit/pagination",
|
|
16
|
-
packageVersion: "
|
|
16
|
+
packageVersion: "14.6.1"
|
|
17
17
|
};
|
|
18
|
+
const paginationMenuStyles = xcss({
|
|
19
|
+
padding: 'space.0',
|
|
20
|
+
margin: 'space.0'
|
|
21
|
+
});
|
|
22
|
+
const paginationMenuItemStyles = xcss({
|
|
23
|
+
marginBlockStart: 'space.0'
|
|
24
|
+
});
|
|
18
25
|
function InnerPagination({
|
|
19
26
|
components = emptyObject,
|
|
20
27
|
defaultSelectedIndex = 0,
|
|
@@ -55,20 +62,24 @@ function InnerPagination({
|
|
|
55
62
|
const transform = (page, currPageIndex, testId) => {
|
|
56
63
|
const selectedPage = pages[selectedIndexValue];
|
|
57
64
|
const pageIndexLabel = `${pageLabel} ${getPageLabel ? getPageLabel(page, currPageIndex) : page}`;
|
|
58
|
-
|
|
59
|
-
|
|
65
|
+
const isCurrentPage = page === selectedPage;
|
|
66
|
+
return /*#__PURE__*/React.createElement(Inline, {
|
|
67
|
+
as: "li",
|
|
68
|
+
xcss: paginationMenuItemStyles,
|
|
69
|
+
key: `page-${getPageLabel ? getPageLabel(page, currPageIndex) : currPageIndex}`
|
|
70
|
+
}, /*#__PURE__*/React.createElement(PageComponent, {
|
|
60
71
|
component: components.Page,
|
|
61
72
|
onClick: event => onChangeWithAnalytics({
|
|
62
73
|
event,
|
|
63
74
|
selectedPageIndex: currPageIndex
|
|
64
75
|
}),
|
|
65
|
-
"aria-current":
|
|
76
|
+
"aria-current": isCurrentPage ? 'page' : undefined,
|
|
66
77
|
"aria-label": pageIndexLabel,
|
|
67
|
-
isSelected:
|
|
78
|
+
isSelected: isCurrentPage,
|
|
68
79
|
isDisabled: isDisabled,
|
|
69
80
|
page: page,
|
|
70
|
-
testId: testId && `${testId}--${
|
|
71
|
-
}, getPageLabel ? getPageLabel(page, currPageIndex) : page);
|
|
81
|
+
testId: testId && `${testId}--${isCurrentPage ? 'current-' : ''}page-${currPageIndex}`
|
|
82
|
+
}, getPageLabel ? getPageLabel(page, currPageIndex) : page));
|
|
72
83
|
};
|
|
73
84
|
return /*#__PURE__*/React.createElement(Box, {
|
|
74
85
|
testId: testId,
|
|
@@ -91,13 +102,17 @@ function InnerPagination({
|
|
|
91
102
|
label: ""
|
|
92
103
|
}),
|
|
93
104
|
"aria-label": previousLabel,
|
|
94
|
-
pages: pages,
|
|
95
105
|
testId: testId && `${testId}--left-navigator`
|
|
96
|
-
}),
|
|
106
|
+
}), /*#__PURE__*/React.createElement(Inline, {
|
|
107
|
+
space: "space.0",
|
|
108
|
+
alignBlock: "baseline",
|
|
109
|
+
as: "ul",
|
|
110
|
+
xcss: paginationMenuStyles
|
|
111
|
+
}, collapseRange(pages, selectedIndexValue, {
|
|
97
112
|
max: max,
|
|
98
113
|
ellipsis: renderEllipsis,
|
|
99
114
|
transform
|
|
100
|
-
}, testId), /*#__PURE__*/React.createElement(Navigator, {
|
|
115
|
+
}, testId)), /*#__PURE__*/React.createElement(Navigator, {
|
|
101
116
|
key: "right-navigator",
|
|
102
117
|
component: components.Next,
|
|
103
118
|
onClick: event => onChangeWithAnalytics({
|
|
@@ -109,7 +124,6 @@ function InnerPagination({
|
|
|
109
124
|
label: ""
|
|
110
125
|
}),
|
|
111
126
|
"aria-label": nextLabel,
|
|
112
|
-
pages: pages,
|
|
113
127
|
testId: testId && `${testId}--right-navigator`
|
|
114
128
|
})));
|
|
115
129
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
2
1
|
import React from 'react';
|
|
3
2
|
import Button from '@atlaskit/button/standard-button';
|
|
4
3
|
export default function Navigator(props) {
|
|
5
|
-
return /*#__PURE__*/React.createElement(Button
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
return /*#__PURE__*/React.createElement(Button, {
|
|
5
|
+
"aria-label": props['aria-label'],
|
|
6
|
+
isDisabled: props.isDisabled,
|
|
7
|
+
iconBefore: props.iconBefore,
|
|
8
|
+
testId: props.testId,
|
|
9
|
+
onClick: props.onClick,
|
|
10
|
+
component: props.component,
|
|
8
11
|
appearance: "subtle"
|
|
9
|
-
})
|
|
12
|
+
});
|
|
10
13
|
}
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import Text from '@atlaskit/ds-explorations/text';
|
|
3
3
|
import { Box, xcss } from '@atlaskit/primitives';
|
|
4
|
+
import VisuallyHidden from '@atlaskit/visually-hidden';
|
|
4
5
|
var containerStyles = xcss({
|
|
5
6
|
display: 'flex',
|
|
6
7
|
position: 'relative'
|
|
7
8
|
});
|
|
8
9
|
export default function renderEllipsis(_ref) {
|
|
9
10
|
var key = _ref.key,
|
|
10
|
-
testId = _ref.testId
|
|
11
|
+
testId = _ref.testId,
|
|
12
|
+
from = _ref.from,
|
|
13
|
+
to = _ref.to;
|
|
11
14
|
return /*#__PURE__*/React.createElement(Box, {
|
|
12
|
-
as: "
|
|
15
|
+
as: "li",
|
|
13
16
|
testId: testId,
|
|
14
17
|
key: key,
|
|
15
18
|
xcss: containerStyles,
|
|
@@ -17,5 +20,5 @@ export default function renderEllipsis(_ref) {
|
|
|
17
20
|
}, /*#__PURE__*/React.createElement(Text, {
|
|
18
21
|
testId: "".concat(testId, "-text"),
|
|
19
22
|
verticalAlign: "middle"
|
|
20
|
-
}, "\u2026"));
|
|
23
|
+
}, /*#__PURE__*/React.createElement(VisuallyHidden, null, "Skipped pages from ", from, " to ", to), "\u2026"));
|
|
21
24
|
}
|
|
@@ -28,24 +28,32 @@ var collapseRange = function collapseRange(pages, current, _ref, testId) {
|
|
|
28
28
|
var _pageCount = max - 2;
|
|
29
29
|
return [].concat(_toConsumableArray(getPageComponents(0, 1)), [ellipsis({
|
|
30
30
|
key: 'ellipsis-1',
|
|
31
|
-
testId: "".concat(testId, "-ellipsis")
|
|
31
|
+
testId: "".concat(testId, "-ellipsis"),
|
|
32
|
+
from: 2,
|
|
33
|
+
to: total - _pageCount
|
|
32
34
|
})], _toConsumableArray(getPageComponents(total - _pageCount)));
|
|
33
35
|
}
|
|
34
36
|
if (!hasStartEllipsis && hasEndEllipsis) {
|
|
35
37
|
var _pageCount2 = max - 2;
|
|
36
38
|
return [].concat(_toConsumableArray(getPageComponents(0, _pageCount2)), [ellipsis({
|
|
37
39
|
key: 'ellipsis-1',
|
|
38
|
-
testId: "".concat(testId, "-ellipsis")
|
|
40
|
+
testId: "".concat(testId, "-ellipsis"),
|
|
41
|
+
from: _pageCount2 + 1,
|
|
42
|
+
to: total - 1
|
|
39
43
|
})], _toConsumableArray(getPageComponents(total - 1)));
|
|
40
44
|
}
|
|
41
45
|
// we have both start and end ellipsis
|
|
42
46
|
var pageCount = max - 4;
|
|
43
47
|
return [].concat(_toConsumableArray(getPageComponents(0, 1)), [ellipsis({
|
|
44
48
|
key: 'ellipsis-1',
|
|
45
|
-
testId: "".concat(testId, "-ellipsis")
|
|
49
|
+
testId: "".concat(testId, "-ellipsis"),
|
|
50
|
+
from: 2,
|
|
51
|
+
to: current - Math.floor(pageCount / 2)
|
|
46
52
|
})], _toConsumableArray(getPageComponents(current - Math.floor(pageCount / 2), current + pageCount - 1)), [ellipsis({
|
|
47
53
|
key: 'ellipsis-2',
|
|
48
|
-
testId: "".concat(testId, "-ellipsis")
|
|
54
|
+
testId: "".concat(testId, "-ellipsis"),
|
|
55
|
+
from: current + 3,
|
|
56
|
+
to: total - 1
|
|
49
57
|
})], _toConsumableArray(getPageComponents(total - 1)));
|
|
50
58
|
};
|
|
51
59
|
export default collapseRange;
|
package/dist/esm/pagination.js
CHANGED
|
@@ -8,7 +8,7 @@ import noop from '@atlaskit/ds-lib/noop';
|
|
|
8
8
|
import useControlled from '@atlaskit/ds-lib/use-controlled';
|
|
9
9
|
import ChevronLeftLargeIcon from '@atlaskit/icon/glyph/chevron-left-large';
|
|
10
10
|
import ChevronRightLargeIcon from '@atlaskit/icon/glyph/chevron-right-large';
|
|
11
|
-
import { Box, Inline } from '@atlaskit/primitives';
|
|
11
|
+
import { Box, Inline, xcss } from '@atlaskit/primitives';
|
|
12
12
|
import Navigator from './internal/components/navigator';
|
|
13
13
|
import PageComponent from './internal/components/page';
|
|
14
14
|
import renderDefaultEllipsis from './internal/components/render-ellipsis';
|
|
@@ -17,8 +17,15 @@ import collapseRange from './internal/utils/collapse-range';
|
|
|
17
17
|
var analyticsAttributes = {
|
|
18
18
|
componentName: 'pagination',
|
|
19
19
|
packageName: "@atlaskit/pagination",
|
|
20
|
-
packageVersion: "
|
|
20
|
+
packageVersion: "14.6.1"
|
|
21
21
|
};
|
|
22
|
+
var paginationMenuStyles = xcss({
|
|
23
|
+
padding: 'space.0',
|
|
24
|
+
margin: 'space.0'
|
|
25
|
+
});
|
|
26
|
+
var paginationMenuItemStyles = xcss({
|
|
27
|
+
marginBlockStart: 'space.0'
|
|
28
|
+
});
|
|
22
29
|
function InnerPagination(_ref, ref) {
|
|
23
30
|
var _ref$components = _ref.components,
|
|
24
31
|
components = _ref$components === void 0 ? emptyObject : _ref$components,
|
|
@@ -70,8 +77,12 @@ function InnerPagination(_ref, ref) {
|
|
|
70
77
|
var transform = function transform(page, currPageIndex, testId) {
|
|
71
78
|
var selectedPage = pages[selectedIndexValue];
|
|
72
79
|
var pageIndexLabel = "".concat(pageLabel, " ").concat(getPageLabel ? getPageLabel(page, currPageIndex) : page);
|
|
73
|
-
|
|
74
|
-
|
|
80
|
+
var isCurrentPage = page === selectedPage;
|
|
81
|
+
return /*#__PURE__*/React.createElement(Inline, {
|
|
82
|
+
as: "li",
|
|
83
|
+
xcss: paginationMenuItemStyles,
|
|
84
|
+
key: "page-".concat(getPageLabel ? getPageLabel(page, currPageIndex) : currPageIndex)
|
|
85
|
+
}, /*#__PURE__*/React.createElement(PageComponent, {
|
|
75
86
|
component: components.Page,
|
|
76
87
|
onClick: function onClick(event) {
|
|
77
88
|
return onChangeWithAnalytics({
|
|
@@ -79,13 +90,13 @@ function InnerPagination(_ref, ref) {
|
|
|
79
90
|
selectedPageIndex: currPageIndex
|
|
80
91
|
});
|
|
81
92
|
},
|
|
82
|
-
"aria-current":
|
|
93
|
+
"aria-current": isCurrentPage ? 'page' : undefined,
|
|
83
94
|
"aria-label": pageIndexLabel,
|
|
84
|
-
isSelected:
|
|
95
|
+
isSelected: isCurrentPage,
|
|
85
96
|
isDisabled: isDisabled,
|
|
86
97
|
page: page,
|
|
87
|
-
testId: testId && "".concat(testId, "--").concat(
|
|
88
|
-
}, getPageLabel ? getPageLabel(page, currPageIndex) : page);
|
|
98
|
+
testId: testId && "".concat(testId, "--").concat(isCurrentPage ? 'current-' : '', "page-").concat(currPageIndex)
|
|
99
|
+
}, getPageLabel ? getPageLabel(page, currPageIndex) : page));
|
|
89
100
|
};
|
|
90
101
|
return /*#__PURE__*/React.createElement(Box, {
|
|
91
102
|
testId: testId,
|
|
@@ -110,13 +121,17 @@ function InnerPagination(_ref, ref) {
|
|
|
110
121
|
label: ""
|
|
111
122
|
}),
|
|
112
123
|
"aria-label": previousLabel,
|
|
113
|
-
pages: pages,
|
|
114
124
|
testId: testId && "".concat(testId, "--left-navigator")
|
|
115
|
-
}),
|
|
125
|
+
}), /*#__PURE__*/React.createElement(Inline, {
|
|
126
|
+
space: "space.0",
|
|
127
|
+
alignBlock: "baseline",
|
|
128
|
+
as: "ul",
|
|
129
|
+
xcss: paginationMenuStyles
|
|
130
|
+
}, collapseRange(pages, selectedIndexValue, {
|
|
116
131
|
max: max,
|
|
117
132
|
ellipsis: renderEllipsis,
|
|
118
133
|
transform: transform
|
|
119
|
-
}, testId), /*#__PURE__*/React.createElement(Navigator, {
|
|
134
|
+
}, testId)), /*#__PURE__*/React.createElement(Navigator, {
|
|
120
135
|
key: "right-navigator",
|
|
121
136
|
component: components.Next,
|
|
122
137
|
onClick: function onClick(event) {
|
|
@@ -130,7 +145,6 @@ function InnerPagination(_ref, ref) {
|
|
|
130
145
|
label: ""
|
|
131
146
|
}),
|
|
132
147
|
"aria-label": nextLabel,
|
|
133
|
-
pages: pages,
|
|
134
148
|
testId: testId && "".concat(testId, "--right-navigator")
|
|
135
149
|
})));
|
|
136
150
|
}
|
|
@@ -2,5 +2,7 @@ import { ReactElement } from 'react';
|
|
|
2
2
|
export type EllipsisProp = {
|
|
3
3
|
key: string;
|
|
4
4
|
testId?: string;
|
|
5
|
+
from: number;
|
|
6
|
+
to: number;
|
|
5
7
|
};
|
|
6
|
-
export default function renderEllipsis({ key, testId, }: EllipsisProp): ReactElement;
|
|
8
|
+
export default function renderEllipsis({ key, testId, from, to, }: EllipsisProp): ReactElement;
|
|
@@ -4,6 +4,8 @@ declare const collapseRange: <T>(pages: T[], current: number, { max, ellipsis, t
|
|
|
4
4
|
ellipsis: (arg: {
|
|
5
5
|
key: string;
|
|
6
6
|
testId: string;
|
|
7
|
+
from: number;
|
|
8
|
+
to: number;
|
|
7
9
|
}) => ReactElement;
|
|
8
10
|
transform: (page: T, index: number, testId?: string) => ReactElement;
|
|
9
11
|
}, testId?: string) => ReactElement[];
|
package/dist/types/types.d.ts
CHANGED
|
@@ -2,5 +2,7 @@ import { ReactElement } from 'react';
|
|
|
2
2
|
export type EllipsisProp = {
|
|
3
3
|
key: string;
|
|
4
4
|
testId?: string;
|
|
5
|
+
from: number;
|
|
6
|
+
to: number;
|
|
5
7
|
};
|
|
6
|
-
export default function renderEllipsis({ key, testId, }: EllipsisProp): ReactElement;
|
|
8
|
+
export default function renderEllipsis({ key, testId, from, to, }: EllipsisProp): ReactElement;
|
|
@@ -4,6 +4,8 @@ declare const collapseRange: <T>(pages: T[], current: number, { max, ellipsis, t
|
|
|
4
4
|
ellipsis: (arg: {
|
|
5
5
|
key: string;
|
|
6
6
|
testId: string;
|
|
7
|
+
from: number;
|
|
8
|
+
to: number;
|
|
7
9
|
}) => ReactElement;
|
|
8
10
|
transform: (page: T, index: number, testId?: string) => ReactElement;
|
|
9
11
|
}, testId?: string) => ReactElement[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/pagination",
|
|
3
|
-
"version": "14.
|
|
3
|
+
"version": "14.6.1",
|
|
4
4
|
"description": "Pagination allows you to divide large amounts of content into smaller chunks across multiple pages.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -40,12 +40,13 @@
|
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@atlaskit/analytics-next": "^9.2.0",
|
|
43
|
-
"@atlaskit/button": "^17.
|
|
43
|
+
"@atlaskit/button": "^17.7.0",
|
|
44
44
|
"@atlaskit/codemod-utils": "^4.2.0",
|
|
45
45
|
"@atlaskit/ds-explorations": "^3.2.0",
|
|
46
46
|
"@atlaskit/ds-lib": "^2.2.0",
|
|
47
47
|
"@atlaskit/icon": "^22.1.0",
|
|
48
|
-
"@atlaskit/primitives": "^4.
|
|
48
|
+
"@atlaskit/primitives": "^4.1.0",
|
|
49
|
+
"@atlaskit/visually-hidden": "^1.2.4",
|
|
49
50
|
"@babel/runtime": "^7.0.0",
|
|
50
51
|
"memoize-one": "^6.0.0"
|
|
51
52
|
},
|