@ozen-ui/kit 0.48.0 → 0.49.1
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/__inner__/cjs/components/Alert/Alert.css +11 -12
- package/__inner__/cjs/components/Alert/Alert.d.ts +13 -39
- package/__inner__/cjs/components/Alert/Alert.js +14 -14
- package/__inner__/cjs/components/Alert/constants.d.ts +1 -1
- package/__inner__/cjs/components/Alert/constants.js +2 -2
- package/__inner__/cjs/components/Alert/index.d.ts +1 -0
- package/__inner__/cjs/components/Alert/index.js +1 -0
- package/__inner__/cjs/components/Alert/types.d.ts +46 -0
- package/__inner__/cjs/components/Alert/types.js +10 -0
- package/__inner__/cjs/components/InputNumber/utils.d.ts +1 -1
- package/__inner__/cjs/components/List/components/ListItemText/ListItemText.d.ts +5 -5
- package/__inner__/cjs/components/Popover/Popover.css +26 -50
- package/__inner__/cjs/components/Popover/Popover.js +10 -4
- package/__inner__/cjs/components/Popover/types.d.ts +6 -0
- package/__inner__/cjs/components/Slider/utils/getPositionOnRail.d.ts +1 -1
- package/__inner__/cjs/components/Snackbar/components/SnackbarItem/SnackbarItem.js +1 -1
- package/__inner__/cjs/components/Tooltip/Tooltip.css +9 -6
- package/__inner__/cjs/components/Tooltip/Tooltip.js +15 -3
- package/__inner__/cjs/components/Tooltip/constants.d.ts +1 -1
- package/__inner__/cjs/components/Tooltip/constants.js +2 -2
- package/__inner__/cjs/components/Tooltip/types.d.ts +11 -3
- package/__inner__/esm/components/Alert/Alert.css +11 -12
- package/__inner__/esm/components/Alert/Alert.d.ts +13 -39
- package/__inner__/esm/components/Alert/Alert.js +14 -14
- package/__inner__/esm/components/Alert/constants.d.ts +1 -1
- package/__inner__/esm/components/Alert/constants.js +1 -1
- package/__inner__/esm/components/Alert/index.d.ts +1 -0
- package/__inner__/esm/components/Alert/index.js +1 -0
- package/__inner__/esm/components/Alert/types.d.ts +46 -0
- package/__inner__/esm/components/Alert/types.js +7 -0
- package/__inner__/esm/components/InputNumber/utils.d.ts +1 -1
- package/__inner__/esm/components/List/components/ListItemText/ListItemText.d.ts +5 -5
- package/__inner__/esm/components/Popover/Popover.css +26 -50
- package/__inner__/esm/components/Popover/Popover.js +10 -4
- package/__inner__/esm/components/Popover/types.d.ts +6 -0
- package/__inner__/esm/components/Slider/utils/getPositionOnRail.d.ts +1 -1
- package/__inner__/esm/components/Snackbar/components/SnackbarItem/SnackbarItem.js +1 -1
- package/__inner__/esm/components/Tooltip/Tooltip.css +9 -6
- package/__inner__/esm/components/Tooltip/Tooltip.js +16 -4
- package/__inner__/esm/components/Tooltip/constants.d.ts +1 -1
- package/__inner__/esm/components/Tooltip/constants.js +1 -1
- package/__inner__/esm/components/Tooltip/types.d.ts +11 -3
- package/package.json +4 -4
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
.Alert {
|
|
3
3
|
--alert-status-line-width: 8px;
|
|
4
4
|
--alert-status-line-gutter: var(--control-padding-xs);
|
|
5
|
+
--alert-title-text-color: var(--color-content-primary);
|
|
6
|
+
--alert-body-text-color: var(--color-content-secondary);
|
|
7
|
+
--alert-icon-color: var(--color-content-primary);
|
|
8
|
+
--alert-close-button-color: var(--color-content-primary);
|
|
5
9
|
display: flex;
|
|
6
10
|
overflow: auto;
|
|
7
11
|
inline-size: 100%;
|
|
@@ -22,18 +26,13 @@
|
|
|
22
26
|
|
|
23
27
|
text-transform: var(--typography-text-xs-text_transform, none);
|
|
24
28
|
}
|
|
25
|
-
.
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
--alert-title-text-color: var(--color-content-primary-inverse);
|
|
33
|
-
--alert-body-text-color: var(--color-content-primary-inverse);
|
|
34
|
-
--alert-icon-color: var(--color-content-primary-inverse);
|
|
35
|
-
--alert-close-button-color: var(--color-content-primary-inverse);
|
|
36
|
-
}
|
|
29
|
+
.Alert_color_dark,
|
|
30
|
+
.Alert_inverse {
|
|
31
|
+
--alert-title-text-color: var(--color-content-primary-inverse);
|
|
32
|
+
--alert-body-text-color: var(--color-content-primary-inverse);
|
|
33
|
+
--alert-icon-color: var(--color-content-primary-inverse);
|
|
34
|
+
--alert-close-button-color: var(--color-content-primary-inverse);
|
|
35
|
+
}
|
|
37
36
|
.Alert_status_info {
|
|
38
37
|
--alert-icon-color: var(--color-content-info);
|
|
39
38
|
--alert-status-line-color: var(--color-background-info);
|
|
@@ -1,43 +1,17 @@
|
|
|
1
1
|
import './Alert.css';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import type { HTMLAttributes, ReactElement, ReactNode, MouseEvent } from 'react';
|
|
4
3
|
import type { ButtonProps } from '../ButtonNext';
|
|
5
4
|
export declare const cnAlert: import("@bem-react/classname").ClassNameFormatter;
|
|
6
|
-
export declare const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
color?: AlertColorVariant;
|
|
20
|
-
/**
|
|
21
|
-
* Если {true} отображает иконку со статусом
|
|
22
|
-
* @default true
|
|
23
|
-
*/
|
|
24
|
-
showIcon?: boolean;
|
|
25
|
-
/**
|
|
26
|
-
* Функция обратного вызова при нажатии на кнопку закрытия
|
|
27
|
-
*/
|
|
28
|
-
onClose?: (e: MouseEvent<HTMLButtonElement>) => void;
|
|
29
|
-
/**
|
|
30
|
-
* Основное содержимое элемента
|
|
31
|
-
* @default null
|
|
32
|
-
* */
|
|
33
|
-
children?: ReactNode;
|
|
34
|
-
/** Действие: кнопка или ссылка. Свойство принимает React-элемент или рендер-функцию */
|
|
35
|
-
action?: ReactElement<ButtonProps> | (({ size, className, }: Pick<ButtonProps, 'size' | 'className'>) => ReactElement);
|
|
36
|
-
/** Дополнительные CSS-классы */
|
|
37
|
-
className?: string;
|
|
38
|
-
/** Текст для кнопки закрытия компонента */
|
|
39
|
-
closeText?: string;
|
|
40
|
-
};
|
|
41
|
-
export type AlertProps = AlertBaseProps & Omit<HTMLAttributes<HTMLDivElement>, 'title'>;
|
|
42
|
-
export declare const Alert: React.ForwardRefExoticComponent<AlertBaseProps & Omit<React.HTMLAttributes<HTMLDivElement>, "title"> & React.RefAttributes<HTMLDivElement>>;
|
|
43
|
-
export {};
|
|
5
|
+
export declare const Alert: React.ForwardRefExoticComponent<{
|
|
6
|
+
title: React.ReactNode;
|
|
7
|
+
status?: "error" | "info" | "success" | "warning" | undefined;
|
|
8
|
+
inverse?: boolean | undefined;
|
|
9
|
+
showIcon?: boolean | undefined;
|
|
10
|
+
onClose?: ((e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void) | undefined;
|
|
11
|
+
children?: React.ReactNode;
|
|
12
|
+
action?: React.ReactElement<ButtonProps, string | React.JSXElementConstructor<any>> | (({ size, className, }: Pick<ButtonProps, "className" | "size">) => React.ReactElement<any, string | React.JSXElementConstructor<any>>) | undefined;
|
|
13
|
+
className?: string | undefined;
|
|
14
|
+
closeText?: string | undefined;
|
|
15
|
+
} & Omit<React.HTMLAttributes<HTMLDivElement>, "title" | "color"> & {
|
|
16
|
+
color?: "dark" | "light" | undefined;
|
|
17
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -2,32 +2,29 @@ import { __assign, __rest } from "tslib";
|
|
|
2
2
|
import './Alert.css';
|
|
3
3
|
import React, { forwardRef, useMemo } from 'react';
|
|
4
4
|
import { CrossIcon, InfoCircleFilledIcon, CheckCircleFilledIcon, WarningTriangleFilledIcon, WarningCircleFilledIcon, } from '@ozen-ui/icons';
|
|
5
|
+
import { deprecate } from '@ozen-ui/logger';
|
|
5
6
|
import { useThemeProps } from '../../hooks/useThemeProps';
|
|
6
7
|
import { cn } from '../../utils/classname';
|
|
7
8
|
import { IconButton } from '../IconButtonNext';
|
|
8
9
|
import { Paper } from '../Paper';
|
|
9
|
-
import { ALERT_DEFAULT_STATUS, ALERT_DEFAULT_SHOW_ICON,
|
|
10
|
+
import { ALERT_DEFAULT_STATUS, ALERT_DEFAULT_SHOW_ICON, ALERT_DEFAULT_INVERSE, } from './constants';
|
|
10
11
|
export var cnAlert = cn('Alert');
|
|
11
|
-
export var alertStatusVariant = [
|
|
12
|
-
'success',
|
|
13
|
-
'error',
|
|
14
|
-
'warning',
|
|
15
|
-
'info',
|
|
16
|
-
];
|
|
17
|
-
export var alertColorVariant = ['light', 'dark'];
|
|
18
12
|
var matchStatusToIcon = {
|
|
19
|
-
neutral: React.createElement(InfoCircleFilledIcon, { size: "s" }),
|
|
20
13
|
info: React.createElement(InfoCircleFilledIcon, { size: "s" }),
|
|
21
|
-
|
|
14
|
+
neutral: React.createElement(InfoCircleFilledIcon, { size: "s" }),
|
|
22
15
|
success: React.createElement(CheckCircleFilledIcon, { size: "s" }),
|
|
23
16
|
error: React.createElement(WarningCircleFilledIcon, { size: "s" }),
|
|
17
|
+
warning: React.createElement(WarningTriangleFilledIcon, { size: "s" }),
|
|
24
18
|
};
|
|
25
19
|
export var Alert = forwardRef(function (inProps, ref) {
|
|
26
20
|
var props = useThemeProps({
|
|
27
21
|
props: inProps,
|
|
28
22
|
name: 'Alert',
|
|
29
23
|
});
|
|
30
|
-
var _a = props.status, status = _a === void 0 ? ALERT_DEFAULT_STATUS : _a, _b = props.showIcon, showIcon = _b === void 0 ? ALERT_DEFAULT_SHOW_ICON : _b, _c = props.
|
|
24
|
+
var _a = props.status, status = _a === void 0 ? ALERT_DEFAULT_STATUS : _a, _b = props.showIcon, showIcon = _b === void 0 ? ALERT_DEFAULT_SHOW_ICON : _b, _c = props.inverse, inverse = _c === void 0 ? ALERT_DEFAULT_INVERSE : _c, color = props.color, closeText = props.closeText, children = props.children, actionProp = props.action, onClose = props.onClose, title = props.title, className = props.className, other = __rest(props, ["status", "showIcon", "inverse", "color", "closeText", "children", "action", "onClose", "title", "className"]);
|
|
25
|
+
if (process.env.NODE_ENV !== 'production' && color) {
|
|
26
|
+
deprecate('Свойство «color» устарело. Для замены используйте «inverse».');
|
|
27
|
+
}
|
|
31
28
|
var action = useMemo(function () {
|
|
32
29
|
var actionProps = {
|
|
33
30
|
size: '2xs',
|
|
@@ -41,9 +38,12 @@ export var Alert = forwardRef(function (inProps, ref) {
|
|
|
41
38
|
}
|
|
42
39
|
return React.cloneElement(actionProp, actionProps);
|
|
43
40
|
}, [actionProp]);
|
|
44
|
-
return (React.createElement(Paper, __assign({ radius: "l", shadow: "m", role: "alert", background: color === '
|
|
45
|
-
|
|
46
|
-
|
|
41
|
+
return (React.createElement(Paper, __assign({ radius: "l", shadow: "m", role: "alert", background: "main" }, (color === 'dark' && { background: 'main-inverse' }), (inverse && { background: 'main-inverse' }), other, { className: cnAlert({
|
|
42
|
+
color: color,
|
|
43
|
+
status: status,
|
|
44
|
+
inverse: inverse,
|
|
45
|
+
hasCloseButton: !!onClose,
|
|
46
|
+
}, [className]), ref: ref }),
|
|
47
47
|
showIcon && (React.createElement("div", { className: cnAlert('Icon') }, matchStatusToIcon[status])),
|
|
48
48
|
React.createElement("div", { className: cnAlert('Content') },
|
|
49
49
|
React.createElement("div", { className: cnAlert('Title') }, title),
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { HTMLAttributes, MouseEvent, ReactElement, ReactNode } from 'react';
|
|
2
|
+
import type { ButtonProps } from '../ButtonNext';
|
|
3
|
+
export declare const alertStatusVariant: readonly ["success", "error", "warning", "info"];
|
|
4
|
+
export declare const alertColorVariant: readonly ["light", "dark"];
|
|
5
|
+
export type AlertStatusVariant = (typeof alertStatusVariant)[number];
|
|
6
|
+
export type AlertColorVariant = (typeof alertColorVariant)[number];
|
|
7
|
+
type AlertPropsDeprecated = {
|
|
8
|
+
/**
|
|
9
|
+
* Цветовая палитра сообщения
|
|
10
|
+
* @deprecated Используйте на замену свойство «inverse»
|
|
11
|
+
* */
|
|
12
|
+
color?: AlertColorVariant;
|
|
13
|
+
};
|
|
14
|
+
type AlertBaseProps = {
|
|
15
|
+
/** Заголовок сообщения */
|
|
16
|
+
title: ReactNode;
|
|
17
|
+
/**
|
|
18
|
+
* Статус сообщения
|
|
19
|
+
* @default info
|
|
20
|
+
*/
|
|
21
|
+
status?: AlertStatusVariant;
|
|
22
|
+
/** Если {true} инвертирует основные цвета компонента */
|
|
23
|
+
inverse?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Если {true} отображает иконку со статусом
|
|
26
|
+
* @default true
|
|
27
|
+
*/
|
|
28
|
+
showIcon?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Функция обратного вызова при нажатии на кнопку закрытия
|
|
31
|
+
*/
|
|
32
|
+
onClose?: (e: MouseEvent<HTMLButtonElement>) => void;
|
|
33
|
+
/**
|
|
34
|
+
* Основное содержимое элемента
|
|
35
|
+
* @default null
|
|
36
|
+
* */
|
|
37
|
+
children?: ReactNode;
|
|
38
|
+
/** Действие: кнопка или ссылка. Свойство принимает React-элемент или рендер-функцию */
|
|
39
|
+
action?: ReactElement<ButtonProps> | (({ size, className, }: Pick<ButtonProps, 'size' | 'className'>) => ReactElement);
|
|
40
|
+
/** Дополнительные CSS-классы */
|
|
41
|
+
className?: string;
|
|
42
|
+
/** Текст для кнопки закрытия компонента */
|
|
43
|
+
closeText?: string;
|
|
44
|
+
};
|
|
45
|
+
export type AlertProps = AlertBaseProps & Omit<HTMLAttributes<HTMLDivElement>, 'title' | 'color'> & AlertPropsDeprecated;
|
|
46
|
+
export {};
|
|
@@ -3,7 +3,7 @@ import type { InputNumberValue, InputNumberCountDirection } from './types';
|
|
|
3
3
|
export declare const isValidValue: (value?: InputNumberValue) => boolean;
|
|
4
4
|
export declare const isInputInvalid: (event: KeyboardEvent<HTMLInputElement>) => boolean;
|
|
5
5
|
export declare const getValue: ({ value, step, min, max, countDirection, }: {
|
|
6
|
-
value?: InputNumberValue
|
|
6
|
+
value?: InputNumberValue;
|
|
7
7
|
countDirection: InputNumberCountDirection;
|
|
8
8
|
min: number;
|
|
9
9
|
max: number;
|
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
import './ListItemText.css';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import type { HTMLAttributes } from 'react';
|
|
4
|
-
import type { TypographyProps } from '../../../Typography';
|
|
4
|
+
import type { TypographyProps, TypographyBaseProps } from '../../../Typography';
|
|
5
5
|
export type ListItemTextProps = {
|
|
6
6
|
children?: never;
|
|
7
7
|
/** Основной текст */
|
|
8
|
-
primary:
|
|
8
|
+
primary: TypographyBaseProps['children'];
|
|
9
9
|
/** Свойства компонента Typography для текста primary */
|
|
10
10
|
primaryTypographyProps?: TypographyProps<'span'>;
|
|
11
11
|
/** Второстепенный текст */
|
|
12
|
-
secondary?:
|
|
12
|
+
secondary?: TypographyBaseProps['children'];
|
|
13
13
|
/** Свойства компонента Typography для текста secondary */
|
|
14
14
|
secondaryTypographyProps?: TypographyProps<'span'>;
|
|
15
15
|
} & HTMLAttributes<HTMLDivElement>;
|
|
16
16
|
export declare const ListItemText: React.ForwardRefExoticComponent<{
|
|
17
17
|
children?: undefined;
|
|
18
18
|
/** Основной текст */
|
|
19
|
-
primary:
|
|
19
|
+
primary: TypographyBaseProps['children'];
|
|
20
20
|
/** Свойства компонента Typography для текста primary */
|
|
21
21
|
primaryTypographyProps?: TypographyProps<"span"> | undefined;
|
|
22
22
|
/** Второстепенный текст */
|
|
23
|
-
secondary?:
|
|
23
|
+
secondary?: TypographyBaseProps['children'];
|
|
24
24
|
/** Свойства компонента Typography для текста secondary */
|
|
25
25
|
secondaryTypographyProps?: TypographyProps<"span"> | undefined;
|
|
26
26
|
} & React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -1,70 +1,46 @@
|
|
|
1
1
|
.Popover {
|
|
2
|
-
|
|
2
|
+
outline: none;
|
|
3
3
|
inline-size: auto;
|
|
4
4
|
box-sizing: border-box;
|
|
5
|
-
|
|
5
|
+
z-index: var(--z-index-popover);
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
.Popover-Arrow {
|
|
9
|
+
--popover-arrow-inset: calc(-1 * (var(--popover-arrow-size) / 2));
|
|
9
10
|
display: flex;
|
|
11
|
+
align-items: start;
|
|
12
|
+
flex-direction: column;
|
|
13
|
+
inline-size: var(--popover-arrow-size);
|
|
14
|
+
block-size: var(--popover-arrow-size);
|
|
10
15
|
color: var(--paper-background-color);
|
|
11
16
|
}
|
|
12
17
|
|
|
13
|
-
.Popover
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
.Popover[data-popper-placement^='top'] > .Popover-Arrow_size_xs svg {
|
|
18
|
-
transform: rotate(270deg);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
.Popover[data-popper-placement^='top'] > .Popover-Arrow_size_s {
|
|
22
|
-
inset-block-end: -12px;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
.Popover[data-popper-placement^='top'] > .Popover-Arrow_size_s svg {
|
|
26
|
-
transform: rotate(270deg);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
.Popover[data-popper-placement^='bottom'] > .Popover-Arrow_size_xs {
|
|
30
|
-
inset-block-start: -9px;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
.Popover[data-popper-placement^='bottom'] > .Popover-Arrow_size_xs svg {
|
|
34
|
-
transform: rotate(90deg);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
.Popover[data-popper-placement^='bottom'] > .Popover-Arrow_size_s {
|
|
38
|
-
inset-block-start: -12px;
|
|
18
|
+
.Popover-Arrow_size_xs {
|
|
19
|
+
--popover-arrow-size: 12px;
|
|
39
20
|
}
|
|
40
21
|
|
|
41
|
-
.Popover
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
.Popover[data-popper-placement^='left'] > .Popover-Arrow_size_xs {
|
|
46
|
-
inset-inline-end: -6px;
|
|
22
|
+
.Popover-Arrow_size_s {
|
|
23
|
+
--popover-arrow-size: 16px;
|
|
47
24
|
}
|
|
48
25
|
|
|
49
|
-
.Popover[data-popper-placement^='
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
.Popover[data-popper-placement^='left'] > .Popover-Arrow_size_s {
|
|
54
|
-
inset-inline-end: -8px;
|
|
55
|
-
}
|
|
26
|
+
.Popover[data-popper-placement^='top'] > .Popover-Arrow {
|
|
27
|
+
transform: rotate(270deg);
|
|
28
|
+
inset-block-end: var(--popover-arrow-inset);
|
|
29
|
+
}
|
|
56
30
|
|
|
57
|
-
.Popover[data-popper-placement^='
|
|
58
|
-
|
|
59
|
-
|
|
31
|
+
.Popover[data-popper-placement^='bottom'] > .Popover-Arrow {
|
|
32
|
+
transform: rotate(90deg);
|
|
33
|
+
inset-block-start: var(--popover-arrow-inset);
|
|
34
|
+
}
|
|
60
35
|
|
|
61
|
-
.Popover[data-popper-placement^='
|
|
62
|
-
|
|
63
|
-
|
|
36
|
+
.Popover[data-popper-placement^='left'] > .Popover-Arrow {
|
|
37
|
+
transform: rotate(180deg);
|
|
38
|
+
inset-inline-end: var(--popover-arrow-inset);
|
|
39
|
+
}
|
|
64
40
|
|
|
65
|
-
.Popover[data-popper-placement^='right'] > .Popover-
|
|
66
|
-
|
|
67
|
-
|
|
41
|
+
.Popover[data-popper-placement^='right'] > .Popover-Arrow {
|
|
42
|
+
inset-inline-start: var(--popover-arrow-inset);
|
|
43
|
+
}
|
|
68
44
|
|
|
69
45
|
.Popover_disableInteractive {
|
|
70
46
|
pointer-events: none;
|
|
@@ -19,7 +19,7 @@ import { PopoverContext } from './PopoverContext';
|
|
|
19
19
|
export var cnPopover = cn('Popover');
|
|
20
20
|
export var Popover = polymorphicComponentWithRef(function (inProps, ref) {
|
|
21
21
|
var props = useThemeProps({ props: inProps, name: 'Popover' });
|
|
22
|
-
var _a = props.arrow, arrow = _a === void 0 ? POPOVER_DEFAULT_ARROW : _a, _b = props.open, open = _b === void 0 ? POPOVER_DEFAULT_OPEN : _b, _c = props.disableInteractive, disableInteractive = _c === void 0 ? POPOVER_DEFAULT_DISABLE_INTERACTIVE : _c, _d = props.disableEnforceFocus, disableEnforceFocus = _d === void 0 ? POPOVER_DEFAULT_DISABLE_ENFORCE_FOCUS : _d, _e = props.disableReturnFocus, disableReturnFocus = _e === void 0 ? POPOVER_DEFAULT_DISABLE_RETURN_FOCUS : _e, _f = props.disableClickOutside, disableClickOutside = _f === void 0 ? POPOVER_DEFAULT_DISABLE_CLICK_OUTSIDE : _f, _g = props.placement, placement = _g === void 0 ? POPOVER_DEFAULT_PLACEMENT : _g, _h = props.strategy, strategy = _h === void 0 ? POPOVER_DEFAULT_STRATEGY : _h, _j = props.disablePreventOverflow, disablePreventOverflow = _j === void 0 ? POPOVER_DEFAULT_DISABLE_PREVENT_OVERFLOW : _j, ignoreClickOutsideRefs = props.ignoreClickOutsideRefs, arrowProps = props.arrowProps, anchorRef = props.anchorRef, equalAnchorWidth = props.equalAnchorWidth, offset = props.offset, children = props.children, transitionProps = props.transitionProps, onClose = props.onClose, onEnter = props.onEnter, onEntered = props.onEntered, onExit = props.onExit, onExitedProp = props.onExited, className = props.className, position = props.position, style = props.style, setUpdate = props.setUpdate, _k = props.as, as = _k === void 0 ? POPOVER_DEFAULT_TAG : _k, other = __rest(props, ["arrow", "open", "disableInteractive", "disableEnforceFocus", "disableReturnFocus", "disableClickOutside", "placement", "strategy", "disablePreventOverflow", "ignoreClickOutsideRefs", "arrowProps", "anchorRef", "equalAnchorWidth", "offset", "children", "transitionProps", "onClose", "onEnter", "onEntered", "onExit", "onExited", "className", "position", "style", "setUpdate", "as"]);
|
|
22
|
+
var _a = props.arrow, arrow = _a === void 0 ? POPOVER_DEFAULT_ARROW : _a, _b = props.open, open = _b === void 0 ? POPOVER_DEFAULT_OPEN : _b, _c = props.disableInteractive, disableInteractive = _c === void 0 ? POPOVER_DEFAULT_DISABLE_INTERACTIVE : _c, _d = props.disableEnforceFocus, disableEnforceFocus = _d === void 0 ? POPOVER_DEFAULT_DISABLE_ENFORCE_FOCUS : _d, _e = props.disableReturnFocus, disableReturnFocus = _e === void 0 ? POPOVER_DEFAULT_DISABLE_RETURN_FOCUS : _e, _f = props.disableClickOutside, disableClickOutside = _f === void 0 ? POPOVER_DEFAULT_DISABLE_CLICK_OUTSIDE : _f, _g = props.placement, placement = _g === void 0 ? POPOVER_DEFAULT_PLACEMENT : _g, _h = props.strategy, strategy = _h === void 0 ? POPOVER_DEFAULT_STRATEGY : _h, _j = props.disablePreventOverflow, disablePreventOverflow = _j === void 0 ? POPOVER_DEFAULT_DISABLE_PREVENT_OVERFLOW : _j, ignoreClickOutsideRefs = props.ignoreClickOutsideRefs, arrowProps = props.arrowProps, anchorRef = props.anchorRef, equalAnchorWidth = props.equalAnchorWidth, offset = props.offset, children = props.children, transitionProps = props.transitionProps, onClose = props.onClose, onEnter = props.onEnter, onEntered = props.onEntered, onExit = props.onExit, onExitedProp = props.onExited, className = props.className, position = props.position, style = props.style, setUpdate = props.setUpdate, modifiersProps = props.modifiers, _k = props.as, as = _k === void 0 ? POPOVER_DEFAULT_TAG : _k, other = __rest(props, ["arrow", "open", "disableInteractive", "disableEnforceFocus", "disableReturnFocus", "disableClickOutside", "placement", "strategy", "disablePreventOverflow", "ignoreClickOutsideRefs", "arrowProps", "anchorRef", "equalAnchorWidth", "offset", "children", "transitionProps", "onClose", "onEnter", "onEntered", "onExit", "onExited", "className", "position", "style", "setUpdate", "modifiers", "as"]);
|
|
23
23
|
var _l = __read(useState(false), 2), openState = _l[0], setOpenState = _l[1];
|
|
24
24
|
var focusedElement = useRef(null);
|
|
25
25
|
var popoverRef = useRef(null);
|
|
@@ -59,7 +59,7 @@ export var Popover = polymorphicComponentWithRef(function (inProps, ref) {
|
|
|
59
59
|
}
|
|
60
60
|
onExitedProp === null || onExitedProp === void 0 ? void 0 : onExitedProp();
|
|
61
61
|
}, [onExitedProp]);
|
|
62
|
-
var modifiers = useMemo(function () { return [
|
|
62
|
+
var modifiers = useMemo(function () { return __spreadArray([
|
|
63
63
|
// Вычисление стилей позиционирования
|
|
64
64
|
{
|
|
65
65
|
name: 'computeStyles',
|
|
@@ -90,14 +90,20 @@ export var Popover = polymorphicComponentWithRef(function (inProps, ref) {
|
|
|
90
90
|
phase: 'beforeWrite',
|
|
91
91
|
requires: ['computeStyles'],
|
|
92
92
|
},
|
|
93
|
+
{
|
|
94
|
+
name: 'arrow',
|
|
95
|
+
options: {
|
|
96
|
+
padding: 12,
|
|
97
|
+
},
|
|
98
|
+
},
|
|
93
99
|
// Отступы от якорного элемента
|
|
94
100
|
{
|
|
95
101
|
name: 'offset',
|
|
96
102
|
options: {
|
|
97
103
|
offset: offset,
|
|
98
104
|
},
|
|
99
|
-
}
|
|
100
|
-
]; }, [offset, equalAnchorWidth]);
|
|
105
|
+
}
|
|
106
|
+
], __read((modifiersProps || [])), false); }, [offset, equalAnchorWidth, modifiersProps]);
|
|
101
107
|
// Якорный элемент или координаты
|
|
102
108
|
var resolveReferenceElement = useMemo(function () {
|
|
103
109
|
if (anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.current)
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { RefObject, ComponentRef, ElementType, ReactNode } from 'react';
|
|
2
2
|
import type PopperJS from '@popperjs/core';
|
|
3
|
+
import type { PopperProps } from 'react-popper';
|
|
3
4
|
import type { CSSTransitionProps } from 'react-transition-group/CSSTransition';
|
|
4
5
|
import type { PolymorphicComponentPropsWithRef } from '../../utils/polymorphicComponentWithRef';
|
|
5
6
|
import type { PortalProps } from '../Portal';
|
|
@@ -76,6 +77,11 @@ export type PopoverBaseProps = {
|
|
|
76
77
|
strategy?: PopoverStrategyVariant;
|
|
77
78
|
/** Если {true} позволяет смещаться по границе якорного элемента компонента */
|
|
78
79
|
disablePreventOverflow?: boolean;
|
|
80
|
+
/**
|
|
81
|
+
* Модификаторы для popper.js
|
|
82
|
+
* https://popper.js.org/docs/v2/modifiers/#custom-modifiers
|
|
83
|
+
* */
|
|
84
|
+
modifiers?: PopperProps<unknown>['modifiers'];
|
|
79
85
|
};
|
|
80
86
|
export type PopoverRef = ComponentRef<typeof POPOVER_DEFAULT_TAG>;
|
|
81
87
|
export type PopoverProps<As extends ElementType = typeof POPOVER_DEFAULT_TAG> = PolymorphicComponentPropsWithRef<PopoverBaseProps, As>;
|
|
@@ -86,6 +86,6 @@ export var SnackbarItem = forwardRef(function (_a, ref) {
|
|
|
86
86
|
}, className: cnSnackbarItem({
|
|
87
87
|
anchorHorizontal: horizontal,
|
|
88
88
|
anchorVertical: vertical,
|
|
89
|
-
}) }, renderContent() || (React.createElement(Alert, {
|
|
89
|
+
}) }, renderContent() || (React.createElement(Alert, { title: title, status: status, onClose: handleClose, inverse: true }, description))))));
|
|
90
90
|
});
|
|
91
91
|
SnackbarItem.displayName = 'SnackbarItem';
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
/* stylelint-disable */
|
|
2
2
|
.Tooltip {
|
|
3
3
|
max-inline-size: 300px;
|
|
4
|
+
color: var(--color-content-primary);
|
|
4
5
|
}
|
|
5
6
|
.Tooltip_size_xs {
|
|
7
|
+
min-inline-size: 28px;
|
|
8
|
+
min-block-size: 28px;
|
|
6
9
|
padding: var(--spacing-2xs) var(--spacing-xs);
|
|
7
10
|
|
|
8
11
|
font: var(--typography-text-xs-font);
|
|
@@ -12,6 +15,8 @@
|
|
|
12
15
|
text-transform: var(--typography-text-xs-text_transform, none);
|
|
13
16
|
}
|
|
14
17
|
.Tooltip_size_s {
|
|
18
|
+
min-inline-size: 40px;
|
|
19
|
+
min-block-size: 40px;
|
|
15
20
|
padding: var(--spacing-xs) var(--spacing-s);
|
|
16
21
|
|
|
17
22
|
font: var(--typography-text-s-font);
|
|
@@ -20,9 +25,7 @@
|
|
|
20
25
|
|
|
21
26
|
text-transform: var(--typography-text-s-text_transform, none);
|
|
22
27
|
}
|
|
23
|
-
.
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
color: var(--color-content-primary-inverse);
|
|
28
|
-
}
|
|
28
|
+
.Tooltip_variant_dark,
|
|
29
|
+
.Tooltip_inverse {
|
|
30
|
+
color: var(--color-content-primary-inverse);
|
|
31
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { __assign, __read, __rest } from "tslib";
|
|
2
2
|
import './Tooltip.css';
|
|
3
3
|
import React, { useRef, useMemo, useState, useEffect } from 'react';
|
|
4
|
+
import { deprecate } from '@ozen-ui/logger';
|
|
4
5
|
import { useControlled } from '../../hooks/useControlled';
|
|
5
6
|
import { useDebounceCallback } from '../../hooks/useDebounceCallback';
|
|
6
7
|
import { useMultiRef } from '../../hooks/useMultiRef';
|
|
@@ -8,15 +9,26 @@ import { useThemeProps } from '../../hooks/useThemeProps';
|
|
|
8
9
|
import { cn } from '../../utils/classname';
|
|
9
10
|
import { polymorphicComponentWithRef } from '../../utils/polymorphicComponentWithRef';
|
|
10
11
|
import { Popover } from '../Popover';
|
|
11
|
-
import { TOOLTIP_DEFAULT_ARROW, TOOLTIP_DEFAULT_DELAY_ENTER, TOOLTIP_DEFAULT_DELAY_LEAVE, TOOLTIP_DEFAULT_DISABLED, TOOLTIP_DEFAULT_OFFSET, TOOLTIP_DEFAULT_SHOULD_WRAP_CHILDREN, TOOLTIP_DEFAULT_SIZE, TOOLTIP_DEFAULT_TAG, TOOLTIP_DEFAULT_TRIGGER,
|
|
12
|
+
import { TOOLTIP_DEFAULT_ARROW, TOOLTIP_DEFAULT_DELAY_ENTER, TOOLTIP_DEFAULT_DELAY_LEAVE, TOOLTIP_DEFAULT_DISABLED, TOOLTIP_DEFAULT_INVERSE, TOOLTIP_DEFAULT_OFFSET, TOOLTIP_DEFAULT_SHOULD_WRAP_CHILDREN, TOOLTIP_DEFAULT_SIZE, TOOLTIP_DEFAULT_TAG, TOOLTIP_DEFAULT_TRIGGER, } from './constants';
|
|
12
13
|
export var cnTooltip = cn('Tooltip');
|
|
13
14
|
export var Tooltip = polymorphicComponentWithRef(function (inProps, ref) {
|
|
14
15
|
var props = useThemeProps({ props: inProps, name: 'Tooltip' });
|
|
15
|
-
var _a = props.trigger, trigger = _a === void 0 ? TOOLTIP_DEFAULT_TRIGGER : _a, _b = props.size, size = _b === void 0 ? TOOLTIP_DEFAULT_SIZE : _b, _c = props.
|
|
16
|
+
var _a = props.trigger, trigger = _a === void 0 ? TOOLTIP_DEFAULT_TRIGGER : _a, _b = props.size, size = _b === void 0 ? TOOLTIP_DEFAULT_SIZE : _b, _c = props.offset, offset = _c === void 0 ? TOOLTIP_DEFAULT_OFFSET : _c, _d = props.delayEnter, delayEnter = _d === void 0 ? TOOLTIP_DEFAULT_DELAY_ENTER : _d, _e = props.delayLeave, delayLeave = _e === void 0 ? TOOLTIP_DEFAULT_DELAY_LEAVE : _e, _f = props.arrow, arrow = _f === void 0 ? TOOLTIP_DEFAULT_ARROW : _f, _g = props.shouldWrapChildren, shouldWrapChildren = _g === void 0 ? TOOLTIP_DEFAULT_SHOULD_WRAP_CHILDREN : _g, _h = props.disabled, disabled = _h === void 0 ? TOOLTIP_DEFAULT_DISABLED : _h, _j = props.inverse, inverse = _j === void 0 ? TOOLTIP_DEFAULT_INVERSE : _j, variant = props.variant, children = props.children, label = props.label, openProp = props.open, placement = props.placement, disableInteractive = props.disableInteractive, className = props.className, onOpen = props.onOpen, onClose = props.onClose, _k = props.as, as = _k === void 0 ? TOOLTIP_DEFAULT_TAG : _k, other = __rest(props, ["trigger", "size", "offset", "delayEnter", "delayLeave", "arrow", "shouldWrapChildren", "disabled", "inverse", "variant", "children", "label", "open", "placement", "disableInteractive", "className", "onOpen", "onClose", "as"]);
|
|
17
|
+
if (process.env.NODE_ENV !== 'production' && variant) {
|
|
18
|
+
deprecate('Свойство «variant» устарело. Для замены используйте «inverse».');
|
|
19
|
+
}
|
|
16
20
|
var _l = __read(useState(), 2), delay = _l[0], setDelay = _l[1];
|
|
17
21
|
var _m = __read(useState(), 2), hasFocus = _m[0], setHasFocus = _m[1];
|
|
18
22
|
var _o = __read(useState(), 2), hasHover = _o[0], setHasHover = _o[1];
|
|
19
23
|
var anchorRef = useRef(null);
|
|
24
|
+
var modifiers = [
|
|
25
|
+
{
|
|
26
|
+
name: 'arrow',
|
|
27
|
+
options: {
|
|
28
|
+
padding: size === 'xs' ? 8 : 12,
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
];
|
|
20
32
|
var _p = __read(useControlled({
|
|
21
33
|
value: openProp,
|
|
22
34
|
defaultValue: false,
|
|
@@ -112,8 +124,8 @@ export var Tooltip = polymorphicComponentWithRef(function (inProps, ref) {
|
|
|
112
124
|
]);
|
|
113
125
|
return (React.createElement(React.Fragment, null,
|
|
114
126
|
React.cloneElement(resolveChildren, composeChildrenProps),
|
|
115
|
-
React.createElement(Popover, __assign({ anchorRef: anchorRef, strategy: "absolute", as: as, background: variant === '
|
|
127
|
+
React.createElement(Popover, __assign({ anchorRef: anchorRef, strategy: "absolute", as: as, background: "main" }, (variant === 'dark' && { background: 'main-inverse' }), (inverse && { background: 'main-inverse' }), { radius: size === 'xs' ? 's' : 'l' }, other, { ref: ref, offset: offset, placement: placement, open: openState && !disabled, onClose: handleClose, className: cnTooltip({ size: size, variant: variant, inverse: inverse }, [className]), disableInteractive: disableInteractive, onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave, arrow: arrow, arrowProps: {
|
|
116
128
|
size: size,
|
|
117
|
-
}, disableEnforceFocus: true, disableReturnFocus: true }), label)));
|
|
129
|
+
}, modifiers: modifiers, disableEnforceFocus: true, disableReturnFocus: true }), label)));
|
|
118
130
|
});
|
|
119
131
|
Tooltip.displayName = 'Tooltip';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export declare const TOOLTIP_DEFAULT_TAG: import("../../utils/polymorphicComponentWithRef").PolymorphicComponentWithRef<import("../Paper").PaperBaseProps, "div">;
|
|
2
2
|
export declare const TOOLTIP_DEFAULT_TRIGGER = "hover";
|
|
3
3
|
export declare const TOOLTIP_DEFAULT_SIZE = "s";
|
|
4
|
-
export declare const
|
|
4
|
+
export declare const TOOLTIP_DEFAULT_INVERSE = true;
|
|
5
5
|
export declare const TOOLTIP_DEFAULT_OFFSET: number[];
|
|
6
6
|
export declare const TOOLTIP_DEFAULT_DELAY_ENTER = 100;
|
|
7
7
|
export declare const TOOLTIP_DEFAULT_DELAY_LEAVE = 100;
|
|
@@ -2,7 +2,7 @@ import { Paper } from '../Paper';
|
|
|
2
2
|
export var TOOLTIP_DEFAULT_TAG = Paper;
|
|
3
3
|
export var TOOLTIP_DEFAULT_TRIGGER = 'hover';
|
|
4
4
|
export var TOOLTIP_DEFAULT_SIZE = 's';
|
|
5
|
-
export var
|
|
5
|
+
export var TOOLTIP_DEFAULT_INVERSE = true;
|
|
6
6
|
export var TOOLTIP_DEFAULT_OFFSET = [0, 8];
|
|
7
7
|
export var TOOLTIP_DEFAULT_DELAY_ENTER = 100;
|
|
8
8
|
export var TOOLTIP_DEFAULT_DELAY_LEAVE = 100;
|
|
@@ -8,6 +8,13 @@ export declare const tooltipVariant: readonly ["light", "dark"];
|
|
|
8
8
|
export type TooltipVariant = (typeof tooltipVariant)[number];
|
|
9
9
|
export declare const tooltipTriggerVariant: readonly ["hover", "focus", "click", "hover&focus"];
|
|
10
10
|
export type TooltipTriggerVariant = (typeof tooltipTriggerVariant)[number];
|
|
11
|
+
type TooltipPropsDeprecated = {
|
|
12
|
+
/**
|
|
13
|
+
* Вариант представления
|
|
14
|
+
* @deprecated Используйте на замену свойство «inverse»
|
|
15
|
+
* */
|
|
16
|
+
variant?: TooltipVariant;
|
|
17
|
+
};
|
|
11
18
|
export type TooltipBaseProps = {
|
|
12
19
|
/** Признак по которому тултип будет представлен */
|
|
13
20
|
open?: boolean;
|
|
@@ -19,8 +26,8 @@ export type TooltipBaseProps = {
|
|
|
19
26
|
label?: ReactNode;
|
|
20
27
|
/** Размер тултипа */
|
|
21
28
|
size?: TooltipSizeVariant;
|
|
22
|
-
/**
|
|
23
|
-
|
|
29
|
+
/** Если {true} инвертирует основные цвета компонента */
|
|
30
|
+
inverse?: boolean;
|
|
24
31
|
/** Если {true} отключает отображение тултипа */
|
|
25
32
|
disabled?: boolean;
|
|
26
33
|
/** События вызова тултипа */
|
|
@@ -41,6 +48,7 @@ export type TooltipBaseProps = {
|
|
|
41
48
|
'data-testid'?: string;
|
|
42
49
|
/** Дополнительные CSS-классы */
|
|
43
50
|
className?: string;
|
|
44
|
-
} & Pick<PopoverBaseProps, 'offset' | 'placement' | 'arrow' | 'anchorRef' | 'ignoreClickOutsideRefs' | 'disableInteractive' | 'onEnter' | 'onEntered' | 'onExit' | 'onExited' | 'setUpdate'>;
|
|
51
|
+
} & TooltipPropsDeprecated & Pick<PopoverBaseProps, 'offset' | 'placement' | 'arrow' | 'anchorRef' | 'ignoreClickOutsideRefs' | 'disableInteractive' | 'onEnter' | 'onEntered' | 'onExit' | 'onExited' | 'setUpdate'>;
|
|
45
52
|
export type TooltipRef = ComponentRef<typeof TOOLTIP_DEFAULT_TAG>;
|
|
46
53
|
export type TooltipProps<As extends ElementType = typeof TOOLTIP_DEFAULT_TAG> = PolymorphicComponentPropsWithRef<TooltipBaseProps, As>;
|
|
54
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ozen-ui/kit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.49.1",
|
|
4
4
|
"description": "React component library",
|
|
5
5
|
"files": [
|
|
6
6
|
"*"
|
|
@@ -28,9 +28,9 @@
|
|
|
28
28
|
"react-popper": "^2.3.0",
|
|
29
29
|
"react-transition-group": "^4.4.5",
|
|
30
30
|
"tslib": "^2.6.2",
|
|
31
|
-
"@ozen-ui/
|
|
32
|
-
"@ozen-ui/
|
|
33
|
-
"@ozen-ui/
|
|
31
|
+
"@ozen-ui/logger": "0.49.1",
|
|
32
|
+
"@ozen-ui/fonts": "0.49.1",
|
|
33
|
+
"@ozen-ui/icons": "0.49.1"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
36
|
"react": ">=17.0.2 <19.0.0",
|