@carbon/ibm-products 2.17.1 → 2.18.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (108) hide show
  1. package/css/index-full-carbon.css +17078 -15669
  2. package/css/index-full-carbon.css.map +1 -1
  3. package/css/index-full-carbon.min.css +1 -1
  4. package/css/index-full-carbon.min.css.map +1 -1
  5. package/css/index-without-carbon-released-only.css +71 -9
  6. package/css/index-without-carbon-released-only.css.map +1 -1
  7. package/css/index-without-carbon-released-only.min.css +1 -1
  8. package/css/index-without-carbon-released-only.min.css.map +1 -1
  9. package/css/index-without-carbon.css +5763 -6355
  10. package/css/index-without-carbon.css.map +1 -1
  11. package/css/index-without-carbon.min.css +1 -1
  12. package/css/index-without-carbon.min.css.map +1 -1
  13. package/css/index.css +124 -9
  14. package/css/index.css.map +1 -1
  15. package/css/index.min.css +1 -1
  16. package/css/index.min.css.map +1 -1
  17. package/es/components/Carousel/Carousel.docs-page.js +11 -0
  18. package/es/components/Carousel/Carousel.js +322 -0
  19. package/es/components/Carousel/CarouselItem.js +53 -0
  20. package/es/components/Carousel/index.js +9 -0
  21. package/es/components/Carousel/utils.js +98 -0
  22. package/es/components/CreateSidePanel/CreateSidePanel.js +7 -1
  23. package/es/components/Datagrid/Datagrid/DatagridExpandedRow.js +3 -1
  24. package/es/components/Datagrid/Datagrid/DatagridRow.js +13 -3
  25. package/es/components/Datagrid/Datagrid/addons/Filtering/hooks/useFilters.js +4 -3
  26. package/es/components/Datagrid/Extensions/Filtering/Filtering.docs-page.js +7 -1
  27. package/es/components/Datagrid/useExpandedRow.js +3 -6
  28. package/es/components/Datagrid/useFocusRowExpander.js +40 -0
  29. package/es/components/Datagrid/useNestedRowExpander.js +9 -0
  30. package/es/components/Datagrid/useNestedRows.js +1 -5
  31. package/es/components/Datagrid/useRowExpander.js +9 -0
  32. package/es/components/Datagrid/useSelectRows.js +9 -2
  33. package/es/components/Datagrid/utils/handleFilterTagLabelText.js +26 -0
  34. package/es/components/EditSidePanel/EditSidePanel.js +8 -2
  35. package/es/components/FilterSummary/FilterSummary.js +21 -7
  36. package/es/components/Guidebanner/Guidebanner.docs-page.js +15 -0
  37. package/es/components/Guidebanner/Guidebanner.js +221 -0
  38. package/es/components/Guidebanner/GuidebannerElement.js +72 -0
  39. package/es/components/Guidebanner/GuidebannerElementButton.js +80 -0
  40. package/es/components/Guidebanner/GuidebannerElementLink.js +57 -0
  41. package/es/components/Guidebanner/index.js +11 -0
  42. package/es/components/NonLinearReading/NonLinearReading.docs-page.js +15 -0
  43. package/es/components/NonLinearReading/NonLinearReading.js +89 -0
  44. package/es/components/NonLinearReading/index.js +8 -0
  45. package/es/components/SidePanel/SidePanel.js +48 -27
  46. package/es/components/TagSet/TagSet.js +22 -5
  47. package/es/components/WebTerminal/WebTerminal.js +5 -3
  48. package/es/global/js/hooks/useCreateComponentStepChange.js +1 -1
  49. package/es/global/js/package-settings.js +6 -3
  50. package/lib/components/Carousel/Carousel.docs-page.js +21 -0
  51. package/lib/components/Carousel/Carousel.js +329 -0
  52. package/lib/components/Carousel/CarouselItem.js +54 -0
  53. package/lib/components/Carousel/index.js +19 -0
  54. package/lib/components/Carousel/utils.js +105 -0
  55. package/lib/components/CreateSidePanel/CreateSidePanel.js +7 -1
  56. package/lib/components/Datagrid/Datagrid/DatagridExpandedRow.js +3 -1
  57. package/lib/components/Datagrid/Datagrid/DatagridRow.js +13 -3
  58. package/lib/components/Datagrid/Datagrid/addons/Filtering/hooks/useFilters.js +4 -3
  59. package/lib/components/Datagrid/Extensions/Filtering/Filtering.docs-page.js +7 -1
  60. package/lib/components/Datagrid/useExpandedRow.js +2 -5
  61. package/lib/components/Datagrid/useFocusRowExpander.js +45 -0
  62. package/lib/components/Datagrid/useNestedRowExpander.js +9 -0
  63. package/lib/components/Datagrid/useNestedRows.js +1 -5
  64. package/lib/components/Datagrid/useRowExpander.js +9 -0
  65. package/lib/components/Datagrid/useSelectRows.js +9 -2
  66. package/lib/components/Datagrid/utils/handleFilterTagLabelText.js +32 -0
  67. package/lib/components/EditSidePanel/EditSidePanel.js +8 -2
  68. package/lib/components/FilterSummary/FilterSummary.js +24 -7
  69. package/lib/components/Guidebanner/Guidebanner.docs-page.js +25 -0
  70. package/lib/components/Guidebanner/Guidebanner.js +229 -0
  71. package/lib/components/Guidebanner/GuidebannerElement.js +77 -0
  72. package/lib/components/Guidebanner/GuidebannerElementButton.js +85 -0
  73. package/lib/components/Guidebanner/GuidebannerElementLink.js +62 -0
  74. package/lib/components/Guidebanner/index.js +33 -0
  75. package/lib/components/NonLinearReading/NonLinearReading.docs-page.js +25 -0
  76. package/lib/components/NonLinearReading/NonLinearReading.js +97 -0
  77. package/lib/components/NonLinearReading/index.js +12 -0
  78. package/lib/components/SidePanel/SidePanel.js +47 -26
  79. package/lib/components/TagSet/TagSet.js +22 -5
  80. package/lib/components/WebTerminal/WebTerminal.js +4 -2
  81. package/lib/global/js/hooks/useCreateComponentStepChange.js +1 -1
  82. package/lib/global/js/package-settings.js +6 -3
  83. package/package.json +5 -5
  84. package/scss/components/Carousel/_carbon-imports.scss +6 -0
  85. package/scss/components/Carousel/_carousel.scss +72 -0
  86. package/scss/components/Carousel/_index-with-carbon.scss +9 -0
  87. package/scss/components/Carousel/_index.scss +8 -0
  88. package/scss/components/Datagrid/styles/_useExpandedRow.scss +21 -0
  89. package/scss/components/Datagrid/styles/addons/_RowSizeDropdown.scss +9 -0
  90. package/scss/components/FilterSummary/_filter-summary.scss +6 -1
  91. package/scss/components/Guidebanner/_carbon-imports.scss +6 -0
  92. package/scss/components/Guidebanner/_guidebanner.scss +248 -0
  93. package/scss/components/Guidebanner/_index-with-carbon.scss +9 -0
  94. package/scss/components/Guidebanner/_index.scss +8 -0
  95. package/scss/components/NonLinearReading/_carbon-imports.scss +6 -0
  96. package/scss/components/NonLinearReading/_index-with-carbon.scss +9 -0
  97. package/scss/components/NonLinearReading/_index.scss +8 -0
  98. package/scss/components/NonLinearReading/_non-linear-reading.scss +122 -0
  99. package/scss/components/SidePanel/_side-panel.scss +22 -6
  100. package/scss/components/WebTerminal/_web-terminal.scss +1 -2
  101. package/scss/components/_Canary/_canary.scss +1 -2
  102. package/scss/components/_Canary/_carbon-imports.scss +7 -0
  103. package/scss/components/_Canary/_index-with-carbon.scss +8 -0
  104. package/scss/components/_Canary/_index.scss +7 -0
  105. package/scss/components/_index-with-carbon.scss +1 -1
  106. package/scss/components/_index.scss +5 -2
  107. /package/es/components/Datagrid/{Extensions → Datagrid.stories}/ColumnAlignment/ColumnAlignment.docs-page.js +0 -0
  108. /package/lib/components/Datagrid/{Extensions → Datagrid.stories}/ColumnAlignment/ColumnAlignment.docs-page.js +0 -0
@@ -0,0 +1,40 @@
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 { useEffect } from 'react';
9
+
10
+ // Focuses the row expander after a nested/expandable row state change.
11
+ // We have to add this workaround because react-table is re-rendering the entire row
12
+ // which removes the focus from the expander and interrupts the keyboard navigation
13
+ // flow.
14
+ export var useFocusRowExpander = function useFocusRowExpander(_ref) {
15
+ var instance = _ref.instance,
16
+ _ref$lastExpandedRowI = _ref.lastExpandedRowIndex,
17
+ lastExpandedRowIndex = _ref$lastExpandedRowI === void 0 ? 0 : _ref$lastExpandedRowI,
18
+ blockClass = _ref.blockClass,
19
+ activeElement = _ref.activeElement;
20
+ useEffect(function () {
21
+ // We need to return at this point so that the focus is not stolen from
22
+ // other interactive elements in the Datagrid
23
+ if (!activeElement.classList.contains("".concat(blockClass, "__row-expander"))) {
24
+ return;
25
+ }
26
+ var tableId = instance === null || instance === void 0 ? void 0 : instance.tableId;
27
+ var rowElements = document.querySelectorAll("#".concat(tableId, " tbody tr"));
28
+ var rowElementsArray = Array.from(rowElements);
29
+ var activeRow = rowElementsArray.filter(function (r) {
30
+ if (r.getAttribute('data-nested-row-id') === lastExpandedRowIndex) {
31
+ return r;
32
+ }
33
+ return null;
34
+ });
35
+ if (activeRow.length) {
36
+ var rowExpander = activeRow[0].querySelector(".".concat(blockClass, "__row-expander"));
37
+ rowExpander.focus();
38
+ }
39
+ }, [instance === null || instance === void 0 ? void 0 : instance.tableId, instance === null || instance === void 0 ? void 0 : instance.expandedRows, lastExpandedRowIndex, blockClass, activeElement]);
40
+ };
@@ -15,12 +15,20 @@ import React, { useRef } from 'react';
15
15
  import { ChevronRight } from '@carbon/react/icons';
16
16
  import cx from 'classnames';
17
17
  import { pkg, carbon } from '../../settings';
18
+ import { useFocusRowExpander } from './useFocusRowExpander';
18
19
  var blockClass = "".concat(pkg.prefix, "--datagrid");
19
20
  var useNestedRowExpander = function useNestedRowExpander(hooks) {
20
21
  var tempState = useRef();
22
+ var lastExpandedRowIndex = useRef();
21
23
  var useInstance = function useInstance(instance) {
22
24
  tempState.current = instance;
23
25
  };
26
+ useFocusRowExpander({
27
+ instance: tempState === null || tempState === void 0 ? void 0 : tempState.current,
28
+ lastExpandedRowIndex: lastExpandedRowIndex === null || lastExpandedRowIndex === void 0 ? void 0 : lastExpandedRowIndex.current,
29
+ blockClass: blockClass,
30
+ activeElement: document.activeElement
31
+ });
24
32
  var visibleColumns = function visibleColumns(columns) {
25
33
  var expanderColumn = {
26
34
  id: 'expander',
@@ -32,6 +40,7 @@ var useNestedRowExpander = function useNestedRowExpander(hooks) {
32
40
  // Prevents `onRowClick` from being called if `useOnRowClick` is included
33
41
  event.stopPropagation();
34
42
  row.toggleRowExpanded();
43
+ lastExpandedRowIndex.current = row.id;
35
44
  }
36
45
  });
37
46
  var _ref2 = (tempState === null || tempState === void 0 ? void 0 : tempState.current) || {},
@@ -6,15 +6,11 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
8
 
9
- import { useEffect } from 'react';
10
- import { pkg } from '../../settings';
11
9
  import cx from 'classnames';
10
+ import { pkg } from '../../settings';
12
11
  import useNestedRowExpander from './useNestedRowExpander';
13
12
  var blockClass = "".concat(pkg.prefix, "--datagrid");
14
13
  var useNestedRows = function useNestedRows(hooks) {
15
- useEffect(function () {
16
- pkg.checkReportFeatureEnabled('Datagrid.useNestedRows');
17
- }, []);
18
14
  useNestedRowExpander(hooks);
19
15
  var marginLeft = 24;
20
16
  var getRowProps = function getRowProps(props, _ref) {
@@ -15,12 +15,20 @@ import React, { useRef } from 'react';
15
15
  import { ChevronDown, ChevronUp } from '@carbon/react/icons';
16
16
  import { pkg, carbon } from '../../settings';
17
17
  import cx from 'classnames';
18
+ import { useFocusRowExpander } from './useFocusRowExpander';
18
19
  var blockClass = "".concat(pkg.prefix, "--datagrid");
19
20
  var useRowExpander = function useRowExpander(hooks) {
20
21
  var tempState = useRef();
22
+ var lastExpandedRowIndex = useRef();
21
23
  var useInstance = function useInstance(instance) {
22
24
  tempState.current = instance;
23
25
  };
26
+ useFocusRowExpander({
27
+ instance: tempState === null || tempState === void 0 ? void 0 : tempState.current,
28
+ lastExpandedRowIndex: lastExpandedRowIndex === null || lastExpandedRowIndex === void 0 ? void 0 : lastExpandedRowIndex.current,
29
+ blockClass: blockClass,
30
+ activeElement: document.activeElement
31
+ });
24
32
  var visibleColumns = function visibleColumns(columns) {
25
33
  var expanderColumn = {
26
34
  id: 'expander',
@@ -31,6 +39,7 @@ var useRowExpander = function useRowExpander(hooks) {
31
39
  // Prevents `onRowClick` from being called if `useOnRowClick` is included
32
40
  event.stopPropagation();
33
41
  row.toggleRowExpanded();
42
+ lastExpandedRowIndex.current = row.id;
34
43
  }
35
44
  });
36
45
  var _ref2 = (tempState === null || tempState === void 0 ? void 0 : tempState.current) || {},
@@ -42,7 +42,14 @@ var useSelectRows = function useSelectRows(hooks) {
42
42
  });
43
43
  });
44
44
  hooks.visibleColumns.push(function (columns) {
45
- return [{
45
+ // Ensures that the first column is the row expander in the
46
+ // case of selected rows and expandable rows being used together
47
+ var newColOrder = _toConsumableArray(columns);
48
+ var expanderColumnIndex = newColOrder.findIndex(function (col) {
49
+ return col.id === 'expander';
50
+ });
51
+ var expanderCol = expanderColumnIndex > -1 ? newColOrder.splice(expanderColumnIndex, 1) : [];
52
+ return [].concat(_toConsumableArray(expanderColumnIndex > -1 && expanderCol && expanderCol.length ? expanderCol : []), [{
46
53
  id: selectionColumnId,
47
54
  Header: function Header(gridState) {
48
55
  return /*#__PURE__*/React.createElement(SelectAll, gridState);
@@ -50,7 +57,7 @@ var useSelectRows = function useSelectRows(hooks) {
50
57
  Cell: function Cell(gridState) {
51
58
  return /*#__PURE__*/React.createElement(SelectRow, gridState);
52
59
  }
53
- }].concat(_toConsumableArray(columns));
60
+ }], _toConsumableArray(newColOrder));
54
61
  });
55
62
  };
56
63
  var useHighlightSelection = function useHighlightSelection(hooks) {
@@ -0,0 +1,26 @@
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
+ // Example usage for custom filter tag labels, in practice this
9
+ // is where a translation service would be utilized. This
10
+ // utility is for storybook demonstration purposes only.
11
+ export var handleFilterTagLabelText = function handleFilterTagLabelText(key, value) {
12
+ switch (key) {
13
+ case 'role':
14
+ return "Role: ".concat(value);
15
+ case 'joined':
16
+ return "Joined: ".concat(value);
17
+ case 'visits':
18
+ return "Visits: ".concat(value);
19
+ case 'passwordStrength':
20
+ return "Password strength: ".concat(value);
21
+ case 'status':
22
+ return "Status: ".concat(value);
23
+ default:
24
+ return "".concat(key, ": ").concat(value);
25
+ }
26
+ };
@@ -1,7 +1,7 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
3
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
4
- var _excluded = ["children", "className", "disableSubmit", "formTitle", "formDescription", "onRequestClose", "onRequestSubmit", "open", "placement", "primaryButtonText", "secondaryButtonText", "selectorPrimaryFocus", "selectorPageContent", "size", "slideIn", "subtitle", "title"];
4
+ var _excluded = ["children", "className", "disableSubmit", "id", "formTitle", "formDescription", "onRequestClose", "onRequestSubmit", "open", "placement", "primaryButtonText", "secondaryButtonText", "selectorPrimaryFocus", "selectorPageContent", "size", "slideIn", "subtitle", "title"];
5
5
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
6
6
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
7
7
  /**
@@ -45,6 +45,7 @@ export var EditSidePanel = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
45
45
  var children = _ref.children,
46
46
  className = _ref.className,
47
47
  disableSubmit = _ref.disableSubmit,
48
+ id = _ref.id,
48
49
  formTitle = _ref.formTitle,
49
50
  formDescription = _ref.formDescription,
50
51
  onRequestClose = _ref.onRequestClose,
@@ -84,7 +85,8 @@ export var EditSidePanel = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
84
85
  onRequestClose: onRequestClose,
85
86
  title: title,
86
87
  subtitle: subtitle,
87
- selectorPrimaryFocus: selectorPrimaryFocus
88
+ selectorPrimaryFocus: selectorPrimaryFocus,
89
+ id: id
88
90
  }, getDevtoolsProps(componentName)), {
89
91
  placement: placement,
90
92
  slideIn: slideIn,
@@ -136,6 +138,10 @@ EditSidePanel.propTypes = {
136
138
  * Specifies a required field that provides a title for a form
137
139
  */
138
140
  formTitle: PropTypes.node.isRequired,
141
+ /**
142
+ * Unique identifier
143
+ */
144
+ id: PropTypes.string,
139
145
  /**
140
146
  * Specifies an optional handler which is called when the CreateSidePanel
141
147
  * is closed.
@@ -4,19 +4,21 @@ var _excluded = ["key", "value"];
4
4
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
5
5
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
6
6
  /**
7
- * Copyright IBM Corp. 2022, 2022
7
+ * Copyright IBM Corp. 2022, 2023
8
8
  *
9
9
  * This source code is licensed under the Apache-2.0 license found in the
10
10
  * LICENSE file in the root directory of this source tree.
11
11
  */
12
12
  import { Button } from '@carbon/react';
13
- import React from 'react';
13
+ import React, { useRef } from 'react';
14
14
  import PropTypes from 'prop-types';
15
15
  import cx from 'classnames';
16
16
  import { TagSet } from '../TagSet';
17
17
  import { pkg } from '../../settings';
18
+ import uuidv4 from '../../global/js/utils/uuidv4';
18
19
  var blockClass = "".concat(pkg.prefix, "--filter-summary");
19
20
  var FilterSummary = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
21
+ var _filterSummaryClearBu;
20
22
  var _ref$className = _ref.className,
21
23
  className = _ref$className === void 0 ? '' : _ref$className,
22
24
  _ref$clearFiltersText = _ref.clearFiltersText,
@@ -28,7 +30,10 @@ var FilterSummary = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
28
30
  _ref$renderLabel = _ref.renderLabel,
29
31
  renderLabel = _ref$renderLabel === void 0 ? null : _ref$renderLabel,
30
32
  _ref$overflowType = _ref.overflowType,
31
- overflowType = _ref$overflowType === void 0 ? 'default' : _ref$overflowType;
33
+ overflowType = _ref$overflowType === void 0 ? 'default' : _ref$overflowType,
34
+ _ref$clearButtonInlin = _ref.clearButtonInline,
35
+ clearButtonInline = _ref$clearButtonInlin === void 0 ? true : _ref$clearButtonInlin;
36
+ var filterSummaryId = "".concat(blockClass, "__").concat(uuidv4());
32
37
  var tagFilters = filters.map(function (_ref2) {
33
38
  var _renderLabel;
34
39
  var key = _ref2.key,
@@ -39,26 +44,35 @@ var FilterSummary = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
39
44
  label: (_renderLabel = renderLabel === null || renderLabel === void 0 ? void 0 : renderLabel(key, value)) !== null && _renderLabel !== void 0 ? _renderLabel : "".concat(key, ": ").concat(value)
40
45
  });
41
46
  });
47
+ var filterSummaryClearButton = useRef();
48
+ var filterSummaryRef = useRef();
49
+ var localRef = filterSummaryRef || ref;
42
50
  return /*#__PURE__*/React.createElement("div", {
43
- ref: ref,
44
- className: cx([blockClass, className])
51
+ ref: localRef,
52
+ className: cx([blockClass, className]),
53
+ id: filterSummaryId
45
54
  }, /*#__PURE__*/React.createElement(TagSet, {
46
55
  allTagsModalSearchLabel: "Search all tags",
47
56
  allTagsModalSearchPlaceholderText: "Search all tags",
48
57
  allTagsModalTitle: "All tags",
49
58
  showAllTagsLabel: "View all tags",
50
59
  tags: tagFilters,
51
- overflowType: overflowType
60
+ overflowType: overflowType,
61
+ className: cx(_defineProperty({}, "".concat(blockClass, "__clear-button-inline"), clearButtonInline)),
62
+ containingElementRef: localRef,
63
+ measurementOffset: filterSummaryClearButton === null || filterSummaryClearButton === void 0 || (_filterSummaryClearBu = filterSummaryClearButton.current) === null || _filterSummaryClearBu === void 0 ? void 0 : _filterSummaryClearBu.offsetWidth
52
64
  }), /*#__PURE__*/React.createElement(Button, {
53
65
  kind: "ghost",
54
66
  size: "sm",
55
- onClick: clearFilters
67
+ onClick: clearFilters,
68
+ ref: filterSummaryClearButton
56
69
  }, clearFiltersText));
57
70
  });
58
71
  var componentName = 'FilterSummary';
59
72
  FilterSummary.displayName = componentName;
60
73
  FilterSummary.propTypes = {
61
74
  className: PropTypes.string,
75
+ clearButtonInline: PropTypes.bool,
62
76
  clearFilters: PropTypes.func.isRequired,
63
77
  clearFiltersText: PropTypes.string,
64
78
  filters: PropTypes.arrayOf(PropTypes.object).isRequired,
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+ import { StoryDocsPage } from '../../global/js/utils/StoryDocsPage';
3
+ import * as stories from './Guidebanner.stories';
4
+ var DocsPage = function DocsPage() {
5
+ return /*#__PURE__*/React.createElement(StoryDocsPage, {
6
+ blocks: [{
7
+ story: stories.collapsible
8
+ }, {
9
+ story: stories.manyInsights
10
+ }, {
11
+ story: stories.fewInsights
12
+ }]
13
+ });
14
+ };
15
+ export default DocsPage;
@@ -0,0 +1,221 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
4
+ var _excluded = ["children", "className", "collapsible", "onClose", "closeIconDescription", "collapseButtonLabel", "expandButtonLabel", "nextIconDescription", "previousIconDescription", "title"];
5
+ /**
6
+ * Copyright IBM Corp. 2023, 2023
7
+ *
8
+ * This source code is licensed under the Apache-2.0 license found in the
9
+ * LICENSE file in the root directory of this source tree.
10
+ */
11
+
12
+ // Import portions of React that are needed.
13
+ import React, { useRef, useState } from 'react';
14
+ import PropTypes from 'prop-types';
15
+ import cx from 'classnames';
16
+ import { blue90, purple70 } from '@carbon/colors';
17
+ import { CaretLeft, CaretRight, Close, Idea } from '@carbon/react/icons';
18
+ import { Button, IconButton } from '@carbon/react';
19
+ import { Carousel } from '../Carousel';
20
+ import { getDevtoolsProps } from '../../global/js/utils/devtools';
21
+ import { pkg } from '../../settings';
22
+
23
+ // The block part of our conventional BEM class names (blockClass__E--M).
24
+ var blockClass = "".concat(pkg.prefix, "--guidebanner");
25
+ var componentName = 'Guidebanner';
26
+ var defaults = {
27
+ collapsible: false,
28
+ // Labels
29
+ closeIconDescription: 'Close',
30
+ collapseButtonLabel: 'Read less',
31
+ expandButtonLabel: 'Read more',
32
+ nextIconDescription: 'Next',
33
+ previousIconDescription: 'Back'
34
+ };
35
+
36
+ /**
37
+ * The guide banner sits at the top of a page, or page-level tab,
38
+ * to introduce foundational concepts related to the page's content.
39
+ */
40
+ export var Guidebanner = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
41
+ var children = _ref.children,
42
+ className = _ref.className,
43
+ _ref$collapsible = _ref.collapsible,
44
+ collapsible = _ref$collapsible === void 0 ? defaults.collapsible : _ref$collapsible,
45
+ onClose = _ref.onClose,
46
+ _ref$closeIconDescrip = _ref.closeIconDescription,
47
+ closeIconDescription = _ref$closeIconDescrip === void 0 ? defaults.closeIconDescription : _ref$closeIconDescrip,
48
+ _ref$collapseButtonLa = _ref.collapseButtonLabel,
49
+ collapseButtonLabel = _ref$collapseButtonLa === void 0 ? defaults.collapseButtonLabel : _ref$collapseButtonLa,
50
+ _ref$expandButtonLabe = _ref.expandButtonLabel,
51
+ expandButtonLabel = _ref$expandButtonLabe === void 0 ? defaults.expandButtonLabel : _ref$expandButtonLabe,
52
+ _ref$nextIconDescript = _ref.nextIconDescription,
53
+ nextIconDescription = _ref$nextIconDescript === void 0 ? defaults.nextIconDescription : _ref$nextIconDescript,
54
+ _ref$previousIconDesc = _ref.previousIconDescription,
55
+ previousIconDescription = _ref$previousIconDesc === void 0 ? defaults.previousIconDescription : _ref$previousIconDesc,
56
+ title = _ref.title,
57
+ rest = _objectWithoutProperties(_ref, _excluded);
58
+ var scrollRef = useRef();
59
+ var toggleRef = useRef();
60
+ var _useState = useState(0),
61
+ _useState2 = _slicedToArray(_useState, 2),
62
+ scrollPosition = _useState2[0],
63
+ setScrollPosition = _useState2[1];
64
+ var _useState3 = useState(false),
65
+ _useState4 = _slicedToArray(_useState3, 2),
66
+ showNavigation = _useState4[0],
67
+ setShowNavigation = _useState4[1];
68
+ var _useState5 = useState(collapsible ? true : false),
69
+ _useState6 = _slicedToArray(_useState5, 2),
70
+ isCollapsed = _useState6[0],
71
+ setIsCollapsed = _useState6[1];
72
+ var handleClickToggle = function handleClickToggle() {
73
+ setIsCollapsed(function (prevState) {
74
+ return !prevState;
75
+ });
76
+ };
77
+ return /*#__PURE__*/React.createElement("div", _extends({}, rest, {
78
+ "aria-expanded": !isCollapsed,
79
+ className: cx(blockClass, className, [collapsible ? "".concat(blockClass, "__collapsible") : null], [isCollapsed ? "".concat(blockClass, "__collapsible-collapsed") : null]),
80
+ ref: ref
81
+ }, getDevtoolsProps(componentName)), /*#__PURE__*/React.createElement(Idea, {
82
+ size: 20,
83
+ className: "".concat(blockClass, "__icon-idea")
84
+ }), /*#__PURE__*/React.createElement("div", {
85
+ className: "".concat(blockClass, "__title")
86
+ }, title), /*#__PURE__*/React.createElement(Carousel, {
87
+ className: "".concat(blockClass, "__carousel")
88
+ // These colors are to match the Carousel's faded edges
89
+ // against the Guidebanner's gradient background.
90
+ ,
91
+ fadedEdgeColor: {
92
+ left: blue90,
93
+ right: purple70
94
+ },
95
+ ref: scrollRef,
96
+ onChangeIsScrollable: function onChangeIsScrollable(value) {
97
+ setShowNavigation(value);
98
+ },
99
+ onScroll: function onScroll(scrollPercent) {
100
+ setScrollPosition(scrollPercent);
101
+ }
102
+ }, children), /*#__PURE__*/React.createElement("div", {
103
+ className: cx([collapsible || showNavigation ? "".concat(blockClass, "__navigation") : null])
104
+ }, collapsible && /*#__PURE__*/React.createElement(Button, {
105
+ kind: "ghost",
106
+ size: "md",
107
+ className: "".concat(blockClass, "__toggle-button"),
108
+ onClick: handleClickToggle,
109
+ ref: toggleRef
110
+ }, isCollapsed ? expandButtonLabel : collapseButtonLabel), showNavigation && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", {
111
+ className: cx("".concat(blockClass, "__back-button"), [scrollPosition === 0 ? "".concat(blockClass, "__back-button--disabled") : null])
112
+ }, /*#__PURE__*/React.createElement(IconButton, {
113
+ align: "top",
114
+ disabled: scrollPosition === 0,
115
+ kind: "ghost",
116
+ label: previousIconDescription,
117
+ onClick: function onClick() {
118
+ scrollRef.current.scrollPrev();
119
+ },
120
+ size: "md"
121
+ }, /*#__PURE__*/React.createElement(CaretLeft, {
122
+ size: 16
123
+ }))), /*#__PURE__*/React.createElement("span", {
124
+ className: cx("".concat(blockClass, "__next-button"), [scrollPosition === 1 ? "".concat(blockClass, "__next-button--disabled") : null])
125
+ }, /*#__PURE__*/React.createElement(IconButton, {
126
+ align: "top-right",
127
+ disabled: scrollPosition === 1,
128
+ kind: "ghost",
129
+ label: nextIconDescription,
130
+ onClick: function onClick() {
131
+ scrollRef.current.scrollNext();
132
+ },
133
+ size: "md"
134
+ }, /*#__PURE__*/React.createElement(CaretRight, {
135
+ size: 16
136
+ }))))), onClose && /*#__PURE__*/React.createElement("span", {
137
+ className: "".concat(blockClass, "__close-button")
138
+ }, /*#__PURE__*/React.createElement(IconButton, {
139
+ align: "bottom-right",
140
+ kind: "ghost",
141
+ label: closeIconDescription,
142
+ onClick: onClose,
143
+ size: "md"
144
+ }, /*#__PURE__*/React.createElement(Close, {
145
+ size: 16
146
+ }))));
147
+ });
148
+
149
+ // Return a placeholder if not released and not enabled by feature flag
150
+ Guidebanner = pkg.checkComponentEnabled(Guidebanner, componentName);
151
+
152
+ // The display name of the component, used by React. Note that displayName
153
+ // is used in preference to relying on function.name.
154
+ Guidebanner.displayName = componentName;
155
+
156
+ // The types and DocGen commentary for the component props,
157
+ // in alphabetical order (for consistency).
158
+ // See https://www.npmjs.com/package/prop-types#usage.
159
+ Guidebanner.propTypes = {
160
+ /**
161
+ * Provide the contents of the Guidebanner.
162
+ * One or more GuidebannerElement components are required.
163
+ */
164
+ children: function children(props, propName) {
165
+ var error;
166
+ var prop = props[propName];
167
+ if (!prop) {
168
+ error = new Error('`Guidebanner` requires one or more children of type `GuidebannerElement`.');
169
+ }
170
+ React.Children.forEach(prop, function (child) {
171
+ if (child.type.displayName !== 'GuidebannerElement') {
172
+ var _child$type, _child$type2;
173
+ // If not GuidebannerElement, then show:
174
+ // React component name(child.type?.name) or
175
+ // HTML element name(child.type).
176
+ error = new Error("`Guidebanner` only accepts children of type `GuidebannerElement`, found `".concat(((_child$type = child.type) === null || _child$type === void 0 ? void 0 : _child$type.displayName) || ((_child$type2 = child.type) === null || _child$type2 === void 0 ? void 0 : _child$type2.name) || child.type, "` instead."));
177
+ }
178
+ });
179
+ return error;
180
+ },
181
+ /**
182
+ * Provide an optional class to be applied to the containing node.
183
+ */
184
+ className: PropTypes.string,
185
+ /**
186
+ * Tooltip text and aria label for the Close button icon.
187
+ */
188
+ closeIconDescription: PropTypes.string,
189
+ /**
190
+ * Text label for the Collapse button.
191
+ */
192
+ collapseButtonLabel: PropTypes.string,
193
+ /**
194
+ * When true, the Guidebanner will initialize in a collapsed state,
195
+ * showing the title and the Expand button.
196
+ *
197
+ * When expanded, it will show the GuidebannerElement child components and the Collapse button.
198
+ */
199
+ collapsible: PropTypes.bool,
200
+ /**
201
+ * Text label for the Expand button.
202
+ */
203
+ expandButtonLabel: PropTypes.string,
204
+ /**
205
+ * Tooltip text and aria label for the Next button icon.
206
+ */
207
+ nextIconDescription: PropTypes.string,
208
+ /**
209
+ * If defined, a Close button will render in the top-right corner and a
210
+ * callback function will be triggered when button is clicked.
211
+ */
212
+ onClose: PropTypes.func,
213
+ /**
214
+ * Tooltip text and aria label for the Back button icon.
215
+ */
216
+ previousIconDescription: PropTypes.string,
217
+ /**
218
+ * Title text.
219
+ */
220
+ title: PropTypes.string.isRequired
221
+ };
@@ -0,0 +1,72 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
+ var _excluded = ["button", "className", "description", "title"];
4
+ /**
5
+ * Copyright IBM Corp. 2023, 2023
6
+ *
7
+ * This source code is licensed under the Apache-2.0 license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */
10
+
11
+ // Import portions of React that are needed.
12
+ import React from 'react';
13
+ import PropTypes from 'prop-types';
14
+ import cx from 'classnames';
15
+ import { getDevtoolsProps } from '../../global/js/utils/devtools';
16
+ import { pkg } from '../../settings';
17
+
18
+ // The block part of our conventional BEM class names (blockClass__E--M).
19
+ var blockClass = "".concat(pkg.prefix, "--guidebanner__element");
20
+ var componentName = 'GuidebannerElement';
21
+
22
+ /**
23
+ * The GuidebannerElement is a required child component of the Guidebanner,
24
+ * and acts as a container for a CarouselItem.
25
+ */
26
+ export var GuidebannerElement = function GuidebannerElement(_ref) {
27
+ var button = _ref.button,
28
+ className = _ref.className,
29
+ description = _ref.description,
30
+ title = _ref.title,
31
+ rest = _objectWithoutProperties(_ref, _excluded);
32
+ return /*#__PURE__*/React.createElement("div", _extends({}, rest, {
33
+ className: cx(blockClass, className)
34
+ }, getDevtoolsProps(componentName)), title && /*#__PURE__*/React.createElement("h2", {
35
+ className: "".concat(blockClass, "-title")
36
+ }, title), description && /*#__PURE__*/React.createElement("p", {
37
+ className: "".concat(blockClass, "-content")
38
+ }, description), button && /*#__PURE__*/React.createElement("div", {
39
+ className: "".concat(blockClass, "-buttons")
40
+ }, button));
41
+ };
42
+
43
+ // Return a placeholder if not released and not enabled by feature flag
44
+ GuidebannerElement = pkg.checkComponentEnabled(GuidebannerElement, componentName);
45
+
46
+ // The display name of the component, used by React. Note that displayName
47
+ // is used in preference to relying on function.name.
48
+ GuidebannerElement.displayName = componentName;
49
+
50
+ // The types and DocGen commentary for the component props,
51
+ // in alphabetical order (for consistency).
52
+ // See https://www.npmjs.com/package/prop-types#usage.
53
+ GuidebannerElement.propTypes = {
54
+ /**
55
+ * An optional button can be rendered below the description.
56
+ * This can be a link, button, Coachmark button, etc.
57
+ */
58
+ button: PropTypes.node,
59
+ /**
60
+ * Provide an optional class to be applied to the containing node.
61
+ */
62
+ className: PropTypes.string,
63
+ /**
64
+ * The description of the element.
65
+ */
66
+
67
+ description: PropTypes.oneOfType([PropTypes.string, PropTypes.node]).isRequired,
68
+ /**
69
+ * The title of the element.
70
+ */
71
+ title: PropTypes.string
72
+ };