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.
- package/app-nav-bar/index.d.ts +24 -0
- package/app-nav-bar/mobile-menu.js +5 -3
- package/app-nav-bar/mobile-menu.js.flow +3 -2
- package/app-nav-bar/user-menu.js +5 -3
- package/app-nav-bar/user-menu.js.flow +3 -2
- package/block/index.d.ts +7 -0
- package/combobox/combobox.js +4 -9
- package/combobox/combobox.js.flow +4 -3
- package/combobox/index.d.ts +1 -1
- package/data-table/filter-menu.js +5 -3
- package/data-table/filter-menu.js.flow +3 -2
- package/data-table/header-cell.js +1 -1
- package/data-table/header-cell.js.flow +1 -1
- package/datepicker/calendar.js +6 -1
- package/datepicker/calendar.js.flow +4 -0
- package/datepicker/datepicker.js +1 -1
- package/datepicker/datepicker.js.flow +5 -2
- package/datepicker/index.d.ts +9 -1
- package/datepicker/month.js +2 -1
- package/datepicker/month.js.flow +8 -1
- package/datepicker/types.js.flow +13 -6
- package/es/app-nav-bar/mobile-menu.js +5 -5
- package/es/app-nav-bar/user-menu.js +5 -5
- package/es/combobox/combobox.js +4 -3
- package/es/data-table/filter-menu.js +3 -2
- package/es/data-table/header-cell.js +1 -1
- package/es/datepicker/calendar.js +6 -1
- package/es/datepicker/datepicker.js +1 -1
- package/es/datepicker/month.js +2 -1
- package/es/form-control/form-control.js +6 -14
- package/es/helper/helper.js +10 -6
- package/es/helpers/base-provider.js +4 -1
- package/es/input/input.js +9 -5
- package/es/layer/layer.js +5 -1
- package/es/layout-grid/grid.js +16 -10
- package/es/layout-grid/styled-components.js +24 -12
- package/es/list/index.js +1 -0
- package/es/list/list-heading.js +77 -0
- package/es/list/list-item.js +1 -1
- package/es/list/menu-adapter.js +4 -2
- package/es/list/styled-components.js +101 -4
- package/es/menu/stateful-container.js +41 -27
- package/es/phone-input/base-country-picker.js +2 -0
- package/es/popover/popover.js +21 -10
- package/es/select/select-component.js +34 -22
- package/es/table-semantic/styled-components.js +8 -10
- package/es/table-semantic/table-builder.js +3 -2
- package/es/table-semantic/table.js +1 -0
- package/es/tag/index.js +1 -1
- package/es/tag/styled-components.js +2 -4
- package/es/tag/tag.js +16 -16
- package/es/textarea/textarea.js +1 -2
- package/es/themes/dark-theme/color-semantic-tokens.js +18 -8
- package/es/themes/light-theme/color-semantic-tokens.js +14 -4
- package/es/tokens/colors.js +3 -3
- package/es/tree-view/tree-view.js +0 -2
- package/esm/app-nav-bar/mobile-menu.js +5 -3
- package/esm/app-nav-bar/user-menu.js +5 -3
- package/esm/combobox/combobox.js +4 -7
- package/esm/data-table/filter-menu.js +4 -3
- package/esm/data-table/header-cell.js +1 -1
- package/esm/datepicker/calendar.js +6 -1
- package/esm/datepicker/datepicker.js +1 -1
- package/esm/datepicker/month.js +2 -1
- package/esm/form-control/form-control.js +21 -33
- package/esm/helper/helper.js +10 -6
- package/esm/helpers/base-provider.js +4 -1
- package/esm/input/input.js +9 -5
- package/esm/layer/layer.js +5 -1
- package/esm/layout-grid/grid.js +20 -10
- package/esm/layout-grid/styled-components.js +52 -35
- package/esm/list/index.js +1 -0
- package/esm/list/list-heading.js +116 -0
- package/esm/list/list-item.js +1 -1
- package/esm/list/menu-adapter.js +4 -2
- package/esm/list/styled-components.js +99 -3
- package/esm/menu/stateful-container.js +56 -40
- package/esm/phone-input/base-country-picker.js +2 -0
- package/esm/popover/popover.js +25 -16
- package/esm/select/select-component.js +87 -79
- package/esm/table-semantic/styled-components.js +8 -10
- package/esm/table-semantic/table-builder.js +3 -2
- package/esm/table-semantic/table.js +1 -0
- package/esm/tag/index.js +1 -1
- package/esm/tag/styled-components.js +2 -4
- package/esm/tag/tag.js +18 -16
- package/esm/textarea/textarea.js +1 -2
- package/esm/themes/dark-theme/color-semantic-tokens.js +18 -8
- package/esm/themes/light-theme/color-semantic-tokens.js +14 -4
- package/esm/tokens/colors.js +3 -3
- package/esm/tree-view/tree-view.js +0 -2
- package/form-control/form-control.js +21 -35
- package/form-control/form-control.js.flow +37 -35
- package/helper/helper.js +10 -6
- package/helper/helper.js.flow +1 -0
- package/helpers/base-provider.js +5 -1
- package/helpers/base-provider.js.flow +4 -1
- package/index.d.ts +1 -0
- package/input/input.js +9 -5
- package/input/input.js.flow +9 -5
- package/layer/layer.js +5 -1
- package/layer/layer.js.flow +3 -1
- package/layer/types.js.flow +4 -0
- package/layout-grid/grid.js +19 -9
- package/layout-grid/grid.js.flow +52 -26
- package/layout-grid/index.d.ts +1 -0
- package/layout-grid/styled-components.js +54 -36
- package/layout-grid/styled-components.js.flow +48 -24
- package/layout-grid/types.js.flow +12 -0
- package/list/index.js +9 -0
- package/list/index.js.flow +1 -0
- package/list/list-heading.js +124 -0
- package/list/list-heading.js.flow +138 -0
- package/list/list-item.js +1 -1
- package/list/list-item.js.flow +1 -1
- package/list/menu-adapter.js +5 -2
- package/list/menu-adapter.js.flow +21 -11
- package/list/styled-components.js +108 -5
- package/list/styled-components.js.flow +103 -2
- package/list/types.js.flow +22 -0
- package/menu/stateful-container.js +57 -42
- package/menu/stateful-container.js.flow +38 -26
- package/package.json +1 -1
- package/phone-input/base-country-picker.js +2 -0
- package/phone-input/base-country-picker.js.flow +2 -0
- package/popover/popover.js +26 -17
- package/popover/popover.js.flow +19 -7
- package/select/select-component.js +87 -79
- package/select/select-component.js.flow +119 -103
- package/snackbar/index.d.ts +3 -3
- package/snackbar/types.js.flow +1 -1
- package/table-semantic/index.d.ts +1 -0
- package/table-semantic/styled-components.js +8 -10
- package/table-semantic/styled-components.js.flow +20 -20
- package/table-semantic/table-builder.js +3 -2
- package/table-semantic/table-builder.js.flow +3 -2
- package/table-semantic/table.js +1 -0
- package/table-semantic/table.js.flow +1 -0
- package/tag/index.d.ts +0 -1
- package/tag/index.js +0 -6
- package/tag/index.js.flow +0 -1
- package/tag/styled-components.js +3 -6
- package/tag/styled-components.js.flow +0 -2
- package/tag/tag.js +19 -14
- package/tag/tag.js.flow +13 -19
- package/textarea/textarea.js +1 -2
- package/textarea/textarea.js.flow +0 -1
- package/theme.ts +12 -0
- package/themes/dark-theme/color-semantic-tokens.js +18 -8
- package/themes/dark-theme/color-semantic-tokens.js.flow +18 -7
- package/themes/light-theme/color-semantic-tokens.js +14 -4
- package/themes/light-theme/color-semantic-tokens.js.flow +14 -3
- package/themes/types.js.flow +11 -0
- package/toast/index.d.ts +1 -0
- package/tokens/colors.js +3 -3
- package/tokens/colors.js.flow +3 -3
- package/tree-view/tree-view.js +0 -2
- package/tree-view/tree-view.js.flow +0 -1
- package/es/utils/get-bui-id.js +0 -33
- package/esm/utils/get-bui-id.js +0 -33
- package/utils/get-bui-id.js +0 -41
- 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
|
-
|
|
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
|
|
55
|
-
|
|
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(
|
|
86
|
+
var _super = _createSuper(MenuStatefulContainerInner);
|
|
58
87
|
|
|
59
|
-
function
|
|
88
|
+
function MenuStatefulContainerInner() {
|
|
60
89
|
var _this;
|
|
61
90
|
|
|
62
|
-
_classCallCheck(this,
|
|
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] =
|
|
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(
|
|
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:
|
|
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
|
|
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(
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
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
|
-
|
|
23
|
-
|
|
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] =
|
|
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:
|
|
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
package/popover/popover.js
CHANGED
|
@@ -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
|
|
63
|
-
_inherits(
|
|
62
|
+
var PopoverInner = /*#__PURE__*/function (_React$Component) {
|
|
63
|
+
_inherits(PopoverInner, _React$Component);
|
|
64
64
|
|
|
65
|
-
var _super = _createSuper(
|
|
65
|
+
var _super = _createSuper(PopoverInner);
|
|
66
66
|
|
|
67
|
-
function
|
|
67
|
+
function PopoverInner() {
|
|
68
68
|
var _this;
|
|
69
69
|
|
|
70
|
-
_classCallCheck(this,
|
|
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(
|
|
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 ||
|
|
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
|
|
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
|
-
|
|
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
|
|
package/popover/popover.js.flow
CHANGED
|
@@ -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
|
|
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 ||
|
|
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={
|
|
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
|
|