@carbon/ibm-products 2.43.2-canary.54 → 2.43.2-canary.55
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 +8 -2
- 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 +8 -2
- 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 +8 -2
- 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 +21 -11
- package/es/components/ConditionBuilder/ConditionBuilder.js +15 -5
- package/es/components/ConditionBuilder/ConditionBuilderActions/ConditionBuilderActions.d.ts +2 -2
- package/es/components/ConditionBuilder/ConditionBuilderActions/ConditionBuilderActions.js +58 -36
- package/es/components/ConditionBuilder/ConditionBuilderAdd/ConditionBuilderAdd.d.ts +3 -1
- package/es/components/ConditionBuilder/ConditionBuilderAdd/ConditionBuilderAdd.js +21 -9
- package/es/components/ConditionBuilder/ConditionBuilderButton/ConditionBuilderButton.d.ts +4 -1
- package/es/components/ConditionBuilder/ConditionBuilderButton/ConditionBuilderButton.js +14 -4
- package/es/components/ConditionBuilder/ConditionBuilderConnector/ConditionConnector.js +8 -4
- package/es/components/ConditionBuilder/ConditionBuilderConnector/GroupConnector.js +17 -9
- package/es/components/ConditionBuilder/ConditionBuilderContent/ConditionBuilderContent.js +19 -10
- package/es/components/ConditionBuilder/ConditionBuilderContext/ConditionBuilderProvider.d.ts +12 -6
- package/es/components/ConditionBuilder/ConditionBuilderContext/ConditionBuilderProvider.js +20 -7
- package/es/components/ConditionBuilder/ConditionBuilderContext/DataConfigs.d.ts +2 -1
- package/es/components/ConditionBuilder/ConditionBuilderContext/DataConfigs.js +18 -17
- package/es/components/ConditionBuilder/ConditionBuilderContext/translationObject.d.ts +36 -39
- package/es/components/ConditionBuilder/ConditionBuilderContext/translationObject.js +36 -38
- package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItem.js +20 -12
- package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemDate/ConditionBuilderItemDate.js +8 -3
- package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemNumber/ConditionBuilderItemNumber.js +9 -7
- package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemOption/ItemOption.js +9 -4
- package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemOption/ItemOptionForValueField.js +10 -5
- package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemText/ConditionBuilderItemText.d.ts +5 -1
- package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemText/ConditionBuilderItemText.js +19 -7
- package/es/components/ConditionBuilder/ConditionGroupBuilder/ConditionGroupBuilder.js +23 -17
- package/es/components/ConditionBuilder/ConditionPreview/ConditionPreview.d.ts +3 -1
- package/es/components/ConditionBuilder/ConditionPreview/ConditionPreview.js +31 -14
- package/es/components/ConditionBuilder/utils/useTranslations.d.ts +1 -0
- package/es/components/ConditionBuilder/utils/useTranslations.js +26 -0
- package/es/components/ConditionBuilder/utils/util.js +1 -9
- package/lib/components/ConditionBuilder/ConditionBlock/ConditionBlock.js +20 -10
- package/lib/components/ConditionBuilder/ConditionBuilder.js +15 -5
- package/lib/components/ConditionBuilder/ConditionBuilderActions/ConditionBuilderActions.d.ts +2 -2
- package/lib/components/ConditionBuilder/ConditionBuilderActions/ConditionBuilderActions.js +56 -33
- package/lib/components/ConditionBuilder/ConditionBuilderAdd/ConditionBuilderAdd.d.ts +3 -1
- package/lib/components/ConditionBuilder/ConditionBuilderAdd/ConditionBuilderAdd.js +20 -8
- package/lib/components/ConditionBuilder/ConditionBuilderButton/ConditionBuilderButton.d.ts +4 -1
- package/lib/components/ConditionBuilder/ConditionBuilderButton/ConditionBuilderButton.js +13 -3
- package/lib/components/ConditionBuilder/ConditionBuilderConnector/ConditionConnector.js +6 -2
- package/lib/components/ConditionBuilder/ConditionBuilderConnector/GroupConnector.js +16 -8
- package/lib/components/ConditionBuilder/ConditionBuilderContent/ConditionBuilderContent.js +18 -9
- package/lib/components/ConditionBuilder/ConditionBuilderContext/ConditionBuilderProvider.d.ts +12 -6
- package/lib/components/ConditionBuilder/ConditionBuilderContext/ConditionBuilderProvider.js +20 -7
- package/lib/components/ConditionBuilder/ConditionBuilderContext/DataConfigs.d.ts +2 -1
- package/lib/components/ConditionBuilder/ConditionBuilderContext/DataConfigs.js +17 -17
- package/lib/components/ConditionBuilder/ConditionBuilderContext/translationObject.d.ts +36 -39
- package/lib/components/ConditionBuilder/ConditionBuilderContext/translationObject.js +36 -38
- package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItem.js +19 -11
- package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemDate/ConditionBuilderItemDate.js +8 -3
- package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemNumber/ConditionBuilderItemNumber.js +8 -6
- package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemOption/ItemOption.js +8 -3
- package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemOption/ItemOptionForValueField.js +9 -4
- package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemText/ConditionBuilderItemText.d.ts +5 -1
- package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemText/ConditionBuilderItemText.js +18 -6
- package/lib/components/ConditionBuilder/ConditionGroupBuilder/ConditionGroupBuilder.js +21 -15
- package/lib/components/ConditionBuilder/ConditionPreview/ConditionPreview.d.ts +3 -1
- package/lib/components/ConditionBuilder/ConditionPreview/ConditionPreview.js +30 -13
- package/lib/components/ConditionBuilder/utils/useTranslations.d.ts +1 -0
- package/lib/components/ConditionBuilder/utils/useTranslations.js +30 -0
- package/lib/components/ConditionBuilder/utils/util.js +0 -9
- package/package.json +3 -3
- package/scss/components/ConditionBuilder/styles/_conditionBuilderCondition.scss +5 -1
- package/scss/components/ConditionBuilder/styles/_conditionBuilderItem.scss +3 -1
@@ -12,20 +12,22 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
12
12
|
var _rollupPluginBabelHelpers = require('../../../_virtual/_rollupPluginBabelHelpers.js');
|
13
13
|
var React = require('react');
|
14
14
|
var index = require('../../../node_modules/prop-types/index.js');
|
15
|
+
var cx = require('classnames');
|
15
16
|
var icons = require('@carbon/react/icons');
|
16
17
|
var react = require('@carbon/react');
|
17
18
|
var ConditionBuilderItem = require('../ConditionBuilderItem/ConditionBuilderItem.js');
|
18
19
|
var DataConfigs = require('../ConditionBuilderContext/DataConfigs.js');
|
19
|
-
var ItemOption = require('../ConditionBuilderItem/ConditionBuilderItemOption/ItemOption.js');
|
20
20
|
var ConditionBuilderProvider = require('../ConditionBuilderContext/ConditionBuilderProvider.js');
|
21
21
|
var ConditionBuilderAdd = require('../ConditionBuilderAdd/ConditionBuilderAdd.js');
|
22
22
|
var uuidv4 = require('../../../global/js/utils/uuidv4.js');
|
23
23
|
var ConditionBuilderButton = require('../ConditionBuilderButton/ConditionBuilderButton.js');
|
24
|
-
var
|
24
|
+
var useTranslations = require('../utils/useTranslations.js');
|
25
|
+
var ItemOptionForValueField = require('../ConditionBuilderItem/ConditionBuilderItemOption/ItemOptionForValueField.js');
|
25
26
|
|
26
27
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
27
28
|
|
28
29
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
30
|
+
var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
29
31
|
|
30
32
|
var ConditionBuilderActions = function ConditionBuilderActions(_ref) {
|
31
33
|
var actions = _ref.actions,
|
@@ -33,90 +35,111 @@ var ConditionBuilderActions = function ConditionBuilderActions(_ref) {
|
|
33
35
|
var _useContext = React.useContext(ConditionBuilderProvider.ConditionBuilderContext),
|
34
36
|
actionState = _useContext.actionState,
|
35
37
|
setActionState = _useContext.setActionState;
|
38
|
+
var _useState = React.useState(-1),
|
39
|
+
_useState2 = _rollupPluginBabelHelpers.slicedToArray(_useState, 2),
|
40
|
+
showDeletionPreview = _useState2[0],
|
41
|
+
setShowDeletionPreview = _useState2[1];
|
42
|
+
var _useTranslations = useTranslations.useTranslations(['actionsText', 'then', 'and', 'removeActionText', 'addActionText']),
|
43
|
+
_useTranslations2 = _rollupPluginBabelHelpers.slicedToArray(_useTranslations, 5),
|
44
|
+
actionsText = _useTranslations2[0],
|
45
|
+
thenText = _useTranslations2[1],
|
46
|
+
andText = _useTranslations2[2],
|
47
|
+
removeActionText = _useTranslations2[3],
|
48
|
+
addActionText = _useTranslations2[4];
|
36
49
|
var addActionHandler = function addActionHandler() {
|
37
50
|
var action = {
|
38
51
|
id: uuidv4["default"](),
|
39
52
|
label: undefined,
|
40
|
-
popoverToOpen: '
|
53
|
+
popoverToOpen: 'valueField'
|
41
54
|
};
|
42
55
|
setActionState([].concat(_rollupPluginBabelHelpers.toConsumableArray(actionState), [action]));
|
43
56
|
};
|
44
|
-
var onchangeHandler = function onchangeHandler(
|
57
|
+
var onchangeHandler = function onchangeHandler(selectedId, actionIndex) {
|
45
58
|
var action = actions.find(function (action) {
|
46
59
|
return action.id === selectedId;
|
47
60
|
}); //fetch the selected action from the input action array
|
48
61
|
|
49
|
-
//if the action is duplicate, that action is added with a new id, else the same action is used.
|
50
62
|
// same actions can be added multiple times
|
51
|
-
var newAction =
|
52
|
-
id:
|
53
|
-
})
|
63
|
+
var newAction = _rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, action), {}, {
|
64
|
+
id: actionState[actionIndex].id
|
65
|
+
});
|
54
66
|
setActionState([].concat(_rollupPluginBabelHelpers.toConsumableArray(actionState.slice(0, actionIndex)), [newAction], _rollupPluginBabelHelpers.toConsumableArray(actionState.slice(actionIndex + 1))));
|
55
|
-
util.focusThisField(evt);
|
56
67
|
};
|
57
68
|
var onRemove = function onRemove(selectedId) {
|
58
69
|
setActionState(actionState.filter(function (action) {
|
59
70
|
return action.id !== selectedId;
|
60
71
|
}));
|
61
72
|
};
|
73
|
+
var handleShowDeletionPreview = function handleShowDeletionPreview(index) {
|
74
|
+
setShowDeletionPreview(index);
|
75
|
+
};
|
76
|
+
var handleHideDeletionPreview = function handleHideDeletionPreview() {
|
77
|
+
setShowDeletionPreview(-1);
|
78
|
+
};
|
62
79
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
63
|
-
className:
|
80
|
+
className: className
|
64
81
|
}, /*#__PURE__*/React__default["default"].createElement(react.Section, {
|
65
82
|
className: "".concat(DataConfigs.blockClass, "__heading"),
|
66
83
|
level: 4
|
67
|
-
}, /*#__PURE__*/React__default["default"].createElement(react.Heading, null,
|
68
|
-
className: "".concat(DataConfigs.blockClass, "__condition-wrapper")
|
84
|
+
}, /*#__PURE__*/React__default["default"].createElement(react.Heading, null, actionsText)), /*#__PURE__*/React__default["default"].createElement("div", {
|
85
|
+
className: "".concat(DataConfigs.blockClass, "__condition-wrapper"),
|
86
|
+
role: "grid"
|
69
87
|
}, actionState === null || actionState === void 0 ? void 0 : actionState.map(function (action, index) {
|
70
88
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
71
89
|
key: action.id,
|
72
|
-
"
|
73
|
-
className: "".concat(DataConfigs.blockClass, "__condition-block
|
90
|
+
role: "row",
|
91
|
+
className: cx__default["default"]("".concat(DataConfigs.blockClass, "__condition-block ").concat(DataConfigs.blockClass, "__gap ").concat(DataConfigs.blockClass, "__gap-bottom"), _rollupPluginBabelHelpers.defineProperty({}, "".concat(DataConfigs.blockClass, "__condition__deletion-preview"), showDeletionPreview == index))
|
74
92
|
}, /*#__PURE__*/React__default["default"].createElement(ConditionBuilderItem.ConditionBuilderItem, {
|
75
93
|
className: "".concat(DataConfigs.blockClass, "__statement-button"),
|
94
|
+
tabIndex: 0,
|
76
95
|
popOverClassName: "".concat(DataConfigs.blockClass, "__gap"),
|
77
|
-
label: index === 0 ?
|
96
|
+
label: index === 0 ? thenText : andText
|
78
97
|
}), /*#__PURE__*/React__default["default"].createElement(ConditionBuilderItem.ConditionBuilderItem, {
|
79
98
|
label: action.label,
|
80
|
-
title:
|
81
|
-
popOverClassName: "".concat(DataConfigs.blockClass, "__gap"),
|
99
|
+
title: actionsText,
|
82
100
|
condition: action,
|
83
|
-
"data-name": "
|
84
|
-
|
101
|
+
"data-name": "valueField",
|
102
|
+
type: "option"
|
103
|
+
}, /*#__PURE__*/React__default["default"].createElement(ItemOptionForValueField.ItemOptionForValueField, {
|
85
104
|
conditionState: {
|
86
105
|
value: action.label
|
87
106
|
},
|
88
|
-
onChange: function onChange(
|
89
|
-
return onchangeHandler(
|
107
|
+
onChange: function onChange(selection) {
|
108
|
+
return onchangeHandler(selection.id, index);
|
90
109
|
},
|
91
110
|
config: {
|
92
111
|
options: actions
|
93
112
|
}
|
94
113
|
})), /*#__PURE__*/React__default["default"].createElement("span", {
|
95
114
|
role: "gridcell",
|
96
|
-
"aria-label":
|
115
|
+
"aria-label": removeActionText
|
97
116
|
}, /*#__PURE__*/React__default["default"].createElement(ConditionBuilderButton.ConditionBuilderButton, {
|
98
117
|
hideLabel: true,
|
99
|
-
label:
|
118
|
+
label: removeActionText,
|
100
119
|
onClick: function onClick() {
|
101
120
|
return onRemove(action.id);
|
102
|
-
}
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
121
|
+
},
|
122
|
+
onMouseEnter: function onMouseEnter() {
|
123
|
+
return handleShowDeletionPreview(index);
|
124
|
+
},
|
125
|
+
onMouseLeave: handleHideDeletionPreview,
|
126
|
+
onFocus: function onFocus() {
|
127
|
+
return handleShowDeletionPreview(index);
|
128
|
+
},
|
129
|
+
onBlur: handleHideDeletionPreview,
|
108
130
|
renderIcon: icons.Close,
|
109
131
|
className: "".concat(DataConfigs.blockClass, "__close-condition"),
|
110
132
|
"data-name": "closeCondition"
|
111
133
|
})), actionState.length === index + 1 && /*#__PURE__*/React__default["default"].createElement(ConditionBuilderAdd["default"], {
|
112
134
|
onClick: addActionHandler,
|
113
135
|
className: "".concat(DataConfigs.blockClass, "__gap ").concat(DataConfigs.blockClass, "__gap-left"),
|
114
|
-
buttonLabel:
|
136
|
+
buttonLabel: addActionText
|
115
137
|
}));
|
116
138
|
}), actionState.length === 0 && /*#__PURE__*/React__default["default"].createElement(ConditionBuilderAdd["default"], {
|
117
139
|
onClick: addActionHandler,
|
118
140
|
className: "".concat(DataConfigs.blockClass, "__gap ").concat(DataConfigs.blockClass, "__gap-left"),
|
119
|
-
buttonLabel:
|
141
|
+
buttonLabel: addActionText,
|
142
|
+
tabIndex: 0
|
120
143
|
})));
|
121
144
|
};
|
122
145
|
var ConditionBuilderActions$1 = ConditionBuilderActions;
|
@@ -125,8 +148,8 @@ ConditionBuilderActions.propTypes = {
|
|
125
148
|
* optional array of object that give the list of actions.
|
126
149
|
*/
|
127
150
|
actions: index["default"].arrayOf(index["default"].shape({
|
128
|
-
id: index["default"].number,
|
129
|
-
label: index["default"].string
|
151
|
+
id: index["default"].oneOfType([index["default"].string, index["default"].number]).isRequired,
|
152
|
+
label: index["default"].string.isRequired
|
130
153
|
})),
|
131
154
|
/**
|
132
155
|
* Provide an optional class to be applied to the containing node.
|
@@ -1,5 +1,5 @@
|
|
1
1
|
export default ConditionBuilderAdd;
|
2
|
-
declare function ConditionBuilderAdd({ className, onClick, addConditionSubGroupHandler, showConditionSubGroupPreviewHandler, hideConditionSubGroupPreviewHandler, showConditionPreviewHandler, hideConditionPreviewHandler, enableSubGroup, buttonLabel, }: {
|
2
|
+
declare function ConditionBuilderAdd({ className, onClick, addConditionSubGroupHandler, showConditionSubGroupPreviewHandler, hideConditionSubGroupPreviewHandler, showConditionPreviewHandler, hideConditionPreviewHandler, enableSubGroup, buttonLabel, tabIndex, }: {
|
3
3
|
className: any;
|
4
4
|
onClick: any;
|
5
5
|
addConditionSubGroupHandler: any;
|
@@ -9,6 +9,7 @@ declare function ConditionBuilderAdd({ className, onClick, addConditionSubGroupH
|
|
9
9
|
hideConditionPreviewHandler: any;
|
10
10
|
enableSubGroup: any;
|
11
11
|
buttonLabel: any;
|
12
|
+
tabIndex: any;
|
12
13
|
}): import("react/jsx-runtime").JSX.Element;
|
13
14
|
declare namespace ConditionBuilderAdd {
|
14
15
|
namespace propTypes {
|
@@ -21,6 +22,7 @@ declare namespace ConditionBuilderAdd {
|
|
21
22
|
let onClick: PropTypes.Requireable<(...args: any[]) => any>;
|
22
23
|
let showConditionPreviewHandler: PropTypes.Requireable<(...args: any[]) => any>;
|
23
24
|
let showConditionSubGroupPreviewHandler: PropTypes.Requireable<(...args: any[]) => any>;
|
25
|
+
let tabIndex: PropTypes.Requireable<number>;
|
24
26
|
}
|
25
27
|
}
|
26
28
|
import PropTypes from 'prop-types';
|
@@ -16,6 +16,7 @@ var icons = require('@carbon/react/icons');
|
|
16
16
|
var ConditionBuilderButton = require('../ConditionBuilderButton/ConditionBuilderButton.js');
|
17
17
|
var index = require('../../../node_modules/prop-types/index.js');
|
18
18
|
var DataConfigs = require('../ConditionBuilderContext/DataConfigs.js');
|
19
|
+
var useTranslations = require('../utils/useTranslations.js');
|
19
20
|
|
20
21
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
21
22
|
|
@@ -31,11 +32,17 @@ var ConditionBuilderAdd = function ConditionBuilderAdd(_ref) {
|
|
31
32
|
showConditionPreviewHandler = _ref.showConditionPreviewHandler,
|
32
33
|
hideConditionPreviewHandler = _ref.hideConditionPreviewHandler,
|
33
34
|
enableSubGroup = _ref.enableSubGroup,
|
34
|
-
buttonLabel = _ref.buttonLabel
|
35
|
+
buttonLabel = _ref.buttonLabel,
|
36
|
+
tabIndex = _ref.tabIndex;
|
35
37
|
var _useState = React.useState(false),
|
36
38
|
_useState2 = _rollupPluginBabelHelpers.slicedToArray(_useState, 2),
|
37
39
|
isAddSubgroup = _useState2[0],
|
38
40
|
setIsAddSubgroup = _useState2[1];
|
41
|
+
var _useTranslations = useTranslations.useTranslations(['addConditionText', 'addConditionRowText', 'addSubgroupText']),
|
42
|
+
_useTranslations2 = _rollupPluginBabelHelpers.slicedToArray(_useTranslations, 3),
|
43
|
+
addConditionText = _useTranslations2[0],
|
44
|
+
addConditionRowText = _useTranslations2[1],
|
45
|
+
addSubgroupText = _useTranslations2[2];
|
39
46
|
var showAddSubGroup = function showAddSubGroup() {
|
40
47
|
setIsAddSubgroup(true);
|
41
48
|
};
|
@@ -63,13 +70,13 @@ var ConditionBuilderAdd = function ConditionBuilderAdd(_ref) {
|
|
63
70
|
};
|
64
71
|
};
|
65
72
|
var wrapperProps = enableSubGroup ? {
|
66
|
-
role: 'gridcell'
|
67
|
-
'aria-label':
|
73
|
+
role: 'gridcell'
|
74
|
+
// 'aria-label': addSubgroupText,
|
68
75
|
} : {};
|
69
76
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
70
77
|
className: "".concat(className, " ").concat(DataConfigs.blockClass, "__add-button-wrapper"),
|
71
78
|
role: !enableSubGroup ? 'gridcell' : 'none',
|
72
|
-
"aria-label": !enableSubGroup ?
|
79
|
+
"aria-label": !enableSubGroup ? addConditionRowText : undefined,
|
73
80
|
onMouseEnter: showAddSubGroup,
|
74
81
|
onMouseLeave: hideAddSubGroup,
|
75
82
|
onFocus: showAddSubGroup,
|
@@ -78,17 +85,18 @@ var ConditionBuilderAdd = function ConditionBuilderAdd(_ref) {
|
|
78
85
|
renderIcon: icons.AddAlt,
|
79
86
|
onClick: onClickHandler
|
80
87
|
}, previewHandlers(), {
|
88
|
+
wrapperProps: wrapperProps,
|
81
89
|
className: "".concat(DataConfigs.blockClass, "__add-button"),
|
82
90
|
hideLabel: true,
|
83
91
|
"data-name": "addButton",
|
84
|
-
label: buttonLabel !== null && buttonLabel !== void 0 ? buttonLabel :
|
85
|
-
|
92
|
+
label: buttonLabel !== null && buttonLabel !== void 0 ? buttonLabel : addConditionText,
|
93
|
+
tabIndex: tabIndex
|
86
94
|
})), enableSubGroup && /*#__PURE__*/React__default["default"].createElement(ConditionBuilderButton.ConditionBuilderButton, _rollupPluginBabelHelpers["extends"]({
|
87
95
|
renderIcon: icons.TextNewLine,
|
88
96
|
onClick: addConditionSubGroupHandler,
|
89
97
|
className: cx__default["default"]("".concat(DataConfigs.blockClass, "__add_condition_group ").concat(DataConfigs.blockClass, "__gap-left")),
|
90
98
|
hideLabel: true,
|
91
|
-
label:
|
99
|
+
label: addSubgroupText,
|
92
100
|
wrapperProps: wrapperProps,
|
93
101
|
wrapperClassName: cx__default["default"]("".concat(DataConfigs.blockClass, "__add_condition_group-wrapper"), _rollupPluginBabelHelpers.defineProperty({}, "".concat(DataConfigs.blockClass, "__add_condition_group-wrapper--show"), isAddSubgroup))
|
94
102
|
}, previewHandlersForSubgroup())));
|
@@ -125,10 +133,14 @@ ConditionBuilderAdd.propTypes = {
|
|
125
133
|
*/
|
126
134
|
onClick: index["default"].func,
|
127
135
|
showConditionPreviewHandler: index["default"].func,
|
128
|
-
showConditionSubGroupPreviewHandler: index["default"].func
|
136
|
+
showConditionSubGroupPreviewHandler: index["default"].func,
|
129
137
|
/**
|
130
138
|
* handler for hiding sub group preview
|
131
139
|
*/
|
140
|
+
/**
|
141
|
+
* Tab index
|
142
|
+
*/
|
143
|
+
tabIndex: index["default"].number
|
132
144
|
};
|
133
145
|
|
134
146
|
exports["default"] = ConditionBuilderAdd$1;
|
@@ -1,4 +1,5 @@
|
|
1
|
-
export function ConditionBuilderButton({ className, label, hideLabel, tooltipAlign, renderIcon: Icon, onClick, showToolTip, wrapperProps, onBlur, onFocus, onMouseEnter, onMouseLeave, isInvalid, wrapperClassName, }: {
|
1
|
+
export function ConditionBuilderButton({ className, label, hideLabel, tooltipAlign, renderIcon: Icon, onClick, showToolTip, wrapperProps, onBlur, onFocus, onMouseEnter, onMouseLeave, isInvalid, wrapperClassName, tabIndex, ...rest }: {
|
2
|
+
[x: string]: any;
|
2
3
|
className: any;
|
3
4
|
label: any;
|
4
5
|
hideLabel: any;
|
@@ -13,6 +14,7 @@ export function ConditionBuilderButton({ className, label, hideLabel, tooltipAli
|
|
13
14
|
onMouseLeave: any;
|
14
15
|
isInvalid: any;
|
15
16
|
wrapperClassName: any;
|
17
|
+
tabIndex: any;
|
16
18
|
}): import("react/jsx-runtime").JSX.Element;
|
17
19
|
export namespace ConditionBuilderButton {
|
18
20
|
namespace propTypes {
|
@@ -27,6 +29,7 @@ export namespace ConditionBuilderButton {
|
|
27
29
|
let onMouseLeave: PropTypes.Requireable<(...args: any[]) => any>;
|
28
30
|
let renderIcon: PropTypes.Requireable<object>;
|
29
31
|
let showToolTip: PropTypes.Requireable<boolean>;
|
32
|
+
let tabIndex: PropTypes.Requireable<number>;
|
30
33
|
let tooltipAlign: PropTypes.Requireable<string>;
|
31
34
|
let wrapperClassName: PropTypes.Requireable<string>;
|
32
35
|
let wrapperProps: PropTypes.Requireable<object>;
|
@@ -23,6 +23,7 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
23
23
|
var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
24
24
|
|
25
25
|
var _WarningAltFilled;
|
26
|
+
var _excluded = ["className", "label", "hideLabel", "tooltipAlign", "renderIcon", "onClick", "showToolTip", "wrapperProps", "onBlur", "onFocus", "onMouseEnter", "onMouseLeave", "isInvalid", "wrapperClassName", "tabIndex"];
|
26
27
|
var ConditionBuilderButton = function ConditionBuilderButton(_ref) {
|
27
28
|
var _Icon, _span;
|
28
29
|
var className = _ref.className,
|
@@ -38,18 +39,23 @@ var ConditionBuilderButton = function ConditionBuilderButton(_ref) {
|
|
38
39
|
onMouseEnter = _ref.onMouseEnter,
|
39
40
|
onMouseLeave = _ref.onMouseLeave,
|
40
41
|
isInvalid = _ref.isInvalid,
|
41
|
-
wrapperClassName = _ref.wrapperClassName
|
42
|
+
wrapperClassName = _ref.wrapperClassName,
|
43
|
+
tabIndex = _ref.tabIndex,
|
44
|
+
rest = _rollupPluginBabelHelpers.objectWithoutProperties(_ref, _excluded);
|
42
45
|
var Button = function Button() {
|
46
|
+
var _rest$dataName;
|
47
|
+
var dataName = (_rest$dataName = rest['data-name']) !== null && _rest$dataName !== void 0 ? _rest$dataName : '';
|
43
48
|
return /*#__PURE__*/React__default["default"].createElement("button", {
|
44
49
|
// role={'gridcell'}
|
45
|
-
tabIndex: -1,
|
50
|
+
tabIndex: tabIndex != undefined ? tabIndex : -1,
|
46
51
|
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)]),
|
47
52
|
type: "button",
|
48
53
|
onClick: onClick,
|
49
54
|
onBlur: onBlur,
|
50
55
|
onFocus: onFocus,
|
51
56
|
onMouseEnter: onMouseEnter,
|
52
|
-
onMouseLeave: onMouseLeave
|
57
|
+
onMouseLeave: onMouseLeave,
|
58
|
+
"data-name": dataName
|
53
59
|
}, 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))));
|
54
60
|
};
|
55
61
|
return hideLabel || showToolTip ? /*#__PURE__*/React__default["default"].createElement(react.Tooltip, _rollupPluginBabelHelpers["extends"]({
|
@@ -96,6 +102,10 @@ ConditionBuilderButton.propTypes = {
|
|
96
102
|
*decides if tooltip to be shown
|
97
103
|
*/
|
98
104
|
showToolTip: index["default"].bool,
|
105
|
+
/**
|
106
|
+
* Tab index
|
107
|
+
*/
|
108
|
+
tabIndex: index["default"].number,
|
99
109
|
/**
|
100
110
|
* tooltip position
|
101
111
|
*/
|
@@ -17,6 +17,7 @@ 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');
|
19
19
|
var ConditionBuilderProvider = require('../ConditionBuilderContext/ConditionBuilderProvider.js');
|
20
|
+
var useTranslations = require('../utils/useTranslations.js');
|
20
21
|
|
21
22
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
22
23
|
|
@@ -30,6 +31,9 @@ var ConditionConnector = function ConditionConnector(_ref) {
|
|
30
31
|
rest = _rollupPluginBabelHelpers.objectWithoutProperties(_ref, _excluded);
|
31
32
|
var _useContext = React.useContext(ConditionBuilderProvider.ConditionBuilderContext),
|
32
33
|
variant = _useContext.variant;
|
34
|
+
var _useTranslations = useTranslations.useTranslations(['connectorText']),
|
35
|
+
_useTranslations2 = _rollupPluginBabelHelpers.slicedToArray(_useTranslations, 1),
|
36
|
+
connectorText = _useTranslations2[0];
|
33
37
|
var handleConnectorHover = React.useCallback(function (parentGroup, isHover) {
|
34
38
|
if (isHover) {
|
35
39
|
parentGroup.classList.add('hoveredConnector');
|
@@ -56,7 +60,7 @@ var ConditionConnector = function ConditionConnector(_ref) {
|
|
56
60
|
// <div className={className} {...rest}>
|
57
61
|
React__default["default"].createElement(ConditionBuilderItem.ConditionBuilderItem, _rollupPluginBabelHelpers["extends"]({
|
58
62
|
label: operator,
|
59
|
-
title:
|
63
|
+
title: connectorText,
|
60
64
|
"data-name": "connectorField",
|
61
65
|
onMouseEnter: activeConnectorHandler,
|
62
66
|
onMouseLeave: inActiveConnectorHandler,
|
@@ -71,7 +75,7 @@ var ConditionConnector = function ConditionConnector(_ref) {
|
|
71
75
|
},
|
72
76
|
conditionState: {
|
73
77
|
value: operator,
|
74
|
-
label:
|
78
|
+
label: connectorText
|
75
79
|
},
|
76
80
|
onChange: onChangeHandler
|
77
81
|
}))
|
@@ -9,12 +9,13 @@
|
|
9
9
|
|
10
10
|
Object.defineProperty(exports, '__esModule', { value: true });
|
11
11
|
|
12
|
+
var _rollupPluginBabelHelpers = require('../../../_virtual/_rollupPluginBabelHelpers.js');
|
12
13
|
var React = require('react');
|
13
14
|
var ConditionBuilderItem = require('../ConditionBuilderItem/ConditionBuilderItem.js');
|
14
15
|
var DataConfigs = require('../ConditionBuilderContext/DataConfigs.js');
|
15
16
|
var ItemOption = require('../ConditionBuilderItem/ConditionBuilderItemOption/ItemOption.js');
|
16
|
-
var util = require('../utils/util.js');
|
17
17
|
var ConditionBuilderProvider = require('../ConditionBuilderContext/ConditionBuilderProvider.js');
|
18
|
+
var useTranslations = require('../utils/useTranslations.js');
|
18
19
|
|
19
20
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
20
21
|
|
@@ -22,26 +23,33 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
22
23
|
|
23
24
|
var GroupConnector = function GroupConnector() {
|
24
25
|
var _useContext = React.useContext(ConditionBuilderProvider.ConditionBuilderContext),
|
25
|
-
rootState = _useContext.rootState
|
26
|
+
rootState = _useContext.rootState,
|
27
|
+
setRootState = _useContext.setRootState;
|
28
|
+
var _useTranslations = useTranslations.useTranslations(['conditionText']),
|
29
|
+
_useTranslations2 = _rollupPluginBabelHelpers.slicedToArray(_useTranslations, 1),
|
30
|
+
conditionText = _useTranslations2[0];
|
31
|
+
var onStatementChangeHandler = function onStatementChangeHandler(updatedStatement) {
|
32
|
+
setRootState(_rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, rootState), {}, {
|
33
|
+
operator: updatedStatement
|
34
|
+
}));
|
35
|
+
};
|
26
36
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
27
|
-
className: "".concat(DataConfigs.blockClass, "__group-separator"),
|
37
|
+
className: "".concat(DataConfigs.blockClass, "__group-separator ").concat(DataConfigs.blockClass, "__group-separator-row"),
|
28
38
|
role: "row",
|
29
39
|
tabIndex: -1,
|
30
40
|
"aria-level": 1
|
31
41
|
}, /*#__PURE__*/React__default["default"].createElement(ConditionBuilderItem.ConditionBuilderItem, {
|
32
42
|
label: rootState.operator,
|
33
|
-
title:
|
43
|
+
title: conditionText,
|
34
44
|
"data-name": "connectorField",
|
35
45
|
popOverClassName: "".concat(DataConfigs.blockClass, "__gap"),
|
36
46
|
className: "".concat(DataConfigs.blockClass, "__statement-button")
|
37
47
|
}, /*#__PURE__*/React__default["default"].createElement(ItemOption.ItemOption, {
|
38
48
|
conditionState: {
|
39
49
|
value: rootState.operator,
|
40
|
-
label:
|
41
|
-
},
|
42
|
-
onChange: function onChange(v, e) {
|
43
|
-
util.focusThisField(e);
|
50
|
+
label: conditionText
|
44
51
|
},
|
52
|
+
onChange: onStatementChangeHandler,
|
45
53
|
config: {
|
46
54
|
options: DataConfigs.connectorConfig
|
47
55
|
}
|
@@ -22,12 +22,13 @@ 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
24
|
var ConditionBuilderActions = require('../ConditionBuilderActions/ConditionBuilderActions.js');
|
25
|
+
var useTranslations = require('../utils/useTranslations.js');
|
25
26
|
|
26
27
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
27
28
|
|
28
29
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
29
30
|
|
30
|
-
var _Heading, _GroupConnector
|
31
|
+
var _Heading, _GroupConnector;
|
31
32
|
var ConditionBuilderContent = function ConditionBuilderContent(_ref) {
|
32
33
|
var _rootState$groups2;
|
33
34
|
var startConditionLabel = _ref.startConditionLabel,
|
@@ -49,6 +50,9 @@ var ConditionBuilderContent = function ConditionBuilderContent(_ref) {
|
|
49
50
|
_useState4 = _rollupPluginBabelHelpers.slicedToArray(_useState3, 2),
|
50
51
|
showConditionGroupPreview = _useState4[0],
|
51
52
|
setShowConditionGroupPreview = _useState4[1];
|
53
|
+
var _useTranslations = useTranslations.useTranslations(['addConditionGroupText']),
|
54
|
+
_useTranslations2 = _rollupPluginBabelHelpers.slicedToArray(_useTranslations, 1),
|
55
|
+
addConditionGroupText = _useTranslations2[0];
|
52
56
|
React.useEffect(function () {
|
53
57
|
var _rootState$groups;
|
54
58
|
if (rootState !== null && rootState !== void 0 && (_rootState$groups = rootState.groups) !== null && _rootState$groups !== void 0 && _rootState$groups.length) {
|
@@ -109,7 +113,7 @@ var ConditionBuilderContent = function ConditionBuilderContent(_ref) {
|
|
109
113
|
}));
|
110
114
|
};
|
111
115
|
return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, !isConditionBuilderActive && /*#__PURE__*/React__default["default"].createElement(react.Button, {
|
112
|
-
className: "".concat(DataConfigs.blockClass, "
|
116
|
+
className: "".concat(DataConfigs.blockClass, "__addConditionText-button"),
|
113
117
|
renderIcon: function renderIcon(props) {
|
114
118
|
return /*#__PURE__*/React__default["default"].createElement(icons.Add, _rollupPluginBabelHelpers["extends"]({
|
115
119
|
size: 16
|
@@ -159,18 +163,23 @@ var ConditionBuilderContent = function ConditionBuilderContent(_ref) {
|
|
159
163
|
onMouseLeave: function onMouseLeave() {
|
160
164
|
setShowConditionGroupPreview(false);
|
161
165
|
},
|
162
|
-
className: "".concat(DataConfigs.blockClass, "
|
166
|
+
className: "".concat(DataConfigs.blockClass, "__addConditionGroupText "),
|
163
167
|
hideLabel: true,
|
164
|
-
label:
|
168
|
+
label: addConditionGroupText,
|
165
169
|
wrapperProps: {
|
166
170
|
role: 'gridcell',
|
167
|
-
'aria-label':
|
171
|
+
'aria-label': addConditionGroupText
|
168
172
|
}
|
169
|
-
})), showConditionGroupPreview &&
|
170
|
-
previewType: "newGroup"
|
171
|
-
|
173
|
+
})), showConditionGroupPreview && /*#__PURE__*/React__default["default"].createElement(ConditionPreview["default"], {
|
174
|
+
previewType: "newGroup",
|
175
|
+
group: {
|
176
|
+
groupOperator: rootState.operator
|
177
|
+
}
|
178
|
+
}))), isConditionBuilderActive && actions && /*#__PURE__*/React__default["default"].createElement(ConditionBuilderActions["default"], {
|
172
179
|
actions: actions,
|
173
|
-
className: "".concat(DataConfigs.blockClass, "__actions-container")
|
180
|
+
className: "".concat(DataConfigs.blockClass, "__actions-container"),
|
181
|
+
variant: variant,
|
182
|
+
conditionBuilderRef: conditionBuilderRef
|
174
183
|
}));
|
175
184
|
};
|
176
185
|
var ConditionBuilderContent$1 = ConditionBuilderContent;
|
package/lib/components/ConditionBuilder/ConditionBuilderContext/ConditionBuilderProvider.d.ts
CHANGED
@@ -21,21 +21,27 @@ export namespace ConditionBuilderProvider {
|
|
21
21
|
let getOptions: PropTypes.Requireable<(...args: any[]) => any>;
|
22
22
|
let inputConfig: PropTypes.Validator<NonNullable<PropTypes.InferProps<{
|
23
23
|
properties: PropTypes.Requireable<(PropTypes.InferProps<{
|
24
|
-
id: PropTypes.
|
25
|
-
label: PropTypes.
|
24
|
+
id: PropTypes.Validator<string>;
|
25
|
+
label: PropTypes.Validator<string>;
|
26
26
|
icon: PropTypes.Requireable<object>;
|
27
|
-
type: PropTypes.
|
27
|
+
type: PropTypes.Validator<string>;
|
28
28
|
config: PropTypes.Requireable<PropTypes.InferProps<{
|
29
29
|
options: PropTypes.Requireable<(PropTypes.InferProps<{
|
30
|
-
id: PropTypes.
|
31
|
-
label: PropTypes.
|
30
|
+
id: PropTypes.Validator<string>;
|
31
|
+
label: PropTypes.Validator<string>;
|
32
32
|
icon: PropTypes.Requireable<object>;
|
33
33
|
}> | null | undefined)[]>;
|
34
|
-
|
34
|
+
component: PropTypes.Requireable<(...args: any[]) => any>;
|
35
|
+
operators: PropTypes.Requireable<(PropTypes.InferProps<{
|
36
|
+
id: PropTypes.Validator<string>;
|
37
|
+
label: PropTypes.Validator<string>;
|
38
|
+
}> | null | undefined)[]>;
|
39
|
+
long: PropTypes.Requireable<boolean>;
|
35
40
|
}>>;
|
36
41
|
}> | null | undefined)[]>;
|
37
42
|
}>>>;
|
38
43
|
let popOverSearchThreshold: PropTypes.Validator<number>;
|
44
|
+
let translateWithId: PropTypes.Requireable<(...args: any[]) => any>;
|
39
45
|
let variant: PropTypes.Validator<string>;
|
40
46
|
}
|
41
47
|
}
|
@@ -70,7 +70,8 @@ var ConditionBuilderProvider = function ConditionBuilderProvider(props) {
|
|
70
70
|
inputConfig: props.inputConfig,
|
71
71
|
popOverSearchThreshold: props.popOverSearchThreshold,
|
72
72
|
getOptions: props.getOptions,
|
73
|
-
variant: props.variant
|
73
|
+
variant: props.variant,
|
74
|
+
translateWithId: props.translateWithId
|
74
75
|
}
|
75
76
|
},
|
76
77
|
// eslint-disable-next-line react/prop-types
|
@@ -97,17 +98,22 @@ ConditionBuilderProvider.propTypes = {
|
|
97
98
|
*/
|
98
99
|
inputConfig: index["default"].shape({
|
99
100
|
properties: index["default"].arrayOf(index["default"].shape({
|
100
|
-
id: index["default"].string,
|
101
|
-
label: index["default"].string,
|
101
|
+
id: index["default"].string.isRequired,
|
102
|
+
label: index["default"].string.isRequired,
|
102
103
|
icon: index["default"].oneOfType([index["default"].func, index["default"].object]),
|
103
|
-
type: index["default"].oneOf(['text', 'number', 'date', 'option', 'time', 'custom']),
|
104
|
+
type: index["default"].oneOf(['text', 'textarea', 'number', 'date', 'option', 'time', 'custom']).isRequired,
|
104
105
|
config: index["default"].shape({
|
105
106
|
options: index["default"].arrayOf(index["default"].shape({
|
106
|
-
id: index["default"].string,
|
107
|
-
label: index["default"].string,
|
107
|
+
id: index["default"].string.isRequired,
|
108
|
+
label: index["default"].string.isRequired,
|
108
109
|
icon: index["default"].oneOfType([index["default"].func, index["default"].object])
|
109
110
|
})),
|
110
|
-
|
111
|
+
component: index["default"].func,
|
112
|
+
operators: index["default"].arrayOf(index["default"].shape({
|
113
|
+
id: index["default"].string.isRequired,
|
114
|
+
label: index["default"].string.isRequired
|
115
|
+
})),
|
116
|
+
long: index["default"].bool
|
111
117
|
})
|
112
118
|
}))
|
113
119
|
}).isRequired,
|
@@ -115,6 +121,13 @@ ConditionBuilderProvider.propTypes = {
|
|
115
121
|
* Provide an mandatory numeric value that will be used to enable search option in the popovers with list.
|
116
122
|
*/
|
117
123
|
popOverSearchThreshold: index["default"].number.isRequired,
|
124
|
+
/**
|
125
|
+
* Optional prop if you want to pass translation to the texts used . Otherwise this will the defined defaults.
|
126
|
+
* This callback function will receive the message id and you need to return the corresponding text for that id.
|
127
|
+
* The message key will be one of [ "ifText", "addConditionText", "addConditionGroupText", "addSubgroupText", "conditionText", "propertyText", "operatorText", "valueText", "connectorText", "conditionRowText", "removeConditionText", "addConditionRowText", "startText", "endText", "clearSearchText", "actionsText", "then", "removeActionText", "addActionText", "invalidText", "invalidNumberWarnText"
|
128
|
+
]
|
129
|
+
*/
|
130
|
+
translateWithId: index["default"].func,
|
118
131
|
/**
|
119
132
|
* Provide the condition builder variant: sentence/ tree
|
120
133
|
*/
|
@@ -1,6 +1,7 @@
|
|
1
1
|
export const statementConfig: {
|
2
2
|
label: string;
|
3
3
|
id: string;
|
4
|
+
connector: string;
|
4
5
|
}[];
|
5
6
|
export const connectorConfig: {
|
6
7
|
label: string;
|
@@ -16,9 +17,9 @@ export const operatorConfig: {
|
|
16
17
|
type: string;
|
17
18
|
}[];
|
18
19
|
export const blockClass: string;
|
19
|
-
export function translateWithId(key: any): any;
|
20
20
|
export namespace valueRenderers {
|
21
21
|
function text(val: any): any;
|
22
|
+
function textarea(val: any): any;
|
22
23
|
function time(val: any): any;
|
23
24
|
function number(val: any): any;
|
24
25
|
function option(value: any): any;
|