@thebuoyant-tsdev/mui-ts-library 3.2.0 → 3.4.0
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.de.md +23 -0
- package/README.md +23 -0
- package/dist/components/chord-chart/ChordChart.js +284 -0
- package/dist/components/chord-chart/ChordChart.types.js +4 -0
- package/dist/components/circle-packing-chart/CirclePackingChart.js +382 -0
- package/dist/components/circle-packing-chart/CirclePackingChart.types.js +4 -0
- package/dist/components/gantt-chart/GanttBarRow.js +202 -0
- package/dist/components/gantt-chart/GanttChart.constants.js +14 -0
- package/dist/components/gantt-chart/GanttChart.js +258 -0
- package/dist/components/gantt-chart/GanttChart.store.js +119 -0
- package/dist/components/gantt-chart/GanttChart.types.js +47 -0
- package/dist/components/gantt-chart/GanttDeleteDialog.js +30 -0
- package/dist/components/gantt-chart/GanttDependencyArrows.js +54 -0
- package/dist/components/gantt-chart/GanttStatusContextMenu.js +36 -0
- package/dist/components/gantt-chart/GanttTaskDialog.js +324 -0
- package/dist/components/gantt-chart/GanttTaskPanel.js +415 -0
- package/dist/components/gantt-chart/GanttTimeline.js +223 -0
- package/dist/components/gantt-chart/GanttTimelineHeader.js +90 -0
- package/dist/components/gantt-chart/GanttToolbar.js +157 -0
- package/dist/components/gantt-chart/GanttWeekendStrips.js +29 -0
- package/dist/components/gantt-chart/hooks/useGanttDrag.js +104 -0
- package/dist/components/gantt-chart/util/gantt-chart.util.js +150 -0
- package/dist/components/horizontal-tree-chart/HorizontalTreeChart.js +488 -0
- package/dist/components/horizontal-tree-chart/HorizontalTreeChart.types.js +8 -0
- package/dist/components/json-editor/JsonEditor.js +102 -0
- package/dist/components/json-editor/JsonEditor.types.js +21 -0
- package/dist/components/json-editor/JsonEditorContent.js +185 -0
- package/dist/components/json-editor/JsonEditorFooter.js +55 -0
- package/dist/components/json-editor/JsonEditorToolbar.js +148 -0
- package/dist/components/password-strength-meter/PasswordStrengthBar.js +66 -0
- package/dist/components/password-strength-meter/PasswordStrengthMeter.js +272 -0
- package/dist/components/password-strength-meter/PasswordStrengthMeter.types.js +27 -0
- package/dist/components/password-strength-meter/util/password-strength.util.js +38 -0
- package/dist/components/radial-tree-chart/RadialTreeChart.js +447 -0
- package/dist/components/radial-tree-chart/RadialTreeChart.types.js +8 -0
- package/dist/components/rich-text-editor/RichTextEditor.js +135 -0
- package/dist/components/rich-text-editor/RichTextEditor.types.js +74 -0
- package/dist/components/rich-text-editor/RichTextEditorColorPicker.js +185 -0
- package/dist/components/rich-text-editor/RichTextEditorContent.js +129 -0
- package/dist/components/rich-text-editor/RichTextEditorEmojiPicker.js +110 -0
- package/dist/components/rich-text-editor/RichTextEditorFooter.js +33 -0
- package/dist/components/rich-text-editor/RichTextEditorImageDialog.js +74 -0
- package/dist/components/rich-text-editor/RichTextEditorLinkDialog.js +70 -0
- package/dist/components/rich-text-editor/RichTextEditorTableMenu.js +97 -0
- package/dist/components/rich-text-editor/RichTextEditorToolbar.js +362 -0
- package/dist/components/rich-text-editor/util/emojis.js +739 -0
- package/dist/components/shared/ToolbarButton.js +22 -0
- package/dist/components/shared/normalizeSize.js +6 -0
- package/dist/components/sql-editor/SqlEditor.js +100 -0
- package/dist/components/sql-editor/SqlEditor.types.js +20 -0
- package/dist/components/sql-editor/SqlEditorContent.js +248 -0
- package/dist/components/sql-editor/SqlEditorFooter.js +45 -0
- package/dist/components/sql-editor/SqlEditorToolbar.js +151 -0
- package/dist/components/sunburst-chart/SunburstChart.js +292 -0
- package/dist/components/sunburst-chart/SunburstChart.types.js +4 -0
- package/dist/components/tag-selection/TagSelection.js +102 -0
- package/dist/components/tag-selection/TagSelection.store.js +40 -0
- package/dist/components/tag-selection/TagSelection.types.d.ts +2 -0
- package/dist/components/tag-selection/TagSelection.types.js +18 -0
- package/dist/components/tag-selection/TagSelectionAutocomplete.js +382 -0
- package/dist/components/tag-selection/TagSelectionChip.js +30 -0
- package/dist/components/tag-selection/TagSelectionSelectedTags.js +73 -0
- package/dist/index.cjs +2 -2
- package/dist/index.js +23 -8035
- package/package.json +1 -1
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { IconButton as e, Tooltip as t } from "@mui/material";
|
|
2
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
3
|
+
//#region src/components/shared/ToolbarButton.tsx
|
|
4
|
+
function r({ label: r, icon: i, onClick: a, active: o, disabled: s }) {
|
|
5
|
+
return /* @__PURE__ */ n(t, {
|
|
6
|
+
title: r,
|
|
7
|
+
arrow: !0,
|
|
8
|
+
children: /* @__PURE__ */ n("span", { children: /* @__PURE__ */ n(e, {
|
|
9
|
+
size: "small",
|
|
10
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
11
|
+
onClick: a,
|
|
12
|
+
disabled: s,
|
|
13
|
+
color: o ? "primary" : "default",
|
|
14
|
+
sx: { borderRadius: 1 },
|
|
15
|
+
"aria-label": r,
|
|
16
|
+
"aria-pressed": o,
|
|
17
|
+
children: i
|
|
18
|
+
}) })
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
//#endregion
|
|
22
|
+
export { r as ToolbarButton };
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { normalizeSize as e } from "../shared/normalizeSize.js";
|
|
2
|
+
import { DEFAULT_SQL_EDITOR_TOOLBAR_CONFIG as t, DEFAULT_SQL_EDITOR_TRANSLATION as n } from "./SqlEditor.types.js";
|
|
3
|
+
import { SqlEditorContent as r } from "./SqlEditorContent.js";
|
|
4
|
+
import { SqlEditorToolbar as i } from "./SqlEditorToolbar.js";
|
|
5
|
+
import { SqlEditorFooter as a } from "./SqlEditorFooter.js";
|
|
6
|
+
import { useCallback as o, useRef as s, useState as c } from "react";
|
|
7
|
+
import { Box as l, Divider as u, Paper as d } from "@mui/material";
|
|
8
|
+
import { Fragment as f, jsx as p, jsxs as m } from "react/jsx-runtime";
|
|
9
|
+
//#region src/components/sql-editor/SqlEditor.tsx
|
|
10
|
+
function h({ value: h, onChange: g, placeholder: _, height: v, width: y, disabled: b = !1, readonly: x = !1, error: S = !1, helperText: C, name: w, dialect: T = "standard", showLineNumbers: E = !0, showLineColumn: D = !0, showErrorCount: O = !1, toolbarConfig: k, translation: A, highlightColors: j, schema: M, onExecute: N, onLint: P, onBlur: F, onFocus: I }) {
|
|
11
|
+
let L = {
|
|
12
|
+
...n,
|
|
13
|
+
...A
|
|
14
|
+
}, R = {
|
|
15
|
+
...t,
|
|
16
|
+
...k
|
|
17
|
+
}, z = e(v), B = e(y), V = z === "auto", H = V ? void 0 : z ?? 300, U = s(null), [W, G] = c(null), [K, q] = c({
|
|
18
|
+
line: 1,
|
|
19
|
+
col: 1
|
|
20
|
+
}), [J, Y] = c(0), X = o((e) => {
|
|
21
|
+
U.current = e, G(e);
|
|
22
|
+
}, []), Z = o((e, t) => {
|
|
23
|
+
q({
|
|
24
|
+
line: e,
|
|
25
|
+
col: t
|
|
26
|
+
});
|
|
27
|
+
}, []), Q = o((e) => {
|
|
28
|
+
Y(e);
|
|
29
|
+
}, []), $ = D || O || !!C;
|
|
30
|
+
return /* @__PURE__ */ m(l, {
|
|
31
|
+
sx: {
|
|
32
|
+
width: B ?? "100%",
|
|
33
|
+
...V ? {
|
|
34
|
+
display: "flex",
|
|
35
|
+
flexDirection: "column",
|
|
36
|
+
flex: 1
|
|
37
|
+
} : {}
|
|
38
|
+
},
|
|
39
|
+
children: [
|
|
40
|
+
/* @__PURE__ */ m(d, {
|
|
41
|
+
variant: "outlined",
|
|
42
|
+
sx: {
|
|
43
|
+
display: "flex",
|
|
44
|
+
flexDirection: "column",
|
|
45
|
+
overflow: "hidden",
|
|
46
|
+
...V ? { flex: 1 } : { height: H },
|
|
47
|
+
borderColor: S ? "error.main" : void 0,
|
|
48
|
+
"&:focus-within": {
|
|
49
|
+
borderColor: S ? "error.main" : "primary.main",
|
|
50
|
+
borderWidth: 2
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
children: [!x && /* @__PURE__ */ m(f, { children: [/* @__PURE__ */ p(i, {
|
|
54
|
+
editorView: W,
|
|
55
|
+
toolbarConfig: R,
|
|
56
|
+
translation: L,
|
|
57
|
+
dialect: T,
|
|
58
|
+
disabled: b,
|
|
59
|
+
onExecute: N
|
|
60
|
+
}), /* @__PURE__ */ p(u, {})] }), /* @__PURE__ */ p(r, {
|
|
61
|
+
value: h,
|
|
62
|
+
onChange: g,
|
|
63
|
+
placeholder: _,
|
|
64
|
+
disabled: b,
|
|
65
|
+
readonly: x,
|
|
66
|
+
showLineNumbers: E,
|
|
67
|
+
dialect: T,
|
|
68
|
+
keywordColor: j?.keyword,
|
|
69
|
+
stringColor: j?.string,
|
|
70
|
+
identifierColor: j?.identifier,
|
|
71
|
+
schema: M,
|
|
72
|
+
onExecute: N,
|
|
73
|
+
onLint: P,
|
|
74
|
+
onDiagnosticsChange: P ? Q : void 0,
|
|
75
|
+
onViewReady: X,
|
|
76
|
+
onCursorChange: Z,
|
|
77
|
+
onBlur: F,
|
|
78
|
+
onFocus: I
|
|
79
|
+
})]
|
|
80
|
+
}),
|
|
81
|
+
$ && /* @__PURE__ */ p(a, {
|
|
82
|
+
helperText: C,
|
|
83
|
+
error: S,
|
|
84
|
+
showLineColumn: D,
|
|
85
|
+
showErrorCount: O,
|
|
86
|
+
diagnosticsCount: J,
|
|
87
|
+
cursorLine: K.line,
|
|
88
|
+
cursorCol: K.col,
|
|
89
|
+
translation: L
|
|
90
|
+
}),
|
|
91
|
+
w && /* @__PURE__ */ p("input", {
|
|
92
|
+
type: "hidden",
|
|
93
|
+
name: w,
|
|
94
|
+
value: h ?? ""
|
|
95
|
+
})
|
|
96
|
+
]
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
//#endregion
|
|
100
|
+
export { h as SqlEditor };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
//#region src/components/sql-editor/SqlEditor.types.ts
|
|
2
|
+
var e = {
|
|
3
|
+
showFormat: !0,
|
|
4
|
+
showCopy: !0,
|
|
5
|
+
showClear: !0,
|
|
6
|
+
showExecute: !1,
|
|
7
|
+
showUndoRedo: !0
|
|
8
|
+
}, t = {
|
|
9
|
+
format: "Format SQL",
|
|
10
|
+
copy: "Copy",
|
|
11
|
+
copySuccess: "Copied!",
|
|
12
|
+
clear: "Clear",
|
|
13
|
+
execute: "Execute",
|
|
14
|
+
undo: "Undo",
|
|
15
|
+
redo: "Redo",
|
|
16
|
+
lineColumn: "Ln {line}, Col {col}",
|
|
17
|
+
errorCount: "{count} error(s)"
|
|
18
|
+
};
|
|
19
|
+
//#endregion
|
|
20
|
+
export { e as DEFAULT_SQL_EDITOR_TOOLBAR_CONFIG, t as DEFAULT_SQL_EDITOR_TRANSLATION };
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import { useEffect as e, useRef as t } from "react";
|
|
2
|
+
import { Box as n, useTheme as r } from "@mui/material";
|
|
3
|
+
import { EditorView as i, highlightActiveLine as a, highlightActiveLineGutter as o, keymap as s, lineNumbers as c, placeholder as l } from "@codemirror/view";
|
|
4
|
+
import { Compartment as u, EditorState as d } from "@codemirror/state";
|
|
5
|
+
import { defaultKeymap as f, history as p, historyKeymap as m } from "@codemirror/commands";
|
|
6
|
+
import { HighlightStyle as ee, syntaxHighlighting as te } from "@codemirror/language";
|
|
7
|
+
import { lintGutter as ne, linter as h } from "@codemirror/lint";
|
|
8
|
+
import { tags as g } from "@lezer/highlight";
|
|
9
|
+
import { jsx as _ } from "react/jsx-runtime";
|
|
10
|
+
import { MSSQL as v, MySQL as y, PostgreSQL as b, SQLite as x, StandardSQL as S, sql as C } from "@codemirror/lang-sql";
|
|
11
|
+
import { autocompletion as re, completionKeymap as w } from "@codemirror/autocomplete";
|
|
12
|
+
//#region src/components/sql-editor/SqlEditorContent.tsx
|
|
13
|
+
var T = {
|
|
14
|
+
standard: S,
|
|
15
|
+
mysql: y,
|
|
16
|
+
postgresql: b,
|
|
17
|
+
sqlite: x,
|
|
18
|
+
mssql: v
|
|
19
|
+
};
|
|
20
|
+
function E({ value: v, onChange: y, placeholder: b, disabled: x = !1, readonly: S = !1, showLineNumbers: E = !0, dialect: D = "standard", keywordColor: O, stringColor: k, identifierColor: A, schema: j, onExecute: M, onLint: N, onDiagnosticsChange: P, onViewReady: F, onCursorChange: I, onBlur: L, onFocus: R }) {
|
|
21
|
+
let z = t(null), B = t(null), V = t(y), H = t(I), U = t(L), W = t(R), G = t(F), K = t(M), q = t(N), J = t(P), Y = t(new u()), X = t(new u()), Z = r(), Q = Z.palette.mode === "dark", $ = !!N, ie = JSON.stringify(j);
|
|
22
|
+
return e(() => {
|
|
23
|
+
V.current = y;
|
|
24
|
+
}, [y]), e(() => {
|
|
25
|
+
H.current = I;
|
|
26
|
+
}, [I]), e(() => {
|
|
27
|
+
U.current = L;
|
|
28
|
+
}, [L]), e(() => {
|
|
29
|
+
W.current = R;
|
|
30
|
+
}, [R]), e(() => {
|
|
31
|
+
G.current = F;
|
|
32
|
+
}, [F]), e(() => {
|
|
33
|
+
K.current = M;
|
|
34
|
+
}, [M]), e(() => {
|
|
35
|
+
q.current = N;
|
|
36
|
+
}, [N]), e(() => {
|
|
37
|
+
J.current = P;
|
|
38
|
+
}, [P]), e(() => {
|
|
39
|
+
if (!z.current) return;
|
|
40
|
+
let e = B.current?.state.doc.toString() ?? v ?? "", t = O ?? Z.palette.primary.main, n = k ?? Z.palette.success.main, r = A ?? Z.palette.info.main, u = ee.define([
|
|
41
|
+
{
|
|
42
|
+
tag: g.keyword,
|
|
43
|
+
color: t,
|
|
44
|
+
fontWeight: "bold"
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
tag: g.name,
|
|
48
|
+
color: r
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
tag: [g.string, g.special(g.string)],
|
|
52
|
+
color: n,
|
|
53
|
+
fontWeight: "bold"
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
tag: g.number,
|
|
57
|
+
color: Z.palette.warning.main
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
tag: [g.lineComment, g.blockComment],
|
|
61
|
+
color: Z.palette.text.disabled,
|
|
62
|
+
fontStyle: "italic"
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
tag: g.operator,
|
|
66
|
+
color: Z.palette.text.secondary
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
tag: [g.function(g.variableName), g.function(g.name)],
|
|
70
|
+
color: Z.palette.secondary.main
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
tag: g.typeName,
|
|
74
|
+
color: Z.palette.info.main
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
tag: g.invalid,
|
|
78
|
+
color: Z.palette.error.main,
|
|
79
|
+
textDecoration: "underline wavy"
|
|
80
|
+
}
|
|
81
|
+
]), _ = i.theme({
|
|
82
|
+
"&": {
|
|
83
|
+
height: "100%",
|
|
84
|
+
fontFamily: "'Fira Code', 'JetBrains Mono', 'Consolas', monospace",
|
|
85
|
+
fontSize: "0.875rem"
|
|
86
|
+
},
|
|
87
|
+
".cm-scroller": { overflow: "auto" },
|
|
88
|
+
".cm-content": {
|
|
89
|
+
padding: "8px 4px",
|
|
90
|
+
caretColor: Z.palette.text.primary
|
|
91
|
+
},
|
|
92
|
+
".cm-gutters": {
|
|
93
|
+
backgroundColor: Q ? Z.palette.grey[900] : Z.palette.grey[50],
|
|
94
|
+
color: Z.palette.text.disabled,
|
|
95
|
+
border: "none",
|
|
96
|
+
borderRight: `1px solid ${Z.palette.divider}`
|
|
97
|
+
},
|
|
98
|
+
".cm-lineNumbers .cm-gutterElement": {
|
|
99
|
+
paddingLeft: "4px",
|
|
100
|
+
paddingRight: "8px"
|
|
101
|
+
},
|
|
102
|
+
".cm-activeLineGutter": { backgroundColor: Z.palette.action.selected },
|
|
103
|
+
".cm-activeLine": { backgroundColor: Z.palette.action.hover },
|
|
104
|
+
"&.cm-focused .cm-selectionBackground, .cm-selectionBackground": { backgroundColor: Z.palette.primary.main + "40" },
|
|
105
|
+
".cm-cursor, .cm-dropCursor": { borderLeftColor: Z.palette.text.primary },
|
|
106
|
+
"&.cm-focused": { outline: "none" },
|
|
107
|
+
".cm-placeholder": {
|
|
108
|
+
color: Z.palette.text.disabled,
|
|
109
|
+
fontStyle: "italic"
|
|
110
|
+
},
|
|
111
|
+
".cm-tooltip": {
|
|
112
|
+
backgroundColor: Z.palette.background.paper,
|
|
113
|
+
border: `1px solid ${Z.palette.divider}`,
|
|
114
|
+
borderRadius: "4px",
|
|
115
|
+
boxShadow: Z.shadows[4]
|
|
116
|
+
},
|
|
117
|
+
".cm-tooltip-autocomplete > ul > li": { color: Z.palette.text.primary },
|
|
118
|
+
".cm-tooltip-autocomplete > ul > li[aria-selected]": {
|
|
119
|
+
backgroundColor: Z.palette.primary.main + "20",
|
|
120
|
+
color: Z.palette.primary.main
|
|
121
|
+
},
|
|
122
|
+
".cm-completionMatchedText": {
|
|
123
|
+
color: Z.palette.primary.main,
|
|
124
|
+
textDecoration: "none",
|
|
125
|
+
fontWeight: "bold"
|
|
126
|
+
},
|
|
127
|
+
".cm-completionDetail": {
|
|
128
|
+
color: Z.palette.text.secondary,
|
|
129
|
+
fontStyle: "italic"
|
|
130
|
+
},
|
|
131
|
+
".cm-gutter-lint": { width: "16px" },
|
|
132
|
+
".cm-lint-marker-error": { color: Z.palette.error.main },
|
|
133
|
+
".cm-lint-marker-warning": { color: Z.palette.warning.main },
|
|
134
|
+
".cm-tooltip.cm-tooltip-lint": {
|
|
135
|
+
backgroundColor: Z.palette.background.paper,
|
|
136
|
+
border: `1px solid ${Z.palette.divider}`,
|
|
137
|
+
borderRadius: "4px"
|
|
138
|
+
},
|
|
139
|
+
".cm-diagnostic-error": { borderLeft: `3px solid ${Z.palette.error.main}` },
|
|
140
|
+
".cm-diagnostic-warning": { borderLeft: `3px solid ${Z.palette.warning.main}` },
|
|
141
|
+
".cm-diagnostic-info": { borderLeft: `3px solid ${Z.palette.info.main}` }
|
|
142
|
+
}, { dark: Q }), y = j ? Object.fromEntries(j.tables.map((e) => [e.name, (e.columns ?? []).map((e) => ({
|
|
143
|
+
label: e.name,
|
|
144
|
+
detail: e.type,
|
|
145
|
+
type: "property"
|
|
146
|
+
}))])) : void 0, M = async (e) => {
|
|
147
|
+
let t = q.current;
|
|
148
|
+
if (!t) return [];
|
|
149
|
+
let n = e.state.doc.toString();
|
|
150
|
+
try {
|
|
151
|
+
let r = (await t(n)).map((t) => {
|
|
152
|
+
let n = Math.max(1, Math.min(t.line, e.state.doc.lines)), r = e.state.doc.line(n);
|
|
153
|
+
return {
|
|
154
|
+
from: r.from + Math.max(0, (t.col ?? 1) - 1),
|
|
155
|
+
to: r.to,
|
|
156
|
+
severity: t.severity ?? "error",
|
|
157
|
+
message: t.message
|
|
158
|
+
};
|
|
159
|
+
});
|
|
160
|
+
return J.current?.(r.length), r;
|
|
161
|
+
} catch {
|
|
162
|
+
return [];
|
|
163
|
+
}
|
|
164
|
+
}, N = s.of([{
|
|
165
|
+
key: "Mod-Enter",
|
|
166
|
+
run: (e) => (K.current?.(e.state.doc.toString()), !0)
|
|
167
|
+
}]), P = [
|
|
168
|
+
_,
|
|
169
|
+
te(u),
|
|
170
|
+
C({
|
|
171
|
+
dialect: T[D],
|
|
172
|
+
schema: y
|
|
173
|
+
}),
|
|
174
|
+
p(),
|
|
175
|
+
re(),
|
|
176
|
+
N,
|
|
177
|
+
s.of([
|
|
178
|
+
...f,
|
|
179
|
+
...m,
|
|
180
|
+
...w
|
|
181
|
+
]),
|
|
182
|
+
Y.current.of(i.editable.of(!x && !S)),
|
|
183
|
+
X.current.of(d.readOnly.of(S)),
|
|
184
|
+
a(),
|
|
185
|
+
...E ? [c(), o()] : [],
|
|
186
|
+
...b ? [l(b)] : [],
|
|
187
|
+
...$ ? [ne(), h(M, { delay: 600 })] : [],
|
|
188
|
+
i.updateListener.of((e) => {
|
|
189
|
+
e.docChanged && V.current?.(e.state.doc.toString());
|
|
190
|
+
let t = e.state.selection.main.head, n = e.state.doc.lineAt(t);
|
|
191
|
+
H.current(n.number, t - n.from + 1);
|
|
192
|
+
}),
|
|
193
|
+
i.domEventHandlers({
|
|
194
|
+
blur: () => {
|
|
195
|
+
U.current?.();
|
|
196
|
+
},
|
|
197
|
+
focus: () => {
|
|
198
|
+
W.current?.();
|
|
199
|
+
}
|
|
200
|
+
})
|
|
201
|
+
], F = new i({
|
|
202
|
+
state: d.create({
|
|
203
|
+
doc: e,
|
|
204
|
+
extensions: P
|
|
205
|
+
}),
|
|
206
|
+
parent: z.current
|
|
207
|
+
});
|
|
208
|
+
return B.current = F, G.current(F), () => {
|
|
209
|
+
G.current(null), F.destroy(), B.current = null;
|
|
210
|
+
};
|
|
211
|
+
}, [
|
|
212
|
+
Q,
|
|
213
|
+
D,
|
|
214
|
+
$,
|
|
215
|
+
O,
|
|
216
|
+
k,
|
|
217
|
+
A,
|
|
218
|
+
ie
|
|
219
|
+
]), e(() => {
|
|
220
|
+
let e = B.current;
|
|
221
|
+
if (!e) return;
|
|
222
|
+
let t = e.state.doc.toString();
|
|
223
|
+
t !== (v ?? "") && e.dispatch({ changes: {
|
|
224
|
+
from: 0,
|
|
225
|
+
to: t.length,
|
|
226
|
+
insert: v ?? ""
|
|
227
|
+
} });
|
|
228
|
+
}, [v]), e(() => {
|
|
229
|
+
B.current?.dispatch({ effects: [Y.current.reconfigure(i.editable.of(!x && !S)), X.current.reconfigure(d.readOnly.of(S))] });
|
|
230
|
+
}, [x, S]), /* @__PURE__ */ _(n, {
|
|
231
|
+
ref: z,
|
|
232
|
+
sx: {
|
|
233
|
+
flex: 1,
|
|
234
|
+
overflow: "hidden",
|
|
235
|
+
display: "flex",
|
|
236
|
+
flexDirection: "column",
|
|
237
|
+
opacity: x ? .5 : 1,
|
|
238
|
+
backgroundColor: Z.palette.background.paper,
|
|
239
|
+
"& .cm-editor": {
|
|
240
|
+
flex: 1,
|
|
241
|
+
display: "flex",
|
|
242
|
+
flexDirection: "column"
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
//#endregion
|
|
248
|
+
export { E as SqlEditorContent };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Box as e, FormHelperText as t } from "@mui/material";
|
|
2
|
+
import { jsx as n, jsxs as r } from "react/jsx-runtime";
|
|
3
|
+
import i from "@mui/icons-material/WarningAmber";
|
|
4
|
+
//#region src/components/sql-editor/SqlEditorFooter.tsx
|
|
5
|
+
function a({ helperText: a, error: o, showLineColumn: s, showErrorCount: c, diagnosticsCount: l, cursorLine: u, cursorCol: d, translation: f }) {
|
|
6
|
+
let p = f.lineColumn.replace("{line}", String(u)).replace("{col}", String(d)), m = f.errorCount.replace("{count}", String(l));
|
|
7
|
+
return /* @__PURE__ */ r(e, {
|
|
8
|
+
sx: {
|
|
9
|
+
display: "flex",
|
|
10
|
+
justifyContent: "space-between",
|
|
11
|
+
alignItems: "flex-start",
|
|
12
|
+
mt: .5,
|
|
13
|
+
px: .5
|
|
14
|
+
},
|
|
15
|
+
children: [/* @__PURE__ */ r(e, { children: [c && l > 0 && /* @__PURE__ */ r(e, {
|
|
16
|
+
sx: {
|
|
17
|
+
display: "flex",
|
|
18
|
+
alignItems: "center",
|
|
19
|
+
gap: .5
|
|
20
|
+
},
|
|
21
|
+
children: [/* @__PURE__ */ n(i, { sx: {
|
|
22
|
+
fontSize: "0.875rem",
|
|
23
|
+
color: "error.main"
|
|
24
|
+
} }), /* @__PURE__ */ n(t, {
|
|
25
|
+
sx: {
|
|
26
|
+
color: "error.main",
|
|
27
|
+
m: 0
|
|
28
|
+
},
|
|
29
|
+
children: m
|
|
30
|
+
})]
|
|
31
|
+
}), /* @__PURE__ */ n(t, {
|
|
32
|
+
error: o,
|
|
33
|
+
children: a ?? ""
|
|
34
|
+
})] }), s && /* @__PURE__ */ n(t, {
|
|
35
|
+
sx: {
|
|
36
|
+
color: "text.disabled",
|
|
37
|
+
fontFamily: "monospace",
|
|
38
|
+
whiteSpace: "nowrap"
|
|
39
|
+
},
|
|
40
|
+
children: p
|
|
41
|
+
})]
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
//#endregion
|
|
45
|
+
export { a as SqlEditorFooter };
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { ToolbarButton as e } from "../shared/ToolbarButton.js";
|
|
2
|
+
import { useState as t } from "react";
|
|
3
|
+
import { Box as n, Divider as r } from "@mui/material";
|
|
4
|
+
import { redo as i, undo as a } from "@codemirror/commands";
|
|
5
|
+
import { Fragment as o, jsx as s, jsxs as c } from "react/jsx-runtime";
|
|
6
|
+
import l from "@mui/icons-material/ContentCopy";
|
|
7
|
+
import u from "@mui/icons-material/Check";
|
|
8
|
+
import d from "@mui/icons-material/Delete";
|
|
9
|
+
import f from "@mui/icons-material/Undo";
|
|
10
|
+
import p from "@mui/icons-material/Redo";
|
|
11
|
+
import m from "@mui/icons-material/AutoFixHigh";
|
|
12
|
+
import h from "@mui/icons-material/PlayArrow";
|
|
13
|
+
import { format as g } from "sql-formatter";
|
|
14
|
+
//#region src/components/sql-editor/SqlEditorToolbar.tsx
|
|
15
|
+
var _ = {
|
|
16
|
+
standard: "sql",
|
|
17
|
+
mysql: "mysql",
|
|
18
|
+
postgresql: "postgresql",
|
|
19
|
+
sqlite: "sqlite",
|
|
20
|
+
mssql: "tsql"
|
|
21
|
+
};
|
|
22
|
+
function v({ editorView: v, toolbarConfig: y, translation: b, dialect: x, disabled: S, onExecute: C }) {
|
|
23
|
+
let [w, T] = t(!1), E = S || !v;
|
|
24
|
+
function D() {
|
|
25
|
+
let e = v?.state.doc.toString() ?? "";
|
|
26
|
+
navigator.clipboard.writeText(e).then(() => {
|
|
27
|
+
T(!0), setTimeout(() => T(!1), 2e3);
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
function O() {
|
|
31
|
+
let e = v;
|
|
32
|
+
e && (e.dispatch({ changes: {
|
|
33
|
+
from: 0,
|
|
34
|
+
to: e.state.doc.length,
|
|
35
|
+
insert: ""
|
|
36
|
+
} }), e.focus());
|
|
37
|
+
}
|
|
38
|
+
function k() {
|
|
39
|
+
let e = v;
|
|
40
|
+
e && (a(e), e.focus());
|
|
41
|
+
}
|
|
42
|
+
function A() {
|
|
43
|
+
let e = v;
|
|
44
|
+
e && (i(e), e.focus());
|
|
45
|
+
}
|
|
46
|
+
function j() {
|
|
47
|
+
let e = v;
|
|
48
|
+
if (!e) return;
|
|
49
|
+
let t = e.state.doc.toString();
|
|
50
|
+
try {
|
|
51
|
+
let n = g(t, { language: _[x] });
|
|
52
|
+
e.dispatch({ changes: {
|
|
53
|
+
from: 0,
|
|
54
|
+
to: e.state.doc.length,
|
|
55
|
+
insert: n
|
|
56
|
+
} });
|
|
57
|
+
} catch {}
|
|
58
|
+
e.focus();
|
|
59
|
+
}
|
|
60
|
+
function M() {
|
|
61
|
+
let e = v;
|
|
62
|
+
!e || !C || C(e.state.doc.toString());
|
|
63
|
+
}
|
|
64
|
+
let N = y.showFormat, P = y.showCopy || y.showClear, F = y.showUndoRedo, I = y.showExecute && !!C;
|
|
65
|
+
return /* @__PURE__ */ c(n, {
|
|
66
|
+
sx: {
|
|
67
|
+
display: "flex",
|
|
68
|
+
flexWrap: "wrap",
|
|
69
|
+
alignItems: "center",
|
|
70
|
+
gap: .25,
|
|
71
|
+
px: 1,
|
|
72
|
+
py: .5
|
|
73
|
+
},
|
|
74
|
+
role: "toolbar",
|
|
75
|
+
"aria-label": "SQL editor actions",
|
|
76
|
+
children: [
|
|
77
|
+
N && /* @__PURE__ */ s(n, {
|
|
78
|
+
sx: {
|
|
79
|
+
display: "flex",
|
|
80
|
+
gap: .25
|
|
81
|
+
},
|
|
82
|
+
children: /* @__PURE__ */ s(e, {
|
|
83
|
+
label: b.format,
|
|
84
|
+
icon: /* @__PURE__ */ s(m, { fontSize: "small" }),
|
|
85
|
+
onClick: j,
|
|
86
|
+
disabled: E
|
|
87
|
+
})
|
|
88
|
+
}),
|
|
89
|
+
N && (P || F) && /* @__PURE__ */ s(r, {
|
|
90
|
+
orientation: "vertical",
|
|
91
|
+
flexItem: !0,
|
|
92
|
+
sx: { mx: .5 }
|
|
93
|
+
}),
|
|
94
|
+
P && /* @__PURE__ */ c(n, {
|
|
95
|
+
sx: {
|
|
96
|
+
display: "flex",
|
|
97
|
+
gap: .25
|
|
98
|
+
},
|
|
99
|
+
children: [y.showCopy && /* @__PURE__ */ s(e, {
|
|
100
|
+
label: w ? b.copySuccess : b.copy,
|
|
101
|
+
icon: w ? /* @__PURE__ */ s(u, {
|
|
102
|
+
fontSize: "small",
|
|
103
|
+
color: "success"
|
|
104
|
+
}) : /* @__PURE__ */ s(l, { fontSize: "small" }),
|
|
105
|
+
onClick: D,
|
|
106
|
+
disabled: E
|
|
107
|
+
}), y.showClear && /* @__PURE__ */ s(e, {
|
|
108
|
+
label: b.clear,
|
|
109
|
+
icon: /* @__PURE__ */ s(d, { fontSize: "small" }),
|
|
110
|
+
onClick: O,
|
|
111
|
+
disabled: E
|
|
112
|
+
})]
|
|
113
|
+
}),
|
|
114
|
+
P && F && /* @__PURE__ */ s(r, {
|
|
115
|
+
orientation: "vertical",
|
|
116
|
+
flexItem: !0,
|
|
117
|
+
sx: { mx: .5 }
|
|
118
|
+
}),
|
|
119
|
+
F && /* @__PURE__ */ c(n, {
|
|
120
|
+
sx: {
|
|
121
|
+
display: "flex",
|
|
122
|
+
gap: .25
|
|
123
|
+
},
|
|
124
|
+
children: [/* @__PURE__ */ s(e, {
|
|
125
|
+
label: b.undo,
|
|
126
|
+
icon: /* @__PURE__ */ s(f, { fontSize: "small" }),
|
|
127
|
+
onClick: k,
|
|
128
|
+
disabled: E
|
|
129
|
+
}), /* @__PURE__ */ s(e, {
|
|
130
|
+
label: b.redo,
|
|
131
|
+
icon: /* @__PURE__ */ s(p, { fontSize: "small" }),
|
|
132
|
+
onClick: A,
|
|
133
|
+
disabled: E
|
|
134
|
+
})]
|
|
135
|
+
}),
|
|
136
|
+
I && /* @__PURE__ */ c(o, { children: [(P || F) && /* @__PURE__ */ s(r, {
|
|
137
|
+
orientation: "vertical",
|
|
138
|
+
flexItem: !0,
|
|
139
|
+
sx: { mx: .5 }
|
|
140
|
+
}), /* @__PURE__ */ s(e, {
|
|
141
|
+
label: b.execute,
|
|
142
|
+
icon: /* @__PURE__ */ s(h, { fontSize: "small" }),
|
|
143
|
+
onClick: M,
|
|
144
|
+
disabled: E
|
|
145
|
+
})] }),
|
|
146
|
+
!N && !P && !F && !I && /* @__PURE__ */ s(n, { sx: { height: 32 } })
|
|
147
|
+
]
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
//#endregion
|
|
151
|
+
export { v as SqlEditorToolbar };
|