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
- type ResolverDef = {
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 p=Object.getOwnPropertySymbols;var S=Object.prototype.hasOwnProperty,h=Object.prototype.propertyIsEnumerable;var y=(e,t,o)=>t in e?T(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,c=(e,t)=>{for(var o in t||(t={}))S.call(t,o)&&y(e,o,t[o]);if(p)for(var o of p(t))h.call(t,o)&&y(e,o,t[o]);return e},b=(e,t)=>I(e,V(t));var F=(e,t)=>{var o={};for(var r in e)S.call(e,r)&&t.indexOf(r)<0&&(o[r]=e[r]);if(e!=null&&p)for(var r of p(e))t.indexOf(r)<0&&h.call(e,r)&&(o[r]=e[r]);return o};var M=(e,t,o)=>new Promise((r,a)=>{var d=n=>{try{u(o.next(n))}catch(s){a(s)}},i=n=>{try{u(o.throw(n))}catch(s){a(s)}},u=n=>n.done?r(n.value):Promise.resolve(n.value).then(d,i);u((o=o.apply(e,t)).next())});import{Fragment as C,jsx as m}from"react/jsx-runtime";import{Suspense as D,useCallback as O,useMemo as U}from"react";import{Provider as k,atom as x,createStore as Q,useAtom as q}from"jotai";import{FormProvider as W,useForm as z,useFormContext as A}from"react-hook-form";import{toast as P}from"sonner";const g=x(void 0);function ee(e){const{defaultValues:t,params:o,children:r,mutationUpdate:a,queryMethod:d}=e,i=a.useMutation(),u=O(s=>M(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]),n=U(()=>{const s=Q();return s.set(g,()=>u),s},[u]);return m(k,{store:n,children:t?m(v,{defaultValues:t,onSubmit:u,children:r}):m(C,{children:m(D,{fallback:m(C,{children:"ConnectEsUpdateForm loading"}),children:m(w,{queryMethod:d,params:o,onSubmit:u,children:r})})})})}function te(e){const[t,o]=q(g),r=A();return{handleSubmit:r.handleSubmit(a=>t(a)),form:r}}function v(e){const{defaultValues:t,onSubmit:o,children:r}=e,a=z({defaultValues:t});return m(W,b(c({},a),{children:m("form",{onSubmit:a.handleSubmit(o),children:r})}))}function w(e){const n=e,{queryMethod:t,params:o,onSubmit:r}=n,a=F(n,["queryMethod","params","onSubmit"]),[d,i]=t.useSuspenseQuery(o),u=U(()=>{var l,f;const s=i.data;return(l=s.item)!=null&&l.value?(f=s.item)==null?void 0:f.value:i.data},[i.data]);return m(v,c({defaultValues:u,onSubmit:r},a))}export{ee as TrpcUpdateForm,te as useTrpcUpdateForm};
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};
@@ -0,0 +1,6 @@
1
+ export type ResolverDef = {
2
+ input: any;
3
+ output: any;
4
+ transformer: boolean;
5
+ errorShape: any;
6
+ };
File without changes