@topthink/components 1.0.73 → 1.0.75
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,4 +1,4 @@
|
|
|
1
|
-
import{jsx as e,jsxs as t,Fragment as r}from"react/jsx-runtime";import n from"rc-table";import{unstable_batchedUpdates as a}from"react-dom";import{FormControl as o,Table as i}from"react-bootstrap";import{useUrlSearchParams as c}from"use-url-search-params";import{isEqual as l,omit as s}from"lodash";import*as d from"react";import{useState as u,useCallback as p,useRef as m,useEffect as h,useMemo as f,memo as g,forwardRef as v,useImperativeHandle as y}from"react";import{B as b,u as x,P as w,a as j,r as C,i as k,N as S,L as E,T as O,C as V,S as z}from"./index-
|
|
1
|
+
import{jsx as e,jsxs as t,Fragment as r}from"react/jsx-runtime";import n from"rc-table";import{unstable_batchedUpdates as a}from"react-dom";import{FormControl as o,Table as i}from"react-bootstrap";import{useUrlSearchParams as c}from"use-url-search-params";import{isEqual as l,omit as s}from"lodash";import*as d from"react";import{useState as u,useCallback as p,useRef as m,useEffect as h,useMemo as f,memo as g,forwardRef as v,useImperativeHandle as y}from"react";import{B as b,u as x,P as w,a as j,r as C,i as k,N as S,L as E,T as O,C as V,S as z}from"./index-kWLMQNlx.js";import N from"styled-components";import H from"./index-4M7c5XF1.js";import"sweetalert2/dist/sweetalert2.js";import"sweetalert2-react-content";import"axios";import"query-string";import"retry-axios";import"rc-notification";import"classnames";import"react-async-hook";import"@topthink/json-form";const q=function(t){let{indeterminate:r=!1,...n}=t;const a=m(null);return h((()=>{a.current&&(a.current.indeterminate=r)}),[r]),e("input",{ref:a,...n,className:"form-check-input",type:"checkbox"})};var K;function M(){return M=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},M.apply(this,arguments)}const B=e=>d.createElement("svg",M({xmlns:"http://www.w3.org/2000/svg",width:16,height:16,fill:"currentColor",viewBox:"0 0 1024 1024"},e),K||(K=d.createElement("path",{d:"M252.069 906.496h520.283c89.582 0 134.144-44.562 134.144-132.846V250.331c0-88.283-44.562-132.845-134.144-132.845H252.069c-89.143 0-134.583 44.141-134.583 132.845V773.67c0 88.704 45.44 132.845 134.583 132.845zm1.28-68.992c-42.844 0-66.853-22.71-66.853-67.291V253.806c0-44.58 24.01-67.292 66.853-67.292h517.723c42.423 0 66.432 22.711 66.432 67.292v516.388c0 44.58-24.01 67.292-66.432 67.292zM511.78 714.496c22.71 0 36.425-15.854 36.425-40.704V547.365H682.35c24.009 0 40.722-12.874 40.722-35.584 0-23.132-15.854-36.426-40.722-36.426H548.206V340.773c0-24.85-13.715-40.704-36.425-40.704s-35.566 16.713-35.566 40.722v134.583H342.49c-24.85 0-41.142 13.275-41.142 36.407 0 22.71 17.152 35.584 41.142 35.584h133.724v126.427c0 23.99 12.855 40.704 35.566 40.704"})));var P;function F(){return F=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},F.apply(this,arguments)}const T=e=>d.createElement("svg",F({xmlns:"http://www.w3.org/2000/svg",width:16,height:16,fill:"currentColor",viewBox:"0 0 1024 1024"},e),P||(P=d.createElement("path",{d:"M252.069 906.496h520.283c89.582 0 134.144-44.562 134.144-132.846V250.331c0-88.283-44.562-132.845-134.144-132.845H252.069c-89.143 0-134.583 44.141-134.583 132.845V773.67c0 88.704 45.44 132.845 134.583 132.845zm1.28-68.992c-42.844 0-66.853-22.71-66.853-67.291V253.806c0-44.58 24.01-67.292 66.853-67.292h517.723c42.423 0 66.432 22.711 66.432 67.292v516.388c0 44.58-24.01 67.292-66.432 67.292zm86.582-289.719h344.576c23.991 0 40.704-12.855 40.704-35.566 0-23.15-15.433-36.425-40.704-36.425H339.931c-24.868 0-40.722 13.276-40.722 36.425 0 22.711 16.713 35.566 40.722 35.566"})));function D(r){let{data:n,options:a,columns:o,onSearch:i}=r;const[c,s]=u(0),[d,m]=u(n);h((()=>{l(n,d)||(m(n),s((e=>e+1)))}),[n]);const[g,v,y]=f((()=>{const e={"ui:col":10,"ui:order":a.order},t={},r={};a.fields.forEach((n=>{const i=o.find((e=>e.dataIndex===n));if(i){const o=i.title;if("string"==typeof o){if(e[n]={"ui:col":4,"ui:labelCol":3,"ui:placeholder":"请输入",...a.ui?.[n]},i.valueEnum){const t=i.valueEnum;return e[n]["ui:placeholder"]="请选择",r[n]={title:o,type:"string",enum:Object.keys(t).flatMap((e=>"string"==typeof t[e].text?[e]:[])),enumNames:Object.keys(t).flatMap((e=>{const r=t[e].text;return"string"==typeof r?[r]:[]}))}}t[n]=void 0,r[n]={title:o,type:"string"}}}})),a.extraFields&&Object.entries(a.extraFields).forEach((n=>{let[o,i]=n;e[o]={"ui:col":4,"ui:labelCol":3,"ui:placeholder":"请输入",...a.ui?.[o]},t[o]=void 0,r[o]={title:i,type:"string"}}));return[{type:"object",properties:r},e,t]}),[a.fields,a.extraFields]),x=p((e=>{let{formData:t}=e;m(t),i({...y,...t})}),[i,y]),w=p((()=>{i(y)}),[i,y]);return e(I,{children:e(H,{formContext:{layout:"horizontal"},schema:g,uiSchema:v,onSubmit:x,formData:d,children:e("div",{className:"col-2 ms-auto mt-auto",children:t("div",{className:"justify-content-end d-flex gap-2 ",children:[e(b,{className:"px-4",onClick:w,variant:"secondary",children:"重置"}),e(b,{className:"px-4",type:"submit",variant:"primary",children:"查询"})]})})})},c)}const I=N.div`
|
|
2
2
|
margin-bottom: 1rem;
|
|
3
3
|
`;function R(t){let{keyword:r,onKeywordChange:n}=t;const[a,i]=u(r),c=x(n,500);h((()=>{i(r)}),[r]);const l=p((e=>{i(e.target.value),c(e.target.value)}),[c,i]);return e(o,{value:a,onChange:l,type:"search",placeholder:"Search..."})}const _=N.thead`
|
|
4
4
|
th {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as t}from"react/jsx-runtime";import o,{getRegistry as r}from"@topthink/json-form";import*as a from"react";import{forwardRef as e,useState as n,useCallback as i}from"react";import s from"axios";import{b as p,r as l,B as m}from"./index-kWLMQNlx.js";import{mapValues as c}from"lodash";import"sweetalert2/dist/sweetalert2.js";import"sweetalert2-react-content";import"react-bootstrap";import"query-string";import"retry-axios";import"rc-notification";import"styled-components";import"classnames";import"use-url-search-params";import"react-async-hook";const d=require("ajv-i18n/localize/zh"),u=a.lazy((()=>import("./editor-widget-CQ3zv-Xu.js"))),f=o=>t(a.Suspense,{fallback:null,children:t(u,{...o})}),h={upload:function(o){let{options:a,...e}=o;const{widgets:n}=r();return a.endpoint&&(a.onUpload=async t=>{const o=new FormData;o.set("file",t);const{url:r,value:e}=await l({url:a.endpoint,method:"post",data:o});return{url:r,value:e}}),t(n.upload,{...e,options:a})},avatar:function(o){let{options:a,...e}=o;const{widgets:n}=r();return a.endpoint&&(a.onUpload=async t=>{const o=new FormData;o.set("file",t);const{url:r}=await l({url:a.endpoint,method:"post",data:o});return r}),t(n.avatar,{...e,options:a})},editor:function(o){let{options:r,...a}=o;return r.endpoint&&(r.onUpload=async t=>{const o=new FormData;o.set("file",t);const{url:a}=await l({url:r.endpoint,method:"post",data:o});return a}),t(f,{...a,options:r})},typeahead:function(o){let{options:a,...e}=o;const{widgets:n}=r();return a.endpoint&&(a.onSearch=async t=>{let{value:o,query:r}=t;return await l({url:a.endpoint,params:{value:o,query:r}})}),t(n.typeahead,{...e,options:a})}},y=e(((r,a)=>{let{action:e,method:u="post",onSuccess:f,formData:y,onSubmitting:w,onSubmit:g,onChange:v,submitText:b="提交",transformData:x,children:D,...j}=r;const[S,k]=n(),[q,_]=p(!1),[z,E]=n(y),F=i((async(t,o)=>{if(!q)try{if(_(!0),w&&w(!0),e){let{formData:o}=t;x&&(o=x(o));try{const t=await l({url:e,method:u,data:o});return k(void 0),f&&await f(t),t}catch(t){if(!s.isAxiosError(t))throw t;k((t=>{const o=t.errors;return"string"==typeof o?{__errors:[o]}:c(o,(t=>({__errors:[t]})))})(t))}}else if(g)return await g(t,o)}finally{_(!1),w&&w(!1)}}),[e,u,g]),U=i((t=>{const{formData:o}=t;E(o),v&&v(t)}),[E,v]),C=i((t=>(t=t.map((t=>({keyword:t.name,dataPath:t.property,...t}))),d(t),t)),[]),N=t(m,{className:"px-4",loading:q,type:"submit",variant:"primary",children:b});return"function"==typeof D&&(D=D({submit:N,loading:q})),t(o,{ref:a,extraErrors:S,onSubmit:F,transformErrors:C,noHtml5Validate:!0,noValidate:!0,...j,formData:z,onChange:U,widgets:h,children:D||t("div",{className:"col-12",children:N})})}));export{y as default};
|
|
@@ -63,8 +63,10 @@ import e from"sweetalert2/dist/sweetalert2.js";import t from"sweetalert2-react-c
|
|
|
63
63
|
margin-bottom: 4px;
|
|
64
64
|
color: rgba(0, 0, 0, .45);
|
|
65
65
|
font-size: 1.1rem;
|
|
66
|
-
`;function De(){}function Me(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e}function Ie(e){return"current_page"in e}function Ue(e){let{total:t=0,onChange:r=De,defaultCurrent:o=1,defaultPageSize:i=10,className:c,...l}=e;const[d,f]=a(o),[m,p]=a(i);s((()=>{Me(l.current)&&f(l.current)}),[l.current]),s((()=>{Me(l.pageSize)&&p(l.pageSize)}),[l.pageSize]);const g=h((()=>Math.floor((t-1)/m)+1),[t,m]),y=u((e=>()=>{e!==d&&(f(e),r(e,m))}),[r,d,m]),x=d-1>0?d-1:0,b=d+1<g?d+1:g,v=[];let w=null,k=null,C=null,N=null;if(g<=7)for(let e=1;e<=g;e+=1){const t=d===e;v.push(n(B.Item,{active:t,onClick:y(e),children:e},e))}else{N=n(B.Last,{onClick:y(g)},"last"),C=n(B.First,{onClick:y(1)},"first"),w=n(B.Prev,{onClick:y(x)},"prev"),k=n(B.Next,{onClick:y(b)},"next");let e=Math.max(1,d-2),t=Math.min(d+2,g);d-1<=2&&(t=5),g-d<=2&&(e=g-4);for(let r=e;r<=t;r+=1){const e=d===r;v.push(n(B.Item,{active:e,onClick:y(r),children:r},r))}d-1>=4&&3!==d&&v.unshift(w),g-d>=4&&d!==g-2&&v.push(k),1!==e&&v.unshift(C),t!==g&&v.push(N)}return n(B,{className:c,children:v})}function Re(e){let{className:t,value:r,locale:i="zh-CN",currency:a=!0,options:s={}}=e;const c=h((()=>{let e;return e=a?{style:"currency",currency:"CNY"}:{minimumFractionDigits:2},new Intl.NumberFormat(i,{...e,...s})}),[a,i,s]);return t?n("span",{className:t,children:c.format(r)}):n(o,{children:c.format(r)})}function qe(e){let{loading:t,disabled:r,children:o,...i}=e;return n(C,{...i,disabled:t||r,children:t?"Loading…":o})}const Ve=p((()=>import("./image-zoom-OrIPGqh0.js")));function Ge(e){return n(g,{fallback:null,children:n(Ve,{...e})})}function Ye(e){let{url:t,method:n,confirm:r,onSuccess:o,children:i,disabled:a,as:s=ne,...c}=e;const[l,d]=me(!1),h=u((async e=>{e.preventDefault();try{if(d(!0),r&&!await oe.confirm({message:r}))return;const e="string"==typeof t?{url:t,method:n}:{method:n,...t},i=await he(e);o&&o(i)}catch(e){ue(e)}finally{d(!1)}}),[t,n,d]);return y(s,{...c,disabled:a||l,onClick:h},i)}const Je=p((()=>import("./index-
|
|
66
|
+
`;function De(){}function Me(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e}function Ie(e){return"current_page"in e}function Ue(e){let{total:t=0,onChange:r=De,defaultCurrent:o=1,defaultPageSize:i=10,className:c,...l}=e;const[d,f]=a(o),[m,p]=a(i);s((()=>{Me(l.current)&&f(l.current)}),[l.current]),s((()=>{Me(l.pageSize)&&p(l.pageSize)}),[l.pageSize]);const g=h((()=>Math.floor((t-1)/m)+1),[t,m]),y=u((e=>()=>{e!==d&&(f(e),r(e,m))}),[r,d,m]),x=d-1>0?d-1:0,b=d+1<g?d+1:g,v=[];let w=null,k=null,C=null,N=null;if(g<=7)for(let e=1;e<=g;e+=1){const t=d===e;v.push(n(B.Item,{active:t,onClick:y(e),children:e},e))}else{N=n(B.Last,{onClick:y(g)},"last"),C=n(B.First,{onClick:y(1)},"first"),w=n(B.Prev,{onClick:y(x)},"prev"),k=n(B.Next,{onClick:y(b)},"next");let e=Math.max(1,d-2),t=Math.min(d+2,g);d-1<=2&&(t=5),g-d<=2&&(e=g-4);for(let r=e;r<=t;r+=1){const e=d===r;v.push(n(B.Item,{active:e,onClick:y(r),children:r},r))}d-1>=4&&3!==d&&v.unshift(w),g-d>=4&&d!==g-2&&v.push(k),1!==e&&v.unshift(C),t!==g&&v.push(N)}return n(B,{className:c,children:v})}function Re(e){let{className:t,value:r,locale:i="zh-CN",currency:a=!0,options:s={}}=e;const c=h((()=>{let e;return e=a?{style:"currency",currency:"CNY"}:{minimumFractionDigits:2},new Intl.NumberFormat(i,{...e,...s})}),[a,i,s]);return t?n("span",{className:t,children:c.format(r)}):n(o,{children:c.format(r)})}function qe(e){let{loading:t,disabled:r,children:o,...i}=e;return n(C,{...i,disabled:t||r,children:t?"Loading…":o})}const Ve=p((()=>import("./image-zoom-OrIPGqh0.js")));function Ge(e){return n(g,{fallback:null,children:n(Ve,{...e})})}function Ye(e){let{url:t,method:n,confirm:r,onSuccess:o,children:i,disabled:a,as:s=ne,...c}=e;const[l,d]=me(!1),h=u((async e=>{e.preventDefault();try{if(d(!0),r&&!await oe.confirm({message:r}))return;const e="string"==typeof t?{url:t,method:n}:{method:n,...t},i=await he(e);o&&o(i)}catch(e){ue(e)}finally{d(!1)}}),[t,n,d]);return y(s,{...c,disabled:a||l,onClick:h},i)}const Je=p((()=>import("./index-4M7c5XF1.js"))),Ke=f(((e,t)=>n(g,{fallback:null,children:n(Je,{...e,ref:t})}))),Qe=p((()=>import("./index--h-_uur9.js"))),We=f(((e,t)=>n(g,{fallback:null,children:n(Qe,{...e,ref:t})})));let Xe=0;function Ze(){let{onHide:e,onShow:t}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const[n,r]=a(!1),[o,i]=a(`visible-${Xe}`),s=u((()=>{r(!1),e&&e()}),[r,e]),c=u((()=>{i("visible-"+ ++Xe)}),[i,Xe]);return{visible:n,show:u((()=>{r(!0),t&&t()}),[r,t]),hide:s,state:{show:n,onHide:s,onExited:c,key:o}}}const et=f(((e,t)=>{let{text:i,onOk:a,modalProps:s,children:c,onShow:l,onHide:d,confirmLoading:u,as:h=ne,...f}=e;const{state:m,show:p,hide:g}=Ze({onShow:l,onHide:d});x(t,(()=>({close:g})));const b=y(h,{...f,onClick:p},i);return r(o,{children:[b,n(oe,{header:i,...s,...m,confirmLoading:u,onOk:async e=>{if(a){!1===await a()&&e.preventDefault()}},children:c})]})})),tt=f(((e,t)=>{let{text:o,onSuccess:s,onSubmit:c,buttonProps:l,modalProps:d,children:h,...f}=e;const[m,p]=a(!1),g=i(null),y=i(null);x(t,(()=>({close:()=>{g.current?.close()}})));const b=u((()=>(y.current?.submit(),!1)),[]),v=u((e=>{s&&s(e),g.current?.close()}),[s]),w=u((async(e,t)=>{c&&await c(e,t)&&g.current?.close()}),[c]);return n(et,{ref:g,text:o,...l,modalProps:d,onOk:b,confirmLoading:m,children:r(Ke,{...f,onSubmitting:p,ref:y,onSuccess:v,onSubmit:w,children:[h,n("input",{type:"submit",hidden:!0})]})})}));function nt(e){let{header:t,children:o,closable:i=!0,show:a,onHide:s,bodyAs:c,headerAs:l="h5",...d}=e;return r(P,{...d,onHide:s,show:a,children:[t&&n(P.Header,{closeButton:i,children:n(P.Title,{as:l,children:t})}),n(P.Body,{as:c,children:o})]})}const rt=f(((e,t)=>{let{text:i,offcanvasProps:a,children:s,onShow:c,onHide:l,as:d=ne,...u}=e;const{state:h,show:f,hide:m}=Ze({onShow:c,onHide:l});x(t,(()=>({close:m})));const p=y(d,{...u,onClick:f},i);return r(o,{children:[p,n(nt,{header:i,...a,...h,children:s})]})}));function ot(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];const n=i(e);return s((()=>{n.current=e})),u((function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return n.current?.(...t)}),t)}function it(e){const{value:t,defaultValue:n,onChange:r,shouldUpdate:o=((e,t)=>e!==t)}=e,i=ot(r),s=ot(o),[c,l]=a(n),d=void 0!==t,u=d?t:c,h=ot((e=>{const t="function"==typeof e?e(u):e;s(u,t)&&(d||l(t),i(t))}),[d,i,u,s]);return[u,h]}const at=f(((e,t)=>{let{className:o,paginate:c=!0,sync:l=!1,columns:d=3,source:h,renderItem:f,renderEmpty:m}=e;const[p,g]=a([]),[y,b]=a(c?{total:0,current:1,pageSize:10}:null),[v,w]=a(!0),[k,C]=I({}),[N,S]=it({value:l?k.page||1:void 0,defaultValue:1,onChange:e=>{l&&C({page:e||void 0})}}),z=u((async()=>{w(!0);try{let e;const t={page:N>1?N:void 0};e="string"==typeof h?await he({url:h,params:t}):await h(t),c&&Ie(e)&&(e.last_page>1&&b({total:e.total,current:e.current_page,pageSize:e.per_page}),e=e.data),g(e)}catch(e){}finally{w(!1)}}),[h,g,N]);s((()=>{z()}),[N]),s((()=>{B.current={reload:z}}),[z]);const B=i({reload:z});return x(t,(()=>B.current)),r(st,{className:o,children:[n(Ne,{wrap:!0,loading:v}),0===p.length&&!v&&m?.(),n(j,{children:p.map(((e,t)=>n(T,{className:"d-flex",md:12/d,children:f(e)},`card-${t}`)))}),y&&n(ct,{...y,onChange:S})]})})),st=_.div`
|
|
67
|
+
|
|
68
|
+
`,ct=_(Ue)`
|
|
67
69
|
margin-bottom: 0;
|
|
68
70
|
justify-content: flex-end;
|
|
69
71
|
margin-top: 1rem;
|
|
70
|
-
`;var
|
|
72
|
+
`;var lt=b(at);function dt(e){let{manual:t,refreshDeps:n,...r}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{execute:o,currentParams:i,error:a,...c}=U((async t=>(e="string"==typeof e?{url:e}:e,await he({...e,...t}))),r);s((()=>{if(!t&&!n)try{o()}catch{}}),[]),s((()=>{n&&l()}),n);const l=u((async()=>{try{i?await o(...i):await o()}catch{}}),[o,i]);if(a&&de(a)){const e=a.errors;a=new Error("string"==typeof e?e:H(e).join(""))}return{refresh:l,execute:o,error:a,...c}}function ut(e,t,n){const r=i(e),o=i(E(e,t,n));return s((()=>{r.current=e})),s((()=>{o.current=E((function(){r.current(...arguments)}),t,n)}),[t,n]),o.current}export{ne as B,ze as C,Be as E,Ke as F,Ge as I,Ne as L,V as M,Re as N,rt as O,Ue as P,ke as R,Pe as S,te as T,it as a,me as b,ce as c,le as d,Ee as e,Ae as f,Le as g,qe as h,Ie as i,Ye as j,We as k,tt as l,et as m,oe as n,nt as o,ee as p,lt as q,he as r,dt as s,Ze as t,ut as u,de as v,ge as w,ue as x};
|
package/es/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{B as Button,C as Card,q as CardList,E as Error,F as Form,I as ImageZoom,L as Loader,h as LoadingButton,M as Message,n as Modal,m as ModalButton,l as ModalForm,N as NumberFormat,o as Offcanvas,O as OffcanvasButton,P as Pagination,j as RequestButton,R as Result,S as Space,g as Statistic,f as Step,e as Steps,k as Table,c as Toast,p as Tooltip,d as isRecord,v as isRequestError,r as request,x as showRequestError,a as useControllableState,u as useDebounce,t as useOverlayState,s as useRequest,b as useSafeState,w as waitPayComplete}from"./index-
|
|
1
|
+
export{B as Button,C as Card,q as CardList,E as Error,F as Form,I as ImageZoom,L as Loader,h as LoadingButton,M as Message,n as Modal,m as ModalButton,l as ModalForm,N as NumberFormat,o as Offcanvas,O as OffcanvasButton,P as Pagination,j as RequestButton,R as Result,S as Space,g as Statistic,f as Step,e as Steps,k as Table,c as Toast,p as Tooltip,d as isRecord,v as isRequestError,r as request,x as showRequestError,a as useControllableState,u as useDebounce,t as useOverlayState,s as useRequest,b as useSafeState,w as waitPayComplete}from"./index-kWLMQNlx.js";export{StyleSheetManager,ThemeProvider,createGlobalStyle,css,keyframes,default as styled}from"styled-components";export{useAsync,useAsyncCallback}from"react-async-hook";import"sweetalert2/dist/sweetalert2.js";import"sweetalert2-react-content";import"react/jsx-runtime";import"react";import"react-bootstrap";import"lodash";import"axios";import"query-string";import"retry-axios";import"rc-notification";import"classnames";import"use-url-search-params";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@topthink/components",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.75",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"prebuild": "rimraf es types",
|
|
6
6
|
"build": "rollup -c --environment NODE_ENV:production",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"@toast-ui/editor": "^3.2.2",
|
|
21
21
|
"@toast-ui/react-editor": "^3.2.3",
|
|
22
22
|
"@topthink/bootstrap": "^1.0.23",
|
|
23
|
-
"@topthink/json-form": "^1.0.
|
|
23
|
+
"@topthink/json-form": "^1.0.52",
|
|
24
24
|
"@types/styled-components": "^5.1.11",
|
|
25
25
|
"ajv-i18n": "^4.0.0",
|
|
26
26
|
"axios": "^0.27.2",
|
|
@@ -64,5 +64,5 @@
|
|
|
64
64
|
},
|
|
65
65
|
"author": "yunwuxin <tzzhangyajun@qq.com> (https://github.com/yunwuxin)",
|
|
66
66
|
"license": "MIT",
|
|
67
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "8771ee69e18444cfd3683ff1f25968b599236eff"
|
|
68
68
|
}
|
package/es/index-qxL7DoAg.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{jsx as t}from"react/jsx-runtime";import r,{getRegistry as o}from"@topthink/json-form";import*as a from"react";import{forwardRef as e,useState as n,useCallback as i}from"react";import s from"axios";import{b as m,r as l,B as p}from"./index-uM81lSNg.js";import{mapValues as c}from"lodash";import"sweetalert2/dist/sweetalert2.js";import"sweetalert2-react-content";import"react-bootstrap";import"query-string";import"retry-axios";import"rc-notification";import"styled-components";import"classnames";import"use-url-search-params";import"react-async-hook";const u=require("ajv-i18n/localize/zh"),d=a.lazy((()=>import("./editor-widget-CQ3zv-Xu.js"))),f=r=>t(a.Suspense,{fallback:null,children:t(d,{...r})}),h={upload:function(r){let{options:a,...e}=r;const{widgets:n}=o();return a.endpoint&&(a.onUpload=async t=>{const r=new FormData;r.set("file",t);const{url:o,value:e}=await l({url:a.endpoint,method:"post",data:r});return{url:o,value:e}}),t(n.upload,{...e,options:a})},editor:function(r){let{options:o,...a}=r;return o.endpoint&&(o.onUpload=async t=>{const r=new FormData;r.set("file",t);const{url:a}=await l({url:o.endpoint,method:"post",data:r});return a}),t(f,{...a,options:o})},typeahead:function(r){let{options:a,...e}=r;const{widgets:n}=o();return a.endpoint&&(a.onSearch=async t=>{let{value:r,query:o}=t;return await l({url:a.endpoint,params:{value:r,query:o}})}),t(n.typeahead,{...e,options:a})}},y=e(((o,a)=>{let{action:e,method:d="post",onSuccess:f,formData:y,onSubmitting:w,onSubmit:g,onChange:b,submitText:x="提交",transformData:v,children:D,...j}=o;const[S,k]=n(),[q,_]=m(!1),[z,E]=n(y),C=i((async(t,r)=>{if(!q)try{if(_(!0),w&&w(!0),e){let{formData:r}=t;v&&(r=v(r));try{const t=await l({url:e,method:d,data:r});return k(void 0),f&&await f(t),t}catch(t){if(!s.isAxiosError(t))throw t;k((t=>{const r=t.errors;return"string"==typeof r?{__errors:[r]}:c(r,(t=>({__errors:[t]})))})(t))}}else if(g)return await g(t,r)}finally{_(!1),w&&w(!1)}}),[e,d,g]),F=i((t=>{const{formData:r}=t;E(r),b&&b(t)}),[E,b]),N=i((t=>(t=t.map((t=>({keyword:t.name,dataPath:t.property,...t}))),u(t),t)),[]),U=t(p,{className:"px-4",loading:q,type:"submit",variant:"primary",children:x});return"function"==typeof D&&(D=D({submit:U,loading:q})),t(r,{ref:a,extraErrors:S,onSubmit:C,transformErrors:N,noHtml5Validate:!0,noValidate:!0,...j,formData:z,onChange:F,widgets:h,children:D||t("div",{className:"col-12",children:U})})}));export{y as default};
|