@carbon/ibm-products 1.60.0 → 1.61.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. package/css/index-full-carbon.css +57 -37
  2. package/css/index-full-carbon.css.map +1 -1
  3. package/css/index-full-carbon.min.css +4 -4
  4. package/css/index-full-carbon.min.css.map +1 -1
  5. package/css/index-without-carbon-released-only.css +9 -3
  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 +47 -22
  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 +47 -37
  14. package/css/index.css.map +1 -1
  15. package/css/index.min.css +4 -4
  16. package/css/index.min.css.map +1 -1
  17. package/es/components/Datagrid/Datagrid/DatagridContent.js +3 -1
  18. package/es/components/Datagrid/Datagrid/DatagridHeaderRow.js +10 -54
  19. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/DraggableItemsList.js +9 -8
  20. package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditButton/InlineEditButton.js +6 -12
  21. package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditCell/InlineEditCell.js +0 -5
  22. package/es/components/Datagrid/Datagrid/addons/RowSize/RowSizeDropdown.js +17 -5
  23. package/es/components/Datagrid/Datagrid/addons/RowSize/RowSizeRadioGroup.js +4 -3
  24. package/es/components/Datagrid/Datagrid/addons/stateReducer.js +37 -24
  25. package/es/components/Datagrid/useColumnCenterAlign.js +6 -6
  26. package/es/components/Datagrid/useColumnRightAlign.js +6 -6
  27. package/es/components/Datagrid/useInlineEdit.js +1 -6
  28. package/es/components/Datagrid/useNestedRowExpander.js +10 -1
  29. package/es/components/Datagrid/useRowExpander.js +11 -1
  30. package/es/components/Datagrid/useSortableColumns.js +6 -5
  31. package/es/components/FilterSummary/FilterSummary.js +6 -2
  32. package/es/components/Guidebanner/Guidebanner.js +3 -3
  33. package/es/components/Guidebanner/GuidebannerElement.js +9 -3
  34. package/es/components/Guidebanner/GuidebannerElementButton.js +9 -4
  35. package/es/components/Guidebanner/GuidebannerElementLink.js +9 -3
  36. package/es/components/InlineTip/InlineTipButton.js +7 -0
  37. package/es/components/InlineTip/InlineTipLink.js +7 -0
  38. package/es/components/TagSet/TagSet.js +11 -3
  39. package/es/components/TagSet/TagSetOverflow.js +16 -5
  40. package/es/components/index.js +2 -2
  41. package/es/global/js/package-settings.js +5 -0
  42. package/es/global/js/utils/getNodeTextContent.js +51 -0
  43. package/lib/components/Datagrid/Datagrid/DatagridContent.js +3 -1
  44. package/lib/components/Datagrid/Datagrid/DatagridHeaderRow.js +9 -54
  45. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/DraggableItemsList.js +9 -8
  46. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditButton/InlineEditButton.js +6 -12
  47. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditCell/InlineEditCell.js +0 -5
  48. package/lib/components/Datagrid/Datagrid/addons/RowSize/RowSizeDropdown.js +15 -3
  49. package/lib/components/Datagrid/Datagrid/addons/RowSize/RowSizeRadioGroup.js +7 -3
  50. package/lib/components/Datagrid/Datagrid/addons/stateReducer.js +38 -33
  51. package/lib/components/Datagrid/useInlineEdit.js +1 -6
  52. package/lib/components/Datagrid/useNestedRowExpander.js +10 -9
  53. package/lib/components/Datagrid/useRowExpander.js +11 -9
  54. package/lib/components/Datagrid/useSortableColumns.js +6 -5
  55. package/lib/components/FilterSummary/FilterSummary.js +6 -2
  56. package/lib/components/Guidebanner/Guidebanner.js +3 -3
  57. package/lib/components/Guidebanner/GuidebannerElement.js +8 -1
  58. package/lib/components/Guidebanner/GuidebannerElementButton.js +8 -1
  59. package/lib/components/Guidebanner/GuidebannerElementLink.js +8 -1
  60. package/lib/components/InlineTip/InlineTipButton.js +8 -1
  61. package/lib/components/InlineTip/InlineTipLink.js +8 -1
  62. package/lib/components/TagSet/TagSet.js +11 -3
  63. package/lib/components/TagSet/TagSetOverflow.js +16 -5
  64. package/lib/components/index.js +30 -0
  65. package/lib/global/js/package-settings.js +5 -0
  66. package/lib/global/js/utils/getNodeTextContent.js +59 -0
  67. package/package.json +4 -4
  68. package/scss/components/CoachmarkBeacon/_coachmark-beacon.scss +0 -15
  69. package/scss/components/Datagrid/_datagrid.scss +1 -0
  70. package/scss/components/Datagrid/_storybook-styles.scss +15 -0
  71. package/scss/components/Datagrid/styles/_useInlineEdit.scss +7 -11
  72. package/scss/components/Datagrid/styles/addons/_RowSizeDropdown.scss +42 -1
  73. package/scss/components/TagSet/_tag-set.scss +13 -3
  74. package/es/components/Datagrid/utils/getColTitle.js +0 -25
  75. package/lib/components/Datagrid/utils/getColTitle.js +0 -32
@@ -26,7 +26,9 @@ var FilterSummary = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
26
26
  _ref$filters = _ref.filters,
27
27
  filters = _ref$filters === void 0 ? [] : _ref$filters,
28
28
  _ref$renderLabel = _ref.renderLabel,
29
- renderLabel = _ref$renderLabel === void 0 ? null : _ref$renderLabel;
29
+ renderLabel = _ref$renderLabel === void 0 ? null : _ref$renderLabel,
30
+ _ref$overflowType = _ref.overflowType,
31
+ overflowType = _ref$overflowType === void 0 ? 'default' : _ref$overflowType;
30
32
  var tagFilters = filters.map(function (_ref2) {
31
33
  var _renderLabel;
32
34
  var key = _ref2.key,
@@ -45,7 +47,8 @@ var FilterSummary = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
45
47
  allTagsModalSearchPlaceholderText: "Search all tags",
46
48
  allTagsModalTitle: "All tags",
47
49
  showAllTagsLabel: "View all tags",
48
- tags: tagFilters
50
+ tags: tagFilters,
51
+ overflowType: overflowType
49
52
  }), /*#__PURE__*/React.createElement(Button, {
50
53
  kind: "ghost",
51
54
  size: "sm",
@@ -59,6 +62,7 @@ FilterSummary.propTypes = {
59
62
  clearFilters: PropTypes.func.isRequired,
60
63
  clearFiltersText: PropTypes.string,
61
64
  filters: PropTypes.arrayOf(PropTypes.object).isRequired,
65
+ overflowType: PropTypes.oneOf(['default', 'tag']),
62
66
  renderLabel: PropTypes.func
63
67
  };
64
68
  export default FilterSummary;
@@ -176,12 +176,12 @@ Guidebanner.propTypes = {
176
176
  error = new Error('`Guidebanner` requires one or more children of type `GuidebannerElement`.');
177
177
  }
178
178
  React.Children.forEach(prop, function (child) {
179
- if (child.type.name !== 'GuidebannerElement') {
180
- var _child$type;
179
+ if (child.type.displayName !== 'GuidebannerElement') {
180
+ var _child$type, _child$type2;
181
181
  // If not GuidebannerElement, then show:
182
182
  // React component name(child.type?.name) or
183
183
  // HTML element name(child.type).
184
- 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.name) || child.type, "` instead."));
184
+ 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."));
185
185
  }
186
186
  });
187
187
  return error;
@@ -28,7 +28,7 @@ var componentName = 'GuidebannerElement';
28
28
  * The GuidebannerElement is a required child component of the Guidebanner,
29
29
  * and acts as a container for a CarouselItem.
30
30
  */
31
- var GuidebannerElement = function GuidebannerElement(_ref) {
31
+ export var GuidebannerElement = function GuidebannerElement(_ref) {
32
32
  var button = _ref.button,
33
33
  className = _ref.className,
34
34
  description = _ref.description,
@@ -45,6 +45,13 @@ var GuidebannerElement = function GuidebannerElement(_ref) {
45
45
  }, button));
46
46
  };
47
47
 
48
+ // Return a placeholder if not released and not enabled by feature flag
49
+ GuidebannerElement = pkg.checkComponentEnabled(GuidebannerElement, componentName);
50
+
51
+ // The display name of the component, used by React. Note that displayName
52
+ // is used in preference to relying on function.name.
53
+ GuidebannerElement.displayName = componentName;
54
+
48
55
  // The types and DocGen commentary for the component props,
49
56
  // in alphabetical order (for consistency).
50
57
  // See https://www.npmjs.com/package/prop-types#usage.
@@ -67,5 +74,4 @@ GuidebannerElement.propTypes = {
67
74
  * The title of the element.
68
75
  */
69
76
  title: PropTypes.string
70
- };
71
- export { GuidebannerElement };
77
+ };
@@ -29,7 +29,7 @@ var componentName = 'GuidebannerElementButton';
29
29
  /**
30
30
  * One of two buttons styled specifically for the GuidebannerElement.
31
31
  */
32
- var GuidebannerElementButton = function GuidebannerElementButton(_ref) {
32
+ export var GuidebannerElementButton = function GuidebannerElementButton(_ref) {
33
33
  var children = _ref.children,
34
34
  className = _ref.className,
35
35
  type = _ref.type,
@@ -52,6 +52,13 @@ var GuidebannerElementButton = function GuidebannerElementButton(_ref) {
52
52
  }, getDevtoolsProps(componentName)), children);
53
53
  };
54
54
 
55
+ // Return a placeholder if not released and not enabled by feature flag
56
+ GuidebannerElementButton = pkg.checkComponentEnabled(GuidebannerElementButton, componentName);
57
+
58
+ // The display name of the component, used by React. Note that displayName
59
+ // is used in preference to relying on function.name.
60
+ GuidebannerElementButton.displayName = componentName;
61
+
55
62
  // The types and DocGen commentary for the component props,
56
63
  // in alphabetical order (for consistency).
57
64
  // See https://www.npmjs.com/package/prop-types#usage.
@@ -71,6 +78,4 @@ GuidebannerElementButton.propTypes = {
71
78
  type: PropTypes.string
72
79
 
73
80
  /* TODO: add types and DocGen for all props. */
74
- };
75
-
76
- export { GuidebannerElementButton };
81
+ };
@@ -28,7 +28,7 @@ var componentName = 'GuidebannerElementLink';
28
28
  /**
29
29
  * A link styled specifically for the GuidebannerElement.
30
30
  */
31
- var GuidebannerElementLink = function GuidebannerElementLink(_ref) {
31
+ export var GuidebannerElementLink = function GuidebannerElementLink(_ref) {
32
32
  var children = _ref.children,
33
33
  className = _ref.className,
34
34
  rest = _objectWithoutProperties(_ref, _excluded);
@@ -40,6 +40,13 @@ var GuidebannerElementLink = function GuidebannerElementLink(_ref) {
40
40
  }, getDevtoolsProps(componentName)), children);
41
41
  };
42
42
 
43
+ // Return a placeholder if not released and not enabled by feature flag
44
+ GuidebannerElementLink = pkg.checkComponentEnabled(GuidebannerElementLink, 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
+ GuidebannerElementLink.displayName = componentName;
49
+
43
50
  // The types and DocGen commentary for the component props,
44
51
  // in alphabetical order (for consistency).
45
52
  // See https://www.npmjs.com/package/prop-types#usage.
@@ -52,5 +59,4 @@ GuidebannerElementLink.propTypes = {
52
59
  * Provide an optional class to be applied to the containing node.
53
60
  */
54
61
  className: PropTypes.string
55
- };
56
- export { GuidebannerElementLink };
62
+ };
@@ -65,6 +65,13 @@ export var InlineTipButton = /*#__PURE__*/React.forwardRef(function (_ref, ref)
65
65
  }), children);
66
66
  });
67
67
 
68
+ // Return a placeholder if not released and not enabled by feature flag
69
+ InlineTipButton = pkg.checkComponentEnabled(InlineTipButton, componentName);
70
+
71
+ // The display name of the component, used by React. Note that displayName
72
+ // is used in preference to relying on function.name.
73
+ InlineTipButton.displayName = componentName;
74
+
68
75
  // The types and DocGen commentary for the component props,
69
76
  // in alphabetical order (for consistency).
70
77
  // See https://www.npmjs.com/package/prop-types#usage.
@@ -65,6 +65,13 @@ export var InlineTipLink = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
65
65
  }), children);
66
66
  });
67
67
 
68
+ // Return a placeholder if not released and not enabled by feature flag
69
+ InlineTipLink = pkg.checkComponentEnabled(InlineTipLink, componentName);
70
+
71
+ // The display name of the component, used by React. Note that displayName
72
+ // is used in preference to relying on function.name.
73
+ InlineTipLink.displayName = componentName;
74
+
68
75
  // The types and DocGen commentary for the component props,
69
76
  // in alphabetical order (for consistency).
70
77
  // See https://www.npmjs.com/package/prop-types#usage.
@@ -2,7 +2,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import _extends from "@babel/runtime/helpers/extends";
3
3
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
4
4
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
5
- var _excluded = ["align", "allTagsModalTarget", "className", "maxVisible", "multiline", "overflowAlign", "overflowClassName", "overflowDirection", "allTagsModalTitle", "allTagsModalSearchLabel", "allTagsModalSearchPlaceholderText", "showAllTagsLabel", "tags"],
5
+ var _excluded = ["align", "allTagsModalTarget", "className", "maxVisible", "multiline", "overflowAlign", "overflowClassName", "overflowType", "overflowDirection", "allTagsModalTitle", "allTagsModalSearchLabel", "allTagsModalSearchPlaceholderText", "showAllTagsLabel", "tags"],
6
6
  _excluded2 = ["label", "id"],
7
7
  _excluded3 = ["label"];
8
8
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
@@ -34,7 +34,8 @@ var defaults = {
34
34
  align: 'start',
35
35
  // allTagsModalTarget: document.body,
36
36
  overflowAlign: 'center',
37
- overflowDirection: 'bottom'
37
+ overflowDirection: 'bottom',
38
+ overflowType: 'default'
38
39
  };
39
40
  export var TagSet = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
40
41
  var _ref$align = _ref.align,
@@ -46,6 +47,8 @@ export var TagSet = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
46
47
  _ref$overflowAlign = _ref.overflowAlign,
47
48
  overflowAlign = _ref$overflowAlign === void 0 ? defaults.overflowAlign : _ref$overflowAlign,
48
49
  overflowClassName = _ref.overflowClassName,
50
+ _ref$overflowType = _ref.overflowType,
51
+ overflowType = _ref$overflowType === void 0 ? defaults.overflowType : _ref$overflowType,
49
52
  _ref$overflowDirectio = _ref.overflowDirection,
50
53
  overflowDirection = _ref$overflowDirectio === void 0 ? defaults.overflowDirection : _ref$overflowDirectio,
51
54
  allTagsModalTitle = _ref.allTagsModalTitle,
@@ -141,13 +144,14 @@ export var TagSet = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
141
144
  onShowAllClick: handleShowAllClick,
142
145
  overflowTags: newOverflowTags,
143
146
  overflowAlign: overflowAlign,
147
+ overflowType: overflowType,
144
148
  overflowDirection: overflowDirection,
145
149
  showAllTagsLabel: showAllTagsLabel,
146
150
  key: "displayed-tag-overflow",
147
151
  ref: overflowTag
148
152
  }));
149
153
  setDisplayedTags(newDisplayedTags);
150
- }, [displayCount, overflowAlign, overflowClassName, overflowDirection, showAllTagsLabel, tags]);
154
+ }, [displayCount, overflowAlign, overflowType, overflowClassName, overflowDirection, showAllTagsLabel, tags]);
151
155
  var checkFullyVisibleTags = useCallback(function () {
152
156
  if (multiline) {
153
157
  return setDisplayCount(maxVisible);
@@ -300,6 +304,10 @@ TagSet.propTypes = {
300
304
  * overflowDirection from the standard tooltip
301
305
  */
302
306
  overflowDirection: PropTypes.oneOf(['top', 'right', 'bottom', 'left']),
307
+ /**
308
+ * Type of rendering displayed inside of the tag overflow component
309
+ */
310
+ overflowType: PropTypes.oneOf(['default', 'tag']),
303
311
  /**
304
312
  * label for the overflow show all tags link.
305
313
  *
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/extends";
2
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
3
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
4
4
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
5
- var _excluded = ["allTagsModalSearchThreshold", "className", "onShowAllClick", "overflowAlign", "overflowDirection", "overflowTags", "showAllTagsLabel"];
5
+ var _excluded = ["allTagsModalSearchThreshold", "className", "onShowAllClick", "overflowAlign", "overflowDirection", "overflowTags", "overflowType", "showAllTagsLabel"];
6
6
  //
7
7
  // Copyright IBM Corp. 2021, 2021
8
8
  //
@@ -35,6 +35,7 @@ export var TagSetOverflow = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
35
35
  _ref$overflowDirectio = _ref.overflowDirection,
36
36
  overflowDirection = _ref$overflowDirectio === void 0 ? defaults.overflowDirection : _ref$overflowDirectio,
37
37
  overflowTags = _ref.overflowTags,
38
+ overflowType = _ref.overflowType,
38
39
  showAllTagsLabel = _ref.showAllTagsLabel,
39
40
  rest = _objectWithoutProperties(_ref, _excluded);
40
41
  var _useState = useState(false),
@@ -78,12 +79,18 @@ export var TagSetOverflow = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
78
79
  }, overflowTags.filter(function (_, index) {
79
80
  return overflowTags.length > allTagsModalSearchThreshold ? index < allTagsModalSearchThreshold : index <= allTagsModalSearchThreshold;
80
81
  }).map(function (tag, index) {
82
+ var _cx2;
83
+ var tagProps = {};
84
+ if (overflowType === 'tag') {
85
+ tagProps.type = 'high-contrast';
86
+ }
87
+ if (overflowType === 'default') {
88
+ tagProps.filter = false;
89
+ }
81
90
  return /*#__PURE__*/React.createElement("li", {
82
- className: "".concat(blockClass, "__tag-item"),
91
+ className: cx("".concat(blockClass, "__tag-item"), (_cx2 = {}, _defineProperty(_cx2, "".concat(blockClass, "__tag-item--default"), overflowType === 'default'), _defineProperty(_cx2, "".concat(blockClass, "__tag-item--tag"), overflowType === 'tag'), _cx2)),
83
92
  key: index
84
- }, /*#__PURE__*/React.cloneElement(tag, {
85
- filter: false
86
- }));
93
+ }, /*#__PURE__*/React.cloneElement(tag, tagProps));
87
94
  })), overflowTags.length > allTagsModalSearchThreshold && /*#__PURE__*/React.createElement(Link, {
88
95
  className: "".concat(blockClass, "__show-all-tags-link"),
89
96
  href: "",
@@ -117,6 +124,10 @@ TagSetOverflow.propTypes = {
117
124
  * tags shown in overflow
118
125
  */
119
126
  overflowTags: PropTypes.arrayOf(PropTypes.object).isRequired,
127
+ /**
128
+ * Type of rendering displayed inside of the tag overflow component
129
+ */
130
+ overflowType: PropTypes.oneOf(['default', 'tag']),
120
131
  /**
121
132
  * label for the overflow show all tags link
122
133
  */
@@ -44,7 +44,7 @@ export { EditFullPage } from './EditFullPage';
44
44
  export { EditUpdateCards } from './EditUpdateCards';
45
45
  export { InlineEdit } from './InlineEdit';
46
46
  export { EditInPlace } from './EditInPlace';
47
- export { Guidebanner } from './Guidebanner';
47
+ export { Guidebanner, GuidebannerElement, GuidebannerElementButton, GuidebannerElementLink } from './Guidebanner';
48
48
  export { NonLinearReading } from './NonLinearReading';
49
49
  export { Coachmark } from './Coachmark';
50
50
  export { CoachmarkFixed } from './CoachmarkFixed';
@@ -53,5 +53,5 @@ export { CoachmarkButton } from './CoachmarkButton';
53
53
  export { CoachmarkOverlayElements } from './CoachmarkOverlayElements';
54
54
  export { CoachmarkOverlayElement } from './CoachmarkOverlayElement';
55
55
  export { CoachmarkStack } from './CoachmarkStack';
56
- export { InlineTip } from './InlineTip';
56
+ export { InlineTip, InlineTipButton, InlineTipLink } from './InlineTip';
57
57
  export { Checklist } from './Checklist';
@@ -73,7 +73,12 @@ var defaults = {
73
73
  ButtonMenu: false,
74
74
  // Novice to pro components not yet reviewed and released:
75
75
  InlineTip: false,
76
+ InlineTipButton: false,
77
+ InlineTipLink: false,
76
78
  Guidebanner: false,
79
+ GuidebannerElement: false,
80
+ GuidebannerElementButton: false,
81
+ GuidebannerElementLink: false,
77
82
  NonLinearReading: false,
78
83
  Checklist: false,
79
84
  Coachmark: false,
@@ -0,0 +1,51 @@
1
+ import _typeof from "@babel/runtime/helpers/typeof";
2
+ /**
3
+ * Copyright IBM Corp. 2023, 2023
4
+ *
5
+ * This source code is licensed under the Apache-2.0 license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+
9
+ /**
10
+ * Returns a compiled string of all the text content of a React node and any of its child nodes.
11
+ * This is meant to be used in a limited fashion to convert a "styled" sentence into a single string:
12
+ * e.g. <p>Title <b>Page</b>.</p> --> "Title Page."
13
+ * This will likely not work for arrays of nodes due to the lack of word spacing:
14
+ * e.g. <ul>
15
+ * <li>Item 1</li>
16
+ * <li>Item 2</li>
17
+ * <li>Item 3</li>
18
+ * </ul>
19
+ * --> "Item 1Item 2Item 3"
20
+ * @param {Node} node A React node
21
+ * @returns {string}
22
+ */
23
+ export var getNodeTextContent = function getNodeTextContent(node) {
24
+ if (node == null) {
25
+ return '';
26
+ }
27
+ switch (_typeof(node)) {
28
+ case 'string':
29
+ case 'number':
30
+ return node.toString();
31
+ case 'object':
32
+ {
33
+ if (node instanceof Array) {
34
+ return node.map(getNodeTextContent).join('');
35
+ }
36
+ if ('props' in node) {
37
+ return getNodeTextContent(node.props.children);
38
+ }
39
+
40
+ // Ignore any other JavaScript 'object' types.
41
+ return '';
42
+ }
43
+ case 'function':
44
+ {
45
+ return getNodeTextContent(node());
46
+ }
47
+ default:
48
+ // Ignore all other JavaScript types.
49
+ return '';
50
+ }
51
+ };
@@ -149,7 +149,9 @@ var DatagridContent = function DatagridContent(_ref) {
149
149
  filters: filterTags,
150
150
  clearFilters: function clearFilters() {
151
151
  return EventEmitter.dispatch(_constants.CLEAR_FILTERS);
152
- }
152
+ },
153
+ renderLabel: filterProps.renderLabel,
154
+ overflowType: "tag"
153
155
  });
154
156
  };
155
157
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(TableContainer, {
@@ -16,7 +16,7 @@ var _layout = require("@carbon/layout");
16
16
  var _commonColumnIds = require("../common-column-ids");
17
17
  var _settings = require("../../../settings");
18
18
  var _stateReducer = require("./addons/stateReducer");
19
- var _getColTitle = _interopRequireDefault(require("../utils/getColTitle"));
19
+ var _getNodeTextContent = require("../../../global/js/utils/getNodeTextContent");
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
  /**
@@ -26,12 +26,10 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
26
26
  * LICENSE file in the root directory of this source tree.
27
27
  */
28
28
 
29
- // @flow
30
-
31
29
  var blockClass = "".concat(_settings.pkg.prefix, "--datagrid");
32
30
  var getAccessibilityProps = function getAccessibilityProps(header) {
33
31
  var props = {};
34
- var title = (0, _getColTitle.default)(header);
32
+ var title = (0, _getNodeTextContent.getNodeTextContent)(header.Header);
35
33
  if (title) {
36
34
  props.title = title;
37
35
  } else {
@@ -69,38 +67,6 @@ var HeaderRow = function HeaderRow(datagridState, headRef, headerGroup) {
69
67
  var _useState = (0, _react.useState)(2),
70
68
  _useState2 = (0, _slicedToArray2.default)(_useState, 1),
71
69
  incrementAmount = _useState2[0];
72
- var getClientXPosition = function getClientXPosition(event) {
73
- var isTouchEvent = false;
74
- if (event.type === 'touchstart') {
75
- // Do not respond to multiple touches (e.g. 2 or 3 fingers)
76
- if (event.touches && event.touches.length > 1) {
77
- return;
78
- }
79
- isTouchEvent = true;
80
- }
81
- var clientX = isTouchEvent ? Math.round(event.touches[0].clientX) : event.clientX;
82
- var closestHeader = event.target.closest('th');
83
- var closestHeaderCoords = closestHeader.getBoundingClientRect();
84
- var headerOffset = closestHeaderCoords.left;
85
- var offsetValue = clientX - headerOffset;
86
- return offsetValue;
87
- };
88
- (0, _react.useEffect)(function () {
89
- var isResizing = datagridState.state.isResizing;
90
- if (isResizing) {
91
- var onColResizeEnd = datagridState.onColResizeEnd;
92
- document.addEventListener('mouseup', function () {
93
- (0, _stateReducer.handleColumnResizeEndEvent)(datagridState.dispatch, onColResizeEnd, isResizing);
94
- document.activeElement.blur();
95
- });
96
- }
97
- return function () {
98
- document.removeEventListener('mouseup', function () {
99
- return (0, _stateReducer.handleColumnResizeEndEvent)(datagridState.dispatch);
100
- });
101
- };
102
- // eslint-disable-next-line react-hooks/exhaustive-deps
103
- }, [datagridState.state.isResizing]);
104
70
  return /*#__PURE__*/_react.default.createElement(TableRow, (0, _extends2.default)({}, headerGroup.getHeaderGroupProps({
105
71
  role: false
106
72
  }), {
@@ -123,32 +89,21 @@ var HeaderRow = function HeaderRow(datagridState, headRef, headerGroup) {
123
89
  state = datagridState.state,
124
90
  dispatch = datagridState.dispatch,
125
91
  onColResizeEnd = datagridState.onColResizeEnd;
126
- var columnResizing = state.columnResizing,
127
- isResizing = state.isResizing;
92
+ var columnResizing = state.columnResizing;
128
93
  var columnWidths = columnResizing.columnWidths;
129
94
  var originalCol = visibleColumns[index];
130
95
  return /*#__PURE__*/_react.default.createElement(TableHeader, (0, _extends2.default)({}, header.getHeaderProps({
131
96
  role: false
132
97
  }), {
133
- className: (0, _classnames.default)((_cx = {}, (0, _defineProperty2.default)(_cx, "".concat(blockClass, "__resizableColumn"), header.getResizerProps), (0, _defineProperty2.default)(_cx, "".concat(blockClass, "__isResizing"), header.isResizing), (0, _defineProperty2.default)(_cx, "".concat(blockClass, "__sortableColumn"), datagridState.isTableSortable), (0, _defineProperty2.default)(_cx, "".concat(blockClass, "__isSorted"), header.isSorted), _cx), header.getHeaderProps().className),
134
- key: header.id
98
+ className: (0, _classnames.default)((_cx = {}, (0, _defineProperty2.default)(_cx, "".concat(blockClass, "__resizableColumn"), header.getResizerProps), (0, _defineProperty2.default)(_cx, "".concat(blockClass, "__isResizing"), header.isResizing), (0, _defineProperty2.default)(_cx, "".concat(blockClass, "__sortableColumn"), datagridState.isTableSortable && header.id !== 'spacer'), (0, _defineProperty2.default)(_cx, "".concat(blockClass, "__isSorted"), header.isSorted), _cx), header.getHeaderProps().className),
99
+ key: header.id,
100
+ "aria-hidden": header.id === 'spacer' && 'true'
135
101
  }, getAccessibilityProps(header)), header.render('Header'), header.getResizerProps && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("input", (0, _extends2.default)({}, header.getResizerProps(), {
136
- onMouseMove: function onMouseMove(event) {
137
- if (isResizing) {
138
- var newWidth = getClientXPosition(event);
139
- // Sets a min width for resizing so at least one character from the column header is visible
140
- if (newWidth >= 50) {
141
- (0, _stateReducer.handleColumnResizingEvent)(dispatch, header, newWidth);
142
- }
143
- }
144
- },
145
- onMouseDown: function onMouseDown() {
146
- return (0, _stateReducer.handleColumnResizeStartEvent)(dispatch, header.id);
147
- },
148
102
  onKeyDown: function onKeyDown(event) {
149
103
  var key = event.key;
150
104
  if (key === 'ArrowLeft' || key === 'ArrowRight') {
151
- var currentColumnWidth = columnWidths[header.id] || (datagridState.isTableSortable && originalCol.width < 90 ? 90 : originalCol.width);
105
+ var originalColMinWidth = originalCol.minWidth || 90;
106
+ var currentColumnWidth = columnWidths[header.id] || (datagridState.isTableSortable && originalCol.width < originalColMinWidth ? originalColMinWidth : originalCol.width);
152
107
  if (key === 'ArrowLeft') {
153
108
  if (currentColumnWidth - incrementAmount > Math.max(minWidth, 50)) {
154
109
  var newWidth = currentColumnWidth - incrementAmount;
@@ -162,7 +117,7 @@ var HeaderRow = function HeaderRow(datagridState, headRef, headerGroup) {
162
117
  }
163
118
  },
164
119
  onKeyUp: function onKeyUp() {
165
- return (0, _stateReducer.handleColumnResizeEndEvent)(dispatch, onColResizeEnd, header.id);
120
+ return (0, _stateReducer.handleColumnResizeEndEvent)(dispatch, onColResizeEnd, header.id, true);
166
121
  },
167
122
  className: (0, _classnames.default)("".concat(blockClass, "__col-resizer-range")),
168
123
  type: "range",
@@ -12,7 +12,7 @@ var _carbonComponentsReact = require("carbon-components-react");
12
12
  var _common = require("./common");
13
13
  var _DraggableElement = _interopRequireDefault(require("../../DraggableElement"));
14
14
  var _settings = require("../../../../../settings");
15
- var _getColTitle2 = _interopRequireDefault(require("../../../utils/getColTitle"));
15
+ var _getNodeTextContent = require("../../../../../global/js/utils/getNodeTextContent");
16
16
  var _core = require("@dnd-kit/core");
17
17
  var _sortable = require("@dnd-kit/sortable");
18
18
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
@@ -32,12 +32,13 @@ var DraggableItemsList = function DraggableItemsList(_ref) {
32
32
  var visibleCols = columns
33
33
  // hide the columns without Header, e.g the sticky actions, spacer
34
34
  .filter(function (colDef) {
35
- return !!(0, _getColTitle2.default)(colDef);
35
+ return (0, _getNodeTextContent.getNodeTextContent)(colDef.Header).trim().length !== 0;
36
36
  }).filter(Boolean).filter(function (colDef) {
37
37
  return !colDef.isAction;
38
38
  }).filter(function (colDef) {
39
- var _getColTitle;
40
- return filterString.length === 0 || ((_getColTitle = (0, _getColTitle2.default)(colDef)) === null || _getColTitle === void 0 ? void 0 : _getColTitle.toLowerCase().includes(filterString)) && colDef.id !== 'spacer';
39
+ return colDef.id !== 'spacer';
40
+ }).filter(function (colDef) {
41
+ return filterString.length === 0 || (0, _getNodeTextContent.getNodeTextContent)(colDef.Header).toLowerCase().includes(filterString);
41
42
  });
42
43
 
43
44
  // let localRefCopy;
@@ -50,7 +51,7 @@ var DraggableItemsList = function DraggableItemsList(_ref) {
50
51
  var toVisibleIndex = columns.findIndex(function (col) {
51
52
  return matchedColsById(col, over);
52
53
  });
53
- var colTitle = (0, _getColTitle2.default)(visibleCols[fromVisibleIndex]);
54
+ var colTitle = (0, _getNodeTextContent.getNodeTextContent)(visibleCols[fromVisibleIndex].Header);
54
55
  setAriaRegionText("".concat(colTitle, " dropped. New position ").concat(toVisibleIndex + 1, " of ").concat(visibleCols.length, "."));
55
56
  var fromIndex = columns.findIndex(function (col) {
56
57
  return matchedColsById(col, active);
@@ -65,7 +66,7 @@ var DraggableItemsList = function DraggableItemsList(_ref) {
65
66
  var fromIndex = visibleCols.findIndex(function (col) {
66
67
  return matchedColsById(col, active);
67
68
  });
68
- var colTitle = (0, _getColTitle2.default)(visibleCols[fromIndex]);
69
+ var colTitle = (0, _getNodeTextContent.getNodeTextContent)(visibleCols[fromIndex].Header);
69
70
  setAriaRegionText("".concat(colTitle, " grabbed. Current position ").concat(fromIndex + 1, " of ").concat(visibleCols.length, "."));
70
71
  };
71
72
  var handleDragUpdate = function handleDragUpdate(event) {
@@ -77,7 +78,7 @@ var DraggableItemsList = function DraggableItemsList(_ref) {
77
78
  var toIndex = visibleCols.findIndex(function (col) {
78
79
  return matchedColsById(col, over);
79
80
  });
80
- var colTitle = (0, _getColTitle2.default)(visibleCols[fromIndex]);
81
+ var colTitle = (0, _getNodeTextContent.getNodeTextContent)(visibleCols[fromIndex].Header);
81
82
  setAriaRegionText("".concat(colTitle, " grabbed. Original position ").concat(fromIndex + 1, ", new position ").concat(toIndex + 1, " of ").concat(visibleCols.length, "."));
82
83
  };
83
84
  var pointerSensor = (0, _core.useSensor)(_core.PointerSensor, {
@@ -140,7 +141,7 @@ var DraggableItemsList = function DraggableItemsList(_ref) {
140
141
  items: visibleCols,
141
142
  strategy: _sortable.verticalListSortingStrategy
142
143
  }, visibleCols.map(function (colDef) {
143
- var colHeaderTitle = (0, _getColTitle2.default)(colDef);
144
+ var colHeaderTitle = (0, _getNodeTextContent.getNodeTextContent)(colDef.Header);
144
145
  var searchString = new RegExp('(' + filterString + ')');
145
146
  var res = filterString.length ? colHeaderTitle.toLowerCase().split(searchString) : null;
146
147
  var firstWord = res !== null ? res[0] === '' ? res[1].charAt(0).toUpperCase() + res[1].substring(1) : res[0].charAt(0).toUpperCase() + res[0].substring(1) : null;
@@ -10,12 +10,11 @@ var _react = _interopRequireDefault(require("react"));
10
10
  var _classnames = _interopRequireDefault(require("classnames"));
11
11
  var _propTypes = _interopRequireDefault(require("prop-types"));
12
12
  var _settings = require("../../../../../../settings");
13
- /*
14
- * Licensed Materials - Property of IBM
15
- * 5724-Q36
16
- * (c) Copyright IBM Corp. 2022
17
- * US Government Users Restricted Rights - Use, duplication or disclosure
18
- * restricted by GSA ADP Schedule Contract with IBM Corp.
13
+ /**
14
+ * Copyright IBM Corp. 2022, 2023
15
+ *
16
+ * This source code is licensed under the Apache-2.0 license found in the
17
+ * LICENSE file in the root directory of this source tree.
19
18
  */
20
19
 
21
20
  var blockClass = "".concat(_settings.pkg.prefix, "--datagrid");
@@ -29,12 +28,9 @@ var InlineEditButton = function InlineEditButton(_ref) {
29
28
  nonEditCell = _ref.nonEditCell,
30
29
  isActiveCell = _ref.isActiveCell,
31
30
  columnConfig = _ref.columnConfig,
32
- totalInlineEditColumns = _ref.totalInlineEditColumns,
33
- totalColumns = _ref.totalColumns,
34
31
  type = _ref.type;
35
- var inlineEditColsLessThanHalfOfTotal = totalInlineEditColumns < totalColumns / 2;
36
32
  return /*#__PURE__*/_react.default.createElement("div", {
37
- className: (0, _classnames.default)("".concat(blockClass, "__inline-edit-button"), (_cx = {}, (0, _defineProperty2.default)(_cx, "".concat(blockClass, "__inline-edit-button--disabled"), disabled || nonEditCell), (0, _defineProperty2.default)(_cx, "".concat(blockClass, "__inline-edit-button--with-label-icon"), LabelIcon), (0, _defineProperty2.default)(_cx, "".concat(blockClass, "__inline-edit-button--non-edit"), nonEditCell), (0, _defineProperty2.default)(_cx, "".concat(blockClass, "__inline-edit-button--active"), isActiveCell), (0, _defineProperty2.default)(_cx, "".concat(blockClass, "__inline-edit-button--edit-less-than-half-of-total-cols"), inlineEditColsLessThanHalfOfTotal), (0, _defineProperty2.default)(_cx, "".concat(blockClass, "__inline-edit-button--").concat(type), type === 'date' || type === 'selection'), _cx)),
33
+ className: (0, _classnames.default)("".concat(blockClass, "__inline-edit-button"), (_cx = {}, (0, _defineProperty2.default)(_cx, "".concat(blockClass, "__inline-edit-button--disabled"), disabled || nonEditCell), (0, _defineProperty2.default)(_cx, "".concat(blockClass, "__inline-edit-button--with-label-icon"), LabelIcon), (0, _defineProperty2.default)(_cx, "".concat(blockClass, "__inline-edit-button--non-edit"), nonEditCell), (0, _defineProperty2.default)(_cx, "".concat(blockClass, "__inline-edit-button--active"), isActiveCell), (0, _defineProperty2.default)(_cx, "".concat(blockClass, "__inline-edit-button--").concat(type), type === 'date' || type === 'selection'), _cx)),
38
34
  tabIndex: isActiveCell ? 0 : -1,
39
35
  "data-disabled": disabled || nonEditCell,
40
36
  "aria-disabled": disabled || nonEditCell,
@@ -60,8 +56,6 @@ InlineEditButton.propTypes = {
60
56
  nonEditCell: _propTypes.default.bool,
61
57
  placeholder: _propTypes.default.string,
62
58
  renderIcon: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.object]),
63
- totalColumns: _propTypes.default.number,
64
- totalInlineEditColumns: _propTypes.default.number,
65
59
  type: _propTypes.default.oneOf(['text', 'number', 'selection', 'date']),
66
60
  value: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.node])
67
61
  };
@@ -35,14 +35,12 @@ var InlineEditCell = function InlineEditCell(_ref) {
35
35
  tabIndex = _ref.tabIndex,
36
36
  value = _ref.value,
37
37
  nonEditCell = _ref.nonEditCell,
38
- totalInlineEditColumns = _ref.totalInlineEditColumns,
39
38
  type = _ref.type;
40
39
  var columnId = cell.column.id;
41
40
  var columnIndex = instance.columns.findIndex(function (col) {
42
41
  return col.id === columnId;
43
42
  });
44
43
  var cellId = "column-".concat(columnIndex, "-row-").concat(cell.row.index);
45
- var totalColumns = instance.columns.length;
46
44
  var _useContext = (0, _react.useContext)(_InlineEditContext.InlineEditContext),
47
45
  state = _useContext.state,
48
46
  dispatch = _useContext.dispatch;
@@ -445,8 +443,6 @@ var InlineEditCell = function InlineEditCell(_ref) {
445
443
  tabIndex: tabIndex,
446
444
  nonEditCell: nonEditCell,
447
445
  columnConfig: cell.column,
448
- totalInlineEditColumns: totalInlineEditColumns,
449
- totalColumns: totalColumns,
450
446
  type: type
451
447
  }), !nonEditCell && inEditMode && cellId === activeCellId && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, type === 'text' && renderTextInput(), type === 'number' && renderNumberInput(), type === 'selection' && renderSelectCell(), type === 'date' && renderDateCell()))
452
448
  );
@@ -465,7 +461,6 @@ InlineEditCell.propTypes = {
465
461
  nonEditCell: _propTypes.default.bool,
466
462
  placeholder: _propTypes.default.string,
467
463
  tabIndex: _propTypes.default.number,
468
- totalInlineEditColumns: _propTypes.default.number,
469
464
  type: _propTypes.default.oneOf(['text', 'number', 'selection', 'date']),
470
465
  value: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.node, _propTypes.default.object])
471
466
  };