oolib 2.90.4 → 2.91.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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export function ActionMenu({ icon, invert, actions, align, iconSize, M, ButtonComp: _ButtonComp, setShowActions: setShowActionsInParent, popOutOfOverflowHiddenParent, CustomSelectComp, storybookPreview,
|
|
1
|
+
export function ActionMenu({ icon, invert, actions, align, iconSize, M, ButtonComp: _ButtonComp, setShowActions: setShowActionsInParent, popOutOfOverflowHiddenParent, CustomSelectComp, storybookPreview, }: {
|
|
2
2
|
icon?: string;
|
|
3
3
|
invert: any;
|
|
4
4
|
actions: any;
|
|
@@ -10,6 +10,5 @@ export function ActionMenu({ icon, invert, actions, align, iconSize, M, ButtonCo
|
|
|
10
10
|
popOutOfOverflowHiddenParent?: boolean;
|
|
11
11
|
CustomSelectComp: any;
|
|
12
12
|
storybookPreview: any;
|
|
13
|
-
useLightboxPortal: any;
|
|
14
13
|
}): React.JSX.Element;
|
|
15
14
|
import React from "react";
|
|
@@ -47,12 +47,13 @@ var react_dom_1 = require("react-dom");
|
|
|
47
47
|
//
|
|
48
48
|
var ActionMenu = function (_a) {
|
|
49
49
|
var _b = _a.icon, icon = _b === void 0 ? "DotsThree" : _b, //most likely will never change
|
|
50
|
-
invert = _a.invert, actions = _a.actions, _c = _a.align, align = _c === void 0 ? "right" : _c, _d = _a.iconSize, iconSize = _d === void 0 ? "S" : _d, M = _a.M, _e = _a.ButtonComp, _ButtonComp = _e === void 0 ? "ButtonGhost" : _e, setShowActionsInParent = _a.setShowActions, _f = _a.popOutOfOverflowHiddenParent, popOutOfOverflowHiddenParent = _f === void 0 ? false : _f, CustomSelectComp = _a.CustomSelectComp, storybookPreview = _a.storybookPreview
|
|
51
|
-
useLightboxPortal = _a.useLightboxPortal;
|
|
50
|
+
invert = _a.invert, actions = _a.actions, _c = _a.align, align = _c === void 0 ? "right" : _c, _d = _a.iconSize, iconSize = _d === void 0 ? "S" : _d, M = _a.M, _e = _a.ButtonComp, _ButtonComp = _e === void 0 ? "ButtonGhost" : _e, setShowActionsInParent = _a.setShowActions, _f = _a.popOutOfOverflowHiddenParent, popOutOfOverflowHiddenParent = _f === void 0 ? false : _f, CustomSelectComp = _a.CustomSelectComp, storybookPreview = _a.storybookPreview;
|
|
52
51
|
var actionMenuRef = (0, react_1.useRef)(null);
|
|
53
52
|
var optionsWrapperRef = (0, react_1.useRef)(null);
|
|
54
53
|
var _g = (0, react_1.useState)(false), showActions = _g[0], setShowActions = _g[1];
|
|
55
|
-
(0, useHandleClickOutside_1.useHandleClickOutside)(
|
|
54
|
+
(0, useHandleClickOutside_1.useHandleClickOutside)(popOutOfOverflowHiddenParent
|
|
55
|
+
? [actionMenuRef, optionsWrapperRef] //cuz in popOut case, options are rendered in a portal, which means the 'options' are no longer a child on acitonMenuRef. Hence we need to track click outside optionsWrapperRef as well.
|
|
56
|
+
: actionMenuRef, setShowActions);
|
|
56
57
|
if (!actions || actions.length === 0)
|
|
57
58
|
return null;
|
|
58
59
|
var getOpsRect = function () { var _a; return (_a = optionsWrapperRef.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect(); };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export function useHandleClickOutside(ref: any, setShowOptions: any, options?:
|
|
1
|
+
export function useHandleClickOutside(ref: any, setShowOptions: any, options?: any): void;
|
|
@@ -2,13 +2,20 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useHandleClickOutside = void 0;
|
|
4
4
|
var react_1 = require("react");
|
|
5
|
+
var toArray_1 = require("../toArray");
|
|
6
|
+
/**
|
|
7
|
+
*
|
|
8
|
+
* @param {*} ref can be a ref or an array of refs
|
|
9
|
+
* @param {*} setShowOptions
|
|
10
|
+
* @param {*} options
|
|
11
|
+
*/
|
|
5
12
|
var useHandleClickOutside = function (ref, setShowOptions, options) {
|
|
6
13
|
if (options === void 0) { options = {}; }
|
|
7
14
|
var _a = options.enabled, enabled = _a === void 0 ? true : _a;
|
|
8
15
|
var handleClickOutside = function (event) {
|
|
9
16
|
if (!enabled)
|
|
10
17
|
return;
|
|
11
|
-
if (ref.current && !
|
|
18
|
+
if ((0, toArray_1.toArray)(ref).every(function (refD) { return refD.current && !refD.current.contains(event.target); })) {
|
|
12
19
|
//clicked outside editor
|
|
13
20
|
setShowOptions(false);
|
|
14
21
|
}
|