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.
- package/AccordionToggle.d.ts +4 -5
- package/BootstrapModalManager/package.json +6 -0
- package/Container.d.ts +1 -1
- package/ElementChildren/package.json +6 -0
- package/FormControl.d.ts +7 -2
- package/ListGroup.d.ts +1 -0
- package/Modal.d.ts +1 -0
- package/Overlay.d.ts +1 -1
- package/OverlayTrigger.d.ts +1 -0
- package/ToggleButton.d.ts +0 -1
- package/cjs/AbstractNav.js +1 -1
- package/cjs/Alert.js +4 -4
- package/cjs/{utils/BootstrapModalManager.js → BootstrapModalManager.js} +9 -5
- package/cjs/Card.js +2 -2
- package/cjs/CardColumns.js +1 -1
- package/cjs/CardDeck.js +1 -1
- package/cjs/CardGroup.js +1 -1
- package/cjs/Carousel.js +9 -9
- package/cjs/CarouselCaption.js +1 -1
- package/cjs/CarouselItem.js +1 -1
- package/cjs/Collapse.js +7 -7
- package/cjs/Container.js +3 -3
- package/cjs/Dropdown.js +5 -5
- package/cjs/DropdownMenu.js +39 -46
- package/cjs/DropdownToggle.js +31 -58
- package/cjs/{utils/ElementChildren.js → ElementChildren.js} +0 -0
- package/cjs/Fade.js +4 -4
- package/cjs/Figure.js +1 -1
- package/cjs/FigureCaption.js +1 -1
- package/cjs/Form.js +1 -1
- package/cjs/FormLabel.js +3 -1
- package/cjs/InputGroup.js +1 -1
- package/cjs/ListGroup.js +16 -3
- package/cjs/Media.js +1 -1
- package/cjs/Modal.js +32 -18
- package/cjs/ModalBody.js +1 -1
- package/cjs/ModalDialog.js +1 -1
- package/cjs/ModalFooter.js +1 -1
- package/cjs/ModalTitle.js +2 -2
- package/cjs/NavDropdown.js +64 -41
- package/cjs/Navbar.js +1 -1
- package/cjs/OverlayTrigger.js +131 -182
- package/cjs/PageItem.js +7 -4
- package/cjs/Pagination.js +21 -36
- package/cjs/Popover.js +9 -10
- package/cjs/ProgressBar.js +1 -1
- package/cjs/ResponsiveEmbed.js +19 -35
- package/cjs/Row.js +1 -0
- package/cjs/SafeAnchor.js +1 -1
- package/cjs/SplitButton.js +9 -3
- package/cjs/TabContent.js +15 -31
- package/cjs/Table.js +31 -47
- package/cjs/Tabs.js +1 -1
- package/cjs/ToastBody.js +1 -1
- package/cjs/ToggleButton.js +45 -78
- package/cjs/ToggleButtonGroup.js +44 -65
- package/cjs/Tooltip.js +2 -1
- package/cjs/{utils/createChainedFunction.js → createChainedFunction.js} +0 -0
- package/cjs/{utils/createWithBsPrefix.js → createWithBsPrefix.js} +3 -3
- package/cjs/{utils/divWithClassName.js → divWithClassName.js} +0 -0
- package/cjs/index.js +4 -0
- package/cjs/{utils/triggerBrowserReflow.js → triggerBrowserReflow.js} +0 -0
- package/cjs/useWrappedRefWithWarning.js +24 -0
- package/createChainedFunction/package.json +6 -0
- package/createWithBsPrefix/package.json +6 -0
- package/dist/react-bootstrap.js +9477 -11933
- package/dist/react-bootstrap.min.js +4 -12
- package/divWithClassName/package.json +6 -0
- package/esm/AbstractNav.js +1 -1
- package/esm/AccordionToggle.d.ts +4 -5
- package/esm/Alert.js +4 -4
- package/esm/{utils/BootstrapModalManager.js → BootstrapModalManager.js} +9 -5
- package/esm/Card.js +2 -2
- package/esm/CardColumns.js +1 -1
- package/esm/CardDeck.js +1 -1
- package/esm/CardGroup.js +1 -1
- package/esm/Carousel.js +6 -6
- package/esm/CarouselCaption.js +1 -1
- package/esm/CarouselItem.js +1 -1
- package/esm/Collapse.js +6 -6
- package/esm/Container.d.ts +1 -1
- package/esm/Container.js +3 -3
- package/esm/Dropdown.js +4 -4
- package/esm/DropdownMenu.js +34 -43
- package/esm/DropdownToggle.js +30 -56
- package/esm/{utils/ElementChildren.js → ElementChildren.js} +0 -0
- package/esm/Fade.js +3 -3
- package/esm/Figure.js +1 -1
- package/esm/FigureCaption.js +1 -1
- package/esm/Form.js +1 -1
- package/esm/FormControl.d.ts +7 -2
- package/esm/FormLabel.js +3 -1
- package/esm/InputGroup.js +1 -1
- package/esm/ListGroup.d.ts +1 -0
- package/esm/ListGroup.js +15 -3
- package/esm/Media.js +1 -1
- package/esm/Modal.d.ts +1 -0
- package/esm/Modal.js +28 -15
- package/esm/ModalBody.js +1 -1
- package/esm/ModalDialog.js +1 -1
- package/esm/ModalFooter.js +1 -1
- package/esm/ModalTitle.js +2 -2
- package/esm/NavDropdown.js +61 -41
- package/esm/Navbar.js +1 -1
- package/esm/Overlay.d.ts +1 -1
- package/esm/OverlayTrigger.d.ts +1 -0
- package/esm/OverlayTrigger.js +130 -182
- package/esm/PageItem.js +5 -2
- package/esm/Pagination.js +22 -37
- package/esm/Popover.js +10 -13
- package/esm/ProgressBar.js +1 -1
- package/esm/ResponsiveEmbed.js +18 -33
- package/esm/Row.js +1 -0
- package/esm/SafeAnchor.js +1 -1
- package/esm/SplitButton.js +9 -3
- package/esm/TabContent.js +15 -31
- package/esm/Table.js +32 -48
- package/esm/Tabs.js +1 -1
- package/esm/ToastBody.js +1 -1
- package/esm/ToggleButton.d.ts +0 -1
- package/esm/ToggleButton.js +44 -79
- package/esm/ToggleButtonGroup.js +42 -65
- package/esm/Tooltip.js +2 -1
- package/esm/{utils/createChainedFunction.js → createChainedFunction.js} +0 -0
- package/esm/{utils/createWithBsPrefix.js → createWithBsPrefix.js} +2 -2
- package/esm/{utils/divWithClassName.js → divWithClassName.js} +0 -0
- package/esm/index.d.ts +1 -0
- package/esm/index.js +2 -0
- package/esm/{utils/triggerBrowserReflow.js → triggerBrowserReflow.js} +0 -0
- package/esm/useWrappedRefWithWarning.js +12 -0
- package/index.d.ts +1 -0
- package/package.json +12 -16
- package/triggerBrowserReflow/package.json +6 -0
- 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
|
|
5
|
+
import addEventListener from 'dom-helpers/addEventListener';
|
|
6
|
+
import canUseDOM from 'dom-helpers/canUseDOM';
|
|
6
7
|
import ownerDocument from 'dom-helpers/ownerDocument';
|
|
7
|
-
import
|
|
8
|
-
import getScrollbarSize from 'dom-helpers/
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
166
|
+
removeEventListener(window, 'resize', this.handleWindowResize);
|
|
154
167
|
};
|
|
155
168
|
|
|
156
169
|
_proto.updateDialogStyle = function updateDialogStyle(node) {
|
|
157
170
|
if (!canUseDOM) return;
|
|
158
|
-
var
|
|
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", "
|
|
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:
|
|
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 './
|
|
1
|
+
import createWithBsPrefix from './createWithBsPrefix';
|
|
2
2
|
export default createWithBsPrefix('modal-body');
|
package/esm/ModalDialog.js
CHANGED
|
@@ -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:
|
|
21
|
+
className: bsPrefix + "-content"
|
|
22
22
|
}, children));
|
|
23
23
|
});
|
|
24
24
|
ModalDialog.displayName = 'ModalDialog';
|
package/esm/ModalFooter.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import createWithBsPrefix from './
|
|
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 './
|
|
2
|
-
import divWithClassName from './
|
|
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
|
package/esm/NavDropdown.js
CHANGED
|
@@ -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
|
-
|
|
10
|
-
|
|
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 './
|
|
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
|
}
|
package/esm/OverlayTrigger.d.ts
CHANGED
|
@@ -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;
|
package/esm/OverlayTrigger.js
CHANGED
|
@@ -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/
|
|
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
|
-
|
|
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
|
-
|
|
36
|
-
|
|
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
|
-
|
|
121
|
-
|
|
122
|
-
|
|
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
|
-
|
|
127
|
-
|
|
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
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
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
|
-
|
|
166
|
-
|
|
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
|
-
|
|
171
|
-
|
|
172
|
-
|
|
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
|
-
|
|
177
|
-
|
|
178
|
-
|
|
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
|
-
|
|
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
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
}
|
|
148
|
+
if (triggers.indexOf('click') !== -1) {
|
|
149
|
+
triggerProps.onClick = handleClick;
|
|
150
|
+
}
|
|
205
151
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
}
|
|
152
|
+
if (triggers.indexOf('focus') !== -1) {
|
|
153
|
+
triggerProps.onFocus = handleFocus;
|
|
154
|
+
triggerProps.onBlur = handleBlur;
|
|
155
|
+
}
|
|
211
156
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
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
|
|
227
|
-
|
|
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
|
-
|
|
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;
|