baseui 10.0.0 → 10.3.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.
Files changed (162) hide show
  1. package/app-nav-bar/index.d.ts +24 -0
  2. package/app-nav-bar/mobile-menu.js +5 -3
  3. package/app-nav-bar/mobile-menu.js.flow +3 -2
  4. package/app-nav-bar/user-menu.js +5 -3
  5. package/app-nav-bar/user-menu.js.flow +3 -2
  6. package/block/index.d.ts +7 -0
  7. package/combobox/combobox.js +4 -9
  8. package/combobox/combobox.js.flow +4 -3
  9. package/combobox/index.d.ts +1 -1
  10. package/data-table/filter-menu.js +5 -3
  11. package/data-table/filter-menu.js.flow +3 -2
  12. package/data-table/header-cell.js +1 -1
  13. package/data-table/header-cell.js.flow +1 -1
  14. package/datepicker/calendar.js +6 -1
  15. package/datepicker/calendar.js.flow +4 -0
  16. package/datepicker/datepicker.js +1 -1
  17. package/datepicker/datepicker.js.flow +5 -2
  18. package/datepicker/index.d.ts +9 -1
  19. package/datepicker/month.js +2 -1
  20. package/datepicker/month.js.flow +8 -1
  21. package/datepicker/types.js.flow +13 -6
  22. package/es/app-nav-bar/mobile-menu.js +5 -5
  23. package/es/app-nav-bar/user-menu.js +5 -5
  24. package/es/combobox/combobox.js +4 -3
  25. package/es/data-table/filter-menu.js +3 -2
  26. package/es/data-table/header-cell.js +1 -1
  27. package/es/datepicker/calendar.js +6 -1
  28. package/es/datepicker/datepicker.js +1 -1
  29. package/es/datepicker/month.js +2 -1
  30. package/es/form-control/form-control.js +6 -14
  31. package/es/helper/helper.js +10 -6
  32. package/es/helpers/base-provider.js +4 -1
  33. package/es/input/input.js +9 -5
  34. package/es/layer/layer.js +5 -1
  35. package/es/layout-grid/grid.js +16 -10
  36. package/es/layout-grid/styled-components.js +24 -12
  37. package/es/list/index.js +1 -0
  38. package/es/list/list-heading.js +77 -0
  39. package/es/list/list-item.js +1 -1
  40. package/es/list/menu-adapter.js +4 -2
  41. package/es/list/styled-components.js +101 -4
  42. package/es/menu/stateful-container.js +41 -27
  43. package/es/phone-input/base-country-picker.js +2 -0
  44. package/es/popover/popover.js +21 -10
  45. package/es/select/select-component.js +34 -22
  46. package/es/table-semantic/styled-components.js +8 -10
  47. package/es/table-semantic/table-builder.js +3 -2
  48. package/es/table-semantic/table.js +1 -0
  49. package/es/tag/index.js +1 -1
  50. package/es/tag/styled-components.js +2 -4
  51. package/es/tag/tag.js +16 -16
  52. package/es/textarea/textarea.js +1 -2
  53. package/es/themes/dark-theme/color-semantic-tokens.js +18 -8
  54. package/es/themes/light-theme/color-semantic-tokens.js +14 -4
  55. package/es/tokens/colors.js +3 -3
  56. package/es/tree-view/tree-view.js +0 -2
  57. package/esm/app-nav-bar/mobile-menu.js +5 -3
  58. package/esm/app-nav-bar/user-menu.js +5 -3
  59. package/esm/combobox/combobox.js +4 -7
  60. package/esm/data-table/filter-menu.js +4 -3
  61. package/esm/data-table/header-cell.js +1 -1
  62. package/esm/datepicker/calendar.js +6 -1
  63. package/esm/datepicker/datepicker.js +1 -1
  64. package/esm/datepicker/month.js +2 -1
  65. package/esm/form-control/form-control.js +21 -33
  66. package/esm/helper/helper.js +10 -6
  67. package/esm/helpers/base-provider.js +4 -1
  68. package/esm/input/input.js +9 -5
  69. package/esm/layer/layer.js +5 -1
  70. package/esm/layout-grid/grid.js +20 -10
  71. package/esm/layout-grid/styled-components.js +52 -35
  72. package/esm/list/index.js +1 -0
  73. package/esm/list/list-heading.js +116 -0
  74. package/esm/list/list-item.js +1 -1
  75. package/esm/list/menu-adapter.js +4 -2
  76. package/esm/list/styled-components.js +99 -3
  77. package/esm/menu/stateful-container.js +56 -40
  78. package/esm/phone-input/base-country-picker.js +2 -0
  79. package/esm/popover/popover.js +25 -16
  80. package/esm/select/select-component.js +87 -79
  81. package/esm/table-semantic/styled-components.js +8 -10
  82. package/esm/table-semantic/table-builder.js +3 -2
  83. package/esm/table-semantic/table.js +1 -0
  84. package/esm/tag/index.js +1 -1
  85. package/esm/tag/styled-components.js +2 -4
  86. package/esm/tag/tag.js +18 -16
  87. package/esm/textarea/textarea.js +1 -2
  88. package/esm/themes/dark-theme/color-semantic-tokens.js +18 -8
  89. package/esm/themes/light-theme/color-semantic-tokens.js +14 -4
  90. package/esm/tokens/colors.js +3 -3
  91. package/esm/tree-view/tree-view.js +0 -2
  92. package/form-control/form-control.js +21 -35
  93. package/form-control/form-control.js.flow +37 -35
  94. package/helper/helper.js +10 -6
  95. package/helper/helper.js.flow +1 -0
  96. package/helpers/base-provider.js +5 -1
  97. package/helpers/base-provider.js.flow +4 -1
  98. package/index.d.ts +1 -0
  99. package/input/input.js +9 -5
  100. package/input/input.js.flow +9 -5
  101. package/layer/layer.js +5 -1
  102. package/layer/layer.js.flow +3 -1
  103. package/layer/types.js.flow +4 -0
  104. package/layout-grid/grid.js +19 -9
  105. package/layout-grid/grid.js.flow +52 -26
  106. package/layout-grid/index.d.ts +1 -0
  107. package/layout-grid/styled-components.js +54 -36
  108. package/layout-grid/styled-components.js.flow +48 -24
  109. package/layout-grid/types.js.flow +12 -0
  110. package/list/index.js +9 -0
  111. package/list/index.js.flow +1 -0
  112. package/list/list-heading.js +124 -0
  113. package/list/list-heading.js.flow +138 -0
  114. package/list/list-item.js +1 -1
  115. package/list/list-item.js.flow +1 -1
  116. package/list/menu-adapter.js +5 -2
  117. package/list/menu-adapter.js.flow +21 -11
  118. package/list/styled-components.js +108 -5
  119. package/list/styled-components.js.flow +103 -2
  120. package/list/types.js.flow +22 -0
  121. package/menu/stateful-container.js +57 -42
  122. package/menu/stateful-container.js.flow +38 -26
  123. package/package.json +1 -1
  124. package/phone-input/base-country-picker.js +2 -0
  125. package/phone-input/base-country-picker.js.flow +2 -0
  126. package/popover/popover.js +26 -17
  127. package/popover/popover.js.flow +19 -7
  128. package/select/select-component.js +87 -79
  129. package/select/select-component.js.flow +119 -103
  130. package/snackbar/index.d.ts +3 -3
  131. package/snackbar/types.js.flow +1 -1
  132. package/table-semantic/index.d.ts +1 -0
  133. package/table-semantic/styled-components.js +8 -10
  134. package/table-semantic/styled-components.js.flow +20 -20
  135. package/table-semantic/table-builder.js +3 -2
  136. package/table-semantic/table-builder.js.flow +3 -2
  137. package/table-semantic/table.js +1 -0
  138. package/table-semantic/table.js.flow +1 -0
  139. package/tag/index.d.ts +0 -1
  140. package/tag/index.js +0 -6
  141. package/tag/index.js.flow +0 -1
  142. package/tag/styled-components.js +3 -6
  143. package/tag/styled-components.js.flow +0 -2
  144. package/tag/tag.js +19 -14
  145. package/tag/tag.js.flow +13 -19
  146. package/textarea/textarea.js +1 -2
  147. package/textarea/textarea.js.flow +0 -1
  148. package/theme.ts +12 -0
  149. package/themes/dark-theme/color-semantic-tokens.js +18 -8
  150. package/themes/dark-theme/color-semantic-tokens.js.flow +18 -7
  151. package/themes/light-theme/color-semantic-tokens.js +14 -4
  152. package/themes/light-theme/color-semantic-tokens.js.flow +14 -3
  153. package/themes/types.js.flow +11 -0
  154. package/toast/index.d.ts +1 -0
  155. package/tokens/colors.js +3 -3
  156. package/tokens/colors.js.flow +3 -3
  157. package/tree-view/tree-view.js +0 -2
  158. package/tree-view/tree-view.js.flow +0 -1
  159. package/es/utils/get-bui-id.js +0 -33
  160. package/esm/utils/get-bui-id.js +0 -33
  161. package/utils/get-bui-id.js +0 -41
  162. package/utils/get-bui-id.js.flow +0 -39
@@ -41,7 +41,7 @@ export var StyledContent = styled('div', function (_ref2) {
41
41
  borderLeftStyle: 'none',
42
42
  display: 'flex',
43
43
  flexGrow: 1,
44
- minHeight: $sublist ? '48px' : '72px',
44
+ minHeight: $sublist ? 'initial' : $theme.sizing.scale1600,
45
45
  justifyContent: 'space-between'
46
46
  }, $theme.direction === 'rtl' ? {
47
47
  paddingLeft: $theme.sizing.scale600,
@@ -100,8 +100,104 @@ export var StyledLabelDescription = styled('p', function (_ref5) {
100
100
  StyledLabelDescription.displayName = "StyledLabelDescription";
101
101
  export var StyledLabelSublistContent = styled('p', function (_ref6) {
102
102
  var $theme = _ref6.$theme;
103
+ return _objectSpread(_objectSpread({}, $theme.typography.LabelMedium), {}, {
104
+ color: $theme.colors.contentPrimary,
105
+ marginTop: $theme.sizing.scale500,
106
+ marginBottom: $theme.sizing.scale500
107
+ });
108
+ });
109
+ StyledLabelSublistContent.displayName = "StyledLabelSublistContent";
110
+ export var StyledHeadingRoot = styled('div', function (_ref7) {
111
+ var $theme = _ref7.$theme;
112
+ return {
113
+ display: 'flex',
114
+ alignItems: 'center',
115
+ width: '100%',
116
+ backgroundColor: $theme.colors.backgroundPrimary,
117
+ overflow: 'hidden',
118
+ minHeight: $theme.sizing.scale1600
119
+ };
120
+ });
121
+ StyledHeadingRoot.displayName = "StyledHeadingRoot";
122
+ export var StyledHeadingContent = styled('div', function (_ref8) {
123
+ var $theme = _ref8.$theme;
124
+ return _objectSpread({
125
+ flexGrow: 1,
126
+ width: '100%',
127
+ minWidth: 0,
128
+ paddingTop: $theme.sizing.scale600,
129
+ paddingBottom: $theme.sizing.scale300
130
+ }, $theme.direction === 'rtl' ? {
131
+ paddingLeft: $theme.sizing.scale600,
132
+ marginRight: $theme.sizing.scale600
133
+ } : {
134
+ paddingRight: $theme.sizing.scale600,
135
+ marginLeft: $theme.sizing.scale600
136
+ });
137
+ });
138
+ StyledHeadingContent.displayName = "StyledHeadingContent";
139
+ export var StyledHeadingContentRow = styled('div', {
140
+ display: 'flex',
141
+ justifyContent: 'space-between',
142
+ width: '100%'
143
+ });
144
+ StyledHeadingContentRow.displayName = "StyledHeadingContentRow";
145
+ export var StyledHeadingMainHeading = styled('p', // $FlowFixMe - suppressing due to webkit properties
146
+ function (_ref9) {
147
+ var _ref9$$maxLines = _ref9.$maxLines,
148
+ $maxLines = _ref9$$maxLines === void 0 ? 1 : _ref9$$maxLines,
149
+ $theme = _ref9.$theme;
150
+ return _objectSpread(_objectSpread({}, $theme.typography.HeadingSmall), {}, {
151
+ color: $theme.colors.contentPrimary,
152
+ marginTop: 0,
153
+ marginBottom: 0,
154
+ marginRight: $theme.sizing.scale600,
155
+ display: '-webkit-box',
156
+ '-webkit-line-clamp': $maxLines,
157
+ '-webkit-box-orient': 'vertical',
158
+ overflow: 'hidden'
159
+ });
160
+ });
161
+ StyledHeadingMainHeading.displayName = "StyledHeadingMainHeading";
162
+ export var StyledHeadingSubHeading = styled('p', // $FlowFixMe - suppressing due to webkit properties
163
+ function (_ref10) {
164
+ var _ref10$$maxLines = _ref10.$maxLines,
165
+ $maxLines = _ref10$$maxLines === void 0 ? 1 : _ref10$$maxLines,
166
+ $theme = _ref10.$theme;
167
+ return _objectSpread(_objectSpread({}, $theme.typography.ParagraphLarge), {}, {
168
+ color: $theme.colors.contentPrimary,
169
+ marginTop: 0,
170
+ marginBottom: 0,
171
+ marginRight: $theme.sizing.scale600,
172
+ display: '-webkit-box',
173
+ '-webkit-line-clamp': $maxLines,
174
+ '-webkit-box-orient': 'vertical',
175
+ overflow: 'hidden'
176
+ });
177
+ });
178
+ StyledHeadingSubHeading.displayName = "StyledHeadingSubHeading";
179
+ export var StyledHeadingEndEnhancerContainer = styled('div', function (_ref11) {
180
+ var $isText = _ref11.$isText,
181
+ $theme = _ref11.$theme;
182
+ return _objectSpread(_objectSpread({}, $theme.typography.LabelMedium), {}, {
183
+ display: 'flex',
184
+ alignItems: $isText ? 'flex-end' : 'center',
185
+ whiteSpace: 'nowrap',
186
+ overflow: 'hidden',
187
+ textOverflow: 'ellipsis'
188
+ });
189
+ });
190
+ StyledHeadingEndEnhancerContainer.displayName = "StyledHeadingEndEnhancerContainer";
191
+ export var StyledHeadingEndEnhancerDescriptionContainer = styled('p', function (_ref12) {
192
+ var $theme = _ref12.$theme;
103
193
  return _objectSpread(_objectSpread({}, $theme.typography.ParagraphMedium), {}, {
104
- color: $theme.colors.contentPrimary
194
+ marginTop: 0,
195
+ marginBottom: 0,
196
+ display: 'flex',
197
+ alignItems: 'flex-start',
198
+ whiteSpace: 'nowrap',
199
+ overflow: 'hidden',
200
+ textOverflow: 'ellipsis'
105
201
  });
106
202
  });
107
- StyledLabelSublistContent.displayName = "StyledLabelSublistContent";
203
+ StyledHeadingEndEnhancerDescriptionContainer.displayName = "StyledHeadingEndEnhancerDescriptionContainer";
@@ -1,5 +1,7 @@
1
1
  function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
2
2
 
3
+ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
4
+
3
5
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
4
6
 
5
7
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
@@ -38,19 +40,48 @@ LICENSE file in the root directory of this source tree.
38
40
  */
39
41
  import * as React from 'react'; // Files
40
42
 
41
- import getBuiId from '../utils/get-bui-id.js';
42
43
  import { STATE_CHANGE_TYPES, KEY_STRINGS } from './constants.js';
43
44
  import { scrollItemIntoView } from './utils.js'; // Types
44
45
 
45
- var MenuStatefulContainer = /*#__PURE__*/function (_React$Component) {
46
- _inherits(MenuStatefulContainer, _React$Component);
46
+ import { useUIDSeed } from 'react-uid';
47
+ var DEFAULT_PROPS = {
48
+ // keeping it in defaultProps to satisfy Flow
49
+ initialState: {
50
+ // We start the index at -1 to indicate that no highlighting exists initially
51
+ highlightedIndex: -1,
52
+ isFocused: false
53
+ },
54
+ typeAhead: true,
55
+ keyboardControlNode: {
56
+ current: null
57
+ },
58
+ stateReducer: function (changeType, changes) {
59
+ return changes;
60
+ },
61
+ onItemSelect: function onItemSelect() {},
62
+ getRequiredItemProps: function getRequiredItemProps() {
63
+ return {};
64
+ },
65
+ children: function children() {
66
+ return null;
67
+ },
68
+ // from nested-menus context
69
+ addMenuToNesting: function addMenuToNesting() {},
70
+ removeMenuFromNesting: function removeMenuFromNesting() {},
71
+ getParentMenu: function getParentMenu() {},
72
+ getChildMenu: function getChildMenu() {},
73
+ forceHighlight: false
74
+ };
75
+
76
+ var MenuStatefulContainerInner = /*#__PURE__*/function (_React$Component) {
77
+ _inherits(MenuStatefulContainerInner, _React$Component);
47
78
 
48
- var _super = _createSuper(MenuStatefulContainer);
79
+ var _super = _createSuper(MenuStatefulContainerInner);
49
80
 
50
- function MenuStatefulContainer() {
81
+ function MenuStatefulContainerInner() {
51
82
  var _this;
52
83
 
53
- _classCallCheck(this, MenuStatefulContainer);
84
+ _classCallCheck(this, MenuStatefulContainerInner);
54
85
 
55
86
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
56
87
  args[_key] = arguments[_key];
@@ -263,7 +294,7 @@ var MenuStatefulContainer = /*#__PURE__*/function (_React$Component) {
263
294
  if (!itemRef) {
264
295
  itemRef = /*#__PURE__*/React.createRef();
265
296
  _this.refList[index] = itemRef;
266
- _this.optionIds[index] = getBuiId();
297
+ _this.optionIds[index] = _this.props.uidSeed(index);
267
298
  }
268
299
 
269
300
  var _this$props$getRequir = _this.props.getRequiredItemProps(item, index),
@@ -321,7 +352,7 @@ var MenuStatefulContainer = /*#__PURE__*/function (_React$Component) {
321
352
  return _this;
322
353
  }
323
354
 
324
- _createClass(MenuStatefulContainer, [{
355
+ _createClass(MenuStatefulContainerInner, [{
325
356
  key: "getItems",
326
357
  value: function getItems() {
327
358
  var _this2 = this;
@@ -413,6 +444,8 @@ var MenuStatefulContainer = /*#__PURE__*/function (_React$Component) {
413
444
  }, {
414
445
  key: "render",
415
446
  value: function render() {
447
+ var _this3 = this;
448
+
416
449
  // omit the stateful-container's props and don't pass it down
417
450
  // to the children (stateless menu)
418
451
  var _this$props = this.props,
@@ -430,7 +463,9 @@ var MenuStatefulContainer = /*#__PURE__*/function (_React$Component) {
430
463
  return this.props.children(_objectSpread(_objectSpread({}, restProps), {}, {
431
464
  rootRef: this.props.rootRef ? this.props.rootRef : this.rootRef,
432
465
  activedescendantId: this.optionIds[this.state.highlightedIndex],
433
- getRequiredItemProps: this.getRequiredItemProps,
466
+ getRequiredItemProps: function getRequiredItemProps(item, index) {
467
+ return _this3.getRequiredItemProps(item, index);
468
+ },
434
469
  handleMouseLeave: this.handleMouseLeave,
435
470
  highlightedIndex: this.state.highlightedIndex,
436
471
  isFocused: this.state.isFocused,
@@ -441,36 +476,17 @@ var MenuStatefulContainer = /*#__PURE__*/function (_React$Component) {
441
476
  }
442
477
  }]);
443
478
 
444
- return MenuStatefulContainer;
445
- }(React.Component);
479
+ return MenuStatefulContainerInner;
480
+ }(React.Component); // Remove when MenuStatefulContainer is converted to a functional component.
446
481
 
447
- _defineProperty(MenuStatefulContainer, "defaultProps", {
448
- // keeping it in defaultProps to satisfy Flow
449
- initialState: {
450
- // We start the index at -1 to indicate that no highlighting exists initially
451
- highlightedIndex: -1,
452
- isFocused: false
453
- },
454
- typeAhead: true,
455
- keyboardControlNode: {
456
- current: null
457
- },
458
- stateReducer: function (changeType, changes) {
459
- return changes;
460
- },
461
- onItemSelect: function onItemSelect() {},
462
- getRequiredItemProps: function getRequiredItemProps() {
463
- return {};
464
- },
465
- children: function children() {
466
- return null;
467
- },
468
- // from nested-menus context
469
- addMenuToNesting: function addMenuToNesting() {},
470
- removeMenuFromNesting: function removeMenuFromNesting() {},
471
- getParentMenu: function getParentMenu() {},
472
- getChildMenu: function getChildMenu() {},
473
- forceHighlight: false
474
- });
475
482
 
476
- export { MenuStatefulContainer as default };
483
+ _defineProperty(MenuStatefulContainerInner, "defaultProps", DEFAULT_PROPS);
484
+
485
+ var MenuStatefulContainer = function MenuStatefulContainer(props) {
486
+ return /*#__PURE__*/React.createElement(MenuStatefulContainerInner, _extends({
487
+ uidSeed: useUIDSeed()
488
+ }, props));
489
+ };
490
+
491
+ MenuStatefulContainer.defaultProps = DEFAULT_PROPS;
492
+ export default MenuStatefulContainer;
@@ -101,6 +101,8 @@ export default function CountryPicker(props) {
101
101
  width: 0
102
102
  },
103
103
  props: {
104
+ // https://github.com/uber/baseweb/issues/3846
105
+ autoComplete: 'chrome-off',
104
106
  'aria-label': 'Select country'
105
107
  }
106
108
  },
@@ -41,22 +41,22 @@ LICENSE file in the root directory of this source tree.
41
41
  import * as React from 'react';
42
42
  import FocusLock from 'react-focus-lock';
43
43
  import { getOverride, getOverrideProps } from '../helpers/overrides.js';
44
- import getBuiId from '../utils/get-bui-id.js';
45
44
  import { ACCESSIBILITY_TYPE, PLACEMENT, TRIGGER_TYPE, ANIMATE_OUT_TIME, ANIMATE_IN_TIME, POPOVER_MARGIN } from './constants.js';
46
45
  import { Layer, TetherBehavior } from '../layer/index.js';
47
46
  import { Arrow as StyledArrow, Body as StyledBody, Inner as StyledInner, Hidden } from './styled-components.js';
48
47
  import { fromPopperPlacement } from './utils.js';
49
48
  import defaultProps from './default-props.js';
49
+ import { useUID } from 'react-uid';
50
50
 
51
- var Popover = /*#__PURE__*/function (_React$Component) {
52
- _inherits(Popover, _React$Component);
51
+ var PopoverInner = /*#__PURE__*/function (_React$Component) {
52
+ _inherits(PopoverInner, _React$Component);
53
53
 
54
- var _super = _createSuper(Popover);
54
+ var _super = _createSuper(PopoverInner);
55
55
 
56
- function Popover() {
56
+ function PopoverInner() {
57
57
  var _this;
58
58
 
59
- _classCallCheck(this, Popover);
59
+ _classCallCheck(this, PopoverInner);
60
60
 
61
61
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
62
62
  args[_key] = arguments[_key];
@@ -74,8 +74,6 @@ var Popover = /*#__PURE__*/function (_React$Component) {
74
74
 
75
75
  _defineProperty(_assertThisInitialized(_this), "onMouseLeaveTimer", void 0);
76
76
 
77
- _defineProperty(_assertThisInitialized(_this), "generatedId", '');
78
-
79
77
  _defineProperty(_assertThisInitialized(_this), "anchorRef", /*#__PURE__*/React.createRef());
80
78
 
81
79
  _defineProperty(_assertThisInitialized(_this), "popperRef", /*#__PURE__*/React.createRef());
@@ -192,10 +190,9 @@ var Popover = /*#__PURE__*/function (_React$Component) {
192
190
  return _this;
193
191
  }
194
192
 
195
- _createClass(Popover, [{
193
+ _createClass(PopoverInner, [{
196
194
  key: "componentDidMount",
197
195
  value: function componentDidMount() {
198
- this.generatedId = getBuiId();
199
196
  this.setState({
200
197
  isMounted: true
201
198
  });
@@ -330,7 +327,7 @@ var Popover = /*#__PURE__*/function (_React$Component) {
330
327
  }, {
331
328
  key: "getPopoverIdAttr",
332
329
  value: function getPopoverIdAttr() {
333
- return this.props.id || this.generatedId || null;
330
+ return this.props.id || null;
334
331
  }
335
332
  }, {
336
333
  key: "getAnchorProps",
@@ -480,7 +477,8 @@ var Popover = /*#__PURE__*/function (_React$Component) {
480
477
  var defaultPopperOptions = {
481
478
  modifiers: {
482
479
  preventOverflow: {
483
- enabled: !this.props.ignoreBoundary
480
+ enabled: !this.props.ignoreBoundary,
481
+ padding: 0
484
482
  }
485
483
  }
486
484
  }; // Only render popover on the browser (portals aren't supported server-side)
@@ -491,7 +489,8 @@ var Popover = /*#__PURE__*/function (_React$Component) {
491
489
  key: "new-layer",
492
490
  mountNode: this.props.mountNode,
493
491
  onEscape: this.props.onEsc,
494
- onDocumentClick: this.onDocumentClick,
492
+ onDocumentClick: this.isHoverTrigger() ? undefined : this.onDocumentClick,
493
+ isHoverLayer: this.isHoverTrigger(),
495
494
  onMount: function onMount() {
496
495
  return _this4.setState({
497
496
  isLayerMounted: true
@@ -529,10 +528,20 @@ var Popover = /*#__PURE__*/function (_React$Component) {
529
528
  }
530
529
  }]);
531
530
 
532
- return Popover;
533
- }(React.Component);
531
+ return PopoverInner;
532
+ }(React.Component); // Remove when Popover is converted to a functional component.
533
+
534
+
535
+ _defineProperty(PopoverInner, "defaultProps", defaultProps);
534
536
 
535
- _defineProperty(Popover, "defaultProps", defaultProps);
537
+ var Popover = function Popover(props) {
538
+ var innerRef = props.innerRef;
539
+ return /*#__PURE__*/React.createElement(PopoverInner, _extends({
540
+ id: props.id || useUID(),
541
+ ref: innerRef
542
+ }, props));
543
+ };
536
544
 
545
+ Popover.defaultProps = defaultProps;
537
546
  export default Popover;
538
547
  /* eslint-enable react/no-find-dom-node */
@@ -60,7 +60,7 @@ import SearchIconComponent from '../icon/search.js';
60
60
  import { LocaleContext } from '../locale/index.js';
61
61
  import { Popover, PLACEMENT } from '../popover/index.js';
62
62
  import { Spinner } from '../spinner/index.js';
63
- import getBuiId from '../utils/get-bui-id.js';
63
+ import { UIDConsumer } from 'react-uid';
64
64
  import AutosizeInput from './autosize-input.js';
65
65
  import { TYPE, STATE_CHANGE_TYPE } from './constants.js';
66
66
  import defaultProps from './default-props.js';
@@ -128,7 +128,6 @@ var Select = /*#__PURE__*/function (_React$Component) {
128
128
  // the select components can accept an array of options or an object where properties are optgroups
129
129
  // and values are arrays of options. this class property is constructed and updated in a normalized
130
130
  // shape where optgroup titles are stored on the option in the __optgroup field.
131
- // id generated for the listbox. used by screenreaders to associate the input with the menu it controls
132
131
  function Select(props) {
133
132
  var _this;
134
133
 
@@ -152,8 +151,6 @@ var Select = /*#__PURE__*/function (_React$Component) {
152
151
 
153
152
  _defineProperty(_assertThisInitialized(_this), "options", []);
154
153
 
155
- _defineProperty(_assertThisInitialized(_this), "listboxId", getBuiId());
156
-
157
154
  _defineProperty(_assertThisInitialized(_this), "state", {
158
155
  activeDescendant: null,
159
156
  inputValue: '',
@@ -209,18 +206,17 @@ var Select = /*#__PURE__*/function (_React$Component) {
209
206
  _this.openAfterFocus = _this.props.openOnClick;
210
207
 
211
208
  _this.focus();
212
-
213
- return;
214
209
  }
215
210
 
216
211
  if (!_this.state.isOpen) {
217
212
  _this.setState({
218
213
  isOpen: true,
214
+ isFocused: true,
219
215
  isPseudoFocused: false
220
216
  });
221
-
222
- return;
223
217
  }
218
+
219
+ return;
224
220
  } // Ensures that interactive elements within the Select component do not trigger the outer click
225
221
  // handler. For example, after an option is selected clicks on the 'clear' icon call here. We
226
222
  // should ignore those events. This comes after case where click is on input element, so that
@@ -236,11 +232,17 @@ var Select = /*#__PURE__*/function (_React$Component) {
236
232
  if (!_this.props.searchable) {
237
233
  _this.focus();
238
234
 
239
- _this.setState(function (prev) {
240
- return {
241
- isOpen: !prev.isOpen
242
- };
243
- });
235
+ if (_this.state.isOpen) {
236
+ _this.setState({
237
+ isOpen: false,
238
+ isFocused: false
239
+ });
240
+ } else {
241
+ _this.setState({
242
+ isOpen: true,
243
+ isFocused: true
244
+ });
245
+ }
244
246
 
245
247
  return;
246
248
  } // Cases below only apply to searchable Select component.
@@ -816,7 +818,7 @@ var Select = /*#__PURE__*/function (_React$Component) {
816
818
  }
817
819
  }, {
818
820
  key: "renderInput",
819
- value: function renderInput() {
821
+ value: function renderInput(listboxId) {
820
822
  var _this4 = this;
821
823
 
822
824
  var _this$props$overrides3 = this.props.overrides,
@@ -845,25 +847,29 @@ var Select = /*#__PURE__*/function (_React$Component) {
845
847
  "aria-disabled": this.props.disabled,
846
848
  "aria-label": label,
847
849
  "aria-labelledby": this.props['aria-labelledby'],
848
- "aria-owns": this.state.isOpen ? this.listboxId : null,
850
+ "aria-owns": this.state.isOpen ? listboxId : null,
849
851
  "aria-required": this.props.required || null,
850
852
  onFocus: this.handleInputFocus,
851
- ref: this.handleInputRef,
852
853
  tabIndex: 0
853
854
  }, sharedProps, inputContainerProps), /*#__PURE__*/React.createElement("input", {
854
- "aria-hidden": "true",
855
+ "aria-hidden": true,
855
856
  id: this.props.id || null,
856
- onFocus: this.handleInputFocus,
857
+ ref: this.handleInputRef,
857
858
  style: {
858
- display: 'none'
859
- }
859
+ opacity: 0,
860
+ width: 0,
861
+ overflow: 'hidden',
862
+ border: 'none',
863
+ padding: 0
864
+ },
865
+ tabIndex: -1
860
866
  }));
861
867
  }
862
868
 
863
869
  return /*#__PURE__*/React.createElement(InputContainer, _extends({}, sharedProps, inputContainerProps), /*#__PURE__*/React.createElement(AutosizeInput, _extends({
864
870
  "aria-activedescendant": this.state.activeDescendant,
865
871
  "aria-autocomplete": "list",
866
- "aria-controls": this.state.isOpen ? this.listboxId : null,
872
+ "aria-controls": this.state.isOpen ? listboxId : null,
867
873
  "aria-describedby": this.props['aria-describedby'],
868
874
  "aria-errormessage": this.props['aria-errormessage'],
869
875
  "aria-disabled": this.props.disabled || null,
@@ -986,7 +992,7 @@ var Select = /*#__PURE__*/function (_React$Component) {
986
992
  value: function filterOptions(excludeOptions) {
987
993
  var _this5 = this;
988
994
 
989
- var filterValue = this.state.inputValue; // apply filter function
995
+ var filterValue = this.state.inputValue.trim(); // apply filter function
990
996
 
991
997
  if (this.props.filterOptions) {
992
998
  this.options = this.props.filterOptions(this.options, filterValue, excludeOptions, {
@@ -1116,63 +1122,65 @@ var Select = /*#__PURE__*/function (_React$Component) {
1116
1122
  }
1117
1123
  }
1118
1124
 
1119
- return /*#__PURE__*/React.createElement(LocaleContext.Consumer, null, function (locale) {
1120
- return /*#__PURE__*/React.createElement(PopoverOverride // Popover does not provide ability to forward refs through, and if we were to simply
1121
- // apply the ref to the Root component below it would be overwritten before the popover
1122
- // renders it. Using this strategy, we will get a ref to the popover, then reuse its
1123
- // anchorRef so we can check if clicks are on the select component or not.
1124
- // eslint-disable-next-line flowtype/no-weak-types
1125
- , _extends({
1126
- ref: function ref(_ref4) {
1127
- if (!_ref4) return;
1128
- _this6.anchor = _ref4.anchorRef;
1129
- },
1130
- focusLock: false,
1131
- mountNode: _this6.props.mountNode,
1132
- onEsc: function onEsc() {
1133
- return _this6.closeMenu();
1134
- },
1135
- isOpen: isOpen,
1136
- popoverMargin: 0,
1137
- content: function content() {
1138
- var dropdownProps = {
1139
- error: _this6.props.error,
1140
- positive: _this6.props.positive,
1141
- getOptionLabel: _this6.props.getOptionLabel || _this6.getOptionLabel.bind(_this6, locale),
1142
- id: _this6.listboxId,
1143
- isLoading: _this6.props.isLoading,
1144
- labelKey: _this6.props.labelKey,
1145
- maxDropdownHeight: _this6.props.maxDropdownHeight,
1146
- multi: multi,
1147
- noResultsMsg: noResultsMsg,
1148
- onActiveDescendantChange: _this6.handleActiveDescendantChange,
1149
- onItemSelect: _this6.selectValue,
1150
- options: options,
1151
- overrides: overrides,
1152
- required: _this6.props.required,
1153
- searchable: _this6.props.searchable,
1154
- size: _this6.props.size,
1155
- type: type,
1156
- value: valueArray,
1157
- valueKey: _this6.props.valueKey,
1158
- width: _this6.anchor.current ? _this6.anchor.current.clientWidth : null,
1159
- keyboardControlNode: _this6.anchor
1160
- };
1161
- return /*#__PURE__*/React.createElement(SelectDropdown, _extends({
1162
- innerRef: _this6.dropdown
1163
- }, dropdownProps));
1164
- },
1165
- placement: PLACEMENT.bottom
1166
- }, popoverProps), /*#__PURE__*/React.createElement(Root, _extends({
1167
- onBlur: _this6.handleBlur,
1168
- "data-baseweb": "select"
1169
- }, sharedProps, rootProps), /*#__PURE__*/React.createElement(ControlContainer, _extends({
1170
- onKeyDown: _this6.handleKeyDown,
1171
- onClick: _this6.handleClick,
1172
- onTouchEnd: _this6.handleTouchEnd,
1173
- onTouchMove: _this6.handleTouchMove,
1174
- onTouchStart: _this6.handleTouchStart
1175
- }, sharedProps, controlContainerProps), type === TYPE.search ? _this6.renderSearch() : null, /*#__PURE__*/React.createElement(ValueContainer, _extends({}, sharedProps, valueContainerProps), _this6.renderValue(valueArray, isOpen, locale), _this6.renderInput(), _this6.shouldShowPlaceholder() ? /*#__PURE__*/React.createElement(Placeholder, _extends({}, sharedProps, placeholderProps), typeof _this6.props.placeholder !== 'undefined' ? _this6.props.placeholder : locale.select.placeholder) : null), /*#__PURE__*/React.createElement(IconsContainer, _extends({}, sharedProps, iconsContainerProps), _this6.renderLoading(), _this6.renderClear(), type === TYPE.select ? _this6.renderArrow() : null))));
1125
+ return /*#__PURE__*/React.createElement(UIDConsumer, null, function (listboxId) {
1126
+ return /*#__PURE__*/React.createElement(LocaleContext.Consumer, null, function (locale) {
1127
+ return /*#__PURE__*/React.createElement(PopoverOverride // Popover does not provide ability to forward refs through, and if we were to simply
1128
+ // apply the ref to the Root component below it would be overwritten before the popover
1129
+ // renders it. Using this strategy, we will get a ref to the popover, then reuse its
1130
+ // anchorRef so we can check if clicks are on the select component or not.
1131
+ // eslint-disable-next-line flowtype/no-weak-types
1132
+ , _extends({
1133
+ innerRef: function innerRef(ref) {
1134
+ if (!ref) return;
1135
+ _this6.anchor = ref.anchorRef;
1136
+ },
1137
+ focusLock: false,
1138
+ mountNode: _this6.props.mountNode,
1139
+ onEsc: function onEsc() {
1140
+ return _this6.closeMenu();
1141
+ },
1142
+ isOpen: isOpen,
1143
+ popoverMargin: 0,
1144
+ content: function content() {
1145
+ var dropdownProps = {
1146
+ error: _this6.props.error,
1147
+ positive: _this6.props.positive,
1148
+ getOptionLabel: _this6.props.getOptionLabel || _this6.getOptionLabel.bind(_this6, locale),
1149
+ id: listboxId,
1150
+ isLoading: _this6.props.isLoading,
1151
+ labelKey: _this6.props.labelKey,
1152
+ maxDropdownHeight: _this6.props.maxDropdownHeight,
1153
+ multi: multi,
1154
+ noResultsMsg: noResultsMsg,
1155
+ onActiveDescendantChange: _this6.handleActiveDescendantChange,
1156
+ onItemSelect: _this6.selectValue,
1157
+ options: options,
1158
+ overrides: overrides,
1159
+ required: _this6.props.required,
1160
+ searchable: _this6.props.searchable,
1161
+ size: _this6.props.size,
1162
+ type: type,
1163
+ value: valueArray,
1164
+ valueKey: _this6.props.valueKey,
1165
+ width: _this6.anchor.current ? _this6.anchor.current.clientWidth : null,
1166
+ keyboardControlNode: _this6.anchor
1167
+ };
1168
+ return /*#__PURE__*/React.createElement(SelectDropdown, _extends({
1169
+ innerRef: _this6.dropdown
1170
+ }, dropdownProps));
1171
+ },
1172
+ placement: PLACEMENT.bottom
1173
+ }, popoverProps), /*#__PURE__*/React.createElement(Root, _extends({
1174
+ onBlur: _this6.handleBlur,
1175
+ "data-baseweb": "select"
1176
+ }, sharedProps, rootProps), /*#__PURE__*/React.createElement(ControlContainer, _extends({
1177
+ onKeyDown: _this6.handleKeyDown,
1178
+ onClick: _this6.handleClick,
1179
+ onTouchEnd: _this6.handleTouchEnd,
1180
+ onTouchMove: _this6.handleTouchMove,
1181
+ onTouchStart: _this6.handleTouchStart
1182
+ }, sharedProps, controlContainerProps), type === TYPE.search ? _this6.renderSearch() : null, /*#__PURE__*/React.createElement(ValueContainer, _extends({}, sharedProps, valueContainerProps), _this6.renderValue(valueArray, isOpen, locale), _this6.renderInput(listboxId), _this6.shouldShowPlaceholder() ? /*#__PURE__*/React.createElement(Placeholder, _extends({}, sharedProps, placeholderProps), typeof _this6.props.placeholder !== 'undefined' ? _this6.props.placeholder : locale.select.placeholder) : null), /*#__PURE__*/React.createElement(IconsContainer, _extends({}, sharedProps, iconsContainerProps), _this6.renderLoading(), _this6.renderClear(), type === TYPE.select ? _this6.renderArrow() : null))));
1183
+ });
1176
1184
  });
1177
1185
  }
1178
1186
  }]);