triafly-ui-kit 1.0.23 → 1.0.24
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 +93 -93
- package/dist/_commonjsHelpers-C6fGbg64.js +6 -0
- package/dist/assets/Accordeon.css +1 -0
- package/dist/assets/Alert.css +1 -0
- package/dist/assets/Avatar.css +1 -0
- package/dist/assets/Badge.css +1 -0
- package/dist/assets/Button.css +1 -0
- package/dist/assets/ButtonsArray.css +1 -0
- package/dist/assets/Checkbox.css +1 -0
- package/dist/assets/CliTextareaInput.css +1 -0
- package/dist/assets/CustomLink.css +1 -0
- package/dist/assets/DatePicker.css +1 -0
- package/dist/assets/DropdownInput.css +1 -0
- package/dist/assets/DropdownMenu.css +1 -0
- package/dist/assets/FileUpload.css +1 -0
- package/dist/assets/FormRoot.css +1 -0
- package/dist/assets/Loader.css +1 -0
- package/dist/assets/ModalWindow.css +1 -0
- package/dist/assets/Pagination.css +1 -0
- package/dist/assets/Radio.css +1 -0
- package/dist/assets/SearchInput.css +1 -0
- package/dist/assets/Skeleton.css +1 -0
- package/dist/assets/Switch.css +1 -0
- package/dist/assets/Table.css +1 -0
- package/dist/assets/Tabs.css +1 -0
- package/dist/assets/TextInput.css +1 -0
- package/dist/assets/TextareaInput.css +1 -0
- package/dist/assets/ToastContext.css +1 -0
- package/dist/assets/Tooltip.css +1 -0
- package/dist/assets/Tooltip2.css +1 -0
- package/dist/assets/fonts/FiraCode-Regular.ttf +0 -0
- package/dist/assets/fonts/Manrope-Bold.ttf +0 -0
- package/dist/assets/fonts/Manrope-Regular.ttf +0 -0
- package/dist/assets/fonts/Manrope-SemiBold.ttf +0 -0
- package/dist/assets/fonts/RobotoSlab-SemiBold.ttf +0 -0
- package/dist/components/Ui/Accordeon/Accordeon.js +33 -0
- package/dist/components/Ui/Accordeon/Accordeon.stories.js +72 -0
- package/dist/components/Ui/Accordeon/index.js +4 -0
- package/dist/components/Ui/Alert/Alert.js +14 -0
- package/dist/components/Ui/Alert/index.js +4 -0
- package/dist/components/Ui/Avatar/Avatar.js +10 -0
- package/dist/components/Ui/Avatar/index.js +4 -0
- package/dist/components/Ui/Badge/Badge.js +43 -0
- package/dist/components/Ui/Badge/index.js +4 -0
- package/dist/components/Ui/Button/Button.js +49 -0
- package/dist/components/Ui/Button/index.js +4 -0
- package/dist/components/Ui/ButtonsArray/ButtonsArray.js +28 -0
- package/dist/components/Ui/ButtonsArray/ButtonsArray.stories.js +78 -0
- package/dist/components/Ui/ButtonsArray/index.js +4 -0
- package/dist/components/Ui/Checkbox/Checkbox.js +39 -0
- package/dist/components/Ui/Checkbox/Checkbox.stories.js +120 -0
- package/dist/components/Ui/Checkbox/index.js +4 -0
- package/dist/components/Ui/CliTextareaInput/CliTextareaInput.js +121 -0
- package/dist/components/Ui/CliTextareaInput/index.js +23 -0
- package/dist/components/Ui/CliTextareaInput/utils/escapeHtml/escapeHtml.js +4 -0
- package/dist/components/Ui/CliTextareaInput/utils/fixJson/fixJson.js +12 -0
- package/dist/components/Ui/CliTextareaInput/utils/highlightSyntax/highlightSyntax.js +20 -0
- package/dist/components/Ui/CliTextareaInput/utils/highlightSyntax/index.js +4 -0
- package/dist/components/Ui/CliTextareaInput/utils/hooks/index.js +17 -0
- package/dist/components/Ui/CliTextareaInput/utils/hooks/useFixFormat/index.js +4 -0
- package/dist/components/Ui/CliTextareaInput/utils/hooks/useFixFormat/useFixFormat.js +29 -0
- package/dist/components/Ui/CliTextareaInput/utils/hooks/useHistoryNavigation/index.js +4 -0
- package/dist/components/Ui/CliTextareaInput/utils/hooks/useHistoryNavigation/useHistoryNavigation.js +34 -0
- package/dist/components/Ui/CliTextareaInput/utils/hooks/useKeyHandlers/index.js +4 -0
- package/dist/components/Ui/CliTextareaInput/utils/hooks/useKeyHandlers/useKeyHandlers.js +45 -0
- package/dist/components/Ui/CliTextareaInput/utils/hooks/useLineNumbers/index.js +5 -0
- package/dist/components/Ui/CliTextareaInput/utils/hooks/useLineNumbers/useLineNumbers.js +17 -0
- package/dist/components/Ui/CliTextareaInput/utils/hooks/useScrollSync/index.js +4 -0
- package/dist/components/Ui/CliTextareaInput/utils/hooks/useScrollSync/useScrollSync.js +13 -0
- package/dist/components/Ui/CliTextareaInput/utils/hooks/useTextActions/index.js +4 -0
- package/dist/components/Ui/CliTextareaInput/utils/hooks/useTextActions/useTextActions.js +37 -0
- package/dist/components/Ui/CliTextareaInput/utils/hooks/useTextCoursore/index.js +4 -0
- package/dist/components/Ui/CliTextareaInput/utils/hooks/useTextCoursore/useTextCoursore.js +14 -0
- package/dist/components/Ui/CliTextareaInput/utils/index.js +21 -0
- package/dist/components/Ui/CliTextareaInput/utils/processJson/index.js +4 -0
- package/dist/components/Ui/CliTextareaInput/utils/processJson/processJson.js +11 -0
- package/dist/components/Ui/CliTextareaInput/utils/processXml/processXml.js +8 -0
- package/dist/components/Ui/CliTextareaInput/utils/processYml/processYml.js +27 -0
- package/dist/components/Ui/CliTextareaInput/utils/types.js +1 -0
- package/dist/components/Ui/CustomLink/CustomLink.js +49 -0
- package/dist/components/Ui/CustomLink/index.js +4 -0
- package/dist/components/Ui/DatePicker/DatePicker.js +175 -0
- package/dist/components/Ui/DatePicker/DatePicker.stories.js +114 -0
- package/dist/components/Ui/DatePicker/index.js +4 -0
- package/dist/components/Ui/DropdownInput/DropdownInput.js +91 -0
- package/dist/components/Ui/DropdownInput/DropdownInput.stories.js +77 -0
- package/dist/components/Ui/DropdownInput/index.js +4 -0
- package/dist/components/Ui/DropdownMenu/DropdownMenu.js +83 -0
- package/dist/components/Ui/DropdownMenu/DropdownMenu.stories.js +50 -0
- package/dist/components/Ui/DropdownMenu/index.js +4 -0
- package/dist/components/Ui/FileUpload/FileUpload.js +615 -0
- package/dist/components/Ui/FileUpload/fn.js +10 -0
- package/dist/components/Ui/FileUpload/index.js +4 -0
- package/dist/components/Ui/FileUpload/types.js +1 -0
- package/dist/components/Ui/Form/FormContext/FormContext.js +5 -0
- package/dist/components/Ui/Form/FormItem/FormItem.js +107 -0
- package/dist/components/Ui/Form/FormItem/fn.js +25 -0
- package/dist/components/Ui/Form/FormItem/types.js +1 -0
- package/dist/components/Ui/Form/FormRoot/FormRoot.js +25 -0
- package/dist/components/Ui/Form/FormRoot/index.js +4 -0
- package/dist/components/Ui/Form/FormRoot/types.js +1 -0
- package/dist/components/Ui/Form/index.js +6 -0
- package/dist/components/Ui/Form/useForm/index.js +4 -0
- package/dist/components/Ui/Form/useForm/useForm.js +111 -0
- package/dist/components/Ui/Form/utils/fn.js +31 -0
- package/dist/components/Ui/Form/utils/types.js +1 -0
- package/dist/components/Ui/Icons/Icons.js +577 -0
- package/dist/components/Ui/Icons/index.js +97 -0
- package/dist/components/Ui/Icons/utils/CreateIcon.js +23 -0
- package/dist/components/Ui/Loader/Loader.js +6 -0
- package/dist/components/Ui/Loader/index.js +4 -0
- package/dist/components/Ui/ModalWindow/ModalWindow.js +50 -0
- package/dist/components/Ui/ModalWindow/index.js +4 -0
- package/dist/components/Ui/Pagination/Pagination.js +294 -0
- package/dist/components/Ui/Pagination/index.js +4 -0
- package/dist/components/Ui/Radio/Radio.js +30 -0
- package/dist/components/Ui/Radio/Radio.stories.js +42 -0
- package/dist/components/Ui/Radio/index.js +4 -0
- package/dist/components/Ui/SearchInput/SearchData.js +30 -0
- package/dist/components/Ui/SearchInput/SearchInput.js +109 -0
- package/dist/components/Ui/Skeleton/Skeleton.js +28 -0
- package/dist/components/Ui/Skeleton/index.js +4 -0
- package/dist/components/Ui/Switch/Switch.js +25 -0
- package/dist/components/Ui/Switch/index.js +4 -0
- package/dist/components/Ui/Table/MemoizedRow/MemoizedRow.js +79 -0
- package/dist/components/Ui/Table/Table.js +160 -0
- package/dist/components/Ui/Table/TableTypes.js +1 -0
- package/dist/components/Ui/Table/index.js +4 -0
- package/dist/components/Ui/Tabs/Tabs.js +24 -0
- package/dist/components/Ui/Tabs/Tabs.stories.js +67 -0
- package/dist/components/Ui/Tabs/index.js +4 -0
- package/dist/components/Ui/TextInput/TextInput.js +85 -0
- package/dist/components/Ui/TextInput/TextInput.stories.js +225 -0
- package/dist/components/Ui/TextInput/index.js +4 -0
- package/dist/components/Ui/TextareaInput/TextareaInput.js +68 -0
- package/dist/components/Ui/TextareaInput/TextareaInput.stories.js +19 -0
- package/dist/components/Ui/TextareaInput/index.js +4 -0
- package/dist/components/Ui/Tooltip/Tooltip.js +92 -0
- package/dist/components/Ui/Tooltip/Tooltip.stories.js +92 -0
- package/dist/components/Ui/Tooltip/index.js +4 -0
- package/dist/context/ToastContext/ToastContext.js +40 -0
- package/dist/context/ToastContext/index.js +5 -0
- package/dist/context/TriaflyContext/TriaflyContext.types.js +1 -0
- package/dist/context/TriaflyContext/TriaflyProvider.js +27 -0
- package/dist/context/TriaflyContext/hooks/index.js +8 -0
- package/dist/context/TriaflyContext/hooks/useBreakpointValue/index.js +4 -0
- package/dist/context/TriaflyContext/hooks/useBreakpointValue/useBreakpointValue.js +11 -0
- package/dist/context/TriaflyContext/hooks/useModal/index.js +4 -0
- package/dist/context/TriaflyContext/hooks/useModal/useModal.js +16 -0
- package/dist/context/TriaflyContext/hooks/useTheme/index.js +4 -0
- package/dist/context/TriaflyContext/hooks/useTheme/useTheme.js +17 -0
- package/dist/context/TriaflyContext/index.js +12 -0
- package/dist/index-2QXL0WYc.js +45 -0
- package/dist/main.d.ts +1243 -0
- package/dist/main.js +164 -0
- package/dist/vite-env.d.js +1 -0
- package/package.json +106 -106
@@ -0,0 +1,121 @@
|
|
1
|
+
import { jsxs as y, jsx as n } from "react/jsx-runtime";
|
2
|
+
import { forwardRef as A, useState as C, useRef as d, useCallback as g, useEffect as p } from "react";
|
3
|
+
import { c as F } from "../../../index-2QXL0WYc.js";
|
4
|
+
import { highlightSyntax as $ } from "./utils/highlightSyntax/highlightSyntax.js";
|
5
|
+
import { useHistoryNavigation as q } from "./utils/hooks/useHistoryNavigation/useHistoryNavigation.js";
|
6
|
+
import { useTextCoursore as B } from "./utils/hooks/useTextCoursore/useTextCoursore.js";
|
7
|
+
import { useLineNumbers as G } from "./utils/hooks/useLineNumbers/useLineNumbers.js";
|
8
|
+
import { useScrollSync as J } from "./utils/hooks/useScrollSync/useScrollSync.js";
|
9
|
+
import { useTextActions as O } from "./utils/hooks/useTextActions/useTextActions.js";
|
10
|
+
import { useKeyHandlers as Q } from "./utils/hooks/useKeyHandlers/useKeyHandlers.js";
|
11
|
+
import '../../../assets/CliTextareaInput.css';const W = A(
|
12
|
+
({
|
13
|
+
name: c,
|
14
|
+
spellCheck: T = !1,
|
15
|
+
isDisabled: b = !1,
|
16
|
+
onChange: s,
|
17
|
+
value: o,
|
18
|
+
resize: H = !1,
|
19
|
+
format: i,
|
20
|
+
onSubmit: L,
|
21
|
+
onError: R,
|
22
|
+
history: I,
|
23
|
+
numberColl: K = !1,
|
24
|
+
showPrompt: u = !1
|
25
|
+
}, l) => {
|
26
|
+
const [a, m] = C(o), r = d(null), S = d(null), N = d(null);
|
27
|
+
J(r, S, N, a);
|
28
|
+
const { saveSelectionCoursore: h, restoreSelectionCoursore: v } = B(r), { visibleLines: M } = G(r, a), f = g(
|
29
|
+
(e) => {
|
30
|
+
const { selectionStart: t, selectionEnd: z, value: x } = e.target;
|
31
|
+
h({ start: t, end: z }), m(x), s == null || s(
|
32
|
+
{
|
33
|
+
target: { value: x }
|
34
|
+
},
|
35
|
+
void 0
|
36
|
+
);
|
37
|
+
},
|
38
|
+
[s, c, h]
|
39
|
+
), j = g(
|
40
|
+
(e, t) => {
|
41
|
+
m(e), s == null || s(
|
42
|
+
{
|
43
|
+
target: { value: e }
|
44
|
+
},
|
45
|
+
t
|
46
|
+
);
|
47
|
+
},
|
48
|
+
[s, c]
|
49
|
+
), { handleFormat: w, handleSubmit: D } = O({
|
50
|
+
value: o,
|
51
|
+
format: i,
|
52
|
+
onChange: f,
|
53
|
+
onSubmit: L,
|
54
|
+
onError: R
|
55
|
+
}), { navigate: E } = q(I, i, j), U = Q({
|
56
|
+
navigate: E,
|
57
|
+
handleFormat: w,
|
58
|
+
handleSubmit: D,
|
59
|
+
onChange: f,
|
60
|
+
localValue: a,
|
61
|
+
showPrompt: u
|
62
|
+
});
|
63
|
+
p(() => {
|
64
|
+
m(o), v();
|
65
|
+
}, [o, v]), p(() => {
|
66
|
+
const e = r.current;
|
67
|
+
e && e.selectionStart < 3 && e.setSelectionRange(3, 3);
|
68
|
+
}, [a]), p(() => {
|
69
|
+
typeof l == "function" ? l(r.current) : l && (l.current = r.current);
|
70
|
+
}, [l]);
|
71
|
+
const V = F({
|
72
|
+
"no-resize": !H
|
73
|
+
}), _ = (e) => {
|
74
|
+
if (u) {
|
75
|
+
const t = e.currentTarget;
|
76
|
+
setTimeout(() => {
|
77
|
+
t.selectionStart < 4 && t.setSelectionRange(4, 4);
|
78
|
+
}, 0);
|
79
|
+
}
|
80
|
+
}, k = (e) => {
|
81
|
+
if (u) {
|
82
|
+
const t = e.currentTarget;
|
83
|
+
t.selectionStart < 4 && t.setSelectionRange(4, 4);
|
84
|
+
}
|
85
|
+
};
|
86
|
+
return /* @__PURE__ */ y("div", { className: "cli-textarea-input", children: [
|
87
|
+
K && /* @__PURE__ */ n("div", { ref: N, className: "line-numbers", children: M.map((e) => /* @__PURE__ */ n("div", { className: "line-number", "data-line": e, children: e }, e)) }),
|
88
|
+
/* @__PURE__ */ y("div", { className: "input-with-highlight", children: [
|
89
|
+
/* @__PURE__ */ n(
|
90
|
+
"textarea",
|
91
|
+
{
|
92
|
+
onMouseUp: _,
|
93
|
+
onSelect: k,
|
94
|
+
ref: r,
|
95
|
+
className: V,
|
96
|
+
value: a,
|
97
|
+
onKeyDown: U,
|
98
|
+
onChange: f,
|
99
|
+
name: c,
|
100
|
+
disabled: b,
|
101
|
+
spellCheck: T
|
102
|
+
}
|
103
|
+
),
|
104
|
+
/* @__PURE__ */ n(
|
105
|
+
"pre",
|
106
|
+
{
|
107
|
+
ref: S,
|
108
|
+
className: `formatted-content ${i}`,
|
109
|
+
dangerouslySetInnerHTML: {
|
110
|
+
__html: $(a || "", i) || " "
|
111
|
+
}
|
112
|
+
}
|
113
|
+
)
|
114
|
+
] })
|
115
|
+
] });
|
116
|
+
}
|
117
|
+
);
|
118
|
+
W.displayName = "CliTextareaInput";
|
119
|
+
export {
|
120
|
+
W as CliTextareaInput
|
121
|
+
};
|
@@ -0,0 +1,23 @@
|
|
1
|
+
import { CliTextareaInput as e } from "./CliTextareaInput.js";
|
2
|
+
import { highlightSyntax as s } from "./utils/highlightSyntax/highlightSyntax.js";
|
3
|
+
import { processJson as m } from "./utils/processJson/processJson.js";
|
4
|
+
import { useFixFormat as f } from "./utils/hooks/useFixFormat/useFixFormat.js";
|
5
|
+
import { useHistoryNavigation as i } from "./utils/hooks/useHistoryNavigation/useHistoryNavigation.js";
|
6
|
+
import { useTextCoursore as a } from "./utils/hooks/useTextCoursore/useTextCoursore.js";
|
7
|
+
import { LINE_HEIGHT as c, useLineNumbers as y } from "./utils/hooks/useLineNumbers/useLineNumbers.js";
|
8
|
+
import { useScrollSync as T } from "./utils/hooks/useScrollSync/useScrollSync.js";
|
9
|
+
import { useTextActions as h } from "./utils/hooks/useTextActions/useTextActions.js";
|
10
|
+
import { useKeyHandlers as N } from "./utils/hooks/useKeyHandlers/useKeyHandlers.js";
|
11
|
+
export {
|
12
|
+
e as CliTextareaInput,
|
13
|
+
c as LINE_HEIGHT,
|
14
|
+
s as highlightSyntax,
|
15
|
+
m as processJson,
|
16
|
+
f as useFixFormat,
|
17
|
+
i as useHistoryNavigation,
|
18
|
+
N as useKeyHandlers,
|
19
|
+
y as useLineNumbers,
|
20
|
+
T as useScrollSync,
|
21
|
+
h as useTextActions,
|
22
|
+
a as useTextCoursore
|
23
|
+
};
|
@@ -0,0 +1,12 @@
|
|
1
|
+
const $ = (l) => {
|
2
|
+
let e = l.replace(/([{,]\s*)([a-zA-Z_][a-zA-Z0-9_]*)(\s*:)/g, '$1"$2"$3').replace(/([}\]"0-9truefalsenull])\s*(\n\s*["{])/g, "$1,$2").replace(/,\s*\]\s*$/g, "").replace(/\s*\/\*.*\*\/\s*/g, "").replace(/,(\s*[}\]])/g, "$1").replace(
|
3
|
+
/(['"])?([a-zA-Z_][a-zA-Z0-9_]*)(['"])?\s*:/g,
|
4
|
+
(r, c, t) => `${r || '"'}${c}${t || '"'}:`
|
5
|
+
).replace(/([0-9truefalsenull}])\s*(\s*\[)/g, "$1,$2").replace(/(['"])([a-zA-Z_][a-zA-Z0-9_]*)(['"])?\s*:/g, '"$2":');
|
6
|
+
const a = (e.match(/{/g) || []).length, s = (e.match(/}/g) || []).length;
|
7
|
+
return a > s && (e += `
|
8
|
+
`.repeat(a - s) + "}".repeat(a - s)), e;
|
9
|
+
};
|
10
|
+
export {
|
11
|
+
$ as fixJson
|
12
|
+
};
|
@@ -0,0 +1,20 @@
|
|
1
|
+
import { escapeHtml as s } from "../escapeHtml/escapeHtml.js";
|
2
|
+
import { processJson as m } from "../processJson/processJson.js";
|
3
|
+
import { processXml as e } from "../processXml/processXml.js";
|
4
|
+
import { processYml as o } from "../processYml/processYml.js";
|
5
|
+
const a = (r, t) => {
|
6
|
+
if (t === "plain") return r;
|
7
|
+
switch (t) {
|
8
|
+
case "json":
|
9
|
+
return m(r);
|
10
|
+
case "yml":
|
11
|
+
return o(r);
|
12
|
+
case "xml":
|
13
|
+
return e(r);
|
14
|
+
default:
|
15
|
+
return s(r);
|
16
|
+
}
|
17
|
+
};
|
18
|
+
export {
|
19
|
+
a as highlightSyntax
|
20
|
+
};
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import { useFixFormat as r } from "./useFixFormat/useFixFormat.js";
|
2
|
+
import { useHistoryNavigation as s } from "./useHistoryNavigation/useHistoryNavigation.js";
|
3
|
+
import { useTextCoursore as m } from "./useTextCoursore/useTextCoursore.js";
|
4
|
+
import { LINE_HEIGHT as f, useLineNumbers as p } from "./useLineNumbers/useLineNumbers.js";
|
5
|
+
import { useScrollSync as n } from "./useScrollSync/useScrollSync.js";
|
6
|
+
import { useTextActions as H } from "./useTextActions/useTextActions.js";
|
7
|
+
import { useKeyHandlers as l } from "./useKeyHandlers/useKeyHandlers.js";
|
8
|
+
export {
|
9
|
+
f as LINE_HEIGHT,
|
10
|
+
r as useFixFormat,
|
11
|
+
s as useHistoryNavigation,
|
12
|
+
l as useKeyHandlers,
|
13
|
+
p as useLineNumbers,
|
14
|
+
n as useScrollSync,
|
15
|
+
H as useTextActions,
|
16
|
+
m as useTextCoursore
|
17
|
+
};
|
@@ -0,0 +1,29 @@
|
|
1
|
+
import { useCallback as e } from "react";
|
2
|
+
import { fixJson as a } from "../../fixJson/fixJson.js";
|
3
|
+
const c = (o, t) => {
|
4
|
+
const r = t.message.match(/at position (\d+)/);
|
5
|
+
if (!r) return 0;
|
6
|
+
const n = parseInt(r[1], 10);
|
7
|
+
return o.substring(0, n).split(`
|
8
|
+
`).length;
|
9
|
+
}, f = () => ({
|
10
|
+
formatJson: e(async (t) => {
|
11
|
+
try {
|
12
|
+
return JSON.stringify(JSON.parse(t), null, 2);
|
13
|
+
} catch {
|
14
|
+
try {
|
15
|
+
const r = a(t), n = JSON.parse(r);
|
16
|
+
return JSON.stringify(n, null, 2);
|
17
|
+
} catch (r) {
|
18
|
+
const n = r instanceof Error ? r : new Error(String(r)), s = new Error(
|
19
|
+
`JSON Error: ${n.message}
|
20
|
+
Line: ${c(t, n)}`
|
21
|
+
);
|
22
|
+
throw s.name = "Ошибка валидации JSON", s;
|
23
|
+
}
|
24
|
+
}
|
25
|
+
}, [])
|
26
|
+
});
|
27
|
+
export {
|
28
|
+
f as useFixFormat
|
29
|
+
};
|
package/dist/components/Ui/CliTextareaInput/utils/hooks/useHistoryNavigation/useHistoryNavigation.js
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
import { useState as g, useRef as I, useEffect as v, useCallback as p } from "react";
|
2
|
+
const w = (c, u, a) => {
|
3
|
+
const [r, d] = g(-1), e = I(c);
|
4
|
+
return v(() => {
|
5
|
+
e.current = c;
|
6
|
+
}, [c]), { navigate: p(
|
7
|
+
(f) => {
|
8
|
+
var o;
|
9
|
+
if (!((o = e.current) != null && o.length) || !e.current.filter((t) => t.format === u).length) return;
|
10
|
+
let n = r;
|
11
|
+
if (f === "up") {
|
12
|
+
const t = e.current.findIndex(
|
13
|
+
(s, i) => i > r && s.format === u
|
14
|
+
);
|
15
|
+
n = t !== -1 ? t : r;
|
16
|
+
} else {
|
17
|
+
const t = [...e.current].reverse().findIndex(
|
18
|
+
(s, i) => {
|
19
|
+
var l;
|
20
|
+
return (((l = e == null ? void 0 : e.current) == null ? void 0 : l.length) ?? 0) - 1 - i < r && s.format === u;
|
21
|
+
}
|
22
|
+
);
|
23
|
+
n = t !== -1 ? e.current.length - 1 - t : -1;
|
24
|
+
}
|
25
|
+
d(n);
|
26
|
+
const x = n === -1 ? ">>> " : `>>> ${e.current[n].value}`;
|
27
|
+
a(x, e.current[n]);
|
28
|
+
},
|
29
|
+
[r, u]
|
30
|
+
) };
|
31
|
+
};
|
32
|
+
export {
|
33
|
+
w as useHistoryNavigation
|
34
|
+
};
|
@@ -0,0 +1,45 @@
|
|
1
|
+
import { useCallback as y } from "react";
|
2
|
+
function u(i, r = "", s) {
|
3
|
+
const e = i.currentTarget, n = e.selectionStart, c = e.selectionEnd, t = r.substring(0, n) + (i.key === "Tab" ? " " : " ") + (r.substring(c) || "");
|
4
|
+
s == null || s({
|
5
|
+
target: { value: t }
|
6
|
+
}), setTimeout(() => {
|
7
|
+
e.selectionStart = n + (i.key === "Tab" ? 4 : 1), e.selectionEnd = e.selectionStart;
|
8
|
+
}, 0);
|
9
|
+
}
|
10
|
+
function k(i, r = "", s) {
|
11
|
+
const e = i.currentTarget, n = e.selectionStart, c = `${r == null ? void 0 : r.substring(0, n)}{}${r == null ? void 0 : r.substring(n)}`;
|
12
|
+
s == null || s({
|
13
|
+
target: { value: c }
|
14
|
+
}), setTimeout(() => {
|
15
|
+
e.selectionStart = n + 1, e.selectionEnd = e.selectionStart;
|
16
|
+
}, 0);
|
17
|
+
}
|
18
|
+
const T = ({
|
19
|
+
navigate: i,
|
20
|
+
handleFormat: r,
|
21
|
+
handleSubmit: s,
|
22
|
+
onChange: e,
|
23
|
+
localValue: n = "",
|
24
|
+
showPrompt: c
|
25
|
+
}) => y(
|
26
|
+
(t) => {
|
27
|
+
if (c) {
|
28
|
+
const f = t.currentTarget;
|
29
|
+
f.selectionStart < 4 && ["Backspace", "Delete", "ArrowLeft"].includes(t.key) && (t.preventDefault(), f.setSelectionRange(4, 4));
|
30
|
+
}
|
31
|
+
if (t.shiftKey && (t.key === "ArrowUp" || t.key === "ArrowDown")) {
|
32
|
+
t.preventDefault(), i(t.key === "ArrowUp" ? "up" : "down");
|
33
|
+
return;
|
34
|
+
}
|
35
|
+
if (t.key === "Tab" || t.key === " ") {
|
36
|
+
t.preventDefault(), u(t, n, e);
|
37
|
+
return;
|
38
|
+
}
|
39
|
+
(t.ctrlKey || t.metaKey) && t.key === "s" && (t.preventDefault(), r()), t.key === "Enter" && !t.shiftKey && !t.ctrlKey && !t.metaKey && (t.preventDefault(), s()), t.key === "{" && (t.preventDefault(), k(t, n, e));
|
40
|
+
},
|
41
|
+
[i, r, s, e, c, n]
|
42
|
+
);
|
43
|
+
export {
|
44
|
+
T as useKeyHandlers
|
45
|
+
};
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import { useState as c, useEffect as a } from "react";
|
2
|
+
const l = 24, L = (r, s) => {
|
3
|
+
const [n, i] = c([0]);
|
4
|
+
return a(() => {
|
5
|
+
const e = () => {
|
6
|
+
const t = r.current;
|
7
|
+
if (!t) return;
|
8
|
+
const o = Math.floor(t.scrollHeight / l) || 1;
|
9
|
+
i(Array.from({ length: o }, (f, u) => u + 1));
|
10
|
+
};
|
11
|
+
return e(), window.addEventListener("resize", e), () => window.removeEventListener("resize", e);
|
12
|
+
}, [s]), { visibleLines: n };
|
13
|
+
};
|
14
|
+
export {
|
15
|
+
l as LINE_HEIGHT,
|
16
|
+
L as useLineNumbers
|
17
|
+
};
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import { useEffect as u } from "react";
|
2
|
+
const a = (t, l, n, s) => (u(() => {
|
3
|
+
const r = t.current, e = l.current, o = n.current;
|
4
|
+
if (!r || !e || !o) return;
|
5
|
+
const c = () => {
|
6
|
+
e.scrollTop = r.scrollTop, o.scrollTop = r.scrollTop;
|
7
|
+
};
|
8
|
+
return r.addEventListener("scroll", c), () => r.removeEventListener("scroll", c);
|
9
|
+
}, [s]), { syncScroll: () => {
|
10
|
+
} });
|
11
|
+
export {
|
12
|
+
a as useScrollSync
|
13
|
+
};
|
@@ -0,0 +1,37 @@
|
|
1
|
+
import { useCallback as m } from "react";
|
2
|
+
import { useFixFormat as x } from "../useFixFormat/useFixFormat.js";
|
3
|
+
const p = ({
|
4
|
+
value: s,
|
5
|
+
format: f,
|
6
|
+
onChange: a,
|
7
|
+
onSubmit: i,
|
8
|
+
onError: c
|
9
|
+
}) => {
|
10
|
+
const { formatJson: e } = x(), n = m(async () => {
|
11
|
+
if (s)
|
12
|
+
try {
|
13
|
+
const t = await e(s);
|
14
|
+
t !== s && a && a({
|
15
|
+
target: { value: t }
|
16
|
+
});
|
17
|
+
} catch (t) {
|
18
|
+
c == null || c(t instanceof Error ? t : new Error(String(t)));
|
19
|
+
}
|
20
|
+
}, [s, a, c, e]), w = m(async () => {
|
21
|
+
if (!(!s || !i))
|
22
|
+
try {
|
23
|
+
const t = f === "json" ? await e(s) : s;
|
24
|
+
await i(t);
|
25
|
+
} catch (t) {
|
26
|
+
c == null || c(
|
27
|
+
new Error(
|
28
|
+
`Отправка не удалась: ${t instanceof Error ? t.message : "Ошибка валидации"}`
|
29
|
+
)
|
30
|
+
);
|
31
|
+
}
|
32
|
+
}, [s, f, i, c, e]);
|
33
|
+
return { handleFormat: n, handleSubmit: w };
|
34
|
+
};
|
35
|
+
export {
|
36
|
+
p as useTextActions
|
37
|
+
};
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import { useRef as u, useCallback as t } from "react";
|
2
|
+
const l = (r) => {
|
3
|
+
const e = u({ start: 0, end: 0 }), n = t(({ start: s, end: c }) => {
|
4
|
+
e.current = { start: s, end: c };
|
5
|
+
}, []), o = t(() => {
|
6
|
+
requestAnimationFrame(() => {
|
7
|
+
r.current && (r.current.selectionStart = e.current.start, r.current.selectionEnd = e.current.end);
|
8
|
+
});
|
9
|
+
}, [r]);
|
10
|
+
return { saveSelectionCoursore: n, restoreSelectionCoursore: o };
|
11
|
+
};
|
12
|
+
export {
|
13
|
+
l as useTextCoursore
|
14
|
+
};
|
@@ -0,0 +1,21 @@
|
|
1
|
+
import { highlightSyntax as e } from "./highlightSyntax/highlightSyntax.js";
|
2
|
+
import { processJson as s } from "./processJson/processJson.js";
|
3
|
+
import { useFixFormat as m } from "./hooks/useFixFormat/useFixFormat.js";
|
4
|
+
import { useHistoryNavigation as f } from "./hooks/useHistoryNavigation/useHistoryNavigation.js";
|
5
|
+
import { useTextCoursore as i } from "./hooks/useTextCoursore/useTextCoursore.js";
|
6
|
+
import { LINE_HEIGHT as a, useLineNumbers as c } from "./hooks/useLineNumbers/useLineNumbers.js";
|
7
|
+
import { useScrollSync as y } from "./hooks/useScrollSync/useScrollSync.js";
|
8
|
+
import { useTextActions as g } from "./hooks/useTextActions/useTextActions.js";
|
9
|
+
import { useKeyHandlers as N } from "./hooks/useKeyHandlers/useKeyHandlers.js";
|
10
|
+
export {
|
11
|
+
a as LINE_HEIGHT,
|
12
|
+
e as highlightSyntax,
|
13
|
+
s as processJson,
|
14
|
+
m as useFixFormat,
|
15
|
+
f as useHistoryNavigation,
|
16
|
+
N as useKeyHandlers,
|
17
|
+
c as useLineNumbers,
|
18
|
+
y as useScrollSync,
|
19
|
+
g as useTextActions,
|
20
|
+
i as useTextCoursore
|
21
|
+
};
|
@@ -0,0 +1,11 @@
|
|
1
|
+
const c = (l) => {
|
2
|
+
let a = 0, p = !1, e = "";
|
3
|
+
for (let n = 0; n < l.length; n++) {
|
4
|
+
const s = l[n];
|
5
|
+
s === '"' && (n === 0 || l[n - 1] !== "\\") && (p = !p), p ? e += s : s === "{" || s === "}" ? s === "{" ? (e += a === 0 ? '<span class="json-bracket">{</span>' : '<span class="json-nested-bracket">{</span>', a++) : (a--, e += a === 0 ? '<span class="json-bracket">}</span>' : '<span class="json-nested-bracket">}</span>') : e += s;
|
6
|
+
}
|
7
|
+
return e.replace(/"([^"\\]*(?:\\.[^"\\]*)*)"\s*:/g, '<span class="json-key">"$1"</span>:').replace(/:\s*"([^"\\]*(?:\\.[^"\\]*)*)"/g, ': <span class="json-string">"$1"</span>').replace(/([:[,]\s*)(-?\d+\.?\d*([eE][+-]?\d+)?)/g, '$1<span class="json-number">$2</span>').replace(/([:[,]\s*)(true|false|null)/g, '$1<span class="json-literal">$2</span>');
|
8
|
+
};
|
9
|
+
export {
|
10
|
+
c as processJson
|
11
|
+
};
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import { escapeHtml as a } from "../escapeHtml/escapeHtml.js";
|
2
|
+
const p = (s) => a(s).replace(/(<\/?)([\w:-]+)(?=[\s>])/g, '$1<span class="xml-tag">$2</span>').replace(
|
3
|
+
/([\w:-]+)=("[^&]*?")/g,
|
4
|
+
"<span class='xml-attr'>$1</span>=<span class='xml-value'>$2</span>"
|
5
|
+
);
|
6
|
+
export {
|
7
|
+
p as processXml
|
8
|
+
};
|
@@ -0,0 +1,27 @@
|
|
1
|
+
import { escapeHtml as c } from "../escapeHtml/escapeHtml.js";
|
2
|
+
const g = (r) => r.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").split(`
|
3
|
+
`).map((t) => {
|
4
|
+
const p = t.match(/(.*?)(#.*)/);
|
5
|
+
let s = t, l = "";
|
6
|
+
if (p) {
|
7
|
+
const [, n, e] = p;
|
8
|
+
s = n, l = `<span class="comment">${c(e)}</span>`;
|
9
|
+
}
|
10
|
+
return s = s.replace(
|
11
|
+
/^(\s*)([^:\n]+)(:\s*)/,
|
12
|
+
(n, e, a, o) => `${e}<span class="key">${c(a)}</span>${o}`
|
13
|
+
), s = s.replace(
|
14
|
+
/(:\s*)("(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*')/,
|
15
|
+
(n, e, a) => `${e}<span class="string">${c(a)}</span>`
|
16
|
+
), s = s.replace(
|
17
|
+
/(:\s*)(\d+(?:\.\d+)?)/,
|
18
|
+
(n, e, a) => `${e}<span class="number">${a}</span>`
|
19
|
+
), s = s.replace(
|
20
|
+
/(:\s*)(true|false|null)/,
|
21
|
+
(n, e, a) => `${e}<span class="boolean">${a}</span>`
|
22
|
+
), s + l;
|
23
|
+
}).join(`
|
24
|
+
`);
|
25
|
+
export {
|
26
|
+
g as processYml
|
27
|
+
};
|
@@ -0,0 +1 @@
|
|
1
|
+
|
@@ -0,0 +1,49 @@
|
|
1
|
+
import { jsxs as p, jsx as c } from "react/jsx-runtime";
|
2
|
+
import { Link as x } from "react-router-dom";
|
3
|
+
import '../../../assets/CustomLink.css';const u = ({
|
4
|
+
href: s,
|
5
|
+
children: a,
|
6
|
+
target: $ = "_self",
|
7
|
+
className: r = "",
|
8
|
+
style: t = {},
|
9
|
+
onClick: l,
|
10
|
+
ariaLabel: e,
|
11
|
+
title: o,
|
12
|
+
icon: n
|
13
|
+
}) => {
|
14
|
+
const i = !!(s != null && s.startsWith("http://")), m = `link ${r} ${i ? "external" : ""}`;
|
15
|
+
return i ? /* @__PURE__ */ p(
|
16
|
+
"a",
|
17
|
+
{
|
18
|
+
href: s,
|
19
|
+
target: $,
|
20
|
+
rel: "noopener noreferrer",
|
21
|
+
className: `${m} ${r}`,
|
22
|
+
style: t,
|
23
|
+
onClick: l,
|
24
|
+
"aria-label": e,
|
25
|
+
title: o,
|
26
|
+
children: [
|
27
|
+
n && /* @__PURE__ */ c("span", { className: "icon", children: n }),
|
28
|
+
a
|
29
|
+
]
|
30
|
+
}
|
31
|
+
) : /* @__PURE__ */ p(
|
32
|
+
x,
|
33
|
+
{
|
34
|
+
to: s,
|
35
|
+
className: `${m} ${r}`,
|
36
|
+
style: t,
|
37
|
+
onClick: l,
|
38
|
+
"aria-label": e,
|
39
|
+
title: o,
|
40
|
+
children: [
|
41
|
+
n && /* @__PURE__ */ c("span", { className: "icon", children: n }),
|
42
|
+
a
|
43
|
+
]
|
44
|
+
}
|
45
|
+
);
|
46
|
+
};
|
47
|
+
export {
|
48
|
+
u as CustomLink
|
49
|
+
};
|