@carbon/ibm-products 2.1.3 → 2.2.0
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 +246 -777
- 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 +11 -210
- 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 +48 -412
- 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 +121 -344
- 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/AboutModal/AboutModal.js +4 -2
- package/es/components/ActionBar/ActionBar.js +6 -2
- package/es/components/AddSelect/AddSelectFormControl.js +6 -6
- package/es/components/AddSelect/AddSelectRow.js +5 -15
- package/es/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.js +6 -5
- package/es/components/ButtonMenu/ButtonMenu.js +4 -4
- package/es/components/ButtonSetWithOverflow/ButtonSetWithOverflow.js +9 -3
- package/es/components/Cascade/Cascade.js +1 -11
- package/es/components/CreateFullPage/CreateFullPage.js +0 -13
- package/es/components/CreateModal/CreateModal.js +0 -7
- package/es/components/CreateSidePanel/CreateSidePanel.js +1 -1
- package/es/components/DataSpreadsheet/DataSpreadsheet.js +3 -3
- package/es/components/Datagrid/Datagrid/DatagridContent.js +1 -1
- package/es/components/Datagrid/Datagrid/DatagridSelectAllWithToggle.js +3 -3
- package/es/components/Datagrid/Datagrid/DatagridToolbar.js +2 -3
- package/es/components/Datagrid/Datagrid/DatagridVirtualBody.js +3 -1
- package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/TearsheetWrapper.js +1 -1
- package/es/components/Datagrid/Datagrid/addons/Filtering/FilterFlyout.js +47 -39
- package/es/components/Datagrid/Datagrid/addons/Filtering/FilterPanel.js +24 -20
- package/es/components/Datagrid/Datagrid/addons/Filtering/hooks/index.js +1 -0
- package/es/components/Datagrid/Datagrid/addons/Filtering/hooks/useFilters.js +15 -44
- package/es/components/Datagrid/Datagrid/addons/Filtering/hooks/useInitialStateFromFilters.js +21 -0
- package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditCell/InlineEditCell.js +10 -12
- package/es/components/Datagrid/Datagrid/addons/InlineEdit/handleGridKeyPress.js +2 -2
- package/es/components/Datagrid/useActionsColumn.js +7 -10
- package/es/components/Datagrid/useCustomizeColumns.js +7 -9
- package/es/components/Datagrid/useExpandedRow.js +7 -11
- package/es/components/Datagrid/useFiltering.js +8 -12
- package/es/components/Datagrid/useInlineEdit.js +0 -3
- package/es/components/Datagrid/useNestedRows.js +6 -10
- package/es/components/Datagrid/useStickyColumn.js +3 -10
- package/es/components/Datagrid/utils/DatagridActions.js +14 -6
- package/es/components/EditFullPage/EditFullPage.js +1 -2
- package/es/components/EditSidePanel/EditSidePanel.js +1 -1
- package/es/components/EditTearsheet/EditTearsheet.js +0 -4
- package/es/components/EditTearsheetNarrow/EditTearsheetNarrow.js +1 -1
- package/es/components/EditUpdateCards/EditUpdateCards.js +2 -3
- package/es/components/EmptyStates/EmptyState.js +0 -4
- package/es/components/EmptyStates/ErrorEmptyState/ErrorEmptyState.js +0 -4
- package/es/components/EmptyStates/NoDataEmptyState/NoDataEmptyState.js +0 -4
- package/es/components/EmptyStates/NoTagsEmptyState/NoTagsEmptyState.js +0 -4
- package/es/components/EmptyStates/NotFoundEmptyState/NotFoundEmptyState.js +0 -4
- package/es/components/EmptyStates/NotificationsEmptyState/NotificationsEmptyState.js +0 -4
- package/es/components/EmptyStates/UnauthorizedEmptyState/UnauthorizedEmptyState.js +0 -4
- package/es/components/ExportModal/ExportModal.js +0 -4
- package/es/components/HTTPErrors/HTTPError403/HTTPError403.js +0 -6
- package/es/components/HTTPErrors/HTTPError404/HTTPError404.js +0 -6
- package/es/components/HTTPErrors/HTTPErrorOther/HTTPErrorOther.js +0 -6
- package/es/components/ImportModal/ImportModal.js +6 -13
- package/es/components/MultiAddSelect/MultiAddSelect.js +0 -4
- package/es/components/NotificationsPanel/preview-components/UnreadNotificationBell.js +17 -2
- package/es/components/PageHeader/PageHeader.js +6 -2
- package/es/components/PageHeader/PageHeaderUtils.js +2 -2
- package/es/components/RemoveModal/RemoveModal.js +0 -6
- package/es/components/SidePanel/SidePanel.js +3 -1
- package/es/components/SingleAddSelect/SingleAddSelect.js +0 -4
- package/es/components/StatusIcon/StatusIcon.js +0 -10
- package/es/components/TagSet/TagSet.js +7 -4
- package/es/components/Tearsheet/TearsheetShell.js +6 -11
- package/es/components/UserProfileImage/UserProfileImage.js +3 -14
- package/es/components/WebTerminal/WebTerminal.js +0 -4
- package/es/global/js/hooks/useCreateComponentStepChange.js +15 -16
- package/es/global/js/hooks/useResizeObserver.js +28 -14
- package/es/global/js/package-settings.js +1 -14
- package/es/global/js/utils/story-helper.js +6 -108
- package/lib/components/AboutModal/AboutModal.js +4 -2
- package/lib/components/ActionBar/ActionBar.js +6 -2
- package/lib/components/AddSelect/AddSelectFormControl.js +6 -6
- package/lib/components/AddSelect/AddSelectRow.js +5 -15
- package/lib/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.js +6 -5
- package/lib/components/ButtonMenu/ButtonMenu.js +4 -4
- package/lib/components/ButtonSetWithOverflow/ButtonSetWithOverflow.js +9 -3
- package/lib/components/Cascade/Cascade.js +1 -11
- package/lib/components/CreateFullPage/CreateFullPage.js +0 -13
- package/lib/components/CreateModal/CreateModal.js +0 -7
- package/lib/components/CreateSidePanel/CreateSidePanel.js +1 -1
- package/lib/components/DataSpreadsheet/DataSpreadsheet.js +3 -3
- package/lib/components/Datagrid/Datagrid/DatagridContent.js +1 -1
- package/lib/components/Datagrid/Datagrid/DatagridSelectAllWithToggle.js +3 -3
- package/lib/components/Datagrid/Datagrid/DatagridToolbar.js +2 -3
- package/lib/components/Datagrid/Datagrid/DatagridVirtualBody.js +3 -1
- package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/TearsheetWrapper.js +1 -1
- package/lib/components/Datagrid/Datagrid/addons/Filtering/FilterFlyout.js +45 -37
- package/lib/components/Datagrid/Datagrid/addons/Filtering/FilterPanel.js +24 -20
- package/lib/components/Datagrid/Datagrid/addons/Filtering/hooks/index.js +7 -0
- package/lib/components/Datagrid/Datagrid/addons/Filtering/hooks/useFilters.js +13 -42
- package/lib/components/Datagrid/Datagrid/addons/Filtering/hooks/useInitialStateFromFilters.js +30 -0
- package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditCell/InlineEditCell.js +10 -12
- package/lib/components/Datagrid/Datagrid/addons/InlineEdit/handleGridKeyPress.js +2 -2
- package/lib/components/Datagrid/useActionsColumn.js +7 -12
- package/lib/components/Datagrid/useCustomizeColumns.js +8 -10
- package/lib/components/Datagrid/useExpandedRow.js +6 -9
- package/lib/components/Datagrid/useFiltering.js +7 -10
- package/lib/components/Datagrid/useInlineEdit.js +0 -3
- package/lib/components/Datagrid/useNestedRows.js +6 -9
- package/lib/components/Datagrid/useStickyColumn.js +3 -10
- package/lib/components/Datagrid/utils/DatagridActions.js +13 -5
- package/lib/components/EditFullPage/EditFullPage.js +1 -2
- package/lib/components/EditSidePanel/EditSidePanel.js +1 -1
- package/lib/components/EditTearsheet/EditTearsheet.js +0 -4
- package/lib/components/EditTearsheetNarrow/EditTearsheetNarrow.js +1 -1
- package/lib/components/EditUpdateCards/EditUpdateCards.js +2 -3
- package/lib/components/EmptyStates/EmptyState.js +0 -4
- package/lib/components/EmptyStates/ErrorEmptyState/ErrorEmptyState.js +0 -4
- package/lib/components/EmptyStates/NoDataEmptyState/NoDataEmptyState.js +0 -4
- package/lib/components/EmptyStates/NoTagsEmptyState/NoTagsEmptyState.js +0 -4
- package/lib/components/EmptyStates/NotFoundEmptyState/NotFoundEmptyState.js +0 -4
- package/lib/components/EmptyStates/NotificationsEmptyState/NotificationsEmptyState.js +0 -4
- package/lib/components/EmptyStates/UnauthorizedEmptyState/UnauthorizedEmptyState.js +0 -4
- package/lib/components/ExportModal/ExportModal.js +0 -4
- package/lib/components/HTTPErrors/HTTPError403/HTTPError403.js +0 -6
- package/lib/components/HTTPErrors/HTTPError404/HTTPError404.js +0 -6
- package/lib/components/HTTPErrors/HTTPErrorOther/HTTPErrorOther.js +0 -6
- package/lib/components/ImportModal/ImportModal.js +6 -13
- package/lib/components/MultiAddSelect/MultiAddSelect.js +0 -4
- package/lib/components/NotificationsPanel/preview-components/UnreadNotificationBell.js +17 -2
- package/lib/components/PageHeader/PageHeader.js +6 -2
- package/lib/components/PageHeader/PageHeaderUtils.js +2 -2
- package/lib/components/RemoveModal/RemoveModal.js +0 -6
- package/lib/components/SidePanel/SidePanel.js +3 -1
- package/lib/components/SingleAddSelect/SingleAddSelect.js +0 -4
- package/lib/components/StatusIcon/StatusIcon.js +0 -10
- package/lib/components/TagSet/TagSet.js +7 -4
- package/lib/components/Tearsheet/TearsheetShell.js +6 -11
- package/lib/components/UserProfileImage/UserProfileImage.js +3 -14
- package/lib/components/WebTerminal/WebTerminal.js +0 -4
- package/lib/global/js/hooks/useCreateComponentStepChange.js +15 -16
- package/lib/global/js/hooks/useResizeObserver.js +27 -13
- package/lib/global/js/package-settings.js +1 -14
- package/lib/global/js/utils/story-helper.js +7 -115
- package/package.json +4 -4
- package/scss/components/AddSelect/_add-select.scss +0 -4
- package/scss/components/BreadcrumbWithOverflow/_breadcrumb-with-overflow.scss +1 -0
- package/scss/components/ButtonMenu/_button-menu.scss +1 -32
- package/scss/components/Cascade/_storybook-styles.scss +2 -3
- package/scss/components/DataSpreadsheet/_storybook-styles.scss +0 -6
- package/scss/components/Datagrid/_datagrid.scss +2 -4
- package/scss/components/Datagrid/_storybook-styles.scss +2 -16
- package/scss/components/Datagrid/styles/_datagrid.scss +13 -26
- package/scss/components/Datagrid/styles/addons/_FilterFlyout.scss +0 -7
- package/scss/components/Datagrid/styles/addons/_FilterPanel.scss +0 -4
- package/scss/components/HTTPErrors/_storybook-styles.scss +6 -0
- package/scss/components/NotificationsPanel/_notifications-panel.scss +1 -1
- package/scss/components/NotificationsPanel/_storybook-styles.scss +2 -10
- package/scss/components/PageHeader/_page-header.scss +1 -0
- package/scss/components/PageHeader/_storybook-styles.scss +14 -24
- package/scss/components/SidePanel/_side-panel.scss +2 -0
- package/scss/components/Tearsheet/_tearsheet.scss +6 -7
- package/scss/components/WebTerminal/_storybook-styles.scss +1 -11
- package/scss/global/styles/_display-box.scss +0 -1
- package/es/components/APIKeyModal/APIKeyModal.docs-page.js +0 -26
- package/es/components/AboutModal/AboutModal.docs-page.js +0 -21
- package/es/components/Cascade/Cascade.docs-page.js +0 -22
- package/es/components/CreateFullPage/CreateFullPage.docs-page.js +0 -39
- package/es/components/CreateModal/CreateModal.docs-page.js +0 -24
- package/es/components/CreateSidePanel/CreateSidePanel.docs-page.js +0 -18
- package/es/components/CreateTearsheet/CreateTearsheet.docs-page.js +0 -29
- package/es/components/EditFullPage/EditFullPage.docs-page.js +0 -39
- package/es/components/EditTearsheet/EditTearsheet.docs-page.js +0 -25
- package/es/components/ExampleComponent/ExampleComponent.docs-page.js +0 -22
- package/es/components/ImportModal/ImportModal.docs-page.js +0 -18
- package/es/components/MultiAddSelect/MultiAddSelect.docs-page.js +0 -17
- package/es/components/RemoveModal/RemoveModal.docs-page.js +0 -18
- package/es/components/SingleAddSelect/SingleAddSelect.docs-page.js +0 -15
- package/es/components/StatusIcon/StatusIcon.docs-page.js +0 -17
- package/es/components/Toolbar/Toolbar.docs-page.js +0 -14
- package/es/components/UserProfileImage/UserProfileImage.docs-page.js +0 -17
- package/es/components/WebTerminal/WebTerminal.docs-page.js +0 -52
- package/es/global/js/utils/StoryDocsPage.js +0 -218
- package/lib/components/APIKeyModal/APIKeyModal.docs-page.js +0 -37
- package/lib/components/AboutModal/AboutModal.docs-page.js +0 -32
- package/lib/components/Cascade/Cascade.docs-page.js +0 -33
- package/lib/components/CreateFullPage/CreateFullPage.docs-page.js +0 -50
- package/lib/components/CreateModal/CreateModal.docs-page.js +0 -35
- package/lib/components/CreateSidePanel/CreateSidePanel.docs-page.js +0 -29
- package/lib/components/CreateTearsheet/CreateTearsheet.docs-page.js +0 -40
- package/lib/components/EditFullPage/EditFullPage.docs-page.js +0 -50
- package/lib/components/EditTearsheet/EditTearsheet.docs-page.js +0 -36
- package/lib/components/ExampleComponent/ExampleComponent.docs-page.js +0 -33
- package/lib/components/ImportModal/ImportModal.docs-page.js +0 -26
- package/lib/components/MultiAddSelect/MultiAddSelect.docs-page.js +0 -25
- package/lib/components/RemoveModal/RemoveModal.docs-page.js +0 -26
- package/lib/components/SingleAddSelect/SingleAddSelect.docs-page.js +0 -23
- package/lib/components/StatusIcon/StatusIcon.docs-page.js +0 -28
- package/lib/components/Toolbar/Toolbar.docs-page.js +0 -25
- package/lib/components/UserProfileImage/UserProfileImage.docs-page.js +0 -28
- package/lib/components/WebTerminal/WebTerminal.docs-page.js +0 -63
- package/lib/global/js/utils/StoryDocsPage.js +0 -225
|
@@ -21,16 +21,6 @@ var componentName = 'Cascade';
|
|
|
21
21
|
var defaults = {
|
|
22
22
|
grid: false
|
|
23
23
|
};
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
|
|
27
|
-
This pattern is intended for use with cards, tiles, or similarly styled
|
|
28
|
-
components. Use this patterns in areas that are the primary focus on the page to
|
|
29
|
-
help the user along their journey or locate the most important information on
|
|
30
|
-
the page. It should not be used on a page if it is the secondary focus of the
|
|
31
|
-
page as that will distract the user.
|
|
32
|
-
|
|
33
|
-
*/
|
|
34
24
|
export var Cascade = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
35
25
|
var children = _ref.children,
|
|
36
26
|
className = _ref.className,
|
|
@@ -82,7 +72,7 @@ Cascade.propTypes = {
|
|
|
82
72
|
*/
|
|
83
73
|
className: PropTypes.string,
|
|
84
74
|
/**
|
|
85
|
-
* Specifies whether or not to wrap the child content in a
|
|
75
|
+
* Specifies whether or not to wrap the child content in a <Grid />.
|
|
86
76
|
* If this is set to true it's important that the children are being wrapped in rows in columns.
|
|
87
77
|
* Check the documentation for additional clarification.
|
|
88
78
|
*/
|
|
@@ -35,19 +35,6 @@ export var StepsContext = /*#__PURE__*/createContext(null);
|
|
|
35
35
|
// This is a context supplied separately to each step in the container
|
|
36
36
|
// to let it know what number it is in the sequence of steps
|
|
37
37
|
export var StepNumberContext = /*#__PURE__*/createContext(-1);
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Use with creations that must be completed in order for a service to be usable.
|
|
41
|
-
*
|
|
42
|
-
* ### Grid
|
|
43
|
-
*
|
|
44
|
-
* The `CreateFullPage` component utilizes Carbons' grid system in the inner
|
|
45
|
-
content of the main section inside of the component. You can read more guidance
|
|
46
|
-
on the Carbon's grid system
|
|
47
|
-
[here](https://www.carbondesignsystem.com/guidelines/2x-grid/overview). You can
|
|
48
|
-
include `<Row>` and `<Column>` components inside of each `CreateFullPageStep`
|
|
49
|
-
component to get the desired affect.
|
|
50
|
-
*/
|
|
51
38
|
export var CreateFullPage = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
52
39
|
var backButtonText = _ref.backButtonText,
|
|
53
40
|
cancelButtonText = _ref.cancelButtonText,
|
|
@@ -30,13 +30,6 @@ var isValidChildren = function isValidChildren() {
|
|
|
30
30
|
return;
|
|
31
31
|
};
|
|
32
32
|
};
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* The `CreateModal` component provides a way for a user to quickly generate a new
|
|
36
|
-
resource. It is triggered by a user’s action, appears on top of the main page
|
|
37
|
-
content, and is persistent until dismissed. The purpose of this modal should be
|
|
38
|
-
immediately apparent to the user, with a clear and obvious path to completion.
|
|
39
|
-
*/
|
|
40
33
|
export var CreateModal = /*#__PURE__*/React.forwardRef(function (_ref2, ref) {
|
|
41
34
|
var className = _ref2.className,
|
|
42
35
|
children = _ref2.children,
|
|
@@ -31,7 +31,7 @@ var componentName = 'CreateSidePanel';
|
|
|
31
31
|
// NOTE: the component SCSS is not imported here: it is rolled up separately.
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
|
-
*
|
|
34
|
+
* This is an example component to show relevant conventions and usage.
|
|
35
35
|
*/
|
|
36
36
|
export var CreateSidePanel = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
37
37
|
var className = _ref.className,
|
|
@@ -667,6 +667,9 @@ export var DataSpreadsheet = /*#__PURE__*/React.forwardRef(function (_ref, ref)
|
|
|
667
667
|
defaultColumn: defaultColumn,
|
|
668
668
|
cellEditorValue: cellEditorValue
|
|
669
669
|
});
|
|
670
|
+
var handleActiveCellMouseEnter = useCallback(function () {
|
|
671
|
+
handleActiveCellMouseEnterCallback(selectionAreas, clickAndHoldActive);
|
|
672
|
+
}, [clickAndHoldActive, selectionAreas, handleActiveCellMouseEnterCallback]);
|
|
670
673
|
|
|
671
674
|
// Only update if there are cell selection areas
|
|
672
675
|
// Find point object that matches currentMatcher and remove the second point
|
|
@@ -699,9 +702,6 @@ export var DataSpreadsheet = /*#__PURE__*/React.forwardRef(function (_ref, ref)
|
|
|
699
702
|
});
|
|
700
703
|
}
|
|
701
704
|
}, [spreadsheetRef, currentMatcher]);
|
|
702
|
-
var handleActiveCellMouseEnter = useCallback(function () {
|
|
703
|
-
handleActiveCellMouseEnterCallback(selectionAreas, clickAndHoldActive);
|
|
704
|
-
}, [clickAndHoldActive, selectionAreas, handleActiveCellMouseEnterCallback]);
|
|
705
705
|
return /*#__PURE__*/React.createElement("div", _extends({}, rest, getTableProps(), getDevtoolsProps(componentName), {
|
|
706
706
|
className: cx(blockClass, className, "".concat(blockClass, "--interactive-cell-element"), (_cx = {}, _defineProperty(_cx, "".concat(blockClass, "__container-has-focus"), containerHasFocus), _defineProperty(_cx, "".concat(blockClass, "__").concat(theme), theme === 'dark'), _cx)),
|
|
707
707
|
ref: spreadsheetRef,
|
|
@@ -82,7 +82,7 @@ export var DatagridContent = function DatagridContent(_ref) {
|
|
|
82
82
|
return /*#__PURE__*/React.createElement(Table, _extends({}, getTableProps(), {
|
|
83
83
|
className: cx(withVirtualScroll ? '' : "".concat(blockClass, "__table-simple"), "".concat(blockClass, "__vertical-align-").concat(verticalAlign), _defineProperty({}, "".concat(blockClass, "__variable-row-height"), variableRowHeight), _defineProperty({}, "".concat(blockClass, "__table-with-inline-edit"), withInlineEdit), _defineProperty({}, "".concat(blockClass, "__table-grid-active"), gridActive), (_getTableProps = getTableProps()) === null || _getTableProps === void 0 ? void 0 : _getTableProps.className),
|
|
84
84
|
role: withInlineEdit && 'grid',
|
|
85
|
-
tabIndex: withInlineEdit
|
|
85
|
+
tabIndex: withInlineEdit && 0,
|
|
86
86
|
onKeyDown: withInlineEdit ? function (event) {
|
|
87
87
|
return handleGridKeyPress({
|
|
88
88
|
event: event,
|
|
@@ -35,9 +35,6 @@ var SelectAllWithToggle = function SelectAllWithToggle(_ref) {
|
|
|
35
35
|
allRowsLabel = _ref$allRowsLabel === void 0 ? 'Select all' : _ref$allRowsLabel,
|
|
36
36
|
columns = _ref.columns,
|
|
37
37
|
withStickyColumn = _ref.withStickyColumn;
|
|
38
|
-
var _ref2 = selectAllToggle || {},
|
|
39
|
-
onSelectAllRows = _ref2.onSelectAllRows,
|
|
40
|
-
labels = _ref2.labels;
|
|
41
38
|
var _useState = useState(SELECT_ALL_PAGE_ROWS),
|
|
42
39
|
_useState2 = _slicedToArray(_useState, 2),
|
|
43
40
|
selectAllMode = _useState2[0],
|
|
@@ -60,6 +57,9 @@ var SelectAllWithToggle = function SelectAllWithToggle(_ref) {
|
|
|
60
57
|
return window.removeEventListener('resize', updateSize);
|
|
61
58
|
};
|
|
62
59
|
}, []);
|
|
60
|
+
var _ref2 = selectAllToggle || {},
|
|
61
|
+
onSelectAllRows = _ref2.onSelectAllRows,
|
|
62
|
+
labels = _ref2.labels;
|
|
63
63
|
if (labels) {
|
|
64
64
|
allPageRowsLabel = labels.allPageRows || allPageRowsLabel;
|
|
65
65
|
allRowsLabel = labels.allRows || allRowsLabel;
|
|
@@ -16,7 +16,6 @@ import { pkg, carbon } from '../../../settings';
|
|
|
16
16
|
import cx from 'classnames';
|
|
17
17
|
var blockClass = "".concat(pkg.prefix, "--datagrid");
|
|
18
18
|
var DatagridBatchActionsToolbar = function DatagridBatchActionsToolbar(datagridState, width, ref) {
|
|
19
|
-
var _Object$keys;
|
|
20
19
|
var _useState = useState(false),
|
|
21
20
|
_useState2 = _slicedToArray(_useState, 2),
|
|
22
21
|
displayAllInMenu = _useState2[0],
|
|
@@ -29,11 +28,11 @@ var DatagridBatchActionsToolbar = function DatagridBatchActionsToolbar(datagridS
|
|
|
29
28
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
30
29
|
receivedInitialWidth = _useState6[0],
|
|
31
30
|
setReceivedInitialWidth = _useState6[1];
|
|
32
|
-
var
|
|
31
|
+
var selectedFlatRows = datagridState.selectedFlatRows,
|
|
33
32
|
toggleAllRowsSelected = datagridState.toggleAllRowsSelected,
|
|
34
33
|
toolbarBatchActions = datagridState.toolbarBatchActions,
|
|
35
34
|
setGlobalFilter = datagridState.setGlobalFilter;
|
|
36
|
-
var totalSelected =
|
|
35
|
+
var totalSelected = selectedFlatRows && selectedFlatRows.length;
|
|
37
36
|
|
|
38
37
|
// Get initial width of batch actions container,
|
|
39
38
|
// used to measure when all items are put inside
|
|
@@ -50,7 +50,9 @@ var DatagridVirtualBody = function DatagridVirtualBody(datagridState) {
|
|
|
50
50
|
var gridRefElement = gridRef === null || gridRef === void 0 ? void 0 : gridRef.current;
|
|
51
51
|
gridRefElement.style.width = gridRefElement === null || gridRefElement === void 0 ? void 0 : gridRefElement.clientWidth;
|
|
52
52
|
};
|
|
53
|
-
useResizeObserver(gridRef,
|
|
53
|
+
useResizeObserver(gridRef, {
|
|
54
|
+
callback: handleVirtualGridResize
|
|
55
|
+
});
|
|
54
56
|
var syncScroll = function syncScroll(e) {
|
|
55
57
|
var virtualBody = e.target;
|
|
56
58
|
document.querySelector(".".concat(blockClass, "__head-wrap")).scrollLeft = virtualBody.scrollLeft;
|
|
@@ -20,7 +20,7 @@ var TearsheetWrapper = function TearsheetWrapper(_ref) {
|
|
|
20
20
|
rest = _objectWithoutProperties(_instance$customizeCo, _excluded);
|
|
21
21
|
return /*#__PURE__*/React.createElement(CustomizeColumnsTearsheet, _extends({}, rest, labels, {
|
|
22
22
|
isOpen: isTearsheetOpen,
|
|
23
|
-
isTableSortable:
|
|
23
|
+
isTableSortable: instance === null || instance === void 0 ? void 0 : instance.isTableSortable,
|
|
24
24
|
setIsTearsheetOpen: setIsTearsheetOpen,
|
|
25
25
|
columnDefinitions: instance.allColumns,
|
|
26
26
|
originalColumnDefinitions: instance.columns,
|
|
@@ -9,10 +9,10 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
import { Filter } from '@carbon/react/icons';
|
|
12
|
-
import {
|
|
12
|
+
import { Button, usePrefix } from '@carbon/react';
|
|
13
13
|
import cx from 'classnames';
|
|
14
14
|
import PropTypes from 'prop-types';
|
|
15
|
-
import React, { useRef, useState
|
|
15
|
+
import React, { useRef, useState } from 'react';
|
|
16
16
|
import { useClickOutside } from '../../../../../global/js/hooks';
|
|
17
17
|
import { pkg } from '../../../../../settings';
|
|
18
18
|
import { ActionSet } from '../../../../ActionSet';
|
|
@@ -45,8 +45,11 @@ var FilterFlyout = function FilterFlyout(_ref) {
|
|
|
45
45
|
setAllFilters = _ref.setAllFilters,
|
|
46
46
|
_ref$data = _ref.data,
|
|
47
47
|
data = _ref$data === void 0 ? [] : _ref$data,
|
|
48
|
-
_ref$
|
|
49
|
-
|
|
48
|
+
_ref$initialFilters = _ref.initialFilters,
|
|
49
|
+
initialFilters = _ref$initialFilters === void 0 ? [] : _ref$initialFilters;
|
|
50
|
+
// Save the initial filters we only need the filters once when it loads
|
|
51
|
+
var initialFiltersRef = useRef(initialFilters);
|
|
52
|
+
|
|
50
53
|
/** State */
|
|
51
54
|
var _useState = useState(false),
|
|
52
55
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -57,17 +60,15 @@ var FilterFlyout = function FilterFlyout(_ref) {
|
|
|
57
60
|
filters: filters,
|
|
58
61
|
setAllFilters: setAllFilters,
|
|
59
62
|
variation: FLYOUT,
|
|
60
|
-
|
|
61
|
-
onCancel: onCancel
|
|
63
|
+
initialFilters: initialFiltersRef.current
|
|
62
64
|
}),
|
|
63
65
|
filtersState = _useFilters.filtersState,
|
|
64
66
|
prevFiltersObjectArrayRef = _useFilters.prevFiltersObjectArrayRef,
|
|
65
67
|
prevFiltersRef = _useFilters.prevFiltersRef,
|
|
66
|
-
|
|
68
|
+
revertToPreviousFilters = _useFilters.revertToPreviousFilters,
|
|
67
69
|
reset = _useFilters.reset,
|
|
68
70
|
renderFilter = _useFilters.renderFilter,
|
|
69
|
-
filtersObjectArray = _useFilters.filtersObjectArray
|
|
70
|
-
lastAppliedFilters = _useFilters.lastAppliedFilters;
|
|
71
|
+
filtersObjectArray = _useFilters.filtersObjectArray;
|
|
71
72
|
|
|
72
73
|
/** Refs */
|
|
73
74
|
var filterFlyoutRef = useRef(null);
|
|
@@ -106,10 +107,26 @@ var FilterFlyout = function FilterFlyout(_ref) {
|
|
|
106
107
|
// updates the ref so next time the flyout opens we have records of the previous filters
|
|
107
108
|
prevFiltersRef.current = JSON.stringify(filtersState);
|
|
108
109
|
prevFiltersObjectArrayRef.current = JSON.stringify(filtersObjectArray);
|
|
109
|
-
|
|
110
|
-
// Update the last applied filters
|
|
111
|
-
lastAppliedFilters.current = JSON.stringify(filtersObjectArray);
|
|
112
110
|
};
|
|
111
|
+
var cancel = function cancel() {
|
|
112
|
+
// Reverting to previous filters only applies when using batch actions
|
|
113
|
+
if (updateMethod === BATCH) {
|
|
114
|
+
revertToPreviousFilters();
|
|
115
|
+
onCancel();
|
|
116
|
+
}
|
|
117
|
+
closeFlyout();
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
/** Effects */
|
|
121
|
+
useClickOutside(filterFlyoutRef, function (target) {
|
|
122
|
+
var hasClickedOnDatePicker = target.closest('.flatpickr-calendar');
|
|
123
|
+
var hasClickedOnDropdown = target.className === "".concat(carbonPrefix, "--list-box__menu-item__option");
|
|
124
|
+
if (!open || hasClickedOnDatePicker || hasClickedOnDropdown) {
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
cancel();
|
|
128
|
+
});
|
|
129
|
+
useSubscribeToEventEmitter(CLEAR_FILTERS, reset);
|
|
113
130
|
|
|
114
131
|
/** Renders all filters */
|
|
115
132
|
var renderFilters = function renderFilters() {
|
|
@@ -136,31 +153,22 @@ var FilterFlyout = function FilterFlyout(_ref) {
|
|
|
136
153
|
buttonSize: "md"
|
|
137
154
|
});
|
|
138
155
|
};
|
|
139
|
-
|
|
140
|
-
/** Effects */
|
|
141
|
-
useClickOutside(filterFlyoutRef, function (target) {
|
|
142
|
-
var hasClickedOnDatePicker = target.closest('.flatpickr-calendar');
|
|
143
|
-
var hasClickedOnDropdown = target.className === "".concat(carbonPrefix, "--list-box__menu-item__option");
|
|
144
|
-
if (!open || hasClickedOnDatePicker || hasClickedOnDropdown) {
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
closeFlyout();
|
|
148
|
-
cancel();
|
|
149
|
-
});
|
|
150
|
-
useSubscribeToEventEmitter(CLEAR_FILTERS, reset);
|
|
151
|
-
useEffect(function reflectLastAppliedFiltersWhenReactTableUpdates() {
|
|
152
|
-
lastAppliedFilters.current = JSON.stringify(reactTableFiltersState);
|
|
153
|
-
}, [reactTableFiltersState, lastAppliedFilters]);
|
|
154
156
|
return /*#__PURE__*/React.createElement("div", {
|
|
155
157
|
className: "".concat(componentClass, "__container")
|
|
156
|
-
}, /*#__PURE__*/React.createElement(
|
|
157
|
-
label: flyoutIconDescription,
|
|
158
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
158
159
|
kind: "ghost",
|
|
159
|
-
|
|
160
|
+
hasIconOnly: true,
|
|
161
|
+
tooltipPosition: "bottom",
|
|
162
|
+
renderIcon: function renderIcon() {
|
|
163
|
+
return /*#__PURE__*/React.createElement(Filter, {
|
|
164
|
+
size: 16
|
|
165
|
+
});
|
|
166
|
+
},
|
|
167
|
+
iconDescription: flyoutIconDescription,
|
|
160
168
|
onClick: open ? closeFlyout : openFlyout,
|
|
161
169
|
className: cx("".concat(componentClass, "__trigger"), _defineProperty({}, "".concat(componentClass, "__trigger--open"), open)),
|
|
162
170
|
disabled: data.length === 0
|
|
163
|
-
}
|
|
171
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
164
172
|
ref: filterFlyoutRef,
|
|
165
173
|
className: cx(componentClass, (_cx2 = {}, _defineProperty(_cx2, "".concat(componentClass, "--open"), open), _defineProperty(_cx2, "".concat(componentClass, "--batch"), showActionSet), _defineProperty(_cx2, "".concat(componentClass, "--instant"), !showActionSet), _cx2))
|
|
166
174
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -188,6 +196,14 @@ FilterFlyout.propTypes = {
|
|
|
188
196
|
* Icon description for the filter flyout button
|
|
189
197
|
*/
|
|
190
198
|
flyoutIconDescription: PropTypes.string,
|
|
199
|
+
/**
|
|
200
|
+
* Filters that should be applied on load
|
|
201
|
+
*/
|
|
202
|
+
initialFilters: PropTypes.arrayOf(PropTypes.shape({
|
|
203
|
+
id: PropTypes.string.isRequired,
|
|
204
|
+
type: PropTypes.string.isRequired,
|
|
205
|
+
value: PropTypes.any.isRequired
|
|
206
|
+
})),
|
|
191
207
|
/**
|
|
192
208
|
* Callback when the apply button is clicked
|
|
193
209
|
*/
|
|
@@ -208,14 +224,6 @@ FilterFlyout.propTypes = {
|
|
|
208
224
|
* Label text of the primary action in the flyout
|
|
209
225
|
*/
|
|
210
226
|
primaryActionLabel: PropTypes.string,
|
|
211
|
-
/**
|
|
212
|
-
* Filters from react table's state
|
|
213
|
-
*/
|
|
214
|
-
reactTableFiltersState: PropTypes.arrayOf(PropTypes.shape({
|
|
215
|
-
id: PropTypes.string.isRequired,
|
|
216
|
-
type: PropTypes.string.isRequired,
|
|
217
|
-
value: PropTypes.any.isRequired
|
|
218
|
-
})),
|
|
219
227
|
/**
|
|
220
228
|
* Label text of the secondary action in the flyout
|
|
221
229
|
*/
|
|
@@ -56,8 +56,11 @@ var FilterPanel = function FilterPanel(_ref) {
|
|
|
56
56
|
searchLabelText = _ref$searchLabelText === void 0 ? 'Filter search' : _ref$searchLabelText,
|
|
57
57
|
_ref$searchPlaceholde = _ref.searchPlaceholder,
|
|
58
58
|
searchPlaceholder = _ref$searchPlaceholde === void 0 ? 'Find filters' : _ref$searchPlaceholde,
|
|
59
|
-
_ref$
|
|
60
|
-
|
|
59
|
+
_ref$initialFilters = _ref.initialFilters,
|
|
60
|
+
initialFilters = _ref$initialFilters === void 0 ? [] : _ref$initialFilters;
|
|
61
|
+
// Save the initial filters we only need the filters once
|
|
62
|
+
var initialFiltersRef = useRef(initialFilters);
|
|
63
|
+
|
|
61
64
|
/** State */
|
|
62
65
|
var _useState = useState(false),
|
|
63
66
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -68,17 +71,15 @@ var FilterPanel = function FilterPanel(_ref) {
|
|
|
68
71
|
filters: filterSections,
|
|
69
72
|
setAllFilters: setAllFilters,
|
|
70
73
|
variation: PANEL,
|
|
71
|
-
|
|
72
|
-
onCancel: onCancel
|
|
74
|
+
initialFilters: initialFiltersRef.current
|
|
73
75
|
}),
|
|
74
76
|
filtersState = _useFilters.filtersState,
|
|
75
77
|
prevFiltersObjectArrayRef = _useFilters.prevFiltersObjectArrayRef,
|
|
76
78
|
prevFiltersRef = _useFilters.prevFiltersRef,
|
|
77
|
-
|
|
79
|
+
revertToPreviousFilters = _useFilters.revertToPreviousFilters,
|
|
78
80
|
reset = _useFilters.reset,
|
|
79
81
|
renderFilter = _useFilters.renderFilter,
|
|
80
|
-
filtersObjectArray = _useFilters.filtersObjectArray
|
|
81
|
-
lastAppliedFilters = _useFilters.lastAppliedFilters;
|
|
82
|
+
filtersObjectArray = _useFilters.filtersObjectArray;
|
|
82
83
|
|
|
83
84
|
/** Refs */
|
|
84
85
|
var filterPanelRef = useRef();
|
|
@@ -108,8 +109,14 @@ var FilterPanel = function FilterPanel(_ref) {
|
|
|
108
109
|
|
|
109
110
|
/** Methods */
|
|
110
111
|
var closePanel = function closePanel() {
|
|
111
|
-
|
|
112
|
-
|
|
112
|
+
return setPanelOpen(false);
|
|
113
|
+
};
|
|
114
|
+
var cancel = function cancel() {
|
|
115
|
+
// Reverting to previous filters only applies when using batch actions
|
|
116
|
+
if (updateMethod === BATCH) {
|
|
117
|
+
revertToPreviousFilters();
|
|
118
|
+
onCancel();
|
|
119
|
+
}
|
|
113
120
|
};
|
|
114
121
|
var apply = function apply() {
|
|
115
122
|
setAllFilters(filtersObjectArray);
|
|
@@ -121,9 +128,6 @@ var FilterPanel = function FilterPanel(_ref) {
|
|
|
121
128
|
// updates the ref so next time the flyout opens we have records of the previous filters
|
|
122
129
|
prevFiltersRef.current = JSON.stringify(filtersState);
|
|
123
130
|
prevFiltersObjectArrayRef.current = JSON.stringify(filtersObjectArray);
|
|
124
|
-
|
|
125
|
-
// Update the last applied filters
|
|
126
|
-
lastAppliedFilters.current = JSON.stringify(filtersObjectArray);
|
|
127
131
|
};
|
|
128
132
|
var renderActionSet = function renderActionSet() {
|
|
129
133
|
return showActionSet && /*#__PURE__*/React.createElement(MotionActionSet, {
|
|
@@ -240,20 +244,20 @@ FilterPanel.propTypes = {
|
|
|
240
244
|
closeIconDescription: PropTypes.string,
|
|
241
245
|
filterPanelMinHeight: PropTypes.number,
|
|
242
246
|
filterSections: PropTypes.array,
|
|
243
|
-
onApply: PropTypes.func,
|
|
244
|
-
onCancel: PropTypes.func,
|
|
245
|
-
onPanelClose: PropTypes.func,
|
|
246
|
-
onPanelOpen: PropTypes.func,
|
|
247
|
-
open: PropTypes.bool,
|
|
248
|
-
primaryActionLabel: PropTypes.string,
|
|
249
247
|
/**
|
|
250
|
-
* Filters
|
|
248
|
+
* Filters that should be applied on load
|
|
251
249
|
*/
|
|
252
|
-
|
|
250
|
+
initialFilters: PropTypes.arrayOf(PropTypes.shape({
|
|
253
251
|
id: PropTypes.string.isRequired,
|
|
254
252
|
type: PropTypes.string.isRequired,
|
|
255
253
|
value: PropTypes.any.isRequired
|
|
256
254
|
})),
|
|
255
|
+
onApply: PropTypes.func,
|
|
256
|
+
onCancel: PropTypes.func,
|
|
257
|
+
onPanelClose: PropTypes.func,
|
|
258
|
+
onPanelOpen: PropTypes.func,
|
|
259
|
+
open: PropTypes.bool,
|
|
260
|
+
primaryActionLabel: PropTypes.string,
|
|
257
261
|
searchLabelText: PropTypes.string,
|
|
258
262
|
searchPlaceholder: PropTypes.string,
|
|
259
263
|
secondaryActionLabel: PropTypes.string,
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
export { default as useInitialStateFromFilters } from './useInitialStateFromFilters';
|
|
8
9
|
export { default as useSubscribeToEventEmitter } from './useSubscribeToEventEmitter';
|
|
9
10
|
export { default as useFilters } from './useFilters';
|
|
10
11
|
export { default as useShouldDisableButtons } from './useShouldDisableButtons';
|
|
@@ -11,9 +11,10 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
11
11
|
* US Government Users Restricted Rights - Use, duplication or disclosure
|
|
12
12
|
* restricted by GSA ADP Schedule Contract with IBM Corp.
|
|
13
13
|
*/
|
|
14
|
-
import React, { useState, useRef
|
|
14
|
+
import React, { useState, useRef } from 'react';
|
|
15
15
|
import { Checkbox, DatePicker, DatePickerInput, Dropdown, FormGroup, NumberInput, RadioButton, RadioButtonGroup, Layer } from '@carbon/react';
|
|
16
|
-
import { INSTANT,
|
|
16
|
+
import { INSTANT, DATE, CHECKBOX, NUMBER, RADIO, DROPDOWN, PANEL } from '../constants';
|
|
17
|
+
import useInitialStateFromFilters from './useInitialStateFromFilters';
|
|
17
18
|
import { getInitialStateFromFilters } from '../utils';
|
|
18
19
|
var useFilters = function useFilters(_ref) {
|
|
19
20
|
var updateMethod = _ref.updateMethod,
|
|
@@ -21,22 +22,19 @@ var useFilters = function useFilters(_ref) {
|
|
|
21
22
|
filters = _ref$filters === void 0 ? [] : _ref$filters,
|
|
22
23
|
setAllFilters = _ref.setAllFilters,
|
|
23
24
|
variation = _ref.variation,
|
|
24
|
-
|
|
25
|
-
_ref$onCancel = _ref.onCancel,
|
|
26
|
-
onCancel = _ref$onCancel === void 0 ? function () {} : _ref$onCancel;
|
|
25
|
+
initialFilters = _ref.initialFilters;
|
|
27
26
|
/** State */
|
|
28
|
-
var
|
|
27
|
+
var _useInitialStateFromF = useInitialStateFromFilters(filters, variation, initialFilters),
|
|
28
|
+
_useInitialStateFromF2 = _slicedToArray(_useInitialStateFromF, 2),
|
|
29
|
+
filtersState = _useInitialStateFromF2[0],
|
|
30
|
+
setFiltersState = _useInitialStateFromF2[1];
|
|
31
|
+
var _useState = useState(initialFilters),
|
|
29
32
|
_useState2 = _slicedToArray(_useState, 2),
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
var _useState3 = useState(reactTableFiltersState),
|
|
33
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
34
|
-
filtersObjectArray = _useState4[0],
|
|
35
|
-
setFiltersObjectArray = _useState4[1];
|
|
33
|
+
filtersObjectArray = _useState2[0],
|
|
34
|
+
setFiltersObjectArray = _useState2[1];
|
|
36
35
|
|
|
37
36
|
// When using batch actions we have to store the filters to then apply them later
|
|
38
37
|
var prevFiltersRef = useRef(JSON.stringify(filtersState));
|
|
39
|
-
var lastAppliedFilters = useRef(JSON.stringify(reactTableFiltersState));
|
|
40
38
|
var prevFiltersObjectArrayRef = useRef(JSON.stringify(filtersObjectArray));
|
|
41
39
|
|
|
42
40
|
/** Methods */
|
|
@@ -45,7 +43,6 @@ var useFilters = function useFilters(_ref) {
|
|
|
45
43
|
var revertToPreviousFilters = function revertToPreviousFilters() {
|
|
46
44
|
setFiltersState(JSON.parse(prevFiltersRef.current));
|
|
47
45
|
setFiltersObjectArray(JSON.parse(prevFiltersObjectArrayRef.current));
|
|
48
|
-
setAllFilters(JSON.parse(lastAppliedFilters.current));
|
|
49
46
|
};
|
|
50
47
|
var reset = function reset() {
|
|
51
48
|
// When we reset we want the "initialFilters" to be an empty array
|
|
@@ -157,11 +154,8 @@ var useFilters = function useFilters(_ref) {
|
|
|
157
154
|
var type = _ref3.type,
|
|
158
155
|
column = _ref3.column,
|
|
159
156
|
components = _ref3.props;
|
|
160
|
-
var filter;
|
|
161
157
|
var isPanel = variation === PANEL;
|
|
162
|
-
|
|
163
|
-
return console.error("type: ".concat(type, "; does not exist as a type of filter."));
|
|
164
|
-
}
|
|
158
|
+
var filter;
|
|
165
159
|
switch (type) {
|
|
166
160
|
case DATE:
|
|
167
161
|
filter = /*#__PURE__*/React.createElement(DatePicker, _extends({}, components.DatePicker, {
|
|
@@ -287,31 +281,10 @@ var useFilters = function useFilters(_ref) {
|
|
|
287
281
|
break;
|
|
288
282
|
}
|
|
289
283
|
if (isPanel) {
|
|
290
|
-
return /*#__PURE__*/React.createElement(Layer,
|
|
291
|
-
key: column
|
|
292
|
-
}, filter);
|
|
284
|
+
return /*#__PURE__*/React.createElement(Layer, null, filter);
|
|
293
285
|
}
|
|
294
|
-
return
|
|
295
|
-
key: column
|
|
296
|
-
}, filter);
|
|
286
|
+
return filter;
|
|
297
287
|
};
|
|
298
|
-
var cancel = function cancel() {
|
|
299
|
-
// Reverting to previous filters only applies when using batch actions
|
|
300
|
-
if (updateMethod === BATCH) {
|
|
301
|
-
revertToPreviousFilters();
|
|
302
|
-
onCancel();
|
|
303
|
-
}
|
|
304
|
-
};
|
|
305
|
-
|
|
306
|
-
/** The purpose of this function is to sync any changes in react-tables state.filters array and reflect
|
|
307
|
-
those new filter changes in the panel/flyout state. The external change is triggered if setAllFilters is called outside of the Datagrid */
|
|
308
|
-
useEffect(function updateStateAndFiltersToReflectExternalFilterChanges() {
|
|
309
|
-
var newFiltersState = getInitialStateFromFilters(filters, variation, reactTableFiltersState);
|
|
310
|
-
setFiltersState(newFiltersState);
|
|
311
|
-
prevFiltersRef.current = JSON.stringify(newFiltersState);
|
|
312
|
-
prevFiltersObjectArrayRef.current = JSON.stringify(reactTableFiltersState);
|
|
313
|
-
setFiltersObjectArray(reactTableFiltersState);
|
|
314
|
-
}, [filters, reactTableFiltersState, variation]);
|
|
315
288
|
return {
|
|
316
289
|
filtersState: filtersState,
|
|
317
290
|
setFiltersState: setFiltersState,
|
|
@@ -320,9 +293,7 @@ var useFilters = function useFilters(_ref) {
|
|
|
320
293
|
revertToPreviousFilters: revertToPreviousFilters,
|
|
321
294
|
reset: reset,
|
|
322
295
|
renderFilter: renderFilter,
|
|
323
|
-
filtersObjectArray: filtersObjectArray
|
|
324
|
-
lastAppliedFilters: lastAppliedFilters,
|
|
325
|
-
cancel: cancel
|
|
296
|
+
filtersObjectArray: filtersObjectArray
|
|
326
297
|
};
|
|
327
298
|
};
|
|
328
299
|
export default useFilters;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
+
/*
|
|
3
|
+
* Licensed Materials - Property of IBM
|
|
4
|
+
* 5724-Q36
|
|
5
|
+
* (c) Copyright IBM Corp. 2022
|
|
6
|
+
* US Government Users Restricted Rights - Use, duplication or disclosure
|
|
7
|
+
* restricted by GSA ADP Schedule Contract with IBM Corp.
|
|
8
|
+
*/
|
|
9
|
+
import { useState } from 'react';
|
|
10
|
+
import { FLYOUT } from '../constants';
|
|
11
|
+
import { getInitialStateFromFilters } from '../utils';
|
|
12
|
+
var useInitialStateFromFilters = function useInitialStateFromFilters(filters) {
|
|
13
|
+
var variation = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : FLYOUT;
|
|
14
|
+
var initialFilters = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
15
|
+
var _useState = useState(getInitialStateFromFilters(filters, variation, initialFilters)),
|
|
16
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
17
|
+
state = _useState2[0],
|
|
18
|
+
setState = _useState2[1];
|
|
19
|
+
return [state, setState];
|
|
20
|
+
};
|
|
21
|
+
export default useInitialStateFromFilters;
|
|
@@ -5,7 +5,7 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
|
5
5
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
6
6
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
7
7
|
/**
|
|
8
|
-
* Copyright IBM Corp. 2022,
|
|
8
|
+
* Copyright IBM Corp. 2022, 2022
|
|
9
9
|
*
|
|
10
10
|
* This source code is licensed under the Apache-2.0 license found in the
|
|
11
11
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -31,8 +31,7 @@ export var InlineEditCell = function InlineEditCell(_ref) {
|
|
|
31
31
|
placeholder = _ref$placeholder === void 0 ? '' : _ref$placeholder,
|
|
32
32
|
tabIndex = _ref.tabIndex,
|
|
33
33
|
value = _ref.value,
|
|
34
|
-
|
|
35
|
-
nonEditCell = _ref$nonEditCell === void 0 ? false : _ref$nonEditCell,
|
|
34
|
+
nonEditCell = _ref.nonEditCell,
|
|
36
35
|
totalInlineEditColumns = _ref.totalInlineEditColumns,
|
|
37
36
|
type = _ref.type;
|
|
38
37
|
var columnId = cell.column.id;
|
|
@@ -73,9 +72,6 @@ export var InlineEditCell = function InlineEditCell(_ref) {
|
|
|
73
72
|
var dropdownRef = useRef();
|
|
74
73
|
var datePickerRef = useRef();
|
|
75
74
|
var outerButtonElement = useRef();
|
|
76
|
-
var rowSize = instance.rowSize,
|
|
77
|
-
onDataUpdate = instance.onDataUpdate;
|
|
78
|
-
var saveCellData;
|
|
79
75
|
useEffect(function () {
|
|
80
76
|
setInitialValue(value);
|
|
81
77
|
var columnId = cell.column.id;
|
|
@@ -149,6 +145,8 @@ export var InlineEditCell = function InlineEditCell(_ref) {
|
|
|
149
145
|
}, 1);
|
|
150
146
|
}
|
|
151
147
|
};
|
|
148
|
+
var rowSize = instance.rowSize,
|
|
149
|
+
onDataUpdate = instance.onDataUpdate;
|
|
152
150
|
|
|
153
151
|
// Auto focus text input when entering edit mode
|
|
154
152
|
useEffect(function () {
|
|
@@ -162,9 +160,14 @@ export var InlineEditCell = function InlineEditCell(_ref) {
|
|
|
162
160
|
}
|
|
163
161
|
}, [inEditMode, type]);
|
|
164
162
|
|
|
163
|
+
// Initialize cellValue from value prop
|
|
164
|
+
useEffect(function () {
|
|
165
|
+
setCellValue(value);
|
|
166
|
+
}, [value]);
|
|
167
|
+
|
|
165
168
|
// Saves the new cell data, onDataUpdate is a required function to be
|
|
166
169
|
// passed to useDatagrid when using useInlineEdit
|
|
167
|
-
saveCellData = useCallback(function (newValue) {
|
|
170
|
+
var saveCellData = useCallback(function (newValue) {
|
|
168
171
|
var columnId = cell.column.id;
|
|
169
172
|
var rowIndex = cell.row.index;
|
|
170
173
|
onDataUpdate(function (prev) {
|
|
@@ -176,11 +179,6 @@ export var InlineEditCell = function InlineEditCell(_ref) {
|
|
|
176
179
|
});
|
|
177
180
|
});
|
|
178
181
|
}, [cell, onDataUpdate]);
|
|
179
|
-
|
|
180
|
-
// Initialize cellValue from value prop
|
|
181
|
-
useEffect(function () {
|
|
182
|
-
setCellValue(value);
|
|
183
|
-
}, [value]);
|
|
184
182
|
var sendFocusBackToGrid = function sendFocusBackToGrid() {
|
|
185
183
|
// Allows the onKeyDown listener to go back to the entire grid area
|
|
186
184
|
var inlineEditArea = document.querySelector("#".concat(instance.tableId, " .").concat(blockClass, "__table-with-inline-edit"));
|
|
@@ -2,7 +2,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
2
2
|
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; }
|
|
3
3
|
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; }
|
|
4
4
|
/**
|
|
5
|
-
* Copyright IBM Corp. 2022,
|
|
5
|
+
* Copyright IBM Corp. 2022, 2022
|
|
6
6
|
*
|
|
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.
|
|
@@ -86,7 +86,7 @@ export var handleGridKeyPress = function handleGridKeyPress(_ref) {
|
|
|
86
86
|
if (['End', 'Home', 'ArrowLeft', 'ArrowUp', 'ArrowRight', 'ArrowDown'].indexOf(key) > -1 && !isEditing && keysPressedList.length < 2) {
|
|
87
87
|
event.preventDefault();
|
|
88
88
|
}
|
|
89
|
-
var isDisabledCell = focusedCell.getAttribute('data-disabled')
|
|
89
|
+
var isDisabledCell = !!focusedCell.getAttribute('data-disabled');
|
|
90
90
|
var sharedUpdateParams = {
|
|
91
91
|
oldId: activeCellId,
|
|
92
92
|
instance: instance
|