@carbon/ibm-products 2.43.2-canary.4 → 2.43.2-canary.42
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 +52 -3
- package/css/index-full-carbon.css.map +1 -1
- package/css/index-full-carbon.min.css +1 -1
- package/css/index-full-carbon.min.css.map +1 -1
- package/css/index-without-carbon-released-only.css +12 -0
- package/css/index-without-carbon-released-only.css.map +1 -1
- package/css/index-without-carbon-released-only.min.css +1 -1
- package/css/index-without-carbon-released-only.min.css.map +1 -1
- package/css/index-without-carbon.css +52 -3
- package/css/index-without-carbon.css.map +1 -1
- package/css/index-without-carbon.min.css +1 -1
- package/css/index-without-carbon.min.css.map +1 -1
- package/css/index.css +52 -3
- package/css/index.css.map +1 -1
- package/css/index.min.css +1 -1
- package/css/index.min.css.map +1 -1
- package/es/components/ConditionBuilder/ConditionBlock/ConditionBlock.js +23 -21
- package/es/components/ConditionBuilder/ConditionBuilder.js +67 -20
- package/es/components/ConditionBuilder/ConditionBuilderActions/ConditionBuilderActions.d.ts +15 -0
- package/es/components/ConditionBuilder/ConditionBuilderActions/ConditionBuilderActions.js +129 -0
- package/es/components/ConditionBuilder/ConditionBuilderAdd/ConditionBuilderAdd.js +6 -4
- package/es/components/ConditionBuilder/ConditionBuilderButton/ConditionBuilderButton.d.ts +5 -1
- package/es/components/ConditionBuilder/ConditionBuilderButton/ConditionBuilderButton.js +16 -4
- package/es/components/ConditionBuilder/ConditionBuilderConnector/ConditionConnector.js +2 -2
- package/es/components/ConditionBuilder/ConditionBuilderConnector/GroupConnector.js +2 -2
- package/es/components/ConditionBuilder/ConditionBuilderContent/ConditionBuilderContent.d.ts +9 -11
- package/es/components/ConditionBuilder/ConditionBuilderContent/ConditionBuilderContent.js +36 -32
- package/es/components/ConditionBuilder/ConditionBuilderContext/ConditionBuilderProvider.d.ts +0 -1
- package/es/components/ConditionBuilder/ConditionBuilderContext/ConditionBuilderProvider.js +7 -2
- package/es/components/ConditionBuilder/ConditionBuilderContext/DataConfigs.d.ts +6 -1
- package/es/components/ConditionBuilder/ConditionBuilderContext/DataConfigs.js +18 -10
- package/es/components/ConditionBuilder/ConditionBuilderContext/translationObject.d.ts +39 -36
- package/es/components/ConditionBuilder/ConditionBuilderContext/translationObject.js +12 -10
- package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItem.d.ts +1 -1
- package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItem.js +24 -16
- package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemNumber/ConditionBuilderItemNumber.js +19 -4
- package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemOption/ItemOption.d.ts +13 -0
- package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemOption/ItemOption.js +109 -0
- package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemOption/{ConditionBuilderItemOption.d.ts → ItemOptionForValueField.d.ts} +2 -2
- package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemOption/{ConditionBuilderItemOption.js → ItemOptionForValueField.js} +58 -33
- package/es/components/ConditionBuilder/ConditionGroupBuilder/ConditionGroupBuilder.js +4 -6
- package/es/components/ConditionBuilder/ConditionPreview/ConditionPreview.js +14 -5
- package/es/components/ConditionBuilder/utils/handleKeyboardEvents.js +1 -2
- package/es/components/ConditionBuilder/utils/util.d.ts +1 -0
- package/es/components/ConditionBuilder/utils/util.js +16 -1
- package/es/components/DataSpreadsheet/DataSpreadsheet.d.ts +12 -0
- package/es/components/DataSpreadsheet/DataSpreadsheet.js +51 -19
- package/es/components/DataSpreadsheet/DataSpreadsheetBody.d.ts +21 -1
- package/es/components/DataSpreadsheet/DataSpreadsheetBody.js +40 -8
- package/es/components/DataSpreadsheet/DataSpreadsheetHeader.d.ts +8 -0
- package/es/components/DataSpreadsheet/DataSpreadsheetHeader.js +20 -6
- package/es/components/DataSpreadsheet/hooks/useSpreadsheetMouseMove.js +4 -1
- package/es/components/DataSpreadsheet/hooks/useSpreadsheetMouseUp.d.ts +3 -1
- package/es/components/DataSpreadsheet/hooks/useSpreadsheetMouseUp.js +15 -3
- package/es/components/DataSpreadsheet/types/index.d.ts +1 -1
- package/es/components/DataSpreadsheet/utils/moveColumnIndicatorLine.js +34 -2
- package/es/components/Datagrid/Datagrid/Datagrid.d.ts +0 -4
- package/es/components/Datagrid/Datagrid/Datagrid.js +4 -9
- package/es/components/Datagrid/Datagrid/DatagridContent.js +1 -1
- package/es/components/Datagrid/Datagrid/DatagridHeaderRow.js +23 -8
- package/es/components/Datagrid/Datagrid/DatagridRow.js +21 -8
- package/es/components/Datagrid/Datagrid/addons/Filtering/FilterFlyout.js +6 -1
- package/es/components/Datagrid/Datagrid/addons/Filtering/FilterPanel.js +6 -1
- package/es/components/Datagrid/Datagrid/addons/Filtering/FilterProvider.d.ts +3 -1
- package/es/components/Datagrid/Datagrid/addons/Filtering/FilterProvider.js +6 -3
- package/es/components/Datagrid/Datagrid/addons/Filtering/hooks/useFilters.d.ts +1 -1
- package/es/components/Datagrid/Datagrid/addons/Filtering/hooks/useFilters.js +21 -16
- package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditButton/InlineEditButton.js +2 -3
- package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditCell/InlineEditCell.js +74 -11
- package/es/components/Datagrid/Datagrid/addons/InlineEdit/handleGridKeyPress.js +10 -2
- package/es/components/Datagrid/types/index.d.ts +37 -4
- package/es/components/Datagrid/useActionsColumn.d.ts +8 -1
- package/es/components/Datagrid/useActionsColumn.js +7 -6
- package/es/components/Datagrid/useColumnRightAlign.d.ts +8 -1
- package/es/components/Datagrid/useColumnRightAlign.js +4 -3
- package/es/components/Datagrid/useCustomizeColumns.d.ts +8 -1
- package/es/components/Datagrid/useCustomizeColumns.js +4 -3
- package/es/components/Datagrid/useDefaultStringRenderer.js +0 -1
- package/es/components/Datagrid/useInlineEdit.js +12 -2
- package/es/components/Datagrid/useNestedRowExpander.js +1 -3
- package/es/components/Datagrid/useNestedRows.js +32 -13
- package/es/components/Datagrid/useRowExpander.js +1 -3
- package/es/components/Decorator/Decorator.js +2 -1
- package/es/components/DecoratorBase/DecoratorBase.js +3 -5
- package/es/components/DecoratorDualButton/DecoratorDualButton.js +2 -1
- package/es/components/DecoratorLink/DecoratorLink.js +2 -1
- package/es/components/DecoratorSingleButton/DecoratorSingleButton.js +2 -1
- package/es/components/EditTearsheet/EditTearsheet.d.ts +5 -1
- package/es/components/EditTearsheet/EditTearsheet.js +0 -1
- package/es/components/EditTearsheet/EditTearsheetForm.d.ts +45 -2
- package/es/components/EditTearsheet/EditTearsheetForm.js +3 -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/PageHeader/PageHeader.js +1 -0
- package/es/components/RemoveModal/RemoveModal.d.ts +4 -0
- package/es/components/RemoveModal/RemoveModal.js +7 -1
- package/es/components/StatusIndicator/StatusIndicatorStep.js +87 -0
- package/es/components/Tearsheet/Tearsheet.d.ts +8 -1
- package/es/components/Tearsheet/Tearsheet.js +9 -1
- package/es/components/Tearsheet/TearsheetNarrow.d.ts +11 -0
- package/es/components/Tearsheet/TearsheetNarrow.js +12 -0
- package/es/components/Tearsheet/TearsheetShell.d.ts +10 -0
- package/es/components/Tearsheet/TearsheetShell.js +17 -3
- package/es/components/Toolbar/ToolbarButton.js +1 -1
- package/es/components/index.d.ts +1 -1
- package/es/index.js +1 -0
- package/lib/components/ConditionBuilder/ConditionBlock/ConditionBlock.js +23 -21
- package/lib/components/ConditionBuilder/ConditionBuilder.js +67 -20
- package/lib/components/ConditionBuilder/ConditionBuilderActions/ConditionBuilderActions.d.ts +15 -0
- package/lib/components/ConditionBuilder/ConditionBuilderActions/ConditionBuilderActions.js +137 -0
- package/lib/components/ConditionBuilder/ConditionBuilderAdd/ConditionBuilderAdd.js +6 -3
- package/lib/components/ConditionBuilder/ConditionBuilderButton/ConditionBuilderButton.d.ts +5 -1
- package/lib/components/ConditionBuilder/ConditionBuilderButton/ConditionBuilderButton.js +16 -4
- package/lib/components/ConditionBuilder/ConditionBuilderConnector/ConditionConnector.js +2 -2
- package/lib/components/ConditionBuilder/ConditionBuilderConnector/GroupConnector.js +2 -2
- package/lib/components/ConditionBuilder/ConditionBuilderContent/ConditionBuilderContent.d.ts +9 -11
- package/lib/components/ConditionBuilder/ConditionBuilderContent/ConditionBuilderContent.js +36 -32
- package/lib/components/ConditionBuilder/ConditionBuilderContext/ConditionBuilderProvider.d.ts +0 -1
- package/lib/components/ConditionBuilder/ConditionBuilderContext/ConditionBuilderProvider.js +7 -2
- package/lib/components/ConditionBuilder/ConditionBuilderContext/DataConfigs.d.ts +6 -1
- package/lib/components/ConditionBuilder/ConditionBuilderContext/DataConfigs.js +18 -10
- package/lib/components/ConditionBuilder/ConditionBuilderContext/translationObject.d.ts +39 -36
- package/lib/components/ConditionBuilder/ConditionBuilderContext/translationObject.js +12 -10
- package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItem.d.ts +1 -1
- package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItem.js +23 -15
- package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemNumber/ConditionBuilderItemNumber.js +20 -5
- package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemOption/ItemOption.d.ts +13 -0
- package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemOption/ItemOption.js +117 -0
- package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemOption/{ConditionBuilderItemOption.d.ts → ItemOptionForValueField.d.ts} +2 -2
- package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemOption/{ConditionBuilderItemOption.js → ItemOptionForValueField.js} +56 -31
- package/lib/components/ConditionBuilder/ConditionGroupBuilder/ConditionGroupBuilder.js +4 -6
- package/lib/components/ConditionBuilder/ConditionPreview/ConditionPreview.js +14 -4
- package/lib/components/ConditionBuilder/utils/handleKeyboardEvents.js +1 -2
- package/lib/components/ConditionBuilder/utils/util.d.ts +1 -0
- package/lib/components/ConditionBuilder/utils/util.js +17 -0
- package/lib/components/DataSpreadsheet/DataSpreadsheet.d.ts +12 -0
- package/lib/components/DataSpreadsheet/DataSpreadsheet.js +51 -19
- package/lib/components/DataSpreadsheet/DataSpreadsheetBody.d.ts +21 -1
- package/lib/components/DataSpreadsheet/DataSpreadsheetBody.js +40 -8
- package/lib/components/DataSpreadsheet/DataSpreadsheetHeader.d.ts +8 -0
- package/lib/components/DataSpreadsheet/DataSpreadsheetHeader.js +20 -6
- package/lib/components/DataSpreadsheet/hooks/useSpreadsheetMouseMove.js +4 -1
- package/lib/components/DataSpreadsheet/hooks/useSpreadsheetMouseUp.d.ts +3 -1
- package/lib/components/DataSpreadsheet/hooks/useSpreadsheetMouseUp.js +15 -3
- package/lib/components/DataSpreadsheet/types/index.d.ts +1 -1
- package/lib/components/DataSpreadsheet/utils/moveColumnIndicatorLine.js +34 -2
- package/lib/components/Datagrid/Datagrid/Datagrid.d.ts +0 -4
- package/lib/components/Datagrid/Datagrid/Datagrid.js +4 -9
- package/lib/components/Datagrid/Datagrid/DatagridContent.js +1 -1
- package/lib/components/Datagrid/Datagrid/DatagridHeaderRow.js +23 -8
- package/lib/components/Datagrid/Datagrid/DatagridRow.js +21 -8
- package/lib/components/Datagrid/Datagrid/addons/Filtering/FilterFlyout.js +6 -1
- package/lib/components/Datagrid/Datagrid/addons/Filtering/FilterPanel.js +6 -1
- package/lib/components/Datagrid/Datagrid/addons/Filtering/FilterProvider.d.ts +3 -1
- package/lib/components/Datagrid/Datagrid/addons/Filtering/FilterProvider.js +6 -3
- package/lib/components/Datagrid/Datagrid/addons/Filtering/hooks/useFilters.d.ts +1 -1
- package/lib/components/Datagrid/Datagrid/addons/Filtering/hooks/useFilters.js +21 -16
- package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditButton/InlineEditButton.js +2 -3
- package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditCell/InlineEditCell.js +73 -10
- package/lib/components/Datagrid/Datagrid/addons/InlineEdit/handleGridKeyPress.js +10 -2
- package/lib/components/Datagrid/types/index.d.ts +37 -4
- package/lib/components/Datagrid/useActionsColumn.d.ts +8 -1
- package/lib/components/Datagrid/useActionsColumn.js +7 -6
- package/lib/components/Datagrid/useColumnRightAlign.d.ts +8 -1
- package/lib/components/Datagrid/useColumnRightAlign.js +4 -3
- package/lib/components/Datagrid/useCustomizeColumns.d.ts +8 -1
- package/lib/components/Datagrid/useCustomizeColumns.js +4 -3
- package/lib/components/Datagrid/useDefaultStringRenderer.js +0 -1
- package/lib/components/Datagrid/useInlineEdit.js +12 -2
- package/lib/components/Datagrid/useNestedRowExpander.js +1 -3
- package/lib/components/Datagrid/useNestedRows.js +32 -13
- package/lib/components/Datagrid/useRowExpander.js +1 -3
- package/lib/components/Decorator/Decorator.js +2 -1
- package/lib/components/DecoratorBase/DecoratorBase.js +3 -5
- package/lib/components/DecoratorDualButton/DecoratorDualButton.js +2 -1
- package/lib/components/DecoratorLink/DecoratorLink.js +2 -1
- package/lib/components/DecoratorSingleButton/DecoratorSingleButton.js +2 -1
- package/lib/components/EditTearsheet/EditTearsheet.d.ts +5 -1
- package/lib/components/EditTearsheet/EditTearsheet.js +0 -1
- package/lib/components/EditTearsheet/EditTearsheetForm.d.ts +45 -2
- package/lib/components/EditTearsheet/EditTearsheetForm.js +3 -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/PageHeader/PageHeader.js +1 -0
- package/lib/components/RemoveModal/RemoveModal.d.ts +4 -0
- package/lib/components/RemoveModal/RemoveModal.js +7 -1
- package/lib/components/StatusIndicator/StatusIndicatorStep.js +94 -0
- package/lib/components/Tearsheet/Tearsheet.d.ts +8 -1
- package/lib/components/Tearsheet/Tearsheet.js +9 -1
- package/lib/components/Tearsheet/TearsheetNarrow.d.ts +11 -0
- package/lib/components/Tearsheet/TearsheetNarrow.js +12 -0
- package/lib/components/Tearsheet/TearsheetShell.d.ts +10 -0
- package/lib/components/Tearsheet/TearsheetShell.js +16 -2
- package/lib/components/Toolbar/ToolbarButton.js +1 -1
- package/lib/components/index.d.ts +1 -1
- package/lib/index.js +5 -0
- package/package.json +7 -6
- package/scss/components/ConditionBuilder/styles/_conditionBuilderCondition.scss +9 -1
- package/scss/components/ConditionBuilder/styles/_conditionBuilderItem.scss +26 -1
- package/scss/components/DataSpreadsheet/_data-spreadsheet.scss +8 -0
- package/scss/components/Datagrid/styles/_useInlineEdit.scss +13 -0
- package/scss/components/StatusIcon/_status-icon.scss +4 -4
- package/scss/components/StringFormatter/_string-formatter.scss +2 -2
- package/scss/components/UserProfileImage/_user-profile-image.scss +6 -2
- package/telemetry.yml +15 -3
- package/es/components/ConditionBuilder/utils/checkForHoldingKey.d.ts +0 -1
- package/es/components/ConditionBuilder/utils/checkForHoldingKey.js +0 -16
- package/lib/components/ConditionBuilder/utils/checkForHoldingKey.d.ts +0 -1
- package/lib/components/ConditionBuilder/utils/checkForHoldingKey.js +0 -20
package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemOption/ItemOption.js
ADDED
@@ -0,0 +1,109 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright IBM Corp. 2020, 2024
|
3
|
+
*
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
6
|
+
*/
|
7
|
+
|
8
|
+
import { slicedToArray as _slicedToArray } from '../../../../_virtual/_rollupPluginBabelHelpers.js';
|
9
|
+
import React__default, { useContext, useRef, useState, useEffect } from 'react';
|
10
|
+
import { Search } from '@carbon/react';
|
11
|
+
import { Checkmark } from '@carbon/react/icons';
|
12
|
+
import PropTypes from '../../../../node_modules/prop-types/index.js';
|
13
|
+
import { ConditionBuilderContext } from '../../ConditionBuilderContext/ConditionBuilderProvider.js';
|
14
|
+
import { blockClass, translateWithId } from '../../ConditionBuilderContext/DataConfigs.js';
|
15
|
+
|
16
|
+
var ItemOption = function ItemOption(_ref) {
|
17
|
+
var _ref$conditionState = _ref.conditionState,
|
18
|
+
conditionState = _ref$conditionState === void 0 ? {} : _ref$conditionState,
|
19
|
+
_ref$config = _ref.config,
|
20
|
+
config = _ref$config === void 0 ? {} : _ref$config,
|
21
|
+
onChange = _ref.onChange;
|
22
|
+
var _useContext = useContext(ConditionBuilderContext),
|
23
|
+
popOverSearchThreshold = _useContext.popOverSearchThreshold;
|
24
|
+
var contentRef = useRef();
|
25
|
+
var allOptions = config.options;
|
26
|
+
var _useState = useState(''),
|
27
|
+
_useState2 = _slicedToArray(_useState, 2),
|
28
|
+
searchValue = _useState2[0],
|
29
|
+
setSearchValue = _useState2[1];
|
30
|
+
var selection = conditionState.value;
|
31
|
+
var filteredItems = allOptions === null || allOptions === void 0 ? void 0 : allOptions.filter(function (opt) {
|
32
|
+
return opt.label.toLowerCase().includes(searchValue.toLowerCase());
|
33
|
+
});
|
34
|
+
useEffect(function () {
|
35
|
+
//this will focus the first input field in the popover
|
36
|
+
|
37
|
+
if (contentRef.current) {
|
38
|
+
var firstFocusableElement = contentRef.current.querySelector('input, button,li');
|
39
|
+
if (firstFocusableElement) {
|
40
|
+
firstFocusableElement.focus();
|
41
|
+
}
|
42
|
+
}
|
43
|
+
}, [allOptions]);
|
44
|
+
var onClickHandler = function onClickHandler(evt, option) {
|
45
|
+
onChange(option.id, evt);
|
46
|
+
};
|
47
|
+
var onSearchChangeHandler = function onSearchChangeHandler(evt) {
|
48
|
+
var value = evt.target.value;
|
49
|
+
setSearchValue(value);
|
50
|
+
};
|
51
|
+
var getAriaLabel = function getAriaLabel() {
|
52
|
+
return conditionState.label ? conditionState.label : conditionState.property ? conditionState.property : translateWithId('property');
|
53
|
+
};
|
54
|
+
if (!allOptions) {
|
55
|
+
return;
|
56
|
+
}
|
57
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
58
|
+
className: "".concat(blockClass, "__item-option"),
|
59
|
+
ref: contentRef
|
60
|
+
}, allOptions.length > popOverSearchThreshold && /*#__PURE__*/React__default.createElement("div", {
|
61
|
+
className: "".concat(blockClass, "__item-option__search")
|
62
|
+
}, /*#__PURE__*/React__default.createElement(Search, {
|
63
|
+
size: "sm",
|
64
|
+
labelText: translateWithId('clear_search'),
|
65
|
+
closeButtonLabelText: translateWithId('clear_search'),
|
66
|
+
onChange: onSearchChangeHandler
|
67
|
+
})), /*#__PURE__*/React__default.createElement("ul", {
|
68
|
+
"aria-label": getAriaLabel(),
|
69
|
+
role: "listbox"
|
70
|
+
}, filteredItems === null || filteredItems === void 0 ? void 0 : filteredItems.map(function (option) {
|
71
|
+
var isSelected = selection === option.id;
|
72
|
+
var Icon = option.icon;
|
73
|
+
return /*#__PURE__*/React__default.createElement("li", {
|
74
|
+
tabIndex: 0,
|
75
|
+
key: option.id,
|
76
|
+
role: "option",
|
77
|
+
"aria-selected": isSelected,
|
78
|
+
className: "".concat(blockClass, "__item-option__option"),
|
79
|
+
onKeyUp: function onKeyUp() {
|
80
|
+
return false;
|
81
|
+
},
|
82
|
+
onClick: function onClick(evt) {
|
83
|
+
return onClickHandler(evt, option);
|
84
|
+
}
|
85
|
+
}, /*#__PURE__*/React__default.createElement("div", {
|
86
|
+
className: "".concat(blockClass, "__item-option__option-content")
|
87
|
+
}, /*#__PURE__*/React__default.createElement("span", {
|
88
|
+
className: "".concat(blockClass, "__item-option__option-label")
|
89
|
+
}, Icon && /*#__PURE__*/React__default.createElement(Icon, null), option.label), isSelected && /*#__PURE__*/React__default.createElement(Checkmark, {
|
90
|
+
className: "".concat(blockClass, "__checkmark")
|
91
|
+
})));
|
92
|
+
})));
|
93
|
+
};
|
94
|
+
ItemOption.propTypes = {
|
95
|
+
/**
|
96
|
+
* current condition object
|
97
|
+
*/
|
98
|
+
conditionState: PropTypes.object,
|
99
|
+
/**
|
100
|
+
* current config object that this property is part of
|
101
|
+
*/
|
102
|
+
config: PropTypes.object,
|
103
|
+
/**
|
104
|
+
* callback to update state oin date change
|
105
|
+
*/
|
106
|
+
onChange: PropTypes.func
|
107
|
+
};
|
108
|
+
|
109
|
+
export { ItemOption };
|
@@ -1,9 +1,9 @@
|
|
1
|
-
export function
|
1
|
+
export function ItemOptionForValueField({ conditionState, config, onChange, }: {
|
2
2
|
conditionState?: {} | undefined;
|
3
3
|
config?: {} | undefined;
|
4
4
|
onChange: any;
|
5
5
|
}): import("react/jsx-runtime").JSX.Element;
|
6
|
-
export namespace
|
6
|
+
export namespace ItemOptionForValueField {
|
7
7
|
namespace propTypes {
|
8
8
|
let conditionState: PropTypes.Requireable<object>;
|
9
9
|
let config: PropTypes.Requireable<object>;
|
@@ -6,35 +6,58 @@
|
|
6
6
|
*/
|
7
7
|
|
8
8
|
import { slicedToArray as _slicedToArray, toConsumableArray as _toConsumableArray, asyncToGenerator as _asyncToGenerator, regeneratorRuntime as _regeneratorRuntime } from '../../../../_virtual/_rollupPluginBabelHelpers.js';
|
9
|
-
import React__default, { useContext,
|
10
|
-
import { Search, Button
|
9
|
+
import React__default, { useContext, useRef, useState, useEffect } from 'react';
|
10
|
+
import { SelectSkeleton, Search, Button } from '@carbon/react';
|
11
11
|
import { CheckboxCheckedFilled, Checkbox, Checkmark } from '@carbon/react/icons';
|
12
12
|
import PropTypes from '../../../../node_modules/prop-types/index.js';
|
13
13
|
import { ConditionBuilderContext } from '../../ConditionBuilderContext/ConditionBuilderProvider.js';
|
14
14
|
import { blockClass, translateWithId } from '../../ConditionBuilderContext/DataConfigs.js';
|
15
15
|
|
16
|
-
var _CheckboxCheckedFille, _Checkbox
|
17
|
-
var
|
16
|
+
var _SelectSkeleton, _CheckboxCheckedFille, _Checkbox;
|
17
|
+
var ItemOptionForValueField = function ItemOptionForValueField(_ref) {
|
18
18
|
var _ref$conditionState = _ref.conditionState,
|
19
19
|
conditionState = _ref$conditionState === void 0 ? {} : _ref$conditionState,
|
20
20
|
_ref$config = _ref.config,
|
21
21
|
config = _ref$config === void 0 ? {} : _ref$config,
|
22
22
|
onChange = _ref.onChange;
|
23
|
-
var multiSelectable = conditionState.operator === '
|
23
|
+
var multiSelectable = conditionState.operator === 'one_of';
|
24
24
|
var _useContext = useContext(ConditionBuilderContext),
|
25
25
|
popOverSearchThreshold = _useContext.popOverSearchThreshold,
|
26
|
-
getOptions = _useContext.getOptions
|
26
|
+
getOptions = _useContext.getOptions,
|
27
|
+
rootState = _useContext.rootState;
|
28
|
+
var contentRef = useRef();
|
27
29
|
var _useState = useState(config.options),
|
28
30
|
_useState2 = _slicedToArray(_useState, 2),
|
29
31
|
allOptions = _useState2[0],
|
30
32
|
setAllOptions = _useState2[1];
|
31
|
-
var _useState3 = useState(
|
33
|
+
var _useState3 = useState(''),
|
32
34
|
_useState4 = _slicedToArray(_useState3, 2),
|
33
|
-
|
34
|
-
|
35
|
+
searchValue = _useState4[0],
|
36
|
+
setSearchValue = _useState4[1];
|
37
|
+
var filteredItems = allOptions === null || allOptions === void 0 ? void 0 : allOptions.filter(function (opt) {
|
38
|
+
return opt.label.toLowerCase().includes(searchValue.toLowerCase());
|
39
|
+
});
|
35
40
|
var selection = Array.isArray(conditionState.value) ? conditionState.value : conditionState.value !== undefined ? [conditionState.value] : [];
|
36
|
-
var contentRef = useRef();
|
37
41
|
useEffect(function () {
|
42
|
+
// if(rest['data-name'] == 'valueField'){
|
43
|
+
// const fetchData = async () => {
|
44
|
+
// const response = await config.options(conditionState);
|
45
|
+
// if (
|
46
|
+
// response?.length > 0 &&
|
47
|
+
// Object.keys(response[0]).includes('label') &&
|
48
|
+
// Object.keys(response[0]).includes('id')
|
49
|
+
// ) {
|
50
|
+
// setAllOptions(response);
|
51
|
+
// setFilteredItems(response);
|
52
|
+
// }
|
53
|
+
// };
|
54
|
+
|
55
|
+
// fetchData(); // Call the async method
|
56
|
+
// }else{
|
57
|
+
// setAllOptions(config.options);
|
58
|
+
// setFilteredItems(config.options);
|
59
|
+
// }
|
60
|
+
|
38
61
|
if (!allOptions && getOptions) {
|
39
62
|
var fetchData = /*#__PURE__*/function () {
|
40
63
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
@@ -43,12 +66,11 @@ var ConditionBuilderItemOption = function ConditionBuilderItemOption(_ref) {
|
|
43
66
|
while (1) switch (_context.prev = _context.next) {
|
44
67
|
case 0:
|
45
68
|
_context.next = 2;
|
46
|
-
return getOptions(conditionState);
|
69
|
+
return getOptions(rootState, conditionState);
|
47
70
|
case 2:
|
48
71
|
response = _context.sent;
|
49
72
|
if ((response === null || response === void 0 ? void 0 : response.length) > 0 && Object.keys(response[0]).includes('label') && Object.keys(response[0]).includes('id')) {
|
50
73
|
setAllOptions(response);
|
51
|
-
setFilteredItems(response);
|
52
74
|
}
|
53
75
|
case 4:
|
54
76
|
case "end":
|
@@ -68,46 +90,47 @@ var ConditionBuilderItemOption = function ConditionBuilderItemOption(_ref) {
|
|
68
90
|
//this will focus the first input field in the popover
|
69
91
|
|
70
92
|
if (contentRef.current) {
|
71
|
-
var
|
72
|
-
|
73
|
-
|
93
|
+
var firstFocusableElement = contentRef.current.querySelector('input, button,li');
|
94
|
+
if (firstFocusableElement) {
|
95
|
+
firstFocusableElement.focus();
|
96
|
+
}
|
74
97
|
}
|
75
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
76
98
|
}, [allOptions]);
|
77
99
|
var handleSelectAll = function handleSelectAll(evt) {
|
78
100
|
if (evt.currentTarget.dataset.selectedAll == 'false') {
|
79
101
|
onChange(undefined);
|
80
102
|
} else {
|
81
|
-
onChange(allOptions
|
82
|
-
return op.id;
|
83
|
-
}));
|
103
|
+
onChange(allOptions);
|
84
104
|
}
|
85
105
|
};
|
86
106
|
var onSearchChangeHandler = function onSearchChangeHandler(evt) {
|
87
107
|
var value = evt.target.value;
|
88
|
-
|
89
|
-
return opt.label.toLowerCase().includes(value.toLowerCase());
|
90
|
-
});
|
91
|
-
setFilteredItems(_filteredItems);
|
108
|
+
setSearchValue(value);
|
92
109
|
};
|
93
110
|
var onClickHandler = function onClickHandler(evt, option, isSelected) {
|
94
111
|
if (multiSelectable) {
|
95
112
|
if (isSelected) {
|
96
113
|
var items = selection.filter(function (v) {
|
97
|
-
return v !== option.id;
|
114
|
+
return v.id !== option.id;
|
98
115
|
});
|
99
116
|
onChange(items.length > 0 ? items : undefined, evt);
|
100
117
|
} else {
|
101
|
-
onChange([].concat(_toConsumableArray(selection), [option
|
118
|
+
onChange([].concat(_toConsumableArray(selection), [option]), evt);
|
102
119
|
}
|
103
120
|
} else {
|
104
|
-
onChange(option
|
121
|
+
onChange(option, evt);
|
105
122
|
}
|
106
123
|
};
|
107
|
-
|
124
|
+
var getAriaLabel = function getAriaLabel() {
|
125
|
+
return conditionState.label ? conditionState.label : conditionState.property ? conditionState.property : translateWithId('property');
|
126
|
+
};
|
127
|
+
if (!allOptions) {
|
128
|
+
return _SelectSkeleton || (_SelectSkeleton = /*#__PURE__*/React__default.createElement(SelectSkeleton, null));
|
129
|
+
}
|
130
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
108
131
|
className: "".concat(blockClass, "__item-option"),
|
109
132
|
ref: contentRef
|
110
|
-
},
|
133
|
+
}, allOptions.length > popOverSearchThreshold && /*#__PURE__*/React__default.createElement("div", {
|
111
134
|
className: "".concat(blockClass, "__item-option__search")
|
112
135
|
}, /*#__PURE__*/React__default.createElement(Search, {
|
113
136
|
size: "sm",
|
@@ -123,11 +146,13 @@ var ConditionBuilderItemOption = function ConditionBuilderItemOption(_ref) {
|
|
123
146
|
onClick: handleSelectAll,
|
124
147
|
className: "".concat(blockClass, "__selectAll-button")
|
125
148
|
}, selection.length == 0 ? 'Select all' : 'Deselect all')), /*#__PURE__*/React__default.createElement("ul", {
|
126
|
-
"aria-label":
|
149
|
+
"aria-label": getAriaLabel(),
|
127
150
|
role: "listbox",
|
128
151
|
"data-multi-select": multiSelectable
|
129
152
|
}, filteredItems === null || filteredItems === void 0 ? void 0 : filteredItems.map(function (option) {
|
130
|
-
var isSelected = selection.
|
153
|
+
var isSelected = selection.map(function (option) {
|
154
|
+
return option.id;
|
155
|
+
}).includes(option.id);
|
131
156
|
var Icon = option.icon;
|
132
157
|
return /*#__PURE__*/React__default.createElement("li", {
|
133
158
|
tabIndex: 0,
|
@@ -154,9 +179,9 @@ var ConditionBuilderItemOption = function ConditionBuilderItemOption(_ref) {
|
|
154
179
|
}, Icon && /*#__PURE__*/React__default.createElement(Icon, null), option.label), isSelected && /*#__PURE__*/React__default.createElement(Checkmark, {
|
155
180
|
className: "".concat(blockClass, "__checkmark")
|
156
181
|
}))));
|
157
|
-
})))
|
182
|
+
})));
|
158
183
|
};
|
159
|
-
|
184
|
+
ItemOptionForValueField.propTypes = {
|
160
185
|
/**
|
161
186
|
* current condition object
|
162
187
|
*/
|
@@ -171,4 +196,4 @@ ConditionBuilderItemOption.propTypes = {
|
|
171
196
|
onChange: PropTypes.func
|
172
197
|
};
|
173
198
|
|
174
|
-
export {
|
199
|
+
export { ItemOptionForValueField };
|
@@ -12,15 +12,14 @@ import PropTypes from '../../../node_modules/prop-types/index.js';
|
|
12
12
|
import cx from 'classnames';
|
13
13
|
import { blockClass, translateWithId, statementConfig } from '../ConditionBuilderContext/DataConfigs.js';
|
14
14
|
import { ConditionBuilderItem } from '../ConditionBuilderItem/ConditionBuilderItem.js';
|
15
|
-
import { ConditionBuilderItemOption } from '../ConditionBuilderItem/ConditionBuilderItemOption/ConditionBuilderItemOption.js';
|
16
15
|
import { focusThisField } from '../utils/util.js';
|
17
16
|
import ConditionConnector from '../ConditionBuilderConnector/ConditionConnector.js';
|
18
17
|
import { ConditionBuilderContext } from '../ConditionBuilderContext/ConditionBuilderProvider.js';
|
19
18
|
import uuidv4 from '../../../global/js/utils/uuidv4.js';
|
20
19
|
import ConditionPreview from '../ConditionPreview/ConditionPreview.js';
|
20
|
+
import { ItemOption } from '../ConditionBuilderItem/ConditionBuilderItemOption/ItemOption.js';
|
21
21
|
|
22
22
|
var _ConditionPreview, _ConditionPreview2;
|
23
|
-
|
24
23
|
/**
|
25
24
|
*
|
26
25
|
* state - this is the current group that is being rendered . This can be a inner group or outer group
|
@@ -85,7 +84,6 @@ var ConditionGroupBuilder = function ConditionGroupBuilder(_ref) {
|
|
85
84
|
var addConditionSubGroupHandler = function addConditionSubGroupHandler(conditionIndex) {
|
86
85
|
onChange(_objectSpread2(_objectSpread2({}, group), {}, {
|
87
86
|
conditions: [].concat(_toConsumableArray(group.conditions.slice(0, conditionIndex + 1)), [{
|
88
|
-
groupSeparateOperator: null,
|
89
87
|
groupOperator: 'and',
|
90
88
|
statement: 'if',
|
91
89
|
conditions: [{
|
@@ -178,7 +176,7 @@ var ConditionGroupBuilder = function ConditionGroupBuilder(_ref) {
|
|
178
176
|
"data-name": "connectorField",
|
179
177
|
popOverClassName: "".concat(blockClass, "__gap"),
|
180
178
|
className: "".concat(blockClass, "__statement-button")
|
181
|
-
}, /*#__PURE__*/React__default.createElement(
|
179
|
+
}, /*#__PURE__*/React__default.createElement(ItemOption, {
|
182
180
|
conditionState: {
|
183
181
|
value: group.statement,
|
184
182
|
label: translateWithId('condition')
|
@@ -214,7 +212,7 @@ var ConditionGroupBuilder = function ConditionGroupBuilder(_ref) {
|
|
214
212
|
onRemoveHandler(eachCondition.id, e);
|
215
213
|
},
|
216
214
|
conditionBuilderRef: conditionBuilderRef
|
217
|
-
})) : /*#__PURE__*/React__default.createElement(ConditionBlock, {
|
215
|
+
})) : /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement(ConditionBlock, {
|
218
216
|
conjunction: conditionIndex > 0 ? group.groupOperator : undefined,
|
219
217
|
aria: {
|
220
218
|
level: aria.level + 1,
|
@@ -244,7 +242,7 @@ var ConditionGroupBuilder = function ConditionGroupBuilder(_ref) {
|
|
244
242
|
},
|
245
243
|
hideConditionPreviewHandler: hideConditionPreviewHandler,
|
246
244
|
isLastCondition: isLastCondition
|
247
|
-
}), conditionIndex == showConditionSubGroupPreview && (_ConditionPreview || (_ConditionPreview = /*#__PURE__*/React__default.createElement(ConditionPreview, {
|
245
|
+
})), conditionIndex == showConditionSubGroupPreview && (_ConditionPreview || (_ConditionPreview = /*#__PURE__*/React__default.createElement(ConditionPreview, {
|
248
246
|
previewType: "subGroup"
|
249
247
|
}))), conditionIndex == showConditionPreview && (_ConditionPreview2 || (_ConditionPreview2 = /*#__PURE__*/React__default.createElement(ConditionPreview, {
|
250
248
|
previewType: "condition"
|
@@ -5,7 +5,9 @@
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
6
6
|
*/
|
7
7
|
|
8
|
-
import
|
8
|
+
import { slicedToArray as _slicedToArray, defineProperty as _defineProperty } from '../../../_virtual/_rollupPluginBabelHelpers.js';
|
9
|
+
import React__default, { useState, useEffect } from 'react';
|
10
|
+
import cx from 'classnames';
|
9
11
|
import PropTypes from '../../../node_modules/prop-types/index.js';
|
10
12
|
import { blockClass, translateWithId } from '../ConditionBuilderContext/DataConfigs.js';
|
11
13
|
import { ConditionBuilderItem } from '../ConditionBuilderItem/ConditionBuilderItem.js';
|
@@ -13,6 +15,13 @@ import ConditionConnector from '../ConditionBuilderConnector/ConditionConnector.
|
|
13
15
|
|
14
16
|
var ConditionPreview = function ConditionPreview(_ref) {
|
15
17
|
var previewType = _ref.previewType;
|
18
|
+
var _useState = useState(false),
|
19
|
+
_useState2 = _slicedToArray(_useState, 2),
|
20
|
+
animate = _useState2[0],
|
21
|
+
setAnimate = _useState2[1];
|
22
|
+
useEffect(function () {
|
23
|
+
setAnimate(true);
|
24
|
+
}, []);
|
16
25
|
var getConditionSection = function getConditionSection() {
|
17
26
|
return /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement(ConditionBuilderItem, {
|
18
27
|
label: translateWithId('property')
|
@@ -23,20 +32,20 @@ var ConditionPreview = function ConditionPreview(_ref) {
|
|
23
32
|
}));
|
24
33
|
};
|
25
34
|
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, previewType == 'newGroup' && /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("div", {
|
26
|
-
className: "".concat(blockClass, "__group__row ").concat(blockClass, "__group-preview
|
35
|
+
className: cx(["".concat(blockClass, "__group__row ").concat(blockClass, "__group-preview "), _defineProperty({}, "".concat(blockClass, "__group-preview-animate"), animate)])
|
27
36
|
}, /*#__PURE__*/React__default.createElement(ConditionBuilderItem, {
|
28
37
|
className: "".concat(blockClass, "__statement-button"),
|
29
38
|
label: translateWithId('and')
|
30
39
|
})), /*#__PURE__*/React__default.createElement("div", {
|
31
40
|
"aria-hidden": true,
|
32
|
-
className: "".concat(blockClass, "__group ").concat(blockClass, "__condition-wrapper ").concat(blockClass, "__group-preview ").concat(blockClass, "__group-wrapper")
|
41
|
+
className: cx(["".concat(blockClass, "__group ").concat(blockClass, "__condition-wrapper ").concat(blockClass, "__group-preview ").concat(blockClass, "__group-wrapper "), _defineProperty({}, "".concat(blockClass, "__group-preview-animate"), animate)])
|
33
42
|
}, /*#__PURE__*/React__default.createElement("div", {
|
34
43
|
className: "".concat(blockClass, "__gap")
|
35
44
|
}, /*#__PURE__*/React__default.createElement(ConditionBuilderItem, {
|
36
45
|
className: "".concat(blockClass, "__statement-button"),
|
37
46
|
label: translateWithId('if')
|
38
47
|
})), getConditionSection())), previewType == 'subGroup' && /*#__PURE__*/React__default.createElement("div", {
|
39
|
-
className: "".concat(blockClass, "__group-preview")
|
48
|
+
className: cx(["".concat(blockClass, "__group__row ").concat(blockClass, "__group-preview "), _defineProperty({}, "".concat(blockClass, "__group-preview-animate"), animate)])
|
40
49
|
}, /*#__PURE__*/React__default.createElement("div", {
|
41
50
|
className: "".concat(blockClass, "__condition-block ").concat(blockClass, "__gap")
|
42
51
|
}, /*#__PURE__*/React__default.createElement(ConditionBuilderItem, {
|
@@ -49,7 +58,7 @@ var ConditionPreview = function ConditionPreview(_ref) {
|
|
49
58
|
className: "".concat(blockClass, "__gap ").concat(blockClass, "__groupConnector"),
|
50
59
|
operator: translateWithId('if')
|
51
60
|
}), getConditionSection()))), previewType == 'condition' && /*#__PURE__*/React__default.createElement("div", {
|
52
|
-
className: "".concat(blockClass, "__group-preview")
|
61
|
+
className: cx(["".concat(blockClass, "__group__row ").concat(blockClass, "__group-preview "), _defineProperty({}, "".concat(blockClass, "__group-preview-animate"), animate)])
|
53
62
|
}, /*#__PURE__*/React__default.createElement("div", {
|
54
63
|
className: "".concat(blockClass, "__condition-block ").concat(blockClass, "__gap")
|
55
64
|
}, /*#__PURE__*/React__default.createElement(ConditionBuilderItem, {
|
@@ -7,8 +7,7 @@
|
|
7
7
|
|
8
8
|
import { toConsumableArray as _toConsumableArray } from '../../../_virtual/_rollupPluginBabelHelpers.js';
|
9
9
|
import { blockClass } from '../ConditionBuilderContext/DataConfigs.js';
|
10
|
-
import { checkForHoldingKey } from './
|
11
|
-
import { focusThisField, traverseReverse, traverseClockVise } from './util.js';
|
10
|
+
import { checkForHoldingKey, focusThisField, traverseReverse, traverseClockVise } from './util.js';
|
12
11
|
|
13
12
|
var handleKeyDown = function handleKeyDown(evt, conditionBuilderRef) {
|
14
13
|
var activeElement = document.activeElement;
|
@@ -3,3 +3,4 @@ export function focusThisItem(currentElement: any): void;
|
|
3
3
|
export function traverseClockVise(eachElem: any, index: any, allElements: any, rotate: any, trapFocus: any): void;
|
4
4
|
export function traverseReverse(eachElem: any, index: any, allElements: any, rotate: any, trapFocus: any): void;
|
5
5
|
export function checkForHoldingKey(evt: any, key: any): any;
|
6
|
+
export function checkDuplicateAction(actionState: any, selectedId: any, currentActionId: any): boolean;
|
@@ -41,5 +41,20 @@ var traverseReverse = function traverseReverse(eachElem, index, allElements, rot
|
|
41
41
|
focusThisItem(allElements[allElements.length - 1]);
|
42
42
|
}
|
43
43
|
};
|
44
|
+
var checkForHoldingKey = function checkForHoldingKey(evt, key) {
|
45
|
+
// possible key inputs: altKey,ctrlKey,metaKey,shiftKey
|
46
|
+
if (key === 'cmd') {
|
47
|
+
return evt.metaKey || evt.ctrlKey;
|
48
|
+
}
|
49
|
+
return evt[key];
|
50
|
+
};
|
51
|
+
var checkDuplicateAction = function checkDuplicateAction(actionState, selectedId, currentActionId) {
|
52
|
+
if (selectedId !== currentActionId && actionState.find(function (eachAction) {
|
53
|
+
return eachAction.id === selectedId;
|
54
|
+
})) {
|
55
|
+
return true;
|
56
|
+
}
|
57
|
+
return false;
|
58
|
+
};
|
44
59
|
|
45
|
-
export { focusThisField, focusThisItem, traverseClockVise, traverseReverse };
|
60
|
+
export { checkDuplicateAction, checkForHoldingKey, focusThisField, focusThisItem, traverseClockVise, traverseReverse };
|
@@ -28,6 +28,10 @@ interface DataSpreadsheetProps {
|
|
28
28
|
* Sets the number of empty rows to be created when there is no data provided
|
29
29
|
*/
|
30
30
|
defaultEmptyRowCount?: number;
|
31
|
+
/**
|
32
|
+
* Check if has custom row header component attached
|
33
|
+
*/
|
34
|
+
hasCustomRowHeader?: boolean;
|
31
35
|
/**
|
32
36
|
* The spreadsheet id
|
33
37
|
*/
|
@@ -46,6 +50,14 @@ interface DataSpreadsheetProps {
|
|
46
50
|
* The event handler that is called when the selection area values change
|
47
51
|
*/
|
48
52
|
onSelectionAreaChange?: () => void;
|
53
|
+
/**
|
54
|
+
* Position of the custom row numbering component
|
55
|
+
*/
|
56
|
+
renderRowHeaderDirection?: 'left' | 'right';
|
57
|
+
/**
|
58
|
+
* Component next to numbering rows
|
59
|
+
*/
|
60
|
+
renderRowHeader?: (index: number) => any[];
|
49
61
|
/**
|
50
62
|
* The aria label applied to the Select all button
|
51
63
|
*/
|
@@ -32,7 +32,7 @@ import { useSpreadsheetOutsideClick } from './hooks/useSpreadsheetOutsideClick.j
|
|
32
32
|
import { useMoveActiveCell } from './hooks/useMoveActiveCell.js';
|
33
33
|
import { useSpreadsheetEdit } from './hooks/useSpreadsheetEdit.js';
|
34
34
|
|
35
|
-
var _excluded = ["cellSize", "className", "columns", "data", "defaultEmptyRowCount", "onDataUpdate", "id", "onActiveCellChange", "onSelectionAreaChange", "selectAllAriaLabel", "spreadsheetAriaLabel", "theme", "totalVisibleColumns"];
|
35
|
+
var _excluded = ["cellSize", "className", "columns", "data", "defaultEmptyRowCount", "onDataUpdate", "id", "onActiveCellChange", "onSelectionAreaChange", "renderRowHeader", "renderRowHeaderDirection", "selectAllAriaLabel", "spreadsheetAriaLabel", "theme", "totalVisibleColumns"];
|
36
36
|
// The block part of our conventional BEM class names (blockClass__E--M).
|
37
37
|
var blockClass = "".concat(pkg.prefix, "--data-spreadsheet");
|
38
38
|
var componentName = 'DataSpreadsheet';
|
@@ -67,6 +67,8 @@ var DataSpreadsheet = /*#__PURE__*/React__default.forwardRef(function (_ref, ref
|
|
67
67
|
onActiveCellChange = _ref$onActiveCellChan === void 0 ? defaults.onActiveCellChange : _ref$onActiveCellChan,
|
68
68
|
_ref$onSelectionAreaC = _ref.onSelectionAreaChange,
|
69
69
|
onSelectionAreaChange = _ref$onSelectionAreaC === void 0 ? defaults.onSelectionAreaChange : _ref$onSelectionAreaC,
|
70
|
+
renderRowHeader = _ref.renderRowHeader,
|
71
|
+
renderRowHeaderDirection = _ref.renderRowHeaderDirection,
|
70
72
|
selectAllAriaLabel = _ref.selectAllAriaLabel,
|
71
73
|
spreadsheetAriaLabel = _ref.spreadsheetAriaLabel,
|
72
74
|
theme = _ref.theme,
|
@@ -112,15 +114,19 @@ var DataSpreadsheet = /*#__PURE__*/React__default.forwardRef(function (_ref, ref
|
|
112
114
|
_useState18 = _slicedToArray(_useState17, 2),
|
113
115
|
headerCellHoldActive = _useState18[0],
|
114
116
|
setHeaderCellHoldActive = _useState18[1];
|
115
|
-
var isBlurSpreadsheet = useRef(false);
|
116
117
|
var _useState19 = useState(false),
|
117
118
|
_useState20 = _slicedToArray(_useState19, 2),
|
118
|
-
|
119
|
-
|
119
|
+
selectedHeaderReorderActive = _useState20[0],
|
120
|
+
setSelectedHeaderReorderActive = _useState20[1];
|
121
|
+
var isBlurSpreadsheet = useRef(false);
|
120
122
|
var _useState21 = useState(false),
|
121
123
|
_useState22 = _slicedToArray(_useState21, 2),
|
122
|
-
|
123
|
-
|
124
|
+
isActiveHeaderCellChanged = _useState22[0],
|
125
|
+
setIsActiveHeaderCellChanged = _useState22[1];
|
126
|
+
var _useState23 = useState(false),
|
127
|
+
_useState24 = _slicedToArray(_useState23, 2),
|
128
|
+
activeCellInsideSelectionArea = _useState24[0],
|
129
|
+
setActiveCellInsideSelectionArea = _useState24[1];
|
124
130
|
var previousState = usePreviousValue({
|
125
131
|
activeCellCoordinates: activeCellCoordinates,
|
126
132
|
isEditing: isEditing,
|
@@ -128,19 +134,21 @@ var DataSpreadsheet = /*#__PURE__*/React__default.forwardRef(function (_ref, ref
|
|
128
134
|
}) || {};
|
129
135
|
var cellSizeValue = getCellSize(cellSize);
|
130
136
|
var cellEditorRef = useRef();
|
131
|
-
var
|
132
|
-
|
133
|
-
activeCellContent =
|
134
|
-
setActiveCellContent =
|
137
|
+
var _useState25 = useState(),
|
138
|
+
_useState26 = _slicedToArray(_useState25, 2),
|
139
|
+
activeCellContent = _useState26[0],
|
140
|
+
setActiveCellContent = _useState26[1];
|
135
141
|
var activeCellRef = useRef();
|
136
142
|
var cellEditorRulerRef = useRef();
|
143
|
+
var hasCustomRowHeader = typeof renderRowHeader === 'function';
|
144
|
+
var maxNumRowsCount = data.length.toString().length;
|
137
145
|
var defaultColumn = useMemo(function () {
|
138
146
|
return {
|
139
147
|
width: 150,
|
140
|
-
rowHeaderWidth: 64,
|
148
|
+
rowHeaderWidth: hasCustomRowHeader ? 40 + maxNumRowsCount * 8.56 : 64,
|
141
149
|
rowHeight: cellSizeValue
|
142
150
|
};
|
143
|
-
}, [cellSizeValue]);
|
151
|
+
}, [cellSizeValue, hasCustomRowHeader, maxNumRowsCount]);
|
144
152
|
var _useMultipleKeyTracki = useMultipleKeyTracking({
|
145
153
|
ref: multiKeyTrackingRef,
|
146
154
|
containerHasFocus: containerHasFocus,
|
@@ -207,9 +215,12 @@ var DataSpreadsheet = /*#__PURE__*/React__default.forwardRef(function (_ref, ref
|
|
207
215
|
}
|
208
216
|
if ((prevCoords === null || prevCoords === void 0 ? void 0 : prevCoords.row) !== (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) || (prevCoords === null || prevCoords === void 0 ? void 0 : prevCoords.column) !== (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column)) {
|
209
217
|
if (activeCellCoordinates && (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) !== 'header' && (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) !== 'header') {
|
210
|
-
var _activeCellFullData$r;
|
211
218
|
var activeCellFullData = typeof (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) === 'number' && typeof (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) === 'number' ? rows[activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row].cells[activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column] : null;
|
212
|
-
|
219
|
+
if (activeCellFullData) {
|
220
|
+
setActiveCellContent(activeCellFullData.render('Cell'));
|
221
|
+
} else {
|
222
|
+
setActiveCellContent(null);
|
223
|
+
}
|
213
224
|
}
|
214
225
|
if (activeCellCoordinates && (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) === 'header' || (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) === 'header') {
|
215
226
|
setActiveCellContent(null);
|
@@ -424,8 +435,8 @@ var DataSpreadsheet = /*#__PURE__*/React__default.forwardRef(function (_ref, ref
|
|
424
435
|
var activeCellFullData = typeof (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) === 'number' && typeof (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) === 'number' ? rows[activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row].cells[activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column] : null;
|
425
436
|
var activeCellValue;
|
426
437
|
if (activeCellFullData && activeCellCoordinates !== null && activeCellCoordinates !== void 0 && activeCellCoordinates.column) {
|
427
|
-
var _activeCellFullData$
|
428
|
-
activeCellValue = activeCellFullData ? (_activeCellFullData$
|
438
|
+
var _activeCellFullData$r;
|
439
|
+
activeCellValue = activeCellFullData ? (_activeCellFullData$r = activeCellFullData.row.cells) === null || _activeCellFullData$r === void 0 || (_activeCellFullData$r = _activeCellFullData$r[activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column]) === null || _activeCellFullData$r === void 0 ? void 0 : _activeCellFullData$r.value : null;
|
429
440
|
}
|
430
441
|
setCellEditorValue(activeCellValue || '');
|
431
442
|
if (cellEditorRulerRef !== null && cellEditorRulerRef !== void 0 && cellEditorRulerRef.current) {
|
@@ -615,6 +626,8 @@ var DataSpreadsheet = /*#__PURE__*/React__default.forwardRef(function (_ref, ref
|
|
615
626
|
columns: columns,
|
616
627
|
currentMatcher: currentMatcher,
|
617
628
|
defaultColumn: defaultColumn,
|
629
|
+
selectedHeaderReorderActive: selectedHeaderReorderActive,
|
630
|
+
setSelectedHeaderReorderActive: setSelectedHeaderReorderActive,
|
618
631
|
headerGroups: headerGroups,
|
619
632
|
rows: rows,
|
620
633
|
scrollBarSize: scrollBarSize,
|
@@ -638,12 +651,17 @@ var DataSpreadsheet = /*#__PURE__*/React__default.forwardRef(function (_ref, ref
|
|
638
651
|
currentMatcher: currentMatcher,
|
639
652
|
setCurrentMatcher: setCurrentMatcher,
|
640
653
|
setContainerHasFocus: setContainerHasFocus,
|
654
|
+
selectedHeaderReorderActive: selectedHeaderReorderActive,
|
655
|
+
setSelectedHeaderReorderActive: setSelectedHeaderReorderActive,
|
641
656
|
selectionAreas: selectionAreas,
|
642
657
|
setSelectionAreas: setSelectionAreas,
|
643
658
|
headerGroups: headerGroups,
|
644
659
|
defaultColumn: defaultColumn,
|
645
660
|
getTableBodyProps: getTableBodyProps,
|
661
|
+
hasCustomRowHeader: hasCustomRowHeader,
|
646
662
|
onDataUpdate: onDataUpdate,
|
663
|
+
renderRowHeaderDirection: renderRowHeaderDirection,
|
664
|
+
renderRowHeader: renderRowHeader,
|
647
665
|
onActiveCellChange: onActiveCellChange,
|
648
666
|
onSelectionAreaChange: onSelectionAreaChange,
|
649
667
|
prepareRow: prepareRow,
|
@@ -688,9 +706,11 @@ var DataSpreadsheet = /*#__PURE__*/React__default.forwardRef(function (_ref, ref
|
|
688
706
|
updateData: updateData
|
689
707
|
}),
|
690
708
|
onChange: function onChange(event) {
|
691
|
-
|
692
|
-
|
693
|
-
cellEditorRulerRef.current
|
709
|
+
if (previousState.isEditing) {
|
710
|
+
setCellEditorValue(event.target.value);
|
711
|
+
if (cellEditorRulerRef !== null && cellEditorRulerRef !== void 0 && cellEditorRulerRef.current) {
|
712
|
+
cellEditorRulerRef.current.textContent = event.target.value;
|
713
|
+
}
|
694
714
|
}
|
695
715
|
},
|
696
716
|
ref: cellEditorRef,
|
@@ -740,6 +760,10 @@ DataSpreadsheet.propTypes = {
|
|
740
760
|
* Sets the number of empty rows to be created when there is no data provided
|
741
761
|
*/
|
742
762
|
defaultEmptyRowCount: PropTypes.number,
|
763
|
+
/**
|
764
|
+
* Check if spreadsheet is using custom row header component attached
|
765
|
+
*/
|
766
|
+
hasCustomRowHeader: PropTypes.bool,
|
743
767
|
/**
|
744
768
|
* The spreadsheet id
|
745
769
|
*/
|
@@ -756,6 +780,14 @@ DataSpreadsheet.propTypes = {
|
|
756
780
|
* The event handler that is called when the selection area values change
|
757
781
|
*/
|
758
782
|
onSelectionAreaChange: PropTypes.func,
|
783
|
+
/**
|
784
|
+
* Component next to numbering rows
|
785
|
+
*/
|
786
|
+
renderRowHeader: PropTypes.func,
|
787
|
+
/**
|
788
|
+
* Component next to numbering rows
|
789
|
+
*/
|
790
|
+
renderRowHeaderDirection: PropTypes.oneOf(['left', 'right']),
|
759
791
|
/**
|
760
792
|
* The aria label applied to the Select all button
|
761
793
|
*/
|