@llmnative/react 1.13.0 → 1.14.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/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +83 -85
- package/dist/index.mjs.map +1 -1
- package/dist/types/src/components/ui/fields/CodeEditor.d.ts +12 -0
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -9603,46 +9603,44 @@ var nu = ({ mode: e, availability: n, renderAIUnavailable: r }) => {
|
|
|
9603
9603
|
}), e.focus();
|
|
9604
9604
|
}
|
|
9605
9605
|
} : null;
|
|
9606
|
-
}, Mu = ({ name: e, onChange: n = void 0, defaultValue: r = void 0, className: i = void 0, label: a, language: o = "html", placeholder: c, minHeight: d, maxHeight: f, required: p, disabled: g, feedback: _, labelClassName: v, validateSyntax: y = !0,
|
|
9607
|
-
let
|
|
9606
|
+
}, Mu = ({ name: e, onChange: n = void 0, defaultValue: r = void 0, className: i = void 0, label: a, language: o = "html", placeholder: c, minHeight: d, maxHeight: f, required: p, disabled: g, feedback: _, labelClassName: v, validateSyntax: y = !0, validate: b, validator: x, extensions: S, commands: C, commandsTrigger: w, wrapperClassName: T, inheritWrapperClassName: E = !0, before: D, after: O }) => {
|
|
9607
|
+
let k = u(), A = Y("CodeEditor"), j = ts({
|
|
9608
9608
|
minHeight: d,
|
|
9609
9609
|
maxHeight: f
|
|
9610
|
-
}), { value:
|
|
9610
|
+
}), { value: M, handleChange: N, formWrapClass: P } = Dd({
|
|
9611
9611
|
name: e,
|
|
9612
9612
|
onChange: n,
|
|
9613
9613
|
defaultValue: r,
|
|
9614
|
-
wrapperClassName:
|
|
9615
|
-
inheritWrapperClassName:
|
|
9616
|
-
}),
|
|
9614
|
+
wrapperClassName: T,
|
|
9615
|
+
inheritWrapperClassName: E
|
|
9616
|
+
}), F = Ed(e, {
|
|
9617
9617
|
required: p,
|
|
9618
9618
|
label: a,
|
|
9619
9619
|
validator: async (e) => {
|
|
9620
9620
|
let t = typeof e == "string" ? e : `${e ?? ""}`;
|
|
9621
|
-
if (y)
|
|
9622
|
-
await
|
|
9623
|
-
|
|
9624
|
-
if (e instanceof pu) return e.message;
|
|
9625
|
-
throw e;
|
|
9621
|
+
if (y) {
|
|
9622
|
+
let e = b ? await b(t) : await Cu(t, o);
|
|
9623
|
+
if (!e.valid) return e.error?.message ?? `Invalid ${o} code.`;
|
|
9626
9624
|
}
|
|
9627
|
-
return await
|
|
9625
|
+
return await x?.(e);
|
|
9628
9626
|
}
|
|
9629
|
-
}),
|
|
9627
|
+
}), I = m(null), L = m(null), R = m(null), [z, B] = h(!0), [V, H] = h({
|
|
9630
9628
|
open: !1,
|
|
9631
9629
|
query: "",
|
|
9632
9630
|
anchorPosition: null,
|
|
9633
9631
|
editorContext: null
|
|
9634
|
-
}),
|
|
9635
|
-
|
|
9636
|
-
let
|
|
9632
|
+
}), U = m(M ?? ""), W = m(V);
|
|
9633
|
+
W.current = V;
|
|
9634
|
+
let ee = C?.length ? w ?? "/" : void 0, G = (C?.length ?? 0) >= 10, te = t.useMemo(() => new Map((C ?? []).map((e) => [e.name, e])), [C]), ne = t.useMemo(() => (C ?? []).map((e) => ({
|
|
9637
9635
|
key: e.name,
|
|
9638
|
-
label: `${
|
|
9636
|
+
label: `${ee ?? "/"}${e.name}`,
|
|
9639
9637
|
value: e.name,
|
|
9640
9638
|
icon: e.icon,
|
|
9641
9639
|
description: e.description,
|
|
9642
9640
|
group: e.group
|
|
9643
|
-
})), [
|
|
9641
|
+
})), [C, ee]), re = t.useMemo(() => {
|
|
9644
9642
|
let e = [], n;
|
|
9645
|
-
return
|
|
9643
|
+
return ne.forEach((r) => {
|
|
9646
9644
|
r.group !== n && (n = r.group, r.group && e.push(/* @__PURE__ */ t.createElement(Bl.Heading, { key: `group:${r.group}` }, r.group))), e.push(/* @__PURE__ */ t.createElement(Bl.Item, {
|
|
9647
9645
|
key: r.key,
|
|
9648
9646
|
label: r.label,
|
|
@@ -9651,26 +9649,26 @@ var nu = ({ mode: e, availability: n, renderAIUnavailable: r }) => {
|
|
|
9651
9649
|
description: r.description
|
|
9652
9650
|
}));
|
|
9653
9651
|
}), e;
|
|
9654
|
-
}, [
|
|
9652
|
+
}, [ne]);
|
|
9655
9653
|
l(() => {
|
|
9656
|
-
|
|
9657
|
-
}, [
|
|
9658
|
-
let
|
|
9659
|
-
|
|
9654
|
+
L.current || (U.current = M ?? "");
|
|
9655
|
+
}, [M]);
|
|
9656
|
+
let K = s((t) => {
|
|
9657
|
+
U.current = t, N({ target: {
|
|
9660
9658
|
name: e,
|
|
9661
9659
|
value: t
|
|
9662
9660
|
} });
|
|
9663
|
-
}, [
|
|
9664
|
-
|
|
9665
|
-
let
|
|
9666
|
-
|
|
9661
|
+
}, [N, e]), ie = m(K);
|
|
9662
|
+
ie.current = K;
|
|
9663
|
+
let ae = s(() => {
|
|
9664
|
+
H({
|
|
9667
9665
|
open: !1,
|
|
9668
9666
|
query: "",
|
|
9669
9667
|
anchorPosition: null,
|
|
9670
9668
|
editorContext: null
|
|
9671
9669
|
});
|
|
9672
|
-
}, []),
|
|
9673
|
-
let n =
|
|
9670
|
+
}, []), oe = s(async (e, t) => {
|
|
9671
|
+
let n = te.get(e.value);
|
|
9674
9672
|
if (n) {
|
|
9675
9673
|
if (n.handler) {
|
|
9676
9674
|
let e = await n.handler(Ll(t)), r = n.consumeSuffix ? Pl(t.textAfterCaret, n.consumeSuffix) : 0;
|
|
@@ -9679,11 +9677,11 @@ var nu = ({ mode: e, availability: n, renderAIUnavailable: r }) => {
|
|
|
9679
9677
|
}
|
|
9680
9678
|
t.replace(t.triggerRange.start, t.triggerRange.end, `${t.trigger}${n.name} `);
|
|
9681
9679
|
}
|
|
9682
|
-
}, [
|
|
9680
|
+
}, [te]);
|
|
9683
9681
|
l(() => {
|
|
9684
9682
|
let e = !1, t = null;
|
|
9685
9683
|
return Ou(o).then((n) => {
|
|
9686
|
-
if (e || !
|
|
9684
|
+
if (e || !I.current) return;
|
|
9687
9685
|
let r = n.EditorView.theme({
|
|
9688
9686
|
"&": {
|
|
9689
9687
|
backgroundColor: "hsl(var(--rf-background))",
|
|
@@ -9729,23 +9727,23 @@ var nu = ({ mode: e, availability: n, renderAIUnavailable: r }) => {
|
|
|
9729
9727
|
n.language,
|
|
9730
9728
|
r,
|
|
9731
9729
|
n.EditorView.updateListener.of((e) => {
|
|
9732
|
-
e.docChanged &&
|
|
9730
|
+
e.docChanged && ie.current(e.state.doc.toString());
|
|
9733
9731
|
}),
|
|
9734
|
-
...
|
|
9732
|
+
...S ?? []
|
|
9735
9733
|
];
|
|
9736
|
-
|
|
9734
|
+
ee && i.push(n.EditorView.updateListener.of((e) => {
|
|
9737
9735
|
let t = e.state.selection.main;
|
|
9738
9736
|
if (t.from !== t.to) {
|
|
9739
|
-
|
|
9737
|
+
W.current.open && ae();
|
|
9740
9738
|
return;
|
|
9741
9739
|
}
|
|
9742
|
-
let n = Au(e.state.doc.toString(), t.from,
|
|
9740
|
+
let n = Au(e.state.doc.toString(), t.from, ee);
|
|
9743
9741
|
if (!n) {
|
|
9744
|
-
|
|
9742
|
+
W.current.open && ae();
|
|
9745
9743
|
return;
|
|
9746
9744
|
}
|
|
9747
|
-
let r = e.view.coordsAtPos(t.from), i = ju(e.view,
|
|
9748
|
-
!r || !i ||
|
|
9745
|
+
let r = e.view.coordsAtPos(t.from), i = ju(e.view, ee);
|
|
9746
|
+
!r || !i || H({
|
|
9749
9747
|
open: !0,
|
|
9750
9748
|
query: n.query,
|
|
9751
9749
|
anchorPosition: {
|
|
@@ -9757,102 +9755,102 @@ var nu = ({ mode: e, availability: n, renderAIUnavailable: r }) => {
|
|
|
9757
9755
|
}), n.Prec.highest(n.keymap.of([
|
|
9758
9756
|
{
|
|
9759
9757
|
key: "ArrowDown",
|
|
9760
|
-
run: () =>
|
|
9758
|
+
run: () => W.current.open ? (R.current?.moveNext(), !0) : !1
|
|
9761
9759
|
},
|
|
9762
9760
|
{
|
|
9763
9761
|
key: "ArrowUp",
|
|
9764
|
-
run: () =>
|
|
9762
|
+
run: () => W.current.open ? (R.current?.movePrev(), !0) : !1
|
|
9765
9763
|
},
|
|
9766
9764
|
{
|
|
9767
9765
|
key: "Enter",
|
|
9768
|
-
run: () =>
|
|
9766
|
+
run: () => W.current.open ? (R.current?.selectActive(), !0) : !1
|
|
9769
9767
|
},
|
|
9770
9768
|
{
|
|
9771
9769
|
key: "Tab",
|
|
9772
|
-
run: () =>
|
|
9770
|
+
run: () => W.current.open ? (R.current?.selectActive(), !0) : !1
|
|
9773
9771
|
},
|
|
9774
9772
|
{
|
|
9775
9773
|
key: "Escape",
|
|
9776
|
-
run: () =>
|
|
9774
|
+
run: () => W.current.open ? (R.current?.close(), !0) : !1
|
|
9777
9775
|
}
|
|
9778
9776
|
])), n.EditorView.domEventHandlers({ keydown: (e) => {
|
|
9779
|
-
if (!
|
|
9777
|
+
if (!W.current.open) return !1;
|
|
9780
9778
|
switch (e.key) {
|
|
9781
|
-
case "ArrowDown": return e.preventDefault(),
|
|
9782
|
-
case "ArrowUp": return e.preventDefault(),
|
|
9779
|
+
case "ArrowDown": return e.preventDefault(), R.current?.moveNext(), !0;
|
|
9780
|
+
case "ArrowUp": return e.preventDefault(), R.current?.movePrev(), !0;
|
|
9783
9781
|
case "Enter":
|
|
9784
|
-
case "Tab": return e.preventDefault(),
|
|
9785
|
-
case "Escape": return e.preventDefault(),
|
|
9782
|
+
case "Tab": return e.preventDefault(), R.current?.selectActive(), !0;
|
|
9783
|
+
case "Escape": return e.preventDefault(), R.current?.close(), !0;
|
|
9786
9784
|
default: return !1;
|
|
9787
9785
|
}
|
|
9788
9786
|
} })), g && i.push(n.EditorView.editable.of(!1));
|
|
9789
9787
|
let a = n.EditorState.create({
|
|
9790
|
-
doc:
|
|
9788
|
+
doc: U.current,
|
|
9791
9789
|
extensions: i
|
|
9792
9790
|
});
|
|
9793
9791
|
t = new n.EditorView({
|
|
9794
9792
|
state: a,
|
|
9795
|
-
parent:
|
|
9796
|
-
}), ku(t.scrollDOM,
|
|
9793
|
+
parent: I.current
|
|
9794
|
+
}), ku(t.scrollDOM, j), L.current = t, B(!1);
|
|
9797
9795
|
}).catch((t) => {
|
|
9798
|
-
e || (console.error("[CodeEditor] Failed to load CodeMirror:", t),
|
|
9796
|
+
e || (console.error("[CodeEditor] Failed to load CodeMirror:", t), B(!1));
|
|
9799
9797
|
}), () => {
|
|
9800
|
-
e = !0, t && (t.destroy(),
|
|
9798
|
+
e = !0, t && (t.destroy(), L.current = null);
|
|
9801
9799
|
};
|
|
9802
9800
|
}, [
|
|
9803
|
-
|
|
9804
|
-
|
|
9801
|
+
ae,
|
|
9802
|
+
S,
|
|
9805
9803
|
g,
|
|
9806
9804
|
o,
|
|
9807
9805
|
c,
|
|
9808
|
-
|
|
9806
|
+
ee
|
|
9809
9807
|
]), l(() => {
|
|
9810
|
-
let e =
|
|
9811
|
-
t && e !==
|
|
9808
|
+
let e = M ?? "", t = L.current;
|
|
9809
|
+
t && e !== U.current && (U.current = e, t.dispatch({ changes: {
|
|
9812
9810
|
from: 0,
|
|
9813
9811
|
to: t.state.doc.length,
|
|
9814
9812
|
insert: e
|
|
9815
9813
|
} }));
|
|
9816
|
-
}, [
|
|
9817
|
-
let e =
|
|
9818
|
-
e && ku(e.scrollDOM,
|
|
9814
|
+
}, [M]), l(() => {
|
|
9815
|
+
let e = L.current;
|
|
9816
|
+
e && ku(e.scrollDOM, j);
|
|
9819
9817
|
}, [
|
|
9820
|
-
|
|
9821
|
-
|
|
9822
|
-
|
|
9818
|
+
j.fill,
|
|
9819
|
+
j.resolvedMinHeight,
|
|
9820
|
+
j.resolvedMaxHeight
|
|
9823
9821
|
]);
|
|
9824
|
-
let
|
|
9825
|
-
style: { minHeight:
|
|
9822
|
+
let se = X("w-full overflow-hidden border border-input", A.CodeEditor?.className, i, z && "flex items-center justify-center bg-muted text-muted-foreground text-sm", F && "border-destructive", D ? "rounded-l-none" : "rounded-l-md", O ? "rounded-r-none" : "rounded-r-md"), ce = /* @__PURE__ */ t.createElement("div", { className: X("min-w-0 flex-1", j.fill && "h-full flex flex-col", se) }, z && /* @__PURE__ */ t.createElement("div", {
|
|
9823
|
+
style: { minHeight: j.fill ? void 0 : j.resolvedMinHeight },
|
|
9826
9824
|
className: "flex items-center justify-center"
|
|
9827
9825
|
}, /* @__PURE__ */ t.createElement(Q, {
|
|
9828
9826
|
name: "loader-circle",
|
|
9829
9827
|
size: 16,
|
|
9830
9828
|
className: "animate-spin text-muted-foreground"
|
|
9831
9829
|
})), /* @__PURE__ */ t.createElement("div", {
|
|
9832
|
-
ref:
|
|
9833
|
-
className: X(
|
|
9830
|
+
ref: I,
|
|
9831
|
+
className: X(z && "hidden", j.fill && "h-full min-h-0 flex-1")
|
|
9834
9832
|
}));
|
|
9835
|
-
return /* @__PURE__ */ t.createElement(Z, { className: X(
|
|
9833
|
+
return /* @__PURE__ */ t.createElement(Z, { className: X(P, j.fill && "h-full flex flex-col min-h-0", A.CodeEditor?.wrapperClassName) }, a && /* @__PURE__ */ t.createElement(Ns, {
|
|
9836
9834
|
label: a,
|
|
9837
9835
|
required: p,
|
|
9838
|
-
htmlFor:
|
|
9836
|
+
htmlFor: k,
|
|
9839
9837
|
className: v
|
|
9840
|
-
}), /* @__PURE__ */ t.createElement("div", { className: X(
|
|
9841
|
-
ref:
|
|
9842
|
-
className: X(
|
|
9843
|
-
trigger:
|
|
9844
|
-
searchable:
|
|
9845
|
-
controlled:
|
|
9846
|
-
open:
|
|
9847
|
-
anchorPosition:
|
|
9848
|
-
query:
|
|
9849
|
-
editorContext:
|
|
9850
|
-
onClose:
|
|
9838
|
+
}), /* @__PURE__ */ t.createElement("div", { className: X(D || O ? os : "", j.fill && "flex-1 min-h-0 flex flex-col") }, D && /* @__PURE__ */ t.createElement("span", { className: X("inline-flex shrink-0 items-center border border-input bg-muted px-3 py-1 text-sm text-muted-foreground", "rounded-l-md rounded-r-none border-r-0") }, D), ee && ne.length > 0 ? /* @__PURE__ */ t.createElement(Bl, {
|
|
9839
|
+
ref: R,
|
|
9840
|
+
className: X(j.fill && "flex-1 min-h-0 flex flex-col"),
|
|
9841
|
+
trigger: ee,
|
|
9842
|
+
searchable: G,
|
|
9843
|
+
controlled: V.editorContext ? {
|
|
9844
|
+
open: V.open,
|
|
9845
|
+
anchorPosition: V.anchorPosition,
|
|
9846
|
+
query: V.query,
|
|
9847
|
+
editorContext: V.editorContext,
|
|
9848
|
+
onClose: ae
|
|
9851
9849
|
} : void 0,
|
|
9852
9850
|
onSelect: (e, t) => {
|
|
9853
|
-
|
|
9851
|
+
oe(e, t);
|
|
9854
9852
|
}
|
|
9855
|
-
},
|
|
9853
|
+
}, re, ce) : ce, O && /* @__PURE__ */ t.createElement("span", { className: X("inline-flex shrink-0 items-center border border-input bg-muted px-3 py-1 text-sm text-muted-foreground", "rounded-l-none rounded-r-md border-l-0") }, O)), F && /* @__PURE__ */ t.createElement(hs, { message: F }), _ && /* @__PURE__ */ t.createElement("p", { className: "mt-1 text-xs text-muted-foreground" }, _));
|
|
9856
9854
|
}, Nu = () => Promise.all([
|
|
9857
9855
|
import("@tiptap/react"),
|
|
9858
9856
|
import("@tiptap/react/menus"),
|