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

Sign up to get free protection for your applications and to get access to all the features.
Files changed (182) hide show
  1. package/css/index-full-carbon.css +5404 -5117
  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-released-only.css +4 -4
  6. package/css/index-without-carbon-released-only.css.map +1 -1
  7. package/css/index-without-carbon-released-only.min.css +1 -1
  8. package/css/index-without-carbon-released-only.min.css.map +1 -1
  9. package/css/index-without-carbon.css +820 -61
  10. package/css/index-without-carbon.css.map +1 -1
  11. package/css/index-without-carbon.min.css +1 -1
  12. package/css/index-without-carbon.min.css.map +1 -1
  13. package/css/index.css +329 -6
  14. package/css/index.css.map +1 -1
  15. package/css/index.min.css +1 -1
  16. package/css/index.min.css.map +1 -1
  17. package/es/_virtual/_rollupPluginBabelHelpers.js +9 -10
  18. package/es/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.d.ts +3 -1
  19. package/es/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.js +8 -2
  20. package/es/components/ConditionBuilder/ConditionBlock/ConditionBlock.d.ts +21 -0
  21. package/es/components/ConditionBuilder/ConditionBlock/ConditionBlock.js +261 -0
  22. package/es/components/ConditionBuilder/ConditionBuilder.js +45 -16
  23. package/es/components/ConditionBuilder/ConditionBuilderAdd/ConditionBuilderAdd.d.ts +12 -0
  24. package/es/components/ConditionBuilder/ConditionBuilderAdd/ConditionBuilderAdd.js +40 -0
  25. package/es/components/ConditionBuilder/ConditionBuilderButton/ConditionBuilderButton.d.ts +22 -0
  26. package/es/components/ConditionBuilder/ConditionBuilderButton/ConditionBuilderButton.js +74 -0
  27. package/es/components/ConditionBuilder/ConditionBuilderContent/ConditionBuilderContent.d.ts +18 -1
  28. package/es/components/ConditionBuilder/ConditionBuilderContent/ConditionBuilderContent.js +90 -42
  29. package/es/components/ConditionBuilder/ConditionBuilderContext/{DataTreeContext.d.ts → ConditionBuilderProvider.d.ts} +5 -2
  30. package/es/components/ConditionBuilder/ConditionBuilderContext/{DataTreeContext.js → ConditionBuilderProvider.js} +27 -8
  31. package/es/components/ConditionBuilder/ConditionBuilderContext/DataConfigs.d.ts +22 -0
  32. package/es/components/ConditionBuilder/ConditionBuilderContext/DataConfigs.js +112 -0
  33. package/es/components/ConditionBuilder/ConditionBuilderContext/translationObject.d.ts +31 -0
  34. package/es/components/ConditionBuilder/ConditionBuilderContext/translationObject.js +40 -0
  35. package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItem.d.ts +28 -0
  36. package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItem.js +151 -0
  37. package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemDate/ConditionBuilderItemDate.d.ts +11 -0
  38. package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemDate/ConditionBuilderItemDate.js +59 -0
  39. package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemNumber/ConditionBuilderItemNumber.d.ts +13 -0
  40. package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemNumber/ConditionBuilderItemNumber.js +52 -0
  41. package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemOption/ConditionBuilderItemOption.d.ts +13 -0
  42. package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemOption/ConditionBuilderItemOption.js +162 -0
  43. package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemText/ConditionBuilderItemText.d.ts +11 -0
  44. package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemText/ConditionBuilderItemText.js +40 -0
  45. package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemTime/ConditionBuilderItemTime.d.ts +11 -0
  46. package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemTime/ConditionBuilderItemTime.js +82 -0
  47. package/es/components/ConditionBuilder/ConditionConnector/ConditionConnector.d.ts +15 -0
  48. package/es/components/ConditionBuilder/ConditionConnector/ConditionConnector.js +85 -0
  49. package/es/components/ConditionBuilder/ConditionGroupBuilder/ConditionGroupBuilder.d.ts +24 -0
  50. package/es/components/ConditionBuilder/ConditionGroupBuilder/ConditionGroupBuilder.js +145 -0
  51. package/es/components/ConditionBuilder/utils/util.d.ts +4 -0
  52. package/es/components/ConditionBuilder/utils/util.js +16 -0
  53. package/es/components/CreateTearsheet/CreateTearsheet.d.ts +106 -4
  54. package/es/components/CreateTearsheet/CreateTearsheet.js +12 -32
  55. package/es/components/Datagrid/Datagrid/DatagridContent.d.ts +1 -0
  56. package/es/components/Datagrid/Datagrid/DatagridContent.js +1 -0
  57. package/es/components/Datagrid/useParentDimensions.js +1 -1
  58. package/es/components/Datagrid/useSkeletonRows.d.ts +1 -1
  59. package/es/components/Datagrid/useSkeletonRows.js +11 -3
  60. package/es/components/EditUpdateCards/EditUpdateCards.d.ts +104 -2
  61. package/es/components/EditUpdateCards/EditUpdateCards.js +3 -0
  62. package/es/components/EmptyStates/NotificationsEmptyState/NotificationsEmptyState.d.ts +61 -2
  63. package/es/components/EmptyStates/NotificationsEmptyState/NotificationsEmptyState.js +1 -3
  64. package/es/components/ExpressiveCard/ExpressiveCard.d.ts +97 -2
  65. package/es/components/ExpressiveCard/ExpressiveCard.js +4 -0
  66. package/es/components/InlineTip/InlineTipButton.d.ts +21 -2
  67. package/es/components/InterstitialScreen/InterstitialScreen.d.ts +100 -2
  68. package/es/components/InterstitialScreen/InterstitialScreen.js +25 -14
  69. package/es/components/Nav/NavItem.js +1 -1
  70. package/es/components/NotificationsPanel/NotificationsPanel.js +5 -6
  71. package/es/components/PageHeader/PageHeader.js +12 -3
  72. package/es/components/SidePanel/SidePanel.js +1 -1
  73. package/es/components/SimpleHeader/SimpleHeader.d.ts +1 -5
  74. package/es/components/SimpleHeader/SimpleHeader.js +2 -4
  75. package/es/components/Tearsheet/TearsheetNarrow.d.ts +4 -13
  76. package/es/components/Tearsheet/TearsheetShell.d.ts +119 -10
  77. package/es/components/Tearsheet/TearsheetShell.js +18 -8
  78. package/es/components/WebTerminal/WebTerminal.d.ts +46 -2
  79. package/es/components/WebTerminal/WebTerminal.js +2 -2
  80. package/es/global/js/hooks/usePrefersReducedMotion.d.ts +2 -0
  81. package/es/global/js/hooks/usePrefersReducedMotion.js +28 -0
  82. package/es/global/js/utils/Wrap.d.ts +31 -2
  83. package/es/global/js/utils/Wrap.js +7 -9
  84. package/es/global/js/utils/getNodeTextContent.d.ts +1 -1
  85. package/es/global/js/utils/getNodeTextContent.js +1 -1
  86. package/es/global/js/utils/window.d.ts +2 -0
  87. package/es/global/js/utils/window.js +12 -0
  88. package/es/node_modules/@carbon/icons-react/es/generated/bucket-9.js +2780 -0
  89. package/lib/_virtual/_rollupPluginBabelHelpers.js +9 -10
  90. package/lib/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.d.ts +3 -1
  91. package/lib/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.js +8 -2
  92. package/lib/components/ConditionBuilder/ConditionBlock/ConditionBlock.d.ts +21 -0
  93. package/lib/components/ConditionBuilder/ConditionBlock/ConditionBlock.js +270 -0
  94. package/lib/components/ConditionBuilder/ConditionBuilder.js +46 -17
  95. package/lib/components/ConditionBuilder/ConditionBuilderAdd/ConditionBuilderAdd.d.ts +12 -0
  96. package/lib/components/ConditionBuilder/ConditionBuilderAdd/ConditionBuilderAdd.js +48 -0
  97. package/lib/components/ConditionBuilder/ConditionBuilderButton/ConditionBuilderButton.d.ts +22 -0
  98. package/lib/components/ConditionBuilder/ConditionBuilderButton/ConditionBuilderButton.js +83 -0
  99. package/lib/components/ConditionBuilder/ConditionBuilderContent/ConditionBuilderContent.d.ts +18 -1
  100. package/lib/components/ConditionBuilder/ConditionBuilderContent/ConditionBuilderContent.js +90 -42
  101. package/lib/components/ConditionBuilder/ConditionBuilderContext/{DataTreeContext.d.ts → ConditionBuilderProvider.d.ts} +5 -2
  102. package/lib/components/ConditionBuilder/ConditionBuilderContext/{DataTreeContext.js → ConditionBuilderProvider.js} +27 -8
  103. package/lib/components/ConditionBuilder/ConditionBuilderContext/DataConfigs.d.ts +22 -0
  104. package/lib/components/ConditionBuilder/ConditionBuilderContext/DataConfigs.js +121 -0
  105. package/lib/components/ConditionBuilder/ConditionBuilderContext/translationObject.d.ts +31 -0
  106. package/lib/components/ConditionBuilder/ConditionBuilderContext/translationObject.js +44 -0
  107. package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItem.d.ts +28 -0
  108. package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItem.js +159 -0
  109. package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemDate/ConditionBuilderItemDate.d.ts +11 -0
  110. package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemDate/ConditionBuilderItemDate.js +67 -0
  111. package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemNumber/ConditionBuilderItemNumber.d.ts +13 -0
  112. package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemNumber/ConditionBuilderItemNumber.js +60 -0
  113. package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemOption/ConditionBuilderItemOption.d.ts +13 -0
  114. package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemOption/ConditionBuilderItemOption.js +170 -0
  115. package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemText/ConditionBuilderItemText.d.ts +11 -0
  116. package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemText/ConditionBuilderItemText.js +48 -0
  117. package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemTime/ConditionBuilderItemTime.d.ts +11 -0
  118. package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemTime/ConditionBuilderItemTime.js +90 -0
  119. package/lib/components/ConditionBuilder/ConditionConnector/ConditionConnector.d.ts +15 -0
  120. package/lib/components/ConditionBuilder/ConditionConnector/ConditionConnector.js +93 -0
  121. package/lib/components/ConditionBuilder/ConditionGroupBuilder/ConditionGroupBuilder.d.ts +24 -0
  122. package/lib/components/ConditionBuilder/ConditionGroupBuilder/ConditionGroupBuilder.js +153 -0
  123. package/lib/components/ConditionBuilder/utils/util.d.ts +4 -0
  124. package/lib/components/ConditionBuilder/utils/util.js +20 -0
  125. package/lib/components/CreateTearsheet/CreateTearsheet.d.ts +106 -4
  126. package/lib/components/CreateTearsheet/CreateTearsheet.js +12 -32
  127. package/lib/components/Datagrid/Datagrid/DatagridContent.d.ts +1 -0
  128. package/lib/components/Datagrid/Datagrid/DatagridContent.js +1 -0
  129. package/lib/components/Datagrid/useParentDimensions.js +1 -1
  130. package/lib/components/Datagrid/useSkeletonRows.d.ts +1 -1
  131. package/lib/components/Datagrid/useSkeletonRows.js +11 -3
  132. package/lib/components/EditUpdateCards/EditUpdateCards.d.ts +104 -2
  133. package/lib/components/EditUpdateCards/EditUpdateCards.js +3 -0
  134. package/lib/components/EmptyStates/NotificationsEmptyState/NotificationsEmptyState.d.ts +61 -2
  135. package/lib/components/EmptyStates/NotificationsEmptyState/NotificationsEmptyState.js +1 -3
  136. package/lib/components/ExpressiveCard/ExpressiveCard.d.ts +97 -2
  137. package/lib/components/ExpressiveCard/ExpressiveCard.js +4 -0
  138. package/lib/components/InlineTip/InlineTipButton.d.ts +21 -2
  139. package/lib/components/InterstitialScreen/InterstitialScreen.d.ts +100 -2
  140. package/lib/components/InterstitialScreen/InterstitialScreen.js +24 -13
  141. package/lib/components/Nav/NavItem.js +2 -2
  142. package/lib/components/NotificationsPanel/NotificationsPanel.js +5 -6
  143. package/lib/components/PageHeader/PageHeader.js +11 -2
  144. package/lib/components/SidePanel/SidePanel.js +1 -1
  145. package/lib/components/SimpleHeader/SimpleHeader.d.ts +1 -5
  146. package/lib/components/SimpleHeader/SimpleHeader.js +2 -4
  147. package/lib/components/Tearsheet/TearsheetNarrow.d.ts +4 -13
  148. package/lib/components/Tearsheet/TearsheetShell.d.ts +119 -10
  149. package/lib/components/Tearsheet/TearsheetShell.js +16 -6
  150. package/lib/components/WebTerminal/WebTerminal.d.ts +46 -2
  151. package/lib/components/WebTerminal/WebTerminal.js +2 -2
  152. package/lib/global/js/hooks/usePrefersReducedMotion.d.ts +2 -0
  153. package/lib/global/js/hooks/usePrefersReducedMotion.js +32 -0
  154. package/lib/global/js/utils/Wrap.d.ts +31 -2
  155. package/lib/global/js/utils/Wrap.js +7 -9
  156. package/lib/global/js/utils/getNodeTextContent.d.ts +1 -1
  157. package/lib/global/js/utils/getNodeTextContent.js +1 -1
  158. package/lib/global/js/utils/window.d.ts +2 -0
  159. package/lib/global/js/utils/window.js +16 -0
  160. package/lib/node_modules/@carbon/icons-react/es/generated/bucket-9.js +2912 -0
  161. package/package.json +6 -4
  162. package/scss/components/CoachmarkOverlayElements/_coachmark-overlay-elements.scss +1 -1
  163. package/scss/components/ConditionBuilder/_condition-builder.scss +26 -0
  164. package/scss/components/ConditionBuilder/styles/_conditionBuilderCondition.scss +46 -0
  165. package/scss/components/ConditionBuilder/styles/_conditionBuilderItem.scss +194 -0
  166. package/scss/components/ConditionBuilder/styles/_index.scss +2 -0
  167. package/scss/components/Guidebanner/_guidebanner.scss +3 -0
  168. package/scss/components/InterstitialScreen/_interstitial-screen.scss +1 -6
  169. package/scss/components/Tearsheet/_tearsheet.scss +3 -1
  170. package/telemetry.yml +939 -683
  171. package/es/components/ConditionBuilder/assets/sampleInput.d.ts +0 -58
  172. package/es/global/js/utils/keyboardNavigation.d.ts +0 -27
  173. package/es/global/js/utils/keyboardNavigation.js +0 -33
  174. package/es/global/js/utils/wrapFocus.d.ts +0 -25
  175. package/es/global/js/utils/wrapFocus.js +0 -68
  176. package/es/node_modules/@carbon/icons-react/es/generated/bucket-8.js +0 -3004
  177. package/lib/components/ConditionBuilder/assets/sampleInput.d.ts +0 -58
  178. package/lib/global/js/utils/keyboardNavigation.d.ts +0 -27
  179. package/lib/global/js/utils/keyboardNavigation.js +0 -39
  180. package/lib/global/js/utils/wrapFocus.d.ts +0 -25
  181. package/lib/global/js/utils/wrapFocus.js +0 -73
  182. package/lib/node_modules/@carbon/icons-react/es/generated/bucket-8.js +0 -3136
@@ -0,0 +1,83 @@
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 React = require('react');
14
+ var cx = require('classnames');
15
+ var index = require('../../../node_modules/prop-types/index.js');
16
+ var react = require('@carbon/react');
17
+ var DataConfigs = require('../ConditionBuilderContext/DataConfigs.js');
18
+
19
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
20
+
21
+ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
22
+ var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
23
+
24
+ var _excluded = ["className", "label", "hideLabel", "tooltipAlign", "renderIcon", "onClick", "showToolTip"];
25
+ var ConditionBuilderButton = function ConditionBuilderButton(_ref) {
26
+ var _Icon;
27
+ var className = _ref.className,
28
+ label = _ref.label,
29
+ hideLabel = _ref.hideLabel,
30
+ tooltipAlign = _ref.tooltipAlign,
31
+ Icon = _ref.renderIcon,
32
+ onClick = _ref.onClick,
33
+ showToolTip = _ref.showToolTip,
34
+ rest = _rollupPluginBabelHelpers.objectWithoutProperties(_ref, _excluded);
35
+ var Button = function Button() {
36
+ return /*#__PURE__*/React__default["default"].createElement("button", _rollupPluginBabelHelpers["extends"]({}, rest, {
37
+ // role={'gridcell'}
38
+ tabIndex: -1,
39
+ className: cx__default["default"]([className, "".concat(DataConfigs.blockClass, "__condition-builder-button"), _rollupPluginBabelHelpers.defineProperty({}, "".concat(DataConfigs.blockClass, "__text-ellipsis"), showToolTip && !hideLabel)]),
40
+ type: "button",
41
+ onClick: onClick
42
+ }), Icon && (_Icon || (_Icon = /*#__PURE__*/React__default["default"].createElement(Icon, null))), !hideLabel && label);
43
+ };
44
+ return hideLabel || showToolTip ? /*#__PURE__*/React__default["default"].createElement(react.Tooltip, _rollupPluginBabelHelpers["extends"]({
45
+ label: label,
46
+ align: tooltipAlign,
47
+ className: "".concat(DataConfigs.blockClass, "__con-tooltip")
48
+ }, rest.wrapperProps), Button()) : /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, Button());
49
+ };
50
+ ConditionBuilderButton.propTypes = {
51
+ /**
52
+ * Provide an optional class to be applied to the containing node.
53
+ */
54
+ className: index["default"].string,
55
+ /**
56
+ * decides if label and tooltip to be hidden
57
+ */
58
+ hideLabel: index["default"].bool,
59
+ /**
60
+ * label of the button
61
+ */
62
+ label: index["default"].string,
63
+ /**
64
+ * callback triggered on click of add button
65
+ */
66
+ onClick: index["default"].func,
67
+ /**
68
+ * Optional prop to allow overriding the icon rendering.
69
+ */
70
+ renderIcon: index["default"].oneOfType([index["default"].func, index["default"].object]),
71
+ /**
72
+ */
73
+ /**
74
+ *decides if tooltip to be shown
75
+ */
76
+ showToolTip: index["default"].bool,
77
+ /**
78
+ * tooltip position
79
+ */
80
+ tooltipAlign: index["default"].string
81
+ };
82
+
83
+ exports.ConditionBuilderButton = ConditionBuilderButton;
@@ -1,9 +1,26 @@
1
1
  export default ConditionBuilderContent;
2
- declare function ConditionBuilderContent({ startConditionLabel }: {
2
+ declare function ConditionBuilderContent({ startConditionLabel, conditionBuilderRef, getConditionState, initialState, }: {
3
3
  startConditionLabel: any;
4
+ conditionBuilderRef: any;
5
+ getConditionState: any;
6
+ initialState: any;
4
7
  }): import("react/jsx-runtime").JSX.Element;
5
8
  declare namespace ConditionBuilderContent {
6
9
  namespace propTypes {
10
+ let conditionBuilderRef: PropTypes.Requireable<object>;
11
+ let getConditionState: PropTypes.Validator<(...args: any[]) => any>;
12
+ let initialState: PropTypes.Requireable<PropTypes.InferProps<{
13
+ groups: PropTypes.Requireable<(PropTypes.InferProps<{
14
+ groupSeparateOperator: PropTypes.Requireable<string>;
15
+ groupOperator: PropTypes.Requireable<string>;
16
+ statement: PropTypes.Requireable<string>;
17
+ conditions: PropTypes.Requireable<(PropTypes.InferProps<{
18
+ property: PropTypes.Requireable<string>;
19
+ operator: PropTypes.Requireable<string>;
20
+ value: PropTypes.Requireable<string>;
21
+ }> | null | undefined)[]>;
22
+ }> | null | undefined)[]>;
23
+ }>>;
7
24
  let startConditionLabel: PropTypes.Validator<string>;
8
25
  }
9
26
  }
@@ -11,53 +11,82 @@ Object.defineProperty(exports, '__esModule', { value: true });
11
11
 
12
12
  var _rollupPluginBabelHelpers = require('../../../_virtual/_rollupPluginBabelHelpers.js');
13
13
  var React = require('react');
14
- var settings = require('../../../settings.js');
15
14
  var index = require('../../../node_modules/prop-types/index.js');
16
15
  var react = require('@carbon/react');
17
16
  var icons = require('@carbon/react/icons');
18
- var DataTreeContext = require('../ConditionBuilderContext/DataTreeContext.js');
17
+ var ConditionGroupBuilder = require('../ConditionGroupBuilder/ConditionGroupBuilder.js');
18
+ var ConditionBuilderProvider = require('../ConditionBuilderContext/ConditionBuilderProvider.js');
19
+ var DataConfigs = require('../ConditionBuilderContext/DataConfigs.js');
19
20
 
20
21
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
21
22
 
22
23
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
23
24
 
24
- var blockClass = "".concat(settings.pkg.prefix, "--condition-builder");
25
- function ConditionBuilderContent(_ref) {
25
+ var ConditionBuilderContent = function ConditionBuilderContent(_ref) {
26
26
  var _rootState$groups2;
27
- var startConditionLabel = _ref.startConditionLabel;
28
- var _useContext = React.useContext(DataTreeContext.ConditionBuilderContext),
27
+ var startConditionLabel = _ref.startConditionLabel,
28
+ conditionBuilderRef = _ref.conditionBuilderRef,
29
+ getConditionState = _ref.getConditionState,
30
+ initialState = _ref.initialState;
31
+ var _useContext = React.useContext(ConditionBuilderProvider.ConditionBuilderContext),
29
32
  rootState = _useContext.rootState,
30
33
  setRootState = _useContext.setRootState;
31
34
  var _useState = React.useState(true),
32
35
  _useState2 = _rollupPluginBabelHelpers.slicedToArray(_useState, 2),
33
36
  isConditionBuilderActive = _useState2[0],
34
37
  setIsConditionBuilderActive = _useState2[1];
35
- var conditionBuilderRef = React.useRef();
36
38
  React.useEffect(function () {
37
39
  var _rootState$groups;
38
40
  if (rootState !== null && rootState !== void 0 && (_rootState$groups = rootState.groups) !== null && _rootState$groups !== void 0 && _rootState$groups.length) {
39
41
  setIsConditionBuilderActive(false);
40
- if (rootState.groups[0].conditions.length == 1 && rootState.groups[0].conditions[0].property == undefined) {
41
- // when the add condition clicked to start the condition building, we by default open the popover of the first property
42
- setTimeout(function () {
43
- conditionBuilderRef.current.querySelector('.propertyField').click();
44
- }, 0);
45
- }
46
42
  } else {
47
43
  setIsConditionBuilderActive(true);
48
44
  }
49
- }, [rootState]);
45
+ if (getConditionState) {
46
+ getConditionState(rootState);
47
+ }
48
+
49
+ // eslint-disable-next-line react-hooks/exhaustive-deps
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]);
50
61
  var onStartConditionBuilder = function onStartConditionBuilder() {
51
62
  //when add condition button is clicked.
52
63
  setIsConditionBuilderActive(false);
53
- setRootState(DataTreeContext.emptyState); //here we can set an empty skeleton object for an empty condition builder,
64
+ setRootState(initialState !== null && initialState !== void 0 ? initialState : ConditionBuilderProvider.emptyState); //here we can set an empty skeleton object for an empty condition builder,
54
65
  //or we can even pre-populate some existing builder and continue editing
55
66
  };
67
+ var _onRemove = React.useCallback(function (groupIndex) {
68
+ setRootState(_rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, rootState), {}, {
69
+ groups: rootState.groups.filter(function (group, gIndex) {
70
+ return groupIndex !== gIndex;
71
+ })
72
+ }));
73
+ }, [setRootState, rootState]);
74
+ var onChangeHandler = function onChangeHandler(updatedGroup, groupIndex) {
75
+ /**
76
+ * This method is triggered from inner components. This will be called every time when any change is to be updated in the rootState.
77
+ * This gets the updated group as argument.
78
+ */
79
+ setRootState(_rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, rootState), {}, {
80
+ groups: rootState.groups.map(function (group, gIndex) {
81
+ return groupIndex === gIndex ? updatedGroup : group;
82
+ })
83
+ }));
84
+ };
56
85
  return /*#__PURE__*/React__default["default"].createElement("div", {
57
- ref: conditionBuilderRef,
58
- className: "".concat(blockClass, "__content-container")
86
+ className: "".concat(DataConfigs.blockClass, "__content-container"),
87
+ tabIndex: -1
59
88
  }, isConditionBuilderActive && /*#__PURE__*/React__default["default"].createElement(react.Button, {
60
- className: "".concat(blockClass, "__condition-builder"),
89
+ className: "".concat(DataConfigs.blockClass, "__condition-builder"),
61
90
  renderIcon: function renderIcon(props) {
62
91
  return /*#__PURE__*/React__default["default"].createElement(icons.Add, _rollupPluginBabelHelpers["extends"]({
63
92
  size: 16
@@ -67,34 +96,53 @@ function ConditionBuilderContent(_ref) {
67
96
  kind: "ghost",
68
97
  size: "sm",
69
98
  onClick: onStartConditionBuilder
70
- }, startConditionLabel), rootState && (rootState === null || rootState === void 0 || (_rootState$groups2 = rootState.groups) === null || _rootState$groups2 === void 0 ? void 0 : _rootState$groups2.map(function () {
71
- return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, "conditionBuilder group renders here")
72
- // <ConditionBuilderGroup
73
- // state={eachGroup}
74
- // onRemove={() => {
75
- // onRemove(groupIndex);
76
- // }}
77
- // onChange={(updatedGroup) => {
78
- // /**
79
- // * This method is triggered from inner components. This will be called every time when any change is to be updated in the rootState.
80
- // * This gets the updated group as argument.
81
- // */
82
- // setRootState({
83
- // ...rootState,
84
- // groups: rootState.groups.map((group, gIndex) =>
85
- // groupIndex === gIndex ? updatedGroup : group
86
- // ),
87
- // });
88
- // }}
89
- //>
90
- ;
99
+ }, 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
+ return /*#__PURE__*/React__default["default"].createElement(ConditionGroupBuilder["default"], {
101
+ key: groupIndex,
102
+ aria: {
103
+ level: 1,
104
+ posinset: groupIndex * 2 + 1,
105
+ setsize: rootState.groups.length * 2
106
+ },
107
+ state: eachGroup,
108
+ onRemove: function onRemove() {
109
+ _onRemove(groupIndex);
110
+ },
111
+ onChange: function onChange(updatedGroup) {
112
+ onChangeHandler(updatedGroup, groupIndex);
113
+ },
114
+ conditionBuilderRef: conditionBuilderRef
115
+ });
91
116
  })));
92
- }
117
+ };
118
+ var ConditionBuilderContent$1 = ConditionBuilderContent;
93
119
  ConditionBuilderContent.propTypes = {
94
120
  /**
95
- * Provide a label to the button that starts condition builder
121
+ * ref of condition builder
122
+ */
123
+ conditionBuilderRef: index["default"].object,
124
+ /**
125
+ * This is a callback function that returns the updated state
126
+ */
127
+ getConditionState: index["default"].func.isRequired,
128
+ /**
129
+ * Optional prop if the condition building need to start from a predefined initial state
130
+ */
131
+ initialState: index["default"].shape({
132
+ groups: index["default"].arrayOf(index["default"].shape({
133
+ groupSeparateOperator: index["default"].string,
134
+ groupOperator: index["default"].string,
135
+ statement: index["default"].string,
136
+ conditions: index["default"].arrayOf(index["default"].shape({
137
+ property: index["default"].string,
138
+ operator: index["default"].string,
139
+ value: index["default"].string
140
+ }))
141
+ }))
142
+ }),
143
+ /* Provide a label to the button that starts condition builder
96
144
  */
97
145
  startConditionLabel: index["default"].string.isRequired
98
146
  };
99
147
 
100
- exports["default"] = ConditionBuilderContent;
148
+ exports["default"] = ConditionBuilderContent$1;
@@ -7,6 +7,7 @@ export namespace emptyState {
7
7
  property: undefined;
8
8
  operator: string;
9
9
  value: string;
10
+ popoverToOpen: string;
10
11
  }[];
11
12
  }[];
12
13
  }
@@ -15,23 +16,25 @@ export function ConditionBuilderProvider(props: any): import("react/jsx-runtime"
15
16
  export namespace ConditionBuilderProvider {
16
17
  namespace propTypes {
17
18
  let children: PropTypes.Validator<NonNullable<PropTypes.ReactNodeLike>>;
19
+ let getOptions: PropTypes.Requireable<(...args: any[]) => any>;
18
20
  let inputConfig: PropTypes.Validator<NonNullable<PropTypes.InferProps<{
19
21
  properties: PropTypes.Requireable<(PropTypes.InferProps<{
20
22
  id: PropTypes.Requireable<string>;
21
23
  label: PropTypes.Requireable<string>;
22
- icon: PropTypes.Requireable<(...args: any[]) => any>;
24
+ icon: PropTypes.Requireable<object>;
23
25
  type: PropTypes.Requireable<string>;
24
26
  config: PropTypes.Requireable<PropTypes.InferProps<{
25
27
  options: PropTypes.Requireable<(PropTypes.InferProps<{
26
28
  id: PropTypes.Requireable<string>;
27
29
  label: PropTypes.Requireable<string>;
28
- icon: PropTypes.Requireable<(...args: any[]) => any>;
30
+ icon: PropTypes.Requireable<object>;
29
31
  }> | null | undefined)[]>;
30
32
  includeSearch: PropTypes.Requireable<boolean>;
31
33
  }>>;
32
34
  }> | null | undefined)[]>;
33
35
  }>>>;
34
36
  let popOverSearchThreshold: PropTypes.Validator<number>;
37
+ let variant: PropTypes.Validator<string>;
35
38
  }
36
39
  }
37
40
  import React from 'react';
@@ -25,7 +25,8 @@ var emptyState = {
25
25
  conditions: [{
26
26
  property: undefined,
27
27
  operator: '',
28
- value: ''
28
+ value: '',
29
+ popoverToOpen: 'propertyField'
29
30
  }]
30
31
  }]
31
32
  };
@@ -58,7 +59,9 @@ var ConditionBuilderProvider = function ConditionBuilderProvider(props) {
58
59
  rootState: rootState,
59
60
  setRootState: setRootState,
60
61
  inputConfig: props.inputConfig,
61
- popOverSearchThreshold: props.popOverSearchThreshold
62
+ popOverSearchThreshold: props.popOverSearchThreshold,
63
+ getOptions: props.getOptions,
64
+ variant: props.variant
62
65
  }
63
66
  },
64
67
  // eslint-disable-next-line react/prop-types
@@ -69,28 +72,44 @@ ConditionBuilderProvider.propTypes = {
69
72
  * Provide the contents of the ConditionBuilder.
70
73
  */
71
74
  children: index["default"].node.isRequired,
75
+ /**
76
+ * This is an optional callback function that will be triggered when options array is not passed in the inputConfig against a property.
77
+ * This can be a asynchronous function that need to return a promise, so it will allow to fetch options from API call.
78
+ * options has to be in valid format
79
+ * [{
80
+ label: 'label',
81
+ id: 'id',
82
+ },...]
83
+ */
84
+ getOptions: index["default"].func,
72
85
  /**
73
86
  * This is a mandatory prop that defines the input to the condition builder.
74
-
87
+
75
88
  */
76
89
  inputConfig: index["default"].shape({
77
90
  properties: index["default"].arrayOf(index["default"].shape({
78
91
  id: index["default"].string,
79
92
  label: index["default"].string,
80
- icon: index["default"].func,
81
- type: index["default"].oneOf(['text', 'number', 'date', 'option']),
93
+ icon: index["default"].oneOfType([index["default"].func, index["default"].object]),
94
+ type: index["default"].oneOf(['text', 'number', 'date', 'option', 'time']),
82
95
  config: index["default"].shape({
83
96
  options: index["default"].arrayOf(index["default"].shape({
84
97
  id: index["default"].string,
85
98
  label: index["default"].string,
86
- icon: index["default"].func
99
+ icon: index["default"].oneOfType([index["default"].func, index["default"].object])
87
100
  })),
88
101
  includeSearch: index["default"].bool
89
102
  })
90
103
  }))
91
104
  }).isRequired,
92
- popOverSearchThreshold: index["default"].number.isRequired
93
- /* TODO: add types and DocGen for all props. */
105
+ /**
106
+ * Provide an mandatory numeric value that will be used to enable search option in the popovers with list.
107
+ */
108
+ popOverSearchThreshold: index["default"].number.isRequired,
109
+ /**
110
+ * Provide the condition builder variant: sentence/ tree
111
+ */
112
+ variant: index["default"].string.isRequired
94
113
  };
95
114
 
96
115
  exports.ConditionBuilderContext = ConditionBuilderContext;
@@ -0,0 +1,22 @@
1
+ export const statementConfig: {
2
+ label: string;
3
+ id: string;
4
+ }[];
5
+ export const connectorConfig: {
6
+ label: string;
7
+ id: string;
8
+ }[];
9
+ export const operatorConfig: {
10
+ label: string;
11
+ id: string;
12
+ type: string;
13
+ }[];
14
+ export const blockClass: string;
15
+ export function translateWithId(key: any): any;
16
+ export namespace valueRenderers {
17
+ function text(val: any): any;
18
+ function time(val: any): any;
19
+ function number(val: any, config: any): any;
20
+ function option(value: any): any;
21
+ function date(value: any): any;
22
+ }
@@ -0,0 +1,121 @@
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 settings = require('../../../settings.js');
13
+ var translationObject = require('./translationObject.js');
14
+
15
+ var statementConfig = [{
16
+ label: 'if',
17
+ id: 'if'
18
+ }, {
19
+ label: 'excl.if',
20
+ id: 'excl.if'
21
+ }];
22
+ var connectorConfig = [{
23
+ label: 'and',
24
+ id: 'and'
25
+ }, {
26
+ label: 'or',
27
+ id: 'or'
28
+ }];
29
+ //op types : option, text, number, date,
30
+ var operatorConfig = [{
31
+ label: 'is',
32
+ id: 'is',
33
+ type: 'all'
34
+ }, {
35
+ label: 'is greater than',
36
+ id: 'greater',
37
+ type: 'number'
38
+ }, {
39
+ label: 'is greater than or equal to',
40
+ id: 'greater-equal',
41
+ type: 'number'
42
+ }, {
43
+ label: 'is lower than',
44
+ id: 'lower',
45
+ type: 'number'
46
+ }, {
47
+ label: 'is lower than or equal to',
48
+ id: 'lower-equal',
49
+ type: 'number'
50
+ }, {
51
+ label: 'starts with',
52
+ id: 'starts-with',
53
+ type: 'text'
54
+ }, {
55
+ label: 'ends with',
56
+ id: 'ends-with',
57
+ type: 'text'
58
+ }, {
59
+ label: 'contains',
60
+ id: 'contains',
61
+ type: 'text'
62
+ }, {
63
+ label: 'is one of',
64
+ id: 'one-of',
65
+ type: 'option'
66
+ }, {
67
+ label: 'is before',
68
+ id: 'before',
69
+ type: 'date,time'
70
+ }, {
71
+ label: 'is after',
72
+ id: 'after',
73
+ type: 'date,time'
74
+ }, {
75
+ label: 'is between',
76
+ id: 'between',
77
+ type: 'date'
78
+ }];
79
+ // The block part of our conventional BEM class names (blockClass__E--M).
80
+ var blockClass = "".concat(settings.pkg.prefix, "--condition-builder");
81
+ var formatDate = function formatDate(date) {
82
+ var day = String(date.getDate()).padStart(2, '0');
83
+ var month = String(date.getMonth() + 1).padStart(2, '0');
84
+ var year = date.getFullYear();
85
+ return "".concat(day, "/").concat(month, "/").concat(year);
86
+ };
87
+ var translationsObjectCurrent = translationObject.translationsObject['en']; // TO DO: need to discuss if language is to be passed as prop
88
+ var translateWithId = function translateWithId(key) {
89
+ var _translationsObjectCu;
90
+ return (_translationsObjectCu = translationsObjectCurrent[key]) !== null && _translationsObjectCu !== void 0 ? _translationsObjectCu : key;
91
+ };
92
+ var valueRenderers = {
93
+ text: function text(val) {
94
+ return val;
95
+ },
96
+ time: function time(val) {
97
+ return val;
98
+ },
99
+ number: function number(val, config) {
100
+ return config.unit && val ? "".concat(val, " ").concat(config.unit) : val;
101
+ },
102
+ option: function option(value) {
103
+ return Array.isArray(value) ? value.join(', ') : value;
104
+ },
105
+ date: function date(value) {
106
+ if (Array.isArray(value) && value.length > 1) {
107
+ var start = value !== null && value !== void 0 && value[0] ? formatDate(new Date(value[0])) : '';
108
+ var end = value !== null && value !== void 0 && value[1] ? formatDate(new Date(value[1])) : '';
109
+ return "".concat(start, " To ").concat(end);
110
+ } else {
111
+ return value && new Date(value) ? formatDate(new Date(value)) : value;
112
+ }
113
+ }
114
+ };
115
+
116
+ exports.blockClass = blockClass;
117
+ exports.connectorConfig = connectorConfig;
118
+ exports.operatorConfig = operatorConfig;
119
+ exports.statementConfig = statementConfig;
120
+ exports.translateWithId = translateWithId;
121
+ exports.valueRenderers = valueRenderers;
@@ -0,0 +1,31 @@
1
+ export namespace translationsObject {
2
+ let en: {
3
+ if: string;
4
+ 'excl-if': string;
5
+ and: string;
6
+ or: string;
7
+ is: string;
8
+ greater: string;
9
+ 'greater-equal': string;
10
+ lower: string;
11
+ 'lower-equal': string;
12
+ 'starts-with': string;
13
+ 'ends-with': string;
14
+ contains: string;
15
+ 'one-of': string;
16
+ before: string;
17
+ after: string;
18
+ between: string;
19
+ 'add-condition': string;
20
+ condition: string;
21
+ property: string;
22
+ operator: string;
23
+ connector: string;
24
+ condition_row: string;
25
+ remove_condition: string;
26
+ add_condition_row: string;
27
+ start: string;
28
+ end: string;
29
+ clear_search: string;
30
+ };
31
+ }
@@ -0,0 +1,44 @@
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 translationsObject = {
13
+ en: {
14
+ if: 'if',
15
+ 'excl-if': 'excl.if',
16
+ and: 'and',
17
+ or: 'or',
18
+ is: 'is',
19
+ greater: 'is greater than',
20
+ 'greater-equal': 'is greater than or equal to',
21
+ lower: 'is lower than',
22
+ 'lower-equal': 'is lower than or equal to',
23
+ 'starts-with': 'starts with',
24
+ 'ends-with': 'ends with',
25
+ contains: 'contains',
26
+ 'one-of': 'is one of',
27
+ before: 'is before',
28
+ after: 'is after',
29
+ between: 'is between',
30
+ 'add-condition': 'Add Condition',
31
+ condition: 'Condition',
32
+ property: 'Property',
33
+ operator: 'Operator',
34
+ connector: 'Connector',
35
+ condition_row: 'Condition row',
36
+ remove_condition: 'Remove condition',
37
+ add_condition_row: 'Add condition row',
38
+ start: 'Start',
39
+ end: 'End',
40
+ clear_search: 'Clear search input'
41
+ }
42
+ };
43
+
44
+ exports.translationsObject = translationsObject;
@@ -0,0 +1,28 @@
1
+ export function ConditionBuilderItem({ children, className, label, renderIcon, title, type, showToolTip, state, popOverClassName, config, ...rest }: {
2
+ [x: string]: any;
3
+ children: any;
4
+ className: any;
5
+ label: any;
6
+ renderIcon: any;
7
+ title: any;
8
+ type: any;
9
+ showToolTip: any;
10
+ state: any;
11
+ popOverClassName: any;
12
+ config: any;
13
+ }): import("react/jsx-runtime").JSX.Element;
14
+ export namespace ConditionBuilderItem {
15
+ namespace propTypes {
16
+ let children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
17
+ let className: PropTypes.Requireable<string>;
18
+ let config: PropTypes.Requireable<object>;
19
+ let label: PropTypes.Requireable<NonNullable<string | any[] | null | undefined>>;
20
+ let popOverClassName: PropTypes.Requireable<string>;
21
+ let renderIcon: PropTypes.Requireable<object>;
22
+ let showToolTip: PropTypes.Requireable<boolean>;
23
+ let state: PropTypes.Requireable<object>;
24
+ let title: PropTypes.Requireable<string>;
25
+ let type: PropTypes.Requireable<string>;
26
+ }
27
+ }
28
+ import PropTypes from 'prop-types';