@carbon/ibm-products 2.0.0-rc.27 → 2.0.0-rc.28
Sign up to get free protection for your applications and to get access to all the features.
- package/css/index-full-carbon.css +71 -221
- package/css/index-full-carbon.css.map +1 -1
- package/css/index-full-carbon.min.css +3 -5
- package/css/index-full-carbon.min.css.map +1 -1
- package/css/index-without-carbon-released-only.css +142 -189
- package/css/index-without-carbon-released-only.css.map +1 -1
- package/css/index-without-carbon-released-only.min.css +1 -3
- package/css/index-without-carbon-released-only.min.css.map +1 -1
- package/css/index-without-carbon.css +71 -221
- package/css/index-without-carbon.css.map +1 -1
- package/css/index-without-carbon.min.css +3 -5
- package/css/index-without-carbon.min.css.map +1 -1
- package/css/index.css +71 -221
- package/css/index.css.map +1 -1
- package/css/index.min.css +3 -5
- package/css/index.min.css.map +1 -1
- package/es/components/AboutModal/AboutModal.js +3 -4
- package/es/components/ActionBar/ActionBar.js +13 -29
- package/es/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.js +15 -21
- package/es/components/ButtonSetWithOverflow/ButtonSetWithOverflow.js +7 -11
- package/es/components/Datagrid/Datagrid/DatagridSelectAllWithToggle.js +7 -8
- package/es/components/Datagrid/Datagrid/DatagridToolbar.js +6 -5
- package/es/components/Datagrid/Datagrid/DatagridVirtualBody.js +3 -4
- package/es/components/Datagrid/Datagrid/addons/Filtering/FilterFlyout.js +17 -3
- package/es/components/Datagrid/Datagrid/addons/Filtering/FilterPanel.js +19 -4
- package/es/components/Datagrid/Datagrid/addons/Filtering/hooks/useFilters.js +8 -5
- package/es/components/Datagrid/Datagrid/addons/Filtering/hooks/useInitialStateFromFilters.js +2 -1
- package/es/components/Datagrid/Datagrid/addons/Filtering/utils.js +19 -1
- package/es/components/Datagrid/useFiltering.js +4 -2
- package/es/components/Datagrid/useOnRowClick.js +11 -1
- package/es/components/Datagrid/useSelectRows.js +2 -0
- package/es/components/{InlineEditV2/InlineEditV2.js → EditInPlace/EditInPlace.js} +92 -30
- package/es/components/{InlineEdit → EditInPlace}/index.js +1 -1
- package/es/components/PageHeader/PageHeader.js +36 -35
- package/es/components/PageHeader/PageHeaderTitle.js +18 -18
- package/es/components/SidePanel/SidePanel.js +25 -26
- package/es/components/TagSet/TagSet.js +5 -7
- package/es/components/Tearsheet/TearsheetShell.js +4 -6
- package/es/components/index.js +1 -1
- package/es/global/js/hooks/useResizeObserver.js +79 -0
- package/es/global/js/hooks/useWindowResize.js +6 -0
- package/es/global/js/hooks/useWindowScroll.js +7 -0
- package/es/global/js/package-settings.js +2 -4
- package/lib/components/AboutModal/AboutModal.js +3 -4
- package/lib/components/ActionBar/ActionBar.js +13 -29
- package/lib/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.js +13 -19
- package/lib/components/ButtonSetWithOverflow/ButtonSetWithOverflow.js +7 -11
- package/lib/components/Datagrid/Datagrid/DatagridSelectAllWithToggle.js +2 -1
- package/lib/components/Datagrid/Datagrid/DatagridToolbar.js +5 -4
- package/lib/components/Datagrid/Datagrid/DatagridVirtualBody.js +3 -4
- package/lib/components/Datagrid/Datagrid/addons/Filtering/FilterFlyout.js +17 -3
- package/lib/components/Datagrid/Datagrid/addons/Filtering/FilterPanel.js +19 -4
- package/lib/components/Datagrid/Datagrid/addons/Filtering/hooks/useFilters.js +8 -5
- package/lib/components/Datagrid/Datagrid/addons/Filtering/hooks/useInitialStateFromFilters.js +2 -1
- package/lib/components/Datagrid/Datagrid/addons/Filtering/utils.js +18 -1
- package/lib/components/Datagrid/useFiltering.js +4 -2
- package/lib/components/Datagrid/useOnRowClick.js +11 -1
- package/lib/components/Datagrid/useSelectRows.js +2 -0
- package/lib/components/{InlineEditV2/InlineEditV2.js → EditInPlace/EditInPlace.js} +100 -34
- package/lib/components/{InlineEdit → EditInPlace}/index.js +3 -3
- package/lib/components/PageHeader/PageHeader.js +36 -35
- package/lib/components/PageHeader/PageHeaderTitle.js +19 -19
- package/lib/components/SidePanel/SidePanel.js +25 -26
- package/lib/components/TagSet/TagSet.js +5 -7
- package/lib/components/Tearsheet/TearsheetShell.js +4 -6
- package/lib/components/index.js +7 -7
- package/lib/global/js/hooks/useResizeObserver.js +91 -0
- package/lib/global/js/hooks/useWindowScroll.js +6 -0
- package/lib/global/js/package-settings.js +2 -4
- package/package.json +3 -4
- package/scss/components/BreadcrumbWithOverflow/_breadcrumb-with-overflow.scss +10 -1
- package/scss/components/Datagrid/styles/_useSelectAllToggle.scss +11 -7
- package/scss/components/{InlineEditV2/_inline-edit-v2.scss → EditInPlace/_edit-in-place.scss} +56 -14
- package/scss/components/{InlineEditV1 → EditInPlace}/_index-with-carbon.scss +1 -1
- package/scss/components/{InlineEditV2 → EditInPlace}/_index.scss +1 -1
- package/scss/components/{InlineEditV1 → EditInPlace}/_storybook-styles.scss +3 -15
- package/scss/components/PageHeader/_page-header.scss +1 -7
- package/scss/components/_index-released-only-with-carbon.scss +1 -1
- package/scss/components/_index-released-only.scss +1 -1
- package/scss/components/_index-with-carbon.scss +1 -2
- package/scss/components/_index.scss +1 -2
- package/es/components/InlineEdit/InlineEdit.js +0 -47
- package/es/components/InlineEditV1/InlineEditV1.js +0 -442
- package/es/components/InlineEditV1/index.js +0 -7
- package/es/components/InlineEditV2/index.js +0 -7
- package/lib/components/InlineEdit/InlineEdit.js +0 -63
- package/lib/components/InlineEditV1/InlineEditV1.js +0 -459
- package/lib/components/InlineEditV1/index.js +0 -13
- package/lib/components/InlineEditV2/index.js +0 -13
- package/scss/components/InlineEditV1/_carbon-imports.scss +0 -6
- package/scss/components/InlineEditV1/_index.scss +0 -8
- package/scss/components/InlineEditV1/_inline-edit-v1.scss +0 -269
- package/scss/components/InlineEditV2/_index-with-carbon.scss +0 -9
- package/scss/components/InlineEditV2/_storybook-styles.scss +0 -9
- /package/scss/components/{InlineEditV2 → EditInPlace}/_carbon-imports.scss +0 -0
@@ -18,7 +18,7 @@ import React, { useEffect, useRef, useState } from 'react';
|
|
18
18
|
import PropTypes from 'prop-types';
|
19
19
|
import { spacing10, baseFontSize } from '@carbon/layout';
|
20
20
|
import cx from 'classnames';
|
21
|
-
import {
|
21
|
+
import { useResizeObserver } from '../../global/js/hooks/useResizeObserver';
|
22
22
|
import { FlexGrid, Column, Row, Button, Tag } from '@carbon/react';
|
23
23
|
import { breakpoints } from '@carbon/layout';
|
24
24
|
import { useWindowResize, useNearestScroll } from '../../global/js/hooks';
|
@@ -39,7 +39,7 @@ var defaults = {
|
|
39
39
|
narrowGrid: false
|
40
40
|
};
|
41
41
|
export var PageHeader = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
42
|
-
var _withoutBackground, _enableBreadcrumbScro,
|
42
|
+
var _withoutBackground, _enableBreadcrumbScro, _ref7, _cx2, _ref8, _cx4, _cx7;
|
43
43
|
|
44
44
|
var actionBarItems = _ref.actionBarItems,
|
45
45
|
actionBarMenuOptionsClass = _ref.actionBarMenuOptionsClass,
|
@@ -195,7 +195,9 @@ export var PageHeader = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
195
195
|
/* istanbul ignore next */
|
196
196
|
|
197
197
|
|
198
|
-
var handleResizeActionBarColumn = function handleResizeActionBarColumn(
|
198
|
+
var handleResizeActionBarColumn = function handleResizeActionBarColumn(_ref4) {
|
199
|
+
var width = _ref4.width;
|
200
|
+
|
199
201
|
/* don't know how to test resize */
|
200
202
|
|
201
203
|
/* istanbul ignore next */
|
@@ -280,8 +282,8 @@ export var PageHeader = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
280
282
|
}, [headerRef, enableBreadcrumbScroll, metrics, metrics.breadcrumbRowHeight, metrics.breadcrumbRowSpaceBelow, metrics.breadcrumbTitleHeight, metrics.breadcrumbRowWidth, metrics.headerHeight, metrics.headerWidth, metrics.headerOffset, metrics.headerTopValue, metrics.navigationRowHeight, navigation, scrollYValue, tags]);
|
281
283
|
useNearestScroll(headerRef, // on scroll or various layout changes check updates if needed
|
282
284
|
// istanbul ignore next
|
283
|
-
function (
|
284
|
-
var current =
|
285
|
+
function (_ref5) {
|
286
|
+
var current = _ref5.current;
|
285
287
|
setPageHeaderStyles(function (prev) {
|
286
288
|
return _objectSpread(_objectSpread({}, prev), {}, _defineProperty({}, "--".concat(blockClass, "--breadcrumb-top"), "".concat(metrics.headerOffset, "px")));
|
287
289
|
});
|
@@ -297,8 +299,8 @@ export var PageHeader = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
297
299
|
document.documentElement.style.setProperty("--".concat(blockClass, "--tagset-tooltip-offset"), "".concat(tagsetTooltipOffset, "px"));
|
298
300
|
setScrollYValue(current.scrollY);
|
299
301
|
}, [metrics.headerHeight, metrics.headerTopValue, metrics.headerOffset, enableBreadcrumbScroll]);
|
300
|
-
useWindowResize(function (
|
301
|
-
var current =
|
302
|
+
useWindowResize(function (_ref6) {
|
303
|
+
var current = _ref6.current;
|
302
304
|
// on window resize and other updates some values may have changed
|
303
305
|
checkUpdateVerticalSpace();
|
304
306
|
setWidthIsNarrow(current.innerWidth / 16 < parseInt(breakpoints.md.width)); // small (below medium) media query
|
@@ -348,15 +350,11 @@ export var PageHeader = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
348
350
|
utilSetCollapsed(collapseHeader, metrics.headerOffset, metrics.headerTopValue);
|
349
351
|
}
|
350
352
|
}, [collapseHeader, metrics.headerOffset, metrics.headerTopValue]);
|
351
|
-
|
352
|
-
|
353
|
-
targetRef: sizingContainerRef,
|
354
|
-
handleWidth: true
|
353
|
+
useResizeObserver(sizingContainerRef, {
|
354
|
+
callback: handleResizeActionBarColumn
|
355
355
|
});
|
356
|
-
|
357
|
-
|
358
|
-
targetRef: headerRef,
|
359
|
-
handleHeight: true
|
356
|
+
useResizeObserver(headerRef, {
|
357
|
+
callback: handleResize
|
360
358
|
}); // Determine what form of title to display in the breadcrumb
|
361
359
|
|
362
360
|
var breadcrumbItemForTitle = utilGetBreadcrumbItemForTitle(blockClass, collapseTitle, title);
|
@@ -364,7 +362,7 @@ export var PageHeader = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
364
362
|
className: "".concat(blockClass, "--offset-top-measuring-element"),
|
365
363
|
ref: offsetTopMeasuringRef
|
366
364
|
}), /*#__PURE__*/React.createElement("section", _extends({}, rest, {
|
367
|
-
className: cx([blockClass, "".concat(blockClass, "--no-margins-below-row"), className, (
|
365
|
+
className: cx([blockClass, "".concat(blockClass, "--no-margins-below-row"), className, (_ref7 = {}, _defineProperty(_ref7, "".concat(blockClass, "--has-navigation"), navigation || tags), _defineProperty(_ref7, "".concat(blockClass, "--has-navigation-tags-only"), !navigation && tags), _ref7)]),
|
368
366
|
style: pageHeaderStyles,
|
369
367
|
ref: headerRef
|
370
368
|
}, getDevtoolsProps(componentName)), /*#__PURE__*/React.createElement(FlexGrid, {
|
@@ -386,7 +384,7 @@ export var PageHeader = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
386
384
|
breadcrumbs: breadcrumbs && breadcrumbItemForTitle ? breadcrumbs.concat(breadcrumbItemForTitle) : breadcrumbItemForTitle ? [breadcrumbItemForTitle] : breadcrumbs // breadcrumbs may be null or undefined
|
387
385
|
|
388
386
|
}) : null), /*#__PURE__*/React.createElement(Column, {
|
389
|
-
className: cx(["".concat(blockClass, "__action-bar-column ").concat(blockClass, "__action-bar-column--background"), (
|
387
|
+
className: cx(["".concat(blockClass, "__action-bar-column ").concat(blockClass, "__action-bar-column--background"), (_ref8 = {}, _defineProperty(_ref8, "".concat(blockClass, "__action-bar-column--has-page-actions"), pageActions), _defineProperty(_ref8, "".concat(blockClass, "__action-bar-column--influenced-by-collapse-button"), spaceForCollapseButton), _ref8)])
|
390
388
|
}, /*#__PURE__*/React.createElement("div", {
|
391
389
|
className: "".concat(blockClass, "__action-bar-column-content"),
|
392
390
|
ref: sizingContainerRef
|
@@ -543,8 +541,8 @@ PageHeader.propTypes = _objectSpread({
|
|
543
541
|
*
|
544
542
|
* NOTE: This prop is required if actionBarItems are supplied
|
545
543
|
*/
|
546
|
-
actionBarOverflowAriaLabel: PropTypes.string.isRequired.if(function (
|
547
|
-
var actionBarItems =
|
544
|
+
actionBarOverflowAriaLabel: PropTypes.string.isRequired.if(function (_ref10) {
|
545
|
+
var actionBarItems = _ref10.actionBarItems;
|
548
546
|
return actionBarItems && actionBarItems.length > 0;
|
549
547
|
}),
|
550
548
|
|
@@ -579,8 +577,8 @@ PageHeader.propTypes = _objectSpread({
|
|
579
577
|
* If the user supplies breadcrumbs then this property is required.
|
580
578
|
* It is used in an overflow menu when there is insufficient space to display all breadcrumbs inline.
|
581
579
|
*/
|
582
|
-
breadcrumbOverflowAriaLabel: PropTypes.string.isRequired.if(function (
|
583
|
-
var breadcrumbs =
|
580
|
+
breadcrumbOverflowAriaLabel: PropTypes.string.isRequired.if(function (_ref11) {
|
581
|
+
var breadcrumbs = _ref11.breadcrumbs;
|
584
582
|
return breadcrumbs && breadcrumbs.length > 0;
|
585
583
|
}),
|
586
584
|
|
@@ -619,8 +617,8 @@ PageHeader.propTypes = _objectSpread({
|
|
619
617
|
/**
|
620
618
|
* A text version of the `label` for display, required if `label` is not a string.
|
621
619
|
*/
|
622
|
-
title: PropTypes.string.isRequired.if(function (
|
623
|
-
var label =
|
620
|
+
title: PropTypes.string.isRequired.if(function (_ref12) {
|
621
|
+
var label = _ref12.label;
|
624
622
|
return typeof label !== 'string';
|
625
623
|
})
|
626
624
|
})),
|
@@ -650,9 +648,9 @@ PageHeader.propTypes = _objectSpread({
|
|
650
648
|
* If `hasCollapseHeaderToggle` is set and `withoutBackground` is unset/falsy then assistive text is
|
651
649
|
* required for both the expend and collapse states of the button component used.
|
652
650
|
*/
|
653
|
-
collapseHeaderIconDescription: PropTypes.string.isRequired.if(function (
|
654
|
-
var withoutBackground =
|
655
|
-
hasCollapseHeaderToggle =
|
651
|
+
collapseHeaderIconDescription: PropTypes.string.isRequired.if(function (_ref13) {
|
652
|
+
var withoutBackground = _ref13.withoutBackground,
|
653
|
+
hasCollapseHeaderToggle = _ref13.hasCollapseHeaderToggle;
|
656
654
|
return !withoutBackground && hasCollapseHeaderToggle;
|
657
655
|
}),
|
658
656
|
|
@@ -672,9 +670,9 @@ PageHeader.propTypes = _objectSpread({
|
|
672
670
|
* If `hasCollapseHeaderToggle` is set and `withoutBackground` is unset/falsy then assistive text is
|
673
671
|
* required for both the expend and collapse states of the button component used.
|
674
672
|
*/
|
675
|
-
expandHeaderIconDescription: PropTypes.string.isRequired.if(function (
|
676
|
-
var withoutBackground =
|
677
|
-
hasCollapseHeaderToggle =
|
673
|
+
expandHeaderIconDescription: PropTypes.string.isRequired.if(function (_ref14) {
|
674
|
+
var withoutBackground = _ref14.withoutBackground,
|
675
|
+
hasCollapseHeaderToggle = _ref14.hasCollapseHeaderToggle;
|
678
676
|
return !withoutBackground && hasCollapseHeaderToggle;
|
679
677
|
}),
|
680
678
|
|
@@ -745,8 +743,8 @@ PageHeader.propTypes = _objectSpread({
|
|
745
743
|
*
|
746
744
|
* NOTE: This prop is required if pageActions are supplied
|
747
745
|
*/
|
748
|
-
pageActionsOverflowLabel: PropTypes.node.isRequired.if(function (
|
749
|
-
var pageActions =
|
746
|
+
pageActionsOverflowLabel: PropTypes.node.isRequired.if(function (_ref15) {
|
747
|
+
var pageActions = _ref15.pageActions;
|
750
748
|
return pageActions && pageActions.length > 0 && !pageActions.content;
|
751
749
|
}),
|
752
750
|
|
@@ -809,14 +807,17 @@ PageHeader.propTypes = _objectSpread({
|
|
809
807
|
loading: PropTypes.bool,
|
810
808
|
// inline edit version properties
|
811
809
|
editableLabel: PropTypes.string,
|
812
|
-
// .isRequired.if(
|
810
|
+
// .isRequired.if(editInPlaceRequired),
|
813
811
|
id: PropTypes.string,
|
814
|
-
// .isRequired.if(
|
812
|
+
// .isRequired.if(editInPlaceRequired),
|
813
|
+
onCancel: PropTypes.func,
|
815
814
|
onChange: PropTypes.func,
|
816
815
|
onSave: PropTypes.func,
|
817
816
|
cancelDescription: PropTypes.string,
|
818
|
-
//.isRequired.if(
|
819
|
-
|
817
|
+
//.isRequired.if(editInPlaceRequired),
|
818
|
+
editDescription: PropTypes.string,
|
819
|
+
// .isRequired.if(editInPlaceRequired),
|
820
|
+
saveDescription: PropTypes.string //.isRequired.if(editInPlaceRequired),
|
820
821
|
// Update docgen if changed
|
821
822
|
|
822
823
|
}), PropTypes.string, PropTypes.shape({
|
@@ -1,12 +1,12 @@
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
2
2
|
import _extends from "@babel/runtime/helpers/extends";
|
3
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
4
|
-
var _excluded = ["text", "content", "loading", "icon", "asText", "onChange", "onSave", "editDescription", "editableLabel", "
|
4
|
+
var _excluded = ["text", "content", "loading", "icon", "asText", "onChange", "onSave", "editDescription", "editableLabel", "cancelDescription", "saveDescription"];
|
5
5
|
import React from 'react';
|
6
6
|
import PropTypes from 'prop-types';
|
7
7
|
import cx from 'classnames';
|
8
8
|
import { SkeletonText } from '@carbon/react';
|
9
|
-
import {
|
9
|
+
import { EditInPlace } from '../';
|
10
10
|
/**
|
11
11
|
*
|
12
12
|
* Utility component used by Page Header
|
@@ -29,7 +29,7 @@ export var PageHeaderTitle = function PageHeaderTitle(_ref) {
|
|
29
29
|
onSave = title.onSave,
|
30
30
|
editDescription = title.editDescription,
|
31
31
|
editableLabel = title.editableLabel,
|
32
|
-
|
32
|
+
cancelDescription = title.cancelDescription,
|
33
33
|
saveDescription = title.saveDescription,
|
34
34
|
rest = _objectWithoutProperties(title, _excluded);
|
35
35
|
|
@@ -47,17 +47,17 @@ export var PageHeaderTitle = function PageHeaderTitle(_ref) {
|
|
47
47
|
className: "".concat(blockClass, "__title-icon")
|
48
48
|
}) : null, loading ? /*#__PURE__*/React.createElement(SkeletonText, {
|
49
49
|
className: "".concat(blockClass, "__title-skeleton")
|
50
|
-
}) : isEditable ? /*#__PURE__*/React.createElement(
|
51
|
-
|
52
|
-
hideLabel: true,
|
50
|
+
}) : isEditable ? /*#__PURE__*/React.createElement(EditInPlace, _extends({
|
51
|
+
tooltipAlignment: "bottom",
|
53
52
|
value: text,
|
54
|
-
|
53
|
+
cancelLabel: cancelDescription,
|
54
|
+
editLabel: editDescription,
|
55
|
+
saveLabel: saveDescription,
|
56
|
+
labelText: editableLabel,
|
55
57
|
onChange: onChange,
|
56
58
|
onSave: onSave,
|
57
|
-
|
58
|
-
|
59
|
-
saveDescription: saveDescription,
|
60
|
-
buttonTooltipPosition: "bottom"
|
59
|
+
size: "md",
|
60
|
+
inheritTypography: true
|
61
61
|
}, rest)) : /*#__PURE__*/React.createElement("span", {
|
62
62
|
title: !loading ? asText : null
|
63
63
|
}, text));
|
@@ -71,7 +71,7 @@ export var PageHeaderTitle = function PageHeaderTitle(_ref) {
|
|
71
71
|
title: titleText
|
72
72
|
}, titleInnards);
|
73
73
|
};
|
74
|
-
export var
|
74
|
+
export var editInPlaceRequired = function editInPlaceRequired(_ref2) {
|
75
75
|
var onSave = _ref2.onSave;
|
76
76
|
return !!onSave;
|
77
77
|
};
|
@@ -97,7 +97,7 @@ PageHeaderTitle.propTypes = {
|
|
97
97
|
* - onSave: function to process a confirmed change
|
98
98
|
* - editDescription: description for edit button
|
99
99
|
* - editableLabel: label for edit required if onSave supplied
|
100
|
-
* -
|
100
|
+
* - cancelDescription: description for edit cancel button
|
101
101
|
* - saveDescription: description for edit save button
|
102
102
|
* - 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.
|
103
103
|
* - content: title or name of current location shown in main part of page header
|
@@ -110,13 +110,13 @@ PageHeaderTitle.propTypes = {
|
|
110
110
|
icon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
111
111
|
loading: PropTypes.bool,
|
112
112
|
// inline edit version properties
|
113
|
-
editDescription: PropTypes.string.isRequired.if(
|
114
|
-
editableLabel: PropTypes.string.isRequired.if(
|
115
|
-
id: PropTypes.string.isRequired.if(
|
113
|
+
editDescription: PropTypes.string.isRequired.if(editInPlaceRequired),
|
114
|
+
editableLabel: PropTypes.string.isRequired.if(editInPlaceRequired),
|
115
|
+
id: PropTypes.string.isRequired.if(editInPlaceRequired),
|
116
116
|
onChange: PropTypes.func,
|
117
117
|
onSave: PropTypes.func,
|
118
|
-
|
119
|
-
saveDescription: PropTypes.string.isRequired.if(
|
118
|
+
cancelDescription: PropTypes.string.isRequired.if(editInPlaceRequired),
|
119
|
+
saveDescription: PropTypes.string.isRequired.if(editInPlaceRequired) // Update docgen if changed
|
120
120
|
|
121
121
|
}), PropTypes.string, PropTypes.shape({
|
122
122
|
content: PropTypes.node.isRequired,
|
@@ -21,7 +21,7 @@ import { motion, AnimatePresence } from 'framer-motion'; // Other standard impor
|
|
21
21
|
|
22
22
|
import PropTypes from 'prop-types';
|
23
23
|
import cx from 'classnames';
|
24
|
-
import {
|
24
|
+
import { useResizeObserver } from '../../global/js/hooks/useResizeObserver';
|
25
25
|
import { moderate02 } from '@carbon/motion';
|
26
26
|
import { getDevtoolsProps } from '../../global/js/utils/devtools';
|
27
27
|
import { allPropTypes } from '../../global/js/utils/props-helper';
|
@@ -51,7 +51,7 @@ var defaults = {
|
|
51
51
|
*/
|
52
52
|
|
53
53
|
export var SidePanel = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
54
|
-
var _window,
|
54
|
+
var _window, _ref5, _cx4;
|
55
55
|
|
56
56
|
var actionToolbarButtons = _ref.actionToolbarButtons,
|
57
57
|
actions = _ref.actions,
|
@@ -172,9 +172,10 @@ export var SidePanel = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
172
172
|
}, [labelText, title]);
|
173
173
|
/* istanbul ignore next */
|
174
174
|
|
175
|
-
var handleResize = function handleResize(
|
175
|
+
var handleResize = function handleResize(_ref2) {
|
176
176
|
var _sidePanelOuter$style3;
|
177
177
|
|
178
|
+
var height = _ref2.height;
|
178
179
|
setPanelHeight(height);
|
179
180
|
var sidePanelOuter = document.querySelector("#".concat(blockClass, "-outer"));
|
180
181
|
var actionsContainer = getActionsContainerElement();
|
@@ -371,9 +372,9 @@ export var SidePanel = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
371
372
|
|
372
373
|
/* istanbul ignore next */
|
373
374
|
|
374
|
-
var handleBlur = function handleBlur(
|
375
|
-
var oldActiveNode =
|
376
|
-
currentActiveNode =
|
375
|
+
var handleBlur = function handleBlur(_ref3) {
|
376
|
+
var oldActiveNode = _ref3.target,
|
377
|
+
currentActiveNode = _ref3.relatedTarget;
|
377
378
|
|
378
379
|
// focus trap should only be set if the side panel is a `slideOver` type
|
379
380
|
if (open && sidePanelInnerRef && !slideIn) {
|
@@ -388,7 +389,7 @@ export var SidePanel = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
388
389
|
};
|
389
390
|
|
390
391
|
var primaryActionContainerClassNames = cx(["".concat(blockClass, "__actions-container"), _defineProperty({}, "".concat(blockClass, "__actions-container-condensed"), condensedActions)]);
|
391
|
-
var mainPanelClassNames = cx([blockClass, className, "".concat(blockClass, "__container"), "".concat(blockClass, "__container--").concat(size), (
|
392
|
+
var mainPanelClassNames = cx([blockClass, className, "".concat(blockClass, "__container"), "".concat(blockClass, "__container--").concat(size), (_ref5 = {}, _defineProperty(_ref5, "".concat(blockClass, "__container-right-placement"), placement === 'right'), _defineProperty(_ref5, "".concat(blockClass, "__container-left-placement"), placement === 'left'), _defineProperty(_ref5, "".concat(blockClass, "__container-with-action-toolbar"), actionToolbarButtons && actionToolbarButtons.length), _defineProperty(_ref5, "".concat(blockClass, "__container-without-overlay"), !includeOverlay && !slideIn), _defineProperty(_ref5, "".concat(blockClass, "__container-is-animating"), !animationComplete || !open), _ref5)]);
|
392
393
|
|
393
394
|
var renderHeader = function renderHeader() {
|
394
395
|
var _cx, _cx2;
|
@@ -427,17 +428,17 @@ export var SidePanel = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
427
428
|
className: cx("".concat(blockClass, "__subtitle-text"), (_cx2 = {}, _defineProperty(_cx2, "".concat(blockClass, "__subtitle-text-no-animation"), !animateTitle), _defineProperty(_cx2, "".concat(blockClass, "__subtitle-text-no-animation-no-action-toolbar"), !animateTitle && (!actionToolbarButtons || !actionToolbarButtons.length)), _defineProperty(_cx2, "".concat(blockClass, "__subtitle-text-is-animating"), !animationComplete && animateTitle), _defineProperty(_cx2, "".concat(blockClass, "__subtitle-without-title"), !title), _cx2))
|
428
429
|
}, subtitle), actionToolbarButtons && actionToolbarButtons.length && /*#__PURE__*/React.createElement("div", {
|
429
430
|
className: cx("".concat(blockClass, "__action-toolbar"), _defineProperty({}, "".concat(blockClass, "__action-toolbar-no-animation"), !animateTitle))
|
430
|
-
}, actionToolbarButtons.map(function (
|
431
|
-
var label =
|
432
|
-
kind =
|
433
|
-
icon =
|
434
|
-
tooltipPosition =
|
435
|
-
tooltipAlignment =
|
436
|
-
leading =
|
437
|
-
disabled =
|
438
|
-
className =
|
439
|
-
onClick =
|
440
|
-
rest = _objectWithoutProperties(
|
431
|
+
}, actionToolbarButtons.map(function (_ref6) {
|
432
|
+
var label = _ref6.label,
|
433
|
+
kind = _ref6.kind,
|
434
|
+
icon = _ref6.icon,
|
435
|
+
tooltipPosition = _ref6.tooltipPosition,
|
436
|
+
tooltipAlignment = _ref6.tooltipAlignment,
|
437
|
+
leading = _ref6.leading,
|
438
|
+
disabled = _ref6.disabled,
|
439
|
+
className = _ref6.className,
|
440
|
+
onClick = _ref6.onClick,
|
441
|
+
rest = _objectWithoutProperties(_ref6, _excluded2);
|
441
442
|
|
442
443
|
return /*#__PURE__*/React.createElement(Button, _extends({}, rest, {
|
443
444
|
key: label,
|
@@ -468,10 +469,8 @@ export var SidePanel = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
468
469
|
};
|
469
470
|
|
470
471
|
var contentRef = ref || sidePanelRef;
|
471
|
-
|
472
|
-
|
473
|
-
onResize: handleResize,
|
474
|
-
targetRef: contentRef
|
472
|
+
useResizeObserver(contentRef, {
|
473
|
+
callback: handleResize
|
475
474
|
});
|
476
475
|
return /*#__PURE__*/React.createElement(AnimatePresence, null, open && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(motion.div, _extends({}, getDevtoolsProps(componentName), rest, {
|
477
476
|
id: "".concat(blockClass, "-outer"),
|
@@ -640,8 +639,8 @@ SidePanel.propTypes = {
|
|
640
639
|
* This is the selector to the element that contains all of the page content that will shrink if the panel is a slide in.
|
641
640
|
* This prop is required when using the `slideIn` variant of the side panel.
|
642
641
|
*/
|
643
|
-
selectorPageContent: PropTypes.string.isRequired.if(function (
|
644
|
-
var slideIn =
|
642
|
+
selectorPageContent: PropTypes.string.isRequired.if(function (_ref8) {
|
643
|
+
var slideIn = _ref8.slideIn;
|
645
644
|
return slideIn;
|
646
645
|
}),
|
647
646
|
|
@@ -669,8 +668,8 @@ SidePanel.propTypes = {
|
|
669
668
|
/**
|
670
669
|
* Sets the title text
|
671
670
|
*/
|
672
|
-
title: PropTypes.string.isRequired.if(function (
|
673
|
-
var labelText =
|
671
|
+
title: PropTypes.string.isRequired.if(function (_ref9) {
|
672
|
+
var labelText = _ref9.labelText;
|
674
673
|
return labelText;
|
675
674
|
})
|
676
675
|
};
|
@@ -23,7 +23,7 @@ import cx from 'classnames';
|
|
23
23
|
import { TagSetOverflow } from './TagSetOverflow';
|
24
24
|
import { TagSetModal } from './TagSetModal';
|
25
25
|
import { Tag } from '@carbon/react';
|
26
|
-
import {
|
26
|
+
import { useResizeObserver } from '../../global/js/hooks/useResizeObserver';
|
27
27
|
import { getDevtoolsProps } from '../../global/js/utils/devtools';
|
28
28
|
import { prepareProps, isRequiredIf } from '../../global/js/utils/props-helper';
|
29
29
|
import { pkg } from '../../settings';
|
@@ -222,13 +222,11 @@ export var TagSet = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
222
222
|
setShowAllModalOpen(false);
|
223
223
|
};
|
224
224
|
|
225
|
-
|
226
|
-
|
227
|
-
targetRef: sizingContainerRef
|
225
|
+
useResizeObserver(sizingContainerRef, {
|
226
|
+
callback: handleSizerTagsResize
|
228
227
|
});
|
229
|
-
|
230
|
-
|
231
|
-
targetRef: tagSetRef
|
228
|
+
useResizeObserver(tagSetRef, {
|
229
|
+
callback: handleResize
|
232
230
|
});
|
233
231
|
return /*#__PURE__*/React.createElement("div", _extends({}, rest, {
|
234
232
|
className: cx([blockClass, className]),
|
@@ -17,7 +17,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
17
17
|
// Import portions of React that are needed.
|
18
18
|
import React, { useEffect, useState, useRef } from 'react';
|
19
19
|
import { createPortal } from 'react-dom';
|
20
|
-
import {
|
20
|
+
import { useResizeObserver } from '../../global/js/hooks/useResizeObserver'; // Other standard imports.
|
21
21
|
|
22
22
|
import PropTypes from 'prop-types';
|
23
23
|
import cx from 'classnames';
|
@@ -91,13 +91,11 @@ export var TearsheetShell = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
91
91
|
}
|
92
92
|
}, [portalTargetIn]);
|
93
93
|
var localRef = useRef();
|
94
|
+
var resizer = useRef(null);
|
94
95
|
var modalRef = ref || localRef;
|
95
96
|
|
96
|
-
var
|
97
|
-
|
98
|
-
}),
|
99
|
-
width = _useResizeDetector.width,
|
100
|
-
resizer = _useResizeDetector.ref;
|
97
|
+
var _useResizeObserver = useResizeObserver(resizer),
|
98
|
+
width = _useResizeObserver.width;
|
101
99
|
|
102
100
|
var wide = size === 'wide'; // Keep track of the stack depth and our position in it (1-based, 0=closed)
|
103
101
|
|
package/es/components/index.js
CHANGED
@@ -35,7 +35,7 @@ export { UserProfileImage } from './UserProfileImage';
|
|
35
35
|
export { WebTerminal, WebTerminalContentWrapper, useWebTerminal, WebTerminalProvider } from './WebTerminal';
|
36
36
|
export { EditSidePanel } from './EditSidePanel';
|
37
37
|
export { OptionsTile } from './OptionsTile';
|
38
|
-
export {
|
38
|
+
export { EditInPlace } from './EditInPlace';
|
39
39
|
export { DataSpreadsheet } from './DataSpreadsheet';
|
40
40
|
export { Datagrid, useDatagrid, useInfiniteScroll, useNestedRows, useSelectRows, useExpandedRow, useOnRowClick, useSortableColumns, useRowIsMouseOver, useColumnCenterAlign, useColumnRightAlign, useDisableSelectRows, useStickyColumn, useActionsColumn, useCustomizeColumns, useSelectAllWithToggle, useColumnOrder, useInlineEdit, useFiltering, getAutoSizedColumnWidth } from './Datagrid';
|
41
41
|
export { EditTearsheet } from './EditTearsheet';
|
@@ -0,0 +1,79 @@
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
2
|
+
|
3
|
+
/**
|
4
|
+
* Copyright IBM Corp. 2023, 2023
|
5
|
+
*
|
6
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
8
|
+
*/
|
9
|
+
import { useRef, useState, useLayoutEffect } from 'react';
|
10
|
+
export var useResizeObserver = function useResizeObserver(ref) {
|
11
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
12
|
+
callback: null,
|
13
|
+
throttleInterval: 0
|
14
|
+
};
|
15
|
+
var callback = options.callback,
|
16
|
+
throttleInterval = options.throttleInterval;
|
17
|
+
|
18
|
+
var _useState = useState(0),
|
19
|
+
_useState2 = _slicedToArray(_useState, 2),
|
20
|
+
width = _useState2[0],
|
21
|
+
setWidth = _useState2[1];
|
22
|
+
|
23
|
+
var _useState3 = useState(0),
|
24
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
25
|
+
height = _useState4[0],
|
26
|
+
setHeight = _useState4[1];
|
27
|
+
|
28
|
+
var throttleTimeout = useRef(null);
|
29
|
+
var entriesToHandle = useRef(null);
|
30
|
+
useLayoutEffect(function () {
|
31
|
+
if (!(ref !== null && ref !== void 0 && ref.current)) {
|
32
|
+
return;
|
33
|
+
}
|
34
|
+
|
35
|
+
var doCallbacks = function doCallbacks() {
|
36
|
+
if (!(ref !== null && ref !== void 0 && ref.current) || !Array.isArray(entriesToHandle === null || entriesToHandle === void 0 ? void 0 : entriesToHandle.current)) {
|
37
|
+
return;
|
38
|
+
}
|
39
|
+
|
40
|
+
var entry = entriesToHandle.current[0];
|
41
|
+
setWidth(entry.contentRect.width);
|
42
|
+
setHeight(entry.contentRect.height);
|
43
|
+
throttleTimeout.current = null;
|
44
|
+
callback && callback(entry.contentRect);
|
45
|
+
};
|
46
|
+
|
47
|
+
var observer = new ResizeObserver(function (entries) {
|
48
|
+
// always update entriesToHandle
|
49
|
+
entriesToHandle.current = entries;
|
50
|
+
|
51
|
+
if (throttleInterval) {
|
52
|
+
// if a throttleInterval check for running timeout
|
53
|
+
if (throttleTimeout.current === null) {
|
54
|
+
// no live timeout set entries to handle and move on
|
55
|
+
// set up throttle
|
56
|
+
throttleTimeout.current = setTimeout(function () {
|
57
|
+
// do callbacks
|
58
|
+
doCallbacks(); // reset throttle
|
59
|
+
|
60
|
+
throttleTimeout.current = null;
|
61
|
+
}, throttleInterval);
|
62
|
+
}
|
63
|
+
} else {
|
64
|
+
// no throttle do callbacks every time
|
65
|
+
doCallbacks();
|
66
|
+
}
|
67
|
+
}); // observe all refs passed
|
68
|
+
|
69
|
+
observer.observe(ref.current);
|
70
|
+
return function () {
|
71
|
+
observer.disconnect();
|
72
|
+
observer = null;
|
73
|
+
}; // eslint-disable-next-line react-hooks/exhaustive-deps
|
74
|
+
}, [ref, options]);
|
75
|
+
return {
|
76
|
+
width: width,
|
77
|
+
height: height
|
78
|
+
};
|
79
|
+
};
|
@@ -5,6 +5,12 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
5
5
|
|
6
6
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
7
7
|
|
8
|
+
/**
|
9
|
+
* Copyright IBM Corp. 2022, 2023
|
10
|
+
*
|
11
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
12
|
+
* LICENSE file in the root directory of this source tree.
|
13
|
+
*/
|
8
14
|
import { useRef, useLayoutEffect } from 'react';
|
9
15
|
var windowExists = (typeof window === "undefined" ? "undefined" : _typeof(window)) !== "undefined";
|
10
16
|
|
@@ -1,4 +1,11 @@
|
|
1
1
|
import _typeof from "@babel/runtime/helpers/typeof";
|
2
|
+
|
3
|
+
/**
|
4
|
+
* Copyright IBM Corp. 2022, 2023
|
5
|
+
*
|
6
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
8
|
+
*/
|
2
9
|
import { useRef, useLayoutEffect } from 'react';
|
3
10
|
import { scrollableAncestor } from '../utils/scrollableAncestor';
|
4
11
|
var windowExists = (typeof window === "undefined" ? "undefined" : _typeof(window)) !== "undefined";
|
@@ -27,6 +27,7 @@ var defaults = {
|
|
27
27
|
CreateTearsheet: true,
|
28
28
|
CreateTearsheetStep: true,
|
29
29
|
CreateTearsheetDivider: true,
|
30
|
+
EditInPlace: true,
|
30
31
|
EmptyState: true,
|
31
32
|
ErrorEmptyState: true,
|
32
33
|
ExportModal: true,
|
@@ -35,8 +36,6 @@ var defaults = {
|
|
35
36
|
HTTPError404: true,
|
36
37
|
HTTPErrorOther: true,
|
37
38
|
ImportModal: true,
|
38
|
-
InlineEdit: true,
|
39
|
-
InlineEditV1: true,
|
40
39
|
MultiAddSelect: true,
|
41
40
|
NotificationsPanel: true,
|
42
41
|
NoDataEmptyState: true,
|
@@ -71,8 +70,7 @@ var defaults = {
|
|
71
70
|
EditTearsheet: false,
|
72
71
|
EditTearsheetNarrow: false,
|
73
72
|
EditFullPage: false,
|
74
|
-
EditUpdateCards: false
|
75
|
-
InlineEditV2: false
|
73
|
+
EditUpdateCards: false
|
76
74
|
/* new component flags here - comment used by generate CLI */
|
77
75
|
|
78
76
|
},
|
@@ -19,7 +19,7 @@ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/h
|
|
19
19
|
|
20
20
|
var _react = _interopRequireWildcard(require("react"));
|
21
21
|
|
22
|
-
var
|
22
|
+
var _useResizeObserver = require("../../global/js/hooks/useResizeObserver");
|
23
23
|
|
24
24
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
25
25
|
|
@@ -94,9 +94,8 @@ var AboutModal = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
|
|
94
94
|
bodyRef.current = contentRef.current.parentElement;
|
95
95
|
}, [bodyRef]); // Detect resize of the ModalBody to recalculate whether scrolling is enabled
|
96
96
|
|
97
|
-
(0,
|
98
|
-
|
99
|
-
targetRef: bodyRef
|
97
|
+
(0, _useResizeObserver.useResizeObserver)(bodyRef, {
|
98
|
+
callback: handleResize
|
100
99
|
});
|
101
100
|
return /*#__PURE__*/_react.default.createElement(_react2.ComposedModal, (0, _extends2.default)({}, rest, {
|
102
101
|
className: (0, _classnames.default)(blockClass, // Apply the block class to the main HTML element
|