mimir-ui-kit 1.38.1 → 1.38.2
Sign up to get free protection for your applications and to get access to all the features.
@@ -1,19 +1,19 @@
|
|
1
|
-
import { useRef as x, useEffect as
|
2
|
-
import { BLOCK_WIDTH as
|
3
|
-
const H = (
|
1
|
+
import { useRef as x, useEffect as w } from "react";
|
2
|
+
import { BLOCK_WIDTH as r } from "./constants.js";
|
3
|
+
const H = (a) => {
|
4
4
|
const t = x(null);
|
5
|
-
return
|
6
|
-
var o,
|
7
|
-
const
|
5
|
+
return w(() => {
|
6
|
+
var o, c, s, l, u, p;
|
7
|
+
const d = window.innerHeight, h = window.innerWidth;
|
8
8
|
if (t.current !== null) {
|
9
|
-
const
|
10
|
-
if (h < n.
|
11
|
-
const e =
|
12
|
-
n.x - e < 0 ? t.current.style.left = (e < 0 ? e / 2 : e) + "px" : t.current.style.left =
|
9
|
+
const y = ((c = (o = t == null ? void 0 : t.current) == null ? void 0 : o.parentElement) == null ? void 0 : c.offsetWidth) ?? 0, f = ((l = (s = t == null ? void 0 : t.current) == null ? void 0 : s.parentElement) == null ? void 0 : l.offsetHeight) ?? 0, n = (p = (u = t == null ? void 0 : t.current) == null ? void 0 : u.parentElement) == null ? void 0 : p.getBoundingClientRect(), i = t.current.offsetHeight;
|
10
|
+
if (h < n.x + r) {
|
11
|
+
const e = y - r;
|
12
|
+
n.x - Math.abs(e) < 0 ? t.current.style.left = (e < 0 ? e / 2 : e) + "px" : t.current.style.left = e + "px";
|
13
13
|
}
|
14
|
-
t.current.style.opacity = "1";
|
14
|
+
d < n.y + i + f ? n.y - i > 0 ? t.current.style.top = -i + "px" : (t.current.style.position = "fixed", t.current.style.top = `calc(50vh - ${i / 2}px)`, t.current.style.left = `calc(50vw - ${r / 2}px)`) : t.current.style.top = f + "px", t.current.style.opacity = "1";
|
15
15
|
}
|
16
|
-
}, [
|
16
|
+
}, [a]), t;
|
17
17
|
};
|
18
18
|
export {
|
19
19
|
H as useDatePickerPosition
|