@carbon/ibm-products 2.37.0 → 2.38.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (118) hide show
  1. package/css/index-without-carbon-released-only.css +218 -0
  2. package/css/index-without-carbon-released-only.css.map +1 -1
  3. package/css/index-without-carbon-released-only.min.css +1 -1
  4. package/css/index-without-carbon-released-only.min.css.map +1 -1
  5. package/css/index.css +218 -0
  6. package/css/index.css.map +1 -1
  7. package/css/index.min.css +1 -1
  8. package/css/index.min.css.map +1 -1
  9. package/es/components/ActionSet/ActionSet.js +3 -2
  10. package/es/components/Checklist/Checklist.js +10 -10
  11. package/es/components/Checklist/ChecklistChart.d.ts +1 -1
  12. package/es/components/Checklist/ChecklistChart.js +6 -30
  13. package/es/components/Coachmark/Coachmark.d.ts +65 -2
  14. package/es/components/Coachmark/Coachmark.js +7 -10
  15. package/es/components/Coachmark/CoachmarkDragbar.d.ts +40 -2
  16. package/es/components/Coachmark/CoachmarkDragbar.js +3 -1
  17. package/es/components/Coachmark/CoachmarkHeader.d.ts +27 -2
  18. package/es/components/Coachmark/CoachmarkHeader.js +0 -1
  19. package/es/components/Coachmark/CoachmarkOverlay.d.ts +42 -2
  20. package/es/components/Coachmark/CoachmarkOverlay.js +18 -15
  21. package/es/components/Coachmark/CoachmarkTagline.d.ts +27 -2
  22. package/es/components/Coachmark/CoachmarkTagline.js +0 -1
  23. package/es/components/Coachmark/utils/enums.d.ts +20 -20
  24. package/es/components/Coachmark/utils/enums.js +22 -20
  25. package/es/components/CoachmarkFixed/CoachmarkFixed.d.ts +42 -2
  26. package/es/components/CoachmarkFixed/CoachmarkFixed.js +4 -2
  27. package/es/components/ConditionBuilder/ConditionBlock/ConditionBlock.d.ts +2 -1
  28. package/es/components/ConditionBuilder/ConditionBlock/ConditionBlock.js +25 -23
  29. package/es/components/ConditionBuilder/ConditionBuilderButton/ConditionBuilderButton.js +2 -2
  30. package/es/components/ConditionBuilder/ConditionBuilderContent/ConditionBuilderContent.js +14 -24
  31. package/es/components/ConditionBuilder/ConditionBuilderContext/ConditionBuilderProvider.d.ts +2 -0
  32. package/es/components/ConditionBuilder/ConditionBuilderContext/ConditionBuilderProvider.js +4 -1
  33. package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItem.d.ts +3 -3
  34. package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItem.js +11 -11
  35. package/es/components/ConditionBuilder/ConditionGroupBuilder/ConditionGroupBuilder.d.ts +5 -3
  36. package/es/components/ConditionBuilder/ConditionGroupBuilder/ConditionGroupBuilder.js +54 -44
  37. package/es/components/DataSpreadsheet/DataSpreadsheetBody.js +14 -8
  38. package/es/components/DataSpreadsheet/DataSpreadsheetHeader.js +5 -2
  39. package/es/components/DataSpreadsheet/hooks/useMoveActiveCell.js +2 -1
  40. package/es/components/Datagrid/Datagrid/DatagridContent.d.ts +1 -0
  41. package/es/components/Datagrid/Datagrid/DatagridContent.js +1 -0
  42. package/es/components/Datagrid/useSkeletonRows.d.ts +1 -1
  43. package/es/components/Datagrid/useSkeletonRows.js +11 -3
  44. package/es/components/EditTearsheetNarrow/EditTearsheetNarrow.d.ts +19 -2
  45. package/es/components/SearchBar/SearchBar.d.ts +10 -1
  46. package/es/components/SearchBar/SearchBar.js +26 -20
  47. package/es/components/TagSet/TagSet.d.ts +87 -3
  48. package/es/components/TagSet/TagSet.js +20 -9
  49. package/es/components/TagSet/TagSetModal.d.ts +32 -26
  50. package/es/components/TagSet/TagSetModal.js +5 -5
  51. package/es/components/TagSet/TagSetOverflow.d.ts +45 -2
  52. package/es/components/TagSet/TagSetOverflow.js +14 -12
  53. package/es/components/WebTerminal/WebTerminal.js +2 -2
  54. package/es/components/WebTerminal/WebTerminalContentWrapper.d.ts +15 -2
  55. package/es/components/WebTerminal/hooks/index.d.ts +16 -11
  56. package/es/components/WebTerminal/hooks/index.js +1 -1
  57. package/es/global/js/package-settings.d.ts +1 -1
  58. package/es/global/js/package-settings.js +1 -1
  59. package/es/node_modules/@carbon/colors/es/index.js +4 -1
  60. package/es/settings.d.ts +1 -1
  61. package/lib/components/ActionSet/ActionSet.js +2 -1
  62. package/lib/components/Checklist/Checklist.js +10 -10
  63. package/lib/components/Checklist/ChecklistChart.d.ts +1 -1
  64. package/lib/components/Checklist/ChecklistChart.js +6 -30
  65. package/lib/components/Coachmark/Coachmark.d.ts +65 -2
  66. package/lib/components/Coachmark/Coachmark.js +6 -9
  67. package/lib/components/Coachmark/CoachmarkDragbar.d.ts +40 -2
  68. package/lib/components/Coachmark/CoachmarkDragbar.js +3 -1
  69. package/lib/components/Coachmark/CoachmarkHeader.d.ts +27 -2
  70. package/lib/components/Coachmark/CoachmarkHeader.js +0 -1
  71. package/lib/components/Coachmark/CoachmarkOverlay.d.ts +42 -2
  72. package/lib/components/Coachmark/CoachmarkOverlay.js +18 -15
  73. package/lib/components/Coachmark/CoachmarkTagline.d.ts +27 -2
  74. package/lib/components/Coachmark/CoachmarkTagline.js +0 -1
  75. package/lib/components/Coachmark/utils/enums.d.ts +20 -20
  76. package/lib/components/Coachmark/utils/enums.js +22 -20
  77. package/lib/components/CoachmarkFixed/CoachmarkFixed.d.ts +42 -2
  78. package/lib/components/CoachmarkFixed/CoachmarkFixed.js +4 -2
  79. package/lib/components/ConditionBuilder/ConditionBlock/ConditionBlock.d.ts +2 -1
  80. package/lib/components/ConditionBuilder/ConditionBlock/ConditionBlock.js +25 -23
  81. package/lib/components/ConditionBuilder/ConditionBuilderButton/ConditionBuilderButton.js +2 -2
  82. package/lib/components/ConditionBuilder/ConditionBuilderContent/ConditionBuilderContent.js +13 -23
  83. package/lib/components/ConditionBuilder/ConditionBuilderContext/ConditionBuilderProvider.d.ts +2 -0
  84. package/lib/components/ConditionBuilder/ConditionBuilderContext/ConditionBuilderProvider.js +4 -1
  85. package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItem.d.ts +3 -3
  86. package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItem.js +11 -11
  87. package/lib/components/ConditionBuilder/ConditionGroupBuilder/ConditionGroupBuilder.d.ts +5 -3
  88. package/lib/components/ConditionBuilder/ConditionGroupBuilder/ConditionGroupBuilder.js +54 -44
  89. package/lib/components/DataSpreadsheet/DataSpreadsheetBody.js +13 -7
  90. package/lib/components/DataSpreadsheet/DataSpreadsheetHeader.js +5 -2
  91. package/lib/components/DataSpreadsheet/hooks/useMoveActiveCell.js +2 -1
  92. package/lib/components/Datagrid/Datagrid/DatagridContent.d.ts +1 -0
  93. package/lib/components/Datagrid/Datagrid/DatagridContent.js +1 -0
  94. package/lib/components/Datagrid/useSkeletonRows.d.ts +1 -1
  95. package/lib/components/Datagrid/useSkeletonRows.js +11 -3
  96. package/lib/components/EditTearsheetNarrow/EditTearsheetNarrow.d.ts +19 -2
  97. package/lib/components/SearchBar/SearchBar.d.ts +10 -1
  98. package/lib/components/SearchBar/SearchBar.js +26 -18
  99. package/lib/components/TagSet/TagSet.d.ts +87 -3
  100. package/lib/components/TagSet/TagSet.js +20 -9
  101. package/lib/components/TagSet/TagSetModal.d.ts +32 -26
  102. package/lib/components/TagSet/TagSetModal.js +3 -3
  103. package/lib/components/TagSet/TagSetOverflow.d.ts +45 -2
  104. package/lib/components/TagSet/TagSetOverflow.js +14 -12
  105. package/lib/components/WebTerminal/WebTerminal.js +2 -2
  106. package/lib/components/WebTerminal/WebTerminalContentWrapper.d.ts +15 -2
  107. package/lib/components/WebTerminal/hooks/index.d.ts +16 -11
  108. package/lib/components/WebTerminal/hooks/index.js +1 -1
  109. package/lib/global/js/package-settings.d.ts +1 -1
  110. package/lib/global/js/package-settings.js +1 -1
  111. package/lib/node_modules/@carbon/colors/es/index.js +6 -0
  112. package/lib/settings.d.ts +1 -1
  113. package/package.json +5 -3
  114. package/scss/components/Checklist/_carbon-imports.scss +2 -2
  115. package/scss/components/_index-released-only-with-carbon.scss +2 -1
  116. package/scss/components/_index-released-only.scss +2 -1
  117. package/scss/components/_index-with-carbon.scss +1 -0
  118. package/telemetry.yml +936 -683
@@ -28,20 +28,21 @@ import ConditionBuilderAdd from '../ConditionBuilderAdd/ConditionBuilderAdd.js';
28
28
  */
29
29
 
30
30
  var ConditionBlock = function ConditionBlock(props) {
31
- var _props$state = props.state,
32
- property = _props$state.property,
33
- value = _props$state.value,
34
- operator = _props$state.operator;
31
+ var _props$condition = props.condition,
32
+ property = _props$condition.property,
33
+ value = _props$condition.value,
34
+ operator = _props$condition.operator;
35
35
  var onRemove = props.onRemove,
36
36
  onChange = props.onChange,
37
- state = props.state,
37
+ condition = props.condition,
38
38
  conjunction = props.conjunction,
39
39
  onConnectorOperatorChange = props.onConnectorOperatorChange,
40
40
  isStatement = props.isStatement,
41
41
  group = props.group,
42
42
  onStatementChange = props.onStatementChange,
43
43
  addConditionHandler = props.addConditionHandler,
44
- conditionIndex = props.conditionIndex;
44
+ conditionIndex = props.conditionIndex,
45
+ isLastCondition = props.isLastCondition;
45
46
  var _useContext = useContext(ConditionBuilderContext),
46
47
  inputConfig = _useContext.inputConfig;
47
48
  var itemComponents = {
@@ -60,13 +61,9 @@ var ConditionBlock = function ConditionBlock(props) {
60
61
  var getCurrentConfig = function getCurrentConfig(property) {
61
62
  var _inputConfig$properti, _inputConfig$properti2;
62
63
  return (_inputConfig$properti = (_inputConfig$properti2 = inputConfig.properties) === null || _inputConfig$properti2 === void 0 ? void 0 : _inputConfig$properti2.filter(function (eachProperty) {
63
- var _eachProperty$label;
64
- return ((_eachProperty$label = eachProperty.label) === null || _eachProperty$label === void 0 ? void 0 : _eachProperty$label.toUpperCase()) == (property === null || property === void 0 ? void 0 : property.toUpperCase());
64
+ return eachProperty.id == property;
65
65
  })[0]) !== null && _inputConfig$properti !== void 0 ? _inputConfig$properti : {};
66
66
  };
67
- var isLastCondition = function isLastCondition(conditionIndex, conditionArr) {
68
- return conditionIndex + 1 >= conditionArr.length || conditionArr.length - 1 != conditionIndex && conditionArr[conditionIndex + 1].conditions;
69
- };
70
67
  var _getCurrentConfig = getCurrentConfig(property),
71
68
  icon = _getCurrentConfig.icon,
72
69
  type = _getCurrentConfig.type,
@@ -81,7 +78,7 @@ var ConditionBlock = function ConditionBlock(props) {
81
78
  onConnectorOperatorChange(op);
82
79
  };
83
80
  var onPropertyChangeHandler = function onPropertyChangeHandler(newProperty) {
84
- onChange(_objectSpread2(_objectSpread2({}, state), {}, {
81
+ onChange(_objectSpread2(_objectSpread2({}, condition), {}, {
85
82
  property: newProperty,
86
83
  operator: undefined,
87
84
  value: '',
@@ -89,14 +86,14 @@ var ConditionBlock = function ConditionBlock(props) {
89
86
  }));
90
87
  };
91
88
  var onOperatorChangeHandler = function onOperatorChangeHandler(newOperator) {
92
- onChange(_objectSpread2(_objectSpread2({}, state), {}, {
89
+ onChange(_objectSpread2(_objectSpread2({}, condition), {}, {
93
90
  operator: newOperator,
94
91
  value: undefined,
95
92
  popoverToOpen: 'valueField'
96
93
  }));
97
94
  };
98
95
  var onValueChangeHandler = function onValueChangeHandler(newValue) {
99
- onChange(_objectSpread2(_objectSpread2({}, state), {}, {
96
+ onChange(_objectSpread2(_objectSpread2({}, condition), {}, {
100
97
  value: newValue,
101
98
  popoverToOpen: ''
102
99
  }));
@@ -125,7 +122,8 @@ var ConditionBlock = function ConditionBlock(props) {
125
122
  title: translateWithId('condition'),
126
123
  "data-name": "connectorField",
127
124
  popOverClassName: "".concat(blockClass, "__gap"),
128
- className: "".concat(blockClass, "__statement-button")
125
+ className: "".concat(blockClass, "__statement-button"),
126
+ tabIndex: 0
129
127
  }, /*#__PURE__*/React__default.createElement(ConditionBuilderItemOption, {
130
128
  conditionState: {
131
129
  value: group.statement,
@@ -145,7 +143,7 @@ var ConditionBlock = function ConditionBlock(props) {
145
143
  renderIcon: icon !== null && icon !== void 0 ? icon : null,
146
144
  className: "".concat(blockClass, "__property-field"),
147
145
  "data-name": "propertyField",
148
- state: state,
146
+ condition: condition,
149
147
  type: type
150
148
  }, /*#__PURE__*/React__default.createElement(ConditionBuilderItemOption, {
151
149
  conditionState: {
@@ -160,7 +158,7 @@ var ConditionBlock = function ConditionBlock(props) {
160
158
  label: operator,
161
159
  title: translateWithId('operator'),
162
160
  "data-name": "operatorField",
163
- state: state,
161
+ condition: condition,
164
162
  type: type
165
163
  }, /*#__PURE__*/React__default.createElement(ConditionBuilderItemOption, {
166
164
  config: {
@@ -177,7 +175,7 @@ var ConditionBlock = function ConditionBlock(props) {
177
175
  title: label,
178
176
  showToolTip: true,
179
177
  "data-name": "valueField",
180
- state: state,
178
+ condition: condition,
181
179
  config: config
182
180
  }, /*#__PURE__*/React__default.createElement(ItemComponent, {
183
181
  conditionState: {
@@ -220,6 +218,10 @@ ConditionBlock.propTypes = {
220
218
  * object hold aria attributes
221
219
  */
222
220
  aria: PropTypes.object,
221
+ /**
222
+ * object that hold the current condition
223
+ */
224
+ condition: PropTypes.object,
223
225
  /**
224
226
  * index of the current condition
225
227
  */
@@ -232,6 +234,10 @@ ConditionBlock.propTypes = {
232
234
  * object that hold the current group object where is condition is part of
233
235
  */
234
236
  group: PropTypes.object,
237
+ /**
238
+ * callback to add a new condition
239
+ */
240
+ isLastCondition: PropTypes.func,
235
241
  /**
236
242
  * boolean that decides to show the statement(if/ excl.if)
237
243
  */
@@ -251,11 +257,7 @@ ConditionBlock.propTypes = {
251
257
  /**
252
258
  * callback to handle the statement(if/ excl.if) change
253
259
  */
254
- onStatementChange: PropTypes.func,
255
- /**
256
- * object that hold the current condition
257
- */
258
- state: PropTypes.object
260
+ onStatementChange: PropTypes.func
259
261
  };
260
262
 
261
263
  export { ConditionBlock$1 as default };
@@ -24,13 +24,13 @@ var ConditionBuilderButton = function ConditionBuilderButton(_ref) {
24
24
  showToolTip = _ref.showToolTip,
25
25
  rest = _objectWithoutProperties(_ref, _excluded);
26
26
  var Button = function Button() {
27
- return /*#__PURE__*/React__default.createElement("button", _extends({}, rest, {
27
+ return /*#__PURE__*/React__default.createElement("button", _extends({
28
28
  // role={'gridcell'}
29
29
  tabIndex: -1,
30
30
  className: cx([className, "".concat(blockClass, "__condition-builder-button"), _defineProperty({}, "".concat(blockClass, "__text-ellipsis"), showToolTip && !hideLabel)]),
31
31
  type: "button",
32
32
  onClick: onClick
33
- }), Icon && (_Icon || (_Icon = /*#__PURE__*/React__default.createElement(Icon, null))), !hideLabel && label);
33
+ }, rest), Icon && (_Icon || (_Icon = /*#__PURE__*/React__default.createElement(Icon, null))), !hideLabel && label);
34
34
  };
35
35
  return hideLabel || showToolTip ? /*#__PURE__*/React__default.createElement(Tooltip, _extends({
36
36
  label: label,
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- import { slicedToArray as _slicedToArray, objectSpread2 as _objectSpread2, extends as _extends } from '../../../_virtual/_rollupPluginBabelHelpers.js';
8
+ import { slicedToArray as _slicedToArray, objectSpread2 as _objectSpread2, extends as _extends, toConsumableArray as _toConsumableArray } from '../../../_virtual/_rollupPluginBabelHelpers.js';
9
9
  import React__default, { useContext, useState, useEffect, useCallback } from 'react';
10
10
  import PropTypes from '../../../node_modules/prop-types/index.js';
11
11
  import { Button } from '@carbon/react';
@@ -23,16 +23,16 @@ var ConditionBuilderContent = function ConditionBuilderContent(_ref) {
23
23
  var _useContext = useContext(ConditionBuilderContext),
24
24
  rootState = _useContext.rootState,
25
25
  setRootState = _useContext.setRootState;
26
- var _useState = useState(true),
26
+ var _useState = useState(false),
27
27
  _useState2 = _slicedToArray(_useState, 2),
28
28
  isConditionBuilderActive = _useState2[0],
29
29
  setIsConditionBuilderActive = _useState2[1];
30
30
  useEffect(function () {
31
31
  var _rootState$groups;
32
32
  if (rootState !== null && rootState !== void 0 && (_rootState$groups = rootState.groups) !== null && _rootState$groups !== void 0 && _rootState$groups.length) {
33
- setIsConditionBuilderActive(false);
34
- } else {
35
33
  setIsConditionBuilderActive(true);
34
+ } else {
35
+ setIsConditionBuilderActive(false);
36
36
  }
37
37
  if (getConditionState) {
38
38
  getConditionState(rootState);
@@ -40,26 +40,16 @@ var ConditionBuilderContent = function ConditionBuilderContent(_ref) {
40
40
 
41
41
  // eslint-disable-next-line react-hooks/exhaustive-deps
42
42
  }, [rootState, conditionBuilderRef]);
43
- useEffect(function () {
44
- if (isConditionBuilderActive == false) {
45
- if (conditionBuilderRef.current) {
46
- var initial = conditionBuilderRef.current.querySelector('[role="gridcell"] button');
47
- if (initial) {
48
- initial.setAttribute('tabindex', '0');
49
- }
50
- }
51
- }
52
- }, [isConditionBuilderActive, conditionBuilderRef]);
53
43
  var onStartConditionBuilder = function onStartConditionBuilder() {
54
44
  //when add condition button is clicked.
55
- setIsConditionBuilderActive(false);
45
+ setIsConditionBuilderActive(true);
56
46
  setRootState(initialState !== null && initialState !== void 0 ? initialState : emptyState); //here we can set an empty skeleton object for an empty condition builder,
57
47
  //or we can even pre-populate some existing builder and continue editing
58
48
  };
59
- var _onRemove = useCallback(function (groupIndex) {
49
+ var _onRemove = useCallback(function (groupId) {
60
50
  setRootState(_objectSpread2(_objectSpread2({}, rootState), {}, {
61
- groups: rootState.groups.filter(function (group, gIndex) {
62
- return groupIndex !== gIndex;
51
+ groups: rootState.groups.filter(function (group) {
52
+ return groupId !== group.id;
63
53
  })
64
54
  }));
65
55
  }, [setRootState, rootState]);
@@ -68,16 +58,15 @@ var ConditionBuilderContent = function ConditionBuilderContent(_ref) {
68
58
  * This method is triggered from inner components. This will be called every time when any change is to be updated in the rootState.
69
59
  * This gets the updated group as argument.
70
60
  */
61
+ var groups = [].concat(_toConsumableArray(rootState.groups.slice(0, groupIndex)), [updatedGroup], _toConsumableArray(rootState.groups.slice(groupIndex + 1)));
71
62
  setRootState(_objectSpread2(_objectSpread2({}, rootState), {}, {
72
- groups: rootState.groups.map(function (group, gIndex) {
73
- return groupIndex === gIndex ? updatedGroup : group;
74
- })
63
+ groups: groups
75
64
  }));
76
65
  };
77
66
  return /*#__PURE__*/React__default.createElement("div", {
78
67
  className: "".concat(blockClass, "__content-container"),
79
68
  tabIndex: -1
80
- }, isConditionBuilderActive && /*#__PURE__*/React__default.createElement(Button, {
69
+ }, !isConditionBuilderActive && /*#__PURE__*/React__default.createElement(Button, {
81
70
  className: "".concat(blockClass, "__condition-builder"),
82
71
  renderIcon: function renderIcon(props) {
83
72
  return /*#__PURE__*/React__default.createElement(Add, _extends({
@@ -90,15 +79,16 @@ var ConditionBuilderContent = function ConditionBuilderContent(_ref) {
90
79
  onClick: onStartConditionBuilder
91
80
  }, startConditionLabel), rootState && (rootState === null || rootState === void 0 || (_rootState$groups2 = rootState.groups) === null || _rootState$groups2 === void 0 ? void 0 : _rootState$groups2.map(function (eachGroup, groupIndex) {
92
81
  return /*#__PURE__*/React__default.createElement(ConditionGroupBuilder, {
82
+ className: "".concat(blockClass, "__condition-builder__group"),
93
83
  key: groupIndex,
94
84
  aria: {
95
85
  level: 1,
96
86
  posinset: groupIndex * 2 + 1,
97
87
  setsize: rootState.groups.length * 2
98
88
  },
99
- state: eachGroup,
89
+ group: eachGroup,
100
90
  onRemove: function onRemove() {
101
- _onRemove(groupIndex);
91
+ _onRemove(eachGroup.id);
102
92
  },
103
93
  onChange: function onChange(updatedGroup) {
104
94
  onChangeHandler(updatedGroup, groupIndex);
@@ -3,11 +3,13 @@ export namespace emptyState {
3
3
  groupSeparateOperator: null;
4
4
  groupOperator: string;
5
5
  statement: string;
6
+ id: any;
6
7
  conditions: {
7
8
  property: undefined;
8
9
  operator: string;
9
10
  value: string;
10
11
  popoverToOpen: string;
12
+ id: any;
11
13
  }[];
12
14
  }[];
13
15
  }
@@ -8,17 +8,20 @@
8
8
  import { slicedToArray as _slicedToArray } from '../../../_virtual/_rollupPluginBabelHelpers.js';
9
9
  import React__default, { useState, createContext } from 'react';
10
10
  import PropTypes from '../../../node_modules/prop-types/index.js';
11
+ import uuidv4 from '../../../global/js/utils/uuidv4.js';
11
12
 
12
13
  var emptyState = {
13
14
  groups: [{
14
15
  groupSeparateOperator: null,
15
16
  groupOperator: 'and',
16
17
  statement: 'if',
18
+ id: uuidv4(),
17
19
  conditions: [{
18
20
  property: undefined,
19
21
  operator: '',
20
22
  value: '',
21
- popoverToOpen: 'propertyField'
23
+ popoverToOpen: 'propertyField',
24
+ id: uuidv4()
22
25
  }]
23
26
  }]
24
27
  };
@@ -1,4 +1,4 @@
1
- export function ConditionBuilderItem({ children, className, label, renderIcon, title, type, showToolTip, state, popOverClassName, config, ...rest }: {
1
+ export function ConditionBuilderItem({ children, className, label, renderIcon, title, type, showToolTip, condition, popOverClassName, config, ...rest }: {
2
2
  [x: string]: any;
3
3
  children: any;
4
4
  className: any;
@@ -7,7 +7,7 @@ export function ConditionBuilderItem({ children, className, label, renderIcon, t
7
7
  title: any;
8
8
  type: any;
9
9
  showToolTip: any;
10
- state: any;
10
+ condition: any;
11
11
  popOverClassName: any;
12
12
  config: any;
13
13
  }): import("react/jsx-runtime").JSX.Element;
@@ -15,12 +15,12 @@ export namespace ConditionBuilderItem {
15
15
  namespace propTypes {
16
16
  let children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
17
17
  let className: PropTypes.Requireable<string>;
18
+ let condition: PropTypes.Requireable<object>;
18
19
  let config: PropTypes.Requireable<object>;
19
20
  let label: PropTypes.Requireable<NonNullable<string | any[] | null | undefined>>;
20
21
  let popOverClassName: PropTypes.Requireable<string>;
21
22
  let renderIcon: PropTypes.Requireable<object>;
22
23
  let showToolTip: PropTypes.Requireable<boolean>;
23
- let state: PropTypes.Requireable<object>;
24
24
  let title: PropTypes.Requireable<string>;
25
25
  let type: PropTypes.Requireable<string>;
26
26
  }
@@ -13,7 +13,7 @@ import { Add } from '@carbon/react/icons';
13
13
  import { valueRenderers, translateWithId, blockClass } from '../ConditionBuilderContext/DataConfigs.js';
14
14
  import { ConditionBuilderButton } from '../ConditionBuilderButton/ConditionBuilderButton.js';
15
15
 
16
- var _excluded = ["children", "className", "label", "renderIcon", "title", "type", "showToolTip", "state", "popOverClassName", "config"];
16
+ var _excluded = ["children", "className", "label", "renderIcon", "title", "type", "showToolTip", "condition", "popOverClassName", "config"];
17
17
  var ConditionBuilderItem = function ConditionBuilderItem(_ref) {
18
18
  var children = _ref.children,
19
19
  className = _ref.className,
@@ -22,7 +22,7 @@ var ConditionBuilderItem = function ConditionBuilderItem(_ref) {
22
22
  title = _ref.title,
23
23
  type = _ref.type,
24
24
  showToolTip = _ref.showToolTip,
25
- state = _ref.state,
25
+ condition = _ref.condition,
26
26
  popOverClassName = _ref.popOverClassName,
27
27
  config = _ref.config,
28
28
  rest = _objectWithoutProperties(_ref, _excluded);
@@ -45,17 +45,17 @@ var ConditionBuilderItem = function ConditionBuilderItem(_ref) {
45
45
  * rest['data-name'] holds the current field name
46
46
  * popoverToOpen hold the next popover to be opened if required
47
47
  */
48
- if (state) {
48
+ if (condition) {
49
49
  var currentField = rest['data-name'];
50
50
  //if any condition is changed, state prop is triggered
51
- if (state.popoverToOpen && currentField !== state.popoverToOpen) {
51
+ if (condition.popoverToOpen && currentField !== condition.popoverToOpen) {
52
52
  // close the previous popover
53
53
  setOpen(false);
54
- } else if (currentField == 'valueField' && type == 'option' && state.operator !== 'one-of') {
54
+ } else if (currentField == 'valueField' && type == 'option' && condition.operator !== 'one-of') {
55
55
  //close the current popover if the field is valueField and is a single select dropdown. For all other inputs ,popover need to be open on value changes.
56
56
  setOpen(false);
57
57
  }
58
- if (state.popoverToOpen == currentField) {
58
+ if (condition.popoverToOpen == currentField) {
59
59
  //current popover need to be opened
60
60
  setOpen(true);
61
61
  }
@@ -65,7 +65,7 @@ var ConditionBuilderItem = function ConditionBuilderItem(_ref) {
65
65
  setOpen(false);
66
66
  }
67
67
  // eslint-disable-next-line react-hooks/exhaustive-deps
68
- }, [state, label]);
68
+ }, [condition, label]);
69
69
  useEffect(function () {
70
70
  //this will focus the first input field in the popover
71
71
  if (open && contentRef.current) {
@@ -113,6 +113,10 @@ ConditionBuilderItem.propTypes = {
113
113
  * Provide an optional class to be applied to the containing node.
114
114
  */
115
115
  className: PropTypes.string,
116
+ /**
117
+ * current condition state object
118
+ */
119
+ condition: PropTypes.object,
116
120
  /**
117
121
  * this is the config object again the current property from inputConfig
118
122
  */
@@ -134,10 +138,6 @@ ConditionBuilderItem.propTypes = {
134
138
  * show tool tip
135
139
  */
136
140
  showToolTip: PropTypes.bool,
137
- /**
138
- * current condition state object
139
- */
140
- state: PropTypes.object,
141
141
  /**
142
142
  * title of the popover
143
143
  */
@@ -5,20 +5,22 @@ export default ConditionGroupBuilder;
5
5
  * All the inner components of group are called from here.
6
6
  * @returns
7
7
  */
8
- declare function ConditionGroupBuilder({ state, aria, onRemove, onChange, conditionBuilderRef, }: {
9
- state: any;
8
+ declare function ConditionGroupBuilder({ group, aria, onRemove, onChange, conditionBuilderRef, className, }: {
9
+ group: any;
10
10
  aria: any;
11
11
  onRemove: any;
12
12
  onChange: any;
13
13
  conditionBuilderRef: any;
14
+ className: any;
14
15
  }): import("react/jsx-runtime").JSX.Element;
15
16
  declare namespace ConditionGroupBuilder {
16
17
  namespace propTypes {
17
18
  let aria: PropTypes.Requireable<object>;
19
+ let className: PropTypes.Requireable<string>;
18
20
  let conditionBuilderRef: PropTypes.Requireable<object>;
21
+ let group: PropTypes.Requireable<object>;
19
22
  let onChange: PropTypes.Requireable<(...args: any[]) => any>;
20
23
  let onRemove: PropTypes.Requireable<(...args: any[]) => any>;
21
- let state: PropTypes.Requireable<object>;
22
24
  }
23
25
  }
24
26
  import PropTypes from 'prop-types';
@@ -10,6 +10,7 @@ import React__default from 'react';
10
10
  import ConditionBlock from '../ConditionBlock/ConditionBlock.js';
11
11
  import PropTypes from '../../../node_modules/prop-types/index.js';
12
12
  import { blockClass, translateWithId } from '../ConditionBuilderContext/DataConfigs.js';
13
+ import uuidv4 from '../../../global/js/utils/uuidv4.js';
13
14
 
14
15
  /**
15
16
  *
@@ -18,17 +19,18 @@ import { blockClass, translateWithId } from '../ConditionBuilderContext/DataConf
18
19
  * @returns
19
20
  */
20
21
  var ConditionGroupBuilder = function ConditionGroupBuilder(_ref) {
21
- var _state$conditions;
22
- var state = _ref.state,
22
+ var _group$conditions;
23
+ var group = _ref.group,
23
24
  aria = _ref.aria,
24
25
  onRemove = _ref.onRemove,
25
26
  onChange = _ref.onChange,
26
- conditionBuilderRef = _ref.conditionBuilderRef;
27
- var onRemoveHandler = function onRemoveHandler(conditionIndex, e) {
28
- if (state.conditions.length > 1) {
29
- onChange(_objectSpread2(_objectSpread2({}, state), {}, {
30
- conditions: state.conditions.filter(function (condition, cIndex) {
31
- return conditionIndex !== cIndex;
27
+ conditionBuilderRef = _ref.conditionBuilderRef,
28
+ className = _ref.className;
29
+ var onRemoveHandler = function onRemoveHandler(conditionId, e) {
30
+ if (group.conditions.length > 1) {
31
+ onChange(_objectSpread2(_objectSpread2({}, group), {}, {
32
+ conditions: group.conditions.filter(function (condition) {
33
+ return conditionId !== condition.id;
32
34
  })
33
35
  }));
34
36
  handleFocusOnClose(e);
@@ -36,23 +38,27 @@ var ConditionGroupBuilder = function ConditionGroupBuilder(_ref) {
36
38
  onRemove();
37
39
  }
38
40
  };
39
- var onChangeHandler = function onChangeHandler(updatedConditions, conditionIndex) {
40
- onChange(_objectSpread2(_objectSpread2({}, state), {}, {
41
- conditions: state.conditions.map(function (condition, cIndex) {
42
- return conditionIndex === cIndex ? updatedConditions : condition;
43
- })
41
+ var onChangeHandler = function onChangeHandler(updatedCondition, conditionIndex) {
42
+ var updatedConditions = [].concat(_toConsumableArray(group.conditions.slice(0, conditionIndex)), [updatedCondition], _toConsumableArray(group.conditions.slice(conditionIndex + 1)));
43
+ onChange(_objectSpread2(_objectSpread2({}, group), {}, {
44
+ conditions: updatedConditions
44
45
  }));
45
46
  };
46
47
  var addConditionHandler = function addConditionHandler(conditionIndex) {
47
- onChange(_objectSpread2(_objectSpread2({}, state), {}, {
48
- conditions: [].concat(_toConsumableArray(state.conditions.slice(0, conditionIndex + 1)), [{
49
- property: undefined,
50
- operator: '',
51
- value: '',
52
- popoverToOpen: 'propertyField'
53
- }], _toConsumableArray(state.conditions.slice(conditionIndex + 1)))
48
+ var newCondition = {
49
+ property: undefined,
50
+ operator: '',
51
+ value: '',
52
+ popoverToOpen: 'propertyField',
53
+ id: uuidv4()
54
+ };
55
+ onChange(_objectSpread2(_objectSpread2({}, group), {}, {
56
+ conditions: [].concat(_toConsumableArray(group.conditions.slice(0, conditionIndex + 1)), [newCondition], _toConsumableArray(group.conditions.slice(conditionIndex + 1)))
54
57
  }));
55
58
  };
59
+ var isLastCondition = function isLastCondition(conditionIndex, conditionArr) {
60
+ return conditionIndex + 1 >= conditionArr.length || conditionArr.length - 1 != conditionIndex && conditionArr[conditionIndex + 1].conditions;
61
+ };
56
62
  var handleFocusOnClose = function handleFocusOnClose(e) {
57
63
  var _e$currentTarget;
58
64
  var previousClose = (_e$currentTarget = e.currentTarget) === null || _e$currentTarget === void 0 || (_e$currentTarget = _e$currentTarget.closest('[role="row"]')) === null || _e$currentTarget === void 0 || (_e$currentTarget = _e$currentTarget.previousSibling) === null || _e$currentTarget === void 0 ? void 0 : _e$currentTarget.querySelector('[data-name="closeCondition"]');
@@ -61,40 +67,39 @@ var ConditionGroupBuilder = function ConditionGroupBuilder(_ref) {
61
67
  }
62
68
  };
63
69
  return /*#__PURE__*/React__default.createElement("div", {
64
- className: " ".concat(blockClass, "__condition-builder__group eachGroup")
70
+ className: "".concat(className, " eachGroup")
65
71
  }, /*#__PURE__*/React__default.createElement("div", {
66
72
  className: "".concat(blockClass, "__condition-wrapper"),
67
73
  role: "grid",
68
74
  "aria-label": translateWithId('condition_builder_group')
69
- }, state === null || state === void 0 || (_state$conditions = state.conditions) === null || _state$conditions === void 0 ? void 0 : _state$conditions.map(function (eachCondition, conditionIndex) {
75
+ }, group === null || group === void 0 || (_group$conditions = group.conditions) === null || _group$conditions === void 0 ? void 0 : _group$conditions.map(function (eachCondition, conditionIndex) {
70
76
  return /*#__PURE__*/React__default.createElement("div", {
71
- key: conditionIndex
77
+ key: eachCondition.id
72
78
  }, eachCondition.conditions && /*#__PURE__*/React__default.createElement(ConditionGroupBuilder, {
79
+ className: "".concat(blockClass, "__condition-builder__group"),
73
80
  aria: {
74
81
  level: aria.level + 1,
75
82
  posinset: conditionIndex + 1,
76
- setsize: state.conditions.length
83
+ setsize: group.conditions.length
77
84
  },
78
- state: eachCondition,
79
- onChange: function onChange(updatedConditions) {
80
- onChangeHandler(updatedConditions, conditionIndex);
85
+ group: eachCondition,
86
+ onChange: function onChange(updatedCondition) {
87
+ onChangeHandler(updatedCondition, conditionIndex);
81
88
  },
82
89
  onRemove: function onRemove(e) {
83
- onRemoveHandler(conditionIndex, e);
90
+ onRemoveHandler(eachCondition.id, e);
84
91
  },
85
- conditionBuilderRef: conditionBuilderRef,
86
- key: conditionIndex
92
+ conditionBuilderRef: conditionBuilderRef
87
93
  }), !eachCondition.conditions && /*#__PURE__*/React__default.createElement(ConditionBlock, {
88
- key: conditionIndex,
89
- conjunction: conditionIndex > 0 ? state.groupOperator : undefined,
94
+ conjunction: conditionIndex > 0 ? group.groupOperator : undefined,
90
95
  aria: {
91
96
  level: aria.level + 1,
92
97
  posinset: conditionIndex + 1,
93
- setsize: state.conditions.length
98
+ setsize: group.conditions.length
94
99
  },
95
100
  isStatement: conditionIndex == 0,
96
- state: eachCondition,
97
- group: state,
101
+ condition: eachCondition,
102
+ group: group,
98
103
  conditionIndex: conditionIndex,
99
104
  className: "".concat(blockClass, "__gap ").concat(blockClass, "__gap-bottom"),
100
105
  onChange: function onChange(updatedConditions) {
@@ -102,18 +107,19 @@ var ConditionGroupBuilder = function ConditionGroupBuilder(_ref) {
102
107
  },
103
108
  addConditionHandler: addConditionHandler,
104
109
  onRemove: function onRemove(e) {
105
- onRemoveHandler(conditionIndex, e);
110
+ onRemoveHandler(eachCondition.id, e);
106
111
  },
107
112
  onConnectorOperatorChange: function onConnectorOperatorChange(op) {
108
- onChange(_objectSpread2(_objectSpread2({}, state), {}, {
113
+ onChange(_objectSpread2(_objectSpread2({}, group), {}, {
109
114
  groupOperator: op
110
115
  }));
111
116
  },
112
117
  onStatementChange: function onStatementChange(updatedStatement) {
113
- onChange(_objectSpread2(_objectSpread2({}, state), {}, {
118
+ onChange(_objectSpread2(_objectSpread2({}, group), {}, {
114
119
  statement: updatedStatement
115
120
  }));
116
- }
121
+ },
122
+ isLastCondition: isLastCondition
117
123
  }));
118
124
  })));
119
125
  };
@@ -123,10 +129,18 @@ ConditionGroupBuilder.propTypes = {
123
129
  * object contains the aria attributes
124
130
  */
125
131
  aria: PropTypes.object,
132
+ /**
133
+ * Provide an class to be applied to the containing node.
134
+ */
135
+ className: PropTypes.string,
126
136
  /**
127
137
  * ref of condition builder
128
138
  */
129
139
  conditionBuilderRef: PropTypes.object,
140
+ /**
141
+ * group defines the current group
142
+ */
143
+ group: PropTypes.object,
130
144
  /**
131
145
 
132
146
  * callback to update the current condition of the state tree
@@ -135,11 +149,7 @@ ConditionGroupBuilder.propTypes = {
135
149
  /**
136
150
  * call back to remove the particular group from the state tree
137
151
  */
138
- onRemove: PropTypes.func,
139
- /**
140
- * state defines the current group
141
- */
142
- state: PropTypes.object
152
+ onRemove: PropTypes.func
143
153
  };
144
154
 
145
155
  export { ConditionGroupBuilder$1 as default };