@carbon/ibm-products 2.42.1-canary.7 → 2.42.1-canary.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. package/css/index-full-carbon.css +302 -9
  2. package/css/index-full-carbon.css.map +1 -1
  3. package/css/index-full-carbon.min.css +1 -1
  4. package/css/index-full-carbon.min.css.map +1 -1
  5. package/css/index-without-carbon.css +302 -9
  6. package/css/index-without-carbon.css.map +1 -1
  7. package/css/index-without-carbon.min.css +1 -1
  8. package/css/index-without-carbon.min.css.map +1 -1
  9. package/css/index.css +302 -9
  10. package/css/index.css.map +1 -1
  11. package/css/index.min.css +1 -1
  12. package/css/index.min.css.map +1 -1
  13. package/es/components/ConditionBuilder/ConditionBlock/ConditionBlock.d.ts +6 -0
  14. package/es/components/ConditionBuilder/ConditionBlock/ConditionBlock.js +74 -33
  15. package/es/components/ConditionBuilder/ConditionBuilderAdd/ConditionBuilderAdd.d.ts +15 -1
  16. package/es/components/ConditionBuilder/ConditionBuilderAdd/ConditionBuilderAdd.js +95 -12
  17. package/es/components/ConditionBuilder/ConditionBuilderButton/ConditionBuilderButton.d.ts +11 -2
  18. package/es/components/ConditionBuilder/ConditionBuilderButton/ConditionBuilderButton.js +27 -9
  19. package/es/components/ConditionBuilder/{ConditionConnector → ConditionBuilderConnector}/ConditionConnector.js +38 -33
  20. package/es/components/ConditionBuilder/ConditionBuilderConnector/GroupConnector.d.ts +2 -0
  21. package/es/components/ConditionBuilder/ConditionBuilderConnector/GroupConnector.js +44 -0
  22. package/es/components/ConditionBuilder/ConditionBuilderContent/ConditionBuilderContent.d.ts +5 -0
  23. package/es/components/ConditionBuilder/ConditionBuilderContent/ConditionBuilderContent.js +95 -14
  24. package/es/components/ConditionBuilder/ConditionBuilderContext/ConditionBuilderProvider.d.ts +1 -0
  25. package/es/components/ConditionBuilder/ConditionBuilderContext/ConditionBuilderProvider.js +1 -0
  26. package/es/components/ConditionBuilder/ConditionBuilderContext/translationObject.d.ts +7 -0
  27. package/es/components/ConditionBuilder/ConditionBuilderContext/translationObject.js +8 -1
  28. package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItem.js +1 -1
  29. package/es/components/ConditionBuilder/ConditionGroupBuilder/ConditionGroupBuilder.js +197 -67
  30. package/es/components/ConditionBuilder/ConditionPreview/ConditionPreview.d.ts +10 -0
  31. package/es/components/ConditionBuilder/ConditionPreview/ConditionPreview.js +69 -0
  32. package/es/components/ConditionBuilder/utils/util.d.ts +1 -0
  33. package/lib/components/ConditionBuilder/ConditionBlock/ConditionBlock.d.ts +6 -0
  34. package/lib/components/ConditionBuilder/ConditionBlock/ConditionBlock.js +73 -32
  35. package/lib/components/ConditionBuilder/ConditionBuilderAdd/ConditionBuilderAdd.d.ts +15 -1
  36. package/lib/components/ConditionBuilder/ConditionBuilderAdd/ConditionBuilderAdd.js +92 -9
  37. package/lib/components/ConditionBuilder/ConditionBuilderButton/ConditionBuilderButton.d.ts +11 -2
  38. package/lib/components/ConditionBuilder/ConditionBuilderButton/ConditionBuilderButton.js +26 -8
  39. package/lib/components/ConditionBuilder/{ConditionConnector → ConditionBuilderConnector}/ConditionConnector.js +36 -31
  40. package/lib/components/ConditionBuilder/ConditionBuilderConnector/GroupConnector.d.ts +2 -0
  41. package/lib/components/ConditionBuilder/ConditionBuilderConnector/GroupConnector.js +52 -0
  42. package/lib/components/ConditionBuilder/ConditionBuilderContent/ConditionBuilderContent.d.ts +5 -0
  43. package/lib/components/ConditionBuilder/ConditionBuilderContent/ConditionBuilderContent.js +92 -11
  44. package/lib/components/ConditionBuilder/ConditionBuilderContext/ConditionBuilderProvider.d.ts +1 -0
  45. package/lib/components/ConditionBuilder/ConditionBuilderContext/ConditionBuilderProvider.js +1 -0
  46. package/lib/components/ConditionBuilder/ConditionBuilderContext/translationObject.d.ts +7 -0
  47. package/lib/components/ConditionBuilder/ConditionBuilderContext/translationObject.js +8 -1
  48. package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItem.js +1 -1
  49. package/lib/components/ConditionBuilder/ConditionGroupBuilder/ConditionGroupBuilder.js +195 -64
  50. package/lib/components/ConditionBuilder/ConditionPreview/ConditionPreview.d.ts +10 -0
  51. package/lib/components/ConditionBuilder/ConditionPreview/ConditionPreview.js +77 -0
  52. package/lib/components/ConditionBuilder/utils/util.d.ts +1 -0
  53. package/package.json +3 -3
  54. package/scss/components/ConditionBuilder/_condition-builder.scss +21 -1
  55. package/scss/components/ConditionBuilder/styles/_conditionBuilderCondition.scss +22 -3
  56. package/scss/components/ConditionBuilder/styles/_conditionBuilderItem.scss +58 -21
  57. /package/es/components/ConditionBuilder/{ConditionConnector → ConditionBuilderConnector}/ConditionConnector.d.ts +0 -0
  58. /package/lib/components/ConditionBuilder/{ConditionConnector → ConditionBuilderConnector}/ConditionConnector.d.ts +0 -0
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- import { slicedToArray as _slicedToArray, defineProperty as _defineProperty, objectSpread2 as _objectSpread2 } from '../../../_virtual/_rollupPluginBabelHelpers.js';
8
+ import { slicedToArray as _slicedToArray, extends as _extends, defineProperty as _defineProperty, objectSpread2 as _objectSpread2 } from '../../../_virtual/_rollupPluginBabelHelpers.js';
9
9
  import React__default, { useContext, useState } from 'react';
10
10
  import { Close } from '@carbon/react/icons';
11
11
  import { ConditionBuilderItem } from '../ConditionBuilderItem/ConditionBuilderItem.js';
@@ -13,7 +13,7 @@ import PropTypes from '../../../node_modules/prop-types/index.js';
13
13
  import { blockClass, translateWithId, statementConfig, operatorConfig } from '../ConditionBuilderContext/DataConfigs.js';
14
14
  import { ConditionBuilderItemOption } from '../ConditionBuilderItem/ConditionBuilderItemOption/ConditionBuilderItemOption.js';
15
15
  import cx from 'classnames';
16
- import ConditionConnector from '../ConditionConnector/ConditionConnector.js';
16
+ import ConditionConnector from '../ConditionBuilderConnector/ConditionConnector.js';
17
17
  import { ConditionBuilderItemNumber } from '../ConditionBuilderItem/ConditionBuilderItemNumber/ConditionBuilderItemNumber.js';
18
18
  import { ConditionBuilderItemText } from '../ConditionBuilderItem/ConditionBuilderItemText/ConditionBuilderItemText.js';
19
19
  import { ConditionBuilderItemDate } from '../ConditionBuilderItem/ConditionBuilderItemDate/ConditionBuilderItemDate.js';
@@ -23,6 +23,7 @@ import { focusThisField } from '../utils/util.js';
23
23
  import { ConditionBuilderItemTime } from '../ConditionBuilderItem/ConditionBuilderItemTime/ConditionBuilderItemTime.js';
24
24
  import ConditionBuilderAdd from '../ConditionBuilderAdd/ConditionBuilderAdd.js';
25
25
 
26
+ var _div;
26
27
  /**
27
28
  * This component build each block of condition consisting of property, operator value and close button.
28
29
  */
@@ -40,11 +41,19 @@ var ConditionBlock = function ConditionBlock(props) {
40
41
  isStatement = props.isStatement,
41
42
  group = props.group,
42
43
  onStatementChange = props.onStatementChange,
43
- addConditionHandler = props.addConditionHandler,
44
44
  conditionIndex = props.conditionIndex,
45
+ addConditionHandler = props.addConditionHandler,
46
+ _addConditionSubGroupHandler = props.addConditionSubGroupHandler,
47
+ aria = props.aria,
48
+ hideConditionSubGroupPreviewHandler = props.hideConditionSubGroupPreviewHandler,
49
+ showConditionSubGroupPreviewHandler = props.showConditionSubGroupPreviewHandler,
50
+ hideConditionPreviewHandler = props.hideConditionPreviewHandler,
51
+ showConditionPreviewHandler = props.showConditionPreviewHandler,
45
52
  isLastCondition = props.isLastCondition;
46
53
  var _useContext = useContext(ConditionBuilderContext),
47
- inputConfig = _useContext.inputConfig;
54
+ inputConfig = _useContext.inputConfig,
55
+ variant = _useContext.variant;
56
+ //Below possible input types expected for value field.
48
57
  var itemComponents = {
49
58
  option: ConditionBuilderItemOption,
50
59
  text: ConditionBuilderItemText,
@@ -69,14 +78,17 @@ var ConditionBlock = function ConditionBlock(props) {
69
78
  type = _getCurrentConfig.type,
70
79
  config = _getCurrentConfig.config,
71
80
  label = _getCurrentConfig.label;
72
- var ItemComponent = property ? itemComponents[type] : null;
81
+ var ItemComponent;
82
+ // if (type == 'custom') {
83
+ // ItemComponent = config.component;
84
+ // } else {
85
+ ItemComponent = property ? itemComponents[type] : null;
86
+ //}
87
+
73
88
  var onStatementChangeHandler = function onStatementChangeHandler(v, evt) {
74
89
  focusThisField(evt);
75
90
  onStatementChange(v);
76
91
  };
77
- var onConnectorOperatorChangeHandler = function onConnectorOperatorChangeHandler(op) {
78
- onConnectorOperatorChange(op);
79
- };
80
92
  var onPropertyChangeHandler = function onPropertyChangeHandler(newProperty) {
81
93
  onChange(_objectSpread2(_objectSpread2({}, condition), {}, {
82
94
  property: newProperty,
@@ -109,21 +121,32 @@ var ConditionBlock = function ConditionBlock(props) {
109
121
  return operator.type.indexOf(type) != -1 || operator.type == 'all';
110
122
  });
111
123
  };
112
- return /*#__PURE__*/React__default.createElement("div", {
113
- className: cx("".concat(blockClass, "__condition-block conditionBlockWrapper ").concat(blockClass, "__gap ").concat(blockClass, "__gap-bottom"), _defineProperty({}, "".concat(blockClass, "__condition__deletion-preview"), showDeletionPreview)),
114
- key: conditionIndex,
124
+ var getAriaAttributes = function getAriaAttributes() {
125
+ return variant == 'tree' ? {
126
+ 'aria-level': aria.level,
127
+ 'aria-posinset': aria.posinset,
128
+ 'aria-setsize': aria.setsize
129
+ } : {};
130
+ };
131
+ return /*#__PURE__*/React__default.createElement("div", _extends({
132
+ className: cx("".concat(blockClass, "__condition-block"), _defineProperty({}, "".concat(blockClass, "__condition__deletion-preview"), showDeletionPreview), _defineProperty({}, "".concat(blockClass, "__gap-bottom"), variant == 'tree' && !(conditionIndex + 1 >= group.conditions.length)), _defineProperty({}, "".concat(blockClass, "__gap ").concat(blockClass, "__gap-bottom"), variant == 'sentence')),
115
133
  role: "row",
116
134
  "aria-label": translateWithId('condition_row'),
117
135
  tabIndex: -1
118
- }, isStatement && /*#__PURE__*/React__default.createElement(ConditionBuilderItem
119
- // open={false}
120
- , {
136
+ }, getAriaAttributes()), conjunction ? /*#__PURE__*/React__default.createElement(ConditionConnector, {
137
+ className: "".concat(blockClass, "__gap"),
138
+ operator: conjunction,
139
+ onChange: function onChange(op) {
140
+ return onConnectorOperatorChange(op);
141
+ }
142
+ }) : _div || (_div = /*#__PURE__*/React__default.createElement("div", {
143
+ role: "gridcell"
144
+ })), isStatement && /*#__PURE__*/React__default.createElement(ConditionBuilderItem, {
121
145
  label: group.statement,
122
146
  title: translateWithId('condition'),
123
147
  "data-name": "connectorField",
124
148
  popOverClassName: "".concat(blockClass, "__gap"),
125
- className: "".concat(blockClass, "__statement-button"),
126
- tabIndex: 0
149
+ className: "".concat(blockClass, "__statement-button")
127
150
  }, /*#__PURE__*/React__default.createElement(ConditionBuilderItemOption, {
128
151
  conditionState: {
129
152
  value: group.statement,
@@ -133,11 +156,7 @@ var ConditionBlock = function ConditionBlock(props) {
133
156
  config: {
134
157
  options: statementConfig
135
158
  }
136
- })), conjunction && /*#__PURE__*/React__default.createElement(ConditionConnector, {
137
- className: "".concat(blockClass, "__gap"),
138
- operator: conjunction,
139
- onChange: onConnectorOperatorChangeHandler
140
- }), /*#__PURE__*/React__default.createElement(ConditionBuilderItem, {
159
+ })), /*#__PURE__*/React__default.createElement(ConditionBuilderItem, {
141
160
  label: label,
142
161
  title: translateWithId('property'),
143
162
  renderIcon: icon !== null && icon !== void 0 ? icon : null,
@@ -184,7 +203,8 @@ var ConditionBlock = function ConditionBlock(props) {
184
203
  value: value
185
204
  },
186
205
  onChange: onValueChangeHandler,
187
- config: config
206
+ config: config,
207
+ "data-name": "valueField"
188
208
  })), /*#__PURE__*/React__default.createElement("span", {
189
209
  role: "gridcell",
190
210
  "aria-label": translateWithId('remove_condition')
@@ -202,9 +222,15 @@ var ConditionBlock = function ConditionBlock(props) {
202
222
  })), isLastCondition(conditionIndex, group.conditions) && /*#__PURE__*/React__default.createElement(ConditionBuilderAdd, {
203
223
  onClick: function onClick() {
204
224
  addConditionHandler(conditionIndex);
205
- }
206
- //addConditionSubGroupHandler={()=>{addConditionSubGroupHandler(conditionIndex)}}
207
- ,
225
+ },
226
+ addConditionSubGroupHandler: function addConditionSubGroupHandler() {
227
+ _addConditionSubGroupHandler(conditionIndex);
228
+ },
229
+ showConditionSubGroupPreviewHandler: showConditionSubGroupPreviewHandler,
230
+ hideConditionSubGroupPreviewHandler: hideConditionSubGroupPreviewHandler,
231
+ enableSubGroup: variant == 'tree',
232
+ showConditionPreviewHandler: showConditionPreviewHandler,
233
+ hideConditionPreviewHandler: hideConditionPreviewHandler,
208
234
  className: "".concat(blockClass, "__gap ").concat(blockClass, "__gap-left")
209
235
  }));
210
236
  };
@@ -215,16 +241,14 @@ ConditionBlock.propTypes = {
215
241
  */
216
242
  addConditionHandler: PropTypes.func,
217
243
  /**
218
- * object hold aria attributes
244
+ * callback to add a new condition subgroup
219
245
  */
220
- aria: PropTypes.object,
246
+ addConditionSubGroupHandler: PropTypes.func,
221
247
  /**
222
- * object that hold the current condition
248
+ * object hold aria attributes
223
249
  */
250
+ aria: PropTypes.object,
224
251
  condition: PropTypes.object,
225
- /**
226
- * index of the current condition
227
- */
228
252
  conditionIndex: PropTypes.number,
229
253
  /**
230
254
  * string that decides to show the condition connector
@@ -235,8 +259,13 @@ ConditionBlock.propTypes = {
235
259
  */
236
260
  group: PropTypes.object,
237
261
  /**
238
- * callback to add a new condition
262
+ * handler for hiding sub group preview
263
+ */
264
+ hideConditionPreviewHandler: PropTypes.func,
265
+ /**
266
+ * handler for hiding sub group preview
239
267
  */
268
+ hideConditionSubGroupPreviewHandler: PropTypes.func,
240
269
  isLastCondition: PropTypes.func,
241
270
  /**
242
271
  * boolean that decides to show the statement(if/ excl.if)
@@ -257,7 +286,19 @@ ConditionBlock.propTypes = {
257
286
  /**
258
287
  * callback to handle the statement(if/ excl.if) change
259
288
  */
260
- onStatementChange: PropTypes.func
289
+ onStatementChange: PropTypes.func,
290
+ /**
291
+ * handler for showing add condition preview
292
+ */
293
+ showConditionPreviewHandler: PropTypes.func,
294
+ /**
295
+ * handler for showing sub group preview
296
+ */
297
+ showConditionSubGroupPreviewHandler: PropTypes.func,
298
+ /**
299
+ * object that hold the current condition
300
+ */
301
+ state: PropTypes.object
261
302
  };
262
303
 
263
304
  export { ConditionBlock$1 as default };
@@ -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';
@@ -5,36 +5,119 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- import React__default from 'react';
9
- import { AddAlt } from '@carbon/react/icons';
8
+ import { slicedToArray as _slicedToArray, extends as _extends } from '../../../_virtual/_rollupPluginBabelHelpers.js';
9
+ import React__default, { useState } from 'react';
10
+ import { AddAlt, TextNewLine } from '@carbon/react/icons';
10
11
  import { ConditionBuilderButton } from '../ConditionBuilderButton/ConditionBuilderButton.js';
11
12
  import PropTypes from '../../../node_modules/prop-types/index.js';
12
- import { blockClass, translateWithId } from '../ConditionBuilderContext/DataConfigs.js';
13
+ import { translateWithId, blockClass } from '../ConditionBuilderContext/DataConfigs.js';
13
14
 
14
15
  var ConditionBuilderAdd = function ConditionBuilderAdd(_ref) {
15
16
  var className = _ref.className,
16
- onClick = _ref.onClick;
17
+ onClick = _ref.onClick,
18
+ addConditionSubGroupHandler = _ref.addConditionSubGroupHandler,
19
+ showConditionSubGroupPreviewHandler = _ref.showConditionSubGroupPreviewHandler,
20
+ hideConditionSubGroupPreviewHandler = _ref.hideConditionSubGroupPreviewHandler,
21
+ showConditionPreviewHandler = _ref.showConditionPreviewHandler,
22
+ hideConditionPreviewHandler = _ref.hideConditionPreviewHandler,
23
+ enableSubGroup = _ref.enableSubGroup,
24
+ buttonLabel = _ref.buttonLabel;
25
+ var _useState = useState(false),
26
+ _useState2 = _slicedToArray(_useState, 2),
27
+ isAddSubgroup = _useState2[0],
28
+ setIsAddSubgroup = _useState2[1];
29
+ var showAddSubGroup = function showAddSubGroup() {
30
+ setIsAddSubgroup(true);
31
+ };
32
+ var hideAddSubGroup = function hideAddSubGroup() {
33
+ setIsAddSubgroup(false);
34
+ };
35
+ var onClickHandler = function onClickHandler() {
36
+ hideConditionPreviewHandler === null || hideConditionPreviewHandler === void 0 || hideConditionPreviewHandler();
37
+ onClick();
38
+ };
39
+ var previewHandlers = function previewHandlers() {
40
+ return enableSubGroup ? {
41
+ onMouseEnter: showConditionPreviewHandler,
42
+ onMouseLeave: hideConditionPreviewHandler,
43
+ onFocus: showConditionPreviewHandler,
44
+ onBlur: hideConditionPreviewHandler
45
+ } : {};
46
+ };
47
+ var previewHandlersForSubgroup = function previewHandlersForSubgroup() {
48
+ return {
49
+ onMouseEnter: showConditionSubGroupPreviewHandler,
50
+ onMouseLeave: hideConditionSubGroupPreviewHandler,
51
+ onFocus: showConditionSubGroupPreviewHandler,
52
+ onBlur: hideConditionSubGroupPreviewHandler
53
+ };
54
+ };
55
+ var wrapperProps = enableSubGroup ? {
56
+ role: 'gridcell',
57
+ 'aria-label': translateWithId('add-condition')
58
+ } : {};
17
59
  return /*#__PURE__*/React__default.createElement("div", {
18
- className: className,
19
- role: "gridcell"
20
- }, /*#__PURE__*/React__default.createElement(ConditionBuilderButton, {
60
+ className: "".concat(className, " ").concat(blockClass, "__add-button-wrapper"),
61
+ role: !enableSubGroup ? 'gridcell' : 'none',
62
+ "aria-label": !enableSubGroup ? translateWithId('add_condition_row') : undefined,
63
+ onMouseEnter: showAddSubGroup,
64
+ onMouseLeave: hideAddSubGroup,
65
+ onFocus: showAddSubGroup,
66
+ onBlur: hideAddSubGroup
67
+ }, /*#__PURE__*/React__default.createElement(ConditionBuilderButton, _extends({
21
68
  renderIcon: AddAlt,
22
- onClick: onClick,
69
+ onClick: onClickHandler
70
+ }, previewHandlers(), {
23
71
  className: "".concat(blockClass, "__add-button"),
24
72
  hideLabel: true,
25
- label: translateWithId('add-condition')
26
- }));
73
+ "data-name": "addButton",
74
+ label: buttonLabel !== null && buttonLabel !== void 0 ? buttonLabel : translateWithId('add-condition'),
75
+ wrapperProps: wrapperProps
76
+ })), isAddSubgroup && enableSubGroup && /*#__PURE__*/React__default.createElement(ConditionBuilderButton, _extends({
77
+ renderIcon: TextNewLine,
78
+ onClick: addConditionSubGroupHandler,
79
+ className: "".concat(blockClass, "__add-condition-group ").concat(blockClass, "__gap-left"),
80
+ hideLabel: true,
81
+ label: translateWithId('add-condition'),
82
+ wrapperProps: wrapperProps
83
+ }, previewHandlersForSubgroup())));
27
84
  };
28
85
  var ConditionBuilderAdd$1 = ConditionBuilderAdd;
29
86
  ConditionBuilderAdd.propTypes = {
87
+ /**
88
+ * handler for hiding sub group preview
89
+ */
90
+ addConditionSubGroupHandler: PropTypes.func,
91
+ /**
92
+ * handler for hiding sub group preview
93
+ */ /**
94
+ * tooltip label for plus button
95
+ */
96
+ buttonLabel: PropTypes.string,
30
97
  /**
31
98
  * Provide an optional class to be applied to the containing node.
32
99
  */
33
100
  className: PropTypes.string,
34
101
  /**
35
- * callback triggered on click of add button
102
+ * boolean to enable sub groups for the tree variant
103
+ */
104
+ enableSubGroup: PropTypes.bool,
105
+ /**
106
+ * handler for hiding sub group preview
107
+ */
108
+ hideConditionPreviewHandler: PropTypes.func,
109
+ hideConditionSubGroupPreviewHandler: PropTypes.func,
110
+ /**
111
+ * handler for hiding sub group preview
112
+ */ /**
113
+ * callback triggered on click of add button
114
+ */
115
+ onClick: PropTypes.func,
116
+ showConditionPreviewHandler: PropTypes.func,
117
+ showConditionSubGroupPreviewHandler: PropTypes.func
118
+ /**
119
+ * handler for hiding sub group preview
36
120
  */
37
- onClick: PropTypes.func
38
121
  };
39
122
 
40
123
  export { ConditionBuilderAdd$1 as default };
@@ -1,5 +1,4 @@
1
- export function ConditionBuilderButton({ className, label, hideLabel, tooltipAlign, renderIcon: Icon, onClick, showToolTip, ...rest }: {
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';
@@ -5,16 +5,15 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- import { objectWithoutProperties as _objectWithoutProperties, extends as _extends, defineProperty as _defineProperty } from '../../../_virtual/_rollupPluginBabelHelpers.js';
8
+ import { extends as _extends, defineProperty as _defineProperty } from '../../../_virtual/_rollupPluginBabelHelpers.js';
9
9
  import React__default from 'react';
10
10
  import cx from 'classnames';
11
11
  import PropTypes from '../../../node_modules/prop-types/index.js';
12
12
  import { Tooltip } from '@carbon/react';
13
13
  import { blockClass } from '../ConditionBuilderContext/DataConfigs.js';
14
14
 
15
- var _excluded = ["className", "label", "hideLabel", "tooltipAlign", "renderIcon", "onClick", "showToolTip"];
16
15
  var ConditionBuilderButton = function ConditionBuilderButton(_ref) {
17
- var _Icon;
16
+ var _Icon, _span;
18
17
  var className = _ref.className,
19
18
  label = _ref.label,
20
19
  hideLabel = _ref.hideLabel,
@@ -22,21 +21,29 @@ var ConditionBuilderButton = function ConditionBuilderButton(_ref) {
22
21
  Icon = _ref.renderIcon,
23
22
  onClick = _ref.onClick,
24
23
  showToolTip = _ref.showToolTip,
25
- rest = _objectWithoutProperties(_ref, _excluded);
24
+ wrapperProps = _ref.wrapperProps,
25
+ onBlur = _ref.onBlur,
26
+ onFocus = _ref.onFocus,
27
+ onMouseEnter = _ref.onMouseEnter,
28
+ onMouseLeave = _ref.onMouseLeave;
26
29
  var Button = function Button() {
27
- return /*#__PURE__*/React__default.createElement("button", _extends({
30
+ return /*#__PURE__*/React__default.createElement("button", {
28
31
  // role={'gridcell'}
29
32
  tabIndex: -1,
30
33
  className: cx([className, "".concat(blockClass, "__button"), _defineProperty({}, "".concat(blockClass, "__text-ellipsis"), showToolTip && !hideLabel)]),
31
34
  type: "button",
32
- onClick: onClick
33
- }, rest), Icon && (_Icon || (_Icon = /*#__PURE__*/React__default.createElement(Icon, null))), !hideLabel && label);
35
+ onClick: onClick,
36
+ onBlur: onBlur,
37
+ onFocus: onFocus,
38
+ onMouseEnter: onMouseEnter,
39
+ onMouseLeave: onMouseLeave
40
+ }, Icon && (_Icon || (_Icon = /*#__PURE__*/React__default.createElement(Icon, null))), !hideLabel && (_span || (_span = /*#__PURE__*/React__default.createElement("span", null, label))));
34
41
  };
35
42
  return hideLabel || showToolTip ? /*#__PURE__*/React__default.createElement(Tooltip, _extends({
36
43
  label: label,
37
44
  align: tooltipAlign,
38
45
  className: "".concat(blockClass, "__con-tooltip")
39
- }, rest.wrapperProps), Button()) : /*#__PURE__*/React__default.createElement(React__default.Fragment, null, Button());
46
+ }, wrapperProps), Button()) : /*#__PURE__*/React__default.createElement(React__default.Fragment, null, Button());
40
47
  };
41
48
  ConditionBuilderButton.propTypes = {
42
49
  /**
@@ -51,10 +58,17 @@ ConditionBuilderButton.propTypes = {
51
58
  * label of the button
52
59
  */
53
60
  label: PropTypes.string,
61
+ /**
62
+ * mouse events callbacks
63
+ */
64
+ onBlur: PropTypes.func,
54
65
  /**
55
66
  * callback triggered on click of add button
56
67
  */
57
68
  onClick: PropTypes.func,
69
+ onFocus: PropTypes.func,
70
+ onMouseEnter: PropTypes.func,
71
+ onMouseLeave: PropTypes.func,
58
72
  /**
59
73
  * Optional prop to allow overriding the icon rendering.
60
74
  */
@@ -68,7 +82,11 @@ ConditionBuilderButton.propTypes = {
68
82
  /**
69
83
  * tooltip position
70
84
  */
71
- tooltipAlign: PropTypes.string
85
+ tooltipAlign: PropTypes.string,
86
+ /**
87
+ * optional props for tree grid to add role and aria-label to wrapper span
88
+ */
89
+ wrapperProps: PropTypes.object
72
90
  };
73
91
 
74
92
  export { ConditionBuilderButton };
@@ -6,21 +6,22 @@
6
6
  */
7
7
 
8
8
  import { objectWithoutProperties as _objectWithoutProperties, extends as _extends } from '../../../_virtual/_rollupPluginBabelHelpers.js';
9
- import React__default, { useCallback } from 'react';
9
+ import React__default, { useContext, useCallback } from 'react';
10
10
  import { ConditionBuilderItem } from '../ConditionBuilderItem/ConditionBuilderItem.js';
11
11
  import { ConditionBuilderItemOption } from '../ConditionBuilderItem/ConditionBuilderItemOption/ConditionBuilderItemOption.js';
12
- import { translateWithId, connectorConfig } from '../ConditionBuilderContext/DataConfigs.js';
13
- import { pkg } from '../../../settings.js';
12
+ import { blockClass, translateWithId, connectorConfig } from '../ConditionBuilderContext/DataConfigs.js';
14
13
  import PropTypes from '../../../node_modules/prop-types/index.js';
15
14
  import { focusThisField } from '../utils/util.js';
15
+ import { ConditionBuilderContext } from '../ConditionBuilderContext/ConditionBuilderProvider.js';
16
16
 
17
17
  var _excluded = ["operator", "className", "onChange"];
18
- var blockClass = "".concat(pkg.prefix, "--condition-builder");
19
- function ConditionConnector(_ref) {
18
+ var ConditionConnector = function ConditionConnector(_ref) {
20
19
  var operator = _ref.operator,
21
20
  className = _ref.className,
22
21
  onChange = _ref.onChange,
23
22
  rest = _objectWithoutProperties(_ref, _excluded);
23
+ var _useContext = useContext(ConditionBuilderContext),
24
+ variant = _useContext.variant;
24
25
  var handleConnectorHover = useCallback(function (parentGroup, isHover) {
25
26
  if (isHover) {
26
27
  parentGroup.classList.add('hoveredConnector');
@@ -40,33 +41,37 @@ function ConditionConnector(_ref) {
40
41
  onChange(op);
41
42
  focusThisField(evt);
42
43
  };
43
- return (
44
- /*#__PURE__*/
45
- // <div className={className} {...rest}>
46
- React__default.createElement(ConditionBuilderItem, _extends({
47
- label: operator,
48
- title: translateWithId('connector'),
49
- "data-name": "connectorField",
50
- onMouseEnter: activeConnectorHandler,
51
- onMouseLeave: inActiveConnectorHandler,
52
- onFocus: activeConnectorHandler,
53
- onBlur: inActiveConnectorHandler
54
- }, rest, {
55
- popOverClassName: className,
56
- className: "".concat(blockClass, "__connector-button ")
57
- }), /*#__PURE__*/React__default.createElement(ConditionBuilderItemOption, {
58
- config: {
59
- options: connectorConfig
60
- },
61
- conditionState: {
62
- value: operator,
63
- label: translateWithId('connector')
64
- },
65
- onChange: onChangeHandler
66
- }))
67
- // </div>
68
- );
69
- }
44
+ return variant == 'tree' ? /*#__PURE__*/React__default.createElement("span", {
45
+ className: "".concat(className, " ").concat(blockClass, "__connector-disabled")
46
+ }, operator) :
47
+ /*#__PURE__*/
48
+ // <div className={className} {...rest}>
49
+ React__default.createElement(ConditionBuilderItem, _extends({
50
+ label: operator,
51
+ title: translateWithId('connector'),
52
+ "data-name": "connectorField",
53
+ onMouseEnter: activeConnectorHandler,
54
+ onMouseLeave: inActiveConnectorHandler,
55
+ onFocus: activeConnectorHandler,
56
+ onBlur: inActiveConnectorHandler
57
+ }, rest, {
58
+ popOverClassName: className,
59
+ className: "".concat(blockClass, "__connector-button ")
60
+ }), /*#__PURE__*/React__default.createElement(ConditionBuilderItemOption, {
61
+ config: {
62
+ options: connectorConfig
63
+ },
64
+ conditionState: {
65
+ value: operator,
66
+ label: translateWithId('connector')
67
+ },
68
+ onChange: onChangeHandler
69
+ }))
70
+
71
+ // </div>
72
+ ;
73
+ };
74
+ var ConditionConnector$1 = ConditionConnector;
70
75
  ConditionConnector.propTypes = {
71
76
  /**
72
77
  * Provide an optional class to be applied to the containing node.
@@ -82,4 +87,4 @@ ConditionConnector.propTypes = {
82
87
  operator: PropTypes.string
83
88
  };
84
89
 
85
- export { ConditionConnector as default };
90
+ export { ConditionConnector$1 as default };
@@ -0,0 +1,2 @@
1
+ export default GroupConnector;
2
+ declare function GroupConnector(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,44 @@
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, { useContext } from 'react';
9
+ import { ConditionBuilderItem } from '../ConditionBuilderItem/ConditionBuilderItem.js';
10
+ import { blockClass, translateWithId, connectorConfig } from '../ConditionBuilderContext/DataConfigs.js';
11
+ import { ConditionBuilderItemOption } from '../ConditionBuilderItem/ConditionBuilderItemOption/ConditionBuilderItemOption.js';
12
+ import { focusThisField } from '../utils/util.js';
13
+ import { ConditionBuilderContext } from '../ConditionBuilderContext/ConditionBuilderProvider.js';
14
+
15
+ var GroupConnector = function GroupConnector() {
16
+ var _useContext = useContext(ConditionBuilderContext),
17
+ rootState = _useContext.rootState;
18
+ return /*#__PURE__*/React__default.createElement("div", {
19
+ className: "".concat(blockClass, "__group-separator"),
20
+ role: "row",
21
+ tabIndex: -1,
22
+ "aria-level": 1
23
+ }, /*#__PURE__*/React__default.createElement(ConditionBuilderItem, {
24
+ label: rootState.operator,
25
+ title: translateWithId('condition'),
26
+ "data-name": "connectorField",
27
+ popOverClassName: "".concat(blockClass, "__gap"),
28
+ className: "".concat(blockClass, "__statement-button")
29
+ }, /*#__PURE__*/React__default.createElement(ConditionBuilderItemOption, {
30
+ conditionState: {
31
+ value: rootState.operator,
32
+ label: translateWithId('condition')
33
+ },
34
+ onChange: function onChange(v, e) {
35
+ focusThisField(e);
36
+ },
37
+ config: {
38
+ options: connectorConfig
39
+ }
40
+ })));
41
+ };
42
+ var GroupConnector$1 = GroupConnector;
43
+
44
+ export { GroupConnector$1 as default };
@@ -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<{