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

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) 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/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditCell/InlineEditCell.js +1 -1
  34. package/es/components/SidePanel/SidePanel.d.ts +2 -2
  35. package/es/components/SidePanel/SidePanel.js +5 -3
  36. package/lib/components/ConditionBuilder/ConditionBlock/ConditionBlock.d.ts +6 -0
  37. package/lib/components/ConditionBuilder/ConditionBlock/ConditionBlock.js +73 -32
  38. package/lib/components/ConditionBuilder/ConditionBuilderAdd/ConditionBuilderAdd.d.ts +15 -1
  39. package/lib/components/ConditionBuilder/ConditionBuilderAdd/ConditionBuilderAdd.js +92 -9
  40. package/lib/components/ConditionBuilder/ConditionBuilderButton/ConditionBuilderButton.d.ts +11 -2
  41. package/lib/components/ConditionBuilder/ConditionBuilderButton/ConditionBuilderButton.js +26 -8
  42. package/lib/components/ConditionBuilder/{ConditionConnector → ConditionBuilderConnector}/ConditionConnector.js +36 -31
  43. package/lib/components/ConditionBuilder/ConditionBuilderConnector/GroupConnector.d.ts +2 -0
  44. package/lib/components/ConditionBuilder/ConditionBuilderConnector/GroupConnector.js +52 -0
  45. package/lib/components/ConditionBuilder/ConditionBuilderContent/ConditionBuilderContent.d.ts +5 -0
  46. package/lib/components/ConditionBuilder/ConditionBuilderContent/ConditionBuilderContent.js +92 -11
  47. package/lib/components/ConditionBuilder/ConditionBuilderContext/ConditionBuilderProvider.d.ts +1 -0
  48. package/lib/components/ConditionBuilder/ConditionBuilderContext/ConditionBuilderProvider.js +1 -0
  49. package/lib/components/ConditionBuilder/ConditionBuilderContext/translationObject.d.ts +7 -0
  50. package/lib/components/ConditionBuilder/ConditionBuilderContext/translationObject.js +8 -1
  51. package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItem.js +1 -1
  52. package/lib/components/ConditionBuilder/ConditionGroupBuilder/ConditionGroupBuilder.js +195 -64
  53. package/lib/components/ConditionBuilder/ConditionPreview/ConditionPreview.d.ts +10 -0
  54. package/lib/components/ConditionBuilder/ConditionPreview/ConditionPreview.js +77 -0
  55. package/lib/components/ConditionBuilder/utils/util.d.ts +1 -0
  56. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditCell/InlineEditCell.js +1 -1
  57. package/lib/components/SidePanel/SidePanel.d.ts +2 -2
  58. package/lib/components/SidePanel/SidePanel.js +5 -3
  59. package/package.json +3 -3
  60. package/scss/components/ConditionBuilder/_condition-builder.scss +21 -1
  61. package/scss/components/ConditionBuilder/styles/_conditionBuilderCondition.scss +22 -3
  62. package/scss/components/ConditionBuilder/styles/_conditionBuilderItem.scss +58 -21
  63. /package/es/components/ConditionBuilder/{ConditionConnector → ConditionBuilderConnector}/ConditionConnector.d.ts +0 -0
  64. /package/lib/components/ConditionBuilder/{ConditionConnector → ConditionBuilderConnector}/ConditionConnector.d.ts +0 -0
@@ -445,7 +445,7 @@ var InlineEditCell = function InlineEditCell(_ref) {
445
445
  "data-inline-type": type,
446
446
  onClick: !nonEditCell ? handleInlineCellClick : addActiveState,
447
447
  onKeyDown: !nonEditCell ? handleKeyDown : null,
448
- className: cx("".concat(blockClass, "__inline-edit--outer-cell-button"), _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, "".concat(blockClass, "__inline-edit--outer-cell-button--").concat(rowSize), rowSize), "".concat(blockClass, "__inline-edit--outer-cell-button--lg"), !rowSize), "".concat(blockClass, "__inline-edit--outer-cell-button--invalid"), config === null || config === void 0 || (_config$validator = config.validator) === null || _config$validator === void 0 ? void 0 : _config$validator.call(config, cellValue)), "".concat(blockClass, "__static--outer-cell"), !disabledCell))
448
+ className: cx("".concat(blockClass, "__inline-edit--outer-cell-button"), _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, "".concat(blockClass, "__inline-edit--outer-cell-button--").concat(rowSize), rowSize), "".concat(blockClass, "__inline-edit--outer-cell-button--lg"), !rowSize), "".concat(blockClass, "__inline-edit--outer-cell-button--invalid"), inEditMode && (config === null || config === void 0 || (_config$validator = config.validator) === null || _config$validator === void 0 ? void 0 : _config$validator.call(config, cellValue))), "".concat(blockClass, "__static--outer-cell"), !disabledCell))
449
449
  }, !nonEditCell && !disabledCell && renderRegularCell(), (!inEditMode || disabledCell) && /*#__PURE__*/React__default.createElement(InlineEditButton, {
450
450
  isActiveCell: cellId === activeCellId,
451
451
  renderIcon: setRenderIcon(),
@@ -11,7 +11,7 @@ type SidePanelBaseProps = {
11
11
  /**
12
12
  * Sets the action toolbar buttons
13
13
  */
14
- actionToolbarButtons?: ButtonProps[];
14
+ actionToolbarButtons?: ButtonProps<any>[];
15
15
  /**
16
16
  * The primary actions to be shown in the side panel. Each action is
17
17
  * specified as an object that will render expressive Buttons. Any Button
@@ -20,7 +20,7 @@ type SidePanelBaseProps = {
20
20
  *
21
21
  * See https://react.carbondesignsystem.com/?path=/docs/components-button--default#component-api
22
22
  */
23
- actions?: ButtonProps[];
23
+ actions?: ButtonProps<any>[];
24
24
  /**
25
25
  * Determines if the title will animate on scroll
26
26
  */
@@ -323,12 +323,12 @@ var SidePanel = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
323
323
  if (primeFocusEl) {
324
324
  primeFocusEl === null || primeFocusEl === void 0 || primeFocusEl.focus();
325
325
  }
326
- } else {
326
+ } else if (!slideIn) {
327
327
  firstElement === null || firstElement === void 0 || firstElement.focus();
328
328
  }
329
329
  }, 0);
330
330
  }
331
- }, [animationComplete, firstElement, open, selectorPrimaryFocus]);
331
+ }, [animationComplete, firstElement, open, selectorPrimaryFocus, slideIn]);
332
332
  var primaryActionContainerClassNames = cx(["".concat(blockClass, "__actions-container"), _defineProperty({}, "".concat(blockClass, "__actions-container--condensed"), condensedActions)]);
333
333
  var mainPanelClassNames = cx([blockClass, className, "".concat(blockClass), "".concat(blockClass, "--").concat(size), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, "".concat(blockClass, "--right-placement"), placement === 'right'), "".concat(blockClass, "--left-placement"), placement === 'left'), "".concat(blockClass, "--slide-in"), slideIn), "".concat(blockClass, "--has-slug"), slug), "".concat(blockClass, "--condensed-actions"), condensedActions), "".concat(blockClass, "--has-overlay"), includeOverlay)]);
334
334
  var renderTitle = function renderTitle() {
@@ -448,7 +448,7 @@ var SidePanel = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
448
448
  placement: placement,
449
449
  shouldReduceMotion: shouldReduceMotion
450
450
  },
451
- onKeyDown: keyDownListener
451
+ onKeyDown: slideIn ? undefined : keyDownListener
452
452
  }), /*#__PURE__*/React__default.createElement(React__default.Fragment, null, renderHeader(), renderMain()), /*#__PURE__*/React__default.createElement(MotionActionSet, {
453
453
  actions: actions !== null && actions !== void 0 ? actions : [],
454
454
  className: primaryActionContainerClassNames,
@@ -471,6 +471,7 @@ SidePanel.propTypes = {
471
471
  /**
472
472
  * Sets the action toolbar buttons
473
473
  */
474
+ /**@ts-ignore */
474
475
  actionToolbarButtons: PropTypes.arrayOf(PropTypes.shape({
475
476
  label: PropTypes.string,
476
477
  leading: PropTypes.bool,
@@ -504,6 +505,7 @@ SidePanel.propTypes = {
504
505
  label: PropTypes.string,
505
506
  loading: PropTypes.bool,
506
507
  // we duplicate this Button prop to improve the DocGen here
508
+ /**@ts-ignore */
507
509
  onClick: Button.propTypes.onClick
508
510
  })))]),
509
511
  /**
@@ -6,17 +6,23 @@ declare function ConditionBlock(props: any): import("react/jsx-runtime").JSX.Ele
6
6
  declare namespace ConditionBlock {
7
7
  namespace propTypes {
8
8
  let addConditionHandler: PropTypes.Requireable<(...args: any[]) => any>;
9
+ let addConditionSubGroupHandler: PropTypes.Requireable<(...args: any[]) => any>;
9
10
  let aria: PropTypes.Requireable<object>;
10
11
  let condition: PropTypes.Requireable<object>;
11
12
  let conditionIndex: PropTypes.Requireable<number>;
12
13
  let conjunction: PropTypes.Requireable<string>;
13
14
  let group: PropTypes.Requireable<object>;
15
+ let hideConditionPreviewHandler: PropTypes.Requireable<(...args: any[]) => any>;
16
+ let hideConditionSubGroupPreviewHandler: PropTypes.Requireable<(...args: any[]) => any>;
14
17
  let isLastCondition: PropTypes.Requireable<(...args: any[]) => any>;
15
18
  let isStatement: PropTypes.Requireable<boolean>;
16
19
  let onChange: PropTypes.Requireable<(...args: any[]) => any>;
17
20
  let onConnectorOperatorChange: PropTypes.Requireable<(...args: any[]) => any>;
18
21
  let onRemove: PropTypes.Requireable<(...args: any[]) => any>;
19
22
  let onStatementChange: PropTypes.Requireable<(...args: any[]) => any>;
23
+ let showConditionPreviewHandler: PropTypes.Requireable<(...args: any[]) => any>;
24
+ let showConditionSubGroupPreviewHandler: PropTypes.Requireable<(...args: any[]) => any>;
25
+ let state: PropTypes.Requireable<object>;
20
26
  }
21
27
  }
22
28
  import PropTypes from 'prop-types';
@@ -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('../ConditionConnector/ConditionConnector.js');
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 = property ? itemComponents[type] : null;
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
- return /*#__PURE__*/React__default["default"].createElement("div", {
122
- className: cx__default["default"]("".concat(DataConfigs.blockClass, "__condition-block conditionBlockWrapper ").concat(DataConfigs.blockClass, "__gap ").concat(DataConfigs.blockClass, "__gap-bottom"), _rollupPluginBabelHelpers.defineProperty({}, "".concat(DataConfigs.blockClass, "__condition__deletion-preview"), showDeletionPreview)),
123
- key: conditionIndex,
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
- }, isStatement && /*#__PURE__*/React__default["default"].createElement(ConditionBuilderItem.ConditionBuilderItem
128
- // open={false}
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
- })), conjunction && /*#__PURE__*/React__default["default"].createElement(ConditionConnector["default"], {
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
- //addConditionSubGroupHandler={()=>{addConditionSubGroupHandler(conditionIndex)}}
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
- * object hold aria attributes
253
+ * callback to add a new condition subgroup
228
254
  */
229
- aria: index["default"].object,
255
+ addConditionSubGroupHandler: index["default"].func,
230
256
  /**
231
- * object that hold the current condition
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
- * callback to add a new condition
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: "gridcell"
28
- }, /*#__PURE__*/React__default["default"].createElement(ConditionBuilderButton.ConditionBuilderButton, {
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: onClick,
77
+ onClick: onClickHandler
78
+ }, previewHandlers(), {
31
79
  className: "".concat(DataConfigs.blockClass, "__add-button"),
32
80
  hideLabel: true,
33
- label: DataConfigs.translateWithId('add-condition')
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
- * callback triggered on click of add button
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, ...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';
@@ -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
- rest = _rollupPluginBabelHelpers.objectWithoutProperties(_ref, _excluded);
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", _rollupPluginBabelHelpers["extends"]({
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
- }, rest), Icon && (_Icon || (_Icon = /*#__PURE__*/React__default["default"].createElement(Icon, null))), !hideLabel && label);
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
- }, rest.wrapperProps), Button()) : /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, Button());
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;