@carbon/ibm-products 2.41.0 → 2.41.1-canary.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. package/css/index-full-carbon.css +6 -0
  2. package/css/index-full-carbon.css.map +1 -1
  3. package/css/index-full-carbon.min.css +1 -1
  4. package/css/index-full-carbon.min.css.map +1 -1
  5. package/css/index-without-carbon-released-only.css +6 -0
  6. package/css/index-without-carbon-released-only.css.map +1 -1
  7. package/css/index-without-carbon-released-only.min.css +1 -1
  8. package/css/index-without-carbon-released-only.min.css.map +1 -1
  9. package/css/index-without-carbon.css +6 -0
  10. package/css/index-without-carbon.css.map +1 -1
  11. package/css/index-without-carbon.min.css +1 -1
  12. package/css/index-without-carbon.min.css.map +1 -1
  13. package/css/index.css +6 -0
  14. package/css/index.css.map +1 -1
  15. package/css/index.min.css +1 -1
  16. package/css/index.min.css.map +1 -1
  17. package/es/components/Coachmark/Coachmark.js +2 -1
  18. package/es/components/CreateTearsheet/CreateTearsheetStep.js +30 -6
  19. package/es/components/Datagrid/Datagrid/DatagridContent.js +21 -1
  20. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/TearsheetWrapper.js +12 -2
  21. package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditButton/InlineEditButton.d.ts +3 -3
  22. package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditButton/InlineEditButton.js +5 -5
  23. package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditCell/InlineEditCell.d.ts +3 -1
  24. package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditCell/InlineEditCell.js +12 -3
  25. package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/InlineEditContext.js +7 -0
  26. package/es/components/Datagrid/useCustomizeColumns.js +0 -4
  27. package/es/components/Datagrid/useEditableCell.js +1 -1
  28. package/es/components/Datagrid/useFocusRowExpander.js +1 -1
  29. package/es/components/Datagrid/useInlineEdit.d.ts +1 -1
  30. package/es/components/Datagrid/useInlineEdit.js +9 -16
  31. package/es/components/EditUpdateCards/EditUpdateCards.d.ts +4 -3
  32. package/es/components/FeatureFlags/index.d.ts +37 -0
  33. package/es/components/FeatureFlags/index.js +151 -0
  34. package/es/components/ProductiveCard/ProductiveCard.d.ts +115 -2
  35. package/es/components/ProductiveCard/ProductiveCard.js +9 -9
  36. package/es/components/TagOverflow/TagOverflowModal.d.ts +34 -28
  37. package/es/components/TagOverflow/TagOverflowModal.js +4 -4
  38. package/es/components/index.d.ts +1 -0
  39. package/es/feature-flags.d.ts +1 -0
  40. package/es/global/js/hooks/usePortalTarget.js +4 -2
  41. package/es/index.js +1 -0
  42. package/lib/components/Coachmark/Coachmark.js +2 -1
  43. package/lib/components/CreateTearsheet/CreateTearsheetStep.js +29 -5
  44. package/lib/components/Datagrid/Datagrid/DatagridContent.js +49 -29
  45. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/TearsheetWrapper.js +13 -19
  46. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditButton/InlineEditButton.d.ts +3 -3
  47. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditButton/InlineEditButton.js +5 -5
  48. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditCell/InlineEditCell.d.ts +3 -1
  49. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditCell/InlineEditCell.js +12 -3
  50. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/InlineEditContext.js +7 -0
  51. package/lib/components/Datagrid/useCustomizeColumns.js +0 -4
  52. package/lib/components/Datagrid/useEditableCell.js +1 -1
  53. package/lib/components/Datagrid/useFocusRowExpander.js +1 -1
  54. package/lib/components/Datagrid/useInlineEdit.d.ts +1 -1
  55. package/lib/components/Datagrid/useInlineEdit.js +8 -15
  56. package/lib/components/EditUpdateCards/EditUpdateCards.d.ts +4 -3
  57. package/lib/components/FeatureFlags/index.d.ts +37 -0
  58. package/lib/components/FeatureFlags/index.js +162 -0
  59. package/lib/components/ProductiveCard/ProductiveCard.d.ts +115 -2
  60. package/lib/components/ProductiveCard/ProductiveCard.js +9 -9
  61. package/lib/components/TagOverflow/TagOverflowModal.d.ts +34 -28
  62. package/lib/components/TagOverflow/TagOverflowModal.js +2 -2
  63. package/lib/components/index.d.ts +1 -0
  64. package/lib/feature-flags.d.ts +1 -0
  65. package/lib/global/js/hooks/usePortalTarget.js +4 -2
  66. package/lib/index.js +4 -0
  67. package/package.json +7 -3
  68. package/scss/components/Datagrid/styles/_useInlineEdit.scss +6 -0
@@ -6,7 +6,7 @@
6
6
  */
7
7
 
8
8
  import { objectWithoutProperties as _objectWithoutProperties, slicedToArray as _slicedToArray, extends as _extends, defineProperty as _defineProperty } from '../../_virtual/_rollupPluginBabelHelpers.js';
9
- import React__default, { forwardRef, useContext, useState, useEffect, isValidElement } from 'react';
9
+ import React__default, { forwardRef, useRef, useContext, useState, useEffect, isValidElement } from 'react';
10
10
  import PropTypes from '../../node_modules/prop-types/index.js';
11
11
  import cx from 'classnames';
12
12
  import { Grid, Column, FormGroup } from '@carbon/react';
@@ -44,6 +44,9 @@ var CreateTearsheetStep = /*#__PURE__*/forwardRef(function (_ref, ref) {
44
44
  subtitle = _ref.subtitle,
45
45
  title = _ref.title,
46
46
  rest = _objectWithoutProperties(_ref, _excluded);
47
+ var localRef = useRef(null);
48
+ var stepRef = ref || localRef;
49
+ var stepRefValue = stepRef.current;
47
50
  var stepsContext = useContext(StepsContext);
48
51
  var stepNumber = useContext(StepNumberContext);
49
52
  var _useState = useState(includeStep),
@@ -75,16 +78,36 @@ var CreateTearsheetStep = /*#__PURE__*/forwardRef(function (_ref, ref) {
75
78
  useEffect(function () {
76
79
  setShouldIncludeStep(includeStep);
77
80
  }, [includeStep, stepsContext, title]);
81
+ var setFocusChildrenTabIndex = function setFocusChildrenTabIndex(childInputs, value) {
82
+ if (childInputs !== null && childInputs !== void 0 && childInputs.length) {
83
+ childInputs.forEach(function (child) {
84
+ child.tabIndex = value;
85
+ });
86
+ }
87
+ };
78
88
 
79
89
  // Whenever we are the current step, supply our disableSubmit and onNext values to the
80
90
  // steps container context so that it can manage the 'Next' button appropriately.
81
91
  useEffect(function () {
92
+ var focusElementQuery = "button, input, select, textarea, a";
93
+ if (stepNumber !== (stepsContext === null || stepsContext === void 0 ? void 0 : stepsContext.currentStep)) {
94
+ // Specify tab-index -1 for focusable elements not contained
95
+ // in the current step so that the useFocus hook can exclude
96
+ // from the focus trap
97
+ var childInputs = stepRefValue === null || stepRefValue === void 0 ? void 0 : stepRefValue.querySelectorAll(focusElementQuery);
98
+ setFocusChildrenTabIndex(childInputs, -1);
99
+ }
82
100
  if (stepNumber === (stepsContext === null || stepsContext === void 0 ? void 0 : stepsContext.currentStep)) {
101
+ // Specify tab-index 0 for current step focusable elements
102
+ // for the useFocus hook to know which elements to include
103
+ // in focus trap
104
+ var _childInputs = stepRefValue === null || stepRefValue === void 0 ? void 0 : stepRefValue.querySelectorAll(focusElementQuery);
105
+ setFocusChildrenTabIndex(_childInputs, 0);
83
106
  stepsContext.setIsDisabled(!!disableSubmit);
84
107
  stepsContext === null || stepsContext === void 0 || stepsContext.setOnNext(onNext); // needs to be updated here otherwise there could be stale state values from only initially setting onNext
85
108
  stepsContext === null || stepsContext === void 0 || stepsContext.setOnPrevious(onPrevious);
86
109
  }
87
- }, [stepsContext, stepNumber, disableSubmit, onNext, onPrevious]);
110
+ }, [stepsContext, stepNumber, disableSubmit, onNext, onPrevious, stepRef, stepRefValue]);
88
111
  var renderDescription = function renderDescription() {
89
112
  if (description) {
90
113
  if (typeof description === 'string') {
@@ -100,9 +123,10 @@ var CreateTearsheetStep = /*#__PURE__*/forwardRef(function (_ref, ref) {
100
123
  }
101
124
  return null;
102
125
  };
103
- return stepsContext ? /*#__PURE__*/React__default.createElement(Grid, _extends({}, rest, {
104
- className: cx(blockClass, className, _defineProperty(_defineProperty({}, "".concat(blockClass, "__step--hidden-step"), stepNumber !== (stepsContext === null || stepsContext === void 0 ? void 0 : stepsContext.currentStep)), "".concat(blockClass, "__step--visible-step"), stepNumber === (stepsContext === null || stepsContext === void 0 ? void 0 : stepsContext.currentStep))),
105
- ref: ref
126
+ return stepsContext ? /*#__PURE__*/React__default.createElement("div", {
127
+ ref: stepRef
128
+ }, /*#__PURE__*/React__default.createElement(Grid, _extends({}, rest, {
129
+ className: cx(blockClass, className, _defineProperty(_defineProperty({}, "".concat(blockClass, "__step--hidden-step"), stepNumber !== (stepsContext === null || stepsContext === void 0 ? void 0 : stepsContext.currentStep)), "".concat(blockClass, "__step--visible-step"), stepNumber === (stepsContext === null || stepsContext === void 0 ? void 0 : stepsContext.currentStep)))
106
130
  }), /*#__PURE__*/React__default.createElement(Column, {
107
131
  xlg: 12,
108
132
  lg: 12,
@@ -117,7 +141,7 @@ var CreateTearsheetStep = /*#__PURE__*/forwardRef(function (_ref, ref) {
117
141
  }, hasFieldset ? /*#__PURE__*/React__default.createElement(FormGroup, {
118
142
  legendText: fieldsetLegendText,
119
143
  className: "".concat(blockClass, "--fieldset")
120
- }, children) : children)) : pconsole.warn("You have tried using a ".concat(componentName, " component outside of a CreateTearsheet. This is not allowed. ").concat(componentName, "s should always be children of the CreateTearsheet"));
144
+ }, children) : children))) : pconsole.warn("You have tried using a ".concat(componentName, " component outside of a CreateTearsheet. This is not allowed. ").concat(componentName, "s should always be children of the CreateTearsheet"));
121
145
  });
122
146
 
123
147
  // Return a placeholder if not released and not enabled by feature flag
@@ -19,6 +19,7 @@ import { handleGridFocus } from './addons/InlineEdit/handleGridFocus.js';
19
19
  import { handleGridKeyPress } from './addons/InlineEdit/handleGridKeyPress.js';
20
20
  import { px } from '@carbon/layout';
21
21
  import { FilterContext, clearSingleFilter } from './addons/Filtering/FilterProvider.js';
22
+ import { useFeatureFlag } from '../../FeatureFlags/index.js';
22
23
  import { InlineEditContext } from './addons/InlineEdit/InlineEditContext/InlineEditContext.js';
23
24
  import { useClickOutside } from '../../../global/js/hooks/useClickOutside.js';
24
25
  import { useMultipleKeyTracking } from '../../DataSpreadsheet/hooks/useMultipleKeyTracking.js';
@@ -41,7 +42,8 @@ var DatagridContent = function DatagridContent(_ref) {
41
42
  panelOpen = _useContext2.panelOpen;
42
43
  var activeCellId = inlineEditState.activeCellId,
43
44
  gridActive = inlineEditState.gridActive,
44
- editId = inlineEditState.editId;
45
+ editId = inlineEditState.editId,
46
+ featureFlags = inlineEditState.featureFlags;
45
47
  var getTableProps = datagridState.getTableProps,
46
48
  getFilterFlyoutProps = datagridState.getFilterFlyoutProps,
47
49
  withVirtualScroll = datagridState.withVirtualScroll,
@@ -69,6 +71,24 @@ var DatagridContent = function DatagridContent(_ref) {
69
71
  var contentRows = DatagridPagination && page || rows;
70
72
  var gridAreaRef = useRef();
71
73
  var multiKeyTrackingRef = useRef();
74
+ var enableEditableCell = useFeatureFlag('enable-datagrid-useEditableCell');
75
+ var enableInlineEdit = useFeatureFlag('enable-datagrid-useInlineEdit');
76
+ var enableCustomizeCols = useFeatureFlag('enable-datagrid-useCustomizeColumns');
77
+ useEffect(function () {
78
+ dispatch({
79
+ type: 'SET_FEATURE_FLAGS',
80
+ payload: {
81
+ 'enable-datagrid-useEditableCell': enableEditableCell,
82
+ 'enable-datagrid-useInlineEdit': enableInlineEdit,
83
+ 'enable-datagrid-useCustomizeColumns': enableCustomizeCols
84
+ }
85
+ });
86
+ }, [dispatch, enableEditableCell, enableCustomizeCols, enableInlineEdit]);
87
+ useEffect(function () {
88
+ if (featureFlags && (featureFlags !== null && featureFlags !== void 0 && featureFlags['enable-datagrid-useEditableCell'] || featureFlags !== null && featureFlags !== void 0 && featureFlags['enable-datagrid-useInlineEdit'])) {
89
+ console.error("Datagrid useEditableCell/useInlineEdit extension has not been enabled via feature flag.");
90
+ }
91
+ }, [featureFlags]);
72
92
  useClickOutside(gridAreaRef, function (target) {
73
93
  if (!withInlineEdit) {
74
94
  return;
@@ -6,9 +6,10 @@
6
6
  */
7
7
 
8
8
  import { objectWithoutProperties as _objectWithoutProperties, extends as _extends } from '../../../../../_virtual/_rollupPluginBabelHelpers.js';
9
- import * as React from 'react';
9
+ import React__default, { useContext, useEffect } from 'react';
10
10
  import PropTypes from '../../../../../node_modules/prop-types/index.js';
11
11
  import CustomizeColumnsTearsheet from './CustomizeColumnsTearsheet.js';
12
+ import { InlineEditContext } from '../InlineEdit/InlineEditContext/InlineEditContext.js';
12
13
 
13
14
  var _excluded = ["onSaveColumnPrefs", "isTearsheetOpen", "setIsTearsheetOpen", "labels"];
14
15
  var TearsheetWrapper = function TearsheetWrapper(_ref) {
@@ -19,7 +20,16 @@ var TearsheetWrapper = function TearsheetWrapper(_ref) {
19
20
  setIsTearsheetOpen = _instance$customizeCo.setIsTearsheetOpen,
20
21
  labels = _instance$customizeCo.labels,
21
22
  rest = _objectWithoutProperties(_instance$customizeCo, _excluded);
22
- return /*#__PURE__*/React.createElement(CustomizeColumnsTearsheet, _extends({}, rest, labels, {
23
+ var _useContext = useContext(InlineEditContext),
24
+ state = _useContext.state;
25
+ var _ref2 = state || {},
26
+ featureFlags = _ref2.featureFlags;
27
+ useEffect(function () {
28
+ if (featureFlags && !(featureFlags !== null && featureFlags !== void 0 && featureFlags['enable-datagrid-useCustomizeColumns'])) {
29
+ console.error("Datagrid useCustomizeColumns extension has not been enabled via feature flag.");
30
+ }
31
+ }, [featureFlags]);
32
+ return /*#__PURE__*/React__default.createElement(CustomizeColumnsTearsheet, _extends({}, rest, labels, {
23
33
  isOpen: isTearsheetOpen,
24
34
  setIsTearsheetOpen: setIsTearsheetOpen,
25
35
  columnDefinitions: instance.allColumns,
@@ -1,9 +1,9 @@
1
- export function InlineEditButton({ label, renderIcon: Icon, disabled, labelIcon: LabelIcon, placeholder, nonEditCell, isActiveCell, columnConfig, type, }: {
1
+ export function InlineEditButton({ label, renderIcon: Icon, labelIcon: LabelIcon, placeholder, disabledCell, nonEditCell, isActiveCell, columnConfig, type, }: {
2
2
  label: any;
3
3
  renderIcon: any;
4
- disabled: any;
5
4
  labelIcon: any;
6
5
  placeholder: any;
6
+ disabledCell: any;
7
7
  nonEditCell: any;
8
8
  isActiveCell: any;
9
9
  columnConfig: any;
@@ -12,7 +12,7 @@ export function InlineEditButton({ label, renderIcon: Icon, disabled, labelIcon:
12
12
  export namespace InlineEditButton {
13
13
  namespace propTypes {
14
14
  let columnConfig: PropTypes.Requireable<object>;
15
- let disabled: PropTypes.Requireable<boolean>;
15
+ let disabledCell: PropTypes.Requireable<boolean>;
16
16
  let isActiveCell: PropTypes.Requireable<boolean>;
17
17
  let label: PropTypes.Requireable<NonNullable<string | number | null | undefined>>;
18
18
  let labelIcon: PropTypes.Requireable<object>;
@@ -15,18 +15,18 @@ var blockClass = "".concat(pkg.prefix, "--datagrid");
15
15
  var InlineEditButton = function InlineEditButton(_ref) {
16
16
  var label = _ref.label,
17
17
  Icon = _ref.renderIcon,
18
- disabled = _ref.disabled,
19
18
  LabelIcon = _ref.labelIcon,
20
19
  placeholder = _ref.placeholder,
20
+ disabledCell = _ref.disabledCell,
21
21
  nonEditCell = _ref.nonEditCell,
22
22
  isActiveCell = _ref.isActiveCell,
23
23
  columnConfig = _ref.columnConfig,
24
24
  type = _ref.type;
25
25
  return /*#__PURE__*/React__default.createElement("div", {
26
- className: cx("".concat(blockClass, "__inline-edit-button"), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, "".concat(blockClass, "__inline-edit-button--disabled"), disabled || nonEditCell), "".concat(blockClass, "__inline-edit-button--with-label-icon"), LabelIcon), "".concat(blockClass, "__inline-edit-button--non-edit"), nonEditCell), "".concat(blockClass, "__inline-edit-button--active"), isActiveCell), "".concat(blockClass, "__inline-edit-button--").concat(type), type === 'date' || type === 'selection')),
26
+ className: cx("".concat(blockClass, "__inline-edit-button"), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, "".concat(blockClass, "__inline-edit-button--disabled"), disabledCell), "".concat(blockClass, "__inline-edit-button--with-label-icon"), LabelIcon), "".concat(blockClass, "__inline-edit-button--non-edit"), nonEditCell), "".concat(blockClass, "__inline-edit-button--active"), isActiveCell), "".concat(blockClass, "__inline-edit-button--").concat(type), type === 'date' || type === 'selection')),
27
27
  tabIndex: isActiveCell ? 0 : -1,
28
- "data-disabled": disabled || nonEditCell,
29
- "aria-disabled": disabled || nonEditCell,
28
+ "data-disabled": disabledCell,
29
+ "aria-disabled": disabledCell,
30
30
  role: "button",
31
31
  title: label
32
32
  }, LabelIcon && /*#__PURE__*/React__default.createElement("div", {
@@ -41,7 +41,7 @@ var InlineEditButton = function InlineEditButton(_ref) {
41
41
  };
42
42
  InlineEditButton.propTypes = {
43
43
  columnConfig: PropTypes.object,
44
- disabled: PropTypes.bool,
44
+ disabledCell: PropTypes.bool,
45
45
  isActiveCell: PropTypes.bool,
46
46
  label: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
47
47
  labelIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
@@ -1,6 +1,7 @@
1
- export function InlineEditCell({ cell, config, instance, placeholder, tabIndex, value, nonEditCell, type, }: {
1
+ export function InlineEditCell({ cell, config, disabledCell, instance, placeholder, tabIndex, value, nonEditCell, type, }: {
2
2
  cell: any;
3
3
  config: any;
4
+ disabledCell?: boolean | undefined;
4
5
  instance: any;
5
6
  placeholder?: string | undefined;
6
7
  tabIndex: any;
@@ -12,6 +13,7 @@ export namespace InlineEditCell {
12
13
  namespace propTypes {
13
14
  let cell: PropTypes.Requireable<object>;
14
15
  let config: PropTypes.Requireable<object>;
16
+ let disabledCell: PropTypes.Requireable<boolean>;
15
17
  let instance: PropTypes.Requireable<PropTypes.InferProps<{
16
18
  columns: PropTypes.Requireable<(object | null | undefined)[]>;
17
19
  onDataUpdate: PropTypes.Requireable<(...args: any[]) => any>;
@@ -22,6 +22,8 @@ var InlineEditCell = function InlineEditCell(_ref) {
22
22
  var _config$validator, _value$text;
23
23
  var cell = _ref.cell,
24
24
  config = _ref.config,
25
+ _ref$disabledCell = _ref.disabledCell,
26
+ disabledCell = _ref$disabledCell === void 0 ? false : _ref$disabledCell,
25
27
  instance = _ref.instance,
26
28
  _ref$placeholder = _ref.placeholder,
27
29
  placeholder = _ref$placeholder === void 0 ? '' : _ref$placeholder,
@@ -319,6 +321,11 @@ var InlineEditCell = function InlineEditCell(_ref) {
319
321
  return Calendar;
320
322
  }
321
323
  };
324
+ var renderRegularCell = function renderRegularCell() {
325
+ return /*#__PURE__*/React__default.createElement("span", _extends({}, inputProps, {
326
+ id: cellId
327
+ }));
328
+ };
322
329
  var renderDateCell = function renderDateCell() {
323
330
  var _config$inputProps, _outerButtonElement$c;
324
331
  var datePickerPreparedProps = prepareProps(config.inputProps, ['datePickerInputProps']);
@@ -434,15 +441,16 @@ var InlineEditCell = function InlineEditCell(_ref) {
434
441
  "data-cell-id": cellId,
435
442
  "data-column-index": columnIndex,
436
443
  "data-row-index": cell.row.index,
437
- "data-disabled": nonEditCell,
444
+ "data-disabled": disabledCell,
438
445
  "data-inline-type": type,
439
446
  onClick: !nonEditCell ? handleInlineCellClick : addActiveState,
440
447
  onKeyDown: !nonEditCell ? handleKeyDown : null,
441
- className: cx("".concat(blockClass, "__inline-edit--outer-cell-button"), _defineProperty(_defineProperty(_defineProperty({}, "".concat(blockClass, "__inline-edit--outer-cell-button--").concat(rowSize), rowSize), "".concat(blockClass, "__inline-edit--outer-cell-button--lg"), !rowSize), "".concat(blockClass, "__inline-edit--outer-cell-button--invalid"), config === null || config === void 0 || (_config$validator = config.validator) === null || _config$validator === void 0 ? void 0 : _config$validator.call(config, cellValue)))
442
- }, !inEditMode && /*#__PURE__*/React__default.createElement(InlineEditButton, {
448
+ className: cx("".concat(blockClass, "__inline-edit--outer-cell-button"), _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, "".concat(blockClass, "__inline-edit--outer-cell-button--").concat(rowSize), rowSize), "".concat(blockClass, "__inline-edit--outer-cell-button--lg"), !rowSize), "".concat(blockClass, "__inline-edit--outer-cell-button--invalid"), config === null || config === void 0 || (_config$validator = config.validator) === null || _config$validator === void 0 ? void 0 : _config$validator.call(config, cellValue)), "".concat(blockClass, "__static--outer-cell"), !disabledCell))
449
+ }, !nonEditCell && !disabledCell && renderRegularCell(), (!inEditMode || disabledCell) && /*#__PURE__*/React__default.createElement(InlineEditButton, {
443
450
  isActiveCell: cellId === activeCellId,
444
451
  renderIcon: setRenderIcon(),
445
452
  label: type === 'selection' ? (_value$text = value === null || value === void 0 ? void 0 : value.text) !== null && _value$text !== void 0 ? _value$text : value : type === 'date' ? buildDate(value) : value,
453
+ disabledCell: disabledCell,
446
454
  labelIcon: (value === null || value === void 0 ? void 0 : value.icon) || null,
447
455
  placeholder: placeholder,
448
456
  tabIndex: tabIndex,
@@ -455,6 +463,7 @@ var InlineEditCell = function InlineEditCell(_ref) {
455
463
  InlineEditCell.propTypes = {
456
464
  cell: PropTypes.object,
457
465
  config: PropTypes.object,
466
+ disabledCell: PropTypes.bool,
458
467
  instance: PropTypes.shape({
459
468
  columns: PropTypes.arrayOf(PropTypes.object),
460
469
  onDataUpdate: PropTypes.func,
@@ -73,6 +73,13 @@ var inlineEditReducer = function inlineEditReducer(state, action) {
73
73
  }
74
74
  break;
75
75
  }
76
+ case 'SET_FEATURE_FLAGS':
77
+ {
78
+ var _action$payload2;
79
+ return _objectSpread2(_objectSpread2({}, state), {}, {
80
+ featureFlags: (_action$payload2 = action.payload) !== null && _action$payload2 !== void 0 ? _action$payload2 : {}
81
+ });
82
+ }
76
83
  default:
77
84
  return state;
78
85
  }
@@ -7,14 +7,10 @@
7
7
 
8
8
  import { slicedToArray as _slicedToArray, objectSpread2 as _objectSpread2, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
9
9
  import * as React from 'react';
10
- import { pkg } from '../../settings.js';
11
10
  import ToggleButtonWrapper from './Datagrid/addons/CustomizeColumns/ButtonWrapper.js';
12
11
  import CustomizeColumnsTearsheetWrapper from './Datagrid/addons/CustomizeColumns/TearsheetWrapper.js';
13
12
 
14
13
  var useCustomizeColumns = function useCustomizeColumns(hooks) {
15
- React.useEffect(function () {
16
- pkg.checkReportFeatureEnabled('Datagrid.useCustomizeColumns');
17
- }, []);
18
14
  var _React$useState = React.useState(false),
19
15
  _React$useState2 = _slicedToArray(_React$useState, 2),
20
16
  isTearsheetOpen = _React$useState2[0],
@@ -8,7 +8,7 @@
8
8
  import useInlineEdit from './useInlineEdit.js';
9
9
 
10
10
  var useEditableCell = function useEditableCell(hooks) {
11
- useInlineEdit(hooks, 'usingEditableCell');
11
+ useInlineEdit(hooks);
12
12
  };
13
13
  var useEditableCell$1 = useEditableCell;
14
14
 
@@ -34,7 +34,7 @@ var useFocusRowExpander = function useFocusRowExpander(_ref) {
34
34
  });
35
35
  if (activeRow.length) {
36
36
  var rowExpander = activeRow[0].querySelector(".".concat(blockClass, "__row-expander"));
37
- rowExpander.focus();
37
+ rowExpander === null || rowExpander === void 0 || rowExpander.focus();
38
38
  }
39
39
  }, [instance === null || instance === void 0 ? void 0 : instance.tableId, instance === null || instance === void 0 ? void 0 : instance.expandedRows, lastExpandedRowIndex, blockClass, activeElement]);
40
40
  };
@@ -1,2 +1,2 @@
1
1
  export default useInlineEdit;
2
- declare function useInlineEdit(hooks: any, usingEditableCell: any): void;
2
+ declare function useInlineEdit(hooks: any): void;
@@ -5,34 +5,27 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- import { defineProperty as _defineProperty } from '../../_virtual/_rollupPluginBabelHelpers.js';
9
- import React__default, { useEffect } from 'react';
8
+ import React__default from 'react';
10
9
  import { pkg } from '../../settings.js';
11
10
  import cx from 'classnames';
12
11
  import { InlineEditCell } from './Datagrid/addons/InlineEdit/InlineEditCell/InlineEditCell.js';
13
12
 
14
13
  var blockClass = "".concat(pkg.prefix, "--datagrid");
15
- var useInlineEdit = function useInlineEdit(hooks, usingEditableCell) {
16
- useEffect(function () {
17
- if (!usingEditableCell) {
18
- pkg.checkReportFeatureEnabled('Datagrid.useInlineEdit');
19
- }
20
- if (usingEditableCell) {
21
- pkg.checkReportFeatureEnabled('Datagrid.useEditableCell');
22
- }
23
- }, [usingEditableCell]);
14
+ var useInlineEdit = function useInlineEdit(hooks) {
24
15
  var addInlineEdit = function addInlineEdit(props, _ref) {
25
- var _cell$column;
16
+ var _cell$column, _cell$column2;
26
17
  var cell = _ref.cell,
27
18
  instance = _ref.instance;
28
19
  var columnInlineEditConfig = cell.column.inlineEdit;
29
20
  var inlineEditType = (_cell$column = cell.column) === null || _cell$column === void 0 || (_cell$column = _cell$column.inlineEdit) === null || _cell$column === void 0 ? void 0 : _cell$column.type;
21
+ var isDisabled = (_cell$column2 = cell.column) === null || _cell$column2 === void 0 ? void 0 : _cell$column2.isDisabled;
30
22
  var renderInlineEditComponent = function renderInlineEditComponent(type) {
31
23
  return /*#__PURE__*/React__default.createElement(InlineEditCell, {
32
24
  config: columnInlineEditConfig,
33
25
  tabIndex: -1,
34
26
  value: cell.value,
35
27
  cell: cell,
28
+ isDisabled: isDisabled,
36
29
  instance: instance,
37
30
  type: type
38
31
  });
@@ -43,15 +36,15 @@ var useInlineEdit = function useInlineEdit(hooks, usingEditableCell) {
43
36
  }];
44
37
  }
45
38
  return [props, {
46
- className: cx("".concat(blockClass, "__cell"), _defineProperty({}, "".concat(blockClass, "__cell-inline-edit"), !!usingEditableCell || pkg.isFeatureEnabled('Datagrid.useInlineEdit') ? true : '')),
39
+ className: cx("".concat(blockClass, "__cell"), "".concat(blockClass, "__cell-inline-edit")),
47
40
  role: 'gridcell',
48
- children: (!!usingEditableCell || pkg.isFeatureEnabled('Datagrid.useInlineEdit')) && /*#__PURE__*/React__default.createElement(React__default.Fragment, null, inlineEditType === 'text' && renderInlineEditComponent(inlineEditType), inlineEditType === 'number' && renderInlineEditComponent(inlineEditType), inlineEditType === 'selection' && renderInlineEditComponent(inlineEditType), inlineEditType === 'date' && renderInlineEditComponent(inlineEditType), !inlineEditType && /*#__PURE__*/React__default.createElement(InlineEditCell, {
41
+ children: /*#__PURE__*/React__default.createElement(React__default.Fragment, null, inlineEditType === 'text' && renderInlineEditComponent(inlineEditType), inlineEditType === 'number' && renderInlineEditComponent(inlineEditType), inlineEditType === 'selection' && renderInlineEditComponent(inlineEditType), inlineEditType === 'date' && renderInlineEditComponent(inlineEditType), !inlineEditType && /*#__PURE__*/React__default.createElement(InlineEditCell, {
49
42
  config: columnInlineEditConfig,
50
43
  tabIndex: -1,
51
44
  value: cell.value,
52
45
  cell: cell,
53
46
  instance: instance,
54
- disabled: true,
47
+ disabledCell: isDisabled,
55
48
  nonEditCell: true,
56
49
  type: "text"
57
50
  }))
@@ -60,7 +53,7 @@ var useInlineEdit = function useInlineEdit(hooks, usingEditableCell) {
60
53
  hooks.getCellProps.push(addInlineEdit);
61
54
  hooks.useInstance.push(function (instance) {
62
55
  Object.assign(instance, {
63
- withInlineEdit: !!usingEditableCell || pkg.isFeatureEnabled('Datagrid.useInlineEdit') ? true : false
56
+ withInlineEdit: true
64
57
  });
65
58
  });
66
59
  };
@@ -14,6 +14,7 @@ type ActionIcon = {
14
14
  iconDescription: string;
15
15
  href?: string;
16
16
  };
17
+ type PlacementType = 'top' | 'bottom';
17
18
  interface EditUpdateCardsProps {
18
19
  /**
19
20
  * Icons that are displayed on card. Refer to design documentation for implementation guidelines
@@ -22,7 +23,7 @@ interface EditUpdateCardsProps {
22
23
  /**
23
24
  * Determines if the action icons are on the top or bottom of the card
24
25
  */
25
- actionsPlacement?: 'top' | 'bottom';
26
+ actionsPlacement?: PlacementType;
26
27
  /**
27
28
  * Optional label for the top of the card.
28
29
  */
@@ -66,7 +67,7 @@ interface EditUpdateCardsProps {
66
67
  /**
67
68
  * Determines if the primary button is on the top or bottom of the card
68
69
  */
69
- primaryButtonPlacement?: 'top' | 'bottom';
70
+ primaryButtonPlacement?: PlacementType;
70
71
  /**
71
72
  * The text that's displayed in the primary button
72
73
  */
@@ -86,7 +87,7 @@ interface EditUpdateCardsProps {
86
87
  /**
87
88
  * Determines if the secondary button is on the top or bottom of the card
88
89
  */
89
- secondaryButtonPlacement?: 'top' | 'bottom';
90
+ secondaryButtonPlacement?: PlacementType;
90
91
  /**
91
92
  * The text that's displayed in the secondary button
92
93
  */
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Supports an object of feature flag values with the `flags` prop, merging them
3
+ * along with the current `FeatureFlagContext` to provide consumers to check if
4
+ * a feature flag is enabled or disabled in a given React tree
5
+ */
6
+ export function FeatureFlags({ children, flags }: {
7
+ children: any;
8
+ flags?: {} | undefined;
9
+ }): import("react/jsx-runtime").JSX.Element;
10
+ export namespace FeatureFlags {
11
+ namespace propTypes {
12
+ let children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
13
+ let flags: PropTypes.Requireable<{
14
+ [x: string]: boolean | null | undefined;
15
+ }>;
16
+ }
17
+ }
18
+ /**
19
+ * Our FeatureFlagContext is used alongside the FeatureFlags component to enable
20
+ * or disable feature flags in a given React tree
21
+ */
22
+ export const FeatureFlagContext: React.Context<any>;
23
+ /**
24
+ * Access all feature flag information for the given FeatureFlagContext
25
+ *
26
+ * @returns {FeatureFlagScope}
27
+ */
28
+ export function useFeatureFlags(): FeatureFlagScope;
29
+ /**
30
+ * Access whether a given flag is enabled or disabled in a given
31
+ * FeatureFlagContext
32
+ *
33
+ * @returns {boolean}
34
+ */
35
+ export function useFeatureFlag(flag: any): boolean;
36
+ import PropTypes from 'prop-types';
37
+ import React from 'react';
@@ -0,0 +1,151 @@
1
+ /**
2
+ * Copyright IBM Corp. 2020, 2024
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
+
8
+ import { slicedToArray as _slicedToArray } from '../../_virtual/_rollupPluginBabelHelpers.js';
9
+ import React__default, { useContext, useState, useRef, useEffect, createContext } from 'react';
10
+ import PropTypes from '../../node_modules/prop-types/index.js';
11
+ import { createScope, FeatureFlags as FeatureFlags$1 } from '@carbon/feature-flags';
12
+
13
+ /**
14
+ * Our FeatureFlagContext is used alongside the FeatureFlags component to enable
15
+ * or disable feature flags in a given React tree
16
+ */
17
+ var FeatureFlagContext = /*#__PURE__*/createContext(FeatureFlags$1);
18
+
19
+ /**
20
+ * Supports an object of feature flag values with the `flags` prop, merging them
21
+ * along with the current `FeatureFlagContext` to provide consumers to check if
22
+ * a feature flag is enabled or disabled in a given React tree
23
+ */
24
+ function FeatureFlags(_ref) {
25
+ var children = _ref.children,
26
+ _ref$flags = _ref.flags,
27
+ flags = _ref$flags === void 0 ? {} : _ref$flags;
28
+ var parentScope = useContext(FeatureFlagContext);
29
+ var _useState = useState(parentScope),
30
+ _useState2 = _slicedToArray(_useState, 2),
31
+ prevParentScope = _useState2[0],
32
+ setPrevParentScope = _useState2[1];
33
+ var _useState3 = useState(function () {
34
+ var scope = createScope(flags);
35
+ scope.mergeWithScope(parentScope);
36
+ return scope;
37
+ }),
38
+ _useState4 = _slicedToArray(_useState3, 2),
39
+ scope = _useState4[0],
40
+ updateScope = _useState4[1];
41
+ if (parentScope !== prevParentScope) {
42
+ var _scope = createScope(flags);
43
+ _scope.mergeWithScope(parentScope);
44
+ updateScope(_scope);
45
+ setPrevParentScope(parentScope);
46
+ }
47
+
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) {
52
+ var scope = createScope(changedFlags);
53
+ scope.mergeWithScope(parentScope);
54
+ updateScope(scope);
55
+ });
56
+ return /*#__PURE__*/React__default.createElement(FeatureFlagContext.Provider, {
57
+ value: scope
58
+ }, children);
59
+ }
60
+ FeatureFlags.propTypes = {
61
+ children: PropTypes.node,
62
+ /**
63
+ * Provide the feature flags to enabled or disabled in the current React tree
64
+ */
65
+ flags: PropTypes.objectOf(PropTypes.bool)
66
+ };
67
+
68
+ /**
69
+ * This hook will store previous versions of the given `value` and compare the
70
+ * current value to the previous one using the `compare` function. If the
71
+ * compare function returns true, then the given `callback` is invoked in an
72
+ * effect.
73
+ *
74
+ * @param {any} value
75
+ * @param {Function} compare
76
+ * @param {Function} callback
77
+ */
78
+ function useChangedValue(value, compare, callback) {
79
+ var initialRender = useRef(false);
80
+ var savedCallback = useRef(callback);
81
+ var _useState5 = useState(value),
82
+ _useState6 = _slicedToArray(_useState5, 2),
83
+ prevValue = _useState6[0],
84
+ setPrevValue = _useState6[1];
85
+ if (!compare(prevValue, value)) {
86
+ setPrevValue(value);
87
+ }
88
+ useEffect(function () {
89
+ savedCallback.current = callback;
90
+ });
91
+ useEffect(function () {
92
+ // We only want the callback triggered after the first render
93
+ if (initialRender.current) {
94
+ savedCallback.current(prevValue);
95
+ }
96
+ }, [prevValue]);
97
+ useEffect(function () {
98
+ initialRender.current = true;
99
+ }, []);
100
+ }
101
+
102
+ /**
103
+ * Access whether a given flag is enabled or disabled in a given
104
+ * FeatureFlagContext
105
+ *
106
+ * @returns {boolean}
107
+ */
108
+ function useFeatureFlag(flag) {
109
+ var scope = useContext(FeatureFlagContext);
110
+ // console.log(scope);
111
+ return scope.enabled(flag);
112
+ }
113
+
114
+ /**
115
+ * Access all feature flag information for the given FeatureFlagContext
116
+ *
117
+ * @returns {FeatureFlagScope}
118
+ */
119
+ function useFeatureFlags() {
120
+ return useContext(FeatureFlagContext);
121
+ }
122
+
123
+ /**
124
+ * Compare two objects and determine if they are equal. This is a shallow
125
+ * comparison since the objects we are comparing are objects with boolean flags
126
+ * from the flags prop in the `FeatureFlags` component
127
+ *
128
+ * @param {object} a
129
+ * @param {object} b
130
+ * @returns {boolean}
131
+ */
132
+ function isEqual(a, b) {
133
+ if (a === b) {
134
+ return true;
135
+ }
136
+ for (var _i = 0, _Object$keys = Object.keys(a); _i < _Object$keys.length; _i++) {
137
+ var key = _Object$keys[_i];
138
+ if (a[key] !== b[key]) {
139
+ return false;
140
+ }
141
+ }
142
+ for (var _i2 = 0, _Object$keys2 = Object.keys(b); _i2 < _Object$keys2.length; _i2++) {
143
+ var _key = _Object$keys2[_i2];
144
+ if (b[_key] !== a[_key]) {
145
+ return false;
146
+ }
147
+ }
148
+ return true;
149
+ }
150
+
151
+ export { FeatureFlagContext, FeatureFlags, useFeatureFlag, useFeatureFlags };