colibri-ui 0.8.31 → 0.8.32
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/Select/components/MenuOverlay/index.d.ts +1 -0
- package/Select/components/MenuOverlay/index.js +3 -0
- package/Select/components/MenuOverlayItem/index.d.ts +3 -1
- package/Select/components/MenuOverlayItem/index.js +4 -2
- package/esm/Select/components/MenuOverlay/index.d.ts +1 -0
- package/esm/Select/components/MenuOverlay/index.js +3 -0
- package/esm/Select/components/MenuOverlayItem/index.d.ts +3 -1
- package/esm/Select/components/MenuOverlayItem/index.js +4 -2
- package/package.json +1 -1
|
@@ -55,9 +55,12 @@ var MenuOverlay = function MenuOverlay(_ref) {
|
|
|
55
55
|
ref: listRef,
|
|
56
56
|
selected: selected
|
|
57
57
|
}, options.map(function (option, index) {
|
|
58
|
+
var _a;
|
|
58
59
|
return /*#__PURE__*/React__default.default.createElement(index$1.default, {
|
|
59
60
|
setScrollView: setScrollView,
|
|
60
61
|
option: option,
|
|
62
|
+
isDisabled: (option === null || option === void 0 ? void 0 : option.disabled) || false,
|
|
63
|
+
isPrevDisabled: options[index - 1] ? (_a = options[index - 1]) === null || _a === void 0 ? void 0 : _a.disabled : false,
|
|
61
64
|
key: index,
|
|
62
65
|
onClick: function onClick() {
|
|
63
66
|
return handleSelect(option, "item-".concat(index));
|
|
@@ -9,6 +9,8 @@ type SelectItemProps = {
|
|
|
9
9
|
};
|
|
10
10
|
onClick?: () => void;
|
|
11
11
|
setScrollView: (value: Coordinates) => void;
|
|
12
|
+
isPrevDisabled?: boolean;
|
|
13
|
+
isDisabled?: boolean;
|
|
12
14
|
};
|
|
13
|
-
declare const SelectItem: ({ option, onClick, setScrollView }: SelectItemProps) => React.JSX.Element;
|
|
15
|
+
declare const SelectItem: ({ option, onClick, setScrollView, isPrevDisabled, isDisabled, }: SelectItemProps) => React.JSX.Element;
|
|
14
16
|
export default SelectItem;
|
|
@@ -13,7 +13,9 @@ var React__default = /*#__PURE__*/_interopDefault(React);
|
|
|
13
13
|
var SelectItem = function SelectItem(_ref) {
|
|
14
14
|
var option = _ref.option,
|
|
15
15
|
onClick = _ref.onClick,
|
|
16
|
-
setScrollView = _ref.setScrollView
|
|
16
|
+
setScrollView = _ref.setScrollView,
|
|
17
|
+
isPrevDisabled = _ref.isPrevDisabled,
|
|
18
|
+
isDisabled = _ref.isDisabled;
|
|
17
19
|
var ref = React.useRef(null);
|
|
18
20
|
function scrollToItem() {
|
|
19
21
|
if (!ref.current) {
|
|
@@ -28,7 +30,7 @@ var SelectItem = function SelectItem(_ref) {
|
|
|
28
30
|
});
|
|
29
31
|
}
|
|
30
32
|
React.useLayoutEffect(function () {
|
|
31
|
-
if (option.selected) {
|
|
33
|
+
if (option.selected || isPrevDisabled && !isDisabled) {
|
|
32
34
|
scrollToItem();
|
|
33
35
|
}
|
|
34
36
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -44,9 +44,12 @@ var MenuOverlay = function MenuOverlay(_ref) {
|
|
|
44
44
|
ref: listRef,
|
|
45
45
|
selected: selected
|
|
46
46
|
}, options.map(function (option, index) {
|
|
47
|
+
var _a;
|
|
47
48
|
return /*#__PURE__*/React__default.createElement(SelectItem, {
|
|
48
49
|
setScrollView: setScrollView,
|
|
49
50
|
option: option,
|
|
51
|
+
isDisabled: (option === null || option === void 0 ? void 0 : option.disabled) || false,
|
|
52
|
+
isPrevDisabled: options[index - 1] ? (_a = options[index - 1]) === null || _a === void 0 ? void 0 : _a.disabled : false,
|
|
50
53
|
key: index,
|
|
51
54
|
onClick: function onClick() {
|
|
52
55
|
return handleSelect(option, "item-".concat(index));
|
|
@@ -9,6 +9,8 @@ type SelectItemProps = {
|
|
|
9
9
|
};
|
|
10
10
|
onClick?: () => void;
|
|
11
11
|
setScrollView: (value: Coordinates) => void;
|
|
12
|
+
isPrevDisabled?: boolean;
|
|
13
|
+
isDisabled?: boolean;
|
|
12
14
|
};
|
|
13
|
-
declare const SelectItem: ({ option, onClick, setScrollView }: SelectItemProps) => React.JSX.Element;
|
|
15
|
+
declare const SelectItem: ({ option, onClick, setScrollView, isPrevDisabled, isDisabled, }: SelectItemProps) => React.JSX.Element;
|
|
14
16
|
export default SelectItem;
|
|
@@ -5,7 +5,9 @@ import Check from '../../../Icons/Check.js';
|
|
|
5
5
|
var SelectItem = function SelectItem(_ref) {
|
|
6
6
|
var option = _ref.option,
|
|
7
7
|
onClick = _ref.onClick,
|
|
8
|
-
setScrollView = _ref.setScrollView
|
|
8
|
+
setScrollView = _ref.setScrollView,
|
|
9
|
+
isPrevDisabled = _ref.isPrevDisabled,
|
|
10
|
+
isDisabled = _ref.isDisabled;
|
|
9
11
|
var ref = useRef(null);
|
|
10
12
|
function scrollToItem() {
|
|
11
13
|
if (!ref.current) {
|
|
@@ -20,7 +22,7 @@ var SelectItem = function SelectItem(_ref) {
|
|
|
20
22
|
});
|
|
21
23
|
}
|
|
22
24
|
useLayoutEffect(function () {
|
|
23
|
-
if (option.selected) {
|
|
25
|
+
if (option.selected || isPrevDisabled && !isDisabled) {
|
|
24
26
|
scrollToItem();
|
|
25
27
|
}
|
|
26
28
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|