@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.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, validator: b, extensions: x, commands: S, commandsTrigger: C, wrapperClassName: w, inheritWrapperClassName: T = !0, before: E, after: D }) => {
9607
- let O = u(), k = Y("CodeEditor"), A = ts({
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: j, handleChange: M, formWrapClass: N } = Dd({
9610
+ }), { value: M, handleChange: N, formWrapClass: P } = Dd({
9611
9611
  name: e,
9612
9612
  onChange: n,
9613
9613
  defaultValue: r,
9614
- wrapperClassName: w,
9615
- inheritWrapperClassName: T
9616
- }), P = Ed(e, {
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) try {
9622
- await Su(t, o);
9623
- } catch (e) {
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 b?.(e);
9625
+ return await x?.(e);
9628
9626
  }
9629
- }), F = m(null), I = m(null), L = m(null), [R, z] = h(!0), [B, V] = h({
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
- }), H = m(j ?? ""), U = m(B);
9635
- U.current = B;
9636
- let W = S?.length ? C ?? "/" : void 0, ee = (S?.length ?? 0) >= 10, G = t.useMemo(() => new Map((S ?? []).map((e) => [e.name, e])), [S]), te = t.useMemo(() => (S ?? []).map((e) => ({
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: `${W ?? "/"}${e.name}`,
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
- })), [S, W]), ne = t.useMemo(() => {
9641
+ })), [C, ee]), re = t.useMemo(() => {
9644
9642
  let e = [], n;
9645
- return te.forEach((r) => {
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
- }, [te]);
9652
+ }, [ne]);
9655
9653
  l(() => {
9656
- I.current || (H.current = j ?? "");
9657
- }, [j]);
9658
- let re = s((t) => {
9659
- H.current = t, M({ target: {
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
- }, [M, e]), K = m(re);
9664
- K.current = re;
9665
- let ie = s(() => {
9666
- V({
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
- }, []), ae = s(async (e, t) => {
9673
- let n = G.get(e.value);
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
- }, [G]);
9680
+ }, [te]);
9683
9681
  l(() => {
9684
9682
  let e = !1, t = null;
9685
9683
  return Ou(o).then((n) => {
9686
- if (e || !F.current) return;
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 && K.current(e.state.doc.toString());
9730
+ e.docChanged && ie.current(e.state.doc.toString());
9733
9731
  }),
9734
- ...x ?? []
9732
+ ...S ?? []
9735
9733
  ];
9736
- W && i.push(n.EditorView.updateListener.of((e) => {
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
- U.current.open && ie();
9737
+ W.current.open && ae();
9740
9738
  return;
9741
9739
  }
9742
- let n = Au(e.state.doc.toString(), t.from, W);
9740
+ let n = Au(e.state.doc.toString(), t.from, ee);
9743
9741
  if (!n) {
9744
- U.current.open && ie();
9742
+ W.current.open && ae();
9745
9743
  return;
9746
9744
  }
9747
- let r = e.view.coordsAtPos(t.from), i = ju(e.view, W);
9748
- !r || !i || V({
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: () => U.current.open ? (L.current?.moveNext(), !0) : !1
9758
+ run: () => W.current.open ? (R.current?.moveNext(), !0) : !1
9761
9759
  },
9762
9760
  {
9763
9761
  key: "ArrowUp",
9764
- run: () => U.current.open ? (L.current?.movePrev(), !0) : !1
9762
+ run: () => W.current.open ? (R.current?.movePrev(), !0) : !1
9765
9763
  },
9766
9764
  {
9767
9765
  key: "Enter",
9768
- run: () => U.current.open ? (L.current?.selectActive(), !0) : !1
9766
+ run: () => W.current.open ? (R.current?.selectActive(), !0) : !1
9769
9767
  },
9770
9768
  {
9771
9769
  key: "Tab",
9772
- run: () => U.current.open ? (L.current?.selectActive(), !0) : !1
9770
+ run: () => W.current.open ? (R.current?.selectActive(), !0) : !1
9773
9771
  },
9774
9772
  {
9775
9773
  key: "Escape",
9776
- run: () => U.current.open ? (L.current?.close(), !0) : !1
9774
+ run: () => W.current.open ? (R.current?.close(), !0) : !1
9777
9775
  }
9778
9776
  ])), n.EditorView.domEventHandlers({ keydown: (e) => {
9779
- if (!U.current.open) return !1;
9777
+ if (!W.current.open) return !1;
9780
9778
  switch (e.key) {
9781
- case "ArrowDown": return e.preventDefault(), L.current?.moveNext(), !0;
9782
- case "ArrowUp": return e.preventDefault(), L.current?.movePrev(), !0;
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(), L.current?.selectActive(), !0;
9785
- case "Escape": return e.preventDefault(), L.current?.close(), !0;
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: H.current,
9788
+ doc: U.current,
9791
9789
  extensions: i
9792
9790
  });
9793
9791
  t = new n.EditorView({
9794
9792
  state: a,
9795
- parent: F.current
9796
- }), ku(t.scrollDOM, A), I.current = t, z(!1);
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), z(!1));
9796
+ e || (console.error("[CodeEditor] Failed to load CodeMirror:", t), B(!1));
9799
9797
  }), () => {
9800
- e = !0, t && (t.destroy(), I.current = null);
9798
+ e = !0, t && (t.destroy(), L.current = null);
9801
9799
  };
9802
9800
  }, [
9803
- ie,
9804
- x,
9801
+ ae,
9802
+ S,
9805
9803
  g,
9806
9804
  o,
9807
9805
  c,
9808
- W
9806
+ ee
9809
9807
  ]), l(() => {
9810
- let e = j ?? "", t = I.current;
9811
- t && e !== H.current && (H.current = e, t.dispatch({ changes: {
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
- }, [j]), l(() => {
9817
- let e = I.current;
9818
- e && ku(e.scrollDOM, A);
9814
+ }, [M]), l(() => {
9815
+ let e = L.current;
9816
+ e && ku(e.scrollDOM, j);
9819
9817
  }, [
9820
- A.fill,
9821
- A.resolvedMinHeight,
9822
- A.resolvedMaxHeight
9818
+ j.fill,
9819
+ j.resolvedMinHeight,
9820
+ j.resolvedMaxHeight
9823
9821
  ]);
9824
- let oe = X("w-full overflow-hidden border border-input", k.CodeEditor?.className, i, R && "flex items-center justify-center bg-muted text-muted-foreground text-sm", P && "border-destructive", E ? "rounded-l-none" : "rounded-l-md", D ? "rounded-r-none" : "rounded-r-md"), se = /* @__PURE__ */ t.createElement("div", { className: X("min-w-0 flex-1", A.fill && "h-full flex flex-col", oe) }, R && /* @__PURE__ */ t.createElement("div", {
9825
- style: { minHeight: A.fill ? void 0 : A.resolvedMinHeight },
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: F,
9833
- className: X(R && "hidden", A.fill && "h-full min-h-0 flex-1")
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(N, A.fill && "h-full flex flex-col min-h-0", k.CodeEditor?.wrapperClassName) }, a && /* @__PURE__ */ t.createElement(Ns, {
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: O,
9836
+ htmlFor: k,
9839
9837
  className: v
9840
- }), /* @__PURE__ */ t.createElement("div", { className: X(E || D ? os : "", A.fill && "flex-1 min-h-0 flex flex-col") }, E && /* @__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") }, E), W && te.length > 0 ? /* @__PURE__ */ t.createElement(Bl, {
9841
- ref: L,
9842
- className: X(A.fill && "flex-1 min-h-0 flex flex-col"),
9843
- trigger: W,
9844
- searchable: ee,
9845
- controlled: B.editorContext ? {
9846
- open: B.open,
9847
- anchorPosition: B.anchorPosition,
9848
- query: B.query,
9849
- editorContext: B.editorContext,
9850
- onClose: ie
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
- ae(e, t);
9851
+ oe(e, t);
9854
9852
  }
9855
- }, ne, se) : se, 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-none rounded-r-md border-l-0") }, D)), P && /* @__PURE__ */ t.createElement(hs, { message: P }), _ && /* @__PURE__ */ t.createElement("p", { className: "mt-1 text-xs text-muted-foreground" }, _));
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"),