@carbon/react 1.7.0 → 1.8.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 (66) hide show
  1. package/es/components/ComposedModal/ComposedModal.js +1 -1
  2. package/es/components/ComposedModal/index.js +4 -4
  3. package/es/components/DataTable/DataTable.js +1 -1
  4. package/es/components/DataTable/Table.js +10 -2
  5. package/es/components/DataTable/TableContainer.js +20 -5
  6. package/es/components/DataTable/TableContext.js +15 -0
  7. package/es/components/DataTable/TableSelectRow.js +1 -1
  8. package/es/components/FileUploader/FileUploader.js +8 -1
  9. package/es/components/FileUploader/FileUploaderButton.js +3 -1
  10. package/es/components/FileUploader/FileUploaderDropContainer.js +3 -1
  11. package/es/components/FileUploader/FileUploaderItem.js +3 -1
  12. package/es/components/InlineLoading/InlineLoading.js +9 -5
  13. package/es/components/Loading/Loading.js +7 -18
  14. package/es/components/MultiSelect/FilterableMultiSelect.js +345 -386
  15. package/es/components/MultiSelect/index.js +4 -8
  16. package/es/components/Notification/Notification.js +322 -189
  17. package/es/components/RadioButton/RadioButton.js +58 -99
  18. package/es/components/RadioButton/index.js +2 -8
  19. package/es/components/RadioButtonGroup/RadioButtonGroup.js +72 -121
  20. package/es/components/RadioButtonGroup/index.js +2 -8
  21. package/es/components/Slider/Slider.js +2 -1
  22. package/es/components/Switch/Switch.js +0 -1
  23. package/es/components/TreeView/TreeView.js +19 -11
  24. package/es/components/UIShell/HeaderMenu.js +1 -1
  25. package/es/components/UIShell/HeaderMenuButton.js +4 -0
  26. package/es/components/UIShell/SideNavLink.js +6 -9
  27. package/es/index.js +7 -6
  28. package/es/internal/createClassWrapper.js +2 -5
  29. package/lib/components/ComposedModal/index.js +7 -7
  30. package/lib/components/DataTable/DataTable.js +5 -5
  31. package/lib/components/DataTable/Table.js +9 -1
  32. package/lib/components/DataTable/TableContainer.js +19 -4
  33. package/lib/components/DataTable/TableContext.js +19 -0
  34. package/lib/components/DataTable/TableSelectRow.js +2 -2
  35. package/lib/components/FileUploader/FileUploader.js +8 -1
  36. package/lib/components/FileUploader/FileUploaderButton.js +3 -1
  37. package/lib/components/FileUploader/FileUploaderDropContainer.js +3 -1
  38. package/lib/components/FileUploader/FileUploaderItem.js +3 -1
  39. package/lib/components/InlineLoading/InlineLoading.js +9 -5
  40. package/lib/components/Loading/Loading.js +6 -17
  41. package/lib/components/MultiSelect/FilterableMultiSelect.js +341 -382
  42. package/lib/components/MultiSelect/index.js +5 -28
  43. package/lib/components/Notification/Notification.js +321 -188
  44. package/lib/components/RadioButton/RadioButton.js +57 -99
  45. package/lib/components/RadioButton/index.js +2 -25
  46. package/lib/components/RadioButtonGroup/RadioButtonGroup.js +68 -117
  47. package/lib/components/RadioButtonGroup/index.js +2 -25
  48. package/lib/components/Slider/Slider.js +2 -1
  49. package/lib/components/Switch/Switch.js +0 -1
  50. package/lib/components/TreeView/TreeView.js +18 -10
  51. package/lib/components/UIShell/HeaderMenu.js +1 -0
  52. package/lib/components/UIShell/HeaderMenuButton.js +4 -0
  53. package/lib/components/UIShell/SideNavLink.js +6 -9
  54. package/lib/index.js +83 -83
  55. package/lib/internal/createClassWrapper.js +2 -5
  56. package/package.json +7 -7
  57. package/es/components/MultiSelect/next/FilterableMultiSelect.js +0 -544
  58. package/es/components/Notification/index.js +0 -42
  59. package/es/components/Notification/next/Notification.js +0 -663
  60. package/es/components/RadioButton/next/RadioButton.js +0 -130
  61. package/es/components/RadioButtonGroup/next/RadioButtonGroup.js +0 -141
  62. package/lib/components/MultiSelect/next/FilterableMultiSelect.js +0 -556
  63. package/lib/components/Notification/index.js +0 -51
  64. package/lib/components/Notification/next/Notification.js +0 -677
  65. package/lib/components/RadioButton/next/RadioButton.js +0 -140
  66. package/lib/components/RadioButtonGroup/next/RadioButtonGroup.js +0 -151
@@ -1,677 +0,0 @@
1
- /**
2
- * Copyright IBM Corp. 2016, 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
-
8
- 'use strict';
9
-
10
- Object.defineProperty(exports, '__esModule', { value: true });
11
-
12
- var _rollupPluginBabelHelpers = require('../../../_virtual/_rollupPluginBabelHelpers.js');
13
- var PropTypes = require('prop-types');
14
- var React = require('react');
15
- var cx = require('classnames');
16
- var iconsReact = require('@carbon/icons-react');
17
- var Button = require('../../Button/Button.js');
18
- var useIsomorphicEffect = require('../../../internal/useIsomorphicEffect.js');
19
- var useNoInteractiveChildren = require('../../../internal/useNoInteractiveChildren.js');
20
- var usePrefix = require('../../../internal/usePrefix.js');
21
- var match = require('../../../internal/keyboard/match.js');
22
- var keys = require('../../../internal/keyboard/keys.js');
23
-
24
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
25
-
26
- var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
27
- var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
28
- var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
29
-
30
- var _iconTypes;
31
-
32
- var _excluded = ["children", "className", "onClick", "inline"],
33
- _excluded2 = ["ariaLabel", "className", "type", "renderIcon", "name", "notificationType"],
34
- _excluded3 = ["role", "onClose", "onCloseButtonClick", "statusIconDescription", "className", "children", "kind", "lowContrast", "hideCloseButton", "timeout", "title", "caption", "subtitle"],
35
- _excluded4 = ["children", "title", "subtitle", "role", "onClose", "onCloseButtonClick", "statusIconDescription", "className", "kind", "lowContrast", "hideCloseButton"],
36
- _excluded5 = ["actionButtonLabel", "ariaLabel", "children", "role", "onActionButtonClick", "onClose", "onCloseButtonClick", "statusIconDescription", "className", "inline", "kind", "lowContrast", "hideCloseButton", "hasFocus", "closeOnEscape", "title", "subtitle"];
37
- /**
38
- * Conditionally call a callback when the escape key is pressed
39
- * @param {node} ref - ref of the container element to scope the functionality to
40
- * @param {func} callback - function to be called
41
- * @param {bool} override - escape hatch to conditionally call the callback
42
- */
43
-
44
- function useEscapeToClose(ref, callback) {
45
- var override = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
46
-
47
- var handleKeyDown = function handleKeyDown(event) {
48
- // The callback should only be called when focus is on or within the container
49
- var elementContainsFocus = ref.current && document.activeElement === ref.current || ref.current.contains(document.activeElement);
50
-
51
- if (match.matches(event, [keys.Escape]) && override && elementContainsFocus) {
52
- callback(event);
53
- }
54
- };
55
-
56
- useIsomorphicEffect["default"](function () {
57
- document.addEventListener('keydown', handleKeyDown, false);
58
- return function () {
59
- return document.removeEventListener('keydown', handleKeyDown, false);
60
- };
61
- });
62
- }
63
-
64
- function NotificationActionButton(_ref) {
65
- var children = _ref.children,
66
- customClassName = _ref.className,
67
- onClick = _ref.onClick,
68
- inline = _ref.inline,
69
- rest = _rollupPluginBabelHelpers.objectWithoutProperties(_ref, _excluded);
70
-
71
- var prefix = usePrefix.usePrefix();
72
- var className = cx__default["default"](customClassName, _rollupPluginBabelHelpers.defineProperty({}, "".concat(prefix, "--actionable-notification__action-button"), true));
73
- return /*#__PURE__*/React__default["default"].createElement(Button["default"], _rollupPluginBabelHelpers["extends"]({
74
- className: className,
75
- kind: inline ? 'ghost' : 'tertiary',
76
- onClick: onClick,
77
- size: "sm"
78
- }, rest), children);
79
- }
80
- NotificationActionButton.propTypes = {
81
- /**
82
- * Specify the content of the notification action button.
83
- */
84
- children: PropTypes__default["default"].node,
85
-
86
- /**
87
- * Specify an optional className to be applied to the notification action button
88
- */
89
- className: PropTypes__default["default"].string,
90
-
91
- /**
92
- * Specify if the visual treatment of the button should be for an inline notification
93
- */
94
- inline: PropTypes__default["default"].bool,
95
-
96
- /**
97
- * Optionally specify a click handler for the notification action button.
98
- */
99
- onClick: PropTypes__default["default"].func
100
- };
101
- function NotificationButton(_ref2) {
102
- var ariaLabel = _ref2.ariaLabel,
103
- className = _ref2.className,
104
- type = _ref2.type,
105
- IconTag = _ref2.renderIcon,
106
- name = _ref2.name,
107
- notificationType = _ref2.notificationType,
108
- rest = _rollupPluginBabelHelpers.objectWithoutProperties(_ref2, _excluded2);
109
-
110
- var prefix = usePrefix.usePrefix();
111
- var buttonClassName = cx__default["default"](className, _rollupPluginBabelHelpers.defineProperty({}, "".concat(prefix, "--").concat(notificationType, "-notification__close-button"), notificationType));
112
- var iconClassName = cx__default["default"](_rollupPluginBabelHelpers.defineProperty({}, "".concat(prefix, "--").concat(notificationType, "-notification__close-icon"), notificationType));
113
- return /*#__PURE__*/React__default["default"].createElement("button", _rollupPluginBabelHelpers["extends"]({}, rest, {
114
- // eslint-disable-next-line react/button-has-type
115
- type: type,
116
- "aria-label": ariaLabel,
117
- title: ariaLabel,
118
- className: buttonClassName
119
- }), IconTag && /*#__PURE__*/React__default["default"].createElement(IconTag, {
120
- className: iconClassName,
121
- name: name
122
- }));
123
- }
124
- NotificationButton.propTypes = {
125
- /**
126
- * Specify a label to be read by screen readers on the notification button
127
- */
128
- ariaLabel: PropTypes__default["default"].string,
129
-
130
- /**
131
- * Specify an optional className to be applied to the notification button
132
- */
133
- className: PropTypes__default["default"].string,
134
-
135
- /**
136
- * Specify an optional icon for the Button through a string,
137
- * if something but regular "close" icon is desirable
138
- */
139
- name: PropTypes__default["default"].string,
140
-
141
- /**
142
- * Specify the notification type
143
- */
144
- notificationType: PropTypes__default["default"].oneOf(['toast', 'inline', 'actionable']),
145
-
146
- /**
147
- * Optional prop to allow overriding the icon rendering.
148
- * Can be a React component class
149
- */
150
- renderIcon: PropTypes__default["default"].oneOfType([PropTypes__default["default"].func, PropTypes__default["default"].object]),
151
-
152
- /**
153
- * Optional prop to specify the type of the Button
154
- */
155
- type: PropTypes__default["default"].string
156
- };
157
- NotificationButton.defaultProps = {
158
- ariaLabel: 'close notification',
159
- notificationType: 'toast',
160
- type: 'button',
161
- renderIcon: iconsReact.Close
162
- };
163
- var iconTypes = (_iconTypes = {
164
- error: iconsReact.ErrorFilled,
165
- success: iconsReact.CheckmarkFilled,
166
- warning: iconsReact.WarningFilled
167
- }, _rollupPluginBabelHelpers.defineProperty(_iconTypes, 'warning-alt', iconsReact.WarningAltFilled), _rollupPluginBabelHelpers.defineProperty(_iconTypes, "info", iconsReact.InformationFilled), _rollupPluginBabelHelpers.defineProperty(_iconTypes, 'info-square', iconsReact.InformationSquareFilled), _iconTypes);
168
-
169
- function NotificationIcon(_ref3) {
170
- var iconDescription = _ref3.iconDescription,
171
- kind = _ref3.kind,
172
- notificationType = _ref3.notificationType;
173
- var prefix = usePrefix.usePrefix();
174
- var IconForKind = iconTypes[kind];
175
-
176
- if (!IconForKind) {
177
- return null;
178
- }
179
-
180
- return /*#__PURE__*/React__default["default"].createElement(IconForKind, {
181
- className: "".concat(prefix, "--").concat(notificationType, "-notification__icon")
182
- }, /*#__PURE__*/React__default["default"].createElement("title", null, iconDescription));
183
- }
184
-
185
- NotificationIcon.propTypes = {
186
- iconDescription: PropTypes__default["default"].string.isRequired,
187
- kind: PropTypes__default["default"].oneOf(['error', 'success', 'warning', 'warning-alt', 'info', 'info-square']).isRequired,
188
- notificationType: PropTypes__default["default"].oneOf(['inline', 'toast']).isRequired
189
- };
190
- function ToastNotification(_ref4) {
191
- var _cx4;
192
-
193
- var role = _ref4.role,
194
- onClose = _ref4.onClose,
195
- onCloseButtonClick = _ref4.onCloseButtonClick,
196
- statusIconDescription = _ref4.statusIconDescription,
197
- className = _ref4.className,
198
- children = _ref4.children,
199
- kind = _ref4.kind,
200
- lowContrast = _ref4.lowContrast,
201
- hideCloseButton = _ref4.hideCloseButton,
202
- timeout = _ref4.timeout,
203
- title = _ref4.title,
204
- caption = _ref4.caption,
205
- subtitle = _ref4.subtitle,
206
- rest = _rollupPluginBabelHelpers.objectWithoutProperties(_ref4, _excluded3);
207
-
208
- var _useState = React.useState(true),
209
- _useState2 = _rollupPluginBabelHelpers.slicedToArray(_useState, 2),
210
- isOpen = _useState2[0],
211
- setIsOpen = _useState2[1];
212
-
213
- var prefix = usePrefix.usePrefix();
214
- var containerClassName = cx__default["default"](className, (_cx4 = {}, _rollupPluginBabelHelpers.defineProperty(_cx4, "".concat(prefix, "--toast-notification"), true), _rollupPluginBabelHelpers.defineProperty(_cx4, "".concat(prefix, "--toast-notification--low-contrast"), lowContrast), _rollupPluginBabelHelpers.defineProperty(_cx4, "".concat(prefix, "--toast-notification--").concat(kind), kind), _cx4));
215
- var contentRef = React.useRef(null);
216
- useNoInteractiveChildren.useNoInteractiveChildren(contentRef);
217
-
218
- var handleClose = function handleClose(evt) {
219
- if (!onClose || onClose(evt) !== false) {
220
- setIsOpen(false);
221
- }
222
- };
223
-
224
- var ref = React.useRef(null);
225
-
226
- function handleCloseButtonClick(event) {
227
- onCloseButtonClick(event);
228
- handleClose(event);
229
- }
230
-
231
- var savedOnClose = React.useRef(onClose);
232
- React.useEffect(function () {
233
- savedOnClose.current = onClose;
234
- });
235
- React.useEffect(function () {
236
- if (!timeout) {
237
- return;
238
- }
239
-
240
- var timeoutId = window.setTimeout(function (event) {
241
- setIsOpen(false);
242
-
243
- if (savedOnClose.current) {
244
- savedOnClose.current(event);
245
- }
246
- }, timeout);
247
- return function () {
248
- window.clearTimeout(timeoutId);
249
- };
250
- }, [timeout]);
251
-
252
- if (!isOpen) {
253
- return null;
254
- }
255
-
256
- return /*#__PURE__*/React__default["default"].createElement("div", _rollupPluginBabelHelpers["extends"]({
257
- ref: ref
258
- }, rest, {
259
- role: role,
260
- className: containerClassName
261
- }), /*#__PURE__*/React__default["default"].createElement(NotificationIcon, {
262
- notificationType: "toast",
263
- kind: kind,
264
- iconDescription: statusIconDescription || "".concat(kind, " icon")
265
- }), /*#__PURE__*/React__default["default"].createElement("div", {
266
- ref: contentRef,
267
- className: "".concat(prefix, "--toast-notification__details")
268
- }, title && /*#__PURE__*/React__default["default"].createElement("div", {
269
- className: "".concat(prefix, "--toast-notification__title")
270
- }, title), subtitle && /*#__PURE__*/React__default["default"].createElement("div", {
271
- className: "".concat(prefix, "--toast-notification__subtitle")
272
- }, subtitle), caption && /*#__PURE__*/React__default["default"].createElement("div", {
273
- className: "".concat(prefix, "--toast-notification__caption")
274
- }, caption), children), !hideCloseButton && /*#__PURE__*/React__default["default"].createElement(NotificationButton, {
275
- notificationType: "toast",
276
- onClick: handleCloseButtonClick,
277
- "aria-hidden": "true",
278
- tabIndex: "-1"
279
- }));
280
- }
281
- ToastNotification.propTypes = {
282
- /**
283
- * Provide a description for "close" icon button that can be read by screen readers
284
- */
285
- ariaLabel: PropTypes__default["default"].string,
286
-
287
- /**
288
- * Specify the caption
289
- */
290
- caption: PropTypes__default["default"].string,
291
-
292
- /**
293
- * Specify the content
294
- */
295
- children: PropTypes__default["default"].node,
296
-
297
- /**
298
- * Specify an optional className to be applied to the notification box
299
- */
300
- className: PropTypes__default["default"].string,
301
-
302
- /**
303
- * Specify the close button should be disabled, or not
304
- */
305
- hideCloseButton: PropTypes__default["default"].bool,
306
-
307
- /**
308
- * Specify what state the notification represents
309
- */
310
- kind: PropTypes__default["default"].oneOf(['error', 'info', 'info-square', 'success', 'warning', 'warning-alt']),
311
-
312
- /**
313
- * Specify whether you are using the low contrast variant of the ToastNotification.
314
- */
315
- lowContrast: PropTypes__default["default"].bool,
316
-
317
- /**
318
- * Provide a function that is called when menu is closed
319
- */
320
- onClose: PropTypes__default["default"].func,
321
-
322
- /**
323
- * Provide a function that is called when the close button is clicked
324
- */
325
- onCloseButtonClick: PropTypes__default["default"].func,
326
-
327
- /**
328
- * By default, this value is "status". You can also provide an alternate
329
- * role if it makes sense from the accessibility-side
330
- */
331
- role: PropTypes__default["default"].oneOf(['alert', 'log', 'status']),
332
-
333
- /**
334
- * Provide a description for "status" icon that can be read by screen readers
335
- */
336
- statusIconDescription: PropTypes__default["default"].string,
337
-
338
- /**
339
- * Specify the sub-title
340
- */
341
- subtitle: PropTypes__default["default"].string,
342
-
343
- /**
344
- * Specify an optional duration the notification should be closed in
345
- */
346
- timeout: PropTypes__default["default"].number,
347
-
348
- /**
349
- * Specify the title
350
- */
351
- title: PropTypes__default["default"].string
352
- };
353
- ToastNotification.defaultProps = {
354
- kind: 'error',
355
- role: 'status',
356
- onCloseButtonClick: function onCloseButtonClick() {},
357
- hideCloseButton: false,
358
- timeout: 0
359
- };
360
- function InlineNotification(_ref5) {
361
- var _cx5;
362
-
363
- var children = _ref5.children,
364
- title = _ref5.title,
365
- subtitle = _ref5.subtitle,
366
- role = _ref5.role,
367
- onClose = _ref5.onClose,
368
- onCloseButtonClick = _ref5.onCloseButtonClick,
369
- statusIconDescription = _ref5.statusIconDescription,
370
- className = _ref5.className,
371
- kind = _ref5.kind,
372
- lowContrast = _ref5.lowContrast,
373
- hideCloseButton = _ref5.hideCloseButton,
374
- rest = _rollupPluginBabelHelpers.objectWithoutProperties(_ref5, _excluded4);
375
-
376
- var _useState3 = React.useState(true),
377
- _useState4 = _rollupPluginBabelHelpers.slicedToArray(_useState3, 2),
378
- isOpen = _useState4[0],
379
- setIsOpen = _useState4[1];
380
-
381
- var prefix = usePrefix.usePrefix();
382
- var containerClassName = cx__default["default"](className, (_cx5 = {}, _rollupPluginBabelHelpers.defineProperty(_cx5, "".concat(prefix, "--inline-notification"), true), _rollupPluginBabelHelpers.defineProperty(_cx5, "".concat(prefix, "--inline-notification--low-contrast"), lowContrast), _rollupPluginBabelHelpers.defineProperty(_cx5, "".concat(prefix, "--inline-notification--").concat(kind), kind), _rollupPluginBabelHelpers.defineProperty(_cx5, "".concat(prefix, "--inline-notification--hide-close-button"), hideCloseButton), _cx5));
383
- var contentRef = React.useRef(null);
384
- useNoInteractiveChildren.useNoInteractiveChildren(contentRef);
385
-
386
- var handleClose = function handleClose(evt) {
387
- if (!onClose || onClose(evt) !== false) {
388
- setIsOpen(false);
389
- }
390
- };
391
-
392
- var ref = React.useRef(null);
393
-
394
- function handleCloseButtonClick(event) {
395
- onCloseButtonClick(event);
396
- handleClose(event);
397
- }
398
-
399
- if (!isOpen) {
400
- return null;
401
- }
402
-
403
- return /*#__PURE__*/React__default["default"].createElement("div", _rollupPluginBabelHelpers["extends"]({
404
- ref: ref
405
- }, rest, {
406
- role: role,
407
- className: containerClassName
408
- }), /*#__PURE__*/React__default["default"].createElement("div", {
409
- className: "".concat(prefix, "--inline-notification__details")
410
- }, /*#__PURE__*/React__default["default"].createElement(NotificationIcon, {
411
- notificationType: "inline",
412
- kind: kind,
413
- iconDescription: statusIconDescription || "".concat(kind, " icon")
414
- }), /*#__PURE__*/React__default["default"].createElement("div", {
415
- ref: contentRef,
416
- className: "".concat(prefix, "--inline-notification__text-wrapper")
417
- }, title && /*#__PURE__*/React__default["default"].createElement("div", {
418
- className: "".concat(prefix, "--inline-notification__title")
419
- }, title), subtitle && /*#__PURE__*/React__default["default"].createElement("div", {
420
- className: "".concat(prefix, "--inline-notification__subtitle")
421
- }, subtitle), children)), !hideCloseButton && /*#__PURE__*/React__default["default"].createElement(NotificationButton, {
422
- notificationType: "inline",
423
- onClick: handleCloseButtonClick,
424
- "aria-hidden": "true",
425
- tabIndex: "-1"
426
- }));
427
- }
428
- InlineNotification.propTypes = {
429
- /**
430
- * Specify the content
431
- */
432
- children: PropTypes__default["default"].node,
433
-
434
- /**
435
- * Specify an optional className to be applied to the notification box
436
- */
437
- className: PropTypes__default["default"].string,
438
-
439
- /**
440
- * Specify the close button should be disabled, or not
441
- */
442
- hideCloseButton: PropTypes__default["default"].bool,
443
-
444
- /**
445
- * Specify what state the notification represents
446
- */
447
- kind: PropTypes__default["default"].oneOf(['error', 'info', 'info-square', 'success', 'warning', 'warning-alt']),
448
-
449
- /**
450
- * Specify whether you are using the low contrast variant of the InlineNotification.
451
- */
452
- lowContrast: PropTypes__default["default"].bool,
453
-
454
- /**
455
- * Provide a function that is called when menu is closed
456
- */
457
- onClose: PropTypes__default["default"].func,
458
-
459
- /**
460
- * Provide a function that is called when the close button is clicked
461
- */
462
- onCloseButtonClick: PropTypes__default["default"].func,
463
-
464
- /**
465
- * By default, this value is "status". You can also provide an alternate
466
- * role if it makes sense from the accessibility-side.
467
- */
468
- role: PropTypes__default["default"].oneOf(['alert', 'log', 'status']),
469
-
470
- /**
471
- * Provide a description for "status" icon that can be read by screen readers
472
- */
473
- statusIconDescription: PropTypes__default["default"].string,
474
-
475
- /**
476
- * Specify the sub-title
477
- */
478
- subtitle: PropTypes__default["default"].string,
479
-
480
- /**
481
- * Specify the title
482
- */
483
- title: PropTypes__default["default"].string
484
- };
485
- InlineNotification.defaultProps = {
486
- kind: 'error',
487
- role: 'status',
488
- onCloseButtonClick: function onCloseButtonClick() {},
489
- hideCloseButton: false
490
- };
491
- function ActionableNotification(_ref6) {
492
- var _cx6;
493
-
494
- var actionButtonLabel = _ref6.actionButtonLabel,
495
- ariaLabel = _ref6.ariaLabel,
496
- children = _ref6.children,
497
- role = _ref6.role,
498
- onActionButtonClick = _ref6.onActionButtonClick,
499
- onClose = _ref6.onClose,
500
- onCloseButtonClick = _ref6.onCloseButtonClick,
501
- statusIconDescription = _ref6.statusIconDescription,
502
- className = _ref6.className,
503
- inline = _ref6.inline,
504
- kind = _ref6.kind,
505
- lowContrast = _ref6.lowContrast,
506
- hideCloseButton = _ref6.hideCloseButton,
507
- hasFocus = _ref6.hasFocus,
508
- closeOnEscape = _ref6.closeOnEscape,
509
- title = _ref6.title,
510
- subtitle = _ref6.subtitle,
511
- rest = _rollupPluginBabelHelpers.objectWithoutProperties(_ref6, _excluded5);
512
-
513
- var _useState5 = React.useState(true),
514
- _useState6 = _rollupPluginBabelHelpers.slicedToArray(_useState5, 2),
515
- isOpen = _useState6[0],
516
- setIsOpen = _useState6[1];
517
-
518
- var prefix = usePrefix.usePrefix();
519
- var containerClassName = cx__default["default"](className, (_cx6 = {}, _rollupPluginBabelHelpers.defineProperty(_cx6, "".concat(prefix, "--actionable-notification"), true), _rollupPluginBabelHelpers.defineProperty(_cx6, "".concat(prefix, "--actionable-notification--toast"), !inline), _rollupPluginBabelHelpers.defineProperty(_cx6, "".concat(prefix, "--actionable-notification--low-contrast"), lowContrast), _rollupPluginBabelHelpers.defineProperty(_cx6, "".concat(prefix, "--actionable-notification--").concat(kind), kind), _rollupPluginBabelHelpers.defineProperty(_cx6, "".concat(prefix, "--actionable-notification--hide-close-button"), hideCloseButton), _cx6));
520
- var ref = React.useRef(null);
521
- useIsomorphicEffect["default"](function () {
522
- if (ref.current && hasFocus) {
523
- ref.current.focus();
524
- }
525
- });
526
-
527
- var handleClose = function handleClose(evt) {
528
- if (!onClose || onClose(evt) !== false) {
529
- setIsOpen(false);
530
- }
531
- };
532
-
533
- useEscapeToClose(ref, handleCloseButtonClick, closeOnEscape);
534
-
535
- function handleCloseButtonClick(event) {
536
- onCloseButtonClick(event);
537
- handleClose(event);
538
- }
539
-
540
- if (!isOpen) {
541
- return null;
542
- }
543
-
544
- return /*#__PURE__*/React__default["default"].createElement("div", _rollupPluginBabelHelpers["extends"]({}, rest, {
545
- ref: ref,
546
- role: role,
547
- className: containerClassName
548
- }), /*#__PURE__*/React__default["default"].createElement("div", {
549
- className: "".concat(prefix, "--actionable-notification__details")
550
- }, /*#__PURE__*/React__default["default"].createElement(NotificationIcon, {
551
- notificationType: inline ? 'inline' : 'toast',
552
- kind: kind,
553
- iconDescription: statusIconDescription || "".concat(kind, " icon")
554
- }), /*#__PURE__*/React__default["default"].createElement("div", {
555
- className: "".concat(prefix, "--actionable-notification__text-wrapper")
556
- }, /*#__PURE__*/React__default["default"].createElement("div", {
557
- className: "".concat(prefix, "--actionable-notification__content")
558
- }, title && /*#__PURE__*/React__default["default"].createElement("div", {
559
- className: "".concat(prefix, "--actionable-notification__title")
560
- }, title), subtitle && /*#__PURE__*/React__default["default"].createElement("div", {
561
- className: "".concat(prefix, "--actionable-notification__subtitle")
562
- }, subtitle), children))), /*#__PURE__*/React__default["default"].createElement(NotificationActionButton, {
563
- onClick: onActionButtonClick,
564
- inline: inline
565
- }, actionButtonLabel), !hideCloseButton && /*#__PURE__*/React__default["default"].createElement(NotificationButton, {
566
- "aria-label": ariaLabel,
567
- notificationType: "actionable",
568
- onClick: handleCloseButtonClick
569
- }));
570
- }
571
- ActionableNotification.propTypes = {
572
- /**
573
- * Pass in the action button label that will be rendered within the ActionableNotification.
574
- */
575
- actionButtonLabel: PropTypes__default["default"].string.isRequired,
576
-
577
- /**
578
- * Provide a description for "close" icon button that can be read by screen readers
579
- */
580
- ariaLabel: PropTypes__default["default"].string,
581
-
582
- /**
583
- * Specify the caption
584
- */
585
- caption: PropTypes__default["default"].string,
586
-
587
- /**
588
- * Specify the content
589
- */
590
- children: PropTypes__default["default"].node,
591
-
592
- /**
593
- * Specify an optional className to be applied to the notification box
594
- */
595
- className: PropTypes__default["default"].string,
596
-
597
- /**
598
- * Specify if pressing the escape key should close notifications
599
- */
600
- closeOnEscape: PropTypes__default["default"].bool,
601
-
602
- /**
603
- * Specify if focus should be moved to the component when the notification contains actions
604
- */
605
- hasFocus: PropTypes__default["default"].bool,
606
-
607
- /**
608
- * Specify the close button should be disabled, or not
609
- */
610
- hideCloseButton: PropTypes__default["default"].bool,
611
-
612
- /*
613
- * Specify if the notification should have inline styling applied instead of toast
614
- */
615
- inline: PropTypes__default["default"].bool,
616
-
617
- /**
618
- * Specify what state the notification represents
619
- */
620
- kind: PropTypes__default["default"].oneOf(['error', 'info', 'info-square', 'success', 'warning', 'warning-alt']).isRequired,
621
-
622
- /**
623
- * Specify whether you are using the low contrast variant of the ActionableNotification.
624
- */
625
- lowContrast: PropTypes__default["default"].bool,
626
-
627
- /**
628
- * Provide a function that is called when the action is clicked
629
- */
630
- onActionButtonClick: PropTypes__default["default"].func,
631
-
632
- /**
633
- * Provide a function that is called when menu is closed
634
- */
635
- onClose: PropTypes__default["default"].func,
636
-
637
- /**
638
- * Provide a function that is called when the close button is clicked
639
- */
640
- onCloseButtonClick: PropTypes__default["default"].func,
641
-
642
- /**
643
- * By default, this value is "alertdialog". You can also provide an alternate
644
- * role if it makes sense from the accessibility-side.
645
- */
646
- role: PropTypes__default["default"].string,
647
-
648
- /**
649
- * Provide a description for "status" icon that can be read by screen readers
650
- */
651
- statusIconDescription: PropTypes__default["default"].string,
652
-
653
- /**
654
- * Specify the sub-title
655
- */
656
- subtitle: PropTypes__default["default"].string,
657
-
658
- /**
659
- * Specify the title
660
- */
661
- title: PropTypes__default["default"].string
662
- };
663
- ActionableNotification.defaultProps = {
664
- kind: 'error',
665
- role: 'alertdialog',
666
- onCloseButtonClick: function onCloseButtonClick() {},
667
- hideCloseButton: false,
668
- hasFocus: true,
669
- closeOnEscape: true,
670
- inline: false
671
- };
672
-
673
- exports.ActionableNotification = ActionableNotification;
674
- exports.InlineNotification = InlineNotification;
675
- exports.NotificationActionButton = NotificationActionButton;
676
- exports.NotificationButton = NotificationButton;
677
- exports.ToastNotification = ToastNotification;