@carbon/ibm-products 2.43.2-canary.307 → 2.43.2-canary.308
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 +15 -3
- 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 +15 -3
- 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 +15 -3
- 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 +15 -3
- 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.d.ts +2 -0
- package/es/components/PageHeader/PageHeader.js +4 -1
- package/es/components/PageHeader/PageHeaderTitle.d.ts +1 -0
- package/es/components/PageHeader/PageHeaderTitle.js +42 -8
- package/lib/components/PageHeader/PageHeader.d.ts +2 -0
- package/lib/components/PageHeader/PageHeader.js +4 -1
- package/lib/components/PageHeader/PageHeaderTitle.d.ts +1 -0
- package/lib/components/PageHeader/PageHeaderTitle.js +39 -5
- package/package.json +3 -3
- package/scss/components/PageHeader/_page-header.scss +16 -3
@@ -5,14 +5,14 @@
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
6
6
|
*/
|
7
7
|
|
8
|
-
import { objectWithoutProperties as _objectWithoutProperties, extends as _extends, defineProperty as _defineProperty } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
9
|
-
import React__default from 'react';
|
8
|
+
import { objectWithoutProperties as _objectWithoutProperties, slicedToArray as _slicedToArray, extends as _extends, defineProperty as _defineProperty } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
9
|
+
import React__default, { useState, useRef, useLayoutEffect } from 'react';
|
10
10
|
import PropTypes from '../../_virtual/index.js';
|
11
11
|
import cx from 'classnames';
|
12
|
-
import { SkeletonText } from '@carbon/react';
|
12
|
+
import { SkeletonText, DefinitionTooltip } from '@carbon/react';
|
13
13
|
import { EditInPlace } from '../EditInPlace/EditInPlace.js';
|
14
14
|
|
15
|
-
var _excluded = ["text", "content", "loading", "icon", "asText", "onChange", "onSave", "editDescription", "editableLabel", "cancelDescription", "saveDescription"];
|
15
|
+
var _excluded = ["text", "content", "loading", "icon", "asText", "onChange", "onSave", "editDescription", "editableLabel", "cancelDescription", "saveDescription", "tooltipAlignment"];
|
16
16
|
|
17
17
|
/**
|
18
18
|
*
|
@@ -38,18 +38,41 @@ var PageHeaderTitle = function PageHeaderTitle(_ref) {
|
|
38
38
|
editableLabel = title.editableLabel,
|
39
39
|
cancelDescription = title.cancelDescription,
|
40
40
|
saveDescription = title.saveDescription,
|
41
|
+
_title$tooltipAlignme = title.tooltipAlignment,
|
42
|
+
tooltipAlignment = _title$tooltipAlignme === void 0 ? 'bottom' : _title$tooltipAlignme,
|
41
43
|
rest = _objectWithoutProperties(title, _excluded);
|
42
44
|
var titleText;
|
43
45
|
var isEditable = !!onSave;
|
46
|
+
var _useState = useState(),
|
47
|
+
_useState2 = _slicedToArray(_useState, 2),
|
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
|
+
};
|
44
65
|
if (text || !content) {
|
45
66
|
if (text === undefined && typeof title === 'string') {
|
46
67
|
text = title;
|
47
68
|
asText = title;
|
48
69
|
}
|
49
70
|
var TitleIcon = icon;
|
50
|
-
titleInnards = /*#__PURE__*/React__default.createElement(React__default.Fragment, null, icon && !loading ? /*#__PURE__*/React__default.createElement(
|
71
|
+
titleInnards = /*#__PURE__*/React__default.createElement(React__default.Fragment, null, icon && !loading ? /*#__PURE__*/React__default.createElement("span", {
|
72
|
+
className: "".concat(blockClass, "__title-icon-wrapper")
|
73
|
+
}, /*#__PURE__*/React__default.createElement(TitleIcon, {
|
51
74
|
className: "".concat(blockClass, "__title-icon")
|
52
|
-
}) : null, loading ? /*#__PURE__*/React__default.createElement(SkeletonText, {
|
75
|
+
})) : null, loading ? /*#__PURE__*/React__default.createElement(SkeletonText, {
|
53
76
|
className: "".concat(blockClass, "__title-skeleton")
|
54
77
|
}) : isEditable ? /*#__PURE__*/React__default.createElement(EditInPlace, _extends({
|
55
78
|
tooltipAlignment: "bottom",
|
@@ -62,7 +85,17 @@ var PageHeaderTitle = function PageHeaderTitle(_ref) {
|
|
62
85
|
onSave: onSave,
|
63
86
|
size: "md",
|
64
87
|
inheritTypography: true
|
65
|
-
}, rest)) : /*#__PURE__*/React__default.createElement(
|
88
|
+
}, rest)) : isEllipsisApplied ? /*#__PURE__*/React__default.createElement(DefinitionTooltip, {
|
89
|
+
openOnHover: false,
|
90
|
+
align: tooltipAlignment,
|
91
|
+
definition: text,
|
92
|
+
className: "".concat(blockClass, "__tooltip")
|
93
|
+
}, /*#__PURE__*/React__default.createElement("span", {
|
94
|
+
ref: longTitleRef,
|
95
|
+
className: "".concat(blockClass, "__titleText")
|
96
|
+
}, text)) : /*#__PURE__*/React__default.createElement("span", {
|
97
|
+
ref: titleRef,
|
98
|
+
className: "".concat(blockClass, "__titleText"),
|
66
99
|
title: !loading ? asText : null
|
67
100
|
}, text));
|
68
101
|
} else {
|
@@ -117,7 +150,8 @@ PageHeaderTitle.propTypes = {
|
|
117
150
|
onChange: PropTypes.func,
|
118
151
|
onSave: PropTypes.func,
|
119
152
|
cancelDescription: PropTypes.string.isRequired.if(editInPlaceRequired),
|
120
|
-
saveDescription: PropTypes.string.isRequired.if(editInPlaceRequired)
|
153
|
+
saveDescription: PropTypes.string.isRequired.if(editInPlaceRequired),
|
154
|
+
tooltipAlignment: PropTypes.oneOf(['top', 'top-left', 'top-right', 'bottom', 'bottom-left', 'bottom-right', 'left', 'right'])
|
121
155
|
// Update docgen if changed
|
122
156
|
}), PropTypes.string, PropTypes.shape({
|
123
157
|
content: PropTypes.node.isRequired,
|
@@ -149,6 +149,7 @@ interface TitleIcon {
|
|
149
149
|
cancelDescription?: string;
|
150
150
|
editDescription?: string;
|
151
151
|
saveDescription?: string;
|
152
|
+
tooltipAlignment?: 'top' | 'top-left' | 'top-right' | 'bottom' | 'bottom-left' | 'bottom-right' | 'left' | 'right';
|
152
153
|
}
|
153
154
|
interface TitleContent {
|
154
155
|
content: ReactNode;
|
@@ -269,6 +270,7 @@ interface PageHeaderBaseProps extends PropsWithChildren {
|
|
269
270
|
* - editableLabel: label for edit required if onChange supplied
|
270
271
|
* - cancelDescription: label for edit cancel button
|
271
272
|
* - saveDescription: label for edit save button
|
273
|
+
* - tooltipAlignment: position for tooltip displayed for large titles. Default to "bottom"
|
272
274
|
* - Object containing user defined contents. These must fit within the area defined for the title in both main part of the header and the breadcrumb.
|
273
275
|
* - content: title or name of current location shown in main part of page header
|
274
276
|
* - breadcrumbContent: version of content used in the breadcrumb on scroll. If not supplied
|
@@ -790,6 +790,7 @@ exports.PageHeader.propTypes = _rollupPluginBabelHelpers.objectSpread2({
|
|
790
790
|
* - editableLabel: label for edit required if onChange supplied
|
791
791
|
* - cancelDescription: label for edit cancel button
|
792
792
|
* - saveDescription: label for edit save button
|
793
|
+
* - tooltipAlignment: position for tooltip displayed for large titles. Default to "bottom".
|
793
794
|
* - Object containing user defined contents. These must fit within the area defined for the title in both main part of the header and the breadcrumb.
|
794
795
|
* - content: title or name of current location shown in main part of page header
|
795
796
|
* - breadcrumbContent: version of content used in the breadcrumb on scroll. If not supplied
|
@@ -814,7 +815,9 @@ exports.PageHeader.propTypes = _rollupPluginBabelHelpers.objectSpread2({
|
|
814
815
|
//.isRequired.if(editInPlaceRequired),
|
815
816
|
editDescription: index.default.string,
|
816
817
|
// .isRequired.if(editInPlaceRequired),
|
817
|
-
saveDescription: index.default.string
|
818
|
+
saveDescription: index.default.string,
|
819
|
+
//.isRequired.if(editInPlaceRequired),
|
820
|
+
tooltipAlignment: index.default.oneOf(['top', 'top-left', 'top-right', 'bottom', 'bottom-left', 'bottom-right', 'left', 'right'])
|
818
821
|
// Update docgen if changed
|
819
822
|
}), index.default.string, index.default.shape({
|
820
823
|
content: index.default.node.isRequired,
|
@@ -18,6 +18,7 @@ export namespace PageHeaderTitle {
|
|
18
18
|
onSave: PropTypes.Requireable<(...args: any[]) => any>;
|
19
19
|
cancelDescription: any;
|
20
20
|
saveDescription: any;
|
21
|
+
tooltipAlignment: PropTypes.Requireable<string>;
|
21
22
|
}> | PropTypes.InferProps<{
|
22
23
|
content: PropTypes.Validator<NonNullable<PropTypes.ReactNodeLike>>;
|
23
24
|
breadcrumbContent: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
@@ -14,7 +14,7 @@ var cx = require('classnames');
|
|
14
14
|
var react = require('@carbon/react');
|
15
15
|
var EditInPlace = require('../EditInPlace/EditInPlace.js');
|
16
16
|
|
17
|
-
var _excluded = ["text", "content", "loading", "icon", "asText", "onChange", "onSave", "editDescription", "editableLabel", "cancelDescription", "saveDescription"];
|
17
|
+
var _excluded = ["text", "content", "loading", "icon", "asText", "onChange", "onSave", "editDescription", "editableLabel", "cancelDescription", "saveDescription", "tooltipAlignment"];
|
18
18
|
|
19
19
|
/**
|
20
20
|
*
|
@@ -40,18 +40,41 @@ var PageHeaderTitle = function PageHeaderTitle(_ref) {
|
|
40
40
|
editableLabel = title.editableLabel,
|
41
41
|
cancelDescription = title.cancelDescription,
|
42
42
|
saveDescription = title.saveDescription,
|
43
|
+
_title$tooltipAlignme = title.tooltipAlignment,
|
44
|
+
tooltipAlignment = _title$tooltipAlignme === void 0 ? 'bottom' : _title$tooltipAlignme,
|
43
45
|
rest = _rollupPluginBabelHelpers.objectWithoutProperties(title, _excluded);
|
44
46
|
var titleText;
|
45
47
|
var isEditable = !!onSave;
|
48
|
+
var _useState = React.useState(),
|
49
|
+
_useState2 = _rollupPluginBabelHelpers.slicedToArray(_useState, 2),
|
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
|
+
};
|
46
67
|
if (text || !content) {
|
47
68
|
if (text === undefined && typeof title === 'string') {
|
48
69
|
text = title;
|
49
70
|
asText = title;
|
50
71
|
}
|
51
72
|
var TitleIcon = icon;
|
52
|
-
titleInnards = /*#__PURE__*/React.createElement(React.Fragment, null, icon && !loading ? /*#__PURE__*/React.createElement(
|
73
|
+
titleInnards = /*#__PURE__*/React.createElement(React.Fragment, null, icon && !loading ? /*#__PURE__*/React.createElement("span", {
|
74
|
+
className: "".concat(blockClass, "__title-icon-wrapper")
|
75
|
+
}, /*#__PURE__*/React.createElement(TitleIcon, {
|
53
76
|
className: "".concat(blockClass, "__title-icon")
|
54
|
-
}) : null, loading ? /*#__PURE__*/React.createElement(react.SkeletonText, {
|
77
|
+
})) : null, loading ? /*#__PURE__*/React.createElement(react.SkeletonText, {
|
55
78
|
className: "".concat(blockClass, "__title-skeleton")
|
56
79
|
}) : isEditable ? /*#__PURE__*/React.createElement(EditInPlace.EditInPlace, _rollupPluginBabelHelpers.extends({
|
57
80
|
tooltipAlignment: "bottom",
|
@@ -64,7 +87,17 @@ var PageHeaderTitle = function PageHeaderTitle(_ref) {
|
|
64
87
|
onSave: onSave,
|
65
88
|
size: "md",
|
66
89
|
inheritTypography: true
|
67
|
-
}, rest)) : /*#__PURE__*/React.createElement(
|
90
|
+
}, rest)) : isEllipsisApplied ? /*#__PURE__*/React.createElement(react.DefinitionTooltip, {
|
91
|
+
openOnHover: false,
|
92
|
+
align: tooltipAlignment,
|
93
|
+
definition: text,
|
94
|
+
className: "".concat(blockClass, "__tooltip")
|
95
|
+
}, /*#__PURE__*/React.createElement("span", {
|
96
|
+
ref: longTitleRef,
|
97
|
+
className: "".concat(blockClass, "__titleText")
|
98
|
+
}, text)) : /*#__PURE__*/React.createElement("span", {
|
99
|
+
ref: titleRef,
|
100
|
+
className: "".concat(blockClass, "__titleText"),
|
68
101
|
title: !loading ? asText : null
|
69
102
|
}, text));
|
70
103
|
} else {
|
@@ -119,7 +152,8 @@ PageHeaderTitle.propTypes = {
|
|
119
152
|
onChange: index.default.func,
|
120
153
|
onSave: index.default.func,
|
121
154
|
cancelDescription: index.default.string.isRequired.if(editInPlaceRequired),
|
122
|
-
saveDescription: index.default.string.isRequired.if(editInPlaceRequired)
|
155
|
+
saveDescription: index.default.string.isRequired.if(editInPlaceRequired),
|
156
|
+
tooltipAlignment: index.default.oneOf(['top', 'top-left', 'top-right', 'bottom', 'bottom-left', 'bottom-right', 'left', 'right'])
|
123
157
|
// Update docgen if changed
|
124
158
|
}), index.default.string, index.default.shape({
|
125
159
|
content: index.default.node.isRequired,
|
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.43.2-canary.
|
4
|
+
"version": "2.43.2-canary.308+ed578ec0d",
|
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.23.1",
|
99
|
-
"@carbon/ibm-products-styles": "^2.39.1-canary.
|
99
|
+
"@carbon/ibm-products-styles": "^2.39.1-canary.318+ed578ec0d",
|
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": "ed578ec0d45dcd72a7c96fd1e8370d4a67019ec6"
|
124
124
|
}
|
@@ -433,13 +433,26 @@ $right-section-alt-width: 100% - $left-section-alt-width;
|
|
433
433
|
}
|
434
434
|
}
|
435
435
|
|
436
|
+
.#{$block-class}__tooltip {
|
437
|
+
min-width: 0;
|
438
|
+
flex-basis: auto;
|
439
|
+
|
440
|
+
button {
|
441
|
+
border-block-end: none;
|
442
|
+
cursor: default;
|
443
|
+
}
|
444
|
+
}
|
445
|
+
.#{$block-class}__titleText {
|
446
|
+
display: block;
|
447
|
+
overflow: hidden;
|
448
|
+
text-overflow: ellipsis;
|
449
|
+
white-space: nowrap;
|
450
|
+
}
|
436
451
|
.#{$block-class}__title {
|
437
452
|
@include type.type-style('heading-04');
|
438
453
|
|
454
|
+
display: flex;
|
439
455
|
min-height: $spacing-08;
|
440
|
-
overflow-x: hidden;
|
441
|
-
text-overflow: ellipsis;
|
442
|
-
white-space: nowrap;
|
443
456
|
}
|
444
457
|
|
445
458
|
.#{$block-class}__title--editable {
|