@carbon/react 1.6.0-rc.0 → 1.7.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.
Files changed (55) hide show
  1. package/es/components/DataTable/TableToolbarSearch.js +10 -2
  2. package/es/components/Form/Form.js +1 -1
  3. package/es/components/FormGroup/FormGroup.js +4 -4
  4. package/es/components/FormItem/FormItem.js +5 -6
  5. package/es/components/Layer/index.js +13 -1
  6. package/es/components/MultiSelect/next/FilterableMultiSelect.js +3 -1
  7. package/es/components/OverflowMenu/OverflowMenu.js +0 -1
  8. package/es/components/Popover/index.js +137 -8
  9. package/es/components/ProgressBar/ProgressBar.js +6 -3
  10. package/es/components/Select/Select.js +14 -7
  11. package/es/components/UIShell/HeaderMenu.js +1 -1
  12. package/es/components/UIShell/HeaderMenuButton.js +3 -4
  13. package/es/components/UIShell/HeaderName.js +3 -4
  14. package/es/components/UIShell/HeaderNavigation.js +27 -75
  15. package/es/components/UIShell/SideNavDetails.js +8 -3
  16. package/es/components/UIShell/SideNavFooter.js +3 -10
  17. package/es/components/UIShell/SideNavIcon.js +3 -4
  18. package/es/components/UIShell/SideNavItem.js +4 -5
  19. package/es/components/UIShell/SideNavLink.js +0 -6
  20. package/es/components/UIShell/SideNavLinkText.js +3 -4
  21. package/es/components/UIShell/SideNavMenu.js +93 -131
  22. package/es/components/UIShell/SideNavSwitcher.js +4 -2
  23. package/es/components/UIShell/SkipToContent.js +3 -4
  24. package/es/index.js +10 -9
  25. package/lib/components/DataTable/TableToolbarSearch.js +10 -2
  26. package/lib/components/Form/Form.js +1 -1
  27. package/lib/components/FormGroup/FormGroup.js +4 -4
  28. package/lib/components/FormItem/FormItem.js +5 -6
  29. package/lib/components/Layer/index.js +13 -0
  30. package/lib/components/MultiSelect/next/FilterableMultiSelect.js +3 -1
  31. package/lib/components/OverflowMenu/OverflowMenu.js +0 -1
  32. package/lib/components/Popover/index.js +135 -6
  33. package/lib/components/ProgressBar/ProgressBar.js +6 -3
  34. package/lib/components/Select/Select.js +14 -7
  35. package/lib/components/UIShell/HeaderMenu.js +1 -1
  36. package/lib/components/UIShell/HeaderMenuButton.js +3 -4
  37. package/lib/components/UIShell/HeaderName.js +3 -4
  38. package/lib/components/UIShell/HeaderNavigation.js +25 -73
  39. package/lib/components/UIShell/SideNavDetails.js +8 -3
  40. package/lib/components/UIShell/SideNavFooter.js +3 -10
  41. package/lib/components/UIShell/SideNavIcon.js +3 -4
  42. package/lib/components/UIShell/SideNavItem.js +4 -5
  43. package/lib/components/UIShell/SideNavLink.js +0 -6
  44. package/lib/components/UIShell/SideNavLinkText.js +3 -4
  45. package/lib/components/UIShell/SideNavMenu.js +89 -128
  46. package/lib/components/UIShell/SideNavSwitcher.js +4 -2
  47. package/lib/components/UIShell/SkipToContent.js +3 -4
  48. package/lib/index.js +42 -40
  49. package/package.json +4 -4
  50. package/es/components/UIShell/index.js +0 -17
  51. package/es/components/UIShell/next/HeaderNavigation.js +0 -52
  52. package/es/components/UIShell/next/SideNavMenu.js +0 -160
  53. package/lib/components/UIShell/index.js +0 -42
  54. package/lib/components/UIShell/next/HeaderNavigation.js +0 -62
  55. package/lib/components/UIShell/next/SideNavMenu.js +0 -170
@@ -13,7 +13,7 @@ import Search from '../Search/index.js';
13
13
  import setupGetInstanceId from './tools/instanceId.js';
14
14
  import { usePrefix } from '../../internal/usePrefix.js';
15
15
 
16
- var _excluded = ["className", "searchContainerClass", "onChange", "onClear", "translateWithId", "placeholder", "labelText", "expanded", "defaultExpanded", "defaultValue", "disabled", "onExpand", "persistent", "id", "onBlur", "onFocus"];
16
+ var _excluded = ["className", "searchContainerClass", "onChange", "onClear", "translateWithId", "placeholder", "labelText", "expanded", "defaultExpanded", "defaultValue", "disabled", "onExpand", "persistent", "id", "onBlur", "onFocus", "size"];
17
17
  var getInstanceId = setupGetInstanceId();
18
18
  var translationKeys = {
19
19
  'carbon.table.toolbar.search.label': 'Filter table',
@@ -43,6 +43,8 @@ var TableToolbarSearch = function TableToolbarSearch(_ref) {
43
43
  id = _ref.id,
44
44
  onBlur = _ref.onBlur,
45
45
  onFocus = _ref.onFocus,
46
+ _ref$size = _ref.size,
47
+ size = _ref$size === void 0 ? 'lg' : _ref$size,
46
48
  rest = _objectWithoutProperties(_ref, _excluded);
47
49
 
48
50
  var _useRef = useRef(expandedProp !== undefined),
@@ -126,7 +128,8 @@ var TableToolbarSearch = function TableToolbarSearch(_ref) {
126
128
  } : handleOnFocus,
127
129
  onBlur: onBlur ? function (event) {
128
130
  return onBlur(event, handleExpand);
129
- } : handleOnBlur
131
+ } : handleOnBlur,
132
+ size: size
130
133
  }, rest));
131
134
  };
132
135
 
@@ -212,6 +215,11 @@ TableToolbarSearch.propTypes = {
212
215
  */
213
216
  searchContainerClass: PropTypes.string,
214
217
 
218
+ /**
219
+ * Specify the size of the Search
220
+ */
221
+ size: PropTypes.oneOf(['sm', 'md', 'lg']),
222
+
215
223
  /**
216
224
  * Optional prop to specify the tabIndex of the <Search> (in expanded state) or the container (in collapsed state)
217
225
  */
@@ -22,7 +22,7 @@ var Form = function Form(_ref) {
22
22
  var classNames = cx("".concat(prefix, "--form"), className);
23
23
  return /*#__PURE__*/React__default.createElement("form", _extends({
24
24
  className: classNames
25
- }, other), ' ', children, ' ');
25
+ }, other), children);
26
26
  };
27
27
 
28
28
  Form.propTypes = {
@@ -21,7 +21,7 @@ var FormGroup = function FormGroup(_ref) {
21
21
  className = _ref.className,
22
22
  message = _ref.message,
23
23
  messageText = _ref.messageText,
24
- other = _objectWithoutProperties(_ref, _excluded);
24
+ rest = _objectWithoutProperties(_ref, _excluded);
25
25
 
26
26
  var prefix = usePrefix();
27
27
  var classNamesFieldset = cx("".concat(prefix, "--fieldset"), className);
@@ -29,11 +29,11 @@ var FormGroup = function FormGroup(_ref) {
29
29
  'data-invalid': ''
30
30
  }, {
31
31
  className: classNamesFieldset
32
- }, other, {
33
- "aria-labelledby": other['aria-labelledby'] || legendId
32
+ }, rest, {
33
+ "aria-labelledby": rest['aria-labelledby'] || legendId
34
34
  }), /*#__PURE__*/React__default.createElement("legend", {
35
35
  className: "".concat(prefix, "--label"),
36
- id: legendId || other['aria-labelledby']
36
+ id: legendId || rest['aria-labelledby']
37
37
  }, legendText), children, message ? /*#__PURE__*/React__default.createElement("div", {
38
38
  className: "".concat(prefix, "--form__requirements")
39
39
  }, messageText) : null);
@@ -13,17 +13,17 @@ import { usePrefix } from '../../internal/usePrefix.js';
13
13
 
14
14
  var _excluded = ["className", "children"];
15
15
 
16
- var FormItem = function FormItem(_ref) {
16
+ function FormItem(_ref) {
17
17
  var className = _ref.className,
18
18
  children = _ref.children,
19
- other = _objectWithoutProperties(_ref, _excluded);
19
+ rest = _objectWithoutProperties(_ref, _excluded);
20
20
 
21
21
  var prefix = usePrefix();
22
22
  var classNames = cx("".concat(prefix, "--form-item"), className);
23
23
  return /*#__PURE__*/React__default.createElement("div", _extends({
24
24
  className: classNames
25
- }, other), children);
26
- };
25
+ }, rest), children);
26
+ }
27
27
 
28
28
  FormItem.propTypes = {
29
29
  /**
@@ -36,6 +36,5 @@ FormItem.propTypes = {
36
36
  */
37
37
  className: PropTypes.string
38
38
  };
39
- var FormItem$1 = FormItem;
40
39
 
41
- export { FormItem$1 as default };
40
+ export { FormItem as default };
@@ -15,6 +15,18 @@ import { LayerContext } from './LayerContext.js';
15
15
  var _excluded = ["as", "className", "children", "level"];
16
16
  var levels = ['one', 'two', 'three'];
17
17
  var MAX_LEVEL = levels.length - 1;
18
+ /**
19
+ * A custom hook that will return information about the current layer. A common
20
+ * field to pull from this is the `level` for the layer that the component that
21
+ * calls this hook is currently in
22
+ */
23
+
24
+ function useLayer() {
25
+ var level = React__default.useContext(LayerContext);
26
+ return {
27
+ level: level
28
+ };
29
+ }
18
30
  function Layer(_ref) {
19
31
  var _ref$as = _ref.as,
20
32
  BaseComponent = _ref$as === void 0 ? 'div' : _ref$as,
@@ -59,4 +71,4 @@ Layer.propTypes = {
59
71
  level: PropTypes.oneOf([0, 1, 2])
60
72
  };
61
73
 
62
- export { Layer };
74
+ export { Layer, useLayer };
@@ -260,7 +260,9 @@ var FilterableMultiSelect = /*#__PURE__*/React__default.forwardRef(function Filt
260
260
  // toggleMenu behavior for the toggleButton to correctly open and
261
261
  // close the menu.
262
262
  onMouseUp: function onMouseUp(event) {
263
- event.stopPropagation();
263
+ if (isOpen) {
264
+ event.stopPropagation();
265
+ }
264
266
  }
265
267
  });
266
268
  var inputProps = getInputProps({
@@ -509,7 +509,6 @@ _defineProperty(OverflowMenu, "defaultProps", {
509
509
  onOpen: function onOpen() {},
510
510
  menuOffset: getMenuOffset,
511
511
  menuOffsetFlip: getMenuOffset,
512
- light: false,
513
512
  selectorPrimaryFocus: '[data-overflow-menu-primary-focus]'
514
513
  });
515
514
 
@@ -5,21 +5,30 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- import { objectWithoutProperties as _objectWithoutProperties, defineProperty as _defineProperty, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
8
+ import { objectWithoutProperties as _objectWithoutProperties, slicedToArray as _slicedToArray, defineProperty as _defineProperty, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
9
9
  import cx from 'classnames';
10
10
  import PropTypes from 'prop-types';
11
- import React__default from 'react';
11
+ import React__default, { useRef, useMemo, useState } from 'react';
12
+ import useIsomorphicEffect from '../../internal/useIsomorphicEffect.js';
13
+ import { useMergedRefs } from '../../internal/useMergedRefs.js';
12
14
  import { usePrefix } from '../../internal/usePrefix.js';
13
15
 
14
- var _excluded = ["align", "as", "caret", "className", "children", "dropShadow", "highContrast", "open"],
16
+ var _excluded = ["align", "as", "autoAlign", "caret", "className", "children", "dropShadow", "highContrast", "open"],
15
17
  _excluded2 = ["className", "children"];
16
- var Popover = /*#__PURE__*/React__default.forwardRef(function Popover(props, ref) {
18
+ var PopoverContext = /*#__PURE__*/React__default.createContext({
19
+ floating: {
20
+ current: null
21
+ }
22
+ });
23
+ var Popover = /*#__PURE__*/React__default.forwardRef(function Popover(props, forwardRef) {
17
24
  var _cx;
18
25
 
19
26
  var _props$align = props.align,
20
27
  align = _props$align === void 0 ? 'bottom' : _props$align,
21
28
  _props$as = props.as,
22
29
  BaseComponent = _props$as === void 0 ? 'span' : _props$as,
30
+ _props$autoAlign = props.autoAlign,
31
+ autoAlign = _props$autoAlign === void 0 ? false : _props$autoAlign,
23
32
  _props$caret = props.caret,
24
33
  caret = _props$caret === void 0 ? true : _props$caret,
25
34
  customClassName = props.className,
@@ -32,11 +41,121 @@ var Popover = /*#__PURE__*/React__default.forwardRef(function Popover(props, ref
32
41
  rest = _objectWithoutProperties(props, _excluded);
33
42
 
34
43
  var prefix = usePrefix();
35
- var className = cx((_cx = {}, _defineProperty(_cx, "".concat(prefix, "--popover-container"), true), _defineProperty(_cx, "".concat(prefix, "--popover--caret"), caret), _defineProperty(_cx, "".concat(prefix, "--popover--drop-shadow"), dropShadow), _defineProperty(_cx, "".concat(prefix, "--popover--high-contrast"), highContrast), _defineProperty(_cx, "".concat(prefix, "--popover--open"), open), _defineProperty(_cx, "".concat(prefix, "--popover--").concat(align), true), _defineProperty(_cx, customClassName, !!customClassName), _cx));
36
- return /*#__PURE__*/React__default.createElement(BaseComponent, _extends({}, rest, {
44
+ var floating = useRef();
45
+ var popover = useRef();
46
+ var value = useMemo(function () {
47
+ return {
48
+ floating: floating
49
+ };
50
+ }, []);
51
+ var ref = useMergedRefs([forwardRef, popover]);
52
+
53
+ var _useState = useState(false),
54
+ _useState2 = _slicedToArray(_useState, 2),
55
+ autoAligned = _useState2[0],
56
+ setAutoAligned = _useState2[1];
57
+
58
+ var _useState3 = useState(align),
59
+ _useState4 = _slicedToArray(_useState3, 2),
60
+ autoAlignment = _useState4[0],
61
+ setAutoAlignment = _useState4[1];
62
+
63
+ var className = cx((_cx = {}, _defineProperty(_cx, "".concat(prefix, "--popover-container"), true), _defineProperty(_cx, "".concat(prefix, "--popover--caret"), caret), _defineProperty(_cx, "".concat(prefix, "--popover--drop-shadow"), dropShadow), _defineProperty(_cx, "".concat(prefix, "--popover--high-contrast"), highContrast), _defineProperty(_cx, "".concat(prefix, "--popover--open"), open), _defineProperty(_cx, "".concat(prefix, "--popover--").concat(autoAlignment), autoAligned), _defineProperty(_cx, "".concat(prefix, "--popover--").concat(align), !autoAligned), _defineProperty(_cx, customClassName, !!customClassName), _cx));
64
+ useIsomorphicEffect(function () {
65
+ if (!autoAlign) {
66
+ setAutoAligned(false);
67
+ return;
68
+ }
69
+
70
+ if (!floating.current) {
71
+ return;
72
+ }
73
+
74
+ if (autoAligned === true) {
75
+ return;
76
+ }
77
+
78
+ var rect = floating.current.getBoundingClientRect(); // The conditions, per side, of when the popover is not visible, excluding the popover's internal padding(16)
79
+
80
+ var conditions = {
81
+ left: rect.x < -16,
82
+ top: rect.y < -16,
83
+ right: rect.x + (rect.width - 16) > document.documentElement.clientWidth,
84
+ bottom: rect.y + (rect.height - 16) > document.documentElement.clientHeight
85
+ };
86
+
87
+ if (!conditions.left && !conditions.top && !conditions.right && !conditions.bottom) {
88
+ setAutoAligned(false);
89
+ return;
90
+ }
91
+
92
+ var alignments = ['top', 'top-left', 'right-bottom', 'right', 'right-top', 'bottom-left', 'bottom', 'bottom-right', 'left-top', 'left', 'left-bottom', 'top-right']; // Creates the prioritized list of options depending on ideal alignment coming from `align`
93
+
94
+ var options = [align];
95
+ var option = alignments[(alignments.indexOf(align) + 1) % alignments.length];
96
+
97
+ while (option) {
98
+ if (options.includes(option)) {
99
+ break;
100
+ }
101
+
102
+ options.push(option);
103
+ option = alignments[(alignments.indexOf(option) + 1) % alignments.length];
104
+ }
105
+
106
+ function isVisible(alignment) {
107
+ popover.current.classList.add("".concat(prefix, "--popover--").concat(alignment));
108
+ var rect = floating.current.getBoundingClientRect(); // Check if popover is not visible to the left of the screen
109
+
110
+ if (rect.x < -16) {
111
+ popover.current.classList.remove("".concat(prefix, "--popover--").concat(alignment));
112
+ return false;
113
+ } // Check if popover is not visible at the top of the screen
114
+
115
+
116
+ if (rect.y < -16) {
117
+ popover.current.classList.remove("".concat(prefix, "--popover--").concat(alignment));
118
+ return false;
119
+ } // Check if popover is not visible to right of screen
120
+
121
+
122
+ if (rect.x + (rect.width - 16) > document.documentElement.clientWidth) {
123
+ popover.current.classList.remove("".concat(prefix, "--popover--").concat(alignment));
124
+ return false;
125
+ } // Check if popover is not visible to bottom of screen
126
+
127
+
128
+ if (rect.y + (rect.height - 16) > document.documentElement.clientHeight) {
129
+ popover.current.classList.remove("".concat(prefix, "--popover--").concat(alignment));
130
+ return false;
131
+ }
132
+
133
+ popover.current.classList.remove("".concat(prefix, "--popover--").concat(alignment));
134
+ return true;
135
+ }
136
+
137
+ var alignment = null;
138
+
139
+ for (var i = 0; i < options.length; i++) {
140
+ var _option = options[i];
141
+
142
+ if (isVisible(_option)) {
143
+ alignment = _option;
144
+ break;
145
+ }
146
+ }
147
+
148
+ if (alignment) {
149
+ setAutoAligned(true);
150
+ setAutoAlignment(alignment);
151
+ }
152
+ }, [autoAligned, align, autoAlign, prefix]);
153
+ return /*#__PURE__*/React__default.createElement(PopoverContext.Provider, {
154
+ value: value
155
+ }, /*#__PURE__*/React__default.createElement(BaseComponent, _extends({}, rest, {
37
156
  className: className,
38
157
  ref: ref
39
- }), children);
158
+ }), children));
40
159
  }); // Note: this displayName is temporarily set so that Storybook ArgTable
41
160
  // correctly displays the name of this component
42
161
 
@@ -56,6 +175,11 @@ Popover.propTypes = {
56
175
  */
57
176
  as: PropTypes.oneOfType([PropTypes.string, PropTypes.elementType]),
58
177
 
178
+ /**
179
+ * Will auto-align the popover on first render if it is not visible. This prop is currently experimental and is subject to futurue changes.
180
+ */
181
+ autoAlign: PropTypes.bool,
182
+
59
183
  /**
60
184
  * Specify whether a caret should be rendered
61
185
  */
@@ -87,12 +211,17 @@ Popover.propTypes = {
87
211
  */
88
212
  open: PropTypes.bool.isRequired
89
213
  };
90
- var PopoverContent = /*#__PURE__*/React__default.forwardRef(function PopoverContent(_ref, ref) {
214
+ var PopoverContent = /*#__PURE__*/React__default.forwardRef(function PopoverContent(_ref, forwardRef) {
91
215
  var className = _ref.className,
92
216
  children = _ref.children,
93
217
  rest = _objectWithoutProperties(_ref, _excluded2);
94
218
 
95
219
  var prefix = usePrefix();
220
+
221
+ var _React$useContext = React__default.useContext(PopoverContext),
222
+ floating = _React$useContext.floating;
223
+
224
+ var ref = useMergedRefs([floating, forwardRef]);
96
225
  return /*#__PURE__*/React__default.createElement("span", _extends({}, rest, {
97
226
  className: "".concat(prefix, "--popover")
98
227
  }), /*#__PURE__*/React__default.createElement("span", {
@@ -84,9 +84,9 @@ function ProgressBar(_ref) {
84
84
  })), /*#__PURE__*/React__default.createElement("div", {
85
85
  className: "".concat(prefix, "--progress-bar__track"),
86
86
  role: "progressbar",
87
+ "aria-busy": !isFinished,
87
88
  "aria-invalid": isError,
88
89
  "aria-labelledby": labelId,
89
- "aria-describedby": helperText ? helperId : null,
90
90
  "aria-valuemin": !indeterminate ? 0 : null,
91
91
  "aria-valuemax": !indeterminate ? max : null,
92
92
  "aria-valuenow": !indeterminate ? cappedValue : null
@@ -96,9 +96,12 @@ function ProgressBar(_ref) {
96
96
  transform: "scaleX(".concat(percentage, ")")
97
97
  } : null
98
98
  })), helperText && /*#__PURE__*/React__default.createElement("div", {
99
- id: helperId,
100
99
  className: "".concat(prefix, "--progress-bar__helper-text")
101
- }, helperText));
100
+ }, helperText, /*#__PURE__*/React__default.createElement("div", {
101
+ className: "".concat(prefix, "--visually-hidden"),
102
+ "aria-live": "polite",
103
+ id: helperId
104
+ }, isFinished ? 'Done' : 'Loading')));
102
105
  }
103
106
 
104
107
  ProgressBar.propTypes = {
@@ -20,18 +20,25 @@ var Select = /*#__PURE__*/React__default.forwardRef(function Select(_ref, ref) {
20
20
 
21
21
  var className = _ref.className,
22
22
  id = _ref.id,
23
- inline = _ref.inline,
23
+ _ref$inline = _ref.inline,
24
+ inline = _ref$inline === void 0 ? false : _ref$inline,
24
25
  labelText = _ref.labelText,
25
- disabled = _ref.disabled,
26
+ _ref$disabled = _ref.disabled,
27
+ disabled = _ref$disabled === void 0 ? false : _ref$disabled,
26
28
  children = _ref.children,
27
- noLabel = _ref.noLabel,
28
- hideLabel = _ref.hideLabel,
29
- invalid = _ref.invalid,
29
+ _ref$noLabel = _ref.noLabel,
30
+ noLabel = _ref$noLabel === void 0 ? false : _ref$noLabel,
31
+ _ref$hideLabel = _ref.hideLabel,
32
+ hideLabel = _ref$hideLabel === void 0 ? false : _ref$hideLabel,
33
+ _ref$invalid = _ref.invalid,
34
+ invalid = _ref$invalid === void 0 ? false : _ref$invalid,
30
35
  invalidText = _ref.invalidText,
31
36
  helperText = _ref.helperText,
32
- light = _ref.light,
37
+ _ref$light = _ref.light,
38
+ light = _ref$light === void 0 ? false : _ref$light,
33
39
  size = _ref.size,
34
- warn = _ref.warn,
40
+ _ref$warn = _ref.warn,
41
+ warn = _ref$warn === void 0 ? false : _ref$warn,
35
42
  warnText = _ref.warnText,
36
43
  other = _objectWithoutProperties(_ref, _excluded);
37
44
 
@@ -163,7 +163,7 @@ var HeaderMenu = /*#__PURE__*/function (_React$Component) {
163
163
  'aria-label': ariaLabel,
164
164
  'aria-labelledby': ariaLabelledBy
165
165
  };
166
- var className = cx((_cx = {}, _defineProperty(_cx, "".concat(prefix, "--header__submenu"), true), _defineProperty(_cx, customClassName, true), _defineProperty(_cx, "".concat(prefix, "--header__submenu--current"), isCurrentPage), _cx)); // Notes on eslint comments and based on the examples in:
166
+ var className = cx((_cx = {}, _defineProperty(_cx, "".concat(prefix, "--header__submenu"), true), _defineProperty(_cx, "".concat(prefix, "--header__submenu--current"), isCurrentPage), _defineProperty(_cx, customClassName, !!customClassName), _cx)); // Notes on eslint comments and based on the examples in:
167
167
  // https://www.w3.org/TR/wai-aria-practices/examples/menubar/menubar-1/menubar-1.html#
168
168
  // - The focus is handled by the <a> menuitem, onMouseOver is for mouse
169
169
  // users
@@ -17,7 +17,7 @@ var _Menu, _Close;
17
17
 
18
18
  var _excluded = ["aria-label", "aria-labelledby", "className", "renderMenuIcon", "renderCloseIcon", "onClick", "isActive", "isCollapsible"];
19
19
 
20
- var HeaderMenuButton = function HeaderMenuButton(_ref) {
20
+ function HeaderMenuButton(_ref) {
21
21
  var _cx;
22
22
 
23
23
  var ariaLabel = _ref['aria-label'],
@@ -48,7 +48,7 @@ var HeaderMenuButton = function HeaderMenuButton(_ref) {
48
48
  type: "button",
49
49
  onClick: onClick
50
50
  }), isActive ? closeIcon : menuIcon);
51
- };
51
+ }
52
52
 
53
53
  HeaderMenuButton.propTypes = _objectSpread2(_objectSpread2({}, AriaLabelPropType), {}, {
54
54
  /**
@@ -64,6 +64,5 @@ HeaderMenuButton.propTypes = _objectSpread2(_objectSpread2({}, AriaLabelPropType
64
64
  */
65
65
  onClick: PropTypes.func
66
66
  });
67
- var HeaderMenuButton$1 = HeaderMenuButton;
68
67
 
69
- export { HeaderMenuButton$1 as default };
68
+ export { HeaderMenuButton as default };
@@ -14,7 +14,7 @@ import { usePrefix } from '../../internal/usePrefix.js';
14
14
 
15
15
  var _excluded = ["children", "className", "prefix", "href"];
16
16
 
17
- var HeaderName = function HeaderName(_ref) {
17
+ function HeaderName(_ref) {
18
18
  var children = _ref.children,
19
19
  customClassName = _ref.className,
20
20
  prefix = _ref.prefix,
@@ -29,7 +29,7 @@ var HeaderName = function HeaderName(_ref) {
29
29
  }), prefix && /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("span", {
30
30
  className: "".concat(selectorPrefix, "--header__name--prefix")
31
31
  }, prefix), "\xA0"), children);
32
- };
32
+ }
33
33
 
34
34
  HeaderName.propTypes = _objectSpread2(_objectSpread2({}, LinkPropTypes), {}, {
35
35
  /**
@@ -57,6 +57,5 @@ HeaderName.propTypes = _objectSpread2(_objectSpread2({}, LinkPropTypes), {}, {
57
57
  HeaderName.defaultProps = {
58
58
  prefix: 'IBM'
59
59
  };
60
- var HeaderName$1 = HeaderName;
61
60
 
62
- export { HeaderName$1 as default };
61
+ export { HeaderName as default };
@@ -5,84 +5,38 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- import { inherits as _inherits, createSuper as _createSuper, classCallCheck as _classCallCheck, defineProperty as _defineProperty, assertThisInitialized as _assertThisInitialized, createClass as _createClass, objectWithoutProperties as _objectWithoutProperties, extends as _extends, objectSpread2 as _objectSpread2 } from '../../_virtual/_rollupPluginBabelHelpers.js';
8
+ import { objectWithoutProperties as _objectWithoutProperties, extends as _extends, objectSpread2 as _objectSpread2 } from '../../_virtual/_rollupPluginBabelHelpers.js';
9
9
  import cx from 'classnames';
10
10
  import React__default from 'react';
11
11
  import PropTypes from 'prop-types';
12
12
  import { AriaLabelPropType } from '../../prop-types/AriaPropTypes.js';
13
- import { PrefixContext } from '../../internal/usePrefix.js';
13
+ import { usePrefix } from '../../internal/usePrefix.js';
14
14
 
15
15
  var _excluded = ["aria-label", "aria-labelledby", "children", "className"];
16
16
 
17
- var HeaderNavigation = /*#__PURE__*/function (_React$Component) {
18
- _inherits(HeaderNavigation, _React$Component);
19
-
20
- var _super = _createSuper(HeaderNavigation);
21
-
22
- function HeaderNavigation(props) {
23
- var _this;
24
-
25
- _classCallCheck(this, HeaderNavigation);
26
-
27
- _this = _super.call(this, props);
28
-
29
- _defineProperty(_assertThisInitialized(_this), "handleItemRef", function (index) {
30
- return function (node) {
31
- _this.items[index] = node;
32
- };
33
- });
34
-
35
- _defineProperty(_assertThisInitialized(_this), "_renderNavItem", function (child, index) {
36
- if ( /*#__PURE__*/React__default.isValidElement(child)) {
37
- return /*#__PURE__*/React__default.cloneElement(child, {
38
- ref: _this.handleItemRef(index)
39
- });
40
- }
41
- });
42
-
43
- _this.items = [];
44
- _this.state = {
45
- selectedIndex: 0
46
- };
47
- return _this;
48
- }
49
-
50
- _createClass(HeaderNavigation, [{
51
- key: "render",
52
- value: function render() {
53
- var prefix = this.context;
54
-
55
- var _this$props = this.props,
56
- ariaLabel = _this$props['aria-label'],
57
- ariaLabelledBy = _this$props['aria-labelledby'],
58
- children = _this$props.children,
59
- customClassName = _this$props.className,
60
- rest = _objectWithoutProperties(_this$props, _excluded);
61
-
62
- var className = cx("".concat(prefix, "--header__nav"), customClassName); // Assign both label strategies in this option, only one should be defined
63
- // so when we spread that should be the one that is applied to the node
64
-
65
- var accessibilityLabel = {
66
- 'aria-label': ariaLabel,
67
- 'aria-labelledby': ariaLabelledBy
68
- };
69
- return /*#__PURE__*/React__default.createElement("nav", _extends({}, rest, accessibilityLabel, {
70
- className: className
71
- }), /*#__PURE__*/React__default.createElement("ul", _extends({}, accessibilityLabel, {
72
- className: "".concat(prefix, "--header__menu-bar")
73
- }), React__default.Children.map(children, this._renderNavItem)));
74
- }
75
- /**
76
- * Render an individual menuitem, adding a `ref` for each child inside of
77
- * `this.items` to properly manage focus.
78
- */
79
-
80
- }]);
81
-
82
- return HeaderNavigation;
83
- }(React__default.Component);
84
-
85
- _defineProperty(HeaderNavigation, "propTypes", _objectSpread2(_objectSpread2({}, AriaLabelPropType), {}, {
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), {}, {
86
40
  /**
87
41
  * Provide valid children of HeaderNavigation, for example `HeaderMenuItem`
88
42
  * or `HeaderMenu`
@@ -93,8 +47,6 @@ _defineProperty(HeaderNavigation, "propTypes", _objectSpread2(_objectSpread2({},
93
47
  * Optionally provide a custom class to apply to the underlying <nav> node
94
48
  */
95
49
  className: PropTypes.string
96
- }));
97
-
98
- _defineProperty(HeaderNavigation, "contextType", PrefixContext);
50
+ });
99
51
 
100
- export { HeaderNavigation as default };
52
+ export { HeaderNavigation };
@@ -5,20 +5,25 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
+ import { objectWithoutProperties as _objectWithoutProperties, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
8
9
  import cx from 'classnames';
9
10
  import PropTypes from 'prop-types';
10
11
  import React__default from 'react';
11
12
  import { usePrefix } from '../../internal/usePrefix.js';
12
13
 
14
+ var _excluded = ["children", "className", "title"];
15
+
13
16
  var SideNavDetails = function SideNavDetails(_ref) {
14
17
  var children = _ref.children,
15
18
  customClassName = _ref.className,
16
- title = _ref.title;
19
+ title = _ref.title,
20
+ rest = _objectWithoutProperties(_ref, _excluded);
21
+
17
22
  var prefix = usePrefix();
18
23
  var className = cx("".concat(prefix, "--side-nav__details"), customClassName);
19
- return /*#__PURE__*/React__default.createElement("div", {
24
+ return /*#__PURE__*/React__default.createElement("div", _extends({
20
25
  className: className
21
- }, /*#__PURE__*/React__default.createElement("h2", {
26
+ }, rest), /*#__PURE__*/React__default.createElement("h2", {
22
27
  className: "".concat(prefix, "--side-nav__title"),
23
28
  title: title
24
29
  }, title), children);
@@ -18,7 +18,7 @@ var _Close, _ChevronRight;
18
18
  * user interaction to expand or collapse the side navigation.
19
19
  */
20
20
 
21
- var SideNavFooter = function SideNavFooter(_ref) {
21
+ function SideNavFooter(_ref) {
22
22
  var assistiveText = _ref.assistiveText,
23
23
  customClassName = _ref.className,
24
24
  expanded = _ref.expanded,
@@ -43,7 +43,7 @@ var SideNavFooter = function SideNavFooter(_ref) {
43
43
  }))), /*#__PURE__*/React__default.createElement("span", {
44
44
  className: "".concat(prefix, "--assistive-text")
45
45
  }, assistiveText)));
46
- };
46
+ }
47
47
 
48
48
  SideNavFooter.propTypes = {
49
49
  /**
@@ -58,12 +58,6 @@ SideNavFooter.propTypes = {
58
58
  */
59
59
  expanded: PropTypes.bool.isRequired,
60
60
 
61
- /**
62
- * Property to indicate if the side nav container is open (or not). Use to
63
- * keep local state and styling in step with the SideNav expansion state.
64
- */
65
- isSideNavExpanded: PropTypes.bool,
66
-
67
61
  /**
68
62
  * Provide a function that is called when the toggle button is interacted
69
63
  * with. Useful for controlling the expansion state of the side navigation.
@@ -73,6 +67,5 @@ SideNavFooter.propTypes = {
73
67
  SideNavFooter.defaultProps = {
74
68
  assistiveText: 'Toggle opening or closing the side navigation'
75
69
  };
76
- var SideNavFooter$1 = SideNavFooter;
77
70
 
78
- export { SideNavFooter$1 as default };
71
+ export { SideNavFooter as default };