@carbon/ibm-products 2.43.2-canary.78 → 2.43.2-canary.81
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 +252 -58
- 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 +72 -20
- 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 +173 -44
- 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/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 +4 -10
- 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 +3 -1
- package/es/components/ConditionBuilder/ConditionBuilderContext/translationObject.js +4 -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 +52 -32
- package/es/components/ConditionBuilder/utils/handleKeyboardEvents.d.ts +1 -0
- package/es/components/ConditionBuilder/utils/handleKeyboardEvents.js +51 -44
- package/es/components/ConditionBuilder/utils/util.d.ts +6 -4
- package/es/components/ConditionBuilder/utils/util.js +35 -17
- package/es/components/Datagrid/Datagrid/addons/Filtering/hooks/useFilters.js +33 -1
- 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/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/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 +4 -10
- 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 +3 -1
- package/lib/components/ConditionBuilder/ConditionBuilderContext/translationObject.js +4 -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 +51 -31
- package/lib/components/ConditionBuilder/utils/handleKeyboardEvents.d.ts +1 -0
- package/lib/components/ConditionBuilder/utils/handleKeyboardEvents.js +50 -42
- package/lib/components/ConditionBuilder/utils/util.d.ts +6 -4
- package/lib/components/ConditionBuilder/utils/util.js +36 -16
- package/lib/components/Datagrid/Datagrid/addons/Filtering/hooks/useFilters.js +32 -0
- 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/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 +5 -5
- 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
@@ -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>;
|
@@ -12,7 +12,7 @@ import PropTypes from '../../../node_modules/prop-types/index.js';
|
|
12
12
|
import cx from 'classnames';
|
13
13
|
import { blockClass, statementConfig } from '../ConditionBuilderContext/DataConfigs.js';
|
14
14
|
import { ConditionBuilderItem } from '../ConditionBuilderItem/ConditionBuilderItem.js';
|
15
|
-
import { focusThisField } from '../utils/util.js';
|
15
|
+
import { focusThisField, manageTabIndexAndFocus } from '../utils/util.js';
|
16
16
|
import ConditionConnector from '../ConditionBuilderConnector/ConditionConnector.js';
|
17
17
|
import { ConditionBuilderContext } from '../ConditionBuilderContext/ConditionBuilderProvider.js';
|
18
18
|
import uuidv4 from '../../../global/js/utils/uuidv4.js';
|
@@ -33,14 +33,15 @@ var ConditionGroupBuilder = function ConditionGroupBuilder(_ref) {
|
|
33
33
|
aria = _ref.aria,
|
34
34
|
onRemove = _ref.onRemove,
|
35
35
|
onChange = _ref.onChange,
|
36
|
-
conditionBuilderRef = _ref.conditionBuilderRef,
|
37
36
|
className = _ref.className;
|
38
|
-
var _useTranslations = useTranslations(['
|
39
|
-
_useTranslations2 = _slicedToArray(_useTranslations,
|
37
|
+
var _useTranslations = useTranslations(['conditionBuilderGroupText', 'conditionText', 'conditionBuilderText']),
|
38
|
+
_useTranslations2 = _slicedToArray(_useTranslations, 3),
|
40
39
|
conditionBuilderGroupText = _useTranslations2[0],
|
41
|
-
conditionText = _useTranslations2[1]
|
40
|
+
conditionText = _useTranslations2[1],
|
41
|
+
conditionBuilderText = _useTranslations2[2];
|
42
42
|
var _useContext = useContext(ConditionBuilderContext),
|
43
|
-
variant = _useContext.variant
|
43
|
+
variant = _useContext.variant,
|
44
|
+
conditionBuilderRef = _useContext.conditionBuilderRef;
|
44
45
|
var _useState = useState(-1),
|
45
46
|
_useState2 = _slicedToArray(_useState, 2),
|
46
47
|
showConditionPreview = _useState2[0],
|
@@ -53,11 +54,40 @@ var ConditionGroupBuilder = function ConditionGroupBuilder(_ref) {
|
|
53
54
|
var onRemoveHandler = function onRemoveHandler(conditionId, evt, conditionIndex) {
|
54
55
|
if (group.conditions.length > 1) {
|
55
56
|
variant == 'tree' ? handleFocusOnCloseTree(evt) : handleFocusOnClose(evt, conditionIndex);
|
56
|
-
|
57
|
-
conditions
|
58
|
-
|
59
|
-
|
60
|
-
|
57
|
+
if (group.conditions[1].conditions) {
|
58
|
+
//when we remove every plain conditions of a group without deleting the subgroup, we need to restructure the group
|
59
|
+
//the inner group become outer group and same level subgroups become plain conditions
|
60
|
+
|
61
|
+
//spreading out the condition inside the subgroup
|
62
|
+
var allConditions = group.conditions.reduce(function (acc, item) {
|
63
|
+
if (item.conditions) {
|
64
|
+
return acc.concat(item.conditions);
|
65
|
+
}
|
66
|
+
return acc;
|
67
|
+
}, []);
|
68
|
+
|
69
|
+
//we always have conditions first and then subgroups, so ordering accordingly
|
70
|
+
var groupedItems = {
|
71
|
+
groups: [],
|
72
|
+
conditions: []
|
73
|
+
};
|
74
|
+
allConditions.forEach(function (item) {
|
75
|
+
if (item.conditions) {
|
76
|
+
groupedItems.groups.push(item);
|
77
|
+
} else {
|
78
|
+
groupedItems.conditions.push(item);
|
79
|
+
}
|
80
|
+
});
|
81
|
+
onChange(_objectSpread2(_objectSpread2({}, group), {}, {
|
82
|
+
conditions: [].concat(_toConsumableArray(groupedItems.conditions), _toConsumableArray(groupedItems.groups))
|
83
|
+
}));
|
84
|
+
} else {
|
85
|
+
onChange(_objectSpread2(_objectSpread2({}, group), {}, {
|
86
|
+
conditions: group.conditions.filter(function (condition) {
|
87
|
+
return conditionId !== condition.id;
|
88
|
+
})
|
89
|
+
}));
|
90
|
+
}
|
61
91
|
} else {
|
62
92
|
onRemove(evt);
|
63
93
|
}
|
@@ -87,11 +117,9 @@ var ConditionGroupBuilder = function ConditionGroupBuilder(_ref) {
|
|
87
117
|
//or focus the next one.
|
88
118
|
var currentGroupCloseButtons = (_e$currentTarget$clos = e.currentTarget.closest(".".concat(blockClass, "__group"))) === null || _e$currentTarget$clos === void 0 ? void 0 : _e$currentTarget$clos.querySelectorAll('[data-name="closeCondition"]');
|
89
119
|
if (conditionIndex == currentGroupCloseButtons.length - 1) {
|
90
|
-
|
91
|
-
(_currentGroupCloseBut = currentGroupCloseButtons[conditionIndex - 1]) === null || _currentGroupCloseBut === void 0 || _currentGroupCloseBut.focus();
|
120
|
+
manageTabIndexAndFocus(currentGroupCloseButtons[conditionIndex - 1], conditionBuilderRef);
|
92
121
|
} else {
|
93
|
-
|
94
|
-
(_currentGroupCloseBut2 = currentGroupCloseButtons[conditionIndex + 1]) === null || _currentGroupCloseBut2 === void 0 || _currentGroupCloseBut2.focus();
|
122
|
+
manageTabIndexAndFocus(currentGroupCloseButtons[conditionIndex + 1], conditionBuilderRef);
|
95
123
|
}
|
96
124
|
};
|
97
125
|
var handleFocusOnCloseTree = function handleFocusOnCloseTree(evt) {
|
@@ -107,11 +135,9 @@ var ConditionGroupBuilder = function ConditionGroupBuilder(_ref) {
|
|
107
135
|
//Otherwise , check the previous item is a valid condition
|
108
136
|
|
109
137
|
if (nextElement !== null && nextElement !== void 0 && nextElement.classList.contains("".concat(blockClass, "__condition-block"))) {
|
110
|
-
|
111
|
-
nextElement === null || nextElement === void 0 || (_nextElement$querySel = nextElement.querySelector('[data-name="closeCondition"]')) === null || _nextElement$querySel === void 0 || _nextElement$querySel.focus();
|
138
|
+
manageTabIndexAndFocus(nextElement === null || nextElement === void 0 ? void 0 : nextElement.querySelector('[data-name="closeCondition"]'), conditionBuilderRef);
|
112
139
|
} else if (prevElement !== null && prevElement !== void 0 && prevElement.classList.contains("".concat(blockClass, "__condition-block"))) {
|
113
|
-
|
114
|
-
prevElement === null || prevElement === void 0 || (_prevElement$querySel = prevElement.querySelector('[data-name="closeCondition"]')) === null || _prevElement$querySel === void 0 || _prevElement$querySel.focus();
|
140
|
+
manageTabIndexAndFocus(prevElement === null || prevElement === void 0 ? void 0 : prevElement.querySelector('[data-name="closeCondition"]'), conditionBuilderRef);
|
115
141
|
}
|
116
142
|
//If there are no valid condition in this group, focus next or previous row
|
117
143
|
else {
|
@@ -119,10 +145,10 @@ var ConditionGroupBuilder = function ConditionGroupBuilder(_ref) {
|
|
119
145
|
var prevRows = (_conditionBuilderCont3 = conditionBuilderContentRef.current) === null || _conditionBuilderCont3 === void 0 ? void 0 : _conditionBuilderCont3.querySelectorAll("[aria-level=\"".concat(Number(currentLevel) - 1, "\"][role=\"row\"]"));
|
120
146
|
var nextRow = (_conditionBuilderCont4 = conditionBuilderContentRef.current) === null || _conditionBuilderCont4 === void 0 ? void 0 : _conditionBuilderCont4.querySelector("[aria-level=\"".concat(Number(currentLevel) + 1, "\"][role=\"row\"]"));
|
121
147
|
if (nextRow) {
|
122
|
-
nextRow
|
148
|
+
manageTabIndexAndFocus(nextRow, conditionBuilderRef);
|
123
149
|
} else if ((prevRows === null || prevRows === void 0 ? void 0 : prevRows.length) > 1) {
|
124
|
-
|
125
|
-
(
|
150
|
+
// prevRows[prevRows.length - 2].setAttribute('tabindex', '0');
|
151
|
+
manageTabIndexAndFocus(prevRows[prevRows.length - 2], conditionBuilderRef);
|
126
152
|
}
|
127
153
|
}
|
128
154
|
};
|
@@ -179,7 +205,7 @@ var ConditionGroupBuilder = function ConditionGroupBuilder(_ref) {
|
|
179
205
|
}, /*#__PURE__*/React__default.createElement("div", {
|
180
206
|
className: "".concat(blockClass, "__condition-wrapper"),
|
181
207
|
role: "grid",
|
182
|
-
"aria-label":
|
208
|
+
"aria-label": conditionBuilderText
|
183
209
|
}, group === null || group === void 0 || (_group$conditions = group.conditions) === null || _group$conditions === void 0 ? void 0 : _group$conditions.map(function (eachCondition, conditionIndex) {
|
184
210
|
return /*#__PURE__*/React__default.createElement("div", {
|
185
211
|
key: eachCondition.id,
|
@@ -233,7 +259,7 @@ var ConditionGroupBuilder = function ConditionGroupBuilder(_ref) {
|
|
233
259
|
label: conditionText
|
234
260
|
},
|
235
261
|
onChange: function onChange(v, evt) {
|
236
|
-
focusThisField(evt);
|
262
|
+
focusThisField(evt, conditionBuilderRef);
|
237
263
|
onStatementChangeHandler(v);
|
238
264
|
},
|
239
265
|
config: {
|
@@ -245,7 +271,7 @@ var ConditionGroupBuilder = function ConditionGroupBuilder(_ref) {
|
|
245
271
|
}, eachCondition.conditions ? /*#__PURE__*/React__default.createElement("div", {
|
246
272
|
className: cx("".concat(blockClass, "__condition-block subgroup ").concat(blockClass, "__gap"), _defineProperty({}, "".concat(blockClass, "__gap-bottom"), group.conditions.length < conditionIndex + 1))
|
247
273
|
}, /*#__PURE__*/React__default.createElement(ConditionConnector, {
|
248
|
-
className: "".concat(blockClass, "__gap ").concat(blockClass, "__groupConnector"),
|
274
|
+
className: "".concat(blockClass, "__gap ").concat(blockClass, "__gap-bottom ").concat(blockClass, "__groupConnector"),
|
249
275
|
operator: group.groupOperator,
|
250
276
|
"aria-hidden": true
|
251
277
|
}), /*#__PURE__*/React__default.createElement(ConditionGroupBuilder, {
|
@@ -261,8 +287,7 @@ var ConditionGroupBuilder = function ConditionGroupBuilder(_ref) {
|
|
261
287
|
},
|
262
288
|
onRemove: function onRemove(e) {
|
263
289
|
onRemoveHandler(eachCondition.id, e);
|
264
|
-
}
|
265
|
-
conditionBuilderRef: conditionBuilderRef
|
290
|
+
}
|
266
291
|
})) : /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement(ConditionBlock, {
|
267
292
|
conjunction: conditionIndex > 0 ? group.groupOperator : undefined,
|
268
293
|
aria: {
|
@@ -317,11 +342,6 @@ ConditionGroupBuilder.propTypes = {
|
|
317
342
|
* Provide an optional class to be applied to the containing node.
|
318
343
|
*/
|
319
344
|
className: PropTypes.string,
|
320
|
-
/**
|
321
|
-
className: PropTypes.string,
|
322
|
-
* ref of condition builder
|
323
|
-
*/
|
324
|
-
conditionBuilderRef: PropTypes.object,
|
325
345
|
group: PropTypes.object,
|
326
346
|
/**
|
327
347
|
* callback to update the current condition of the state tree
|
@@ -7,25 +7,27 @@
|
|
7
7
|
|
8
8
|
import { toConsumableArray as _toConsumableArray } from '../../../_virtual/_rollupPluginBabelHelpers.js';
|
9
9
|
import { blockClass } from '../ConditionBuilderContext/DataConfigs.js';
|
10
|
-
import {
|
10
|
+
import { focusThisItem, manageTabIndexAndFocus, traverseClockVise, traverseReverse, checkForHoldingKey, focusThisField } from './util.js';
|
11
11
|
|
12
12
|
var handleKeyDown = function handleKeyDown(evt, conditionBuilderRef, variant) {
|
13
|
+
var _activeElement$closes;
|
13
14
|
var activeElement = document.activeElement;
|
15
|
+
if (!((_activeElement$closes = activeElement.closest(".".concat(blockClass, "__popover"))) !== null && _activeElement$closes !== void 0 && _activeElement$closes.querySelector('[role="dialog"]'))) {
|
16
|
+
handleKeyPressForMainContent(evt, conditionBuilderRef, variant);
|
17
|
+
}
|
18
|
+
};
|
19
|
+
var handleKeyDownForPopover = function handleKeyDownForPopover(evt, conditionBuilderRef, popoverRef) {
|
14
20
|
if (excludeKeyPress(evt)) {
|
15
21
|
return;
|
16
22
|
}
|
17
|
-
|
18
|
-
handleKeyPressForPopover(evt, activeElement.closest("[role=\"dialog\"]"));
|
19
|
-
} else {
|
20
|
-
handleKeyPressForMainContent(evt, conditionBuilderRef, variant);
|
21
|
-
}
|
23
|
+
handleKeyPressForPopover(evt, popoverRef === null || popoverRef === void 0 ? void 0 : popoverRef.current, conditionBuilderRef);
|
22
24
|
};
|
25
|
+
|
23
26
|
//skipping keyboard handling for date and time fields to get take carbon's
|
24
27
|
var excludeKeyPress = function excludeKeyPress(evt) {
|
25
|
-
|
26
|
-
return !['Escape'].includes(evt.key) && (((_evt$target$closest = evt.target.closest(".".concat(blockClass, "__item-date"))) === null || _evt$target$closest === void 0 ? void 0 : _evt$target$closest.length) || ((_evt$target$closest2 = evt.target.closest(".".concat(blockClass, "__item-time"))) === null || _evt$target$closest2 === void 0 ? void 0 : _evt$target$closest2.length));
|
28
|
+
return !['Escape'].includes(evt.key) && (evt.target.closest(".".concat(blockClass, "__item-date")) || evt.target.closest(".".concat(blockClass, "__item-time")));
|
27
29
|
};
|
28
|
-
var handleKeyPressForPopover = function handleKeyPressForPopover(evt, parentContainer) {
|
30
|
+
var handleKeyPressForPopover = function handleKeyPressForPopover(evt, parentContainer, conditionBuilderRef) {
|
29
31
|
var _parentContainer$quer;
|
30
32
|
var key = evt.key;
|
31
33
|
var isHoldingShiftKey = checkForHoldingKey(evt, 'shiftKey');
|
@@ -35,22 +37,22 @@ var handleKeyPressForPopover = function handleKeyPressForPopover(evt, parentCont
|
|
35
37
|
case 'ArrowUp':
|
36
38
|
//traverse through the popover options, search box, selectAll button
|
37
39
|
parentContainer.querySelectorAll("[role=\"option\"]").forEach(function (eachElem, index, allElements) {
|
38
|
-
traverseReverse(eachElem, index, allElements);
|
40
|
+
traverseReverse(eachElem, index, allElements, null, null, conditionBuilderRef);
|
39
41
|
});
|
40
42
|
break;
|
41
43
|
case 'ArrowDown':
|
42
44
|
//traverse through the popover options, search box, selectAll button
|
43
45
|
parentContainer.querySelectorAll("[role=\"option\"]").forEach(function (eachElem, index, allElements) {
|
44
|
-
traverseClockVise(eachElem, index, allElements);
|
46
|
+
traverseClockVise(eachElem, index, allElements, null, null, conditionBuilderRef);
|
45
47
|
});
|
46
48
|
break;
|
47
49
|
case 'Tab':
|
48
50
|
allItems = [].concat(_toConsumableArray(Array.from(parentContainer.querySelectorAll(".".concat(blockClass, "__selectAll-button,[role=\"searchbox\"]")))), [parentContainer.querySelector("[role=\"option\"]")]);
|
49
51
|
allItems.forEach(function (eachElem, index, allElements) {
|
50
52
|
if (isHoldingShiftKey) {
|
51
|
-
traverseReverse(eachElem, index, allElements, true, true);
|
53
|
+
traverseReverse(eachElem, index, allElements, true, true, conditionBuilderRef);
|
52
54
|
} else {
|
53
|
-
traverseClockVise(eachElem, index, allElements, true, true);
|
55
|
+
traverseClockVise(eachElem, index, allElements, true, true, conditionBuilderRef);
|
54
56
|
}
|
55
57
|
});
|
56
58
|
evt.preventDefault();
|
@@ -70,40 +72,41 @@ var handleKeyPressForPopover = function handleKeyPressForPopover(evt, parentCont
|
|
70
72
|
if (document.activeElement.type !== 'button') {
|
71
73
|
var _document$activeEleme2;
|
72
74
|
//for button , enter key is click which already handled by framework, else trigger click
|
73
|
-
focusThisField(evt);
|
75
|
+
focusThisField(evt, conditionBuilderRef);
|
74
76
|
(_document$activeEleme2 = document.activeElement) === null || _document$activeEleme2 === void 0 || _document$activeEleme2.click();
|
75
77
|
}
|
76
78
|
}
|
77
79
|
break;
|
78
80
|
case 'Escape':
|
79
|
-
//focus the corresponding field in which the popover is triggered
|
80
|
-
focusThisField(evt);
|
81
|
+
//focus the corresponding field in which the popover is triggered\
|
82
|
+
focusThisField(evt, conditionBuilderRef);
|
81
83
|
break;
|
82
84
|
}
|
83
85
|
};
|
84
86
|
var handleKeyPressForMainContent = function handleKeyPressForMainContent(evt, conditionBuilderRef, variant) {
|
87
|
+
var _document$activeEleme3;
|
85
88
|
switch (evt.key) {
|
86
89
|
case 'ArrowRight':
|
87
90
|
evt.preventDefault();
|
88
91
|
if (variant == 'tree') {
|
89
|
-
var _evt$target$
|
90
|
-
var allCellsInRow = Array.from((_evt$target$
|
91
|
-
if (
|
92
|
+
var _evt$target$closest;
|
93
|
+
var allCellsInRow = Array.from((_evt$target$closest = evt.target.closest('[role="row"]')) === null || _evt$target$closest === void 0 ? void 0 : _evt$target$closest.querySelectorAll('[role="gridcell"] button'));
|
94
|
+
if (allCellsInRow.length === 1) {
|
95
|
+
evt.target = evt.target.closest('[role="row"]');
|
96
|
+
handleRowNavigationTree(evt, conditionBuilderRef, variant);
|
97
|
+
//focus next row
|
98
|
+
} else if (evt.target.getAttribute('role') == 'row') {
|
92
99
|
//when current focus is on a row, then we need to enter inside and focus the first cell of that row
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
} else {
|
97
|
-
var _allCellsInRow$;
|
98
|
-
(_allCellsInRow$ = allCellsInRow[0]) === null || _allCellsInRow$ === void 0 || _allCellsInRow$.focus();
|
99
|
-
}
|
100
|
+
|
101
|
+
//focus first cell
|
102
|
+
manageTabIndexAndFocus(allCellsInRow[0], conditionBuilderRef);
|
100
103
|
} else {
|
101
104
|
//finding the next cell to be focussed
|
102
105
|
//next cell = current cell index + 1
|
103
106
|
|
104
107
|
var currentItemIndex = allCellsInRow.indexOf(evt.target);
|
105
108
|
if (currentItemIndex < allCellsInRow.length - 1) {
|
106
|
-
focusThisItem(allCellsInRow[currentItemIndex + 1]);
|
109
|
+
focusThisItem(allCellsInRow[currentItemIndex + 1], conditionBuilderRef);
|
107
110
|
}
|
108
111
|
}
|
109
112
|
} else {
|
@@ -114,17 +117,17 @@ var handleKeyPressForMainContent = function handleKeyPressForMainContent(evt, co
|
|
114
117
|
evt.preventDefault();
|
115
118
|
if (variant == 'tree') {
|
116
119
|
if (evt.target.getAttribute('role') !== 'row') {
|
117
|
-
var _evt$target$
|
120
|
+
var _evt$target$closest2;
|
118
121
|
//when any cell is focussed, arrow left will select the previous cell or current row
|
119
122
|
|
120
|
-
var
|
121
|
-
var _currentItemIndex =
|
123
|
+
var _allCellsInRow = Array.from((_evt$target$closest2 = evt.target.closest('[role="row"]')) === null || _evt$target$closest2 === void 0 ? void 0 : _evt$target$closest2.querySelectorAll('[role="gridcell"] button'));
|
124
|
+
var _currentItemIndex = _allCellsInRow.indexOf(evt.target);
|
122
125
|
if (_currentItemIndex > 0) {
|
123
|
-
focusThisItem(
|
126
|
+
focusThisItem(_allCellsInRow[_currentItemIndex - 1], conditionBuilderRef);
|
124
127
|
} else {
|
125
128
|
//focus the row
|
126
129
|
var wrapper = evt.target.closest("[role=\"row\"]");
|
127
|
-
wrapper
|
130
|
+
manageTabIndexAndFocus(wrapper, conditionBuilderRef);
|
128
131
|
}
|
129
132
|
}
|
130
133
|
} else {
|
@@ -140,6 +143,12 @@ var handleKeyPressForMainContent = function handleKeyPressForMainContent(evt, co
|
|
140
143
|
handleRowNavigation(evt, conditionBuilderRef, variant);
|
141
144
|
}
|
142
145
|
break;
|
146
|
+
case 'Enter':
|
147
|
+
if (((_document$activeEleme3 = document.activeElement) === null || _document$activeEleme3 === void 0 || (_document$activeEleme3 = _document$activeEleme3.querySelectorAll("button")) === null || _document$activeEleme3 === void 0 ? void 0 : _document$activeEleme3.length) === 1) {
|
148
|
+
var _document$activeEleme4;
|
149
|
+
(_document$activeEleme4 = document.activeElement) === null || _document$activeEleme4 === void 0 || (_document$activeEleme4 = _document$activeEleme4.querySelectorAll("button")[0]) === null || _document$activeEleme4 === void 0 || _document$activeEleme4.click();
|
150
|
+
}
|
151
|
+
break;
|
143
152
|
}
|
144
153
|
};
|
145
154
|
var getRows = function getRows(conditionBuilderRef) {
|
@@ -155,9 +164,9 @@ var getRowIndex = function getRowIndex(element, conditionBuilderRef) {
|
|
155
164
|
var handleRowNavigation = function handleRowNavigation(evt, conditionBuilderRef, variant) {
|
156
165
|
var rows = getRows(conditionBuilderRef);
|
157
166
|
var currentRowIndex = getRowIndex(evt.target, conditionBuilderRef);
|
158
|
-
navigateToNextRowCell(evt, currentRowIndex, rows, variant);
|
167
|
+
navigateToNextRowCell(evt, currentRowIndex, rows, variant, conditionBuilderRef);
|
159
168
|
};
|
160
|
-
function handleRowNavigationTree(evt, conditionBuilderRef, variant) {
|
169
|
+
var handleRowNavigationTree = function handleRowNavigationTree(evt, conditionBuilderRef, variant) {
|
161
170
|
var rows = getRows(conditionBuilderRef);
|
162
171
|
var currentRowIndex = getRowIndex(evt.target, conditionBuilderRef);
|
163
172
|
var nextRowIndex = currentRowIndex;
|
@@ -175,15 +184,13 @@ function handleRowNavigationTree(evt, conditionBuilderRef, variant) {
|
|
175
184
|
nextRowIndex = rows.length - 1;
|
176
185
|
}
|
177
186
|
if (nextRowIndex !== currentRowIndex) {
|
178
|
-
rows[
|
179
|
-
rows[nextRowIndex].setAttribute('tabindex', '0');
|
180
|
-
rows[nextRowIndex].focus();
|
187
|
+
manageTabIndexAndFocus(rows[nextRowIndex], conditionBuilderRef);
|
181
188
|
}
|
182
189
|
} else {
|
183
|
-
navigateToNextRowCell(evt, currentRowIndex, rows, variant);
|
190
|
+
navigateToNextRowCell(evt, currentRowIndex, rows, variant, conditionBuilderRef);
|
184
191
|
}
|
185
|
-
}
|
186
|
-
var navigateToNextRowCell = function navigateToNextRowCell(evt, currentRowIndex, rows, variant) {
|
192
|
+
};
|
193
|
+
var navigateToNextRowCell = function navigateToNextRowCell(evt, currentRowIndex, rows, variant, conditionBuilderRef) {
|
187
194
|
//when the current focussed element is a cell of any row, arrow up/down will focus the next row same cell.
|
188
195
|
|
189
196
|
var nextRowIndex = currentRowIndex;
|
@@ -200,17 +207,17 @@ var navigateToNextRowCell = function navigateToNextRowCell(evt, currentRowIndex,
|
|
200
207
|
nextRow === null || nextRow === void 0 || (_nextRow$querySelecto = nextRow.querySelector("[data-name=\"".concat(itemName, "\"]"))) === null || _nextRow$querySelecto === void 0 || _nextRow$querySelecto.focus();
|
201
208
|
} else if (variant === 'tree') {
|
202
209
|
//when the next row is a if statement , then that row is focused. From any cell of last row of an group , arrow down select the next row (if)
|
203
|
-
nextRow
|
210
|
+
manageTabIndexAndFocus(nextRow, conditionBuilderRef);
|
204
211
|
}
|
205
212
|
};
|
206
213
|
var handleCellNavigation = function handleCellNavigation(evt, conditionBuilderRef) {
|
207
214
|
conditionBuilderRef.current.querySelectorAll("[role=\"gridcell\"] button").forEach(function (eachElem, index, allElements) {
|
208
215
|
if (evt.key === 'ArrowRight') {
|
209
|
-
traverseClockVise(eachElem, index, allElements);
|
216
|
+
traverseClockVise(eachElem, index, allElements, null, null, conditionBuilderRef);
|
210
217
|
} else {
|
211
|
-
traverseReverse(eachElem, index, allElements);
|
218
|
+
traverseReverse(eachElem, index, allElements, null, null, conditionBuilderRef);
|
212
219
|
}
|
213
220
|
});
|
214
221
|
};
|
215
222
|
|
216
|
-
export { handleKeyDown };
|
223
|
+
export { handleKeyDown, handleKeyDownForPopover };
|
@@ -1,6 +1,8 @@
|
|
1
|
-
export function focusThisField(evt: any): void;
|
2
|
-
export function focusThisItem(currentElement: any): void;
|
3
|
-
export function traverseClockVise(eachElem: any, index: any, allElements: any, rotate: any, trapFocus: any): void;
|
4
|
-
export function traverseReverse(eachElem: any, index: any, allElements: any, rotate: any, trapFocus: any): void;
|
1
|
+
export function focusThisField(evt: any, conditionBuilderRef: any): void;
|
2
|
+
export function focusThisItem(currentElement: any, conditionBuilderRef: any): void;
|
3
|
+
export function traverseClockVise(eachElem: any, index: any, allElements: any, rotate: any, trapFocus: any, conditionBuilderRef: any): void;
|
4
|
+
export function traverseReverse(eachElem: any, index: any, allElements: any, rotate: any, trapFocus: any, conditionBuilderRef: any): void;
|
5
5
|
export function checkForHoldingKey(evt: any, key: any): any;
|
6
6
|
export function checkDuplicateAction(actionState: any, selectedId: any, currentActionId: any): boolean;
|
7
|
+
export function checkIsValid(item: any): any;
|
8
|
+
export function manageTabIndexAndFocus(currentElement: any, conditionBuilderRef: any): void;
|
@@ -5,40 +5,45 @@
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
6
6
|
*/
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
(
|
13
|
-
|
8
|
+
import { blockClass } from '../ConditionBuilderContext/DataConfigs.js';
|
9
|
+
|
10
|
+
var focusThisField = function focusThisField(evt, conditionBuilderRef) {
|
11
|
+
if (evt) {
|
12
|
+
setTimeout(function () {
|
13
|
+
var _evt$target$closest, _evt$target$closest2, _evt$target$closest3;
|
14
|
+
manageTabIndexAndFocus((_evt$target$closest = evt.target.closest('[role="gridcell"]')) === null || _evt$target$closest === void 0 ? void 0 : _evt$target$closest.querySelector('button'), conditionBuilderRef);
|
15
|
+
(_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.click();
|
16
|
+
(_evt$target$closest3 = evt.target.closest('[role="gridcell"]')) === null || _evt$target$closest3 === void 0 || (_evt$target$closest3 = _evt$target$closest3.querySelector('button')) === null || _evt$target$closest3 === void 0 || _evt$target$closest3.focus();
|
17
|
+
}, 0);
|
18
|
+
}
|
14
19
|
};
|
15
|
-
var focusThisItem = function focusThisItem(currentElement) {
|
20
|
+
var focusThisItem = function focusThisItem(currentElement, conditionBuilderRef) {
|
16
21
|
setTimeout(function () {
|
17
22
|
//document.activeElement.setAttribute('tabindex', '-1');
|
18
23
|
// currentElement.setAttribute('tabindex', '0');
|
19
|
-
currentElement
|
24
|
+
manageTabIndexAndFocus(currentElement, conditionBuilderRef);
|
20
25
|
}, 0);
|
21
26
|
};
|
22
|
-
var traverseClockVise = function traverseClockVise(eachElem, index, allElements, rotate, trapFocus) {
|
27
|
+
var traverseClockVise = function traverseClockVise(eachElem, index, allElements, rotate, trapFocus, conditionBuilderRef) {
|
23
28
|
if (eachElem == document.activeElement) {
|
24
29
|
if (index !== allElements.length - 1) {
|
25
|
-
focusThisItem(allElements[index + 1]);
|
30
|
+
focusThisItem(allElements[index + 1], conditionBuilderRef);
|
26
31
|
} else {
|
27
|
-
focusThisItem(allElements[rotate ? 0 : allElements.length - 1]);
|
32
|
+
focusThisItem(allElements[rotate ? 0 : allElements.length - 1], conditionBuilderRef);
|
28
33
|
}
|
29
34
|
} else if (Array.from(allElements).indexOf(document.activeElement) == -1 && trapFocus) {
|
30
|
-
focusThisItem(allElements[0]);
|
35
|
+
focusThisItem(allElements[0], conditionBuilderRef);
|
31
36
|
}
|
32
37
|
};
|
33
|
-
var traverseReverse = function traverseReverse(eachElem, index, allElements, rotate, trapFocus) {
|
38
|
+
var traverseReverse = function traverseReverse(eachElem, index, allElements, rotate, trapFocus, conditionBuilderRef) {
|
34
39
|
if (eachElem == document.activeElement) {
|
35
40
|
if (index !== 0) {
|
36
|
-
focusThisItem(allElements[index - 1]);
|
41
|
+
focusThisItem(allElements[index - 1], conditionBuilderRef);
|
37
42
|
} else {
|
38
|
-
focusThisItem(allElements[rotate ? allElements.length - 1 : 0]);
|
43
|
+
focusThisItem(allElements[rotate ? allElements.length - 1 : 0], conditionBuilderRef);
|
39
44
|
}
|
40
45
|
} else if (Array.from(allElements).indexOf(document.activeElement) == -1 && trapFocus) {
|
41
|
-
focusThisItem(allElements[allElements.length - 1]);
|
46
|
+
focusThisItem(allElements[allElements.length - 1], conditionBuilderRef);
|
42
47
|
}
|
43
48
|
};
|
44
49
|
var checkForHoldingKey = function checkForHoldingKey(evt, key) {
|
@@ -48,5 +53,18 @@ var checkForHoldingKey = function checkForHoldingKey(evt, key) {
|
|
48
53
|
}
|
49
54
|
return evt[key];
|
50
55
|
};
|
56
|
+
var checkIsValid = function checkIsValid(item) {
|
57
|
+
return item && item !== 'INVALID';
|
58
|
+
};
|
59
|
+
var manageTabIndexAndFocus = function manageTabIndexAndFocus(currentElement, conditionBuilderRef) {
|
60
|
+
var _currentElement$close, _conditionBuilderRef$;
|
61
|
+
var contentContainer = (_currentElement$close = currentElement === null || currentElement === void 0 ? void 0 : currentElement.closest(".".concat(blockClass, "__content-container"))) !== null && _currentElement$close !== void 0 ? _currentElement$close : currentElement === null || currentElement === void 0 ? void 0 : currentElement.closest(".".concat(blockClass, "__actions-container"));
|
62
|
+
contentContainer && Array.from(contentContainer.querySelectorAll('[tabindex="0"]')).map(function (element) {
|
63
|
+
return element === null || element === void 0 ? void 0 : element.setAttribute('tabindex', '-1');
|
64
|
+
});
|
65
|
+
currentElement === null || currentElement === void 0 || currentElement.setAttribute('tabindex', '0');
|
66
|
+
(_conditionBuilderRef$ = conditionBuilderRef.current) === null || _conditionBuilderRef$ === void 0 || (_conditionBuilderRef$ = _conditionBuilderRef$.querySelector(".".concat(blockClass, "__statement-button"))) === null || _conditionBuilderRef$ === void 0 || _conditionBuilderRef$.setAttribute('tabindex', '1');
|
67
|
+
currentElement === null || currentElement === void 0 || currentElement.focus();
|
68
|
+
};
|
51
69
|
|
52
|
-
export { checkForHoldingKey, focusThisField, focusThisItem, traverseClockVise, traverseReverse };
|
70
|
+
export { checkForHoldingKey, checkIsValid, focusThisField, focusThisItem, manageTabIndexAndFocus, traverseClockVise, traverseReverse };
|
@@ -5,7 +5,7 @@
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
6
6
|
*/
|
7
7
|
|
8
|
-
import { slicedToArray as _slicedToArray, extends as _extends, objectSpread2 as _objectSpread2, defineProperty as _defineProperty
|
8
|
+
import { slicedToArray as _slicedToArray, toConsumableArray as _toConsumableArray, extends as _extends, objectSpread2 as _objectSpread2, defineProperty as _defineProperty } from '../../../../../../_virtual/_rollupPluginBabelHelpers.js';
|
9
9
|
import { MULTISELECT, DROPDOWN, RADIO, CHECKBOX, NUMBER, DATE, BATCH, SAVED_FILTERS, INSTANT, PANEL } from '../constants.js';
|
10
10
|
import { MultiSelect, Dropdown, FormGroup, RadioButtonGroup, RadioButton, NumberInput, DatePicker, DatePickerInput, Layer, Checkbox } from '@carbon/react';
|
11
11
|
import React__default, { useContext, useState, useRef, useCallback, useEffect } from 'react';
|
@@ -13,6 +13,7 @@ import OverflowCheckboxes from '../OverflowCheckboxes.js';
|
|
13
13
|
import { getInitialStateFromFilters } from '../utils.js';
|
14
14
|
import { FilterContext } from '../FilterProvider.js';
|
15
15
|
import { handleCheckboxChange } from '../handleCheckboxChange.js';
|
16
|
+
import uuidv4 from '../../../../../../global/js/utils/uuidv4.js';
|
16
17
|
import { usePreviousValue } from '../../../../../../global/js/hooks/usePreviousValue.js';
|
17
18
|
|
18
19
|
var useFilters = function useFilters(_ref) {
|
@@ -47,6 +48,7 @@ var useFilters = function useFilters(_ref) {
|
|
47
48
|
var previousState = usePreviousValue({
|
48
49
|
panelOpen: panelOpen
|
49
50
|
});
|
51
|
+
var filteredItemsRef = useRef();
|
50
52
|
|
51
53
|
// When using batch actions we have to store the filters to then apply them later
|
52
54
|
var prevFiltersRef = useRef(JSON.stringify(filtersState));
|
@@ -307,8 +309,18 @@ var useFilters = function useFilters(_ref) {
|
|
307
309
|
}
|
308
310
|
return null;
|
309
311
|
}).filter(Boolean);
|
312
|
+
var isEqual = compareFilterItems(filteredItems);
|
313
|
+
if (!isEqual) {
|
314
|
+
filteredItemsRef.current = _toConsumableArray(filteredItems);
|
315
|
+
}
|
316
|
+
var getKey = function getKey() {
|
317
|
+
return isEqual ? {
|
318
|
+
key: uuidv4()
|
319
|
+
} : column;
|
320
|
+
};
|
310
321
|
filter = /*#__PURE__*/React__default.createElement(MultiSelect, _extends({}, components.MultiSelect, {
|
311
322
|
selectedItems: filteredItems,
|
323
|
+
key: getKey(),
|
312
324
|
onChange: function onChange(_ref9) {
|
313
325
|
var _components$MultiSele, _components$MultiSele2;
|
314
326
|
var selectedItems = _ref9.selectedItems;
|
@@ -324,6 +336,7 @@ var useFilters = function useFilters(_ref) {
|
|
324
336
|
}
|
325
337
|
return null;
|
326
338
|
}).filter(Boolean);
|
339
|
+
filteredItemsRef.current = _toConsumableArray(foundItems);
|
327
340
|
|
328
341
|
// Change selected state for those items that have been selected
|
329
342
|
allOptions.map(function (a) {
|
@@ -366,6 +379,25 @@ var useFilters = function useFilters(_ref) {
|
|
366
379
|
key: column
|
367
380
|
}, filter);
|
368
381
|
};
|
382
|
+
var compareFilterItems = function compareFilterItems(filteredItems) {
|
383
|
+
var _filteredItems$map, _filteredItemsRef$cur, _filteredItemsRef$cur2;
|
384
|
+
var filteredItemsId = (_filteredItems$map = filteredItems.map(function (item) {
|
385
|
+
return item.id;
|
386
|
+
})) !== null && _filteredItems$map !== void 0 ? _filteredItems$map : [];
|
387
|
+
var previousFilteredItemsId = (_filteredItemsRef$cur = filteredItemsRef === null || filteredItemsRef === void 0 || (_filteredItemsRef$cur2 = filteredItemsRef.current) === null || _filteredItemsRef$cur2 === void 0 ? void 0 : _filteredItemsRef$cur2.map(function (item) {
|
388
|
+
return item.id;
|
389
|
+
})) !== null && _filteredItemsRef$cur !== void 0 ? _filteredItemsRef$cur : [];
|
390
|
+
var set1 = new Set(filteredItemsId);
|
391
|
+
var set2 = new Set(previousFilteredItemsId);
|
392
|
+
// Check if the sets have the same size (same number of unique elements)
|
393
|
+
if (set1.size !== set2.size) {
|
394
|
+
return false;
|
395
|
+
}
|
396
|
+
// Check if all elements in set1 are also present in set2 (using spread syntax)
|
397
|
+
return _toConsumableArray(set1).every(function (element) {
|
398
|
+
return set2.has(element);
|
399
|
+
});
|
400
|
+
};
|
369
401
|
|
370
402
|
/** This useEffect will properly handle the previous filters when the panel closes
|
371
403
|
* 1. If the panel closes we need to call the reset fn but also store the
|
@@ -12,14 +12,15 @@ import cx from 'classnames';
|
|
12
12
|
import { getDevtoolsProps } from '../../global/js/utils/devtools.js';
|
13
13
|
import { pkg } from '../../settings.js';
|
14
14
|
import { DefinitionTooltip } from '@carbon/react';
|
15
|
-
import { StringFormatterAlignment } from './utils/enums.js';
|
15
|
+
import { StringFormatterAlignment, deprecated_StringFormatterAlignment, propMappingFunction } from './utils/enums.js';
|
16
|
+
import { allPropTypes } from '../../global/js/utils/props-helper.js';
|
16
17
|
|
17
18
|
var _excluded = ["className", "lines", "tooltipDirection", "truncate", "width", "value"];
|
18
19
|
var blockClass = "".concat(pkg.prefix, "--string-formatter");
|
19
20
|
var componentName = 'StringFormatter';
|
20
21
|
var defaults = {
|
21
22
|
lines: 1,
|
22
|
-
tooltipDirection: StringFormatterAlignment.
|
23
|
+
tooltipDirection: StringFormatterAlignment.BOTTOM_START,
|
23
24
|
truncate: false,
|
24
25
|
width: null
|
25
26
|
};
|
@@ -59,6 +60,16 @@ var StringFormatter = /*#__PURE__*/React__default.forwardRef(function (_ref, ref
|
|
59
60
|
});
|
60
61
|
StringFormatter = pkg.checkComponentEnabled(StringFormatter, componentName);
|
61
62
|
StringFormatter.displayName = componentName;
|
63
|
+
StringFormatter.validateAlignment = function () {
|
64
|
+
return function (props, propName, componentName) {
|
65
|
+
var prop = props[propName];
|
66
|
+
var deprecatedAlignValues = Object.values(deprecated_StringFormatterAlignment);
|
67
|
+
if (deprecatedAlignValues.includes(prop)) {
|
68
|
+
var mappedNewProp = propMappingFunction(prop);
|
69
|
+
console.warn("\"".concat(prop, "\" is a deprecated value for the \"").concat(propName, "\" prop on the \"").concat(componentName, "\" component. Use \"").concat(mappedNewProp, "\" instead. Allowable values are: ").concat(Object.values(StringFormatterAlignment).join(', '), "."));
|
70
|
+
}
|
71
|
+
};
|
72
|
+
};
|
62
73
|
StringFormatter.propTypes = {
|
63
74
|
/**
|
64
75
|
* Provide an optional class to be applied to the containing node.
|
@@ -67,7 +78,7 @@ StringFormatter.propTypes = {
|
|
67
78
|
/** Number of lines to clamp value. */
|
68
79
|
lines: PropTypes.number,
|
69
80
|
/** Specify the direction of the tooltip. Can be either top or bottom. */
|
70
|
-
tooltipDirection: PropTypes.oneOf(Object.values(StringFormatterAlignment)),
|
81
|
+
tooltipDirection: allPropTypes([StringFormatter.validateAlignment(), PropTypes.oneOf(Object.values(deprecated_StringFormatterAlignment), Object.values(StringFormatterAlignment))]),
|
71
82
|
/** Whether or not the value should be truncated. */
|
72
83
|
truncate: PropTypes.bool,
|
73
84
|
/** Value to format. */
|