@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
- # React + TypeScript + Vite
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
- ## Expanding the ESLint configuration
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
- interface MenuProps extends PopupProps {
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 interface PopupProps {
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 v, useState as y, useEffect as m } from "react";
3
- import { CSSTransition as L } from "react-transition-group";
4
- import S from "../portal/Portal.js";
5
- import { ANIMATION_LENGTH as T } from "../../../config.js";
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 N = T, M = ({
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: E
19
+ children: w
18
20
  }) => {
19
- const a = v(null), [w, g] = y({}), [x, k] = y({});
21
+ const a = S(null), [E, x] = g({}), [v, L] = g({});
20
22
  return m(() => {
21
23
  if (!d) return;
22
- if (!u) {
23
- g({}), k({});
24
- return;
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" ? e.top : e.top + window.scrollY,
30
- left: l === "fixed" ? e.left : e.left + window.scrollX,
31
- width: e.width,
32
- height: e.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 t = {
35
- width: b === "parent" ? e.width : "auto"
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
- t.bottom = "100%", t.marginBottom = o, i = e.top;
39
+ e.bottom = "100%", e.marginBottom = o, i = t.top;
41
40
  break;
42
41
  case "bottom":
43
- t.top = "100%", t.marginTop = o, i = n - e.bottom;
42
+ e.top = "100%", e.marginTop = o, i = n - t.bottom;
44
43
  break;
45
44
  case "inner-top":
46
- t.top = 0, i = n - e.top;
45
+ e.top = 0, i = n - t.top;
47
46
  break;
48
47
  case "inner-bottom":
49
- t.bottom = 0, i = e.bottom;
48
+ e.bottom = 0, i = t.bottom;
50
49
  break;
51
50
  default:
52
- e.top < n - e.bottom ? (t.top = "100%", t.marginTop = o, i = n - e.bottom) : (t.bottom = "100%", t.marginBottom = o, i = e.top);
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" && (t.maxHeight = `calc(${i}px - 2 * ${o})`), f) {
54
+ switch (h === "auto" && (e.maxHeight = `calc(${i}px - 2 * ${o})`), f) {
56
55
  case "left":
57
- t.right = "100%", t.marginRight = o;
56
+ e.right = "100%", e.marginRight = o;
58
57
  break;
59
58
  case "right":
60
- t.left = "100%", t.marginLeft = o;
59
+ e.left = "100%", e.marginLeft = o;
61
60
  break;
62
61
  case "inner-left":
63
- t.left = 0;
62
+ e.left = 0;
64
63
  break;
65
64
  case "inner-right":
66
- t.right = 0;
65
+ e.right = 0;
67
66
  break;
68
67
  default:
69
- e.left < r - e.right ? (t.left = "100%", t.marginLeft = o) : (t.right = "100%", t.marginRight = o);
68
+ t.left < r - t.right ? (e.left = "100%", e.marginLeft = o) : (e.right = "100%", e.marginRight = o);
70
69
  break;
71
70
  }
72
- g(t);
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(S, { id: "alxgrn-popup", children: /* @__PURE__ */ s(
88
- L,
86
+ }, [c]), /* @__PURE__ */ s(N, { id: "alxgrn-popup", children: /* @__PURE__ */ s(
87
+ T,
89
88
  {
90
89
  in: d,
91
- timeout: N,
90
+ timeout: I,
92
91
  unmountOnExit: !0,
93
92
  classNames: "Popup",
94
93
  nodeRef: a,
95
- children: /* @__PURE__ */ s("div", { className: "Popup", style: x, children: /* @__PURE__ */ s("div", { className: "PopupInner", ref: a, style: w, children: E }) })
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
- M as Popup,
101
- M as default
99
+ W as Popup,
100
+ W as default
102
101
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@alxgrn/telefrag-ui",
3
3
  "description": "UI library for The Daily Telefrag project",
4
- "version": "0.0.45",
4
+ "version": "0.0.46",
5
5
  "private": false,
6
6
  "author": "Alexander Fedorov <alex@molner.ru>",
7
7
  "license": "Apache-2.0",