@carbon/ibm-products 2.0.0-rc.25 → 2.0.0-rc.27
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +10 -4
- package/css/index-full-carbon.css +129 -127
- package/css/index-full-carbon.css.map +1 -1
- package/css/index-full-carbon.min.css +3 -3
- package/css/index-full-carbon.min.css.map +1 -1
- package/css/index-without-carbon-released-only.css +69 -118
- package/css/index-without-carbon-released-only.css.map +1 -1
- package/css/index-without-carbon-released-only.min.css +2 -2
- package/css/index-without-carbon-released-only.min.css.map +1 -1
- package/css/index-without-carbon.css +129 -127
- package/css/index-without-carbon.css.map +1 -1
- package/css/index-without-carbon.min.css +3 -3
- package/css/index-without-carbon.min.css.map +1 -1
- package/css/index.css +129 -127
- package/css/index.css.map +1 -1
- package/css/index.min.css +3 -3
- package/css/index.min.css.map +1 -1
- package/es/components/AddSelect/AddSelectBody.js +1 -0
- package/es/components/AddSelect/AddSelectFormControl.js +92 -0
- package/es/components/AddSelect/AddSelectList.js +26 -195
- package/es/components/AddSelect/AddSelectRow.js +220 -0
- package/es/components/AddSelect/hooks/useFocus.js +35 -0
- package/es/components/Card/Card.js +8 -6
- package/es/components/Card/CardHeader.js +2 -2
- package/es/components/Datagrid/Datagrid/DatagridEmptyBody.js +15 -20
- package/es/components/Datagrid/Datagrid/DatagridHeaderRow.js +6 -2
- package/es/components/Datagrid/Datagrid/DatagridRefBody.js +3 -1
- package/es/components/Datagrid/Datagrid/DatagridRow.js +6 -2
- package/es/components/Datagrid/Datagrid/DatagridSimpleBody.js +3 -1
- package/es/components/Datagrid/Datagrid/DatagridToolbar.js +1 -1
- package/es/components/Datagrid/Datagrid/DatagridVirtualBody.js +3 -1
- package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/Columns.js +15 -65
- package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/CustomizeColumnsTearsheet.js +5 -2
- package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/DraggableItemsList.js +112 -0
- package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/TearsheetWrapper.js +1 -0
- package/es/components/Datagrid/Datagrid/addons/Filtering/hooks/useFilters.js +11 -0
- package/es/components/Datagrid/Datagrid/addons/RowSize/RowSizeDropdown.js +29 -23
- package/es/components/Datagrid/Datagrid/addons/RowSize/RowSizeRadioGroup.js +1 -0
- package/es/components/Datagrid/index.js +7 -7
- package/es/components/Datagrid/useInfiniteScroll.js +5 -1
- package/es/components/Datagrid/useOnRowClick.js +3 -3
- package/es/components/Datagrid/useSortableColumns.js +7 -5
- package/es/components/Datagrid/utils/getAutoSizedColumnWidth.js +29 -0
- package/es/components/ExampleComponent/ExampleComponent.js +39 -5
- package/es/components/ExampleComponent/useExample.js +51 -0
- package/es/components/ExpressiveCard/ExpressiveCard.js +3 -3
- package/es/components/InlineEditV1/InlineEditV1.js +15 -20
- package/es/components/InlineEditV2/InlineEditV2.js +21 -31
- package/es/components/PageHeader/PageHeader.js +4 -3
- package/es/components/ProductiveCard/ProductiveCard.js +3 -3
- package/es/components/index.js +1 -1
- package/es/global/js/package-settings.js +24 -3
- package/es/global/js/utils/story-helper.js +9 -0
- package/es/global/js/utils/test-helper.js +38 -6
- package/lib/components/AddSelect/AddSelectBody.js +1 -0
- package/lib/components/AddSelect/AddSelectFormControl.js +110 -0
- package/lib/components/AddSelect/AddSelectList.js +29 -203
- package/lib/components/AddSelect/AddSelectRow.js +247 -0
- package/lib/components/AddSelect/hooks/useFocus.js +46 -0
- package/lib/components/Card/Card.js +7 -5
- package/lib/components/Card/CardHeader.js +2 -2
- package/lib/components/Datagrid/Datagrid/DatagridEmptyBody.js +14 -19
- package/lib/components/Datagrid/Datagrid/DatagridHeaderRow.js +6 -2
- package/lib/components/Datagrid/Datagrid/DatagridRefBody.js +3 -1
- package/lib/components/Datagrid/Datagrid/DatagridRow.js +6 -2
- package/lib/components/Datagrid/Datagrid/DatagridSimpleBody.js +3 -1
- package/lib/components/Datagrid/Datagrid/DatagridToolbar.js +1 -1
- package/lib/components/Datagrid/Datagrid/DatagridVirtualBody.js +3 -1
- package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/Columns.js +16 -69
- package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/CustomizeColumnsTearsheet.js +5 -2
- package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/DraggableItemsList.js +132 -0
- package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/TearsheetWrapper.js +1 -0
- package/lib/components/Datagrid/Datagrid/addons/Filtering/hooks/useFilters.js +11 -0
- package/lib/components/Datagrid/Datagrid/addons/RowSize/RowSizeDropdown.js +23 -16
- package/lib/components/Datagrid/Datagrid/addons/RowSize/RowSizeRadioGroup.js +1 -0
- package/lib/components/Datagrid/index.js +9 -1
- package/lib/components/Datagrid/useInfiniteScroll.js +5 -0
- package/lib/components/Datagrid/useOnRowClick.js +3 -3
- package/lib/components/Datagrid/useSortableColumns.js +7 -5
- package/lib/components/Datagrid/utils/getAutoSizedColumnWidth.js +40 -0
- package/lib/components/ExampleComponent/ExampleComponent.js +47 -4
- package/lib/components/ExampleComponent/useExample.js +63 -0
- package/lib/components/ExpressiveCard/ExpressiveCard.js +3 -3
- package/lib/components/InlineEditV1/InlineEditV1.js +14 -19
- package/lib/components/InlineEditV2/InlineEditV2.js +20 -30
- package/lib/components/PageHeader/PageHeader.js +4 -3
- package/lib/components/ProductiveCard/ProductiveCard.js +3 -3
- package/lib/components/index.js +6 -0
- package/lib/global/js/package-settings.js +24 -3
- package/lib/global/js/utils/story-helper.js +13 -2
- package/lib/global/js/utils/test-helper.js +42 -8
- package/package.json +2 -2
- package/scss/components/ActionBar/_action-bar.scss +0 -4
- package/scss/components/AddSelect/_add-select.scss +4 -16
- package/scss/components/Card/_card.scss +13 -6
- package/scss/components/Datagrid/styles/addons/_CustomizeColumnsTearsheet.scss +15 -2
- package/scss/components/Datagrid/styles/addons/_RowSizeDropdown.scss +18 -6
- package/scss/components/ExportModal/_export-modal.scss +0 -4
- package/scss/components/ExpressiveCard/_expressive-card.scss +1 -1
- package/scss/components/InlineEditV1/_inline-edit-v1.scss +5 -89
- package/scss/components/InlineEditV2/_inline-edit-v2.scss +42 -3
- package/scss/components/PageHeader/_page-header.scss +2 -3
- package/scss/components/ProductiveCard/_productive-card.scss +31 -2
- package/scss/components/SidePanel/_side-panel.scss +2 -1
- package/scss/components/TagSet/_tag-set.scss +1 -0
- package/scss/components/UserProfileImage/_user-profile-image.scss +5 -0
@@ -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
|
|
6
7
|
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
8
|
|
@@ -14,13 +15,14 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
14
15
|
* LICENSE file in the root directory of this source tree.
|
15
16
|
*/
|
16
17
|
// Import portions of React that are needed.
|
17
|
-
import React from 'react'; // Other standard imports.
|
18
|
+
import React, { useRef, useEffect, useState } from 'react'; // Other standard imports.
|
18
19
|
|
19
20
|
import PropTypes from 'prop-types';
|
20
21
|
import cx from 'classnames';
|
21
22
|
import { pkg } from '../../settings'; // Carbon and package components we use.
|
22
23
|
|
23
|
-
import { Button, ButtonSet } from '@carbon/react';
|
24
|
+
import { Button, ButtonSet } from '@carbon/react';
|
25
|
+
import useExample from './useExample'; // The block part of our conventional BEM class names (blockClass__E--M).
|
24
26
|
|
25
27
|
var blockClass = "".concat(pkg.prefix, "--example-component");
|
26
28
|
var componentName = 'ExampleComponent'; // NOTE: the component SCSS is not imported here: it is rolled up separately.
|
@@ -29,6 +31,7 @@ var componentName = 'ExampleComponent'; // NOTE: the component SCSS is not impor
|
|
29
31
|
var defaults = {
|
30
32
|
primaryKind: 'primary',
|
31
33
|
secondaryKind: 'secondary',
|
34
|
+
secondaryIcon: null,
|
32
35
|
size: 'lg'
|
33
36
|
};
|
34
37
|
/**
|
@@ -40,6 +43,7 @@ export var ExampleComponent = /*#__PURE__*/React.forwardRef(function (_ref, ref)
|
|
40
43
|
boxedBorder = _ref.boxedBorder,
|
41
44
|
className = _ref.className,
|
42
45
|
disabled = _ref.disabled,
|
46
|
+
usesExampleHook = _ref.usesExampleHook,
|
43
47
|
onPrimaryClick = _ref.onPrimaryClick,
|
44
48
|
onSecondaryClick = _ref.onSecondaryClick,
|
45
49
|
primaryButtonLabel = _ref.primaryButtonLabel,
|
@@ -48,11 +52,22 @@ export var ExampleComponent = /*#__PURE__*/React.forwardRef(function (_ref, ref)
|
|
48
52
|
secondaryButtonLabel = _ref.secondaryButtonLabel,
|
49
53
|
_ref$secondaryKind = _ref.secondaryKind,
|
50
54
|
secondaryKind = _ref$secondaryKind === void 0 ? defaults.secondaryKind : _ref$secondaryKind,
|
55
|
+
_ref$secondaryIcon = _ref.secondaryIcon,
|
56
|
+
secondaryIcon = _ref$secondaryIcon === void 0 ? defaults.secondaryIcon : _ref$secondaryIcon,
|
51
57
|
_ref$size = _ref.size,
|
52
58
|
size = _ref$size === void 0 ? defaults.size : _ref$size,
|
53
59
|
style = _ref.style,
|
54
60
|
rest = _objectWithoutProperties(_ref, _excluded);
|
55
61
|
|
62
|
+
var _useState = useState(primaryButtonLabel),
|
63
|
+
_useState2 = _slicedToArray(_useState, 2),
|
64
|
+
thePrimaryButtonLabel = _useState2[0],
|
65
|
+
setThePrimaryButtonLabel = _useState2[1];
|
66
|
+
|
67
|
+
var _useExample = useExample(usesExampleHook),
|
68
|
+
_useExample2 = _slicedToArray(_useExample, 1),
|
69
|
+
exampleUse = _useExample2[0];
|
70
|
+
|
56
71
|
var modeClass = boxedBorder ? "".concat(blockClass, "--boxed-set") : "".concat(blockClass, "--shadow-set");
|
57
72
|
|
58
73
|
var handlePrimaryClick = function handlePrimaryClick(e) {
|
@@ -67,6 +82,14 @@ export var ExampleComponent = /*#__PURE__*/React.forwardRef(function (_ref, ref)
|
|
67
82
|
}
|
68
83
|
};
|
69
84
|
|
85
|
+
var theSecondaryIcon = useRef(secondaryIcon && pkg.checkReportFeatureEnabled('ExampleComponent.secondaryIcon') ? secondaryIcon : null);
|
86
|
+
useEffect(function () {
|
87
|
+
if (usesExampleHook !== undefined && pkg.checkReportFeatureEnabled('ExampleComponent.useExample')) {
|
88
|
+
setThePrimaryButtonLabel("".concat(primaryButtonLabel, " ").concat(exampleUse.toFixed(1), "s"));
|
89
|
+
} else {
|
90
|
+
setThePrimaryButtonLabel(primaryButtonLabel);
|
91
|
+
}
|
92
|
+
}, [primaryButtonLabel, usesExampleHook, exampleUse]);
|
70
93
|
return /*#__PURE__*/React.createElement(ButtonSet, _extends({}, rest, {
|
71
94
|
className: cx(blockClass, // Apply the block class to the main HTML element
|
72
95
|
className, // Apply any supplied class names to the main HTML element.
|
@@ -78,6 +101,7 @@ export var ExampleComponent = /*#__PURE__*/React.forwardRef(function (_ref, ref)
|
|
78
101
|
className: "".concat(blockClass, "__secondary-button"),
|
79
102
|
kind: secondaryKind,
|
80
103
|
onClick: handleSecondaryClick,
|
104
|
+
renderIcon: theSecondaryIcon.current,
|
81
105
|
disabled: disabled,
|
82
106
|
size: size
|
83
107
|
}, secondaryButtonLabel), /*#__PURE__*/React.createElement(Button, {
|
@@ -86,7 +110,7 @@ export var ExampleComponent = /*#__PURE__*/React.forwardRef(function (_ref, ref)
|
|
86
110
|
onClick: handlePrimaryClick,
|
87
111
|
disabled: disabled,
|
88
112
|
size: size
|
89
|
-
},
|
113
|
+
}, thePrimaryButtonLabel));
|
90
114
|
}); // Return a placeholder if not released and not enabled by feature flag.
|
91
115
|
|
92
116
|
ExampleComponent = pkg.checkComponentEnabled(ExampleComponent, componentName); // The display name of the component, used by React. Note that displayName
|
@@ -142,6 +166,11 @@ ExampleComponent.propTypes = {
|
|
142
166
|
*/
|
143
167
|
secondaryButtonLabel: PropTypes.string.isRequired,
|
144
168
|
|
169
|
+
/**
|
170
|
+
* The icon to use for the secondary button.
|
171
|
+
*/
|
172
|
+
secondaryIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
173
|
+
|
145
174
|
/**
|
146
175
|
* The kind of button for the secondary button ('secondary' or 'tertiary').
|
147
176
|
*/
|
@@ -155,5 +184,10 @@ ExampleComponent.propTypes = {
|
|
155
184
|
/**
|
156
185
|
* Optional style settings for the containing node.
|
157
186
|
*/
|
158
|
-
style: PropTypes.object
|
187
|
+
style: PropTypes.object,
|
188
|
+
|
189
|
+
/**
|
190
|
+
* Hook example timeout (in seconds) or undefined
|
191
|
+
*/
|
192
|
+
usesExampleHook: PropTypes.number
|
159
193
|
};
|
@@ -0,0 +1,51 @@
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
2
|
+
|
3
|
+
/**
|
4
|
+
* Copyright IBM Corp. 2020, 2021
|
5
|
+
*
|
6
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
8
|
+
*/
|
9
|
+
import { useState, useEffect } from 'react';
|
10
|
+
import { pkg } from '../../settings';
|
11
|
+
|
12
|
+
var useExample = function useExample(initialTime) {
|
13
|
+
// NOTE: hooks cannot be called conditionally.
|
14
|
+
//
|
15
|
+
// ** If the hook uses other hooks then they must be called,
|
16
|
+
// ** this could lead to unexpected behavior.
|
17
|
+
// ** As some hooks may still be called even if the condition is false.
|
18
|
+
var _useState = useState( // 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]; // Use of the feature flag to
|
24
|
+
|
25
|
+
|
26
|
+
var feature = 'ExampleComponent.useExample';
|
27
|
+
var tryFeature = initialTime !== undefined;
|
28
|
+
var featureEnabled = tryFeature && pkg.checkReportFeatureEnabled(feature);
|
29
|
+
|
30
|
+
if (tryFeature && !featureEnabled) {
|
31
|
+
// Output a useful message if the feature is disabled.
|
32
|
+
console.warn("Disabled feature \"".concat(feature, "\" does not change the initialTime."));
|
33
|
+
} // Actual hook is code is below
|
34
|
+
|
35
|
+
|
36
|
+
useEffect(function () {
|
37
|
+
if (!featureEnabled) {
|
38
|
+
return;
|
39
|
+
} // turn off all or part of the feature
|
40
|
+
|
41
|
+
|
42
|
+
if (time > 0) {
|
43
|
+
setTimeout(function () {
|
44
|
+
setTime(Math.max(0, time - 0.1));
|
45
|
+
}, 100);
|
46
|
+
}
|
47
|
+
}, [featureEnabled, time]);
|
48
|
+
return [time];
|
49
|
+
};
|
50
|
+
|
51
|
+
export default useExample;
|
@@ -46,12 +46,12 @@ ExpressiveCard.propTypes = {
|
|
46
46
|
/**
|
47
47
|
* Optional header description
|
48
48
|
*/
|
49
|
-
description: PropTypes.string,
|
49
|
+
description: PropTypes.oneOfType([PropTypes.string, PropTypes.object, PropTypes.node]),
|
50
50
|
|
51
51
|
/**
|
52
52
|
* Optional label for the top of the card
|
53
53
|
*/
|
54
|
-
label: PropTypes.string,
|
54
|
+
label: PropTypes.oneOfType([PropTypes.string, PropTypes.object, PropTypes.node]),
|
55
55
|
|
56
56
|
/**
|
57
57
|
* Optional media content like an image to be placed in the card
|
@@ -126,6 +126,6 @@ ExpressiveCard.propTypes = {
|
|
126
126
|
/**
|
127
127
|
* Title that's displayed at the top of the card
|
128
128
|
*/
|
129
|
-
title: PropTypes.string
|
129
|
+
title: PropTypes.oneOfType([PropTypes.string, PropTypes.object, PropTypes.node])
|
130
130
|
};
|
131
131
|
ExpressiveCard.displayName = componentName;
|
@@ -21,7 +21,7 @@ import { pkg } from '../../settings'; // Carbon and package components we use.
|
|
21
21
|
|
22
22
|
/* TODO: @use(s) of carbon components and other package components. */
|
23
23
|
|
24
|
-
import {
|
24
|
+
import { IconButton, usePrefix } from '@carbon/react';
|
25
25
|
import { Close, Edit, EditOff, Checkmark, WarningFilled } from '@carbon/react/icons'; // The block part of our conventional BEM class names (blockClass__E--M).
|
26
26
|
|
27
27
|
var blockClass = "".concat(pkg.prefix, "--inline-edit");
|
@@ -285,35 +285,30 @@ export var InlineEditV1 = /*#__PURE__*/React.forwardRef(function (_ref, refIn) {
|
|
285
285
|
className: cx("".concat(blockClass, "__toolbar"), (_cx3 = {}, _defineProperty(_cx3, "".concat(blockClass, "__toolbar--animation"), toolbarAnimation), _defineProperty(_cx3, "".concat(blockClass, "__toolbar--saveable"), refInput.current && value !== internalValue), _cx3))
|
286
286
|
}, showValidation && /*#__PURE__*/React.createElement("div", {
|
287
287
|
className: "".concat(blockClass, "__validation-icon")
|
288
|
-
}, validationIcon), editing ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(
|
288
|
+
}, validationIcon), editing ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(IconButton, _extends({
|
289
289
|
className: "".concat(blockClass, "__cancel"),
|
290
290
|
kind: "ghost",
|
291
|
-
|
292
|
-
iconDescription: cancelDescription,
|
291
|
+
label: cancelDescription,
|
293
292
|
onClick: handleCancel,
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
}
|
299
|
-
}, tipPositions.cancel)), /*#__PURE__*/React.createElement(Button, _extends({
|
293
|
+
size: size
|
294
|
+
}, tipPositions.cancel), /*#__PURE__*/React.createElement(Close, {
|
295
|
+
size: 16
|
296
|
+
})), /*#__PURE__*/React.createElement(IconButton, _extends({
|
300
297
|
className: "".concat(blockClass, "__save"),
|
301
298
|
kind: "ghost",
|
302
|
-
|
303
|
-
iconDescription: saveDescription,
|
299
|
+
label: saveDescription,
|
304
300
|
onClick: handleSave,
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
disabled: value === internalValue
|
311
|
-
}, tipPositions.save))) : /*#__PURE__*/React.createElement(IconButton, _extends({
|
301
|
+
disabled: value === internalValue,
|
302
|
+
size: size
|
303
|
+
}, tipPositions.save), /*#__PURE__*/React.createElement(Checkmark, {
|
304
|
+
size: 16
|
305
|
+
}))) : /*#__PURE__*/React.createElement(IconButton, _extends({
|
312
306
|
className: cx("".concat(blockClass, "__edit"), _defineProperty({}, "".concat(blockClass, "__edit--always-visible"), editAlwaysVisible)),
|
313
307
|
kind: "ghost",
|
314
308
|
label: editDescription,
|
315
309
|
onClick: handleEdit,
|
316
|
-
disabled: disabled
|
310
|
+
disabled: disabled,
|
311
|
+
size: size
|
317
312
|
}, tipPositions.edit), disabled ? /*#__PURE__*/React.createElement(EditOff, {
|
318
313
|
size: 16
|
319
314
|
}) : /*#__PURE__*/React.createElement(Edit, {
|
@@ -11,7 +11,7 @@ var _excluded = ["cancelLabel", "editLabel", "id", "invalid", "invalidLabel", "l
|
|
11
11
|
* LICENSE file in the root directory of this source tree.
|
12
12
|
*/
|
13
13
|
import React, { useState, useEffect, forwardRef, useRef } from 'react';
|
14
|
-
import {
|
14
|
+
import { IconButton } from '@carbon/react';
|
15
15
|
import cx from 'classnames';
|
16
16
|
import PropTypes from 'prop-types';
|
17
17
|
import { Edit, Checkmark, Close, // EditOff,
|
@@ -21,6 +21,8 @@ import { getDevtoolsProps } from '../../global/js/utils/devtools';
|
|
21
21
|
var componentName = 'InlineEditV2';
|
22
22
|
var blockClass = "".concat(pkg.prefix, "--inline-edit-v2");
|
23
23
|
export var InlineEditV2 = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
24
|
+
var _cx;
|
25
|
+
|
24
26
|
var cancelLabel = _ref.cancelLabel,
|
25
27
|
editLabel = _ref.editLabel,
|
26
28
|
id = _ref.id,
|
@@ -147,7 +149,7 @@ export var InlineEditV2 = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
147
149
|
return /*#__PURE__*/React.createElement("div", _extends({}, rest, {
|
148
150
|
ref: ref
|
149
151
|
}, getDevtoolsProps(componentName)), /*#__PURE__*/React.createElement("div", {
|
150
|
-
className: cx(blockClass,
|
152
|
+
className: cx(blockClass, (_cx = {}, _defineProperty(_cx, "".concat(blockClass, "--focused"), focused), _defineProperty(_cx, "".concat(blockClass, "--invalid"), invalid), _cx)),
|
151
153
|
onFocus: onFocusHandler,
|
152
154
|
onBlur: onBlurHandler
|
153
155
|
}, /*#__PURE__*/React.createElement("label", {
|
@@ -162,55 +164,43 @@ export var InlineEditV2 = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
162
164
|
ref: inputRef // readOnly={readOnly}
|
163
165
|
,
|
164
166
|
onKeyDown: onKeyHandler
|
165
|
-
}),
|
167
|
+
}), /*#__PURE__*/React.createElement("div", {
|
168
|
+
className: "".concat(blockClass, "__toolbar")
|
169
|
+
}, focused ? /*#__PURE__*/React.createElement(React.Fragment, null, invalid && /*#__PURE__*/React.createElement(WarningFilled, {
|
166
170
|
size: 16,
|
167
171
|
className: "".concat(blockClass, "__warning-icon")
|
168
|
-
}), /*#__PURE__*/React.createElement(
|
169
|
-
hasIconOnly: true,
|
170
|
-
renderIcon: function renderIcon() {
|
171
|
-
return /*#__PURE__*/React.createElement(Close, {
|
172
|
-
size: 24
|
173
|
-
});
|
174
|
-
},
|
172
|
+
}), /*#__PURE__*/React.createElement(IconButton, {
|
175
173
|
size: "sm",
|
176
|
-
|
174
|
+
label: cancelLabel,
|
177
175
|
onClick: onCancelHandler,
|
178
176
|
kind: "ghost",
|
179
177
|
tabIndex: 0,
|
180
178
|
key: "cancel",
|
181
179
|
className: "".concat(blockClass, "__btn ").concat(blockClass, "__btn-cancel")
|
182
|
-
}
|
183
|
-
|
184
|
-
|
185
|
-
return /*#__PURE__*/React.createElement(Checkmark, {
|
186
|
-
size: 24
|
187
|
-
});
|
188
|
-
},
|
180
|
+
}, /*#__PURE__*/React.createElement(Close, {
|
181
|
+
size: 16
|
182
|
+
})), /*#__PURE__*/React.createElement(IconButton, {
|
189
183
|
size: "sm",
|
190
|
-
|
184
|
+
label: saveLabel,
|
191
185
|
onClick: onSaveHandler,
|
192
186
|
kind: "ghost",
|
193
187
|
tabIndex: 0,
|
194
188
|
key: "save",
|
195
189
|
className: "".concat(blockClass, "__btn ").concat(blockClass, "__btn-save"),
|
196
190
|
disabled: !canSave
|
197
|
-
}
|
191
|
+
}, /*#__PURE__*/React.createElement(Checkmark, {
|
192
|
+
size: 16
|
193
|
+
}))) : /*#__PURE__*/React.createElement(IconButton, {
|
198
194
|
className: "".concat(blockClass, "__btn ").concat(blockClass, "__btn-edit"),
|
199
|
-
|
200
|
-
,
|
201
|
-
renderIcon: function renderIcon() {
|
202
|
-
return /*#__PURE__*/React.createElement(Edit, {
|
203
|
-
size: 24
|
204
|
-
});
|
205
|
-
},
|
206
|
-
size: "sm" // iconDescription={readOnly ? readOnlyLabel : editLabel}
|
207
|
-
,
|
208
|
-
iconDescription: editLabel,
|
195
|
+
size: "sm",
|
196
|
+
label: editLabel,
|
209
197
|
onClick: onFocusHandler,
|
210
198
|
kind: "ghost",
|
211
199
|
tabIndex: 0,
|
212
200
|
key: "edit"
|
213
|
-
}
|
201
|
+
}, /*#__PURE__*/React.createElement(Edit, {
|
202
|
+
size: 16
|
203
|
+
})))), focused && invalid && /*#__PURE__*/React.createElement("p", {
|
214
204
|
className: "".concat(blockClass, "__warning-text")
|
215
205
|
}, invalidLabel));
|
216
206
|
});
|
@@ -446,8 +446,9 @@ export var PageHeader = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
446
446
|
showAllTagsLabel: showAllTagsLabel,
|
447
447
|
tags: tags,
|
448
448
|
overflowClassName: "".concat(blockClass, "__navigation-tags-overflow")
|
449
|
-
})) : null) : null), hasCollapseButton ? /*#__PURE__*/React.createElement(
|
450
|
-
className: cx("".concat(blockClass, "__collapse-expand-toggle"), _defineProperty({}, "".concat(blockClass, "__collapse-expand-toggle--collapsed"), fullyCollapsed))
|
449
|
+
})) : null) : null), hasCollapseButton ? /*#__PURE__*/React.createElement("div", {
|
450
|
+
className: cx("".concat(blockClass, "__collapse-expand-toggle"), _defineProperty({}, "".concat(blockClass, "__collapse-expand-toggle--collapsed"), fullyCollapsed))
|
451
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
451
452
|
hasIconOnly: true,
|
452
453
|
iconDescription:
|
453
454
|
/* istanbul ignore next */
|
@@ -463,7 +464,7 @@ export var PageHeader = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
463
464
|
tooltipPosition: "bottom",
|
464
465
|
tooltipAlignment: "end",
|
465
466
|
type: "button"
|
466
|
-
}) : null));
|
467
|
+
})) : null));
|
467
468
|
|
468
469
|
function thePageActions(isBreadcrumbRow, inBreadcrumbRow) {
|
469
470
|
if (pageActions) {
|
@@ -75,12 +75,12 @@ ProductiveCard.propTypes = {
|
|
75
75
|
/**
|
76
76
|
* Optional header description
|
77
77
|
*/
|
78
|
-
description: PropTypes.string,
|
78
|
+
description: PropTypes.oneOfType([PropTypes.string, PropTypes.object, PropTypes.node]),
|
79
79
|
|
80
80
|
/**
|
81
81
|
* Optional label for the top of the card
|
82
82
|
*/
|
83
|
-
label: PropTypes.string,
|
83
|
+
label: PropTypes.oneOfType([PropTypes.string, PropTypes.object, PropTypes.node]),
|
84
84
|
|
85
85
|
/**
|
86
86
|
* Provides the callback for a clickable card
|
@@ -130,7 +130,7 @@ ProductiveCard.propTypes = {
|
|
130
130
|
/**
|
131
131
|
* Title that's displayed at the top of the card
|
132
132
|
*/
|
133
|
-
title: PropTypes.string,
|
133
|
+
title: PropTypes.oneOfType([PropTypes.string, PropTypes.object, PropTypes.node]),
|
134
134
|
|
135
135
|
/**
|
136
136
|
* Determines title size
|
package/es/components/index.js
CHANGED
@@ -37,7 +37,7 @@ export { EditSidePanel } from './EditSidePanel';
|
|
37
37
|
export { OptionsTile } from './OptionsTile';
|
38
38
|
export { InlineEdit } from './InlineEdit';
|
39
39
|
export { DataSpreadsheet } from './DataSpreadsheet';
|
40
|
-
export { Datagrid, useDatagrid, useInfiniteScroll, useNestedRows, useSelectRows, useExpandedRow, useOnRowClick, useSortableColumns, useRowIsMouseOver, useColumnCenterAlign, useColumnRightAlign, useDisableSelectRows, useStickyColumn, useActionsColumn, useCustomizeColumns, useSelectAllWithToggle, useColumnOrder, useInlineEdit, useFiltering } from './Datagrid';
|
40
|
+
export { Datagrid, useDatagrid, useInfiniteScroll, useNestedRows, useSelectRows, useExpandedRow, useOnRowClick, useSortableColumns, useRowIsMouseOver, useColumnCenterAlign, useColumnRightAlign, useDisableSelectRows, useStickyColumn, useActionsColumn, useCustomizeColumns, useSelectAllWithToggle, useColumnOrder, useInlineEdit, useFiltering, getAutoSizedColumnWidth } from './Datagrid';
|
41
41
|
export { EditTearsheet } from './EditTearsheet';
|
42
42
|
export { EditTearsheetNarrow } from './EditTearsheetNarrow';
|
43
43
|
export { EditFullPage } from './EditFullPage';
|
@@ -79,7 +79,8 @@ var defaults = {
|
|
79
79
|
// feature level flags
|
80
80
|
feature: {
|
81
81
|
'a-new-feature': false,
|
82
|
-
'default-portal-target-body': true
|
82
|
+
'default-portal-target-body': true,
|
83
|
+
'Datagrid.useInfiniteScroll': false
|
83
84
|
}
|
84
85
|
};
|
85
86
|
|
@@ -91,6 +92,10 @@ var warningMessageFeature = function warningMessageFeature(property) {
|
|
91
92
|
return "Carbon for IBM Products (WARNING): Feature \"".concat(property, "\" enabled via feature flags.");
|
92
93
|
};
|
93
94
|
|
95
|
+
var errorMessageFeature = function errorMessageFeature(property) {
|
96
|
+
return "Carbon for IBM Products (Error): Feature \"".concat(property, "\" not enabled. To enable see the notes on feature flags in the README.");
|
97
|
+
};
|
98
|
+
|
94
99
|
var warningMessageAllComponents = 'Carbon for IBM Products (WARNING): All components enabled through use of setAllComponents. This includes components that have not yet completed their review process.';
|
95
100
|
var warningMessageAllFeatures = 'Carbon for IBM Products (WARNING): All features enabled through use of setAllFeatures'; // Values to represent overrides for component or feature settings.
|
96
101
|
// Each value maps the initial value to the value that should be returned.
|
@@ -111,7 +116,11 @@ var allFeatures = all.INITIAL;
|
|
111
116
|
var silent = false;
|
112
117
|
var component = new Proxy(_objectSpread({}, defaults.component), {
|
113
118
|
set: function set(target, property, value) {
|
114
|
-
|
119
|
+
if (target[property] !== true && !silent && value) {
|
120
|
+
// not already true, not silent, and now true
|
121
|
+
console.warn(warningMessageComponent(property));
|
122
|
+
}
|
123
|
+
|
115
124
|
target[property] = value;
|
116
125
|
return true; // value set
|
117
126
|
},
|
@@ -123,7 +132,11 @@ var component = new Proxy(_objectSpread({}, defaults.component), {
|
|
123
132
|
});
|
124
133
|
var feature = new Proxy(_objectSpread({}, defaults.feature), {
|
125
134
|
set: function set(target, property, value) {
|
126
|
-
|
135
|
+
if (target[property] !== true && !silent && value) {
|
136
|
+
// not already true, not silent, and now true
|
137
|
+
console.warn(warningMessageFeature(property));
|
138
|
+
}
|
139
|
+
|
127
140
|
target[property] = value;
|
128
141
|
return true; // value set
|
129
142
|
},
|
@@ -153,6 +166,14 @@ export default {
|
|
153
166
|
var byDefault = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
154
167
|
return byDefault ? defaults.feature[featureName] : feature[featureName];
|
155
168
|
},
|
169
|
+
checkReportFeatureEnabled: function checkReportFeatureEnabled(featureName) {
|
170
|
+
if (feature[featureName]) {
|
171
|
+
// NOTE: Warning emitted if feature flag is enabled (see Proxy above)
|
172
|
+
return true;
|
173
|
+
} else {
|
174
|
+
console.error(errorMessageFeature(featureName));
|
175
|
+
}
|
176
|
+
},
|
156
177
|
isFeaturePublic: function isFeaturePublic(featureName) {
|
157
178
|
var byDefault = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
158
179
|
return Object.prototype.hasOwnProperty.call(byDefault ? defaults.feature : feature, featureName);
|
@@ -76,4 +76,13 @@ CodesandboxLink.propTypes = {
|
|
76
76
|
* directory withing examples codesandbox will be found
|
77
77
|
*/
|
78
78
|
exampleDirectory: PropTypes.string
|
79
|
+
};
|
80
|
+
/**
|
81
|
+
* A helper function that finds the designated theme on the Storybook canvas.
|
82
|
+
* @returns "dark" or "light"
|
83
|
+
*/
|
84
|
+
|
85
|
+
export var getSelectedCarbonTheme = function getSelectedCarbonTheme() {
|
86
|
+
var themeId = document.querySelector('html').getAttribute('storybook-carbon-theme');
|
87
|
+
return themeId === 'g90' || themeId === 'g100' ? 'dark' : 'light';
|
79
88
|
};
|
@@ -198,6 +198,43 @@ export var expectMultipleWarn = function expectMultipleWarn(messages, test) {
|
|
198
198
|
warn.mockRestore();
|
199
199
|
return result;
|
200
200
|
};
|
201
|
+
|
202
|
+
var checkLogging = function checkLogging(mock, message) {
|
203
|
+
if (message) {
|
204
|
+
var _expect4;
|
205
|
+
|
206
|
+
expect(mock).toBeCalled();
|
207
|
+
|
208
|
+
(_expect4 = expect(mock)).toHaveBeenCalledWith.apply(_expect4, _toConsumableArray(makeMatcherArray(message)));
|
209
|
+
}
|
210
|
+
};
|
211
|
+
/**
|
212
|
+
* A helper function to enable a test to expect a single call to
|
213
|
+
* console.error, for example when intentionally omitting a required prop
|
214
|
+
* or supplying an invalid prop type or value for the purposes of the test.
|
215
|
+
* @param {errors: {string|regex|function|[]}, warnings: {string|regex|function|[]}} messages the expected parameters for the call to
|
216
|
+
* console.error or console.warn, which must be called exactly once. A single string or regex or an
|
217
|
+
* expect matcher can be used to match a single-argument call to console.error (most common),
|
218
|
+
* while an array of strings and/or regex and/or expect matchers can be used to match a
|
219
|
+
* multiple-argument call. Strings can be full or substring matches to the corresponding
|
220
|
+
* argument.
|
221
|
+
* @param {Function} test the test function to call, during which the call to
|
222
|
+
* console.error will be expected.
|
223
|
+
*/
|
224
|
+
|
225
|
+
|
226
|
+
export var expectLogging = function expectLogging(_ref2, test) {
|
227
|
+
var errors = _ref2.errors,
|
228
|
+
warnings = _ref2.warnings;
|
229
|
+
var error = jest.spyOn(console, 'error').mockImplementation(jest.fn());
|
230
|
+
var warn = jest.spyOn(console, 'warn').mockImplementation(jest.fn());
|
231
|
+
var result = test();
|
232
|
+
checkLogging(error, errors);
|
233
|
+
checkLogging(warn, warnings);
|
234
|
+
error.mockRestore();
|
235
|
+
warn.mockRestore();
|
236
|
+
return result;
|
237
|
+
};
|
201
238
|
/**
|
202
239
|
* A helper function to enable a test to expect a single call to
|
203
240
|
* console.error, for example when intentionally omitting a required prop
|
@@ -213,14 +250,9 @@ export var expectMultipleWarn = function expectMultipleWarn(messages, test) {
|
|
213
250
|
*/
|
214
251
|
|
215
252
|
export var expectError = function expectError(message, test) {
|
216
|
-
var _expect4;
|
217
|
-
|
218
253
|
var error = jest.spyOn(console, 'error').mockImplementation(jest.fn());
|
219
254
|
var result = test();
|
220
|
-
|
221
|
-
|
222
|
-
(_expect4 = expect(error)).toHaveBeenCalledWith.apply(_expect4, _toConsumableArray(makeMatcherArray(message)));
|
223
|
-
|
255
|
+
checkLogging(error, message);
|
224
256
|
error.mockRestore();
|
225
257
|
return result;
|
226
258
|
};
|
@@ -282,6 +282,7 @@ var AddSelectBody = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
282
282
|
var displayColumnView = multi && useNormalizedItems && !searchTerm && !globalFiltersApplied; // main content
|
283
283
|
|
284
284
|
var body = /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
|
285
|
+
id: "add-select",
|
285
286
|
className: "".concat(blockClass, "__header")
|
286
287
|
}, /*#__PURE__*/_react.default.createElement(_AddSelectFilter.AddSelectFilter, {
|
287
288
|
inputLabel: globalSearchLabel,
|