@carbon/ibm-products 2.0.0-rc.3 → 2.0.0-rc.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. package/css/index-full-carbon.css +63 -157
  2. package/css/index-full-carbon.css.map +1 -1
  3. package/css/index-full-carbon.min.css +3 -9
  4. package/css/index-full-carbon.min.css.map +1 -1
  5. package/css/index-without-carbon-released-only.css +8 -151
  6. package/css/index-without-carbon-released-only.css.map +1 -1
  7. package/css/index-without-carbon-released-only.min.css +3 -9
  8. package/css/index-without-carbon-released-only.min.css.map +1 -1
  9. package/css/index-without-carbon.css +63 -157
  10. package/css/index-without-carbon.css.map +1 -1
  11. package/css/index-without-carbon.min.css +3 -9
  12. package/css/index-without-carbon.min.css.map +1 -1
  13. package/css/index.css +63 -157
  14. package/css/index.css.map +1 -1
  15. package/css/index.min.css +3 -9
  16. package/css/index.min.css.map +1 -1
  17. package/es/components/AddSelect/AddSelectBody.js +2 -2
  18. package/es/components/CreateTearsheet/CreateTearsheet.js +8 -1
  19. package/es/components/CreateTearsheetNarrow/CreateTearsheetNarrow.js +2 -2
  20. package/es/components/Datagrid/Datagrid/DatagridContent.js +10 -5
  21. package/es/components/Datagrid/Datagrid/DatagridVirtualBody.js +2 -1
  22. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/ButtonWrapper.js +3 -0
  23. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/Columns.js +10 -9
  24. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/CustomizeColumnsModal.js +1 -2
  25. package/es/components/Datagrid/useInfiniteScroll.js +5 -2
  26. package/es/components/Datagrid/utils/getArgTypes.js +4 -0
  27. package/es/components/EditUpdateCards/EditUpdateCards.js +144 -0
  28. package/es/components/EditUpdateCards/index.js +7 -0
  29. package/es/components/PageHeader/PageHeader.js +3 -3
  30. package/es/components/PageHeader/PageHeaderTitle.js +3 -1
  31. package/es/components/SidePanel/SidePanel.js +44 -51
  32. package/es/components/SidePanel/motion/variants.js +45 -0
  33. package/es/components/index.js +2 -1
  34. package/es/global/js/hooks/useResetCreateComponent.js +6 -2
  35. package/es/global/js/package-settings.js +2 -1
  36. package/es/global/js/utils/getBezierValues.js +20 -0
  37. package/es/global/js/utils/getNumberOfHiddenSteps.js +19 -0
  38. package/es/global/js/utils/motionConstants.js +45 -0
  39. package/lib/components/AddSelect/AddSelectBody.js +2 -2
  40. package/lib/components/CreateTearsheet/CreateTearsheet.js +9 -1
  41. package/lib/components/CreateTearsheetNarrow/CreateTearsheetNarrow.js +2 -2
  42. package/lib/components/Datagrid/Datagrid/DatagridContent.js +9 -4
  43. package/lib/components/Datagrid/Datagrid/DatagridVirtualBody.js +2 -1
  44. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/ButtonWrapper.js +3 -0
  45. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/Columns.js +9 -8
  46. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/CustomizeColumnsModal.js +1 -2
  47. package/lib/components/Datagrid/useInfiniteScroll.js +5 -2
  48. package/lib/components/Datagrid/utils/getArgTypes.js +4 -0
  49. package/lib/components/EditUpdateCards/EditUpdateCards.js +152 -0
  50. package/lib/components/EditUpdateCards/index.js +13 -0
  51. package/lib/components/PageHeader/PageHeader.js +3 -3
  52. package/lib/components/PageHeader/PageHeaderTitle.js +3 -1
  53. package/lib/components/SidePanel/SidePanel.js +45 -50
  54. package/lib/components/SidePanel/motion/variants.js +55 -0
  55. package/lib/components/index.js +9 -1
  56. package/lib/global/js/hooks/useResetCreateComponent.js +7 -2
  57. package/lib/global/js/package-settings.js +2 -1
  58. package/lib/global/js/utils/getBezierValues.js +29 -0
  59. package/lib/global/js/utils/getNumberOfHiddenSteps.js +28 -0
  60. package/lib/global/js/utils/motionConstants.js +55 -0
  61. package/package.json +5 -3
  62. package/scss/components/AddSelect/_add-select.scss +2 -2
  63. package/scss/components/Datagrid/_storybook-styles.scss +4 -0
  64. package/scss/components/Datagrid/styles/_useInlineEdit.scss +20 -5
  65. package/scss/components/Datagrid/styles/addons/_CustomizeColumnsModal.scss +2 -0
  66. package/scss/components/EditUpdateCards/_carbon-imports.scss +9 -0
  67. package/scss/components/EditUpdateCards/_edit-update-cards.scss +85 -0
  68. package/scss/components/EditUpdateCards/_index-with-carbon.scss +9 -0
  69. package/scss/components/EditUpdateCards/_index.scss +8 -0
  70. package/scss/components/EditUpdateCards/_storybook-styles.scss +55 -0
  71. package/scss/components/PageHeader/_page-header.scss +4 -0
  72. package/scss/components/SidePanel/_side-panel.scss +2 -78
  73. package/scss/components/SidePanel/_storybook-styles.scss +6 -1
  74. package/scss/components/_index-with-carbon.scss +1 -0
  75. package/scss/components/_index.scss +1 -0
@@ -81,5 +81,9 @@ export var ARG_TYPES = {
81
81
  type: 'number'
82
82
  },
83
83
  description: 'This value controls the height of the expanded content area. _This value is set/passed inside of the `datagridState` object._'
84
+ },
85
+ customizeColumnsProps: {
86
+ control: 'object',
87
+ description: 'This is an object containing all of the props used with the column customization extension. _This value is set/passed inside of the `datagridState` object._'
84
88
  }
85
89
  };
@@ -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
+ };
@@ -0,0 +1,7 @@
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
+ export { EditUpdateCards } from './EditUpdateCards';
@@ -301,7 +301,7 @@ export var PageHeader = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
301
301
  var current = _ref5.current;
302
302
  // on window resize and other updates some values may have changed
303
303
  checkUpdateVerticalSpace();
304
- setWidthIsNarrow(current.innerWidth < breakpoints.md.width); // small (below medium) media query
304
+ setWidthIsNarrow(current.innerWidth / 16 < parseInt(breakpoints.md.width)); // small (below medium) media query
305
305
  }, [actionBarItems, children, breadcrumbs, enableBreadcrumbScroll, navigation, pageActions, subtitle, tags, title]);
306
306
  useEffect(function () {
307
307
  checkUpdateVerticalSpace(); // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -344,7 +344,7 @@ export var PageHeader = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
344
344
  };
345
345
 
346
346
  useEffect(function () {
347
- if (typeof collapseHeader === 'boolean') {
347
+ if (collapseHeader === true) {
348
348
  utilSetCollapsed(collapseHeader, metrics.headerOffset, metrics.headerTopValue);
349
349
  }
350
350
  }, [collapseHeader, metrics.headerOffset, metrics.headerTopValue]);
@@ -484,7 +484,7 @@ export var PageHeader = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
484
484
  onWidthChange: handleWidthChange,
485
485
  buttons: pageActions,
486
486
  buttonSetOverflowLabel: pageActionsOverflowLabel,
487
- rightAlign: true
487
+ rightAlign: !widthIsNarrow
488
488
  })));
489
489
  }
490
490
  }
@@ -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
- }, titleInnards);
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'; // Other standard imports.
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(open),
87
+ var _useState = useState(false),
86
88
  _useState2 = _slicedToArray(_useState, 2),
87
- shouldRender = _useState2[0],
88
- setRender = _useState2[1];
89
+ animationComplete = _useState2[0],
90
+ setAnimationComplete = _useState2[1];
89
91
 
90
- var _useState3 = useState(false),
92
+ var _useState3 = useState(0),
91
93
  _useState4 = _slicedToArray(_useState3, 2),
92
- animationComplete = _useState4[0],
93
- setAnimationComplete = _useState4[1];
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 && shouldRender && !animateTitle) {
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, shouldRender, panelHeight, title, size, reducedMotion.matches]); // click outside functionality if `includeOverlay` prop is set
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]); // initialize the side panel to open
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(event) {
339
- event.persist();
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 (shouldRender && slideIn) {
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, shouldRender, size, reducedMotion.matches]); // adds focus trap functionality
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 shouldRender && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", _extends({}, getDevtoolsProps(componentName), rest, {
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("div", {
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
- style: {
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
+ };
@@ -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';
@@ -5,6 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import { useEffect } from 'react';
8
+ import { getNumberOfHiddenSteps } from '../utils/getNumberOfHiddenSteps';
8
9
  /**
9
10
  * Resets the current step of the create component if it has been closed.
10
11
  * @param {object} useResetCreateComponent - Create component that uses this custom hook
@@ -12,6 +13,7 @@ import { useEffect } from 'react';
12
13
  * @param {object} useResetCreateComponent.previousState
13
14
  * @param {boolean} useResetCreateComponent.open
14
15
  * @param {Function} useResetCreateComponent.setCurrentStep
16
+ * @param {object} useResetCreateComponent.stepData
15
17
  * @param {number} useResetCreateComponent.initialStep
16
18
  * @param {number} useResetCreateComponent.totalSteps
17
19
  * @param {string} useResetCreateComponent.componentName
@@ -22,13 +24,15 @@ export var useResetCreateComponent = function useResetCreateComponent(_ref) {
22
24
  previousState = _ref.previousState,
23
25
  open = _ref.open,
24
26
  setCurrentStep = _ref.setCurrentStep,
27
+ stepData = _ref.stepData,
25
28
  initialStep = _ref.initialStep,
26
29
  totalSteps = _ref.totalSteps,
27
30
  componentName = _ref.componentName;
28
31
  useEffect(function () {
29
32
  if (!(previousState !== null && previousState !== void 0 && previousState.open) && open) {
30
33
  if (initialStep && totalSteps && Number(initialStep) <= Number(totalSteps) && Number(initialStep) > 0) {
31
- setCurrentStep(Number(initialStep));
34
+ var numberOfHiddenSteps = getNumberOfHiddenSteps(stepData, initialStep);
35
+ setCurrentStep(Number(initialStep + numberOfHiddenSteps));
32
36
  } else {
33
37
  // default should be fist includedStep instead of just 1
34
38
  setCurrentStep(firstIncludedStep);
@@ -39,5 +43,5 @@ export var useResetCreateComponent = function useResetCreateComponent(_ref) {
39
43
  console.warn("".concat(componentName, ": An invalid `initialStep` prop was supplied. The `initialStep` prop should be a number that is greater than 0 or less than or equal to the number of steps your ").concat(componentName, " has."));
40
44
  }
41
45
  }
42
- }, [firstIncludedStep, open, previousState, setCurrentStep, initialStep, totalSteps, componentName]);
46
+ }, [firstIncludedStep, open, previousState, setCurrentStep, stepData, initialStep, totalSteps, componentName]);
43
47
  };
@@ -69,7 +69,8 @@ var defaults = {
69
69
  Datagrid: false,
70
70
  EditTearsheet: false,
71
71
  EditTearsheetNarrow: false,
72
- EditFullPage: false
72
+ EditFullPage: false,
73
+ EditUpdateCards: false
73
74
  /* new component flags here - comment used by generate CLI */
74
75
 
75
76
  },
@@ -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,19 @@
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
+ export var getNumberOfHiddenSteps = function getNumberOfHiddenSteps(stepData, initialStep) {
8
+ var numberOfHiddenSteps = 0;
9
+ stepData.forEach(function (step, stepIndex) {
10
+ if (stepIndex + 1 > initialStep) {
11
+ return;
12
+ }
13
+
14
+ if (step.shouldIncludeStep === false) {
15
+ numberOfHiddenSteps += 1;
16
+ }
17
+ });
18
+ return numberOfHiddenSteps;
19
+ };
@@ -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,
@@ -37,6 +37,8 @@ var _devtools = require("../../global/js/utils/devtools");
37
37
 
38
38
  var _lastIndexInArray = require("../../global/js/utils/lastIndexInArray");
39
39
 
40
+ var _getNumberOfHiddenSteps = require("../../global/js/utils/getNumberOfHiddenSteps");
41
+
40
42
  var _excluded = ["backButtonText", "cancelButtonText", "children", "className", "description", "influencerWidth", "initialStep", "label", "nextButtonText", "onClose", "onRequestSubmit", "open", "submitButtonText", "title", "verticalPosition"];
41
43
 
42
44
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
@@ -147,7 +149,12 @@ var CreateTearsheet = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
147
149
  if (lastItem !== lastIncludedStep) {
148
150
  setLastIncludedStep(lastItem);
149
151
  }
150
- }, [stepData, firstIncludedStep, lastIncludedStep]);
152
+
153
+ if (open && initialStep) {
154
+ var numberOfHiddenSteps = (0, _getNumberOfHiddenSteps.getNumberOfHiddenSteps)(stepData, initialStep);
155
+ setCurrentStep(Number(initialStep + numberOfHiddenSteps));
156
+ }
157
+ }, [stepData, firstIncludedStep, lastIncludedStep, initialStep, open]);
151
158
  (0, _hooks.useCreateComponentFocus)({
152
159
  previousState: previousState,
153
160
  currentStep: currentStep,
@@ -160,6 +167,7 @@ var CreateTearsheet = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
160
167
  previousState: previousState,
161
168
  open: open,
162
169
  setCurrentStep: setCurrentStep,
170
+ stepData: stepData,
163
171
  initialStep: initialStep,
164
172
  totalSteps: stepData === null || stepData === void 0 ? void 0 : stepData.length,
165
173
  componentName: componentName