@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.
- package/components/AsyncAutocomplete/useLogic/useLogic.d.ts +1 -0
- package/components/Autocomplete/Autocomplete.d.ts +1 -0
- package/components/Autocomplete/Autocomplete.js +12 -8
- package/components/Autocomplete/constants.d.ts +1 -0
- package/components/Autocomplete/constants.js +1 -0
- package/components/Autocomplete/styles.d.ts +4 -0
- package/components/Autocomplete/styles.js +9 -0
- package/components/Autocomplete/types.d.ts +4 -0
- package/components/Autocomplete/useLogic/useLogic.d.ts +11 -4
- package/components/Autocomplete/useLogic/useLogic.js +77 -11
- package/components/Autocomplete/useLogic/utils/checkIsFocusedHelperChange/checkIsFocusedHelperChange.d.ts +4 -0
- package/components/Autocomplete/useLogic/utils/checkIsFocusedHelperChange/checkIsFocusedHelperChange.js +17 -0
- package/components/Autocomplete/useLogic/utils/checkIsFocusedHelperChange/index.d.ts +1 -0
- package/components/Autocomplete/useLogic/utils/checkIsFocusedHelperChange/index.js +1 -0
- package/components/Autocomplete/useLogic/utils/checkIsPopperVisible/checkIsPopperVisible.d.ts +8 -0
- package/components/Autocomplete/useLogic/utils/checkIsPopperVisible/checkIsPopperVisible.js +6 -0
- package/components/Autocomplete/useLogic/utils/checkIsPopperVisible/index.d.ts +1 -0
- package/components/Autocomplete/useLogic/utils/checkIsPopperVisible/index.js +1 -0
- package/components/Autocomplete/useLogic/utils/index.d.ts +2 -0
- package/components/Autocomplete/useLogic/utils/index.js +2 -0
- package/components/Autocomplete/utils/checkIsFocusedHelperOption/checkIsFocusedHelperOption.d.ts +5 -0
- package/components/Autocomplete/utils/checkIsFocusedHelperOption/checkIsFocusedHelperOption.js +7 -0
- package/components/Autocomplete/utils/checkIsFocusedHelperOption/index.d.ts +1 -0
- package/components/Autocomplete/utils/checkIsFocusedHelperOption/index.js +1 -0
- package/components/Autocomplete/utils/index.d.ts +1 -0
- package/components/Autocomplete/utils/index.js +1 -0
- package/components/Onboarding/ui/StepStrategy/steps/HighlightStep/styles.d.ts +1 -1
- package/components/Select/Select.js +4 -3
- package/components/Select/useLogic/useLogic.d.ts +11 -2
- package/components/Select/useLogic/useLogic.js +4 -1
- package/components/TagsList/PopoverTags/PopoverTags.d.ts +7 -0
- package/components/TagsList/PopoverTags/PopoverTags.js +8 -0
- package/components/TagsList/PopoverTags/index.d.ts +2 -0
- package/components/TagsList/PopoverTags/index.js +2 -0
- package/components/TagsList/PopoverTags/styles.d.ts +8 -0
- package/components/TagsList/PopoverTags/styles.js +15 -0
- package/components/TagsList/PopoverTags/types.d.ts +24 -0
- package/components/TagsList/PopoverTags/types.js +1 -0
- package/components/TagsList/Tag/Tag.d.ts +9 -1
- package/components/TagsList/Tag/Tag.js +4 -3
- package/components/TagsList/TagsList.js +11 -5
- package/components/TagsList/constants.d.ts +35 -0
- package/components/TagsList/constants.js +35 -0
- package/components/TagsList/styles.d.ts +9 -1
- package/components/TagsList/styles.js +20 -1
- package/components/TagsList/types.d.ts +4 -0
- package/components/TagsList/useLogic/hooks/index.d.ts +1 -0
- package/components/TagsList/useLogic/hooks/index.js +1 -0
- package/components/TagsList/useLogic/hooks/useHoverDelay/index.d.ts +1 -0
- package/components/TagsList/useLogic/hooks/useHoverDelay/index.js +1 -0
- package/components/TagsList/useLogic/hooks/useHoverDelay/types.d.ts +20 -0
- package/components/TagsList/useLogic/hooks/useHoverDelay/types.js +1 -0
- package/components/TagsList/useLogic/hooks/useHoverDelay/useHoverDelay.d.ts +5 -0
- package/components/TagsList/useLogic/hooks/useHoverDelay/useHoverDelay.js +27 -0
- package/components/TagsList/useLogic/useLogic.d.ts +14 -2
- package/components/TagsList/useLogic/useLogic.js +84 -4
- package/components/TagsList/utils/calculatePopoverWidth/calculatePopoverWidth.d.ts +5 -0
- package/components/TagsList/utils/calculatePopoverWidth/calculatePopoverWidth.js +22 -0
- package/components/TagsList/utils/calculatePopoverWidth/index.d.ts +1 -0
- package/components/TagsList/utils/calculatePopoverWidth/index.js +1 -0
- package/components/TagsList/utils/index.d.ts +1 -0
- package/components/TagsList/utils/index.js +1 -0
- package/components/TreeLikeAsyncAutocomplete/Input/Input.js +3 -2
- package/components/TreeLikeAsyncAutocomplete/Input/useLogic/useLogic.d.ts +3 -2
- package/components/TreeLikeAsyncAutocomplete/Input/useLogic/useLogic.js +3 -1
- package/components/TreeLikeAutocomplete/Input/Input.js +2 -2
- package/components/TreeLikeAutocomplete/Input/useLogic/useLogic.d.ts +2 -1
- package/components/TreeLikeAutocomplete/Input/useLogic/useLogic.js +3 -1
- package/node/components/AsyncAutocomplete/useLogic/useLogic.d.ts +1 -0
- package/node/components/Autocomplete/Autocomplete.d.ts +1 -0
- package/node/components/Autocomplete/Autocomplete.js +11 -7
- package/node/components/Autocomplete/constants.d.ts +1 -0
- package/node/components/Autocomplete/constants.js +2 -1
- package/node/components/Autocomplete/styles.d.ts +4 -0
- package/node/components/Autocomplete/styles.js +10 -1
- package/node/components/Autocomplete/types.d.ts +4 -0
- package/node/components/Autocomplete/useLogic/useLogic.d.ts +11 -4
- package/node/components/Autocomplete/useLogic/useLogic.js +77 -11
- package/node/components/Autocomplete/useLogic/utils/checkIsFocusedHelperChange/checkIsFocusedHelperChange.d.ts +4 -0
- package/node/components/Autocomplete/useLogic/utils/checkIsFocusedHelperChange/checkIsFocusedHelperChange.js +21 -0
- package/node/components/Autocomplete/useLogic/utils/checkIsFocusedHelperChange/index.d.ts +1 -0
- package/node/components/Autocomplete/useLogic/utils/checkIsFocusedHelperChange/index.js +17 -0
- package/node/components/Autocomplete/useLogic/utils/checkIsPopperVisible/checkIsPopperVisible.d.ts +8 -0
- package/node/components/Autocomplete/useLogic/utils/checkIsPopperVisible/checkIsPopperVisible.js +10 -0
- package/node/components/Autocomplete/useLogic/utils/checkIsPopperVisible/index.d.ts +1 -0
- package/node/components/Autocomplete/useLogic/utils/checkIsPopperVisible/index.js +5 -0
- package/node/components/Autocomplete/useLogic/utils/index.d.ts +2 -0
- package/node/components/Autocomplete/useLogic/utils/index.js +2 -0
- package/node/components/Autocomplete/utils/checkIsFocusedHelperOption/checkIsFocusedHelperOption.d.ts +5 -0
- package/node/components/Autocomplete/utils/checkIsFocusedHelperOption/checkIsFocusedHelperOption.js +11 -0
- package/node/components/Autocomplete/utils/checkIsFocusedHelperOption/index.d.ts +1 -0
- package/node/components/Autocomplete/utils/checkIsFocusedHelperOption/index.js +17 -0
- package/node/components/Autocomplete/utils/index.d.ts +1 -0
- package/node/components/Autocomplete/utils/index.js +17 -0
- package/node/components/Onboarding/ui/StepStrategy/steps/HighlightStep/styles.d.ts +1 -1
- package/node/components/Select/Select.js +4 -3
- package/node/components/Select/useLogic/useLogic.d.ts +11 -2
- package/node/components/Select/useLogic/useLogic.js +4 -1
- package/node/components/TagsList/PopoverTags/PopoverTags.d.ts +7 -0
- package/node/components/TagsList/PopoverTags/PopoverTags.js +12 -0
- package/node/components/TagsList/PopoverTags/index.d.ts +2 -0
- package/node/components/TagsList/PopoverTags/index.js +18 -0
- package/node/components/TagsList/PopoverTags/styles.d.ts +8 -0
- package/node/components/TagsList/PopoverTags/styles.js +18 -0
- package/node/components/TagsList/PopoverTags/types.d.ts +24 -0
- package/node/components/TagsList/PopoverTags/types.js +2 -0
- package/node/components/TagsList/Tag/Tag.d.ts +9 -1
- package/node/components/TagsList/Tag/Tag.js +4 -4
- package/node/components/TagsList/TagsList.js +10 -4
- package/node/components/TagsList/constants.d.ts +35 -0
- package/node/components/TagsList/constants.js +36 -1
- package/node/components/TagsList/styles.d.ts +9 -1
- package/node/components/TagsList/styles.js +20 -1
- package/node/components/TagsList/types.d.ts +4 -0
- package/node/components/TagsList/useLogic/hooks/index.d.ts +1 -0
- package/node/components/TagsList/useLogic/hooks/index.js +17 -0
- package/node/components/TagsList/useLogic/hooks/useHoverDelay/index.d.ts +1 -0
- package/node/components/TagsList/useLogic/hooks/useHoverDelay/index.js +17 -0
- package/node/components/TagsList/useLogic/hooks/useHoverDelay/types.d.ts +20 -0
- package/node/components/TagsList/useLogic/hooks/useHoverDelay/types.js +2 -0
- package/node/components/TagsList/useLogic/hooks/useHoverDelay/useHoverDelay.d.ts +5 -0
- package/node/components/TagsList/useLogic/hooks/useHoverDelay/useHoverDelay.js +31 -0
- package/node/components/TagsList/useLogic/useLogic.d.ts +14 -2
- package/node/components/TagsList/useLogic/useLogic.js +81 -1
- package/node/components/TagsList/utils/calculatePopoverWidth/calculatePopoverWidth.d.ts +5 -0
- package/node/components/TagsList/utils/calculatePopoverWidth/calculatePopoverWidth.js +26 -0
- package/node/components/TagsList/utils/calculatePopoverWidth/index.d.ts +1 -0
- package/node/components/TagsList/utils/calculatePopoverWidth/index.js +17 -0
- package/node/components/TagsList/utils/index.d.ts +1 -0
- package/node/components/TagsList/utils/index.js +3 -1
- package/node/components/TreeLikeAsyncAutocomplete/Input/Input.js +3 -2
- package/node/components/TreeLikeAsyncAutocomplete/Input/useLogic/useLogic.d.ts +3 -2
- package/node/components/TreeLikeAsyncAutocomplete/Input/useLogic/useLogic.js +3 -1
- package/node/components/TreeLikeAutocomplete/Input/Input.js +2 -2
- package/node/components/TreeLikeAutocomplete/Input/useLogic/useLogic.d.ts +2 -1
- package/node/components/TreeLikeAutocomplete/Input/useLogic/useLogic.js +3 -1
- package/package.json +1 -1
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TagsList = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const CrossOutlineMd_1 = require("../../icons/CrossOutlineMd");
|
|
6
|
+
const IconButton_1 = require("../IconButton");
|
|
7
|
+
const NewPopover_1 = require("../NewPopover");
|
|
8
|
+
const Typography_1 = require("../Typography");
|
|
9
|
+
const constants_1 = require("./constants");
|
|
10
|
+
const PopoverTags_1 = require("./PopoverTags");
|
|
5
11
|
const styles_1 = require("./styles");
|
|
6
12
|
const Tag_1 = require("./Tag");
|
|
7
13
|
const useLogic_1 = require("./useLogic");
|
|
@@ -11,11 +17,11 @@ const utils_1 = require("./utils");
|
|
|
11
17
|
* Не предназначен для использования в продуктах, не экспортируется из пакета
|
|
12
18
|
*/
|
|
13
19
|
const TagsList = (props) => {
|
|
14
|
-
const { hiddenCount, tagsContainerRef, visibleOptions, getTagProps, showCounter, } = (0, useLogic_1.useLogic)(props);
|
|
15
|
-
const { className, keyId, isDisabled,
|
|
20
|
+
const { hiddenCount, tagsContainerRef, counterRef, visibleOptions, getTagProps, showCounter, isPopoverOpen, isPopoverEnabled, setPopoverContentRef, popoverContentCssVars, stopPopoverEventPropagation, popoverAnchorEl, closePopover, startPopoverDelay, cancelPopoverDelay, handleTagClick, handleCounterClick, } = (0, useLogic_1.useLogic)(props);
|
|
21
|
+
const { className, data = [], keyId, isDisabled, getOptionLabel } = props;
|
|
16
22
|
return ((0, jsx_runtime_1.jsxs)(styles_1.Wrapper, { className: className, ref: tagsContainerRef, children: [visibleOptions?.map((option) => {
|
|
17
23
|
const tagProps = getTagProps(option);
|
|
18
|
-
return ((0, jsx_runtime_1.jsx)(Tag_1.Tag, { isDisabled: isDisabled, onClick:
|
|
19
|
-
}), showCounter && ((0, jsx_runtime_1.jsx)(styles_1.CounterTag, { isDisabled: isDisabled, label: `+${hiddenCount}`, onClick:
|
|
24
|
+
return ((0, jsx_runtime_1.jsx)(Tag_1.Tag, { isDisabled: isDisabled, onClick: handleTagClick, ...tagProps }, (0, utils_1.getKey)(option, keyId, getOptionLabel)));
|
|
25
|
+
}), showCounter && ((0, jsx_runtime_1.jsx)(styles_1.CounterTag, { ref: counterRef, isDisabled: isDisabled, label: `+${hiddenCount}`, onClick: handleCounterClick, onMouseEnter: isPopoverEnabled ? startPopoverDelay : undefined, onMouseLeave: isPopoverEnabled ? cancelPopoverDelay : undefined }, "more")), (0, jsx_runtime_1.jsx)(NewPopover_1.NewPopover, { isOpen: isPopoverOpen, anchorEl: popoverAnchorEl, disableAutoFocus: true, onClose: closePopover, children: (0, jsx_runtime_1.jsxs)(styles_1.PopoverContentWrapper, { ref: setPopoverContentRef, style: popoverContentCssVars, onClick: stopPopoverEventPropagation, onMouseDown: stopPopoverEventPropagation, children: [(0, jsx_runtime_1.jsxs)(styles_1.PopoverHeader, { children: [(0, jsx_runtime_1.jsx)(Typography_1.Typography, { variant: "h5", children: constants_1.POPOVER_TITLE_TEXT }), (0, jsx_runtime_1.jsx)(IconButton_1.IconButton, { variant: "text", title: constants_1.POPOVER_CLOSE_TEXT, "aria-label": constants_1.POPOVER_CLOSE_TEXT, onClick: closePopover, children: (0, jsx_runtime_1.jsx)(CrossOutlineMd_1.CrossOutlineMd, {}) })] }), (0, jsx_runtime_1.jsx)(PopoverTags_1.PopoverTags, { data: data, keyId: keyId, isDisabled: isDisabled, getOptionLabel: getOptionLabel, getTagProps: getTagProps })] }) })] }));
|
|
20
26
|
};
|
|
21
27
|
exports.TagsList = TagsList;
|
|
@@ -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,5 +1,40 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.GAP_BETWEEN_TAGS = exports.MIN_AVAILABLE_WIDTH = void 0;
|
|
3
|
+
exports.POPOVER_CLOSE_TEXT = exports.POPOVER_TITLE_TEXT = exports.POPOVER_TAGS_PADDING_SPACING = exports.POPOVER_TAGS_GAP_SPACING = exports.POPOVER_MIN_TAGS_IN_ROW = exports.POPOVER_MAX_HEIGHT = exports.POPOVER_MAX_WIDTH = exports.POPOVER_HOVER_DELAY = exports.GAP_BETWEEN_TAGS = exports.MIN_AVAILABLE_WIDTH = void 0;
|
|
4
4
|
exports.MIN_AVAILABLE_WIDTH = 50;
|
|
5
5
|
exports.GAP_BETWEEN_TAGS = 4; // 4px
|
|
6
|
+
/**
|
|
7
|
+
* Задержка появления всплывающего окна при наведении на счётчик (мс)
|
|
8
|
+
*/
|
|
9
|
+
exports.POPOVER_HOVER_DELAY = 500;
|
|
10
|
+
/**
|
|
11
|
+
* Максимальная ширина всплывающего окна (px)
|
|
12
|
+
*/
|
|
13
|
+
exports.POPOVER_MAX_WIDTH = 480;
|
|
14
|
+
/**
|
|
15
|
+
* Максимальная высота всплывающего окна (px)
|
|
16
|
+
*/
|
|
17
|
+
exports.POPOVER_MAX_HEIGHT = 370;
|
|
18
|
+
/**
|
|
19
|
+
* Количество тэгов, которые всплывающее окно вмещает в строку в любом случае:
|
|
20
|
+
* задаёт его минимальную ширину
|
|
21
|
+
*/
|
|
22
|
+
exports.POPOVER_MIN_TAGS_IN_ROW = 2;
|
|
23
|
+
/**
|
|
24
|
+
* Отступ между тэгами во всплывающем окне в единицах theme.spacing.
|
|
25
|
+
* Используется и в стилях, и в расчёте минимальной ширины окна
|
|
26
|
+
*/
|
|
27
|
+
exports.POPOVER_TAGS_GAP_SPACING = 2;
|
|
28
|
+
/**
|
|
29
|
+
* Горизонтальный отступ контейнера тэгов во всплывающем окне в единицах
|
|
30
|
+
* theme.spacing. Используется и в стилях, и в расчёте минимальной ширины окна
|
|
31
|
+
*/
|
|
32
|
+
exports.POPOVER_TAGS_PADDING_SPACING = 4;
|
|
33
|
+
/**
|
|
34
|
+
* Заголовок всплывающего окна со списком выбранных элементов
|
|
35
|
+
*/
|
|
36
|
+
exports.POPOVER_TITLE_TEXT = 'Выбранные элементы';
|
|
37
|
+
/**
|
|
38
|
+
* Доступное имя кнопки, закрывающей всплывающее окно
|
|
39
|
+
*/
|
|
40
|
+
exports.POPOVER_CLOSE_TEXT = 'Закрыть';
|
|
@@ -3,6 +3,14 @@ export declare const Wrapper: import("@emotion/styled/dist/declarations/src/type
|
|
|
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("@emotion/styled/dist/declarations/src/types").StyledComponent<import("./Tag").TagProps & {
|
|
6
|
+
export declare const CounterTag: import("@emotion/styled/dist/declarations/src/types").StyledComponent<import("./Tag").TagProps & import("react").RefAttributes<HTMLDivElement> & {
|
|
7
7
|
theme?: import("@emotion/react").Theme | undefined;
|
|
8
8
|
}, {}, {}>;
|
|
9
|
+
export declare const PopoverContentWrapper: import("@emotion/styled/dist/declarations/src/types").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("@emotion/styled/dist/declarations/src/types").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
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CounterTag = exports.Wrapper = void 0;
|
|
3
|
+
exports.PopoverHeader = exports.PopoverContentWrapper = exports.CounterTag = exports.Wrapper = void 0;
|
|
4
4
|
const styled_1 = require("../styled");
|
|
5
5
|
const Tag_1 = require("../Tag");
|
|
6
6
|
const constants_1 = require("./constants");
|
|
@@ -11,9 +11,28 @@ exports.Wrapper = styled_1.styled.div `
|
|
|
11
11
|
column-gap: ${constants_1.GAP_BETWEEN_TAGS}px;
|
|
12
12
|
`;
|
|
13
13
|
exports.CounterTag = (0, styled_1.styled)(Tag_2.Tag) `
|
|
14
|
+
cursor: pointer;
|
|
15
|
+
|
|
14
16
|
overflow: unset;
|
|
15
17
|
|
|
16
18
|
.${Tag_1.tagClassnames.label} {
|
|
17
19
|
min-width: unset;
|
|
18
20
|
}
|
|
19
21
|
`;
|
|
22
|
+
exports.PopoverContentWrapper = styled_1.styled.div `
|
|
23
|
+
--tags-list-popover-width: ${constants_1.POPOVER_MAX_WIDTH}px;
|
|
24
|
+
display: flex;
|
|
25
|
+
flex-direction: column;
|
|
26
|
+
gap: ${({ theme }) => theme.spacing(2)};
|
|
27
|
+
|
|
28
|
+
width: var(--tags-list-popover-width);
|
|
29
|
+
max-width: ${constants_1.POPOVER_MAX_WIDTH}px;
|
|
30
|
+
padding-block: ${({ theme }) => theme.spacing(4)};
|
|
31
|
+
`;
|
|
32
|
+
exports.PopoverHeader = styled_1.styled.div `
|
|
33
|
+
display: flex;
|
|
34
|
+
align-items: center;
|
|
35
|
+
justify-content: space-between;
|
|
36
|
+
|
|
37
|
+
padding-inline: ${({ theme }) => theme.spacing(4)};
|
|
38
|
+
`;
|
|
@@ -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,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("./useHoverDelay"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useHoverDelay';
|
|
@@ -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("./useHoverDelay"), exports);
|
|
@@ -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,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useHoverDelay = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
/**
|
|
6
|
+
* Откладывает вызов на время удержания указателя над элементом.
|
|
7
|
+
*/
|
|
8
|
+
const useHoverDelay = ({ delay, onHover, }) => {
|
|
9
|
+
const timeoutRef = (0, react_1.useRef)(undefined);
|
|
10
|
+
const savedOnHoverRef = (0, react_1.useRef)(onHover);
|
|
11
|
+
(0, react_1.useEffect)(() => {
|
|
12
|
+
savedOnHoverRef.current = onHover;
|
|
13
|
+
});
|
|
14
|
+
const cancel = () => {
|
|
15
|
+
if (timeoutRef.current === undefined) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
clearTimeout(timeoutRef.current);
|
|
19
|
+
timeoutRef.current = undefined;
|
|
20
|
+
};
|
|
21
|
+
const start = () => {
|
|
22
|
+
cancel();
|
|
23
|
+
timeoutRef.current = setTimeout(() => {
|
|
24
|
+
timeoutRef.current = undefined;
|
|
25
|
+
savedOnHoverRef.current();
|
|
26
|
+
}, delay);
|
|
27
|
+
};
|
|
28
|
+
(0, react_1.useEffect)(() => cancel, []);
|
|
29
|
+
return { start, cancel };
|
|
30
|
+
};
|
|
31
|
+
exports.useHoverDelay = useHoverDelay;
|
|
@@ -1,15 +1,27 @@
|
|
|
1
|
-
|
|
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 {};
|
|
@@ -3,14 +3,39 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.useLogic = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
const useTheme_1 = require("../../theme/hooks/useTheme");
|
|
6
|
+
const useClickAwayEffect_1 = require("../../useClickAwayEffect");
|
|
7
|
+
const useNewToggle_1 = require("../../useNewToggle");
|
|
8
|
+
const useViewportType_1 = require("../../useViewportType");
|
|
6
9
|
const constants_1 = require("../constants");
|
|
7
10
|
const utils_1 = require("../utils");
|
|
8
|
-
const
|
|
11
|
+
const useHoverDelay_1 = require("./hooks/useHoverDelay");
|
|
12
|
+
const useLogic = ({ data = [], keyId, isDisabled, getOptionLabel, onChange, onClick, inputContainerRef, fieldRef, reservedWidth = 0, }) => {
|
|
9
13
|
const [visibleOptions, setVisibleOptions] = (0, react_1.useState)([]);
|
|
10
14
|
const [hiddenCount, setHiddenCount] = (0, react_1.useState)(0);
|
|
15
|
+
const [isPopoverOpen, togglePopover] = (0, useNewToggle_1.useNewToggle)(false);
|
|
16
|
+
const [isPopoverContentMounted, togglePopoverContentMounted] = (0, useNewToggle_1.useNewToggle)(false);
|
|
17
|
+
/**
|
|
18
|
+
* Ширина окна и якорь позиционирования фиксируются на момент открытия
|
|
19
|
+
* и дальше не пересчитываются
|
|
20
|
+
*/
|
|
21
|
+
const [popoverWidth, setPopoverWidth] = (0, react_1.useState)(0);
|
|
22
|
+
const [popoverAnchorEl, setPopoverAnchorEl] = (0, react_1.useState)(null);
|
|
11
23
|
const tagsContainerRef = (0, react_1.useRef)(null);
|
|
12
24
|
const availableWidthRef = (0, react_1.useRef)(0);
|
|
25
|
+
const popoverContentRef = (0, react_1.useRef)(null);
|
|
26
|
+
const counterRef = (0, react_1.useRef)(null);
|
|
13
27
|
const theme = (0, useTheme_1.useTheme)();
|
|
28
|
+
const { isMobile } = (0, useViewportType_1.useViewportType)();
|
|
29
|
+
const openPopover = () => {
|
|
30
|
+
const field = fieldRef.current;
|
|
31
|
+
if (isPopoverOpen || !field) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
setPopoverWidth((0, utils_1.calculatePopoverWidth)(field.getBoundingClientRect().width, data.map((item) => getOptionLabel(item).toString()), theme));
|
|
35
|
+
setPopoverAnchorEl(field);
|
|
36
|
+
togglePopover(true);
|
|
37
|
+
};
|
|
38
|
+
const closePopover = () => togglePopover(false);
|
|
14
39
|
/**
|
|
15
40
|
* Обновляет доступную ширину для расчета количества отображаемых тегов
|
|
16
41
|
*/
|
|
@@ -67,6 +92,7 @@ const useLogic = ({ data = [], keyId, getOptionLabel, onChange, inputContainerRe
|
|
|
67
92
|
if (!data.length) {
|
|
68
93
|
setVisibleOptions([]);
|
|
69
94
|
setHiddenCount(0);
|
|
95
|
+
closePopover();
|
|
70
96
|
return;
|
|
71
97
|
}
|
|
72
98
|
const resizeObserver = new ResizeObserver(() => {
|
|
@@ -105,12 +131,66 @@ const useLogic = ({ data = [], keyId, getOptionLabel, onChange, inputContainerRe
|
|
|
105
131
|
return { label, shrinks: false, onDelete };
|
|
106
132
|
};
|
|
107
133
|
const showCounter = hiddenCount > 0;
|
|
134
|
+
const { start: startPopoverDelay, cancel: cancelPopoverDelay } = (0, useHoverDelay_1.useHoverDelay)({ onHover: openPopover, delay: constants_1.POPOVER_HOVER_DELAY });
|
|
135
|
+
const setPopoverContentRef = (0, react_1.useCallback)((node) => {
|
|
136
|
+
popoverContentRef.current = node;
|
|
137
|
+
togglePopoverContentMounted(Boolean(node));
|
|
138
|
+
}, []);
|
|
139
|
+
const popoverExcludedNodes = (0, react_1.useMemo)(() => [counterRef], []);
|
|
140
|
+
(0, useClickAwayEffect_1.useClickAwayEffect)({
|
|
141
|
+
ref: popoverContentRef,
|
|
142
|
+
onClickAway: closePopover,
|
|
143
|
+
isActive: isPopoverOpen && isPopoverContentMounted,
|
|
144
|
+
excludeNodes: popoverExcludedNodes,
|
|
145
|
+
});
|
|
146
|
+
const isPopoverEnabled = !isMobile && !isDisabled;
|
|
147
|
+
const handleTagClick = (event) => {
|
|
148
|
+
event.stopPropagation();
|
|
149
|
+
onClick?.(event);
|
|
150
|
+
};
|
|
151
|
+
const handleCounterClick = (event) => {
|
|
152
|
+
event.stopPropagation();
|
|
153
|
+
cancelPopoverDelay();
|
|
154
|
+
// На мобильной ширине и в заблокированном поле у счётчика прежнее поведение — список опций
|
|
155
|
+
if (!isPopoverEnabled) {
|
|
156
|
+
onClick?.(event);
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
if (isPopoverOpen) {
|
|
160
|
+
closePopover();
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
openPopover();
|
|
164
|
+
};
|
|
165
|
+
/**
|
|
166
|
+
* Окно живёт в портале, но синтетические события React всплывают по дереву
|
|
167
|
+
* компонентов и доходят до обработчиков поля: у MUI Select это `handleMouseDown`,
|
|
168
|
+
* который переводит фокус на поле и открывает список, у TreeLike* — `onClick` поля
|
|
169
|
+
*/
|
|
170
|
+
const stopPopoverEventPropagation = (event) => {
|
|
171
|
+
event.stopPropagation();
|
|
172
|
+
};
|
|
173
|
+
const popoverContentCssVars = {
|
|
174
|
+
'--tags-list-popover-width': `${popoverWidth}px`,
|
|
175
|
+
};
|
|
108
176
|
return {
|
|
109
177
|
visibleOptions,
|
|
110
178
|
hiddenCount,
|
|
111
179
|
showCounter,
|
|
112
180
|
tagsContainerRef,
|
|
181
|
+
counterRef,
|
|
113
182
|
getTagProps,
|
|
183
|
+
isPopoverOpen,
|
|
184
|
+
isPopoverEnabled,
|
|
185
|
+
setPopoverContentRef,
|
|
186
|
+
popoverContentCssVars,
|
|
187
|
+
stopPopoverEventPropagation,
|
|
188
|
+
popoverAnchorEl,
|
|
189
|
+
closePopover,
|
|
190
|
+
startPopoverDelay,
|
|
191
|
+
cancelPopoverDelay,
|
|
192
|
+
handleTagClick,
|
|
193
|
+
handleCounterClick,
|
|
114
194
|
};
|
|
115
195
|
};
|
|
116
196
|
exports.useLogic = useLogic;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.calculatePopoverWidth = void 0;
|
|
4
|
+
const constants_1 = require("../../constants");
|
|
5
|
+
const getTagWidth_1 = require("../getTagWidth");
|
|
6
|
+
const getSpacingValue = (theme, spacing) => parseInt(theme.spacing(spacing), 10);
|
|
7
|
+
/**
|
|
8
|
+
* Минимальная ширина popover: вмещает в строку POPOVER_MIN_TAGS_IN_ROW самых
|
|
9
|
+
* широких тэгов вместе с отступом между ними и отступами контейнера
|
|
10
|
+
*/
|
|
11
|
+
const getMinWidth = (tagLabels, theme) => {
|
|
12
|
+
const widestTagWidths = tagLabels
|
|
13
|
+
.map((label) => (0, getTagWidth_1.getTagWidth)(label, theme))
|
|
14
|
+
.sort((current, next) => next - current)
|
|
15
|
+
.slice(0, constants_1.POPOVER_MIN_TAGS_IN_ROW);
|
|
16
|
+
const tagsWidth = widestTagWidths.reduce((width, tagWidth) => width + tagWidth, 0);
|
|
17
|
+
const gapsWidth = Math.max(widestTagWidths.length - 1, 0) *
|
|
18
|
+
getSpacingValue(theme, constants_1.POPOVER_TAGS_GAP_SPACING);
|
|
19
|
+
const paddingsWidth = getSpacingValue(theme, constants_1.POPOVER_TAGS_PADDING_SPACING) * 2;
|
|
20
|
+
return tagsWidth + gapsWidth + paddingsWidth;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Вычисляет ширину всплывающего окна
|
|
24
|
+
*/
|
|
25
|
+
const calculatePopoverWidth = (fieldWidth, tagLabels, theme) => Math.min(Math.max(fieldWidth, getMinWidth(tagLabels, theme)), constants_1.POPOVER_MAX_WIDTH);
|
|
26
|
+
exports.calculatePopoverWidth = calculatePopoverWidth;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './calculatePopoverWidth';
|
|
@@ -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("./calculatePopoverWidth"), exports);
|
|
@@ -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';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.calculateVisibleTagsCount = exports.getAvailableWidth = exports.getTagWidth = exports.getKey = exports.getElementByText = void 0;
|
|
3
|
+
exports.calculatePopoverWidth = exports.calculateVisibleTagsCount = exports.getAvailableWidth = exports.getTagWidth = exports.getKey = exports.getElementByText = void 0;
|
|
4
4
|
var getElementByText_1 = require("./getElementByText");
|
|
5
5
|
Object.defineProperty(exports, "getElementByText", { enumerable: true, get: function () { return getElementByText_1.getElementByText; } });
|
|
6
6
|
var getKey_1 = require("./getKey");
|
|
@@ -11,3 +11,5 @@ var getAvailableWidth_1 = require("./getAvailableWidth");
|
|
|
11
11
|
Object.defineProperty(exports, "getAvailableWidth", { enumerable: true, get: function () { return getAvailableWidth_1.getAvailableWidth; } });
|
|
12
12
|
var calculateVisibleTagsCount_1 = require("./calculateVisibleTagsCount");
|
|
13
13
|
Object.defineProperty(exports, "calculateVisibleTagsCount", { enumerable: true, get: function () { return calculateVisibleTagsCount_1.calculateVisibleTagsCount; } });
|
|
14
|
+
var calculatePopoverWidth_1 = require("./calculatePopoverWidth");
|
|
15
|
+
Object.defineProperty(exports, "calculatePopoverWidth", { enumerable: true, get: function () { return calculatePopoverWidth_1.calculatePopoverWidth; } });
|
|
@@ -12,13 +12,14 @@ const styles_1 = require("./styles");
|
|
|
12
12
|
const useLogic_1 = require("./useLogic");
|
|
13
13
|
const ClearButton = ({ disabled, onClick }) => ((0, jsx_runtime_1.jsx)(IconButton_1.IconButton, { variant: "text", color: "grey", disabled: disabled, onClick: onClick, title: constants_1.CLEAR_TEXT, "aria-label": constants_1.CLEAR_TEXT, children: (0, jsx_runtime_1.jsx)(CrossOutlineMd_1.CrossOutlineMd, {}) }));
|
|
14
14
|
exports.Input = (0, react_1.forwardRef)(({ disabled, onChange: propsOnChange, value, inputRef, hideHelperText = false, onClick, isLoading, ...restProps }, forwardedRef) => {
|
|
15
|
-
const { isVisibleClearButton, isVisibleTagsList, onChange, textFieldProps, onClearAll, } = (0, useLogic_1.useLogic)({
|
|
15
|
+
const { isVisibleClearButton, isVisibleTagsList, onChange, textFieldProps, onClearAll, fieldRef, } = (0, useLogic_1.useLogic)({
|
|
16
16
|
inputRef,
|
|
17
|
+
InputProps: restProps.InputProps,
|
|
17
18
|
value,
|
|
18
19
|
onChange: propsOnChange,
|
|
19
20
|
disabled,
|
|
20
21
|
onClick,
|
|
21
22
|
isLoading,
|
|
22
23
|
});
|
|
23
|
-
return ((0, jsx_runtime_1.jsx)(styles_1.StyledTextField, { ...restProps, hideHelperText: hideHelperText, ref: forwardedRef, disabled: disabled, inputProps: { readOnly: true }, ...textFieldProps, startAdornment: isVisibleTagsList && ((0, jsx_runtime_1.jsx)(styles_1.StyledTagsList, { data: value, keyId: "id", isDisabled: disabled, getOptionLabel: (option) => option.label, onClick: onClick, onChange: onChange })), endAdornment: (0, jsx_runtime_1.jsxs)(styles_1.IconWrapper, { children: [isVisibleClearButton && ((0, jsx_runtime_1.jsx)(ClearButton, { disabled: disabled, onClick: onClearAll })), isLoading ? ((0, jsx_runtime_1.jsx)(Loader_1.Loader, { size: "small" })) : ((0, jsx_runtime_1.jsx)(IconButton_1.IconButton, { variant: "text", color: "grey", disabled: disabled, children: (0, jsx_runtime_1.jsx)(DownOutlineMd_1.DownOutlineMd, {}) }))] }) }));
|
|
24
|
+
return ((0, jsx_runtime_1.jsx)(styles_1.StyledTextField, { ...restProps, hideHelperText: hideHelperText, ref: forwardedRef, disabled: disabled, inputProps: { readOnly: true }, ...textFieldProps, InputProps: { ...restProps.InputProps, ref: fieldRef }, startAdornment: isVisibleTagsList && ((0, jsx_runtime_1.jsx)(styles_1.StyledTagsList, { data: value, keyId: "id", isDisabled: disabled, fieldRef: fieldRef, getOptionLabel: (option) => option.label, onClick: onClick, onChange: onChange })), endAdornment: (0, jsx_runtime_1.jsxs)(styles_1.IconWrapper, { children: [isVisibleClearButton && ((0, jsx_runtime_1.jsx)(ClearButton, { disabled: disabled, onClick: onClearAll })), isLoading ? ((0, jsx_runtime_1.jsx)(Loader_1.Loader, { size: "small" })) : ((0, jsx_runtime_1.jsx)(IconButton_1.IconButton, { variant: "text", color: "grey", disabled: disabled, children: (0, jsx_runtime_1.jsx)(DownOutlineMd_1.DownOutlineMd, {}) }))] }) }));
|
|
24
25
|
});
|
|
@@ -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;
|
|
@@ -3,8 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.useLogic = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
const useForwardedRef_1 = require("../../../useForwardedRef");
|
|
6
|
-
const useLogic = ({ value, disabled, isLoading, inputRef: externalInputRef, onChange: propsOnChange, onClick: propsOnClick, }) => {
|
|
6
|
+
const useLogic = ({ value, disabled, isLoading, inputRef: externalInputRef, InputProps: externalInputProps, onChange: propsOnChange, onClick: propsOnClick, }) => {
|
|
7
7
|
const inputRef = (0, useForwardedRef_1.useForwardedRef)(externalInputRef);
|
|
8
|
+
const fieldRef = (0, useForwardedRef_1.useForwardedRef)(externalInputProps?.ref);
|
|
8
9
|
const prevValue = (0, react_1.useRef)(undefined);
|
|
9
10
|
(0, react_1.useEffect)(() => {
|
|
10
11
|
if (value && !prevValue.current) {
|
|
@@ -43,6 +44,7 @@ const useLogic = ({ value, disabled, isLoading, inputRef: externalInputRef, onCh
|
|
|
43
44
|
onChange,
|
|
44
45
|
onClick,
|
|
45
46
|
isVisibleTagsList: hasValue,
|
|
47
|
+
fieldRef,
|
|
46
48
|
textFieldProps: {
|
|
47
49
|
value: preparedValue,
|
|
48
50
|
$isHidden: hasValue,
|
|
@@ -11,7 +11,7 @@ const styles_1 = require("./styles");
|
|
|
11
11
|
const useLogic_1 = require("./useLogic");
|
|
12
12
|
const ClearButton = ({ disabled, onClick }) => ((0, jsx_runtime_1.jsx)(IconButton_1.IconButton, { variant: "text", color: "grey", disabled: disabled, title: constants_1.CLEAR_TEXT, "aria-label": constants_1.CLEAR_TEXT, onClick: onClick, children: (0, jsx_runtime_1.jsx)(CrossOutlineMd_1.CrossOutlineMd, {}) }));
|
|
13
13
|
exports.Input = (0, react_1.forwardRef)((props, forwardedRef) => {
|
|
14
|
-
const { textFieldProps, isVisibleTagsList, isVisibleClearButton, handleChange, handleClearAll, } = (0, useLogic_1.useLogic)(props);
|
|
14
|
+
const { textFieldProps, isVisibleTagsList, isVisibleClearButton, handleChange, handleClearAll, fieldRef, } = (0, useLogic_1.useLogic)(props);
|
|
15
15
|
const { value, valueToRender, disabled, isLoading, onChange, onClick, ...restProps } = props;
|
|
16
|
-
return ((0, jsx_runtime_1.jsx)(styles_1.StyledTextField, { ...restProps, ref: forwardedRef, disabled: disabled, inputProps: { readOnly: true }, startAdornment: isVisibleTagsList && ((0, jsx_runtime_1.jsx)(styles_1.StyledTagsList, { data: valueToRender, keyId: "id", isDisabled: disabled, getOptionLabel: (option) => option.label, onClick: onClick, onChange: handleChange })), endAdornment: (0, jsx_runtime_1.jsxs)(styles_1.EndAdornmentWrapper, { children: [isLoading && (0, jsx_runtime_1.jsx)(styles_1.StyledLoader, {}), isVisibleClearButton && ((0, jsx_runtime_1.jsx)(ClearButton, { disabled: disabled, onClick: handleClearAll })), (0, jsx_runtime_1.jsx)(IconButton_1.IconButton, { variant: "text", color: "grey", disabled: disabled, children: (0, jsx_runtime_1.jsx)(DownOutlineMd_1.DownOutlineMd, {}) })] }), onClick: onClick, ...textFieldProps }));
|
|
16
|
+
return ((0, jsx_runtime_1.jsx)(styles_1.StyledTextField, { ...restProps, ref: forwardedRef, disabled: disabled, inputProps: { readOnly: true }, InputProps: { ...restProps.InputProps, ref: fieldRef }, startAdornment: isVisibleTagsList && ((0, jsx_runtime_1.jsx)(styles_1.StyledTagsList, { data: valueToRender, keyId: "id", isDisabled: disabled, fieldRef: fieldRef, getOptionLabel: (option) => option.label, onClick: onClick, onChange: handleChange })), endAdornment: (0, jsx_runtime_1.jsxs)(styles_1.EndAdornmentWrapper, { children: [isLoading && (0, jsx_runtime_1.jsx)(styles_1.StyledLoader, {}), isVisibleClearButton && ((0, jsx_runtime_1.jsx)(ClearButton, { disabled: disabled, onClick: handleClearAll })), (0, jsx_runtime_1.jsx)(IconButton_1.IconButton, { variant: "text", color: "grey", disabled: disabled, children: (0, jsx_runtime_1.jsx)(DownOutlineMd_1.DownOutlineMd, {}) })] }), onClick: onClick, ...textFieldProps }));
|
|
17
17
|
});
|
|
@@ -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;
|
|
@@ -3,8 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.useLogic = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
const useForwardedRef_1 = require("../../../useForwardedRef");
|
|
6
|
-
const useLogic = ({ value, disabled, isLoading, inputRef: externalInputRef, onChange, }) => {
|
|
6
|
+
const useLogic = ({ value, disabled, isLoading, inputRef: externalInputRef, InputProps: externalInputProps, onChange, }) => {
|
|
7
7
|
const inputRef = (0, useForwardedRef_1.useForwardedRef)(externalInputRef);
|
|
8
|
+
const fieldRef = (0, useForwardedRef_1.useForwardedRef)(externalInputProps?.ref);
|
|
8
9
|
const prevValue = (0, react_1.useRef)(undefined);
|
|
9
10
|
(0, react_1.useEffect)(() => {
|
|
10
11
|
if (value && !prevValue.current) {
|
|
@@ -41,6 +42,7 @@ const useLogic = ({ value, disabled, isLoading, inputRef: externalInputRef, onCh
|
|
|
41
42
|
inputRef,
|
|
42
43
|
value: preparedValue,
|
|
43
44
|
},
|
|
45
|
+
fieldRef,
|
|
44
46
|
isVisibleTagsList: hasValue,
|
|
45
47
|
isVisibleClearButton,
|
|
46
48
|
handleChange,
|