@carbon/ibm-products 2.10.2 → 2.11.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (127) hide show
  1. package/README.md +7 -0
  2. package/css/index-full-carbon.css +71 -26
  3. package/css/index-full-carbon.css.map +1 -1
  4. package/css/index-full-carbon.min.css +3 -3
  5. package/css/index-full-carbon.min.css.map +1 -1
  6. package/css/index-without-carbon-released-only.css +1 -0
  7. package/css/index-without-carbon-released-only.css.map +1 -1
  8. package/css/index-without-carbon-released-only.min.css.map +1 -1
  9. package/css/index-without-carbon.css +71 -26
  10. package/css/index-without-carbon.css.map +1 -1
  11. package/css/index-without-carbon.min.css +3 -3
  12. package/css/index-without-carbon.min.css.map +1 -1
  13. package/css/index.css +68 -25
  14. package/css/index.css.map +1 -1
  15. package/css/index.min.css +2 -2
  16. package/css/index.min.css.map +1 -1
  17. package/es/components/APIKeyModal/APIKeyModal.js +10 -3
  18. package/es/components/AboutModal/AboutModal.js +10 -3
  19. package/es/components/ButtonSetWithOverflow/ButtonSetWithOverflow.js +17 -5
  20. package/es/components/CreateModal/CreateModal.js +10 -3
  21. package/es/components/Datagrid/Datagrid/DatagridContent.js +9 -7
  22. package/es/components/Datagrid/Datagrid/DatagridEmptyBody.js +3 -2
  23. package/es/components/Datagrid/Datagrid/DatagridExpandedRow.js +26 -13
  24. package/es/components/Datagrid/Datagrid/DatagridRow.js +47 -40
  25. package/es/components/Datagrid/Datagrid/DatagridToolbar.js +30 -37
  26. package/es/components/Datagrid/Datagrid/DraggableElement.js +36 -132
  27. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/Columns.js +17 -49
  28. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/DraggableItemsList.js +125 -40
  29. package/es/components/Datagrid/Extensions/ExpandableRow/ExpandableRow.docs-page.js +1 -1
  30. package/es/components/Datagrid/useExpandedRow.js +1 -1
  31. package/es/components/Datagrid/useNestedRowExpander.js +22 -9
  32. package/es/components/Datagrid/useRowExpander.js +22 -9
  33. package/es/components/Datagrid/utils/DatagridActions.js +1 -1
  34. package/es/components/Datagrid/utils/DatagridPagination.js +1 -1
  35. package/es/components/Datagrid/utils/getArgTypes.js +12 -0
  36. package/es/components/EditTearsheet/EditTearsheet.js +47 -38
  37. package/es/components/EditTearsheet/EditTearsheetForm.js +6 -0
  38. package/es/components/EditTearsheet/preview-components/MultiFormEditTearsheet.js +6 -1
  39. package/es/components/EmptyStates/EmptyState.js +1 -1
  40. package/es/components/EmptyStates/ErrorEmptyState/ErrorEmptyState.js +1 -1
  41. package/es/components/EmptyStates/NoDataEmptyState/NoDataEmptyState.js +1 -1
  42. package/es/components/EmptyStates/NoTagsEmptyState/NoTagsEmptyState.js +1 -1
  43. package/es/components/EmptyStates/NotFoundEmptyState/NotFoundEmptyState.js +1 -1
  44. package/es/components/EmptyStates/NotificationsEmptyState/NotificationsEmptyState.js +1 -1
  45. package/es/components/EmptyStates/UnauthorizedEmptyState/UnauthorizedEmptyState.js +1 -1
  46. package/es/components/EmptyStates/assets/ErrorIllustration.js +6 -11
  47. package/es/components/EmptyStates/assets/NoDataIllustration.js +6 -11
  48. package/es/components/EmptyStates/assets/NoTagsIllustration.js +6 -12
  49. package/es/components/EmptyStates/assets/NotFoundIllustration.js +6 -12
  50. package/es/components/EmptyStates/assets/NotificationsIllustration.js +6 -12
  51. package/es/components/EmptyStates/assets/UnauthorizedIllustration.js +6 -12
  52. package/es/components/ExportModal/ExportModal.js +10 -3
  53. package/es/components/ImportModal/ImportModal.js +10 -3
  54. package/es/components/RemoveModal/RemoveModal.js +10 -3
  55. package/es/components/TagSet/TagSet.js +5 -21
  56. package/es/components/TagSet/TagSetModal.js +7 -3
  57. package/es/components/Tearsheet/Tearsheet.js +2 -2
  58. package/es/components/Tearsheet/TearsheetNarrow.js +2 -2
  59. package/es/components/Tearsheet/TearsheetShell.js +14 -28
  60. package/es/global/decorators/sidePanelDecorator.js +7 -0
  61. package/es/global/js/hooks/usePortalTarget.js +30 -0
  62. package/es/global/js/hooks/useRetrieveFormTitles.js +20 -0
  63. package/es/global/js/hooks/useWindowScroll.js +5 -0
  64. package/es/global/js/package-settings.js +0 -1
  65. package/es/global/js/utils/getNodeTextContent.js +47 -0
  66. package/flags.js +6 -0
  67. package/lib/components/APIKeyModal/APIKeyModal.js +10 -3
  68. package/lib/components/AboutModal/AboutModal.js +10 -3
  69. package/lib/components/ButtonSetWithOverflow/ButtonSetWithOverflow.js +17 -5
  70. package/lib/components/CreateModal/CreateModal.js +10 -3
  71. package/lib/components/Datagrid/Datagrid/DatagridContent.js +9 -7
  72. package/lib/components/Datagrid/Datagrid/DatagridEmptyBody.js +2 -1
  73. package/lib/components/Datagrid/Datagrid/DatagridExpandedRow.js +26 -13
  74. package/lib/components/Datagrid/Datagrid/DatagridRow.js +46 -41
  75. package/lib/components/Datagrid/Datagrid/DatagridToolbar.js +30 -37
  76. package/lib/components/Datagrid/Datagrid/DraggableElement.js +37 -137
  77. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/Columns.js +20 -49
  78. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/DraggableItemsList.js +130 -47
  79. package/lib/components/Datagrid/Extensions/ExpandableRow/ExpandableRow.docs-page.js +1 -1
  80. package/lib/components/Datagrid/useExpandedRow.js +1 -1
  81. package/lib/components/Datagrid/useNestedRowExpander.js +24 -9
  82. package/lib/components/Datagrid/useRowExpander.js +24 -9
  83. package/lib/components/Datagrid/utils/DatagridActions.js +1 -1
  84. package/lib/components/Datagrid/utils/DatagridPagination.js +1 -1
  85. package/lib/components/Datagrid/utils/getArgTypes.js +12 -0
  86. package/lib/components/EditTearsheet/EditTearsheet.js +47 -38
  87. package/lib/components/EditTearsheet/EditTearsheetForm.js +6 -0
  88. package/lib/components/EditTearsheet/preview-components/MultiFormEditTearsheet.js +6 -1
  89. package/lib/components/EmptyStates/EmptyState.js +1 -1
  90. package/lib/components/EmptyStates/ErrorEmptyState/ErrorEmptyState.js +1 -1
  91. package/lib/components/EmptyStates/NoDataEmptyState/NoDataEmptyState.js +1 -1
  92. package/lib/components/EmptyStates/NoTagsEmptyState/NoTagsEmptyState.js +1 -1
  93. package/lib/components/EmptyStates/NotFoundEmptyState/NotFoundEmptyState.js +1 -1
  94. package/lib/components/EmptyStates/NotificationsEmptyState/NotificationsEmptyState.js +1 -1
  95. package/lib/components/EmptyStates/UnauthorizedEmptyState/UnauthorizedEmptyState.js +1 -1
  96. package/lib/components/EmptyStates/assets/ErrorIllustration.js +6 -11
  97. package/lib/components/EmptyStates/assets/NoDataIllustration.js +6 -11
  98. package/lib/components/EmptyStates/assets/NoTagsIllustration.js +6 -12
  99. package/lib/components/EmptyStates/assets/NotFoundIllustration.js +6 -12
  100. package/lib/components/EmptyStates/assets/NotificationsIllustration.js +6 -12
  101. package/lib/components/EmptyStates/assets/UnauthorizedIllustration.js +6 -12
  102. package/lib/components/ExportModal/ExportModal.js +10 -3
  103. package/lib/components/ImportModal/ImportModal.js +10 -3
  104. package/lib/components/RemoveModal/RemoveModal.js +10 -3
  105. package/lib/components/TagSet/TagSet.js +5 -21
  106. package/lib/components/TagSet/TagSetModal.js +7 -3
  107. package/lib/components/Tearsheet/Tearsheet.js +2 -2
  108. package/lib/components/Tearsheet/TearsheetNarrow.js +2 -2
  109. package/lib/components/Tearsheet/TearsheetShell.js +14 -28
  110. package/lib/global/decorators/sidePanelDecorator.js +7 -0
  111. package/lib/global/js/hooks/usePortalTarget.js +38 -0
  112. package/lib/global/js/hooks/useRetrieveFormTitles.js +28 -0
  113. package/lib/global/js/hooks/useWindowScroll.js +6 -0
  114. package/lib/global/js/package-settings.js +0 -1
  115. package/lib/global/js/utils/getNodeTextContent.js +55 -0
  116. package/package.json +7 -3
  117. package/scss/components/ActionSet/_action-set.scss +2 -1
  118. package/scss/components/Datagrid/_datagrid.scss +9 -0
  119. package/scss/components/Datagrid/styles/_datagrid.scss +7 -6
  120. package/scss/components/Datagrid/styles/_draggableElement.scss +34 -16
  121. package/scss/components/Datagrid/styles/_useExpandedRow.scss +13 -0
  122. package/scss/components/Datagrid/styles/addons/_CustomizeColumnsTearsheet.scss +1 -1
  123. package/scss/components/Datagrid/styles/addons/_FilterFlyout.scss +23 -11
  124. package/scss/components/Datagrid/styles/addons/_FilterPanel.scss +7 -3
  125. package/scss/components/FilterSummary/_filter-summary.scss +3 -1
  126. package/scss/global/decorators/_side-panel-decorator.scss +7 -0
  127. package/scss/global/js/utils/_story-as-full-page.scss +0 -6
@@ -15,7 +15,6 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
15
15
  //
16
16
 
17
17
  import React, { useState, useEffect, useRef, useCallback } from 'react';
18
- import { createPortal } from 'react-dom';
19
18
  import PropTypes from 'prop-types';
20
19
  import cx from 'classnames';
21
20
  import { TagSetOverflow } from './TagSetOverflow';
@@ -32,13 +31,12 @@ var allTagsModalSearchThreshold = 10;
32
31
  // Default values for props
33
32
  var defaults = {
34
33
  align: 'start',
35
- // allTagsModalTarget: document.body,
36
34
  overflowAlign: 'bottom'
37
35
  };
38
36
  export var TagSet = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
39
37
  var _ref$align = _ref.align,
40
38
  align = _ref$align === void 0 ? defaults.align : _ref$align,
41
- allTagsModalTargetIn = _ref.allTagsModalTarget,
39
+ allTagsModalTarget = _ref.allTagsModalTarget,
42
40
  className = _ref.className,
43
41
  maxVisible = _ref.maxVisible,
44
42
  multiline = _ref.multiline,
@@ -76,22 +74,9 @@ export var TagSet = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
76
74
  sizingTags = _useState10[0],
77
75
  setSizingTags = _useState10[1];
78
76
  var overflowTag = useRef(null);
79
- var _useState11 = useState(null),
80
- _useState12 = _slicedToArray(_useState11, 2),
81
- allTagsModalTarget = _useState12[0],
82
- setAllTagsModalTarget = _useState12[1];
83
77
  var handleShowAllClick = function handleShowAllClick() {
84
78
  setShowAllModalOpen(true);
85
79
  };
86
- useEffect(function () {
87
- if (allTagsModalTargetIn) {
88
- setAllTagsModalTarget(allTagsModalTargetIn);
89
- } else {
90
- if (pkg.isFeatureEnabled('default-portal-target-body')) {
91
- setAllTagsModalTarget(document.body);
92
- }
93
- }
94
- }, [allTagsModalTargetIn]);
95
80
  useEffect(function () {
96
81
  var newSizingTags = [];
97
82
  // create sizing tags
@@ -211,16 +196,15 @@ export var TagSet = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
211
196
  }, hiddenSizingTags), /*#__PURE__*/React.createElement("div", {
212
197
  className: cx(["".concat(blockClass, "__tag-container"), multiline && "".concat(blockClass, "__tag-container--multiline")]),
213
198
  ref: displayedArea
214
- }, displayedTags)), (allTagsModalTarget ? createPortal : function (children) {
215
- return children;
216
- })( /*#__PURE__*/React.createElement(TagSetModal, {
199
+ }, displayedTags)), /*#__PURE__*/React.createElement(TagSetModal, {
217
200
  allTags: tags,
218
201
  open: showAllModalOpen,
219
202
  title: allTagsModalTitle,
220
203
  onClose: handleModalClose,
221
204
  searchLabel: allTagsModalSearchLabel,
222
- searchPlaceholder: allTagsModalSearchPlaceholderText
223
- }), allTagsModalTarget));
205
+ searchPlaceholder: allTagsModalSearchPlaceholderText,
206
+ portalTarget: allTagsModalTarget
207
+ }));
224
208
  });
225
209
 
226
210
  // Return a placeholder if not released and not enabled by feature flag
@@ -2,7 +2,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import _extends from "@babel/runtime/helpers/extends";
3
3
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
4
4
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
5
- var _excluded = ["allTags", "className", "title", "onClose", "open", "searchLabel", "searchPlaceholder"],
5
+ var _excluded = ["allTags", "className", "title", "onClose", "open", "portalTarget", "searchLabel", "searchPlaceholder"],
6
6
  _excluded2 = ["label"];
7
7
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
8
8
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
@@ -19,6 +19,7 @@ import cx from 'classnames';
19
19
  import { ComposedModal, ModalHeader, ModalBody, Search, Tag } from '@carbon/react';
20
20
  import { pkg } from '../../settings';
21
21
  import { prepareProps } from '../../global/js/utils/props-helper';
22
+ import { usePortalTarget } from '../../global/js/hooks/usePortalTarget';
22
23
  var componentName = 'TagSetModal';
23
24
  var blockClass = "".concat(pkg.prefix, "--tag-set-modal");
24
25
 
@@ -33,6 +34,7 @@ export var TagSetModal = function TagSetModal(_ref) {
33
34
  title = _ref.title,
34
35
  onClose = _ref.onClose,
35
36
  open = _ref.open,
37
+ portalTargetIn = _ref.portalTarget,
36
38
  _ref$searchLabel = _ref.searchLabel,
37
39
  searchLabel = _ref$searchLabel === void 0 ? defaults.searchLabel : _ref$searchLabel,
38
40
  searchPlaceholder = _ref.searchPlaceholder,
@@ -45,6 +47,7 @@ export var TagSetModal = function TagSetModal(_ref) {
45
47
  _useState4 = _slicedToArray(_useState3, 2),
46
48
  search = _useState4[0],
47
49
  setSearch = _useState4[1];
50
+ var renderPortalUse = usePortalTarget(portalTargetIn);
48
51
  useEffect(function () {
49
52
  var newFilteredModalTags = [];
50
53
  if (open) {
@@ -67,7 +70,7 @@ export var TagSetModal = function TagSetModal(_ref) {
67
70
  var handleSearch = function handleSearch(ev) {
68
71
  setSearch(ev.target.value || '');
69
72
  };
70
- return /*#__PURE__*/React.createElement(ComposedModal, _extends({}, rest, {
73
+ return renderPortalUse( /*#__PURE__*/React.createElement(ComposedModal, _extends({}, rest, {
71
74
  containerClassName: "".concat(blockClass, "__container"),
72
75
  className: cx(className, "".concat(blockClass)),
73
76
  size: "sm",
@@ -96,7 +99,7 @@ export var TagSetModal = function TagSetModal(_ref) {
96
99
  }), label);
97
100
  })), /*#__PURE__*/React.createElement("div", {
98
101
  className: "".concat(blockClass, "__fade")
99
- }));
102
+ })));
100
103
  };
101
104
  TagSetModal.propTypes = {
102
105
  allTags: PropTypes.arrayOf(PropTypes.shape(_objectSpread(_objectSpread({}, prepareProps(Tag.propTypes, 'filter')), {}, {
@@ -105,6 +108,7 @@ TagSetModal.propTypes = {
105
108
  className: PropTypes.string,
106
109
  onClose: PropTypes.func,
107
110
  open: PropTypes.bool,
111
+ portalTarget: PropTypes.node,
108
112
  searchLabel: PropTypes.string,
109
113
  searchPlaceholder: PropTypes.string,
110
114
  title: PropTypes.string
@@ -176,9 +176,9 @@ Tearsheet.propTypes = _objectSpread({
176
176
  */
177
177
  open: PropTypes.bool,
178
178
  /**
179
- * The DOM node the tearsheet should be rendered within. Defaults to document.body.
179
+ * The DOM element that the tearsheet should be rendered within. Defaults to document.body.
180
180
  */
181
- portalTarget: PropTypes.node,
181
+ portalTarget: PropTypes.instanceOf(Element),
182
182
  /**
183
183
  * Specify a CSS selector that matches the DOM element that should be focused when the Modal opens
184
184
  */
@@ -142,9 +142,9 @@ TearsheetNarrow.propTypes = _objectSpread({
142
142
  */
143
143
  open: PropTypes.bool,
144
144
  /**
145
- * The DOM node the tearsheet should be rendered within. Defaults to document.body.
145
+ * The DOM element that the tearsheet should be rendered within. Defaults to document.body.
146
146
  */
147
- portalTarget: PropTypes.node,
147
+ portalTarget: PropTypes.instanceOf(Element),
148
148
  /**
149
149
  * The main title of the tearsheet, displayed in the header area.
150
150
  */
@@ -14,7 +14,6 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
14
14
 
15
15
  // Import portions of React that are needed.
16
16
  import React, { useEffect, useState, useRef } from 'react';
17
- import { createPortal } from 'react-dom';
18
17
  import { useResizeObserver } from '../../global/js/hooks/useResizeObserver';
19
18
 
20
19
  // Other standard imports.
@@ -22,11 +21,13 @@ import PropTypes from 'prop-types';
22
21
  import cx from 'classnames';
23
22
  import { pkg } from '../../settings';
24
23
  import pconsole from '../../global/js/utils/pconsole';
24
+ import { getNodeTextContent } from '../../global/js/utils/getNodeTextContent';
25
25
 
26
26
  // Carbon and package components we use.
27
27
  import { Button, ComposedModal, Layer, ModalHeader, ModalBody, usePrefix } from '@carbon/react';
28
28
  import { ActionSet } from '../ActionSet';
29
29
  import { Wrap } from '../../global/js/utils/Wrap';
30
+ import { usePortalTarget } from '../../global/js/hooks/usePortalTarget';
30
31
 
31
32
  // The block part of our conventional BEM class names (bc__E--M).
32
33
  var bc = "".concat(pkg.prefix, "--tearsheet");
@@ -85,20 +86,7 @@ export var TearsheetShell = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
85
86
  rest = _objectWithoutProperties(_ref, _excluded);
86
87
  var carbonPrefix = usePrefix();
87
88
  var bcModalHeader = "".concat(carbonPrefix, "--modal-header");
88
- // node the modal tearsheet is hosted in
89
- var _useState = useState(null),
90
- _useState2 = _slicedToArray(_useState, 2),
91
- portalTarget = _useState2[0],
92
- setPortalTarget = _useState2[1];
93
- useEffect(function () {
94
- if (portalTargetIn) {
95
- setPortalTarget(portalTargetIn);
96
- } else {
97
- if (pkg.isFeatureEnabled('default-portal-target-body')) {
98
- setPortalTarget(document.body);
99
- }
100
- }
101
- }, [portalTargetIn]);
89
+ var renderPortalUse = usePortalTarget(portalTargetIn);
102
90
  var localRef = useRef();
103
91
  var resizer = useRef(null);
104
92
  var modalRef = ref || localRef;
@@ -107,14 +95,14 @@ export var TearsheetShell = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
107
95
  var wide = size === 'wide';
108
96
 
109
97
  // Keep track of the stack depth and our position in it (1-based, 0=closed)
98
+ var _useState = useState(0),
99
+ _useState2 = _slicedToArray(_useState, 2),
100
+ depth = _useState2[0],
101
+ setDepth = _useState2[1];
110
102
  var _useState3 = useState(0),
111
103
  _useState4 = _slicedToArray(_useState3, 2),
112
- depth = _useState4[0],
113
- setDepth = _useState4[1];
114
- var _useState5 = useState(0),
115
- _useState6 = _slicedToArray(_useState5, 2),
116
- position = _useState6[0],
117
- setPosition = _useState6[1];
104
+ position = _useState4[0],
105
+ setPosition = _useState4[1];
118
106
 
119
107
  // Keep a record of the previous value of depth.
120
108
  var prevDepth = useRef();
@@ -199,10 +187,8 @@ export var TearsheetShell = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
199
187
 
200
188
  // Include an ActionSet if and only if one or more actions is given.
201
189
  var includeActions = actions && (actions === null || actions === void 0 ? void 0 : actions.length) > 0;
202
- return (portalTarget ? createPortal : function (children) {
203
- return children;
204
- })( /*#__PURE__*/React.createElement(ComposedModal, _extends({}, rest, {
205
- "aria-label": title,
190
+ return renderPortalUse( /*#__PURE__*/React.createElement(ComposedModal, _extends({}, rest, {
191
+ "aria-label": getNodeTextContent(title),
206
192
  className: cx(bc, className, (_cx = {}, _defineProperty(_cx, "".concat(bc, "--stacked-").concat(position, "-of-").concat(depth),
207
193
  // Don't apply this on the initial open of a single tearsheet.
208
194
  depth > 1 || depth === 1 && prevDepth.current > 1), _defineProperty(_cx, "".concat(bc, "--wide"), wide), _defineProperty(_cx, "".concat(bc, "--narrow"), !wide), _cx)),
@@ -266,7 +252,7 @@ export var TearsheetShell = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
266
252
  })))), /*#__PURE__*/React.createElement("div", {
267
253
  className: "".concat(bc, "__resize-detector"),
268
254
  ref: resizer
269
- })), portalTarget);
255
+ })));
270
256
  } else {
271
257
  pconsole.warn('Tearsheet not rendered: maximum stacking depth exceeded.');
272
258
  return null;
@@ -397,9 +383,9 @@ TearsheetShell.propTypes = _objectSpread({
397
383
  */
398
384
  open: PropTypes.bool,
399
385
  /**
400
- * The DOM node the tearsheet should be rendered within. Defaults to document.body.
386
+ * The DOM element that the tearsheet should be rendered within. Defaults to document.body.
401
387
  */
402
- portalTarget: PropTypes.node,
388
+ portalTarget: PropTypes.instanceOf(Element),
403
389
  /**
404
390
  * Specifies the width of the tearsheet, 'narrow' or 'wide'.
405
391
  */
@@ -1,3 +1,10 @@
1
+ /**
2
+ * Copyright IBM Corp. 2023, 2023
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
+
1
8
  import React from 'react';
2
9
  import { Content } from '@carbon/react';
3
10
  export var sidePanelDecorator = function sidePanelDecorator(renderHeader, prefix) {
@@ -0,0 +1,30 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
+ /**
3
+ * Copyright IBM Corp. 2023, 2023
4
+ *
5
+ * This source code is licensed under the Apache-2.0 license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ import { useState, useEffect, useCallback } from 'react';
9
+ import { pkg } from '../../../settings';
10
+ import { createPortal } from 'react-dom';
11
+ var usePortalTarget = function usePortalTarget(portalTargetIn) {
12
+ var _useState = useState(null),
13
+ _useState2 = _slicedToArray(_useState, 2),
14
+ portalTarget = _useState2[0],
15
+ setPortalTarget = _useState2[1];
16
+ useEffect(function () {
17
+ if (portalTargetIn) {
18
+ setPortalTarget(portalTargetIn);
19
+ } else {
20
+ if (pkg.isFeatureEnabled('default-portal-target-body')) {
21
+ setPortalTarget(document.body);
22
+ }
23
+ }
24
+ }, [portalTargetIn]);
25
+ var renderPortalUse = useCallback(function (children) {
26
+ return portalTarget ? /*#__PURE__*/createPortal(children, portalTarget) : children;
27
+ }, [portalTarget]);
28
+ return renderPortalUse;
29
+ };
30
+ export { usePortalTarget };
@@ -0,0 +1,20 @@
1
+ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
+ import { useEffect } from 'react';
3
+ export var useRetrieveFormTitles = function useRetrieveFormTitles(_ref) {
4
+ var formContext = _ref.formContext,
5
+ formNumber = _ref.formNumber,
6
+ title = _ref.title;
7
+ useEffect(function () {
8
+ if (formContext) {
9
+ formContext.setFormTitles(function (prev) {
10
+ var prevTitle = prev[formNumber];
11
+ if (prevTitle !== title) {
12
+ var clone = _toConsumableArray(prev);
13
+ clone[formNumber] = title;
14
+ return clone;
15
+ }
16
+ return prev;
17
+ });
18
+ }
19
+ }, [title, formContext, formNumber]);
20
+ };
@@ -74,4 +74,9 @@ export function useNearestScroll(ref, effect, deps) {
74
74
  scrollableTarget = window;
75
75
  }
76
76
  return useTargetScroll(scrollableTarget, effect, deps, throttle);
77
+ }
78
+ export function useScroll(ref, effect, deps) {
79
+ var _ref$current;
80
+ var throttle = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
81
+ return useTargetScroll((_ref$current = ref === null || ref === void 0 ? void 0 : ref.current) !== null && _ref$current !== void 0 ? _ref$current : null, effect, deps, throttle);
77
82
  }
@@ -74,7 +74,6 @@ var defaults = {
74
74
 
75
75
  // feature level flags
76
76
  feature: {
77
- 'a-new-feature': false,
78
77
  'default-portal-target-body': true,
79
78
  'Datagrid.useInfiniteScroll': false,
80
79
  'Datagrid.useInlineEdit': false,
@@ -0,0 +1,47 @@
1
+ import _typeof from "@babel/runtime/helpers/typeof";
2
+ /**
3
+ * Copyright IBM Corp. 2023
4
+ *
5
+ * This source code is licensed under the Apache-2.0 license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+
9
+ /**
10
+ * Returns a compiled string of all the text content of a React node and any of its child nodes.
11
+ * This is meant to be used in a limited fashion to convert a "styled" sentence into a single string:
12
+ * e.g. <p>Title <b>Page</b>.</p> --> "Title Page."
13
+ * This will likely not work for arrays of nodes due to the lack of word spacing:
14
+ * e.g. <ul>
15
+ * <li>Item 1</li>
16
+ * <li>Item 2</li>
17
+ * <li>Item 3</li>
18
+ * </ul>
19
+ * --> "Item 1Item 2Item 3"
20
+ * @param {Node} node A React node
21
+ * @returns {string}
22
+ */
23
+ export var getNodeTextContent = function getNodeTextContent(node) {
24
+ if (node == null) {
25
+ return '';
26
+ }
27
+ switch (_typeof(node)) {
28
+ case 'string':
29
+ case 'number':
30
+ return node.toString();
31
+ case 'object':
32
+ {
33
+ if (node instanceof Array) {
34
+ return node.map(getNodeTextContent).join('');
35
+ }
36
+ if ('props' in node) {
37
+ return getNodeTextContent(node.props.children);
38
+ }
39
+
40
+ // Ignore any other JavaScript 'object' types.
41
+ return '';
42
+ }
43
+ default:
44
+ // Ignore all other JavaScript types.
45
+ return '';
46
+ }
47
+ };
package/flags.js ADDED
@@ -0,0 +1,6 @@
1
+ const { pkg } = require('./lib/settings.js');
2
+ const { component, feature } = pkg;
3
+
4
+ console.log('Components enabled by default\n', { component });
5
+
6
+ console.log('\n\nDefault feature flag values\n', { feature });
@@ -19,10 +19,11 @@ var _react2 = require("@carbon/react");
19
19
  var _icons = require("@carbon/react/icons");
20
20
  var _APIKeyDownloader = require("./APIKeyDownloader");
21
21
  var _settings = require("../../settings");
22
+ var _usePortalTarget = require("../../global/js/hooks/usePortalTarget");
22
23
  var _devtools = require("../../global/js/utils/devtools");
23
24
  var _propsHelper = require("../../global/js/utils/props-helper");
24
25
  var _uuidv = _interopRequireDefault(require("../../global/js/utils/uuidv4"));
25
- var _excluded = ["apiKey", "apiKeyLabel", "apiKeyName", "body", "className", "closeButtonText", "copyButtonText", "copyErrorText", "copyIconDescription", "customSteps", "downloadBodyText", "downloadFileName", "downloadFileType", "downloadLinkText", "editButtonText", "editSuccess", "editSuccessTitle", "editing", "error", "errorText", "generateButtonText", "generateSuccessBody", "generateSuccessTitle", "generateTitle", "hasAPIKeyVisibilityToggle", "hasDownloadLink", "hideAPIKeyLabel", "loading", "loadingText", "modalLabel", "nameHelperText", "nameLabel", "namePlaceholder", "nameRequired", "nextStepButtonText", "onClose", "onCopy", "onRequestEdit", "onRequestGenerate", "open", "previousStepButtonText", "showAPIKeyLabel"]; //
26
+ var _excluded = ["apiKey", "apiKeyLabel", "apiKeyName", "body", "className", "closeButtonText", "copyButtonText", "copyErrorText", "copyIconDescription", "customSteps", "downloadBodyText", "downloadFileName", "downloadFileType", "downloadLinkText", "editButtonText", "editSuccess", "editSuccessTitle", "editing", "error", "errorText", "generateButtonText", "generateSuccessBody", "generateSuccessTitle", "generateTitle", "hasAPIKeyVisibilityToggle", "hasDownloadLink", "hideAPIKeyLabel", "loading", "loadingText", "modalLabel", "nameHelperText", "nameLabel", "namePlaceholder", "nameRequired", "nextStepButtonText", "onClose", "onCopy", "onRequestEdit", "onRequestGenerate", "open", "portalTarget", "previousStepButtonText", "showAPIKeyLabel"]; //
26
27
  // Copyright IBM Corp. 2021, 2021
27
28
  //
28
29
  // This source code is licensed under the Apache-2.0 license found in the
@@ -83,6 +84,7 @@ var APIKeyModal = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
83
84
  onRequestEdit = _ref.onRequestEdit,
84
85
  onRequestGenerate = _ref.onRequestGenerate,
85
86
  open = _ref.open,
87
+ portalTargetIn = _ref.portalTarget,
86
88
  previousStepButtonText = _ref.previousStepButtonText,
87
89
  showAPIKeyLabel = _ref.showAPIKeyLabel,
88
90
  rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
@@ -105,6 +107,7 @@ var APIKeyModal = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
105
107
  var copyRef = (0, _react.useRef)();
106
108
  var apiKeyInputId = (0, _react.useRef)((0, _uuidv.default)());
107
109
  var nameInputId = (0, _react.useRef)((0, _uuidv.default)());
110
+ var renderPortalUse = (0, _usePortalTarget.usePortalTarget)(portalTargetIn);
108
111
  var hasSteps = Boolean(customSteps.length);
109
112
  var apiKeyLoaded = apiKey && !loading;
110
113
  var hasNextStep = hasSteps && currentStep < customSteps.length - 1;
@@ -233,7 +236,7 @@ var APIKeyModal = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
233
236
  onCloseHandler();
234
237
  }
235
238
  };
236
- return /*#__PURE__*/_react.default.createElement(_react2.ComposedModal, (0, _extends2.default)({}, rest, _objectSpread({
239
+ return renderPortalUse( /*#__PURE__*/_react.default.createElement(_react2.ComposedModal, (0, _extends2.default)({}, rest, _objectSpread({
237
240
  open: open,
238
241
  ref: ref
239
242
  }, (0, _devtools.getDevtoolsProps)(componentName)), {
@@ -308,7 +311,7 @@ var APIKeyModal = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
308
311
  kind: "primary",
309
312
  onClick: submitHandler,
310
313
  disabled: isPrimaryButtonDisabled()
311
- }), getPrimaryButtonText())));
314
+ }), getPrimaryButtonText()))));
312
315
  });
313
316
  exports.APIKeyModal = APIKeyModal;
314
317
  var customStepsRequiredProps = function customStepsRequiredProps(type) {
@@ -509,6 +512,10 @@ APIKeyModal.propTypes = {
509
512
  * designates if modal is open or closed
510
513
  */
511
514
  open: _propTypes.default.bool.isRequired,
515
+ /**
516
+ * The DOM node the tearsheet should be rendered within. Defaults to document.body.
517
+ */
518
+ portalTarget: _propTypes.default.node,
512
519
  /**
513
520
  * text that displays in the secondary button when using custom steps to indicate to the user that there is a previous step
514
521
  */
@@ -18,7 +18,8 @@ var _settings = require("../../settings");
18
18
  var _uuidv = _interopRequireDefault(require("../../global/js/utils/uuidv4"));
19
19
  var _devtools = require("../../global/js/utils/devtools");
20
20
  var _react2 = require("@carbon/react");
21
- var _excluded = ["additionalInfo", "className", "closeIconDescription", "copyrightText", "content", "links", "logo", "modalAriaLabel", "onClose", "open", "title", "version"];
21
+ var _usePortalTarget = require("../../global/js/hooks/usePortalTarget");
22
+ var _excluded = ["additionalInfo", "className", "closeIconDescription", "copyrightText", "content", "links", "logo", "modalAriaLabel", "onClose", "open", "portalTarget", "title", "version"];
22
23
  /**
23
24
  * Copyright IBM Corp. 2020, 2021
24
25
  *
@@ -56,6 +57,7 @@ var AboutModal = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
56
57
  modalAriaLabel = _ref.modalAriaLabel,
57
58
  onClose = _ref.onClose,
58
59
  open = _ref.open,
60
+ portalTargetIn = _ref.portalTarget,
59
61
  title = _ref.title,
60
62
  version = _ref.version,
61
63
  rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
@@ -66,6 +68,7 @@ var AboutModal = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
66
68
  var bodyRef = (0, _react.useRef)();
67
69
  var contentRef = (0, _react.useRef)();
68
70
  var contentId = (0, _uuidv.default)();
71
+ var renderPortalUse = (0, _usePortalTarget.usePortalTarget)(portalTargetIn);
69
72
  var handleResize = function handleResize() {
70
73
  setHasScrollingContent(
71
74
  // if our scroll height exceeds the client height enable scrolling
@@ -82,7 +85,7 @@ var AboutModal = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
82
85
 
83
86
  // Detect resize of the ModalBody to recalculate whether scrolling is enabled
84
87
  (0, _useResizeObserver.useResizeObserver)(bodyRef, handleResize);
85
- return /*#__PURE__*/_react.default.createElement(_react2.ComposedModal, (0, _extends2.default)({}, rest, {
88
+ return renderPortalUse( /*#__PURE__*/_react.default.createElement(_react2.ComposedModal, (0, _extends2.default)({}, rest, {
86
89
  className: (0, _classnames.default)(blockClass,
87
90
  // Apply the block class to the main HTML element
88
91
  className // Apply any supplied class names to the main HTML element.
@@ -126,7 +129,7 @@ var AboutModal = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
126
129
  theme: "g100"
127
130
  }, /*#__PURE__*/_react.default.createElement(_react2.ModalFooter, {
128
131
  className: "".concat(blockClass, "__footer")
129
- }, additionalInfo)));
132
+ }, additionalInfo))));
130
133
  });
131
134
 
132
135
  // Return a placeholder if not released and not enabled by feature flag
@@ -185,6 +188,10 @@ AboutModal.propTypes = {
185
188
  * Specifies whether the AboutModal is open or not.
186
189
  */
187
190
  open: _propTypes.default.bool,
191
+ /**
192
+ * The DOM node the tearsheet should be rendered within. Defaults to document.body.
193
+ */
194
+ portalTarget: _propTypes.default.node,
188
195
  /**
189
196
  * Header text that provides the product name. The IBM Services logo
190
197
  * consists of two discrete, but required, elements: the iconic
@@ -17,8 +17,8 @@ var _useResizeObserver = require("../../global/js/hooks/useResizeObserver");
17
17
  var _react2 = require("@carbon/react");
18
18
  var _settings = require("../../settings");
19
19
  var _propsHelper = require("../../global/js/utils/props-helper");
20
- var _excluded = ["buttons"],
21
- _excluded2 = ["label", "key", "kind"],
20
+ var _excluded = ["isHidden", "buttons"],
21
+ _excluded2 = ["label", "key", "kind", "id"],
22
22
  _excluded3 = ["buttons"],
23
23
  _excluded4 = ["key", "kind"];
24
24
  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); }
@@ -105,7 +105,9 @@ var ButtonSetWithOverflow = function ButtonSetWithOverflow(_ref) {
105
105
  // eslint-disable-next-line react-hooks/exhaustive-deps
106
106
  }, [buttons]);
107
107
  var AButtonSet = /*#__PURE__*/_react.default.forwardRef(function (_ref2, ref) {
108
- var buttons = _ref2.buttons,
108
+ var _ref2$isHidden = _ref2.isHidden,
109
+ isHidden = _ref2$isHidden === void 0 ? false : _ref2$isHidden,
110
+ buttons = _ref2.buttons,
109
111
  rest = (0, _objectWithoutProperties2.default)(_ref2, _excluded);
110
112
  return /*#__PURE__*/_react.default.createElement(_react2.ButtonSet, (0, _extends2.default)({}, rest, {
111
113
  ref: ref
@@ -113,16 +115,25 @@ var ButtonSetWithOverflow = function ButtonSetWithOverflow(_ref) {
113
115
  var label = _ref3.label,
114
116
  key = _ref3.key,
115
117
  kind = _ref3.kind,
118
+ id = _ref3.id,
116
119
  other = (0, _objectWithoutProperties2.default)(_ref3, _excluded2);
117
120
  var kindFix = kind === 'default' ? 'primary' : kind;
118
121
  return /*#__PURE__*/_react.default.createElement(_react2.Button, (0, _extends2.default)({}, other, {
119
122
  key: key && "button-set-".concat(key),
120
123
  size: buttonSize,
121
124
  type: "button",
122
- kind: kindFix
125
+ kind: kindFix,
126
+ id: id ? isHidden ? "".concat(id, "--hidden") : id : null
123
127
  }), label);
124
128
  }));
125
129
  });
130
+ AButtonSet.propTypes = {
131
+ /**
132
+ * isHidden - Used to conditionally change id if one is passed to the `AButtonSet` component
133
+ * in order to avoid duplicate ids between the visible and hidden button set buttons
134
+ */
135
+ isHidden: _propTypes.default.bool
136
+ };
126
137
  var AButtonMenu = /*#__PURE__*/_react.default.forwardRef(function (_ref4, ref) {
127
138
  var buttons = _ref4.buttons,
128
139
  rest = (0, _objectWithoutProperties2.default)(_ref4, _excluded3);
@@ -153,7 +164,8 @@ var ButtonSetWithOverflow = function ButtonSetWithOverflow(_ref) {
153
164
  "aria-hidden": true,
154
165
  ref: sizingContainerRefSet,
155
166
  size: buttonSize,
156
- buttons: buttons
167
+ buttons: buttons,
168
+ isHidden: true
157
169
  })), /*#__PURE__*/_react.default.createElement("div", {
158
170
  className: "".concat(blockClass, "__button-container ").concat(blockClass, "__button-container--hidden"),
159
171
  "aria-hidden": true
@@ -13,7 +13,8 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
13
13
  var _classnames = _interopRequireDefault(require("classnames"));
14
14
  var _devtools = require("../../global/js/utils/devtools");
15
15
  var _settings = require("../../settings");
16
- var _excluded = ["className", "children", "onRequestClose", "onRequestSubmit", "open", "title", "subtitle", "description", "secondaryButtonText", "primaryButtonText", "disableSubmit", "selectorPrimaryFocus"];
16
+ var _usePortalTarget = require("../../global/js/hooks/usePortalTarget");
17
+ var _excluded = ["className", "children", "onRequestClose", "onRequestSubmit", "open", "title", "subtitle", "description", "secondaryButtonText", "portalTarget", "primaryButtonText", "disableSubmit", "selectorPrimaryFocus"];
17
18
  /**
18
19
  * Copyright IBM Corp. 2021, 2021
19
20
  *
@@ -52,11 +53,13 @@ var CreateModal = /*#__PURE__*/_react.default.forwardRef(function (_ref2, ref) {
52
53
  subtitle = _ref2.subtitle,
53
54
  description = _ref2.description,
54
55
  secondaryButtonText = _ref2.secondaryButtonText,
56
+ portalTargetIn = _ref2.portalTarget,
55
57
  primaryButtonText = _ref2.primaryButtonText,
56
58
  disableSubmit = _ref2.disableSubmit,
57
59
  selectorPrimaryFocus = _ref2.selectorPrimaryFocus,
58
60
  rest = (0, _objectWithoutProperties2.default)(_ref2, _excluded);
59
- return /*#__PURE__*/_react.default.createElement(_react2.ComposedModal, (0, _extends2.default)({}, rest, {
61
+ var renderPortalUse = (0, _usePortalTarget.usePortalTarget)(portalTargetIn);
62
+ return renderPortalUse( /*#__PURE__*/_react.default.createElement(_react2.ComposedModal, (0, _extends2.default)({}, rest, {
60
63
  selectorPrimaryFocus: selectorPrimaryFocus,
61
64
  className: (0, _classnames.default)(blockClass, className),
62
65
  open: open,
@@ -89,7 +92,7 @@ var CreateModal = /*#__PURE__*/_react.default.forwardRef(function (_ref2, ref) {
89
92
  kind: "primary",
90
93
  onClick: onRequestSubmit,
91
94
  disabled: disableSubmit
92
- }, primaryButtonText)));
95
+ }, primaryButtonText))));
93
96
  });
94
97
 
95
98
  // Return a placeholder if not released and not enabled by feature flag
@@ -127,6 +130,10 @@ CreateModal.propTypes = {
127
130
  * Specifies whether the CreateModal is open or not.
128
131
  */
129
132
  open: _propTypes.default.bool,
133
+ /**
134
+ * The DOM node the tearsheet should be rendered within. Defaults to document.body.
135
+ */
136
+ portalTarget: _propTypes.default.node,
130
137
  /**
131
138
  * Specifies the primary button's text in the modal.
132
139
  */