@carbon/ibm-products 1.40.0 → 1.41.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/css/index-full-carbon.css +39 -65
- package/css/index-full-carbon.css.map +1 -1
- package/css/index-full-carbon.min.css +2 -2
- package/css/index-full-carbon.min.css.map +1 -1
- package/css/index-without-carbon-released-only.css +1 -0
- package/css/index-without-carbon-released-only.css.map +1 -1
- package/css/index-without-carbon-released-only.min.css +1 -1
- package/css/index-without-carbon-released-only.min.css.map +1 -1
- package/css/index-without-carbon.css +39 -65
- package/css/index-without-carbon.css.map +1 -1
- package/css/index-without-carbon.min.css +2 -2
- package/css/index-without-carbon.min.css.map +1 -1
- package/css/index.css +39 -65
- package/css/index.css.map +1 -1
- package/css/index.min.css +2 -2
- package/css/index.min.css.map +1 -1
- package/es/components/APIKeyModal/APIKeyDownloader.js +21 -23
- package/es/components/APIKeyModal/APIKeyModal.js +43 -45
- package/es/components/AddSelect/AddSelectBody.js +1 -1
- package/es/components/AddSelect/hooks/usePath.js +7 -1
- package/es/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.js +1 -1
- package/es/components/ButtonSetWithOverflow/ButtonSetWithOverflow.js +1 -1
- package/es/components/CreateFullPage/CreateFullPage.js +8 -2
- package/es/components/CreateTearsheet/CreateTearsheet.js +8 -2
- package/es/components/CreateTearsheet/preview-components/MultiStepTearsheet.js +4 -2
- package/es/components/DataSpreadsheet/DataSpreadsheet.js +1 -3
- package/es/components/DataSpreadsheet/utils/handleCellDeletion.js +5 -4
- package/es/components/Datagrid/Datagrid/DatagridContent.js +18 -6
- package/es/components/Datagrid/Datagrid/DatagridEmptyBody.js +9 -3
- package/es/components/Datagrid/Datagrid/DatagridRow.js +2 -8
- package/es/components/Datagrid/Datagrid/DatagridVirtualBody.js +27 -8
- package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/Actions.js +7 -9
- package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/ButtonWrapper.js +11 -13
- package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/Columns.js +26 -24
- package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/{CustomizeColumnsModal.js → CustomizeColumnsTearsheet.js} +32 -32
- package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/TearsheetWrapper.js +51 -0
- package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/index.js +6 -7
- package/es/components/Datagrid/Datagrid/addons/Filtering/FilterFlyout.js +26 -36
- package/es/components/Datagrid/Datagrid.stories/index.js +1 -1
- package/es/components/Datagrid/useCustomizeColumns.js +13 -15
- package/es/components/Datagrid/useFiltering.js +0 -2
- package/es/components/Datagrid/useParentDimensions.js +3 -1
- package/es/components/Datagrid/utils/getArgTypes.js +5 -0
- package/es/components/Datagrid/utils/getInlineEditColumns.js +6 -1
- package/es/components/ImportModal/ImportModal.js +42 -44
- package/es/components/index.js +1 -1
- package/es/global/js/hooks/useCreateComponentFocus.js +31 -10
- package/es/global/js/hooks/useCreateComponentStepChange.js +73 -79
- package/es/global/js/utils/test-helper.js +12 -14
- package/es/global/js/utils/unwrap-if-fragment.js +1 -1
- package/lib/components/APIKeyModal/APIKeyDownloader.js +21 -23
- package/lib/components/APIKeyModal/APIKeyModal.js +43 -45
- package/lib/components/AddSelect/AddSelectBody.js +1 -1
- package/lib/components/AddSelect/hooks/usePath.js +6 -0
- package/lib/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.js +1 -1
- package/lib/components/ButtonSetWithOverflow/ButtonSetWithOverflow.js +1 -1
- package/lib/components/CreateFullPage/CreateFullPage.js +8 -2
- package/lib/components/CreateTearsheet/CreateTearsheet.js +8 -2
- package/lib/components/CreateTearsheet/preview-components/MultiStepTearsheet.js +4 -2
- package/lib/components/DataSpreadsheet/DataSpreadsheet.js +1 -3
- package/lib/components/DataSpreadsheet/utils/handleCellDeletion.js +5 -4
- package/lib/components/Datagrid/Datagrid/DatagridContent.js +18 -6
- package/lib/components/Datagrid/Datagrid/DatagridEmptyBody.js +9 -3
- package/lib/components/Datagrid/Datagrid/DatagridRow.js +2 -11
- package/lib/components/Datagrid/Datagrid/DatagridVirtualBody.js +27 -8
- package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/Actions.js +7 -9
- package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/ButtonWrapper.js +6 -6
- package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/Columns.js +26 -24
- package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/{CustomizeColumnsModal.js → CustomizeColumnsTearsheet.js} +26 -25
- package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/{ModalWrapper.js → TearsheetWrapper.js} +30 -33
- package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/index.js +3 -3
- package/lib/components/Datagrid/Datagrid/addons/Filtering/FilterFlyout.js +26 -36
- package/lib/components/Datagrid/Datagrid.stories/index.js +1 -1
- package/lib/components/Datagrid/useCustomizeColumns.js +7 -7
- package/lib/components/Datagrid/useFiltering.js +0 -2
- package/lib/components/Datagrid/useParentDimensions.js +3 -1
- package/lib/components/Datagrid/utils/getArgTypes.js +5 -0
- package/lib/components/Datagrid/utils/getInlineEditColumns.js +6 -1
- package/lib/components/ImportModal/ImportModal.js +42 -44
- package/lib/components/index.js +6 -0
- package/lib/global/js/hooks/useCreateComponentFocus.js +32 -10
- package/lib/global/js/hooks/useCreateComponentStepChange.js +73 -79
- package/lib/global/js/utils/test-helper.js +12 -14
- package/lib/global/js/utils/unwrap-if-fragment.js +1 -1
- package/package.json +10 -10
- package/scss/components/Datagrid/_storybook-styles.scss +7 -0
- package/scss/components/Datagrid/styles/_datagrid.scss +22 -0
- package/scss/components/Datagrid/styles/_draggableElement.scss +9 -8
- package/scss/components/Datagrid/styles/_index.scss +8 -8
- package/scss/components/Datagrid/styles/addons/_CustomizeColumnsTearsheet.scss +60 -0
- package/scss/components/FilterSummary/_filter-summary.scss +1 -0
- package/scss/components/Tearsheet/_tearsheet.scss +2 -0
- package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/ModalWrapper.js +0 -56
- package/scss/components/Datagrid/styles/addons/_CustomizeColumnsModal.scss +0 -86
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* US Government Users Restricted Rights - Use, duplication or disclosure
|
|
9
|
-
* restricted by GSA ADP Schedule Contract with IBM Corp.
|
|
3
|
+
/**
|
|
4
|
+
* Copyright IBM Corp. 2022, 2022
|
|
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.
|
|
10
8
|
*/
|
|
11
9
|
|
|
12
10
|
import React from 'react';
|
|
@@ -31,7 +29,6 @@ var getNextIndex = function getNextIndex(array, currentIndex, key) {
|
|
|
31
29
|
return newIndex;
|
|
32
30
|
};
|
|
33
31
|
var Columns = function Columns(_ref) {
|
|
34
|
-
var _classNames;
|
|
35
32
|
var getVisibleColumnsCount = _ref.getVisibleColumnsCount,
|
|
36
33
|
filterString = _ref.filterString,
|
|
37
34
|
columns = _ref.columns,
|
|
@@ -70,12 +67,7 @@ var Columns = function Columns(_ref) {
|
|
|
70
67
|
e.stopPropagation();
|
|
71
68
|
}
|
|
72
69
|
},
|
|
73
|
-
tabIndex: 0
|
|
74
|
-
onFocus: function onFocus(e) {
|
|
75
|
-
if (e.target === e.currentTarget) {
|
|
76
|
-
setFocusIndex(0);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
70
|
+
tabIndex: 0
|
|
79
71
|
}, /*#__PURE__*/React.createElement("span", {
|
|
80
72
|
"aria-live": "assertive",
|
|
81
73
|
className: "".concat(blockClass, "__shared-ui--assistive-text")
|
|
@@ -84,7 +76,7 @@ var Columns = function Columns(_ref) {
|
|
|
84
76
|
className: "".concat(blockClass, "__shared-ui--assistive-text")
|
|
85
77
|
}, filterString.length === 0 ? assistiveTextInstructionsLabel : assistiveTextDisabledInstructionsLabel), /*#__PURE__*/React.createElement("div", {
|
|
86
78
|
id: "".concat(blockClass, "__customize-columns-select-all"),
|
|
87
|
-
className: classNames(
|
|
79
|
+
className: classNames("".concat(blockClass, "__customize-columns-select-all"), _defineProperty({}, "".concat(blockClass, "__customize-columns-select-all--selected"), getVisibleColumnsCount() > 0)),
|
|
88
80
|
selected: getVisibleColumnsCount() > 0
|
|
89
81
|
}, /*#__PURE__*/React.createElement(Checkbox, {
|
|
90
82
|
wrapperClassName: "".concat(blockClass, "__customize-columns-checkbox-wrapper"),
|
|
@@ -98,6 +90,24 @@ var Columns = function Columns(_ref) {
|
|
|
98
90
|
})), columns.filter(function (colDef) {
|
|
99
91
|
return filterString.length === 0 || colDef.Header.props.title.toLowerCase().includes(filterString);
|
|
100
92
|
}).map(function (colDef, i) {
|
|
93
|
+
var searchString = new RegExp('(' + filterString + ')');
|
|
94
|
+
var res = filterString.length ? colDef.Header.props.title.toLowerCase().split(searchString) : null;
|
|
95
|
+
var firstWord = res !== null ? res[0] === '' ? res[1].charAt(0).toUpperCase() + res[1].substring(1) : res[0].charAt(0).toUpperCase() + res[0].substring(1) : null;
|
|
96
|
+
var highlightedText = res !== null ? res[0] === '' ? "<strong>".concat(firstWord, "</strong>") + res[2] : firstWord + "<strong>".concat(res[1], "</strong>") + res[2] : colDef.Header.props.title;
|
|
97
|
+
var listContents = /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Checkbox, {
|
|
98
|
+
wrapperClassName: "".concat(blockClass, "__customize-columns-checkbox-wrapper"),
|
|
99
|
+
checked: isColumnVisible(colDef),
|
|
100
|
+
onChange: onSelectColumn.bind(null, colDef),
|
|
101
|
+
id: "".concat(blockClass, "__customization-column-").concat(colDef.id),
|
|
102
|
+
labelText: colDef.Header.props.title,
|
|
103
|
+
title: colDef.Header.props.title,
|
|
104
|
+
className: "".concat(blockClass, "__customize-columns-checkbox"),
|
|
105
|
+
hideLabel: true
|
|
106
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
107
|
+
dangerouslySetInnerHTML: {
|
|
108
|
+
__html: highlightedText
|
|
109
|
+
}
|
|
110
|
+
}));
|
|
101
111
|
return /*#__PURE__*/React.createElement(DraggableElement, {
|
|
102
112
|
key: colDef.id,
|
|
103
113
|
index: i,
|
|
@@ -125,15 +135,7 @@ var Columns = function Columns(_ref) {
|
|
|
125
135
|
}
|
|
126
136
|
},
|
|
127
137
|
selected: isColumnVisible(colDef)
|
|
128
|
-
},
|
|
129
|
-
wrapperClassName: "".concat(blockClass, "__customize-columns-checkbox-wrapper"),
|
|
130
|
-
checked: isColumnVisible(colDef),
|
|
131
|
-
onChange: onSelectColumn.bind(null, colDef),
|
|
132
|
-
id: "".concat(blockClass, "__customization-column-").concat(colDef.id),
|
|
133
|
-
labelText: colDef.Header.props.title,
|
|
134
|
-
title: colDef.Header.props.title,
|
|
135
|
-
className: "".concat(blockClass, "__customize-columns-checkbox")
|
|
136
|
-
}));
|
|
138
|
+
}, listContents);
|
|
137
139
|
}))));
|
|
138
140
|
};
|
|
139
141
|
Columns.propTypes = {
|
|
@@ -2,31 +2,30 @@ 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. 2022, 2022
|
|
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
|
+
|
|
13
12
|
import React, { useEffect, useState } from 'react';
|
|
14
13
|
import PropTypes from 'prop-types';
|
|
15
|
-
import { Modal } from 'carbon-components-react';
|
|
16
14
|
import { isColumnVisible } from './common';
|
|
17
15
|
import Columns from './Columns';
|
|
18
16
|
import Actions from './Actions';
|
|
19
17
|
import { pkg } from '../../../../../settings';
|
|
20
18
|
import { useCallback } from 'react';
|
|
19
|
+
import { TearsheetNarrow } from '../../../../Tearsheet';
|
|
21
20
|
var blockClass = "".concat(pkg.prefix, "--datagrid");
|
|
22
|
-
var
|
|
21
|
+
var CustomizeColumnsTearsheet = function CustomizeColumnsTearsheet(_ref) {
|
|
23
22
|
var isOpen = _ref.isOpen,
|
|
24
|
-
|
|
23
|
+
setIsTearsheetOpen = _ref.setIsTearsheetOpen,
|
|
25
24
|
onSaveColumnPrefs = _ref.onSaveColumnPrefs,
|
|
26
25
|
columnDefinitions = _ref.columnDefinitions,
|
|
27
26
|
originalColumnDefinitions = _ref.originalColumnDefinitions,
|
|
28
|
-
_ref$
|
|
29
|
-
|
|
27
|
+
_ref$customizeTearshe = _ref.customizeTearsheetHeadingLabel,
|
|
28
|
+
customizeTearsheetHeadingLabel = _ref$customizeTearshe === void 0 ? 'Customize columns' : _ref$customizeTearshe,
|
|
30
29
|
_ref$primaryButtonTex = _ref.primaryButtonTextLabel,
|
|
31
30
|
primaryButtonTextLabel = _ref$primaryButtonTex === void 0 ? 'Save' : _ref$primaryButtonTex,
|
|
32
31
|
_ref$secondaryButtonT = _ref.secondaryButtonTextLabel,
|
|
@@ -80,10 +79,10 @@ var CustomizeColumnsModal = function CustomizeColumnsModal(_ref) {
|
|
|
80
79
|
isDirty = _useState10[0],
|
|
81
80
|
setIsDirty = _useState10[1];
|
|
82
81
|
var onRequestClose = function onRequestClose() {
|
|
83
|
-
|
|
82
|
+
setIsTearsheetOpen(false);
|
|
84
83
|
};
|
|
85
84
|
var onRequestSubmit = function onRequestSubmit() {
|
|
86
|
-
|
|
85
|
+
setIsTearsheetOpen(false);
|
|
87
86
|
var updatedColumns = columnObjects.map(function (colDef) {
|
|
88
87
|
return {
|
|
89
88
|
id: colDef.id,
|
|
@@ -119,21 +118,22 @@ var CustomizeColumnsModal = function CustomizeColumnsModal(_ref) {
|
|
|
119
118
|
setVisibleColumnsCount(getVisibleColumnsCount());
|
|
120
119
|
setTotalColumns(columnObjects.length);
|
|
121
120
|
}, [getVisibleColumnsCount, columnObjects.length]);
|
|
122
|
-
return /*#__PURE__*/React.createElement(
|
|
123
|
-
className: "".concat(blockClass, "__customize-columns-
|
|
121
|
+
return /*#__PURE__*/React.createElement(TearsheetNarrow, {
|
|
122
|
+
className: "".concat(blockClass, "__customize-columns-tearsheet"),
|
|
124
123
|
open: isOpen,
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
124
|
+
title: "".concat(customizeTearsheetHeadingLabel, " (").concat(visibleColumnsCount, "/").concat(totalColumns, ")"),
|
|
125
|
+
description: instructionsLabel,
|
|
126
|
+
actions: [{
|
|
127
|
+
kind: 'secondary',
|
|
128
|
+
label: secondaryButtonTextLabel,
|
|
129
|
+
onClick: onRequestClose
|
|
130
|
+
}, {
|
|
131
|
+
kind: 'primary',
|
|
132
|
+
label: primaryButtonTextLabel,
|
|
133
|
+
onClick: onRequestSubmit,
|
|
134
|
+
disabled: !isDirty
|
|
135
|
+
}]
|
|
136
|
+
}, /*#__PURE__*/React.createElement(Actions, {
|
|
137
137
|
columns: columnObjects,
|
|
138
138
|
originalColumnDefinitions: originalColumnDefinitions,
|
|
139
139
|
searchText: searchText,
|
|
@@ -158,11 +158,11 @@ var CustomizeColumnsModal = function CustomizeColumnsModal(_ref) {
|
|
|
158
158
|
selectAllLabel: selectAllLabel
|
|
159
159
|
}));
|
|
160
160
|
};
|
|
161
|
-
|
|
161
|
+
CustomizeColumnsTearsheet.propTypes = {
|
|
162
162
|
assistiveTextDisabledInstructionsLabel: PropTypes.string,
|
|
163
163
|
assistiveTextInstructionsLabel: PropTypes.string,
|
|
164
164
|
columnDefinitions: PropTypes.array.isRequired,
|
|
165
|
-
|
|
165
|
+
customizeTearsheetHeadingLabel: PropTypes.string,
|
|
166
166
|
findColumnPlaceholderLabel: PropTypes.string,
|
|
167
167
|
instructionsLabel: PropTypes.string,
|
|
168
168
|
isOpen: PropTypes.bool.isRequired,
|
|
@@ -172,6 +172,6 @@ CustomizeColumnsModal.propTypes = {
|
|
|
172
172
|
resetToDefaultLabel: PropTypes.string,
|
|
173
173
|
secondaryButtonTextLabel: PropTypes.string,
|
|
174
174
|
selectAllLabel: PropTypes.string,
|
|
175
|
-
|
|
175
|
+
setIsTearsheetOpen: PropTypes.func.isRequired
|
|
176
176
|
};
|
|
177
|
-
export default
|
|
177
|
+
export default CustomizeColumnsTearsheet;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
+
var _excluded = ["onSaveColumnPrefs", "isTearsheetOpen", "setIsTearsheetOpen", "labels"];
|
|
4
|
+
/**
|
|
5
|
+
* Copyright IBM Corp. 2022, 2022
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import * as React from 'react';
|
|
12
|
+
import PropTypes from 'prop-types';
|
|
13
|
+
import CustomizeColumnsTearsheet from './CustomizeColumnsTearsheet';
|
|
14
|
+
var TearsheetWrapper = function TearsheetWrapper(_ref) {
|
|
15
|
+
var instance = _ref.instance;
|
|
16
|
+
var _instance$customizeCo = instance.customizeColumnsProps,
|
|
17
|
+
_onSaveColumnPrefs = _instance$customizeCo.onSaveColumnPrefs,
|
|
18
|
+
isTearsheetOpen = _instance$customizeCo.isTearsheetOpen,
|
|
19
|
+
setIsTearsheetOpen = _instance$customizeCo.setIsTearsheetOpen,
|
|
20
|
+
labels = _instance$customizeCo.labels,
|
|
21
|
+
rest = _objectWithoutProperties(_instance$customizeCo, _excluded);
|
|
22
|
+
return /*#__PURE__*/React.createElement(CustomizeColumnsTearsheet, _extends({}, rest, labels, {
|
|
23
|
+
isOpen: isTearsheetOpen,
|
|
24
|
+
setIsTearsheetOpen: setIsTearsheetOpen,
|
|
25
|
+
columnDefinitions: instance.allColumns,
|
|
26
|
+
originalColumnDefinitions: instance.columns,
|
|
27
|
+
onSaveColumnPrefs: function onSaveColumnPrefs(updatedColDefs) {
|
|
28
|
+
var hiddenIds = updatedColDefs.filter(function (colDef) {
|
|
29
|
+
return !colDef.isVisible;
|
|
30
|
+
}).map(function (colDef) {
|
|
31
|
+
return colDef.id;
|
|
32
|
+
});
|
|
33
|
+
instance.setHiddenColumns(hiddenIds);
|
|
34
|
+
if (typeof instance.setColumnOrder === 'function') {
|
|
35
|
+
instance.setColumnOrder(updatedColDefs.map(function (colDef) {
|
|
36
|
+
return colDef.id;
|
|
37
|
+
}));
|
|
38
|
+
} else {
|
|
39
|
+
// eslint-disable-next-line no-console
|
|
40
|
+
console.warn("Column order can not be updated. Did you forget to add 'useColumnOrder' in 'useDatagrid'");
|
|
41
|
+
}
|
|
42
|
+
if (typeof _onSaveColumnPrefs === 'function') {
|
|
43
|
+
_onSaveColumnPrefs(updatedColDefs);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}));
|
|
47
|
+
};
|
|
48
|
+
TearsheetWrapper.propTypes = {
|
|
49
|
+
instance: PropTypes.object.isRequired
|
|
50
|
+
};
|
|
51
|
+
export default TearsheetWrapper;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* restricted by GSA ADP Schedule Contract with IBM Corp.
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2022, 2022
|
|
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.
|
|
7
6
|
*/
|
|
8
7
|
|
|
9
|
-
export { default as
|
|
8
|
+
export { default as CustomizeColumnsTearsheetWrapper } from './TearsheetWrapper';
|
|
10
9
|
export { default as ToggleButtonWrapper } from './ButtonWrapper';
|
|
@@ -48,12 +48,9 @@ var FilterFlyout = function FilterFlyout(_ref) {
|
|
|
48
48
|
onApply = _ref$onApply === void 0 ? function () {} : _ref$onApply,
|
|
49
49
|
_ref$onCancel = _ref.onCancel,
|
|
50
50
|
onCancel = _ref$onCancel === void 0 ? function () {} : _ref$onCancel,
|
|
51
|
-
_ref$shouldClickOutsi = _ref.shouldClickOutsideToClose,
|
|
52
|
-
shouldClickOutsideToClose = _ref$shouldClickOutsi === void 0 ? false : _ref$shouldClickOutsi,
|
|
53
51
|
_ref$secondaryActionL = _ref.secondaryActionLabel,
|
|
54
52
|
secondaryActionLabel = _ref$secondaryActionL === void 0 ? 'Cancel' : _ref$secondaryActionL,
|
|
55
|
-
setAllFilters = _ref.setAllFilters
|
|
56
|
-
setFilter = _ref.setFilter;
|
|
53
|
+
setAllFilters = _ref.setAllFilters;
|
|
57
54
|
/** Context state and methods */
|
|
58
55
|
var _useContext = useContext(FilterContext),
|
|
59
56
|
EventEmitter = _useContext.EventEmitter;
|
|
@@ -100,8 +97,11 @@ var FilterFlyout = function FilterFlyout(_ref) {
|
|
|
100
97
|
prevFiltersObjectArrayRef.current = JSON.stringify(filtersObjectArray);
|
|
101
98
|
};
|
|
102
99
|
var cancel = function cancel() {
|
|
103
|
-
|
|
104
|
-
|
|
100
|
+
// Reverting to previous filters only applies when using batch actions
|
|
101
|
+
if (updateMethod === BATCH) {
|
|
102
|
+
revertToPreviousFilters();
|
|
103
|
+
onCancel();
|
|
104
|
+
}
|
|
105
105
|
closeFlyout();
|
|
106
106
|
};
|
|
107
107
|
var reset = function reset() {
|
|
@@ -133,34 +133,32 @@ var FilterFlyout = function FilterFlyout(_ref) {
|
|
|
133
133
|
if (type === DATE && !value[1]) {
|
|
134
134
|
return;
|
|
135
135
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
136
|
+
var filtersObjectArrayCopy = _toConsumableArray(filtersObjectArray);
|
|
137
|
+
// check if the filter already exists in the array
|
|
138
|
+
var filter = filtersObjectArrayCopy.find(function (item) {
|
|
139
|
+
return item.id === column;
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
// if filter exists in array then update the filter's new value
|
|
143
|
+
if (filter) {
|
|
144
|
+
filter.value = value;
|
|
145
|
+
} else {
|
|
146
|
+
filtersObjectArrayCopy.push({
|
|
147
|
+
id: column,
|
|
148
|
+
value: value,
|
|
149
|
+
type: type
|
|
141
150
|
});
|
|
151
|
+
}
|
|
152
|
+
setFiltersObjectArray(filtersObjectArrayCopy);
|
|
142
153
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
} else {
|
|
147
|
-
filtersObjectArrayCopy.push({
|
|
148
|
-
id: column,
|
|
149
|
-
value: value,
|
|
150
|
-
type: type
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
setFiltersObjectArray(filtersObjectArrayCopy);
|
|
154
|
-
} else if (updateMethod === INSTANT) {
|
|
155
|
-
setFilter(column, value);
|
|
154
|
+
// Automatically apply the filters if the updateMethod is instant
|
|
155
|
+
if (updateMethod === INSTANT) {
|
|
156
|
+
setAllFilters(filtersObjectArrayCopy);
|
|
156
157
|
}
|
|
157
|
-
}, [
|
|
158
|
+
}, [setAllFilters, updateMethod, filtersObjectArray]);
|
|
158
159
|
|
|
159
160
|
/** Effects */
|
|
160
161
|
useClickOutside(filterFlyoutRef, function (target) {
|
|
161
|
-
if (shouldClickOutsideToClose === false) {
|
|
162
|
-
return;
|
|
163
|
-
}
|
|
164
162
|
var hasClickedOnDatePicker = target.closest('.flatpickr-calendar');
|
|
165
163
|
if (!open || hasClickedOnDatePicker) {
|
|
166
164
|
return;
|
|
@@ -361,14 +359,6 @@ FilterFlyout.propTypes = {
|
|
|
361
359
|
* Function that sets all the filters, this comes from the datagridState
|
|
362
360
|
*/
|
|
363
361
|
setAllFilters: PropTypes.func.isRequired,
|
|
364
|
-
/**
|
|
365
|
-
* Function that sets an individual filter, this comes from the datagridState
|
|
366
|
-
*/
|
|
367
|
-
setFilter: PropTypes.func.isRequired,
|
|
368
|
-
/**
|
|
369
|
-
* Boolean if you want the flyout to close when clicked outside of the parent
|
|
370
|
-
*/
|
|
371
|
-
shouldClickOutsideToClose: PropTypes.bool,
|
|
372
362
|
/**
|
|
373
363
|
* Title of the filter flyout
|
|
374
364
|
*/
|
|
@@ -2,4 +2,4 @@ export { story as CustomizeColumnStory } from './CustomizeColumnStory';
|
|
|
2
2
|
export { default as StickyActionsColumn } from './StickyActionsColumnStory';
|
|
3
3
|
export { story as RowSizeDropdownStory } from './RowSizeDropdownStory';
|
|
4
4
|
export { story as LeftPanelStory } from './LeftPanelStory';
|
|
5
|
-
export { story as
|
|
5
|
+
export { story as SelectAllWithToggle } from './SelectAllWithToggleStory';
|
|
@@ -3,39 +3,37 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
3
3
|
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
|
-
|
|
7
|
-
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* US Government Users Restricted Rights - Use, duplication or disclosure
|
|
12
|
-
* restricted by GSA ADP Schedule Contract with IBM Corp.
|
|
6
|
+
/**
|
|
7
|
+
* Copyright IBM Corp. 2022, 2022
|
|
8
|
+
*
|
|
9
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
10
|
+
* LICENSE file in the root directory of this source tree.
|
|
13
11
|
*/
|
|
14
12
|
|
|
15
13
|
import * as React from 'react';
|
|
16
|
-
import {
|
|
14
|
+
import { CustomizeColumnsTearsheetWrapper, ToggleButtonWrapper } from './Datagrid/addons/CustomizeColumns';
|
|
17
15
|
var useCustomizeColumns = function useCustomizeColumns(hooks) {
|
|
18
16
|
var _React$useState = React.useState(false),
|
|
19
17
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
isTearsheetOpen = _React$useState2[0],
|
|
19
|
+
setIsTearsheetOpen = _React$useState2[1];
|
|
22
20
|
hooks.useInstance.push(function (instance) {
|
|
23
21
|
var customizeColumnsProps = instance.customizeColumnsProps;
|
|
24
22
|
var _ref = customizeColumnsProps || {},
|
|
25
23
|
labels = _ref.labels;
|
|
26
24
|
Object.assign(instance, {
|
|
27
25
|
customizeColumnsProps: _objectSpread(_objectSpread({}, customizeColumnsProps), {}, {
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
isTearsheetOpen: isTearsheetOpen,
|
|
27
|
+
setIsTearsheetOpen: setIsTearsheetOpen
|
|
30
28
|
}),
|
|
31
29
|
CustomizeColumnsButton: function CustomizeColumnsButton(props) {
|
|
32
30
|
return /*#__PURE__*/React.createElement(ToggleButtonWrapper, _extends({
|
|
33
31
|
iconTooltipLabel: labels === null || labels === void 0 ? void 0 : labels.iconTooltipLabel,
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
isTearsheetOpen: isTearsheetOpen,
|
|
33
|
+
setIsTearsheetOpen: setIsTearsheetOpen
|
|
36
34
|
}, props));
|
|
37
35
|
},
|
|
38
|
-
|
|
36
|
+
CustomizeColumnsTearsheet: CustomizeColumnsTearsheetWrapper
|
|
39
37
|
});
|
|
40
38
|
});
|
|
41
39
|
};
|
|
@@ -61,7 +61,6 @@ var useFiltering = function useFiltering(hooks) {
|
|
|
61
61
|
hooks.useInstance.push(function (instance) {
|
|
62
62
|
var filterProps = instance.filterProps,
|
|
63
63
|
setAllFilters = instance.setAllFilters,
|
|
64
|
-
setFilter = instance.setFilter,
|
|
65
64
|
headers = instance.headers;
|
|
66
65
|
var defaultProps = {
|
|
67
66
|
variation: 'flyout'
|
|
@@ -69,7 +68,6 @@ var useFiltering = function useFiltering(hooks) {
|
|
|
69
68
|
var getFilterFlyoutProps = function getFilterFlyoutProps() {
|
|
70
69
|
return _objectSpread(_objectSpread(_objectSpread({}, defaultProps), filterProps), {}, {
|
|
71
70
|
setAllFilters: setAllFilters,
|
|
72
|
-
setFilter: setFilter,
|
|
73
71
|
headers: headers
|
|
74
72
|
});
|
|
75
73
|
};
|
|
@@ -12,6 +12,7 @@ var useParentDimensions = function useParentDimensions(hooks) {
|
|
|
12
12
|
var headRef = useRef();
|
|
13
13
|
var innerListRef = useRef();
|
|
14
14
|
var listRef = useRef();
|
|
15
|
+
var gridRef = useRef();
|
|
15
16
|
var _useState = useState(),
|
|
16
17
|
_useState2 = _slicedToArray(_useState, 2),
|
|
17
18
|
tableHeight = _useState2[0],
|
|
@@ -47,7 +48,8 @@ var useParentDimensions = function useParentDimensions(hooks) {
|
|
|
47
48
|
headRef: headRef,
|
|
48
49
|
innerListRef: innerListRef,
|
|
49
50
|
handleResize: handleResize,
|
|
50
|
-
listRef: listRef
|
|
51
|
+
listRef: listRef,
|
|
52
|
+
gridRef: gridRef
|
|
51
53
|
});
|
|
52
54
|
};
|
|
53
55
|
hooks.useInstance.push(useInstance);
|
|
@@ -90,5 +90,10 @@ export var ARG_TYPES = {
|
|
|
90
90
|
customizeColumnsProps: {
|
|
91
91
|
control: 'object',
|
|
92
92
|
description: 'This is an object containing all of the props used with the column customization extension. _This value is set/passed inside of the `datagridState` object._'
|
|
93
|
+
},
|
|
94
|
+
filterProps: {
|
|
95
|
+
name: 'Filter props',
|
|
96
|
+
control: 'object',
|
|
97
|
+
description: 'This is an object for all the props passed into the filter flyout and filter panel'
|
|
93
98
|
}
|
|
94
99
|
};
|
|
@@ -74,8 +74,13 @@ export var getInlineEditColumns = function getInlineEditColumns() {
|
|
|
74
74
|
accessor: 'visits',
|
|
75
75
|
width: 120,
|
|
76
76
|
inlineEdit: {
|
|
77
|
+
validator: function validator(n) {
|
|
78
|
+
return n && n < 10;
|
|
79
|
+
},
|
|
77
80
|
type: 'number',
|
|
78
|
-
inputProps: {
|
|
81
|
+
inputProps: {
|
|
82
|
+
invalidText: 'Invalid number, must be 10 or greater'
|
|
83
|
+
} // These props are passed to the Carbon component used for inline editing
|
|
79
84
|
}
|
|
80
85
|
}, {
|
|
81
86
|
Header: 'Active since',
|
|
@@ -111,51 +111,49 @@ export var ImportModal = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
111
111
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(evt) {
|
|
112
112
|
var fileName, pendingFile, response, blob, fetchedFile, failedFile;
|
|
113
113
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
114
|
-
while (1) {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
_context.next = 10;
|
|
132
|
-
break;
|
|
133
|
-
}
|
|
134
|
-
throw new Error(response.status);
|
|
135
|
-
case 10:
|
|
136
|
-
_context.next = 12;
|
|
137
|
-
return response.blob();
|
|
138
|
-
case 12:
|
|
139
|
-
blob = _context.sent;
|
|
140
|
-
fetchedFile = new File([blob], fileName, {
|
|
141
|
-
type: blob.type
|
|
142
|
-
});
|
|
143
|
-
fetchedFile.invalidFileType = isInvalidFileType(fetchedFile);
|
|
144
|
-
fetchedFile.uuid = pendingFile.uuid;
|
|
145
|
-
updateFiles([fetchedFile]);
|
|
146
|
-
_context.next = 23;
|
|
114
|
+
while (1) switch (_context.prev = _context.next) {
|
|
115
|
+
case 0:
|
|
116
|
+
evt.preventDefault();
|
|
117
|
+
fileName = importUrl.substring(importUrl.lastIndexOf('/') + 1).split('?')[0];
|
|
118
|
+
pendingFile = {
|
|
119
|
+
name: fileName,
|
|
120
|
+
status: 'uploading',
|
|
121
|
+
uuid: uuidv4()
|
|
122
|
+
};
|
|
123
|
+
setFiles([pendingFile]);
|
|
124
|
+
_context.prev = 4;
|
|
125
|
+
_context.next = 7;
|
|
126
|
+
return fetch(importUrl);
|
|
127
|
+
case 7:
|
|
128
|
+
response = _context.sent;
|
|
129
|
+
if (!(!response.ok || response.status !== 200)) {
|
|
130
|
+
_context.next = 10;
|
|
147
131
|
break;
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
132
|
+
}
|
|
133
|
+
throw new Error(response.status);
|
|
134
|
+
case 10:
|
|
135
|
+
_context.next = 12;
|
|
136
|
+
return response.blob();
|
|
137
|
+
case 12:
|
|
138
|
+
blob = _context.sent;
|
|
139
|
+
fetchedFile = new File([blob], fileName, {
|
|
140
|
+
type: blob.type
|
|
141
|
+
});
|
|
142
|
+
fetchedFile.invalidFileType = isInvalidFileType(fetchedFile);
|
|
143
|
+
fetchedFile.uuid = pendingFile.uuid;
|
|
144
|
+
updateFiles([fetchedFile]);
|
|
145
|
+
_context.next = 23;
|
|
146
|
+
break;
|
|
147
|
+
case 19:
|
|
148
|
+
_context.prev = 19;
|
|
149
|
+
_context.t0 = _context["catch"](4);
|
|
150
|
+
failedFile = _objectSpread(_objectSpread({}, pendingFile), {}, {
|
|
151
|
+
fetchError: true
|
|
152
|
+
});
|
|
153
|
+
updateFiles([failedFile]);
|
|
154
|
+
case 23:
|
|
155
|
+
case "end":
|
|
156
|
+
return _context.stop();
|
|
159
157
|
}
|
|
160
158
|
}, _callee, null, [[4, 19]]);
|
|
161
159
|
}));
|
package/es/components/index.js
CHANGED
|
@@ -37,7 +37,7 @@ export { WebTerminal, WebTerminalContentWrapper, useWebTerminal, WebTerminalProv
|
|
|
37
37
|
export { EditSidePanel } from './EditSidePanel';
|
|
38
38
|
export { OptionsTile } from './OptionsTile';
|
|
39
39
|
export { DataSpreadsheet } from './DataSpreadsheet';
|
|
40
|
-
export { Datagrid, useDatagrid, useInfiniteScroll, useNestedRows, useSelectRows, useExpandedRow, useOnRowClick, useSortableColumns, useRowIsMouseOver, useColumnRightAlign, useDisableSelectRows, useStickyColumn, useActionsColumn, useCustomizeColumns, useSelectAllWithToggle, useColumnOrder, useInlineEdit } from './Datagrid';
|
|
40
|
+
export { Datagrid, useDatagrid, useInfiniteScroll, useNestedRows, useSelectRows, useExpandedRow, useOnRowClick, useSortableColumns, useRowIsMouseOver, useColumnRightAlign, useDisableSelectRows, useStickyColumn, useActionsColumn, useCustomizeColumns, useSelectAllWithToggle, useColumnOrder, useInlineEdit, useFiltering } from './Datagrid';
|
|
41
41
|
export { EditTearsheet } from './EditTearsheet';
|
|
42
42
|
export { EditTearsheetNarrow } from './EditTearsheetNarrow';
|
|
43
43
|
export { EditFullPage } from './EditFullPage';
|