@carbon/ibm-products 2.45.0 → 2.46.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 +261 -124
- 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 +3 -0
- 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 +81 -86
- 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 +182 -110
- 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/ActionBar/ActionBarItem.js +1 -1
- package/es/components/Coachmark/Coachmark.d.ts +6 -1
- package/es/components/Coachmark/Coachmark.js +37 -6
- package/es/components/Coachmark/CoachmarkOverlay.js +2 -4
- package/es/components/CoachmarkBeacon/CoachmarkBeacon.js +1 -7
- package/es/components/ConditionBuilder/ConditionBlock/ConditionBlock.js +20 -14
- package/es/components/ConditionBuilder/ConditionBuilder.js +3 -3
- package/es/components/ConditionBuilder/ConditionBuilderActions/ConditionBuilderActions.js +8 -5
- package/es/components/ConditionBuilder/ConditionBuilderAdd/ConditionBuilderAdd.js +4 -2
- package/es/components/ConditionBuilder/ConditionBuilderButton/ConditionBuilderButton.js +2 -2
- package/es/components/ConditionBuilder/ConditionBuilderConnector/ConditionConnector.js +4 -3
- package/es/components/ConditionBuilder/ConditionBuilderContent/ConditionBuilderContent.d.ts +1 -3
- package/es/components/ConditionBuilder/ConditionBuilderContent/ConditionBuilderContent.js +26 -30
- package/es/components/ConditionBuilder/ConditionBuilderContext/ConditionBuilderProvider.d.ts +1 -0
- package/es/components/ConditionBuilder/ConditionBuilderContext/ConditionBuilderProvider.js +6 -1
- package/es/components/ConditionBuilder/ConditionBuilderContext/translationObject.d.ts +4 -1
- package/es/components/ConditionBuilder/ConditionBuilderContext/translationObject.js +5 -2
- package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItem.d.ts +3 -1
- package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItem.js +47 -23
- package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemDate/ConditionBuilderItemDate.js +1 -1
- package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemNumber/ConditionBuilderItemNumber.js +3 -3
- package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemOption/ItemOptionForValueField.js +6 -3
- package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemText/ConditionBuilderItemText.js +3 -2
- package/es/components/ConditionBuilder/ConditionGroupBuilder/ConditionGroupBuilder.d.ts +1 -3
- package/es/components/ConditionBuilder/ConditionGroupBuilder/ConditionGroupBuilder.js +62 -32
- package/es/components/ConditionBuilder/utils/handleKeyboardEvents.d.ts +1 -0
- package/es/components/ConditionBuilder/utils/handleKeyboardEvents.js +52 -46
- package/es/components/ConditionBuilder/utils/util.d.ts +6 -5
- package/es/components/ConditionBuilder/utils/util.js +35 -17
- package/es/components/DataSpreadsheet/DataSpreadsheet.d.ts +6 -0
- package/es/components/DataSpreadsheet/DataSpreadsheet.js +77 -38
- package/es/components/DataSpreadsheet/DataSpreadsheetBody.d.ts +4 -0
- package/es/components/DataSpreadsheet/DataSpreadsheetBody.js +10 -1
- package/es/components/DataSpreadsheet/types/index.d.ts +1 -0
- package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/CustomizeColumnsTearsheet.js +34 -10
- package/es/components/Datagrid/Datagrid/addons/Filtering/hooks/useFilters.js +33 -1
- package/es/components/Datagrid/types/index.d.ts +14 -2
- package/es/components/Datagrid/useDisableSelectRows.d.ts +2 -1
- package/es/components/Datagrid/useDisableSelectRows.js +27 -22
- package/es/components/StringFormatter/StringFormatter.js +14 -3
- package/es/components/StringFormatter/utils/enums.d.ts +20 -1
- package/es/components/StringFormatter/utils/enums.js +22 -2
- package/es/components/Tearsheet/TearsheetShell.d.ts +1 -1
- package/es/components/Tearsheet/TearsheetShell.js +4 -2
- package/es/global/js/hooks/useFocus.d.ts +1 -0
- package/es/global/js/hooks/useFocus.js +5 -2
- package/es/node_modules/@carbon/icon-helpers/es/index.js +49 -62
- package/es/node_modules/@carbon/icons-react/es/generated/bucket-2.js +1020 -1058
- package/es/node_modules/@carbon/icons-react/es/generated/bucket-9.js +881 -758
- package/lib/components/ActionBar/ActionBarItem.js +1 -1
- package/lib/components/Coachmark/Coachmark.d.ts +6 -1
- package/lib/components/Coachmark/Coachmark.js +36 -5
- package/lib/components/Coachmark/CoachmarkOverlay.js +2 -4
- package/lib/components/CoachmarkBeacon/CoachmarkBeacon.js +1 -7
- package/lib/components/ConditionBuilder/ConditionBlock/ConditionBlock.js +19 -13
- package/lib/components/ConditionBuilder/ConditionBuilder.js +3 -3
- package/lib/components/ConditionBuilder/ConditionBuilderActions/ConditionBuilderActions.js +8 -5
- package/lib/components/ConditionBuilder/ConditionBuilderAdd/ConditionBuilderAdd.js +4 -2
- package/lib/components/ConditionBuilder/ConditionBuilderButton/ConditionBuilderButton.js +2 -2
- package/lib/components/ConditionBuilder/ConditionBuilderConnector/ConditionConnector.js +4 -3
- package/lib/components/ConditionBuilder/ConditionBuilderContent/ConditionBuilderContent.d.ts +1 -3
- package/lib/components/ConditionBuilder/ConditionBuilderContent/ConditionBuilderContent.js +25 -29
- package/lib/components/ConditionBuilder/ConditionBuilderContext/ConditionBuilderProvider.d.ts +1 -0
- package/lib/components/ConditionBuilder/ConditionBuilderContext/ConditionBuilderProvider.js +6 -1
- package/lib/components/ConditionBuilder/ConditionBuilderContext/translationObject.d.ts +4 -1
- package/lib/components/ConditionBuilder/ConditionBuilderContext/translationObject.js +5 -2
- package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItem.d.ts +3 -1
- package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItem.js +46 -22
- package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemDate/ConditionBuilderItemDate.js +1 -1
- package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemNumber/ConditionBuilderItemNumber.js +3 -3
- package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemOption/ItemOptionForValueField.js +6 -3
- package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemText/ConditionBuilderItemText.js +3 -2
- package/lib/components/ConditionBuilder/ConditionGroupBuilder/ConditionGroupBuilder.d.ts +1 -3
- package/lib/components/ConditionBuilder/ConditionGroupBuilder/ConditionGroupBuilder.js +61 -31
- package/lib/components/ConditionBuilder/utils/handleKeyboardEvents.d.ts +1 -0
- package/lib/components/ConditionBuilder/utils/handleKeyboardEvents.js +51 -44
- package/lib/components/ConditionBuilder/utils/util.d.ts +6 -5
- package/lib/components/ConditionBuilder/utils/util.js +36 -16
- package/lib/components/DataSpreadsheet/DataSpreadsheet.d.ts +6 -0
- package/lib/components/DataSpreadsheet/DataSpreadsheet.js +77 -38
- package/lib/components/DataSpreadsheet/DataSpreadsheetBody.d.ts +4 -0
- package/lib/components/DataSpreadsheet/DataSpreadsheetBody.js +10 -1
- package/lib/components/DataSpreadsheet/types/index.d.ts +1 -0
- package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/CustomizeColumnsTearsheet.js +34 -10
- package/lib/components/Datagrid/Datagrid/addons/Filtering/hooks/useFilters.js +32 -0
- package/lib/components/Datagrid/types/index.d.ts +14 -2
- package/lib/components/Datagrid/useDisableSelectRows.d.ts +2 -1
- package/lib/components/Datagrid/useDisableSelectRows.js +27 -22
- package/lib/components/StringFormatter/StringFormatter.js +13 -2
- package/lib/components/StringFormatter/utils/enums.d.ts +20 -1
- package/lib/components/StringFormatter/utils/enums.js +23 -1
- package/lib/components/Tearsheet/TearsheetShell.d.ts +1 -1
- package/lib/components/Tearsheet/TearsheetShell.js +3 -1
- package/lib/global/js/hooks/useFocus.d.ts +1 -0
- package/lib/global/js/hooks/useFocus.js +5 -1
- package/lib/node_modules/@carbon/icon-helpers/es/index.js +49 -62
- package/lib/node_modules/@carbon/icons-react/es/generated/bucket-2.js +1036 -1074
- package/lib/node_modules/@carbon/icons-react/es/generated/bucket-9.js +946 -823
- package/package.json +6 -6
- package/scss/components/Coachmark/_coachmark-overlay.scss +6 -70
- package/scss/components/Coachmark/_coachmark.scss +5 -4
- package/scss/components/CoachmarkBeacon/_coachmark-beacon.scss +1 -3
- package/scss/components/ConditionBuilder/_condition-builder.scss +4 -0
- package/scss/components/ConditionBuilder/styles/_conditionBuilderCondition.scss +6 -1
- package/scss/components/ConditionBuilder/styles/_conditionBuilderItem.scss +1 -1
- package/scss/components/Datagrid/styles/addons/_CustomizeColumnsTearsheet.scss +7 -5
- package/scss/components/Datagrid/styles/addons/_FilterFlyout.scss +5 -4
- package/telemetry.yml +5 -14
@@ -1,4 +1,4 @@
|
|
1
|
-
export function ConditionBuilderItem({ children, className, label, renderIcon, title, type, showToolTip, condition, popOverClassName, config, renderChildren, ...rest }: {
|
1
|
+
export function ConditionBuilderItem({ children, className, label, renderIcon, title, type, showToolTip, condition, popOverClassName, config, renderChildren, onChange, ...rest }: {
|
2
2
|
[x: string]: any;
|
3
3
|
children: any;
|
4
4
|
className: any;
|
@@ -11,6 +11,7 @@ export function ConditionBuilderItem({ children, className, label, renderIcon, t
|
|
11
11
|
popOverClassName: any;
|
12
12
|
config: any;
|
13
13
|
renderChildren: any;
|
14
|
+
onChange: any;
|
14
15
|
}): import("react/jsx-runtime").JSX.Element;
|
15
16
|
export namespace ConditionBuilderItem {
|
16
17
|
namespace propTypes {
|
@@ -19,6 +20,7 @@ export namespace ConditionBuilderItem {
|
|
19
20
|
let condition: PropTypes.Requireable<object>;
|
20
21
|
let config: PropTypes.Requireable<object>;
|
21
22
|
let label: PropTypes.Requireable<NonNullable<string | object | null | undefined>>;
|
23
|
+
let onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
22
24
|
let popOverClassName: PropTypes.Requireable<string>;
|
23
25
|
let renderChildren: PropTypes.Requireable<(...args: any[]) => any>;
|
24
26
|
let renderIcon: PropTypes.Requireable<object>;
|
@@ -17,12 +17,14 @@ var icons = require('@carbon/react/icons');
|
|
17
17
|
var DataConfigs = require('../ConditionBuilderContext/DataConfigs.js');
|
18
18
|
var ConditionBuilderButton = require('../ConditionBuilderButton/ConditionBuilderButton.js');
|
19
19
|
var useTranslations = require('../utils/useTranslations.js');
|
20
|
+
var ConditionBuilderProvider = require('../ConditionBuilderContext/ConditionBuilderProvider.js');
|
21
|
+
var handleKeyboardEvents = require('../utils/handleKeyboardEvents.js');
|
20
22
|
|
21
23
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
22
24
|
|
23
25
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
24
26
|
|
25
|
-
var _excluded = ["children", "className", "label", "renderIcon", "title", "type", "showToolTip", "condition", "popOverClassName", "config", "renderChildren"];
|
27
|
+
var _excluded = ["children", "className", "label", "renderIcon", "title", "type", "showToolTip", "condition", "popOverClassName", "config", "renderChildren", "onChange"];
|
26
28
|
var ConditionBuilderItem = function ConditionBuilderItem(_ref) {
|
27
29
|
var children = _ref.children,
|
28
30
|
className = _ref.className,
|
@@ -35,30 +37,29 @@ var ConditionBuilderItem = function ConditionBuilderItem(_ref) {
|
|
35
37
|
popOverClassName = _ref.popOverClassName,
|
36
38
|
config = _ref.config,
|
37
39
|
renderChildren = _ref.renderChildren,
|
40
|
+
onChange = _ref.onChange,
|
38
41
|
rest = _rollupPluginBabelHelpers.objectWithoutProperties(_ref, _excluded);
|
39
|
-
var contentRef = React.useRef(null);
|
40
42
|
var popoverRef = React.useRef(null);
|
41
43
|
var _useState = React.useState(false),
|
42
44
|
_useState2 = _rollupPluginBabelHelpers.slicedToArray(_useState, 2),
|
43
45
|
open = _useState2[0],
|
44
46
|
setOpen = _useState2[1];
|
45
|
-
var _useTranslations = useTranslations.useTranslations(['invalidText', 'addConditionText', label
|
46
|
-
_useTranslations2 = _rollupPluginBabelHelpers.slicedToArray(_useTranslations,
|
47
|
+
var _useTranslations = useTranslations.useTranslations(['invalidText', 'addConditionText', label]),
|
48
|
+
_useTranslations2 = _rollupPluginBabelHelpers.slicedToArray(_useTranslations, 3),
|
47
49
|
invalidText = _useTranslations2[0],
|
48
50
|
addConditionText = _useTranslations2[1],
|
49
|
-
labelText = _useTranslations2[2]
|
50
|
-
|
51
|
+
labelText = _useTranslations2[2];
|
52
|
+
var _useContext = React.useContext(ConditionBuilderProvider.ConditionBuilderContext),
|
53
|
+
conditionBuilderRef = _useContext.conditionBuilderRef;
|
51
54
|
var getPropertyDetails = function getPropertyDetails() {
|
52
|
-
|
55
|
+
var _ref2 = condition || {},
|
56
|
+
property = _ref2.property,
|
57
|
+
operator = _ref2.operator;
|
58
|
+
if (label === 'INVALID' || rest['data-name'] === 'propertyField' && property === 'INVALID' || rest['data-name'] === 'operatorField' && operator === 'INVALID') {
|
53
59
|
return {
|
54
60
|
propertyLabel: invalidText,
|
55
61
|
isInvalid: true
|
56
62
|
};
|
57
|
-
} else if (label === 'INVALID_DATE') {
|
58
|
-
return {
|
59
|
-
propertyLabel: invalidDateText,
|
60
|
-
isInvalid: true
|
61
|
-
};
|
62
63
|
}
|
63
64
|
var propertyId = rest['data-name'] == 'valueField' && type ? DataConfigs.valueRenderers[type](label, config) : labelText;
|
64
65
|
return {
|
@@ -97,27 +98,46 @@ var ConditionBuilderItem = function ConditionBuilderItem(_ref) {
|
|
97
98
|
}, [condition, label]);
|
98
99
|
React.useEffect(function () {
|
99
100
|
//this will focus the first input field in the popover
|
100
|
-
if (open &&
|
101
|
-
var firstFocusableElement =
|
101
|
+
if (open && popoverRef.current) {
|
102
|
+
var firstFocusableElement = popoverRef.current.querySelector('input,textarea');
|
102
103
|
if (firstFocusableElement) {
|
103
|
-
|
104
|
+
setTimeout(function () {
|
105
|
+
return firstFocusableElement.focus();
|
106
|
+
}, 0);
|
104
107
|
}
|
105
108
|
}
|
106
|
-
}, [
|
109
|
+
}, [popoverRef, open]);
|
110
|
+
var manageInvalidSelection = function manageInvalidSelection() {
|
111
|
+
//when the user didn't select any value , we need to show as incomplete
|
112
|
+
if (rest['data-name'] === 'propertyField' && !(condition !== null && condition !== void 0 && condition.property) || rest['data-name'] === 'operatorField' && !(condition !== null && condition !== void 0 && condition.operator) || rest['data-name'] === 'valueField' && !(condition !== null && condition !== void 0 && condition.value)) {
|
113
|
+
onChange === null || onChange === void 0 || onChange('INVALID');
|
114
|
+
}
|
115
|
+
};
|
107
116
|
var closePopover = function closePopover() {
|
108
|
-
|
117
|
+
if (open) {
|
118
|
+
manageInvalidSelection();
|
119
|
+
}
|
120
|
+
setOpen(false);
|
109
121
|
};
|
110
122
|
var openPopOver = function openPopOver() {
|
111
123
|
return setOpen(true);
|
112
124
|
};
|
113
125
|
var togglePopover = function togglePopover() {
|
114
|
-
|
126
|
+
if (children || renderChildren) {
|
127
|
+
setOpen(!open);
|
128
|
+
}
|
129
|
+
};
|
130
|
+
var handleKeyDownHandler = function handleKeyDownHandler(evt) {
|
131
|
+
handleKeyboardEvents.handleKeyDownForPopover(evt, conditionBuilderRef, popoverRef);
|
132
|
+
if (evt.key === 'Escape') {
|
133
|
+
manageInvalidSelection();
|
134
|
+
}
|
115
135
|
};
|
116
136
|
return /*#__PURE__*/React__default["default"].createElement(react.Popover, {
|
117
137
|
open: open,
|
118
138
|
isTabTip: true,
|
119
139
|
role: "gridcell",
|
120
|
-
className: popOverClassName,
|
140
|
+
className: "".concat(popOverClassName, " ").concat(DataConfigs.blockClass, "__popover"),
|
121
141
|
ref: popoverRef,
|
122
142
|
onRequestClose: closePopover
|
123
143
|
}, /*#__PURE__*/React__default["default"].createElement(ConditionBuilderButton.ConditionBuilderButton, _rollupPluginBabelHelpers["extends"]({
|
@@ -132,13 +152,13 @@ var ConditionBuilderItem = function ConditionBuilderItem(_ref) {
|
|
132
152
|
isInvalid: isInvalid,
|
133
153
|
condition: condition
|
134
154
|
}, rest)), open && /*#__PURE__*/React__default["default"].createElement(react.PopoverContent, {
|
135
|
-
className: "".concat(DataConfigs.blockClass, "
|
155
|
+
className: "".concat(DataConfigs.blockClass, "__popover-content-wrapper"),
|
136
156
|
role: "dialog",
|
137
|
-
"aria-label": title
|
157
|
+
"aria-label": title,
|
158
|
+
onKeyDown: handleKeyDownHandler
|
138
159
|
}, /*#__PURE__*/React__default["default"].createElement(react.Layer, null, /*#__PURE__*/React__default["default"].createElement("h1", {
|
139
160
|
className: "".concat(DataConfigs.blockClass, "__item__title")
|
140
161
|
}, title), /*#__PURE__*/React__default["default"].createElement("div", {
|
141
|
-
ref: contentRef,
|
142
162
|
className: "".concat(DataConfigs.blockClass, "__popover-content")
|
143
163
|
}, renderChildren ? renderChildren(popoverRef) : children))));
|
144
164
|
};
|
@@ -164,6 +184,10 @@ ConditionBuilderItem.propTypes = {
|
|
164
184
|
* text to be displayed in the field
|
165
185
|
*/
|
166
186
|
label: index["default"].oneOfType([index["default"].string, index["default"].array, index["default"].object]),
|
187
|
+
/**
|
188
|
+
* callback to update the current condition of the state tree
|
189
|
+
*/
|
190
|
+
onChange: index["default"].func,
|
167
191
|
/**
|
168
192
|
* class name for popover
|
169
193
|
*/
|
@@ -32,7 +32,7 @@ var ConditionBuilderItemDate = function ConditionBuilderItemDate(_ref) {
|
|
32
32
|
endText = _useTranslations2[1];
|
33
33
|
var datePickerType = conditionState.operator == 'between' ? 'range' : 'single';
|
34
34
|
var onCloseHandler = function onCloseHandler(selectedDate) {
|
35
|
-
onChange(selectedDate && selectedDate.length > 0 ? selectedDate : '
|
35
|
+
onChange(selectedDate && selectedDate.length > 0 ? selectedDate : 'INVALID');
|
36
36
|
};
|
37
37
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
38
38
|
className: "".concat(blockClass, "__item-date ")
|
@@ -30,7 +30,7 @@ var ConditionBuilderItemNumber = function ConditionBuilderItemNumber(_ref) {
|
|
30
30
|
invalidNumberWarnText = _useTranslations2[0];
|
31
31
|
var onChangeHandler = function onChangeHandler(e, _ref2) {
|
32
32
|
var value = _ref2.value;
|
33
|
-
if (!isNaN(value) && checkIfValid(value)) {
|
33
|
+
if (value !== '' && !isNaN(value) && checkIfValid(value)) {
|
34
34
|
var _config$unit;
|
35
35
|
onChange("".concat(value, " ").concat((_config$unit = config.unit) !== null && _config$unit !== void 0 ? _config$unit : ''));
|
36
36
|
} else {
|
@@ -44,8 +44,8 @@ var ConditionBuilderItemNumber = function ConditionBuilderItemNumber(_ref) {
|
|
44
44
|
return true;
|
45
45
|
};
|
46
46
|
var getDefaultValue = function getDefaultValue() {
|
47
|
-
var _conditionState$value;
|
48
|
-
return (_conditionState$value = conditionState.value) === null || _conditionState$
|
47
|
+
var _conditionState$value, _conditionState$value2;
|
48
|
+
return (_conditionState$value = (_conditionState$value2 = conditionState.value) === null || _conditionState$value2 === void 0 || (_conditionState$value2 = _conditionState$value2.split(' ')) === null || _conditionState$value2 === void 0 ? void 0 : _conditionState$value2[0]) !== null && _conditionState$value !== void 0 ? _conditionState$value : '';
|
49
49
|
};
|
50
50
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
51
51
|
className: "".concat(DataConfigs.blockClass, "__item-number")
|
@@ -121,14 +121,17 @@ var ItemOptionForValueField = function ItemOptionForValueField(_ref) {
|
|
121
121
|
setSearchValue(value);
|
122
122
|
};
|
123
123
|
var onClickHandler = function onClickHandler(evt, option, isSelected) {
|
124
|
+
var updatedSelections = selection.filter(function (item) {
|
125
|
+
return item !== 'INVALID';
|
126
|
+
});
|
124
127
|
if (multiSelectable) {
|
125
128
|
if (isSelected) {
|
126
|
-
var items =
|
129
|
+
var items = updatedSelections.filter(function (v) {
|
127
130
|
return v.id !== option.id;
|
128
131
|
});
|
129
|
-
onChange(items.length > 0 ? items : undefined
|
132
|
+
onChange(items.length > 0 ? items : undefined);
|
130
133
|
} else {
|
131
|
-
onChange([].concat(_rollupPluginBabelHelpers.toConsumableArray(
|
134
|
+
onChange([].concat(_rollupPluginBabelHelpers.toConsumableArray(updatedSelections), [option]));
|
132
135
|
}
|
133
136
|
} else {
|
134
137
|
onChange(option, evt);
|
@@ -14,13 +14,14 @@ var React = require('react');
|
|
14
14
|
var react = require('@carbon/react');
|
15
15
|
var index = require('../../../../node_modules/prop-types/index.js');
|
16
16
|
var DataConfigs = require('../../ConditionBuilderContext/DataConfigs.js');
|
17
|
+
var util = require('../../utils/util.js');
|
17
18
|
|
18
19
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
19
20
|
|
20
21
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
21
22
|
|
22
23
|
var ConditionBuilderItemText = function ConditionBuilderItemText(_ref) {
|
23
|
-
var _conditionState$
|
24
|
+
var _conditionState$prope;
|
24
25
|
var conditionState = _ref.conditionState,
|
25
26
|
_onChange = _ref.onChange,
|
26
27
|
config = _ref.config,
|
@@ -28,7 +29,7 @@ var ConditionBuilderItemText = function ConditionBuilderItemText(_ref) {
|
|
28
29
|
var inputProps = _rollupPluginBabelHelpers.objectSpread2({
|
29
30
|
labelText: conditionState.property,
|
30
31
|
hideLabel: true,
|
31
|
-
value: (
|
32
|
+
value: util.checkIsValid(conditionState.value) ? conditionState.value : '',
|
32
33
|
id: (_conditionState$prope = conditionState.property) === null || _conditionState$prope === void 0 ? void 0 : _conditionState$prope.replace(/\s/g, ''),
|
33
34
|
onChange: function onChange(evt) {
|
34
35
|
_onChange(evt.target.value);
|
@@ -5,19 +5,17 @@ export default ConditionGroupBuilder;
|
|
5
5
|
* All the inner components of group are called from here.
|
6
6
|
* @returns
|
7
7
|
*/
|
8
|
-
declare function ConditionGroupBuilder({ group, aria, onRemove, onChange,
|
8
|
+
declare function ConditionGroupBuilder({ group, aria, onRemove, onChange, className, }: {
|
9
9
|
group: any;
|
10
10
|
aria: any;
|
11
11
|
onRemove: any;
|
12
12
|
onChange: any;
|
13
|
-
conditionBuilderRef: any;
|
14
13
|
className: any;
|
15
14
|
}): import("react/jsx-runtime").JSX.Element;
|
16
15
|
declare namespace ConditionGroupBuilder {
|
17
16
|
namespace propTypes {
|
18
17
|
let aria: PropTypes.Requireable<object>;
|
19
18
|
let className: PropTypes.Requireable<string>;
|
20
|
-
let conditionBuilderRef: PropTypes.Requireable<object>;
|
21
19
|
let group: PropTypes.Requireable<object>;
|
22
20
|
let onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
23
21
|
let onRemove: PropTypes.Requireable<(...args: any[]) => any>;
|
@@ -42,14 +42,15 @@ var ConditionGroupBuilder = function ConditionGroupBuilder(_ref) {
|
|
42
42
|
aria = _ref.aria,
|
43
43
|
onRemove = _ref.onRemove,
|
44
44
|
onChange = _ref.onChange,
|
45
|
-
conditionBuilderRef = _ref.conditionBuilderRef,
|
46
45
|
className = _ref.className;
|
47
|
-
var _useTranslations = useTranslations.useTranslations(['
|
48
|
-
_useTranslations2 = _rollupPluginBabelHelpers.slicedToArray(_useTranslations,
|
46
|
+
var _useTranslations = useTranslations.useTranslations(['conditionBuilderGroupText', 'conditionText', 'conditionBuilderText']),
|
47
|
+
_useTranslations2 = _rollupPluginBabelHelpers.slicedToArray(_useTranslations, 3),
|
49
48
|
conditionBuilderGroupText = _useTranslations2[0],
|
50
|
-
conditionText = _useTranslations2[1]
|
49
|
+
conditionText = _useTranslations2[1],
|
50
|
+
conditionBuilderText = _useTranslations2[2];
|
51
51
|
var _useContext = React.useContext(ConditionBuilderProvider.ConditionBuilderContext),
|
52
|
-
variant = _useContext.variant
|
52
|
+
variant = _useContext.variant,
|
53
|
+
conditionBuilderRef = _useContext.conditionBuilderRef;
|
53
54
|
var _useState = React.useState(-1),
|
54
55
|
_useState2 = _rollupPluginBabelHelpers.slicedToArray(_useState, 2),
|
55
56
|
showConditionPreview = _useState2[0],
|
@@ -62,11 +63,42 @@ var ConditionGroupBuilder = function ConditionGroupBuilder(_ref) {
|
|
62
63
|
var onRemoveHandler = function onRemoveHandler(conditionId, evt, conditionIndex) {
|
63
64
|
if (group.conditions.length > 1) {
|
64
65
|
variant == 'tree' ? handleFocusOnCloseTree(evt) : handleFocusOnClose(evt, conditionIndex);
|
65
|
-
|
66
|
-
conditions
|
67
|
-
|
68
|
-
|
69
|
-
|
66
|
+
if (group.conditions[1].conditions && group.conditions[1].id !== conditionId) {
|
67
|
+
//when we remove every plain conditions of a group without deleting the subgroup, we need to restructure the group
|
68
|
+
//the inner group become outer group and same level subgroups become plain conditions
|
69
|
+
|
70
|
+
//ensure we are deleting last condition , not the subgroup
|
71
|
+
|
72
|
+
//spreading out the condition inside the subgroup
|
73
|
+
var allConditions = group.conditions.reduce(function (acc, item) {
|
74
|
+
if (item.conditions) {
|
75
|
+
return acc.concat(item.conditions);
|
76
|
+
}
|
77
|
+
return acc;
|
78
|
+
}, []);
|
79
|
+
|
80
|
+
//we always have conditions first and then subgroups, so ordering accordingly
|
81
|
+
var groupedItems = {
|
82
|
+
groups: [],
|
83
|
+
conditions: []
|
84
|
+
};
|
85
|
+
allConditions.forEach(function (item) {
|
86
|
+
if (item.conditions) {
|
87
|
+
groupedItems.groups.push(item);
|
88
|
+
} else {
|
89
|
+
groupedItems.conditions.push(item);
|
90
|
+
}
|
91
|
+
});
|
92
|
+
onChange(_rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, group), {}, {
|
93
|
+
conditions: [].concat(_rollupPluginBabelHelpers.toConsumableArray(groupedItems.conditions), _rollupPluginBabelHelpers.toConsumableArray(groupedItems.groups))
|
94
|
+
}));
|
95
|
+
} else {
|
96
|
+
onChange(_rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, group), {}, {
|
97
|
+
conditions: group.conditions.filter(function (condition) {
|
98
|
+
return conditionId !== condition.id;
|
99
|
+
})
|
100
|
+
}));
|
101
|
+
}
|
70
102
|
} else {
|
71
103
|
onRemove(evt);
|
72
104
|
}
|
@@ -96,11 +128,9 @@ var ConditionGroupBuilder = function ConditionGroupBuilder(_ref) {
|
|
96
128
|
//or focus the next one.
|
97
129
|
var currentGroupCloseButtons = (_e$currentTarget$clos = e.currentTarget.closest(".".concat(DataConfigs.blockClass, "__group"))) === null || _e$currentTarget$clos === void 0 ? void 0 : _e$currentTarget$clos.querySelectorAll('[data-name="closeCondition"]');
|
98
130
|
if (conditionIndex == currentGroupCloseButtons.length - 1) {
|
99
|
-
|
100
|
-
(_currentGroupCloseBut = currentGroupCloseButtons[conditionIndex - 1]) === null || _currentGroupCloseBut === void 0 || _currentGroupCloseBut.focus();
|
131
|
+
util.manageTabIndexAndFocus(currentGroupCloseButtons[conditionIndex - 1], conditionBuilderRef);
|
101
132
|
} else {
|
102
|
-
|
103
|
-
(_currentGroupCloseBut2 = currentGroupCloseButtons[conditionIndex + 1]) === null || _currentGroupCloseBut2 === void 0 || _currentGroupCloseBut2.focus();
|
133
|
+
util.manageTabIndexAndFocus(currentGroupCloseButtons[conditionIndex + 1], conditionBuilderRef);
|
104
134
|
}
|
105
135
|
};
|
106
136
|
var handleFocusOnCloseTree = function handleFocusOnCloseTree(evt) {
|
@@ -116,11 +146,9 @@ var ConditionGroupBuilder = function ConditionGroupBuilder(_ref) {
|
|
116
146
|
//Otherwise , check the previous item is a valid condition
|
117
147
|
|
118
148
|
if (nextElement !== null && nextElement !== void 0 && nextElement.classList.contains("".concat(DataConfigs.blockClass, "__condition-block"))) {
|
119
|
-
|
120
|
-
nextElement === null || nextElement === void 0 || (_nextElement$querySel = nextElement.querySelector('[data-name="closeCondition"]')) === null || _nextElement$querySel === void 0 || _nextElement$querySel.focus();
|
149
|
+
util.manageTabIndexAndFocus(nextElement === null || nextElement === void 0 ? void 0 : nextElement.querySelector('[data-name="closeCondition"]'), conditionBuilderRef);
|
121
150
|
} else if (prevElement !== null && prevElement !== void 0 && prevElement.classList.contains("".concat(DataConfigs.blockClass, "__condition-block"))) {
|
122
|
-
|
123
|
-
prevElement === null || prevElement === void 0 || (_prevElement$querySel = prevElement.querySelector('[data-name="closeCondition"]')) === null || _prevElement$querySel === void 0 || _prevElement$querySel.focus();
|
151
|
+
util.manageTabIndexAndFocus(prevElement === null || prevElement === void 0 ? void 0 : prevElement.querySelector('[data-name="closeCondition"]'), conditionBuilderRef);
|
124
152
|
}
|
125
153
|
//If there are no valid condition in this group, focus next or previous row
|
126
154
|
else {
|
@@ -128,10 +156,18 @@ var ConditionGroupBuilder = function ConditionGroupBuilder(_ref) {
|
|
128
156
|
var prevRows = (_conditionBuilderCont3 = conditionBuilderContentRef.current) === null || _conditionBuilderCont3 === void 0 ? void 0 : _conditionBuilderCont3.querySelectorAll("[aria-level=\"".concat(Number(currentLevel) - 1, "\"][role=\"row\"]"));
|
129
157
|
var nextRow = (_conditionBuilderCont4 = conditionBuilderContentRef.current) === null || _conditionBuilderCont4 === void 0 ? void 0 : _conditionBuilderCont4.querySelector("[aria-level=\"".concat(Number(currentLevel) + 1, "\"][role=\"row\"]"));
|
130
158
|
if (nextRow) {
|
131
|
-
|
159
|
+
//since there are no condition in current group, this group will move one level up
|
160
|
+
|
161
|
+
var rowIdentity = {
|
162
|
+
ariaLevel: Number(nextRow.ariaLevel) - 1,
|
163
|
+
ariaPosInSet: nextRow.ariaPosInSet
|
164
|
+
};
|
165
|
+
setTimeout(function () {
|
166
|
+
var currentRowToFocus = conditionBuilderContentRef.current.querySelector("[role=\"row\"][aria-level=\"".concat(rowIdentity.ariaLevel, "\"][aria-posinset=\"").concat(rowIdentity.ariaPosInSet, "\"]"));
|
167
|
+
util.manageTabIndexAndFocus(currentRowToFocus, conditionBuilderRef);
|
168
|
+
}, 0);
|
132
169
|
} else if ((prevRows === null || prevRows === void 0 ? void 0 : prevRows.length) > 1) {
|
133
|
-
|
134
|
-
(_prevRows = prevRows[prevRows.length - 2]) === null || _prevRows === void 0 || _prevRows.focus();
|
170
|
+
util.manageTabIndexAndFocus(prevRows[prevRows.length - 2], conditionBuilderRef);
|
135
171
|
}
|
136
172
|
}
|
137
173
|
};
|
@@ -188,7 +224,7 @@ var ConditionGroupBuilder = function ConditionGroupBuilder(_ref) {
|
|
188
224
|
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
189
225
|
className: "".concat(DataConfigs.blockClass, "__condition-wrapper"),
|
190
226
|
role: "grid",
|
191
|
-
"aria-label":
|
227
|
+
"aria-label": conditionBuilderText
|
192
228
|
}, group === null || group === void 0 || (_group$conditions = group.conditions) === null || _group$conditions === void 0 ? void 0 : _group$conditions.map(function (eachCondition, conditionIndex) {
|
193
229
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
194
230
|
key: eachCondition.id,
|
@@ -242,7 +278,7 @@ var ConditionGroupBuilder = function ConditionGroupBuilder(_ref) {
|
|
242
278
|
label: conditionText
|
243
279
|
},
|
244
280
|
onChange: function onChange(v, evt) {
|
245
|
-
util.focusThisField(evt);
|
281
|
+
util.focusThisField(evt, conditionBuilderRef);
|
246
282
|
onStatementChangeHandler(v);
|
247
283
|
},
|
248
284
|
config: {
|
@@ -254,7 +290,7 @@ var ConditionGroupBuilder = function ConditionGroupBuilder(_ref) {
|
|
254
290
|
}, eachCondition.conditions ? /*#__PURE__*/React__default["default"].createElement("div", {
|
255
291
|
className: cx__default["default"]("".concat(DataConfigs.blockClass, "__condition-block subgroup ").concat(DataConfigs.blockClass, "__gap"), _rollupPluginBabelHelpers.defineProperty({}, "".concat(DataConfigs.blockClass, "__gap-bottom"), group.conditions.length < conditionIndex + 1))
|
256
292
|
}, /*#__PURE__*/React__default["default"].createElement(ConditionConnector["default"], {
|
257
|
-
className: "".concat(DataConfigs.blockClass, "__gap ").concat(DataConfigs.blockClass, "__groupConnector"),
|
293
|
+
className: "".concat(DataConfigs.blockClass, "__gap ").concat(DataConfigs.blockClass, "__gap-bottom ").concat(DataConfigs.blockClass, "__groupConnector"),
|
258
294
|
operator: group.groupOperator,
|
259
295
|
"aria-hidden": true
|
260
296
|
}), /*#__PURE__*/React__default["default"].createElement(ConditionGroupBuilder, {
|
@@ -270,8 +306,7 @@ var ConditionGroupBuilder = function ConditionGroupBuilder(_ref) {
|
|
270
306
|
},
|
271
307
|
onRemove: function onRemove(e) {
|
272
308
|
onRemoveHandler(eachCondition.id, e);
|
273
|
-
}
|
274
|
-
conditionBuilderRef: conditionBuilderRef
|
309
|
+
}
|
275
310
|
})) : /*#__PURE__*/React__default["default"].createElement("div", null, /*#__PURE__*/React__default["default"].createElement(ConditionBlock["default"], {
|
276
311
|
conjunction: conditionIndex > 0 ? group.groupOperator : undefined,
|
277
312
|
aria: {
|
@@ -326,11 +361,6 @@ ConditionGroupBuilder.propTypes = {
|
|
326
361
|
* Provide an optional class to be applied to the containing node.
|
327
362
|
*/
|
328
363
|
className: index["default"].string,
|
329
|
-
/**
|
330
|
-
className: PropTypes.string,
|
331
|
-
* ref of condition builder
|
332
|
-
*/
|
333
|
-
conditionBuilderRef: index["default"].object,
|
334
364
|
group: index["default"].object,
|
335
365
|
/**
|
336
366
|
* callback to update the current condition of the state tree
|