@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
@@ -0,0 +1,80 @@
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
+ Renderable,
29
+ TabsTabTheme
30
+ } from '@instructure/shared-types'
31
+ import type { WithStyleProps, ComponentStyle } from '@instructure/emotion'
32
+ import type { ViewOwnProps } from '@instructure/ui-view/latest'
33
+
34
+ type TabsTabOwnProps = {
35
+ variant?: 'default' | 'secondary'
36
+ id: string
37
+ index: number
38
+ controls: string
39
+ isDisabled?: boolean
40
+ isSelected?: boolean
41
+ onClick?: (
42
+ event: React.MouseEvent<ViewOwnProps>,
43
+ tabData: { index: number; id: string }
44
+ ) => void
45
+ onKeyDown?: (
46
+ event: React.KeyboardEvent<ViewOwnProps>,
47
+ tabData: { index: number; id: string }
48
+ ) => void
49
+ children?: Renderable
50
+ /**
51
+ * Whether tabOverflow prop in Tabs is set to 'scroll'.
52
+ */
53
+ isOverflowScroll?: boolean
54
+ }
55
+
56
+ type PropKeys = keyof TabsTabOwnProps
57
+
58
+ type AllowedPropKeys = Readonly<Array<PropKeys>>
59
+
60
+ type TabsTabProps = TabsTabOwnProps &
61
+ WithStyleProps<TabsTabTheme, TabsTabStyle> &
62
+ OtherHTMLAttributes<TabsTabOwnProps>
63
+
64
+ type TabsTabStyle = ComponentStyle<'tab'>
65
+
66
+ const allowedProps: AllowedPropKeys = [
67
+ 'variant',
68
+ 'id',
69
+ 'index',
70
+ 'controls',
71
+ 'isDisabled',
72
+ 'isSelected',
73
+ 'onClick',
74
+ 'onKeyDown',
75
+ 'children',
76
+ 'isOverflowScroll'
77
+ ]
78
+
79
+ export type { TabsTabProps, TabsTabStyle }
80
+ export { allowedProps }
@@ -0,0 +1,161 @@
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 { keyframes } from '@instructure/emotion'
26
+
27
+ import type { NewComponentTypes } from '@instructure/ui-themes'
28
+ import type { TabsTabProps, TabsTabStyle } from './props'
29
+
30
+ type StyleParams = {
31
+ variant: TabsTabProps['variant']
32
+ isSelected: TabsTabProps['isSelected']
33
+ isDisabled: TabsTabProps['isDisabled']
34
+ isOverflowScroll: TabsTabProps['isOverflowScroll']
35
+ }
36
+
37
+ // keyframes have to be outside of 'generateStyle',
38
+ // since it is causing problems in style recalculation
39
+ const selectedTab = keyframes`
40
+ to {
41
+ opacity: 1;
42
+ transform: translate3d(0, 0, 0) scaleX(1);
43
+ }`
44
+
45
+ /**
46
+ * ---
47
+ * private: true
48
+ * ---
49
+ * Generates the style object from the theme and provided additional information
50
+ * @param {Object} componentTheme The theme variable object.
51
+ * @param {Object} params the props and passed through data of the component, the style is applied to
52
+ * @return {Object} The final style object, which will be used in the component
53
+ */
54
+ const generateStyle = (
55
+ componentTheme: NewComponentTypes['TabsTab'],
56
+ params: StyleParams
57
+ ): TabsTabStyle => {
58
+ const { variant, isSelected, isDisabled, isOverflowScroll } = params
59
+
60
+ const variants = {
61
+ default: {
62
+ padding: '1rem 1.25rem', // if horizontal padding changes, update `scrollOverlayWidthDefault` in `Tabs/theme.js`
63
+ lineHeight: 1,
64
+ position: 'relative',
65
+ zIndex: componentTheme.zIndex,
66
+ color: componentTheme.defaultTextColor,
67
+
68
+ ...(isDisabled && { fontWeight: 'normal' }),
69
+
70
+ '&::after': {
71
+ content: '""',
72
+ height: '0.25rem',
73
+ width: '100%',
74
+ position: 'absolute',
75
+ insetInlineStart: 0,
76
+ bottom: 0,
77
+ opacity: 0,
78
+ transform: 'translate3d(0, 0, 0) scaleX(0.01)',
79
+ ...(isSelected && {
80
+ backgroundColor: componentTheme.defaultSelectedBorderColor,
81
+ animationName: selectedTab,
82
+ animationDuration: '0.2s',
83
+ animationFillMode: 'forwards',
84
+ animationTimingFunction: 'ease-out'
85
+ })
86
+ },
87
+
88
+ '&:hover': {
89
+ ...(!isDisabled &&
90
+ !isSelected && {
91
+ borderBottomColor: componentTheme.defaultHoverBorderColor
92
+ })
93
+ }
94
+ },
95
+ secondary: {
96
+ padding: '0.75rem 1rem', // if horizontal padding changes, update `scrollOverlayWidthSecondary` in `Tabs/theme.js`
97
+ color: componentTheme.secondaryTextColor,
98
+ marginInlineEnd: '0.2em',
99
+ marginBottom: isOverflowScroll ? '0rem' : '-0.0625rem',
100
+ border: '0.0625rem solid transparent',
101
+ borderTopLeftRadius: '0.1875rem',
102
+ borderTopRightRadius: '0.1875rem',
103
+ position: 'relative',
104
+
105
+ ...(isSelected && {
106
+ background: componentTheme.secondarySelectedBackground,
107
+ borderColor: componentTheme.secondarySelectedBorderColor,
108
+ zIndex: componentTheme.zIndex,
109
+ borderBottomColor: componentTheme.secondarySelectedBackground,
110
+ color: componentTheme.secondarySelectedTextColor
111
+ }),
112
+
113
+ '&:first-of-type': { marginInlineStart: '0' },
114
+
115
+ '&:hover': {
116
+ ...(!isDisabled &&
117
+ !isSelected && {
118
+ background: componentTheme.secondarySelectedBackground,
119
+ borderColor: componentTheme.secondarySelectedBorderColor,
120
+ color: componentTheme.secondarySelectedTextColor
121
+ })
122
+ }
123
+ }
124
+ }
125
+
126
+ // overrides for View default focus ring
127
+ const focusRingStyles = {
128
+ '&:before': {
129
+ inset: '0.5rem',
130
+ borderRadius: '0.25rem'
131
+ },
132
+
133
+ '&:focus': {
134
+ '&:before': {
135
+ inset: '0.375rem'
136
+ }
137
+ }
138
+ }
139
+
140
+ return {
141
+ tab: {
142
+ label: 'tab',
143
+ fontFamily: componentTheme.fontFamily,
144
+ fontWeight: componentTheme.fontWeight,
145
+ lineHeight: componentTheme.lineHeight,
146
+ fontSize: componentTheme.fontSize,
147
+ cursor: 'pointer',
148
+ userSelect: 'none',
149
+ whiteSpace: 'nowrap',
150
+
151
+ ...((isSelected || isDisabled) && { cursor: 'default' }),
152
+ ...(isDisabled && { opacity: 0.5 }),
153
+
154
+ ...focusRingStyles,
155
+
156
+ ...variants[variant!]
157
+ }
158
+ }
159
+ }
160
+
161
+ export default generateStyle