mtxuilib 0.0.459 → 0.0.460
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.
|
@@ -3,12 +3,7 @@ import type { Message, PartialMessage } from "@bufbuild/protobuf";
|
|
|
3
3
|
import { DecoratedMutation, DecoratedQuery } from "@trpc/react-query/dist/createTRPCReact";
|
|
4
4
|
import { UseFormProps } from "react-hook-form";
|
|
5
5
|
import { z } from "zod";
|
|
6
|
-
|
|
7
|
-
input: any;
|
|
8
|
-
output: any;
|
|
9
|
-
transformer: boolean;
|
|
10
|
-
errorShape: any;
|
|
11
|
-
};
|
|
6
|
+
import { ResolverDef } from "../lib/trpc/types";
|
|
12
7
|
export declare function TrpcUpdateForm<TDef extends ResolverDef>(props: {
|
|
13
8
|
defaultValues?: any;
|
|
14
9
|
mutationUpdate: DecoratedMutation<TDef>;
|
|
@@ -17,6 +12,7 @@ export declare function useTrpcUpdateForm<TSchema extends z.ZodType>(props: Omit
|
|
|
17
12
|
schema?: TSchema;
|
|
18
13
|
}): {
|
|
19
14
|
handleSubmit: (e?: import("react").BaseSyntheticEvent<object, any, any> | undefined) => Promise<void>;
|
|
15
|
+
onCancel: () => void;
|
|
20
16
|
form: import("react-hook-form").UseFormReturn<z.TypeOf<TSchema>, any, undefined>;
|
|
21
17
|
};
|
|
22
18
|
declare function FormInner(props: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";var T=Object.defineProperty,I=Object.defineProperties;var V=Object.getOwnPropertyDescriptors;var
|
|
1
|
+
"use client";var T=Object.defineProperty,I=Object.defineProperties;var V=Object.getOwnPropertyDescriptors;var d=Object.getOwnPropertySymbols;var h=Object.prototype.hasOwnProperty,b=Object.prototype.propertyIsEnumerable;var S=(e,t,o)=>t in e?T(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,p=(e,t)=>{for(var o in t||(t={}))h.call(t,o)&&S(e,o,t[o]);if(d)for(var o of d(t))b.call(t,o)&&S(e,o,t[o]);return e},F=(e,t)=>I(e,V(t));var M=(e,t)=>{var o={};for(var r in e)h.call(e,r)&&t.indexOf(r)<0&&(o[r]=e[r]);if(e!=null&&d)for(var r of d(e))t.indexOf(r)<0&&b.call(e,r)&&(o[r]=e[r]);return o};var f=(e,t,o)=>new Promise((r,n)=>{var c=a=>{try{u(o.next(a))}catch(s){n(s)}},i=a=>{try{u(o.throw(a))}catch(s){n(s)}},u=a=>a.done?r(a.value):Promise.resolve(a.value).then(c,i);u((o=o.apply(e,t)).next())});import{Fragment as C,jsx as m}from"react/jsx-runtime";import{Suspense as k,useCallback as D,useMemo as U}from"react";import{Provider as O,atom as x,createStore as Q,useAtom as q}from"jotai";import{FormProvider as W,useForm as w,useFormContext as z}from"react-hook-form";import{toast as P}from"sonner";import{useMtRouter as A}from"../hooks/use-router";const g=x(void 0);function oe(e){const{defaultValues:t,params:o,children:r,mutationUpdate:n,queryMethod:c}=e,i=n.useMutation(),u=D(s=>f(this,null,function*(){try{const l=yield i.mutateAsync(s);P("ok",{description:JSON.stringify(l,null,2),action:{label:"Undo",onClick:()=>console.log("Undo")}})}catch(l){P("error",{description:JSON.stringify(l,null,2),action:{label:"Undo",onClick:()=>console.log("Undo")}}),console.log("\u51FA\u9519",l)}}),[i]),a=U(()=>{const s=Q();return s.set(g,()=>u),s},[u]);return m(O,{store:a,children:t?m(v,{defaultValues:t,onSubmit:u,children:r}):m(C,{children:m(k,{fallback:m(C,{children:"ConnectEsUpdateForm loading"}),children:m(R,{queryMethod:c,params:o,onSubmit:u,children:r})})})})}function re(e){const[t,o]=q(g),r=z(),n=A();return{handleSubmit:r.handleSubmit(c=>f(this,null,function*(){yield t(c),n.back()})),onCancel:()=>{n.back()},form:r}}function v(e){const{defaultValues:t,onSubmit:o,children:r}=e,n=w({defaultValues:t});return m(W,F(p({},n),{children:m("form",{onSubmit:n.handleSubmit(o),children:r})}))}function R(e){const a=e,{queryMethod:t,params:o,onSubmit:r}=a,n=M(a,["queryMethod","params","onSubmit"]),[c,i]=t.useSuspenseQuery(o),u=U(()=>{var l,y;const s=i.data;return(l=s.item)!=null&&l.value?(y=s.item)==null?void 0:y.value:i.data},[i.data]);return m(v,p({defaultValues:u,onSubmit:r},n))}export{oe as TrpcUpdateForm,re as useTrpcUpdateForm};
|
|
File without changes
|