colibri-ui 0.8.31 → 0.8.33

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/Avatar/index.js CHANGED
@@ -42,9 +42,12 @@ var Avatar = /*#__PURE__*/React.memo(function (props) {
42
42
  ref = props.ref,
43
43
  rest = tslib.__rest(props, ["src", "size", "className", "bordered", "alt", "accountType", "onClick", "initials", "loading", "ariaLabel", "ref"]);
44
44
  var stubSrc = getStubImage(accountType);
45
+ // Приоритет: переданное изображение (src) > инициалы > дефолтное изображение
46
+ var hasInitials = initials && initials.trim().length > 0;
47
+ var hasCustomImage = !!src;
48
+ // Показываем изображение если есть src ИЛИ (нет инициалов И есть дефолтное изображение)
49
+ var shouldShowImage = hasCustomImage || !hasInitials && stubSrc;
45
50
  var finalSrc = src || stubSrc;
46
- // Изображение показываем, если есть src ИЛИ есть дефолтное изображение
47
- var shouldShowImage = !!finalSrc && !initials;
48
51
  return shouldShowImage ? (
49
52
  /*#__PURE__*/
50
53
  // eslint-disable-next-line jsx-a11y/click-events-have-key-events
@@ -4,6 +4,7 @@ interface Props<T extends string> {
4
4
  value: T;
5
5
  label: React.ReactNode;
6
6
  selected: boolean;
7
+ disabled?: boolean;
7
8
  }[];
8
9
  onChange: (value: T) => void;
9
10
  }
@@ -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
@@ -31,9 +31,12 @@ var Avatar = /*#__PURE__*/memo(function (props) {
31
31
  ref = props.ref,
32
32
  rest = __rest(props, ["src", "size", "className", "bordered", "alt", "accountType", "onClick", "initials", "loading", "ariaLabel", "ref"]);
33
33
  var stubSrc = getStubImage(accountType);
34
+ // Приоритет: переданное изображение (src) > инициалы > дефолтное изображение
35
+ var hasInitials = initials && initials.trim().length > 0;
36
+ var hasCustomImage = !!src;
37
+ // Показываем изображение если есть src ИЛИ (нет инициалов И есть дефолтное изображение)
38
+ var shouldShowImage = hasCustomImage || !hasInitials && stubSrc;
34
39
  var finalSrc = src || stubSrc;
35
- // Изображение показываем, если есть src ИЛИ есть дефолтное изображение
36
- var shouldShowImage = !!finalSrc && !initials;
37
40
  return shouldShowImage ? (
38
41
  /*#__PURE__*/
39
42
  // eslint-disable-next-line jsx-a11y/click-events-have-key-events
@@ -4,6 +4,7 @@ interface Props<T extends string> {
4
4
  value: T;
5
5
  label: React.ReactNode;
6
6
  selected: boolean;
7
+ disabled?: boolean;
7
8
  }[];
8
9
  onChange: (value: T) => void;
9
10
  }
@@ -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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "colibri-ui",
3
- "version": "0.8.31",
3
+ "version": "0.8.33",
4
4
  "description": "React UI components library",
5
5
  "main": "index.js",
6
6
  "scripts": {},