@carbon/ibm-products 2.43.2-canary.19 → 2.43.2-canary.20
Sign up to get free protection for your applications and to get access to all the features.
- package/css/index-full-carbon.css +32 -1
- 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.css +32 -1
- 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 +32 -1
- package/css/index.css.map +1 -1
- package/css/index.min.css +1 -1
- package/css/index.min.css.map +1 -1
- package/es/components/ConditionBuilder/ConditionBlock/ConditionBlock.js +23 -21
- package/es/components/ConditionBuilder/ConditionBuilder.js +67 -20
- package/es/components/ConditionBuilder/ConditionBuilderActions/ConditionBuilderActions.d.ts +15 -0
- package/es/components/ConditionBuilder/ConditionBuilderActions/ConditionBuilderActions.js +129 -0
- package/es/components/ConditionBuilder/ConditionBuilderAdd/ConditionBuilderAdd.js +6 -4
- package/es/components/ConditionBuilder/ConditionBuilderButton/ConditionBuilderButton.d.ts +5 -1
- package/es/components/ConditionBuilder/ConditionBuilderButton/ConditionBuilderButton.js +16 -4
- package/es/components/ConditionBuilder/ConditionBuilderConnector/ConditionConnector.js +2 -2
- package/es/components/ConditionBuilder/ConditionBuilderConnector/GroupConnector.js +2 -2
- package/es/components/ConditionBuilder/ConditionBuilderContent/ConditionBuilderContent.d.ts +9 -11
- package/es/components/ConditionBuilder/ConditionBuilderContent/ConditionBuilderContent.js +36 -32
- package/es/components/ConditionBuilder/ConditionBuilderContext/ConditionBuilderProvider.d.ts +0 -1
- package/es/components/ConditionBuilder/ConditionBuilderContext/ConditionBuilderProvider.js +7 -2
- package/es/components/ConditionBuilder/ConditionBuilderContext/DataConfigs.d.ts +6 -1
- package/es/components/ConditionBuilder/ConditionBuilderContext/DataConfigs.js +18 -10
- package/es/components/ConditionBuilder/ConditionBuilderContext/translationObject.d.ts +39 -36
- package/es/components/ConditionBuilder/ConditionBuilderContext/translationObject.js +12 -10
- package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItem.d.ts +1 -1
- package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItem.js +24 -16
- package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemNumber/ConditionBuilderItemNumber.js +19 -4
- package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemOption/ItemOption.d.ts +13 -0
- package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemOption/ItemOption.js +109 -0
- package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemOption/{ConditionBuilderItemOption.d.ts → ItemOptionForValueField.d.ts} +2 -2
- package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemOption/{ConditionBuilderItemOption.js → ItemOptionForValueField.js} +58 -33
- package/es/components/ConditionBuilder/ConditionGroupBuilder/ConditionGroupBuilder.js +4 -6
- package/es/components/ConditionBuilder/ConditionPreview/ConditionPreview.js +14 -5
- package/es/components/ConditionBuilder/utils/handleKeyboardEvents.js +1 -2
- package/es/components/ConditionBuilder/utils/util.d.ts +1 -0
- package/es/components/ConditionBuilder/utils/util.js +16 -1
- package/lib/components/ConditionBuilder/ConditionBlock/ConditionBlock.js +23 -21
- package/lib/components/ConditionBuilder/ConditionBuilder.js +67 -20
- package/lib/components/ConditionBuilder/ConditionBuilderActions/ConditionBuilderActions.d.ts +15 -0
- package/lib/components/ConditionBuilder/ConditionBuilderActions/ConditionBuilderActions.js +137 -0
- package/lib/components/ConditionBuilder/ConditionBuilderAdd/ConditionBuilderAdd.js +6 -3
- package/lib/components/ConditionBuilder/ConditionBuilderButton/ConditionBuilderButton.d.ts +5 -1
- package/lib/components/ConditionBuilder/ConditionBuilderButton/ConditionBuilderButton.js +16 -4
- package/lib/components/ConditionBuilder/ConditionBuilderConnector/ConditionConnector.js +2 -2
- package/lib/components/ConditionBuilder/ConditionBuilderConnector/GroupConnector.js +2 -2
- package/lib/components/ConditionBuilder/ConditionBuilderContent/ConditionBuilderContent.d.ts +9 -11
- package/lib/components/ConditionBuilder/ConditionBuilderContent/ConditionBuilderContent.js +36 -32
- package/lib/components/ConditionBuilder/ConditionBuilderContext/ConditionBuilderProvider.d.ts +0 -1
- package/lib/components/ConditionBuilder/ConditionBuilderContext/ConditionBuilderProvider.js +7 -2
- package/lib/components/ConditionBuilder/ConditionBuilderContext/DataConfigs.d.ts +6 -1
- package/lib/components/ConditionBuilder/ConditionBuilderContext/DataConfigs.js +18 -10
- package/lib/components/ConditionBuilder/ConditionBuilderContext/translationObject.d.ts +39 -36
- package/lib/components/ConditionBuilder/ConditionBuilderContext/translationObject.js +12 -10
- package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItem.d.ts +1 -1
- package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItem.js +23 -15
- package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemNumber/ConditionBuilderItemNumber.js +20 -5
- package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemOption/ItemOption.d.ts +13 -0
- package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemOption/ItemOption.js +117 -0
- package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemOption/{ConditionBuilderItemOption.d.ts → ItemOptionForValueField.d.ts} +2 -2
- package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemOption/{ConditionBuilderItemOption.js → ItemOptionForValueField.js} +56 -31
- package/lib/components/ConditionBuilder/ConditionGroupBuilder/ConditionGroupBuilder.js +4 -6
- package/lib/components/ConditionBuilder/ConditionPreview/ConditionPreview.js +14 -4
- package/lib/components/ConditionBuilder/utils/handleKeyboardEvents.js +1 -2
- package/lib/components/ConditionBuilder/utils/util.d.ts +1 -0
- package/lib/components/ConditionBuilder/utils/util.js +17 -0
- package/package.json +3 -3
- package/scss/components/ConditionBuilder/styles/_conditionBuilderCondition.scss +9 -1
- package/scss/components/ConditionBuilder/styles/_conditionBuilderItem.scss +26 -1
- package/es/components/ConditionBuilder/utils/checkForHoldingKey.d.ts +0 -1
- package/es/components/ConditionBuilder/utils/checkForHoldingKey.js +0 -16
- package/lib/components/ConditionBuilder/utils/checkForHoldingKey.d.ts +0 -1
- package/lib/components/ConditionBuilder/utils/checkForHoldingKey.js +0 -20
@@ -26,7 +26,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
26
26
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
27
27
|
var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
28
28
|
|
29
|
-
var _excluded = ["className", "inputConfig", "startConditionLabel", "popOverSearchThreshold", "getOptions", "initialState", "getConditionState", "variant"];
|
29
|
+
var _excluded = ["className", "inputConfig", "startConditionLabel", "popOverSearchThreshold", "getOptions", "initialState", "getConditionState", "getActionsState", "variant", "actions"];
|
30
30
|
|
31
31
|
// Carbon and package components we use.
|
32
32
|
/* TODO: @import(s) of carbon components and other package components. */
|
@@ -61,7 +61,9 @@ exports.ConditionBuilder = /*#__PURE__*/React__default["default"].forwardRef(fun
|
|
61
61
|
getOptions = _ref.getOptions,
|
62
62
|
initialState = _ref.initialState,
|
63
63
|
getConditionState = _ref.getConditionState,
|
64
|
+
getActionsState = _ref.getActionsState,
|
64
65
|
variant = _ref.variant,
|
66
|
+
actions = _ref.actions,
|
65
67
|
rest = _rollupPluginBabelHelpers.objectWithoutProperties(_ref, _excluded);
|
66
68
|
var localRef = React.useRef();
|
67
69
|
var conditionBuilderRef = ref || localRef;
|
@@ -92,7 +94,9 @@ exports.ConditionBuilder = /*#__PURE__*/React__default["default"].forwardRef(fun
|
|
92
94
|
startConditionLabel: startConditionLabel,
|
93
95
|
conditionBuilderRef: conditionBuilderRef,
|
94
96
|
getConditionState: getConditionState,
|
95
|
-
|
97
|
+
getActionsState: getActionsState,
|
98
|
+
initialState: initialState,
|
99
|
+
actions: actions
|
96
100
|
}))));
|
97
101
|
});
|
98
102
|
|
@@ -108,27 +112,66 @@ exports.ConditionBuilder.displayName = componentName;
|
|
108
112
|
// See https://www.npmjs.com/package/prop-types#usage.
|
109
113
|
exports.ConditionBuilder.propTypes = {
|
110
114
|
/**
|
111
|
-
*
|
115
|
+
* optional array of actions
|
112
116
|
*/
|
113
|
-
|
114
|
-
|
117
|
+
actions: index["default"].arrayOf(index["default"].shape({
|
118
|
+
id: index["default"].oneOfType([index["default"].string | index["default"].number]).isRequired,
|
119
|
+
label: index["default"].string.isRequired
|
120
|
+
})),
|
115
121
|
/**
|
116
122
|
* Provide an optional class to be applied to the containing node.
|
117
123
|
*/
|
118
124
|
className: index["default"].string,
|
125
|
+
/**
|
126
|
+
* This is a callback that gives back the updated action state
|
127
|
+
*/
|
128
|
+
getActionsState: index["default"].func,
|
129
|
+
/**
|
130
|
+
* This is a callback that gives back updated condition state
|
131
|
+
*/
|
119
132
|
getConditionState: index["default"].func.isRequired,
|
133
|
+
/**
|
134
|
+
* This is a callback that get triggered when you want to dynamically fetch options.
|
135
|
+
* Component call this when the option array is not passed against a property with type as option in the input config.
|
136
|
+
* This is an asynchronous callback that can return a promise , and you need to resolve the promise with options array in the valid format.
|
137
|
+
* You will receive the root condition state and current condition as the 2 arguments.
|
138
|
+
* eg: const getOptions = async (conditionState,condition) => {
|
139
|
+
switch (condition.property) {
|
140
|
+
case 'continent':
|
141
|
+
return new Promise((resolve) => {
|
142
|
+
const continents=[{
|
143
|
+
label: 'Africa',
|
144
|
+
id: 'Africa',
|
145
|
+
},...]
|
146
|
+
resolve(continents);
|
147
|
+
});
|
148
|
+
default:
|
149
|
+
return [];
|
150
|
+
}
|
151
|
+
};
|
152
|
+
*/
|
120
153
|
getOptions: index["default"].func,
|
154
|
+
/**
|
155
|
+
* Optional prop if you want to pass a saved condition state.
|
156
|
+
* This object should respect the structure of condition state that is available in getConditionState callback
|
157
|
+
*/
|
121
158
|
initialState: index["default"].shape({
|
122
159
|
groups: index["default"].arrayOf(index["default"].shape({
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
160
|
+
groupOperator: index["default"].string.isRequired,
|
161
|
+
statement: index["default"].string.isRequired,
|
162
|
+
conditions: index["default"].arrayOf(index["default"].oneOfType([index["default"].shape({
|
163
|
+
property: index["default"].string.isRequired,
|
164
|
+
operator: index["default"].string.isRequired,
|
165
|
+
value: index["default"].oneOfType([index["default"].string, index["default"].arrayOf(index["default"].shape({
|
166
|
+
id: index["default"].string,
|
167
|
+
label: index["default"].string
|
168
|
+
})), index["default"].shape({
|
169
|
+
id: index["default"].string,
|
170
|
+
label: index["default"].string
|
171
|
+
})])
|
172
|
+
}), index["default"].object]))
|
173
|
+
})),
|
174
|
+
operator: index["default"].string
|
132
175
|
}),
|
133
176
|
/**
|
134
177
|
* This is a mandatory prop that defines the input to the condition builder.
|
@@ -136,17 +179,21 @@ exports.ConditionBuilder.propTypes = {
|
|
136
179
|
*/
|
137
180
|
inputConfig: index["default"].shape({
|
138
181
|
properties: index["default"].arrayOf(index["default"].shape({
|
139
|
-
id: index["default"].string,
|
140
|
-
label: index["default"].string,
|
182
|
+
id: index["default"].string.isRequired,
|
183
|
+
label: index["default"].string.isRequired,
|
141
184
|
icon: index["default"].oneOfType([index["default"].func, index["default"].object]),
|
142
|
-
type: index["default"].oneOf(['text', 'number', 'date', 'option', 'time']),
|
185
|
+
type: index["default"].oneOf(['text', 'number', 'date', 'option', 'time', 'custom']).isRequired,
|
143
186
|
config: index["default"].shape({
|
144
187
|
options: index["default"].arrayOf(index["default"].shape({
|
145
|
-
id: index["default"].string,
|
146
|
-
label: index["default"].string,
|
188
|
+
id: index["default"].string.isRequired,
|
189
|
+
label: index["default"].string.isRequired,
|
147
190
|
icon: index["default"].oneOfType([index["default"].func, index["default"].object])
|
148
191
|
})),
|
149
|
-
|
192
|
+
component: index["default"].func,
|
193
|
+
operators: index["default"].arrayOf(index["default"].shape({
|
194
|
+
id: index["default"].string.isRequired,
|
195
|
+
label: index["default"].string.isRequired
|
196
|
+
}))
|
150
197
|
})
|
151
198
|
}))
|
152
199
|
}).isRequired,
|
@@ -0,0 +1,15 @@
|
|
1
|
+
export default ConditionBuilderActions;
|
2
|
+
declare function ConditionBuilderActions({ actions, className }: {
|
3
|
+
actions: any;
|
4
|
+
className: any;
|
5
|
+
}): import("react/jsx-runtime").JSX.Element;
|
6
|
+
declare namespace ConditionBuilderActions {
|
7
|
+
namespace propTypes {
|
8
|
+
let actions: PropTypes.Requireable<(PropTypes.InferProps<{
|
9
|
+
id: PropTypes.Requireable<number>;
|
10
|
+
label: PropTypes.Requireable<string>;
|
11
|
+
}> | null | undefined)[]>;
|
12
|
+
let className: PropTypes.Requireable<string>;
|
13
|
+
}
|
14
|
+
}
|
15
|
+
import PropTypes from 'prop-types';
|
@@ -0,0 +1,137 @@
|
|
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 index = require('../../../node_modules/prop-types/index.js');
|
15
|
+
var icons = require('@carbon/react/icons');
|
16
|
+
var react = require('@carbon/react');
|
17
|
+
var ConditionBuilderItem = require('../ConditionBuilderItem/ConditionBuilderItem.js');
|
18
|
+
var DataConfigs = require('../ConditionBuilderContext/DataConfigs.js');
|
19
|
+
var ItemOption = require('../ConditionBuilderItem/ConditionBuilderItemOption/ItemOption.js');
|
20
|
+
var ConditionBuilderProvider = require('../ConditionBuilderContext/ConditionBuilderProvider.js');
|
21
|
+
var ConditionBuilderAdd = require('../ConditionBuilderAdd/ConditionBuilderAdd.js');
|
22
|
+
var uuidv4 = require('../../../global/js/utils/uuidv4.js');
|
23
|
+
var ConditionBuilderButton = require('../ConditionBuilderButton/ConditionBuilderButton.js');
|
24
|
+
var util = require('../utils/util.js');
|
25
|
+
|
26
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
27
|
+
|
28
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
29
|
+
|
30
|
+
var ConditionBuilderActions = function ConditionBuilderActions(_ref) {
|
31
|
+
var actions = _ref.actions,
|
32
|
+
className = _ref.className;
|
33
|
+
var _useContext = React.useContext(ConditionBuilderProvider.ConditionBuilderContext),
|
34
|
+
actionState = _useContext.actionState,
|
35
|
+
setActionState = _useContext.setActionState;
|
36
|
+
var addActionHandler = function addActionHandler() {
|
37
|
+
var action = {
|
38
|
+
id: uuidv4["default"](),
|
39
|
+
label: undefined,
|
40
|
+
popoverToOpen: 'actionField'
|
41
|
+
};
|
42
|
+
setActionState([].concat(_rollupPluginBabelHelpers.toConsumableArray(actionState), [action]));
|
43
|
+
};
|
44
|
+
var onchangeHandler = function onchangeHandler(evt, selectedId, actionIndex, currentAction) {
|
45
|
+
var action = actions.find(function (action) {
|
46
|
+
return action.id === selectedId;
|
47
|
+
}); //fetch the selected action from the input action array
|
48
|
+
|
49
|
+
//if the action is duplicate, that action is added with a new id, else the same action is used.
|
50
|
+
// same actions can be added multiple times
|
51
|
+
var newAction = util.checkDuplicateAction(actionState, selectedId, currentAction.id) ? _rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, action), {}, {
|
52
|
+
id: uuidv4["default"]()
|
53
|
+
}) : action;
|
54
|
+
setActionState([].concat(_rollupPluginBabelHelpers.toConsumableArray(actionState.slice(0, actionIndex)), [newAction], _rollupPluginBabelHelpers.toConsumableArray(actionState.slice(actionIndex + 1))));
|
55
|
+
util.focusThisField(evt);
|
56
|
+
};
|
57
|
+
var onRemove = function onRemove(selectedId) {
|
58
|
+
setActionState(actionState.filter(function (action) {
|
59
|
+
return action.id !== selectedId;
|
60
|
+
}));
|
61
|
+
};
|
62
|
+
return /*#__PURE__*/React__default["default"].createElement("div", {
|
63
|
+
className: "".concat(className)
|
64
|
+
}, /*#__PURE__*/React__default["default"].createElement(react.Section, {
|
65
|
+
className: "".concat(DataConfigs.blockClass, "__heading"),
|
66
|
+
level: 4
|
67
|
+
}, /*#__PURE__*/React__default["default"].createElement(react.Heading, null, DataConfigs.translateWithId('actions'))), /*#__PURE__*/React__default["default"].createElement("div", {
|
68
|
+
className: "".concat(DataConfigs.blockClass, "__condition-wrapper")
|
69
|
+
}, actionState === null || actionState === void 0 ? void 0 : actionState.map(function (action, index) {
|
70
|
+
return /*#__PURE__*/React__default["default"].createElement("div", {
|
71
|
+
key: action.id,
|
72
|
+
"aria-hidden": true,
|
73
|
+
className: "".concat(DataConfigs.blockClass, "__condition-block conditionBlockWrapper ").concat(DataConfigs.blockClass, "__gap ").concat(DataConfigs.blockClass, "__gap-bottom ")
|
74
|
+
}, /*#__PURE__*/React__default["default"].createElement(ConditionBuilderItem.ConditionBuilderItem, {
|
75
|
+
className: "".concat(DataConfigs.blockClass, "__statement-button"),
|
76
|
+
popOverClassName: "".concat(DataConfigs.blockClass, "__gap"),
|
77
|
+
label: index === 0 ? DataConfigs.translateWithId('then') : DataConfigs.translateWithId('and')
|
78
|
+
}), /*#__PURE__*/React__default["default"].createElement(ConditionBuilderItem.ConditionBuilderItem, {
|
79
|
+
label: action.label,
|
80
|
+
title: DataConfigs.translateWithId('actions'),
|
81
|
+
popOverClassName: "".concat(DataConfigs.blockClass, "__gap"),
|
82
|
+
condition: action,
|
83
|
+
"data-name": "actionField"
|
84
|
+
}, /*#__PURE__*/React__default["default"].createElement(ItemOption.ItemOption, {
|
85
|
+
conditionState: {
|
86
|
+
value: action.label
|
87
|
+
},
|
88
|
+
onChange: function onChange(selectedId, evt) {
|
89
|
+
return onchangeHandler(evt, selectedId, index, action);
|
90
|
+
},
|
91
|
+
config: {
|
92
|
+
options: actions
|
93
|
+
}
|
94
|
+
})), /*#__PURE__*/React__default["default"].createElement("span", {
|
95
|
+
role: "gridcell",
|
96
|
+
"aria-label": DataConfigs.translateWithId('remove_action')
|
97
|
+
}, /*#__PURE__*/React__default["default"].createElement(ConditionBuilderButton.ConditionBuilderButton, {
|
98
|
+
hideLabel: true,
|
99
|
+
label: DataConfigs.translateWithId('remove_action'),
|
100
|
+
onClick: function onClick() {
|
101
|
+
return onRemove(action.id);
|
102
|
+
}
|
103
|
+
// onMouseEnter={handleShowDeletionPreview}
|
104
|
+
// onMouseLeave={handleHideDeletionPreview}
|
105
|
+
// onFocus={handleShowDeletionPreview}
|
106
|
+
// onBlur={handleHideDeletionPreview}
|
107
|
+
,
|
108
|
+
renderIcon: icons.Close,
|
109
|
+
className: "".concat(DataConfigs.blockClass, "__close-condition"),
|
110
|
+
"data-name": "closeCondition"
|
111
|
+
})), actionState.length === index + 1 && /*#__PURE__*/React__default["default"].createElement(ConditionBuilderAdd["default"], {
|
112
|
+
onClick: addActionHandler,
|
113
|
+
className: "".concat(DataConfigs.blockClass, "__gap ").concat(DataConfigs.blockClass, "__gap-left"),
|
114
|
+
buttonLabel: DataConfigs.translateWithId('add_action')
|
115
|
+
}));
|
116
|
+
}), actionState.length === 0 && /*#__PURE__*/React__default["default"].createElement(ConditionBuilderAdd["default"], {
|
117
|
+
onClick: addActionHandler,
|
118
|
+
className: "".concat(DataConfigs.blockClass, "__gap ").concat(DataConfigs.blockClass, "__gap-left"),
|
119
|
+
buttonLabel: DataConfigs.translateWithId('add_action')
|
120
|
+
})));
|
121
|
+
};
|
122
|
+
var ConditionBuilderActions$1 = ConditionBuilderActions;
|
123
|
+
ConditionBuilderActions.propTypes = {
|
124
|
+
/**
|
125
|
+
* optional array of object that give the list of actions.
|
126
|
+
*/
|
127
|
+
actions: index["default"].arrayOf(index["default"].shape({
|
128
|
+
id: index["default"].number,
|
129
|
+
label: index["default"].string
|
130
|
+
})),
|
131
|
+
/**
|
132
|
+
* Provide an optional class to be applied to the containing node.
|
133
|
+
*/
|
134
|
+
className: index["default"].string
|
135
|
+
};
|
136
|
+
|
137
|
+
exports["default"] = ConditionBuilderActions$1;
|
@@ -11,6 +11,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
11
11
|
|
12
12
|
var _rollupPluginBabelHelpers = require('../../../_virtual/_rollupPluginBabelHelpers.js');
|
13
13
|
var React = require('react');
|
14
|
+
var cx = require('classnames');
|
14
15
|
var icons = require('@carbon/react/icons');
|
15
16
|
var ConditionBuilderButton = require('../ConditionBuilderButton/ConditionBuilderButton.js');
|
16
17
|
var index = require('../../../node_modules/prop-types/index.js');
|
@@ -19,6 +20,7 @@ var DataConfigs = require('../ConditionBuilderContext/DataConfigs.js');
|
|
19
20
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
20
21
|
|
21
22
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
23
|
+
var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
22
24
|
|
23
25
|
var ConditionBuilderAdd = function ConditionBuilderAdd(_ref) {
|
24
26
|
var className = _ref.className,
|
@@ -81,13 +83,14 @@ var ConditionBuilderAdd = function ConditionBuilderAdd(_ref) {
|
|
81
83
|
"data-name": "addButton",
|
82
84
|
label: buttonLabel !== null && buttonLabel !== void 0 ? buttonLabel : DataConfigs.translateWithId('add-condition'),
|
83
85
|
wrapperProps: wrapperProps
|
84
|
-
})),
|
86
|
+
})), enableSubGroup && /*#__PURE__*/React__default["default"].createElement(ConditionBuilderButton.ConditionBuilderButton, _rollupPluginBabelHelpers["extends"]({
|
85
87
|
renderIcon: icons.TextNewLine,
|
86
88
|
onClick: addConditionSubGroupHandler,
|
87
|
-
className: "".concat(DataConfigs.blockClass, "
|
89
|
+
className: cx__default["default"]("".concat(DataConfigs.blockClass, "__add_condition_group ").concat(DataConfigs.blockClass, "__gap-left")),
|
88
90
|
hideLabel: true,
|
89
91
|
label: DataConfigs.translateWithId('add-condition'),
|
90
|
-
wrapperProps: wrapperProps
|
92
|
+
wrapperProps: wrapperProps,
|
93
|
+
wrapperClassName: cx__default["default"]("".concat(DataConfigs.blockClass, "__add_condition_group-wrapper"), _rollupPluginBabelHelpers.defineProperty({}, "".concat(DataConfigs.blockClass, "__add_condition_group-wrapper--show"), isAddSubgroup))
|
91
94
|
}, previewHandlersForSubgroup())));
|
92
95
|
};
|
93
96
|
var ConditionBuilderAdd$1 = ConditionBuilderAdd;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
export function ConditionBuilderButton({ className, label, hideLabel, tooltipAlign, renderIcon: Icon, onClick, showToolTip, wrapperProps, onBlur, onFocus, onMouseEnter, onMouseLeave, }: {
|
1
|
+
export function ConditionBuilderButton({ className, label, hideLabel, tooltipAlign, renderIcon: Icon, onClick, showToolTip, wrapperProps, onBlur, onFocus, onMouseEnter, onMouseLeave, isInvalid, wrapperClassName, }: {
|
2
2
|
className: any;
|
3
3
|
label: any;
|
4
4
|
hideLabel: any;
|
@@ -11,11 +11,14 @@ export function ConditionBuilderButton({ className, label, hideLabel, tooltipAli
|
|
11
11
|
onFocus: any;
|
12
12
|
onMouseEnter: any;
|
13
13
|
onMouseLeave: any;
|
14
|
+
isInvalid: any;
|
15
|
+
wrapperClassName: any;
|
14
16
|
}): import("react/jsx-runtime").JSX.Element;
|
15
17
|
export namespace ConditionBuilderButton {
|
16
18
|
namespace propTypes {
|
17
19
|
let className: PropTypes.Requireable<string>;
|
18
20
|
let hideLabel: PropTypes.Requireable<boolean>;
|
21
|
+
let isInvalid: PropTypes.Requireable<boolean>;
|
19
22
|
let label: PropTypes.Requireable<string>;
|
20
23
|
let onBlur: PropTypes.Requireable<(...args: any[]) => any>;
|
21
24
|
let onClick: PropTypes.Requireable<(...args: any[]) => any>;
|
@@ -25,6 +28,7 @@ export namespace ConditionBuilderButton {
|
|
25
28
|
let renderIcon: PropTypes.Requireable<object>;
|
26
29
|
let showToolTip: PropTypes.Requireable<boolean>;
|
27
30
|
let tooltipAlign: PropTypes.Requireable<string>;
|
31
|
+
let wrapperClassName: PropTypes.Requireable<string>;
|
28
32
|
let wrapperProps: PropTypes.Requireable<object>;
|
29
33
|
}
|
30
34
|
}
|
@@ -15,12 +15,14 @@ var cx = require('classnames');
|
|
15
15
|
var index = require('../../../node_modules/prop-types/index.js');
|
16
16
|
var react = require('@carbon/react');
|
17
17
|
var DataConfigs = require('../ConditionBuilderContext/DataConfigs.js');
|
18
|
+
var icons = require('@carbon/react/icons');
|
18
19
|
|
19
20
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
20
21
|
|
21
22
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
22
23
|
var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
23
24
|
|
25
|
+
var _WarningAltFilled;
|
24
26
|
var ConditionBuilderButton = function ConditionBuilderButton(_ref) {
|
25
27
|
var _Icon, _span;
|
26
28
|
var className = _ref.className,
|
@@ -34,24 +36,26 @@ var ConditionBuilderButton = function ConditionBuilderButton(_ref) {
|
|
34
36
|
onBlur = _ref.onBlur,
|
35
37
|
onFocus = _ref.onFocus,
|
36
38
|
onMouseEnter = _ref.onMouseEnter,
|
37
|
-
onMouseLeave = _ref.onMouseLeave
|
39
|
+
onMouseLeave = _ref.onMouseLeave,
|
40
|
+
isInvalid = _ref.isInvalid,
|
41
|
+
wrapperClassName = _ref.wrapperClassName;
|
38
42
|
var Button = function Button() {
|
39
43
|
return /*#__PURE__*/React__default["default"].createElement("button", {
|
40
44
|
// role={'gridcell'}
|
41
45
|
tabIndex: -1,
|
42
|
-
className: cx__default["default"]([className, "".concat(DataConfigs.blockClass, "__button"), _rollupPluginBabelHelpers.defineProperty({}, "".concat(DataConfigs.blockClass, "__text-ellipsis"), showToolTip && !hideLabel)]),
|
46
|
+
className: cx__default["default"]([className, "".concat(DataConfigs.blockClass, "__button"), _rollupPluginBabelHelpers.defineProperty({}, "".concat(DataConfigs.blockClass, "__text-ellipsis"), showToolTip && !hideLabel && !isInvalid), _rollupPluginBabelHelpers.defineProperty({}, "".concat(DataConfigs.blockClass, "__invalid-input"), isInvalid)]),
|
43
47
|
type: "button",
|
44
48
|
onClick: onClick,
|
45
49
|
onBlur: onBlur,
|
46
50
|
onFocus: onFocus,
|
47
51
|
onMouseEnter: onMouseEnter,
|
48
52
|
onMouseLeave: onMouseLeave
|
49
|
-
}, Icon && (_Icon || (_Icon = /*#__PURE__*/React__default["default"].createElement(Icon, null))), !hideLabel && (_span || (_span = /*#__PURE__*/React__default["default"].createElement("span", null, label))));
|
53
|
+
}, Icon && (_Icon || (_Icon = /*#__PURE__*/React__default["default"].createElement(Icon, null))), !hideLabel && (_span || (_span = /*#__PURE__*/React__default["default"].createElement("span", null, label))), isInvalid && (_WarningAltFilled || (_WarningAltFilled = /*#__PURE__*/React__default["default"].createElement(icons.WarningAltFilled, null))));
|
50
54
|
};
|
51
55
|
return hideLabel || showToolTip ? /*#__PURE__*/React__default["default"].createElement(react.Tooltip, _rollupPluginBabelHelpers["extends"]({
|
52
56
|
label: label,
|
53
57
|
align: tooltipAlign,
|
54
|
-
className: "".concat(
|
58
|
+
className: "".concat(wrapperClassName)
|
55
59
|
}, wrapperProps), Button()) : /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, Button());
|
56
60
|
};
|
57
61
|
ConditionBuilderButton.propTypes = {
|
@@ -63,6 +67,10 @@ ConditionBuilderButton.propTypes = {
|
|
63
67
|
* decides if label and tooltip to be hidden
|
64
68
|
*/
|
65
69
|
hideLabel: index["default"].bool,
|
70
|
+
/**
|
71
|
+
* boolean to know the updated value in not valid
|
72
|
+
*/
|
73
|
+
isInvalid: index["default"].bool,
|
66
74
|
/**
|
67
75
|
* label of the button
|
68
76
|
*/
|
@@ -92,6 +100,10 @@ ConditionBuilderButton.propTypes = {
|
|
92
100
|
* tooltip position
|
93
101
|
*/
|
94
102
|
tooltipAlign: index["default"].string,
|
103
|
+
/**
|
104
|
+
* classname applies to the wrapper of popover
|
105
|
+
*/
|
106
|
+
wrapperClassName: index["default"].string,
|
95
107
|
/**
|
96
108
|
* optional props for tree grid to add role and aria-label to wrapper span
|
97
109
|
*/
|
@@ -12,7 +12,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
12
12
|
var _rollupPluginBabelHelpers = require('../../../_virtual/_rollupPluginBabelHelpers.js');
|
13
13
|
var React = require('react');
|
14
14
|
var ConditionBuilderItem = require('../ConditionBuilderItem/ConditionBuilderItem.js');
|
15
|
-
var
|
15
|
+
var ItemOption = require('../ConditionBuilderItem/ConditionBuilderItemOption/ItemOption.js');
|
16
16
|
var DataConfigs = require('../ConditionBuilderContext/DataConfigs.js');
|
17
17
|
var index = require('../../../node_modules/prop-types/index.js');
|
18
18
|
var util = require('../utils/util.js');
|
@@ -65,7 +65,7 @@ var ConditionConnector = function ConditionConnector(_ref) {
|
|
65
65
|
}, rest, {
|
66
66
|
popOverClassName: className,
|
67
67
|
className: "".concat(DataConfigs.blockClass, "__connector-button ")
|
68
|
-
}), /*#__PURE__*/React__default["default"].createElement(
|
68
|
+
}), /*#__PURE__*/React__default["default"].createElement(ItemOption.ItemOption, {
|
69
69
|
config: {
|
70
70
|
options: DataConfigs.connectorConfig
|
71
71
|
},
|
@@ -12,7 +12,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
12
12
|
var React = require('react');
|
13
13
|
var ConditionBuilderItem = require('../ConditionBuilderItem/ConditionBuilderItem.js');
|
14
14
|
var DataConfigs = require('../ConditionBuilderContext/DataConfigs.js');
|
15
|
-
var
|
15
|
+
var ItemOption = require('../ConditionBuilderItem/ConditionBuilderItemOption/ItemOption.js');
|
16
16
|
var util = require('../utils/util.js');
|
17
17
|
var ConditionBuilderProvider = require('../ConditionBuilderContext/ConditionBuilderProvider.js');
|
18
18
|
|
@@ -34,7 +34,7 @@ var GroupConnector = function GroupConnector() {
|
|
34
34
|
"data-name": "connectorField",
|
35
35
|
popOverClassName: "".concat(DataConfigs.blockClass, "__gap"),
|
36
36
|
className: "".concat(DataConfigs.blockClass, "__statement-button")
|
37
|
-
}, /*#__PURE__*/React__default["default"].createElement(
|
37
|
+
}, /*#__PURE__*/React__default["default"].createElement(ItemOption.ItemOption, {
|
38
38
|
conditionState: {
|
39
39
|
value: rootState.operator,
|
40
40
|
label: DataConfigs.translateWithId('condition')
|
package/lib/components/ConditionBuilder/ConditionBuilderContent/ConditionBuilderContent.d.ts
CHANGED
@@ -1,30 +1,28 @@
|
|
1
1
|
export default ConditionBuilderContent;
|
2
|
-
declare function ConditionBuilderContent({ startConditionLabel, conditionBuilderRef, getConditionState, initialState, }: {
|
2
|
+
declare function ConditionBuilderContent({ startConditionLabel, conditionBuilderRef, getConditionState, getActionsState, initialState, actions, }: {
|
3
3
|
startConditionLabel: any;
|
4
4
|
conditionBuilderRef: any;
|
5
5
|
getConditionState: any;
|
6
|
+
getActionsState: any;
|
6
7
|
initialState: any;
|
8
|
+
actions: any;
|
7
9
|
}): import("react/jsx-runtime").JSX.Element;
|
8
10
|
declare namespace ConditionBuilderContent {
|
9
11
|
namespace propTypes {
|
10
12
|
let actions: PropTypes.Requireable<(PropTypes.InferProps<{
|
11
|
-
id: PropTypes.
|
12
|
-
label: PropTypes.
|
13
|
+
id: PropTypes.Validator<NonNullable<NonNullable<string | number | null | undefined>>>;
|
14
|
+
label: PropTypes.Validator<string>;
|
13
15
|
}> | null | undefined)[]>;
|
14
16
|
let conditionBuilderRef: PropTypes.Requireable<object>;
|
15
17
|
let getActionsState: PropTypes.Requireable<(...args: any[]) => any>;
|
16
18
|
let getConditionState: PropTypes.Validator<(...args: any[]) => any>;
|
17
19
|
let initialState: PropTypes.Requireable<PropTypes.InferProps<{
|
18
20
|
groups: PropTypes.Requireable<(PropTypes.InferProps<{
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
conditions: PropTypes.Requireable<(PropTypes.InferProps<{
|
23
|
-
property: PropTypes.Requireable<string>;
|
24
|
-
operator: PropTypes.Requireable<string>;
|
25
|
-
value: PropTypes.Requireable<string>;
|
26
|
-
}> | null | undefined)[]>;
|
21
|
+
groupOperator: PropTypes.Validator<string>;
|
22
|
+
statement: PropTypes.Validator<string>;
|
23
|
+
conditions: PropTypes.Requireable<(object | null | undefined)[]>;
|
27
24
|
}> | null | undefined)[]>;
|
25
|
+
operator: PropTypes.Requireable<string>;
|
28
26
|
}>>;
|
29
27
|
let startConditionLabel: PropTypes.Validator<string>;
|
30
28
|
}
|
@@ -21,6 +21,7 @@ var ConditionBuilderButton = require('../ConditionBuilderButton/ConditionBuilder
|
|
21
21
|
var uuidv4 = require('../../../global/js/utils/uuidv4.js');
|
22
22
|
var ConditionPreview = require('../ConditionPreview/ConditionPreview.js');
|
23
23
|
var GroupConnector = require('../ConditionBuilderConnector/GroupConnector.js');
|
24
|
+
var ConditionBuilderActions = require('../ConditionBuilderActions/ConditionBuilderActions.js');
|
24
25
|
|
25
26
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
26
27
|
|
@@ -32,14 +33,14 @@ var ConditionBuilderContent = function ConditionBuilderContent(_ref) {
|
|
32
33
|
var startConditionLabel = _ref.startConditionLabel,
|
33
34
|
conditionBuilderRef = _ref.conditionBuilderRef,
|
34
35
|
getConditionState = _ref.getConditionState,
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
// );
|
36
|
+
getActionsState = _ref.getActionsState,
|
37
|
+
initialState = _ref.initialState,
|
38
|
+
actions = _ref.actions;
|
39
39
|
var _useContext = React.useContext(ConditionBuilderProvider.ConditionBuilderContext),
|
40
40
|
rootState = _useContext.rootState,
|
41
41
|
setRootState = _useContext.setRootState,
|
42
|
-
variant = _useContext.variant
|
42
|
+
variant = _useContext.variant,
|
43
|
+
actionState = _useContext.actionState;
|
43
44
|
var _useState = React.useState(false),
|
44
45
|
_useState2 = _rollupPluginBabelHelpers.slicedToArray(_useState, 2),
|
45
46
|
isConditionBuilderActive = _useState2[0],
|
@@ -61,11 +62,10 @@ var ConditionBuilderContent = function ConditionBuilderContent(_ref) {
|
|
61
62
|
|
62
63
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
63
64
|
}, [rootState]);
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
// }, [actionState]);
|
65
|
+
React.useEffect(function () {
|
66
|
+
getActionsState === null || getActionsState === void 0 || getActionsState(actionState);
|
67
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
68
|
+
}, [actionState]);
|
69
69
|
var onStartConditionBuilder = function onStartConditionBuilder() {
|
70
70
|
//when add condition button is clicked.
|
71
71
|
setIsConditionBuilderActive(true);
|
@@ -91,8 +91,6 @@ var ConditionBuilderContent = function ConditionBuilderContent(_ref) {
|
|
91
91
|
};
|
92
92
|
var addConditionGroupHandler = function addConditionGroupHandler() {
|
93
93
|
var newGroup = {
|
94
|
-
groupSeparateOperator: 'and',
|
95
|
-
// 'or'|'and'|'null',
|
96
94
|
groupOperator: 'and',
|
97
95
|
//'and|or',
|
98
96
|
statement: 'if',
|
@@ -111,7 +109,7 @@ var ConditionBuilderContent = function ConditionBuilderContent(_ref) {
|
|
111
109
|
}));
|
112
110
|
};
|
113
111
|
return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, !isConditionBuilderActive && /*#__PURE__*/React__default["default"].createElement(react.Button, {
|
114
|
-
className: "".concat(DataConfigs.blockClass, "
|
112
|
+
className: "".concat(DataConfigs.blockClass, "__add_condition-button"),
|
115
113
|
renderIcon: function renderIcon(props) {
|
116
114
|
return /*#__PURE__*/React__default["default"].createElement(icons.Add, _rollupPluginBabelHelpers["extends"]({
|
117
115
|
size: 16
|
@@ -121,10 +119,7 @@ var ConditionBuilderContent = function ConditionBuilderContent(_ref) {
|
|
121
119
|
kind: "ghost",
|
122
120
|
size: "sm",
|
123
121
|
onClick: onStartConditionBuilder
|
124
|
-
}, startConditionLabel), isConditionBuilderActive &&
|
125
|
-
/*#__PURE__*/
|
126
|
-
// <h5 >Condition</h5>
|
127
|
-
React__default["default"].createElement(react.Section, {
|
122
|
+
}, startConditionLabel), isConditionBuilderActive && /*#__PURE__*/React__default["default"].createElement(react.Section, {
|
128
123
|
className: "".concat(DataConfigs.blockClass, "__heading"),
|
129
124
|
level: 4
|
130
125
|
}, _Heading || (_Heading = /*#__PURE__*/React__default["default"].createElement(react.Heading, null, "Condition"))), /*#__PURE__*/React__default["default"].createElement("div", {
|
@@ -164,16 +159,19 @@ var ConditionBuilderContent = function ConditionBuilderContent(_ref) {
|
|
164
159
|
onMouseLeave: function onMouseLeave() {
|
165
160
|
setShowConditionGroupPreview(false);
|
166
161
|
},
|
167
|
-
className: "".concat(DataConfigs.blockClass, "
|
162
|
+
className: "".concat(DataConfigs.blockClass, "__add_condition_group "),
|
168
163
|
hideLabel: true,
|
169
|
-
label: DataConfigs.translateWithId('
|
164
|
+
label: DataConfigs.translateWithId('add_condition_group'),
|
170
165
|
wrapperProps: {
|
171
166
|
role: 'gridcell',
|
172
|
-
'aria-label': DataConfigs.translateWithId('
|
167
|
+
'aria-label': DataConfigs.translateWithId('add_condition_group')
|
173
168
|
}
|
174
169
|
})), showConditionGroupPreview && (_ConditionPreview || (_ConditionPreview = /*#__PURE__*/React__default["default"].createElement(ConditionPreview["default"], {
|
175
170
|
previewType: "newGroup"
|
176
|
-
})))))
|
171
|
+
}))))), isConditionBuilderActive && actions && /*#__PURE__*/React__default["default"].createElement(ConditionBuilderActions["default"], {
|
172
|
+
actions: actions,
|
173
|
+
className: "".concat(DataConfigs.blockClass, "__actions-container")
|
174
|
+
}));
|
177
175
|
};
|
178
176
|
var ConditionBuilderContent$1 = ConditionBuilderContent;
|
179
177
|
ConditionBuilderContent.propTypes = {
|
@@ -181,8 +179,8 @@ ConditionBuilderContent.propTypes = {
|
|
181
179
|
* optional array of object that give the list of actions.
|
182
180
|
*/
|
183
181
|
actions: index["default"].arrayOf(index["default"].shape({
|
184
|
-
id: index["default"].number,
|
185
|
-
label: index["default"].string
|
182
|
+
id: index["default"].oneOfType([index["default"].string, index["default"].number]).isRequired,
|
183
|
+
label: index["default"].string.isRequired
|
186
184
|
})),
|
187
185
|
/**
|
188
186
|
* ref of condition builder
|
@@ -201,15 +199,21 @@ ConditionBuilderContent.propTypes = {
|
|
201
199
|
*/
|
202
200
|
initialState: index["default"].shape({
|
203
201
|
groups: index["default"].arrayOf(index["default"].shape({
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
202
|
+
groupOperator: index["default"].string.isRequired,
|
203
|
+
statement: index["default"].string.isRequired,
|
204
|
+
conditions: index["default"].arrayOf(index["default"].oneOfType([index["default"].shape({
|
205
|
+
property: index["default"].string.isRequired,
|
206
|
+
operator: index["default"].string.isRequired,
|
207
|
+
value: index["default"].oneOfType([index["default"].string, index["default"].arrayOf(index["default"].shape({
|
208
|
+
id: index["default"].string,
|
209
|
+
label: index["default"].string
|
210
|
+
})), index["default"].shape({
|
211
|
+
id: index["default"].string,
|
212
|
+
label: index["default"].string
|
213
|
+
})])
|
214
|
+
}), index["default"].object]))
|
215
|
+
})),
|
216
|
+
operator: index["default"].string
|
213
217
|
}),
|
214
218
|
/* Provide a label to the button that starts condition builder
|
215
219
|
*/
|