@carbon/ibm-products 2.0.0-rc.2 → 2.0.0-rc.4
Sign up to get free protection for your applications and to get access to all the features.
- package/css/index-full-carbon.css +946 -327
- package/css/index-full-carbon.css.map +1 -1
- package/css/index-full-carbon.min.css +4 -8
- package/css/index-full-carbon.min.css.map +1 -1
- package/css/index-without-carbon-released-only.css +785 -168
- package/css/index-without-carbon-released-only.css.map +1 -1
- package/css/index-without-carbon-released-only.min.css +4 -8
- package/css/index-without-carbon-released-only.min.css.map +1 -1
- package/css/index-without-carbon.css +720 -232
- package/css/index-without-carbon.css.map +1 -1
- package/css/index-without-carbon.min.css +4 -8
- package/css/index-without-carbon.min.css.map +1 -1
- package/css/index.css +742 -244
- package/css/index.css.map +1 -1
- package/css/index.min.css +4 -8
- package/css/index.min.css.map +1 -1
- package/es/components/APIKeyModal/APIKeyModal.js +1 -1
- package/es/components/AddSelect/AddSelect.js +0 -3
- package/es/components/AddSelect/AddSelectBody.js +22 -5
- package/es/components/AddSelect/AddSelectBreadcrumbs.js +11 -3
- package/es/components/AddSelect/AddSelectColumn.js +5 -5
- package/es/components/AddSelect/AddSelectFilter.js +5 -4
- package/es/components/AddSelect/AddSelectList.js +61 -27
- package/es/components/AddSelect/AddSelectMetaPanel.js +1 -1
- package/es/components/AddSelect/AddSelectSort.js +1 -1
- package/es/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.js +4 -6
- package/es/components/Card/Card.js +16 -6
- package/es/components/Card/CardFooter.js +3 -1
- package/es/components/Card/CardHeader.js +20 -1
- package/es/components/ComboButton/ComboButton.js +1 -1
- package/es/components/CreateTearsheetNarrow/CreateTearsheetNarrow.js +2 -2
- package/es/components/DataSpreadsheet/DataSpreadsheet.js +63 -11
- package/es/components/DataSpreadsheet/DataSpreadsheetBody.js +2 -1
- package/es/components/DataSpreadsheet/DataSpreadsheetHeader.js +7 -0
- package/es/components/DataSpreadsheet/hooks/useMultipleKeyTracking.js +6 -5
- package/es/components/DataSpreadsheet/utils/handleCellDeletion.js +31 -0
- package/es/components/DataSpreadsheet/utils/handleMultipleKeys.js +1 -1
- package/es/components/Datagrid/Datagrid/Datagrid.js +10 -38
- package/es/components/Datagrid/Datagrid/DatagridContent.js +154 -0
- package/es/components/Datagrid/Datagrid/DatagridExpandedRow.js +9 -1
- package/es/components/Datagrid/Datagrid/DatagridRow.js +10 -2
- package/es/components/Datagrid/Datagrid/DatagridSelectAll.js +10 -3
- package/es/components/Datagrid/Datagrid/DatagridSelectAllWithToggle.js +13 -4
- package/es/components/Datagrid/Datagrid/DatagridToolbar.js +5 -4
- package/es/components/Datagrid/Datagrid/DatagridVirtualBody.js +2 -1
- package/es/components/Datagrid/Datagrid/DraggableElement.js +6 -2
- package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/Actions.js +5 -45
- package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/ButtonWrapper.js +4 -1
- package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/Columns.js +36 -10
- package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/CustomizeColumnsModal.js +62 -26
- package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/ModalWrapper.js +3 -2
- package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditButton/InlineEditButton.js +60 -0
- package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditButton/index.js +1 -0
- package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditCell/InlineEditCell.js +534 -0
- package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditCell/index.js +1 -0
- package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/InlineEditContext.js +112 -0
- package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/getCellIdAsObject.js +27 -0
- package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/index.js +1 -0
- package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/returnUpdatedActiveCell.js +39 -0
- package/es/components/Datagrid/Datagrid/addons/InlineEdit/handleGridFocus.js +19 -0
- package/es/components/Datagrid/Datagrid/addons/InlineEdit/handleGridKeyPress.js +263 -0
- package/es/components/Datagrid/Datagrid/addons/InlineEdit/handleMultipleKeys.js +87 -0
- package/es/components/Datagrid/Datagrid/addons/RowSize/RowSizeDropdown.js +17 -14
- package/es/components/Datagrid/Datagrid/addons/RowSize/RowSizeRadioGroup.js +13 -36
- package/es/components/Datagrid/{Datagrid.stories-helpers → Datagrid.stories}/CustomizeColumnStory.js +0 -0
- package/es/components/Datagrid/{Datagrid.stories-helpers → Datagrid.stories}/LeftPanelStory.js +0 -0
- package/es/components/Datagrid/{Datagrid.stories-helpers → Datagrid.stories}/RowSizeDropdownStory.js +0 -0
- package/es/components/Datagrid/{Datagrid.stories-helpers → Datagrid.stories}/SelectAllWithToggleStory.js +0 -0
- package/es/components/Datagrid/{Datagrid.stories-helpers → Datagrid.stories}/StickyActionsColumnStory.js +0 -0
- package/es/components/Datagrid/{Datagrid.stories-helpers → Datagrid.stories}/common.js +0 -0
- package/es/components/Datagrid/{Datagrid.stories-helpers → Datagrid.stories}/index.js +0 -0
- package/es/components/Datagrid/index.js +3 -1
- package/es/components/Datagrid/useActionsColumn.js +28 -12
- package/es/components/Datagrid/useColumnOrder.js +8 -0
- package/es/components/Datagrid/useCustomizeColumns.js +5 -0
- package/es/components/Datagrid/useDisableSelectRows.js +6 -2
- package/es/components/Datagrid/useExpandedRow.js +0 -1
- package/es/components/Datagrid/useInfiniteScroll.js +5 -2
- package/es/components/Datagrid/useInlineEdit.js +71 -0
- package/es/components/Datagrid/useNestedRowExpander.js +42 -0
- package/es/components/Datagrid/useNestedRows.js +2 -2
- package/es/components/Datagrid/useRowExpander.js +1 -1
- package/es/components/Datagrid/useRowSize.js +17 -6
- package/es/components/Datagrid/useSelectAllToggle.js +17 -4
- package/es/components/Datagrid/useSelectRows.js +12 -2
- package/es/components/Datagrid/useSortableColumns.js +1 -1
- package/es/components/Datagrid/useStickyColumn.js +11 -0
- package/es/components/Datagrid/utils/DatagridActions.js +152 -0
- package/es/components/Datagrid/utils/DatagridPagination.js +33 -0
- package/es/components/Datagrid/utils/Wrapper.js +21 -0
- package/es/components/Datagrid/utils/getArgTypes.js +89 -0
- package/es/components/Datagrid/utils/getInlineEditColumns.js +153 -0
- package/es/components/Datagrid/utils/makeData.js +46 -1
- package/es/components/EditUpdateCards/EditUpdateCards.js +144 -0
- package/es/components/EditUpdateCards/index.js +7 -0
- package/es/components/ExportModal/ExportModal.js +1 -1
- package/es/components/ImportModal/ImportModal.js +3 -3
- package/es/components/InlineEdit/InlineEdit.js +11 -9
- package/es/components/ModifiedTabs/ModifiedTabLabelNew.js +1 -1
- package/es/components/ModifiedTabs/ModifiedTabLabelWithClose.js +1 -1
- package/es/components/NotificationsPanel/NotificationsPanel.js +1 -1
- package/es/components/OptionsTile/OptionsTile.js +1 -1
- package/es/components/PageHeader/PageHeader.js +1 -1
- package/es/components/PageHeader/PageHeaderTitle.js +3 -1
- package/es/components/ProductiveCard/ProductiveCard.js +5 -0
- package/es/components/Saving/Saving.js +1 -1
- package/es/components/SidePanel/SidePanel.js +45 -52
- package/es/components/SidePanel/motion/variants.js +45 -0
- package/es/components/StatusIcon/StatusIcon.js +1 -1
- package/es/components/UserProfileImage/UserProfileImage.js +1 -1
- package/es/components/WebTerminal/WebTerminal.js +1 -1
- package/es/components/WebTerminal/preview-components/Navigation.js +1 -1
- package/es/components/index.js +3 -2
- package/es/global/js/hooks/useClickOutside.js +1 -1
- package/es/global/js/package-settings.js +5 -4
- package/es/global/js/utils/getBezierValues.js +20 -0
- package/es/global/js/utils/motionConstants.js +45 -0
- package/es/global/js/utils/rangeWithCallback.js +13 -0
- package/es/global/js/utils/story-helper.js +5 -1
- package/es/global/js/utils/uuidv4.spec.js +4 -0
- package/lib/components/APIKeyModal/APIKeyModal.js +4 -4
- package/lib/components/AddSelect/AddSelect.js +0 -4
- package/lib/components/AddSelect/AddSelectBody.js +22 -5
- package/lib/components/AddSelect/AddSelectBreadcrumbs.js +14 -3
- package/lib/components/AddSelect/AddSelectColumn.js +5 -5
- package/lib/components/AddSelect/AddSelectFilter.js +5 -4
- package/lib/components/AddSelect/AddSelectList.js +62 -28
- package/lib/components/AddSelect/AddSelectMetaPanel.js +2 -2
- package/lib/components/AddSelect/AddSelectSort.js +4 -4
- package/lib/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.js +6 -6
- package/lib/components/Card/Card.js +16 -6
- package/lib/components/Card/CardFooter.js +3 -1
- package/lib/components/Card/CardHeader.js +21 -1
- package/lib/components/ComboButton/ComboButton.js +3 -3
- package/lib/components/CreateTearsheetNarrow/CreateTearsheetNarrow.js +2 -2
- package/lib/components/DataSpreadsheet/DataSpreadsheet.js +63 -10
- package/lib/components/DataSpreadsheet/DataSpreadsheetBody.js +2 -1
- package/lib/components/DataSpreadsheet/DataSpreadsheetHeader.js +7 -0
- package/lib/components/DataSpreadsheet/hooks/useMultipleKeyTracking.js +6 -5
- package/lib/components/DataSpreadsheet/utils/handleCellDeletion.js +42 -0
- package/lib/components/DataSpreadsheet/utils/handleMultipleKeys.js +1 -1
- package/lib/components/Datagrid/Datagrid/Datagrid.js +12 -45
- package/lib/components/Datagrid/Datagrid/DatagridContent.js +188 -0
- package/lib/components/Datagrid/Datagrid/DatagridExpandedRow.js +9 -1
- package/lib/components/Datagrid/Datagrid/DatagridRow.js +19 -2
- package/lib/components/Datagrid/Datagrid/DatagridSelectAll.js +12 -3
- package/lib/components/Datagrid/Datagrid/DatagridSelectAllWithToggle.js +16 -5
- package/lib/components/Datagrid/Datagrid/DatagridToolbar.js +6 -5
- package/lib/components/Datagrid/Datagrid/DatagridVirtualBody.js +2 -1
- package/lib/components/Datagrid/Datagrid/DraggableElement.js +7 -3
- package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/Actions.js +12 -47
- package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/ButtonWrapper.js +5 -2
- package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/Columns.js +48 -25
- package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/CustomizeColumnsModal.js +60 -25
- package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/ModalWrapper.js +3 -2
- package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditButton/InlineEditButton.js +76 -0
- package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditButton/index.js +13 -0
- package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditCell/InlineEditCell.js +558 -0
- package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditCell/index.js +13 -0
- package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/InlineEditContext.js +129 -0
- package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/getCellIdAsObject.js +36 -0
- package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/index.js +19 -0
- package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/returnUpdatedActiveCell.js +45 -0
- package/lib/components/Datagrid/Datagrid/addons/InlineEdit/handleGridFocus.js +28 -0
- package/lib/components/Datagrid/Datagrid/addons/InlineEdit/handleGridKeyPress.js +272 -0
- package/lib/components/Datagrid/Datagrid/addons/InlineEdit/handleMultipleKeys.js +100 -0
- package/lib/components/Datagrid/Datagrid/addons/RowSize/RowSizeDropdown.js +17 -13
- package/lib/components/Datagrid/Datagrid/addons/RowSize/RowSizeRadioGroup.js +13 -35
- package/lib/components/Datagrid/{Datagrid.stories-helpers → Datagrid.stories}/CustomizeColumnStory.js +0 -0
- package/lib/components/Datagrid/{Datagrid.stories-helpers → Datagrid.stories}/LeftPanelStory.js +0 -0
- package/lib/components/Datagrid/{Datagrid.stories-helpers → Datagrid.stories}/RowSizeDropdownStory.js +0 -0
- package/lib/components/Datagrid/{Datagrid.stories-helpers → Datagrid.stories}/SelectAllWithToggleStory.js +0 -0
- package/lib/components/Datagrid/{Datagrid.stories-helpers → Datagrid.stories}/StickyActionsColumnStory.js +0 -0
- package/lib/components/Datagrid/{Datagrid.stories-helpers → Datagrid.stories}/common.js +0 -0
- package/lib/components/Datagrid/{Datagrid.stories-helpers → Datagrid.stories}/index.js +0 -0
- package/lib/components/Datagrid/index.js +17 -1
- package/lib/components/Datagrid/useActionsColumn.js +28 -13
- package/lib/components/Datagrid/useColumnOrder.js +17 -0
- package/lib/components/Datagrid/useCustomizeColumns.js +5 -0
- package/lib/components/Datagrid/useDisableSelectRows.js +6 -2
- package/lib/components/Datagrid/useExpandedRow.js +0 -1
- package/lib/components/Datagrid/useInfiniteScroll.js +5 -2
- package/lib/components/Datagrid/useInlineEdit.js +85 -0
- package/lib/components/Datagrid/useNestedRowExpander.js +57 -0
- package/lib/components/Datagrid/useNestedRows.js +3 -3
- package/lib/components/Datagrid/useRowExpander.js +3 -3
- package/lib/components/Datagrid/useRowSize.js +18 -13
- package/lib/components/Datagrid/useSelectAllToggle.js +18 -4
- package/lib/components/Datagrid/useSelectRows.js +12 -2
- package/lib/components/Datagrid/useSortableColumns.js +5 -5
- package/lib/components/Datagrid/useStickyColumn.js +11 -0
- package/lib/components/Datagrid/utils/DatagridActions.js +170 -0
- package/lib/components/Datagrid/utils/DatagridPagination.js +46 -0
- package/lib/components/Datagrid/utils/Wrapper.js +33 -0
- package/lib/components/Datagrid/utils/getArgTypes.js +97 -0
- package/lib/components/Datagrid/utils/getInlineEditColumns.js +168 -0
- package/lib/components/Datagrid/utils/makeData.js +47 -1
- package/lib/components/EditUpdateCards/EditUpdateCards.js +152 -0
- package/lib/components/EditUpdateCards/index.js +13 -0
- package/lib/components/ExportModal/ExportModal.js +3 -3
- package/lib/components/ImportModal/ImportModal.js +4 -4
- package/lib/components/InlineEdit/InlineEdit.js +16 -14
- package/lib/components/ModifiedTabs/ModifiedTabLabelNew.js +2 -2
- package/lib/components/ModifiedTabs/ModifiedTabLabelWithClose.js +3 -3
- package/lib/components/NotificationsPanel/NotificationsPanel.js +8 -8
- package/lib/components/OptionsTile/OptionsTile.js +6 -6
- package/lib/components/PageHeader/PageHeader.js +2 -2
- package/lib/components/PageHeader/PageHeaderTitle.js +3 -1
- package/lib/components/ProductiveCard/ProductiveCard.js +5 -0
- package/lib/components/Saving/Saving.js +5 -5
- package/lib/components/SidePanel/SidePanel.js +48 -53
- package/lib/components/SidePanel/motion/variants.js +55 -0
- package/lib/components/StatusIcon/StatusIcon.js +45 -45
- package/lib/components/UserProfileImage/UserProfileImage.js +7 -7
- package/lib/components/WebTerminal/WebTerminal.js +3 -3
- package/lib/components/WebTerminal/preview-components/Navigation.js +4 -4
- package/lib/components/index.js +21 -1
- package/lib/global/js/hooks/useClickOutside.js +1 -1
- package/lib/global/js/package-settings.js +5 -4
- package/lib/global/js/utils/getBezierValues.js +29 -0
- package/lib/global/js/utils/motionConstants.js +55 -0
- package/lib/global/js/utils/rangeWithCallback.js +22 -0
- package/lib/global/js/utils/story-helper.js +5 -1
- package/lib/global/js/utils/uuidv4.spec.js +4 -0
- package/package.json +18 -16
- package/scss/components/AddSelect/_add-select.scss +129 -30
- package/scss/components/Card/_card.scss +1 -0
- package/scss/components/Cascade/_cascade.scss +1 -1
- package/scss/components/CreateTearsheet/_create-tearsheet.scss +2 -0
- package/scss/components/Datagrid/_datagrid.scss +7 -0
- package/scss/components/Datagrid/_storybook-styles.scss +12 -5
- package/scss/components/Datagrid/styles/_datagrid.scss +31 -15
- package/scss/components/Datagrid/styles/_draggableElement.scss +26 -9
- package/scss/components/Datagrid/styles/_index.scss +1 -0
- package/scss/components/Datagrid/styles/_useActionsColumn.scss +14 -0
- package/scss/components/Datagrid/styles/_useExpandedRow.scss +37 -9
- package/scss/components/Datagrid/styles/_useInlineEdit.scss +419 -0
- package/scss/components/Datagrid/styles/_useNestedRows.scss +16 -1
- package/scss/components/Datagrid/styles/_useStickyColumn.scss +31 -2
- package/scss/components/Datagrid/styles/addons/_CustomizeColumnsModal.scss +47 -6
- package/scss/components/Datagrid/styles/addons/_RowSizeDropdown.scss +9 -1
- package/scss/components/EditUpdateCards/_carbon-imports.scss +9 -0
- package/scss/components/EditUpdateCards/_edit-update-cards.scss +85 -0
- package/scss/components/EditUpdateCards/_index-with-carbon.scss +9 -0
- package/scss/components/EditUpdateCards/_index.scss +8 -0
- package/scss/components/EditUpdateCards/_storybook-styles.scss +55 -0
- package/scss/components/InlineEdit/_inline-edit.scss +4 -2
- package/scss/components/NotificationsPanel/_notifications-panel.scss +3 -6
- package/scss/components/PageHeader/_page-header.scss +4 -0
- package/scss/components/RemoveModal/_remove-modal.scss +0 -4
- package/scss/components/SidePanel/_side-panel.scss +3 -82
- package/scss/components/SidePanel/_storybook-styles.scss +6 -1
- package/scss/components/Tearsheet/_tearsheet.scss +2 -2
- package/scss/components/_index-released-only.scss +1 -0
- package/scss/components/_index-with-carbon.scss +1 -0
- package/scss/components/_index.scss +1 -0
@@ -0,0 +1,558 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
|
+
|
5
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
6
|
+
|
7
|
+
Object.defineProperty(exports, "__esModule", {
|
8
|
+
value: true
|
9
|
+
});
|
10
|
+
exports.InlineEditCell = void 0;
|
11
|
+
|
12
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
13
|
+
|
14
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
15
|
+
|
16
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
17
|
+
|
18
|
+
var _react = _interopRequireWildcard(require("react"));
|
19
|
+
|
20
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
21
|
+
|
22
|
+
var _react2 = require("@carbon/react");
|
23
|
+
|
24
|
+
var _icons = require("@carbon/react/icons");
|
25
|
+
|
26
|
+
var _InlineEditButton = require("../InlineEditButton");
|
27
|
+
|
28
|
+
var _settings = require("../../../../../../settings");
|
29
|
+
|
30
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
31
|
+
|
32
|
+
var _InlineEditContext = require("../InlineEditContext");
|
33
|
+
|
34
|
+
var _hooks = require("../../../../../../global/js/hooks");
|
35
|
+
|
36
|
+
var _propsHelper = require("../../../../../../global/js/utils/props-helper");
|
37
|
+
|
38
|
+
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); }
|
39
|
+
|
40
|
+
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; }
|
41
|
+
|
42
|
+
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; }
|
43
|
+
|
44
|
+
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; }
|
45
|
+
|
46
|
+
var blockClass = "".concat(_settings.pkg.prefix, "--datagrid");
|
47
|
+
|
48
|
+
var InlineEditCell = function InlineEditCell(_ref) {
|
49
|
+
var _config$validator, _cx3;
|
50
|
+
|
51
|
+
var cell = _ref.cell,
|
52
|
+
config = _ref.config,
|
53
|
+
instance = _ref.instance,
|
54
|
+
_ref$placeholder = _ref.placeholder,
|
55
|
+
placeholder = _ref$placeholder === void 0 ? '' : _ref$placeholder,
|
56
|
+
tabIndex = _ref.tabIndex,
|
57
|
+
value = _ref.value,
|
58
|
+
nonEditCell = _ref.nonEditCell,
|
59
|
+
totalInlineEditColumns = _ref.totalInlineEditColumns,
|
60
|
+
type = _ref.type;
|
61
|
+
var columnId = cell.column.id;
|
62
|
+
var columnIndex = instance.columns.findIndex(function (col) {
|
63
|
+
return col.id === columnId;
|
64
|
+
});
|
65
|
+
var cellId = "column-".concat(columnIndex, "-row-").concat(cell.row.index);
|
66
|
+
var totalColumns = instance.columns.length;
|
67
|
+
|
68
|
+
var _useContext = (0, _react.useContext)(_InlineEditContext.InlineEditContext),
|
69
|
+
state = _useContext.state,
|
70
|
+
dispatch = _useContext.dispatch;
|
71
|
+
|
72
|
+
var _useState = (0, _react.useState)(false),
|
73
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
74
|
+
inEditMode = _useState2[0],
|
75
|
+
setInEditMode = _useState2[1];
|
76
|
+
|
77
|
+
var _useState3 = (0, _react.useState)(value),
|
78
|
+
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
79
|
+
cellValue = _useState4[0],
|
80
|
+
setCellValue = _useState4[1];
|
81
|
+
|
82
|
+
var _useState5 = (0, _react.useState)(),
|
83
|
+
_useState6 = (0, _slicedToArray2.default)(_useState5, 2),
|
84
|
+
initialValue = _useState6[0],
|
85
|
+
setInitialValue = _useState6[1];
|
86
|
+
|
87
|
+
var _useState7 = (0, _react.useState)(),
|
88
|
+
_useState8 = (0, _slicedToArray2.default)(_useState7, 2),
|
89
|
+
cellLabel = _useState8[0],
|
90
|
+
setCellLabel = _useState8[1];
|
91
|
+
|
92
|
+
var activeCellId = state.activeCellId,
|
93
|
+
editId = state.editId;
|
94
|
+
var previousState = (0, _hooks.usePreviousValue)({
|
95
|
+
editId: editId,
|
96
|
+
activeCellId: activeCellId
|
97
|
+
});
|
98
|
+
|
99
|
+
var _ref2 = config || {},
|
100
|
+
inputProps = _ref2.inputProps;
|
101
|
+
|
102
|
+
var textInputRef = (0, _react.useRef)();
|
103
|
+
var numberInputRef = (0, _react.useRef)();
|
104
|
+
var dropdownRef = (0, _react.useRef)();
|
105
|
+
var datePickerRef = (0, _react.useRef)();
|
106
|
+
var outerButtonElement = (0, _react.useRef)();
|
107
|
+
(0, _react.useEffect)(function () {
|
108
|
+
setInitialValue(value);
|
109
|
+
var columnId = cell.column.id;
|
110
|
+
var columnLabel = instance.columns.find(function (item) {
|
111
|
+
return item.id === columnId;
|
112
|
+
});
|
113
|
+
setCellLabel(typeof columnLabel.Header === 'string' ? columnLabel.Header : 'Inline edit cell label'); // eslint-disable-next-line react-hooks/exhaustive-deps
|
114
|
+
}, []); // Reverts cellValue back to initialValue when exiting edit mode via clicking outside
|
115
|
+
// of the cell (either on a regular cell or clicking into another inline edit cell) and the
|
116
|
+
// edit input is in an invalid state
|
117
|
+
|
118
|
+
(0, _react.useEffect)(function () {
|
119
|
+
if ((previousState === null || previousState === void 0 ? void 0 : previousState.editId) === cellId && !editId || (previousState === null || previousState === void 0 ? void 0 : previousState.editId) === cellId && cellId !== editId) {
|
120
|
+
var _ref3 = config || {},
|
121
|
+
validator = _ref3.validator;
|
122
|
+
|
123
|
+
var isInvalid = validator === null || validator === void 0 ? void 0 : validator(cellValue);
|
124
|
+
|
125
|
+
if (isInvalid) {
|
126
|
+
setCellValue(initialValue);
|
127
|
+
saveCellData(initialValue);
|
128
|
+
return;
|
129
|
+
}
|
130
|
+
}
|
131
|
+
}, [previousState === null || previousState === void 0 ? void 0 : previousState.editId, editId, cellId, cellValue, config, initialValue, saveCellData]); // If you are in edit mode and click outside of the cell,
|
132
|
+
// this changes the cell back to the InlineEditButton
|
133
|
+
|
134
|
+
(0, _react.useEffect)(function () {
|
135
|
+
if (activeCellId !== cellId || !editId) {
|
136
|
+
setInEditMode(false);
|
137
|
+
}
|
138
|
+
|
139
|
+
if (activeCellId === cellId && editId === cellId && !nonEditCell) {
|
140
|
+
setInEditMode(true);
|
141
|
+
saveCellData(cellValue);
|
142
|
+
}
|
143
|
+
}, [activeCellId, cellId, nonEditCell, editId, cellValue, saveCellData]);
|
144
|
+
|
145
|
+
var openDropdown = function openDropdown(type) {
|
146
|
+
// *****
|
147
|
+
// Only added this querySelector because v11 Datepicker isn't forwarding the ref which breaks how we were handling this in v10
|
148
|
+
// *****
|
149
|
+
var datePickerInputElement = document.querySelector("#".concat(blockClass, "__inline-edit--date-picker--").concat(cell.row.index));
|
150
|
+
var dropdownTrigger = type === 'selection' ? dropdownRef === null || dropdownRef === void 0 ? void 0 : dropdownRef.current : datePickerInputElement;
|
151
|
+
dropdownTrigger.click();
|
152
|
+
|
153
|
+
if (type === 'date') {
|
154
|
+
dropdownTrigger === null || dropdownTrigger === void 0 ? void 0 : dropdownTrigger.focus();
|
155
|
+
}
|
156
|
+
}; // Re-initializes initialValue if clicking outside of a cell that was previously
|
157
|
+
// in edit mode, otherwise `initialValue` becomes stale
|
158
|
+
|
159
|
+
|
160
|
+
(0, _react.useEffect)(function () {
|
161
|
+
if ((previousState === null || previousState === void 0 ? void 0 : previousState.editId) === cellId && (previousState === null || previousState === void 0 ? void 0 : previousState.activeCellId) === cellId && activeCellId !== cellId) {
|
162
|
+
setInitialValue(cellValue);
|
163
|
+
}
|
164
|
+
}, [previousState, cellId, cellValue, activeCellId]);
|
165
|
+
|
166
|
+
var handleInlineCellClick = function handleInlineCellClick() {
|
167
|
+
if (!inEditMode) {
|
168
|
+
dispatch({
|
169
|
+
type: 'ENTER_EDIT_MODE',
|
170
|
+
payload: {
|
171
|
+
activeCellId: cellId,
|
172
|
+
editId: cellId
|
173
|
+
}
|
174
|
+
});
|
175
|
+
setInEditMode(true);
|
176
|
+
setTimeout(function () {
|
177
|
+
if (type === 'selection' || type === 'date') {
|
178
|
+
openDropdown(type);
|
179
|
+
}
|
180
|
+
}, 1);
|
181
|
+
}
|
182
|
+
};
|
183
|
+
|
184
|
+
var rowSize = instance.rowSize,
|
185
|
+
onDataUpdate = instance.onDataUpdate; // Auto focus text input when entering edit mode
|
186
|
+
|
187
|
+
(0, _react.useEffect)(function () {
|
188
|
+
if (inEditMode) {
|
189
|
+
if (type === 'text') {
|
190
|
+
textInputRef.current.focus();
|
191
|
+
}
|
192
|
+
|
193
|
+
if (type === 'number') {
|
194
|
+
numberInputRef.current.focus();
|
195
|
+
}
|
196
|
+
}
|
197
|
+
}, [inEditMode, type]); // Initialize cellValue from value prop
|
198
|
+
|
199
|
+
(0, _react.useEffect)(function () {
|
200
|
+
setCellValue(value);
|
201
|
+
}, [value]); // Saves the new cell data, onDataUpdate is a required function to be
|
202
|
+
// passed to useDatagrid when using useInlineEdit
|
203
|
+
|
204
|
+
var saveCellData = (0, _react.useCallback)(function (newValue) {
|
205
|
+
var columnId = cell.column.id;
|
206
|
+
var rowIndex = cell.row.index;
|
207
|
+
onDataUpdate(function (prev) {
|
208
|
+
return prev.map(function (row, index) {
|
209
|
+
if (index === rowIndex) {
|
210
|
+
return _objectSpread(_objectSpread({}, prev[rowIndex]), {}, (0, _defineProperty2.default)({}, columnId, newValue));
|
211
|
+
}
|
212
|
+
|
213
|
+
return row;
|
214
|
+
});
|
215
|
+
});
|
216
|
+
}, [cell, onDataUpdate]);
|
217
|
+
|
218
|
+
var sendFocusBackToGrid = function sendFocusBackToGrid() {
|
219
|
+
// Allows the onKeyDown listener to go back to the entire grid area
|
220
|
+
var inlineEditArea = document.querySelector("#".concat(instance.tableId, " .").concat(blockClass, "__table-with-inline-edit"));
|
221
|
+
inlineEditArea.focus();
|
222
|
+
};
|
223
|
+
|
224
|
+
var getNewCellId = function getNewCellId(key) {
|
225
|
+
var totalRows = instance.rows.length;
|
226
|
+
var newCellId = key === 'Enter' ? "column-".concat(columnIndex, "-row-").concat(cell.row.index < totalRows - 1 ? cell.row.index + 1 : cell.row.index) : "column-".concat(columnIndex < instance.columns.length - 1 ? columnIndex + 1 : columnIndex, "-row-").concat(cell.row.index);
|
227
|
+
return newCellId;
|
228
|
+
};
|
229
|
+
|
230
|
+
var handleKeyDown = function handleKeyDown(event) {
|
231
|
+
var key = event.key;
|
232
|
+
|
233
|
+
switch (key) {
|
234
|
+
// Save cell contents to data
|
235
|
+
case 'Tab':
|
236
|
+
case 'Enter':
|
237
|
+
{
|
238
|
+
if (inEditMode) {
|
239
|
+
// Dropdown saves are handled in the Dropdown's/DatePicker's onChange prop
|
240
|
+
if (type === 'selection' || type === 'date') {
|
241
|
+
return;
|
242
|
+
}
|
243
|
+
|
244
|
+
var _ref4 = config || {},
|
245
|
+
validator = _ref4.validator;
|
246
|
+
|
247
|
+
var isInvalid = validator === null || validator === void 0 ? void 0 : validator(cellValue); // If an invalid state is detected, Tab/Enter should not do anything
|
248
|
+
// until the input has a valid state once again
|
249
|
+
|
250
|
+
if (isInvalid) {
|
251
|
+
return;
|
252
|
+
}
|
253
|
+
|
254
|
+
var newCellId = getNewCellId(key);
|
255
|
+
saveCellData(cellValue);
|
256
|
+
setInitialValue(cellValue);
|
257
|
+
dispatch({
|
258
|
+
type: 'EXIT_EDIT_MODE',
|
259
|
+
payload: newCellId
|
260
|
+
});
|
261
|
+
setInEditMode(false);
|
262
|
+
sendFocusBackToGrid();
|
263
|
+
}
|
264
|
+
|
265
|
+
break;
|
266
|
+
}
|
267
|
+
|
268
|
+
case 'Escape':
|
269
|
+
{
|
270
|
+
if (inEditMode) {
|
271
|
+
dispatch({
|
272
|
+
type: 'EXIT_EDIT_MODE',
|
273
|
+
payload: cellId
|
274
|
+
});
|
275
|
+
setCellValue(initialValue);
|
276
|
+
saveCellData(initialValue);
|
277
|
+
setInEditMode(false);
|
278
|
+
sendFocusBackToGrid();
|
279
|
+
}
|
280
|
+
|
281
|
+
break;
|
282
|
+
}
|
283
|
+
|
284
|
+
default:
|
285
|
+
return;
|
286
|
+
}
|
287
|
+
};
|
288
|
+
|
289
|
+
var addActiveState = function addActiveState() {
|
290
|
+
dispatch({
|
291
|
+
type: 'UPDATE_ACTIVE_CELL_ID',
|
292
|
+
payload: cellId
|
293
|
+
});
|
294
|
+
};
|
295
|
+
|
296
|
+
var renderDropdownItem = function renderDropdownItem(item) {
|
297
|
+
var includesIcon = !!(item !== null && item !== void 0 && item.icon);
|
298
|
+
return includesIcon ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(item.icon), /*#__PURE__*/_react.default.createElement("span", {
|
299
|
+
className: (0, _classnames.default)("".concat(blockClass, "__inline-edit--select-item"))
|
300
|
+
}, item === null || item === void 0 ? void 0 : item.text)) : item === null || item === void 0 ? void 0 : item.text;
|
301
|
+
};
|
302
|
+
|
303
|
+
var renderSelectCell = function renderSelectCell() {
|
304
|
+
var _ref5 = config || {},
|
305
|
+
inputProps = _ref5.inputProps;
|
306
|
+
|
307
|
+
return /*#__PURE__*/_react.default.createElement(_react2.Dropdown, (0, _extends2.default)({
|
308
|
+
id: cellId,
|
309
|
+
label: cellLabel || 'Dropdown menu options',
|
310
|
+
ariaLabel: cellLabel || 'Dropdown menu options'
|
311
|
+
}, inputProps, {
|
312
|
+
hideLabel: true,
|
313
|
+
style: {
|
314
|
+
width: cell.column.totalWidth
|
315
|
+
},
|
316
|
+
className: (0, _classnames.default)("".concat(blockClass, "__inline-edit--select"), (0, _defineProperty2.default)({}, "".concat(blockClass, "__inline-edit--select-").concat(rowSize), rowSize)),
|
317
|
+
items: (inputProps === null || inputProps === void 0 ? void 0 : inputProps.items) || [],
|
318
|
+
initialSelectedItem: cell.value,
|
319
|
+
itemToElement: function itemToElement(item) {
|
320
|
+
return renderDropdownItem(item);
|
321
|
+
},
|
322
|
+
renderSelectedItem: function renderSelectedItem(item) {
|
323
|
+
return renderDropdownItem(item);
|
324
|
+
},
|
325
|
+
onChange: function onChange(item) {
|
326
|
+
var _inputProps$onChange;
|
327
|
+
|
328
|
+
var newCellId = getNewCellId('Enter');
|
329
|
+
saveCellData(item.selectedItem);
|
330
|
+
setCellValue(item.selectedItem);
|
331
|
+
dispatch({
|
332
|
+
type: 'EXIT_EDIT_MODE',
|
333
|
+
payload: newCellId
|
334
|
+
});
|
335
|
+
setInEditMode(false);
|
336
|
+
sendFocusBackToGrid();
|
337
|
+
inputProps === null || inputProps === void 0 ? void 0 : (_inputProps$onChange = inputProps.onChange) === null || _inputProps$onChange === void 0 ? void 0 : _inputProps$onChange.call(inputProps, item.selectedItem);
|
338
|
+
},
|
339
|
+
downshiftProps: {
|
340
|
+
onStateChange: function onStateChange(downshiftState) {
|
341
|
+
var _ref6 = downshiftState || {},
|
342
|
+
isOpen = _ref6.isOpen; // !isOpen does not work in this case because a state change occurs on hover of the
|
343
|
+
// menu items and isOpen is changed to undefined which causes dispatch to be called unexpectedly
|
344
|
+
|
345
|
+
|
346
|
+
if (isOpen === false) {
|
347
|
+
dispatch({
|
348
|
+
type: 'EXIT_EDIT_MODE',
|
349
|
+
payload: cellId
|
350
|
+
});
|
351
|
+
setInEditMode(false);
|
352
|
+
sendFocusBackToGrid();
|
353
|
+
}
|
354
|
+
}
|
355
|
+
},
|
356
|
+
ref: dropdownRef
|
357
|
+
}));
|
358
|
+
};
|
359
|
+
|
360
|
+
var setRenderIcon = function setRenderIcon() {
|
361
|
+
if (type === 'text') {
|
362
|
+
return function (props) {
|
363
|
+
return /*#__PURE__*/_react.default.createElement(_icons.Edit, (0, _extends2.default)({
|
364
|
+
size: 16
|
365
|
+
}, props));
|
366
|
+
};
|
367
|
+
}
|
368
|
+
|
369
|
+
if (type === 'number') {
|
370
|
+
return function (props) {
|
371
|
+
return /*#__PURE__*/_react.default.createElement(_icons.CaretSort, (0, _extends2.default)({
|
372
|
+
size: 16
|
373
|
+
}, props));
|
374
|
+
};
|
375
|
+
}
|
376
|
+
|
377
|
+
if (type === 'selection') {
|
378
|
+
return function (props) {
|
379
|
+
return /*#__PURE__*/_react.default.createElement(_icons.ChevronDown, (0, _extends2.default)({
|
380
|
+
size: 16
|
381
|
+
}, props));
|
382
|
+
};
|
383
|
+
}
|
384
|
+
|
385
|
+
if (type === 'date') {
|
386
|
+
return function (props) {
|
387
|
+
return /*#__PURE__*/_react.default.createElement(_icons.Calendar, (0, _extends2.default)({
|
388
|
+
size: 16
|
389
|
+
}, props));
|
390
|
+
};
|
391
|
+
}
|
392
|
+
};
|
393
|
+
|
394
|
+
var renderDateCell = function renderDateCell() {
|
395
|
+
var _config$inputProps, _outerButtonElement$c;
|
396
|
+
|
397
|
+
var datePickerPreparedProps = (0, _propsHelper.prepareProps)(config.inputProps, ['datePickerInputProps']);
|
398
|
+
var datePickerInputProps = config === null || config === void 0 ? void 0 : (_config$inputProps = config.inputProps) === null || _config$inputProps === void 0 ? void 0 : _config$inputProps.datePickerInputProps;
|
399
|
+
return /*#__PURE__*/_react.default.createElement(_react2.DatePicker, (0, _extends2.default)({}, datePickerPreparedProps, {
|
400
|
+
appendTo: outerButtonElement === null || outerButtonElement === void 0 ? void 0 : (_outerButtonElement$c = outerButtonElement.current) === null || _outerButtonElement$c === void 0 ? void 0 : _outerButtonElement$c.parentElement,
|
401
|
+
ref: datePickerRef,
|
402
|
+
style: {
|
403
|
+
width: cell.column.totalWidth
|
404
|
+
},
|
405
|
+
datePickerType: "single",
|
406
|
+
className: (0, _classnames.default)("".concat(blockClass, "__inline-edit--date"), (0, _defineProperty2.default)({}, "".concat(blockClass, "__inline-edit--date-").concat(rowSize), rowSize)),
|
407
|
+
onChange: function onChange(newDate) {
|
408
|
+
var _datePickerPreparedPr;
|
409
|
+
|
410
|
+
var newDateObj = newDate[0];
|
411
|
+
datePickerPreparedProps === null || datePickerPreparedProps === void 0 ? void 0 : (_datePickerPreparedPr = datePickerPreparedProps.onChange) === null || _datePickerPreparedPr === void 0 ? void 0 : _datePickerPreparedPr.call(datePickerPreparedProps, newDateObj, cell);
|
412
|
+
var newCellId = getNewCellId('Enter');
|
413
|
+
saveCellData(newDateObj);
|
414
|
+
setCellValue(newDateObj); // To handle the interaction of the masked input when the DatePicker and updating
|
415
|
+
|
416
|
+
setTimeout(function () {
|
417
|
+
setInEditMode(false);
|
418
|
+
sendFocusBackToGrid();
|
419
|
+
dispatch({
|
420
|
+
type: 'EXIT_EDIT_MODE',
|
421
|
+
payload: newCellId
|
422
|
+
});
|
423
|
+
}, 1);
|
424
|
+
},
|
425
|
+
value: cell.value
|
426
|
+
}), /*#__PURE__*/_react.default.createElement(_react2.DatePickerInput, (0, _extends2.default)({}, datePickerInputProps, {
|
427
|
+
style: {
|
428
|
+
position: 'static'
|
429
|
+
},
|
430
|
+
placeholder: (datePickerInputProps === null || datePickerInputProps === void 0 ? void 0 : datePickerInputProps.placeholder) || 'mm/dd/yyyy',
|
431
|
+
labelText: (datePickerInputProps === null || datePickerInputProps === void 0 ? void 0 : datePickerInputProps.labelText) || cellLabel || 'Set date',
|
432
|
+
id: "".concat(blockClass, "__inline-edit--date-picker--").concat(cell.row.index),
|
433
|
+
hideLabel: true
|
434
|
+
})));
|
435
|
+
}; // Ensures that months and days are all 2 digits, prefixes 0 if `num` is a single digit
|
436
|
+
|
437
|
+
|
438
|
+
var padTo2Digits = function padTo2Digits(num) {
|
439
|
+
return num.toString().padStart(2, '0');
|
440
|
+
};
|
441
|
+
|
442
|
+
var buildDate = function buildDate(value) {
|
443
|
+
if (value instanceof Date) {
|
444
|
+
var _config$dateFormat = config.dateFormat,
|
445
|
+
dateFormat = _config$dateFormat === void 0 ? 'm/d/Y' : _config$dateFormat;
|
446
|
+
var maskedFullYear = value.getFullYear();
|
447
|
+
var maskedMonth = padTo2Digits(value.getMonth() + 1);
|
448
|
+
var maskedDay = padTo2Digits(value.getDate());
|
449
|
+
|
450
|
+
if (dateFormat === 'm/d/Y' || dateFormat === 'm/d/y') {
|
451
|
+
return [maskedMonth, maskedDay, maskedFullYear].join('/');
|
452
|
+
}
|
453
|
+
|
454
|
+
if (dateFormat === 'd/m/Y' || dateFormat === 'd/m/y') {
|
455
|
+
return [maskedDay, maskedMonth, maskedFullYear].join('/');
|
456
|
+
}
|
457
|
+
}
|
458
|
+
|
459
|
+
return null;
|
460
|
+
};
|
461
|
+
|
462
|
+
var renderNumberInput = function renderNumberInput() {
|
463
|
+
var _ref7 = config || {},
|
464
|
+
validator = _ref7.validator;
|
465
|
+
|
466
|
+
return /*#__PURE__*/_react.default.createElement(_react2.NumberInput, (0, _extends2.default)({
|
467
|
+
placeholder: placeholder,
|
468
|
+
label: cellLabel
|
469
|
+
}, inputProps, {
|
470
|
+
id: cellId,
|
471
|
+
hideLabel: true,
|
472
|
+
defaultValue: cellValue,
|
473
|
+
invalid: validator === null || validator === void 0 ? void 0 : validator(cellValue),
|
474
|
+
invalidText: (inputProps === null || inputProps === void 0 ? void 0 : inputProps.invalidText) || 'Provide missing invalidText',
|
475
|
+
onChange: function onChange(event, _ref8) {
|
476
|
+
var value = _ref8.value;
|
477
|
+
setCellValue(value);
|
478
|
+
|
479
|
+
if (inputProps.onChange) {
|
480
|
+
inputProps.onChange(value);
|
481
|
+
}
|
482
|
+
},
|
483
|
+
ref: numberInputRef
|
484
|
+
}));
|
485
|
+
};
|
486
|
+
|
487
|
+
var renderTextInput = function renderTextInput() {
|
488
|
+
var _ref9 = config || {},
|
489
|
+
validator = _ref9.validator;
|
490
|
+
|
491
|
+
var isInvalid = validator === null || validator === void 0 ? void 0 : validator(cellValue);
|
492
|
+
return /*#__PURE__*/_react.default.createElement(_react2.TextInput, (0, _extends2.default)({
|
493
|
+
labelText: cellLabel,
|
494
|
+
placeholder: placeholder
|
495
|
+
}, inputProps, {
|
496
|
+
id: cellId,
|
497
|
+
hideLabel: true,
|
498
|
+
defaultValue: cellValue,
|
499
|
+
invalid: isInvalid,
|
500
|
+
invalidText: (inputProps === null || inputProps === void 0 ? void 0 : inputProps.invalidText) || 'Provide missing invalidText',
|
501
|
+
onChange: function onChange(event) {
|
502
|
+
setCellValue(event.target.value);
|
503
|
+
|
504
|
+
if (inputProps.onChange) {
|
505
|
+
inputProps.onChange(event.target.value);
|
506
|
+
}
|
507
|
+
},
|
508
|
+
ref: textInputRef
|
509
|
+
}));
|
510
|
+
};
|
511
|
+
|
512
|
+
return (
|
513
|
+
/*#__PURE__*/
|
514
|
+
// eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions
|
515
|
+
_react.default.createElement("div", {
|
516
|
+
ref: outerButtonElement,
|
517
|
+
"data-cell-id": cellId,
|
518
|
+
"data-column-index": columnIndex,
|
519
|
+
"data-row-index": cell.row.index,
|
520
|
+
"data-disabled": nonEditCell,
|
521
|
+
"data-inline-type": type,
|
522
|
+
onClick: !nonEditCell ? handleInlineCellClick : addActiveState,
|
523
|
+
onKeyDown: !nonEditCell ? handleKeyDown : null,
|
524
|
+
className: (0, _classnames.default)("".concat(blockClass, "__inline-edit--outer-cell-button"), (_cx3 = {}, (0, _defineProperty2.default)(_cx3, "".concat(blockClass, "__inline-edit--outer-cell-button--").concat(rowSize), rowSize), (0, _defineProperty2.default)(_cx3, "".concat(blockClass, "__inline-edit--outer-cell-button--lg"), !rowSize), (0, _defineProperty2.default)(_cx3, "".concat(blockClass, "__inline-edit--outer-cell-button--invalid"), config === null || config === void 0 ? void 0 : (_config$validator = config.validator) === null || _config$validator === void 0 ? void 0 : _config$validator.call(config, cellValue)), _cx3))
|
525
|
+
}, !inEditMode && /*#__PURE__*/_react.default.createElement(_InlineEditButton.InlineEditButton, {
|
526
|
+
isActiveCell: cellId === activeCellId,
|
527
|
+
renderIcon: setRenderIcon(),
|
528
|
+
label: type === 'selection' ? value.text : type === 'date' ? buildDate(value) : value,
|
529
|
+
labelIcon: (value === null || value === void 0 ? void 0 : value.icon) || null,
|
530
|
+
placeholder: placeholder,
|
531
|
+
tabIndex: tabIndex,
|
532
|
+
nonEditCell: nonEditCell,
|
533
|
+
columnConfig: cell.column,
|
534
|
+
totalInlineEditColumns: totalInlineEditColumns,
|
535
|
+
totalColumns: totalColumns,
|
536
|
+
type: type
|
537
|
+
}), !nonEditCell && inEditMode && cellId === activeCellId && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, type === 'text' && renderTextInput(), type === 'number' && renderNumberInput(), type === 'selection' && renderSelectCell(), type === 'date' && renderDateCell()))
|
538
|
+
);
|
539
|
+
};
|
540
|
+
|
541
|
+
exports.InlineEditCell = InlineEditCell;
|
542
|
+
InlineEditCell.propTypes = {
|
543
|
+
cell: _propTypes.default.object,
|
544
|
+
config: _propTypes.default.object,
|
545
|
+
instance: _propTypes.default.shape({
|
546
|
+
columns: _propTypes.default.arrayOf(_propTypes.default.object),
|
547
|
+
onDataUpdate: _propTypes.default.func,
|
548
|
+
rows: _propTypes.default.arrayOf(_propTypes.default.object),
|
549
|
+
rowSize: _propTypes.default.string,
|
550
|
+
tableId: _propTypes.default.string
|
551
|
+
}),
|
552
|
+
nonEditCell: _propTypes.default.bool,
|
553
|
+
placeholder: _propTypes.default.string,
|
554
|
+
tabIndex: _propTypes.default.number,
|
555
|
+
totalInlineEditColumns: _propTypes.default.number,
|
556
|
+
type: _propTypes.default.oneOf(['text', 'number', 'selection', 'date']),
|
557
|
+
value: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.node, _propTypes.default.object])
|
558
|
+
};
|
@@ -0,0 +1,13 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
Object.defineProperty(exports, "InlineEditCell", {
|
7
|
+
enumerable: true,
|
8
|
+
get: function get() {
|
9
|
+
return _InlineEditCell.InlineEditCell;
|
10
|
+
}
|
11
|
+
});
|
12
|
+
|
13
|
+
var _InlineEditCell = require("./InlineEditCell");
|