@ozen-ui/kit 0.56.0 → 0.57.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/__inner__/cjs/components/DataList/constants.d.ts +1 -1
- package/__inner__/cjs/components/DataList/constants.js +1 -2
- package/__inner__/cjs/components/Dialog/Dialog.d.ts +1 -2
- package/__inner__/cjs/components/Drawer/Drawer.d.ts +1 -2
- package/__inner__/cjs/components/Menu/Menu.js +2 -1
- package/__inner__/cjs/components/Modal/Modal.d.ts +1 -2
- package/__inner__/cjs/components/Modal/Modal.js +5 -6
- package/__inner__/cjs/components/Modal/constants.d.ts +0 -1
- package/__inner__/cjs/components/Modal/constants.js +1 -2
- package/__inner__/cjs/components/Modal/types.d.ts +0 -3
- package/__inner__/cjs/components/Popover/Popover.d.ts +1 -1
- package/__inner__/cjs/components/Popover/Popover.js +8 -3
- package/__inner__/cjs/components/Popover/constants.d.ts +1 -1
- package/__inner__/cjs/components/Popover/constants.js +1 -2
- package/__inner__/cjs/components/Popover/types.d.ts +2 -4
- package/__inner__/cjs/components/Portal/Portal.js +3 -3
- package/__inner__/cjs/components/Portal/constants.d.ts +2 -0
- package/__inner__/cjs/components/Portal/constants.js +3 -1
- package/__inner__/cjs/components/Portal/types.d.ts +3 -0
- package/__inner__/cjs/components/Snackbar/components/Snackbar/Snackbar.d.ts +1 -1
- package/__inner__/cjs/components/Tooltip/Tooltip.js +11 -11
- package/__inner__/cjs/components/Tooltip/constants.d.ts +1 -1
- package/__inner__/cjs/components/Tooltip/constants.js +1 -2
- package/__inner__/cjs/components/Tooltip/types.d.ts +1 -1
- package/__inner__/esm/components/DataList/constants.d.ts +1 -1
- package/__inner__/esm/components/DataList/constants.js +1 -2
- package/__inner__/esm/components/Dialog/Dialog.d.ts +1 -2
- package/__inner__/esm/components/Drawer/Drawer.d.ts +1 -2
- package/__inner__/esm/components/Menu/Menu.js +2 -1
- package/__inner__/esm/components/Modal/Modal.d.ts +1 -2
- package/__inner__/esm/components/Modal/Modal.js +6 -7
- package/__inner__/esm/components/Modal/constants.d.ts +0 -1
- package/__inner__/esm/components/Modal/constants.js +0 -1
- package/__inner__/esm/components/Modal/types.d.ts +0 -3
- package/__inner__/esm/components/Popover/Popover.d.ts +1 -1
- package/__inner__/esm/components/Popover/Popover.js +9 -4
- package/__inner__/esm/components/Popover/constants.d.ts +1 -1
- package/__inner__/esm/components/Popover/constants.js +1 -2
- package/__inner__/esm/components/Popover/types.d.ts +2 -4
- package/__inner__/esm/components/Portal/Portal.js +4 -4
- package/__inner__/esm/components/Portal/constants.d.ts +2 -0
- package/__inner__/esm/components/Portal/constants.js +2 -0
- package/__inner__/esm/components/Portal/types.d.ts +3 -0
- package/__inner__/esm/components/Snackbar/components/Snackbar/Snackbar.d.ts +1 -1
- package/__inner__/esm/components/Tooltip/Tooltip.js +12 -12
- package/__inner__/esm/components/Tooltip/constants.d.ts +1 -1
- package/__inner__/esm/components/Tooltip/constants.js +1 -2
- package/__inner__/esm/components/Tooltip/types.d.ts +1 -1
- package/package.json +6 -6
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const DATA_LIST_DEFAULT_TAG
|
|
1
|
+
export declare const DATA_LIST_DEFAULT_TAG = "div";
|
|
2
2
|
export declare const DATA_LIST_DEFAULT_SIZE = "m";
|
|
3
3
|
export declare const DATA_LIST_DEFAULT_OPEN = false;
|
|
4
4
|
export declare const DATA_LIST_OPTION_DEFAULT_DISABLED = false;
|
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DATA_LIST_OPTION_DEFAULT_TAG = exports.DATA_LIST_OPTION_DEFAULT_DISABLED = exports.DATA_LIST_DEFAULT_OPEN = exports.DATA_LIST_DEFAULT_SIZE = exports.DATA_LIST_DEFAULT_TAG = void 0;
|
|
4
4
|
var constants_1 = require("../List/constants");
|
|
5
|
-
|
|
6
|
-
exports.DATA_LIST_DEFAULT_TAG = Paper_1.Paper;
|
|
5
|
+
exports.DATA_LIST_DEFAULT_TAG = 'div';
|
|
7
6
|
exports.DATA_LIST_DEFAULT_SIZE = 'm';
|
|
8
7
|
exports.DATA_LIST_DEFAULT_OPEN = false;
|
|
9
8
|
exports.DATA_LIST_OPTION_DEFAULT_DISABLED = false;
|
|
@@ -41,7 +41,6 @@ export declare const Dialog: React.ForwardRefExoticComponent<{
|
|
|
41
41
|
className?: string | undefined;
|
|
42
42
|
'data-testid'?: string | undefined;
|
|
43
43
|
ignoreClickOutsideRefs?: React.RefObject<HTMLElement>[] | undefined;
|
|
44
|
-
disablePortal?: boolean | undefined;
|
|
45
44
|
} & import("../Portal").PortalBaseProps & {
|
|
46
45
|
as?: "div" | undefined;
|
|
47
|
-
} & Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "
|
|
46
|
+
} & Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, keyof import("../Portal").PortalBaseProps> & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -42,7 +42,6 @@ export declare const Drawer: React.ForwardRefExoticComponent<{
|
|
|
42
42
|
className?: string | undefined;
|
|
43
43
|
'data-testid'?: string | undefined;
|
|
44
44
|
ignoreClickOutsideRefs?: React.RefObject<HTMLElement>[] | undefined;
|
|
45
|
-
disablePortal?: boolean | undefined;
|
|
46
45
|
} & import("../Portal").PortalBaseProps & {
|
|
47
46
|
as?: "div" | undefined;
|
|
48
|
-
} & Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "
|
|
47
|
+
} & Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, keyof import("../Portal").PortalBaseProps> & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -8,6 +8,7 @@ var logger_1 = require("@ozen-ui/logger");
|
|
|
8
8
|
var useThemeProps_1 = require("../../hooks/useThemeProps");
|
|
9
9
|
var classname_1 = require("../../utils/classname");
|
|
10
10
|
var getPaperSizeToFormElement_1 = require("../../utils/getPaperSizeToFormElement");
|
|
11
|
+
var Paper_1 = require("../Paper");
|
|
11
12
|
var Popover_1 = require("../Popover");
|
|
12
13
|
var components_1 = require("./components");
|
|
13
14
|
var constants_1 = require("./constants");
|
|
@@ -19,7 +20,7 @@ exports.Menu = (0, react_1.forwardRef)(function (inProps, ref) {
|
|
|
19
20
|
if (process.env.NODE_ENV !== 'production' && menuListRef) {
|
|
20
21
|
(0, logger_1.deprecate)('Свойство «menuListRef» устарело. Для замены используйте «menuListProps.ref».');
|
|
21
22
|
}
|
|
22
|
-
return (react_1.default.createElement(Popover_1.Popover, tslib_1.__assign({ offset: [0, 4], radius: radius }, other, { open: open, onClose: onClose, className: (0, exports.cnMenu)('', [className]), disableEnforceFocus: true, ref: ref }),
|
|
23
|
+
return (react_1.default.createElement(Popover_1.Popover, tslib_1.__assign({ as: Paper_1.Paper, offset: [0, 4], radius: radius }, other, { open: open, onClose: onClose, className: (0, exports.cnMenu)('', [className]), disableEnforceFocus: true, ref: ref }),
|
|
23
24
|
react_1.default.createElement(components_1.MenuContextConsumer, { onClose: onClose, menuListRef: menuListRef, menuListProps: tslib_1.__assign(tslib_1.__assign({ size: size }, menuListProps), { ref: menuListRef || (menuListProps === null || menuListProps === void 0 ? void 0 : menuListProps.ref) }) }, children)));
|
|
24
25
|
});
|
|
25
26
|
exports.Menu.displayName = 'Menu';
|
|
@@ -34,7 +34,6 @@ export declare const Modal: React.ForwardRefExoticComponent<{
|
|
|
34
34
|
className?: string | undefined;
|
|
35
35
|
'data-testid'?: string | undefined;
|
|
36
36
|
ignoreClickOutsideRefs?: React.RefObject<HTMLElement>[] | undefined;
|
|
37
|
-
disablePortal?: boolean | undefined;
|
|
38
37
|
} & import("../Portal").PortalBaseProps & {
|
|
39
38
|
as?: "div" | undefined;
|
|
40
|
-
} & Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "
|
|
39
|
+
} & Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, keyof import("../Portal").PortalBaseProps> & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -19,15 +19,14 @@ var constants_1 = require("./constants");
|
|
|
19
19
|
var index_1 = require("./index");
|
|
20
20
|
exports.cnModal = (0, classname_1.cn)('Modal');
|
|
21
21
|
exports.Modal = (0, react_1.forwardRef)(function (_a, ref) {
|
|
22
|
-
var _b = _a.open, open = _b === void 0 ? constants_1.MODAL_DEFAULT_OPEN : _b, _c = _a.keepMounted, keepMounted = _c === void 0 ? constants_1.MODAL_DEFAULT_KEEP_MOUNTED : _c, _d = _a.hideBackdrop, hideBackdrop = _d === void 0 ? constants_1.MODAL_DEFAULT_HIDE_BACKDROP : _d, _e = _a.disableScrollLock, disableScrollLock = _e === void 0 ? constants_1.MODAL_DEFAULT_DISABLE_SCROLL_LOCK : _e, _f = _a.disableClickOutside, disableClickOutside = _f === void 0 ? constants_1.MODAL_DEFAULT_DISABLE_CLICK_OUTSIDE : _f, _g = _a.disableEscapeKeyDown, disableEscapeKeyDown = _g === void 0 ? constants_1.MODAL_DEFAULT_ESCAPE_KEY_DOWN : _g,
|
|
22
|
+
var _b = _a.open, open = _b === void 0 ? constants_1.MODAL_DEFAULT_OPEN : _b, _c = _a.keepMounted, keepMounted = _c === void 0 ? constants_1.MODAL_DEFAULT_KEEP_MOUNTED : _c, _d = _a.hideBackdrop, hideBackdrop = _d === void 0 ? constants_1.MODAL_DEFAULT_HIDE_BACKDROP : _d, _e = _a.disableScrollLock, disableScrollLock = _e === void 0 ? constants_1.MODAL_DEFAULT_DISABLE_SCROLL_LOCK : _e, _f = _a.disableClickOutside, disableClickOutside = _f === void 0 ? constants_1.MODAL_DEFAULT_DISABLE_CLICK_OUTSIDE : _f, _g = _a.disableEscapeKeyDown, disableEscapeKeyDown = _g === void 0 ? constants_1.MODAL_DEFAULT_ESCAPE_KEY_DOWN : _g, children = _a.children, onEnter = _a.onEnter, onEntered = _a.onEntered, onExit = _a.onExit, onExitedProp = _a.onExited, onClose = _a.onClose, backdropProps = _a.backdropProps, windowProps = _a.windowProps, transitionProps = _a.transitionProps, className = _a.className, ignoreClickOutsideRefs = _a.ignoreClickOutsideRefs, other = tslib_1.__rest(_a, ["open", "keepMounted", "hideBackdrop", "disableScrollLock", "disableClickOutside", "disableEscapeKeyDown", "children", "onEnter", "onEntered", "onExit", "onExited", "onClose", "backdropProps", "windowProps", "transitionProps", "className", "ignoreClickOutsideRefs"]);
|
|
23
23
|
var hasBackdrop = !hideBackdrop;
|
|
24
24
|
var rootRef = (0, react_1.useRef)(null);
|
|
25
25
|
var windowInnerRef = (0, react_1.useRef)(null);
|
|
26
26
|
var focusedElement = (0, react_1.useRef)(null);
|
|
27
|
-
var
|
|
28
|
-
var
|
|
29
|
-
var
|
|
30
|
-
var RootComponent = disablePortal ? 'div' : Portal_1.Portal;
|
|
27
|
+
var _h = tslib_1.__read((0, react_1.useState)(false), 2), openState = _h[0], setOpenState = _h[1];
|
|
28
|
+
var _j = tslib_1.__read((0, react_1.useState)(false), 2), opened = _j[0], setOpened = _j[1];
|
|
29
|
+
var _k = (0, index_1.useModalManager)(windowInnerRef, 1000, openState), isTop = _k.isTop, refsClickOutside = _k.refsClickOutside;
|
|
31
30
|
(0, useClickOutside_1.useClickOutside)({
|
|
32
31
|
refs: tslib_1.__spreadArray(tslib_1.__spreadArray([
|
|
33
32
|
windowInnerRef
|
|
@@ -73,7 +72,7 @@ exports.Modal = (0, react_1.forwardRef)(function (_a, ref) {
|
|
|
73
72
|
active: isTop && !disableEscapeKeyDown,
|
|
74
73
|
});
|
|
75
74
|
return (react_1.default.createElement(react_transition_group_1.CSSTransition, tslib_1.__assign({ classNames: (0, exports.cnModal)({ animation: true }), nodeRef: rootRef, timeout: 300 }, transitionProps, { in: openState, onEnter: onEnter, onEntered: onEntered, onExit: onExit, onExited: onExited, unmountOnExit: !keepMounted, appear: true }),
|
|
76
|
-
react_1.default.createElement(
|
|
75
|
+
react_1.default.createElement(Portal_1.Portal, tslib_1.__assign({}, other, { className: (0, exports.cnModal)({ hidden: keepMounted && !openState, hasBackdrop: hasBackdrop }, [className]), ref: (0, useMultiRef_1.useMultiRef)([rootRef, ref]) }),
|
|
77
76
|
!hideBackdrop && (react_1.default.createElement(Backdrop_1.Backdrop, tslib_1.__assign({ zIndex: -1, open: openState }, backdropProps, { className: backdropProps === null || backdropProps === void 0 ? void 0 : backdropProps.className }))),
|
|
78
77
|
react_1.default.createElement(components_1.ModalConsumer, tslib_1.__assign({}, windowProps, { ref: (0, useMultiRef_1.useMultiRef)([windowInnerRef, trapRef, windowProps === null || windowProps === void 0 ? void 0 : windowProps.ref]) }), children))));
|
|
79
78
|
});
|
|
@@ -4,4 +4,3 @@ export declare const MODAL_DEFAULT_HIDE_BACKDROP = false;
|
|
|
4
4
|
export declare const MODAL_DEFAULT_DISABLE_SCROLL_LOCK = false;
|
|
5
5
|
export declare const MODAL_DEFAULT_DISABLE_CLICK_OUTSIDE = false;
|
|
6
6
|
export declare const MODAL_DEFAULT_ESCAPE_KEY_DOWN = false;
|
|
7
|
-
export declare const MODAL_DEFAULT_DISABLE_PORTAL = false;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.MODAL_DEFAULT_ESCAPE_KEY_DOWN = exports.MODAL_DEFAULT_DISABLE_CLICK_OUTSIDE = exports.MODAL_DEFAULT_DISABLE_SCROLL_LOCK = exports.MODAL_DEFAULT_HIDE_BACKDROP = exports.MODAL_DEFAULT_KEEP_MOUNTED = exports.MODAL_DEFAULT_OPEN = void 0;
|
|
4
4
|
exports.MODAL_DEFAULT_OPEN = false;
|
|
5
5
|
exports.MODAL_DEFAULT_KEEP_MOUNTED = false;
|
|
6
6
|
exports.MODAL_DEFAULT_HIDE_BACKDROP = false;
|
|
7
7
|
exports.MODAL_DEFAULT_DISABLE_SCROLL_LOCK = false;
|
|
8
8
|
exports.MODAL_DEFAULT_DISABLE_CLICK_OUTSIDE = false;
|
|
9
9
|
exports.MODAL_DEFAULT_ESCAPE_KEY_DOWN = false;
|
|
10
|
-
exports.MODAL_DEFAULT_DISABLE_PORTAL = false;
|
|
@@ -51,8 +51,5 @@ export type ModalProps = {
|
|
|
51
51
|
'data-testid'?: string;
|
|
52
52
|
/** Список ссылок на элементы при клике на которые Modal не будет закрываться (см. хук useClickOutside) */
|
|
53
53
|
ignoreClickOutsideRefs?: RefObject<HTMLElement>[];
|
|
54
|
-
/** Если {true} отключает портал для компонента.
|
|
55
|
-
* Подробнее — https://react.dev/reference/react-dom/createPortal. */
|
|
56
|
-
disablePortal?: boolean;
|
|
57
54
|
} & PortalProps;
|
|
58
55
|
export type ModalRef = PortalRef;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import './Popover.css';
|
|
2
2
|
import type { PopoverBaseProps } from './types';
|
|
3
3
|
export declare const cnPopover: import("@bem-react/classname").ClassNameFormatter;
|
|
4
|
-
export declare const Popover: import("../../utils/polymorphicComponentWithRef").PolymorphicComponentWithRef<PopoverBaseProps,
|
|
4
|
+
export declare const Popover: import("../../utils/polymorphicComponentWithRef").PolymorphicComponentWithRef<PopoverBaseProps, "div">;
|
|
@@ -14,6 +14,7 @@ var useThemeProps_1 = require("../../hooks/useThemeProps");
|
|
|
14
14
|
var classname_1 = require("../../utils/classname");
|
|
15
15
|
var isKey_1 = require("../../utils/isKey");
|
|
16
16
|
var polymorphicComponentWithRef_1 = require("../../utils/polymorphicComponentWithRef");
|
|
17
|
+
var Paper_1 = require("../Paper");
|
|
17
18
|
var Portal_1 = require("../Portal");
|
|
18
19
|
var components_1 = require("./components");
|
|
19
20
|
var constants_1 = require("./constants");
|
|
@@ -22,7 +23,11 @@ var PopoverContext_1 = require("./PopoverContext");
|
|
|
22
23
|
exports.cnPopover = (0, classname_1.cn)('Popover');
|
|
23
24
|
exports.Popover = (0, polymorphicComponentWithRef_1.polymorphicComponentWithRef)(function (inProps, ref) {
|
|
24
25
|
var props = (0, useThemeProps_1.useThemeProps)({ props: inProps, name: 'Popover' });
|
|
25
|
-
var _a = props.arrow, arrow = _a === void 0 ? constants_1.POPOVER_DEFAULT_ARROW : _a, _b = props.open, open = _b === void 0 ? constants_1.POPOVER_DEFAULT_OPEN : _b, _c = props.disableInteractive, disableInteractive = _c === void 0 ? constants_1.POPOVER_DEFAULT_DISABLE_INTERACTIVE : _c, _d = props.disableEnforceFocus, disableEnforceFocus = _d === void 0 ? constants_1.POPOVER_DEFAULT_DISABLE_ENFORCE_FOCUS : _d, _e = props.disableReturnFocus, disableReturnFocus = _e === void 0 ? constants_1.POPOVER_DEFAULT_DISABLE_RETURN_FOCUS : _e, _f = props.disableClickOutside, disableClickOutside = _f === void 0 ? constants_1.POPOVER_DEFAULT_DISABLE_CLICK_OUTSIDE : _f, _g = props.placement, placement = _g === void 0 ? constants_1.POPOVER_DEFAULT_PLACEMENT : _g, _h = props.strategy, strategy = _h === void 0 ? constants_1.POPOVER_DEFAULT_STRATEGY : _h, _j = props.disablePreventOverflow, disablePreventOverflow = _j === void 0 ? constants_1.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,
|
|
26
|
+
var _a = props.arrow, arrow = _a === void 0 ? constants_1.POPOVER_DEFAULT_ARROW : _a, _b = props.open, open = _b === void 0 ? constants_1.POPOVER_DEFAULT_OPEN : _b, _c = props.disableInteractive, disableInteractive = _c === void 0 ? constants_1.POPOVER_DEFAULT_DISABLE_INTERACTIVE : _c, _d = props.disableEnforceFocus, disableEnforceFocus = _d === void 0 ? constants_1.POPOVER_DEFAULT_DISABLE_ENFORCE_FOCUS : _d, _e = props.disableReturnFocus, disableReturnFocus = _e === void 0 ? constants_1.POPOVER_DEFAULT_DISABLE_RETURN_FOCUS : _e, _f = props.disableClickOutside, disableClickOutside = _f === void 0 ? constants_1.POPOVER_DEFAULT_DISABLE_CLICK_OUTSIDE : _f, _g = props.placement, placement = _g === void 0 ? constants_1.POPOVER_DEFAULT_PLACEMENT : _g, _h = props.strategy, strategy = _h === void 0 ? constants_1.POPOVER_DEFAULT_STRATEGY : _h, _j = props.disablePreventOverflow, disablePreventOverflow = _j === void 0 ? constants_1.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, modifiersProp = props.modifiers, _k = props.as, as = _k === void 0 ? constants_1.POPOVER_DEFAULT_TAG : _k, other = tslib_1.__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"]);
|
|
27
|
+
var Tag = (0, react_1.useMemo)(function () {
|
|
28
|
+
// eslint-disable-next-line react/display-name
|
|
29
|
+
return (0, react_1.forwardRef)(function (props, ref) { return (react_1.default.createElement(Paper_1.Paper, tslib_1.__assign({ radius: "l", shadow: "m", background: "main" }, props, { as: as, ref: ref }))); });
|
|
30
|
+
}, [as]);
|
|
26
31
|
var _l = tslib_1.__read((0, react_1.useState)(false), 2), openState = _l[0], setOpenState = _l[1];
|
|
27
32
|
var focusedElement = (0, react_1.useRef)(null);
|
|
28
33
|
var popoverRef = (0, react_1.useRef)(null);
|
|
@@ -105,7 +110,7 @@ exports.Popover = (0, polymorphicComponentWithRef_1.polymorphicComponentWithRef)
|
|
|
105
110
|
offset: offset,
|
|
106
111
|
},
|
|
107
112
|
}
|
|
108
|
-
], tslib_1.__read((
|
|
113
|
+
], tslib_1.__read((modifiersProp || [])), false); }, [offset, equalAnchorWidth, modifiersProp]);
|
|
109
114
|
// Якорный элемент или координаты
|
|
110
115
|
var resolveReferenceElement = (0, react_1.useMemo)(function () {
|
|
111
116
|
if (anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.current)
|
|
@@ -146,7 +151,7 @@ exports.Popover = (0, polymorphicComponentWithRef_1.polymorphicComponentWithRef)
|
|
|
146
151
|
}, [open]);
|
|
147
152
|
return (react_1.default.createElement(PopoverContext_1.PopoverContext.Provider, { value: { isTop: isTop } },
|
|
148
153
|
react_1.default.createElement(react_transition_group_1.CSSTransition, tslib_1.__assign({ nodeRef: popoverRef, classNames: (0, exports.cnPopover)({ animation: true }), timeout: 120 }, transitionProps, { in: openState, onEnter: onEnter, onEntered: onEntered, onExit: onExit, onExited: onExited, unmountOnExit: true }),
|
|
149
|
-
react_1.default.createElement(Portal_1.Portal, tslib_1.__assign({ as:
|
|
154
|
+
react_1.default.createElement(Portal_1.Portal, tslib_1.__assign({ as: Tag }, other, { style: tslib_1.__assign(tslib_1.__assign({}, style), styles.popper), ref: portalRef, className: (0, exports.cnPopover)({ disableInteractive: disableInteractive }, [className]) }, attributes.popper),
|
|
150
155
|
children,
|
|
151
156
|
arrow && (react_1.default.createElement(components_1.PopoverArrow, tslib_1.__assign({}, arrowProps, { style: tslib_1.__assign(tslib_1.__assign({}, arrowProps === null || arrowProps === void 0 ? void 0 : arrowProps.style), styles.arrow), "data-popper-arrow": true })))))));
|
|
152
157
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const POPOVER_DEFAULT_TAG
|
|
1
|
+
export declare const POPOVER_DEFAULT_TAG = "div";
|
|
2
2
|
export declare const POPOVER_DEFAULT_ARROW = false;
|
|
3
3
|
export declare const POPOVER_DEFAULT_OPEN = false;
|
|
4
4
|
export declare const POPOVER_DEFAULT_DISABLE_INTERACTIVE = false;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.POPOVER_DEFAULT_DISABLE_PREVENT_OVERFLOW = exports.POPOVER_DEFAULT_STRATEGY = exports.POPOVER_DEFAULT_PLACEMENT = exports.POPOVER_DEFAULT_DISABLE_CLICK_OUTSIDE = exports.POPOVER_DEFAULT_DISABLE_RETURN_FOCUS = exports.POPOVER_DEFAULT_DISABLE_ENFORCE_FOCUS = exports.POPOVER_DEFAULT_DISABLE_INTERACTIVE = exports.POPOVER_DEFAULT_OPEN = exports.POPOVER_DEFAULT_ARROW = exports.POPOVER_DEFAULT_TAG = void 0;
|
|
4
|
-
|
|
5
|
-
exports.POPOVER_DEFAULT_TAG = Paper_1.Paper;
|
|
4
|
+
exports.POPOVER_DEFAULT_TAG = 'div';
|
|
6
5
|
exports.POPOVER_DEFAULT_ARROW = false;
|
|
7
6
|
exports.POPOVER_DEFAULT_OPEN = false;
|
|
8
7
|
exports.POPOVER_DEFAULT_DISABLE_INTERACTIVE = false;
|
|
@@ -3,7 +3,7 @@ import type PopperJS from '@popperjs/core';
|
|
|
3
3
|
import type { PopperProps } from 'react-popper';
|
|
4
4
|
import type { CSSTransitionProps } from 'react-transition-group/CSSTransition';
|
|
5
5
|
import type { PolymorphicComponentPropsWithRef } from '../../utils/polymorphicComponentWithRef';
|
|
6
|
-
import type {
|
|
6
|
+
import type { PortalBaseProps } from '../Portal';
|
|
7
7
|
import type { PopoverArrowProps } from './components';
|
|
8
8
|
import type { POPOVER_DEFAULT_TAG } from './constants';
|
|
9
9
|
export type VirtualElement = {
|
|
@@ -71,8 +71,6 @@ export type PopoverBaseProps = {
|
|
|
71
71
|
'data-testid'?: string;
|
|
72
72
|
/** Функция обратного вызова для получения метода по перерасчету расположения компонента Popover */
|
|
73
73
|
setUpdate?(update: PopperJS.Instance['update'] | null): void;
|
|
74
|
-
/** Контейнер для монтирования всплывающего окна */
|
|
75
|
-
container?: PortalProps['container'];
|
|
76
74
|
/** Стратегия позиционирования */
|
|
77
75
|
strategy?: PopoverStrategyVariant;
|
|
78
76
|
/** Если {true} позволяет смещаться по границе якорного элемента компонента */
|
|
@@ -82,6 +80,6 @@ export type PopoverBaseProps = {
|
|
|
82
80
|
* https://popper.js.org/docs/v2/modifiers/#custom-modifiers
|
|
83
81
|
* */
|
|
84
82
|
modifiers?: PopperProps<unknown>['modifiers'];
|
|
85
|
-
};
|
|
83
|
+
} & PortalBaseProps;
|
|
86
84
|
export type PopoverRef = ComponentRef<typeof POPOVER_DEFAULT_TAG>;
|
|
87
85
|
export type PopoverProps<As extends ElementType = typeof POPOVER_DEFAULT_TAG> = PolymorphicComponentPropsWithRef<PopoverBaseProps, As>;
|
|
@@ -12,9 +12,9 @@ exports.Portal = (0, polymorphicComponentWithRef_1.polymorphicComponentWithRef)(
|
|
|
12
12
|
var _a = (0, useThemeProps_1.useThemeProps)({
|
|
13
13
|
props: inProps,
|
|
14
14
|
name: 'Portal',
|
|
15
|
-
}),
|
|
15
|
+
}), _b = _a.disablePortal, disablePortal = _b === void 0 ? constants_1.PORTAL_DEFAULT_DISABLE_PORTAL : _b, _c = _a.as, Tag = _c === void 0 ? constants_1.PORTAL_DEFAULT_TAG : _c, containerProp = _a.container, children = _a.children, other = tslib_1.__rest(_a, ["disablePortal", "as", "container", "children"]);
|
|
16
|
+
var container = containerProp || constants_1.PORTAL_DEFAULT_CONTAINER;
|
|
16
17
|
var theme = (0, ThemeProvider_1.useTheme)();
|
|
17
|
-
|
|
18
|
-
return (0, react_dom_1.createPortal)(react_1.default.createElement(ThemeProvider_1.ThemeProvider, tslib_1.__assign({ theme: theme, className: className, as: Tag }, other, { ref: ref }), children), portalContainer);
|
|
18
|
+
return disablePortal ? (react_1.default.createElement(Tag, tslib_1.__assign({}, other, { ref: ref }), children)) : ((0, react_dom_1.createPortal)(react_1.default.createElement(ThemeProvider_1.ThemeProvider, tslib_1.__assign({ theme: theme, as: Tag }, other, { ref: ref }), children), container));
|
|
19
19
|
});
|
|
20
20
|
exports.Portal.displayName = 'Portal';
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PORTAL_DEFAULT_TAG = void 0;
|
|
3
|
+
exports.PORTAL_DEFAULT_DISABLE_PORTAL = exports.PORTAL_DEFAULT_CONTAINER = exports.PORTAL_DEFAULT_TAG = void 0;
|
|
4
4
|
exports.PORTAL_DEFAULT_TAG = 'div';
|
|
5
|
+
exports.PORTAL_DEFAULT_CONTAINER = window.document.body;
|
|
6
|
+
exports.PORTAL_DEFAULT_DISABLE_PORTAL = false;
|
|
@@ -5,5 +5,8 @@ export type PortalRef = ComponentRef<typeof PORTAL_DEFAULT_TAG>;
|
|
|
5
5
|
export type PortalBaseProps = {
|
|
6
6
|
/** Контейнер для монтирования портала */
|
|
7
7
|
container?: Element | DocumentFragment | null;
|
|
8
|
+
/** Если {true} отключает портал для компонента.
|
|
9
|
+
* Подробнее — https://react.dev/reference/react-dom/createPortal. */
|
|
10
|
+
disablePortal?: boolean;
|
|
8
11
|
};
|
|
9
12
|
export type PortalProps<As extends ElementType = typeof PORTAL_DEFAULT_TAG> = PolymorphicComponentPropsWithoutRef<PortalBaseProps, As>;
|
|
@@ -10,7 +10,7 @@ export type SnackbarProps = PortalProps & {
|
|
|
10
10
|
};
|
|
11
11
|
export declare const Snackbar: React.ForwardRefExoticComponent<import("../../../Portal").PortalBaseProps & {
|
|
12
12
|
as?: "div" | undefined;
|
|
13
|
-
} & Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "
|
|
13
|
+
} & Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, keyof import("../../../Portal").PortalBaseProps> & {
|
|
14
14
|
/** Расположение сообщения относительно контейнера */
|
|
15
15
|
anchorOrigin?: SnackbarAnchorOrigin | undefined;
|
|
16
16
|
} & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -17,7 +17,7 @@ var constants_1 = require("./constants");
|
|
|
17
17
|
exports.cnTooltip = (0, classname_1.cn)('Tooltip');
|
|
18
18
|
exports.Tooltip = (0, polymorphicComponentWithRef_1.polymorphicComponentWithRef)(function (inProps, ref) {
|
|
19
19
|
var props = (0, useThemeProps_1.useThemeProps)({ props: inProps, name: 'Tooltip' });
|
|
20
|
-
var _a = props.trigger, trigger = _a === void 0 ? constants_1.TOOLTIP_DEFAULT_TRIGGER : _a, _b = props.size, size = _b === void 0 ? constants_1.TOOLTIP_DEFAULT_SIZE : _b, _c = props.offset, offset = _c === void 0 ? constants_1.TOOLTIP_DEFAULT_OFFSET : _c, _d = props.delayEnter, delayEnter = _d === void 0 ? constants_1.TOOLTIP_DEFAULT_DELAY_ENTER : _d, _e = props.delayLeave, delayLeave = _e === void 0 ? constants_1.TOOLTIP_DEFAULT_DELAY_LEAVE : _e, _f = props.arrow, arrow = _f === void 0 ? constants_1.TOOLTIP_DEFAULT_ARROW : _f, _g = props.shouldWrapChildren, shouldWrapChildren = _g === void 0 ? constants_1.TOOLTIP_DEFAULT_SHOULD_WRAP_CHILDREN : _g, _h = props.disabled, disabled = _h === void 0 ? constants_1.TOOLTIP_DEFAULT_DISABLED : _h, _j = props.inverse, inverse = _j === void 0 ? constants_1.TOOLTIP_DEFAULT_INVERSE : _j, _k = props.as, as = _k === void 0 ? constants_1.TOOLTIP_DEFAULT_TAG : _k,
|
|
20
|
+
var _a = props.trigger, trigger = _a === void 0 ? constants_1.TOOLTIP_DEFAULT_TRIGGER : _a, _b = props.size, size = _b === void 0 ? constants_1.TOOLTIP_DEFAULT_SIZE : _b, _c = props.offset, offset = _c === void 0 ? constants_1.TOOLTIP_DEFAULT_OFFSET : _c, _d = props.delayEnter, delayEnter = _d === void 0 ? constants_1.TOOLTIP_DEFAULT_DELAY_ENTER : _d, _e = props.delayLeave, delayLeave = _e === void 0 ? constants_1.TOOLTIP_DEFAULT_DELAY_LEAVE : _e, _f = props.arrow, arrow = _f === void 0 ? constants_1.TOOLTIP_DEFAULT_ARROW : _f, _g = props.shouldWrapChildren, shouldWrapChildren = _g === void 0 ? constants_1.TOOLTIP_DEFAULT_SHOULD_WRAP_CHILDREN : _g, _h = props.disabled, disabled = _h === void 0 ? constants_1.TOOLTIP_DEFAULT_DISABLED : _h, _j = props.inverse, inverse = _j === void 0 ? constants_1.TOOLTIP_DEFAULT_INVERSE : _j, _k = props.as, as = _k === void 0 ? constants_1.TOOLTIP_DEFAULT_TAG : _k, modifiersProp = props.modifiers, onMouseEnter = props.onMouseEnter, onMouseLeave = props.onMouseLeave, variant = props.variant, children = props.children, label = props.label, openProp = props.open, className = props.className, onOpen = props.onOpen, onClose = props.onClose, other = tslib_1.__rest(props, ["trigger", "size", "offset", "delayEnter", "delayLeave", "arrow", "shouldWrapChildren", "disabled", "inverse", "as", "modifiers", "onMouseEnter", "onMouseLeave", "variant", "children", "label", "open", "className", "onOpen", "onClose"]);
|
|
21
21
|
if (process.env.NODE_ENV !== 'production' && variant) {
|
|
22
22
|
(0, logger_1.deprecate)('Свойство «variant» устарело. Для замены используйте «inverse».');
|
|
23
23
|
}
|
|
@@ -25,14 +25,14 @@ exports.Tooltip = (0, polymorphicComponentWithRef_1.polymorphicComponentWithRef)
|
|
|
25
25
|
var _l = tslib_1.__read((0, react_1.useState)(), 2), delay = _l[0], setDelay = _l[1];
|
|
26
26
|
var _m = tslib_1.__read((0, useBoolean_1.useBoolean)(), 2), focused = _m[0], setFocused = _m[1];
|
|
27
27
|
var _o = tslib_1.__read((0, useBoolean_1.useBoolean)(), 2), hovered = _o[0], setHovered = _o[1];
|
|
28
|
-
var modifiers = [
|
|
28
|
+
var modifiers = tslib_1.__spreadArray([
|
|
29
29
|
{
|
|
30
30
|
name: 'arrow',
|
|
31
31
|
options: {
|
|
32
32
|
padding: size === 'xs' ? 8 : 12,
|
|
33
33
|
},
|
|
34
|
-
}
|
|
35
|
-
];
|
|
34
|
+
}
|
|
35
|
+
], tslib_1.__read((modifiersProp || [])), false);
|
|
36
36
|
var _p = tslib_1.__read((0, useControlled_1.useControlled)({
|
|
37
37
|
value: openProp,
|
|
38
38
|
defaultValue: false,
|
|
@@ -65,18 +65,20 @@ exports.Tooltip = (0, polymorphicComponentWithRef_1.polymorphicComponentWithRef)
|
|
|
65
65
|
}, [children, shouldWrapChildren]);
|
|
66
66
|
var childrenProps = resolveChildren.props, childrenRef = resolveChildren.ref;
|
|
67
67
|
var childrenMultiRef = (0, useMultiRef_1.useMultiRef)([anchorRef, childrenRef]);
|
|
68
|
-
var handleMouseEnter = function () {
|
|
68
|
+
var handleMouseEnter = function (e) {
|
|
69
69
|
if (trigger === 'hover' || trigger === 'hover&focus') {
|
|
70
70
|
setHovered.on();
|
|
71
71
|
setOpenWithDelay(true);
|
|
72
72
|
}
|
|
73
|
+
onMouseEnter === null || onMouseEnter === void 0 ? void 0 : onMouseEnter(e);
|
|
73
74
|
};
|
|
74
|
-
var handleMouseLeave = function () {
|
|
75
|
+
var handleMouseLeave = function (e) {
|
|
75
76
|
if (trigger === 'hover' || trigger === 'hover&focus') {
|
|
76
77
|
setHovered.off();
|
|
77
78
|
if (!focused)
|
|
78
79
|
setOpenWithDelay(false);
|
|
79
80
|
}
|
|
81
|
+
onMouseLeave === null || onMouseLeave === void 0 ? void 0 : onMouseLeave(e);
|
|
80
82
|
};
|
|
81
83
|
var handleClick = function () {
|
|
82
84
|
if (trigger === 'click')
|
|
@@ -112,11 +114,11 @@ exports.Tooltip = (0, polymorphicComponentWithRef_1.polymorphicComponentWithRef)
|
|
|
112
114
|
onBlur === null || onBlur === void 0 ? void 0 : onBlur(e);
|
|
113
115
|
},
|
|
114
116
|
onMouseEnter: function (e) {
|
|
115
|
-
handleMouseEnter();
|
|
117
|
+
handleMouseEnter(e);
|
|
116
118
|
onMouseEnter === null || onMouseEnter === void 0 ? void 0 : onMouseEnter(e);
|
|
117
119
|
},
|
|
118
120
|
onMouseLeave: function (e) {
|
|
119
|
-
handleMouseLeave();
|
|
121
|
+
handleMouseLeave(e);
|
|
120
122
|
onMouseLeave === null || onMouseLeave === void 0 ? void 0 : onMouseLeave(e);
|
|
121
123
|
},
|
|
122
124
|
};
|
|
@@ -132,9 +134,7 @@ exports.Tooltip = (0, polymorphicComponentWithRef_1.polymorphicComponentWithRef)
|
|
|
132
134
|
]);
|
|
133
135
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
134
136
|
react_1.default.cloneElement(resolveChildren, composeChildrenProps),
|
|
135
|
-
react_1.default.createElement(Popover_1.Popover, tslib_1.__assign({
|
|
136
|
-
size: size,
|
|
137
|
-
}, modifiers: modifiers, disableEnforceFocus: true, disableReturnFocus: true }),
|
|
137
|
+
react_1.default.createElement(Popover_1.Popover, tslib_1.__assign({ arrow: arrow, offset: offset, background: "main", strategy: "absolute", arrowProps: { size: size }, anchorRef: anchorRef, modifiers: modifiers, as: as, onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave, radius: size === 'xs' ? 's' : 'l' }, (inverse && { background: 'main-inverse' }), (variant === 'dark' && { background: 'main-inverse' }), { className: (0, exports.cnTooltip)({ size: size, variant: variant, inverse: inverse }, [className]), disableEnforceFocus: true, disableReturnFocus: true }, other, { open: openState, onClose: closeWithDelay, ref: ref }),
|
|
138
138
|
react_1.default.createElement("div", { className: (0, exports.cnTooltip)('Content', { size: size, variant: variant, inverse: inverse }) }, label))));
|
|
139
139
|
});
|
|
140
140
|
exports.Tooltip.displayName = 'Tooltip';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const TOOLTIP_DEFAULT_TAG
|
|
1
|
+
export declare const TOOLTIP_DEFAULT_TAG = "div";
|
|
2
2
|
export declare const TOOLTIP_DEFAULT_TRIGGER = "hover";
|
|
3
3
|
export declare const TOOLTIP_DEFAULT_SIZE = "s";
|
|
4
4
|
export declare const TOOLTIP_DEFAULT_INVERSE = true;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TOOLTIP_DEFAULT_DISABLED = exports.TOOLTIP_DEFAULT_SHOULD_WRAP_CHILDREN = exports.TOOLTIP_DEFAULT_ARROW = exports.TOOLTIP_DEFAULT_DELAY_LEAVE = exports.TOOLTIP_DEFAULT_DELAY_ENTER = exports.TOOLTIP_DEFAULT_OFFSET = exports.TOOLTIP_DEFAULT_INVERSE = exports.TOOLTIP_DEFAULT_SIZE = exports.TOOLTIP_DEFAULT_TRIGGER = exports.TOOLTIP_DEFAULT_TAG = void 0;
|
|
4
|
-
|
|
5
|
-
exports.TOOLTIP_DEFAULT_TAG = Paper_1.Paper;
|
|
4
|
+
exports.TOOLTIP_DEFAULT_TAG = 'div';
|
|
6
5
|
exports.TOOLTIP_DEFAULT_TRIGGER = 'hover';
|
|
7
6
|
exports.TOOLTIP_DEFAULT_SIZE = 's';
|
|
8
7
|
exports.TOOLTIP_DEFAULT_INVERSE = true;
|
|
@@ -48,7 +48,7 @@ export type TooltipBaseProps = {
|
|
|
48
48
|
'data-testid'?: string;
|
|
49
49
|
/** Дополнительные CSS-классы */
|
|
50
50
|
className?: string;
|
|
51
|
-
} & TooltipPropsDeprecated &
|
|
51
|
+
} & TooltipPropsDeprecated & Omit<Partial<PopoverBaseProps>, 'onClose' | 'open'>;
|
|
52
52
|
export type TooltipRef = ComponentRef<typeof TOOLTIP_DEFAULT_TAG>;
|
|
53
53
|
export type TooltipProps<As extends ElementType = typeof TOOLTIP_DEFAULT_TAG> = PolymorphicComponentPropsWithRef<TooltipBaseProps, As>;
|
|
54
54
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const DATA_LIST_DEFAULT_TAG
|
|
1
|
+
export declare const DATA_LIST_DEFAULT_TAG = "div";
|
|
2
2
|
export declare const DATA_LIST_DEFAULT_SIZE = "m";
|
|
3
3
|
export declare const DATA_LIST_DEFAULT_OPEN = false;
|
|
4
4
|
export declare const DATA_LIST_OPTION_DEFAULT_DISABLED = false;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { LIST_ITEM_DEFAULT_TAG } from '../List/constants';
|
|
2
|
-
|
|
3
|
-
export var DATA_LIST_DEFAULT_TAG = Paper;
|
|
2
|
+
export var DATA_LIST_DEFAULT_TAG = 'div';
|
|
4
3
|
export var DATA_LIST_DEFAULT_SIZE = 'm';
|
|
5
4
|
export var DATA_LIST_DEFAULT_OPEN = false;
|
|
6
5
|
export var DATA_LIST_OPTION_DEFAULT_DISABLED = false;
|
|
@@ -41,7 +41,6 @@ export declare const Dialog: React.ForwardRefExoticComponent<{
|
|
|
41
41
|
className?: string | undefined;
|
|
42
42
|
'data-testid'?: string | undefined;
|
|
43
43
|
ignoreClickOutsideRefs?: React.RefObject<HTMLElement>[] | undefined;
|
|
44
|
-
disablePortal?: boolean | undefined;
|
|
45
44
|
} & import("../Portal").PortalBaseProps & {
|
|
46
45
|
as?: "div" | undefined;
|
|
47
|
-
} & Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "
|
|
46
|
+
} & Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, keyof import("../Portal").PortalBaseProps> & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -42,7 +42,6 @@ export declare const Drawer: React.ForwardRefExoticComponent<{
|
|
|
42
42
|
className?: string | undefined;
|
|
43
43
|
'data-testid'?: string | undefined;
|
|
44
44
|
ignoreClickOutsideRefs?: React.RefObject<HTMLElement>[] | undefined;
|
|
45
|
-
disablePortal?: boolean | undefined;
|
|
46
45
|
} & import("../Portal").PortalBaseProps & {
|
|
47
46
|
as?: "div" | undefined;
|
|
48
|
-
} & Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "
|
|
47
|
+
} & Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, keyof import("../Portal").PortalBaseProps> & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -5,6 +5,7 @@ import { deprecate } from '@ozen-ui/logger';
|
|
|
5
5
|
import { useThemeProps } from '../../hooks/useThemeProps';
|
|
6
6
|
import { cn } from '../../utils/classname';
|
|
7
7
|
import { getPaperSizeToFormElement } from '../../utils/getPaperSizeToFormElement';
|
|
8
|
+
import { Paper } from '../Paper';
|
|
8
9
|
import { Popover } from '../Popover';
|
|
9
10
|
import { MenuContextConsumer } from './components';
|
|
10
11
|
import { MENU_DEFAULT_SIZE } from './constants';
|
|
@@ -16,7 +17,7 @@ export var Menu = forwardRef(function (inProps, ref) {
|
|
|
16
17
|
if (process.env.NODE_ENV !== 'production' && menuListRef) {
|
|
17
18
|
deprecate('Свойство «menuListRef» устарело. Для замены используйте «menuListProps.ref».');
|
|
18
19
|
}
|
|
19
|
-
return (React.createElement(Popover, __assign({ offset: [0, 4], radius: radius }, other, { open: open, onClose: onClose, className: cnMenu('', [className]), disableEnforceFocus: true, ref: ref }),
|
|
20
|
+
return (React.createElement(Popover, __assign({ as: Paper, offset: [0, 4], radius: radius }, other, { open: open, onClose: onClose, className: cnMenu('', [className]), disableEnforceFocus: true, ref: ref }),
|
|
20
21
|
React.createElement(MenuContextConsumer, { onClose: onClose, menuListRef: menuListRef, menuListProps: __assign(__assign({ size: size }, menuListProps), { ref: menuListRef || (menuListProps === null || menuListProps === void 0 ? void 0 : menuListProps.ref) }) }, children)));
|
|
21
22
|
});
|
|
22
23
|
Menu.displayName = 'Menu';
|
|
@@ -34,7 +34,6 @@ export declare const Modal: React.ForwardRefExoticComponent<{
|
|
|
34
34
|
className?: string | undefined;
|
|
35
35
|
'data-testid'?: string | undefined;
|
|
36
36
|
ignoreClickOutsideRefs?: React.RefObject<HTMLElement>[] | undefined;
|
|
37
|
-
disablePortal?: boolean | undefined;
|
|
38
37
|
} & import("../Portal").PortalBaseProps & {
|
|
39
38
|
as?: "div" | undefined;
|
|
40
|
-
} & Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "
|
|
39
|
+
} & Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, keyof import("../Portal").PortalBaseProps> & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -12,19 +12,18 @@ import { isKey } from '../../utils/isKey';
|
|
|
12
12
|
import { Backdrop } from '../Backdrop';
|
|
13
13
|
import { Portal } from '../Portal';
|
|
14
14
|
import { ModalConsumer } from './components';
|
|
15
|
-
import { MODAL_DEFAULT_DISABLE_CLICK_OUTSIDE,
|
|
15
|
+
import { MODAL_DEFAULT_DISABLE_CLICK_OUTSIDE, MODAL_DEFAULT_DISABLE_SCROLL_LOCK, MODAL_DEFAULT_ESCAPE_KEY_DOWN, MODAL_DEFAULT_HIDE_BACKDROP, MODAL_DEFAULT_KEEP_MOUNTED, MODAL_DEFAULT_OPEN, } from './constants';
|
|
16
16
|
import { useModalManager } from './index';
|
|
17
17
|
export var cnModal = cn('Modal');
|
|
18
18
|
export var Modal = forwardRef(function (_a, ref) {
|
|
19
|
-
var _b = _a.open, open = _b === void 0 ? MODAL_DEFAULT_OPEN : _b, _c = _a.keepMounted, keepMounted = _c === void 0 ? MODAL_DEFAULT_KEEP_MOUNTED : _c, _d = _a.hideBackdrop, hideBackdrop = _d === void 0 ? MODAL_DEFAULT_HIDE_BACKDROP : _d, _e = _a.disableScrollLock, disableScrollLock = _e === void 0 ? MODAL_DEFAULT_DISABLE_SCROLL_LOCK : _e, _f = _a.disableClickOutside, disableClickOutside = _f === void 0 ? MODAL_DEFAULT_DISABLE_CLICK_OUTSIDE : _f, _g = _a.disableEscapeKeyDown, disableEscapeKeyDown = _g === void 0 ? MODAL_DEFAULT_ESCAPE_KEY_DOWN : _g,
|
|
19
|
+
var _b = _a.open, open = _b === void 0 ? MODAL_DEFAULT_OPEN : _b, _c = _a.keepMounted, keepMounted = _c === void 0 ? MODAL_DEFAULT_KEEP_MOUNTED : _c, _d = _a.hideBackdrop, hideBackdrop = _d === void 0 ? MODAL_DEFAULT_HIDE_BACKDROP : _d, _e = _a.disableScrollLock, disableScrollLock = _e === void 0 ? MODAL_DEFAULT_DISABLE_SCROLL_LOCK : _e, _f = _a.disableClickOutside, disableClickOutside = _f === void 0 ? MODAL_DEFAULT_DISABLE_CLICK_OUTSIDE : _f, _g = _a.disableEscapeKeyDown, disableEscapeKeyDown = _g === void 0 ? MODAL_DEFAULT_ESCAPE_KEY_DOWN : _g, children = _a.children, onEnter = _a.onEnter, onEntered = _a.onEntered, onExit = _a.onExit, onExitedProp = _a.onExited, onClose = _a.onClose, backdropProps = _a.backdropProps, windowProps = _a.windowProps, transitionProps = _a.transitionProps, className = _a.className, ignoreClickOutsideRefs = _a.ignoreClickOutsideRefs, other = __rest(_a, ["open", "keepMounted", "hideBackdrop", "disableScrollLock", "disableClickOutside", "disableEscapeKeyDown", "children", "onEnter", "onEntered", "onExit", "onExited", "onClose", "backdropProps", "windowProps", "transitionProps", "className", "ignoreClickOutsideRefs"]);
|
|
20
20
|
var hasBackdrop = !hideBackdrop;
|
|
21
21
|
var rootRef = useRef(null);
|
|
22
22
|
var windowInnerRef = useRef(null);
|
|
23
23
|
var focusedElement = useRef(null);
|
|
24
|
-
var
|
|
25
|
-
var
|
|
26
|
-
var
|
|
27
|
-
var RootComponent = disablePortal ? 'div' : Portal;
|
|
24
|
+
var _h = __read(useState(false), 2), openState = _h[0], setOpenState = _h[1];
|
|
25
|
+
var _j = __read(useState(false), 2), opened = _j[0], setOpened = _j[1];
|
|
26
|
+
var _k = useModalManager(windowInnerRef, 1000, openState), isTop = _k.isTop, refsClickOutside = _k.refsClickOutside;
|
|
28
27
|
useClickOutside({
|
|
29
28
|
refs: __spreadArray(__spreadArray([
|
|
30
29
|
windowInnerRef
|
|
@@ -70,7 +69,7 @@ export var Modal = forwardRef(function (_a, ref) {
|
|
|
70
69
|
active: isTop && !disableEscapeKeyDown,
|
|
71
70
|
});
|
|
72
71
|
return (React.createElement(CSSTransition, __assign({ classNames: cnModal({ animation: true }), nodeRef: rootRef, timeout: 300 }, transitionProps, { in: openState, onEnter: onEnter, onEntered: onEntered, onExit: onExit, onExited: onExited, unmountOnExit: !keepMounted, appear: true }),
|
|
73
|
-
React.createElement(
|
|
72
|
+
React.createElement(Portal, __assign({}, other, { className: cnModal({ hidden: keepMounted && !openState, hasBackdrop: hasBackdrop }, [className]), ref: useMultiRef([rootRef, ref]) }),
|
|
74
73
|
!hideBackdrop && (React.createElement(Backdrop, __assign({ zIndex: -1, open: openState }, backdropProps, { className: backdropProps === null || backdropProps === void 0 ? void 0 : backdropProps.className }))),
|
|
75
74
|
React.createElement(ModalConsumer, __assign({}, windowProps, { ref: useMultiRef([windowInnerRef, trapRef, windowProps === null || windowProps === void 0 ? void 0 : windowProps.ref]) }), children))));
|
|
76
75
|
});
|
|
@@ -4,4 +4,3 @@ export declare const MODAL_DEFAULT_HIDE_BACKDROP = false;
|
|
|
4
4
|
export declare const MODAL_DEFAULT_DISABLE_SCROLL_LOCK = false;
|
|
5
5
|
export declare const MODAL_DEFAULT_DISABLE_CLICK_OUTSIDE = false;
|
|
6
6
|
export declare const MODAL_DEFAULT_ESCAPE_KEY_DOWN = false;
|
|
7
|
-
export declare const MODAL_DEFAULT_DISABLE_PORTAL = false;
|
|
@@ -51,8 +51,5 @@ export type ModalProps = {
|
|
|
51
51
|
'data-testid'?: string;
|
|
52
52
|
/** Список ссылок на элементы при клике на которые Modal не будет закрываться (см. хук useClickOutside) */
|
|
53
53
|
ignoreClickOutsideRefs?: RefObject<HTMLElement>[];
|
|
54
|
-
/** Если {true} отключает портал для компонента.
|
|
55
|
-
* Подробнее — https://react.dev/reference/react-dom/createPortal. */
|
|
56
|
-
disablePortal?: boolean;
|
|
57
54
|
} & PortalProps;
|
|
58
55
|
export type ModalRef = PortalRef;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import './Popover.css';
|
|
2
2
|
import type { PopoverBaseProps } from './types';
|
|
3
3
|
export declare const cnPopover: import("@bem-react/classname").ClassNameFormatter;
|
|
4
|
-
export declare const Popover: import("../../utils/polymorphicComponentWithRef").PolymorphicComponentWithRef<PopoverBaseProps,
|
|
4
|
+
export declare const Popover: import("../../utils/polymorphicComponentWithRef").PolymorphicComponentWithRef<PopoverBaseProps, "div">;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __assign, __read, __rest, __spreadArray } from "tslib";
|
|
2
|
-
import React, { useCallback, useMemo, useEffect, useRef, useState, } from 'react';
|
|
2
|
+
import React, { useCallback, useMemo, useEffect, useRef, useState, forwardRef, } from 'react';
|
|
3
3
|
import { usePopper } from 'react-popper';
|
|
4
4
|
import { CSSTransition } from 'react-transition-group';
|
|
5
5
|
import './Popover.css';
|
|
@@ -11,6 +11,7 @@ import { useThemeProps } from '../../hooks/useThemeProps';
|
|
|
11
11
|
import { cn } from '../../utils/classname';
|
|
12
12
|
import { isKey } from '../../utils/isKey';
|
|
13
13
|
import { polymorphicComponentWithRef } from '../../utils/polymorphicComponentWithRef';
|
|
14
|
+
import { Paper } from '../Paper';
|
|
14
15
|
import { Portal } from '../Portal';
|
|
15
16
|
import { PopoverArrow } from './components';
|
|
16
17
|
import { POPOVER_DEFAULT_TAG, POPOVER_DEFAULT_ARROW, POPOVER_DEFAULT_DISABLE_CLICK_OUTSIDE, POPOVER_DEFAULT_DISABLE_ENFORCE_FOCUS, POPOVER_DEFAULT_DISABLE_INTERACTIVE, POPOVER_DEFAULT_DISABLE_RETURN_FOCUS, POPOVER_DEFAULT_OPEN, POPOVER_DEFAULT_PLACEMENT, POPOVER_DEFAULT_STRATEGY, POPOVER_DEFAULT_DISABLE_PREVENT_OVERFLOW, } from './constants';
|
|
@@ -19,7 +20,11 @@ import { PopoverContext } from './PopoverContext';
|
|
|
19
20
|
export var cnPopover = cn('Popover');
|
|
20
21
|
export var Popover = polymorphicComponentWithRef(function (inProps, ref) {
|
|
21
22
|
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,
|
|
23
|
+
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, modifiersProp = 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"]);
|
|
24
|
+
var Tag = useMemo(function () {
|
|
25
|
+
// eslint-disable-next-line react/display-name
|
|
26
|
+
return forwardRef(function (props, ref) { return (React.createElement(Paper, __assign({ radius: "l", shadow: "m", background: "main" }, props, { as: as, ref: ref }))); });
|
|
27
|
+
}, [as]);
|
|
23
28
|
var _l = __read(useState(false), 2), openState = _l[0], setOpenState = _l[1];
|
|
24
29
|
var focusedElement = useRef(null);
|
|
25
30
|
var popoverRef = useRef(null);
|
|
@@ -102,7 +107,7 @@ export var Popover = polymorphicComponentWithRef(function (inProps, ref) {
|
|
|
102
107
|
offset: offset,
|
|
103
108
|
},
|
|
104
109
|
}
|
|
105
|
-
], __read((
|
|
110
|
+
], __read((modifiersProp || [])), false); }, [offset, equalAnchorWidth, modifiersProp]);
|
|
106
111
|
// Якорный элемент или координаты
|
|
107
112
|
var resolveReferenceElement = useMemo(function () {
|
|
108
113
|
if (anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.current)
|
|
@@ -143,7 +148,7 @@ export var Popover = polymorphicComponentWithRef(function (inProps, ref) {
|
|
|
143
148
|
}, [open]);
|
|
144
149
|
return (React.createElement(PopoverContext.Provider, { value: { isTop: isTop } },
|
|
145
150
|
React.createElement(CSSTransition, __assign({ nodeRef: popoverRef, classNames: cnPopover({ animation: true }), timeout: 120 }, transitionProps, { in: openState, onEnter: onEnter, onEntered: onEntered, onExit: onExit, onExited: onExited, unmountOnExit: true }),
|
|
146
|
-
React.createElement(Portal, __assign({ as:
|
|
151
|
+
React.createElement(Portal, __assign({ as: Tag }, other, { style: __assign(__assign({}, style), styles.popper), ref: portalRef, className: cnPopover({ disableInteractive: disableInteractive }, [className]) }, attributes.popper),
|
|
147
152
|
children,
|
|
148
153
|
arrow && (React.createElement(PopoverArrow, __assign({}, arrowProps, { style: __assign(__assign({}, arrowProps === null || arrowProps === void 0 ? void 0 : arrowProps.style), styles.arrow), "data-popper-arrow": true })))))));
|
|
149
154
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const POPOVER_DEFAULT_TAG
|
|
1
|
+
export declare const POPOVER_DEFAULT_TAG = "div";
|
|
2
2
|
export declare const POPOVER_DEFAULT_ARROW = false;
|
|
3
3
|
export declare const POPOVER_DEFAULT_OPEN = false;
|
|
4
4
|
export declare const POPOVER_DEFAULT_DISABLE_INTERACTIVE = false;
|
|
@@ -3,7 +3,7 @@ import type PopperJS from '@popperjs/core';
|
|
|
3
3
|
import type { PopperProps } from 'react-popper';
|
|
4
4
|
import type { CSSTransitionProps } from 'react-transition-group/CSSTransition';
|
|
5
5
|
import type { PolymorphicComponentPropsWithRef } from '../../utils/polymorphicComponentWithRef';
|
|
6
|
-
import type {
|
|
6
|
+
import type { PortalBaseProps } from '../Portal';
|
|
7
7
|
import type { PopoverArrowProps } from './components';
|
|
8
8
|
import type { POPOVER_DEFAULT_TAG } from './constants';
|
|
9
9
|
export type VirtualElement = {
|
|
@@ -71,8 +71,6 @@ export type PopoverBaseProps = {
|
|
|
71
71
|
'data-testid'?: string;
|
|
72
72
|
/** Функция обратного вызова для получения метода по перерасчету расположения компонента Popover */
|
|
73
73
|
setUpdate?(update: PopperJS.Instance['update'] | null): void;
|
|
74
|
-
/** Контейнер для монтирования всплывающего окна */
|
|
75
|
-
container?: PortalProps['container'];
|
|
76
74
|
/** Стратегия позиционирования */
|
|
77
75
|
strategy?: PopoverStrategyVariant;
|
|
78
76
|
/** Если {true} позволяет смещаться по границе якорного элемента компонента */
|
|
@@ -82,6 +80,6 @@ export type PopoverBaseProps = {
|
|
|
82
80
|
* https://popper.js.org/docs/v2/modifiers/#custom-modifiers
|
|
83
81
|
* */
|
|
84
82
|
modifiers?: PopperProps<unknown>['modifiers'];
|
|
85
|
-
};
|
|
83
|
+
} & PortalBaseProps;
|
|
86
84
|
export type PopoverRef = ComponentRef<typeof POPOVER_DEFAULT_TAG>;
|
|
87
85
|
export type PopoverProps<As extends ElementType = typeof POPOVER_DEFAULT_TAG> = PolymorphicComponentPropsWithRef<PopoverBaseProps, As>;
|
|
@@ -4,14 +4,14 @@ import { createPortal } from 'react-dom';
|
|
|
4
4
|
import { useThemeProps } from '../../hooks/useThemeProps';
|
|
5
5
|
import { polymorphicComponentWithRef } from '../../utils/polymorphicComponentWithRef';
|
|
6
6
|
import { useTheme, ThemeProvider } from '../ThemeProvider';
|
|
7
|
-
import { PORTAL_DEFAULT_TAG } from './constants';
|
|
7
|
+
import { PORTAL_DEFAULT_CONTAINER, PORTAL_DEFAULT_DISABLE_PORTAL, PORTAL_DEFAULT_TAG, } from './constants';
|
|
8
8
|
export var Portal = polymorphicComponentWithRef(function (inProps, ref) {
|
|
9
9
|
var _a = useThemeProps({
|
|
10
10
|
props: inProps,
|
|
11
11
|
name: 'Portal',
|
|
12
|
-
}),
|
|
12
|
+
}), _b = _a.disablePortal, disablePortal = _b === void 0 ? PORTAL_DEFAULT_DISABLE_PORTAL : _b, _c = _a.as, Tag = _c === void 0 ? PORTAL_DEFAULT_TAG : _c, containerProp = _a.container, children = _a.children, other = __rest(_a, ["disablePortal", "as", "container", "children"]);
|
|
13
|
+
var container = containerProp || PORTAL_DEFAULT_CONTAINER;
|
|
13
14
|
var theme = useTheme();
|
|
14
|
-
|
|
15
|
-
return createPortal(React.createElement(ThemeProvider, __assign({ theme: theme, className: className, as: Tag }, other, { ref: ref }), children), portalContainer);
|
|
15
|
+
return disablePortal ? (React.createElement(Tag, __assign({}, other, { ref: ref }), children)) : (createPortal(React.createElement(ThemeProvider, __assign({ theme: theme, as: Tag }, other, { ref: ref }), children), container));
|
|
16
16
|
});
|
|
17
17
|
Portal.displayName = 'Portal';
|
|
@@ -5,5 +5,8 @@ export type PortalRef = ComponentRef<typeof PORTAL_DEFAULT_TAG>;
|
|
|
5
5
|
export type PortalBaseProps = {
|
|
6
6
|
/** Контейнер для монтирования портала */
|
|
7
7
|
container?: Element | DocumentFragment | null;
|
|
8
|
+
/** Если {true} отключает портал для компонента.
|
|
9
|
+
* Подробнее — https://react.dev/reference/react-dom/createPortal. */
|
|
10
|
+
disablePortal?: boolean;
|
|
8
11
|
};
|
|
9
12
|
export type PortalProps<As extends ElementType = typeof PORTAL_DEFAULT_TAG> = PolymorphicComponentPropsWithoutRef<PortalBaseProps, As>;
|
|
@@ -10,7 +10,7 @@ export type SnackbarProps = PortalProps & {
|
|
|
10
10
|
};
|
|
11
11
|
export declare const Snackbar: React.ForwardRefExoticComponent<import("../../../Portal").PortalBaseProps & {
|
|
12
12
|
as?: "div" | undefined;
|
|
13
|
-
} & Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "
|
|
13
|
+
} & Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, keyof import("../../../Portal").PortalBaseProps> & {
|
|
14
14
|
/** Расположение сообщения относительно контейнера */
|
|
15
15
|
anchorOrigin?: SnackbarAnchorOrigin | undefined;
|
|
16
16
|
} & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __assign, __read, __rest } from "tslib";
|
|
1
|
+
import { __assign, __read, __rest, __spreadArray } from "tslib";
|
|
2
2
|
import './Tooltip.css';
|
|
3
3
|
import React, { useRef, useMemo, useEffect, useState } from 'react';
|
|
4
4
|
import { deprecate } from '@ozen-ui/logger';
|
|
@@ -14,7 +14,7 @@ import { TOOLTIP_DEFAULT_ARROW, TOOLTIP_DEFAULT_DELAY_ENTER, TOOLTIP_DEFAULT_DEL
|
|
|
14
14
|
export var cnTooltip = cn('Tooltip');
|
|
15
15
|
export var Tooltip = polymorphicComponentWithRef(function (inProps, ref) {
|
|
16
16
|
var props = useThemeProps({ props: inProps, name: 'Tooltip' });
|
|
17
|
-
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, _k = props.as, as = _k === void 0 ? TOOLTIP_DEFAULT_TAG : _k,
|
|
17
|
+
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, _k = props.as, as = _k === void 0 ? TOOLTIP_DEFAULT_TAG : _k, modifiersProp = props.modifiers, onMouseEnter = props.onMouseEnter, onMouseLeave = props.onMouseLeave, variant = props.variant, children = props.children, label = props.label, openProp = props.open, className = props.className, onOpen = props.onOpen, onClose = props.onClose, other = __rest(props, ["trigger", "size", "offset", "delayEnter", "delayLeave", "arrow", "shouldWrapChildren", "disabled", "inverse", "as", "modifiers", "onMouseEnter", "onMouseLeave", "variant", "children", "label", "open", "className", "onOpen", "onClose"]);
|
|
18
18
|
if (process.env.NODE_ENV !== 'production' && variant) {
|
|
19
19
|
deprecate('Свойство «variant» устарело. Для замены используйте «inverse».');
|
|
20
20
|
}
|
|
@@ -22,14 +22,14 @@ export var Tooltip = polymorphicComponentWithRef(function (inProps, ref) {
|
|
|
22
22
|
var _l = __read(useState(), 2), delay = _l[0], setDelay = _l[1];
|
|
23
23
|
var _m = __read(useBoolean(), 2), focused = _m[0], setFocused = _m[1];
|
|
24
24
|
var _o = __read(useBoolean(), 2), hovered = _o[0], setHovered = _o[1];
|
|
25
|
-
var modifiers = [
|
|
25
|
+
var modifiers = __spreadArray([
|
|
26
26
|
{
|
|
27
27
|
name: 'arrow',
|
|
28
28
|
options: {
|
|
29
29
|
padding: size === 'xs' ? 8 : 12,
|
|
30
30
|
},
|
|
31
|
-
}
|
|
32
|
-
];
|
|
31
|
+
}
|
|
32
|
+
], __read((modifiersProp || [])), false);
|
|
33
33
|
var _p = __read(useControlled({
|
|
34
34
|
value: openProp,
|
|
35
35
|
defaultValue: false,
|
|
@@ -62,18 +62,20 @@ export var Tooltip = polymorphicComponentWithRef(function (inProps, ref) {
|
|
|
62
62
|
}, [children, shouldWrapChildren]);
|
|
63
63
|
var childrenProps = resolveChildren.props, childrenRef = resolveChildren.ref;
|
|
64
64
|
var childrenMultiRef = useMultiRef([anchorRef, childrenRef]);
|
|
65
|
-
var handleMouseEnter = function () {
|
|
65
|
+
var handleMouseEnter = function (e) {
|
|
66
66
|
if (trigger === 'hover' || trigger === 'hover&focus') {
|
|
67
67
|
setHovered.on();
|
|
68
68
|
setOpenWithDelay(true);
|
|
69
69
|
}
|
|
70
|
+
onMouseEnter === null || onMouseEnter === void 0 ? void 0 : onMouseEnter(e);
|
|
70
71
|
};
|
|
71
|
-
var handleMouseLeave = function () {
|
|
72
|
+
var handleMouseLeave = function (e) {
|
|
72
73
|
if (trigger === 'hover' || trigger === 'hover&focus') {
|
|
73
74
|
setHovered.off();
|
|
74
75
|
if (!focused)
|
|
75
76
|
setOpenWithDelay(false);
|
|
76
77
|
}
|
|
78
|
+
onMouseLeave === null || onMouseLeave === void 0 ? void 0 : onMouseLeave(e);
|
|
77
79
|
};
|
|
78
80
|
var handleClick = function () {
|
|
79
81
|
if (trigger === 'click')
|
|
@@ -109,11 +111,11 @@ export var Tooltip = polymorphicComponentWithRef(function (inProps, ref) {
|
|
|
109
111
|
onBlur === null || onBlur === void 0 ? void 0 : onBlur(e);
|
|
110
112
|
},
|
|
111
113
|
onMouseEnter: function (e) {
|
|
112
|
-
handleMouseEnter();
|
|
114
|
+
handleMouseEnter(e);
|
|
113
115
|
onMouseEnter === null || onMouseEnter === void 0 ? void 0 : onMouseEnter(e);
|
|
114
116
|
},
|
|
115
117
|
onMouseLeave: function (e) {
|
|
116
|
-
handleMouseLeave();
|
|
118
|
+
handleMouseLeave(e);
|
|
117
119
|
onMouseLeave === null || onMouseLeave === void 0 ? void 0 : onMouseLeave(e);
|
|
118
120
|
},
|
|
119
121
|
};
|
|
@@ -129,9 +131,7 @@ export var Tooltip = polymorphicComponentWithRef(function (inProps, ref) {
|
|
|
129
131
|
]);
|
|
130
132
|
return (React.createElement(React.Fragment, null,
|
|
131
133
|
React.cloneElement(resolveChildren, composeChildrenProps),
|
|
132
|
-
React.createElement(Popover, __assign({
|
|
133
|
-
size: size,
|
|
134
|
-
}, modifiers: modifiers, disableEnforceFocus: true, disableReturnFocus: true }),
|
|
134
|
+
React.createElement(Popover, __assign({ arrow: arrow, offset: offset, background: "main", strategy: "absolute", arrowProps: { size: size }, anchorRef: anchorRef, modifiers: modifiers, as: as, onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave, radius: size === 'xs' ? 's' : 'l' }, (inverse && { background: 'main-inverse' }), (variant === 'dark' && { background: 'main-inverse' }), { className: cnTooltip({ size: size, variant: variant, inverse: inverse }, [className]), disableEnforceFocus: true, disableReturnFocus: true }, other, { open: openState, onClose: closeWithDelay, ref: ref }),
|
|
135
135
|
React.createElement("div", { className: cnTooltip('Content', { size: size, variant: variant, inverse: inverse }) }, label))));
|
|
136
136
|
});
|
|
137
137
|
Tooltip.displayName = 'Tooltip';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const TOOLTIP_DEFAULT_TAG
|
|
1
|
+
export declare const TOOLTIP_DEFAULT_TAG = "div";
|
|
2
2
|
export declare const TOOLTIP_DEFAULT_TRIGGER = "hover";
|
|
3
3
|
export declare const TOOLTIP_DEFAULT_SIZE = "s";
|
|
4
4
|
export declare const TOOLTIP_DEFAULT_INVERSE = true;
|
|
@@ -48,7 +48,7 @@ export type TooltipBaseProps = {
|
|
|
48
48
|
'data-testid'?: string;
|
|
49
49
|
/** Дополнительные CSS-классы */
|
|
50
50
|
className?: string;
|
|
51
|
-
} & TooltipPropsDeprecated &
|
|
51
|
+
} & TooltipPropsDeprecated & Omit<Partial<PopoverBaseProps>, 'onClose' | 'open'>;
|
|
52
52
|
export type TooltipRef = ComponentRef<typeof TOOLTIP_DEFAULT_TAG>;
|
|
53
53
|
export type TooltipProps<As extends ElementType = typeof TOOLTIP_DEFAULT_TAG> = PolymorphicComponentPropsWithRef<TooltipBaseProps, As>;
|
|
54
54
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ozen-ui/kit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.57.0",
|
|
4
4
|
"description": "React component library",
|
|
5
5
|
"files": [
|
|
6
6
|
"*"
|
|
@@ -23,13 +23,13 @@
|
|
|
23
23
|
"@popperjs/core": "^2.11.8",
|
|
24
24
|
"@rehookify/datepicker": "^6.6.1",
|
|
25
25
|
"decimal.js": "^10.4.3",
|
|
26
|
-
"react-is": "^18.
|
|
26
|
+
"react-is": "^18.3.1",
|
|
27
27
|
"react-popper": "^2.3.0",
|
|
28
28
|
"react-transition-group": "^4.4.5",
|
|
29
|
-
"tslib": "^2.6.
|
|
30
|
-
"@ozen-ui/fonts": "0.
|
|
31
|
-
"@ozen-ui/
|
|
32
|
-
"@ozen-ui/
|
|
29
|
+
"tslib": "^2.6.3",
|
|
30
|
+
"@ozen-ui/fonts": "0.57.0",
|
|
31
|
+
"@ozen-ui/icons": "0.57.0",
|
|
32
|
+
"@ozen-ui/logger": "0.57.0"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"react": ">=17.0.2 <19.0.0",
|