@thebuoyant-tsdev/mui-ts-library 3.27.0 → 3.28.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.
@@ -1,43 +1,45 @@
1
1
  import { useEffect as e, useRef as t } from "react";
2
2
  import { Box as n, useTheme as r } from "@mui/material";
3
3
  import { jsx as i } from "react/jsx-runtime";
4
- import { EditorView as a, highlightActiveLine as o, highlightActiveLineGutter as s, keymap as c, lineNumbers as l, placeholder as u } from "@codemirror/view";
5
- import { Compartment as d, EditorState as f } from "@codemirror/state";
6
- import { defaultKeymap as p, history as m, historyKeymap as ee } from "@codemirror/commands";
7
- import { HighlightStyle as te, syntaxHighlighting as ne } from "@codemirror/language";
4
+ import { EditorView as a, highlightActiveLine as ee, highlightActiveLineGutter as te, keymap as o, lineNumbers as s, placeholder as c } from "@codemirror/view";
5
+ import { Compartment as l, EditorState as u } from "@codemirror/state";
6
+ import { defaultKeymap as ne, history as d, historyKeymap as f } from "@codemirror/commands";
7
+ import { HighlightStyle as p, syntaxHighlighting as m } from "@codemirror/language";
8
8
  import { lintGutter as h, linter as g } from "@codemirror/lint";
9
9
  import { tags as _ } from "@lezer/highlight";
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";
10
+ import { MSSQL as v, MySQL as y, PostgreSQL as b, SQLite as x, StandardSQL as S, sql as re } from "@codemirror/lang-sql";
11
+ import { autocompletion as ie, completionKeymap as ae } from "@codemirror/autocomplete";
12
12
  //#region src/components/sql-editor/SqlEditorContent.tsx
13
- var T = {
13
+ var C = {
14
14
  standard: S,
15
15
  mysql: y,
16
16
  postgresql: b,
17
17
  sqlite: x,
18
18
  mssql: v
19
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 d()), X = t(new d()), Z = r(), Q = Z.palette.mode === "dark", $ = !!N, ie = JSON.stringify(j);
20
+ function w({ value: v, onChange: y, placeholder: b, disabled: x = !1, readonly: S = !1, showLineNumbers: w = !0, dialect: T = "standard", keywordColor: E, stringColor: D, identifierColor: O, schema: k, onExecute: A, onFormat: j, onLint: M, onDiagnosticsChange: N, onViewReady: P, onCursorChange: F, onBlur: I, onFocus: L }) {
21
+ let R = t(null), z = t(null), B = t(y), V = t(F), H = t(I), U = t(L), W = t(P), G = t(A), K = t(j), q = t(M), J = t(N), Y = t(new l()), X = t(new l()), Z = r(), Q = Z.palette.mode === "dark", $ = !!M, oe = JSON.stringify(k);
22
22
  return e(() => {
23
- V.current = y;
23
+ B.current = y;
24
24
  }, [y]), e(() => {
25
+ V.current = F;
26
+ }, [F]), e(() => {
25
27
  H.current = I;
26
28
  }, [I]), e(() => {
27
29
  U.current = L;
28
30
  }, [L]), e(() => {
29
- W.current = R;
30
- }, [R]), e(() => {
31
- G.current = F;
32
- }, [F]), e(() => {
33
- K.current = M;
31
+ W.current = P;
32
+ }, [P]), e(() => {
33
+ G.current = A;
34
+ }, [A]), e(() => {
35
+ K.current = j;
36
+ }, [j]), e(() => {
37
+ q.current = M;
34
38
  }, [M]), e(() => {
35
- q.current = N;
39
+ J.current = N;
36
40
  }, [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, i = te.define([
41
+ if (!R.current) return;
42
+ let e = z.current?.state.doc.toString() ?? v ?? "", t = E ?? Z.palette.primary.main, n = D ?? Z.palette.success.main, r = O ?? Z.palette.info.main, i = p.define([
41
43
  {
42
44
  tag: _.keyword,
43
45
  color: t,
@@ -78,7 +80,7 @@ function E({ value: v, onChange: y, placeholder: b, disabled: x = !1, readonly:
78
80
  color: Z.palette.error.main,
79
81
  textDecoration: "underline wavy"
80
82
  }
81
- ]), d = a.theme({
83
+ ]), l = a.theme({
82
84
  "&": {
83
85
  height: "100%",
84
86
  fontFamily: "'Fira Code', 'JetBrains Mono', 'Consolas', monospace",
@@ -139,11 +141,11 @@ function E({ value: v, onChange: y, placeholder: b, disabled: x = !1, readonly:
139
141
  ".cm-diagnostic-error": { borderLeft: `3px solid ${Z.palette.error.main}` },
140
142
  ".cm-diagnostic-warning": { borderLeft: `3px solid ${Z.palette.warning.main}` },
141
143
  ".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) => ({
144
+ }, { dark: Q }), y = k ? Object.fromEntries(k.tables.map((e) => [e.name, (e.columns ?? []).map((e) => ({
143
145
  label: e.name,
144
146
  detail: e.type,
145
147
  type: "property"
146
- }))])) : void 0, M = async (e) => {
148
+ }))])) : void 0, A = async (e) => {
147
149
  let t = q.current;
148
150
  if (!t) return [];
149
151
  let n = e.state.doc.toString();
@@ -161,63 +163,67 @@ function E({ value: v, onChange: y, placeholder: b, disabled: x = !1, readonly:
161
163
  } catch {
162
164
  return [];
163
165
  }
164
- }, N = c.of([{
166
+ }, j = o.of([{
165
167
  key: "Mod-Enter",
166
- run: (e) => (K.current?.(e.state.doc.toString()), !0)
167
- }]), P = [
168
- d,
169
- ne(i),
170
- C({
171
- dialect: T[D],
168
+ run: (e) => (G.current?.(e.state.doc.toString()), !0)
169
+ }]), M = o.of([{
170
+ key: "Shift-Alt-f",
171
+ run: () => (K.current?.(), !0)
172
+ }]), N = [
173
+ l,
174
+ m(i),
175
+ re({
176
+ dialect: C[T],
172
177
  schema: y
173
178
  }),
174
- m(),
175
- re(),
176
- N,
177
- c.of([
178
- ...p,
179
- ...ee,
180
- ...w
179
+ d(),
180
+ ie(),
181
+ j,
182
+ M,
183
+ o.of([
184
+ ...ne,
185
+ ...f,
186
+ ...ae
181
187
  ]),
182
188
  Y.current.of(a.editable.of(!x && !S)),
183
- X.current.of(f.readOnly.of(S)),
184
- o(),
185
- ...E ? [l(), s()] : [],
186
- ...b ? [u(b)] : [],
187
- ...$ ? [h(), g(M, { delay: 600 })] : [],
189
+ X.current.of(u.readOnly.of(S)),
190
+ ee(),
191
+ ...w ? [s(), te()] : [],
192
+ ...b ? [c(b)] : [],
193
+ ...$ ? [h(), g(A, { delay: 600 })] : [],
188
194
  a.updateListener.of((e) => {
189
- e.docChanged && V.current?.(e.state.doc.toString());
195
+ e.docChanged && B.current?.(e.state.doc.toString());
190
196
  let t = e.state.selection.main.head, n = e.state.doc.lineAt(t);
191
- H.current(n.number, t - n.from + 1);
197
+ V.current(n.number, t - n.from + 1);
192
198
  }),
193
199
  a.domEventHandlers({
194
200
  blur: () => {
195
- U.current?.();
201
+ H.current?.();
196
202
  },
197
203
  focus: () => {
198
- W.current?.();
204
+ U.current?.();
199
205
  }
200
206
  })
201
- ], F = new a({
202
- state: f.create({
207
+ ], P = new a({
208
+ state: u.create({
203
209
  doc: e,
204
- extensions: P
210
+ extensions: N
205
211
  }),
206
- parent: z.current
212
+ parent: R.current
207
213
  });
208
- return B.current = F, G.current(F), () => {
209
- G.current(null), F.destroy(), B.current = null;
214
+ return z.current = P, W.current(P), () => {
215
+ W.current(null), P.destroy(), z.current = null;
210
216
  };
211
217
  }, [
212
218
  Q,
213
- D,
219
+ T,
214
220
  $,
221
+ E,
222
+ D,
215
223
  O,
216
- k,
217
- A,
218
- ie
224
+ oe
219
225
  ]), e(() => {
220
- let e = B.current;
226
+ let e = z.current;
221
227
  if (!e) return;
222
228
  let t = e.state.doc.toString();
223
229
  t !== (v ?? "") && e.dispatch({ changes: {
@@ -226,9 +232,9 @@ function E({ value: v, onChange: y, placeholder: b, disabled: x = !1, readonly:
226
232
  insert: v ?? ""
227
233
  } });
228
234
  }, [v]), e(() => {
229
- B.current?.dispatch({ effects: [Y.current.reconfigure(a.editable.of(!x && !S)), X.current.reconfigure(f.readOnly.of(S))] });
235
+ z.current?.dispatch({ effects: [Y.current.reconfigure(a.editable.of(!x && !S)), X.current.reconfigure(u.readOnly.of(S))] });
230
236
  }, [x, S]), /* @__PURE__ */ i(n, {
231
- ref: z,
237
+ ref: R,
232
238
  sx: {
233
239
  flex: 1,
234
240
  overflow: "hidden",
@@ -245,4 +251,4 @@ function E({ value: v, onChange: y, placeholder: b, disabled: x = !1, readonly:
245
251
  });
246
252
  }
247
253
  //#endregion
248
- export { E as SqlEditorContent };
254
+ export { w as SqlEditorContent };
@@ -10,8 +10,8 @@ import f from "@mui/icons-material/Delete";
10
10
  import p from "@mui/icons-material/Undo";
11
11
  import m from "@mui/icons-material/Redo";
12
12
  import h from "@mui/icons-material/AutoFixHigh";
13
- import g from "@mui/icons-material/PlayArrow";
14
- import { format as _ } from "sql-formatter";
13
+ import { format as g } from "sql-formatter";
14
+ import _ from "@mui/icons-material/PlayArrow";
15
15
  //#region src/components/sql-editor/SqlEditorToolbar.tsx
16
16
  var v = {
17
17
  standard: "sql",
@@ -49,7 +49,7 @@ function y({ editorView: y, toolbarConfig: b, translation: x, dialect: S, disabl
49
49
  if (!e) return;
50
50
  let t = e.state.doc.toString();
51
51
  try {
52
- let n = _(t, { language: v[S] });
52
+ let n = g(t, { language: v[S] });
53
53
  e.dispatch({ changes: {
54
54
  from: 0,
55
55
  to: e.state.doc.length,
@@ -151,7 +151,7 @@ function y({ editorView: y, toolbarConfig: b, translation: x, dialect: S, disabl
151
151
  sx: { mx: .5 }
152
152
  }), /* @__PURE__ */ o(e, {
153
153
  label: x.execute,
154
- icon: /* @__PURE__ */ o(g, { fontSize: "small" }),
154
+ icon: /* @__PURE__ */ o(_, { fontSize: "small" }),
155
155
  onClick: I,
156
156
  disabled: A
157
157
  })] }),