@carbon/react 1.22.0-rc.0 → 1.22.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 (71) hide show
  1. package/es/{es/components → components}/Checkbox/Checkbox.Skeleton.d.ts +0 -0
  2. package/es/{es/components → components}/Checkbox/Checkbox.d.ts +0 -0
  3. package/es/{es/components → components}/Checkbox/index.d.ts +0 -0
  4. package/es/{es/components → components}/DataTable/TableSelectAll.d.ts +0 -0
  5. package/es/{es/components → components}/Dropdown/Dropdown.d.ts +0 -0
  6. package/es/{es/components → components}/Dropdown/index.d.ts +0 -0
  7. package/es/{es/components → components}/FluidForm/FluidForm.d.ts +0 -0
  8. package/es/{es/components → components}/FluidForm/FormContext.d.ts +0 -0
  9. package/es/{es/components → components}/FluidForm/index.d.ts +0 -0
  10. package/es/components/FluidSelect/FluidSelect.js +1 -0
  11. package/es/components/IconButton/index.js +1 -0
  12. package/es/{es/components → components}/ListBox/ListBox.d.ts +0 -0
  13. package/es/{es/components → components}/ListBox/ListBoxField.d.ts +0 -0
  14. package/es/{es/components → components}/ListBox/ListBoxMenu.d.ts +0 -0
  15. package/es/{es/components → components}/ListBox/ListBoxMenuIcon.d.ts +0 -0
  16. package/es/{es/components → components}/ListBox/ListBoxMenuItem.d.ts +0 -0
  17. package/es/{es/components → components}/ListBox/ListBoxPropTypes.d.ts +0 -0
  18. package/es/{es/components → components}/ListBox/ListBoxSelection.d.ts +0 -0
  19. package/es/{es/components → components}/ListBox/index.d.ts +0 -0
  20. package/es/{es/components → components}/NumberInput/NumberInput.Skeleton.d.ts +0 -0
  21. package/es/components/OverflowMenu/OverflowMenu.js +28 -34
  22. package/es/components/Pagination/Pagination.js +1 -0
  23. package/es/components/Pagination/experimental/PageSelector.js +1 -0
  24. package/es/components/Pagination/experimental/Pagination.js +1 -0
  25. package/es/components/Select/Select.Skeleton.d.ts +33 -0
  26. package/es/components/Select/index.js +1 -0
  27. package/es/{es/components → components}/Slider/Slider.Skeleton.d.ts +0 -0
  28. package/es/{es/components → components}/Text/Text.d.ts +0 -0
  29. package/es/{es/components → components}/Text/TextDirection.d.ts +0 -0
  30. package/es/{es/components → components}/Text/createTextComponent.d.ts +0 -0
  31. package/es/{es/components → components}/Text/index.d.ts +0 -0
  32. package/es/components/Tooltip/Tooltip.js +33 -4
  33. package/es/{es/index.d.ts → index.d.ts} +0 -0
  34. package/es/internal/FloatingMenu.js +1 -4
  35. package/es/{es/internal → internal}/usePrefix.d.ts +0 -0
  36. package/lib/{lib/components → components}/Checkbox/Checkbox.Skeleton.d.ts +0 -0
  37. package/lib/{lib/components → components}/Checkbox/Checkbox.d.ts +0 -0
  38. package/lib/{lib/components → components}/Checkbox/index.d.ts +0 -0
  39. package/lib/{lib/components → components}/DataTable/TableSelectAll.d.ts +0 -0
  40. package/lib/{lib/components → components}/Dropdown/Dropdown.d.ts +0 -0
  41. package/lib/{lib/components → components}/Dropdown/index.d.ts +0 -0
  42. package/lib/{lib/components → components}/FluidForm/FluidForm.d.ts +0 -0
  43. package/lib/{lib/components → components}/FluidForm/FormContext.d.ts +0 -0
  44. package/lib/{lib/components → components}/FluidForm/index.d.ts +0 -0
  45. package/lib/components/FluidSelect/FluidSelect.js +1 -0
  46. package/lib/components/IconButton/index.js +1 -0
  47. package/lib/{lib/components → components}/ListBox/ListBox.d.ts +0 -0
  48. package/lib/{lib/components → components}/ListBox/ListBoxField.d.ts +0 -0
  49. package/lib/{lib/components → components}/ListBox/ListBoxMenu.d.ts +0 -0
  50. package/lib/{lib/components → components}/ListBox/ListBoxMenuIcon.d.ts +0 -0
  51. package/lib/{lib/components → components}/ListBox/ListBoxMenuItem.d.ts +0 -0
  52. package/lib/{lib/components → components}/ListBox/ListBoxPropTypes.d.ts +0 -0
  53. package/lib/{lib/components → components}/ListBox/ListBoxSelection.d.ts +0 -0
  54. package/lib/{lib/components → components}/ListBox/index.d.ts +0 -0
  55. package/lib/{lib/components → components}/NumberInput/NumberInput.Skeleton.d.ts +0 -0
  56. package/lib/components/OverflowMenu/OverflowMenu.js +27 -52
  57. package/lib/components/Pagination/Pagination.js +1 -0
  58. package/lib/components/Pagination/experimental/PageSelector.js +1 -0
  59. package/lib/components/Pagination/experimental/Pagination.js +1 -0
  60. package/lib/components/Select/Select.Skeleton.d.ts +33 -0
  61. package/lib/components/Select/index.js +2 -0
  62. package/lib/{lib/components → components}/Slider/Slider.Skeleton.d.ts +0 -0
  63. package/lib/{lib/components → components}/Text/Text.d.ts +0 -0
  64. package/lib/{lib/components → components}/Text/TextDirection.d.ts +0 -0
  65. package/lib/{lib/components → components}/Text/createTextComponent.d.ts +0 -0
  66. package/lib/{lib/components → components}/Text/index.d.ts +0 -0
  67. package/lib/components/Tooltip/Tooltip.js +31 -2
  68. package/lib/{lib/index.d.ts → index.d.ts} +0 -0
  69. package/lib/internal/FloatingMenu.js +1 -4
  70. package/lib/{lib/internal → internal}/usePrefix.d.ts +0 -0
  71. package/package.json +4 -4
@@ -10,6 +10,7 @@ import PropTypes from 'prop-types';
10
10
  import React__default from 'react';
11
11
  import cx from 'classnames';
12
12
  import Select from '../Select/Select.js';
13
+ import '../Select/Select.Skeleton.js';
13
14
  import { usePrefix } from '../../internal/usePrefix.js';
14
15
  import { FormContext } from '../FluidForm/FormContext.js';
15
16
 
@@ -32,6 +32,7 @@ var IconButton = /*#__PURE__*/React__default.forwardRef(function IconButton(prop
32
32
  return /*#__PURE__*/React__default.createElement(Tooltip, {
33
33
  align: align,
34
34
  className: "".concat(prefix, "--icon-tooltip"),
35
+ closeOnActivation: true,
35
36
  defaultOpen: defaultOpen,
36
37
  enterDelayMs: enterDelayMs,
37
38
  label: label,
@@ -15,10 +15,10 @@ import FloatingMenu, { DIRECTION_TOP, DIRECTION_BOTTOM } from '../../internal/Fl
15
15
  import { OverflowMenuVertical } from '@carbon/icons-react';
16
16
  import mergeRefs from '../../tools/mergeRefs.js';
17
17
  import { PrefixContext } from '../../internal/usePrefix.js';
18
- import * as FeatureFlags from '@carbon/feature-flags';
19
18
  import deprecate from '../../prop-types/deprecate.js';
19
+ import { IconButton } from '../IconButton/index.js';
20
20
  import { matches } from '../../internal/keyboard/match.js';
21
- import { ArrowDown, ArrowUp, ArrowRight, ArrowLeft, Escape } from '../../internal/keyboard/keys.js';
21
+ import { ArrowUp, ArrowRight, ArrowDown, ArrowLeft, Escape } from '../../internal/keyboard/keys.js';
22
22
 
23
23
  var _excluded = ["id", "ariaLabel", "children", "iconDescription", "direction", "flipped", "focusTrap", "menuOffset", "menuOffsetFlip", "iconClass", "onClick", "onOpen", "selectorPrimaryFocus", "renderIcon", "innerRef", "menuOptionsClass", "light", "size"];
24
24
 
@@ -129,14 +129,14 @@ var OverflowMenu = /*#__PURE__*/function (_Component) {
129
129
  }
130
130
  });
131
131
 
132
- _defineProperty(_assertThisInitialized(_this), "handleKeyDown", function (evt) {
133
- if (matches(evt, [ArrowDown])) {
134
- _this.setState({
135
- open: !_this.state.open
136
- });
132
+ _defineProperty(_assertThisInitialized(_this), "closeMenuAndFocus", function () {
133
+ var wasOpen = _this.state.open;
137
134
 
138
- _this.props.onClick(evt);
139
- }
135
+ _this.closeMenu(function () {
136
+ if (wasOpen) {
137
+ _this.focusMenuEl();
138
+ }
139
+ });
140
140
  });
141
141
 
142
142
  _defineProperty(_assertThisInitialized(_this), "handleKeyPress", function (evt) {
@@ -146,13 +146,7 @@ var OverflowMenu = /*#__PURE__*/function (_Component) {
146
146
 
147
147
 
148
148
  if (matches(evt, [Escape])) {
149
- var wasOpen = _this.state.open;
150
-
151
- _this.closeMenu(function () {
152
- if (wasOpen) {
153
- _this.focusMenuEl();
154
- }
155
- }); // Stop the esc keypress from bubbling out and closing something it shouldn't
149
+ _this.closeMenuAndFocus(); // Stop the esc keypress from bubbling out and closing something it shouldn't
156
150
 
157
151
 
158
152
  evt.stopPropagation();
@@ -187,8 +181,6 @@ var OverflowMenu = /*#__PURE__*/function (_Component) {
187
181
  });
188
182
 
189
183
  _defineProperty(_assertThisInitialized(_this), "handleOverflowMenuItemFocus", function (_ref) {
190
- var _overflowMenuItem$cur;
191
-
192
184
  var currentIndex = _ref.currentIndex,
193
185
  direction = _ref.direction;
194
186
  var enabledIndices = React__default.Children.toArray(_this.props.children).reduce(function (acc, curr, i) {
@@ -202,7 +194,7 @@ var OverflowMenu = /*#__PURE__*/function (_Component) {
202
194
  var nextValidIndex = function () {
203
195
  var nextIndex = enabledIndices.indexOf(currentIndex) + direction;
204
196
 
205
- switch (enabledIndices.indexOf(currentIndex) + direction) {
197
+ switch (nextIndex) {
206
198
  case -1:
207
199
  return enabledIndices.length - 1;
208
200
 
@@ -214,9 +206,9 @@ var OverflowMenu = /*#__PURE__*/function (_Component) {
214
206
  }
215
207
  }();
216
208
 
217
- var overflowMenuItem = _this["overflowMenuItem".concat(enabledIndices[nextValidIndex])].overflowMenuItem;
209
+ var overflowMenuItem = _this["overflowMenuItem".concat(enabledIndices[nextValidIndex])];
218
210
 
219
- overflowMenuItem === null || overflowMenuItem === void 0 ? void 0 : (_overflowMenuItem$cur = overflowMenuItem.current) === null || _overflowMenuItem$cur === void 0 ? void 0 : _overflowMenuItem$cur.focus();
211
+ overflowMenuItem === null || overflowMenuItem === void 0 ? void 0 : overflowMenuItem.focus();
220
212
  });
221
213
 
222
214
  _defineProperty(_assertThisInitialized(_this), "_bindMenuBody", function (menuBody) {
@@ -240,7 +232,7 @@ var OverflowMenu = /*#__PURE__*/function (_Component) {
240
232
 
241
233
  if (typeof target.matches === 'function') {
242
234
  if (!menuBody.contains(target) && triggerEl && !target.matches(".".concat(_this.context, "--overflow-menu,.").concat(_this.context, "--overflow-menu-options"))) {
243
- _this.closeMenu();
235
+ _this.closeMenuAndFocus();
244
236
  }
245
237
  }
246
238
  }, !hasFocusin);
@@ -324,7 +316,7 @@ var OverflowMenu = /*#__PURE__*/function (_Component) {
324
316
  var _child$props;
325
317
 
326
318
  return /*#__PURE__*/React__default.cloneElement(child, {
327
- closeMenu: (child === null || child === void 0 ? void 0 : (_child$props = child.props) === null || _child$props === void 0 ? void 0 : _child$props.closeMenu) || _this2.closeMenu,
319
+ closeMenu: (child === null || child === void 0 ? void 0 : (_child$props = child.props) === null || _child$props === void 0 ? void 0 : _child$props.closeMenu) || _this2.closeMenuAndFocus,
328
320
  handleOverflowMenuItemFocus: _this2.handleOverflowMenuItemFocus,
329
321
  ref: function ref(e) {
330
322
  _this2["overflowMenuItem".concat(index)] = e;
@@ -336,7 +328,8 @@ var OverflowMenu = /*#__PURE__*/function (_Component) {
336
328
  className: overflowMenuOptionsClasses,
337
329
  tabIndex: "-1",
338
330
  role: "menu",
339
- "aria-label": ariaLabel
331
+ "aria-label": ariaLabel,
332
+ onKeyDown: this.handleKeyPress
340
333
  }, childrenWithProps);
341
334
  var wrappedMenuBody = /*#__PURE__*/React__default.createElement(FloatingMenu, {
342
335
  focusTrap: focusTrap,
@@ -357,17 +350,18 @@ var OverflowMenu = /*#__PURE__*/function (_Component) {
357
350
  };
358
351
  return /*#__PURE__*/React__default.createElement(ClickListener, {
359
352
  onClickOutside: this.handleClickOutside
360
- }, /*#__PURE__*/React__default.createElement("button", _extends({}, other, {
353
+ }, /*#__PURE__*/React__default.createElement("span", {
354
+ className: "".concat(prefix, "--overflow-menu__wrapper")
355
+ }, /*#__PURE__*/React__default.createElement(IconButton, _extends({}, other, {
361
356
  type: "button",
362
357
  "aria-haspopup": true,
363
358
  "aria-expanded": this.state.open,
364
359
  className: overflowMenuClasses,
365
- onKeyDown: this.handleKeyPress,
366
360
  onClick: this.handleClick,
367
- "aria-label": ariaLabel,
368
361
  id: id,
369
- ref: mergeRefs(this._triggerRef, ref)
370
- }), /*#__PURE__*/React__default.createElement(IconElement, iconProps), open && this.state.hasMountedTrigger && wrappedMenuBody));
362
+ ref: mergeRefs(this._triggerRef, ref),
363
+ label: iconDescription
364
+ }), /*#__PURE__*/React__default.createElement(IconElement, iconProps)), open && this.state.hasMountedTrigger && wrappedMenuBody));
371
365
  }
372
366
  }], [{
373
367
  key: "getDerivedStateFromProps",
@@ -388,7 +382,7 @@ _defineProperty(OverflowMenu, "propTypes", {
388
382
  /**
389
383
  * The ARIA label.
390
384
  */
391
- ariaLabel: FeatureFlags.enabled('enable-v11-release') ? PropTypes.string.isRequired : PropTypes.string,
385
+ ariaLabel: PropTypes.string.isRequired,
392
386
 
393
387
  /**
394
388
  * The child nodes.
@@ -434,7 +428,7 @@ _defineProperty(OverflowMenu, "propTypes", {
434
428
  * `true` to use the light version. For use on $ui-01 backgrounds only.
435
429
  * Don't use this to make OverflowMenu background color same as container background color.
436
430
  */
437
- light: FeatureFlags.enabled('enable-v11-release') ? deprecate(PropTypes.bool, 'The `light` prop for `OverflowMenu` is no longer needed and has been deprecated. It will be removed in the next major release. Use the Layer component instead.') : PropTypes.bool,
431
+ light: deprecate(PropTypes.bool, 'The `light` prop for `OverflowMenu` is no longer needed and has been deprecated. It will be removed in the next major release. Use the Layer component instead.'),
438
432
 
439
433
  /**
440
434
  * The adjustment in position applied to the floating menu.
@@ -501,14 +495,14 @@ _defineProperty(OverflowMenu, "propTypes", {
501
495
  /**
502
496
  * Specify the size of the OverflowMenu. Currently supports either `sm`, 'md' (default) or 'lg` as an option.
503
497
  */
504
- size: FeatureFlags.enabled('enable-v11-release') ? PropTypes.oneOf(['sm', 'md', 'lg']) : PropTypes.oneOf(['sm', 'md', 'lg', 'xl'])
498
+ size: PropTypes.oneOf(['sm', 'md', 'lg'])
505
499
  });
506
500
 
507
501
  _defineProperty(OverflowMenu, "contextType", PrefixContext);
508
502
 
509
503
  _defineProperty(OverflowMenu, "defaultProps", {
510
- ariaLabel: FeatureFlags.enabled('enable-v11-release') ? null : 'Open and close list of options',
511
- iconDescription: 'Open and close list of options',
504
+ ariaLabel: null,
505
+ iconDescription: 'Options',
512
506
  open: false,
513
507
  direction: DIRECTION_BOTTOM,
514
508
  flipped: false,
@@ -11,6 +11,7 @@ import cx from 'classnames';
11
11
  import PropTypes from 'prop-types';
12
12
  import React__default, { useRef, useState } from 'react';
13
13
  import Select from '../Select/Select.js';
14
+ import '../Select/Select.Skeleton.js';
14
15
  import SelectItem from '../SelectItem/SelectItem.js';
15
16
  import { equals } from '../../tools/array.js';
16
17
  import { useFallbackId } from '../../internal/useId.js';
@@ -11,6 +11,7 @@ import PropTypes from 'prop-types';
11
11
  import cx from 'classnames';
12
12
  import setupGetInstanceId from '../../../tools/setupGetInstanceId.js';
13
13
  import Select from '../../Select/Select.js';
14
+ import '../../Select/Select.Skeleton.js';
14
15
  import SelectItem from '../../SelectItem/SelectItem.js';
15
16
  import { usePrefix } from '../../../internal/usePrefix.js';
16
17
 
@@ -12,6 +12,7 @@ import cx from 'classnames';
12
12
  import { CaretLeft, CaretRight } from '@carbon/icons-react';
13
13
  import Button from '../../Button/Button.js';
14
14
  import Select from '../../Select/Select.js';
15
+ import '../../Select/Select.Skeleton.js';
15
16
  import SelectItem from '../../SelectItem/SelectItem.js';
16
17
  import { IconButton } from '../../IconButton/index.js';
17
18
  import * as FeatureFlags from '@carbon/feature-flags';
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Copyright IBM Corp. 2016, 2018
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
+ import PropTypes from 'prop-types';
8
+ import { HTMLAttributes } from 'react';
9
+ export interface SelectSkeletonProps extends HTMLAttributes<HTMLDivElement> {
10
+ /**
11
+ * Specify an optional className to add to the form item wrapper.
12
+ */
13
+ className?: string;
14
+ /**
15
+ * Specify whether the label should be hidden, or not
16
+ */
17
+ hideLabel?: boolean;
18
+ }
19
+ declare const SelectSkeleton: {
20
+ ({ hideLabel, className, ...rest }: SelectSkeletonProps): JSX.Element;
21
+ propTypes: {
22
+ /**
23
+ * Specify an optional className to add to the form item wrapper.
24
+ */
25
+ className: PropTypes.Requireable<string>;
26
+ /**
27
+ * Specify whether the label should be hidden, or not
28
+ */
29
+ hideLabel: PropTypes.Requireable<boolean>;
30
+ };
31
+ };
32
+ export default SelectSkeleton;
33
+ export { SelectSkeleton };
@@ -7,3 +7,4 @@
7
7
 
8
8
  import Select from './Select.js';
9
9
  export { default as Select, default } from './Select.js';
10
+ export { default as SelectSkeleton } from './Select.Skeleton.js';
File without changes
File without changes
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- import { objectWithoutProperties as _objectWithoutProperties, slicedToArray as _slicedToArray, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
8
+ import { objectWithoutProperties as _objectWithoutProperties, slicedToArray as _slicedToArray, extends as _extends, objectSpread2 as _objectSpread2 } from '../../_virtual/_rollupPluginBabelHelpers.js';
9
9
  import cx from 'classnames';
10
10
  import PropTypes from 'prop-types';
11
11
  import React__default, { useRef, useEffect } from 'react';
@@ -15,9 +15,9 @@ import { useId } from '../../internal/useId.js';
15
15
  import { useNoInteractiveChildren, getInteractiveContent } from '../../internal/useNoInteractiveChildren.js';
16
16
  import { usePrefix } from '../../internal/usePrefix.js';
17
17
  import { match } from '../../internal/keyboard/match.js';
18
- import { Escape } from '../../internal/keyboard/keys.js';
18
+ import { Escape, Enter, Space } from '../../internal/keyboard/keys.js';
19
19
 
20
- var _excluded = ["align", "className", "children", "label", "description", "enterDelayMs", "leaveDelayMs", "defaultOpen"];
20
+ var _excluded = ["align", "className", "children", "label", "description", "enterDelayMs", "leaveDelayMs", "defaultOpen", "closeOnActivation"];
21
21
 
22
22
  function Tooltip(_ref) {
23
23
  var _ref$align = _ref.align,
@@ -32,6 +32,8 @@ function Tooltip(_ref) {
32
32
  leaveDelayMs = _ref$leaveDelayMs === void 0 ? 300 : _ref$leaveDelayMs,
33
33
  _ref$defaultOpen = _ref.defaultOpen,
34
34
  defaultOpen = _ref$defaultOpen === void 0 ? false : _ref$defaultOpen,
35
+ _ref$closeOnActivatio = _ref.closeOnActivation,
36
+ closeOnActivation = _ref$closeOnActivatio === void 0 ? false : _ref$closeOnActivatio,
35
37
  rest = _objectWithoutProperties(_ref, _excluded);
36
38
 
37
39
  var containerRef = useRef(null);
@@ -52,10 +54,28 @@ function Tooltip(_ref) {
52
54
  onBlur: function onBlur() {
53
55
  return setOpen(false);
54
56
  },
57
+ onClick: function onClick() {
58
+ return closeOnActivation && setOpen(false);
59
+ },
55
60
  // This should be placed on the trigger in case the element is disabled
56
61
  onMouseEnter: onMouseEnter
57
62
  };
58
63
 
64
+ function getChildEventHandlers(childProps) {
65
+ var eventHandlerFunctions = ['onFocus', 'onBlur', 'onClick', 'onMouseEnter'];
66
+ var eventHandlers = {};
67
+ eventHandlerFunctions.forEach(function (functionName) {
68
+ eventHandlers[functionName] = function (evt) {
69
+ triggerProps[functionName]();
70
+
71
+ if (childProps !== null && childProps !== void 0 && childProps[functionName]) {
72
+ childProps === null || childProps === void 0 ? void 0 : childProps[functionName](evt);
73
+ }
74
+ };
75
+ });
76
+ return eventHandlers;
77
+ }
78
+
59
79
  if (label) {
60
80
  triggerProps['aria-labelledby'] = id;
61
81
  } else {
@@ -67,6 +87,10 @@ function Tooltip(_ref) {
67
87
  event.stopPropagation();
68
88
  setOpen(false);
69
89
  }
90
+
91
+ if (open && closeOnActivation && (match(event, Enter) || match(event, Space))) {
92
+ setOpen(false);
93
+ }
70
94
  }
71
95
 
72
96
  function onMouseEnter() {
@@ -94,7 +118,7 @@ function Tooltip(_ref) {
94
118
  onMouseLeave: onMouseLeave,
95
119
  open: open,
96
120
  ref: containerRef
97
- }), /*#__PURE__*/React__default.cloneElement(child, triggerProps), /*#__PURE__*/React__default.createElement(PopoverContent, {
121
+ }), /*#__PURE__*/React__default.cloneElement(child, _objectSpread2(_objectSpread2({}, triggerProps), getChildEventHandlers(child.props))), /*#__PURE__*/React__default.createElement(PopoverContent, {
98
122
  "aria-hidden": "true",
99
123
  className: "".concat(prefix, "--tooltip-content"),
100
124
  id: id,
@@ -119,6 +143,11 @@ Tooltip.propTypes = {
119
143
  */
120
144
  className: PropTypes.string,
121
145
 
146
+ /**
147
+ * Determines wether the tooltip should close when inner content is activated (click, Enter or Space)
148
+ */
149
+ closeOnActivation: PropTypes.bool,
150
+
122
151
  /**
123
152
  * Specify whether the tooltip should be open when it first renders
124
153
  */
File without changes
@@ -266,10 +266,7 @@ var FloatingMenu = /*#__PURE__*/function (_React$Component) {
266
266
  tabbableNode || // First sequentially focusable node
267
267
  focusableNode || // First programmatic focusable node
268
268
  menuBody;
269
-
270
- if (_this.props.focusTrap) {
271
- focusTarget.focus();
272
- }
269
+ focusTarget.focus();
273
270
 
274
271
  if (focusTarget === menuBody && process.env.NODE_ENV !== "production") {
275
272
  process.env.NODE_ENV !== "production" ? warning(focusableNode === null, 'Floating Menus must have at least a programmatically focusable child. ' + 'This can be accomplished by adding tabIndex="-1" to the content element.') : void 0;
File without changes
@@ -14,6 +14,7 @@ var PropTypes = require('prop-types');
14
14
  var React = require('react');
15
15
  var cx = require('classnames');
16
16
  var Select = require('../Select/Select.js');
17
+ require('../Select/Select.Skeleton.js');
17
18
  var usePrefix = require('../../internal/usePrefix.js');
18
19
  var FormContext = require('../FluidForm/FormContext.js');
19
20
 
@@ -42,6 +42,7 @@ var IconButton = /*#__PURE__*/React__default["default"].forwardRef(function Icon
42
42
  return /*#__PURE__*/React__default["default"].createElement(Tooltip.Tooltip, {
43
43
  align: align,
44
44
  className: "".concat(prefix, "--icon-tooltip"),
45
+ closeOnActivation: true,
45
46
  defaultOpen: defaultOpen,
46
47
  enterDelayMs: enterDelayMs,
47
48
  label: label,
@@ -19,36 +19,17 @@ var FloatingMenu = require('../../internal/FloatingMenu.js');
19
19
  var iconsReact = require('@carbon/icons-react');
20
20
  var mergeRefs = require('../../tools/mergeRefs.js');
21
21
  var usePrefix = require('../../internal/usePrefix.js');
22
- var FeatureFlags = require('@carbon/feature-flags');
23
22
  var deprecate = require('../../prop-types/deprecate.js');
23
+ var index = require('../IconButton/index.js');
24
24
  var match = require('../../internal/keyboard/match.js');
25
25
  var keys = require('../../internal/keyboard/keys.js');
26
26
 
27
27
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
28
28
 
29
- function _interopNamespace(e) {
30
- if (e && e.__esModule) return e;
31
- var n = Object.create(null);
32
- if (e) {
33
- Object.keys(e).forEach(function (k) {
34
- if (k !== 'default') {
35
- var d = Object.getOwnPropertyDescriptor(e, k);
36
- Object.defineProperty(n, k, d.get ? d : {
37
- enumerable: true,
38
- get: function () { return e[k]; }
39
- });
40
- }
41
- });
42
- }
43
- n["default"] = e;
44
- return Object.freeze(n);
45
- }
46
-
47
29
  var invariant__default = /*#__PURE__*/_interopDefaultLegacy(invariant);
48
30
  var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
49
31
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
50
32
  var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
51
- var FeatureFlags__namespace = /*#__PURE__*/_interopNamespace(FeatureFlags);
52
33
 
53
34
  var _excluded = ["id", "ariaLabel", "children", "iconDescription", "direction", "flipped", "focusTrap", "menuOffset", "menuOffsetFlip", "iconClass", "onClick", "onOpen", "selectorPrimaryFocus", "renderIcon", "innerRef", "menuOptionsClass", "light", "size"];
54
35
 
@@ -159,14 +140,14 @@ var OverflowMenu = /*#__PURE__*/function (_Component) {
159
140
  }
160
141
  });
161
142
 
162
- _rollupPluginBabelHelpers.defineProperty(_rollupPluginBabelHelpers.assertThisInitialized(_this), "handleKeyDown", function (evt) {
163
- if (match.matches(evt, [keys.ArrowDown])) {
164
- _this.setState({
165
- open: !_this.state.open
166
- });
143
+ _rollupPluginBabelHelpers.defineProperty(_rollupPluginBabelHelpers.assertThisInitialized(_this), "closeMenuAndFocus", function () {
144
+ var wasOpen = _this.state.open;
167
145
 
168
- _this.props.onClick(evt);
169
- }
146
+ _this.closeMenu(function () {
147
+ if (wasOpen) {
148
+ _this.focusMenuEl();
149
+ }
150
+ });
170
151
  });
171
152
 
172
153
  _rollupPluginBabelHelpers.defineProperty(_rollupPluginBabelHelpers.assertThisInitialized(_this), "handleKeyPress", function (evt) {
@@ -176,13 +157,7 @@ var OverflowMenu = /*#__PURE__*/function (_Component) {
176
157
 
177
158
 
178
159
  if (match.matches(evt, [keys.Escape])) {
179
- var wasOpen = _this.state.open;
180
-
181
- _this.closeMenu(function () {
182
- if (wasOpen) {
183
- _this.focusMenuEl();
184
- }
185
- }); // Stop the esc keypress from bubbling out and closing something it shouldn't
160
+ _this.closeMenuAndFocus(); // Stop the esc keypress from bubbling out and closing something it shouldn't
186
161
 
187
162
 
188
163
  evt.stopPropagation();
@@ -217,8 +192,6 @@ var OverflowMenu = /*#__PURE__*/function (_Component) {
217
192
  });
218
193
 
219
194
  _rollupPluginBabelHelpers.defineProperty(_rollupPluginBabelHelpers.assertThisInitialized(_this), "handleOverflowMenuItemFocus", function (_ref) {
220
- var _overflowMenuItem$cur;
221
-
222
195
  var currentIndex = _ref.currentIndex,
223
196
  direction = _ref.direction;
224
197
  var enabledIndices = React__default["default"].Children.toArray(_this.props.children).reduce(function (acc, curr, i) {
@@ -232,7 +205,7 @@ var OverflowMenu = /*#__PURE__*/function (_Component) {
232
205
  var nextValidIndex = function () {
233
206
  var nextIndex = enabledIndices.indexOf(currentIndex) + direction;
234
207
 
235
- switch (enabledIndices.indexOf(currentIndex) + direction) {
208
+ switch (nextIndex) {
236
209
  case -1:
237
210
  return enabledIndices.length - 1;
238
211
 
@@ -244,9 +217,9 @@ var OverflowMenu = /*#__PURE__*/function (_Component) {
244
217
  }
245
218
  }();
246
219
 
247
- var overflowMenuItem = _this["overflowMenuItem".concat(enabledIndices[nextValidIndex])].overflowMenuItem;
220
+ var overflowMenuItem = _this["overflowMenuItem".concat(enabledIndices[nextValidIndex])];
248
221
 
249
- overflowMenuItem === null || overflowMenuItem === void 0 ? void 0 : (_overflowMenuItem$cur = overflowMenuItem.current) === null || _overflowMenuItem$cur === void 0 ? void 0 : _overflowMenuItem$cur.focus();
222
+ overflowMenuItem === null || overflowMenuItem === void 0 ? void 0 : overflowMenuItem.focus();
250
223
  });
251
224
 
252
225
  _rollupPluginBabelHelpers.defineProperty(_rollupPluginBabelHelpers.assertThisInitialized(_this), "_bindMenuBody", function (menuBody) {
@@ -270,7 +243,7 @@ var OverflowMenu = /*#__PURE__*/function (_Component) {
270
243
 
271
244
  if (typeof target.matches === 'function') {
272
245
  if (!menuBody.contains(target) && triggerEl && !target.matches(".".concat(_this.context, "--overflow-menu,.").concat(_this.context, "--overflow-menu-options"))) {
273
- _this.closeMenu();
246
+ _this.closeMenuAndFocus();
274
247
  }
275
248
  }
276
249
  }, !hasFocusin);
@@ -354,7 +327,7 @@ var OverflowMenu = /*#__PURE__*/function (_Component) {
354
327
  var _child$props;
355
328
 
356
329
  return /*#__PURE__*/React__default["default"].cloneElement(child, {
357
- closeMenu: (child === null || child === void 0 ? void 0 : (_child$props = child.props) === null || _child$props === void 0 ? void 0 : _child$props.closeMenu) || _this2.closeMenu,
330
+ closeMenu: (child === null || child === void 0 ? void 0 : (_child$props = child.props) === null || _child$props === void 0 ? void 0 : _child$props.closeMenu) || _this2.closeMenuAndFocus,
358
331
  handleOverflowMenuItemFocus: _this2.handleOverflowMenuItemFocus,
359
332
  ref: function ref(e) {
360
333
  _this2["overflowMenuItem".concat(index)] = e;
@@ -366,7 +339,8 @@ var OverflowMenu = /*#__PURE__*/function (_Component) {
366
339
  className: overflowMenuOptionsClasses,
367
340
  tabIndex: "-1",
368
341
  role: "menu",
369
- "aria-label": ariaLabel
342
+ "aria-label": ariaLabel,
343
+ onKeyDown: this.handleKeyPress
370
344
  }, childrenWithProps);
371
345
  var wrappedMenuBody = /*#__PURE__*/React__default["default"].createElement(FloatingMenu["default"], {
372
346
  focusTrap: focusTrap,
@@ -387,17 +361,18 @@ var OverflowMenu = /*#__PURE__*/function (_Component) {
387
361
  };
388
362
  return /*#__PURE__*/React__default["default"].createElement(ClickListener["default"], {
389
363
  onClickOutside: this.handleClickOutside
390
- }, /*#__PURE__*/React__default["default"].createElement("button", _rollupPluginBabelHelpers["extends"]({}, other, {
364
+ }, /*#__PURE__*/React__default["default"].createElement("span", {
365
+ className: "".concat(prefix, "--overflow-menu__wrapper")
366
+ }, /*#__PURE__*/React__default["default"].createElement(index.IconButton, _rollupPluginBabelHelpers["extends"]({}, other, {
391
367
  type: "button",
392
368
  "aria-haspopup": true,
393
369
  "aria-expanded": this.state.open,
394
370
  className: overflowMenuClasses,
395
- onKeyDown: this.handleKeyPress,
396
371
  onClick: this.handleClick,
397
- "aria-label": ariaLabel,
398
372
  id: id,
399
- ref: mergeRefs["default"](this._triggerRef, ref)
400
- }), /*#__PURE__*/React__default["default"].createElement(IconElement, iconProps), open && this.state.hasMountedTrigger && wrappedMenuBody));
373
+ ref: mergeRefs["default"](this._triggerRef, ref),
374
+ label: iconDescription
375
+ }), /*#__PURE__*/React__default["default"].createElement(IconElement, iconProps)), open && this.state.hasMountedTrigger && wrappedMenuBody));
401
376
  }
402
377
  }], [{
403
378
  key: "getDerivedStateFromProps",
@@ -418,7 +393,7 @@ _rollupPluginBabelHelpers.defineProperty(OverflowMenu, "propTypes", {
418
393
  /**
419
394
  * The ARIA label.
420
395
  */
421
- ariaLabel: FeatureFlags__namespace.enabled('enable-v11-release') ? PropTypes__default["default"].string.isRequired : PropTypes__default["default"].string,
396
+ ariaLabel: PropTypes__default["default"].string.isRequired,
422
397
 
423
398
  /**
424
399
  * The child nodes.
@@ -464,7 +439,7 @@ _rollupPluginBabelHelpers.defineProperty(OverflowMenu, "propTypes", {
464
439
  * `true` to use the light version. For use on $ui-01 backgrounds only.
465
440
  * Don't use this to make OverflowMenu background color same as container background color.
466
441
  */
467
- light: FeatureFlags__namespace.enabled('enable-v11-release') ? deprecate["default"](PropTypes__default["default"].bool, 'The `light` prop for `OverflowMenu` is no longer needed and has been deprecated. It will be removed in the next major release. Use the Layer component instead.') : PropTypes__default["default"].bool,
442
+ light: deprecate["default"](PropTypes__default["default"].bool, 'The `light` prop for `OverflowMenu` is no longer needed and has been deprecated. It will be removed in the next major release. Use the Layer component instead.'),
468
443
 
469
444
  /**
470
445
  * The adjustment in position applied to the floating menu.
@@ -531,14 +506,14 @@ _rollupPluginBabelHelpers.defineProperty(OverflowMenu, "propTypes", {
531
506
  /**
532
507
  * Specify the size of the OverflowMenu. Currently supports either `sm`, 'md' (default) or 'lg` as an option.
533
508
  */
534
- size: FeatureFlags__namespace.enabled('enable-v11-release') ? PropTypes__default["default"].oneOf(['sm', 'md', 'lg']) : PropTypes__default["default"].oneOf(['sm', 'md', 'lg', 'xl'])
509
+ size: PropTypes__default["default"].oneOf(['sm', 'md', 'lg'])
535
510
  });
536
511
 
537
512
  _rollupPluginBabelHelpers.defineProperty(OverflowMenu, "contextType", usePrefix.PrefixContext);
538
513
 
539
514
  _rollupPluginBabelHelpers.defineProperty(OverflowMenu, "defaultProps", {
540
- ariaLabel: FeatureFlags__namespace.enabled('enable-v11-release') ? null : 'Open and close list of options',
541
- iconDescription: 'Open and close list of options',
515
+ ariaLabel: null,
516
+ iconDescription: 'Options',
542
517
  open: false,
543
518
  direction: FloatingMenu.DIRECTION_BOTTOM,
544
519
  flipped: false,
@@ -15,6 +15,7 @@ var cx = require('classnames');
15
15
  var PropTypes = require('prop-types');
16
16
  var React = require('react');
17
17
  var Select = require('../Select/Select.js');
18
+ require('../Select/Select.Skeleton.js');
18
19
  var SelectItem = require('../SelectItem/SelectItem.js');
19
20
  var array = require('../../tools/array.js');
20
21
  var useId = require('../../internal/useId.js');
@@ -15,6 +15,7 @@ var PropTypes = require('prop-types');
15
15
  var cx = require('classnames');
16
16
  var setupGetInstanceId = require('../../../tools/setupGetInstanceId.js');
17
17
  var Select = require('../../Select/Select.js');
18
+ require('../../Select/Select.Skeleton.js');
18
19
  var SelectItem = require('../../SelectItem/SelectItem.js');
19
20
  var usePrefix = require('../../../internal/usePrefix.js');
20
21
 
@@ -16,6 +16,7 @@ var cx = require('classnames');
16
16
  var iconsReact = require('@carbon/icons-react');
17
17
  var Button = require('../../Button/Button.js');
18
18
  var Select = require('../../Select/Select.js');
19
+ require('../../Select/Select.Skeleton.js');
19
20
  var SelectItem = require('../../SelectItem/SelectItem.js');
20
21
  var index = require('../../IconButton/index.js');
21
22
  var FeatureFlags = require('@carbon/feature-flags');
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Copyright IBM Corp. 2016, 2018
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
+ import PropTypes from 'prop-types';
8
+ import { HTMLAttributes } from 'react';
9
+ export interface SelectSkeletonProps extends HTMLAttributes<HTMLDivElement> {
10
+ /**
11
+ * Specify an optional className to add to the form item wrapper.
12
+ */
13
+ className?: string;
14
+ /**
15
+ * Specify whether the label should be hidden, or not
16
+ */
17
+ hideLabel?: boolean;
18
+ }
19
+ declare const SelectSkeleton: {
20
+ ({ hideLabel, className, ...rest }: SelectSkeletonProps): JSX.Element;
21
+ propTypes: {
22
+ /**
23
+ * Specify an optional className to add to the form item wrapper.
24
+ */
25
+ className: PropTypes.Requireable<string>;
26
+ /**
27
+ * Specify whether the label should be hidden, or not
28
+ */
29
+ hideLabel: PropTypes.Requireable<boolean>;
30
+ };
31
+ };
32
+ export default SelectSkeleton;
33
+ export { SelectSkeleton };
@@ -10,8 +10,10 @@
10
10
  Object.defineProperty(exports, '__esModule', { value: true });
11
11
 
12
12
  var Select = require('./Select.js');
13
+ var Select_Skeleton = require('./Select.Skeleton.js');
13
14
 
14
15
 
15
16
 
16
17
  exports.Select = Select["default"];
17
18
  exports["default"] = Select["default"];
19
+ exports.SelectSkeleton = Select_Skeleton["default"];
@@ -27,7 +27,7 @@ var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
27
27
  var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
28
28
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
29
29
 
30
- var _excluded = ["align", "className", "children", "label", "description", "enterDelayMs", "leaveDelayMs", "defaultOpen"];
30
+ var _excluded = ["align", "className", "children", "label", "description", "enterDelayMs", "leaveDelayMs", "defaultOpen", "closeOnActivation"];
31
31
 
32
32
  function Tooltip(_ref) {
33
33
  var _ref$align = _ref.align,
@@ -42,6 +42,8 @@ function Tooltip(_ref) {
42
42
  leaveDelayMs = _ref$leaveDelayMs === void 0 ? 300 : _ref$leaveDelayMs,
43
43
  _ref$defaultOpen = _ref.defaultOpen,
44
44
  defaultOpen = _ref$defaultOpen === void 0 ? false : _ref$defaultOpen,
45
+ _ref$closeOnActivatio = _ref.closeOnActivation,
46
+ closeOnActivation = _ref$closeOnActivatio === void 0 ? false : _ref$closeOnActivatio,
45
47
  rest = _rollupPluginBabelHelpers.objectWithoutProperties(_ref, _excluded);
46
48
 
47
49
  var containerRef = React.useRef(null);
@@ -62,10 +64,28 @@ function Tooltip(_ref) {
62
64
  onBlur: function onBlur() {
63
65
  return setOpen(false);
64
66
  },
67
+ onClick: function onClick() {
68
+ return closeOnActivation && setOpen(false);
69
+ },
65
70
  // This should be placed on the trigger in case the element is disabled
66
71
  onMouseEnter: onMouseEnter
67
72
  };
68
73
 
74
+ function getChildEventHandlers(childProps) {
75
+ var eventHandlerFunctions = ['onFocus', 'onBlur', 'onClick', 'onMouseEnter'];
76
+ var eventHandlers = {};
77
+ eventHandlerFunctions.forEach(function (functionName) {
78
+ eventHandlers[functionName] = function (evt) {
79
+ triggerProps[functionName]();
80
+
81
+ if (childProps !== null && childProps !== void 0 && childProps[functionName]) {
82
+ childProps === null || childProps === void 0 ? void 0 : childProps[functionName](evt);
83
+ }
84
+ };
85
+ });
86
+ return eventHandlers;
87
+ }
88
+
69
89
  if (label) {
70
90
  triggerProps['aria-labelledby'] = id;
71
91
  } else {
@@ -77,6 +97,10 @@ function Tooltip(_ref) {
77
97
  event.stopPropagation();
78
98
  setOpen(false);
79
99
  }
100
+
101
+ if (open && closeOnActivation && (match.match(event, keys.Enter) || match.match(event, keys.Space))) {
102
+ setOpen(false);
103
+ }
80
104
  }
81
105
 
82
106
  function onMouseEnter() {
@@ -104,7 +128,7 @@ function Tooltip(_ref) {
104
128
  onMouseLeave: onMouseLeave,
105
129
  open: open,
106
130
  ref: containerRef
107
- }), /*#__PURE__*/React__default["default"].cloneElement(child, triggerProps), /*#__PURE__*/React__default["default"].createElement(index.PopoverContent, {
131
+ }), /*#__PURE__*/React__default["default"].cloneElement(child, _rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, triggerProps), getChildEventHandlers(child.props))), /*#__PURE__*/React__default["default"].createElement(index.PopoverContent, {
108
132
  "aria-hidden": "true",
109
133
  className: "".concat(prefix, "--tooltip-content"),
110
134
  id: id,
@@ -129,6 +153,11 @@ Tooltip.propTypes = {
129
153
  */
130
154
  className: PropTypes__default["default"].string,
131
155
 
156
+ /**
157
+ * Determines wether the tooltip should close when inner content is activated (click, Enter or Space)
158
+ */
159
+ closeOnActivation: PropTypes__default["default"].bool,
160
+
132
161
  /**
133
162
  * Specify whether the tooltip should be open when it first renders
134
163
  */
File without changes
@@ -277,10 +277,7 @@ var FloatingMenu = /*#__PURE__*/function (_React$Component) {
277
277
  tabbableNode || // First sequentially focusable node
278
278
  focusableNode || // First programmatic focusable node
279
279
  menuBody;
280
-
281
- if (_this.props.focusTrap) {
282
- focusTarget.focus();
283
- }
280
+ focusTarget.focus();
284
281
 
285
282
  if (focusTarget === menuBody && process.env.NODE_ENV !== "production") {
286
283
  process.env.NODE_ENV !== "production" ? warning.warning(focusableNode === null, 'Floating Menus must have at least a programmatically focusable child. ' + 'This can be accomplished by adding tabIndex="-1" to the content element.') : void 0;
File without changes
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.22.0-rc.0",
4
+ "version": "1.22.0",
5
5
  "license": "Apache-2.0",
6
6
  "main": "lib/index.js",
7
7
  "module": "es/index.js",
@@ -44,9 +44,9 @@
44
44
  "dependencies": {
45
45
  "@babel/runtime": "^7.18.3",
46
46
  "@carbon/feature-flags": "^0.12.0",
47
- "@carbon/icons-react": "^11.16.0-rc.0",
47
+ "@carbon/icons-react": "^11.16.0",
48
48
  "@carbon/layout": "^11.11.0",
49
- "@carbon/styles": "^1.22.0-rc.0",
49
+ "@carbon/styles": "^1.22.0",
50
50
  "@carbon/telemetry": "0.1.0",
51
51
  "classnames": "2.3.2",
52
52
  "copy-to-clipboard": "^3.3.1",
@@ -135,5 +135,5 @@
135
135
  "**/*.scss",
136
136
  "**/*.css"
137
137
  ],
138
- "gitHead": "3e7357ecc2ee754a8d5a2c23c1082d5cdd425faa"
138
+ "gitHead": "f4c904ce641392046ad21e6c77394a53f6cf0f30"
139
139
  }