@zendeskgarden/react-tabs 9.0.0-next.9 → 9.1.0

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.
@@ -24,7 +24,8 @@ const Tab = React.forwardRef((_ref, ref) => {
24
24
  return React.createElement(StyledTab, Object.assign({
25
25
  role: "tab",
26
26
  "aria-disabled": disabled,
27
- ref: ref
27
+ ref: ref,
28
+ $isVertical: tabsPropGetters?.isVertical
28
29
  }, otherProps));
29
30
  }
30
31
  const {
@@ -34,12 +35,13 @@ const Tab = React.forwardRef((_ref, ref) => {
34
35
  value: item
35
36
  });
36
37
  return React.createElement(StyledTab, Object.assign({
37
- isSelected: item === tabsPropGetters.selectedValue
38
+ $isSelected: item === tabsPropGetters.selectedValue,
39
+ $isVertical: tabsPropGetters.isVertical
38
40
  }, tabProps, otherProps, {
39
41
  ref: mergeRefs([tabRef, ref])
40
42
  }));
41
43
  });
42
- Tab.displayName = 'Tab';
44
+ Tab.displayName = 'Tabs.Tab';
43
45
  Tab.propTypes = {
44
46
  disabled: PropTypes.bool,
45
47
  item: PropTypes.any
@@ -19,10 +19,12 @@ const TabList = React.forwardRef((props, ref) => {
19
19
  }, props));
20
20
  }
21
21
  const tabListProps = tabsPropGetters.getTabListProps();
22
- return React.createElement(StyledTabList, Object.assign({}, tabListProps, props, {
22
+ return React.createElement(StyledTabList, Object.assign({
23
+ $isVertical: tabsPropGetters.isVertical
24
+ }, tabListProps, props, {
23
25
  ref: ref
24
26
  }));
25
27
  });
26
- TabList.displayName = 'TabList';
28
+ TabList.displayName = 'Tabs.TabList';
27
29
 
28
30
  export { TabList };
@@ -27,12 +27,13 @@ const TabPanel = React.forwardRef((_ref, ref) => {
27
27
  value: item
28
28
  });
29
29
  return React.createElement(StyledTabPanel, Object.assign({
30
- "aria-hidden": tabsPropGetters.selectedValue !== item
30
+ "aria-hidden": tabsPropGetters.selectedValue !== item,
31
+ $isVertical: tabsPropGetters.isVertical
31
32
  }, tabPanelProps, otherProps, {
32
33
  ref: ref
33
34
  }));
34
35
  });
35
- TabPanel.displayName = 'TabPanel';
36
+ TabPanel.displayName = 'Tabs.TabPanel';
36
37
  TabPanel.propTypes = {
37
38
  item: PropTypes.any
38
39
  };
@@ -43,10 +43,14 @@ const TabsComponent = forwardRef((_ref, ref) => {
43
43
  }
44
44
  }
45
45
  });
46
+ const contextValue = useMemo(() => ({
47
+ isVertical,
48
+ ...tabsContextValue
49
+ }), [isVertical, tabsContextValue]);
46
50
  return React.createElement(TabsContext.Provider, {
47
- value: tabsContextValue
51
+ value: contextValue
48
52
  }, React.createElement(StyledTabs, Object.assign({
49
- isVertical: isVertical
53
+ $isVertical: isVertical
50
54
  }, otherProps, {
51
55
  ref: ref
52
56
  }), children));
@@ -5,17 +5,29 @@
5
5
  * found at http://www.apache.org/licenses/LICENSE-2.0.
6
6
  */
7
7
  import styled, { css } from 'styled-components';
8
- import { retrieveComponentStyles, DEFAULT_THEME, getColorV8, focusStyles } from '@zendeskgarden/react-theming';
8
+ import { retrieveComponentStyles, getColor, focusStyles } from '@zendeskgarden/react-theming';
9
9
  import { stripUnit } from 'polished';
10
10
 
11
11
  const COMPONENT_ID = 'tabs.tab';
12
12
  const colorStyles = _ref => {
13
13
  let {
14
14
  theme,
15
- isSelected
15
+ $isSelected
16
16
  } = _ref;
17
- const selectedColor = getColorV8('primaryHue', 600, theme);
18
- return css(["border-color:", ";color:", ";&:hover{color:", ";}", " &:active{border-color:currentcolor;color:", ";}&[aria-disabled='true']{border-color:transparent;color:", ";}"], isSelected && 'currentcolor !important', isSelected ? selectedColor : 'inherit', selectedColor, focusStyles({
17
+ const borderColor = $isSelected ? getColor({
18
+ theme,
19
+ variable: 'border.primaryEmphasis'
20
+ }) : 'transparent';
21
+ const selectedColor = getColor({
22
+ theme,
23
+ variable: 'foreground.primary'
24
+ });
25
+ const foregroundColor = $isSelected ? selectedColor : 'inherit';
26
+ const disabledColor = getColor({
27
+ theme,
28
+ variable: 'foreground.disabled'
29
+ });
30
+ return css(["border-color:", ";color:", ";&:hover{color:", ";}", " &:active{border-color:currentcolor;color:", ";}&[aria-disabled='true']{border-color:transparent;color:", ";}"], borderColor, foregroundColor, selectedColor, focusStyles({
19
31
  theme,
20
32
  inset: true,
21
33
  spacerWidth: null,
@@ -24,26 +36,39 @@ const colorStyles = _ref => {
24
36
  styles: {
25
37
  color: selectedColor
26
38
  }
27
- }), selectedColor, props => getColorV8('neutralHue', 400, props.theme));
39
+ }), selectedColor, disabledColor);
28
40
  };
29
41
  const sizeStyles = _ref2 => {
30
42
  let {
31
- theme
43
+ theme,
44
+ $isVertical
32
45
  } = _ref2;
33
- const paddingTop = theme.space.base * 2.5;
34
- const paddingHorizontal = theme.space.base * 7;
35
- const paddingBottom = paddingTop - stripUnit(theme.borderWidths.md) - stripUnit(theme.borderWidths.sm);
36
- return css(["padding:", "px ", "px ", "px;"], paddingTop, paddingHorizontal, paddingBottom);
46
+ const borderWidth = theme.borderWidths.md;
47
+ const focusHeight = `calc(100% - ${theme.space.base * ($isVertical ? 2 : 4)}px);`;
48
+ let marginBottom;
49
+ let padding;
50
+ if ($isVertical) {
51
+ marginBottom = `${theme.space.base * 5}px`;
52
+ padding = `${theme.space.base}px ${theme.space.base * 2}px`;
53
+ } else {
54
+ const paddingTop = theme.space.base * 2.5;
55
+ const paddingHorizontal = theme.space.base * 7;
56
+ const paddingBottom = paddingTop - stripUnit(theme.borderWidths.md) - stripUnit(theme.borderWidths.sm);
57
+ padding = `${paddingTop}px ${paddingHorizontal}px ${paddingBottom}px`;
58
+ }
59
+ return css(["margin-bottom:", ";border-width:", ";padding:", ";&:focus-visible::before,&[data-garden-focus-visible]::before{height:", ";}&:last-of-type{margin-bottom:0;}"], marginBottom, borderWidth, padding, focusHeight);
37
60
  };
38
61
  const StyledTab = styled.div.attrs({
39
62
  'data-garden-id': COMPONENT_ID,
40
- 'data-garden-version': '9.0.0-next.9'
63
+ 'data-garden-version': '9.1.0'
41
64
  }).withConfig({
42
65
  displayName: "StyledTab",
43
66
  componentId: "sc-x2pbow-0"
44
- })(["display:inline-block;position:relative;transition:color 0.25s ease-in-out;border-bottom:", " transparent;border-width:", ";cursor:pointer;overflow:hidden;vertical-align:top;user-select:none;text-align:center;text-decoration:none;text-overflow:ellipsis;", " ", " &:focus{text-decoration:none;}&::before{transition:box-shadow 0.1s ease-in-out;content:'';}&:focus-visible::before{position:absolute;top:", "px;right:", "px;left:", "px;border-radius:", ";height:", "px;pointer-events:none;}&:active::before{box-shadow:none;}&[aria-disabled='true']{cursor:default;}", ";"], props => props.theme.borderStyles.solid, props => props.theme.borderWidths.md, sizeStyles, colorStyles, props => props.theme.space.base * 2.5, props => props.theme.space.base * 6, props => props.theme.space.base * 6, props => props.theme.borderRadii.md, props => props.theme.space.base * 5, props => retrieveComponentStyles(COMPONENT_ID, props));
45
- StyledTab.defaultProps = {
46
- theme: DEFAULT_THEME
47
- };
67
+ })(["display:", ";position:relative;transition:color 0.25s ease-in-out;border-bottom:", ";border-", ":", ";cursor:pointer;overflow:hidden;vertical-align:top;user-select:none;text-align:", ";text-decoration:none;text-overflow:ellipsis;", ";", ";&:focus{text-decoration:none;}&::before{transition:box-shadow 0.1s ease-in-out;content:'';}&:focus-visible::before{position:absolute;top:", "px;right:", "px;left:", "px;border-radius:", ";pointer-events:none;}&:active::before{box-shadow:none;}&[aria-disabled='true']{cursor:default;}", ";"], props => props.$isVertical ? 'block' : 'inline-block', props => props.$isVertical ? undefined : props.theme.borderStyles.solid, props => props.theme.rtl ? 'right' : 'left', props => props.$isVertical ? props.theme.borderStyles.solid : undefined, props => {
68
+ if (props.$isVertical) {
69
+ return props.theme.rtl ? 'right' : 'left';
70
+ }
71
+ return 'center';
72
+ }, sizeStyles, colorStyles, props => props.theme.space.base * (props.$isVertical ? 1 : 2.5), props => props.theme.space.base * (props.$isVertical ? 1 : 6), props => props.theme.space.base * (props.$isVertical ? 1 : 6), props => props.theme.borderRadii.md, props => retrieveComponentStyles(COMPONENT_ID, props));
48
73
 
49
74
  export { StyledTab };
@@ -4,19 +4,41 @@
4
4
  * Use of this source code is governed under the Apache License, Version 2.0
5
5
  * found at http://www.apache.org/licenses/LICENSE-2.0.
6
6
  */
7
- import styled from 'styled-components';
8
- import { getColorV8, retrieveComponentStyles, DEFAULT_THEME } from '@zendeskgarden/react-theming';
7
+ import styled, { css } from 'styled-components';
8
+ import { retrieveComponentStyles, getColor, getLineHeight } from '@zendeskgarden/react-theming';
9
9
 
10
10
  const COMPONENT_ID = 'tabs.tablist';
11
+ const colorStyles = _ref => {
12
+ let {
13
+ theme
14
+ } = _ref;
15
+ const borderColor = getColor({
16
+ theme,
17
+ variable: 'border.default'
18
+ });
19
+ const foregroundColor = getColor({
20
+ theme,
21
+ variable: 'foreground.default'
22
+ });
23
+ return css(["transition:border-color 0.25s ease-in-out;color-scheme:only ", ";border-bottom-color:", ";color:", ";"], p => p.theme.colors.base, borderColor, foregroundColor);
24
+ };
25
+ const sizeStyles = _ref2 => {
26
+ let {
27
+ theme,
28
+ $isVertical
29
+ } = _ref2;
30
+ const marginBottom = $isVertical ? 0 : `${theme.space.base * 5}px`;
31
+ const borderBottom = $isVertical ? undefined : theme.borderWidths.sm;
32
+ const fontSize = theme.fontSizes.md;
33
+ const lineHeight = getLineHeight(theme.space.base * 5, fontSize);
34
+ return css(["margin-top:0;margin-bottom:", ";border-bottom-width:", ";padding:0;line-height:", ";font-size:", ";"], marginBottom, borderBottom, lineHeight, fontSize);
35
+ };
11
36
  const StyledTabList = styled.div.attrs({
12
37
  'data-garden-id': COMPONENT_ID,
13
- 'data-garden-version': '9.0.0-next.9'
38
+ 'data-garden-version': '9.1.0'
14
39
  }).withConfig({
15
40
  displayName: "StyledTabList",
16
41
  componentId: "sc-wa5aaj-0"
17
- })(["display:block;margin-top:0;margin-bottom:", "px;border-bottom:", " ", " ", ";padding:0;line-height:", "px;white-space:nowrap;color:", ";font-size:", ";", ";"], props => props.theme.space.base * 5, props => props.theme.borderWidths.sm, props => props.theme.borderStyles.solid, props => getColorV8('neutralHue', 300, props.theme), props => props.theme.space.base * 5, props => getColorV8('neutralHue', 600, props.theme), props => props.theme.fontSizes.md, props => retrieveComponentStyles(COMPONENT_ID, props));
18
- StyledTabList.defaultProps = {
19
- theme: DEFAULT_THEME
20
- };
42
+ })(["display:", ";border-bottom:", ";vertical-align:", ";white-space:nowrap;", ";", ";", ";"], props => props.$isVertical ? 'table-cell' : 'block', props => props.$isVertical ? 'none' : props.theme.borderStyles.solid, props => props.$isVertical ? 'top' : undefined, sizeStyles, colorStyles, props => retrieveComponentStyles(COMPONENT_ID, props));
21
43
 
22
44
  export { StyledTabList };
@@ -4,19 +4,24 @@
4
4
  * Use of this source code is governed under the Apache License, Version 2.0
5
5
  * found at http://www.apache.org/licenses/LICENSE-2.0.
6
6
  */
7
- import styled from 'styled-components';
8
- import { retrieveComponentStyles, DEFAULT_THEME } from '@zendeskgarden/react-theming';
7
+ import styled, { css } from 'styled-components';
8
+ import { retrieveComponentStyles } from '@zendeskgarden/react-theming';
9
9
 
10
10
  const COMPONENT_ID = 'tabs.tabpanel';
11
+ const sizeStyles = _ref => {
12
+ let {
13
+ theme,
14
+ $isVertical
15
+ } = _ref;
16
+ const margin = $isVertical ? `${theme.space.base * 8}px` : undefined;
17
+ return css(["margin-", ":", ";"], theme.rtl ? 'right' : 'left', margin);
18
+ };
11
19
  const StyledTabPanel = styled.div.attrs({
12
20
  'data-garden-id': COMPONENT_ID,
13
- 'data-garden-version': '9.0.0-next.9'
21
+ 'data-garden-version': '9.1.0'
14
22
  }).withConfig({
15
23
  displayName: "StyledTabPanel",
16
24
  componentId: "sc-7lhrmp-0"
17
- })(["display:block;&[aria-hidden='true']{display:none;}", ";"], props => retrieveComponentStyles(COMPONENT_ID, props));
18
- StyledTabPanel.defaultProps = {
19
- theme: DEFAULT_THEME
20
- };
25
+ })(["display:block;vertical-align:", ";color-scheme:only ", ";", ";&[aria-hidden='true']{display:none;}", ";"], props => props.$isVertical && 'top', p => p.theme.colors.base, sizeStyles, props => retrieveComponentStyles(COMPONENT_ID, props));
21
26
 
22
27
  export { StyledTabPanel };
@@ -4,28 +4,16 @@
4
4
  * Use of this source code is governed under the Apache License, Version 2.0
5
5
  * found at http://www.apache.org/licenses/LICENSE-2.0.
6
6
  */
7
- import styled, { css } from 'styled-components';
8
- import { retrieveComponentStyles, DEFAULT_THEME } from '@zendeskgarden/react-theming';
9
- import { StyledTab } from './StyledTab.js';
10
- import { StyledTabPanel } from './StyledTabPanel.js';
11
- import { StyledTabList } from './StyledTabList.js';
7
+ import styled from 'styled-components';
8
+ import { retrieveComponentStyles } from '@zendeskgarden/react-theming';
12
9
 
13
10
  const COMPONENT_ID = 'tabs.tabs';
14
- const verticalStyling = _ref => {
15
- let {
16
- theme
17
- } = _ref;
18
- return css(["display:table;", "{display:table-cell;margin-bottom:0;border-bottom:none;vertical-align:top;}", "{display:block;margin-bottom:", "px;margin-left:", ";border-left:", ";border-bottom-style:none;border-", "-style:", ";border-", "-color:transparent;padding:", "px ", "px;text-align:", ";&:last-of-type{margin-bottom:0;}&:focus-visible::before{top:", "px;right:", "px;left:", "px;}}", "{margin-", ":", "px;vertical-align:top;}"], StyledTabList, StyledTab, theme.space.base * 5, theme.rtl && '0', theme.rtl && '0', theme.rtl ? 'right' : 'left', theme.borderStyles.solid, theme.rtl ? 'right' : 'left', theme.space.base, theme.space.base * 2, theme.rtl ? 'right' : 'left', theme.space.base, theme.space.base, theme.space.base, StyledTabPanel, theme.rtl ? 'right' : 'left', theme.space.base * 8);
19
- };
20
11
  const StyledTabs = styled.div.attrs({
21
12
  'data-garden-id': COMPONENT_ID,
22
- 'data-garden-version': '9.0.0-next.9'
13
+ 'data-garden-version': '9.1.0'
23
14
  }).withConfig({
24
15
  displayName: "StyledTabs",
25
16
  componentId: "sc-1qaor65-0"
26
- })(["display:block;overflow:hidden;direction:", ";", ";", ";"], props => props.theme.rtl && 'rtl', props => props.isVertical && verticalStyling(props), props => retrieveComponentStyles(COMPONENT_ID, props));
27
- StyledTabs.defaultProps = {
28
- theme: DEFAULT_THEME
29
- };
17
+ })(["display:", ";overflow:hidden;direction:", ";", ";"], props => props.$isVertical ? 'table' : 'block', props => props.theme.rtl && 'rtl', props => retrieveComponentStyles(COMPONENT_ID, props));
30
18
 
31
19
  export { StyledTabs };
@@ -8,7 +8,7 @@ import { Children, isValidElement } from 'react';
8
8
 
9
9
  const toTabs = children => Children.toArray(children).reduce((_items, child) => {
10
10
  const retVal = _items;
11
- if ( isValidElement(child)) {
11
+ if (isValidElement(child)) {
12
12
  if ('item' in child.props) {
13
13
  const props = child.props;
14
14
  retVal.push({
package/dist/index.cjs.js CHANGED
@@ -22,13 +22,25 @@ var PropTypes__default = /*#__PURE__*/_interopDefault(PropTypes);
22
22
  var styled__default = /*#__PURE__*/_interopDefault(styled);
23
23
 
24
24
  const COMPONENT_ID$3 = 'tabs.tab';
25
- const colorStyles = _ref => {
25
+ const colorStyles$1 = _ref => {
26
26
  let {
27
27
  theme,
28
- isSelected
28
+ $isSelected
29
29
  } = _ref;
30
- const selectedColor = reactTheming.getColorV8('primaryHue', 600, theme);
31
- return styled.css(["border-color:", ";color:", ";&:hover{color:", ";}", " &:active{border-color:currentcolor;color:", ";}&[aria-disabled='true']{border-color:transparent;color:", ";}"], isSelected && 'currentcolor !important', isSelected ? selectedColor : 'inherit', selectedColor, reactTheming.focusStyles({
30
+ const borderColor = $isSelected ? reactTheming.getColor({
31
+ theme,
32
+ variable: 'border.primaryEmphasis'
33
+ }) : 'transparent';
34
+ const selectedColor = reactTheming.getColor({
35
+ theme,
36
+ variable: 'foreground.primary'
37
+ });
38
+ const foregroundColor = $isSelected ? selectedColor : 'inherit';
39
+ const disabledColor = reactTheming.getColor({
40
+ theme,
41
+ variable: 'foreground.disabled'
42
+ });
43
+ return styled.css(["border-color:", ";color:", ";&:hover{color:", ";}", " &:active{border-color:currentcolor;color:", ";}&[aria-disabled='true']{border-color:transparent;color:", ";}"], borderColor, foregroundColor, selectedColor, reactTheming.focusStyles({
32
44
  theme,
33
45
  inset: true,
34
46
  spacerWidth: null,
@@ -37,69 +49,100 @@ const colorStyles = _ref => {
37
49
  styles: {
38
50
  color: selectedColor
39
51
  }
40
- }), selectedColor, props => reactTheming.getColorV8('neutralHue', 400, props.theme));
52
+ }), selectedColor, disabledColor);
41
53
  };
42
- const sizeStyles = _ref2 => {
54
+ const sizeStyles$2 = _ref2 => {
43
55
  let {
44
- theme
56
+ theme,
57
+ $isVertical
45
58
  } = _ref2;
46
- const paddingTop = theme.space.base * 2.5;
47
- const paddingHorizontal = theme.space.base * 7;
48
- const paddingBottom = paddingTop - polished.stripUnit(theme.borderWidths.md) - polished.stripUnit(theme.borderWidths.sm);
49
- return styled.css(["padding:", "px ", "px ", "px;"], paddingTop, paddingHorizontal, paddingBottom);
59
+ const borderWidth = theme.borderWidths.md;
60
+ const focusHeight = `calc(100% - ${theme.space.base * ($isVertical ? 2 : 4)}px);`;
61
+ let marginBottom;
62
+ let padding;
63
+ if ($isVertical) {
64
+ marginBottom = `${theme.space.base * 5}px`;
65
+ padding = `${theme.space.base}px ${theme.space.base * 2}px`;
66
+ } else {
67
+ const paddingTop = theme.space.base * 2.5;
68
+ const paddingHorizontal = theme.space.base * 7;
69
+ const paddingBottom = paddingTop - polished.stripUnit(theme.borderWidths.md) - polished.stripUnit(theme.borderWidths.sm);
70
+ padding = `${paddingTop}px ${paddingHorizontal}px ${paddingBottom}px`;
71
+ }
72
+ return styled.css(["margin-bottom:", ";border-width:", ";padding:", ";&:focus-visible::before,&[data-garden-focus-visible]::before{height:", ";}&:last-of-type{margin-bottom:0;}"], marginBottom, borderWidth, padding, focusHeight);
50
73
  };
51
74
  const StyledTab = styled__default.default.div.attrs({
52
75
  'data-garden-id': COMPONENT_ID$3,
53
- 'data-garden-version': '9.0.0-next.9'
76
+ 'data-garden-version': '9.1.0'
54
77
  }).withConfig({
55
78
  displayName: "StyledTab",
56
79
  componentId: "sc-x2pbow-0"
57
- })(["display:inline-block;position:relative;transition:color 0.25s ease-in-out;border-bottom:", " transparent;border-width:", ";cursor:pointer;overflow:hidden;vertical-align:top;user-select:none;text-align:center;text-decoration:none;text-overflow:ellipsis;", " ", " &:focus{text-decoration:none;}&::before{transition:box-shadow 0.1s ease-in-out;content:'';}&:focus-visible::before{position:absolute;top:", "px;right:", "px;left:", "px;border-radius:", ";height:", "px;pointer-events:none;}&:active::before{box-shadow:none;}&[aria-disabled='true']{cursor:default;}", ";"], props => props.theme.borderStyles.solid, props => props.theme.borderWidths.md, sizeStyles, colorStyles, props => props.theme.space.base * 2.5, props => props.theme.space.base * 6, props => props.theme.space.base * 6, props => props.theme.borderRadii.md, props => props.theme.space.base * 5, props => reactTheming.retrieveComponentStyles(COMPONENT_ID$3, props));
58
- StyledTab.defaultProps = {
59
- theme: reactTheming.DEFAULT_THEME
60
- };
80
+ })(["display:", ";position:relative;transition:color 0.25s ease-in-out;border-bottom:", ";border-", ":", ";cursor:pointer;overflow:hidden;vertical-align:top;user-select:none;text-align:", ";text-decoration:none;text-overflow:ellipsis;", ";", ";&:focus{text-decoration:none;}&::before{transition:box-shadow 0.1s ease-in-out;content:'';}&:focus-visible::before{position:absolute;top:", "px;right:", "px;left:", "px;border-radius:", ";pointer-events:none;}&:active::before{box-shadow:none;}&[aria-disabled='true']{cursor:default;}", ";"], props => props.$isVertical ? 'block' : 'inline-block', props => props.$isVertical ? undefined : props.theme.borderStyles.solid, props => props.theme.rtl ? 'right' : 'left', props => props.$isVertical ? props.theme.borderStyles.solid : undefined, props => {
81
+ if (props.$isVertical) {
82
+ return props.theme.rtl ? 'right' : 'left';
83
+ }
84
+ return 'center';
85
+ }, sizeStyles$2, colorStyles$1, props => props.theme.space.base * (props.$isVertical ? 1 : 2.5), props => props.theme.space.base * (props.$isVertical ? 1 : 6), props => props.theme.space.base * (props.$isVertical ? 1 : 6), props => props.theme.borderRadii.md, props => reactTheming.retrieveComponentStyles(COMPONENT_ID$3, props));
61
86
 
62
87
  const COMPONENT_ID$2 = 'tabs.tablist';
88
+ const colorStyles = _ref => {
89
+ let {
90
+ theme
91
+ } = _ref;
92
+ const borderColor = reactTheming.getColor({
93
+ theme,
94
+ variable: 'border.default'
95
+ });
96
+ const foregroundColor = reactTheming.getColor({
97
+ theme,
98
+ variable: 'foreground.default'
99
+ });
100
+ return styled.css(["transition:border-color 0.25s ease-in-out;color-scheme:only ", ";border-bottom-color:", ";color:", ";"], p => p.theme.colors.base, borderColor, foregroundColor);
101
+ };
102
+ const sizeStyles$1 = _ref2 => {
103
+ let {
104
+ theme,
105
+ $isVertical
106
+ } = _ref2;
107
+ const marginBottom = $isVertical ? 0 : `${theme.space.base * 5}px`;
108
+ const borderBottom = $isVertical ? undefined : theme.borderWidths.sm;
109
+ const fontSize = theme.fontSizes.md;
110
+ const lineHeight = reactTheming.getLineHeight(theme.space.base * 5, fontSize);
111
+ return styled.css(["margin-top:0;margin-bottom:", ";border-bottom-width:", ";padding:0;line-height:", ";font-size:", ";"], marginBottom, borderBottom, lineHeight, fontSize);
112
+ };
63
113
  const StyledTabList = styled__default.default.div.attrs({
64
114
  'data-garden-id': COMPONENT_ID$2,
65
- 'data-garden-version': '9.0.0-next.9'
115
+ 'data-garden-version': '9.1.0'
66
116
  }).withConfig({
67
117
  displayName: "StyledTabList",
68
118
  componentId: "sc-wa5aaj-0"
69
- })(["display:block;margin-top:0;margin-bottom:", "px;border-bottom:", " ", " ", ";padding:0;line-height:", "px;white-space:nowrap;color:", ";font-size:", ";", ";"], props => props.theme.space.base * 5, props => props.theme.borderWidths.sm, props => props.theme.borderStyles.solid, props => reactTheming.getColorV8('neutralHue', 300, props.theme), props => props.theme.space.base * 5, props => reactTheming.getColorV8('neutralHue', 600, props.theme), props => props.theme.fontSizes.md, props => reactTheming.retrieveComponentStyles(COMPONENT_ID$2, props));
70
- StyledTabList.defaultProps = {
71
- theme: reactTheming.DEFAULT_THEME
72
- };
119
+ })(["display:", ";border-bottom:", ";vertical-align:", ";white-space:nowrap;", ";", ";", ";"], props => props.$isVertical ? 'table-cell' : 'block', props => props.$isVertical ? 'none' : props.theme.borderStyles.solid, props => props.$isVertical ? 'top' : undefined, sizeStyles$1, colorStyles, props => reactTheming.retrieveComponentStyles(COMPONENT_ID$2, props));
73
120
 
74
121
  const COMPONENT_ID$1 = 'tabs.tabpanel';
122
+ const sizeStyles = _ref => {
123
+ let {
124
+ theme,
125
+ $isVertical
126
+ } = _ref;
127
+ const margin = $isVertical ? `${theme.space.base * 8}px` : undefined;
128
+ return styled.css(["margin-", ":", ";"], theme.rtl ? 'right' : 'left', margin);
129
+ };
75
130
  const StyledTabPanel = styled__default.default.div.attrs({
76
131
  'data-garden-id': COMPONENT_ID$1,
77
- 'data-garden-version': '9.0.0-next.9'
132
+ 'data-garden-version': '9.1.0'
78
133
  }).withConfig({
79
134
  displayName: "StyledTabPanel",
80
135
  componentId: "sc-7lhrmp-0"
81
- })(["display:block;&[aria-hidden='true']{display:none;}", ";"], props => reactTheming.retrieveComponentStyles(COMPONENT_ID$1, props));
82
- StyledTabPanel.defaultProps = {
83
- theme: reactTheming.DEFAULT_THEME
84
- };
136
+ })(["display:block;vertical-align:", ";color-scheme:only ", ";", ";&[aria-hidden='true']{display:none;}", ";"], props => props.$isVertical && 'top', p => p.theme.colors.base, sizeStyles, props => reactTheming.retrieveComponentStyles(COMPONENT_ID$1, props));
85
137
 
86
138
  const COMPONENT_ID = 'tabs.tabs';
87
- const verticalStyling = _ref => {
88
- let {
89
- theme
90
- } = _ref;
91
- return styled.css(["display:table;", "{display:table-cell;margin-bottom:0;border-bottom:none;vertical-align:top;}", "{display:block;margin-bottom:", "px;margin-left:", ";border-left:", ";border-bottom-style:none;border-", "-style:", ";border-", "-color:transparent;padding:", "px ", "px;text-align:", ";&:last-of-type{margin-bottom:0;}&:focus-visible::before{top:", "px;right:", "px;left:", "px;}}", "{margin-", ":", "px;vertical-align:top;}"], StyledTabList, StyledTab, theme.space.base * 5, theme.rtl && '0', theme.rtl && '0', theme.rtl ? 'right' : 'left', theme.borderStyles.solid, theme.rtl ? 'right' : 'left', theme.space.base, theme.space.base * 2, theme.rtl ? 'right' : 'left', theme.space.base, theme.space.base, theme.space.base, StyledTabPanel, theme.rtl ? 'right' : 'left', theme.space.base * 8);
92
- };
93
139
  const StyledTabs = styled__default.default.div.attrs({
94
140
  'data-garden-id': COMPONENT_ID,
95
- 'data-garden-version': '9.0.0-next.9'
141
+ 'data-garden-version': '9.1.0'
96
142
  }).withConfig({
97
143
  displayName: "StyledTabs",
98
144
  componentId: "sc-1qaor65-0"
99
- })(["display:block;overflow:hidden;direction:", ";", ";", ";"], props => props.theme.rtl && 'rtl', props => props.isVertical && verticalStyling(props), props => reactTheming.retrieveComponentStyles(COMPONENT_ID, props));
100
- StyledTabs.defaultProps = {
101
- theme: reactTheming.DEFAULT_THEME
102
- };
145
+ })(["display:", ";overflow:hidden;direction:", ";", ";"], props => props.$isVertical ? 'table' : 'block', props => props.theme.rtl && 'rtl', props => reactTheming.retrieveComponentStyles(COMPONENT_ID, props));
103
146
 
104
147
  const TabsContext = React.createContext(undefined);
105
148
  const useTabsContext = () => {
@@ -117,7 +160,8 @@ const Tab = React__default.default.forwardRef((_ref, ref) => {
117
160
  return React__default.default.createElement(StyledTab, Object.assign({
118
161
  role: "tab",
119
162
  "aria-disabled": disabled,
120
- ref: ref
163
+ ref: ref,
164
+ $isVertical: tabsPropGetters?.isVertical
121
165
  }, otherProps));
122
166
  }
123
167
  const {
@@ -127,12 +171,13 @@ const Tab = React__default.default.forwardRef((_ref, ref) => {
127
171
  value: item
128
172
  });
129
173
  return React__default.default.createElement(StyledTab, Object.assign({
130
- isSelected: item === tabsPropGetters.selectedValue
174
+ $isSelected: item === tabsPropGetters.selectedValue,
175
+ $isVertical: tabsPropGetters.isVertical
131
176
  }, tabProps, otherProps, {
132
177
  ref: reactMergeRefs.mergeRefs([tabRef, ref])
133
178
  }));
134
179
  });
135
- Tab.displayName = 'Tab';
180
+ Tab.displayName = 'Tabs.Tab';
136
181
  Tab.propTypes = {
137
182
  disabled: PropTypes__default.default.bool,
138
183
  item: PropTypes__default.default.any
@@ -146,11 +191,13 @@ const TabList = React__default.default.forwardRef((props, ref) => {
146
191
  }, props));
147
192
  }
148
193
  const tabListProps = tabsPropGetters.getTabListProps();
149
- return React__default.default.createElement(StyledTabList, Object.assign({}, tabListProps, props, {
194
+ return React__default.default.createElement(StyledTabList, Object.assign({
195
+ $isVertical: tabsPropGetters.isVertical
196
+ }, tabListProps, props, {
150
197
  ref: ref
151
198
  }));
152
199
  });
153
- TabList.displayName = 'TabList';
200
+ TabList.displayName = 'Tabs.TabList';
154
201
 
155
202
  const TabPanel = React__default.default.forwardRef((_ref, ref) => {
156
203
  let {
@@ -167,19 +214,20 @@ const TabPanel = React__default.default.forwardRef((_ref, ref) => {
167
214
  value: item
168
215
  });
169
216
  return React__default.default.createElement(StyledTabPanel, Object.assign({
170
- "aria-hidden": tabsPropGetters.selectedValue !== item
217
+ "aria-hidden": tabsPropGetters.selectedValue !== item,
218
+ $isVertical: tabsPropGetters.isVertical
171
219
  }, tabPanelProps, otherProps, {
172
220
  ref: ref
173
221
  }));
174
222
  });
175
- TabPanel.displayName = 'TabPanel';
223
+ TabPanel.displayName = 'Tabs.TabPanel';
176
224
  TabPanel.propTypes = {
177
225
  item: PropTypes__default.default.any
178
226
  };
179
227
 
180
228
  const toTabs = children => React.Children.toArray(children).reduce((_items, child) => {
181
229
  const retVal = _items;
182
- if ( React.isValidElement(child)) {
230
+ if (React.isValidElement(child)) {
183
231
  if ('item' in child.props) {
184
232
  const props = child.props;
185
233
  retVal.push({
@@ -220,10 +268,14 @@ const TabsComponent = React.forwardRef((_ref, ref) => {
220
268
  }
221
269
  }
222
270
  });
271
+ const contextValue = React.useMemo(() => ({
272
+ isVertical,
273
+ ...tabsContextValue
274
+ }), [isVertical, tabsContextValue]);
223
275
  return React__default.default.createElement(TabsContext.Provider, {
224
- value: tabsContextValue
276
+ value: contextValue
225
277
  }, React__default.default.createElement(StyledTabs, Object.assign({
226
- isVertical: isVertical
278
+ $isVertical: isVertical
227
279
  }, otherProps, {
228
280
  ref: ref
229
281
  }), children));
@@ -13,7 +13,7 @@ export declare const TabsComponent: React.ForwardRefExoticComponent<ITabsProps &
13
13
  /**
14
14
  * @extends HTMLAttributes<HTMLDivElement>
15
15
  */
16
- export declare const Tabs: React.ForwardRefExoticComponent<ITabsProps & React.RefAttributes<HTMLDivElement>> & {
16
+ export declare const Tabs: typeof TabsComponent & {
17
17
  Tab: typeof Tab;
18
18
  TabList: typeof TabList;
19
19
  TabPanel: typeof TabPanel;
@@ -6,12 +6,11 @@
6
6
  */
7
7
  import { DefaultTheme } from 'styled-components';
8
8
  interface IStyledTabProps {
9
- isSelected?: boolean;
9
+ $isSelected?: boolean;
10
+ $isVertical?: boolean;
10
11
  }
11
- /**
12
- * 1. Text truncation (requires `max-width`).
13
- * 2. Overflow compensation.
14
- * 3. Override default anchor styling
15
- */
16
- export declare const StyledTab: import("styled-components").StyledComponent<"div", DefaultTheme, IStyledTabProps, never>;
12
+ export declare const StyledTab: import("styled-components").StyledComponent<"div", DefaultTheme, {
13
+ 'data-garden-id': string;
14
+ 'data-garden-version': string;
15
+ } & IStyledTabProps, "data-garden-id" | "data-garden-version">;
17
16
  export {};
@@ -4,10 +4,12 @@
4
4
  * Use of this source code is governed under the Apache License, Version 2.0
5
5
  * found at http://www.apache.org/licenses/LICENSE-2.0.
6
6
  */
7
- /**
8
- * 1. List element reset.
9
- */
10
- export declare const StyledTabList: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {
7
+ import { DefaultTheme } from 'styled-components';
8
+ interface IStyledTabListProps {
9
+ $isVertical?: boolean;
10
+ }
11
+ export declare const StyledTabList: import("styled-components").StyledComponent<"div", DefaultTheme, {
11
12
  'data-garden-id': string;
12
13
  'data-garden-version': string;
13
- }, "data-garden-id" | "data-garden-version">;
14
+ } & IStyledTabListProps, "data-garden-id" | "data-garden-version">;
15
+ export {};
@@ -4,10 +4,12 @@
4
4
  * Use of this source code is governed under the Apache License, Version 2.0
5
5
  * found at http://www.apache.org/licenses/LICENSE-2.0.
6
6
  */
7
- /**
8
- * Accepts all `<div>` props
9
- */
10
- export declare const StyledTabPanel: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {
7
+ import { DefaultTheme } from 'styled-components';
8
+ interface IStyledTabPanelProps {
9
+ $isVertical?: boolean;
10
+ }
11
+ export declare const StyledTabPanel: import("styled-components").StyledComponent<"div", DefaultTheme, {
11
12
  'data-garden-id': string;
12
13
  'data-garden-version': string;
13
- }, "data-garden-id" | "data-garden-version">;
14
+ } & IStyledTabPanelProps, "data-garden-id" | "data-garden-version">;
15
+ export {};
@@ -4,15 +4,11 @@
4
4
  * Use of this source code is governed under the Apache License, Version 2.0
5
5
  * found at http://www.apache.org/licenses/LICENSE-2.0.
6
6
  */
7
- import { DefaultTheme } from 'styled-components';
8
7
  interface IStyledTabsProps {
9
- /**
10
- * Displays vertical TabList styling
11
- */
12
- isVertical?: boolean;
8
+ $isVertical?: boolean;
13
9
  }
14
10
  /**
15
11
  * Accepts all `<div>` props
16
12
  */
17
- export declare const StyledTabs: import("styled-components").StyledComponent<"div", DefaultTheme, IStyledTabsProps, never>;
13
+ export declare const StyledTabs: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, IStyledTabsProps, never>;
18
14
  export {};
@@ -4,7 +4,10 @@
4
4
  * Use of this source code is governed under the Apache License, Version 2.0
5
5
  * found at http://www.apache.org/licenses/LICENSE-2.0.
6
6
  */
7
- /// <reference types="react" />
8
7
  import { IUseTabsReturnValue } from '@zendeskgarden/container-tabs';
9
- export declare const TabsContext: import("react").Context<IUseTabsReturnValue<any> | undefined>;
10
- export declare const useTabsContext: () => IUseTabsReturnValue<any> | undefined;
8
+ interface ITabsContext extends IUseTabsReturnValue<any> {
9
+ isVertical?: boolean;
10
+ }
11
+ export declare const TabsContext: import("react").Context<ITabsContext | undefined>;
12
+ export declare const useTabsContext: () => ITabsContext | undefined;
13
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zendeskgarden/react-tabs",
3
- "version": "9.0.0-next.9",
3
+ "version": "9.1.0",
4
4
  "description": "Components and render prop containers relating to the Garden Design System.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Zendesk Garden <garden@zendesk.com>",
@@ -21,20 +21,20 @@
21
21
  "sideEffects": false,
22
22
  "types": "dist/typings/index.d.ts",
23
23
  "dependencies": {
24
- "@zendeskgarden/container-tabs": "^2.0.1",
24
+ "@zendeskgarden/container-tabs": "^2.0.10",
25
25
  "@zendeskgarden/container-utilities": "^2.0.0",
26
- "polished": "^4.0.0",
26
+ "polished": "^4.3.1",
27
27
  "prop-types": "^15.5.7",
28
28
  "react-merge-refs": "^2.0.0"
29
29
  },
30
30
  "peerDependencies": {
31
31
  "@zendeskgarden/react-theming": ">=9.0.0-next",
32
- "react": ">=16.8.0",
33
- "react-dom": ">=16.8.0",
32
+ "react": "^16.8.0 || ^17.0.0 || ^18.0.0",
33
+ "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0",
34
34
  "styled-components": "^5.3.1"
35
35
  },
36
36
  "devDependencies": {
37
- "@zendeskgarden/react-theming": "^9.0.0-next.9"
37
+ "@zendeskgarden/react-theming": "^9.1.0"
38
38
  },
39
39
  "keywords": [
40
40
  "components",
@@ -46,5 +46,5 @@
46
46
  "access": "public"
47
47
  },
48
48
  "zendeskgarden:src": "src/index.ts",
49
- "gitHead": "771281b562d376a6aee04b0cd71dd888b3ae4a1d"
49
+ "gitHead": "a2842d18615ad057d75988fde4df5a0c79d2714e"
50
50
  }