@astral/ui 4.106.0 → 4.107.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/Autocomplete/Autocomplete.js +2 -3
- 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/Autocomplete/Autocomplete.js +2 -3
- 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
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { POPOVER_MAX_WIDTH, POPOVER_MIN_TAGS_IN_ROW, POPOVER_TAGS_GAP_SPACING, POPOVER_TAGS_PADDING_SPACING, } from '../../constants';
|
|
2
|
+
import { getTagWidth } from '../getTagWidth';
|
|
3
|
+
const getSpacingValue = (theme, spacing) => parseInt(theme.spacing(spacing), 10);
|
|
4
|
+
/**
|
|
5
|
+
* Минимальная ширина popover: вмещает в строку POPOVER_MIN_TAGS_IN_ROW самых
|
|
6
|
+
* широких тэгов вместе с отступом между ними и отступами контейнера
|
|
7
|
+
*/
|
|
8
|
+
const getMinWidth = (tagLabels, theme) => {
|
|
9
|
+
const widestTagWidths = tagLabels
|
|
10
|
+
.map((label) => getTagWidth(label, theme))
|
|
11
|
+
.sort((current, next) => next - current)
|
|
12
|
+
.slice(0, POPOVER_MIN_TAGS_IN_ROW);
|
|
13
|
+
const tagsWidth = widestTagWidths.reduce((width, tagWidth) => width + tagWidth, 0);
|
|
14
|
+
const gapsWidth = Math.max(widestTagWidths.length - 1, 0) *
|
|
15
|
+
getSpacingValue(theme, POPOVER_TAGS_GAP_SPACING);
|
|
16
|
+
const paddingsWidth = getSpacingValue(theme, POPOVER_TAGS_PADDING_SPACING) * 2;
|
|
17
|
+
return tagsWidth + gapsWidth + paddingsWidth;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Вычисляет ширину всплывающего окна
|
|
21
|
+
*/
|
|
22
|
+
export const calculatePopoverWidth = (fieldWidth, tagLabels, theme) => Math.min(Math.max(fieldWidth, getMinWidth(tagLabels, theme)), POPOVER_MAX_WIDTH);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './calculatePopoverWidth';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './calculatePopoverWidth';
|
|
@@ -3,3 +3,4 @@ export { getKey } from './getKey';
|
|
|
3
3
|
export { getTagWidth } from './getTagWidth';
|
|
4
4
|
export { getAvailableWidth } from './getAvailableWidth';
|
|
5
5
|
export { calculateVisibleTagsCount } from './calculateVisibleTagsCount';
|
|
6
|
+
export { calculatePopoverWidth } from './calculatePopoverWidth';
|
|
@@ -3,3 +3,4 @@ export { getKey } from './getKey';
|
|
|
3
3
|
export { getTagWidth } from './getTagWidth';
|
|
4
4
|
export { getAvailableWidth } from './getAvailableWidth';
|
|
5
5
|
export { calculateVisibleTagsCount } from './calculateVisibleTagsCount';
|
|
6
|
+
export { calculatePopoverWidth } from './calculatePopoverWidth';
|
|
@@ -9,13 +9,14 @@ import { IconWrapper, StyledTagsList, StyledTextField } from './styles';
|
|
|
9
9
|
import { useLogic } from './useLogic';
|
|
10
10
|
const ClearButton = ({ disabled, onClick }) => (_jsx(IconButton, { variant: "text", color: "grey", disabled: disabled, onClick: onClick, title: CLEAR_TEXT, "aria-label": CLEAR_TEXT, children: _jsx(CrossOutlineMd, {}) }));
|
|
11
11
|
export const Input = forwardRef(({ disabled, onChange: propsOnChange, value, inputRef, hideHelperText = false, onClick, isLoading, ...restProps }, forwardedRef) => {
|
|
12
|
-
const { isVisibleClearButton, isVisibleTagsList, onChange, textFieldProps, onClearAll, } = useLogic({
|
|
12
|
+
const { isVisibleClearButton, isVisibleTagsList, onChange, textFieldProps, onClearAll, fieldRef, } = useLogic({
|
|
13
13
|
inputRef,
|
|
14
|
+
InputProps: restProps.InputProps,
|
|
14
15
|
value,
|
|
15
16
|
onChange: propsOnChange,
|
|
16
17
|
disabled,
|
|
17
18
|
onClick,
|
|
18
19
|
isLoading,
|
|
19
20
|
});
|
|
20
|
-
return (_jsx(StyledTextField, { ...restProps, hideHelperText: hideHelperText, ref: forwardedRef, disabled: disabled, inputProps: { readOnly: true }, ...textFieldProps, startAdornment: isVisibleTagsList && (_jsx(StyledTagsList, { data: value, keyId: "id", isDisabled: disabled, getOptionLabel: (option) => option.label, onClick: onClick, onChange: onChange })), endAdornment: _jsxs(IconWrapper, { children: [isVisibleClearButton && (_jsx(ClearButton, { disabled: disabled, onClick: onClearAll })), isLoading ? (_jsx(Loader, { size: "small" })) : (_jsx(IconButton, { variant: "text", color: "grey", disabled: disabled, children: _jsx(DownOutlineMd, {}) }))] }) }));
|
|
21
|
+
return (_jsx(StyledTextField, { ...restProps, hideHelperText: hideHelperText, ref: forwardedRef, disabled: disabled, inputProps: { readOnly: true }, ...textFieldProps, InputProps: { ...restProps.InputProps, ref: fieldRef }, startAdornment: isVisibleTagsList && (_jsx(StyledTagsList, { data: value, keyId: "id", isDisabled: disabled, fieldRef: fieldRef, getOptionLabel: (option) => option.label, onClick: onClick, onChange: onChange })), endAdornment: _jsxs(IconWrapper, { children: [isVisibleClearButton && (_jsx(ClearButton, { disabled: disabled, onClick: onClearAll })), isLoading ? (_jsx(Loader, { size: "small" })) : (_jsx(IconButton, { variant: "text", color: "grey", disabled: disabled, children: _jsx(DownOutlineMd, {}) }))] }) }));
|
|
21
22
|
});
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { type MouseEvent, type SyntheticEvent } from 'react';
|
|
2
2
|
import { type TreeLikeAsyncAutocompleteValue } from '../../types';
|
|
3
3
|
import type { InputProps } from '../types';
|
|
4
|
-
type UseLogicParams = Pick<InputProps, 'value' | 'disabled' | 'inputRef' | 'onChange' | 'isLoading' | 'onClick'>;
|
|
5
|
-
export declare const useLogic: ({ value, disabled, isLoading, inputRef: externalInputRef, onChange: propsOnChange, onClick: propsOnClick, }: UseLogicParams) => {
|
|
4
|
+
type UseLogicParams = Pick<InputProps, 'value' | 'disabled' | 'inputRef' | 'InputProps' | 'onChange' | 'isLoading' | 'onClick'>;
|
|
5
|
+
export declare const useLogic: ({ value, disabled, isLoading, inputRef: externalInputRef, InputProps: externalInputProps, onChange: propsOnChange, onClick: propsOnClick, }: UseLogicParams) => {
|
|
6
6
|
isVisibleClearButton: boolean;
|
|
7
7
|
onClearAll: (event: SyntheticEvent<HTMLButtonElement>) => void;
|
|
8
8
|
onChange: (newValue: TreeLikeAsyncAutocompleteValue | undefined) => void;
|
|
9
9
|
onClick: (event: MouseEvent<HTMLDivElement>) => void;
|
|
10
10
|
isVisibleTagsList: boolean;
|
|
11
|
+
fieldRef: import("react").RefObject<HTMLElement | null>;
|
|
11
12
|
textFieldProps: {
|
|
12
13
|
value: string;
|
|
13
14
|
$isHidden: boolean;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { useEffect, useRef, } from 'react';
|
|
2
2
|
import { useForwardedRef } from '../../../useForwardedRef';
|
|
3
|
-
export const useLogic = ({ value, disabled, isLoading, inputRef: externalInputRef, onChange: propsOnChange, onClick: propsOnClick, }) => {
|
|
3
|
+
export const useLogic = ({ value, disabled, isLoading, inputRef: externalInputRef, InputProps: externalInputProps, onChange: propsOnChange, onClick: propsOnClick, }) => {
|
|
4
4
|
const inputRef = useForwardedRef(externalInputRef);
|
|
5
|
+
const fieldRef = useForwardedRef(externalInputProps?.ref);
|
|
5
6
|
const prevValue = useRef(undefined);
|
|
6
7
|
useEffect(() => {
|
|
7
8
|
if (value && !prevValue.current) {
|
|
@@ -40,6 +41,7 @@ export const useLogic = ({ value, disabled, isLoading, inputRef: externalInputRe
|
|
|
40
41
|
onChange,
|
|
41
42
|
onClick,
|
|
42
43
|
isVisibleTagsList: hasValue,
|
|
44
|
+
fieldRef,
|
|
43
45
|
textFieldProps: {
|
|
44
46
|
value: preparedValue,
|
|
45
47
|
$isHidden: hasValue,
|
|
@@ -8,7 +8,7 @@ import { EndAdornmentWrapper, StyledLoader, StyledTagsList, StyledTextField, } f
|
|
|
8
8
|
import { useLogic } from './useLogic';
|
|
9
9
|
const ClearButton = ({ disabled, onClick }) => (_jsx(IconButton, { variant: "text", color: "grey", disabled: disabled, title: CLEAR_TEXT, "aria-label": CLEAR_TEXT, onClick: onClick, children: _jsx(CrossOutlineMd, {}) }));
|
|
10
10
|
export const Input = forwardRef((props, forwardedRef) => {
|
|
11
|
-
const { textFieldProps, isVisibleTagsList, isVisibleClearButton, handleChange, handleClearAll, } = useLogic(props);
|
|
11
|
+
const { textFieldProps, isVisibleTagsList, isVisibleClearButton, handleChange, handleClearAll, fieldRef, } = useLogic(props);
|
|
12
12
|
const { value, valueToRender, disabled, isLoading, onChange, onClick, ...restProps } = props;
|
|
13
|
-
return (_jsx(StyledTextField, { ...restProps, ref: forwardedRef, disabled: disabled, inputProps: { readOnly: true }, startAdornment: isVisibleTagsList && (_jsx(StyledTagsList, { data: valueToRender, keyId: "id", isDisabled: disabled, getOptionLabel: (option) => option.label, onClick: onClick, onChange: handleChange })), endAdornment: _jsxs(EndAdornmentWrapper, { children: [isLoading && _jsx(StyledLoader, {}), isVisibleClearButton && (_jsx(ClearButton, { disabled: disabled, onClick: handleClearAll })), _jsx(IconButton, { variant: "text", color: "grey", disabled: disabled, children: _jsx(DownOutlineMd, {}) })] }), onClick: onClick, ...textFieldProps }));
|
|
13
|
+
return (_jsx(StyledTextField, { ...restProps, ref: forwardedRef, disabled: disabled, inputProps: { readOnly: true }, InputProps: { ...restProps.InputProps, ref: fieldRef }, startAdornment: isVisibleTagsList && (_jsx(StyledTagsList, { data: valueToRender, keyId: "id", isDisabled: disabled, fieldRef: fieldRef, getOptionLabel: (option) => option.label, onClick: onClick, onChange: handleChange })), endAdornment: _jsxs(EndAdornmentWrapper, { children: [isLoading && _jsx(StyledLoader, {}), isVisibleClearButton && (_jsx(ClearButton, { disabled: disabled, onClick: handleClearAll })), _jsx(IconButton, { variant: "text", color: "grey", disabled: disabled, children: _jsx(DownOutlineMd, {}) })] }), onClick: onClick, ...textFieldProps }));
|
|
14
14
|
});
|
|
@@ -2,12 +2,13 @@ import { type SyntheticEvent } from 'react';
|
|
|
2
2
|
import { type TreeListData } from '../../../Tree';
|
|
3
3
|
import type { TreeLikeAutocompleteValue } from '../../types';
|
|
4
4
|
import { type InputProps } from '../types';
|
|
5
|
-
export declare const useLogic: ({ value, disabled, isLoading, inputRef: externalInputRef, onChange, }: InputProps) => {
|
|
5
|
+
export declare const useLogic: ({ value, disabled, isLoading, inputRef: externalInputRef, InputProps: externalInputProps, onChange, }: InputProps) => {
|
|
6
6
|
textFieldProps: {
|
|
7
7
|
$isHidden: boolean;
|
|
8
8
|
inputRef: import("react").RefObject<HTMLInputElement | null>;
|
|
9
9
|
value: string | TreeLikeAutocompleteValue;
|
|
10
10
|
};
|
|
11
|
+
fieldRef: import("react").RefObject<HTMLElement | null>;
|
|
11
12
|
isVisibleTagsList: boolean;
|
|
12
13
|
isVisibleClearButton: boolean;
|
|
13
14
|
handleChange: (newValue: TreeListData[] | undefined) => void;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { useEffect, useRef, } from 'react';
|
|
2
2
|
import { useForwardedRef } from '../../../useForwardedRef';
|
|
3
|
-
export const useLogic = ({ value, disabled, isLoading, inputRef: externalInputRef, onChange, }) => {
|
|
3
|
+
export const useLogic = ({ value, disabled, isLoading, inputRef: externalInputRef, InputProps: externalInputProps, onChange, }) => {
|
|
4
4
|
const inputRef = useForwardedRef(externalInputRef);
|
|
5
|
+
const fieldRef = useForwardedRef(externalInputProps?.ref);
|
|
5
6
|
const prevValue = useRef(undefined);
|
|
6
7
|
useEffect(() => {
|
|
7
8
|
if (value && !prevValue.current) {
|
|
@@ -38,6 +39,7 @@ export const useLogic = ({ value, disabled, isLoading, inputRef: externalInputRe
|
|
|
38
39
|
inputRef,
|
|
39
40
|
value: preparedValue,
|
|
40
41
|
},
|
|
42
|
+
fieldRef,
|
|
41
43
|
isVisibleTagsList: hasValue,
|
|
42
44
|
isVisibleClearButton,
|
|
43
45
|
handleChange,
|
|
@@ -29,8 +29,8 @@ const AutocompleteInner = (props, ref) => {
|
|
|
29
29
|
if (!multiple || !Array.isArray(value)) {
|
|
30
30
|
return null;
|
|
31
31
|
}
|
|
32
|
-
|
|
33
|
-
option.toString(), inputContainerRef: inputBaseRef, reservedWidth: constants_1.INPUT_MIN_WIDTH, onChange: (tagValues) => {
|
|
32
|
+
return ((0, jsx_runtime_1.jsx)(TagsList_1.TagsList, { data: value, getOptionLabel: (option) => getOptionLabel?.(option) ??
|
|
33
|
+
option.toString(), inputContainerRef: inputBaseRef, fieldRef: inputBaseRef, reservedWidth: constants_1.INPUT_MIN_WIDTH, onChange: (tagValues) => {
|
|
34
34
|
if (!onChange) {
|
|
35
35
|
return;
|
|
36
36
|
}
|
|
@@ -42,7 +42,6 @@ const AutocompleteInner = (props, ref) => {
|
|
|
42
42
|
const reason = 'removeOption';
|
|
43
43
|
onChange(syntheticEvent, tagValues, reason);
|
|
44
44
|
} }));
|
|
45
|
-
return tagsListElement;
|
|
46
45
|
};
|
|
47
46
|
const generalInputParams = {
|
|
48
47
|
...inputParams,
|
|
@@ -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" | "
|
|
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:
|
|
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
|
-
|
|
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,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
|
+
};
|
|
@@ -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: (
|
|
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
|
-
|
|
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
|
+
});
|
|
@@ -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';
|