@zendeskgarden/react-tabs 8.57.1 → 8.58.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.
- package/dist/index.cjs.js +81 -258
- package/dist/index.esm.js +81 -258
- package/package.json +3 -3
package/dist/index.cjs.js
CHANGED
|
@@ -25,281 +25,106 @@ var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
|
|
|
25
25
|
var mergeRefs__default = /*#__PURE__*/_interopDefaultLegacy(mergeRefs);
|
|
26
26
|
var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
|
|
27
27
|
|
|
28
|
-
function ownKeys(object, enumerableOnly) {
|
|
29
|
-
var keys = Object.keys(object);
|
|
30
|
-
|
|
31
|
-
if (Object.getOwnPropertySymbols) {
|
|
32
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
|
33
|
-
enumerableOnly && (symbols = symbols.filter(function (sym) {
|
|
34
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
35
|
-
})), keys.push.apply(keys, symbols);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
return keys;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
function _objectSpread2(target) {
|
|
42
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
43
|
-
var source = null != arguments[i] ? arguments[i] : {};
|
|
44
|
-
i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
|
|
45
|
-
_defineProperty(target, key, source[key]);
|
|
46
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
|
|
47
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return target;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function _defineProperty(obj, key, value) {
|
|
55
|
-
if (key in obj) {
|
|
56
|
-
Object.defineProperty(obj, key, {
|
|
57
|
-
value: value,
|
|
58
|
-
enumerable: true,
|
|
59
|
-
configurable: true,
|
|
60
|
-
writable: true
|
|
61
|
-
});
|
|
62
|
-
} else {
|
|
63
|
-
obj[key] = value;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
return obj;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
28
|
function _extends() {
|
|
70
29
|
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
71
30
|
for (var i = 1; i < arguments.length; i++) {
|
|
72
31
|
var source = arguments[i];
|
|
73
|
-
|
|
74
32
|
for (var key in source) {
|
|
75
33
|
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
76
34
|
target[key] = source[key];
|
|
77
35
|
}
|
|
78
36
|
}
|
|
79
37
|
}
|
|
80
|
-
|
|
81
38
|
return target;
|
|
82
39
|
};
|
|
83
40
|
return _extends.apply(this, arguments);
|
|
84
41
|
}
|
|
85
42
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
95
|
-
target[key] = source[key];
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
return target;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
function _objectWithoutProperties(source, excluded) {
|
|
102
|
-
if (source == null) return {};
|
|
103
|
-
|
|
104
|
-
var target = _objectWithoutPropertiesLoose(source, excluded);
|
|
105
|
-
|
|
106
|
-
var key, i;
|
|
107
|
-
|
|
108
|
-
if (Object.getOwnPropertySymbols) {
|
|
109
|
-
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
110
|
-
|
|
111
|
-
for (i = 0; i < sourceSymbolKeys.length; i++) {
|
|
112
|
-
key = sourceSymbolKeys[i];
|
|
113
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
114
|
-
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
115
|
-
target[key] = source[key];
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
return target;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
function _slicedToArray(arr, i) {
|
|
123
|
-
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
function _arrayWithHoles(arr) {
|
|
127
|
-
if (Array.isArray(arr)) return arr;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
function _iterableToArrayLimit(arr, i) {
|
|
131
|
-
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
132
|
-
|
|
133
|
-
if (_i == null) return;
|
|
134
|
-
var _arr = [];
|
|
135
|
-
var _n = true;
|
|
136
|
-
var _d = false;
|
|
137
|
-
|
|
138
|
-
var _s, _e;
|
|
139
|
-
|
|
140
|
-
try {
|
|
141
|
-
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
|
|
142
|
-
_arr.push(_s.value);
|
|
143
|
-
|
|
144
|
-
if (i && _arr.length === i) break;
|
|
145
|
-
}
|
|
146
|
-
} catch (err) {
|
|
147
|
-
_d = true;
|
|
148
|
-
_e = err;
|
|
149
|
-
} finally {
|
|
150
|
-
try {
|
|
151
|
-
if (!_n && _i["return"] != null) _i["return"]();
|
|
152
|
-
} finally {
|
|
153
|
-
if (_d) throw _e;
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
return _arr;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
function _unsupportedIterableToArray(o, minLen) {
|
|
161
|
-
if (!o) return;
|
|
162
|
-
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
163
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
164
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
165
|
-
if (n === "Map" || n === "Set") return Array.from(o);
|
|
166
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
function _arrayLikeToArray(arr, len) {
|
|
170
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
171
|
-
|
|
172
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
173
|
-
|
|
174
|
-
return arr2;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
function _nonIterableRest() {
|
|
178
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
var COMPONENT_ID$3 = 'tabs.tab';
|
|
182
|
-
var colorStyles = function colorStyles(_ref) {
|
|
183
|
-
var theme = _ref.theme,
|
|
184
|
-
isSelected = _ref.isSelected;
|
|
185
|
-
var selectedColor = reactTheming.getColor('primaryHue', 600, theme);
|
|
186
|
-
return styled.css(["border-color:", ";color:", ";&:hover{color:", ";}&:active{border-color:currentColor;color:", ";}&[data-garden-focus-visible]{color:", ";}&[data-garden-focus-visible]::before{box-shadow:inset ", ";}&[aria-disabled='true']{border-color:transparent;color:", ";}"], isSelected && 'currentColor !important', isSelected ? selectedColor : 'inherit', selectedColor, selectedColor, selectedColor, theme.shadows.sm(reactTheming.getColor('primaryHue', 600, theme, 0.35)), function (props) {
|
|
187
|
-
return reactTheming.getColor('neutralHue', 400, props.theme);
|
|
188
|
-
});
|
|
43
|
+
const COMPONENT_ID$3 = 'tabs.tab';
|
|
44
|
+
const colorStyles = _ref => {
|
|
45
|
+
let {
|
|
46
|
+
theme,
|
|
47
|
+
isSelected
|
|
48
|
+
} = _ref;
|
|
49
|
+
const selectedColor = reactTheming.getColor('primaryHue', 600, theme);
|
|
50
|
+
return styled.css(["border-color:", ";color:", ";&:hover{color:", ";}&:active{border-color:currentColor;color:", ";}&[data-garden-focus-visible]{color:", ";}&[data-garden-focus-visible]::before{box-shadow:inset ", ";}&[aria-disabled='true']{border-color:transparent;color:", ";}"], isSelected && 'currentColor !important', isSelected ? selectedColor : 'inherit', selectedColor, selectedColor, selectedColor, theme.shadows.sm(reactTheming.getColor('primaryHue', 600, theme, 0.35)), props => reactTheming.getColor('neutralHue', 400, props.theme));
|
|
189
51
|
};
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
52
|
+
const sizeStyles = _ref2 => {
|
|
53
|
+
let {
|
|
54
|
+
theme
|
|
55
|
+
} = _ref2;
|
|
56
|
+
const paddingTop = theme.space.base * 2.5;
|
|
57
|
+
const paddingHorizontal = theme.space.base * 7;
|
|
58
|
+
const paddingBottom = paddingTop - polished.stripUnit(theme.borderWidths.md) - polished.stripUnit(theme.borderWidths.sm);
|
|
195
59
|
return styled.css(["padding:", "px ", "px ", "px;"], paddingTop, paddingHorizontal, paddingBottom);
|
|
196
60
|
};
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
};
|
|
203
|
-
}).withConfig({
|
|
61
|
+
const StyledTab = styled__default["default"].div.attrs(props => ({
|
|
62
|
+
'data-garden-id': COMPONENT_ID$3,
|
|
63
|
+
'data-garden-version': '8.58.0',
|
|
64
|
+
'aria-disabled': props.disabled
|
|
65
|
+
})).withConfig({
|
|
204
66
|
displayName: "StyledTab",
|
|
205
67
|
componentId: "sc-x2pbow-0"
|
|
206
|
-
})(["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{outline:none;text-decoration:none;}&[data-garden-focus-visible]::before{position:absolute;top:", "px;right:", "px;left:", "px;border-radius:", ";height:", "px;pointer-events:none;}&::before{transition:box-shadow 0.1s ease-in-out;content:'';}&:active::before{box-shadow:none;}&[aria-disabled='true']{cursor:default;}", ";"],
|
|
207
|
-
return props.theme.borderStyles.solid;
|
|
208
|
-
}, function (props) {
|
|
209
|
-
return props.theme.borderWidths.md;
|
|
210
|
-
}, sizeStyles, colorStyles, function (props) {
|
|
211
|
-
return props.theme.space.base * 2.5;
|
|
212
|
-
}, function (props) {
|
|
213
|
-
return props.theme.space.base * 6;
|
|
214
|
-
}, function (props) {
|
|
215
|
-
return props.theme.space.base * 6;
|
|
216
|
-
}, function (props) {
|
|
217
|
-
return props.theme.borderRadii.md;
|
|
218
|
-
}, function (props) {
|
|
219
|
-
return props.theme.space.base * 5;
|
|
220
|
-
}, function (props) {
|
|
221
|
-
return reactTheming.retrieveComponentStyles(COMPONENT_ID$3, props);
|
|
222
|
-
});
|
|
68
|
+
})(["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{outline:none;text-decoration:none;}&[data-garden-focus-visible]::before{position:absolute;top:", "px;right:", "px;left:", "px;border-radius:", ";height:", "px;pointer-events:none;}&::before{transition:box-shadow 0.1s ease-in-out;content:'';}&: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));
|
|
223
69
|
StyledTab.defaultProps = {
|
|
224
70
|
theme: reactTheming.DEFAULT_THEME
|
|
225
71
|
};
|
|
226
72
|
|
|
227
|
-
|
|
228
|
-
|
|
73
|
+
const COMPONENT_ID$2 = 'tabs.tablist';
|
|
74
|
+
const StyledTabList = styled__default["default"].div.attrs({
|
|
229
75
|
'data-garden-id': COMPONENT_ID$2,
|
|
230
|
-
'data-garden-version': '8.
|
|
76
|
+
'data-garden-version': '8.58.0'
|
|
231
77
|
}).withConfig({
|
|
232
78
|
displayName: "StyledTabList",
|
|
233
79
|
componentId: "sc-wa5aaj-0"
|
|
234
|
-
})(["display:block;margin-top:0;margin-bottom:", "px;border-bottom:", " ", " ", ";padding:0;line-height:", "px;white-space:nowrap;color:", ";font-size:", ";", ";"],
|
|
235
|
-
return props.theme.space.base * 5;
|
|
236
|
-
}, function (props) {
|
|
237
|
-
return props.theme.borderWidths.sm;
|
|
238
|
-
}, function (props) {
|
|
239
|
-
return props.theme.borderStyles.solid;
|
|
240
|
-
}, function (props) {
|
|
241
|
-
return reactTheming.getColor('neutralHue', 300, props.theme);
|
|
242
|
-
}, function (props) {
|
|
243
|
-
return props.theme.space.base * 5;
|
|
244
|
-
}, function (props) {
|
|
245
|
-
return reactTheming.getColor('neutralHue', 600, props.theme);
|
|
246
|
-
}, function (props) {
|
|
247
|
-
return props.theme.fontSizes.md;
|
|
248
|
-
}, function (props) {
|
|
249
|
-
return reactTheming.retrieveComponentStyles(COMPONENT_ID$2, props);
|
|
250
|
-
});
|
|
80
|
+
})(["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.getColor('neutralHue', 300, props.theme), props => props.theme.space.base * 5, props => reactTheming.getColor('neutralHue', 600, props.theme), props => props.theme.fontSizes.md, props => reactTheming.retrieveComponentStyles(COMPONENT_ID$2, props));
|
|
251
81
|
StyledTabList.defaultProps = {
|
|
252
82
|
theme: reactTheming.DEFAULT_THEME
|
|
253
83
|
};
|
|
254
84
|
|
|
255
|
-
|
|
256
|
-
|
|
85
|
+
const COMPONENT_ID$1 = 'tabs.tabpanel';
|
|
86
|
+
const StyledTabPanel = styled__default["default"].div.attrs({
|
|
257
87
|
'data-garden-id': COMPONENT_ID$1,
|
|
258
|
-
'data-garden-version': '8.
|
|
88
|
+
'data-garden-version': '8.58.0'
|
|
259
89
|
}).withConfig({
|
|
260
90
|
displayName: "StyledTabPanel",
|
|
261
91
|
componentId: "sc-7lhrmp-0"
|
|
262
|
-
})(["display:block;&[aria-hidden='true']{display:none;}", ";"],
|
|
263
|
-
return reactTheming.retrieveComponentStyles(COMPONENT_ID$1, props);
|
|
264
|
-
});
|
|
92
|
+
})(["display:block;&[aria-hidden='true']{display:none;}", ";"], props => reactTheming.retrieveComponentStyles(COMPONENT_ID$1, props));
|
|
265
93
|
StyledTabPanel.defaultProps = {
|
|
266
94
|
theme: reactTheming.DEFAULT_THEME
|
|
267
95
|
};
|
|
268
96
|
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
97
|
+
const COMPONENT_ID = 'tabs.tabs';
|
|
98
|
+
const verticalStyling = _ref => {
|
|
99
|
+
let {
|
|
100
|
+
theme
|
|
101
|
+
} = _ref;
|
|
272
102
|
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;}&[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);
|
|
273
103
|
};
|
|
274
|
-
|
|
104
|
+
const StyledTabs = styled__default["default"].div.attrs({
|
|
275
105
|
'data-garden-id': COMPONENT_ID,
|
|
276
|
-
'data-garden-version': '8.
|
|
106
|
+
'data-garden-version': '8.58.0'
|
|
277
107
|
}).withConfig({
|
|
278
108
|
displayName: "StyledTabs",
|
|
279
109
|
componentId: "sc-1qaor65-0"
|
|
280
|
-
})(["display:block;overflow:hidden;direction:", ";", ";", ";"],
|
|
281
|
-
return props.theme.rtl && 'rtl';
|
|
282
|
-
}, function (props) {
|
|
283
|
-
return props.isVertical && verticalStyling(props);
|
|
284
|
-
}, function (props) {
|
|
285
|
-
return reactTheming.retrieveComponentStyles(COMPONENT_ID, props);
|
|
286
|
-
});
|
|
110
|
+
})(["display:block;overflow:hidden;direction:", ";", ";", ";"], props => props.theme.rtl && 'rtl', props => props.isVertical && verticalStyling(props), props => reactTheming.retrieveComponentStyles(COMPONENT_ID, props));
|
|
287
111
|
StyledTabs.defaultProps = {
|
|
288
112
|
theme: reactTheming.DEFAULT_THEME
|
|
289
113
|
};
|
|
290
114
|
|
|
291
|
-
|
|
292
|
-
|
|
115
|
+
const TabsContext = React.createContext(undefined);
|
|
116
|
+
const useTabsContext = () => {
|
|
293
117
|
return React.useContext(TabsContext);
|
|
294
118
|
};
|
|
295
119
|
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
120
|
+
const Tab = React__default["default"].forwardRef((_ref, ref) => {
|
|
121
|
+
let {
|
|
122
|
+
disabled,
|
|
123
|
+
item,
|
|
124
|
+
...otherProps
|
|
125
|
+
} = _ref;
|
|
126
|
+
const tabsPropGetters = useTabsContext();
|
|
127
|
+
const tabRef = React__default["default"].createRef();
|
|
303
128
|
if (disabled || !tabsPropGetters) {
|
|
304
129
|
return React__default["default"].createElement(StyledTab, _extends({
|
|
305
130
|
role: "tab",
|
|
@@ -307,8 +132,8 @@ var Tab = React__default["default"].forwardRef(function (_ref, ref) {
|
|
|
307
132
|
ref: mergeRefs__default["default"]([tabRef, ref])
|
|
308
133
|
}, otherProps));
|
|
309
134
|
}
|
|
310
|
-
|
|
311
|
-
item
|
|
135
|
+
const tabProps = tabsPropGetters.getTabProps({
|
|
136
|
+
item,
|
|
312
137
|
focusRef: tabRef,
|
|
313
138
|
index: tabsPropGetters.tabIndexRef.current++
|
|
314
139
|
});
|
|
@@ -324,32 +149,33 @@ Tab.propTypes = {
|
|
|
324
149
|
item: PropTypes__default["default"].any
|
|
325
150
|
};
|
|
326
151
|
|
|
327
|
-
|
|
328
|
-
|
|
152
|
+
const TabList = React__default["default"].forwardRef((props, ref) => {
|
|
153
|
+
const tabsPropGetters = useTabsContext();
|
|
329
154
|
if (!tabsPropGetters) {
|
|
330
155
|
return React__default["default"].createElement(StyledTabList, _extends({
|
|
331
156
|
ref: ref
|
|
332
157
|
}, props));
|
|
333
158
|
}
|
|
334
|
-
|
|
159
|
+
const tabListProps = tabsPropGetters.getTabListProps();
|
|
335
160
|
return React__default["default"].createElement(StyledTabList, _extends({}, tabListProps, props, {
|
|
336
161
|
ref: ref
|
|
337
162
|
}));
|
|
338
163
|
});
|
|
339
164
|
TabList.displayName = 'TabList';
|
|
340
165
|
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
166
|
+
const TabPanel = React__default["default"].forwardRef((_ref, ref) => {
|
|
167
|
+
let {
|
|
168
|
+
item,
|
|
169
|
+
...otherProps
|
|
170
|
+
} = _ref;
|
|
171
|
+
const tabsPropGetters = useTabsContext();
|
|
346
172
|
if (!tabsPropGetters) {
|
|
347
173
|
return React__default["default"].createElement(StyledTabPanel, _extends({
|
|
348
174
|
ref: ref
|
|
349
175
|
}, otherProps));
|
|
350
176
|
}
|
|
351
|
-
|
|
352
|
-
item
|
|
177
|
+
const tabPanelProps = tabsPropGetters.getTabPanelProps({
|
|
178
|
+
item,
|
|
353
179
|
index: tabsPropGetters.tabPanelIndexRef.current++
|
|
354
180
|
});
|
|
355
181
|
return React__default["default"].createElement(StyledTabPanel, _extends({
|
|
@@ -363,27 +189,25 @@ TabPanel.propTypes = {
|
|
|
363
189
|
item: PropTypes__default["default"].any
|
|
364
190
|
};
|
|
365
191
|
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
var selectedItem = containerUtilities.getControlledValue(controlledSelectedItem, internalSelectedItem);
|
|
381
|
-
var tabPropGetters = containerTabs.useTabs({
|
|
192
|
+
const Tabs = React.forwardRef((_ref, ref) => {
|
|
193
|
+
let {
|
|
194
|
+
isVertical,
|
|
195
|
+
children,
|
|
196
|
+
onChange,
|
|
197
|
+
selectedItem: controlledSelectedItem,
|
|
198
|
+
...otherProps
|
|
199
|
+
} = _ref;
|
|
200
|
+
const theme = React.useContext(styled.ThemeContext) || reactTheming.DEFAULT_THEME;
|
|
201
|
+
const [internalSelectedItem, setInternalSelectedItem] = React.useState();
|
|
202
|
+
const tabIndexRef = React.useRef(0);
|
|
203
|
+
const tabPanelIndexRef = React.useRef(0);
|
|
204
|
+
const selectedItem = containerUtilities.getControlledValue(controlledSelectedItem, internalSelectedItem);
|
|
205
|
+
const tabPropGetters = containerTabs.useTabs({
|
|
382
206
|
rtl: theme.rtl,
|
|
383
207
|
orientation: isVertical ? 'vertical' : 'horizontal',
|
|
384
|
-
selectedItem
|
|
208
|
+
selectedItem,
|
|
385
209
|
defaultSelectedIndex: 0,
|
|
386
|
-
onSelect:
|
|
210
|
+
onSelect: item => {
|
|
387
211
|
if (onChange) {
|
|
388
212
|
onChange(item);
|
|
389
213
|
} else {
|
|
@@ -391,12 +215,11 @@ var Tabs = React.forwardRef(function (_ref, ref) {
|
|
|
391
215
|
}
|
|
392
216
|
}
|
|
393
217
|
});
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
}, [tabPropGetters]);
|
|
218
|
+
const tabsContextValue = React.useMemo(() => ({
|
|
219
|
+
...tabPropGetters,
|
|
220
|
+
tabIndexRef,
|
|
221
|
+
tabPanelIndexRef
|
|
222
|
+
}), [tabPropGetters]);
|
|
400
223
|
return React__default["default"].createElement(TabsContext.Provider, {
|
|
401
224
|
value: tabsContextValue
|
|
402
225
|
}, React__default["default"].createElement(StyledTabs, _extends({
|
package/dist/index.esm.js
CHANGED
|
@@ -14,281 +14,106 @@ import { stripUnit } from 'polished';
|
|
|
14
14
|
import { useTabs } from '@zendeskgarden/container-tabs';
|
|
15
15
|
import { getControlledValue } from '@zendeskgarden/container-utilities';
|
|
16
16
|
|
|
17
|
-
function ownKeys(object, enumerableOnly) {
|
|
18
|
-
var keys = Object.keys(object);
|
|
19
|
-
|
|
20
|
-
if (Object.getOwnPropertySymbols) {
|
|
21
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
|
22
|
-
enumerableOnly && (symbols = symbols.filter(function (sym) {
|
|
23
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
24
|
-
})), keys.push.apply(keys, symbols);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return keys;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function _objectSpread2(target) {
|
|
31
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
32
|
-
var source = null != arguments[i] ? arguments[i] : {};
|
|
33
|
-
i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
|
|
34
|
-
_defineProperty(target, key, source[key]);
|
|
35
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
|
|
36
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
return target;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
function _defineProperty(obj, key, value) {
|
|
44
|
-
if (key in obj) {
|
|
45
|
-
Object.defineProperty(obj, key, {
|
|
46
|
-
value: value,
|
|
47
|
-
enumerable: true,
|
|
48
|
-
configurable: true,
|
|
49
|
-
writable: true
|
|
50
|
-
});
|
|
51
|
-
} else {
|
|
52
|
-
obj[key] = value;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return obj;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
17
|
function _extends() {
|
|
59
18
|
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
60
19
|
for (var i = 1; i < arguments.length; i++) {
|
|
61
20
|
var source = arguments[i];
|
|
62
|
-
|
|
63
21
|
for (var key in source) {
|
|
64
22
|
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
65
23
|
target[key] = source[key];
|
|
66
24
|
}
|
|
67
25
|
}
|
|
68
26
|
}
|
|
69
|
-
|
|
70
27
|
return target;
|
|
71
28
|
};
|
|
72
29
|
return _extends.apply(this, arguments);
|
|
73
30
|
}
|
|
74
31
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
84
|
-
target[key] = source[key];
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
return target;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
function _objectWithoutProperties(source, excluded) {
|
|
91
|
-
if (source == null) return {};
|
|
92
|
-
|
|
93
|
-
var target = _objectWithoutPropertiesLoose(source, excluded);
|
|
94
|
-
|
|
95
|
-
var key, i;
|
|
96
|
-
|
|
97
|
-
if (Object.getOwnPropertySymbols) {
|
|
98
|
-
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
99
|
-
|
|
100
|
-
for (i = 0; i < sourceSymbolKeys.length; i++) {
|
|
101
|
-
key = sourceSymbolKeys[i];
|
|
102
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
103
|
-
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
104
|
-
target[key] = source[key];
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
return target;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
function _slicedToArray(arr, i) {
|
|
112
|
-
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
function _arrayWithHoles(arr) {
|
|
116
|
-
if (Array.isArray(arr)) return arr;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
function _iterableToArrayLimit(arr, i) {
|
|
120
|
-
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
121
|
-
|
|
122
|
-
if (_i == null) return;
|
|
123
|
-
var _arr = [];
|
|
124
|
-
var _n = true;
|
|
125
|
-
var _d = false;
|
|
126
|
-
|
|
127
|
-
var _s, _e;
|
|
128
|
-
|
|
129
|
-
try {
|
|
130
|
-
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
|
|
131
|
-
_arr.push(_s.value);
|
|
132
|
-
|
|
133
|
-
if (i && _arr.length === i) break;
|
|
134
|
-
}
|
|
135
|
-
} catch (err) {
|
|
136
|
-
_d = true;
|
|
137
|
-
_e = err;
|
|
138
|
-
} finally {
|
|
139
|
-
try {
|
|
140
|
-
if (!_n && _i["return"] != null) _i["return"]();
|
|
141
|
-
} finally {
|
|
142
|
-
if (_d) throw _e;
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
return _arr;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
function _unsupportedIterableToArray(o, minLen) {
|
|
150
|
-
if (!o) return;
|
|
151
|
-
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
152
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
153
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
154
|
-
if (n === "Map" || n === "Set") return Array.from(o);
|
|
155
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
function _arrayLikeToArray(arr, len) {
|
|
159
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
160
|
-
|
|
161
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
162
|
-
|
|
163
|
-
return arr2;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
function _nonIterableRest() {
|
|
167
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
var COMPONENT_ID$3 = 'tabs.tab';
|
|
171
|
-
var colorStyles = function colorStyles(_ref) {
|
|
172
|
-
var theme = _ref.theme,
|
|
173
|
-
isSelected = _ref.isSelected;
|
|
174
|
-
var selectedColor = getColor('primaryHue', 600, theme);
|
|
175
|
-
return css(["border-color:", ";color:", ";&:hover{color:", ";}&:active{border-color:currentColor;color:", ";}&[data-garden-focus-visible]{color:", ";}&[data-garden-focus-visible]::before{box-shadow:inset ", ";}&[aria-disabled='true']{border-color:transparent;color:", ";}"], isSelected && 'currentColor !important', isSelected ? selectedColor : 'inherit', selectedColor, selectedColor, selectedColor, theme.shadows.sm(getColor('primaryHue', 600, theme, 0.35)), function (props) {
|
|
176
|
-
return getColor('neutralHue', 400, props.theme);
|
|
177
|
-
});
|
|
32
|
+
const COMPONENT_ID$3 = 'tabs.tab';
|
|
33
|
+
const colorStyles = _ref => {
|
|
34
|
+
let {
|
|
35
|
+
theme,
|
|
36
|
+
isSelected
|
|
37
|
+
} = _ref;
|
|
38
|
+
const selectedColor = getColor('primaryHue', 600, theme);
|
|
39
|
+
return css(["border-color:", ";color:", ";&:hover{color:", ";}&:active{border-color:currentColor;color:", ";}&[data-garden-focus-visible]{color:", ";}&[data-garden-focus-visible]::before{box-shadow:inset ", ";}&[aria-disabled='true']{border-color:transparent;color:", ";}"], isSelected && 'currentColor !important', isSelected ? selectedColor : 'inherit', selectedColor, selectedColor, selectedColor, theme.shadows.sm(getColor('primaryHue', 600, theme, 0.35)), props => getColor('neutralHue', 400, props.theme));
|
|
178
40
|
};
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
41
|
+
const sizeStyles = _ref2 => {
|
|
42
|
+
let {
|
|
43
|
+
theme
|
|
44
|
+
} = _ref2;
|
|
45
|
+
const paddingTop = theme.space.base * 2.5;
|
|
46
|
+
const paddingHorizontal = theme.space.base * 7;
|
|
47
|
+
const paddingBottom = paddingTop - stripUnit(theme.borderWidths.md) - stripUnit(theme.borderWidths.sm);
|
|
184
48
|
return css(["padding:", "px ", "px ", "px;"], paddingTop, paddingHorizontal, paddingBottom);
|
|
185
49
|
};
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
};
|
|
192
|
-
}).withConfig({
|
|
50
|
+
const StyledTab = styled.div.attrs(props => ({
|
|
51
|
+
'data-garden-id': COMPONENT_ID$3,
|
|
52
|
+
'data-garden-version': '8.58.0',
|
|
53
|
+
'aria-disabled': props.disabled
|
|
54
|
+
})).withConfig({
|
|
193
55
|
displayName: "StyledTab",
|
|
194
56
|
componentId: "sc-x2pbow-0"
|
|
195
|
-
})(["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{outline:none;text-decoration:none;}&[data-garden-focus-visible]::before{position:absolute;top:", "px;right:", "px;left:", "px;border-radius:", ";height:", "px;pointer-events:none;}&::before{transition:box-shadow 0.1s ease-in-out;content:'';}&:active::before{box-shadow:none;}&[aria-disabled='true']{cursor:default;}", ";"],
|
|
196
|
-
return props.theme.borderStyles.solid;
|
|
197
|
-
}, function (props) {
|
|
198
|
-
return props.theme.borderWidths.md;
|
|
199
|
-
}, sizeStyles, colorStyles, function (props) {
|
|
200
|
-
return props.theme.space.base * 2.5;
|
|
201
|
-
}, function (props) {
|
|
202
|
-
return props.theme.space.base * 6;
|
|
203
|
-
}, function (props) {
|
|
204
|
-
return props.theme.space.base * 6;
|
|
205
|
-
}, function (props) {
|
|
206
|
-
return props.theme.borderRadii.md;
|
|
207
|
-
}, function (props) {
|
|
208
|
-
return props.theme.space.base * 5;
|
|
209
|
-
}, function (props) {
|
|
210
|
-
return retrieveComponentStyles(COMPONENT_ID$3, props);
|
|
211
|
-
});
|
|
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{outline:none;text-decoration:none;}&[data-garden-focus-visible]::before{position:absolute;top:", "px;right:", "px;left:", "px;border-radius:", ";height:", "px;pointer-events:none;}&::before{transition:box-shadow 0.1s ease-in-out;content:'';}&: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));
|
|
212
58
|
StyledTab.defaultProps = {
|
|
213
59
|
theme: DEFAULT_THEME
|
|
214
60
|
};
|
|
215
61
|
|
|
216
|
-
|
|
217
|
-
|
|
62
|
+
const COMPONENT_ID$2 = 'tabs.tablist';
|
|
63
|
+
const StyledTabList = styled.div.attrs({
|
|
218
64
|
'data-garden-id': COMPONENT_ID$2,
|
|
219
|
-
'data-garden-version': '8.
|
|
65
|
+
'data-garden-version': '8.58.0'
|
|
220
66
|
}).withConfig({
|
|
221
67
|
displayName: "StyledTabList",
|
|
222
68
|
componentId: "sc-wa5aaj-0"
|
|
223
|
-
})(["display:block;margin-top:0;margin-bottom:", "px;border-bottom:", " ", " ", ";padding:0;line-height:", "px;white-space:nowrap;color:", ";font-size:", ";", ";"],
|
|
224
|
-
return props.theme.space.base * 5;
|
|
225
|
-
}, function (props) {
|
|
226
|
-
return props.theme.borderWidths.sm;
|
|
227
|
-
}, function (props) {
|
|
228
|
-
return props.theme.borderStyles.solid;
|
|
229
|
-
}, function (props) {
|
|
230
|
-
return getColor('neutralHue', 300, props.theme);
|
|
231
|
-
}, function (props) {
|
|
232
|
-
return props.theme.space.base * 5;
|
|
233
|
-
}, function (props) {
|
|
234
|
-
return getColor('neutralHue', 600, props.theme);
|
|
235
|
-
}, function (props) {
|
|
236
|
-
return props.theme.fontSizes.md;
|
|
237
|
-
}, function (props) {
|
|
238
|
-
return retrieveComponentStyles(COMPONENT_ID$2, props);
|
|
239
|
-
});
|
|
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 => getColor('neutralHue', 300, props.theme), props => props.theme.space.base * 5, props => getColor('neutralHue', 600, props.theme), props => props.theme.fontSizes.md, props => retrieveComponentStyles(COMPONENT_ID$2, props));
|
|
240
70
|
StyledTabList.defaultProps = {
|
|
241
71
|
theme: DEFAULT_THEME
|
|
242
72
|
};
|
|
243
73
|
|
|
244
|
-
|
|
245
|
-
|
|
74
|
+
const COMPONENT_ID$1 = 'tabs.tabpanel';
|
|
75
|
+
const StyledTabPanel = styled.div.attrs({
|
|
246
76
|
'data-garden-id': COMPONENT_ID$1,
|
|
247
|
-
'data-garden-version': '8.
|
|
77
|
+
'data-garden-version': '8.58.0'
|
|
248
78
|
}).withConfig({
|
|
249
79
|
displayName: "StyledTabPanel",
|
|
250
80
|
componentId: "sc-7lhrmp-0"
|
|
251
|
-
})(["display:block;&[aria-hidden='true']{display:none;}", ";"],
|
|
252
|
-
return retrieveComponentStyles(COMPONENT_ID$1, props);
|
|
253
|
-
});
|
|
81
|
+
})(["display:block;&[aria-hidden='true']{display:none;}", ";"], props => retrieveComponentStyles(COMPONENT_ID$1, props));
|
|
254
82
|
StyledTabPanel.defaultProps = {
|
|
255
83
|
theme: DEFAULT_THEME
|
|
256
84
|
};
|
|
257
85
|
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
86
|
+
const COMPONENT_ID = 'tabs.tabs';
|
|
87
|
+
const verticalStyling = _ref => {
|
|
88
|
+
let {
|
|
89
|
+
theme
|
|
90
|
+
} = _ref;
|
|
261
91
|
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;}&[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);
|
|
262
92
|
};
|
|
263
|
-
|
|
93
|
+
const StyledTabs = styled.div.attrs({
|
|
264
94
|
'data-garden-id': COMPONENT_ID,
|
|
265
|
-
'data-garden-version': '8.
|
|
95
|
+
'data-garden-version': '8.58.0'
|
|
266
96
|
}).withConfig({
|
|
267
97
|
displayName: "StyledTabs",
|
|
268
98
|
componentId: "sc-1qaor65-0"
|
|
269
|
-
})(["display:block;overflow:hidden;direction:", ";", ";", ";"],
|
|
270
|
-
return props.theme.rtl && 'rtl';
|
|
271
|
-
}, function (props) {
|
|
272
|
-
return props.isVertical && verticalStyling(props);
|
|
273
|
-
}, function (props) {
|
|
274
|
-
return retrieveComponentStyles(COMPONENT_ID, props);
|
|
275
|
-
});
|
|
99
|
+
})(["display:block;overflow:hidden;direction:", ";", ";", ";"], props => props.theme.rtl && 'rtl', props => props.isVertical && verticalStyling(props), props => retrieveComponentStyles(COMPONENT_ID, props));
|
|
276
100
|
StyledTabs.defaultProps = {
|
|
277
101
|
theme: DEFAULT_THEME
|
|
278
102
|
};
|
|
279
103
|
|
|
280
|
-
|
|
281
|
-
|
|
104
|
+
const TabsContext = createContext(undefined);
|
|
105
|
+
const useTabsContext = () => {
|
|
282
106
|
return useContext(TabsContext);
|
|
283
107
|
};
|
|
284
108
|
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
109
|
+
const Tab = React.forwardRef((_ref, ref) => {
|
|
110
|
+
let {
|
|
111
|
+
disabled,
|
|
112
|
+
item,
|
|
113
|
+
...otherProps
|
|
114
|
+
} = _ref;
|
|
115
|
+
const tabsPropGetters = useTabsContext();
|
|
116
|
+
const tabRef = React.createRef();
|
|
292
117
|
if (disabled || !tabsPropGetters) {
|
|
293
118
|
return React.createElement(StyledTab, _extends({
|
|
294
119
|
role: "tab",
|
|
@@ -296,8 +121,8 @@ var Tab = React.forwardRef(function (_ref, ref) {
|
|
|
296
121
|
ref: mergeRefs([tabRef, ref])
|
|
297
122
|
}, otherProps));
|
|
298
123
|
}
|
|
299
|
-
|
|
300
|
-
item
|
|
124
|
+
const tabProps = tabsPropGetters.getTabProps({
|
|
125
|
+
item,
|
|
301
126
|
focusRef: tabRef,
|
|
302
127
|
index: tabsPropGetters.tabIndexRef.current++
|
|
303
128
|
});
|
|
@@ -313,32 +138,33 @@ Tab.propTypes = {
|
|
|
313
138
|
item: PropTypes.any
|
|
314
139
|
};
|
|
315
140
|
|
|
316
|
-
|
|
317
|
-
|
|
141
|
+
const TabList = React.forwardRef((props, ref) => {
|
|
142
|
+
const tabsPropGetters = useTabsContext();
|
|
318
143
|
if (!tabsPropGetters) {
|
|
319
144
|
return React.createElement(StyledTabList, _extends({
|
|
320
145
|
ref: ref
|
|
321
146
|
}, props));
|
|
322
147
|
}
|
|
323
|
-
|
|
148
|
+
const tabListProps = tabsPropGetters.getTabListProps();
|
|
324
149
|
return React.createElement(StyledTabList, _extends({}, tabListProps, props, {
|
|
325
150
|
ref: ref
|
|
326
151
|
}));
|
|
327
152
|
});
|
|
328
153
|
TabList.displayName = 'TabList';
|
|
329
154
|
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
155
|
+
const TabPanel = React.forwardRef((_ref, ref) => {
|
|
156
|
+
let {
|
|
157
|
+
item,
|
|
158
|
+
...otherProps
|
|
159
|
+
} = _ref;
|
|
160
|
+
const tabsPropGetters = useTabsContext();
|
|
335
161
|
if (!tabsPropGetters) {
|
|
336
162
|
return React.createElement(StyledTabPanel, _extends({
|
|
337
163
|
ref: ref
|
|
338
164
|
}, otherProps));
|
|
339
165
|
}
|
|
340
|
-
|
|
341
|
-
item
|
|
166
|
+
const tabPanelProps = tabsPropGetters.getTabPanelProps({
|
|
167
|
+
item,
|
|
342
168
|
index: tabsPropGetters.tabPanelIndexRef.current++
|
|
343
169
|
});
|
|
344
170
|
return React.createElement(StyledTabPanel, _extends({
|
|
@@ -352,27 +178,25 @@ TabPanel.propTypes = {
|
|
|
352
178
|
item: PropTypes.any
|
|
353
179
|
};
|
|
354
180
|
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
var selectedItem = getControlledValue(controlledSelectedItem, internalSelectedItem);
|
|
370
|
-
var tabPropGetters = useTabs({
|
|
181
|
+
const Tabs = forwardRef((_ref, ref) => {
|
|
182
|
+
let {
|
|
183
|
+
isVertical,
|
|
184
|
+
children,
|
|
185
|
+
onChange,
|
|
186
|
+
selectedItem: controlledSelectedItem,
|
|
187
|
+
...otherProps
|
|
188
|
+
} = _ref;
|
|
189
|
+
const theme = useContext(ThemeContext) || DEFAULT_THEME;
|
|
190
|
+
const [internalSelectedItem, setInternalSelectedItem] = useState();
|
|
191
|
+
const tabIndexRef = useRef(0);
|
|
192
|
+
const tabPanelIndexRef = useRef(0);
|
|
193
|
+
const selectedItem = getControlledValue(controlledSelectedItem, internalSelectedItem);
|
|
194
|
+
const tabPropGetters = useTabs({
|
|
371
195
|
rtl: theme.rtl,
|
|
372
196
|
orientation: isVertical ? 'vertical' : 'horizontal',
|
|
373
|
-
selectedItem
|
|
197
|
+
selectedItem,
|
|
374
198
|
defaultSelectedIndex: 0,
|
|
375
|
-
onSelect:
|
|
199
|
+
onSelect: item => {
|
|
376
200
|
if (onChange) {
|
|
377
201
|
onChange(item);
|
|
378
202
|
} else {
|
|
@@ -380,12 +204,11 @@ var Tabs = forwardRef(function (_ref, ref) {
|
|
|
380
204
|
}
|
|
381
205
|
}
|
|
382
206
|
});
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
}, [tabPropGetters]);
|
|
207
|
+
const tabsContextValue = useMemo(() => ({
|
|
208
|
+
...tabPropGetters,
|
|
209
|
+
tabIndexRef,
|
|
210
|
+
tabPanelIndexRef
|
|
211
|
+
}), [tabPropGetters]);
|
|
389
212
|
return React.createElement(TabsContext.Provider, {
|
|
390
213
|
value: tabsContextValue
|
|
391
214
|
}, React.createElement(StyledTabs, _extends({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zendeskgarden/react-tabs",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.58.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>",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"styled-components": "^4.2.0 || ^5.0.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@zendeskgarden/react-theming": "^8.
|
|
37
|
+
"@zendeskgarden/react-theming": "^8.58.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": "
|
|
49
|
+
"gitHead": "07760a92573b619860e1252f6931467b9123f1b6"
|
|
50
50
|
}
|