@carbon/ibm-products 2.41.1-canary.5 → 2.41.1-canary.8
Sign up to get free protection for your applications and to get access to all the features.
- package/css/index-full-carbon.css +6 -0
- package/css/index-full-carbon.css.map +1 -1
- package/css/index-full-carbon.min.css +1 -1
- package/css/index-full-carbon.min.css.map +1 -1
- package/css/index-without-carbon-released-only.css +6 -0
- package/css/index-without-carbon-released-only.css.map +1 -1
- package/css/index-without-carbon-released-only.min.css +1 -1
- package/css/index-without-carbon-released-only.min.css.map +1 -1
- package/css/index-without-carbon.css +6 -0
- package/css/index-without-carbon.css.map +1 -1
- package/css/index-without-carbon.min.css +1 -1
- package/css/index-without-carbon.min.css.map +1 -1
- package/css/index.css +6 -0
- package/css/index.css.map +1 -1
- package/css/index.min.css +1 -1
- package/css/index.min.css.map +1 -1
- package/es/components/Datagrid/Datagrid/DatagridContent.js +21 -1
- package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/TearsheetWrapper.js +12 -2
- package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditButton/InlineEditButton.d.ts +3 -3
- package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditButton/InlineEditButton.js +5 -5
- package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditCell/InlineEditCell.d.ts +3 -1
- package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditCell/InlineEditCell.js +12 -3
- package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/InlineEditContext.js +7 -0
- package/es/components/Datagrid/useCustomizeColumns.js +0 -4
- package/es/components/Datagrid/useEditableCell.js +1 -1
- package/es/components/Datagrid/useInlineEdit.d.ts +1 -1
- package/es/components/Datagrid/useInlineEdit.js +9 -16
- package/es/components/FeatureFlags/index.d.ts +37 -0
- package/es/components/FeatureFlags/index.js +151 -0
- package/es/components/index.d.ts +1 -0
- package/es/feature-flags.d.ts +1 -0
- package/es/global/js/hooks/usePortalTarget.js +4 -2
- package/es/index.js +1 -0
- package/lib/components/Datagrid/Datagrid/DatagridContent.js +49 -29
- package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/TearsheetWrapper.js +13 -19
- package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditButton/InlineEditButton.d.ts +3 -3
- package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditButton/InlineEditButton.js +5 -5
- package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditCell/InlineEditCell.d.ts +3 -1
- package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditCell/InlineEditCell.js +12 -3
- package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/InlineEditContext.js +7 -0
- package/lib/components/Datagrid/useCustomizeColumns.js +0 -4
- package/lib/components/Datagrid/useEditableCell.js +1 -1
- package/lib/components/Datagrid/useInlineEdit.d.ts +1 -1
- package/lib/components/Datagrid/useInlineEdit.js +8 -15
- package/lib/components/FeatureFlags/index.d.ts +37 -0
- package/lib/components/FeatureFlags/index.js +162 -0
- package/lib/components/index.d.ts +1 -0
- package/lib/feature-flags.d.ts +1 -0
- package/lib/global/js/hooks/usePortalTarget.js +4 -2
- package/lib/index.js +4 -0
- package/package.json +8 -4
- package/scss/components/Datagrid/styles/_useInlineEdit.scss +6 -0
package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditButton/InlineEditButton.d.ts
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
export function InlineEditButton({ label, renderIcon: Icon,
|
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
|
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>;
|
package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditButton/InlineEditButton.js
CHANGED
@@ -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"),
|
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":
|
29
|
-
"aria-disabled":
|
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
|
-
|
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]),
|
package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditCell/InlineEditCell.d.ts
CHANGED
@@ -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":
|
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,
|
package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/InlineEditContext.js
CHANGED
@@ -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],
|
@@ -1,2 +1,2 @@
|
|
1
1
|
export default useInlineEdit;
|
2
|
-
declare function useInlineEdit(hooks: any
|
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
|
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
|
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"),
|
39
|
+
className: cx("".concat(blockClass, "__cell"), "".concat(blockClass, "__cell-inline-edit")),
|
47
40
|
role: 'gridcell',
|
48
|
-
children:
|
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
|
-
|
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:
|
56
|
+
withInlineEdit: true
|
64
57
|
});
|
65
58
|
});
|
66
59
|
};
|
@@ -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 };
|
package/es/components/index.d.ts
CHANGED
@@ -69,3 +69,4 @@ export { Guidebanner, GuidebannerElement, GuidebannerElementButton, GuidebannerE
|
|
69
69
|
export { InlineTip, InlineTipButton, InlineTipLink } from "./InlineTip";
|
70
70
|
export { DescriptionList, DescriptionListBody, DescriptionListCell, DescriptionListRow } from "./DescriptionList";
|
71
71
|
export { FilterPanel, FilterPanelAccordion, FilterPanelAccordionItem, FilterPanelCheckbox, FilterPanelCheckboxWithOverflow, FilterPanelGroup, FilterPanelLabel, FilterPanelSearch } from "./FilterPanel";
|
72
|
+
export { FeatureFlags as unstable_FeatureFlags, useFeatureFlag as unstable_useFeatureFlag, useFeatureFlags as unstable_useFeatureFlags } from "./FeatureFlags";
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -9,8 +9,10 @@ import { slicedToArray as _slicedToArray } from '../../../_virtual/_rollupPlugin
|
|
9
9
|
import { useState, useEffect, useCallback } from 'react';
|
10
10
|
import { pkg } from '../../../settings.js';
|
11
11
|
import { createPortal } from 'react-dom';
|
12
|
+
import { useFeatureFlag } from '../../../components/FeatureFlags/index.js';
|
12
13
|
|
13
14
|
var usePortalTarget = function usePortalTarget(portalTargetIn) {
|
15
|
+
var enablePortalTarget = useFeatureFlag('default-portal-target-body');
|
14
16
|
var _useState = useState(null),
|
15
17
|
_useState2 = _slicedToArray(_useState, 2),
|
16
18
|
portalTarget = _useState2[0],
|
@@ -19,11 +21,11 @@ var usePortalTarget = function usePortalTarget(portalTargetIn) {
|
|
19
21
|
if (portalTargetIn) {
|
20
22
|
setPortalTarget(portalTargetIn);
|
21
23
|
} else {
|
22
|
-
if (pkg.isFeatureEnabled('default-portal-target-body')) {
|
24
|
+
if (pkg.isFeatureEnabled('default-portal-target-body') || enablePortalTarget) {
|
23
25
|
setPortalTarget(document.body);
|
24
26
|
}
|
25
27
|
}
|
26
|
-
}, [portalTargetIn]);
|
28
|
+
}, [portalTargetIn, enablePortalTarget]);
|
27
29
|
var renderPortalUse = useCallback(function (children) {
|
28
30
|
return portalTarget ? /*#__PURE__*/createPortal(children, portalTarget) : children;
|
29
31
|
}, [portalTarget]);
|
package/es/index.js
CHANGED
@@ -133,3 +133,4 @@ export { FilterPanelLabel } from './components/FilterPanel/FilterPanelLabel/Filt
|
|
133
133
|
export { FilterPanelSearch } from './components/FilterPanel/FilterPanelSearch/FilterPanelSearch.js';
|
134
134
|
export { ConditionBuilder } from './components/ConditionBuilder/ConditionBuilder.js';
|
135
135
|
export { GetStartedCard } from './components/GetStartedCard/GetStartedCard.js';
|
136
|
+
export { FeatureFlags as unstable_FeatureFlags, useFeatureFlag as unstable_useFeatureFlag, useFeatureFlags as unstable_useFeatureFlags } from './components/FeatureFlags/index.js';
|
@@ -17,12 +17,13 @@ var constants = require('./addons/Filtering/constants.js');
|
|
17
17
|
var DatagridBody = require('./DatagridBody.js');
|
18
18
|
var DatagridHead = require('./DatagridHead.js');
|
19
19
|
var DatagridToolbar = require('./DatagridToolbar.js');
|
20
|
-
var index = require('../../../node_modules/prop-types/index.js');
|
20
|
+
var index$1 = require('../../../node_modules/prop-types/index.js');
|
21
21
|
var cx = require('classnames');
|
22
22
|
var handleGridFocus = require('./addons/InlineEdit/handleGridFocus.js');
|
23
23
|
var handleGridKeyPress = require('./addons/InlineEdit/handleGridKeyPress.js');
|
24
24
|
var layout = require('@carbon/layout');
|
25
25
|
var FilterProvider = require('./addons/Filtering/FilterProvider.js');
|
26
|
+
var index = require('../../FeatureFlags/index.js');
|
26
27
|
var InlineEditContext = require('./addons/InlineEdit/InlineEditContext/InlineEditContext.js');
|
27
28
|
var useClickOutside = require('../../../global/js/hooks/useClickOutside.js');
|
28
29
|
var useMultipleKeyTracking = require('../../DataSpreadsheet/hooks/useMultipleKeyTracking.js');
|
@@ -50,7 +51,8 @@ var DatagridContent = function DatagridContent(_ref) {
|
|
50
51
|
panelOpen = _useContext2.panelOpen;
|
51
52
|
var activeCellId = inlineEditState.activeCellId,
|
52
53
|
gridActive = inlineEditState.gridActive,
|
53
|
-
editId = inlineEditState.editId
|
54
|
+
editId = inlineEditState.editId,
|
55
|
+
featureFlags = inlineEditState.featureFlags;
|
54
56
|
var getTableProps = datagridState.getTableProps,
|
55
57
|
getFilterFlyoutProps = datagridState.getFilterFlyoutProps,
|
56
58
|
withVirtualScroll = datagridState.withVirtualScroll,
|
@@ -78,6 +80,24 @@ var DatagridContent = function DatagridContent(_ref) {
|
|
78
80
|
var contentRows = DatagridPagination && page || rows;
|
79
81
|
var gridAreaRef = React.useRef();
|
80
82
|
var multiKeyTrackingRef = React.useRef();
|
83
|
+
var enableEditableCell = index.useFeatureFlag('enable-datagrid-useEditableCell');
|
84
|
+
var enableInlineEdit = index.useFeatureFlag('enable-datagrid-useInlineEdit');
|
85
|
+
var enableCustomizeCols = index.useFeatureFlag('enable-datagrid-useCustomizeColumns');
|
86
|
+
React.useEffect(function () {
|
87
|
+
dispatch({
|
88
|
+
type: 'SET_FEATURE_FLAGS',
|
89
|
+
payload: {
|
90
|
+
'enable-datagrid-useEditableCell': enableEditableCell,
|
91
|
+
'enable-datagrid-useInlineEdit': enableInlineEdit,
|
92
|
+
'enable-datagrid-useCustomizeColumns': enableCustomizeCols
|
93
|
+
}
|
94
|
+
});
|
95
|
+
}, [dispatch, enableEditableCell, enableCustomizeCols, enableInlineEdit]);
|
96
|
+
React.useEffect(function () {
|
97
|
+
if (featureFlags && (featureFlags !== null && featureFlags !== void 0 && featureFlags['enable-datagrid-useEditableCell'] || featureFlags !== null && featureFlags !== void 0 && featureFlags['enable-datagrid-useInlineEdit'])) {
|
98
|
+
console.error("Datagrid useEditableCell/useInlineEdit extension has not been enabled via feature flag.");
|
99
|
+
}
|
100
|
+
}, [featureFlags]);
|
81
101
|
useClickOutside.useClickOutside(gridAreaRef, function (target) {
|
82
102
|
if (!withInlineEdit) {
|
83
103
|
return;
|
@@ -184,34 +204,34 @@ var DatagridContent = function DatagridContent(_ref) {
|
|
184
204
|
}));
|
185
205
|
};
|
186
206
|
DatagridContent.propTypes = {
|
187
|
-
ariaToolbarLabel: index["default"].string,
|
188
|
-
datagridState: index["default"].shape({
|
189
|
-
getTableProps: index["default"].func,
|
190
|
-
getFilterFlyoutProps: index["default"].func,
|
191
|
-
withVirtualScroll: index["default"].bool,
|
192
|
-
DatagridActions: index["default"].oneOfType([index["default"].element, index["default"].func]),
|
193
|
-
DatagridPagination: index["default"].oneOfType([index["default"].element, index["default"].func]),
|
194
|
-
CustomizeColumnsTearsheet: index["default"].oneOfType([index["default"].element, index["default"].func]),
|
195
|
-
isFetching: index["default"].bool,
|
196
|
-
skeletonRowCount: index["default"].number,
|
197
|
-
fullHeightDatagrid: index["default"].bool,
|
198
|
-
filterProps: index["default"].object,
|
199
|
-
variableRowHeight: index["default"].bool,
|
200
|
-
useDenseHeader: index["default"].bool,
|
201
|
-
withInlineEdit: index["default"].bool,
|
202
|
-
verticalAlign: index["default"].string,
|
203
|
-
gridTitle: index["default"].node,
|
204
|
-
gridDescription: index["default"].node,
|
205
|
-
page: index["default"].arrayOf(index["default"].object),
|
206
|
-
rows: index["default"].arrayOf(index["default"].object),
|
207
|
-
tableId: index["default"].string,
|
208
|
-
totalColumnsWidth: index["default"].number,
|
209
|
-
gridRef: index["default"].object,
|
210
|
-
setAllFilters: index["default"].func,
|
211
|
-
getFilterProps: index["default"].func,
|
212
|
-
state: index["default"].object
|
207
|
+
ariaToolbarLabel: index$1["default"].string,
|
208
|
+
datagridState: index$1["default"].shape({
|
209
|
+
getTableProps: index$1["default"].func,
|
210
|
+
getFilterFlyoutProps: index$1["default"].func,
|
211
|
+
withVirtualScroll: index$1["default"].bool,
|
212
|
+
DatagridActions: index$1["default"].oneOfType([index$1["default"].element, index$1["default"].func]),
|
213
|
+
DatagridPagination: index$1["default"].oneOfType([index$1["default"].element, index$1["default"].func]),
|
214
|
+
CustomizeColumnsTearsheet: index$1["default"].oneOfType([index$1["default"].element, index$1["default"].func]),
|
215
|
+
isFetching: index$1["default"].bool,
|
216
|
+
skeletonRowCount: index$1["default"].number,
|
217
|
+
fullHeightDatagrid: index$1["default"].bool,
|
218
|
+
filterProps: index$1["default"].object,
|
219
|
+
variableRowHeight: index$1["default"].bool,
|
220
|
+
useDenseHeader: index$1["default"].bool,
|
221
|
+
withInlineEdit: index$1["default"].bool,
|
222
|
+
verticalAlign: index$1["default"].string,
|
223
|
+
gridTitle: index$1["default"].node,
|
224
|
+
gridDescription: index$1["default"].node,
|
225
|
+
page: index$1["default"].arrayOf(index$1["default"].object),
|
226
|
+
rows: index$1["default"].arrayOf(index$1["default"].object),
|
227
|
+
tableId: index$1["default"].string,
|
228
|
+
totalColumnsWidth: index$1["default"].number,
|
229
|
+
gridRef: index$1["default"].object,
|
230
|
+
setAllFilters: index$1["default"].func,
|
231
|
+
getFilterProps: index$1["default"].func,
|
232
|
+
state: index$1["default"].object
|
213
233
|
}),
|
214
|
-
title: index["default"].string
|
234
|
+
title: index$1["default"].string
|
215
235
|
};
|
216
236
|
|
217
237
|
exports.DatagridContent = DatagridContent;
|
@@ -13,26 +13,11 @@ var _rollupPluginBabelHelpers = require('../../../../../_virtual/_rollupPluginBa
|
|
13
13
|
var React = require('react');
|
14
14
|
var index = require('../../../../../node_modules/prop-types/index.js');
|
15
15
|
var CustomizeColumnsTearsheet = require('./CustomizeColumnsTearsheet.js');
|
16
|
+
var InlineEditContext = require('../InlineEdit/InlineEditContext/InlineEditContext.js');
|
16
17
|
|
17
|
-
function
|
18
|
-
if (e && e.__esModule) return e;
|
19
|
-
var n = Object.create(null);
|
20
|
-
if (e) {
|
21
|
-
Object.keys(e).forEach(function (k) {
|
22
|
-
if (k !== 'default') {
|
23
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
24
|
-
Object.defineProperty(n, k, d.get ? d : {
|
25
|
-
enumerable: true,
|
26
|
-
get: function () { return e[k]; }
|
27
|
-
});
|
28
|
-
}
|
29
|
-
});
|
30
|
-
}
|
31
|
-
n["default"] = e;
|
32
|
-
return Object.freeze(n);
|
33
|
-
}
|
18
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
34
19
|
|
35
|
-
var
|
20
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
36
21
|
|
37
22
|
var _excluded = ["onSaveColumnPrefs", "isTearsheetOpen", "setIsTearsheetOpen", "labels"];
|
38
23
|
var TearsheetWrapper = function TearsheetWrapper(_ref) {
|
@@ -43,7 +28,16 @@ var TearsheetWrapper = function TearsheetWrapper(_ref) {
|
|
43
28
|
setIsTearsheetOpen = _instance$customizeCo.setIsTearsheetOpen,
|
44
29
|
labels = _instance$customizeCo.labels,
|
45
30
|
rest = _rollupPluginBabelHelpers.objectWithoutProperties(_instance$customizeCo, _excluded);
|
46
|
-
|
31
|
+
var _useContext = React.useContext(InlineEditContext.InlineEditContext),
|
32
|
+
state = _useContext.state;
|
33
|
+
var _ref2 = state || {},
|
34
|
+
featureFlags = _ref2.featureFlags;
|
35
|
+
React.useEffect(function () {
|
36
|
+
if (featureFlags && !(featureFlags !== null && featureFlags !== void 0 && featureFlags['enable-datagrid-useCustomizeColumns'])) {
|
37
|
+
console.error("Datagrid useCustomizeColumns extension has not been enabled via feature flag.");
|
38
|
+
}
|
39
|
+
}, [featureFlags]);
|
40
|
+
return /*#__PURE__*/React__default["default"].createElement(CustomizeColumnsTearsheet["default"], _rollupPluginBabelHelpers["extends"]({}, rest, labels, {
|
47
41
|
isOpen: isTearsheetOpen,
|
48
42
|
setIsTearsheetOpen: setIsTearsheetOpen,
|
49
43
|
columnDefinitions: instance.allColumns,
|
package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditButton/InlineEditButton.d.ts
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
export function InlineEditButton({ label, renderIcon: Icon,
|
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
|
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>;
|