@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.
- package/css/index-full-carbon.css +556 -63
- package/css/index-full-carbon.css.map +1 -1
- package/css/index-full-carbon.min.css +1 -1
- package/css/index-full-carbon.min.css.map +1 -1
- package/css/index-without-carbon-released-only.css +50 -16
- package/css/index-without-carbon-released-only.css.map +1 -1
- package/css/index-without-carbon-released-only.min.css +1 -1
- package/css/index-without-carbon-released-only.min.css.map +1 -1
- package/css/index-without-carbon.css +556 -63
- package/css/index-without-carbon.css.map +1 -1
- package/css/index-without-carbon.min.css +1 -1
- package/css/index-without-carbon.min.css.map +1 -1
- package/css/index.css +527 -55
- package/css/index.css.map +1 -1
- package/css/index.min.css +1 -1
- package/css/index.min.css.map +1 -1
- package/es/components/BigNumbers/BigNumbers.d.ts +11 -0
- package/es/components/BigNumbers/BigNumbers.js +238 -0
- package/es/components/BigNumbers/constants.d.ts +13 -0
- package/es/components/BigNumbers/constants.js +67 -0
- package/es/components/BigNumbers/index.d.ts +1 -0
- package/es/components/Cascade/Cascade.d.ts +19 -2
- package/es/components/Cascade/Cascade.js +12 -9
- package/es/components/Coachmark/CoachmarkTagline.js +1 -2
- package/es/components/CoachmarkStack/CoachmarkStackHome.js +1 -1
- package/es/components/DataSpreadsheet/DataSpreadsheetBody.js +4 -3
- package/es/components/DataSpreadsheet/DataSpreadsheetHeader.js +3 -2
- package/es/components/DataSpreadsheet/utils/checkForHoldingKey.d.ts +1 -0
- package/es/components/DataSpreadsheet/utils/checkForHoldingKey.js +17 -0
- package/es/components/Datagrid/Datagrid/Datagrid.js +9 -2
- package/es/components/Datagrid/Datagrid/DatagridContent.d.ts +3 -1
- package/es/components/Datagrid/Datagrid/DatagridContent.js +6 -2
- package/es/components/Datagrid/Datagrid/DatagridHeaderRow.js +21 -8
- package/es/components/Datagrid/Datagrid/DatagridRow.js +15 -2
- package/es/components/Datagrid/Datagrid/DatagridToolbar.d.ts +10 -1
- package/es/components/Datagrid/Datagrid/DatagridToolbar.js +21 -4
- package/es/components/Datagrid/Datagrid/addons/Filtering/FilterProvider.js +32 -9
- package/es/components/Datagrid/Datagrid/addons/Filtering/constants.d.ts +3 -1
- package/es/components/Datagrid/Datagrid/addons/Filtering/constants.js +4 -1
- package/es/components/Datagrid/Datagrid/addons/Filtering/hooks/useFilters.js +35 -3
- package/es/components/Datagrid/Datagrid/addons/Slug/DatagridSlug.d.ts +2 -0
- package/es/components/Datagrid/Datagrid/addons/Slug/{ColumnHeaderSlug.js → DatagridSlug.js} +4 -4
- package/es/components/Datagrid/Datagrid/addons/stateReducer.js +3 -3
- package/es/components/Datagrid/useSelectAllToggle.js +5 -3
- package/es/components/Datagrid/useSortableColumns.js +2 -2
- package/es/components/EmptyStates/EmptyStateContent.d.ts +1 -1
- package/es/components/FullPageError/FullPageError.js +41 -15
- package/es/components/FullPageError/assets/Error403SVG.d.ts +9 -0
- package/es/components/FullPageError/assets/Error403SVG.js +714 -0
- package/es/components/FullPageError/assets/Error404SVG.d.ts +9 -0
- package/es/components/FullPageError/assets/Error404SVG.js +623 -0
- package/es/components/HTTPErrors/HTTPErrorContent.d.ts +1 -1
- package/es/components/InterstitialScreen/InterstitialScreen.js +1 -1
- package/es/components/SidePanel/SidePanel.js +13 -6
- package/es/components/SidePanel/motion/variants.d.ts +39 -12
- package/es/components/SidePanel/motion/variants.js +42 -11
- package/es/components/StringFormatter/StringFormatter.d.ts +6 -0
- package/es/components/StringFormatter/StringFormatter.js +79 -0
- package/es/components/StringFormatter/index.d.ts +1 -0
- package/es/components/StringFormatter/utils/enums.d.ts +14 -0
- package/es/components/StringFormatter/utils/enums.js +23 -0
- package/es/components/Tearsheet/TearsheetShell.js +26 -8
- package/es/components/UserAvatar/UserAvatar.js +59 -44
- package/es/components/index.d.ts +2 -0
- package/es/global/js/hooks/index.d.ts +2 -0
- package/es/global/js/hooks/useFocus.d.ts +11 -0
- package/es/global/js/hooks/useFocus.js +76 -0
- package/es/global/js/hooks/useIsomorphicEffect.d.ts +2 -0
- package/es/global/js/hooks/useIsomorphicEffect.js +14 -0
- package/es/global/js/package-settings.d.ts +2 -0
- package/es/global/js/package-settings.js +2 -0
- package/es/index.js +2 -0
- package/es/settings.d.ts +2 -0
- package/lib/components/BigNumbers/BigNumbers.d.ts +11 -0
- package/lib/components/BigNumbers/BigNumbers.js +244 -0
- package/lib/components/BigNumbers/constants.d.ts +13 -0
- package/lib/components/BigNumbers/constants.js +76 -0
- package/lib/components/BigNumbers/index.d.ts +1 -0
- package/lib/components/Cascade/Cascade.d.ts +19 -2
- package/lib/components/Cascade/Cascade.js +12 -9
- package/lib/components/Coachmark/CoachmarkTagline.js +3 -4
- package/lib/components/CoachmarkStack/CoachmarkStackHome.js +2 -2
- package/lib/components/DataSpreadsheet/DataSpreadsheetBody.js +4 -3
- package/lib/components/DataSpreadsheet/DataSpreadsheetHeader.js +3 -2
- package/lib/components/DataSpreadsheet/utils/checkForHoldingKey.d.ts +1 -0
- package/lib/components/DataSpreadsheet/utils/checkForHoldingKey.js +21 -0
- package/lib/components/Datagrid/Datagrid/Datagrid.js +9 -2
- package/lib/components/Datagrid/Datagrid/DatagridContent.d.ts +3 -1
- package/lib/components/Datagrid/Datagrid/DatagridContent.js +6 -2
- package/lib/components/Datagrid/Datagrid/DatagridHeaderRow.js +20 -7
- package/lib/components/Datagrid/Datagrid/DatagridRow.js +14 -1
- package/lib/components/Datagrid/Datagrid/DatagridToolbar.d.ts +10 -1
- package/lib/components/Datagrid/Datagrid/DatagridToolbar.js +20 -3
- package/lib/components/Datagrid/Datagrid/addons/Filtering/FilterProvider.js +30 -7
- package/lib/components/Datagrid/Datagrid/addons/Filtering/constants.d.ts +3 -1
- package/lib/components/Datagrid/Datagrid/addons/Filtering/constants.js +4 -0
- package/lib/components/Datagrid/Datagrid/addons/Filtering/hooks/useFilters.js +33 -1
- package/lib/components/Datagrid/Datagrid/addons/Slug/DatagridSlug.d.ts +2 -0
- package/lib/components/Datagrid/Datagrid/addons/Slug/{ColumnHeaderSlug.js → DatagridSlug.js} +4 -4
- package/lib/components/Datagrid/Datagrid/addons/stateReducer.js +3 -3
- package/lib/components/Datagrid/useSelectAllToggle.js +4 -2
- package/lib/components/Datagrid/useSortableColumns.js +2 -2
- package/lib/components/EmptyStates/EmptyStateContent.d.ts +1 -1
- package/lib/components/FullPageError/FullPageError.js +41 -15
- package/lib/components/FullPageError/assets/Error403SVG.d.ts +9 -0
- package/lib/components/FullPageError/assets/Error403SVG.js +722 -0
- package/lib/components/FullPageError/assets/Error404SVG.d.ts +9 -0
- package/lib/components/FullPageError/assets/Error404SVG.js +631 -0
- package/lib/components/HTTPErrors/HTTPErrorContent.d.ts +1 -1
- package/lib/components/InterstitialScreen/InterstitialScreen.js +3 -3
- package/lib/components/SidePanel/SidePanel.js +11 -4
- package/lib/components/SidePanel/motion/variants.d.ts +39 -12
- package/lib/components/SidePanel/motion/variants.js +42 -10
- package/lib/components/StringFormatter/StringFormatter.d.ts +6 -0
- package/lib/components/StringFormatter/StringFormatter.js +85 -0
- package/lib/components/StringFormatter/index.d.ts +1 -0
- package/lib/components/StringFormatter/utils/enums.d.ts +14 -0
- package/lib/components/StringFormatter/utils/enums.js +27 -0
- package/lib/components/Tearsheet/TearsheetShell.js +26 -8
- package/lib/components/UserAvatar/UserAvatar.js +59 -44
- package/lib/components/index.d.ts +2 -0
- package/lib/global/js/hooks/index.d.ts +2 -0
- package/lib/global/js/hooks/useFocus.d.ts +11 -0
- package/lib/global/js/hooks/useFocus.js +80 -0
- package/lib/global/js/hooks/useIsomorphicEffect.d.ts +2 -0
- package/lib/global/js/hooks/useIsomorphicEffect.js +18 -0
- package/lib/global/js/package-settings.d.ts +2 -0
- package/lib/global/js/package-settings.js +2 -0
- package/lib/index.js +10 -0
- package/lib/settings.d.ts +2 -0
- package/package.json +7 -7
- package/scss/components/BigNumbers/_big-numbers.scss +151 -0
- package/scss/components/BigNumbers/_carbon-imports.scss +11 -0
- package/scss/components/BigNumbers/_index-with-carbon.scss +9 -0
- package/scss/components/BigNumbers/_index.scss +8 -0
- package/scss/components/Datagrid/styles/_datagrid.scss +19 -0
- package/scss/components/FilterSummary/_filter-summary.scss +1 -1
- package/scss/components/FullPageError/_full-page-error.scss +20 -2
- package/scss/components/ProductiveCard/_productive-card.scss +1 -1
- package/scss/components/SidePanel/_side-panel.scss +1 -1
- package/scss/components/StringFormatter/_carbon-imports.scss +10 -0
- package/scss/components/StringFormatter/_index-with-carbon.scss +9 -0
- package/scss/components/StringFormatter/_index.scss +8 -0
- package/scss/components/StringFormatter/_string-formatter.scss +97 -0
- package/scss/components/Tearsheet/_tearsheet.scss +34 -2
- package/scss/components/UserAvatar/_user-avatar.scss +47 -4
- package/scss/components/_index-with-carbon.scss +2 -0
- package/scss/components/_index.scss +2 -0
- package/es/components/Datagrid/Datagrid/addons/Slug/ColumnHeaderSlug.d.ts +0 -2
- package/es/node_modules/@carbon/icon-helpers/es/index.js +0 -140
- package/es/node_modules/@carbon/icons-react/es/Icon.js +0 -73
- package/es/node_modules/@carbon/icons-react/es/generated/bucket-0.js +0 -2985
- package/es/node_modules/@carbon/icons-react/es/generated/bucket-3.js +0 -2900
- package/es/node_modules/@carbon/icons-react/es/generated/bucket-8.js +0 -3004
- package/es/node_modules/@carbon/icons-react/es/iconPropTypes-4cbeb95d.js +0 -14
- package/lib/components/Datagrid/Datagrid/addons/Slug/ColumnHeaderSlug.d.ts +0 -2
- package/lib/node_modules/@carbon/icon-helpers/es/index.js +0 -145
- package/lib/node_modules/@carbon/icons-react/es/Icon.js +0 -81
- package/lib/node_modules/@carbon/icons-react/es/generated/bucket-0.js +0 -3117
- package/lib/node_modules/@carbon/icons-react/es/generated/bucket-3.js +0 -3032
- package/lib/node_modules/@carbon/icons-react/es/generated/bucket-8.js +0 -3136
- 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 {
|
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:
|
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(
|
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
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
}
|
27
|
-
|
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
|
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
|
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
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
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(
|
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(
|
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", "
|
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
|
-
|
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
|
-
|
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
|
-
|
49
|
-
|
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
|
-
|
61
|
-
|
62
|
-
_ref$
|
63
|
-
|
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
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
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(
|
81
|
-
|
82
|
-
|
83
|
-
}
|
84
|
-
|
85
|
-
|
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
|
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: "
|
104
|
-
}, getDevtoolsProps(componentName)),
|
107
|
+
role: "img"
|
108
|
+
}, getDevtoolsProps(componentName)), getItem());
|
105
109
|
};
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
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
|
*/
|
package/es/components/index.d.ts
CHANGED
@@ -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";
|