@carbon/ibm-products 1.61.1 → 1.62.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (123) hide show
  1. package/css/index-full-carbon.css +156 -68
  2. package/css/index-full-carbon.css.map +1 -1
  3. package/css/index-full-carbon.min.css +3 -3
  4. package/css/index-full-carbon.min.css.map +1 -1
  5. package/css/index-without-carbon-released-only.css +1753 -0
  6. package/css/index-without-carbon-released-only.css.map +1 -1
  7. package/css/index-without-carbon-released-only.min.css +3 -1
  8. package/css/index-without-carbon-released-only.min.css.map +1 -1
  9. package/css/index-without-carbon.css +156 -68
  10. package/css/index-without-carbon.css.map +1 -1
  11. package/css/index-without-carbon.min.css +3 -3
  12. package/css/index-without-carbon.min.css.map +1 -1
  13. package/css/index.css +156 -68
  14. package/css/index.css.map +1 -1
  15. package/css/index.min.css +3 -3
  16. package/css/index.min.css.map +1 -1
  17. package/es/components/Coachmark/Coachmark.js +17 -5
  18. package/es/components/Coachmark/CoachmarkDragbar.js +12 -5
  19. package/es/components/Coachmark/CoachmarkHeader.js +2 -1
  20. package/es/components/Coachmark/CoachmarkOverlay.js +105 -9
  21. package/es/components/CoachmarkBeacon/CoachmarkBeacon.js +5 -2
  22. package/es/components/CoachmarkFixed/CoachmarkFixed.js +26 -6
  23. package/es/components/CoachmarkOverlayElements/CoachmarkOverlayElements.js +28 -3
  24. package/es/components/CoachmarkStack/CoachmarkStack.js +19 -4
  25. package/es/components/CoachmarkStack/CoachmarkStackHome.js +45 -11
  26. package/es/components/Datagrid/Datagrid/DatagridContent.js +12 -9
  27. package/es/components/Datagrid/Datagrid/DatagridExpandedRow.js +4 -4
  28. package/es/components/Datagrid/Datagrid/DatagridHeaderRow.js +41 -25
  29. package/es/components/Datagrid/Datagrid/DatagridRefBody.js +4 -1
  30. package/es/components/Datagrid/Datagrid/DatagridRow.js +5 -2
  31. package/es/components/Datagrid/Datagrid/DatagridSelectAll.js +12 -11
  32. package/es/components/Datagrid/Datagrid/DatagridSimpleBody.js +4 -1
  33. package/es/components/Datagrid/Datagrid/DatagridToolbar.js +29 -23
  34. package/es/components/Datagrid/Datagrid/DatagridVirtualBody.js +18 -18
  35. package/es/components/Datagrid/Datagrid/addons/stateReducer.js +50 -14
  36. package/es/components/Datagrid/Datagrid.stories/StickyActionsColumnStory.js +1 -1
  37. package/es/components/Datagrid/useActionsColumn.js +9 -9
  38. package/es/components/Datagrid/useDatagrid.js +13 -1
  39. package/es/components/Datagrid/useFlexResize.js +19 -9
  40. package/es/components/Datagrid/useInfiniteScroll.js +10 -9
  41. package/es/components/Datagrid/useOnRowClick.js +6 -7
  42. package/es/components/Datagrid/useParentDimensions.js +6 -6
  43. package/es/components/Datagrid/useResizeTable.js +7 -7
  44. package/es/components/Datagrid/useSelectAllToggle.js +2 -2
  45. package/es/components/Datagrid/useSelectRows.js +31 -21
  46. package/es/components/Datagrid/useSkeletonRows.js +6 -6
  47. package/es/components/Datagrid/useSortableColumns.js +4 -5
  48. package/es/components/Datagrid/useStickyColumn.js +13 -6
  49. package/es/components/EmptyStates/ErrorEmptyState/ErrorEmptyState.js +1 -0
  50. package/es/components/EmptyStates/NoDataEmptyState/NoDataEmptyState.js +1 -0
  51. package/es/components/EmptyStates/NoTagsEmptyState/NoTagsEmptyState.js +1 -0
  52. package/es/components/EmptyStates/NotFoundEmptyState/NotFoundEmptyState.js +1 -0
  53. package/es/components/EmptyStates/NotificationsEmptyState/NotificationsEmptyState.js +1 -0
  54. package/es/components/EmptyStates/UnauthorizedEmptyState/UnauthorizedEmptyState.js +1 -0
  55. package/es/components/EmptyStates/assets/ErrorIllustration.js +6 -4
  56. package/es/components/EmptyStates/assets/NoDataIllustration.js +6 -4
  57. package/es/components/EmptyStates/assets/NoTagsIllustration.js +6 -4
  58. package/es/components/EmptyStates/assets/NotFoundIllustration.js +6 -4
  59. package/es/components/EmptyStates/assets/NotificationsIllustration.js +6 -4
  60. package/es/components/EmptyStates/assets/UnauthorizedIllustration.js +6 -4
  61. package/es/global/js/hooks/index.js +3 -2
  62. package/es/global/js/hooks/usePrefix.js +11 -0
  63. package/es/global/js/package-settings.js +1 -2
  64. package/lib/components/Coachmark/Coachmark.js +16 -4
  65. package/lib/components/Coachmark/CoachmarkDragbar.js +12 -5
  66. package/lib/components/Coachmark/CoachmarkHeader.js +2 -1
  67. package/lib/components/Coachmark/CoachmarkOverlay.js +105 -8
  68. package/lib/components/CoachmarkBeacon/CoachmarkBeacon.js +5 -2
  69. package/lib/components/CoachmarkFixed/CoachmarkFixed.js +25 -5
  70. package/lib/components/CoachmarkOverlayElements/CoachmarkOverlayElements.js +28 -3
  71. package/lib/components/CoachmarkStack/CoachmarkStack.js +18 -3
  72. package/lib/components/CoachmarkStack/CoachmarkStackHome.js +44 -10
  73. package/lib/components/Datagrid/Datagrid/DatagridContent.js +12 -9
  74. package/lib/components/Datagrid/Datagrid/DatagridExpandedRow.js +4 -4
  75. package/lib/components/Datagrid/Datagrid/DatagridHeaderRow.js +41 -32
  76. package/lib/components/Datagrid/Datagrid/DatagridRefBody.js +4 -1
  77. package/lib/components/Datagrid/Datagrid/DatagridRow.js +5 -2
  78. package/lib/components/Datagrid/Datagrid/DatagridSelectAll.js +6 -4
  79. package/lib/components/Datagrid/Datagrid/DatagridSimpleBody.js +4 -1
  80. package/lib/components/Datagrid/Datagrid/DatagridToolbar.js +29 -23
  81. package/lib/components/Datagrid/Datagrid/DatagridVirtualBody.js +12 -12
  82. package/lib/components/Datagrid/Datagrid/addons/stateReducer.js +52 -15
  83. package/lib/components/Datagrid/Datagrid.stories/StickyActionsColumnStory.js +1 -1
  84. package/lib/components/Datagrid/useActionsColumn.js +9 -12
  85. package/lib/components/Datagrid/useDatagrid.js +13 -1
  86. package/lib/components/Datagrid/useFlexResize.js +19 -9
  87. package/lib/components/Datagrid/useInfiniteScroll.js +9 -9
  88. package/lib/components/Datagrid/useOnRowClick.js +6 -7
  89. package/lib/components/Datagrid/useParentDimensions.js +5 -6
  90. package/lib/components/Datagrid/useResizeTable.js +6 -7
  91. package/lib/components/Datagrid/useSelectAllToggle.js +2 -2
  92. package/lib/components/Datagrid/useSelectRows.js +31 -21
  93. package/lib/components/Datagrid/useSkeletonRows.js +6 -6
  94. package/lib/components/Datagrid/useSortableColumns.js +4 -5
  95. package/lib/components/Datagrid/useStickyColumn.js +8 -0
  96. package/lib/components/EmptyStates/ErrorEmptyState/ErrorEmptyState.js +1 -0
  97. package/lib/components/EmptyStates/NoDataEmptyState/NoDataEmptyState.js +1 -0
  98. package/lib/components/EmptyStates/NoTagsEmptyState/NoTagsEmptyState.js +1 -0
  99. package/lib/components/EmptyStates/NotFoundEmptyState/NotFoundEmptyState.js +1 -0
  100. package/lib/components/EmptyStates/NotificationsEmptyState/NotificationsEmptyState.js +1 -0
  101. package/lib/components/EmptyStates/UnauthorizedEmptyState/UnauthorizedEmptyState.js +1 -0
  102. package/lib/components/EmptyStates/assets/ErrorIllustration.js +6 -4
  103. package/lib/components/EmptyStates/assets/NoDataIllustration.js +6 -4
  104. package/lib/components/EmptyStates/assets/NoTagsIllustration.js +6 -4
  105. package/lib/components/EmptyStates/assets/NotFoundIllustration.js +6 -4
  106. package/lib/components/EmptyStates/assets/NotificationsIllustration.js +6 -4
  107. package/lib/components/EmptyStates/assets/UnauthorizedIllustration.js +6 -4
  108. package/lib/global/js/hooks/index.js +8 -1
  109. package/lib/global/js/hooks/usePrefix.js +19 -0
  110. package/lib/global/js/package-settings.js +1 -2
  111. package/package.json +2 -2
  112. package/scss/components/Checklist/_checklist.scss +13 -25
  113. package/scss/components/Coachmark/styles/_coachmark-dragbar.scss +1 -45
  114. package/scss/components/Coachmark/styles/_coachmark-header.scss +0 -33
  115. package/scss/components/Coachmark/styles/_coachmark-overlay.scss +113 -5
  116. package/scss/components/Coachmark/styles/_coachmark-tagline.scss +18 -0
  117. package/scss/components/CoachmarkBeacon/_coachmark-beacon.scss +19 -1
  118. package/scss/components/CoachmarkOverlayElement/_coachmark-overlay-element.scss +2 -0
  119. package/scss/components/CoachmarkOverlayElements/_coachmark-overlay-elements.scss +1 -0
  120. package/scss/components/CoachmarkStack/_coachmark-stack.scss +3 -0
  121. package/scss/components/Datagrid/styles/_datagrid.scss +31 -5
  122. package/scss/components/Datagrid/styles/_useNestedRows.scss +1 -1
  123. package/scss/components/_index-released-only.scss +1 -0
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
- var _excluded = ["theme", "size"];
3
+ var _excluded = ["title", "theme", "size"];
4
4
  /**
5
5
  * Copyright IBM Corp. 2020, 2021
6
6
  *
@@ -20,7 +20,8 @@ import uuidv4 from '../../../global/js/utils/uuidv4';
20
20
  // The block part of our conventional BEM class names (blockClass__E--M).
21
21
  var blockClass = "".concat(pkg.prefix, "--empty-state");
22
22
  export var NoTagsIllustration = function NoTagsIllustration(_ref) {
23
- var theme = _ref.theme,
23
+ var title = _ref.title,
24
+ theme = _ref.theme,
24
25
  size = _ref.size,
25
26
  rest = _objectWithoutProperties(_ref, _excluded);
26
27
  var svgId = uuidv4();
@@ -32,7 +33,7 @@ export var NoTagsIllustration = function NoTagsIllustration(_ref) {
32
33
  viewBox: "0 0 80 80",
33
34
  className: cx(["".concat(blockClass, "__illustration"), "".concat(blockClass, "__illustration-noTags"), "".concat(blockClass, "__illustration--").concat(size)]),
34
35
  role: "img"
35
- }), theme === 'dark' ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("defs", null, /*#__PURE__*/React.createElement("linearGradient", {
36
+ }), /*#__PURE__*/React.createElement("title", null, title), theme === 'dark' ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("defs", null, /*#__PURE__*/React.createElement("linearGradient", {
36
37
  id: "prefix__c_dark_".concat(svgId),
37
38
  x1: 34.96,
38
39
  y1: 5.37,
@@ -479,5 +480,6 @@ export var NoTagsIllustration = function NoTagsIllustration(_ref) {
479
480
  };
480
481
  NoTagsIllustration.propTypes = {
481
482
  size: PropTypes.oneOf(['lg', 'sm']),
482
- theme: PropTypes.oneOf(['light', 'dark'])
483
+ theme: PropTypes.oneOf(['light', 'dark']),
484
+ title: PropTypes.string
483
485
  };
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
- var _excluded = ["theme", "size"];
3
+ var _excluded = ["title", "theme", "size"];
4
4
  /**
5
5
  * Copyright IBM Corp. 2020, 2021
6
6
  *
@@ -20,7 +20,8 @@ import uuidv4 from '../../../global/js/utils/uuidv4';
20
20
  // The block part of our conventional BEM class names (blockClass__E--M).
21
21
  var blockClass = "".concat(pkg.prefix, "--empty-state");
22
22
  export var NotFoundIllustration = function NotFoundIllustration(_ref) {
23
- var theme = _ref.theme,
23
+ var title = _ref.title,
24
+ theme = _ref.theme,
24
25
  size = _ref.size,
25
26
  rest = _objectWithoutProperties(_ref, _excluded);
26
27
  var svgId = uuidv4();
@@ -31,7 +32,7 @@ export var NotFoundIllustration = function NotFoundIllustration(_ref) {
31
32
  viewBox: "0 0 80 80",
32
33
  className: cx(["".concat(blockClass, "__illustration"), "".concat(blockClass, "__illustration-notFound"), "".concat(blockClass, "__illustration--").concat(size)]),
33
34
  role: "img"
34
- }), theme === 'dark' ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("defs", null, /*#__PURE__*/React.createElement("linearGradient", {
35
+ }), /*#__PURE__*/React.createElement("title", null, title), theme === 'dark' ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("defs", null, /*#__PURE__*/React.createElement("linearGradient", {
35
36
  id: "prefix__a_dark_".concat(svgId),
36
37
  x1: 2.6,
37
38
  y1: -12.81,
@@ -356,5 +357,6 @@ export var NotFoundIllustration = function NotFoundIllustration(_ref) {
356
357
  };
357
358
  NotFoundIllustration.propTypes = {
358
359
  size: PropTypes.oneOf(['lg', 'sm']),
359
- theme: PropTypes.oneOf(['light', 'dark'])
360
+ theme: PropTypes.oneOf(['light', 'dark']),
361
+ title: PropTypes.string
360
362
  };
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
- var _excluded = ["theme", "size"];
3
+ var _excluded = ["title", "theme", "size"];
4
4
  /**
5
5
  * Copyright IBM Corp. 2020, 2021
6
6
  *
@@ -20,7 +20,8 @@ import uuidv4 from '../../../global/js/utils/uuidv4';
20
20
  // The block part of our conventional BEM class names (blockClass__E--M).
21
21
  var blockClass = "".concat(pkg.prefix, "--empty-state");
22
22
  export var NotificationsIllustration = function NotificationsIllustration(_ref) {
23
- var theme = _ref.theme,
23
+ var title = _ref.title,
24
+ theme = _ref.theme,
24
25
  size = _ref.size,
25
26
  rest = _objectWithoutProperties(_ref, _excluded);
26
27
  var svgId = uuidv4();
@@ -31,7 +32,7 @@ export var NotificationsIllustration = function NotificationsIllustration(_ref)
31
32
  viewBox: "0 0 80 80",
32
33
  className: cx(["".concat(blockClass, "__illustration"), "".concat(blockClass, "__illustration-notification"), "".concat(blockClass, "__illustration--").concat(size)]),
33
34
  role: "img"
34
- }), theme === 'dark' ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("defs", null, /*#__PURE__*/React.createElement("linearGradient", {
35
+ }), /*#__PURE__*/React.createElement("title", null, title), theme === 'dark' ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("defs", null, /*#__PURE__*/React.createElement("linearGradient", {
35
36
  id: "prefix__a_dark_".concat(svgId),
36
37
  x1: 30.05,
37
38
  y1: 54.31,
@@ -327,5 +328,6 @@ export var NotificationsIllustration = function NotificationsIllustration(_ref)
327
328
  };
328
329
  NotificationsIllustration.propTypes = {
329
330
  size: PropTypes.oneOf(['lg', 'sm']),
330
- theme: PropTypes.oneOf(['light', 'dark'])
331
+ theme: PropTypes.oneOf(['light', 'dark']),
332
+ title: PropTypes.string
331
333
  };
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
- var _excluded = ["theme", "size"];
3
+ var _excluded = ["title", "theme", "size"];
4
4
  /**
5
5
  * Copyright IBM Corp. 2020, 2021
6
6
  *
@@ -20,7 +20,8 @@ import uuidv4 from '../../../global/js/utils/uuidv4';
20
20
  // The block part of our conventional BEM class names (blockClass__E--M).
21
21
  var blockClass = "".concat(pkg.prefix, "--empty-state");
22
22
  export var UnauthorizedIllustration = function UnauthorizedIllustration(_ref) {
23
- var theme = _ref.theme,
23
+ var title = _ref.title,
24
+ theme = _ref.theme,
24
25
  size = _ref.size,
25
26
  rest = _objectWithoutProperties(_ref, _excluded);
26
27
  var svgId = uuidv4();
@@ -32,7 +33,7 @@ export var UnauthorizedIllustration = function UnauthorizedIllustration(_ref) {
32
33
  viewBox: "0 0 80 80",
33
34
  className: cx(["".concat(blockClass, "__illustration"), "".concat(blockClass, "__illustration-unauthorized"), "".concat(blockClass, "__illustration--").concat(size)]),
34
35
  role: "img"
35
- }), theme === 'dark' ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("defs", null, /*#__PURE__*/React.createElement("linearGradient", {
36
+ }), /*#__PURE__*/React.createElement("title", null, title), theme === 'dark' ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("defs", null, /*#__PURE__*/React.createElement("linearGradient", {
36
37
  id: "prefix__b_dark_".concat(svgId),
37
38
  x1: 17.33,
38
39
  y1: 40.68,
@@ -300,5 +301,6 @@ export var UnauthorizedIllustration = function UnauthorizedIllustration(_ref) {
300
301
  };
301
302
  UnauthorizedIllustration.propTypes = {
302
303
  size: PropTypes.oneOf(['lg', 'sm']),
303
- theme: PropTypes.oneOf(['light', 'dark'])
304
+ theme: PropTypes.oneOf(['light', 'dark']),
305
+ title: PropTypes.string
304
306
  };
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright IBM Corp. 2020, 2021
2
+ * Copyright IBM Corp. 2020, 2023
3
3
  *
4
4
  * This source code is licensed under the Apache-2.0 license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -15,4 +15,5 @@ export { usePreviousValue } from './usePreviousValue';
15
15
  export { useResetCreateComponent } from './useResetCreateComponent';
16
16
  export { useRetrieveStepData } from './useRetrieveStepData';
17
17
  export { useValidCreateStepCount } from './useValidCreateStepCount';
18
- export { useControllableState } from './useControllableState';
18
+ export { useControllableState } from './useControllableState';
19
+ export { usePrefix } from './usePrefix';
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Copyright IBM Corp. 2023, 2023
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 pkg from '../package-settings';
9
+ export var usePrefix = function usePrefix() {
10
+ return pkg.prefix;
11
+ };
@@ -25,6 +25,7 @@ var defaults = {
25
25
  CreateTearsheet: true,
26
26
  CreateTearsheetStep: true,
27
27
  CreateTearsheetDivider: true,
28
+ Datagrid: true,
28
29
  EditInPlace: true,
29
30
  EmptyState: true,
30
31
  ErrorEmptyState: true,
@@ -65,7 +66,6 @@ var defaults = {
65
66
  EditSidePanel: false,
66
67
  CancelableTextEdit: false,
67
68
  DataSpreadsheet: false,
68
- Datagrid: false,
69
69
  EditTearsheet: false,
70
70
  EditTearsheetNarrow: false,
71
71
  EditFullPage: false,
@@ -98,7 +98,6 @@ var defaults = {
98
98
  'Datagrid.useExpandedRow': false,
99
99
  'Datagrid.useNestedRows': false,
100
100
  'Datagrid.useInlineEdit': false,
101
- 'Datagrid.useActionsColumn': false,
102
101
  'Datagrid.useFiltering': false,
103
102
  'Datagrid.useCustomizeColumns': false,
104
103
  'ExampleComponent.secondaryIcon': false,
@@ -25,6 +25,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
25
25
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
26
26
  // The block part of our conventional BEM class names (blockClass__E--M).
27
27
  var blockClass = "".concat(_settings.pkg.prefix, "--coachmark");
28
+ var overlayBlockClass = "".concat(blockClass, "-overlay");
28
29
  var componentName = 'Coachmark';
29
30
  var defaults = {
30
31
  align: 'bottom',
@@ -86,7 +87,18 @@ var Coachmark = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
86
87
  var closeOverlay = function closeOverlay() {
87
88
  setIsOpen(false);
88
89
  };
89
- var handleClose = function handleClose() {
90
+ var escFunction = (0, _react.useCallback)(function (event) {
91
+ if (event.key === 'Escape') {
92
+ handleClose();
93
+ }
94
+ }, [handleClose]);
95
+ (0, _react.useEffect)(function () {
96
+ document.addEventListener('keydown', escFunction, false);
97
+ return function () {
98
+ document.removeEventListener('keydown', escFunction, false);
99
+ };
100
+ }, [escFunction]);
101
+ var handleClose = (0, _react.useCallback)(function () {
90
102
  if (isStacked) {
91
103
  // If stacked, do not unmount,
92
104
  // only call its ("parent") onClose method.
@@ -95,7 +107,7 @@ var Coachmark = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
95
107
  setIsOpen(false);
96
108
  onClose();
97
109
  }
98
- };
110
+ }, [isStacked, onClose]);
99
111
  var handleTargetClick = function handleTargetClick(e) {
100
112
  setTargetRect(e.target.getBoundingClientRect());
101
113
  setTargetOffset({
@@ -116,6 +128,7 @@ var Coachmark = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
116
128
  var contextValue = {
117
129
  buttonProps: {
118
130
  'aria-expanded': isOpen,
131
+ tabIndex: 0,
119
132
  onClick: handleTargetClick,
120
133
  // Compensate for accidental open/close on double-click.
121
134
  // Only open on double-click.
@@ -167,7 +180,7 @@ var Coachmark = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
167
180
  kind: overlayKind,
168
181
  onClose: handleClose,
169
182
  theme: theme,
170
- className: overlayClassName
183
+ className: (0, _classnames.default)(overlayClassName, "".concat(overlayBlockClass, "--is-visible"))
171
184
  }, children), portalNode)));
172
185
  });
173
186
 
@@ -189,7 +202,6 @@ Coachmark.propTypes = {
189
202
  * @see COACHMARK_ALIGNMENT
190
203
  */
191
204
  align: _propTypes.default.oneOf(['bottom', 'bottom-left', 'bottom-right', 'left', 'left-top', 'left-bottom', 'right', 'right-top', 'right-bottom', 'top', 'top-left', 'top-right']),
192
- // TODO: UPDATE COMMENT HERE - UPDATE MDX TO HAVE DIRECTION TO USE ONLY OVERLAY ELEMENTS>...
193
205
  /**
194
206
  * Coachmark should use a single CoachmarkOverlayElements component as a child.
195
207
  * @see CoachmarkOverlayElements
@@ -16,7 +16,7 @@ var _iconsReact = require("@carbon/icons-react");
16
16
  var _carbonComponentsReact = require("carbon-components-react");
17
17
  var _devtools = require("../../global/js/utils/devtools");
18
18
  var _settings = require("../../settings");
19
- var _excluded = ["closeIconDescription", "onClose", "onDrag", "showCloseButton", "theme"];
19
+ var _excluded = ["a11yKeyboardHandler", "closeIconDescription", "onClose", "onDrag", "showCloseButton", "theme"];
20
20
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
21
21
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
22
22
  // Carbon and package components we use.
@@ -24,6 +24,7 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
24
24
 
25
25
  // The block part of our conventional BEM class names (blockClass__E--M).
26
26
  var blockClass = "".concat(_settings.pkg.prefix, "--coachmark-dragbar");
27
+ var overlayBlockClass = "".concat(_settings.pkg.prefix, "--coachmark-overlay");
27
28
  var componentName = 'CoachmarkDragbar';
28
29
  var defaults = {
29
30
  closeIconDescription: 'Close',
@@ -38,7 +39,8 @@ var defaults = {
38
39
  * of other Novice to Pro components.
39
40
  */
40
41
  var CoachmarkDragbar = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
41
- var _ref$closeIconDescrip = _ref.closeIconDescription,
42
+ var a11yKeyboardHandler = _ref.a11yKeyboardHandler,
43
+ _ref$closeIconDescrip = _ref.closeIconDescription,
42
44
  closeIconDescription = _ref$closeIconDescrip === void 0 ? defaults.closeIconDescription : _ref$closeIconDescrip,
43
45
  _ref$onClose = _ref.onClose,
44
46
  onClose = _ref$onClose === void 0 ? defaults.onClose : _ref$onClose,
@@ -88,15 +90,16 @@ var CoachmarkDragbar = /*#__PURE__*/_react.default.forwardRef(function (_ref, re
88
90
  // role="main"
89
91
  }, (0, _devtools.getDevtoolsProps)(componentName)), /*#__PURE__*/_react.default.createElement("button", {
90
92
  type: "button",
91
- className: "".concat(blockClass, "__handle"),
92
- onMouseDown: handleDragStart
93
+ className: "".concat(overlayBlockClass, "__handle"),
94
+ onMouseDown: handleDragStart,
95
+ onKeyDown: a11yKeyboardHandler
93
96
  }, /*#__PURE__*/_react.default.createElement(_iconsReact.Draggable16, null)), showCloseButton && /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.Button, {
94
97
  kind: "ghost",
95
98
  size: "sm",
96
99
  renderIcon: _iconsReact.Close16,
97
100
  iconDescription: closeIconDescription,
98
101
  hasIconOnly: true,
99
- className: "".concat(blockClass, "--close-btn"),
102
+ className: "".concat(overlayBlockClass, "--close-btn"),
100
103
  onClick: onClose
101
104
  }));
102
105
  });
@@ -113,6 +116,10 @@ CoachmarkDragbar.displayName = componentName;
113
116
  // in alphabetical order (for consistency).
114
117
  // See https://www.npmjs.com/package/prop-types#usage.
115
118
  CoachmarkDragbar.propTypes = {
119
+ /**
120
+ * Handler to manage keyboard interactions with the dragbar.
121
+ */
122
+ a11yKeyboardHandler: _propTypes.default.func.isRequired,
116
123
  /**
117
124
  * Tooltip text and aria label for the Close button icon.
118
125
  */
@@ -17,6 +17,7 @@ var _settings = require("../../settings");
17
17
  var _excluded = ["closeIconDescription", "onClose", "showCloseButton", "theme"];
18
18
  // The block part of our conventional BEM class names (blockClass__E--M).
19
19
  var blockClass = "".concat(_settings.pkg.prefix, "--coachmark-header");
20
+ var overlayBlockClass = "".concat(_settings.pkg.prefix, "--coachmark-overlay");
20
21
  var componentName = 'CoachmarkHeader';
21
22
  var defaults = {
22
23
  closeIconDescription: 'Close',
@@ -49,7 +50,7 @@ var CoachmarkHeader = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
49
50
  renderIcon: _iconsReact.Close16,
50
51
  iconDescription: closeIconDescription,
51
52
  hasIconOnly: true,
52
- className: "".concat(blockClass, "--close-btn"),
53
+ className: "".concat(overlayBlockClass, "--close-btn"),
53
54
  onClick: onClose
54
55
  }));
55
56
  });
@@ -7,8 +7,10 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.CoachmarkOverlay = void 0;
9
9
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
10
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
10
11
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
11
12
  var _react = _interopRequireWildcard(require("react"));
13
+ var _uuidv = _interopRequireDefault(require("../../global/js/utils/uuidv4"));
12
14
  var _propTypes = _interopRequireDefault(require("prop-types"));
13
15
  var _classnames = _interopRequireDefault(require("classnames"));
14
16
  var _devtools = require("../../global/js/utils/devtools");
@@ -46,12 +48,46 @@ var CoachmarkOverlay = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref)
46
48
  _ref$theme = _ref.theme,
47
49
  theme = _ref$theme === void 0 ? defaults.theme : _ref$theme,
48
50
  rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
51
+ var _useWindowDimensions = useWindowDimensions(),
52
+ winHeight = _useWindowDimensions.winHeight,
53
+ winWidth = _useWindowDimensions.winWidth;
54
+ var _useState = (0, _react.useState)(false),
55
+ _useState2 = (0, _slicedToArray2.default)(_useState, 2),
56
+ a11yDragMode = _useState2[0],
57
+ setA11yDragMode = _useState2[1];
49
58
  var overlayRef = (0, _react.useRef)();
50
59
  var coachmark = (0, _context.useCoachmark)();
51
60
  var isBeacon = kind === _enums.COACHMARK_OVERLAY_KIND.TOOLTIP;
52
61
  var isDraggable = kind === _enums.COACHMARK_OVERLAY_KIND.FLOATING;
62
+ var isVisible = className && className.includes('is-visible');
63
+ var handleKeyPress = function handleKeyPress(event) {
64
+ var shiftKey = event.shiftKey,
65
+ key = event.key;
66
+ if (key === 'Enter' || key === ' ') {
67
+ setA11yDragMode(function (prevVal) {
68
+ return !prevVal;
69
+ });
70
+ } else if (a11yDragMode) {
71
+ var distanceToMove = shiftKey ? 128 : 32;
72
+ switch (key) {
73
+ case 'ArrowLeft':
74
+ handleDrag(distanceToMove * -1, 0);
75
+ break;
76
+ case 'ArrowRight':
77
+ handleDrag(distanceToMove, 0);
78
+ break;
79
+ case 'ArrowUp':
80
+ handleDrag(0, distanceToMove * -1);
81
+ break;
82
+ case 'ArrowDown':
83
+ handleDrag(0, distanceToMove);
84
+ break;
85
+ default:
86
+ break;
87
+ }
88
+ }
89
+ };
53
90
  var styledTune = {};
54
- // TODO: check this... this feels like it should be in a hook with no dep array.
55
91
  if (isBeacon || isDraggable) {
56
92
  if (coachmark.targetRect) {
57
93
  styledTune = {
@@ -70,36 +106,97 @@ var CoachmarkOverlay = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref)
70
106
  styledTune.top += offsetTune.top;
71
107
  }
72
108
  }
109
+ function handleDragBounds(x, y) {
110
+ var xRes = x;
111
+ var yRes = y;
112
+ var xMax = winWidth - 288;
113
+ var yMax = winHeight - 150;
114
+ if (xRes < 0) {
115
+ xRes = 0;
116
+ } else if (xRes > xMax) {
117
+ xRes = xMax;
118
+ }
119
+ if (yRes < 0) {
120
+ yRes = 0;
121
+ } else if (yRes > yMax) {
122
+ yRes = yMax;
123
+ }
124
+ return {
125
+ targetX: xRes,
126
+ targetY: yRes
127
+ };
128
+ }
73
129
  function handleDrag(movementX, movementY) {
74
130
  var overlay = overlayRef.current;
75
131
  var _overlay$getBoundingC = overlay.getBoundingClientRect(),
76
132
  x = _overlay$getBoundingC.x,
77
133
  y = _overlay$getBoundingC.y;
134
+ var _handleDragBounds = handleDragBounds(x + movementX, y + movementY),
135
+ targetX = _handleDragBounds.targetX,
136
+ targetY = _handleDragBounds.targetY;
78
137
  overlay.style.transform = 'none';
79
138
  overlay.style.position = 'fixed';
80
- overlay.style.left = "".concat(x + movementX, "px");
81
- overlay.style.top = "".concat(y + movementY, "px");
139
+ overlay.style.left = "".concat(targetX, "px");
140
+ overlay.style.top = "".concat(targetY, "px");
82
141
  overlay.style.bottom = 'auto';
83
142
  }
143
+ var contentId = (0, _uuidv.default)();
84
144
  return /*#__PURE__*/_react.default.createElement("div", (0, _extends2.default)({}, rest, {
85
- className: (0, _classnames.default)(blockClass, "".concat(blockClass, "--").concat(kind), "".concat(blockClass, "__").concat(theme), (isBeacon || isDraggable) && "".concat(blockClass, "--").concat(coachmark.align), fixedIsVisible && "".concat(blockClass, "--is-visible"), className),
145
+ className: (0, _classnames.default)(blockClass, "".concat(blockClass, "--").concat(kind), "".concat(blockClass, "__").concat(theme), (isBeacon || isDraggable) && "".concat(blockClass, "--").concat(coachmark.align), fixedIsVisible && "".concat(blockClass, "--is-visible"), a11yDragMode && "".concat(blockClass, "--is-dragmode"), className),
86
146
  ref: overlayRef,
87
- style: styledTune
147
+ style: styledTune,
148
+ "aria-labelledby": contentId,
149
+ tabIndex: -1
88
150
  }, (0, _devtools.getDevtoolsProps)(componentName)), isDraggable ? /*#__PURE__*/_react.default.createElement(_CoachmarkDragbar.CoachmarkDragbar, {
151
+ a11yKeyboardHandler: handleKeyPress,
152
+ onBlur: function onBlur() {
153
+ return setA11yDragMode(false);
154
+ },
89
155
  onDrag: handleDrag,
156
+ theme: theme,
90
157
  onClose: onClose
91
158
  }) : /*#__PURE__*/_react.default.createElement(_CoachmarkHeader.CoachmarkHeader, {
92
159
  onClose: onClose
93
160
  }), /*#__PURE__*/_react.default.createElement("div", {
94
161
  className: "".concat(blockClass, "__body"),
95
- ref: ref
96
- }, children), isBeacon && /*#__PURE__*/_react.default.createElement("span", {
162
+ ref: ref,
163
+ id: contentId
164
+ }, _react.default.Children.map(children, function (child) {
165
+ return /*#__PURE__*/_react.default.cloneElement(child, {
166
+ isVisible: isVisible
167
+ });
168
+ })), isBeacon && /*#__PURE__*/_react.default.createElement("span", {
97
169
  className: "".concat(blockClass, "__caret")
98
170
  }));
99
171
  });
172
+ exports.CoachmarkOverlay = CoachmarkOverlay;
173
+ function getWindowDimensions() {
174
+ var _window = window,
175
+ winWidth = _window.innerWidth,
176
+ winHeight = _window.innerHeight;
177
+ return {
178
+ winWidth: winWidth,
179
+ winHeight: winHeight
180
+ };
181
+ }
182
+ var useWindowDimensions = function useWindowDimensions() {
183
+ var _useState3 = (0, _react.useState)(getWindowDimensions()),
184
+ _useState4 = (0, _slicedToArray2.default)(_useState3, 2),
185
+ windowDimensions = _useState4[0],
186
+ setWindowDimensions = _useState4[1];
187
+ (0, _react.useEffect)(function () {
188
+ function handleResize() {
189
+ setWindowDimensions(getWindowDimensions());
190
+ }
191
+ window.addEventListener('resize', handleResize);
192
+ return function () {
193
+ return window.removeEventListener('resize', handleResize);
194
+ };
195
+ }, []);
196
+ return windowDimensions;
197
+ };
100
198
 
101
199
  // Return a placeholder if not released and not enabled by feature flag
102
- exports.CoachmarkOverlay = CoachmarkOverlay;
103
200
  exports.CoachmarkOverlay = CoachmarkOverlay = _settings.pkg.checkComponentEnabled(CoachmarkOverlay, componentName);
104
201
 
105
202
  // The display name of the component, used by React. Note that displayName
@@ -43,14 +43,17 @@ var CoachmarkBeacon = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
43
43
  className: (0, _classnames.default)(blockClass, "".concat(blockClass, "-").concat(kind), className),
44
44
  ref: ref,
45
45
  style: overlayPositionStyle
46
- }, (0, _devtools.getDevtoolsProps)(componentName)), /*#__PURE__*/_react.default.createElement("button", (0, _extends2.default)({
46
+ }, (0, _devtools.getDevtoolsProps)(componentName), {
47
+ role: "tooltip"
48
+ }), /*#__PURE__*/_react.default.createElement("button", (0, _extends2.default)({
47
49
  tabIndex: 0,
48
50
  type: "button"
49
51
  }, coachmark.buttonProps, {
50
52
  "aria-label": label,
51
53
  className: "".concat(blockClass, "__target")
52
54
  }), /*#__PURE__*/_react.default.createElement("svg", {
53
- className: "".concat(blockClass, "__center")
55
+ className: "".concat(blockClass, "__center"),
56
+ alt: ""
54
57
  }, /*#__PURE__*/_react.default.createElement("circle", {
55
58
  r: 1,
56
59
  cx: 38,
@@ -23,7 +23,9 @@ var _excluded = ["children", "className", "onClose", "portalTarget", "tagline",
23
23
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
24
24
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
25
25
  // The block part of our conventional BEM class names (blockClass__E--M).
26
- var blockClass = "".concat(_settings.pkg.prefix, "--coachmark-fixed");
26
+ var coachmarkClass = "".concat(_settings.pkg.prefix, "--coachmark");
27
+ var blockClass = "".concat(coachmarkClass, "-fixed");
28
+ var overlayBlockClass = "".concat(coachmarkClass, "-overlay");
27
29
  var componentName = 'CoachmarkFixed';
28
30
  var defaults = {
29
31
  onClose: function onClose() {},
@@ -74,9 +76,14 @@ var CoachmarkFixed = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref)
74
76
  _useState10 = (0, _slicedToArray2.default)(_useState9, 2),
75
77
  fixedIsVisible = _useState10[0],
76
78
  setFixedIsVisible = _useState10[1];
77
- var handleClose = function handleClose() {
78
- setFixedIsVisible(false);
79
- };
79
+ var prefersReducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)');
80
+ var handleClose = (0, _react.useCallback)(function () {
81
+ if (prefersReducedMotion.matches) {
82
+ setIsOpen(false);
83
+ } else {
84
+ setFixedIsVisible(false);
85
+ }
86
+ }, [prefersReducedMotion.matches]);
80
87
  var handleTransitionEnd = function handleTransitionEnd(e) {
81
88
  if (e.propertyName === 'transform' && !fixedIsVisible) {
82
89
  setIsOpen(false);
@@ -93,9 +100,21 @@ var CoachmarkFixed = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref)
93
100
  setIsOpen(false);
94
101
  setShouldResetPosition(true);
95
102
  };
103
+ var escFunction = (0, _react.useCallback)(function (event) {
104
+ if (event.key === 'Escape') {
105
+ handleClose();
106
+ }
107
+ }, [handleClose]);
108
+ (0, _react.useEffect)(function () {
109
+ document.addEventListener('keydown', escFunction, false);
110
+ return function () {
111
+ document.removeEventListener('keydown', escFunction, false);
112
+ };
113
+ }, [escFunction]);
96
114
  var contextValue = {
97
115
  buttonProps: {
98
116
  'aria-expanded': isOpen,
117
+ tabIndex: 0,
99
118
  onClick: handleTargetClick,
100
119
  // Compensate for accidental open/close on double-click.
101
120
  // Only open on double-click.
@@ -150,7 +169,8 @@ var CoachmarkFixed = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref)
150
169
  kind: _enums.COACHMARK_OVERLAY_KIND.FIXED,
151
170
  onClose: handleClose,
152
171
  onTransitionEnd: handleTransitionEnd,
153
- theme: theme
172
+ theme: theme,
173
+ className: (0, _classnames.default)(fixedIsVisible && "".concat(overlayBlockClass, "--is-visible"), overlayBlockClass)
154
174
  }, children), portalNode)));
155
175
  });
156
176