@carbon/ibm-products 2.38.0-alpha.5 → 2.38.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (110) 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/EditTearsheetNarrow/EditTearsheetNarrow.d.ts +19 -2
  41. package/es/components/SearchBar/SearchBar.d.ts +10 -1
  42. package/es/components/SearchBar/SearchBar.js +26 -20
  43. package/es/components/TagSet/TagSet.d.ts +87 -3
  44. package/es/components/TagSet/TagSet.js +20 -9
  45. package/es/components/TagSet/TagSetModal.d.ts +32 -26
  46. package/es/components/TagSet/TagSetModal.js +5 -5
  47. package/es/components/TagSet/TagSetOverflow.d.ts +45 -2
  48. package/es/components/TagSet/TagSetOverflow.js +14 -12
  49. package/es/components/WebTerminal/WebTerminal.js +2 -2
  50. package/es/components/WebTerminal/WebTerminalContentWrapper.d.ts +15 -2
  51. package/es/components/WebTerminal/hooks/index.d.ts +16 -11
  52. package/es/components/WebTerminal/hooks/index.js +1 -1
  53. package/es/global/js/package-settings.d.ts +1 -1
  54. package/es/global/js/package-settings.js +1 -1
  55. package/es/node_modules/@carbon/colors/es/index.js +4 -1
  56. package/es/settings.d.ts +1 -1
  57. package/lib/components/ActionSet/ActionSet.js +2 -1
  58. package/lib/components/Checklist/Checklist.js +10 -10
  59. package/lib/components/Checklist/ChecklistChart.d.ts +1 -1
  60. package/lib/components/Checklist/ChecklistChart.js +6 -30
  61. package/lib/components/Coachmark/Coachmark.d.ts +65 -2
  62. package/lib/components/Coachmark/Coachmark.js +6 -9
  63. package/lib/components/Coachmark/CoachmarkDragbar.d.ts +40 -2
  64. package/lib/components/Coachmark/CoachmarkDragbar.js +3 -1
  65. package/lib/components/Coachmark/CoachmarkHeader.d.ts +27 -2
  66. package/lib/components/Coachmark/CoachmarkHeader.js +0 -1
  67. package/lib/components/Coachmark/CoachmarkOverlay.d.ts +42 -2
  68. package/lib/components/Coachmark/CoachmarkOverlay.js +18 -15
  69. package/lib/components/Coachmark/CoachmarkTagline.d.ts +27 -2
  70. package/lib/components/Coachmark/CoachmarkTagline.js +0 -1
  71. package/lib/components/Coachmark/utils/enums.d.ts +20 -20
  72. package/lib/components/Coachmark/utils/enums.js +22 -20
  73. package/lib/components/CoachmarkFixed/CoachmarkFixed.d.ts +42 -2
  74. package/lib/components/CoachmarkFixed/CoachmarkFixed.js +4 -2
  75. package/lib/components/ConditionBuilder/ConditionBlock/ConditionBlock.d.ts +2 -1
  76. package/lib/components/ConditionBuilder/ConditionBlock/ConditionBlock.js +25 -23
  77. package/lib/components/ConditionBuilder/ConditionBuilderButton/ConditionBuilderButton.js +2 -2
  78. package/lib/components/ConditionBuilder/ConditionBuilderContent/ConditionBuilderContent.js +13 -23
  79. package/lib/components/ConditionBuilder/ConditionBuilderContext/ConditionBuilderProvider.d.ts +2 -0
  80. package/lib/components/ConditionBuilder/ConditionBuilderContext/ConditionBuilderProvider.js +4 -1
  81. package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItem.d.ts +3 -3
  82. package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItem.js +11 -11
  83. package/lib/components/ConditionBuilder/ConditionGroupBuilder/ConditionGroupBuilder.d.ts +5 -3
  84. package/lib/components/ConditionBuilder/ConditionGroupBuilder/ConditionGroupBuilder.js +54 -44
  85. package/lib/components/DataSpreadsheet/DataSpreadsheetBody.js +13 -7
  86. package/lib/components/DataSpreadsheet/DataSpreadsheetHeader.js +5 -2
  87. package/lib/components/DataSpreadsheet/hooks/useMoveActiveCell.js +2 -1
  88. package/lib/components/EditTearsheetNarrow/EditTearsheetNarrow.d.ts +19 -2
  89. package/lib/components/SearchBar/SearchBar.d.ts +10 -1
  90. package/lib/components/SearchBar/SearchBar.js +26 -18
  91. package/lib/components/TagSet/TagSet.d.ts +87 -3
  92. package/lib/components/TagSet/TagSet.js +20 -9
  93. package/lib/components/TagSet/TagSetModal.d.ts +32 -26
  94. package/lib/components/TagSet/TagSetModal.js +3 -3
  95. package/lib/components/TagSet/TagSetOverflow.d.ts +45 -2
  96. package/lib/components/TagSet/TagSetOverflow.js +14 -12
  97. package/lib/components/WebTerminal/WebTerminal.js +2 -2
  98. package/lib/components/WebTerminal/WebTerminalContentWrapper.d.ts +15 -2
  99. package/lib/components/WebTerminal/hooks/index.d.ts +16 -11
  100. package/lib/components/WebTerminal/hooks/index.js +1 -1
  101. package/lib/global/js/package-settings.d.ts +1 -1
  102. package/lib/global/js/package-settings.js +1 -1
  103. package/lib/node_modules/@carbon/colors/es/index.js +6 -0
  104. package/lib/settings.d.ts +1 -1
  105. package/package.json +3 -3
  106. package/scss/components/Checklist/_carbon-imports.scss +2 -2
  107. package/scss/components/_index-released-only-with-carbon.scss +2 -1
  108. package/scss/components/_index-released-only.scss +2 -1
  109. package/scss/components/_index-with-carbon.scss +1 -0
  110. package/telemetry.yml +5 -8
@@ -39,7 +39,6 @@ var defaults = {
39
39
  kind: enums.COACHMARK_OVERLAY_KIND.FLOATING,
40
40
  theme: 'light'
41
41
  };
42
-
43
42
  /**
44
43
  * DO NOT USE. This component is for the exclusive use
45
44
  * of other Novice to Pro components.
@@ -61,7 +60,7 @@ exports.CoachmarkOverlay = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
61
60
  _useState2 = _rollupPluginBabelHelpers.slicedToArray(_useState, 2),
62
61
  a11yDragMode = _useState2[0],
63
62
  setA11yDragMode = _useState2[1];
64
- var overlayRef = React.useRef();
63
+ var overlayRef = React.useRef(null);
65
64
  var coachmark = context.useCoachmark();
66
65
  var isBeacon = kind === enums.COACHMARK_OVERLAY_KIND.TOOLTIP;
67
66
  var isDraggable = kind === enums.COACHMARK_OVERLAY_KIND.FLOATING;
@@ -94,20 +93,21 @@ exports.CoachmarkOverlay = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
94
93
  var styledTune = {};
95
94
  if (isBeacon || isDraggable) {
96
95
  if (coachmark.targetRect) {
97
- styledTune = {
98
- left: coachmark.targetRect.x + window.scrollX,
99
- top: coachmark.targetRect.y + window.scrollY
100
- };
96
+ styledTune.left = coachmark.targetRect.x + window.scrollX;
97
+ styledTune.top = coachmark.targetRect.y + window.scrollY;
101
98
  }
102
- if (isBeacon) {
103
- // Compensate for radius of beacon
104
- styledTune.left += 16;
105
- styledTune.top += 16;
106
- } else if (isDraggable) {
107
- // Compensate for width and height of target element
108
- var offsetTune = constants.getOffsetTune(coachmark, kind);
109
- styledTune.left += offsetTune.left;
110
- styledTune.top += offsetTune.top;
99
+ if (styledTune.left && styledTune.top) {
100
+ if (isBeacon) {
101
+ // Compensate for radius of beacon
102
+ styledTune.left += 16;
103
+ styledTune.top += 16;
104
+ }
105
+ if (isDraggable) {
106
+ // Compensate for width and height of target element
107
+ var offsetTune = constants.getOffsetTune(coachmark, kind);
108
+ styledTune.left += offsetTune.left;
109
+ styledTune.top += offsetTune.top;
110
+ }
111
111
  }
112
112
  }
113
113
  function handleDragBounds(x, y) {
@@ -132,6 +132,9 @@ exports.CoachmarkOverlay = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
132
132
  }
133
133
  function handleDrag(movementX, movementY) {
134
134
  var overlay = overlayRef.current;
135
+ if (!overlay) {
136
+ return;
137
+ }
135
138
  var _overlay$getBoundingC = overlay.getBoundingClientRect(),
136
139
  x = _overlay$getBoundingC.x,
137
140
  y = _overlay$getBoundingC.y;
@@ -1,6 +1,31 @@
1
+ /**
2
+ * Copyright IBM Corp. 2023, 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
+ import React from 'react';
8
+ interface CoachmarkTaglineProps {
9
+ /**
10
+ * Tooltip text and aria label for the Close button icon.
11
+ */
12
+ closeIconDescription?: string;
13
+ /**
14
+ * Function to call when the close button is clicked.
15
+ */
16
+ onClose?: () => void;
17
+ /**
18
+ * Determines the theme of the component.
19
+ */
20
+ theme?: 'light' | 'dark';
21
+ /**
22
+ * The title of the tagline.
23
+ */
24
+ title: string;
25
+ }
1
26
  /**
2
27
  * DO NOT USE. This component is for the exclusive use
3
28
  * of other Novice to Pro components.
4
29
  */
5
- export let CoachmarkTagline: React.ForwardRefExoticComponent<React.RefAttributes<any>>;
6
- import React from 'react';
30
+ export declare let CoachmarkTagline: React.ForwardRefExoticComponent<CoachmarkTaglineProps & React.RefAttributes<HTMLDivElement>>;
31
+ export {};
@@ -35,7 +35,6 @@ var defaults = {
35
35
  onClose: function onClose() {},
36
36
  theme: 'light'
37
37
  };
38
-
39
38
  /**
40
39
  * DO NOT USE. This component is for the exclusive use
41
40
  * of other Novice to Pro components.
@@ -11,27 +11,27 @@ export declare enum BEACON_KIND {
11
11
  * @param FIXED is fixed to the bottom-right of the viewport.
12
12
  * @param STACKED is fixed to the bottom-right of the viewport, includes links to show more, stackable Coachmarks if included.
13
13
  */
14
- export declare const COACHMARK_OVERLAY_KIND: {
15
- TOOLTIP: string;
16
- FLOATING: string;
17
- FIXED: string;
18
- STACKED: string;
19
- };
14
+ export declare enum COACHMARK_OVERLAY_KIND {
15
+ TOOLTIP = "tooltip",
16
+ FLOATING = "floating",
17
+ FIXED = "fixed",
18
+ STACKED = "stacked"
19
+ }
20
20
  /**
21
21
  * Where to render the Coachmark relative to its target.
22
22
  * Applies only to Floating and Tooltip Coachmarks.
23
23
  */
24
- export declare const COACHMARK_ALIGNMENT: {
25
- BOTTOM: string;
26
- BOTTOM_LEFT: string;
27
- BOTTOM_RIGHT: string;
28
- LEFT: string;
29
- LEFT_TOP: string;
30
- LEFT_BOTTOM: string;
31
- RIGHT: string;
32
- RIGHT_TOP: string;
33
- RIGHT_BOTTOM: string;
34
- TOP: string;
35
- TOP_LEFT: string;
36
- TOP_RIGHT: string;
37
- };
24
+ export declare enum COACHMARK_ALIGNMENT {
25
+ BOTTOM = "bottom",
26
+ BOTTOM_LEFT = "bottom-left",
27
+ BOTTOM_RIGHT = "bottom-right",
28
+ LEFT = "left",
29
+ LEFT_TOP = "left-top",
30
+ LEFT_BOTTOM = "left-bottom",
31
+ RIGHT = "right",
32
+ RIGHT_TOP = "right-top",
33
+ RIGHT_BOTTOM = "right-bottom",
34
+ TOP = "top",
35
+ TOP_LEFT = "top-left",
36
+ TOP_RIGHT = "top-right"
37
+ }
@@ -18,30 +18,32 @@ Object.defineProperty(exports, '__esModule', { value: true });
18
18
  * @param FIXED is fixed to the bottom-right of the viewport.
19
19
  * @param STACKED is fixed to the bottom-right of the viewport, includes links to show more, stackable Coachmarks if included.
20
20
  */
21
- var COACHMARK_OVERLAY_KIND = {
22
- TOOLTIP: 'tooltip',
23
- FLOATING: 'floating',
24
- FIXED: 'fixed',
25
- STACKED: 'stacked'
26
- };
21
+ var COACHMARK_OVERLAY_KIND = /*#__PURE__*/function (COACHMARK_OVERLAY_KIND) {
22
+ COACHMARK_OVERLAY_KIND["TOOLTIP"] = "tooltip";
23
+ COACHMARK_OVERLAY_KIND["FLOATING"] = "floating";
24
+ COACHMARK_OVERLAY_KIND["FIXED"] = "fixed";
25
+ COACHMARK_OVERLAY_KIND["STACKED"] = "stacked";
26
+ return COACHMARK_OVERLAY_KIND;
27
+ }({});
27
28
  /**
28
29
  * Where to render the Coachmark relative to its target.
29
30
  * Applies only to Floating and Tooltip Coachmarks.
30
31
  */
31
- var COACHMARK_ALIGNMENT = {
32
- BOTTOM: 'bottom',
33
- BOTTOM_LEFT: 'bottom-left',
34
- BOTTOM_RIGHT: 'bottom-right',
35
- LEFT: 'left',
36
- LEFT_TOP: 'left-top',
37
- LEFT_BOTTOM: 'left-bottom',
38
- RIGHT: 'right',
39
- RIGHT_TOP: 'right-top',
40
- RIGHT_BOTTOM: 'right-bottom',
41
- TOP: 'top',
42
- TOP_LEFT: 'top-left',
43
- TOP_RIGHT: 'top-right'
44
- };
32
+ var COACHMARK_ALIGNMENT = /*#__PURE__*/function (COACHMARK_ALIGNMENT) {
33
+ COACHMARK_ALIGNMENT["BOTTOM"] = "bottom";
34
+ COACHMARK_ALIGNMENT["BOTTOM_LEFT"] = "bottom-left";
35
+ COACHMARK_ALIGNMENT["BOTTOM_RIGHT"] = "bottom-right";
36
+ COACHMARK_ALIGNMENT["LEFT"] = "left";
37
+ COACHMARK_ALIGNMENT["LEFT_TOP"] = "left-top";
38
+ COACHMARK_ALIGNMENT["LEFT_BOTTOM"] = "left-bottom";
39
+ COACHMARK_ALIGNMENT["RIGHT"] = "right";
40
+ COACHMARK_ALIGNMENT["RIGHT_TOP"] = "right-top";
41
+ COACHMARK_ALIGNMENT["RIGHT_BOTTOM"] = "right-bottom";
42
+ COACHMARK_ALIGNMENT["TOP"] = "top";
43
+ COACHMARK_ALIGNMENT["TOP_LEFT"] = "top-left";
44
+ COACHMARK_ALIGNMENT["TOP_RIGHT"] = "top-right";
45
+ return COACHMARK_ALIGNMENT;
46
+ }({});
45
47
 
46
48
  exports.COACHMARK_ALIGNMENT = COACHMARK_ALIGNMENT;
47
49
  exports.COACHMARK_OVERLAY_KIND = COACHMARK_OVERLAY_KIND;
@@ -1,8 +1,48 @@
1
+ /**
2
+ * Copyright IBM Corp. 2023, 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
+ import React, { ReactNode } from 'react';
8
+ interface CoachmarkFixedProps {
9
+ /**
10
+ * CoachmarkFixed should use a single CoachmarkOverlayElements component as a child.
11
+ */
12
+ children: ReactNode;
13
+ /**
14
+ * Optional class name for this component.
15
+ */
16
+ className?: string;
17
+ /**
18
+ * Function to call when the Coachmark closes.
19
+ */
20
+ onClose?: () => void;
21
+ /**
22
+ * By default, the Coachmark will be appended to the end of `document.body`.
23
+ * The Coachmark will remain persistent as the user navigates the app until
24
+ * the user closes the Coachmark.
25
+ *
26
+ * Alternatively, the app developer can tightly couple the Coachmark to a DOM
27
+ * element or other component by specifying a CSS selector. The Coachmark will
28
+ * remain visible as long as that element remains visible or mounted. When the
29
+ * element is hidden or component is unmounted, the Coachmark will disappear.
30
+ */
31
+ portalTarget?: string;
32
+ /**
33
+ * The tagline title which will be fixed to the bottom right of the window and will serve as the display trigger.
34
+ */
35
+ tagline: string;
36
+ /**
37
+ * Determines the theme of the component.
38
+ */
39
+ theme?: 'light' | 'dark';
40
+ }
1
41
  /**
2
42
  * Fixed coachmarks are used to call out specific functionality or concepts
3
43
  * within the UI that may not be intuitive but are important for the
4
44
  * user to gain understanding of the product's main value and discover new use cases.
5
45
  * This variant allows the a coachmark overlay to be displayed by interacting with the tagline.
6
46
  */
7
- export let CoachmarkFixed: React.ForwardRefExoticComponent<React.RefAttributes<any>>;
8
- import React from 'react';
47
+ export declare let CoachmarkFixed: React.ForwardRefExoticComponent<CoachmarkFixedProps & React.RefAttributes<HTMLDivElement>>;
48
+ export {};
@@ -59,7 +59,7 @@ exports.CoachmarkFixed = /*#__PURE__*/React__default["default"].forwardRef(funct
59
59
  _ref$theme = _ref.theme,
60
60
  theme = _ref$theme === void 0 ? defaults.theme : _ref$theme,
61
61
  rest = _rollupPluginBabelHelpers.objectWithoutProperties(_ref, _excluded);
62
- var overlayRef = React.useRef();
62
+ var overlayRef = React.useRef(null);
63
63
  var portalNode = portalTarget ? (_document$querySelect = document.querySelector(portalTarget)) !== null && _document$querySelect !== void 0 ? _document$querySelect : document.querySelector('body') : document.querySelector('body');
64
64
  var _useState = React.useState(false),
65
65
  _useState2 = _rollupPluginBabelHelpers.slicedToArray(_useState, 2),
@@ -181,7 +181,9 @@ exports.CoachmarkFixed = /*#__PURE__*/React__default["default"].forwardRef(funct
181
181
  onTransitionEnd: handleTransitionEnd,
182
182
  theme: theme,
183
183
  className: cx__default["default"](fixedIsVisible && "".concat(overlayBlockClass, "--is-visible"), overlayBlockClass)
184
- }, children), portalNode)));
184
+ }, children),
185
+ // Default to `document.body` when `portalNode` is `null`
186
+ portalNode || document.body)));
185
187
  });
186
188
 
187
189
  // Return a placeholder if not released and not enabled by feature flag
@@ -7,15 +7,16 @@ declare namespace ConditionBlock {
7
7
  namespace propTypes {
8
8
  let addConditionHandler: PropTypes.Requireable<(...args: any[]) => any>;
9
9
  let aria: PropTypes.Requireable<object>;
10
+ let condition: PropTypes.Requireable<object>;
10
11
  let conditionIndex: PropTypes.Requireable<number>;
11
12
  let conjunction: PropTypes.Requireable<string>;
12
13
  let group: PropTypes.Requireable<object>;
14
+ let isLastCondition: PropTypes.Requireable<(...args: any[]) => any>;
13
15
  let isStatement: PropTypes.Requireable<boolean>;
14
16
  let onChange: PropTypes.Requireable<(...args: any[]) => any>;
15
17
  let onConnectorOperatorChange: PropTypes.Requireable<(...args: any[]) => any>;
16
18
  let onRemove: PropTypes.Requireable<(...args: any[]) => any>;
17
19
  let onStatementChange: PropTypes.Requireable<(...args: any[]) => any>;
18
- let state: PropTypes.Requireable<object>;
19
20
  }
20
21
  }
21
22
  import PropTypes from 'prop-types';
@@ -37,20 +37,21 @@ var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
37
37
  */
38
38
 
39
39
  var ConditionBlock = function ConditionBlock(props) {
40
- var _props$state = props.state,
41
- property = _props$state.property,
42
- value = _props$state.value,
43
- operator = _props$state.operator;
40
+ var _props$condition = props.condition,
41
+ property = _props$condition.property,
42
+ value = _props$condition.value,
43
+ operator = _props$condition.operator;
44
44
  var onRemove = props.onRemove,
45
45
  onChange = props.onChange,
46
- state = props.state,
46
+ condition = props.condition,
47
47
  conjunction = props.conjunction,
48
48
  onConnectorOperatorChange = props.onConnectorOperatorChange,
49
49
  isStatement = props.isStatement,
50
50
  group = props.group,
51
51
  onStatementChange = props.onStatementChange,
52
52
  addConditionHandler = props.addConditionHandler,
53
- conditionIndex = props.conditionIndex;
53
+ conditionIndex = props.conditionIndex,
54
+ isLastCondition = props.isLastCondition;
54
55
  var _useContext = React.useContext(ConditionBuilderProvider.ConditionBuilderContext),
55
56
  inputConfig = _useContext.inputConfig;
56
57
  var itemComponents = {
@@ -69,13 +70,9 @@ var ConditionBlock = function ConditionBlock(props) {
69
70
  var getCurrentConfig = function getCurrentConfig(property) {
70
71
  var _inputConfig$properti, _inputConfig$properti2;
71
72
  return (_inputConfig$properti = (_inputConfig$properti2 = inputConfig.properties) === null || _inputConfig$properti2 === void 0 ? void 0 : _inputConfig$properti2.filter(function (eachProperty) {
72
- var _eachProperty$label;
73
- return ((_eachProperty$label = eachProperty.label) === null || _eachProperty$label === void 0 ? void 0 : _eachProperty$label.toUpperCase()) == (property === null || property === void 0 ? void 0 : property.toUpperCase());
73
+ return eachProperty.id == property;
74
74
  })[0]) !== null && _inputConfig$properti !== void 0 ? _inputConfig$properti : {};
75
75
  };
76
- var isLastCondition = function isLastCondition(conditionIndex, conditionArr) {
77
- return conditionIndex + 1 >= conditionArr.length || conditionArr.length - 1 != conditionIndex && conditionArr[conditionIndex + 1].conditions;
78
- };
79
76
  var _getCurrentConfig = getCurrentConfig(property),
80
77
  icon = _getCurrentConfig.icon,
81
78
  type = _getCurrentConfig.type,
@@ -90,7 +87,7 @@ var ConditionBlock = function ConditionBlock(props) {
90
87
  onConnectorOperatorChange(op);
91
88
  };
92
89
  var onPropertyChangeHandler = function onPropertyChangeHandler(newProperty) {
93
- onChange(_rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, state), {}, {
90
+ onChange(_rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, condition), {}, {
94
91
  property: newProperty,
95
92
  operator: undefined,
96
93
  value: '',
@@ -98,14 +95,14 @@ var ConditionBlock = function ConditionBlock(props) {
98
95
  }));
99
96
  };
100
97
  var onOperatorChangeHandler = function onOperatorChangeHandler(newOperator) {
101
- onChange(_rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, state), {}, {
98
+ onChange(_rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, condition), {}, {
102
99
  operator: newOperator,
103
100
  value: undefined,
104
101
  popoverToOpen: 'valueField'
105
102
  }));
106
103
  };
107
104
  var onValueChangeHandler = function onValueChangeHandler(newValue) {
108
- onChange(_rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, state), {}, {
105
+ onChange(_rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, condition), {}, {
109
106
  value: newValue,
110
107
  popoverToOpen: ''
111
108
  }));
@@ -134,7 +131,8 @@ var ConditionBlock = function ConditionBlock(props) {
134
131
  title: DataConfigs.translateWithId('condition'),
135
132
  "data-name": "connectorField",
136
133
  popOverClassName: "".concat(DataConfigs.blockClass, "__gap"),
137
- className: "".concat(DataConfigs.blockClass, "__statement-button")
134
+ className: "".concat(DataConfigs.blockClass, "__statement-button"),
135
+ tabIndex: 0
138
136
  }, /*#__PURE__*/React__default["default"].createElement(ConditionBuilderItemOption.ConditionBuilderItemOption, {
139
137
  conditionState: {
140
138
  value: group.statement,
@@ -154,7 +152,7 @@ var ConditionBlock = function ConditionBlock(props) {
154
152
  renderIcon: icon !== null && icon !== void 0 ? icon : null,
155
153
  className: "".concat(DataConfigs.blockClass, "__property-field"),
156
154
  "data-name": "propertyField",
157
- state: state,
155
+ condition: condition,
158
156
  type: type
159
157
  }, /*#__PURE__*/React__default["default"].createElement(ConditionBuilderItemOption.ConditionBuilderItemOption, {
160
158
  conditionState: {
@@ -169,7 +167,7 @@ var ConditionBlock = function ConditionBlock(props) {
169
167
  label: operator,
170
168
  title: DataConfigs.translateWithId('operator'),
171
169
  "data-name": "operatorField",
172
- state: state,
170
+ condition: condition,
173
171
  type: type
174
172
  }, /*#__PURE__*/React__default["default"].createElement(ConditionBuilderItemOption.ConditionBuilderItemOption, {
175
173
  config: {
@@ -186,7 +184,7 @@ var ConditionBlock = function ConditionBlock(props) {
186
184
  title: label,
187
185
  showToolTip: true,
188
186
  "data-name": "valueField",
189
- state: state,
187
+ condition: condition,
190
188
  config: config
191
189
  }, /*#__PURE__*/React__default["default"].createElement(ItemComponent, {
192
190
  conditionState: {
@@ -229,6 +227,10 @@ ConditionBlock.propTypes = {
229
227
  * object hold aria attributes
230
228
  */
231
229
  aria: index["default"].object,
230
+ /**
231
+ * object that hold the current condition
232
+ */
233
+ condition: index["default"].object,
232
234
  /**
233
235
  * index of the current condition
234
236
  */
@@ -241,6 +243,10 @@ ConditionBlock.propTypes = {
241
243
  * object that hold the current group object where is condition is part of
242
244
  */
243
245
  group: index["default"].object,
246
+ /**
247
+ * callback to add a new condition
248
+ */
249
+ isLastCondition: index["default"].func,
244
250
  /**
245
251
  * boolean that decides to show the statement(if/ excl.if)
246
252
  */
@@ -260,11 +266,7 @@ ConditionBlock.propTypes = {
260
266
  /**
261
267
  * callback to handle the statement(if/ excl.if) change
262
268
  */
263
- onStatementChange: index["default"].func,
264
- /**
265
- * object that hold the current condition
266
- */
267
- state: index["default"].object
269
+ onStatementChange: index["default"].func
268
270
  };
269
271
 
270
272
  exports["default"] = ConditionBlock$1;
@@ -33,13 +33,13 @@ var ConditionBuilderButton = function ConditionBuilderButton(_ref) {
33
33
  showToolTip = _ref.showToolTip,
34
34
  rest = _rollupPluginBabelHelpers.objectWithoutProperties(_ref, _excluded);
35
35
  var Button = function Button() {
36
- return /*#__PURE__*/React__default["default"].createElement("button", _rollupPluginBabelHelpers["extends"]({}, rest, {
36
+ return /*#__PURE__*/React__default["default"].createElement("button", _rollupPluginBabelHelpers["extends"]({
37
37
  // role={'gridcell'}
38
38
  tabIndex: -1,
39
39
  className: cx__default["default"]([className, "".concat(DataConfigs.blockClass, "__condition-builder-button"), _rollupPluginBabelHelpers.defineProperty({}, "".concat(DataConfigs.blockClass, "__text-ellipsis"), showToolTip && !hideLabel)]),
40
40
  type: "button",
41
41
  onClick: onClick
42
- }), Icon && (_Icon || (_Icon = /*#__PURE__*/React__default["default"].createElement(Icon, null))), !hideLabel && label);
42
+ }, rest), Icon && (_Icon || (_Icon = /*#__PURE__*/React__default["default"].createElement(Icon, null))), !hideLabel && label);
43
43
  };
44
44
  return hideLabel || showToolTip ? /*#__PURE__*/React__default["default"].createElement(react.Tooltip, _rollupPluginBabelHelpers["extends"]({
45
45
  label: label,
@@ -31,16 +31,16 @@ var ConditionBuilderContent = function ConditionBuilderContent(_ref) {
31
31
  var _useContext = React.useContext(ConditionBuilderProvider.ConditionBuilderContext),
32
32
  rootState = _useContext.rootState,
33
33
  setRootState = _useContext.setRootState;
34
- var _useState = React.useState(true),
34
+ var _useState = React.useState(false),
35
35
  _useState2 = _rollupPluginBabelHelpers.slicedToArray(_useState, 2),
36
36
  isConditionBuilderActive = _useState2[0],
37
37
  setIsConditionBuilderActive = _useState2[1];
38
38
  React.useEffect(function () {
39
39
  var _rootState$groups;
40
40
  if (rootState !== null && rootState !== void 0 && (_rootState$groups = rootState.groups) !== null && _rootState$groups !== void 0 && _rootState$groups.length) {
41
- setIsConditionBuilderActive(false);
42
- } else {
43
41
  setIsConditionBuilderActive(true);
42
+ } else {
43
+ setIsConditionBuilderActive(false);
44
44
  }
45
45
  if (getConditionState) {
46
46
  getConditionState(rootState);
@@ -48,26 +48,16 @@ var ConditionBuilderContent = function ConditionBuilderContent(_ref) {
48
48
 
49
49
  // eslint-disable-next-line react-hooks/exhaustive-deps
50
50
  }, [rootState, conditionBuilderRef]);
51
- React.useEffect(function () {
52
- if (isConditionBuilderActive == false) {
53
- if (conditionBuilderRef.current) {
54
- var initial = conditionBuilderRef.current.querySelector('[role="gridcell"] button');
55
- if (initial) {
56
- initial.setAttribute('tabindex', '0');
57
- }
58
- }
59
- }
60
- }, [isConditionBuilderActive, conditionBuilderRef]);
61
51
  var onStartConditionBuilder = function onStartConditionBuilder() {
62
52
  //when add condition button is clicked.
63
- setIsConditionBuilderActive(false);
53
+ setIsConditionBuilderActive(true);
64
54
  setRootState(initialState !== null && initialState !== void 0 ? initialState : ConditionBuilderProvider.emptyState); //here we can set an empty skeleton object for an empty condition builder,
65
55
  //or we can even pre-populate some existing builder and continue editing
66
56
  };
67
- var _onRemove = React.useCallback(function (groupIndex) {
57
+ var _onRemove = React.useCallback(function (groupId) {
68
58
  setRootState(_rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, rootState), {}, {
69
- groups: rootState.groups.filter(function (group, gIndex) {
70
- return groupIndex !== gIndex;
59
+ groups: rootState.groups.filter(function (group) {
60
+ return groupId !== group.id;
71
61
  })
72
62
  }));
73
63
  }, [setRootState, rootState]);
@@ -76,16 +66,15 @@ var ConditionBuilderContent = function ConditionBuilderContent(_ref) {
76
66
  * This method is triggered from inner components. This will be called every time when any change is to be updated in the rootState.
77
67
  * This gets the updated group as argument.
78
68
  */
69
+ var groups = [].concat(_rollupPluginBabelHelpers.toConsumableArray(rootState.groups.slice(0, groupIndex)), [updatedGroup], _rollupPluginBabelHelpers.toConsumableArray(rootState.groups.slice(groupIndex + 1)));
79
70
  setRootState(_rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, rootState), {}, {
80
- groups: rootState.groups.map(function (group, gIndex) {
81
- return groupIndex === gIndex ? updatedGroup : group;
82
- })
71
+ groups: groups
83
72
  }));
84
73
  };
85
74
  return /*#__PURE__*/React__default["default"].createElement("div", {
86
75
  className: "".concat(DataConfigs.blockClass, "__content-container"),
87
76
  tabIndex: -1
88
- }, isConditionBuilderActive && /*#__PURE__*/React__default["default"].createElement(react.Button, {
77
+ }, !isConditionBuilderActive && /*#__PURE__*/React__default["default"].createElement(react.Button, {
89
78
  className: "".concat(DataConfigs.blockClass, "__condition-builder"),
90
79
  renderIcon: function renderIcon(props) {
91
80
  return /*#__PURE__*/React__default["default"].createElement(icons.Add, _rollupPluginBabelHelpers["extends"]({
@@ -98,15 +87,16 @@ var ConditionBuilderContent = function ConditionBuilderContent(_ref) {
98
87
  onClick: onStartConditionBuilder
99
88
  }, startConditionLabel), rootState && (rootState === null || rootState === void 0 || (_rootState$groups2 = rootState.groups) === null || _rootState$groups2 === void 0 ? void 0 : _rootState$groups2.map(function (eachGroup, groupIndex) {
100
89
  return /*#__PURE__*/React__default["default"].createElement(ConditionGroupBuilder["default"], {
90
+ className: "".concat(DataConfigs.blockClass, "__condition-builder__group"),
101
91
  key: groupIndex,
102
92
  aria: {
103
93
  level: 1,
104
94
  posinset: groupIndex * 2 + 1,
105
95
  setsize: rootState.groups.length * 2
106
96
  },
107
- state: eachGroup,
97
+ group: eachGroup,
108
98
  onRemove: function onRemove() {
109
- _onRemove(groupIndex);
99
+ _onRemove(eachGroup.id);
110
100
  },
111
101
  onChange: function onChange(updatedGroup) {
112
102
  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
  }
@@ -12,6 +12,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
12
12
  var _rollupPluginBabelHelpers = require('../../../_virtual/_rollupPluginBabelHelpers.js');
13
13
  var React = require('react');
14
14
  var index = require('../../../node_modules/prop-types/index.js');
15
+ var uuidv4 = require('../../../global/js/utils/uuidv4.js');
15
16
 
16
17
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
17
18
 
@@ -22,11 +23,13 @@ var emptyState = {
22
23
  groupSeparateOperator: null,
23
24
  groupOperator: 'and',
24
25
  statement: 'if',
26
+ id: uuidv4["default"](),
25
27
  conditions: [{
26
28
  property: undefined,
27
29
  operator: '',
28
30
  value: '',
29
- popoverToOpen: 'propertyField'
31
+ popoverToOpen: 'propertyField',
32
+ id: uuidv4["default"]()
30
33
  }]
31
34
  }]
32
35
  };
@@ -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
  }