baseui 0.0.0-next-0b9fd6a → 0.0.0-next-e0f9354

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,19 +24,19 @@ function getColorStyles(_ref) {
24
24
  $hierarchy = _ref.$hierarchy,
25
25
  $color = _ref.$color;
26
26
  var COLOR_STYLES = (_COLOR_STYLES = {}, _defineProperty(_COLOR_STYLES, _constants.HIERARCHY.primary, (_HIERARCHY$primary = {}, _defineProperty(_HIERARCHY$primary, _constants.COLOR.accent, {
27
- color: $theme.colors.contentInversePrimary,
27
+ color: $theme.colors.contentOnColor,
28
28
  backgroundColor: $theme.colors.backgroundAccent
29
29
  }), _defineProperty(_HIERARCHY$primary, _constants.COLOR.primary, {
30
30
  color: $theme.colors.contentInversePrimary,
31
31
  backgroundColor: $theme.colors.backgroundInversePrimary
32
32
  }), _defineProperty(_HIERARCHY$primary, _constants.COLOR.positive, {
33
- color: $theme.colors.contentInversePrimary,
33
+ color: $theme.colors.contentOnColor,
34
34
  backgroundColor: $theme.colors.backgroundPositive
35
35
  }), _defineProperty(_HIERARCHY$primary, _constants.COLOR.negative, {
36
- color: $theme.colors.contentInversePrimary,
36
+ color: $theme.colors.contentOnColor,
37
37
  backgroundColor: $theme.colors.backgroundNegative
38
38
  }), _defineProperty(_HIERARCHY$primary, _constants.COLOR.warning, {
39
- color: $theme.colors.primaryA,
39
+ color: $theme.colors.contentOnColorInverse,
40
40
  backgroundColor: $theme.colors.backgroundWarning
41
41
  }), _HIERARCHY$primary)), _defineProperty(_COLOR_STYLES, _constants.HIERARCHY.secondary, (_HIERARCHY$secondary = {}, _defineProperty(_HIERARCHY$secondary, _constants.COLOR.accent, {
42
42
  color: $theme.colors.contentAccent,
@@ -16,7 +16,7 @@ function getColorStyles({ $theme, $hierarchy, $color }): {|
16
16
  const COLOR_STYLES = {
17
17
  [HIERARCHY.primary]: {
18
18
  [COLOR.accent]: {
19
- color: $theme.colors.contentInversePrimary,
19
+ color: $theme.colors.contentOnColor,
20
20
  backgroundColor: $theme.colors.backgroundAccent,
21
21
  },
22
22
  [COLOR.primary]: {
@@ -24,15 +24,15 @@ function getColorStyles({ $theme, $hierarchy, $color }): {|
24
24
  backgroundColor: $theme.colors.backgroundInversePrimary,
25
25
  },
26
26
  [COLOR.positive]: {
27
- color: $theme.colors.contentInversePrimary,
27
+ color: $theme.colors.contentOnColor,
28
28
  backgroundColor: $theme.colors.backgroundPositive,
29
29
  },
30
30
  [COLOR.negative]: {
31
- color: $theme.colors.contentInversePrimary,
31
+ color: $theme.colors.contentOnColor,
32
32
  backgroundColor: $theme.colors.backgroundNegative,
33
33
  },
34
34
  [COLOR.warning]: {
35
- color: $theme.colors.primaryA,
35
+ color: $theme.colors.contentOnColorInverse,
36
36
  backgroundColor: $theme.colors.backgroundWarning,
37
37
  },
38
38
  },
@@ -15,7 +15,7 @@ function getColorStyles({
15
15
  const COLOR_STYLES = {
16
16
  [HIERARCHY.primary]: {
17
17
  [COLOR.accent]: {
18
- color: $theme.colors.contentInversePrimary,
18
+ color: $theme.colors.contentOnColor,
19
19
  backgroundColor: $theme.colors.backgroundAccent
20
20
  },
21
21
  [COLOR.primary]: {
@@ -23,15 +23,15 @@ function getColorStyles({
23
23
  backgroundColor: $theme.colors.backgroundInversePrimary
24
24
  },
25
25
  [COLOR.positive]: {
26
- color: $theme.colors.contentInversePrimary,
26
+ color: $theme.colors.contentOnColor,
27
27
  backgroundColor: $theme.colors.backgroundPositive
28
28
  },
29
29
  [COLOR.negative]: {
30
- color: $theme.colors.contentInversePrimary,
30
+ color: $theme.colors.contentOnColor,
31
31
  backgroundColor: $theme.colors.backgroundNegative
32
32
  },
33
33
  [COLOR.warning]: {
34
- color: $theme.colors.primaryA,
34
+ color: $theme.colors.contentOnColorInverse,
35
35
  backgroundColor: $theme.colors.backgroundWarning
36
36
  }
37
37
  },
@@ -28,7 +28,7 @@ const defaultProps = {
28
28
  ignoreCase: true,
29
29
  isLoading: false,
30
30
  labelKey: 'label',
31
- maxDropdownHeight: '900px',
31
+ maxDropdownHeight: '40vh',
32
32
  multi: false,
33
33
  onBlur: () => {},
34
34
  onBlurResetsInput: true,
@@ -25,6 +25,14 @@ export const StyledRoot = styled('div', ({
25
25
  });
26
26
  StyledRoot.displayName = "StyledRoot";
27
27
  StyledRoot.displayName = 'StyledRoot';
28
+ export const StyledTabBar = styled('div', ({
29
+ $hasEndEnhancer,
30
+ $orientation
31
+ }) => $hasEndEnhancer || !isHorizontal($orientation) ? {
32
+ display: 'flex'
33
+ } : {});
34
+ StyledTabBar.displayName = "StyledTabBar";
35
+ StyledTabBar.displayName = 'StyledTabBar';
28
36
  export const StyledTabList = styled('div', ({
29
37
  $theme,
30
38
  $fill = FILL.intrinsic,
@@ -33,7 +41,8 @@ export const StyledTabList = styled('div', ({
33
41
  const style = {
34
42
  position: 'relative',
35
43
  display: 'flex',
36
- flexWrap: 'nowrap'
44
+ flexWrap: 'nowrap',
45
+ flexGrow: 1
37
46
  };
38
47
 
39
48
  if (isHorizontal($orientation)) {
@@ -139,6 +148,19 @@ export const StyledTab = styled('button', ({
139
148
  });
140
149
  StyledTab.displayName = "StyledTab";
141
150
  StyledTab.displayName = 'StyledTab';
151
+ export const StyledEndEnhancerContainer = styled('div', ({
152
+ $theme
153
+ }) => {
154
+ const marginDirection = $theme.direction === 'rtl' ? 'marginRight' : 'marginLeft';
155
+ return {
156
+ display: 'flex',
157
+ alignItems: 'center',
158
+ justifyContent: 'flex-end',
159
+ [marginDirection]: $theme.sizing.scale600
160
+ };
161
+ });
162
+ StyledEndEnhancerContainer.displayName = "StyledEndEnhancerContainer";
163
+ StyledEndEnhancerContainer.displayName = 'StyledEndEnhancerContainer';
142
164
  export const StyledArtworkContainer = styled('div', ({
143
165
  $theme,
144
166
  $orientation = ORIENTATION.horizontal
@@ -9,12 +9,13 @@ LICENSE file in the root directory of this source tree.
9
9
 
10
10
  /* global window */
11
11
  import * as React from 'react';
12
+ import * as ReactIs from 'react-is';
12
13
  import { useUID } from 'react-uid';
13
14
  import { useStyletron } from '../styles';
14
15
  import { getOverrides } from '../helpers/overrides';
15
16
  import { isFocusVisible, forkFocus, forkBlur } from '../utils/focusVisible';
16
17
  import { ORIENTATION, FILL } from './constants';
17
- import { StyledRoot, StyledTabList, StyledTab, StyledArtworkContainer, StyledTabHighlight, StyledTabBorder, StyledTabPanel } from './styled-components';
18
+ import { StyledRoot, StyledTabList, StyledTab, StyledArtworkContainer, StyledTabHighlight, StyledTabBorder, StyledTabPanel, StyledEndEnhancerContainer, StyledTabBar } from './styled-components';
18
19
  import { getTabId, getTabPanelId, isVertical, isHorizontal, isRTL } from './utils';
19
20
  const KEYBOARD_ACTION = {
20
21
  next: 'next',
@@ -78,6 +79,20 @@ const scrollParentToCentreTarget = targetNode => {
78
79
  targetNode.parentNode.scroll(target.x, target.y);
79
80
  };
80
81
 
82
+ function RenderEnhancer({
83
+ Enhancer
84
+ }) {
85
+ if (typeof Enhancer === 'string') {
86
+ return Enhancer;
87
+ }
88
+
89
+ if (ReactIs.isValidElementType(Enhancer)) {
90
+ return /*#__PURE__*/React.createElement(Enhancer, null);
91
+ }
92
+
93
+ return Enhancer;
94
+ }
95
+
81
96
  export function Tabs({
82
97
  activeKey = '0',
83
98
  disabled = false,
@@ -88,7 +103,8 @@ export function Tabs({
88
103
  orientation = ORIENTATION.horizontal,
89
104
  overrides = {},
90
105
  renderAll = false,
91
- uid: customUid = null
106
+ uid: customUid = null,
107
+ endEnhancer
92
108
  }) {
93
109
  // Create unique id prefix for this tabs component
94
110
  const generatedUid = useUID();
@@ -103,7 +119,8 @@ export function Tabs({
103
119
  const [Root, RootProps] = getOverrides(RootOverrides, StyledRoot);
104
120
  const [TabList, TabListProps] = getOverrides(TabListOverrides, StyledTabList);
105
121
  const [TabHighlight, TabHighlightProps] = getOverrides(TabHighlightOverrides, StyledTabHighlight);
106
- const [TabBorder, TabBorderProps] = getOverrides(TabBorderOverrides, StyledTabBorder); // Count key updates
122
+ const [TabBorder, TabBorderProps] = getOverrides(TabBorderOverrides, StyledTabBorder);
123
+ const [EndEnhancerContainer, endEnhancerContainerProps] = getOverrides(overrides.EndEnhancerContainer, StyledEndEnhancerContainer); // Count key updates
107
124
  // We disable a few things until after first mount:
108
125
  // - the highlight animation, avoiding an initial slide-in
109
126
  // - smooth scrolling active tab into view
@@ -196,7 +213,10 @@ export function Tabs({
196
213
  }
197
214
  }
198
215
  }, [orientation, theme.direction]);
199
- return /*#__PURE__*/React.createElement(Root, _extends({}, sharedStylingProps, RootProps), /*#__PURE__*/React.createElement(TabList, _extends({
216
+ return /*#__PURE__*/React.createElement(Root, _extends({}, sharedStylingProps, RootProps), /*#__PURE__*/React.createElement(StyledTabBar, {
217
+ $hasEndEnhancer: Boolean(endEnhancer),
218
+ $orientation: orientation
219
+ }, /*#__PURE__*/React.createElement(TabList, _extends({
200
220
  "data-baseweb": "tab-list",
201
221
  role: "tablist",
202
222
  "aria-orientation": orientation
@@ -224,7 +244,11 @@ export function Tabs({
224
244
  $animate: keyUpdated > 1,
225
245
  "aria-hidden": "true",
226
246
  role: "presentation"
227
- }, sharedStylingProps, TabHighlightProps))), /*#__PURE__*/React.createElement(TabBorder, _extends({
247
+ }, sharedStylingProps, TabHighlightProps))), orientation === ORIENTATION.horizontal && endEnhancer !== null && endEnhancer !== undefined && /*#__PURE__*/React.createElement(EndEnhancerContainer, _extends({}, endEnhancerContainerProps, {
248
+ $orientation: orientation
249
+ }), /*#__PURE__*/React.createElement(RenderEnhancer, {
250
+ Enhancer: endEnhancer
251
+ }))), /*#__PURE__*/React.createElement(TabBorder, _extends({
228
252
  "data-baseweb": "tab-border",
229
253
  "aria-hidden": "true",
230
254
  role: "presentation"
@@ -22,19 +22,19 @@ function getColorStyles(_ref) {
22
22
  $hierarchy = _ref.$hierarchy,
23
23
  $color = _ref.$color;
24
24
  var COLOR_STYLES = (_COLOR_STYLES = {}, _defineProperty(_COLOR_STYLES, HIERARCHY.primary, (_HIERARCHY$primary = {}, _defineProperty(_HIERARCHY$primary, COLOR.accent, {
25
- color: $theme.colors.contentInversePrimary,
25
+ color: $theme.colors.contentOnColor,
26
26
  backgroundColor: $theme.colors.backgroundAccent
27
27
  }), _defineProperty(_HIERARCHY$primary, COLOR.primary, {
28
28
  color: $theme.colors.contentInversePrimary,
29
29
  backgroundColor: $theme.colors.backgroundInversePrimary
30
30
  }), _defineProperty(_HIERARCHY$primary, COLOR.positive, {
31
- color: $theme.colors.contentInversePrimary,
31
+ color: $theme.colors.contentOnColor,
32
32
  backgroundColor: $theme.colors.backgroundPositive
33
33
  }), _defineProperty(_HIERARCHY$primary, COLOR.negative, {
34
- color: $theme.colors.contentInversePrimary,
34
+ color: $theme.colors.contentOnColor,
35
35
  backgroundColor: $theme.colors.backgroundNegative
36
36
  }), _defineProperty(_HIERARCHY$primary, COLOR.warning, {
37
- color: $theme.colors.primaryA,
37
+ color: $theme.colors.contentOnColorInverse,
38
38
  backgroundColor: $theme.colors.backgroundWarning
39
39
  }), _HIERARCHY$primary)), _defineProperty(_COLOR_STYLES, HIERARCHY.secondary, (_HIERARCHY$secondary = {}, _defineProperty(_HIERARCHY$secondary, COLOR.accent, {
40
40
  color: $theme.colors.contentAccent,
@@ -28,7 +28,7 @@ var defaultProps = {
28
28
  ignoreCase: true,
29
29
  isLoading: false,
30
30
  labelKey: 'label',
31
- maxDropdownHeight: '900px',
31
+ maxDropdownHeight: '40vh',
32
32
  multi: false,
33
33
  onBlur: function onBlur() {},
34
34
  onBlurResetsInput: true,
@@ -31,16 +31,26 @@ export var StyledRoot = styled('div', function (_ref) {
31
31
  });
32
32
  StyledRoot.displayName = "StyledRoot";
33
33
  StyledRoot.displayName = 'StyledRoot';
34
- export var StyledTabList = styled('div', function (_ref2) {
35
- var $theme = _ref2.$theme,
36
- _ref2$$fill = _ref2.$fill,
37
- $fill = _ref2$$fill === void 0 ? FILL.intrinsic : _ref2$$fill,
38
- _ref2$$orientation = _ref2.$orientation,
39
- $orientation = _ref2$$orientation === void 0 ? ORIENTATION.horizontal : _ref2$$orientation;
34
+ export var StyledTabBar = styled('div', function (_ref2) {
35
+ var $hasEndEnhancer = _ref2.$hasEndEnhancer,
36
+ $orientation = _ref2.$orientation;
37
+ return $hasEndEnhancer || !isHorizontal($orientation) ? {
38
+ display: 'flex'
39
+ } : {};
40
+ });
41
+ StyledTabBar.displayName = "StyledTabBar";
42
+ StyledTabBar.displayName = 'StyledTabBar';
43
+ export var StyledTabList = styled('div', function (_ref3) {
44
+ var $theme = _ref3.$theme,
45
+ _ref3$$fill = _ref3.$fill,
46
+ $fill = _ref3$$fill === void 0 ? FILL.intrinsic : _ref3$$fill,
47
+ _ref3$$orientation = _ref3.$orientation,
48
+ $orientation = _ref3$$orientation === void 0 ? ORIENTATION.horizontal : _ref3$$orientation;
40
49
  var style = {
41
50
  position: 'relative',
42
51
  display: 'flex',
43
- flexWrap: 'nowrap'
52
+ flexWrap: 'nowrap',
53
+ flexGrow: 1
44
54
  };
45
55
 
46
56
  if (isHorizontal($orientation)) {
@@ -77,16 +87,16 @@ export var StyledTabList = styled('div', function (_ref2) {
77
87
  });
78
88
  StyledTabList.displayName = "StyledTabList";
79
89
  StyledTabList.displayName = 'StyledTabList';
80
- export var StyledTab = styled('button', function (_ref3) {
81
- var $theme = _ref3.$theme,
82
- _ref3$$orientation = _ref3.$orientation,
83
- $orientation = _ref3$$orientation === void 0 ? ORIENTATION.horizontal : _ref3$$orientation,
84
- _ref3$$fill = _ref3.$fill,
85
- $fill = _ref3$$fill === void 0 ? FILL.intrinsic : _ref3$$fill,
86
- _ref3$$focusVisible = _ref3.$focusVisible,
87
- $focusVisible = _ref3$$focusVisible === void 0 ? false : _ref3$$focusVisible,
88
- _ref3$$isActive = _ref3.$isActive,
89
- $isActive = _ref3$$isActive === void 0 ? false : _ref3$$isActive;
90
+ export var StyledTab = styled('button', function (_ref4) {
91
+ var $theme = _ref4.$theme,
92
+ _ref4$$orientation = _ref4.$orientation,
93
+ $orientation = _ref4$$orientation === void 0 ? ORIENTATION.horizontal : _ref4$$orientation,
94
+ _ref4$$fill = _ref4.$fill,
95
+ $fill = _ref4$$fill === void 0 ? FILL.intrinsic : _ref4$$fill,
96
+ _ref4$$focusVisible = _ref4.$focusVisible,
97
+ $focusVisible = _ref4$$focusVisible === void 0 ? false : _ref4$$focusVisible,
98
+ _ref4$$isActive = _ref4.$isActive,
99
+ $isActive = _ref4$$isActive === void 0 ? false : _ref4$$isActive;
90
100
 
91
101
  var style = _objectSpread({
92
102
  cursor: 'pointer',
@@ -148,10 +158,21 @@ export var StyledTab = styled('button', function (_ref3) {
148
158
  });
149
159
  StyledTab.displayName = "StyledTab";
150
160
  StyledTab.displayName = 'StyledTab';
151
- export var StyledArtworkContainer = styled('div', function (_ref4) {
152
- var $theme = _ref4.$theme,
153
- _ref4$$orientation = _ref4.$orientation,
154
- $orientation = _ref4$$orientation === void 0 ? ORIENTATION.horizontal : _ref4$$orientation;
161
+ export var StyledEndEnhancerContainer = styled('div', function (_ref5) {
162
+ var $theme = _ref5.$theme;
163
+ var marginDirection = $theme.direction === 'rtl' ? 'marginRight' : 'marginLeft';
164
+ return _defineProperty({
165
+ display: 'flex',
166
+ alignItems: 'center',
167
+ justifyContent: 'flex-end'
168
+ }, marginDirection, $theme.sizing.scale600);
169
+ });
170
+ StyledEndEnhancerContainer.displayName = "StyledEndEnhancerContainer";
171
+ StyledEndEnhancerContainer.displayName = 'StyledEndEnhancerContainer';
172
+ export var StyledArtworkContainer = styled('div', function (_ref7) {
173
+ var $theme = _ref7.$theme,
174
+ _ref7$$orientation = _ref7.$orientation,
175
+ $orientation = _ref7$$orientation === void 0 ? ORIENTATION.horizontal : _ref7$$orientation;
155
176
  var style = {
156
177
  display: 'flex'
157
178
  };
@@ -166,10 +187,10 @@ export var StyledArtworkContainer = styled('div', function (_ref4) {
166
187
  });
167
188
  StyledArtworkContainer.displayName = "StyledArtworkContainer";
168
189
  StyledArtworkContainer.displayName = 'StyledArtworkContainer';
169
- export var StyledTabBorder = styled('div', function (_ref5) {
170
- var $theme = _ref5.$theme,
171
- _ref5$$orientation = _ref5.$orientation,
172
- $orientation = _ref5$$orientation === void 0 ? ORIENTATION.horizontal : _ref5$$orientation;
190
+ export var StyledTabBorder = styled('div', function (_ref8) {
191
+ var $theme = _ref8.$theme,
192
+ _ref8$$orientation = _ref8.$orientation,
193
+ $orientation = _ref8$$orientation === void 0 ? ORIENTATION.horizontal : _ref8$$orientation;
173
194
  var style = {
174
195
  backgroundColor: $theme.colors.borderOpaque,
175
196
  position: 'relative'
@@ -185,16 +206,16 @@ export var StyledTabBorder = styled('div', function (_ref5) {
185
206
  });
186
207
  StyledTabBorder.displayName = "StyledTabBorder";
187
208
  StyledTabBorder.displayName = 'StyledTabBorder';
188
- export var StyledTabHighlight = styled('div', function (_ref6) {
189
- var $theme = _ref6.$theme,
190
- _ref6$$orientation = _ref6.$orientation,
191
- $orientation = _ref6$$orientation === void 0 ? ORIENTATION.horizontal : _ref6$$orientation,
192
- _ref6$$length = _ref6.$length,
193
- $length = _ref6$$length === void 0 ? 0 : _ref6$$length,
194
- _ref6$$distance = _ref6.$distance,
195
- $distance = _ref6$$distance === void 0 ? 0 : _ref6$$distance,
196
- _ref6$$animate = _ref6.$animate,
197
- $animate = _ref6$$animate === void 0 ? false : _ref6$$animate;
209
+ export var StyledTabHighlight = styled('div', function (_ref9) {
210
+ var $theme = _ref9.$theme,
211
+ _ref9$$orientation = _ref9.$orientation,
212
+ $orientation = _ref9$$orientation === void 0 ? ORIENTATION.horizontal : _ref9$$orientation,
213
+ _ref9$$length = _ref9.$length,
214
+ $length = _ref9$$length === void 0 ? 0 : _ref9$$length,
215
+ _ref9$$distance = _ref9.$distance,
216
+ $distance = _ref9$$distance === void 0 ? 0 : _ref9$$distance,
217
+ _ref9$$animate = _ref9.$animate,
218
+ $animate = _ref9$$animate === void 0 ? false : _ref9$$animate;
198
219
  var style = {
199
220
  backgroundColor: $theme.colors.borderSelected,
200
221
  position: 'absolute',
@@ -229,10 +250,10 @@ export var StyledTabHighlight = styled('div', function (_ref6) {
229
250
  });
230
251
  StyledTabHighlight.displayName = "StyledTabHighlight";
231
252
  StyledTabHighlight.displayName = 'StyledTabHighlight';
232
- export var StyledTabPanel = styled('div', function (_ref7) {
233
- var $theme = _ref7.$theme,
234
- _ref7$$pad = _ref7.$pad,
235
- $pad = _ref7$$pad === void 0 ? true : _ref7$$pad;
253
+ export var StyledTabPanel = styled('div', function (_ref10) {
254
+ var $theme = _ref10.$theme,
255
+ _ref10$$pad = _ref10.$pad,
256
+ $pad = _ref10$$pad === void 0 ? true : _ref10$$pad;
236
257
  var style = {
237
258
  flexGrow: 1,
238
259
  // only used in vertical orientation
@@ -43,12 +43,13 @@ LICENSE file in the root directory of this source tree.
43
43
 
44
44
  /* global window */
45
45
  import * as React from 'react';
46
+ import * as ReactIs from 'react-is';
46
47
  import { useUID } from 'react-uid';
47
48
  import { useStyletron } from '../styles';
48
49
  import { getOverrides } from '../helpers/overrides';
49
50
  import { isFocusVisible, forkFocus, forkBlur } from '../utils/focusVisible';
50
51
  import { ORIENTATION, FILL } from './constants';
51
- import { StyledRoot, StyledTabList, StyledTab, StyledArtworkContainer, StyledTabHighlight, StyledTabBorder, StyledTabPanel } from './styled-components';
52
+ import { StyledRoot, StyledTabList, StyledTab, StyledArtworkContainer, StyledTabHighlight, StyledTabBorder, StyledTabPanel, StyledEndEnhancerContainer, StyledTabBar } from './styled-components';
52
53
  import { getTabId, getTabPanelId, isVertical, isHorizontal, isRTL } from './utils';
53
54
  var KEYBOARD_ACTION = {
54
55
  next: 'next',
@@ -111,25 +112,40 @@ var scrollParentToCentreTarget = function scrollParentToCentreTarget(targetNode)
111
112
  targetNode.parentNode.scroll(target.x, target.y);
112
113
  };
113
114
 
114
- export function Tabs(_ref) {
115
- var _ref$activeKey = _ref.activeKey,
116
- activeKey = _ref$activeKey === void 0 ? '0' : _ref$activeKey,
117
- _ref$disabled = _ref.disabled,
118
- disabled = _ref$disabled === void 0 ? false : _ref$disabled,
119
- children = _ref.children,
120
- _ref$fill = _ref.fill,
121
- fill = _ref$fill === void 0 ? FILL.intrinsic : _ref$fill,
122
- _ref$activateOnFocus = _ref.activateOnFocus,
123
- activateOnFocus = _ref$activateOnFocus === void 0 ? true : _ref$activateOnFocus,
124
- onChange = _ref.onChange,
125
- _ref$orientation = _ref.orientation,
126
- orientation = _ref$orientation === void 0 ? ORIENTATION.horizontal : _ref$orientation,
127
- _ref$overrides = _ref.overrides,
128
- overrides = _ref$overrides === void 0 ? {} : _ref$overrides,
129
- _ref$renderAll = _ref.renderAll,
130
- renderAll = _ref$renderAll === void 0 ? false : _ref$renderAll,
131
- _ref$uid = _ref.uid,
132
- customUid = _ref$uid === void 0 ? null : _ref$uid;
115
+ function RenderEnhancer(_ref) {
116
+ var Enhancer = _ref.Enhancer;
117
+
118
+ if (typeof Enhancer === 'string') {
119
+ return Enhancer;
120
+ }
121
+
122
+ if (ReactIs.isValidElementType(Enhancer)) {
123
+ return /*#__PURE__*/React.createElement(Enhancer, null);
124
+ }
125
+
126
+ return Enhancer;
127
+ }
128
+
129
+ export function Tabs(_ref2) {
130
+ var _ref2$activeKey = _ref2.activeKey,
131
+ activeKey = _ref2$activeKey === void 0 ? '0' : _ref2$activeKey,
132
+ _ref2$disabled = _ref2.disabled,
133
+ disabled = _ref2$disabled === void 0 ? false : _ref2$disabled,
134
+ children = _ref2.children,
135
+ _ref2$fill = _ref2.fill,
136
+ fill = _ref2$fill === void 0 ? FILL.intrinsic : _ref2$fill,
137
+ _ref2$activateOnFocus = _ref2.activateOnFocus,
138
+ activateOnFocus = _ref2$activateOnFocus === void 0 ? true : _ref2$activateOnFocus,
139
+ onChange = _ref2.onChange,
140
+ _ref2$orientation = _ref2.orientation,
141
+ orientation = _ref2$orientation === void 0 ? ORIENTATION.horizontal : _ref2$orientation,
142
+ _ref2$overrides = _ref2.overrides,
143
+ overrides = _ref2$overrides === void 0 ? {} : _ref2$overrides,
144
+ _ref2$renderAll = _ref2.renderAll,
145
+ renderAll = _ref2$renderAll === void 0 ? false : _ref2$renderAll,
146
+ _ref2$uid = _ref2.uid,
147
+ customUid = _ref2$uid === void 0 ? null : _ref2$uid,
148
+ endEnhancer = _ref2.endEnhancer;
133
149
  // Create unique id prefix for this tabs component
134
150
  var generatedUid = useUID();
135
151
  var uid = customUid || generatedUid; // Unpack overrides
@@ -157,7 +173,12 @@ export function Tabs(_ref) {
157
173
  var _getOverrides7 = getOverrides(TabBorderOverrides, StyledTabBorder),
158
174
  _getOverrides8 = _slicedToArray(_getOverrides7, 2),
159
175
  TabBorder = _getOverrides8[0],
160
- TabBorderProps = _getOverrides8[1]; // Count key updates
176
+ TabBorderProps = _getOverrides8[1];
177
+
178
+ var _getOverrides9 = getOverrides(overrides.EndEnhancerContainer, StyledEndEnhancerContainer),
179
+ _getOverrides10 = _slicedToArray(_getOverrides9, 2),
180
+ EndEnhancerContainer = _getOverrides10[0],
181
+ endEnhancerContainerProps = _getOverrides10[1]; // Count key updates
161
182
  // We disable a few things until after first mount:
162
183
  // - the highlight animation, avoiding an initial slide-in
163
184
  // - smooth scrolling active tab into view
@@ -263,7 +284,10 @@ export function Tabs(_ref) {
263
284
  }
264
285
  }
265
286
  }, [orientation, theme.direction]);
266
- return /*#__PURE__*/React.createElement(Root, _extends({}, sharedStylingProps, RootProps), /*#__PURE__*/React.createElement(TabList, _extends({
287
+ return /*#__PURE__*/React.createElement(Root, _extends({}, sharedStylingProps, RootProps), /*#__PURE__*/React.createElement(StyledTabBar, {
288
+ $hasEndEnhancer: Boolean(endEnhancer),
289
+ $orientation: orientation
290
+ }, /*#__PURE__*/React.createElement(TabList, _extends({
267
291
  "data-baseweb": "tab-list",
268
292
  role: "tablist",
269
293
  "aria-orientation": orientation
@@ -291,7 +315,11 @@ export function Tabs(_ref) {
291
315
  $animate: keyUpdated > 1,
292
316
  "aria-hidden": "true",
293
317
  role: "presentation"
294
- }, sharedStylingProps, TabHighlightProps))), /*#__PURE__*/React.createElement(TabBorder, _extends({
318
+ }, sharedStylingProps, TabHighlightProps))), orientation === ORIENTATION.horizontal && endEnhancer !== null && endEnhancer !== undefined && /*#__PURE__*/React.createElement(EndEnhancerContainer, _extends({}, endEnhancerContainerProps, {
319
+ $orientation: orientation
320
+ }), /*#__PURE__*/React.createElement(RenderEnhancer, {
321
+ Enhancer: endEnhancer
322
+ }))), /*#__PURE__*/React.createElement(TabBorder, _extends({
295
323
  "data-baseweb": "tab-border",
296
324
  "aria-hidden": "true",
297
325
  role: "presentation"
@@ -308,20 +336,20 @@ export function Tabs(_ref) {
308
336
  }));
309
337
  }
310
338
 
311
- function InternalTab(_ref2) {
312
- var childKey = _ref2.childKey,
313
- childIndex = _ref2.childIndex,
314
- activeKey = _ref2.activeKey,
315
- orientation = _ref2.orientation,
316
- activeTabRef = _ref2.activeTabRef,
317
- updateHighlight = _ref2.updateHighlight,
318
- parseKeyDown = _ref2.parseKeyDown,
319
- activateOnFocus = _ref2.activateOnFocus,
320
- uid = _ref2.uid,
321
- disabled = _ref2.disabled,
322
- sharedStylingProps = _ref2.sharedStylingProps,
323
- onChange = _ref2.onChange,
324
- props = _objectWithoutProperties(_ref2, _excluded);
339
+ function InternalTab(_ref3) {
340
+ var childKey = _ref3.childKey,
341
+ childIndex = _ref3.childIndex,
342
+ activeKey = _ref3.activeKey,
343
+ orientation = _ref3.orientation,
344
+ activeTabRef = _ref3.activeTabRef,
345
+ updateHighlight = _ref3.updateHighlight,
346
+ parseKeyDown = _ref3.parseKeyDown,
347
+ activateOnFocus = _ref3.activateOnFocus,
348
+ uid = _ref3.uid,
349
+ disabled = _ref3.disabled,
350
+ sharedStylingProps = _ref3.sharedStylingProps,
351
+ onChange = _ref3.onChange,
352
+ props = _objectWithoutProperties(_ref3, _excluded);
325
353
 
326
354
  var key = childKey || String(childIndex);
327
355
  var isActive = key == activeKey;
@@ -372,15 +400,15 @@ function InternalTab(_ref2) {
372
400
  var TabOverrides = overrides.Tab,
373
401
  ArtworkContainerOverrides = overrides.ArtworkContainer;
374
402
 
375
- var _getOverrides9 = getOverrides(TabOverrides, StyledTab),
376
- _getOverrides10 = _slicedToArray(_getOverrides9, 2),
377
- Tab = _getOverrides10[0],
378
- TabProps = _getOverrides10[1];
379
-
380
- var _getOverrides11 = getOverrides(ArtworkContainerOverrides, StyledArtworkContainer),
403
+ var _getOverrides11 = getOverrides(TabOverrides, StyledTab),
381
404
  _getOverrides12 = _slicedToArray(_getOverrides11, 2),
382
- ArtworkContainer = _getOverrides12[0],
383
- ArtworkContainerProps = _getOverrides12[1]; // Keyboard focus styling
405
+ Tab = _getOverrides12[0],
406
+ TabProps = _getOverrides12[1];
407
+
408
+ var _getOverrides13 = getOverrides(ArtworkContainerOverrides, StyledArtworkContainer),
409
+ _getOverrides14 = _slicedToArray(_getOverrides13, 2),
410
+ ArtworkContainer = _getOverrides14[0],
411
+ ArtworkContainerProps = _getOverrides14[1]; // Keyboard focus styling
384
412
 
385
413
 
386
414
  var _React$useState5 = React.useState(false),
@@ -480,14 +508,14 @@ function InternalTab(_ref2) {
480
508
  })) : null, title ? title : key);
481
509
  }
482
510
 
483
- function InternalTabPanel(_ref3) {
484
- var childKey = _ref3.childKey,
485
- childIndex = _ref3.childIndex,
486
- activeKey = _ref3.activeKey,
487
- uid = _ref3.uid,
488
- sharedStylingProps = _ref3.sharedStylingProps,
489
- renderAll = _ref3.renderAll,
490
- props = _objectWithoutProperties(_ref3, _excluded3);
511
+ function InternalTabPanel(_ref4) {
512
+ var childKey = _ref4.childKey,
513
+ childIndex = _ref4.childIndex,
514
+ activeKey = _ref4.activeKey,
515
+ uid = _ref4.uid,
516
+ sharedStylingProps = _ref4.sharedStylingProps,
517
+ renderAll = _ref4.renderAll,
518
+ props = _objectWithoutProperties(_ref4, _excluded3);
491
519
 
492
520
  var key = childKey || String(childIndex);
493
521
  var isActive = key == activeKey;
@@ -496,10 +524,10 @@ function InternalTabPanel(_ref3) {
496
524
  children = props.children;
497
525
  var TabPanelOverrides = overrides.TabPanel;
498
526
 
499
- var _getOverrides13 = getOverrides(TabPanelOverrides, StyledTabPanel),
500
- _getOverrides14 = _slicedToArray(_getOverrides13, 2),
501
- TabPanel = _getOverrides14[0],
502
- TabPanelProps = _getOverrides14[1];
527
+ var _getOverrides15 = getOverrides(TabPanelOverrides, StyledTabPanel),
528
+ _getOverrides16 = _slicedToArray(_getOverrides15, 2),
529
+ TabPanel = _getOverrides16[0],
530
+ TabPanelProps = _getOverrides16[1];
503
531
 
504
532
  return /*#__PURE__*/React.createElement(TabPanel, _extends({
505
533
  "data-baseweb": "tab-panel",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "baseui",
3
- "version": "0.0.0-next-0b9fd6a",
3
+ "version": "0.0.0-next-e0f9354",
4
4
  "description": "A React Component library implementing the Base design language",
5
5
  "keywords": [
6
6
  "react",
@@ -39,7 +39,7 @@ var defaultProps = {
39
39
  ignoreCase: true,
40
40
  isLoading: false,
41
41
  labelKey: 'label',
42
- maxDropdownHeight: '900px',
42
+ maxDropdownHeight: '40vh',
43
43
  multi: false,
44
44
  onBlur: function onBlur() {},
45
45
  onBlurResetsInput: true,
@@ -2,6 +2,10 @@ import type { Orientation, Fill } from './types';
2
2
  export declare const StyledRoot: import("styletron-react").StyletronComponent<"div", {
3
3
  $orientation?: Orientation;
4
4
  }>;
5
+ export declare const StyledTabBar: import("styletron-react").StyletronComponent<"div", {
6
+ $hasEndEnhancer: boolean;
7
+ $orientation: Orientation;
8
+ }>;
5
9
  export declare const StyledTabList: import("styletron-react").StyletronComponent<"div", {
6
10
  $orientation?: Orientation;
7
11
  $fill?: Fill;
@@ -12,6 +16,7 @@ export declare const StyledTab: import("styletron-react").StyletronComponent<"bu
12
16
  $focusVisible?: boolean;
13
17
  $isActive?: boolean;
14
18
  }>;
19
+ export declare const StyledEndEnhancerContainer: import("styletron-react").StyletronComponent<"div", {}>;
15
20
  export declare const StyledArtworkContainer: import("styletron-react").StyletronComponent<"div", {
16
21
  $orientation?: Orientation;
17
22
  }>;
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.StyledTabPanel = exports.StyledTabList = exports.StyledTabHighlight = exports.StyledTabBorder = exports.StyledTab = exports.StyledRoot = exports.StyledArtworkContainer = void 0;
6
+ exports.StyledTabPanel = exports.StyledTabList = exports.StyledTabHighlight = exports.StyledTabBorder = exports.StyledTabBar = exports.StyledTab = exports.StyledRoot = exports.StyledEndEnhancerContainer = exports.StyledArtworkContainer = void 0;
7
7
 
8
8
  var _styles = require("../styles");
9
9
 
@@ -36,16 +36,27 @@ var StyledRoot = (0, _styles.styled)('div', function (_ref) {
36
36
  exports.StyledRoot = StyledRoot;
37
37
  StyledRoot.displayName = "StyledRoot";
38
38
  StyledRoot.displayName = 'StyledRoot';
39
- var StyledTabList = (0, _styles.styled)('div', function (_ref2) {
40
- var $theme = _ref2.$theme,
41
- _ref2$$fill = _ref2.$fill,
42
- $fill = _ref2$$fill === void 0 ? _constants.FILL.intrinsic : _ref2$$fill,
43
- _ref2$$orientation = _ref2.$orientation,
44
- $orientation = _ref2$$orientation === void 0 ? _constants.ORIENTATION.horizontal : _ref2$$orientation;
39
+ var StyledTabBar = (0, _styles.styled)('div', function (_ref2) {
40
+ var $hasEndEnhancer = _ref2.$hasEndEnhancer,
41
+ $orientation = _ref2.$orientation;
42
+ return $hasEndEnhancer || !(0, _utils.isHorizontal)($orientation) ? {
43
+ display: 'flex'
44
+ } : {};
45
+ });
46
+ exports.StyledTabBar = StyledTabBar;
47
+ StyledTabBar.displayName = "StyledTabBar";
48
+ StyledTabBar.displayName = 'StyledTabBar';
49
+ var StyledTabList = (0, _styles.styled)('div', function (_ref3) {
50
+ var $theme = _ref3.$theme,
51
+ _ref3$$fill = _ref3.$fill,
52
+ $fill = _ref3$$fill === void 0 ? _constants.FILL.intrinsic : _ref3$$fill,
53
+ _ref3$$orientation = _ref3.$orientation,
54
+ $orientation = _ref3$$orientation === void 0 ? _constants.ORIENTATION.horizontal : _ref3$$orientation;
45
55
  var style = {
46
56
  position: 'relative',
47
57
  display: 'flex',
48
- flexWrap: 'nowrap'
58
+ flexWrap: 'nowrap',
59
+ flexGrow: 1
49
60
  };
50
61
 
51
62
  if ((0, _utils.isHorizontal)($orientation)) {
@@ -83,16 +94,16 @@ var StyledTabList = (0, _styles.styled)('div', function (_ref2) {
83
94
  exports.StyledTabList = StyledTabList;
84
95
  StyledTabList.displayName = "StyledTabList";
85
96
  StyledTabList.displayName = 'StyledTabList';
86
- var StyledTab = (0, _styles.styled)('button', function (_ref3) {
87
- var $theme = _ref3.$theme,
88
- _ref3$$orientation = _ref3.$orientation,
89
- $orientation = _ref3$$orientation === void 0 ? _constants.ORIENTATION.horizontal : _ref3$$orientation,
90
- _ref3$$fill = _ref3.$fill,
91
- $fill = _ref3$$fill === void 0 ? _constants.FILL.intrinsic : _ref3$$fill,
92
- _ref3$$focusVisible = _ref3.$focusVisible,
93
- $focusVisible = _ref3$$focusVisible === void 0 ? false : _ref3$$focusVisible,
94
- _ref3$$isActive = _ref3.$isActive,
95
- $isActive = _ref3$$isActive === void 0 ? false : _ref3$$isActive;
97
+ var StyledTab = (0, _styles.styled)('button', function (_ref4) {
98
+ var $theme = _ref4.$theme,
99
+ _ref4$$orientation = _ref4.$orientation,
100
+ $orientation = _ref4$$orientation === void 0 ? _constants.ORIENTATION.horizontal : _ref4$$orientation,
101
+ _ref4$$fill = _ref4.$fill,
102
+ $fill = _ref4$$fill === void 0 ? _constants.FILL.intrinsic : _ref4$$fill,
103
+ _ref4$$focusVisible = _ref4.$focusVisible,
104
+ $focusVisible = _ref4$$focusVisible === void 0 ? false : _ref4$$focusVisible,
105
+ _ref4$$isActive = _ref4.$isActive,
106
+ $isActive = _ref4$$isActive === void 0 ? false : _ref4$$isActive;
96
107
 
97
108
  var style = _objectSpread({
98
109
  cursor: 'pointer',
@@ -155,10 +166,22 @@ var StyledTab = (0, _styles.styled)('button', function (_ref3) {
155
166
  exports.StyledTab = StyledTab;
156
167
  StyledTab.displayName = "StyledTab";
157
168
  StyledTab.displayName = 'StyledTab';
158
- var StyledArtworkContainer = (0, _styles.styled)('div', function (_ref4) {
159
- var $theme = _ref4.$theme,
160
- _ref4$$orientation = _ref4.$orientation,
161
- $orientation = _ref4$$orientation === void 0 ? _constants.ORIENTATION.horizontal : _ref4$$orientation;
169
+ var StyledEndEnhancerContainer = (0, _styles.styled)('div', function (_ref5) {
170
+ var $theme = _ref5.$theme;
171
+ var marginDirection = $theme.direction === 'rtl' ? 'marginRight' : 'marginLeft';
172
+ return _defineProperty({
173
+ display: 'flex',
174
+ alignItems: 'center',
175
+ justifyContent: 'flex-end'
176
+ }, marginDirection, $theme.sizing.scale600);
177
+ });
178
+ exports.StyledEndEnhancerContainer = StyledEndEnhancerContainer;
179
+ StyledEndEnhancerContainer.displayName = "StyledEndEnhancerContainer";
180
+ StyledEndEnhancerContainer.displayName = 'StyledEndEnhancerContainer';
181
+ var StyledArtworkContainer = (0, _styles.styled)('div', function (_ref7) {
182
+ var $theme = _ref7.$theme,
183
+ _ref7$$orientation = _ref7.$orientation,
184
+ $orientation = _ref7$$orientation === void 0 ? _constants.ORIENTATION.horizontal : _ref7$$orientation;
162
185
  var style = {
163
186
  display: 'flex'
164
187
  };
@@ -174,10 +197,10 @@ var StyledArtworkContainer = (0, _styles.styled)('div', function (_ref4) {
174
197
  exports.StyledArtworkContainer = StyledArtworkContainer;
175
198
  StyledArtworkContainer.displayName = "StyledArtworkContainer";
176
199
  StyledArtworkContainer.displayName = 'StyledArtworkContainer';
177
- var StyledTabBorder = (0, _styles.styled)('div', function (_ref5) {
178
- var $theme = _ref5.$theme,
179
- _ref5$$orientation = _ref5.$orientation,
180
- $orientation = _ref5$$orientation === void 0 ? _constants.ORIENTATION.horizontal : _ref5$$orientation;
200
+ var StyledTabBorder = (0, _styles.styled)('div', function (_ref8) {
201
+ var $theme = _ref8.$theme,
202
+ _ref8$$orientation = _ref8.$orientation,
203
+ $orientation = _ref8$$orientation === void 0 ? _constants.ORIENTATION.horizontal : _ref8$$orientation;
181
204
  var style = {
182
205
  backgroundColor: $theme.colors.borderOpaque,
183
206
  position: 'relative'
@@ -194,16 +217,16 @@ var StyledTabBorder = (0, _styles.styled)('div', function (_ref5) {
194
217
  exports.StyledTabBorder = StyledTabBorder;
195
218
  StyledTabBorder.displayName = "StyledTabBorder";
196
219
  StyledTabBorder.displayName = 'StyledTabBorder';
197
- var StyledTabHighlight = (0, _styles.styled)('div', function (_ref6) {
198
- var $theme = _ref6.$theme,
199
- _ref6$$orientation = _ref6.$orientation,
200
- $orientation = _ref6$$orientation === void 0 ? _constants.ORIENTATION.horizontal : _ref6$$orientation,
201
- _ref6$$length = _ref6.$length,
202
- $length = _ref6$$length === void 0 ? 0 : _ref6$$length,
203
- _ref6$$distance = _ref6.$distance,
204
- $distance = _ref6$$distance === void 0 ? 0 : _ref6$$distance,
205
- _ref6$$animate = _ref6.$animate,
206
- $animate = _ref6$$animate === void 0 ? false : _ref6$$animate;
220
+ var StyledTabHighlight = (0, _styles.styled)('div', function (_ref9) {
221
+ var $theme = _ref9.$theme,
222
+ _ref9$$orientation = _ref9.$orientation,
223
+ $orientation = _ref9$$orientation === void 0 ? _constants.ORIENTATION.horizontal : _ref9$$orientation,
224
+ _ref9$$length = _ref9.$length,
225
+ $length = _ref9$$length === void 0 ? 0 : _ref9$$length,
226
+ _ref9$$distance = _ref9.$distance,
227
+ $distance = _ref9$$distance === void 0 ? 0 : _ref9$$distance,
228
+ _ref9$$animate = _ref9.$animate,
229
+ $animate = _ref9$$animate === void 0 ? false : _ref9$$animate;
207
230
  var style = {
208
231
  backgroundColor: $theme.colors.borderSelected,
209
232
  position: 'absolute',
@@ -239,10 +262,10 @@ var StyledTabHighlight = (0, _styles.styled)('div', function (_ref6) {
239
262
  exports.StyledTabHighlight = StyledTabHighlight;
240
263
  StyledTabHighlight.displayName = "StyledTabHighlight";
241
264
  StyledTabHighlight.displayName = 'StyledTabHighlight';
242
- var StyledTabPanel = (0, _styles.styled)('div', function (_ref7) {
243
- var $theme = _ref7.$theme,
244
- _ref7$$pad = _ref7.$pad,
245
- $pad = _ref7$$pad === void 0 ? true : _ref7$$pad;
265
+ var StyledTabPanel = (0, _styles.styled)('div', function (_ref10) {
266
+ var $theme = _ref10.$theme,
267
+ _ref10$$pad = _ref10.$pad,
268
+ $pad = _ref10$$pad === void 0 ? true : _ref10$$pad;
246
269
  var style = {
247
270
  flexGrow: 1,
248
271
  // only used in vertical orientation
@@ -29,6 +29,16 @@ export const StyledRoot = styled<{ $orientation?: OrientationT }>(
29
29
  }
30
30
  );
31
31
 
32
+ export const StyledTabBar = styled<{ $hasEndEnhancer: boolean, $orientation: OrientationT }>(
33
+ 'div',
34
+ ({ $hasEndEnhancer, $orientation }) =>
35
+ $hasEndEnhancer || !isHorizontal($orientation)
36
+ ? {
37
+ display: 'flex',
38
+ }
39
+ : {}
40
+ );
41
+
32
42
  export const StyledTabList = styled<{
33
43
  $orientation?: OrientationT,
34
44
  $fill?: FillT,
@@ -37,6 +47,7 @@ export const StyledTabList = styled<{
37
47
  position: 'relative',
38
48
  display: 'flex',
39
49
  flexWrap: 'nowrap',
50
+ flexGrow: 1,
40
51
  };
41
52
  if (isHorizontal($orientation)) {
42
53
  style.flexDirection = 'row';
@@ -137,6 +148,16 @@ export const StyledTab = styled<{
137
148
  }
138
149
  );
139
150
 
151
+ export const StyledEndEnhancerContainer = styled<{}>('div', ({ $theme }) => {
152
+ const marginDirection: string = $theme.direction === 'rtl' ? 'marginRight' : 'marginLeft';
153
+ return {
154
+ display: 'flex',
155
+ alignItems: 'center',
156
+ justifyContent: 'flex-end',
157
+ [marginDirection]: $theme.sizing.scale600,
158
+ };
159
+ });
160
+
140
161
  export const StyledArtworkContainer = styled<{ $orientation?: OrientationT }>(
141
162
  'div',
142
163
  ({ $theme, $orientation = ORIENTATION.horizontal }) => {
@@ -1,3 +1,3 @@
1
1
  /// <reference types="react" />
2
2
  import type { TabsProps } from './types';
3
- export declare function Tabs({ activeKey, disabled, children, fill, activateOnFocus, onChange, orientation, overrides, renderAll, uid: customUid, }: TabsProps): JSX.Element;
3
+ export declare function Tabs({ activeKey, disabled, children, fill, activateOnFocus, onChange, orientation, overrides, renderAll, uid: customUid, endEnhancer, }: TabsProps): JSX.Element;
@@ -9,6 +9,8 @@ exports.Tabs = Tabs;
9
9
 
10
10
  var React = _interopRequireWildcard(require("react"));
11
11
 
12
+ var ReactIs = _interopRequireWildcard(require("react-is"));
13
+
12
14
  var _reactUid = require("react-uid");
13
15
 
14
16
  var _styles = require("../styles");
@@ -124,25 +126,40 @@ var scrollParentToCentreTarget = function scrollParentToCentreTarget(targetNode)
124
126
  targetNode.parentNode.scroll(target.x, target.y);
125
127
  };
126
128
 
127
- function Tabs(_ref) {
128
- var _ref$activeKey = _ref.activeKey,
129
- activeKey = _ref$activeKey === void 0 ? '0' : _ref$activeKey,
130
- _ref$disabled = _ref.disabled,
131
- disabled = _ref$disabled === void 0 ? false : _ref$disabled,
132
- children = _ref.children,
133
- _ref$fill = _ref.fill,
134
- fill = _ref$fill === void 0 ? _constants.FILL.intrinsic : _ref$fill,
135
- _ref$activateOnFocus = _ref.activateOnFocus,
136
- activateOnFocus = _ref$activateOnFocus === void 0 ? true : _ref$activateOnFocus,
137
- onChange = _ref.onChange,
138
- _ref$orientation = _ref.orientation,
139
- orientation = _ref$orientation === void 0 ? _constants.ORIENTATION.horizontal : _ref$orientation,
140
- _ref$overrides = _ref.overrides,
141
- overrides = _ref$overrides === void 0 ? {} : _ref$overrides,
142
- _ref$renderAll = _ref.renderAll,
143
- renderAll = _ref$renderAll === void 0 ? false : _ref$renderAll,
144
- _ref$uid = _ref.uid,
145
- customUid = _ref$uid === void 0 ? null : _ref$uid;
129
+ function RenderEnhancer(_ref) {
130
+ var Enhancer = _ref.Enhancer;
131
+
132
+ if (typeof Enhancer === 'string') {
133
+ return Enhancer;
134
+ }
135
+
136
+ if (ReactIs.isValidElementType(Enhancer)) {
137
+ return /*#__PURE__*/React.createElement(Enhancer, null);
138
+ }
139
+
140
+ return Enhancer;
141
+ }
142
+
143
+ function Tabs(_ref2) {
144
+ var _ref2$activeKey = _ref2.activeKey,
145
+ activeKey = _ref2$activeKey === void 0 ? '0' : _ref2$activeKey,
146
+ _ref2$disabled = _ref2.disabled,
147
+ disabled = _ref2$disabled === void 0 ? false : _ref2$disabled,
148
+ children = _ref2.children,
149
+ _ref2$fill = _ref2.fill,
150
+ fill = _ref2$fill === void 0 ? _constants.FILL.intrinsic : _ref2$fill,
151
+ _ref2$activateOnFocus = _ref2.activateOnFocus,
152
+ activateOnFocus = _ref2$activateOnFocus === void 0 ? true : _ref2$activateOnFocus,
153
+ onChange = _ref2.onChange,
154
+ _ref2$orientation = _ref2.orientation,
155
+ orientation = _ref2$orientation === void 0 ? _constants.ORIENTATION.horizontal : _ref2$orientation,
156
+ _ref2$overrides = _ref2.overrides,
157
+ overrides = _ref2$overrides === void 0 ? {} : _ref2$overrides,
158
+ _ref2$renderAll = _ref2.renderAll,
159
+ renderAll = _ref2$renderAll === void 0 ? false : _ref2$renderAll,
160
+ _ref2$uid = _ref2.uid,
161
+ customUid = _ref2$uid === void 0 ? null : _ref2$uid,
162
+ endEnhancer = _ref2.endEnhancer;
146
163
  // Create unique id prefix for this tabs component
147
164
  var generatedUid = (0, _reactUid.useUID)();
148
165
  var uid = customUid || generatedUid; // Unpack overrides
@@ -170,7 +187,12 @@ function Tabs(_ref) {
170
187
  var _getOverrides7 = (0, _overrides.getOverrides)(TabBorderOverrides, _styledComponents.StyledTabBorder),
171
188
  _getOverrides8 = _slicedToArray(_getOverrides7, 2),
172
189
  TabBorder = _getOverrides8[0],
173
- TabBorderProps = _getOverrides8[1]; // Count key updates
190
+ TabBorderProps = _getOverrides8[1];
191
+
192
+ var _getOverrides9 = (0, _overrides.getOverrides)(overrides.EndEnhancerContainer, _styledComponents.StyledEndEnhancerContainer),
193
+ _getOverrides10 = _slicedToArray(_getOverrides9, 2),
194
+ EndEnhancerContainer = _getOverrides10[0],
195
+ endEnhancerContainerProps = _getOverrides10[1]; // Count key updates
174
196
  // We disable a few things until after first mount:
175
197
  // - the highlight animation, avoiding an initial slide-in
176
198
  // - smooth scrolling active tab into view
@@ -276,7 +298,10 @@ function Tabs(_ref) {
276
298
  }
277
299
  }
278
300
  }, [orientation, theme.direction]);
279
- return /*#__PURE__*/React.createElement(Root, _extends({}, sharedStylingProps, RootProps), /*#__PURE__*/React.createElement(TabList, _extends({
301
+ return /*#__PURE__*/React.createElement(Root, _extends({}, sharedStylingProps, RootProps), /*#__PURE__*/React.createElement(_styledComponents.StyledTabBar, {
302
+ $hasEndEnhancer: Boolean(endEnhancer),
303
+ $orientation: orientation
304
+ }, /*#__PURE__*/React.createElement(TabList, _extends({
280
305
  "data-baseweb": "tab-list",
281
306
  role: "tablist",
282
307
  "aria-orientation": orientation
@@ -304,7 +329,11 @@ function Tabs(_ref) {
304
329
  $animate: keyUpdated > 1,
305
330
  "aria-hidden": "true",
306
331
  role: "presentation"
307
- }, sharedStylingProps, TabHighlightProps))), /*#__PURE__*/React.createElement(TabBorder, _extends({
332
+ }, sharedStylingProps, TabHighlightProps))), orientation === _constants.ORIENTATION.horizontal && endEnhancer !== null && endEnhancer !== undefined && /*#__PURE__*/React.createElement(EndEnhancerContainer, _extends({}, endEnhancerContainerProps, {
333
+ $orientation: orientation
334
+ }), /*#__PURE__*/React.createElement(RenderEnhancer, {
335
+ Enhancer: endEnhancer
336
+ }))), /*#__PURE__*/React.createElement(TabBorder, _extends({
308
337
  "data-baseweb": "tab-border",
309
338
  "aria-hidden": "true",
310
339
  role: "presentation"
@@ -321,20 +350,20 @@ function Tabs(_ref) {
321
350
  }));
322
351
  }
323
352
 
324
- function InternalTab(_ref2) {
325
- var childKey = _ref2.childKey,
326
- childIndex = _ref2.childIndex,
327
- activeKey = _ref2.activeKey,
328
- orientation = _ref2.orientation,
329
- activeTabRef = _ref2.activeTabRef,
330
- updateHighlight = _ref2.updateHighlight,
331
- parseKeyDown = _ref2.parseKeyDown,
332
- activateOnFocus = _ref2.activateOnFocus,
333
- uid = _ref2.uid,
334
- disabled = _ref2.disabled,
335
- sharedStylingProps = _ref2.sharedStylingProps,
336
- onChange = _ref2.onChange,
337
- props = _objectWithoutProperties(_ref2, _excluded);
353
+ function InternalTab(_ref3) {
354
+ var childKey = _ref3.childKey,
355
+ childIndex = _ref3.childIndex,
356
+ activeKey = _ref3.activeKey,
357
+ orientation = _ref3.orientation,
358
+ activeTabRef = _ref3.activeTabRef,
359
+ updateHighlight = _ref3.updateHighlight,
360
+ parseKeyDown = _ref3.parseKeyDown,
361
+ activateOnFocus = _ref3.activateOnFocus,
362
+ uid = _ref3.uid,
363
+ disabled = _ref3.disabled,
364
+ sharedStylingProps = _ref3.sharedStylingProps,
365
+ onChange = _ref3.onChange,
366
+ props = _objectWithoutProperties(_ref3, _excluded);
338
367
 
339
368
  var key = childKey || String(childIndex);
340
369
  var isActive = key == activeKey;
@@ -385,15 +414,15 @@ function InternalTab(_ref2) {
385
414
  var TabOverrides = overrides.Tab,
386
415
  ArtworkContainerOverrides = overrides.ArtworkContainer;
387
416
 
388
- var _getOverrides9 = (0, _overrides.getOverrides)(TabOverrides, _styledComponents.StyledTab),
389
- _getOverrides10 = _slicedToArray(_getOverrides9, 2),
390
- Tab = _getOverrides10[0],
391
- TabProps = _getOverrides10[1];
392
-
393
- var _getOverrides11 = (0, _overrides.getOverrides)(ArtworkContainerOverrides, _styledComponents.StyledArtworkContainer),
417
+ var _getOverrides11 = (0, _overrides.getOverrides)(TabOverrides, _styledComponents.StyledTab),
394
418
  _getOverrides12 = _slicedToArray(_getOverrides11, 2),
395
- ArtworkContainer = _getOverrides12[0],
396
- ArtworkContainerProps = _getOverrides12[1]; // Keyboard focus styling
419
+ Tab = _getOverrides12[0],
420
+ TabProps = _getOverrides12[1];
421
+
422
+ var _getOverrides13 = (0, _overrides.getOverrides)(ArtworkContainerOverrides, _styledComponents.StyledArtworkContainer),
423
+ _getOverrides14 = _slicedToArray(_getOverrides13, 2),
424
+ ArtworkContainer = _getOverrides14[0],
425
+ ArtworkContainerProps = _getOverrides14[1]; // Keyboard focus styling
397
426
 
398
427
 
399
428
  var _React$useState5 = React.useState(false),
@@ -493,14 +522,14 @@ function InternalTab(_ref2) {
493
522
  })) : null, title ? title : key);
494
523
  }
495
524
 
496
- function InternalTabPanel(_ref3) {
497
- var childKey = _ref3.childKey,
498
- childIndex = _ref3.childIndex,
499
- activeKey = _ref3.activeKey,
500
- uid = _ref3.uid,
501
- sharedStylingProps = _ref3.sharedStylingProps,
502
- renderAll = _ref3.renderAll,
503
- props = _objectWithoutProperties(_ref3, _excluded3);
525
+ function InternalTabPanel(_ref4) {
526
+ var childKey = _ref4.childKey,
527
+ childIndex = _ref4.childIndex,
528
+ activeKey = _ref4.activeKey,
529
+ uid = _ref4.uid,
530
+ sharedStylingProps = _ref4.sharedStylingProps,
531
+ renderAll = _ref4.renderAll,
532
+ props = _objectWithoutProperties(_ref4, _excluded3);
504
533
 
505
534
  var key = childKey || String(childIndex);
506
535
  var isActive = key == activeKey;
@@ -509,10 +538,10 @@ function InternalTabPanel(_ref3) {
509
538
  children = props.children;
510
539
  var TabPanelOverrides = overrides.TabPanel;
511
540
 
512
- var _getOverrides13 = (0, _overrides.getOverrides)(TabPanelOverrides, _styledComponents.StyledTabPanel),
513
- _getOverrides14 = _slicedToArray(_getOverrides13, 2),
514
- TabPanel = _getOverrides14[0],
515
- TabPanelProps = _getOverrides14[1];
541
+ var _getOverrides15 = (0, _overrides.getOverrides)(TabPanelOverrides, _styledComponents.StyledTabPanel),
542
+ _getOverrides16 = _slicedToArray(_getOverrides15, 2),
543
+ TabPanel = _getOverrides16[0],
544
+ TabPanelProps = _getOverrides16[1];
516
545
 
517
546
  return /*#__PURE__*/React.createElement(TabPanel, _extends({
518
547
  "data-baseweb": "tab-panel",
@@ -10,6 +10,7 @@ LICENSE file in the root directory of this source tree.
10
10
  /* global window */
11
11
 
12
12
  import * as React from 'react';
13
+ import * as ReactIs from 'react-is';
13
14
  import { useUID } from 'react-uid';
14
15
  import { useStyletron } from '../styles/index.js';
15
16
  import { getOverrides } from '../helpers/overrides.js';
@@ -23,6 +24,8 @@ import {
23
24
  StyledTabHighlight,
24
25
  StyledTabBorder,
25
26
  StyledTabPanel,
27
+ StyledEndEnhancerContainer,
28
+ StyledTabBar,
26
29
  } from './styled-components.js';
27
30
  import { getTabId, getTabPanelId, isVertical, isHorizontal, isRTL } from './utils.js';
28
31
 
@@ -88,6 +91,18 @@ const scrollParentToCentreTarget = (targetNode) => {
88
91
  targetNode.parentNode.scroll(target.x, target.y);
89
92
  };
90
93
 
94
+ function RenderEnhancer({ Enhancer }) {
95
+ if (typeof Enhancer === 'string') {
96
+ return Enhancer;
97
+ }
98
+ if (ReactIs.isValidElementType(Enhancer)) {
99
+ // $FlowFixMe
100
+ return <Enhancer />;
101
+ }
102
+ // $FlowFixMe
103
+ return Enhancer;
104
+ }
105
+
91
106
  export function Tabs({
92
107
  activeKey = '0',
93
108
  disabled = false,
@@ -99,6 +114,7 @@ export function Tabs({
99
114
  overrides = {},
100
115
  renderAll = false,
101
116
  uid: customUid = null,
117
+ endEnhancer,
102
118
  }: TabsPropsT) {
103
119
  // Create unique id prefix for this tabs component
104
120
  const generatedUid = useUID();
@@ -115,6 +131,10 @@ export function Tabs({
115
131
  const [TabList, TabListProps] = getOverrides(TabListOverrides, StyledTabList);
116
132
  const [TabHighlight, TabHighlightProps] = getOverrides(TabHighlightOverrides, StyledTabHighlight);
117
133
  const [TabBorder, TabBorderProps] = getOverrides(TabBorderOverrides, StyledTabBorder);
134
+ const [EndEnhancerContainer, endEnhancerContainerProps] = getOverrides(
135
+ overrides.EndEnhancerContainer,
136
+ StyledEndEnhancerContainer
137
+ );
118
138
 
119
139
  // Count key updates
120
140
  // We disable a few things until after first mount:
@@ -216,45 +236,56 @@ export function Tabs({
216
236
 
217
237
  return (
218
238
  <Root {...sharedStylingProps} {...RootProps}>
219
- <TabList
220
- data-baseweb="tab-list"
221
- role="tablist"
222
- aria-orientation={orientation}
223
- {...sharedStylingProps}
224
- {...TabListProps}
225
- >
226
- {React.Children.map(children, (child, index) => {
227
- if (!child) return;
228
- return (
229
- <InternalTab
230
- childKey={child.key}
231
- childIndex={index}
232
- activeKey={activeKey}
233
- orientation={orientation}
234
- activeTabRef={activeTabRef}
235
- updateHighlight={updateHighlight}
236
- parseKeyDown={parseKeyDown}
237
- activateOnFocus={activateOnFocus}
238
- uid={uid}
239
- disabled={disabled}
240
- sharedStylingProps={sharedStylingProps}
241
- onChange={onChange}
242
- {...child.props}
243
- />
244
- );
245
- })}
246
- <TabHighlight
247
- data-baseweb="tab-highlight"
248
- $length={highlightLayout.length}
249
- $distance={highlightLayout.distance}
250
- // This avoids the tab sliding in from the side on mount
251
- $animate={keyUpdated > 1}
252
- aria-hidden="true"
253
- role="presentation"
239
+ <StyledTabBar $hasEndEnhancer={Boolean(endEnhancer)} $orientation={orientation}>
240
+ <TabList
241
+ data-baseweb="tab-list"
242
+ role="tablist"
243
+ aria-orientation={orientation}
254
244
  {...sharedStylingProps}
255
- {...TabHighlightProps}
256
- />
257
- </TabList>
245
+ {...TabListProps}
246
+ >
247
+ {React.Children.map(children, (child, index) => {
248
+ if (!child) return;
249
+ return (
250
+ <InternalTab
251
+ childKey={child.key}
252
+ childIndex={index}
253
+ activeKey={activeKey}
254
+ orientation={orientation}
255
+ activeTabRef={activeTabRef}
256
+ updateHighlight={updateHighlight}
257
+ parseKeyDown={parseKeyDown}
258
+ activateOnFocus={activateOnFocus}
259
+ uid={uid}
260
+ disabled={disabled}
261
+ sharedStylingProps={sharedStylingProps}
262
+ onChange={onChange}
263
+ {...child.props}
264
+ />
265
+ );
266
+ })}
267
+ <TabHighlight
268
+ data-baseweb="tab-highlight"
269
+ $length={highlightLayout.length}
270
+ $distance={highlightLayout.distance}
271
+ // This avoids the tab sliding in from the side on mount
272
+ $animate={keyUpdated > 1}
273
+ aria-hidden="true"
274
+ role="presentation"
275
+ {...sharedStylingProps}
276
+ {...TabHighlightProps}
277
+ />
278
+ </TabList>
279
+
280
+ {orientation === ORIENTATION.horizontal &&
281
+ endEnhancer !== null &&
282
+ endEnhancer !== undefined && (
283
+ <EndEnhancerContainer {...endEnhancerContainerProps} $orientation={orientation}>
284
+ <RenderEnhancer Enhancer={endEnhancer} />
285
+ </EndEnhancerContainer>
286
+ )}
287
+ </StyledTabBar>
288
+
258
289
  <TabBorder
259
290
  data-baseweb="tab-border"
260
291
  aria-hidden="true"
@@ -10,6 +10,8 @@ export declare type TabsOverrides = {
10
10
  TabList?: Override;
11
11
  TabHighlight?: Override;
12
12
  TabBorder?: Override;
13
+ EndEnhancerContainer?: Override;
14
+ StyledTabBar?: Override;
13
15
  };
14
16
  export declare type TabOverrides = {
15
17
  Tab?: Override;
@@ -38,6 +40,7 @@ export declare type TabsProps = {
38
40
  overrides?: TabsOverrides;
39
41
  renderAll?: boolean;
40
42
  uid?: string;
43
+ endEnhancer?: React.ReactNode;
41
44
  };
42
45
  export declare type StatefulTabsProps = {
43
46
  initialState?: StatefulTabsState;
@@ -22,6 +22,8 @@ export type TabsOverridesT = {
22
22
  TabList?: OverrideT,
23
23
  TabHighlight?: OverrideT,
24
24
  TabBorder?: OverrideT,
25
+ EndEnhancerContainer?: OverrideT,
26
+ StyledTabBar?: OverrideT,
25
27
  };
26
28
 
27
29
  export type TabOverridesT = {
@@ -57,6 +59,7 @@ export type TabsPropsT = {|
57
59
  overrides?: TabsOverridesT,
58
60
  renderAll?: boolean,
59
61
  uid?: string,
62
+ endEnhancer?: React.Node | React.AbstractComponent<{}>,
60
63
  |};
61
64
 
62
65
  export type StatefulTabsPropsT = {|