@carbon/ibm-products 2.54.0-canary.73 → 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/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/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
@@ -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 };
|
@@ -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
|
|