@carbon/react 1.6.0-rc.0 → 1.6.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/es/components/DataTable/TableToolbarSearch.js +10 -2
- package/es/components/Layer/index.js +13 -1
- package/es/components/OverflowMenu/OverflowMenu.js +0 -1
- package/es/components/UIShell/HeaderMenu.js +1 -1
- package/es/components/UIShell/HeaderMenuButton.js +3 -4
- package/es/components/UIShell/HeaderName.js +3 -4
- package/es/components/UIShell/HeaderNavigation.js +27 -75
- package/es/components/UIShell/SideNavFooter.js +3 -10
- package/es/components/UIShell/SideNavIcon.js +3 -4
- package/es/components/UIShell/SideNavItem.js +4 -5
- package/es/components/UIShell/SideNavLink.js +0 -6
- package/es/components/UIShell/SideNavLinkText.js +3 -4
- package/es/components/UIShell/SideNavMenu.js +93 -131
- package/es/components/UIShell/SideNavSwitcher.js +4 -2
- package/es/components/UIShell/SkipToContent.js +3 -4
- package/es/index.js +10 -9
- package/lib/components/DataTable/TableToolbarSearch.js +10 -2
- package/lib/components/Layer/index.js +13 -0
- package/lib/components/OverflowMenu/OverflowMenu.js +0 -1
- package/lib/components/UIShell/HeaderMenu.js +1 -1
- package/lib/components/UIShell/HeaderMenuButton.js +3 -4
- package/lib/components/UIShell/HeaderName.js +3 -4
- package/lib/components/UIShell/HeaderNavigation.js +25 -73
- package/lib/components/UIShell/SideNavFooter.js +3 -10
- package/lib/components/UIShell/SideNavIcon.js +3 -4
- package/lib/components/UIShell/SideNavItem.js +4 -5
- package/lib/components/UIShell/SideNavLink.js +0 -6
- package/lib/components/UIShell/SideNavLinkText.js +3 -4
- package/lib/components/UIShell/SideNavMenu.js +89 -128
- package/lib/components/UIShell/SideNavSwitcher.js +4 -2
- package/lib/components/UIShell/SkipToContent.js +3 -4
- package/lib/index.js +42 -40
- package/package.json +3 -3
- package/es/components/UIShell/index.js +0 -17
- package/es/components/UIShell/next/HeaderNavigation.js +0 -52
- package/es/components/UIShell/next/SideNavMenu.js +0 -160
- package/lib/components/UIShell/index.js +0 -42
- package/lib/components/UIShell/next/HeaderNavigation.js +0 -62
- package/lib/components/UIShell/next/SideNavMenu.js +0 -170
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright IBM Corp. 2016, 2022
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { slicedToArray as _slicedToArray, defineProperty as _defineProperty } from '../../../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
|
-
import { ChevronDown } from '@carbon/icons-react';
|
|
10
|
-
import cx from 'classnames';
|
|
11
|
-
import PropTypes from 'prop-types';
|
|
12
|
-
import React__default, { useState } from 'react';
|
|
13
|
-
import SideNavIcon from '../SideNavIcon.js';
|
|
14
|
-
import { usePrefix } from '../../../internal/usePrefix.js';
|
|
15
|
-
import { match } from '../../../internal/keyboard/match.js';
|
|
16
|
-
import { Escape } from '../../../internal/keyboard/keys.js';
|
|
17
|
-
|
|
18
|
-
var _ChevronDown;
|
|
19
|
-
var SideNavMenu = /*#__PURE__*/React__default.forwardRef(function SideNavMenu(props, ref) {
|
|
20
|
-
var _cx;
|
|
21
|
-
|
|
22
|
-
var customClassName = props.className,
|
|
23
|
-
children = props.children,
|
|
24
|
-
_props$defaultExpande = props.defaultExpanded,
|
|
25
|
-
defaultExpanded = _props$defaultExpande === void 0 ? false : _props$defaultExpande,
|
|
26
|
-
_props$isActive = props.isActive,
|
|
27
|
-
isActive = _props$isActive === void 0 ? false : _props$isActive,
|
|
28
|
-
_props$large = props.large,
|
|
29
|
-
large = _props$large === void 0 ? false : _props$large,
|
|
30
|
-
IconElement = props.renderIcon,
|
|
31
|
-
isSideNavExpanded = props.isSideNavExpanded,
|
|
32
|
-
title = props.title;
|
|
33
|
-
var prefix = usePrefix();
|
|
34
|
-
|
|
35
|
-
var _useState = useState(defaultExpanded),
|
|
36
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
37
|
-
isExpanded = _useState2[0],
|
|
38
|
-
setIsExpanded = _useState2[1];
|
|
39
|
-
|
|
40
|
-
var _useState3 = useState(defaultExpanded),
|
|
41
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
42
|
-
prevExpanded = _useState4[0],
|
|
43
|
-
setPrevExpanded = _useState4[1];
|
|
44
|
-
|
|
45
|
-
var className = cx((_cx = {}, _defineProperty(_cx, "".concat(prefix, "--side-nav__item"), true), _defineProperty(_cx, "".concat(prefix, "--side-nav__item--active"), isActive || hasActiveChild(children) && !isExpanded), _defineProperty(_cx, "".concat(prefix, "--side-nav__item--icon"), IconElement), _defineProperty(_cx, "".concat(prefix, "--side-nav__item--large"), large), _defineProperty(_cx, customClassName, !!customClassName), _cx));
|
|
46
|
-
|
|
47
|
-
if (isSideNavExpanded === false && isExpanded === true) {
|
|
48
|
-
setIsExpanded(false);
|
|
49
|
-
setPrevExpanded(true);
|
|
50
|
-
} else if (isSideNavExpanded === true && prevExpanded === true) {
|
|
51
|
-
setIsExpanded(true);
|
|
52
|
-
setPrevExpanded(false);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return (
|
|
56
|
-
/*#__PURE__*/
|
|
57
|
-
// eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions
|
|
58
|
-
React__default.createElement("li", {
|
|
59
|
-
className: className,
|
|
60
|
-
onKeyDown: function onKeyDown(event) {
|
|
61
|
-
if (match(event, Escape)) {
|
|
62
|
-
setIsExpanded(false);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}, /*#__PURE__*/React__default.createElement("button", {
|
|
66
|
-
"aria-expanded": isExpanded,
|
|
67
|
-
className: "".concat(prefix, "--side-nav__submenu"),
|
|
68
|
-
onClick: function onClick() {
|
|
69
|
-
setIsExpanded(!isExpanded);
|
|
70
|
-
},
|
|
71
|
-
ref: ref,
|
|
72
|
-
type: "button"
|
|
73
|
-
}, IconElement && /*#__PURE__*/React__default.createElement(SideNavIcon, null, /*#__PURE__*/React__default.createElement(IconElement, null)), /*#__PURE__*/React__default.createElement("span", {
|
|
74
|
-
className: "".concat(prefix, "--side-nav__submenu-title")
|
|
75
|
-
}, title), /*#__PURE__*/React__default.createElement(SideNavIcon, {
|
|
76
|
-
className: "".concat(prefix, "--side-nav__submenu-chevron"),
|
|
77
|
-
small: true
|
|
78
|
-
}, _ChevronDown || (_ChevronDown = /*#__PURE__*/React__default.createElement(ChevronDown, {
|
|
79
|
-
size: 20
|
|
80
|
-
})))), /*#__PURE__*/React__default.createElement("ul", {
|
|
81
|
-
className: "".concat(prefix, "--side-nav__menu")
|
|
82
|
-
}, children))
|
|
83
|
-
);
|
|
84
|
-
});
|
|
85
|
-
SideNavMenu.propTypes = {
|
|
86
|
-
/**
|
|
87
|
-
* Provide <SideNavMenuItem>'s inside of the `SideNavMenu`
|
|
88
|
-
*/
|
|
89
|
-
children: PropTypes.node,
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Provide an optional class to be applied to the containing node
|
|
93
|
-
*/
|
|
94
|
-
className: PropTypes.string,
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* Specify whether the menu should default to expanded. By default, it will
|
|
98
|
-
* be closed.
|
|
99
|
-
*/
|
|
100
|
-
defaultExpanded: PropTypes.bool,
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Specify whether the `SideNavMenu` is "active". `SideNavMenu` should be
|
|
104
|
-
* considered active if one of its menu items are a link for the current
|
|
105
|
-
* page.
|
|
106
|
-
*/
|
|
107
|
-
isActive: PropTypes.bool,
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* Property to indicate if the side nav container is open (or not). Use to
|
|
111
|
-
* keep local state and styling in step with the SideNav expansion state.
|
|
112
|
-
*/
|
|
113
|
-
isSideNavExpanded: PropTypes.bool,
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* Specify if this is a large variation of the SideNavMenu
|
|
117
|
-
*/
|
|
118
|
-
large: PropTypes.bool,
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* Pass in a custom icon to render next to the `SideNavMenu` title
|
|
122
|
-
*/
|
|
123
|
-
renderIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* Provide the text for the overall menu name
|
|
127
|
-
*/
|
|
128
|
-
title: PropTypes.string.isRequired
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
function hasActiveChild(children) {
|
|
132
|
-
// if we have children, either a single or multiple, find if it is active
|
|
133
|
-
if (Array.isArray(children)) {
|
|
134
|
-
return children.some(function (child) {
|
|
135
|
-
if (!child.props) {
|
|
136
|
-
return false;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
if (child.props.isActive === true) {
|
|
140
|
-
return true;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
if (child.props['aria-current']) {
|
|
144
|
-
return true;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
return false;
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
if (children.props) {
|
|
152
|
-
if (children.props.isActive === true || children.props['aria-current']) {
|
|
153
|
-
return true;
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
return false;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
export { SideNavMenu };
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright IBM Corp. 2016, 2022
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
'use strict';
|
|
9
|
-
|
|
10
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
11
|
-
|
|
12
|
-
var FeatureFlags = require('@carbon/feature-flags');
|
|
13
|
-
var HeaderNavigation$2 = require('./HeaderNavigation.js');
|
|
14
|
-
var SideNavMenu$2 = require('./SideNavMenu.js');
|
|
15
|
-
var SideNavMenu$1 = require('./next/SideNavMenu.js');
|
|
16
|
-
var HeaderNavigation$1 = require('./next/HeaderNavigation.js');
|
|
17
|
-
|
|
18
|
-
function _interopNamespace(e) {
|
|
19
|
-
if (e && e.__esModule) return e;
|
|
20
|
-
var n = Object.create(null);
|
|
21
|
-
if (e) {
|
|
22
|
-
Object.keys(e).forEach(function (k) {
|
|
23
|
-
if (k !== 'default') {
|
|
24
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
25
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
26
|
-
enumerable: true,
|
|
27
|
-
get: function () { return e[k]; }
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
n["default"] = e;
|
|
33
|
-
return Object.freeze(n);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
var FeatureFlags__namespace = /*#__PURE__*/_interopNamespace(FeatureFlags);
|
|
37
|
-
|
|
38
|
-
var HeaderNavigation = FeatureFlags__namespace.enabled('enable-v11-release') ? HeaderNavigation$1.HeaderNavigation : HeaderNavigation$2["default"];
|
|
39
|
-
var SideNavMenu = FeatureFlags__namespace.enabled('enable-v11-release') ? SideNavMenu$1.SideNavMenu : SideNavMenu$2["default"];
|
|
40
|
-
|
|
41
|
-
exports.HeaderNavigation = HeaderNavigation;
|
|
42
|
-
exports.SideNavMenu = SideNavMenu;
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright IBM Corp. 2016, 2022
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
'use strict';
|
|
9
|
-
|
|
10
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
11
|
-
|
|
12
|
-
var _rollupPluginBabelHelpers = require('../../../_virtual/_rollupPluginBabelHelpers.js');
|
|
13
|
-
var cx = require('classnames');
|
|
14
|
-
var React = require('react');
|
|
15
|
-
var PropTypes = require('prop-types');
|
|
16
|
-
var AriaPropTypes = require('../../../prop-types/AriaPropTypes.js');
|
|
17
|
-
var usePrefix = require('../../../internal/usePrefix.js');
|
|
18
|
-
|
|
19
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
20
|
-
|
|
21
|
-
var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
|
22
|
-
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
23
|
-
var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
|
|
24
|
-
|
|
25
|
-
var _excluded = ["aria-label", "aria-labelledby", "children", "className"];
|
|
26
|
-
|
|
27
|
-
function HeaderNavigation(props) {
|
|
28
|
-
var ariaLabel = props['aria-label'],
|
|
29
|
-
ariaLabelledBy = props['aria-labelledby'],
|
|
30
|
-
children = props.children,
|
|
31
|
-
customClassName = props.className,
|
|
32
|
-
rest = _rollupPluginBabelHelpers.objectWithoutProperties(props, _excluded);
|
|
33
|
-
|
|
34
|
-
var prefix = usePrefix.usePrefix();
|
|
35
|
-
var className = cx__default["default"]("".concat(prefix, "--header__nav"), customClassName); // Assign both label strategies in this option, only one should be defined
|
|
36
|
-
// so when we spread that should be the one that is applied to the node
|
|
37
|
-
|
|
38
|
-
var accessibilityLabel = {
|
|
39
|
-
'aria-label': ariaLabel,
|
|
40
|
-
'aria-labelledby': ariaLabelledBy
|
|
41
|
-
};
|
|
42
|
-
return /*#__PURE__*/React__default["default"].createElement("nav", _rollupPluginBabelHelpers["extends"]({}, rest, accessibilityLabel, {
|
|
43
|
-
className: className
|
|
44
|
-
}), /*#__PURE__*/React__default["default"].createElement("ul", {
|
|
45
|
-
className: "".concat(prefix, "--header__menu-bar")
|
|
46
|
-
}, children));
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
HeaderNavigation.propTypes = _rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, AriaPropTypes.AriaLabelPropType), {}, {
|
|
50
|
-
/**
|
|
51
|
-
* Provide valid children of HeaderNavigation, for example `HeaderMenuItem`
|
|
52
|
-
* or `HeaderMenu`
|
|
53
|
-
*/
|
|
54
|
-
children: PropTypes__default["default"].node,
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Optionally provide a custom class to apply to the underlying <nav> node
|
|
58
|
-
*/
|
|
59
|
-
className: PropTypes__default["default"].string
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
exports.HeaderNavigation = HeaderNavigation;
|
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright IBM Corp. 2016, 2022
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
'use strict';
|
|
9
|
-
|
|
10
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
11
|
-
|
|
12
|
-
var _rollupPluginBabelHelpers = require('../../../_virtual/_rollupPluginBabelHelpers.js');
|
|
13
|
-
var iconsReact = require('@carbon/icons-react');
|
|
14
|
-
var cx = require('classnames');
|
|
15
|
-
var PropTypes = require('prop-types');
|
|
16
|
-
var React = require('react');
|
|
17
|
-
var SideNavIcon = require('../SideNavIcon.js');
|
|
18
|
-
var usePrefix = require('../../../internal/usePrefix.js');
|
|
19
|
-
var match = require('../../../internal/keyboard/match.js');
|
|
20
|
-
var keys = require('../../../internal/keyboard/keys.js');
|
|
21
|
-
|
|
22
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
23
|
-
|
|
24
|
-
var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
|
25
|
-
var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
|
|
26
|
-
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
27
|
-
|
|
28
|
-
var _ChevronDown;
|
|
29
|
-
var SideNavMenu = /*#__PURE__*/React__default["default"].forwardRef(function SideNavMenu(props, ref) {
|
|
30
|
-
var _cx;
|
|
31
|
-
|
|
32
|
-
var customClassName = props.className,
|
|
33
|
-
children = props.children,
|
|
34
|
-
_props$defaultExpande = props.defaultExpanded,
|
|
35
|
-
defaultExpanded = _props$defaultExpande === void 0 ? false : _props$defaultExpande,
|
|
36
|
-
_props$isActive = props.isActive,
|
|
37
|
-
isActive = _props$isActive === void 0 ? false : _props$isActive,
|
|
38
|
-
_props$large = props.large,
|
|
39
|
-
large = _props$large === void 0 ? false : _props$large,
|
|
40
|
-
IconElement = props.renderIcon,
|
|
41
|
-
isSideNavExpanded = props.isSideNavExpanded,
|
|
42
|
-
title = props.title;
|
|
43
|
-
var prefix = usePrefix.usePrefix();
|
|
44
|
-
|
|
45
|
-
var _useState = React.useState(defaultExpanded),
|
|
46
|
-
_useState2 = _rollupPluginBabelHelpers.slicedToArray(_useState, 2),
|
|
47
|
-
isExpanded = _useState2[0],
|
|
48
|
-
setIsExpanded = _useState2[1];
|
|
49
|
-
|
|
50
|
-
var _useState3 = React.useState(defaultExpanded),
|
|
51
|
-
_useState4 = _rollupPluginBabelHelpers.slicedToArray(_useState3, 2),
|
|
52
|
-
prevExpanded = _useState4[0],
|
|
53
|
-
setPrevExpanded = _useState4[1];
|
|
54
|
-
|
|
55
|
-
var className = cx__default["default"]((_cx = {}, _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--side-nav__item"), true), _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--side-nav__item--active"), isActive || hasActiveChild(children) && !isExpanded), _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--side-nav__item--icon"), IconElement), _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--side-nav__item--large"), large), _rollupPluginBabelHelpers.defineProperty(_cx, customClassName, !!customClassName), _cx));
|
|
56
|
-
|
|
57
|
-
if (isSideNavExpanded === false && isExpanded === true) {
|
|
58
|
-
setIsExpanded(false);
|
|
59
|
-
setPrevExpanded(true);
|
|
60
|
-
} else if (isSideNavExpanded === true && prevExpanded === true) {
|
|
61
|
-
setIsExpanded(true);
|
|
62
|
-
setPrevExpanded(false);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
return (
|
|
66
|
-
/*#__PURE__*/
|
|
67
|
-
// eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions
|
|
68
|
-
React__default["default"].createElement("li", {
|
|
69
|
-
className: className,
|
|
70
|
-
onKeyDown: function onKeyDown(event) {
|
|
71
|
-
if (match.match(event, keys.Escape)) {
|
|
72
|
-
setIsExpanded(false);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}, /*#__PURE__*/React__default["default"].createElement("button", {
|
|
76
|
-
"aria-expanded": isExpanded,
|
|
77
|
-
className: "".concat(prefix, "--side-nav__submenu"),
|
|
78
|
-
onClick: function onClick() {
|
|
79
|
-
setIsExpanded(!isExpanded);
|
|
80
|
-
},
|
|
81
|
-
ref: ref,
|
|
82
|
-
type: "button"
|
|
83
|
-
}, IconElement && /*#__PURE__*/React__default["default"].createElement(SideNavIcon["default"], null, /*#__PURE__*/React__default["default"].createElement(IconElement, null)), /*#__PURE__*/React__default["default"].createElement("span", {
|
|
84
|
-
className: "".concat(prefix, "--side-nav__submenu-title")
|
|
85
|
-
}, title), /*#__PURE__*/React__default["default"].createElement(SideNavIcon["default"], {
|
|
86
|
-
className: "".concat(prefix, "--side-nav__submenu-chevron"),
|
|
87
|
-
small: true
|
|
88
|
-
}, _ChevronDown || (_ChevronDown = /*#__PURE__*/React__default["default"].createElement(iconsReact.ChevronDown, {
|
|
89
|
-
size: 20
|
|
90
|
-
})))), /*#__PURE__*/React__default["default"].createElement("ul", {
|
|
91
|
-
className: "".concat(prefix, "--side-nav__menu")
|
|
92
|
-
}, children))
|
|
93
|
-
);
|
|
94
|
-
});
|
|
95
|
-
SideNavMenu.propTypes = {
|
|
96
|
-
/**
|
|
97
|
-
* Provide <SideNavMenuItem>'s inside of the `SideNavMenu`
|
|
98
|
-
*/
|
|
99
|
-
children: PropTypes__default["default"].node,
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Provide an optional class to be applied to the containing node
|
|
103
|
-
*/
|
|
104
|
-
className: PropTypes__default["default"].string,
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Specify whether the menu should default to expanded. By default, it will
|
|
108
|
-
* be closed.
|
|
109
|
-
*/
|
|
110
|
-
defaultExpanded: PropTypes__default["default"].bool,
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* Specify whether the `SideNavMenu` is "active". `SideNavMenu` should be
|
|
114
|
-
* considered active if one of its menu items are a link for the current
|
|
115
|
-
* page.
|
|
116
|
-
*/
|
|
117
|
-
isActive: PropTypes__default["default"].bool,
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* Property to indicate if the side nav container is open (or not). Use to
|
|
121
|
-
* keep local state and styling in step with the SideNav expansion state.
|
|
122
|
-
*/
|
|
123
|
-
isSideNavExpanded: PropTypes__default["default"].bool,
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* Specify if this is a large variation of the SideNavMenu
|
|
127
|
-
*/
|
|
128
|
-
large: PropTypes__default["default"].bool,
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* Pass in a custom icon to render next to the `SideNavMenu` title
|
|
132
|
-
*/
|
|
133
|
-
renderIcon: PropTypes__default["default"].oneOfType([PropTypes__default["default"].func, PropTypes__default["default"].object]),
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* Provide the text for the overall menu name
|
|
137
|
-
*/
|
|
138
|
-
title: PropTypes__default["default"].string.isRequired
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
function hasActiveChild(children) {
|
|
142
|
-
// if we have children, either a single or multiple, find if it is active
|
|
143
|
-
if (Array.isArray(children)) {
|
|
144
|
-
return children.some(function (child) {
|
|
145
|
-
if (!child.props) {
|
|
146
|
-
return false;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
if (child.props.isActive === true) {
|
|
150
|
-
return true;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
if (child.props['aria-current']) {
|
|
154
|
-
return true;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
return false;
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
if (children.props) {
|
|
162
|
-
if (children.props.isActive === true || children.props['aria-current']) {
|
|
163
|
-
return true;
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
return false;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
exports.SideNavMenu = SideNavMenu;
|