react-bootstrap 0.32.0 → 0.32.4
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/CHANGELOG.md +38 -0
- package/README.md +11 -7
- package/dist/react-bootstrap.js +13464 -13723
- package/dist/react-bootstrap.min.js +10 -18464
- package/es/Accordion.js +13 -16
- package/es/Alert.js +26 -31
- package/es/Badge.js +21 -31
- package/es/Breadcrumb.js +17 -20
- package/es/BreadcrumbItem.js +30 -30
- package/es/Button.js +23 -27
- package/es/ButtonGroup.js +20 -22
- package/es/ButtonToolbar.js +16 -18
- package/es/Carousel.js +120 -157
- package/es/CarouselCaption.js +18 -21
- package/es/CarouselItem.js +34 -33
- package/es/Checkbox.js +43 -54
- package/es/Clearfix.js +24 -24
- package/es/CloseButton.js +21 -30
- package/es/Col.js +42 -26
- package/es/Collapse.js +68 -68
- package/es/ControlLabel.js +19 -24
- package/es/Dropdown.js +93 -91
- package/es/DropdownButton.js +25 -35
- package/es/DropdownMenu.js +65 -65
- package/es/DropdownToggle.js +28 -40
- package/es/Fade.js +26 -29
- package/es/Form.js +22 -22
- package/es/FormControl.js +32 -33
- package/es/FormControlFeedback.js +21 -21
- package/es/FormControlStatic.js +18 -21
- package/es/FormGroup.js +27 -34
- package/es/Glyphicon.js +18 -19
- package/es/Grid.js +20 -22
- package/es/HelpBlock.js +17 -17
- package/es/Image.js +19 -24
- package/es/InputGroup.js +17 -18
- package/es/InputGroupAddon.js +17 -17
- package/es/InputGroupButton.js +17 -17
- package/es/Jumbotron.js +18 -21
- package/es/Label.js +21 -27
- package/es/ListGroup.js +24 -29
- package/es/ListGroupItem.js +30 -48
- package/es/Media.js +18 -22
- package/es/MediaBody.js +19 -22
- package/es/MediaHeading.js +18 -21
- package/es/MediaLeft.js +18 -19
- package/es/MediaList.js +17 -17
- package/es/MediaListItem.js +17 -17
- package/es/MediaRight.js +18 -19
- package/es/MenuItem.js +44 -49
- package/es/Modal.js +63 -74
- package/es/ModalBody.js +18 -21
- package/es/ModalDialog.js +31 -39
- package/es/ModalFooter.js +18 -21
- package/es/ModalHeader.js +25 -35
- package/es/ModalTitle.js +18 -21
- package/es/Nav.js +73 -92
- package/es/NavDropdown.js +40 -52
- package/es/NavItem.js +34 -38
- package/es/Navbar.js +62 -73
- package/es/NavbarBrand.js +20 -24
- package/es/NavbarCollapse.js +21 -28
- package/es/NavbarHeader.js +19 -20
- package/es/NavbarToggle.js +30 -38
- package/es/Overlay.js +21 -25
- package/es/OverlayTrigger.js +71 -68
- package/es/PageHeader.js +18 -26
- package/es/PageItem.js +0 -1
- package/es/Pager.js +23 -30
- package/es/PagerItem.js +36 -40
- package/es/Pagination.js +18 -24
- package/es/PaginationItem.js +47 -57
- package/es/Panel.js +51 -54
- package/es/PanelBody.js +18 -29
- package/es/PanelCollapse.js +20 -23
- package/es/PanelFooter.js +16 -23
- package/es/PanelGroup.js +44 -45
- package/es/PanelHeading.js +19 -28
- package/es/PanelTitle.js +22 -34
- package/es/PanelToggle.js +21 -24
- package/es/Popover.js +36 -46
- package/es/ProgressBar.js +59 -62
- package/es/Radio.js +43 -54
- package/es/ResponsiveEmbed.js +27 -32
- package/es/Row.js +18 -21
- package/es/SafeAnchor.js +32 -32
- package/es/SplitButton.js +33 -46
- package/es/SplitToggle.js +14 -13
- package/es/Tab.js +12 -18
- package/es/TabContainer.js +24 -30
- package/es/TabContent.js +36 -43
- package/es/TabPane.js +58 -68
- package/es/Table.js +25 -29
- package/es/Tabs.js +56 -71
- package/es/Thumbnail.js +34 -34
- package/es/ToggleButton.js +32 -37
- package/es/ToggleButtonGroup.js +45 -57
- package/es/Tooltip.js +33 -40
- package/es/Well.js +17 -17
- package/es/index.js +2 -0
- package/es/utils/PropTypes.js +13 -19
- package/es/utils/StyleConfig.js +0 -4
- package/es/utils/ValidComponentChildren.js +11 -20
- package/es/utils/bootstrapUtils.js +17 -31
- package/es/utils/createChainedFunction.js +2 -2
- package/es/utils/deprecationWarning.js +28 -30
- package/es/utils/splitComponentProps.js +1 -2
- package/lib/Accordion.js +23 -36
- package/lib/Alert.js +43 -65
- package/lib/Badge.js +36 -56
- package/lib/Breadcrumb.js +32 -47
- package/lib/BreadcrumbItem.js +48 -63
- package/lib/Button.js +49 -71
- package/lib/ButtonGroup.js +39 -57
- package/lib/ButtonToolbar.js +29 -42
- package/lib/Carousel.js +161 -214
- package/lib/CarouselCaption.js +32 -46
- package/lib/CarouselItem.js +54 -73
- package/lib/Checkbox.js +64 -87
- package/lib/Clearfix.js +45 -58
- package/lib/CloseButton.js +33 -50
- package/lib/Col.js +78 -73
- package/lib/Collapse.js +104 -125
- package/lib/ControlLabel.js +38 -59
- package/lib/Dropdown.js +153 -192
- package/lib/DropdownButton.js +44 -70
- package/lib/DropdownMenu.js +96 -120
- package/lib/DropdownToggle.js +48 -77
- package/lib/Fade.js +49 -68
- package/lib/Form.js +39 -52
- package/lib/FormControl.js +58 -79
- package/lib/FormControlFeedback.js +42 -54
- package/lib/FormControlStatic.js +32 -46
- package/lib/FormGroup.js +47 -67
- package/lib/Glyphicon.js +33 -46
- package/lib/Grid.js +36 -51
- package/lib/HelpBlock.js +29 -40
- package/lib/Image.js +37 -53
- package/lib/InputGroup.js +34 -49
- package/lib/InputGroupAddon.js +29 -40
- package/lib/InputGroupButton.js +29 -40
- package/lib/Jumbotron.js +32 -46
- package/lib/Label.js +35 -53
- package/lib/ListGroup.js +45 -61
- package/lib/ListGroupItem.js +55 -85
- package/lib/Media.js +43 -70
- package/lib/MediaBody.js +37 -55
- package/lib/MediaHeading.js +32 -46
- package/lib/MediaLeft.js +34 -48
- package/lib/MediaList.js +29 -40
- package/lib/MediaListItem.js +29 -40
- package/lib/MediaRight.js +34 -48
- package/lib/MenuItem.js +70 -92
- package/lib/Modal.js +130 -186
- package/lib/ModalBody.js +32 -46
- package/lib/ModalDialog.js +47 -69
- package/lib/ModalFooter.js +32 -46
- package/lib/ModalHeader.js +43 -70
- package/lib/ModalTitle.js +32 -46
- package/lib/Nav.js +122 -160
- package/lib/NavDropdown.js +63 -97
- package/lib/NavItem.js +54 -77
- package/lib/Navbar.js +115 -152
- package/lib/NavbarBrand.js +37 -55
- package/lib/NavbarCollapse.js +36 -57
- package/lib/NavbarHeader.js +33 -48
- package/lib/NavbarToggle.js +52 -77
- package/lib/Overlay.js +50 -75
- package/lib/OverlayTrigger.js +114 -129
- package/lib/PageHeader.js +30 -49
- package/lib/PageItem.js +9 -10
- package/lib/Pager.js +41 -63
- package/lib/PagerItem.js +55 -78
- package/lib/Pagination.js +32 -50
- package/lib/PaginationItem.js +67 -91
- package/lib/Panel.js +93 -127
- package/lib/PanelBody.js +35 -57
- package/lib/PanelCollapse.js +44 -56
- package/lib/PanelFooter.js +31 -48
- package/lib/PanelGroup.js +73 -88
- package/lib/PanelHeading.js +37 -59
- package/lib/PanelTitle.js +41 -68
- package/lib/PanelToggle.js +45 -66
- package/lib/Popover.js +59 -84
- package/lib/ProgressBar.js +86 -103
- package/lib/Radio.js +64 -87
- package/lib/ResponsiveEmbed.js +45 -63
- package/lib/Row.js +32 -46
- package/lib/SafeAnchor.js +53 -69
- package/lib/SplitButton.js +57 -90
- package/lib/SplitToggle.js +25 -34
- package/lib/Tab.js +32 -55
- package/lib/TabContainer.js +45 -61
- package/lib/TabContent.js +67 -87
- package/lib/TabPane.js +103 -131
- package/lib/Table.js +44 -59
- package/lib/Tabs.js +82 -119
- package/lib/Thumbnail.js +55 -67
- package/lib/ToggleButton.js +49 -68
- package/lib/ToggleButtonGroup.js +67 -104
- package/lib/Tooltip.js +55 -77
- package/lib/Well.js +30 -41
- package/lib/index.js +147 -214
- package/lib/utils/PropTypes.js +24 -31
- package/lib/utils/StyleConfig.js +13 -11
- package/lib/utils/ValidComponentChildren.js +34 -29
- package/lib/utils/bootstrapUtils.js +41 -52
- package/lib/utils/capitalize.js +2 -0
- package/lib/utils/createChainedFunction.js +8 -5
- package/lib/utils/deprecationWarning.js +37 -47
- package/lib/utils/index.js +11 -15
- package/lib/utils/splitComponentProps.js +5 -10
- package/package.json +58 -50
package/lib/Nav.js
CHANGED
|
@@ -1,92 +1,59 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var _extends3 = require('babel-runtime/helpers/extends');
|
|
6
|
-
|
|
7
|
-
var _extends4 = _interopRequireDefault(_extends3);
|
|
8
|
-
|
|
9
|
-
var _objectWithoutProperties2 = require('babel-runtime/helpers/objectWithoutProperties');
|
|
10
|
-
|
|
11
|
-
var _objectWithoutProperties3 = _interopRequireDefault(_objectWithoutProperties2);
|
|
12
|
-
|
|
13
|
-
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
|
|
14
|
-
|
|
15
|
-
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
|
|
16
|
-
|
|
17
|
-
var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
|
|
18
|
-
|
|
19
|
-
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
|
|
20
|
-
|
|
21
|
-
var _inherits2 = require('babel-runtime/helpers/inherits');
|
|
22
|
-
|
|
23
|
-
var _inherits3 = _interopRequireDefault(_inherits2);
|
|
24
|
-
|
|
25
|
-
var _classnames = require('classnames');
|
|
26
|
-
|
|
27
|
-
var _classnames2 = _interopRequireDefault(_classnames);
|
|
28
|
-
|
|
29
|
-
var _keycode = require('keycode');
|
|
3
|
+
var _interopRequireWildcard = require("@babel/runtime-corejs2/helpers/interopRequireWildcard");
|
|
30
4
|
|
|
31
|
-
var
|
|
5
|
+
var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
|
|
32
6
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
var _react2 = _interopRequireDefault(_react);
|
|
36
|
-
|
|
37
|
-
var _propTypes = require('prop-types');
|
|
7
|
+
exports.__esModule = true;
|
|
8
|
+
exports.default = void 0;
|
|
38
9
|
|
|
39
|
-
var
|
|
10
|
+
var _extends3 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/extends"));
|
|
40
11
|
|
|
41
|
-
var
|
|
12
|
+
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/objectWithoutPropertiesLoose"));
|
|
42
13
|
|
|
43
|
-
var
|
|
14
|
+
var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/inheritsLoose"));
|
|
44
15
|
|
|
45
|
-
var
|
|
16
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
46
17
|
|
|
47
|
-
var
|
|
18
|
+
var _keycode = _interopRequireDefault(require("keycode"));
|
|
48
19
|
|
|
49
|
-
var
|
|
20
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
50
21
|
|
|
51
|
-
var
|
|
22
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
52
23
|
|
|
53
|
-
var
|
|
24
|
+
var _reactDom = _interopRequireDefault(require("react-dom"));
|
|
54
25
|
|
|
55
|
-
var
|
|
26
|
+
var _all = _interopRequireDefault(require("prop-types-extra/lib/all"));
|
|
56
27
|
|
|
57
|
-
var
|
|
28
|
+
var _warning = _interopRequireDefault(require("warning"));
|
|
58
29
|
|
|
59
|
-
var
|
|
30
|
+
var _bootstrapUtils = require("./utils/bootstrapUtils");
|
|
60
31
|
|
|
61
|
-
var
|
|
32
|
+
var _createChainedFunction = _interopRequireDefault(require("./utils/createChainedFunction"));
|
|
62
33
|
|
|
63
|
-
|
|
34
|
+
var _ValidComponentChildren = _interopRequireDefault(require("./utils/ValidComponentChildren"));
|
|
64
35
|
|
|
65
36
|
// TODO: Should we expose `<NavItem>` as `<Nav.Item>`?
|
|
66
|
-
|
|
67
37
|
// TODO: This `bsStyle` is very unlike the others. Should we rename it?
|
|
68
|
-
|
|
69
38
|
// TODO: `pullRight` and `pullLeft` don't render right outside of `navbar`.
|
|
70
39
|
// Consider renaming or replacing them.
|
|
71
|
-
|
|
72
40
|
var propTypes = {
|
|
73
41
|
/**
|
|
74
42
|
* Marks the NavItem with a matching `eventKey` as active. Has a
|
|
75
43
|
* higher precedence over `activeHref`.
|
|
76
44
|
*/
|
|
77
|
-
activeKey:
|
|
45
|
+
activeKey: _propTypes.default.any,
|
|
78
46
|
|
|
79
47
|
/**
|
|
80
48
|
* Marks the child NavItem with a matching `href` prop as active.
|
|
81
49
|
*/
|
|
82
|
-
activeHref:
|
|
50
|
+
activeHref: _propTypes.default.string,
|
|
83
51
|
|
|
84
52
|
/**
|
|
85
53
|
* NavItems are be positioned vertically.
|
|
86
54
|
*/
|
|
87
|
-
stacked:
|
|
88
|
-
|
|
89
|
-
justified: (0, _all2.default)(_propTypes2.default.bool, function (_ref) {
|
|
55
|
+
stacked: _propTypes.default.bool,
|
|
56
|
+
justified: (0, _all.default)(_propTypes.default.bool, function (_ref) {
|
|
90
57
|
var justified = _ref.justified,
|
|
91
58
|
navbar = _ref.navbar;
|
|
92
59
|
return justified && navbar ? Error('justified navbar `Nav`s are not supported') : null;
|
|
@@ -102,7 +69,7 @@ var propTypes = {
|
|
|
102
69
|
* )
|
|
103
70
|
* ```
|
|
104
71
|
*/
|
|
105
|
-
onSelect:
|
|
72
|
+
onSelect: _propTypes.default.func,
|
|
106
73
|
|
|
107
74
|
/**
|
|
108
75
|
* ARIA role for the Nav, in the context of a TabContainer, the default will
|
|
@@ -112,79 +79,80 @@ var propTypes = {
|
|
|
112
79
|
* the ARIA authoring practices for tabs:
|
|
113
80
|
* https://www.w3.org/TR/2013/WD-wai-aria-practices-20130307/#tabpanel
|
|
114
81
|
*/
|
|
115
|
-
role:
|
|
82
|
+
role: _propTypes.default.string,
|
|
116
83
|
|
|
117
84
|
/**
|
|
118
85
|
* Apply styling an alignment for use in a Navbar. This prop will be set
|
|
119
86
|
* automatically when the Nav is used inside a Navbar.
|
|
120
87
|
*/
|
|
121
|
-
navbar:
|
|
88
|
+
navbar: _propTypes.default.bool,
|
|
122
89
|
|
|
123
90
|
/**
|
|
124
91
|
* Float the Nav to the right. When `navbar` is `true` the appropriate
|
|
125
92
|
* contextual classes are added as well.
|
|
126
93
|
*/
|
|
127
|
-
pullRight:
|
|
94
|
+
pullRight: _propTypes.default.bool,
|
|
128
95
|
|
|
129
96
|
/**
|
|
130
97
|
* Float the Nav to the left. When `navbar` is `true` the appropriate
|
|
131
98
|
* contextual classes are added as well.
|
|
132
99
|
*/
|
|
133
|
-
pullLeft:
|
|
100
|
+
pullLeft: _propTypes.default.bool
|
|
134
101
|
};
|
|
135
|
-
|
|
136
102
|
var defaultProps = {
|
|
137
103
|
justified: false,
|
|
138
104
|
pullRight: false,
|
|
139
105
|
pullLeft: false,
|
|
140
106
|
stacked: false
|
|
141
107
|
};
|
|
142
|
-
|
|
143
108
|
var contextTypes = {
|
|
144
|
-
$bs_navbar:
|
|
145
|
-
bsClass:
|
|
146
|
-
onSelect:
|
|
109
|
+
$bs_navbar: _propTypes.default.shape({
|
|
110
|
+
bsClass: _propTypes.default.string,
|
|
111
|
+
onSelect: _propTypes.default.func
|
|
147
112
|
}),
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
getPaneId: _propTypes2.default.func.isRequired
|
|
113
|
+
$bs_tabContainer: _propTypes.default.shape({
|
|
114
|
+
activeKey: _propTypes.default.any,
|
|
115
|
+
onSelect: _propTypes.default.func.isRequired,
|
|
116
|
+
getTabId: _propTypes.default.func.isRequired,
|
|
117
|
+
getPaneId: _propTypes.default.func.isRequired
|
|
154
118
|
})
|
|
155
119
|
};
|
|
156
120
|
|
|
157
|
-
var Nav =
|
|
158
|
-
|
|
121
|
+
var Nav =
|
|
122
|
+
/*#__PURE__*/
|
|
123
|
+
function (_React$Component) {
|
|
124
|
+
(0, _inheritsLoose2.default)(Nav, _React$Component);
|
|
159
125
|
|
|
160
126
|
function Nav() {
|
|
161
|
-
|
|
162
|
-
return (0, _possibleConstructorReturn3.default)(this, _React$Component.apply(this, arguments));
|
|
127
|
+
return _React$Component.apply(this, arguments) || this;
|
|
163
128
|
}
|
|
164
129
|
|
|
165
|
-
Nav.prototype
|
|
166
|
-
|
|
130
|
+
var _proto = Nav.prototype;
|
|
131
|
+
|
|
132
|
+
_proto.componentDidUpdate = function componentDidUpdate() {
|
|
133
|
+
var _this = this;
|
|
167
134
|
|
|
168
135
|
if (!this._needsRefocus) {
|
|
169
136
|
return;
|
|
170
137
|
}
|
|
171
138
|
|
|
172
139
|
this._needsRefocus = false;
|
|
173
|
-
|
|
174
140
|
var children = this.props.children;
|
|
175
141
|
|
|
176
|
-
var
|
|
177
|
-
activeKey =
|
|
178
|
-
activeHref =
|
|
142
|
+
var _this$getActiveProps = this.getActiveProps(),
|
|
143
|
+
activeKey = _this$getActiveProps.activeKey,
|
|
144
|
+
activeHref = _this$getActiveProps.activeHref;
|
|
179
145
|
|
|
180
|
-
var activeChild =
|
|
181
|
-
return
|
|
146
|
+
var activeChild = _ValidComponentChildren.default.find(children, function (child) {
|
|
147
|
+
return _this.isActive(child, activeKey, activeHref);
|
|
182
148
|
});
|
|
183
149
|
|
|
184
|
-
var childrenArray =
|
|
150
|
+
var childrenArray = _ValidComponentChildren.default.toArray(children);
|
|
151
|
+
|
|
185
152
|
var activeChildIndex = childrenArray.indexOf(activeChild);
|
|
186
153
|
|
|
187
|
-
var childNodes =
|
|
154
|
+
var childNodes = _reactDom.default.findDOMNode(this).children;
|
|
155
|
+
|
|
188
156
|
var activeNode = childNodes && childNodes[activeChildIndex];
|
|
189
157
|
|
|
190
158
|
if (!activeNode || !activeNode.firstChild) {
|
|
@@ -194,37 +162,36 @@ var Nav = function (_React$Component) {
|
|
|
194
162
|
activeNode.firstChild.focus();
|
|
195
163
|
};
|
|
196
164
|
|
|
197
|
-
|
|
165
|
+
_proto.getActiveProps = function getActiveProps() {
|
|
198
166
|
var tabContainer = this.context.$bs_tabContainer;
|
|
199
167
|
|
|
200
168
|
if (tabContainer) {
|
|
201
|
-
process.env.NODE_ENV !==
|
|
202
|
-
|
|
169
|
+
process.env.NODE_ENV !== "production" ? (0, _warning.default)(this.props.activeKey == null && !this.props.activeHref, 'Specifying a `<Nav>` `activeKey` or `activeHref` in the context of ' + 'a `<TabContainer>` is not supported. Instead use `<TabContainer ' + ("activeKey={" + this.props.activeKey + "} />`.")) : void 0;
|
|
203
170
|
return tabContainer;
|
|
204
171
|
}
|
|
205
172
|
|
|
206
173
|
return this.props;
|
|
207
174
|
};
|
|
208
175
|
|
|
209
|
-
|
|
210
|
-
var
|
|
176
|
+
_proto.getNextActiveChild = function getNextActiveChild(offset) {
|
|
177
|
+
var _this2 = this;
|
|
211
178
|
|
|
212
179
|
var children = this.props.children;
|
|
213
|
-
|
|
214
180
|
var validChildren = children.filter(function (child) {
|
|
215
181
|
return child.props.eventKey != null && !child.props.disabled;
|
|
216
182
|
});
|
|
217
183
|
|
|
218
|
-
var
|
|
219
|
-
activeKey =
|
|
220
|
-
activeHref =
|
|
184
|
+
var _this$getActiveProps2 = this.getActiveProps(),
|
|
185
|
+
activeKey = _this$getActiveProps2.activeKey,
|
|
186
|
+
activeHref = _this$getActiveProps2.activeHref;
|
|
187
|
+
|
|
188
|
+
var activeChild = _ValidComponentChildren.default.find(children, function (child) {
|
|
189
|
+
return _this2.isActive(child, activeKey, activeHref);
|
|
190
|
+
}); // This assumes the active child is not disabled.
|
|
221
191
|
|
|
222
|
-
var activeChild = _ValidComponentChildren2.default.find(children, function (child) {
|
|
223
|
-
return _this3.isActive(child, activeKey, activeHref);
|
|
224
|
-
});
|
|
225
192
|
|
|
226
|
-
// This assumes the active child is not disabled.
|
|
227
193
|
var activeChildIndex = validChildren.indexOf(activeChild);
|
|
194
|
+
|
|
228
195
|
if (activeChildIndex === -1) {
|
|
229
196
|
// Something has gone wrong. Select the first valid child we can find.
|
|
230
197
|
return validChildren[0];
|
|
@@ -242,8 +209,8 @@ var Nav = function (_React$Component) {
|
|
|
242
209
|
return validChildren[nextIndex];
|
|
243
210
|
};
|
|
244
211
|
|
|
245
|
-
|
|
246
|
-
var
|
|
212
|
+
_proto.getTabProps = function getTabProps(child, tabContainer, navRole, active, onSelect) {
|
|
213
|
+
var _this3 = this;
|
|
247
214
|
|
|
248
215
|
if (!tabContainer && navRole !== 'tablist') {
|
|
249
216
|
// No tab props here.
|
|
@@ -258,18 +225,16 @@ var Nav = function (_React$Component) {
|
|
|
258
225
|
onKeyDown = _child$props.onKeyDown,
|
|
259
226
|
tabIndex = _child$props.tabIndex;
|
|
260
227
|
|
|
261
|
-
|
|
262
228
|
if (tabContainer) {
|
|
263
|
-
process.env.NODE_ENV !==
|
|
264
|
-
|
|
229
|
+
process.env.NODE_ENV !== "production" ? (0, _warning.default)(!id && !controls, 'In the context of a `<TabContainer>`, `<NavItem>`s are given ' + 'generated `id` and `aria-controls` attributes for the sake of ' + 'proper component accessibility. Any provided ones will be ignored. ' + 'To control these attributes directly, provide a `generateChildId` ' + 'prop to the parent `<TabContainer>`.') : void 0;
|
|
265
230
|
id = tabContainer.getTabId(eventKey);
|
|
266
231
|
controls = tabContainer.getPaneId(eventKey);
|
|
267
232
|
}
|
|
268
233
|
|
|
269
234
|
if (navRole === 'tablist') {
|
|
270
235
|
role = role || 'tab';
|
|
271
|
-
onKeyDown = (0,
|
|
272
|
-
return
|
|
236
|
+
onKeyDown = (0, _createChainedFunction.default)(function (event) {
|
|
237
|
+
return _this3.handleTabKeyDown(onSelect, event);
|
|
273
238
|
}, onKeyDown);
|
|
274
239
|
tabIndex = active ? tabIndex : -1;
|
|
275
240
|
}
|
|
@@ -283,18 +248,20 @@ var Nav = function (_React$Component) {
|
|
|
283
248
|
};
|
|
284
249
|
};
|
|
285
250
|
|
|
286
|
-
|
|
287
|
-
var nextActiveChild
|
|
251
|
+
_proto.handleTabKeyDown = function handleTabKeyDown(onSelect, event) {
|
|
252
|
+
var nextActiveChild;
|
|
288
253
|
|
|
289
254
|
switch (event.keyCode) {
|
|
290
|
-
case
|
|
291
|
-
case
|
|
255
|
+
case _keycode.default.codes.left:
|
|
256
|
+
case _keycode.default.codes.up:
|
|
292
257
|
nextActiveChild = this.getNextActiveChild(-1);
|
|
293
258
|
break;
|
|
294
|
-
|
|
295
|
-
case
|
|
259
|
+
|
|
260
|
+
case _keycode.default.codes.right:
|
|
261
|
+
case _keycode.default.codes.down:
|
|
296
262
|
nextActiveChild = this.getNextActiveChild(1);
|
|
297
263
|
break;
|
|
264
|
+
|
|
298
265
|
default:
|
|
299
266
|
// It was a different key; don't handle this keypress.
|
|
300
267
|
return;
|
|
@@ -309,7 +276,7 @@ var Nav = function (_React$Component) {
|
|
|
309
276
|
this._needsRefocus = true;
|
|
310
277
|
};
|
|
311
278
|
|
|
312
|
-
|
|
279
|
+
_proto.isActive = function isActive(_ref2, activeKey, activeHref) {
|
|
313
280
|
var props = _ref2.props;
|
|
314
281
|
|
|
315
282
|
if (props.active || activeKey != null && props.eventKey === activeKey || activeHref && props.href === activeHref) {
|
|
@@ -319,48 +286,46 @@ var Nav = function (_React$Component) {
|
|
|
319
286
|
return props.active;
|
|
320
287
|
};
|
|
321
288
|
|
|
322
|
-
|
|
289
|
+
_proto.render = function render() {
|
|
323
290
|
var _extends2,
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
var
|
|
327
|
-
stacked =
|
|
328
|
-
justified =
|
|
329
|
-
onSelect =
|
|
330
|
-
propsRole =
|
|
331
|
-
propsNavbar =
|
|
332
|
-
pullRight =
|
|
333
|
-
pullLeft =
|
|
334
|
-
className =
|
|
335
|
-
children =
|
|
336
|
-
props = (0,
|
|
337
|
-
|
|
338
|
-
|
|
291
|
+
_this4 = this;
|
|
292
|
+
|
|
293
|
+
var _this$props = this.props,
|
|
294
|
+
stacked = _this$props.stacked,
|
|
295
|
+
justified = _this$props.justified,
|
|
296
|
+
onSelect = _this$props.onSelect,
|
|
297
|
+
propsRole = _this$props.role,
|
|
298
|
+
propsNavbar = _this$props.navbar,
|
|
299
|
+
pullRight = _this$props.pullRight,
|
|
300
|
+
pullLeft = _this$props.pullLeft,
|
|
301
|
+
className = _this$props.className,
|
|
302
|
+
children = _this$props.children,
|
|
303
|
+
props = (0, _objectWithoutPropertiesLoose2.default)(_this$props, ["stacked", "justified", "onSelect", "role", "navbar", "pullRight", "pullLeft", "className", "children"]);
|
|
339
304
|
var tabContainer = this.context.$bs_tabContainer;
|
|
340
305
|
var role = propsRole || (tabContainer ? 'tablist' : null);
|
|
341
306
|
|
|
342
|
-
var
|
|
343
|
-
activeKey =
|
|
344
|
-
activeHref =
|
|
307
|
+
var _this$getActiveProps3 = this.getActiveProps(),
|
|
308
|
+
activeKey = _this$getActiveProps3.activeKey,
|
|
309
|
+
activeHref = _this$getActiveProps3.activeHref;
|
|
345
310
|
|
|
346
311
|
delete props.activeKey; // Accessed via this.getActiveProps().
|
|
312
|
+
|
|
347
313
|
delete props.activeHref; // Accessed via this.getActiveProps().
|
|
348
314
|
|
|
349
315
|
var _splitBsProps = (0, _bootstrapUtils.splitBsProps)(props),
|
|
350
316
|
bsProps = _splitBsProps[0],
|
|
351
317
|
elementProps = _splitBsProps[1];
|
|
352
318
|
|
|
353
|
-
var classes = (0,
|
|
354
|
-
|
|
319
|
+
var classes = (0, _extends3.default)({}, (0, _bootstrapUtils.getClassSet)(bsProps), (_extends2 = {}, _extends2[(0, _bootstrapUtils.prefix)(bsProps, 'stacked')] = stacked, _extends2[(0, _bootstrapUtils.prefix)(bsProps, 'justified')] = justified, _extends2));
|
|
355
320
|
var navbar = propsNavbar != null ? propsNavbar : this.context.$bs_navbar;
|
|
356
|
-
var pullLeftClassName
|
|
357
|
-
var pullRightClassName
|
|
321
|
+
var pullLeftClassName;
|
|
322
|
+
var pullRightClassName;
|
|
358
323
|
|
|
359
324
|
if (navbar) {
|
|
360
|
-
var navbarProps = this.context.$bs_navbar || {
|
|
361
|
-
|
|
325
|
+
var navbarProps = this.context.$bs_navbar || {
|
|
326
|
+
bsClass: 'navbar'
|
|
327
|
+
};
|
|
362
328
|
classes[(0, _bootstrapUtils.prefix)(navbarProps, 'nav')] = true;
|
|
363
|
-
|
|
364
329
|
pullRightClassName = (0, _bootstrapUtils.prefix)(navbarProps, 'right');
|
|
365
330
|
pullLeftClassName = (0, _bootstrapUtils.prefix)(navbarProps, 'left');
|
|
366
331
|
} else {
|
|
@@ -370,33 +335,30 @@ var Nav = function (_React$Component) {
|
|
|
370
335
|
|
|
371
336
|
classes[pullRightClassName] = pullRight;
|
|
372
337
|
classes[pullLeftClassName] = pullLeft;
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
activeHref: activeHref,
|
|
388
|
-
onSelect: childOnSelect
|
|
389
|
-
}));
|
|
390
|
-
})
|
|
391
|
-
);
|
|
338
|
+
return _react.default.createElement("ul", (0, _extends3.default)({}, elementProps, {
|
|
339
|
+
role: role,
|
|
340
|
+
className: (0, _classnames.default)(className, classes)
|
|
341
|
+
}), _ValidComponentChildren.default.map(children, function (child) {
|
|
342
|
+
var active = _this4.isActive(child, activeKey, activeHref);
|
|
343
|
+
|
|
344
|
+
var childOnSelect = (0, _createChainedFunction.default)(child.props.onSelect, onSelect, navbar && navbar.onSelect, tabContainer && tabContainer.onSelect);
|
|
345
|
+
return (0, _react.cloneElement)(child, (0, _extends3.default)({}, _this4.getTabProps(child, tabContainer, role, active, childOnSelect), {
|
|
346
|
+
active: active,
|
|
347
|
+
activeKey: activeKey,
|
|
348
|
+
activeHref: activeHref,
|
|
349
|
+
onSelect: childOnSelect
|
|
350
|
+
}));
|
|
351
|
+
}));
|
|
392
352
|
};
|
|
393
353
|
|
|
394
354
|
return Nav;
|
|
395
|
-
}(
|
|
355
|
+
}(_react.default.Component);
|
|
396
356
|
|
|
397
357
|
Nav.propTypes = propTypes;
|
|
398
358
|
Nav.defaultProps = defaultProps;
|
|
399
359
|
Nav.contextTypes = contextTypes;
|
|
400
360
|
|
|
401
|
-
|
|
402
|
-
|
|
361
|
+
var _default = (0, _bootstrapUtils.bsClass)('nav', (0, _bootstrapUtils.bsStyles)(['tabs', 'pills'], Nav));
|
|
362
|
+
|
|
363
|
+
exports.default = _default;
|
|
364
|
+
module.exports = exports["default"];
|