@carbon/ibm-products 2.38.0 → 2.40.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (196) hide show
  1. package/css/index-full-carbon.css +236 -3
  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 +5 -0
  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 +236 -3
  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 +236 -3
  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/AddSelect/AddSelect.d.ts +44 -2
  18. package/es/components/AddSelect/AddSelect.js +8 -4
  19. package/es/components/AddSelect/AddSelectBody.d.ts +44 -2
  20. package/es/components/AddSelect/AddSelectBody.js +10 -12
  21. package/es/components/AddSelect/AddSelectSort.d.ts +16 -17
  22. package/es/components/AddSelect/AddSelectSort.js +5 -5
  23. package/es/components/AddSelect/types/index.d.ts +44 -0
  24. package/es/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.d.ts +5 -1
  25. package/es/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.js +12 -6
  26. package/es/components/Card/Card.js +50 -9
  27. package/es/components/Card/CardFooter.d.ts +5 -1
  28. package/es/components/Card/CardFooter.js +11 -1
  29. package/es/components/Carousel/Carousel.d.ts +6 -2
  30. package/es/components/Checklist/Checklist.d.ts +100 -2
  31. package/es/components/Checklist/Checklist.js +9 -5
  32. package/es/components/Checklist/Checklist.types.d.ts +19 -0
  33. package/es/components/Checklist/Checklist.types.js +22 -0
  34. package/es/components/Checklist/ChecklistChart.d.ts +5 -1
  35. package/es/components/Checklist/ChecklistChart.js +9 -4
  36. package/es/components/Checklist/ChecklistIcon.d.ts +5 -1
  37. package/es/components/Checklist/ChecklistIcon.js +9 -4
  38. package/es/components/CoachmarkButton/CoachmarkButton.d.ts +19 -2
  39. package/es/components/CoachmarkOverlayElements/CoachmarkOverlayElements.d.ts +46 -2
  40. package/es/components/CoachmarkOverlayElements/CoachmarkOverlayElements.js +5 -4
  41. package/es/components/CreateInfluencer/CreateInfluencer.d.ts +55 -17
  42. package/es/components/CreateInfluencer/CreateInfluencer.js +1 -1
  43. package/es/components/CreateTearsheet/CreateTearsheetStep.d.ts +95 -2
  44. package/es/components/CreateTearsheet/CreateTearsheetStep.js +7 -5
  45. package/es/components/DataSpreadsheet/DataSpreadsheet.d.ts +67 -2
  46. package/es/components/DataSpreadsheet/DataSpreadsheet.js +50 -28
  47. package/es/components/DataSpreadsheet/DataSpreadsheetBody.d.ts +139 -2
  48. package/es/components/DataSpreadsheet/DataSpreadsheetBody.js +46 -31
  49. package/es/components/DataSpreadsheet/DataSpreadsheetHeader.d.ts +89 -2
  50. package/es/components/DataSpreadsheet/DataSpreadsheetHeader.js +39 -25
  51. package/es/components/DataSpreadsheet/types/index.d.ts +30 -0
  52. package/es/components/Datagrid/Datagrid/DatagridVirtualBody.js +5 -1
  53. package/es/components/ExpressiveCard/ExpressiveCard.d.ts +2 -1
  54. package/es/components/GetStartedCard/GetStartedCard.d.ts +5 -0
  55. package/es/components/GetStartedCard/GetStartedCard.js +82 -0
  56. package/es/components/GetStartedCard/index.d.ts +1 -0
  57. package/es/components/Guidebanner/Guidebanner.d.ts +62 -2
  58. package/es/components/Guidebanner/Guidebanner.js +6 -5
  59. package/es/components/Guidebanner/GuidebannerElement.d.ts +30 -17
  60. package/es/components/Guidebanner/GuidebannerElement.js +4 -4
  61. package/es/components/Guidebanner/GuidebannerElementButton.d.ts +29 -15
  62. package/es/components/Guidebanner/GuidebannerElementButton.js +10 -4
  63. package/es/components/Guidebanner/GuidebannerElementLink.d.ts +20 -13
  64. package/es/components/Guidebanner/GuidebannerElementLink.js +3 -3
  65. package/es/components/InterstitialScreen/InterstitialScreen.js +3 -1
  66. package/es/components/MultiAddSelect/MultiAddSelect.d.ts +134 -2
  67. package/es/components/MultiAddSelect/MultiAddSelect.js +2 -1
  68. package/es/components/NotificationsPanel/NotificationsPanel.d.ts +162 -1
  69. package/es/components/NotificationsPanel/NotificationsPanel.js +10 -11
  70. package/es/components/PageHeader/PageHeader.d.ts +298 -5
  71. package/es/components/PageHeader/PageHeader.js +98 -47
  72. package/es/components/PageHeader/PageHeaderUtils.d.ts +1 -1
  73. package/es/components/PageHeader/PageHeaderUtils.js +4 -1
  74. package/es/components/SidePanel/SidePanel.d.ts +6 -2
  75. package/es/components/SidePanel/SidePanel.js +18 -3
  76. package/es/components/SidePanel/constants.d.ts +1 -0
  77. package/es/components/SidePanel/constants.js +1 -0
  78. package/es/components/SingleAddSelect/SingleAddSelect.d.ts +69 -2
  79. package/es/components/SingleAddSelect/SingleAddSelect.js +2 -1
  80. package/es/components/TagOverflow/TagOverflow.d.ts +5 -0
  81. package/es/components/TagOverflow/TagOverflow.js +153 -29
  82. package/es/components/TagOverflow/TagOverflowModal.d.ts +29 -0
  83. package/es/components/TagOverflow/TagOverflowModal.js +112 -0
  84. package/es/components/TagOverflow/TagOverflowPopover.d.ts +2 -0
  85. package/es/components/TagOverflow/TagOverflowPopover.js +135 -0
  86. package/es/components/Tearsheet/Tearsheet.d.ts +132 -6
  87. package/es/components/Tearsheet/Tearsheet.js +25 -13
  88. package/es/components/Tearsheet/TearsheetShell.d.ts +5 -1
  89. package/es/components/Tearsheet/TearsheetShell.js +26 -4
  90. package/es/components/WebTerminal/WebTerminal.d.ts +4 -0
  91. package/es/components/WebTerminal/WebTerminal.js +11 -3
  92. package/es/components/index.d.ts +1 -0
  93. package/es/global/js/hooks/useFocus.d.ts +3 -1
  94. package/es/global/js/hooks/useFocus.js +6 -3
  95. package/es/global/js/hooks/useRetrieveStepData.d.ts +1 -1
  96. package/es/global/js/hooks/useRetrieveStepData.js +1 -1
  97. package/es/global/js/package-settings.d.ts +1 -0
  98. package/es/global/js/package-settings.js +1 -0
  99. package/es/index.js +1 -0
  100. package/es/settings.d.ts +1 -0
  101. package/lib/components/AddSelect/AddSelect.d.ts +44 -2
  102. package/lib/components/AddSelect/AddSelect.js +7 -3
  103. package/lib/components/AddSelect/AddSelectBody.d.ts +44 -2
  104. package/lib/components/AddSelect/AddSelectBody.js +10 -12
  105. package/lib/components/AddSelect/AddSelectSort.d.ts +16 -17
  106. package/lib/components/AddSelect/AddSelectSort.js +5 -5
  107. package/lib/components/AddSelect/types/index.d.ts +44 -0
  108. package/lib/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.d.ts +5 -1
  109. package/lib/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.js +12 -6
  110. package/lib/components/Card/Card.js +50 -9
  111. package/lib/components/Card/CardFooter.d.ts +5 -1
  112. package/lib/components/Card/CardFooter.js +11 -1
  113. package/lib/components/Carousel/Carousel.d.ts +6 -2
  114. package/lib/components/Checklist/Checklist.d.ts +100 -2
  115. package/lib/components/Checklist/Checklist.js +9 -5
  116. package/lib/components/Checklist/Checklist.types.d.ts +19 -0
  117. package/lib/components/Checklist/Checklist.types.js +27 -0
  118. package/lib/components/Checklist/ChecklistChart.d.ts +5 -1
  119. package/lib/components/Checklist/ChecklistChart.js +14 -9
  120. package/lib/components/Checklist/ChecklistIcon.d.ts +5 -1
  121. package/lib/components/Checklist/ChecklistIcon.js +9 -4
  122. package/lib/components/CoachmarkButton/CoachmarkButton.d.ts +19 -2
  123. package/lib/components/CoachmarkOverlayElements/CoachmarkOverlayElements.d.ts +46 -2
  124. package/lib/components/CoachmarkOverlayElements/CoachmarkOverlayElements.js +5 -4
  125. package/lib/components/CreateInfluencer/CreateInfluencer.d.ts +55 -17
  126. package/lib/components/CreateInfluencer/CreateInfluencer.js +1 -1
  127. package/lib/components/CreateTearsheet/CreateTearsheetStep.d.ts +95 -2
  128. package/lib/components/CreateTearsheet/CreateTearsheetStep.js +7 -5
  129. package/lib/components/DataSpreadsheet/DataSpreadsheet.d.ts +67 -2
  130. package/lib/components/DataSpreadsheet/DataSpreadsheet.js +50 -28
  131. package/lib/components/DataSpreadsheet/DataSpreadsheetBody.d.ts +139 -2
  132. package/lib/components/DataSpreadsheet/DataSpreadsheetBody.js +46 -31
  133. package/lib/components/DataSpreadsheet/DataSpreadsheetHeader.d.ts +89 -2
  134. package/lib/components/DataSpreadsheet/DataSpreadsheetHeader.js +39 -25
  135. package/lib/components/DataSpreadsheet/types/index.d.ts +30 -0
  136. package/lib/components/Datagrid/Datagrid/DatagridVirtualBody.js +5 -1
  137. package/lib/components/ExpressiveCard/ExpressiveCard.d.ts +2 -1
  138. package/lib/components/GetStartedCard/GetStartedCard.d.ts +5 -0
  139. package/lib/components/GetStartedCard/GetStartedCard.js +88 -0
  140. package/lib/components/GetStartedCard/index.d.ts +1 -0
  141. package/lib/components/Guidebanner/Guidebanner.d.ts +62 -2
  142. package/lib/components/Guidebanner/Guidebanner.js +6 -5
  143. package/lib/components/Guidebanner/GuidebannerElement.d.ts +30 -17
  144. package/lib/components/Guidebanner/GuidebannerElement.js +4 -4
  145. package/lib/components/Guidebanner/GuidebannerElementButton.d.ts +29 -15
  146. package/lib/components/Guidebanner/GuidebannerElementButton.js +10 -4
  147. package/lib/components/Guidebanner/GuidebannerElementLink.d.ts +20 -13
  148. package/lib/components/Guidebanner/GuidebannerElementLink.js +3 -3
  149. package/lib/components/InterstitialScreen/InterstitialScreen.js +3 -1
  150. package/lib/components/MultiAddSelect/MultiAddSelect.d.ts +134 -2
  151. package/lib/components/MultiAddSelect/MultiAddSelect.js +2 -1
  152. package/lib/components/NotificationsPanel/NotificationsPanel.d.ts +162 -1
  153. package/lib/components/NotificationsPanel/NotificationsPanel.js +10 -11
  154. package/lib/components/PageHeader/PageHeader.d.ts +298 -5
  155. package/lib/components/PageHeader/PageHeader.js +98 -47
  156. package/lib/components/PageHeader/PageHeaderUtils.d.ts +1 -1
  157. package/lib/components/PageHeader/PageHeaderUtils.js +4 -1
  158. package/lib/components/SidePanel/SidePanel.d.ts +6 -2
  159. package/lib/components/SidePanel/SidePanel.js +18 -3
  160. package/lib/components/SidePanel/constants.d.ts +1 -0
  161. package/lib/components/SidePanel/constants.js +1 -0
  162. package/lib/components/SingleAddSelect/SingleAddSelect.d.ts +69 -2
  163. package/lib/components/SingleAddSelect/SingleAddSelect.js +2 -1
  164. package/lib/components/TagOverflow/TagOverflow.d.ts +5 -0
  165. package/lib/components/TagOverflow/TagOverflow.js +154 -28
  166. package/lib/components/TagOverflow/TagOverflowModal.d.ts +29 -0
  167. package/lib/components/TagOverflow/TagOverflowModal.js +121 -0
  168. package/lib/components/TagOverflow/TagOverflowPopover.d.ts +2 -0
  169. package/lib/components/TagOverflow/TagOverflowPopover.js +144 -0
  170. package/lib/components/Tearsheet/Tearsheet.d.ts +132 -6
  171. package/lib/components/Tearsheet/Tearsheet.js +25 -13
  172. package/lib/components/Tearsheet/TearsheetShell.d.ts +5 -1
  173. package/lib/components/Tearsheet/TearsheetShell.js +26 -4
  174. package/lib/components/WebTerminal/WebTerminal.d.ts +4 -0
  175. package/lib/components/WebTerminal/WebTerminal.js +11 -3
  176. package/lib/components/index.d.ts +1 -0
  177. package/lib/global/js/hooks/useFocus.d.ts +3 -1
  178. package/lib/global/js/hooks/useFocus.js +6 -3
  179. package/lib/global/js/hooks/useRetrieveStepData.d.ts +1 -1
  180. package/lib/global/js/hooks/useRetrieveStepData.js +1 -1
  181. package/lib/global/js/package-settings.d.ts +1 -0
  182. package/lib/global/js/package-settings.js +1 -0
  183. package/lib/index.js +5 -0
  184. package/lib/settings.d.ts +1 -0
  185. package/package.json +3 -3
  186. package/scss/components/CoachmarkStack/_coachmark-stack.scss +4 -2
  187. package/scss/components/GetStartedCard/_carbon-imports.scss +9 -0
  188. package/scss/components/GetStartedCard/_get-started-card.scss +135 -0
  189. package/scss/components/GetStartedCard/_index-with-carbon.scss +9 -0
  190. package/scss/components/GetStartedCard/_index.scss +8 -0
  191. package/scss/components/SidePanel/_side-panel-variables.scss +1 -0
  192. package/scss/components/StringFormatter/_string-formatter.scss +1 -1
  193. package/scss/components/TagOverflow/_tag-overflow.scss +157 -0
  194. package/scss/components/_index-with-carbon.scss +1 -0
  195. package/scss/components/_index.scss +1 -0
  196. package/telemetry.yml +25 -16
@@ -2,4 +2,9 @@
2
2
  * TODO: A description of the component.
3
3
  */
4
4
  export let TagOverflow: React.ForwardRefExoticComponent<React.RefAttributes<any>>;
5
+ /**
6
+ * The strings shown in the showAllModal are only shown if we have more than allTagsModalSearchLThreshold
7
+ * @returns null if no problems
8
+ */
9
+ export const string_required_if_more_than_10_tags: (props: any, propName: any, componentName: any, location: any, propFullName: any, secret: any) => any;
5
10
  import React from 'react';
@@ -10,40 +10,67 @@ import React__default, { useRef, useState, useCallback, useEffect } from 'react'
10
10
  import PropTypes from '../../node_modules/prop-types/index.js';
11
11
  import cx from 'classnames';
12
12
  import { getDevtoolsProps } from '../../global/js/utils/devtools.js';
13
+ import { isRequiredIf } from '../../global/js/utils/props-helper.js';
13
14
  import { pkg } from '../../settings.js';
14
15
  import { Tooltip, Tag } from '@carbon/react';
15
16
  import { TYPES } from './constants.js';
16
17
  import { useResizeObserver } from '../../global/js/hooks/useResizeObserver.js';
17
- import { TagSet } from '../TagSet/TagSet.js';
18
+ import { TagOverflowPopover } from './TagOverflowPopover.js';
19
+ import { TagOverflowModal } from './TagOverflowModal.js';
18
20
 
19
- var _excluded = ["className", "items", "tagComponent", "maxVisible", "multiline"],
21
+ var _excluded = ["items", "tagComponent", "align", "showAllTagsLabel", "allTagsModalSearchLabel", "allTagsModalSearchPlaceholderText", "allTagsModalTarget", "allTagsModalTitle", "className", "containingElementRef", "measurementOffset", "maxVisible", "multiline", "overflowAlign", "overflowClassName", "overflowType", "onOverflowTagChange"],
20
22
  _excluded2 = ["className", "id"];
21
23
  var blockClass = "".concat(pkg.prefix, "--tag-overflow");
22
24
  var componentName = 'TagOverflow';
25
+ var allTagsModalSearchThreshold = 10;
26
+
27
+ // TODO: support prop overflowType
23
28
 
24
29
  // Default values for props
25
30
  var defaults = {
26
- items: []
31
+ items: [],
32
+ align: 'start',
33
+ measurementOffset: 0,
34
+ overflowAlign: 'bottom',
35
+ overflowType: 'default',
36
+ onOverflowTagChange: function onOverflowTagChange() {}
27
37
  };
28
38
 
29
39
  /**
30
40
  * TODO: A description of the component.
31
41
  */
32
42
  var TagOverflow = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
33
- var className = _ref.className,
34
- _ref$items = _ref.items,
43
+ var _ref$items = _ref.items,
35
44
  items = _ref$items === void 0 ? defaults.items : _ref$items,
36
45
  tagComponent = _ref.tagComponent,
46
+ _ref$align = _ref.align,
47
+ align = _ref$align === void 0 ? defaults.align : _ref$align,
48
+ showAllTagsLabel = _ref.showAllTagsLabel,
49
+ allTagsModalSearchLabel = _ref.allTagsModalSearchLabel,
50
+ allTagsModalSearchPlaceholderText = _ref.allTagsModalSearchPlaceholderText,
51
+ allTagsModalTarget = _ref.allTagsModalTarget,
52
+ allTagsModalTitle = _ref.allTagsModalTitle,
53
+ className = _ref.className,
54
+ containingElementRef = _ref.containingElementRef,
55
+ _ref$measurementOffse = _ref.measurementOffset,
56
+ measurementOffset = _ref$measurementOffse === void 0 ? defaults.measurementOffset : _ref$measurementOffse,
37
57
  maxVisible = _ref.maxVisible,
38
58
  multiline = _ref.multiline,
59
+ _ref$overflowAlign = _ref.overflowAlign,
60
+ overflowAlign = _ref$overflowAlign === void 0 ? defaults.overflowAlign : _ref$overflowAlign,
61
+ overflowClassName = _ref.overflowClassName,
62
+ _ref$overflowType = _ref.overflowType,
63
+ overflowType = _ref$overflowType === void 0 ? defaults.overflowType : _ref$overflowType,
64
+ _ref$onOverflowTagCha = _ref.onOverflowTagChange,
65
+ onOverflowTagChange = _ref$onOverflowTagCha === void 0 ? defaults.onOverflowTagChange : _ref$onOverflowTagCha,
39
66
  rest = _objectWithoutProperties(_ref, _excluded);
40
67
  var localContainerRef = useRef(null);
41
68
  var containerRef = ref || localContainerRef;
42
69
  var itemRefs = useRef(null);
43
70
  var overflowRef = useRef(null);
44
- // measurementOffset is the value of margin applied on each items
71
+ // itemOffset is the value of margin applied on each items
45
72
  // This value is required for calculating how many items will fit within the container
46
- var measurementOffset = 4;
73
+ var itemOffset = 4;
47
74
  var overflowIndicatorWidth = 40;
48
75
  var _useState = useState(0),
49
76
  _useState2 = _slicedToArray(_useState, 2),
@@ -57,10 +84,25 @@ var TagOverflow = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
57
84
  _useState6 = _slicedToArray(_useState5, 2),
58
85
  overflowItems = _useState6[0],
59
86
  setOverflowItems = _useState6[1];
87
+ var _useState7 = useState(false),
88
+ _useState8 = _slicedToArray(_useState7, 2),
89
+ showAllModalOpen = _useState8[0],
90
+ setShowAllModalOpen = _useState8[1];
91
+ var _useState9 = useState(false),
92
+ _useState10 = _slicedToArray(_useState9, 2),
93
+ popoverOpen = _useState10[0],
94
+ setPopoverOpen = _useState10[1];
95
+ var resizeElm = containingElementRef && containingElementRef.current ? containingElementRef : containerRef;
96
+ var handleShowAllClick = function handleShowAllClick() {
97
+ setShowAllModalOpen(true);
98
+ };
99
+ var handleModalClose = function handleModalClose() {
100
+ setShowAllModalOpen(false);
101
+ };
60
102
  var handleResize = function handleResize() {
61
- setContainerWidth(containerRef.current.offsetWidth);
103
+ setContainerWidth(resizeElm.current.offsetWidth);
62
104
  };
63
- useResizeObserver(containerRef, handleResize);
105
+ useResizeObserver(resizeElm, handleResize);
64
106
  var getMap = function getMap() {
65
107
  if (!itemRefs.current) {
66
108
  itemRefs.current = new Map();
@@ -74,6 +116,7 @@ var TagOverflow = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
74
116
  }
75
117
  };
76
118
  var getVisibleItems = useCallback(function () {
119
+ var _overflowRef$current;
77
120
  if (!itemRefs.current) {
78
121
  return items;
79
122
  }
@@ -82,13 +125,16 @@ var TagOverflow = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
82
125
  return _visibleItems;
83
126
  }
84
127
  var map = getMap();
85
- var overflowContainerWidth = overflowRef.current.offsetWidth > overflowIndicatorWidth ? overflowRef.current.offsetWidth : overflowIndicatorWidth;
86
- var maxWidth = containerWidth - overflowContainerWidth;
128
+ var optionalContainingElement = containingElementRef === null || containingElementRef === void 0 ? void 0 : containingElementRef.current;
129
+ var measurementOffsetValue = typeof measurementOffset === 'number' ? measurementOffset : 0;
130
+ var spaceAvailable = optionalContainingElement ? optionalContainingElement.offsetWidth - measurementOffsetValue : containerWidth;
131
+ var overflowContainerWidth = ((_overflowRef$current = overflowRef.current) === null || _overflowRef$current === void 0 ? void 0 : _overflowRef$current.offsetWidth) > overflowIndicatorWidth ? overflowRef.current.offsetWidth : overflowIndicatorWidth;
132
+ var maxWidth = spaceAvailable - overflowContainerWidth;
87
133
  var childrenWidth = 0;
88
134
  var maxReached = false;
89
135
  return items.reduce(function (prev, cur) {
90
136
  if (!maxReached) {
91
- var itemWidth = map.get(cur.id) + measurementOffset;
137
+ var itemWidth = map.get(cur.id) + itemOffset;
92
138
  var fits = itemWidth + childrenWidth < maxWidth;
93
139
  if (fits) {
94
140
  childrenWidth += itemWidth;
@@ -99,7 +145,7 @@ var TagOverflow = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
99
145
  }
100
146
  return prev;
101
147
  }, []);
102
- }, [itemRefs, overflowRef, containerWidth, items, multiline, maxVisible]);
148
+ }, [itemRefs, overflowRef, containerWidth, items, multiline, maxVisible, containingElementRef, measurementOffset]);
103
149
  var getCustomComponent = function getCustomComponent(item) {
104
150
  var className = item.className,
105
151
  id = item.id,
@@ -121,14 +167,16 @@ var TagOverflow = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
121
167
  var overflowItemsArr = hiddenItems === null || hiddenItems === void 0 ? void 0 : hiddenItems.map(function (item) {
122
168
  return {
123
169
  type: item.tagType,
124
- label: item.label
170
+ label: item.label,
171
+ id: item.id
125
172
  };
126
173
  });
127
174
  setVisibleItems(visibleItemsArr);
128
175
  setOverflowItems(overflowItemsArr);
129
- }, [containerWidth, items, maxVisible, getVisibleItems]);
176
+ onOverflowTagChange === null || onOverflowTagChange === void 0 || onOverflowTagChange(overflowItemsArr);
177
+ }, [containerWidth, items, maxVisible, getVisibleItems, onOverflowTagChange]);
130
178
  return /*#__PURE__*/React__default.createElement("div", _extends({}, rest, {
131
- className: cx(blockClass, className, _defineProperty({}, "".concat(blockClass, "--multiline"), multiline)),
179
+ className: cx(blockClass, className, "".concat(blockClass, "--align-").concat(align), _defineProperty({}, "".concat(blockClass, "--multiline"), multiline)),
132
180
  ref: containerRef,
133
181
  role: "main"
134
182
  }, getDevtoolsProps(componentName)), visibleItems.length > 0 && visibleItems.map(function (item) {
@@ -153,14 +201,27 @@ var TagOverflow = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
153
201
  }), /*#__PURE__*/React__default.createElement("span", {
154
202
  className: "".concat(blockClass, "__indicator"),
155
203
  ref: overflowRef
156
- }, overflowItems.length > 0 && /*#__PURE__*/React__default.createElement(TagSet, {
157
- tags: overflowItems,
158
- allTagsModalTitle: "All tags",
159
- containingElementRef: overflowRef,
160
- allTagsModalSearchLabel: "Search all tags",
161
- allTagsModalSearchPlaceholderText: "Search all tags",
162
- showAllTagsLabel: "Show all tags"
163
- })));
204
+ }, overflowItems.length > 0 && /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(TagOverflowPopover, {
205
+ allTagsModalSearchThreshold: allTagsModalSearchThreshold,
206
+ className: overflowClassName,
207
+ onShowAllClick: handleShowAllClick,
208
+ overflowTags: overflowItems,
209
+ overflowAlign: overflowAlign,
210
+ overflowType: overflowType,
211
+ showAllTagsLabel: showAllTagsLabel,
212
+ key: "tag-overflow-popover",
213
+ ref: overflowRef,
214
+ popoverOpen: popoverOpen,
215
+ setPopoverOpen: setPopoverOpen
216
+ }), /*#__PURE__*/React__default.createElement(TagOverflowModal, {
217
+ allTags: items,
218
+ open: showAllModalOpen,
219
+ title: allTagsModalTitle,
220
+ onClose: handleModalClose,
221
+ searchLabel: allTagsModalSearchLabel,
222
+ searchPlaceholder: allTagsModalSearchPlaceholderText,
223
+ portalTarget: allTagsModalTarget
224
+ }))));
164
225
  });
165
226
 
166
227
  // Return a placeholder if not released and not enabled by feature flag
@@ -171,20 +232,56 @@ TagOverflow = pkg.checkComponentEnabled(TagOverflow, componentName);
171
232
  TagOverflow.displayName = componentName;
172
233
  var tagTypes = Object.keys(TYPES);
173
234
 
235
+ /**
236
+ * The strings shown in the showAllModal are only shown if we have more than allTagsModalSearchLThreshold
237
+ * @returns null if no problems
238
+ */
239
+ var string_required_if_more_than_10_tags = isRequiredIf(PropTypes.string, function (_ref2) {
240
+ var items = _ref2.items;
241
+ return items && items.length > allTagsModalSearchThreshold;
242
+ });
243
+
174
244
  // The types and DocGen commentary for the component props,
175
245
  // in alphabetical order (for consistency).
176
246
  // See https://www.npmjs.com/package/prop-types#usage.
177
247
  TagOverflow.propTypes = {
248
+ /**
249
+ * align the Tags displayed by the TagSet. Default start.
250
+ */
251
+ align: PropTypes.oneOf(['start', 'center', 'end']),
252
+ /**
253
+ * label text for the show all search. **Note: Required if more than 10 tags**
254
+ */
255
+ allTagsModalSearchLabel: string_required_if_more_than_10_tags,
256
+ /**
257
+ * placeholder text for the show all search. **Note: Required if more than 10 tags**
258
+ */
259
+ allTagsModalSearchPlaceholderText: string_required_if_more_than_10_tags,
260
+ /**
261
+ * portal target for the all tags modal
262
+ */
263
+ allTagsModalTarget: PropTypes.node,
264
+ /**
265
+ * title for the show all modal. **Note: Required if more than 10 tags**
266
+ */
267
+ allTagsModalTitle: string_required_if_more_than_10_tags,
178
268
  /**
179
269
  * Provide an optional class to be applied to the containing node.
180
270
  */
181
271
  className: PropTypes.string,
272
+ /**
273
+ * Optional ref for custom resize container to measure available space
274
+ * Default will measure the available space of the TagSet container itself.
275
+ */
276
+ containingElementRef: PropTypes.object,
182
277
  /**
183
278
  * The items to be shown in the TagOverflow. Each item is specified as an object with properties:
184
- * **label**\* (required) to supply the item content,
185
- * **id**\* (required) to uniquely identify the each item.
186
- * **tagType** the type value to be passed to the Carbon Tag component
187
- * if you are passing an tagComponent prop for rendering custom components,
279
+ * **label**\* (required) to supply the content,
280
+ * **id**\* (required) to uniquely identify each item.
281
+ * **tagType** the type value to be passed to the Carbon Tag component.
282
+ * Refer https://react.carbondesignsystem.com/?path=/docs/components-tag--default to see the possible values for tagType
283
+ *
284
+ * If you want to render a custom component, pass it as tagComponent prop and
188
285
  * then pass the props required for your custom component as the properties of item object
189
286
  */
190
287
  items: PropTypes.arrayOf(PropTypes.shape({
@@ -196,14 +293,41 @@ TagOverflow.propTypes = {
196
293
  * maximum visible items
197
294
  */
198
295
  maxVisible: PropTypes.number,
296
+ /**
297
+ * Specify offset amount for measure available space, only used when `containingElementSelector`
298
+ * is also provided
299
+ */
300
+ measurementOffset: PropTypes.number,
199
301
  /**
200
302
  * display items in multiple lines
201
303
  */
202
304
  multiline: PropTypes.bool,
305
+ /**
306
+ * Handler to get overflow tags
307
+ */
308
+ onOverflowTagChange: PropTypes.func,
309
+ /**
310
+ * overflowAlign from the standard tooltip. Default center.
311
+ */
312
+ overflowAlign: PropTypes.oneOf(['top', 'top-left', 'top-right', 'bottom', 'bottom-left', 'bottom-right', 'left', 'left-bottom', 'left-top', 'right', 'right-bottom', 'right-top']),
313
+ /**
314
+ * overflowClassName for the tooltip popup
315
+ */
316
+ overflowClassName: PropTypes.string,
317
+ /**
318
+ * Type of rendering displayed inside of the tag overflow component
319
+ */
320
+ overflowType: PropTypes.oneOf(['default', 'tag']),
321
+ /**
322
+ * label for the overflow show all tags link.
323
+ *
324
+ * **Note:** Required if more than 10 tags
325
+ */
326
+ showAllTagsLabel: string_required_if_more_than_10_tags,
203
327
  /** Component definition of the items to be rendered inside TagOverflow.
204
328
  * If this is not passed, items will be rendered as Tag component
205
329
  */
206
330
  tagComponent: PropTypes.elementType
207
331
  };
208
332
 
209
- export { TagOverflow };
333
+ export { TagOverflow, string_required_if_more_than_10_tags };
@@ -0,0 +1,29 @@
1
+ export function TagOverflowModal({ allTags, className, title, onClose, open, portalTarget: portalTargetIn, searchLabel, searchPlaceholder, ...rest }: {
2
+ [x: string]: any;
3
+ allTags: any;
4
+ className: any;
5
+ title: any;
6
+ onClose: any;
7
+ open: any;
8
+ portalTarget: any;
9
+ searchLabel?: string | undefined;
10
+ searchPlaceholder: any;
11
+ }): any;
12
+ export namespace TagOverflowModal {
13
+ export namespace propTypes {
14
+ let allTags: PropTypes.Requireable<(PropTypes.InferProps<{
15
+ label: PropTypes.Validator<string>;
16
+ }> | null | undefined)[]>;
17
+ let className: PropTypes.Requireable<string>;
18
+ let onClose: PropTypes.Requireable<(...args: any[]) => any>;
19
+ let open: PropTypes.Requireable<boolean>;
20
+ let portalTarget: PropTypes.Requireable<PropTypes.ReactNodeLike>;
21
+ let searchLabel: PropTypes.Requireable<string>;
22
+ let searchPlaceholder: PropTypes.Requireable<string>;
23
+ let title: PropTypes.Requireable<string>;
24
+ }
25
+ export { componentName as displayName };
26
+ }
27
+ import PropTypes from 'prop-types';
28
+ declare const componentName: "TagOverflowModal";
29
+ export {};
@@ -0,0 +1,112 @@
1
+ /**
2
+ * Copyright IBM Corp. 2020, 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
+
8
+ import { objectWithoutProperties as _objectWithoutProperties, slicedToArray as _slicedToArray, extends as _extends, objectSpread2 as _objectSpread2 } from '../../_virtual/_rollupPluginBabelHelpers.js';
9
+ import React__default, { useState } from 'react';
10
+ import PropTypes from '../../node_modules/prop-types/index.js';
11
+ import cx from 'classnames';
12
+ import { ComposedModal, ModalHeader, Search, ModalBody, Tag } from '@carbon/react';
13
+ import { pkg } from '../../settings.js';
14
+ import { prepareProps } from '../../global/js/utils/props-helper.js';
15
+ import { usePortalTarget } from '../../global/js/hooks/usePortalTarget.js';
16
+
17
+ var _excluded = ["allTags", "className", "title", "onClose", "open", "portalTarget", "searchLabel", "searchPlaceholder"],
18
+ _excluded2 = ["label", "id"];
19
+ var componentName = 'TagOverflowModal';
20
+ var blockClass = "".concat(pkg.prefix, "--tag-overflow-modal");
21
+
22
+ // Default values for props
23
+ var defaults = {
24
+ // marked as required by TagSet if needed, default used to satisfy <Search /> component
25
+ searchLabel: ''
26
+ };
27
+ var TagOverflowModal = function TagOverflowModal(_ref) {
28
+ var allTags = _ref.allTags,
29
+ className = _ref.className,
30
+ title = _ref.title,
31
+ onClose = _ref.onClose,
32
+ open = _ref.open,
33
+ portalTargetIn = _ref.portalTarget,
34
+ _ref$searchLabel = _ref.searchLabel,
35
+ searchLabel = _ref$searchLabel === void 0 ? defaults.searchLabel : _ref$searchLabel,
36
+ searchPlaceholder = _ref.searchPlaceholder,
37
+ rest = _objectWithoutProperties(_ref, _excluded);
38
+ var _useState = useState(''),
39
+ _useState2 = _slicedToArray(_useState, 2),
40
+ search = _useState2[0],
41
+ setSearch = _useState2[1];
42
+ var renderPortalUse = usePortalTarget(portalTargetIn);
43
+ var getFilteredItems = function getFilteredItems() {
44
+ var newFilteredModalTags = [];
45
+ if (open) {
46
+ if (search === '') {
47
+ newFilteredModalTags = allTags.slice(0);
48
+ } else {
49
+ var lCaseSearch = search.toLocaleLowerCase();
50
+ allTags.forEach(function (tag) {
51
+ var _tag$dataSearch, _tag$label;
52
+ var dataSearch = (_tag$dataSearch = tag['data-search']) === null || _tag$dataSearch === void 0 || (_tag$dataSearch = _tag$dataSearch.toLocaleLowerCase()) === null || _tag$dataSearch === void 0 ? void 0 : _tag$dataSearch.indexOf(lCaseSearch);
53
+ var labelSearch = (_tag$label = tag.label) === null || _tag$label === void 0 || (_tag$label = _tag$label.toLocaleLowerCase()) === null || _tag$label === void 0 ? void 0 : _tag$label.indexOf(lCaseSearch);
54
+ if (dataSearch > -1 || labelSearch > -1) {
55
+ newFilteredModalTags.push(tag);
56
+ }
57
+ });
58
+ }
59
+ }
60
+ return newFilteredModalTags;
61
+ };
62
+ var handleSearch = function handleSearch(evt) {
63
+ setSearch(evt.target.value || '');
64
+ };
65
+ return renderPortalUse( /*#__PURE__*/React__default.createElement(ComposedModal, _extends({}, rest, {
66
+ containerClassName: "".concat(blockClass, "__container"),
67
+ className: cx(className, blockClass),
68
+ size: "sm",
69
+ "aria-label": "Search all",
70
+ open: open,
71
+ onClose: onClose
72
+ }), /*#__PURE__*/React__default.createElement(ModalHeader, {
73
+ className: "".concat(blockClass, "__header"),
74
+ closeModal: onClose,
75
+ title: title
76
+ }, /*#__PURE__*/React__default.createElement(Search, {
77
+ "data-modal-primary-focus": true,
78
+ className: "".concat(blockClass, "__search"),
79
+ labelText: searchLabel,
80
+ placeholder: searchPlaceholder,
81
+ onChange: handleSearch,
82
+ size: "lg"
83
+ })), /*#__PURE__*/React__default.createElement(ModalBody, {
84
+ className: "".concat(blockClass, "__body"),
85
+ hasForm: true
86
+ }, getFilteredItems().map(function (_ref2) {
87
+ var label = _ref2.label,
88
+ id = _ref2.id,
89
+ other = _objectWithoutProperties(_ref2, _excluded2);
90
+ return /*#__PURE__*/React__default.createElement(Tag, _extends({}, other, {
91
+ filter: false,
92
+ key: id
93
+ }), label);
94
+ })), /*#__PURE__*/React__default.createElement("div", {
95
+ className: "".concat(blockClass, "__fade")
96
+ })));
97
+ };
98
+ TagOverflowModal.propTypes = {
99
+ allTags: PropTypes.arrayOf(PropTypes.shape(_objectSpread2(_objectSpread2({}, prepareProps(Tag.propTypes, 'filter')), {}, {
100
+ label: PropTypes.string.isRequired
101
+ }))),
102
+ className: PropTypes.string,
103
+ onClose: PropTypes.func,
104
+ open: PropTypes.bool,
105
+ portalTarget: PropTypes.node,
106
+ searchLabel: PropTypes.string,
107
+ searchPlaceholder: PropTypes.string,
108
+ title: PropTypes.string
109
+ };
110
+ TagOverflowModal.displayName = componentName;
111
+
112
+ export { TagOverflowModal };
@@ -0,0 +1,2 @@
1
+ export const TagOverflowPopover: React.ForwardRefExoticComponent<React.RefAttributes<any>>;
2
+ import React from 'react';
@@ -0,0 +1,135 @@
1
+ /**
2
+ * Copyright IBM Corp. 2020, 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
+
8
+ import { objectWithoutProperties as _objectWithoutProperties, extends as _extends, defineProperty as _defineProperty } from '../../_virtual/_rollupPluginBabelHelpers.js';
9
+ import React__default, { useRef } from 'react';
10
+ import PropTypes from '../../node_modules/prop-types/index.js';
11
+ import cx from 'classnames';
12
+ import { Popover, Tag, PopoverContent, Link } from '@carbon/react';
13
+ import { pkg } from '../../settings.js';
14
+ import { useClickOutside } from '../../global/js/hooks/useClickOutside.js';
15
+
16
+ var _excluded = ["allTagsModalSearchThreshold", "className", "onShowAllClick", "overflowAlign", "overflowTags", "overflowType", "showAllTagsLabel", "popoverOpen", "setPopoverOpen"];
17
+ var componentName = 'TagOverflowPopover';
18
+ var blockClass = "".concat(pkg.prefix, "--tag-overflow-popover");
19
+
20
+ // Default values for props
21
+ var defaults = {
22
+ allTagsModalSearchThreshold: 10,
23
+ overflowAlign: 'bottom'
24
+ };
25
+ var TagOverflowPopover = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
26
+ var _ref$allTagsModalSear = _ref.allTagsModalSearchThreshold,
27
+ allTagsModalSearchThreshold = _ref$allTagsModalSear === void 0 ? defaults.allTagsModalSearchThreshold : _ref$allTagsModalSear,
28
+ className = _ref.className,
29
+ onShowAllClick = _ref.onShowAllClick,
30
+ _ref$overflowAlign = _ref.overflowAlign,
31
+ overflowAlign = _ref$overflowAlign === void 0 ? defaults.overflowAlign : _ref$overflowAlign,
32
+ overflowTags = _ref.overflowTags,
33
+ overflowType = _ref.overflowType,
34
+ showAllTagsLabel = _ref.showAllTagsLabel,
35
+ popoverOpen = _ref.popoverOpen,
36
+ setPopoverOpen = _ref.setPopoverOpen,
37
+ rest = _objectWithoutProperties(_ref, _excluded);
38
+ var localRef = useRef();
39
+ var overflowTagContent = useRef(null);
40
+ useClickOutside(ref || localRef, function () {
41
+ if (popoverOpen) {
42
+ setPopoverOpen(false);
43
+ }
44
+ });
45
+ var handleShowAllTagsClick = function handleShowAllTagsClick(evt) {
46
+ evt.stopPropagation();
47
+ evt.preventDefault();
48
+ setPopoverOpen(false);
49
+ onShowAllClick();
50
+ };
51
+ var handleEscKeyPress = function handleEscKeyPress(event) {
52
+ var key = event.key;
53
+ if (key === 'Escape') {
54
+ setPopoverOpen(false);
55
+ }
56
+ };
57
+ var getOverflowPopoverItems = function getOverflowPopoverItems() {
58
+ return overflowTags.filter(function (_, index) {
59
+ return overflowTags.length > allTagsModalSearchThreshold ? index < allTagsModalSearchThreshold : index <= allTagsModalSearchThreshold;
60
+ });
61
+ };
62
+ return /*#__PURE__*/React__default.createElement("span", _extends({}, rest, {
63
+ "aria-hidden": overflowTags.length === 0,
64
+ className: cx(blockClass, _defineProperty({}, "".concat(blockClass, "--hidden"), overflowTags.length === 0)),
65
+ ref: ref || localRef
66
+ }), /*#__PURE__*/React__default.createElement(Popover, {
67
+ align: overflowAlign,
68
+ className: cx(className, "".concat(blockClass, "__el")),
69
+ dropShadow: true,
70
+ highContrast: true,
71
+ onKeyDown: handleEscKeyPress,
72
+ open: popoverOpen
73
+ }, /*#__PURE__*/React__default.createElement(Tag, {
74
+ onClick: function onClick() {
75
+ return setPopoverOpen(!popoverOpen);
76
+ },
77
+ className: cx("".concat(blockClass, "__trigger"))
78
+ }, "+", overflowTags.length), /*#__PURE__*/React__default.createElement(PopoverContent, null, /*#__PURE__*/React__default.createElement("div", {
79
+ ref: overflowTagContent,
80
+ className: "".concat(blockClass, "__content")
81
+ }, /*#__PURE__*/React__default.createElement("ul", {
82
+ className: "".concat(blockClass, "__tag-list")
83
+ }, getOverflowPopoverItems().map(function (tag) {
84
+ return /*#__PURE__*/React__default.createElement("li", {
85
+ className: cx("".concat(blockClass, "__tag-item"), _defineProperty(_defineProperty({}, "".concat(blockClass, "__tag-item--default"), overflowType === 'default'), "".concat(blockClass, "__tag-item--tag"), overflowType === 'tag')),
86
+ key: tag.id
87
+ }, tag.label);
88
+ })), overflowTags.length > allTagsModalSearchThreshold && /*#__PURE__*/React__default.createElement(Link, {
89
+ className: "".concat(blockClass, "__show-all-tags-link"),
90
+ href: "",
91
+ onClick: handleShowAllTagsClick,
92
+ role: "button"
93
+ }, showAllTagsLabel)))));
94
+ });
95
+ TagOverflowPopover.displayName = componentName;
96
+ TagOverflowPopover.propTypes = {
97
+ /**
98
+ * count of overflowTags over which a modal is offered
99
+ */
100
+ allTagsModalSearchThreshold: PropTypes.number,
101
+ /**
102
+ * className
103
+ */
104
+ className: PropTypes.string,
105
+ /**
106
+ * function to execute on clicking show all
107
+ */
108
+ onShowAllClick: PropTypes.func.isRequired,
109
+ /**
110
+ * overflowAlign from the standard tooltip
111
+ */
112
+ overflowAlign: PropTypes.oneOf(['top', 'top-left', 'top-right', 'bottom', 'bottom-left', 'bottom-right', 'left', 'left-bottom', 'left-top', 'right', 'right-bottom', 'right-top']),
113
+ /**
114
+ * tags shown in overflow
115
+ */
116
+ overflowTags: PropTypes.arrayOf(PropTypes.object).isRequired,
117
+ /**
118
+ * Type of rendering displayed inside of the tag overflow component
119
+ */
120
+ overflowType: PropTypes.oneOf(['default', 'tag']),
121
+ /**
122
+ * Open state of the popover
123
+ */
124
+ popoverOpen: PropTypes.bool,
125
+ /**
126
+ * Setter function for the popoverOpen state value
127
+ */
128
+ setPopoverOpen: PropTypes.func,
129
+ /**
130
+ * label for the overflow show all tags link
131
+ */
132
+ showAllTagsLabel: PropTypes.string
133
+ };
134
+
135
+ export { TagOverflowPopover };