@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,6 +1,7 @@
1
1
  export declare const DEFAULT_AUTOCOMPLETE_ELEMENT_ROWS_COUNT = 2;
2
2
  export declare const INPUT_MIN_WIDTH = 110;
3
3
  export declare const DEFAULT_PLACEHOLDER = "\u041D\u0430\u0447\u043D\u0438\u0442\u0435 \u0432\u0432\u043E\u0434\u0438\u0442\u044C \u0434\u043B\u044F \u043F\u043E\u0438\u0441\u043A\u0430";
4
+ export declare const FOCUSED_HELPER_OPTION: unique symbol;
4
5
  export declare const autocompleteClassnames: {
5
6
  root: string;
6
7
  multiple: string;
@@ -1,10 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.autocompleteClassnames = exports.DEFAULT_PLACEHOLDER = exports.INPUT_MIN_WIDTH = exports.DEFAULT_AUTOCOMPLETE_ELEMENT_ROWS_COUNT = void 0;
3
+ exports.autocompleteClassnames = exports.FOCUSED_HELPER_OPTION = exports.DEFAULT_PLACEHOLDER = exports.INPUT_MIN_WIDTH = exports.DEFAULT_AUTOCOMPLETE_ELEMENT_ROWS_COUNT = void 0;
4
4
  const createUIKitClassname_1 = require("../utils/createUIKitClassname");
5
5
  exports.DEFAULT_AUTOCOMPLETE_ELEMENT_ROWS_COUNT = 2;
6
6
  exports.INPUT_MIN_WIDTH = 110;
7
7
  exports.DEFAULT_PLACEHOLDER = 'Начните вводить для поиска';
8
+ exports.FOCUSED_HELPER_OPTION = Symbol('focusedHelperOption');
8
9
  exports.autocompleteClassnames = {
9
10
  root: (0, createUIKitClassname_1.createUIKitClassname)('autocomplete'),
10
11
  multiple: (0, createUIKitClassname_1.createUIKitClassname)('autocomplete_multiple'),
@@ -1,5 +1,9 @@
1
1
  /// <reference types="react" />
2
2
  import MuiAutocomplete from '@mui/material/Autocomplete';
3
+ export declare const StyledFocusedHelperOption: import("@emotion/styled/dist/declarations/src/types").StyledComponent<{
4
+ theme?: import("@emotion/react").Theme | undefined;
5
+ as?: import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> | undefined;
6
+ }, import("react").DetailedHTMLProps<import("react").LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>, {}>;
3
7
  export declare const StyledMenuItem: import("@emotion/styled/dist/declarations/src/types").StyledComponent<import("..").WithoutEmotionSpecific<Omit<import("@mui/material").MenuItemProps, "component">> & {
4
8
  disabledReason?: string | undefined;
5
9
  note?: string | undefined;
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.StyledAutocomplete = exports.StyledMenuItem = void 0;
26
+ exports.StyledAutocomplete = exports.StyledMenuItem = exports.StyledFocusedHelperOption = void 0;
27
27
  const Autocomplete_1 = __importStar(require("@mui/material/Autocomplete"));
28
28
  const FormControl_1 = require("@mui/material/FormControl");
29
29
  const IconButton_1 = require("@mui/material/IconButton");
@@ -33,6 +33,15 @@ const MenuItem_1 = require("../MenuItem");
33
33
  const SvgIcon_1 = require("../SvgIcon");
34
34
  const styled_1 = require("../styled");
35
35
  const constants_2 = require("./constants");
36
+ exports.StyledFocusedHelperOption = styled_1.styled.li `
37
+ &&.${Autocomplete_1.autocompleteClasses.option} {
38
+ display: flex;
39
+ justify-content: center;
40
+ align-items: center;
41
+ height: 48px;
42
+ opacity: 1;
43
+ }
44
+ `;
36
45
  exports.StyledMenuItem = (0, styled_1.styled)(MenuItem_1.MenuItem) `
37
46
  max-height: ${({ theme }) => theme.spacing(13)};
38
47
 
@@ -48,4 +48,8 @@ export type AutocompleteProps<TAutocompleteValueProps, TMultiple extends boolean
48
48
  * Включает/отключает резервирование места под helperText
49
49
  */
50
50
  hideHelperText?: boolean;
51
+ /**
52
+ * Текст подсказки в popover при фокусе
53
+ */
54
+ focusedHelperText?: string;
51
55
  };
@@ -1,16 +1,23 @@
1
- import { type AutocompleteInputChangeReason } from '@mui/material/Autocomplete';
1
+ import { type AutocompleteChangeDetails, type AutocompleteChangeReason, type AutocompleteFreeSoloValueMapping, type AutocompleteInputChangeReason, type AutocompleteValue } from '@mui/material';
2
2
  import { type SyntheticEvent } from 'react';
3
3
  import { type AutocompleteProps } from '../types';
4
4
  type UseLogicParams<TAutocompleteValueProps, TMultiple extends boolean, TDisableClearable extends boolean, TFreeSolo extends boolean> = AutocompleteProps<TAutocompleteValueProps, TMultiple, TDisableClearable, TFreeSolo>;
5
- export declare const useLogic: <TAutocompleteValueProps, TMultiple extends boolean, TDisableClearable extends boolean, TFreeSolo extends boolean>({ value, isOptionEqualToValue: externalOptionEqualToValue, autoHighlight, freeSolo, options, multiple, className, loading, isLoadedDataError, loadedDataError, noOptionsText, onInputChange, }: UseLogicParams<TAutocompleteValueProps, TMultiple, TDisableClearable, TFreeSolo>) => {
5
+ export declare const useLogic: <TAutocompleteValueProps, TMultiple extends boolean, TDisableClearable extends boolean, TFreeSolo extends boolean>({ value, inputValue, getOptionLabel: externalGetOptionLabel, isOptionEqualToValue: externalOptionEqualToValue, getOptionDisabled: externalGetOptionDisabled, filterOptions: externalFilterOptions, groupBy: externalGroupBy, openOnFocus, autoHighlight, freeSolo, options, multiple, className, loading, isLoadedDataError, loadedDataError, noOptionsText, focusedHelperText, onInputChange, onChange, }: UseLogicParams<TAutocompleteValueProps, TMultiple, TDisableClearable, TFreeSolo>) => {
6
6
  isValueEmpty: boolean;
7
- isPopperVisible: boolean | undefined;
7
+ isPopperVisible: boolean;
8
8
  autocompleteProps: {
9
9
  className: string;
10
10
  isOptionEqualToValue: (option: TAutocompleteValueProps, currentValue: TAutocompleteValueProps) => boolean;
11
+ getOptionDisabled: (option: TAutocompleteValueProps) => boolean;
11
12
  autoHighlight: boolean;
12
- noOptionsText: string | number | bigint | boolean | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<import("react").ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<import("react").ReactNode> | null | undefined> | null;
13
+ noOptionsText: string | number | bigint | boolean | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<import("react").ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<import("react").ReactNode> | null | undefined> | null | undefined;
14
+ options: readonly TAutocompleteValueProps[];
15
+ getOptionLabel: (option: TAutocompleteValueProps | AutocompleteFreeSoloValueMapping<TFreeSolo>) => string;
16
+ filterOptions: ((options: TAutocompleteValueProps[], state: import("@mui/material").FilterOptionsState<TAutocompleteValueProps>) => TAutocompleteValueProps[]) | undefined;
17
+ groupBy: ((option: TAutocompleteValueProps) => string) | undefined;
18
+ onChange: (event: SyntheticEvent, newValue: AutocompleteValue<TAutocompleteValueProps, TMultiple, TDisableClearable, TFreeSolo>, reason: AutocompleteChangeReason, details?: AutocompleteChangeDetails<TAutocompleteValueProps> | undefined) => void;
13
19
  onInputChange: (event: SyntheticEvent, currentValue: string, reason: AutocompleteInputChangeReason) => void;
20
+ openOnFocus: boolean;
14
21
  };
15
22
  };
16
23
  export {};
@@ -4,22 +4,81 @@ exports.useLogic = void 0;
4
4
  const react_1 = require("react");
5
5
  const cn_1 = require("../../utils/cn");
6
6
  const constants_1 = require("../constants");
7
- const utils_1 = require("./utils");
8
- const useLogic = ({ value, isOptionEqualToValue: externalOptionEqualToValue, autoHighlight = true, freeSolo, options, multiple, className, loading, isLoadedDataError, loadedDataError = 'Ошибка загрузки данных', noOptionsText = 'Нет данных', onInputChange, }) => {
7
+ const utils_1 = require("../utils");
8
+ const utils_2 = require("./utils");
9
+ const useLogic = ({ value, inputValue, getOptionLabel: externalGetOptionLabel, isOptionEqualToValue: externalOptionEqualToValue, getOptionDisabled: externalGetOptionDisabled, filterOptions: externalFilterOptions, groupBy: externalGroupBy, openOnFocus, autoHighlight = true, freeSolo, options, multiple, className, loading, isLoadedDataError, loadedDataError = 'Ошибка загрузки данных', noOptionsText = 'Нет данных', focusedHelperText, onInputChange, onChange, }) => {
9
10
  const [innerInputValue, setInnerInputValue] = (0, react_1.useState)('');
10
- const isValueEmpty = (0, utils_1.checkIsInputEmpty)(value);
11
- const isInnerInputValueNotEmpty = innerInputValue.length >= 1;
12
- const isOptionsAvailable = options.length > 0;
13
- const isPopperVisible = (loading && isOptionsAvailable) ||
14
- (!loading && !isOptionsAvailable && isInnerInputValueNotEmpty) ||
15
- isOptionsAvailable ||
16
- isLoadedDataError;
11
+ const isValueEmpty = (0, utils_2.checkIsInputEmpty)(value);
12
+ const isInputTextEmpty = (inputValue ?? '').length === 0 && innerInputValue.length === 0;
13
+ const hasOptions = options.length > 0;
14
+ const hasFocusedHelperText = Boolean(focusedHelperText);
15
+ const shouldShowFocusedHelper = hasFocusedHelperText &&
16
+ isInputTextEmpty &&
17
+ !hasOptions &&
18
+ !loading &&
19
+ !isLoadedDataError;
20
+ const isPopperVisible = (0, utils_2.checkIsPopperVisible)({
21
+ loading,
22
+ hasOptions,
23
+ isInputValueNotEmpty: !isInputTextEmpty,
24
+ isLoadedDataError,
25
+ shouldShowFocusedHelper,
26
+ });
27
+ const hasFocusedHelperOption = shouldShowFocusedHelper && Boolean(freeSolo);
28
+ const resolvedNoOptionsText = (0, react_1.useMemo)(() => {
29
+ if (isLoadedDataError) {
30
+ return loadedDataError;
31
+ }
32
+ if (shouldShowFocusedHelper) {
33
+ return focusedHelperText;
34
+ }
35
+ return noOptionsText;
36
+ }, [
37
+ isLoadedDataError,
38
+ loadedDataError,
39
+ shouldShowFocusedHelper,
40
+ focusedHelperText,
41
+ noOptionsText,
42
+ ]);
43
+ const autocompleteOptions = (0, react_1.useMemo)(() => {
44
+ if (hasFocusedHelperOption) {
45
+ return [constants_1.FOCUSED_HELPER_OPTION];
46
+ }
47
+ return options;
48
+ }, [hasFocusedHelperOption, options]);
49
+ const resolveGetOptionLabel = (0, react_1.useCallback)((option) => {
50
+ if ((0, utils_1.checkIsFocusedHelperOption)(option)) {
51
+ return focusedHelperText ?? '';
52
+ }
53
+ if (externalGetOptionLabel) {
54
+ return externalGetOptionLabel(option);
55
+ }
56
+ const optionWithLabel = option;
57
+ return optionWithLabel.label ?? String(option);
58
+ }, [externalGetOptionLabel, focusedHelperText]);
59
+ const handleChange = (0, react_1.useCallback)((event, newValue, reason, details) => {
60
+ if ((0, utils_2.checkIsFocusedHelperChange)(newValue, details?.option)) {
61
+ return;
62
+ }
63
+ onChange?.(event, newValue, reason, details);
64
+ }, [onChange]);
17
65
  const isOptionEqualToValue = (0, react_1.useCallback)((option, currentValue) => {
66
+ if ((0, utils_1.checkIsFocusedHelperOption)(option) ||
67
+ (0, utils_1.checkIsFocusedHelperOption)(currentValue)) {
68
+ return false;
69
+ }
18
70
  if (externalOptionEqualToValue) {
19
71
  return externalOptionEqualToValue(option, currentValue);
20
72
  }
21
73
  return JSON.stringify(option) === JSON.stringify(currentValue);
22
74
  }, [externalOptionEqualToValue]);
75
+ const resolveGetOptionDisabled = (0, react_1.useCallback)((option) => {
76
+ if ((0, utils_1.checkIsFocusedHelperOption)(option)) {
77
+ return true;
78
+ }
79
+ return externalGetOptionDisabled?.(option) ?? false;
80
+ }, [externalGetOptionDisabled]);
81
+ const resolvedOpenOnFocus = hasFocusedHelperText || Boolean(openOnFocus);
23
82
  const handleInputChange = (event, currentValue, reason) => {
24
83
  onInputChange?.(event, currentValue, reason);
25
84
  if (!loading) {
@@ -31,16 +90,23 @@ const useLogic = ({ value, isOptionEqualToValue: externalOptionEqualToValue, aut
31
90
  [constants_1.autocompleteClassnames.multiple]: multiple,
32
91
  [constants_1.autocompleteClassnames.emptyValue]: isValueEmpty,
33
92
  });
34
- }, [multiple, isValueEmpty]);
93
+ }, [className, multiple, isValueEmpty]);
35
94
  return {
36
95
  isValueEmpty,
37
96
  isPopperVisible,
38
97
  autocompleteProps: {
39
98
  className: classnames,
40
99
  isOptionEqualToValue,
100
+ getOptionDisabled: resolveGetOptionDisabled,
41
101
  autoHighlight: freeSolo ? false : autoHighlight,
42
- noOptionsText: isLoadedDataError ? loadedDataError : noOptionsText,
102
+ noOptionsText: resolvedNoOptionsText,
103
+ options: autocompleteOptions,
104
+ getOptionLabel: resolveGetOptionLabel,
105
+ filterOptions: hasFocusedHelperOption ? undefined : externalFilterOptions,
106
+ groupBy: hasFocusedHelperOption ? undefined : externalGroupBy,
107
+ onChange: handleChange,
43
108
  onInputChange: handleInputChange,
109
+ openOnFocus: resolvedOpenOnFocus,
44
110
  },
45
111
  };
46
112
  };
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Проверяет, является ли значение при onChange focusedHelper-опцией (freeSolo)
3
+ */
4
+ export declare const checkIsFocusedHelperChange: (newValue: unknown, changedOption?: unknown) => boolean;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.checkIsFocusedHelperChange = void 0;
4
+ const utils_1 = require("../../../utils");
5
+ /**
6
+ * Проверяет, является ли значение при onChange focusedHelper-опцией (freeSolo)
7
+ */
8
+ const checkIsFocusedHelperChange = (newValue, changedOption) => {
9
+ if ((0, utils_1.checkIsFocusedHelperOption)(changedOption)) {
10
+ return true;
11
+ }
12
+ if ((0, utils_1.checkIsFocusedHelperOption)(newValue)) {
13
+ return true;
14
+ }
15
+ if (Array.isArray(newValue) &&
16
+ newValue.some((item) => (0, utils_1.checkIsFocusedHelperOption)(item))) {
17
+ return true;
18
+ }
19
+ return false;
20
+ };
21
+ exports.checkIsFocusedHelperChange = checkIsFocusedHelperChange;
@@ -0,0 +1 @@
1
+ export * from './checkIsFocusedHelperChange';
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./checkIsFocusedHelperChange"), exports);
@@ -0,0 +1,8 @@
1
+ export type CheckIsPopperVisibleParams = {
2
+ loading?: boolean;
3
+ hasOptions: boolean;
4
+ isInputValueNotEmpty: boolean;
5
+ isLoadedDataError?: boolean;
6
+ shouldShowFocusedHelper: boolean;
7
+ };
8
+ export declare const checkIsPopperVisible: ({ loading, hasOptions, isInputValueNotEmpty, isLoadedDataError, shouldShowFocusedHelper, }: CheckIsPopperVisibleParams) => boolean;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.checkIsPopperVisible = void 0;
4
+ const checkIsPopperVisible = ({ loading = false, hasOptions, isInputValueNotEmpty, isLoadedDataError = false, shouldShowFocusedHelper, }) => {
5
+ if (shouldShowFocusedHelper || hasOptions || isLoadedDataError) {
6
+ return true;
7
+ }
8
+ return !loading && isInputValueNotEmpty;
9
+ };
10
+ exports.checkIsPopperVisible = checkIsPopperVisible;
@@ -0,0 +1 @@
1
+ export { checkIsPopperVisible, type CheckIsPopperVisibleParams, } from './checkIsPopperVisible';
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.checkIsPopperVisible = void 0;
4
+ var checkIsPopperVisible_1 = require("./checkIsPopperVisible");
5
+ Object.defineProperty(exports, "checkIsPopperVisible", { enumerable: true, get: function () { return checkIsPopperVisible_1.checkIsPopperVisible; } });
@@ -1 +1,3 @@
1
1
  export * from './checkIsInputEmpty';
2
+ export * from './checkIsPopperVisible';
3
+ export * from './checkIsFocusedHelperChange';
@@ -15,3 +15,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./checkIsInputEmpty"), exports);
18
+ __exportStar(require("./checkIsPopperVisible"), exports);
19
+ __exportStar(require("./checkIsFocusedHelperChange"), exports);
@@ -0,0 +1,5 @@
1
+ import { FOCUSED_HELPER_OPTION } from '../../constants';
2
+ /**
3
+ * Определяет, является ли опция специальной опцией для отображения focusedHelperText при freeSolo=true
4
+ */
5
+ export declare const checkIsFocusedHelperOption: (option: unknown) => option is typeof FOCUSED_HELPER_OPTION;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.checkIsFocusedHelperOption = void 0;
4
+ const constants_1 = require("../../constants");
5
+ /**
6
+ * Определяет, является ли опция специальной опцией для отображения focusedHelperText при freeSolo=true
7
+ */
8
+ const checkIsFocusedHelperOption = (option) => {
9
+ return option === constants_1.FOCUSED_HELPER_OPTION;
10
+ };
11
+ exports.checkIsFocusedHelperOption = checkIsFocusedHelperOption;
@@ -0,0 +1 @@
1
+ export * from './checkIsFocusedHelperOption';
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./checkIsFocusedHelperOption"), exports);
@@ -0,0 +1 @@
1
+ export * from './checkIsFocusedHelperOption';
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./checkIsFocusedHelperOption"), exports);
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- export declare const StepPopover: import("@emotion/styled/dist/declarations/src/types").StyledComponent<Omit<import("../../../../../NewPopover").NewPopoverProps, "title" | "disableMobileDrawer" | "hasArrow"> & {
2
+ export declare const StepPopover: import("@emotion/styled/dist/declarations/src/types").StyledComponent<Omit<import("../../../../../NewPopover").NewPopoverProps, "title" | "hasArrow" | "disableMobileDrawer"> & {
3
3
  variant?: import("../../../../../HintPopover").HintPopoverVariant | undefined;
4
4
  title?: import("react").ReactNode;
5
5
  action?: import("react").ReactNode;
@@ -24,7 +24,7 @@ const styles_1 = require("./styles");
24
24
  const useLogic_1 = require("./useLogic");
25
25
  const ClearButton = (0, react_1.forwardRef)(({ onClick, disabled }, ref) => ((0, jsx_runtime_1.jsx)(IconButton_1.IconButton, { disabled: disabled, ref: ref, onClick: onClick, variant: "text", title: constants_1.CLEAR_TEXT, "aria-label": constants_1.CLEAR_TEXT, children: (0, jsx_runtime_1.jsx)(CrossOutlineMd_1.CrossOutlineMd, {}) })));
26
26
  const SelectInner = ({ required, getOptionLabel, placeholder, helperText, hideHelperText = false, loading, success, children, disabled, error, label, fullWidth, onChange: externalOnChange, isShowClearButton, isEnableAllSelection = false, valueOptions, value, onSelectAll, onUnselectAll, ...props }, ref) => {
27
- const { isOpened, isShowingClearButton, isNoData, onClearAll, openSelect, closeSelect, resetButtonRef, isShowingSelectAll, handleChangeOption, isSelectedAll, isIndeterminate, handleChangeArrayValue, selectAllClassName, findMenuItemsLabel, isShowingPlaceholder, } = (0, useLogic_1.useLogic)({
27
+ const { isOpened, isShowingClearButton, isNoData, onClearAll, openSelect, closeSelect, resetButtonRef, isShowingSelectAll, handleChangeOption, isSelectedAll, isIndeterminate, handleChangeArrayValue, selectAllClassName, findMenuItemsLabel, isShowingPlaceholder, fieldRef, } = (0, useLogic_1.useLogic)({
28
28
  ...props,
29
29
  children,
30
30
  value,
@@ -36,11 +36,12 @@ const SelectInner = ({ required, getOptionLabel, placeholder, helperText, hideHe
36
36
  onSelectAll,
37
37
  onUnselectAll,
38
38
  loading,
39
+ ref,
39
40
  });
40
41
  const renderValue = (selectedOptions) => {
41
42
  // Массив с выбранными опциями
42
43
  if (Array.isArray(selectedOptions) && selectedOptions.length) {
43
- return ((0, jsx_runtime_1.jsx)(TagsList_1.TagsList, { data: selectedOptions, getOptionLabel: getOptionLabel || ((optionLabel) => optionLabel), onChange: handleChangeArrayValue, onClick: openSelect }));
44
+ return ((0, jsx_runtime_1.jsx)(TagsList_1.TagsList, { data: selectedOptions, getOptionLabel: getOptionLabel || ((optionLabel) => optionLabel), fieldRef: fieldRef, onChange: handleChangeArrayValue, onClick: openSelect }));
44
45
  }
45
46
  // Пустой массив или пустая строка
46
47
  if ((Array.isArray(selectedOptions) || typeof selectedOptions === 'string') &&
@@ -53,6 +54,6 @@ const SelectInner = ({ required, getOptionLabel, placeholder, helperText, hideHe
53
54
  }
54
55
  return findMenuItemsLabel(children, selectedOptions);
55
56
  };
56
- return ((0, jsx_runtime_1.jsxs)(FormControl_1.default, { error: error, fullWidth: fullWidth, children: [label && ((0, jsx_runtime_1.jsx)(InputLabel_1.default, { htmlFor: "grouped-select", required: required, disabled: disabled, children: label })), (0, jsx_runtime_1.jsxs)(styles_1.StyledSelect, { ...props, value: value === null || value === undefined ? '' : value, open: isOpened, disabled: disabled, onOpen: openSelect, onClose: closeSelect, renderValue: renderValue, IconComponent: () => null, displayEmpty: true, ref: ref, fullWidth: fullWidth, onChange: handleChangeOption, "$isShowingPlaceholder": isShowingPlaceholder, endAdornment: (0, jsx_runtime_1.jsxs)(styles_1.EndAdornmentWrapper, { children: [loading && (0, jsx_runtime_1.jsx)(Loader_1.Loader, { color: "primary", size: "small" }), !loading && isShowingClearButton && ((0, jsx_runtime_1.jsx)(ClearButton, { disabled: disabled, ref: resetButtonRef, onClick: onClearAll })), !loading && ((0, jsx_runtime_1.jsx)(IconButton_1.IconButton, { variant: "text", disabled: disabled, onClick: openSelect, children: !isOpened ? (0, jsx_runtime_1.jsx)(DownOutlineMd_1.DownOutlineMd, {}) : (0, jsx_runtime_1.jsx)(UpOutlineMd_1.UpOutlineMd, {}) }))] }), children: [(0, jsx_runtime_1.jsx)(styles_1.Placeholder, { value: "", children: placeholder }), !loading && isShowingSelectAll && ((0, jsx_runtime_1.jsxs)(MenuItem_1.MenuItem, { className: selectAllClassName, selected: isSelectedAll, value: constants_1.SELECT_ALL_VALUE, children: [(0, jsx_runtime_1.jsx)(ListItemIcon_1.default, { children: (0, jsx_runtime_1.jsx)(Checkbox_1.Checkbox, { checked: isSelectedAll, indeterminate: isIndeterminate }) }), "\u0412\u044B\u0431\u0440\u0430\u0442\u044C \u0432\u0441\u0435"] })), !loading && children, !loading && isNoData && (0, jsx_runtime_1.jsx)(styles_1.StateWrapper, { children: "\u041D\u0435\u0442 \u0434\u0430\u043D\u043D\u044B\u0445" })] }), (0, jsx_runtime_1.jsx)(FormHelperText_1.FormHelperText, { error: error, success: success, hideHelperText: hideHelperText, children: helperText })] }));
57
+ return ((0, jsx_runtime_1.jsxs)(FormControl_1.default, { error: error, fullWidth: fullWidth, children: [label && ((0, jsx_runtime_1.jsx)(InputLabel_1.default, { htmlFor: "grouped-select", required: required, disabled: disabled, children: label })), (0, jsx_runtime_1.jsxs)(styles_1.StyledSelect, { ...props, value: value === null || value === undefined ? '' : value, open: isOpened, disabled: disabled, onOpen: openSelect, onClose: closeSelect, renderValue: renderValue, IconComponent: () => null, displayEmpty: true, ref: fieldRef, fullWidth: fullWidth, onChange: handleChangeOption, "$isShowingPlaceholder": isShowingPlaceholder, endAdornment: (0, jsx_runtime_1.jsxs)(styles_1.EndAdornmentWrapper, { children: [loading && (0, jsx_runtime_1.jsx)(Loader_1.Loader, { color: "primary", size: "small" }), !loading && isShowingClearButton && ((0, jsx_runtime_1.jsx)(ClearButton, { disabled: disabled, ref: resetButtonRef, onClick: onClearAll })), !loading && ((0, jsx_runtime_1.jsx)(IconButton_1.IconButton, { variant: "text", disabled: disabled, onClick: openSelect, children: !isOpened ? (0, jsx_runtime_1.jsx)(DownOutlineMd_1.DownOutlineMd, {}) : (0, jsx_runtime_1.jsx)(UpOutlineMd_1.UpOutlineMd, {}) }))] }), children: [(0, jsx_runtime_1.jsx)(styles_1.Placeholder, { value: "", children: placeholder }), !loading && isShowingSelectAll && ((0, jsx_runtime_1.jsxs)(MenuItem_1.MenuItem, { className: selectAllClassName, selected: isSelectedAll, value: constants_1.SELECT_ALL_VALUE, children: [(0, jsx_runtime_1.jsx)(ListItemIcon_1.default, { children: (0, jsx_runtime_1.jsx)(Checkbox_1.Checkbox, { checked: isSelectedAll, indeterminate: isIndeterminate }) }), "\u0412\u044B\u0431\u0440\u0430\u0442\u044C \u0432\u0441\u0435"] })), !loading && children, !loading && isNoData && (0, jsx_runtime_1.jsx)(styles_1.StateWrapper, { children: "\u041D\u0435\u0442 \u0434\u0430\u043D\u043D\u044B\u0445" })] }), (0, jsx_runtime_1.jsx)(FormHelperText_1.FormHelperText, { error: error, success: success, hideHelperText: hideHelperText, children: helperText })] }));
57
58
  };
58
59
  exports.Select = (0, forwardRefWithGeneric_1.forwardRefWithGeneric)(SelectInner);
@@ -1,6 +1,13 @@
1
- import { type ReactNode, type SyntheticEvent } from 'react';
1
+ import { type ForwardedRef, type ReactNode, type SyntheticEvent } from 'react';
2
2
  import { type SelectProps } from '../types';
3
- export declare const useLogic: <TValue>({ value, onChange, children, open: externalIsOpened, defaultOpen, multiple, isEnableAllSelection, isShowClearButton, valueOptions, onSelectAll, onUnselectAll, name, placeholder, onClose, onOpen, loading, }: SelectProps<TValue>) => {
3
+ type UseLogicParams<TValue> = Omit<SelectProps<TValue>, 'ref'> & {
4
+ /**
5
+ * Ref, пробрасываемый на контейнер поля: по нему считается ширина
6
+ * всплывающего окна тэгов и он служит якорем его позиционирования
7
+ */
8
+ ref: ForwardedRef<HTMLDivElement>;
9
+ };
10
+ export declare const useLogic: <TValue>({ value, onChange, children, open: externalIsOpened, defaultOpen, multiple, isEnableAllSelection, isShowClearButton, valueOptions, onSelectAll, onUnselectAll, name, placeholder, onClose, onOpen, loading, ref, }: UseLogicParams<TValue>) => {
4
11
  isOpened: boolean;
5
12
  isNoData: boolean;
6
13
  isShowingClearButton: boolean;
@@ -17,4 +24,6 @@ export declare const useLogic: <TValue>({ value, onChange, children, open: exter
17
24
  selectAllClassName: string | undefined;
18
25
  findMenuItemsLabel: (nodes: ReactNode, selectedValue: TValue) => ReactNode;
19
26
  isShowingPlaceholder: boolean;
27
+ fieldRef: import("react").RefObject<HTMLDivElement | null>;
20
28
  };
29
+ export {};
@@ -4,12 +4,14 @@ exports.useLogic = void 0;
4
4
  const MenuItem_1 = require("@mui/material/MenuItem");
5
5
  const react_1 = require("react");
6
6
  const MenuItem_2 = require("../../MenuItem");
7
+ const useForwardedRef_1 = require("../../useForwardedRef");
7
8
  const getNodeText_1 = require("../../utils/getNodeText");
8
9
  const isSyncReactElement_1 = require("../../utils/isSyncReactElement");
9
10
  const constants_1 = require("../constants");
10
11
  const isShowingPlaceholder_1 = require("./utils/isShowingPlaceholder");
11
- const useLogic = ({ value, onChange, children, open: externalIsOpened, defaultOpen, multiple, isEnableAllSelection, isShowClearButton = true, valueOptions, onSelectAll, onUnselectAll, name, placeholder, onClose, onOpen, loading, }) => {
12
+ const useLogic = ({ value, onChange, children, open: externalIsOpened, defaultOpen, multiple, isEnableAllSelection, isShowClearButton = true, valueOptions, onSelectAll, onUnselectAll, name, placeholder, onClose, onOpen, loading, ref, }) => {
12
13
  const [isOpened, setOpened] = (0, react_1.useState)(!loading && (defaultOpen || externalIsOpened || false));
14
+ const fieldRef = (0, useForwardedRef_1.useForwardedRef)(ref);
13
15
  const resetButtonRef = (0, react_1.useRef)(null);
14
16
  const optionsLength = Array.isArray(valueOptions)
15
17
  ? valueOptions?.length
@@ -132,6 +134,7 @@ const useLogic = ({ value, onChange, children, open: externalIsOpened, defaultOp
132
134
  selectAllClassName,
133
135
  findMenuItemsLabel,
134
136
  isShowingPlaceholder: (0, isShowingPlaceholder_1.isShowingPlaceholder)(value, placeholder),
137
+ fieldRef,
135
138
  };
136
139
  };
137
140
  exports.useLogic = useLogic;
@@ -0,0 +1,7 @@
1
+ import type { TagValue } from '../types';
2
+ import { type PopoverTagsProps } from './types';
3
+ /**
4
+ * Показывает все выбранные элементы тэгами с переносом по строкам.
5
+ * Используется как содержимое всплывающего окна TagsList
6
+ */
7
+ export declare const PopoverTags: <TData extends TagValue>({ data, keyId, isDisabled, getOptionLabel, getTagProps, }: PopoverTagsProps<TData>) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PopoverTags = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const utils_1 = require("../utils");
6
+ const styles_1 = require("./styles");
7
+ /**
8
+ * Показывает все выбранные элементы тэгами с переносом по строкам.
9
+ * Используется как содержимое всплывающего окна TagsList
10
+ */
11
+ const PopoverTags = ({ data, keyId, isDisabled, getOptionLabel, getTagProps, }) => ((0, jsx_runtime_1.jsx)(styles_1.Wrapper, { children: data.map((option) => ((0, jsx_runtime_1.jsx)(styles_1.StyledTag, { isDisabled: isDisabled, ...getTagProps(option) }, (0, utils_1.getKey)(option, keyId, getOptionLabel)))) }));
12
+ exports.PopoverTags = PopoverTags;
@@ -0,0 +1,2 @@
1
+ export * from './PopoverTags';
2
+ export * from './types';
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./PopoverTags"), exports);
18
+ __exportStar(require("./types"), exports);
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+ export declare const Wrapper: import("@emotion/styled/dist/declarations/src/types").StyledComponent<{
3
+ theme?: import("@emotion/react").Theme | undefined;
4
+ as?: import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> | undefined;
5
+ }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
6
+ export declare const StyledTag: import("@emotion/styled/dist/declarations/src/types").StyledComponent<import("../Tag").TagProps & import("react").RefAttributes<HTMLDivElement> & {
7
+ theme?: import("@emotion/react").Theme | undefined;
8
+ }, {}, {}>;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StyledTag = exports.Wrapper = void 0;
4
+ const styled_1 = require("../../styled");
5
+ const constants_1 = require("../constants");
6
+ const Tag_1 = require("../Tag");
7
+ exports.Wrapper = styled_1.styled.div `
8
+ overflow-y: auto;
9
+ display: flex;
10
+ flex-wrap: wrap;
11
+ gap: ${({ theme }) => theme.spacing(constants_1.POPOVER_TAGS_GAP_SPACING)};
12
+
13
+ max-height: ${constants_1.POPOVER_MAX_HEIGHT}px;
14
+ padding-inline: ${({ theme }) => theme.spacing(constants_1.POPOVER_TAGS_PADDING_SPACING)};
15
+ `;
16
+ exports.StyledTag = (0, styled_1.styled)(Tag_1.Tag) `
17
+ max-width: 100%;
18
+ `;
@@ -0,0 +1,24 @@
1
+ import { type TagProps } from '../Tag';
2
+ import { type TagValue } from '../types';
3
+ export type PopoverTagsProps<TData extends TagValue = TagValue> = {
4
+ /**
5
+ * Полный список выбранных элементов
6
+ */
7
+ data: TData[];
8
+ /**
9
+ * Поле, используемое в качестве ключа списка
10
+ */
11
+ keyId?: TData extends object ? keyof TData : never;
12
+ /**
13
+ * Если `true`, то тэги будут недоступны для взаимодействия
14
+ */
15
+ isDisabled?: boolean;
16
+ /**
17
+ * Используется для определения строкового значения опции
18
+ */
19
+ getOptionLabel: (value: TData) => string | number;
20
+ /**
21
+ * Возвращает пропсы тэга, включая обработчик удаления
22
+ */
23
+ getTagProps: (option: TData) => Pick<TagProps, 'label' | 'onDelete'>;
24
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -21,9 +21,17 @@ export type TagProps = {
21
21
  * Хендлер клика по тегу
22
22
  */
23
23
  onClick?: (value: MouseEvent<HTMLDivElement>) => void;
24
+ /**
25
+ * Хендлер наведения указателя на тег
26
+ */
27
+ onMouseEnter?: (value: MouseEvent<HTMLDivElement>) => void;
28
+ /**
29
+ * Хендлер увода указателя с тега
30
+ */
31
+ onMouseLeave?: (value: MouseEvent<HTMLDivElement>) => void;
24
32
  /**
25
33
  * Название класса, применяется к корневому компоненту
26
34
  */
27
35
  className?: string;
28
36
  };
29
- export declare const Tag: (props: TagProps) => import("react/jsx-runtime").JSX.Element;
37
+ export declare const Tag: import("react").ForwardRefExoticComponent<TagProps & import("react").RefAttributes<HTMLDivElement>>;
@@ -2,12 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Tag = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
5
6
  const OverflowTypography_1 = require("../../OverflowTypography");
6
7
  const styles_1 = require("./styles");
7
8
  const useLogic_1 = require("./useLogic");
8
- const Tag = (props) => {
9
+ exports.Tag = (0, react_1.forwardRef)((props, ref) => {
9
10
  const { onMouseDown } = (0, useLogic_1.useLogic)();
10
11
  const { shrinks, isDisabled, label, ...restProps } = props;
11
- return ((0, jsx_runtime_1.jsx)(styles_1.StyledTag, { "$shrinks": shrinks, color: "grey", variant: "light", disabled: isDisabled, label: (0, jsx_runtime_1.jsx)(OverflowTypography_1.OverflowTypography, { children: label }), ...restProps, onMouseDown: onMouseDown }));
12
- };
13
- exports.Tag = Tag;
12
+ return ((0, jsx_runtime_1.jsx)(styles_1.StyledTag, { ref: ref, "$shrinks": shrinks, color: "grey", variant: "light", disabled: isDisabled, label: (0, jsx_runtime_1.jsx)(OverflowTypography_1.OverflowTypography, { children: label }), ...restProps, onMouseDown: onMouseDown }));
13
+ });