@carbon/ibm-products 2.42.1-canary.7 → 2.43.0
Sign up to get free protection for your applications and to get access to all the features.
- package/css/index-full-carbon.css +302 -9
- 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.css +302 -9
- 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 +302 -9
- 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.d.ts +6 -0
- package/es/components/ConditionBuilder/ConditionBlock/ConditionBlock.js +74 -33
- package/es/components/ConditionBuilder/ConditionBuilderAdd/ConditionBuilderAdd.d.ts +15 -1
- package/es/components/ConditionBuilder/ConditionBuilderAdd/ConditionBuilderAdd.js +95 -12
- package/es/components/ConditionBuilder/ConditionBuilderButton/ConditionBuilderButton.d.ts +11 -2
- package/es/components/ConditionBuilder/ConditionBuilderButton/ConditionBuilderButton.js +27 -9
- package/es/components/ConditionBuilder/{ConditionConnector → ConditionBuilderConnector}/ConditionConnector.js +38 -33
- package/es/components/ConditionBuilder/ConditionBuilderConnector/GroupConnector.d.ts +2 -0
- package/es/components/ConditionBuilder/ConditionBuilderConnector/GroupConnector.js +44 -0
- package/es/components/ConditionBuilder/ConditionBuilderContent/ConditionBuilderContent.d.ts +5 -0
- package/es/components/ConditionBuilder/ConditionBuilderContent/ConditionBuilderContent.js +95 -14
- package/es/components/ConditionBuilder/ConditionBuilderContext/ConditionBuilderProvider.d.ts +1 -0
- package/es/components/ConditionBuilder/ConditionBuilderContext/ConditionBuilderProvider.js +1 -0
- package/es/components/ConditionBuilder/ConditionBuilderContext/translationObject.d.ts +7 -0
- package/es/components/ConditionBuilder/ConditionBuilderContext/translationObject.js +8 -1
- package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItem.js +1 -1
- package/es/components/ConditionBuilder/ConditionGroupBuilder/ConditionGroupBuilder.js +197 -67
- package/es/components/ConditionBuilder/ConditionPreview/ConditionPreview.d.ts +10 -0
- package/es/components/ConditionBuilder/ConditionPreview/ConditionPreview.js +69 -0
- package/es/components/ConditionBuilder/utils/util.d.ts +1 -0
- package/es/components/Datagrid/Datagrid/DatagridHeaderRow.js +1 -1
- package/es/components/Datagrid/Datagrid/DatagridVirtualBody.d.ts +1 -1
- package/es/components/Datagrid/Datagrid/DatagridVirtualBody.js +0 -5
- package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/CustomizeColumnsTearsheet.js +7 -4
- package/es/components/Datagrid/Datagrid/addons/Filtering/hooks/useFilterContext.d.ts +7 -1
- package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditCell/InlineEditCell.d.ts +1 -0
- package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditCell/InlineEditCell.js +12 -2
- package/es/components/Datagrid/types/index.d.ts +2 -0
- package/es/components/Datagrid/useColumnOrder.d.ts +7 -1
- package/es/components/Datagrid/useFiltering.d.ts +8 -1
- package/es/components/Datagrid/useFiltering.js +8 -7
- package/es/components/Datagrid/useFlexResize.d.ts +1 -1
- package/es/components/Datagrid/useFlexResize.js +11 -11
- package/es/components/Datagrid/useNestedRows.js +24 -2
- package/es/components/Datagrid/useOnRowClick.d.ts +8 -1
- package/es/components/Datagrid/useOnRowClick.js +2 -1
- package/es/components/Datagrid/useRowIsMouseOver.d.ts +2 -1
- package/es/components/Datagrid/useRowIsMouseOver.js +1 -1
- package/es/components/Datagrid/useSelectRows.d.ts +8 -1
- package/es/components/Datagrid/useSelectRows.js +3 -2
- package/es/components/Datagrid/useSortableColumns.d.ts +10 -3
- package/es/components/Datagrid/useSortableColumns.js +3 -2
- package/es/components/Datagrid/utils/getAutoSizedColumnWidth.d.ts +8 -1
- package/es/components/Datagrid/utils/getAutoSizedColumnWidth.js +0 -7
- package/es/components/SidePanel/SidePanel.js +4 -2
- package/lib/components/ConditionBuilder/ConditionBlock/ConditionBlock.d.ts +6 -0
- package/lib/components/ConditionBuilder/ConditionBlock/ConditionBlock.js +73 -32
- package/lib/components/ConditionBuilder/ConditionBuilderAdd/ConditionBuilderAdd.d.ts +15 -1
- package/lib/components/ConditionBuilder/ConditionBuilderAdd/ConditionBuilderAdd.js +92 -9
- package/lib/components/ConditionBuilder/ConditionBuilderButton/ConditionBuilderButton.d.ts +11 -2
- package/lib/components/ConditionBuilder/ConditionBuilderButton/ConditionBuilderButton.js +26 -8
- package/lib/components/ConditionBuilder/{ConditionConnector → ConditionBuilderConnector}/ConditionConnector.js +36 -31
- package/lib/components/ConditionBuilder/ConditionBuilderConnector/GroupConnector.d.ts +2 -0
- package/lib/components/ConditionBuilder/ConditionBuilderConnector/GroupConnector.js +52 -0
- package/lib/components/ConditionBuilder/ConditionBuilderContent/ConditionBuilderContent.d.ts +5 -0
- package/lib/components/ConditionBuilder/ConditionBuilderContent/ConditionBuilderContent.js +92 -11
- package/lib/components/ConditionBuilder/ConditionBuilderContext/ConditionBuilderProvider.d.ts +1 -0
- package/lib/components/ConditionBuilder/ConditionBuilderContext/ConditionBuilderProvider.js +1 -0
- package/lib/components/ConditionBuilder/ConditionBuilderContext/translationObject.d.ts +7 -0
- package/lib/components/ConditionBuilder/ConditionBuilderContext/translationObject.js +8 -1
- package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItem.js +1 -1
- package/lib/components/ConditionBuilder/ConditionGroupBuilder/ConditionGroupBuilder.js +195 -64
- package/lib/components/ConditionBuilder/ConditionPreview/ConditionPreview.d.ts +10 -0
- package/lib/components/ConditionBuilder/ConditionPreview/ConditionPreview.js +77 -0
- package/lib/components/ConditionBuilder/utils/util.d.ts +1 -0
- package/lib/components/Datagrid/Datagrid/DatagridHeaderRow.js +1 -1
- package/lib/components/Datagrid/Datagrid/DatagridVirtualBody.d.ts +1 -1
- package/lib/components/Datagrid/Datagrid/DatagridVirtualBody.js +0 -5
- package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/CustomizeColumnsTearsheet.js +7 -4
- package/lib/components/Datagrid/Datagrid/addons/Filtering/hooks/useFilterContext.d.ts +7 -1
- package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditCell/InlineEditCell.d.ts +1 -0
- package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditCell/InlineEditCell.js +12 -2
- package/lib/components/Datagrid/types/index.d.ts +2 -0
- package/lib/components/Datagrid/useColumnOrder.d.ts +7 -1
- package/lib/components/Datagrid/useFiltering.d.ts +8 -1
- package/lib/components/Datagrid/useFiltering.js +8 -7
- package/lib/components/Datagrid/useFlexResize.d.ts +1 -1
- package/lib/components/Datagrid/useFlexResize.js +11 -11
- package/lib/components/Datagrid/useNestedRows.js +24 -2
- package/lib/components/Datagrid/useOnRowClick.d.ts +8 -1
- package/lib/components/Datagrid/useOnRowClick.js +2 -1
- package/lib/components/Datagrid/useRowIsMouseOver.d.ts +2 -1
- package/lib/components/Datagrid/useRowIsMouseOver.js +1 -1
- package/lib/components/Datagrid/useSelectRows.d.ts +8 -1
- package/lib/components/Datagrid/useSelectRows.js +3 -2
- package/lib/components/Datagrid/useSortableColumns.d.ts +10 -3
- package/lib/components/Datagrid/useSortableColumns.js +3 -2
- package/lib/components/Datagrid/utils/getAutoSizedColumnWidth.d.ts +8 -1
- package/lib/components/Datagrid/utils/getAutoSizedColumnWidth.js +0 -7
- package/lib/components/SidePanel/SidePanel.js +4 -2
- package/package.json +3 -3
- package/scss/components/ConditionBuilder/_condition-builder.scss +21 -1
- package/scss/components/ConditionBuilder/styles/_conditionBuilderCondition.scss +22 -3
- package/scss/components/ConditionBuilder/styles/_conditionBuilderItem.scss +58 -21
- package/telemetry.yml +23 -0
- /package/es/components/ConditionBuilder/{ConditionConnector → ConditionBuilderConnector}/ConditionConnector.d.ts +0 -0
- /package/lib/components/ConditionBuilder/{ConditionConnector → ConditionBuilderConnector}/ConditionConnector.d.ts +0 -0
@@ -8,25 +8,38 @@
|
|
8
8
|
import { slicedToArray as _slicedToArray, objectSpread2 as _objectSpread2, extends as _extends, toConsumableArray as _toConsumableArray } from '../../../_virtual/_rollupPluginBabelHelpers.js';
|
9
9
|
import React__default, { useContext, useState, useEffect, useCallback } from 'react';
|
10
10
|
import PropTypes from '../../../node_modules/prop-types/index.js';
|
11
|
-
import { Button } from '@carbon/react';
|
12
|
-
import { Add } from '@carbon/react/icons';
|
11
|
+
import { Button, Section, Heading } from '@carbon/react';
|
12
|
+
import { Add, TextNewLine } from '@carbon/react/icons';
|
13
13
|
import ConditionGroupBuilder from '../ConditionGroupBuilder/ConditionGroupBuilder.js';
|
14
14
|
import { ConditionBuilderContext, emptyState } from '../ConditionBuilderContext/ConditionBuilderProvider.js';
|
15
|
-
import { blockClass } from '../ConditionBuilderContext/DataConfigs.js';
|
15
|
+
import { blockClass, translateWithId } from '../ConditionBuilderContext/DataConfigs.js';
|
16
|
+
import { ConditionBuilderButton } from '../ConditionBuilderButton/ConditionBuilderButton.js';
|
17
|
+
import uuidv4 from '../../../global/js/utils/uuidv4.js';
|
18
|
+
import ConditionPreview from '../ConditionPreview/ConditionPreview.js';
|
19
|
+
import GroupConnector from '../ConditionBuilderConnector/GroupConnector.js';
|
16
20
|
|
21
|
+
var _Heading, _GroupConnector, _ConditionPreview;
|
17
22
|
var ConditionBuilderContent = function ConditionBuilderContent(_ref) {
|
18
23
|
var _rootState$groups2;
|
19
24
|
var startConditionLabel = _ref.startConditionLabel,
|
20
25
|
conditionBuilderRef = _ref.conditionBuilderRef,
|
21
26
|
getConditionState = _ref.getConditionState,
|
22
27
|
initialState = _ref.initialState;
|
28
|
+
// const { rootState, setRootState, variant, actionState } = useContext(
|
29
|
+
// ConditionBuilderContext
|
30
|
+
// );
|
23
31
|
var _useContext = useContext(ConditionBuilderContext),
|
24
32
|
rootState = _useContext.rootState,
|
25
|
-
setRootState = _useContext.setRootState
|
33
|
+
setRootState = _useContext.setRootState,
|
34
|
+
variant = _useContext.variant;
|
26
35
|
var _useState = useState(false),
|
27
36
|
_useState2 = _slicedToArray(_useState, 2),
|
28
37
|
isConditionBuilderActive = _useState2[0],
|
29
38
|
setIsConditionBuilderActive = _useState2[1];
|
39
|
+
var _useState3 = useState(false),
|
40
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
41
|
+
showConditionGroupPreview = _useState4[0],
|
42
|
+
setShowConditionGroupPreview = _useState4[1];
|
30
43
|
useEffect(function () {
|
31
44
|
var _rootState$groups;
|
32
45
|
if (rootState !== null && rootState !== void 0 && (_rootState$groups = rootState.groups) !== null && _rootState$groups !== void 0 && _rootState$groups.length) {
|
@@ -39,7 +52,12 @@ var ConditionBuilderContent = function ConditionBuilderContent(_ref) {
|
|
39
52
|
}
|
40
53
|
|
41
54
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
42
|
-
}, [rootState
|
55
|
+
}, [rootState]);
|
56
|
+
|
57
|
+
// useEffect(() => {
|
58
|
+
// getActionsState?.(actionState);
|
59
|
+
// // eslint-disable-next-line react-hooks/exhaustive-deps
|
60
|
+
// }, [actionState]);
|
43
61
|
var onStartConditionBuilder = function onStartConditionBuilder() {
|
44
62
|
//when add condition button is clicked.
|
45
63
|
setIsConditionBuilderActive(true);
|
@@ -63,10 +81,28 @@ var ConditionBuilderContent = function ConditionBuilderContent(_ref) {
|
|
63
81
|
groups: groups
|
64
82
|
}));
|
65
83
|
};
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
84
|
+
var addConditionGroupHandler = function addConditionGroupHandler() {
|
85
|
+
var newGroup = {
|
86
|
+
groupSeparateOperator: 'and',
|
87
|
+
// 'or'|'and'|'null',
|
88
|
+
groupOperator: 'and',
|
89
|
+
//'and|or',
|
90
|
+
statement: 'if',
|
91
|
+
// 'if|exclude if',
|
92
|
+
id: uuidv4(),
|
93
|
+
conditions: [{
|
94
|
+
property: undefined,
|
95
|
+
operator: '',
|
96
|
+
value: '',
|
97
|
+
popoverToOpen: 'propertyField',
|
98
|
+
id: uuidv4()
|
99
|
+
}]
|
100
|
+
};
|
101
|
+
setRootState(_objectSpread2(_objectSpread2({}, rootState), {}, {
|
102
|
+
groups: [].concat(_toConsumableArray(rootState.groups), [newGroup])
|
103
|
+
}));
|
104
|
+
};
|
105
|
+
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, !isConditionBuilderActive && /*#__PURE__*/React__default.createElement(Button, {
|
70
106
|
className: "".concat(blockClass, "__add-condition-button"),
|
71
107
|
renderIcon: function renderIcon(props) {
|
72
108
|
return /*#__PURE__*/React__default.createElement(Add, _extends({
|
@@ -77,10 +113,22 @@ var ConditionBuilderContent = function ConditionBuilderContent(_ref) {
|
|
77
113
|
kind: "ghost",
|
78
114
|
size: "sm",
|
79
115
|
onClick: onStartConditionBuilder
|
80
|
-
}, startConditionLabel),
|
81
|
-
|
116
|
+
}, startConditionLabel), isConditionBuilderActive &&
|
117
|
+
/*#__PURE__*/
|
118
|
+
// <h5 >Condition</h5>
|
119
|
+
React__default.createElement(Section, {
|
120
|
+
className: "".concat(blockClass, "__heading"),
|
121
|
+
level: 4
|
122
|
+
}, _Heading || (_Heading = /*#__PURE__*/React__default.createElement(Heading, null, "Condition"))), /*#__PURE__*/React__default.createElement("div", {
|
123
|
+
className: "".concat(blockClass, "__content-container"),
|
124
|
+
role: "treegrid",
|
125
|
+
"aria-label": "condition builder tree"
|
126
|
+
}, rootState && (rootState === null || rootState === void 0 || (_rootState$groups2 = rootState.groups) === null || _rootState$groups2 === void 0 ? void 0 : _rootState$groups2.map(function (eachGroup, groupIndex) {
|
127
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
128
|
+
key: eachGroup.id,
|
129
|
+
className: "".concat(blockClass, "__group-wrapper")
|
130
|
+
}, /*#__PURE__*/React__default.createElement(ConditionGroupBuilder, {
|
82
131
|
className: "".concat(blockClass, "__group"),
|
83
|
-
key: groupIndex,
|
84
132
|
aria: {
|
85
133
|
level: 1,
|
86
134
|
posinset: groupIndex * 2 + 1,
|
@@ -94,15 +142,48 @@ var ConditionBuilderContent = function ConditionBuilderContent(_ref) {
|
|
94
142
|
onChangeHandler(updatedGroup, groupIndex);
|
95
143
|
},
|
96
144
|
conditionBuilderRef: conditionBuilderRef
|
97
|
-
});
|
98
|
-
}))
|
145
|
+
}), groupIndex < rootState.groups.length - 1 && (_GroupConnector || (_GroupConnector = /*#__PURE__*/React__default.createElement(GroupConnector, null))));
|
146
|
+
})), isConditionBuilderActive && /*#__PURE__*/React__default.createElement(React__default.Fragment, null, variant == 'tree' && /*#__PURE__*/React__default.createElement("div", {
|
147
|
+
role: "row",
|
148
|
+
tabIndex: -1,
|
149
|
+
"aria-level": 1
|
150
|
+
}, /*#__PURE__*/React__default.createElement(ConditionBuilderButton, {
|
151
|
+
renderIcon: TextNewLine,
|
152
|
+
onClick: addConditionGroupHandler,
|
153
|
+
onMouseEnter: function onMouseEnter() {
|
154
|
+
setShowConditionGroupPreview(true);
|
155
|
+
},
|
156
|
+
onMouseLeave: function onMouseLeave() {
|
157
|
+
setShowConditionGroupPreview(false);
|
158
|
+
},
|
159
|
+
className: "".concat(blockClass, "__add-condition-group "),
|
160
|
+
hideLabel: true,
|
161
|
+
label: translateWithId('add-condition-sub-group'),
|
162
|
+
wrapperProps: {
|
163
|
+
role: 'gridcell',
|
164
|
+
'aria-label': translateWithId('add-condition-sub-group')
|
165
|
+
}
|
166
|
+
})), showConditionGroupPreview && (_ConditionPreview || (_ConditionPreview = /*#__PURE__*/React__default.createElement(ConditionPreview, {
|
167
|
+
previewType: "newGroup"
|
168
|
+
}))))));
|
99
169
|
};
|
100
170
|
var ConditionBuilderContent$1 = ConditionBuilderContent;
|
101
171
|
ConditionBuilderContent.propTypes = {
|
172
|
+
/**
|
173
|
+
* optional array of object that give the list of actions.
|
174
|
+
*/
|
175
|
+
actions: PropTypes.arrayOf(PropTypes.shape({
|
176
|
+
id: PropTypes.number,
|
177
|
+
label: PropTypes.string
|
178
|
+
})),
|
102
179
|
/**
|
103
180
|
* ref of condition builder
|
104
181
|
*/
|
105
182
|
conditionBuilderRef: PropTypes.object,
|
183
|
+
/**
|
184
|
+
* callback functions that will provide the updated action state back.
|
185
|
+
*/
|
186
|
+
getActionsState: PropTypes.func,
|
106
187
|
/**
|
107
188
|
* This is a callback function that returns the updated state
|
108
189
|
*/
|
@@ -17,9 +17,12 @@ export namespace translationsObject {
|
|
17
17
|
after: string;
|
18
18
|
between: string;
|
19
19
|
'add-condition': string;
|
20
|
+
'add-condition-group': string;
|
21
|
+
'add-condition-sub-group': string;
|
20
22
|
condition: string;
|
21
23
|
property: string;
|
22
24
|
operator: string;
|
25
|
+
value: string;
|
23
26
|
connector: string;
|
24
27
|
condition_row: string;
|
25
28
|
remove_condition: string;
|
@@ -27,5 +30,9 @@ export namespace translationsObject {
|
|
27
30
|
start: string;
|
28
31
|
end: string;
|
29
32
|
clear_search: string;
|
33
|
+
actions: string;
|
34
|
+
then: string;
|
35
|
+
remove_action: string;
|
36
|
+
add_action: string;
|
30
37
|
};
|
31
38
|
}
|
@@ -24,16 +24,23 @@ var translationsObject = {
|
|
24
24
|
after: 'is after',
|
25
25
|
between: 'is between',
|
26
26
|
'add-condition': 'Add Condition',
|
27
|
+
'add-condition-group': 'Add Condition Group',
|
28
|
+
'add-condition-sub-group': 'Add Condition sub group',
|
27
29
|
condition: 'Condition',
|
28
30
|
property: 'Property',
|
29
31
|
operator: 'Operator',
|
32
|
+
value: 'Value',
|
30
33
|
connector: 'Connector',
|
31
34
|
condition_row: 'Condition row',
|
32
35
|
remove_condition: 'Remove condition',
|
33
36
|
add_condition_row: 'Add condition row',
|
34
37
|
start: 'Start',
|
35
38
|
end: 'End',
|
36
|
-
clear_search: 'Clear search input'
|
39
|
+
clear_search: 'Clear search input',
|
40
|
+
actions: 'Actions',
|
41
|
+
then: 'then',
|
42
|
+
remove_action: 'Remove Action',
|
43
|
+
add_action: 'Add action'
|
37
44
|
}
|
38
45
|
};
|
39
46
|
|
@@ -87,7 +87,7 @@ var ConditionBuilderItem = function ConditionBuilderItem(_ref) {
|
|
87
87
|
label: propertyLabel !== null && propertyLabel !== void 0 ? propertyLabel : translateWithId('add-condition'),
|
88
88
|
hideLabel: !label ? true : false,
|
89
89
|
onClick: function onClick() {
|
90
|
-
setOpen(!open);
|
90
|
+
children ? setOpen(!open) : null;
|
91
91
|
},
|
92
92
|
className: className,
|
93
93
|
"aria-haspopup": true,
|
@@ -5,12 +5,21 @@
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
6
6
|
*/
|
7
7
|
|
8
|
-
import { objectSpread2 as _objectSpread2, toConsumableArray as _toConsumableArray } from '../../../_virtual/_rollupPluginBabelHelpers.js';
|
9
|
-
import React__default from 'react';
|
8
|
+
import { slicedToArray as _slicedToArray, defineProperty as _defineProperty, objectSpread2 as _objectSpread2, toConsumableArray as _toConsumableArray } from '../../../_virtual/_rollupPluginBabelHelpers.js';
|
9
|
+
import React__default, { useContext, useState, Fragment } from 'react';
|
10
10
|
import ConditionBlock from '../ConditionBlock/ConditionBlock.js';
|
11
11
|
import PropTypes from '../../../node_modules/prop-types/index.js';
|
12
|
-
import
|
12
|
+
import cx from 'classnames';
|
13
|
+
import { blockClass, translateWithId, statementConfig } from '../ConditionBuilderContext/DataConfigs.js';
|
14
|
+
import { ConditionBuilderItem } from '../ConditionBuilderItem/ConditionBuilderItem.js';
|
15
|
+
import { ConditionBuilderItemOption } from '../ConditionBuilderItem/ConditionBuilderItemOption/ConditionBuilderItemOption.js';
|
16
|
+
import { focusThisField } from '../utils/util.js';
|
17
|
+
import ConditionConnector from '../ConditionBuilderConnector/ConditionConnector.js';
|
18
|
+
import { ConditionBuilderContext } from '../ConditionBuilderContext/ConditionBuilderProvider.js';
|
13
19
|
import uuidv4 from '../../../global/js/utils/uuidv4.js';
|
20
|
+
import ConditionPreview from '../ConditionPreview/ConditionPreview.js';
|
21
|
+
|
22
|
+
var _ConditionPreview, _ConditionPreview2;
|
14
23
|
|
15
24
|
/**
|
16
25
|
*
|
@@ -18,14 +27,24 @@ import uuidv4 from '../../../global/js/utils/uuidv4.js';
|
|
18
27
|
* All the inner components of group are called from here.
|
19
28
|
* @returns
|
20
29
|
*/
|
30
|
+
|
21
31
|
var ConditionGroupBuilder = function ConditionGroupBuilder(_ref) {
|
22
|
-
var _group$conditions;
|
23
32
|
var group = _ref.group,
|
24
33
|
aria = _ref.aria,
|
25
34
|
onRemove = _ref.onRemove,
|
26
35
|
onChange = _ref.onChange,
|
27
36
|
conditionBuilderRef = _ref.conditionBuilderRef,
|
28
37
|
className = _ref.className;
|
38
|
+
var _useContext = useContext(ConditionBuilderContext),
|
39
|
+
variant = _useContext.variant;
|
40
|
+
var _useState = useState(-1),
|
41
|
+
_useState2 = _slicedToArray(_useState, 2),
|
42
|
+
showConditionPreview = _useState2[0],
|
43
|
+
setShowConditionPreview = _useState2[1];
|
44
|
+
var _useState3 = useState(-1),
|
45
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
46
|
+
showConditionSubGroupPreview = _useState4[0],
|
47
|
+
setShowConditionSubGroupPreview = _useState4[1];
|
29
48
|
var onRemoveHandler = function onRemoveHandler(conditionId, evt) {
|
30
49
|
if (group.conditions.length > 1) {
|
31
50
|
onChange(_objectSpread2(_objectSpread2({}, group), {}, {
|
@@ -56,72 +75,183 @@ var ConditionGroupBuilder = function ConditionGroupBuilder(_ref) {
|
|
56
75
|
conditions: [].concat(_toConsumableArray(group.conditions.slice(0, conditionIndex + 1)), [newCondition], _toConsumableArray(group.conditions.slice(conditionIndex + 1)))
|
57
76
|
}));
|
58
77
|
};
|
59
|
-
var
|
60
|
-
|
61
|
-
|
62
|
-
var handleFocusOnClose = function handleFocusOnClose(evt) {
|
63
|
-
var _evt$currentTarget;
|
64
|
-
var previousClose = (_evt$currentTarget = evt.currentTarget) === null || _evt$currentTarget === void 0 || (_evt$currentTarget = _evt$currentTarget.closest('[role="row"]')) === null || _evt$currentTarget === void 0 || (_evt$currentTarget = _evt$currentTarget.parentElement) === null || _evt$currentTarget === void 0 || (_evt$currentTarget = _evt$currentTarget.previousSibling) === null || _evt$currentTarget === void 0 ? void 0 : _evt$currentTarget.querySelector('[data-name="closeCondition"]');
|
78
|
+
var handleFocusOnClose = function handleFocusOnClose(e) {
|
79
|
+
var _e$currentTarget;
|
80
|
+
var previousClose = (_e$currentTarget = e.currentTarget) === null || _e$currentTarget === void 0 || (_e$currentTarget = _e$currentTarget.closest('[role="row"]')) === null || _e$currentTarget === void 0 || (_e$currentTarget = _e$currentTarget.previousSibling) === null || _e$currentTarget === void 0 ? void 0 : _e$currentTarget.querySelector('[data-name="closeCondition"]');
|
65
81
|
if (previousClose) {
|
66
82
|
previousClose.focus();
|
67
83
|
}
|
68
84
|
};
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
85
|
+
var addConditionSubGroupHandler = function addConditionSubGroupHandler(conditionIndex) {
|
86
|
+
onChange(_objectSpread2(_objectSpread2({}, group), {}, {
|
87
|
+
conditions: [].concat(_toConsumableArray(group.conditions.slice(0, conditionIndex + 1)), [{
|
88
|
+
groupSeparateOperator: null,
|
89
|
+
groupOperator: 'and',
|
90
|
+
statement: 'if',
|
91
|
+
conditions: [{
|
92
|
+
property: undefined,
|
93
|
+
operator: '',
|
94
|
+
value: '',
|
95
|
+
popoverToOpen: 'propertyField',
|
96
|
+
id: uuidv4()
|
97
|
+
}],
|
98
|
+
id: uuidv4()
|
99
|
+
}], _toConsumableArray(group.conditions.slice(conditionIndex + 1)))
|
100
|
+
}));
|
101
|
+
};
|
102
|
+
var isLastCondition = function isLastCondition(conditionIndex, conditionArr) {
|
103
|
+
return conditionIndex + 1 >= conditionArr.length || conditionArr.length - 1 != conditionIndex && conditionArr[conditionIndex + 1].conditions;
|
104
|
+
};
|
105
|
+
var _showConditionSubGroupPreviewHandler = function showConditionSubGroupPreviewHandler(conditionIndex) {
|
106
|
+
setShowConditionSubGroupPreview(conditionIndex);
|
107
|
+
};
|
108
|
+
var hideConditionSubGroupPreviewHandler = function hideConditionSubGroupPreviewHandler() {
|
109
|
+
setShowConditionSubGroupPreview(-1);
|
110
|
+
};
|
111
|
+
var _showConditionPreviewHandler = function showConditionPreviewHandler(conditionIndex) {
|
112
|
+
setShowConditionPreview(conditionIndex);
|
113
|
+
};
|
114
|
+
var hideConditionPreviewHandler = function hideConditionPreviewHandler() {
|
115
|
+
setShowConditionPreview(-1);
|
116
|
+
};
|
117
|
+
var onStatementChangeHandler = function onStatementChangeHandler(updatedStatement) {
|
118
|
+
onChange(_objectSpread2(_objectSpread2({}, group), {}, {
|
119
|
+
statement: updatedStatement
|
120
|
+
}));
|
121
|
+
};
|
122
|
+
var onConnectorOperatorChange = function onConnectorOperatorChange(op) {
|
123
|
+
onChange(_objectSpread2(_objectSpread2({}, group), {}, {
|
124
|
+
groupOperator: op
|
125
|
+
}));
|
126
|
+
};
|
127
|
+
var getSentenceVariant = function getSentenceVariant() {
|
128
|
+
var _group$conditions;
|
76
129
|
return /*#__PURE__*/React__default.createElement("div", {
|
77
|
-
|
78
|
-
},
|
79
|
-
className: "".concat(blockClass, "
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
}
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
130
|
+
className: "".concat(className, " eachGroup")
|
131
|
+
}, /*#__PURE__*/React__default.createElement("div", {
|
132
|
+
className: "".concat(blockClass, "__condition-wrapper"),
|
133
|
+
role: "grid",
|
134
|
+
"aria-label": translateWithId('condition_builder_group')
|
135
|
+
}, group === null || group === void 0 || (_group$conditions = group.conditions) === null || _group$conditions === void 0 ? void 0 : _group$conditions.map(function (eachCondition, conditionIndex) {
|
136
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
137
|
+
key: eachCondition.id,
|
138
|
+
className: "".concat(blockClass, "__group-wrapper")
|
139
|
+
}, /*#__PURE__*/React__default.createElement(ConditionBlock, {
|
140
|
+
conjunction: conditionIndex > 0 ? group.groupOperator : undefined,
|
141
|
+
aria: {
|
142
|
+
level: aria.level + 1,
|
143
|
+
posinset: conditionIndex + 1,
|
144
|
+
setsize: group.conditions.length
|
145
|
+
},
|
146
|
+
isStatement: conditionIndex == 0,
|
147
|
+
condition: eachCondition,
|
148
|
+
group: group,
|
149
|
+
conditionIndex: conditionIndex,
|
150
|
+
onChange: function onChange(updatedConditions) {
|
151
|
+
onChangeHandler(updatedConditions, conditionIndex);
|
152
|
+
},
|
153
|
+
addConditionHandler: addConditionHandler,
|
154
|
+
onRemove: function onRemove(e) {
|
155
|
+
onRemoveHandler(eachCondition.id, e);
|
156
|
+
},
|
157
|
+
onConnectorOperatorChange: onConnectorOperatorChange,
|
158
|
+
onStatementChange: onStatementChangeHandler,
|
159
|
+
isLastCondition: isLastCondition
|
160
|
+
}));
|
161
|
+
})));
|
162
|
+
};
|
163
|
+
var getTreeVariant = function getTreeVariant() {
|
164
|
+
var _group$conditions2;
|
165
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
166
|
+
className: "".concat(className, " ").concat(blockClass, "__condition-wrapper"),
|
167
|
+
role: aria.level === 1 ? 'rowgroup' : undefined,
|
168
|
+
"aria-label": aria.level == 1 ? translateWithId('condition_builder_group') : undefined
|
169
|
+
}, /*#__PURE__*/React__default.createElement("div", {
|
170
|
+
tabIndex: 0,
|
171
|
+
role: "row",
|
172
|
+
"aria-level": aria.level,
|
173
|
+
"aria-posinset": aria.posinset,
|
174
|
+
"aria-setsize": aria.setsize
|
175
|
+
}, /*#__PURE__*/React__default.createElement(ConditionBuilderItem, {
|
176
|
+
label: group.statement,
|
177
|
+
title: translateWithId('condition'),
|
178
|
+
"data-name": "connectorField",
|
179
|
+
popOverClassName: "".concat(blockClass, "__gap"),
|
180
|
+
className: "".concat(blockClass, "__statement-button")
|
181
|
+
}, /*#__PURE__*/React__default.createElement(ConditionBuilderItemOption, {
|
182
|
+
conditionState: {
|
183
|
+
value: group.statement,
|
184
|
+
label: translateWithId('condition')
|
116
185
|
},
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
}));
|
186
|
+
onChange: function onChange(v, evt) {
|
187
|
+
focusThisField(evt);
|
188
|
+
onStatementChangeHandler(v);
|
121
189
|
},
|
122
|
-
|
190
|
+
config: {
|
191
|
+
options: statementConfig
|
192
|
+
}
|
193
|
+
}))), group === null || group === void 0 || (_group$conditions2 = group.conditions) === null || _group$conditions2 === void 0 ? void 0 : _group$conditions2.map(function (eachCondition, conditionIndex) {
|
194
|
+
return /*#__PURE__*/React__default.createElement(Fragment, {
|
195
|
+
key: eachCondition.id
|
196
|
+
}, eachCondition.conditions ? /*#__PURE__*/React__default.createElement("div", {
|
197
|
+
className: cx("".concat(blockClass, "__condition-block subgroup ").concat(blockClass, "__gap"), _defineProperty({}, "".concat(blockClass, "__gap-bottom"), group.conditions.length < conditionIndex + 1))
|
198
|
+
}, /*#__PURE__*/React__default.createElement(ConditionConnector, {
|
199
|
+
className: "".concat(blockClass, "__gap ").concat(blockClass, "__groupConnector"),
|
200
|
+
operator: group.groupOperator,
|
201
|
+
"aria-hidden": true
|
202
|
+
}), /*#__PURE__*/React__default.createElement(ConditionGroupBuilder, {
|
203
|
+
aria: {
|
204
|
+
level: aria.level + 1,
|
205
|
+
posinset: conditionIndex + 1,
|
206
|
+
setsize: group.conditions.length
|
207
|
+
},
|
208
|
+
className: "".concat(blockClass, "__group"),
|
209
|
+
group: eachCondition,
|
210
|
+
onChange: function onChange(updatedConditions) {
|
211
|
+
onChangeHandler(updatedConditions, conditionIndex);
|
212
|
+
},
|
213
|
+
onRemove: function onRemove(e) {
|
214
|
+
onRemoveHandler(eachCondition.id, e);
|
215
|
+
},
|
216
|
+
conditionBuilderRef: conditionBuilderRef
|
217
|
+
})) : /*#__PURE__*/React__default.createElement(ConditionBlock, {
|
218
|
+
conjunction: conditionIndex > 0 ? group.groupOperator : undefined,
|
219
|
+
aria: {
|
220
|
+
level: aria.level + 1,
|
221
|
+
posinset: conditionIndex + 1,
|
222
|
+
setsize: group.conditions.length
|
223
|
+
},
|
224
|
+
isStatement: false,
|
225
|
+
condition: eachCondition,
|
226
|
+
group: group,
|
227
|
+
conditionIndex: conditionIndex,
|
228
|
+
addConditionHandler: addConditionHandler,
|
229
|
+
addConditionSubGroupHandler: addConditionSubGroupHandler,
|
230
|
+
onChange: function onChange(updatedConditions) {
|
231
|
+
onChangeHandler(updatedConditions, conditionIndex);
|
232
|
+
},
|
233
|
+
onRemove: function onRemove(e) {
|
234
|
+
onRemoveHandler(eachCondition.id, e);
|
235
|
+
},
|
236
|
+
onConnectorOperatorChange: onConnectorOperatorChange,
|
237
|
+
onStatementChange: onStatementChangeHandler,
|
238
|
+
showConditionSubGroupPreviewHandler: function showConditionSubGroupPreviewHandler() {
|
239
|
+
_showConditionSubGroupPreviewHandler(conditionIndex);
|
240
|
+
},
|
241
|
+
hideConditionSubGroupPreviewHandler: hideConditionSubGroupPreviewHandler,
|
242
|
+
showConditionPreviewHandler: function showConditionPreviewHandler() {
|
243
|
+
_showConditionPreviewHandler(conditionIndex);
|
244
|
+
},
|
245
|
+
hideConditionPreviewHandler: hideConditionPreviewHandler,
|
246
|
+
isLastCondition: isLastCondition
|
247
|
+
}), conditionIndex == showConditionSubGroupPreview && (_ConditionPreview || (_ConditionPreview = /*#__PURE__*/React__default.createElement(ConditionPreview, {
|
248
|
+
previewType: "subGroup"
|
249
|
+
}))), conditionIndex == showConditionPreview && (_ConditionPreview2 || (_ConditionPreview2 = /*#__PURE__*/React__default.createElement(ConditionPreview, {
|
250
|
+
previewType: "condition"
|
251
|
+
}))));
|
123
252
|
}));
|
124
|
-
}
|
253
|
+
};
|
254
|
+
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, variant == 'tree' && getTreeVariant(), variant == 'sentence' && getSentenceVariant());
|
125
255
|
};
|
126
256
|
var ConditionGroupBuilder$1 = ConditionGroupBuilder;
|
127
257
|
ConditionGroupBuilder.propTypes = {
|
@@ -130,19 +260,19 @@ ConditionGroupBuilder.propTypes = {
|
|
130
260
|
*/
|
131
261
|
aria: PropTypes.object,
|
132
262
|
/**
|
133
|
-
*
|
263
|
+
* state defines the current group
|
264
|
+
*/
|
265
|
+
/**
|
266
|
+
* Provide an optional class to be applied to the containing node.
|
134
267
|
*/
|
135
268
|
className: PropTypes.string,
|
136
269
|
/**
|
270
|
+
className: PropTypes.string,
|
137
271
|
* ref of condition builder
|
138
272
|
*/
|
139
273
|
conditionBuilderRef: PropTypes.object,
|
140
|
-
/**
|
141
|
-
* group defines the current group
|
142
|
-
*/
|
143
274
|
group: PropTypes.object,
|
144
275
|
/**
|
145
|
-
|
146
276
|
* callback to update the current condition of the state tree
|
147
277
|
*/
|
148
278
|
onChange: PropTypes.func,
|
@@ -0,0 +1,10 @@
|
|
1
|
+
export default ConditionPreview;
|
2
|
+
declare function ConditionPreview({ previewType }: {
|
3
|
+
previewType: any;
|
4
|
+
}): import("react/jsx-runtime").JSX.Element;
|
5
|
+
declare namespace ConditionPreview {
|
6
|
+
namespace propTypes {
|
7
|
+
let previewType: PropTypes.Requireable<string>;
|
8
|
+
}
|
9
|
+
}
|
10
|
+
import PropTypes from 'prop-types';
|
@@ -0,0 +1,69 @@
|
|
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 React__default from 'react';
|
9
|
+
import PropTypes from '../../../node_modules/prop-types/index.js';
|
10
|
+
import { blockClass, translateWithId } from '../ConditionBuilderContext/DataConfigs.js';
|
11
|
+
import { ConditionBuilderItem } from '../ConditionBuilderItem/ConditionBuilderItem.js';
|
12
|
+
import ConditionConnector from '../ConditionBuilderConnector/ConditionConnector.js';
|
13
|
+
|
14
|
+
var ConditionPreview = function ConditionPreview(_ref) {
|
15
|
+
var previewType = _ref.previewType;
|
16
|
+
var getConditionSection = function getConditionSection() {
|
17
|
+
return /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement(ConditionBuilderItem, {
|
18
|
+
label: translateWithId('property')
|
19
|
+
}), /*#__PURE__*/React__default.createElement(ConditionBuilderItem, {
|
20
|
+
label: translateWithId('operator')
|
21
|
+
}), /*#__PURE__*/React__default.createElement(ConditionBuilderItem, {
|
22
|
+
label: translateWithId('value')
|
23
|
+
}));
|
24
|
+
};
|
25
|
+
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 ")
|
27
|
+
}, /*#__PURE__*/React__default.createElement(ConditionBuilderItem, {
|
28
|
+
className: "".concat(blockClass, "__statement-button"),
|
29
|
+
label: translateWithId('and')
|
30
|
+
})), /*#__PURE__*/React__default.createElement("div", {
|
31
|
+
"aria-hidden": true,
|
32
|
+
className: "".concat(blockClass, "__group ").concat(blockClass, "__condition-wrapper ").concat(blockClass, "__group-preview ").concat(blockClass, "__group-wrapper")
|
33
|
+
}, /*#__PURE__*/React__default.createElement("div", {
|
34
|
+
className: "".concat(blockClass, "__gap")
|
35
|
+
}, /*#__PURE__*/React__default.createElement(ConditionBuilderItem, {
|
36
|
+
className: "".concat(blockClass, "__statement-button"),
|
37
|
+
label: translateWithId('if')
|
38
|
+
})), getConditionSection())), previewType == 'subGroup' && /*#__PURE__*/React__default.createElement("div", {
|
39
|
+
className: "".concat(blockClass, "__group-preview")
|
40
|
+
}, /*#__PURE__*/React__default.createElement("div", {
|
41
|
+
className: "".concat(blockClass, "__condition-block ").concat(blockClass, "__gap")
|
42
|
+
}, /*#__PURE__*/React__default.createElement(ConditionBuilderItem, {
|
43
|
+
label: translateWithId('and'),
|
44
|
+
className: "".concat(blockClass, "__statement-button"),
|
45
|
+
popOverClassName: "".concat(blockClass, "__gap")
|
46
|
+
}), /*#__PURE__*/React__default.createElement("div", {
|
47
|
+
className: "".concat(blockClass, "__group ").concat(blockClass, "__condition-wrapper")
|
48
|
+
}, /*#__PURE__*/React__default.createElement(ConditionConnector, {
|
49
|
+
className: "".concat(blockClass, "__gap ").concat(blockClass, "__groupConnector"),
|
50
|
+
operator: translateWithId('if')
|
51
|
+
}), getConditionSection()))), previewType == 'condition' && /*#__PURE__*/React__default.createElement("div", {
|
52
|
+
className: "".concat(blockClass, "__group-preview")
|
53
|
+
}, /*#__PURE__*/React__default.createElement("div", {
|
54
|
+
className: "".concat(blockClass, "__condition-block ").concat(blockClass, "__gap")
|
55
|
+
}, /*#__PURE__*/React__default.createElement(ConditionBuilderItem, {
|
56
|
+
label: translateWithId('and'),
|
57
|
+
className: "".concat(blockClass, "__statement-button"),
|
58
|
+
popOverClassName: "".concat(blockClass, "__gap")
|
59
|
+
}), getConditionSection())));
|
60
|
+
};
|
61
|
+
var ConditionPreview$1 = ConditionPreview;
|
62
|
+
ConditionPreview.propTypes = {
|
63
|
+
/**
|
64
|
+
* type of review to be displayed
|
65
|
+
*/
|
66
|
+
previewType: PropTypes.oneOf(['condition', 'subGroup', 'newGroup'])
|
67
|
+
};
|
68
|
+
|
69
|
+
export { ConditionPreview$1 as default };
|
@@ -2,3 +2,4 @@ export function focusThisField(evt: any): void;
|
|
2
2
|
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
|
+
export function checkForHoldingKey(evt: any, key: any): any;
|