@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
|
@@ -15,22 +15,21 @@ var react = require('@carbon/react');
|
|
|
15
15
|
var index = require('../../node_modules/prop-types/index.js');
|
|
16
16
|
var cx = require('classnames');
|
|
17
17
|
var devtools = require('../../global/js/utils/devtools.js');
|
|
18
|
-
var settings = require('../../settings.js');
|
|
19
18
|
var ConditionBuilderContent = require('./ConditionBuilderContent/ConditionBuilderContent.js');
|
|
20
|
-
var
|
|
19
|
+
var ConditionBuilderProvider = require('./ConditionBuilderContext/ConditionBuilderProvider.js');
|
|
20
|
+
var settings = require('../../settings.js');
|
|
21
|
+
var DataConfigs = require('./ConditionBuilderContext/DataConfigs.js');
|
|
21
22
|
|
|
22
23
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
23
24
|
|
|
24
25
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
25
26
|
var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
|
26
27
|
|
|
27
|
-
var _excluded = ["className", "inputConfig", "startConditionLabel", "popOverSearchThreshold"];
|
|
28
|
+
var _excluded = ["className", "inputConfig", "startConditionLabel", "popOverSearchThreshold", "getOptions", "initialState", "getConditionState", "variant"];
|
|
28
29
|
|
|
29
30
|
// Carbon and package components we use.
|
|
30
31
|
/* TODO: @import(s) of carbon components and other package components. */
|
|
31
32
|
|
|
32
|
-
// The block part of our conventional BEM class names (blockClass__E--M).
|
|
33
|
-
var blockClass = "".concat(settings.pkg.prefix, "--condition-builder");
|
|
34
33
|
var componentName = 'ConditionBuilder';
|
|
35
34
|
|
|
36
35
|
// NOTE: the component SCSS is not imported here: it is rolled up separately.
|
|
@@ -58,12 +57,20 @@ exports.ConditionBuilder = /*#__PURE__*/React__default["default"].forwardRef(fun
|
|
|
58
57
|
inputConfig = _ref.inputConfig,
|
|
59
58
|
startConditionLabel = _ref.startConditionLabel,
|
|
60
59
|
popOverSearchThreshold = _ref.popOverSearchThreshold,
|
|
60
|
+
getOptions = _ref.getOptions,
|
|
61
|
+
initialState = _ref.initialState,
|
|
62
|
+
getConditionState = _ref.getConditionState,
|
|
63
|
+
variant = _ref.variant,
|
|
61
64
|
rest = _rollupPluginBabelHelpers.objectWithoutProperties(_ref, _excluded);
|
|
62
|
-
|
|
65
|
+
var localRef = React.useRef();
|
|
66
|
+
var conditionBuilderRef = ref || localRef;
|
|
67
|
+
return /*#__PURE__*/React__default["default"].createElement(ConditionBuilderProvider.ConditionBuilderProvider, {
|
|
63
68
|
inputConfig: inputConfig,
|
|
64
|
-
popOverSearchThreshold: popOverSearchThreshold
|
|
69
|
+
popOverSearchThreshold: popOverSearchThreshold,
|
|
70
|
+
getOptions: getOptions,
|
|
71
|
+
variant: variant
|
|
65
72
|
}, /*#__PURE__*/React__default["default"].createElement("div", _rollupPluginBabelHelpers["extends"]({}, rest, {
|
|
66
|
-
className: cx__default["default"](blockClass,
|
|
73
|
+
className: cx__default["default"](DataConfigs.blockClass,
|
|
67
74
|
// Apply the block class to the main HTML element
|
|
68
75
|
className,
|
|
69
76
|
// Apply any supplied class names to the main HTML element.
|
|
@@ -72,10 +79,15 @@ exports.ConditionBuilder = /*#__PURE__*/React__default["default"].forwardRef(fun
|
|
|
72
79
|
// switched classes dependant on props or state
|
|
73
80
|
// example: [`${blockClass}__here-if-small`]: size === 'sm',
|
|
74
81
|
}),
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}, devtools.getDevtoolsProps(componentName)), /*#__PURE__*/React__default["default"].createElement(react.VStack,
|
|
78
|
-
|
|
82
|
+
role: "main",
|
|
83
|
+
ref: conditionBuilderRef
|
|
84
|
+
}, devtools.getDevtoolsProps(componentName)), /*#__PURE__*/React__default["default"].createElement(react.VStack, {
|
|
85
|
+
className: "".concat(DataConfigs.blockClass, "__").concat(variant)
|
|
86
|
+
}, /*#__PURE__*/React__default["default"].createElement(ConditionBuilderContent["default"], {
|
|
87
|
+
startConditionLabel: startConditionLabel,
|
|
88
|
+
conditionBuilderRef: conditionBuilderRef,
|
|
89
|
+
getConditionState: getConditionState,
|
|
90
|
+
initialState: initialState
|
|
79
91
|
}))));
|
|
80
92
|
});
|
|
81
93
|
|
|
@@ -99,6 +111,20 @@ exports.ConditionBuilder.propTypes = {
|
|
|
99
111
|
* Provide an optional class to be applied to the containing node.
|
|
100
112
|
*/
|
|
101
113
|
className: index["default"].string,
|
|
114
|
+
getConditionState: index["default"].func.isRequired,
|
|
115
|
+
getOptions: index["default"].func,
|
|
116
|
+
initialState: index["default"].shape({
|
|
117
|
+
groups: index["default"].arrayOf(index["default"].shape({
|
|
118
|
+
groupSeparateOperator: index["default"].string,
|
|
119
|
+
groupOperator: index["default"].string,
|
|
120
|
+
statement: index["default"].string,
|
|
121
|
+
conditions: index["default"].arrayOf(index["default"].shape({
|
|
122
|
+
property: index["default"].string,
|
|
123
|
+
operator: index["default"].string,
|
|
124
|
+
value: index["default"].string
|
|
125
|
+
}))
|
|
126
|
+
}))
|
|
127
|
+
}),
|
|
102
128
|
/**
|
|
103
129
|
* This is a mandatory prop that defines the input to the condition builder.
|
|
104
130
|
|
|
@@ -107,13 +133,13 @@ exports.ConditionBuilder.propTypes = {
|
|
|
107
133
|
properties: index["default"].arrayOf(index["default"].shape({
|
|
108
134
|
id: index["default"].string,
|
|
109
135
|
label: index["default"].string,
|
|
110
|
-
icon: index["default"].func,
|
|
111
|
-
type: index["default"].oneOf(['text', 'number', 'date', 'option']),
|
|
136
|
+
icon: index["default"].oneOfType([index["default"].func, index["default"].object]),
|
|
137
|
+
type: index["default"].oneOf(['text', 'number', 'date', 'option', 'time']),
|
|
112
138
|
config: index["default"].shape({
|
|
113
139
|
options: index["default"].arrayOf(index["default"].shape({
|
|
114
140
|
id: index["default"].string,
|
|
115
141
|
label: index["default"].string,
|
|
116
|
-
icon: index["default"].func
|
|
142
|
+
icon: index["default"].oneOfType([index["default"].func, index["default"].object])
|
|
117
143
|
})),
|
|
118
144
|
includeSearch: index["default"].bool
|
|
119
145
|
})
|
|
@@ -126,7 +152,10 @@ exports.ConditionBuilder.propTypes = {
|
|
|
126
152
|
/**
|
|
127
153
|
* Provide a label to the button that starts condition builder
|
|
128
154
|
*/
|
|
129
|
-
startConditionLabel: index["default"].string.isRequired
|
|
130
|
-
|
|
155
|
+
startConditionLabel: index["default"].string.isRequired,
|
|
131
156
|
/* TODO: add types and DocGen for all props. */
|
|
157
|
+
/**
|
|
158
|
+
* Provide the condition builder variant: sentence/ tree
|
|
159
|
+
*/
|
|
160
|
+
variant: index["default"].string.isRequired
|
|
132
161
|
};
|
|
@@ -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,48 @@
|
|
|
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 React = require('react');
|
|
13
|
+
var icons = require('@carbon/react/icons');
|
|
14
|
+
var ConditionBuilderButton = require('../ConditionBuilderButton/ConditionBuilderButton.js');
|
|
15
|
+
var index = require('../../../node_modules/prop-types/index.js');
|
|
16
|
+
var DataConfigs = require('../ConditionBuilderContext/DataConfigs.js');
|
|
17
|
+
|
|
18
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
19
|
+
|
|
20
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
21
|
+
|
|
22
|
+
var ConditionBuilderAdd = function ConditionBuilderAdd(_ref) {
|
|
23
|
+
var className = _ref.className,
|
|
24
|
+
onClick = _ref.onClick;
|
|
25
|
+
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
26
|
+
className: className
|
|
27
|
+
}, /*#__PURE__*/React__default["default"].createElement(ConditionBuilderButton.ConditionBuilderButton, {
|
|
28
|
+
renderIcon: icons.AddAlt,
|
|
29
|
+
onClick: onClick,
|
|
30
|
+
className: "".concat(DataConfigs.blockClass, "__add-button"),
|
|
31
|
+
hideLabel: true,
|
|
32
|
+
label: DataConfigs.translateWithId('add-condition'),
|
|
33
|
+
role: "gridcell"
|
|
34
|
+
}));
|
|
35
|
+
};
|
|
36
|
+
var ConditionBuilderAdd$1 = ConditionBuilderAdd;
|
|
37
|
+
ConditionBuilderAdd.propTypes = {
|
|
38
|
+
/**
|
|
39
|
+
* Provide an optional class to be applied to the containing node.
|
|
40
|
+
*/
|
|
41
|
+
className: index["default"].string,
|
|
42
|
+
/**
|
|
43
|
+
* callback triggered on click of add button
|
|
44
|
+
*/
|
|
45
|
+
onClick: index["default"].func
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
exports["default"] = ConditionBuilderAdd$1;
|
|
@@ -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,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;
|
package/lib/components/ConditionBuilder/ConditionBuilderContent/ConditionBuilderContent.d.ts
CHANGED
|
@@ -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
|
|
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
|
|
25
|
-
function ConditionBuilderContent(_ref) {
|
|
25
|
+
var ConditionBuilderContent = function ConditionBuilderContent(_ref) {
|
|
26
26
|
var _rootState$groups2;
|
|
27
|
-
var startConditionLabel = _ref.startConditionLabel
|
|
28
|
-
|
|
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
|
-
|
|
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(
|
|
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
|
-
|
|
58
|
-
|
|
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(
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
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
|
-
*
|
|
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<
|
|
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';
|
|
@@ -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
|
-
|
|
93
|
-
|
|
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
|
+
}
|