@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
@@ -18,7 +18,8 @@ import { Bee } from '@carbon/react/icons';
18
18
  var ConditionPreview = function ConditionPreview(_ref) {
19
19
  var _ConditionBuilderItem, _ConditionBuilderItem2, _ConditionBuilderItem3;
20
20
  var previewType = _ref.previewType,
21
- group = _ref.group;
21
+ group = _ref.group,
22
+ colorIndex = _ref.colorIndex;
22
23
  var _useState = useState(false),
23
24
  _useState2 = _slicedToArray(_useState, 2),
24
25
  animate = _useState2[0],
@@ -50,6 +51,7 @@ var ConditionPreview = function ConditionPreview(_ref) {
50
51
  className: "".concat(blockClass, "__statement-button"),
51
52
  label: group.groupOperator
52
53
  })), /*#__PURE__*/React__default.createElement("div", {
54
+ "data-color-index": colorIndex,
53
55
  "aria-hidden": true,
54
56
  className: cx(["".concat(blockClass, "__group ").concat(blockClass, "__condition-wrapper ").concat(blockClass, "__group-preview ").concat(blockClass, "__group-wrapper "), _defineProperty({}, "".concat(blockClass, "__group-preview-animate"), animate)])
55
57
  }, /*#__PURE__*/React__default.createElement("div", {
@@ -58,7 +60,7 @@ var ConditionPreview = function ConditionPreview(_ref) {
58
60
  className: "".concat(blockClass, "__statement-button"),
59
61
  label: ifText
60
62
  })), getConditionSection())), previewType == 'subGroup' && /*#__PURE__*/React__default.createElement("div", {
61
- className: cx(["".concat(blockClass, "__group__row ").concat(blockClass, "__group-preview "), _defineProperty({}, "".concat(blockClass, "__group-preview-animate"), animate)])
63
+ className: cx(["".concat(blockClass, "__group__row ").concat(blockClass, "__group-preview ").concat(blockClass, "__gap-bottom"), _defineProperty({}, "".concat(blockClass, "__group-preview-animate"), animate)])
62
64
  }, /*#__PURE__*/React__default.createElement("div", {
63
65
  className: "".concat(blockClass, "__condition-block ").concat(blockClass, "__gap")
64
66
  }, /*#__PURE__*/React__default.createElement(ConditionBuilderItem, {
@@ -71,7 +73,7 @@ var ConditionPreview = function ConditionPreview(_ref) {
71
73
  className: "".concat(blockClass, "__gap ").concat(blockClass, "__groupConnector"),
72
74
  operator: ifText
73
75
  }), getConditionSection()))), previewType == 'condition' && /*#__PURE__*/React__default.createElement("div", {
74
- className: cx(["".concat(blockClass, "__group__row ").concat(blockClass, "__group-preview "), _defineProperty({}, "".concat(blockClass, "__group-preview-animate"), animate)])
76
+ className: cx(["".concat(blockClass, "__group__row ").concat(blockClass, "__group-preview ").concat(blockClass, "__gap-bottom"), _defineProperty({}, "".concat(blockClass, "__group-preview-animate"), animate)])
75
77
  }, /*#__PURE__*/React__default.createElement("div", {
76
78
  className: "".concat(blockClass, "__condition-block ").concat(blockClass, "__gap")
77
79
  }, /*#__PURE__*/React__default.createElement(ConditionBuilderItem, {
@@ -82,6 +84,10 @@ var ConditionPreview = function ConditionPreview(_ref) {
82
84
  };
83
85
  var ConditionPreview$1 = ConditionPreview;
84
86
  ConditionPreview.propTypes = {
87
+ /**
88
+ * index of the color for next group
89
+ */
90
+ colorIndex: PropTypes.number,
85
91
  /**
86
92
  * current conditional group
87
93
  */
@@ -35,12 +35,18 @@ var handleKeyPressForPopover = function handleKeyPressForPopover(evt, parentCont
35
35
  var allItems = [];
36
36
  switch (key) {
37
37
  case 'ArrowUp':
38
+ evt.preventDefault();
38
39
  //traverse through the popover options, search box, selectAll button
39
40
  parentContainer.querySelectorAll("[role=\"option\"]").forEach(function (eachElem, index, allElements) {
40
41
  traverseReverse(eachElem, index, allElements, null, null, conditionBuilderRef);
41
42
  });
43
+ //scroll to top when we reach a the top of the list to make search box visible
44
+ if (Array.from(evt.target.closest('ul').querySelectorAll('li')).indexOf(evt.target) === 1) {
45
+ parentContainer.querySelector(".".concat(blockClass, "__popover-content-wrapper")).scrollTop = 0;
46
+ }
42
47
  break;
43
48
  case 'ArrowDown':
49
+ evt.preventDefault();
44
50
  //traverse through the popover options, search box, selectAll button
45
51
  parentContainer.querySelectorAll("[role=\"option\"]").forEach(function (eachElem, index, allElements) {
46
52
  traverseClockVise(eachElem, index, allElements, null, null, conditionBuilderRef);
@@ -68,12 +74,19 @@ var handleKeyPressForPopover = function handleKeyPressForPopover(evt, parentCont
68
74
  }
69
75
  break;
70
76
  case 'Enter':
71
- if (isMultiSelect !== 'true') {
77
+ if (isMultiSelect === 'true') {
72
78
  if (document.activeElement.type !== 'button') {
73
79
  var _document$activeEleme2;
80
+ //for button , enter key is click which already handled by framework, for other elements trigger click
81
+ (_document$activeEleme2 = document.activeElement) === null || _document$activeEleme2 === void 0 || _document$activeEleme2.click();
82
+ }
83
+ evt.preventDefault();
84
+ } else {
85
+ if (document.activeElement.type !== 'button') {
86
+ var _document$activeEleme3;
74
87
  //for button , enter key is click which already handled by framework, else trigger click
75
88
  focusThisField(evt, conditionBuilderRef);
76
- (_document$activeEleme2 = document.activeElement) === null || _document$activeEleme2 === void 0 || _document$activeEleme2.click();
89
+ (_document$activeEleme3 = document.activeElement) === null || _document$activeEleme3 === void 0 || _document$activeEleme3.click();
77
90
  }
78
91
  }
79
92
  break;
@@ -84,7 +97,7 @@ var handleKeyPressForPopover = function handleKeyPressForPopover(evt, parentCont
84
97
  }
85
98
  };
86
99
  var handleKeyPressForMainContent = function handleKeyPressForMainContent(evt, conditionBuilderRef, variant) {
87
- var _document$activeEleme3;
100
+ var _document$activeEleme4;
88
101
  switch (evt.key) {
89
102
  case 'ArrowRight':
90
103
  evt.preventDefault();
@@ -144,9 +157,9 @@ var handleKeyPressForMainContent = function handleKeyPressForMainContent(evt, co
144
157
  }
145
158
  break;
146
159
  case 'Enter':
147
- if (((_document$activeEleme3 = document.activeElement) === null || _document$activeEleme3 === void 0 || (_document$activeEleme3 = _document$activeEleme3.querySelectorAll("button")) === null || _document$activeEleme3 === void 0 ? void 0 : _document$activeEleme3.length) === 1) {
148
- var _document$activeEleme4;
149
- (_document$activeEleme4 = document.activeElement) === null || _document$activeEleme4 === void 0 || (_document$activeEleme4 = _document$activeEleme4.querySelectorAll("button")[0]) === null || _document$activeEleme4 === void 0 || _document$activeEleme4.click();
160
+ if (((_document$activeEleme4 = document.activeElement) === null || _document$activeEleme4 === void 0 || (_document$activeEleme4 = _document$activeEleme4.querySelectorAll("button")) === null || _document$activeEleme4 === void 0 ? void 0 : _document$activeEleme4.length) === 1) {
161
+ var _document$activeEleme5;
162
+ (_document$activeEleme5 = document.activeElement) === null || _document$activeEleme5 === void 0 || (_document$activeEleme5 = _document$activeEleme5.querySelectorAll("button")[0]) === null || _document$activeEleme5 === void 0 || _document$activeEleme5.click();
150
163
  }
151
164
  break;
152
165
  }
@@ -1,5 +1,61 @@
1
+ import React, { PropsWithChildren } from 'react';
2
+ import { ButtonProps } from '@carbon/type';
3
+ import { CarbonIconType } from '@carbon/icons-react/lib/CarbonIcon';
4
+ interface Action extends ButtonProps {
5
+ id?: string;
6
+ key: string;
7
+ iconDescription: string;
8
+ label: string;
9
+ onClick?: () => void;
10
+ renderIcon: CarbonIconType;
11
+ }
12
+ interface ActionBarProps extends PropsWithChildren {
13
+ /**
14
+ * Specifies the action bar items. Each item is specified as an object
15
+ * with required fields: key for array rendering, renderIcon, iconDescription and
16
+ * label to provide the icon to display,
17
+ * and optional 'onClick' to receive notifications when the button is clicked.
18
+ * Additional fields in the object will be passed to the
19
+ * Button component, and these can include 'disabled', 'ref', 'className',
20
+ * and any other Button props.
21
+ *
22
+ * Note that the Button props 'kind', 'size',
23
+ * 'tooltipPosition', 'tooltipAlignment' and 'type' are ignored, as these
24
+ * cannot be used for an action bar item.
25
+ *
26
+ * Carbon Button API https://react.carbondesignsystem.com/?path=/docs/components-button--default#component-api
27
+ */
28
+ actions?: readonly Action[];
29
+ /**
30
+ * className
31
+ */
32
+ className?: string;
33
+ /**
34
+ * maxVisible : Maximum action bar items visible before going into the overflow menu
35
+ */
36
+ maxVisible?: number;
37
+ /**
38
+ * class name applied to the overflow options
39
+ */
40
+ menuOptionsClass?: string;
41
+ /**
42
+ * onItemCountChange - event reporting maxWidth
43
+ */
44
+ onWidthChange?: (sizes: {
45
+ minWidth: number;
46
+ maxWidth: number;
47
+ }) => void;
48
+ /**
49
+ * overflowAriaLabel label for open close button overflow used for action bar items that do nto fit.
50
+ */
51
+ overflowAriaLabel: string;
52
+ /**
53
+ * align tags to right of available space
54
+ */
55
+ rightAlign?: boolean;
56
+ }
1
57
  /**
2
58
  * The ActionBar is used internally by the PageHeader to wrap ActionBarItems.
3
59
  */
4
- export let ActionBar: React.ForwardRefExoticComponent<React.RefAttributes<any>>;
5
- import React from 'react';
60
+ export declare let ActionBar: React.ForwardRefExoticComponent<ActionBarProps & React.RefAttributes<HTMLDivElement>>;
61
+ export {};
@@ -29,7 +29,6 @@ var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
29
29
  var _excluded = ["actions", "className", "maxVisible", "menuOptionsClass", "onWidthChange", "overflowAriaLabel", "rightAlign"],
30
30
  _excluded2 = ["key", "id"],
31
31
  _excluded3 = ["key"];
32
-
33
32
  // The block part of our conventional BEM class names (blockClass__E--M).
34
33
  var blockClass = "".concat(settings.pkg.prefix, "--action-bar");
35
34
  var componentName = 'ActionBar';
@@ -38,7 +37,6 @@ var componentName = 'ActionBar';
38
37
  var defaults = {
39
38
  actions: Object.freeze([])
40
39
  };
41
-
42
40
  // NOTE: the component SCSS is not imported here: it is rolled up separately.
43
41
 
44
42
  /**
@@ -62,7 +60,7 @@ exports.ActionBar = /*#__PURE__*/React__default["default"].forwardRef(function (
62
60
  _useState4 = _rollupPluginBabelHelpers.slicedToArray(_useState3, 2),
63
61
  displayedItems = _useState4[0],
64
62
  setDisplayedItems = _useState4[1];
65
- var _useState5 = React.useState([]),
63
+ var _useState5 = React.useState(null),
66
64
  _useState6 = _rollupPluginBabelHelpers.slicedToArray(_useState5, 2),
67
65
  hiddenSizingItems = _useState6[0],
68
66
  setHiddenSizingItems = _useState6[1];
@@ -70,7 +68,7 @@ exports.ActionBar = /*#__PURE__*/React__default["default"].forwardRef(function (
70
68
  var refDisplayedItems = React.useRef(null);
71
69
  var sizingRef = React.useRef(null);
72
70
  var sizes = React.useRef({});
73
- var backupRef = React.useRef();
71
+ var backupRef = React.useRef(null);
74
72
  var localRef = ref || backupRef;
75
73
 
76
74
  // create hidden sizing items
@@ -130,24 +128,25 @@ exports.ActionBar = /*#__PURE__*/React__default["default"].forwardRef(function (
130
128
  var checkFullyVisibleItems = function checkFullyVisibleItems() {
131
129
  /* istanbul ignore if */
132
130
  if (sizingRef.current) {
131
+ var _refDisplayedItems$cu;
133
132
  var sizingItems = Array.from(sizingRef.current.querySelectorAll(".".concat(blockClass, "__hidden-sizing-item")));
134
133
 
135
134
  // first item is always the overflow even if nothing else is rendered
136
135
  var overflowItem = sizingItems.shift();
137
136
 
138
137
  // determine how many will fit
139
- var spaceAvailable = refDisplayedItems.current.offsetWidth;
138
+ var spaceAvailable = (_refDisplayedItems$cu = refDisplayedItems.current) === null || _refDisplayedItems$cu === void 0 ? void 0 : _refDisplayedItems$cu.offsetWidth;
140
139
  var willFit = 0;
141
140
  var maxVisibleWidth = 0;
142
141
  var fitLimit = maxVisible ? Math.min(maxVisible, sizingItems.length) : sizingItems.length;
143
142
 
144
143
  // loop checking the space available
145
144
  for (var i = 0; i < fitLimit; i++) {
146
- var newSpaceAvailable = spaceAvailable - sizingItems[i].offsetWidth;
145
+ var newSpaceAvailable = spaceAvailable && spaceAvailable - sizingItems[i].offsetWidth;
147
146
 
148
147
  // update maxVisibleWidth for later use by onWidthChange
149
148
  maxVisibleWidth += sizingItems[i].offsetWidth;
150
- if (newSpaceAvailable >= 0) {
149
+ if (newSpaceAvailable && newSpaceAvailable >= 0) {
151
150
  spaceAvailable = newSpaceAvailable;
152
151
  willFit += 1;
153
152
  }
@@ -157,7 +156,7 @@ exports.ActionBar = /*#__PURE__*/React__default["default"].forwardRef(function (
157
156
  var overflowWidth = overflowItem.offsetWidth;
158
157
  if (willFit < sizingItems.length) {
159
158
  // Check space for overflow
160
- while (willFit > 0 && spaceAvailable < overflowWidth) {
159
+ while (willFit > 0 && spaceAvailable && spaceAvailable < overflowWidth) {
161
160
  willFit -= 1;
162
161
 
163
162
  // Highly unlikely that any action bar item is narrower than the overflow item
@@ -170,7 +169,10 @@ exports.ActionBar = /*#__PURE__*/React__default["default"].forwardRef(function (
170
169
  sizes.current.minWidth = overflowWidth;
171
170
  sizes.current.maxWidth = maxVisibleWidth;
172
171
  // emit onWidthChange
173
- onWidthChange(_rollupPluginBabelHelpers.objectSpread2({}, sizes.current));
172
+ onWidthChange({
173
+ minWidth: overflowWidth,
174
+ maxWidth: maxVisibleWidth
175
+ });
174
176
  }
175
177
  if (willFit < 1) {
176
178
  setDisplayCount(0);
@@ -221,14 +223,17 @@ exports.ActionBar.propTypes = {
221
223
  *
222
224
  * Carbon Button API https://react.carbondesignsystem.com/?path=/docs/components-button--default#component-api
223
225
  */
226
+ /**@ts-ignore */
224
227
  actions: index["default"].arrayOf(index["default"].shape(_rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, propsHelper.prepareProps(react.Button.propTypes, [
225
228
  // props not desired from Button.propTypes
226
229
  'kind', 'size', 'tooltipPosition', 'tooltipAlignment'])), {}, {
230
+ id: index["default"].string,
227
231
  // Additional props
228
232
  key: index["default"].string.isRequired,
229
233
  // Redefine as form different to Button and a key prop used by ActionBarItems
230
234
  iconDescription: index["default"].string.isRequired,
231
235
  label: index["default"].string.isRequired,
236
+ /**@ts-ignore */
232
237
  renderIcon: react.Button.propTypes.renderIcon.isRequired,
233
238
  // We duplicate onClick here to improve DocGen in Storybook
234
239
  onClick: index["default"].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 {};
@@ -22,11 +22,9 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
22
22
  var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
23
23
 
24
24
  var _excluded = ["label", "className", "renderIcon"];
25
-
26
25
  // The block part of our conventional BEM class names (blockClass__E--M).
27
26
  var componentName = 'ActionBarItem';
28
27
  var blockClass = "".concat(settings.pkg.prefix, "--action-bar-item");
29
-
30
28
  // NOTE: the component SCSS is not imported here: it is rolled up separately.
31
29
 
32
30
  /**
@@ -94,5 +92,10 @@ exports.ActionBarItem.propTypes = _rollupPluginBabelHelpers.objectSpread2(_rollu
94
92
  *
95
93
  * (inherited from Carbon Button)
96
94
  */
97
- renderIcon: index["default"].oneOfType([index["default"].func, index["default"].object])
95
+ /**@ts-ignore */
96
+ renderIcon: index["default"].oneOfType([index["default"].func, index["default"].object]),
97
+ /**
98
+ * Optional tab index
99
+ */
100
+ tabIndex: index["default"].number
98
101
  });
@@ -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 {};
@@ -42,17 +42,17 @@ var ActionBarOverflowItems = function ActionBarOverflowItems(_ref) {
42
42
  // This uses a copy of a menu item option
43
43
  // NOTE: Cannot use a real Tooltip icon below as it uses a <button /> the
44
44
  // div equivalent below is based on Carbon 10.25.0
45
- var ItemIcon = item.props.renderIcon;
45
+ var ItemIcon = item === null || item === void 0 ? void 0 : item.props.renderIcon;
46
46
  return /*#__PURE__*/React__default["default"].createElement(react.OverflowMenuItem, {
47
47
  className: "".concat(blockClass, "__item"),
48
- onClick: item.props.onClick,
48
+ onClick: item === null || item === void 0 ? void 0 : item.props.onClick,
49
49
  itemText: /*#__PURE__*/React__default["default"].createElement("div", {
50
50
  className: "".concat(blockClass, "__item-content"),
51
51
  "aria-describedby": "".concat(internalId.current, "-").concat(index, "--item-label")
52
52
  }, /*#__PURE__*/React__default["default"].createElement("span", {
53
53
  className: "".concat(blockClass, "__item-label"),
54
54
  id: "".concat(internalId.current, "-").concat(index, "--item-label")
55
- }, item.props.label), typeof item.props.renderIcon === 'function' ? /*#__PURE__*/React__default["default"].createElement(ItemIcon, null) : item.props.renderIcon)
55
+ }, 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["default"].createElement(ItemIcon, null) : item === null || item === void 0 ? void 0 : item.props.renderIcon)
56
56
  });
57
57
  }));
58
58
  };
@@ -74,7 +74,11 @@ ActionBarOverflowItems.propTypes = {
74
74
  /**
75
75
  * overflowItems: items to bre shown in the ActionBar overflow menu
76
76
  */
77
- overflowItems: index["default"].arrayOf(index["default"].element)
77
+ overflowItems: index["default"].arrayOf(index["default"].element),
78
+ /**
79
+ * Optional tab index
80
+ */
81
+ tabIndex: index["default"].number
78
82
  };
79
83
 
80
84
  exports.ActionBarOverflowItems = 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>;
@@ -61,7 +61,8 @@ var ConditionBlock = function ConditionBlock(props) {
61
61
  showConditionSubGroupPreviewHandler = props.showConditionSubGroupPreviewHandler,
62
62
  hideConditionPreviewHandler = props.hideConditionPreviewHandler,
63
63
  showConditionPreviewHandler = props.showConditionPreviewHandler,
64
- isLastCondition = props.isLastCondition;
64
+ isLastCondition = props.isLastCondition,
65
+ setShowDeletionPreviewForSubgroups = props.setShowDeletionPreviewForSubgroups;
65
66
  var _useContext = React.useContext(ConditionBuilderProvider.ConditionBuilderContext),
66
67
  inputConfig = _useContext.inputConfig,
67
68
  variant = _useContext.variant,
@@ -102,6 +103,15 @@ var ConditionBlock = function ConditionBlock(props) {
102
103
  textarea: ConditionBuilderItemText.ConditionBuilderItemText
103
104
  };
104
105
  var ItemComponent = property ? itemComponents[type] : null;
106
+ React.useEffect(function () {
107
+ var _group$conditions, _group$conditions2;
108
+ 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) {
109
+ setShowDeletionPreviewForSubgroups === null || setShowDeletionPreviewForSubgroups === void 0 || setShowDeletionPreviewForSubgroups(true);
110
+ } else {
111
+ setShowDeletionPreviewForSubgroups === null || setShowDeletionPreviewForSubgroups === void 0 || setShowDeletionPreviewForSubgroups(false);
112
+ }
113
+ // eslint-disable-next-line react-hooks/exhaustive-deps
114
+ }, [showDeletionPreview]);
105
115
  var onStatementChangeHandler = function onStatementChangeHandler(v, evt) {
106
116
  util.focusThisField(evt, conditionBuilderRef);
107
117
  onStatementChange(v);
@@ -121,10 +131,9 @@ var ConditionBlock = function ConditionBlock(props) {
121
131
  popoverToOpen: util.checkIsValid(newOperator) ? 'valueField' : ''
122
132
  }));
123
133
  };
124
- var onValueChangeHandler = function onValueChangeHandler(newValue, evt) {
134
+ var onValueChangeHandler = function onValueChangeHandler(newValue) {
125
135
  var currentCondition = _rollupPluginBabelHelpers.objectSpread2({}, condition);
126
136
  delete currentCondition.popoverToOpen;
127
- util.focusThisField(evt, conditionBuilderRef);
128
137
  onChange(_rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, currentCondition), {}, {
129
138
  value: newValue
130
139
  }));
@@ -317,6 +326,10 @@ ConditionBlock.propTypes = {
317
326
  * callback to handle the statement(if/ excl.if) change
318
327
  */
319
328
  onStatementChange: index["default"].func,
329
+ /**
330
+ * method to set ShowDeletionPreviewForSubgroups
331
+ */
332
+ setShowDeletionPreviewForSubgroups: index["default"].func,
320
333
  /**
321
334
  * handler for showing add condition preview
322
335
  */
@@ -96,11 +96,11 @@ var ConditionBuilderAdd = function ConditionBuilderAdd(_ref) {
96
96
  })), enableSubGroup && /*#__PURE__*/React__default["default"].createElement(ConditionBuilderButton.ConditionBuilderButton, _rollupPluginBabelHelpers["extends"]({
97
97
  renderIcon: icons.TextNewLine,
98
98
  onClick: addConditionSubGroupHandler,
99
- className: cx__default["default"]("".concat(DataConfigs.blockClass, "__add-condition-sub-group ").concat(DataConfigs.blockClass, "__gap-left")),
99
+ className: cx__default["default"]("".concat(DataConfigs.blockClass, "__add-condition-sub-group")),
100
100
  hideLabel: true,
101
101
  label: addSubgroupText,
102
102
  wrapperProps: wrapperProps,
103
- wrapperClassName: cx__default["default"]("".concat(DataConfigs.blockClass, "__add-condition-sub-group-wrapper"), _rollupPluginBabelHelpers.defineProperty({}, "".concat(DataConfigs.blockClass, "__add-condition-sub-group-wrapper--show"), isAddSubgroup))
103
+ wrapperClassName: cx__default["default"]("".concat(DataConfigs.blockClass, "__add-condition-sub-group-wrapper ").concat(DataConfigs.blockClass, "__gap-left"), _rollupPluginBabelHelpers.defineProperty({}, "".concat(DataConfigs.blockClass, "__add-condition-sub-group-wrapper--show"), isAddSubgroup))
104
104
  }, previewHandlersForSubgroup())));
105
105
  };
106
106
  var ConditionBuilderAdd$1 = ConditionBuilderAdd;
@@ -42,11 +42,11 @@ var ConditionBuilderButton = function ConditionBuilderButton(_ref) {
42
42
  wrapperClassName = _ref.wrapperClassName,
43
43
  tabIndex = _ref.tabIndex,
44
44
  rest = _rollupPluginBabelHelpers.objectWithoutProperties(_ref, _excluded);
45
+ var carbonPrefix = react.usePrefix();
45
46
  var Button = function Button() {
46
47
  var _rest$dataName;
47
48
  var dataName = (_rest$dataName = rest['data-name']) !== null && _rest$dataName !== void 0 ? _rest$dataName : '';
48
49
  return /*#__PURE__*/React__default["default"].createElement("button", _rollupPluginBabelHelpers["extends"]({
49
- // role={'gridcell'}
50
50
  tabIndex: tabIndex != undefined ? tabIndex : -1,
51
51
  className: cx__default["default"]([className, "".concat(DataConfigs.blockClass, "__button"), _rollupPluginBabelHelpers.defineProperty({}, "".concat(DataConfigs.blockClass, "__text-ellipsis"), showToolTip && !hideLabel && !isInvalid), _rollupPluginBabelHelpers.defineProperty({}, "".concat(DataConfigs.blockClass, "__invalid-input"), isInvalid)]),
52
52
  type: "button",
@@ -61,8 +61,10 @@ var ConditionBuilderButton = function ConditionBuilderButton(_ref) {
61
61
  return hideLabel || showToolTip ? /*#__PURE__*/React__default["default"].createElement(react.Tooltip, _rollupPluginBabelHelpers["extends"]({
62
62
  label: label,
63
63
  align: tooltipAlign,
64
- className: "".concat(wrapperClassName)
65
- }, wrapperProps), Button()) : /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, Button());
64
+ className: "".concat(wrapperClassName, " ").concat(DataConfigs.blockClass, "__tooltip ").concat(carbonPrefix, "--icon-tooltip")
65
+ }, wrapperProps, {
66
+ leaveDelayMs: 0
67
+ }), Button()) : /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, Button());
66
68
  };
67
69
  ConditionBuilderButton.propTypes = {
68
70
  /**
@@ -18,6 +18,7 @@ var index = require('../../../node_modules/prop-types/index.js');
18
18
  var util = require('../utils/util.js');
19
19
  var ConditionBuilderProvider = require('../ConditionBuilderContext/ConditionBuilderProvider.js');
20
20
  var useTranslations = require('../utils/useTranslations.js');
21
+ var ConditionBuilderButton = require('../ConditionBuilderButton/ConditionBuilderButton.js');
21
22
 
22
23
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
23
24
 
@@ -56,7 +57,9 @@ var ConditionConnector = function ConditionConnector(_ref) {
56
57
  };
57
58
  return variant == 'tree' ? /*#__PURE__*/React__default["default"].createElement("span", {
58
59
  className: "".concat(className, " ").concat(DataConfigs.blockClass, "__connector--disabled")
59
- }, operator) :
60
+ }, /*#__PURE__*/React__default["default"].createElement(ConditionBuilderButton.ConditionBuilderButton, {
61
+ label: operator
62
+ })) :
60
63
  /*#__PURE__*/
61
64
  // <div className={className} {...rest}>
62
65
  React__default["default"].createElement(ConditionBuilderItem.ConditionBuilderItem, _rollupPluginBabelHelpers["extends"]({
@@ -30,7 +30,7 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
30
30
 
31
31
  var _GroupConnector;
32
32
  var ConditionBuilderContent = function ConditionBuilderContent(_ref) {
33
- var _rootState$groups2;
33
+ var _rootState$groups3;
34
34
  var startConditionLabel = _ref.startConditionLabel,
35
35
  getConditionState = _ref.getConditionState,
36
36
  getActionsState = _ref.getActionsState,
@@ -118,6 +118,11 @@ var ConditionBuilderContent = function ConditionBuilderContent(_ref) {
118
118
  groups: [].concat(_rollupPluginBabelHelpers.toConsumableArray(rootState.groups), [newGroup])
119
119
  }));
120
120
  };
121
+ var getColorIndex = function getColorIndex() {
122
+ var _rootState$groups$len, _rootState$groups2;
123
+ 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;
124
+ return groupLength % 5;
125
+ };
121
126
  if (!isConditionBuilderActive) {
122
127
  return /*#__PURE__*/React__default["default"].createElement(react.Button, {
123
128
  className: "".concat(DataConfigs.blockClass, "__addConditionText-button"),
@@ -137,7 +142,7 @@ var ConditionBuilderContent = function ConditionBuilderContent(_ref) {
137
142
  className: "".concat(DataConfigs.blockClass, "__content-container"),
138
143
  role: "treegrid",
139
144
  "aria-label": "condition builder tree"
140
- }, rootState && (rootState === null || rootState === void 0 || (_rootState$groups2 = rootState.groups) === null || _rootState$groups2 === void 0 ? void 0 : _rootState$groups2.map(function (eachGroup, groupIndex) {
145
+ }, rootState && (rootState === null || rootState === void 0 || (_rootState$groups3 = rootState.groups) === null || _rootState$groups3 === void 0 ? void 0 : _rootState$groups3.map(function (eachGroup, groupIndex) {
141
146
  return /*#__PURE__*/React__default["default"].createElement("div", {
142
147
  key: eachGroup.id,
143
148
  className: "".concat(DataConfigs.blockClass, "__group-wrapper")
@@ -177,6 +182,7 @@ var ConditionBuilderContent = function ConditionBuilderContent(_ref) {
177
182
  }
178
183
  })), showConditionGroupPreview && /*#__PURE__*/React__default["default"].createElement(ConditionPreview["default"], {
179
184
  previewType: "newGroup",
185
+ colorIndex: getColorIndex(),
180
186
  group: {
181
187
  groupOperator: rootState.operator
182
188
  }
@@ -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
  }
@@ -36,7 +36,7 @@ var translationsObject = {
36
36
  connectorText: 'Connector',
37
37
  conditionRowText: 'Condition row',
38
38
  conditionRowGroupText: 'Condition row group',
39
- removeConditionText: 'Remove condition',
39
+ removeConditionText: 'Delete condition',
40
40
  addConditionRowText: 'Add condition row',
41
41
  startText: 'Start',
42
42
  endText: 'End',
@@ -49,7 +49,10 @@ var translationsObject = {
49
49
  invalidNumberWarnText: 'Invalid number, must be 0 or greater',
50
50
  conditionBuilderText: 'Condition Builder',
51
51
  actionSectionText: 'Action Section',
52
- conditionHeadingText: 'Condition'
52
+ conditionHeadingText: 'Condition',
53
+ addPropertyText: 'Add property',
54
+ addOperatorText: 'Add operator',
55
+ addValueText: 'Add value'
53
56
  };
54
57
 
55
58
  exports.translationsObject = translationsObject;