react-bootstrap 1.0.0-beta.13 → 1.0.0-beta.17

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 (134) hide show
  1. package/AccordionToggle.d.ts +4 -5
  2. package/BootstrapModalManager/package.json +6 -0
  3. package/Container.d.ts +1 -1
  4. package/ElementChildren/package.json +6 -0
  5. package/FormControl.d.ts +7 -2
  6. package/ListGroup.d.ts +1 -0
  7. package/Modal.d.ts +1 -0
  8. package/Overlay.d.ts +1 -1
  9. package/OverlayTrigger.d.ts +1 -0
  10. package/ToggleButton.d.ts +0 -1
  11. package/cjs/AbstractNav.js +1 -1
  12. package/cjs/Alert.js +4 -4
  13. package/cjs/{utils/BootstrapModalManager.js → BootstrapModalManager.js} +9 -5
  14. package/cjs/Card.js +2 -2
  15. package/cjs/CardColumns.js +1 -1
  16. package/cjs/CardDeck.js +1 -1
  17. package/cjs/CardGroup.js +1 -1
  18. package/cjs/Carousel.js +9 -9
  19. package/cjs/CarouselCaption.js +1 -1
  20. package/cjs/CarouselItem.js +1 -1
  21. package/cjs/Collapse.js +7 -7
  22. package/cjs/Container.js +3 -3
  23. package/cjs/Dropdown.js +5 -5
  24. package/cjs/DropdownMenu.js +39 -46
  25. package/cjs/DropdownToggle.js +31 -58
  26. package/cjs/{utils/ElementChildren.js → ElementChildren.js} +0 -0
  27. package/cjs/Fade.js +4 -4
  28. package/cjs/Figure.js +1 -1
  29. package/cjs/FigureCaption.js +1 -1
  30. package/cjs/Form.js +1 -1
  31. package/cjs/FormLabel.js +3 -1
  32. package/cjs/InputGroup.js +1 -1
  33. package/cjs/ListGroup.js +16 -3
  34. package/cjs/Media.js +1 -1
  35. package/cjs/Modal.js +32 -18
  36. package/cjs/ModalBody.js +1 -1
  37. package/cjs/ModalDialog.js +1 -1
  38. package/cjs/ModalFooter.js +1 -1
  39. package/cjs/ModalTitle.js +2 -2
  40. package/cjs/NavDropdown.js +64 -41
  41. package/cjs/Navbar.js +1 -1
  42. package/cjs/OverlayTrigger.js +131 -182
  43. package/cjs/PageItem.js +7 -4
  44. package/cjs/Pagination.js +21 -36
  45. package/cjs/Popover.js +9 -10
  46. package/cjs/ProgressBar.js +1 -1
  47. package/cjs/ResponsiveEmbed.js +19 -35
  48. package/cjs/Row.js +1 -0
  49. package/cjs/SafeAnchor.js +1 -1
  50. package/cjs/SplitButton.js +9 -3
  51. package/cjs/TabContent.js +15 -31
  52. package/cjs/Table.js +31 -47
  53. package/cjs/Tabs.js +1 -1
  54. package/cjs/ToastBody.js +1 -1
  55. package/cjs/ToggleButton.js +45 -78
  56. package/cjs/ToggleButtonGroup.js +44 -65
  57. package/cjs/Tooltip.js +2 -1
  58. package/cjs/{utils/createChainedFunction.js → createChainedFunction.js} +0 -0
  59. package/cjs/{utils/createWithBsPrefix.js → createWithBsPrefix.js} +3 -3
  60. package/cjs/{utils/divWithClassName.js → divWithClassName.js} +0 -0
  61. package/cjs/index.js +4 -0
  62. package/cjs/{utils/triggerBrowserReflow.js → triggerBrowserReflow.js} +0 -0
  63. package/cjs/useWrappedRefWithWarning.js +24 -0
  64. package/createChainedFunction/package.json +6 -0
  65. package/createWithBsPrefix/package.json +6 -0
  66. package/dist/react-bootstrap.js +9477 -11933
  67. package/dist/react-bootstrap.min.js +4 -12
  68. package/divWithClassName/package.json +6 -0
  69. package/esm/AbstractNav.js +1 -1
  70. package/esm/AccordionToggle.d.ts +4 -5
  71. package/esm/Alert.js +4 -4
  72. package/esm/{utils/BootstrapModalManager.js → BootstrapModalManager.js} +9 -5
  73. package/esm/Card.js +2 -2
  74. package/esm/CardColumns.js +1 -1
  75. package/esm/CardDeck.js +1 -1
  76. package/esm/CardGroup.js +1 -1
  77. package/esm/Carousel.js +6 -6
  78. package/esm/CarouselCaption.js +1 -1
  79. package/esm/CarouselItem.js +1 -1
  80. package/esm/Collapse.js +6 -6
  81. package/esm/Container.d.ts +1 -1
  82. package/esm/Container.js +3 -3
  83. package/esm/Dropdown.js +4 -4
  84. package/esm/DropdownMenu.js +34 -43
  85. package/esm/DropdownToggle.js +30 -56
  86. package/esm/{utils/ElementChildren.js → ElementChildren.js} +0 -0
  87. package/esm/Fade.js +3 -3
  88. package/esm/Figure.js +1 -1
  89. package/esm/FigureCaption.js +1 -1
  90. package/esm/Form.js +1 -1
  91. package/esm/FormControl.d.ts +7 -2
  92. package/esm/FormLabel.js +3 -1
  93. package/esm/InputGroup.js +1 -1
  94. package/esm/ListGroup.d.ts +1 -0
  95. package/esm/ListGroup.js +15 -3
  96. package/esm/Media.js +1 -1
  97. package/esm/Modal.d.ts +1 -0
  98. package/esm/Modal.js +28 -15
  99. package/esm/ModalBody.js +1 -1
  100. package/esm/ModalDialog.js +1 -1
  101. package/esm/ModalFooter.js +1 -1
  102. package/esm/ModalTitle.js +2 -2
  103. package/esm/NavDropdown.js +61 -41
  104. package/esm/Navbar.js +1 -1
  105. package/esm/Overlay.d.ts +1 -1
  106. package/esm/OverlayTrigger.d.ts +1 -0
  107. package/esm/OverlayTrigger.js +130 -182
  108. package/esm/PageItem.js +5 -2
  109. package/esm/Pagination.js +22 -37
  110. package/esm/Popover.js +10 -13
  111. package/esm/ProgressBar.js +1 -1
  112. package/esm/ResponsiveEmbed.js +18 -33
  113. package/esm/Row.js +1 -0
  114. package/esm/SafeAnchor.js +1 -1
  115. package/esm/SplitButton.js +9 -3
  116. package/esm/TabContent.js +15 -31
  117. package/esm/Table.js +32 -48
  118. package/esm/Tabs.js +1 -1
  119. package/esm/ToastBody.js +1 -1
  120. package/esm/ToggleButton.d.ts +0 -1
  121. package/esm/ToggleButton.js +44 -79
  122. package/esm/ToggleButtonGroup.js +42 -65
  123. package/esm/Tooltip.js +2 -1
  124. package/esm/{utils/createChainedFunction.js → createChainedFunction.js} +0 -0
  125. package/esm/{utils/createWithBsPrefix.js → createWithBsPrefix.js} +2 -2
  126. package/esm/{utils/divWithClassName.js → divWithClassName.js} +0 -0
  127. package/esm/index.d.ts +1 -0
  128. package/esm/index.js +2 -0
  129. package/esm/{utils/triggerBrowserReflow.js → triggerBrowserReflow.js} +0 -0
  130. package/esm/useWrappedRefWithWarning.js +12 -0
  131. package/index.d.ts +1 -0
  132. package/package.json +12 -16
  133. package/triggerBrowserReflow/package.json +6 -0
  134. package/useWrappedRefWithWarning/package.json +6 -0
package/esm/Modal.js CHANGED
@@ -2,21 +2,23 @@ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWith
2
2
  import _extends from "@babel/runtime/helpers/esm/extends";
3
3
  import _inheritsLoose from "@babel/runtime/helpers/esm/inheritsLoose";
4
4
  import classNames from 'classnames';
5
- import events from 'dom-helpers/events';
5
+ import addEventListener from 'dom-helpers/addEventListener';
6
+ import canUseDOM from 'dom-helpers/canUseDOM';
6
7
  import ownerDocument from 'dom-helpers/ownerDocument';
7
- import canUseDOM from 'dom-helpers/util/inDOM';
8
- import getScrollbarSize from 'dom-helpers/util/scrollbarSize';
8
+ import removeEventListener from 'dom-helpers/removeEventListener';
9
+ import getScrollbarSize from 'dom-helpers/scrollbarSize';
9
10
  import React from 'react';
10
11
  import BaseModal from 'react-overlays/Modal';
12
+ import BootstrapModalManager from './BootstrapModalManager';
11
13
  import Fade from './Fade';
12
14
  import Body from './ModalBody';
15
+ import ModalContext from './ModalContext';
13
16
  import ModalDialog from './ModalDialog';
14
17
  import Footer from './ModalFooter';
15
18
  import Header from './ModalHeader';
16
19
  import Title from './ModalTitle';
17
- import BootstrapModalManager from './utils/BootstrapModalManager';
18
20
  import { createBootstrapComponent } from './ThemeProvider';
19
- import ModalContext from './ModalContext';
21
+ var manager;
20
22
  var defaultProps = {
21
23
  show: false,
22
24
  backdrop: true,
@@ -25,8 +27,7 @@ var defaultProps = {
25
27
  enforceFocus: true,
26
28
  restoreFocus: true,
27
29
  animation: true,
28
- dialogAs: ModalDialog,
29
- manager: new BootstrapModalManager()
30
+ dialogAs: ModalDialog
30
31
  };
31
32
  /* eslint-disable no-use-before-define, react/no-multi-comp */
32
33
 
@@ -112,7 +113,7 @@ function (_React$Component) {
112
113
 
113
114
  if (_this.props.onEntering) (_this$props2 = _this.props).onEntering.apply(_this$props2, [node].concat(args)); // FIXME: This should work even when animation is disabled.
114
115
 
115
- events.on(window, 'resize', _this.handleWindowResize);
116
+ addEventListener(window, 'resize', _this.handleWindowResize);
116
117
  };
117
118
 
118
119
  _this.handleExited = function (node) {
@@ -126,13 +127,25 @@ function (_React$Component) {
126
127
 
127
128
  if (_this.props.onExited) (_this$props3 = _this.props).onExited.apply(_this$props3, args); // FIXME: This should work even when animation is disabled.
128
129
 
129
- events.off(window, 'resize', _this.handleWindowResize);
130
+ removeEventListener(window, 'resize', _this.handleWindowResize);
130
131
  };
131
132
 
132
133
  _this.handleWindowResize = function () {
133
134
  _this.updateDialogStyle(_this._modal.dialog);
134
135
  };
135
136
 
137
+ _this.getModalManager = function () {
138
+ if (_this.props.manager) {
139
+ return _this.props.manager;
140
+ }
141
+
142
+ if (!manager) {
143
+ manager = new BootstrapModalManager();
144
+ }
145
+
146
+ return manager;
147
+ };
148
+
136
149
  _this.renderBackdrop = function (props) {
137
150
  var _this$props4 = _this.props,
138
151
  bsPrefix = _this$props4.bsPrefix,
@@ -150,13 +163,12 @@ function (_React$Component) {
150
163
 
151
164
  _proto.componentWillUnmount = function componentWillUnmount() {
152
165
  // Clean up the listener if we need to.
153
- events.off(window, 'resize', this.handleWindowResize);
166
+ removeEventListener(window, 'resize', this.handleWindowResize);
154
167
  };
155
168
 
156
169
  _proto.updateDialogStyle = function updateDialogStyle(node) {
157
170
  if (!canUseDOM) return;
158
- var manager = this.props.manager;
159
- var containerIsOverflowing = manager.isContainerOverflowing(this._modal);
171
+ var containerIsOverflowing = this.getModalManager().isContainerOverflowing(this._modal);
160
172
  var modalIsOverflowing = node.scrollHeight > ownerDocument(node).documentElement.clientHeight;
161
173
  this.setState({
162
174
  style: {
@@ -178,7 +190,6 @@ function (_React$Component) {
178
190
  animation = _this$props5.animation,
179
191
  backdrop = _this$props5.backdrop,
180
192
  keyboard = _this$props5.keyboard,
181
- manager = _this$props5.manager,
182
193
  onEscapeKeyDown = _this$props5.onEscapeKeyDown,
183
194
  onShow = _this$props5.onShow,
184
195
  onHide = _this$props5.onHide,
@@ -186,6 +197,7 @@ function (_React$Component) {
186
197
  autoFocus = _this$props5.autoFocus,
187
198
  enforceFocus = _this$props5.enforceFocus,
188
199
  restoreFocus = _this$props5.restoreFocus,
200
+ restoreFocusOptions = _this$props5.restoreFocusOptions,
189
201
  onEntered = _this$props5.onEntered,
190
202
  onExit = _this$props5.onExit,
191
203
  onExiting = _this$props5.onExiting,
@@ -194,7 +206,7 @@ function (_React$Component) {
194
206
  _6 = _this$props5.onEnter,
195
207
  _4 = _this$props5.onEntering,
196
208
  _2 = _this$props5.backdropClassName,
197
- props = _objectWithoutPropertiesLoose(_this$props5, ["bsPrefix", "className", "style", "dialogClassName", "children", "dialogAs", "show", "animation", "backdrop", "keyboard", "manager", "onEscapeKeyDown", "onShow", "onHide", "container", "autoFocus", "enforceFocus", "restoreFocus", "onEntered", "onExit", "onExiting", "onExited", "onEntering", "onEnter", "onEntering", "backdropClassName"]);
209
+ props = _objectWithoutPropertiesLoose(_this$props5, ["bsPrefix", "className", "style", "dialogClassName", "children", "dialogAs", "show", "animation", "backdrop", "keyboard", "onEscapeKeyDown", "onShow", "onHide", "container", "autoFocus", "enforceFocus", "restoreFocus", "restoreFocusOptions", "onEntered", "onExit", "onExiting", "onExited", "onEntering", "onEnter", "onEntering", "backdropClassName"]);
198
210
 
199
211
  var clickHandler = backdrop === true ? this.handleClick : null;
200
212
 
@@ -212,13 +224,14 @@ function (_React$Component) {
212
224
  autoFocus: autoFocus,
213
225
  enforceFocus: enforceFocus,
214
226
  restoreFocus: restoreFocus,
227
+ restoreFocusOptions: restoreFocusOptions,
215
228
  onEscapeKeyDown: onEscapeKeyDown,
216
229
  onShow: onShow,
217
230
  onHide: onHide,
218
231
  onEntered: onEntered,
219
232
  onExit: onExit,
220
233
  onExiting: onExiting,
221
- manager: manager,
234
+ manager: this.getModalManager(),
222
235
  ref: this.setModalRef,
223
236
  style: baseModalStyle,
224
237
  className: classNames(className, bsPrefix),
package/esm/ModalBody.js CHANGED
@@ -1,2 +1,2 @@
1
- import createWithBsPrefix from './utils/createWithBsPrefix';
1
+ import createWithBsPrefix from './createWithBsPrefix';
2
2
  export default createWithBsPrefix('modal-body');
@@ -18,7 +18,7 @@ var ModalDialog = React.forwardRef(function (_ref, ref) {
18
18
  ref: ref,
19
19
  className: classNames(dialogClass, className, size && bsPrefix + "-" + size, centered && dialogClass + "-centered", scrollable && dialogClass + "-scrollable")
20
20
  }), React.createElement("div", {
21
- className: classNames(bsPrefix + "-content")
21
+ className: bsPrefix + "-content"
22
22
  }, children));
23
23
  });
24
24
  ModalDialog.displayName = 'ModalDialog';
@@ -1,2 +1,2 @@
1
- import createWithBsPrefix from './utils/createWithBsPrefix';
1
+ import createWithBsPrefix from './createWithBsPrefix';
2
2
  export default createWithBsPrefix('modal-footer');
package/esm/ModalTitle.js CHANGED
@@ -1,5 +1,5 @@
1
- import createWithBsPrefix from './utils/createWithBsPrefix';
2
- import divWithClassName from './utils/divWithClassName';
1
+ import createWithBsPrefix from './createWithBsPrefix';
2
+ import divWithClassName from './divWithClassName';
3
3
  var DivStyledAsH4 = divWithClassName('h4');
4
4
  export default createWithBsPrefix('modal-title', {
5
5
  Component: DivStyledAsH4
@@ -1,52 +1,72 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
- import _inheritsLoose from "@babel/runtime/helpers/esm/inheritsLoose";
4
3
  import React from 'react';
4
+ import PropTypes from 'prop-types';
5
5
  import Dropdown from './Dropdown';
6
6
  import NavItem from './NavItem';
7
7
  import NavLink from './NavLink';
8
+ var propTypes = {
9
+ /**
10
+ * An html id attribute for the Toggle button, necessary for assistive technologies, such as screen readers.
11
+ * @type {string|number}
12
+ * @required
13
+ */
14
+ id: PropTypes.any,
8
15
 
9
- var NavDropdown =
10
- /*#__PURE__*/
11
- function (_React$Component) {
12
- _inheritsLoose(NavDropdown, _React$Component);
13
-
14
- function NavDropdown() {
15
- return _React$Component.apply(this, arguments) || this;
16
- }
17
-
18
- var _proto = NavDropdown.prototype;
19
-
20
- _proto.render = function render() {
21
- var _this$props = this.props,
22
- id = _this$props.id,
23
- title = _this$props.title,
24
- children = _this$props.children,
25
- bsPrefix = _this$props.bsPrefix,
26
- rootCloseEvent = _this$props.rootCloseEvent,
27
- menuRole = _this$props.menuRole,
28
- disabled = _this$props.disabled,
29
- active = _this$props.active,
30
- props = _objectWithoutPropertiesLoose(_this$props, ["id", "title", "children", "bsPrefix", "rootCloseEvent", "menuRole", "disabled", "active"]);
31
-
32
- return React.createElement(Dropdown, _extends({}, props, {
33
- as: NavItem
34
- }), React.createElement(Dropdown.Toggle, {
35
- id: id,
36
- eventKey: null,
37
- active: active,
38
- disabled: disabled,
39
- childBsPrefix: bsPrefix,
40
- as: NavLink
41
- }, title), React.createElement(Dropdown.Menu, {
42
- role: menuRole,
43
- rootCloseEvent: rootCloseEvent
44
- }, children));
45
- };
46
-
47
- return NavDropdown;
48
- }(React.Component);
16
+ /** An `onClick` handler passed to the Toggle component */
17
+ onClick: PropTypes.func,
49
18
 
19
+ /** The content of the non-toggle Button. */
20
+ title: PropTypes.node.isRequired,
21
+
22
+ /** Disables the toggle NavLink */
23
+ disabled: PropTypes.bool,
24
+
25
+ /** Style the toggle NavLink as active */
26
+ active: PropTypes.bool,
27
+
28
+ /** An ARIA accessible role applied to the Menu component. When set to 'menu', The dropdown */
29
+ menuRole: PropTypes.string,
30
+
31
+ /**
32
+ * Which event when fired outside the component will cause it to be closed.
33
+ *
34
+ * _see [DropdownMenu](#menu-props) for more details_
35
+ */
36
+ rootCloseEvent: PropTypes.string,
37
+
38
+ /** @ignore */
39
+ bsPrefix: PropTypes.string
40
+ };
41
+ var NavDropdown = React.forwardRef(function (_ref, ref) {
42
+ var id = _ref.id,
43
+ title = _ref.title,
44
+ children = _ref.children,
45
+ bsPrefix = _ref.bsPrefix,
46
+ rootCloseEvent = _ref.rootCloseEvent,
47
+ menuRole = _ref.menuRole,
48
+ disabled = _ref.disabled,
49
+ active = _ref.active,
50
+ props = _objectWithoutPropertiesLoose(_ref, ["id", "title", "children", "bsPrefix", "rootCloseEvent", "menuRole", "disabled", "active"]);
51
+
52
+ return React.createElement(Dropdown, _extends({
53
+ ref: ref
54
+ }, props, {
55
+ as: NavItem
56
+ }), React.createElement(Dropdown.Toggle, {
57
+ id: id,
58
+ eventKey: null,
59
+ active: active,
60
+ disabled: disabled,
61
+ childBsPrefix: bsPrefix,
62
+ as: NavLink
63
+ }, title), React.createElement(Dropdown.Menu, {
64
+ role: menuRole,
65
+ rootCloseEvent: rootCloseEvent
66
+ }, children));
67
+ });
68
+ NavDropdown.displayName = 'NavDropdown';
69
+ NavDropdown.propTypes = propTypes;
50
70
  NavDropdown.Item = Dropdown.Item;
51
71
  NavDropdown.Divider = Dropdown.Divider;
52
72
  NavDropdown.Header = Dropdown.Header;
package/esm/Navbar.js CHANGED
@@ -3,7 +3,7 @@ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWith
3
3
  import classNames from 'classnames';
4
4
  import React, { useMemo, useCallback } from 'react';
5
5
  import { useUncontrolled } from 'uncontrollable';
6
- import createWithBsPrefix from './utils/createWithBsPrefix';
6
+ import createWithBsPrefix from './createWithBsPrefix';
7
7
  import NavbarBrand from './NavbarBrand';
8
8
  import NavbarCollapse from './NavbarCollapse';
9
9
  import NavbarToggle from './NavbarToggle';
package/esm/Overlay.d.ts CHANGED
@@ -27,7 +27,7 @@ export interface OverlayProps extends TransitionCallbacks {
27
27
  popperConfig?: object;
28
28
  rootClose?: boolean;
29
29
  rootCloseEvent?: 'click' | 'mousedown';
30
- onHide?: () => void;
30
+ onHide?: (event: React.SyntheticEvent) => void;
31
31
  transition?: boolean | React.ElementType;
32
32
  placement?: Placement;
33
33
  }
@@ -10,6 +10,7 @@ export interface OverlayTriggerProps
10
10
  trigger?: TriggerType | TriggerType[];
11
11
  delay?: number | { show: number; hide: number };
12
12
  defaultShow?: boolean;
13
+ flip?: boolean;
13
14
  overlay: React.ReactNode | (() => React.ReactNode);
14
15
  target?: never;
15
16
  onHide?: never;
@@ -1,8 +1,9 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
3
  import _inheritsLoose from "@babel/runtime/helpers/esm/inheritsLoose";
4
- import contains from 'dom-helpers/query/contains';
5
- import React, { cloneElement } from 'react';
4
+ import contains from 'dom-helpers/contains';
5
+ import React, { cloneElement, useCallback, useRef, useState } from 'react';
6
+ import useTimeout from '@restart/hooks/useTimeout';
6
7
  import ReactDOM from 'react-dom';
7
8
  import warning from 'warning';
8
9
  import Overlay from './Overlay';
@@ -25,206 +26,153 @@ function (_React$Component) {
25
26
  return RefHolder;
26
27
  }(React.Component);
27
28
 
28
- var normalizeDelay = function normalizeDelay(delay) {
29
+ function normalizeDelay(delay) {
29
30
  return delay && typeof delay === 'object' ? delay : {
30
31
  show: delay,
31
32
  hide: delay
32
33
  };
33
- };
34
-
35
- var defaultProps = {
36
- defaultOverlayShown: false,
37
- trigger: ['hover', 'focus']
38
- }; // eslint-disable-next-line react/no-multi-comp
39
-
40
- var OverlayTrigger =
41
- /*#__PURE__*/
42
- function (_React$Component2) {
43
- _inheritsLoose(OverlayTrigger, _React$Component2);
44
-
45
- function OverlayTrigger(props, context) {
46
- var _this;
47
-
48
- _this = _React$Component2.call(this, props, context) || this;
49
-
50
- _this.getTarget = function () {
51
- return ReactDOM.findDOMNode(_this.trigger.current);
52
- };
53
-
54
- _this.handleShow = function () {
55
- clearTimeout(_this._timeout);
56
- _this._hoverState = 'show';
57
- var delay = normalizeDelay(_this.props.delay);
58
-
59
- if (!delay.show) {
60
- _this.show();
61
-
62
- return;
63
- }
64
-
65
- _this._timeout = setTimeout(function () {
66
- if (_this._hoverState === 'show') _this.show();
67
- }, delay.show);
68
- };
69
-
70
- _this.handleHide = function () {
71
- clearTimeout(_this._timeout);
72
- _this._hoverState = 'hide';
73
- var delay = normalizeDelay(_this.props.delay);
74
-
75
- if (!delay.hide) {
76
- _this.hide();
77
-
78
- return;
79
- }
80
-
81
- _this._timeout = setTimeout(function () {
82
- if (_this._hoverState === 'hide') _this.hide();
83
- }, delay.hide);
84
- };
85
-
86
- _this.handleFocus = function (e) {
87
- var _this$getChildProps = _this.getChildProps(),
88
- onFocus = _this$getChildProps.onFocus;
89
-
90
- _this.handleShow(e);
91
-
92
- if (onFocus) onFocus(e);
93
- };
94
-
95
- _this.handleBlur = function (e) {
96
- var _this$getChildProps2 = _this.getChildProps(),
97
- onBlur = _this$getChildProps2.onBlur;
98
-
99
- _this.handleHide(e);
100
-
101
- if (onBlur) onBlur(e);
102
- };
103
-
104
- _this.handleClick = function (e) {
105
- var _this$getChildProps3 = _this.getChildProps(),
106
- onClick = _this$getChildProps3.onClick;
107
-
108
- if (_this.state.show) _this.hide();else _this.show();
109
- if (onClick) onClick(e);
110
- };
111
-
112
- _this.handleMouseOver = function (e) {
113
- _this.handleMouseOverOut(_this.handleShow, e, 'fromElement');
114
- };
34
+ } // Simple implementation of mouseEnter and mouseLeave.
35
+ // React's built version is broken: https://github.com/facebook/react/issues/4251
36
+ // for cases when the trigger is disabled and mouseOut/Over can cause flicker
37
+ // moving from one child element to another.
115
38
 
116
- _this.handleMouseOut = function (e) {
117
- return _this.handleMouseOverOut(_this.handleHide, e, 'toElement');
118
- };
119
39
 
120
- _this.trigger = React.createRef();
121
- _this.state = {
122
- show: !!props.defaultShow
123
- }; // We add aria-describedby in the case where the overlay is a role="tooltip"
124
- // for other cases describedby isn't appropriate (e.g. a popover with inputs) so we don't add it.
40
+ function handleMouseOverOut(handler, e, relatedNative) {
41
+ var target = e.currentTarget;
42
+ var related = e.relatedTarget || e.nativeEvent[relatedNative];
125
43
 
126
- _this.ariaModifier = {
127
- enabled: true,
128
- order: 900,
129
- fn: function fn(data) {
130
- var popper = data.instance.popper;
131
-
132
- var target = _this.getTarget();
133
-
134
- if (!_this.state.show || !target) return data;
135
- var role = popper.getAttribute('role') || '';
136
-
137
- if (popper.id && role.toLowerCase() === 'tooltip') {
138
- target.setAttribute('aria-describedby', popper.id);
139
- }
140
-
141
- return data;
142
- }
143
- };
144
- return _this;
44
+ if ((!related || related !== target) && !contains(target, related)) {
45
+ handler(e);
145
46
  }
47
+ }
146
48
 
147
- var _proto2 = OverlayTrigger.prototype;
148
-
149
- _proto2.componentWillUnmount = function componentWillUnmount() {
150
- clearTimeout(this._timeout);
151
- };
152
-
153
- _proto2.getChildProps = function getChildProps() {
154
- return React.Children.only(this.props.children).props;
155
- };
156
-
157
- // Simple implementation of mouseEnter and mouseLeave.
158
- // React's built version is broken: https://github.com/facebook/react/issues/4251
159
- // for cases when the trigger is disabled and mouseOut/Over can cause flicker
160
- // moving from one child element to another.
161
- _proto2.handleMouseOverOut = function handleMouseOverOut(handler, e, relatedNative) {
162
- var target = e.currentTarget;
163
- var related = e.relatedTarget || e.nativeEvent[relatedNative];
49
+ var defaultProps = {
50
+ defaultShow: false,
51
+ trigger: ['hover', 'focus']
52
+ };
164
53
 
165
- if ((!related || related !== target) && !contains(target, related)) {
166
- handler(e);
54
+ function OverlayTrigger(_ref) {
55
+ var trigger = _ref.trigger,
56
+ overlay = _ref.overlay,
57
+ children = _ref.children,
58
+ _ref$popperConfig = _ref.popperConfig,
59
+ popperConfig = _ref$popperConfig === void 0 ? {} : _ref$popperConfig,
60
+ defaultShow = _ref.defaultShow,
61
+ propsDelay = _ref.delay,
62
+ props = _objectWithoutPropertiesLoose(_ref, ["trigger", "overlay", "children", "popperConfig", "defaultShow", "delay"]);
63
+
64
+ var triggerNodeRef = useRef(null);
65
+ var timeout = useTimeout();
66
+ var hoverStateRef = useRef();
67
+
68
+ var _useState = useState(!!defaultShow),
69
+ show = _useState[0],
70
+ setShow = _useState[1];
71
+
72
+ var delay = normalizeDelay(propsDelay);
73
+ var child = React.Children.only(children);
74
+ var _child$props = child.props,
75
+ onFocus = _child$props.onFocus,
76
+ onBlur = _child$props.onBlur,
77
+ onClick = _child$props.onClick;
78
+ var getTarget = useCallback(function () {
79
+ return ReactDOM.findDOMNode(triggerNodeRef.current);
80
+ }, []);
81
+ var handleShow = useCallback(function () {
82
+ timeout.clear();
83
+ hoverStateRef.current = 'show';
84
+
85
+ if (!delay.show) {
86
+ setShow(true);
87
+ return;
167
88
  }
168
- };
169
89
 
170
- _proto2.hide = function hide() {
171
- this.setState({
172
- show: false
173
- });
174
- };
90
+ timeout.set(function () {
91
+ if (hoverStateRef.current === 'show') setShow(true);
92
+ }, delay.show);
93
+ }, [delay.show, timeout]);
94
+ var handleHide = useCallback(function () {
95
+ timeout.clear();
96
+ hoverStateRef.current = 'hide';
97
+
98
+ if (!delay.hide) {
99
+ setShow(false);
100
+ return;
101
+ }
175
102
 
176
- _proto2.show = function show() {
177
- this.setState({
178
- show: true
103
+ timeout.set(function () {
104
+ if (hoverStateRef.current === 'hide') setShow(false);
105
+ }, delay.hide);
106
+ }, [delay.hide, timeout]);
107
+ var handleFocus = useCallback(function (e) {
108
+ handleShow(e);
109
+ if (onFocus) onFocus(e);
110
+ }, [handleShow, onFocus]);
111
+ var handleBlur = useCallback(function (e) {
112
+ handleHide(e);
113
+ if (onBlur) onBlur(e);
114
+ }, [handleHide, onBlur]);
115
+ var handleClick = useCallback(function (e) {
116
+ setShow(function (prevShow) {
117
+ return !prevShow;
179
118
  });
180
- };
119
+ if (onClick) onClick(e);
120
+ }, [onClick]);
121
+ var handleMouseOver = useCallback(function (e) {
122
+ handleMouseOverOut(handleShow, e, 'fromElement');
123
+ }, [handleShow]);
124
+ var handleMouseOut = useCallback(function (e) {
125
+ handleMouseOverOut(handleHide, e, 'toElement');
126
+ }, [handleHide]); // We add aria-describedby in the case where the overlay is a role="tooltip"
127
+ // for other cases describedby isn't appropriate (e.g. a popover with inputs) so we don't add it.
128
+
129
+ var ariaModifier = {
130
+ enabled: true,
131
+ order: 900,
132
+ fn: function fn(data) {
133
+ var popper = data.instance.popper;
134
+ var target = getTarget();
135
+ if (!show || !target) return data;
136
+ var role = popper.getAttribute('role') || '';
137
+
138
+ if (popper.id && role.toLowerCase() === 'tooltip') {
139
+ target.setAttribute('aria-describedby', popper.id);
140
+ }
181
141
 
182
- _proto2.render = function render() {
183
- var _this$props = this.props,
184
- trigger = _this$props.trigger,
185
- overlay = _this$props.overlay,
186
- children = _this$props.children,
187
- _this$props$popperCon = _this$props.popperConfig,
188
- popperConfig = _this$props$popperCon === void 0 ? {} : _this$props$popperCon,
189
- props = _objectWithoutPropertiesLoose(_this$props, ["trigger", "overlay", "children", "popperConfig"]);
190
-
191
- delete props.delay;
192
- delete props.defaultShow;
193
- var child = React.Children.only(children);
194
- var triggerProps = {};
195
- var triggers = trigger == null ? [] : [].concat(trigger);
196
-
197
- if (triggers.indexOf('click') !== -1) {
198
- triggerProps.onClick = this.handleClick;
142
+ return data;
199
143
  }
144
+ };
145
+ var triggers = trigger == null ? [] : [].concat(trigger);
146
+ var triggerProps = {};
200
147
 
201
- if (triggers.indexOf('focus') !== -1) {
202
- triggerProps.onFocus = this.handleShow;
203
- triggerProps.onBlur = this.handleHide;
204
- }
148
+ if (triggers.indexOf('click') !== -1) {
149
+ triggerProps.onClick = handleClick;
150
+ }
205
151
 
206
- if (triggers.indexOf('hover') !== -1) {
207
- process.env.NODE_ENV !== "production" ? warning(triggers.length >= 1, '[react-bootstrap] Specifying only the `"hover"` trigger limits the ' + 'visibility of the overlay to just mouse users. Consider also ' + 'including the `"focus"` trigger so that touch and keyboard only ' + 'users can see the overlay as well.') : void 0;
208
- triggerProps.onMouseOver = this.handleMouseOver;
209
- triggerProps.onMouseOut = this.handleMouseOut;
210
- }
152
+ if (triggers.indexOf('focus') !== -1) {
153
+ triggerProps.onFocus = handleFocus;
154
+ triggerProps.onBlur = handleBlur;
155
+ }
211
156
 
212
- return React.createElement(React.Fragment, null, React.createElement(RefHolder, {
213
- ref: this.trigger
214
- }, cloneElement(child, triggerProps)), React.createElement(Overlay, _extends({}, props, {
215
- popperConfig: _extends({}, popperConfig, {
216
- modifiers: _extends({}, popperConfig.modifiers, {
217
- ariaModifier: this.ariaModifier
218
- })
219
- }),
220
- show: this.state.show,
221
- onHide: this.handleHide,
222
- target: this.getTarget
223
- }), overlay));
224
- };
157
+ if (triggers.indexOf('hover') !== -1) {
158
+ process.env.NODE_ENV !== "production" ? warning(triggers.length > 1, '[react-bootstrap] Specifying only the `"hover"` trigger limits the visibility of the overlay to just mouse users. Consider also including the `"focus"` trigger so that touch and keyboard only users can see the overlay as well.') : void 0;
159
+ triggerProps.onMouseOver = handleMouseOver;
160
+ triggerProps.onMouseOut = handleMouseOut;
161
+ }
225
162
 
226
- return OverlayTrigger;
227
- }(React.Component);
163
+ return React.createElement(React.Fragment, null, React.createElement(RefHolder, {
164
+ ref: triggerNodeRef
165
+ }, cloneElement(child, triggerProps)), React.createElement(Overlay, _extends({}, props, {
166
+ popperConfig: _extends({}, popperConfig, {
167
+ modifiers: _extends({}, popperConfig.modifiers, {
168
+ ariaModifier: ariaModifier
169
+ })
170
+ }),
171
+ show: show,
172
+ onHide: handleHide,
173
+ target: getTarget
174
+ }), overlay));
175
+ }
228
176
 
229
177
  OverlayTrigger.defaultProps = defaultProps;
230
178
  export default OverlayTrigger;
package/esm/PageItem.js CHANGED
@@ -11,7 +11,7 @@ var defaultProps = {
11
11
  disabled: false,
12
12
  activeLabel: '(current)'
13
13
  };
14
- export default function PageItem(_ref) {
14
+ var PageItem = React.forwardRef(function (_ref, ref) {
15
15
  var active = _ref.active,
16
16
  disabled = _ref.disabled,
17
17
  className = _ref.className,
@@ -22,6 +22,7 @@ export default function PageItem(_ref) {
22
22
 
23
23
  var Component = active || disabled ? 'span' : SafeAnchor;
24
24
  return React.createElement("li", {
25
+ ref: ref,
25
26
  style: style,
26
27
  className: classNames(className, 'page-item', {
27
28
  active: active,
@@ -33,8 +34,10 @@ export default function PageItem(_ref) {
33
34
  }, props), children, active && activeLabel && React.createElement("span", {
34
35
  className: "sr-only"
35
36
  }, activeLabel)));
36
- }
37
+ });
37
38
  PageItem.defaultProps = defaultProps;
39
+ PageItem.displayName = 'PageItem';
40
+ export default PageItem;
38
41
 
39
42
  function createButton(name, defaultValue, label) {
40
43
  var _class, _temp;