@carbon/ibm-products 1.51.0 → 1.52.0
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +10 -5
- package/css/index-full-carbon.css +89 -64
- 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.css +89 -64
- 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 +89 -64
- 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/AboutModal/AboutModal.js +3 -4
- package/es/components/ActionBar/ActionBar.js +9 -18
- package/es/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.js +8 -13
- package/es/components/ButtonSetWithOverflow/ButtonSetWithOverflow.js +7 -11
- package/es/components/Datagrid/Datagrid/DatagridToolbar.js +5 -5
- package/es/components/Datagrid/Datagrid/DatagridVirtualBody.js +3 -4
- package/es/components/Datagrid/index.js +1 -0
- package/es/components/Datagrid/useActionsColumn.js +10 -7
- package/es/components/Datagrid/useCustomizeColumns.js +5 -1
- package/es/components/Datagrid/useEditableCell.js +12 -0
- package/es/components/Datagrid/useExpandedRow.js +11 -7
- package/es/components/Datagrid/useFiltering.js +11 -8
- package/es/components/Datagrid/useInlineEdit.js +17 -8
- package/es/components/Datagrid/useNestedRows.js +10 -6
- package/es/components/ExampleComponent/ExampleComponent.js +32 -4
- package/es/components/ExampleComponent/useExample.js +49 -0
- package/es/components/InlineEditV1/InlineEditV1.js +3 -1
- package/es/components/NonLinearReading/NonLinearReading.js +7 -7
- package/es/components/PageHeader/PageHeader.js +28 -31
- package/es/components/SidePanel/SidePanel.js +25 -26
- package/es/components/TagSet/TagSet.js +5 -7
- package/es/components/Tearsheet/TearsheetShell.js +4 -6
- package/es/components/index.js +1 -1
- package/es/global/js/hooks/useResizeObserver.js +74 -0
- package/es/global/js/package-settings.js +34 -4
- package/es/global/js/utils/test-helper.js +34 -3
- package/es/settings.js +26 -30
- package/lib/components/AboutModal/AboutModal.js +3 -4
- package/lib/components/ActionBar/ActionBar.js +9 -18
- package/lib/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.js +8 -13
- package/lib/components/ButtonSetWithOverflow/ButtonSetWithOverflow.js +7 -11
- package/lib/components/Datagrid/Datagrid/DatagridToolbar.js +4 -4
- package/lib/components/Datagrid/Datagrid/DatagridVirtualBody.js +3 -4
- package/lib/components/Datagrid/index.js +7 -0
- package/lib/components/Datagrid/useActionsColumn.js +7 -1
- package/lib/components/Datagrid/useCustomizeColumns.js +4 -0
- package/lib/components/Datagrid/useEditableCell.js +20 -0
- package/lib/components/Datagrid/useExpandedRow.js +4 -0
- package/lib/components/Datagrid/useFiltering.js +4 -0
- package/lib/components/Datagrid/useInlineEdit.js +19 -8
- package/lib/components/Datagrid/useNestedRows.js +9 -6
- package/lib/components/ExampleComponent/ExampleComponent.js +35 -4
- package/lib/components/ExampleComponent/useExample.js +58 -0
- package/lib/components/InlineEditV1/InlineEditV1.js +3 -1
- package/lib/components/NonLinearReading/NonLinearReading.js +6 -6
- package/lib/components/PageHeader/PageHeader.js +28 -31
- package/lib/components/SidePanel/SidePanel.js +25 -26
- package/lib/components/TagSet/TagSet.js +5 -7
- package/lib/components/Tearsheet/TearsheetShell.js +4 -6
- package/lib/components/index.js +6 -0
- package/lib/global/js/hooks/useResizeObserver.js +83 -0
- package/lib/global/js/package-settings.js +33 -3
- package/lib/global/js/utils/test-helper.js +37 -5
- package/lib/settings.js +26 -30
- package/package.json +2 -3
- package/scss/components/NonLinearReading/_non-linear-reading.scss +76 -67
- package/scss/components/NonLinearReading/_storybook-styles.scss +16 -0
@@ -23,7 +23,7 @@ import PropTypes from 'prop-types';
|
|
23
23
|
import cx from 'classnames';
|
24
24
|
import { Link, TooltipIcon } from 'carbon-components-react';
|
25
25
|
import { pkg, carbon } from '../../settings';
|
26
|
-
import {
|
26
|
+
import { useResizeObserver } from '../../global/js/hooks/useResizeObserver';
|
27
27
|
import { ArrowLeft16 } from '@carbon/icons-react';
|
28
28
|
|
29
29
|
// Carbon and package components we use.
|
@@ -238,24 +238,19 @@ export var BreadcrumbWithOverflow = function BreadcrumbWithOverflow(_ref) {
|
|
238
238
|
/* istanbul ignore next */ // not sure how to test resize
|
239
239
|
checkFullyVisibleBreadcrumbItems();
|
240
240
|
};
|
241
|
-
|
242
|
-
/* istanbul ignore next */ // not sure how to test resize
|
243
|
-
var handleBreadcrumbItemsResize = function handleBreadcrumbItemsResize() {
|
244
|
-
/* istanbul ignore next */ // not sure how to test resize
|
245
|
-
checkFullyVisibleBreadcrumbItems();
|
246
|
-
};
|
247
241
|
var backItem = breadcrumbs[breadcrumbs.length - 1];
|
248
242
|
/* istanbul ignore if */ // not sure how to test media queries
|
249
243
|
if (backItem.isCurrentPage) {
|
250
244
|
backItem = breadcrumbs[breadcrumbs.length - 2];
|
251
245
|
}
|
252
|
-
|
253
|
-
|
254
|
-
|
246
|
+
|
247
|
+
// container resize
|
248
|
+
useResizeObserver(sizingContainerRef, {
|
249
|
+
callback: handleResize
|
255
250
|
});
|
256
|
-
|
257
|
-
|
258
|
-
|
251
|
+
// item resize
|
252
|
+
useResizeObserver(breadcrumbItemWithOverflow, {
|
253
|
+
callback: handleResize
|
259
254
|
});
|
260
255
|
return /*#__PURE__*/React.createElement("div", {
|
261
256
|
className: cx(blockClass, className, _defineProperty({}, "".concat(blockClass, "__with-items"), displayedBreadcrumbItems.length > 1)),
|
@@ -21,7 +21,7 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
|
|
21
21
|
import React, { useEffect, useState, useRef } from 'react';
|
22
22
|
import PropTypes from 'prop-types';
|
23
23
|
import cx from 'classnames';
|
24
|
-
import {
|
24
|
+
import { useResizeObserver } from '../../global/js/hooks/useResizeObserver';
|
25
25
|
import { ButtonSet, Button } from 'carbon-components-react';
|
26
26
|
import { ButtonMenu, ButtonMenuItem } from '../ButtonMenu';
|
27
27
|
import { pkg, carbon } from '../../settings';
|
@@ -135,18 +135,14 @@ export var ButtonSetWithOverflow = function ButtonSetWithOverflow(_ref) {
|
|
135
135
|
}, prepareProps(other, ['iconDescription', 'renderIcon'])));
|
136
136
|
}).reverse());
|
137
137
|
});
|
138
|
-
|
139
|
-
|
140
|
-
targetRef: sizingContainerRefSet
|
138
|
+
useResizeObserver(sizingContainerRefSet, {
|
139
|
+
callback: checkFullyVisibleItems
|
141
140
|
});
|
142
|
-
|
143
|
-
|
144
|
-
targetRef: sizingContainerRefCombo
|
141
|
+
useResizeObserver(sizingContainerRefCombo, {
|
142
|
+
callback: checkFullyVisibleItems
|
145
143
|
});
|
146
|
-
|
147
|
-
|
148
|
-
targetRef: spaceAvailableRef,
|
149
|
-
handleWidth: true
|
144
|
+
useResizeObserver(spaceAvailableRef, {
|
145
|
+
callback: checkFullyVisibleItems
|
150
146
|
});
|
151
147
|
return /*#__PURE__*/React.createElement("div", {
|
152
148
|
className: cx([blockClass, className, _defineProperty({}, "".concat(blockClass, "--right"), rightAlign)]),
|
@@ -7,10 +7,10 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
7
7
|
* LICENSE file in the root directory of this source tree.
|
8
8
|
*/
|
9
9
|
|
10
|
-
import React, { useEffect, useState } from 'react';
|
10
|
+
import React, { useEffect, useRef, useState } from 'react';
|
11
11
|
import { Add16, OverflowMenuVertical16 } from '@carbon/icons-react';
|
12
12
|
import { DataTable, TableBatchActions, TableBatchAction } from 'carbon-components-react';
|
13
|
-
import {
|
13
|
+
import { useResizeObserver } from '../../../global/js/hooks/useResizeObserver';
|
14
14
|
import { ButtonMenu, ButtonMenuItem } from '../../ButtonMenu';
|
15
15
|
import { pkg, carbon } from '../../../settings';
|
16
16
|
import cx from 'classnames';
|
@@ -124,9 +124,9 @@ var DatagridBatchActionsToolbar = function DatagridBatchActionsToolbar(datagridS
|
|
124
124
|
})), renderBatchActionOverflow());
|
125
125
|
};
|
126
126
|
var DatagridToolbar = function DatagridToolbar(datagridState) {
|
127
|
-
var
|
128
|
-
|
129
|
-
|
127
|
+
var ref = useRef(null);
|
128
|
+
var _useResizeObserver = useResizeObserver(ref),
|
129
|
+
width = _useResizeObserver.width;
|
130
130
|
var DatagridActions = datagridState.DatagridActions,
|
131
131
|
DatagridBatchActions = datagridState.DatagridBatchActions,
|
132
132
|
batchActions = datagridState.batchActions,
|
@@ -13,7 +13,7 @@ import React, { useEffect } from 'react';
|
|
13
13
|
import { VariableSizeList } from 'react-window';
|
14
14
|
import { DataTable } from 'carbon-components-react';
|
15
15
|
import { px } from '@carbon/layout';
|
16
|
-
import {
|
16
|
+
import { useResizeObserver } from '../../../global/js/hooks/useResizeObserver';
|
17
17
|
import { pkg } from '../../../settings';
|
18
18
|
import DatagridHead from './DatagridHead';
|
19
19
|
var blockClass = "".concat(pkg.prefix, "--datagrid");
|
@@ -51,9 +51,8 @@ var DatagridVirtualBody = function DatagridVirtualBody(datagridState) {
|
|
51
51
|
var gridRefElement = gridRef === null || gridRef === void 0 ? void 0 : gridRef.current;
|
52
52
|
gridRefElement.style.width = gridRefElement === null || gridRefElement === void 0 ? void 0 : gridRefElement.clientWidth;
|
53
53
|
};
|
54
|
-
|
55
|
-
|
56
|
-
targetRef: gridRef
|
54
|
+
useResizeObserver(gridRef, {
|
55
|
+
callback: handleVirtualGridResize
|
57
56
|
});
|
58
57
|
var syncScroll = function syncScroll(e) {
|
59
58
|
var virtualBody = e.target;
|
@@ -23,5 +23,6 @@ export { default as useSelectAllWithToggle } from './useSelectAllToggle';
|
|
23
23
|
export { default as useColumnCenterAlign } from './useColumnCenterAlign';
|
24
24
|
export { default as useColumnOrder } from './useColumnOrder';
|
25
25
|
export { default as useInlineEdit } from './useInlineEdit';
|
26
|
+
export { default as useEditableCell } from './useEditableCell';
|
26
27
|
export { default as useFiltering } from './useFiltering';
|
27
28
|
export { getAutoSizedColumnWidth } from './utils/getAutoSizedColumnWidth';
|
@@ -5,19 +5,22 @@ var _excluded = ["id", "itemText", "onClick", "icon"],
|
|
5
5
|
_excluded2 = ["id", "onClick", "shouldHideMenuItem", "shouldDisableMenuItem", "disabled"];
|
6
6
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
7
7
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
8
|
-
|
9
|
-
*
|
10
|
-
*
|
11
|
-
*
|
12
|
-
*
|
13
|
-
* restricted by GSA ADP Schedule Contract with IBM Corp.
|
8
|
+
/**
|
9
|
+
* Copyright IBM Corp. 2021, 2023
|
10
|
+
*
|
11
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
12
|
+
* LICENSE file in the root directory of this source tree.
|
14
13
|
*/
|
15
|
-
|
14
|
+
|
15
|
+
import React, { useEffect } from 'react';
|
16
16
|
import cx from 'classnames';
|
17
17
|
import { IconSkeleton, OverflowMenu, OverflowMenuItem } from 'carbon-components-react';
|
18
18
|
import { pkg } from '../../settings';
|
19
19
|
var blockClass = "".concat(pkg.prefix, "--datagrid");
|
20
20
|
var useActionsColumn = function useActionsColumn(hooks) {
|
21
|
+
useEffect(function () {
|
22
|
+
pkg.checkReportFeatureEnabled('Datagrid.useActionsColumn');
|
23
|
+
}, []);
|
21
24
|
var useAttachActionsOnInstance = function useAttachActionsOnInstance(instance) {
|
22
25
|
var rowActions = instance.rowActions,
|
23
26
|
isFetching = instance.isFetching,
|
@@ -4,15 +4,19 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
4
4
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
5
5
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
6
6
|
/**
|
7
|
-
* Copyright IBM Corp. 2022,
|
7
|
+
* Copyright IBM Corp. 2022, 2023
|
8
8
|
*
|
9
9
|
* This source code is licensed under the Apache-2.0 license found in the
|
10
10
|
* LICENSE file in the root directory of this source tree.
|
11
11
|
*/
|
12
12
|
|
13
13
|
import * as React from 'react';
|
14
|
+
import { pkg } from '../../settings';
|
14
15
|
import { CustomizeColumnsTearsheetWrapper, ToggleButtonWrapper } from './Datagrid/addons/CustomizeColumns';
|
15
16
|
var useCustomizeColumns = function useCustomizeColumns(hooks) {
|
17
|
+
React.useEffect(function () {
|
18
|
+
pkg.checkReportFeatureEnabled('Datagrid.useCustomizeColumns');
|
19
|
+
}, []);
|
16
20
|
var _React$useState = React.useState(false),
|
17
21
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
18
22
|
isTearsheetOpen = _React$useState2[0],
|
@@ -0,0 +1,12 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright IBM Corp. 2023, 2023
|
3
|
+
*
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
6
|
+
*/
|
7
|
+
|
8
|
+
import useInlineEdit from './useInlineEdit';
|
9
|
+
var useEditableCell = function useEditableCell(hooks) {
|
10
|
+
useInlineEdit(hooks, 'usingEditableCell');
|
11
|
+
};
|
12
|
+
export default useEditableCell;
|
@@ -2,17 +2,21 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
3
3
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
4
4
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
5
|
-
|
6
|
-
*
|
7
|
-
*
|
8
|
-
*
|
9
|
-
*
|
10
|
-
* restricted by GSA ADP Schedule Contract with IBM Corp.
|
5
|
+
/**
|
6
|
+
* Copyright IBM Corp. 2020, 2023
|
7
|
+
*
|
8
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
9
|
+
* LICENSE file in the root directory of this source tree.
|
11
10
|
*/
|
12
|
-
|
11
|
+
|
12
|
+
import { useEffect, useState } from 'react';
|
13
|
+
import { pkg } from '../../settings';
|
13
14
|
import DatagridExpandedRow from './Datagrid/DatagridExpandedRow';
|
14
15
|
import useRowExpander from './useRowExpander';
|
15
16
|
var useExpandedRow = function useExpandedRow(hooks) {
|
17
|
+
useEffect(function () {
|
18
|
+
pkg.checkReportFeatureEnabled('Datagrid.useExpandedRow');
|
19
|
+
}, []);
|
16
20
|
useRowExpander(hooks);
|
17
21
|
var useInstance = function useInstance(instance) {
|
18
22
|
var rows = instance.rows,
|
@@ -2,18 +2,21 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
3
3
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
4
4
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
5
|
-
|
6
|
-
|
7
|
-
*
|
8
|
-
*
|
9
|
-
*
|
10
|
-
* US Government Users Restricted Rights - Use, duplication or disclosure
|
11
|
-
* restricted by GSA ADP Schedule Contract with IBM Corp.
|
5
|
+
/**
|
6
|
+
* Copyright IBM Corp. 2022, 2023
|
7
|
+
*
|
8
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
9
|
+
* LICENSE file in the root directory of this source tree.
|
12
10
|
*/
|
13
|
-
|
11
|
+
|
12
|
+
import { useMemo, useEffect } from 'react';
|
13
|
+
import { pkg } from '../../settings';
|
14
14
|
import { FilterFlyout } from './Datagrid/addons/Filtering';
|
15
15
|
import { BATCH } from './Datagrid/addons/Filtering/constants';
|
16
16
|
var useFiltering = function useFiltering(hooks) {
|
17
|
+
useEffect(function () {
|
18
|
+
pkg.checkReportFeatureEnabled('Datagrid.useFiltering');
|
19
|
+
}, []);
|
17
20
|
var filterTypes = useMemo(function () {
|
18
21
|
return {
|
19
22
|
date: function date(rows, id, _ref) {
|
@@ -1,17 +1,26 @@
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
2
|
-
|
3
|
-
*
|
4
|
-
*
|
5
|
-
*
|
6
|
-
*
|
7
|
-
* restricted by GSA ADP Schedule Contract with IBM Corp.
|
2
|
+
/**
|
3
|
+
* Copyright IBM Corp. 2022, 2023
|
4
|
+
*
|
5
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
8
7
|
*/
|
9
|
-
|
8
|
+
|
9
|
+
import React, { useEffect } from 'react';
|
10
10
|
import { pkg } from '../../settings';
|
11
11
|
import cx from 'classnames';
|
12
12
|
import { InlineEditCell } from './Datagrid/addons/InlineEdit/InlineEditCell';
|
13
|
+
import { warn } from '../../global/js/utils/pconsole';
|
13
14
|
var blockClass = "".concat(pkg.prefix, "--datagrid");
|
14
|
-
var useInlineEdit = function useInlineEdit(hooks) {
|
15
|
+
var useInlineEdit = function useInlineEdit(hooks, usingEditableCell) {
|
16
|
+
useEffect(function () {
|
17
|
+
pkg.checkReportFeatureEnabled('Datagrid.useInlineEdit');
|
18
|
+
}, []);
|
19
|
+
useEffect(function () {
|
20
|
+
if (!usingEditableCell) {
|
21
|
+
warn("The 'useInlineEdit' hook is being renamed in Carbon for IBM Products v2 to 'useEditableCell'. You can use this newly renamed hook now or upgrade when moving to v2.");
|
22
|
+
}
|
23
|
+
}, [usingEditableCell]);
|
15
24
|
var addInlineEdit = function addInlineEdit(props, _ref) {
|
16
25
|
var _cell$column, _cell$column$inlineEd, _instance$columns$fil;
|
17
26
|
var cell = _ref.cell,
|
@@ -1,16 +1,20 @@
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
2
|
-
|
3
|
-
*
|
4
|
-
*
|
5
|
-
*
|
6
|
-
*
|
7
|
-
* restricted by GSA ADP Schedule Contract with IBM Corp.
|
2
|
+
/**
|
3
|
+
* Copyright IBM Corp. 2020, 2023
|
4
|
+
*
|
5
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
8
7
|
*/
|
8
|
+
|
9
|
+
import { useEffect } from 'react';
|
9
10
|
import { pkg } from '../../settings';
|
10
11
|
import cx from 'classnames';
|
11
12
|
import useNestedRowExpander from './useNestedRowExpander';
|
12
13
|
var blockClass = "".concat(pkg.prefix, "--datagrid");
|
13
14
|
var useNestedRows = function useNestedRows(hooks) {
|
15
|
+
useEffect(function () {
|
16
|
+
pkg.checkReportFeatureEnabled('Datagrid.useNestedRows');
|
17
|
+
}, []);
|
14
18
|
useNestedRowExpander(hooks);
|
15
19
|
var marginLeft = 24;
|
16
20
|
var getRowProps = function getRowProps(props, _ref) {
|
@@ -1,7 +1,8 @@
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
3
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
3
4
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
4
|
-
var _excluded = ["borderColor", "boxedBorder", "className", "disabled", "onPrimaryClick", "onSecondaryClick", "primaryButtonLabel", "primaryKind", "secondaryButtonLabel", "secondaryKind", "size", "style"];
|
5
|
+
var _excluded = ["borderColor", "boxedBorder", "className", "disabled", "usesExampleHook", "onPrimaryClick", "onSecondaryClick", "primaryButtonLabel", "primaryKind", "secondaryButtonLabel", "secondaryKind", "secondaryIcon", "size", "style"];
|
5
6
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
6
7
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
7
8
|
/**
|
@@ -12,12 +13,13 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
12
13
|
*/
|
13
14
|
|
14
15
|
// Import portions of React that are needed.
|
15
|
-
import React from 'react';
|
16
|
+
import React, { useRef, useEffect, useState } from 'react';
|
16
17
|
|
17
18
|
// Other standard imports.
|
18
19
|
import PropTypes from 'prop-types';
|
19
20
|
import cx from 'classnames';
|
20
21
|
import { pkg } from '../../settings';
|
22
|
+
import useExample from './useExample';
|
21
23
|
|
22
24
|
// Carbon and package components we use.
|
23
25
|
import { Button, ButtonSet } from 'carbon-components-react';
|
@@ -43,6 +45,7 @@ export var ExampleComponent = /*#__PURE__*/React.forwardRef(function (_ref, ref)
|
|
43
45
|
boxedBorder = _ref.boxedBorder,
|
44
46
|
className = _ref.className,
|
45
47
|
disabled = _ref.disabled,
|
48
|
+
usesExampleHook = _ref.usesExampleHook,
|
46
49
|
onPrimaryClick = _ref.onPrimaryClick,
|
47
50
|
onSecondaryClick = _ref.onSecondaryClick,
|
48
51
|
primaryButtonLabel = _ref.primaryButtonLabel,
|
@@ -51,10 +54,18 @@ export var ExampleComponent = /*#__PURE__*/React.forwardRef(function (_ref, ref)
|
|
51
54
|
secondaryButtonLabel = _ref.secondaryButtonLabel,
|
52
55
|
_ref$secondaryKind = _ref.secondaryKind,
|
53
56
|
secondaryKind = _ref$secondaryKind === void 0 ? defaults.secondaryKind : _ref$secondaryKind,
|
57
|
+
secondaryIcon = _ref.secondaryIcon,
|
54
58
|
_ref$size = _ref.size,
|
55
59
|
size = _ref$size === void 0 ? defaults.size : _ref$size,
|
56
60
|
style = _ref.style,
|
57
61
|
rest = _objectWithoutProperties(_ref, _excluded);
|
62
|
+
var _useState = useState(primaryButtonLabel),
|
63
|
+
_useState2 = _slicedToArray(_useState, 2),
|
64
|
+
thePrimaryButtonLabel = _useState2[0],
|
65
|
+
setThePrimaryButtonLabel = _useState2[1];
|
66
|
+
var _useExample = useExample(usesExampleHook),
|
67
|
+
_useExample2 = _slicedToArray(_useExample, 1),
|
68
|
+
exampleUse = _useExample2[0];
|
58
69
|
var modeClass = boxedBorder ? "".concat(blockClass, "--boxed-set") : "".concat(blockClass, "--shadow-set");
|
59
70
|
var handlePrimaryClick = function handlePrimaryClick(e) {
|
60
71
|
if (onPrimaryClick) {
|
@@ -66,6 +77,14 @@ export var ExampleComponent = /*#__PURE__*/React.forwardRef(function (_ref, ref)
|
|
66
77
|
onSecondaryClick(e);
|
67
78
|
}
|
68
79
|
};
|
80
|
+
var theSecondaryIcon = useRef(secondaryIcon && pkg.checkReportFeatureEnabled('ExampleComponent.secondaryIcon') ? secondaryIcon : null);
|
81
|
+
useEffect(function () {
|
82
|
+
if (usesExampleHook !== undefined && pkg.checkReportFeatureEnabled('ExampleComponent.useExample')) {
|
83
|
+
setThePrimaryButtonLabel("".concat(primaryButtonLabel, " ").concat(exampleUse.toFixed(1), "s"));
|
84
|
+
} else {
|
85
|
+
setThePrimaryButtonLabel(primaryButtonLabel);
|
86
|
+
}
|
87
|
+
}, [primaryButtonLabel, usesExampleHook, exampleUse]);
|
69
88
|
return /*#__PURE__*/React.createElement(ButtonSet, _extends({}, rest, {
|
70
89
|
className: cx(blockClass,
|
71
90
|
// Apply the block class to the main HTML element
|
@@ -78,6 +97,7 @@ export var ExampleComponent = /*#__PURE__*/React.forwardRef(function (_ref, ref)
|
|
78
97
|
className: "".concat(blockClass, "__secondary-button"),
|
79
98
|
kind: secondaryKind,
|
80
99
|
onClick: handleSecondaryClick,
|
100
|
+
renderIcon: theSecondaryIcon.current,
|
81
101
|
disabled: disabled,
|
82
102
|
size: size
|
83
103
|
}, secondaryButtonLabel), /*#__PURE__*/React.createElement(Button, {
|
@@ -86,7 +106,7 @@ export var ExampleComponent = /*#__PURE__*/React.forwardRef(function (_ref, ref)
|
|
86
106
|
onClick: handlePrimaryClick,
|
87
107
|
disabled: disabled,
|
88
108
|
size: size
|
89
|
-
},
|
109
|
+
}, thePrimaryButtonLabel));
|
90
110
|
});
|
91
111
|
|
92
112
|
// Return a placeholder if not released and not enabled by feature flag.
|
@@ -136,6 +156,10 @@ ExampleComponent.propTypes = {
|
|
136
156
|
* The secondary button label.
|
137
157
|
*/
|
138
158
|
secondaryButtonLabel: PropTypes.string.isRequired,
|
159
|
+
/**
|
160
|
+
* The icon to use for the secondary button.
|
161
|
+
*/
|
162
|
+
secondaryIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
139
163
|
/**
|
140
164
|
* The kind of button for the secondary button ('secondary' or 'tertiary').
|
141
165
|
*/
|
@@ -147,5 +171,9 @@ ExampleComponent.propTypes = {
|
|
147
171
|
/**
|
148
172
|
* Optional style settings for the containing node.
|
149
173
|
*/
|
150
|
-
style: PropTypes.object
|
174
|
+
style: PropTypes.object,
|
175
|
+
/**
|
176
|
+
* Hook example timeout (in seconds) or undefined
|
177
|
+
*/
|
178
|
+
usesExampleHook: PropTypes.number
|
151
179
|
};
|
@@ -0,0 +1,49 @@
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
2
|
+
/**
|
3
|
+
* Copyright IBM Corp. 2020, 2021
|
4
|
+
*
|
5
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
7
|
+
*/
|
8
|
+
import { useState, useEffect } from 'react';
|
9
|
+
import { pkg } from '../../settings';
|
10
|
+
var useExample = function useExample(initialTime) {
|
11
|
+
// NOTE: hooks cannot be called conditionally.
|
12
|
+
//
|
13
|
+
// ** If the hook uses other hooks then they must be called,
|
14
|
+
// ** this could lead to unexpected behavior.
|
15
|
+
// ** As some hooks may still be called even if the condition is false.
|
16
|
+
|
17
|
+
var _useState = useState(
|
18
|
+
// Disable hook in a safe way if possible, else use despite feature disabled.
|
19
|
+
// Either a console error or warning will be logged.
|
20
|
+
initialTime),
|
21
|
+
_useState2 = _slicedToArray(_useState, 2),
|
22
|
+
time = _useState2[0],
|
23
|
+
setTime = _useState2[1];
|
24
|
+
|
25
|
+
// Use of the feature flag to
|
26
|
+
var feature = 'ExampleComponent.useExample';
|
27
|
+
var tryFeature = initialTime !== undefined;
|
28
|
+
var featureEnabled = tryFeature && pkg.checkReportFeatureEnabled(feature);
|
29
|
+
if (tryFeature && !featureEnabled) {
|
30
|
+
// Output a useful message if the feature is disabled.
|
31
|
+
console.warn("Disabled feature \"".concat(feature, "\" does not change the initialTime."));
|
32
|
+
}
|
33
|
+
|
34
|
+
// Actual hook is code is below
|
35
|
+
useEffect(function () {
|
36
|
+
if (!featureEnabled) {
|
37
|
+
return;
|
38
|
+
}
|
39
|
+
|
40
|
+
// turn off all or part of the feature
|
41
|
+
if (time > 0) {
|
42
|
+
setTimeout(function () {
|
43
|
+
setTime(Math.max(0, time - 0.1));
|
44
|
+
}, 100);
|
45
|
+
}
|
46
|
+
}, [featureEnabled, time]);
|
47
|
+
return [time];
|
48
|
+
};
|
49
|
+
export default useExample;
|
@@ -306,7 +306,9 @@ InlineEditV1.deprecated = {
|
|
306
306
|
level: 'warn',
|
307
307
|
details: "The v1 version of this component is being deprecated. please switch to the v2 component as soon as possible."
|
308
308
|
};
|
309
|
-
|
309
|
+
|
310
|
+
// needed to show deprecation message but based on host component name
|
311
|
+
InlineEditV1 = pkg.checkComponentEnabled(InlineEditV1, 'InlineEdit');
|
310
312
|
|
311
313
|
// The types and DocGen commentary for the component props,
|
312
314
|
// in alphabetical order (for consistency).
|
@@ -12,7 +12,7 @@ var _excluded = ["children", "className", "definition", "theme"];
|
|
12
12
|
import React, { useState } from 'react';
|
13
13
|
import PropTypes from 'prop-types';
|
14
14
|
import cx from 'classnames';
|
15
|
-
import {
|
15
|
+
import { ChevronDown16 } from '@carbon/icons-react';
|
16
16
|
import { getDevtoolsProps } from '../../global/js/utils/devtools';
|
17
17
|
import { pkg } from '../../settings';
|
18
18
|
|
@@ -47,16 +47,16 @@ export var NonLinearReading = /*#__PURE__*/React.forwardRef(function (_ref, ref)
|
|
47
47
|
});
|
48
48
|
};
|
49
49
|
return /*#__PURE__*/React.createElement("span", _extends({}, rest, {
|
50
|
-
className: cx(blockClass, className),
|
50
|
+
className: cx(blockClass, "".concat(blockClass, "__").concat(theme), className),
|
51
51
|
ref: ref,
|
52
52
|
role: "main"
|
53
53
|
}, getDevtoolsProps(componentName)), ' ', /*#__PURE__*/React.createElement("button", {
|
54
54
|
type: "button",
|
55
55
|
"aria-expanded": isOpen,
|
56
|
-
className: cx("".concat(blockClass, "
|
56
|
+
className: cx("".concat(blockClass, "__keyword"), [isOpen ? ["".concat(blockClass, "__keyword-open")] : ["".concat(blockClass, "__keyword-closed")]]),
|
57
57
|
onClick: handleToggle
|
58
|
-
}, children,
|
59
|
-
className: "".concat(blockClass, "
|
58
|
+
}, children, /*#__PURE__*/React.createElement(ChevronDown16, null)), ' ', isOpen && /*#__PURE__*/React.createElement("span", {
|
59
|
+
className: "".concat(blockClass, "__body")
|
60
60
|
}, definition), ' ');
|
61
61
|
});
|
62
62
|
|
@@ -69,7 +69,7 @@ NonLinearReading.displayName = componentName;
|
|
69
69
|
// See https://www.npmjs.com/package/prop-types#usage.
|
70
70
|
NonLinearReading.propTypes = {
|
71
71
|
/**
|
72
|
-
* The
|
72
|
+
* The keyword of the component appears as a pill.
|
73
73
|
*/
|
74
74
|
children: PropTypes.node.isRequired,
|
75
75
|
/**
|
@@ -77,7 +77,7 @@ NonLinearReading.propTypes = {
|
|
77
77
|
*/
|
78
78
|
className: PropTypes.string,
|
79
79
|
/**
|
80
|
-
* The content that appears when the
|
80
|
+
* The content that appears when the keyword is toggled open.
|
81
81
|
*/
|
82
82
|
definition: PropTypes.node.isRequired,
|
83
83
|
/**
|