@code0-tech/pictor 0.5.0 → 0.5.1

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.
@@ -2,7 +2,7 @@ import { default as React } from 'react';
2
2
  import { Code0Component } from '../../utils';
3
3
  import { ValidationProps } from '../form';
4
4
  import { Extension } from '@uiw/react-codemirror';
5
- import { StreamLanguage } from '@codemirror/language';
5
+ import { StreamLanguage, TagStyle } from '@codemirror/language';
6
6
  import { CompletionContext, CompletionResult } from '@codemirror/autocomplete';
7
7
  import { BasicSetupOptions } from '@uiw/codemirror-extensions-basic-setup';
8
8
  export type EditorTokenizer = (content: string) => string | null;
@@ -24,6 +24,8 @@ export interface EditorInputProps extends Omit<Code0Component<HTMLDivElement>, '
24
24
  readonly?: boolean;
25
25
  showTooltips?: boolean;
26
26
  showValidation?: boolean;
27
+ formatter?: (value: string) => Promise<string>;
27
28
  basicSetup?: BasicSetupOptions;
29
+ tokenStyles?: TagStyle[];
28
30
  }
29
31
  export declare const Editor: React.FC<EditorInputProps>;
@@ -1,337 +1,325 @@
1
- import { jsxs as s, jsx as t } from "react/jsx-runtime";
2
- import m, { isValidElement as ce } from "react";
1
+ import { jsxs as s, jsx as r } from "react/jsx-runtime";
2
+ import m, { isValidElement as me } from "react";
3
3
  import { createPortal as K } from "react-dom";
4
4
  import "../../utils/contextStore.js";
5
- import { hashToColor as b, mergeCode0Props as ue } from "../../utils/utils.js";
6
- import de, { Prec as _, keymap as J, ViewPlugin as me, RangeSetBuilder as he, Decoration as F, EditorView as fe, WidgetType as ge } from "@uiw/react-codemirror";
7
- import { json as pe, jsonParseLinter as ye } from "@codemirror/lang-json";
5
+ import { hashToColor as w, mergeCode0Props as he } from "../../utils/utils.js";
6
+ import fe, { Prec as _, keymap as J, ViewPlugin as ge, RangeSetBuilder as pe, Decoration as F, EditorView as ye, WidgetType as be } from "@uiw/react-codemirror";
7
+ import { json as ve, jsonParseLinter as Se } from "@codemirror/lang-json";
8
8
  import { syntaxTree as L } from "@codemirror/language";
9
- import { linter as be } from "@codemirror/lint";
10
- import ve from "../../node_modules/prettier/standalone.js";
11
- import we from "../../node_modules/prettier/plugins/babel.js";
12
- import Se from "../../node_modules/prettier/plugins/estree.js";
13
- import { createTheme as Ce } from "@uiw/codemirror-themes";
14
- import { tags as v, getStyleTags as Te } from "../../node_modules/@lezer/highlight/dist/index.js";
9
+ import { linter as we } from "@codemirror/lint";
10
+ import Ce from "../../node_modules/prettier/standalone.js";
11
+ import Te from "../../node_modules/prettier/plugins/babel.js";
12
+ import xe from "../../node_modules/prettier/plugins/estree.js";
13
+ import { createTheme as Ae } from "@uiw/codemirror-themes";
14
+ import { getStyleTags as ke, tags as C } from "../../node_modules/@lezer/highlight/dist/index.js";
15
15
  import '../../assets/components/editor/Editor.styles.css';/* empty css */
16
- import { Badge as y } from "../badge/Badge.js";
17
- import { IconExclamationCircle as Ae, IconAlertTriangle as xe, IconAlertSquareRounded as ke, IconInfoCircle as Ee, IconSpace as ze, IconArrowBarToRight as Pe, IconCornerDownLeft as je } from "@tabler/icons-react";
16
+ import { Badge as b } from "../badge/Badge.js";
17
+ import { IconExclamationCircle as ze, IconAlertTriangle as je, IconAlertSquareRounded as Pe, IconInfoCircle as Ee, IconSpace as Ve, IconArrowBarToRight as Ne, IconCornerDownLeft as Ie } from "@tabler/icons-react";
18
18
  import { Text as a } from "../text/Text.js";
19
- import { Flex as k } from "../flex/Flex.js";
20
- import { Tooltip as E, TooltipTrigger as z, TooltipPortal as P, TooltipContent as j, TooltipArrow as V } from "../tooltip/Tooltip.js";
21
- import { ScrollArea as Ve, ScrollAreaViewport as Ne, ScrollAreaScrollbar as G, ScrollAreaThumb as Q } from "../scroll-area/ScrollArea.js";
22
- import { autocompletion as Ie, acceptCompletion as Re, startCompletion as N } from "@codemirror/autocomplete";
23
- function Be(i, r, h) {
24
- return (r = Me(r)) in i ? Object.defineProperty(i, r, { value: h, enumerable: !0, configurable: !0, writable: !0 }) : i[r] = h, i;
19
+ import { Flex as x } from "../flex/Flex.js";
20
+ import { Tooltip as A, TooltipTrigger as k, TooltipPortal as z, TooltipContent as j, TooltipArrow as P } from "../tooltip/Tooltip.js";
21
+ import { ScrollArea as Re, ScrollAreaViewport as Me, ScrollAreaScrollbar as G, ScrollAreaThumb as Q } from "../scroll-area/ScrollArea.js";
22
+ import { autocompletion as Be, acceptCompletion as Fe, startCompletion as E } from "@codemirror/autocomplete";
23
+ function Oe(i, t, f) {
24
+ return (t = qe(t)) in i ? Object.defineProperty(i, t, { value: f, enumerable: !0, configurable: !0, writable: !0 }) : i[t] = f, i;
25
25
  }
26
- function Me(i) {
27
- var r = qe(i, "string");
28
- return typeof r == "symbol" ? r : r + "";
26
+ function qe(i) {
27
+ var t = We(i, "string");
28
+ return typeof t == "symbol" ? t : t + "";
29
29
  }
30
- function qe(i, r) {
30
+ function We(i, t) {
31
31
  if (typeof i != "object" || !i) return i;
32
- var h = i[Symbol.toPrimitive];
33
- if (h !== void 0) {
34
- var g = h.call(i, r);
35
- if (typeof g != "object") return g;
32
+ var f = i[Symbol.toPrimitive];
33
+ if (f !== void 0) {
34
+ var p = f.call(i, t);
35
+ if (typeof p != "object") return p;
36
36
  throw new TypeError("@@toPrimitive must return a primitive value.");
37
37
  }
38
- return (r === "string" ? String : Number)(i);
38
+ return (t === "string" ? String : Number)(i);
39
39
  }
40
- class X extends ge {
41
- constructor(r, h) {
42
- super(), this.type = r, this.rawValue = h;
40
+ class X extends be {
41
+ constructor(t, f) {
42
+ super(), this.type = t, this.rawValue = f;
43
43
  }
44
44
  toDOM() {
45
- const r = document.createElement("span");
46
- return r.className = "cm-react-anchor", r.dataset.type = this.type, r.dataset.value = this.rawValue, r.contentEditable = "false", r.style.pointerEvents = "none", r.style.verticalAlign = "middle", r.style.display = "inline-block", r;
45
+ const t = document.createElement("span");
46
+ return t.className = "cm-react-anchor", t.dataset.type = this.type, t.dataset.value = this.rawValue, t.contentEditable = "false", t.style.pointerEvents = "none", t.style.verticalAlign = "middle", t.style.display = "inline-block", t;
47
47
  }
48
48
  ignoreEvent() {
49
49
  return !0;
50
50
  }
51
- eq(r) {
52
- return r.type === this.type && r.rawValue === this.rawValue;
51
+ eq(t) {
52
+ return t.type === this.type && t.rawValue === this.rawValue;
53
53
  }
54
54
  }
55
- const Fe = Ce({
56
- theme: "light",
57
- settings: {
58
- background: "transparent",
59
- backgroundImage: "",
60
- foreground: "rgba(255,255,255, 0.75)",
61
- caret: "gray",
62
- selection: "rgba(112,179,255,0.25)",
63
- selectionMatch: "rgba(112,179,255,0.1)",
64
- fontSize: "0.8rem",
65
- gutterBackground: "transparent",
66
- gutterForeground: "rgba(255,255,255, 0.5)",
67
- gutterBorder: "transparent",
68
- gutterActiveForeground: "rgba(255,255,255, 1)",
69
- lineHighlight: "rgba(255,255,255, 0.1)"
70
- },
71
- styles: [{
72
- tag: v.squareBracket,
73
- color: b("squareBracket")
74
- }, {
75
- tag: v.bracket,
76
- color: b("bracket")
77
- }, {
78
- tag: v.string,
79
- color: b("Text")
80
- }, {
81
- tag: v.bool,
82
- color: b("Boolean")
83
- }, {
84
- tag: v.number,
85
- color: b("Number")
86
- }]
87
- }), Oe = (i) => ce(i) || typeof i == "string" || typeof i == "number" || Array.isArray(i), at = (i) => {
55
+ const De = (i) => me(i) || typeof i == "string" || typeof i == "number" || Array.isArray(i), ur = (i) => {
88
56
  const {
89
- language: r,
90
- tokenizer: h,
91
- tokenHighlights: g,
92
- suggestions: w,
93
- onChange: O,
94
- extensions: W = [],
95
- initialValue: S,
96
- formValidation: Y,
97
- disabled: I,
98
- showTooltips: Z = !0,
99
- showValidation: $ = !0,
100
- readonly: U,
101
- basicSetup: ee,
57
+ language: t,
58
+ tokenizer: f,
59
+ tokenHighlights: p,
60
+ tokenStyles: O = [],
61
+ suggestions: V,
62
+ onChange: q,
63
+ extensions: Y = [],
64
+ formatter: W,
65
+ initialValue: v,
66
+ formValidation: Z,
67
+ disabled: N,
68
+ showTooltips: $ = !0,
69
+ showValidation: U = !0,
70
+ readonly: ee,
71
+ basicSetup: re,
102
72
  customSuggestionComponent: D = !1,
103
73
  ...te
104
- } = i, [re, R] = m.useState(""), B = m.useRef(null), [oe, ne] = m.useState(/* @__PURE__ */ new Map()), [c, ie] = m.useState([]), [f, p] = m.useState(null), C = m.useRef(null);
105
- r === "json" && m.useEffect(() => {
74
+ } = i, [oe, I] = m.useState(), R = m.useRef(null), [ne, ie] = m.useState(/* @__PURE__ */ new Map()), [u, se] = m.useState([]), [T, le] = m.useState(null), [g, y] = m.useState(null), H = m.useRef(null);
75
+ m.useEffect(() => {
106
76
  (async () => {
107
77
  try {
108
- const e = await ve.format(JSON.stringify(S) ?? "", {
109
- parser: r,
110
- plugins: [we, Se],
78
+ const e = W ? await W(v) : t === "json" ? await Ce.format(JSON.stringify(v), {
79
+ parser: "json",
80
+ plugins: [Te, xe],
111
81
  printWidth: 1
112
- });
113
- R(e);
82
+ }) : v;
83
+ I(e);
114
84
  } catch {
115
- R(JSON.stringify(S) ?? "");
85
+ I(t == "json" ? JSON.stringify(v) : v);
116
86
  }
117
87
  })();
118
- }, [S]);
119
- const se = m.useMemo(() => {
120
- const e = [...W];
121
- if (w) {
122
- const o = (l) => {
123
- const u = w(l);
124
- if (u && Oe(u)) {
125
- const d = l.view?.coordsAtPos(l.pos);
126
- return d && p({
127
- component: u,
88
+ }, []);
89
+ const ae = m.useMemo(() => {
90
+ const e = [...Y];
91
+ if (V) {
92
+ const n = (o) => {
93
+ const c = V(o);
94
+ if (c && De(c)) {
95
+ const l = o.view?.coordsAtPos(o.pos);
96
+ return l && y({
97
+ component: c,
128
98
  position: {
129
- top: d.bottom,
130
- left: d.left
99
+ top: l.bottom,
100
+ left: l.left
131
101
  }
132
102
  }), null;
133
103
  }
134
- return p(null), u;
104
+ return y(null), c;
135
105
  };
136
- e.push(Ie({
106
+ e.push(Be({
137
107
  ...D ? {
138
- override: [o]
108
+ override: [n]
139
109
  } : {
140
- override: [w]
110
+ override: [V]
141
111
  }
142
112
  })), e.push(_.highest(J.of([{
143
113
  key: "Tab",
144
- run: Re
114
+ run: Fe
145
115
  }]))), D && e.push(_.highest(J.of([{
146
116
  key: "ArrowUp",
147
- run: (l) => (f || N(l), !0)
117
+ run: (o) => (g || E(o), !0)
148
118
  }, {
149
119
  key: "ArrowDown",
150
- run: (l) => f ? (B?.current?.querySelector("[tabindex]")?.focus(), !0) : (N(l), !0)
120
+ run: (o) => g ? (R?.current?.querySelector("[tabindex]")?.focus(), !0) : (E(o), !0)
151
121
  }])));
152
122
  }
153
- r === "json" ? (e.push(pe()), e.push(be(ye(), {
154
- markerFilter: (o) => (ie(o), [])
155
- }))) : r && e.push(r);
156
- const n = me.fromClass(class {
157
- constructor(o) {
158
- Be(this, "decorations", void 0), this.decorations = this.build(o);
123
+ t === "json" ? (e.push(ve()), e.push(we(Se(), {
124
+ markerFilter: (n) => (se(n), [])
125
+ }))) : t && e.push(t);
126
+ const d = ge.fromClass(class {
127
+ constructor(n) {
128
+ Oe(this, "decorations", void 0), this.decorations = this.build(n);
159
129
  }
160
- update(o) {
161
- (o.docChanged || o.viewportChanged) && (this.decorations = this.build(o.view));
130
+ update(n) {
131
+ (n.docChanged || n.viewportChanged) && (this.decorations = this.build(n.view));
162
132
  }
163
- build(o) {
164
- const l = new he(), u = Object.keys(g || {});
165
- return L(o.state).iterate({
166
- enter: (d) => {
167
- const A = o.state.doc.sliceString(d.from, d.to);
168
- if (A.includes(`
133
+ build(n) {
134
+ const o = new pe(), c = Object.keys(p || {});
135
+ return L(n.state).iterate({
136
+ enter: (l) => {
137
+ const h = n.state.doc.sliceString(l.from, l.to);
138
+ if (h.includes(`
169
139
  `)) return;
170
- const q = h?.(A), ae = Te(d)?.tags.map((x) => "name" in x ? x.name : void 0), H = u.find((x) => ae?.includes(x));
171
- H && !q ? l.add(d.from, d.to, F.replace({
172
- widget: new X(H, A),
140
+ const M = f?.(h), de = ke(l)?.tags.map((S) => "name" in S ? S.name : void 0), B = c.find((S) => de?.includes(S));
141
+ B && !M ? p?.[B]({
142
+ content: h
143
+ }) && o.add(l.from, l.to, F.replace({
144
+ widget: new X(B, h),
173
145
  point: !0
174
- })) : q && l.add(d.from, d.to, F.replace({
175
- widget: new X(q, A),
146
+ })) : M && o.add(l.from, l.to, F.replace({
147
+ widget: new X(M, h),
176
148
  point: !0
177
149
  }));
178
150
  }
179
- }), l.finish();
151
+ }), o.finish();
180
152
  }
181
153
  }, {
182
- decorations: (o) => o.decorations
154
+ decorations: (n) => n.decorations
183
155
  });
184
- return e.push(n), e.push(fe.atomicRanges.of((o) => o.plugin(n)?.decorations || F.none)), e;
185
- }, [r, h, g, W, w, B.current]), [T, le] = m.useState(null), M = m.useCallback((e) => {
156
+ return e.push(d), e.push(ye.atomicRanges.of((n) => n.plugin(d)?.decorations || F.none)), e;
157
+ }, [R]), ce = m.useCallback((e) => {
186
158
  if (e.docChanged || e.viewportChanged || e.selectionSet) {
187
159
  if (e.view) {
188
160
  const {
189
- from: n,
190
- to: o
161
+ from: o,
162
+ to: c
191
163
  } = e.state?.selection?.main ?? {
192
164
  from: 0,
193
165
  to: 0
194
166
  };
195
167
  let l = 0;
196
168
  L(e.state).iterate({
197
- from: n,
198
- to: o,
199
- enter: (u) => {
200
- u.from >= n && u.to <= o && l++;
169
+ from: o,
170
+ to: c,
171
+ enter: (h) => {
172
+ h.from >= o && h.to <= c && l++;
201
173
  }
202
- }), e.selectionSet && l < 2 ? (n === o && n !== T?.from ? p(null) : n === o && n === T?.from && n != 0 ? p((u) => u) : n === o && n === T?.from && n == 0 && p(null), N(e.view)) : e.selectionSet && l >= 2 && p(null), le({
203
- from: n,
204
- to: o
174
+ }), e.selectionSet && l < 2 ? (o === c && o !== T?.from ? y(null) : o === c && o === T?.from && o != 0 ? y((h) => h) : o === c && o === T?.from && o == 0 && y(null), E(e.view)) : e.selectionSet && l >= 2 && y(null), le({
175
+ from: o,
176
+ to: c
205
177
  });
206
- } else e.selectionSet && (p(null), N(e.view));
207
- window.requestAnimationFrame(() => {
208
- const n = C.current?.querySelectorAll(".cm-react-anchor"), o = /* @__PURE__ */ new Map();
209
- n?.forEach((l) => {
210
- o.set(l, {
211
- type: l.dataset.type,
212
- value: l.dataset.value
213
- });
214
- }), ne(o);
215
- });
216
- }
217
- }, [T]);
218
- return m.useEffect(() => {
219
- if (C.current) {
220
- const e = window.setTimeout(() => {
221
- const n = new CustomEvent("scroll");
222
- C.current?.dispatchEvent(n), M({
223
- docChanged: !0,
224
- viewportChanged: !0,
225
- selectionSet: !1
178
+ } else e.selectionSet && (y(null), E(e.view));
179
+ const d = H.current?.querySelectorAll(".cm-react-anchor"), n = /* @__PURE__ */ new Map();
180
+ d?.forEach((o) => {
181
+ n.set(o, {
182
+ type: o.dataset.type,
183
+ value: o.dataset.value
226
184
  });
227
- }, 50);
228
- return () => clearTimeout(e);
185
+ }), ie(n);
229
186
  }
230
- return () => {
231
- };
232
- }, [M]), /* @__PURE__ */ s(Ve, { h: "100%", type: "scroll", children: [
233
- $ && /* @__PURE__ */ t("div", { className: "editor__diagnostics", children: /* @__PURE__ */ s(k, { style: {
187
+ }, [T]), ue = m.useMemo(() => Ae({
188
+ theme: "light",
189
+ settings: {
190
+ background: "transparent",
191
+ backgroundImage: "",
192
+ foreground: "rgba(255,255,255, 0.75)",
193
+ caret: "gray",
194
+ selection: "rgba(112,179,255,0.25)",
195
+ selectionMatch: "rgba(112,179,255,0.1)",
196
+ fontSize: "0.8rem",
197
+ gutterBackground: "transparent",
198
+ gutterForeground: "rgba(255,255,255, 0.5)",
199
+ gutterBorder: "transparent",
200
+ gutterActiveForeground: "rgba(255,255,255, 1)",
201
+ lineHighlight: "rgba(255,255,255, 0.1)"
202
+ },
203
+ styles: [{
204
+ tag: C.squareBracket,
205
+ color: w("squareBracket")
206
+ }, {
207
+ tag: C.bracket,
208
+ color: w("bracket")
209
+ }, {
210
+ tag: C.string,
211
+ color: w("Text")
212
+ }, {
213
+ tag: C.bool,
214
+ color: w("Boolean")
215
+ }, {
216
+ tag: C.number,
217
+ color: w("Number")
218
+ }, ...O]
219
+ }), [O]);
220
+ return /* @__PURE__ */ s(Re, { h: "100%", type: "scroll", children: [
221
+ U && /* @__PURE__ */ r("div", { className: "editor__diagnostics", children: /* @__PURE__ */ s(x, { style: {
234
222
  gap: "0.35rem",
235
223
  textWrap: "nowrap"
236
224
  }, align: "center", children: [
237
- c.filter((e) => e.severity == "error").length > 0 ? /* @__PURE__ */ s(E, { children: [
238
- /* @__PURE__ */ t(z, { asChild: !0, children: /* @__PURE__ */ s(y, { color: "red", children: [
239
- /* @__PURE__ */ t(Ae, { size: 13 }),
240
- /* @__PURE__ */ t(a, { children: c.filter((e) => e.severity == "error").length })
225
+ u.filter((e) => e.severity == "error").length > 0 ? /* @__PURE__ */ s(A, { children: [
226
+ /* @__PURE__ */ r(k, { asChild: !0, children: /* @__PURE__ */ s(b, { color: "red", children: [
227
+ /* @__PURE__ */ r(ze, { size: 13 }),
228
+ /* @__PURE__ */ r(a, { children: u.filter((e) => e.severity == "error").length })
241
229
  ] }) }),
242
- /* @__PURE__ */ t(P, { children: /* @__PURE__ */ s(j, { side: "bottom", children: [
243
- /* @__PURE__ */ t(V, {}),
244
- c.filter((e) => e.severity == "error").map((e) => /* @__PURE__ */ t(a, { size: "xs", children: e.message }, e.message))
230
+ /* @__PURE__ */ r(z, { children: /* @__PURE__ */ s(j, { side: "bottom", children: [
231
+ /* @__PURE__ */ r(P, {}),
232
+ u.filter((e) => e.severity == "error").map((e) => /* @__PURE__ */ r(a, { size: "xs", children: e.message }, e.message))
245
233
  ] }) })
246
234
  ] }) : null,
247
- c.filter((e) => e.severity == "warning").length > 0 ? /* @__PURE__ */ s(E, { children: [
248
- /* @__PURE__ */ t(z, { asChild: !0, children: /* @__PURE__ */ s(y, { color: "orange", children: [
249
- /* @__PURE__ */ t(xe, { size: 13 }),
250
- /* @__PURE__ */ t(a, { children: c.filter((e) => e.severity == "warning").length })
235
+ u.filter((e) => e.severity == "warning").length > 0 ? /* @__PURE__ */ s(A, { children: [
236
+ /* @__PURE__ */ r(k, { asChild: !0, children: /* @__PURE__ */ s(b, { color: "orange", children: [
237
+ /* @__PURE__ */ r(je, { size: 13 }),
238
+ /* @__PURE__ */ r(a, { children: u.filter((e) => e.severity == "warning").length })
251
239
  ] }) }),
252
- /* @__PURE__ */ t(P, { children: /* @__PURE__ */ s(j, { side: "bottom", children: [
253
- /* @__PURE__ */ t(V, {}),
254
- c.filter((e) => e.severity == "warning").map((e) => /* @__PURE__ */ t(a, { size: "xs", children: e.message }, e.message))
240
+ /* @__PURE__ */ r(z, { children: /* @__PURE__ */ s(j, { side: "bottom", children: [
241
+ /* @__PURE__ */ r(P, {}),
242
+ u.filter((e) => e.severity == "warning").map((e) => /* @__PURE__ */ r(a, { size: "xs", children: e.message }, e.message))
255
243
  ] }) })
256
244
  ] }) : null,
257
- c.filter((e) => e.severity == "info").length > 0 ? /* @__PURE__ */ s(E, { children: [
258
- /* @__PURE__ */ t(z, { asChild: !0, children: /* @__PURE__ */ s(y, { color: "#9ca3af", children: [
259
- /* @__PURE__ */ t(ke, { size: 13 }),
260
- /* @__PURE__ */ t(a, { children: c.filter((e) => e.severity == "info").length })
245
+ u.filter((e) => e.severity == "info").length > 0 ? /* @__PURE__ */ s(A, { children: [
246
+ /* @__PURE__ */ r(k, { asChild: !0, children: /* @__PURE__ */ s(b, { color: "#9ca3af", children: [
247
+ /* @__PURE__ */ r(Pe, { size: 13 }),
248
+ /* @__PURE__ */ r(a, { children: u.filter((e) => e.severity == "info").length })
261
249
  ] }) }),
262
- /* @__PURE__ */ t(P, { children: /* @__PURE__ */ s(j, { side: "bottom", children: [
263
- /* @__PURE__ */ t(V, {}),
264
- c.filter((e) => e.severity == "info").map((e) => /* @__PURE__ */ t(a, { size: "xs", children: e.message }, e.message))
250
+ /* @__PURE__ */ r(z, { children: /* @__PURE__ */ s(j, { side: "bottom", children: [
251
+ /* @__PURE__ */ r(P, {}),
252
+ u.filter((e) => e.severity == "info").map((e) => /* @__PURE__ */ r(a, { size: "xs", children: e.message }, e.message))
265
253
  ] }) })
266
254
  ] }) : null,
267
- c.filter((e) => e.severity == "hint").length > 0 ? /* @__PURE__ */ s(E, { children: [
268
- /* @__PURE__ */ t(z, { asChild: !0, children: /* @__PURE__ */ s(y, { color: "#3b82f6", children: [
269
- /* @__PURE__ */ t(Ee, { size: 13 }),
270
- /* @__PURE__ */ t(a, { children: c.filter((e) => e.severity == "hint").length })
255
+ u.filter((e) => e.severity == "hint").length > 0 ? /* @__PURE__ */ s(A, { children: [
256
+ /* @__PURE__ */ r(k, { asChild: !0, children: /* @__PURE__ */ s(b, { color: "#3b82f6", children: [
257
+ /* @__PURE__ */ r(Ee, { size: 13 }),
258
+ /* @__PURE__ */ r(a, { children: u.filter((e) => e.severity == "hint").length })
271
259
  ] }) }),
272
- /* @__PURE__ */ t(P, { children: /* @__PURE__ */ s(j, { side: "bottom", children: [
273
- /* @__PURE__ */ t(V, {}),
274
- c.filter((e) => e.severity == "hint").map((e) => /* @__PURE__ */ t(a, { size: "xs", children: e.message }, e.message))
260
+ /* @__PURE__ */ r(z, { children: /* @__PURE__ */ s(j, { side: "bottom", children: [
261
+ /* @__PURE__ */ r(P, {}),
262
+ u.filter((e) => e.severity == "hint").map((e) => /* @__PURE__ */ r(a, { size: "xs", children: e.message }, e.message))
275
263
  ] }) })
276
264
  ] }) : null
277
265
  ] }) }),
278
- Z && /* @__PURE__ */ t("div", { className: "editor__tools", children: /* @__PURE__ */ s(k, { style: {
266
+ $ && /* @__PURE__ */ r("div", { className: "editor__tools", children: /* @__PURE__ */ s(x, { style: {
279
267
  gap: "0.35rem",
280
268
  textWrap: "nowrap"
281
269
  }, align: "center", children: [
282
- /* @__PURE__ */ s(k, { style: {
270
+ /* @__PURE__ */ s(x, { style: {
283
271
  gap: "0.35rem"
284
272
  }, align: "center", children: [
285
- /* @__PURE__ */ s(y, { color: "secondary", border: !0, children: [
286
- /* @__PURE__ */ t(a, { children: navigator !== void 0 && /Mac/.test(navigator.userAgent) ? "⌃" : "strg" }),
287
- /* @__PURE__ */ t(a, { children: "+" }),
288
- /* @__PURE__ */ t(ze, { size: 13 })
273
+ /* @__PURE__ */ s(b, { color: "secondary", border: !0, children: [
274
+ /* @__PURE__ */ r(a, { children: navigator !== void 0 && /Mac/.test(navigator.userAgent) ? "⌃" : "strg" }),
275
+ /* @__PURE__ */ r(a, { children: "+" }),
276
+ /* @__PURE__ */ r(Ve, { size: 13 })
289
277
  ] }),
290
- /* @__PURE__ */ t(a, { children: "to show" })
278
+ /* @__PURE__ */ r(a, { children: "to show" })
291
279
  ] }),
292
- /* @__PURE__ */ t(a, { children: "and" }),
293
- /* @__PURE__ */ s(k, { style: {
280
+ /* @__PURE__ */ r(a, { children: "and" }),
281
+ /* @__PURE__ */ s(x, { style: {
294
282
  gap: "0.35rem"
295
283
  }, align: "center", children: [
296
- /* @__PURE__ */ s(y, { color: "secondary", border: !0, children: [
297
- /* @__PURE__ */ t(Pe, { size: 13 }),
298
- /* @__PURE__ */ t(a, { children: "or" }),
299
- /* @__PURE__ */ t(je, { size: 13 })
284
+ /* @__PURE__ */ s(b, { color: "secondary", border: !0, children: [
285
+ /* @__PURE__ */ r(Ne, { size: 13 }),
286
+ /* @__PURE__ */ r(a, { children: "or" }),
287
+ /* @__PURE__ */ r(Ie, { size: 13 })
300
288
  ] }),
301
- /* @__PURE__ */ t(a, { children: "to select" })
289
+ /* @__PURE__ */ r(a, { children: "to select" })
302
290
  ] }),
303
- /* @__PURE__ */ t(a, { children: "suggestions" })
291
+ /* @__PURE__ */ r(a, { children: "suggestions" })
304
292
  ] }) }),
305
- /* @__PURE__ */ t(Ne, { asChild: !0, children: /* @__PURE__ */ s("div", { ref: C, ...ue("editor", te), children: [
306
- /* @__PURE__ */ t(de, { width: "100%", height: "100%", value: r === "json" ? re : S, theme: Fe, readOnly: I || U, editable: !I, extensions: se, "aria-disabled": I, className: "editor__control", onChange: (e) => {
307
- if (R(e), r === "json")
293
+ /* @__PURE__ */ r(Me, { asChild: !0, children: /* @__PURE__ */ s("div", { ref: H, ...he("editor", te), children: [
294
+ /* @__PURE__ */ r(fe, { width: "100%", height: "100%", value: oe, theme: ue, readOnly: N || ee, editable: !N, extensions: ae, "aria-disabled": N, className: "editor__control", onChange: (e) => {
295
+ if (I(e), t === "json")
308
296
  try {
309
- const n = JSON.parse(e);
310
- O?.(n), Y?.setValue(n);
297
+ const d = JSON.parse(e);
298
+ q?.(d), Z?.setValue(d);
311
299
  } catch {
312
300
  }
313
301
  else
314
- O?.(e);
315
- }, onUpdate: M, basicSetup: ee }),
316
- g && Array.from(oe.entries()).map(([e, n]) => {
317
- const o = g[n.type];
318
- return o ? K(/* @__PURE__ */ t("div", { style: {
302
+ q?.(e);
303
+ }, onUpdate: ce, basicSetup: re }),
304
+ p && Array.from(ne.entries()).map(([e, d]) => {
305
+ const n = p[d.type];
306
+ return n ? K(/* @__PURE__ */ r("div", { style: {
319
307
  display: "contents"
320
- }, children: o({
321
- content: n.value
322
- }) }, e.outerHTML + n.value), e) : null;
308
+ }, children: n({
309
+ content: d.value
310
+ }) }, e.outerHTML + d.value), e) : null;
323
311
  }),
324
- f && K(/* @__PURE__ */ t("div", { ref: B, style: {
312
+ g && K(/* @__PURE__ */ r("div", { ref: R, style: {
325
313
  position: "fixed",
326
- top: f.position.top,
327
- left: f.position.left,
314
+ top: g.position.top,
315
+ left: g.position.left,
328
316
  zIndex: 9999
329
- }, children: f.component }, f.position.top + "-" + f.position.left), document.body)
317
+ }, children: g.component }, g.position.top + "-" + g.position.left), document.body)
330
318
  ] }) }),
331
- /* @__PURE__ */ t(G, { orientation: "vertical", children: /* @__PURE__ */ t(Q, {}) }),
332
- /* @__PURE__ */ t(G, { orientation: "horizontal", children: /* @__PURE__ */ t(Q, {}) })
319
+ /* @__PURE__ */ r(G, { orientation: "vertical", children: /* @__PURE__ */ r(Q, {}) }),
320
+ /* @__PURE__ */ r(G, { orientation: "horizontal", children: /* @__PURE__ */ r(Q, {}) })
333
321
  ] });
334
322
  };
335
323
  export {
336
- at as Editor
324
+ ur as Editor
337
325
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@code0-tech/pictor",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "type": "module",
5
5
  "description": "A simple template for a custom React component library",
6
6
  "scripts": {
@@ -56,9 +56,9 @@
56
56
  "@types/react": "^19.2.14",
57
57
  "@types/react-dom": "^19.2.3",
58
58
  "@types/react-syntax-highlighter": "^15.5.13",
59
- "@uiw/codemirror-themes": "^4.25.8",
59
+ "@uiw/codemirror-themes": "^4.25.9",
60
60
  "@uiw/react-codemirror": "^4.25.8",
61
- "@vitejs/plugin-react": "^5.1.4",
61
+ "@vitejs/plugin-react": "^5.2.0",
62
62
  "@vitest/browser-playwright": "^4.0.18",
63
63
  "@vitest/coverage-v8": "^4.0.18",
64
64
  "@xyflow/react": "^12.10.1",
@@ -76,7 +76,7 @@
76
76
  "playwright": "1.58.1",
77
77
  "react": "^19.2.4",
78
78
  "react-dom": "^19.2.4",
79
- "react-resizable-panels": "^4.7.2",
79
+ "react-resizable-panels": "^4.7.6",
80
80
  "react-zoom-pan-pinch": "^3.7.0",
81
81
  "rimraf": "^6.1.3",
82
82
  "sass": "^1.98.0",