@instructure/ui-tabs 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 (134) hide show
  1. package/CHANGELOG.md +48 -308
  2. package/es/Tabs/{Panel → v1/Panel}/index.js +2 -2
  3. package/es/Tabs/{Tab → v1/Tab}/index.js +2 -2
  4. package/es/Tabs/{index.js → v1/index.js} +2 -2
  5. package/es/Tabs/v2/Panel/index.js +126 -0
  6. package/es/Tabs/v2/Panel/props.js +26 -0
  7. package/es/Tabs/v2/Panel/styles.js +81 -0
  8. package/es/Tabs/v2/Tab/index.js +118 -0
  9. package/es/Tabs/v2/Tab/props.js +26 -0
  10. package/es/Tabs/v2/Tab/styles.js +145 -0
  11. package/es/Tabs/v2/index.js +396 -0
  12. package/es/Tabs/v2/props.js +26 -0
  13. package/es/Tabs/v2/styles.js +145 -0
  14. package/es/{index.js → exports/a.js} +3 -3
  15. package/es/exports/b.js +26 -0
  16. package/lib/Tabs/v1/Panel/index.js +132 -0
  17. package/lib/Tabs/v1/Tab/index.js +125 -0
  18. package/lib/Tabs/v1/index.js +410 -0
  19. package/lib/Tabs/{Panel → v2/Panel}/index.js +3 -4
  20. package/lib/Tabs/v2/Panel/props.js +31 -0
  21. package/lib/Tabs/v2/Panel/styles.js +87 -0
  22. package/lib/Tabs/{Tab → v2/Tab}/index.js +3 -4
  23. package/lib/Tabs/v2/Tab/props.js +31 -0
  24. package/lib/Tabs/v2/Tab/styles.js +151 -0
  25. package/lib/Tabs/{index.js → v2/index.js} +5 -6
  26. package/lib/Tabs/v2/props.js +31 -0
  27. package/lib/Tabs/v2/styles.js +151 -0
  28. package/lib/{index.js → exports/a.js} +4 -4
  29. package/lib/exports/b.js +26 -0
  30. package/package.json +46 -24
  31. package/src/Tabs/{Panel → v1/Panel}/index.tsx +2 -2
  32. package/src/Tabs/{Tab → v1/Tab}/index.tsx +3 -3
  33. package/src/Tabs/{Tab → v1/Tab}/props.ts +1 -1
  34. package/src/Tabs/{index.tsx → v1/index.tsx} +3 -3
  35. package/src/Tabs/{props.ts → v1/props.ts} +1 -1
  36. package/src/Tabs/v2/Panel/index.tsx +138 -0
  37. package/src/Tabs/v2/Panel/props.ts +100 -0
  38. package/src/Tabs/v2/Panel/styles.ts +92 -0
  39. package/src/Tabs/v2/README.md +559 -0
  40. package/src/Tabs/v2/Tab/index.tsx +123 -0
  41. package/src/Tabs/v2/Tab/props.ts +80 -0
  42. package/src/Tabs/v2/Tab/styles.ts +161 -0
  43. package/src/Tabs/v2/index.tsx +547 -0
  44. package/src/Tabs/v2/props.ts +126 -0
  45. package/src/Tabs/v2/styles.ts +156 -0
  46. package/src/{index.ts → exports/a.ts} +6 -6
  47. package/src/exports/b.ts +31 -0
  48. package/tsconfig.build.tsbuildinfo +1 -1
  49. package/types/Tabs/v1/Panel/index.d.ts.map +1 -0
  50. package/types/Tabs/v1/Panel/props.d.ts.map +1 -0
  51. package/types/Tabs/v1/Panel/styles.d.ts.map +1 -0
  52. package/types/Tabs/v1/Panel/theme.d.ts.map +1 -0
  53. package/types/Tabs/{Tab → v1/Tab}/index.d.ts +1 -1
  54. package/types/Tabs/v1/Tab/index.d.ts.map +1 -0
  55. package/types/Tabs/{Tab → v1/Tab}/props.d.ts +1 -1
  56. package/types/Tabs/v1/Tab/props.d.ts.map +1 -0
  57. package/types/Tabs/v1/Tab/styles.d.ts.map +1 -0
  58. package/types/Tabs/v1/Tab/theme.d.ts.map +1 -0
  59. package/types/Tabs/{index.d.ts → v1/index.d.ts} +1 -1
  60. package/types/Tabs/v1/index.d.ts.map +1 -0
  61. package/types/Tabs/{props.d.ts → v1/props.d.ts} +1 -1
  62. package/types/Tabs/v1/props.d.ts.map +1 -0
  63. package/types/Tabs/v1/styles.d.ts.map +1 -0
  64. package/types/Tabs/v1/theme.d.ts.map +1 -0
  65. package/types/Tabs/v2/Panel/index.d.ts +46 -0
  66. package/types/Tabs/v2/Panel/index.d.ts.map +1 -0
  67. package/types/Tabs/v2/Panel/props.d.ts +46 -0
  68. package/types/Tabs/v2/Panel/props.d.ts.map +1 -0
  69. package/types/Tabs/v2/Panel/styles.d.ts +19 -0
  70. package/types/Tabs/v2/Panel/styles.d.ts.map +1 -0
  71. package/types/Tabs/v2/Tab/index.d.ts +43 -0
  72. package/types/Tabs/v2/Tab/index.d.ts.map +1 -0
  73. package/types/Tabs/v2/Tab/props.d.ts +33 -0
  74. package/types/Tabs/v2/Tab/props.d.ts.map +1 -0
  75. package/types/Tabs/v2/Tab/styles.d.ts +20 -0
  76. package/types/Tabs/v2/Tab/styles.d.ts.map +1 -0
  77. package/types/Tabs/v2/index.d.ts +80 -0
  78. package/types/Tabs/v2/index.d.ts.map +1 -0
  79. package/types/Tabs/v2/props.d.ts +68 -0
  80. package/types/Tabs/v2/props.d.ts.map +1 -0
  81. package/types/Tabs/v2/styles.d.ts +19 -0
  82. package/types/Tabs/v2/styles.d.ts.map +1 -0
  83. package/types/exports/a.d.ts +7 -0
  84. package/types/exports/a.d.ts.map +1 -0
  85. package/types/exports/b.d.ts +7 -0
  86. package/types/exports/b.d.ts.map +1 -0
  87. package/types/Tabs/Panel/index.d.ts.map +0 -1
  88. package/types/Tabs/Panel/props.d.ts.map +0 -1
  89. package/types/Tabs/Panel/styles.d.ts.map +0 -1
  90. package/types/Tabs/Panel/theme.d.ts.map +0 -1
  91. package/types/Tabs/Tab/index.d.ts.map +0 -1
  92. package/types/Tabs/Tab/props.d.ts.map +0 -1
  93. package/types/Tabs/Tab/styles.d.ts.map +0 -1
  94. package/types/Tabs/Tab/theme.d.ts.map +0 -1
  95. package/types/Tabs/index.d.ts.map +0 -1
  96. package/types/Tabs/props.d.ts.map +0 -1
  97. package/types/Tabs/styles.d.ts.map +0 -1
  98. package/types/Tabs/theme.d.ts.map +0 -1
  99. package/types/index.d.ts +0 -7
  100. package/types/index.d.ts.map +0 -1
  101. /package/es/Tabs/{Panel → v1/Panel}/props.js +0 -0
  102. /package/es/Tabs/{Panel → v1/Panel}/styles.js +0 -0
  103. /package/es/Tabs/{Panel → v1/Panel}/theme.js +0 -0
  104. /package/es/Tabs/{Tab → v1/Tab}/props.js +0 -0
  105. /package/es/Tabs/{Tab → v1/Tab}/styles.js +0 -0
  106. /package/es/Tabs/{Tab → v1/Tab}/theme.js +0 -0
  107. /package/es/Tabs/{props.js → v1/props.js} +0 -0
  108. /package/es/Tabs/{styles.js → v1/styles.js} +0 -0
  109. /package/es/Tabs/{theme.js → v1/theme.js} +0 -0
  110. /package/lib/Tabs/{Panel → v1/Panel}/props.js +0 -0
  111. /package/lib/Tabs/{Panel → v1/Panel}/styles.js +0 -0
  112. /package/lib/Tabs/{Panel → v1/Panel}/theme.js +0 -0
  113. /package/lib/Tabs/{Tab → v1/Tab}/props.js +0 -0
  114. /package/lib/Tabs/{Tab → v1/Tab}/styles.js +0 -0
  115. /package/lib/Tabs/{Tab → v1/Tab}/theme.js +0 -0
  116. /package/lib/Tabs/{props.js → v1/props.js} +0 -0
  117. /package/lib/Tabs/{styles.js → v1/styles.js} +0 -0
  118. /package/lib/Tabs/{theme.js → v1/theme.js} +0 -0
  119. /package/src/Tabs/{Panel → v1/Panel}/props.ts +0 -0
  120. /package/src/Tabs/{Panel → v1/Panel}/styles.ts +0 -0
  121. /package/src/Tabs/{Panel → v1/Panel}/theme.ts +0 -0
  122. /package/src/Tabs/{README.md → v1/README.md} +0 -0
  123. /package/src/Tabs/{Tab → v1/Tab}/styles.ts +0 -0
  124. /package/src/Tabs/{Tab → v1/Tab}/theme.ts +0 -0
  125. /package/src/Tabs/{styles.ts → v1/styles.ts} +0 -0
  126. /package/src/Tabs/{theme.ts → v1/theme.ts} +0 -0
  127. /package/types/Tabs/{Panel → v1/Panel}/index.d.ts +0 -0
  128. /package/types/Tabs/{Panel → v1/Panel}/props.d.ts +0 -0
  129. /package/types/Tabs/{Panel → v1/Panel}/styles.d.ts +0 -0
  130. /package/types/Tabs/{Panel → v1/Panel}/theme.d.ts +0 -0
  131. /package/types/Tabs/{Tab → v1/Tab}/styles.d.ts +0 -0
  132. /package/types/Tabs/{Tab → v1/Tab}/theme.d.ts +0 -0
  133. /package/types/Tabs/{styles.d.ts → v1/styles.d.ts} +0 -0
  134. /package/types/Tabs/{theme.d.ts → v1/theme.d.ts} +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instructure/ui-tabs",
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",
@@ -16,28 +16,28 @@
16
16
  "dependencies": {
17
17
  "@babel/runtime": "^7.27.6",
18
18
  "keycode": "^2",
19
- "@instructure/console": "11.6.0",
20
- "@instructure/debounce": "11.6.0",
21
- "@instructure/emotion": "11.6.0",
22
- "@instructure/shared-types": "11.6.0",
23
- "@instructure/ui-dom-utils": "11.6.0",
24
- "@instructure/ui-focusable": "11.6.0",
25
- "@instructure/ui-i18n": "11.6.0",
26
- "@instructure/ui-motion": "11.6.0",
27
- "@instructure/ui-react-utils": "11.6.0",
28
- "@instructure/ui-utils": "11.6.0",
29
- "@instructure/ui-view": "11.6.0",
30
- "@instructure/uid": "11.6.0"
19
+ "@instructure/debounce": "11.6.1-snapshot-129",
20
+ "@instructure/console": "11.6.1-snapshot-129",
21
+ "@instructure/emotion": "11.6.1-snapshot-129",
22
+ "@instructure/shared-types": "11.6.1-snapshot-129",
23
+ "@instructure/ui-dom-utils": "11.6.1-snapshot-129",
24
+ "@instructure/ui-focusable": "11.6.1-snapshot-129",
25
+ "@instructure/ui-i18n": "11.6.1-snapshot-129",
26
+ "@instructure/ui-react-utils": "11.6.1-snapshot-129",
27
+ "@instructure/ui-motion": "11.6.1-snapshot-129",
28
+ "@instructure/ui-utils": "11.6.1-snapshot-129",
29
+ "@instructure/ui-view": "11.6.1-snapshot-129",
30
+ "@instructure/uid": "11.6.1-snapshot-129"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@testing-library/jest-dom": "^6.6.3",
34
34
  "@testing-library/react": "15.0.7",
35
35
  "@testing-library/user-event": "^14.6.1",
36
36
  "vitest": "^3.2.2",
37
- "@instructure/ui-babel-preset": "11.6.0",
38
- "@instructure/ui-color-utils": "11.6.0",
39
- "@instructure/ui-axe-check": "11.6.0",
40
- "@instructure/ui-themes": "11.6.0"
37
+ "@instructure/ui-axe-check": "11.6.1-snapshot-129",
38
+ "@instructure/ui-babel-preset": "11.6.1-snapshot-129",
39
+ "@instructure/ui-color-utils": "11.6.1-snapshot-129",
40
+ "@instructure/ui-themes": "11.6.1-snapshot-129"
41
41
  },
42
42
  "peerDependencies": {
43
43
  "react": ">=18 <=19"
@@ -47,17 +47,39 @@
47
47
  },
48
48
  "sideEffects": false,
49
49
  "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
50
  "./lib/*": "./lib/*",
57
51
  "./es/*": "./es/*",
58
52
  "./types/*": "./types/*",
59
53
  "./package.json": "./package.json",
60
- "./src/*": "./src/*"
54
+ "./src/*": "./src/*",
55
+ ".": {
56
+ "src": "./src/exports/a.ts",
57
+ "types": "./types/exports/a.d.ts",
58
+ "import": "./es/exports/a.js",
59
+ "require": "./lib/exports/a.js",
60
+ "default": "./es/exports/a.js"
61
+ },
62
+ "./v11_6": {
63
+ "src": "./src/exports/a.ts",
64
+ "types": "./types/exports/a.d.ts",
65
+ "import": "./es/exports/a.js",
66
+ "require": "./lib/exports/a.js",
67
+ "default": "./es/exports/a.js"
68
+ },
69
+ "./v11_7": {
70
+ "src": "./src/exports/b.ts",
71
+ "types": "./types/exports/b.d.ts",
72
+ "import": "./es/exports/b.js",
73
+ "require": "./lib/exports/b.js",
74
+ "default": "./es/exports/b.js"
75
+ },
76
+ "./latest": {
77
+ "src": "./src/exports/b.ts",
78
+ "types": "./types/exports/b.d.ts",
79
+ "import": "./es/exports/b.js",
80
+ "require": "./lib/exports/b.js",
81
+ "default": "./es/exports/b.js"
82
+ }
61
83
  },
62
84
  "scripts": {
63
85
  "lint": "ui-scripts lint",
@@ -24,11 +24,11 @@
24
24
 
25
25
  import { Component } from 'react'
26
26
 
27
- import { View } from '@instructure/ui-view'
27
+ import { View } from '@instructure/ui-view/v11_6'
28
28
  import { passthroughProps } from '@instructure/ui-react-utils'
29
29
  import { Transition } from '@instructure/ui-motion'
30
30
 
31
- import { withStyle } from '@instructure/emotion'
31
+ import { withStyleLegacy as withStyle } from '@instructure/emotion'
32
32
 
33
33
  import generateStyle from './styles'
34
34
  import generateComponentTheme from './theme'
@@ -25,10 +25,10 @@
25
25
  import { Component } from 'react'
26
26
 
27
27
  import { passthroughProps, callRenderProp } from '@instructure/ui-react-utils'
28
- import { View } from '@instructure/ui-view'
29
- import type { ViewOwnProps } from '@instructure/ui-view'
28
+ import { View } from '@instructure/ui-view/v11_6'
29
+ import type { ViewOwnProps } from '@instructure/ui-view/v11_6'
30
30
 
31
- import { withStyle } from '@instructure/emotion'
31
+ import { withStyleLegacy as withStyle } from '@instructure/emotion'
32
32
 
33
33
  import generateStyle from './styles'
34
34
  import generateComponentTheme from './theme'
@@ -29,7 +29,7 @@ import type {
29
29
  TabsTabTheme
30
30
  } from '@instructure/shared-types'
31
31
  import type { WithStyleProps, ComponentStyle } from '@instructure/emotion'
32
- import type { ViewOwnProps } from '@instructure/ui-view'
32
+ import type { ViewOwnProps } from '@instructure/ui-view/v11_6'
33
33
 
34
34
  type TabsTabOwnProps = {
35
35
  variant?: 'default' | 'secondary'
@@ -32,8 +32,8 @@ import {
32
32
 
33
33
  import keycode from 'keycode'
34
34
 
35
- import { View } from '@instructure/ui-view'
36
- import type { ViewOwnProps } from '@instructure/ui-view'
35
+ import { View } from '@instructure/ui-view/v11_6'
36
+ import type { ViewOwnProps } from '@instructure/ui-view/v11_6'
37
37
  import {
38
38
  matchComponentTypes,
39
39
  safeCloneElement,
@@ -48,7 +48,7 @@ import { debounce } from '@instructure/debounce'
48
48
  import type { Debounced } from '@instructure/debounce'
49
49
  import { px } from '@instructure/ui-utils'
50
50
 
51
- import { withStyle } from '@instructure/emotion'
51
+ import { withStyleLegacy as withStyle } from '@instructure/emotion'
52
52
 
53
53
  import generateStyle from './styles'
54
54
  import generateComponentTheme from './theme'
@@ -29,7 +29,7 @@ import type {
29
29
  } from '@instructure/emotion'
30
30
  import type { OtherHTMLAttributes, TabsTheme } from '@instructure/shared-types'
31
31
  import type { TextDirectionContextConsumerProps } from '@instructure/ui-i18n'
32
- import type { ViewOwnProps } from '@instructure/ui-view'
32
+ import type { ViewOwnProps } from '@instructure/ui-view/v11_6'
33
33
 
34
34
  type TabsOwnProps = {
35
35
  /**
@@ -0,0 +1,138 @@
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 { View } from '@instructure/ui-view/latest'
28
+ import { passthroughProps } from '@instructure/ui-react-utils'
29
+ import { Transition } from '@instructure/ui-motion'
30
+
31
+ import { withStyle } from '@instructure/emotion'
32
+
33
+ import generateStyle from './styles'
34
+ import type { TabsPanelProps } from './props'
35
+ import { allowedProps } from './props'
36
+
37
+ /**
38
+ ---
39
+ parent: Tabs
40
+ id: Tabs.Panel
41
+ ---
42
+ **/
43
+ @withStyle(generateStyle)
44
+ class Panel extends Component<TabsPanelProps> {
45
+ static readonly componentId = 'Tabs.Panel'
46
+
47
+ static allowedProps = allowedProps
48
+
49
+ static defaultProps = {
50
+ isDisabled: false,
51
+ textAlign: 'start',
52
+ variant: 'default',
53
+ isSelected: false,
54
+ padding: 'small',
55
+ active: false,
56
+ unmountOnExit: true
57
+ }
58
+
59
+ componentDidMount() {
60
+ this.props.makeStyles?.({ isHidden: this.isHidden })
61
+ }
62
+
63
+ componentDidUpdate() {
64
+ this.props.makeStyles?.({ isHidden: this.isHidden })
65
+ }
66
+
67
+ ref: HTMLDivElement | null = null
68
+
69
+ get isHidden() {
70
+ const { isDisabled, isSelected } = this.props
71
+ return !isSelected || !!isDisabled
72
+ }
73
+
74
+ handleRef = (el: HTMLDivElement | null) => {
75
+ const { elementRef } = this.props
76
+
77
+ this.ref = el
78
+
79
+ if (typeof elementRef === 'function') {
80
+ elementRef(el)
81
+ }
82
+ }
83
+
84
+ render() {
85
+ const {
86
+ labelledBy,
87
+ variant,
88
+ id,
89
+ maxHeight,
90
+ minHeight,
91
+ padding,
92
+ textAlign,
93
+ children,
94
+ elementRef,
95
+ isDisabled,
96
+ isSelected,
97
+ styles,
98
+ active,
99
+ unmountOnExit,
100
+ tabIndex,
101
+ ...props
102
+ } = this.props
103
+
104
+ return (
105
+ <div
106
+ {...passthroughProps(props)}
107
+ css={styles?.panel}
108
+ role="tabpanel"
109
+ id={id}
110
+ aria-labelledby={labelledBy}
111
+ aria-hidden={this.isHidden ? 'true' : undefined}
112
+ tabIndex={this.isHidden ? undefined : tabIndex}
113
+ ref={this.handleRef}
114
+ >
115
+ <Transition
116
+ type="fade"
117
+ in={!this.isHidden}
118
+ unmountOnExit={unmountOnExit}
119
+ transitionExit={false}
120
+ >
121
+ <View
122
+ css={styles?.content}
123
+ maxHeight={maxHeight}
124
+ minHeight={minHeight}
125
+ as="div"
126
+ padding={padding}
127
+ textAlign={textAlign}
128
+ >
129
+ {children}
130
+ </View>
131
+ </Transition>
132
+ </div>
133
+ )
134
+ }
135
+ }
136
+
137
+ export default Panel
138
+ export { Panel }
@@ -0,0 +1,100 @@
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
+ Spacing,
28
+ WithStyleProps,
29
+ ComponentStyle
30
+ } from '@instructure/emotion'
31
+ import type {
32
+ OtherHTMLAttributes,
33
+ TabsPanelTheme
34
+ } from '@instructure/shared-types'
35
+
36
+ type TabsPanelOwnProps = {
37
+ /**
38
+ * The content that will be rendered in the corresponding <Tab /> and will label
39
+ * this `<Tabs.Panel />` for screen readers
40
+ */
41
+ renderTitle: React.ReactNode | (() => React.ReactNode)
42
+ children?: React.ReactNode
43
+ variant?: 'default' | 'secondary'
44
+ isSelected?: boolean
45
+ isDisabled?: boolean
46
+ maxHeight?: string | number
47
+ minHeight?: string | number
48
+ id?: string
49
+ labelledBy?: string
50
+ padding?: Spacing
51
+ textAlign?: 'start' | 'center' | 'end'
52
+ /**
53
+ * provides a reference to the underlying html root element
54
+ */
55
+ elementRef?: (element: HTMLDivElement | null) => void
56
+ /**
57
+ * Only one `<Tabs.Panel />` can be marked as active. The marked panel's content is rendered
58
+ * for all the `<Tabs.Panel />`s.
59
+ */
60
+ active?: boolean
61
+ /**
62
+ * When set to false, the tabPanel only will be hidden, but not dismounted when not active
63
+ */
64
+ unmountOnExit?: boolean
65
+ /**
66
+ * The tabIndex of the tabpanel element. Set to 0 for text-only panels to make them
67
+ * accessible to keyboard and screen reader users.
68
+ */
69
+ tabIndex?: number
70
+ }
71
+
72
+ type PropKeys = keyof TabsPanelOwnProps
73
+
74
+ type AllowedPropKeys = Readonly<Array<PropKeys>>
75
+
76
+ type TabsPanelProps = TabsPanelOwnProps &
77
+ WithStyleProps<TabsPanelTheme, TabsPanelStyle> &
78
+ OtherHTMLAttributes<TabsPanelOwnProps>
79
+
80
+ type TabsPanelStyle = ComponentStyle<'panel' | 'content'>
81
+ const allowedProps: AllowedPropKeys = [
82
+ 'renderTitle',
83
+ 'children',
84
+ 'variant',
85
+ 'isSelected',
86
+ 'isDisabled',
87
+ 'maxHeight',
88
+ 'minHeight',
89
+ 'id',
90
+ 'labelledBy',
91
+ 'padding',
92
+ 'textAlign',
93
+ 'elementRef',
94
+ 'active',
95
+ 'unmountOnExit',
96
+ 'tabIndex'
97
+ ]
98
+
99
+ export type { TabsPanelProps, TabsPanelStyle }
100
+ export { allowedProps }
@@ -0,0 +1,92 @@
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 type { TabsPanelProps, TabsPanelStyle } from './props'
26
+ import type { NewComponentTypes, SharedTokens } from '@instructure/ui-themes'
27
+
28
+ type StyleParams = {
29
+ maxHeight: TabsPanelProps['maxHeight']
30
+ isSelected: TabsPanelProps['isSelected']
31
+ isHidden: boolean
32
+ }
33
+
34
+ /**
35
+ * ---
36
+ * private: true
37
+ * ---
38
+ * Generates the style object from the theme and provided additional information
39
+ * @param {Object} componentTheme The theme variable object.
40
+ * @param {Object} params the props and passed through data of the component, the style is applied to
41
+ * @return {Object} The final style object, which will be used in the component
42
+ */
43
+ const generateStyle = (
44
+ componentTheme: NewComponentTypes['TabsPanel'],
45
+ params: StyleParams,
46
+ sharedTokens: SharedTokens
47
+ ): TabsPanelStyle => {
48
+ const { maxHeight, isSelected, isHidden } = params
49
+
50
+ return {
51
+ panel: {
52
+ label: 'panel',
53
+ boxSizing: 'border-box',
54
+ flexShrink: 0,
55
+ flexGrow: 0,
56
+ fontFamily: componentTheme.fontFamily,
57
+ fontWeight: componentTheme.fontWeight,
58
+ lineHeight: componentTheme.lineHeight,
59
+ fontSize: componentTheme.fontSize,
60
+ ...(isSelected && {
61
+ flexGrow: 1,
62
+ height: '100%'
63
+ }),
64
+ ...(isHidden && {
65
+ display: 'none'
66
+ }),
67
+ '&:focus': {
68
+ outlineColor: sharedTokens.focusOutline.infoColor
69
+ }
70
+ },
71
+ content: {
72
+ label: 'panel__content',
73
+ boxSizing: 'border-box',
74
+ width: '100%',
75
+ height: '100%',
76
+ borderWidth: componentTheme.borderWidth,
77
+ borderStyle: 'solid',
78
+ background: componentTheme.background,
79
+ borderColor: componentTheme.borderColor,
80
+ color: componentTheme.textColor,
81
+ borderLeft: 'none',
82
+ borderRight: 'none',
83
+ borderBottom: 'none',
84
+ // we exposed this so in some use cases it can be set to "visible",
85
+ // e.g. when a 100% width button's focus ring would get cropped
86
+ overflowY: componentTheme.defaultOverflowY,
87
+ ...(maxHeight && { overflow: 'auto' })
88
+ }
89
+ }
90
+ }
91
+
92
+ export default generateStyle