@instructure/ui-pagination 11.6.0 → 11.6.1-snapshot-129

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 (141) hide show
  1. package/CHANGELOG.md +42 -296
  2. package/es/Pagination/{PaginationArrowButton → v1/PaginationArrowButton}/index.js +2 -2
  3. package/es/Pagination/{PaginationButton → v1/PaginationButton}/index.js +1 -1
  4. package/es/Pagination/{PaginationPageInput → v1/PaginationPageInput}/index.js +1 -1
  5. package/es/Pagination/{index.js → v1/index.js} +1 -1
  6. package/es/Pagination/v2/PaginationArrowButton/index.js +109 -0
  7. package/es/Pagination/v2/PaginationArrowButton/props.js +30 -0
  8. package/es/Pagination/v2/PaginationButton/index.js +77 -0
  9. package/es/Pagination/v2/PaginationButton/props.js +29 -0
  10. package/es/Pagination/v2/PaginationPageInput/index.js +189 -0
  11. package/es/Pagination/v2/PaginationPageInput/props.js +26 -0
  12. package/es/Pagination/v2/PaginationPageInput/styles.js +56 -0
  13. package/es/Pagination/v2/index.js +481 -0
  14. package/es/Pagination/v2/props.js +26 -0
  15. package/es/Pagination/v2/styles.js +58 -0
  16. package/es/{index.js → exports/a.js} +1 -1
  17. package/es/exports/b.js +24 -0
  18. package/lib/Pagination/{PaginationArrowButton → v1/PaginationArrowButton}/index.js +8 -8
  19. package/lib/Pagination/{PaginationButton → v1/PaginationButton}/index.js +2 -2
  20. package/lib/Pagination/{PaginationPageInput → v1/PaginationPageInput}/index.js +2 -2
  21. package/lib/Pagination/{index.js → v1/index.js} +6 -6
  22. package/lib/Pagination/v2/PaginationArrowButton/index.js +115 -0
  23. package/lib/Pagination/v2/PaginationArrowButton/props.js +35 -0
  24. package/lib/Pagination/v2/PaginationButton/index.js +83 -0
  25. package/lib/Pagination/v2/PaginationButton/props.js +34 -0
  26. package/lib/Pagination/v2/PaginationPageInput/index.js +194 -0
  27. package/lib/Pagination/v2/PaginationPageInput/props.js +31 -0
  28. package/lib/Pagination/v2/PaginationPageInput/styles.js +62 -0
  29. package/lib/Pagination/v2/index.js +496 -0
  30. package/lib/Pagination/v2/props.js +31 -0
  31. package/lib/Pagination/v2/styles.js +64 -0
  32. package/lib/{index.js → exports/a.js} +3 -3
  33. package/lib/exports/b.js +18 -0
  34. package/package.json +48 -25
  35. package/src/Pagination/{PaginationArrowButton → v1/PaginationArrowButton}/index.tsx +2 -2
  36. package/src/Pagination/{PaginationArrowButton → v1/PaginationArrowButton}/props.ts +1 -1
  37. package/src/Pagination/{PaginationButton → v1/PaginationButton}/index.tsx +1 -1
  38. package/src/Pagination/{PaginationButton → v1/PaginationButton}/props.ts +1 -1
  39. package/src/Pagination/{PaginationPageInput → v1/PaginationPageInput}/index.tsx +1 -1
  40. package/src/Pagination/{index.tsx → v1/index.tsx} +1 -1
  41. package/src/Pagination/v2/PaginationArrowButton/index.tsx +120 -0
  42. package/src/Pagination/v2/PaginationArrowButton/props.ts +74 -0
  43. package/src/Pagination/v2/PaginationButton/index.tsx +82 -0
  44. package/src/Pagination/v2/PaginationButton/props.ts +77 -0
  45. package/src/Pagination/v2/PaginationPageInput/index.tsx +242 -0
  46. package/src/Pagination/v2/PaginationPageInput/props.ts +95 -0
  47. package/src/Pagination/v2/PaginationPageInput/styles.ts +62 -0
  48. package/src/Pagination/v2/README.md +417 -0
  49. package/src/Pagination/v2/index.tsx +665 -0
  50. package/src/Pagination/v2/props.ts +245 -0
  51. package/src/Pagination/v2/styles.ts +64 -0
  52. package/src/exports/a.ts +29 -0
  53. package/src/exports/b.ts +29 -0
  54. package/tsconfig.build.json +1 -0
  55. package/tsconfig.build.tsbuildinfo +1 -1
  56. package/types/Pagination/v1/PaginationArrowButton/index.d.ts.map +1 -0
  57. package/types/Pagination/{PaginationArrowButton → v1/PaginationArrowButton}/props.d.ts +1 -1
  58. package/types/Pagination/v1/PaginationArrowButton/props.d.ts.map +1 -0
  59. package/types/Pagination/v1/PaginationButton/index.d.ts.map +1 -0
  60. package/types/Pagination/{PaginationButton → v1/PaginationButton}/props.d.ts +1 -1
  61. package/types/Pagination/v1/PaginationButton/props.d.ts.map +1 -0
  62. package/types/Pagination/v1/PaginationPageInput/index.d.ts.map +1 -0
  63. package/types/Pagination/v1/PaginationPageInput/props.d.ts.map +1 -0
  64. package/types/Pagination/v1/PaginationPageInput/styles.d.ts.map +1 -0
  65. package/types/Pagination/v1/PaginationPageInput/theme.d.ts.map +1 -0
  66. package/types/Pagination/v1/index.d.ts.map +1 -0
  67. package/types/Pagination/v1/props.d.ts.map +1 -0
  68. package/types/Pagination/v1/styles.d.ts.map +1 -0
  69. package/types/Pagination/v1/theme.d.ts.map +1 -0
  70. package/types/Pagination/v2/PaginationArrowButton/index.d.ts +27 -0
  71. package/types/Pagination/v2/PaginationArrowButton/index.d.ts.map +1 -0
  72. package/types/Pagination/v2/PaginationArrowButton/props.d.ts +17 -0
  73. package/types/Pagination/v2/PaginationArrowButton/props.d.ts.map +1 -0
  74. package/types/Pagination/v2/PaginationButton/index.d.ts +26 -0
  75. package/types/Pagination/v2/PaginationButton/index.d.ts.map +1 -0
  76. package/types/Pagination/v2/PaginationButton/props.d.ts +30 -0
  77. package/types/Pagination/v2/PaginationButton/props.d.ts.map +1 -0
  78. package/types/Pagination/v2/PaginationPageInput/index.d.ts +50 -0
  79. package/types/Pagination/v2/PaginationPageInput/index.d.ts.map +1 -0
  80. package/types/Pagination/v2/PaginationPageInput/props.d.ts +45 -0
  81. package/types/Pagination/v2/PaginationPageInput/props.d.ts.map +1 -0
  82. package/types/Pagination/v2/PaginationPageInput/styles.d.ts +16 -0
  83. package/types/Pagination/v2/PaginationPageInput/styles.d.ts.map +1 -0
  84. package/types/Pagination/v2/index.d.ts +106 -0
  85. package/types/Pagination/v2/index.d.ts.map +1 -0
  86. package/types/Pagination/v2/props.d.ts +138 -0
  87. package/types/Pagination/v2/props.d.ts.map +1 -0
  88. package/types/Pagination/v2/styles.d.ts +16 -0
  89. package/types/Pagination/v2/styles.d.ts.map +1 -0
  90. package/types/exports/a.d.ts +5 -0
  91. package/types/exports/a.d.ts.map +1 -0
  92. package/types/exports/b.d.ts +5 -0
  93. package/types/exports/b.d.ts.map +1 -0
  94. package/src/index.ts +0 -29
  95. package/types/Pagination/PaginationArrowButton/index.d.ts.map +0 -1
  96. package/types/Pagination/PaginationArrowButton/props.d.ts.map +0 -1
  97. package/types/Pagination/PaginationButton/index.d.ts.map +0 -1
  98. package/types/Pagination/PaginationButton/props.d.ts.map +0 -1
  99. package/types/Pagination/PaginationPageInput/index.d.ts.map +0 -1
  100. package/types/Pagination/PaginationPageInput/props.d.ts.map +0 -1
  101. package/types/Pagination/PaginationPageInput/styles.d.ts.map +0 -1
  102. package/types/Pagination/PaginationPageInput/theme.d.ts.map +0 -1
  103. package/types/Pagination/index.d.ts.map +0 -1
  104. package/types/Pagination/props.d.ts.map +0 -1
  105. package/types/Pagination/styles.d.ts.map +0 -1
  106. package/types/Pagination/theme.d.ts.map +0 -1
  107. package/types/index.d.ts +0 -5
  108. package/types/index.d.ts.map +0 -1
  109. /package/es/Pagination/{PaginationArrowButton → v1/PaginationArrowButton}/props.js +0 -0
  110. /package/es/Pagination/{PaginationButton → v1/PaginationButton}/props.js +0 -0
  111. /package/es/Pagination/{PaginationPageInput → v1/PaginationPageInput}/props.js +0 -0
  112. /package/es/Pagination/{PaginationPageInput → v1/PaginationPageInput}/styles.js +0 -0
  113. /package/es/Pagination/{PaginationPageInput → v1/PaginationPageInput}/theme.js +0 -0
  114. /package/es/Pagination/{props.js → v1/props.js} +0 -0
  115. /package/es/Pagination/{styles.js → v1/styles.js} +0 -0
  116. /package/es/Pagination/{theme.js → v1/theme.js} +0 -0
  117. /package/lib/Pagination/{PaginationArrowButton → v1/PaginationArrowButton}/props.js +0 -0
  118. /package/lib/Pagination/{PaginationButton → v1/PaginationButton}/props.js +0 -0
  119. /package/lib/Pagination/{PaginationPageInput → v1/PaginationPageInput}/props.js +0 -0
  120. /package/lib/Pagination/{PaginationPageInput → v1/PaginationPageInput}/styles.js +0 -0
  121. /package/lib/Pagination/{PaginationPageInput → v1/PaginationPageInput}/theme.js +0 -0
  122. /package/lib/Pagination/{props.js → v1/props.js} +0 -0
  123. /package/lib/Pagination/{styles.js → v1/styles.js} +0 -0
  124. /package/lib/Pagination/{theme.js → v1/theme.js} +0 -0
  125. /package/src/Pagination/{PaginationPageInput → v1/PaginationPageInput}/props.ts +0 -0
  126. /package/src/Pagination/{PaginationPageInput → v1/PaginationPageInput}/styles.ts +0 -0
  127. /package/src/Pagination/{PaginationPageInput → v1/PaginationPageInput}/theme.ts +0 -0
  128. /package/src/Pagination/{README.md → v1/README.md} +0 -0
  129. /package/src/Pagination/{props.ts → v1/props.ts} +0 -0
  130. /package/src/Pagination/{styles.ts → v1/styles.ts} +0 -0
  131. /package/src/Pagination/{theme.ts → v1/theme.ts} +0 -0
  132. /package/types/Pagination/{PaginationArrowButton → v1/PaginationArrowButton}/index.d.ts +0 -0
  133. /package/types/Pagination/{PaginationButton → v1/PaginationButton}/index.d.ts +0 -0
  134. /package/types/Pagination/{PaginationPageInput → v1/PaginationPageInput}/index.d.ts +0 -0
  135. /package/types/Pagination/{PaginationPageInput → v1/PaginationPageInput}/props.d.ts +0 -0
  136. /package/types/Pagination/{PaginationPageInput → v1/PaginationPageInput}/styles.d.ts +0 -0
  137. /package/types/Pagination/{PaginationPageInput → v1/PaginationPageInput}/theme.d.ts +0 -0
  138. /package/types/Pagination/{index.d.ts → v1/index.d.ts} +0 -0
  139. /package/types/Pagination/{props.d.ts → v1/props.d.ts} +0 -0
  140. /package/types/Pagination/{styles.d.ts → v1/styles.d.ts} +0 -0
  141. /package/types/Pagination/{theme.d.ts → v1/theme.d.ts} +0 -0
@@ -0,0 +1,481 @@
1
+ var _dec, _dec2, _class, _Pagination;
2
+ /*
3
+ * The MIT License (MIT)
4
+ *
5
+ * Copyright (c) 2015 - present Instructure, Inc.
6
+ *
7
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ * of this software and associated documentation files (the "Software"), to deal
9
+ * in the Software without restriction, including without limitation the rights
10
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ * copies of the Software, and to permit persons to whom the Software is
12
+ * furnished to do so, subject to the following conditions:
13
+ *
14
+ * The above copyright notice and this permission notice shall be included in all
15
+ * copies or substantial portions of the Software.
16
+ *
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ * SOFTWARE.
24
+ */
25
+ import { cloneElement, Children, Component } from 'react';
26
+ import { Text } from '@instructure/ui-text/latest';
27
+ import { View } from '@instructure/ui-view/latest';
28
+ import { omitProps, withDeterministicId } from '@instructure/ui-react-utils';
29
+ import { hasVisibleChildren } from '@instructure/ui-a11y-utils';
30
+ import { findTabbable, getActiveElement } from '@instructure/ui-dom-utils';
31
+ import { withStyle } from '@instructure/emotion';
32
+ import { PaginationButton } from "./PaginationButton/index.js";
33
+ import { PaginationArrowButton } from "./PaginationArrowButton/index.js";
34
+ import { PaginationPageInput } from "./PaginationPageInput/index.js";
35
+ import generateStyle from "./styles.js";
36
+ import { allowedProps } from "./props.js";
37
+ import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
38
+ /** This is an [].findIndex optimized to work on really big, but sparse, arrays */
39
+ const fastFindIndex = (arr, fn) => Number(Object.keys(arr).find(k => fn(arr[Number(k)])));
40
+ const childrenArray = props => {
41
+ const children = props.children;
42
+ if (!children) {
43
+ return [];
44
+ }
45
+ return Array.isArray(children) ? children : [children];
46
+ };
47
+ function propsHaveCompactView(props) {
48
+ if (props.children) return props.variant === 'compact' && childrenArray(props).length > 5;
49
+ return props.variant === 'compact' && props.totalPageNumber > 5;
50
+ }
51
+ /**
52
+ ---
53
+ category: components
54
+ ---
55
+ **/
56
+ let Pagination = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle), _dec(_class = _dec2(_class = (_Pagination = class Pagination extends Component {
57
+ constructor(props) {
58
+ super(props);
59
+ this._labelId = void 0;
60
+ this._firstButton = null;
61
+ this._prevButton = null;
62
+ this._nextButton = null;
63
+ this._lastButton = null;
64
+ this.ref = null;
65
+ this.currentPageRef = null;
66
+ this.handleElementRef = el => {
67
+ this.ref = el;
68
+ if (el && typeof this.props.elementRef === 'function') {
69
+ this.props.elementRef(el);
70
+ }
71
+ };
72
+ this.handleInputRef = el => {
73
+ if (typeof this.props.inputRef === 'function') {
74
+ this.props.inputRef(el);
75
+ }
76
+ };
77
+ this.renderDefaultPageInput = () => {
78
+ const _this$props = this.props,
79
+ currentPage = _this$props.currentPage,
80
+ totalPageNumber = _this$props.totalPageNumber;
81
+ return _jsx(PaginationPageInput, {
82
+ numberOfPages: totalPageNumber,
83
+ currentPageIndex: currentPage - 1,
84
+ onChange: (_e, nextPageIndex) => {
85
+ var _this$props$onPageCha, _this$props2;
86
+ return (_this$props$onPageCha = (_this$props2 = this.props).onPageChange) === null || _this$props$onPageCha === void 0 ? void 0 : _this$props$onPageCha.call(_this$props2, nextPageIndex + 1, currentPage);
87
+ },
88
+ screenReaderLabel: this.props.screenReaderLabelNumberInput,
89
+ label: this.props.labelNumberInput,
90
+ disabled: this.props.disabled,
91
+ inputRef: this.handleInputRef
92
+ });
93
+ };
94
+ this.handleNavigation = (nextIndex, previousIndex) => {
95
+ const onPageChange = this.props.onPageChange;
96
+ if (typeof onPageChange === 'function') {
97
+ onPageChange(nextIndex, previousIndex);
98
+ }
99
+ };
100
+ this.renderPagesInInterval = (from, to, currentPage) => {
101
+ if (to - from > 1000) throw new Error('Pagination: too many pages (more than 1000)');
102
+ const pages = [];
103
+ for (let i = from; i <= to; i++) {
104
+ var _this$props$renderPag, _this$props3;
105
+ pages.push(_jsx(Pagination.Page, {
106
+ ref: e => {
107
+ if (i === currentPage) {
108
+ this.currentPageRef = e;
109
+ }
110
+ },
111
+ onClick: () => this.handleNavigation(i, currentPage),
112
+ onMouseEnter: () => this.handleOnMouseEnter(i),
113
+ current: i === currentPage,
114
+ ...(this.props.screenReaderLabelPageButton ? {
115
+ screenReaderLabel: this.props.screenReaderLabelPageButton(i, this.props.totalPageNumber)
116
+ } : {}),
117
+ children: (_this$props$renderPag = (_this$props3 = this.props).renderPageIndicator) === null || _this$props$renderPag === void 0 ? void 0 : _this$props$renderPag.call(_this$props3, i, currentPage)
118
+ }, i));
119
+ }
120
+ return pages;
121
+ };
122
+ this.renderDefaultPages = () => {
123
+ var _this$props$styles3;
124
+ const _this$props4 = this.props,
125
+ ellipsis = _this$props4.ellipsis,
126
+ currentPage = _this$props4.currentPage,
127
+ totalPageNumber = _this$props4.totalPageNumber,
128
+ siblingCount = _this$props4.siblingCount,
129
+ boundaryCount = _this$props4.boundaryCount,
130
+ variant = _this$props4.variant;
131
+ const pages = [];
132
+ if (totalPageNumber <= 2 * boundaryCount || totalPageNumber <= 1 + siblingCount + boundaryCount || variant === 'full') {
133
+ var _this$props$styles;
134
+ return _jsx("ul", {
135
+ css: (_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.pageIndicatorList,
136
+ children: this.renderPagesInInterval(1, totalPageNumber, currentPage)
137
+ });
138
+ }
139
+ if (currentPage > boundaryCount + siblingCount + 1) {
140
+ pages.push(this.renderPagesInInterval(1, boundaryCount, currentPage));
141
+ pages.push(_jsx("li", {
142
+ style: {
143
+ all: 'unset'
144
+ },
145
+ children: _jsx(Text, {
146
+ children: ellipsis
147
+ })
148
+ }, "ellipsis1"));
149
+ if (currentPage - siblingCount > totalPageNumber - boundaryCount + 1) {
150
+ var _this$props$styles2;
151
+ pages.push(this.renderPagesInInterval(totalPageNumber - boundaryCount + 1, totalPageNumber, currentPage));
152
+ return _jsx("ul", {
153
+ css: (_this$props$styles2 = this.props.styles) === null || _this$props$styles2 === void 0 ? void 0 : _this$props$styles2.pageIndicatorList,
154
+ children: pages
155
+ });
156
+ }
157
+ pages.push(this.renderPagesInInterval(currentPage - siblingCount, currentPage, currentPage));
158
+ } else {
159
+ pages.push(this.renderPagesInInterval(1, Math.max(currentPage, boundaryCount), currentPage));
160
+ }
161
+ if (currentPage < totalPageNumber - (siblingCount + boundaryCount)) {
162
+ pages.push(this.renderPagesInInterval(Math.max(currentPage, boundaryCount) + 1, currentPage + siblingCount, currentPage));
163
+ pages.push(_jsx("li", {
164
+ style: {
165
+ all: 'unset'
166
+ },
167
+ children: _jsx(Text, {
168
+ children: ellipsis
169
+ })
170
+ }, "ellipsis2"));
171
+ pages.push(this.renderPagesInInterval(totalPageNumber - boundaryCount + 1, totalPageNumber, currentPage));
172
+ } else {
173
+ pages.push(this.renderPagesInInterval(currentPage + 1, totalPageNumber, currentPage));
174
+ }
175
+ return _jsx("ul", {
176
+ css: (_this$props$styles3 = this.props.styles) === null || _this$props$styles3 === void 0 ? void 0 : _this$props$styles3.pageIndicatorList,
177
+ children: pages
178
+ });
179
+ };
180
+ this.renderDefaultArrowButton = direction => {
181
+ if (!this.withFirstAndLastButton && (direction === 'first' || direction === 'last')) {
182
+ return null;
183
+ }
184
+ // We don't display the arrows in "compact" variant under 6 items
185
+ if (!(propsHaveCompactView(this.props) || this.inputMode)) {
186
+ return null;
187
+ }
188
+ const _this$props5 = this.props,
189
+ totalPageNumber = _this$props5.totalPageNumber,
190
+ currentPage = _this$props5.currentPage;
191
+ const _this$getArrowVariant = this.getArrowVariant(direction, currentPage - 1, totalPageNumber),
192
+ label = _this$getArrowVariant.label,
193
+ shouldEnableIcon = _this$getArrowVariant.shouldEnableIcon,
194
+ handleButtonRef = _this$getArrowVariant.handleButtonRef;
195
+ const disabled = this.props.disabled || !shouldEnableIcon;
196
+ const onClick = () => {
197
+ if (direction === 'first') {
198
+ this.handleNavigation(1, currentPage);
199
+ }
200
+ if (direction === 'prev') {
201
+ this.handleNavigation(Math.max(currentPage - 1, 1), currentPage);
202
+ }
203
+ if (direction === 'next') {
204
+ this.handleNavigation(Math.min(currentPage + 1, totalPageNumber), currentPage);
205
+ }
206
+ if (direction === 'last') {
207
+ this.handleNavigation(totalPageNumber, currentPage);
208
+ }
209
+ };
210
+ return shouldEnableIcon || this.showDisabledButtons ? _jsx(PaginationArrowButton, {
211
+ direction: direction,
212
+ "data-direction": direction,
213
+ label: label,
214
+ onClick: onClick,
215
+ disabled: disabled,
216
+ buttonRef: handleButtonRef
217
+ }) : null;
218
+ };
219
+ this.handleOnMouseEnter = page => {
220
+ if (typeof this.props.onMouseEnter === 'function') {
221
+ this.props.onMouseEnter(page);
222
+ }
223
+ };
224
+ this._labelId = props.deterministicId();
225
+ }
226
+ get _root() {
227
+ return this.ref;
228
+ }
229
+ get inputMode() {
230
+ return this.props.variant === 'input';
231
+ }
232
+ get childPages() {
233
+ return childrenArray(this.props);
234
+ }
235
+ get withFirstAndLastButton() {
236
+ return this.inputMode || this.props.withFirstAndLastButton;
237
+ }
238
+ get showDisabledButtons() {
239
+ return this.inputMode || this.props.showDisabledButtons;
240
+ }
241
+ getSnapshotBeforeUpdate() {
242
+ const activeElement = getActiveElement();
243
+ if (activeElement === this._firstButton || activeElement === this._prevButton || activeElement === this._nextButton || activeElement === this._lastButton) {
244
+ return {
245
+ lastFocusedButton: activeElement
246
+ };
247
+ } else {
248
+ return {
249
+ lastFocusedButton: void 0
250
+ };
251
+ }
252
+ }
253
+ componentDidMount() {
254
+ var _this$props$makeStyle, _this$props6;
255
+ (_this$props$makeStyle = (_this$props6 = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props6);
256
+ }
257
+ componentDidUpdate(prevProps, _prevState, snapshot) {
258
+ var _this$props$makeStyle2, _this$props7;
259
+ (_this$props$makeStyle2 = (_this$props7 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props7);
260
+
261
+ // set focus on the currently active page
262
+ if (this.props.currentPage !== prevProps.currentPage && document.activeElement !== this._firstButton && document.activeElement !== this._prevButton && document.activeElement !== this._nextButton && document.activeElement !== this._lastButton) {
263
+ var _this$currentPageRef, _this$currentPageRef$, _this$currentPageRef$2;
264
+ // @ts-expect-error fix typing
265
+ (_this$currentPageRef = this.currentPageRef) === null || _this$currentPageRef === void 0 ? void 0 : (_this$currentPageRef$ = _this$currentPageRef.ref) === null || _this$currentPageRef$ === void 0 ? void 0 : (_this$currentPageRef$2 = _this$currentPageRef$.focus) === null || _this$currentPageRef$2 === void 0 ? void 0 : _this$currentPageRef$2.call(_this$currentPageRef$);
266
+ }
267
+ if (!this.props.shouldHandleFocus || !propsHaveCompactView(prevProps) && !propsHaveCompactView(this.props)) {
268
+ return;
269
+ } else {
270
+ this.focusElementAfterUpdate(snapshot);
271
+ }
272
+ }
273
+ focusElementAfterUpdate(snapshot) {
274
+ const lastFocusedButton = snapshot.lastFocusedButton;
275
+ if (lastFocusedButton) {
276
+ var _nextFocusElement;
277
+ const focusable = findTabbable(this.ref);
278
+ const direction = lastFocusedButton.dataset.direction;
279
+
280
+ // By default we want to focus the previously focused button
281
+ let nextFocusElement = lastFocusedButton;
282
+
283
+ // In case the button is not focusable anymore
284
+ // (disabled or not in the DOM), we focus to the next available page
285
+ if (!focusable.includes(nextFocusElement)) {
286
+ if (direction === 'first' || direction === 'prev') {
287
+ nextFocusElement = focusable[0];
288
+ }
289
+ if (direction === 'next' || direction === 'last') {
290
+ nextFocusElement = focusable[focusable.length - 1];
291
+ }
292
+ }
293
+ ;
294
+ (_nextFocusElement = nextFocusElement) === null || _nextFocusElement === void 0 ? void 0 : _nextFocusElement.focus();
295
+ }
296
+ }
297
+ get compactView() {
298
+ return propsHaveCompactView(this.props);
299
+ }
300
+ transferDisabledPropToChildren(children) {
301
+ return children && this.props.disabled ? Children.map(children, page => /*#__PURE__*/cloneElement(page, {
302
+ disabled: this.props.disabled
303
+ })) : children;
304
+ }
305
+ renderLabel() {
306
+ const display = this.props.variant === 'full' ? 'inline-block' : 'block';
307
+ const visibleLabel = hasVisibleChildren(this.props.label);
308
+ return _jsx(View, {
309
+ padding: visibleLabel ? 'small' : '0',
310
+ display: visibleLabel ? display : 'auto',
311
+ id: this._labelId,
312
+ children: _jsx(Text, {
313
+ variant: "content",
314
+ children: this.props.label
315
+ })
316
+ });
317
+ }
318
+ renderPageInput(currentPageIndex) {
319
+ if (!this.props.children) return this.renderDefaultPageInput();
320
+ return _jsx(PaginationPageInput, {
321
+ numberOfPages: this.childPages.length,
322
+ currentPageIndex: currentPageIndex,
323
+ onChange: this.handleInputChange.bind(this),
324
+ screenReaderLabel: this.props.screenReaderLabelNumberInput,
325
+ label: this.props.labelNumberInput,
326
+ disabled: this.props.disabled,
327
+ inputRef: this.handleInputRef
328
+ });
329
+ }
330
+ handleInputChange(event, pageIndex) {
331
+ var _this$childPages$page, _this$childPages$page2;
332
+ (_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);
333
+ }
334
+ renderPages(currentPageIndex) {
335
+ if (!this.props.children) return this.renderDefaultPages();
336
+ const allPages = this.childPages;
337
+ let visiblePages = allPages;
338
+ if (this.compactView) {
339
+ const firstIndex = 0;
340
+ const lastIndex = allPages.length - 1;
341
+ const sliceStart = Math.min(lastIndex - 3, Math.max(currentPageIndex - 1, firstIndex));
342
+ const sliceEnd = Math.min(currentPageIndex + 4, lastIndex);
343
+ visiblePages = allPages.slice(sliceStart, sliceEnd);
344
+ const firstPage = allPages[firstIndex];
345
+ const lastPage = allPages[lastIndex];
346
+ if (sliceStart - firstIndex > 1) visiblePages.unshift(_jsx("li", {
347
+ style: {
348
+ all: 'unset'
349
+ },
350
+ "aria-hidden": "true",
351
+ children: _jsx(Text, {
352
+ children: this.props.ellipsis
353
+ })
354
+ }, "first"));
355
+ if (sliceStart - firstIndex > 0) visiblePages.unshift(firstPage);
356
+ if (lastIndex - sliceEnd + 1 > 1) visiblePages.push(_jsx("li", {
357
+ style: {
358
+ all: 'unset'
359
+ },
360
+ "aria-hidden": "true",
361
+ children: _jsx(Text, {
362
+ children: this.props.ellipsis
363
+ })
364
+ }, "last"));
365
+ if (lastIndex - sliceEnd + 1 > 0) visiblePages.push(lastPage);
366
+ }
367
+ return _jsx(View, {
368
+ display: "inline-block",
369
+ as: "ul",
370
+ margin: "0",
371
+ padding: "0",
372
+ children: this.transferDisabledPropToChildren(visiblePages)
373
+ });
374
+ }
375
+ getArrowVariant(direction, currentPageIndex, pagesCount) {
376
+ switch (direction) {
377
+ case 'first':
378
+ return {
379
+ pageIndex: 0,
380
+ label: this.props.labelFirst || 'First Page',
381
+ shouldEnableIcon: currentPageIndex > 1,
382
+ handleButtonRef: el => {
383
+ this._firstButton = el;
384
+ }
385
+ };
386
+ case 'prev':
387
+ return {
388
+ pageIndex: currentPageIndex - 1,
389
+ label: this.props.labelPrev || 'Previous Page',
390
+ shouldEnableIcon: currentPageIndex > 0,
391
+ handleButtonRef: el => {
392
+ this._prevButton = el;
393
+ }
394
+ };
395
+ case 'next':
396
+ return {
397
+ pageIndex: currentPageIndex + 1,
398
+ label: this.props.labelNext || 'Next Page',
399
+ shouldEnableIcon: currentPageIndex < pagesCount - 1,
400
+ handleButtonRef: el => {
401
+ this._nextButton = el;
402
+ }
403
+ };
404
+ case 'last':
405
+ return {
406
+ pageIndex: pagesCount - 1,
407
+ label: this.props.labelLast || 'Last Page',
408
+ shouldEnableIcon: currentPageIndex < pagesCount - 2,
409
+ handleButtonRef: el => {
410
+ this._lastButton = el;
411
+ }
412
+ };
413
+ }
414
+ }
415
+ renderArrowButton(direction, currentPageIndex) {
416
+ var _page$props, _page$props2;
417
+ if (!this.props.children) return this.renderDefaultArrowButton(direction);
418
+ const childPages = this.childPages;
419
+ // We don't display the arrows in "compact" variant under 6 items
420
+ if (!(propsHaveCompactView(this.props) || this.inputMode)) {
421
+ return null;
422
+ }
423
+ if (!this.withFirstAndLastButton && (direction === 'first' || direction === 'last')) {
424
+ return null;
425
+ }
426
+ const _this$getArrowVariant2 = this.getArrowVariant(direction, currentPageIndex, childPages.length),
427
+ pageIndex = _this$getArrowVariant2.pageIndex,
428
+ label = _this$getArrowVariant2.label,
429
+ shouldEnableIcon = _this$getArrowVariant2.shouldEnableIcon,
430
+ handleButtonRef = _this$getArrowVariant2.handleButtonRef;
431
+ const page = childPages[pageIndex];
432
+ 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;
433
+ const onClick = page === null || page === void 0 ? void 0 : (_page$props2 = page.props) === null || _page$props2 === void 0 ? void 0 : _page$props2.onClick;
434
+ return shouldEnableIcon || this.showDisabledButtons ? _jsx(PaginationArrowButton, {
435
+ direction: direction,
436
+ "data-direction": direction,
437
+ label: label,
438
+ onClick: onClick,
439
+ disabled: disabled,
440
+ buttonRef: handleButtonRef
441
+ }) : null;
442
+ }
443
+ render() {
444
+ var _this$props$styles4, _this$props$styles5;
445
+ const currentPageIndex = fastFindIndex(this.childPages, p => p && p.props && p.props.current);
446
+ const passthroughProps = View.omitViewProps(omitProps(this.props, Pagination.allowedProps), Pagination);
447
+ return _jsxs(View, {
448
+ ...passthroughProps,
449
+ role: "navigation",
450
+ as: this.props.as,
451
+ elementRef: this.handleElementRef,
452
+ margin: this.props.margin,
453
+ css: (_this$props$styles4 = this.props.styles) === null || _this$props$styles4 === void 0 ? void 0 : _this$props$styles4.pagination,
454
+ "aria-labelledby": this.props.label ? this._labelId : void 0,
455
+ "data-cid": "Pagination",
456
+ children: [this.props.label && this.renderLabel(), _jsxs(View, {
457
+ display: "inline-block",
458
+ css: (_this$props$styles5 = this.props.styles) === null || _this$props$styles5 === void 0 ? void 0 : _this$props$styles5.pages,
459
+ children: [this.renderArrowButton('first', currentPageIndex), this.renderArrowButton('prev', currentPageIndex), this.inputMode ? this.renderPageInput(currentPageIndex) : this.renderPages(currentPageIndex), this.renderArrowButton('next', currentPageIndex), this.renderArrowButton('last', currentPageIndex)]
460
+ })]
461
+ });
462
+ }
463
+ }, _Pagination.displayName = "Pagination", _Pagination.componentId = 'Pagination', _Pagination.allowedProps = allowedProps, _Pagination.defaultProps = {
464
+ disabled: false,
465
+ withFirstAndLastButton: false,
466
+ showDisabledButtons: false,
467
+ variant: 'full',
468
+ as: 'div',
469
+ labelNumberInput: numberOfPages => `of ${numberOfPages}`,
470
+ screenReaderLabelNumberInput: (currentPage, numberOfPages) => `Select page (${currentPage} of ${numberOfPages})`,
471
+ shouldHandleFocus: true,
472
+ totalPageNumber: 0,
473
+ currentPage: 1,
474
+ siblingCount: 1,
475
+ boundaryCount: 1,
476
+ ellipsis: '…',
477
+ renderPageIndicator: page => page,
478
+ margin: 'space8'
479
+ }, _Pagination.Page = PaginationButton, _Pagination.Navigation = PaginationArrowButton, _Pagination.PageInput = PaginationPageInput, _Pagination)) || _class) || _class);
480
+ export default Pagination;
481
+ export { Pagination, PaginationButton };
@@ -0,0 +1,26 @@
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
+ const allowedProps = ['children', 'disabled', 'withFirstAndLastButton', 'showDisabledButtons', 'label', 'labelNext', 'labelPrev', 'labelFirst', 'labelLast', 'labelNumberInput', 'screenReaderLabelNumberInput', 'screenReaderLabelPageButton', 'variant', 'margin', 'as', 'elementRef', 'inputRef', 'shouldHandleFocus', 'totalPageNumber', 'currentPage', 'onPageChange', 'siblingCount', 'boundaryCount', 'renderPageIndicator', 'ellipsis', 'onMouseEnter'];
26
+ export { allowedProps };
@@ -0,0 +1,58 @@
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
+ * ---
27
+ * private: true
28
+ * ---
29
+ * Generates the style object from the theme and provided additional information
30
+ * @param {Object} componentTheme The theme variable object.
31
+ * @param {Object} props the props of the component, the style is applied to
32
+ * @param {Object} sharedTokens Shared token object that stores common values for the theme.
33
+ * @param {Object} state the state of the component, the style is applied to
34
+ * @return {Object} The final style object, which will be used in the component
35
+ */
36
+ const generateStyle = componentTheme => {
37
+ return {
38
+ pageIndicatorList: {
39
+ all: 'unset',
40
+ display: 'flex',
41
+ alignItems: 'center',
42
+ gap: componentTheme.pageIndicatorGap,
43
+ flexWrap: 'wrap',
44
+ justifyContent: 'center'
45
+ },
46
+ pagination: {
47
+ label: 'pagination',
48
+ textAlign: 'center'
49
+ },
50
+ pages: {
51
+ label: 'pagination__pages',
52
+ display: 'inline-flex',
53
+ alignItems: 'center',
54
+ gap: componentTheme.pageIndicatorGap
55
+ }
56
+ };
57
+ };
58
+ export default generateStyle;
@@ -21,4 +21,4 @@
21
21
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
22
  * SOFTWARE.
23
23
  */
24
- export { Pagination, PaginationButton } from "./Pagination/index.js";
24
+ export { Pagination, PaginationButton } from "../Pagination/v1/index.js";
@@ -0,0 +1,24 @@
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
+ export { Pagination, PaginationButton } from "../Pagination/v2/index.js";
@@ -7,13 +7,13 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.default = exports.PaginationArrowButton = void 0;
8
8
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
9
9
  var _react = require("react");
10
- var _IconButton = require("@instructure/ui-buttons/lib/IconButton");
10
+ var _v11_ = require("@instructure/ui-buttons/v11_6");
11
11
  var _PresentationContent = require("@instructure/ui-a11y-content/lib/PresentationContent");
12
- var _Tooltip = require("@instructure/ui-tooltip/lib/Tooltip");
13
- var _IconArrowOpenStartSolid = require("@instructure/ui-icons/lib/IconArrowOpenStartSolid.js");
14
- var _IconArrowOpenEndSolid = require("@instructure/ui-icons/lib/IconArrowOpenEndSolid.js");
15
- var _IconArrowDoubleStartSolid = require("@instructure/ui-icons/lib/IconArrowDoubleStartSolid.js");
16
- var _IconArrowDoubleEndSolid = require("@instructure/ui-icons/lib/IconArrowDoubleEndSolid.js");
12
+ var _v11_2 = require("@instructure/ui-tooltip/v11_6");
13
+ var _IconArrowOpenStartSolid = require("@instructure/ui-icons/lib/generated/IconArrowOpenStartSolid.js");
14
+ var _IconArrowOpenEndSolid = require("@instructure/ui-icons/lib/generated/IconArrowOpenEndSolid.js");
15
+ var _IconArrowDoubleStartSolid = require("@instructure/ui-icons/lib/generated/IconArrowDoubleStartSolid.js");
16
+ var _IconArrowDoubleEndSolid = require("@instructure/ui-icons/lib/generated/IconArrowDoubleEndSolid.js");
17
17
  var _props = require("./props");
18
18
  var _jsxRuntime = require("@emotion/react/jsx-runtime");
19
19
  const _excluded = ["label", "direction", "buttonRef"];
@@ -84,13 +84,13 @@ class PaginationArrowButton extends _react.Component {
84
84
  direction = _this$props.direction,
85
85
  buttonRef = _this$props.buttonRef,
86
86
  props = (0, _objectWithoutProperties2.default)(_this$props, _excluded);
87
- return (0, _jsxRuntime.jsx)(_Tooltip.Tooltip, {
87
+ return (0, _jsxRuntime.jsx)(_v11_2.Tooltip, {
88
88
  elementRef: this.handleRef,
89
89
  on: ['hover', 'focus'],
90
90
  renderTip: (0, _jsxRuntime.jsx)(_PresentationContent.PresentationContent, {
91
91
  children: label
92
92
  }),
93
- children: (0, _jsxRuntime.jsx)(_IconButton.IconButton, {
93
+ children: (0, _jsxRuntime.jsx)(_v11_.IconButton, {
94
94
  ...props,
95
95
  size: "small",
96
96
  withBackground: false,
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = exports.PaginationButton = void 0;
7
7
  var _react = require("react");
8
- var _BaseButton = require("@instructure/ui-buttons/lib/BaseButton");
8
+ var _v11_ = require("@instructure/ui-buttons/v11_6");
9
9
  var _omitProps = require("@instructure/ui-react-utils/lib/omitProps.js");
10
10
  var _props = require("./props");
11
11
  var _jsxRuntime = require("@emotion/react/jsx-runtime");
@@ -57,7 +57,7 @@ class PaginationButton extends _react.Component {
57
57
  style: {
58
58
  all: 'unset'
59
59
  },
60
- children: (0, _jsxRuntime.jsx)(_BaseButton.BaseButton, {
60
+ children: (0, _jsxRuntime.jsx)(_v11_.BaseButton, {
61
61
  color: "primary",
62
62
  "data-cid": "PaginationButton",
63
63
  withBackground: this.props.current,
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.default = exports.PaginationPageInput = void 0;
8
8
  var _react = require("react");
9
9
  var _emotion = require("@instructure/emotion");
10
- var _NumberInput = require("@instructure/ui-number-input/lib/NumberInput");
10
+ var _v11_ = require("@instructure/ui-number-input/v11_6");
11
11
  var _ScreenReaderContent = require("@instructure/ui-a11y-content/lib/ScreenReaderContent");
12
12
  var _styles = _interopRequireDefault(require("./styles"));
13
13
  var _theme = _interopRequireDefault(require("./theme"));
@@ -168,7 +168,7 @@ let PaginationPageInput = exports.PaginationPageInput = (_dec = (0, _emotion.wit
168
168
  "data-cid": "PaginationPageInput",
169
169
  children: [(0, _jsxRuntime.jsx)("span", {
170
170
  css: styles === null || styles === void 0 ? void 0 : styles.numberInput,
171
- children: (0, _jsxRuntime.jsx)(_NumberInput.NumberInput, {
171
+ children: (0, _jsxRuntime.jsx)(_v11_.NumberInput, {
172
172
  renderLabel: this.renderScreenReaderLabel(),
173
173
  onBlur: this.handleBlur,
174
174
  onChange: this.handleChange,