carbon-react 125.2.2 → 125.4.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/esm/components/select/filterable-select/filterable-select.component.d.ts +3 -0
- package/esm/components/select/filterable-select/filterable-select.component.js +25 -20
- package/esm/components/select/option/option.component.d.ts +2 -0
- package/esm/components/select/option/option.component.js +6 -0
- package/esm/components/select/option/option.style.d.ts +1 -0
- package/esm/components/select/option/option.style.js +10 -0
- package/esm/components/select/option-row/option-row.component.d.ts +2 -0
- package/esm/components/select/option-row/option-row.component.js +7 -0
- package/esm/components/select/option-row/option-row.style.d.ts +1 -0
- package/esm/components/select/option-row/option-row.style.js +10 -0
- package/esm/components/select/select-list/select-list.component.js +4 -1
- package/lib/components/select/filterable-select/filterable-select.component.d.ts +3 -0
- package/lib/components/select/filterable-select/filterable-select.component.js +25 -20
- package/lib/components/select/option/option.component.d.ts +2 -0
- package/lib/components/select/option/option.component.js +6 -0
- package/lib/components/select/option/option.style.d.ts +1 -0
- package/lib/components/select/option/option.style.js +10 -0
- package/lib/components/select/option-row/option-row.component.d.ts +2 -0
- package/lib/components/select/option-row/option-row.component.js +7 -0
- package/lib/components/select/option-row/option-row.style.d.ts +1 -0
- package/lib/components/select/option-row/option-row.style.js +10 -0
- package/lib/components/select/select-list/select-list.component.js +4 -1
- package/package.json +1 -1
|
@@ -60,6 +60,9 @@ export interface FilterableSelectProps extends Omit<FormInputPropTypes, "default
|
|
|
60
60
|
* Higher values make for smoother scrolling but may impact performance.
|
|
61
61
|
* Only used if the `enableVirtualScroll` prop is set. */
|
|
62
62
|
virtualScrollOverscan?: number;
|
|
63
|
+
/** Boolean to disable automatic filtering and highlighting of options.
|
|
64
|
+
* This allows custom filtering and option styling to be performed outside of the component when the filter text changes. */
|
|
65
|
+
disableDefaultFiltering?: boolean;
|
|
63
66
|
}
|
|
64
67
|
export declare const FilterableSelect: React.ForwardRefExoticComponent<FilterableSelectProps & React.RefAttributes<unknown>>;
|
|
65
68
|
export default FilterableSelect;
|
|
@@ -54,6 +54,7 @@ const FilterableSelect = /*#__PURE__*/React.forwardRef(({
|
|
|
54
54
|
inputRef,
|
|
55
55
|
enableVirtualScroll,
|
|
56
56
|
virtualScrollOverscan,
|
|
57
|
+
disableDefaultFiltering = false,
|
|
57
58
|
...textboxProps
|
|
58
59
|
}, ref) => {
|
|
59
60
|
const [activeDescendantId, setActiveDescendantId] = useState();
|
|
@@ -120,7 +121,7 @@ const FilterableSelect = /*#__PURE__*/React.forwardRef(({
|
|
|
120
121
|
setSelectedValue(previousValue => {
|
|
121
122
|
const match = findElementWithMatchingText(newFilterText, children);
|
|
122
123
|
const isFilterCleared = isDeleteEvent && newFilterText === "";
|
|
123
|
-
if (!match || isFilterCleared) {
|
|
124
|
+
if (!match || isFilterCleared || match.props.disabled) {
|
|
124
125
|
setTextValue(newFilterText);
|
|
125
126
|
triggerChange("", false);
|
|
126
127
|
return "";
|
|
@@ -396,32 +397,35 @@ const FilterableSelect = /*#__PURE__*/React.forwardRef(({
|
|
|
396
397
|
...filterOutStyledSystemSpacingProps(textboxProps)
|
|
397
398
|
};
|
|
398
399
|
}
|
|
399
|
-
const
|
|
400
|
+
const selectListProps = {
|
|
400
401
|
ref: listboxRef,
|
|
401
402
|
id: selectListId.current,
|
|
402
|
-
labelId
|
|
403
|
+
labelId,
|
|
403
404
|
anchorElement: textboxRef?.parentElement || undefined,
|
|
404
405
|
onSelect: onSelectOption,
|
|
405
|
-
onSelectListClose
|
|
406
|
+
onSelectListClose,
|
|
406
407
|
onMouseDown: handleListMouseDown,
|
|
407
|
-
filterText
|
|
408
|
-
highlightedValue
|
|
409
|
-
noResultsMessage
|
|
410
|
-
disablePortal
|
|
411
|
-
listActionButton
|
|
412
|
-
listMaxHeight
|
|
408
|
+
filterText,
|
|
409
|
+
highlightedValue,
|
|
410
|
+
noResultsMessage,
|
|
411
|
+
disablePortal,
|
|
412
|
+
listActionButton,
|
|
413
|
+
listMaxHeight,
|
|
413
414
|
onListAction: handleOnListAction,
|
|
414
|
-
isLoading
|
|
415
|
-
onListScrollBottom
|
|
416
|
-
tableHeader
|
|
417
|
-
multiColumn
|
|
415
|
+
isLoading,
|
|
416
|
+
onListScrollBottom,
|
|
417
|
+
tableHeader,
|
|
418
|
+
multiColumn,
|
|
418
419
|
loaderDataRole: "filterable-select-list-loader",
|
|
419
|
-
listPlacement
|
|
420
|
-
flipEnabled
|
|
421
|
-
isOpen
|
|
422
|
-
enableVirtualScroll
|
|
423
|
-
virtualScrollOverscan
|
|
424
|
-
}
|
|
420
|
+
listPlacement,
|
|
421
|
+
flipEnabled,
|
|
422
|
+
isOpen,
|
|
423
|
+
enableVirtualScroll,
|
|
424
|
+
virtualScrollOverscan
|
|
425
|
+
};
|
|
426
|
+
const selectList = disableDefaultFiltering ? /*#__PURE__*/React.createElement(SelectList, selectListProps, children) : /*#__PURE__*/React.createElement(FilterableSelectList, _extends({}, selectListProps, {
|
|
427
|
+
filterText: filterText
|
|
428
|
+
}), children);
|
|
425
429
|
const marginProps = useFormSpacing(textboxProps);
|
|
426
430
|
return /*#__PURE__*/React.createElement(StyledSelect, _extends({
|
|
427
431
|
hasTextCursor: true,
|
|
@@ -529,6 +533,7 @@ FilterableSelect.propTypes = {
|
|
|
529
533
|
"deferTimeout": PropTypes.number,
|
|
530
534
|
"dir": PropTypes.string,
|
|
531
535
|
"disabled": PropTypes.bool,
|
|
536
|
+
"disableDefaultFiltering": PropTypes.bool,
|
|
532
537
|
"disablePortal": PropTypes.bool,
|
|
533
538
|
"draggable": PropTypes.oneOfType([PropTypes.oneOf(["false", "true"]), PropTypes.bool]),
|
|
534
539
|
"enableVirtualScroll": PropTypes.bool,
|
|
@@ -16,6 +16,8 @@ export interface OptionProps extends Omit<React.InputHTMLAttributes<HTMLLIElemen
|
|
|
16
16
|
borderColor?: string;
|
|
17
17
|
/** MultiSelect only - fill Pill background with color */
|
|
18
18
|
fill?: boolean;
|
|
19
|
+
/** If true, the component will be disabled */
|
|
20
|
+
disabled?: boolean;
|
|
19
21
|
/**
|
|
20
22
|
* @private
|
|
21
23
|
* @ignore
|
|
@@ -6,6 +6,7 @@ import SelectListContext from "../__internal__/select-list-context";
|
|
|
6
6
|
const Option = /*#__PURE__*/React.forwardRef(({
|
|
7
7
|
text,
|
|
8
8
|
children,
|
|
9
|
+
disabled,
|
|
9
10
|
onSelect,
|
|
10
11
|
value,
|
|
11
12
|
id,
|
|
@@ -21,6 +22,9 @@ const Option = /*#__PURE__*/React.forwardRef(({
|
|
|
21
22
|
isSelected = selectListContext.multiselectValues.includes(value);
|
|
22
23
|
}
|
|
23
24
|
function handleClick() {
|
|
25
|
+
if (disabled) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
24
28
|
if (!onClick) {
|
|
25
29
|
onSelect?.({
|
|
26
30
|
text,
|
|
@@ -36,7 +40,9 @@ const Option = /*#__PURE__*/React.forwardRef(({
|
|
|
36
40
|
id: id,
|
|
37
41
|
ref: ref,
|
|
38
42
|
"aria-selected": isSelected,
|
|
43
|
+
"aria-disabled": disabled,
|
|
39
44
|
"data-component": "option",
|
|
45
|
+
isDisabled: disabled,
|
|
40
46
|
onClick: handleClick,
|
|
41
47
|
isHighlighted: selectListContext.currentOptionsListIndex === index,
|
|
42
48
|
role: "option",
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { OptionProps } from ".";
|
|
2
2
|
interface StyledOptionProps extends Pick<OptionProps, "id"> {
|
|
3
3
|
isHighlighted?: boolean;
|
|
4
|
+
isDisabled?: boolean;
|
|
4
5
|
}
|
|
5
6
|
declare const StyledOption: import("styled-components").StyledComponent<"li", any, StyledOptionProps, never>;
|
|
6
7
|
export default StyledOption;
|
|
@@ -24,5 +24,15 @@ const StyledOption = styled.li`
|
|
|
24
24
|
:hover {
|
|
25
25
|
background-color: var(--colorsUtilityMajor100);
|
|
26
26
|
}
|
|
27
|
+
|
|
28
|
+
${({
|
|
29
|
+
isDisabled
|
|
30
|
+
}) => isDisabled && css`
|
|
31
|
+
color: var(--colorsUtilityYin030);
|
|
32
|
+
cursor: not-allowed;
|
|
33
|
+
:hover {
|
|
34
|
+
background-color: var(--colorsUtilityYang100);
|
|
35
|
+
}
|
|
36
|
+
`}
|
|
27
37
|
`;
|
|
28
38
|
export default StyledOption;
|
|
@@ -7,6 +7,7 @@ const OptionRow = /*#__PURE__*/React.forwardRef(({
|
|
|
7
7
|
id,
|
|
8
8
|
text,
|
|
9
9
|
children,
|
|
10
|
+
disabled,
|
|
10
11
|
onSelect,
|
|
11
12
|
value,
|
|
12
13
|
index,
|
|
@@ -15,6 +16,9 @@ const OptionRow = /*#__PURE__*/React.forwardRef(({
|
|
|
15
16
|
...rest
|
|
16
17
|
}, ref) => {
|
|
17
18
|
const handleClick = () => {
|
|
19
|
+
if (disabled) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
18
22
|
onSelect?.({
|
|
19
23
|
id,
|
|
20
24
|
text,
|
|
@@ -30,7 +34,9 @@ const OptionRow = /*#__PURE__*/React.forwardRef(({
|
|
|
30
34
|
id: id,
|
|
31
35
|
ref: ref,
|
|
32
36
|
"aria-selected": isSelected,
|
|
37
|
+
"aria-disabled": disabled,
|
|
33
38
|
"data-component": "option-row",
|
|
39
|
+
isDisabled: disabled,
|
|
34
40
|
onClick: handleClick,
|
|
35
41
|
isHighlighted: selectListContext.currentOptionsListIndex === index,
|
|
36
42
|
role: "option",
|
|
@@ -43,6 +49,7 @@ OptionRow.propTypes = {
|
|
|
43
49
|
"data-component": PropTypes.string,
|
|
44
50
|
"data-element": PropTypes.string,
|
|
45
51
|
"data-role": PropTypes.string,
|
|
52
|
+
"disabled": PropTypes.bool,
|
|
46
53
|
"hidden": PropTypes.bool,
|
|
47
54
|
"id": PropTypes.string,
|
|
48
55
|
"index": PropTypes.number,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { OptionRowProps } from ".";
|
|
2
2
|
interface StyledOptionRowProps extends Pick<OptionRowProps, "hidden"> {
|
|
3
3
|
isHighlighted?: boolean;
|
|
4
|
+
isDisabled?: boolean;
|
|
4
5
|
}
|
|
5
6
|
declare const StyledOptionRow: import("styled-components").StyledComponent<"tr", any, StyledOptionRowProps, never>;
|
|
6
7
|
export default StyledOptionRow;
|
|
@@ -28,5 +28,15 @@ const StyledOptionRow = styled.tr`
|
|
|
28
28
|
font-weight: 700;
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
|
+
|
|
32
|
+
${({
|
|
33
|
+
isDisabled
|
|
34
|
+
}) => isDisabled && css`
|
|
35
|
+
color: var(--colorsUtilityYin030);
|
|
36
|
+
cursor: not-allowed;
|
|
37
|
+
:hover {
|
|
38
|
+
background-color: var(--colorsUtilityYang100);
|
|
39
|
+
}
|
|
40
|
+
`}
|
|
31
41
|
`;
|
|
32
42
|
export default StyledOptionRow;
|
|
@@ -189,7 +189,7 @@ const SelectList = /*#__PURE__*/React.forwardRef(({
|
|
|
189
189
|
}
|
|
190
190
|
let nextIndex = getNextIndexByKey(key, indexOfHighlighted, lastIndex, isLoading);
|
|
191
191
|
const nextElement = childrenList[nextIndex];
|
|
192
|
-
if ( /*#__PURE__*/React.isValidElement(nextElement) && nextElement.type !== Option && nextElement.type !== OptionRow) {
|
|
192
|
+
if ( /*#__PURE__*/React.isValidElement(nextElement) && nextElement.type !== Option && nextElement.type !== OptionRow || nextElement.props.disabled) {
|
|
193
193
|
nextIndex = getNextHighlightableItemIndex(key, nextIndex);
|
|
194
194
|
}
|
|
195
195
|
return nextIndex;
|
|
@@ -254,6 +254,9 @@ const SelectList = /*#__PURE__*/React.forwardRef(({
|
|
|
254
254
|
onSelectListClose();
|
|
255
255
|
return;
|
|
256
256
|
}
|
|
257
|
+
if (currentOption.props.disabled) {
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
257
260
|
const {
|
|
258
261
|
text,
|
|
259
262
|
value
|
|
@@ -60,6 +60,9 @@ export interface FilterableSelectProps extends Omit<FormInputPropTypes, "default
|
|
|
60
60
|
* Higher values make for smoother scrolling but may impact performance.
|
|
61
61
|
* Only used if the `enableVirtualScroll` prop is set. */
|
|
62
62
|
virtualScrollOverscan?: number;
|
|
63
|
+
/** Boolean to disable automatic filtering and highlighting of options.
|
|
64
|
+
* This allows custom filtering and option styling to be performed outside of the component when the filter text changes. */
|
|
65
|
+
disableDefaultFiltering?: boolean;
|
|
63
66
|
}
|
|
64
67
|
export declare const FilterableSelect: React.ForwardRefExoticComponent<FilterableSelectProps & React.RefAttributes<unknown>>;
|
|
65
68
|
export default FilterableSelect;
|
|
@@ -63,6 +63,7 @@ const FilterableSelect = exports.FilterableSelect = /*#__PURE__*/_react.default.
|
|
|
63
63
|
inputRef,
|
|
64
64
|
enableVirtualScroll,
|
|
65
65
|
virtualScrollOverscan,
|
|
66
|
+
disableDefaultFiltering = false,
|
|
66
67
|
...textboxProps
|
|
67
68
|
}, ref) => {
|
|
68
69
|
const [activeDescendantId, setActiveDescendantId] = (0, _react.useState)();
|
|
@@ -129,7 +130,7 @@ const FilterableSelect = exports.FilterableSelect = /*#__PURE__*/_react.default.
|
|
|
129
130
|
setSelectedValue(previousValue => {
|
|
130
131
|
const match = findElementWithMatchingText(newFilterText, children);
|
|
131
132
|
const isFilterCleared = isDeleteEvent && newFilterText === "";
|
|
132
|
-
if (!match || isFilterCleared) {
|
|
133
|
+
if (!match || isFilterCleared || match.props.disabled) {
|
|
133
134
|
setTextValue(newFilterText);
|
|
134
135
|
triggerChange("", false);
|
|
135
136
|
return "";
|
|
@@ -405,32 +406,35 @@ const FilterableSelect = exports.FilterableSelect = /*#__PURE__*/_react.default.
|
|
|
405
406
|
...(0, _utils.filterOutStyledSystemSpacingProps)(textboxProps)
|
|
406
407
|
};
|
|
407
408
|
}
|
|
408
|
-
const
|
|
409
|
+
const selectListProps = {
|
|
409
410
|
ref: listboxRef,
|
|
410
411
|
id: selectListId.current,
|
|
411
|
-
labelId
|
|
412
|
+
labelId,
|
|
412
413
|
anchorElement: textboxRef?.parentElement || undefined,
|
|
413
414
|
onSelect: onSelectOption,
|
|
414
|
-
onSelectListClose
|
|
415
|
+
onSelectListClose,
|
|
415
416
|
onMouseDown: handleListMouseDown,
|
|
416
|
-
filterText
|
|
417
|
-
highlightedValue
|
|
418
|
-
noResultsMessage
|
|
419
|
-
disablePortal
|
|
420
|
-
listActionButton
|
|
421
|
-
listMaxHeight
|
|
417
|
+
filterText,
|
|
418
|
+
highlightedValue,
|
|
419
|
+
noResultsMessage,
|
|
420
|
+
disablePortal,
|
|
421
|
+
listActionButton,
|
|
422
|
+
listMaxHeight,
|
|
422
423
|
onListAction: handleOnListAction,
|
|
423
|
-
isLoading
|
|
424
|
-
onListScrollBottom
|
|
425
|
-
tableHeader
|
|
426
|
-
multiColumn
|
|
424
|
+
isLoading,
|
|
425
|
+
onListScrollBottom,
|
|
426
|
+
tableHeader,
|
|
427
|
+
multiColumn,
|
|
427
428
|
loaderDataRole: "filterable-select-list-loader",
|
|
428
|
-
listPlacement
|
|
429
|
-
flipEnabled
|
|
430
|
-
isOpen
|
|
431
|
-
enableVirtualScroll
|
|
432
|
-
virtualScrollOverscan
|
|
433
|
-
}
|
|
429
|
+
listPlacement,
|
|
430
|
+
flipEnabled,
|
|
431
|
+
isOpen,
|
|
432
|
+
enableVirtualScroll,
|
|
433
|
+
virtualScrollOverscan
|
|
434
|
+
};
|
|
435
|
+
const selectList = disableDefaultFiltering ? /*#__PURE__*/_react.default.createElement(_selectList.default, selectListProps, children) : /*#__PURE__*/_react.default.createElement(FilterableSelectList, _extends({}, selectListProps, {
|
|
436
|
+
filterText: filterText
|
|
437
|
+
}), children);
|
|
434
438
|
const marginProps = (0, _useFormSpacing.default)(textboxProps);
|
|
435
439
|
return /*#__PURE__*/_react.default.createElement(_select.default, _extends({
|
|
436
440
|
hasTextCursor: true,
|
|
@@ -538,6 +542,7 @@ FilterableSelect.propTypes = {
|
|
|
538
542
|
"deferTimeout": _propTypes.default.number,
|
|
539
543
|
"dir": _propTypes.default.string,
|
|
540
544
|
"disabled": _propTypes.default.bool,
|
|
545
|
+
"disableDefaultFiltering": _propTypes.default.bool,
|
|
541
546
|
"disablePortal": _propTypes.default.bool,
|
|
542
547
|
"draggable": _propTypes.default.oneOfType([_propTypes.default.oneOf(["false", "true"]), _propTypes.default.bool]),
|
|
543
548
|
"enableVirtualScroll": _propTypes.default.bool,
|
|
@@ -16,6 +16,8 @@ export interface OptionProps extends Omit<React.InputHTMLAttributes<HTMLLIElemen
|
|
|
16
16
|
borderColor?: string;
|
|
17
17
|
/** MultiSelect only - fill Pill background with color */
|
|
18
18
|
fill?: boolean;
|
|
19
|
+
/** If true, the component will be disabled */
|
|
20
|
+
disabled?: boolean;
|
|
19
21
|
/**
|
|
20
22
|
* @private
|
|
21
23
|
* @ignore
|
|
@@ -15,6 +15,7 @@ function _extends() { _extends = Object.assign ? Object.assign.bind() : function
|
|
|
15
15
|
const Option = /*#__PURE__*/_react.default.forwardRef(({
|
|
16
16
|
text,
|
|
17
17
|
children,
|
|
18
|
+
disabled,
|
|
18
19
|
onSelect,
|
|
19
20
|
value,
|
|
20
21
|
id,
|
|
@@ -30,6 +31,9 @@ const Option = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
30
31
|
isSelected = selectListContext.multiselectValues.includes(value);
|
|
31
32
|
}
|
|
32
33
|
function handleClick() {
|
|
34
|
+
if (disabled) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
33
37
|
if (!onClick) {
|
|
34
38
|
onSelect?.({
|
|
35
39
|
text,
|
|
@@ -45,7 +49,9 @@ const Option = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
45
49
|
id: id,
|
|
46
50
|
ref: ref,
|
|
47
51
|
"aria-selected": isSelected,
|
|
52
|
+
"aria-disabled": disabled,
|
|
48
53
|
"data-component": "option",
|
|
54
|
+
isDisabled: disabled,
|
|
49
55
|
onClick: handleClick,
|
|
50
56
|
isHighlighted: selectListContext.currentOptionsListIndex === index,
|
|
51
57
|
role: "option",
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { OptionProps } from ".";
|
|
2
2
|
interface StyledOptionProps extends Pick<OptionProps, "id"> {
|
|
3
3
|
isHighlighted?: boolean;
|
|
4
|
+
isDisabled?: boolean;
|
|
4
5
|
}
|
|
5
6
|
declare const StyledOption: import("styled-components").StyledComponent<"li", any, StyledOptionProps, never>;
|
|
6
7
|
export default StyledOption;
|
|
@@ -32,5 +32,15 @@ const StyledOption = _styledComponents.default.li`
|
|
|
32
32
|
:hover {
|
|
33
33
|
background-color: var(--colorsUtilityMajor100);
|
|
34
34
|
}
|
|
35
|
+
|
|
36
|
+
${({
|
|
37
|
+
isDisabled
|
|
38
|
+
}) => isDisabled && (0, _styledComponents.css)`
|
|
39
|
+
color: var(--colorsUtilityYin030);
|
|
40
|
+
cursor: not-allowed;
|
|
41
|
+
:hover {
|
|
42
|
+
background-color: var(--colorsUtilityYang100);
|
|
43
|
+
}
|
|
44
|
+
`}
|
|
35
45
|
`;
|
|
36
46
|
var _default = exports.default = StyledOption;
|
|
@@ -16,6 +16,7 @@ const OptionRow = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
16
16
|
id,
|
|
17
17
|
text,
|
|
18
18
|
children,
|
|
19
|
+
disabled,
|
|
19
20
|
onSelect,
|
|
20
21
|
value,
|
|
21
22
|
index,
|
|
@@ -24,6 +25,9 @@ const OptionRow = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
24
25
|
...rest
|
|
25
26
|
}, ref) => {
|
|
26
27
|
const handleClick = () => {
|
|
28
|
+
if (disabled) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
27
31
|
onSelect?.({
|
|
28
32
|
id,
|
|
29
33
|
text,
|
|
@@ -39,7 +43,9 @@ const OptionRow = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
39
43
|
id: id,
|
|
40
44
|
ref: ref,
|
|
41
45
|
"aria-selected": isSelected,
|
|
46
|
+
"aria-disabled": disabled,
|
|
42
47
|
"data-component": "option-row",
|
|
48
|
+
isDisabled: disabled,
|
|
43
49
|
onClick: handleClick,
|
|
44
50
|
isHighlighted: selectListContext.currentOptionsListIndex === index,
|
|
45
51
|
role: "option",
|
|
@@ -52,6 +58,7 @@ OptionRow.propTypes = {
|
|
|
52
58
|
"data-component": _propTypes.default.string,
|
|
53
59
|
"data-element": _propTypes.default.string,
|
|
54
60
|
"data-role": _propTypes.default.string,
|
|
61
|
+
"disabled": _propTypes.default.bool,
|
|
55
62
|
"hidden": _propTypes.default.bool,
|
|
56
63
|
"id": _propTypes.default.string,
|
|
57
64
|
"index": _propTypes.default.number,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { OptionRowProps } from ".";
|
|
2
2
|
interface StyledOptionRowProps extends Pick<OptionRowProps, "hidden"> {
|
|
3
3
|
isHighlighted?: boolean;
|
|
4
|
+
isDisabled?: boolean;
|
|
4
5
|
}
|
|
5
6
|
declare const StyledOptionRow: import("styled-components").StyledComponent<"tr", any, StyledOptionRowProps, never>;
|
|
6
7
|
export default StyledOptionRow;
|
|
@@ -36,5 +36,15 @@ const StyledOptionRow = _styledComponents.default.tr`
|
|
|
36
36
|
font-weight: 700;
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
+
|
|
40
|
+
${({
|
|
41
|
+
isDisabled
|
|
42
|
+
}) => isDisabled && (0, _styledComponents.css)`
|
|
43
|
+
color: var(--colorsUtilityYin030);
|
|
44
|
+
cursor: not-allowed;
|
|
45
|
+
:hover {
|
|
46
|
+
background-color: var(--colorsUtilityYang100);
|
|
47
|
+
}
|
|
48
|
+
`}
|
|
39
49
|
`;
|
|
40
50
|
var _default = exports.default = StyledOptionRow;
|
|
@@ -198,7 +198,7 @@ const SelectList = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
198
198
|
}
|
|
199
199
|
let nextIndex = (0, _getNextIndexByKey.default)(key, indexOfHighlighted, lastIndex, isLoading);
|
|
200
200
|
const nextElement = childrenList[nextIndex];
|
|
201
|
-
if ( /*#__PURE__*/_react.default.isValidElement(nextElement) && nextElement.type !== _option.default && nextElement.type !== _optionRow.default) {
|
|
201
|
+
if ( /*#__PURE__*/_react.default.isValidElement(nextElement) && nextElement.type !== _option.default && nextElement.type !== _optionRow.default || nextElement.props.disabled) {
|
|
202
202
|
nextIndex = getNextHighlightableItemIndex(key, nextIndex);
|
|
203
203
|
}
|
|
204
204
|
return nextIndex;
|
|
@@ -263,6 +263,9 @@ const SelectList = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
263
263
|
onSelectListClose();
|
|
264
264
|
return;
|
|
265
265
|
}
|
|
266
|
+
if (currentOption.props.disabled) {
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
266
269
|
const {
|
|
267
270
|
text,
|
|
268
271
|
value
|