@alxgrn/telefrag-ui 0.0.1

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.
Files changed (79) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +38 -0
  3. package/dist/assets/Button.css +1 -0
  4. package/dist/assets/DatePicker.css +1 -0
  5. package/dist/assets/Editable.css +1 -0
  6. package/dist/assets/Fieldset.css +1 -0
  7. package/dist/assets/Files.css +1 -0
  8. package/dist/assets/Form.css +1 -0
  9. package/dist/assets/FormCol.css +1 -0
  10. package/dist/assets/FormRow.css +1 -0
  11. package/dist/assets/Input.css +1 -0
  12. package/dist/assets/Label.css +1 -0
  13. package/dist/assets/Menu.css +1 -0
  14. package/dist/assets/Message.css +1 -0
  15. package/dist/assets/Modal.css +1 -0
  16. package/dist/assets/Popup.css +1 -0
  17. package/dist/assets/RadioLabel.css +1 -0
  18. package/dist/assets/Select.css +1 -0
  19. package/dist/assets/Time.css +1 -0
  20. package/dist/components/button/Button.d.ts +12 -0
  21. package/dist/components/button/Button.js +14 -0
  22. package/dist/components/checkbox/Checkbox.d.ts +6 -0
  23. package/dist/components/checkbox/Checkbox.js +26 -0
  24. package/dist/components/checkbox/CheckboxList.d.ts +19 -0
  25. package/dist/components/checkbox/CheckboxList.js +48 -0
  26. package/dist/components/date/Date.d.ts +15 -0
  27. package/dist/components/date/Date.js +83 -0
  28. package/dist/components/date/DatePicker.d.ts +17 -0
  29. package/dist/components/date/DatePicker.js +58 -0
  30. package/dist/components/fieldset/Fieldset.d.ts +11 -0
  31. package/dist/components/fieldset/Fieldset.js +25 -0
  32. package/dist/components/files/Files.d.ts +17 -0
  33. package/dist/components/files/Files.js +71 -0
  34. package/dist/components/form/Form.d.ts +19 -0
  35. package/dist/components/form/Form.js +149 -0
  36. package/dist/components/form/FormCol.d.ts +3 -0
  37. package/dist/components/form/FormCol.js +6 -0
  38. package/dist/components/form/FormRow.d.ts +3 -0
  39. package/dist/components/form/FormRow.js +6 -0
  40. package/dist/components/hidden/Hidden.d.ts +7 -0
  41. package/dist/components/hidden/Hidden.js +12 -0
  42. package/dist/components/input/Input.d.ts +18 -0
  43. package/dist/components/input/Input.js +69 -0
  44. package/dist/components/label/Label.d.ts +11 -0
  45. package/dist/components/label/Label.js +25 -0
  46. package/dist/components/radio/Radio.d.ts +22 -0
  47. package/dist/components/radio/Radio.js +37 -0
  48. package/dist/components/radio/RadioLabel.d.ts +11 -0
  49. package/dist/components/radio/RadioLabel.js +27 -0
  50. package/dist/components/radio/RadioList.d.ts +23 -0
  51. package/dist/components/radio/RadioList.js +36 -0
  52. package/dist/components/required/RequiredMark.d.ts +6 -0
  53. package/dist/components/required/RequiredMark.js +5 -0
  54. package/dist/components/select/Select.d.ts +20 -0
  55. package/dist/components/select/Select.js +61 -0
  56. package/dist/components/time/Time.d.ts +17 -0
  57. package/dist/components/time/Time.js +112 -0
  58. package/dist/components/ui/alert/Alert.d.ts +15 -0
  59. package/dist/components/ui/alert/Alert.js +26 -0
  60. package/dist/components/ui/confirm/Confirm.d.ts +18 -0
  61. package/dist/components/ui/confirm/Confirm.js +41 -0
  62. package/dist/components/ui/editable/Editable.d.ts +12 -0
  63. package/dist/components/ui/editable/Editable.js +53 -0
  64. package/dist/components/ui/info/Info.js +8 -0
  65. package/dist/components/ui/menu/Menu.d.ts +23 -0
  66. package/dist/components/ui/menu/Menu.js +23 -0
  67. package/dist/components/ui/message/Message.d.ts +10 -0
  68. package/dist/components/ui/message/Message.js +19 -0
  69. package/dist/components/ui/modal/Modal.d.ts +8 -0
  70. package/dist/components/ui/modal/Modal.js +39 -0
  71. package/dist/components/ui/popup/Popup.d.ts +14 -0
  72. package/dist/components/ui/popup/Popup.js +100 -0
  73. package/dist/components/ui/portal/Portal.d.ts +7 -0
  74. package/dist/components/ui/portal/Portal.js +20 -0
  75. package/dist/components/ui/prompt/Prompt.d.ts +16 -0
  76. package/dist/components/ui/prompt/Prompt.js +48 -0
  77. package/dist/main.d.ts +27 -0
  78. package/dist/main.js +52 -0
  79. package/package.json +53 -0
@@ -0,0 +1,100 @@
1
+ import { jsx as a } from "react/jsx-runtime";
2
+ import { useRef as v, useState as y, useEffect as m } from "react";
3
+ import { CSSTransition as S } from "react-transition-group";
4
+ import L from "../portal/Portal.js";
5
+ import '../../../assets/Popup.css';const P = 100, I = ({
6
+ parent: s,
7
+ isOpen: d,
8
+ onClose: i,
9
+ vertical: p = "auto",
10
+ horizontal: f = "auto",
11
+ margin: o = "0",
12
+ maxHeight: h = "none",
13
+ width: b = "auto",
14
+ position: l = "absolute",
15
+ children: w
16
+ }) => {
17
+ const u = v(null), [E, g] = y({}), [x, k] = y({});
18
+ return m(() => {
19
+ if (!d) return;
20
+ if (!s.current) {
21
+ g({}), k({});
22
+ return;
23
+ }
24
+ const r = document.documentElement.clientWidth, n = document.documentElement.clientHeight, e = s.current.getBoundingClientRect();
25
+ k({
26
+ position: l,
27
+ top: l === "fixed" ? e.top : e.top + window.scrollY,
28
+ left: l === "fixed" ? e.left : e.left + window.scrollX,
29
+ width: e.width,
30
+ height: e.height
31
+ });
32
+ const t = {
33
+ width: b === "parent" ? e.width : "auto"
34
+ };
35
+ let c = 0;
36
+ switch (p) {
37
+ case "top":
38
+ t.bottom = "100%", t.marginBottom = o, c = e.top;
39
+ break;
40
+ case "bottom":
41
+ t.top = "100%", t.marginTop = o, c = n - e.bottom;
42
+ break;
43
+ case "inner-top":
44
+ t.top = 0, c = n - e.top;
45
+ break;
46
+ case "inner-bottom":
47
+ t.bottom = 0, c = e.bottom;
48
+ break;
49
+ default:
50
+ e.top < n - e.bottom ? (t.top = "100%", t.marginTop = o, c = n - e.bottom) : (t.bottom = "100%", t.marginBottom = o, c = e.top);
51
+ break;
52
+ }
53
+ switch (h === "auto" && (t.maxHeight = `calc(${c}px - 2 * ${o})`), f) {
54
+ case "left":
55
+ t.right = "100%", t.marginRight = o;
56
+ break;
57
+ case "right":
58
+ t.left = "100%", t.marginLeft = o;
59
+ break;
60
+ case "inner-left":
61
+ t.left = 0;
62
+ break;
63
+ case "inner-right":
64
+ t.right = 0;
65
+ break;
66
+ default:
67
+ e.left < r - e.right ? (t.left = "100%", t.marginLeft = o) : (t.right = "100%", t.marginRight = o);
68
+ break;
69
+ }
70
+ g(t);
71
+ }, [s, d, o, p, f, h, b, l]), m(() => {
72
+ const r = (n) => {
73
+ u.current && !u.current.contains(n.target) && i();
74
+ };
75
+ return document.addEventListener("click", r, !0), () => {
76
+ document.removeEventListener("click", r, !0);
77
+ };
78
+ }, [i]), m(() => {
79
+ const r = (n) => {
80
+ n.key === "Escape" && i();
81
+ };
82
+ return document.body.addEventListener("keydown", r), () => {
83
+ document.body.removeEventListener("keydown", r);
84
+ };
85
+ }, [i]), /* @__PURE__ */ a(L, { id: "alxgrn-popup", children: /* @__PURE__ */ a(
86
+ S,
87
+ {
88
+ in: d,
89
+ timeout: P,
90
+ unmountOnExit: !0,
91
+ classNames: "Popup",
92
+ nodeRef: u,
93
+ children: /* @__PURE__ */ a("div", { className: "Popup", style: x, children: /* @__PURE__ */ a("div", { className: "PopupInner", ref: u, style: E, children: w }) })
94
+ }
95
+ ) });
96
+ };
97
+ export {
98
+ I as Popup,
99
+ I as default
100
+ };
@@ -0,0 +1,7 @@
1
+ import { default as React } from 'react';
2
+ export type PortalProps = {
3
+ id: string;
4
+ fixBody?: boolean;
5
+ };
6
+ declare const Portal: React.FC<React.PropsWithChildren<PortalProps>>;
7
+ export default Portal;
@@ -0,0 +1,20 @@
1
+ import { createPortal as n } from "react-dom";
2
+ const i = ({ id: t, fixBody: o, children: d }) => {
3
+ let e = document.getElementById(t);
4
+ return e || (e = document.createElement("div"), e.setAttribute("id", t), document.body.append(e), o && new MutationObserver(() => {
5
+ var s = (e == null ? void 0 : e.innerHTML) === "";
6
+ s ? l() : r();
7
+ }).observe(e, {
8
+ childList: !0
9
+ // наблюдать за непосредственными детьми
10
+ })), n(d, e);
11
+ }, r = () => {
12
+ const t = `-${window.scrollY}px`;
13
+ document.body.style.position = "fixed", document.body.style.top = t, document.body.style.left = "0px", document.body.style.right = "0px";
14
+ }, l = () => {
15
+ const t = document.body.style.top;
16
+ document.body.style.position = "", document.body.style.top = "", document.body.style.left = "", document.body.style.right = "", window.scrollTo(0, parseInt(t || "0") * -1);
17
+ };
18
+ export {
19
+ i as default
20
+ };
@@ -0,0 +1,16 @@
1
+ import { default as React, FC } from 'react';
2
+ import { ButtonType } from '../../button/Button';
3
+ export interface PromptProps {
4
+ value?: string | null;
5
+ title?: string | null;
6
+ top?: string | null | React.ReactNode;
7
+ bottom?: string | null | React.ReactNode;
8
+ limit?: number | null;
9
+ isOpen: boolean;
10
+ submit?: string | null;
11
+ submitType?: ButtonType;
12
+ onCancel: () => void;
13
+ onSubmit: (value: string) => void;
14
+ }
15
+ declare const Prompt: FC<PromptProps>;
16
+ export default Prompt;
@@ -0,0 +1,48 @@
1
+ import { jsxs as d, jsx as r } from "react/jsx-runtime";
2
+ import { useState as p, useEffect as h } from "react";
3
+ import x from "../modal/Modal.js";
4
+ import { Form as b } from "../../form/Form.js";
5
+ import j from "../../input/Input.js";
6
+ const g = ({
7
+ value: o,
8
+ title: e,
9
+ top: n,
10
+ bottom: i,
11
+ limit: s,
12
+ submit: a,
13
+ submitType: f,
14
+ isOpen: t,
15
+ onCancel: l,
16
+ onSubmit: c
17
+ }) => {
18
+ const [u, m] = p("");
19
+ return h(() => {
20
+ m(o ?? "");
21
+ }, [o, t]), /* @__PURE__ */ d(x, { isOpen: t, onClose: l, children: [
22
+ e && /* @__PURE__ */ r("h1", { children: e }),
23
+ /* @__PURE__ */ r(
24
+ b,
25
+ {
26
+ submit: a ?? "Ok",
27
+ submitType: f,
28
+ onSubmit: () => c(u),
29
+ children: /* @__PURE__ */ r(
30
+ j,
31
+ {
32
+ id: "value",
33
+ required: !0,
34
+ value: u,
35
+ onChange: m,
36
+ limit: s,
37
+ top: n,
38
+ bottom: i,
39
+ autoFocus: !0
40
+ }
41
+ )
42
+ }
43
+ )
44
+ ] });
45
+ };
46
+ export {
47
+ g as default
48
+ };
package/dist/main.d.ts ADDED
@@ -0,0 +1,27 @@
1
+ import { Form, FormData } from './components/form/Form';
2
+ import { default as Date } from './components/date/Date';
3
+ import { default as Time } from './components/time/Time';
4
+ import { default as Files } from './components/files/Files';
5
+ import { default as Input } from './components/input/Input';
6
+ import { default as Label } from './components/label/Label';
7
+ import { default as RadioList } from './components/radio/RadioList';
8
+ import { default as Button } from './components/button/Button';
9
+ import { default as Select } from './components/select/Select';
10
+ import { default as Hidden } from './components/hidden/Hidden';
11
+ import { default as Checkbox } from './components/checkbox/Checkbox';
12
+ import { default as CheckboxList } from './components/checkbox/CheckboxList';
13
+ import { default as Fieldset } from './components/fieldset/Fieldset';
14
+ import { default as FormRow } from './components/form/FormRow';
15
+ import { default as FormCol } from './components/form/FormCol';
16
+ import { default as DatePicker } from './components/date/DatePicker';
17
+ import { Menu, MenuItem } from './components/ui/menu/Menu';
18
+ import { default as Modal } from './components/ui/modal/Modal';
19
+ import { default as Popup } from './components/ui/popup/Popup';
20
+ import { default as Portal } from './components/ui/portal/Portal';
21
+ import { default as Message } from './components/ui/message/Message';
22
+ import { default as Alert } from './components/ui/alert/Alert';
23
+ import { default as Confirm } from './components/ui/confirm/Confirm';
24
+ import { default as Prompt } from './components/ui/prompt/Prompt';
25
+ import { default as Editable } from './components/ui/editable/Editable';
26
+ export { Form, Date, Time, Files, Input, Label, RadioList, Button, Select, Hidden, Checkbox, CheckboxList, Fieldset, FormRow, FormCol, DatePicker, Menu, Modal, Popup, Portal, Message, Alert, Confirm, Prompt, Editable, };
27
+ export type { FormData, MenuItem, };
package/dist/main.js ADDED
@@ -0,0 +1,52 @@
1
+ import { Form as r } from "./components/form/Form.js";
2
+ import { default as a } from "./components/date/Date.js";
3
+ import { default as m } from "./components/time/Time.js";
4
+ import { Files as l } from "./components/files/Files.js";
5
+ import { default as d } from "./components/input/Input.js";
6
+ import { default as u } from "./components/label/Label.js";
7
+ import { RadioList as n } from "./components/radio/RadioList.js";
8
+ import { default as b } from "./components/button/Button.js";
9
+ import { Select as C } from "./components/select/Select.js";
10
+ import { default as k } from "./components/hidden/Hidden.js";
11
+ import { default as M } from "./components/checkbox/Checkbox.js";
12
+ import { CheckboxList as D } from "./components/checkbox/CheckboxList.js";
13
+ import { default as g } from "./components/fieldset/Fieldset.js";
14
+ import { default as A } from "./components/form/FormRow.js";
15
+ import { default as E } from "./components/form/FormCol.js";
16
+ import { default as I } from "./components/date/DatePicker.js";
17
+ import { Menu as T } from "./components/ui/menu/Menu.js";
18
+ import { default as q } from "./components/ui/modal/Modal.js";
19
+ import { Popup as y } from "./components/ui/popup/Popup.js";
20
+ import { default as G } from "./components/ui/portal/Portal.js";
21
+ import { default as K } from "./components/ui/message/Message.js";
22
+ import { default as O } from "./components/ui/alert/Alert.js";
23
+ import { default as U } from "./components/ui/confirm/Confirm.js";
24
+ import { default as W } from "./components/ui/prompt/Prompt.js";
25
+ import { default as Y } from "./components/ui/editable/Editable.js";
26
+ export {
27
+ O as Alert,
28
+ b as Button,
29
+ M as Checkbox,
30
+ D as CheckboxList,
31
+ U as Confirm,
32
+ a as Date,
33
+ I as DatePicker,
34
+ Y as Editable,
35
+ g as Fieldset,
36
+ l as Files,
37
+ r as Form,
38
+ E as FormCol,
39
+ A as FormRow,
40
+ k as Hidden,
41
+ d as Input,
42
+ u as Label,
43
+ T as Menu,
44
+ K as Message,
45
+ q as Modal,
46
+ y as Popup,
47
+ G as Portal,
48
+ W as Prompt,
49
+ n as RadioList,
50
+ C as Select,
51
+ m as Time
52
+ };
package/package.json ADDED
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": "@alxgrn/telefrag-ui",
3
+ "description": "UI library for The Daily Telefrag project",
4
+ "version": "0.0.1",
5
+ "private": false,
6
+ "author": "Alexander Fedorov <alex@molner.ru>",
7
+ "license": "Apache-2.0",
8
+ "keywords": [
9
+ "react",
10
+ "components",
11
+ "ui",
12
+ "telefrag"
13
+ ],
14
+ "type": "module",
15
+ "main": "dist/main.js",
16
+ "types": "dist/main.d.ts",
17
+ "files": [
18
+ "dist"
19
+ ],
20
+ "sideEffects": [
21
+ "**/*.css"
22
+ ],
23
+ "scripts": {
24
+ "dev": "vite",
25
+ "build": "tsc --p ./tsconfig.build.json && vite build",
26
+ "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
27
+ "preview": "vite preview",
28
+ "prepublishOnly": "npm run build"
29
+ },
30
+ "peerDependencies": {
31
+ "react": "^18.2.0",
32
+ "react-children-utilities": "^2.10.0",
33
+ "react-dom": "^18.2.0",
34
+ "react-transition-group": "^4.4.5"
35
+ },
36
+ "devDependencies": {
37
+ "@types/node": "^22.7.5",
38
+ "@types/react": "^18.2.37",
39
+ "@types/react-dom": "^18.2.15",
40
+ "@types/react-transition-group": "^4.4.11",
41
+ "@typescript-eslint/eslint-plugin": "^6.10.0",
42
+ "@typescript-eslint/parser": "^6.10.0",
43
+ "@vitejs/plugin-react": "^4.2.0",
44
+ "eslint": "^8.53.0",
45
+ "eslint-plugin-react-hooks": "^4.6.0",
46
+ "eslint-plugin-react-refresh": "^0.4.4",
47
+ "glob": "^11.0.0",
48
+ "typescript": "^5.2.2",
49
+ "vite": "^5.0.0",
50
+ "vite-plugin-dts": "^4.2.4",
51
+ "vite-plugin-lib-inject-css": "^2.1.1"
52
+ }
53
+ }