@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.
- package/LICENSE +201 -0
- package/README.md +38 -0
- package/dist/assets/Button.css +1 -0
- package/dist/assets/DatePicker.css +1 -0
- package/dist/assets/Editable.css +1 -0
- package/dist/assets/Fieldset.css +1 -0
- package/dist/assets/Files.css +1 -0
- package/dist/assets/Form.css +1 -0
- package/dist/assets/FormCol.css +1 -0
- package/dist/assets/FormRow.css +1 -0
- package/dist/assets/Input.css +1 -0
- package/dist/assets/Label.css +1 -0
- package/dist/assets/Menu.css +1 -0
- package/dist/assets/Message.css +1 -0
- package/dist/assets/Modal.css +1 -0
- package/dist/assets/Popup.css +1 -0
- package/dist/assets/RadioLabel.css +1 -0
- package/dist/assets/Select.css +1 -0
- package/dist/assets/Time.css +1 -0
- package/dist/components/button/Button.d.ts +12 -0
- package/dist/components/button/Button.js +14 -0
- package/dist/components/checkbox/Checkbox.d.ts +6 -0
- package/dist/components/checkbox/Checkbox.js +26 -0
- package/dist/components/checkbox/CheckboxList.d.ts +19 -0
- package/dist/components/checkbox/CheckboxList.js +48 -0
- package/dist/components/date/Date.d.ts +15 -0
- package/dist/components/date/Date.js +83 -0
- package/dist/components/date/DatePicker.d.ts +17 -0
- package/dist/components/date/DatePicker.js +58 -0
- package/dist/components/fieldset/Fieldset.d.ts +11 -0
- package/dist/components/fieldset/Fieldset.js +25 -0
- package/dist/components/files/Files.d.ts +17 -0
- package/dist/components/files/Files.js +71 -0
- package/dist/components/form/Form.d.ts +19 -0
- package/dist/components/form/Form.js +149 -0
- package/dist/components/form/FormCol.d.ts +3 -0
- package/dist/components/form/FormCol.js +6 -0
- package/dist/components/form/FormRow.d.ts +3 -0
- package/dist/components/form/FormRow.js +6 -0
- package/dist/components/hidden/Hidden.d.ts +7 -0
- package/dist/components/hidden/Hidden.js +12 -0
- package/dist/components/input/Input.d.ts +18 -0
- package/dist/components/input/Input.js +69 -0
- package/dist/components/label/Label.d.ts +11 -0
- package/dist/components/label/Label.js +25 -0
- package/dist/components/radio/Radio.d.ts +22 -0
- package/dist/components/radio/Radio.js +37 -0
- package/dist/components/radio/RadioLabel.d.ts +11 -0
- package/dist/components/radio/RadioLabel.js +27 -0
- package/dist/components/radio/RadioList.d.ts +23 -0
- package/dist/components/radio/RadioList.js +36 -0
- package/dist/components/required/RequiredMark.d.ts +6 -0
- package/dist/components/required/RequiredMark.js +5 -0
- package/dist/components/select/Select.d.ts +20 -0
- package/dist/components/select/Select.js +61 -0
- package/dist/components/time/Time.d.ts +17 -0
- package/dist/components/time/Time.js +112 -0
- package/dist/components/ui/alert/Alert.d.ts +15 -0
- package/dist/components/ui/alert/Alert.js +26 -0
- package/dist/components/ui/confirm/Confirm.d.ts +18 -0
- package/dist/components/ui/confirm/Confirm.js +41 -0
- package/dist/components/ui/editable/Editable.d.ts +12 -0
- package/dist/components/ui/editable/Editable.js +53 -0
- package/dist/components/ui/info/Info.js +8 -0
- package/dist/components/ui/menu/Menu.d.ts +23 -0
- package/dist/components/ui/menu/Menu.js +23 -0
- package/dist/components/ui/message/Message.d.ts +10 -0
- package/dist/components/ui/message/Message.js +19 -0
- package/dist/components/ui/modal/Modal.d.ts +8 -0
- package/dist/components/ui/modal/Modal.js +39 -0
- package/dist/components/ui/popup/Popup.d.ts +14 -0
- package/dist/components/ui/popup/Popup.js +100 -0
- package/dist/components/ui/portal/Portal.d.ts +7 -0
- package/dist/components/ui/portal/Portal.js +20 -0
- package/dist/components/ui/prompt/Prompt.d.ts +16 -0
- package/dist/components/ui/prompt/Prompt.js +48 -0
- package/dist/main.d.ts +27 -0
- package/dist/main.js +52 -0
- package/package.json +53 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { jsxs as u, jsx as c } from "react/jsx-runtime";
|
|
2
|
+
import { useState as m, useEffect as y } from "react";
|
|
3
|
+
import '../../assets/DatePicker.css';const q = ({ year: o, month: i, day: l, onChange: N }) => {
|
|
4
|
+
const v = L(), f = /* @__PURE__ */ new Date(), D = f.getDate(), d = f.getMonth(), h = f.getFullYear(), [a, p] = m(h), [r, g] = m(d), [Y, x] = m([]), [C, k] = m(0), [S, M] = m(0), [w, F] = m(0);
|
|
5
|
+
y(() => {
|
|
6
|
+
let e = o, t = i, n = l;
|
|
7
|
+
typeof e == "string" && (e = parseInt(e)), typeof t == "string" && (t = parseInt(t)), typeof n == "string" && (n = parseInt(n)), e !== void 0 && isNaN(e) && (e = h), t !== void 0 && isNaN(t) && (t = d), n !== void 0 && isNaN(n) && (n = D);
|
|
8
|
+
const s = new Date(e ?? h, t ? t - 1 : d, n ?? D);
|
|
9
|
+
p(s.getFullYear()), g(s.getMonth()), k(s.getDate()), M(s.getMonth()), F(s.getFullYear());
|
|
10
|
+
}, [o, i, l, h, d, D]), y(() => {
|
|
11
|
+
const e = E(r, a);
|
|
12
|
+
let t = new Date(a, r, 1).getDay();
|
|
13
|
+
t === 0 && (t = 7);
|
|
14
|
+
const n = [];
|
|
15
|
+
for (let s = 1; s < t; s++) n.push(0);
|
|
16
|
+
for (let s = 1; s <= e; s++) n.push(s);
|
|
17
|
+
x(n);
|
|
18
|
+
}, [r, a]);
|
|
19
|
+
const P = (e) => {
|
|
20
|
+
let t = r + e;
|
|
21
|
+
t < 0 && (t = 11), t > 11 && (t = 0), g(t);
|
|
22
|
+
}, I = (e) => {
|
|
23
|
+
e && (k(e), M(r), F(a), N && N({ day: e, month: r + 1, year: a }));
|
|
24
|
+
}, j = (e) => {
|
|
25
|
+
if (!e) return "Empty";
|
|
26
|
+
if (e === C && r === S && a === w) return "Selected";
|
|
27
|
+
if (e === D && r === d && a === h) return "Current";
|
|
28
|
+
};
|
|
29
|
+
return /* @__PURE__ */ u("div", { className: "FormDatePicker", children: [
|
|
30
|
+
/* @__PURE__ */ u("div", { className: "FormDatePickerMenu", children: [
|
|
31
|
+
/* @__PURE__ */ c("span", { className: "FormDatePickerPrev", onClick: () => P(-1), children: "«" }),
|
|
32
|
+
/* @__PURE__ */ c("span", { className: "FormDatePickerText", children: v[r] }),
|
|
33
|
+
/* @__PURE__ */ c("span", { className: "FormDatePickerNext", onClick: () => P(1), children: "»" })
|
|
34
|
+
] }),
|
|
35
|
+
/* @__PURE__ */ c("div", { className: "FormDatePickerDays", children: Y.map((e, t) => /* @__PURE__ */ c(
|
|
36
|
+
"span",
|
|
37
|
+
{
|
|
38
|
+
className: j(e),
|
|
39
|
+
onClick: () => I(e),
|
|
40
|
+
children: e || ""
|
|
41
|
+
},
|
|
42
|
+
t
|
|
43
|
+
)) }),
|
|
44
|
+
/* @__PURE__ */ u("div", { className: "FormDatePickerMenu", children: [
|
|
45
|
+
/* @__PURE__ */ c("span", { className: "FormDatePickerPrev", onClick: () => p(a - 1), children: "«" }),
|
|
46
|
+
/* @__PURE__ */ c("span", { className: "FormDatePickerText", children: a }),
|
|
47
|
+
/* @__PURE__ */ c("span", { className: "FormDatePickerNext", onClick: () => p(a + 1), children: "»" })
|
|
48
|
+
] })
|
|
49
|
+
] });
|
|
50
|
+
}, E = (o, i) => new Date(i, o + 1, 0).getDate(), L = () => {
|
|
51
|
+
let o = new Date(2e3, 0), i = [];
|
|
52
|
+
for (let l = 0; l < 12; l++)
|
|
53
|
+
i.push(o.toLocaleString("default", { month: "long" })), o.setMonth(l + 1);
|
|
54
|
+
return i;
|
|
55
|
+
};
|
|
56
|
+
export {
|
|
57
|
+
q as default
|
|
58
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { default as React, FC, PropsWithChildren } from 'react';
|
|
2
|
+
export type FieldsetProps = {
|
|
3
|
+
top?: string | null | React.ReactNode;
|
|
4
|
+
bottom?: string | null | React.ReactNode;
|
|
5
|
+
label?: string | null;
|
|
6
|
+
error?: boolean | null;
|
|
7
|
+
disabled?: boolean | null;
|
|
8
|
+
required?: boolean | null;
|
|
9
|
+
};
|
|
10
|
+
declare const Fieldset: FC<PropsWithChildren<FieldsetProps>>;
|
|
11
|
+
export default Fieldset;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { jsxs as i, jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import t from "../required/RequiredMark.js";
|
|
3
|
+
import '../../assets/Fieldset.css';const h = ({
|
|
4
|
+
label: a,
|
|
5
|
+
top: r,
|
|
6
|
+
bottom: l,
|
|
7
|
+
required: c = !1,
|
|
8
|
+
error: d = !1,
|
|
9
|
+
disabled: n = !1,
|
|
10
|
+
children: m
|
|
11
|
+
}) => /* @__PURE__ */ i("div", { className: (() => {
|
|
12
|
+
let s = "Fieldset";
|
|
13
|
+
return d && (s += " Error"), n && (s += " Disabled"), s;
|
|
14
|
+
})(), children: [
|
|
15
|
+
a && /* @__PURE__ */ i("div", { className: "Label", children: [
|
|
16
|
+
/* @__PURE__ */ e(t, { required: c }),
|
|
17
|
+
/* @__PURE__ */ e("span", { children: a })
|
|
18
|
+
] }),
|
|
19
|
+
r && /* @__PURE__ */ e("div", { className: "Top", children: r }),
|
|
20
|
+
/* @__PURE__ */ e("div", { className: "Inner", children: m }),
|
|
21
|
+
l && /* @__PURE__ */ e("div", { className: "Bottom", children: l })
|
|
22
|
+
] });
|
|
23
|
+
export {
|
|
24
|
+
h as default
|
|
25
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { default as React, FC } from 'react';
|
|
2
|
+
export interface FilesProps {
|
|
3
|
+
id: string;
|
|
4
|
+
files: File[];
|
|
5
|
+
onChange: (files: File[]) => void;
|
|
6
|
+
label?: string | null;
|
|
7
|
+
text: string | null | React.ReactNode;
|
|
8
|
+
top?: string | null | React.ReactNode;
|
|
9
|
+
bottom?: string | null | React.ReactNode;
|
|
10
|
+
accept?: string | null;
|
|
11
|
+
multiple?: boolean | null;
|
|
12
|
+
required?: boolean | null;
|
|
13
|
+
disabled?: boolean | null;
|
|
14
|
+
}
|
|
15
|
+
export declare const bytes2string: (bytes: number) => string;
|
|
16
|
+
export declare const Files: FC<FilesProps>;
|
|
17
|
+
export default Files;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { jsxs as i, jsx as l } from "react/jsx-runtime";
|
|
2
|
+
import { useState as L, useEffect as M } from "react";
|
|
3
|
+
import $ from "../fieldset/Fieldset.js";
|
|
4
|
+
import '../../assets/Files.css';const h = (t) => t > 1024 * 1024 ? Math.round(t / (1024 * 1024)) + " Mb" : t > 1024 ? Math.round(t / 1024) + " Kb" : t + " bytes", D = ({
|
|
5
|
+
id: t,
|
|
6
|
+
files: n,
|
|
7
|
+
onChange: c,
|
|
8
|
+
label: m,
|
|
9
|
+
text: p,
|
|
10
|
+
top: d,
|
|
11
|
+
bottom: g,
|
|
12
|
+
accept: F,
|
|
13
|
+
multiple: v = !1,
|
|
14
|
+
required: o = !1,
|
|
15
|
+
disabled: s = !1
|
|
16
|
+
}) => {
|
|
17
|
+
const [f, u] = L(!1);
|
|
18
|
+
M(() => {
|
|
19
|
+
o && n.length < 1 ? u(!0) : u(!1);
|
|
20
|
+
}, [n, o]);
|
|
21
|
+
const x = () => {
|
|
22
|
+
const e = n.reduce((r, a) => r += a.size, 0);
|
|
23
|
+
return e ? h(e) : "";
|
|
24
|
+
}, z = (e) => {
|
|
25
|
+
if (s) return;
|
|
26
|
+
const r = [...n];
|
|
27
|
+
r.splice(e, 1), c(r);
|
|
28
|
+
}, E = (e) => {
|
|
29
|
+
const r = e.target, a = Array.from(r.files);
|
|
30
|
+
c(a);
|
|
31
|
+
};
|
|
32
|
+
return /* @__PURE__ */ i(
|
|
33
|
+
$,
|
|
34
|
+
{
|
|
35
|
+
label: m,
|
|
36
|
+
error: f,
|
|
37
|
+
disabled: s,
|
|
38
|
+
required: o,
|
|
39
|
+
top: d,
|
|
40
|
+
bottom: g,
|
|
41
|
+
children: [
|
|
42
|
+
n.length > 0 && /* @__PURE__ */ l("ul", { className: `FileList ${s ? "Disabled" : ""}`, children: n.map((e, r) => /* @__PURE__ */ l("li", { onClick: () => z(r), children: /* @__PURE__ */ i("div", { children: [
|
|
43
|
+
/* @__PURE__ */ l("span", { children: e.name }),
|
|
44
|
+
/* @__PURE__ */ l("span", { children: h(e.size) })
|
|
45
|
+
] }) }, r)) }),
|
|
46
|
+
/* @__PURE__ */ i("div", { className: `FileLabel ${s ? "Disabled" : ""} ${f ? "Error" : ""}`, children: [
|
|
47
|
+
/* @__PURE__ */ i("label", { children: [
|
|
48
|
+
p,
|
|
49
|
+
/* @__PURE__ */ l(
|
|
50
|
+
"input",
|
|
51
|
+
{
|
|
52
|
+
id: t,
|
|
53
|
+
type: "file",
|
|
54
|
+
accept: F ?? void 0,
|
|
55
|
+
onChange: (e) => E(e),
|
|
56
|
+
multiple: v ?? void 0,
|
|
57
|
+
disabled: !!s
|
|
58
|
+
}
|
|
59
|
+
)
|
|
60
|
+
] }),
|
|
61
|
+
/* @__PURE__ */ l("span", { children: x() })
|
|
62
|
+
] })
|
|
63
|
+
]
|
|
64
|
+
}
|
|
65
|
+
);
|
|
66
|
+
};
|
|
67
|
+
export {
|
|
68
|
+
D as Files,
|
|
69
|
+
h as bytes2string,
|
|
70
|
+
D as default
|
|
71
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { default as React, PropsWithChildren } from 'react';
|
|
2
|
+
import { ButtonType } from '../button/Button';
|
|
3
|
+
export type FormProps = {
|
|
4
|
+
info?: string | null;
|
|
5
|
+
error?: string | null;
|
|
6
|
+
success?: string | null;
|
|
7
|
+
submit?: string | null;
|
|
8
|
+
cancel?: string | null;
|
|
9
|
+
submitType?: ButtonType;
|
|
10
|
+
cancelType?: ButtonType;
|
|
11
|
+
wide?: boolean | null;
|
|
12
|
+
onSubmit?: (d: FormData) => void;
|
|
13
|
+
onCancel?: () => void;
|
|
14
|
+
};
|
|
15
|
+
export type FormData = {
|
|
16
|
+
[i: string]: string | number | boolean | File[] | any[];
|
|
17
|
+
};
|
|
18
|
+
export declare const Form: React.FC<PropsWithChildren<FormProps>>;
|
|
19
|
+
export default Form;
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { jsxs as b, jsx as c } from "react/jsx-runtime";
|
|
2
|
+
import { useState as L, useEffect as g } from "react";
|
|
3
|
+
import { deepForEach as h } from "react-children-utilities";
|
|
4
|
+
import F, { isValidDate as q } from "../date/Date.js";
|
|
5
|
+
import y from "../button/Button.js";
|
|
6
|
+
import H from "../time/Time.js";
|
|
7
|
+
import { Files as x } from "../files/Files.js";
|
|
8
|
+
import C from "../input/Input.js";
|
|
9
|
+
import "../label/Label.js";
|
|
10
|
+
import { RadioList as E } from "../radio/RadioList.js";
|
|
11
|
+
import { Select as I } from "../select/Select.js";
|
|
12
|
+
import R from "../hidden/Hidden.js";
|
|
13
|
+
import N from "../checkbox/Checkbox.js";
|
|
14
|
+
import { CheckboxList as D } from "../checkbox/CheckboxList.js";
|
|
15
|
+
import "../fieldset/Fieldset.js";
|
|
16
|
+
import '../../assets/Editable.css';import '../../assets/Message.css';import '../../assets/Modal.css';import '../../assets/FormCol.css';import '../../assets/FormRow.css';import '../../assets/Form.css';/* empty css */
|
|
17
|
+
/* empty css */
|
|
18
|
+
import "../date/DatePicker.js";
|
|
19
|
+
import "react-transition-group";
|
|
20
|
+
import "react-dom";
|
|
21
|
+
import "../ui/popup/Popup.js";
|
|
22
|
+
import "../ui/menu/Menu.js";
|
|
23
|
+
/* empty css */
|
|
24
|
+
/* empty css */
|
|
25
|
+
/* empty css */
|
|
26
|
+
const pe = ({
|
|
27
|
+
info: l,
|
|
28
|
+
error: u,
|
|
29
|
+
success: d,
|
|
30
|
+
submit: n,
|
|
31
|
+
cancel: f,
|
|
32
|
+
submitType: S = "Accent",
|
|
33
|
+
cancelType: j = "Error",
|
|
34
|
+
wide: w,
|
|
35
|
+
onSubmit: k,
|
|
36
|
+
onCancel: A,
|
|
37
|
+
children: p
|
|
38
|
+
}) => {
|
|
39
|
+
const [B, i] = L(!1);
|
|
40
|
+
return g(() => {
|
|
41
|
+
n && (i(!1), h(p, (t) => {
|
|
42
|
+
if (!t) return;
|
|
43
|
+
const r = t;
|
|
44
|
+
if (typeof r.type != "function") return;
|
|
45
|
+
const e = r.props;
|
|
46
|
+
if (e.required)
|
|
47
|
+
switch (r.type) {
|
|
48
|
+
case C:
|
|
49
|
+
e.value.trim() || i(!0);
|
|
50
|
+
break;
|
|
51
|
+
case N:
|
|
52
|
+
e.checked || i(!0);
|
|
53
|
+
break;
|
|
54
|
+
case I:
|
|
55
|
+
{
|
|
56
|
+
const o = e.value;
|
|
57
|
+
e.options.findIndex((m) => m.value === o) < 0 && i(!0);
|
|
58
|
+
}
|
|
59
|
+
break;
|
|
60
|
+
case E:
|
|
61
|
+
{
|
|
62
|
+
const o = e.value;
|
|
63
|
+
e.options.findIndex((m) => m.value === o) < 0 && i(!0);
|
|
64
|
+
}
|
|
65
|
+
break;
|
|
66
|
+
case x:
|
|
67
|
+
e.files.length < 1 && i(!0);
|
|
68
|
+
break;
|
|
69
|
+
case F:
|
|
70
|
+
q(e.value.trim()) || i(!0);
|
|
71
|
+
break;
|
|
72
|
+
case D:
|
|
73
|
+
e.options.findIndex((a) => a.checked === !0) < 0 && i(!0);
|
|
74
|
+
break;
|
|
75
|
+
}
|
|
76
|
+
}));
|
|
77
|
+
}, [p, n]), /* @__PURE__ */ b("div", { className: w ? "Form FormWide" : "Form", children: [
|
|
78
|
+
d && /* @__PURE__ */ c("div", { className: "FormSuccess", children: d }),
|
|
79
|
+
u && /* @__PURE__ */ c("div", { className: "FormError", children: u }),
|
|
80
|
+
l && /* @__PURE__ */ c("div", { className: "FormInfo", children: l }),
|
|
81
|
+
p,
|
|
82
|
+
(n || f) && /* @__PURE__ */ b("div", { className: "FormSubmitButtons", children: [
|
|
83
|
+
n && /* @__PURE__ */ c(
|
|
84
|
+
y,
|
|
85
|
+
{
|
|
86
|
+
type: S,
|
|
87
|
+
label: n,
|
|
88
|
+
disabled: B,
|
|
89
|
+
onClick: () => {
|
|
90
|
+
if (!k) return;
|
|
91
|
+
const t = {}, r = (e, s) => {
|
|
92
|
+
if (!t[e]) {
|
|
93
|
+
t[e] = s;
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
t[e] instanceof Array ? t[e].push(s) : t[e] = [t[e], s];
|
|
97
|
+
};
|
|
98
|
+
h(p, (e) => {
|
|
99
|
+
if (!e) return;
|
|
100
|
+
const s = e;
|
|
101
|
+
if (typeof s.type != "function") return;
|
|
102
|
+
const o = s.props;
|
|
103
|
+
switch (s.type) {
|
|
104
|
+
case F:
|
|
105
|
+
case H:
|
|
106
|
+
case C:
|
|
107
|
+
r(o.id, o.value.trim());
|
|
108
|
+
break;
|
|
109
|
+
case N:
|
|
110
|
+
r(o.id, o.checked ? o.value : void 0);
|
|
111
|
+
break;
|
|
112
|
+
case I:
|
|
113
|
+
case E:
|
|
114
|
+
r(o.id, o.value);
|
|
115
|
+
break;
|
|
116
|
+
case x:
|
|
117
|
+
r(o.id, o.files);
|
|
118
|
+
break;
|
|
119
|
+
case R:
|
|
120
|
+
r(o.id, o.value);
|
|
121
|
+
break;
|
|
122
|
+
case D:
|
|
123
|
+
{
|
|
124
|
+
const a = [];
|
|
125
|
+
o.options.forEach((v) => {
|
|
126
|
+
v.checked && a.push(v.value);
|
|
127
|
+
}), r(o.id, a);
|
|
128
|
+
}
|
|
129
|
+
break;
|
|
130
|
+
}
|
|
131
|
+
}), k(t);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
),
|
|
135
|
+
f && /* @__PURE__ */ c(
|
|
136
|
+
y,
|
|
137
|
+
{
|
|
138
|
+
type: j,
|
|
139
|
+
label: f,
|
|
140
|
+
onClick: A
|
|
141
|
+
}
|
|
142
|
+
)
|
|
143
|
+
] })
|
|
144
|
+
] });
|
|
145
|
+
};
|
|
146
|
+
export {
|
|
147
|
+
pe as Form,
|
|
148
|
+
pe as default
|
|
149
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { default as React, FC } from 'react';
|
|
2
|
+
export type InputProps = {
|
|
3
|
+
id: string;
|
|
4
|
+
type?: 'text' | 'password' | 'textarea';
|
|
5
|
+
value: string;
|
|
6
|
+
onChange: (s: string) => void;
|
|
7
|
+
label?: string | null;
|
|
8
|
+
placeholder?: string | null;
|
|
9
|
+
top?: string | null | React.ReactNode;
|
|
10
|
+
bottom?: string | null | React.ReactNode;
|
|
11
|
+
required?: boolean | null;
|
|
12
|
+
disabled?: boolean | null;
|
|
13
|
+
limit?: number | null;
|
|
14
|
+
rows?: number | null;
|
|
15
|
+
autoFocus?: boolean;
|
|
16
|
+
};
|
|
17
|
+
declare const Input: FC<InputProps>;
|
|
18
|
+
export default Input;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { jsx as a, jsxs as p } from "react/jsx-runtime";
|
|
2
|
+
import C from "../label/Label.js";
|
|
3
|
+
import '../../assets/Input.css';const F = ({
|
|
4
|
+
id: s,
|
|
5
|
+
type: e = "text",
|
|
6
|
+
value: t,
|
|
7
|
+
onChange: x,
|
|
8
|
+
label: b,
|
|
9
|
+
placeholder: n,
|
|
10
|
+
rows: l = 5,
|
|
11
|
+
top: h,
|
|
12
|
+
bottom: m,
|
|
13
|
+
autoFocus: u = !1,
|
|
14
|
+
required: f = !1,
|
|
15
|
+
disabled: o = !1,
|
|
16
|
+
limit: g
|
|
17
|
+
}) => {
|
|
18
|
+
const i = () => !!(f && !t.trim().length), c = () => {
|
|
19
|
+
if (i()) return {
|
|
20
|
+
caretColor: "var(--alxgrn-input-border-error)",
|
|
21
|
+
borderColor: "var(--alxgrn-input-border-error)",
|
|
22
|
+
backgroundColor: "var(--alxgrn-input-bg-error)"
|
|
23
|
+
};
|
|
24
|
+
}, d = (r) => {
|
|
25
|
+
g && (r = r.substring(0, g)), x(r);
|
|
26
|
+
};
|
|
27
|
+
return /* @__PURE__ */ a("div", { className: "FormItem", children: /* @__PURE__ */ p(
|
|
28
|
+
C,
|
|
29
|
+
{
|
|
30
|
+
top: h,
|
|
31
|
+
bottom: m,
|
|
32
|
+
label: b,
|
|
33
|
+
required: f,
|
|
34
|
+
disabled: o,
|
|
35
|
+
error: i(),
|
|
36
|
+
children: [
|
|
37
|
+
(e === "text" || e === "password") && /* @__PURE__ */ a(
|
|
38
|
+
"input",
|
|
39
|
+
{
|
|
40
|
+
id: s,
|
|
41
|
+
type: e,
|
|
42
|
+
value: t,
|
|
43
|
+
onChange: (r) => d(r.target.value),
|
|
44
|
+
placeholder: n ?? void 0,
|
|
45
|
+
style: c(),
|
|
46
|
+
disabled: !!o,
|
|
47
|
+
autoFocus: !!u
|
|
48
|
+
}
|
|
49
|
+
),
|
|
50
|
+
e === "textarea" && /* @__PURE__ */ a(
|
|
51
|
+
"textarea",
|
|
52
|
+
{
|
|
53
|
+
id: s,
|
|
54
|
+
rows: l || 5,
|
|
55
|
+
value: t,
|
|
56
|
+
onChange: (r) => d(r.target.value),
|
|
57
|
+
placeholder: n ?? void 0,
|
|
58
|
+
style: c(),
|
|
59
|
+
disabled: !!o,
|
|
60
|
+
autoFocus: !!u
|
|
61
|
+
}
|
|
62
|
+
)
|
|
63
|
+
]
|
|
64
|
+
}
|
|
65
|
+
) });
|
|
66
|
+
};
|
|
67
|
+
export {
|
|
68
|
+
F as default
|
|
69
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { default as React, FC, PropsWithChildren } from 'react';
|
|
2
|
+
export type LabelProps = {
|
|
3
|
+
top?: string | null | React.ReactNode;
|
|
4
|
+
bottom?: string | null | React.ReactNode;
|
|
5
|
+
label?: string | null;
|
|
6
|
+
error?: boolean | null;
|
|
7
|
+
disabled?: boolean | null;
|
|
8
|
+
required?: boolean | null;
|
|
9
|
+
};
|
|
10
|
+
declare const Label: FC<PropsWithChildren<LabelProps>>;
|
|
11
|
+
export default Label;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { jsxs as c, jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import f from "../required/RequiredMark.js";
|
|
3
|
+
import '../../assets/Label.css';const h = ({
|
|
4
|
+
label: a,
|
|
5
|
+
top: l,
|
|
6
|
+
bottom: r,
|
|
7
|
+
required: i = !1,
|
|
8
|
+
error: d = !1,
|
|
9
|
+
disabled: m = !1,
|
|
10
|
+
children: n
|
|
11
|
+
}) => /* @__PURE__ */ c("label", { className: (() => {
|
|
12
|
+
let s = "";
|
|
13
|
+
return d && (s += " Error"), m && (s += " Disabled"), s;
|
|
14
|
+
})(), children: [
|
|
15
|
+
a && /* @__PURE__ */ c("div", { className: "Label", children: [
|
|
16
|
+
/* @__PURE__ */ e(f, { required: i }),
|
|
17
|
+
/* @__PURE__ */ e("span", { children: a })
|
|
18
|
+
] }),
|
|
19
|
+
l && /* @__PURE__ */ e("div", { className: "Top", children: l }),
|
|
20
|
+
n,
|
|
21
|
+
r && /* @__PURE__ */ e("div", { className: "Bottom", children: r })
|
|
22
|
+
] });
|
|
23
|
+
export {
|
|
24
|
+
h as default
|
|
25
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Одиночный radio-элемент не имеет особого смысла, но он
|
|
4
|
+
* используется как базовый и для checkbox. Также на его основе
|
|
5
|
+
* работает списочный элемент RadioList.
|
|
6
|
+
* Суть работы состоит в следующем: элементу передается значение
|
|
7
|
+
* value которое возвращается в функции onChange вместе со статусом
|
|
8
|
+
* отметки элемента.
|
|
9
|
+
*/
|
|
10
|
+
export interface RadioProps {
|
|
11
|
+
type?: 'radio' | 'checkbox';
|
|
12
|
+
value: string | number;
|
|
13
|
+
error?: boolean;
|
|
14
|
+
onChange: (checked: boolean, value: string | number) => void;
|
|
15
|
+
label?: string | null;
|
|
16
|
+
bottom?: string | null;
|
|
17
|
+
required?: boolean | null;
|
|
18
|
+
disabled?: boolean | null;
|
|
19
|
+
checked?: boolean | null;
|
|
20
|
+
}
|
|
21
|
+
export declare const Radio: React.FC<RadioProps>;
|
|
22
|
+
export default Radio;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import n from "./RadioLabel.js";
|
|
3
|
+
const p = ({
|
|
4
|
+
type: l = "radio",
|
|
5
|
+
value: s,
|
|
6
|
+
onChange: f,
|
|
7
|
+
label: o,
|
|
8
|
+
bottom: u,
|
|
9
|
+
error: d = !1,
|
|
10
|
+
required: e = !1,
|
|
11
|
+
disabled: r = !1,
|
|
12
|
+
checked: a = !1
|
|
13
|
+
}) => /* @__PURE__ */ t(
|
|
14
|
+
n,
|
|
15
|
+
{
|
|
16
|
+
label: o,
|
|
17
|
+
bottom: u,
|
|
18
|
+
required: !!e,
|
|
19
|
+
error: d || e && !a,
|
|
20
|
+
disabled: !!r,
|
|
21
|
+
checked: !!a,
|
|
22
|
+
children: /* @__PURE__ */ t(
|
|
23
|
+
"input",
|
|
24
|
+
{
|
|
25
|
+
type: l,
|
|
26
|
+
onChange: (i) => f(i.target.checked, s),
|
|
27
|
+
checked: !!a,
|
|
28
|
+
disabled: !!r,
|
|
29
|
+
required: !!e
|
|
30
|
+
}
|
|
31
|
+
)
|
|
32
|
+
}
|
|
33
|
+
);
|
|
34
|
+
export {
|
|
35
|
+
p as Radio,
|
|
36
|
+
p as default
|
|
37
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { default as React, PropsWithChildren } from 'react';
|
|
2
|
+
export interface RadioLabelProps {
|
|
3
|
+
label?: string | null;
|
|
4
|
+
bottom?: string | null;
|
|
5
|
+
error?: boolean | null;
|
|
6
|
+
disabled?: boolean | null;
|
|
7
|
+
required?: boolean | null;
|
|
8
|
+
checked?: boolean | null;
|
|
9
|
+
}
|
|
10
|
+
declare const RadioLabel: React.FC<PropsWithChildren<RadioLabelProps>>;
|
|
11
|
+
export default RadioLabel;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { jsxs as a, jsx as r } from "react/jsx-runtime";
|
|
2
|
+
import f from "../required/RequiredMark.js";
|
|
3
|
+
import '../../assets/RadioLabel.css';const v = ({
|
|
4
|
+
label: s,
|
|
5
|
+
bottom: l,
|
|
6
|
+
required: c = !1,
|
|
7
|
+
error: i = !1,
|
|
8
|
+
disabled: d = !1,
|
|
9
|
+
checked: o = !1,
|
|
10
|
+
children: n
|
|
11
|
+
}) => /* @__PURE__ */ a("label", { className: (() => {
|
|
12
|
+
let e = "Radio";
|
|
13
|
+
return i && (e += " Error"), d && (e += " Disabled"), o && (e += " Checked"), e;
|
|
14
|
+
})(), children: [
|
|
15
|
+
n,
|
|
16
|
+
/* @__PURE__ */ r("s", {}),
|
|
17
|
+
/* @__PURE__ */ a("div", { children: [
|
|
18
|
+
s && /* @__PURE__ */ a("div", { children: [
|
|
19
|
+
/* @__PURE__ */ r(f, { required: c }),
|
|
20
|
+
/* @__PURE__ */ r("span", { style: i ? { color: "var(--alxgrn-color-error)" } : void 0, children: s })
|
|
21
|
+
] }),
|
|
22
|
+
l && /* @__PURE__ */ r("div", { className: "Bottom", children: l })
|
|
23
|
+
] })
|
|
24
|
+
] });
|
|
25
|
+
export {
|
|
26
|
+
v as default
|
|
27
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Список из Radio-элементов.
|
|
4
|
+
* По сути это аналог Select, но представленный в виде Radio.
|
|
5
|
+
*/
|
|
6
|
+
export type RadioListValue = string | number;
|
|
7
|
+
export interface RadioListOption {
|
|
8
|
+
label: string;
|
|
9
|
+
value: RadioListValue;
|
|
10
|
+
bottom?: string | null;
|
|
11
|
+
disabled?: boolean | null;
|
|
12
|
+
required?: boolean | null;
|
|
13
|
+
}
|
|
14
|
+
export interface RadioListProps {
|
|
15
|
+
label?: string | null;
|
|
16
|
+
value: RadioListValue;
|
|
17
|
+
options: RadioListOption[];
|
|
18
|
+
onChange: (value: RadioListValue, checked?: boolean) => void;
|
|
19
|
+
disabled?: boolean | null;
|
|
20
|
+
required?: boolean | null;
|
|
21
|
+
}
|
|
22
|
+
export declare const RadioList: React.FC<RadioListProps>;
|
|
23
|
+
export default RadioList;
|