@carbon/ibm-products 2.25.0 → 2.27.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (162) hide show
  1. package/css/index-full-carbon.css +556 -63
  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 +50 -16
  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 +556 -63
  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 +527 -55
  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/BigNumbers/BigNumbers.d.ts +11 -0
  18. package/es/components/BigNumbers/BigNumbers.js +238 -0
  19. package/es/components/BigNumbers/constants.d.ts +13 -0
  20. package/es/components/BigNumbers/constants.js +67 -0
  21. package/es/components/BigNumbers/index.d.ts +1 -0
  22. package/es/components/Cascade/Cascade.d.ts +19 -2
  23. package/es/components/Cascade/Cascade.js +12 -9
  24. package/es/components/Coachmark/CoachmarkTagline.js +1 -2
  25. package/es/components/CoachmarkStack/CoachmarkStackHome.js +1 -1
  26. package/es/components/DataSpreadsheet/DataSpreadsheetBody.js +4 -3
  27. package/es/components/DataSpreadsheet/DataSpreadsheetHeader.js +3 -2
  28. package/es/components/DataSpreadsheet/utils/checkForHoldingKey.d.ts +1 -0
  29. package/es/components/DataSpreadsheet/utils/checkForHoldingKey.js +17 -0
  30. package/es/components/Datagrid/Datagrid/Datagrid.js +9 -2
  31. package/es/components/Datagrid/Datagrid/DatagridContent.d.ts +3 -1
  32. package/es/components/Datagrid/Datagrid/DatagridContent.js +6 -2
  33. package/es/components/Datagrid/Datagrid/DatagridHeaderRow.js +21 -8
  34. package/es/components/Datagrid/Datagrid/DatagridRow.js +15 -2
  35. package/es/components/Datagrid/Datagrid/DatagridToolbar.d.ts +10 -1
  36. package/es/components/Datagrid/Datagrid/DatagridToolbar.js +21 -4
  37. package/es/components/Datagrid/Datagrid/addons/Filtering/FilterProvider.js +32 -9
  38. package/es/components/Datagrid/Datagrid/addons/Filtering/constants.d.ts +3 -1
  39. package/es/components/Datagrid/Datagrid/addons/Filtering/constants.js +4 -1
  40. package/es/components/Datagrid/Datagrid/addons/Filtering/hooks/useFilters.js +35 -3
  41. package/es/components/Datagrid/Datagrid/addons/Slug/DatagridSlug.d.ts +2 -0
  42. package/es/components/Datagrid/Datagrid/addons/Slug/{ColumnHeaderSlug.js → DatagridSlug.js} +4 -4
  43. package/es/components/Datagrid/Datagrid/addons/stateReducer.js +3 -3
  44. package/es/components/Datagrid/useSelectAllToggle.js +5 -3
  45. package/es/components/Datagrid/useSortableColumns.js +2 -2
  46. package/es/components/EmptyStates/EmptyStateContent.d.ts +1 -1
  47. package/es/components/FullPageError/FullPageError.js +41 -15
  48. package/es/components/FullPageError/assets/Error403SVG.d.ts +9 -0
  49. package/es/components/FullPageError/assets/Error403SVG.js +714 -0
  50. package/es/components/FullPageError/assets/Error404SVG.d.ts +9 -0
  51. package/es/components/FullPageError/assets/Error404SVG.js +623 -0
  52. package/es/components/HTTPErrors/HTTPErrorContent.d.ts +1 -1
  53. package/es/components/InterstitialScreen/InterstitialScreen.js +1 -1
  54. package/es/components/SidePanel/SidePanel.js +13 -6
  55. package/es/components/SidePanel/motion/variants.d.ts +39 -12
  56. package/es/components/SidePanel/motion/variants.js +42 -11
  57. package/es/components/StringFormatter/StringFormatter.d.ts +6 -0
  58. package/es/components/StringFormatter/StringFormatter.js +79 -0
  59. package/es/components/StringFormatter/index.d.ts +1 -0
  60. package/es/components/StringFormatter/utils/enums.d.ts +14 -0
  61. package/es/components/StringFormatter/utils/enums.js +23 -0
  62. package/es/components/Tearsheet/TearsheetShell.js +26 -8
  63. package/es/components/UserAvatar/UserAvatar.js +59 -44
  64. package/es/components/index.d.ts +2 -0
  65. package/es/global/js/hooks/index.d.ts +2 -0
  66. package/es/global/js/hooks/useFocus.d.ts +11 -0
  67. package/es/global/js/hooks/useFocus.js +76 -0
  68. package/es/global/js/hooks/useIsomorphicEffect.d.ts +2 -0
  69. package/es/global/js/hooks/useIsomorphicEffect.js +14 -0
  70. package/es/global/js/package-settings.d.ts +2 -0
  71. package/es/global/js/package-settings.js +2 -0
  72. package/es/index.js +2 -0
  73. package/es/settings.d.ts +2 -0
  74. package/lib/components/BigNumbers/BigNumbers.d.ts +11 -0
  75. package/lib/components/BigNumbers/BigNumbers.js +244 -0
  76. package/lib/components/BigNumbers/constants.d.ts +13 -0
  77. package/lib/components/BigNumbers/constants.js +76 -0
  78. package/lib/components/BigNumbers/index.d.ts +1 -0
  79. package/lib/components/Cascade/Cascade.d.ts +19 -2
  80. package/lib/components/Cascade/Cascade.js +12 -9
  81. package/lib/components/Coachmark/CoachmarkTagline.js +3 -4
  82. package/lib/components/CoachmarkStack/CoachmarkStackHome.js +2 -2
  83. package/lib/components/DataSpreadsheet/DataSpreadsheetBody.js +4 -3
  84. package/lib/components/DataSpreadsheet/DataSpreadsheetHeader.js +3 -2
  85. package/lib/components/DataSpreadsheet/utils/checkForHoldingKey.d.ts +1 -0
  86. package/lib/components/DataSpreadsheet/utils/checkForHoldingKey.js +21 -0
  87. package/lib/components/Datagrid/Datagrid/Datagrid.js +9 -2
  88. package/lib/components/Datagrid/Datagrid/DatagridContent.d.ts +3 -1
  89. package/lib/components/Datagrid/Datagrid/DatagridContent.js +6 -2
  90. package/lib/components/Datagrid/Datagrid/DatagridHeaderRow.js +20 -7
  91. package/lib/components/Datagrid/Datagrid/DatagridRow.js +14 -1
  92. package/lib/components/Datagrid/Datagrid/DatagridToolbar.d.ts +10 -1
  93. package/lib/components/Datagrid/Datagrid/DatagridToolbar.js +20 -3
  94. package/lib/components/Datagrid/Datagrid/addons/Filtering/FilterProvider.js +30 -7
  95. package/lib/components/Datagrid/Datagrid/addons/Filtering/constants.d.ts +3 -1
  96. package/lib/components/Datagrid/Datagrid/addons/Filtering/constants.js +4 -0
  97. package/lib/components/Datagrid/Datagrid/addons/Filtering/hooks/useFilters.js +33 -1
  98. package/lib/components/Datagrid/Datagrid/addons/Slug/DatagridSlug.d.ts +2 -0
  99. package/lib/components/Datagrid/Datagrid/addons/Slug/{ColumnHeaderSlug.js → DatagridSlug.js} +4 -4
  100. package/lib/components/Datagrid/Datagrid/addons/stateReducer.js +3 -3
  101. package/lib/components/Datagrid/useSelectAllToggle.js +4 -2
  102. package/lib/components/Datagrid/useSortableColumns.js +2 -2
  103. package/lib/components/EmptyStates/EmptyStateContent.d.ts +1 -1
  104. package/lib/components/FullPageError/FullPageError.js +41 -15
  105. package/lib/components/FullPageError/assets/Error403SVG.d.ts +9 -0
  106. package/lib/components/FullPageError/assets/Error403SVG.js +722 -0
  107. package/lib/components/FullPageError/assets/Error404SVG.d.ts +9 -0
  108. package/lib/components/FullPageError/assets/Error404SVG.js +631 -0
  109. package/lib/components/HTTPErrors/HTTPErrorContent.d.ts +1 -1
  110. package/lib/components/InterstitialScreen/InterstitialScreen.js +3 -3
  111. package/lib/components/SidePanel/SidePanel.js +11 -4
  112. package/lib/components/SidePanel/motion/variants.d.ts +39 -12
  113. package/lib/components/SidePanel/motion/variants.js +42 -10
  114. package/lib/components/StringFormatter/StringFormatter.d.ts +6 -0
  115. package/lib/components/StringFormatter/StringFormatter.js +85 -0
  116. package/lib/components/StringFormatter/index.d.ts +1 -0
  117. package/lib/components/StringFormatter/utils/enums.d.ts +14 -0
  118. package/lib/components/StringFormatter/utils/enums.js +27 -0
  119. package/lib/components/Tearsheet/TearsheetShell.js +26 -8
  120. package/lib/components/UserAvatar/UserAvatar.js +59 -44
  121. package/lib/components/index.d.ts +2 -0
  122. package/lib/global/js/hooks/index.d.ts +2 -0
  123. package/lib/global/js/hooks/useFocus.d.ts +11 -0
  124. package/lib/global/js/hooks/useFocus.js +80 -0
  125. package/lib/global/js/hooks/useIsomorphicEffect.d.ts +2 -0
  126. package/lib/global/js/hooks/useIsomorphicEffect.js +18 -0
  127. package/lib/global/js/package-settings.d.ts +2 -0
  128. package/lib/global/js/package-settings.js +2 -0
  129. package/lib/index.js +10 -0
  130. package/lib/settings.d.ts +2 -0
  131. package/package.json +7 -7
  132. package/scss/components/BigNumbers/_big-numbers.scss +151 -0
  133. package/scss/components/BigNumbers/_carbon-imports.scss +11 -0
  134. package/scss/components/BigNumbers/_index-with-carbon.scss +9 -0
  135. package/scss/components/BigNumbers/_index.scss +8 -0
  136. package/scss/components/Datagrid/styles/_datagrid.scss +19 -0
  137. package/scss/components/FilterSummary/_filter-summary.scss +1 -1
  138. package/scss/components/FullPageError/_full-page-error.scss +20 -2
  139. package/scss/components/ProductiveCard/_productive-card.scss +1 -1
  140. package/scss/components/SidePanel/_side-panel.scss +1 -1
  141. package/scss/components/StringFormatter/_carbon-imports.scss +10 -0
  142. package/scss/components/StringFormatter/_index-with-carbon.scss +9 -0
  143. package/scss/components/StringFormatter/_index.scss +8 -0
  144. package/scss/components/StringFormatter/_string-formatter.scss +97 -0
  145. package/scss/components/Tearsheet/_tearsheet.scss +34 -2
  146. package/scss/components/UserAvatar/_user-avatar.scss +47 -4
  147. package/scss/components/_index-with-carbon.scss +2 -0
  148. package/scss/components/_index.scss +2 -0
  149. package/es/components/Datagrid/Datagrid/addons/Slug/ColumnHeaderSlug.d.ts +0 -2
  150. package/es/node_modules/@carbon/icon-helpers/es/index.js +0 -140
  151. package/es/node_modules/@carbon/icons-react/es/Icon.js +0 -73
  152. package/es/node_modules/@carbon/icons-react/es/generated/bucket-0.js +0 -2985
  153. package/es/node_modules/@carbon/icons-react/es/generated/bucket-3.js +0 -2900
  154. package/es/node_modules/@carbon/icons-react/es/generated/bucket-8.js +0 -3004
  155. package/es/node_modules/@carbon/icons-react/es/iconPropTypes-4cbeb95d.js +0 -14
  156. package/lib/components/Datagrid/Datagrid/addons/Slug/ColumnHeaderSlug.d.ts +0 -2
  157. package/lib/node_modules/@carbon/icon-helpers/es/index.js +0 -145
  158. package/lib/node_modules/@carbon/icons-react/es/Icon.js +0 -81
  159. package/lib/node_modules/@carbon/icons-react/es/generated/bucket-0.js +0 -3117
  160. package/lib/node_modules/@carbon/icons-react/es/generated/bucket-3.js +0 -3032
  161. package/lib/node_modules/@carbon/icons-react/es/generated/bucket-8.js +0 -3136
  162. package/lib/node_modules/@carbon/icons-react/es/iconPropTypes-4cbeb95d.js +0 -18
@@ -12,10 +12,10 @@ import cx from '../../node_modules/classnames/index.js';
12
12
  import { getDevtoolsProps } from '../../global/js/utils/devtools.js';
13
13
  import { pkg } from '../../settings.js';
14
14
  import { clamp } from 'lodash';
15
+ import { ArrowRight } from '@carbon/react/icons';
15
16
  import { ComposedModal, ModalHeader, ProgressIndicator, ProgressStep, ModalBody, ModalFooter, FlexGrid, Row, Column, Button } from '@carbon/react';
16
17
  import { Carousel } from '../Carousel/Carousel.js';
17
18
  import { SteppedAnimatedMedia } from '../SteppedAnimatedMedia/SteppedAnimatedMedia.js';
18
- import { ArrowRight } from '../../node_modules/@carbon/icons-react/es/generated/bucket-0.js';
19
19
 
20
20
  var _excluded = ["children", "className", "closeIconDescription", "domainName", "hideProgressIndicator", "interstitialAriaLabel", "isFullScreen", "isOpen", "media", "nextButtonLabel", "onClose", "previousButtonLabel", "productName", "headerClassName", "headerTitle", "startButtonLabel", "skipButtonLabel"];
21
21
 
@@ -7,7 +7,7 @@
7
7
 
8
8
  import { objectWithoutProperties as _objectWithoutProperties, slicedToArray as _slicedToArray, defineProperty as _defineProperty, extends as _extends, objectSpread2 as _objectSpread2 } from '../../_virtual/_rollupPluginBabelHelpers.js';
9
9
  import React__default, { useState, useRef, useEffect, useCallback } from 'react';
10
- import { AnimatePresence, motion } from 'framer-motion';
10
+ import { motion, useReducedMotion, AnimatePresence } from 'framer-motion';
11
11
  import PropTypes from '../../node_modules/prop-types/index.js';
12
12
  import cx from '../../node_modules/classnames/index.js';
13
13
  import { useResizeObserver } from '../../global/js/hooks/useResizeObserver.js';
@@ -19,10 +19,10 @@ import { pkg } from '../../settings.js';
19
19
  import { SIDE_PANEL_SIZES } from './constants.js';
20
20
  import { Button } from '@carbon/react';
21
21
  import { ArrowLeft, Close } from '@carbon/react/icons';
22
- import { overlayVariants, panelVariants } from './motion/variants.js';
22
+ import { actionSetVariants, overlayVariants, panelVariants } from './motion/variants.js';
23
23
  import pconsole from '../../global/js/utils/pconsole.js';
24
- import { usePreviousValue } from '../../global/js/hooks/usePreviousValue.js';
25
24
  import { ActionSet } from '../ActionSet/ActionSet.js';
25
+ import { usePreviousValue } from '../../global/js/hooks/usePreviousValue.js';
26
26
 
27
27
  var _excluded = ["actionToolbarButtons", "actions", "animateTitle", "children", "className", "closeIconDescription", "condensedActions", "currentStep", "id", "includeOverlay", "labelText", "navigationBackIconDescription", "onNavigationBack", "onRequestClose", "onUnmount", "open", "placement", "preventCloseOnClickOutside", "selectorPageContent", "selectorPrimaryFocus", "size", "slideIn", "slug", "subtitle", "title"],
28
28
  _excluded2 = ["label", "kind", "icon", "tooltipPosition", "tooltipAlignment", "leading", "disabled", "className", "onClick"];
@@ -40,6 +40,7 @@ var defaults = {
40
40
  placement: 'right',
41
41
  size: 'md'
42
42
  };
43
+ var MotionActionSet = motion(ActionSet);
43
44
 
44
45
  /**
45
46
  * Side panels keep users in-context of a page while performing tasks like navigating, editing, viewing details, or configuring something new.
@@ -107,6 +108,7 @@ var SidePanel = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
107
108
  _useState6 = _slicedToArray(_useState5, 2),
108
109
  doAnimateTitle = _useState6[0],
109
110
  setDoAnimateTitle = _useState6[1];
111
+ var shouldReduceMotion = useReducedMotion();
110
112
  useEffect(function () {
111
113
  setDoAnimateTitle(animateTitle);
112
114
  }, [animateTitle]);
@@ -429,7 +431,10 @@ var SidePanel = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
429
431
  initial: "hidden",
430
432
  animate: "visible",
431
433
  exit: "exit",
432
- custom: placement
434
+ custom: {
435
+ placement: placement,
436
+ shouldReduceMotion: shouldReduceMotion
437
+ }
433
438
  }), /*#__PURE__*/React__default.createElement("span", {
434
439
  ref: startTrapRef,
435
440
  tabIndex: "0",
@@ -438,10 +443,12 @@ var SidePanel = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
438
443
  }, "Focus sentinel"), doAnimateTitle ? /*#__PURE__*/React__default.createElement("div", {
439
444
  ref: animatedScrollRef,
440
445
  className: "".concat(blockClass, "__animated-scroll-wrapper ").concat(blockClass, "--scrolls")
441
- }, renderHeader(), renderMain()) : /*#__PURE__*/React__default.createElement(React__default.Fragment, null, renderHeader(), renderMain()), /*#__PURE__*/React__default.createElement(ActionSet, {
446
+ }, renderHeader(), renderMain()) : /*#__PURE__*/React__default.createElement(React__default.Fragment, null, renderHeader(), renderMain()), /*#__PURE__*/React__default.createElement(MotionActionSet, {
442
447
  actions: actions,
443
448
  className: primaryActionContainerClassNames,
444
- size: size === 'xs' ? 'sm' : size
449
+ size: size === 'xs' ? 'sm' : size,
450
+ custom: shouldReduceMotion,
451
+ variants: actionSetVariants
445
452
  }), /*#__PURE__*/React__default.createElement("span", {
446
453
  ref: endTrapRef,
447
454
  tabIndex: "0",
@@ -16,27 +16,54 @@ export namespace overlayVariants {
16
16
  }
17
17
  }
18
18
  export namespace panelVariants {
19
- export namespace visible_1 {
20
- export let x: number;
21
- export namespace transition_1 {
22
- let duration_1: number;
23
- export { duration_1 as duration };
24
- let ease_1: number[];
25
- export { ease_1 as ease };
26
- }
27
- export { transition_1 as transition };
28
- }
19
+ export function visible_1({ shouldReduceMotion }: {
20
+ shouldReduceMotion: any;
21
+ }): {
22
+ x: number;
23
+ transition: {
24
+ duration: number;
25
+ ease: number[];
26
+ };
27
+ opacity: any;
28
+ };
29
29
  export { visible_1 as visible };
30
- export function hidden_1(placement: any): {
30
+ export function hidden_1({ placement, shouldReduceMotion }: {
31
+ placement: any;
32
+ shouldReduceMotion: any;
33
+ }): {
31
34
  x: string | number;
35
+ opacity: any;
32
36
  };
33
37
  export { hidden_1 as hidden };
34
- export function exit_1(placement: any): {
38
+ export function exit_1({ placement, shouldReduceMotion }: {
39
+ placement: any;
40
+ shouldReduceMotion: any;
41
+ }): {
35
42
  x: string | number;
36
43
  transition: {
37
44
  duration: number;
38
45
  ease: number[];
39
46
  };
47
+ opacity: any;
40
48
  };
41
49
  export { exit_1 as exit };
42
50
  }
51
+ export namespace actionSetVariants {
52
+ export function hidden_2(shouldReduceMotion: any): {
53
+ opacity: number;
54
+ transition: {
55
+ duration: number;
56
+ ease: number | number[];
57
+ };
58
+ };
59
+ export { hidden_2 as hidden };
60
+ export function visible_2(shouldReduceMotion: any): {
61
+ opacity: number;
62
+ transition: {
63
+ duration: number;
64
+ ease: number | number[];
65
+ delay: number;
66
+ };
67
+ };
68
+ export { visible_2 as visible };
69
+ }
@@ -23,27 +23,58 @@ var overlayVariants = {
23
23
  }
24
24
  };
25
25
  var panelVariants = {
26
- visible: {
27
- x: 0,
28
- transition: {
29
- duration: DURATIONS.moderate02,
30
- ease: EASINGS.productive.standard
31
- }
26
+ visible: function visible(_ref) {
27
+ var shouldReduceMotion = _ref.shouldReduceMotion;
28
+ return {
29
+ x: 0,
30
+ transition: {
31
+ duration: DURATIONS.moderate02,
32
+ ease: EASINGS.productive.standard
33
+ },
34
+ opacity: shouldReduceMotion && 1
35
+ };
32
36
  },
33
- hidden: function hidden(placement) {
37
+ hidden: function hidden(_ref2) {
38
+ var placement = _ref2.placement,
39
+ shouldReduceMotion = _ref2.shouldReduceMotion;
34
40
  return {
35
- x: placement === 'right' ? '100%' : -320
41
+ x: placement === 'right' ? shouldReduceMotion ? 0 : '100%' : shouldReduceMotion ? 0 : -320,
42
+ opacity: shouldReduceMotion && 0
36
43
  };
37
44
  },
38
- exit: function exit(placement) {
45
+ exit: function exit(_ref3) {
46
+ var placement = _ref3.placement,
47
+ shouldReduceMotion = _ref3.shouldReduceMotion;
39
48
  return {
40
- x: placement === 'right' ? '100%' : -320,
49
+ x: placement === 'right' ? shouldReduceMotion ? 0 : '100%' : shouldReduceMotion ? 0 : -320,
41
50
  transition: {
42
51
  duration: DURATIONS.moderate01,
43
52
  ease: EASINGS.productive.exit
53
+ },
54
+ opacity: shouldReduceMotion && 0
55
+ };
56
+ }
57
+ };
58
+ var actionSetVariants = {
59
+ hidden: function hidden(shouldReduceMotion) {
60
+ return {
61
+ opacity: shouldReduceMotion ? 0 : 1,
62
+ transition: {
63
+ duration: shouldReduceMotion ? DURATIONS.moderate01 : DURATIONS.fast01,
64
+ ease: shouldReduceMotion ? 0 : EASINGS.productive.exit
65
+ }
66
+ };
67
+ },
68
+ visible: function visible(shouldReduceMotion) {
69
+ return {
70
+ opacity: 1,
71
+ transition: {
72
+ duration: shouldReduceMotion ? DURATIONS.moderate01 : DURATIONS.fast02,
73
+ ease: shouldReduceMotion ? 0 : EASINGS.productive.entrance,
74
+ delay: shouldReduceMotion ? 0.075 : 0
44
75
  }
45
76
  };
46
77
  }
47
78
  };
48
79
 
49
- export { overlayVariants, panelVariants };
80
+ export { actionSetVariants, overlayVariants, panelVariants };
@@ -0,0 +1,6 @@
1
+ /**
2
+ * StringFormatter allows for truncating text while displaying a tooltip
3
+ * overlay on hover or focus with the entirety of the provided copy.
4
+ */
5
+ export let StringFormatter: React.ForwardRefExoticComponent<React.RefAttributes<any>>;
6
+ import React from 'react';
@@ -0,0 +1,79 @@
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, defineProperty as _defineProperty, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
9
+ import React__default from 'react';
10
+ import PropTypes from '../../node_modules/prop-types/index.js';
11
+ import cx from '../../node_modules/classnames/index.js';
12
+ import { getDevtoolsProps } from '../../global/js/utils/devtools.js';
13
+ import { pkg } from '../../settings.js';
14
+ import { DefinitionTooltip } from '@carbon/react';
15
+ import { StringFormatterAlignment } from './utils/enums.js';
16
+
17
+ var _excluded = ["className", "lines", "tooltipDirection", "truncate", "width", "value"];
18
+ var blockClass = "".concat(pkg.prefix, "--string-formatter");
19
+ var componentName = 'StringFormatter';
20
+ var defaults = {
21
+ lines: 1,
22
+ tooltipDirection: StringFormatterAlignment.BOTTOM_LEFT,
23
+ truncate: false,
24
+ width: null
25
+ };
26
+
27
+ /**
28
+ * StringFormatter allows for truncating text while displaying a tooltip
29
+ * overlay on hover or focus with the entirety of the provided copy.
30
+ */
31
+ var StringFormatter = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
32
+ var className = _ref.className,
33
+ _ref$lines = _ref.lines,
34
+ lines = _ref$lines === void 0 ? defaults.lines : _ref$lines,
35
+ _ref$tooltipDirection = _ref.tooltipDirection,
36
+ tooltipDirection = _ref$tooltipDirection === void 0 ? defaults.tooltipDirection : _ref$tooltipDirection,
37
+ _ref$truncate = _ref.truncate,
38
+ truncate = _ref$truncate === void 0 ? defaults.truncate : _ref$truncate,
39
+ _ref$width = _ref.width,
40
+ width = _ref$width === void 0 ? defaults.width : _ref$width,
41
+ value = _ref.value,
42
+ rest = _objectWithoutProperties(_ref, _excluded);
43
+ var stringFormatterContent = /*#__PURE__*/React__default.createElement("span", {
44
+ className: cx("".concat(blockClass, "--content"), _defineProperty({}, "".concat(blockClass, "--truncate"), truncate)),
45
+ style: {
46
+ maxWidth: width,
47
+ WebkitLineClamp: lines
48
+ }
49
+ }, value);
50
+ return /*#__PURE__*/React__default.createElement("span", _extends({}, rest, {
51
+ className: cx(blockClass, className),
52
+ ref: ref
53
+ }, getDevtoolsProps(componentName)), truncate ? /*#__PURE__*/React__default.createElement(DefinitionTooltip, {
54
+ className: "".concat(blockClass, "__tooltip"),
55
+ align: tooltipDirection,
56
+ definition: value,
57
+ openOnHover: true
58
+ }, stringFormatterContent) : stringFormatterContent);
59
+ });
60
+ StringFormatter = pkg.checkComponentEnabled(StringFormatter, componentName);
61
+ StringFormatter.displayName = componentName;
62
+ StringFormatter.propTypes = {
63
+ /**
64
+ * Provide an optional class to be applied to the containing node.
65
+ */
66
+ className: PropTypes.string,
67
+ /** Number of lines to clamp value. */
68
+ lines: PropTypes.number,
69
+ /** Specify the direction of the tooltip. Can be either top or bottom. */
70
+ tooltipDirection: PropTypes.oneOf(Object.values(StringFormatterAlignment)),
71
+ /** Whether or not the value should be truncated. */
72
+ truncate: PropTypes.bool,
73
+ /** Value to format. */
74
+ value: PropTypes.string.isRequired,
75
+ /** Maximum width of value which should include */
76
+ width: PropTypes.string
77
+ };
78
+
79
+ export { StringFormatter };
@@ -0,0 +1 @@
1
+ export { StringFormatter } from "./StringFormatter";
@@ -0,0 +1,14 @@
1
+ export namespace StringFormatterAlignment {
2
+ let TOP: string;
3
+ let TOP_LEFT: string;
4
+ let TOP_RIGHT: string;
5
+ let BOTTOM: string;
6
+ let BOTTOM_LEFT: string;
7
+ let BOTTOM_RIGHT: string;
8
+ let LEFT: string;
9
+ let LEFT_BOTTOM: string;
10
+ let LEFT_TOP: string;
11
+ let RIGHT: string;
12
+ let RIGHT_BOTTOM: string;
13
+ let RIGHT_TOP: string;
14
+ }
@@ -0,0 +1,23 @@
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
+ var StringFormatterAlignment = {
9
+ TOP: 'top',
10
+ TOP_LEFT: 'top-left',
11
+ TOP_RIGHT: 'top-right',
12
+ BOTTOM: 'bottom',
13
+ BOTTOM_LEFT: 'bottom-left',
14
+ BOTTOM_RIGHT: 'bottom-right',
15
+ LEFT: 'left',
16
+ LEFT_BOTTOM: 'left-bottom',
17
+ LEFT_TOP: 'left-top',
18
+ RIGHT: 'right',
19
+ RIGHT_BOTTOM: 'right-bottom',
20
+ RIGHT_TOP: 'right-top'
21
+ };
22
+
23
+ export { StringFormatterAlignment };
@@ -16,9 +16,10 @@ import { getNodeTextContent } from '../../global/js/utils/getNodeTextContent.js'
16
16
  import { usePrefix, ComposedModal, ModalHeader, Layer, ModalBody, Button } from '@carbon/react';
17
17
  import { Wrap } from '../../global/js/utils/Wrap.js';
18
18
  import { usePortalTarget } from '../../global/js/hooks/usePortalTarget.js';
19
+ import { useFocus } from '../../global/js/hooks/useFocus.js';
19
20
  import { ActionSet } from '../ActionSet/ActionSet.js';
20
21
 
21
- var _excluded = ["actions", "ariaLabel", "children", "className", "closeIconDescription", "description", "hasCloseIcon", "headerActions", "influencer", "influencerPosition", "influencerWidth", "label", "navigation", "onClose", "open", "selectorPrimaryFocus", "size", "portalTarget", "title", "verticalPosition"];
22
+ var _excluded = ["actions", "ariaLabel", "children", "className", "closeIconDescription", "description", "hasCloseIcon", "headerActions", "influencer", "influencerPosition", "influencerWidth", "label", "navigation", "onClose", "open", "portalTarget", "selectorPrimaryFocus", "size", "slug", "title", "verticalPosition"];
22
23
 
23
24
  // The block part of our conventional BEM class names (bc__E--M).
24
25
  var bc = "".concat(pkg.prefix, "--tearsheet");
@@ -70,9 +71,10 @@ var TearsheetShell = /*#__PURE__*/React__default.forwardRef(function (_ref, ref)
70
71
  navigation = _ref.navigation,
71
72
  onClose = _ref.onClose,
72
73
  open = _ref.open,
74
+ portalTargetIn = _ref.portalTarget,
73
75
  selectorPrimaryFocus = _ref.selectorPrimaryFocus,
74
76
  size = _ref.size,
75
- portalTargetIn = _ref.portalTarget,
77
+ slug = _ref.slug,
76
78
  title = _ref.title,
77
79
  verticalPosition = _ref.verticalPosition,
78
80
  rest = _objectWithoutProperties(_ref, _excluded);
@@ -81,9 +83,13 @@ var TearsheetShell = /*#__PURE__*/React__default.forwardRef(function (_ref, ref)
81
83
  var renderPortalUse = usePortalTarget(portalTargetIn);
82
84
  var localRef = useRef();
83
85
  var resizer = useRef(null);
86
+ var modalBodyRef = useRef(null);
84
87
  var modalRef = ref || localRef;
85
88
  var _useResizeObserver = useResizeObserver(resizer),
86
89
  width = _useResizeObserver.width;
90
+ var _useFocus = useFocus(modalRef),
91
+ firstElement = _useFocus.firstElement,
92
+ keyDownListener = _useFocus.keyDownListener;
87
93
  var wide = size === 'wide';
88
94
 
89
95
  // Keep track of the stack depth and our position in it (1-based, 0=closed)
@@ -121,11 +127,16 @@ var TearsheetShell = /*#__PURE__*/React__default.forwardRef(function (_ref, ref)
121
127
 
122
128
  // Callback to give the tearsheet the opportunity to claim focus
123
129
  handleStackChange.claimFocus = function () {
124
- var element = selectorPrimaryFocus ? modalRef.current.querySelector(selectorPrimaryFocus) : modalRef.current;
125
- setTimeout(function () {
126
- return element.focus();
127
- }, 1);
130
+ firstElement === null || firstElement === void 0 || firstElement.focus();
128
131
  };
132
+ useEffect(function () {
133
+ if (open) {
134
+ // Focusing the first element
135
+ setTimeout(function () {
136
+ firstElement === null || firstElement === void 0 || firstElement.focus();
137
+ }, 0);
138
+ }
139
+ }, [open, firstElement]);
129
140
  useEffect(function () {
130
141
  var notify = function notify() {
131
142
  return stack.all.forEach(function (handler) {
@@ -180,15 +191,17 @@ var TearsheetShell = /*#__PURE__*/React__default.forwardRef(function (_ref, ref)
180
191
  var includeActions = actions && (actions === null || actions === void 0 ? void 0 : actions.length) > 0;
181
192
  return renderPortalUse( /*#__PURE__*/React__default.createElement(ComposedModal, _extends({}, rest, {
182
193
  "aria-label": ariaLabel || getNodeTextContent(title),
183
- className: cx(bc, className, _defineProperty(_defineProperty(_defineProperty({}, "".concat(bc, "--stacked-").concat(position, "-of-").concat(depth),
194
+ className: cx(bc, className, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, "".concat(bc, "--stacked-").concat(position, "-of-").concat(depth),
184
195
  // Don't apply this on the initial open of a single tearsheet.
185
- depth > 1 || depth === 1 && prevDepth.current > 1), "".concat(bc, "--wide"), wide), "".concat(bc, "--narrow"), !wide)),
196
+ depth > 1 || depth === 1 && prevDepth.current > 1), "".concat(bc, "--wide"), wide), "".concat(bc, "--narrow"), !wide), "".concat(bc, "--has-slug"), slug), "".concat(bc, "--has-close"), effectiveHasCloseIcon)),
197
+ slug: slug,
186
198
  style: _defineProperty(_defineProperty({}, "--".concat(bc, "--stacking-scale-factor-single"), (width - 32) / width), "--".concat(bc, "--stacking-scale-factor-double"), (width - 64) / width),
187
199
  containerClassName: cx("".concat(bc, "__container"), _defineProperty({}, "".concat(bc, "__container--lower"), verticalPosition === 'lower')),
188
200
  onClose: onClose,
189
201
  open: open,
190
202
  selectorPrimaryFocus: selectorPrimaryFocus,
191
203
  onFocus: handleFocus,
204
+ onKeyDown: keyDownListener,
192
205
  preventCloseOnClickOutside: !isPassive,
193
206
  ref: modalRef,
194
207
  selectorsFloatingMenus: [".".concat(carbonPrefix, "--overflow-menu-options"), ".".concat(carbonPrefix, "--tooltip"), '.flatpickr-calendar', ".".concat(bc, "__container")],
@@ -216,6 +229,7 @@ var TearsheetShell = /*#__PURE__*/React__default.forwardRef(function (_ref, ref)
216
229
  }, headerActions)), /*#__PURE__*/React__default.createElement(Wrap, {
217
230
  className: "".concat(bc, "__header-navigation")
218
231
  }, navigation)), /*#__PURE__*/React__default.createElement(Wrap, {
232
+ ref: modalBodyRef,
219
233
  element: ModalBody,
220
234
  className: "".concat(bc, "__body")
221
235
  }, /*#__PURE__*/React__default.createElement(Wrap, {
@@ -382,6 +396,10 @@ TearsheetShell.propTypes = _objectSpread2({
382
396
  * Specifies the width of the tearsheet, 'narrow' or 'wide'.
383
397
  */
384
398
  size: PropTypes.oneOf(['narrow', 'wide']).isRequired,
399
+ /**
400
+ * **Experimental:** Provide a `Slug` component to be rendered inside the `SidePanel` component
401
+ */
402
+ slug: PropTypes.node,
385
403
  /**
386
404
  * The main title of the tearsheet, displayed in the header area.
387
405
  */
@@ -11,12 +11,11 @@ import PropTypes from '../../node_modules/prop-types/index.js';
11
11
  import cx from '../../node_modules/classnames/index.js';
12
12
  import { getDevtoolsProps } from '../../global/js/utils/devtools.js';
13
13
  import { pkg } from '../../settings.js';
14
- import { User, Group } from '@carbon/react/icons';
15
14
  import { usePrefix, Tooltip } from '@carbon/react';
15
+ import { User } from '@carbon/react/icons';
16
16
  import { TooltipTrigger } from '../TooltipTrigger/TooltipTrigger.js';
17
17
 
18
- var _excluded = ["backgroundColor", "className", "renderIcon", "tooltipText", "tooltipAlignment"];
19
- var _User, _User2, _Group;
18
+ var _excluded = ["backgroundColor", "className", "name", "renderIcon", "size", "tooltipText", "tooltipAlignment"];
20
19
  // Carbon and package components we use.
21
20
  /* TODO: @import(s) of carbon components and other package components. */
22
21
 
@@ -45,69 +44,77 @@ var componentName = 'UserAvatar';
45
44
  */
46
45
 
47
46
  var defaults = {
48
- renderIcon: function renderIcon() {
49
- return _User || (_User = /*#__PURE__*/React__default.createElement(User, {
50
- size: 32
51
- }));
52
- },
53
- tooltipAlignment: 'bottom',
54
- tooltipText: 'Thomas J. Watson'
47
+ size: 'md',
48
+ tooltipAlignment: 'bottom'
55
49
  };
56
50
  var UserAvatar = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
57
- var _SetItem;
58
51
  var backgroundColor = _ref.backgroundColor,
59
52
  className = _ref.className,
60
- _ref$renderIcon = _ref.renderIcon,
61
- renderIcon = _ref$renderIcon === void 0 ? defaults.renderIcon : _ref$renderIcon,
62
- _ref$tooltipText = _ref.tooltipText,
63
- tooltipText = _ref$tooltipText === void 0 ? defaults.tooltipText : _ref$tooltipText,
53
+ name = _ref.name,
54
+ RenderIcon = _ref.renderIcon,
55
+ _ref$size = _ref.size,
56
+ size = _ref$size === void 0 ? defaults.size : _ref$size,
57
+ tooltipText = _ref.tooltipText,
64
58
  _ref$tooltipAlignment = _ref.tooltipAlignment,
65
59
  tooltipAlignment = _ref$tooltipAlignment === void 0 ? defaults.tooltipAlignment : _ref$tooltipAlignment,
66
60
  rest = _objectWithoutProperties(_ref, _excluded);
67
61
  var carbonPrefix = usePrefix();
68
- var icons = {
69
- user: {
70
- md: _User2 || (_User2 = /*#__PURE__*/React__default.createElement(User, {
71
- size: 32
72
- }))
73
- },
74
- group: {
75
- md: _Group || (_Group = /*#__PURE__*/React__default.createElement(Group, {
76
- size: 32
77
- }))
62
+ var iconSize = {
63
+ sm: 16,
64
+ md: 20,
65
+ lg: 24,
66
+ xl: 32
67
+ };
68
+ var formatInitials = function formatInitials() {
69
+ var _ref2;
70
+ var parts = name.split(' ');
71
+ var firstChar = parts[0].charAt(0).toUpperCase();
72
+ var secondChar = parts[0].charAt(1).toUpperCase();
73
+ if (parts.length === 1) {
74
+ return firstChar + secondChar;
75
+ }
76
+ var lastChar = parts[parts.length - 1].charAt(0).toUpperCase();
77
+ var initials = [firstChar];
78
+ if (lastChar) {
79
+ initials.push(lastChar);
78
80
  }
81
+ return (_ref2 = '').concat.apply(_ref2, initials);
79
82
  };
80
- var getItem = function getItem(renderIcon) {
81
- if (renderIcon === User) {
82
- return icons.user['md'];
83
- } else if (renderIcon === Group) {
84
- return icons.group['md'];
85
- } else {
86
- return renderIcon;
83
+ var getItem = function getItem() {
84
+ var iconProps = {
85
+ size: iconSize[size]
86
+ };
87
+ if (RenderIcon) {
88
+ return /*#__PURE__*/React__default.createElement(RenderIcon, iconProps);
87
89
  }
90
+ if (name) {
91
+ return formatInitials();
92
+ }
93
+ return /*#__PURE__*/React__default.createElement(User, iconProps);
88
94
  };
89
- var SetItem = getItem(renderIcon);
90
- var renderUserAvatar = function renderUserAvatar() {
95
+ var Avatar = function Avatar() {
91
96
  return /*#__PURE__*/React__default.createElement("div", _extends({}, rest, {
92
- tabIndex: 0,
93
97
  className: cx(blockClass,
94
98
  // Apply the block class to the main HTML element
95
99
  className, // Apply any supplied class names to the main HTML element.
96
- "".concat(blockClass, "--").concat(backgroundColor),
100
+ "".concat(blockClass, "--").concat(backgroundColor), "".concat(blockClass, "--").concat(size),
97
101
  // example: `${blockClass}__template-string-class-${kind}-n-${size}`,
98
102
  {
99
103
  // switched classes dependant on props or state
100
104
  // example: [`${blockClass}__here-if-small`]: size === 'sm',
101
105
  }),
102
106
  ref: ref,
103
- role: "button"
104
- }, getDevtoolsProps(componentName)), _SetItem || (_SetItem = /*#__PURE__*/React__default.createElement(SetItem, null)));
107
+ role: "img"
108
+ }, getDevtoolsProps(componentName)), getItem());
105
109
  };
106
- return SetItem && (tooltipText ? /*#__PURE__*/React__default.createElement(Tooltip, {
107
- align: tooltipAlignment,
108
- label: tooltipText,
109
- className: "".concat(blockClass, "__tooltip ").concat(carbonPrefix, "--icon-tooltip")
110
- }, /*#__PURE__*/React__default.createElement(TooltipTrigger, null, renderUserAvatar())) : renderUserAvatar());
110
+ if (tooltipText) {
111
+ return /*#__PURE__*/React__default.createElement(Tooltip, {
112
+ align: tooltipAlignment,
113
+ label: tooltipText,
114
+ className: "".concat(blockClass, "__tooltip ").concat(carbonPrefix, "--icon-tooltip")
115
+ }, /*#__PURE__*/React__default.createElement(TooltipTrigger, null, /*#__PURE__*/React__default.createElement(Avatar, null)));
116
+ }
117
+ return /*#__PURE__*/React__default.createElement(Avatar, null);
111
118
  });
112
119
 
113
120
  // Return a placeholder if not released and not enabled by feature flag
@@ -129,10 +136,18 @@ UserAvatar.propTypes = {
129
136
  * Provide an optional class to be applied to the containing node.
130
137
  */
131
138
  className: PropTypes.string,
139
+ /**
140
+ * When passing the name prop, either send the initials to be used or the user's full name. The first two capital letters of the user's name will be used as the name.
141
+ */
142
+ name: PropTypes.string,
132
143
  /**
133
144
  * Provide a custom icon to use if you need to use an icon other than the default one
134
145
  */
135
- renderIcon: PropTypes.func,
146
+ renderIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
147
+ /**
148
+ * Set the size of the avatar circle
149
+ */
150
+ size: PropTypes.oneOf(['xl', 'lg', 'md', 'sm']),
136
151
  /**
137
152
  * Specify how the trigger should align with the tooltip
138
153
  */
@@ -34,6 +34,7 @@ export { CoachmarkOverlayElement } from "./CoachmarkOverlayElement";
34
34
  export { CoachmarkOverlayElements } from "./CoachmarkOverlayElements";
35
35
  export { CoachmarkStack } from "./CoachmarkStack";
36
36
  export { NonLinearReading } from "./NonLinearReading";
37
+ export { BigNumbers } from "./BigNumbers";
37
38
  export { TruncatedList } from "./TruncatedList";
38
39
  export { InterstitialScreen } from "./InterstitialScreen";
39
40
  export { InterstitialScreenView } from "./InterstitialScreenView";
@@ -41,6 +42,7 @@ export { InterstitialScreenViewModule } from "./InterstitialScreenViewModule";
41
42
  export { DelimitedList } from "./DelimitedList";
42
43
  export { FullPageError } from "./FullPageError";
43
44
  export { SearchBar } from "./SearchBar";
45
+ export { StringFormatter } from "./StringFormatter";
44
46
  export { UserAvatar } from "./UserAvatar";
45
47
  export { ComboButton, ComboButtonItem } from "./ComboButton";
46
48
  export { CreateFullPage, CreateFullPageStep } from "./CreateFullPage";
@@ -9,4 +9,6 @@ export { useRetrieveStepData } from "./useRetrieveStepData";
9
9
  export { useValidCreateStepCount } from "./useValidCreateStepCount";
10
10
  export { useControllableState } from "./useControllableState";
11
11
  export { usePrefix } from "./usePrefix";
12
+ export { useFocus } from "./useFocus";
13
+ export { useIsomorphicEffect } from "./useIsomorphicEffect";
12
14
  export { useNearestScroll, useWindowScroll } from "./useWindowScroll";
@@ -0,0 +1,11 @@
1
+ export function useFocus(modalRef: any): {
2
+ firstElement: any;
3
+ lastElement: any;
4
+ allElements: any;
5
+ keyDownListener: (event: any) => void;
6
+ getFocusable: () => {
7
+ first: any;
8
+ last: any;
9
+ all: any;
10
+ };
11
+ };