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
@@ -9,18 +9,18 @@ exports.default = void 0;
9
9
 
10
10
  var React = _interopRequireWildcard(require("react"));
11
11
 
12
- var _getBuiId = _interopRequireDefault(require("../utils/get-bui-id.js"));
13
-
14
12
  var _constants = require("./constants.js");
15
13
 
16
14
  var _utils = require("./utils.js");
17
15
 
18
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
+ var _reactUid = require("react-uid");
19
17
 
20
18
  function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
21
19
 
22
20
  function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
23
21
 
22
+ 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); }
23
+
24
24
  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; }
25
25
 
26
26
  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; }
@@ -51,15 +51,44 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
51
51
 
52
52
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
53
53
 
54
- var MenuStatefulContainer = /*#__PURE__*/function (_React$Component) {
55
- _inherits(MenuStatefulContainer, _React$Component);
54
+ var DEFAULT_PROPS = {
55
+ // keeping it in defaultProps to satisfy Flow
56
+ initialState: {
57
+ // We start the index at -1 to indicate that no highlighting exists initially
58
+ highlightedIndex: -1,
59
+ isFocused: false
60
+ },
61
+ typeAhead: true,
62
+ keyboardControlNode: {
63
+ current: null
64
+ },
65
+ stateReducer: function (changeType, changes) {
66
+ return changes;
67
+ },
68
+ onItemSelect: function onItemSelect() {},
69
+ getRequiredItemProps: function getRequiredItemProps() {
70
+ return {};
71
+ },
72
+ children: function children() {
73
+ return null;
74
+ },
75
+ // from nested-menus context
76
+ addMenuToNesting: function addMenuToNesting() {},
77
+ removeMenuFromNesting: function removeMenuFromNesting() {},
78
+ getParentMenu: function getParentMenu() {},
79
+ getChildMenu: function getChildMenu() {},
80
+ forceHighlight: false
81
+ };
82
+
83
+ var MenuStatefulContainerInner = /*#__PURE__*/function (_React$Component) {
84
+ _inherits(MenuStatefulContainerInner, _React$Component);
56
85
 
57
- var _super = _createSuper(MenuStatefulContainer);
86
+ var _super = _createSuper(MenuStatefulContainerInner);
58
87
 
59
- function MenuStatefulContainer() {
88
+ function MenuStatefulContainerInner() {
60
89
  var _this;
61
90
 
62
- _classCallCheck(this, MenuStatefulContainer);
91
+ _classCallCheck(this, MenuStatefulContainerInner);
63
92
 
64
93
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
65
94
  args[_key] = arguments[_key];
@@ -272,7 +301,7 @@ var MenuStatefulContainer = /*#__PURE__*/function (_React$Component) {
272
301
  if (!itemRef) {
273
302
  itemRef = /*#__PURE__*/React.createRef();
274
303
  _this.refList[index] = itemRef;
275
- _this.optionIds[index] = (0, _getBuiId.default)();
304
+ _this.optionIds[index] = _this.props.uidSeed(index);
276
305
  }
277
306
 
278
307
  var _this$props$getRequir = _this.props.getRequiredItemProps(item, index),
@@ -330,7 +359,7 @@ var MenuStatefulContainer = /*#__PURE__*/function (_React$Component) {
330
359
  return _this;
331
360
  }
332
361
 
333
- _createClass(MenuStatefulContainer, [{
362
+ _createClass(MenuStatefulContainerInner, [{
334
363
  key: "getItems",
335
364
  value: function getItems() {
336
365
  var _this2 = this;
@@ -422,6 +451,8 @@ var MenuStatefulContainer = /*#__PURE__*/function (_React$Component) {
422
451
  }, {
423
452
  key: "render",
424
453
  value: function render() {
454
+ var _this3 = this;
455
+
425
456
  // omit the stateful-container's props and don't pass it down
426
457
  // to the children (stateless menu)
427
458
  var _this$props = this.props,
@@ -439,7 +470,9 @@ var MenuStatefulContainer = /*#__PURE__*/function (_React$Component) {
439
470
  return this.props.children(_objectSpread(_objectSpread({}, restProps), {}, {
440
471
  rootRef: this.props.rootRef ? this.props.rootRef : this.rootRef,
441
472
  activedescendantId: this.optionIds[this.state.highlightedIndex],
442
- getRequiredItemProps: this.getRequiredItemProps,
473
+ getRequiredItemProps: function getRequiredItemProps(item, index) {
474
+ return _this3.getRequiredItemProps(item, index);
475
+ },
443
476
  handleMouseLeave: this.handleMouseLeave,
444
477
  highlightedIndex: this.state.highlightedIndex,
445
478
  isFocused: this.state.isFocused,
@@ -450,36 +483,18 @@ var MenuStatefulContainer = /*#__PURE__*/function (_React$Component) {
450
483
  }
451
484
  }]);
452
485
 
453
- return MenuStatefulContainer;
454
- }(React.Component);
486
+ return MenuStatefulContainerInner;
487
+ }(React.Component); // Remove when MenuStatefulContainer is converted to a functional component.
455
488
 
456
- exports.default = MenuStatefulContainer;
457
489
 
458
- _defineProperty(MenuStatefulContainer, "defaultProps", {
459
- // keeping it in defaultProps to satisfy Flow
460
- initialState: {
461
- // We start the index at -1 to indicate that no highlighting exists initially
462
- highlightedIndex: -1,
463
- isFocused: false
464
- },
465
- typeAhead: true,
466
- keyboardControlNode: {
467
- current: null
468
- },
469
- stateReducer: function (changeType, changes) {
470
- return changes;
471
- },
472
- onItemSelect: function onItemSelect() {},
473
- getRequiredItemProps: function getRequiredItemProps() {
474
- return {};
475
- },
476
- children: function children() {
477
- return null;
478
- },
479
- // from nested-menus context
480
- addMenuToNesting: function addMenuToNesting() {},
481
- removeMenuFromNesting: function removeMenuFromNesting() {},
482
- getParentMenu: function getParentMenu() {},
483
- getChildMenu: function getChildMenu() {},
484
- forceHighlight: false
485
- });
490
+ _defineProperty(MenuStatefulContainerInner, "defaultProps", DEFAULT_PROPS);
491
+
492
+ var MenuStatefulContainer = function MenuStatefulContainer(props) {
493
+ return /*#__PURE__*/React.createElement(MenuStatefulContainerInner, _extends({
494
+ uidSeed: (0, _reactUid.useUIDSeed)()
495
+ }, props));
496
+ };
497
+
498
+ MenuStatefulContainer.defaultProps = DEFAULT_PROPS;
499
+ var _default = MenuStatefulContainer;
500
+ exports.default = _default;
@@ -7,7 +7,6 @@ LICENSE file in the root directory of this source tree.
7
7
  // @flow
8
8
  import * as React from 'react';
9
9
  // Files
10
- import getBuiId from '../utils/get-bui-id.js';
11
10
  import {STATE_CHANGE_TYPES, KEY_STRINGS} from './constants.js';
12
11
  import {scrollItemIntoView} from './utils.js';
13
12
  // Types
@@ -18,31 +17,34 @@ import type {
18
17
  RenderPropsT,
19
18
  StateReducerFnT,
20
19
  } from './types.js';
21
-
22
- export default class MenuStatefulContainer extends React.Component<
23
- StatefulContainerPropsT,
20
+ import {useUIDSeed} from 'react-uid';
21
+
22
+ const DEFAULT_PROPS = {
23
+ // keeping it in defaultProps to satisfy Flow
24
+ initialState: {
25
+ // We start the index at -1 to indicate that no highlighting exists initially
26
+ highlightedIndex: -1,
27
+ isFocused: false,
28
+ },
29
+ typeAhead: true,
30
+ keyboardControlNode: {current: null},
31
+ stateReducer: ((changeType, changes) => changes: StateReducerFnT),
32
+ onItemSelect: () => {},
33
+ getRequiredItemProps: () => ({}),
34
+ children: () => null,
35
+ // from nested-menus context
36
+ addMenuToNesting: () => {},
37
+ removeMenuFromNesting: () => {},
38
+ getParentMenu: () => {},
39
+ getChildMenu: () => {},
40
+ forceHighlight: false,
41
+ };
42
+
43
+ class MenuStatefulContainerInner extends React.Component<
44
+ StatefulContainerPropsT & {uidSeed: (item: number) => string},
24
45
  StatefulContainerStateT,
25
46
  > {
26
- static defaultProps = {
27
- // keeping it in defaultProps to satisfy Flow
28
- initialState: {
29
- // We start the index at -1 to indicate that no highlighting exists initially
30
- highlightedIndex: -1,
31
- isFocused: false,
32
- },
33
- typeAhead: true,
34
- keyboardControlNode: {current: null},
35
- stateReducer: ((changeType, changes) => changes: StateReducerFnT),
36
- onItemSelect: () => {},
37
- getRequiredItemProps: () => ({}),
38
- children: () => null,
39
- // from nested-menus context
40
- addMenuToNesting: () => {},
41
- removeMenuFromNesting: () => {},
42
- getParentMenu: () => {},
43
- getChildMenu: () => {},
44
- forceHighlight: false,
45
- };
47
+ static defaultProps = DEFAULT_PROPS;
46
48
 
47
49
  state: StatefulContainerStateT = {
48
50
  ...this.constructor.defaultProps.initialState,
@@ -357,7 +359,7 @@ export default class MenuStatefulContainer extends React.Component<
357
359
  if (!itemRef) {
358
360
  itemRef = React.createRef();
359
361
  this.refList[index] = itemRef;
360
- this.optionIds[index] = getBuiId();
362
+ this.optionIds[index] = this.props.uidSeed(index);
361
363
  }
362
364
  const {
363
365
  disabled: disabledVal,
@@ -440,7 +442,8 @@ export default class MenuStatefulContainer extends React.Component<
440
442
  ...restProps,
441
443
  rootRef: this.props.rootRef ? this.props.rootRef : this.rootRef,
442
444
  activedescendantId: this.optionIds[this.state.highlightedIndex],
443
- getRequiredItemProps: this.getRequiredItemProps,
445
+ getRequiredItemProps: (item, index) =>
446
+ this.getRequiredItemProps(item, index),
444
447
  handleMouseLeave: this.handleMouseLeave,
445
448
  highlightedIndex: this.state.highlightedIndex,
446
449
  isFocused: this.state.isFocused,
@@ -454,6 +457,15 @@ export default class MenuStatefulContainer extends React.Component<
454
457
  }
455
458
  }
456
459
 
460
+ // Remove when MenuStatefulContainer is converted to a functional component.
461
+ const MenuStatefulContainer = (props: StatefulContainerPropsT) => {
462
+ return <MenuStatefulContainerInner uidSeed={useUIDSeed()} {...props} />;
463
+ };
464
+
465
+ MenuStatefulContainer.defaultProps = DEFAULT_PROPS;
466
+
467
+ export default MenuStatefulContainer;
468
+
457
469
  declare var __DEV__: boolean;
458
470
  declare var __NODE__: boolean;
459
471
  declare var __BROWSER__: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "baseui",
3
- "version": "10.0.0",
3
+ "version": "10.3.0",
4
4
  "description": "A React Component library implementing the Base design language",
5
5
  "keywords": [
6
6
  "react",
@@ -118,6 +118,8 @@ function CountryPicker(props) {
118
118
  width: 0
119
119
  },
120
120
  props: {
121
+ // https://github.com/uber/baseweb/issues/3846
122
+ autoComplete: 'chrome-off',
121
123
  'aria-label': 'Select country'
122
124
  }
123
125
  },
@@ -84,6 +84,8 @@ export default function CountryPicker(props: CountrySelectPropsT) {
84
84
  width: 0,
85
85
  },
86
86
  props: {
87
+ // https://github.com/uber/baseweb/issues/3846
88
+ autoComplete: 'chrome-off',
87
89
  'aria-label': 'Select country',
88
90
  },
89
91
  },
@@ -11,8 +11,6 @@ var _reactFocusLock = _interopRequireDefault(require("react-focus-lock"));
11
11
 
12
12
  var _overrides = require("../helpers/overrides.js");
13
13
 
14
- var _getBuiId = _interopRequireDefault(require("../utils/get-bui-id.js"));
15
-
16
14
  var _constants = require("./constants.js");
17
15
 
18
16
  var _index = require("../layer/index.js");
@@ -23,6 +21,8 @@ var _utils = require("./utils.js");
23
21
 
24
22
  var _defaultProps = _interopRequireDefault(require("./default-props.js"));
25
23
 
24
+ var _reactUid = require("react-uid");
25
+
26
26
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
27
27
 
28
28
  function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
@@ -59,15 +59,15 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
59
59
 
60
60
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
61
61
 
62
- var Popover = /*#__PURE__*/function (_React$Component) {
63
- _inherits(Popover, _React$Component);
62
+ var PopoverInner = /*#__PURE__*/function (_React$Component) {
63
+ _inherits(PopoverInner, _React$Component);
64
64
 
65
- var _super = _createSuper(Popover);
65
+ var _super = _createSuper(PopoverInner);
66
66
 
67
- function Popover() {
67
+ function PopoverInner() {
68
68
  var _this;
69
69
 
70
- _classCallCheck(this, Popover);
70
+ _classCallCheck(this, PopoverInner);
71
71
 
72
72
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
73
73
  args[_key] = arguments[_key];
@@ -85,8 +85,6 @@ var Popover = /*#__PURE__*/function (_React$Component) {
85
85
 
86
86
  _defineProperty(_assertThisInitialized(_this), "onMouseLeaveTimer", void 0);
87
87
 
88
- _defineProperty(_assertThisInitialized(_this), "generatedId", '');
89
-
90
88
  _defineProperty(_assertThisInitialized(_this), "anchorRef", /*#__PURE__*/React.createRef());
91
89
 
92
90
  _defineProperty(_assertThisInitialized(_this), "popperRef", /*#__PURE__*/React.createRef());
@@ -203,10 +201,9 @@ var Popover = /*#__PURE__*/function (_React$Component) {
203
201
  return _this;
204
202
  }
205
203
 
206
- _createClass(Popover, [{
204
+ _createClass(PopoverInner, [{
207
205
  key: "componentDidMount",
208
206
  value: function componentDidMount() {
209
- this.generatedId = (0, _getBuiId.default)();
210
207
  this.setState({
211
208
  isMounted: true
212
209
  });
@@ -341,7 +338,7 @@ var Popover = /*#__PURE__*/function (_React$Component) {
341
338
  }, {
342
339
  key: "getPopoverIdAttr",
343
340
  value: function getPopoverIdAttr() {
344
- return this.props.id || this.generatedId || null;
341
+ return this.props.id || null;
345
342
  }
346
343
  }, {
347
344
  key: "getAnchorProps",
@@ -495,7 +492,8 @@ var Popover = /*#__PURE__*/function (_React$Component) {
495
492
  var defaultPopperOptions = {
496
493
  modifiers: {
497
494
  preventOverflow: {
498
- enabled: !this.props.ignoreBoundary
495
+ enabled: !this.props.ignoreBoundary,
496
+ padding: 0
499
497
  }
500
498
  }
501
499
  }; // Only render popover on the browser (portals aren't supported server-side)
@@ -506,7 +504,8 @@ var Popover = /*#__PURE__*/function (_React$Component) {
506
504
  key: "new-layer",
507
505
  mountNode: this.props.mountNode,
508
506
  onEscape: this.props.onEsc,
509
- onDocumentClick: this.onDocumentClick,
507
+ onDocumentClick: this.isHoverTrigger() ? undefined : this.onDocumentClick,
508
+ isHoverLayer: this.isHoverTrigger(),
510
509
  onMount: function onMount() {
511
510
  return _this4.setState({
512
511
  isLayerMounted: true
@@ -544,11 +543,21 @@ var Popover = /*#__PURE__*/function (_React$Component) {
544
543
  }
545
544
  }]);
546
545
 
547
- return Popover;
548
- }(React.Component);
546
+ return PopoverInner;
547
+ }(React.Component); // Remove when Popover is converted to a functional component.
548
+
549
+
550
+ _defineProperty(PopoverInner, "defaultProps", _defaultProps.default);
549
551
 
550
- _defineProperty(Popover, "defaultProps", _defaultProps.default);
552
+ var Popover = function Popover(props) {
553
+ var innerRef = props.innerRef;
554
+ return /*#__PURE__*/React.createElement(PopoverInner, _extends({
555
+ id: props.id || (0, _reactUid.useUID)(),
556
+ ref: innerRef
557
+ }, props));
558
+ };
551
559
 
560
+ Popover.defaultProps = _defaultProps.default;
552
561
  var _default = Popover;
553
562
  /* eslint-enable react/no-find-dom-node */
554
563
 
@@ -11,7 +11,6 @@ import * as React from 'react';
11
11
  import FocusLock from 'react-focus-lock';
12
12
 
13
13
  import {getOverride, getOverrideProps} from '../helpers/overrides.js';
14
- import getBuiId from '../utils/get-bui-id.js';
15
14
  import {
16
15
  ACCESSIBILITY_TYPE,
17
16
  PLACEMENT,
@@ -29,6 +28,7 @@ import {
29
28
  } from './styled-components.js';
30
29
  import {fromPopperPlacement} from './utils.js';
31
30
  import defaultProps from './default-props.js';
31
+ import {useUID} from 'react-uid';
32
32
 
33
33
  import type {
34
34
  AnchorPropsT,
@@ -38,7 +38,10 @@ import type {
38
38
  } from './types.js';
39
39
  import type {PopperDataObjectT, NormalizedOffsetsT} from '../layer/types.js';
40
40
 
41
- class Popover extends React.Component<PopoverPropsT, PopoverPrivateStateT> {
41
+ class PopoverInner extends React.Component<
42
+ PopoverPropsT,
43
+ PopoverPrivateStateT,
44
+ > {
42
45
  static defaultProps: $Shape<PopoverPropsT> = defaultProps;
43
46
 
44
47
  /* eslint-disable react/sort-comp */
@@ -47,7 +50,6 @@ class Popover extends React.Component<PopoverPropsT, PopoverPrivateStateT> {
47
50
  animateOutCompleteTimer: ?TimeoutID;
48
51
  onMouseEnterTimer: ?TimeoutID;
49
52
  onMouseLeaveTimer: ?TimeoutID;
50
- generatedId: string = '';
51
53
  anchorRef = (React.createRef(): {current: *});
52
54
  popperRef = (React.createRef(): {current: *});
53
55
  arrowRef = (React.createRef(): {current: *});
@@ -61,7 +63,6 @@ class Popover extends React.Component<PopoverPropsT, PopoverPrivateStateT> {
61
63
  state = this.getDefaultState(this.props);
62
64
 
63
65
  componentDidMount() {
64
- this.generatedId = getBuiId();
65
66
  this.setState({isMounted: true});
66
67
  }
67
68
 
@@ -289,7 +290,7 @@ class Popover extends React.Component<PopoverPropsT, PopoverPrivateStateT> {
289
290
  }
290
291
 
291
292
  getPopoverIdAttr() {
292
- return this.props.id || this.generatedId || null;
293
+ return this.props.id || null;
293
294
  }
294
295
 
295
296
  getAnchorProps() {
@@ -439,7 +440,7 @@ class Popover extends React.Component<PopoverPropsT, PopoverPrivateStateT> {
439
440
 
440
441
  const defaultPopperOptions = {
441
442
  modifiers: {
442
- preventOverflow: {enabled: !this.props.ignoreBoundary},
443
+ preventOverflow: {enabled: !this.props.ignoreBoundary, padding: 0},
443
444
  },
444
445
  };
445
446
  // Only render popover on the browser (portals aren't supported server-side)
@@ -450,7 +451,10 @@ class Popover extends React.Component<PopoverPropsT, PopoverPrivateStateT> {
450
451
  key="new-layer"
451
452
  mountNode={this.props.mountNode}
452
453
  onEscape={this.props.onEsc}
453
- onDocumentClick={this.onDocumentClick}
454
+ onDocumentClick={
455
+ this.isHoverTrigger() ? undefined : this.onDocumentClick
456
+ }
457
+ isHoverLayer={this.isHoverTrigger()}
454
458
  onMount={() => this.setState({isLayerMounted: true})}
455
459
  onUnmount={() => this.setState({isLayerMounted: false})}
456
460
  >
@@ -487,6 +491,14 @@ class Popover extends React.Component<PopoverPropsT, PopoverPrivateStateT> {
487
491
  }
488
492
  }
489
493
 
494
+ // Remove when Popover is converted to a functional component.
495
+ const Popover = (props: PopoverPropsT & {innerRef?: React$ElementRef<*>}) => {
496
+ const {innerRef} = props;
497
+ return <PopoverInner id={props.id || useUID()} ref={innerRef} {...props} />;
498
+ };
499
+
500
+ Popover.defaultProps = defaultProps;
501
+
490
502
  export default Popover;
491
503
  /* eslint-enable react/no-find-dom-node */
492
504