@carbon/react 1.5.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/ComposedModal/ComposedModal.js +2 -1
- package/es/components/ComposedModal/next/ComposedModal.js +2 -1
- package/es/components/DataTable/TableActionList.js +3 -1
- package/es/components/DataTable/TableToolbarContent.js +3 -1
- package/es/components/DataTable/TableToolbarSearch.js +10 -2
- package/es/components/DatePicker/DatePicker.js +14 -5
- package/es/components/FileUploader/FileUploader.js +1 -1
- package/es/components/FileUploader/FileUploaderButton.js +1 -1
- package/es/components/FileUploader/Filename.js +1 -1
- package/es/components/Layer/index.js +13 -1
- package/es/components/Link/Link.js +6 -3
- package/es/components/ListBox/ListBoxPropTypes.js +1 -2
- package/es/components/ListBox/ListBoxSelection.js +3 -4
- package/es/components/OverflowMenu/OverflowMenu.js +0 -1
- package/es/components/RadioButton/next/RadioButton.js +2 -1
- package/es/components/Search/next/Search.js +1 -0
- package/es/components/Tabs/next/Tabs.js +42 -4
- package/es/components/Toggle/Toggle.js +147 -109
- package/es/components/UIShell/HeaderGlobalBar.js +3 -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/SideNav.js +3 -3
- 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 +13 -11
- package/es/tools/wrapComponent.js +6 -4
- package/lib/components/ComposedModal/ComposedModal.js +2 -1
- package/lib/components/ComposedModal/next/ComposedModal.js +2 -1
- package/lib/components/DataTable/TableActionList.js +3 -1
- package/lib/components/DataTable/TableToolbarContent.js +3 -1
- package/lib/components/DataTable/TableToolbarSearch.js +10 -2
- package/lib/components/DatePicker/DatePicker.js +14 -5
- package/lib/components/FileUploader/FileUploader.js +1 -1
- package/lib/components/FileUploader/FileUploaderButton.js +1 -1
- package/lib/components/FileUploader/Filename.js +1 -1
- package/lib/components/Layer/index.js +13 -0
- package/lib/components/Link/Link.js +6 -3
- package/lib/components/ListBox/ListBoxPropTypes.js +1 -21
- package/lib/components/ListBox/ListBoxSelection.js +3 -4
- package/lib/components/OverflowMenu/OverflowMenu.js +0 -1
- package/lib/components/RadioButton/next/RadioButton.js +2 -1
- package/lib/components/Search/next/Search.js +1 -0
- package/lib/components/Tabs/next/Tabs.js +42 -4
- package/lib/components/Toggle/Toggle.js +146 -107
- package/lib/components/UIShell/HeaderGlobalBar.js +3 -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/SideNav.js +3 -3
- 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 +86 -82
- package/lib/tools/wrapComponent.js +6 -4
- package/package.json +18 -18
- package/es/components/Toggle/index.js +0 -19
- package/es/components/Toggle/next/Toggle.js +0 -158
- 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/Toggle/index.js +0 -23
- package/lib/components/Toggle/next/Toggle.js +0 -169
- 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
|
@@ -13,6 +13,7 @@ var _rollupPluginBabelHelpers = require('../_virtual/_rollupPluginBabelHelpers.j
|
|
|
13
13
|
var React = require('react');
|
|
14
14
|
var PropTypes = require('prop-types');
|
|
15
15
|
var cx = require('classnames');
|
|
16
|
+
var usePrefix = require('../internal/usePrefix.js');
|
|
16
17
|
|
|
17
18
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
18
19
|
|
|
@@ -24,21 +25,22 @@ var _excluded = ["className"];
|
|
|
24
25
|
|
|
25
26
|
var wrapComponent = function wrapComponent(_ref) {
|
|
26
27
|
var name = _ref.name,
|
|
27
|
-
|
|
28
|
+
getClassName = _ref.className,
|
|
28
29
|
type = _ref.type;
|
|
29
30
|
|
|
30
|
-
|
|
31
|
+
function Component(_ref2) {
|
|
31
32
|
var baseClassName = _ref2.className,
|
|
32
33
|
other = _rollupPluginBabelHelpers.objectWithoutProperties(_ref2, _excluded);
|
|
33
34
|
|
|
34
|
-
var
|
|
35
|
+
var prefix = usePrefix.usePrefix();
|
|
36
|
+
var componentClass = cx__default["default"](typeof getClassName === 'function' ? getClassName(prefix) : getClassName, baseClassName);
|
|
35
37
|
return /*#__PURE__*/React__default["default"].createElement(type, _rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, other), {}, {
|
|
36
38
|
// Prevent Weird quirk where `cx` will evaluate to an empty string, '',
|
|
37
39
|
// and so we have empty `class` attributes in the resulting markup
|
|
38
40
|
// eslint-disable-next-line no-extra-boolean-cast
|
|
39
41
|
className: !!componentClass ? componentClass : undefined
|
|
40
42
|
}));
|
|
41
|
-
}
|
|
43
|
+
}
|
|
42
44
|
|
|
43
45
|
Component.displayName = name;
|
|
44
46
|
Component.propTypes = {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@carbon/react",
|
|
3
3
|
"description": "React components for the Carbon Design System",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.6.0",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"module": "es/index.js",
|
|
@@ -43,10 +43,10 @@
|
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@babel/runtime": "^7.18.3",
|
|
46
|
-
"@carbon/feature-flags": "^0.8.0
|
|
47
|
-
"@carbon/icons-react": "^11.5.0
|
|
48
|
-
"@carbon/layout": "^11.3.0
|
|
49
|
-
"@carbon/styles": "^1.
|
|
46
|
+
"@carbon/feature-flags": "^0.8.0",
|
|
47
|
+
"@carbon/icons-react": "^11.5.0",
|
|
48
|
+
"@carbon/layout": "^11.3.0",
|
|
49
|
+
"@carbon/styles": "^1.6.0",
|
|
50
50
|
"@carbon/telemetry": "0.1.0",
|
|
51
51
|
"classnames": "2.3.1",
|
|
52
52
|
"copy-to-clipboard": "^3.3.1",
|
|
@@ -72,26 +72,26 @@
|
|
|
72
72
|
"@babel/plugin-transform-react-constant-elements": "^7.17.12",
|
|
73
73
|
"@babel/preset-env": "^7.18.2",
|
|
74
74
|
"@babel/preset-react": "^7.17.12",
|
|
75
|
-
"@carbon/test-utils": "^10.25.0
|
|
76
|
-
"@carbon/themes": "^11.4.0
|
|
75
|
+
"@carbon/test-utils": "^10.25.0",
|
|
76
|
+
"@carbon/themes": "^11.4.0",
|
|
77
77
|
"@rollup/plugin-babel": "^5.3.0",
|
|
78
78
|
"@rollup/plugin-commonjs": "^21.0.0",
|
|
79
79
|
"@rollup/plugin-node-resolve": "^13.0.0",
|
|
80
|
-
"@storybook/addon-a11y": "^6.
|
|
81
|
-
"@storybook/addon-actions": "^6.
|
|
82
|
-
"@storybook/addon-docs": "^6.
|
|
83
|
-
"@storybook/addon-essentials": "^6.
|
|
80
|
+
"@storybook/addon-a11y": "^6.5.6",
|
|
81
|
+
"@storybook/addon-actions": "^6.5.6",
|
|
82
|
+
"@storybook/addon-docs": "^6.5.6",
|
|
83
|
+
"@storybook/addon-essentials": "^6.5.6",
|
|
84
84
|
"@storybook/addon-knobs": "^6.4.0",
|
|
85
85
|
"@storybook/addon-notes": "^5.3.21",
|
|
86
|
-
"@storybook/addon-storysource": "^6.
|
|
87
|
-
"@storybook/builder-webpack5": "^6.
|
|
88
|
-
"@storybook/manager-webpack5": "^6.
|
|
89
|
-
"@storybook/react": "^6.
|
|
90
|
-
"@storybook/theming": "^6.
|
|
86
|
+
"@storybook/addon-storysource": "^6.5.6",
|
|
87
|
+
"@storybook/builder-webpack5": "^6.5.6",
|
|
88
|
+
"@storybook/manager-webpack5": "^6.5.6",
|
|
89
|
+
"@storybook/react": "^6.5.6",
|
|
90
|
+
"@storybook/theming": "^6.5.6",
|
|
91
91
|
"autoprefixer": "^10.4.0",
|
|
92
92
|
"babel-loader": "^8.2.3",
|
|
93
93
|
"babel-plugin-dev-expression": "^0.2.3",
|
|
94
|
-
"babel-preset-carbon": "^0.3.0
|
|
94
|
+
"babel-preset-carbon": "^0.3.0",
|
|
95
95
|
"browserify-zlib": "^0.2.0",
|
|
96
96
|
"browserslist-config-carbon": "^11.0.0",
|
|
97
97
|
"css-loader": "^6.5.1",
|
|
@@ -129,5 +129,5 @@
|
|
|
129
129
|
"**/*.scss",
|
|
130
130
|
"**/*.css"
|
|
131
131
|
],
|
|
132
|
-
"gitHead": "
|
|
132
|
+
"gitHead": "07aff903e75a56d215c3582c214505379448e38e"
|
|
133
133
|
}
|
|
@@ -1,19 +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 { Toggle as Toggle$2 } from './next/Toggle.js';
|
|
9
|
-
import ToggleClassic from './Toggle.js';
|
|
10
|
-
import { createComponentToggle } from '../../internal/ComponentToggle.js';
|
|
11
|
-
|
|
12
|
-
var Toggle = createComponentToggle({
|
|
13
|
-
name: 'Toggle',
|
|
14
|
-
next: Toggle$2,
|
|
15
|
-
classic: ToggleClassic
|
|
16
|
-
});
|
|
17
|
-
var Toggle$1 = Toggle;
|
|
18
|
-
|
|
19
|
-
export { Toggle$1 as default };
|
|
@@ -1,158 +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 { objectWithoutProperties as _objectWithoutProperties, slicedToArray as _slicedToArray, defineProperty as _defineProperty, extends as _extends } from '../../../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
|
-
import React__default from 'react';
|
|
10
|
-
import PropTypes from 'prop-types';
|
|
11
|
-
import cx from 'classnames';
|
|
12
|
-
import { useControllableState } from '../../../internal/useControllableState.js';
|
|
13
|
-
import { usePrefix } from '../../../internal/usePrefix.js';
|
|
14
|
-
|
|
15
|
-
var _path;
|
|
16
|
-
|
|
17
|
-
var _excluded = ["className", "defaultToggled", "disabled", "hideLabel", "id", "labelA", "labelB", "labelText", "onClick", "onToggle", "size", "toggled"];
|
|
18
|
-
function Toggle(_ref) {
|
|
19
|
-
var className = _ref.className,
|
|
20
|
-
_ref$defaultToggled = _ref.defaultToggled,
|
|
21
|
-
defaultToggled = _ref$defaultToggled === void 0 ? false : _ref$defaultToggled,
|
|
22
|
-
_ref$disabled = _ref.disabled,
|
|
23
|
-
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
24
|
-
_ref$hideLabel = _ref.hideLabel,
|
|
25
|
-
hideLabel = _ref$hideLabel === void 0 ? false : _ref$hideLabel,
|
|
26
|
-
id = _ref.id,
|
|
27
|
-
_ref$labelA = _ref.labelA,
|
|
28
|
-
labelA = _ref$labelA === void 0 ? 'Off' : _ref$labelA,
|
|
29
|
-
_ref$labelB = _ref.labelB,
|
|
30
|
-
labelB = _ref$labelB === void 0 ? 'On' : _ref$labelB,
|
|
31
|
-
labelText = _ref.labelText,
|
|
32
|
-
onClick = _ref.onClick,
|
|
33
|
-
onToggle = _ref.onToggle,
|
|
34
|
-
_ref$size = _ref.size,
|
|
35
|
-
size = _ref$size === void 0 ? 'md' : _ref$size,
|
|
36
|
-
toggled = _ref.toggled,
|
|
37
|
-
other = _objectWithoutProperties(_ref, _excluded);
|
|
38
|
-
|
|
39
|
-
var prefix = usePrefix();
|
|
40
|
-
|
|
41
|
-
var _useControllableState = useControllableState({
|
|
42
|
-
value: toggled,
|
|
43
|
-
onChange: onToggle,
|
|
44
|
-
defaultValue: defaultToggled
|
|
45
|
-
}),
|
|
46
|
-
_useControllableState2 = _slicedToArray(_useControllableState, 2),
|
|
47
|
-
checked = _useControllableState2[0],
|
|
48
|
-
setChecked = _useControllableState2[1];
|
|
49
|
-
|
|
50
|
-
function handleClick(e) {
|
|
51
|
-
setChecked(!checked);
|
|
52
|
-
|
|
53
|
-
if (onClick) {
|
|
54
|
-
onClick(e);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
var isSm = size === 'sm';
|
|
59
|
-
var sideLabel = hideLabel ? labelText : checked ? labelB : labelA;
|
|
60
|
-
var wrapperClasses = cx("".concat(prefix, "--toggle"), _defineProperty({}, "".concat(prefix, "--toggle--disabled"), disabled), className);
|
|
61
|
-
var labelTextClasses = cx("".concat(prefix, "--toggle__label-text"), _defineProperty({}, "".concat(prefix, "--visually-hidden"), hideLabel));
|
|
62
|
-
var appearanceClasses = cx("".concat(prefix, "--toggle__appearance"), _defineProperty({}, "".concat(prefix, "--toggle__appearance--sm"), isSm));
|
|
63
|
-
var switchClasses = cx("".concat(prefix, "--toggle__switch"), _defineProperty({}, "".concat(prefix, "--toggle__switch--checked"), checked));
|
|
64
|
-
return /*#__PURE__*/React__default.createElement("div", {
|
|
65
|
-
className: wrapperClasses
|
|
66
|
-
}, /*#__PURE__*/React__default.createElement("button", _extends({}, other, {
|
|
67
|
-
id: id,
|
|
68
|
-
className: "".concat(prefix, "--toggle__button"),
|
|
69
|
-
role: "switch",
|
|
70
|
-
type: "button",
|
|
71
|
-
"aria-checked": checked,
|
|
72
|
-
disabled: disabled,
|
|
73
|
-
onClick: handleClick
|
|
74
|
-
})), /*#__PURE__*/React__default.createElement("label", {
|
|
75
|
-
htmlFor: id,
|
|
76
|
-
className: "".concat(prefix, "--toggle__label")
|
|
77
|
-
}, /*#__PURE__*/React__default.createElement("span", {
|
|
78
|
-
className: labelTextClasses
|
|
79
|
-
}, labelText), /*#__PURE__*/React__default.createElement("div", {
|
|
80
|
-
className: appearanceClasses
|
|
81
|
-
}, /*#__PURE__*/React__default.createElement("div", {
|
|
82
|
-
className: switchClasses
|
|
83
|
-
}, isSm && /*#__PURE__*/React__default.createElement("svg", {
|
|
84
|
-
className: "".concat(prefix, "--toggle__check"),
|
|
85
|
-
width: "6px",
|
|
86
|
-
height: "5px",
|
|
87
|
-
viewBox: "0 0 6 5"
|
|
88
|
-
}, _path || (_path = /*#__PURE__*/React__default.createElement("path", {
|
|
89
|
-
d: "M2.2 2.7L5 0 6 1 2.2 5 0 2.7 1 1.5z"
|
|
90
|
-
})))), /*#__PURE__*/React__default.createElement("span", {
|
|
91
|
-
className: "".concat(prefix, "--toggle__text"),
|
|
92
|
-
"aria-hidden": "true"
|
|
93
|
-
}, sideLabel))));
|
|
94
|
-
}
|
|
95
|
-
Toggle.propTypes = {
|
|
96
|
-
/**
|
|
97
|
-
* Specify a custom className to apply to the form-item node
|
|
98
|
-
*/
|
|
99
|
-
className: PropTypes.string,
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Specify whether the toggle should be on by default
|
|
103
|
-
*/
|
|
104
|
-
defaultToggled: PropTypes.bool,
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Whether this control should be disabled
|
|
108
|
-
*/
|
|
109
|
-
disabled: PropTypes.bool,
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* Specify whether the label should be hidden, or not
|
|
113
|
-
*/
|
|
114
|
-
hideLabel: PropTypes.bool,
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* Provide an id that unique represents the underlying `<button>`
|
|
118
|
-
*/
|
|
119
|
-
id: PropTypes.string.isRequired,
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* Specify the label for the "off" position
|
|
123
|
-
*/
|
|
124
|
-
labelA: PropTypes.node,
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* Specify the label for the "on" position
|
|
128
|
-
*/
|
|
129
|
-
labelB: PropTypes.node,
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* Provide the text that will be read by a screen reader when visiting this
|
|
133
|
-
* control
|
|
134
|
-
*/
|
|
135
|
-
labelText: PropTypes.node.isRequired,
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* Provide an event listener that is called when the control is clicked
|
|
139
|
-
*/
|
|
140
|
-
onClick: PropTypes.func,
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
* Provide an event listener that is called when the control is toggled
|
|
144
|
-
*/
|
|
145
|
-
onToggle: PropTypes.func,
|
|
146
|
-
|
|
147
|
-
/**
|
|
148
|
-
* Specify the size of the Toggle. Currently only supports 'sm' or 'md' (default)
|
|
149
|
-
*/
|
|
150
|
-
size: PropTypes.oneOf(['sm', 'md']),
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* Specify whether the control is toggled
|
|
154
|
-
*/
|
|
155
|
-
toggled: PropTypes.bool
|
|
156
|
-
};
|
|
157
|
-
|
|
158
|
-
export { Toggle, Toggle as default };
|
|
@@ -1,17 +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 * as FeatureFlags from '@carbon/feature-flags';
|
|
9
|
-
import HeaderNavigation$2 from './HeaderNavigation.js';
|
|
10
|
-
import SideNavMenuClassic from './SideNavMenu.js';
|
|
11
|
-
import { SideNavMenu as SideNavMenu$1 } from './next/SideNavMenu.js';
|
|
12
|
-
import { HeaderNavigation as HeaderNavigation$1 } from './next/HeaderNavigation.js';
|
|
13
|
-
|
|
14
|
-
var HeaderNavigation = FeatureFlags.enabled('enable-v11-release') ? HeaderNavigation$1 : HeaderNavigation$2;
|
|
15
|
-
var SideNavMenu = FeatureFlags.enabled('enable-v11-release') ? SideNavMenu$1 : SideNavMenuClassic;
|
|
16
|
-
|
|
17
|
-
export { HeaderNavigation, SideNavMenu };
|
|
@@ -1,52 +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 { objectWithoutProperties as _objectWithoutProperties, extends as _extends, objectSpread2 as _objectSpread2 } from '../../../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
|
-
import cx from 'classnames';
|
|
10
|
-
import React__default from 'react';
|
|
11
|
-
import PropTypes from 'prop-types';
|
|
12
|
-
import { AriaLabelPropType } from '../../../prop-types/AriaPropTypes.js';
|
|
13
|
-
import { usePrefix } from '../../../internal/usePrefix.js';
|
|
14
|
-
|
|
15
|
-
var _excluded = ["aria-label", "aria-labelledby", "children", "className"];
|
|
16
|
-
|
|
17
|
-
function HeaderNavigation(props) {
|
|
18
|
-
var ariaLabel = props['aria-label'],
|
|
19
|
-
ariaLabelledBy = props['aria-labelledby'],
|
|
20
|
-
children = props.children,
|
|
21
|
-
customClassName = props.className,
|
|
22
|
-
rest = _objectWithoutProperties(props, _excluded);
|
|
23
|
-
|
|
24
|
-
var prefix = usePrefix();
|
|
25
|
-
var className = cx("".concat(prefix, "--header__nav"), customClassName); // Assign both label strategies in this option, only one should be defined
|
|
26
|
-
// so when we spread that should be the one that is applied to the node
|
|
27
|
-
|
|
28
|
-
var accessibilityLabel = {
|
|
29
|
-
'aria-label': ariaLabel,
|
|
30
|
-
'aria-labelledby': ariaLabelledBy
|
|
31
|
-
};
|
|
32
|
-
return /*#__PURE__*/React__default.createElement("nav", _extends({}, rest, accessibilityLabel, {
|
|
33
|
-
className: className
|
|
34
|
-
}), /*#__PURE__*/React__default.createElement("ul", {
|
|
35
|
-
className: "".concat(prefix, "--header__menu-bar")
|
|
36
|
-
}, children));
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
HeaderNavigation.propTypes = _objectSpread2(_objectSpread2({}, AriaLabelPropType), {}, {
|
|
40
|
-
/**
|
|
41
|
-
* Provide valid children of HeaderNavigation, for example `HeaderMenuItem`
|
|
42
|
-
* or `HeaderMenu`
|
|
43
|
-
*/
|
|
44
|
-
children: PropTypes.node,
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Optionally provide a custom class to apply to the underlying <nav> node
|
|
48
|
-
*/
|
|
49
|
-
className: PropTypes.string
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
export { HeaderNavigation };
|
|
@@ -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,23 +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 Toggle$2 = require('./next/Toggle.js');
|
|
13
|
-
var Toggle$3 = require('./Toggle.js');
|
|
14
|
-
var ComponentToggle = require('../../internal/ComponentToggle.js');
|
|
15
|
-
|
|
16
|
-
var Toggle = ComponentToggle.createComponentToggle({
|
|
17
|
-
name: 'Toggle',
|
|
18
|
-
next: Toggle$2.Toggle,
|
|
19
|
-
classic: Toggle$3["default"]
|
|
20
|
-
});
|
|
21
|
-
var Toggle$1 = Toggle;
|
|
22
|
-
|
|
23
|
-
exports["default"] = Toggle$1;
|