@instructure/ui-pagination 10.6.1-snapshot-9 → 10.6.1-snapshot-13
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/PaginationButton/index.js +8 -2
- package/es/Pagination/__new-tests__/Pagination.test.js +4 -4
- package/es/Pagination/index.js +14 -6
- package/es/Pagination/styles.js +7 -1
- package/es/Pagination/theme.js +39 -0
- package/lib/Pagination/PaginationButton/index.js +8 -2
- package/lib/Pagination/__new-tests__/Pagination.test.js +4 -4
- package/lib/Pagination/index.js +14 -6
- package/lib/Pagination/styles.js +7 -1
- package/lib/Pagination/theme.js +45 -0
- package/package.json +21 -21
- package/src/Pagination/PaginationButton/index.tsx +13 -10
- package/src/Pagination/__new-tests__/Pagination.test.tsx +6 -4
- package/src/Pagination/index.tsx +4 -3
- package/src/Pagination/props.ts +3 -1
- package/src/Pagination/styles.ts +8 -1
- package/src/Pagination/theme.ts +45 -0
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/Pagination/PaginationButton/index.d.ts.map +1 -1
- package/types/Pagination/index.d.ts +1 -1
- package/types/Pagination/index.d.ts.map +1 -1
- package/types/Pagination/props.d.ts +1 -1
- package/types/Pagination/props.d.ts.map +1 -1
- package/types/Pagination/styles.d.ts +2 -1
- package/types/Pagination/styles.d.ts.map +1 -1
- package/types/Pagination/theme.d.ts +10 -0
- package/types/Pagination/theme.d.ts.map +1 -0
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.6.1-snapshot-
|
|
6
|
+
## [10.6.1-snapshot-13](https://github.com/instructure/instructure-ui/compare/v10.6.0...v10.6.1-snapshot-13) (2024-11-26)
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **shared-types,ui-pagination:** pagination indicators have spacing and coded as a list for a11y ([e6e5a7b](https://github.com/instructure/instructure-ui/commit/e6e5a7b6cda158f16cf0d86787130877b9c22a75))
|
|
9
12
|
|
|
10
13
|
|
|
11
14
|
|
|
@@ -45,14 +45,20 @@ let PaginationButton = (_dec = testable(), _dec(_class = (_PaginationButton = cl
|
|
|
45
45
|
render() {
|
|
46
46
|
const exclude = this.props.current ? ['onClick', 'href'] : [];
|
|
47
47
|
const props = omitProps(this.props, PaginationButton.allowedProps, exclude);
|
|
48
|
-
|
|
48
|
+
|
|
49
|
+
// wrapped in an unstyled <li> for better a11y
|
|
50
|
+
return /*#__PURE__*/React.createElement("li", {
|
|
51
|
+
style: {
|
|
52
|
+
all: 'unset'
|
|
53
|
+
}
|
|
54
|
+
}, /*#__PURE__*/React.createElement(BaseButton, Object.assign({
|
|
49
55
|
color: "primary",
|
|
50
56
|
withBackground: this.props.current,
|
|
51
57
|
withBorder: this.props.current
|
|
52
58
|
}, props, {
|
|
53
59
|
"aria-current": this.props.current ? 'page' : void 0,
|
|
54
60
|
elementRef: this.handleRef
|
|
55
|
-
}), this.props.children);
|
|
61
|
+
}), this.props.children));
|
|
56
62
|
}
|
|
57
63
|
}, _PaginationButton.displayName = "PaginationButton", _PaginationButton.componentId = 'Pagination.Page', _PaginationButton.propTypes = propTypes, _PaginationButton.allowedProps = allowedProps, _PaginationButton.defaultProps = {
|
|
58
64
|
current: false
|
|
@@ -99,7 +99,7 @@ describe('<Pagination />', () => {
|
|
|
99
99
|
variant: "compact",
|
|
100
100
|
labelNext: "Next",
|
|
101
101
|
labelPrev: "Prev"
|
|
102
|
-
}, buildPages(5))),
|
|
102
|
+
}, /*#__PURE__*/React.createElement("ul", null, 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
|
-
}, buildPages(8))),
|
|
112
|
+
}, /*#__PURE__*/React.createElement("ul", null, 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
|
-
}, buildPages(8))),
|
|
125
|
+
}, /*#__PURE__*/React.createElement("ul", null, 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
|
-
}, buildPages(8))),
|
|
139
|
+
}, /*#__PURE__*/React.createElement("ul", null, buildPages(8)))),
|
|
140
140
|
container = _render4.container;
|
|
141
141
|
const axeCheck = await runAxeCheck(container);
|
|
142
142
|
expect(axeCheck).toBe(true);
|
package/es/Pagination/index.js
CHANGED
|
@@ -34,6 +34,7 @@ import { PaginationButton } from './PaginationButton';
|
|
|
34
34
|
import { PaginationArrowButton } from './PaginationArrowButton';
|
|
35
35
|
import { PaginationPageInput } from './PaginationPageInput';
|
|
36
36
|
import generateStyle from './styles';
|
|
37
|
+
import generateComponentTheme from './theme';
|
|
37
38
|
import { propTypes, allowedProps } from './props';
|
|
38
39
|
/** This is an [].findIndex optimized to work on really big, but sparse, arrays */
|
|
39
40
|
const fastFindIndex = (arr, fn) => Number(Object.keys(arr).find(k => fn(arr[Number(k)])));
|
|
@@ -53,7 +54,7 @@ function propsHaveCompactView(props) {
|
|
|
53
54
|
category: components
|
|
54
55
|
---
|
|
55
56
|
**/
|
|
56
|
-
let Pagination = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
|
|
57
|
+
let Pagination = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, generateComponentTheme), _dec3 = testable(), _dec(_class = _dec2(_class = _dec3(_class = (_Pagination = class Pagination extends Component {
|
|
57
58
|
constructor(props) {
|
|
58
59
|
super(props);
|
|
59
60
|
this._labelId = void 0;
|
|
@@ -112,6 +113,7 @@ let Pagination = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
|
|
|
112
113
|
return pages;
|
|
113
114
|
};
|
|
114
115
|
this.renderDefaultPages = () => {
|
|
116
|
+
var _this$props$styles;
|
|
115
117
|
const _this$props4 = this.props,
|
|
116
118
|
ellipsis = _this$props4.ellipsis,
|
|
117
119
|
currentPage = _this$props4.currentPage,
|
|
@@ -141,7 +143,9 @@ let Pagination = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
|
|
|
141
143
|
} else {
|
|
142
144
|
pages.push(this.renderPagesInInterval(currentPage + 1, totalPageNumber, currentPage));
|
|
143
145
|
}
|
|
144
|
-
return
|
|
146
|
+
return jsx("ul", {
|
|
147
|
+
css: (_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.pageIndicatorList
|
|
148
|
+
}, pages);
|
|
145
149
|
};
|
|
146
150
|
this.renderDefaultArrowButton = direction => {
|
|
147
151
|
if (!this.withFirstAndLastButton && (direction === 'first' || direction === 'last')) {
|
|
@@ -385,7 +389,7 @@ let Pagination = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
|
|
|
385
389
|
}) : null;
|
|
386
390
|
}
|
|
387
391
|
render() {
|
|
388
|
-
var _this$props$
|
|
392
|
+
var _this$props$styles2, _this$props$styles3;
|
|
389
393
|
const currentPageIndex = fastFindIndex(this.childPages, p => p && p.props && p.props.current);
|
|
390
394
|
const passthroughProps = View.omitViewProps(omitProps(this.props, Pagination.allowedProps), Pagination);
|
|
391
395
|
return jsx(View, Object.assign({}, passthroughProps, {
|
|
@@ -393,11 +397,11 @@ let Pagination = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
|
|
|
393
397
|
as: this.props.as,
|
|
394
398
|
elementRef: this.handleElementRef,
|
|
395
399
|
margin: this.props.margin,
|
|
396
|
-
css: (_this$props$
|
|
400
|
+
css: (_this$props$styles2 = this.props.styles) === null || _this$props$styles2 === void 0 ? void 0 : _this$props$styles2.pagination,
|
|
397
401
|
"aria-labelledby": this.props.label ? this._labelId : void 0
|
|
398
402
|
}), this.props.label && this.renderLabel(), jsx(View, {
|
|
399
403
|
display: "inline-block",
|
|
400
|
-
css: (_this$props$
|
|
404
|
+
css: (_this$props$styles3 = this.props.styles) === null || _this$props$styles3 === void 0 ? void 0 : _this$props$styles3.pages
|
|
401
405
|
}, this.renderArrowButton('first', currentPageIndex), this.renderArrowButton('prev', currentPageIndex), this.inputMode ? this.renderPageInput(currentPageIndex) : this.renderPages(currentPageIndex), this.renderArrowButton('next', currentPageIndex), this.renderArrowButton('last', currentPageIndex)));
|
|
402
406
|
}
|
|
403
407
|
}, _Pagination.displayName = "Pagination", _Pagination.componentId = 'Pagination', _Pagination.propTypes = propTypes, _Pagination.allowedProps = allowedProps, _Pagination.defaultProps = {
|
|
@@ -413,7 +417,11 @@ let Pagination = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
|
|
|
413
417
|
currentPage: 1,
|
|
414
418
|
siblingCount: 1,
|
|
415
419
|
boundaryCount: 1,
|
|
416
|
-
ellipsis:
|
|
420
|
+
ellipsis: jsx("li", {
|
|
421
|
+
style: {
|
|
422
|
+
all: 'unset'
|
|
423
|
+
}
|
|
424
|
+
}, "..."),
|
|
417
425
|
renderPageIndicator: page => page
|
|
418
426
|
}, _Pagination.Page = PaginationButton, _Pagination.Navigation = PaginationArrowButton, _Pagination)) || _class) || _class) || _class);
|
|
419
427
|
export default Pagination;
|
package/es/Pagination/styles.js
CHANGED
|
@@ -32,8 +32,14 @@
|
|
|
32
32
|
* @param {Object} state the state of the component, the style is applied to
|
|
33
33
|
* @return {Object} The final style object, which will be used in the component
|
|
34
34
|
*/
|
|
35
|
-
const generateStyle =
|
|
35
|
+
const generateStyle = componentTheme => {
|
|
36
36
|
return {
|
|
37
|
+
pageIndicatorList: {
|
|
38
|
+
all: 'unset',
|
|
39
|
+
display: 'flex',
|
|
40
|
+
alignItems: 'center',
|
|
41
|
+
gap: componentTheme.pageIndicatorGap
|
|
42
|
+
},
|
|
37
43
|
pagination: {
|
|
38
44
|
label: 'pagination',
|
|
39
45
|
textAlign: 'center'
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The MIT License (MIT)
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Generates the theme object for the component from the theme and provided additional information
|
|
27
|
+
* @param {Object} theme The actual theme object.
|
|
28
|
+
* @return {Object} The final theme object with the overrides and component variables
|
|
29
|
+
*/
|
|
30
|
+
const generateComponentTheme = theme => {
|
|
31
|
+
const spacing = theme.spacing;
|
|
32
|
+
const componentVariables = {
|
|
33
|
+
pageIndicatorGap: spacing.xSmall
|
|
34
|
+
};
|
|
35
|
+
return {
|
|
36
|
+
...componentVariables
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
export default generateComponentTheme;
|
|
@@ -51,14 +51,20 @@ let PaginationButton = exports.PaginationButton = (_dec = (0, _testable.testable
|
|
|
51
51
|
render() {
|
|
52
52
|
const exclude = this.props.current ? ['onClick', 'href'] : [];
|
|
53
53
|
const props = (0, _omitProps.omitProps)(this.props, PaginationButton.allowedProps, exclude);
|
|
54
|
-
|
|
54
|
+
|
|
55
|
+
// wrapped in an unstyled <li> for better a11y
|
|
56
|
+
return /*#__PURE__*/_react.default.createElement("li", {
|
|
57
|
+
style: {
|
|
58
|
+
all: 'unset'
|
|
59
|
+
}
|
|
60
|
+
}, /*#__PURE__*/_react.default.createElement(_BaseButton.BaseButton, Object.assign({
|
|
55
61
|
color: "primary",
|
|
56
62
|
withBackground: this.props.current,
|
|
57
63
|
withBorder: this.props.current
|
|
58
64
|
}, props, {
|
|
59
65
|
"aria-current": this.props.current ? 'page' : void 0,
|
|
60
66
|
elementRef: this.handleRef
|
|
61
|
-
}), this.props.children);
|
|
67
|
+
}), this.props.children));
|
|
62
68
|
}
|
|
63
69
|
}, _PaginationButton.displayName = "PaginationButton", _PaginationButton.componentId = 'Pagination.Page', _PaginationButton.propTypes = _props.propTypes, _PaginationButton.allowedProps = _props.allowedProps, _PaginationButton.defaultProps = {
|
|
64
70
|
current: false
|
|
@@ -101,7 +101,7 @@ describe('<Pagination />', () => {
|
|
|
101
101
|
variant: "compact",
|
|
102
102
|
labelNext: "Next",
|
|
103
103
|
labelPrev: "Prev"
|
|
104
|
-
}, buildPages(5))),
|
|
104
|
+
}, /*#__PURE__*/_react.default.createElement("ul", null, 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
|
-
}, buildPages(8))),
|
|
114
|
+
}, /*#__PURE__*/_react.default.createElement("ul", null, 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
|
-
}, buildPages(8))),
|
|
127
|
+
}, /*#__PURE__*/_react.default.createElement("ul", null, 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
|
-
}, buildPages(8))),
|
|
141
|
+
}, /*#__PURE__*/_react.default.createElement("ul", null, buildPages(8)))),
|
|
142
142
|
container = _render4.container;
|
|
143
143
|
const axeCheck = await (0, _runAxeCheck.runAxeCheck)(container);
|
|
144
144
|
expect(axeCheck).toBe(true);
|
package/lib/Pagination/index.js
CHANGED
|
@@ -26,6 +26,7 @@ var _PaginationButton = require("./PaginationButton");
|
|
|
26
26
|
var _PaginationArrowButton = require("./PaginationArrowButton");
|
|
27
27
|
var _PaginationPageInput = require("./PaginationPageInput");
|
|
28
28
|
var _styles = _interopRequireDefault(require("./styles"));
|
|
29
|
+
var _theme = _interopRequireDefault(require("./theme"));
|
|
29
30
|
var _props = require("./props");
|
|
30
31
|
var _dec, _dec2, _dec3, _class, _Pagination, _span, _span2;
|
|
31
32
|
/*
|
|
@@ -70,7 +71,7 @@ function propsHaveCompactView(props) {
|
|
|
70
71
|
category: components
|
|
71
72
|
---
|
|
72
73
|
**/
|
|
73
|
-
let Pagination = exports.Pagination = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (0, _emotion.withStyle)(_styles.default,
|
|
74
|
+
let Pagination = exports.Pagination = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec3 = (0, _testable.testable)(), _dec(_class = _dec2(_class = _dec3(_class = (_Pagination = class Pagination extends _react.Component {
|
|
74
75
|
constructor(props) {
|
|
75
76
|
super(props);
|
|
76
77
|
this._labelId = void 0;
|
|
@@ -129,6 +130,7 @@ let Pagination = exports.Pagination = (_dec = (0, _withDeterministicId.withDeter
|
|
|
129
130
|
return pages;
|
|
130
131
|
};
|
|
131
132
|
this.renderDefaultPages = () => {
|
|
133
|
+
var _this$props$styles;
|
|
132
134
|
const _this$props4 = this.props,
|
|
133
135
|
ellipsis = _this$props4.ellipsis,
|
|
134
136
|
currentPage = _this$props4.currentPage,
|
|
@@ -158,7 +160,9 @@ let Pagination = exports.Pagination = (_dec = (0, _withDeterministicId.withDeter
|
|
|
158
160
|
} else {
|
|
159
161
|
pages.push(this.renderPagesInInterval(currentPage + 1, totalPageNumber, currentPage));
|
|
160
162
|
}
|
|
161
|
-
return
|
|
163
|
+
return (0, _emotion.jsx)("ul", {
|
|
164
|
+
css: (_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.pageIndicatorList
|
|
165
|
+
}, pages);
|
|
162
166
|
};
|
|
163
167
|
this.renderDefaultArrowButton = direction => {
|
|
164
168
|
if (!this.withFirstAndLastButton && (direction === 'first' || direction === 'last')) {
|
|
@@ -402,7 +406,7 @@ let Pagination = exports.Pagination = (_dec = (0, _withDeterministicId.withDeter
|
|
|
402
406
|
}) : null;
|
|
403
407
|
}
|
|
404
408
|
render() {
|
|
405
|
-
var _this$props$
|
|
409
|
+
var _this$props$styles2, _this$props$styles3;
|
|
406
410
|
const currentPageIndex = fastFindIndex(this.childPages, p => p && p.props && p.props.current);
|
|
407
411
|
const passthroughProps = _View.View.omitViewProps((0, _omitProps.omitProps)(this.props, Pagination.allowedProps), Pagination);
|
|
408
412
|
return (0, _emotion.jsx)(_View.View, Object.assign({}, passthroughProps, {
|
|
@@ -410,11 +414,11 @@ let Pagination = exports.Pagination = (_dec = (0, _withDeterministicId.withDeter
|
|
|
410
414
|
as: this.props.as,
|
|
411
415
|
elementRef: this.handleElementRef,
|
|
412
416
|
margin: this.props.margin,
|
|
413
|
-
css: (_this$props$
|
|
417
|
+
css: (_this$props$styles2 = this.props.styles) === null || _this$props$styles2 === void 0 ? void 0 : _this$props$styles2.pagination,
|
|
414
418
|
"aria-labelledby": this.props.label ? this._labelId : void 0
|
|
415
419
|
}), this.props.label && this.renderLabel(), (0, _emotion.jsx)(_View.View, {
|
|
416
420
|
display: "inline-block",
|
|
417
|
-
css: (_this$props$
|
|
421
|
+
css: (_this$props$styles3 = this.props.styles) === null || _this$props$styles3 === void 0 ? void 0 : _this$props$styles3.pages
|
|
418
422
|
}, this.renderArrowButton('first', currentPageIndex), this.renderArrowButton('prev', currentPageIndex), this.inputMode ? this.renderPageInput(currentPageIndex) : this.renderPages(currentPageIndex), this.renderArrowButton('next', currentPageIndex), this.renderArrowButton('last', currentPageIndex)));
|
|
419
423
|
}
|
|
420
424
|
}, _Pagination.displayName = "Pagination", _Pagination.componentId = 'Pagination', _Pagination.propTypes = _props.propTypes, _Pagination.allowedProps = _props.allowedProps, _Pagination.defaultProps = {
|
|
@@ -430,7 +434,11 @@ let Pagination = exports.Pagination = (_dec = (0, _withDeterministicId.withDeter
|
|
|
430
434
|
currentPage: 1,
|
|
431
435
|
siblingCount: 1,
|
|
432
436
|
boundaryCount: 1,
|
|
433
|
-
ellipsis:
|
|
437
|
+
ellipsis: (0, _emotion.jsx)("li", {
|
|
438
|
+
style: {
|
|
439
|
+
all: 'unset'
|
|
440
|
+
}
|
|
441
|
+
}, "..."),
|
|
434
442
|
renderPageIndicator: page => page
|
|
435
443
|
}, _Pagination.Page = _PaginationButton.PaginationButton, _Pagination.Navigation = _PaginationArrowButton.PaginationArrowButton, _Pagination)) || _class) || _class) || _class);
|
|
436
444
|
var _default = exports.default = Pagination;
|
package/lib/Pagination/styles.js
CHANGED
|
@@ -38,8 +38,14 @@ exports.default = void 0;
|
|
|
38
38
|
* @param {Object} state the state of the component, the style is applied to
|
|
39
39
|
* @return {Object} The final style object, which will be used in the component
|
|
40
40
|
*/
|
|
41
|
-
const generateStyle =
|
|
41
|
+
const generateStyle = componentTheme => {
|
|
42
42
|
return {
|
|
43
|
+
pageIndicatorList: {
|
|
44
|
+
all: 'unset',
|
|
45
|
+
display: 'flex',
|
|
46
|
+
alignItems: 'center',
|
|
47
|
+
gap: componentTheme.pageIndicatorGap
|
|
48
|
+
},
|
|
43
49
|
pagination: {
|
|
44
50
|
label: 'pagination',
|
|
45
51
|
textAlign: 'center'
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
/*
|
|
8
|
+
* The MIT License (MIT)
|
|
9
|
+
*
|
|
10
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
11
|
+
*
|
|
12
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
13
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
14
|
+
* in the Software without restriction, including without limitation the rights
|
|
15
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
16
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
17
|
+
* furnished to do so, subject to the following conditions:
|
|
18
|
+
*
|
|
19
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
20
|
+
* copies or substantial portions of the Software.
|
|
21
|
+
*
|
|
22
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
23
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
24
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
25
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
26
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
27
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
28
|
+
* SOFTWARE.
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Generates the theme object for the component from the theme and provided additional information
|
|
33
|
+
* @param {Object} theme The actual theme object.
|
|
34
|
+
* @return {Object} The final theme object with the overrides and component variables
|
|
35
|
+
*/
|
|
36
|
+
const generateComponentTheme = theme => {
|
|
37
|
+
const spacing = theme.spacing;
|
|
38
|
+
const componentVariables = {
|
|
39
|
+
pageIndicatorGap: spacing.xSmall
|
|
40
|
+
};
|
|
41
|
+
return {
|
|
42
|
+
...componentVariables
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
var _default = exports.default = generateComponentTheme;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-pagination",
|
|
3
|
-
"version": "10.6.1-snapshot-
|
|
3
|
+
"version": "10.6.1-snapshot-13",
|
|
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.6.1-snapshot-
|
|
27
|
-
"@instructure/ui-babel-preset": "10.6.1-snapshot-
|
|
28
|
-
"@instructure/ui-test-utils": "10.6.1-snapshot-
|
|
26
|
+
"@instructure/ui-axe-check": "10.6.1-snapshot-13",
|
|
27
|
+
"@instructure/ui-babel-preset": "10.6.1-snapshot-13",
|
|
28
|
+
"@instructure/ui-test-utils": "10.6.1-snapshot-13",
|
|
29
29
|
"@testing-library/jest-dom": "^6.4.6",
|
|
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.25.6",
|
|
36
|
-
"@instructure/emotion": "10.6.1-snapshot-
|
|
37
|
-
"@instructure/shared-types": "10.6.1-snapshot-
|
|
38
|
-
"@instructure/ui-a11y-content": "10.6.1-snapshot-
|
|
39
|
-
"@instructure/ui-a11y-utils": "10.6.1-snapshot-
|
|
40
|
-
"@instructure/ui-buttons": "10.6.1-snapshot-
|
|
41
|
-
"@instructure/ui-dom-utils": "10.6.1-snapshot-
|
|
42
|
-
"@instructure/ui-icons": "10.6.1-snapshot-
|
|
43
|
-
"@instructure/ui-number-input": "10.6.1-snapshot-
|
|
44
|
-
"@instructure/ui-portal": "10.6.1-snapshot-
|
|
45
|
-
"@instructure/ui-prop-types": "10.6.1-snapshot-
|
|
46
|
-
"@instructure/ui-react-utils": "10.6.1-snapshot-
|
|
47
|
-
"@instructure/ui-testable": "10.6.1-snapshot-
|
|
48
|
-
"@instructure/ui-themes": "10.6.1-snapshot-
|
|
49
|
-
"@instructure/ui-tooltip": "10.6.1-snapshot-
|
|
50
|
-
"@instructure/ui-utils": "10.6.1-snapshot-
|
|
51
|
-
"@instructure/ui-view": "10.6.1-snapshot-
|
|
52
|
-
"@instructure/uid": "10.6.1-snapshot-
|
|
36
|
+
"@instructure/emotion": "10.6.1-snapshot-13",
|
|
37
|
+
"@instructure/shared-types": "10.6.1-snapshot-13",
|
|
38
|
+
"@instructure/ui-a11y-content": "10.6.1-snapshot-13",
|
|
39
|
+
"@instructure/ui-a11y-utils": "10.6.1-snapshot-13",
|
|
40
|
+
"@instructure/ui-buttons": "10.6.1-snapshot-13",
|
|
41
|
+
"@instructure/ui-dom-utils": "10.6.1-snapshot-13",
|
|
42
|
+
"@instructure/ui-icons": "10.6.1-snapshot-13",
|
|
43
|
+
"@instructure/ui-number-input": "10.6.1-snapshot-13",
|
|
44
|
+
"@instructure/ui-portal": "10.6.1-snapshot-13",
|
|
45
|
+
"@instructure/ui-prop-types": "10.6.1-snapshot-13",
|
|
46
|
+
"@instructure/ui-react-utils": "10.6.1-snapshot-13",
|
|
47
|
+
"@instructure/ui-testable": "10.6.1-snapshot-13",
|
|
48
|
+
"@instructure/ui-themes": "10.6.1-snapshot-13",
|
|
49
|
+
"@instructure/ui-tooltip": "10.6.1-snapshot-13",
|
|
50
|
+
"@instructure/ui-utils": "10.6.1-snapshot-13",
|
|
51
|
+
"@instructure/ui-view": "10.6.1-snapshot-13",
|
|
52
|
+
"@instructure/uid": "10.6.1-snapshot-13",
|
|
53
53
|
"prop-types": "^15.8.1"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
@@ -59,17 +59,20 @@ class PaginationButton extends Component<PaginationPageProps> {
|
|
|
59
59
|
|
|
60
60
|
const props = omitProps(this.props, PaginationButton.allowedProps, exclude)
|
|
61
61
|
|
|
62
|
+
// wrapped in an unstyled <li> for better a11y
|
|
62
63
|
return (
|
|
63
|
-
<
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
64
|
+
<li style={{ all: 'unset' }}>
|
|
65
|
+
<BaseButton
|
|
66
|
+
color="primary"
|
|
67
|
+
withBackground={this.props.current}
|
|
68
|
+
withBorder={this.props.current}
|
|
69
|
+
{...props}
|
|
70
|
+
aria-current={this.props.current ? 'page' : undefined}
|
|
71
|
+
elementRef={this.handleRef}
|
|
72
|
+
>
|
|
73
|
+
{this.props.children}
|
|
74
|
+
</BaseButton>
|
|
75
|
+
</li>
|
|
73
76
|
)
|
|
74
77
|
}
|
|
75
78
|
}
|
|
@@ -123,7 +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
|
-
|
|
126
|
+
<ul>
|
|
127
|
+
{buildPages(5)}
|
|
128
|
+
</ul>
|
|
127
129
|
</Pagination>
|
|
128
130
|
)
|
|
129
131
|
|
|
@@ -134,7 +136,7 @@ describe('<Pagination />', () => {
|
|
|
134
136
|
it('by default with more pages', async () => {
|
|
135
137
|
const { container } = render(
|
|
136
138
|
<Pagination variant="compact" labelNext="Next" labelPrev="Prev">
|
|
137
|
-
{buildPages(8)}
|
|
139
|
+
<ul>{buildPages(8)}</ul>
|
|
138
140
|
</Pagination>
|
|
139
141
|
)
|
|
140
142
|
const axeCheck = await runAxeCheck(container)
|
|
@@ -151,7 +153,7 @@ describe('<Pagination />', () => {
|
|
|
151
153
|
labelLast="Last"
|
|
152
154
|
withFirstAndLastButton
|
|
153
155
|
>
|
|
154
|
-
{buildPages(8)}
|
|
156
|
+
<ul>{buildPages(8)}</ul>
|
|
155
157
|
</Pagination>
|
|
156
158
|
)
|
|
157
159
|
const axeCheck = await runAxeCheck(container)
|
|
@@ -169,7 +171,7 @@ describe('<Pagination />', () => {
|
|
|
169
171
|
withFirstAndLastButton
|
|
170
172
|
showDisabledButtons
|
|
171
173
|
>
|
|
172
|
-
{buildPages(8)}
|
|
174
|
+
<ul>{buildPages(8)}</ul>
|
|
173
175
|
</Pagination>
|
|
174
176
|
)
|
|
175
177
|
const axeCheck = await runAxeCheck(container)
|
package/src/Pagination/index.tsx
CHANGED
|
@@ -36,6 +36,7 @@ import { PaginationArrowButton } from './PaginationArrowButton'
|
|
|
36
36
|
import { PaginationPageInput } from './PaginationPageInput'
|
|
37
37
|
|
|
38
38
|
import generateStyle from './styles'
|
|
39
|
+
import generateComponentTheme from './theme'
|
|
39
40
|
|
|
40
41
|
import type { PaginationPageProps } from './PaginationButton/props'
|
|
41
42
|
import type { PaginationArrowDirections } from './PaginationArrowButton/props'
|
|
@@ -80,7 +81,7 @@ category: components
|
|
|
80
81
|
---
|
|
81
82
|
**/
|
|
82
83
|
@withDeterministicId()
|
|
83
|
-
@withStyle(generateStyle,
|
|
84
|
+
@withStyle(generateStyle, generateComponentTheme)
|
|
84
85
|
@testable()
|
|
85
86
|
class Pagination extends Component<PaginationProps> {
|
|
86
87
|
static readonly componentId = 'Pagination'
|
|
@@ -103,7 +104,7 @@ class Pagination extends Component<PaginationProps> {
|
|
|
103
104
|
currentPage: 1,
|
|
104
105
|
siblingCount: 1,
|
|
105
106
|
boundaryCount: 1,
|
|
106
|
-
ellipsis: '
|
|
107
|
+
ellipsis: <li style={{all: 'unset'}}>...</li>,
|
|
107
108
|
renderPageIndicator: (page: number) => page
|
|
108
109
|
}
|
|
109
110
|
|
|
@@ -408,7 +409,7 @@ class Pagination extends Component<PaginationProps> {
|
|
|
408
409
|
)
|
|
409
410
|
)
|
|
410
411
|
}
|
|
411
|
-
return pages
|
|
412
|
+
return (<ul css={this.props.styles?.pageIndicatorList}>{pages}</ul>)
|
|
412
413
|
}
|
|
413
414
|
|
|
414
415
|
renderPages(currentPageIndex: number) {
|
package/src/Pagination/props.ts
CHANGED
|
@@ -197,7 +197,9 @@ type PaginationProps = PaginationOwnProps &
|
|
|
197
197
|
OtherHTMLAttributes<PaginationOwnProps> &
|
|
198
198
|
WithDeterministicIdProps
|
|
199
199
|
|
|
200
|
-
type PaginationStyle = ComponentStyle<
|
|
200
|
+
type PaginationStyle = ComponentStyle<
|
|
201
|
+
'pagination' | 'pages' | 'pageIndicatorList'
|
|
202
|
+
>
|
|
201
203
|
|
|
202
204
|
const propTypes: PropValidators<PropKeys> = {
|
|
203
205
|
children: Children.oneOf([PaginationButton]),
|
package/src/Pagination/styles.ts
CHANGED
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
|
+
import type { PaginationTheme } from '@instructure/shared-types'
|
|
25
26
|
import type { PaginationStyle } from './props'
|
|
26
27
|
|
|
27
28
|
/**
|
|
@@ -34,8 +35,14 @@ import type { PaginationStyle } from './props'
|
|
|
34
35
|
* @param {Object} state the state of the component, the style is applied to
|
|
35
36
|
* @return {Object} The final style object, which will be used in the component
|
|
36
37
|
*/
|
|
37
|
-
const generateStyle = (): PaginationStyle => {
|
|
38
|
+
const generateStyle = (componentTheme: PaginationTheme): PaginationStyle => {
|
|
38
39
|
return {
|
|
40
|
+
pageIndicatorList: {
|
|
41
|
+
all: 'unset',
|
|
42
|
+
display: 'flex',
|
|
43
|
+
alignItems: 'center',
|
|
44
|
+
gap: componentTheme.pageIndicatorGap
|
|
45
|
+
},
|
|
39
46
|
pagination: {
|
|
40
47
|
label: 'pagination',
|
|
41
48
|
textAlign: 'center'
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The MIT License (MIT)
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import type { Theme } from '@instructure/ui-themes'
|
|
26
|
+
import { PaginationTheme } from '@instructure/shared-types'
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Generates the theme object for the component from the theme and provided additional information
|
|
30
|
+
* @param {Object} theme The actual theme object.
|
|
31
|
+
* @return {Object} The final theme object with the overrides and component variables
|
|
32
|
+
*/
|
|
33
|
+
const generateComponentTheme = (theme: Theme): PaginationTheme => {
|
|
34
|
+
const { spacing } = theme
|
|
35
|
+
|
|
36
|
+
const componentVariables: PaginationTheme = {
|
|
37
|
+
pageIndicatorGap: spacing.xSmall
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return {
|
|
41
|
+
...componentVariables
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export default generateComponentTheme
|