@carbon/ibm-products 2.41.1-canary.0 → 2.41.1-canary.13
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/Coachmark/Coachmark.js +2 -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/useFocusRowExpander.js +1 -1
- package/es/components/Datagrid/useInlineEdit.d.ts +1 -1
- package/es/components/Datagrid/useInlineEdit.js +9 -16
- package/es/components/EditUpdateCards/EditUpdateCards.d.ts +4 -3
- package/es/components/FeatureFlags/index.d.ts +37 -0
- package/es/components/FeatureFlags/index.js +151 -0
- package/es/components/Guidebanner/Guidebanner.js +7 -2
- package/es/components/ProductiveCard/ProductiveCard.d.ts +115 -2
- package/es/components/ProductiveCard/ProductiveCard.js +9 -9
- package/es/components/TagOverflow/TagOverflowModal.d.ts +34 -28
- package/es/components/TagOverflow/TagOverflowModal.js +4 -4
- 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/Coachmark/Coachmark.js +2 -1
- 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/useFocusRowExpander.js +1 -1
- package/lib/components/Datagrid/useInlineEdit.d.ts +1 -1
- package/lib/components/Datagrid/useInlineEdit.js +8 -15
- package/lib/components/EditUpdateCards/EditUpdateCards.d.ts +4 -3
- package/lib/components/FeatureFlags/index.d.ts +37 -0
- package/lib/components/FeatureFlags/index.js +162 -0
- package/lib/components/Guidebanner/Guidebanner.js +7 -2
- package/lib/components/ProductiveCard/ProductiveCard.d.ts +115 -2
- package/lib/components/ProductiveCard/ProductiveCard.js +9 -9
- package/lib/components/TagOverflow/TagOverflowModal.d.ts +34 -28
- package/lib/components/TagOverflow/TagOverflowModal.js +2 -2
- 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 +7 -3
- package/scss/components/Datagrid/styles/_useInlineEdit.scss +6 -0
@@ -6,9 +6,10 @@
|
|
6
6
|
*/
|
7
7
|
|
8
8
|
import { objectWithoutProperties as _objectWithoutProperties, extends as _extends } from '../../../../../_virtual/_rollupPluginBabelHelpers.js';
|
9
|
-
import
|
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
|
-
|
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,
|
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],
|
@@ -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
|
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
|
};
|
@@ -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?:
|
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?:
|
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?:
|
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 };
|
@@ -14,6 +14,7 @@ import { Idea, CaretLeft, CaretRight, Close } from '@carbon/react/icons';
|
|
14
14
|
import { Button, IconButton } from '@carbon/react';
|
15
15
|
import { getDevtoolsProps } from '../../global/js/utils/devtools.js';
|
16
16
|
import { pkg } from '../../settings.js';
|
17
|
+
import uuidv4 from '../../global/js/utils/uuidv4.js';
|
17
18
|
import { Carousel } from '../Carousel/Carousel.js';
|
18
19
|
|
19
20
|
var _CaretLeft, _CaretRight, _Close;
|
@@ -76,8 +77,9 @@ var Guidebanner = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
|
|
76
77
|
return !prevState;
|
77
78
|
});
|
78
79
|
};
|
80
|
+
var carouselContentId = "".concat(uuidv4(), "--carousel-content-id");
|
79
81
|
return /*#__PURE__*/React__default.createElement("div", _extends({}, rest, {
|
80
|
-
"aria-
|
82
|
+
"aria-owns": !isCollapsed ? carouselContentId : undefined,
|
81
83
|
className: cx(blockClass, className, collapsible && "".concat(blockClass, "__collapsible"), isCollapsed && "".concat(blockClass, "__collapsible-collapsed"), withLeftGutter && "".concat(blockClass, "__with-left-gutter")),
|
82
84
|
ref: ref
|
83
85
|
}, getDevtoolsProps(componentName)), /*#__PURE__*/React__default.createElement(Idea, {
|
@@ -86,6 +88,7 @@ var Guidebanner = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
|
|
86
88
|
}), /*#__PURE__*/React__default.createElement("div", {
|
87
89
|
className: "".concat(blockClass, "__title")
|
88
90
|
}, title), /*#__PURE__*/React__default.createElement(Carousel, {
|
91
|
+
id: carouselContentId,
|
89
92
|
className: "".concat(blockClass, "__carousel")
|
90
93
|
// These colors are to match the Carousel's faded edges
|
91
94
|
// against the Guidebanner's gradient background.
|
@@ -108,7 +111,9 @@ var Guidebanner = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
|
|
108
111
|
size: "md",
|
109
112
|
className: "".concat(blockClass, "__toggle-button"),
|
110
113
|
onClick: handleClickToggle,
|
111
|
-
ref: toggleRef
|
114
|
+
ref: toggleRef,
|
115
|
+
"aria-controls": !isCollapsed ? carouselContentId : undefined,
|
116
|
+
"aria-expanded": !isCollapsed
|
112
117
|
}, isCollapsed ? expandButtonLabel : collapseButtonLabel), showNavigation && /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("span", {
|
113
118
|
className: cx("".concat(blockClass, "__back-button"), [scrollPosition === 0 ? "".concat(blockClass, "__back-button--disabled") : null])
|
114
119
|
}, /*#__PURE__*/React__default.createElement(IconButton, {
|
@@ -1,2 +1,115 @@
|
|
1
|
-
|
2
|
-
import
|
1
|
+
import React, { PropsWithChildren, ReactNode } from 'react';
|
2
|
+
import { CarbonIconType } from '@carbon/icons-react/lib/CarbonIcon';
|
3
|
+
type ActionIcon = {
|
4
|
+
id?: string;
|
5
|
+
icon?: CarbonIconType;
|
6
|
+
onKeyDown?(): void;
|
7
|
+
onClick?(): void;
|
8
|
+
iconDescription?: string;
|
9
|
+
href?: string;
|
10
|
+
};
|
11
|
+
type overflowAction = {
|
12
|
+
id?: string;
|
13
|
+
itemText?: string;
|
14
|
+
onClick?: () => void;
|
15
|
+
onKeydown?: () => void;
|
16
|
+
};
|
17
|
+
type PlacementType = 'top' | 'bottom';
|
18
|
+
type ClickZoneType = 'one' | 'two' | 'three';
|
19
|
+
interface ProductiveCardProps extends PropsWithChildren {
|
20
|
+
/**
|
21
|
+
* Icons that are displayed on card. Refer to design documentation for implementation guidelines. Note- href will supersede onClick
|
22
|
+
*/
|
23
|
+
actionIcons?: ActionIcon[];
|
24
|
+
/**
|
25
|
+
* Determines if the action icons are on the top or bottom of the card
|
26
|
+
*/
|
27
|
+
actionsPlacement?: PlacementType;
|
28
|
+
/**
|
29
|
+
* Content that shows in the body of the card
|
30
|
+
*/
|
31
|
+
/**
|
32
|
+
* Optional user provided class
|
33
|
+
*/
|
34
|
+
className?: string;
|
35
|
+
children: ReactNode;
|
36
|
+
/**
|
37
|
+
* Designates which zones of the card are clickable. Refer to design documentation for implementation guidelines
|
38
|
+
*/
|
39
|
+
clickZone?: ClickZoneType;
|
40
|
+
/**
|
41
|
+
* Optional header description
|
42
|
+
*/
|
43
|
+
description?: string | object | ReactNode;
|
44
|
+
/**
|
45
|
+
* Optional label for the top of the card
|
46
|
+
*/
|
47
|
+
label?: string | object | ReactNode;
|
48
|
+
/**
|
49
|
+
* Provides the callback for a clickable card
|
50
|
+
*/
|
51
|
+
onClick?: () => void;
|
52
|
+
/**
|
53
|
+
* Function that's called from the primary button or action icon
|
54
|
+
*/
|
55
|
+
onPrimaryButtonClick?: () => void;
|
56
|
+
/**
|
57
|
+
* Function that's called from the secondary button
|
58
|
+
*/
|
59
|
+
onSecondaryButtonClick?: () => void;
|
60
|
+
/**
|
61
|
+
* Use an overflow menu instead of action icons. Refer to design documentation for implementation guidelines
|
62
|
+
*/
|
63
|
+
overflowActions?: overflowAction[];
|
64
|
+
/**
|
65
|
+
* Aria label prop required for OverflowMenu
|
66
|
+
*/
|
67
|
+
overflowAriaLabel?: string;
|
68
|
+
/**
|
69
|
+
* Optionally specify an href for your Button to become an <a> element
|
70
|
+
*/
|
71
|
+
primaryButtonHref?: string;
|
72
|
+
/**
|
73
|
+
* Optional prop to allow overriding the icon rendering. Can be a React component class
|
74
|
+
*/
|
75
|
+
primaryButtonIcon?: CarbonIconType;
|
76
|
+
/**
|
77
|
+
* Determines if the primary button is on the top or bottom of the card
|
78
|
+
*/
|
79
|
+
primaryButtonPlacement?: PlacementType;
|
80
|
+
/**
|
81
|
+
* The text that's displayed in the primary button
|
82
|
+
*/
|
83
|
+
primaryButtonText?: string;
|
84
|
+
/**
|
85
|
+
* Optionally specify an href for your Button to become an <a> element
|
86
|
+
*/
|
87
|
+
secondaryButtonHref?: string;
|
88
|
+
/**
|
89
|
+
* Optional prop to allow overriding the icon rendering. Can be a React component class
|
90
|
+
*/
|
91
|
+
secondaryButtonIcon?: CarbonIconType;
|
92
|
+
/**
|
93
|
+
* Determines if the secondary button is on the top or bottom of the card
|
94
|
+
*/
|
95
|
+
secondaryButtonPlacement?: PlacementType;
|
96
|
+
/**
|
97
|
+
* The text that's displayed in the secondary button
|
98
|
+
*/
|
99
|
+
secondaryButtonText?: string;
|
100
|
+
/**
|
101
|
+
* **Experimental:** For all cases a `Slug` component can be provided.
|
102
|
+
* Clickable tiles only accept a boolean value of true and display a hollow slug.
|
103
|
+
*/
|
104
|
+
slug?: ReactNode | boolean;
|
105
|
+
/**
|
106
|
+
* Title that's displayed at the top of the card
|
107
|
+
*/
|
108
|
+
title?: string | object | ReactNode;
|
109
|
+
/**
|
110
|
+
* Determines title size
|
111
|
+
*/
|
112
|
+
titleSize?: 'default' | 'large';
|
113
|
+
}
|
114
|
+
export declare let ProductiveCard: React.ForwardRefExoticComponent<ProductiveCardProps & React.RefAttributes<HTMLDivElement>>;
|
115
|
+
export {};
|