@carbon/ibm-products 2.46.0-rc.0 → 2.47.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (183) hide show
  1. package/css/config-dev.css +6 -1
  2. package/css/config-dev.css.map +1 -1
  3. package/css/config.css +6 -1
  4. package/css/config.css.map +1 -1
  5. package/css/index-full-carbon.css +1323 -264
  6. package/css/index-full-carbon.css.map +1 -1
  7. package/css/index-full-carbon.min.css +1 -1
  8. package/css/index-full-carbon.min.css.map +1 -1
  9. package/css/index-without-carbon-released-only.css +49 -60
  10. package/css/index-without-carbon-released-only.css.map +1 -1
  11. package/css/index-without-carbon-released-only.min.css +1 -1
  12. package/css/index-without-carbon-released-only.min.css.map +1 -1
  13. package/css/index-without-carbon.css +1323 -264
  14. package/css/index-without-carbon.css.map +1 -1
  15. package/css/index-without-carbon.min.css +1 -1
  16. package/css/index-without-carbon.min.css.map +1 -1
  17. package/css/index.css +1323 -264
  18. package/css/index.css.map +1 -1
  19. package/css/index.min.css +1 -1
  20. package/css/index.min.css.map +1 -1
  21. package/es/components/APIKeyModal/APIKeyModal.types.d.ts +6 -0
  22. package/es/components/ActionBar/ActionBar.d.ts +58 -2
  23. package/es/components/ActionBar/ActionBar.js +14 -9
  24. package/es/components/ActionBar/ActionBarItem.d.ts +36 -2
  25. package/es/components/ActionBar/ActionBarItem.js +7 -4
  26. package/es/components/ActionBar/ActionBarOverflowItems.d.ts +55 -16
  27. package/es/components/ActionBar/ActionBarOverflowItems.js +8 -4
  28. package/es/components/AddSelect/types/index.d.ts +6 -0
  29. package/es/components/Card/Card.d.ts +68 -2
  30. package/es/components/Card/Card.js +28 -35
  31. package/es/components/Card/CardFooter.d.ts +51 -48
  32. package/es/components/Card/CardFooter.js +4 -2
  33. package/es/components/Card/CardHeader.d.ts +67 -49
  34. package/es/components/Card/CardHeader.js +4 -2
  35. package/es/components/Coachmark/utils/enums.d.ts +6 -0
  36. package/es/components/ConditionBuilder/ConditionBlock/ConditionBlock.d.ts +1 -0
  37. package/es/components/ConditionBuilder/ConditionBlock/ConditionBlock.js +17 -4
  38. package/es/components/ConditionBuilder/ConditionBuilderAdd/ConditionBuilderAdd.js +2 -2
  39. package/es/components/ConditionBuilder/ConditionBuilderButton/ConditionBuilderButton.js +6 -4
  40. package/es/components/ConditionBuilder/ConditionBuilderConnector/ConditionConnector.js +4 -1
  41. package/es/components/ConditionBuilder/ConditionBuilderContent/ConditionBuilderContent.js +8 -2
  42. package/es/components/ConditionBuilder/ConditionBuilderContext/translationObject.d.ts +3 -0
  43. package/es/components/ConditionBuilder/ConditionBuilderContext/translationObject.js +5 -2
  44. package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItem.js +20 -4
  45. package/es/components/ConditionBuilder/ConditionGroupBuilder/ConditionGroupBuilder.js +15 -7
  46. package/es/components/ConditionBuilder/ConditionPreview/ConditionPreview.d.ts +3 -1
  47. package/es/components/ConditionBuilder/ConditionPreview/ConditionPreview.js +9 -3
  48. package/es/components/ConditionBuilder/utils/handleKeyboardEvents.js +19 -6
  49. package/es/components/DataSpreadsheet/types/index.d.ts +6 -0
  50. package/es/components/Datagrid/Datagrid/DatagridBody.d.ts +6 -0
  51. package/es/components/Datagrid/Datagrid/DatagridContent.js +3 -2
  52. package/es/components/Datagrid/Datagrid/DatagridRefBody.d.ts +6 -0
  53. package/es/components/Datagrid/Datagrid/DatagridSelectAll.js +4 -5
  54. package/es/components/Datagrid/Datagrid/DatagridSimpleBody.d.ts +6 -0
  55. package/es/components/Datagrid/Datagrid/DatagridVirtualBody.js +3 -1
  56. package/es/components/Datagrid/Datagrid/DraggableElement.d.ts +6 -0
  57. package/es/components/Datagrid/Datagrid/addons/Filtering/FilterPanel.js +1 -1
  58. package/es/components/Datagrid/Datagrid/addons/Filtering/FilterProvider.d.ts +3 -2
  59. package/es/components/Datagrid/Datagrid/addons/Filtering/FilterProvider.js +13 -8
  60. package/es/components/Datagrid/Datagrid/addons/Filtering/handleCheckboxChange.js +7 -0
  61. package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditCell/InlineEditCell.js +1 -1
  62. package/es/components/Datagrid/common-column-ids.d.ts +6 -0
  63. package/es/components/Datagrid/types/index.d.ts +6 -0
  64. package/es/components/Datagrid/useDatagrid.d.ts +6 -0
  65. package/es/components/Datagrid/useDisableSelectRows.d.ts +6 -0
  66. package/es/components/Datagrid/useInitialColumnSort.js +4 -0
  67. package/es/components/Datagrid/useRowIsMouseOver.d.ts +6 -0
  68. package/es/components/Datagrid/useSortableColumns.d.ts +5 -4
  69. package/es/components/Datagrid/useSortableColumns.js +18 -13
  70. package/es/components/EmptyStates/EmptyState.d.ts +72 -5
  71. package/es/components/EmptyStates/EmptyState.js +8 -5
  72. package/es/components/EmptyStates/EmptyStateV2.d.ts +63 -2
  73. package/es/components/EmptyStates/EmptyStateV2.js +3 -2
  74. package/es/components/FullPageError/FullPageError.d.ts +36 -2
  75. package/es/components/FullPageError/FullPageError.js +0 -3
  76. package/es/components/GetStartedCard/GetStartedCard.d.ts +60 -2
  77. package/es/components/GetStartedCard/GetStartedCard.js +11 -10
  78. package/es/components/PageHeader/PageHeaderUtils.js +1 -1
  79. package/es/components/StringFormatter/utils/enums.js +7 -0
  80. package/es/components/TagOverflow/TagOverflow.d.ts +35 -4
  81. package/es/components/TagOverflow/TagOverflow.js +47 -64
  82. package/es/components/TagOverflow/TagOverflowModal.js +4 -6
  83. package/es/components/TagOverflow/TagOverflowPopover.d.ts +13 -1
  84. package/es/components/TagOverflow/TagOverflowPopover.js +38 -41
  85. package/es/components/Tearsheet/TearsheetShell.js +4 -1
  86. package/es/components/UserAvatar/UserAvatar.d.ts +59 -1
  87. package/es/components/UserAvatar/UserAvatar.js +7 -23
  88. package/es/global/js/utils/scrollableAncestor.js +7 -0
  89. package/es/global/js/utils/uuidv4.d.ts +6 -0
  90. package/es/global/js/utils/uuidv4.js +2 -0
  91. package/es/global/js/utils/wait.d.ts +6 -0
  92. package/es/global/js/utils/wait.js +2 -0
  93. package/flags.js +7 -0
  94. package/lib/components/APIKeyModal/APIKeyModal.types.d.ts +6 -0
  95. package/lib/components/ActionBar/ActionBar.d.ts +58 -2
  96. package/lib/components/ActionBar/ActionBar.js +14 -9
  97. package/lib/components/ActionBar/ActionBarItem.d.ts +36 -2
  98. package/lib/components/ActionBar/ActionBarItem.js +6 -3
  99. package/lib/components/ActionBar/ActionBarOverflowItems.d.ts +55 -16
  100. package/lib/components/ActionBar/ActionBarOverflowItems.js +8 -4
  101. package/lib/components/AddSelect/types/index.d.ts +6 -0
  102. package/lib/components/Card/Card.d.ts +68 -2
  103. package/lib/components/Card/Card.js +28 -35
  104. package/lib/components/Card/CardFooter.d.ts +51 -48
  105. package/lib/components/Card/CardFooter.js +4 -2
  106. package/lib/components/Card/CardHeader.d.ts +67 -49
  107. package/lib/components/Card/CardHeader.js +4 -2
  108. package/lib/components/Coachmark/utils/enums.d.ts +6 -0
  109. package/lib/components/ConditionBuilder/ConditionBlock/ConditionBlock.d.ts +1 -0
  110. package/lib/components/ConditionBuilder/ConditionBlock/ConditionBlock.js +16 -3
  111. package/lib/components/ConditionBuilder/ConditionBuilderAdd/ConditionBuilderAdd.js +2 -2
  112. package/lib/components/ConditionBuilder/ConditionBuilderButton/ConditionBuilderButton.js +5 -3
  113. package/lib/components/ConditionBuilder/ConditionBuilderConnector/ConditionConnector.js +4 -1
  114. package/lib/components/ConditionBuilder/ConditionBuilderContent/ConditionBuilderContent.js +8 -2
  115. package/lib/components/ConditionBuilder/ConditionBuilderContext/translationObject.d.ts +3 -0
  116. package/lib/components/ConditionBuilder/ConditionBuilderContext/translationObject.js +5 -2
  117. package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItem.js +20 -4
  118. package/lib/components/ConditionBuilder/ConditionGroupBuilder/ConditionGroupBuilder.js +15 -7
  119. package/lib/components/ConditionBuilder/ConditionPreview/ConditionPreview.d.ts +3 -1
  120. package/lib/components/ConditionBuilder/ConditionPreview/ConditionPreview.js +9 -3
  121. package/lib/components/ConditionBuilder/utils/handleKeyboardEvents.js +19 -6
  122. package/lib/components/DataSpreadsheet/types/index.d.ts +6 -0
  123. package/lib/components/Datagrid/Datagrid/DatagridBody.d.ts +6 -0
  124. package/lib/components/Datagrid/Datagrid/DatagridContent.js +3 -2
  125. package/lib/components/Datagrid/Datagrid/DatagridRefBody.d.ts +6 -0
  126. package/lib/components/Datagrid/Datagrid/DatagridSelectAll.js +4 -5
  127. package/lib/components/Datagrid/Datagrid/DatagridSimpleBody.d.ts +6 -0
  128. package/lib/components/Datagrid/Datagrid/DatagridVirtualBody.js +3 -1
  129. package/lib/components/Datagrid/Datagrid/DraggableElement.d.ts +6 -0
  130. package/lib/components/Datagrid/Datagrid/addons/Filtering/FilterPanel.js +1 -1
  131. package/lib/components/Datagrid/Datagrid/addons/Filtering/FilterProvider.d.ts +3 -2
  132. package/lib/components/Datagrid/Datagrid/addons/Filtering/FilterProvider.js +13 -8
  133. package/lib/components/Datagrid/Datagrid/addons/Filtering/handleCheckboxChange.js +7 -0
  134. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditCell/InlineEditCell.js +1 -1
  135. package/lib/components/Datagrid/common-column-ids.d.ts +6 -0
  136. package/lib/components/Datagrid/types/index.d.ts +6 -0
  137. package/lib/components/Datagrid/useDatagrid.d.ts +6 -0
  138. package/lib/components/Datagrid/useDisableSelectRows.d.ts +6 -0
  139. package/lib/components/Datagrid/useInitialColumnSort.js +4 -0
  140. package/lib/components/Datagrid/useRowIsMouseOver.d.ts +6 -0
  141. package/lib/components/Datagrid/useSortableColumns.d.ts +5 -4
  142. package/lib/components/Datagrid/useSortableColumns.js +18 -13
  143. package/lib/components/EmptyStates/EmptyState.d.ts +72 -5
  144. package/lib/components/EmptyStates/EmptyState.js +8 -5
  145. package/lib/components/EmptyStates/EmptyStateV2.d.ts +63 -2
  146. package/lib/components/EmptyStates/EmptyStateV2.js +3 -2
  147. package/lib/components/FullPageError/FullPageError.d.ts +36 -2
  148. package/lib/components/FullPageError/FullPageError.js +0 -3
  149. package/lib/components/GetStartedCard/GetStartedCard.d.ts +60 -2
  150. package/lib/components/GetStartedCard/GetStartedCard.js +10 -9
  151. package/lib/components/PageHeader/PageHeaderUtils.js +1 -1
  152. package/lib/components/StringFormatter/utils/enums.js +7 -0
  153. package/lib/components/TagOverflow/TagOverflow.d.ts +35 -4
  154. package/lib/components/TagOverflow/TagOverflow.js +46 -63
  155. package/lib/components/TagOverflow/TagOverflowModal.js +4 -6
  156. package/lib/components/TagOverflow/TagOverflowPopover.d.ts +13 -1
  157. package/lib/components/TagOverflow/TagOverflowPopover.js +37 -40
  158. package/lib/components/Tearsheet/TearsheetShell.js +4 -1
  159. package/lib/components/UserAvatar/UserAvatar.d.ts +59 -1
  160. package/lib/components/UserAvatar/UserAvatar.js +7 -23
  161. package/lib/global/js/utils/scrollableAncestor.js +7 -0
  162. package/lib/global/js/utils/uuidv4.d.ts +6 -0
  163. package/lib/global/js/utils/uuidv4.js +2 -0
  164. package/lib/global/js/utils/wait.d.ts +6 -0
  165. package/lib/global/js/utils/wait.js +2 -0
  166. package/package.json +4 -4
  167. package/scss/components/ConditionBuilder/_condition-builder.scss +3 -0
  168. package/scss/components/ConditionBuilder/styles/_conditionBuilderCondition.scss +18 -2
  169. package/scss/components/ConditionBuilder/styles/_conditionBuilderItem.scss +48 -31
  170. package/scss/components/ConditionBuilder/styles/_index.scss +7 -0
  171. package/scss/components/CreateModal/_create-modal.scss +0 -4
  172. package/scss/components/Datagrid/styles/_datagrid.scss +1 -0
  173. package/scss/components/Datagrid/styles/_useActionsColumn.scss +6 -7
  174. package/scss/components/Datagrid/styles/_useColumnRightAlign.scss +6 -7
  175. package/scss/components/Datagrid/styles/_useExpandedRow.scss +6 -7
  176. package/scss/components/Datagrid/styles/_useInlineEdit.scss +6 -7
  177. package/scss/components/Datagrid/styles/_useNestedRows.scss +6 -7
  178. package/scss/components/Datagrid/styles/_useNestedTable.scss +6 -7
  179. package/scss/components/Datagrid/styles/_useStickyColumn.scss +6 -7
  180. package/scss/components/Datagrid/styles/addons/_RowSizeDropdown.scss +6 -7
  181. package/scss/config-dev.scss +7 -0
  182. package/scss/config.scss +7 -0
  183. package/telemetry.yml +2 -0
@@ -6,7 +6,7 @@
6
6
  */
7
7
 
8
8
  import { objectWithoutProperties as _objectWithoutProperties, extends as _extends, defineProperty as _defineProperty } from '../../_virtual/_rollupPluginBabelHelpers.js';
9
- import React__default, { useRef } from 'react';
9
+ import React__default, { forwardRef, useRef } from 'react';
10
10
  import PropTypes from '../../node_modules/prop-types/index.js';
11
11
  import cx from 'classnames';
12
12
  import { Popover, Tag, PopoverContent, Link } from '@carbon/react';
@@ -17,52 +17,48 @@ var _excluded = ["allTagsModalSearchThreshold", "className", "onShowAllClick", "
17
17
  _excluded2 = ["label", "id", "tagType", "filter", "onClose"];
18
18
  var componentName = 'TagOverflowPopover';
19
19
  var blockClass = "".concat(pkg.prefix, "--tag-overflow-popover");
20
-
21
- // Default values for props
22
- var defaults = {
23
- allTagsModalSearchThreshold: 10,
24
- overflowAlign: 'bottom'
25
- };
26
- var TagOverflowPopover = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
27
- var _ref$allTagsModalSear = _ref.allTagsModalSearchThreshold,
28
- allTagsModalSearchThreshold = _ref$allTagsModalSear === void 0 ? defaults.allTagsModalSearchThreshold : _ref$allTagsModalSear,
29
- className = _ref.className,
30
- onShowAllClick = _ref.onShowAllClick,
31
- _ref$overflowAlign = _ref.overflowAlign,
32
- overflowAlign = _ref$overflowAlign === void 0 ? defaults.overflowAlign : _ref$overflowAlign,
33
- overflowTags = _ref.overflowTags,
34
- overflowType = _ref.overflowType,
35
- showAllTagsLabel = _ref.showAllTagsLabel,
36
- popoverOpen = _ref.popoverOpen,
37
- setPopoverOpen = _ref.setPopoverOpen,
38
- rest = _objectWithoutProperties(_ref, _excluded);
39
- var localRef = useRef();
20
+ var TagOverflowPopover = /*#__PURE__*/forwardRef(function (props, ref) {
21
+ var _overflowTags$length;
22
+ var allTagsModalSearchThreshold = props.allTagsModalSearchThreshold,
23
+ className = props.className,
24
+ onShowAllClick = props.onShowAllClick,
25
+ overflowAlign = props.overflowAlign,
26
+ overflowTags = props.overflowTags,
27
+ overflowType = props.overflowType,
28
+ showAllTagsLabel = props.showAllTagsLabel,
29
+ popoverOpen = props.popoverOpen,
30
+ setPopoverOpen = props.setPopoverOpen,
31
+ rest = _objectWithoutProperties(props, _excluded);
32
+ var localRef = useRef(null);
40
33
  var overflowTagContent = useRef(null);
41
34
  useClickOutside(ref || localRef, function () {
42
35
  if (popoverOpen) {
43
- setPopoverOpen(false);
36
+ setPopoverOpen === null || setPopoverOpen === void 0 || setPopoverOpen(false);
44
37
  }
45
38
  });
46
39
  var handleShowAllTagsClick = function handleShowAllTagsClick(evt) {
47
40
  evt.stopPropagation();
48
41
  evt.preventDefault();
49
- setPopoverOpen(false);
50
- onShowAllClick();
42
+ setPopoverOpen === null || setPopoverOpen === void 0 || setPopoverOpen(false);
43
+ onShowAllClick === null || onShowAllClick === void 0 || onShowAllClick();
51
44
  };
52
- var handleEscKeyPress = function handleEscKeyPress(event) {
53
- var key = event.key;
45
+ var handleEscKeyPress = function handleEscKeyPress(evt) {
46
+ var key = evt.key;
54
47
  if (key === 'Escape') {
55
- setPopoverOpen(false);
48
+ setPopoverOpen === null || setPopoverOpen === void 0 || setPopoverOpen(false);
56
49
  }
57
50
  };
58
51
  var getOverflowPopoverItems = function getOverflowPopoverItems() {
59
- return overflowTags.filter(function (_, index) {
60
- return overflowTags.length > allTagsModalSearchThreshold ? index < allTagsModalSearchThreshold : index <= allTagsModalSearchThreshold;
52
+ var thresh = allTagsModalSearchThreshold !== null && allTagsModalSearchThreshold !== void 0 ? allTagsModalSearchThreshold : 0;
53
+ return overflowTags === null || overflowTags === void 0 ? void 0 : overflowTags.filter(function (_, index) {
54
+ return (overflowTags === null || overflowTags === void 0 ? void 0 : overflowTags.length) > thresh ? index < thresh : index <= thresh;
61
55
  });
62
56
  };
57
+ var visibleItems = getOverflowPopoverItems();
58
+ var hasItems = (visibleItems === null || visibleItems === void 0 ? void 0 : visibleItems.length) > 0;
63
59
  return /*#__PURE__*/React__default.createElement("span", _extends({}, rest, {
64
- "aria-hidden": overflowTags.length === 0,
65
- className: cx(blockClass, _defineProperty({}, "".concat(blockClass, "--hidden"), overflowTags.length === 0)),
60
+ "aria-hidden": (overflowTags === null || overflowTags === void 0 ? void 0 : overflowTags.length) === 0,
61
+ className: cx(blockClass, _defineProperty({}, "".concat(blockClass, "--hidden"), (overflowTags === null || overflowTags === void 0 ? void 0 : overflowTags.length) === 0)),
66
62
  ref: ref || localRef
67
63
  }), /*#__PURE__*/React__default.createElement(Popover, {
68
64
  align: overflowAlign,
@@ -73,21 +69,21 @@ var TagOverflowPopover = /*#__PURE__*/React__default.forwardRef(function (_ref,
73
69
  open: popoverOpen
74
70
  }, /*#__PURE__*/React__default.createElement(Tag, {
75
71
  onClick: function onClick() {
76
- return setPopoverOpen(!popoverOpen);
72
+ return setPopoverOpen === null || setPopoverOpen === void 0 ? void 0 : setPopoverOpen(!popoverOpen);
77
73
  },
78
74
  className: cx("".concat(blockClass, "__trigger"))
79
- }, "+", overflowTags.length), /*#__PURE__*/React__default.createElement(PopoverContent, null, /*#__PURE__*/React__default.createElement("div", {
75
+ }, "+", overflowTags === null || overflowTags === void 0 ? void 0 : overflowTags.length), /*#__PURE__*/React__default.createElement(PopoverContent, null, /*#__PURE__*/React__default.createElement("div", {
80
76
  ref: overflowTagContent,
81
77
  className: "".concat(blockClass, "__content")
82
78
  }, /*#__PURE__*/React__default.createElement("ul", {
83
79
  className: "".concat(blockClass, "__tag-list")
84
- }, getOverflowPopoverItems().map(function (_ref2) {
85
- var label = _ref2.label,
86
- id = _ref2.id,
87
- tagType = _ref2.tagType,
88
- filter = _ref2.filter,
89
- _onClose = _ref2.onClose,
90
- other = _objectWithoutProperties(_ref2, _excluded2);
80
+ }, hasItems && visibleItems.map(function (_ref) {
81
+ var label = _ref.label,
82
+ id = _ref.id,
83
+ tagType = _ref.tagType,
84
+ filter = _ref.filter,
85
+ _onClose = _ref.onClose,
86
+ other = _objectWithoutProperties(_ref, _excluded2);
91
87
  var typeValue = overflowType === 'tag' ? 'high-contrast' : tagType;
92
88
  var isFilterable = overflowType === 'tag' ? filter : false;
93
89
  return /*#__PURE__*/React__default.createElement("li", {
@@ -100,7 +96,7 @@ var TagOverflowPopover = /*#__PURE__*/React__default.forwardRef(function (_ref,
100
96
  type: typeValue,
101
97
  filter: isFilterable
102
98
  }), label) : label);
103
- })), overflowTags.length > allTagsModalSearchThreshold && /*#__PURE__*/React__default.createElement(Link, {
99
+ })), ((_overflowTags$length = overflowTags === null || overflowTags === void 0 ? void 0 : overflowTags.length) !== null && _overflowTags$length !== void 0 ? _overflowTags$length : 0) > (allTagsModalSearchThreshold !== null && allTagsModalSearchThreshold !== void 0 ? allTagsModalSearchThreshold : 0) && /*#__PURE__*/React__default.createElement(Link, {
104
100
  className: "".concat(blockClass, "__show-all-tags-link"),
105
101
  href: "",
106
102
  onClick: handleShowAllTagsClick,
@@ -128,6 +124,7 @@ TagOverflowPopover.propTypes = {
128
124
  /**
129
125
  * tags shown in overflow
130
126
  */
127
+ //@ts-ignore
131
128
  overflowTags: PropTypes.arrayOf(PropTypes.object).isRequired,
132
129
  /**
133
130
  * Type of rendering displayed inside of the tag overflow component
@@ -167,10 +167,13 @@ var TearsheetShell = /*#__PURE__*/React__default.forwardRef(function (_ref, ref)
167
167
  useEffect(function () {
168
168
  if (open && position !== depth) {
169
169
  setTimeout(function () {
170
+ if (selectorPrimaryFocus) {
171
+ return specifiedElement === null || specifiedElement === void 0 ? void 0 : specifiedElement.focus();
172
+ }
170
173
  firstElement === null || firstElement === void 0 || firstElement.focus();
171
174
  }, 0);
172
175
  }
173
- }, [position, depth, firstElement, open]);
176
+ }, [position, depth, firstElement, open, specifiedElement, selectorPrimaryFocus]);
174
177
  useEffect(function () {
175
178
  var notify = function notify() {
176
179
  return stack.all.forEach(function (handler) {
@@ -1,2 +1,60 @@
1
- export let UserAvatar: React.ForwardRefExoticComponent<React.RefAttributes<any>>;
1
+ /**
2
+ * Copyright IBM Corp. 2024, 2024
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
+ */
2
7
  import React from 'react';
8
+ import '../../global/js/utils/props-helper';
9
+ /**
10
+ * TODO: A description of the component.
11
+ */
12
+ type BackgroundColor = 'order-1-cyan' | 'order-2-gray' | 'order-3-green' | 'order-4-magenta' | 'order-5-purple' | 'order-6-teal' | 'order-7-cyan' | 'order-8-gray' | 'order-9-green' | 'order-10-magenta' | 'order-11-purple' | 'order-12-teal';
13
+ type Size = 'xl' | 'lg' | 'md' | 'sm';
14
+ type TooltipAlignment = 'top' | 'top-left' | 'top-right' | 'bottom' | 'bottom-left' | 'bottom-right' | 'left' | 'right';
15
+ type ImageProps = {
16
+ /**
17
+ * When passing the image prop, supply a full path to the image to be displayed.
18
+ */
19
+ image: string;
20
+ /**
21
+ * When passing the image prop use the imageDescription prop to describe the image for screen reader.
22
+ */
23
+ imageDescription: string;
24
+ } | {
25
+ image?: never;
26
+ imageDescription?: never;
27
+ };
28
+ type UserAvatarBaseProps = {
29
+ /**
30
+ * Provide the background color need to be set for UserAvatar.
31
+ */
32
+ backgroundColor?: BackgroundColor;
33
+ /**
34
+ * Provide an optional class to be applied to the containing node.
35
+ */
36
+ className?: string;
37
+ /**
38
+ * When passing the name prop, either send the initials to be used or the user's full name. The first two capital letters of the user's name will be used as the name.
39
+ */
40
+ name?: string;
41
+ /**
42
+ * Provide a custom icon to use if you need to use an icon other than the default one
43
+ */
44
+ renderIcon?: React.ElementType;
45
+ /**
46
+ * Set the size of the avatar circle
47
+ */
48
+ size?: Size;
49
+ /**
50
+ * Specify how the trigger should align with the tooltip
51
+ */
52
+ tooltipAlignment?: TooltipAlignment;
53
+ /**
54
+ * Pass in the display name to have it shown on hover
55
+ */
56
+ tooltipText?: string;
57
+ };
58
+ type UserAvatarProps = UserAvatarBaseProps & ImageProps;
59
+ export declare let UserAvatar: React.ForwardRefExoticComponent<UserAvatarProps & React.RefAttributes<HTMLDivElement>>;
60
+ export {};
@@ -26,42 +26,23 @@ var componentName = 'UserAvatar';
26
26
 
27
27
  // NOTE: the component SCSS is not imported here: it is rolled up separately.
28
28
 
29
- // Default values can be included here and then assigned to the prop params,
30
- // e.g. prop = defaults.prop,
31
- // This gathers default values together neatly and ensures non-primitive
32
- // values are initialized early to avoid react making unnecessary re-renders.
33
- // Note that default values are not required for props that are 'required',
34
- // nor for props where the component can apply undefined values reasonably.
35
- // Default values should be provided when the component needs to make a choice
36
- // or assumption when a prop is not supplied.
37
-
38
- // Default values for props
39
- // const defaults = {
40
- // /* TODO: add defaults for relevant props if needed */
41
- // };
42
-
43
29
  /**
44
30
  * TODO: A description of the component.
45
31
  */
46
32
 
47
- var defaults = {
48
- size: 'md',
49
- tooltipAlignment: 'bottom',
50
- backgroundColor: 'order-1-cyan'
51
- };
52
33
  var UserAvatar = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
53
34
  var _ref$backgroundColor = _ref.backgroundColor,
54
- backgroundColor = _ref$backgroundColor === void 0 ? defaults.backgroundColor : _ref$backgroundColor,
35
+ backgroundColor = _ref$backgroundColor === void 0 ? 'order-1-cyan' : _ref$backgroundColor,
55
36
  className = _ref.className,
56
37
  image = _ref.image,
57
38
  imageDescription = _ref.imageDescription,
58
39
  name = _ref.name,
59
40
  RenderIcon = _ref.renderIcon,
60
41
  _ref$size = _ref.size,
61
- size = _ref$size === void 0 ? defaults.size : _ref$size,
42
+ size = _ref$size === void 0 ? 'md' : _ref$size,
62
43
  tooltipText = _ref.tooltipText,
63
44
  _ref$tooltipAlignment = _ref.tooltipAlignment,
64
- tooltipAlignment = _ref$tooltipAlignment === void 0 ? defaults.tooltipAlignment : _ref$tooltipAlignment,
45
+ tooltipAlignment = _ref$tooltipAlignment === void 0 ? 'bottom' : _ref$tooltipAlignment,
65
46
  rest = _objectWithoutProperties(_ref, _excluded);
66
47
  var carbonPrefix = usePrefix();
67
48
  var iconSize = {
@@ -72,7 +53,7 @@ var UserAvatar = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
72
53
  };
73
54
  var formatInitials = function formatInitials() {
74
55
  var _ref2;
75
- var parts = name.split(' ');
56
+ var parts = (name === null || name === void 0 ? void 0 : name.split(' ')) || [];
76
57
  var firstChar = parts[0].charAt(0).toUpperCase();
77
58
  var secondChar = parts[0].charAt(1).toUpperCase();
78
59
  if (parts.length === 1) {
@@ -152,10 +133,12 @@ UserAvatar.propTypes = {
152
133
  /**
153
134
  * When passing the image prop, supply a full path to the image to be displayed.
154
135
  */
136
+ /**@ts-ignore */
155
137
  image: PropTypes.string,
156
138
  /**
157
139
  * When passing the image prop use the imageDescription prop to describe the image for screen reader.
158
140
  */
141
+ /**@ts-ignore */
159
142
  imageDescription: PropTypes.string.isRequired.if(function (_ref3) {
160
143
  var image = _ref3.image;
161
144
  return !!image;
@@ -167,6 +150,7 @@ UserAvatar.propTypes = {
167
150
  /**
168
151
  * Provide a custom icon to use if you need to use an icon other than the default one
169
152
  */
153
+ /**@ts-ignore */
170
154
  renderIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
171
155
  /**
172
156
  * Set the size of the avatar circle
@@ -7,6 +7,13 @@
7
7
 
8
8
  import { typeof as _typeof } from '../../../_virtual/_rollupPluginBabelHelpers.js';
9
9
 
10
+ /**
11
+ * Copyright IBM Corp. 2024
12
+ *
13
+ * This source code is licensed under the Apache-2.0 license found in the
14
+ * LICENSE file in the root directory of this source tree.
15
+ */
16
+
10
17
  var windowExists = (typeof window === "undefined" ? "undefined" : _typeof(window)) !== "undefined";
11
18
 
12
19
  // determine whether the target is scrollable
@@ -1,2 +1,8 @@
1
1
  export default uuidv4;
2
+ /**
3
+ * Copyright IBM Corp. 2024
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
+ */
2
8
  declare function uuidv4(): any;
@@ -5,6 +5,8 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
+ // https://stackoverflow.com/a/2117523
9
+
8
10
  function uuidv4() {
9
11
  var randomValues = function randomValues(c) {
10
12
  return typeof crypto !== 'undefined' ? crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4 : Math.random() * 16 >> c / 4;
@@ -1,2 +1,8 @@
1
1
  export default wait;
2
+ /**
3
+ * Copyright IBM Corp. 2024
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
+ */
2
8
  declare function wait(ms: any): Promise<any>;
@@ -5,6 +5,8 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
+ // utility function for an async timeout
9
+
8
10
  function wait(ms) {
9
11
  return new Promise(function (resolve) {
10
12
  return setTimeout(resolve, ms);
package/flags.js CHANGED
@@ -1,3 +1,10 @@
1
+ /**
2
+ * Copyright IBM Corp. 2024
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
+
1
8
  const { pkg } = require('./lib/settings.js');
2
9
  const { component, feature } = pkg;
3
10
 
@@ -1,3 +1,9 @@
1
+ /**
2
+ * Copyright IBM Corp. 2024
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
+ */
1
7
  import { ReactNode } from 'react';
2
8
  interface APIKeyModalCommonProps {
3
9
  /**
@@ -1,5 +1,61 @@
1
+ import React, { PropsWithChildren } from 'react';
2
+ import { ButtonProps } from '@carbon/type';
3
+ import { CarbonIconType } from '@carbon/icons-react/lib/CarbonIcon';
4
+ interface Action extends ButtonProps {
5
+ id?: string;
6
+ key: string;
7
+ iconDescription: string;
8
+ label: string;
9
+ onClick?: () => void;
10
+ renderIcon: CarbonIconType;
11
+ }
12
+ interface ActionBarProps extends PropsWithChildren {
13
+ /**
14
+ * Specifies the action bar items. Each item is specified as an object
15
+ * with required fields: key for array rendering, renderIcon, iconDescription and
16
+ * label to provide the icon to display,
17
+ * and optional 'onClick' to receive notifications when the button is clicked.
18
+ * Additional fields in the object will be passed to the
19
+ * Button component, and these can include 'disabled', 'ref', 'className',
20
+ * and any other Button props.
21
+ *
22
+ * Note that the Button props 'kind', 'size',
23
+ * 'tooltipPosition', 'tooltipAlignment' and 'type' are ignored, as these
24
+ * cannot be used for an action bar item.
25
+ *
26
+ * Carbon Button API https://react.carbondesignsystem.com/?path=/docs/components-button--default#component-api
27
+ */
28
+ actions?: readonly Action[];
29
+ /**
30
+ * className
31
+ */
32
+ className?: string;
33
+ /**
34
+ * maxVisible : Maximum action bar items visible before going into the overflow menu
35
+ */
36
+ maxVisible?: number;
37
+ /**
38
+ * class name applied to the overflow options
39
+ */
40
+ menuOptionsClass?: string;
41
+ /**
42
+ * onItemCountChange - event reporting maxWidth
43
+ */
44
+ onWidthChange?: (sizes: {
45
+ minWidth: number;
46
+ maxWidth: number;
47
+ }) => void;
48
+ /**
49
+ * overflowAriaLabel label for open close button overflow used for action bar items that do nto fit.
50
+ */
51
+ overflowAriaLabel: string;
52
+ /**
53
+ * align tags to right of available space
54
+ */
55
+ rightAlign?: boolean;
56
+ }
1
57
  /**
2
58
  * The ActionBar is used internally by the PageHeader to wrap ActionBarItems.
3
59
  */
4
- export let ActionBar: React.ForwardRefExoticComponent<React.RefAttributes<any>>;
5
- import React from 'react';
60
+ export declare let ActionBar: React.ForwardRefExoticComponent<ActionBarProps & React.RefAttributes<HTMLDivElement>>;
61
+ export {};
@@ -29,7 +29,6 @@ var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
29
29
  var _excluded = ["actions", "className", "maxVisible", "menuOptionsClass", "onWidthChange", "overflowAriaLabel", "rightAlign"],
30
30
  _excluded2 = ["key", "id"],
31
31
  _excluded3 = ["key"];
32
-
33
32
  // The block part of our conventional BEM class names (blockClass__E--M).
34
33
  var blockClass = "".concat(settings.pkg.prefix, "--action-bar");
35
34
  var componentName = 'ActionBar';
@@ -38,7 +37,6 @@ var componentName = 'ActionBar';
38
37
  var defaults = {
39
38
  actions: Object.freeze([])
40
39
  };
41
-
42
40
  // NOTE: the component SCSS is not imported here: it is rolled up separately.
43
41
 
44
42
  /**
@@ -62,7 +60,7 @@ exports.ActionBar = /*#__PURE__*/React__default["default"].forwardRef(function (
62
60
  _useState4 = _rollupPluginBabelHelpers.slicedToArray(_useState3, 2),
63
61
  displayedItems = _useState4[0],
64
62
  setDisplayedItems = _useState4[1];
65
- var _useState5 = React.useState([]),
63
+ var _useState5 = React.useState(null),
66
64
  _useState6 = _rollupPluginBabelHelpers.slicedToArray(_useState5, 2),
67
65
  hiddenSizingItems = _useState6[0],
68
66
  setHiddenSizingItems = _useState6[1];
@@ -70,7 +68,7 @@ exports.ActionBar = /*#__PURE__*/React__default["default"].forwardRef(function (
70
68
  var refDisplayedItems = React.useRef(null);
71
69
  var sizingRef = React.useRef(null);
72
70
  var sizes = React.useRef({});
73
- var backupRef = React.useRef();
71
+ var backupRef = React.useRef(null);
74
72
  var localRef = ref || backupRef;
75
73
 
76
74
  // create hidden sizing items
@@ -130,24 +128,25 @@ exports.ActionBar = /*#__PURE__*/React__default["default"].forwardRef(function (
130
128
  var checkFullyVisibleItems = function checkFullyVisibleItems() {
131
129
  /* istanbul ignore if */
132
130
  if (sizingRef.current) {
131
+ var _refDisplayedItems$cu;
133
132
  var sizingItems = Array.from(sizingRef.current.querySelectorAll(".".concat(blockClass, "__hidden-sizing-item")));
134
133
 
135
134
  // first item is always the overflow even if nothing else is rendered
136
135
  var overflowItem = sizingItems.shift();
137
136
 
138
137
  // determine how many will fit
139
- var spaceAvailable = refDisplayedItems.current.offsetWidth;
138
+ var spaceAvailable = (_refDisplayedItems$cu = refDisplayedItems.current) === null || _refDisplayedItems$cu === void 0 ? void 0 : _refDisplayedItems$cu.offsetWidth;
140
139
  var willFit = 0;
141
140
  var maxVisibleWidth = 0;
142
141
  var fitLimit = maxVisible ? Math.min(maxVisible, sizingItems.length) : sizingItems.length;
143
142
 
144
143
  // loop checking the space available
145
144
  for (var i = 0; i < fitLimit; i++) {
146
- var newSpaceAvailable = spaceAvailable - sizingItems[i].offsetWidth;
145
+ var newSpaceAvailable = spaceAvailable && spaceAvailable - sizingItems[i].offsetWidth;
147
146
 
148
147
  // update maxVisibleWidth for later use by onWidthChange
149
148
  maxVisibleWidth += sizingItems[i].offsetWidth;
150
- if (newSpaceAvailable >= 0) {
149
+ if (newSpaceAvailable && newSpaceAvailable >= 0) {
151
150
  spaceAvailable = newSpaceAvailable;
152
151
  willFit += 1;
153
152
  }
@@ -157,7 +156,7 @@ exports.ActionBar = /*#__PURE__*/React__default["default"].forwardRef(function (
157
156
  var overflowWidth = overflowItem.offsetWidth;
158
157
  if (willFit < sizingItems.length) {
159
158
  // Check space for overflow
160
- while (willFit > 0 && spaceAvailable < overflowWidth) {
159
+ while (willFit > 0 && spaceAvailable && spaceAvailable < overflowWidth) {
161
160
  willFit -= 1;
162
161
 
163
162
  // Highly unlikely that any action bar item is narrower than the overflow item
@@ -170,7 +169,10 @@ exports.ActionBar = /*#__PURE__*/React__default["default"].forwardRef(function (
170
169
  sizes.current.minWidth = overflowWidth;
171
170
  sizes.current.maxWidth = maxVisibleWidth;
172
171
  // emit onWidthChange
173
- onWidthChange(_rollupPluginBabelHelpers.objectSpread2({}, sizes.current));
172
+ onWidthChange({
173
+ minWidth: overflowWidth,
174
+ maxWidth: maxVisibleWidth
175
+ });
174
176
  }
175
177
  if (willFit < 1) {
176
178
  setDisplayCount(0);
@@ -221,14 +223,17 @@ exports.ActionBar.propTypes = {
221
223
  *
222
224
  * Carbon Button API https://react.carbondesignsystem.com/?path=/docs/components-button--default#component-api
223
225
  */
226
+ /**@ts-ignore */
224
227
  actions: index["default"].arrayOf(index["default"].shape(_rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, propsHelper.prepareProps(react.Button.propTypes, [
225
228
  // props not desired from Button.propTypes
226
229
  'kind', 'size', 'tooltipPosition', 'tooltipAlignment'])), {}, {
230
+ id: index["default"].string,
227
231
  // Additional props
228
232
  key: index["default"].string.isRequired,
229
233
  // Redefine as form different to Button and a key prop used by ActionBarItems
230
234
  iconDescription: index["default"].string.isRequired,
231
235
  label: index["default"].string.isRequired,
236
+ /**@ts-ignore */
232
237
  renderIcon: react.Button.propTypes.renderIcon.isRequired,
233
238
  // We duplicate onClick here to improve DocGen in Storybook
234
239
  onClick: index["default"].func
@@ -1,5 +1,39 @@
1
+ import React, { PropsWithChildren } from 'react';
2
+ import { CarbonIconType } from '@carbon/icons-react/lib/CarbonIcon';
3
+ interface ActionBarItemProps extends PropsWithChildren {
4
+ /**
5
+ * Specify an optional className to be added to your Button
6
+ *
7
+ * (inherited from Carbon Button)
8
+ */
9
+ className?: string;
10
+ /**
11
+ * If specifying the `renderIcon` prop, provide a description for that icon that can
12
+ * be read by screen readers
13
+ *
14
+ * (inherited from Carbon Button)
15
+ */
16
+ label?: string;
17
+ /**
18
+ * Optional click handler
19
+ *
20
+ * (inherited from Carbon Button)
21
+ */
22
+ onClick?: () => void;
23
+ /**
24
+ * Optional prop to allow overriding the icon rendering.
25
+ * Can be a React component class
26
+ *
27
+ * (inherited from Carbon Button)
28
+ */
29
+ renderIcon?: CarbonIconType;
30
+ /**
31
+ * Optional tab index
32
+ */
33
+ tabIndex?: number;
34
+ }
1
35
  /**
2
36
  * The ActionBarItem is used in the page header to populate the action bar
3
37
  */
4
- export let ActionBarItem: React.ForwardRefExoticComponent<React.RefAttributes<any>>;
5
- import React from 'react';
38
+ export declare let ActionBarItem: React.ForwardRefExoticComponent<ActionBarItemProps & React.RefAttributes<HTMLDivElement>>;
39
+ export {};
@@ -22,11 +22,9 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
22
22
  var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
23
23
 
24
24
  var _excluded = ["label", "className", "renderIcon"];
25
-
26
25
  // The block part of our conventional BEM class names (blockClass__E--M).
27
26
  var componentName = 'ActionBarItem';
28
27
  var blockClass = "".concat(settings.pkg.prefix, "--action-bar-item");
29
-
30
28
  // NOTE: the component SCSS is not imported here: it is rolled up separately.
31
29
 
32
30
  /**
@@ -94,5 +92,10 @@ exports.ActionBarItem.propTypes = _rollupPluginBabelHelpers.objectSpread2(_rollu
94
92
  *
95
93
  * (inherited from Carbon Button)
96
94
  */
97
- renderIcon: index["default"].oneOfType([index["default"].func, index["default"].object])
95
+ /**@ts-ignore */
96
+ renderIcon: index["default"].oneOfType([index["default"].func, index["default"].object]),
97
+ /**
98
+ * Optional tab index
99
+ */
100
+ tabIndex: index["default"].number
98
101
  });