@carbon/ibm-products 2.43.2-canary.306 → 2.43.2-canary.307

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,11 +5,13 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- import { slicedToArray as _slicedToArray } from '../../_virtual/_rollupPluginBabelHelpers.js';
8
+ import { objectWithoutProperties as _objectWithoutProperties, objectSpread2 as _objectSpread2, slicedToArray as _slicedToArray } from '../../_virtual/_rollupPluginBabelHelpers.js';
9
9
  import React__default, { useContext, useState, useRef, useEffect, createContext } from 'react';
10
10
  import PropTypes from '../../_virtual/index.js';
11
11
  import { createScope, FeatureFlags as FeatureFlags$1 } from '@carbon/feature-flags';
12
12
 
13
+ var _excluded = ["children", "flags"];
14
+
13
15
  /**
14
16
  * Our FeatureFlagContext is used alongside the FeatureFlags component to enable
15
17
  * or disable feature flags in a given React tree
@@ -17,21 +19,27 @@ import { createScope, FeatureFlags as FeatureFlags$1 } from '@carbon/feature-fla
17
19
  var FeatureFlagContext = /*#__PURE__*/createContext(FeatureFlags$1);
18
20
 
19
21
  /**
20
- * Supports an object of feature flag values with the `flags` prop, merging them
22
+ * Supports individual feature flag values as props, merging them
21
23
  * along with the current `FeatureFlagContext` to provide consumers to check if
22
24
  * a feature flag is enabled or disabled in a given React tree
23
25
  */
24
26
  function FeatureFlags(_ref) {
25
27
  var children = _ref.children,
26
28
  _ref$flags = _ref.flags,
27
- flags = _ref$flags === void 0 ? {} : _ref$flags;
29
+ flags = _ref$flags === void 0 ? {} : _ref$flags,
30
+ newFlags = _objectWithoutProperties(_ref, _excluded);
28
31
  var parentScope = useContext(FeatureFlagContext);
32
+ var newFlagsObject = Object.keys(newFlags).reduce(function (acc, key) {
33
+ acc[key] = newFlags[key];
34
+ return acc;
35
+ }, {});
36
+ var combinedFlags = _objectSpread2(_objectSpread2({}, newFlagsObject), flags);
29
37
  var _useState = useState(parentScope),
30
38
  _useState2 = _slicedToArray(_useState, 2),
31
39
  prevParentScope = _useState2[0],
32
40
  setPrevParentScope = _useState2[1];
33
41
  var _useState3 = useState(function () {
34
- var scope = createScope(flags);
42
+ var scope = createScope(combinedFlags);
35
43
  scope.mergeWithScope(parentScope);
36
44
  return scope;
37
45
  }),
@@ -39,16 +47,15 @@ function FeatureFlags(_ref) {
39
47
  scope = _useState4[0],
40
48
  updateScope = _useState4[1];
41
49
  if (parentScope !== prevParentScope) {
42
- var _scope = createScope(flags);
50
+ var _scope = createScope(combinedFlags);
43
51
  _scope.mergeWithScope(parentScope);
44
52
  updateScope(_scope);
45
53
  setPrevParentScope(parentScope);
46
54
  }
47
55
 
48
- // We use a custom hook to detect if any of the keys or their values change
49
- // for flags that are passed in. If they have changed, then we re-create the
50
- // FeatureFlagScope using the new flags
51
- useChangedValue(flags, isEqual, function (changedFlags) {
56
+ // We use a custom hook to detect if any of the individual flag props or their values change
57
+ // If any flags have changed, we re-create the FeatureFlagScope using the updated flags
58
+ useChangedValue(combinedFlags, isEqual, function (changedFlags) {
52
59
  var scope = createScope(changedFlags);
53
60
  scope.mergeWithScope(parentScope);
54
61
  updateScope(scope);
@@ -60,7 +67,7 @@ function FeatureFlags(_ref) {
60
67
  FeatureFlags.propTypes = {
61
68
  children: PropTypes.node,
62
69
  /**
63
- * Provide the feature flags to enabled or disabled in the current React tree
70
+ * Provide the feature flags to enabled or disabled in the current React tree, this has been deprecated. as we are going to pass individual boolean props for each flag.
64
71
  */
65
72
  flags: PropTypes.objectOf(PropTypes.bool)
66
73
  };
@@ -260,9 +260,7 @@ var TearsheetShell = /*#__PURE__*/React__default.forwardRef(function (_ref, ref)
260
260
  return _defineProperty(_defineProperty({}, "--".concat(bc, "--stacking-scale-factor-single"), (width - 32) / width), "--".concat(bc, "--stacking-scale-factor-double"), (width - 64) / width);
261
261
  };
262
262
  return renderPortalUse( /*#__PURE__*/React__default.createElement(unstable_FeatureFlags, {
263
- flags: {
264
- 'enable-experimental-focus-wrap-without-sentinels': true
265
- }
263
+ enableExperimentalFocusWrapWithoutSentinels: true
266
264
  }, /*#__PURE__*/React__default.createElement(ComposedModal, _extends({}, rest, {
267
265
  "aria-label": ariaLabel || getNodeTextContent(title),
268
266
  className: cx(bc, className, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, "".concat(bc, "--stacked-").concat(position, "-of-").concat(depth),