@instructure/ui-pagination 10.10.1-snapshot-7 → 10.10.1-snapshot-9
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 +5 -2
- package/es/Pagination/__new-tests__/Pagination.test.js +10 -10
- package/es/Pagination/index.js +39 -20
- package/lib/Pagination/__new-tests__/Pagination.test.js +10 -10
- package/lib/Pagination/index.js +39 -20
- package/package.json +21 -21
- package/src/Pagination/__new-tests__/Pagination.test.tsx +10 -13
- package/src/Pagination/index.tsx +28 -16
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/Pagination/index.d.ts +4 -4
- package/types/Pagination/index.d.ts.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,9 +3,12 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
-
## [10.10.1-snapshot-
|
|
6
|
+
## [10.10.1-snapshot-9](https://github.com/instructure/instructure-ui/compare/v10.10.0...v10.10.1-snapshot-9) (2025-02-03)
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **ui-pagination:** fix Pagination sometimes displaying non li elements in lists, fix key errors too ([1dbe539](https://github.com/instructure/instructure-ui/commit/1dbe53995c5eca96711024e86151eb0bbcf7e1f4))
|
|
9
12
|
|
|
10
13
|
|
|
11
14
|
|
|
@@ -99,7 +99,7 @@ describe('<Pagination />', () => {
|
|
|
99
99
|
variant: "compact",
|
|
100
100
|
labelNext: "Next",
|
|
101
101
|
labelPrev: "Prev"
|
|
102
|
-
},
|
|
102
|
+
}, buildPages(5))),
|
|
103
103
|
container = _render.container;
|
|
104
104
|
const axeCheck = await runAxeCheck(container);
|
|
105
105
|
expect(axeCheck).toBe(true);
|
|
@@ -109,7 +109,7 @@ describe('<Pagination />', () => {
|
|
|
109
109
|
variant: "compact",
|
|
110
110
|
labelNext: "Next",
|
|
111
111
|
labelPrev: "Prev"
|
|
112
|
-
},
|
|
112
|
+
}, buildPages(8))),
|
|
113
113
|
container = _render2.container;
|
|
114
114
|
const axeCheck = await runAxeCheck(container);
|
|
115
115
|
expect(axeCheck).toBe(true);
|
|
@@ -122,7 +122,7 @@ describe('<Pagination />', () => {
|
|
|
122
122
|
labelFirst: "First",
|
|
123
123
|
labelLast: "Last",
|
|
124
124
|
withFirstAndLastButton: true
|
|
125
|
-
},
|
|
125
|
+
}, buildPages(8))),
|
|
126
126
|
container = _render3.container;
|
|
127
127
|
const axeCheck = await runAxeCheck(container);
|
|
128
128
|
expect(axeCheck).toBe(true);
|
|
@@ -136,7 +136,7 @@ describe('<Pagination />', () => {
|
|
|
136
136
|
labelLast: "Last",
|
|
137
137
|
withFirstAndLastButton: true,
|
|
138
138
|
showDisabledButtons: true
|
|
139
|
-
},
|
|
139
|
+
}, buildPages(8))),
|
|
140
140
|
container = _render4.container;
|
|
141
141
|
const axeCheck = await runAxeCheck(container);
|
|
142
142
|
expect(axeCheck).toBe(true);
|
|
@@ -848,7 +848,7 @@ describe('<Pagination />', () => {
|
|
|
848
848
|
totalPageNumber: 9
|
|
849
849
|
}))),
|
|
850
850
|
container = _render24.container;
|
|
851
|
-
expect(container.firstChild).toHaveTextContent('12
|
|
851
|
+
expect(container.firstChild).toHaveTextContent('12…9Next Page');
|
|
852
852
|
});
|
|
853
853
|
it('should render the correct pages - 2', () => {
|
|
854
854
|
const _render25 = render(_Pagination3 || (_Pagination3 = /*#__PURE__*/React.createElement(Pagination, {
|
|
@@ -859,7 +859,7 @@ describe('<Pagination />', () => {
|
|
|
859
859
|
currentPage: 5
|
|
860
860
|
}))),
|
|
861
861
|
container = _render25.container;
|
|
862
|
-
expect(container.firstChild).toHaveTextContent('Previous Page1
|
|
862
|
+
expect(container.firstChild).toHaveTextContent('Previous Page1…456…9Next Page');
|
|
863
863
|
});
|
|
864
864
|
it('should render the correct pages - 3', () => {
|
|
865
865
|
const _render26 = render(_Pagination4 || (_Pagination4 = /*#__PURE__*/React.createElement(Pagination, {
|
|
@@ -885,7 +885,7 @@ describe('<Pagination />', () => {
|
|
|
885
885
|
boundaryCount: 2
|
|
886
886
|
}))),
|
|
887
887
|
container = _render27.container;
|
|
888
|
-
expect(container.firstChild).toHaveTextContent('Previous Page12
|
|
888
|
+
expect(container.firstChild).toHaveTextContent('Previous Page12…456…89Next Page');
|
|
889
889
|
});
|
|
890
890
|
it('should render the correct pages - 5', () => {
|
|
891
891
|
const _render28 = render(_Pagination6 || (_Pagination6 = /*#__PURE__*/React.createElement(Pagination, {
|
|
@@ -922,7 +922,7 @@ describe('<Pagination />', () => {
|
|
|
922
922
|
siblingCount: 1
|
|
923
923
|
}))),
|
|
924
924
|
container = _render30.container;
|
|
925
|
-
expect(container.firstChild).toHaveTextContent('123
|
|
925
|
+
expect(container.firstChild).toHaveTextContent('123…789Next Page');
|
|
926
926
|
});
|
|
927
927
|
it('should render the correct ellipsis', () => {
|
|
928
928
|
const _render31 = render(_Pagination9 || (_Pagination9 = /*#__PURE__*/React.createElement(Pagination, {
|
|
@@ -960,7 +960,7 @@ describe('<Pagination />', () => {
|
|
|
960
960
|
currentPage: 5678
|
|
961
961
|
}))),
|
|
962
962
|
container = _render33.container;
|
|
963
|
-
expect(container.firstChild).toHaveTextContent('Previous Page1
|
|
963
|
+
expect(container.firstChild).toHaveTextContent('Previous Page1…567756785679…1000000000000000Next Page');
|
|
964
964
|
});
|
|
965
965
|
it('should render first and last buttons', () => {
|
|
966
966
|
const _render34 = render(_Pagination11 || (_Pagination11 = /*#__PURE__*/React.createElement(Pagination, {
|
|
@@ -974,7 +974,7 @@ describe('<Pagination />', () => {
|
|
|
974
974
|
withFirstAndLastButton: true
|
|
975
975
|
}))),
|
|
976
976
|
container = _render34.container;
|
|
977
|
-
expect(container.firstChild).toHaveTextContent('First PagePrevious Page1
|
|
977
|
+
expect(container.firstChild).toHaveTextContent('First PagePrevious Page1…456…100Next PageLast Page');
|
|
978
978
|
});
|
|
979
979
|
it('should render every page if boundary and sibling counts are big enough', () => {
|
|
980
980
|
const _render35 = render(_Pagination12 || (_Pagination12 = /*#__PURE__*/React.createElement(Pagination, {
|
package/es/Pagination/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _dec, _dec2, _dec3, _class, _Pagination
|
|
1
|
+
var _dec, _dec2, _dec3, _class, _Pagination;
|
|
2
2
|
/*
|
|
3
3
|
* The MIT License (MIT)
|
|
4
4
|
*
|
|
@@ -113,7 +113,7 @@ let Pagination = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
|
|
|
113
113
|
return pages;
|
|
114
114
|
};
|
|
115
115
|
this.renderDefaultPages = () => {
|
|
116
|
-
var _this$props$
|
|
116
|
+
var _this$props$styles3;
|
|
117
117
|
const _this$props4 = this.props,
|
|
118
118
|
ellipsis = _this$props4.ellipsis,
|
|
119
119
|
currentPage = _this$props4.currentPage,
|
|
@@ -123,14 +123,25 @@ let Pagination = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
|
|
|
123
123
|
variant = _this$props4.variant;
|
|
124
124
|
const pages = [];
|
|
125
125
|
if (totalPageNumber <= 2 * boundaryCount || totalPageNumber <= 1 + siblingCount + boundaryCount || variant === 'full') {
|
|
126
|
-
|
|
126
|
+
var _this$props$styles;
|
|
127
|
+
return jsx("ul", {
|
|
128
|
+
css: (_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.pageIndicatorList
|
|
129
|
+
}, this.renderPagesInInterval(1, totalPageNumber, currentPage));
|
|
127
130
|
}
|
|
128
131
|
if (currentPage > boundaryCount + siblingCount + 1) {
|
|
129
132
|
pages.push(this.renderPagesInInterval(1, boundaryCount, currentPage));
|
|
130
|
-
pages.push(
|
|
133
|
+
pages.push(jsx("li", {
|
|
134
|
+
key: "ellipsis1",
|
|
135
|
+
style: {
|
|
136
|
+
all: 'unset'
|
|
137
|
+
}
|
|
138
|
+
}, ellipsis));
|
|
131
139
|
if (currentPage - siblingCount > totalPageNumber - boundaryCount + 1) {
|
|
140
|
+
var _this$props$styles2;
|
|
132
141
|
pages.push(this.renderPagesInInterval(totalPageNumber - boundaryCount + 1, totalPageNumber, currentPage));
|
|
133
|
-
return
|
|
142
|
+
return jsx("ul", {
|
|
143
|
+
css: (_this$props$styles2 = this.props.styles) === null || _this$props$styles2 === void 0 ? void 0 : _this$props$styles2.pageIndicatorList
|
|
144
|
+
}, pages);
|
|
134
145
|
}
|
|
135
146
|
pages.push(this.renderPagesInInterval(currentPage - siblingCount, currentPage, currentPage));
|
|
136
147
|
} else {
|
|
@@ -138,13 +149,18 @@ let Pagination = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
|
|
|
138
149
|
}
|
|
139
150
|
if (currentPage < totalPageNumber - (siblingCount + boundaryCount)) {
|
|
140
151
|
pages.push(this.renderPagesInInterval(Math.max(currentPage, boundaryCount) + 1, currentPage + siblingCount, currentPage));
|
|
141
|
-
pages.push(
|
|
152
|
+
pages.push(jsx("li", {
|
|
153
|
+
key: "ellipsis2",
|
|
154
|
+
style: {
|
|
155
|
+
all: 'unset'
|
|
156
|
+
}
|
|
157
|
+
}, ellipsis));
|
|
142
158
|
pages.push(this.renderPagesInInterval(totalPageNumber - boundaryCount + 1, totalPageNumber, currentPage));
|
|
143
159
|
} else {
|
|
144
160
|
pages.push(this.renderPagesInInterval(currentPage + 1, totalPageNumber, currentPage));
|
|
145
161
|
}
|
|
146
162
|
return jsx("ul", {
|
|
147
|
-
css: (_this$props$
|
|
163
|
+
css: (_this$props$styles3 = this.props.styles) === null || _this$props$styles3 === void 0 ? void 0 : _this$props$styles3.pageIndicatorList
|
|
148
164
|
}, pages);
|
|
149
165
|
};
|
|
150
166
|
this.renderDefaultArrowButton = direction => {
|
|
@@ -305,19 +321,26 @@ let Pagination = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
|
|
|
305
321
|
visiblePages = allPages.slice(sliceStart, sliceEnd);
|
|
306
322
|
const firstPage = allPages[firstIndex];
|
|
307
323
|
const lastPage = allPages[lastIndex];
|
|
308
|
-
if (sliceStart - firstIndex > 1) visiblePages.unshift(
|
|
324
|
+
if (sliceStart - firstIndex > 1) visiblePages.unshift(jsx("li", {
|
|
325
|
+
style: {
|
|
326
|
+
all: 'unset'
|
|
327
|
+
},
|
|
309
328
|
key: "first",
|
|
310
329
|
"aria-hidden": "true"
|
|
311
|
-
},
|
|
330
|
+
}, this.props.ellipsis));
|
|
312
331
|
if (sliceStart - firstIndex > 0) visiblePages.unshift(firstPage);
|
|
313
|
-
if (lastIndex - sliceEnd + 1 > 1) visiblePages.push(
|
|
332
|
+
if (lastIndex - sliceEnd + 1 > 1) visiblePages.push(jsx("li", {
|
|
333
|
+
style: {
|
|
334
|
+
all: 'unset'
|
|
335
|
+
},
|
|
314
336
|
key: "last",
|
|
315
337
|
"aria-hidden": "true"
|
|
316
|
-
},
|
|
338
|
+
}, this.props.ellipsis));
|
|
317
339
|
if (lastIndex - sliceEnd + 1 > 0) visiblePages.push(lastPage);
|
|
318
340
|
}
|
|
319
341
|
return jsx(View, {
|
|
320
|
-
display: "inline-block"
|
|
342
|
+
display: "inline-block",
|
|
343
|
+
as: "ul"
|
|
321
344
|
}, this.transferDisabledPropToChildren(visiblePages));
|
|
322
345
|
}
|
|
323
346
|
getArrowVariant(direction, currentPageIndex, pagesCount) {
|
|
@@ -389,7 +412,7 @@ let Pagination = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
|
|
|
389
412
|
}) : null;
|
|
390
413
|
}
|
|
391
414
|
render() {
|
|
392
|
-
var _this$props$
|
|
415
|
+
var _this$props$styles4, _this$props$styles5;
|
|
393
416
|
const currentPageIndex = fastFindIndex(this.childPages, p => p && p.props && p.props.current);
|
|
394
417
|
const passthroughProps = View.omitViewProps(omitProps(this.props, Pagination.allowedProps), Pagination);
|
|
395
418
|
return jsx(View, Object.assign({}, passthroughProps, {
|
|
@@ -397,11 +420,11 @@ let Pagination = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
|
|
|
397
420
|
as: this.props.as,
|
|
398
421
|
elementRef: this.handleElementRef,
|
|
399
422
|
margin: this.props.margin,
|
|
400
|
-
css: (_this$props$
|
|
423
|
+
css: (_this$props$styles4 = this.props.styles) === null || _this$props$styles4 === void 0 ? void 0 : _this$props$styles4.pagination,
|
|
401
424
|
"aria-labelledby": this.props.label ? this._labelId : void 0
|
|
402
425
|
}), this.props.label && this.renderLabel(), jsx(View, {
|
|
403
426
|
display: "inline-block",
|
|
404
|
-
css: (_this$props$
|
|
427
|
+
css: (_this$props$styles5 = this.props.styles) === null || _this$props$styles5 === void 0 ? void 0 : _this$props$styles5.pages
|
|
405
428
|
}, this.renderArrowButton('first', currentPageIndex), this.renderArrowButton('prev', currentPageIndex), this.inputMode ? this.renderPageInput(currentPageIndex) : this.renderPages(currentPageIndex), this.renderArrowButton('next', currentPageIndex), this.renderArrowButton('last', currentPageIndex)));
|
|
406
429
|
}
|
|
407
430
|
}, _Pagination.displayName = "Pagination", _Pagination.componentId = 'Pagination', _Pagination.propTypes = propTypes, _Pagination.allowedProps = allowedProps, _Pagination.defaultProps = {
|
|
@@ -417,11 +440,7 @@ let Pagination = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
|
|
|
417
440
|
currentPage: 1,
|
|
418
441
|
siblingCount: 1,
|
|
419
442
|
boundaryCount: 1,
|
|
420
|
-
ellipsis:
|
|
421
|
-
style: {
|
|
422
|
-
all: 'unset'
|
|
423
|
-
}
|
|
424
|
-
}, "..."),
|
|
443
|
+
ellipsis: '…',
|
|
425
444
|
renderPageIndicator: page => page
|
|
426
445
|
}, _Pagination.Page = PaginationButton, _Pagination.Navigation = PaginationArrowButton, _Pagination)) || _class) || _class) || _class);
|
|
427
446
|
export default Pagination;
|
|
@@ -101,7 +101,7 @@ describe('<Pagination />', () => {
|
|
|
101
101
|
variant: "compact",
|
|
102
102
|
labelNext: "Next",
|
|
103
103
|
labelPrev: "Prev"
|
|
104
|
-
},
|
|
104
|
+
}, buildPages(5))),
|
|
105
105
|
container = _render.container;
|
|
106
106
|
const axeCheck = await (0, _runAxeCheck.runAxeCheck)(container);
|
|
107
107
|
expect(axeCheck).toBe(true);
|
|
@@ -111,7 +111,7 @@ describe('<Pagination />', () => {
|
|
|
111
111
|
variant: "compact",
|
|
112
112
|
labelNext: "Next",
|
|
113
113
|
labelPrev: "Prev"
|
|
114
|
-
},
|
|
114
|
+
}, buildPages(8))),
|
|
115
115
|
container = _render2.container;
|
|
116
116
|
const axeCheck = await (0, _runAxeCheck.runAxeCheck)(container);
|
|
117
117
|
expect(axeCheck).toBe(true);
|
|
@@ -124,7 +124,7 @@ describe('<Pagination />', () => {
|
|
|
124
124
|
labelFirst: "First",
|
|
125
125
|
labelLast: "Last",
|
|
126
126
|
withFirstAndLastButton: true
|
|
127
|
-
},
|
|
127
|
+
}, buildPages(8))),
|
|
128
128
|
container = _render3.container;
|
|
129
129
|
const axeCheck = await (0, _runAxeCheck.runAxeCheck)(container);
|
|
130
130
|
expect(axeCheck).toBe(true);
|
|
@@ -138,7 +138,7 @@ describe('<Pagination />', () => {
|
|
|
138
138
|
labelLast: "Last",
|
|
139
139
|
withFirstAndLastButton: true,
|
|
140
140
|
showDisabledButtons: true
|
|
141
|
-
},
|
|
141
|
+
}, buildPages(8))),
|
|
142
142
|
container = _render4.container;
|
|
143
143
|
const axeCheck = await (0, _runAxeCheck.runAxeCheck)(container);
|
|
144
144
|
expect(axeCheck).toBe(true);
|
|
@@ -850,7 +850,7 @@ describe('<Pagination />', () => {
|
|
|
850
850
|
totalPageNumber: 9
|
|
851
851
|
}))),
|
|
852
852
|
container = _render24.container;
|
|
853
|
-
expect(container.firstChild).toHaveTextContent('12
|
|
853
|
+
expect(container.firstChild).toHaveTextContent('12…9Next Page');
|
|
854
854
|
});
|
|
855
855
|
it('should render the correct pages - 2', () => {
|
|
856
856
|
const _render25 = (0, _react2.render)(_Pagination3 || (_Pagination3 = /*#__PURE__*/_react.default.createElement(_index.Pagination, {
|
|
@@ -861,7 +861,7 @@ describe('<Pagination />', () => {
|
|
|
861
861
|
currentPage: 5
|
|
862
862
|
}))),
|
|
863
863
|
container = _render25.container;
|
|
864
|
-
expect(container.firstChild).toHaveTextContent('Previous Page1
|
|
864
|
+
expect(container.firstChild).toHaveTextContent('Previous Page1…456…9Next Page');
|
|
865
865
|
});
|
|
866
866
|
it('should render the correct pages - 3', () => {
|
|
867
867
|
const _render26 = (0, _react2.render)(_Pagination4 || (_Pagination4 = /*#__PURE__*/_react.default.createElement(_index.Pagination, {
|
|
@@ -887,7 +887,7 @@ describe('<Pagination />', () => {
|
|
|
887
887
|
boundaryCount: 2
|
|
888
888
|
}))),
|
|
889
889
|
container = _render27.container;
|
|
890
|
-
expect(container.firstChild).toHaveTextContent('Previous Page12
|
|
890
|
+
expect(container.firstChild).toHaveTextContent('Previous Page12…456…89Next Page');
|
|
891
891
|
});
|
|
892
892
|
it('should render the correct pages - 5', () => {
|
|
893
893
|
const _render28 = (0, _react2.render)(_Pagination6 || (_Pagination6 = /*#__PURE__*/_react.default.createElement(_index.Pagination, {
|
|
@@ -924,7 +924,7 @@ describe('<Pagination />', () => {
|
|
|
924
924
|
siblingCount: 1
|
|
925
925
|
}))),
|
|
926
926
|
container = _render30.container;
|
|
927
|
-
expect(container.firstChild).toHaveTextContent('123
|
|
927
|
+
expect(container.firstChild).toHaveTextContent('123…789Next Page');
|
|
928
928
|
});
|
|
929
929
|
it('should render the correct ellipsis', () => {
|
|
930
930
|
const _render31 = (0, _react2.render)(_Pagination9 || (_Pagination9 = /*#__PURE__*/_react.default.createElement(_index.Pagination, {
|
|
@@ -962,7 +962,7 @@ describe('<Pagination />', () => {
|
|
|
962
962
|
currentPage: 5678
|
|
963
963
|
}))),
|
|
964
964
|
container = _render33.container;
|
|
965
|
-
expect(container.firstChild).toHaveTextContent('Previous Page1
|
|
965
|
+
expect(container.firstChild).toHaveTextContent('Previous Page1…567756785679…1000000000000000Next Page');
|
|
966
966
|
});
|
|
967
967
|
it('should render first and last buttons', () => {
|
|
968
968
|
const _render34 = (0, _react2.render)(_Pagination11 || (_Pagination11 = /*#__PURE__*/_react.default.createElement(_index.Pagination, {
|
|
@@ -976,7 +976,7 @@ describe('<Pagination />', () => {
|
|
|
976
976
|
withFirstAndLastButton: true
|
|
977
977
|
}))),
|
|
978
978
|
container = _render34.container;
|
|
979
|
-
expect(container.firstChild).toHaveTextContent('First PagePrevious Page1
|
|
979
|
+
expect(container.firstChild).toHaveTextContent('First PagePrevious Page1…456…100Next PageLast Page');
|
|
980
980
|
});
|
|
981
981
|
it('should render every page if boundary and sibling counts are big enough', () => {
|
|
982
982
|
const _render35 = (0, _react2.render)(_Pagination12 || (_Pagination12 = /*#__PURE__*/_react.default.createElement(_index.Pagination, {
|
package/lib/Pagination/index.js
CHANGED
|
@@ -28,7 +28,7 @@ var _PaginationPageInput = require("./PaginationPageInput");
|
|
|
28
28
|
var _styles = _interopRequireDefault(require("./styles"));
|
|
29
29
|
var _theme = _interopRequireDefault(require("./theme"));
|
|
30
30
|
var _props = require("./props");
|
|
31
|
-
var _dec, _dec2, _dec3, _class, _Pagination
|
|
31
|
+
var _dec, _dec2, _dec3, _class, _Pagination;
|
|
32
32
|
/*
|
|
33
33
|
* The MIT License (MIT)
|
|
34
34
|
*
|
|
@@ -130,7 +130,7 @@ let Pagination = exports.Pagination = (_dec = (0, _withDeterministicId.withDeter
|
|
|
130
130
|
return pages;
|
|
131
131
|
};
|
|
132
132
|
this.renderDefaultPages = () => {
|
|
133
|
-
var _this$props$
|
|
133
|
+
var _this$props$styles3;
|
|
134
134
|
const _this$props4 = this.props,
|
|
135
135
|
ellipsis = _this$props4.ellipsis,
|
|
136
136
|
currentPage = _this$props4.currentPage,
|
|
@@ -140,14 +140,25 @@ let Pagination = exports.Pagination = (_dec = (0, _withDeterministicId.withDeter
|
|
|
140
140
|
variant = _this$props4.variant;
|
|
141
141
|
const pages = [];
|
|
142
142
|
if (totalPageNumber <= 2 * boundaryCount || totalPageNumber <= 1 + siblingCount + boundaryCount || variant === 'full') {
|
|
143
|
-
|
|
143
|
+
var _this$props$styles;
|
|
144
|
+
return (0, _emotion.jsx)("ul", {
|
|
145
|
+
css: (_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.pageIndicatorList
|
|
146
|
+
}, this.renderPagesInInterval(1, totalPageNumber, currentPage));
|
|
144
147
|
}
|
|
145
148
|
if (currentPage > boundaryCount + siblingCount + 1) {
|
|
146
149
|
pages.push(this.renderPagesInInterval(1, boundaryCount, currentPage));
|
|
147
|
-
pages.push(
|
|
150
|
+
pages.push((0, _emotion.jsx)("li", {
|
|
151
|
+
key: "ellipsis1",
|
|
152
|
+
style: {
|
|
153
|
+
all: 'unset'
|
|
154
|
+
}
|
|
155
|
+
}, ellipsis));
|
|
148
156
|
if (currentPage - siblingCount > totalPageNumber - boundaryCount + 1) {
|
|
157
|
+
var _this$props$styles2;
|
|
149
158
|
pages.push(this.renderPagesInInterval(totalPageNumber - boundaryCount + 1, totalPageNumber, currentPage));
|
|
150
|
-
return
|
|
159
|
+
return (0, _emotion.jsx)("ul", {
|
|
160
|
+
css: (_this$props$styles2 = this.props.styles) === null || _this$props$styles2 === void 0 ? void 0 : _this$props$styles2.pageIndicatorList
|
|
161
|
+
}, pages);
|
|
151
162
|
}
|
|
152
163
|
pages.push(this.renderPagesInInterval(currentPage - siblingCount, currentPage, currentPage));
|
|
153
164
|
} else {
|
|
@@ -155,13 +166,18 @@ let Pagination = exports.Pagination = (_dec = (0, _withDeterministicId.withDeter
|
|
|
155
166
|
}
|
|
156
167
|
if (currentPage < totalPageNumber - (siblingCount + boundaryCount)) {
|
|
157
168
|
pages.push(this.renderPagesInInterval(Math.max(currentPage, boundaryCount) + 1, currentPage + siblingCount, currentPage));
|
|
158
|
-
pages.push(
|
|
169
|
+
pages.push((0, _emotion.jsx)("li", {
|
|
170
|
+
key: "ellipsis2",
|
|
171
|
+
style: {
|
|
172
|
+
all: 'unset'
|
|
173
|
+
}
|
|
174
|
+
}, ellipsis));
|
|
159
175
|
pages.push(this.renderPagesInInterval(totalPageNumber - boundaryCount + 1, totalPageNumber, currentPage));
|
|
160
176
|
} else {
|
|
161
177
|
pages.push(this.renderPagesInInterval(currentPage + 1, totalPageNumber, currentPage));
|
|
162
178
|
}
|
|
163
179
|
return (0, _emotion.jsx)("ul", {
|
|
164
|
-
css: (_this$props$
|
|
180
|
+
css: (_this$props$styles3 = this.props.styles) === null || _this$props$styles3 === void 0 ? void 0 : _this$props$styles3.pageIndicatorList
|
|
165
181
|
}, pages);
|
|
166
182
|
};
|
|
167
183
|
this.renderDefaultArrowButton = direction => {
|
|
@@ -322,19 +338,26 @@ let Pagination = exports.Pagination = (_dec = (0, _withDeterministicId.withDeter
|
|
|
322
338
|
visiblePages = allPages.slice(sliceStart, sliceEnd);
|
|
323
339
|
const firstPage = allPages[firstIndex];
|
|
324
340
|
const lastPage = allPages[lastIndex];
|
|
325
|
-
if (sliceStart - firstIndex > 1) visiblePages.unshift(
|
|
341
|
+
if (sliceStart - firstIndex > 1) visiblePages.unshift((0, _emotion.jsx)("li", {
|
|
342
|
+
style: {
|
|
343
|
+
all: 'unset'
|
|
344
|
+
},
|
|
326
345
|
key: "first",
|
|
327
346
|
"aria-hidden": "true"
|
|
328
|
-
},
|
|
347
|
+
}, this.props.ellipsis));
|
|
329
348
|
if (sliceStart - firstIndex > 0) visiblePages.unshift(firstPage);
|
|
330
|
-
if (lastIndex - sliceEnd + 1 > 1) visiblePages.push(
|
|
349
|
+
if (lastIndex - sliceEnd + 1 > 1) visiblePages.push((0, _emotion.jsx)("li", {
|
|
350
|
+
style: {
|
|
351
|
+
all: 'unset'
|
|
352
|
+
},
|
|
331
353
|
key: "last",
|
|
332
354
|
"aria-hidden": "true"
|
|
333
|
-
},
|
|
355
|
+
}, this.props.ellipsis));
|
|
334
356
|
if (lastIndex - sliceEnd + 1 > 0) visiblePages.push(lastPage);
|
|
335
357
|
}
|
|
336
358
|
return (0, _emotion.jsx)(_View.View, {
|
|
337
|
-
display: "inline-block"
|
|
359
|
+
display: "inline-block",
|
|
360
|
+
as: "ul"
|
|
338
361
|
}, this.transferDisabledPropToChildren(visiblePages));
|
|
339
362
|
}
|
|
340
363
|
getArrowVariant(direction, currentPageIndex, pagesCount) {
|
|
@@ -406,7 +429,7 @@ let Pagination = exports.Pagination = (_dec = (0, _withDeterministicId.withDeter
|
|
|
406
429
|
}) : null;
|
|
407
430
|
}
|
|
408
431
|
render() {
|
|
409
|
-
var _this$props$
|
|
432
|
+
var _this$props$styles4, _this$props$styles5;
|
|
410
433
|
const currentPageIndex = fastFindIndex(this.childPages, p => p && p.props && p.props.current);
|
|
411
434
|
const passthroughProps = _View.View.omitViewProps((0, _omitProps.omitProps)(this.props, Pagination.allowedProps), Pagination);
|
|
412
435
|
return (0, _emotion.jsx)(_View.View, Object.assign({}, passthroughProps, {
|
|
@@ -414,11 +437,11 @@ let Pagination = exports.Pagination = (_dec = (0, _withDeterministicId.withDeter
|
|
|
414
437
|
as: this.props.as,
|
|
415
438
|
elementRef: this.handleElementRef,
|
|
416
439
|
margin: this.props.margin,
|
|
417
|
-
css: (_this$props$
|
|
440
|
+
css: (_this$props$styles4 = this.props.styles) === null || _this$props$styles4 === void 0 ? void 0 : _this$props$styles4.pagination,
|
|
418
441
|
"aria-labelledby": this.props.label ? this._labelId : void 0
|
|
419
442
|
}), this.props.label && this.renderLabel(), (0, _emotion.jsx)(_View.View, {
|
|
420
443
|
display: "inline-block",
|
|
421
|
-
css: (_this$props$
|
|
444
|
+
css: (_this$props$styles5 = this.props.styles) === null || _this$props$styles5 === void 0 ? void 0 : _this$props$styles5.pages
|
|
422
445
|
}, this.renderArrowButton('first', currentPageIndex), this.renderArrowButton('prev', currentPageIndex), this.inputMode ? this.renderPageInput(currentPageIndex) : this.renderPages(currentPageIndex), this.renderArrowButton('next', currentPageIndex), this.renderArrowButton('last', currentPageIndex)));
|
|
423
446
|
}
|
|
424
447
|
}, _Pagination.displayName = "Pagination", _Pagination.componentId = 'Pagination', _Pagination.propTypes = _props.propTypes, _Pagination.allowedProps = _props.allowedProps, _Pagination.defaultProps = {
|
|
@@ -434,11 +457,7 @@ let Pagination = exports.Pagination = (_dec = (0, _withDeterministicId.withDeter
|
|
|
434
457
|
currentPage: 1,
|
|
435
458
|
siblingCount: 1,
|
|
436
459
|
boundaryCount: 1,
|
|
437
|
-
ellipsis:
|
|
438
|
-
style: {
|
|
439
|
-
all: 'unset'
|
|
440
|
-
}
|
|
441
|
-
}, "..."),
|
|
460
|
+
ellipsis: '…',
|
|
442
461
|
renderPageIndicator: page => page
|
|
443
462
|
}, _Pagination.Page = _PaginationButton.PaginationButton, _Pagination.Navigation = _PaginationArrowButton.PaginationArrowButton, _Pagination)) || _class) || _class) || _class);
|
|
444
463
|
var _default = exports.default = Pagination;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-pagination",
|
|
3
|
-
"version": "10.10.1-snapshot-
|
|
3
|
+
"version": "10.10.1-snapshot-9",
|
|
4
4
|
"description": "A UI component library made by Instructure Inc.",
|
|
5
5
|
"author": "Instructure, Inc. Engineering and Product Design",
|
|
6
6
|
"module": "./es/index.js",
|
|
@@ -23,9 +23,9 @@
|
|
|
23
23
|
},
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@instructure/ui-axe-check": "10.10.1-snapshot-
|
|
27
|
-
"@instructure/ui-babel-preset": "10.10.1-snapshot-
|
|
28
|
-
"@instructure/ui-test-utils": "10.10.1-snapshot-
|
|
26
|
+
"@instructure/ui-axe-check": "10.10.1-snapshot-9",
|
|
27
|
+
"@instructure/ui-babel-preset": "10.10.1-snapshot-9",
|
|
28
|
+
"@instructure/ui-test-utils": "10.10.1-snapshot-9",
|
|
29
29
|
"@testing-library/jest-dom": "^6.6.3",
|
|
30
30
|
"@testing-library/react": "^16.0.1",
|
|
31
31
|
"@testing-library/user-event": "^14.5.2",
|
|
@@ -33,23 +33,23 @@
|
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@babel/runtime": "^7.26.0",
|
|
36
|
-
"@instructure/emotion": "10.10.1-snapshot-
|
|
37
|
-
"@instructure/shared-types": "10.10.1-snapshot-
|
|
38
|
-
"@instructure/ui-a11y-content": "10.10.1-snapshot-
|
|
39
|
-
"@instructure/ui-a11y-utils": "10.10.1-snapshot-
|
|
40
|
-
"@instructure/ui-buttons": "10.10.1-snapshot-
|
|
41
|
-
"@instructure/ui-dom-utils": "10.10.1-snapshot-
|
|
42
|
-
"@instructure/ui-icons": "10.10.1-snapshot-
|
|
43
|
-
"@instructure/ui-number-input": "10.10.1-snapshot-
|
|
44
|
-
"@instructure/ui-portal": "10.10.1-snapshot-
|
|
45
|
-
"@instructure/ui-prop-types": "10.10.1-snapshot-
|
|
46
|
-
"@instructure/ui-react-utils": "10.10.1-snapshot-
|
|
47
|
-
"@instructure/ui-testable": "10.10.1-snapshot-
|
|
48
|
-
"@instructure/ui-themes": "10.10.1-snapshot-
|
|
49
|
-
"@instructure/ui-tooltip": "10.10.1-snapshot-
|
|
50
|
-
"@instructure/ui-utils": "10.10.1-snapshot-
|
|
51
|
-
"@instructure/ui-view": "10.10.1-snapshot-
|
|
52
|
-
"@instructure/uid": "10.10.1-snapshot-
|
|
36
|
+
"@instructure/emotion": "10.10.1-snapshot-9",
|
|
37
|
+
"@instructure/shared-types": "10.10.1-snapshot-9",
|
|
38
|
+
"@instructure/ui-a11y-content": "10.10.1-snapshot-9",
|
|
39
|
+
"@instructure/ui-a11y-utils": "10.10.1-snapshot-9",
|
|
40
|
+
"@instructure/ui-buttons": "10.10.1-snapshot-9",
|
|
41
|
+
"@instructure/ui-dom-utils": "10.10.1-snapshot-9",
|
|
42
|
+
"@instructure/ui-icons": "10.10.1-snapshot-9",
|
|
43
|
+
"@instructure/ui-number-input": "10.10.1-snapshot-9",
|
|
44
|
+
"@instructure/ui-portal": "10.10.1-snapshot-9",
|
|
45
|
+
"@instructure/ui-prop-types": "10.10.1-snapshot-9",
|
|
46
|
+
"@instructure/ui-react-utils": "10.10.1-snapshot-9",
|
|
47
|
+
"@instructure/ui-testable": "10.10.1-snapshot-9",
|
|
48
|
+
"@instructure/ui-themes": "10.10.1-snapshot-9",
|
|
49
|
+
"@instructure/ui-tooltip": "10.10.1-snapshot-9",
|
|
50
|
+
"@instructure/ui-utils": "10.10.1-snapshot-9",
|
|
51
|
+
"@instructure/ui-view": "10.10.1-snapshot-9",
|
|
52
|
+
"@instructure/uid": "10.10.1-snapshot-9",
|
|
53
53
|
"prop-types": "^15.8.1"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
@@ -123,12 +123,9 @@ describe('<Pagination />', () => {
|
|
|
123
123
|
it('by default', async () => {
|
|
124
124
|
const { container } = render(
|
|
125
125
|
<Pagination variant="compact" labelNext="Next" labelPrev="Prev">
|
|
126
|
-
|
|
127
|
-
{buildPages(5)}
|
|
128
|
-
</ul>
|
|
126
|
+
{buildPages(5)}
|
|
129
127
|
</Pagination>
|
|
130
128
|
)
|
|
131
|
-
|
|
132
129
|
const axeCheck = await runAxeCheck(container)
|
|
133
130
|
expect(axeCheck).toBe(true)
|
|
134
131
|
})
|
|
@@ -136,7 +133,7 @@ describe('<Pagination />', () => {
|
|
|
136
133
|
it('by default with more pages', async () => {
|
|
137
134
|
const { container } = render(
|
|
138
135
|
<Pagination variant="compact" labelNext="Next" labelPrev="Prev">
|
|
139
|
-
|
|
136
|
+
{buildPages(8)}
|
|
140
137
|
</Pagination>
|
|
141
138
|
)
|
|
142
139
|
const axeCheck = await runAxeCheck(container)
|
|
@@ -153,7 +150,7 @@ describe('<Pagination />', () => {
|
|
|
153
150
|
labelLast="Last"
|
|
154
151
|
withFirstAndLastButton
|
|
155
152
|
>
|
|
156
|
-
|
|
153
|
+
{buildPages(8)}
|
|
157
154
|
</Pagination>
|
|
158
155
|
)
|
|
159
156
|
const axeCheck = await runAxeCheck(container)
|
|
@@ -171,7 +168,7 @@ describe('<Pagination />', () => {
|
|
|
171
168
|
withFirstAndLastButton
|
|
172
169
|
showDisabledButtons
|
|
173
170
|
>
|
|
174
|
-
|
|
171
|
+
{buildPages(8)}
|
|
175
172
|
</Pagination>
|
|
176
173
|
)
|
|
177
174
|
const axeCheck = await runAxeCheck(container)
|
|
@@ -966,7 +963,7 @@ describe('<Pagination />', () => {
|
|
|
966
963
|
totalPageNumber={9}
|
|
967
964
|
/>
|
|
968
965
|
)
|
|
969
|
-
expect(container.firstChild).toHaveTextContent('12
|
|
966
|
+
expect(container.firstChild).toHaveTextContent('12…9Next Page')
|
|
970
967
|
})
|
|
971
968
|
it('should render the correct pages - 2', () => {
|
|
972
969
|
const { container } = render(
|
|
@@ -979,7 +976,7 @@ describe('<Pagination />', () => {
|
|
|
979
976
|
/>
|
|
980
977
|
)
|
|
981
978
|
expect(container.firstChild).toHaveTextContent(
|
|
982
|
-
'Previous Page1
|
|
979
|
+
'Previous Page1…456…9Next Page'
|
|
983
980
|
)
|
|
984
981
|
})
|
|
985
982
|
it('should render the correct pages - 3', () => {
|
|
@@ -1011,7 +1008,7 @@ describe('<Pagination />', () => {
|
|
|
1011
1008
|
/>
|
|
1012
1009
|
)
|
|
1013
1010
|
expect(container.firstChild).toHaveTextContent(
|
|
1014
|
-
'Previous Page12
|
|
1011
|
+
'Previous Page12…456…89Next Page'
|
|
1015
1012
|
)
|
|
1016
1013
|
})
|
|
1017
1014
|
it('should render the correct pages - 5', () => {
|
|
@@ -1056,7 +1053,7 @@ describe('<Pagination />', () => {
|
|
|
1056
1053
|
siblingCount={1}
|
|
1057
1054
|
/>
|
|
1058
1055
|
)
|
|
1059
|
-
expect(container.firstChild).toHaveTextContent('123
|
|
1056
|
+
expect(container.firstChild).toHaveTextContent('123…789Next Page')
|
|
1060
1057
|
})
|
|
1061
1058
|
it('should render the correct ellipsis', () => {
|
|
1062
1059
|
const { container } = render(
|
|
@@ -1098,7 +1095,7 @@ describe('<Pagination />', () => {
|
|
|
1098
1095
|
/>
|
|
1099
1096
|
)
|
|
1100
1097
|
expect(container.firstChild).toHaveTextContent(
|
|
1101
|
-
'Previous Page1
|
|
1098
|
+
'Previous Page1…567756785679…1000000000000000Next Page'
|
|
1102
1099
|
)
|
|
1103
1100
|
})
|
|
1104
1101
|
it('should render first and last buttons', () => {
|
|
@@ -1115,7 +1112,7 @@ describe('<Pagination />', () => {
|
|
|
1115
1112
|
/>
|
|
1116
1113
|
)
|
|
1117
1114
|
expect(container.firstChild).toHaveTextContent(
|
|
1118
|
-
'First PagePrevious Page1
|
|
1115
|
+
'First PagePrevious Page1…456…100Next PageLast Page'
|
|
1119
1116
|
)
|
|
1120
1117
|
})
|
|
1121
1118
|
it('should render every page if boundary and sibling counts are big enough', () => {
|