@carbon/ibm-products 2.0.0-rc.3 → 2.0.0-rc.4
Sign up to get free protection for your applications and to get access to all the features.
- package/css/index-full-carbon.css +63 -157
- package/css/index-full-carbon.css.map +1 -1
- package/css/index-full-carbon.min.css +3 -9
- package/css/index-full-carbon.min.css.map +1 -1
- package/css/index-without-carbon-released-only.css +8 -151
- package/css/index-without-carbon-released-only.css.map +1 -1
- package/css/index-without-carbon-released-only.min.css +3 -9
- package/css/index-without-carbon-released-only.min.css.map +1 -1
- package/css/index-without-carbon.css +63 -157
- package/css/index-without-carbon.css.map +1 -1
- package/css/index-without-carbon.min.css +3 -9
- package/css/index-without-carbon.min.css.map +1 -1
- package/css/index.css +63 -157
- package/css/index.css.map +1 -1
- package/css/index.min.css +3 -9
- package/css/index.min.css.map +1 -1
- package/es/components/AddSelect/AddSelectBody.js +2 -2
- package/es/components/CreateTearsheetNarrow/CreateTearsheetNarrow.js +2 -2
- package/es/components/Datagrid/Datagrid/DatagridContent.js +9 -4
- package/es/components/Datagrid/Datagrid/DatagridVirtualBody.js +2 -1
- package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/ButtonWrapper.js +3 -0
- package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/Columns.js +10 -9
- package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/CustomizeColumnsModal.js +1 -2
- package/es/components/Datagrid/useInfiniteScroll.js +5 -2
- package/es/components/Datagrid/utils/getArgTypes.js +4 -0
- package/es/components/EditUpdateCards/EditUpdateCards.js +144 -0
- package/es/components/EditUpdateCards/index.js +7 -0
- package/es/components/PageHeader/PageHeaderTitle.js +3 -1
- package/es/components/SidePanel/SidePanel.js +44 -51
- package/es/components/SidePanel/motion/variants.js +45 -0
- package/es/components/index.js +2 -1
- package/es/global/js/package-settings.js +2 -1
- package/es/global/js/utils/getBezierValues.js +20 -0
- package/es/global/js/utils/motionConstants.js +45 -0
- package/lib/components/AddSelect/AddSelectBody.js +2 -2
- package/lib/components/CreateTearsheetNarrow/CreateTearsheetNarrow.js +2 -2
- package/lib/components/Datagrid/Datagrid/DatagridContent.js +8 -3
- package/lib/components/Datagrid/Datagrid/DatagridVirtualBody.js +2 -1
- package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/ButtonWrapper.js +3 -0
- package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/Columns.js +9 -8
- package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/CustomizeColumnsModal.js +1 -2
- package/lib/components/Datagrid/useInfiniteScroll.js +5 -2
- package/lib/components/Datagrid/utils/getArgTypes.js +4 -0
- package/lib/components/EditUpdateCards/EditUpdateCards.js +152 -0
- package/lib/components/EditUpdateCards/index.js +13 -0
- package/lib/components/PageHeader/PageHeaderTitle.js +3 -1
- package/lib/components/SidePanel/SidePanel.js +45 -50
- package/lib/components/SidePanel/motion/variants.js +55 -0
- package/lib/components/index.js +9 -1
- package/lib/global/js/package-settings.js +2 -1
- package/lib/global/js/utils/getBezierValues.js +29 -0
- package/lib/global/js/utils/motionConstants.js +55 -0
- package/package.json +5 -3
- package/scss/components/AddSelect/_add-select.scss +2 -2
- package/scss/components/Datagrid/_storybook-styles.scss +4 -0
- package/scss/components/Datagrid/styles/_useInlineEdit.scss +20 -5
- package/scss/components/Datagrid/styles/addons/_CustomizeColumnsModal.scss +2 -0
- package/scss/components/EditUpdateCards/_carbon-imports.scss +9 -0
- package/scss/components/EditUpdateCards/_edit-update-cards.scss +85 -0
- package/scss/components/EditUpdateCards/_index-with-carbon.scss +9 -0
- package/scss/components/EditUpdateCards/_index.scss +8 -0
- package/scss/components/EditUpdateCards/_storybook-styles.scss +55 -0
- package/scss/components/PageHeader/_page-header.scss +4 -0
- package/scss/components/SidePanel/_side-panel.scss +2 -78
- package/scss/components/SidePanel/_storybook-styles.scss +6 -1
- package/scss/components/_index-with-carbon.scss +1 -0
- package/scss/components/_index.scss +1 -0
@@ -0,0 +1,144 @@
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
3
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
4
|
+
var _excluded = ["actionIcons", "actionsPlacement", "className", "description", "editChildren", "editMode", "label", "previewChildren", "title", "titleSize"];
|
5
|
+
|
6
|
+
/**
|
7
|
+
* Copyright IBM Corp. 2022, 2022
|
8
|
+
*
|
9
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
10
|
+
* LICENSE file in the root directory of this source tree.
|
11
|
+
*/
|
12
|
+
// Import portions of React that are needed.
|
13
|
+
import React from 'react'; // Other standard imports.
|
14
|
+
|
15
|
+
import PropTypes from 'prop-types';
|
16
|
+
import cx from 'classnames';
|
17
|
+
import { getDevtoolsProps } from '../../global/js/utils/devtools';
|
18
|
+
import { pkg
|
19
|
+
/*, carbon */
|
20
|
+
} from '../../settings';
|
21
|
+
import { ProductiveCard } from '../ProductiveCard'; // import { children } from 'cheerio/lib/api/traversing';
|
22
|
+
// Carbon and package components we use.
|
23
|
+
|
24
|
+
/* TODO: @import(s) of carbon components and other package components. */
|
25
|
+
// The block part of our conventional BEM class names (blockClass__E--M).
|
26
|
+
|
27
|
+
var blockClass = "".concat(pkg.prefix, "--edit-update-cards");
|
28
|
+
var componentName = 'EditUpdateCards'; // NOTE: the component SCSS is not imported here: it is rolled up separately.
|
29
|
+
// Default values can be included here and then assigned to the prop params,
|
30
|
+
// e.g. prop = defaults.prop,
|
31
|
+
// This gathers default values together neatly and ensures non-primitive
|
32
|
+
// values are initialized early to avoid react making unnecessary re-renders.
|
33
|
+
// Note that default values are not required for props that are 'required',
|
34
|
+
// nor for props where the component can apply undefined values reasonably.
|
35
|
+
// Default values should be provided when the component needs to make a choice
|
36
|
+
// or assumption when a prop is not supplied.
|
37
|
+
// Default values for props
|
38
|
+
// const defaults = {
|
39
|
+
// /* TODO: add defaults for relevant props if needed */
|
40
|
+
// };
|
41
|
+
|
42
|
+
/**
|
43
|
+
* TODO: A description of the component.
|
44
|
+
*/
|
45
|
+
|
46
|
+
export var EditUpdateCards = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
47
|
+
var actionIcons = _ref.actionIcons,
|
48
|
+
actionsPlacement = _ref.actionsPlacement,
|
49
|
+
className = _ref.className,
|
50
|
+
description = _ref.description,
|
51
|
+
editChildren = _ref.editChildren,
|
52
|
+
editMode = _ref.editMode,
|
53
|
+
label = _ref.label,
|
54
|
+
previewChildren = _ref.previewChildren,
|
55
|
+
title = _ref.title,
|
56
|
+
titleSize = _ref.titleSize,
|
57
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
58
|
+
|
59
|
+
// const [editMode, setEditMode] = useState(false);
|
60
|
+
return /*#__PURE__*/React.createElement("div", _extends({}, rest, {
|
61
|
+
className: cx(blockClass, // Apply the block class to the main HTML element
|
62
|
+
className, // Apply any supplied class names to the main HTML element.
|
63
|
+
// example: `${blockClass}__template-string-class-${kind}-n-${size}`,
|
64
|
+
_defineProperty({}, "".concat(blockClass, "__actions-bottom"), actionsPlacement === 'bottom')),
|
65
|
+
ref: ref,
|
66
|
+
role: "main"
|
67
|
+
}, getDevtoolsProps(componentName)), /*#__PURE__*/React.createElement(ProductiveCard, {
|
68
|
+
actionIcons: actionIcons,
|
69
|
+
actionsPlacement: actionsPlacement,
|
70
|
+
className: className,
|
71
|
+
description: description,
|
72
|
+
label: label,
|
73
|
+
title: title,
|
74
|
+
titleSize: titleSize
|
75
|
+
}, editMode === false && /*#__PURE__*/React.createElement("div", null, previewChildren), editMode && /*#__PURE__*/React.createElement("div", null, editChildren)));
|
76
|
+
}); // Return a placeholder if not released and not enabled by feature flag
|
77
|
+
|
78
|
+
EditUpdateCards = pkg.checkComponentEnabled(EditUpdateCards, componentName); // The display name of the component, used by React. Note that displayName
|
79
|
+
// is used in preference to relying on function.name.
|
80
|
+
|
81
|
+
EditUpdateCards.displayName = componentName; // The types and DocGen commentary for the component props,
|
82
|
+
// in alphabetical order (for consistency).
|
83
|
+
// See https://www.npmjs.com/package/prop-types#usage.
|
84
|
+
|
85
|
+
EditUpdateCards.propTypes = {
|
86
|
+
/**
|
87
|
+
* Icons that are displayed on card. Refer to design documentation for implementation guidelines
|
88
|
+
*/
|
89
|
+
actionIcons: PropTypes.arrayOf(PropTypes.shape({
|
90
|
+
id: PropTypes.string,
|
91
|
+
icon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
92
|
+
onKeyDown: PropTypes.func,
|
93
|
+
onClick: PropTypes.func,
|
94
|
+
iconDescription: PropTypes.string,
|
95
|
+
href: PropTypes.string
|
96
|
+
})),
|
97
|
+
|
98
|
+
/**
|
99
|
+
* Determines if the action icons are on the top or bottom of the card
|
100
|
+
*/
|
101
|
+
actionsPlacement: PropTypes.oneOf(['top', 'bottom']),
|
102
|
+
|
103
|
+
/**
|
104
|
+
* Optional label for the top of the card.
|
105
|
+
*/
|
106
|
+
className: PropTypes.string,
|
107
|
+
|
108
|
+
/**
|
109
|
+
* Optional header description
|
110
|
+
*/
|
111
|
+
description: PropTypes.string,
|
112
|
+
|
113
|
+
/**
|
114
|
+
* Edit mode children
|
115
|
+
*/
|
116
|
+
editChildren: PropTypes.node,
|
117
|
+
|
118
|
+
/**
|
119
|
+
* Edit mode
|
120
|
+
*/
|
121
|
+
editMode: PropTypes.bool,
|
122
|
+
|
123
|
+
/**
|
124
|
+
* Optional label for the top of the card
|
125
|
+
*/
|
126
|
+
label: PropTypes.string,
|
127
|
+
|
128
|
+
/**
|
129
|
+
* Preview mode children
|
130
|
+
*/
|
131
|
+
previewChildren: PropTypes.node,
|
132
|
+
|
133
|
+
/**
|
134
|
+
* Title that's displayed at the top of the card
|
135
|
+
*/
|
136
|
+
title: PropTypes.string,
|
137
|
+
|
138
|
+
/**
|
139
|
+
* Determines title size
|
140
|
+
*/
|
141
|
+
titleSize: PropTypes.oneOf(['default', 'large'])
|
142
|
+
/* TODO: add types and DocGen for all props. */
|
143
|
+
|
144
|
+
};
|
@@ -68,7 +68,9 @@ export var PageHeaderTitle = function PageHeaderTitle(_ref) {
|
|
68
68
|
return /*#__PURE__*/React.createElement("div", {
|
69
69
|
className: cx("".concat(blockClass, "__title"), _defineProperty({}, "".concat(blockClass, "__title--editable"), isEditable), _defineProperty({}, "".concat(blockClass, "__title--fades"), hasBreadcrumbRow)),
|
70
70
|
title: titleText
|
71
|
-
},
|
71
|
+
}, /*#__PURE__*/React.createElement("h1", {
|
72
|
+
className: "".concat(blockClass, "__title-wrapper")
|
73
|
+
}, titleInnards));
|
72
74
|
};
|
73
75
|
export var inlineEditRequired = function inlineEditRequired(_ref2) {
|
74
76
|
var onSave = _ref2.onSave;
|
@@ -16,7 +16,8 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
16
16
|
* LICENSE file in the root directory of this source tree.
|
17
17
|
*/
|
18
18
|
// Import portions of React that are needed.
|
19
|
-
import React, { useState, useEffect, useRef } from 'react';
|
19
|
+
import React, { useState, useEffect, useRef } from 'react';
|
20
|
+
import { motion, AnimatePresence } from 'framer-motion'; // Other standard imports.
|
20
21
|
|
21
22
|
import PropTypes from 'prop-types';
|
22
23
|
import cx from 'classnames';
|
@@ -32,6 +33,7 @@ import { usePreviousValue } from '../../global/js/hooks'; // Carbon and package
|
|
32
33
|
import { Button } from '@carbon/react';
|
33
34
|
import { Close, ArrowLeft } from '@carbon/react/icons';
|
34
35
|
import { ActionSet } from '../ActionSet';
|
36
|
+
import { overlayVariants, panelVariants } from './motion/variants';
|
35
37
|
var blockClass = "".concat(pkg.prefix, "--side-panel");
|
36
38
|
var componentName = 'SidePanel'; // NOTE: the component SCSS is not imported here: it is rolled up separately.
|
37
39
|
// Default values for props
|
@@ -82,20 +84,15 @@ export var SidePanel = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
82
84
|
title = _ref.title,
|
83
85
|
rest = _objectWithoutProperties(_ref, _excluded);
|
84
86
|
|
85
|
-
var _useState = useState(
|
87
|
+
var _useState = useState(false),
|
86
88
|
_useState2 = _slicedToArray(_useState, 2),
|
87
|
-
|
88
|
-
|
89
|
+
animationComplete = _useState2[0],
|
90
|
+
setAnimationComplete = _useState2[1];
|
89
91
|
|
90
|
-
var _useState3 = useState(
|
92
|
+
var _useState3 = useState(0),
|
91
93
|
_useState4 = _slicedToArray(_useState3, 2),
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
var _useState5 = useState(0),
|
96
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
97
|
-
panelHeight = _useState6[0],
|
98
|
-
setPanelHeight = _useState6[1];
|
94
|
+
panelHeight = _useState4[0],
|
95
|
+
setPanelHeight = _useState4[1];
|
99
96
|
|
100
97
|
var sidePanelRef = useRef();
|
101
98
|
var sidePanelOverlayRef = useRef();
|
@@ -125,8 +122,10 @@ export var SidePanel = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
125
122
|
// height css custom property
|
126
123
|
|
127
124
|
if ((previousState === null || previousState === void 0 ? void 0 : previousState.size) !== size) {
|
125
|
+
var _sidePanelOuter$style;
|
126
|
+
|
128
127
|
scrollableSection.scrollTop = 0;
|
129
|
-
sidePanelOuter.style.setProperty("--".concat(blockClass, "--title-container-height"), "".concat(Number(initialTitleHeight), "px"));
|
128
|
+
sidePanelOuter === null || sidePanelOuter === void 0 ? void 0 : (_sidePanelOuter$style = sidePanelOuter.style) === null || _sidePanelOuter$style === void 0 ? void 0 : _sidePanelOuter$style.setProperty("--".concat(blockClass, "--title-container-height"), "".concat(Number(initialTitleHeight), "px"));
|
130
129
|
}
|
131
130
|
}
|
132
131
|
}, [currentStep, ref, size, previousState === null || previousState === void 0 ? void 0 : previousState.size]); // set initial focus when side panel opens
|
@@ -154,12 +153,14 @@ export var SidePanel = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
154
153
|
}, [selectorPrimaryFocus, open, animationComplete]);
|
155
154
|
useEffect(function () {
|
156
155
|
if (open && actions && actions.length && animationComplete) {
|
156
|
+
var _sidePanelOuter$style2;
|
157
|
+
|
157
158
|
var sidePanelOuter = document.querySelector("#".concat(blockClass, "-outer"));
|
158
159
|
var actionsContainer = getActionsContainerElement();
|
159
160
|
var actionsHeight = (actionsContainer === null || actionsContainer === void 0 ? void 0 : actionsContainer.offsetHeight) + 16; // add additional 1rem spacing to bottom padding
|
160
161
|
|
161
162
|
actionsHeight = "".concat(Math.round(actionsHeight / 16), "rem");
|
162
|
-
sidePanelOuter === null || sidePanelOuter === void 0 ? void 0 : sidePanelOuter.style.setProperty("--".concat(blockClass, "--content-bottom-padding"), actionsHeight);
|
163
|
+
sidePanelOuter === null || sidePanelOuter === void 0 ? void 0 : (_sidePanelOuter$style2 = sidePanelOuter.style) === null || _sidePanelOuter$style2 === void 0 ? void 0 : _sidePanelOuter$style2.setProperty("--".concat(blockClass, "--content-bottom-padding"), actionsHeight);
|
163
164
|
}
|
164
165
|
}, [actions, condensedActions, open, animationComplete]); // Add console warning if labelText is provided without a title.
|
165
166
|
// This combination is not allowed.
|
@@ -172,13 +173,15 @@ export var SidePanel = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
172
173
|
/* istanbul ignore next */
|
173
174
|
|
174
175
|
var handleResize = function handleResize(width, height) {
|
176
|
+
var _sidePanelOuter$style3;
|
177
|
+
|
175
178
|
setPanelHeight(height);
|
176
179
|
var sidePanelOuter = document.querySelector("#".concat(blockClass, "-outer"));
|
177
180
|
var actionsContainer = getActionsContainerElement();
|
178
|
-
var actionsHeight = actionsContainer.offsetHeight + 16; // add additional 1rem spacing to bottom padding
|
181
|
+
var actionsHeight = (actionsContainer === null || actionsContainer === void 0 ? void 0 : actionsContainer.offsetHeight) + 16; // add additional 1rem spacing to bottom padding
|
179
182
|
|
180
183
|
actionsHeight = "".concat(Math.round(actionsHeight / 16), "rem");
|
181
|
-
sidePanelOuter.style.setProperty("--".concat(blockClass, "--content-bottom-padding"), actionsHeight);
|
184
|
+
sidePanelOuter === null || sidePanelOuter === void 0 ? void 0 : (_sidePanelOuter$style3 = sidePanelOuter.style) === null || _sidePanelOuter$style3 === void 0 ? void 0 : _sidePanelOuter$style3.setProperty("--".concat(blockClass, "--content-bottom-padding"), actionsHeight);
|
182
185
|
};
|
183
186
|
|
184
187
|
var getActionsContainerElement = function getActionsContainerElement() {
|
@@ -263,7 +266,7 @@ export var SidePanel = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
263
266
|
});
|
264
267
|
}
|
265
268
|
|
266
|
-
if (open &&
|
269
|
+
if (open && !animateTitle) {
|
267
270
|
var _sidePanelOuter = document.querySelector("#".concat(blockClass, "-outer"));
|
268
271
|
|
269
272
|
var _sidePanelTitleElement = document.querySelector(".".concat(blockClass, "__title-container .").concat(blockClass, "__title-text"));
|
@@ -284,7 +287,7 @@ export var SidePanel = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
284
287
|
_sidePanelOuter === null || _sidePanelOuter === void 0 ? void 0 : _sidePanelOuter.style.setProperty("--".concat(blockClass, "--action-bar-container-height"), "".concat(sidePanelActionBarElementHeight, "px"));
|
285
288
|
_sidePanelOuter === null || _sidePanelOuter === void 0 ? void 0 : _sidePanelOuter.style.setProperty("--".concat(blockClass, "--label-text-height"), "".concat(labelHeight, "px"));
|
286
289
|
}
|
287
|
-
}, [open, animateTitle, animationComplete,
|
290
|
+
}, [open, animateTitle, animationComplete, panelHeight, title, size, reducedMotion.matches]); // click outside functionality if `includeOverlay` prop is set
|
288
291
|
|
289
292
|
useEffect(function () {
|
290
293
|
var handleOutsideClick = function handleOutsideClick(event) {
|
@@ -310,18 +313,11 @@ export var SidePanel = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
310
313
|
return function () {
|
311
314
|
document.removeEventListener('click', handleOutsideClick);
|
312
315
|
};
|
313
|
-
}, [includeOverlay, onRequestClose, open, preventCloseOnClickOutside, ref, onUnmount]); //
|
314
|
-
|
315
|
-
useEffect(function () {
|
316
|
-
if (open) {
|
317
|
-
setRender(true);
|
318
|
-
}
|
319
|
-
}, [open]); // initializes the side panel to close
|
316
|
+
}, [includeOverlay, onRequestClose, open, preventCloseOnClickOutside, ref, onUnmount]); // initializes the side panel to close
|
320
317
|
|
321
318
|
var onAnimationEnd = function onAnimationEnd() {
|
322
319
|
if (!open) {
|
323
320
|
onUnmount === null || onUnmount === void 0 ? void 0 : onUnmount();
|
324
|
-
setRender(false);
|
325
321
|
}
|
326
322
|
|
327
323
|
setAnimationComplete(true);
|
@@ -335,13 +331,8 @@ export var SidePanel = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
335
331
|
}
|
336
332
|
}, [reducedMotion.matches]); // initializes the side panel to open
|
337
333
|
|
338
|
-
var _onAnimationStart = function onAnimationStart(
|
339
|
-
|
340
|
-
var isPanelTarget = event.target.id === "".concat(blockClass, "-outer");
|
341
|
-
|
342
|
-
if (isPanelTarget) {
|
343
|
-
setAnimationComplete(false);
|
344
|
-
}
|
334
|
+
var _onAnimationStart = function onAnimationStart() {
|
335
|
+
setAnimationComplete(false);
|
345
336
|
}; // used to reset margins of the slide in panel when closed/closing
|
346
337
|
|
347
338
|
|
@@ -358,13 +349,12 @@ export var SidePanel = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
358
349
|
}, [open, placement, selectorPageContent, slideIn]);
|
359
350
|
useEffect(function () {
|
360
351
|
if (!open && previousState !== null && previousState !== void 0 && previousState.open && reducedMotion.matches) {
|
361
|
-
setRender(false);
|
362
352
|
onUnmount === null || onUnmount === void 0 ? void 0 : onUnmount();
|
363
353
|
}
|
364
354
|
}, [open, onUnmount, reducedMotion.matches, previousState === null || previousState === void 0 ? void 0 : previousState.open]); // used to set margins of content for slide in panel version
|
365
355
|
|
366
356
|
useEffect(function () {
|
367
|
-
if (
|
357
|
+
if (open && slideIn) {
|
368
358
|
var pageContentElement = document.querySelector(selectorPageContent);
|
369
359
|
|
370
360
|
if (placement && placement === 'right' && pageContentElement) {
|
@@ -377,7 +367,7 @@ export var SidePanel = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
377
367
|
pageContentElement.style.marginLeft = SIDE_PANEL_SIZES[size];
|
378
368
|
}
|
379
369
|
}
|
380
|
-
}, [slideIn, selectorPageContent, placement,
|
370
|
+
}, [slideIn, selectorPageContent, placement, size, reducedMotion.matches, open]); // adds focus trap functionality
|
381
371
|
|
382
372
|
/* istanbul ignore next */
|
383
373
|
|
@@ -483,20 +473,22 @@ export var SidePanel = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
483
473
|
onResize: handleResize,
|
484
474
|
targetRef: contentRef
|
485
475
|
});
|
486
|
-
return
|
476
|
+
return /*#__PURE__*/React.createElement(AnimatePresence, null, open && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(motion.div, _extends({}, getDevtoolsProps(componentName), rest, {
|
487
477
|
id: "".concat(blockClass, "-outer"),
|
488
478
|
className: mainPanelClassNames,
|
489
|
-
style: {
|
490
|
-
animation: !reducedMotion.matches ? "".concat(open ? placement === 'right' ? "side-panel-entrance-right ".concat(moderate02) : "side-panel-entrance-left ".concat(moderate02) : placement === 'right' ? "side-panel-exit-right ".concat(moderate02) : "side-panel-exit-left ".concat(moderate02)) : null
|
491
|
-
},
|
492
|
-
onAnimationEnd: onAnimationEnd,
|
493
|
-
onAnimationStart: function onAnimationStart(event) {
|
494
|
-
return _onAnimationStart(event);
|
495
|
-
},
|
496
479
|
onBlur: handleBlur,
|
497
480
|
ref: contentRef,
|
498
481
|
role: "complementary",
|
499
|
-
"aria-label": title
|
482
|
+
"aria-label": title,
|
483
|
+
onAnimationComplete: onAnimationEnd,
|
484
|
+
onAnimationStart: function onAnimationStart(event) {
|
485
|
+
return _onAnimationStart(event);
|
486
|
+
},
|
487
|
+
variants: panelVariants,
|
488
|
+
initial: "hidden",
|
489
|
+
animate: "visible",
|
490
|
+
exit: "exit",
|
491
|
+
custom: placement
|
500
492
|
}), /*#__PURE__*/React.createElement("span", {
|
501
493
|
ref: startTrapRef,
|
502
494
|
tabIndex: "0",
|
@@ -516,13 +508,14 @@ export var SidePanel = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
516
508
|
tabIndex: "0",
|
517
509
|
role: "link",
|
518
510
|
className: "".concat(blockClass, "__visually-hidden")
|
519
|
-
}, "Focus sentinel")), includeOverlay && /*#__PURE__*/React.createElement(
|
511
|
+
}, "Focus sentinel")), /*#__PURE__*/React.createElement(AnimatePresence, null, includeOverlay && /*#__PURE__*/React.createElement(motion.div, {
|
512
|
+
variants: overlayVariants,
|
513
|
+
initial: "hidden",
|
514
|
+
animate: "visible",
|
515
|
+
exit: "exit",
|
520
516
|
ref: sidePanelOverlayRef,
|
521
|
-
className: "".concat(blockClass, "__overlay")
|
522
|
-
|
523
|
-
animation: !reducedMotion.matches ? "".concat(open ? "side-panel-overlay-entrance ".concat(moderate02) : "side-panel-overlay-exit ".concat(moderate02)) : null
|
524
|
-
}
|
525
|
-
}));
|
517
|
+
className: "".concat(blockClass, "__overlay")
|
518
|
+
}))));
|
526
519
|
}); // Return a placeholder if not released and not enabled by feature flag
|
527
520
|
|
528
521
|
SidePanel = pkg.checkComponentEnabled(SidePanel, componentName);
|
@@ -0,0 +1,45 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright IBM Corp. 2022, 2022
|
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
|
+
import { DURATIONS, EASINGS } from '../../../global/js/utils/motionConstants';
|
8
|
+
export var overlayVariants = {
|
9
|
+
visible: {
|
10
|
+
opacity: 1,
|
11
|
+
transition: {
|
12
|
+
duration: DURATIONS.moderate02,
|
13
|
+
ease: EASINGS.productive.standard
|
14
|
+
}
|
15
|
+
},
|
16
|
+
hidden: {
|
17
|
+
opacity: 0
|
18
|
+
},
|
19
|
+
exit: {
|
20
|
+
opacity: 0
|
21
|
+
}
|
22
|
+
};
|
23
|
+
export var panelVariants = {
|
24
|
+
visible: {
|
25
|
+
x: 0,
|
26
|
+
transition: {
|
27
|
+
duration: DURATIONS.moderate02,
|
28
|
+
ease: EASINGS.productive.standard
|
29
|
+
}
|
30
|
+
},
|
31
|
+
hidden: function hidden(placement) {
|
32
|
+
return {
|
33
|
+
x: placement === 'right' ? '100%' : -320
|
34
|
+
};
|
35
|
+
},
|
36
|
+
exit: function exit(placement) {
|
37
|
+
return {
|
38
|
+
x: placement === 'right' ? '100%' : -320,
|
39
|
+
transition: {
|
40
|
+
duration: DURATIONS.moderate01,
|
41
|
+
ease: EASINGS.productive.exit
|
42
|
+
}
|
43
|
+
};
|
44
|
+
}
|
45
|
+
};
|
package/es/components/index.js
CHANGED
@@ -40,4 +40,5 @@ export { DataSpreadsheet } from './DataSpreadsheet';
|
|
40
40
|
export { Datagrid, useDatagrid, useInfiniteScroll, useNestedRows, useSelectRows, useExpandedRow, useOnRowClick, useSortableColumns, useRowIsMouseOver, useColumnRightAlign, useDisableSelectRows, useStickyColumn, useActionsColumn, useCustomizeColumns, useSelectAllWithToggle, useColumnOrder, useInlineEdit } from './Datagrid';
|
41
41
|
export { EditTearsheet } from './EditTearsheet';
|
42
42
|
export { EditTearsheetNarrow } from './EditTearsheetNarrow';
|
43
|
-
export { EditFullPage } from './EditFullPage';
|
43
|
+
export { EditFullPage } from './EditFullPage';
|
44
|
+
export { EditUpdateCards } from './EditUpdateCards';
|
@@ -0,0 +1,20 @@
|
|
1
|
+
import { motion } from '@carbon/motion';
|
2
|
+
/**
|
3
|
+
* This function turns a cubic-bezier() string to an
|
4
|
+
* array of values that we can use with framer-motion
|
5
|
+
* @param {string} type - The carbon motion type, either 'standard', 'entrance', or 'exit'
|
6
|
+
* @param {string} mode - The carbon motion mode, either 'productive', or 'expressive'
|
7
|
+
*/
|
8
|
+
|
9
|
+
export var getBezierValues = function getBezierValues(type, mode) {
|
10
|
+
var cubicBezier = motion(type, mode);
|
11
|
+
var extractStringFromParens = /\(([^)]+)\)/;
|
12
|
+
var desiredBezierStrings = extractStringFromParens.exec(cubicBezier)[1];
|
13
|
+
var formattedDesiredBezierStrings = desiredBezierStrings.trim().split(',').map(Number);
|
14
|
+
|
15
|
+
if (Array.isArray(formattedDesiredBezierStrings)) {
|
16
|
+
return formattedDesiredBezierStrings;
|
17
|
+
}
|
18
|
+
|
19
|
+
return [];
|
20
|
+
};
|
@@ -0,0 +1,45 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright IBM Corp. 2022, 2022
|
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
|
+
import { getBezierValues } from './getBezierValues';
|
8
|
+
import { fast01, fast02, moderate01, moderate02, slow01, slow02 } from '@carbon/motion';
|
9
|
+
|
10
|
+
var cleanMotionValue = function cleanMotionValue(val) {
|
11
|
+
return parseInt(val) / 1000;
|
12
|
+
};
|
13
|
+
|
14
|
+
export var DURATIONS = {
|
15
|
+
// Micro-interactions such as button and toggle
|
16
|
+
fast01: cleanMotionValue(fast01),
|
17
|
+
// '70ms'
|
18
|
+
// Micro-interactions such as fade
|
19
|
+
fast02: cleanMotionValue(fast02),
|
20
|
+
// '110ms'
|
21
|
+
// Micro-interactions, small expansion, short distance movements
|
22
|
+
moderate01: cleanMotionValue(moderate01),
|
23
|
+
// '150ms'
|
24
|
+
// Expansion, system communication, toast
|
25
|
+
moderate02: cleanMotionValue(moderate02),
|
26
|
+
// '240ms'
|
27
|
+
// Large expansion, important system notifications
|
28
|
+
slow01: cleanMotionValue(slow01),
|
29
|
+
// '400ms'
|
30
|
+
// Background dimming
|
31
|
+
slow02: cleanMotionValue(slow02) // '700ms'
|
32
|
+
|
33
|
+
};
|
34
|
+
export var EASINGS = {
|
35
|
+
productive: {
|
36
|
+
entrance: getBezierValues('entrance', 'productive'),
|
37
|
+
standard: getBezierValues('standard', 'productive'),
|
38
|
+
exit: getBezierValues('exit', 'productive')
|
39
|
+
},
|
40
|
+
expressive: {
|
41
|
+
entrance: getBezierValues('entrance', 'expressive'),
|
42
|
+
standard: getBezierValues('standard', 'expressive'),
|
43
|
+
exit: getBezierValues('exit', 'expressive')
|
44
|
+
}
|
45
|
+
};
|
@@ -363,11 +363,11 @@ AddSelectBody.propTypes = {
|
|
363
363
|
entries: _propTypes.default.arrayOf(_propTypes.default.shape({
|
364
364
|
avatar: _propTypes.default.shape({
|
365
365
|
alt: _propTypes.default.string,
|
366
|
-
icon: _propTypes.default.func,
|
366
|
+
icon: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.object]),
|
367
367
|
src: _propTypes.default.string
|
368
368
|
}),
|
369
369
|
children: _propTypes.default.object,
|
370
|
-
icon: _propTypes.default.func,
|
370
|
+
icon: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.object]),
|
371
371
|
id: _propTypes.default.string.isRequired,
|
372
372
|
meta: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.shape({
|
373
373
|
id: _propTypes.default.string,
|
@@ -124,9 +124,9 @@ CreateTearsheetNarrow.propTypes = {
|
|
124
124
|
formDescription: _propTypes.default.node,
|
125
125
|
|
126
126
|
/**
|
127
|
-
* Specifies a
|
127
|
+
* Specifies a field that provides a title for a form
|
128
128
|
*/
|
129
|
-
formTitle: _propTypes.default.node
|
129
|
+
formTitle: _propTypes.default.node,
|
130
130
|
|
131
131
|
/**
|
132
132
|
* A label for the tearsheet, displayed in the header area of the tearsheet
|
@@ -140,10 +140,15 @@ var DatagridContent = function DatagridContent(_ref) {
|
|
140
140
|
}
|
141
141
|
|
142
142
|
var gridElement = document.querySelector("#".concat(tableId));
|
143
|
+
var tableHeader = document.querySelector(".".concat(_settings.carbon.prefix, "--data-table-header"));
|
143
144
|
gridElement.style.setProperty("--".concat(blockClass, "--grid-width"), (0, _layout.px)(totalColumnsWidth + 32));
|
144
|
-
|
145
|
+
|
146
|
+
if (gridActive) {
|
147
|
+
gridElement.style.setProperty("--".concat(blockClass, "--grid-header-height"), (0, _layout.px)((tableHeader === null || tableHeader === void 0 ? void 0 : tableHeader.clientHeight) || 0));
|
148
|
+
}
|
149
|
+
}, [withInlineEdit, tableId, totalColumnsWidth, datagridState, gridActive]);
|
145
150
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(TableContainer, {
|
146
|
-
className: (0, _classnames.default)("".concat(blockClass, "__grid-container"), withVirtualScroll || fullHeightDatagrid ? "".concat(blockClass, "__full-height") : '', DatagridPagination ? "".concat(blockClass, "__with-pagination") : '', useDenseHeader ? "".concat(blockClass, "__dense-header") : '', (_cx4 = {}, (0, _defineProperty2.default)(_cx4, "".concat(blockClass, "__grid-container-grid-active"), gridActive), (0, _defineProperty2.default)(_cx4, "".concat(blockClass, "__grid-container-grid-active--without-toolbar"), withInlineEdit && !DatagridActions), _cx4)),
|
151
|
+
className: (0, _classnames.default)("".concat(blockClass, "__grid-container"), withVirtualScroll || fullHeightDatagrid ? "".concat(blockClass, "__full-height") : '', DatagridPagination ? "".concat(blockClass, "__with-pagination") : '', useDenseHeader ? "".concat(blockClass, "__dense-header") : '', (_cx4 = {}, (0, _defineProperty2.default)(_cx4, "".concat(blockClass, "__grid-container-grid-active"), gridActive), (0, _defineProperty2.default)(_cx4, "".concat(blockClass, "__grid-container-inline-edit"), withInlineEdit), (0, _defineProperty2.default)(_cx4, "".concat(blockClass, "__grid-container-grid-active--without-toolbar"), withInlineEdit && !DatagridActions), _cx4)),
|
147
152
|
title: gridTitle,
|
148
153
|
description: gridDescription
|
149
154
|
}, /*#__PURE__*/_react.default.createElement(_DatagridToolbar.default, datagridState), /*#__PURE__*/_react.default.createElement("div", {
|
@@ -165,7 +170,7 @@ DatagridContent.propTypes = {
|
|
165
170
|
withVirtualScroll: _propTypes.default.bool,
|
166
171
|
DatagridActions: _propTypes.default.oneOfType([_propTypes.default.element, _propTypes.default.func]),
|
167
172
|
DatagridPagination: _propTypes.default.oneOfType([_propTypes.default.element, _propTypes.default.func]),
|
168
|
-
CustomizeColumnsModal: _propTypes.default.element,
|
173
|
+
CustomizeColumnsModal: _propTypes.default.oneOfType([_propTypes.default.element, _propTypes.default.func]),
|
169
174
|
isFetching: _propTypes.default.bool,
|
170
175
|
leftPanel: _propTypes.default.object,
|
171
176
|
fullHeightDatagrid: _propTypes.default.bool,
|
@@ -53,6 +53,7 @@ var DatagridVirtualBody = function DatagridVirtualBody(datagridState) {
|
|
53
53
|
innerListRef = datagridState.innerListRef,
|
54
54
|
_datagridState$tableH = datagridState.tableHeight,
|
55
55
|
tableHeight = _datagridState$tableH === void 0 ? 400 : _datagridState$tableH,
|
56
|
+
virtualHeight = datagridState.virtualHeight,
|
56
57
|
listRef = datagridState.listRef,
|
57
58
|
rowSize = datagridState.rowSize,
|
58
59
|
DatagridPagination = datagridState.DatagridPagination,
|
@@ -72,7 +73,7 @@ var DatagridVirtualBody = function DatagridVirtualBody(datagridState) {
|
|
72
73
|
return /*#__PURE__*/_react.default.createElement(TableBody, (0, _extends2.default)({}, getTableBodyProps(), {
|
73
74
|
onScroll: onScroll
|
74
75
|
}), /*#__PURE__*/_react.default.createElement(_reactWindow.VariableSizeList, {
|
75
|
-
height: tableHeight,
|
76
|
+
height: virtualHeight || tableHeight,
|
76
77
|
itemCount: visibleRows.length,
|
77
78
|
itemSize: function itemSize(index) {
|
78
79
|
return visibleRows[index].isExpanded ? (visibleRows[index].expandedContentHeight || 0) + rowHeight : rowHeight;
|
@@ -59,6 +59,9 @@ var ButtonWrapper = function ButtonWrapper(_ref) {
|
|
59
59
|
}));
|
60
60
|
};
|
61
61
|
|
62
|
+
ButtonWrapper.defaultProps = {
|
63
|
+
onClick: function onClick() {}
|
64
|
+
};
|
62
65
|
ButtonWrapper.propTypes = {
|
63
66
|
iconTooltipLabel: _propTypes.default.string,
|
64
67
|
isModalOpen: _propTypes.default.bool.isRequired,
|
@@ -57,7 +57,7 @@ var getNextIndex = function getNextIndex(array, currentIndex, key) {
|
|
57
57
|
};
|
58
58
|
|
59
59
|
var Columns = function Columns(_ref) {
|
60
|
-
var
|
60
|
+
var _cx;
|
61
61
|
|
62
62
|
var getVisibleColumnsCount = _ref.getVisibleColumnsCount,
|
63
63
|
filterString = _ref.filterString,
|
@@ -116,12 +116,11 @@ var Columns = function Columns(_ref) {
|
|
116
116
|
className: "".concat(blockClass, "__shared-ui--assistive-text")
|
117
117
|
}, filterString.length === 0 ? assistiveTextInstructionsLabel : assistiveTextDisabledInstructionsLabel), /*#__PURE__*/_react.default.createElement("div", {
|
118
118
|
id: "".concat(blockClass, "__customize-columns-select-all"),
|
119
|
-
className: (0, _classnames.default)((
|
119
|
+
className: (0, _classnames.default)((_cx = {}, (0, _defineProperty2.default)(_cx, "".concat(blockClass, "__customize-columns-select-all"), getVisibleColumnsCount() === 0), (0, _defineProperty2.default)(_cx, "".concat(blockClass, "__customize-columns-select-all-selected"), getVisibleColumnsCount() > 0), _cx)),
|
120
120
|
selected: getVisibleColumnsCount() > 0
|
121
121
|
}, /*#__PURE__*/_react.default.createElement(_react2.Checkbox, {
|
122
|
-
|
122
|
+
className: "".concat(blockClass, "__customize-columns-checkbox-wrapper"),
|
123
123
|
checked: getVisibleColumnsCount() === columns.length,
|
124
|
-
empty: !!getVisibleColumnsCount() === 0,
|
125
124
|
indeterminate: getVisibleColumnsCount() < columns.length && getVisibleColumnsCount() > 0,
|
126
125
|
onChange: function onChange() {
|
127
126
|
onSelectColumn(columns, getVisibleColumnsCount() !== columns.length);
|
@@ -160,13 +159,15 @@ var Columns = function Columns(_ref) {
|
|
160
159
|
},
|
161
160
|
selected: (0, _common.isColumnVisible)(colDef)
|
162
161
|
}, /*#__PURE__*/_react.default.createElement(_react2.Checkbox, {
|
163
|
-
|
162
|
+
className: (0, _classnames.default)("".concat(blockClass, "__customize-columns-checkbox-wrapper"), "".concat(blockClass, "__customize-columns-checkbox")),
|
164
163
|
checked: (0, _common.isColumnVisible)(colDef),
|
165
|
-
onChange:
|
164
|
+
onChange: function onChange(_, _ref2) {
|
165
|
+
var checked = _ref2.checked;
|
166
|
+
return onSelectColumn(colDef, checked);
|
167
|
+
},
|
166
168
|
id: "".concat(blockClass, "__customization-column-").concat(colDef.id),
|
167
169
|
labelText: colDef.Header.props.title,
|
168
|
-
title: colDef.Header.props.title
|
169
|
-
className: "".concat(blockClass, "__customize-columns-checkbox")
|
170
|
+
title: colDef.Header.props.title
|
170
171
|
}));
|
171
172
|
}))));
|
172
173
|
};
|