@astral/ui 4.106.0 → 4.108.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.
Files changed (137) hide show
  1. package/components/AsyncAutocomplete/useLogic/useLogic.d.ts +1 -0
  2. package/components/Autocomplete/Autocomplete.d.ts +1 -0
  3. package/components/Autocomplete/Autocomplete.js +12 -8
  4. package/components/Autocomplete/constants.d.ts +1 -0
  5. package/components/Autocomplete/constants.js +1 -0
  6. package/components/Autocomplete/styles.d.ts +4 -0
  7. package/components/Autocomplete/styles.js +9 -0
  8. package/components/Autocomplete/types.d.ts +4 -0
  9. package/components/Autocomplete/useLogic/useLogic.d.ts +11 -4
  10. package/components/Autocomplete/useLogic/useLogic.js +77 -11
  11. package/components/Autocomplete/useLogic/utils/checkIsFocusedHelperChange/checkIsFocusedHelperChange.d.ts +4 -0
  12. package/components/Autocomplete/useLogic/utils/checkIsFocusedHelperChange/checkIsFocusedHelperChange.js +17 -0
  13. package/components/Autocomplete/useLogic/utils/checkIsFocusedHelperChange/index.d.ts +1 -0
  14. package/components/Autocomplete/useLogic/utils/checkIsFocusedHelperChange/index.js +1 -0
  15. package/components/Autocomplete/useLogic/utils/checkIsPopperVisible/checkIsPopperVisible.d.ts +8 -0
  16. package/components/Autocomplete/useLogic/utils/checkIsPopperVisible/checkIsPopperVisible.js +6 -0
  17. package/components/Autocomplete/useLogic/utils/checkIsPopperVisible/index.d.ts +1 -0
  18. package/components/Autocomplete/useLogic/utils/checkIsPopperVisible/index.js +1 -0
  19. package/components/Autocomplete/useLogic/utils/index.d.ts +2 -0
  20. package/components/Autocomplete/useLogic/utils/index.js +2 -0
  21. package/components/Autocomplete/utils/checkIsFocusedHelperOption/checkIsFocusedHelperOption.d.ts +5 -0
  22. package/components/Autocomplete/utils/checkIsFocusedHelperOption/checkIsFocusedHelperOption.js +7 -0
  23. package/components/Autocomplete/utils/checkIsFocusedHelperOption/index.d.ts +1 -0
  24. package/components/Autocomplete/utils/checkIsFocusedHelperOption/index.js +1 -0
  25. package/components/Autocomplete/utils/index.d.ts +1 -0
  26. package/components/Autocomplete/utils/index.js +1 -0
  27. package/components/Onboarding/ui/StepStrategy/steps/HighlightStep/styles.d.ts +1 -1
  28. package/components/Select/Select.js +4 -3
  29. package/components/Select/useLogic/useLogic.d.ts +11 -2
  30. package/components/Select/useLogic/useLogic.js +4 -1
  31. package/components/TagsList/PopoverTags/PopoverTags.d.ts +7 -0
  32. package/components/TagsList/PopoverTags/PopoverTags.js +8 -0
  33. package/components/TagsList/PopoverTags/index.d.ts +2 -0
  34. package/components/TagsList/PopoverTags/index.js +2 -0
  35. package/components/TagsList/PopoverTags/styles.d.ts +8 -0
  36. package/components/TagsList/PopoverTags/styles.js +15 -0
  37. package/components/TagsList/PopoverTags/types.d.ts +24 -0
  38. package/components/TagsList/PopoverTags/types.js +1 -0
  39. package/components/TagsList/Tag/Tag.d.ts +9 -1
  40. package/components/TagsList/Tag/Tag.js +4 -3
  41. package/components/TagsList/TagsList.js +11 -5
  42. package/components/TagsList/constants.d.ts +35 -0
  43. package/components/TagsList/constants.js +35 -0
  44. package/components/TagsList/styles.d.ts +9 -1
  45. package/components/TagsList/styles.js +20 -1
  46. package/components/TagsList/types.d.ts +4 -0
  47. package/components/TagsList/useLogic/hooks/index.d.ts +1 -0
  48. package/components/TagsList/useLogic/hooks/index.js +1 -0
  49. package/components/TagsList/useLogic/hooks/useHoverDelay/index.d.ts +1 -0
  50. package/components/TagsList/useLogic/hooks/useHoverDelay/index.js +1 -0
  51. package/components/TagsList/useLogic/hooks/useHoverDelay/types.d.ts +20 -0
  52. package/components/TagsList/useLogic/hooks/useHoverDelay/types.js +1 -0
  53. package/components/TagsList/useLogic/hooks/useHoverDelay/useHoverDelay.d.ts +5 -0
  54. package/components/TagsList/useLogic/hooks/useHoverDelay/useHoverDelay.js +27 -0
  55. package/components/TagsList/useLogic/useLogic.d.ts +14 -2
  56. package/components/TagsList/useLogic/useLogic.js +84 -4
  57. package/components/TagsList/utils/calculatePopoverWidth/calculatePopoverWidth.d.ts +5 -0
  58. package/components/TagsList/utils/calculatePopoverWidth/calculatePopoverWidth.js +22 -0
  59. package/components/TagsList/utils/calculatePopoverWidth/index.d.ts +1 -0
  60. package/components/TagsList/utils/calculatePopoverWidth/index.js +1 -0
  61. package/components/TagsList/utils/index.d.ts +1 -0
  62. package/components/TagsList/utils/index.js +1 -0
  63. package/components/TreeLikeAsyncAutocomplete/Input/Input.js +3 -2
  64. package/components/TreeLikeAsyncAutocomplete/Input/useLogic/useLogic.d.ts +3 -2
  65. package/components/TreeLikeAsyncAutocomplete/Input/useLogic/useLogic.js +3 -1
  66. package/components/TreeLikeAutocomplete/Input/Input.js +2 -2
  67. package/components/TreeLikeAutocomplete/Input/useLogic/useLogic.d.ts +2 -1
  68. package/components/TreeLikeAutocomplete/Input/useLogic/useLogic.js +3 -1
  69. package/node/components/AsyncAutocomplete/useLogic/useLogic.d.ts +1 -0
  70. package/node/components/Autocomplete/Autocomplete.d.ts +1 -0
  71. package/node/components/Autocomplete/Autocomplete.js +11 -7
  72. package/node/components/Autocomplete/constants.d.ts +1 -0
  73. package/node/components/Autocomplete/constants.js +2 -1
  74. package/node/components/Autocomplete/styles.d.ts +4 -0
  75. package/node/components/Autocomplete/styles.js +10 -1
  76. package/node/components/Autocomplete/types.d.ts +4 -0
  77. package/node/components/Autocomplete/useLogic/useLogic.d.ts +11 -4
  78. package/node/components/Autocomplete/useLogic/useLogic.js +77 -11
  79. package/node/components/Autocomplete/useLogic/utils/checkIsFocusedHelperChange/checkIsFocusedHelperChange.d.ts +4 -0
  80. package/node/components/Autocomplete/useLogic/utils/checkIsFocusedHelperChange/checkIsFocusedHelperChange.js +21 -0
  81. package/node/components/Autocomplete/useLogic/utils/checkIsFocusedHelperChange/index.d.ts +1 -0
  82. package/node/components/Autocomplete/useLogic/utils/checkIsFocusedHelperChange/index.js +17 -0
  83. package/node/components/Autocomplete/useLogic/utils/checkIsPopperVisible/checkIsPopperVisible.d.ts +8 -0
  84. package/node/components/Autocomplete/useLogic/utils/checkIsPopperVisible/checkIsPopperVisible.js +10 -0
  85. package/node/components/Autocomplete/useLogic/utils/checkIsPopperVisible/index.d.ts +1 -0
  86. package/node/components/Autocomplete/useLogic/utils/checkIsPopperVisible/index.js +5 -0
  87. package/node/components/Autocomplete/useLogic/utils/index.d.ts +2 -0
  88. package/node/components/Autocomplete/useLogic/utils/index.js +2 -0
  89. package/node/components/Autocomplete/utils/checkIsFocusedHelperOption/checkIsFocusedHelperOption.d.ts +5 -0
  90. package/node/components/Autocomplete/utils/checkIsFocusedHelperOption/checkIsFocusedHelperOption.js +11 -0
  91. package/node/components/Autocomplete/utils/checkIsFocusedHelperOption/index.d.ts +1 -0
  92. package/node/components/Autocomplete/utils/checkIsFocusedHelperOption/index.js +17 -0
  93. package/node/components/Autocomplete/utils/index.d.ts +1 -0
  94. package/node/components/Autocomplete/utils/index.js +17 -0
  95. package/node/components/Onboarding/ui/StepStrategy/steps/HighlightStep/styles.d.ts +1 -1
  96. package/node/components/Select/Select.js +4 -3
  97. package/node/components/Select/useLogic/useLogic.d.ts +11 -2
  98. package/node/components/Select/useLogic/useLogic.js +4 -1
  99. package/node/components/TagsList/PopoverTags/PopoverTags.d.ts +7 -0
  100. package/node/components/TagsList/PopoverTags/PopoverTags.js +12 -0
  101. package/node/components/TagsList/PopoverTags/index.d.ts +2 -0
  102. package/node/components/TagsList/PopoverTags/index.js +18 -0
  103. package/node/components/TagsList/PopoverTags/styles.d.ts +8 -0
  104. package/node/components/TagsList/PopoverTags/styles.js +18 -0
  105. package/node/components/TagsList/PopoverTags/types.d.ts +24 -0
  106. package/node/components/TagsList/PopoverTags/types.js +2 -0
  107. package/node/components/TagsList/Tag/Tag.d.ts +9 -1
  108. package/node/components/TagsList/Tag/Tag.js +4 -4
  109. package/node/components/TagsList/TagsList.js +10 -4
  110. package/node/components/TagsList/constants.d.ts +35 -0
  111. package/node/components/TagsList/constants.js +36 -1
  112. package/node/components/TagsList/styles.d.ts +9 -1
  113. package/node/components/TagsList/styles.js +20 -1
  114. package/node/components/TagsList/types.d.ts +4 -0
  115. package/node/components/TagsList/useLogic/hooks/index.d.ts +1 -0
  116. package/node/components/TagsList/useLogic/hooks/index.js +17 -0
  117. package/node/components/TagsList/useLogic/hooks/useHoverDelay/index.d.ts +1 -0
  118. package/node/components/TagsList/useLogic/hooks/useHoverDelay/index.js +17 -0
  119. package/node/components/TagsList/useLogic/hooks/useHoverDelay/types.d.ts +20 -0
  120. package/node/components/TagsList/useLogic/hooks/useHoverDelay/types.js +2 -0
  121. package/node/components/TagsList/useLogic/hooks/useHoverDelay/useHoverDelay.d.ts +5 -0
  122. package/node/components/TagsList/useLogic/hooks/useHoverDelay/useHoverDelay.js +31 -0
  123. package/node/components/TagsList/useLogic/useLogic.d.ts +14 -2
  124. package/node/components/TagsList/useLogic/useLogic.js +81 -1
  125. package/node/components/TagsList/utils/calculatePopoverWidth/calculatePopoverWidth.d.ts +5 -0
  126. package/node/components/TagsList/utils/calculatePopoverWidth/calculatePopoverWidth.js +26 -0
  127. package/node/components/TagsList/utils/calculatePopoverWidth/index.d.ts +1 -0
  128. package/node/components/TagsList/utils/calculatePopoverWidth/index.js +17 -0
  129. package/node/components/TagsList/utils/index.d.ts +1 -0
  130. package/node/components/TagsList/utils/index.js +3 -1
  131. package/node/components/TreeLikeAsyncAutocomplete/Input/Input.js +3 -2
  132. package/node/components/TreeLikeAsyncAutocomplete/Input/useLogic/useLogic.d.ts +3 -2
  133. package/node/components/TreeLikeAsyncAutocomplete/Input/useLogic/useLogic.js +3 -1
  134. package/node/components/TreeLikeAutocomplete/Input/Input.js +2 -2
  135. package/node/components/TreeLikeAutocomplete/Input/useLogic/useLogic.d.ts +2 -1
  136. package/node/components/TreeLikeAutocomplete/Input/useLogic/useLogic.js +3 -1
  137. package/package.json +1 -1
@@ -1,5 +1,11 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { CounterTag, Wrapper } from './styles';
2
+ import { CrossOutlineMd } from '../../icons/CrossOutlineMd';
3
+ import { IconButton } from '../IconButton';
4
+ import { NewPopover } from '../NewPopover';
5
+ import { Typography } from '../Typography';
6
+ import { POPOVER_CLOSE_TEXT, POPOVER_TITLE_TEXT } from './constants';
7
+ import { PopoverTags } from './PopoverTags';
8
+ import { CounterTag, PopoverContentWrapper, PopoverHeader, Wrapper, } from './styles';
3
9
  import { Tag } from './Tag';
4
10
  import { useLogic } from './useLogic';
5
11
  import { getKey } from './utils';
@@ -8,10 +14,10 @@ import { getKey } from './utils';
8
14
  * Не предназначен для использования в продуктах, не экспортируется из пакета
9
15
  */
10
16
  export const TagsList = (props) => {
11
- const { hiddenCount, tagsContainerRef, visibleOptions, getTagProps, showCounter, } = useLogic(props);
12
- const { className, keyId, isDisabled, onClick, getOptionLabel } = props;
17
+ const { hiddenCount, tagsContainerRef, counterRef, visibleOptions, getTagProps, showCounter, isPopoverOpen, isPopoverEnabled, setPopoverContentRef, popoverContentCssVars, stopPopoverEventPropagation, popoverAnchorEl, closePopover, startPopoverDelay, cancelPopoverDelay, handleTagClick, handleCounterClick, } = useLogic(props);
18
+ const { className, data = [], keyId, isDisabled, getOptionLabel } = props;
13
19
  return (_jsxs(Wrapper, { className: className, ref: tagsContainerRef, children: [visibleOptions?.map((option) => {
14
20
  const tagProps = getTagProps(option);
15
- return (_jsx(Tag, { isDisabled: isDisabled, onClick: onClick, ...tagProps }, getKey(option, keyId, getOptionLabel)));
16
- }), showCounter && (_jsx(CounterTag, { isDisabled: isDisabled, label: `+${hiddenCount}`, onClick: onClick }, "more"))] }));
21
+ return (_jsx(Tag, { isDisabled: isDisabled, onClick: handleTagClick, ...tagProps }, getKey(option, keyId, getOptionLabel)));
22
+ }), showCounter && (_jsx(CounterTag, { ref: counterRef, isDisabled: isDisabled, label: `+${hiddenCount}`, onClick: handleCounterClick, onMouseEnter: isPopoverEnabled ? startPopoverDelay : undefined, onMouseLeave: isPopoverEnabled ? cancelPopoverDelay : undefined }, "more")), _jsx(NewPopover, { isOpen: isPopoverOpen, anchorEl: popoverAnchorEl, disableAutoFocus: true, onClose: closePopover, children: _jsxs(PopoverContentWrapper, { ref: setPopoverContentRef, style: popoverContentCssVars, onClick: stopPopoverEventPropagation, onMouseDown: stopPopoverEventPropagation, children: [_jsxs(PopoverHeader, { children: [_jsx(Typography, { variant: "h5", children: POPOVER_TITLE_TEXT }), _jsx(IconButton, { variant: "text", title: POPOVER_CLOSE_TEXT, "aria-label": POPOVER_CLOSE_TEXT, onClick: closePopover, children: _jsx(CrossOutlineMd, {}) })] }), _jsx(PopoverTags, { data: data, keyId: keyId, isDisabled: isDisabled, getOptionLabel: getOptionLabel, getTagProps: getTagProps })] }) })] }));
17
23
  };
@@ -1,2 +1,37 @@
1
1
  export declare const MIN_AVAILABLE_WIDTH = 50;
2
2
  export declare const GAP_BETWEEN_TAGS = 4;
3
+ /**
4
+ * Задержка появления всплывающего окна при наведении на счётчик (мс)
5
+ */
6
+ export declare const POPOVER_HOVER_DELAY = 500;
7
+ /**
8
+ * Максимальная ширина всплывающего окна (px)
9
+ */
10
+ export declare const POPOVER_MAX_WIDTH = 480;
11
+ /**
12
+ * Максимальная высота всплывающего окна (px)
13
+ */
14
+ export declare const POPOVER_MAX_HEIGHT = 370;
15
+ /**
16
+ * Количество тэгов, которые всплывающее окно вмещает в строку в любом случае:
17
+ * задаёт его минимальную ширину
18
+ */
19
+ export declare const POPOVER_MIN_TAGS_IN_ROW = 2;
20
+ /**
21
+ * Отступ между тэгами во всплывающем окне в единицах theme.spacing.
22
+ * Используется и в стилях, и в расчёте минимальной ширины окна
23
+ */
24
+ export declare const POPOVER_TAGS_GAP_SPACING = 2;
25
+ /**
26
+ * Горизонтальный отступ контейнера тэгов во всплывающем окне в единицах
27
+ * theme.spacing. Используется и в стилях, и в расчёте минимальной ширины окна
28
+ */
29
+ export declare const POPOVER_TAGS_PADDING_SPACING = 4;
30
+ /**
31
+ * Заголовок всплывающего окна со списком выбранных элементов
32
+ */
33
+ export declare const POPOVER_TITLE_TEXT = "\u0412\u044B\u0431\u0440\u0430\u043D\u043D\u044B\u0435 \u044D\u043B\u0435\u043C\u0435\u043D\u0442\u044B";
34
+ /**
35
+ * Доступное имя кнопки, закрывающей всплывающее окно
36
+ */
37
+ export declare const POPOVER_CLOSE_TEXT = "\u0417\u0430\u043A\u0440\u044B\u0442\u044C";
@@ -1,2 +1,37 @@
1
1
  export const MIN_AVAILABLE_WIDTH = 50;
2
2
  export const GAP_BETWEEN_TAGS = 4; // 4px
3
+ /**
4
+ * Задержка появления всплывающего окна при наведении на счётчик (мс)
5
+ */
6
+ export const POPOVER_HOVER_DELAY = 500;
7
+ /**
8
+ * Максимальная ширина всплывающего окна (px)
9
+ */
10
+ export const POPOVER_MAX_WIDTH = 480;
11
+ /**
12
+ * Максимальная высота всплывающего окна (px)
13
+ */
14
+ export const POPOVER_MAX_HEIGHT = 370;
15
+ /**
16
+ * Количество тэгов, которые всплывающее окно вмещает в строку в любом случае:
17
+ * задаёт его минимальную ширину
18
+ */
19
+ export const POPOVER_MIN_TAGS_IN_ROW = 2;
20
+ /**
21
+ * Отступ между тэгами во всплывающем окне в единицах theme.spacing.
22
+ * Используется и в стилях, и в расчёте минимальной ширины окна
23
+ */
24
+ export const POPOVER_TAGS_GAP_SPACING = 2;
25
+ /**
26
+ * Горизонтальный отступ контейнера тэгов во всплывающем окне в единицах
27
+ * theme.spacing. Используется и в стилях, и в расчёте минимальной ширины окна
28
+ */
29
+ export const POPOVER_TAGS_PADDING_SPACING = 4;
30
+ /**
31
+ * Заголовок всплывающего окна со списком выбранных элементов
32
+ */
33
+ export const POPOVER_TITLE_TEXT = 'Выбранные элементы';
34
+ /**
35
+ * Доступное имя кнопки, закрывающей всплывающее окно
36
+ */
37
+ export const POPOVER_CLOSE_TEXT = 'Закрыть';
@@ -3,6 +3,14 @@ export declare const Wrapper: import("../styled").StyledComponent<{
3
3
  theme?: import("@emotion/react").Theme | undefined;
4
4
  as?: import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> | undefined;
5
5
  }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
6
- export declare const CounterTag: import("../styled").StyledComponent<import("./Tag").TagProps & {
6
+ export declare const CounterTag: import("../styled").StyledComponent<import("./Tag").TagProps & import("react").RefAttributes<HTMLDivElement> & {
7
7
  theme?: import("@emotion/react").Theme | undefined;
8
8
  }, {}, {}>;
9
+ export declare const PopoverContentWrapper: import("../styled").StyledComponent<{
10
+ theme?: import("@emotion/react").Theme | undefined;
11
+ as?: import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> | undefined;
12
+ }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
13
+ export declare const PopoverHeader: import("../styled").StyledComponent<{
14
+ theme?: import("@emotion/react").Theme | undefined;
15
+ as?: import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> | undefined;
16
+ }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
@@ -1,6 +1,6 @@
1
1
  import { styled } from '../styled';
2
2
  import { tagClassnames } from '../Tag';
3
- import { GAP_BETWEEN_TAGS } from './constants';
3
+ import { GAP_BETWEEN_TAGS, POPOVER_MAX_WIDTH } from './constants';
4
4
  import { Tag } from './Tag';
5
5
  export const Wrapper = styled.div `
6
6
  overflow: hidden;
@@ -8,9 +8,28 @@ export const Wrapper = styled.div `
8
8
  column-gap: ${GAP_BETWEEN_TAGS}px;
9
9
  `;
10
10
  export const CounterTag = styled(Tag) `
11
+ cursor: pointer;
12
+
11
13
  overflow: unset;
12
14
 
13
15
  .${tagClassnames.label} {
14
16
  min-width: unset;
15
17
  }
16
18
  `;
19
+ export const PopoverContentWrapper = styled.div `
20
+ --tags-list-popover-width: ${POPOVER_MAX_WIDTH}px;
21
+ display: flex;
22
+ flex-direction: column;
23
+ gap: ${({ theme }) => theme.spacing(2)};
24
+
25
+ width: var(--tags-list-popover-width);
26
+ max-width: ${POPOVER_MAX_WIDTH}px;
27
+ padding-block: ${({ theme }) => theme.spacing(4)};
28
+ `;
29
+ export const PopoverHeader = styled.div `
30
+ display: flex;
31
+ align-items: center;
32
+ justify-content: space-between;
33
+
34
+ padding-inline: ${({ theme }) => theme.spacing(4)};
35
+ `;
@@ -31,6 +31,10 @@ export type TagsListProps<TData extends TagValue = TagValue> = {
31
31
  * Ref на внешний контейнер, чья ширина используется как база для расчёта доступного пространства..
32
32
  */
33
33
  inputContainerRef?: RefObject<HTMLElement | null>;
34
+ /**
35
+ * Ref на поле инпута
36
+ */
37
+ fieldRef: RefObject<HTMLElement | null>;
34
38
  /**
35
39
  * Зарезервированная ширина, которая будет вычтена из доступной ширины при расчете количества отображаемых тегов
36
40
  */
@@ -0,0 +1 @@
1
+ export * from './useHoverDelay';
@@ -0,0 +1 @@
1
+ export * from './useHoverDelay';
@@ -0,0 +1 @@
1
+ export * from './useHoverDelay';
@@ -0,0 +1 @@
1
+ export * from './useHoverDelay';
@@ -0,0 +1,20 @@
1
+ export type UseHoverDelayResult = {
2
+ /**
3
+ * Запускает отсчёт задержки. Повторный вызов перезапускает отсчёт
4
+ */
5
+ start: () => void;
6
+ /**
7
+ * Отменяет отсчёт, если он не завершился
8
+ */
9
+ cancel: () => void;
10
+ };
11
+ export type UseHoverDelayParams = {
12
+ /**
13
+ * Функция, вызывающаяся при hover-эффекте после задержки
14
+ */
15
+ onHover: () => void;
16
+ /**
17
+ * Задержка вызова функции в мс
18
+ */
19
+ delay: number;
20
+ };
@@ -0,0 +1,5 @@
1
+ import { type UseHoverDelayParams, type UseHoverDelayResult } from './types';
2
+ /**
3
+ * Откладывает вызов на время удержания указателя над элементом.
4
+ */
5
+ export declare const useHoverDelay: ({ delay, onHover, }: UseHoverDelayParams) => UseHoverDelayResult;
@@ -0,0 +1,27 @@
1
+ import { useEffect, useRef } from 'react';
2
+ /**
3
+ * Откладывает вызов на время удержания указателя над элементом.
4
+ */
5
+ export const useHoverDelay = ({ delay, onHover, }) => {
6
+ const timeoutRef = useRef(undefined);
7
+ const savedOnHoverRef = useRef(onHover);
8
+ useEffect(() => {
9
+ savedOnHoverRef.current = onHover;
10
+ });
11
+ const cancel = () => {
12
+ if (timeoutRef.current === undefined) {
13
+ return;
14
+ }
15
+ clearTimeout(timeoutRef.current);
16
+ timeoutRef.current = undefined;
17
+ };
18
+ const start = () => {
19
+ cancel();
20
+ timeoutRef.current = setTimeout(() => {
21
+ timeoutRef.current = undefined;
22
+ savedOnHoverRef.current();
23
+ }, delay);
24
+ };
25
+ useEffect(() => cancel, []);
26
+ return { start, cancel };
27
+ };
@@ -1,15 +1,27 @@
1
- /// <reference types="react" />
1
+ import { type CSSProperties, type MouseEvent, type SyntheticEvent } from 'react';
2
2
  import type { TagsListProps, TagValue } from '../types';
3
3
  type UseLogicParams<TData extends TagValue> = TagsListProps<TData>;
4
- export declare const useLogic: <TData extends TagValue>({ data, keyId, getOptionLabel, onChange, inputContainerRef, reservedWidth, }: UseLogicParams<TData>) => {
4
+ export declare const useLogic: <TData extends TagValue>({ data, keyId, isDisabled, getOptionLabel, onChange, onClick, inputContainerRef, fieldRef, reservedWidth, }: UseLogicParams<TData>) => {
5
5
  visibleOptions: TData[];
6
6
  hiddenCount: number;
7
7
  showCounter: boolean;
8
8
  tagsContainerRef: import("react").RefObject<HTMLDivElement | null>;
9
+ counterRef: import("react").RefObject<HTMLDivElement | null>;
9
10
  getTagProps: (option: TData) => {
10
11
  label: string | number;
11
12
  shrinks: boolean;
12
13
  onDelete: () => void;
13
14
  };
15
+ isPopoverOpen: boolean;
16
+ isPopoverEnabled: boolean;
17
+ setPopoverContentRef: (node: HTMLDivElement | null) => void;
18
+ popoverContentCssVars: CSSProperties;
19
+ stopPopoverEventPropagation: (event: SyntheticEvent) => void;
20
+ popoverAnchorEl: HTMLElement | null;
21
+ closePopover: () => void;
22
+ startPopoverDelay: () => void;
23
+ cancelPopoverDelay: () => void;
24
+ handleTagClick: (event: MouseEvent<HTMLDivElement>) => void;
25
+ handleCounterClick: (event: MouseEvent<HTMLDivElement>) => void;
14
26
  };
15
27
  export {};
@@ -1,13 +1,38 @@
1
- import { useEffect, useLayoutEffect, useRef, useState } from 'react';
1
+ import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, } from 'react';
2
2
  import { useTheme } from '../../theme/hooks/useTheme';
3
- import { MIN_AVAILABLE_WIDTH } from '../constants';
4
- import { calculateVisibleTagsCount, getAvailableWidth } from '../utils';
5
- export const useLogic = ({ data = [], keyId, getOptionLabel, onChange, inputContainerRef, reservedWidth = 0, }) => {
3
+ import { useClickAwayEffect } from '../../useClickAwayEffect';
4
+ import { useNewToggle } from '../../useNewToggle';
5
+ import { useViewportType } from '../../useViewportType';
6
+ import { MIN_AVAILABLE_WIDTH, POPOVER_HOVER_DELAY } from '../constants';
7
+ import { calculatePopoverWidth, calculateVisibleTagsCount, getAvailableWidth, } from '../utils';
8
+ import { useHoverDelay } from './hooks/useHoverDelay';
9
+ export const useLogic = ({ data = [], keyId, isDisabled, getOptionLabel, onChange, onClick, inputContainerRef, fieldRef, reservedWidth = 0, }) => {
6
10
  const [visibleOptions, setVisibleOptions] = useState([]);
7
11
  const [hiddenCount, setHiddenCount] = useState(0);
12
+ const [isPopoverOpen, togglePopover] = useNewToggle(false);
13
+ const [isPopoverContentMounted, togglePopoverContentMounted] = useNewToggle(false);
14
+ /**
15
+ * Ширина окна и якорь позиционирования фиксируются на момент открытия
16
+ * и дальше не пересчитываются
17
+ */
18
+ const [popoverWidth, setPopoverWidth] = useState(0);
19
+ const [popoverAnchorEl, setPopoverAnchorEl] = useState(null);
8
20
  const tagsContainerRef = useRef(null);
9
21
  const availableWidthRef = useRef(0);
22
+ const popoverContentRef = useRef(null);
23
+ const counterRef = useRef(null);
10
24
  const theme = useTheme();
25
+ const { isMobile } = useViewportType();
26
+ const openPopover = () => {
27
+ const field = fieldRef.current;
28
+ if (isPopoverOpen || !field) {
29
+ return;
30
+ }
31
+ setPopoverWidth(calculatePopoverWidth(field.getBoundingClientRect().width, data.map((item) => getOptionLabel(item).toString()), theme));
32
+ setPopoverAnchorEl(field);
33
+ togglePopover(true);
34
+ };
35
+ const closePopover = () => togglePopover(false);
11
36
  /**
12
37
  * Обновляет доступную ширину для расчета количества отображаемых тегов
13
38
  */
@@ -64,6 +89,7 @@ export const useLogic = ({ data = [], keyId, getOptionLabel, onChange, inputCont
64
89
  if (!data.length) {
65
90
  setVisibleOptions([]);
66
91
  setHiddenCount(0);
92
+ closePopover();
67
93
  return;
68
94
  }
69
95
  const resizeObserver = new ResizeObserver(() => {
@@ -102,11 +128,65 @@ export const useLogic = ({ data = [], keyId, getOptionLabel, onChange, inputCont
102
128
  return { label, shrinks: false, onDelete };
103
129
  };
104
130
  const showCounter = hiddenCount > 0;
131
+ const { start: startPopoverDelay, cancel: cancelPopoverDelay } = useHoverDelay({ onHover: openPopover, delay: POPOVER_HOVER_DELAY });
132
+ const setPopoverContentRef = useCallback((node) => {
133
+ popoverContentRef.current = node;
134
+ togglePopoverContentMounted(Boolean(node));
135
+ }, []);
136
+ const popoverExcludedNodes = useMemo(() => [counterRef], []);
137
+ useClickAwayEffect({
138
+ ref: popoverContentRef,
139
+ onClickAway: closePopover,
140
+ isActive: isPopoverOpen && isPopoverContentMounted,
141
+ excludeNodes: popoverExcludedNodes,
142
+ });
143
+ const isPopoverEnabled = !isMobile && !isDisabled;
144
+ const handleTagClick = (event) => {
145
+ event.stopPropagation();
146
+ onClick?.(event);
147
+ };
148
+ const handleCounterClick = (event) => {
149
+ event.stopPropagation();
150
+ cancelPopoverDelay();
151
+ // На мобильной ширине и в заблокированном поле у счётчика прежнее поведение — список опций
152
+ if (!isPopoverEnabled) {
153
+ onClick?.(event);
154
+ return;
155
+ }
156
+ if (isPopoverOpen) {
157
+ closePopover();
158
+ return;
159
+ }
160
+ openPopover();
161
+ };
162
+ /**
163
+ * Окно живёт в портале, но синтетические события React всплывают по дереву
164
+ * компонентов и доходят до обработчиков поля: у MUI Select это `handleMouseDown`,
165
+ * который переводит фокус на поле и открывает список, у TreeLike* — `onClick` поля
166
+ */
167
+ const stopPopoverEventPropagation = (event) => {
168
+ event.stopPropagation();
169
+ };
170
+ const popoverContentCssVars = {
171
+ '--tags-list-popover-width': `${popoverWidth}px`,
172
+ };
105
173
  return {
106
174
  visibleOptions,
107
175
  hiddenCount,
108
176
  showCounter,
109
177
  tagsContainerRef,
178
+ counterRef,
110
179
  getTagProps,
180
+ isPopoverOpen,
181
+ isPopoverEnabled,
182
+ setPopoverContentRef,
183
+ popoverContentCssVars,
184
+ stopPopoverEventPropagation,
185
+ popoverAnchorEl,
186
+ closePopover,
187
+ startPopoverDelay,
188
+ cancelPopoverDelay,
189
+ handleTagClick,
190
+ handleCounterClick,
111
191
  };
112
192
  };
@@ -0,0 +1,5 @@
1
+ import type { Theme } from '../../../theme/types';
2
+ /**
3
+ * Вычисляет ширину всплывающего окна
4
+ */
5
+ export declare const calculatePopoverWidth: (fieldWidth: number, tagLabels: string[], theme: Theme) => number;
@@ -0,0 +1,22 @@
1
+ import { POPOVER_MAX_WIDTH, POPOVER_MIN_TAGS_IN_ROW, POPOVER_TAGS_GAP_SPACING, POPOVER_TAGS_PADDING_SPACING, } from '../../constants';
2
+ import { getTagWidth } from '../getTagWidth';
3
+ const getSpacingValue = (theme, spacing) => parseInt(theme.spacing(spacing), 10);
4
+ /**
5
+ * Минимальная ширина popover: вмещает в строку POPOVER_MIN_TAGS_IN_ROW самых
6
+ * широких тэгов вместе с отступом между ними и отступами контейнера
7
+ */
8
+ const getMinWidth = (tagLabels, theme) => {
9
+ const widestTagWidths = tagLabels
10
+ .map((label) => getTagWidth(label, theme))
11
+ .sort((current, next) => next - current)
12
+ .slice(0, POPOVER_MIN_TAGS_IN_ROW);
13
+ const tagsWidth = widestTagWidths.reduce((width, tagWidth) => width + tagWidth, 0);
14
+ const gapsWidth = Math.max(widestTagWidths.length - 1, 0) *
15
+ getSpacingValue(theme, POPOVER_TAGS_GAP_SPACING);
16
+ const paddingsWidth = getSpacingValue(theme, POPOVER_TAGS_PADDING_SPACING) * 2;
17
+ return tagsWidth + gapsWidth + paddingsWidth;
18
+ };
19
+ /**
20
+ * Вычисляет ширину всплывающего окна
21
+ */
22
+ export const calculatePopoverWidth = (fieldWidth, tagLabels, theme) => Math.min(Math.max(fieldWidth, getMinWidth(tagLabels, theme)), POPOVER_MAX_WIDTH);
@@ -0,0 +1 @@
1
+ export * from './calculatePopoverWidth';
@@ -0,0 +1 @@
1
+ export * from './calculatePopoverWidth';
@@ -3,3 +3,4 @@ export { getKey } from './getKey';
3
3
  export { getTagWidth } from './getTagWidth';
4
4
  export { getAvailableWidth } from './getAvailableWidth';
5
5
  export { calculateVisibleTagsCount } from './calculateVisibleTagsCount';
6
+ export { calculatePopoverWidth } from './calculatePopoverWidth';
@@ -3,3 +3,4 @@ export { getKey } from './getKey';
3
3
  export { getTagWidth } from './getTagWidth';
4
4
  export { getAvailableWidth } from './getAvailableWidth';
5
5
  export { calculateVisibleTagsCount } from './calculateVisibleTagsCount';
6
+ export { calculatePopoverWidth } from './calculatePopoverWidth';
@@ -9,13 +9,14 @@ import { IconWrapper, StyledTagsList, StyledTextField } from './styles';
9
9
  import { useLogic } from './useLogic';
10
10
  const ClearButton = ({ disabled, onClick }) => (_jsx(IconButton, { variant: "text", color: "grey", disabled: disabled, onClick: onClick, title: CLEAR_TEXT, "aria-label": CLEAR_TEXT, children: _jsx(CrossOutlineMd, {}) }));
11
11
  export const Input = forwardRef(({ disabled, onChange: propsOnChange, value, inputRef, hideHelperText = false, onClick, isLoading, ...restProps }, forwardedRef) => {
12
- const { isVisibleClearButton, isVisibleTagsList, onChange, textFieldProps, onClearAll, } = useLogic({
12
+ const { isVisibleClearButton, isVisibleTagsList, onChange, textFieldProps, onClearAll, fieldRef, } = useLogic({
13
13
  inputRef,
14
+ InputProps: restProps.InputProps,
14
15
  value,
15
16
  onChange: propsOnChange,
16
17
  disabled,
17
18
  onClick,
18
19
  isLoading,
19
20
  });
20
- return (_jsx(StyledTextField, { ...restProps, hideHelperText: hideHelperText, ref: forwardedRef, disabled: disabled, inputProps: { readOnly: true }, ...textFieldProps, startAdornment: isVisibleTagsList && (_jsx(StyledTagsList, { data: value, keyId: "id", isDisabled: disabled, getOptionLabel: (option) => option.label, onClick: onClick, onChange: onChange })), endAdornment: _jsxs(IconWrapper, { children: [isVisibleClearButton && (_jsx(ClearButton, { disabled: disabled, onClick: onClearAll })), isLoading ? (_jsx(Loader, { size: "small" })) : (_jsx(IconButton, { variant: "text", color: "grey", disabled: disabled, children: _jsx(DownOutlineMd, {}) }))] }) }));
21
+ return (_jsx(StyledTextField, { ...restProps, hideHelperText: hideHelperText, ref: forwardedRef, disabled: disabled, inputProps: { readOnly: true }, ...textFieldProps, InputProps: { ...restProps.InputProps, ref: fieldRef }, startAdornment: isVisibleTagsList && (_jsx(StyledTagsList, { data: value, keyId: "id", isDisabled: disabled, fieldRef: fieldRef, getOptionLabel: (option) => option.label, onClick: onClick, onChange: onChange })), endAdornment: _jsxs(IconWrapper, { children: [isVisibleClearButton && (_jsx(ClearButton, { disabled: disabled, onClick: onClearAll })), isLoading ? (_jsx(Loader, { size: "small" })) : (_jsx(IconButton, { variant: "text", color: "grey", disabled: disabled, children: _jsx(DownOutlineMd, {}) }))] }) }));
21
22
  });
@@ -1,13 +1,14 @@
1
1
  import { type MouseEvent, type SyntheticEvent } from 'react';
2
2
  import { type TreeLikeAsyncAutocompleteValue } from '../../types';
3
3
  import type { InputProps } from '../types';
4
- type UseLogicParams = Pick<InputProps, 'value' | 'disabled' | 'inputRef' | 'onChange' | 'isLoading' | 'onClick'>;
5
- export declare const useLogic: ({ value, disabled, isLoading, inputRef: externalInputRef, onChange: propsOnChange, onClick: propsOnClick, }: UseLogicParams) => {
4
+ type UseLogicParams = Pick<InputProps, 'value' | 'disabled' | 'inputRef' | 'InputProps' | 'onChange' | 'isLoading' | 'onClick'>;
5
+ export declare const useLogic: ({ value, disabled, isLoading, inputRef: externalInputRef, InputProps: externalInputProps, onChange: propsOnChange, onClick: propsOnClick, }: UseLogicParams) => {
6
6
  isVisibleClearButton: boolean;
7
7
  onClearAll: (event: SyntheticEvent<HTMLButtonElement>) => void;
8
8
  onChange: (newValue: TreeLikeAsyncAutocompleteValue | undefined) => void;
9
9
  onClick: (event: MouseEvent<HTMLDivElement>) => void;
10
10
  isVisibleTagsList: boolean;
11
+ fieldRef: import("react").RefObject<HTMLElement | null>;
11
12
  textFieldProps: {
12
13
  value: string;
13
14
  $isHidden: boolean;
@@ -1,7 +1,8 @@
1
1
  import { useEffect, useRef, } from 'react';
2
2
  import { useForwardedRef } from '../../../useForwardedRef';
3
- export const useLogic = ({ value, disabled, isLoading, inputRef: externalInputRef, onChange: propsOnChange, onClick: propsOnClick, }) => {
3
+ export const useLogic = ({ value, disabled, isLoading, inputRef: externalInputRef, InputProps: externalInputProps, onChange: propsOnChange, onClick: propsOnClick, }) => {
4
4
  const inputRef = useForwardedRef(externalInputRef);
5
+ const fieldRef = useForwardedRef(externalInputProps?.ref);
5
6
  const prevValue = useRef(undefined);
6
7
  useEffect(() => {
7
8
  if (value && !prevValue.current) {
@@ -40,6 +41,7 @@ export const useLogic = ({ value, disabled, isLoading, inputRef: externalInputRe
40
41
  onChange,
41
42
  onClick,
42
43
  isVisibleTagsList: hasValue,
44
+ fieldRef,
43
45
  textFieldProps: {
44
46
  value: preparedValue,
45
47
  $isHidden: hasValue,
@@ -8,7 +8,7 @@ import { EndAdornmentWrapper, StyledLoader, StyledTagsList, StyledTextField, } f
8
8
  import { useLogic } from './useLogic';
9
9
  const ClearButton = ({ disabled, onClick }) => (_jsx(IconButton, { variant: "text", color: "grey", disabled: disabled, title: CLEAR_TEXT, "aria-label": CLEAR_TEXT, onClick: onClick, children: _jsx(CrossOutlineMd, {}) }));
10
10
  export const Input = forwardRef((props, forwardedRef) => {
11
- const { textFieldProps, isVisibleTagsList, isVisibleClearButton, handleChange, handleClearAll, } = useLogic(props);
11
+ const { textFieldProps, isVisibleTagsList, isVisibleClearButton, handleChange, handleClearAll, fieldRef, } = useLogic(props);
12
12
  const { value, valueToRender, disabled, isLoading, onChange, onClick, ...restProps } = props;
13
- return (_jsx(StyledTextField, { ...restProps, ref: forwardedRef, disabled: disabled, inputProps: { readOnly: true }, startAdornment: isVisibleTagsList && (_jsx(StyledTagsList, { data: valueToRender, keyId: "id", isDisabled: disabled, getOptionLabel: (option) => option.label, onClick: onClick, onChange: handleChange })), endAdornment: _jsxs(EndAdornmentWrapper, { children: [isLoading && _jsx(StyledLoader, {}), isVisibleClearButton && (_jsx(ClearButton, { disabled: disabled, onClick: handleClearAll })), _jsx(IconButton, { variant: "text", color: "grey", disabled: disabled, children: _jsx(DownOutlineMd, {}) })] }), onClick: onClick, ...textFieldProps }));
13
+ return (_jsx(StyledTextField, { ...restProps, ref: forwardedRef, disabled: disabled, inputProps: { readOnly: true }, InputProps: { ...restProps.InputProps, ref: fieldRef }, startAdornment: isVisibleTagsList && (_jsx(StyledTagsList, { data: valueToRender, keyId: "id", isDisabled: disabled, fieldRef: fieldRef, getOptionLabel: (option) => option.label, onClick: onClick, onChange: handleChange })), endAdornment: _jsxs(EndAdornmentWrapper, { children: [isLoading && _jsx(StyledLoader, {}), isVisibleClearButton && (_jsx(ClearButton, { disabled: disabled, onClick: handleClearAll })), _jsx(IconButton, { variant: "text", color: "grey", disabled: disabled, children: _jsx(DownOutlineMd, {}) })] }), onClick: onClick, ...textFieldProps }));
14
14
  });
@@ -2,12 +2,13 @@ import { type SyntheticEvent } from 'react';
2
2
  import { type TreeListData } from '../../../Tree';
3
3
  import type { TreeLikeAutocompleteValue } from '../../types';
4
4
  import { type InputProps } from '../types';
5
- export declare const useLogic: ({ value, disabled, isLoading, inputRef: externalInputRef, onChange, }: InputProps) => {
5
+ export declare const useLogic: ({ value, disabled, isLoading, inputRef: externalInputRef, InputProps: externalInputProps, onChange, }: InputProps) => {
6
6
  textFieldProps: {
7
7
  $isHidden: boolean;
8
8
  inputRef: import("react").RefObject<HTMLInputElement | null>;
9
9
  value: string | TreeLikeAutocompleteValue;
10
10
  };
11
+ fieldRef: import("react").RefObject<HTMLElement | null>;
11
12
  isVisibleTagsList: boolean;
12
13
  isVisibleClearButton: boolean;
13
14
  handleChange: (newValue: TreeListData[] | undefined) => void;
@@ -1,7 +1,8 @@
1
1
  import { useEffect, useRef, } from 'react';
2
2
  import { useForwardedRef } from '../../../useForwardedRef';
3
- export const useLogic = ({ value, disabled, isLoading, inputRef: externalInputRef, onChange, }) => {
3
+ export const useLogic = ({ value, disabled, isLoading, inputRef: externalInputRef, InputProps: externalInputProps, onChange, }) => {
4
4
  const inputRef = useForwardedRef(externalInputRef);
5
+ const fieldRef = useForwardedRef(externalInputProps?.ref);
5
6
  const prevValue = useRef(undefined);
6
7
  useEffect(() => {
7
8
  if (value && !prevValue.current) {
@@ -38,6 +39,7 @@ export const useLogic = ({ value, disabled, isLoading, inputRef: externalInputRe
38
39
  inputRef,
39
40
  value: preparedValue,
40
41
  },
42
+ fieldRef,
41
43
  isVisibleTagsList: hasValue,
42
44
  isVisibleClearButton,
43
45
  handleChange,
@@ -366,6 +366,7 @@ export declare const useLogic: <TOptions, TMultiple extends boolean, TDisableCle
366
366
  openOnFocus?: boolean | undefined;
367
367
  selectOnFocus?: boolean | undefined;
368
368
  loadedDataError?: string | undefined;
369
+ focusedHelperText?: string | undefined;
369
370
  overflowOption?: import("../..").OverflowedElementProps | undefined;
370
371
  options: TOptions[];
371
372
  disabled: boolean | undefined;
@@ -18,4 +18,5 @@ export declare const Autocomplete: <TAutocompleteValueProps, TMultiple extends b
18
18
  openText?: string | undefined;
19
19
  clearText?: string | undefined;
20
20
  hideHelperText?: boolean | undefined;
21
+ focusedHelperText?: string | undefined;
21
22
  } & import("react").RefAttributes<unknown>) => import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | null;
@@ -16,21 +16,23 @@ const Loader_1 = require("../Loader");
16
16
  const OverflowTypography_1 = require("../OverflowTypography");
17
17
  const TagsList_1 = require("../TagsList");
18
18
  const TextField_1 = require("../TextField");
19
+ const Typography_1 = require("../Typography");
19
20
  const cn_1 = require("../utils/cn");
20
21
  const constants_1 = require("./constants");
21
22
  const styles_1 = require("./styles");
22
23
  const useLogic_1 = require("./useLogic");
24
+ const utils_1 = require("./utils");
23
25
  const AutocompleteInner = (props, ref) => {
24
26
  const { isValueEmpty, isPopperVisible, autocompleteProps } = (0, useLogic_1.useLogic)(props);
25
27
  const inputBaseRef = (0, react_1.useRef)(null);
26
- const { required, success, error, label, getOptionLabel, helperText, inputRef, multiple, size = 'medium', placeholder = constants_1.DEFAULT_PLACEHOLDER, overflowOption, closeText = 'Закрыть', openText = 'Открыть', clearText = 'Очистить', loadingText = (0, jsx_runtime_1.jsx)(Loader_1.Loader, {}), isLoadedDataError, loadedDataError, noOptionsText, autoHighlight, renderInput: externalRenderInput, renderTags: externalRenderTags, renderOption: externalRenderOption, inputProps, hideHelperText = false, loading, value, onChange, ...restProps } = props;
28
+ const { required, success, error, label, getOptionLabel, helperText, inputRef, multiple, size = 'medium', placeholder = constants_1.DEFAULT_PLACEHOLDER, overflowOption, closeText = 'Закрыть', openText = 'Открыть', clearText = 'Очистить', loadingText = (0, jsx_runtime_1.jsx)(Loader_1.Loader, {}), isLoadedDataError, loadedDataError, noOptionsText, autoHighlight, renderInput: externalRenderInput, renderTags: externalRenderTags, renderOption: externalRenderOption, inputProps, hideHelperText = false, focusedHelperText, loading, value, onChange, ...restProps } = props;
27
29
  const renderInput = (0, react_1.useCallback)((inputParams) => {
28
30
  const createStartAdornment = () => {
29
31
  if (!multiple || !Array.isArray(value)) {
30
32
  return null;
31
33
  }
32
- const tagsListElement = ((0, jsx_runtime_1.jsx)(TagsList_1.TagsList, { data: value, getOptionLabel: (option) => getOptionLabel?.(option) ??
33
- option.toString(), inputContainerRef: inputBaseRef, reservedWidth: constants_1.INPUT_MIN_WIDTH, onChange: (tagValues) => {
34
+ return ((0, jsx_runtime_1.jsx)(TagsList_1.TagsList, { data: value, getOptionLabel: (option) => getOptionLabel?.(option) ??
35
+ option.toString(), inputContainerRef: inputBaseRef, fieldRef: inputBaseRef, reservedWidth: constants_1.INPUT_MIN_WIDTH, onChange: (tagValues) => {
34
36
  if (!onChange) {
35
37
  return;
36
38
  }
@@ -42,7 +44,6 @@ const AutocompleteInner = (props, ref) => {
42
44
  const reason = 'removeOption';
43
45
  onChange(syntheticEvent, tagValues, reason);
44
46
  } }));
45
- return tagsListElement;
46
47
  };
47
48
  const generalInputParams = {
48
49
  ...inputParams,
@@ -100,13 +101,16 @@ const AutocompleteInner = (props, ref) => {
100
101
  onChange,
101
102
  ]);
102
103
  const renderOption = (0, react_1.useCallback)((optionProps, option, optionState, ownerState) => {
104
+ const { key, ...restOptionProps } = optionProps;
105
+ if ((0, utils_1.checkIsFocusedHelperOption)(option)) {
106
+ return ((0, jsx_runtime_1.jsx)(styles_1.StyledFocusedHelperOption, { role: "presentation", ...restOptionProps, children: (0, jsx_runtime_1.jsx)(Typography_1.Typography, { variant: "body1", color: "grey", colorIntensity: "600", children: focusedHelperText }) }, key));
107
+ }
103
108
  if (externalRenderOption) {
104
109
  return externalRenderOption(optionProps, option, optionState, ownerState);
105
110
  }
106
111
  const isSelected = Boolean(optionProps['aria-selected']);
107
- const { key, ...restOptionProps } = optionProps;
108
112
  return ((0, jsx_runtime_1.jsxs)(styles_1.StyledMenuItem, { selected: isSelected, ...restOptionProps, children: [multiple && ((0, jsx_runtime_1.jsx)(ListItemIcon_1.default, { children: (0, jsx_runtime_1.jsx)(Checkbox_1.Checkbox, { role: "menuitemcheckbox", checked: isSelected }) })), (0, jsx_runtime_1.jsx)(OverflowTypography_1.OverflowTypography, { rowsCount: constants_1.DEFAULT_AUTOCOMPLETE_ELEMENT_ROWS_COUNT, ...overflowOption, children: optionProps.key })] }, key));
109
- }, [multiple, overflowOption, externalRenderOption]);
113
+ }, [focusedHelperText, multiple, overflowOption, externalRenderOption]);
110
114
  const renderPopper = (0, react_1.useCallback)((popperProps) => {
111
115
  if (!isPopperVisible) {
112
116
  return null;
@@ -123,6 +127,6 @@ const AutocompleteInner = (props, ref) => {
123
127
  popper: {
124
128
  component: renderPopper,
125
129
  },
126
- }, getOptionLabel: getOptionLabel, renderInput: renderInput, renderTags: renderTags, renderOption: renderOption, value: value, onChange: onChange, ...autocompleteProps }));
130
+ }, renderInput: renderInput, renderTags: renderTags, renderOption: renderOption, value: value, ...autocompleteProps }));
127
131
  };
128
132
  exports.Autocomplete = (0, forwardRefWithGeneric_1.forwardRefWithGeneric)(AutocompleteInner);