@carbon/ibm-products 2.0.0-rc.27 → 2.0.0-rc.28
Sign up to get free protection for your applications and to get access to all the features.
- package/css/index-full-carbon.css +71 -221
- package/css/index-full-carbon.css.map +1 -1
- package/css/index-full-carbon.min.css +3 -5
- package/css/index-full-carbon.min.css.map +1 -1
- package/css/index-without-carbon-released-only.css +142 -189
- package/css/index-without-carbon-released-only.css.map +1 -1
- package/css/index-without-carbon-released-only.min.css +1 -3
- package/css/index-without-carbon-released-only.min.css.map +1 -1
- package/css/index-without-carbon.css +71 -221
- package/css/index-without-carbon.css.map +1 -1
- package/css/index-without-carbon.min.css +3 -5
- package/css/index-without-carbon.min.css.map +1 -1
- package/css/index.css +71 -221
- package/css/index.css.map +1 -1
- package/css/index.min.css +3 -5
- package/css/index.min.css.map +1 -1
- package/es/components/AboutModal/AboutModal.js +3 -4
- package/es/components/ActionBar/ActionBar.js +13 -29
- package/es/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.js +15 -21
- package/es/components/ButtonSetWithOverflow/ButtonSetWithOverflow.js +7 -11
- package/es/components/Datagrid/Datagrid/DatagridSelectAllWithToggle.js +7 -8
- package/es/components/Datagrid/Datagrid/DatagridToolbar.js +6 -5
- package/es/components/Datagrid/Datagrid/DatagridVirtualBody.js +3 -4
- package/es/components/Datagrid/Datagrid/addons/Filtering/FilterFlyout.js +17 -3
- package/es/components/Datagrid/Datagrid/addons/Filtering/FilterPanel.js +19 -4
- package/es/components/Datagrid/Datagrid/addons/Filtering/hooks/useFilters.js +8 -5
- package/es/components/Datagrid/Datagrid/addons/Filtering/hooks/useInitialStateFromFilters.js +2 -1
- package/es/components/Datagrid/Datagrid/addons/Filtering/utils.js +19 -1
- package/es/components/Datagrid/useFiltering.js +4 -2
- package/es/components/Datagrid/useOnRowClick.js +11 -1
- package/es/components/Datagrid/useSelectRows.js +2 -0
- package/es/components/{InlineEditV2/InlineEditV2.js → EditInPlace/EditInPlace.js} +92 -30
- package/es/components/{InlineEdit → EditInPlace}/index.js +1 -1
- package/es/components/PageHeader/PageHeader.js +36 -35
- package/es/components/PageHeader/PageHeaderTitle.js +18 -18
- 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 +79 -0
- package/es/global/js/hooks/useWindowResize.js +6 -0
- package/es/global/js/hooks/useWindowScroll.js +7 -0
- package/es/global/js/package-settings.js +2 -4
- package/lib/components/AboutModal/AboutModal.js +3 -4
- package/lib/components/ActionBar/ActionBar.js +13 -29
- package/lib/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.js +13 -19
- package/lib/components/ButtonSetWithOverflow/ButtonSetWithOverflow.js +7 -11
- package/lib/components/Datagrid/Datagrid/DatagridSelectAllWithToggle.js +2 -1
- package/lib/components/Datagrid/Datagrid/DatagridToolbar.js +5 -4
- package/lib/components/Datagrid/Datagrid/DatagridVirtualBody.js +3 -4
- package/lib/components/Datagrid/Datagrid/addons/Filtering/FilterFlyout.js +17 -3
- package/lib/components/Datagrid/Datagrid/addons/Filtering/FilterPanel.js +19 -4
- package/lib/components/Datagrid/Datagrid/addons/Filtering/hooks/useFilters.js +8 -5
- package/lib/components/Datagrid/Datagrid/addons/Filtering/hooks/useInitialStateFromFilters.js +2 -1
- package/lib/components/Datagrid/Datagrid/addons/Filtering/utils.js +18 -1
- package/lib/components/Datagrid/useFiltering.js +4 -2
- package/lib/components/Datagrid/useOnRowClick.js +11 -1
- package/lib/components/Datagrid/useSelectRows.js +2 -0
- package/lib/components/{InlineEditV2/InlineEditV2.js → EditInPlace/EditInPlace.js} +100 -34
- package/lib/components/{InlineEdit → EditInPlace}/index.js +3 -3
- package/lib/components/PageHeader/PageHeader.js +36 -35
- package/lib/components/PageHeader/PageHeaderTitle.js +19 -19
- 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 +7 -7
- package/lib/global/js/hooks/useResizeObserver.js +91 -0
- package/lib/global/js/hooks/useWindowScroll.js +6 -0
- package/lib/global/js/package-settings.js +2 -4
- package/package.json +3 -4
- package/scss/components/BreadcrumbWithOverflow/_breadcrumb-with-overflow.scss +10 -1
- package/scss/components/Datagrid/styles/_useSelectAllToggle.scss +11 -7
- package/scss/components/{InlineEditV2/_inline-edit-v2.scss → EditInPlace/_edit-in-place.scss} +56 -14
- package/scss/components/{InlineEditV1 → EditInPlace}/_index-with-carbon.scss +1 -1
- package/scss/components/{InlineEditV2 → EditInPlace}/_index.scss +1 -1
- package/scss/components/{InlineEditV1 → EditInPlace}/_storybook-styles.scss +3 -15
- package/scss/components/PageHeader/_page-header.scss +1 -7
- package/scss/components/_index-released-only-with-carbon.scss +1 -1
- package/scss/components/_index-released-only.scss +1 -1
- package/scss/components/_index-with-carbon.scss +1 -2
- package/scss/components/_index.scss +1 -2
- package/es/components/InlineEdit/InlineEdit.js +0 -47
- package/es/components/InlineEditV1/InlineEditV1.js +0 -442
- package/es/components/InlineEditV1/index.js +0 -7
- package/es/components/InlineEditV2/index.js +0 -7
- package/lib/components/InlineEdit/InlineEdit.js +0 -63
- package/lib/components/InlineEditV1/InlineEditV1.js +0 -459
- package/lib/components/InlineEditV1/index.js +0 -13
- package/lib/components/InlineEditV2/index.js +0 -13
- package/scss/components/InlineEditV1/_carbon-imports.scss +0 -6
- package/scss/components/InlineEditV1/_index.scss +0 -8
- package/scss/components/InlineEditV1/_inline-edit-v1.scss +0 -269
- package/scss/components/InlineEditV2/_index-with-carbon.scss +0 -9
- package/scss/components/InlineEditV2/_storybook-styles.scss +0 -9
- /package/scss/components/{InlineEditV2 → EditInPlace}/_carbon-imports.scss +0 -0
@@ -4,14 +4,12 @@ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProper
|
|
4
4
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
5
5
|
var _excluded = ["onChange"];
|
6
6
|
|
7
|
-
|
8
|
-
*
|
9
|
-
*
|
10
|
-
*
|
11
|
-
*
|
12
|
-
* restricted by GSA ADP Schedule Contract with IBM Corp.
|
7
|
+
/**
|
8
|
+
* Copyright IBM Corp. 2020, 2023
|
9
|
+
*
|
10
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
11
|
+
* LICENSE file in the root directory of this source tree.
|
13
12
|
*/
|
14
|
-
// @flow
|
15
13
|
import React, { useEffect, useState, useLayoutEffect } from 'react';
|
16
14
|
import PropTypes from 'prop-types';
|
17
15
|
import cx from 'classnames';
|
@@ -103,7 +101,8 @@ var SelectAllWithToggle = function SelectAllWithToggle(_ref) {
|
|
103
101
|
}, props));
|
104
102
|
},
|
105
103
|
size: "sm",
|
106
|
-
ariaLabel: allRowsLabel
|
104
|
+
ariaLabel: allRowsLabel,
|
105
|
+
menuOptionsClass: "".concat(blockClass, "__select-all-toggle-overflow")
|
107
106
|
}, /*#__PURE__*/React.createElement(OverflowMenuItem, {
|
108
107
|
itemText: allPageRowsLabel,
|
109
108
|
requireTitle: true,
|
@@ -7,10 +7,10 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
7
7
|
* This source code is licensed under the Apache-2.0 license found in the
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
9
9
|
*/
|
10
|
-
import React, { useEffect, useState } from 'react';
|
10
|
+
import React, { useEffect, useRef, useState } from 'react';
|
11
11
|
import { Add, OverflowMenuVertical } from '@carbon/react/icons';
|
12
12
|
import { TableToolbar, TableBatchActions, TableBatchAction } from '@carbon/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';
|
@@ -134,9 +134,10 @@ var DatagridBatchActionsToolbar = function DatagridBatchActionsToolbar(datagridS
|
|
134
134
|
};
|
135
135
|
|
136
136
|
var DatagridToolbar = function DatagridToolbar(datagridState) {
|
137
|
-
var
|
138
|
-
|
139
|
-
|
137
|
+
var ref = useRef(null);
|
138
|
+
|
139
|
+
var _useResizeObserver = useResizeObserver(ref),
|
140
|
+
width = _useResizeObserver.width;
|
140
141
|
|
141
142
|
var DatagridActions = datagridState.DatagridActions,
|
142
143
|
DatagridBatchActions = datagridState.DatagridBatchActions,
|
@@ -18,7 +18,7 @@ import { TableBody } from '@carbon/react';
|
|
18
18
|
import { pkg } from '../../../settings';
|
19
19
|
import DatagridHead from './DatagridHead';
|
20
20
|
import { px } from '@carbon/layout';
|
21
|
-
import {
|
21
|
+
import { useResizeObserver } from '../../../global/js/hooks/useResizeObserver';
|
22
22
|
var blockClass = "".concat(pkg.prefix, "--datagrid");
|
23
23
|
var rowSizeMap = {
|
24
24
|
xs: 24,
|
@@ -57,9 +57,8 @@ var DatagridVirtualBody = function DatagridVirtualBody(datagridState) {
|
|
57
57
|
gridRefElement.style.width = gridRefElement === null || gridRefElement === void 0 ? void 0 : gridRefElement.clientWidth;
|
58
58
|
};
|
59
59
|
|
60
|
-
|
61
|
-
|
62
|
-
targetRef: gridRef
|
60
|
+
useResizeObserver(gridRef, {
|
61
|
+
callback: handleVirtualGridResize
|
63
62
|
});
|
64
63
|
|
65
64
|
var syncScroll = function syncScroll(e) {
|
@@ -46,9 +46,13 @@ var FilterFlyout = function FilterFlyout(_ref) {
|
|
46
46
|
secondaryActionLabel = _ref$secondaryActionL === void 0 ? 'Cancel' : _ref$secondaryActionL,
|
47
47
|
setAllFilters = _ref.setAllFilters,
|
48
48
|
_ref$data = _ref.data,
|
49
|
-
data = _ref$data === void 0 ? [] : _ref$data
|
50
|
-
|
49
|
+
data = _ref$data === void 0 ? [] : _ref$data,
|
50
|
+
_ref$initialFilters = _ref.initialFilters,
|
51
|
+
initialFilters = _ref$initialFilters === void 0 ? [] : _ref$initialFilters;
|
52
|
+
// Save the initial filters we only need the filters once when it loads
|
53
|
+
var initialFiltersRef = useRef(initialFilters);
|
51
54
|
/** State */
|
55
|
+
|
52
56
|
var _useState = useState(false),
|
53
57
|
_useState2 = _slicedToArray(_useState, 2),
|
54
58
|
open = _useState2[0],
|
@@ -58,7 +62,8 @@ var FilterFlyout = function FilterFlyout(_ref) {
|
|
58
62
|
updateMethod: updateMethod,
|
59
63
|
filters: filters,
|
60
64
|
setAllFilters: setAllFilters,
|
61
|
-
variation: FLYOUT
|
65
|
+
variation: FLYOUT,
|
66
|
+
initialFilters: initialFiltersRef.current
|
62
67
|
}),
|
63
68
|
filtersState = _useFilters.filtersState,
|
64
69
|
prevFiltersObjectArrayRef = _useFilters.prevFiltersObjectArrayRef,
|
@@ -208,6 +213,15 @@ FilterFlyout.propTypes = {
|
|
208
213
|
*/
|
209
214
|
flyoutIconDescription: PropTypes.string,
|
210
215
|
|
216
|
+
/**
|
217
|
+
* Filters that should be applied on load
|
218
|
+
*/
|
219
|
+
initialFilters: PropTypes.arrayOf(PropTypes.shape({
|
220
|
+
id: PropTypes.string.isRequired,
|
221
|
+
type: PropTypes.string.isRequired,
|
222
|
+
value: PropTypes.any.isRequired
|
223
|
+
})),
|
224
|
+
|
211
225
|
/**
|
212
226
|
* Callback when the apply button is clicked
|
213
227
|
*/
|
@@ -57,9 +57,13 @@ var FilterPanel = function FilterPanel(_ref) {
|
|
57
57
|
_ref$searchLabelText = _ref.searchLabelText,
|
58
58
|
searchLabelText = _ref$searchLabelText === void 0 ? 'Filter search' : _ref$searchLabelText,
|
59
59
|
_ref$searchPlaceholde = _ref.searchPlaceholder,
|
60
|
-
searchPlaceholder = _ref$searchPlaceholde === void 0 ? 'Find filters' : _ref$searchPlaceholde
|
61
|
-
|
60
|
+
searchPlaceholder = _ref$searchPlaceholde === void 0 ? 'Find filters' : _ref$searchPlaceholde,
|
61
|
+
_ref$initialFilters = _ref.initialFilters,
|
62
|
+
initialFilters = _ref$initialFilters === void 0 ? [] : _ref$initialFilters;
|
63
|
+
// Save the initial filters we only need the filters once
|
64
|
+
var initialFiltersRef = useRef(initialFilters);
|
62
65
|
/** State */
|
66
|
+
|
63
67
|
var _useState = useState(false),
|
64
68
|
_useState2 = _slicedToArray(_useState, 2),
|
65
69
|
showDividerLine = _useState2[0],
|
@@ -69,7 +73,8 @@ var FilterPanel = function FilterPanel(_ref) {
|
|
69
73
|
updateMethod: updateMethod,
|
70
74
|
filters: filterSections,
|
71
75
|
setAllFilters: setAllFilters,
|
72
|
-
variation: PANEL
|
76
|
+
variation: PANEL,
|
77
|
+
initialFilters: initialFiltersRef.current
|
73
78
|
}),
|
74
79
|
filtersState = _useFilters.filtersState,
|
75
80
|
prevFiltersObjectArrayRef = _useFilters.prevFiltersObjectArrayRef,
|
@@ -225,13 +230,14 @@ var FilterPanel = function FilterPanel(_ref) {
|
|
225
230
|
height: getScrollableContainerHeight()
|
226
231
|
},
|
227
232
|
onScroll: onInnerContainerScroll
|
228
|
-
}, filterSections.map(function (_ref2) {
|
233
|
+
}, filterSections.map(function (_ref2, index) {
|
229
234
|
var _ref2$categoryTitle = _ref2.categoryTitle,
|
230
235
|
categoryTitle = _ref2$categoryTitle === void 0 ? null : _ref2$categoryTitle,
|
231
236
|
_ref2$filters = _ref2.filters,
|
232
237
|
filters = _ref2$filters === void 0 ? [] : _ref2$filters,
|
233
238
|
hasAccordion = _ref2.hasAccordion;
|
234
239
|
return /*#__PURE__*/React.createElement("div", {
|
240
|
+
key: index,
|
235
241
|
className: "".concat(componentClass, "__category")
|
236
242
|
}, categoryTitle && /*#__PURE__*/React.createElement("div", {
|
237
243
|
className: "".concat(componentClass, "__category-title")
|
@@ -253,6 +259,15 @@ FilterPanel.propTypes = {
|
|
253
259
|
closeIconDescription: PropTypes.string,
|
254
260
|
filterPanelMinHeight: PropTypes.number,
|
255
261
|
filterSections: PropTypes.array,
|
262
|
+
|
263
|
+
/**
|
264
|
+
* Filters that should be applied on load
|
265
|
+
*/
|
266
|
+
initialFilters: PropTypes.arrayOf(PropTypes.shape({
|
267
|
+
id: PropTypes.string.isRequired,
|
268
|
+
type: PropTypes.string.isRequired,
|
269
|
+
value: PropTypes.any.isRequired
|
270
|
+
})),
|
256
271
|
onApply: PropTypes.func,
|
257
272
|
onCancel: PropTypes.func,
|
258
273
|
onPanelClose: PropTypes.func,
|
@@ -25,15 +25,16 @@ var useFilters = function useFilters(_ref) {
|
|
25
25
|
_ref$filters = _ref.filters,
|
26
26
|
filters = _ref$filters === void 0 ? [] : _ref$filters,
|
27
27
|
setAllFilters = _ref.setAllFilters,
|
28
|
-
variation = _ref.variation
|
28
|
+
variation = _ref.variation,
|
29
|
+
initialFilters = _ref.initialFilters;
|
29
30
|
|
30
31
|
/** State */
|
31
|
-
var _useInitialStateFromF = useInitialStateFromFilters(filters, variation),
|
32
|
+
var _useInitialStateFromF = useInitialStateFromFilters(filters, variation, initialFilters),
|
32
33
|
_useInitialStateFromF2 = _slicedToArray(_useInitialStateFromF, 2),
|
33
34
|
filtersState = _useInitialStateFromF2[0],
|
34
35
|
setFiltersState = _useInitialStateFromF2[1];
|
35
36
|
|
36
|
-
var _useState = useState(
|
37
|
+
var _useState = useState(initialFilters),
|
37
38
|
_useState2 = _slicedToArray(_useState, 2),
|
38
39
|
filtersObjectArray = _useState2[0],
|
39
40
|
setFiltersObjectArray = _useState2[1]; // When using batch actions we have to store the filters to then apply them later
|
@@ -51,8 +52,10 @@ var useFilters = function useFilters(_ref) {
|
|
51
52
|
};
|
52
53
|
|
53
54
|
var reset = function reset() {
|
54
|
-
//
|
55
|
-
var
|
55
|
+
// When we reset we want the "initialFilters" to be an empty array
|
56
|
+
var resetFiltersArray = []; // Get the initial values for the filters
|
57
|
+
|
58
|
+
var initialFiltersState = getInitialStateFromFilters(filters, variation, resetFiltersArray);
|
56
59
|
var initialFiltersObjectArray = []; // Set the state to the initial values
|
57
60
|
|
58
61
|
setFiltersState(initialFiltersState);
|
package/es/components/Datagrid/Datagrid/addons/Filtering/hooks/useInitialStateFromFilters.js
CHANGED
@@ -13,8 +13,9 @@ import { getInitialStateFromFilters } from '../utils';
|
|
13
13
|
|
14
14
|
var useInitialStateFromFilters = function useInitialStateFromFilters(filters) {
|
15
15
|
var variation = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : FLYOUT;
|
16
|
+
var initialFilters = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
16
17
|
|
17
|
-
var _useState = useState(getInitialStateFromFilters(filters, variation)),
|
18
|
+
var _useState = useState(getInitialStateFromFilters(filters, variation, initialFilters)),
|
18
19
|
_useState2 = _slicedToArray(_useState, 2),
|
19
20
|
state = _useState2[0],
|
20
21
|
setState = _useState2[1];
|
@@ -4,10 +4,24 @@
|
|
4
4
|
* This source code is licensed under the Apache-2.0 license found in the
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
6
6
|
*/
|
7
|
-
import { CHECKBOX, DATE, DROPDOWN, FLYOUT, NUMBER, PANEL, RADIO } from './constants';
|
7
|
+
import { CHECKBOX, DATE, DROPDOWN, FLYOUT, NUMBER, PANEL, RADIO } from './constants';
|
8
|
+
|
9
|
+
var applyInitialFilters = function applyInitialFilters(filterState, initialFilters) {
|
10
|
+
Object.keys(filterState).forEach(function (key) {
|
11
|
+
var hasInitialFilter = initialFilters.find(function (filter) {
|
12
|
+
return filter.id === key;
|
13
|
+
});
|
14
|
+
|
15
|
+
if (hasInitialFilter) {
|
16
|
+
filterState[key].value = hasInitialFilter.value;
|
17
|
+
}
|
18
|
+
});
|
19
|
+
}; // This functions takes the filters passed in and makes an object to track it's state
|
20
|
+
|
8
21
|
|
9
22
|
export var getInitialStateFromFilters = function getInitialStateFromFilters(filters) {
|
10
23
|
var variation = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : FLYOUT;
|
24
|
+
var initialFilters = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
11
25
|
var initialFilterState = {};
|
12
26
|
|
13
27
|
var setInitialState = function setInitialState(_ref) {
|
@@ -68,5 +82,9 @@ export var getInitialStateFromFilters = function getInitialStateFromFilters(filt
|
|
68
82
|
console.error('No variation passed into useInitialStateFromFilters');
|
69
83
|
}
|
70
84
|
|
85
|
+
if (initialFilters.length > 0) {
|
86
|
+
applyInitialFilters(initialFilterState, initialFilters);
|
87
|
+
}
|
88
|
+
|
71
89
|
return initialFilterState;
|
72
90
|
};
|
@@ -71,11 +71,13 @@ var useFiltering = function useFiltering(hooks) {
|
|
71
71
|
setAllFilters = instance.setAllFilters,
|
72
72
|
setFilter = instance.setFilter,
|
73
73
|
headers = instance.headers,
|
74
|
-
data = instance.data
|
74
|
+
data = instance.data,
|
75
|
+
state = instance.state;
|
75
76
|
var defaultProps = {
|
76
77
|
variation: 'flyout',
|
77
78
|
updateMethod: BATCH,
|
78
|
-
panelIconDescription: 'Open filter panel'
|
79
|
+
panelIconDescription: 'Open filter panel',
|
80
|
+
initialFilters: state.filters
|
79
81
|
};
|
80
82
|
|
81
83
|
var getFilterFlyoutProps = function getFilterFlyoutProps() {
|
@@ -26,9 +26,19 @@ var useOnRowClick = function useOnRowClick(hooks) {
|
|
26
26
|
}
|
27
27
|
};
|
28
28
|
|
29
|
+
var onKeyDown = function onKeyDown(event) {
|
30
|
+
var key = event.key;
|
31
|
+
|
32
|
+
if (key === 'Enter') {
|
33
|
+
onClick();
|
34
|
+
}
|
35
|
+
};
|
36
|
+
|
29
37
|
return [props, {
|
30
|
-
onClick: onClick
|
38
|
+
onClick: onClick,
|
39
|
+
onKeyDown: onKeyDown
|
31
40
|
}, {
|
41
|
+
tabIndex: 0,
|
32
42
|
style: {
|
33
43
|
cursor: 'pointer'
|
34
44
|
}
|
@@ -81,6 +81,7 @@ var SelectRow = function SelectRow(datagridState) {
|
|
81
81
|
radio = datagridState.radio,
|
82
82
|
toggleAllRowsSelected = datagridState.toggleAllRowsSelected,
|
83
83
|
onRadioSelect = datagridState.onRadioSelect,
|
84
|
+
onRowSelect = datagridState.onRowSelect,
|
84
85
|
columns = datagridState.columns,
|
85
86
|
withStickyColumn = datagridState.withStickyColumn;
|
86
87
|
|
@@ -121,6 +122,7 @@ var SelectRow = function SelectRow(datagridState) {
|
|
121
122
|
}
|
122
123
|
|
123
124
|
onChange(e);
|
125
|
+
onRowSelect === null || onRowSelect === void 0 ? void 0 : onRowSelect(row, e);
|
124
126
|
},
|
125
127
|
id: "".concat(tableId, "-").concat(row.index),
|
126
128
|
name: "".concat(tableId, "-").concat(row.index, "-name"),
|
@@ -1,8 +1,13 @@
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
3
|
+
import _typeof from "@babel/runtime/helpers/typeof";
|
3
4
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
4
5
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
5
|
-
var _excluded = ["cancelLabel", "editLabel", "id", "invalid", "invalidLabel", "labelText", "onCancel", "onChange", "onSave", "saveLabel", "value"];
|
6
|
+
var _excluded = ["cancelLabel", "editAlwaysVisible", "editLabel", "id", "inheritTypography", "invalid", "invalidLabel", "invalidText", "labelText", "onCancel", "onChange", "onSave", "saveLabel", "size", "tooltipAlignment", "value"];
|
7
|
+
|
8
|
+
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; }
|
9
|
+
|
10
|
+
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
11
|
|
7
12
|
/**
|
8
13
|
* Copyright IBM Corp. 2022, 2022
|
@@ -18,21 +23,31 @@ import { Edit, Checkmark, Close, // EditOff,
|
|
18
23
|
WarningFilled } from '@carbon/react/icons';
|
19
24
|
import { pkg, carbon } from '../../settings';
|
20
25
|
import { getDevtoolsProps } from '../../global/js/utils/devtools';
|
21
|
-
var componentName = '
|
22
|
-
var blockClass = "".concat(pkg.prefix, "--
|
23
|
-
|
26
|
+
var componentName = 'EditInPlace';
|
27
|
+
var blockClass = "".concat(pkg.prefix, "--edit-in-place");
|
28
|
+
var defaults = {
|
29
|
+
tooltipAlignment: 'top',
|
30
|
+
size: 'sm'
|
31
|
+
};
|
32
|
+
export var EditInPlace = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
24
33
|
var _cx;
|
25
34
|
|
26
35
|
var cancelLabel = _ref.cancelLabel,
|
36
|
+
editAlwaysVisible = _ref.editAlwaysVisible,
|
27
37
|
editLabel = _ref.editLabel,
|
28
38
|
id = _ref.id,
|
39
|
+
inheritTypography = _ref.inheritTypography,
|
29
40
|
invalid = _ref.invalid,
|
30
|
-
|
41
|
+
deprecated_invalidLabel = _ref.invalidLabel,
|
42
|
+
invalidText = _ref.invalidText,
|
31
43
|
labelText = _ref.labelText,
|
32
44
|
onCancel = _ref.onCancel,
|
33
45
|
onChange = _ref.onChange,
|
34
46
|
onSave = _ref.onSave,
|
35
47
|
saveLabel = _ref.saveLabel,
|
48
|
+
_ref$size = _ref.size,
|
49
|
+
size = _ref$size === void 0 ? defaults.size : _ref$size,
|
50
|
+
tooltipAlignment = _ref.tooltipAlignment,
|
36
51
|
value = _ref.value,
|
37
52
|
rest = _objectWithoutProperties(_ref, _excluded);
|
38
53
|
|
@@ -54,20 +69,27 @@ export var InlineEditV2 = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
54
69
|
var inputRef = useRef(null);
|
55
70
|
var canSave = value !== initialValue && !invalid;
|
56
71
|
var escaping = useRef(false);
|
72
|
+
var tipAlignIsObject = _typeof(tooltipAlignment) === 'object';
|
73
|
+
var tipAlignments = ['edit', 'save', 'cancel'].reduce(function (acc, tips) {
|
74
|
+
var _ref2;
|
75
|
+
|
76
|
+
acc[tips] = (_ref2 = tipAlignIsObject ? tooltipAlignment[tips] : tooltipAlignment) !== null && _ref2 !== void 0 ? _ref2 : defaults.tooltipAlignment;
|
77
|
+
return acc;
|
78
|
+
}, {});
|
57
79
|
useEffect(function () {
|
58
80
|
if (!initialValue && !dirtyInput) {
|
59
81
|
setInitialValue(value);
|
60
82
|
}
|
61
83
|
}, [initialValue, dirtyInput, value]);
|
62
84
|
|
63
|
-
var isTargetingChild = function isTargetingChild(
|
64
|
-
var currentTarget =
|
65
|
-
relatedTarget =
|
85
|
+
var isTargetingChild = function isTargetingChild(_ref3) {
|
86
|
+
var currentTarget = _ref3.currentTarget,
|
87
|
+
relatedTarget = _ref3.relatedTarget;
|
66
88
|
return currentTarget.contains(relatedTarget);
|
67
89
|
};
|
68
90
|
|
69
|
-
var onChangeHandler = function onChangeHandler(
|
70
|
-
var target =
|
91
|
+
var onChangeHandler = function onChangeHandler(_ref4) {
|
92
|
+
var target = _ref4.target;
|
71
93
|
|
72
94
|
if (!dirtyInput) {
|
73
95
|
setDirtyInput(true);
|
@@ -149,7 +171,7 @@ export var InlineEditV2 = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
149
171
|
return /*#__PURE__*/React.createElement("div", _extends({}, rest, {
|
150
172
|
ref: ref
|
151
173
|
}, getDevtoolsProps(componentName)), /*#__PURE__*/React.createElement("div", {
|
152
|
-
className: cx(blockClass, (_cx = {}, _defineProperty(_cx, "".concat(blockClass, "--focused"), focused), _defineProperty(_cx, "".concat(blockClass, "--invalid"), invalid), _cx)),
|
174
|
+
className: cx(blockClass, "".concat(blockClass, "--").concat(size), (_cx = {}, _defineProperty(_cx, "".concat(blockClass, "--focused"), focused), _defineProperty(_cx, "".concat(blockClass, "--invalid"), invalid), _defineProperty(_cx, "".concat(blockClass, "--inherit-type"), inheritTypography), _defineProperty(_cx, "".concat(blockClass, "--overflows"), inputRef.current && inputRef.current.scrollWidth > inputRef.current.offsetWidth), _cx)),
|
153
175
|
onFocus: onFocusHandler,
|
154
176
|
onBlur: onBlurHandler
|
155
177
|
}, /*#__PURE__*/React.createElement("label", {
|
@@ -157,7 +179,7 @@ export var InlineEditV2 = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
157
179
|
htmlFor: id
|
158
180
|
}, labelText), /*#__PURE__*/React.createElement("input", {
|
159
181
|
id: id,
|
160
|
-
className: cx("".concat(blockClass, "__text-input"), "".concat(carbon.prefix, "--text-input"), "".concat(carbon.prefix, "--text-input--
|
182
|
+
className: cx("".concat(blockClass, "__text-input"), "".concat(carbon.prefix, "--text-input"), "".concat(carbon.prefix, "--text-input--").concat(size)),
|
161
183
|
type: "text",
|
162
184
|
value: value,
|
163
185
|
onChange: onChangeHandler,
|
@@ -165,12 +187,16 @@ export var InlineEditV2 = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
165
187
|
,
|
166
188
|
onKeyDown: onKeyHandler
|
167
189
|
}), /*#__PURE__*/React.createElement("div", {
|
190
|
+
className: "".concat(blockClass, "__ellipsis"),
|
191
|
+
"aria-hidden": !focused
|
192
|
+
}, "\u2026"), /*#__PURE__*/React.createElement("div", {
|
168
193
|
className: "".concat(blockClass, "__toolbar")
|
169
|
-
},
|
194
|
+
}, invalid && /*#__PURE__*/React.createElement(WarningFilled, {
|
170
195
|
size: 16,
|
171
196
|
className: "".concat(blockClass, "__warning-icon")
|
172
|
-
}), /*#__PURE__*/React.createElement(IconButton, {
|
173
|
-
|
197
|
+
}), focused ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(IconButton, {
|
198
|
+
align: tipAlignments.cancel,
|
199
|
+
size: size,
|
174
200
|
label: cancelLabel,
|
175
201
|
onClick: onCancelHandler,
|
176
202
|
kind: "ghost",
|
@@ -180,7 +206,8 @@ export var InlineEditV2 = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
180
206
|
}, /*#__PURE__*/React.createElement(Close, {
|
181
207
|
size: 16
|
182
208
|
})), /*#__PURE__*/React.createElement(IconButton, {
|
183
|
-
|
209
|
+
align: tipAlignments.save,
|
210
|
+
size: size,
|
184
211
|
label: saveLabel,
|
185
212
|
onClick: onSaveHandler,
|
186
213
|
kind: "ghost",
|
@@ -191,8 +218,9 @@ export var InlineEditV2 = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
191
218
|
}, /*#__PURE__*/React.createElement(Checkmark, {
|
192
219
|
size: 16
|
193
220
|
}))) : /*#__PURE__*/React.createElement(IconButton, {
|
194
|
-
|
195
|
-
|
221
|
+
align: tipAlignments.edit,
|
222
|
+
className: cx("".concat(blockClass, "__btn"), "".concat(blockClass, "__btn-edit"), _defineProperty({}, "".concat(blockClass, "__btn-edit--always-visible"), editAlwaysVisible)),
|
223
|
+
size: size,
|
196
224
|
label: editLabel,
|
197
225
|
onClick: onFocusHandler,
|
198
226
|
kind: "ghost",
|
@@ -200,18 +228,32 @@ export var InlineEditV2 = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
200
228
|
key: "edit"
|
201
229
|
}, /*#__PURE__*/React.createElement(Edit, {
|
202
230
|
size: 16
|
203
|
-
})))),
|
231
|
+
})))), invalid && /*#__PURE__*/React.createElement("p", {
|
204
232
|
className: "".concat(blockClass, "__warning-text")
|
205
|
-
},
|
233
|
+
}, invalidText !== null && invalidText !== void 0 ? invalidText : deprecated_invalidLabel));
|
206
234
|
});
|
207
|
-
|
208
|
-
|
209
|
-
|
235
|
+
EditInPlace = pkg.checkComponentEnabled(EditInPlace, componentName);
|
236
|
+
EditInPlace.displayName = componentName;
|
237
|
+
export var deprecatedProps = {
|
238
|
+
/**
|
239
|
+
* **Deprecated**
|
240
|
+
* invalidLabel was misnamed, using invalidText to match Carbon
|
241
|
+
*/
|
242
|
+
invalidText: PropTypes.string
|
243
|
+
};
|
244
|
+
var alignPropType = PropTypes.oneOf(['top', 'top-left', 'top-right', 'bottom', 'bottom-left', 'bottom-right', 'left', 'right']);
|
245
|
+
EditInPlace.propTypes = _objectSpread({
|
210
246
|
/**
|
211
247
|
* label for cancel button
|
212
248
|
*/
|
213
249
|
cancelLabel: PropTypes.string.isRequired,
|
214
250
|
|
251
|
+
/**
|
252
|
+
* By default the edit icon is shown on hover only.
|
253
|
+
*/
|
254
|
+
editAlwaysVisible: PropTypes.bool,
|
255
|
+
|
256
|
+
/**
|
215
257
|
/**
|
216
258
|
* label for edit button
|
217
259
|
*/
|
@@ -222,6 +264,15 @@ InlineEditV2.propTypes = {
|
|
222
264
|
*/
|
223
265
|
id: PropTypes.string.isRequired,
|
224
266
|
|
267
|
+
/**
|
268
|
+
* inheritTypography - causes the text entry field to inherit typography settings
|
269
|
+
* assigned to the container. This is useful when editing titles for instance.
|
270
|
+
*
|
271
|
+
* NOTE: The size property limits the vertical size of the input element.
|
272
|
+
* Inherited font's should be selected to fit within the size selected.
|
273
|
+
*/
|
274
|
+
inheritTypography: PropTypes.bool,
|
275
|
+
|
225
276
|
/**
|
226
277
|
* determines if the input is invalid
|
227
278
|
*/
|
@@ -230,7 +281,7 @@ InlineEditV2.propTypes = {
|
|
230
281
|
/**
|
231
282
|
* text that is displayed if the input is invalid
|
232
283
|
*/
|
233
|
-
|
284
|
+
invalidText: PropTypes.string,
|
234
285
|
|
235
286
|
/**
|
236
287
|
* Provide the text that will be read by a screen reader when visiting this control
|
@@ -267,13 +318,24 @@ InlineEditV2.propTypes = {
|
|
267
318
|
*/
|
268
319
|
saveLabel: PropTypes.string.isRequired,
|
269
320
|
|
321
|
+
/**
|
322
|
+
* vertical size of control
|
323
|
+
*/
|
324
|
+
size: PropTypes.oneOf(['sm', 'md', 'lg']),
|
325
|
+
|
326
|
+
/**
|
327
|
+
* tooltipAlignment from the standard tooltip. Default center.
|
328
|
+
*
|
329
|
+
* Can be passed either as one of tooltip options or as an object specifying cancel, edit and save separately
|
330
|
+
*/
|
331
|
+
tooltipAlignment: PropTypes.oneOfType([alignPropType, PropTypes.shape({
|
332
|
+
cancel: alignPropType,
|
333
|
+
edit: alignPropType,
|
334
|
+
save: alignPropType
|
335
|
+
})]),
|
336
|
+
|
270
337
|
/**
|
271
338
|
* current value of the input
|
272
339
|
*/
|
273
340
|
value: PropTypes.string.isRequired
|
274
|
-
};
|
275
|
-
InlineEditV2.defaultProps = {
|
276
|
-
invalid: false,
|
277
|
-
invalidLabel: '' // readOnly: false,
|
278
|
-
|
279
|
-
};
|
341
|
+
}, deprecatedProps);
|