@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
@@ -27,7 +27,7 @@ var _dec, _class, _Tabs;
27
27
 
28
28
  import { cloneElement, Children, Component } from 'react';
29
29
  import keycode from 'keycode';
30
- import { View } from '@instructure/ui-view';
30
+ import { View } from '@instructure/ui-view/v11_6';
31
31
  import { matchComponentTypes, safeCloneElement, passthroughProps } from '@instructure/ui-react-utils';
32
32
  import { logError as error } from '@instructure/console';
33
33
  import { uid } from '@instructure/uid';
@@ -35,7 +35,7 @@ import { Focusable } from '@instructure/ui-focusable';
35
35
  import { getBoundingClientRect } from '@instructure/ui-dom-utils';
36
36
  import { debounce } from '@instructure/debounce';
37
37
  import { px } from '@instructure/ui-utils';
38
- import { withStyle } from '@instructure/emotion';
38
+ import { withStyleLegacy as withStyle } from '@instructure/emotion';
39
39
  import generateStyle from "./styles.js";
40
40
  import generateComponentTheme from "./theme.js";
41
41
  import { Tab } from "./Tab/index.js";
@@ -0,0 +1,126 @@
1
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
2
+ const _excluded = ["labelledBy", "variant", "id", "maxHeight", "minHeight", "padding", "textAlign", "children", "elementRef", "isDisabled", "isSelected", "styles", "active", "unmountOnExit", "tabIndex"];
3
+ var _dec, _class, _Panel;
4
+ /*
5
+ * The MIT License (MIT)
6
+ *
7
+ * Copyright (c) 2015 - present Instructure, Inc.
8
+ *
9
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
10
+ * of this software and associated documentation files (the "Software"), to deal
11
+ * in the Software without restriction, including without limitation the rights
12
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ * copies of the Software, and to permit persons to whom the Software is
14
+ * furnished to do so, subject to the following conditions:
15
+ *
16
+ * The above copyright notice and this permission notice shall be included in all
17
+ * copies or substantial portions of the Software.
18
+ *
19
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
+ * SOFTWARE.
26
+ */
27
+
28
+ import { Component } from 'react';
29
+ import { View } from '@instructure/ui-view/latest';
30
+ import { passthroughProps } from '@instructure/ui-react-utils';
31
+ import { Transition } from '@instructure/ui-motion';
32
+ import { withStyle } from '@instructure/emotion';
33
+ import generateStyle from "./styles.js";
34
+ import { allowedProps } from "./props.js";
35
+ /**
36
+ ---
37
+ parent: Tabs
38
+ id: Tabs.Panel
39
+ ---
40
+ **/
41
+ import { jsx as _jsx } from "@emotion/react/jsx-runtime";
42
+ let Panel = (_dec = withStyle(generateStyle), _dec(_class = (_Panel = class Panel extends Component {
43
+ constructor(...args) {
44
+ super(...args);
45
+ this.ref = null;
46
+ this.handleRef = el => {
47
+ const elementRef = this.props.elementRef;
48
+ this.ref = el;
49
+ if (typeof elementRef === 'function') {
50
+ elementRef(el);
51
+ }
52
+ };
53
+ }
54
+ componentDidMount() {
55
+ var _this$props$makeStyle, _this$props;
56
+ (_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props, {
57
+ isHidden: this.isHidden
58
+ });
59
+ }
60
+ componentDidUpdate() {
61
+ var _this$props$makeStyle2, _this$props2;
62
+ (_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2, {
63
+ isHidden: this.isHidden
64
+ });
65
+ }
66
+ get isHidden() {
67
+ const _this$props3 = this.props,
68
+ isDisabled = _this$props3.isDisabled,
69
+ isSelected = _this$props3.isSelected;
70
+ return !isSelected || !!isDisabled;
71
+ }
72
+ render() {
73
+ const _this$props4 = this.props,
74
+ labelledBy = _this$props4.labelledBy,
75
+ variant = _this$props4.variant,
76
+ id = _this$props4.id,
77
+ maxHeight = _this$props4.maxHeight,
78
+ minHeight = _this$props4.minHeight,
79
+ padding = _this$props4.padding,
80
+ textAlign = _this$props4.textAlign,
81
+ children = _this$props4.children,
82
+ elementRef = _this$props4.elementRef,
83
+ isDisabled = _this$props4.isDisabled,
84
+ isSelected = _this$props4.isSelected,
85
+ styles = _this$props4.styles,
86
+ active = _this$props4.active,
87
+ unmountOnExit = _this$props4.unmountOnExit,
88
+ tabIndex = _this$props4.tabIndex,
89
+ props = _objectWithoutProperties(_this$props4, _excluded);
90
+ return _jsx("div", {
91
+ ...passthroughProps(props),
92
+ css: styles === null || styles === void 0 ? void 0 : styles.panel,
93
+ role: "tabpanel",
94
+ id: id,
95
+ "aria-labelledby": labelledBy,
96
+ "aria-hidden": this.isHidden ? 'true' : void 0,
97
+ tabIndex: this.isHidden ? void 0 : tabIndex,
98
+ ref: this.handleRef,
99
+ children: _jsx(Transition, {
100
+ type: "fade",
101
+ in: !this.isHidden,
102
+ unmountOnExit: unmountOnExit,
103
+ transitionExit: false,
104
+ children: _jsx(View, {
105
+ css: styles === null || styles === void 0 ? void 0 : styles.content,
106
+ maxHeight: maxHeight,
107
+ minHeight: minHeight,
108
+ as: "div",
109
+ padding: padding,
110
+ textAlign: textAlign,
111
+ children: children
112
+ })
113
+ })
114
+ });
115
+ }
116
+ }, _Panel.displayName = "Panel", _Panel.componentId = 'Tabs.Panel', _Panel.allowedProps = allowedProps, _Panel.defaultProps = {
117
+ isDisabled: false,
118
+ textAlign: 'start',
119
+ variant: 'default',
120
+ isSelected: false,
121
+ padding: 'small',
122
+ active: false,
123
+ unmountOnExit: true
124
+ }, _Panel)) || _class);
125
+ export default Panel;
126
+ export { Panel };
@@ -0,0 +1,26 @@
1
+ /*
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2015 - present Instructure, Inc.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ const allowedProps = ['renderTitle', 'children', 'variant', 'isSelected', 'isDisabled', 'maxHeight', 'minHeight', 'id', 'labelledBy', 'padding', 'textAlign', 'elementRef', 'active', 'unmountOnExit', 'tabIndex'];
26
+ export { allowedProps };
@@ -0,0 +1,81 @@
1
+ /*
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2015 - present Instructure, Inc.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ /**
26
+ * ---
27
+ * private: true
28
+ * ---
29
+ * Generates the style object from the theme and provided additional information
30
+ * @param {Object} componentTheme The theme variable object.
31
+ * @param {Object} params the props and passed through data of the component, the style is applied to
32
+ * @return {Object} The final style object, which will be used in the component
33
+ */
34
+ const generateStyle = (componentTheme, params, sharedTokens) => {
35
+ const maxHeight = params.maxHeight,
36
+ isSelected = params.isSelected,
37
+ isHidden = params.isHidden;
38
+ return {
39
+ panel: {
40
+ label: 'panel',
41
+ boxSizing: 'border-box',
42
+ flexShrink: 0,
43
+ flexGrow: 0,
44
+ fontFamily: componentTheme.fontFamily,
45
+ fontWeight: componentTheme.fontWeight,
46
+ lineHeight: componentTheme.lineHeight,
47
+ fontSize: componentTheme.fontSize,
48
+ ...(isSelected && {
49
+ flexGrow: 1,
50
+ height: '100%'
51
+ }),
52
+ ...(isHidden && {
53
+ display: 'none'
54
+ }),
55
+ '&:focus': {
56
+ outlineColor: sharedTokens.focusOutline.infoColor
57
+ }
58
+ },
59
+ content: {
60
+ label: 'panel__content',
61
+ boxSizing: 'border-box',
62
+ width: '100%',
63
+ height: '100%',
64
+ borderWidth: componentTheme.borderWidth,
65
+ borderStyle: 'solid',
66
+ background: componentTheme.background,
67
+ borderColor: componentTheme.borderColor,
68
+ color: componentTheme.textColor,
69
+ borderLeft: 'none',
70
+ borderRight: 'none',
71
+ borderBottom: 'none',
72
+ // we exposed this so in some use cases it can be set to "visible",
73
+ // e.g. when a 100% width button's focus ring would get cropped
74
+ overflowY: componentTheme.defaultOverflowY,
75
+ ...(maxHeight && {
76
+ overflow: 'auto'
77
+ })
78
+ }
79
+ };
80
+ };
81
+ export default generateStyle;
@@ -0,0 +1,118 @@
1
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
2
+ const _excluded = ["id", "variant", "isSelected", "isDisabled", "controls", "children", "styles"];
3
+ var _dec, _class, _Tab;
4
+ /*
5
+ * The MIT License (MIT)
6
+ *
7
+ * Copyright (c) 2015 - present Instructure, Inc.
8
+ *
9
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
10
+ * of this software and associated documentation files (the "Software"), to deal
11
+ * in the Software without restriction, including without limitation the rights
12
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ * copies of the Software, and to permit persons to whom the Software is
14
+ * furnished to do so, subject to the following conditions:
15
+ *
16
+ * The above copyright notice and this permission notice shall be included in all
17
+ * copies or substantial portions of the Software.
18
+ *
19
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
+ * SOFTWARE.
26
+ */
27
+
28
+ import { Component } from 'react';
29
+ import { passthroughProps, callRenderProp } from '@instructure/ui-react-utils';
30
+ import { View } from '@instructure/ui-view/latest';
31
+ import { withStyle } from '@instructure/emotion';
32
+ import generateStyle from "./styles.js";
33
+ import { allowedProps } from "./props.js";
34
+ /**
35
+ ---
36
+ parent: Tabs
37
+ id: Tabs.Tab
38
+ ---
39
+ **/
40
+ import { jsx as _jsx } from "@emotion/react/jsx-runtime";
41
+ let Tab = (_dec = withStyle(generateStyle), _dec(_class = (_Tab = class Tab extends Component {
42
+ constructor(...args) {
43
+ super(...args);
44
+ this.handleClick = event => {
45
+ const _this$props = this.props,
46
+ onClick = _this$props.onClick,
47
+ index = _this$props.index,
48
+ id = _this$props.id,
49
+ isDisabled = _this$props.isDisabled;
50
+ if (isDisabled) {
51
+ return;
52
+ }
53
+ if (typeof onClick === 'function') {
54
+ onClick(event, {
55
+ index,
56
+ id
57
+ });
58
+ }
59
+ };
60
+ this.handleKeyDown = event => {
61
+ const _this$props2 = this.props,
62
+ onKeyDown = _this$props2.onKeyDown,
63
+ index = _this$props2.index,
64
+ id = _this$props2.id,
65
+ isDisabled = _this$props2.isDisabled;
66
+ if (isDisabled) {
67
+ return;
68
+ }
69
+ if (typeof onKeyDown === 'function') {
70
+ onKeyDown(event, {
71
+ index,
72
+ id
73
+ });
74
+ }
75
+ };
76
+ }
77
+ componentDidMount() {
78
+ var _this$props$makeStyle, _this$props3;
79
+ (_this$props$makeStyle = (_this$props3 = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props3);
80
+ }
81
+ componentDidUpdate() {
82
+ var _this$props$makeStyle2, _this$props4;
83
+ (_this$props$makeStyle2 = (_this$props4 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props4);
84
+ }
85
+ render() {
86
+ const _this$props5 = this.props,
87
+ id = _this$props5.id,
88
+ variant = _this$props5.variant,
89
+ isSelected = _this$props5.isSelected,
90
+ isDisabled = _this$props5.isDisabled,
91
+ controls = _this$props5.controls,
92
+ children = _this$props5.children,
93
+ styles = _this$props5.styles,
94
+ props = _objectWithoutProperties(_this$props5, _excluded);
95
+ return _jsx(View, {
96
+ ...passthroughProps(props),
97
+ as: "div",
98
+ role: "tab",
99
+ id: id,
100
+ onClick: this.handleClick,
101
+ onKeyDown: this.handleKeyDown,
102
+ css: styles === null || styles === void 0 ? void 0 : styles.tab,
103
+ "aria-selected": isSelected ? 'true' : void 0,
104
+ "aria-disabled": isDisabled ? 'true' : void 0,
105
+ "aria-controls": controls,
106
+ tabIndex: isSelected && !isDisabled ? 0 : void 0,
107
+ position: "relative",
108
+ focusPosition: "inset",
109
+ children: callRenderProp(children)
110
+ });
111
+ }
112
+ }, _Tab.displayName = "Tab", _Tab.componentId = 'Tabs.Tab', _Tab.allowedProps = allowedProps, _Tab.defaultProps = {
113
+ variant: 'default',
114
+ isDisabled: false,
115
+ isSelected: false
116
+ }, _Tab)) || _class);
117
+ export default Tab;
118
+ export { Tab };
@@ -0,0 +1,26 @@
1
+ /*
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2015 - present Instructure, Inc.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ const allowedProps = ['variant', 'id', 'index', 'controls', 'isDisabled', 'isSelected', 'onClick', 'onKeyDown', 'children', 'isOverflowScroll'];
26
+ export { allowedProps };
@@ -0,0 +1,145 @@
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
+ // keyframes have to be outside of 'generateStyle',
27
+ // since it is causing problems in style recalculation
28
+ const selectedTab = keyframes`
29
+ to {
30
+ opacity: 1;
31
+ transform: translate3d(0, 0, 0) scaleX(1);
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 = (componentTheme, params) => {
44
+ const variant = params.variant,
45
+ isSelected = params.isSelected,
46
+ isDisabled = params.isDisabled,
47
+ isOverflowScroll = params.isOverflowScroll;
48
+ const variants = {
49
+ default: {
50
+ padding: '1rem 1.25rem',
51
+ // if horizontal padding changes, update `scrollOverlayWidthDefault` in `Tabs/theme.js`
52
+ lineHeight: 1,
53
+ position: 'relative',
54
+ zIndex: componentTheme.zIndex,
55
+ color: componentTheme.defaultTextColor,
56
+ ...(isDisabled && {
57
+ fontWeight: 'normal'
58
+ }),
59
+ '&::after': {
60
+ content: '""',
61
+ height: '0.25rem',
62
+ width: '100%',
63
+ position: 'absolute',
64
+ insetInlineStart: 0,
65
+ bottom: 0,
66
+ opacity: 0,
67
+ transform: 'translate3d(0, 0, 0) scaleX(0.01)',
68
+ ...(isSelected && {
69
+ backgroundColor: componentTheme.defaultSelectedBorderColor,
70
+ animationName: selectedTab,
71
+ animationDuration: '0.2s',
72
+ animationFillMode: 'forwards',
73
+ animationTimingFunction: 'ease-out'
74
+ })
75
+ },
76
+ '&:hover': {
77
+ ...(!isDisabled && !isSelected && {
78
+ borderBottomColor: componentTheme.defaultHoverBorderColor
79
+ })
80
+ }
81
+ },
82
+ secondary: {
83
+ padding: '0.75rem 1rem',
84
+ // if horizontal padding changes, update `scrollOverlayWidthSecondary` in `Tabs/theme.js`
85
+ color: componentTheme.secondaryTextColor,
86
+ marginInlineEnd: '0.2em',
87
+ marginBottom: isOverflowScroll ? '0rem' : '-0.0625rem',
88
+ border: '0.0625rem solid transparent',
89
+ borderTopLeftRadius: '0.1875rem',
90
+ borderTopRightRadius: '0.1875rem',
91
+ position: 'relative',
92
+ ...(isSelected && {
93
+ background: componentTheme.secondarySelectedBackground,
94
+ borderColor: componentTheme.secondarySelectedBorderColor,
95
+ zIndex: componentTheme.zIndex,
96
+ borderBottomColor: componentTheme.secondarySelectedBackground,
97
+ color: componentTheme.secondarySelectedTextColor
98
+ }),
99
+ '&:first-of-type': {
100
+ marginInlineStart: '0'
101
+ },
102
+ '&:hover': {
103
+ ...(!isDisabled && !isSelected && {
104
+ background: componentTheme.secondarySelectedBackground,
105
+ borderColor: componentTheme.secondarySelectedBorderColor,
106
+ color: componentTheme.secondarySelectedTextColor
107
+ })
108
+ }
109
+ }
110
+ };
111
+
112
+ // overrides for View default focus ring
113
+ const focusRingStyles = {
114
+ '&:before': {
115
+ inset: '0.5rem',
116
+ borderRadius: '0.25rem'
117
+ },
118
+ '&:focus': {
119
+ '&:before': {
120
+ inset: '0.375rem'
121
+ }
122
+ }
123
+ };
124
+ return {
125
+ tab: {
126
+ label: 'tab',
127
+ fontFamily: componentTheme.fontFamily,
128
+ fontWeight: componentTheme.fontWeight,
129
+ lineHeight: componentTheme.lineHeight,
130
+ fontSize: componentTheme.fontSize,
131
+ cursor: 'pointer',
132
+ userSelect: 'none',
133
+ whiteSpace: 'nowrap',
134
+ ...((isSelected || isDisabled) && {
135
+ cursor: 'default'
136
+ }),
137
+ ...(isDisabled && {
138
+ opacity: 0.5
139
+ }),
140
+ ...focusRingStyles,
141
+ ...variants[variant]
142
+ }
143
+ };
144
+ };
145
+ export default generateStyle;