@thebuoyant-tsdev/mui-ts-library 3.4.0 → 3.6.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 +16 -0
- package/README.md +16 -0
- package/dist/components/sql-editor/SqlEditor.d.ts +1 -1
- package/dist/components/sql-editor/SqlEditor.js +56 -43
- package/dist/components/sql-editor/SqlEditor.types.d.ts +9 -0
- package/dist/components/sql-editor/SqlEditor.types.js +6 -2
- package/dist/components/sql-editor/SqlEditorHistoryMenu.d.ts +11 -0
- package/dist/components/sql-editor/SqlEditorHistoryMenu.js +75 -0
- package/dist/components/sql-editor/SqlEditorToolbar.d.ts +5 -1
- package/dist/components/sql-editor/SqlEditorToolbar.js +85 -73
- package/dist/components/sql-editor/useSqlQueryHistory.d.ts +6 -0
- package/dist/components/sql-editor/useSqlQueryHistory.js +20 -0
- package/dist/components/sql-editor/util/sqlQueryHistory.util.d.ts +12 -0
- package/dist/components/sql-editor/util/sqlQueryHistory.util.js +28 -0
- package/dist/index.cjs +2 -2
- package/package.json +1 -1
package/README.de.md
CHANGED
|
@@ -313,6 +313,22 @@ import type {
|
|
|
313
313
|
|
|
314
314
|
## Changelog
|
|
315
315
|
|
|
316
|
+
### [3.6.0] — 2026-06-22
|
|
317
|
+
|
|
318
|
+
**Storybook & StackBlitz — Praxisnahe Vitrine**
|
|
319
|
+
- 17 neue Storybook-Stories über alle 11 Komponenten, jede mit einem komplett anderen, realistischen Datensatz (Festplatten-Analyse, Handelsströme, Bauprojekt-Zeitpläne, Support-Ticket-Routing u.v.m.) statt Prop-Toggle-Varianten auf einer generischen Fixture.
|
|
320
|
+
- StackBlitz-Demo-Karten zeigen jetzt eine Use-Case-Kategorie zur schnellen Einordnung, mit geschärftem Hero-Text.
|
|
321
|
+
|
|
322
|
+
---
|
|
323
|
+
|
|
324
|
+
### [3.5.0] — 2026-06-22
|
|
325
|
+
|
|
326
|
+
**SqlEditor — Query-Verlauf**
|
|
327
|
+
- Neue Option `toolbarConfig.showHistory` speichert jede ausgeführte Abfrage in `localStorage` und lädt sie per Klick wieder. Neue Props: `queryHistoryKey`, `queryHistoryMaxEntries`.
|
|
328
|
+
- D3-Chart-Storybook-Stories demonstrieren jetzt automatisch Drill-down, Zoom und Hover-Highlight beim Laden.
|
|
329
|
+
|
|
330
|
+
---
|
|
331
|
+
|
|
316
332
|
### [3.4.0] — 2026-06-21
|
|
317
333
|
|
|
318
334
|
**Accessibility & Test-Coverage**
|
package/README.md
CHANGED
|
@@ -313,6 +313,22 @@ import type {
|
|
|
313
313
|
|
|
314
314
|
## Changelog
|
|
315
315
|
|
|
316
|
+
### [3.6.0] — 2026-06-22
|
|
317
|
+
|
|
318
|
+
**Storybook & StackBlitz — Real-World Showcase**
|
|
319
|
+
- 17 new Storybook stories across all 11 components, each with a genuinely different, realistic dataset (disk-usage analysis, trade flows, construction schedules, support-ticket routing, and more) instead of prop-toggle variations on one generic fixture.
|
|
320
|
+
- StackBlitz demo cards now show a use-case category for quick orientation, with sharpened hero copy.
|
|
321
|
+
|
|
322
|
+
---
|
|
323
|
+
|
|
324
|
+
### [3.5.0] — 2026-06-22
|
|
325
|
+
|
|
326
|
+
**SqlEditor — Query History**
|
|
327
|
+
- New `toolbarConfig.showHistory` option saves every executed query to `localStorage` and lets you reload it with one click. New props: `queryHistoryKey`, `queryHistoryMaxEntries`.
|
|
328
|
+
- D3 chart Storybook stories now auto-demonstrate drill-down, zoom, and hover-highlight on load.
|
|
329
|
+
|
|
330
|
+
---
|
|
331
|
+
|
|
316
332
|
### [3.4.0] — 2026-06-21
|
|
317
333
|
|
|
318
334
|
**Accessibility & Test Coverage**
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { type SqlEditorProps } from "./SqlEditor.types";
|
|
2
|
-
export declare function SqlEditor({ value, onChange, placeholder, height, width, disabled, readonly, error, helperText, name, dialect, showLineNumbers, showLineColumn, showErrorCount, toolbarConfig, translation, highlightColors, schema, onExecute, onLint, onBlur, onFocus, }: SqlEditorProps): import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
export declare function SqlEditor({ value, onChange, placeholder, height, width, disabled, readonly, error, helperText, name, dialect, showLineNumbers, showLineColumn, showErrorCount, toolbarConfig, translation, highlightColors, schema, queryHistoryKey, queryHistoryMaxEntries, onExecute, onLint, onBlur, onFocus, }: SqlEditorProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -3,64 +3,77 @@ import { DEFAULT_SQL_EDITOR_TOOLBAR_CONFIG as t, DEFAULT_SQL_EDITOR_TRANSLATION
|
|
|
3
3
|
import { SqlEditorContent as r } from "./SqlEditorContent.js";
|
|
4
4
|
import { SqlEditorToolbar as i } from "./SqlEditorToolbar.js";
|
|
5
5
|
import { SqlEditorFooter as a } from "./SqlEditorFooter.js";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
6
|
+
import { useSqlQueryHistory as o } from "./useSqlQueryHistory.js";
|
|
7
|
+
import { useCallback as s, useRef as c, useState as l } from "react";
|
|
8
|
+
import { Box as u, Divider as d, Paper as f } from "@mui/material";
|
|
9
|
+
import { Fragment as p, jsx as m, jsxs as h } from "react/jsx-runtime";
|
|
9
10
|
//#region src/components/sql-editor/SqlEditor.tsx
|
|
10
|
-
function
|
|
11
|
-
let
|
|
11
|
+
function g({ value: g, onChange: _, placeholder: ee, 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, queryHistoryKey: N = "sql-editor-query-history", queryHistoryMaxEntries: P = 20, onExecute: F, onLint: I, onBlur: L, onFocus: R }) {
|
|
12
|
+
let z = {
|
|
12
13
|
...n,
|
|
13
14
|
...A
|
|
14
|
-
},
|
|
15
|
+
}, B = {
|
|
15
16
|
...t,
|
|
16
17
|
...k
|
|
17
|
-
},
|
|
18
|
+
}, { history: te, addEntry: V, clearHistory: H } = o(N, P), U = e(v), W = e(y), G = U === "auto", K = G ? void 0 : U ?? 300, q = c(null), [J, Y] = l(null), [X, Z] = l({
|
|
18
19
|
line: 1,
|
|
19
20
|
col: 1
|
|
20
|
-
}), [
|
|
21
|
-
|
|
22
|
-
}, []),
|
|
23
|
-
|
|
21
|
+
}), [Q, ne] = l(0), re = s((e) => {
|
|
22
|
+
q.current = e, Y(e);
|
|
23
|
+
}, []), ie = s((e, t) => {
|
|
24
|
+
Z({
|
|
24
25
|
line: e,
|
|
25
26
|
col: t
|
|
26
27
|
});
|
|
27
|
-
}, []),
|
|
28
|
-
|
|
29
|
-
}, []), $ =
|
|
30
|
-
|
|
28
|
+
}, []), ae = s((e) => {
|
|
29
|
+
ne(e);
|
|
30
|
+
}, []), $ = F ? (e) => {
|
|
31
|
+
V(e), F(e);
|
|
32
|
+
} : void 0, oe = s((e) => {
|
|
33
|
+
let t = q.current;
|
|
34
|
+
t && (t.dispatch({ changes: {
|
|
35
|
+
from: 0,
|
|
36
|
+
to: t.state.doc.length,
|
|
37
|
+
insert: e
|
|
38
|
+
} }), t.focus()), _?.(e);
|
|
39
|
+
}, [_]), se = D || O || !!C;
|
|
40
|
+
return /* @__PURE__ */ h(u, {
|
|
31
41
|
sx: {
|
|
32
|
-
width:
|
|
33
|
-
...
|
|
42
|
+
width: W ?? "100%",
|
|
43
|
+
...G ? {
|
|
34
44
|
display: "flex",
|
|
35
45
|
flexDirection: "column",
|
|
36
46
|
flex: 1
|
|
37
47
|
} : {}
|
|
38
48
|
},
|
|
39
49
|
children: [
|
|
40
|
-
/* @__PURE__ */
|
|
50
|
+
/* @__PURE__ */ h(f, {
|
|
41
51
|
variant: "outlined",
|
|
42
52
|
sx: {
|
|
43
53
|
display: "flex",
|
|
44
54
|
flexDirection: "column",
|
|
45
55
|
overflow: "hidden",
|
|
46
|
-
...
|
|
56
|
+
...G ? { flex: 1 } : { height: K },
|
|
47
57
|
borderColor: S ? "error.main" : void 0,
|
|
48
58
|
"&:focus-within": {
|
|
49
59
|
borderColor: S ? "error.main" : "primary.main",
|
|
50
60
|
borderWidth: 2
|
|
51
61
|
}
|
|
52
62
|
},
|
|
53
|
-
children: [!x && /* @__PURE__ */
|
|
54
|
-
editorView:
|
|
55
|
-
toolbarConfig:
|
|
56
|
-
translation:
|
|
63
|
+
children: [!x && /* @__PURE__ */ h(p, { children: [/* @__PURE__ */ m(i, {
|
|
64
|
+
editorView: J,
|
|
65
|
+
toolbarConfig: B,
|
|
66
|
+
translation: z,
|
|
57
67
|
dialect: T,
|
|
58
68
|
disabled: b,
|
|
59
|
-
onExecute:
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
69
|
+
onExecute: $,
|
|
70
|
+
queryHistory: te,
|
|
71
|
+
onSelectHistoryEntry: oe,
|
|
72
|
+
onClearHistory: H
|
|
73
|
+
}), /* @__PURE__ */ m(d, {})] }), /* @__PURE__ */ m(r, {
|
|
74
|
+
value: g,
|
|
75
|
+
onChange: _,
|
|
76
|
+
placeholder: ee,
|
|
64
77
|
disabled: b,
|
|
65
78
|
readonly: x,
|
|
66
79
|
showLineNumbers: E,
|
|
@@ -69,32 +82,32 @@ function h({ value: h, onChange: g, placeholder: _, height: v, width: y, disable
|
|
|
69
82
|
stringColor: j?.string,
|
|
70
83
|
identifierColor: j?.identifier,
|
|
71
84
|
schema: M,
|
|
72
|
-
onExecute:
|
|
73
|
-
onLint:
|
|
74
|
-
onDiagnosticsChange:
|
|
75
|
-
onViewReady:
|
|
76
|
-
onCursorChange:
|
|
77
|
-
onBlur:
|
|
78
|
-
onFocus:
|
|
85
|
+
onExecute: $,
|
|
86
|
+
onLint: I,
|
|
87
|
+
onDiagnosticsChange: I ? ae : void 0,
|
|
88
|
+
onViewReady: re,
|
|
89
|
+
onCursorChange: ie,
|
|
90
|
+
onBlur: L,
|
|
91
|
+
onFocus: R
|
|
79
92
|
})]
|
|
80
93
|
}),
|
|
81
|
-
|
|
94
|
+
se && /* @__PURE__ */ m(a, {
|
|
82
95
|
helperText: C,
|
|
83
96
|
error: S,
|
|
84
97
|
showLineColumn: D,
|
|
85
98
|
showErrorCount: O,
|
|
86
|
-
diagnosticsCount:
|
|
87
|
-
cursorLine:
|
|
88
|
-
cursorCol:
|
|
89
|
-
translation:
|
|
99
|
+
diagnosticsCount: Q,
|
|
100
|
+
cursorLine: X.line,
|
|
101
|
+
cursorCol: X.col,
|
|
102
|
+
translation: z
|
|
90
103
|
}),
|
|
91
|
-
w && /* @__PURE__ */
|
|
104
|
+
w && /* @__PURE__ */ m("input", {
|
|
92
105
|
type: "hidden",
|
|
93
106
|
name: w,
|
|
94
|
-
value:
|
|
107
|
+
value: g ?? ""
|
|
95
108
|
})
|
|
96
109
|
]
|
|
97
110
|
});
|
|
98
111
|
}
|
|
99
112
|
//#endregion
|
|
100
|
-
export {
|
|
113
|
+
export { g as SqlEditor };
|
|
@@ -10,6 +10,8 @@ export type SqlEditorToolbarConfig = {
|
|
|
10
10
|
showClear?: boolean;
|
|
11
11
|
showExecute?: boolean;
|
|
12
12
|
showUndoRedo?: boolean;
|
|
13
|
+
/** Shows a "Query history" button — requires `onExecute` to be set (default: false). */
|
|
14
|
+
showHistory?: boolean;
|
|
13
15
|
};
|
|
14
16
|
export declare const DEFAULT_SQL_EDITOR_TOOLBAR_CONFIG: Required<SqlEditorToolbarConfig>;
|
|
15
17
|
export type SqlEditorTranslation = {
|
|
@@ -22,6 +24,9 @@ export type SqlEditorTranslation = {
|
|
|
22
24
|
redo: string;
|
|
23
25
|
lineColumn: string;
|
|
24
26
|
errorCount: string;
|
|
27
|
+
history: string;
|
|
28
|
+
historyEmpty: string;
|
|
29
|
+
clearHistory: string;
|
|
25
30
|
};
|
|
26
31
|
export declare const DEFAULT_SQL_EDITOR_TRANSLATION: SqlEditorTranslation;
|
|
27
32
|
export type SqlEditorDialect = "standard" | "mysql" | "postgresql" | "sqlite" | "mssql";
|
|
@@ -55,6 +60,10 @@ export type SqlEditorProps = {
|
|
|
55
60
|
/** Name for native form submission via hidden input. */
|
|
56
61
|
name?: string;
|
|
57
62
|
placeholder?: string;
|
|
63
|
+
/** localStorage key for the query history — set a unique value if multiple SqlEditors run on the same page (default: "sql-editor-query-history"). */
|
|
64
|
+
queryHistoryKey?: string;
|
|
65
|
+
/** Maximum number of entries kept in the query history (default: 20). */
|
|
66
|
+
queryHistoryMaxEntries?: number;
|
|
58
67
|
readonly?: boolean;
|
|
59
68
|
schema?: SqlSchema;
|
|
60
69
|
showErrorCount?: boolean;
|
|
@@ -4,7 +4,8 @@ var e = {
|
|
|
4
4
|
showCopy: !0,
|
|
5
5
|
showClear: !0,
|
|
6
6
|
showExecute: !1,
|
|
7
|
-
showUndoRedo: !0
|
|
7
|
+
showUndoRedo: !0,
|
|
8
|
+
showHistory: !1
|
|
8
9
|
}, t = {
|
|
9
10
|
format: "Format SQL",
|
|
10
11
|
copy: "Copy",
|
|
@@ -14,7 +15,10 @@ var e = {
|
|
|
14
15
|
undo: "Undo",
|
|
15
16
|
redo: "Redo",
|
|
16
17
|
lineColumn: "Ln {line}, Col {col}",
|
|
17
|
-
errorCount: "{count} error(s)"
|
|
18
|
+
errorCount: "{count} error(s)",
|
|
19
|
+
history: "Query history",
|
|
20
|
+
historyEmpty: "No queries yet",
|
|
21
|
+
clearHistory: "Clear history"
|
|
18
22
|
};
|
|
19
23
|
//#endregion
|
|
20
24
|
export { e as DEFAULT_SQL_EDITOR_TOOLBAR_CONFIG, t as DEFAULT_SQL_EDITOR_TRANSLATION };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { SqlEditorTranslation } from "./SqlEditor.types";
|
|
2
|
+
import type { SqlQueryHistoryEntry } from "./util/sqlQueryHistory.util";
|
|
3
|
+
type SqlEditorHistoryMenuProps = {
|
|
4
|
+
history: SqlQueryHistoryEntry[];
|
|
5
|
+
onSelect: (sql: string) => void;
|
|
6
|
+
onClear: () => void;
|
|
7
|
+
translation: SqlEditorTranslation;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
};
|
|
10
|
+
export declare function SqlEditorHistoryMenu({ history, onSelect, onClear, translation: t, disabled, }: SqlEditorHistoryMenuProps): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { useState as e } from "react";
|
|
2
|
+
import { Divider as t, IconButton as n, ListItemIcon as r, ListItemText as i, Menu as a, MenuItem as o, Tooltip as s, Typography as c } from "@mui/material";
|
|
3
|
+
import { Fragment as l, jsx as u, jsxs as d } from "react/jsx-runtime";
|
|
4
|
+
import f from "@mui/icons-material/History";
|
|
5
|
+
import p from "@mui/icons-material/DeleteSweep";
|
|
6
|
+
//#region src/components/sql-editor/SqlEditorHistoryMenu.tsx
|
|
7
|
+
function m(e, t = 60) {
|
|
8
|
+
let n = e.replace(/\s+/g, " ").trim();
|
|
9
|
+
return n.length > t ? `${n.slice(0, t)}…` : n;
|
|
10
|
+
}
|
|
11
|
+
function h({ history: h, onSelect: g, onClear: _, translation: v, disabled: y }) {
|
|
12
|
+
let [b, x] = e(null);
|
|
13
|
+
function S() {
|
|
14
|
+
x(null);
|
|
15
|
+
}
|
|
16
|
+
function C(e) {
|
|
17
|
+
g(e), S();
|
|
18
|
+
}
|
|
19
|
+
function w() {
|
|
20
|
+
_(), S();
|
|
21
|
+
}
|
|
22
|
+
return /* @__PURE__ */ d(l, { children: [/* @__PURE__ */ u(s, {
|
|
23
|
+
title: v.history,
|
|
24
|
+
arrow: !0,
|
|
25
|
+
children: /* @__PURE__ */ u("span", { children: /* @__PURE__ */ u(n, {
|
|
26
|
+
size: "small",
|
|
27
|
+
onClick: (e) => x(e.currentTarget),
|
|
28
|
+
disabled: y,
|
|
29
|
+
"aria-label": v.history,
|
|
30
|
+
children: /* @__PURE__ */ u(f, { fontSize: "small" })
|
|
31
|
+
}) })
|
|
32
|
+
}), /* @__PURE__ */ d(a, {
|
|
33
|
+
anchorEl: b,
|
|
34
|
+
open: !!b,
|
|
35
|
+
onClose: S,
|
|
36
|
+
slotProps: { paper: { sx: {
|
|
37
|
+
minWidth: 280,
|
|
38
|
+
maxWidth: 400
|
|
39
|
+
} } },
|
|
40
|
+
children: [
|
|
41
|
+
h.length === 0 && /* @__PURE__ */ u(o, {
|
|
42
|
+
disabled: !0,
|
|
43
|
+
children: /* @__PURE__ */ u(i, { children: v.historyEmpty })
|
|
44
|
+
}),
|
|
45
|
+
h.map((e) => /* @__PURE__ */ u(o, {
|
|
46
|
+
onClick: () => C(e.sql),
|
|
47
|
+
children: /* @__PURE__ */ u(i, {
|
|
48
|
+
primary: m(e.sql),
|
|
49
|
+
secondary: /* @__PURE__ */ u(c, {
|
|
50
|
+
variant: "caption",
|
|
51
|
+
color: "text.secondary",
|
|
52
|
+
children: new Date(e.timestamp).toLocaleString()
|
|
53
|
+
}),
|
|
54
|
+
slotProps: { primary: { sx: {
|
|
55
|
+
fontFamily: "monospace",
|
|
56
|
+
fontSize: "0.8125rem"
|
|
57
|
+
} } }
|
|
58
|
+
})
|
|
59
|
+
}, e.timestamp)),
|
|
60
|
+
h.length > 0 && /* @__PURE__ */ u(t, {}),
|
|
61
|
+
h.length > 0 && /* @__PURE__ */ d(o, {
|
|
62
|
+
onClick: w,
|
|
63
|
+
children: [/* @__PURE__ */ u(r, { children: /* @__PURE__ */ u(p, {
|
|
64
|
+
fontSize: "small",
|
|
65
|
+
color: "error"
|
|
66
|
+
}) }), /* @__PURE__ */ u(i, {
|
|
67
|
+
sx: { color: "error.main" },
|
|
68
|
+
children: v.clearHistory
|
|
69
|
+
})]
|
|
70
|
+
})
|
|
71
|
+
]
|
|
72
|
+
})] });
|
|
73
|
+
}
|
|
74
|
+
//#endregion
|
|
75
|
+
export { h as SqlEditorHistoryMenu };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { EditorView } from "@codemirror/view";
|
|
2
2
|
import type { SqlEditorDialect, SqlEditorToolbarConfig, SqlEditorTranslation } from "./SqlEditor.types";
|
|
3
|
+
import type { SqlQueryHistoryEntry } from "./util/sqlQueryHistory.util";
|
|
3
4
|
type SqlEditorToolbarProps = {
|
|
4
5
|
editorView: EditorView | null;
|
|
5
6
|
toolbarConfig: Required<SqlEditorToolbarConfig>;
|
|
@@ -7,6 +8,9 @@ type SqlEditorToolbarProps = {
|
|
|
7
8
|
dialect: SqlEditorDialect;
|
|
8
9
|
disabled?: boolean;
|
|
9
10
|
onExecute?: (sql: string) => void;
|
|
11
|
+
queryHistory?: SqlQueryHistoryEntry[];
|
|
12
|
+
onSelectHistoryEntry?: (sql: string) => void;
|
|
13
|
+
onClearHistory?: () => void;
|
|
10
14
|
};
|
|
11
|
-
export declare function SqlEditorToolbar({ editorView, toolbarConfig: tc, translation: t, dialect, disabled, onExecute, }: SqlEditorToolbarProps): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export declare function SqlEditorToolbar({ editorView, toolbarConfig: tc, translation: t, dialect, disabled, onExecute, queryHistory, onSelectHistoryEntry, onClearHistory, }: SqlEditorToolbarProps): import("react/jsx-runtime").JSX.Element;
|
|
12
16
|
export {};
|
|
@@ -1,54 +1,55 @@
|
|
|
1
1
|
import { ToolbarButton as e } from "../shared/ToolbarButton.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import l from "
|
|
7
|
-
import u from "@mui/icons-material/
|
|
8
|
-
import d from "@mui/icons-material/
|
|
9
|
-
import f from "@mui/icons-material/
|
|
10
|
-
import p from "@mui/icons-material/
|
|
11
|
-
import m from "@mui/icons-material/
|
|
12
|
-
import h from "@mui/icons-material/
|
|
13
|
-
import
|
|
2
|
+
import { SqlEditorHistoryMenu as t } from "./SqlEditorHistoryMenu.js";
|
|
3
|
+
import { useState as n } from "react";
|
|
4
|
+
import { Box as r, Divider as i } from "@mui/material";
|
|
5
|
+
import { redo as a, undo as o } from "@codemirror/commands";
|
|
6
|
+
import { Fragment as s, jsx as c, jsxs as l } from "react/jsx-runtime";
|
|
7
|
+
import u from "@mui/icons-material/ContentCopy";
|
|
8
|
+
import d from "@mui/icons-material/Check";
|
|
9
|
+
import f from "@mui/icons-material/Delete";
|
|
10
|
+
import p from "@mui/icons-material/Undo";
|
|
11
|
+
import m from "@mui/icons-material/Redo";
|
|
12
|
+
import h from "@mui/icons-material/AutoFixHigh";
|
|
13
|
+
import g from "@mui/icons-material/PlayArrow";
|
|
14
|
+
import { format as _ } from "sql-formatter";
|
|
14
15
|
//#region src/components/sql-editor/SqlEditorToolbar.tsx
|
|
15
|
-
var
|
|
16
|
+
var v = {
|
|
16
17
|
standard: "sql",
|
|
17
18
|
mysql: "mysql",
|
|
18
19
|
postgresql: "postgresql",
|
|
19
20
|
sqlite: "sqlite",
|
|
20
21
|
mssql: "tsql"
|
|
21
22
|
};
|
|
22
|
-
function
|
|
23
|
-
let [
|
|
24
|
-
function
|
|
25
|
-
let e =
|
|
23
|
+
function y({ editorView: y, toolbarConfig: b, translation: x, dialect: S, disabled: C, onExecute: w, queryHistory: T = [], onSelectHistoryEntry: E, onClearHistory: D }) {
|
|
24
|
+
let [O, k] = n(!1), A = C || !y;
|
|
25
|
+
function j() {
|
|
26
|
+
let e = y?.state.doc.toString() ?? "";
|
|
26
27
|
navigator.clipboard.writeText(e).then(() => {
|
|
27
|
-
|
|
28
|
+
k(!0), setTimeout(() => k(!1), 2e3);
|
|
28
29
|
});
|
|
29
30
|
}
|
|
30
|
-
function
|
|
31
|
-
let e =
|
|
31
|
+
function M() {
|
|
32
|
+
let e = y;
|
|
32
33
|
e && (e.dispatch({ changes: {
|
|
33
34
|
from: 0,
|
|
34
35
|
to: e.state.doc.length,
|
|
35
36
|
insert: ""
|
|
36
37
|
} }), e.focus());
|
|
37
38
|
}
|
|
38
|
-
function
|
|
39
|
-
let e =
|
|
40
|
-
e && (
|
|
39
|
+
function N() {
|
|
40
|
+
let e = y;
|
|
41
|
+
e && (o(e), e.focus());
|
|
41
42
|
}
|
|
42
|
-
function
|
|
43
|
-
let e =
|
|
44
|
-
e && (
|
|
43
|
+
function P() {
|
|
44
|
+
let e = y;
|
|
45
|
+
e && (a(e), e.focus());
|
|
45
46
|
}
|
|
46
|
-
function
|
|
47
|
-
let e =
|
|
47
|
+
function F() {
|
|
48
|
+
let e = y;
|
|
48
49
|
if (!e) return;
|
|
49
50
|
let t = e.state.doc.toString();
|
|
50
51
|
try {
|
|
51
|
-
let n =
|
|
52
|
+
let n = _(t, { language: v[S] });
|
|
52
53
|
e.dispatch({ changes: {
|
|
53
54
|
from: 0,
|
|
54
55
|
to: e.state.doc.length,
|
|
@@ -57,12 +58,12 @@ function v({ editorView: v, toolbarConfig: y, translation: b, dialect: x, disabl
|
|
|
57
58
|
} catch {}
|
|
58
59
|
e.focus();
|
|
59
60
|
}
|
|
60
|
-
function
|
|
61
|
-
let e =
|
|
62
|
-
!e || !
|
|
61
|
+
function I() {
|
|
62
|
+
let e = y;
|
|
63
|
+
!e || !w || w(e.state.doc.toString());
|
|
63
64
|
}
|
|
64
|
-
let
|
|
65
|
-
return /* @__PURE__ */
|
|
65
|
+
let L = b.showFormat, R = b.showCopy || b.showClear, z = b.showUndoRedo, B = b.showExecute && !!w, V = b.showHistory && !!w && !!E && !!D;
|
|
66
|
+
return /* @__PURE__ */ l(r, {
|
|
66
67
|
sx: {
|
|
67
68
|
display: "flex",
|
|
68
69
|
flexWrap: "wrap",
|
|
@@ -74,78 +75,89 @@ function v({ editorView: v, toolbarConfig: y, translation: b, dialect: x, disabl
|
|
|
74
75
|
role: "toolbar",
|
|
75
76
|
"aria-label": "SQL editor actions",
|
|
76
77
|
children: [
|
|
77
|
-
|
|
78
|
+
L && /* @__PURE__ */ c(r, {
|
|
78
79
|
sx: {
|
|
79
80
|
display: "flex",
|
|
80
81
|
gap: .25
|
|
81
82
|
},
|
|
82
|
-
children: /* @__PURE__ */
|
|
83
|
-
label:
|
|
84
|
-
icon: /* @__PURE__ */
|
|
85
|
-
onClick:
|
|
86
|
-
disabled:
|
|
83
|
+
children: /* @__PURE__ */ c(e, {
|
|
84
|
+
label: x.format,
|
|
85
|
+
icon: /* @__PURE__ */ c(h, { fontSize: "small" }),
|
|
86
|
+
onClick: F,
|
|
87
|
+
disabled: A
|
|
87
88
|
})
|
|
88
89
|
}),
|
|
89
|
-
|
|
90
|
+
L && (R || z) && /* @__PURE__ */ c(i, {
|
|
90
91
|
orientation: "vertical",
|
|
91
92
|
flexItem: !0,
|
|
92
93
|
sx: { mx: .5 }
|
|
93
94
|
}),
|
|
94
|
-
|
|
95
|
+
R && /* @__PURE__ */ l(r, {
|
|
95
96
|
sx: {
|
|
96
97
|
display: "flex",
|
|
97
98
|
gap: .25
|
|
98
99
|
},
|
|
99
|
-
children: [
|
|
100
|
-
label:
|
|
101
|
-
icon:
|
|
100
|
+
children: [b.showCopy && /* @__PURE__ */ c(e, {
|
|
101
|
+
label: O ? x.copySuccess : x.copy,
|
|
102
|
+
icon: O ? /* @__PURE__ */ c(d, {
|
|
102
103
|
fontSize: "small",
|
|
103
104
|
color: "success"
|
|
104
|
-
}) : /* @__PURE__ */
|
|
105
|
-
onClick:
|
|
106
|
-
disabled:
|
|
107
|
-
}),
|
|
108
|
-
label:
|
|
109
|
-
icon: /* @__PURE__ */
|
|
110
|
-
onClick:
|
|
111
|
-
disabled:
|
|
105
|
+
}) : /* @__PURE__ */ c(u, { fontSize: "small" }),
|
|
106
|
+
onClick: j,
|
|
107
|
+
disabled: A
|
|
108
|
+
}), b.showClear && /* @__PURE__ */ c(e, {
|
|
109
|
+
label: x.clear,
|
|
110
|
+
icon: /* @__PURE__ */ c(f, { fontSize: "small" }),
|
|
111
|
+
onClick: M,
|
|
112
|
+
disabled: A
|
|
112
113
|
})]
|
|
113
114
|
}),
|
|
114
|
-
|
|
115
|
+
R && z && /* @__PURE__ */ c(i, {
|
|
115
116
|
orientation: "vertical",
|
|
116
117
|
flexItem: !0,
|
|
117
118
|
sx: { mx: .5 }
|
|
118
119
|
}),
|
|
119
|
-
|
|
120
|
+
z && /* @__PURE__ */ l(r, {
|
|
120
121
|
sx: {
|
|
121
122
|
display: "flex",
|
|
122
123
|
gap: .25
|
|
123
124
|
},
|
|
124
|
-
children: [/* @__PURE__ */
|
|
125
|
-
label:
|
|
126
|
-
icon: /* @__PURE__ */
|
|
127
|
-
onClick:
|
|
128
|
-
disabled:
|
|
129
|
-
}), /* @__PURE__ */
|
|
130
|
-
label:
|
|
131
|
-
icon: /* @__PURE__ */
|
|
132
|
-
onClick:
|
|
133
|
-
disabled:
|
|
125
|
+
children: [/* @__PURE__ */ c(e, {
|
|
126
|
+
label: x.undo,
|
|
127
|
+
icon: /* @__PURE__ */ c(p, { fontSize: "small" }),
|
|
128
|
+
onClick: N,
|
|
129
|
+
disabled: A
|
|
130
|
+
}), /* @__PURE__ */ c(e, {
|
|
131
|
+
label: x.redo,
|
|
132
|
+
icon: /* @__PURE__ */ c(m, { fontSize: "small" }),
|
|
133
|
+
onClick: P,
|
|
134
|
+
disabled: A
|
|
134
135
|
})]
|
|
135
136
|
}),
|
|
136
|
-
|
|
137
|
+
V && /* @__PURE__ */ l(s, { children: [(R || z) && /* @__PURE__ */ c(i, {
|
|
138
|
+
orientation: "vertical",
|
|
139
|
+
flexItem: !0,
|
|
140
|
+
sx: { mx: .5 }
|
|
141
|
+
}), /* @__PURE__ */ c(t, {
|
|
142
|
+
history: T,
|
|
143
|
+
onSelect: E,
|
|
144
|
+
onClear: D,
|
|
145
|
+
translation: x,
|
|
146
|
+
disabled: C
|
|
147
|
+
})] }),
|
|
148
|
+
B && /* @__PURE__ */ l(s, { children: [(R || z || V) && /* @__PURE__ */ c(i, {
|
|
137
149
|
orientation: "vertical",
|
|
138
150
|
flexItem: !0,
|
|
139
151
|
sx: { mx: .5 }
|
|
140
|
-
}), /* @__PURE__ */
|
|
141
|
-
label:
|
|
142
|
-
icon: /* @__PURE__ */
|
|
143
|
-
onClick:
|
|
144
|
-
disabled:
|
|
152
|
+
}), /* @__PURE__ */ c(e, {
|
|
153
|
+
label: x.execute,
|
|
154
|
+
icon: /* @__PURE__ */ c(g, { fontSize: "small" }),
|
|
155
|
+
onClick: I,
|
|
156
|
+
disabled: A
|
|
145
157
|
})] }),
|
|
146
|
-
!
|
|
158
|
+
!L && !R && !z && !V && !B && /* @__PURE__ */ c(r, { sx: { height: 32 } })
|
|
147
159
|
]
|
|
148
160
|
});
|
|
149
161
|
}
|
|
150
162
|
//#endregion
|
|
151
|
-
export {
|
|
163
|
+
export { y as SqlEditorToolbar };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { addQueryToHistory as e, loadQueryHistory as t, saveQueryHistory as n } from "./util/sqlQueryHistory.util.js";
|
|
2
|
+
import { useCallback as r, useState as i } from "react";
|
|
3
|
+
//#region src/components/sql-editor/useSqlQueryHistory.ts
|
|
4
|
+
function a(a, o) {
|
|
5
|
+
let [s, c] = i(() => t(a));
|
|
6
|
+
return {
|
|
7
|
+
history: s,
|
|
8
|
+
addEntry: r((t) => {
|
|
9
|
+
c((r) => {
|
|
10
|
+
let i = e(r, t, o);
|
|
11
|
+
return n(a, i), i;
|
|
12
|
+
});
|
|
13
|
+
}, [a, o]),
|
|
14
|
+
clearHistory: r(() => {
|
|
15
|
+
c([]), n(a, []);
|
|
16
|
+
}, [a])
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
export { a as useSqlQueryHistory };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type SqlQueryHistoryEntry = {
|
|
2
|
+
sql: string;
|
|
3
|
+
timestamp: number;
|
|
4
|
+
};
|
|
5
|
+
export declare function loadQueryHistory(storageKey: string): SqlQueryHistoryEntry[];
|
|
6
|
+
export declare function saveQueryHistory(storageKey: string, history: SqlQueryHistoryEntry[]): void;
|
|
7
|
+
/**
|
|
8
|
+
* Adds a new entry to the front of the history. An existing entry with the
|
|
9
|
+
* same SQL is moved to the front instead of duplicated. Result is capped at
|
|
10
|
+
* maxEntries.
|
|
11
|
+
*/
|
|
12
|
+
export declare function addQueryToHistory(history: SqlQueryHistoryEntry[], sql: string, maxEntries: number): SqlQueryHistoryEntry[];
|