@ozen-ui/kit 0.10.0 → 0.11.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/InputNumber/InputNumber.js +2 -2
- package/__inner__/cjs/components/Popover/Popover.js +7 -7
- package/__inner__/cjs/components/Popover/constants.d.ts +1 -0
- package/__inner__/cjs/components/Popover/constants.js +2 -1
- package/__inner__/cjs/components/Popover/types.d.ts +2 -0
- package/__inner__/esm/components/InputNumber/InputNumber.js +2 -2
- package/__inner__/esm/components/Popover/Popover.js +8 -8
- package/__inner__/esm/components/Popover/constants.d.ts +1 -0
- package/__inner__/esm/components/Popover/constants.js +1 -0
- package/__inner__/esm/components/Popover/types.d.ts +2 -0
- package/package.json +1 -1
|
@@ -144,8 +144,8 @@ exports.InputNumber = (0, react_1.forwardRef)(function (inProps, ref) {
|
|
|
144
144
|
]), min: min, max: max, step: step }, inputProps, { type: "number", onFocus: handleFocus, onBlur: handleBlur, onChange: handleChange, onKeyDown: handleKeyDown, ref: (0, useMultiRef_1.useMultiRef)([inputProps === null || inputProps === void 0 ? void 0 : inputProps.ref, fieldRef]) }))),
|
|
145
145
|
react_1["default"].createElement(FieldIcon_1.FieldIcon, { className: (0, exports.cnInputNumber)('RenderRight'), icon: renderRight, size: size }),
|
|
146
146
|
react_1["default"].createElement("span", { className: (0, exports.cnInputNumber)('Controls') },
|
|
147
|
-
react_1["default"].createElement(IconButton_1.IconButton, { tabIndex: -1, size: size, className: (0, exports.cnInputNumber)('Increment'), icon: icons_1.SortUpIcon, onMouseDown: handleMouseDown('increment'), disabled: disabled, "aria-label": "increment", variant: "ghost" }),
|
|
148
|
-
react_1["default"].createElement(IconButton_1.IconButton, { tabIndex: -1, size: size, icon: icons_1.SortDownIcon, className: (0, exports.cnInputNumber)('Decrement'), onMouseDown: handleMouseDown('decrement'), disabled: disabled, "aria-label": "decrement", variant: "ghost" })),
|
|
147
|
+
react_1["default"].createElement(IconButton_1.IconButton, { tabIndex: -1, size: size, className: (0, exports.cnInputNumber)('Increment'), icon: icons_1.SortUpIcon, onMouseDown: handleMouseDown('increment'), disabled: disabled, "aria-label": "increment", type: "button", variant: "ghost" }),
|
|
148
|
+
react_1["default"].createElement(IconButton_1.IconButton, { tabIndex: -1, size: size, icon: icons_1.SortDownIcon, className: (0, exports.cnInputNumber)('Decrement'), onMouseDown: handleMouseDown('decrement'), disabled: disabled, "aria-label": "decrement", type: "button", variant: "ghost" })),
|
|
149
149
|
react_1["default"].createElement(Fieldset_1.Fieldset, { className: (0, exports.cnInputNumber)('Fieldset') })),
|
|
150
150
|
react_1["default"].createElement(FieldHint_1.FieldHint, { size: size, error: error, disabled: disabled }, hint)));
|
|
151
151
|
});
|
|
@@ -22,12 +22,12 @@ var PopoverContext_1 = require("./PopoverContext");
|
|
|
22
22
|
exports.cnPopover = (0, classname_1.cn)('Popover');
|
|
23
23
|
exports.Popover = (0, polymorphicComponentWithRef_1.polymorphicComponentWithRef)(function (inProps, ref) {
|
|
24
24
|
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.placement, placement =
|
|
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, 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, other = tslib_1.__rest(props, ["arrow", "open", "disableInteractive", "disableEnforceFocus", "disableReturnFocus", "disableClickOutside", "placement", "ignoreClickOutsideRefs", "arrowProps", "anchorRef", "equalAnchorWidth", "offset", "children", "transitionProps", "onClose", "onEnter", "onEntered", "onExit", "onExited", "className", "position", "style", "setUpdate"]);
|
|
26
26
|
var isClickOutSide = (0, react_1.useRef)(null);
|
|
27
|
-
var
|
|
27
|
+
var _h = tslib_1.__read((0, react_1.useState)(false), 2), openState = _h[0], setOpenState = _h[1];
|
|
28
28
|
var focusedElement = (0, react_1.useRef)(null);
|
|
29
29
|
var popoverRef = (0, react_1.useRef)(null);
|
|
30
|
-
var
|
|
30
|
+
var _j = (0, index_1.usePopoverManager)(popoverRef, 1000, openState), refsClickOutside = _j.refsClickOutside, isTop = _j.isTop;
|
|
31
31
|
// Ловушка фокуса
|
|
32
32
|
var trapRef = (0, useFocusTrap_1.useFocusTrap)({
|
|
33
33
|
active: !disableEnforceFocus && isTop,
|
|
@@ -52,7 +52,7 @@ exports.Popover = (0, polymorphicComponentWithRef_1.polymorphicComponentWithRef)
|
|
|
52
52
|
isClickOutSide.current = true;
|
|
53
53
|
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
54
54
|
},
|
|
55
|
-
active: openState
|
|
55
|
+
active: openState && !disableClickOutside
|
|
56
56
|
});
|
|
57
57
|
var onExited = (0, react_1.useCallback)(function () {
|
|
58
58
|
var _a, _b;
|
|
@@ -120,12 +120,12 @@ exports.Popover = (0, polymorphicComponentWithRef_1.polymorphicComponentWithRef)
|
|
|
120
120
|
};
|
|
121
121
|
return undefined;
|
|
122
122
|
}, [anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.current, position]);
|
|
123
|
-
var
|
|
124
|
-
var
|
|
123
|
+
var _k = tslib_1.__read((0, react_1.useState)(null), 2), popperElement = _k[0], setPopperElement = _k[1];
|
|
124
|
+
var _l = (0, react_popper_1.usePopper)(resolveReferenceElement, popperElement, {
|
|
125
125
|
placement: placement,
|
|
126
126
|
strategy: 'fixed',
|
|
127
127
|
modifiers: modifiers
|
|
128
|
-
}), styles =
|
|
128
|
+
}), styles = _l.styles, attributes = _l.attributes, update = _l.update;
|
|
129
129
|
// Передача метода по перерасчету расположения компонента Popover в родительский компонент
|
|
130
130
|
(0, react_1.useEffect)(function () {
|
|
131
131
|
setUpdate === null || setUpdate === void 0 ? void 0 : setUpdate(update);
|
|
@@ -4,4 +4,5 @@ export declare const POPOVER_DEFAULT_OPEN = false;
|
|
|
4
4
|
export declare const POPOVER_DEFAULT_DISABLE_INTERACTIVE = false;
|
|
5
5
|
export declare const POPOVER_DEFAULT_DISABLE_ENFORCE_FOCUS = false;
|
|
6
6
|
export declare const POPOVER_DEFAULT_DISABLE_RETURN_FOCUS = false;
|
|
7
|
+
export declare const POPOVER_DEFAULT_DISABLE_CLICK_OUTSIDE = false;
|
|
7
8
|
export declare const POPOVER_DEFAULT_PLACEMENT = "auto";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
exports.__esModule = true;
|
|
3
|
-
exports.POPOVER_DEFAULT_PLACEMENT = 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;
|
|
3
|
+
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
4
|
var Paper_1 = require("../Paper");
|
|
5
5
|
exports.POPOVER_DEFAULT_TAG = Paper_1.Paper;
|
|
6
6
|
exports.POPOVER_DEFAULT_ARROW = false;
|
|
@@ -8,4 +8,5 @@ exports.POPOVER_DEFAULT_OPEN = false;
|
|
|
8
8
|
exports.POPOVER_DEFAULT_DISABLE_INTERACTIVE = false;
|
|
9
9
|
exports.POPOVER_DEFAULT_DISABLE_ENFORCE_FOCUS = false;
|
|
10
10
|
exports.POPOVER_DEFAULT_DISABLE_RETURN_FOCUS = false;
|
|
11
|
+
exports.POPOVER_DEFAULT_DISABLE_CLICK_OUTSIDE = false;
|
|
11
12
|
exports.POPOVER_DEFAULT_PLACEMENT = 'auto';
|
|
@@ -62,6 +62,8 @@ export type PopoverBaseProps = {
|
|
|
62
62
|
disableEnforceFocus?: boolean;
|
|
63
63
|
/** Отключает захват и возврат текущего фокуса на момент открытия и закрытия окна соответственно */
|
|
64
64
|
disableReturnFocus?: boolean;
|
|
65
|
+
/** Если {true} отключает закрытие окна при клике за его пределами */
|
|
66
|
+
disableClickOutside?: boolean;
|
|
65
67
|
/** Идентификатор компонента для тестов */
|
|
66
68
|
'data-testid'?: string;
|
|
67
69
|
/** Функция обратного вызова для получения метода по перерасчету расположения компонента Popover */
|
|
@@ -141,8 +141,8 @@ export var InputNumber = forwardRef(function (inProps, ref) {
|
|
|
141
141
|
]), min: min, max: max, step: step }, inputProps, { type: "number", onFocus: handleFocus, onBlur: handleBlur, onChange: handleChange, onKeyDown: handleKeyDown, ref: useMultiRef([inputProps === null || inputProps === void 0 ? void 0 : inputProps.ref, fieldRef]) }))),
|
|
142
142
|
React.createElement(FieldIcon, { className: cnInputNumber('RenderRight'), icon: renderRight, size: size }),
|
|
143
143
|
React.createElement("span", { className: cnInputNumber('Controls') },
|
|
144
|
-
React.createElement(IconButton, { tabIndex: -1, size: size, className: cnInputNumber('Increment'), icon: SortUpIcon, onMouseDown: handleMouseDown('increment'), disabled: disabled, "aria-label": "increment", variant: "ghost" }),
|
|
145
|
-
React.createElement(IconButton, { tabIndex: -1, size: size, icon: SortDownIcon, className: cnInputNumber('Decrement'), onMouseDown: handleMouseDown('decrement'), disabled: disabled, "aria-label": "decrement", variant: "ghost" })),
|
|
144
|
+
React.createElement(IconButton, { tabIndex: -1, size: size, className: cnInputNumber('Increment'), icon: SortUpIcon, onMouseDown: handleMouseDown('increment'), disabled: disabled, "aria-label": "increment", type: "button", variant: "ghost" }),
|
|
145
|
+
React.createElement(IconButton, { tabIndex: -1, size: size, icon: SortDownIcon, className: cnInputNumber('Decrement'), onMouseDown: handleMouseDown('decrement'), disabled: disabled, "aria-label": "decrement", type: "button", variant: "ghost" })),
|
|
146
146
|
React.createElement(Fieldset, { className: cnInputNumber('Fieldset') })),
|
|
147
147
|
React.createElement(FieldHint, { size: size, error: error, disabled: disabled }, hint)));
|
|
148
148
|
});
|
|
@@ -13,18 +13,18 @@ import { isKey } from '../../utils/isKey';
|
|
|
13
13
|
import { polymorphicComponentWithRef } from '../../utils/polymorphicComponentWithRef';
|
|
14
14
|
import { Portal } from '../Portal';
|
|
15
15
|
import { PopoverArrow } from './components';
|
|
16
|
-
import { POPOVER_DEFAULT_ARROW, POPOVER_DEFAULT_DISABLE_ENFORCE_FOCUS, POPOVER_DEFAULT_DISABLE_INTERACTIVE, POPOVER_DEFAULT_DISABLE_RETURN_FOCUS, POPOVER_DEFAULT_OPEN, POPOVER_DEFAULT_PLACEMENT, POPOVER_DEFAULT_TAG, } from './constants';
|
|
16
|
+
import { 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_TAG, } from './constants';
|
|
17
17
|
import { usePopoverManager } from './index';
|
|
18
18
|
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.placement, placement =
|
|
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, 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, other = __rest(props, ["arrow", "open", "disableInteractive", "disableEnforceFocus", "disableReturnFocus", "disableClickOutside", "placement", "ignoreClickOutsideRefs", "arrowProps", "anchorRef", "equalAnchorWidth", "offset", "children", "transitionProps", "onClose", "onEnter", "onEntered", "onExit", "onExited", "className", "position", "style", "setUpdate"]);
|
|
23
23
|
var isClickOutSide = useRef(null);
|
|
24
|
-
var
|
|
24
|
+
var _h = __read(useState(false), 2), openState = _h[0], setOpenState = _h[1];
|
|
25
25
|
var focusedElement = useRef(null);
|
|
26
26
|
var popoverRef = useRef(null);
|
|
27
|
-
var
|
|
27
|
+
var _j = usePopoverManager(popoverRef, 1000, openState), refsClickOutside = _j.refsClickOutside, isTop = _j.isTop;
|
|
28
28
|
// Ловушка фокуса
|
|
29
29
|
var trapRef = useFocusTrap({
|
|
30
30
|
active: !disableEnforceFocus && isTop,
|
|
@@ -49,7 +49,7 @@ export var Popover = polymorphicComponentWithRef(function (inProps, ref) {
|
|
|
49
49
|
isClickOutSide.current = true;
|
|
50
50
|
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
51
51
|
},
|
|
52
|
-
active: openState
|
|
52
|
+
active: openState && !disableClickOutside
|
|
53
53
|
});
|
|
54
54
|
var onExited = useCallback(function () {
|
|
55
55
|
var _a, _b;
|
|
@@ -117,12 +117,12 @@ export var Popover = polymorphicComponentWithRef(function (inProps, ref) {
|
|
|
117
117
|
};
|
|
118
118
|
return undefined;
|
|
119
119
|
}, [anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.current, position]);
|
|
120
|
-
var
|
|
121
|
-
var
|
|
120
|
+
var _k = __read(useState(null), 2), popperElement = _k[0], setPopperElement = _k[1];
|
|
121
|
+
var _l = usePopper(resolveReferenceElement, popperElement, {
|
|
122
122
|
placement: placement,
|
|
123
123
|
strategy: 'fixed',
|
|
124
124
|
modifiers: modifiers
|
|
125
|
-
}), styles =
|
|
125
|
+
}), styles = _l.styles, attributes = _l.attributes, update = _l.update;
|
|
126
126
|
// Передача метода по перерасчету расположения компонента Popover в родительский компонент
|
|
127
127
|
useEffect(function () {
|
|
128
128
|
setUpdate === null || setUpdate === void 0 ? void 0 : setUpdate(update);
|
|
@@ -4,4 +4,5 @@ export declare const POPOVER_DEFAULT_OPEN = false;
|
|
|
4
4
|
export declare const POPOVER_DEFAULT_DISABLE_INTERACTIVE = false;
|
|
5
5
|
export declare const POPOVER_DEFAULT_DISABLE_ENFORCE_FOCUS = false;
|
|
6
6
|
export declare const POPOVER_DEFAULT_DISABLE_RETURN_FOCUS = false;
|
|
7
|
+
export declare const POPOVER_DEFAULT_DISABLE_CLICK_OUTSIDE = false;
|
|
7
8
|
export declare const POPOVER_DEFAULT_PLACEMENT = "auto";
|
|
@@ -5,4 +5,5 @@ export var POPOVER_DEFAULT_OPEN = false;
|
|
|
5
5
|
export var POPOVER_DEFAULT_DISABLE_INTERACTIVE = false;
|
|
6
6
|
export var POPOVER_DEFAULT_DISABLE_ENFORCE_FOCUS = false;
|
|
7
7
|
export var POPOVER_DEFAULT_DISABLE_RETURN_FOCUS = false;
|
|
8
|
+
export var POPOVER_DEFAULT_DISABLE_CLICK_OUTSIDE = false;
|
|
8
9
|
export var POPOVER_DEFAULT_PLACEMENT = 'auto';
|
|
@@ -62,6 +62,8 @@ export type PopoverBaseProps = {
|
|
|
62
62
|
disableEnforceFocus?: boolean;
|
|
63
63
|
/** Отключает захват и возврат текущего фокуса на момент открытия и закрытия окна соответственно */
|
|
64
64
|
disableReturnFocus?: boolean;
|
|
65
|
+
/** Если {true} отключает закрытие окна при клике за его пределами */
|
|
66
|
+
disableClickOutside?: boolean;
|
|
65
67
|
/** Идентификатор компонента для тестов */
|
|
66
68
|
'data-testid'?: string;
|
|
67
69
|
/** Функция обратного вызова для получения метода по перерасчету расположения компонента Popover */
|