@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
|
@@ -145,9 +145,15 @@ var ButtonSetWithOverflow = function ButtonSetWithOverflow(_ref) {
|
|
|
145
145
|
}, (0, _propsHelper.prepareProps)(other, ['iconDescription', 'renderIcon'])));
|
|
146
146
|
}).reverse());
|
|
147
147
|
});
|
|
148
|
-
(0, _useResizeObserver.useResizeObserver)(sizingContainerRefSet,
|
|
149
|
-
|
|
150
|
-
|
|
148
|
+
(0, _useResizeObserver.useResizeObserver)(sizingContainerRefSet, {
|
|
149
|
+
callback: checkFullyVisibleItems
|
|
150
|
+
});
|
|
151
|
+
(0, _useResizeObserver.useResizeObserver)(sizingContainerRefCombo, {
|
|
152
|
+
callback: checkFullyVisibleItems
|
|
153
|
+
});
|
|
154
|
+
(0, _useResizeObserver.useResizeObserver)(spaceAvailableRef, {
|
|
155
|
+
callback: checkFullyVisibleItems
|
|
156
|
+
});
|
|
151
157
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
152
158
|
className: (0, _classnames.default)([blockClass, className, (0, _defineProperty2.default)({}, "".concat(blockClass, "--right"), rightAlign)]),
|
|
153
159
|
ref: spaceAvailableRef
|
|
@@ -29,16 +29,6 @@ var componentName = 'Cascade';
|
|
|
29
29
|
var defaults = {
|
|
30
30
|
grid: false
|
|
31
31
|
};
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
|
|
35
|
-
This pattern is intended for use with cards, tiles, or similarly styled
|
|
36
|
-
components. Use this patterns in areas that are the primary focus on the page to
|
|
37
|
-
help the user along their journey or locate the most important information on
|
|
38
|
-
the page. It should not be used on a page if it is the secondary focus of the
|
|
39
|
-
page as that will distract the user.
|
|
40
|
-
|
|
41
|
-
*/
|
|
42
32
|
var Cascade = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
43
33
|
var children = _ref.children,
|
|
44
34
|
className = _ref.className,
|
|
@@ -91,7 +81,7 @@ Cascade.propTypes = {
|
|
|
91
81
|
*/
|
|
92
82
|
className: _propTypes.default.string,
|
|
93
83
|
/**
|
|
94
|
-
* Specifies whether or not to wrap the child content in a
|
|
84
|
+
* Specifies whether or not to wrap the child content in a <Grid />.
|
|
95
85
|
* If this is set to true it's important that the children are being wrapped in rows in columns.
|
|
96
86
|
* Check the documentation for additional clarification.
|
|
97
87
|
*/
|
|
@@ -43,19 +43,6 @@ var StepsContext = /*#__PURE__*/(0, _react.createContext)(null);
|
|
|
43
43
|
// to let it know what number it is in the sequence of steps
|
|
44
44
|
exports.StepsContext = StepsContext;
|
|
45
45
|
var StepNumberContext = /*#__PURE__*/(0, _react.createContext)(-1);
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Use with creations that must be completed in order for a service to be usable.
|
|
49
|
-
*
|
|
50
|
-
* ### Grid
|
|
51
|
-
*
|
|
52
|
-
* The `CreateFullPage` component utilizes Carbons' grid system in the inner
|
|
53
|
-
content of the main section inside of the component. You can read more guidance
|
|
54
|
-
on the Carbon's grid system
|
|
55
|
-
[here](https://www.carbondesignsystem.com/guidelines/2x-grid/overview). You can
|
|
56
|
-
include `<Row>` and `<Column>` components inside of each `CreateFullPageStep`
|
|
57
|
-
component to get the desired affect.
|
|
58
|
-
*/
|
|
59
46
|
exports.StepNumberContext = StepNumberContext;
|
|
60
47
|
var CreateFullPage = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
|
|
61
48
|
var backButtonText = _ref.backButtonText,
|
|
@@ -35,13 +35,6 @@ var isValidChildren = function isValidChildren() {
|
|
|
35
35
|
return;
|
|
36
36
|
};
|
|
37
37
|
};
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* The `CreateModal` component provides a way for a user to quickly generate a new
|
|
41
|
-
resource. It is triggered by a user’s action, appears on top of the main page
|
|
42
|
-
content, and is persistent until dismissed. The purpose of this modal should be
|
|
43
|
-
immediately apparent to the user, with a clear and obvious path to completion.
|
|
44
|
-
*/
|
|
45
38
|
var CreateModal = /*#__PURE__*/_react.default.forwardRef(function (_ref2, ref) {
|
|
46
39
|
var className = _ref2.className,
|
|
47
40
|
children = _ref2.children,
|
|
@@ -34,7 +34,7 @@ var componentName = 'CreateSidePanel';
|
|
|
34
34
|
// NOTE: the component SCSS is not imported here: it is rolled up separately.
|
|
35
35
|
|
|
36
36
|
/**
|
|
37
|
-
*
|
|
37
|
+
* This is an example component to show relevant conventions and usage.
|
|
38
38
|
*/
|
|
39
39
|
var CreateSidePanel = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
|
|
40
40
|
var className = _ref.className,
|
|
@@ -674,6 +674,9 @@ var DataSpreadsheet = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
|
|
|
674
674
|
defaultColumn: defaultColumn,
|
|
675
675
|
cellEditorValue: cellEditorValue
|
|
676
676
|
});
|
|
677
|
+
var handleActiveCellMouseEnter = (0, _react.useCallback)(function () {
|
|
678
|
+
handleActiveCellMouseEnterCallback(selectionAreas, clickAndHoldActive);
|
|
679
|
+
}, [clickAndHoldActive, selectionAreas, handleActiveCellMouseEnterCallback]);
|
|
677
680
|
|
|
678
681
|
// Only update if there are cell selection areas
|
|
679
682
|
// Find point object that matches currentMatcher and remove the second point
|
|
@@ -706,9 +709,6 @@ var DataSpreadsheet = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
|
|
|
706
709
|
});
|
|
707
710
|
}
|
|
708
711
|
}, [spreadsheetRef, currentMatcher]);
|
|
709
|
-
var handleActiveCellMouseEnter = (0, _react.useCallback)(function () {
|
|
710
|
-
handleActiveCellMouseEnterCallback(selectionAreas, clickAndHoldActive);
|
|
711
|
-
}, [clickAndHoldActive, selectionAreas, handleActiveCellMouseEnterCallback]);
|
|
712
712
|
return /*#__PURE__*/_react.default.createElement("div", (0, _extends2.default)({}, rest, getTableProps(), (0, _devtools.getDevtoolsProps)(componentName), {
|
|
713
713
|
className: (0, _classnames.default)(blockClass, className, "".concat(blockClass, "--interactive-cell-element"), (_cx = {}, (0, _defineProperty2.default)(_cx, "".concat(blockClass, "__container-has-focus"), containerHasFocus), (0, _defineProperty2.default)(_cx, "".concat(blockClass, "__").concat(theme), theme === 'dark'), _cx)),
|
|
714
714
|
ref: spreadsheetRef,
|
|
@@ -92,7 +92,7 @@ var DatagridContent = function DatagridContent(_ref) {
|
|
|
92
92
|
return /*#__PURE__*/_react.default.createElement(_react2.Table, (0, _extends2.default)({}, getTableProps(), {
|
|
93
93
|
className: (0, _classnames.default)(withVirtualScroll ? '' : "".concat(blockClass, "__table-simple"), "".concat(blockClass, "__vertical-align-").concat(verticalAlign), (0, _defineProperty2.default)({}, "".concat(blockClass, "__variable-row-height"), variableRowHeight), (0, _defineProperty2.default)({}, "".concat(blockClass, "__table-with-inline-edit"), withInlineEdit), (0, _defineProperty2.default)({}, "".concat(blockClass, "__table-grid-active"), gridActive), (_getTableProps = getTableProps()) === null || _getTableProps === void 0 ? void 0 : _getTableProps.className),
|
|
94
94
|
role: withInlineEdit && 'grid',
|
|
95
|
-
tabIndex: withInlineEdit
|
|
95
|
+
tabIndex: withInlineEdit && 0,
|
|
96
96
|
onKeyDown: withInlineEdit ? function (event) {
|
|
97
97
|
return (0, _handleGridKeyPress.handleGridKeyPress)({
|
|
98
98
|
event: event,
|
|
@@ -44,9 +44,6 @@ var SelectAllWithToggle = function SelectAllWithToggle(_ref) {
|
|
|
44
44
|
allRowsLabel = _ref$allRowsLabel === void 0 ? 'Select all' : _ref$allRowsLabel,
|
|
45
45
|
columns = _ref.columns,
|
|
46
46
|
withStickyColumn = _ref.withStickyColumn;
|
|
47
|
-
var _ref2 = selectAllToggle || {},
|
|
48
|
-
onSelectAllRows = _ref2.onSelectAllRows,
|
|
49
|
-
labels = _ref2.labels;
|
|
50
47
|
var _useState = (0, _react.useState)(SELECT_ALL_PAGE_ROWS),
|
|
51
48
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
52
49
|
selectAllMode = _useState2[0],
|
|
@@ -69,6 +66,9 @@ var SelectAllWithToggle = function SelectAllWithToggle(_ref) {
|
|
|
69
66
|
return window.removeEventListener('resize', updateSize);
|
|
70
67
|
};
|
|
71
68
|
}, []);
|
|
69
|
+
var _ref2 = selectAllToggle || {},
|
|
70
|
+
onSelectAllRows = _ref2.onSelectAllRows,
|
|
71
|
+
labels = _ref2.labels;
|
|
72
72
|
if (labels) {
|
|
73
73
|
allPageRowsLabel = labels.allPageRows || allPageRowsLabel;
|
|
74
74
|
allRowsLabel = labels.allRows || allRowsLabel;
|
|
@@ -26,7 +26,6 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
26
26
|
|
|
27
27
|
var blockClass = "".concat(_settings.pkg.prefix, "--datagrid");
|
|
28
28
|
var DatagridBatchActionsToolbar = function DatagridBatchActionsToolbar(datagridState, width, ref) {
|
|
29
|
-
var _Object$keys;
|
|
30
29
|
var _useState = (0, _react.useState)(false),
|
|
31
30
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
32
31
|
displayAllInMenu = _useState2[0],
|
|
@@ -39,11 +38,11 @@ var DatagridBatchActionsToolbar = function DatagridBatchActionsToolbar(datagridS
|
|
|
39
38
|
_useState6 = (0, _slicedToArray2.default)(_useState5, 2),
|
|
40
39
|
receivedInitialWidth = _useState6[0],
|
|
41
40
|
setReceivedInitialWidth = _useState6[1];
|
|
42
|
-
var
|
|
41
|
+
var selectedFlatRows = datagridState.selectedFlatRows,
|
|
43
42
|
toggleAllRowsSelected = datagridState.toggleAllRowsSelected,
|
|
44
43
|
toolbarBatchActions = datagridState.toolbarBatchActions,
|
|
45
44
|
setGlobalFilter = datagridState.setGlobalFilter;
|
|
46
|
-
var totalSelected =
|
|
45
|
+
var totalSelected = selectedFlatRows && selectedFlatRows.length;
|
|
47
46
|
|
|
48
47
|
// Get initial width of batch actions container,
|
|
49
48
|
// used to measure when all items are put inside
|
|
@@ -59,7 +59,9 @@ var DatagridVirtualBody = function DatagridVirtualBody(datagridState) {
|
|
|
59
59
|
var gridRefElement = gridRef === null || gridRef === void 0 ? void 0 : gridRef.current;
|
|
60
60
|
gridRefElement.style.width = gridRefElement === null || gridRefElement === void 0 ? void 0 : gridRefElement.clientWidth;
|
|
61
61
|
};
|
|
62
|
-
(0, _useResizeObserver.useResizeObserver)(gridRef,
|
|
62
|
+
(0, _useResizeObserver.useResizeObserver)(gridRef, {
|
|
63
|
+
callback: handleVirtualGridResize
|
|
64
|
+
});
|
|
63
65
|
var syncScroll = function syncScroll(e) {
|
|
64
66
|
var virtualBody = e.target;
|
|
65
67
|
document.querySelector(".".concat(blockClass, "__head-wrap")).scrollLeft = virtualBody.scrollLeft;
|
|
@@ -29,7 +29,7 @@ var TearsheetWrapper = function TearsheetWrapper(_ref) {
|
|
|
29
29
|
rest = (0, _objectWithoutProperties2.default)(_instance$customizeCo, _excluded);
|
|
30
30
|
return /*#__PURE__*/React.createElement(_CustomizeColumnsTearsheet.default, (0, _extends2.default)({}, rest, labels, {
|
|
31
31
|
isOpen: isTearsheetOpen,
|
|
32
|
-
isTableSortable:
|
|
32
|
+
isTableSortable: instance === null || instance === void 0 ? void 0 : instance.isTableSortable,
|
|
33
33
|
setIsTearsheetOpen: setIsTearsheetOpen,
|
|
34
34
|
columnDefinitions: instance.allColumns,
|
|
35
35
|
originalColumnDefinitions: instance.columns,
|
|
@@ -55,8 +55,11 @@ var FilterFlyout = function FilterFlyout(_ref) {
|
|
|
55
55
|
setAllFilters = _ref.setAllFilters,
|
|
56
56
|
_ref$data = _ref.data,
|
|
57
57
|
data = _ref$data === void 0 ? [] : _ref$data,
|
|
58
|
-
_ref$
|
|
59
|
-
|
|
58
|
+
_ref$initialFilters = _ref.initialFilters,
|
|
59
|
+
initialFilters = _ref$initialFilters === void 0 ? [] : _ref$initialFilters;
|
|
60
|
+
// Save the initial filters we only need the filters once when it loads
|
|
61
|
+
var initialFiltersRef = (0, _react2.useRef)(initialFilters);
|
|
62
|
+
|
|
60
63
|
/** State */
|
|
61
64
|
var _useState = (0, _react2.useState)(false),
|
|
62
65
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
@@ -67,17 +70,15 @@ var FilterFlyout = function FilterFlyout(_ref) {
|
|
|
67
70
|
filters: filters,
|
|
68
71
|
setAllFilters: setAllFilters,
|
|
69
72
|
variation: _constants.FLYOUT,
|
|
70
|
-
|
|
71
|
-
onCancel: onCancel
|
|
73
|
+
initialFilters: initialFiltersRef.current
|
|
72
74
|
}),
|
|
73
75
|
filtersState = _useFilters.filtersState,
|
|
74
76
|
prevFiltersObjectArrayRef = _useFilters.prevFiltersObjectArrayRef,
|
|
75
77
|
prevFiltersRef = _useFilters.prevFiltersRef,
|
|
76
|
-
|
|
78
|
+
revertToPreviousFilters = _useFilters.revertToPreviousFilters,
|
|
77
79
|
reset = _useFilters.reset,
|
|
78
80
|
renderFilter = _useFilters.renderFilter,
|
|
79
|
-
filtersObjectArray = _useFilters.filtersObjectArray
|
|
80
|
-
lastAppliedFilters = _useFilters.lastAppliedFilters;
|
|
81
|
+
filtersObjectArray = _useFilters.filtersObjectArray;
|
|
81
82
|
|
|
82
83
|
/** Refs */
|
|
83
84
|
var filterFlyoutRef = (0, _react2.useRef)(null);
|
|
@@ -116,10 +117,26 @@ var FilterFlyout = function FilterFlyout(_ref) {
|
|
|
116
117
|
// updates the ref so next time the flyout opens we have records of the previous filters
|
|
117
118
|
prevFiltersRef.current = JSON.stringify(filtersState);
|
|
118
119
|
prevFiltersObjectArrayRef.current = JSON.stringify(filtersObjectArray);
|
|
119
|
-
|
|
120
|
-
// Update the last applied filters
|
|
121
|
-
lastAppliedFilters.current = JSON.stringify(filtersObjectArray);
|
|
122
120
|
};
|
|
121
|
+
var cancel = function cancel() {
|
|
122
|
+
// Reverting to previous filters only applies when using batch actions
|
|
123
|
+
if (updateMethod === _constants.BATCH) {
|
|
124
|
+
revertToPreviousFilters();
|
|
125
|
+
onCancel();
|
|
126
|
+
}
|
|
127
|
+
closeFlyout();
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
/** Effects */
|
|
131
|
+
(0, _hooks.useClickOutside)(filterFlyoutRef, function (target) {
|
|
132
|
+
var hasClickedOnDatePicker = target.closest('.flatpickr-calendar');
|
|
133
|
+
var hasClickedOnDropdown = target.className === "".concat(carbonPrefix, "--list-box__menu-item__option");
|
|
134
|
+
if (!open || hasClickedOnDatePicker || hasClickedOnDropdown) {
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
cancel();
|
|
138
|
+
});
|
|
139
|
+
(0, _hooks2.useSubscribeToEventEmitter)(_constants.CLEAR_FILTERS, reset);
|
|
123
140
|
|
|
124
141
|
/** Renders all filters */
|
|
125
142
|
var renderFilters = function renderFilters() {
|
|
@@ -146,31 +163,22 @@ var FilterFlyout = function FilterFlyout(_ref) {
|
|
|
146
163
|
buttonSize: "md"
|
|
147
164
|
});
|
|
148
165
|
};
|
|
149
|
-
|
|
150
|
-
/** Effects */
|
|
151
|
-
(0, _hooks.useClickOutside)(filterFlyoutRef, function (target) {
|
|
152
|
-
var hasClickedOnDatePicker = target.closest('.flatpickr-calendar');
|
|
153
|
-
var hasClickedOnDropdown = target.className === "".concat(carbonPrefix, "--list-box__menu-item__option");
|
|
154
|
-
if (!open || hasClickedOnDatePicker || hasClickedOnDropdown) {
|
|
155
|
-
return;
|
|
156
|
-
}
|
|
157
|
-
closeFlyout();
|
|
158
|
-
cancel();
|
|
159
|
-
});
|
|
160
|
-
(0, _hooks2.useSubscribeToEventEmitter)(_constants.CLEAR_FILTERS, reset);
|
|
161
|
-
(0, _react2.useEffect)(function reflectLastAppliedFiltersWhenReactTableUpdates() {
|
|
162
|
-
lastAppliedFilters.current = JSON.stringify(reactTableFiltersState);
|
|
163
|
-
}, [reactTableFiltersState, lastAppliedFilters]);
|
|
164
166
|
return /*#__PURE__*/_react2.default.createElement("div", {
|
|
165
167
|
className: "".concat(componentClass, "__container")
|
|
166
|
-
}, /*#__PURE__*/_react2.default.createElement(_react.
|
|
167
|
-
label: flyoutIconDescription,
|
|
168
|
+
}, /*#__PURE__*/_react2.default.createElement(_react.Button, {
|
|
168
169
|
kind: "ghost",
|
|
169
|
-
|
|
170
|
+
hasIconOnly: true,
|
|
171
|
+
tooltipPosition: "bottom",
|
|
172
|
+
renderIcon: function renderIcon() {
|
|
173
|
+
return /*#__PURE__*/_react2.default.createElement(_icons.Filter, {
|
|
174
|
+
size: 16
|
|
175
|
+
});
|
|
176
|
+
},
|
|
177
|
+
iconDescription: flyoutIconDescription,
|
|
170
178
|
onClick: open ? closeFlyout : openFlyout,
|
|
171
179
|
className: (0, _classnames.default)("".concat(componentClass, "__trigger"), (0, _defineProperty2.default)({}, "".concat(componentClass, "__trigger--open"), open)),
|
|
172
180
|
disabled: data.length === 0
|
|
173
|
-
}
|
|
181
|
+
}), /*#__PURE__*/_react2.default.createElement("div", {
|
|
174
182
|
ref: filterFlyoutRef,
|
|
175
183
|
className: (0, _classnames.default)(componentClass, (_cx2 = {}, (0, _defineProperty2.default)(_cx2, "".concat(componentClass, "--open"), open), (0, _defineProperty2.default)(_cx2, "".concat(componentClass, "--batch"), showActionSet), (0, _defineProperty2.default)(_cx2, "".concat(componentClass, "--instant"), !showActionSet), _cx2))
|
|
176
184
|
}, /*#__PURE__*/_react2.default.createElement("div", {
|
|
@@ -198,6 +206,14 @@ FilterFlyout.propTypes = {
|
|
|
198
206
|
* Icon description for the filter flyout button
|
|
199
207
|
*/
|
|
200
208
|
flyoutIconDescription: _propTypes.default.string,
|
|
209
|
+
/**
|
|
210
|
+
* Filters that should be applied on load
|
|
211
|
+
*/
|
|
212
|
+
initialFilters: _propTypes.default.arrayOf(_propTypes.default.shape({
|
|
213
|
+
id: _propTypes.default.string.isRequired,
|
|
214
|
+
type: _propTypes.default.string.isRequired,
|
|
215
|
+
value: _propTypes.default.any.isRequired
|
|
216
|
+
})),
|
|
201
217
|
/**
|
|
202
218
|
* Callback when the apply button is clicked
|
|
203
219
|
*/
|
|
@@ -218,14 +234,6 @@ FilterFlyout.propTypes = {
|
|
|
218
234
|
* Label text of the primary action in the flyout
|
|
219
235
|
*/
|
|
220
236
|
primaryActionLabel: _propTypes.default.string,
|
|
221
|
-
/**
|
|
222
|
-
* Filters from react table's state
|
|
223
|
-
*/
|
|
224
|
-
reactTableFiltersState: _propTypes.default.arrayOf(_propTypes.default.shape({
|
|
225
|
-
id: _propTypes.default.string.isRequired,
|
|
226
|
-
type: _propTypes.default.string.isRequired,
|
|
227
|
-
value: _propTypes.default.any.isRequired
|
|
228
|
-
})),
|
|
229
237
|
/**
|
|
230
238
|
* Label text of the secondary action in the flyout
|
|
231
239
|
*/
|
|
@@ -66,8 +66,11 @@ var FilterPanel = function FilterPanel(_ref) {
|
|
|
66
66
|
searchLabelText = _ref$searchLabelText === void 0 ? 'Filter search' : _ref$searchLabelText,
|
|
67
67
|
_ref$searchPlaceholde = _ref.searchPlaceholder,
|
|
68
68
|
searchPlaceholder = _ref$searchPlaceholde === void 0 ? 'Find filters' : _ref$searchPlaceholde,
|
|
69
|
-
_ref$
|
|
70
|
-
|
|
69
|
+
_ref$initialFilters = _ref.initialFilters,
|
|
70
|
+
initialFilters = _ref$initialFilters === void 0 ? [] : _ref$initialFilters;
|
|
71
|
+
// Save the initial filters we only need the filters once
|
|
72
|
+
var initialFiltersRef = (0, _react.useRef)(initialFilters);
|
|
73
|
+
|
|
71
74
|
/** State */
|
|
72
75
|
var _useState = (0, _react.useState)(false),
|
|
73
76
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
@@ -78,17 +81,15 @@ var FilterPanel = function FilterPanel(_ref) {
|
|
|
78
81
|
filters: filterSections,
|
|
79
82
|
setAllFilters: setAllFilters,
|
|
80
83
|
variation: _constants.PANEL,
|
|
81
|
-
|
|
82
|
-
onCancel: onCancel
|
|
84
|
+
initialFilters: initialFiltersRef.current
|
|
83
85
|
}),
|
|
84
86
|
filtersState = _useFilters.filtersState,
|
|
85
87
|
prevFiltersObjectArrayRef = _useFilters.prevFiltersObjectArrayRef,
|
|
86
88
|
prevFiltersRef = _useFilters.prevFiltersRef,
|
|
87
|
-
|
|
89
|
+
revertToPreviousFilters = _useFilters.revertToPreviousFilters,
|
|
88
90
|
reset = _useFilters.reset,
|
|
89
91
|
renderFilter = _useFilters.renderFilter,
|
|
90
|
-
filtersObjectArray = _useFilters.filtersObjectArray
|
|
91
|
-
lastAppliedFilters = _useFilters.lastAppliedFilters;
|
|
92
|
+
filtersObjectArray = _useFilters.filtersObjectArray;
|
|
92
93
|
|
|
93
94
|
/** Refs */
|
|
94
95
|
var filterPanelRef = (0, _react.useRef)();
|
|
@@ -118,8 +119,14 @@ var FilterPanel = function FilterPanel(_ref) {
|
|
|
118
119
|
|
|
119
120
|
/** Methods */
|
|
120
121
|
var closePanel = function closePanel() {
|
|
121
|
-
|
|
122
|
-
|
|
122
|
+
return setPanelOpen(false);
|
|
123
|
+
};
|
|
124
|
+
var cancel = function cancel() {
|
|
125
|
+
// Reverting to previous filters only applies when using batch actions
|
|
126
|
+
if (updateMethod === _constants.BATCH) {
|
|
127
|
+
revertToPreviousFilters();
|
|
128
|
+
onCancel();
|
|
129
|
+
}
|
|
123
130
|
};
|
|
124
131
|
var apply = function apply() {
|
|
125
132
|
setAllFilters(filtersObjectArray);
|
|
@@ -131,9 +138,6 @@ var FilterPanel = function FilterPanel(_ref) {
|
|
|
131
138
|
// updates the ref so next time the flyout opens we have records of the previous filters
|
|
132
139
|
prevFiltersRef.current = JSON.stringify(filtersState);
|
|
133
140
|
prevFiltersObjectArrayRef.current = JSON.stringify(filtersObjectArray);
|
|
134
|
-
|
|
135
|
-
// Update the last applied filters
|
|
136
|
-
lastAppliedFilters.current = JSON.stringify(filtersObjectArray);
|
|
137
141
|
};
|
|
138
142
|
var renderActionSet = function renderActionSet() {
|
|
139
143
|
return showActionSet && /*#__PURE__*/_react.default.createElement(MotionActionSet, {
|
|
@@ -250,20 +254,20 @@ FilterPanel.propTypes = {
|
|
|
250
254
|
closeIconDescription: _propTypes.default.string,
|
|
251
255
|
filterPanelMinHeight: _propTypes.default.number,
|
|
252
256
|
filterSections: _propTypes.default.array,
|
|
253
|
-
onApply: _propTypes.default.func,
|
|
254
|
-
onCancel: _propTypes.default.func,
|
|
255
|
-
onPanelClose: _propTypes.default.func,
|
|
256
|
-
onPanelOpen: _propTypes.default.func,
|
|
257
|
-
open: _propTypes.default.bool,
|
|
258
|
-
primaryActionLabel: _propTypes.default.string,
|
|
259
257
|
/**
|
|
260
|
-
* Filters
|
|
258
|
+
* Filters that should be applied on load
|
|
261
259
|
*/
|
|
262
|
-
|
|
260
|
+
initialFilters: _propTypes.default.arrayOf(_propTypes.default.shape({
|
|
263
261
|
id: _propTypes.default.string.isRequired,
|
|
264
262
|
type: _propTypes.default.string.isRequired,
|
|
265
263
|
value: _propTypes.default.any.isRequired
|
|
266
264
|
})),
|
|
265
|
+
onApply: _propTypes.default.func,
|
|
266
|
+
onCancel: _propTypes.default.func,
|
|
267
|
+
onPanelClose: _propTypes.default.func,
|
|
268
|
+
onPanelOpen: _propTypes.default.func,
|
|
269
|
+
open: _propTypes.default.bool,
|
|
270
|
+
primaryActionLabel: _propTypes.default.string,
|
|
267
271
|
searchLabelText: _propTypes.default.string,
|
|
268
272
|
searchPlaceholder: _propTypes.default.string,
|
|
269
273
|
secondaryActionLabel: _propTypes.default.string,
|
|
@@ -10,6 +10,12 @@ Object.defineProperty(exports, "useFilters", {
|
|
|
10
10
|
return _useFilters.default;
|
|
11
11
|
}
|
|
12
12
|
});
|
|
13
|
+
Object.defineProperty(exports, "useInitialStateFromFilters", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function get() {
|
|
16
|
+
return _useInitialStateFromFilters.default;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
13
19
|
Object.defineProperty(exports, "useShouldDisableButtons", {
|
|
14
20
|
enumerable: true,
|
|
15
21
|
get: function get() {
|
|
@@ -22,6 +28,7 @@ Object.defineProperty(exports, "useSubscribeToEventEmitter", {
|
|
|
22
28
|
return _useSubscribeToEventEmitter.default;
|
|
23
29
|
}
|
|
24
30
|
});
|
|
31
|
+
var _useInitialStateFromFilters = _interopRequireDefault(require("./useInitialStateFromFilters"));
|
|
25
32
|
var _useSubscribeToEventEmitter = _interopRequireDefault(require("./useSubscribeToEventEmitter"));
|
|
26
33
|
var _useFilters = _interopRequireDefault(require("./useFilters"));
|
|
27
34
|
var _useShouldDisableButtons = _interopRequireDefault(require("./useShouldDisableButtons"));
|
|
@@ -13,6 +13,7 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/sli
|
|
|
13
13
|
var _react = _interopRequireWildcard(require("react"));
|
|
14
14
|
var _react2 = require("@carbon/react");
|
|
15
15
|
var _constants = require("../constants");
|
|
16
|
+
var _useInitialStateFromFilters = _interopRequireDefault(require("./useInitialStateFromFilters"));
|
|
16
17
|
var _utils = require("../utils");
|
|
17
18
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
18
19
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -30,22 +31,19 @@ var useFilters = function useFilters(_ref) {
|
|
|
30
31
|
filters = _ref$filters === void 0 ? [] : _ref$filters,
|
|
31
32
|
setAllFilters = _ref.setAllFilters,
|
|
32
33
|
variation = _ref.variation,
|
|
33
|
-
|
|
34
|
-
_ref$onCancel = _ref.onCancel,
|
|
35
|
-
onCancel = _ref$onCancel === void 0 ? function () {} : _ref$onCancel;
|
|
34
|
+
initialFilters = _ref.initialFilters;
|
|
36
35
|
/** State */
|
|
37
|
-
var
|
|
36
|
+
var _useInitialStateFromF = (0, _useInitialStateFromFilters.default)(filters, variation, initialFilters),
|
|
37
|
+
_useInitialStateFromF2 = (0, _slicedToArray2.default)(_useInitialStateFromF, 2),
|
|
38
|
+
filtersState = _useInitialStateFromF2[0],
|
|
39
|
+
setFiltersState = _useInitialStateFromF2[1];
|
|
40
|
+
var _useState = (0, _react.useState)(initialFilters),
|
|
38
41
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
var _useState3 = (0, _react.useState)(reactTableFiltersState),
|
|
42
|
-
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
43
|
-
filtersObjectArray = _useState4[0],
|
|
44
|
-
setFiltersObjectArray = _useState4[1];
|
|
42
|
+
filtersObjectArray = _useState2[0],
|
|
43
|
+
setFiltersObjectArray = _useState2[1];
|
|
45
44
|
|
|
46
45
|
// When using batch actions we have to store the filters to then apply them later
|
|
47
46
|
var prevFiltersRef = (0, _react.useRef)(JSON.stringify(filtersState));
|
|
48
|
-
var lastAppliedFilters = (0, _react.useRef)(JSON.stringify(reactTableFiltersState));
|
|
49
47
|
var prevFiltersObjectArrayRef = (0, _react.useRef)(JSON.stringify(filtersObjectArray));
|
|
50
48
|
|
|
51
49
|
/** Methods */
|
|
@@ -54,7 +52,6 @@ var useFilters = function useFilters(_ref) {
|
|
|
54
52
|
var revertToPreviousFilters = function revertToPreviousFilters() {
|
|
55
53
|
setFiltersState(JSON.parse(prevFiltersRef.current));
|
|
56
54
|
setFiltersObjectArray(JSON.parse(prevFiltersObjectArrayRef.current));
|
|
57
|
-
setAllFilters(JSON.parse(lastAppliedFilters.current));
|
|
58
55
|
};
|
|
59
56
|
var reset = function reset() {
|
|
60
57
|
// When we reset we want the "initialFilters" to be an empty array
|
|
@@ -166,11 +163,8 @@ var useFilters = function useFilters(_ref) {
|
|
|
166
163
|
var type = _ref3.type,
|
|
167
164
|
column = _ref3.column,
|
|
168
165
|
components = _ref3.props;
|
|
169
|
-
var filter;
|
|
170
166
|
var isPanel = variation === _constants.PANEL;
|
|
171
|
-
|
|
172
|
-
return console.error("type: ".concat(type, "; does not exist as a type of filter."));
|
|
173
|
-
}
|
|
167
|
+
var filter;
|
|
174
168
|
switch (type) {
|
|
175
169
|
case _constants.DATE:
|
|
176
170
|
filter = /*#__PURE__*/_react.default.createElement(_react2.DatePicker, (0, _extends2.default)({}, components.DatePicker, {
|
|
@@ -296,31 +290,10 @@ var useFilters = function useFilters(_ref) {
|
|
|
296
290
|
break;
|
|
297
291
|
}
|
|
298
292
|
if (isPanel) {
|
|
299
|
-
return /*#__PURE__*/_react.default.createElement(_react2.Layer,
|
|
300
|
-
key: column
|
|
301
|
-
}, filter);
|
|
293
|
+
return /*#__PURE__*/_react.default.createElement(_react2.Layer, null, filter);
|
|
302
294
|
}
|
|
303
|
-
return
|
|
304
|
-
key: column
|
|
305
|
-
}, filter);
|
|
295
|
+
return filter;
|
|
306
296
|
};
|
|
307
|
-
var cancel = function cancel() {
|
|
308
|
-
// Reverting to previous filters only applies when using batch actions
|
|
309
|
-
if (updateMethod === _constants.BATCH) {
|
|
310
|
-
revertToPreviousFilters();
|
|
311
|
-
onCancel();
|
|
312
|
-
}
|
|
313
|
-
};
|
|
314
|
-
|
|
315
|
-
/** The purpose of this function is to sync any changes in react-tables state.filters array and reflect
|
|
316
|
-
those new filter changes in the panel/flyout state. The external change is triggered if setAllFilters is called outside of the Datagrid */
|
|
317
|
-
(0, _react.useEffect)(function updateStateAndFiltersToReflectExternalFilterChanges() {
|
|
318
|
-
var newFiltersState = (0, _utils.getInitialStateFromFilters)(filters, variation, reactTableFiltersState);
|
|
319
|
-
setFiltersState(newFiltersState);
|
|
320
|
-
prevFiltersRef.current = JSON.stringify(newFiltersState);
|
|
321
|
-
prevFiltersObjectArrayRef.current = JSON.stringify(reactTableFiltersState);
|
|
322
|
-
setFiltersObjectArray(reactTableFiltersState);
|
|
323
|
-
}, [filters, reactTableFiltersState, variation]);
|
|
324
297
|
return {
|
|
325
298
|
filtersState: filtersState,
|
|
326
299
|
setFiltersState: setFiltersState,
|
|
@@ -329,9 +302,7 @@ var useFilters = function useFilters(_ref) {
|
|
|
329
302
|
revertToPreviousFilters: revertToPreviousFilters,
|
|
330
303
|
reset: reset,
|
|
331
304
|
renderFilter: renderFilter,
|
|
332
|
-
filtersObjectArray: filtersObjectArray
|
|
333
|
-
lastAppliedFilters: lastAppliedFilters,
|
|
334
|
-
cancel: cancel
|
|
305
|
+
filtersObjectArray: filtersObjectArray
|
|
335
306
|
};
|
|
336
307
|
};
|
|
337
308
|
var _default = useFilters;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
9
|
+
var _react = require("react");
|
|
10
|
+
var _constants = require("../constants");
|
|
11
|
+
var _utils = require("../utils");
|
|
12
|
+
/*
|
|
13
|
+
* Licensed Materials - Property of IBM
|
|
14
|
+
* 5724-Q36
|
|
15
|
+
* (c) Copyright IBM Corp. 2022
|
|
16
|
+
* US Government Users Restricted Rights - Use, duplication or disclosure
|
|
17
|
+
* restricted by GSA ADP Schedule Contract with IBM Corp.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
var useInitialStateFromFilters = function useInitialStateFromFilters(filters) {
|
|
21
|
+
var variation = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _constants.FLYOUT;
|
|
22
|
+
var initialFilters = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
23
|
+
var _useState = (0, _react.useState)((0, _utils.getInitialStateFromFilters)(filters, variation, initialFilters)),
|
|
24
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
25
|
+
state = _useState2[0],
|
|
26
|
+
setState = _useState2[1];
|
|
27
|
+
return [state, setState];
|
|
28
|
+
};
|
|
29
|
+
var _default = useInitialStateFromFilters;
|
|
30
|
+
exports.default = _default;
|
|
@@ -24,7 +24,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
24
24
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof3(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
25
25
|
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; }
|
|
26
26
|
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) { (0, _defineProperty2.default)(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; } /**
|
|
27
|
-
* Copyright IBM Corp. 2022,
|
|
27
|
+
* Copyright IBM Corp. 2022, 2022
|
|
28
28
|
*
|
|
29
29
|
* This source code is licensed under the Apache-2.0 license found in the
|
|
30
30
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -39,8 +39,7 @@ var InlineEditCell = function InlineEditCell(_ref) {
|
|
|
39
39
|
placeholder = _ref$placeholder === void 0 ? '' : _ref$placeholder,
|
|
40
40
|
tabIndex = _ref.tabIndex,
|
|
41
41
|
value = _ref.value,
|
|
42
|
-
|
|
43
|
-
nonEditCell = _ref$nonEditCell === void 0 ? false : _ref$nonEditCell,
|
|
42
|
+
nonEditCell = _ref.nonEditCell,
|
|
44
43
|
totalInlineEditColumns = _ref.totalInlineEditColumns,
|
|
45
44
|
type = _ref.type;
|
|
46
45
|
var columnId = cell.column.id;
|
|
@@ -81,9 +80,6 @@ var InlineEditCell = function InlineEditCell(_ref) {
|
|
|
81
80
|
var dropdownRef = (0, _react.useRef)();
|
|
82
81
|
var datePickerRef = (0, _react.useRef)();
|
|
83
82
|
var outerButtonElement = (0, _react.useRef)();
|
|
84
|
-
var rowSize = instance.rowSize,
|
|
85
|
-
onDataUpdate = instance.onDataUpdate;
|
|
86
|
-
var saveCellData;
|
|
87
83
|
(0, _react.useEffect)(function () {
|
|
88
84
|
setInitialValue(value);
|
|
89
85
|
var columnId = cell.column.id;
|
|
@@ -157,6 +153,8 @@ var InlineEditCell = function InlineEditCell(_ref) {
|
|
|
157
153
|
}, 1);
|
|
158
154
|
}
|
|
159
155
|
};
|
|
156
|
+
var rowSize = instance.rowSize,
|
|
157
|
+
onDataUpdate = instance.onDataUpdate;
|
|
160
158
|
|
|
161
159
|
// Auto focus text input when entering edit mode
|
|
162
160
|
(0, _react.useEffect)(function () {
|
|
@@ -170,9 +168,14 @@ var InlineEditCell = function InlineEditCell(_ref) {
|
|
|
170
168
|
}
|
|
171
169
|
}, [inEditMode, type]);
|
|
172
170
|
|
|
171
|
+
// Initialize cellValue from value prop
|
|
172
|
+
(0, _react.useEffect)(function () {
|
|
173
|
+
setCellValue(value);
|
|
174
|
+
}, [value]);
|
|
175
|
+
|
|
173
176
|
// Saves the new cell data, onDataUpdate is a required function to be
|
|
174
177
|
// passed to useDatagrid when using useInlineEdit
|
|
175
|
-
saveCellData = (0, _react.useCallback)(function (newValue) {
|
|
178
|
+
var saveCellData = (0, _react.useCallback)(function (newValue) {
|
|
176
179
|
var columnId = cell.column.id;
|
|
177
180
|
var rowIndex = cell.row.index;
|
|
178
181
|
onDataUpdate(function (prev) {
|
|
@@ -184,11 +187,6 @@ var InlineEditCell = function InlineEditCell(_ref) {
|
|
|
184
187
|
});
|
|
185
188
|
});
|
|
186
189
|
}, [cell, onDataUpdate]);
|
|
187
|
-
|
|
188
|
-
// Initialize cellValue from value prop
|
|
189
|
-
(0, _react.useEffect)(function () {
|
|
190
|
-
setCellValue(value);
|
|
191
|
-
}, [value]);
|
|
192
190
|
var sendFocusBackToGrid = function sendFocusBackToGrid() {
|
|
193
191
|
// Allows the onKeyDown listener to go back to the entire grid area
|
|
194
192
|
var inlineEditArea = document.querySelector("#".concat(instance.tableId, " .").concat(blockClass, "__table-with-inline-edit"));
|