@instructure/ui-pagination 8.13.1-snapshot.9 → 8.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/es/Pagination/PaginationArrowButton/index.js +36 -4
  3. package/es/Pagination/PaginationArrowButton/props.js +6 -3
  4. package/es/Pagination/PaginationButton/props.js +9 -2
  5. package/es/Pagination/PaginationLocator.js +4 -0
  6. package/es/Pagination/PaginationPageInput/PaginationPageInputLocator.js +35 -0
  7. package/es/Pagination/PaginationPageInput/index.js +208 -0
  8. package/es/Pagination/PaginationPageInput/props.js +35 -0
  9. package/es/Pagination/PaginationPageInput/styles.js +55 -0
  10. package/es/Pagination/PaginationPageInput/theme.js +40 -0
  11. package/es/Pagination/index.js +178 -52
  12. package/es/Pagination/props.js +32 -2
  13. package/lib/Pagination/PaginationArrowButton/index.js +39 -3
  14. package/lib/Pagination/PaginationArrowButton/props.js +6 -3
  15. package/lib/Pagination/PaginationButton/props.js +9 -2
  16. package/lib/Pagination/PaginationLocator.js +5 -0
  17. package/lib/Pagination/PaginationPageInput/PaginationPageInputLocator.js +46 -0
  18. package/lib/Pagination/PaginationPageInput/index.js +202 -0
  19. package/lib/Pagination/PaginationPageInput/props.js +46 -0
  20. package/lib/Pagination/PaginationPageInput/styles.js +63 -0
  21. package/lib/Pagination/PaginationPageInput/theme.js +48 -0
  22. package/lib/Pagination/index.js +179 -52
  23. package/lib/Pagination/props.js +32 -2
  24. package/package.json +23 -22
  25. package/src/Pagination/PaginationArrowButton/index.tsx +32 -4
  26. package/src/Pagination/PaginationArrowButton/props.ts +22 -6
  27. package/src/Pagination/PaginationButton/props.ts +18 -2
  28. package/src/Pagination/PaginationLocator.ts +5 -1
  29. package/src/Pagination/PaginationPageInput/PaginationPageInputLocator.ts +42 -0
  30. package/src/Pagination/PaginationPageInput/index.tsx +242 -0
  31. package/src/Pagination/PaginationPageInput/props.ts +112 -0
  32. package/src/Pagination/PaginationPageInput/styles.ts +60 -0
  33. package/src/Pagination/PaginationPageInput/theme.ts +46 -0
  34. package/src/Pagination/README.md +116 -0
  35. package/src/Pagination/index.tsx +213 -80
  36. package/src/Pagination/props.ts +53 -4
  37. package/tsconfig.build.json +26 -2
  38. package/tsconfig.build.tsbuildinfo +1 -0
  39. package/types/Pagination/PaginationArrowButton/PaginationArrowButtonLocator.d.ts +57 -56
  40. package/types/Pagination/PaginationArrowButton/PaginationArrowButtonLocator.d.ts.map +1 -1
  41. package/types/Pagination/PaginationArrowButton/index.d.ts +9 -4
  42. package/types/Pagination/PaginationArrowButton/index.d.ts.map +1 -1
  43. package/types/Pagination/PaginationArrowButton/props.d.ts +5 -3
  44. package/types/Pagination/PaginationArrowButton/props.d.ts.map +1 -1
  45. package/types/Pagination/PaginationButton/index.d.ts +2 -0
  46. package/types/Pagination/PaginationButton/index.d.ts.map +1 -1
  47. package/types/Pagination/PaginationButton/props.d.ts +1 -0
  48. package/types/Pagination/PaginationButton/props.d.ts.map +1 -1
  49. package/types/Pagination/PaginationLocator.d.ts +944 -234
  50. package/types/Pagination/PaginationLocator.d.ts.map +1 -1
  51. package/types/Pagination/PaginationPageInput/PaginationPageInputLocator.d.ts +581 -0
  52. package/types/Pagination/PaginationPageInput/PaginationPageInputLocator.d.ts.map +1 -0
  53. package/types/Pagination/PaginationPageInput/index.d.ts +63 -0
  54. package/types/Pagination/PaginationPageInput/index.d.ts.map +1 -0
  55. package/types/Pagination/PaginationPageInput/props.d.ts +46 -0
  56. package/types/Pagination/PaginationPageInput/props.d.ts.map +1 -0
  57. package/types/Pagination/PaginationPageInput/styles.d.ts +15 -0
  58. package/types/Pagination/PaginationPageInput/styles.d.ts.map +1 -0
  59. package/types/Pagination/PaginationPageInput/theme.d.ts +10 -0
  60. package/types/Pagination/PaginationPageInput/theme.d.ts.map +1 -0
  61. package/types/Pagination/index.d.ts +50 -14
  62. package/types/Pagination/index.d.ts.map +1 -1
  63. package/types/Pagination/props.d.ts +13 -3
  64. package/types/Pagination/props.d.ts.map +1 -1
  65. package/LICENSE.md +0 -27
@@ -35,36 +35,42 @@ import { findTabbable, getActiveElement } from '@instructure/ui-dom-utils';
35
35
  import { withStyle, jsx } from '@instructure/emotion';
36
36
  import { PaginationButton } from './PaginationButton';
37
37
  import { PaginationArrowButton } from './PaginationArrowButton';
38
+ import { PaginationPageInput } from './PaginationPageInput';
38
39
  import generateStyle from './styles';
39
40
  import { propTypes, allowedProps } from './props';
40
41
 
41
42
  /** This is an [].findIndex optimized to work on really big, but sparse, arrays */
42
43
  const fastFindIndex = (arr, fn) => Number(Object.keys(arr).find(k => fn(arr[Number(k)])));
43
44
 
44
- function propsHaveCompactView(props) {
45
- var _props$children;
45
+ const childrenArray = props => {
46
+ const children = props.children;
46
47
 
47
- return props.variant === 'compact' && (props === null || props === void 0 ? void 0 : (_props$children = props.children) === null || _props$children === void 0 ? void 0 : _props$children.length) > 5;
48
- }
48
+ if (!children) {
49
+ return [];
50
+ }
49
51
 
50
- function shouldShowPrevButton(props, currentPageIndex) {
51
- return propsHaveCompactView(props) && currentPageIndex > 0;
52
- }
52
+ return Array.isArray(children) ? children : [children];
53
+ };
53
54
 
54
- function shouldShowNextButton(props, currentPageIndex) {
55
- return propsHaveCompactView(props) && currentPageIndex < props.children.length - 1;
55
+ function propsHaveCompactView(props) {
56
+ return props.variant === 'compact' && childrenArray(props).length > 5;
56
57
  }
58
+
57
59
  /**
58
60
  ---
59
61
  category: components
60
62
  ---
61
63
  **/
62
-
63
-
64
64
  let Pagination = (_dec = withStyle(generateStyle, null), _dec2 = testable(), _dec(_class = _dec2(_class = (_temp = _class2 = class Pagination extends Component {
65
65
  constructor() {
66
66
  super(...arguments);
67
+ this._labelId = void 0;
67
68
  this.ref = null;
69
+ this._inputRef = null;
70
+ this._firstButton = null;
71
+ this._prevButton = null;
72
+ this._nextButton = null;
73
+ this._lastButton = null;
68
74
 
69
75
  this.handleElementRef = el => {
70
76
  this.ref = el;
@@ -76,42 +82,87 @@ let Pagination = (_dec = withStyle(generateStyle, null), _dec2 = testable(), _de
76
82
  }
77
83
  };
78
84
 
85
+ this.handleInputRef = el => {
86
+ this._inputRef = el;
87
+ };
88
+
79
89
  this._labelId = uid('Pagination');
80
- this._prevButton = null;
81
- this._nextButton = null;
82
90
  }
83
91
 
84
92
  get _root() {
85
93
  return this.ref;
86
94
  }
87
95
 
96
+ get inputMode() {
97
+ return this.props.variant === 'input';
98
+ }
99
+
100
+ get childPages() {
101
+ return childrenArray(this.props);
102
+ }
103
+
104
+ get withFirstAndLastButton() {
105
+ return this.inputMode || this.props.withFirstAndLastButton;
106
+ }
107
+
108
+ get showDisabledButtons() {
109
+ return this.inputMode || this.props.showDisabledButtons;
110
+ }
111
+
88
112
  getSnapshotBeforeUpdate() {
89
113
  const activeElement = getActiveElement();
90
- return {
91
- prevButtonFocused: this._prevButton === activeElement,
92
- nextButtonFocused: this._nextButton === activeElement
93
- };
114
+
115
+ if (activeElement === this._firstButton || activeElement === this._prevButton || activeElement === this._nextButton || activeElement === this._lastButton) {
116
+ return {
117
+ lastFocusedButton: activeElement
118
+ };
119
+ } else {
120
+ return {
121
+ lastFocusedButton: void 0
122
+ };
123
+ }
94
124
  }
95
125
 
96
126
  componentDidMount() {
97
- this.props.makeStyles();
127
+ var _this$props$makeStyle, _this$props;
128
+
129
+ (_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
98
130
  }
99
131
 
100
- componentDidUpdate(prevProps, prevState, snapshot) {
101
- this.props.makeStyles();
132
+ componentDidUpdate(prevProps, _prevState, snapshot) {
133
+ var _this$props$makeStyle2, _this$props2;
134
+
135
+ (_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
102
136
 
103
137
  if (!this.props.shouldHandleFocus || !propsHaveCompactView(prevProps) && !propsHaveCompactView(this.props)) {
104
138
  return;
139
+ } else {
140
+ this.focusElementAfterUpdate(snapshot);
105
141
  }
142
+ }
106
143
 
107
- const _ref = snapshot || {},
108
- prevButtonFocused = _ref.prevButtonFocused,
109
- nextButtonFocused = _ref.nextButtonFocused;
144
+ focusElementAfterUpdate(snapshot) {
145
+ const lastFocusedButton = snapshot.lastFocusedButton;
110
146
 
111
- if (prevButtonFocused || nextButtonFocused) {
147
+ if (lastFocusedButton) {
112
148
  const focusable = findTabbable(this.ref);
113
- const focusIndex = prevButtonFocused ? 0 : focusable.length - 1;
114
- focusable[focusIndex].focus();
149
+ const direction = lastFocusedButton.dataset.direction; // By default we want to focus the previously focused button
150
+
151
+ let nextFocusElement = lastFocusedButton; // In case the button is not focusable anymore
152
+ // (disabled or not in the DOM), we focus to the next available page
153
+
154
+ if (!focusable.includes(nextFocusElement)) {
155
+ if (direction === 'first' || direction === 'prev') {
156
+ nextFocusElement = focusable[0];
157
+ }
158
+
159
+ if (direction === 'next' || direction === 'last') {
160
+ nextFocusElement = focusable[focusable.length - 1];
161
+ }
162
+ }
163
+
164
+ ;
165
+ nextFocusElement.focus();
115
166
  }
116
167
  }
117
168
 
@@ -120,13 +171,13 @@ let Pagination = (_dec = withStyle(generateStyle, null), _dec2 = testable(), _de
120
171
  }
121
172
 
122
173
  transferDisabledPropToChildren(children) {
123
- return this.props.disabled ? React.Children.map(children, page => /*#__PURE__*/React.cloneElement(page, {
174
+ return children && this.props.disabled ? React.Children.map(children, page => /*#__PURE__*/React.cloneElement(page, {
124
175
  disabled: this.props.disabled
125
176
  })) : children;
126
177
  }
127
178
 
128
179
  renderLabel() {
129
- const display = this.props.variant === 'compact' ? 'block' : 'inline-block';
180
+ const display = this.props.variant === 'full' ? 'inline-block' : 'block';
130
181
  const visibleLabel = hasVisibleChildren(this.props.label);
131
182
  return jsx(View, {
132
183
  as: "span",
@@ -136,8 +187,26 @@ let Pagination = (_dec = withStyle(generateStyle, null), _dec2 = testable(), _de
136
187
  }, this.props.label);
137
188
  }
138
189
 
190
+ renderPageInput(currentPageIndex) {
191
+ return jsx(PaginationPageInput, {
192
+ numberOfPages: this.childPages.length,
193
+ currentPageIndex: currentPageIndex,
194
+ onChange: this.handleInputChange.bind(this),
195
+ screenReaderLabel: this.props.screenReaderLabelNumberInput,
196
+ label: this.props.labelNumberInput,
197
+ disabled: this.props.disabled,
198
+ inputRef: this.handleInputRef
199
+ });
200
+ }
201
+
202
+ handleInputChange(event, pageIndex) {
203
+ var _this$childPages$page, _this$childPages$page2;
204
+
205
+ (_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);
206
+ }
207
+
139
208
  renderPages(currentPageIndex) {
140
- const allPages = this.props.children;
209
+ const allPages = this.childPages;
141
210
  let visiblePages = allPages;
142
211
 
143
212
  if (this.compactView) {
@@ -149,14 +218,14 @@ let Pagination = (_dec = withStyle(generateStyle, null), _dec2 = testable(), _de
149
218
  const firstPage = allPages[firstIndex];
150
219
  const lastPage = allPages[lastIndex];
151
220
  if (sliceStart - firstIndex > 1) visiblePages.unshift(_span || (_span = jsx("span", {
152
- key: "first",
153
- "aria-hidden": "true"
154
- }, "\u2026")));
221
+ key: "first",
222
+ "aria-hidden": "true"
223
+ }, "\u2026")));
155
224
  if (sliceStart - firstIndex > 0) visiblePages.unshift(firstPage);
156
225
  if (lastIndex - sliceEnd + 1 > 1) visiblePages.push(_span2 || (_span2 = jsx("span", {
157
- key: "last",
158
- "aria-hidden": "true"
159
- }, "\u2026")));
226
+ key: "last",
227
+ "aria-hidden": "true"
228
+ }, "\u2026")));
160
229
  if (lastIndex - sliceEnd + 1 > 0) visiblePages.push(lastPage);
161
230
  }
162
231
 
@@ -165,27 +234,80 @@ let Pagination = (_dec = withStyle(generateStyle, null), _dec2 = testable(), _de
165
234
  }, this.transferDisabledPropToChildren(visiblePages));
166
235
  }
167
236
 
168
- renderArrowButton(label, direction, currentPageIndex) {
169
- // eslint-disable-next-line react/prop-types
170
- const _this$props$children$ = this.props.children[currentPageIndex + direction].props,
171
- onClick = _this$props$children$.onClick,
172
- disabled = _this$props$children$.disabled;
237
+ getArrowVariant(direction, currentPageIndex, pagesCount) {
238
+ switch (direction) {
239
+ case 'first':
240
+ return {
241
+ pageIndex: 0,
242
+ label: this.props.labelFirst || 'First Page',
243
+ shouldEnableIcon: currentPageIndex > 1,
244
+ handleButtonRef: el => {
245
+ this._firstButton = el;
246
+ }
247
+ };
173
248
 
174
- const handleButtonRef = el => {
175
- if (direction < 0) {
176
- this._prevButton = el;
177
- } else {
178
- this._nextButton = el;
179
- }
180
- };
249
+ case 'prev':
250
+ return {
251
+ pageIndex: currentPageIndex - 1,
252
+ label: this.props.labelPrev || 'Previous Page',
253
+ shouldEnableIcon: currentPageIndex > 0,
254
+ handleButtonRef: el => {
255
+ this._prevButton = el;
256
+ }
257
+ };
258
+
259
+ case 'next':
260
+ return {
261
+ pageIndex: currentPageIndex + 1,
262
+ label: this.props.labelNext || 'Next Page',
263
+ shouldEnableIcon: currentPageIndex < pagesCount - 1,
264
+ handleButtonRef: el => {
265
+ this._nextButton = el;
266
+ }
267
+ };
268
+
269
+ case 'last':
270
+ return {
271
+ pageIndex: pagesCount - 1,
272
+ label: this.props.labelLast || 'Last Page',
273
+ shouldEnableIcon: currentPageIndex < pagesCount - 2,
274
+ handleButtonRef: el => {
275
+ this._lastButton = el;
276
+ }
277
+ };
278
+ }
279
+ }
280
+
281
+ renderArrowButton(direction, currentPageIndex) {
282
+ var _page$props, _page$props2;
283
+
284
+ const childPages = this.childPages; // We don't display the arrows in "compact" variant under 6 items
181
285
 
182
- return jsx(PaginationArrowButton, {
183
- direction: direction === -1 ? 'prev' : 'next',
286
+ if (!(propsHaveCompactView(this.props) || this.inputMode)) {
287
+ return null;
288
+ }
289
+
290
+ if (!this.withFirstAndLastButton && (direction === 'first' || direction === 'last')) {
291
+ return null;
292
+ }
293
+
294
+ const _this$getArrowVariant = this.getArrowVariant(direction, currentPageIndex, childPages.length),
295
+ pageIndex = _this$getArrowVariant.pageIndex,
296
+ label = _this$getArrowVariant.label,
297
+ shouldEnableIcon = _this$getArrowVariant.shouldEnableIcon,
298
+ handleButtonRef = _this$getArrowVariant.handleButtonRef;
299
+
300
+ const page = childPages[pageIndex];
301
+ 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;
302
+ const onClick = page === null || page === void 0 ? void 0 : (_page$props2 = page.props) === null || _page$props2 === void 0 ? void 0 : _page$props2.onClick;
303
+ return shouldEnableIcon || this.showDisabledButtons ? jsx(PaginationArrowButton, {
304
+ direction: direction,
305
+ "data-direction": direction,
184
306
  label: label,
185
307
  onClick: onClick,
186
308
  disabled: disabled,
187
309
  buttonRef: handleButtonRef
188
- });
310
+ }) : null;
189
311
  }
190
312
 
191
313
  render() {
@@ -200,19 +322,23 @@ let Pagination = (_dec = withStyle(generateStyle, null), _dec2 = testable(), _de
200
322
  elementRef: this.handleElementRef,
201
323
  margin: this.props.margin,
202
324
  css: (_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.pagination,
203
- "aria-labelledby": this.props.label && this._labelId
325
+ "aria-labelledby": this.props.label ? this._labelId : void 0
204
326
  }), this.props.label && this.renderLabel(), jsx(View, {
205
327
  display: "inline-block",
206
328
  css: (_this$props$styles2 = this.props.styles) === null || _this$props$styles2 === void 0 ? void 0 : _this$props$styles2.pages
207
- }, shouldShowPrevButton(this.props, currentPageIndex) && this.renderArrowButton(this.props.labelPrev, -1, currentPageIndex), this.renderPages(currentPageIndex), shouldShowNextButton(this.props, currentPageIndex) && this.renderArrowButton(this.props.labelNext, 1, currentPageIndex)));
329
+ }, this.renderArrowButton('first', currentPageIndex), this.renderArrowButton('prev', currentPageIndex), this.inputMode ? this.renderPageInput(currentPageIndex) : this.renderPages(currentPageIndex), this.renderArrowButton('next', currentPageIndex), this.renderArrowButton('last', currentPageIndex)));
208
330
  }
209
331
 
210
332
  }, _class2.displayName = "Pagination", _class2.componentId = 'Pagination', _class2.propTypes = propTypes, _class2.allowedProps = allowedProps, _class2.defaultProps = {
211
333
  children: null,
212
334
  disabled: false,
335
+ withFirstAndLastButton: false,
336
+ showDisabledButtons: false,
213
337
  variant: 'full',
214
338
  as: 'div',
215
339
  elementRef: el => {},
340
+ labelNumberInput: numberOfPages => `of ${numberOfPages}`,
341
+ screenReaderLabelNumberInput: (currentPage, numberOfPages) => `Select page (${currentPage} of ${numberOfPages})`,
216
342
  shouldHandleFocus: true
217
343
  }, _class2.Page = PaginationButton, _class2.Navigation = PaginationArrowButton, _temp)) || _class) || _class);
218
344
  export default Pagination;
@@ -36,6 +36,16 @@ const propTypes = {
36
36
  */
37
37
  disabled: PropTypes.bool,
38
38
 
39
+ /**
40
+ * Displays "jump to first" and "jump to last" buttons. Always turned on with `input` variant.
41
+ */
42
+ withFirstAndLastButton: PropTypes.bool,
43
+
44
+ /**
45
+ * Displays the unavailable navigation buttons as disabled instead of hiding them. Always turned on with `input` variant.
46
+ */
47
+ showDisabledButtons: PropTypes.bool,
48
+
39
49
  /**
40
50
  * Visible label for component
41
51
  */
@@ -51,12 +61,32 @@ const propTypes = {
51
61
  */
52
62
  labelPrev: PropTypes.string,
53
63
 
64
+ /**
65
+ * Accessible label for "jump to first" button
66
+ */
67
+ labelFirst: PropTypes.string,
68
+
69
+ /**
70
+ * Accessible label for "jump to last" button
71
+ */
72
+ labelLast: PropTypes.string,
73
+
74
+ /**
75
+ * Label for number input (for `input` variant)
76
+ */
77
+ labelNumberInput: PropTypes.func,
78
+
79
+ /**
80
+ * ScreenReaderLabel for number input (for `input` variant)
81
+ */
82
+ screenReaderLabelNumberInput: PropTypes.func,
83
+
54
84
  /**
55
85
  * The compact variant truncates the page navigation to show only the first,
56
86
  * last, and pages immediately surrounding the current page. Fewer than 5 pages,
57
87
  * no next/previous arrow buttons will be shown, and all pages will be listed
58
88
  */
59
- variant: PropTypes.oneOf(['full', 'compact']),
89
+ variant: PropTypes.oneOf(['full', 'compact', 'input']),
60
90
 
61
91
  /**
62
92
  * Valid values are `0`, `none`, `auto`, `xxx-small`, `xx-small`, `x-small`,
@@ -82,5 +112,5 @@ const propTypes = {
82
112
  */
83
113
  shouldHandleFocus: PropTypes.bool
84
114
  };
85
- const allowedProps = ['children', 'disabled', 'label', 'labelNext', 'labelPrev', 'variant', 'margin', 'as', 'elementRef', 'shouldHandleFocus'];
115
+ const allowedProps = ['children', 'disabled', 'withFirstAndLastButton', 'showDisabledButtons', 'label', 'labelNext', 'labelPrev', 'labelFirst', 'labelLast', 'labelNumberInput', 'screenReaderLabelNumberInput', 'variant', 'margin', 'as', 'elementRef', 'shouldHandleFocus'];
86
116
  export { propTypes, allowedProps };
@@ -23,6 +23,10 @@ var _IconArrowOpenStartSolid = require("@instructure/ui-icons/lib/IconArrowOpenS
23
23
 
24
24
  var _IconArrowOpenEndSolid = require("@instructure/ui-icons/lib/IconArrowOpenEndSolid.js");
25
25
 
26
+ var _IconArrowDoubleStartSolid = require("@instructure/ui-icons/lib/IconArrowDoubleStartSolid.js");
27
+
28
+ var _IconArrowDoubleEndSolid = require("@instructure/ui-icons/lib/IconArrowDoubleEndSolid.js");
29
+
26
30
  var _testable = require("@instructure/ui-testable/lib/testable.js");
27
31
 
28
32
  var _props = require("./props");
@@ -47,13 +51,44 @@ let PaginationArrowButton = (_dec = (0, _testable.testable)(), _dec(_class = (_t
47
51
  };
48
52
  }
49
53
 
54
+ get margin() {
55
+ switch (this.props.direction) {
56
+ case 'first':
57
+ return '0 xx-small 0 0';
58
+
59
+ case 'last':
60
+ return '0 0 0 xx-small';
61
+
62
+ default:
63
+ return void 0;
64
+ }
65
+ }
66
+
67
+ get Icon() {
68
+ switch (this.props.direction) {
69
+ case 'first':
70
+ return _IconArrowDoubleStartSolid.IconArrowDoubleStartSolid;
71
+
72
+ case 'prev':
73
+ return _IconArrowOpenStartSolid.IconArrowOpenStartSolid;
74
+
75
+ case 'next':
76
+ return _IconArrowOpenEndSolid.IconArrowOpenEndSolid;
77
+
78
+ case 'last':
79
+ return _IconArrowDoubleEndSolid.IconArrowDoubleEndSolid;
80
+
81
+ default:
82
+ return null;
83
+ }
84
+ }
85
+
50
86
  render() {
51
87
  const _this$props = this.props,
52
88
  label = _this$props.label,
53
89
  direction = _this$props.direction,
54
90
  buttonRef = _this$props.buttonRef,
55
91
  props = (0, _objectWithoutProperties2.default)(_this$props, _excluded);
56
- const Icon = direction === 'prev' ? _IconArrowOpenStartSolid.IconArrowOpenStartSolid : _IconArrowOpenEndSolid.IconArrowOpenEndSolid;
57
92
  return /*#__PURE__*/_react.default.createElement(_Tooltip.Tooltip, {
58
93
  on: ['hover', 'focus'],
59
94
  renderTip: /*#__PURE__*/_react.default.createElement(_PresentationContent.PresentationContent, {
@@ -65,8 +100,9 @@ let PaginationArrowButton = (_dec = (0, _testable.testable)(), _dec(_class = (_t
65
100
  withBorder: false,
66
101
  screenReaderLabel: label,
67
102
  rel: props.href || props.to ? direction : void 0,
68
- elementRef: buttonRef
69
- }), Icon));
103
+ elementRef: buttonRef,
104
+ margin: this.margin
105
+ }), this.Icon));
70
106
  }
71
107
 
72
108
  }, _class2.displayName = "PaginationArrowButton", _class2.componentId = 'Pagination.Navigation', _class2.allowedProps = _props.allowedProps, _class2.propTypes = _props.propTypes, _class2.defaultProps = {
@@ -33,10 +33,13 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
33
33
  * SOFTWARE.
34
34
  */
35
35
  const propTypes = {
36
- direction: _propTypes.default.oneOf(['next', 'prev']),
36
+ direction: _propTypes.default.oneOf(['first', 'prev', 'next', 'last']),
37
37
  label: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.node]).isRequired,
38
- buttonRef: _propTypes.default.func
38
+ buttonRef: _propTypes.default.func,
39
+ onClick: _propTypes.default.func
39
40
  };
40
41
  exports.propTypes = propTypes;
41
- const allowedProps = ['direction', 'label', 'buttonRef'];
42
+ const allowedProps = ['direction', 'label', 'buttonRef' // we don't want to pass onClick
43
+ // 'onClick'
44
+ ];
42
45
  exports.allowedProps = allowedProps;
@@ -41,8 +41,15 @@ const propTypes = {
41
41
  /**
42
42
  * Whether the page is currently displayed
43
43
  */
44
- current: _propTypes.default.bool
44
+ current: _propTypes.default.bool,
45
+
46
+ /**
47
+ * Whether the page is currently displayed
48
+ */
49
+ onClick: _propTypes.default.func
45
50
  };
46
51
  exports.propTypes = propTypes;
47
- const allowedProps = ['children', 'current'];
52
+ const allowedProps = ['children', 'current' // we don't want to pass onClick
53
+ // 'onClick'
54
+ ];
48
55
  exports.allowedProps = allowedProps;
@@ -7,6 +7,8 @@ exports.PaginationLocator = void 0;
7
7
 
8
8
  var _locator = require("@instructure/ui-test-locator/lib/utils/locator.js");
9
9
 
10
+ var _PaginationPageInputLocator = require("./PaginationPageInput/PaginationPageInputLocator");
11
+
10
12
  var _PaginationArrowButtonLocator = require("./PaginationArrowButton/PaginationArrowButtonLocator");
11
13
 
12
14
  var _index = require("./index");
@@ -44,6 +46,9 @@ const PaginationLocator = (0, _locator.locator)(_index.Pagination.selector, {
44
46
  },
45
47
  findArrowButton: async function () {
46
48
  return _PaginationArrowButtonLocator.PaginationArrowButtonLocator.find(...arguments);
49
+ },
50
+ findPageInput: async function () {
51
+ return _PaginationPageInputLocator.PaginationPageInputLocator.find(...arguments);
47
52
  }
48
53
  });
49
54
  exports.PaginationLocator = PaginationLocator;
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.PaginationPageInputLocator = void 0;
7
+
8
+ var _locator = require("@instructure/ui-test-locator/lib/utils/locator.js");
9
+
10
+ var _NumberInputLocator = require("@instructure/ui-number-input/lib/NumberInput/NumberInputLocator");
11
+
12
+ var _index = require("./index");
13
+
14
+ /*
15
+ * The MIT License (MIT)
16
+ *
17
+ * Copyright (c) 2015 - present Instructure, Inc.
18
+ *
19
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
20
+ * of this software and associated documentation files (the "Software"), to deal
21
+ * in the Software without restriction, including without limitation the rights
22
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
23
+ * copies of the Software, and to permit persons to whom the Software is
24
+ * furnished to do so, subject to the following conditions:
25
+ *
26
+ * The above copyright notice and this permission notice shall be included in all
27
+ * copies or substantial portions of the Software.
28
+ *
29
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
30
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
31
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
32
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
33
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
34
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
35
+ * SOFTWARE.
36
+ */
37
+ // eslint-disable-line no-restricted-imports
38
+ const PaginationPageInputLocator = (0, _locator.locator)(_index.PaginationPageInput.selector, {
39
+ findInput: function () {
40
+ return _NumberInputLocator.NumberInputLocator.findInput(...arguments);
41
+ },
42
+ findNumberInputArrows: function () {
43
+ return _NumberInputLocator.NumberInputLocator.findArrowButtons(...arguments);
44
+ }
45
+ });
46
+ exports.PaginationPageInputLocator = PaginationPageInputLocator;