carbon-react 104.10.1 → 104.12.1
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/lib/components/flat-table/flat-table-body-draggable/flat-table-body-draggable.component.js +3 -0
- package/lib/components/navigation-bar/navigation-bar.style.js +10 -9
- package/lib/components/pager/pager.style.js +3 -1
- package/lib/components/search/search.style.js +31 -40
- package/lib/components/select/__internal__/select-list-context.d.ts +3 -0
- package/lib/components/select/__internal__/select-list-context.js +15 -0
- package/lib/components/select/__internal__/select-text/select-text.component.d.ts +30 -0
- package/lib/components/select/__internal__/select-text/select-text.component.js +111 -0
- package/lib/components/select/__internal__/select-text/select-text.d.ts +34 -0
- package/lib/components/select/__internal__/select-text/select-text.style.d.ts +2 -0
- package/lib/components/select/__internal__/select-text/select-text.style.js +65 -0
- package/lib/components/select/filterable-select/filterable-select.component.js +7 -4
- package/lib/components/select/multi-select/multi-select.component.js +23 -7
- package/lib/components/select/multi-select/multi-select.style.d.ts +1 -0
- package/lib/components/select/multi-select/multi-select.style.js +5 -1
- package/lib/components/select/option/option.component.js +32 -8
- package/lib/components/select/option-row/option-row.component.js +23 -6
- package/lib/components/select/select-list/select-list.component.js +36 -23
- package/lib/components/select/select-textbox/select-textbox.component.d.ts +113 -26
- package/lib/components/select/select-textbox/select-textbox.component.js +82 -3
- package/lib/components/select/select-textbox/select-textbox.d.ts +8 -2
- package/lib/components/select/select.style.js +10 -7
- package/lib/components/select/simple-select/simple-select.component.js +13 -20
- package/package.json +1 -1
|
@@ -76,6 +76,7 @@ const SimpleSelect = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
76
76
|
const filterText = (0, _react.useRef)();
|
|
77
77
|
const [textboxRef, setTextboxRef] = (0, _react.useState)();
|
|
78
78
|
const [isOpen, setOpenState] = (0, _react.useState)(false);
|
|
79
|
+
const [activeDescendantId, setActiveDescendantId] = (0, _react.useState)();
|
|
79
80
|
const [textValue, setTextValue] = (0, _react.useState)("");
|
|
80
81
|
const [selectedValue, setSelectedValue] = (0, _react.useState)(value || defaultValue || "");
|
|
81
82
|
const childOptions = (0, _react.useMemo)(() => _react.default.Children.toArray(children), [children]);
|
|
@@ -113,15 +114,7 @@ const SimpleSelect = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
113
114
|
return match.props.value;
|
|
114
115
|
});
|
|
115
116
|
}, [childOptions, createCustomEvent, onChange]);
|
|
116
|
-
const
|
|
117
|
-
const newValue = event.target.value;
|
|
118
|
-
const newCharacter = newValue.slice(-1);
|
|
119
|
-
const isDeleteEvent = event.nativeEvent.inputType === "deleteContentBackward" || event.nativeEvent.inputType === "deleteContentForward" || event.nativeEvent.inputType === "delete";
|
|
120
|
-
|
|
121
|
-
if (isDeleteEvent) {
|
|
122
|
-
return;
|
|
123
|
-
}
|
|
124
|
-
|
|
117
|
+
const triggerFilterChange = (0, _react.useCallback)(newCharacter => {
|
|
125
118
|
if (isTimerCounting.current) {
|
|
126
119
|
const newVal = filterText.current + newCharacter;
|
|
127
120
|
filterText.current = newVal;
|
|
@@ -161,8 +154,10 @@ const SimpleSelect = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
161
154
|
|
|
162
155
|
return true;
|
|
163
156
|
});
|
|
157
|
+
} else if (key.length === 1) {
|
|
158
|
+
triggerFilterChange(key);
|
|
164
159
|
}
|
|
165
|
-
}, [onKeyDown, onOpen, readOnly]);
|
|
160
|
+
}, [triggerFilterChange, onKeyDown, onOpen, readOnly]);
|
|
166
161
|
const handleGlobalClick = (0, _react.useCallback)(event => {
|
|
167
162
|
const notInContainer = containerRef.current && !containerRef.current.contains(event.target);
|
|
168
163
|
const notInList = listboxRef.current && !listboxRef.current.contains(event.target);
|
|
@@ -170,7 +165,6 @@ const SimpleSelect = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
170
165
|
|
|
171
166
|
if (notInContainer && notInList && !isClickTriggeredBySelect.current) {
|
|
172
167
|
setOpenState(false);
|
|
173
|
-
filterText.current = "";
|
|
174
168
|
}
|
|
175
169
|
|
|
176
170
|
isClickTriggeredBySelect.current = false;
|
|
@@ -283,14 +277,15 @@ const SimpleSelect = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
283
277
|
const {
|
|
284
278
|
text,
|
|
285
279
|
value: newValue,
|
|
286
|
-
selectionType
|
|
280
|
+
selectionType,
|
|
281
|
+
id: selectedOptionId
|
|
287
282
|
} = optionData;
|
|
288
283
|
const isClickTriggered = selectionType === "click";
|
|
289
284
|
updateValue(newValue, text);
|
|
285
|
+
setActiveDescendantId(selectedOptionId);
|
|
290
286
|
|
|
291
287
|
if (selectionType !== "navigationKey") {
|
|
292
288
|
setOpenState(false);
|
|
293
|
-
filterText.current = text;
|
|
294
289
|
}
|
|
295
290
|
|
|
296
291
|
if (isClickTriggered) {
|
|
@@ -312,7 +307,6 @@ const SimpleSelect = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
312
307
|
|
|
313
308
|
function onSelectListClose() {
|
|
314
309
|
setOpenState(false);
|
|
315
|
-
filterText.current = "";
|
|
316
310
|
}
|
|
317
311
|
|
|
318
312
|
function isNavigationKey(key) {
|
|
@@ -341,9 +335,9 @@ const SimpleSelect = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
341
335
|
onMouseDown: handleTextboxMouseDown,
|
|
342
336
|
onFocus: handleTextboxFocus,
|
|
343
337
|
onKeyDown: handleTextboxKeydown,
|
|
344
|
-
onChange: handleTextboxChange,
|
|
345
338
|
onBlur: handleTextboxBlur,
|
|
346
339
|
tooltipPosition,
|
|
340
|
+
transparent,
|
|
347
341
|
...(0, _utils.filterOutStyledSystemSpacingProps)(props)
|
|
348
342
|
};
|
|
349
343
|
}
|
|
@@ -371,16 +365,15 @@ const SimpleSelect = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
371
365
|
transparent: transparent,
|
|
372
366
|
disabled: disabled,
|
|
373
367
|
readOnly: readOnly,
|
|
374
|
-
"aria-expanded": isOpen,
|
|
375
|
-
"aria-haspopup": "listbox",
|
|
376
368
|
ref: containerRef,
|
|
377
369
|
"data-component": dataComponent,
|
|
378
370
|
"data-role": dataRole,
|
|
379
371
|
"data-element": dataElement
|
|
380
372
|
}, (0, _utils.filterStyledSystemMarginProps)(props)), /*#__PURE__*/_react.default.createElement(_selectTextbox.default, _extends({
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
373
|
+
isOpen: isOpen,
|
|
374
|
+
labelId: labelId.current,
|
|
375
|
+
activeDescendantId: activeDescendantId,
|
|
376
|
+
"aria-controls": isOpen ? selectListId.current : undefined
|
|
384
377
|
}, getTextboxProps(), {
|
|
385
378
|
positionedChildren: disablePortal && isOpen && selectList
|
|
386
379
|
})), !disablePortal && isOpen && selectList);
|