@zendeskgarden/react-tabs 8.75.1 → 8.76.1

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.
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Copyright Zendesk, Inc.
3
+ *
4
+ * Use of this source code is governed under the Apache License, Version 2.0
5
+ * found at http://www.apache.org/licenses/LICENSE-2.0.
6
+ */
7
+ import React from 'react';
8
+ import PropTypes from 'prop-types';
9
+ import mergeRefs from 'react-merge-refs';
10
+ import { StyledTab } from '../styled/StyledTab.js';
11
+ import '../styled/StyledTabList.js';
12
+ import '../styled/StyledTabPanel.js';
13
+ import '../styled/StyledTabs.js';
14
+ import { useTabsContext } from '../utils/useTabsContext.js';
15
+
16
+ const Tab = React.forwardRef((_ref, ref) => {
17
+ let {
18
+ disabled,
19
+ item,
20
+ ...otherProps
21
+ } = _ref;
22
+ const tabsPropGetters = useTabsContext();
23
+ if (disabled || !tabsPropGetters) {
24
+ return React.createElement(StyledTab, Object.assign({
25
+ role: "tab",
26
+ "aria-disabled": disabled,
27
+ ref: ref
28
+ }, otherProps));
29
+ }
30
+ const {
31
+ ref: tabRef,
32
+ ...tabProps
33
+ } = tabsPropGetters.getTabProps({
34
+ value: item
35
+ });
36
+ return React.createElement(StyledTab, Object.assign({
37
+ isSelected: item === tabsPropGetters.selectedValue
38
+ }, tabProps, otherProps, {
39
+ ref: mergeRefs([tabRef, ref])
40
+ }));
41
+ });
42
+ Tab.displayName = 'Tab';
43
+ Tab.propTypes = {
44
+ disabled: PropTypes.bool,
45
+ item: PropTypes.any
46
+ };
47
+
48
+ export { Tab };
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Copyright Zendesk, Inc.
3
+ *
4
+ * Use of this source code is governed under the Apache License, Version 2.0
5
+ * found at http://www.apache.org/licenses/LICENSE-2.0.
6
+ */
7
+ import React from 'react';
8
+ import '../styled/StyledTab.js';
9
+ import { StyledTabList } from '../styled/StyledTabList.js';
10
+ import '../styled/StyledTabPanel.js';
11
+ import '../styled/StyledTabs.js';
12
+ import { useTabsContext } from '../utils/useTabsContext.js';
13
+
14
+ const TabList = React.forwardRef((props, ref) => {
15
+ const tabsPropGetters = useTabsContext();
16
+ if (!tabsPropGetters) {
17
+ return React.createElement(StyledTabList, Object.assign({
18
+ ref: ref
19
+ }, props));
20
+ }
21
+ const tabListProps = tabsPropGetters.getTabListProps();
22
+ return React.createElement(StyledTabList, Object.assign({}, tabListProps, props, {
23
+ ref: ref
24
+ }));
25
+ });
26
+ TabList.displayName = 'TabList';
27
+
28
+ export { TabList };
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Copyright Zendesk, Inc.
3
+ *
4
+ * Use of this source code is governed under the Apache License, Version 2.0
5
+ * found at http://www.apache.org/licenses/LICENSE-2.0.
6
+ */
7
+ import React from 'react';
8
+ import PropTypes from 'prop-types';
9
+ import '../styled/StyledTab.js';
10
+ import '../styled/StyledTabList.js';
11
+ import { StyledTabPanel } from '../styled/StyledTabPanel.js';
12
+ import '../styled/StyledTabs.js';
13
+ import { useTabsContext } from '../utils/useTabsContext.js';
14
+
15
+ const TabPanel = React.forwardRef((_ref, ref) => {
16
+ let {
17
+ item,
18
+ ...otherProps
19
+ } = _ref;
20
+ const tabsPropGetters = useTabsContext();
21
+ if (!tabsPropGetters) {
22
+ return React.createElement(StyledTabPanel, Object.assign({
23
+ ref: ref
24
+ }, otherProps));
25
+ }
26
+ const tabPanelProps = tabsPropGetters.getTabPanelProps({
27
+ value: item
28
+ });
29
+ return React.createElement(StyledTabPanel, Object.assign({
30
+ "aria-hidden": tabsPropGetters.selectedValue !== item
31
+ }, tabPanelProps, otherProps, {
32
+ ref: ref
33
+ }));
34
+ });
35
+ TabPanel.displayName = 'TabPanel';
36
+ TabPanel.propTypes = {
37
+ item: PropTypes.any
38
+ };
39
+
40
+ export { TabPanel };
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Copyright Zendesk, Inc.
3
+ *
4
+ * Use of this source code is governed under the Apache License, Version 2.0
5
+ * found at http://www.apache.org/licenses/LICENSE-2.0.
6
+ */
7
+ import React, { forwardRef, useContext, useState, useMemo } from 'react';
8
+ import PropTypes from 'prop-types';
9
+ import { ThemeContext } from 'styled-components';
10
+ import { DEFAULT_THEME } from '@zendeskgarden/react-theming';
11
+ import { useTabs } from '@zendeskgarden/container-tabs';
12
+ import { getControlledValue } from '@zendeskgarden/container-utilities';
13
+ import { toTabs } from '../utils/toTabs.js';
14
+ import { TabsContext } from '../utils/useTabsContext.js';
15
+ import { StyledTabs } from '../styled/StyledTabs.js';
16
+
17
+ const Tabs = forwardRef((_ref, ref) => {
18
+ let {
19
+ isVertical,
20
+ children,
21
+ onChange,
22
+ selectedItem: controlledSelectedItem,
23
+ ...otherProps
24
+ } = _ref;
25
+ const theme = useContext(ThemeContext) || DEFAULT_THEME;
26
+ const [internalSelectedItem, setInternalSelectedItem] = useState();
27
+ const selectedItem = getControlledValue(controlledSelectedItem, internalSelectedItem);
28
+ const tabs = useMemo(() => toTabs(children), [children]);
29
+ const tabsContextValue = useTabs({
30
+ tabs,
31
+ rtl: theme.rtl,
32
+ orientation: isVertical ? 'vertical' : 'horizontal',
33
+ selectedValue: selectedItem,
34
+ defaultSelectedValue: tabs.find(tab => !tab.disabled)?.value,
35
+ onSelect: item => {
36
+ if (onChange) {
37
+ onChange(item);
38
+ } else {
39
+ setInternalSelectedItem(item);
40
+ }
41
+ }
42
+ });
43
+ return React.createElement(TabsContext.Provider, {
44
+ value: tabsContextValue
45
+ }, React.createElement(StyledTabs, Object.assign({
46
+ isVertical: isVertical
47
+ }, otherProps, {
48
+ ref: ref
49
+ }), children));
50
+ });
51
+ Tabs.propTypes = {
52
+ isVertical: PropTypes.bool,
53
+ selectedItem: PropTypes.any,
54
+ onChange: PropTypes.func
55
+ };
56
+ Tabs.defaultProps = {
57
+ isVertical: false
58
+ };
59
+ Tabs.displayName = 'Tabs';
60
+
61
+ export { Tabs };
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Copyright Zendesk, Inc.
3
+ *
4
+ * Use of this source code is governed under the Apache License, Version 2.0
5
+ * found at http://www.apache.org/licenses/LICENSE-2.0.
6
+ */
7
+ export { Tab } from './elements/Tab.js';
8
+ export { TabList } from './elements/TabList.js';
9
+ export { TabPanel } from './elements/TabPanel.js';
10
+ export { Tabs } from './elements/Tabs.js';
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Copyright Zendesk, Inc.
3
+ *
4
+ * Use of this source code is governed under the Apache License, Version 2.0
5
+ * found at http://www.apache.org/licenses/LICENSE-2.0.
6
+ */
7
+ import styled, { css } from 'styled-components';
8
+ import { retrieveComponentStyles, DEFAULT_THEME, getColorV8, focusStyles } from '@zendeskgarden/react-theming';
9
+ import { stripUnit } from 'polished';
10
+
11
+ const COMPONENT_ID = 'tabs.tab';
12
+ const colorStyles = _ref => {
13
+ let {
14
+ theme,
15
+ isSelected
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({
19
+ theme,
20
+ inset: true,
21
+ spacerWidth: null,
22
+ shadowWidth: 'sm',
23
+ selector: '&:focus-visible::before, &[data-garden-focus-visible="true"]::before',
24
+ styles: {
25
+ color: selectedColor
26
+ }
27
+ }), selectedColor, props => getColorV8('neutralHue', 400, props.theme));
28
+ };
29
+ const sizeStyles = _ref2 => {
30
+ let {
31
+ theme
32
+ } = _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);
37
+ };
38
+ const StyledTab = styled.div.attrs({
39
+ 'data-garden-id': COMPONENT_ID,
40
+ 'data-garden-version': '8.76.1'
41
+ }).withConfig({
42
+ displayName: "StyledTab",
43
+ 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,&[data-garden-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
+ };
48
+
49
+ export { StyledTab };
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Copyright Zendesk, Inc.
3
+ *
4
+ * Use of this source code is governed under the Apache License, Version 2.0
5
+ * found at http://www.apache.org/licenses/LICENSE-2.0.
6
+ */
7
+ import styled from 'styled-components';
8
+ import { getColorV8, retrieveComponentStyles, DEFAULT_THEME } from '@zendeskgarden/react-theming';
9
+
10
+ const COMPONENT_ID = 'tabs.tablist';
11
+ const StyledTabList = styled.div.attrs({
12
+ 'data-garden-id': COMPONENT_ID,
13
+ 'data-garden-version': '8.76.1'
14
+ }).withConfig({
15
+ displayName: "StyledTabList",
16
+ 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
+ };
21
+
22
+ export { StyledTabList };
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Copyright Zendesk, Inc.
3
+ *
4
+ * Use of this source code is governed under the Apache License, Version 2.0
5
+ * found at http://www.apache.org/licenses/LICENSE-2.0.
6
+ */
7
+ import styled from 'styled-components';
8
+ import { retrieveComponentStyles, DEFAULT_THEME } from '@zendeskgarden/react-theming';
9
+
10
+ const COMPONENT_ID = 'tabs.tabpanel';
11
+ const StyledTabPanel = styled.div.attrs({
12
+ 'data-garden-id': COMPONENT_ID,
13
+ 'data-garden-version': '8.76.1'
14
+ }).withConfig({
15
+ displayName: "StyledTabPanel",
16
+ 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
+ };
21
+
22
+ export { StyledTabPanel };
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Copyright Zendesk, Inc.
3
+ *
4
+ * Use of this source code is governed under the Apache License, Version 2.0
5
+ * found at http://www.apache.org/licenses/LICENSE-2.0.
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';
12
+
13
+ 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,&[data-garden-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
+ const StyledTabs = styled.div.attrs({
21
+ 'data-garden-id': COMPONENT_ID,
22
+ 'data-garden-version': '8.76.1'
23
+ }).withConfig({
24
+ displayName: "StyledTabs",
25
+ 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
+ };
30
+
31
+ export { StyledTabs };
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Copyright Zendesk, Inc.
3
+ *
4
+ * Use of this source code is governed under the Apache License, Version 2.0
5
+ * found at http://www.apache.org/licenses/LICENSE-2.0.
6
+ */
7
+ import { Children, isValidElement } from 'react';
8
+
9
+ const toTabs = children => Children.toArray(children).reduce((_items, child) => {
10
+ const retVal = _items;
11
+ if ( isValidElement(child)) {
12
+ if ('item' in child.props) {
13
+ const props = child.props;
14
+ retVal.push({
15
+ value: props.item,
16
+ disabled: props.disabled
17
+ });
18
+ } else {
19
+ const childItems = toTabs(child.props.children);
20
+ retVal.push(...childItems);
21
+ }
22
+ }
23
+ return retVal;
24
+ }, []);
25
+
26
+ export { toTabs };
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Copyright Zendesk, Inc.
3
+ *
4
+ * Use of this source code is governed under the Apache License, Version 2.0
5
+ * found at http://www.apache.org/licenses/LICENSE-2.0.
6
+ */
7
+ import { createContext, useContext } from 'react';
8
+
9
+ const TabsContext = createContext(undefined);
10
+ const useTabsContext = () => {
11
+ return useContext(TabsContext);
12
+ };
13
+
14
+ export { TabsContext, useTabsContext };
package/dist/index.cjs.js CHANGED
@@ -1,10 +1,9 @@
1
1
  /**
2
- * Copyright Zendesk, Inc.
3
- *
4
- * Use of this source code is governed under the Apache License, Version 2.0
5
- * found at http://www.apache.org/licenses/LICENSE-2.0.
6
- */
7
-
2
+ * Copyright Zendesk, Inc.
3
+ *
4
+ * Use of this source code is governed under the Apache License, Version 2.0
5
+ * found at http://www.apache.org/licenses/LICENSE-2.0.
6
+ */
8
7
  'use strict';
9
8
 
10
9
  var React = require('react');
@@ -23,21 +22,6 @@ var PropTypes__default = /*#__PURE__*/_interopDefault(PropTypes);
23
22
  var mergeRefs__default = /*#__PURE__*/_interopDefault(mergeRefs);
24
23
  var styled__default = /*#__PURE__*/_interopDefault(styled);
25
24
 
26
- function _extends() {
27
- _extends = Object.assign ? Object.assign.bind() : function (target) {
28
- for (var i = 1; i < arguments.length; i++) {
29
- var source = arguments[i];
30
- for (var key in source) {
31
- if (Object.prototype.hasOwnProperty.call(source, key)) {
32
- target[key] = source[key];
33
- }
34
- }
35
- }
36
- return target;
37
- };
38
- return _extends.apply(this, arguments);
39
- }
40
-
41
25
  const COMPONENT_ID$3 = 'tabs.tab';
42
26
  const colorStyles = _ref => {
43
27
  let {
@@ -67,7 +51,7 @@ const sizeStyles = _ref2 => {
67
51
  };
68
52
  const StyledTab = styled__default.default.div.attrs({
69
53
  'data-garden-id': COMPONENT_ID$3,
70
- 'data-garden-version': '8.75.1'
54
+ 'data-garden-version': '8.76.1'
71
55
  }).withConfig({
72
56
  displayName: "StyledTab",
73
57
  componentId: "sc-x2pbow-0"
@@ -79,7 +63,7 @@ StyledTab.defaultProps = {
79
63
  const COMPONENT_ID$2 = 'tabs.tablist';
80
64
  const StyledTabList = styled__default.default.div.attrs({
81
65
  'data-garden-id': COMPONENT_ID$2,
82
- 'data-garden-version': '8.75.1'
66
+ 'data-garden-version': '8.76.1'
83
67
  }).withConfig({
84
68
  displayName: "StyledTabList",
85
69
  componentId: "sc-wa5aaj-0"
@@ -91,7 +75,7 @@ StyledTabList.defaultProps = {
91
75
  const COMPONENT_ID$1 = 'tabs.tabpanel';
92
76
  const StyledTabPanel = styled__default.default.div.attrs({
93
77
  'data-garden-id': COMPONENT_ID$1,
94
- 'data-garden-version': '8.75.1'
78
+ 'data-garden-version': '8.76.1'
95
79
  }).withConfig({
96
80
  displayName: "StyledTabPanel",
97
81
  componentId: "sc-7lhrmp-0"
@@ -109,7 +93,7 @@ const verticalStyling = _ref => {
109
93
  };
110
94
  const StyledTabs = styled__default.default.div.attrs({
111
95
  'data-garden-id': COMPONENT_ID,
112
- 'data-garden-version': '8.75.1'
96
+ 'data-garden-version': '8.76.1'
113
97
  }).withConfig({
114
98
  displayName: "StyledTabs",
115
99
  componentId: "sc-1qaor65-0"
@@ -131,7 +115,7 @@ const Tab = React__default.default.forwardRef((_ref, ref) => {
131
115
  } = _ref;
132
116
  const tabsPropGetters = useTabsContext();
133
117
  if (disabled || !tabsPropGetters) {
134
- return React__default.default.createElement(StyledTab, _extends({
118
+ return React__default.default.createElement(StyledTab, Object.assign({
135
119
  role: "tab",
136
120
  "aria-disabled": disabled,
137
121
  ref: ref
@@ -143,7 +127,7 @@ const Tab = React__default.default.forwardRef((_ref, ref) => {
143
127
  } = tabsPropGetters.getTabProps({
144
128
  value: item
145
129
  });
146
- return React__default.default.createElement(StyledTab, _extends({
130
+ return React__default.default.createElement(StyledTab, Object.assign({
147
131
  isSelected: item === tabsPropGetters.selectedValue
148
132
  }, tabProps, otherProps, {
149
133
  ref: mergeRefs__default.default([tabRef, ref])
@@ -158,12 +142,12 @@ Tab.propTypes = {
158
142
  const TabList = React__default.default.forwardRef((props, ref) => {
159
143
  const tabsPropGetters = useTabsContext();
160
144
  if (!tabsPropGetters) {
161
- return React__default.default.createElement(StyledTabList, _extends({
145
+ return React__default.default.createElement(StyledTabList, Object.assign({
162
146
  ref: ref
163
147
  }, props));
164
148
  }
165
149
  const tabListProps = tabsPropGetters.getTabListProps();
166
- return React__default.default.createElement(StyledTabList, _extends({}, tabListProps, props, {
150
+ return React__default.default.createElement(StyledTabList, Object.assign({}, tabListProps, props, {
167
151
  ref: ref
168
152
  }));
169
153
  });
@@ -176,14 +160,14 @@ const TabPanel = React__default.default.forwardRef((_ref, ref) => {
176
160
  } = _ref;
177
161
  const tabsPropGetters = useTabsContext();
178
162
  if (!tabsPropGetters) {
179
- return React__default.default.createElement(StyledTabPanel, _extends({
163
+ return React__default.default.createElement(StyledTabPanel, Object.assign({
180
164
  ref: ref
181
165
  }, otherProps));
182
166
  }
183
167
  const tabPanelProps = tabsPropGetters.getTabPanelProps({
184
168
  value: item
185
169
  });
186
- return React__default.default.createElement(StyledTabPanel, _extends({
170
+ return React__default.default.createElement(StyledTabPanel, Object.assign({
187
171
  "aria-hidden": tabsPropGetters.selectedValue !== item
188
172
  }, tabPanelProps, otherProps, {
189
173
  ref: ref
@@ -239,7 +223,7 @@ const Tabs = React.forwardRef((_ref, ref) => {
239
223
  });
240
224
  return React__default.default.createElement(TabsContext.Provider, {
241
225
  value: tabsContextValue
242
- }, React__default.default.createElement(StyledTabs, _extends({
226
+ }, React__default.default.createElement(StyledTabs, Object.assign({
243
227
  isVertical: isVertical
244
228
  }, otherProps, {
245
229
  ref: ref
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zendeskgarden/react-tabs",
3
- "version": "8.75.1",
3
+ "version": "8.76.1",
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>",
@@ -10,7 +10,7 @@
10
10
  "url": "https://github.com/zendeskgarden/react-components/issues"
11
11
  },
12
12
  "main": "dist/index.cjs.js",
13
- "module": "dist/index.esm.js",
13
+ "module": "dist/esm/index.js",
14
14
  "files": [
15
15
  "dist"
16
16
  ],
@@ -28,13 +28,13 @@
28
28
  "react-merge-refs": "^1.1.0"
29
29
  },
30
30
  "peerDependencies": {
31
- "@zendeskgarden/react-theming": "^8.67.0",
31
+ "@zendeskgarden/react-theming": "^8.75.0",
32
32
  "react": ">=16.8.0",
33
33
  "react-dom": ">=16.8.0",
34
34
  "styled-components": "^4.2.0 || ^5.0.0"
35
35
  },
36
36
  "devDependencies": {
37
- "@zendeskgarden/react-theming": "^8.75.1"
37
+ "@zendeskgarden/react-theming": "^8.76.1"
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": "8e2bb36bcfef722db47a135fc987f72597be5000"
49
+ "gitHead": "8351e305688a65273cb18741c0800be8027cf878"
50
50
  }
package/dist/index.esm.js DELETED
@@ -1,249 +0,0 @@
1
- /**
2
- * Copyright Zendesk, Inc.
3
- *
4
- * Use of this source code is governed under the Apache License, Version 2.0
5
- * found at http://www.apache.org/licenses/LICENSE-2.0.
6
- */
7
-
8
- import React, { createContext, useContext, Children, isValidElement, forwardRef, useState, useMemo } from 'react';
9
- import PropTypes from 'prop-types';
10
- import mergeRefs from 'react-merge-refs';
11
- import styled, { css, ThemeContext } from 'styled-components';
12
- import { retrieveComponentStyles, DEFAULT_THEME, getColorV8, focusStyles } from '@zendeskgarden/react-theming';
13
- import { stripUnit } from 'polished';
14
- import { useTabs } from '@zendeskgarden/container-tabs';
15
- import { getControlledValue } from '@zendeskgarden/container-utilities';
16
-
17
- function _extends() {
18
- _extends = Object.assign ? Object.assign.bind() : function (target) {
19
- for (var i = 1; i < arguments.length; i++) {
20
- var source = arguments[i];
21
- for (var key in source) {
22
- if (Object.prototype.hasOwnProperty.call(source, key)) {
23
- target[key] = source[key];
24
- }
25
- }
26
- }
27
- return target;
28
- };
29
- return _extends.apply(this, arguments);
30
- }
31
-
32
- const COMPONENT_ID$3 = 'tabs.tab';
33
- const colorStyles = _ref => {
34
- let {
35
- theme,
36
- isSelected
37
- } = _ref;
38
- const selectedColor = getColorV8('primaryHue', 600, theme);
39
- 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({
40
- theme,
41
- inset: true,
42
- spacerWidth: null,
43
- shadowWidth: 'sm',
44
- selector: '&:focus-visible::before, &[data-garden-focus-visible="true"]::before',
45
- styles: {
46
- color: selectedColor
47
- }
48
- }), selectedColor, props => getColorV8('neutralHue', 400, props.theme));
49
- };
50
- const sizeStyles = _ref2 => {
51
- let {
52
- theme
53
- } = _ref2;
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
- return css(["padding:", "px ", "px ", "px;"], paddingTop, paddingHorizontal, paddingBottom);
58
- };
59
- const StyledTab = styled.div.attrs({
60
- 'data-garden-id': COMPONENT_ID$3,
61
- 'data-garden-version': '8.75.1'
62
- }).withConfig({
63
- displayName: "StyledTab",
64
- componentId: "sc-x2pbow-0"
65
- })(["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,&[data-garden-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$3, props));
66
- StyledTab.defaultProps = {
67
- theme: DEFAULT_THEME
68
- };
69
-
70
- const COMPONENT_ID$2 = 'tabs.tablist';
71
- const StyledTabList = styled.div.attrs({
72
- 'data-garden-id': COMPONENT_ID$2,
73
- 'data-garden-version': '8.75.1'
74
- }).withConfig({
75
- displayName: "StyledTabList",
76
- componentId: "sc-wa5aaj-0"
77
- })(["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$2, props));
78
- StyledTabList.defaultProps = {
79
- theme: DEFAULT_THEME
80
- };
81
-
82
- const COMPONENT_ID$1 = 'tabs.tabpanel';
83
- const StyledTabPanel = styled.div.attrs({
84
- 'data-garden-id': COMPONENT_ID$1,
85
- 'data-garden-version': '8.75.1'
86
- }).withConfig({
87
- displayName: "StyledTabPanel",
88
- componentId: "sc-7lhrmp-0"
89
- })(["display:block;&[aria-hidden='true']{display:none;}", ";"], props => retrieveComponentStyles(COMPONENT_ID$1, props));
90
- StyledTabPanel.defaultProps = {
91
- theme: DEFAULT_THEME
92
- };
93
-
94
- const COMPONENT_ID = 'tabs.tabs';
95
- const verticalStyling = _ref => {
96
- let {
97
- theme
98
- } = _ref;
99
- 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,&[data-garden-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);
100
- };
101
- const StyledTabs = styled.div.attrs({
102
- 'data-garden-id': COMPONENT_ID,
103
- 'data-garden-version': '8.75.1'
104
- }).withConfig({
105
- displayName: "StyledTabs",
106
- componentId: "sc-1qaor65-0"
107
- })(["display:block;overflow:hidden;direction:", ";", ";", ";"], props => props.theme.rtl && 'rtl', props => props.isVertical && verticalStyling(props), props => retrieveComponentStyles(COMPONENT_ID, props));
108
- StyledTabs.defaultProps = {
109
- theme: DEFAULT_THEME
110
- };
111
-
112
- const TabsContext = createContext(undefined);
113
- const useTabsContext = () => {
114
- return useContext(TabsContext);
115
- };
116
-
117
- const Tab = React.forwardRef((_ref, ref) => {
118
- let {
119
- disabled,
120
- item,
121
- ...otherProps
122
- } = _ref;
123
- const tabsPropGetters = useTabsContext();
124
- if (disabled || !tabsPropGetters) {
125
- return React.createElement(StyledTab, _extends({
126
- role: "tab",
127
- "aria-disabled": disabled,
128
- ref: ref
129
- }, otherProps));
130
- }
131
- const {
132
- ref: tabRef,
133
- ...tabProps
134
- } = tabsPropGetters.getTabProps({
135
- value: item
136
- });
137
- return React.createElement(StyledTab, _extends({
138
- isSelected: item === tabsPropGetters.selectedValue
139
- }, tabProps, otherProps, {
140
- ref: mergeRefs([tabRef, ref])
141
- }));
142
- });
143
- Tab.displayName = 'Tab';
144
- Tab.propTypes = {
145
- disabled: PropTypes.bool,
146
- item: PropTypes.any
147
- };
148
-
149
- const TabList = React.forwardRef((props, ref) => {
150
- const tabsPropGetters = useTabsContext();
151
- if (!tabsPropGetters) {
152
- return React.createElement(StyledTabList, _extends({
153
- ref: ref
154
- }, props));
155
- }
156
- const tabListProps = tabsPropGetters.getTabListProps();
157
- return React.createElement(StyledTabList, _extends({}, tabListProps, props, {
158
- ref: ref
159
- }));
160
- });
161
- TabList.displayName = 'TabList';
162
-
163
- const TabPanel = React.forwardRef((_ref, ref) => {
164
- let {
165
- item,
166
- ...otherProps
167
- } = _ref;
168
- const tabsPropGetters = useTabsContext();
169
- if (!tabsPropGetters) {
170
- return React.createElement(StyledTabPanel, _extends({
171
- ref: ref
172
- }, otherProps));
173
- }
174
- const tabPanelProps = tabsPropGetters.getTabPanelProps({
175
- value: item
176
- });
177
- return React.createElement(StyledTabPanel, _extends({
178
- "aria-hidden": tabsPropGetters.selectedValue !== item
179
- }, tabPanelProps, otherProps, {
180
- ref: ref
181
- }));
182
- });
183
- TabPanel.displayName = 'TabPanel';
184
- TabPanel.propTypes = {
185
- item: PropTypes.any
186
- };
187
-
188
- const toTabs = children => Children.toArray(children).reduce((_items, child) => {
189
- const retVal = _items;
190
- if ( isValidElement(child)) {
191
- if ('item' in child.props) {
192
- const props = child.props;
193
- retVal.push({
194
- value: props.item,
195
- disabled: props.disabled
196
- });
197
- } else {
198
- const childItems = toTabs(child.props.children);
199
- retVal.push(...childItems);
200
- }
201
- }
202
- return retVal;
203
- }, []);
204
-
205
- const Tabs = forwardRef((_ref, ref) => {
206
- let {
207
- isVertical,
208
- children,
209
- onChange,
210
- selectedItem: controlledSelectedItem,
211
- ...otherProps
212
- } = _ref;
213
- const theme = useContext(ThemeContext) || DEFAULT_THEME;
214
- const [internalSelectedItem, setInternalSelectedItem] = useState();
215
- const selectedItem = getControlledValue(controlledSelectedItem, internalSelectedItem);
216
- const tabs = useMemo(() => toTabs(children), [children]);
217
- const tabsContextValue = useTabs({
218
- tabs,
219
- rtl: theme.rtl,
220
- orientation: isVertical ? 'vertical' : 'horizontal',
221
- selectedValue: selectedItem,
222
- defaultSelectedValue: tabs.find(tab => !tab.disabled)?.value,
223
- onSelect: item => {
224
- if (onChange) {
225
- onChange(item);
226
- } else {
227
- setInternalSelectedItem(item);
228
- }
229
- }
230
- });
231
- return React.createElement(TabsContext.Provider, {
232
- value: tabsContextValue
233
- }, React.createElement(StyledTabs, _extends({
234
- isVertical: isVertical
235
- }, otherProps, {
236
- ref: ref
237
- }), children));
238
- });
239
- Tabs.propTypes = {
240
- isVertical: PropTypes.bool,
241
- selectedItem: PropTypes.any,
242
- onChange: PropTypes.func
243
- };
244
- Tabs.defaultProps = {
245
- isVertical: false
246
- };
247
- Tabs.displayName = 'Tabs';
248
-
249
- export { Tab, TabList, TabPanel, Tabs };