@carbon/ibm-products 2.43.2-canary.103 → 2.43.2-canary.105

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. package/css/index-full-carbon.css +1147 -95
  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 +1147 -95
  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 +1147 -95
  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/ActionBar/ActionBar.d.ts +58 -2
  14. package/es/components/ActionBar/ActionBar.js +14 -9
  15. package/es/components/ActionBar/ActionBarItem.d.ts +36 -2
  16. package/es/components/ActionBar/ActionBarItem.js +7 -4
  17. package/es/components/ActionBar/ActionBarOverflowItems.d.ts +55 -16
  18. package/es/components/ActionBar/ActionBarOverflowItems.js +8 -4
  19. package/es/components/ConditionBuilder/ConditionBlock/ConditionBlock.d.ts +1 -0
  20. package/es/components/ConditionBuilder/ConditionBlock/ConditionBlock.js +17 -4
  21. package/es/components/ConditionBuilder/ConditionBuilderAdd/ConditionBuilderAdd.js +2 -2
  22. package/es/components/ConditionBuilder/ConditionBuilderButton/ConditionBuilderButton.js +6 -4
  23. package/es/components/ConditionBuilder/ConditionBuilderConnector/ConditionConnector.js +4 -1
  24. package/es/components/ConditionBuilder/ConditionBuilderContent/ConditionBuilderContent.js +8 -2
  25. package/es/components/ConditionBuilder/ConditionBuilderContext/translationObject.d.ts +3 -0
  26. package/es/components/ConditionBuilder/ConditionBuilderContext/translationObject.js +5 -2
  27. package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItem.js +20 -4
  28. package/es/components/ConditionBuilder/ConditionGroupBuilder/ConditionGroupBuilder.js +15 -7
  29. package/es/components/ConditionBuilder/ConditionPreview/ConditionPreview.d.ts +3 -1
  30. package/es/components/ConditionBuilder/ConditionPreview/ConditionPreview.js +9 -3
  31. package/es/components/ConditionBuilder/utils/handleKeyboardEvents.js +19 -6
  32. package/lib/components/ActionBar/ActionBar.d.ts +58 -2
  33. package/lib/components/ActionBar/ActionBar.js +14 -9
  34. package/lib/components/ActionBar/ActionBarItem.d.ts +36 -2
  35. package/lib/components/ActionBar/ActionBarItem.js +6 -3
  36. package/lib/components/ActionBar/ActionBarOverflowItems.d.ts +55 -16
  37. package/lib/components/ActionBar/ActionBarOverflowItems.js +8 -4
  38. package/lib/components/ConditionBuilder/ConditionBlock/ConditionBlock.d.ts +1 -0
  39. package/lib/components/ConditionBuilder/ConditionBlock/ConditionBlock.js +16 -3
  40. package/lib/components/ConditionBuilder/ConditionBuilderAdd/ConditionBuilderAdd.js +2 -2
  41. package/lib/components/ConditionBuilder/ConditionBuilderButton/ConditionBuilderButton.js +5 -3
  42. package/lib/components/ConditionBuilder/ConditionBuilderConnector/ConditionConnector.js +4 -1
  43. package/lib/components/ConditionBuilder/ConditionBuilderContent/ConditionBuilderContent.js +8 -2
  44. package/lib/components/ConditionBuilder/ConditionBuilderContext/translationObject.d.ts +3 -0
  45. package/lib/components/ConditionBuilder/ConditionBuilderContext/translationObject.js +5 -2
  46. package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItem.js +20 -4
  47. package/lib/components/ConditionBuilder/ConditionGroupBuilder/ConditionGroupBuilder.js +15 -7
  48. package/lib/components/ConditionBuilder/ConditionPreview/ConditionPreview.d.ts +3 -1
  49. package/lib/components/ConditionBuilder/ConditionPreview/ConditionPreview.js +9 -3
  50. package/lib/components/ConditionBuilder/utils/handleKeyboardEvents.js +19 -6
  51. package/package.json +2 -2
  52. package/scss/components/ConditionBuilder/_condition-builder.scss +3 -0
  53. package/scss/components/ConditionBuilder/styles/_conditionBuilderCondition.scss +11 -2
  54. package/scss/components/ConditionBuilder/styles/_conditionBuilderItem.scss +41 -31
@@ -20,7 +20,6 @@ import { ActionBarOverflowItems } from './ActionBarOverflowItems.js';
20
20
  var _excluded = ["actions", "className", "maxVisible", "menuOptionsClass", "onWidthChange", "overflowAriaLabel", "rightAlign"],
21
21
  _excluded2 = ["key", "id"],
22
22
  _excluded3 = ["key"];
23
-
24
23
  // The block part of our conventional BEM class names (blockClass__E--M).
25
24
  var blockClass = "".concat(pkg.prefix, "--action-bar");
26
25
  var componentName = 'ActionBar';
@@ -29,7 +28,6 @@ var componentName = 'ActionBar';
29
28
  var defaults = {
30
29
  actions: Object.freeze([])
31
30
  };
32
-
33
31
  // NOTE: the component SCSS is not imported here: it is rolled up separately.
34
32
 
35
33
  /**
@@ -53,7 +51,7 @@ var ActionBar = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
53
51
  _useState4 = _slicedToArray(_useState3, 2),
54
52
  displayedItems = _useState4[0],
55
53
  setDisplayedItems = _useState4[1];
56
- var _useState5 = useState([]),
54
+ var _useState5 = useState(null),
57
55
  _useState6 = _slicedToArray(_useState5, 2),
58
56
  hiddenSizingItems = _useState6[0],
59
57
  setHiddenSizingItems = _useState6[1];
@@ -61,7 +59,7 @@ var ActionBar = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
61
59
  var refDisplayedItems = useRef(null);
62
60
  var sizingRef = useRef(null);
63
61
  var sizes = useRef({});
64
- var backupRef = useRef();
62
+ var backupRef = useRef(null);
65
63
  var localRef = ref || backupRef;
66
64
 
67
65
  // create hidden sizing items
@@ -121,24 +119,25 @@ var ActionBar = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
121
119
  var checkFullyVisibleItems = function checkFullyVisibleItems() {
122
120
  /* istanbul ignore if */
123
121
  if (sizingRef.current) {
122
+ var _refDisplayedItems$cu;
124
123
  var sizingItems = Array.from(sizingRef.current.querySelectorAll(".".concat(blockClass, "__hidden-sizing-item")));
125
124
 
126
125
  // first item is always the overflow even if nothing else is rendered
127
126
  var overflowItem = sizingItems.shift();
128
127
 
129
128
  // determine how many will fit
130
- var spaceAvailable = refDisplayedItems.current.offsetWidth;
129
+ var spaceAvailable = (_refDisplayedItems$cu = refDisplayedItems.current) === null || _refDisplayedItems$cu === void 0 ? void 0 : _refDisplayedItems$cu.offsetWidth;
131
130
  var willFit = 0;
132
131
  var maxVisibleWidth = 0;
133
132
  var fitLimit = maxVisible ? Math.min(maxVisible, sizingItems.length) : sizingItems.length;
134
133
 
135
134
  // loop checking the space available
136
135
  for (var i = 0; i < fitLimit; i++) {
137
- var newSpaceAvailable = spaceAvailable - sizingItems[i].offsetWidth;
136
+ var newSpaceAvailable = spaceAvailable && spaceAvailable - sizingItems[i].offsetWidth;
138
137
 
139
138
  // update maxVisibleWidth for later use by onWidthChange
140
139
  maxVisibleWidth += sizingItems[i].offsetWidth;
141
- if (newSpaceAvailable >= 0) {
140
+ if (newSpaceAvailable && newSpaceAvailable >= 0) {
142
141
  spaceAvailable = newSpaceAvailable;
143
142
  willFit += 1;
144
143
  }
@@ -148,7 +147,7 @@ var ActionBar = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
148
147
  var overflowWidth = overflowItem.offsetWidth;
149
148
  if (willFit < sizingItems.length) {
150
149
  // Check space for overflow
151
- while (willFit > 0 && spaceAvailable < overflowWidth) {
150
+ while (willFit > 0 && spaceAvailable && spaceAvailable < overflowWidth) {
152
151
  willFit -= 1;
153
152
 
154
153
  // Highly unlikely that any action bar item is narrower than the overflow item
@@ -161,7 +160,10 @@ var ActionBar = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
161
160
  sizes.current.minWidth = overflowWidth;
162
161
  sizes.current.maxWidth = maxVisibleWidth;
163
162
  // emit onWidthChange
164
- onWidthChange(_objectSpread2({}, sizes.current));
163
+ onWidthChange({
164
+ minWidth: overflowWidth,
165
+ maxWidth: maxVisibleWidth
166
+ });
165
167
  }
166
168
  if (willFit < 1) {
167
169
  setDisplayCount(0);
@@ -212,14 +214,17 @@ ActionBar.propTypes = {
212
214
  *
213
215
  * Carbon Button API https://react.carbondesignsystem.com/?path=/docs/components-button--default#component-api
214
216
  */
217
+ /**@ts-ignore */
215
218
  actions: PropTypes.arrayOf(PropTypes.shape(_objectSpread2(_objectSpread2({}, prepareProps(Button.propTypes, [
216
219
  // props not desired from Button.propTypes
217
220
  'kind', 'size', 'tooltipPosition', 'tooltipAlignment'])), {}, {
221
+ id: PropTypes.string,
218
222
  // Additional props
219
223
  key: PropTypes.string.isRequired,
220
224
  // Redefine as form different to Button and a key prop used by ActionBarItems
221
225
  iconDescription: PropTypes.string.isRequired,
222
226
  label: PropTypes.string.isRequired,
227
+ /**@ts-ignore */
223
228
  renderIcon: Button.propTypes.renderIcon.isRequired,
224
229
  // We duplicate onClick here to improve DocGen in Storybook
225
230
  onClick: PropTypes.func
@@ -1,5 +1,39 @@
1
+ import React, { PropsWithChildren } from 'react';
2
+ import { CarbonIconType } from '@carbon/icons-react/lib/CarbonIcon';
3
+ interface ActionBarItemProps extends PropsWithChildren {
4
+ /**
5
+ * Specify an optional className to be added to your Button
6
+ *
7
+ * (inherited from Carbon Button)
8
+ */
9
+ className?: string;
10
+ /**
11
+ * If specifying the `renderIcon` prop, provide a description for that icon that can
12
+ * be read by screen readers
13
+ *
14
+ * (inherited from Carbon Button)
15
+ */
16
+ label?: string;
17
+ /**
18
+ * Optional click handler
19
+ *
20
+ * (inherited from Carbon Button)
21
+ */
22
+ onClick?: () => void;
23
+ /**
24
+ * Optional prop to allow overriding the icon rendering.
25
+ * Can be a React component class
26
+ *
27
+ * (inherited from Carbon Button)
28
+ */
29
+ renderIcon?: CarbonIconType;
30
+ /**
31
+ * Optional tab index
32
+ */
33
+ tabIndex?: number;
34
+ }
1
35
  /**
2
36
  * The ActionBarItem is used in the page header to populate the action bar
3
37
  */
4
- export let ActionBarItem: React.ForwardRefExoticComponent<React.RefAttributes<any>>;
5
- import React from 'react';
38
+ export declare let ActionBarItem: React.ForwardRefExoticComponent<ActionBarItemProps & React.RefAttributes<HTMLDivElement>>;
39
+ export {};
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- import { objectWithoutProperties as _objectWithoutProperties, objectSpread2 as _objectSpread2 } from '../../_virtual/_rollupPluginBabelHelpers.js';
8
+ import { objectSpread2 as _objectSpread2, objectWithoutProperties as _objectWithoutProperties } from '../../_virtual/_rollupPluginBabelHelpers.js';
9
9
  import React__default from 'react';
10
10
  import PropTypes from '../../node_modules/prop-types/index.js';
11
11
  import cx from 'classnames';
@@ -13,11 +13,9 @@ import { pkg } from '../../settings.js';
13
13
  import { IconButton } from '@carbon/react';
14
14
 
15
15
  var _excluded = ["label", "className", "renderIcon"];
16
-
17
16
  // The block part of our conventional BEM class names (blockClass__E--M).
18
17
  var componentName = 'ActionBarItem';
19
18
  var blockClass = "".concat(pkg.prefix, "--action-bar-item");
20
-
21
19
  // NOTE: the component SCSS is not imported here: it is rolled up separately.
22
20
 
23
21
  /**
@@ -85,7 +83,12 @@ ActionBarItem.propTypes = _objectSpread2(_objectSpread2({}, propTypes), {}, {
85
83
  *
86
84
  * (inherited from Carbon Button)
87
85
  */
88
- renderIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
86
+ /**@ts-ignore */
87
+ renderIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
88
+ /**
89
+ * Optional tab index
90
+ */
91
+ tabIndex: PropTypes.number
89
92
  });
90
93
 
91
94
  export { ActionBarItem };
@@ -1,18 +1,57 @@
1
- export function ActionBarOverflowItems({ className, menuOptionsClass, overflowItems, overflowAriaLabel, }: {
2
- className: any;
3
- menuOptionsClass: any;
4
- overflowItems: any;
5
- overflowAriaLabel: any;
6
- }): import("react/jsx-runtime").JSX.Element;
7
- export namespace ActionBarOverflowItems {
8
- export { componentName as displayName };
9
- export namespace propTypes {
10
- let className: PropTypes.Requireable<string>;
11
- let menuOptionsClass: PropTypes.Requireable<string>;
12
- let overflowAriaLabel: PropTypes.Requireable<string>;
13
- let overflowItems: PropTypes.Requireable<(PropTypes.ReactElementLike | null | undefined)[]>;
14
- }
15
- }
16
- declare const componentName: "ActionBar";
1
+ import { PropsWithChildren, ReactElement } from 'react';
17
2
  import PropTypes from 'prop-types';
3
+ import { CarbonIconType } from '@carbon/icons-react/lib/CarbonIcon';
4
+ type OverflowItem = {
5
+ label: string;
6
+ onClick: () => void;
7
+ renderIcon: CarbonIconType;
8
+ };
9
+ interface ActionBarOverflowItemProps extends PropsWithChildren {
10
+ /**
11
+ * className
12
+ */
13
+ className?: string;
14
+ /**
15
+ * class name applied to the overflow options
16
+ */
17
+ menuOptionsClass?: string;
18
+ /**
19
+ * overflowAriaLabel label for open close button overflow used for action bar items that do nto fit.
20
+ */
21
+ overflowAriaLabel?: string;
22
+ /**
23
+ * overflowItems: items to bre shown in the ActionBar overflow menu
24
+ */
25
+ overflowItems?: ReactElement<OverflowItem>[];
26
+ /**
27
+ * Optional tab index
28
+ */
29
+ tabIndex?: number;
30
+ }
31
+ export declare const ActionBarOverflowItems: {
32
+ ({ className, menuOptionsClass, overflowItems, overflowAriaLabel, }: ActionBarOverflowItemProps): import("react/jsx-runtime").JSX.Element;
33
+ displayName: string;
34
+ propTypes: {
35
+ /**
36
+ * className
37
+ */
38
+ className: PropTypes.Requireable<string>;
39
+ /**
40
+ * class name applied to the overflow options
41
+ */
42
+ menuOptionsClass: PropTypes.Requireable<string>;
43
+ /**
44
+ * overflowAriaLabel label for open close button overflow used for action bar items that do nto fit.
45
+ */
46
+ overflowAriaLabel: PropTypes.Requireable<string>;
47
+ /**
48
+ * overflowItems: items to bre shown in the ActionBar overflow menu
49
+ */
50
+ overflowItems: PropTypes.Requireable<(PropTypes.ReactElementLike | null | undefined)[]>;
51
+ /**
52
+ * Optional tab index
53
+ */
54
+ tabIndex: PropTypes.Requireable<number>;
55
+ };
56
+ };
18
57
  export {};
@@ -33,17 +33,17 @@ var ActionBarOverflowItems = function ActionBarOverflowItems(_ref) {
33
33
  // This uses a copy of a menu item option
34
34
  // NOTE: Cannot use a real Tooltip icon below as it uses a <button /> the
35
35
  // div equivalent below is based on Carbon 10.25.0
36
- var ItemIcon = item.props.renderIcon;
36
+ var ItemIcon = item === null || item === void 0 ? void 0 : item.props.renderIcon;
37
37
  return /*#__PURE__*/React__default.createElement(OverflowMenuItem, {
38
38
  className: "".concat(blockClass, "__item"),
39
- onClick: item.props.onClick,
39
+ onClick: item === null || item === void 0 ? void 0 : item.props.onClick,
40
40
  itemText: /*#__PURE__*/React__default.createElement("div", {
41
41
  className: "".concat(blockClass, "__item-content"),
42
42
  "aria-describedby": "".concat(internalId.current, "-").concat(index, "--item-label")
43
43
  }, /*#__PURE__*/React__default.createElement("span", {
44
44
  className: "".concat(blockClass, "__item-label"),
45
45
  id: "".concat(internalId.current, "-").concat(index, "--item-label")
46
- }, item.props.label), typeof item.props.renderIcon === 'function' ? /*#__PURE__*/React__default.createElement(ItemIcon, null) : item.props.renderIcon)
46
+ }, item === null || item === void 0 ? void 0 : item.props.label), typeof (item === null || item === void 0 ? void 0 : item.props.renderIcon) === 'function' ? /*#__PURE__*/React__default.createElement(ItemIcon, null) : item === null || item === void 0 ? void 0 : item.props.renderIcon)
47
47
  });
48
48
  }));
49
49
  };
@@ -65,7 +65,11 @@ ActionBarOverflowItems.propTypes = {
65
65
  /**
66
66
  * overflowItems: items to bre shown in the ActionBar overflow menu
67
67
  */
68
- overflowItems: PropTypes.arrayOf(PropTypes.element)
68
+ overflowItems: PropTypes.arrayOf(PropTypes.element),
69
+ /**
70
+ * Optional tab index
71
+ */
72
+ tabIndex: PropTypes.number
69
73
  };
70
74
 
71
75
  export { ActionBarOverflowItems };
@@ -20,6 +20,7 @@ declare namespace ConditionBlock {
20
20
  let onConnectorOperatorChange: PropTypes.Requireable<(...args: any[]) => any>;
21
21
  let onRemove: PropTypes.Requireable<(...args: any[]) => any>;
22
22
  let onStatementChange: PropTypes.Requireable<(...args: any[]) => any>;
23
+ let setShowDeletionPreviewForSubgroups: PropTypes.Requireable<(...args: any[]) => any>;
23
24
  let showConditionPreviewHandler: PropTypes.Requireable<(...args: any[]) => any>;
24
25
  let showConditionSubGroupPreviewHandler: PropTypes.Requireable<(...args: any[]) => any>;
25
26
  let state: PropTypes.Requireable<object>;
@@ -6,7 +6,7 @@
6
6
  */
7
7
 
8
8
  import { slicedToArray as _slicedToArray, extends as _extends, defineProperty as _defineProperty, objectSpread2 as _objectSpread2 } from '../../../_virtual/_rollupPluginBabelHelpers.js';
9
- import React__default, { useContext, useState } from 'react';
9
+ import React__default, { useContext, useState, useEffect } from 'react';
10
10
  import { Close } from '@carbon/react/icons';
11
11
  import { ConditionBuilderItem } from '../ConditionBuilderItem/ConditionBuilderItem.js';
12
12
  import PropTypes from '../../../node_modules/prop-types/index.js';
@@ -52,7 +52,8 @@ var ConditionBlock = function ConditionBlock(props) {
52
52
  showConditionSubGroupPreviewHandler = props.showConditionSubGroupPreviewHandler,
53
53
  hideConditionPreviewHandler = props.hideConditionPreviewHandler,
54
54
  showConditionPreviewHandler = props.showConditionPreviewHandler,
55
- isLastCondition = props.isLastCondition;
55
+ isLastCondition = props.isLastCondition,
56
+ setShowDeletionPreviewForSubgroups = props.setShowDeletionPreviewForSubgroups;
56
57
  var _useContext = useContext(ConditionBuilderContext),
57
58
  inputConfig = _useContext.inputConfig,
58
59
  variant = _useContext.variant,
@@ -93,6 +94,15 @@ var ConditionBlock = function ConditionBlock(props) {
93
94
  textarea: ConditionBuilderItemText
94
95
  };
95
96
  var ItemComponent = property ? itemComponents[type] : null;
97
+ useEffect(function () {
98
+ var _group$conditions, _group$conditions2;
99
+ if (showDeletionPreview && (group === null || group === void 0 || (_group$conditions = group.conditions) === null || _group$conditions === void 0 ? void 0 : _group$conditions.length) > 1 && group !== null && group !== void 0 && (_group$conditions2 = group.conditions) !== null && _group$conditions2 !== void 0 && _group$conditions2[1].conditions && group.conditions[1].id !== condition.id) {
100
+ setShowDeletionPreviewForSubgroups === null || setShowDeletionPreviewForSubgroups === void 0 || setShowDeletionPreviewForSubgroups(true);
101
+ } else {
102
+ setShowDeletionPreviewForSubgroups === null || setShowDeletionPreviewForSubgroups === void 0 || setShowDeletionPreviewForSubgroups(false);
103
+ }
104
+ // eslint-disable-next-line react-hooks/exhaustive-deps
105
+ }, [showDeletionPreview]);
96
106
  var onStatementChangeHandler = function onStatementChangeHandler(v, evt) {
97
107
  focusThisField(evt, conditionBuilderRef);
98
108
  onStatementChange(v);
@@ -112,10 +122,9 @@ var ConditionBlock = function ConditionBlock(props) {
112
122
  popoverToOpen: checkIsValid(newOperator) ? 'valueField' : ''
113
123
  }));
114
124
  };
115
- var onValueChangeHandler = function onValueChangeHandler(newValue, evt) {
125
+ var onValueChangeHandler = function onValueChangeHandler(newValue) {
116
126
  var currentCondition = _objectSpread2({}, condition);
117
127
  delete currentCondition.popoverToOpen;
118
- focusThisField(evt, conditionBuilderRef);
119
128
  onChange(_objectSpread2(_objectSpread2({}, currentCondition), {}, {
120
129
  value: newValue
121
130
  }));
@@ -308,6 +317,10 @@ ConditionBlock.propTypes = {
308
317
  * callback to handle the statement(if/ excl.if) change
309
318
  */
310
319
  onStatementChange: PropTypes.func,
320
+ /**
321
+ * method to set ShowDeletionPreviewForSubgroups
322
+ */
323
+ setShowDeletionPreviewForSubgroups: PropTypes.func,
311
324
  /**
312
325
  * handler for showing add condition preview
313
326
  */
@@ -87,11 +87,11 @@ var ConditionBuilderAdd = function ConditionBuilderAdd(_ref) {
87
87
  })), enableSubGroup && /*#__PURE__*/React__default.createElement(ConditionBuilderButton, _extends({
88
88
  renderIcon: TextNewLine,
89
89
  onClick: addConditionSubGroupHandler,
90
- className: cx("".concat(blockClass, "__add-condition-sub-group ").concat(blockClass, "__gap-left")),
90
+ className: cx("".concat(blockClass, "__add-condition-sub-group")),
91
91
  hideLabel: true,
92
92
  label: addSubgroupText,
93
93
  wrapperProps: wrapperProps,
94
- wrapperClassName: cx("".concat(blockClass, "__add-condition-sub-group-wrapper"), _defineProperty({}, "".concat(blockClass, "__add-condition-sub-group-wrapper--show"), isAddSubgroup))
94
+ wrapperClassName: cx("".concat(blockClass, "__add-condition-sub-group-wrapper ").concat(blockClass, "__gap-left"), _defineProperty({}, "".concat(blockClass, "__add-condition-sub-group-wrapper--show"), isAddSubgroup))
95
95
  }, previewHandlersForSubgroup())));
96
96
  };
97
97
  var ConditionBuilderAdd$1 = ConditionBuilderAdd;
@@ -9,7 +9,7 @@ import { objectWithoutProperties as _objectWithoutProperties, extends as _extend
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
- import { Tooltip } from '@carbon/react';
12
+ import { usePrefix, Tooltip } from '@carbon/react';
13
13
  import { blockClass } from '../ConditionBuilderContext/DataConfigs.js';
14
14
  import { WarningAltFilled } from '@carbon/react/icons';
15
15
 
@@ -33,11 +33,11 @@ var ConditionBuilderButton = function ConditionBuilderButton(_ref) {
33
33
  wrapperClassName = _ref.wrapperClassName,
34
34
  tabIndex = _ref.tabIndex,
35
35
  rest = _objectWithoutProperties(_ref, _excluded);
36
+ var carbonPrefix = usePrefix();
36
37
  var Button = function Button() {
37
38
  var _rest$dataName;
38
39
  var dataName = (_rest$dataName = rest['data-name']) !== null && _rest$dataName !== void 0 ? _rest$dataName : '';
39
40
  return /*#__PURE__*/React__default.createElement("button", _extends({
40
- // role={'gridcell'}
41
41
  tabIndex: tabIndex != undefined ? tabIndex : -1,
42
42
  className: cx([className, "".concat(blockClass, "__button"), _defineProperty({}, "".concat(blockClass, "__text-ellipsis"), showToolTip && !hideLabel && !isInvalid), _defineProperty({}, "".concat(blockClass, "__invalid-input"), isInvalid)]),
43
43
  type: "button",
@@ -52,8 +52,10 @@ var ConditionBuilderButton = function ConditionBuilderButton(_ref) {
52
52
  return hideLabel || showToolTip ? /*#__PURE__*/React__default.createElement(Tooltip, _extends({
53
53
  label: label,
54
54
  align: tooltipAlign,
55
- className: "".concat(wrapperClassName)
56
- }, wrapperProps), Button()) : /*#__PURE__*/React__default.createElement(React__default.Fragment, null, Button());
55
+ className: "".concat(wrapperClassName, " ").concat(blockClass, "__tooltip ").concat(carbonPrefix, "--icon-tooltip")
56
+ }, wrapperProps, {
57
+ leaveDelayMs: 0
58
+ }), Button()) : /*#__PURE__*/React__default.createElement(React__default.Fragment, null, Button());
57
59
  };
58
60
  ConditionBuilderButton.propTypes = {
59
61
  /**
@@ -14,6 +14,7 @@ import PropTypes from '../../../node_modules/prop-types/index.js';
14
14
  import { focusThisField } from '../utils/util.js';
15
15
  import { ConditionBuilderContext } from '../ConditionBuilderContext/ConditionBuilderProvider.js';
16
16
  import { useTranslations } from '../utils/useTranslations.js';
17
+ import { ConditionBuilderButton } from '../ConditionBuilderButton/ConditionBuilderButton.js';
17
18
 
18
19
  var _excluded = ["operator", "className", "onChange"];
19
20
  var ConditionConnector = function ConditionConnector(_ref) {
@@ -48,7 +49,9 @@ var ConditionConnector = function ConditionConnector(_ref) {
48
49
  };
49
50
  return variant == 'tree' ? /*#__PURE__*/React__default.createElement("span", {
50
51
  className: "".concat(className, " ").concat(blockClass, "__connector--disabled")
51
- }, operator) :
52
+ }, /*#__PURE__*/React__default.createElement(ConditionBuilderButton, {
53
+ label: operator
54
+ })) :
52
55
  /*#__PURE__*/
53
56
  // <div className={className} {...rest}>
54
57
  React__default.createElement(ConditionBuilderItem, _extends({
@@ -22,7 +22,7 @@ import { useTranslations } from '../utils/useTranslations.js';
22
22
 
23
23
  var _GroupConnector;
24
24
  var ConditionBuilderContent = function ConditionBuilderContent(_ref) {
25
- var _rootState$groups2;
25
+ var _rootState$groups3;
26
26
  var startConditionLabel = _ref.startConditionLabel,
27
27
  getConditionState = _ref.getConditionState,
28
28
  getActionsState = _ref.getActionsState,
@@ -110,6 +110,11 @@ var ConditionBuilderContent = function ConditionBuilderContent(_ref) {
110
110
  groups: [].concat(_toConsumableArray(rootState.groups), [newGroup])
111
111
  }));
112
112
  };
113
+ var getColorIndex = function getColorIndex() {
114
+ var _rootState$groups$len, _rootState$groups2;
115
+ var groupLength = (_rootState$groups$len = rootState === null || rootState === void 0 || (_rootState$groups2 = rootState.groups) === null || _rootState$groups2 === void 0 ? void 0 : _rootState$groups2.length) !== null && _rootState$groups$len !== void 0 ? _rootState$groups$len : 0;
116
+ return groupLength % 5;
117
+ };
113
118
  if (!isConditionBuilderActive) {
114
119
  return /*#__PURE__*/React__default.createElement(Button, {
115
120
  className: "".concat(blockClass, "__addConditionText-button"),
@@ -129,7 +134,7 @@ var ConditionBuilderContent = function ConditionBuilderContent(_ref) {
129
134
  className: "".concat(blockClass, "__content-container"),
130
135
  role: "treegrid",
131
136
  "aria-label": "condition builder tree"
132
- }, rootState && (rootState === null || rootState === void 0 || (_rootState$groups2 = rootState.groups) === null || _rootState$groups2 === void 0 ? void 0 : _rootState$groups2.map(function (eachGroup, groupIndex) {
137
+ }, rootState && (rootState === null || rootState === void 0 || (_rootState$groups3 = rootState.groups) === null || _rootState$groups3 === void 0 ? void 0 : _rootState$groups3.map(function (eachGroup, groupIndex) {
133
138
  return /*#__PURE__*/React__default.createElement("div", {
134
139
  key: eachGroup.id,
135
140
  className: "".concat(blockClass, "__group-wrapper")
@@ -169,6 +174,7 @@ var ConditionBuilderContent = function ConditionBuilderContent(_ref) {
169
174
  }
170
175
  })), showConditionGroupPreview && /*#__PURE__*/React__default.createElement(ConditionPreview, {
171
176
  previewType: "newGroup",
177
+ colorIndex: getColorIndex(),
172
178
  group: {
173
179
  groupOperator: rootState.operator
174
180
  }
@@ -39,4 +39,7 @@ export namespace translationsObject {
39
39
  let conditionBuilderText: string;
40
40
  let actionSectionText: string;
41
41
  let conditionHeadingText: string;
42
+ let addPropertyText: string;
43
+ let addOperatorText: string;
44
+ let addValueText: string;
42
45
  }
@@ -32,7 +32,7 @@ var translationsObject = {
32
32
  connectorText: 'Connector',
33
33
  conditionRowText: 'Condition row',
34
34
  conditionRowGroupText: 'Condition row group',
35
- removeConditionText: 'Remove condition',
35
+ removeConditionText: 'Delete condition',
36
36
  addConditionRowText: 'Add condition row',
37
37
  startText: 'Start',
38
38
  endText: 'End',
@@ -45,7 +45,10 @@ var translationsObject = {
45
45
  invalidNumberWarnText: 'Invalid number, must be 0 or greater',
46
46
  conditionBuilderText: 'Condition Builder',
47
47
  actionSectionText: 'Action Section',
48
- conditionHeadingText: 'Condition'
48
+ conditionHeadingText: 'Condition',
49
+ addPropertyText: 'Add property',
50
+ addOperatorText: 'Add operator',
51
+ addValueText: 'Add value'
49
52
  };
50
53
 
51
54
  export { translationsObject };
@@ -36,11 +36,14 @@ var ConditionBuilderItem = function ConditionBuilderItem(_ref) {
36
36
  _useState2 = _slicedToArray(_useState, 2),
37
37
  open = _useState2[0],
38
38
  setOpen = _useState2[1];
39
- var _useTranslations = useTranslations(['invalidText', 'addConditionText', label]),
40
- _useTranslations2 = _slicedToArray(_useTranslations, 3),
39
+ var _useTranslations = useTranslations(['invalidText', 'addConditionText', 'addPropertyText', 'addOperatorText', 'addValueText', label]),
40
+ _useTranslations2 = _slicedToArray(_useTranslations, 6),
41
41
  invalidText = _useTranslations2[0],
42
42
  addConditionText = _useTranslations2[1],
43
- labelText = _useTranslations2[2];
43
+ addPropertyText = _useTranslations2[2],
44
+ addOperatorText = _useTranslations2[3],
45
+ addValueText = _useTranslations2[4],
46
+ labelText = _useTranslations2[5];
44
47
  var _useContext = useContext(ConditionBuilderContext),
45
48
  conditionBuilderRef = _useContext.conditionBuilderRef;
46
49
  var getPropertyDetails = function getPropertyDetails() {
@@ -125,6 +128,19 @@ var ConditionBuilderItem = function ConditionBuilderItem(_ref) {
125
128
  manageInvalidSelection();
126
129
  }
127
130
  };
131
+ var getLabel = function getLabel() {
132
+ if (propertyLabel) {
133
+ return propertyLabel;
134
+ } else if (rest['data-name'] === 'propertyField') {
135
+ return addPropertyText;
136
+ } else if (rest['data-name'] === 'operatorField') {
137
+ return addOperatorText;
138
+ } else if (rest['data-name'] === 'valueField') {
139
+ return addValueText;
140
+ } else {
141
+ return addConditionText;
142
+ }
143
+ };
128
144
  return /*#__PURE__*/React__default.createElement(Popover, {
129
145
  open: open,
130
146
  isTabTip: true,
@@ -133,7 +149,7 @@ var ConditionBuilderItem = function ConditionBuilderItem(_ref) {
133
149
  ref: popoverRef,
134
150
  onRequestClose: closePopover
135
151
  }, /*#__PURE__*/React__default.createElement(ConditionBuilderButton, _extends({
136
- label: propertyLabel !== null && propertyLabel !== void 0 ? propertyLabel : addConditionText,
152
+ label: getLabel(),
137
153
  hideLabel: !label ? true : false,
138
154
  onClick: togglePopover,
139
155
  className: className,
@@ -50,6 +50,10 @@ var ConditionGroupBuilder = function ConditionGroupBuilder(_ref) {
50
50
  _useState4 = _slicedToArray(_useState3, 2),
51
51
  showConditionSubGroupPreview = _useState4[0],
52
52
  setShowConditionSubGroupPreview = _useState4[1];
53
+ var _useState5 = useState(false),
54
+ _useState6 = _slicedToArray(_useState5, 2),
55
+ showDeletionPreviewForSubgroups = _useState6[0],
56
+ setShowDeletionPreviewForSubgroups = _useState6[1];
53
57
  var conditionBuilderContentRef = useRef();
54
58
  var onRemoveHandler = function onRemoveHandler(conditionId, evt, conditionIndex) {
55
59
  if (group.conditions.length > 1) {
@@ -80,9 +84,11 @@ var ConditionGroupBuilder = function ConditionGroupBuilder(_ref) {
80
84
  groupedItems.conditions.push(item);
81
85
  }
82
86
  });
83
- onChange(_objectSpread2(_objectSpread2({}, group), {}, {
84
- conditions: [].concat(_toConsumableArray(groupedItems.conditions), _toConsumableArray(groupedItems.groups))
85
- }));
87
+ onRemove(evt);
88
+ // onChange({
89
+ // ...group,
90
+ // conditions: [...groupedItems.conditions, ...groupedItems.groups],
91
+ // });
86
92
  } else {
87
93
  onChange(_objectSpread2(_objectSpread2({}, group), {}, {
88
94
  conditions: group.conditions.filter(function (condition) {
@@ -155,10 +161,11 @@ var ConditionGroupBuilder = function ConditionGroupBuilder(_ref) {
155
161
  };
156
162
  setTimeout(function () {
157
163
  var currentRowToFocus = conditionBuilderContentRef.current.querySelector("[role=\"row\"][aria-level=\"".concat(rowIdentity.ariaLevel, "\"][aria-posinset=\"").concat(rowIdentity.ariaPosInSet, "\"]"));
158
- manageTabIndexAndFocus(currentRowToFocus, conditionBuilderRef);
164
+ manageTabIndexAndFocus(currentRowToFocus === null || currentRowToFocus === void 0 ? void 0 : currentRowToFocus.querySelector('[data-name="closeCondition"]'), conditionBuilderRef);
159
165
  }, 0);
160
166
  } else if ((prevRows === null || prevRows === void 0 ? void 0 : prevRows.length) > 1) {
161
- manageTabIndexAndFocus(prevRows[prevRows.length - 2], conditionBuilderRef);
167
+ var _prevRows;
168
+ manageTabIndexAndFocus((_prevRows = prevRows[prevRows.length - 2]) === null || _prevRows === void 0 ? void 0 : _prevRows.querySelector('[data-name="closeCondition"]'), conditionBuilderRef);
162
169
  }
163
170
  }
164
171
  };
@@ -279,7 +286,7 @@ var ConditionGroupBuilder = function ConditionGroupBuilder(_ref) {
279
286
  return /*#__PURE__*/React__default.createElement(Fragment, {
280
287
  key: eachCondition.id
281
288
  }, eachCondition.conditions ? /*#__PURE__*/React__default.createElement("div", {
282
- className: cx("".concat(blockClass, "__condition-block subgroup ").concat(blockClass, "__gap"), _defineProperty({}, "".concat(blockClass, "__gap-bottom"), group.conditions.length < conditionIndex + 1))
289
+ className: cx("".concat(blockClass, "__condition-block subgroup ").concat(blockClass, "__gap"), _defineProperty(_defineProperty({}, "".concat(blockClass, "__gap-bottom"), group.conditions.length < conditionIndex + 1), "".concat(blockClass, "__subgroup_deletionPreview"), showDeletionPreviewForSubgroups), {})
283
290
  }, /*#__PURE__*/React__default.createElement(ConditionConnector, {
284
291
  className: "".concat(blockClass, "__gap ").concat(blockClass, "__gap-bottom ").concat(blockClass, "__groupConnector"),
285
292
  operator: group.groupOperator,
@@ -327,7 +334,8 @@ var ConditionGroupBuilder = function ConditionGroupBuilder(_ref) {
327
334
  _showConditionPreviewHandler(conditionIndex);
328
335
  },
329
336
  hideConditionPreviewHandler: hideConditionPreviewHandler,
330
- isLastCondition: isLastCondition
337
+ isLastCondition: isLastCondition,
338
+ setShowDeletionPreviewForSubgroups: setShowDeletionPreviewForSubgroups
331
339
  })), conditionIndex == showConditionSubGroupPreview && (_ConditionPreview || (_ConditionPreview = /*#__PURE__*/React__default.createElement(ConditionPreview, {
332
340
  previewType: "subGroup",
333
341
  group: group
@@ -1,10 +1,12 @@
1
1
  export default ConditionPreview;
2
- declare function ConditionPreview({ previewType, group }: {
2
+ declare function ConditionPreview({ previewType, group, colorIndex }: {
3
3
  previewType: any;
4
4
  group: any;
5
+ colorIndex: any;
5
6
  }): import("react/jsx-runtime").JSX.Element;
6
7
  declare namespace ConditionPreview {
7
8
  namespace propTypes {
9
+ let colorIndex: PropTypes.Requireable<number>;
8
10
  let group: PropTypes.Requireable<object>;
9
11
  let previewType: PropTypes.Requireable<string>;
10
12
  }