@thebuoyant-tsdev/mui-ts-library 3.2.1 → 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.
Files changed (74) hide show
  1. package/README.de.md +31 -0
  2. package/README.md +31 -0
  3. package/dist/components/chord-chart/ChordChart.js +284 -0
  4. package/dist/components/chord-chart/ChordChart.types.js +4 -0
  5. package/dist/components/circle-packing-chart/CirclePackingChart.js +382 -0
  6. package/dist/components/circle-packing-chart/CirclePackingChart.types.js +4 -0
  7. package/dist/components/gantt-chart/GanttBarRow.js +202 -0
  8. package/dist/components/gantt-chart/GanttChart.constants.js +14 -0
  9. package/dist/components/gantt-chart/GanttChart.js +258 -0
  10. package/dist/components/gantt-chart/GanttChart.store.js +119 -0
  11. package/dist/components/gantt-chart/GanttChart.types.js +47 -0
  12. package/dist/components/gantt-chart/GanttDeleteDialog.js +30 -0
  13. package/dist/components/gantt-chart/GanttDependencyArrows.js +54 -0
  14. package/dist/components/gantt-chart/GanttStatusContextMenu.js +36 -0
  15. package/dist/components/gantt-chart/GanttTaskDialog.js +324 -0
  16. package/dist/components/gantt-chart/GanttTaskPanel.js +415 -0
  17. package/dist/components/gantt-chart/GanttTimeline.js +223 -0
  18. package/dist/components/gantt-chart/GanttTimelineHeader.js +90 -0
  19. package/dist/components/gantt-chart/GanttToolbar.js +157 -0
  20. package/dist/components/gantt-chart/GanttWeekendStrips.js +29 -0
  21. package/dist/components/gantt-chart/hooks/useGanttDrag.js +104 -0
  22. package/dist/components/gantt-chart/util/gantt-chart.util.js +150 -0
  23. package/dist/components/horizontal-tree-chart/HorizontalTreeChart.js +488 -0
  24. package/dist/components/horizontal-tree-chart/HorizontalTreeChart.types.js +8 -0
  25. package/dist/components/json-editor/JsonEditor.js +102 -0
  26. package/dist/components/json-editor/JsonEditor.types.js +21 -0
  27. package/dist/components/json-editor/JsonEditorContent.js +185 -0
  28. package/dist/components/json-editor/JsonEditorFooter.js +55 -0
  29. package/dist/components/json-editor/JsonEditorToolbar.js +148 -0
  30. package/dist/components/password-strength-meter/PasswordStrengthBar.js +66 -0
  31. package/dist/components/password-strength-meter/PasswordStrengthMeter.js +272 -0
  32. package/dist/components/password-strength-meter/PasswordStrengthMeter.types.js +27 -0
  33. package/dist/components/password-strength-meter/util/password-strength.util.js +38 -0
  34. package/dist/components/radial-tree-chart/RadialTreeChart.js +447 -0
  35. package/dist/components/radial-tree-chart/RadialTreeChart.types.js +8 -0
  36. package/dist/components/rich-text-editor/RichTextEditor.js +135 -0
  37. package/dist/components/rich-text-editor/RichTextEditor.types.js +74 -0
  38. package/dist/components/rich-text-editor/RichTextEditorColorPicker.js +185 -0
  39. package/dist/components/rich-text-editor/RichTextEditorContent.js +129 -0
  40. package/dist/components/rich-text-editor/RichTextEditorEmojiPicker.js +110 -0
  41. package/dist/components/rich-text-editor/RichTextEditorFooter.js +33 -0
  42. package/dist/components/rich-text-editor/RichTextEditorImageDialog.js +74 -0
  43. package/dist/components/rich-text-editor/RichTextEditorLinkDialog.js +70 -0
  44. package/dist/components/rich-text-editor/RichTextEditorTableMenu.js +97 -0
  45. package/dist/components/rich-text-editor/RichTextEditorToolbar.js +362 -0
  46. package/dist/components/rich-text-editor/util/emojis.js +739 -0
  47. package/dist/components/shared/ToolbarButton.js +22 -0
  48. package/dist/components/shared/normalizeSize.js +6 -0
  49. package/dist/components/sql-editor/SqlEditor.d.ts +1 -1
  50. package/dist/components/sql-editor/SqlEditor.js +113 -0
  51. package/dist/components/sql-editor/SqlEditor.types.d.ts +9 -0
  52. package/dist/components/sql-editor/SqlEditor.types.js +24 -0
  53. package/dist/components/sql-editor/SqlEditorContent.js +248 -0
  54. package/dist/components/sql-editor/SqlEditorFooter.js +45 -0
  55. package/dist/components/sql-editor/SqlEditorHistoryMenu.d.ts +11 -0
  56. package/dist/components/sql-editor/SqlEditorHistoryMenu.js +75 -0
  57. package/dist/components/sql-editor/SqlEditorToolbar.d.ts +5 -1
  58. package/dist/components/sql-editor/SqlEditorToolbar.js +163 -0
  59. package/dist/components/sql-editor/useSqlQueryHistory.d.ts +6 -0
  60. package/dist/components/sql-editor/useSqlQueryHistory.js +20 -0
  61. package/dist/components/sql-editor/util/sqlQueryHistory.util.d.ts +12 -0
  62. package/dist/components/sql-editor/util/sqlQueryHistory.util.js +28 -0
  63. package/dist/components/sunburst-chart/SunburstChart.js +292 -0
  64. package/dist/components/sunburst-chart/SunburstChart.types.js +4 -0
  65. package/dist/components/tag-selection/TagSelection.js +102 -0
  66. package/dist/components/tag-selection/TagSelection.store.js +40 -0
  67. package/dist/components/tag-selection/TagSelection.types.d.ts +2 -0
  68. package/dist/components/tag-selection/TagSelection.types.js +18 -0
  69. package/dist/components/tag-selection/TagSelectionAutocomplete.js +382 -0
  70. package/dist/components/tag-selection/TagSelectionChip.js +30 -0
  71. package/dist/components/tag-selection/TagSelectionSelectedTags.js +73 -0
  72. package/dist/index.cjs +2 -2
  73. package/dist/index.js +23 -8035
  74. 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,6 @@
1
+ //#region src/components/shared/normalizeSize.ts
2
+ function e(e) {
3
+ if (!(e === "" || e === void 0)) return typeof e == "string" && e !== "auto" && !isNaN(Number(e)) ? Number(e) : e;
4
+ }
5
+ //#endregion
6
+ export { e as normalizeSize };
@@ -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;
@@ -0,0 +1,113 @@
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 { 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";
10
+ //#region src/components/sql-editor/SqlEditor.tsx
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 = {
13
+ ...n,
14
+ ...A
15
+ }, B = {
16
+ ...t,
17
+ ...k
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({
19
+ line: 1,
20
+ col: 1
21
+ }), [Q, ne] = l(0), re = s((e) => {
22
+ q.current = e, Y(e);
23
+ }, []), ie = s((e, t) => {
24
+ Z({
25
+ line: e,
26
+ col: t
27
+ });
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, {
41
+ sx: {
42
+ width: W ?? "100%",
43
+ ...G ? {
44
+ display: "flex",
45
+ flexDirection: "column",
46
+ flex: 1
47
+ } : {}
48
+ },
49
+ children: [
50
+ /* @__PURE__ */ h(f, {
51
+ variant: "outlined",
52
+ sx: {
53
+ display: "flex",
54
+ flexDirection: "column",
55
+ overflow: "hidden",
56
+ ...G ? { flex: 1 } : { height: K },
57
+ borderColor: S ? "error.main" : void 0,
58
+ "&:focus-within": {
59
+ borderColor: S ? "error.main" : "primary.main",
60
+ borderWidth: 2
61
+ }
62
+ },
63
+ children: [!x && /* @__PURE__ */ h(p, { children: [/* @__PURE__ */ m(i, {
64
+ editorView: J,
65
+ toolbarConfig: B,
66
+ translation: z,
67
+ dialect: T,
68
+ disabled: b,
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,
77
+ disabled: b,
78
+ readonly: x,
79
+ showLineNumbers: E,
80
+ dialect: T,
81
+ keywordColor: j?.keyword,
82
+ stringColor: j?.string,
83
+ identifierColor: j?.identifier,
84
+ schema: M,
85
+ onExecute: $,
86
+ onLint: I,
87
+ onDiagnosticsChange: I ? ae : void 0,
88
+ onViewReady: re,
89
+ onCursorChange: ie,
90
+ onBlur: L,
91
+ onFocus: R
92
+ })]
93
+ }),
94
+ se && /* @__PURE__ */ m(a, {
95
+ helperText: C,
96
+ error: S,
97
+ showLineColumn: D,
98
+ showErrorCount: O,
99
+ diagnosticsCount: Q,
100
+ cursorLine: X.line,
101
+ cursorCol: X.col,
102
+ translation: z
103
+ }),
104
+ w && /* @__PURE__ */ m("input", {
105
+ type: "hidden",
106
+ name: w,
107
+ value: g ?? ""
108
+ })
109
+ ]
110
+ });
111
+ }
112
+ //#endregion
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;
@@ -0,0 +1,24 @@
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
+ showHistory: !1
9
+ }, t = {
10
+ format: "Format SQL",
11
+ copy: "Copy",
12
+ copySuccess: "Copied!",
13
+ clear: "Clear",
14
+ execute: "Execute",
15
+ undo: "Undo",
16
+ redo: "Redo",
17
+ lineColumn: "Ln {line}, Col {col}",
18
+ errorCount: "{count} error(s)",
19
+ history: "Query history",
20
+ historyEmpty: "No queries yet",
21
+ clearHistory: "Clear history"
22
+ };
23
+ //#endregion
24
+ 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,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 {};