@carbon/ibm-products 2.40.0 → 2.40.1-canary.6
Sign up to get free protection for your applications and to get access to all the features.
- package/css/index-full-carbon.css +36 -34
- 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 +36 -34
- 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 +699 -34
- 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 +3 -3
- package/es/components/ConditionBuilder/ConditionBuilder.js +6 -1
- package/es/components/ConditionBuilder/ConditionBuilderAdd/ConditionBuilderAdd.js +3 -3
- package/es/components/ConditionBuilder/ConditionBuilderButton/ConditionBuilderButton.js +1 -1
- package/es/components/ConditionBuilder/ConditionBuilderContent/ConditionBuilderContent.js +2 -2
- package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItem.js +3 -3
- package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemDate/ConditionBuilderItemDate.js +1 -1
- package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemNumber/ConditionBuilderItemNumber.js +1 -1
- package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemOption/ConditionBuilderItemOption.js +30 -18
- package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemText/ConditionBuilderItemText.js +3 -3
- package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemTime/ConditionBuilderItemTime.js +7 -7
- package/es/components/ConditionBuilder/ConditionConnector/ConditionConnector.js +6 -6
- package/es/components/ConditionBuilder/ConditionGroupBuilder/ConditionGroupBuilder.js +11 -11
- package/es/components/ConditionBuilder/utils/checkForHoldingKey.d.ts +1 -0
- package/es/components/ConditionBuilder/utils/checkForHoldingKey.js +16 -0
- package/es/components/ConditionBuilder/utils/handleKeyboardEvents.d.ts +1 -0
- package/es/components/ConditionBuilder/utils/handleKeyboardEvents.js +125 -0
- package/es/components/ConditionBuilder/utils/util.d.ts +1 -1
- package/es/components/ConditionBuilder/utils/util.js +34 -5
- package/es/components/Datagrid/Datagrid/DatagridHeaderRow.js +3 -4
- package/es/components/TagOverflow/TagOverflow.js +35 -20
- package/es/components/TagOverflow/TagOverflowModal.d.ts +3 -1
- package/es/components/TagOverflow/TagOverflowModal.js +14 -20
- package/es/components/TagOverflow/TagOverflowPopover.js +19 -4
- package/lib/components/ConditionBuilder/ConditionBlock/ConditionBlock.js +3 -3
- package/lib/components/ConditionBuilder/ConditionBuilder.js +6 -1
- package/lib/components/ConditionBuilder/ConditionBuilderAdd/ConditionBuilderAdd.js +3 -3
- package/lib/components/ConditionBuilder/ConditionBuilderButton/ConditionBuilderButton.js +1 -1
- package/lib/components/ConditionBuilder/ConditionBuilderContent/ConditionBuilderContent.js +2 -2
- package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItem.js +3 -3
- package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemDate/ConditionBuilderItemDate.js +1 -1
- package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemNumber/ConditionBuilderItemNumber.js +1 -1
- package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemOption/ConditionBuilderItemOption.js +29 -17
- package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemText/ConditionBuilderItemText.js +3 -3
- package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemTime/ConditionBuilderItemTime.js +7 -7
- package/lib/components/ConditionBuilder/ConditionConnector/ConditionConnector.js +6 -6
- package/lib/components/ConditionBuilder/ConditionGroupBuilder/ConditionGroupBuilder.js +11 -11
- package/lib/components/ConditionBuilder/utils/checkForHoldingKey.d.ts +1 -0
- package/lib/components/ConditionBuilder/utils/checkForHoldingKey.js +20 -0
- package/lib/components/ConditionBuilder/utils/handleKeyboardEvents.d.ts +1 -0
- package/lib/components/ConditionBuilder/utils/handleKeyboardEvents.js +129 -0
- package/lib/components/ConditionBuilder/utils/util.d.ts +1 -1
- package/lib/components/ConditionBuilder/utils/util.js +36 -4
- package/lib/components/Datagrid/Datagrid/DatagridHeaderRow.js +3 -4
- package/lib/components/TagOverflow/TagOverflow.js +34 -19
- package/lib/components/TagOverflow/TagOverflowModal.d.ts +3 -1
- package/lib/components/TagOverflow/TagOverflowModal.js +14 -20
- package/lib/components/TagOverflow/TagOverflowPopover.js +19 -4
- package/package.json +2 -2
- package/scss/components/ConditionBuilder/styles/_conditionBuilderCondition.scss +4 -4
- package/scss/components/ConditionBuilder/styles/_conditionBuilderItem.scss +34 -34
- package/scss/components/TagOverflow/_tag-overflow.scss +5 -2
- package/scss/components/_index-with-carbon.scss +1 -0
@@ -67,7 +67,7 @@ var ConditionBuilderContent = function ConditionBuilderContent(_ref) {
|
|
67
67
|
className: "".concat(blockClass, "__content-container"),
|
68
68
|
tabIndex: -1
|
69
69
|
}, !isConditionBuilderActive && /*#__PURE__*/React__default.createElement(Button, {
|
70
|
-
className: "".concat(blockClass, "
|
70
|
+
className: "".concat(blockClass, "__add-condition-button"),
|
71
71
|
renderIcon: function renderIcon(props) {
|
72
72
|
return /*#__PURE__*/React__default.createElement(Add, _extends({
|
73
73
|
size: 16
|
@@ -79,7 +79,7 @@ var ConditionBuilderContent = function ConditionBuilderContent(_ref) {
|
|
79
79
|
onClick: onStartConditionBuilder
|
80
80
|
}, startConditionLabel), rootState && (rootState === null || rootState === void 0 || (_rootState$groups2 = rootState.groups) === null || _rootState$groups2 === void 0 ? void 0 : _rootState$groups2.map(function (eachGroup, groupIndex) {
|
81
81
|
return /*#__PURE__*/React__default.createElement(ConditionGroupBuilder, {
|
82
|
-
className: "".concat(blockClass, "
|
82
|
+
className: "".concat(blockClass, "__group"),
|
83
83
|
key: groupIndex,
|
84
84
|
aria: {
|
85
85
|
level: 1,
|
@@ -69,7 +69,7 @@ var ConditionBuilderItem = function ConditionBuilderItem(_ref) {
|
|
69
69
|
useEffect(function () {
|
70
70
|
//this will focus the first input field in the popover
|
71
71
|
if (open && contentRef.current) {
|
72
|
-
var firstFocusableElement = contentRef.current.querySelector('input
|
72
|
+
var firstFocusableElement = contentRef.current.querySelector('input');
|
73
73
|
if (firstFocusableElement) {
|
74
74
|
firstFocusableElement.focus();
|
75
75
|
}
|
@@ -95,11 +95,11 @@ var ConditionBuilderItem = function ConditionBuilderItem(_ref) {
|
|
95
95
|
renderIcon: renderIcon ? renderIcon : label == undefined ? Add : null,
|
96
96
|
showToolTip: showToolTip
|
97
97
|
}, rest)), /*#__PURE__*/React__default.createElement(PopoverContent, {
|
98
|
-
className: "".concat(blockClass, "
|
98
|
+
className: "".concat(blockClass, "__item__content"),
|
99
99
|
role: "dialog",
|
100
100
|
"aria-label": "".concat(title)
|
101
101
|
}, /*#__PURE__*/React__default.createElement(Layer, null, /*#__PURE__*/React__default.createElement("h1", {
|
102
|
-
className: "".concat(blockClass, "
|
102
|
+
className: "".concat(blockClass, "__item__title")
|
103
103
|
}, title), /*#__PURE__*/React__default.createElement("div", {
|
104
104
|
ref: contentRef
|
105
105
|
}, open && children))));
|
@@ -18,7 +18,7 @@ var ConditionBuilderItemDate = function ConditionBuilderItemDate(_ref) {
|
|
18
18
|
var DatePickerInputRef = useRef();
|
19
19
|
var datePickerType = conditionState.operator == 'between' ? 'range' : 'single';
|
20
20
|
return /*#__PURE__*/React__default.createElement("div", {
|
21
|
-
className: "".concat(blockClass, "
|
21
|
+
className: "".concat(blockClass, "__item-date ")
|
22
22
|
}, datePickerType == 'single' && /*#__PURE__*/React__default.createElement(DatePicker, {
|
23
23
|
ref: DatePickerInputRef,
|
24
24
|
dateFormat: "d/m/Y",
|
@@ -21,7 +21,7 @@ var ConditionBuilderItemNumber = function ConditionBuilderItemNumber(_ref) {
|
|
21
21
|
onChange(value + '');
|
22
22
|
};
|
23
23
|
return /*#__PURE__*/React__default.createElement("div", {
|
24
|
-
className: "".concat(blockClass, "
|
24
|
+
className: "".concat(blockClass, "__item-number")
|
25
25
|
}, /*#__PURE__*/React__default.createElement(NumberInput, {
|
26
26
|
label: conditionState.property,
|
27
27
|
hideLabel: true,
|
@@ -6,7 +6,7 @@
|
|
6
6
|
*/
|
7
7
|
|
8
8
|
import { slicedToArray as _slicedToArray, toConsumableArray as _toConsumableArray, asyncToGenerator as _asyncToGenerator, regeneratorRuntime as _regeneratorRuntime } from '../../../../_virtual/_rollupPluginBabelHelpers.js';
|
9
|
-
import React__default, { useContext, useState, useEffect } from 'react';
|
9
|
+
import React__default, { useContext, useState, useRef, useEffect } from 'react';
|
10
10
|
import { Search, Button, SelectSkeleton } from '@carbon/react';
|
11
11
|
import { CheckboxCheckedFilled, Checkbox, Checkmark } from '@carbon/react/icons';
|
12
12
|
import PropTypes from '../../../../node_modules/prop-types/index.js';
|
@@ -33,6 +33,7 @@ var ConditionBuilderItemOption = function ConditionBuilderItemOption(_ref) {
|
|
33
33
|
filteredItems = _useState4[0],
|
34
34
|
setFilteredItems = _useState4[1];
|
35
35
|
var selection = Array.isArray(conditionState.value) ? conditionState.value : conditionState.value !== undefined ? [conditionState.value] : [];
|
36
|
+
var contentRef = useRef();
|
36
37
|
useEffect(function () {
|
37
38
|
if (!allOptions && getOptions) {
|
38
39
|
var fetchData = /*#__PURE__*/function () {
|
@@ -63,8 +64,18 @@ var ConditionBuilderItemOption = function ConditionBuilderItemOption(_ref) {
|
|
63
64
|
}
|
64
65
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
65
66
|
}, []);
|
66
|
-
|
67
|
-
|
67
|
+
useEffect(function () {
|
68
|
+
//this will focus the first input field in the popover
|
69
|
+
|
70
|
+
if (contentRef.current) {
|
71
|
+
var _contentRef$current;
|
72
|
+
var firstFocusableElement = (_contentRef$current = contentRef.current) === null || _contentRef$current === void 0 ? void 0 : _contentRef$current.querySelector('input, button,li');
|
73
|
+
firstFocusableElement === null || firstFocusableElement === void 0 || firstFocusableElement.focus();
|
74
|
+
}
|
75
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
76
|
+
}, [allOptions]);
|
77
|
+
var handleSelectAll = function handleSelectAll(evt) {
|
78
|
+
if (evt.currentTarget.dataset.selectedAll == 'false') {
|
68
79
|
onChange(undefined);
|
69
80
|
} else {
|
70
81
|
onChange(allOptions.map(function (op) {
|
@@ -72,31 +83,32 @@ var ConditionBuilderItemOption = function ConditionBuilderItemOption(_ref) {
|
|
72
83
|
}));
|
73
84
|
}
|
74
85
|
};
|
75
|
-
var onSearchChangeHandler = function onSearchChangeHandler(
|
76
|
-
var value =
|
86
|
+
var onSearchChangeHandler = function onSearchChangeHandler(evt) {
|
87
|
+
var value = evt.target.value;
|
77
88
|
var _filteredItems = allOptions.filter(function (opt) {
|
78
89
|
return opt.label.toLowerCase().includes(value.toLowerCase());
|
79
90
|
});
|
80
91
|
setFilteredItems(_filteredItems);
|
81
92
|
};
|
82
|
-
var onClickHandler = function onClickHandler(
|
93
|
+
var onClickHandler = function onClickHandler(evt, option, isSelected) {
|
83
94
|
if (multiSelectable) {
|
84
95
|
if (isSelected) {
|
85
96
|
var items = selection.filter(function (v) {
|
86
97
|
return v !== option.id;
|
87
98
|
});
|
88
|
-
onChange(items.length > 0 ? items : undefined,
|
99
|
+
onChange(items.length > 0 ? items : undefined, evt);
|
89
100
|
} else {
|
90
|
-
onChange([].concat(_toConsumableArray(selection), [option.id]),
|
101
|
+
onChange([].concat(_toConsumableArray(selection), [option.id]), evt);
|
91
102
|
}
|
92
103
|
} else {
|
93
|
-
onChange(option.id,
|
104
|
+
onChange(option.id, evt);
|
94
105
|
}
|
95
106
|
};
|
96
107
|
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, allOptions && /*#__PURE__*/React__default.createElement("div", {
|
97
|
-
className: "".concat(blockClass, "
|
108
|
+
className: "".concat(blockClass, "__item-option"),
|
109
|
+
ref: contentRef
|
98
110
|
}, (config.includeSearch || allOptions.length > popOverSearchThreshold) && /*#__PURE__*/React__default.createElement("div", {
|
99
|
-
className: "".concat(blockClass, "
|
111
|
+
className: "".concat(blockClass, "__item-option__search")
|
100
112
|
}, /*#__PURE__*/React__default.createElement(Search, {
|
101
113
|
size: "sm",
|
102
114
|
labelText: translateWithId('clear_search'),
|
@@ -122,25 +134,25 @@ var ConditionBuilderItemOption = function ConditionBuilderItemOption(_ref) {
|
|
122
134
|
key: option.id,
|
123
135
|
role: "option",
|
124
136
|
"aria-selected": isSelected,
|
125
|
-
className: "".concat(blockClass, "
|
137
|
+
className: "".concat(blockClass, "__item-option__option"),
|
126
138
|
onKeyUp: function onKeyUp() {
|
127
139
|
return false;
|
128
140
|
},
|
129
|
-
onClick: function onClick(
|
130
|
-
return onClickHandler(
|
141
|
+
onClick: function onClick(evt) {
|
142
|
+
return onClickHandler(evt, option, isSelected);
|
131
143
|
}
|
132
144
|
}, /*#__PURE__*/React__default.createElement("div", {
|
133
|
-
className: "".concat(blockClass, "
|
145
|
+
className: "".concat(blockClass, "__item-option__option-content")
|
134
146
|
}, multiSelectable ? /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("span", {
|
135
147
|
className: "".concat(blockClass, "__option-check-box")
|
136
148
|
}, isSelected ? _CheckboxCheckedFille || (_CheckboxCheckedFille = /*#__PURE__*/React__default.createElement(CheckboxCheckedFilled, null)) : _Checkbox || (_Checkbox = /*#__PURE__*/React__default.createElement(Checkbox, null))), /*#__PURE__*/React__default.createElement("span", {
|
137
|
-
className: "".concat(blockClass, "
|
149
|
+
className: "".concat(blockClass, "__item-option__option-label")
|
138
150
|
}, option.label), Icon && /*#__PURE__*/React__default.createElement("span", {
|
139
151
|
className: "".concat(blockClass, "__option-icon")
|
140
152
|
}, /*#__PURE__*/React__default.createElement(Icon, null))) : /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("span", {
|
141
|
-
className: "".concat(blockClass, "
|
153
|
+
className: "".concat(blockClass, "__item-option__option-label")
|
142
154
|
}, Icon && /*#__PURE__*/React__default.createElement(Icon, null), option.label), isSelected && /*#__PURE__*/React__default.createElement(Checkmark, {
|
143
|
-
className: "".concat(blockClass, "
|
155
|
+
className: "".concat(blockClass, "__checkmark")
|
144
156
|
}))));
|
145
157
|
}))), !allOptions && (_SelectSkeleton || (_SelectSkeleton = /*#__PURE__*/React__default.createElement(SelectSkeleton, null))));
|
146
158
|
};
|
@@ -15,14 +15,14 @@ var ConditionBuilderItemText = function ConditionBuilderItemText(_ref) {
|
|
15
15
|
var conditionState = _ref.conditionState,
|
16
16
|
_onChange = _ref.onChange;
|
17
17
|
return /*#__PURE__*/React__default.createElement("div", {
|
18
|
-
className: "".concat(blockClass, "
|
18
|
+
className: "".concat(blockClass, "__item-text")
|
19
19
|
}, /*#__PURE__*/React__default.createElement(TextInput, {
|
20
20
|
labelText: conditionState.property,
|
21
21
|
hideLabel: true,
|
22
22
|
value: (_conditionState$value = conditionState.value) !== null && _conditionState$value !== void 0 ? _conditionState$value : '',
|
23
23
|
id: (_conditionState$prope = conditionState.property) === null || _conditionState$prope === void 0 ? void 0 : _conditionState$prope.replace(/\s/g, ''),
|
24
|
-
onChange: function onChange(
|
25
|
-
_onChange(
|
24
|
+
onChange: function onChange(evt) {
|
25
|
+
_onChange(evt.target.value);
|
26
26
|
}
|
27
27
|
}));
|
28
28
|
};
|
@@ -33,17 +33,17 @@ var ConditionBuilderItemTime = function ConditionBuilderItemTime(_ref) {
|
|
33
33
|
onChange(timeValue ? timeToUpdate : undefined);
|
34
34
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
35
35
|
}, [timeValue, dayZoneValue, timeZoneValue]);
|
36
|
-
var setTimeZone = function setTimeZone(
|
37
|
-
setTimeZoneValue(
|
36
|
+
var setTimeZone = function setTimeZone(evt) {
|
37
|
+
setTimeZoneValue(evt.target.value);
|
38
38
|
};
|
39
|
-
var setDayZone = function setDayZone(
|
40
|
-
setDayZoneValue(
|
39
|
+
var setDayZone = function setDayZone(evt) {
|
40
|
+
setDayZoneValue(evt.target.value);
|
41
41
|
};
|
42
|
-
var setTime = function setTime(
|
43
|
-
setTimeValue(
|
42
|
+
var setTime = function setTime(evt) {
|
43
|
+
setTimeValue(evt.target.value);
|
44
44
|
};
|
45
45
|
return /*#__PURE__*/React__default.createElement("div", {
|
46
|
-
className: "".concat(blockClass, "
|
46
|
+
className: "".concat(blockClass, "__item-time")
|
47
47
|
}, /*#__PURE__*/React__default.createElement(TimePicker, {
|
48
48
|
id: "time-picker",
|
49
49
|
labelText: "Select a time",
|
@@ -28,17 +28,17 @@ function ConditionConnector(_ref) {
|
|
28
28
|
parentGroup.classList.remove('hoveredConnector');
|
29
29
|
}
|
30
30
|
}, []);
|
31
|
-
var activeConnectorHandler = function activeConnectorHandler(
|
32
|
-
var parentGroup =
|
31
|
+
var activeConnectorHandler = function activeConnectorHandler(evt) {
|
32
|
+
var parentGroup = evt.currentTarget.closest('.eachGroup');
|
33
33
|
handleConnectorHover(parentGroup, true);
|
34
34
|
};
|
35
|
-
var inActiveConnectorHandler = function inActiveConnectorHandler(
|
36
|
-
var parentGroup =
|
35
|
+
var inActiveConnectorHandler = function inActiveConnectorHandler(evt) {
|
36
|
+
var parentGroup = evt.currentTarget.closest('.eachGroup');
|
37
37
|
handleConnectorHover(parentGroup, false);
|
38
38
|
};
|
39
|
-
var onChangeHandler = function onChangeHandler(op,
|
39
|
+
var onChangeHandler = function onChangeHandler(op, evt) {
|
40
40
|
onChange(op);
|
41
|
-
focusThisField(
|
41
|
+
focusThisField(evt);
|
42
42
|
};
|
43
43
|
return (
|
44
44
|
/*#__PURE__*/
|
@@ -26,16 +26,16 @@ var ConditionGroupBuilder = function ConditionGroupBuilder(_ref) {
|
|
26
26
|
onChange = _ref.onChange,
|
27
27
|
conditionBuilderRef = _ref.conditionBuilderRef,
|
28
28
|
className = _ref.className;
|
29
|
-
var onRemoveHandler = function onRemoveHandler(conditionId,
|
29
|
+
var onRemoveHandler = function onRemoveHandler(conditionId, evt) {
|
30
30
|
if (group.conditions.length > 1) {
|
31
31
|
onChange(_objectSpread2(_objectSpread2({}, group), {}, {
|
32
32
|
conditions: group.conditions.filter(function (condition) {
|
33
33
|
return conditionId !== condition.id;
|
34
34
|
})
|
35
35
|
}));
|
36
|
-
handleFocusOnClose(
|
36
|
+
handleFocusOnClose(evt);
|
37
37
|
} else {
|
38
|
-
onRemove();
|
38
|
+
onRemove(evt);
|
39
39
|
}
|
40
40
|
};
|
41
41
|
var onChangeHandler = function onChangeHandler(updatedCondition, conditionIndex) {
|
@@ -59,9 +59,9 @@ var ConditionGroupBuilder = function ConditionGroupBuilder(_ref) {
|
|
59
59
|
var isLastCondition = function isLastCondition(conditionIndex, conditionArr) {
|
60
60
|
return conditionIndex + 1 >= conditionArr.length || conditionArr.length - 1 != conditionIndex && conditionArr[conditionIndex + 1].conditions;
|
61
61
|
};
|
62
|
-
var handleFocusOnClose = function handleFocusOnClose(
|
63
|
-
var
|
64
|
-
var previousClose = (
|
62
|
+
var handleFocusOnClose = function handleFocusOnClose(evt) {
|
63
|
+
var _evt$currentTarget;
|
64
|
+
var previousClose = (_evt$currentTarget = evt.currentTarget) === null || _evt$currentTarget === void 0 || (_evt$currentTarget = _evt$currentTarget.closest('[role="row"]')) === null || _evt$currentTarget === void 0 || (_evt$currentTarget = _evt$currentTarget.parentElement) === null || _evt$currentTarget === void 0 || (_evt$currentTarget = _evt$currentTarget.previousSibling) === null || _evt$currentTarget === void 0 ? void 0 : _evt$currentTarget.querySelector('[data-name="closeCondition"]');
|
65
65
|
if (previousClose) {
|
66
66
|
previousClose.focus();
|
67
67
|
}
|
@@ -76,7 +76,7 @@ var ConditionGroupBuilder = function ConditionGroupBuilder(_ref) {
|
|
76
76
|
return /*#__PURE__*/React__default.createElement("div", {
|
77
77
|
key: eachCondition.id
|
78
78
|
}, eachCondition.conditions && /*#__PURE__*/React__default.createElement(ConditionGroupBuilder, {
|
79
|
-
className: "".concat(blockClass, "
|
79
|
+
className: "".concat(blockClass, "__group"),
|
80
80
|
aria: {
|
81
81
|
level: aria.level + 1,
|
82
82
|
posinset: conditionIndex + 1,
|
@@ -86,8 +86,8 @@ var ConditionGroupBuilder = function ConditionGroupBuilder(_ref) {
|
|
86
86
|
onChange: function onChange(updatedCondition) {
|
87
87
|
onChangeHandler(updatedCondition, conditionIndex);
|
88
88
|
},
|
89
|
-
onRemove: function onRemove(
|
90
|
-
onRemoveHandler(eachCondition.id,
|
89
|
+
onRemove: function onRemove(evt) {
|
90
|
+
onRemoveHandler(eachCondition.id, evt);
|
91
91
|
},
|
92
92
|
conditionBuilderRef: conditionBuilderRef
|
93
93
|
}), !eachCondition.conditions && /*#__PURE__*/React__default.createElement(ConditionBlock, {
|
@@ -106,8 +106,8 @@ var ConditionGroupBuilder = function ConditionGroupBuilder(_ref) {
|
|
106
106
|
onChangeHandler(updatedConditions, conditionIndex);
|
107
107
|
},
|
108
108
|
addConditionHandler: addConditionHandler,
|
109
|
-
onRemove: function onRemove(
|
110
|
-
onRemoveHandler(eachCondition.id,
|
109
|
+
onRemove: function onRemove(evt) {
|
110
|
+
onRemoveHandler(eachCondition.id, evt);
|
111
111
|
},
|
112
112
|
onConnectorOperatorChange: function onConnectorOperatorChange(op) {
|
113
113
|
onChange(_objectSpread2(_objectSpread2({}, group), {}, {
|
@@ -0,0 +1 @@
|
|
1
|
+
export function checkForHoldingKey(evt: any, key: any): any;
|
@@ -0,0 +1,16 @@
|
|
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
|
+
var checkForHoldingKey = function checkForHoldingKey(evt, key) {
|
9
|
+
// possible key inputs: altKey,ctrlKey,metaKey,shiftKey
|
10
|
+
if (key === 'cmd') {
|
11
|
+
return evt.metaKey || evt.ctrlKey;
|
12
|
+
}
|
13
|
+
return evt[key];
|
14
|
+
};
|
15
|
+
|
16
|
+
export { checkForHoldingKey };
|
@@ -0,0 +1 @@
|
|
1
|
+
export function handleKeyDown(evt: any, conditionBuilderRef: any): void;
|
@@ -0,0 +1,125 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright IBM Corp. 2020, 2024
|
3
|
+
*
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
6
|
+
*/
|
7
|
+
|
8
|
+
import { toConsumableArray as _toConsumableArray } from '../../../_virtual/_rollupPluginBabelHelpers.js';
|
9
|
+
import { blockClass } from '../ConditionBuilderContext/DataConfigs.js';
|
10
|
+
import { checkForHoldingKey } from './checkForHoldingKey.js';
|
11
|
+
import { focusThisField, traverseReverse, traverseClockVise } from './util.js';
|
12
|
+
|
13
|
+
var handleKeyDown = function handleKeyDown(evt, conditionBuilderRef) {
|
14
|
+
var activeElement = document.activeElement;
|
15
|
+
if (activeElement.closest("[role=\"dialog\"]")) {
|
16
|
+
handleKeyPressForPopover(evt, activeElement.closest("[role=\"dialog\"]"));
|
17
|
+
} else {
|
18
|
+
handleKeyPressForMainContent(evt, conditionBuilderRef);
|
19
|
+
}
|
20
|
+
};
|
21
|
+
var handleKeyPressForPopover = function handleKeyPressForPopover(evt, parentContainer) {
|
22
|
+
var _parentContainer$quer;
|
23
|
+
var key = evt.key;
|
24
|
+
var isHoldingShiftKey = checkForHoldingKey(evt, 'shiftKey');
|
25
|
+
var isMultiSelect = (_parentContainer$quer = parentContainer.querySelector('ul')) === null || _parentContainer$quer === void 0 ? void 0 : _parentContainer$quer.dataset.multiSelect;
|
26
|
+
var allItems = [];
|
27
|
+
switch (key) {
|
28
|
+
case 'ArrowUp':
|
29
|
+
//traverse through the popover options, search box, selectAll button
|
30
|
+
parentContainer.querySelectorAll("[role=\"option\"]").forEach(function (eachElem, index, allElements) {
|
31
|
+
traverseReverse(eachElem, index, allElements);
|
32
|
+
});
|
33
|
+
break;
|
34
|
+
case 'ArrowDown':
|
35
|
+
//traverse through the popover options, search box, selectAll button
|
36
|
+
parentContainer.querySelectorAll("[role=\"option\"]").forEach(function (eachElem, index, allElements) {
|
37
|
+
traverseClockVise(eachElem, index, allElements);
|
38
|
+
});
|
39
|
+
break;
|
40
|
+
case 'Tab':
|
41
|
+
allItems = [].concat(_toConsumableArray(Array.from(parentContainer.querySelectorAll(".".concat(blockClass, "__selectAll-button,[role=\"searchbox\"]")))), [parentContainer.querySelector("[role=\"option\"]")]);
|
42
|
+
allItems.forEach(function (eachElem, index, allElements) {
|
43
|
+
if (isHoldingShiftKey) {
|
44
|
+
traverseReverse(eachElem, index, allElements, true, true);
|
45
|
+
} else {
|
46
|
+
traverseClockVise(eachElem, index, allElements, true, true);
|
47
|
+
}
|
48
|
+
});
|
49
|
+
evt.preventDefault();
|
50
|
+
break;
|
51
|
+
case ' ':
|
52
|
+
if (isMultiSelect === 'true') {
|
53
|
+
if (document.activeElement.type !== 'button') {
|
54
|
+
var _document$activeEleme;
|
55
|
+
//for button , enter key is click which already handled by framework, for other elements trigger click
|
56
|
+
(_document$activeEleme = document.activeElement) === null || _document$activeEleme === void 0 || _document$activeEleme.click();
|
57
|
+
}
|
58
|
+
evt.preventDefault();
|
59
|
+
}
|
60
|
+
break;
|
61
|
+
case 'Enter':
|
62
|
+
if (isMultiSelect !== 'true') {
|
63
|
+
if (document.activeElement.type !== 'button') {
|
64
|
+
var _document$activeEleme2;
|
65
|
+
//for button , enter key is click which already handled by framework, else trigger click
|
66
|
+
(_document$activeEleme2 = document.activeElement) === null || _document$activeEleme2 === void 0 || _document$activeEleme2.click();
|
67
|
+
focusThisField(evt);
|
68
|
+
}
|
69
|
+
}
|
70
|
+
break;
|
71
|
+
case 'Escape':
|
72
|
+
//focus the corresponding field in which the popover is triggered
|
73
|
+
focusThisField(evt);
|
74
|
+
break;
|
75
|
+
}
|
76
|
+
};
|
77
|
+
var getRows = function getRows(conditionBuilderRef) {
|
78
|
+
return Array.from(conditionBuilderRef.current.querySelectorAll('[role="row"]'));
|
79
|
+
};
|
80
|
+
var getRowIndex = function getRowIndex(element, conditionBuilderRef) {
|
81
|
+
var rows = getRows(conditionBuilderRef);
|
82
|
+
return rows.findIndex(function (row) {
|
83
|
+
return row.contains(element);
|
84
|
+
});
|
85
|
+
};
|
86
|
+
var handleRowNavigation = function handleRowNavigation(evt, conditionBuilderRef) {
|
87
|
+
var rows = getRows(conditionBuilderRef);
|
88
|
+
var currentRowIndex = getRowIndex(evt.target, conditionBuilderRef);
|
89
|
+
navigateToNextRowCell(evt, currentRowIndex, rows);
|
90
|
+
};
|
91
|
+
var navigateToNextRowCell = function navigateToNextRowCell(evt, currentRowIndex, rows) {
|
92
|
+
var _nextRow$querySelecto;
|
93
|
+
//when the focussed element is a cell of the row which has only 1 cell (connector or statement) , focus the next row
|
94
|
+
|
95
|
+
var nextRowIndex = currentRowIndex;
|
96
|
+
if (evt.key === 'ArrowUp') {
|
97
|
+
nextRowIndex = currentRowIndex == 0 ? currentRowIndex : currentRowIndex - 1;
|
98
|
+
}
|
99
|
+
if (evt.key === 'ArrowDown') {
|
100
|
+
nextRowIndex = currentRowIndex === rows.length - 1 ? rows.length - 1 : currentRowIndex + 1;
|
101
|
+
}
|
102
|
+
var nextRow = rows[nextRowIndex];
|
103
|
+
var itemName = evt.target.dataset.name;
|
104
|
+
nextRow === null || nextRow === void 0 || (_nextRow$querySelecto = nextRow.querySelector("[data-name=\"".concat(itemName, "\"]"))) === null || _nextRow$querySelecto === void 0 || _nextRow$querySelecto.focus();
|
105
|
+
};
|
106
|
+
var handleKeyPressForMainContent = function handleKeyPressForMainContent(evt, conditionBuilderRef) {
|
107
|
+
switch (evt.key) {
|
108
|
+
case 'ArrowRight':
|
109
|
+
case 'ArrowLeft':
|
110
|
+
conditionBuilderRef.current.querySelectorAll("[role=\"gridcell\"] button").forEach(function (eachElem, index, allElements) {
|
111
|
+
if (evt.key === 'ArrowRight') {
|
112
|
+
traverseClockVise(eachElem, index, allElements);
|
113
|
+
} else {
|
114
|
+
traverseReverse(eachElem, index, allElements);
|
115
|
+
}
|
116
|
+
});
|
117
|
+
break;
|
118
|
+
case 'ArrowUp':
|
119
|
+
case 'ArrowDown':
|
120
|
+
handleRowNavigation(evt, conditionBuilderRef);
|
121
|
+
break;
|
122
|
+
}
|
123
|
+
};
|
124
|
+
|
125
|
+
export { handleKeyDown };
|
@@ -1,4 +1,4 @@
|
|
1
|
-
export function focusThisField(
|
1
|
+
export function focusThisField(evt: any): void;
|
2
2
|
export function focusThisItem(currentElement: any): void;
|
3
3
|
export function traverseClockVise(eachElem: any, index: any, allElements: any, rotate: any, trapFocus: any): void;
|
4
4
|
export function traverseReverse(eachElem: any, index: any, allElements: any, rotate: any, trapFocus: any): void;
|
@@ -5,12 +5,41 @@
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
6
6
|
*/
|
7
7
|
|
8
|
-
var focusThisField = function focusThisField(
|
8
|
+
var focusThisField = function focusThisField(evt) {
|
9
9
|
setTimeout(function () {
|
10
|
-
var
|
11
|
-
(
|
12
|
-
(
|
10
|
+
var _evt$target$closest, _evt$target$closest2;
|
11
|
+
(_evt$target$closest = evt.target.closest('[role="gridcell"]')) === null || _evt$target$closest === void 0 || (_evt$target$closest = _evt$target$closest.querySelector('button')) === null || _evt$target$closest === void 0 || _evt$target$closest.click();
|
12
|
+
(_evt$target$closest2 = evt.target.closest('[role="gridcell"]')) === null || _evt$target$closest2 === void 0 || (_evt$target$closest2 = _evt$target$closest2.querySelector('button')) === null || _evt$target$closest2 === void 0 || _evt$target$closest2.focus();
|
13
13
|
}, 0);
|
14
14
|
};
|
15
|
+
var focusThisItem = function focusThisItem(currentElement) {
|
16
|
+
setTimeout(function () {
|
17
|
+
//document.activeElement.setAttribute('tabindex', '-1');
|
18
|
+
// currentElement.setAttribute('tabindex', '0');
|
19
|
+
currentElement === null || currentElement === void 0 || currentElement.focus();
|
20
|
+
}, 0);
|
21
|
+
};
|
22
|
+
var traverseClockVise = function traverseClockVise(eachElem, index, allElements, rotate, trapFocus) {
|
23
|
+
if (eachElem == document.activeElement) {
|
24
|
+
if (index !== allElements.length - 1) {
|
25
|
+
focusThisItem(allElements[index + 1]);
|
26
|
+
} else {
|
27
|
+
focusThisItem(allElements[rotate ? 0 : allElements.length - 1]);
|
28
|
+
}
|
29
|
+
} else if (Array.from(allElements).indexOf(document.activeElement) == -1 && trapFocus) {
|
30
|
+
focusThisItem(allElements[0]);
|
31
|
+
}
|
32
|
+
};
|
33
|
+
var traverseReverse = function traverseReverse(eachElem, index, allElements, rotate, trapFocus) {
|
34
|
+
if (eachElem == document.activeElement) {
|
35
|
+
if (index !== 0) {
|
36
|
+
focusThisItem(allElements[index - 1]);
|
37
|
+
} else {
|
38
|
+
focusThisItem(allElements[rotate ? allElements.length - 1 : 0]);
|
39
|
+
}
|
40
|
+
} else if (Array.from(allElements).indexOf(document.activeElement) == -1 && trapFocus) {
|
41
|
+
focusThisItem(allElements[allElements.length - 1]);
|
42
|
+
}
|
43
|
+
};
|
15
44
|
|
16
|
-
export { focusThisField };
|
45
|
+
export { focusThisField, focusThisItem, traverseClockVise, traverseReverse };
|
@@ -20,7 +20,7 @@ import { useInitialColumnSort } from '../useInitialColumnSort.js';
|
|
20
20
|
var _th;
|
21
21
|
var _excluded = ["role"],
|
22
22
|
_excluded2 = ["className", "role"],
|
23
|
-
_excluded3 = ["role"
|
23
|
+
_excluded3 = ["role"];
|
24
24
|
var blockClass = "".concat(pkg.prefix, "--datagrid");
|
25
25
|
var getAccessibilityProps = function getAccessibilityProps(header) {
|
26
26
|
var props = {};
|
@@ -176,11 +176,10 @@ var HeaderRow = function HeaderRow(datagridState, headRef, headerGroup) {
|
|
176
176
|
var originalCol = visibleColumns[index];
|
177
177
|
var _header$getHeaderProp = header.getHeaderProps();
|
178
178
|
_header$getHeaderProp.role;
|
179
|
-
var
|
180
|
-
headerProps = _objectWithoutProperties(_header$getHeaderProp, _excluded3);
|
179
|
+
var headerProps = _objectWithoutProperties(_header$getHeaderProp, _excluded3);
|
181
180
|
var resizerProps = header === null || header === void 0 || (_header$getResizerPro = header.getResizerProps) === null || _header$getResizerPro === void 0 ? void 0 : _header$getResizerPro.call(header);
|
182
181
|
return /*#__PURE__*/React__default.createElement(TableHeader, _extends({}, headerProps, {
|
183
|
-
className: cx(
|
182
|
+
className: cx(header.className, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, "".concat(blockClass, "__resizableColumn"), resizerProps), "".concat(blockClass, "__isResizing"), header.isResizing), "".concat(blockClass, "__sortableColumn"), datagridState.isTableSortable && header.id !== 'spacer'), "".concat(blockClass, "__isSorted"), header.isSorted), "".concat(blockClass, "__header-actions-column"), header.isAction), "".concat(blockClass, "__with-slug"), header.slug && /*#__PURE__*/React__default.isValidElement(header.slug))),
|
184
183
|
key: header.id,
|
185
184
|
"aria-hidden": header.id === 'spacer' && 'true'
|
186
185
|
}, getAccessibilityProps(header)), header.render('Header'), renderSlug(header.slug), resizerProps && !header.isAction && /*#__PURE__*/React__default.createElement(ResizeHeader, {
|