@atlaskit/pagination 14.0.3 → 14.1.2
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 +29 -0
- package/dist/cjs/internal/utils/collapse-range.js +2 -2
- package/dist/cjs/pagination.js +9 -6
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/internal/utils/collapse-range.js +2 -2
- package/dist/es2019/pagination.js +9 -6
- package/dist/es2019/version.json +1 -1
- package/dist/esm/internal/utils/collapse-range.js +2 -2
- package/dist/esm/pagination.js +9 -6
- package/dist/esm/version.json +1 -1
- package/dist/types/internal/components/navigator.d.ts +1 -0
- package/dist/types/internal/utils/collapse-range.d.ts +2 -2
- package/dist/types/types.d.ts +7 -0
- package/package.json +12 -20
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,34 @@
|
|
|
1
1
|
# @atlaskit/pagination
|
|
2
2
|
|
|
3
|
+
## 14.1.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`b85e7ce12cd`](https://bitbucket.org/atlassian/atlassian-frontend/commits/b85e7ce12cd) - Internal upgrade of memoize-one to 6.0.0
|
|
8
|
+
|
|
9
|
+
## 14.1.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies
|
|
14
|
+
|
|
15
|
+
## 14.1.0
|
|
16
|
+
|
|
17
|
+
### Minor Changes
|
|
18
|
+
|
|
19
|
+
- [`f7f36b1ea80`](https://bitbucket.org/atlassian/atlassian-frontend/commits/f7f36b1ea80) - Test IDs are now applied to sub-components, including the page items and left/right navigation controls
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- [`cd34d8ca8ea`](https://bitbucket.org/atlassian/atlassian-frontend/commits/cd34d8ca8ea) - Internal wiring up to the tokens techstack, no code changes.
|
|
24
|
+
- Updated dependencies
|
|
25
|
+
|
|
26
|
+
## 14.0.4
|
|
27
|
+
|
|
28
|
+
### Patch Changes
|
|
29
|
+
|
|
30
|
+
- Updated dependencies
|
|
31
|
+
|
|
3
32
|
## 14.0.3
|
|
4
33
|
|
|
5
34
|
### Patch Changes
|
|
@@ -11,7 +11,7 @@ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers
|
|
|
11
11
|
|
|
12
12
|
var _memoizeOne = _interopRequireDefault(require("memoize-one"));
|
|
13
13
|
|
|
14
|
-
var collapseRange = function collapseRange(pages, current, _ref) {
|
|
14
|
+
var collapseRange = function collapseRange(pages, current, _ref, testId) {
|
|
15
15
|
var max = _ref.max,
|
|
16
16
|
ellipsis = _ref.ellipsis,
|
|
17
17
|
transform = _ref.transform;
|
|
@@ -26,7 +26,7 @@ var collapseRange = function collapseRange(pages, current, _ref) {
|
|
|
26
26
|
var startIndex = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
27
27
|
var lastIndex = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : total;
|
|
28
28
|
return pages.slice(startIndex, lastIndex).map(function (page, index) {
|
|
29
|
-
return transform(page, startIndex + index);
|
|
29
|
+
return transform(page, startIndex + index, testId);
|
|
30
30
|
});
|
|
31
31
|
});
|
|
32
32
|
|
package/dist/cjs/pagination.js
CHANGED
|
@@ -44,7 +44,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
44
44
|
var analyticsAttributes = {
|
|
45
45
|
componentName: 'pagination',
|
|
46
46
|
packageName: "@atlaskit/pagination",
|
|
47
|
-
packageVersion: "14.
|
|
47
|
+
packageVersion: "14.1.2"
|
|
48
48
|
};
|
|
49
49
|
|
|
50
50
|
function InnerPagination(_ref, ref) {
|
|
@@ -97,7 +97,7 @@ function InnerPagination(_ref, ref) {
|
|
|
97
97
|
analyticsData: analyticsContext
|
|
98
98
|
}, analyticsAttributes));
|
|
99
99
|
|
|
100
|
-
var transform = function transform(page, currPageIndex) {
|
|
100
|
+
var transform = function transform(page, currPageIndex, testId) {
|
|
101
101
|
var selectedPage = pages[selectedIndexValue];
|
|
102
102
|
return (0, _core.jsx)(_page.default, {
|
|
103
103
|
key: "page-".concat(getPageLabel ? getPageLabel(page, currPageIndex) : currPageIndex),
|
|
@@ -109,7 +109,8 @@ function InnerPagination(_ref, ref) {
|
|
|
109
109
|
});
|
|
110
110
|
},
|
|
111
111
|
isSelected: page === selectedPage,
|
|
112
|
-
page: page
|
|
112
|
+
page: page,
|
|
113
|
+
testId: testId && "".concat(testId, "--").concat(page === selectedPage ? 'current-' : '', "page-").concat(currPageIndex)
|
|
113
114
|
}, getPageLabel ? getPageLabel(page, currPageIndex) : page);
|
|
114
115
|
};
|
|
115
116
|
|
|
@@ -132,12 +133,13 @@ function InnerPagination(_ref, ref) {
|
|
|
132
133
|
label: ""
|
|
133
134
|
}),
|
|
134
135
|
"aria-label": previousLabel,
|
|
135
|
-
pages: pages
|
|
136
|
+
pages: pages,
|
|
137
|
+
testId: testId && "".concat(testId, "--left-navigator")
|
|
136
138
|
}), (0, _collapseRange.default)(pages, selectedIndexValue, {
|
|
137
139
|
max: max,
|
|
138
140
|
ellipsis: renderEllipsis,
|
|
139
141
|
transform: transform
|
|
140
|
-
}), (0, _core.jsx)(_navigator.default, {
|
|
142
|
+
}, testId), (0, _core.jsx)(_navigator.default, {
|
|
141
143
|
key: "right-navigator",
|
|
142
144
|
component: components.Next,
|
|
143
145
|
onClick: function onClick(event) {
|
|
@@ -151,7 +153,8 @@ function InnerPagination(_ref, ref) {
|
|
|
151
153
|
label: ""
|
|
152
154
|
}),
|
|
153
155
|
"aria-label": nextLabel,
|
|
154
|
-
pages: pages
|
|
156
|
+
pages: pages,
|
|
157
|
+
testId: testId && "".concat(testId, "--right-navigator")
|
|
155
158
|
}));
|
|
156
159
|
}
|
|
157
160
|
|
package/dist/cjs/version.json
CHANGED
|
@@ -4,7 +4,7 @@ const collapseRange = (pages, current, {
|
|
|
4
4
|
max,
|
|
5
5
|
ellipsis,
|
|
6
6
|
transform
|
|
7
|
-
}) => {
|
|
7
|
+
}, testId) => {
|
|
8
8
|
const total = pages.length; // only need ellipsis if we have more pages than we can display
|
|
9
9
|
|
|
10
10
|
const needEllipsis = total > max; // show start ellipsis if the current page is further away than max - 4 from the first page
|
|
@@ -13,7 +13,7 @@ const collapseRange = (pages, current, {
|
|
|
13
13
|
|
|
14
14
|
const hasEndEllipsis = needEllipsis && current < total - max + 3;
|
|
15
15
|
const getPageComponents = memoizeOne((startIndex = 0, lastIndex = total) => {
|
|
16
|
-
return pages.slice(startIndex, lastIndex).map((page, index) => transform(page, startIndex + index));
|
|
16
|
+
return pages.slice(startIndex, lastIndex).map((page, index) => transform(page, startIndex + index, testId));
|
|
17
17
|
});
|
|
18
18
|
|
|
19
19
|
if (!needEllipsis) {
|
|
@@ -15,7 +15,7 @@ import collapseRange from './internal/utils/collapse-range';
|
|
|
15
15
|
const analyticsAttributes = {
|
|
16
16
|
componentName: 'pagination',
|
|
17
17
|
packageName: "@atlaskit/pagination",
|
|
18
|
-
packageVersion: "14.
|
|
18
|
+
packageVersion: "14.1.2"
|
|
19
19
|
};
|
|
20
20
|
|
|
21
21
|
function InnerPagination({
|
|
@@ -56,7 +56,7 @@ function InnerPagination({
|
|
|
56
56
|
...analyticsAttributes
|
|
57
57
|
});
|
|
58
58
|
|
|
59
|
-
const transform = (page, currPageIndex) => {
|
|
59
|
+
const transform = (page, currPageIndex, testId) => {
|
|
60
60
|
const selectedPage = pages[selectedIndexValue];
|
|
61
61
|
return jsx(PageComponent, {
|
|
62
62
|
key: `page-${getPageLabel ? getPageLabel(page, currPageIndex) : currPageIndex}`,
|
|
@@ -66,7 +66,8 @@ function InnerPagination({
|
|
|
66
66
|
selectedPageIndex: currPageIndex
|
|
67
67
|
}),
|
|
68
68
|
isSelected: page === selectedPage,
|
|
69
|
-
page: page
|
|
69
|
+
page: page,
|
|
70
|
+
testId: testId && `${testId}--${page === selectedPage ? 'current-' : ''}page-${currPageIndex}`
|
|
70
71
|
}, getPageLabel ? getPageLabel(page, currPageIndex) : page);
|
|
71
72
|
};
|
|
72
73
|
|
|
@@ -89,12 +90,13 @@ function InnerPagination({
|
|
|
89
90
|
label: ""
|
|
90
91
|
}),
|
|
91
92
|
"aria-label": previousLabel,
|
|
92
|
-
pages: pages
|
|
93
|
+
pages: pages,
|
|
94
|
+
testId: testId && `${testId}--left-navigator`
|
|
93
95
|
}), collapseRange(pages, selectedIndexValue, {
|
|
94
96
|
max: max,
|
|
95
97
|
ellipsis: renderEllipsis,
|
|
96
98
|
transform
|
|
97
|
-
}), jsx(Navigator, {
|
|
99
|
+
}, testId), jsx(Navigator, {
|
|
98
100
|
key: "right-navigator",
|
|
99
101
|
component: components.Next,
|
|
100
102
|
onClick: event => onChangeWithAnalytics({
|
|
@@ -106,7 +108,8 @@ function InnerPagination({
|
|
|
106
108
|
label: ""
|
|
107
109
|
}),
|
|
108
110
|
"aria-label": nextLabel,
|
|
109
|
-
pages: pages
|
|
111
|
+
pages: pages,
|
|
112
|
+
testId: testId && `${testId}--right-navigator`
|
|
110
113
|
}));
|
|
111
114
|
}
|
|
112
115
|
|
package/dist/es2019/version.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
2
|
import memoizeOne from 'memoize-one';
|
|
3
3
|
|
|
4
|
-
var collapseRange = function collapseRange(pages, current, _ref) {
|
|
4
|
+
var collapseRange = function collapseRange(pages, current, _ref, testId) {
|
|
5
5
|
var max = _ref.max,
|
|
6
6
|
ellipsis = _ref.ellipsis,
|
|
7
7
|
transform = _ref.transform;
|
|
@@ -16,7 +16,7 @@ var collapseRange = function collapseRange(pages, current, _ref) {
|
|
|
16
16
|
var startIndex = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
17
17
|
var lastIndex = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : total;
|
|
18
18
|
return pages.slice(startIndex, lastIndex).map(function (page, index) {
|
|
19
|
-
return transform(page, startIndex + index);
|
|
19
|
+
return transform(page, startIndex + index, testId);
|
|
20
20
|
});
|
|
21
21
|
});
|
|
22
22
|
|
package/dist/esm/pagination.js
CHANGED
|
@@ -22,7 +22,7 @@ import collapseRange from './internal/utils/collapse-range';
|
|
|
22
22
|
var analyticsAttributes = {
|
|
23
23
|
componentName: 'pagination',
|
|
24
24
|
packageName: "@atlaskit/pagination",
|
|
25
|
-
packageVersion: "14.
|
|
25
|
+
packageVersion: "14.1.2"
|
|
26
26
|
};
|
|
27
27
|
|
|
28
28
|
function InnerPagination(_ref, ref) {
|
|
@@ -75,7 +75,7 @@ function InnerPagination(_ref, ref) {
|
|
|
75
75
|
analyticsData: analyticsContext
|
|
76
76
|
}, analyticsAttributes));
|
|
77
77
|
|
|
78
|
-
var transform = function transform(page, currPageIndex) {
|
|
78
|
+
var transform = function transform(page, currPageIndex, testId) {
|
|
79
79
|
var selectedPage = pages[selectedIndexValue];
|
|
80
80
|
return jsx(PageComponent, {
|
|
81
81
|
key: "page-".concat(getPageLabel ? getPageLabel(page, currPageIndex) : currPageIndex),
|
|
@@ -87,7 +87,8 @@ function InnerPagination(_ref, ref) {
|
|
|
87
87
|
});
|
|
88
88
|
},
|
|
89
89
|
isSelected: page === selectedPage,
|
|
90
|
-
page: page
|
|
90
|
+
page: page,
|
|
91
|
+
testId: testId && "".concat(testId, "--").concat(page === selectedPage ? 'current-' : '', "page-").concat(currPageIndex)
|
|
91
92
|
}, getPageLabel ? getPageLabel(page, currPageIndex) : page);
|
|
92
93
|
};
|
|
93
94
|
|
|
@@ -110,12 +111,13 @@ function InnerPagination(_ref, ref) {
|
|
|
110
111
|
label: ""
|
|
111
112
|
}),
|
|
112
113
|
"aria-label": previousLabel,
|
|
113
|
-
pages: pages
|
|
114
|
+
pages: pages,
|
|
115
|
+
testId: testId && "".concat(testId, "--left-navigator")
|
|
114
116
|
}), collapseRange(pages, selectedIndexValue, {
|
|
115
117
|
max: max,
|
|
116
118
|
ellipsis: renderEllipsis,
|
|
117
119
|
transform: transform
|
|
118
|
-
}), jsx(Navigator, {
|
|
120
|
+
}, testId), jsx(Navigator, {
|
|
119
121
|
key: "right-navigator",
|
|
120
122
|
component: components.Next,
|
|
121
123
|
onClick: function onClick(event) {
|
|
@@ -129,7 +131,8 @@ function InnerPagination(_ref, ref) {
|
|
|
129
131
|
label: ""
|
|
130
132
|
}),
|
|
131
133
|
"aria-label": nextLabel,
|
|
132
|
-
pages: pages
|
|
134
|
+
pages: pages,
|
|
135
|
+
testId: testId && "".concat(testId, "--right-navigator")
|
|
133
136
|
}));
|
|
134
137
|
}
|
|
135
138
|
|
package/dist/esm/version.json
CHANGED
|
@@ -7,6 +7,7 @@ export declare type NavigatorPropsType<T> = {
|
|
|
7
7
|
isDisabled?: boolean;
|
|
8
8
|
iconBefore: ReactElement;
|
|
9
9
|
pages: T[];
|
|
10
|
+
testId?: string;
|
|
10
11
|
/** This function is called with the when user clicks on navigator */
|
|
11
12
|
onClick?: (event: SyntheticEvent) => void;
|
|
12
13
|
component?: React.ElementType<any>;
|
|
@@ -4,6 +4,6 @@ declare const collapseRange: <T>(pages: T[], current: number, { max, ellipsis, t
|
|
|
4
4
|
ellipsis: (arg: {
|
|
5
5
|
key: string;
|
|
6
6
|
}) => ReactElement;
|
|
7
|
-
transform: (page: T, index: number) => ReactElement;
|
|
8
|
-
}) => ReactElement[];
|
|
7
|
+
transform: (page: T, index: number, testId?: string | undefined) => ReactElement;
|
|
8
|
+
}, testId?: string | undefined) => ReactElement[];
|
|
9
9
|
export default collapseRange;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -37,6 +37,13 @@ export interface PaginationPropTypes<T = unknown> {
|
|
|
37
37
|
* A `testId` prop is provided for specified elements,
|
|
38
38
|
* which is a unique string that appears as a data attribute `data-testid`
|
|
39
39
|
* in the rendered code, serving as a hook for automated tests
|
|
40
|
+
*
|
|
41
|
+
* Will set data-testid on these elements when defined:
|
|
42
|
+
* - Pagination nav wrapper - {testId}
|
|
43
|
+
* - Page - {testId}--page-{page index}
|
|
44
|
+
* - Current page - {testId}--current-page-{page index}
|
|
45
|
+
* - Left navigator - {testId}--left-navigator
|
|
46
|
+
* - Right navigator - {testId}--right-navigator
|
|
40
47
|
* */
|
|
41
48
|
testId?: string;
|
|
42
49
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/pagination",
|
|
3
|
-
"version": "14.
|
|
3
|
+
"version": "14.1.2",
|
|
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/"
|
|
@@ -24,14 +24,14 @@
|
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@atlaskit/analytics-next": "^8.0.0",
|
|
27
|
-
"@atlaskit/button": "^
|
|
28
|
-
"@atlaskit/codemod-utils": "^3.
|
|
29
|
-
"@atlaskit/ds-lib": "^1.
|
|
30
|
-
"@atlaskit/icon": "^21.
|
|
31
|
-
"@atlaskit/theme": "^
|
|
27
|
+
"@atlaskit/button": "^16.1.0",
|
|
28
|
+
"@atlaskit/codemod-utils": "^3.4.0",
|
|
29
|
+
"@atlaskit/ds-lib": "^1.3.0",
|
|
30
|
+
"@atlaskit/icon": "^21.9.0",
|
|
31
|
+
"@atlaskit/theme": "^12.0.0",
|
|
32
32
|
"@babel/runtime": "^7.0.0",
|
|
33
33
|
"@emotion/core": "^10.0.9",
|
|
34
|
-
"memoize-one": "^
|
|
34
|
+
"memoize-one": "^6.0.0"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"react": "^16.8.0"
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"@atlaskit/build-utils": "*",
|
|
41
41
|
"@atlaskit/docs": "*",
|
|
42
42
|
"@atlaskit/dynamic-table": "^14.1.0",
|
|
43
|
-
"@atlaskit/section-message": "^6.
|
|
43
|
+
"@atlaskit/section-message": "^6.1.0",
|
|
44
44
|
"@atlaskit/ssr": "*",
|
|
45
45
|
"@atlaskit/visual-regression": "*",
|
|
46
46
|
"@atlaskit/webdriver-runner": "*",
|
|
@@ -61,18 +61,10 @@
|
|
|
61
61
|
"import-structure": "atlassian-conventions"
|
|
62
62
|
},
|
|
63
63
|
"@repo/internal": {
|
|
64
|
-
"ui-components":
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
"
|
|
68
|
-
"analytics-next"
|
|
69
|
-
],
|
|
70
|
-
"theming": [
|
|
71
|
-
"new-theming-api"
|
|
72
|
-
],
|
|
73
|
-
"deprecation": [
|
|
74
|
-
"no-deprecated-imports"
|
|
75
|
-
]
|
|
64
|
+
"ui-components": "lite-mode",
|
|
65
|
+
"analytics": "analytics-next",
|
|
66
|
+
"theming": "tokens",
|
|
67
|
+
"deprecation": "no-deprecated-imports"
|
|
76
68
|
}
|
|
77
69
|
},
|
|
78
70
|
"af:exports": {
|