mtxuilib 0.0.503 → 0.0.505
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as t,jsxs as n}from"react/jsx-runtime";import{Dialog as
|
|
1
|
+
"use client";import{jsx as t,jsxs as n}from"react/jsx-runtime";import{Dialog as e,DialogContent as i,DialogTrigger as r}from"../../ui/dialog";import{MtButton as g}from"../../ui/ui-mt/Button";const D=l=>{const{title:o,data:a}=l;return n(e,{children:[t(r,{asChild:!0,children:t(g,{variant:"outline",children:o||"debug"})}),t(i,{className:"max-h-lvh w-full overflow-scroll bg-red-100",children:t("pre",{className:" text-xs",children:JSON.stringify(a,null,2)})})]})};export{D as DebugValue};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";var
|
|
1
|
+
"use client";var C=Object.defineProperty,T=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?C(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,c=(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)=>T(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 p=(e,t,o)=>new Promise((r,n)=>{var l=a=>{try{m(o.next(a))}catch(u){n(u)}},s=a=>{try{m(o.throw(a))}catch(u){n(u)}},m=a=>a.done?r(a.value):Promise.resolve(a.value).then(l,s);m((o=o.apply(e,t)).next())});import{Fragment as P,jsx as i}from"react/jsx-runtime";import{Suspense as D,useCallback as I,useMemo as V}from"react";import{atom as k,useAtom as q}from"jotai";import{FormProvider as O,useForm as Q,useFormContext as x}from"react-hook-form";import{toast as U}from"sonner";import{useMtRouter as W}from"../hooks/use-router";const w=k(void 0);function ee(e){const{defaultValues:t,params:o,children:r,mutationUpdate:n,queryMethod:l}=e,s=n.useMutation(),m=I(a=>p(this,null,function*(){try{const u=yield s.mutateAsync(a);U("ok",{description:JSON.stringify(u,null,2),action:{label:"Undo",onClick:()=>console.log("Undo")}})}catch(u){U("error",{description:JSON.stringify(u,null,2),action:{label:"Undo",onClick:()=>console.log("Undo")}}),console.log("\u51FA\u9519",u)}}),[s]);return i(P,{children:!t&&l?i(D,{fallback:i(P,{children:"UpdateForm loading"}),children:i(z,{queryMethod:l,params:o,onSubmit:m,children:r})}):i(g,{defaultValues:t,onSubmit:m,children:r})})}function te(e){const[t,o]=q(w),r=x(),n=W();return{handleSubmit:r.handleSubmit(l=>p(this,null,function*(){yield t(l),n.back()})),onCancel:()=>{n.back()},form:r}}function g(e){const{defaultValues:t,onSubmit:o,children:r}=e,n=Q({defaultValues:t});return i(O,F(c({},n),{children:i("form",{onSubmit:n.handleSubmit(o),children:r})}))}function z(e){const a=e,{queryMethod:t,params:o,onSubmit:r}=a,n=M(a,["queryMethod","params","onSubmit"]),[l,s]=t.useSuspenseQuery(o),m=V(()=>{var f,y;const u=s.data;return(f=u.item)!=null&&f.value?(y=u.item)==null?void 0:y.value:s.data},[s.data]);return i(g,c({defaultValues:m,onSubmit:r},n))}export{ee as TrpcUpdateForm,te as useTrpcUpdateForm};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{Fragment as
|
|
1
|
+
"use client";import{Fragment as g,jsx as i}from"react/jsx-runtime";import{createContext as m,useCallback as k,useContext as h,useMemo as o,useState as v}from"react";import{getCookie as w}from"gomtm/clientlib";import{ExtKey_Hostname as c,ExtKey_SelfBackend as u,ExtKey_mtmaccessToken as p,ExtKey_mtmbackend as y,MtM_TOKEN_NAME as d}from"gomtm/consts";import{MtReactQueryProvider as C}from"gomtm/providers/ReactQueryProvider";const a=m(void 0);function b(t){const{children:n,initExtKv:e}=t,r=o(()=>e[u],[e]),l=o(()=>e[y],[e]),f=o(()=>e[c],[e]),x=o(()=>e[p],[e]);return i(g,{children:i(a.Provider,{value:{extKv:e,token:x,hostname:f,backendUrl:l,trpcBackendUrl:r},children:i(C,{children:n})})})}function s(){const t=h(a);if(t===void 0)throw new Error("useTrpcApp must be used within a TrpcAppProvider");return t}const U=()=>{const{backendUrl:t}=s();return t},E=()=>{const{hostname:t}=s();return t||window.location.host},_=()=>{const t=E(),{token:n}=s();return k(r=>{switch(r){case c:return t;case p:return n;case u:return;default:throw new Error(`extinfo key error: ${r}`)}},[t,n])},B=()=>{const[t]=v(typeof window!="undefined"?w(d):"");return{token:t||"",setToken:n=>{typeof window!="undefined"&&(document.cookie=`${d}=${n}`)}}};export{b as TrpcAppProvider,_ as useExtInfo,E as useHostname,U as useMtmBackendUrl,B as useToken,s as useTrpcApp};
|