@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
@@ -13,7 +13,7 @@ Object.defineProperty(exports, "PaginationButton", {
13
13
  });
14
14
  exports.default = void 0;
15
15
  var _react = require("react");
16
- var _View = require("@instructure/ui-view/lib/View");
16
+ var _v11_ = require("@instructure/ui-view/v11_6");
17
17
  var _omitProps = require("@instructure/ui-react-utils/lib/omitProps.js");
18
18
  var _withDeterministicId = require("@instructure/ui-react-utils/lib/DeterministicIdContext/withDeterministicId.js");
19
19
  var _hasVisibleChildren = require("@instructure/ui-a11y-utils/lib/hasVisibleChildren.js");
@@ -317,7 +317,7 @@ let Pagination = exports.Pagination = (_dec = (0, _withDeterministicId.withDeter
317
317
  renderLabel() {
318
318
  const display = this.props.variant === 'full' ? 'inline-block' : 'block';
319
319
  const visibleLabel = (0, _hasVisibleChildren.hasVisibleChildren)(this.props.label);
320
- return (0, _jsxRuntime.jsx)(_View.View, {
320
+ return (0, _jsxRuntime.jsx)(_v11_.View, {
321
321
  as: "span",
322
322
  padding: visibleLabel ? 'small' : '0',
323
323
  display: visibleLabel ? display : 'auto',
@@ -370,7 +370,7 @@ let Pagination = exports.Pagination = (_dec = (0, _withDeterministicId.withDeter
370
370
  }, "last"));
371
371
  if (lastIndex - sliceEnd + 1 > 0) visiblePages.push(lastPage);
372
372
  }
373
- return (0, _jsxRuntime.jsx)(_View.View, {
373
+ return (0, _jsxRuntime.jsx)(_v11_.View, {
374
374
  display: "inline-block",
375
375
  as: "ul",
376
376
  margin: "0",
@@ -449,8 +449,8 @@ let Pagination = exports.Pagination = (_dec = (0, _withDeterministicId.withDeter
449
449
  render() {
450
450
  var _this$props$styles4, _this$props$styles5;
451
451
  const currentPageIndex = fastFindIndex(this.childPages, p => p && p.props && p.props.current);
452
- const passthroughProps = _View.View.omitViewProps((0, _omitProps.omitProps)(this.props, Pagination.allowedProps), Pagination);
453
- return (0, _jsxRuntime.jsxs)(_View.View, {
452
+ const passthroughProps = _v11_.View.omitViewProps((0, _omitProps.omitProps)(this.props, Pagination.allowedProps), Pagination);
453
+ return (0, _jsxRuntime.jsxs)(_v11_.View, {
454
454
  ...passthroughProps,
455
455
  role: "navigation",
456
456
  as: this.props.as,
@@ -459,7 +459,7 @@ let Pagination = exports.Pagination = (_dec = (0, _withDeterministicId.withDeter
459
459
  css: (_this$props$styles4 = this.props.styles) === null || _this$props$styles4 === void 0 ? void 0 : _this$props$styles4.pagination,
460
460
  "aria-labelledby": this.props.label ? this._labelId : void 0,
461
461
  "data-cid": "Pagination",
462
- children: [this.props.label && this.renderLabel(), (0, _jsxRuntime.jsxs)(_View.View, {
462
+ children: [this.props.label && this.renderLabel(), (0, _jsxRuntime.jsxs)(_v11_.View, {
463
463
  display: "inline-block",
464
464
  css: (_this$props$styles5 = this.props.styles) === null || _this$props$styles5 === void 0 ? void 0 : _this$props$styles5.pages,
465
465
  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)]
@@ -0,0 +1,115 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = exports.PaginationArrowButton = void 0;
8
+ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
9
+ var _react = require("react");
10
+ var _latest = require("@instructure/ui-buttons/latest");
11
+ var _PresentationContent = require("@instructure/ui-a11y-content/lib/PresentationContent");
12
+ var _latest2 = require("@instructure/ui-tooltip/latest");
13
+ var _uiIcons = require("@instructure/ui-icons");
14
+ var _props = require("./props");
15
+ var _jsxRuntime = require("@emotion/react/jsx-runtime");
16
+ const _excluded = ["label", "direction", "buttonRef"];
17
+ /*
18
+ * The MIT License (MIT)
19
+ *
20
+ * Copyright (c) 2015 - present Instructure, Inc.
21
+ *
22
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
23
+ * of this software and associated documentation files (the "Software"), to deal
24
+ * in the Software without restriction, including without limitation the rights
25
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
26
+ * copies of the Software, and to permit persons to whom the Software is
27
+ * furnished to do so, subject to the following conditions:
28
+ *
29
+ * The above copyright notice and this permission notice shall be included in all
30
+ * copies or substantial portions of the Software.
31
+ *
32
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
33
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
34
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
35
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
36
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
37
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
38
+ * SOFTWARE.
39
+ */
40
+ /**
41
+ ---
42
+ parent: Pagination
43
+ id: Pagination.Navigation
44
+ ---
45
+ **/
46
+ class PaginationArrowButton extends _react.Component {
47
+ constructor(...args) {
48
+ super(...args);
49
+ this.ref = null;
50
+ this.handleRef = el => {
51
+ this.ref = el;
52
+ };
53
+ }
54
+ get margin() {
55
+ switch (this.props.direction) {
56
+ case 'first':
57
+ return '0 xx-small 0 0';
58
+ case 'last':
59
+ return '0 0 0 xx-small';
60
+ default:
61
+ return void 0;
62
+ }
63
+ }
64
+ get Icon() {
65
+ switch (this.props.direction) {
66
+ case 'first':
67
+ return _uiIcons.ChevronsLeftInstUIIcon;
68
+ case 'prev':
69
+ return _uiIcons.ChevronLeftInstUIIcon;
70
+ case 'next':
71
+ return _uiIcons.ChevronRightInstUIIcon;
72
+ case 'last':
73
+ return _uiIcons.ChevronsRightInstUIIcon;
74
+ default:
75
+ return null;
76
+ }
77
+ }
78
+ renderIcon() {
79
+ const icon = this.Icon;
80
+ if (!icon) return null;
81
+ return (0, _uiIcons.renderIconWithProps)(icon, 'md', 'actionTertiaryBaseColor');
82
+ }
83
+ render() {
84
+ const _this$props = this.props,
85
+ label = _this$props.label,
86
+ direction = _this$props.direction,
87
+ buttonRef = _this$props.buttonRef,
88
+ props = (0, _objectWithoutProperties2.default)(_this$props, _excluded);
89
+ return (0, _jsxRuntime.jsx)(_latest2.Tooltip, {
90
+ elementRef: this.handleRef,
91
+ on: ['hover', 'focus'],
92
+ renderTip: (0, _jsxRuntime.jsx)(_PresentationContent.PresentationContent, {
93
+ children: label
94
+ }),
95
+ children: (0, _jsxRuntime.jsx)(_latest.IconButton, {
96
+ ...props,
97
+ size: "small",
98
+ withBackground: false,
99
+ withBorder: false,
100
+ screenReaderLabel: label,
101
+ rel: props.href || props.to ? direction : void 0,
102
+ elementRef: buttonRef,
103
+ margin: this.margin,
104
+ "data-cid": "PaginationArrowButton",
105
+ children: this.renderIcon()
106
+ })
107
+ });
108
+ }
109
+ }
110
+ exports.PaginationArrowButton = PaginationArrowButton;
111
+ PaginationArrowButton.displayName = "PaginationArrowButton";
112
+ PaginationArrowButton.componentId = 'Pagination.Navigation';
113
+ PaginationArrowButton.allowedProps = _props.allowedProps;
114
+ PaginationArrowButton.defaultProps = {};
115
+ var _default = exports.default = PaginationArrowButton;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.allowedProps = void 0;
7
+ /*
8
+ * The MIT License (MIT)
9
+ *
10
+ * Copyright (c) 2015 - present Instructure, Inc.
11
+ *
12
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
13
+ * of this software and associated documentation files (the "Software"), to deal
14
+ * in the Software without restriction, including without limitation the rights
15
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
+ * copies of the Software, and to permit persons to whom the Software is
17
+ * furnished to do so, subject to the following conditions:
18
+ *
19
+ * The above copyright notice and this permission notice shall be included in all
20
+ * copies or substantial portions of the Software.
21
+ *
22
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
+ * SOFTWARE.
29
+ */
30
+
31
+ const allowedProps = exports.allowedProps = ['direction', 'label', 'buttonRef'
32
+
33
+ // we don't want to pass onClick
34
+ // 'onClick'
35
+ ];
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = exports.PaginationButton = void 0;
7
+ var _react = require("react");
8
+ var _latest = require("@instructure/ui-buttons/latest");
9
+ var _omitProps = require("@instructure/ui-react-utils/lib/omitProps.js");
10
+ var _props = require("./props");
11
+ var _jsxRuntime = require("@emotion/react/jsx-runtime");
12
+ /*
13
+ * The MIT License (MIT)
14
+ *
15
+ * Copyright (c) 2015 - present Instructure, Inc.
16
+ *
17
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
18
+ * of this software and associated documentation files (the "Software"), to deal
19
+ * in the Software without restriction, including without limitation the rights
20
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
21
+ * copies of the Software, and to permit persons to whom the Software is
22
+ * furnished to do so, subject to the following conditions:
23
+ *
24
+ * The above copyright notice and this permission notice shall be included in all
25
+ * copies or substantial portions of the Software.
26
+ *
27
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
28
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
29
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
30
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
31
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
32
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
33
+ * SOFTWARE.
34
+ */
35
+
36
+ /**
37
+ ---
38
+ parent: Pagination
39
+ id: Pagination.Page
40
+ ---
41
+ **/
42
+
43
+ class PaginationButton extends _react.Component {
44
+ constructor(...args) {
45
+ super(...args);
46
+ this.ref = null;
47
+ this.handleRef = el => {
48
+ this.ref = el;
49
+ };
50
+ }
51
+ render() {
52
+ const exclude = this.props.current ? ['onClick', 'href'] : [];
53
+ const props = (0, _omitProps.omitProps)(this.props, PaginationButton.allowedProps, exclude);
54
+
55
+ // wrapped in an unstyled <li> for better a11y
56
+ return (0, _jsxRuntime.jsx)("li", {
57
+ style: {
58
+ all: 'unset'
59
+ },
60
+ children: (0, _jsxRuntime.jsx)(_latest.BaseButton, {
61
+ color: "primary",
62
+ "data-cid": "PaginationButton",
63
+ withBackground: this.props.current,
64
+ withBorder: this.props.current,
65
+ ...props,
66
+ "aria-current": this.props.current ? 'page' : void 0,
67
+ elementRef: this.handleRef,
68
+ ...(this.props.screenReaderLabel ? {
69
+ 'aria-label': this.props.screenReaderLabel
70
+ } : {}),
71
+ children: this.props.children
72
+ })
73
+ });
74
+ }
75
+ }
76
+ exports.PaginationButton = PaginationButton;
77
+ PaginationButton.displayName = "PaginationButton";
78
+ PaginationButton.componentId = 'Pagination.Page';
79
+ PaginationButton.allowedProps = _props.allowedProps;
80
+ PaginationButton.defaultProps = {
81
+ current: false
82
+ };
83
+ var _default = exports.default = PaginationButton;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.allowedProps = void 0;
7
+ /*
8
+ * The MIT License (MIT)
9
+ *
10
+ * Copyright (c) 2015 - present Instructure, Inc.
11
+ *
12
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
13
+ * of this software and associated documentation files (the "Software"), to deal
14
+ * in the Software without restriction, including without limitation the rights
15
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
+ * copies of the Software, and to permit persons to whom the Software is
17
+ * furnished to do so, subject to the following conditions:
18
+ *
19
+ * The above copyright notice and this permission notice shall be included in all
20
+ * copies or substantial portions of the Software.
21
+ *
22
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
+ * SOFTWARE.
29
+ */
30
+
31
+ const allowedProps = exports.allowedProps = ['children', 'current', 'screenReaderLabel'
32
+ // we don't want to pass onClick
33
+ // 'onClick'
34
+ ];
@@ -0,0 +1,194 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = exports.PaginationPageInput = void 0;
8
+ var _react = require("react");
9
+ var _emotion = require("@instructure/emotion");
10
+ var _latest = require("@instructure/ui-text/latest");
11
+ var _latest2 = require("@instructure/ui-number-input/latest");
12
+ var _ScreenReaderContent = require("@instructure/ui-a11y-content/lib/ScreenReaderContent");
13
+ var _styles = _interopRequireDefault(require("./styles"));
14
+ var _props = require("./props");
15
+ var _jsxRuntime = require("@emotion/react/jsx-runtime");
16
+ var _dec, _class, _PaginationPageInput;
17
+ /*
18
+ * The MIT License (MIT)
19
+ *
20
+ * Copyright (c) 2015 - present Instructure, Inc.
21
+ *
22
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
23
+ * of this software and associated documentation files (the "Software"), to deal
24
+ * in the Software without restriction, including without limitation the rights
25
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
26
+ * copies of the Software, and to permit persons to whom the Software is
27
+ * furnished to do so, subject to the following conditions:
28
+ *
29
+ * The above copyright notice and this permission notice shall be included in all
30
+ * copies or substantial portions of the Software.
31
+ *
32
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
33
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
34
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
35
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
36
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
37
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
38
+ * SOFTWARE.
39
+ */
40
+ /**
41
+ ---
42
+ parent: Pagination
43
+ id: Pagination.PageInput
44
+ ---
45
+ **/
46
+ let PaginationPageInput = exports.PaginationPageInput = (_dec = (0, _emotion.withStyle)(_styles.default, 'PaginationPageInput'), _dec(_class = (_PaginationPageInput = class PaginationPageInput extends _react.Component {
47
+ constructor(props) {
48
+ super(props);
49
+ this.ref = null;
50
+ this.handleRef = el => {
51
+ this.ref = el;
52
+ };
53
+ this.handleInputRef = el => {
54
+ if (typeof this.props.inputRef === 'function') {
55
+ this.props.inputRef(el);
56
+ }
57
+ };
58
+ this.handleChange = (_event, value) => {
59
+ let newValue = value;
60
+
61
+ // if the last character was not a number, don't accept it
62
+ if (value.length > 0 && isNaN(value.slice(-1))) {
63
+ newValue = value.slice(0, -1);
64
+ }
65
+ this.setState({
66
+ number: newValue ? Number(newValue) : this.MIN,
67
+ value: newValue
68
+ });
69
+ };
70
+ this.handleDecrement = event => {
71
+ this.setNewPage(event, Math.floor(this.currentPage - 1));
72
+ };
73
+ this.handleIncrement = event => {
74
+ this.setNewPage(event, Math.floor(this.currentPage + 1));
75
+ };
76
+ this.handleBlur = event => {
77
+ if (Math.round(this.state.number) !== this.currentPage) {
78
+ this.setNewPage(event, Math.round(this.state.number));
79
+ }
80
+ };
81
+ this.state = this.initialState;
82
+ }
83
+ get currentPage() {
84
+ return this.props.currentPageIndex + 1;
85
+ }
86
+ get initialState() {
87
+ return {
88
+ number: this.currentPage,
89
+ value: `${this.currentPage}`
90
+ };
91
+ }
92
+ get MIN() {
93
+ return 1;
94
+ }
95
+ get MAX() {
96
+ return this.props.numberOfPages;
97
+ }
98
+ componentDidMount() {
99
+ var _this$props$makeStyle, _this$props;
100
+ (_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
101
+ }
102
+ componentDidUpdate(prevProps) {
103
+ var _this$props$makeStyle2, _this$props2;
104
+ (_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
105
+
106
+ // when the current page changes from outside (e.g.: from arrow buttons),
107
+ // we update the initial state
108
+ if (this.props.currentPageIndex !== prevProps.currentPageIndex) {
109
+ this.resetInitialState();
110
+ }
111
+ }
112
+ resetInitialState() {
113
+ this.setState(this.initialState);
114
+ }
115
+ handleKeyDown(event) {
116
+ const key = event.key;
117
+ if (key.toLowerCase() === 'enter') {
118
+ const _this$state = this.state,
119
+ value = _this$state.value,
120
+ number = _this$state.number;
121
+
122
+ // If it is invalid, we reset the input to the current page
123
+ if (value === '' || isNaN(value)) {
124
+ this.resetInitialState();
125
+ return;
126
+ }
127
+ this.setNewPage(event, number);
128
+ }
129
+ }
130
+ getNumberWithinRange(n) {
131
+ if (n < this.MIN) return this.MIN;
132
+ if (n > this.MAX) return this.MAX;
133
+ return n;
134
+ }
135
+ setNewPage(event, n) {
136
+ const number = this.getNumberWithinRange(n);
137
+ this.setState({
138
+ number,
139
+ value: `${number}`
140
+ });
141
+ this.props.onChange(event, number - 1);
142
+ }
143
+ renderLabel() {
144
+ const _this$props3 = this.props,
145
+ label = _this$props3.label,
146
+ numberOfPages = _this$props3.numberOfPages,
147
+ styles = _this$props3.styles;
148
+ return typeof label === 'function' && label(numberOfPages) ? (0, _jsxRuntime.jsx)(_latest.Text, {
149
+ variant: "content",
150
+ children: (0, _jsxRuntime.jsx)("span", {
151
+ css: styles === null || styles === void 0 ? void 0 : styles.inputLabel,
152
+ children: label(numberOfPages)
153
+ })
154
+ }) : null;
155
+ }
156
+ renderScreenReaderLabel() {
157
+ const _this$props4 = this.props,
158
+ screenReaderLabel = _this$props4.screenReaderLabel,
159
+ numberOfPages = _this$props4.numberOfPages;
160
+ return (0, _jsxRuntime.jsx)(_ScreenReaderContent.ScreenReaderContent, {
161
+ children: screenReaderLabel(this.currentPage, numberOfPages)
162
+ });
163
+ }
164
+ render() {
165
+ const _this$props5 = this.props,
166
+ styles = _this$props5.styles,
167
+ disabled = _this$props5.disabled;
168
+ return (0, _jsxRuntime.jsxs)("span", {
169
+ css: styles === null || styles === void 0 ? void 0 : styles.paginationPageInput,
170
+ ref: this.handleRef,
171
+ "data-cid": "PaginationPageInput",
172
+ children: [(0, _jsxRuntime.jsx)("span", {
173
+ css: styles === null || styles === void 0 ? void 0 : styles.numberInput,
174
+ children: (0, _jsxRuntime.jsx)(_latest2.NumberInput, {
175
+ renderLabel: this.renderScreenReaderLabel(),
176
+ onBlur: this.handleBlur,
177
+ onChange: this.handleChange,
178
+ onDecrement: this.handleDecrement,
179
+ onIncrement: this.handleIncrement,
180
+ onKeyDown: this.handleKeyDown.bind(this),
181
+ interaction: disabled ? 'disabled' : 'enabled',
182
+ showArrows: false,
183
+ value: this.state.value,
184
+ width: "100%",
185
+ textAlign: "center",
186
+ inputRef: this.handleInputRef
187
+ })
188
+ }), this.renderLabel()]
189
+ });
190
+ }
191
+ }, _PaginationPageInput.displayName = "PaginationPageInput", _PaginationPageInput.componentId = 'Pagination.PageInput', _PaginationPageInput.allowedProps = _props.allowedProps, _PaginationPageInput.defaultProps = {
192
+ disabled: false
193
+ }, _PaginationPageInput)) || _class);
194
+ var _default = exports.default = PaginationPageInput;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.allowedProps = void 0;
7
+ /*
8
+ * The MIT License (MIT)
9
+ *
10
+ * Copyright (c) 2015 - present Instructure, Inc.
11
+ *
12
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
13
+ * of this software and associated documentation files (the "Software"), to deal
14
+ * in the Software without restriction, including without limitation the rights
15
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
+ * copies of the Software, and to permit persons to whom the Software is
17
+ * furnished to do so, subject to the following conditions:
18
+ *
19
+ * The above copyright notice and this permission notice shall be included in all
20
+ * copies or substantial portions of the Software.
21
+ *
22
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
+ * SOFTWARE.
29
+ */
30
+
31
+ const allowedProps = exports.allowedProps = ['numberOfPages', 'currentPageIndex', 'onChange', 'screenReaderLabel', 'label', 'disabled', 'inputRef'];
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ /*
8
+ * The MIT License (MIT)
9
+ *
10
+ * Copyright (c) 2015 - present Instructure, Inc.
11
+ *
12
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
13
+ * of this software and associated documentation files (the "Software"), to deal
14
+ * in the Software without restriction, including without limitation the rights
15
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
+ * copies of the Software, and to permit persons to whom the Software is
17
+ * furnished to do so, subject to the following conditions:
18
+ *
19
+ * The above copyright notice and this permission notice shall be included in all
20
+ * copies or substantial portions of the Software.
21
+ *
22
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
+ * SOFTWARE.
29
+ */
30
+
31
+ /**
32
+ * ---
33
+ * private: true
34
+ * ---
35
+ * Generates the style object from the theme and provided additional information
36
+ * @param {Object} componentTheme The theme variable object.
37
+ * @param {Object} props the props of the component, the style is applied to
38
+ * @param {Object} sharedTokens Shared token object that stores common values for the theme.
39
+ * @param {Object} state the state of the component, the style is applied to
40
+ * @return {Object} The final style object, which will be used in the component
41
+ */
42
+ const generateStyle = componentTheme => {
43
+ return {
44
+ paginationPageInput: {
45
+ label: 'paginationPageInput',
46
+ display: 'inline-flex',
47
+ alignItems: 'center',
48
+ margin: `0 ${componentTheme.inputSpacing}`
49
+ },
50
+ numberInput: {
51
+ label: 'paginationPageInput__input',
52
+ width: componentTheme.inputWidth
53
+ },
54
+ inputLabel: {
55
+ label: 'paginationPageInput__inputLabel',
56
+ marginInlineStart: componentTheme.inputSpacing,
57
+ whiteSpace: 'nowrap',
58
+ color: componentTheme.labelColor
59
+ }
60
+ };
61
+ };
62
+ var _default = exports.default = generateStyle;