@carbon/ibm-products 2.43.2-canary.80 → 2.43.2-canary.83

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/css/index-full-carbon.css +11 -2
  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 +11 -2
  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 +11 -2
  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.js +20 -14
  14. package/es/components/ConditionBuilder/ConditionBuilder.js +3 -3
  15. package/es/components/ConditionBuilder/ConditionBuilderActions/ConditionBuilderActions.js +8 -5
  16. package/es/components/ConditionBuilder/ConditionBuilderAdd/ConditionBuilderAdd.js +4 -2
  17. package/es/components/ConditionBuilder/ConditionBuilderButton/ConditionBuilderButton.js +2 -2
  18. package/es/components/ConditionBuilder/ConditionBuilderConnector/ConditionConnector.js +4 -3
  19. package/es/components/ConditionBuilder/ConditionBuilderContent/ConditionBuilderContent.d.ts +1 -3
  20. package/es/components/ConditionBuilder/ConditionBuilderContent/ConditionBuilderContent.js +26 -30
  21. package/es/components/ConditionBuilder/ConditionBuilderContext/ConditionBuilderProvider.d.ts +1 -0
  22. package/es/components/ConditionBuilder/ConditionBuilderContext/ConditionBuilderProvider.js +6 -1
  23. package/es/components/ConditionBuilder/ConditionBuilderContext/translationObject.d.ts +4 -1
  24. package/es/components/ConditionBuilder/ConditionBuilderContext/translationObject.js +5 -2
  25. package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItem.d.ts +3 -1
  26. package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItem.js +47 -23
  27. package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemDate/ConditionBuilderItemDate.js +1 -1
  28. package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemNumber/ConditionBuilderItemNumber.js +3 -3
  29. package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemOption/ItemOptionForValueField.js +6 -3
  30. package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemText/ConditionBuilderItemText.js +3 -2
  31. package/es/components/ConditionBuilder/ConditionGroupBuilder/ConditionGroupBuilder.d.ts +1 -3
  32. package/es/components/ConditionBuilder/ConditionGroupBuilder/ConditionGroupBuilder.js +62 -32
  33. package/es/components/ConditionBuilder/utils/handleKeyboardEvents.d.ts +1 -0
  34. package/es/components/ConditionBuilder/utils/handleKeyboardEvents.js +52 -46
  35. package/es/components/ConditionBuilder/utils/util.d.ts +6 -5
  36. package/es/components/ConditionBuilder/utils/util.js +35 -17
  37. package/lib/components/ConditionBuilder/ConditionBlock/ConditionBlock.js +19 -13
  38. package/lib/components/ConditionBuilder/ConditionBuilder.js +3 -3
  39. package/lib/components/ConditionBuilder/ConditionBuilderActions/ConditionBuilderActions.js +8 -5
  40. package/lib/components/ConditionBuilder/ConditionBuilderAdd/ConditionBuilderAdd.js +4 -2
  41. package/lib/components/ConditionBuilder/ConditionBuilderButton/ConditionBuilderButton.js +2 -2
  42. package/lib/components/ConditionBuilder/ConditionBuilderConnector/ConditionConnector.js +4 -3
  43. package/lib/components/ConditionBuilder/ConditionBuilderContent/ConditionBuilderContent.d.ts +1 -3
  44. package/lib/components/ConditionBuilder/ConditionBuilderContent/ConditionBuilderContent.js +25 -29
  45. package/lib/components/ConditionBuilder/ConditionBuilderContext/ConditionBuilderProvider.d.ts +1 -0
  46. package/lib/components/ConditionBuilder/ConditionBuilderContext/ConditionBuilderProvider.js +6 -1
  47. package/lib/components/ConditionBuilder/ConditionBuilderContext/translationObject.d.ts +4 -1
  48. package/lib/components/ConditionBuilder/ConditionBuilderContext/translationObject.js +5 -2
  49. package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItem.d.ts +3 -1
  50. package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItem.js +46 -22
  51. package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemDate/ConditionBuilderItemDate.js +1 -1
  52. package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemNumber/ConditionBuilderItemNumber.js +3 -3
  53. package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemOption/ItemOptionForValueField.js +6 -3
  54. package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemText/ConditionBuilderItemText.js +3 -2
  55. package/lib/components/ConditionBuilder/ConditionGroupBuilder/ConditionGroupBuilder.d.ts +1 -3
  56. package/lib/components/ConditionBuilder/ConditionGroupBuilder/ConditionGroupBuilder.js +61 -31
  57. package/lib/components/ConditionBuilder/utils/handleKeyboardEvents.d.ts +1 -0
  58. package/lib/components/ConditionBuilder/utils/handleKeyboardEvents.js +51 -44
  59. package/lib/components/ConditionBuilder/utils/util.d.ts +6 -5
  60. package/lib/components/ConditionBuilder/utils/util.js +36 -16
  61. package/package.json +2 -2
  62. package/scss/components/ConditionBuilder/_condition-builder.scss +4 -0
  63. package/scss/components/ConditionBuilder/styles/_conditionBuilderCondition.scss +6 -1
  64. package/scss/components/ConditionBuilder/styles/_conditionBuilderItem.scss +1 -1
@@ -121,14 +121,17 @@ var ItemOptionForValueField = function ItemOptionForValueField(_ref) {
121
121
  setSearchValue(value);
122
122
  };
123
123
  var onClickHandler = function onClickHandler(evt, option, isSelected) {
124
+ var updatedSelections = selection.filter(function (item) {
125
+ return item !== 'INVALID';
126
+ });
124
127
  if (multiSelectable) {
125
128
  if (isSelected) {
126
- var items = selection.filter(function (v) {
129
+ var items = updatedSelections.filter(function (v) {
127
130
  return v.id !== option.id;
128
131
  });
129
- onChange(items.length > 0 ? items : undefined, evt);
132
+ onChange(items.length > 0 ? items : undefined);
130
133
  } else {
131
- onChange([].concat(_rollupPluginBabelHelpers.toConsumableArray(selection), [option]), evt);
134
+ onChange([].concat(_rollupPluginBabelHelpers.toConsumableArray(updatedSelections), [option]));
132
135
  }
133
136
  } else {
134
137
  onChange(option, evt);
@@ -14,13 +14,14 @@ var React = require('react');
14
14
  var react = require('@carbon/react');
15
15
  var index = require('../../../../node_modules/prop-types/index.js');
16
16
  var DataConfigs = require('../../ConditionBuilderContext/DataConfigs.js');
17
+ var util = require('../../utils/util.js');
17
18
 
18
19
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
19
20
 
20
21
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
21
22
 
22
23
  var ConditionBuilderItemText = function ConditionBuilderItemText(_ref) {
23
- var _conditionState$value, _conditionState$prope;
24
+ var _conditionState$prope;
24
25
  var conditionState = _ref.conditionState,
25
26
  _onChange = _ref.onChange,
26
27
  config = _ref.config,
@@ -28,7 +29,7 @@ var ConditionBuilderItemText = function ConditionBuilderItemText(_ref) {
28
29
  var inputProps = _rollupPluginBabelHelpers.objectSpread2({
29
30
  labelText: conditionState.property,
30
31
  hideLabel: true,
31
- value: (_conditionState$value = conditionState.value) !== null && _conditionState$value !== void 0 ? _conditionState$value : '',
32
+ value: util.checkIsValid(conditionState.value) ? conditionState.value : '',
32
33
  id: (_conditionState$prope = conditionState.property) === null || _conditionState$prope === void 0 ? void 0 : _conditionState$prope.replace(/\s/g, ''),
33
34
  onChange: function onChange(evt) {
34
35
  _onChange(evt.target.value);
@@ -5,19 +5,17 @@ export default ConditionGroupBuilder;
5
5
  * All the inner components of group are called from here.
6
6
  * @returns
7
7
  */
8
- declare function ConditionGroupBuilder({ group, aria, onRemove, onChange, conditionBuilderRef, className, }: {
8
+ declare function ConditionGroupBuilder({ group, aria, onRemove, onChange, className, }: {
9
9
  group: any;
10
10
  aria: any;
11
11
  onRemove: any;
12
12
  onChange: any;
13
- conditionBuilderRef: any;
14
13
  className: any;
15
14
  }): import("react/jsx-runtime").JSX.Element;
16
15
  declare namespace ConditionGroupBuilder {
17
16
  namespace propTypes {
18
17
  let aria: PropTypes.Requireable<object>;
19
18
  let className: PropTypes.Requireable<string>;
20
- let conditionBuilderRef: PropTypes.Requireable<object>;
21
19
  let group: PropTypes.Requireable<object>;
22
20
  let onChange: PropTypes.Requireable<(...args: any[]) => any>;
23
21
  let onRemove: PropTypes.Requireable<(...args: any[]) => any>;
@@ -42,14 +42,15 @@ var ConditionGroupBuilder = function ConditionGroupBuilder(_ref) {
42
42
  aria = _ref.aria,
43
43
  onRemove = _ref.onRemove,
44
44
  onChange = _ref.onChange,
45
- conditionBuilderRef = _ref.conditionBuilderRef,
46
45
  className = _ref.className;
47
- var _useTranslations = useTranslations.useTranslations(['condition_builder_group', 'conditionText']),
48
- _useTranslations2 = _rollupPluginBabelHelpers.slicedToArray(_useTranslations, 2),
46
+ var _useTranslations = useTranslations.useTranslations(['conditionBuilderGroupText', 'conditionText', 'conditionBuilderText']),
47
+ _useTranslations2 = _rollupPluginBabelHelpers.slicedToArray(_useTranslations, 3),
49
48
  conditionBuilderGroupText = _useTranslations2[0],
50
- conditionText = _useTranslations2[1];
49
+ conditionText = _useTranslations2[1],
50
+ conditionBuilderText = _useTranslations2[2];
51
51
  var _useContext = React.useContext(ConditionBuilderProvider.ConditionBuilderContext),
52
- variant = _useContext.variant;
52
+ variant = _useContext.variant,
53
+ conditionBuilderRef = _useContext.conditionBuilderRef;
53
54
  var _useState = React.useState(-1),
54
55
  _useState2 = _rollupPluginBabelHelpers.slicedToArray(_useState, 2),
55
56
  showConditionPreview = _useState2[0],
@@ -62,11 +63,42 @@ var ConditionGroupBuilder = function ConditionGroupBuilder(_ref) {
62
63
  var onRemoveHandler = function onRemoveHandler(conditionId, evt, conditionIndex) {
63
64
  if (group.conditions.length > 1) {
64
65
  variant == 'tree' ? handleFocusOnCloseTree(evt) : handleFocusOnClose(evt, conditionIndex);
65
- onChange(_rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, group), {}, {
66
- conditions: group.conditions.filter(function (condition) {
67
- return conditionId !== condition.id;
68
- })
69
- }));
66
+ if (group.conditions[1].conditions && group.conditions[1].id !== conditionId) {
67
+ //when we remove every plain conditions of a group without deleting the subgroup, we need to restructure the group
68
+ //the inner group become outer group and same level subgroups become plain conditions
69
+
70
+ //ensure we are deleting last condition , not the subgroup
71
+
72
+ //spreading out the condition inside the subgroup
73
+ var allConditions = group.conditions.reduce(function (acc, item) {
74
+ if (item.conditions) {
75
+ return acc.concat(item.conditions);
76
+ }
77
+ return acc;
78
+ }, []);
79
+
80
+ //we always have conditions first and then subgroups, so ordering accordingly
81
+ var groupedItems = {
82
+ groups: [],
83
+ conditions: []
84
+ };
85
+ allConditions.forEach(function (item) {
86
+ if (item.conditions) {
87
+ groupedItems.groups.push(item);
88
+ } else {
89
+ groupedItems.conditions.push(item);
90
+ }
91
+ });
92
+ onChange(_rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, group), {}, {
93
+ conditions: [].concat(_rollupPluginBabelHelpers.toConsumableArray(groupedItems.conditions), _rollupPluginBabelHelpers.toConsumableArray(groupedItems.groups))
94
+ }));
95
+ } else {
96
+ onChange(_rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, group), {}, {
97
+ conditions: group.conditions.filter(function (condition) {
98
+ return conditionId !== condition.id;
99
+ })
100
+ }));
101
+ }
70
102
  } else {
71
103
  onRemove(evt);
72
104
  }
@@ -96,11 +128,9 @@ var ConditionGroupBuilder = function ConditionGroupBuilder(_ref) {
96
128
  //or focus the next one.
97
129
  var currentGroupCloseButtons = (_e$currentTarget$clos = e.currentTarget.closest(".".concat(DataConfigs.blockClass, "__group"))) === null || _e$currentTarget$clos === void 0 ? void 0 : _e$currentTarget$clos.querySelectorAll('[data-name="closeCondition"]');
98
130
  if (conditionIndex == currentGroupCloseButtons.length - 1) {
99
- var _currentGroupCloseBut;
100
- (_currentGroupCloseBut = currentGroupCloseButtons[conditionIndex - 1]) === null || _currentGroupCloseBut === void 0 || _currentGroupCloseBut.focus();
131
+ util.manageTabIndexAndFocus(currentGroupCloseButtons[conditionIndex - 1], conditionBuilderRef);
101
132
  } else {
102
- var _currentGroupCloseBut2;
103
- (_currentGroupCloseBut2 = currentGroupCloseButtons[conditionIndex + 1]) === null || _currentGroupCloseBut2 === void 0 || _currentGroupCloseBut2.focus();
133
+ util.manageTabIndexAndFocus(currentGroupCloseButtons[conditionIndex + 1], conditionBuilderRef);
104
134
  }
105
135
  };
106
136
  var handleFocusOnCloseTree = function handleFocusOnCloseTree(evt) {
@@ -116,11 +146,9 @@ var ConditionGroupBuilder = function ConditionGroupBuilder(_ref) {
116
146
  //Otherwise , check the previous item is a valid condition
117
147
 
118
148
  if (nextElement !== null && nextElement !== void 0 && nextElement.classList.contains("".concat(DataConfigs.blockClass, "__condition-block"))) {
119
- var _nextElement$querySel;
120
- nextElement === null || nextElement === void 0 || (_nextElement$querySel = nextElement.querySelector('[data-name="closeCondition"]')) === null || _nextElement$querySel === void 0 || _nextElement$querySel.focus();
149
+ util.manageTabIndexAndFocus(nextElement === null || nextElement === void 0 ? void 0 : nextElement.querySelector('[data-name="closeCondition"]'), conditionBuilderRef);
121
150
  } else if (prevElement !== null && prevElement !== void 0 && prevElement.classList.contains("".concat(DataConfigs.blockClass, "__condition-block"))) {
122
- var _prevElement$querySel;
123
- prevElement === null || prevElement === void 0 || (_prevElement$querySel = prevElement.querySelector('[data-name="closeCondition"]')) === null || _prevElement$querySel === void 0 || _prevElement$querySel.focus();
151
+ util.manageTabIndexAndFocus(prevElement === null || prevElement === void 0 ? void 0 : prevElement.querySelector('[data-name="closeCondition"]'), conditionBuilderRef);
124
152
  }
125
153
  //If there are no valid condition in this group, focus next or previous row
126
154
  else {
@@ -128,10 +156,18 @@ var ConditionGroupBuilder = function ConditionGroupBuilder(_ref) {
128
156
  var prevRows = (_conditionBuilderCont3 = conditionBuilderContentRef.current) === null || _conditionBuilderCont3 === void 0 ? void 0 : _conditionBuilderCont3.querySelectorAll("[aria-level=\"".concat(Number(currentLevel) - 1, "\"][role=\"row\"]"));
129
157
  var nextRow = (_conditionBuilderCont4 = conditionBuilderContentRef.current) === null || _conditionBuilderCont4 === void 0 ? void 0 : _conditionBuilderCont4.querySelector("[aria-level=\"".concat(Number(currentLevel) + 1, "\"][role=\"row\"]"));
130
158
  if (nextRow) {
131
- nextRow === null || nextRow === void 0 || nextRow.focus();
159
+ //since there are no condition in current group, this group will move one level up
160
+
161
+ var rowIdentity = {
162
+ ariaLevel: Number(nextRow.ariaLevel) - 1,
163
+ ariaPosInSet: nextRow.ariaPosInSet
164
+ };
165
+ setTimeout(function () {
166
+ var currentRowToFocus = conditionBuilderContentRef.current.querySelector("[role=\"row\"][aria-level=\"".concat(rowIdentity.ariaLevel, "\"][aria-posinset=\"").concat(rowIdentity.ariaPosInSet, "\"]"));
167
+ util.manageTabIndexAndFocus(currentRowToFocus, conditionBuilderRef);
168
+ }, 0);
132
169
  } else if ((prevRows === null || prevRows === void 0 ? void 0 : prevRows.length) > 1) {
133
- var _prevRows;
134
- (_prevRows = prevRows[prevRows.length - 2]) === null || _prevRows === void 0 || _prevRows.focus();
170
+ util.manageTabIndexAndFocus(prevRows[prevRows.length - 2], conditionBuilderRef);
135
171
  }
136
172
  }
137
173
  };
@@ -188,7 +224,7 @@ var ConditionGroupBuilder = function ConditionGroupBuilder(_ref) {
188
224
  }, /*#__PURE__*/React__default["default"].createElement("div", {
189
225
  className: "".concat(DataConfigs.blockClass, "__condition-wrapper"),
190
226
  role: "grid",
191
- "aria-label": conditionBuilderGroupText
227
+ "aria-label": conditionBuilderText
192
228
  }, group === null || group === void 0 || (_group$conditions = group.conditions) === null || _group$conditions === void 0 ? void 0 : _group$conditions.map(function (eachCondition, conditionIndex) {
193
229
  return /*#__PURE__*/React__default["default"].createElement("div", {
194
230
  key: eachCondition.id,
@@ -242,7 +278,7 @@ var ConditionGroupBuilder = function ConditionGroupBuilder(_ref) {
242
278
  label: conditionText
243
279
  },
244
280
  onChange: function onChange(v, evt) {
245
- util.focusThisField(evt);
281
+ util.focusThisField(evt, conditionBuilderRef);
246
282
  onStatementChangeHandler(v);
247
283
  },
248
284
  config: {
@@ -254,7 +290,7 @@ var ConditionGroupBuilder = function ConditionGroupBuilder(_ref) {
254
290
  }, eachCondition.conditions ? /*#__PURE__*/React__default["default"].createElement("div", {
255
291
  className: cx__default["default"]("".concat(DataConfigs.blockClass, "__condition-block subgroup ").concat(DataConfigs.blockClass, "__gap"), _rollupPluginBabelHelpers.defineProperty({}, "".concat(DataConfigs.blockClass, "__gap-bottom"), group.conditions.length < conditionIndex + 1))
256
292
  }, /*#__PURE__*/React__default["default"].createElement(ConditionConnector["default"], {
257
- className: "".concat(DataConfigs.blockClass, "__gap ").concat(DataConfigs.blockClass, "__groupConnector"),
293
+ className: "".concat(DataConfigs.blockClass, "__gap ").concat(DataConfigs.blockClass, "__gap-bottom ").concat(DataConfigs.blockClass, "__groupConnector"),
258
294
  operator: group.groupOperator,
259
295
  "aria-hidden": true
260
296
  }), /*#__PURE__*/React__default["default"].createElement(ConditionGroupBuilder, {
@@ -270,8 +306,7 @@ var ConditionGroupBuilder = function ConditionGroupBuilder(_ref) {
270
306
  },
271
307
  onRemove: function onRemove(e) {
272
308
  onRemoveHandler(eachCondition.id, e);
273
- },
274
- conditionBuilderRef: conditionBuilderRef
309
+ }
275
310
  })) : /*#__PURE__*/React__default["default"].createElement("div", null, /*#__PURE__*/React__default["default"].createElement(ConditionBlock["default"], {
276
311
  conjunction: conditionIndex > 0 ? group.groupOperator : undefined,
277
312
  aria: {
@@ -326,11 +361,6 @@ ConditionGroupBuilder.propTypes = {
326
361
  * Provide an optional class to be applied to the containing node.
327
362
  */
328
363
  className: index["default"].string,
329
- /**
330
- className: PropTypes.string,
331
- * ref of condition builder
332
- */
333
- conditionBuilderRef: index["default"].object,
334
364
  group: index["default"].object,
335
365
  /**
336
366
  * callback to update the current condition of the state tree
@@ -1 +1,2 @@
1
1
  export function handleKeyDown(evt: any, conditionBuilderRef: any, variant: any): void;
2
+ export function handleKeyDownForPopover(evt: any, conditionBuilderRef: any, popoverRef: any): void;
@@ -14,22 +14,24 @@ var DataConfigs = require('../ConditionBuilderContext/DataConfigs.js');
14
14
  var util = require('./util.js');
15
15
 
16
16
  var handleKeyDown = function handleKeyDown(evt, conditionBuilderRef, variant) {
17
+ var _activeElement$closes;
17
18
  var activeElement = document.activeElement;
19
+ if (!((_activeElement$closes = activeElement.closest(".".concat(DataConfigs.blockClass, "__popover"))) !== null && _activeElement$closes !== void 0 && _activeElement$closes.querySelector('[role="dialog"]'))) {
20
+ handleKeyPressForMainContent(evt, conditionBuilderRef, variant);
21
+ }
22
+ };
23
+ var handleKeyDownForPopover = function handleKeyDownForPopover(evt, conditionBuilderRef, popoverRef) {
18
24
  if (excludeKeyPress(evt)) {
19
25
  return;
20
26
  }
21
- if (activeElement.closest("[role=\"dialog\"]")) {
22
- handleKeyPressForPopover(evt, activeElement.closest("[role=\"dialog\"]"));
23
- } else {
24
- handleKeyPressForMainContent(evt, conditionBuilderRef, variant);
25
- }
27
+ handleKeyPressForPopover(evt, popoverRef === null || popoverRef === void 0 ? void 0 : popoverRef.current, conditionBuilderRef);
26
28
  };
29
+
27
30
  //skipping keyboard handling for date and time fields to get take carbon's
28
31
  var excludeKeyPress = function excludeKeyPress(evt) {
29
- var _evt$target$closest, _evt$target$closest2;
30
- return !['Escape'].includes(evt.key) && (((_evt$target$closest = evt.target.closest(".".concat(DataConfigs.blockClass, "__item-date"))) === null || _evt$target$closest === void 0 ? void 0 : _evt$target$closest.length) || ((_evt$target$closest2 = evt.target.closest(".".concat(DataConfigs.blockClass, "__item-time"))) === null || _evt$target$closest2 === void 0 ? void 0 : _evt$target$closest2.length));
32
+ return !['Escape'].includes(evt.key) && (evt.target.closest(".".concat(DataConfigs.blockClass, "__item-date")) || evt.target.closest(".".concat(DataConfigs.blockClass, "__item-time")));
31
33
  };
32
- var handleKeyPressForPopover = function handleKeyPressForPopover(evt, parentContainer) {
34
+ var handleKeyPressForPopover = function handleKeyPressForPopover(evt, parentContainer, conditionBuilderRef) {
33
35
  var _parentContainer$quer;
34
36
  var key = evt.key;
35
37
  var isHoldingShiftKey = util.checkForHoldingKey(evt, 'shiftKey');
@@ -39,22 +41,22 @@ var handleKeyPressForPopover = function handleKeyPressForPopover(evt, parentCont
39
41
  case 'ArrowUp':
40
42
  //traverse through the popover options, search box, selectAll button
41
43
  parentContainer.querySelectorAll("[role=\"option\"]").forEach(function (eachElem, index, allElements) {
42
- util.traverseReverse(eachElem, index, allElements);
44
+ util.traverseReverse(eachElem, index, allElements, null, null, conditionBuilderRef);
43
45
  });
44
46
  break;
45
47
  case 'ArrowDown':
46
48
  //traverse through the popover options, search box, selectAll button
47
49
  parentContainer.querySelectorAll("[role=\"option\"]").forEach(function (eachElem, index, allElements) {
48
- util.traverseClockVise(eachElem, index, allElements);
50
+ util.traverseClockVise(eachElem, index, allElements, null, null, conditionBuilderRef);
49
51
  });
50
52
  break;
51
53
  case 'Tab':
52
54
  allItems = [].concat(_rollupPluginBabelHelpers.toConsumableArray(Array.from(parentContainer.querySelectorAll(".".concat(DataConfigs.blockClass, "__selectAll-button,[role=\"searchbox\"]")))), [parentContainer.querySelector("[role=\"option\"]")]);
53
55
  allItems.forEach(function (eachElem, index, allElements) {
54
56
  if (isHoldingShiftKey) {
55
- util.traverseReverse(eachElem, index, allElements, true, true);
57
+ util.traverseReverse(eachElem, index, allElements, true, true, conditionBuilderRef);
56
58
  } else {
57
- util.traverseClockVise(eachElem, index, allElements, true, true);
59
+ util.traverseClockVise(eachElem, index, allElements, true, true, conditionBuilderRef);
58
60
  }
59
61
  });
60
62
  evt.preventDefault();
@@ -74,40 +76,41 @@ var handleKeyPressForPopover = function handleKeyPressForPopover(evt, parentCont
74
76
  if (document.activeElement.type !== 'button') {
75
77
  var _document$activeEleme2;
76
78
  //for button , enter key is click which already handled by framework, else trigger click
77
- util.focusThisField(evt);
79
+ util.focusThisField(evt, conditionBuilderRef);
78
80
  (_document$activeEleme2 = document.activeElement) === null || _document$activeEleme2 === void 0 || _document$activeEleme2.click();
79
81
  }
80
82
  }
81
83
  break;
82
84
  case 'Escape':
83
- //focus the corresponding field in which the popover is triggered
84
- util.focusThisField(evt);
85
+ //focus the corresponding field in which the popover is triggered\
86
+ util.focusThisField(evt, conditionBuilderRef);
85
87
  break;
86
88
  }
87
89
  };
88
90
  var handleKeyPressForMainContent = function handleKeyPressForMainContent(evt, conditionBuilderRef, variant) {
91
+ var _document$activeEleme3;
89
92
  switch (evt.key) {
90
93
  case 'ArrowRight':
91
94
  evt.preventDefault();
92
95
  if (variant == 'tree') {
93
- var _evt$target$closest3;
94
- var allCellsInRow = Array.from((_evt$target$closest3 = evt.target.closest('[role="row"]')) === null || _evt$target$closest3 === void 0 ? void 0 : _evt$target$closest3.querySelectorAll('[role="gridcell"] button'));
95
- if (evt.target.getAttribute('role') == 'row') {
96
+ var _evt$target$closest;
97
+ var allCellsInRow = Array.from((_evt$target$closest = evt.target.closest('[role="row"]')) === null || _evt$target$closest === void 0 ? void 0 : _evt$target$closest.querySelectorAll('[role="gridcell"] button'));
98
+ if (allCellsInRow.length === 1) {
99
+ evt.target = evt.target.closest('[role="row"]');
100
+ handleRowNavigationTree(evt, conditionBuilderRef, variant);
101
+ //focus next row
102
+ } else if (evt.target.getAttribute('role') == 'row') {
96
103
  //when current focus is on a row, then we need to enter inside and focus the first cell of that row
97
- if (allCellsInRow.length === 1) {
98
- handleRowNavigationTree(evt, conditionBuilderRef, variant);
99
- //focus next row
100
- } else {
101
- var _allCellsInRow$;
102
- (_allCellsInRow$ = allCellsInRow[0]) === null || _allCellsInRow$ === void 0 || _allCellsInRow$.focus();
103
- }
104
+
105
+ //focus first cell
106
+ util.manageTabIndexAndFocus(allCellsInRow[0], conditionBuilderRef);
104
107
  } else {
105
108
  //finding the next cell to be focussed
106
109
  //next cell = current cell index + 1
107
110
 
108
111
  var currentItemIndex = allCellsInRow.indexOf(evt.target);
109
112
  if (currentItemIndex < allCellsInRow.length - 1) {
110
- util.focusThisItem(allCellsInRow[currentItemIndex + 1]);
113
+ util.focusThisItem(allCellsInRow[currentItemIndex + 1], conditionBuilderRef);
111
114
  }
112
115
  }
113
116
  } else {
@@ -118,17 +121,17 @@ var handleKeyPressForMainContent = function handleKeyPressForMainContent(evt, co
118
121
  evt.preventDefault();
119
122
  if (variant == 'tree') {
120
123
  if (evt.target.getAttribute('role') !== 'row') {
121
- var _evt$target$closest4;
124
+ var _evt$target$closest2;
122
125
  //when any cell is focussed, arrow left will select the previous cell or current row
123
126
 
124
- var allItems = Array.from((_evt$target$closest4 = evt.target.closest('[role="row"]')) === null || _evt$target$closest4 === void 0 ? void 0 : _evt$target$closest4.querySelectorAll('[role="gridcell"] button'));
125
- var _currentItemIndex = allItems.indexOf(evt.target);
127
+ var _allCellsInRow = Array.from((_evt$target$closest2 = evt.target.closest('[role="row"]')) === null || _evt$target$closest2 === void 0 ? void 0 : _evt$target$closest2.querySelectorAll('[role="gridcell"] button'));
128
+ var _currentItemIndex = _allCellsInRow.indexOf(evt.target);
126
129
  if (_currentItemIndex > 0) {
127
- util.focusThisItem(allItems[_currentItemIndex - 1]);
130
+ util.focusThisItem(_allCellsInRow[_currentItemIndex - 1], conditionBuilderRef);
128
131
  } else {
129
132
  //focus the row
130
133
  var wrapper = evt.target.closest("[role=\"row\"]");
131
- wrapper.focus();
134
+ util.manageTabIndexAndFocus(wrapper, conditionBuilderRef);
132
135
  }
133
136
  }
134
137
  } else {
@@ -144,6 +147,12 @@ var handleKeyPressForMainContent = function handleKeyPressForMainContent(evt, co
144
147
  handleRowNavigation(evt, conditionBuilderRef, variant);
145
148
  }
146
149
  break;
150
+ case 'Enter':
151
+ 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) {
152
+ var _document$activeEleme4;
153
+ (_document$activeEleme4 = document.activeElement) === null || _document$activeEleme4 === void 0 || (_document$activeEleme4 = _document$activeEleme4.querySelectorAll("button")[0]) === null || _document$activeEleme4 === void 0 || _document$activeEleme4.click();
154
+ }
155
+ break;
147
156
  }
148
157
  };
149
158
  var getRows = function getRows(conditionBuilderRef) {
@@ -159,9 +168,9 @@ var getRowIndex = function getRowIndex(element, conditionBuilderRef) {
159
168
  var handleRowNavigation = function handleRowNavigation(evt, conditionBuilderRef, variant) {
160
169
  var rows = getRows(conditionBuilderRef);
161
170
  var currentRowIndex = getRowIndex(evt.target, conditionBuilderRef);
162
- navigateToNextRowCell(evt, currentRowIndex, rows, variant);
171
+ navigateToNextRowCell(evt, currentRowIndex, rows, variant, conditionBuilderRef);
163
172
  };
164
- function handleRowNavigationTree(evt, conditionBuilderRef, variant) {
173
+ var handleRowNavigationTree = function handleRowNavigationTree(evt, conditionBuilderRef, variant) {
165
174
  var rows = getRows(conditionBuilderRef);
166
175
  var currentRowIndex = getRowIndex(evt.target, conditionBuilderRef);
167
176
  var nextRowIndex = currentRowIndex;
@@ -179,15 +188,13 @@ function handleRowNavigationTree(evt, conditionBuilderRef, variant) {
179
188
  nextRowIndex = rows.length - 1;
180
189
  }
181
190
  if (nextRowIndex !== currentRowIndex) {
182
- rows[currentRowIndex].setAttribute('tabindex', '-1');
183
- rows[nextRowIndex].setAttribute('tabindex', '0');
184
- rows[nextRowIndex].focus();
191
+ util.manageTabIndexAndFocus(rows[nextRowIndex], conditionBuilderRef);
185
192
  }
186
193
  } else {
187
- navigateToNextRowCell(evt, currentRowIndex, rows, variant);
194
+ navigateToNextRowCell(evt, currentRowIndex, rows, variant, conditionBuilderRef);
188
195
  }
189
- }
190
- var navigateToNextRowCell = function navigateToNextRowCell(evt, currentRowIndex, rows, variant) {
196
+ };
197
+ var navigateToNextRowCell = function navigateToNextRowCell(evt, currentRowIndex, rows, variant, conditionBuilderRef) {
191
198
  //when the current focussed element is a cell of any row, arrow up/down will focus the next row same cell.
192
199
 
193
200
  var nextRowIndex = currentRowIndex;
@@ -200,21 +207,21 @@ var navigateToNextRowCell = function navigateToNextRowCell(evt, currentRowIndex,
200
207
  var nextRow = rows[nextRowIndex];
201
208
  var itemName = evt.target.dataset.name;
202
209
  if (nextRow !== null && nextRow !== void 0 && nextRow.querySelector("[data-name=\"".concat(itemName, "\"]"))) {
203
- var _nextRow$querySelecto;
204
- nextRow === null || nextRow === void 0 || (_nextRow$querySelecto = nextRow.querySelector("[data-name=\"".concat(itemName, "\"]"))) === null || _nextRow$querySelecto === void 0 || _nextRow$querySelecto.focus();
210
+ util.manageTabIndexAndFocus(nextRow === null || nextRow === void 0 ? void 0 : nextRow.querySelector("[data-name=\"".concat(itemName, "\"]")), conditionBuilderRef);
205
211
  } else if (variant === 'tree') {
206
212
  //when the next row is a if statement , then that row is focused. From any cell of last row of an group , arrow down select the next row (if)
207
- nextRow === null || nextRow === void 0 || nextRow.focus();
213
+ util.manageTabIndexAndFocus(nextRow, conditionBuilderRef);
208
214
  }
209
215
  };
210
216
  var handleCellNavigation = function handleCellNavigation(evt, conditionBuilderRef) {
211
217
  conditionBuilderRef.current.querySelectorAll("[role=\"gridcell\"] button").forEach(function (eachElem, index, allElements) {
212
218
  if (evt.key === 'ArrowRight') {
213
- util.traverseClockVise(eachElem, index, allElements);
219
+ util.traverseClockVise(eachElem, index, allElements, null, null, conditionBuilderRef);
214
220
  } else {
215
- util.traverseReverse(eachElem, index, allElements);
221
+ util.traverseReverse(eachElem, index, allElements, null, null, conditionBuilderRef);
216
222
  }
217
223
  });
218
224
  };
219
225
 
220
226
  exports.handleKeyDown = handleKeyDown;
227
+ exports.handleKeyDownForPopover = handleKeyDownForPopover;
@@ -1,6 +1,7 @@
1
- export function focusThisField(evt: any): void;
2
- export function focusThisItem(currentElement: any): void;
3
- export function traverseClockVise(eachElem: any, index: any, allElements: any, rotate: any, trapFocus: any): void;
4
- export function traverseReverse(eachElem: any, index: any, allElements: any, rotate: any, trapFocus: any): void;
1
+ export function focusThisField(evt: any, conditionBuilderRef: any): void;
2
+ export function focusThisItem(currentElement: any, conditionBuilderRef: any): void;
3
+ export function traverseClockVise(eachElem: any, index: any, allElements: any, rotate: any, trapFocus: any, conditionBuilderRef: any): void;
4
+ export function traverseReverse(eachElem: any, index: any, allElements: any, rotate: any, trapFocus: any, conditionBuilderRef: any): void;
5
5
  export function checkForHoldingKey(evt: any, key: any): any;
6
- export function checkDuplicateAction(actionState: any, selectedId: any, currentActionId: any): boolean;
6
+ export function checkIsValid(item: any): any;
7
+ export function manageTabIndexAndFocus(currentElement: any, conditionBuilderRef: any): void;
@@ -9,40 +9,45 @@
9
9
 
10
10
  Object.defineProperty(exports, '__esModule', { value: true });
11
11
 
12
- var focusThisField = function focusThisField(evt) {
13
- setTimeout(function () {
14
- var _evt$target$closest, _evt$target$closest2;
15
- (_evt$target$closest = evt.target.closest('[role="gridcell"]')) === null || _evt$target$closest === void 0 || (_evt$target$closest = _evt$target$closest.querySelector('button')) === null || _evt$target$closest === void 0 || _evt$target$closest.click();
16
- (_evt$target$closest2 = evt.target.closest('[role="gridcell"]')) === null || _evt$target$closest2 === void 0 || (_evt$target$closest2 = _evt$target$closest2.querySelector('button')) === null || _evt$target$closest2 === void 0 || _evt$target$closest2.focus();
17
- }, 0);
12
+ var DataConfigs = require('../ConditionBuilderContext/DataConfigs.js');
13
+
14
+ var focusThisField = function focusThisField(evt, conditionBuilderRef) {
15
+ if (evt) {
16
+ setTimeout(function () {
17
+ var _evt$target$closest, _evt$target$closest2, _evt$target$closest3;
18
+ manageTabIndexAndFocus((_evt$target$closest = evt.target.closest('[role="gridcell"]')) === null || _evt$target$closest === void 0 ? void 0 : _evt$target$closest.querySelector('button'), conditionBuilderRef);
19
+ (_evt$target$closest2 = evt.target.closest('[role="gridcell"]')) === null || _evt$target$closest2 === void 0 || (_evt$target$closest2 = _evt$target$closest2.querySelector('button')) === null || _evt$target$closest2 === void 0 || _evt$target$closest2.click();
20
+ (_evt$target$closest3 = evt.target.closest('[role="gridcell"]')) === null || _evt$target$closest3 === void 0 || (_evt$target$closest3 = _evt$target$closest3.querySelector('button')) === null || _evt$target$closest3 === void 0 || _evt$target$closest3.focus();
21
+ }, 0);
22
+ }
18
23
  };
19
- var focusThisItem = function focusThisItem(currentElement) {
24
+ var focusThisItem = function focusThisItem(currentElement, conditionBuilderRef) {
20
25
  setTimeout(function () {
21
26
  //document.activeElement.setAttribute('tabindex', '-1');
22
27
  // currentElement.setAttribute('tabindex', '0');
23
- currentElement === null || currentElement === void 0 || currentElement.focus();
28
+ manageTabIndexAndFocus(currentElement, conditionBuilderRef);
24
29
  }, 0);
25
30
  };
26
- var traverseClockVise = function traverseClockVise(eachElem, index, allElements, rotate, trapFocus) {
31
+ var traverseClockVise = function traverseClockVise(eachElem, index, allElements, rotate, trapFocus, conditionBuilderRef) {
27
32
  if (eachElem == document.activeElement) {
28
33
  if (index !== allElements.length - 1) {
29
- focusThisItem(allElements[index + 1]);
34
+ focusThisItem(allElements[index + 1], conditionBuilderRef);
30
35
  } else {
31
- focusThisItem(allElements[rotate ? 0 : allElements.length - 1]);
36
+ focusThisItem(allElements[rotate ? 0 : allElements.length - 1], conditionBuilderRef);
32
37
  }
33
38
  } else if (Array.from(allElements).indexOf(document.activeElement) == -1 && trapFocus) {
34
- focusThisItem(allElements[0]);
39
+ focusThisItem(allElements[0], conditionBuilderRef);
35
40
  }
36
41
  };
37
- var traverseReverse = function traverseReverse(eachElem, index, allElements, rotate, trapFocus) {
42
+ var traverseReverse = function traverseReverse(eachElem, index, allElements, rotate, trapFocus, conditionBuilderRef) {
38
43
  if (eachElem == document.activeElement) {
39
44
  if (index !== 0) {
40
- focusThisItem(allElements[index - 1]);
45
+ focusThisItem(allElements[index - 1], conditionBuilderRef);
41
46
  } else {
42
- focusThisItem(allElements[rotate ? allElements.length - 1 : 0]);
47
+ focusThisItem(allElements[rotate ? allElements.length - 1 : 0], conditionBuilderRef);
43
48
  }
44
49
  } else if (Array.from(allElements).indexOf(document.activeElement) == -1 && trapFocus) {
45
- focusThisItem(allElements[allElements.length - 1]);
50
+ focusThisItem(allElements[allElements.length - 1], conditionBuilderRef);
46
51
  }
47
52
  };
48
53
  var checkForHoldingKey = function checkForHoldingKey(evt, key) {
@@ -52,9 +57,24 @@ var checkForHoldingKey = function checkForHoldingKey(evt, key) {
52
57
  }
53
58
  return evt[key];
54
59
  };
60
+ var checkIsValid = function checkIsValid(item) {
61
+ return item && item !== 'INVALID';
62
+ };
63
+ var manageTabIndexAndFocus = function manageTabIndexAndFocus(currentElement, conditionBuilderRef) {
64
+ var _currentElement$close, _conditionBuilderRef$;
65
+ var contentContainer = (_currentElement$close = currentElement === null || currentElement === void 0 ? void 0 : currentElement.closest(".".concat(DataConfigs.blockClass, "__content-container"))) !== null && _currentElement$close !== void 0 ? _currentElement$close : currentElement === null || currentElement === void 0 ? void 0 : currentElement.closest(".".concat(DataConfigs.blockClass, "__actions-container"));
66
+ contentContainer && Array.from(contentContainer.querySelectorAll('[tabindex="0"]')).map(function (element) {
67
+ return element === null || element === void 0 ? void 0 : element.setAttribute('tabindex', '-1');
68
+ });
69
+ currentElement === null || currentElement === void 0 || currentElement.setAttribute('tabindex', '0');
70
+ (_conditionBuilderRef$ = conditionBuilderRef.current) === null || _conditionBuilderRef$ === void 0 || (_conditionBuilderRef$ = _conditionBuilderRef$.querySelector(".".concat(DataConfigs.blockClass, "__statement-button"))) === null || _conditionBuilderRef$ === void 0 || _conditionBuilderRef$.setAttribute('tabindex', '1');
71
+ currentElement === null || currentElement === void 0 || currentElement.focus();
72
+ };
55
73
 
56
74
  exports.checkForHoldingKey = checkForHoldingKey;
75
+ exports.checkIsValid = checkIsValid;
57
76
  exports.focusThisField = focusThisField;
58
77
  exports.focusThisItem = focusThisItem;
78
+ exports.manageTabIndexAndFocus = manageTabIndexAndFocus;
59
79
  exports.traverseClockVise = traverseClockVise;
60
80
  exports.traverseReverse = traverseReverse;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@carbon/ibm-products",
3
3
  "description": "Carbon for IBM Products",
4
- "version": "2.43.2-canary.80+e0eb6fb53",
4
+ "version": "2.43.2-canary.83+9b0d58d31",
5
5
  "license": "Apache-2.0",
6
6
  "main": "lib/index.js",
7
7
  "module": "es/index.js",
@@ -120,5 +120,5 @@
120
120
  "react": "^16.8.6 || ^17.0.1 || ^18.2.0",
121
121
  "react-dom": "^16.8.6 || ^17.0.1 || ^18.2.0"
122
122
  },
123
- "gitHead": "e0eb6fb53b1cb01482b4c428d3c3901e4ce55514"
123
+ "gitHead": "9b0d58d318e27eb456613a6d1843edb60fba19a0"
124
124
  }
@@ -69,3 +69,7 @@ $block-class: #{c4p-settings.$pkg-prefix}--condition-builder;
69
69
  .#{$block-class}__group-separator {
70
70
  margin-top: $spacing-02;
71
71
  }
72
+ .#{$block-class}__add-group,
73
+ .#{$block-class}__group-separator {
74
+ width: fit-content;
75
+ }
@@ -67,7 +67,7 @@ $block-class: #{c4p-settings.$pkg-prefix}--condition-builder;
67
67
  pointer-events: none;
68
68
  transition: all $duration-moderate-02 motion(exit, expressive);
69
69
  }
70
- .#{$block-class}__connector-disabled {
70
+ .#{$block-class}__connector--disabled {
71
71
  display: flex;
72
72
  min-width: $spacing-10;
73
73
  align-items: center;
@@ -75,3 +75,8 @@ $block-class: #{c4p-settings.$pkg-prefix}--condition-builder;
75
75
  color: $text-helper;
76
76
  padding-inline: $spacing-03;
77
77
  }
78
+ .#{$block-class}__condition-wrapper
79
+ > .#{$block-class}__condition-block:last-child
80
+ > .#{$block-class}__groupConnector {
81
+ margin-bottom: 0;
82
+ }
@@ -18,7 +18,7 @@ $block-class: #{c4p-settings.$pkg-prefix}--condition-builder;
18
18
  @include type-style('body-01');
19
19
  }
20
20
 
21
- .#{$block-class}__item__content {
21
+ .#{$block-class}__popover-content-wrapper {
22
22
  overflow: auto;
23
23
  min-width: $spacing-07 + $spacing-13;
24
24
  max-width: $spacing-13 + $spacing-13;