@atlaskit/pagination 14.5.2 → 14.6.0
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/internal/components/render-ellipsis.js +6 -3
- package/dist/cjs/internal/utils/collapse-range.js +12 -4
- package/dist/cjs/pagination.js +25 -9
- 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 -10
- 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 -10
- 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/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 +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/pagination
|
|
2
2
|
|
|
3
|
+
## 14.6.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#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.
|
|
8
|
+
|
|
9
|
+
## 14.5.3
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies
|
|
14
|
+
|
|
3
15
|
## 14.5.2
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -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
|
@@ -27,8 +27,15 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
27
27
|
var analyticsAttributes = {
|
|
28
28
|
componentName: 'pagination',
|
|
29
29
|
packageName: "@atlaskit/pagination",
|
|
30
|
-
packageVersion: "14.
|
|
30
|
+
packageVersion: "14.6.0"
|
|
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,
|
|
@@ -122,11 +133,16 @@ function InnerPagination(_ref, ref) {
|
|
|
122
133
|
"aria-label": previousLabel,
|
|
123
134
|
pages: pages,
|
|
124
135
|
testId: testId && "".concat(testId, "--left-navigator")
|
|
125
|
-
}),
|
|
136
|
+
}), /*#__PURE__*/_react.default.createElement(_primitives.Inline, {
|
|
137
|
+
space: "space.0",
|
|
138
|
+
alignBlock: "baseline",
|
|
139
|
+
as: "ul",
|
|
140
|
+
xcss: paginationMenuStyles
|
|
141
|
+
}, (0, _collapseRange.default)(pages, selectedIndexValue, {
|
|
126
142
|
max: max,
|
|
127
143
|
ellipsis: renderEllipsis,
|
|
128
144
|
transform: transform
|
|
129
|
-
}, testId), /*#__PURE__*/_react.default.createElement(_navigator.default, {
|
|
145
|
+
}, testId)), /*#__PURE__*/_react.default.createElement(_navigator.default, {
|
|
130
146
|
key: "right-navigator",
|
|
131
147
|
component: components.Next,
|
|
132
148
|
onClick: function onClick(event) {
|
|
@@ -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: "14.
|
|
16
|
+
packageVersion: "14.6.0"
|
|
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,
|
|
@@ -93,11 +104,16 @@ function InnerPagination({
|
|
|
93
104
|
"aria-label": previousLabel,
|
|
94
105
|
pages: pages,
|
|
95
106
|
testId: testId && `${testId}--left-navigator`
|
|
96
|
-
}),
|
|
107
|
+
}), /*#__PURE__*/React.createElement(Inline, {
|
|
108
|
+
space: "space.0",
|
|
109
|
+
alignBlock: "baseline",
|
|
110
|
+
as: "ul",
|
|
111
|
+
xcss: paginationMenuStyles
|
|
112
|
+
}, collapseRange(pages, selectedIndexValue, {
|
|
97
113
|
max: max,
|
|
98
114
|
ellipsis: renderEllipsis,
|
|
99
115
|
transform
|
|
100
|
-
}, testId), /*#__PURE__*/React.createElement(Navigator, {
|
|
116
|
+
}, testId)), /*#__PURE__*/React.createElement(Navigator, {
|
|
101
117
|
key: "right-navigator",
|
|
102
118
|
component: components.Next,
|
|
103
119
|
onClick: event => onChangeWithAnalytics({
|
|
@@ -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: "14.
|
|
20
|
+
packageVersion: "14.6.0"
|
|
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,
|
|
@@ -112,11 +123,16 @@ function InnerPagination(_ref, ref) {
|
|
|
112
123
|
"aria-label": previousLabel,
|
|
113
124
|
pages: pages,
|
|
114
125
|
testId: testId && "".concat(testId, "--left-navigator")
|
|
115
|
-
}),
|
|
126
|
+
}), /*#__PURE__*/React.createElement(Inline, {
|
|
127
|
+
space: "space.0",
|
|
128
|
+
alignBlock: "baseline",
|
|
129
|
+
as: "ul",
|
|
130
|
+
xcss: paginationMenuStyles
|
|
131
|
+
}, collapseRange(pages, selectedIndexValue, {
|
|
116
132
|
max: max,
|
|
117
133
|
ellipsis: renderEllipsis,
|
|
118
134
|
transform: transform
|
|
119
|
-
}, testId), /*#__PURE__*/React.createElement(Navigator, {
|
|
135
|
+
}, testId)), /*#__PURE__*/React.createElement(Navigator, {
|
|
120
136
|
key: "right-navigator",
|
|
121
137
|
component: components.Next,
|
|
122
138
|
onClick: function onClick(event) {
|
|
@@ -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.0",
|
|
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/"
|
|
@@ -45,7 +45,8 @@
|
|
|
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": "^
|
|
48
|
+
"@atlaskit/primitives": "^4.0.0",
|
|
49
|
+
"@atlaskit/visually-hidden": "^1.2.4",
|
|
49
50
|
"@babel/runtime": "^7.0.0",
|
|
50
51
|
"memoize-one": "^6.0.0"
|
|
51
52
|
},
|