@alxgrn/telefrag-ui 0.0.45 → 0.0.46
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/README.md
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
|
-
#
|
|
1
|
+
# UI-библиотека проекта [The Daily Telefrag](https://dailytelefrag.ru)
|
|
2
|
+
Документация по компонентам [тут](./docs/README.md)
|
|
3
|
+
|
|
4
|
+
Ниже просто мусор для памяти :)
|
|
5
|
+
|
|
6
|
+
## Подготовка для публикации библиотеки
|
|
2
7
|
https://dev.to/receter/how-to-create-a-react-component-library-using-vites-library-mode-4lma
|
|
3
8
|
ВНИМАНИЕ: на последней версии Vite может возникнуть ошибка `but '--jsx' is not set`.
|
|
4
9
|
Как её чинить непонятно. В интернете пишут про версии TS и т.п. Поэтому инциализировали версию vite 5.0.0 с более старыми версиями всего.
|
|
5
10
|
|
|
6
|
-
|
|
11
|
+
## Настройка тестов
|
|
7
12
|
https://deku.posstree.com/en/react/vite/react-typescript/test/
|
|
8
13
|
|
|
9
|
-
|
|
14
|
+
## React + TypeScript + Vite
|
|
10
15
|
|
|
11
16
|
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
|
|
12
17
|
|
|
@@ -15,7 +20,7 @@ Currently, two official plugins are available:
|
|
|
15
20
|
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh
|
|
16
21
|
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
|
|
17
22
|
|
|
18
|
-
|
|
23
|
+
### Expanding the ESLint configuration
|
|
19
24
|
|
|
20
25
|
If you are developing a production application, we recommend updating the configuration to enable type aware lint rules:
|
|
21
26
|
|
|
@@ -15,9 +15,9 @@ export type MenuAlternative = {
|
|
|
15
15
|
disabled?: boolean | null;
|
|
16
16
|
};
|
|
17
17
|
export type MenuItem = MenuAlternative | MenuSeparator;
|
|
18
|
-
|
|
18
|
+
type MenuProps = PopupProps & {
|
|
19
19
|
items: MenuItem[];
|
|
20
20
|
onClick: (item: MenuItem) => void;
|
|
21
|
-
}
|
|
21
|
+
};
|
|
22
22
|
export declare const Menu: React.FC<MenuProps>;
|
|
23
23
|
export default Menu;
|
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
import { FC, PropsWithChildren } from 'react';
|
|
2
|
-
export
|
|
2
|
+
export type PopupPropsPosition = {
|
|
3
|
+
x: number;
|
|
4
|
+
y: number;
|
|
5
|
+
isOpen: boolean;
|
|
6
|
+
onClose: () => void;
|
|
7
|
+
margin?: string;
|
|
8
|
+
vertical?: 'auto' | 'top' | 'bottom';
|
|
9
|
+
horizontal?: 'auto' | 'left' | 'right';
|
|
10
|
+
maxHeight?: 'auto' | 'none';
|
|
11
|
+
position?: 'absolute' | 'fixed';
|
|
12
|
+
parent?: never;
|
|
13
|
+
width?: never;
|
|
14
|
+
};
|
|
15
|
+
export type PopupPropsParent = {
|
|
16
|
+
x?: never;
|
|
17
|
+
y?: never;
|
|
3
18
|
parent: HTMLElement;
|
|
4
19
|
isOpen: boolean;
|
|
5
20
|
onClose: () => void;
|
|
@@ -9,6 +24,7 @@ export interface PopupProps {
|
|
|
9
24
|
maxHeight?: 'auto' | 'none';
|
|
10
25
|
width?: 'auto' | 'parent';
|
|
11
26
|
position?: 'absolute' | 'fixed';
|
|
12
|
-
}
|
|
27
|
+
};
|
|
28
|
+
export type PopupProps = PopupPropsPosition | PopupPropsParent;
|
|
13
29
|
export declare const Popup: FC<PropsWithChildren<PopupProps>>;
|
|
14
30
|
export default Popup;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { jsx as s } from "react/jsx-runtime";
|
|
2
|
-
import { useRef as
|
|
3
|
-
import { CSSTransition as
|
|
4
|
-
import
|
|
5
|
-
import { ANIMATION_LENGTH as
|
|
2
|
+
import { useRef as S, useState as g, useEffect as m } from "react";
|
|
3
|
+
import { CSSTransition as T } from "react-transition-group";
|
|
4
|
+
import N from "../portal/Portal.js";
|
|
5
|
+
import { ANIMATION_LENGTH as P } from "../../../config.js";
|
|
6
6
|
import '../../../assets/Popup.css';/* empty css */
|
|
7
|
-
const
|
|
7
|
+
const I = P, W = ({
|
|
8
|
+
x: k,
|
|
9
|
+
y,
|
|
8
10
|
parent: u,
|
|
9
11
|
isOpen: d,
|
|
10
12
|
onClose: c,
|
|
@@ -14,62 +16,59 @@ const N = T, M = ({
|
|
|
14
16
|
maxHeight: h = "none",
|
|
15
17
|
width: b = "auto",
|
|
16
18
|
position: l = "absolute",
|
|
17
|
-
children:
|
|
19
|
+
children: w
|
|
18
20
|
}) => {
|
|
19
|
-
const a =
|
|
21
|
+
const a = S(null), [E, x] = g({}), [v, L] = g({});
|
|
20
22
|
return m(() => {
|
|
21
23
|
if (!d) return;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
const r = document.documentElement.clientWidth, n = document.documentElement.clientHeight, e = u.getBoundingClientRect();
|
|
27
|
-
k({
|
|
24
|
+
const r = document.documentElement.clientWidth, n = document.documentElement.clientHeight;
|
|
25
|
+
let t = {};
|
|
26
|
+
u ? t = u.getBoundingClientRect() : (t.y = t.top = t.bottom = y, t.x = t.left = t.right = k, t.width = t.height = 0), L({
|
|
28
27
|
position: l,
|
|
29
|
-
top: l === "fixed" ?
|
|
30
|
-
left: l === "fixed" ?
|
|
31
|
-
width:
|
|
32
|
-
height:
|
|
28
|
+
top: l === "fixed" ? t.top : t.top + window.scrollY,
|
|
29
|
+
left: l === "fixed" ? t.left : t.left + window.scrollX,
|
|
30
|
+
width: t.width,
|
|
31
|
+
height: t.height
|
|
33
32
|
});
|
|
34
|
-
const
|
|
35
|
-
width: b === "parent" ?
|
|
33
|
+
const e = {
|
|
34
|
+
width: b === "parent" ? t.width : "auto"
|
|
36
35
|
};
|
|
37
36
|
let i = 0;
|
|
38
37
|
switch (p) {
|
|
39
38
|
case "top":
|
|
40
|
-
|
|
39
|
+
e.bottom = "100%", e.marginBottom = o, i = t.top;
|
|
41
40
|
break;
|
|
42
41
|
case "bottom":
|
|
43
|
-
|
|
42
|
+
e.top = "100%", e.marginTop = o, i = n - t.bottom;
|
|
44
43
|
break;
|
|
45
44
|
case "inner-top":
|
|
46
|
-
|
|
45
|
+
e.top = 0, i = n - t.top;
|
|
47
46
|
break;
|
|
48
47
|
case "inner-bottom":
|
|
49
|
-
|
|
48
|
+
e.bottom = 0, i = t.bottom;
|
|
50
49
|
break;
|
|
51
50
|
default:
|
|
52
|
-
|
|
51
|
+
t.top < n - t.bottom ? (e.top = "100%", e.marginTop = o, i = n - t.bottom) : (e.bottom = "100%", e.marginBottom = o, i = t.top);
|
|
53
52
|
break;
|
|
54
53
|
}
|
|
55
|
-
switch (h === "auto" && (
|
|
54
|
+
switch (h === "auto" && (e.maxHeight = `calc(${i}px - 2 * ${o})`), f) {
|
|
56
55
|
case "left":
|
|
57
|
-
|
|
56
|
+
e.right = "100%", e.marginRight = o;
|
|
58
57
|
break;
|
|
59
58
|
case "right":
|
|
60
|
-
|
|
59
|
+
e.left = "100%", e.marginLeft = o;
|
|
61
60
|
break;
|
|
62
61
|
case "inner-left":
|
|
63
|
-
|
|
62
|
+
e.left = 0;
|
|
64
63
|
break;
|
|
65
64
|
case "inner-right":
|
|
66
|
-
|
|
65
|
+
e.right = 0;
|
|
67
66
|
break;
|
|
68
67
|
default:
|
|
69
|
-
|
|
68
|
+
t.left < r - t.right ? (e.left = "100%", e.marginLeft = o) : (e.right = "100%", e.marginRight = o);
|
|
70
69
|
break;
|
|
71
70
|
}
|
|
72
|
-
|
|
71
|
+
x(e);
|
|
73
72
|
}, [u, d, o, p, f, h, b, l]), m(() => {
|
|
74
73
|
const r = (n) => {
|
|
75
74
|
a.current && !a.current.contains(n.target) && c();
|
|
@@ -84,19 +83,19 @@ const N = T, M = ({
|
|
|
84
83
|
return document.body.addEventListener("keydown", r), () => {
|
|
85
84
|
document.body.removeEventListener("keydown", r);
|
|
86
85
|
};
|
|
87
|
-
}, [c]), /* @__PURE__ */ s(
|
|
88
|
-
|
|
86
|
+
}, [c]), /* @__PURE__ */ s(N, { id: "alxgrn-popup", children: /* @__PURE__ */ s(
|
|
87
|
+
T,
|
|
89
88
|
{
|
|
90
89
|
in: d,
|
|
91
|
-
timeout:
|
|
90
|
+
timeout: I,
|
|
92
91
|
unmountOnExit: !0,
|
|
93
92
|
classNames: "Popup",
|
|
94
93
|
nodeRef: a,
|
|
95
|
-
children: /* @__PURE__ */ s("div", { className: "Popup", style:
|
|
94
|
+
children: /* @__PURE__ */ s("div", { className: "Popup", style: v, children: /* @__PURE__ */ s("div", { className: "PopupInner", ref: a, style: E, children: w }) })
|
|
96
95
|
}
|
|
97
96
|
) });
|
|
98
97
|
};
|
|
99
98
|
export {
|
|
100
|
-
|
|
101
|
-
|
|
99
|
+
W as Popup,
|
|
100
|
+
W as default
|
|
102
101
|
};
|
package/package.json
CHANGED