@carbon/ibm-products 2.2.0 → 2.3.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 +965 -434
- package/css/index-full-carbon.css.map +1 -1
- package/css/index-full-carbon.min.css +4 -4
- package/css/index-full-carbon.min.css.map +1 -1
- package/css/index-without-carbon-released-only.css +354 -155
- 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 +600 -236
- package/css/index-without-carbon.css.map +1 -1
- package/css/index-without-carbon.min.css +4 -4
- package/css/index-without-carbon.min.css.map +1 -1
- package/css/index.css +516 -293
- package/css/index.css.map +1 -1
- package/css/index.min.css +4 -4
- package/css/index.min.css.map +1 -1
- package/es/components/APIKeyModal/APIKeyModal.docs-page.js +26 -0
- package/es/components/AboutModal/AboutModal.docs-page.js +21 -0
- package/es/components/AboutModal/AboutModal.js +2 -4
- package/es/components/ActionBar/ActionBar.js +2 -6
- package/es/components/AddSelect/AddSelectFormControl.js +6 -6
- package/es/components/AddSelect/AddSelectRow.js +15 -5
- package/es/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.js +5 -6
- package/es/components/ButtonMenu/ButtonMenu.js +4 -4
- package/es/components/ButtonSetWithOverflow/ButtonSetWithOverflow.js +3 -9
- package/es/components/Cascade/Cascade.docs-page.js +22 -0
- package/es/components/Cascade/Cascade.js +11 -1
- package/es/components/CreateFullPage/CreateFullPage.docs-page.js +39 -0
- package/es/components/CreateFullPage/CreateFullPage.js +13 -0
- package/es/components/CreateModal/CreateModal.docs-page.js +24 -0
- package/es/components/CreateModal/CreateModal.js +7 -0
- package/es/components/CreateSidePanel/CreateSidePanel.docs-page.js +18 -0
- package/es/components/CreateSidePanel/CreateSidePanel.js +1 -1
- package/es/components/CreateTearsheet/CreateTearsheet.docs-page.js +29 -0
- 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 +25 -10
- package/es/components/Datagrid/Datagrid/DatagridVirtualBody.js +1 -3
- package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/TearsheetWrapper.js +1 -1
- package/es/components/Datagrid/Datagrid/addons/Filtering/FilterFlyout.js +39 -47
- package/es/components/Datagrid/Datagrid/addons/Filtering/FilterPanel.js +20 -24
- package/es/components/Datagrid/Datagrid/addons/Filtering/hooks/index.js +2 -2
- package/es/components/Datagrid/Datagrid/addons/Filtering/hooks/useFilterContext.js +13 -0
- package/es/components/Datagrid/Datagrid/addons/Filtering/hooks/useFilters.js +44 -15
- package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditCell/InlineEditCell.js +16 -30
- package/es/components/Datagrid/Datagrid/addons/InlineEdit/handleGridKeyPress.js +2 -2
- package/es/components/Datagrid/index.js +2 -1
- package/es/components/Datagrid/useActionsColumn.js +10 -7
- package/es/components/Datagrid/useCustomizeColumns.js +9 -7
- package/es/components/Datagrid/useExpandedRow.js +11 -7
- package/es/components/Datagrid/useFiltering.js +12 -8
- package/es/components/Datagrid/useInlineEdit.js +3 -0
- package/es/components/Datagrid/useNestedRows.js +10 -6
- package/es/components/Datagrid/useStickyColumn.js +10 -3
- package/es/components/Datagrid/utils/DatagridActions.js +12 -20
- package/es/components/EditFullPage/EditFullPage.docs-page.js +39 -0
- package/es/components/EditFullPage/EditFullPage.js +2 -1
- package/es/components/EditSidePanel/EditSidePanel.js +1 -1
- package/es/components/EditTearsheet/EditTearsheet.docs-page.js +25 -0
- package/es/components/EditTearsheet/EditTearsheet.js +4 -0
- package/es/components/EditTearsheetNarrow/EditTearsheetNarrow.js +1 -1
- package/es/components/EditUpdateCards/EditUpdateCards.js +3 -2
- package/es/components/EmptyStates/EmptyState.js +4 -0
- package/es/components/EmptyStates/ErrorEmptyState/ErrorEmptyState.js +4 -0
- package/es/components/EmptyStates/NoDataEmptyState/NoDataEmptyState.js +4 -0
- package/es/components/EmptyStates/NoTagsEmptyState/NoTagsEmptyState.js +4 -0
- package/es/components/EmptyStates/NotFoundEmptyState/NotFoundEmptyState.js +4 -0
- package/es/components/EmptyStates/NotificationsEmptyState/NotificationsEmptyState.js +4 -0
- package/es/components/EmptyStates/UnauthorizedEmptyState/UnauthorizedEmptyState.js +4 -0
- package/es/components/ExampleComponent/ExampleComponent.docs-page.js +22 -0
- package/es/components/ExportModal/ExportModal.js +4 -0
- package/es/components/HTTPErrors/HTTPError403/HTTPError403.js +6 -0
- package/es/components/HTTPErrors/HTTPError404/HTTPError404.js +6 -0
- package/es/components/HTTPErrors/HTTPErrorOther/HTTPErrorOther.js +6 -0
- package/es/components/ImportModal/ImportModal.docs-page.js +18 -0
- package/es/components/ImportModal/ImportModal.js +13 -6
- package/es/components/MultiAddSelect/MultiAddSelect.docs-page.js +17 -0
- package/es/components/MultiAddSelect/MultiAddSelect.js +4 -0
- package/es/components/NotificationsPanel/preview-components/UnreadNotificationBell.js +2 -17
- package/es/components/PageHeader/PageHeader.js +2 -6
- package/es/components/PageHeader/PageHeaderUtils.js +2 -2
- package/es/components/RemoveModal/RemoveModal.docs-page.js +18 -0
- package/es/components/RemoveModal/RemoveModal.js +6 -0
- package/es/components/SidePanel/SidePanel.js +1 -3
- package/es/components/SingleAddSelect/SingleAddSelect.docs-page.js +15 -0
- package/es/components/SingleAddSelect/SingleAddSelect.js +4 -0
- package/es/components/StatusIcon/StatusIcon.docs-page.js +17 -0
- package/es/components/StatusIcon/StatusIcon.js +10 -0
- package/es/components/TagSet/TagSet.js +4 -7
- package/es/components/Tearsheet/TearsheetShell.js +11 -6
- package/es/components/Toolbar/Toolbar.docs-page.js +14 -0
- package/es/components/UserProfileImage/UserProfileImage.docs-page.js +17 -0
- package/es/components/UserProfileImage/UserProfileImage.js +14 -3
- package/es/components/WebTerminal/WebTerminal.docs-page.js +52 -0
- package/es/components/WebTerminal/WebTerminal.js +4 -0
- package/es/components/index.js +1 -1
- package/es/global/js/hooks/useCreateComponentStepChange.js +16 -15
- package/es/global/js/hooks/useResizeObserver.js +14 -28
- package/es/global/js/package-settings.js +14 -1
- package/es/global/js/utils/StoryDocsPage.js +218 -0
- package/es/global/js/utils/story-helper.js +108 -6
- package/lib/components/APIKeyModal/APIKeyModal.docs-page.js +37 -0
- package/lib/components/AboutModal/AboutModal.docs-page.js +32 -0
- package/lib/components/AboutModal/AboutModal.js +2 -4
- package/lib/components/ActionBar/ActionBar.js +2 -6
- package/lib/components/AddSelect/AddSelectFormControl.js +6 -6
- package/lib/components/AddSelect/AddSelectRow.js +15 -5
- package/lib/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.js +5 -6
- package/lib/components/ButtonMenu/ButtonMenu.js +4 -4
- package/lib/components/ButtonSetWithOverflow/ButtonSetWithOverflow.js +3 -9
- package/lib/components/Cascade/Cascade.docs-page.js +33 -0
- package/lib/components/Cascade/Cascade.js +11 -1
- package/lib/components/CreateFullPage/CreateFullPage.docs-page.js +50 -0
- package/lib/components/CreateFullPage/CreateFullPage.js +13 -0
- package/lib/components/CreateModal/CreateModal.docs-page.js +35 -0
- package/lib/components/CreateModal/CreateModal.js +7 -0
- package/lib/components/CreateSidePanel/CreateSidePanel.docs-page.js +29 -0
- package/lib/components/CreateSidePanel/CreateSidePanel.js +1 -1
- package/lib/components/CreateTearsheet/CreateTearsheet.docs-page.js +40 -0
- 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 +25 -10
- package/lib/components/Datagrid/Datagrid/DatagridVirtualBody.js +1 -3
- package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/TearsheetWrapper.js +1 -1
- package/lib/components/Datagrid/Datagrid/addons/Filtering/FilterFlyout.js +37 -45
- package/lib/components/Datagrid/Datagrid/addons/Filtering/FilterPanel.js +20 -24
- package/lib/components/Datagrid/Datagrid/addons/Filtering/hooks/index.js +6 -6
- package/lib/components/Datagrid/Datagrid/addons/Filtering/hooks/useFilterContext.js +20 -0
- package/lib/components/Datagrid/Datagrid/addons/Filtering/hooks/useFilters.js +42 -13
- package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditCell/InlineEditCell.js +16 -30
- package/lib/components/Datagrid/Datagrid/addons/InlineEdit/handleGridKeyPress.js +2 -2
- package/lib/components/Datagrid/index.js +8 -1
- package/lib/components/Datagrid/useActionsColumn.js +12 -7
- package/lib/components/Datagrid/useCustomizeColumns.js +10 -8
- package/lib/components/Datagrid/useExpandedRow.js +9 -6
- package/lib/components/Datagrid/useFiltering.js +10 -7
- package/lib/components/Datagrid/useInlineEdit.js +3 -0
- package/lib/components/Datagrid/useNestedRows.js +9 -6
- package/lib/components/Datagrid/useStickyColumn.js +10 -3
- package/lib/components/Datagrid/utils/DatagridActions.js +49 -57
- package/lib/components/EditFullPage/EditFullPage.docs-page.js +50 -0
- package/lib/components/EditFullPage/EditFullPage.js +2 -1
- package/lib/components/EditSidePanel/EditSidePanel.js +1 -1
- package/lib/components/EditTearsheet/EditTearsheet.docs-page.js +36 -0
- package/lib/components/EditTearsheet/EditTearsheet.js +4 -0
- package/lib/components/EditTearsheetNarrow/EditTearsheetNarrow.js +1 -1
- package/lib/components/EditUpdateCards/EditUpdateCards.js +3 -2
- package/lib/components/EmptyStates/EmptyState.js +4 -0
- package/lib/components/EmptyStates/ErrorEmptyState/ErrorEmptyState.js +4 -0
- package/lib/components/EmptyStates/NoDataEmptyState/NoDataEmptyState.js +4 -0
- package/lib/components/EmptyStates/NoTagsEmptyState/NoTagsEmptyState.js +4 -0
- package/lib/components/EmptyStates/NotFoundEmptyState/NotFoundEmptyState.js +4 -0
- package/lib/components/EmptyStates/NotificationsEmptyState/NotificationsEmptyState.js +4 -0
- package/lib/components/EmptyStates/UnauthorizedEmptyState/UnauthorizedEmptyState.js +4 -0
- package/lib/components/ExampleComponent/ExampleComponent.docs-page.js +33 -0
- package/lib/components/ExportModal/ExportModal.js +4 -0
- package/lib/components/HTTPErrors/HTTPError403/HTTPError403.js +6 -0
- package/lib/components/HTTPErrors/HTTPError404/HTTPError404.js +6 -0
- package/lib/components/HTTPErrors/HTTPErrorOther/HTTPErrorOther.js +6 -0
- package/lib/components/ImportModal/ImportModal.docs-page.js +26 -0
- package/lib/components/ImportModal/ImportModal.js +13 -6
- package/lib/components/MultiAddSelect/MultiAddSelect.docs-page.js +25 -0
- package/lib/components/MultiAddSelect/MultiAddSelect.js +4 -0
- package/lib/components/NotificationsPanel/preview-components/UnreadNotificationBell.js +2 -17
- package/lib/components/PageHeader/PageHeader.js +2 -6
- package/lib/components/PageHeader/PageHeaderUtils.js +2 -2
- package/lib/components/RemoveModal/RemoveModal.docs-page.js +26 -0
- package/lib/components/RemoveModal/RemoveModal.js +6 -0
- package/lib/components/SidePanel/SidePanel.js +1 -3
- package/lib/components/SingleAddSelect/SingleAddSelect.docs-page.js +23 -0
- package/lib/components/SingleAddSelect/SingleAddSelect.js +4 -0
- package/lib/components/StatusIcon/StatusIcon.docs-page.js +28 -0
- package/lib/components/StatusIcon/StatusIcon.js +10 -0
- package/lib/components/TagSet/TagSet.js +4 -7
- package/lib/components/Tearsheet/TearsheetShell.js +11 -6
- package/lib/components/Toolbar/Toolbar.docs-page.js +25 -0
- package/lib/components/UserProfileImage/UserProfileImage.docs-page.js +28 -0
- package/lib/components/UserProfileImage/UserProfileImage.js +14 -3
- package/lib/components/WebTerminal/WebTerminal.docs-page.js +63 -0
- package/lib/components/WebTerminal/WebTerminal.js +4 -0
- package/lib/components/index.js +6 -0
- package/lib/global/js/hooks/useCreateComponentStepChange.js +16 -15
- package/lib/global/js/hooks/useResizeObserver.js +13 -27
- package/lib/global/js/package-settings.js +14 -1
- package/lib/global/js/utils/StoryDocsPage.js +225 -0
- package/lib/global/js/utils/story-helper.js +115 -7
- package/package.json +4 -4
- package/scss/components/AddSelect/_add-select.scss +10 -6
- package/scss/components/BreadcrumbWithOverflow/_breadcrumb-with-overflow.scss +0 -1
- package/scss/components/ButtonMenu/_button-menu.scss +32 -1
- package/scss/components/Cascade/_storybook-styles.scss +3 -2
- package/scss/components/CreateFullPage/_create-full-page.scss +3 -3
- package/scss/components/CreateModal/_create-modal.scss +3 -3
- package/scss/components/CreateSidePanel/_create-side-panel.scss +4 -4
- package/scss/components/CreateTearsheet/_create-tearsheet.scss +2 -2
- package/scss/components/CreateTearsheet/_storybook-styles.scss +1 -1
- package/scss/components/CreateTearsheetNarrow/_create-tearsheet-narrow.scss +2 -2
- package/scss/components/DataSpreadsheet/_data-spreadsheet.scss +5 -5
- package/scss/components/DataSpreadsheet/_storybook-styles.scss +6 -0
- package/scss/components/Datagrid/_datagrid.scss +4 -2
- package/scss/components/Datagrid/_storybook-styles.scss +18 -4
- package/scss/components/Datagrid/styles/_datagrid.scss +26 -13
- package/scss/components/Datagrid/styles/addons/_FilterFlyout.scss +7 -0
- package/scss/components/Datagrid/styles/addons/_FilterPanel.scss +4 -0
- package/scss/components/EditSidePanel/_edit-side-panel.scss +2 -2
- package/scss/components/EditTearsheet/_edit-tearsheet.scss +2 -2
- package/scss/components/EditTearsheet/_storybook-styles.scss +1 -1
- package/scss/components/ImportModal/_import-modal.scss +1 -1
- package/scss/components/NotificationsPanel/_notifications-panel.scss +3 -3
- package/scss/components/NotificationsPanel/_storybook-styles.scss +10 -2
- package/scss/components/OptionsTile/_storybook-styles.scss +1 -1
- package/scss/components/PageHeader/_page-header.scss +4 -5
- package/scss/components/PageHeader/_storybook-styles.scss +24 -14
- package/scss/components/Saving/_saving.scss +1 -1
- package/scss/components/SidePanel/_side-panel.scss +3 -5
- package/scss/components/TagSet/_tag-set.scss +1 -1
- package/scss/components/Tearsheet/_tearsheet.scss +9 -8
- package/scss/components/UserProfileImage/_user-profile-image.scss +2 -2
- package/scss/components/WebTerminal/_storybook-styles.scss +11 -1
- package/scss/global/styles/_display-box.scss +1 -0
- package/es/components/Datagrid/Datagrid/addons/Filtering/hooks/useInitialStateFromFilters.js +0 -21
- package/lib/components/Datagrid/Datagrid/addons/Filtering/hooks/useInitialStateFromFilters.js +0 -30
- package/scss/components/HTTPErrors/_storybook-styles.scss +0 -6
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
var _react = _interopRequireDefault(require("react"));
|
|
10
|
+
var _StoryDocsPage = require("../../global/js/utils/StoryDocsPage");
|
|
11
|
+
var stories = _interopRequireWildcard(require("./CreateSidePanel.stories"));
|
|
12
|
+
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); }
|
|
13
|
+
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; }
|
|
14
|
+
var DocsPage = function DocsPage() {
|
|
15
|
+
return /*#__PURE__*/_react.default.createElement(_StoryDocsPage.StoryDocsPage, {
|
|
16
|
+
altGuidelinesHref: [{
|
|
17
|
+
href: 'https://pages.github.ibm.com/cdai-design/pal/patterns/creation-flows/usage#side-panel',
|
|
18
|
+
label: 'Carbon create flows side panel usage guidelines'
|
|
19
|
+
}],
|
|
20
|
+
blocks: [{
|
|
21
|
+
story: stories.Default
|
|
22
|
+
}, {
|
|
23
|
+
title: 'Form validation',
|
|
24
|
+
description: "All forms, including that within the `CreateSidePanel` should follow C&CS\nguidelines for form validation.\n\nThis includes the following:\n\n- The `Submit` button in the side panel should be disabled, until all required\n inputs are filled in and valid\n- All required inputs should _only_ throw an invalid error _after_ the element\n loses focus\n- All optional form fields should have an `(optional)` text at the end of the\n input `labelText`. Optional should always be in parentheses\n\nYou can find more information on how to validate your form fields in\n[Carbon's Form usage page](https://www.carbondesignsystem.com/components/form/usage)."
|
|
25
|
+
}]
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
var _default = DocsPage;
|
|
29
|
+
exports.default = _default;
|
|
@@ -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
|
+
* Use with medium complexity creations if the user needs page context. On-page content can be seen and interacted with.
|
|
38
38
|
*/
|
|
39
39
|
var CreateSidePanel = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
|
|
40
40
|
var className = _ref.className,
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
var _react = _interopRequireDefault(require("react"));
|
|
10
|
+
var _StoryDocsPage = require("../../global/js/utils/StoryDocsPage");
|
|
11
|
+
var stories = _interopRequireWildcard(require("./CreateTearsheet.stories"));
|
|
12
|
+
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); }
|
|
13
|
+
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; }
|
|
14
|
+
var DocsPage = function DocsPage() {
|
|
15
|
+
return /*#__PURE__*/_react.default.createElement(_StoryDocsPage.StoryDocsPage, {
|
|
16
|
+
altGuidelinesHref: "https://pages.github.ibm.com/cdai-design/pal/patterns/creation-flows/usage#wide-tearsheet",
|
|
17
|
+
blocks: [{
|
|
18
|
+
story: stories.multiStepTearsheet,
|
|
19
|
+
description: "This is used when you have one section per step. This can be created by passing\nin the overall `<CreateTearsheet />` component and the `<CreateTearsheetStep />`\ncomponent with form items as children:",
|
|
20
|
+
source: {
|
|
21
|
+
code: " <CreateTearsheet {...props}>\n <CreateTearsheetStep\n title=\"Required title\"\n subtitle=\"Optional subtitle\"\n description=\"Optional description\"\n onNext={() => {'Optional function'}}\n disableSubmit={}\n >\n <TextInput\n id=\"test-1\"\n invalidText=\"A valid value is required\"\n labelText=\"Topic name\"\n placeholder=\"Enter topic name\"\n />\n </CreateTearsheetStep>\n </CreateTearsheet>"
|
|
22
|
+
}
|
|
23
|
+
}, {
|
|
24
|
+
title: 'Using custom components',
|
|
25
|
+
description: "It is possible to use custom components that return `CreateTearsheetStep`s in\norder to help reduce the amount of logic in the component that contains the main\n`CreateTearsheet`. _It is required that each child of the `CreateTearsheet`\neither be a custom step or a `CreateTearsheetStep`_. An example of this could\nlook like the following:",
|
|
26
|
+
source: {
|
|
27
|
+
code: "const CreateStepCustom = ({ subtitle, ...rest }) => {\n return (\n <CreateTearsheetStep\n {...rest}\n subtitle={subtitle}\n title=\"Step 1\"\n onNext={() => console.log('optional validation check')}\n onMount={() => console.log('optional onMount fn')}\n disableSubmit={false}\n >\n step content here\n </CreateTearsheetStep>\n );\n};\n\nconst CreateComponent = () => {\n return (\n <CreateTearsheet {...createTearsheetProps}>\n <CreateStepCustom subtitle=\"Custom step subtitle\" />\n <CreateTearsheetStep\n title=\"Topic name\"\n fieldsetLegendText=\"Topic information\"\n disableSubmit={!value}\n subtitle=\"This is the unique name used to recognize your topic\"\n description=\"It will also be used by your producers and consumers as part of the\n connection information, so make it something easy to recognize.\"\n >\n Content for second step\n </CreateTearsheetStep>\n </CreateTearsheet>\n );\n};"
|
|
28
|
+
}
|
|
29
|
+
}, {
|
|
30
|
+
title: 'Using dynamic steps',
|
|
31
|
+
description: "The use of dynamic steps can be utilized in a scenario when the user makes a\ncertain selection on one step that effects which steps will follow it, this is\ncontrolled via the `includeStep` prop. See abbreviated example below:",
|
|
32
|
+
code: "import { useState } from 'react';\n\nconst CreateFlow = () => {\n const [shouldIncludeAdditionalStep, setShouldIncludeAdditionalStep] =\n useState(false);\n return (\n <CreateTearsheet {...createTearsheetProps}>\n <CreateTearsheetStep {...step1Props}>\n Step 1 content\n <Checkbox\n labelText={`Include additional step`}\n id=\"include-additional-step-checkbox\"\n onChange={(value) => setShouldIncludeAdditionalStep(value)}\n checked={shouldIncludeAdditionalStep}\n />\n </CreateTearsheetStep>\n <CreateTearsheetStep\n {...step2Props}\n includeStep={shouldIncludeAdditionalStep}\n >\n Dynamic step content\n </CreateTearsheetStep>\n <CreateTearsheetStep {...step3Props}>\n Final step content\n </CreateTearsheetStep>\n </CreateTearsheet>\n );\n};"
|
|
33
|
+
}, {
|
|
34
|
+
title: 'Class names',
|
|
35
|
+
description: "Additionally, to get the preferred styling when including your own children as\nsections, you can utilize the below included class names.\n\n| Class name | Element | Features |\n| ----------------------------------------------------- | ----------- | ---------------------------------------------------------- |\n| `#{$pkg-prefix}--create-tearsheet__step--title` | title | `productive-heading-04` & `margin-bottom` of `$spacing-05` |\n| `#{$pkg-prefix}--create-tearsheet__step--subtitle` | subtitle | `productive-heading-01` & `margin-bottom` of `$spacing-03` |\n| `#{$pkg-prefix}--create-tearsheet__step--description` | description | `body-long-01` & `margin-bottom` of `$spacing-06` |\n| `#{$pkg-prefix}--create-tearsheet__step--fieldset` | fieldset | `margin-bottom` of `$spacing-05` to all children elements |\n| `#{$pkg-prefix}--create-tearsheet__section--divider` | divider | Includes a `1px` divider line inside the `main` content |\n"
|
|
36
|
+
}]
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
var _default = DocsPage;
|
|
40
|
+
exports.default = _default;
|
|
@@ -674,9 +674,6 @@ 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]);
|
|
680
677
|
|
|
681
678
|
// Only update if there are cell selection areas
|
|
682
679
|
// Find point object that matches currentMatcher and remove the second point
|
|
@@ -709,6 +706,9 @@ var DataSpreadsheet = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
|
|
|
709
706
|
});
|
|
710
707
|
}
|
|
711
708
|
}, [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 : -1,
|
|
96
96
|
onKeyDown: withInlineEdit ? function (event) {
|
|
97
97
|
return (0, _handleGridKeyPress.handleGridKeyPress)({
|
|
98
98
|
event: event,
|
|
@@ -44,6 +44,9 @@ 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;
|
|
47
50
|
var _useState = (0, _react.useState)(SELECT_ALL_PAGE_ROWS),
|
|
48
51
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
49
52
|
selectAllMode = _useState2[0],
|
|
@@ -66,9 +69,6 @@ var SelectAllWithToggle = function SelectAllWithToggle(_ref) {
|
|
|
66
69
|
return window.removeEventListener('resize', updateSize);
|
|
67
70
|
};
|
|
68
71
|
}, []);
|
|
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;
|
|
@@ -18,7 +18,7 @@ var _classnames = _interopRequireDefault(require("classnames"));
|
|
|
18
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); }
|
|
19
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; }
|
|
20
20
|
/**
|
|
21
|
-
* Copyright IBM Corp. 2022,
|
|
21
|
+
* Copyright IBM Corp. 2022, 2023
|
|
22
22
|
*
|
|
23
23
|
* This source code is licensed under the Apache-2.0 license found in the
|
|
24
24
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -26,6 +26,7 @@ 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;
|
|
29
30
|
var _useState = (0, _react.useState)(false),
|
|
30
31
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
31
32
|
displayAllInMenu = _useState2[0],
|
|
@@ -38,11 +39,12 @@ var DatagridBatchActionsToolbar = function DatagridBatchActionsToolbar(datagridS
|
|
|
38
39
|
_useState6 = (0, _slicedToArray2.default)(_useState5, 2),
|
|
39
40
|
receivedInitialWidth = _useState6[0],
|
|
40
41
|
setReceivedInitialWidth = _useState6[1];
|
|
41
|
-
var
|
|
42
|
+
var selectedRowIds = datagridState.state.selectedRowIds,
|
|
42
43
|
toggleAllRowsSelected = datagridState.toggleAllRowsSelected,
|
|
43
44
|
toolbarBatchActions = datagridState.toolbarBatchActions,
|
|
44
|
-
setGlobalFilter = datagridState.setGlobalFilter
|
|
45
|
-
|
|
45
|
+
setGlobalFilter = datagridState.setGlobalFilter,
|
|
46
|
+
rows = datagridState.rows;
|
|
47
|
+
var totalSelected = (_Object$keys = Object.keys(selectedRowIds || {})) === null || _Object$keys === void 0 ? void 0 : _Object$keys.length;
|
|
46
48
|
|
|
47
49
|
// Get initial width of batch actions container,
|
|
48
50
|
// used to measure when all items are put inside
|
|
@@ -62,6 +64,19 @@ var DatagridBatchActionsToolbar = function DatagridBatchActionsToolbar(datagridS
|
|
|
62
64
|
setDisplayAllInMenu(false);
|
|
63
65
|
}
|
|
64
66
|
}, [width, ref, initialListWidth]);
|
|
67
|
+
var getSelectedRowData = function getSelectedRowData() {
|
|
68
|
+
var selectedRowIndexes = Object.keys(selectedRowIds);
|
|
69
|
+
var selectedRowData = selectedRowIndexes && selectedRowIndexes.length ? selectedRowIndexes.map(function (rowIndex) {
|
|
70
|
+
var filteredRow = rows.filter(function (row) {
|
|
71
|
+
return row.index === parseInt(rowIndex);
|
|
72
|
+
});
|
|
73
|
+
if (filteredRow.length) {
|
|
74
|
+
return filteredRow[0];
|
|
75
|
+
}
|
|
76
|
+
return [];
|
|
77
|
+
}) : [];
|
|
78
|
+
return selectedRowData;
|
|
79
|
+
};
|
|
65
80
|
|
|
66
81
|
// Render batch actions in ButtonMenu
|
|
67
82
|
var renderBatchActionOverflow = function renderBatchActionOverflow() {
|
|
@@ -84,8 +99,8 @@ var DatagridBatchActionsToolbar = function DatagridBatchActionsToolbar(datagridS
|
|
|
84
99
|
return /*#__PURE__*/_react.default.createElement(_ButtonMenu.ButtonMenuItem, {
|
|
85
100
|
key: "".concat(batchAction.label, "-").concat(index),
|
|
86
101
|
itemText: batchAction.label,
|
|
87
|
-
onClick: function onClick() {
|
|
88
|
-
batchAction.onClick();
|
|
102
|
+
onClick: function onClick(event) {
|
|
103
|
+
batchAction.onClick(getSelectedRowData(), event);
|
|
89
104
|
if (batchAction.type === 'select_all') {
|
|
90
105
|
toggleAllRowsSelected(true);
|
|
91
106
|
}
|
|
@@ -97,8 +112,8 @@ var DatagridBatchActionsToolbar = function DatagridBatchActionsToolbar(datagridS
|
|
|
97
112
|
return /*#__PURE__*/_react.default.createElement(_ButtonMenu.ButtonMenuItem, {
|
|
98
113
|
key: "".concat(batchAction.label, "-").concat(index),
|
|
99
114
|
itemText: batchAction.label,
|
|
100
|
-
onClick: function onClick() {
|
|
101
|
-
batchAction.onClick();
|
|
115
|
+
onClick: function onClick(event) {
|
|
116
|
+
batchAction.onClick(getSelectedRowData(), event);
|
|
102
117
|
if (batchAction.type === 'select_all') {
|
|
103
118
|
toggleAllRowsSelected(true);
|
|
104
119
|
}
|
|
@@ -122,8 +137,8 @@ var DatagridBatchActionsToolbar = function DatagridBatchActionsToolbar(datagridS
|
|
|
122
137
|
return /*#__PURE__*/_react.default.createElement(_react2.TableBatchAction, {
|
|
123
138
|
key: "".concat(batchAction.label, "-").concat(index),
|
|
124
139
|
renderIcon: batchAction.renderIcon,
|
|
125
|
-
onClick: function onClick() {
|
|
126
|
-
batchAction.onClick();
|
|
140
|
+
onClick: function onClick(event) {
|
|
141
|
+
batchAction.onClick(getSelectedRowData(), event);
|
|
127
142
|
if (batchAction.type === 'select_all') {
|
|
128
143
|
toggleAllRowsSelected(true);
|
|
129
144
|
}
|
|
@@ -59,9 +59,7 @@ 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,
|
|
63
|
-
callback: handleVirtualGridResize
|
|
64
|
-
});
|
|
62
|
+
(0, _useResizeObserver.useResizeObserver)(gridRef, handleVirtualGridResize);
|
|
65
63
|
var syncScroll = function syncScroll(e) {
|
|
66
64
|
var virtualBody = e.target;
|
|
67
65
|
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: instance === null || instance === void 0 ? void 0 : instance.isTableSortable,
|
|
32
|
+
isTableSortable: (instance === null || instance === void 0 ? void 0 : instance.isTableSortable) || false,
|
|
33
33
|
setIsTearsheetOpen: setIsTearsheetOpen,
|
|
34
34
|
columnDefinitions: instance.allColumns,
|
|
35
35
|
originalColumnDefinitions: instance.columns,
|
|
@@ -55,11 +55,8 @@ 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
|
-
|
|
60
|
-
// Save the initial filters we only need the filters once when it loads
|
|
61
|
-
var initialFiltersRef = (0, _react2.useRef)(initialFilters);
|
|
62
|
-
|
|
58
|
+
_ref$reactTableFilter = _ref.reactTableFiltersState,
|
|
59
|
+
reactTableFiltersState = _ref$reactTableFilter === void 0 ? [] : _ref$reactTableFilter;
|
|
63
60
|
/** State */
|
|
64
61
|
var _useState = (0, _react2.useState)(false),
|
|
65
62
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
@@ -70,15 +67,17 @@ var FilterFlyout = function FilterFlyout(_ref) {
|
|
|
70
67
|
filters: filters,
|
|
71
68
|
setAllFilters: setAllFilters,
|
|
72
69
|
variation: _constants.FLYOUT,
|
|
73
|
-
|
|
70
|
+
reactTableFiltersState: reactTableFiltersState,
|
|
71
|
+
onCancel: onCancel
|
|
74
72
|
}),
|
|
75
73
|
filtersState = _useFilters.filtersState,
|
|
76
74
|
prevFiltersObjectArrayRef = _useFilters.prevFiltersObjectArrayRef,
|
|
77
75
|
prevFiltersRef = _useFilters.prevFiltersRef,
|
|
78
|
-
|
|
76
|
+
cancel = _useFilters.cancel,
|
|
79
77
|
reset = _useFilters.reset,
|
|
80
78
|
renderFilter = _useFilters.renderFilter,
|
|
81
|
-
filtersObjectArray = _useFilters.filtersObjectArray
|
|
79
|
+
filtersObjectArray = _useFilters.filtersObjectArray,
|
|
80
|
+
lastAppliedFilters = _useFilters.lastAppliedFilters;
|
|
82
81
|
|
|
83
82
|
/** Refs */
|
|
84
83
|
var filterFlyoutRef = (0, _react2.useRef)(null);
|
|
@@ -117,26 +116,10 @@ var FilterFlyout = function FilterFlyout(_ref) {
|
|
|
117
116
|
// updates the ref so next time the flyout opens we have records of the previous filters
|
|
118
117
|
prevFiltersRef.current = JSON.stringify(filtersState);
|
|
119
118
|
prevFiltersObjectArrayRef.current = JSON.stringify(filtersObjectArray);
|
|
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
119
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
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);
|
|
120
|
+
// Update the last applied filters
|
|
121
|
+
lastAppliedFilters.current = JSON.stringify(filtersObjectArray);
|
|
122
|
+
};
|
|
140
123
|
|
|
141
124
|
/** Renders all filters */
|
|
142
125
|
var renderFilters = function renderFilters() {
|
|
@@ -163,22 +146,31 @@ var FilterFlyout = function FilterFlyout(_ref) {
|
|
|
163
146
|
buttonSize: "md"
|
|
164
147
|
});
|
|
165
148
|
};
|
|
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]);
|
|
166
164
|
return /*#__PURE__*/_react2.default.createElement("div", {
|
|
167
165
|
className: "".concat(componentClass, "__container")
|
|
168
|
-
}, /*#__PURE__*/_react2.default.createElement(_react.
|
|
166
|
+
}, /*#__PURE__*/_react2.default.createElement(_react.IconButton, {
|
|
167
|
+
label: flyoutIconDescription,
|
|
169
168
|
kind: "ghost",
|
|
170
|
-
|
|
171
|
-
tooltipPosition: "bottom",
|
|
172
|
-
renderIcon: function renderIcon() {
|
|
173
|
-
return /*#__PURE__*/_react2.default.createElement(_icons.Filter, {
|
|
174
|
-
size: 16
|
|
175
|
-
});
|
|
176
|
-
},
|
|
177
|
-
iconDescription: flyoutIconDescription,
|
|
169
|
+
align: "bottom",
|
|
178
170
|
onClick: open ? closeFlyout : openFlyout,
|
|
179
171
|
className: (0, _classnames.default)("".concat(componentClass, "__trigger"), (0, _defineProperty2.default)({}, "".concat(componentClass, "__trigger--open"), open)),
|
|
180
172
|
disabled: data.length === 0
|
|
181
|
-
}), /*#__PURE__*/_react2.default.createElement("div", {
|
|
173
|
+
}, /*#__PURE__*/_react2.default.createElement(_icons.Filter, null)), /*#__PURE__*/_react2.default.createElement("div", {
|
|
182
174
|
ref: filterFlyoutRef,
|
|
183
175
|
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))
|
|
184
176
|
}, /*#__PURE__*/_react2.default.createElement("div", {
|
|
@@ -206,14 +198,6 @@ FilterFlyout.propTypes = {
|
|
|
206
198
|
* Icon description for the filter flyout button
|
|
207
199
|
*/
|
|
208
200
|
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
|
-
})),
|
|
217
201
|
/**
|
|
218
202
|
* Callback when the apply button is clicked
|
|
219
203
|
*/
|
|
@@ -234,6 +218,14 @@ FilterFlyout.propTypes = {
|
|
|
234
218
|
* Label text of the primary action in the flyout
|
|
235
219
|
*/
|
|
236
220
|
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
|
+
})),
|
|
237
229
|
/**
|
|
238
230
|
* Label text of the secondary action in the flyout
|
|
239
231
|
*/
|
|
@@ -66,11 +66,8 @@ 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
|
-
|
|
71
|
-
// Save the initial filters we only need the filters once
|
|
72
|
-
var initialFiltersRef = (0, _react.useRef)(initialFilters);
|
|
73
|
-
|
|
69
|
+
_ref$reactTableFilter = _ref.reactTableFiltersState,
|
|
70
|
+
reactTableFiltersState = _ref$reactTableFilter === void 0 ? [] : _ref$reactTableFilter;
|
|
74
71
|
/** State */
|
|
75
72
|
var _useState = (0, _react.useState)(false),
|
|
76
73
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
@@ -81,15 +78,17 @@ var FilterPanel = function FilterPanel(_ref) {
|
|
|
81
78
|
filters: filterSections,
|
|
82
79
|
setAllFilters: setAllFilters,
|
|
83
80
|
variation: _constants.PANEL,
|
|
84
|
-
|
|
81
|
+
reactTableFiltersState: reactTableFiltersState,
|
|
82
|
+
onCancel: onCancel
|
|
85
83
|
}),
|
|
86
84
|
filtersState = _useFilters.filtersState,
|
|
87
85
|
prevFiltersObjectArrayRef = _useFilters.prevFiltersObjectArrayRef,
|
|
88
86
|
prevFiltersRef = _useFilters.prevFiltersRef,
|
|
89
|
-
|
|
87
|
+
cancel = _useFilters.cancel,
|
|
90
88
|
reset = _useFilters.reset,
|
|
91
89
|
renderFilter = _useFilters.renderFilter,
|
|
92
|
-
filtersObjectArray = _useFilters.filtersObjectArray
|
|
90
|
+
filtersObjectArray = _useFilters.filtersObjectArray,
|
|
91
|
+
lastAppliedFilters = _useFilters.lastAppliedFilters;
|
|
93
92
|
|
|
94
93
|
/** Refs */
|
|
95
94
|
var filterPanelRef = (0, _react.useRef)();
|
|
@@ -119,14 +118,8 @@ var FilterPanel = function FilterPanel(_ref) {
|
|
|
119
118
|
|
|
120
119
|
/** Methods */
|
|
121
120
|
var closePanel = function closePanel() {
|
|
122
|
-
|
|
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
|
-
}
|
|
121
|
+
cancel();
|
|
122
|
+
setPanelOpen(false);
|
|
130
123
|
};
|
|
131
124
|
var apply = function apply() {
|
|
132
125
|
setAllFilters(filtersObjectArray);
|
|
@@ -138,6 +131,9 @@ var FilterPanel = function FilterPanel(_ref) {
|
|
|
138
131
|
// updates the ref so next time the flyout opens we have records of the previous filters
|
|
139
132
|
prevFiltersRef.current = JSON.stringify(filtersState);
|
|
140
133
|
prevFiltersObjectArrayRef.current = JSON.stringify(filtersObjectArray);
|
|
134
|
+
|
|
135
|
+
// Update the last applied filters
|
|
136
|
+
lastAppliedFilters.current = JSON.stringify(filtersObjectArray);
|
|
141
137
|
};
|
|
142
138
|
var renderActionSet = function renderActionSet() {
|
|
143
139
|
return showActionSet && /*#__PURE__*/_react.default.createElement(MotionActionSet, {
|
|
@@ -254,20 +250,20 @@ FilterPanel.propTypes = {
|
|
|
254
250
|
closeIconDescription: _propTypes.default.string,
|
|
255
251
|
filterPanelMinHeight: _propTypes.default.number,
|
|
256
252
|
filterSections: _propTypes.default.array,
|
|
257
|
-
/**
|
|
258
|
-
* Filters that should be applied on load
|
|
259
|
-
*/
|
|
260
|
-
initialFilters: _propTypes.default.arrayOf(_propTypes.default.shape({
|
|
261
|
-
id: _propTypes.default.string.isRequired,
|
|
262
|
-
type: _propTypes.default.string.isRequired,
|
|
263
|
-
value: _propTypes.default.any.isRequired
|
|
264
|
-
})),
|
|
265
253
|
onApply: _propTypes.default.func,
|
|
266
254
|
onCancel: _propTypes.default.func,
|
|
267
255
|
onPanelClose: _propTypes.default.func,
|
|
268
256
|
onPanelOpen: _propTypes.default.func,
|
|
269
257
|
open: _propTypes.default.bool,
|
|
270
258
|
primaryActionLabel: _propTypes.default.string,
|
|
259
|
+
/**
|
|
260
|
+
* Filters from react table's state
|
|
261
|
+
*/
|
|
262
|
+
reactTableFiltersState: _propTypes.default.arrayOf(_propTypes.default.shape({
|
|
263
|
+
id: _propTypes.default.string.isRequired,
|
|
264
|
+
type: _propTypes.default.string.isRequired,
|
|
265
|
+
value: _propTypes.default.any.isRequired
|
|
266
|
+
})),
|
|
271
267
|
searchLabelText: _propTypes.default.string,
|
|
272
268
|
searchPlaceholder: _propTypes.default.string,
|
|
273
269
|
secondaryActionLabel: _propTypes.default.string,
|
|
@@ -4,16 +4,16 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
Object.defineProperty(exports, "
|
|
7
|
+
Object.defineProperty(exports, "useFilterContext", {
|
|
8
8
|
enumerable: true,
|
|
9
9
|
get: function get() {
|
|
10
|
-
return
|
|
10
|
+
return _useFilterContext.default;
|
|
11
11
|
}
|
|
12
12
|
});
|
|
13
|
-
Object.defineProperty(exports, "
|
|
13
|
+
Object.defineProperty(exports, "useFilters", {
|
|
14
14
|
enumerable: true,
|
|
15
15
|
get: function get() {
|
|
16
|
-
return
|
|
16
|
+
return _useFilters.default;
|
|
17
17
|
}
|
|
18
18
|
});
|
|
19
19
|
Object.defineProperty(exports, "useShouldDisableButtons", {
|
|
@@ -28,7 +28,7 @@ Object.defineProperty(exports, "useSubscribeToEventEmitter", {
|
|
|
28
28
|
return _useSubscribeToEventEmitter.default;
|
|
29
29
|
}
|
|
30
30
|
});
|
|
31
|
-
var _useInitialStateFromFilters = _interopRequireDefault(require("./useInitialStateFromFilters"));
|
|
32
31
|
var _useSubscribeToEventEmitter = _interopRequireDefault(require("./useSubscribeToEventEmitter"));
|
|
33
32
|
var _useFilters = _interopRequireDefault(require("./useFilters"));
|
|
34
|
-
var _useShouldDisableButtons = _interopRequireDefault(require("./useShouldDisableButtons"));
|
|
33
|
+
var _useShouldDisableButtons = _interopRequireDefault(require("./useShouldDisableButtons"));
|
|
34
|
+
var _useFilterContext = _interopRequireDefault(require("./useFilterContext"));
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _FilterProvider = require("../FilterProvider");
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
var useFilterContext = function useFilterContext() {
|
|
10
|
+
// get the context
|
|
11
|
+
var context = (0, _react.useContext)(_FilterProvider.FilterContext);
|
|
12
|
+
|
|
13
|
+
// if `undefined`, throw an error
|
|
14
|
+
if (context === undefined) {
|
|
15
|
+
throw new Error('useFilterContext was used outside of its Provider');
|
|
16
|
+
}
|
|
17
|
+
return context;
|
|
18
|
+
};
|
|
19
|
+
var _default = useFilterContext;
|
|
20
|
+
exports.default = _default;
|
|
@@ -13,7 +13,6 @@ 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"));
|
|
17
16
|
var _utils = require("../utils");
|
|
18
17
|
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); }
|
|
19
18
|
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; }
|
|
@@ -31,19 +30,22 @@ var useFilters = function useFilters(_ref) {
|
|
|
31
30
|
filters = _ref$filters === void 0 ? [] : _ref$filters,
|
|
32
31
|
setAllFilters = _ref.setAllFilters,
|
|
33
32
|
variation = _ref.variation,
|
|
34
|
-
|
|
33
|
+
reactTableFiltersState = _ref.reactTableFiltersState,
|
|
34
|
+
_ref$onCancel = _ref.onCancel,
|
|
35
|
+
onCancel = _ref$onCancel === void 0 ? function () {} : _ref$onCancel;
|
|
35
36
|
/** State */
|
|
36
|
-
var
|
|
37
|
-
_useInitialStateFromF2 = (0, _slicedToArray2.default)(_useInitialStateFromF, 2),
|
|
38
|
-
filtersState = _useInitialStateFromF2[0],
|
|
39
|
-
setFiltersState = _useInitialStateFromF2[1];
|
|
40
|
-
var _useState = (0, _react.useState)(initialFilters),
|
|
37
|
+
var _useState = (0, _react.useState)((0, _utils.getInitialStateFromFilters)(filters, variation, reactTableFiltersState)),
|
|
41
38
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
42
|
-
|
|
43
|
-
|
|
39
|
+
filtersState = _useState2[0],
|
|
40
|
+
setFiltersState = _useState2[1];
|
|
41
|
+
var _useState3 = (0, _react.useState)(reactTableFiltersState),
|
|
42
|
+
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
43
|
+
filtersObjectArray = _useState4[0],
|
|
44
|
+
setFiltersObjectArray = _useState4[1];
|
|
44
45
|
|
|
45
46
|
// When using batch actions we have to store the filters to then apply them later
|
|
46
47
|
var prevFiltersRef = (0, _react.useRef)(JSON.stringify(filtersState));
|
|
48
|
+
var lastAppliedFilters = (0, _react.useRef)(JSON.stringify(reactTableFiltersState));
|
|
47
49
|
var prevFiltersObjectArrayRef = (0, _react.useRef)(JSON.stringify(filtersObjectArray));
|
|
48
50
|
|
|
49
51
|
/** Methods */
|
|
@@ -52,6 +54,7 @@ var useFilters = function useFilters(_ref) {
|
|
|
52
54
|
var revertToPreviousFilters = function revertToPreviousFilters() {
|
|
53
55
|
setFiltersState(JSON.parse(prevFiltersRef.current));
|
|
54
56
|
setFiltersObjectArray(JSON.parse(prevFiltersObjectArrayRef.current));
|
|
57
|
+
setAllFilters(JSON.parse(lastAppliedFilters.current));
|
|
55
58
|
};
|
|
56
59
|
var reset = function reset() {
|
|
57
60
|
// When we reset we want the "initialFilters" to be an empty array
|
|
@@ -163,8 +166,11 @@ var useFilters = function useFilters(_ref) {
|
|
|
163
166
|
var type = _ref3.type,
|
|
164
167
|
column = _ref3.column,
|
|
165
168
|
components = _ref3.props;
|
|
166
|
-
var isPanel = variation === _constants.PANEL;
|
|
167
169
|
var filter;
|
|
170
|
+
var isPanel = variation === _constants.PANEL;
|
|
171
|
+
if (!type) {
|
|
172
|
+
return console.error("type: ".concat(type, "; does not exist as a type of filter."));
|
|
173
|
+
}
|
|
168
174
|
switch (type) {
|
|
169
175
|
case _constants.DATE:
|
|
170
176
|
filter = /*#__PURE__*/_react.default.createElement(_react2.DatePicker, (0, _extends2.default)({}, components.DatePicker, {
|
|
@@ -290,10 +296,31 @@ var useFilters = function useFilters(_ref) {
|
|
|
290
296
|
break;
|
|
291
297
|
}
|
|
292
298
|
if (isPanel) {
|
|
293
|
-
return /*#__PURE__*/_react.default.createElement(_react2.Layer,
|
|
299
|
+
return /*#__PURE__*/_react.default.createElement(_react2.Layer, {
|
|
300
|
+
key: column
|
|
301
|
+
}, filter);
|
|
294
302
|
}
|
|
295
|
-
return
|
|
303
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, {
|
|
304
|
+
key: column
|
|
305
|
+
}, filter);
|
|
296
306
|
};
|
|
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]);
|
|
297
324
|
return {
|
|
298
325
|
filtersState: filtersState,
|
|
299
326
|
setFiltersState: setFiltersState,
|
|
@@ -302,7 +329,9 @@ var useFilters = function useFilters(_ref) {
|
|
|
302
329
|
revertToPreviousFilters: revertToPreviousFilters,
|
|
303
330
|
reset: reset,
|
|
304
331
|
renderFilter: renderFilter,
|
|
305
|
-
filtersObjectArray: filtersObjectArray
|
|
332
|
+
filtersObjectArray: filtersObjectArray,
|
|
333
|
+
lastAppliedFilters: lastAppliedFilters,
|
|
334
|
+
cancel: cancel
|
|
306
335
|
};
|
|
307
336
|
};
|
|
308
337
|
var _default = useFilters;
|