@carbon/ibm-products 2.43.2-canary.173 → 2.43.2-canary.176

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. package/css/index-full-carbon.css +9 -1
  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 +9 -1
  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 +9 -1
  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 +7 -3
  14. package/es/components/ConditionBuilder/ConditionBuilder.js +2 -1
  15. package/es/components/ConditionBuilder/ConditionBuilder.types.d.ts +2 -1
  16. package/es/components/ConditionBuilder/ConditionBuilderActions/ConditionBuilderActions.js +1 -1
  17. package/es/components/ConditionBuilder/ConditionBuilderAdd/ConditionBuilderAdd.js +1 -1
  18. package/es/components/ConditionBuilder/ConditionBuilderButton/ConditionBuilderButton.d.ts +3 -1
  19. package/es/components/ConditionBuilder/ConditionBuilderButton/ConditionBuilderButton.js +1 -1
  20. package/es/components/ConditionBuilder/ConditionBuilderConnector/ConditionConnector.js +4 -2
  21. package/es/components/ConditionBuilder/ConditionBuilderConnector/GroupConnector.js +4 -1
  22. package/es/components/ConditionBuilder/ConditionBuilderContent/ConditionBuilderContent.js +2 -2
  23. package/es/components/ConditionBuilder/ConditionBuilderContext/ConditionBuilderProvider.js +1 -1
  24. package/es/components/ConditionBuilder/ConditionBuilderContext/translationObject.d.ts +5 -0
  25. package/es/components/ConditionBuilder/ConditionBuilderContext/translationObject.js +5 -0
  26. package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItem.js +9 -3
  27. package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemDate/ConditionBuilderItemDate.js +1 -2
  28. package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemNumber/ConditionBuilderItemNumber.js +1 -1
  29. package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemOption/ItemOption.d.ts +3 -1
  30. package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemOption/ItemOption.js +11 -5
  31. package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemOption/ItemOptionForValueField.js +1 -1
  32. package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemText/ConditionBuilderItemText.js +1 -2
  33. package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemTime/ConditionBuilderItemTime.js +1 -1
  34. package/es/components/ConditionBuilder/ConditionGroupBuilder/ConditionGroupBuilder.js +7 -4
  35. package/es/components/ConditionBuilder/ConditionPreview/ConditionPreview.js +1 -1
  36. package/es/components/ConditionBuilder/utils/handleKeyboardEvents.js +1 -2
  37. package/es/components/ConditionBuilder/utils/useDataConfigs.d.ts +18 -0
  38. package/es/components/ConditionBuilder/utils/useDataConfigs.js +120 -0
  39. package/es/components/ConditionBuilder/utils/useTranslations.d.ts +1 -1
  40. package/es/components/ConditionBuilder/utils/useTranslations.js +4 -1
  41. package/es/components/ConditionBuilder/utils/util.d.ts +12 -0
  42. package/es/components/ConditionBuilder/utils/util.js +48 -2
  43. package/es/global/js/hooks/useFocus.d.ts +1 -1
  44. package/es/global/js/hooks/useFocus.js +40 -24
  45. package/lib/components/ConditionBuilder/ConditionBlock/ConditionBlock.js +17 -13
  46. package/lib/components/ConditionBuilder/ConditionBuilder.js +5 -4
  47. package/lib/components/ConditionBuilder/ConditionBuilder.types.d.ts +2 -1
  48. package/lib/components/ConditionBuilder/ConditionBuilderActions/ConditionBuilderActions.js +9 -9
  49. package/lib/components/ConditionBuilder/ConditionBuilderAdd/ConditionBuilderAdd.js +6 -6
  50. package/lib/components/ConditionBuilder/ConditionBuilderButton/ConditionBuilderButton.d.ts +3 -1
  51. package/lib/components/ConditionBuilder/ConditionBuilderButton/ConditionBuilderButton.js +3 -3
  52. package/lib/components/ConditionBuilder/ConditionBuilderConnector/ConditionConnector.js +7 -5
  53. package/lib/components/ConditionBuilder/ConditionBuilderConnector/GroupConnector.js +8 -5
  54. package/lib/components/ConditionBuilder/ConditionBuilderContent/ConditionBuilderContent.js +11 -11
  55. package/lib/components/ConditionBuilder/ConditionBuilderContext/ConditionBuilderProvider.js +1 -1
  56. package/lib/components/ConditionBuilder/ConditionBuilderContext/translationObject.d.ts +5 -0
  57. package/lib/components/ConditionBuilder/ConditionBuilderContext/translationObject.js +5 -0
  58. package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItem.js +13 -7
  59. package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemDate/ConditionBuilderItemDate.js +2 -3
  60. package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemNumber/ConditionBuilderItemNumber.js +2 -2
  61. package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemOption/ItemOption.d.ts +3 -1
  62. package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemOption/ItemOption.js +17 -11
  63. package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemOption/ItemOptionForValueField.js +12 -12
  64. package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemText/ConditionBuilderItemText.js +1 -2
  65. package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemTime/ConditionBuilderItemTime.js +2 -2
  66. package/lib/components/ConditionBuilder/ConditionGroupBuilder/ConditionGroupBuilder.js +20 -17
  67. package/lib/components/ConditionBuilder/ConditionPreview/ConditionPreview.js +17 -17
  68. package/lib/components/ConditionBuilder/utils/handleKeyboardEvents.js +8 -9
  69. package/lib/components/ConditionBuilder/utils/useDataConfigs.d.ts +18 -0
  70. package/lib/components/ConditionBuilder/utils/useDataConfigs.js +124 -0
  71. package/lib/components/ConditionBuilder/utils/useTranslations.d.ts +1 -1
  72. package/lib/components/ConditionBuilder/utils/useTranslations.js +4 -1
  73. package/lib/components/ConditionBuilder/utils/util.d.ts +12 -0
  74. package/lib/components/ConditionBuilder/utils/util.js +53 -3
  75. package/lib/global/js/hooks/useFocus.d.ts +1 -1
  76. package/lib/global/js/hooks/useFocus.js +40 -24
  77. package/package.json +3 -3
  78. package/scss/components/ConditionBuilder/styles/_conditionBuilderItem.scss +10 -1
  79. package/es/components/ConditionBuilder/ConditionBuilderContext/DataConfigs.d.ts +0 -30
  80. package/es/components/ConditionBuilder/ConditionBuilderContext/DataConfigs.js +0 -125
  81. package/lib/components/ConditionBuilder/ConditionBuilderContext/DataConfigs.d.ts +0 -30
  82. package/lib/components/ConditionBuilder/ConditionBuilderContext/DataConfigs.js +0 -135
@@ -13,11 +13,11 @@ var _rollupPluginBabelHelpers = require('../../../_virtual/_rollupPluginBabelHel
13
13
  var React = require('react');
14
14
  var cx = require('classnames');
15
15
  var index = require('../../../node_modules/prop-types/index.js');
16
- var DataConfigs = require('../ConditionBuilderContext/DataConfigs.js');
17
16
  var ConditionBuilderItem = require('../ConditionBuilderItem/ConditionBuilderItem.js');
18
17
  var ConditionConnector = require('../ConditionBuilderConnector/ConditionConnector.js');
19
18
  var useTranslations = require('../utils/useTranslations.js');
20
19
  var icons = require('@carbon/react/icons');
20
+ var util = require('../utils/util.js');
21
21
 
22
22
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
23
23
 
@@ -44,7 +44,7 @@ var ConditionPreview = function ConditionPreview(_ref) {
44
44
  }, []);
45
45
  var getConditionSection = function getConditionSection() {
46
46
  return /*#__PURE__*/React__default["default"].createElement("div", {
47
- className: "".concat(DataConfigs.blockClass, "__preview-condition")
47
+ className: "".concat(util.blockClass, "__preview-condition")
48
48
  }, _ConditionBuilderItem || (_ConditionBuilderItem = /*#__PURE__*/React__default["default"].createElement(ConditionBuilderItem.ConditionBuilderItem, {
49
49
  label: propertyText,
50
50
  renderIcon: icons.Bee
@@ -55,40 +55,40 @@ var ConditionPreview = function ConditionPreview(_ref) {
55
55
  })));
56
56
  };
57
57
  return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, previewType == 'newGroup' && /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement("div", {
58
- className: cx__default["default"](["".concat(DataConfigs.blockClass, "__group__row ").concat(DataConfigs.blockClass, "__group-preview "), _rollupPluginBabelHelpers.defineProperty({}, "".concat(DataConfigs.blockClass, "__group-preview-animate"), animate)])
58
+ className: cx__default["default"](["".concat(util.blockClass, "__group__row ").concat(util.blockClass, "__group-preview "), _rollupPluginBabelHelpers.defineProperty({}, "".concat(util.blockClass, "__group-preview-animate"), animate)])
59
59
  }, /*#__PURE__*/React__default["default"].createElement(ConditionBuilderItem.ConditionBuilderItem, {
60
- className: "".concat(DataConfigs.blockClass, "__statement-button"),
60
+ className: "".concat(util.blockClass, "__statement-button"),
61
61
  label: group.groupOperator
62
62
  })), /*#__PURE__*/React__default["default"].createElement("div", {
63
63
  "data-color-index": colorIndex,
64
64
  "aria-hidden": true,
65
- className: cx__default["default"](["".concat(DataConfigs.blockClass, "__group ").concat(DataConfigs.blockClass, "__condition-wrapper ").concat(DataConfigs.blockClass, "__group-preview ").concat(DataConfigs.blockClass, "__group-wrapper "), _rollupPluginBabelHelpers.defineProperty({}, "".concat(DataConfigs.blockClass, "__group-preview-animate"), animate)])
65
+ className: cx__default["default"](["".concat(util.blockClass, "__group ").concat(util.blockClass, "__condition-wrapper ").concat(util.blockClass, "__group-preview ").concat(util.blockClass, "__group-wrapper "), _rollupPluginBabelHelpers.defineProperty({}, "".concat(util.blockClass, "__group-preview-animate"), animate)])
66
66
  }, /*#__PURE__*/React__default["default"].createElement("div", {
67
- className: "".concat(DataConfigs.blockClass, "__gap")
67
+ className: "".concat(util.blockClass, "__gap")
68
68
  }, /*#__PURE__*/React__default["default"].createElement(ConditionBuilderItem.ConditionBuilderItem, {
69
- className: "".concat(DataConfigs.blockClass, "__statement-button"),
69
+ className: "".concat(util.blockClass, "__statement-button"),
70
70
  label: ifText
71
71
  })), getConditionSection())), previewType == 'subGroup' && /*#__PURE__*/React__default["default"].createElement("div", {
72
- className: cx__default["default"](["".concat(DataConfigs.blockClass, "__group__row ").concat(DataConfigs.blockClass, "__group-preview ").concat(DataConfigs.blockClass, "__gap-bottom"), _rollupPluginBabelHelpers.defineProperty({}, "".concat(DataConfigs.blockClass, "__group-preview-animate"), animate)])
72
+ className: cx__default["default"](["".concat(util.blockClass, "__group__row ").concat(util.blockClass, "__group-preview ").concat(util.blockClass, "__gap-bottom"), _rollupPluginBabelHelpers.defineProperty({}, "".concat(util.blockClass, "__group-preview-animate"), animate)])
73
73
  }, /*#__PURE__*/React__default["default"].createElement("div", {
74
- className: "".concat(DataConfigs.blockClass, "__condition-block ").concat(DataConfigs.blockClass, "__gap")
74
+ className: "".concat(util.blockClass, "__condition-block ").concat(util.blockClass, "__gap")
75
75
  }, /*#__PURE__*/React__default["default"].createElement(ConditionBuilderItem.ConditionBuilderItem, {
76
76
  label: group.groupOperator,
77
- className: "".concat(DataConfigs.blockClass, "__statement-button"),
78
- popOverClassName: "".concat(DataConfigs.blockClass, "__gap")
77
+ className: "".concat(util.blockClass, "__statement-button"),
78
+ popOverClassName: "".concat(util.blockClass, "__gap")
79
79
  }), /*#__PURE__*/React__default["default"].createElement("div", {
80
- className: "".concat(DataConfigs.blockClass, "__group ").concat(DataConfigs.blockClass, "__condition-wrapper")
80
+ className: "".concat(util.blockClass, "__group ").concat(util.blockClass, "__condition-wrapper")
81
81
  }, /*#__PURE__*/React__default["default"].createElement(ConditionConnector["default"], {
82
- className: "".concat(DataConfigs.blockClass, "__gap ").concat(DataConfigs.blockClass, "__groupConnector"),
82
+ className: "".concat(util.blockClass, "__gap ").concat(util.blockClass, "__groupConnector"),
83
83
  operator: ifText
84
84
  }), getConditionSection()))), previewType == 'condition' && /*#__PURE__*/React__default["default"].createElement("div", {
85
- className: cx__default["default"](["".concat(DataConfigs.blockClass, "__group__row ").concat(DataConfigs.blockClass, "__group-preview ").concat(DataConfigs.blockClass, "__gap-bottom"), _rollupPluginBabelHelpers.defineProperty({}, "".concat(DataConfigs.blockClass, "__group-preview-animate"), animate)])
85
+ className: cx__default["default"](["".concat(util.blockClass, "__group__row ").concat(util.blockClass, "__group-preview ").concat(util.blockClass, "__gap-bottom"), _rollupPluginBabelHelpers.defineProperty({}, "".concat(util.blockClass, "__group-preview-animate"), animate)])
86
86
  }, /*#__PURE__*/React__default["default"].createElement("div", {
87
- className: "".concat(DataConfigs.blockClass, "__condition-block ").concat(DataConfigs.blockClass, "__gap")
87
+ className: "".concat(util.blockClass, "__condition-block ").concat(util.blockClass, "__gap")
88
88
  }, /*#__PURE__*/React__default["default"].createElement(ConditionBuilderItem.ConditionBuilderItem, {
89
89
  label: group.groupOperator,
90
- className: "".concat(DataConfigs.blockClass, "__statement-button"),
91
- popOverClassName: "".concat(DataConfigs.blockClass, "__gap")
90
+ className: "".concat(util.blockClass, "__statement-button"),
91
+ popOverClassName: "".concat(util.blockClass, "__gap")
92
92
  }), getConditionSection())));
93
93
  };
94
94
  ConditionPreview.propTypes = {
@@ -10,13 +10,12 @@
10
10
  Object.defineProperty(exports, '__esModule', { value: true });
11
11
 
12
12
  var _rollupPluginBabelHelpers = require('../../../_virtual/_rollupPluginBabelHelpers.js');
13
- var DataConfigs = require('../ConditionBuilderContext/DataConfigs.js');
14
13
  var util = require('./util.js');
15
14
 
16
15
  var handleKeyDown = function handleKeyDown(evt, conditionBuilderRef, variant) {
17
16
  var _activeElement$closes;
18
17
  var activeElement = document.activeElement;
19
- if (!((_activeElement$closes = activeElement.closest(".".concat(DataConfigs.blockClass, "__popover"))) !== null && _activeElement$closes !== void 0 && _activeElement$closes.querySelector('[role="dialog"]'))) {
18
+ if (!((_activeElement$closes = activeElement.closest(".".concat(util.blockClass, "__popover"))) !== null && _activeElement$closes !== void 0 && _activeElement$closes.querySelector('[role="dialog"]'))) {
20
19
  handleKeyPressForMainContent(evt, conditionBuilderRef, variant);
21
20
  }
22
21
  };
@@ -29,7 +28,7 @@ var handleKeyDownForPopover = function handleKeyDownForPopover(evt, conditionBui
29
28
 
30
29
  //skipping keyboard handling for date and time fields to get take carbon's
31
30
  var excludeKeyPress = function excludeKeyPress(evt) {
32
- return !['Escape'].includes(evt.key) && (evt.target.closest(".".concat(DataConfigs.blockClass, "__item-date")) || evt.target.closest(".".concat(DataConfigs.blockClass, "__item-time")));
31
+ return !['Escape'].includes(evt.key) && (evt.target.closest(".".concat(util.blockClass, "__item-date")) || evt.target.closest(".".concat(util.blockClass, "__item-time")));
33
32
  };
34
33
  var handleKeyPressForPopover = function handleKeyPressForPopover(evt, parentContainer, conditionBuilderRef) {
35
34
  var _parentContainer$quer;
@@ -46,7 +45,7 @@ var handleKeyPressForPopover = function handleKeyPressForPopover(evt, parentCont
46
45
  });
47
46
  //scroll to top when we reach a the top of the list to make search box visible
48
47
  if (Array.from(evt.target.closest('ul').querySelectorAll('li')).indexOf(evt.target) === 1) {
49
- parentContainer.querySelector(".".concat(DataConfigs.blockClass, "__popover-content-wrapper")).scrollTop = 0;
48
+ parentContainer.querySelector(".".concat(util.blockClass, "__popover-content-wrapper")).scrollTop = 0;
50
49
  }
51
50
  break;
52
51
  case 'ArrowDown':
@@ -57,7 +56,7 @@ var handleKeyPressForPopover = function handleKeyPressForPopover(evt, parentCont
57
56
  });
58
57
  break;
59
58
  case 'Tab':
60
- allItems = [].concat(_rollupPluginBabelHelpers.toConsumableArray(Array.from(parentContainer.querySelectorAll(".".concat(DataConfigs.blockClass, "__selectAll-button,[role=\"searchbox\"]")))), [parentContainer.querySelector("[role=\"option\"]")]);
59
+ allItems = [].concat(_rollupPluginBabelHelpers.toConsumableArray(Array.from(parentContainer.querySelectorAll(".".concat(util.blockClass, "__selectAll-button,[role=\"searchbox\"]")))), [parentContainer.querySelector("[role=\"option\"]")]);
61
60
  allItems.forEach(function (eachElem, index, allElements) {
62
61
  if (isHoldingShiftKey) {
63
62
  util.traverseReverse(eachElem, index, allElements, true, true, conditionBuilderRef);
@@ -105,7 +104,7 @@ var handleKeyPressForMainContent = function handleKeyPressForMainContent(evt, co
105
104
  switch (evt.key) {
106
105
  case 'ArrowRight':
107
106
  evt.preventDefault();
108
- if (variant == DataConfigs.HIERARCHICAL_VARIANT) {
107
+ if (variant == util.HIERARCHICAL_VARIANT) {
109
108
  var _evt$target$closest;
110
109
  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'));
111
110
  if (allCellsInRow.length === 1) {
@@ -132,7 +131,7 @@ var handleKeyPressForMainContent = function handleKeyPressForMainContent(evt, co
132
131
  break;
133
132
  case 'ArrowLeft':
134
133
  evt.preventDefault();
135
- if (variant == DataConfigs.HIERARCHICAL_VARIANT) {
134
+ if (variant == util.HIERARCHICAL_VARIANT) {
136
135
  if (evt.target.getAttribute('role') !== 'row') {
137
136
  var _evt$target$closest2;
138
137
  //when any cell is focussed, arrow left will select the previous cell or current row
@@ -154,7 +153,7 @@ var handleKeyPressForMainContent = function handleKeyPressForMainContent(evt, co
154
153
  case 'ArrowUp':
155
154
  case 'ArrowDown':
156
155
  evt.preventDefault();
157
- if (variant == DataConfigs.HIERARCHICAL_VARIANT) {
156
+ if (variant == util.HIERARCHICAL_VARIANT) {
158
157
  handleRowNavigationHierarchical(evt, conditionBuilderRef, variant);
159
158
  } else {
160
159
  handleRowNavigation(evt, conditionBuilderRef, variant);
@@ -221,7 +220,7 @@ var navigateToNextRowCell = function navigateToNextRowCell(evt, currentRowIndex,
221
220
  var itemName = evt.target.dataset.name;
222
221
  if (nextRow !== null && nextRow !== void 0 && nextRow.querySelector("[data-name=\"".concat(itemName, "\"]"))) {
223
222
  util.manageTabIndexAndFocus(nextRow === null || nextRow === void 0 ? void 0 : nextRow.querySelector("[data-name=\"".concat(itemName, "\"]")), conditionBuilderRef);
224
- } else if (variant === DataConfigs.HIERARCHICAL_VARIANT) {
223
+ } else if (variant === util.HIERARCHICAL_VARIANT) {
225
224
  //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)
226
225
  util.manageTabIndexAndFocus(nextRow, conditionBuilderRef);
227
226
  }
@@ -0,0 +1,18 @@
1
+ export function useDataConfigs(): {
2
+ statementConfig: {
3
+ label: string;
4
+ id: string;
5
+ connector: string;
6
+ text1: any;
7
+ text2: string;
8
+ }[];
9
+ connectorConfig: {
10
+ label: any;
11
+ id: string;
12
+ }[];
13
+ operatorConfig: {
14
+ label: any;
15
+ id: string;
16
+ type: string;
17
+ }[];
18
+ };
@@ -0,0 +1,124 @@
1
+ /**
2
+ * Copyright IBM Corp. 2020, 2024
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ 'use strict';
9
+
10
+ Object.defineProperty(exports, '__esModule', { value: true });
11
+
12
+ var _rollupPluginBabelHelpers = require('../../../_virtual/_rollupPluginBabelHelpers.js');
13
+ var useTranslations = require('./useTranslations.js');
14
+
15
+ var useDataConfigs = function useDataConfigs() {
16
+ var _useTranslations = useTranslations.useTranslations(['ifAll', 'ifAny', 'unlessAll', 'unlessAny', 'and', 'or', 'is', 'greater', 'greaterEqual', 'lower', 'lowerEqual', 'startsWith', 'endsWith', 'contains', 'oneOf', 'before', 'after', 'between']),
17
+ _useTranslations2 = _rollupPluginBabelHelpers.slicedToArray(_useTranslations, 18),
18
+ ifAll = _useTranslations2[0],
19
+ ifAny = _useTranslations2[1],
20
+ unlessAll = _useTranslations2[2],
21
+ unlessAny = _useTranslations2[3],
22
+ and = _useTranslations2[4],
23
+ or = _useTranslations2[5],
24
+ is = _useTranslations2[6],
25
+ greater = _useTranslations2[7],
26
+ greaterEqual = _useTranslations2[8],
27
+ lower = _useTranslations2[9],
28
+ lowerEqual = _useTranslations2[10],
29
+ startsWith = _useTranslations2[11],
30
+ endsWith = _useTranslations2[12],
31
+ contains = _useTranslations2[13],
32
+ oneOf = _useTranslations2[14],
33
+ before = _useTranslations2[15],
34
+ after = _useTranslations2[16],
35
+ between = _useTranslations2[17];
36
+ var statementConfig = [{
37
+ label: 'ifText',
38
+ id: 'ifAll',
39
+ connector: 'and',
40
+ text1: ifAll,
41
+ text2: '(a && b)'
42
+ }, {
43
+ label: 'ifText',
44
+ id: 'ifAny',
45
+ connector: 'or',
46
+ text1: ifAny,
47
+ text2: '(a || b)'
48
+ }, {
49
+ label: 'unlessText',
50
+ id: 'unlessAll',
51
+ connector: 'and',
52
+ text1: unlessAll,
53
+ text2: '! (a && b)'
54
+ }, {
55
+ label: 'unlessText',
56
+ id: 'unlessAny',
57
+ connector: 'or',
58
+ text1: unlessAny,
59
+ text2: '! (a || b)'
60
+ }];
61
+ var connectorConfig = [{
62
+ label: and,
63
+ id: 'and'
64
+ }, {
65
+ label: or,
66
+ id: 'or'
67
+ }];
68
+ var operatorConfig = [{
69
+ label: is,
70
+ id: 'is',
71
+ type: 'all'
72
+ }, {
73
+ label: greater,
74
+ id: 'greater',
75
+ type: 'number'
76
+ }, {
77
+ label: greaterEqual,
78
+ id: 'greaterEqual',
79
+ type: 'number'
80
+ }, {
81
+ label: lower,
82
+ id: 'lower',
83
+ type: 'number'
84
+ }, {
85
+ label: lowerEqual,
86
+ id: 'lowerEqual',
87
+ type: 'number'
88
+ }, {
89
+ label: startsWith,
90
+ id: 'startsWith',
91
+ type: 'text,textarea'
92
+ }, {
93
+ label: endsWith,
94
+ id: 'endsWith',
95
+ type: 'text,textarea'
96
+ }, {
97
+ label: contains,
98
+ id: 'contains',
99
+ type: 'text,textarea'
100
+ }, {
101
+ label: oneOf,
102
+ id: 'oneOf',
103
+ type: 'option'
104
+ }, {
105
+ label: before,
106
+ id: 'before',
107
+ type: 'date,time'
108
+ }, {
109
+ label: after,
110
+ id: 'after',
111
+ type: 'date,time'
112
+ }, {
113
+ label: between,
114
+ id: 'between',
115
+ type: 'date'
116
+ }];
117
+ return {
118
+ statementConfig: statementConfig,
119
+ connectorConfig: connectorConfig,
120
+ operatorConfig: operatorConfig
121
+ };
122
+ };
123
+
124
+ exports.useDataConfigs = useDataConfigs;
@@ -1 +1 @@
1
- export function useTranslations(translationKeys: any): any;
1
+ export function useTranslations(translationKeys: any, alterTranslationKeyMap: any): any;
@@ -13,10 +13,13 @@ var React = require('react');
13
13
  var ConditionBuilderProvider = require('../ConditionBuilderContext/ConditionBuilderProvider.js');
14
14
  var translationObject = require('../ConditionBuilderContext/translationObject.js');
15
15
 
16
- var useTranslations = function useTranslations(translationKeys) {
16
+ var useTranslations = function useTranslations(translationKeys, alterTranslationKeyMap) {
17
17
  var _useContext = React.useContext(ConditionBuilderProvider.ConditionBuilderContext),
18
18
  translateWithId = _useContext.translateWithId;
19
19
  return translationKeys.map(function (translationKey) {
20
+ if (alterTranslationKeyMap !== null && alterTranslationKeyMap !== void 0 && alterTranslationKeyMap[translationKey]) {
21
+ translationKey = alterTranslationKeyMap[translationKey];
22
+ }
20
23
  if (translateWithId !== null && translateWithId !== void 0 && translateWithId(translationKey)) {
21
24
  return translateWithId(translationKey);
22
25
  } else if (translationObject.translationsObject[translationKey]) {
@@ -1,3 +1,6 @@
1
+ export const blockClass: string;
2
+ export const NON_HIERARCHICAL_VARIANT: "Non-Hierarchical";
3
+ export const HIERARCHICAL_VARIANT: "Hierarchical";
1
4
  export function focusThisField(evt: any, conditionBuilderRef: any): void;
2
5
  export function focusThisItem(currentElement: any, conditionBuilderRef: any): void;
3
6
  export function traverseClockVise(eachElem: any, index: any, allElements: any, rotate: any, trapFocus: any, conditionBuilderRef: any): void;
@@ -5,3 +8,12 @@ export function traverseReverse(eachElem: any, index: any, allElements: any, rot
5
8
  export function checkForHoldingKey(evt: any, key: any): any;
6
9
  export function checkIsValid(item: any): any;
7
10
  export function manageTabIndexAndFocus(currentElement: any, conditionBuilderRef: any): void;
11
+ export namespace getValue {
12
+ function text(value: any): any;
13
+ function textarea(value: any): any;
14
+ function time(value: any): any;
15
+ function number(value: any): any;
16
+ function option(value: any): any;
17
+ function date(value: any): any;
18
+ function custom(value: any): any;
19
+ }
@@ -9,8 +9,11 @@
9
9
 
10
10
  Object.defineProperty(exports, '__esModule', { value: true });
11
11
 
12
- var DataConfigs = require('../ConditionBuilderContext/DataConfigs.js');
12
+ var settings = require('../../../settings.js');
13
13
 
14
+ var blockClass = "".concat(settings.pkg.prefix, "--condition-builder");
15
+ var NON_HIERARCHICAL_VARIANT = 'Non-Hierarchical';
16
+ var HIERARCHICAL_VARIANT = 'Hierarchical';
14
17
  var focusThisField = function focusThisField(evt, conditionBuilderRef) {
15
18
  if (evt) {
16
19
  setTimeout(function () {
@@ -62,19 +65,66 @@ var checkIsValid = function checkIsValid(item) {
62
65
  };
63
66
  var manageTabIndexAndFocus = function manageTabIndexAndFocus(currentElement, conditionBuilderRef) {
64
67
  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"));
68
+ var contentContainer = (_currentElement$close = currentElement === null || currentElement === void 0 ? void 0 : currentElement.closest(".".concat(blockClass, "__content-container"))) !== null && _currentElement$close !== void 0 ? _currentElement$close : currentElement === null || currentElement === void 0 ? void 0 : currentElement.closest(".".concat(blockClass, "__actions-container"));
66
69
  contentContainer && Array.from(contentContainer.querySelectorAll('[tabindex="0"]')).map(function (element) {
67
70
  return element === null || element === void 0 ? void 0 : element.setAttribute('tabindex', '-1');
68
71
  });
69
72
  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');
73
+ (_conditionBuilderRef$ = conditionBuilderRef.current) === null || _conditionBuilderRef$ === void 0 || (_conditionBuilderRef$ = _conditionBuilderRef$.querySelector(".".concat(blockClass, "__statement-button"))) === null || _conditionBuilderRef$ === void 0 || _conditionBuilderRef$.setAttribute('tabindex', '1');
71
74
  currentElement === null || currentElement === void 0 || currentElement.focus();
72
75
  };
76
+ var formatDate = function formatDate(date) {
77
+ var day = String(date.getDate()).padStart(2, '0');
78
+ var month = String(date.getMonth() + 1).padStart(2, '0');
79
+ var year = date.getFullYear();
80
+ return "".concat(day, "/").concat(month, "/").concat(year);
81
+ };
82
+ var getValue = {
83
+ text: function text(value) {
84
+ return value;
85
+ },
86
+ textarea: function textarea(value) {
87
+ return value;
88
+ },
89
+ time: function time(value) {
90
+ return value;
91
+ },
92
+ number: function number(value) {
93
+ return value;
94
+ },
95
+ option: function option(value) {
96
+ if (value && typeof value !== 'string') {
97
+ var selectedValues = Array.isArray(value) ? value : [value];
98
+ return selectedValues.map(function (option) {
99
+ return option.label;
100
+ }).join(', ');
101
+ }
102
+ return value;
103
+ },
104
+ date: function date(value) {
105
+ if (Array.isArray(value) && value.length > 1) {
106
+ var start = value !== null && value !== void 0 && value[0] && !isNaN(new Date(value[0])) ? formatDate(new Date(value[0])) : '';
107
+ var end = value !== null && value !== void 0 && value[1] && !isNaN(new Date(value[1])) ? formatDate(new Date(value[1])) : '';
108
+ return "".concat(start, " To ").concat(end);
109
+ } else if (Array.isArray(value) && !isNaN(new Date(value[0]))) {
110
+ return formatDate(new Date(value[0]));
111
+ } else {
112
+ return value;
113
+ }
114
+ },
115
+ custom: function custom(value) {
116
+ return value;
117
+ }
118
+ };
73
119
 
120
+ exports.HIERARCHICAL_VARIANT = HIERARCHICAL_VARIANT;
121
+ exports.NON_HIERARCHICAL_VARIANT = NON_HIERARCHICAL_VARIANT;
122
+ exports.blockClass = blockClass;
74
123
  exports.checkForHoldingKey = checkForHoldingKey;
75
124
  exports.checkIsValid = checkIsValid;
76
125
  exports.focusThisField = focusThisField;
77
126
  exports.focusThisItem = focusThisItem;
127
+ exports.getValue = getValue;
78
128
  exports.manageTabIndexAndFocus = manageTabIndexAndFocus;
79
129
  exports.traverseClockVise = traverseClockVise;
80
130
  exports.traverseReverse = traverseReverse;
@@ -4,7 +4,7 @@ export function useFocus(modalRef: any, selectorPrimaryFocus: any): {
4
4
  lastElement: any;
5
5
  allElements: any;
6
6
  specifiedElement: any;
7
- keyDownListener: (event: any) => void;
7
+ keyDownListener: (event: any) => Promise<void>;
8
8
  getFocusable: () => {
9
9
  first: any;
10
10
  last: any;
@@ -9,9 +9,11 @@
9
9
 
10
10
  Object.defineProperty(exports, '__esModule', { value: true });
11
11
 
12
+ var _rollupPluginBabelHelpers = require('../../../_virtual/_rollupPluginBabelHelpers.js');
12
13
  var react = require('@carbon/react');
13
14
  var settings = require('../../../settings.js');
14
15
  var React = require('react');
16
+ var wait = require('../utils/wait.js');
15
17
 
16
18
  var getSpecificElement = function getSpecificElement(parentEl, elementId) {
17
19
  var element = parentEl === null || parentEl === void 0 ? void 0 : parentEl.querySelector(elementId);
@@ -20,6 +22,7 @@ var getSpecificElement = function getSpecificElement(parentEl, elementId) {
20
22
  var useFocus = function useFocus(modalRef, selectorPrimaryFocus) {
21
23
  var carbonPrefix = react.usePrefix();
22
24
  var tearsheetBaseClass = "".concat(settings.pkg.prefix, "--tearsheet");
25
+ var sidePanelBaseClass = "".concat(settings.pkg.prefix, "--side-panel");
23
26
  // Querying focusable element in the modal
24
27
  // Query to exclude hidden elements in the modal from querySelectorAll() method
25
28
  // feel free to include more if needed :)
@@ -31,8 +34,9 @@ var useFocus = function useFocus(modalRef, selectorPrimaryFocus) {
31
34
  var queryTextarea = "textarea".concat(notQuery);
32
35
  var queryLink = "[href]".concat(notQuery);
33
36
  var queryTabIndex = "[tabindex=\"0\"]".concat(notQuery);
37
+ var querySidePanelScroll = ".".concat(sidePanelBaseClass, "--scrolls");
34
38
  // Final query
35
- var query = "".concat(queryButton, ",").concat(queryLink, ",").concat(queryInput, ",").concat(querySelect, ",").concat(queryTextarea, ", ").concat(queryTabIndex);
39
+ var query = "".concat(queryButton, ",").concat(queryLink, ",").concat(queryInput, ",").concat(querySelect, ",").concat(queryTextarea, ",").concat(queryTabIndex, ",").concat(querySidePanelScroll);
36
40
  var modalEl = modalRef === null || modalRef === void 0 ? void 0 : modalRef.current;
37
41
  var getFocusable = React.useCallback(function () {
38
42
  var _focusableElements, _focusableElements2, _focusableElements3, _focusableElements4;
@@ -58,30 +62,42 @@ var useFocus = function useFocus(modalRef, selectorPrimaryFocus) {
58
62
  React.useEffect(function () {
59
63
  getFocusable();
60
64
  }, [getFocusable]);
61
- var handleKeyDown = function handleKeyDown(event) {
62
- // Checking whether the key is tab or not
63
- if (event.key === 'Tab') {
64
- // updating the focusable elements list
65
- var _getFocusable = getFocusable(),
66
- first = _getFocusable.first,
67
- last = _getFocusable.last,
68
- all = _getFocusable.all;
69
- setTimeout(function () {
70
- var _document, _document2;
71
- if (event.shiftKey && !Array.prototype.includes.call(all, (_document = document) === null || _document === void 0 ? void 0 : _document.activeElement)) {
72
- // Prevents the default "Tab" behavior
73
- event.preventDefault();
74
- // if the user press shift+tab and the current element not in focusable items
75
- last === null || last === void 0 || last.focus();
76
- } else if (!Array.prototype.includes.call(all, (_document2 = document) === null || _document2 === void 0 ? void 0 : _document2.activeElement)) {
77
- event.preventDefault();
78
- // user pressing tab key only then
79
- // focusing the first element if the current element is not in focusable items
80
- first === null || first === void 0 || first.focus();
65
+ var handleKeyDown = /*#__PURE__*/function () {
66
+ var _ref = _rollupPluginBabelHelpers.asyncToGenerator( /*#__PURE__*/_rollupPluginBabelHelpers.regeneratorRuntime().mark(function _callee(event) {
67
+ var _document, _document2, _getFocusable, first, last, all;
68
+ return _rollupPluginBabelHelpers.regeneratorRuntime().wrap(function _callee$(_context) {
69
+ while (1) switch (_context.prev = _context.next) {
70
+ case 0:
71
+ if (!(event.key === 'Tab')) {
72
+ _context.next = 5;
73
+ break;
74
+ }
75
+ // updating the focusable elements list
76
+ _getFocusable = getFocusable(), first = _getFocusable.first, last = _getFocusable.last, all = _getFocusable.all;
77
+ _context.next = 4;
78
+ return wait["default"](1);
79
+ case 4:
80
+ if (event.shiftKey && !Array.prototype.includes.call(all, (_document = document) === null || _document === void 0 ? void 0 : _document.activeElement)) {
81
+ // Prevents the default "Tab" behavior
82
+ event.preventDefault();
83
+ // if the user press shift+tab and the current element not in focusable items
84
+ last === null || last === void 0 || last.focus();
85
+ } else if (!Array.prototype.includes.call(all, (_document2 = document) === null || _document2 === void 0 ? void 0 : _document2.activeElement)) {
86
+ event.preventDefault();
87
+ // user pressing tab key only then
88
+ // focusing the first element if the current element is not in focusable items
89
+ first === null || first === void 0 || first.focus();
90
+ }
91
+ case 5:
92
+ case "end":
93
+ return _context.stop();
81
94
  }
82
- }, 0);
83
- }
84
- };
95
+ }, _callee);
96
+ }));
97
+ return function handleKeyDown(_x) {
98
+ return _ref.apply(this, arguments);
99
+ };
100
+ }();
85
101
  return {
86
102
  firstElement: getFocusable().first,
87
103
  lastElement: getFocusable().last,
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.173+485e8bcac",
4
+ "version": "2.43.2-canary.176+0df908523",
5
5
  "license": "Apache-2.0",
6
6
  "main": "lib/index.js",
7
7
  "module": "es/index.js",
@@ -96,7 +96,7 @@
96
96
  "dependencies": {
97
97
  "@babel/runtime": "^7.23.9",
98
98
  "@carbon/feature-flags": "^0.20.0",
99
- "@carbon/ibm-products-styles": "^2.39.1-canary.183+485e8bcac",
99
+ "@carbon/ibm-products-styles": "^2.44.0-rc.0",
100
100
  "@carbon/telemetry": "^0.1.0",
101
101
  "@dnd-kit/core": "^6.0.8",
102
102
  "@dnd-kit/modifiers": "^7.0.0",
@@ -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": "485e8bcac3193e56d65721076160944b4e126256"
123
+ "gitHead": "0df908523eab166b8bb63731f60a727ef846e41f"
124
124
  }
@@ -54,7 +54,8 @@ $block-class: #{c4p-settings.$pkg-prefix}--condition-builder;
54
54
  }
55
55
 
56
56
  .#{$block-class}__item-option__option {
57
- height: 2rem;
57
+ display: grid;
58
+ min-height: 2rem;
58
59
  cursor: pointer;
59
60
  padding-inline: $spacing-05;
60
61
  }
@@ -297,3 +298,11 @@ $colors: (
297
298
  fill: $icon-primary;
298
299
  }
299
300
  }
301
+
302
+ .#{$block-class}__statement_wrapper {
303
+ padding: $spacing-03 0;
304
+
305
+ :nth-child(2) {
306
+ color: $text-secondary;
307
+ }
308
+ }
@@ -1,30 +0,0 @@
1
- export const statementConfig: {
2
- label: string;
3
- id: string;
4
- connector: string;
5
- }[];
6
- export const connectorConfig: {
7
- label: string;
8
- id: string;
9
- }[];
10
- export const actionConfig: {
11
- label: string;
12
- id: string;
13
- }[];
14
- export const operatorConfig: {
15
- label: string;
16
- id: string;
17
- type: string;
18
- }[];
19
- export const NON_HIERARCHICAL_VARIANT: "Non-Hierarchical";
20
- export const HIERARCHICAL_VARIANT: "Hierarchical";
21
- export const blockClass: string;
22
- export namespace valueRenderers {
23
- function text(val: any): any;
24
- function textarea(val: any): any;
25
- function time(val: any): any;
26
- function number(val: any): any;
27
- function option(value: any): any;
28
- function date(value: any): any;
29
- function custom(value: any): any;
30
- }