@carbon/ibm-products 2.38.0 → 2.39.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (103) hide show
  1. package/css/index-full-carbon.css +227 -0
  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.css +227 -0
  6. package/css/index-without-carbon.css.map +1 -1
  7. package/css/index-without-carbon.min.css +1 -1
  8. package/css/index-without-carbon.min.css.map +1 -1
  9. package/css/index.css +227 -0
  10. package/css/index.css.map +1 -1
  11. package/css/index.min.css +1 -1
  12. package/css/index.min.css.map +1 -1
  13. package/es/components/Card/Card.js +50 -9
  14. package/es/components/Card/CardFooter.d.ts +5 -1
  15. package/es/components/Card/CardFooter.js +11 -1
  16. package/es/components/Carousel/Carousel.d.ts +6 -2
  17. package/es/components/Checklist/Checklist.d.ts +100 -2
  18. package/es/components/Checklist/Checklist.js +9 -5
  19. package/es/components/Checklist/Checklist.types.d.ts +19 -0
  20. package/es/components/Checklist/Checklist.types.js +22 -0
  21. package/es/components/Checklist/ChecklistChart.d.ts +5 -1
  22. package/es/components/Checklist/ChecklistChart.js +9 -4
  23. package/es/components/Checklist/ChecklistIcon.d.ts +5 -1
  24. package/es/components/Checklist/ChecklistIcon.js +9 -4
  25. package/es/components/CoachmarkButton/CoachmarkButton.d.ts +19 -2
  26. package/es/components/CoachmarkOverlayElements/CoachmarkOverlayElements.d.ts +46 -2
  27. package/es/components/CoachmarkOverlayElements/CoachmarkOverlayElements.js +5 -4
  28. package/es/components/CreateInfluencer/CreateInfluencer.d.ts +55 -17
  29. package/es/components/DataSpreadsheet/DataSpreadsheet.d.ts +67 -2
  30. package/es/components/DataSpreadsheet/DataSpreadsheet.js +48 -27
  31. package/es/components/DataSpreadsheet/DataSpreadsheetBody.d.ts +139 -2
  32. package/es/components/DataSpreadsheet/DataSpreadsheetBody.js +46 -31
  33. package/es/components/DataSpreadsheet/DataSpreadsheetHeader.d.ts +89 -2
  34. package/es/components/DataSpreadsheet/DataSpreadsheetHeader.js +34 -25
  35. package/es/components/DataSpreadsheet/types/index.d.ts +30 -0
  36. package/es/components/GetStartedCard/GetStartedCard.d.ts +5 -0
  37. package/es/components/GetStartedCard/GetStartedCard.js +82 -0
  38. package/es/components/GetStartedCard/index.d.ts +1 -0
  39. package/es/components/Guidebanner/Guidebanner.js +2 -2
  40. package/es/components/NotificationsPanel/NotificationsPanel.d.ts +162 -1
  41. package/es/components/NotificationsPanel/NotificationsPanel.js +10 -10
  42. package/es/components/SidePanel/SidePanel.js +1 -1
  43. package/es/components/TagOverflow/TagOverflow.d.ts +5 -0
  44. package/es/components/TagOverflow/TagOverflow.js +153 -29
  45. package/es/components/TagOverflow/TagOverflowModal.d.ts +29 -0
  46. package/es/components/TagOverflow/TagOverflowModal.js +112 -0
  47. package/es/components/TagOverflow/TagOverflowPopover.d.ts +2 -0
  48. package/es/components/TagOverflow/TagOverflowPopover.js +135 -0
  49. package/es/components/index.d.ts +1 -0
  50. package/es/global/js/package-settings.d.ts +1 -0
  51. package/es/global/js/package-settings.js +1 -0
  52. package/es/index.js +1 -0
  53. package/es/settings.d.ts +1 -0
  54. package/lib/components/Card/Card.js +50 -9
  55. package/lib/components/Card/CardFooter.d.ts +5 -1
  56. package/lib/components/Card/CardFooter.js +11 -1
  57. package/lib/components/Carousel/Carousel.d.ts +6 -2
  58. package/lib/components/Checklist/Checklist.d.ts +100 -2
  59. package/lib/components/Checklist/Checklist.js +9 -5
  60. package/lib/components/Checklist/Checklist.types.d.ts +19 -0
  61. package/lib/components/Checklist/Checklist.types.js +27 -0
  62. package/lib/components/Checklist/ChecklistChart.d.ts +5 -1
  63. package/lib/components/Checklist/ChecklistChart.js +14 -9
  64. package/lib/components/Checklist/ChecklistIcon.d.ts +5 -1
  65. package/lib/components/Checklist/ChecklistIcon.js +9 -4
  66. package/lib/components/CoachmarkButton/CoachmarkButton.d.ts +19 -2
  67. package/lib/components/CoachmarkOverlayElements/CoachmarkOverlayElements.d.ts +46 -2
  68. package/lib/components/CoachmarkOverlayElements/CoachmarkOverlayElements.js +5 -4
  69. package/lib/components/CreateInfluencer/CreateInfluencer.d.ts +55 -17
  70. package/lib/components/DataSpreadsheet/DataSpreadsheet.d.ts +67 -2
  71. package/lib/components/DataSpreadsheet/DataSpreadsheet.js +48 -27
  72. package/lib/components/DataSpreadsheet/DataSpreadsheetBody.d.ts +139 -2
  73. package/lib/components/DataSpreadsheet/DataSpreadsheetBody.js +46 -31
  74. package/lib/components/DataSpreadsheet/DataSpreadsheetHeader.d.ts +89 -2
  75. package/lib/components/DataSpreadsheet/DataSpreadsheetHeader.js +34 -25
  76. package/lib/components/DataSpreadsheet/types/index.d.ts +30 -0
  77. package/lib/components/GetStartedCard/GetStartedCard.d.ts +5 -0
  78. package/lib/components/GetStartedCard/GetStartedCard.js +88 -0
  79. package/lib/components/GetStartedCard/index.d.ts +1 -0
  80. package/lib/components/Guidebanner/Guidebanner.js +2 -2
  81. package/lib/components/NotificationsPanel/NotificationsPanel.d.ts +162 -1
  82. package/lib/components/NotificationsPanel/NotificationsPanel.js +10 -10
  83. package/lib/components/SidePanel/SidePanel.js +1 -1
  84. package/lib/components/TagOverflow/TagOverflow.d.ts +5 -0
  85. package/lib/components/TagOverflow/TagOverflow.js +154 -28
  86. package/lib/components/TagOverflow/TagOverflowModal.d.ts +29 -0
  87. package/lib/components/TagOverflow/TagOverflowModal.js +121 -0
  88. package/lib/components/TagOverflow/TagOverflowPopover.d.ts +2 -0
  89. package/lib/components/TagOverflow/TagOverflowPopover.js +144 -0
  90. package/lib/components/index.d.ts +1 -0
  91. package/lib/global/js/package-settings.d.ts +1 -0
  92. package/lib/global/js/package-settings.js +1 -0
  93. package/lib/index.js +5 -0
  94. package/lib/settings.d.ts +1 -0
  95. package/package.json +3 -3
  96. package/scss/components/GetStartedCard/_carbon-imports.scss +9 -0
  97. package/scss/components/GetStartedCard/_get-started-card.scss +135 -0
  98. package/scss/components/GetStartedCard/_index-with-carbon.scss +9 -0
  99. package/scss/components/GetStartedCard/_index.scss +8 -0
  100. package/scss/components/TagOverflow/_tag-overflow.scss +157 -0
  101. package/scss/components/_index-with-carbon.scss +1 -0
  102. package/scss/components/_index.scss +1 -0
  103. package/telemetry.yml +23 -16
@@ -1,2 +1,163 @@
1
- export let NotificationsPanel: React.ForwardRefExoticComponent<React.RefAttributes<any>>;
1
+ /**
2
+ * Copyright IBM Corp. 2020, 2022
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
+ /// <reference path="../../../src/custom-typings/index.d.ts" />
2
8
  import React from 'react';
9
+ import { Link } from '@carbon/react';
10
+ interface Link {
11
+ url: string;
12
+ text: string;
13
+ }
14
+ interface Data {
15
+ id?: string | number;
16
+ type?: 'error' | 'warning' | 'success' | 'informational';
17
+ timestamp?: Date;
18
+ title?: string;
19
+ description?: string;
20
+ link?: Link;
21
+ unread?: boolean;
22
+ onNotificationClick?: () => void;
23
+ }
24
+ interface NotificationsPanelProps {
25
+ /**
26
+ * Provide an optional class to be applied to the containing node.
27
+ */
28
+ className?: string;
29
+ /**
30
+ * Array of data for Notifications component to render
31
+ */
32
+ data: Data[];
33
+ /**
34
+ * Sets the `days ago` label text
35
+ */
36
+ daysAgoText?: (value: number) => string;
37
+ /**
38
+ * Label for Dismiss all button
39
+ */
40
+ dismissAllLabel?: string;
41
+ /**
42
+ * Label for Dismiss single notification icon button
43
+ */
44
+ dismissSingleNotificationIconDescription?: string;
45
+ /**
46
+ * Optional: Determines if the `Do not disturb` toggle is on or off when the component is rendered
47
+ */
48
+ doNotDisturbDefaultToggled?: boolean;
49
+ /**
50
+ * Optional: Label for Do not disturb toggle
51
+ */
52
+ doNotDisturbLabel?: string;
53
+ /**
54
+ * Sets the empty state label text when there are no notifications
55
+ */
56
+ emptyStateLabel?: string;
57
+ /**
58
+ * Sets the `hour ago` label text
59
+ */
60
+ hourAgoText?: (value: number) => string;
61
+ /**
62
+ * Sets the `hours ago` label text
63
+ */
64
+ hoursAgoText?: (value: number) => string;
65
+ /**
66
+ * Sets the `minute ago` label text
67
+ */
68
+ minuteAgoText?: (value: number) => string;
69
+ /**
70
+ * Sets the `minutes ago` label text
71
+ */
72
+ minutesAgoText?: (value: number) => string;
73
+ /**
74
+ * Sets the `month ago` label text
75
+ */
76
+ monthAgoText?: (value: number) => string;
77
+ /**
78
+ * Sets the `months ago` label text
79
+ */
80
+ monthsAgoText?: (value: number) => string;
81
+ /**
82
+ * Sets the `now` label text
83
+ */
84
+ nowText?: string;
85
+ /**
86
+ * Sets the notifications panel open state
87
+ */
88
+ onClickOutside: () => void;
89
+ /**
90
+ * Function that will dismiss all notifications
91
+ */
92
+ onDismissAllNotifications?: () => void;
93
+ /**
94
+ * Function that will dismiss a single notification
95
+ */
96
+ onDismissSingleNotification?: (prop: any) => void;
97
+ /**
98
+ * Optional: function that returns the current selected value of the disable notification toggle
99
+ */
100
+ onDoNotDisturbChange?: (prop: any) => void;
101
+ /**
102
+ * Event handler for the View all button
103
+ */
104
+ onSettingsClick?: () => void;
105
+ /**
106
+ * Event handler for the View all button
107
+ */
108
+ onViewAllClick?: () => void;
109
+ /**
110
+ * Determines whether the notifications panel should render or not
111
+ */
112
+ open: boolean;
113
+ /**
114
+ * Sets the previous label text
115
+ */
116
+ previousLabel?: string;
117
+ /**
118
+ * Sets the `read less` label text
119
+ */
120
+ readLessLabel?: string;
121
+ /**
122
+ * Sets the `read more` label text
123
+ */
124
+ readMoreLabel?: string;
125
+ /**
126
+ * Sets the `seconds ago` label text
127
+ */
128
+ secondsAgoText?: (value: number) => string;
129
+ /**
130
+ * Sets the settings icon description text
131
+ */
132
+ settingsIconDescription?: string;
133
+ /**
134
+ * Sets the title for the Notifications panel
135
+ */
136
+ title?: string;
137
+ /**
138
+ * Sets the today label text
139
+ */
140
+ todayLabel?: string;
141
+ /**
142
+ * Sets the View all button text
143
+ */
144
+ viewAllLabel?: (value: number) => string;
145
+ /**
146
+ * Sets the `year ago` label text
147
+ */
148
+ yearAgoText?: (value: number) => string;
149
+ /**
150
+ * Sets the `years ago` label text
151
+ */
152
+ yearsAgoText?: (value: number) => string;
153
+ /**
154
+ * Sets the `Yesterday at` label text
155
+ */
156
+ yesterdayAtText?: (value: number) => string;
157
+ /**
158
+ * Sets the yesterday label text
159
+ */
160
+ yesterdayLabel?: string;
161
+ }
162
+ export declare let NotificationsPanel: React.ForwardRefExoticComponent<NotificationsPanelProps & React.RefAttributes<unknown>>;
163
+ export {};
@@ -209,9 +209,9 @@ var NotificationsPanel = /*#__PURE__*/React__default.forwardRef(function (_ref,
209
209
  return item.id === id;
210
210
  })[0];
211
211
  var trimLength = 88;
212
- var description = notification.description;
213
- var descriptionClassName = cx(["".concat(blockClass, "__notification-description"), _defineProperty(_defineProperty({}, "".concat(blockClass, "__notification-long-description"), notification.showAll), "".concat(blockClass, "__notification-short-description"), !notification.showAll)]);
214
- var showMoreButtonClassName = cx([_defineProperty(_defineProperty({}, "".concat(blockClass, "__notification-read-less-button"), notification.showAll), "".concat(blockClass, "__notification-read-more-button"), !notification.showAll)]);
212
+ var description = notification === null || notification === void 0 ? void 0 : notification['description'];
213
+ var descriptionClassName = cx(["".concat(blockClass, "__notification-description"), _defineProperty(_defineProperty({}, "".concat(blockClass, "__notification-long-description"), notification === null || notification === void 0 ? void 0 : notification['showAll']), "".concat(blockClass, "__notification-short-description"), !(notification !== null && notification !== void 0 && notification['showAll']))]);
214
+ var showMoreButtonClassName = cx([_defineProperty(_defineProperty({}, "".concat(blockClass, "__notification-read-less-button"), notification === null || notification === void 0 ? void 0 : notification['showAll']), "".concat(blockClass, "__notification-read-more-button"), !(notification !== null && notification !== void 0 && notification['showAll']))]);
215
215
  return /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement("p", {
216
216
  className: descriptionClassName
217
217
  }, description), description.length > trimLength && /*#__PURE__*/React__default.createElement(Button, {
@@ -222,14 +222,14 @@ var NotificationsPanel = /*#__PURE__*/React__default.forwardRef(function (_ref,
222
222
  size: 16
223
223
  }, props));
224
224
  },
225
- iconDescription: notification.showAll ? readLessLabel : readMoreLabel,
225
+ iconDescription: notification !== null && notification !== void 0 && notification['showAll'] ? readLessLabel : readMoreLabel,
226
226
  onClick: function onClick(event) {
227
227
  event.preventDefault();
228
228
  event.stopPropagation();
229
229
  var newData = allNotifications.map(function (item) {
230
- if (item.id === notification.id) {
230
+ if (item.id === (notification === null || notification === void 0 ? void 0 : notification['id'])) {
231
231
  return Object.assign({}, item, {
232
- showAll: !item.showAll
232
+ showAll: !(item !== null && item !== void 0 && item['showAll'])
233
233
  });
234
234
  }
235
235
  return item;
@@ -237,7 +237,7 @@ var NotificationsPanel = /*#__PURE__*/React__default.forwardRef(function (_ref,
237
237
  setAllNotifications(newData);
238
238
  },
239
239
  className: showMoreButtonClassName
240
- }, notification.showAll ? readLessLabel : readMoreLabel));
240
+ }, notification !== null && notification !== void 0 && notification['showAll'] ? readLessLabel : readMoreLabel));
241
241
  };
242
242
  var renderNotification = function renderNotification(group, notification, index) {
243
243
  var notificationClassName = cx(["".concat(blockClass, "__notification"), "".concat(blockClass, "__notification-").concat(group)]);
@@ -246,14 +246,13 @@ var NotificationsPanel = /*#__PURE__*/React__default.forwardRef(function (_ref,
246
246
  "aria-label": notification.title,
247
247
  key: "".concat(notification.timestamp, "-").concat(notification.title, "-").concat(index),
248
248
  className: notificationClassName,
249
- type: "button",
250
249
  role: "button",
251
250
  tabIndex: 0,
252
251
  onClick: function onClick() {
253
252
  return notification.onNotificationClick(notification);
254
253
  },
255
254
  onKeyDown: function onKeyDown(event) {
256
- if (event.target.classList.contains("".concat(blockClass, "__dismiss-single-button"))) {
255
+ if (event.target instanceof HTMLElement && event.target.classList.contains("".concat(blockClass, "__dismiss-single-button"))) {
257
256
  return;
258
257
  }
259
258
  event.which === 13 && notification.onNotificationClick(notification);
@@ -316,7 +315,7 @@ var NotificationsPanel = /*#__PURE__*/React__default.forwardRef(function (_ref,
316
315
  id: blockClass,
317
316
  className: cx(blockClass, className, "".concat(blockClass, "__container")),
318
317
  style: {
319
- animation: !reducedMotion ? "".concat(open ? 'fade-in 250ms' : 'fade-out forwards 250ms') : null
318
+ animation: !reducedMotion ? "".concat(open ? 'fade-in 250ms' : 'fade-out forwards 250ms') : undefined
320
319
  },
321
320
  onAnimationEnd: onAnimationEnd,
322
321
  ref: ref || notificationPanelRef
@@ -405,6 +404,7 @@ NotificationsPanel.propTypes = {
405
404
  /**
406
405
  * Array of data for Notifications component to render
407
406
  */
407
+ /**@ts-ignore*/
408
408
  data: PropTypes.arrayOf(PropTypes.shape({
409
409
  id: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
410
410
  type: PropTypes.oneOf(['error', 'warning', 'success', 'informational']),
@@ -346,7 +346,7 @@ var SidePanel = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
346
346
  });
347
347
  }
348
348
  return /*#__PURE__*/React__default.createElement("div", {
349
- className: cx("".concat(blockClass, "__header"), _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, "".concat(blockClass, "__header--on-detail-step"), currentStep > 0), "".concat(blockClass, "__header--no-title-animation"), !doAnimateTitle), "".concat(blockClass, "__header--reduced-motion"), reducedMotion.matches), "".concat(blockClass, "__header--has-title"), title)),
349
+ className: cx("".concat(blockClass, "__header"), _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, "".concat(blockClass, "__header--on-detail-step"), currentStep > 0), "".concat(blockClass, "__header--no-title-animation"), !animateTitle), "".concat(blockClass, "__header--reduced-motion"), reducedMotion.matches), "".concat(blockClass, "__header--has-title"), title)),
350
350
  ref: headerRef
351
351
  }, currentStep > 0 && /*#__PURE__*/React__default.createElement(Button, {
352
352
  "aria-label": navigationBackIconDescription,
@@ -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 {};