@yakad/ui 1.3.107 → 1.3.108
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,10 +1,13 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
|
|
2
|
+
import { CardProps } from "../";
|
|
3
|
+
export interface WithDropdawnProps extends CardProps {
|
|
3
4
|
trigger?: "onClick" | "onRightClick";
|
|
4
|
-
|
|
5
|
-
dropdawnchildren?: React.ReactElement;
|
|
5
|
+
dropdawnChildren?: React.ReactElement;
|
|
6
6
|
children?: React.ReactElement<{
|
|
7
7
|
onClick?: (e: React.MouseEvent<HTMLElement>) => void;
|
|
8
8
|
}>;
|
|
9
9
|
}
|
|
10
|
-
export declare const WithDropdawn:
|
|
10
|
+
export declare const WithDropdawn: {
|
|
11
|
+
({ trigger, dropdawnChildren, style, children, ...restProps }: WithDropdawnProps): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
displayName: string;
|
|
13
|
+
};
|
|
@@ -1,8 +1,20 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
2
13
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
14
|
import { useRef, useState, useEffect, cloneElement } from "react";
|
|
4
|
-
import { WithInteractions } from "../";
|
|
5
|
-
export const WithDropdawn = (
|
|
15
|
+
import { Card, WithInteractions } from "../";
|
|
16
|
+
export const WithDropdawn = (_a) => {
|
|
17
|
+
var { trigger = "onClick", dropdawnChildren, style, children } = _a, restProps = __rest(_a, ["trigger", "dropdawnChildren", "style", "children"]);
|
|
6
18
|
const toggleElementRef = useRef(null);
|
|
7
19
|
const dropdawnRef = useRef(null);
|
|
8
20
|
const [showDropdawn, setShowDropdawn] = useState(false);
|
|
@@ -31,7 +43,7 @@ export const WithDropdawn = ({ trigger = "onClick", dropdawnchildren, dropdawnst
|
|
|
31
43
|
setTop(top);
|
|
32
44
|
setLeft(left);
|
|
33
45
|
}
|
|
34
|
-
}, [showDropdawn,
|
|
46
|
+
}, [showDropdawn, dropdawnChildren]);
|
|
35
47
|
return (_jsxs(_Fragment, { children: [_jsx(WithInteractions, { ref: toggleElementRef, onRightClick: () => trigger === "onRightClick" && setShowDropdawn(true), children: children &&
|
|
36
48
|
cloneElement(children, {
|
|
37
49
|
onClick: (e) => {
|
|
@@ -39,5 +51,6 @@ export const WithDropdawn = ({ trigger = "onClick", dropdawnchildren, dropdawnst
|
|
|
39
51
|
(_b = (_a = children.props).onClick) === null || _b === void 0 ? void 0 : _b.call(_a, e);
|
|
40
52
|
trigger === "onClick" && toggleShowDropdawn();
|
|
41
53
|
},
|
|
42
|
-
}) }), _jsx(WithInteractions, { onOutsideClick: () => setShowDropdawn(false), children: _jsx(
|
|
54
|
+
}) }), _jsx(WithInteractions, { onOutsideClick: () => setShowDropdawn(false), children: _jsx(Card, Object.assign({ ref: dropdawnRef }, restProps, { style: Object.assign({ position: "fixed", top: top, left: left, maxWidth: "calc(100% - 4rem)", maxHeight: "min(50vh, 50rem)", zIndex: 2, visibility: showDropdawn ? "visible" : "hidden" }, style), children: dropdawnChildren })) })] }));
|
|
43
55
|
};
|
|
56
|
+
WithDropdawn.displayName = "WithDropdawn";
|
|
@@ -216,3 +216,4 @@ export const WithInteractions = forwardRef((_a, forwardedRef) => {
|
|
|
216
216
|
return null;
|
|
217
217
|
return cloneElement(children, Object.assign(Object.assign({}, restProps), { ref: mergeRefs(localRef, forwardedRef, (_b = children.props) === null || _b === void 0 ? void 0 : _b.ref) }));
|
|
218
218
|
});
|
|
219
|
+
WithInteractions.displayName = "WithInteractions";
|