@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
@@ -17,7 +17,7 @@ var index = require('../../../node_modules/prop-types/index.js');
|
|
17
17
|
var DataConfigs = require('../ConditionBuilderContext/DataConfigs.js');
|
18
18
|
var ConditionBuilderItemOption = require('../ConditionBuilderItem/ConditionBuilderItemOption/ConditionBuilderItemOption.js');
|
19
19
|
var cx = require('classnames');
|
20
|
-
var ConditionConnector = require('../
|
20
|
+
var ConditionConnector = require('../ConditionBuilderConnector/ConditionConnector.js');
|
21
21
|
var ConditionBuilderItemNumber = require('../ConditionBuilderItem/ConditionBuilderItemNumber/ConditionBuilderItemNumber.js');
|
22
22
|
var ConditionBuilderItemText = require('../ConditionBuilderItem/ConditionBuilderItemText/ConditionBuilderItemText.js');
|
23
23
|
var ConditionBuilderItemDate = require('../ConditionBuilderItem/ConditionBuilderItemDate/ConditionBuilderItemDate.js');
|
@@ -32,6 +32,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
32
32
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
33
33
|
var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
34
34
|
|
35
|
+
var _div;
|
35
36
|
/**
|
36
37
|
* This component build each block of condition consisting of property, operator value and close button.
|
37
38
|
*/
|
@@ -49,11 +50,19 @@ var ConditionBlock = function ConditionBlock(props) {
|
|
49
50
|
isStatement = props.isStatement,
|
50
51
|
group = props.group,
|
51
52
|
onStatementChange = props.onStatementChange,
|
52
|
-
addConditionHandler = props.addConditionHandler,
|
53
53
|
conditionIndex = props.conditionIndex,
|
54
|
+
addConditionHandler = props.addConditionHandler,
|
55
|
+
_addConditionSubGroupHandler = props.addConditionSubGroupHandler,
|
56
|
+
aria = props.aria,
|
57
|
+
hideConditionSubGroupPreviewHandler = props.hideConditionSubGroupPreviewHandler,
|
58
|
+
showConditionSubGroupPreviewHandler = props.showConditionSubGroupPreviewHandler,
|
59
|
+
hideConditionPreviewHandler = props.hideConditionPreviewHandler,
|
60
|
+
showConditionPreviewHandler = props.showConditionPreviewHandler,
|
54
61
|
isLastCondition = props.isLastCondition;
|
55
62
|
var _useContext = React.useContext(ConditionBuilderProvider.ConditionBuilderContext),
|
56
|
-
inputConfig = _useContext.inputConfig
|
63
|
+
inputConfig = _useContext.inputConfig,
|
64
|
+
variant = _useContext.variant;
|
65
|
+
//Below possible input types expected for value field.
|
57
66
|
var itemComponents = {
|
58
67
|
option: ConditionBuilderItemOption.ConditionBuilderItemOption,
|
59
68
|
text: ConditionBuilderItemText.ConditionBuilderItemText,
|
@@ -78,14 +87,17 @@ var ConditionBlock = function ConditionBlock(props) {
|
|
78
87
|
type = _getCurrentConfig.type,
|
79
88
|
config = _getCurrentConfig.config,
|
80
89
|
label = _getCurrentConfig.label;
|
81
|
-
var ItemComponent
|
90
|
+
var ItemComponent;
|
91
|
+
// if (type == 'custom') {
|
92
|
+
// ItemComponent = config.component;
|
93
|
+
// } else {
|
94
|
+
ItemComponent = property ? itemComponents[type] : null;
|
95
|
+
//}
|
96
|
+
|
82
97
|
var onStatementChangeHandler = function onStatementChangeHandler(v, evt) {
|
83
98
|
util.focusThisField(evt);
|
84
99
|
onStatementChange(v);
|
85
100
|
};
|
86
|
-
var onConnectorOperatorChangeHandler = function onConnectorOperatorChangeHandler(op) {
|
87
|
-
onConnectorOperatorChange(op);
|
88
|
-
};
|
89
101
|
var onPropertyChangeHandler = function onPropertyChangeHandler(newProperty) {
|
90
102
|
onChange(_rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, condition), {}, {
|
91
103
|
property: newProperty,
|
@@ -118,21 +130,32 @@ var ConditionBlock = function ConditionBlock(props) {
|
|
118
130
|
return operator.type.indexOf(type) != -1 || operator.type == 'all';
|
119
131
|
});
|
120
132
|
};
|
121
|
-
|
122
|
-
|
123
|
-
|
133
|
+
var getAriaAttributes = function getAriaAttributes() {
|
134
|
+
return variant == 'tree' ? {
|
135
|
+
'aria-level': aria.level,
|
136
|
+
'aria-posinset': aria.posinset,
|
137
|
+
'aria-setsize': aria.setsize
|
138
|
+
} : {};
|
139
|
+
};
|
140
|
+
return /*#__PURE__*/React__default["default"].createElement("div", _rollupPluginBabelHelpers["extends"]({
|
141
|
+
className: cx__default["default"]("".concat(DataConfigs.blockClass, "__condition-block"), _rollupPluginBabelHelpers.defineProperty({}, "".concat(DataConfigs.blockClass, "__condition__deletion-preview"), showDeletionPreview), _rollupPluginBabelHelpers.defineProperty({}, "".concat(DataConfigs.blockClass, "__gap-bottom"), variant == 'tree' && !(conditionIndex + 1 >= group.conditions.length)), _rollupPluginBabelHelpers.defineProperty({}, "".concat(DataConfigs.blockClass, "__gap ").concat(DataConfigs.blockClass, "__gap-bottom"), variant == 'sentence')),
|
124
142
|
role: "row",
|
125
143
|
"aria-label": DataConfigs.translateWithId('condition_row'),
|
126
144
|
tabIndex: -1
|
127
|
-
},
|
128
|
-
|
129
|
-
|
145
|
+
}, getAriaAttributes()), conjunction ? /*#__PURE__*/React__default["default"].createElement(ConditionConnector["default"], {
|
146
|
+
className: "".concat(DataConfigs.blockClass, "__gap"),
|
147
|
+
operator: conjunction,
|
148
|
+
onChange: function onChange(op) {
|
149
|
+
return onConnectorOperatorChange(op);
|
150
|
+
}
|
151
|
+
}) : _div || (_div = /*#__PURE__*/React__default["default"].createElement("div", {
|
152
|
+
role: "gridcell"
|
153
|
+
})), isStatement && /*#__PURE__*/React__default["default"].createElement(ConditionBuilderItem.ConditionBuilderItem, {
|
130
154
|
label: group.statement,
|
131
155
|
title: DataConfigs.translateWithId('condition'),
|
132
156
|
"data-name": "connectorField",
|
133
157
|
popOverClassName: "".concat(DataConfigs.blockClass, "__gap"),
|
134
|
-
className: "".concat(DataConfigs.blockClass, "__statement-button")
|
135
|
-
tabIndex: 0
|
158
|
+
className: "".concat(DataConfigs.blockClass, "__statement-button")
|
136
159
|
}, /*#__PURE__*/React__default["default"].createElement(ConditionBuilderItemOption.ConditionBuilderItemOption, {
|
137
160
|
conditionState: {
|
138
161
|
value: group.statement,
|
@@ -142,11 +165,7 @@ var ConditionBlock = function ConditionBlock(props) {
|
|
142
165
|
config: {
|
143
166
|
options: DataConfigs.statementConfig
|
144
167
|
}
|
145
|
-
})),
|
146
|
-
className: "".concat(DataConfigs.blockClass, "__gap"),
|
147
|
-
operator: conjunction,
|
148
|
-
onChange: onConnectorOperatorChangeHandler
|
149
|
-
}), /*#__PURE__*/React__default["default"].createElement(ConditionBuilderItem.ConditionBuilderItem, {
|
168
|
+
})), /*#__PURE__*/React__default["default"].createElement(ConditionBuilderItem.ConditionBuilderItem, {
|
150
169
|
label: label,
|
151
170
|
title: DataConfigs.translateWithId('property'),
|
152
171
|
renderIcon: icon !== null && icon !== void 0 ? icon : null,
|
@@ -193,7 +212,8 @@ var ConditionBlock = function ConditionBlock(props) {
|
|
193
212
|
value: value
|
194
213
|
},
|
195
214
|
onChange: onValueChangeHandler,
|
196
|
-
config: config
|
215
|
+
config: config,
|
216
|
+
"data-name": "valueField"
|
197
217
|
})), /*#__PURE__*/React__default["default"].createElement("span", {
|
198
218
|
role: "gridcell",
|
199
219
|
"aria-label": DataConfigs.translateWithId('remove_condition')
|
@@ -211,9 +231,15 @@ var ConditionBlock = function ConditionBlock(props) {
|
|
211
231
|
})), isLastCondition(conditionIndex, group.conditions) && /*#__PURE__*/React__default["default"].createElement(ConditionBuilderAdd["default"], {
|
212
232
|
onClick: function onClick() {
|
213
233
|
addConditionHandler(conditionIndex);
|
214
|
-
}
|
215
|
-
|
216
|
-
|
234
|
+
},
|
235
|
+
addConditionSubGroupHandler: function addConditionSubGroupHandler() {
|
236
|
+
_addConditionSubGroupHandler(conditionIndex);
|
237
|
+
},
|
238
|
+
showConditionSubGroupPreviewHandler: showConditionSubGroupPreviewHandler,
|
239
|
+
hideConditionSubGroupPreviewHandler: hideConditionSubGroupPreviewHandler,
|
240
|
+
enableSubGroup: variant == 'tree',
|
241
|
+
showConditionPreviewHandler: showConditionPreviewHandler,
|
242
|
+
hideConditionPreviewHandler: hideConditionPreviewHandler,
|
217
243
|
className: "".concat(DataConfigs.blockClass, "__gap ").concat(DataConfigs.blockClass, "__gap-left")
|
218
244
|
}));
|
219
245
|
};
|
@@ -224,16 +250,14 @@ ConditionBlock.propTypes = {
|
|
224
250
|
*/
|
225
251
|
addConditionHandler: index["default"].func,
|
226
252
|
/**
|
227
|
-
*
|
253
|
+
* callback to add a new condition subgroup
|
228
254
|
*/
|
229
|
-
|
255
|
+
addConditionSubGroupHandler: index["default"].func,
|
230
256
|
/**
|
231
|
-
* object
|
257
|
+
* object hold aria attributes
|
232
258
|
*/
|
259
|
+
aria: index["default"].object,
|
233
260
|
condition: index["default"].object,
|
234
|
-
/**
|
235
|
-
* index of the current condition
|
236
|
-
*/
|
237
261
|
conditionIndex: index["default"].number,
|
238
262
|
/**
|
239
263
|
* string that decides to show the condition connector
|
@@ -244,8 +268,13 @@ ConditionBlock.propTypes = {
|
|
244
268
|
*/
|
245
269
|
group: index["default"].object,
|
246
270
|
/**
|
247
|
-
*
|
271
|
+
* handler for hiding sub group preview
|
272
|
+
*/
|
273
|
+
hideConditionPreviewHandler: index["default"].func,
|
274
|
+
/**
|
275
|
+
* handler for hiding sub group preview
|
248
276
|
*/
|
277
|
+
hideConditionSubGroupPreviewHandler: index["default"].func,
|
249
278
|
isLastCondition: index["default"].func,
|
250
279
|
/**
|
251
280
|
* boolean that decides to show the statement(if/ excl.if)
|
@@ -266,7 +295,19 @@ ConditionBlock.propTypes = {
|
|
266
295
|
/**
|
267
296
|
* callback to handle the statement(if/ excl.if) change
|
268
297
|
*/
|
269
|
-
onStatementChange: index["default"].func
|
298
|
+
onStatementChange: index["default"].func,
|
299
|
+
/**
|
300
|
+
* handler for showing add condition preview
|
301
|
+
*/
|
302
|
+
showConditionPreviewHandler: index["default"].func,
|
303
|
+
/**
|
304
|
+
* handler for showing sub group preview
|
305
|
+
*/
|
306
|
+
showConditionSubGroupPreviewHandler: index["default"].func,
|
307
|
+
/**
|
308
|
+
* object that hold the current condition
|
309
|
+
*/
|
310
|
+
state: index["default"].object
|
270
311
|
};
|
271
312
|
|
272
313
|
exports["default"] = ConditionBlock$1;
|
@@ -1,12 +1,26 @@
|
|
1
1
|
export default ConditionBuilderAdd;
|
2
|
-
declare function ConditionBuilderAdd({ className, onClick }: {
|
2
|
+
declare function ConditionBuilderAdd({ className, onClick, addConditionSubGroupHandler, showConditionSubGroupPreviewHandler, hideConditionSubGroupPreviewHandler, showConditionPreviewHandler, hideConditionPreviewHandler, enableSubGroup, buttonLabel, }: {
|
3
3
|
className: any;
|
4
4
|
onClick: any;
|
5
|
+
addConditionSubGroupHandler: any;
|
6
|
+
showConditionSubGroupPreviewHandler: any;
|
7
|
+
hideConditionSubGroupPreviewHandler: any;
|
8
|
+
showConditionPreviewHandler: any;
|
9
|
+
hideConditionPreviewHandler: any;
|
10
|
+
enableSubGroup: any;
|
11
|
+
buttonLabel: any;
|
5
12
|
}): import("react/jsx-runtime").JSX.Element;
|
6
13
|
declare namespace ConditionBuilderAdd {
|
7
14
|
namespace propTypes {
|
15
|
+
let addConditionSubGroupHandler: PropTypes.Requireable<(...args: any[]) => any>;
|
16
|
+
let buttonLabel: PropTypes.Requireable<string>;
|
8
17
|
let className: PropTypes.Requireable<string>;
|
18
|
+
let enableSubGroup: PropTypes.Requireable<boolean>;
|
19
|
+
let hideConditionPreviewHandler: PropTypes.Requireable<(...args: any[]) => any>;
|
20
|
+
let hideConditionSubGroupPreviewHandler: PropTypes.Requireable<(...args: any[]) => any>;
|
9
21
|
let onClick: PropTypes.Requireable<(...args: any[]) => any>;
|
22
|
+
let showConditionPreviewHandler: PropTypes.Requireable<(...args: any[]) => any>;
|
23
|
+
let showConditionSubGroupPreviewHandler: PropTypes.Requireable<(...args: any[]) => any>;
|
10
24
|
}
|
11
25
|
}
|
12
26
|
import PropTypes from 'prop-types';
|
@@ -9,6 +9,7 @@
|
|
9
9
|
|
10
10
|
Object.defineProperty(exports, '__esModule', { value: true });
|
11
11
|
|
12
|
+
var _rollupPluginBabelHelpers = require('../../../_virtual/_rollupPluginBabelHelpers.js');
|
12
13
|
var React = require('react');
|
13
14
|
var icons = require('@carbon/react/icons');
|
14
15
|
var ConditionBuilderButton = require('../ConditionBuilderButton/ConditionBuilderButton.js');
|
@@ -21,28 +22,110 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
21
22
|
|
22
23
|
var ConditionBuilderAdd = function ConditionBuilderAdd(_ref) {
|
23
24
|
var className = _ref.className,
|
24
|
-
onClick = _ref.onClick
|
25
|
+
onClick = _ref.onClick,
|
26
|
+
addConditionSubGroupHandler = _ref.addConditionSubGroupHandler,
|
27
|
+
showConditionSubGroupPreviewHandler = _ref.showConditionSubGroupPreviewHandler,
|
28
|
+
hideConditionSubGroupPreviewHandler = _ref.hideConditionSubGroupPreviewHandler,
|
29
|
+
showConditionPreviewHandler = _ref.showConditionPreviewHandler,
|
30
|
+
hideConditionPreviewHandler = _ref.hideConditionPreviewHandler,
|
31
|
+
enableSubGroup = _ref.enableSubGroup,
|
32
|
+
buttonLabel = _ref.buttonLabel;
|
33
|
+
var _useState = React.useState(false),
|
34
|
+
_useState2 = _rollupPluginBabelHelpers.slicedToArray(_useState, 2),
|
35
|
+
isAddSubgroup = _useState2[0],
|
36
|
+
setIsAddSubgroup = _useState2[1];
|
37
|
+
var showAddSubGroup = function showAddSubGroup() {
|
38
|
+
setIsAddSubgroup(true);
|
39
|
+
};
|
40
|
+
var hideAddSubGroup = function hideAddSubGroup() {
|
41
|
+
setIsAddSubgroup(false);
|
42
|
+
};
|
43
|
+
var onClickHandler = function onClickHandler() {
|
44
|
+
hideConditionPreviewHandler === null || hideConditionPreviewHandler === void 0 || hideConditionPreviewHandler();
|
45
|
+
onClick();
|
46
|
+
};
|
47
|
+
var previewHandlers = function previewHandlers() {
|
48
|
+
return enableSubGroup ? {
|
49
|
+
onMouseEnter: showConditionPreviewHandler,
|
50
|
+
onMouseLeave: hideConditionPreviewHandler,
|
51
|
+
onFocus: showConditionPreviewHandler,
|
52
|
+
onBlur: hideConditionPreviewHandler
|
53
|
+
} : {};
|
54
|
+
};
|
55
|
+
var previewHandlersForSubgroup = function previewHandlersForSubgroup() {
|
56
|
+
return {
|
57
|
+
onMouseEnter: showConditionSubGroupPreviewHandler,
|
58
|
+
onMouseLeave: hideConditionSubGroupPreviewHandler,
|
59
|
+
onFocus: showConditionSubGroupPreviewHandler,
|
60
|
+
onBlur: hideConditionSubGroupPreviewHandler
|
61
|
+
};
|
62
|
+
};
|
63
|
+
var wrapperProps = enableSubGroup ? {
|
64
|
+
role: 'gridcell',
|
65
|
+
'aria-label': DataConfigs.translateWithId('add-condition')
|
66
|
+
} : {};
|
25
67
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
26
|
-
className: className,
|
27
|
-
role:
|
28
|
-
|
68
|
+
className: "".concat(className, " ").concat(DataConfigs.blockClass, "__add-button-wrapper"),
|
69
|
+
role: !enableSubGroup ? 'gridcell' : 'none',
|
70
|
+
"aria-label": !enableSubGroup ? DataConfigs.translateWithId('add_condition_row') : undefined,
|
71
|
+
onMouseEnter: showAddSubGroup,
|
72
|
+
onMouseLeave: hideAddSubGroup,
|
73
|
+
onFocus: showAddSubGroup,
|
74
|
+
onBlur: hideAddSubGroup
|
75
|
+
}, /*#__PURE__*/React__default["default"].createElement(ConditionBuilderButton.ConditionBuilderButton, _rollupPluginBabelHelpers["extends"]({
|
29
76
|
renderIcon: icons.AddAlt,
|
30
|
-
onClick:
|
77
|
+
onClick: onClickHandler
|
78
|
+
}, previewHandlers(), {
|
31
79
|
className: "".concat(DataConfigs.blockClass, "__add-button"),
|
32
80
|
hideLabel: true,
|
33
|
-
|
34
|
-
|
81
|
+
"data-name": "addButton",
|
82
|
+
label: buttonLabel !== null && buttonLabel !== void 0 ? buttonLabel : DataConfigs.translateWithId('add-condition'),
|
83
|
+
wrapperProps: wrapperProps
|
84
|
+
})), isAddSubgroup && enableSubGroup && /*#__PURE__*/React__default["default"].createElement(ConditionBuilderButton.ConditionBuilderButton, _rollupPluginBabelHelpers["extends"]({
|
85
|
+
renderIcon: icons.TextNewLine,
|
86
|
+
onClick: addConditionSubGroupHandler,
|
87
|
+
className: "".concat(DataConfigs.blockClass, "__add-condition-group ").concat(DataConfigs.blockClass, "__gap-left"),
|
88
|
+
hideLabel: true,
|
89
|
+
label: DataConfigs.translateWithId('add-condition'),
|
90
|
+
wrapperProps: wrapperProps
|
91
|
+
}, previewHandlersForSubgroup())));
|
35
92
|
};
|
36
93
|
var ConditionBuilderAdd$1 = ConditionBuilderAdd;
|
37
94
|
ConditionBuilderAdd.propTypes = {
|
95
|
+
/**
|
96
|
+
* handler for hiding sub group preview
|
97
|
+
*/
|
98
|
+
addConditionSubGroupHandler: index["default"].func,
|
99
|
+
/**
|
100
|
+
* handler for hiding sub group preview
|
101
|
+
*/ /**
|
102
|
+
* tooltip label for plus button
|
103
|
+
*/
|
104
|
+
buttonLabel: index["default"].string,
|
38
105
|
/**
|
39
106
|
* Provide an optional class to be applied to the containing node.
|
40
107
|
*/
|
41
108
|
className: index["default"].string,
|
42
109
|
/**
|
43
|
-
*
|
110
|
+
* boolean to enable sub groups for the tree variant
|
111
|
+
*/
|
112
|
+
enableSubGroup: index["default"].bool,
|
113
|
+
/**
|
114
|
+
* handler for hiding sub group preview
|
115
|
+
*/
|
116
|
+
hideConditionPreviewHandler: index["default"].func,
|
117
|
+
hideConditionSubGroupPreviewHandler: index["default"].func,
|
118
|
+
/**
|
119
|
+
* handler for hiding sub group preview
|
120
|
+
*/ /**
|
121
|
+
* callback triggered on click of add button
|
122
|
+
*/
|
123
|
+
onClick: index["default"].func,
|
124
|
+
showConditionPreviewHandler: index["default"].func,
|
125
|
+
showConditionSubGroupPreviewHandler: index["default"].func
|
126
|
+
/**
|
127
|
+
* handler for hiding sub group preview
|
44
128
|
*/
|
45
|
-
onClick: index["default"].func
|
46
129
|
};
|
47
130
|
|
48
131
|
exports["default"] = ConditionBuilderAdd$1;
|
@@ -1,5 +1,4 @@
|
|
1
|
-
export function ConditionBuilderButton({ className, label, hideLabel, tooltipAlign, renderIcon: Icon, onClick, showToolTip,
|
2
|
-
[x: string]: any;
|
1
|
+
export function ConditionBuilderButton({ className, label, hideLabel, tooltipAlign, renderIcon: Icon, onClick, showToolTip, wrapperProps, onBlur, onFocus, onMouseEnter, onMouseLeave, }: {
|
3
2
|
className: any;
|
4
3
|
label: any;
|
5
4
|
hideLabel: any;
|
@@ -7,16 +6,26 @@ export function ConditionBuilderButton({ className, label, hideLabel, tooltipAli
|
|
7
6
|
renderIcon: any;
|
8
7
|
onClick: any;
|
9
8
|
showToolTip: any;
|
9
|
+
wrapperProps: any;
|
10
|
+
onBlur: any;
|
11
|
+
onFocus: any;
|
12
|
+
onMouseEnter: any;
|
13
|
+
onMouseLeave: any;
|
10
14
|
}): import("react/jsx-runtime").JSX.Element;
|
11
15
|
export namespace ConditionBuilderButton {
|
12
16
|
namespace propTypes {
|
13
17
|
let className: PropTypes.Requireable<string>;
|
14
18
|
let hideLabel: PropTypes.Requireable<boolean>;
|
15
19
|
let label: PropTypes.Requireable<string>;
|
20
|
+
let onBlur: PropTypes.Requireable<(...args: any[]) => any>;
|
16
21
|
let onClick: PropTypes.Requireable<(...args: any[]) => any>;
|
22
|
+
let onFocus: PropTypes.Requireable<(...args: any[]) => any>;
|
23
|
+
let onMouseEnter: PropTypes.Requireable<(...args: any[]) => any>;
|
24
|
+
let onMouseLeave: PropTypes.Requireable<(...args: any[]) => any>;
|
17
25
|
let renderIcon: PropTypes.Requireable<object>;
|
18
26
|
let showToolTip: PropTypes.Requireable<boolean>;
|
19
27
|
let tooltipAlign: PropTypes.Requireable<string>;
|
28
|
+
let wrapperProps: PropTypes.Requireable<object>;
|
20
29
|
}
|
21
30
|
}
|
22
31
|
import PropTypes from 'prop-types';
|
@@ -21,9 +21,8 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
21
21
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
22
22
|
var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
23
23
|
|
24
|
-
var _excluded = ["className", "label", "hideLabel", "tooltipAlign", "renderIcon", "onClick", "showToolTip"];
|
25
24
|
var ConditionBuilderButton = function ConditionBuilderButton(_ref) {
|
26
|
-
var _Icon;
|
25
|
+
var _Icon, _span;
|
27
26
|
var className = _ref.className,
|
28
27
|
label = _ref.label,
|
29
28
|
hideLabel = _ref.hideLabel,
|
@@ -31,21 +30,29 @@ var ConditionBuilderButton = function ConditionBuilderButton(_ref) {
|
|
31
30
|
Icon = _ref.renderIcon,
|
32
31
|
onClick = _ref.onClick,
|
33
32
|
showToolTip = _ref.showToolTip,
|
34
|
-
|
33
|
+
wrapperProps = _ref.wrapperProps,
|
34
|
+
onBlur = _ref.onBlur,
|
35
|
+
onFocus = _ref.onFocus,
|
36
|
+
onMouseEnter = _ref.onMouseEnter,
|
37
|
+
onMouseLeave = _ref.onMouseLeave;
|
35
38
|
var Button = function Button() {
|
36
|
-
return /*#__PURE__*/React__default["default"].createElement("button",
|
39
|
+
return /*#__PURE__*/React__default["default"].createElement("button", {
|
37
40
|
// role={'gridcell'}
|
38
41
|
tabIndex: -1,
|
39
42
|
className: cx__default["default"]([className, "".concat(DataConfigs.blockClass, "__button"), _rollupPluginBabelHelpers.defineProperty({}, "".concat(DataConfigs.blockClass, "__text-ellipsis"), showToolTip && !hideLabel)]),
|
40
43
|
type: "button",
|
41
|
-
onClick: onClick
|
42
|
-
|
44
|
+
onClick: onClick,
|
45
|
+
onBlur: onBlur,
|
46
|
+
onFocus: onFocus,
|
47
|
+
onMouseEnter: onMouseEnter,
|
48
|
+
onMouseLeave: onMouseLeave
|
49
|
+
}, Icon && (_Icon || (_Icon = /*#__PURE__*/React__default["default"].createElement(Icon, null))), !hideLabel && (_span || (_span = /*#__PURE__*/React__default["default"].createElement("span", null, label))));
|
43
50
|
};
|
44
51
|
return hideLabel || showToolTip ? /*#__PURE__*/React__default["default"].createElement(react.Tooltip, _rollupPluginBabelHelpers["extends"]({
|
45
52
|
label: label,
|
46
53
|
align: tooltipAlign,
|
47
54
|
className: "".concat(DataConfigs.blockClass, "__con-tooltip")
|
48
|
-
},
|
55
|
+
}, wrapperProps), Button()) : /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, Button());
|
49
56
|
};
|
50
57
|
ConditionBuilderButton.propTypes = {
|
51
58
|
/**
|
@@ -60,10 +67,17 @@ ConditionBuilderButton.propTypes = {
|
|
60
67
|
* label of the button
|
61
68
|
*/
|
62
69
|
label: index["default"].string,
|
70
|
+
/**
|
71
|
+
* mouse events callbacks
|
72
|
+
*/
|
73
|
+
onBlur: index["default"].func,
|
63
74
|
/**
|
64
75
|
* callback triggered on click of add button
|
65
76
|
*/
|
66
77
|
onClick: index["default"].func,
|
78
|
+
onFocus: index["default"].func,
|
79
|
+
onMouseEnter: index["default"].func,
|
80
|
+
onMouseLeave: index["default"].func,
|
67
81
|
/**
|
68
82
|
* Optional prop to allow overriding the icon rendering.
|
69
83
|
*/
|
@@ -77,7 +91,11 @@ ConditionBuilderButton.propTypes = {
|
|
77
91
|
/**
|
78
92
|
* tooltip position
|
79
93
|
*/
|
80
|
-
tooltipAlign: index["default"].string
|
94
|
+
tooltipAlign: index["default"].string,
|
95
|
+
/**
|
96
|
+
* optional props for tree grid to add role and aria-label to wrapper span
|
97
|
+
*/
|
98
|
+
wrapperProps: index["default"].object
|
81
99
|
};
|
82
100
|
|
83
101
|
exports.ConditionBuilderButton = ConditionBuilderButton;
|
@@ -14,21 +14,22 @@ var React = require('react');
|
|
14
14
|
var ConditionBuilderItem = require('../ConditionBuilderItem/ConditionBuilderItem.js');
|
15
15
|
var ConditionBuilderItemOption = require('../ConditionBuilderItem/ConditionBuilderItemOption/ConditionBuilderItemOption.js');
|
16
16
|
var DataConfigs = require('../ConditionBuilderContext/DataConfigs.js');
|
17
|
-
var settings = require('../../../settings.js');
|
18
17
|
var index = require('../../../node_modules/prop-types/index.js');
|
19
18
|
var util = require('../utils/util.js');
|
19
|
+
var ConditionBuilderProvider = require('../ConditionBuilderContext/ConditionBuilderProvider.js');
|
20
20
|
|
21
21
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
22
22
|
|
23
23
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
24
24
|
|
25
25
|
var _excluded = ["operator", "className", "onChange"];
|
26
|
-
var
|
27
|
-
function ConditionConnector(_ref) {
|
26
|
+
var ConditionConnector = function ConditionConnector(_ref) {
|
28
27
|
var operator = _ref.operator,
|
29
28
|
className = _ref.className,
|
30
29
|
onChange = _ref.onChange,
|
31
30
|
rest = _rollupPluginBabelHelpers.objectWithoutProperties(_ref, _excluded);
|
31
|
+
var _useContext = React.useContext(ConditionBuilderProvider.ConditionBuilderContext),
|
32
|
+
variant = _useContext.variant;
|
32
33
|
var handleConnectorHover = React.useCallback(function (parentGroup, isHover) {
|
33
34
|
if (isHover) {
|
34
35
|
parentGroup.classList.add('hoveredConnector');
|
@@ -48,33 +49,37 @@ function ConditionConnector(_ref) {
|
|
48
49
|
onChange(op);
|
49
50
|
util.focusThisField(evt);
|
50
51
|
};
|
51
|
-
return (
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
}
|
75
|
-
|
76
|
-
)
|
77
|
-
|
52
|
+
return variant == 'tree' ? /*#__PURE__*/React__default["default"].createElement("span", {
|
53
|
+
className: "".concat(className, " ").concat(DataConfigs.blockClass, "__connector-disabled")
|
54
|
+
}, operator) :
|
55
|
+
/*#__PURE__*/
|
56
|
+
// <div className={className} {...rest}>
|
57
|
+
React__default["default"].createElement(ConditionBuilderItem.ConditionBuilderItem, _rollupPluginBabelHelpers["extends"]({
|
58
|
+
label: operator,
|
59
|
+
title: DataConfigs.translateWithId('connector'),
|
60
|
+
"data-name": "connectorField",
|
61
|
+
onMouseEnter: activeConnectorHandler,
|
62
|
+
onMouseLeave: inActiveConnectorHandler,
|
63
|
+
onFocus: activeConnectorHandler,
|
64
|
+
onBlur: inActiveConnectorHandler
|
65
|
+
}, rest, {
|
66
|
+
popOverClassName: className,
|
67
|
+
className: "".concat(DataConfigs.blockClass, "__connector-button ")
|
68
|
+
}), /*#__PURE__*/React__default["default"].createElement(ConditionBuilderItemOption.ConditionBuilderItemOption, {
|
69
|
+
config: {
|
70
|
+
options: DataConfigs.connectorConfig
|
71
|
+
},
|
72
|
+
conditionState: {
|
73
|
+
value: operator,
|
74
|
+
label: DataConfigs.translateWithId('connector')
|
75
|
+
},
|
76
|
+
onChange: onChangeHandler
|
77
|
+
}))
|
78
|
+
|
79
|
+
// </div>
|
80
|
+
;
|
81
|
+
};
|
82
|
+
var ConditionConnector$1 = ConditionConnector;
|
78
83
|
ConditionConnector.propTypes = {
|
79
84
|
/**
|
80
85
|
* Provide an optional class to be applied to the containing node.
|
@@ -90,4 +95,4 @@ ConditionConnector.propTypes = {
|
|
90
95
|
operator: index["default"].string
|
91
96
|
};
|
92
97
|
|
93
|
-
exports["default"] = ConditionConnector;
|
98
|
+
exports["default"] = ConditionConnector$1;
|
@@ -0,0 +1,52 @@
|
|
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
|
+
'use strict';
|
9
|
+
|
10
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
11
|
+
|
12
|
+
var React = require('react');
|
13
|
+
var ConditionBuilderItem = require('../ConditionBuilderItem/ConditionBuilderItem.js');
|
14
|
+
var DataConfigs = require('../ConditionBuilderContext/DataConfigs.js');
|
15
|
+
var ConditionBuilderItemOption = require('../ConditionBuilderItem/ConditionBuilderItemOption/ConditionBuilderItemOption.js');
|
16
|
+
var util = require('../utils/util.js');
|
17
|
+
var ConditionBuilderProvider = require('../ConditionBuilderContext/ConditionBuilderProvider.js');
|
18
|
+
|
19
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
20
|
+
|
21
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
22
|
+
|
23
|
+
var GroupConnector = function GroupConnector() {
|
24
|
+
var _useContext = React.useContext(ConditionBuilderProvider.ConditionBuilderContext),
|
25
|
+
rootState = _useContext.rootState;
|
26
|
+
return /*#__PURE__*/React__default["default"].createElement("div", {
|
27
|
+
className: "".concat(DataConfigs.blockClass, "__group-separator"),
|
28
|
+
role: "row",
|
29
|
+
tabIndex: -1,
|
30
|
+
"aria-level": 1
|
31
|
+
}, /*#__PURE__*/React__default["default"].createElement(ConditionBuilderItem.ConditionBuilderItem, {
|
32
|
+
label: rootState.operator,
|
33
|
+
title: DataConfigs.translateWithId('condition'),
|
34
|
+
"data-name": "connectorField",
|
35
|
+
popOverClassName: "".concat(DataConfigs.blockClass, "__gap"),
|
36
|
+
className: "".concat(DataConfigs.blockClass, "__statement-button")
|
37
|
+
}, /*#__PURE__*/React__default["default"].createElement(ConditionBuilderItemOption.ConditionBuilderItemOption, {
|
38
|
+
conditionState: {
|
39
|
+
value: rootState.operator,
|
40
|
+
label: DataConfigs.translateWithId('condition')
|
41
|
+
},
|
42
|
+
onChange: function onChange(v, e) {
|
43
|
+
util.focusThisField(e);
|
44
|
+
},
|
45
|
+
config: {
|
46
|
+
options: DataConfigs.connectorConfig
|
47
|
+
}
|
48
|
+
})));
|
49
|
+
};
|
50
|
+
var GroupConnector$1 = GroupConnector;
|
51
|
+
|
52
|
+
exports["default"] = GroupConnector$1;
|
package/lib/components/ConditionBuilder/ConditionBuilderContent/ConditionBuilderContent.d.ts
CHANGED
@@ -7,7 +7,12 @@ declare function ConditionBuilderContent({ startConditionLabel, conditionBuilder
|
|
7
7
|
}): import("react/jsx-runtime").JSX.Element;
|
8
8
|
declare namespace ConditionBuilderContent {
|
9
9
|
namespace propTypes {
|
10
|
+
let actions: PropTypes.Requireable<(PropTypes.InferProps<{
|
11
|
+
id: PropTypes.Requireable<number>;
|
12
|
+
label: PropTypes.Requireable<string>;
|
13
|
+
}> | null | undefined)[]>;
|
10
14
|
let conditionBuilderRef: PropTypes.Requireable<object>;
|
15
|
+
let getActionsState: PropTypes.Requireable<(...args: any[]) => any>;
|
11
16
|
let getConditionState: PropTypes.Validator<(...args: any[]) => any>;
|
12
17
|
let initialState: PropTypes.Requireable<PropTypes.InferProps<{
|
13
18
|
groups: PropTypes.Requireable<(PropTypes.InferProps<{
|