@carbon/ibm-products 2.54.0-canary.71 → 2.54.0-canary.74
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.
- package/css/index-full-carbon.css +13 -5
- 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 +13 -5
- 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 +13 -5
- 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 +13 -5
- 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/CoachmarkOverlayElements/CoachmarkOverlayElements.d.ts +12 -0
- package/es/components/CoachmarkOverlayElements/CoachmarkOverlayElements.js +39 -8
- package/es/components/PageHeader/PageHeader.js +13 -3
- package/es/components/PageHeader/PageHeaderTitle.js +10 -29
- package/es/global/js/utils/checkForOverflow.d.ts +5 -0
- package/es/global/js/utils/checkForOverflow.js +31 -0
- package/lib/components/CoachmarkOverlayElements/CoachmarkOverlayElements.d.ts +12 -0
- package/lib/components/CoachmarkOverlayElements/CoachmarkOverlayElements.js +39 -8
- package/lib/components/PageHeader/PageHeader.js +12 -2
- package/lib/components/PageHeader/PageHeaderTitle.js +8 -27
- package/lib/global/js/utils/checkForOverflow.d.ts +5 -0
- package/lib/global/js/utils/checkForOverflow.js +34 -0
- package/package.json +3 -3
- package/scss/components/PageHeader/_page-header.scss +18 -6
@@ -20,7 +20,7 @@ import { pkg } from '../../settings.js';
|
|
20
20
|
import '../Coachmark/Coachmark.js';
|
21
21
|
import { useCoachmark } from '../Coachmark/utils/context.js';
|
22
22
|
|
23
|
-
var _excluded = ["className", "children", "isVisible", "media", "renderMedia", "nextButtonText", "previousButtonLabel", "closeButtonLabel"];
|
23
|
+
var _excluded = ["className", "children", "isVisible", "media", "renderMedia", "currentStep", "nextButtonText", "previousButtonLabel", "closeButtonLabel", "onNext", "onBack"];
|
24
24
|
|
25
25
|
// The block part of our conventional BEM class names (blockClass__E--M).
|
26
26
|
var blockClass = "".concat(pkg.prefix, "--coachmark-overlay-elements");
|
@@ -41,7 +41,10 @@ var defaults = {
|
|
41
41
|
isVisible: false,
|
42
42
|
nextButtonText: 'Next',
|
43
43
|
previousButtonLabel: 'Back',
|
44
|
-
closeButtonLabel: 'Got it'
|
44
|
+
closeButtonLabel: 'Got it',
|
45
|
+
onNext: undefined,
|
46
|
+
onBack: undefined,
|
47
|
+
currentStep: 0
|
45
48
|
};
|
46
49
|
/**
|
47
50
|
* Composable container to allow for the displaying of CoachmarkOverlayElement
|
@@ -54,12 +57,18 @@ var CoachmarkOverlayElements = /*#__PURE__*/React__default.forwardRef(function (
|
|
54
57
|
isVisible = _ref$isVisible === void 0 ? defaults.isVisible : _ref$isVisible,
|
55
58
|
media = _ref.media,
|
56
59
|
renderMedia = _ref.renderMedia,
|
60
|
+
_ref$currentStep = _ref.currentStep,
|
61
|
+
currentStep = _ref$currentStep === void 0 ? defaults.currentStep : _ref$currentStep,
|
57
62
|
_ref$nextButtonText = _ref.nextButtonText,
|
58
63
|
nextButtonText = _ref$nextButtonText === void 0 ? defaults.nextButtonText : _ref$nextButtonText,
|
59
64
|
_ref$previousButtonLa = _ref.previousButtonLabel,
|
60
65
|
previousButtonLabel = _ref$previousButtonLa === void 0 ? defaults.previousButtonLabel : _ref$previousButtonLa,
|
61
66
|
_ref$closeButtonLabel = _ref.closeButtonLabel,
|
62
67
|
closeButtonLabel = _ref$closeButtonLabel === void 0 ? defaults.closeButtonLabel : _ref$closeButtonLabel,
|
68
|
+
_ref$onNext = _ref.onNext,
|
69
|
+
onNext = _ref$onNext === void 0 ? defaults.onNext : _ref$onNext,
|
70
|
+
_ref$onBack = _ref.onBack,
|
71
|
+
onBack = _ref$onBack === void 0 ? defaults.onBack : _ref$onBack,
|
63
72
|
rest = _objectWithoutProperties(_ref, _excluded);
|
64
73
|
var buttonFocusRef = useRef(undefined);
|
65
74
|
var scrollRef = useRef(undefined);
|
@@ -67,7 +76,7 @@ var CoachmarkOverlayElements = /*#__PURE__*/React__default.forwardRef(function (
|
|
67
76
|
_useState2 = _slicedToArray(_useState, 2),
|
68
77
|
scrollPosition = _useState2[0],
|
69
78
|
setScrollPosition = _useState2[1];
|
70
|
-
var _useState3 = useState(
|
79
|
+
var _useState3 = useState(currentStep),
|
71
80
|
_useState4 = _slicedToArray(_useState3, 2),
|
72
81
|
currentProgStep = _useState4[0],
|
73
82
|
_setCurrentProgStep = _useState4[1];
|
@@ -90,6 +99,15 @@ var CoachmarkOverlayElements = /*#__PURE__*/React__default.forwardRef(function (
|
|
90
99
|
playStep: currentProgStep
|
91
100
|
});
|
92
101
|
}, [currentProgStep, renderMedia]);
|
102
|
+
useEffect(function () {
|
103
|
+
var _scrollRef$current, _scrollRef$current$sc;
|
104
|
+
// When current step is set by props
|
105
|
+
// scroll to the appropriate view on the carrousel
|
106
|
+
var targetStep = clamp(currentStep, progStepFloor, progStepCeil);
|
107
|
+
scrollRef === null || scrollRef === void 0 || (_scrollRef$current = scrollRef.current) === null || _scrollRef$current === void 0 || (_scrollRef$current$sc = _scrollRef$current.scrollToView) === null || _scrollRef$current$sc === void 0 || _scrollRef$current$sc.call(_scrollRef$current, targetStep);
|
108
|
+
// Avoid circular call to this hook
|
109
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
110
|
+
}, [currentStep]);
|
93
111
|
useEffect(function () {
|
94
112
|
// On mount, one of the two primary buttons ("next" or "close")
|
95
113
|
// will be rendered and must have focus. (a11y)
|
@@ -131,7 +149,6 @@ var CoachmarkOverlayElements = /*#__PURE__*/React__default.forwardRef(function (
|
|
131
149
|
}, coachmark.closeButtonProps, {
|
132
150
|
ref: buttonFocusRef
|
133
151
|
}), closeButtonLabel))) : /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Carousel, {
|
134
|
-
disableArrowScroll: true,
|
135
152
|
ref: scrollRef,
|
136
153
|
onScroll: function onScroll(scrollPercent) {
|
137
154
|
setScrollPosition(scrollPercent);
|
@@ -146,10 +163,11 @@ var CoachmarkOverlayElements = /*#__PURE__*/React__default.forwardRef(function (
|
|
146
163
|
title: previousButtonLabel,
|
147
164
|
disabled: scrollPosition === 0,
|
148
165
|
onClick: function onClick() {
|
149
|
-
var _scrollRef$
|
166
|
+
var _scrollRef$current2, _scrollRef$current2$s;
|
150
167
|
var targetStep = clamp(currentProgStep - 1, progStepFloor, progStepCeil);
|
151
|
-
scrollRef === null || scrollRef === void 0 || (_scrollRef$
|
168
|
+
scrollRef === null || scrollRef === void 0 || (_scrollRef$current2 = scrollRef.current) === null || _scrollRef$current2 === void 0 || (_scrollRef$current2$s = _scrollRef$current2.scrollToView) === null || _scrollRef$current2$s === void 0 || _scrollRef$current2$s.call(_scrollRef$current2, targetStep);
|
152
169
|
setCurrentProgStep(targetStep);
|
170
|
+
onBack === null || onBack === void 0 || onBack();
|
153
171
|
}
|
154
172
|
}, previousButtonLabel), currentProgStep < progStepCeil ? /*#__PURE__*/React__default.createElement(Button, {
|
155
173
|
size: "sm",
|
@@ -157,10 +175,11 @@ var CoachmarkOverlayElements = /*#__PURE__*/React__default.forwardRef(function (
|
|
157
175
|
title: nextButtonText,
|
158
176
|
disabled: scrollPosition === 1,
|
159
177
|
onClick: function onClick() {
|
160
|
-
var _scrollRef$
|
178
|
+
var _scrollRef$current3, _scrollRef$current3$s;
|
161
179
|
var targetStep = clamp(currentProgStep + 1, progStepFloor, progStepCeil);
|
162
|
-
scrollRef === null || scrollRef === void 0 || (_scrollRef$
|
180
|
+
scrollRef === null || scrollRef === void 0 || (_scrollRef$current3 = scrollRef.current) === null || _scrollRef$current3 === void 0 || (_scrollRef$current3$s = _scrollRef$current3.scrollToView) === null || _scrollRef$current3$s === void 0 || _scrollRef$current3$s.call(_scrollRef$current3, targetStep);
|
163
181
|
setCurrentProgStep(targetStep);
|
182
|
+
onNext === null || onNext === void 0 || onNext();
|
164
183
|
}
|
165
184
|
}, nextButtonText) : closeButtonLabel && /*#__PURE__*/React__default.createElement(Button, _extends({
|
166
185
|
size: "sm",
|
@@ -194,6 +213,10 @@ CoachmarkOverlayElements.propTypes = {
|
|
194
213
|
* The label for the Close button.
|
195
214
|
*/
|
196
215
|
closeButtonLabel: PropTypes.string,
|
216
|
+
/**
|
217
|
+
* Current step of the coachmarks
|
218
|
+
*/
|
219
|
+
currentStep: PropTypes.number,
|
197
220
|
/**
|
198
221
|
* The visibility of CoachmarkOverlayElements is
|
199
222
|
* managed in the parent component.
|
@@ -215,6 +238,14 @@ CoachmarkOverlayElements.propTypes = {
|
|
215
238
|
* The label for the Next button.
|
216
239
|
*/
|
217
240
|
nextButtonText: PropTypes.string,
|
241
|
+
/**
|
242
|
+
* Optional callback called when clicking on the Previous button.
|
243
|
+
*/
|
244
|
+
onBack: PropTypes.func,
|
245
|
+
/**
|
246
|
+
* Optional callback called when clicking on the Next button.
|
247
|
+
*/
|
248
|
+
onNext: PropTypes.func,
|
218
249
|
/**
|
219
250
|
* The label for the Previous button.
|
220
251
|
*/
|
@@ -6,7 +6,7 @@
|
|
6
6
|
*/
|
7
7
|
|
8
8
|
import { objectSpread2 as _objectSpread2, objectWithoutProperties as _objectWithoutProperties, slicedToArray as _slicedToArray, defineProperty as _defineProperty, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
9
|
-
import { Button, Tooltip, Tag, usePrefix, FlexGrid, Row, Column } from '@carbon/react';
|
9
|
+
import { Button, Tooltip, Tag, usePrefix, FlexGrid, Row, Column, DefinitionTooltip } from '@carbon/react';
|
10
10
|
import React__default, { useState, useRef, useEffect } from 'react';
|
11
11
|
import { string_required_if_more_than_10_tags, TagSet } from '../TagSet/TagSet.js';
|
12
12
|
import { spacing, baseFontSize, breakpoints } from '@carbon/layout';
|
@@ -19,6 +19,7 @@ import cx from 'classnames';
|
|
19
19
|
import { getDevtoolsProps } from '../../global/js/utils/devtools.js';
|
20
20
|
import { pkg } from '../../settings.js';
|
21
21
|
import { useResizeObserver } from '../../global/js/hooks/useResizeObserver.js';
|
22
|
+
import { checkHeightOverflow } from '../../global/js/utils/checkForOverflow.js';
|
22
23
|
import { useNearestScroll } from '../../global/js/hooks/useWindowScroll.js';
|
23
24
|
import { useWindowResize } from '../../global/js/hooks/useWindowResize.js';
|
24
25
|
import { BreadcrumbWithOverflow } from '../BreadcrumbWithOverflow/BreadcrumbWithOverflow.js';
|
@@ -361,6 +362,12 @@ var PageHeader = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
|
|
361
362
|
}
|
362
363
|
};
|
363
364
|
var displayedBreadcrumbs = getBreadcrumbs();
|
365
|
+
var subtitleRef = useRef(null);
|
366
|
+
var isOverflowing = checkHeightOverflow(subtitleRef.current);
|
367
|
+
var subtitleContent = /*#__PURE__*/React__default.createElement("span", {
|
368
|
+
ref: subtitleRef,
|
369
|
+
className: "".concat(blockClass, "__subtitle-text")
|
370
|
+
}, subtitle);
|
364
371
|
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("div", {
|
365
372
|
className: "".concat(blockClass, "--offset-top-measuring-element"),
|
366
373
|
ref: offsetTopMeasuringRef
|
@@ -412,11 +419,14 @@ var PageHeader = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
|
|
412
419
|
blockClass: blockClass,
|
413
420
|
hasBreadcrumbRow: hasBreadcrumbRow,
|
414
421
|
title: title
|
415
|
-
}) : null), thePageActions(false, pageActionsInBreadcrumbRow)) : null, subtitle
|
422
|
+
}) : null), thePageActions(false, pageActionsInBreadcrumbRow)) : null, subtitle && /*#__PURE__*/React__default.createElement(Row, {
|
416
423
|
className: "".concat(blockClass, "__subtitle-row")
|
417
424
|
}, /*#__PURE__*/React__default.createElement(Column, {
|
418
425
|
className: "".concat(blockClass, "__subtitle")
|
419
|
-
},
|
426
|
+
}, isOverflowing ? /*#__PURE__*/React__default.createElement(DefinitionTooltip, {
|
427
|
+
definition: subtitle,
|
428
|
+
className: "".concat(blockClass, "__subtitle-tooltip")
|
429
|
+
}, subtitleContent) : subtitleContent)), children ? /*#__PURE__*/React__default.createElement(Row, {
|
420
430
|
className: "".concat(blockClass, "__available-row")
|
421
431
|
}, /*#__PURE__*/React__default.createElement(Column, {
|
422
432
|
className: "".concat(blockClass, "__available-column")
|
@@ -5,12 +5,13 @@
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
6
6
|
*/
|
7
7
|
|
8
|
-
import { objectWithoutProperties as _objectWithoutProperties,
|
9
|
-
import React__default, {
|
8
|
+
import { objectWithoutProperties as _objectWithoutProperties, extends as _extends, defineProperty as _defineProperty } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
9
|
+
import React__default, { useRef } from 'react';
|
10
10
|
import PropTypes from '../../_virtual/index.js';
|
11
11
|
import cx from 'classnames';
|
12
12
|
import { SkeletonText, DefinitionTooltip } from '@carbon/react';
|
13
13
|
import { EditInPlace } from '../EditInPlace/EditInPlace.js';
|
14
|
+
import { checkWidthOverflow } from '../../global/js/utils/checkForOverflow.js';
|
14
15
|
|
15
16
|
var _excluded = ["text", "content", "loading", "icon", "asText", "onChange", "onSave", "editDescription", "editableLabel", "cancelDescription", "saveDescription", "tooltipAlignment"];
|
16
17
|
|
@@ -43,31 +44,18 @@ var PageHeaderTitle = function PageHeaderTitle(_ref) {
|
|
43
44
|
rest = _objectWithoutProperties(title, _excluded);
|
44
45
|
var titleText;
|
45
46
|
var isEditable = !!onSave;
|
46
|
-
var
|
47
|
-
|
48
|
-
isEllipsisApplied = _useState2[0],
|
49
|
-
setIsEllipsisApplied = _useState2[1];
|
50
|
-
var longTitleRef = useRef(undefined);
|
51
|
-
var titleRef = useRef(undefined);
|
52
|
-
useLayoutEffect(function () {
|
53
|
-
setIsEllipsisApplied(isEllipsisActive());
|
54
|
-
}, [longTitleRef, titleRef, title]);
|
55
|
-
var isEllipsisActive = function isEllipsisActive() {
|
56
|
-
if (longTitleRef.current) {
|
57
|
-
var _longTitleRef$current, _longTitleRef$current2;
|
58
|
-
return ((_longTitleRef$current = longTitleRef.current) === null || _longTitleRef$current === void 0 ? void 0 : _longTitleRef$current.offsetWidth) < ((_longTitleRef$current2 = longTitleRef.current) === null || _longTitleRef$current2 === void 0 ? void 0 : _longTitleRef$current2.scrollWidth);
|
59
|
-
} else if (titleRef.current) {
|
60
|
-
var _titleRef$current, _titleRef$current2;
|
61
|
-
return ((_titleRef$current = titleRef.current) === null || _titleRef$current === void 0 ? void 0 : _titleRef$current.offsetWidth) < ((_titleRef$current2 = titleRef.current) === null || _titleRef$current2 === void 0 ? void 0 : _titleRef$current2.scrollWidth);
|
62
|
-
}
|
63
|
-
return false;
|
64
|
-
};
|
47
|
+
var titleRef = useRef();
|
48
|
+
var isEllipsisApplied = checkWidthOverflow(titleRef.current);
|
65
49
|
if (text || !content) {
|
66
50
|
if (text === undefined && typeof title === 'string') {
|
67
51
|
text = title;
|
68
52
|
asText = title;
|
69
53
|
}
|
70
54
|
var TitleIcon = icon;
|
55
|
+
var titleContent = /*#__PURE__*/React__default.createElement("span", {
|
56
|
+
ref: titleRef,
|
57
|
+
className: "".concat(blockClass, "__titleText")
|
58
|
+
}, text);
|
71
59
|
titleInnards = /*#__PURE__*/React__default.createElement(React__default.Fragment, null, icon && !loading ? /*#__PURE__*/React__default.createElement("span", {
|
72
60
|
className: "".concat(blockClass, "__title-icon-wrapper")
|
73
61
|
}, /*#__PURE__*/React__default.createElement(TitleIcon, {
|
@@ -90,14 +78,7 @@ var PageHeaderTitle = function PageHeaderTitle(_ref) {
|
|
90
78
|
align: tooltipAlignment,
|
91
79
|
definition: text,
|
92
80
|
className: "".concat(blockClass, "__tooltip")
|
93
|
-
},
|
94
|
-
ref: longTitleRef,
|
95
|
-
className: "".concat(blockClass, "__titleText")
|
96
|
-
}, text)) : /*#__PURE__*/React__default.createElement("span", {
|
97
|
-
ref: titleRef,
|
98
|
-
className: "".concat(blockClass, "__titleText"),
|
99
|
-
title: !loading ? asText : null
|
100
|
-
}, text));
|
81
|
+
}, titleContent) : titleContent);
|
101
82
|
} else {
|
102
83
|
titleInnards = content;
|
103
84
|
titleText = asText;
|
@@ -0,0 +1,31 @@
|
|
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
|
+
// Copyright IBM Corp. 2024, 2024
|
9
|
+
//
|
10
|
+
// This source code is licensed under the Apache-2.0 license found in the
|
11
|
+
// LICENSE file in the root directory of this source tree.
|
12
|
+
//
|
13
|
+
|
14
|
+
/**
|
15
|
+
* used to calculate if a element is overflowing the width or height of an area
|
16
|
+
*/
|
17
|
+
|
18
|
+
var checkWidthOverflow = function checkWidthOverflow(el) {
|
19
|
+
if (el) {
|
20
|
+
return (el === null || el === void 0 ? void 0 : el.offsetWidth) < (el === null || el === void 0 ? void 0 : el.scrollWidth);
|
21
|
+
}
|
22
|
+
return false;
|
23
|
+
};
|
24
|
+
var checkHeightOverflow = function checkHeightOverflow(el) {
|
25
|
+
if (el) {
|
26
|
+
return (el === null || el === void 0 ? void 0 : el.offsetHeight) < (el === null || el === void 0 ? void 0 : el.scrollHeight);
|
27
|
+
}
|
28
|
+
return false;
|
29
|
+
};
|
30
|
+
|
31
|
+
export { checkHeightOverflow, checkWidthOverflow };
|
@@ -46,6 +46,18 @@ export interface CoachmarkOverlayElementsProps {
|
|
46
46
|
* The label for the Close button.
|
47
47
|
*/
|
48
48
|
closeButtonLabel?: string;
|
49
|
+
/**
|
50
|
+
* Callback called when clicking on the Next button.
|
51
|
+
*/
|
52
|
+
onNext?: () => void;
|
53
|
+
/**
|
54
|
+
* Callback called when clicking on the Previous button.
|
55
|
+
*/
|
56
|
+
onBack?: () => void;
|
57
|
+
/**
|
58
|
+
* Current step of the coachmarks.
|
59
|
+
*/
|
60
|
+
currentStep?: number;
|
49
61
|
}
|
50
62
|
/**
|
51
63
|
* Composable container to allow for the displaying of CoachmarkOverlayElement
|
@@ -22,7 +22,7 @@ var settings = require('../../settings.js');
|
|
22
22
|
require('../Coachmark/Coachmark.js');
|
23
23
|
var context = require('../Coachmark/utils/context.js');
|
24
24
|
|
25
|
-
var _excluded = ["className", "children", "isVisible", "media", "renderMedia", "nextButtonText", "previousButtonLabel", "closeButtonLabel"];
|
25
|
+
var _excluded = ["className", "children", "isVisible", "media", "renderMedia", "currentStep", "nextButtonText", "previousButtonLabel", "closeButtonLabel", "onNext", "onBack"];
|
26
26
|
|
27
27
|
// The block part of our conventional BEM class names (blockClass__E--M).
|
28
28
|
var blockClass = "".concat(settings.pkg.prefix, "--coachmark-overlay-elements");
|
@@ -43,7 +43,10 @@ var defaults = {
|
|
43
43
|
isVisible: false,
|
44
44
|
nextButtonText: 'Next',
|
45
45
|
previousButtonLabel: 'Back',
|
46
|
-
closeButtonLabel: 'Got it'
|
46
|
+
closeButtonLabel: 'Got it',
|
47
|
+
onNext: undefined,
|
48
|
+
onBack: undefined,
|
49
|
+
currentStep: 0
|
47
50
|
};
|
48
51
|
/**
|
49
52
|
* Composable container to allow for the displaying of CoachmarkOverlayElement
|
@@ -56,12 +59,18 @@ exports.CoachmarkOverlayElements = /*#__PURE__*/React.forwardRef(function (_ref,
|
|
56
59
|
isVisible = _ref$isVisible === void 0 ? defaults.isVisible : _ref$isVisible,
|
57
60
|
media = _ref.media,
|
58
61
|
renderMedia = _ref.renderMedia,
|
62
|
+
_ref$currentStep = _ref.currentStep,
|
63
|
+
currentStep = _ref$currentStep === void 0 ? defaults.currentStep : _ref$currentStep,
|
59
64
|
_ref$nextButtonText = _ref.nextButtonText,
|
60
65
|
nextButtonText = _ref$nextButtonText === void 0 ? defaults.nextButtonText : _ref$nextButtonText,
|
61
66
|
_ref$previousButtonLa = _ref.previousButtonLabel,
|
62
67
|
previousButtonLabel = _ref$previousButtonLa === void 0 ? defaults.previousButtonLabel : _ref$previousButtonLa,
|
63
68
|
_ref$closeButtonLabel = _ref.closeButtonLabel,
|
64
69
|
closeButtonLabel = _ref$closeButtonLabel === void 0 ? defaults.closeButtonLabel : _ref$closeButtonLabel,
|
70
|
+
_ref$onNext = _ref.onNext,
|
71
|
+
onNext = _ref$onNext === void 0 ? defaults.onNext : _ref$onNext,
|
72
|
+
_ref$onBack = _ref.onBack,
|
73
|
+
onBack = _ref$onBack === void 0 ? defaults.onBack : _ref$onBack,
|
65
74
|
rest = _rollupPluginBabelHelpers.objectWithoutProperties(_ref, _excluded);
|
66
75
|
var buttonFocusRef = React.useRef(undefined);
|
67
76
|
var scrollRef = React.useRef(undefined);
|
@@ -69,7 +78,7 @@ exports.CoachmarkOverlayElements = /*#__PURE__*/React.forwardRef(function (_ref,
|
|
69
78
|
_useState2 = _rollupPluginBabelHelpers.slicedToArray(_useState, 2),
|
70
79
|
scrollPosition = _useState2[0],
|
71
80
|
setScrollPosition = _useState2[1];
|
72
|
-
var _useState3 = React.useState(
|
81
|
+
var _useState3 = React.useState(currentStep),
|
73
82
|
_useState4 = _rollupPluginBabelHelpers.slicedToArray(_useState3, 2),
|
74
83
|
currentProgStep = _useState4[0],
|
75
84
|
_setCurrentProgStep = _useState4[1];
|
@@ -92,6 +101,15 @@ exports.CoachmarkOverlayElements = /*#__PURE__*/React.forwardRef(function (_ref,
|
|
92
101
|
playStep: currentProgStep
|
93
102
|
});
|
94
103
|
}, [currentProgStep, renderMedia]);
|
104
|
+
React.useEffect(function () {
|
105
|
+
var _scrollRef$current, _scrollRef$current$sc;
|
106
|
+
// When current step is set by props
|
107
|
+
// scroll to the appropriate view on the carrousel
|
108
|
+
var targetStep = lodash.clamp(currentStep, progStepFloor, progStepCeil);
|
109
|
+
scrollRef === null || scrollRef === void 0 || (_scrollRef$current = scrollRef.current) === null || _scrollRef$current === void 0 || (_scrollRef$current$sc = _scrollRef$current.scrollToView) === null || _scrollRef$current$sc === void 0 || _scrollRef$current$sc.call(_scrollRef$current, targetStep);
|
110
|
+
// Avoid circular call to this hook
|
111
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
112
|
+
}, [currentStep]);
|
95
113
|
React.useEffect(function () {
|
96
114
|
// On mount, one of the two primary buttons ("next" or "close")
|
97
115
|
// will be rendered and must have focus. (a11y)
|
@@ -133,7 +151,6 @@ exports.CoachmarkOverlayElements = /*#__PURE__*/React.forwardRef(function (_ref,
|
|
133
151
|
}, coachmark.closeButtonProps, {
|
134
152
|
ref: buttonFocusRef
|
135
153
|
}), closeButtonLabel))) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Carousel.Carousel, {
|
136
|
-
disableArrowScroll: true,
|
137
154
|
ref: scrollRef,
|
138
155
|
onScroll: function onScroll(scrollPercent) {
|
139
156
|
setScrollPosition(scrollPercent);
|
@@ -148,10 +165,11 @@ exports.CoachmarkOverlayElements = /*#__PURE__*/React.forwardRef(function (_ref,
|
|
148
165
|
title: previousButtonLabel,
|
149
166
|
disabled: scrollPosition === 0,
|
150
167
|
onClick: function onClick() {
|
151
|
-
var _scrollRef$
|
168
|
+
var _scrollRef$current2, _scrollRef$current2$s;
|
152
169
|
var targetStep = lodash.clamp(currentProgStep - 1, progStepFloor, progStepCeil);
|
153
|
-
scrollRef === null || scrollRef === void 0 || (_scrollRef$
|
170
|
+
scrollRef === null || scrollRef === void 0 || (_scrollRef$current2 = scrollRef.current) === null || _scrollRef$current2 === void 0 || (_scrollRef$current2$s = _scrollRef$current2.scrollToView) === null || _scrollRef$current2$s === void 0 || _scrollRef$current2$s.call(_scrollRef$current2, targetStep);
|
154
171
|
setCurrentProgStep(targetStep);
|
172
|
+
onBack === null || onBack === void 0 || onBack();
|
155
173
|
}
|
156
174
|
}, previousButtonLabel), currentProgStep < progStepCeil ? /*#__PURE__*/React.createElement(react.Button, {
|
157
175
|
size: "sm",
|
@@ -159,10 +177,11 @@ exports.CoachmarkOverlayElements = /*#__PURE__*/React.forwardRef(function (_ref,
|
|
159
177
|
title: nextButtonText,
|
160
178
|
disabled: scrollPosition === 1,
|
161
179
|
onClick: function onClick() {
|
162
|
-
var _scrollRef$
|
180
|
+
var _scrollRef$current3, _scrollRef$current3$s;
|
163
181
|
var targetStep = lodash.clamp(currentProgStep + 1, progStepFloor, progStepCeil);
|
164
|
-
scrollRef === null || scrollRef === void 0 || (_scrollRef$
|
182
|
+
scrollRef === null || scrollRef === void 0 || (_scrollRef$current3 = scrollRef.current) === null || _scrollRef$current3 === void 0 || (_scrollRef$current3$s = _scrollRef$current3.scrollToView) === null || _scrollRef$current3$s === void 0 || _scrollRef$current3$s.call(_scrollRef$current3, targetStep);
|
165
183
|
setCurrentProgStep(targetStep);
|
184
|
+
onNext === null || onNext === void 0 || onNext();
|
166
185
|
}
|
167
186
|
}, nextButtonText) : closeButtonLabel && /*#__PURE__*/React.createElement(react.Button, _rollupPluginBabelHelpers.extends({
|
168
187
|
size: "sm",
|
@@ -196,6 +215,10 @@ exports.CoachmarkOverlayElements.propTypes = {
|
|
196
215
|
* The label for the Close button.
|
197
216
|
*/
|
198
217
|
closeButtonLabel: index.default.string,
|
218
|
+
/**
|
219
|
+
* Current step of the coachmarks
|
220
|
+
*/
|
221
|
+
currentStep: index.default.number,
|
199
222
|
/**
|
200
223
|
* The visibility of CoachmarkOverlayElements is
|
201
224
|
* managed in the parent component.
|
@@ -217,6 +240,14 @@ exports.CoachmarkOverlayElements.propTypes = {
|
|
217
240
|
* The label for the Next button.
|
218
241
|
*/
|
219
242
|
nextButtonText: index.default.string,
|
243
|
+
/**
|
244
|
+
* Optional callback called when clicking on the Previous button.
|
245
|
+
*/
|
246
|
+
onBack: index.default.func,
|
247
|
+
/**
|
248
|
+
* Optional callback called when clicking on the Next button.
|
249
|
+
*/
|
250
|
+
onNext: index.default.func,
|
220
251
|
/**
|
221
252
|
* The label for the Previous button.
|
222
253
|
*/
|
@@ -21,6 +21,7 @@ var cx = require('classnames');
|
|
21
21
|
var devtools = require('../../global/js/utils/devtools.js');
|
22
22
|
var settings = require('../../settings.js');
|
23
23
|
var useResizeObserver = require('../../global/js/hooks/useResizeObserver.js');
|
24
|
+
var checkForOverflow = require('../../global/js/utils/checkForOverflow.js');
|
24
25
|
var useWindowScroll = require('../../global/js/hooks/useWindowScroll.js');
|
25
26
|
var useWindowResize = require('../../global/js/hooks/useWindowResize.js');
|
26
27
|
var BreadcrumbWithOverflow = require('../BreadcrumbWithOverflow/BreadcrumbWithOverflow.js');
|
@@ -363,6 +364,12 @@ exports.PageHeader = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
363
364
|
}
|
364
365
|
};
|
365
366
|
var displayedBreadcrumbs = getBreadcrumbs();
|
367
|
+
var subtitleRef = React.useRef(null);
|
368
|
+
var isOverflowing = checkForOverflow.checkHeightOverflow(subtitleRef.current);
|
369
|
+
var subtitleContent = /*#__PURE__*/React.createElement("span", {
|
370
|
+
ref: subtitleRef,
|
371
|
+
className: "".concat(PageHeaderUtils.blockClass, "__subtitle-text")
|
372
|
+
}, subtitle);
|
366
373
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
367
374
|
className: "".concat(PageHeaderUtils.blockClass, "--offset-top-measuring-element"),
|
368
375
|
ref: offsetTopMeasuringRef
|
@@ -414,11 +421,14 @@ exports.PageHeader = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
414
421
|
blockClass: PageHeaderUtils.blockClass,
|
415
422
|
hasBreadcrumbRow: hasBreadcrumbRow,
|
416
423
|
title: title
|
417
|
-
}) : null), thePageActions(false, pageActionsInBreadcrumbRow)) : null, subtitle
|
424
|
+
}) : null), thePageActions(false, pageActionsInBreadcrumbRow)) : null, subtitle && /*#__PURE__*/React.createElement(react.Row, {
|
418
425
|
className: "".concat(PageHeaderUtils.blockClass, "__subtitle-row")
|
419
426
|
}, /*#__PURE__*/React.createElement(react.Column, {
|
420
427
|
className: "".concat(PageHeaderUtils.blockClass, "__subtitle")
|
421
|
-
},
|
428
|
+
}, isOverflowing ? /*#__PURE__*/React.createElement(react.DefinitionTooltip, {
|
429
|
+
definition: subtitle,
|
430
|
+
className: "".concat(PageHeaderUtils.blockClass, "__subtitle-tooltip")
|
431
|
+
}, subtitleContent) : subtitleContent)), children ? /*#__PURE__*/React.createElement(react.Row, {
|
422
432
|
className: "".concat(PageHeaderUtils.blockClass, "__available-row")
|
423
433
|
}, /*#__PURE__*/React.createElement(react.Column, {
|
424
434
|
className: "".concat(PageHeaderUtils.blockClass, "__available-column")
|
@@ -13,6 +13,7 @@ var index = require('../../_virtual/index.js');
|
|
13
13
|
var cx = require('classnames');
|
14
14
|
var react = require('@carbon/react');
|
15
15
|
var EditInPlace = require('../EditInPlace/EditInPlace.js');
|
16
|
+
var checkForOverflow = require('../../global/js/utils/checkForOverflow.js');
|
16
17
|
|
17
18
|
var _excluded = ["text", "content", "loading", "icon", "asText", "onChange", "onSave", "editDescription", "editableLabel", "cancelDescription", "saveDescription", "tooltipAlignment"];
|
18
19
|
|
@@ -45,31 +46,18 @@ var PageHeaderTitle = function PageHeaderTitle(_ref) {
|
|
45
46
|
rest = _rollupPluginBabelHelpers.objectWithoutProperties(title, _excluded);
|
46
47
|
var titleText;
|
47
48
|
var isEditable = !!onSave;
|
48
|
-
var
|
49
|
-
|
50
|
-
isEllipsisApplied = _useState2[0],
|
51
|
-
setIsEllipsisApplied = _useState2[1];
|
52
|
-
var longTitleRef = React.useRef(undefined);
|
53
|
-
var titleRef = React.useRef(undefined);
|
54
|
-
React.useLayoutEffect(function () {
|
55
|
-
setIsEllipsisApplied(isEllipsisActive());
|
56
|
-
}, [longTitleRef, titleRef, title]);
|
57
|
-
var isEllipsisActive = function isEllipsisActive() {
|
58
|
-
if (longTitleRef.current) {
|
59
|
-
var _longTitleRef$current, _longTitleRef$current2;
|
60
|
-
return ((_longTitleRef$current = longTitleRef.current) === null || _longTitleRef$current === void 0 ? void 0 : _longTitleRef$current.offsetWidth) < ((_longTitleRef$current2 = longTitleRef.current) === null || _longTitleRef$current2 === void 0 ? void 0 : _longTitleRef$current2.scrollWidth);
|
61
|
-
} else if (titleRef.current) {
|
62
|
-
var _titleRef$current, _titleRef$current2;
|
63
|
-
return ((_titleRef$current = titleRef.current) === null || _titleRef$current === void 0 ? void 0 : _titleRef$current.offsetWidth) < ((_titleRef$current2 = titleRef.current) === null || _titleRef$current2 === void 0 ? void 0 : _titleRef$current2.scrollWidth);
|
64
|
-
}
|
65
|
-
return false;
|
66
|
-
};
|
49
|
+
var titleRef = React.useRef();
|
50
|
+
var isEllipsisApplied = checkForOverflow.checkWidthOverflow(titleRef.current);
|
67
51
|
if (text || !content) {
|
68
52
|
if (text === undefined && typeof title === 'string') {
|
69
53
|
text = title;
|
70
54
|
asText = title;
|
71
55
|
}
|
72
56
|
var TitleIcon = icon;
|
57
|
+
var titleContent = /*#__PURE__*/React.createElement("span", {
|
58
|
+
ref: titleRef,
|
59
|
+
className: "".concat(blockClass, "__titleText")
|
60
|
+
}, text);
|
73
61
|
titleInnards = /*#__PURE__*/React.createElement(React.Fragment, null, icon && !loading ? /*#__PURE__*/React.createElement("span", {
|
74
62
|
className: "".concat(blockClass, "__title-icon-wrapper")
|
75
63
|
}, /*#__PURE__*/React.createElement(TitleIcon, {
|
@@ -92,14 +80,7 @@ var PageHeaderTitle = function PageHeaderTitle(_ref) {
|
|
92
80
|
align: tooltipAlignment,
|
93
81
|
definition: text,
|
94
82
|
className: "".concat(blockClass, "__tooltip")
|
95
|
-
},
|
96
|
-
ref: longTitleRef,
|
97
|
-
className: "".concat(blockClass, "__titleText")
|
98
|
-
}, text)) : /*#__PURE__*/React.createElement("span", {
|
99
|
-
ref: titleRef,
|
100
|
-
className: "".concat(blockClass, "__titleText"),
|
101
|
-
title: !loading ? asText : null
|
102
|
-
}, text));
|
83
|
+
}, titleContent) : titleContent);
|
103
84
|
} else {
|
104
85
|
titleInnards = content;
|
105
86
|
titleText = asText;
|
@@ -0,0 +1,34 @@
|
|
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
|
+
'use strict';
|
9
|
+
|
10
|
+
// Copyright IBM Corp. 2024, 2024
|
11
|
+
//
|
12
|
+
// This source code is licensed under the Apache-2.0 license found in the
|
13
|
+
// LICENSE file in the root directory of this source tree.
|
14
|
+
//
|
15
|
+
|
16
|
+
/**
|
17
|
+
* used to calculate if a element is overflowing the width or height of an area
|
18
|
+
*/
|
19
|
+
|
20
|
+
var checkWidthOverflow = function checkWidthOverflow(el) {
|
21
|
+
if (el) {
|
22
|
+
return (el === null || el === void 0 ? void 0 : el.offsetWidth) < (el === null || el === void 0 ? void 0 : el.scrollWidth);
|
23
|
+
}
|
24
|
+
return false;
|
25
|
+
};
|
26
|
+
var checkHeightOverflow = function checkHeightOverflow(el) {
|
27
|
+
if (el) {
|
28
|
+
return (el === null || el === void 0 ? void 0 : el.offsetHeight) < (el === null || el === void 0 ? void 0 : el.scrollHeight);
|
29
|
+
}
|
30
|
+
return false;
|
31
|
+
};
|
32
|
+
|
33
|
+
exports.checkHeightOverflow = checkHeightOverflow;
|
34
|
+
exports.checkWidthOverflow = checkWidthOverflow;
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@carbon/ibm-products",
|
3
3
|
"description": "Carbon for IBM Products",
|
4
|
-
"version": "2.54.0-canary.
|
4
|
+
"version": "2.54.0-canary.74+26394dd2b",
|
5
5
|
"license": "Apache-2.0",
|
6
6
|
"main": "lib/index.js",
|
7
7
|
"module": "es/index.js",
|
@@ -96,7 +96,7 @@
|
|
96
96
|
"dependencies": {
|
97
97
|
"@babel/runtime": "^7.23.9",
|
98
98
|
"@carbon/feature-flags": "^0.24.0",
|
99
|
-
"@carbon/ibm-products-styles": "^2.
|
99
|
+
"@carbon/ibm-products-styles": "^2.50.0-canary.74+26394dd2b",
|
100
100
|
"@carbon/telemetry": "^0.1.0",
|
101
101
|
"@dnd-kit/core": "^6.0.8",
|
102
102
|
"@dnd-kit/modifiers": "^7.0.0",
|
@@ -120,5 +120,5 @@
|
|
120
120
|
"react": "^16.8.6 || ^17.0.1 || ^18.2.0",
|
121
121
|
"react-dom": "^16.8.6 || ^17.0.1 || ^18.2.0"
|
122
122
|
},
|
123
|
-
"gitHead": "
|
123
|
+
"gitHead": "26394dd2b740f19306e8fbbbd6c2195fc5a3bbed"
|
124
124
|
}
|
@@ -538,14 +538,8 @@ $right-section-alt-width: 100% - $left-section-alt-width;
|
|
538
538
|
}
|
539
539
|
|
540
540
|
.#{$block-class}__subtitle-row {
|
541
|
-
display: -webkit-box;
|
542
|
-
overflow: hidden;
|
543
|
-
max-width: 100%;
|
544
541
|
margin-top: $spacing-03;
|
545
542
|
|
546
|
-
-webkit-box-orient: vertical;
|
547
|
-
-webkit-line-clamp: 2;
|
548
|
-
|
549
543
|
@include breakpoint-up('md') {
|
550
544
|
max-width: $left-section-std-width;
|
551
545
|
}
|
@@ -559,6 +553,24 @@ $right-section-alt-width: 100% - $left-section-alt-width;
|
|
559
553
|
@include type.type-style('body-01');
|
560
554
|
}
|
561
555
|
|
556
|
+
.#{$block-class}__subtitle-tooltip .#{$carbon-prefix}--definition-term {
|
557
|
+
border-bottom: 0;
|
558
|
+
letter-spacing: inherit;
|
559
|
+
}
|
560
|
+
|
561
|
+
// overwrites the existing styles to make the popover bigger because in some cases the narrow space can be too constricting for the header
|
562
|
+
.#{$block-class}__subtitle-tooltip
|
563
|
+
.#{$carbon-prefix}--popover-content.#{$carbon-prefix}--definition-tooltip {
|
564
|
+
max-inline-size: fit-content;
|
565
|
+
}
|
566
|
+
|
567
|
+
.#{$block-class}__subtitle-text {
|
568
|
+
display: -webkit-box;
|
569
|
+
overflow: hidden;
|
570
|
+
-webkit-box-orient: vertical;
|
571
|
+
-webkit-line-clamp: 2;
|
572
|
+
}
|
573
|
+
|
562
574
|
.#{$block-class}__available-row {
|
563
575
|
@include type.type-style('body-01');
|
564
576
|
|