@carbon/ibm-products 2.43.2-canary.9 → 2.44.0-rc.1
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 +51 -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 +51 -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 +51 -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 +29 -7
- package/es/components/DataSpreadsheet/DataSpreadsheetBody.d.ts +12 -0
- package/es/components/DataSpreadsheet/DataSpreadsheetBody.js +22 -6
- package/es/components/DataSpreadsheet/DataSpreadsheetHeader.js +3 -0
- package/es/components/Datagrid/Datagrid/Datagrid.js +2 -1
- package/es/components/Datagrid/Datagrid/DatagridContent.js +1 -1
- package/es/components/Datagrid/Datagrid/DatagridHeaderRow.js +11 -1
- package/es/components/Datagrid/Datagrid/DatagridRow.js +13 -2
- 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 +1 -1
- 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 +18 -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/useInlineEdit.js +12 -2
- package/es/components/Datagrid/useNestedRows.js +32 -13
- 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/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 +29 -7
- package/lib/components/DataSpreadsheet/DataSpreadsheetBody.d.ts +12 -0
- package/lib/components/DataSpreadsheet/DataSpreadsheetBody.js +22 -6
- package/lib/components/DataSpreadsheet/DataSpreadsheetHeader.js +3 -0
- package/lib/components/Datagrid/Datagrid/Datagrid.js +2 -1
- package/lib/components/Datagrid/Datagrid/DatagridContent.js +1 -1
- package/lib/components/Datagrid/Datagrid/DatagridHeaderRow.js +11 -1
- package/lib/components/Datagrid/Datagrid/DatagridRow.js +13 -2
- 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 +1 -1
- 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 +18 -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/useInlineEdit.js +12 -2
- package/lib/components/Datagrid/useNestedRows.js +32 -13
- 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/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 +7 -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
@@ -17,6 +17,7 @@ import { ConditionBuilderButton } from '../ConditionBuilderButton/ConditionBuild
|
|
17
17
|
import uuidv4 from '../../../global/js/utils/uuidv4.js';
|
18
18
|
import ConditionPreview from '../ConditionPreview/ConditionPreview.js';
|
19
19
|
import GroupConnector from '../ConditionBuilderConnector/GroupConnector.js';
|
20
|
+
import ConditionBuilderActions from '../ConditionBuilderActions/ConditionBuilderActions.js';
|
20
21
|
|
21
22
|
var _Heading, _GroupConnector, _ConditionPreview;
|
22
23
|
var ConditionBuilderContent = function ConditionBuilderContent(_ref) {
|
@@ -24,14 +25,14 @@ var ConditionBuilderContent = function ConditionBuilderContent(_ref) {
|
|
24
25
|
var startConditionLabel = _ref.startConditionLabel,
|
25
26
|
conditionBuilderRef = _ref.conditionBuilderRef,
|
26
27
|
getConditionState = _ref.getConditionState,
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
// );
|
28
|
+
getActionsState = _ref.getActionsState,
|
29
|
+
initialState = _ref.initialState,
|
30
|
+
actions = _ref.actions;
|
31
31
|
var _useContext = useContext(ConditionBuilderContext),
|
32
32
|
rootState = _useContext.rootState,
|
33
33
|
setRootState = _useContext.setRootState,
|
34
|
-
variant = _useContext.variant
|
34
|
+
variant = _useContext.variant,
|
35
|
+
actionState = _useContext.actionState;
|
35
36
|
var _useState = useState(false),
|
36
37
|
_useState2 = _slicedToArray(_useState, 2),
|
37
38
|
isConditionBuilderActive = _useState2[0],
|
@@ -53,11 +54,10 @@ var ConditionBuilderContent = function ConditionBuilderContent(_ref) {
|
|
53
54
|
|
54
55
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
55
56
|
}, [rootState]);
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
// }, [actionState]);
|
57
|
+
useEffect(function () {
|
58
|
+
getActionsState === null || getActionsState === void 0 || getActionsState(actionState);
|
59
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
60
|
+
}, [actionState]);
|
61
61
|
var onStartConditionBuilder = function onStartConditionBuilder() {
|
62
62
|
//when add condition button is clicked.
|
63
63
|
setIsConditionBuilderActive(true);
|
@@ -83,8 +83,6 @@ var ConditionBuilderContent = function ConditionBuilderContent(_ref) {
|
|
83
83
|
};
|
84
84
|
var addConditionGroupHandler = function addConditionGroupHandler() {
|
85
85
|
var newGroup = {
|
86
|
-
groupSeparateOperator: 'and',
|
87
|
-
// 'or'|'and'|'null',
|
88
86
|
groupOperator: 'and',
|
89
87
|
//'and|or',
|
90
88
|
statement: 'if',
|
@@ -103,7 +101,7 @@ var ConditionBuilderContent = function ConditionBuilderContent(_ref) {
|
|
103
101
|
}));
|
104
102
|
};
|
105
103
|
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, !isConditionBuilderActive && /*#__PURE__*/React__default.createElement(Button, {
|
106
|
-
className: "".concat(blockClass, "
|
104
|
+
className: "".concat(blockClass, "__add_condition-button"),
|
107
105
|
renderIcon: function renderIcon(props) {
|
108
106
|
return /*#__PURE__*/React__default.createElement(Add, _extends({
|
109
107
|
size: 16
|
@@ -113,10 +111,7 @@ var ConditionBuilderContent = function ConditionBuilderContent(_ref) {
|
|
113
111
|
kind: "ghost",
|
114
112
|
size: "sm",
|
115
113
|
onClick: onStartConditionBuilder
|
116
|
-
}, startConditionLabel), isConditionBuilderActive &&
|
117
|
-
/*#__PURE__*/
|
118
|
-
// <h5 >Condition</h5>
|
119
|
-
React__default.createElement(Section, {
|
114
|
+
}, startConditionLabel), isConditionBuilderActive && /*#__PURE__*/React__default.createElement(Section, {
|
120
115
|
className: "".concat(blockClass, "__heading"),
|
121
116
|
level: 4
|
122
117
|
}, _Heading || (_Heading = /*#__PURE__*/React__default.createElement(Heading, null, "Condition"))), /*#__PURE__*/React__default.createElement("div", {
|
@@ -156,16 +151,19 @@ var ConditionBuilderContent = function ConditionBuilderContent(_ref) {
|
|
156
151
|
onMouseLeave: function onMouseLeave() {
|
157
152
|
setShowConditionGroupPreview(false);
|
158
153
|
},
|
159
|
-
className: "".concat(blockClass, "
|
154
|
+
className: "".concat(blockClass, "__add_condition_group "),
|
160
155
|
hideLabel: true,
|
161
|
-
label: translateWithId('
|
156
|
+
label: translateWithId('add_condition_group'),
|
162
157
|
wrapperProps: {
|
163
158
|
role: 'gridcell',
|
164
|
-
'aria-label': translateWithId('
|
159
|
+
'aria-label': translateWithId('add_condition_group')
|
165
160
|
}
|
166
161
|
})), showConditionGroupPreview && (_ConditionPreview || (_ConditionPreview = /*#__PURE__*/React__default.createElement(ConditionPreview, {
|
167
162
|
previewType: "newGroup"
|
168
|
-
})))))
|
163
|
+
}))))), isConditionBuilderActive && actions && /*#__PURE__*/React__default.createElement(ConditionBuilderActions, {
|
164
|
+
actions: actions,
|
165
|
+
className: "".concat(blockClass, "__actions-container")
|
166
|
+
}));
|
169
167
|
};
|
170
168
|
var ConditionBuilderContent$1 = ConditionBuilderContent;
|
171
169
|
ConditionBuilderContent.propTypes = {
|
@@ -173,8 +171,8 @@ ConditionBuilderContent.propTypes = {
|
|
173
171
|
* optional array of object that give the list of actions.
|
174
172
|
*/
|
175
173
|
actions: PropTypes.arrayOf(PropTypes.shape({
|
176
|
-
id: PropTypes.number,
|
177
|
-
label: PropTypes.string
|
174
|
+
id: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
|
175
|
+
label: PropTypes.string.isRequired
|
178
176
|
})),
|
179
177
|
/**
|
180
178
|
* ref of condition builder
|
@@ -193,15 +191,21 @@ ConditionBuilderContent.propTypes = {
|
|
193
191
|
*/
|
194
192
|
initialState: PropTypes.shape({
|
195
193
|
groups: PropTypes.arrayOf(PropTypes.shape({
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
194
|
+
groupOperator: PropTypes.string.isRequired,
|
195
|
+
statement: PropTypes.string.isRequired,
|
196
|
+
conditions: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.shape({
|
197
|
+
property: PropTypes.string.isRequired,
|
198
|
+
operator: PropTypes.string.isRequired,
|
199
|
+
value: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.shape({
|
200
|
+
id: PropTypes.string,
|
201
|
+
label: PropTypes.string
|
202
|
+
})), PropTypes.shape({
|
203
|
+
id: PropTypes.string,
|
204
|
+
label: PropTypes.string
|
205
|
+
})])
|
206
|
+
}), PropTypes.object]))
|
207
|
+
})),
|
208
|
+
operator: PropTypes.string
|
205
209
|
}),
|
206
210
|
/* Provide a label to the button that starts condition builder
|
207
211
|
*/
|
@@ -13,7 +13,6 @@ import uuidv4 from '../../../global/js/utils/uuidv4.js';
|
|
13
13
|
var emptyState = {
|
14
14
|
operator: 'or',
|
15
15
|
groups: [{
|
16
|
-
groupSeparateOperator: null,
|
17
16
|
groupOperator: 'and',
|
18
17
|
statement: 'if',
|
19
18
|
id: uuidv4(),
|
@@ -50,10 +49,16 @@ var ConditionBuilderProvider = function ConditionBuilderProvider(props) {
|
|
50
49
|
_useState2 = _slicedToArray(_useState, 2),
|
51
50
|
rootState = _useState2[0],
|
52
51
|
setRootState = _useState2[1];
|
52
|
+
var _useState3 = useState([]),
|
53
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
54
|
+
actionState = _useState4[0],
|
55
|
+
setActionState = _useState4[1];
|
53
56
|
return /*#__PURE__*/React__default.createElement(ConditionBuilderContext.Provider, {
|
54
57
|
value: {
|
55
58
|
rootState: rootState,
|
56
59
|
setRootState: setRootState,
|
60
|
+
actionState: actionState,
|
61
|
+
setActionState: setActionState,
|
57
62
|
inputConfig: props.inputConfig,
|
58
63
|
popOverSearchThreshold: props.popOverSearchThreshold,
|
59
64
|
getOptions: props.getOptions,
|
@@ -87,7 +92,7 @@ ConditionBuilderProvider.propTypes = {
|
|
87
92
|
id: PropTypes.string,
|
88
93
|
label: PropTypes.string,
|
89
94
|
icon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
90
|
-
type: PropTypes.oneOf(['text', 'number', 'date', 'option', 'time']),
|
95
|
+
type: PropTypes.oneOf(['text', 'number', 'date', 'option', 'time', 'custom']),
|
91
96
|
config: PropTypes.shape({
|
92
97
|
options: PropTypes.arrayOf(PropTypes.shape({
|
93
98
|
id: PropTypes.string,
|
@@ -6,6 +6,10 @@ export const connectorConfig: {
|
|
6
6
|
label: string;
|
7
7
|
id: string;
|
8
8
|
}[];
|
9
|
+
export const actionConfig: {
|
10
|
+
label: string;
|
11
|
+
id: string;
|
12
|
+
}[];
|
9
13
|
export const operatorConfig: {
|
10
14
|
label: string;
|
11
15
|
id: string;
|
@@ -16,7 +20,8 @@ export function translateWithId(key: any): any;
|
|
16
20
|
export namespace valueRenderers {
|
17
21
|
function text(val: any): any;
|
18
22
|
function time(val: any): any;
|
19
|
-
function number(val: any
|
23
|
+
function number(val: any): any;
|
20
24
|
function option(value: any): any;
|
21
25
|
function date(value: any): any;
|
26
|
+
function custom(value: any): any;
|
22
27
|
}
|
@@ -13,7 +13,7 @@ var statementConfig = [{
|
|
13
13
|
id: 'if'
|
14
14
|
}, {
|
15
15
|
label: 'excl.if',
|
16
|
-
id: '
|
16
|
+
id: 'excl_if'
|
17
17
|
}];
|
18
18
|
var connectorConfig = [{
|
19
19
|
label: 'and',
|
@@ -22,7 +22,6 @@ var connectorConfig = [{
|
|
22
22
|
label: 'or',
|
23
23
|
id: 'or'
|
24
24
|
}];
|
25
|
-
//op types : option, text, number, date,
|
26
25
|
var operatorConfig = [{
|
27
26
|
label: 'is',
|
28
27
|
id: 'is',
|
@@ -33,7 +32,7 @@ var operatorConfig = [{
|
|
33
32
|
type: 'number'
|
34
33
|
}, {
|
35
34
|
label: 'is greater than or equal to',
|
36
|
-
id: '
|
35
|
+
id: 'greater_equal',
|
37
36
|
type: 'number'
|
38
37
|
}, {
|
39
38
|
label: 'is lower than',
|
@@ -41,15 +40,15 @@ var operatorConfig = [{
|
|
41
40
|
type: 'number'
|
42
41
|
}, {
|
43
42
|
label: 'is lower than or equal to',
|
44
|
-
id: '
|
43
|
+
id: 'lower_equal',
|
45
44
|
type: 'number'
|
46
45
|
}, {
|
47
46
|
label: 'starts with',
|
48
|
-
id: '
|
47
|
+
id: 'starts_with',
|
49
48
|
type: 'text'
|
50
49
|
}, {
|
51
50
|
label: 'ends with',
|
52
|
-
id: '
|
51
|
+
id: 'ends_with',
|
53
52
|
type: 'text'
|
54
53
|
}, {
|
55
54
|
label: 'contains',
|
@@ -57,7 +56,7 @@ var operatorConfig = [{
|
|
57
56
|
type: 'text'
|
58
57
|
}, {
|
59
58
|
label: 'is one of',
|
60
|
-
id: '
|
59
|
+
id: 'one_of',
|
61
60
|
type: 'option'
|
62
61
|
}, {
|
63
62
|
label: 'is before',
|
@@ -92,11 +91,17 @@ var valueRenderers = {
|
|
92
91
|
time: function time(val) {
|
93
92
|
return val;
|
94
93
|
},
|
95
|
-
number: function number(val
|
96
|
-
return
|
94
|
+
number: function number(val) {
|
95
|
+
return val;
|
97
96
|
},
|
98
97
|
option: function option(value) {
|
99
|
-
|
98
|
+
if (value && typeof value !== 'string') {
|
99
|
+
var selectedValues = Array.isArray(value) ? value : [value];
|
100
|
+
return selectedValues.map(function (option) {
|
101
|
+
return option.label;
|
102
|
+
}).join(', ');
|
103
|
+
}
|
104
|
+
return value;
|
100
105
|
},
|
101
106
|
date: function date(value) {
|
102
107
|
if (Array.isArray(value) && value.length > 1) {
|
@@ -106,6 +111,9 @@ var valueRenderers = {
|
|
106
111
|
} else {
|
107
112
|
return value && new Date(value) ? formatDate(new Date(value)) : value;
|
108
113
|
}
|
114
|
+
},
|
115
|
+
custom: function custom(value) {
|
116
|
+
return value;
|
109
117
|
}
|
110
118
|
};
|
111
119
|
|
@@ -1,38 +1,41 @@
|
|
1
1
|
export namespace translationsObject {
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
2
|
+
namespace en {
|
3
|
+
let _if: string;
|
4
|
+
export { _if as if };
|
5
|
+
export let excl_if: string;
|
6
|
+
export let and: string;
|
7
|
+
export let or: string;
|
8
|
+
export let is: string;
|
9
|
+
export let greater: string;
|
10
|
+
export let greater_equal: string;
|
11
|
+
export let lower: string;
|
12
|
+
export let lower_equal: string;
|
13
|
+
export let starts_with: string;
|
14
|
+
export let ends_with: string;
|
15
|
+
export let contains: string;
|
16
|
+
export let one_of: string;
|
17
|
+
export let before: string;
|
18
|
+
export let after: string;
|
19
|
+
export let between: string;
|
20
|
+
export let add_condition: string;
|
21
|
+
export let add_condition_group: string;
|
22
|
+
export let add_subgroup: string;
|
23
|
+
export let condition: string;
|
24
|
+
export let property: string;
|
25
|
+
export let operator: string;
|
26
|
+
export let value: string;
|
27
|
+
export let connector: string;
|
28
|
+
export let condition_row: string;
|
29
|
+
export let remove_condition: string;
|
30
|
+
export let add_condition_row: string;
|
31
|
+
export let start: string;
|
32
|
+
export let end: string;
|
33
|
+
export let clear_search: string;
|
34
|
+
export let actions: string;
|
35
|
+
export let then: string;
|
36
|
+
export let remove_action: string;
|
37
|
+
export let add_action: string;
|
38
|
+
export let invalid_text: string;
|
39
|
+
export let text_invalid_number: string;
|
40
|
+
}
|
38
41
|
}
|
@@ -8,24 +8,24 @@
|
|
8
8
|
var translationsObject = {
|
9
9
|
en: {
|
10
10
|
if: 'if',
|
11
|
-
|
11
|
+
excl_if: 'excl.if',
|
12
12
|
and: 'and',
|
13
13
|
or: 'or',
|
14
14
|
is: 'is',
|
15
15
|
greater: 'is greater than',
|
16
|
-
|
16
|
+
greater_equal: 'is greater than or equal to',
|
17
17
|
lower: 'is lower than',
|
18
|
-
|
19
|
-
|
20
|
-
|
18
|
+
lower_equal: 'is lower than or equal to',
|
19
|
+
starts_with: 'starts with',
|
20
|
+
ends_with: 'ends with',
|
21
21
|
contains: 'contains',
|
22
|
-
|
22
|
+
one_of: 'is one of',
|
23
23
|
before: 'is before',
|
24
24
|
after: 'is after',
|
25
25
|
between: 'is between',
|
26
|
-
|
27
|
-
|
28
|
-
|
26
|
+
add_condition: 'Add condition',
|
27
|
+
add_condition_group: 'Add condition group',
|
28
|
+
add_subgroup: 'Add subgroup',
|
29
29
|
condition: 'Condition',
|
30
30
|
property: 'Property',
|
31
31
|
operator: 'Operator',
|
@@ -40,7 +40,9 @@ var translationsObject = {
|
|
40
40
|
actions: 'Actions',
|
41
41
|
then: 'then',
|
42
42
|
remove_action: 'Remove Action',
|
43
|
-
add_action: 'Add action'
|
43
|
+
add_action: 'Add action',
|
44
|
+
invalid_text: 'Incomplete',
|
45
|
+
text_invalid_number: 'Invalid number, must be 0 or greater'
|
44
46
|
}
|
45
47
|
};
|
46
48
|
|
@@ -17,7 +17,7 @@ export namespace ConditionBuilderItem {
|
|
17
17
|
let className: PropTypes.Requireable<string>;
|
18
18
|
let condition: PropTypes.Requireable<object>;
|
19
19
|
let config: PropTypes.Requireable<object>;
|
20
|
-
let label: PropTypes.Requireable<NonNullable<string |
|
20
|
+
let label: PropTypes.Requireable<NonNullable<string | object | null | undefined>>;
|
21
21
|
let popOverClassName: PropTypes.Requireable<string>;
|
22
22
|
let renderIcon: PropTypes.Requireable<object>;
|
23
23
|
let showToolTip: PropTypes.Requireable<boolean>;
|
@@ -10,7 +10,7 @@ import React__default, { useRef, useState, useEffect } from 'react';
|
|
10
10
|
import { Popover, PopoverContent, Layer } from '@carbon/react';
|
11
11
|
import PropTypes from '../../../node_modules/prop-types/index.js';
|
12
12
|
import { Add } from '@carbon/react/icons';
|
13
|
-
import {
|
13
|
+
import { translateWithId, blockClass, valueRenderers } from '../ConditionBuilderContext/DataConfigs.js';
|
14
14
|
import { ConditionBuilderButton } from '../ConditionBuilderButton/ConditionBuilderButton.js';
|
15
15
|
|
16
16
|
var _excluded = ["children", "className", "label", "renderIcon", "title", "type", "showToolTip", "condition", "popOverClassName", "config"];
|
@@ -27,19 +27,26 @@ var ConditionBuilderItem = function ConditionBuilderItem(_ref) {
|
|
27
27
|
config = _ref.config,
|
28
28
|
rest = _objectWithoutProperties(_ref, _excluded);
|
29
29
|
var contentRef = useRef(null);
|
30
|
-
var _useState = useState(
|
30
|
+
var _useState = useState(false),
|
31
31
|
_useState2 = _slicedToArray(_useState, 2),
|
32
|
-
|
33
|
-
|
34
|
-
var
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
32
|
+
open = _useState2[0],
|
33
|
+
setOpen = _useState2[1];
|
34
|
+
var getPropertyDetails = function getPropertyDetails() {
|
35
|
+
if (label === 'INVALID') {
|
36
|
+
return {
|
37
|
+
propertyLabel: translateWithId('invalid_text'),
|
38
|
+
isInvalid: true
|
39
|
+
};
|
40
|
+
}
|
39
41
|
var propertyId = rest['data-name'] == 'valueField' && type ? valueRenderers[type](label, config) : label;
|
40
|
-
|
41
|
-
|
42
|
-
|
42
|
+
return {
|
43
|
+
isInvalid: false,
|
44
|
+
propertyLabel: translateWithId(propertyId)
|
45
|
+
};
|
46
|
+
};
|
47
|
+
var _getPropertyDetails = getPropertyDetails(),
|
48
|
+
propertyLabel = _getPropertyDetails.propertyLabel,
|
49
|
+
isInvalid = _getPropertyDetails.isInvalid;
|
43
50
|
useEffect(function () {
|
44
51
|
/**
|
45
52
|
* rest['data-name'] holds the current field name
|
@@ -51,7 +58,7 @@ var ConditionBuilderItem = function ConditionBuilderItem(_ref) {
|
|
51
58
|
if (condition.popoverToOpen && currentField !== condition.popoverToOpen) {
|
52
59
|
// close the previous popover
|
53
60
|
setOpen(false);
|
54
|
-
} else if (currentField == 'valueField' && type == 'option' && condition.operator !== '
|
61
|
+
} else if (currentField == 'valueField' && type == 'option' && condition.operator !== 'one_of') {
|
55
62
|
//close the current popover if the field is valueField and is a single select dropdown. For all other inputs ,popover need to be open on value changes.
|
56
63
|
setOpen(false);
|
57
64
|
}
|
@@ -84,7 +91,7 @@ var ConditionBuilderItem = function ConditionBuilderItem(_ref) {
|
|
84
91
|
setOpen(false);
|
85
92
|
}
|
86
93
|
}, /*#__PURE__*/React__default.createElement(ConditionBuilderButton, _extends({
|
87
|
-
label: propertyLabel !== null && propertyLabel !== void 0 ? propertyLabel : translateWithId('
|
94
|
+
label: propertyLabel !== null && propertyLabel !== void 0 ? propertyLabel : translateWithId('add_condition'),
|
88
95
|
hideLabel: !label ? true : false,
|
89
96
|
onClick: function onClick() {
|
90
97
|
children ? setOpen(!open) : null;
|
@@ -93,7 +100,8 @@ var ConditionBuilderItem = function ConditionBuilderItem(_ref) {
|
|
93
100
|
"aria-haspopup": true,
|
94
101
|
"aria-expanded": open,
|
95
102
|
renderIcon: renderIcon ? renderIcon : label == undefined ? Add : null,
|
96
|
-
showToolTip: showToolTip
|
103
|
+
showToolTip: showToolTip,
|
104
|
+
isInvalid: isInvalid
|
97
105
|
}, rest)), /*#__PURE__*/React__default.createElement(PopoverContent, {
|
98
106
|
className: "".concat(blockClass, "__item__content"),
|
99
107
|
role: "dialog",
|
@@ -125,7 +133,7 @@ ConditionBuilderItem.propTypes = {
|
|
125
133
|
/**
|
126
134
|
* text to be displayed in the field
|
127
135
|
*/
|
128
|
-
label: PropTypes.oneOfType([PropTypes.string, PropTypes.array]),
|
136
|
+
label: PropTypes.oneOfType([PropTypes.string, PropTypes.array, PropTypes.object]),
|
129
137
|
/**
|
130
138
|
* class name for popover
|
131
139
|
*/
|
@@ -7,10 +7,9 @@
|
|
7
7
|
|
8
8
|
import React__default from 'react';
|
9
9
|
import { NumberInput } from '@carbon/react';
|
10
|
-
import { pkg } from '../../../../settings.js';
|
11
10
|
import PropTypes from '../../../../node_modules/prop-types/index.js';
|
11
|
+
import { blockClass, translateWithId } from '../../ConditionBuilderContext/DataConfigs.js';
|
12
12
|
|
13
|
-
var blockClass = "".concat(pkg.prefix, "--condition-builder");
|
14
13
|
var ConditionBuilderItemNumber = function ConditionBuilderItemNumber(_ref) {
|
15
14
|
var _conditionState$prope;
|
16
15
|
var conditionState = _ref.conditionState,
|
@@ -18,18 +17,34 @@ var ConditionBuilderItemNumber = function ConditionBuilderItemNumber(_ref) {
|
|
18
17
|
onChange = _ref.onChange;
|
19
18
|
var onChangeHandler = function onChangeHandler(e, _ref2) {
|
20
19
|
var value = _ref2.value;
|
21
|
-
|
20
|
+
if (checkIfValid(value)) {
|
21
|
+
var _config$unit;
|
22
|
+
onChange("".concat(value, " ").concat((_config$unit = config.unit) !== null && _config$unit !== void 0 ? _config$unit : ''));
|
23
|
+
} else {
|
24
|
+
onChange('INVALID');
|
25
|
+
}
|
26
|
+
};
|
27
|
+
var checkIfValid = function checkIfValid(value) {
|
28
|
+
if (value > config.max || value < config.min) {
|
29
|
+
return false;
|
30
|
+
}
|
31
|
+
return true;
|
32
|
+
};
|
33
|
+
var getDefaultValue = function getDefaultValue() {
|
34
|
+
var _conditionState$value;
|
35
|
+
return (_conditionState$value = conditionState.value) === null || _conditionState$value === void 0 || (_conditionState$value = _conditionState$value.split(' ')) === null || _conditionState$value === void 0 ? void 0 : _conditionState$value[0];
|
22
36
|
};
|
23
37
|
return /*#__PURE__*/React__default.createElement("div", {
|
24
38
|
className: "".concat(blockClass, "__item-number")
|
25
39
|
}, /*#__PURE__*/React__default.createElement(NumberInput, {
|
26
40
|
label: conditionState.property,
|
27
41
|
hideLabel: true,
|
42
|
+
defaultValue: getDefaultValue(),
|
28
43
|
id: (_conditionState$prope = conditionState.property) === null || _conditionState$prope === void 0 ? void 0 : _conditionState$prope.replace(/\s/g, ''),
|
29
|
-
value: conditionState.value ? conditionState.value.split(' ')[0] : conditionState.value,
|
30
44
|
min: config.min,
|
31
45
|
max: config.max,
|
32
46
|
step: config.step,
|
47
|
+
invalidText: translateWithId('text_invalid_number'),
|
33
48
|
allowEmpty: true,
|
34
49
|
onChange: onChangeHandler
|
35
50
|
}));
|
@@ -0,0 +1,13 @@
|
|
1
|
+
export function ItemOption({ conditionState, config, onChange }: {
|
2
|
+
conditionState?: {} | undefined;
|
3
|
+
config?: {} | undefined;
|
4
|
+
onChange: any;
|
5
|
+
}): import("react/jsx-runtime").JSX.Element | undefined;
|
6
|
+
export namespace ItemOption {
|
7
|
+
namespace propTypes {
|
8
|
+
let conditionState: PropTypes.Requireable<object>;
|
9
|
+
let config: PropTypes.Requireable<object>;
|
10
|
+
let onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
11
|
+
}
|
12
|
+
}
|
13
|
+
import PropTypes from 'prop-types';
|