@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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instructure/ui-pagination",
3
- "version": "11.6.0",
3
+ "version": "11.6.1-snapshot-129",
4
4
  "description": "A UI component library made by Instructure Inc.",
5
5
  "author": "Instructure, Inc. Engineering and Product Design",
6
6
  "module": "./es/index.js",
@@ -15,29 +15,30 @@
15
15
  "license": "MIT",
16
16
  "dependencies": {
17
17
  "@babel/runtime": "^7.27.6",
18
- "@instructure/shared-types": "11.6.0",
19
- "@instructure/emotion": "11.6.0",
20
- "@instructure/ui-a11y-content": "11.6.0",
21
- "@instructure/ui-a11y-utils": "11.6.0",
22
- "@instructure/ui-dom-utils": "11.6.0",
23
- "@instructure/ui-icons": "11.6.0",
24
- "@instructure/ui-buttons": "11.6.0",
25
- "@instructure/ui-portal": "11.6.0",
26
- "@instructure/ui-react-utils": "11.6.0",
27
- "@instructure/ui-number-input": "11.6.0",
28
- "@instructure/ui-themes": "11.6.0",
29
- "@instructure/ui-tooltip": "11.6.0",
30
- "@instructure/ui-utils": "11.6.0",
31
- "@instructure/uid": "11.6.0",
32
- "@instructure/ui-view": "11.6.0"
18
+ "@instructure/emotion": "11.6.1-snapshot-129",
19
+ "@instructure/ui-a11y-content": "11.6.1-snapshot-129",
20
+ "@instructure/ui-buttons": "11.6.1-snapshot-129",
21
+ "@instructure/shared-types": "11.6.1-snapshot-129",
22
+ "@instructure/ui-a11y-utils": "11.6.1-snapshot-129",
23
+ "@instructure/ui-dom-utils": "11.6.1-snapshot-129",
24
+ "@instructure/ui-icons": "11.6.1-snapshot-129",
25
+ "@instructure/ui-portal": "11.6.1-snapshot-129",
26
+ "@instructure/ui-number-input": "11.6.1-snapshot-129",
27
+ "@instructure/ui-react-utils": "11.6.1-snapshot-129",
28
+ "@instructure/ui-text": "11.6.1-snapshot-129",
29
+ "@instructure/ui-tooltip": "11.6.1-snapshot-129",
30
+ "@instructure/ui-themes": "11.6.1-snapshot-129",
31
+ "@instructure/ui-utils": "11.6.1-snapshot-129",
32
+ "@instructure/ui-view": "11.6.1-snapshot-129",
33
+ "@instructure/uid": "11.6.1-snapshot-129"
33
34
  },
34
35
  "devDependencies": {
35
36
  "@testing-library/jest-dom": "^6.6.3",
36
37
  "@testing-library/react": "15.0.7",
37
38
  "@testing-library/user-event": "^14.6.1",
38
39
  "vitest": "^3.2.2",
39
- "@instructure/ui-axe-check": "11.6.0",
40
- "@instructure/ui-babel-preset": "11.6.0"
40
+ "@instructure/ui-axe-check": "11.6.1-snapshot-129",
41
+ "@instructure/ui-babel-preset": "11.6.1-snapshot-129"
41
42
  },
42
43
  "peerDependencies": {
43
44
  "react": ">=18 <=19"
@@ -47,17 +48,39 @@
47
48
  },
48
49
  "sideEffects": false,
49
50
  "exports": {
50
- ".": {
51
- "types": "./types/index.d.ts",
52
- "import": "./es/index.js",
53
- "require": "./lib/index.js",
54
- "default": "./es/index.js"
55
- },
56
51
  "./lib/*": "./lib/*",
57
52
  "./es/*": "./es/*",
58
53
  "./types/*": "./types/*",
59
54
  "./package.json": "./package.json",
60
- "./src/*": "./src/*"
55
+ "./src/*": "./src/*",
56
+ ".": {
57
+ "src": "./src/exports/a.ts",
58
+ "types": "./types/exports/a.d.ts",
59
+ "import": "./es/exports/a.js",
60
+ "require": "./lib/exports/a.js",
61
+ "default": "./es/exports/a.js"
62
+ },
63
+ "./v11_6": {
64
+ "src": "./src/exports/a.ts",
65
+ "types": "./types/exports/a.d.ts",
66
+ "import": "./es/exports/a.js",
67
+ "require": "./lib/exports/a.js",
68
+ "default": "./es/exports/a.js"
69
+ },
70
+ "./v11_7": {
71
+ "src": "./src/exports/b.ts",
72
+ "types": "./types/exports/b.d.ts",
73
+ "import": "./es/exports/b.js",
74
+ "require": "./lib/exports/b.js",
75
+ "default": "./es/exports/b.js"
76
+ },
77
+ "./latest": {
78
+ "src": "./src/exports/b.ts",
79
+ "types": "./types/exports/b.d.ts",
80
+ "import": "./es/exports/b.js",
81
+ "require": "./lib/exports/b.js",
82
+ "default": "./es/exports/b.js"
83
+ }
61
84
  },
62
85
  "scripts": {
63
86
  "lint": "ui-scripts lint",
@@ -24,9 +24,9 @@
24
24
 
25
25
  import { Component } from 'react'
26
26
 
27
- import { IconButton } from '@instructure/ui-buttons'
27
+ import { IconButton } from '@instructure/ui-buttons/v11_6'
28
28
  import { PresentationContent } from '@instructure/ui-a11y-content'
29
- import { Tooltip } from '@instructure/ui-tooltip'
29
+ import { Tooltip } from '@instructure/ui-tooltip/v11_6'
30
30
  import {
31
31
  IconArrowOpenStartSolid,
32
32
  IconArrowOpenEndSolid,
@@ -27,7 +27,7 @@ import type {
27
27
  OtherHTMLAttributes,
28
28
  PickPropsWithExceptions
29
29
  } from '@instructure/shared-types'
30
- import type { IconButtonProps } from '@instructure/ui-buttons'
30
+ import type { IconButtonProps } from '@instructure/ui-buttons/v11_6'
31
31
 
32
32
  type PaginationArrowDirections = 'first' | 'prev' | 'next' | 'last'
33
33
 
@@ -24,7 +24,7 @@
24
24
 
25
25
  import { Component } from 'react'
26
26
 
27
- import { BaseButton } from '@instructure/ui-buttons'
27
+ import { BaseButton } from '@instructure/ui-buttons/v11_6'
28
28
  import { omitProps } from '@instructure/ui-react-utils'
29
29
 
30
30
  import { allowedProps } from './props'
@@ -27,7 +27,7 @@ import type {
27
27
  OtherHTMLAttributes,
28
28
  PickPropsWithExceptions
29
29
  } from '@instructure/shared-types'
30
- import type { BaseButtonProps } from '@instructure/ui-buttons'
30
+ import type { BaseButtonProps } from '@instructure/ui-buttons/v11_6'
31
31
 
32
32
  type PaginationPageOwnProps = {
33
33
  /**
@@ -25,7 +25,7 @@
25
25
  import { Component } from 'react'
26
26
 
27
27
  import { withStyle } from '@instructure/emotion'
28
- import { NumberInput } from '@instructure/ui-number-input'
28
+ import { NumberInput } from '@instructure/ui-number-input/v11_6'
29
29
  import { ScreenReaderContent } from '@instructure/ui-a11y-content'
30
30
 
31
31
  import generateStyle from './styles'
@@ -29,7 +29,7 @@ import {
29
29
  ReactNode
30
30
  } from 'react'
31
31
 
32
- import { View } from '@instructure/ui-view'
32
+ import { View } from '@instructure/ui-view/v11_6'
33
33
  import { omitProps, withDeterministicId } from '@instructure/ui-react-utils'
34
34
  import { hasVisibleChildren } from '@instructure/ui-a11y-utils'
35
35
  import { findTabbable, getActiveElement } from '@instructure/ui-dom-utils'
@@ -0,0 +1,120 @@
1
+ /*
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2015 - present Instructure, Inc.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ import { Component } from 'react'
26
+
27
+ import { IconButton } from '@instructure/ui-buttons/latest'
28
+ import { PresentationContent } from '@instructure/ui-a11y-content'
29
+ import { Tooltip } from '@instructure/ui-tooltip/latest'
30
+ import {
31
+ ChevronLeftInstUIIcon,
32
+ ChevronRightInstUIIcon,
33
+ ChevronsLeftInstUIIcon,
34
+ ChevronsRightInstUIIcon,
35
+ renderIconWithProps
36
+ } from '@instructure/ui-icons'
37
+
38
+ import type { PaginationNavigationProps } from './props'
39
+ import { allowedProps } from './props'
40
+
41
+ /**
42
+ ---
43
+ parent: Pagination
44
+ id: Pagination.Navigation
45
+ ---
46
+ **/
47
+ class PaginationArrowButton extends Component<PaginationNavigationProps> {
48
+ static readonly componentId = 'Pagination.Navigation'
49
+
50
+ static allowedProps = allowedProps
51
+
52
+ static defaultProps = {}
53
+
54
+ ref: Element | null = null
55
+
56
+ handleRef = (el: Element | null) => {
57
+ this.ref = el
58
+ }
59
+
60
+ get margin() {
61
+ switch (this.props.direction) {
62
+ case 'first':
63
+ return '0 xx-small 0 0'
64
+ case 'last':
65
+ return '0 0 0 xx-small'
66
+ default:
67
+ return undefined
68
+ }
69
+ }
70
+
71
+ get Icon() {
72
+ switch (this.props.direction) {
73
+ case 'first':
74
+ return ChevronsLeftInstUIIcon
75
+ case 'prev':
76
+ return ChevronLeftInstUIIcon
77
+ case 'next':
78
+ return ChevronRightInstUIIcon
79
+ case 'last':
80
+ return ChevronsRightInstUIIcon
81
+ default:
82
+ return null
83
+ }
84
+ }
85
+
86
+ renderIcon() {
87
+ const icon = this.Icon
88
+ if (!icon) return null
89
+ return renderIconWithProps(icon, 'md', 'actionTertiaryBaseColor')
90
+ }
91
+
92
+ render() {
93
+ const { label, direction, buttonRef, ...props } = this.props
94
+
95
+ return (
96
+ <Tooltip
97
+ elementRef={this.handleRef}
98
+ on={['hover', 'focus']}
99
+ renderTip={<PresentationContent>{label}</PresentationContent>}
100
+ >
101
+ <IconButton
102
+ {...props}
103
+ size="small"
104
+ withBackground={false}
105
+ withBorder={false}
106
+ screenReaderLabel={label}
107
+ rel={props.href || props.to ? direction : undefined}
108
+ elementRef={buttonRef}
109
+ margin={this.margin}
110
+ data-cid="PaginationArrowButton"
111
+ >
112
+ {this.renderIcon()}
113
+ </IconButton>
114
+ </Tooltip>
115
+ )
116
+ }
117
+ }
118
+
119
+ export default PaginationArrowButton
120
+ export { PaginationArrowButton }
@@ -0,0 +1,74 @@
1
+ /*
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2015 - present Instructure, Inc.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ import React from 'react'
26
+ import type {
27
+ OtherHTMLAttributes,
28
+ PickPropsWithExceptions
29
+ } from '@instructure/shared-types'
30
+ import type { IconButtonProps } from '@instructure/ui-buttons/latest'
31
+
32
+ type PaginationArrowDirections = 'first' | 'prev' | 'next' | 'last'
33
+
34
+ type PaginationNavigationOwnProps = {
35
+ direction?: PaginationArrowDirections
36
+ label: string
37
+ buttonRef?: (element: Element | null) => void
38
+ onClick?: (
39
+ event:
40
+ | React.KeyboardEvent<HTMLInputElement>
41
+ | React.MouseEvent<HTMLButtonElement>
42
+ | React.FocusEvent<HTMLInputElement>
43
+ ) => void
44
+ }
45
+
46
+ type PropKeys = keyof PaginationNavigationOwnProps
47
+
48
+ type AllowedPropKeys = Readonly<Array<PropKeys>>
49
+
50
+ type PaginationNavigationProps =
51
+ // We pass almost all the props to IconButton
52
+ PickPropsWithExceptions<
53
+ IconButtonProps,
54
+ | 'size'
55
+ | 'withBackground'
56
+ | 'withBorder'
57
+ | 'screenReaderLabel'
58
+ | 'rel'
59
+ | 'elementRef'
60
+ | 'margin'
61
+ > &
62
+ PaginationNavigationOwnProps &
63
+ OtherHTMLAttributes<PaginationNavigationOwnProps>
64
+ const allowedProps: AllowedPropKeys = [
65
+ 'direction',
66
+ 'label',
67
+ 'buttonRef'
68
+
69
+ // we don't want to pass onClick
70
+ // 'onClick'
71
+ ]
72
+
73
+ export type { PaginationNavigationProps, PaginationArrowDirections }
74
+ export { allowedProps }
@@ -0,0 +1,82 @@
1
+ /*
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2015 - present Instructure, Inc.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ import { Component } from 'react'
26
+
27
+ import { BaseButton } from '@instructure/ui-buttons/latest'
28
+ import { omitProps } from '@instructure/ui-react-utils'
29
+
30
+ import { allowedProps } from './props'
31
+ import type { PaginationPageProps } from './props'
32
+
33
+ /**
34
+ ---
35
+ parent: Pagination
36
+ id: Pagination.Page
37
+ ---
38
+ **/
39
+
40
+ class PaginationButton extends Component<PaginationPageProps> {
41
+ static readonly componentId = 'Pagination.Page'
42
+
43
+ static allowedProps = allowedProps
44
+ static defaultProps = {
45
+ current: false
46
+ }
47
+
48
+ ref: Element | null = null
49
+
50
+ handleRef = (el: Element | null) => {
51
+ this.ref = el
52
+ }
53
+
54
+ render() {
55
+ const exclude = this.props.current ? ['onClick', 'href'] : []
56
+
57
+ const props = omitProps(this.props, PaginationButton.allowedProps, exclude)
58
+
59
+ // wrapped in an unstyled <li> for better a11y
60
+ return (
61
+ <li style={{ all: 'unset' }}>
62
+ <BaseButton
63
+ color="primary"
64
+ data-cid="PaginationButton"
65
+ withBackground={this.props.current}
66
+ withBorder={this.props.current}
67
+ {...props}
68
+ aria-current={this.props.current ? 'page' : undefined}
69
+ elementRef={this.handleRef}
70
+ {...(this.props.screenReaderLabel
71
+ ? { 'aria-label': this.props.screenReaderLabel }
72
+ : {})}
73
+ >
74
+ {this.props.children}
75
+ </BaseButton>
76
+ </li>
77
+ )
78
+ }
79
+ }
80
+
81
+ export default PaginationButton
82
+ export { PaginationButton }
@@ -0,0 +1,77 @@
1
+ /*
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2015 - present Instructure, Inc.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ import React from 'react'
26
+ import type {
27
+ OtherHTMLAttributes,
28
+ PickPropsWithExceptions
29
+ } from '@instructure/shared-types'
30
+ import type { BaseButtonProps } from '@instructure/ui-buttons/latest'
31
+
32
+ type PaginationPageOwnProps = {
33
+ /**
34
+ * Content to render as page selection
35
+ */
36
+ children: React.ReactNode
37
+ /**
38
+ * Whether the page is currently displayed
39
+ */
40
+ current?: boolean
41
+ /**
42
+ * Callback fired when the `Pagination.Page` is clicked.
43
+ */
44
+ onClick?: (
45
+ event:
46
+ | React.KeyboardEvent<HTMLInputElement>
47
+ | React.MouseEvent<HTMLButtonElement>
48
+ | React.FocusEvent<HTMLInputElement>
49
+ ) => void
50
+ /**
51
+ * The text screenreaders should say when this button is in focus (sets the
52
+ * `aria-label` attribute).
53
+ * If left undefined (default) SRs will announce text in the child node(s).
54
+ */
55
+ screenReaderLabel?: string
56
+ }
57
+
58
+ type PropKeys = keyof PaginationPageOwnProps
59
+
60
+ type AllowedPropKeys = Readonly<Array<PropKeys>>
61
+
62
+ type PaginationPageProps =
63
+ // We pass almost all props to BaseButton
64
+ PickPropsWithExceptions<BaseButtonProps, 'aria-current' | 'elementRef'> &
65
+ PaginationPageOwnProps &
66
+ OtherHTMLAttributes<PaginationPageOwnProps>
67
+
68
+ const allowedProps: AllowedPropKeys = [
69
+ 'children',
70
+ 'current',
71
+ 'screenReaderLabel'
72
+ // we don't want to pass onClick
73
+ // 'onClick'
74
+ ]
75
+
76
+ export type { PaginationPageProps }
77
+ export { allowedProps }