@carbon/ibm-products 2.36.0-alpha.27 → 2.37.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/css/index-full-carbon.css +5404 -5117
- package/css/index-full-carbon.css.map +1 -1
- package/css/index-full-carbon.min.css +1 -1
- package/css/index-full-carbon.min.css.map +1 -1
- package/css/index-without-carbon-released-only.css +4 -4
- package/css/index-without-carbon-released-only.css.map +1 -1
- package/css/index-without-carbon-released-only.min.css +1 -1
- package/css/index-without-carbon-released-only.min.css.map +1 -1
- package/css/index-without-carbon.css +820 -61
- package/css/index-without-carbon.css.map +1 -1
- package/css/index-without-carbon.min.css +1 -1
- package/css/index-without-carbon.min.css.map +1 -1
- package/css/index.css +329 -6
- package/css/index.css.map +1 -1
- package/css/index.min.css +1 -1
- package/css/index.min.css.map +1 -1
- package/es/_virtual/_rollupPluginBabelHelpers.js +9 -10
- package/es/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.d.ts +3 -1
- package/es/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.js +8 -2
- package/es/components/Carousel/Carousel.d.ts +46 -2
- package/es/components/Carousel/Carousel.js +36 -21
- package/es/components/Carousel/CarouselItem.d.ts +19 -2
- package/es/components/Carousel/CarouselItem.js +0 -1
- package/es/components/ConditionBuilder/ConditionBlock/ConditionBlock.d.ts +21 -0
- package/es/components/ConditionBuilder/ConditionBlock/ConditionBlock.js +261 -0
- package/es/components/ConditionBuilder/ConditionBuilder.js +45 -16
- package/es/components/ConditionBuilder/ConditionBuilderAdd/ConditionBuilderAdd.d.ts +12 -0
- package/es/components/ConditionBuilder/ConditionBuilderAdd/ConditionBuilderAdd.js +40 -0
- package/es/components/ConditionBuilder/ConditionBuilderButton/ConditionBuilderButton.d.ts +22 -0
- package/es/components/ConditionBuilder/ConditionBuilderButton/ConditionBuilderButton.js +74 -0
- package/es/components/ConditionBuilder/ConditionBuilderContent/ConditionBuilderContent.d.ts +18 -1
- package/es/components/ConditionBuilder/ConditionBuilderContent/ConditionBuilderContent.js +90 -42
- package/es/components/ConditionBuilder/ConditionBuilderContext/{DataTreeContext.d.ts → ConditionBuilderProvider.d.ts} +5 -2
- package/es/components/ConditionBuilder/ConditionBuilderContext/{DataTreeContext.js → ConditionBuilderProvider.js} +27 -8
- package/es/components/ConditionBuilder/ConditionBuilderContext/DataConfigs.d.ts +22 -0
- package/es/components/ConditionBuilder/ConditionBuilderContext/DataConfigs.js +112 -0
- package/es/components/ConditionBuilder/ConditionBuilderContext/translationObject.d.ts +31 -0
- package/es/components/ConditionBuilder/ConditionBuilderContext/translationObject.js +40 -0
- package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItem.d.ts +28 -0
- package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItem.js +151 -0
- package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemDate/ConditionBuilderItemDate.d.ts +11 -0
- package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemDate/ConditionBuilderItemDate.js +59 -0
- package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemNumber/ConditionBuilderItemNumber.d.ts +13 -0
- package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemNumber/ConditionBuilderItemNumber.js +52 -0
- package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemOption/ConditionBuilderItemOption.d.ts +13 -0
- package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemOption/ConditionBuilderItemOption.js +162 -0
- package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemText/ConditionBuilderItemText.d.ts +11 -0
- package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemText/ConditionBuilderItemText.js +40 -0
- package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemTime/ConditionBuilderItemTime.d.ts +11 -0
- package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemTime/ConditionBuilderItemTime.js +82 -0
- package/es/components/ConditionBuilder/ConditionConnector/ConditionConnector.d.ts +15 -0
- package/es/components/ConditionBuilder/ConditionConnector/ConditionConnector.js +85 -0
- package/es/components/ConditionBuilder/ConditionGroupBuilder/ConditionGroupBuilder.d.ts +24 -0
- package/es/components/ConditionBuilder/ConditionGroupBuilder/ConditionGroupBuilder.js +145 -0
- package/es/components/ConditionBuilder/utils/util.d.ts +4 -0
- package/es/components/ConditionBuilder/utils/util.js +16 -0
- package/es/components/CreateTearsheet/CreateTearsheet.d.ts +106 -4
- package/es/components/CreateTearsheet/CreateTearsheet.js +12 -32
- package/es/components/Datagrid/useParentDimensions.js +1 -1
- package/es/components/EditUpdateCards/EditUpdateCards.d.ts +104 -2
- package/es/components/EditUpdateCards/EditUpdateCards.js +3 -0
- package/es/components/EmptyStates/NotificationsEmptyState/NotificationsEmptyState.d.ts +61 -2
- package/es/components/EmptyStates/NotificationsEmptyState/NotificationsEmptyState.js +1 -3
- package/es/components/ExpressiveCard/ExpressiveCard.d.ts +97 -2
- package/es/components/ExpressiveCard/ExpressiveCard.js +4 -0
- package/es/components/InlineTip/InlineTipButton.d.ts +21 -2
- package/es/components/InterstitialScreen/InterstitialScreen.d.ts +100 -2
- package/es/components/InterstitialScreen/InterstitialScreen.js +25 -14
- package/es/components/Nav/NavItem.js +1 -1
- package/es/components/NotificationsPanel/NotificationsPanel.js +5 -6
- package/es/components/PageHeader/PageHeader.js +12 -3
- package/es/components/SidePanel/SidePanel.js +1 -1
- package/es/components/SimpleHeader/SimpleHeader.d.ts +1 -5
- package/es/components/SimpleHeader/SimpleHeader.js +2 -4
- package/es/components/Tearsheet/TearsheetNarrow.d.ts +4 -13
- package/es/components/Tearsheet/TearsheetShell.d.ts +119 -10
- package/es/components/Tearsheet/TearsheetShell.js +18 -8
- package/es/components/UserProfileImage/UserProfileImage.d.ts +66 -2
- package/es/components/UserProfileImage/UserProfileImage.js +5 -3
- package/es/components/WebTerminal/WebTerminal.d.ts +46 -2
- package/es/components/WebTerminal/WebTerminal.js +2 -2
- package/es/global/js/hooks/usePrefersReducedMotion.d.ts +2 -0
- package/es/global/js/hooks/usePrefersReducedMotion.js +28 -0
- package/es/global/js/utils/Wrap.d.ts +31 -2
- package/es/global/js/utils/Wrap.js +7 -9
- package/es/global/js/utils/getNodeTextContent.d.ts +1 -1
- package/es/global/js/utils/getNodeTextContent.js +1 -1
- package/es/global/js/utils/window.d.ts +2 -0
- package/es/global/js/utils/window.js +12 -0
- package/es/node_modules/@carbon/icons-react/es/generated/bucket-9.js +2780 -0
- package/lib/_virtual/_rollupPluginBabelHelpers.js +9 -10
- package/lib/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.d.ts +3 -1
- package/lib/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.js +8 -2
- package/lib/components/Carousel/Carousel.d.ts +46 -2
- package/lib/components/Carousel/Carousel.js +35 -20
- package/lib/components/Carousel/CarouselItem.d.ts +19 -2
- package/lib/components/Carousel/CarouselItem.js +0 -1
- package/lib/components/ConditionBuilder/ConditionBlock/ConditionBlock.d.ts +21 -0
- package/lib/components/ConditionBuilder/ConditionBlock/ConditionBlock.js +270 -0
- package/lib/components/ConditionBuilder/ConditionBuilder.js +46 -17
- package/lib/components/ConditionBuilder/ConditionBuilderAdd/ConditionBuilderAdd.d.ts +12 -0
- package/lib/components/ConditionBuilder/ConditionBuilderAdd/ConditionBuilderAdd.js +48 -0
- package/lib/components/ConditionBuilder/ConditionBuilderButton/ConditionBuilderButton.d.ts +22 -0
- package/lib/components/ConditionBuilder/ConditionBuilderButton/ConditionBuilderButton.js +83 -0
- package/lib/components/ConditionBuilder/ConditionBuilderContent/ConditionBuilderContent.d.ts +18 -1
- package/lib/components/ConditionBuilder/ConditionBuilderContent/ConditionBuilderContent.js +90 -42
- package/lib/components/ConditionBuilder/ConditionBuilderContext/{DataTreeContext.d.ts → ConditionBuilderProvider.d.ts} +5 -2
- package/lib/components/ConditionBuilder/ConditionBuilderContext/{DataTreeContext.js → ConditionBuilderProvider.js} +27 -8
- package/lib/components/ConditionBuilder/ConditionBuilderContext/DataConfigs.d.ts +22 -0
- package/lib/components/ConditionBuilder/ConditionBuilderContext/DataConfigs.js +121 -0
- package/lib/components/ConditionBuilder/ConditionBuilderContext/translationObject.d.ts +31 -0
- package/lib/components/ConditionBuilder/ConditionBuilderContext/translationObject.js +44 -0
- package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItem.d.ts +28 -0
- package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItem.js +159 -0
- package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemDate/ConditionBuilderItemDate.d.ts +11 -0
- package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemDate/ConditionBuilderItemDate.js +67 -0
- package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemNumber/ConditionBuilderItemNumber.d.ts +13 -0
- package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemNumber/ConditionBuilderItemNumber.js +60 -0
- package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemOption/ConditionBuilderItemOption.d.ts +13 -0
- package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemOption/ConditionBuilderItemOption.js +170 -0
- package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemText/ConditionBuilderItemText.d.ts +11 -0
- package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemText/ConditionBuilderItemText.js +48 -0
- package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemTime/ConditionBuilderItemTime.d.ts +11 -0
- package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemTime/ConditionBuilderItemTime.js +90 -0
- package/lib/components/ConditionBuilder/ConditionConnector/ConditionConnector.d.ts +15 -0
- package/lib/components/ConditionBuilder/ConditionConnector/ConditionConnector.js +93 -0
- package/lib/components/ConditionBuilder/ConditionGroupBuilder/ConditionGroupBuilder.d.ts +24 -0
- package/lib/components/ConditionBuilder/ConditionGroupBuilder/ConditionGroupBuilder.js +153 -0
- package/lib/components/ConditionBuilder/utils/util.d.ts +4 -0
- package/lib/components/ConditionBuilder/utils/util.js +20 -0
- package/lib/components/CreateTearsheet/CreateTearsheet.d.ts +106 -4
- package/lib/components/CreateTearsheet/CreateTearsheet.js +12 -32
- package/lib/components/Datagrid/useParentDimensions.js +1 -1
- package/lib/components/EditUpdateCards/EditUpdateCards.d.ts +104 -2
- package/lib/components/EditUpdateCards/EditUpdateCards.js +3 -0
- package/lib/components/EmptyStates/NotificationsEmptyState/NotificationsEmptyState.d.ts +61 -2
- package/lib/components/EmptyStates/NotificationsEmptyState/NotificationsEmptyState.js +1 -3
- package/lib/components/ExpressiveCard/ExpressiveCard.d.ts +97 -2
- package/lib/components/ExpressiveCard/ExpressiveCard.js +4 -0
- package/lib/components/InlineTip/InlineTipButton.d.ts +21 -2
- package/lib/components/InterstitialScreen/InterstitialScreen.d.ts +100 -2
- package/lib/components/InterstitialScreen/InterstitialScreen.js +24 -13
- package/lib/components/Nav/NavItem.js +2 -2
- package/lib/components/NotificationsPanel/NotificationsPanel.js +5 -6
- package/lib/components/PageHeader/PageHeader.js +11 -2
- package/lib/components/SidePanel/SidePanel.js +1 -1
- package/lib/components/SimpleHeader/SimpleHeader.d.ts +1 -5
- package/lib/components/SimpleHeader/SimpleHeader.js +2 -4
- package/lib/components/Tearsheet/TearsheetNarrow.d.ts +4 -13
- package/lib/components/Tearsheet/TearsheetShell.d.ts +119 -10
- package/lib/components/Tearsheet/TearsheetShell.js +16 -6
- package/lib/components/UserProfileImage/UserProfileImage.d.ts +66 -2
- package/lib/components/UserProfileImage/UserProfileImage.js +5 -3
- package/lib/components/WebTerminal/WebTerminal.d.ts +46 -2
- package/lib/components/WebTerminal/WebTerminal.js +2 -2
- package/lib/global/js/hooks/usePrefersReducedMotion.d.ts +2 -0
- package/lib/global/js/hooks/usePrefersReducedMotion.js +32 -0
- package/lib/global/js/utils/Wrap.d.ts +31 -2
- package/lib/global/js/utils/Wrap.js +7 -9
- package/lib/global/js/utils/getNodeTextContent.d.ts +1 -1
- package/lib/global/js/utils/getNodeTextContent.js +1 -1
- package/lib/global/js/utils/window.d.ts +2 -0
- package/lib/global/js/utils/window.js +16 -0
- package/lib/node_modules/@carbon/icons-react/es/generated/bucket-9.js +2912 -0
- package/package.json +5 -5
- package/scss/components/CoachmarkOverlayElements/_coachmark-overlay-elements.scss +1 -1
- package/scss/components/ConditionBuilder/_condition-builder.scss +26 -0
- package/scss/components/ConditionBuilder/styles/_conditionBuilderCondition.scss +46 -0
- package/scss/components/ConditionBuilder/styles/_conditionBuilderItem.scss +194 -0
- package/scss/components/ConditionBuilder/styles/_index.scss +2 -0
- package/scss/components/Guidebanner/_guidebanner.scss +3 -0
- package/scss/components/InterstitialScreen/_interstitial-screen.scss +1 -6
- package/scss/components/Tearsheet/_tearsheet.scss +3 -1
- package/telemetry.yml +3 -0
- package/es/components/ConditionBuilder/assets/sampleInput.d.ts +0 -58
- package/es/global/js/utils/keyboardNavigation.d.ts +0 -27
- package/es/global/js/utils/keyboardNavigation.js +0 -33
- package/es/global/js/utils/wrapFocus.d.ts +0 -25
- package/es/global/js/utils/wrapFocus.js +0 -68
- package/es/node_modules/@carbon/icons-react/es/generated/bucket-8.js +0 -3004
- package/lib/components/ConditionBuilder/assets/sampleInput.d.ts +0 -58
- package/lib/global/js/utils/keyboardNavigation.d.ts +0 -27
- package/lib/global/js/utils/keyboardNavigation.js +0 -39
- package/lib/global/js/utils/wrapFocus.d.ts +0 -25
- package/lib/global/js/utils/wrapFocus.js +0 -73
- package/lib/node_modules/@carbon/icons-react/es/generated/bucket-8.js +0 -3136
|
@@ -6,22 +6,21 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import { objectWithoutProperties as _objectWithoutProperties, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
|
-
import React__default from 'react';
|
|
9
|
+
import React__default, { useRef } from 'react';
|
|
10
10
|
import { VStack } from '@carbon/react';
|
|
11
11
|
import PropTypes from '../../node_modules/prop-types/index.js';
|
|
12
12
|
import cx from 'classnames';
|
|
13
13
|
import { getDevtoolsProps } from '../../global/js/utils/devtools.js';
|
|
14
|
-
import { pkg } from '../../settings.js';
|
|
15
14
|
import ConditionBuilderContent from './ConditionBuilderContent/ConditionBuilderContent.js';
|
|
16
|
-
import { ConditionBuilderProvider } from './ConditionBuilderContext/
|
|
15
|
+
import { ConditionBuilderProvider } from './ConditionBuilderContext/ConditionBuilderProvider.js';
|
|
16
|
+
import { pkg } from '../../settings.js';
|
|
17
|
+
import { blockClass } from './ConditionBuilderContext/DataConfigs.js';
|
|
17
18
|
|
|
18
|
-
var _excluded = ["className", "inputConfig", "startConditionLabel", "popOverSearchThreshold"];
|
|
19
|
+
var _excluded = ["className", "inputConfig", "startConditionLabel", "popOverSearchThreshold", "getOptions", "initialState", "getConditionState", "variant"];
|
|
19
20
|
|
|
20
21
|
// Carbon and package components we use.
|
|
21
22
|
/* TODO: @import(s) of carbon components and other package components. */
|
|
22
23
|
|
|
23
|
-
// The block part of our conventional BEM class names (blockClass__E--M).
|
|
24
|
-
var blockClass = "".concat(pkg.prefix, "--condition-builder");
|
|
25
24
|
var componentName = 'ConditionBuilder';
|
|
26
25
|
|
|
27
26
|
// NOTE: the component SCSS is not imported here: it is rolled up separately.
|
|
@@ -49,10 +48,18 @@ var ConditionBuilder = /*#__PURE__*/React__default.forwardRef(function (_ref, re
|
|
|
49
48
|
inputConfig = _ref.inputConfig,
|
|
50
49
|
startConditionLabel = _ref.startConditionLabel,
|
|
51
50
|
popOverSearchThreshold = _ref.popOverSearchThreshold,
|
|
51
|
+
getOptions = _ref.getOptions,
|
|
52
|
+
initialState = _ref.initialState,
|
|
53
|
+
getConditionState = _ref.getConditionState,
|
|
54
|
+
variant = _ref.variant,
|
|
52
55
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
56
|
+
var localRef = useRef();
|
|
57
|
+
var conditionBuilderRef = ref || localRef;
|
|
53
58
|
return /*#__PURE__*/React__default.createElement(ConditionBuilderProvider, {
|
|
54
59
|
inputConfig: inputConfig,
|
|
55
|
-
popOverSearchThreshold: popOverSearchThreshold
|
|
60
|
+
popOverSearchThreshold: popOverSearchThreshold,
|
|
61
|
+
getOptions: getOptions,
|
|
62
|
+
variant: variant
|
|
56
63
|
}, /*#__PURE__*/React__default.createElement("div", _extends({}, rest, {
|
|
57
64
|
className: cx(blockClass,
|
|
58
65
|
// Apply the block class to the main HTML element
|
|
@@ -63,10 +70,15 @@ var ConditionBuilder = /*#__PURE__*/React__default.forwardRef(function (_ref, re
|
|
|
63
70
|
// switched classes dependant on props or state
|
|
64
71
|
// example: [`${blockClass}__here-if-small`]: size === 'sm',
|
|
65
72
|
}),
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}, getDevtoolsProps(componentName)), /*#__PURE__*/React__default.createElement(VStack,
|
|
69
|
-
|
|
73
|
+
role: "main",
|
|
74
|
+
ref: conditionBuilderRef
|
|
75
|
+
}, getDevtoolsProps(componentName)), /*#__PURE__*/React__default.createElement(VStack, {
|
|
76
|
+
className: "".concat(blockClass, "__").concat(variant)
|
|
77
|
+
}, /*#__PURE__*/React__default.createElement(ConditionBuilderContent, {
|
|
78
|
+
startConditionLabel: startConditionLabel,
|
|
79
|
+
conditionBuilderRef: conditionBuilderRef,
|
|
80
|
+
getConditionState: getConditionState,
|
|
81
|
+
initialState: initialState
|
|
70
82
|
}))));
|
|
71
83
|
});
|
|
72
84
|
|
|
@@ -90,6 +102,20 @@ ConditionBuilder.propTypes = {
|
|
|
90
102
|
* Provide an optional class to be applied to the containing node.
|
|
91
103
|
*/
|
|
92
104
|
className: PropTypes.string,
|
|
105
|
+
getConditionState: PropTypes.func.isRequired,
|
|
106
|
+
getOptions: PropTypes.func,
|
|
107
|
+
initialState: PropTypes.shape({
|
|
108
|
+
groups: PropTypes.arrayOf(PropTypes.shape({
|
|
109
|
+
groupSeparateOperator: PropTypes.string,
|
|
110
|
+
groupOperator: PropTypes.string,
|
|
111
|
+
statement: PropTypes.string,
|
|
112
|
+
conditions: PropTypes.arrayOf(PropTypes.shape({
|
|
113
|
+
property: PropTypes.string,
|
|
114
|
+
operator: PropTypes.string,
|
|
115
|
+
value: PropTypes.string
|
|
116
|
+
}))
|
|
117
|
+
}))
|
|
118
|
+
}),
|
|
93
119
|
/**
|
|
94
120
|
* This is a mandatory prop that defines the input to the condition builder.
|
|
95
121
|
|
|
@@ -98,13 +124,13 @@ ConditionBuilder.propTypes = {
|
|
|
98
124
|
properties: PropTypes.arrayOf(PropTypes.shape({
|
|
99
125
|
id: PropTypes.string,
|
|
100
126
|
label: PropTypes.string,
|
|
101
|
-
icon: PropTypes.func,
|
|
102
|
-
type: PropTypes.oneOf(['text', 'number', 'date', 'option']),
|
|
127
|
+
icon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
128
|
+
type: PropTypes.oneOf(['text', 'number', 'date', 'option', 'time']),
|
|
103
129
|
config: PropTypes.shape({
|
|
104
130
|
options: PropTypes.arrayOf(PropTypes.shape({
|
|
105
131
|
id: PropTypes.string,
|
|
106
132
|
label: PropTypes.string,
|
|
107
|
-
icon: PropTypes.func
|
|
133
|
+
icon: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
|
|
108
134
|
})),
|
|
109
135
|
includeSearch: PropTypes.bool
|
|
110
136
|
})
|
|
@@ -117,9 +143,12 @@ ConditionBuilder.propTypes = {
|
|
|
117
143
|
/**
|
|
118
144
|
* Provide a label to the button that starts condition builder
|
|
119
145
|
*/
|
|
120
|
-
startConditionLabel: PropTypes.string.isRequired
|
|
121
|
-
|
|
146
|
+
startConditionLabel: PropTypes.string.isRequired,
|
|
122
147
|
/* TODO: add types and DocGen for all props. */
|
|
148
|
+
/**
|
|
149
|
+
* Provide the condition builder variant: sentence/ tree
|
|
150
|
+
*/
|
|
151
|
+
variant: PropTypes.string.isRequired
|
|
123
152
|
};
|
|
124
153
|
|
|
125
154
|
export { ConditionBuilder };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export default ConditionBuilderAdd;
|
|
2
|
+
declare function ConditionBuilderAdd({ className, onClick }: {
|
|
3
|
+
className: any;
|
|
4
|
+
onClick: any;
|
|
5
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
declare namespace ConditionBuilderAdd {
|
|
7
|
+
namespace propTypes {
|
|
8
|
+
let className: PropTypes.Requireable<string>;
|
|
9
|
+
let onClick: PropTypes.Requireable<(...args: any[]) => any>;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
import PropTypes from 'prop-types';
|
|
@@ -0,0 +1,40 @@
|
|
|
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
|
+
import React__default from 'react';
|
|
9
|
+
import { AddAlt } from '@carbon/react/icons';
|
|
10
|
+
import { ConditionBuilderButton } from '../ConditionBuilderButton/ConditionBuilderButton.js';
|
|
11
|
+
import PropTypes from '../../../node_modules/prop-types/index.js';
|
|
12
|
+
import { blockClass, translateWithId } from '../ConditionBuilderContext/DataConfigs.js';
|
|
13
|
+
|
|
14
|
+
var ConditionBuilderAdd = function ConditionBuilderAdd(_ref) {
|
|
15
|
+
var className = _ref.className,
|
|
16
|
+
onClick = _ref.onClick;
|
|
17
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
|
18
|
+
className: className
|
|
19
|
+
}, /*#__PURE__*/React__default.createElement(ConditionBuilderButton, {
|
|
20
|
+
renderIcon: AddAlt,
|
|
21
|
+
onClick: onClick,
|
|
22
|
+
className: "".concat(blockClass, "__add-button"),
|
|
23
|
+
hideLabel: true,
|
|
24
|
+
label: translateWithId('add-condition'),
|
|
25
|
+
role: "gridcell"
|
|
26
|
+
}));
|
|
27
|
+
};
|
|
28
|
+
var ConditionBuilderAdd$1 = ConditionBuilderAdd;
|
|
29
|
+
ConditionBuilderAdd.propTypes = {
|
|
30
|
+
/**
|
|
31
|
+
* Provide an optional class to be applied to the containing node.
|
|
32
|
+
*/
|
|
33
|
+
className: PropTypes.string,
|
|
34
|
+
/**
|
|
35
|
+
* callback triggered on click of add button
|
|
36
|
+
*/
|
|
37
|
+
onClick: PropTypes.func
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export { ConditionBuilderAdd$1 as default };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export function ConditionBuilderButton({ className, label, hideLabel, tooltipAlign, renderIcon: Icon, onClick, showToolTip, ...rest }: {
|
|
2
|
+
[x: string]: any;
|
|
3
|
+
className: any;
|
|
4
|
+
label: any;
|
|
5
|
+
hideLabel: any;
|
|
6
|
+
tooltipAlign: any;
|
|
7
|
+
renderIcon: any;
|
|
8
|
+
onClick: any;
|
|
9
|
+
showToolTip: any;
|
|
10
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export namespace ConditionBuilderButton {
|
|
12
|
+
namespace propTypes {
|
|
13
|
+
let className: PropTypes.Requireable<string>;
|
|
14
|
+
let hideLabel: PropTypes.Requireable<boolean>;
|
|
15
|
+
let label: PropTypes.Requireable<string>;
|
|
16
|
+
let onClick: PropTypes.Requireable<(...args: any[]) => any>;
|
|
17
|
+
let renderIcon: PropTypes.Requireable<object>;
|
|
18
|
+
let showToolTip: PropTypes.Requireable<boolean>;
|
|
19
|
+
let tooltipAlign: PropTypes.Requireable<string>;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
import PropTypes from 'prop-types';
|
|
@@ -0,0 +1,74 @@
|
|
|
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
|
+
import { objectWithoutProperties as _objectWithoutProperties, extends as _extends, defineProperty as _defineProperty } from '../../../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
|
+
import React__default from 'react';
|
|
10
|
+
import cx from 'classnames';
|
|
11
|
+
import PropTypes from '../../../node_modules/prop-types/index.js';
|
|
12
|
+
import { Tooltip } from '@carbon/react';
|
|
13
|
+
import { blockClass } from '../ConditionBuilderContext/DataConfigs.js';
|
|
14
|
+
|
|
15
|
+
var _excluded = ["className", "label", "hideLabel", "tooltipAlign", "renderIcon", "onClick", "showToolTip"];
|
|
16
|
+
var ConditionBuilderButton = function ConditionBuilderButton(_ref) {
|
|
17
|
+
var _Icon;
|
|
18
|
+
var className = _ref.className,
|
|
19
|
+
label = _ref.label,
|
|
20
|
+
hideLabel = _ref.hideLabel,
|
|
21
|
+
tooltipAlign = _ref.tooltipAlign,
|
|
22
|
+
Icon = _ref.renderIcon,
|
|
23
|
+
onClick = _ref.onClick,
|
|
24
|
+
showToolTip = _ref.showToolTip,
|
|
25
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
26
|
+
var Button = function Button() {
|
|
27
|
+
return /*#__PURE__*/React__default.createElement("button", _extends({}, rest, {
|
|
28
|
+
// role={'gridcell'}
|
|
29
|
+
tabIndex: -1,
|
|
30
|
+
className: cx([className, "".concat(blockClass, "__condition-builder-button"), _defineProperty({}, "".concat(blockClass, "__text-ellipsis"), showToolTip && !hideLabel)]),
|
|
31
|
+
type: "button",
|
|
32
|
+
onClick: onClick
|
|
33
|
+
}), Icon && (_Icon || (_Icon = /*#__PURE__*/React__default.createElement(Icon, null))), !hideLabel && label);
|
|
34
|
+
};
|
|
35
|
+
return hideLabel || showToolTip ? /*#__PURE__*/React__default.createElement(Tooltip, _extends({
|
|
36
|
+
label: label,
|
|
37
|
+
align: tooltipAlign,
|
|
38
|
+
className: "".concat(blockClass, "__con-tooltip")
|
|
39
|
+
}, rest.wrapperProps), Button()) : /*#__PURE__*/React__default.createElement(React__default.Fragment, null, Button());
|
|
40
|
+
};
|
|
41
|
+
ConditionBuilderButton.propTypes = {
|
|
42
|
+
/**
|
|
43
|
+
* Provide an optional class to be applied to the containing node.
|
|
44
|
+
*/
|
|
45
|
+
className: PropTypes.string,
|
|
46
|
+
/**
|
|
47
|
+
* decides if label and tooltip to be hidden
|
|
48
|
+
*/
|
|
49
|
+
hideLabel: PropTypes.bool,
|
|
50
|
+
/**
|
|
51
|
+
* label of the button
|
|
52
|
+
*/
|
|
53
|
+
label: PropTypes.string,
|
|
54
|
+
/**
|
|
55
|
+
* callback triggered on click of add button
|
|
56
|
+
*/
|
|
57
|
+
onClick: PropTypes.func,
|
|
58
|
+
/**
|
|
59
|
+
* Optional prop to allow overriding the icon rendering.
|
|
60
|
+
*/
|
|
61
|
+
renderIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
62
|
+
/**
|
|
63
|
+
*/
|
|
64
|
+
/**
|
|
65
|
+
*decides if tooltip to be shown
|
|
66
|
+
*/
|
|
67
|
+
showToolTip: PropTypes.bool,
|
|
68
|
+
/**
|
|
69
|
+
* tooltip position
|
|
70
|
+
*/
|
|
71
|
+
tooltipAlign: PropTypes.string
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export { 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
|
}
|
|
@@ -5,18 +5,21 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { slicedToArray as _slicedToArray, extends as _extends } from '../../../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
|
-
import React__default, { useContext, useState,
|
|
10
|
-
import { pkg } from '../../../settings.js';
|
|
8
|
+
import { slicedToArray as _slicedToArray, objectSpread2 as _objectSpread2, extends as _extends } from '../../../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
|
+
import React__default, { useContext, useState, useEffect, useCallback } from 'react';
|
|
11
10
|
import PropTypes from '../../../node_modules/prop-types/index.js';
|
|
12
11
|
import { Button } from '@carbon/react';
|
|
13
12
|
import { Add } from '@carbon/react/icons';
|
|
14
|
-
import
|
|
13
|
+
import ConditionGroupBuilder from '../ConditionGroupBuilder/ConditionGroupBuilder.js';
|
|
14
|
+
import { ConditionBuilderContext, emptyState } from '../ConditionBuilderContext/ConditionBuilderProvider.js';
|
|
15
|
+
import { blockClass } from '../ConditionBuilderContext/DataConfigs.js';
|
|
15
16
|
|
|
16
|
-
var
|
|
17
|
-
function ConditionBuilderContent(_ref) {
|
|
17
|
+
var ConditionBuilderContent = function ConditionBuilderContent(_ref) {
|
|
18
18
|
var _rootState$groups2;
|
|
19
|
-
var startConditionLabel = _ref.startConditionLabel
|
|
19
|
+
var startConditionLabel = _ref.startConditionLabel,
|
|
20
|
+
conditionBuilderRef = _ref.conditionBuilderRef,
|
|
21
|
+
getConditionState = _ref.getConditionState,
|
|
22
|
+
initialState = _ref.initialState;
|
|
20
23
|
var _useContext = useContext(ConditionBuilderContext),
|
|
21
24
|
rootState = _useContext.rootState,
|
|
22
25
|
setRootState = _useContext.setRootState;
|
|
@@ -24,30 +27,56 @@ function ConditionBuilderContent(_ref) {
|
|
|
24
27
|
_useState2 = _slicedToArray(_useState, 2),
|
|
25
28
|
isConditionBuilderActive = _useState2[0],
|
|
26
29
|
setIsConditionBuilderActive = _useState2[1];
|
|
27
|
-
var conditionBuilderRef = useRef();
|
|
28
30
|
useEffect(function () {
|
|
29
31
|
var _rootState$groups;
|
|
30
32
|
if (rootState !== null && rootState !== void 0 && (_rootState$groups = rootState.groups) !== null && _rootState$groups !== void 0 && _rootState$groups.length) {
|
|
31
33
|
setIsConditionBuilderActive(false);
|
|
32
|
-
if (rootState.groups[0].conditions.length == 1 && rootState.groups[0].conditions[0].property == undefined) {
|
|
33
|
-
// when the add condition clicked to start the condition building, we by default open the popover of the first property
|
|
34
|
-
setTimeout(function () {
|
|
35
|
-
conditionBuilderRef.current.querySelector('.propertyField').click();
|
|
36
|
-
}, 0);
|
|
37
|
-
}
|
|
38
34
|
} else {
|
|
39
35
|
setIsConditionBuilderActive(true);
|
|
40
36
|
}
|
|
41
|
-
|
|
37
|
+
if (getConditionState) {
|
|
38
|
+
getConditionState(rootState);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
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]);
|
|
42
53
|
var onStartConditionBuilder = function onStartConditionBuilder() {
|
|
43
54
|
//when add condition button is clicked.
|
|
44
55
|
setIsConditionBuilderActive(false);
|
|
45
|
-
setRootState(emptyState); //here we can set an empty skeleton object for an empty condition builder,
|
|
56
|
+
setRootState(initialState !== null && initialState !== void 0 ? initialState : emptyState); //here we can set an empty skeleton object for an empty condition builder,
|
|
46
57
|
//or we can even pre-populate some existing builder and continue editing
|
|
47
58
|
};
|
|
59
|
+
var _onRemove = useCallback(function (groupIndex) {
|
|
60
|
+
setRootState(_objectSpread2(_objectSpread2({}, rootState), {}, {
|
|
61
|
+
groups: rootState.groups.filter(function (group, gIndex) {
|
|
62
|
+
return groupIndex !== gIndex;
|
|
63
|
+
})
|
|
64
|
+
}));
|
|
65
|
+
}, [setRootState, rootState]);
|
|
66
|
+
var onChangeHandler = function onChangeHandler(updatedGroup, groupIndex) {
|
|
67
|
+
/**
|
|
68
|
+
* This method is triggered from inner components. This will be called every time when any change is to be updated in the rootState.
|
|
69
|
+
* This gets the updated group as argument.
|
|
70
|
+
*/
|
|
71
|
+
setRootState(_objectSpread2(_objectSpread2({}, rootState), {}, {
|
|
72
|
+
groups: rootState.groups.map(function (group, gIndex) {
|
|
73
|
+
return groupIndex === gIndex ? updatedGroup : group;
|
|
74
|
+
})
|
|
75
|
+
}));
|
|
76
|
+
};
|
|
48
77
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
49
|
-
|
|
50
|
-
|
|
78
|
+
className: "".concat(blockClass, "__content-container"),
|
|
79
|
+
tabIndex: -1
|
|
51
80
|
}, isConditionBuilderActive && /*#__PURE__*/React__default.createElement(Button, {
|
|
52
81
|
className: "".concat(blockClass, "__condition-builder"),
|
|
53
82
|
renderIcon: function renderIcon(props) {
|
|
@@ -59,34 +88,53 @@ function ConditionBuilderContent(_ref) {
|
|
|
59
88
|
kind: "ghost",
|
|
60
89
|
size: "sm",
|
|
61
90
|
onClick: onStartConditionBuilder
|
|
62
|
-
}, startConditionLabel), rootState && (rootState === null || rootState === void 0 || (_rootState$groups2 = rootState.groups) === null || _rootState$groups2 === void 0 ? void 0 : _rootState$groups2.map(function () {
|
|
63
|
-
return /*#__PURE__*/React__default.createElement(
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
// });
|
|
80
|
-
// }}
|
|
81
|
-
//>
|
|
82
|
-
;
|
|
91
|
+
}, 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
|
+
return /*#__PURE__*/React__default.createElement(ConditionGroupBuilder, {
|
|
93
|
+
key: groupIndex,
|
|
94
|
+
aria: {
|
|
95
|
+
level: 1,
|
|
96
|
+
posinset: groupIndex * 2 + 1,
|
|
97
|
+
setsize: rootState.groups.length * 2
|
|
98
|
+
},
|
|
99
|
+
state: eachGroup,
|
|
100
|
+
onRemove: function onRemove() {
|
|
101
|
+
_onRemove(groupIndex);
|
|
102
|
+
},
|
|
103
|
+
onChange: function onChange(updatedGroup) {
|
|
104
|
+
onChangeHandler(updatedGroup, groupIndex);
|
|
105
|
+
},
|
|
106
|
+
conditionBuilderRef: conditionBuilderRef
|
|
107
|
+
});
|
|
83
108
|
})));
|
|
84
|
-
}
|
|
109
|
+
};
|
|
110
|
+
var ConditionBuilderContent$1 = ConditionBuilderContent;
|
|
85
111
|
ConditionBuilderContent.propTypes = {
|
|
86
112
|
/**
|
|
87
|
-
*
|
|
113
|
+
* ref of condition builder
|
|
114
|
+
*/
|
|
115
|
+
conditionBuilderRef: PropTypes.object,
|
|
116
|
+
/**
|
|
117
|
+
* This is a callback function that returns the updated state
|
|
118
|
+
*/
|
|
119
|
+
getConditionState: PropTypes.func.isRequired,
|
|
120
|
+
/**
|
|
121
|
+
* Optional prop if the condition building need to start from a predefined initial state
|
|
122
|
+
*/
|
|
123
|
+
initialState: PropTypes.shape({
|
|
124
|
+
groups: PropTypes.arrayOf(PropTypes.shape({
|
|
125
|
+
groupSeparateOperator: PropTypes.string,
|
|
126
|
+
groupOperator: PropTypes.string,
|
|
127
|
+
statement: PropTypes.string,
|
|
128
|
+
conditions: PropTypes.arrayOf(PropTypes.shape({
|
|
129
|
+
property: PropTypes.string,
|
|
130
|
+
operator: PropTypes.string,
|
|
131
|
+
value: PropTypes.string
|
|
132
|
+
}))
|
|
133
|
+
}))
|
|
134
|
+
}),
|
|
135
|
+
/* Provide a label to the button that starts condition builder
|
|
88
136
|
*/
|
|
89
137
|
startConditionLabel: PropTypes.string.isRequired
|
|
90
138
|
};
|
|
91
139
|
|
|
92
|
-
export { ConditionBuilderContent as default };
|
|
140
|
+
export { ConditionBuilderContent$1 as default };
|
|
@@ -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<
|
|
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<
|
|
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';
|
|
@@ -17,7 +17,8 @@ var emptyState = {
|
|
|
17
17
|
conditions: [{
|
|
18
18
|
property: undefined,
|
|
19
19
|
operator: '',
|
|
20
|
-
value: ''
|
|
20
|
+
value: '',
|
|
21
|
+
popoverToOpen: 'propertyField'
|
|
21
22
|
}]
|
|
22
23
|
}]
|
|
23
24
|
};
|
|
@@ -50,7 +51,9 @@ var ConditionBuilderProvider = function ConditionBuilderProvider(props) {
|
|
|
50
51
|
rootState: rootState,
|
|
51
52
|
setRootState: setRootState,
|
|
52
53
|
inputConfig: props.inputConfig,
|
|
53
|
-
popOverSearchThreshold: props.popOverSearchThreshold
|
|
54
|
+
popOverSearchThreshold: props.popOverSearchThreshold,
|
|
55
|
+
getOptions: props.getOptions,
|
|
56
|
+
variant: props.variant
|
|
54
57
|
}
|
|
55
58
|
},
|
|
56
59
|
// eslint-disable-next-line react/prop-types
|
|
@@ -61,28 +64,44 @@ ConditionBuilderProvider.propTypes = {
|
|
|
61
64
|
* Provide the contents of the ConditionBuilder.
|
|
62
65
|
*/
|
|
63
66
|
children: PropTypes.node.isRequired,
|
|
67
|
+
/**
|
|
68
|
+
* This is an optional callback function that will be triggered when options array is not passed in the inputConfig against a property.
|
|
69
|
+
* This can be a asynchronous function that need to return a promise, so it will allow to fetch options from API call.
|
|
70
|
+
* options has to be in valid format
|
|
71
|
+
* [{
|
|
72
|
+
label: 'label',
|
|
73
|
+
id: 'id',
|
|
74
|
+
},...]
|
|
75
|
+
*/
|
|
76
|
+
getOptions: PropTypes.func,
|
|
64
77
|
/**
|
|
65
78
|
* This is a mandatory prop that defines the input to the condition builder.
|
|
66
|
-
|
|
79
|
+
|
|
67
80
|
*/
|
|
68
81
|
inputConfig: PropTypes.shape({
|
|
69
82
|
properties: PropTypes.arrayOf(PropTypes.shape({
|
|
70
83
|
id: PropTypes.string,
|
|
71
84
|
label: PropTypes.string,
|
|
72
|
-
icon: PropTypes.func,
|
|
73
|
-
type: PropTypes.oneOf(['text', 'number', 'date', 'option']),
|
|
85
|
+
icon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
86
|
+
type: PropTypes.oneOf(['text', 'number', 'date', 'option', 'time']),
|
|
74
87
|
config: PropTypes.shape({
|
|
75
88
|
options: PropTypes.arrayOf(PropTypes.shape({
|
|
76
89
|
id: PropTypes.string,
|
|
77
90
|
label: PropTypes.string,
|
|
78
|
-
icon: PropTypes.func
|
|
91
|
+
icon: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
|
|
79
92
|
})),
|
|
80
93
|
includeSearch: PropTypes.bool
|
|
81
94
|
})
|
|
82
95
|
}))
|
|
83
96
|
}).isRequired,
|
|
84
|
-
|
|
85
|
-
|
|
97
|
+
/**
|
|
98
|
+
* Provide an mandatory numeric value that will be used to enable search option in the popovers with list.
|
|
99
|
+
*/
|
|
100
|
+
popOverSearchThreshold: PropTypes.number.isRequired,
|
|
101
|
+
/**
|
|
102
|
+
* Provide the condition builder variant: sentence/ tree
|
|
103
|
+
*/
|
|
104
|
+
variant: PropTypes.string.isRequired
|
|
86
105
|
};
|
|
87
106
|
|
|
88
107
|
export { ConditionBuilderContext, ConditionBuilderProvider, emptyState };
|
|
@@ -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
|
+
}
|