@instructure/ui-pagination 8.33.1 → 8.33.2-snapshot-5
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 +8 -0
- package/es/Pagination/PaginationArrowButton/PaginationArrowButtonLocator.js +5 -4
- package/es/Pagination/PaginationArrowButton/index.js +6 -19
- package/es/Pagination/PaginationArrowButton/props.js +5 -1
- package/es/Pagination/PaginationButton/index.js +1 -5
- package/es/Pagination/PaginationButton/props.js +5 -1
- package/es/Pagination/PaginationLocator.js +4 -2
- package/es/Pagination/PaginationPageInput/PaginationPageInputLocator.js +5 -2
- package/es/Pagination/PaginationPageInput/index.js +15 -40
- package/es/Pagination/PaginationPageInput/props.js +1 -0
- package/es/Pagination/PaginationPageInput/styles.js +0 -1
- package/es/Pagination/PaginationPageInput/theme.js +2 -2
- package/es/Pagination/index.js +11 -57
- package/es/Pagination/locator.js +1 -0
- package/es/Pagination/props.js +1 -0
- package/es/Pagination/styles.js +0 -1
- package/es/index.js +1 -0
- package/lib/Pagination/PaginationArrowButton/PaginationArrowButtonLocator.js +4 -7
- package/lib/Pagination/PaginationArrowButton/index.js +4 -31
- package/lib/Pagination/PaginationArrowButton/locator.js +0 -2
- package/lib/Pagination/PaginationArrowButton/props.js +4 -4
- package/lib/Pagination/PaginationButton/index.js +0 -11
- package/lib/Pagination/PaginationButton/props.js +4 -4
- package/lib/Pagination/PaginationLocator.js +3 -6
- package/lib/Pagination/PaginationPageInput/PaginationPageInputLocator.js +4 -5
- package/lib/Pagination/PaginationPageInput/index.js +14 -49
- package/lib/Pagination/PaginationPageInput/props.js +1 -3
- package/lib/Pagination/PaginationPageInput/styles.js +0 -2
- package/lib/Pagination/PaginationPageInput/theme.js +2 -3
- package/lib/Pagination/index.js +11 -74
- package/lib/Pagination/locator.js +0 -2
- package/lib/Pagination/props.js +1 -6
- package/lib/Pagination/styles.js +0 -2
- package/lib/index.js +0 -1
- package/package.json +21 -21
- package/tsconfig.build.tsbuildinfo +1 -1
|
@@ -1,32 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
|
-
|
|
5
4
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
6
|
-
|
|
7
5
|
Object.defineProperty(exports, "__esModule", {
|
|
8
6
|
value: true
|
|
9
7
|
});
|
|
10
8
|
exports.default = exports.PaginationPageInput = void 0;
|
|
11
|
-
|
|
12
9
|
var _react = _interopRequireWildcard(require("react"));
|
|
13
|
-
|
|
14
10
|
var _testable = require("@instructure/ui-testable/lib/testable.js");
|
|
15
|
-
|
|
16
11
|
var _emotion = require("@instructure/emotion");
|
|
17
|
-
|
|
18
12
|
var _NumberInput = require("@instructure/ui-number-input/lib/NumberInput");
|
|
19
|
-
|
|
20
13
|
var _ScreenReaderContent = require("@instructure/ui-a11y-content/lib/ScreenReaderContent");
|
|
21
|
-
|
|
22
14
|
var _styles = _interopRequireDefault(require("./styles"));
|
|
23
|
-
|
|
24
15
|
var _theme = _interopRequireDefault(require("./theme"));
|
|
25
|
-
|
|
26
16
|
var _props = require("./props");
|
|
27
|
-
|
|
28
17
|
var _dec, _dec2, _class, _class2;
|
|
29
|
-
|
|
30
18
|
/**
|
|
31
19
|
---
|
|
32
20
|
parent: Pagination
|
|
@@ -38,108 +26,89 @@ let PaginationPageInput = (_dec = (0, _emotion.withStyle)(_styles.default, _them
|
|
|
38
26
|
constructor(props) {
|
|
39
27
|
super(props);
|
|
40
28
|
this.ref = null;
|
|
41
|
-
|
|
42
29
|
this.handleRef = el => {
|
|
43
30
|
this.ref = el;
|
|
44
31
|
};
|
|
45
|
-
|
|
46
32
|
this.handleInputRef = el => {
|
|
47
33
|
if (typeof this.props.inputRef === 'function') {
|
|
48
34
|
this.props.inputRef(el);
|
|
49
35
|
}
|
|
50
36
|
};
|
|
51
|
-
|
|
52
37
|
this.handleChange = (_event, value) => {
|
|
53
|
-
let newValue = value;
|
|
38
|
+
let newValue = value;
|
|
54
39
|
|
|
40
|
+
// if the last character was not a number, don't accept it
|
|
55
41
|
if (value.length > 0 && isNaN(value.slice(-1))) {
|
|
56
42
|
newValue = value.slice(0, -1);
|
|
57
43
|
}
|
|
58
|
-
|
|
59
44
|
this.setState({
|
|
60
45
|
number: newValue ? Number(newValue) : this.MIN,
|
|
61
46
|
value: newValue
|
|
62
47
|
});
|
|
63
48
|
};
|
|
64
|
-
|
|
65
49
|
this.handleDecrement = event => {
|
|
66
50
|
this.setNewPage(event, Math.floor(this.currentPage - 1));
|
|
67
51
|
};
|
|
68
|
-
|
|
69
52
|
this.handleIncrement = event => {
|
|
70
53
|
this.setNewPage(event, Math.floor(this.currentPage + 1));
|
|
71
54
|
};
|
|
72
|
-
|
|
73
55
|
this.handleBlur = event => {
|
|
74
56
|
this.setNewPage(event, Math.round(this.state.number));
|
|
75
57
|
};
|
|
76
|
-
|
|
77
58
|
this.state = this.initialState;
|
|
78
59
|
}
|
|
79
|
-
|
|
80
60
|
get currentPage() {
|
|
81
61
|
return this.props.currentPageIndex + 1;
|
|
82
62
|
}
|
|
83
|
-
|
|
84
63
|
get initialState() {
|
|
85
64
|
return {
|
|
86
65
|
number: this.currentPage,
|
|
87
66
|
value: `${this.currentPage}`
|
|
88
67
|
};
|
|
89
68
|
}
|
|
90
|
-
|
|
91
69
|
get MIN() {
|
|
92
70
|
return 1;
|
|
93
71
|
}
|
|
94
|
-
|
|
95
72
|
get MAX() {
|
|
96
73
|
return this.props.numberOfPages;
|
|
97
74
|
}
|
|
98
|
-
|
|
99
75
|
componentDidMount() {
|
|
100
76
|
var _this$props$makeStyle, _this$props;
|
|
101
|
-
|
|
102
77
|
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
|
|
103
78
|
}
|
|
104
|
-
|
|
105
79
|
componentDidUpdate(prevProps) {
|
|
106
80
|
var _this$props$makeStyle2, _this$props2;
|
|
81
|
+
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
|
|
107
82
|
|
|
108
|
-
|
|
83
|
+
// when the current page changes from outside (e.g.: from arrow buttons),
|
|
109
84
|
// we update the initial state
|
|
110
|
-
|
|
111
85
|
if (this.props.currentPageIndex !== prevProps.currentPageIndex) {
|
|
112
86
|
this.resetInitialState();
|
|
113
87
|
}
|
|
114
88
|
}
|
|
115
|
-
|
|
116
89
|
resetInitialState() {
|
|
117
90
|
this.setState(this.initialState);
|
|
118
91
|
}
|
|
119
|
-
|
|
120
92
|
handleKeyDown(event) {
|
|
121
93
|
const key = event.key;
|
|
122
|
-
|
|
123
94
|
if (key.toLowerCase() === 'enter') {
|
|
124
95
|
const _this$state = this.state,
|
|
125
|
-
|
|
126
|
-
|
|
96
|
+
value = _this$state.value,
|
|
97
|
+
number = _this$state.number;
|
|
127
98
|
|
|
99
|
+
// If it is invalid, we reset the input to the current page
|
|
128
100
|
if (value === '' || isNaN(value)) {
|
|
129
101
|
this.resetInitialState();
|
|
130
102
|
return;
|
|
131
103
|
}
|
|
132
|
-
|
|
133
104
|
this.setNewPage(event, number);
|
|
134
105
|
}
|
|
135
106
|
}
|
|
136
|
-
|
|
137
107
|
getNumberWithinRange(n) {
|
|
138
108
|
if (n < this.MIN) return this.MIN;
|
|
139
109
|
if (n > this.MAX) return this.MAX;
|
|
140
110
|
return n;
|
|
141
111
|
}
|
|
142
|
-
|
|
143
112
|
setNewPage(event, n) {
|
|
144
113
|
const number = this.getNumberWithinRange(n);
|
|
145
114
|
this.setState({
|
|
@@ -148,28 +117,25 @@ let PaginationPageInput = (_dec = (0, _emotion.withStyle)(_styles.default, _them
|
|
|
148
117
|
});
|
|
149
118
|
this.props.onChange(event, number - 1);
|
|
150
119
|
}
|
|
151
|
-
|
|
152
120
|
renderLabel() {
|
|
153
121
|
const _this$props3 = this.props,
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
122
|
+
label = _this$props3.label,
|
|
123
|
+
numberOfPages = _this$props3.numberOfPages,
|
|
124
|
+
styles = _this$props3.styles;
|
|
157
125
|
return typeof label === 'function' && label(numberOfPages) ? (0, _emotion.jsx)("span", {
|
|
158
126
|
css: styles === null || styles === void 0 ? void 0 : styles.inputLabel
|
|
159
127
|
}, label(numberOfPages)) : null;
|
|
160
128
|
}
|
|
161
|
-
|
|
162
129
|
renderScreenReaderLabel() {
|
|
163
130
|
const _this$props4 = this.props,
|
|
164
|
-
|
|
165
|
-
|
|
131
|
+
screenReaderLabel = _this$props4.screenReaderLabel,
|
|
132
|
+
numberOfPages = _this$props4.numberOfPages;
|
|
166
133
|
return (0, _emotion.jsx)(_ScreenReaderContent.ScreenReaderContent, null, screenReaderLabel(this.currentPage, numberOfPages));
|
|
167
134
|
}
|
|
168
|
-
|
|
169
135
|
render() {
|
|
170
136
|
const _this$props5 = this.props,
|
|
171
|
-
|
|
172
|
-
|
|
137
|
+
styles = _this$props5.styles,
|
|
138
|
+
disabled = _this$props5.disabled;
|
|
173
139
|
return (0, _emotion.jsx)("span", {
|
|
174
140
|
css: styles === null || styles === void 0 ? void 0 : styles.paginationPageInput,
|
|
175
141
|
ref: this.handleRef
|
|
@@ -190,7 +156,6 @@ let PaginationPageInput = (_dec = (0, _emotion.withStyle)(_styles.default, _them
|
|
|
190
156
|
inputRef: this.handleInputRef
|
|
191
157
|
})), this.renderLabel());
|
|
192
158
|
}
|
|
193
|
-
|
|
194
159
|
}, _class2.displayName = "PaginationPageInput", _class2.componentId = 'Pagination.PageInput', _class2.propTypes = _props.propTypes, _class2.allowedProps = _props.allowedProps, _class2.defaultProps = {
|
|
195
160
|
disabled: false
|
|
196
161
|
}, _class2)) || _class) || _class);
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.propTypes = exports.allowedProps = void 0;
|
|
9
|
-
|
|
10
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
-
|
|
12
9
|
/*
|
|
13
10
|
* The MIT License (MIT)
|
|
14
11
|
*
|
|
@@ -32,6 +29,7 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
32
29
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
33
30
|
* SOFTWARE.
|
|
34
31
|
*/
|
|
32
|
+
|
|
35
33
|
const propTypes = {
|
|
36
34
|
numberOfPages: _propTypes.default.number.isRequired,
|
|
37
35
|
currentPageIndex: _propTypes.default.number.isRequired,
|
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
/*
|
|
9
8
|
* The MIT License (MIT)
|
|
10
9
|
*
|
|
@@ -58,6 +57,5 @@ const generateStyle = componentTheme => {
|
|
|
58
57
|
}
|
|
59
58
|
};
|
|
60
59
|
};
|
|
61
|
-
|
|
62
60
|
var _default = generateStyle;
|
|
63
61
|
exports.default = _default;
|
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
/*
|
|
9
8
|
* The MIT License (MIT)
|
|
10
9
|
*
|
|
@@ -40,9 +39,9 @@ const generateComponentTheme = theme => {
|
|
|
40
39
|
inputSpacing: spacing.xSmall,
|
|
41
40
|
inputWidth: '4.5rem'
|
|
42
41
|
};
|
|
43
|
-
return {
|
|
42
|
+
return {
|
|
43
|
+
...componentVariables
|
|
44
44
|
};
|
|
45
45
|
};
|
|
46
|
-
|
|
47
46
|
var _default = generateComponentTheme;
|
|
48
47
|
exports.default = _default;
|
package/lib/Pagination/index.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
|
-
|
|
5
4
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
6
|
-
|
|
7
5
|
Object.defineProperty(exports, "__esModule", {
|
|
8
6
|
value: true
|
|
9
7
|
});
|
|
@@ -15,54 +13,33 @@ Object.defineProperty(exports, "PaginationButton", {
|
|
|
15
13
|
}
|
|
16
14
|
});
|
|
17
15
|
exports.default = void 0;
|
|
18
|
-
|
|
19
16
|
var _react = _interopRequireWildcard(require("react"));
|
|
20
|
-
|
|
21
17
|
var _View = require("@instructure/ui-view/lib/View");
|
|
22
|
-
|
|
23
18
|
var _testable = require("@instructure/ui-testable/lib/testable.js");
|
|
24
|
-
|
|
25
19
|
var _omitProps = require("@instructure/ui-react-utils/lib/omitProps.js");
|
|
26
|
-
|
|
27
20
|
var _withDeterministicId = require("@instructure/ui-react-utils/lib/DeterministicIdContext/withDeterministicId.js");
|
|
28
|
-
|
|
29
21
|
var _hasVisibleChildren = require("@instructure/ui-a11y-utils/lib/hasVisibleChildren.js");
|
|
30
|
-
|
|
31
22
|
var _findTabbable = require("@instructure/ui-dom-utils/lib/findTabbable.js");
|
|
32
|
-
|
|
33
23
|
var _getActiveElement = require("@instructure/ui-dom-utils/lib/getActiveElement.js");
|
|
34
|
-
|
|
35
24
|
var _emotion = require("@instructure/emotion");
|
|
36
|
-
|
|
37
25
|
var _PaginationButton = require("./PaginationButton");
|
|
38
|
-
|
|
39
26
|
var _PaginationArrowButton = require("./PaginationArrowButton");
|
|
40
|
-
|
|
41
27
|
var _PaginationPageInput = require("./PaginationPageInput");
|
|
42
|
-
|
|
43
28
|
var _styles = _interopRequireDefault(require("./styles"));
|
|
44
|
-
|
|
45
29
|
var _props = require("./props");
|
|
46
|
-
|
|
47
30
|
var _dec, _dec2, _dec3, _class, _class2, _span, _span2;
|
|
48
|
-
|
|
49
31
|
/** This is an [].findIndex optimized to work on really big, but sparse, arrays */
|
|
50
32
|
const fastFindIndex = (arr, fn) => Number(Object.keys(arr).find(k => fn(arr[Number(k)])));
|
|
51
|
-
|
|
52
33
|
const childrenArray = props => {
|
|
53
34
|
const children = props.children;
|
|
54
|
-
|
|
55
35
|
if (!children) {
|
|
56
36
|
return [];
|
|
57
37
|
}
|
|
58
|
-
|
|
59
38
|
return Array.isArray(children) ? children : [children];
|
|
60
39
|
};
|
|
61
|
-
|
|
62
40
|
function propsHaveCompactView(props) {
|
|
63
41
|
return props.variant === 'compact' && childrenArray(props).length > 5;
|
|
64
42
|
}
|
|
65
|
-
|
|
66
43
|
/**
|
|
67
44
|
---
|
|
68
45
|
category: components
|
|
@@ -78,47 +55,36 @@ let Pagination = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2
|
|
|
78
55
|
this._nextButton = null;
|
|
79
56
|
this._lastButton = null;
|
|
80
57
|
this.ref = null;
|
|
81
|
-
|
|
82
58
|
this.handleElementRef = el => {
|
|
83
59
|
this.ref = el;
|
|
84
|
-
|
|
85
60
|
if (el && typeof this.props.elementRef === 'function') {
|
|
86
61
|
this.props.elementRef(el);
|
|
87
62
|
}
|
|
88
63
|
};
|
|
89
|
-
|
|
90
64
|
this.handleInputRef = el => {
|
|
91
65
|
if (typeof this.props.inputRef === 'function') {
|
|
92
66
|
this.props.inputRef(el);
|
|
93
67
|
}
|
|
94
68
|
};
|
|
95
|
-
|
|
96
69
|
this._labelId = props.deterministicId();
|
|
97
70
|
}
|
|
98
|
-
|
|
99
71
|
get _root() {
|
|
100
72
|
return this.ref;
|
|
101
73
|
}
|
|
102
|
-
|
|
103
74
|
get inputMode() {
|
|
104
75
|
return this.props.variant === 'input';
|
|
105
76
|
}
|
|
106
|
-
|
|
107
77
|
get childPages() {
|
|
108
78
|
return childrenArray(this.props);
|
|
109
79
|
}
|
|
110
|
-
|
|
111
80
|
get withFirstAndLastButton() {
|
|
112
81
|
return this.inputMode || this.props.withFirstAndLastButton;
|
|
113
82
|
}
|
|
114
|
-
|
|
115
83
|
get showDisabledButtons() {
|
|
116
84
|
return this.inputMode || this.props.showDisabledButtons;
|
|
117
85
|
}
|
|
118
|
-
|
|
119
86
|
getSnapshotBeforeUpdate() {
|
|
120
87
|
const activeElement = (0, _getActiveElement.getActiveElement)();
|
|
121
|
-
|
|
122
88
|
if (activeElement === this._firstButton || activeElement === this._prevButton || activeElement === this._nextButton || activeElement === this._lastButton) {
|
|
123
89
|
return {
|
|
124
90
|
lastFocusedButton: activeElement
|
|
@@ -129,60 +95,50 @@ let Pagination = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2
|
|
|
129
95
|
};
|
|
130
96
|
}
|
|
131
97
|
}
|
|
132
|
-
|
|
133
98
|
componentDidMount() {
|
|
134
99
|
var _this$props$makeStyle, _this$props;
|
|
135
|
-
|
|
136
100
|
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
|
|
137
101
|
}
|
|
138
|
-
|
|
139
102
|
componentDidUpdate(prevProps, _prevState, snapshot) {
|
|
140
103
|
var _this$props$makeStyle2, _this$props2;
|
|
141
|
-
|
|
142
104
|
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
|
|
143
|
-
|
|
144
105
|
if (!this.props.shouldHandleFocus || !propsHaveCompactView(prevProps) && !propsHaveCompactView(this.props)) {
|
|
145
106
|
return;
|
|
146
107
|
} else {
|
|
147
108
|
this.focusElementAfterUpdate(snapshot);
|
|
148
109
|
}
|
|
149
110
|
}
|
|
150
|
-
|
|
151
111
|
focusElementAfterUpdate(snapshot) {
|
|
152
112
|
const lastFocusedButton = snapshot.lastFocusedButton;
|
|
153
|
-
|
|
154
113
|
if (lastFocusedButton) {
|
|
155
114
|
const focusable = (0, _findTabbable.findTabbable)(this.ref);
|
|
156
|
-
const direction = lastFocusedButton.dataset.direction;
|
|
115
|
+
const direction = lastFocusedButton.dataset.direction;
|
|
157
116
|
|
|
158
|
-
|
|
159
|
-
|
|
117
|
+
// By default we want to focus the previously focused button
|
|
118
|
+
let nextFocusElement = lastFocusedButton;
|
|
160
119
|
|
|
120
|
+
// In case the button is not focusable anymore
|
|
121
|
+
// (disabled or not in the DOM), we focus to the next available page
|
|
161
122
|
if (!focusable.includes(nextFocusElement)) {
|
|
162
123
|
if (direction === 'first' || direction === 'prev') {
|
|
163
124
|
nextFocusElement = focusable[0];
|
|
164
125
|
}
|
|
165
|
-
|
|
166
126
|
if (direction === 'next' || direction === 'last') {
|
|
167
127
|
nextFocusElement = focusable[focusable.length - 1];
|
|
168
128
|
}
|
|
169
129
|
}
|
|
170
|
-
|
|
171
130
|
;
|
|
172
131
|
nextFocusElement.focus();
|
|
173
132
|
}
|
|
174
133
|
}
|
|
175
|
-
|
|
176
134
|
get compactView() {
|
|
177
135
|
return propsHaveCompactView(this.props);
|
|
178
136
|
}
|
|
179
|
-
|
|
180
137
|
transferDisabledPropToChildren(children) {
|
|
181
138
|
return children && this.props.disabled ? _react.default.Children.map(children, page => /*#__PURE__*/_react.default.cloneElement(page, {
|
|
182
139
|
disabled: this.props.disabled
|
|
183
140
|
})) : children;
|
|
184
141
|
}
|
|
185
|
-
|
|
186
142
|
renderLabel() {
|
|
187
143
|
const display = this.props.variant === 'full' ? 'inline-block' : 'block';
|
|
188
144
|
const visibleLabel = (0, _hasVisibleChildren.hasVisibleChildren)(this.props.label);
|
|
@@ -193,7 +149,6 @@ let Pagination = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2
|
|
|
193
149
|
id: this._labelId
|
|
194
150
|
}, this.props.label);
|
|
195
151
|
}
|
|
196
|
-
|
|
197
152
|
renderPageInput(currentPageIndex) {
|
|
198
153
|
return (0, _emotion.jsx)(_PaginationPageInput.PaginationPageInput, {
|
|
199
154
|
numberOfPages: this.childPages.length,
|
|
@@ -205,17 +160,13 @@ let Pagination = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2
|
|
|
205
160
|
inputRef: this.handleInputRef
|
|
206
161
|
});
|
|
207
162
|
}
|
|
208
|
-
|
|
209
163
|
handleInputChange(event, pageIndex) {
|
|
210
164
|
var _this$childPages$page, _this$childPages$page2;
|
|
211
|
-
|
|
212
165
|
(_this$childPages$page = (_this$childPages$page2 = this.childPages[pageIndex].props).onClick) === null || _this$childPages$page === void 0 ? void 0 : _this$childPages$page.call(_this$childPages$page2, event);
|
|
213
166
|
}
|
|
214
|
-
|
|
215
167
|
renderPages(currentPageIndex) {
|
|
216
168
|
const allPages = this.childPages;
|
|
217
169
|
let visiblePages = allPages;
|
|
218
|
-
|
|
219
170
|
if (this.compactView) {
|
|
220
171
|
const firstIndex = 0;
|
|
221
172
|
const lastIndex = allPages.length - 1;
|
|
@@ -235,12 +186,10 @@ let Pagination = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2
|
|
|
235
186
|
}, "\u2026")));
|
|
236
187
|
if (lastIndex - sliceEnd + 1 > 0) visiblePages.push(lastPage);
|
|
237
188
|
}
|
|
238
|
-
|
|
239
189
|
return (0, _emotion.jsx)(_View.View, {
|
|
240
190
|
display: "inline-block"
|
|
241
191
|
}, this.transferDisabledPropToChildren(visiblePages));
|
|
242
192
|
}
|
|
243
|
-
|
|
244
193
|
getArrowVariant(direction, currentPageIndex, pagesCount) {
|
|
245
194
|
switch (direction) {
|
|
246
195
|
case 'first':
|
|
@@ -252,7 +201,6 @@ let Pagination = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2
|
|
|
252
201
|
this._firstButton = el;
|
|
253
202
|
}
|
|
254
203
|
};
|
|
255
|
-
|
|
256
204
|
case 'prev':
|
|
257
205
|
return {
|
|
258
206
|
pageIndex: currentPageIndex - 1,
|
|
@@ -262,7 +210,6 @@ let Pagination = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2
|
|
|
262
210
|
this._prevButton = el;
|
|
263
211
|
}
|
|
264
212
|
};
|
|
265
|
-
|
|
266
213
|
case 'next':
|
|
267
214
|
return {
|
|
268
215
|
pageIndex: currentPageIndex + 1,
|
|
@@ -272,7 +219,6 @@ let Pagination = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2
|
|
|
272
219
|
this._nextButton = el;
|
|
273
220
|
}
|
|
274
221
|
};
|
|
275
|
-
|
|
276
222
|
case 'last':
|
|
277
223
|
return {
|
|
278
224
|
pageIndex: pagesCount - 1,
|
|
@@ -284,26 +230,22 @@ let Pagination = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2
|
|
|
284
230
|
};
|
|
285
231
|
}
|
|
286
232
|
}
|
|
287
|
-
|
|
288
233
|
renderArrowButton(direction, currentPageIndex) {
|
|
289
234
|
var _page$props, _page$props2;
|
|
235
|
+
const childPages = this.childPages;
|
|
290
236
|
|
|
291
|
-
|
|
292
|
-
|
|
237
|
+
// We don't display the arrows in "compact" variant under 6 items
|
|
293
238
|
if (!(propsHaveCompactView(this.props) || this.inputMode)) {
|
|
294
239
|
return null;
|
|
295
240
|
}
|
|
296
|
-
|
|
297
241
|
if (!this.withFirstAndLastButton && (direction === 'first' || direction === 'last')) {
|
|
298
242
|
return null;
|
|
299
243
|
}
|
|
300
|
-
|
|
301
244
|
const _this$getArrowVariant = this.getArrowVariant(direction, currentPageIndex, childPages.length),
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
245
|
+
pageIndex = _this$getArrowVariant.pageIndex,
|
|
246
|
+
label = _this$getArrowVariant.label,
|
|
247
|
+
shouldEnableIcon = _this$getArrowVariant.shouldEnableIcon,
|
|
248
|
+
handleButtonRef = _this$getArrowVariant.handleButtonRef;
|
|
307
249
|
const page = childPages[pageIndex];
|
|
308
250
|
const disabled = (page === null || page === void 0 ? void 0 : (_page$props = page.props) === null || _page$props === void 0 ? void 0 : _page$props.disabled) || this.props.disabled || !shouldEnableIcon;
|
|
309
251
|
const onClick = page === null || page === void 0 ? void 0 : (_page$props2 = page.props) === null || _page$props2 === void 0 ? void 0 : _page$props2.onClick;
|
|
@@ -316,15 +258,11 @@ let Pagination = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2
|
|
|
316
258
|
buttonRef: handleButtonRef
|
|
317
259
|
}) : null;
|
|
318
260
|
}
|
|
319
|
-
|
|
320
261
|
render() {
|
|
321
262
|
var _this$props$styles, _this$props$styles2;
|
|
322
|
-
|
|
323
263
|
if (!this.props.children) return null;
|
|
324
264
|
const currentPageIndex = fastFindIndex(this.childPages, p => p && p.props && p.props.current);
|
|
325
|
-
|
|
326
265
|
const passthroughProps = _View.View.omitViewProps((0, _omitProps.omitProps)(this.props, Pagination.allowedProps), Pagination);
|
|
327
|
-
|
|
328
266
|
return (0, _emotion.jsx)(_View.View, Object.assign({}, passthroughProps, {
|
|
329
267
|
role: "navigation",
|
|
330
268
|
as: this.props.as,
|
|
@@ -337,7 +275,6 @@ let Pagination = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2
|
|
|
337
275
|
css: (_this$props$styles2 = this.props.styles) === null || _this$props$styles2 === void 0 ? void 0 : _this$props$styles2.pages
|
|
338
276
|
}, this.renderArrowButton('first', currentPageIndex), this.renderArrowButton('prev', currentPageIndex), this.inputMode ? this.renderPageInput(currentPageIndex) : this.renderPages(currentPageIndex), this.renderArrowButton('next', currentPageIndex), this.renderArrowButton('last', currentPageIndex)));
|
|
339
277
|
}
|
|
340
|
-
|
|
341
278
|
}, _class2.displayName = "Pagination", _class2.componentId = 'Pagination', _class2.propTypes = _props.propTypes, _class2.allowedProps = _props.allowedProps, _class2.defaultProps = {
|
|
342
279
|
disabled: false,
|
|
343
280
|
withFirstAndLastButton: false,
|
package/lib/Pagination/props.js
CHANGED
|
@@ -1,20 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.propTypes = exports.allowedProps = void 0;
|
|
9
|
-
|
|
10
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
-
|
|
12
9
|
var _Children = require("@instructure/ui-prop-types/lib/Children.js");
|
|
13
|
-
|
|
14
10
|
var _emotion = require("@instructure/emotion");
|
|
15
|
-
|
|
16
11
|
var _PaginationButton = require("./PaginationButton");
|
|
17
|
-
|
|
18
12
|
/*
|
|
19
13
|
* The MIT License (MIT)
|
|
20
14
|
*
|
|
@@ -38,6 +32,7 @@ var _PaginationButton = require("./PaginationButton");
|
|
|
38
32
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
39
33
|
* SOFTWARE.
|
|
40
34
|
*/
|
|
35
|
+
|
|
41
36
|
const propTypes = {
|
|
42
37
|
children: _Children.Children.oneOf([_PaginationButton.PaginationButton]),
|
|
43
38
|
disabled: _propTypes.default.bool,
|
package/lib/Pagination/styles.js
CHANGED
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
/*
|
|
9
8
|
* The MIT License (MIT)
|
|
10
9
|
*
|
|
@@ -52,6 +51,5 @@ const generateStyle = () => {
|
|
|
52
51
|
}
|
|
53
52
|
};
|
|
54
53
|
};
|
|
55
|
-
|
|
56
54
|
var _default = generateStyle;
|
|
57
55
|
exports.default = _default;
|
package/lib/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-pagination",
|
|
3
|
-
"version": "8.33.
|
|
3
|
+
"version": "8.33.2-snapshot-5",
|
|
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,29 +23,29 @@
|
|
|
23
23
|
},
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@instructure/ui-babel-preset": "8.33.
|
|
27
|
-
"@instructure/ui-test-locator": "8.33.
|
|
28
|
-
"@instructure/ui-test-queries": "8.33.
|
|
29
|
-
"@instructure/ui-test-utils": "8.33.
|
|
26
|
+
"@instructure/ui-babel-preset": "8.33.2-snapshot-5",
|
|
27
|
+
"@instructure/ui-test-locator": "8.33.2-snapshot-5",
|
|
28
|
+
"@instructure/ui-test-queries": "8.33.2-snapshot-5",
|
|
29
|
+
"@instructure/ui-test-utils": "8.33.2-snapshot-5"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@babel/runtime": "^7.13.10",
|
|
33
|
-
"@instructure/emotion": "8.33.
|
|
34
|
-
"@instructure/shared-types": "8.33.
|
|
35
|
-
"@instructure/ui-a11y-content": "8.33.
|
|
36
|
-
"@instructure/ui-a11y-utils": "8.33.
|
|
37
|
-
"@instructure/ui-buttons": "8.33.
|
|
38
|
-
"@instructure/ui-dom-utils": "8.33.
|
|
39
|
-
"@instructure/ui-icons": "8.33.
|
|
40
|
-
"@instructure/ui-number-input": "8.33.
|
|
41
|
-
"@instructure/ui-portal": "8.33.
|
|
42
|
-
"@instructure/ui-prop-types": "8.33.
|
|
43
|
-
"@instructure/ui-react-utils": "8.33.
|
|
44
|
-
"@instructure/ui-testable": "8.33.
|
|
45
|
-
"@instructure/ui-tooltip": "8.33.
|
|
46
|
-
"@instructure/ui-utils": "8.33.
|
|
47
|
-
"@instructure/ui-view": "8.33.
|
|
48
|
-
"@instructure/uid": "8.33.
|
|
33
|
+
"@instructure/emotion": "8.33.2-snapshot-5",
|
|
34
|
+
"@instructure/shared-types": "8.33.2-snapshot-5",
|
|
35
|
+
"@instructure/ui-a11y-content": "8.33.2-snapshot-5",
|
|
36
|
+
"@instructure/ui-a11y-utils": "8.33.2-snapshot-5",
|
|
37
|
+
"@instructure/ui-buttons": "8.33.2-snapshot-5",
|
|
38
|
+
"@instructure/ui-dom-utils": "8.33.2-snapshot-5",
|
|
39
|
+
"@instructure/ui-icons": "8.33.2-snapshot-5",
|
|
40
|
+
"@instructure/ui-number-input": "8.33.2-snapshot-5",
|
|
41
|
+
"@instructure/ui-portal": "8.33.2-snapshot-5",
|
|
42
|
+
"@instructure/ui-prop-types": "8.33.2-snapshot-5",
|
|
43
|
+
"@instructure/ui-react-utils": "8.33.2-snapshot-5",
|
|
44
|
+
"@instructure/ui-testable": "8.33.2-snapshot-5",
|
|
45
|
+
"@instructure/ui-tooltip": "8.33.2-snapshot-5",
|
|
46
|
+
"@instructure/ui-utils": "8.33.2-snapshot-5",
|
|
47
|
+
"@instructure/ui-view": "8.33.2-snapshot-5",
|
|
48
|
+
"@instructure/uid": "8.33.2-snapshot-5",
|
|
49
49
|
"keycode": "^2",
|
|
50
50
|
"prop-types": "^15"
|
|
51
51
|
},
|