@topthink/components 1.0.68 → 1.0.70
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/es/index-RvCEJ0zy.js +39 -0
- package/es/index-gIRl3vp6.js +70 -0
- package/es/index-zJSNEC-2.js +1 -0
- package/es/index.js +1 -1
- package/package.json +3 -3
- package/types/components/card-list.d.ts +19 -0
- package/types/components/pagination.d.ts +2 -0
- package/types/index.d.ts +1 -0
- package/es/index-WNXBQWc1.js +0 -66
- package/es/index-mlGSIgGo.js +0 -39
- package/es/index-oPMscx3h.js +0 -1
|
@@ -0,0 +1,39 @@
|
|
|
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-gIRl3vp6.js";import N from"styled-components";import H from"./index-zJSNEC-2.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
|
+
margin-bottom: 1rem;
|
|
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
|
+
th {
|
|
5
|
+
padding: 0.5rem 0.5rem;
|
|
6
|
+
border-bottom-width: 1px;
|
|
7
|
+
border-color: var(--bs-border-color);
|
|
8
|
+
}
|
|
9
|
+
`,A={table:t=>e(i,{...t,className:"mb-0 align-middle table-hover"}),header:{wrapper:t=>e(_,{...t})}},L=N.a`
|
|
10
|
+
cursor: pointer;
|
|
11
|
+
width: 28px;
|
|
12
|
+
height: 28px;
|
|
13
|
+
display: inline-flex;
|
|
14
|
+
align-items: center;
|
|
15
|
+
justify-content: center;
|
|
16
|
+
vertical-align: middle;
|
|
17
|
+
`,$=function(t){let{record:r,expanded:n,expandable:a,onExpand:o}=t;return e(L,a?{onClick:e=>o(r,e),children:e(n?T:B,{})}:{})},G=N(w)`
|
|
18
|
+
margin-bottom: 0;
|
|
19
|
+
justify-content: flex-end;
|
|
20
|
+
margin-top: 1rem;
|
|
21
|
+
`,J=v(((o,i)=>{let{source:l,rowKey:d="id",paginate:g=!0,toolBarRender:v,columns:b=[],search:x,rowSelection:w,card:z=!0,expandable:N={},sync:H=!1,...K}=o;const[M,B]=u([]),[P,F]=u(g?{total:0,current:1,pageSize:10}:null),[T,I]=u(!0),[_,L]=c({}),[J,Q]=function(t,r,n){const[a,o]=u((()=>new Set(t?.selectedRowKeys||[]))),i=e=>"string"==typeof r?e[r]:r(e),c=e=>n.find((t=>i(t)===e)),l=p((e=>{e instanceof Set||(e=new Set(e)),o(e);const r=Array.from(e),n=r.map((function(e){return c(e)}));t?.onChange&&t?.onChange(r,n)}),[c]);return[p((r=>{if(!t)return r;const o=n.map(i),c=o.every((function(e){return a.has(e)})),s=o.some((function(e){return a.has(e)}));return[{key:"selection",title:e(q,{checked:c&&n.length>0,indeterminate:!c&&s,onChange:()=>{c?o.forEach((function(e){a.delete(e)})):o.forEach((function(e){a.add(e)})),l(new Set(a))}}),width:30,align:"center",render(t){let{record:r}=t;const n=i(r),o=a.has(n);return e(q,{checked:o,onChange:()=>{o?a.delete(n):a.add(n),l(new Set(a))}})}},...r]}),[n,t,a]),l]}(w,d,M),Z=f((()=>s(_,["q","page"])),[_]),[ee,te]=j({value:H?Z:void 0,defaultValue:{},onChange:e=>{H&&L(e)}}),[re,ne]=j({value:H?_.q||"":void 0,defaultValue:"",onChange:e=>{H&&L({q:e||void 0})}}),[ae,oe]=j({value:H?_.page||1:void 0,defaultValue:1,onChange:e=>{H&&L({page:e||void 0})}}),ie=p((async()=>{I(!0),Q([]);try{let e;const t={...ee,q:re,page:ae>1?ae:void 0};e="string"==typeof l?await C({url:l,params:t}):await l(t),g&&k(e)&&(F({total:e.total,current:e.current_page,pageSize:e.per_page}),e=e.data),B(e)}catch(e){}finally{I(!1)}}),[l,B,re,ae,ee]);h((()=>{ie()}),[re,ae,ee]);const ce=m({reload:ie});h((()=>{ce.current={reload:ie}}),[ie]),y(i,(()=>ce.current));const le=f((()=>J(b).map((t=>{let{render:r,valueType:n,valueEnum:a,...o}=t;const i={...o};return r?i.render=(e,t,n)=>r({value:e,record:t,index:n,action:ce.current}):"currency"===n?i.render=t=>e(S,{value:t}):a&&(i.render=t=>a[t]?a[t].status?e("span",{className:`text-${a[t].status}`,children:a[t].text}):a[t].text:t),i}))),[b,J,ce]),se=t(r,{children:[e(E,{loading:T}),"object"==typeof x&&e(D,{data:ee,columns:b,options:x,onSearch:e=>{a((()=>{oe(1),te(e)}))}}),!1!==v&&t(U,{children:[e(X,{size:12,children:v&&v(ce.current)}),t(W,{size:12,children:[!0===x&&e(R,{keyword:re,onKeywordChange:e=>{a((()=>{oe(1),ne(e)}))}}),e(Y,{onClick:ce.current.reload,children:e("i",{className:"bi bi-arrow-repeat"})})]})]}),e(O.Provider,{value:!0,children:e(n,{...K,expandable:{expandIcon:$,...N},rowKey:d,columns:le,components:A,data:M})}),P&&e(G,{...P,onChange:oe})]});return z?e(V,{children:se}):se}));var Q=g(J);const U=N.div`
|
|
22
|
+
display: flex;
|
|
23
|
+
justify-content: space-between;
|
|
24
|
+
padding-bottom: 1rem;
|
|
25
|
+
height: 48px;
|
|
26
|
+
border-bottom: 2px solid #212529;
|
|
27
|
+
`,W=N(z)`
|
|
28
|
+
|
|
29
|
+
`,X=N(z)`
|
|
30
|
+
|
|
31
|
+
`,Y=N.span`
|
|
32
|
+
cursor: pointer;
|
|
33
|
+
font-size: 20px;
|
|
34
|
+
line-height: 1;
|
|
35
|
+
|
|
36
|
+
&:hover {
|
|
37
|
+
color: var(--bs-primary);
|
|
38
|
+
}
|
|
39
|
+
`;export{Q as default};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import e from"sweetalert2/dist/sweetalert2.js";import t from"sweetalert2-react-content";import{jsx as n,jsxs as r,Fragment as o}from"react/jsx-runtime";import{useRef as i,useState as a,useEffect as s,createContext as c,Fragment as l,useContext as d,useCallback as u,useMemo as h,forwardRef as f,Children as m,lazy as p,Suspense as g,createElement as y,useImperativeHandle as x,memo as v}from"react";import{OverlayTrigger as b,Tooltip as w,Spinner as k,Button as C,Modal as N,Alert as S,Card as z,Pagination as B,Offcanvas as P,Row as j,Col as T}from"react-bootstrap";import{uniqueId as $,values as H,debounce as E}from"lodash";import A from"axios";import L from"query-string";import*as F from"retry-axios";import O from"rc-notification";import _,{css as D}from"styled-components";import M from"classnames";import{useUrlSearchParams as I}from"use-url-search-params";import{useAsyncCallback as U}from"react-async-hook";const R=t(e),q={confirmButtonText:"确定",cancelButtonText:"取消"},V={confirm:async e=>{const{isConfirmed:t}=await R.fire({...q,icon:"warning",showCancelButton:!0,...e,async preConfirm(t){if(e.preConfirm)try{return await e.preConfirm(t)}catch(e){return e instanceof Error&&R.showValidationMessage(e.message),!1}return!0}});return t},success:e=>{R.fire({...q,toast:!0,position:"top",icon:"success",timer:2e3,showConfirmButton:!1,...e})},error:e=>{R.fire({...q,toast:!0,position:"top",icon:"error",timer:5e3,showConfirmButton:!1,...e})},close:e=>{R.close(e)},defaults:q};const G=c({});function Y(e){return t=>{let{resolve:r,destroy:o,message:c}=t;const[l,f]=function(e){const t=i(null),[n,r]=a(e);return s((()=>{t.current&&(t.current(),t.current=null)}),[n]),[n,(e,n)=>{t.current="function"==typeof n?n:null,r(e)}]}(!0),m=d(G),p=u((e=>{f(!1,(()=>{r(e)}))}),[f,r]),g=h((()=>({show:l,onHide:()=>p(),onExited:()=>o(),container:m.container})),[l,p,o]);return n(e,{resolve:p,state:g,message:c})}}function J(e){return t=>new Promise((r=>{const o=n(e,{resolve:r,destroy:()=>{X(o)},message:t});W(o)}))}let K=()=>{},Q=new Set;const W=e=>{Q=new Set(Q),Q.add(e),K(Q)},X=e=>{Q=new Set(Q),Q.delete(e),K(Q)};function Z(e,t){return J(Y(e))(t)}function ee(e){let{tooltip:t,children:r,placement:o="bottom"}=e;return n(b,{placement:o,overlay:n(w,{id:$(),children:t}),children:r})}const te=c(!1),ne=f(((e,t)=>{let{loading:i,percent:a,disabled:s,children:c,tooltip:l,variant:u,...h}=e;d(te)&&!u&&(u="link"),i&&(s=!0,c=r(o,{children:[n(k,{ref:t,as:"span",size:"sm",role:"status","aria-hidden":"true",animation:"border"}),a?r("span",{className:"ms-2",children:[a,"%"]}):null]}));const f=n(C,{ref:t,...h,variant:u,disabled:s,children:c});return l?n(ee,{tooltip:l,children:n("span",{className:"d-inline-block",children:f})}):f})),re=function(e){let{state:t,message:{title:o,message:i,okText:a,cancelText:s},resolve:c}=e;return r(N,{...t,children:[n(N.Header,{children:n(N.Title,{as:"h5",children:o||"确认"})}),n(N.Body,{children:i}),r(N.Footer,{children:[n(ne,{variant:"secondary",onClick:()=>c(),children:s||"取消"}),n(ne,{onClick:()=>c(!0),children:a||"确定"})]})]})};const oe=e=>{let{header:t,children:i,footer:s,closable:c=!0,show:l,cancelText:d="取消",okText:u="确定",onOk:f,onCancel:m,onHide:p,okButtonProps:g,bodyAs:y,headerAs:x="h5",confirmLoading:v=!1,...b}=e;const[w,k]=a(!1),C=h((()=>n(ne,{loading:w||v,variant:"primary",onClick:async e=>{k(!0);try{await(f?.(e)),e.defaultPrevented||p?.()}finally{k(!1)}},...g,children:u})),[g,u,f,p,w,v]),S=h((()=>n(ne,{variant:"secondary",onClick:e=>{m?.(e),e.defaultPrevented||p?.()},children:d})),[m,p,d]);switch(typeof s){case"undefined":s=r(o,{children:[S,C]});break;case"function":s=s({okButton:C,cancelButton:S})}return r(N,{...b,onHide:p,show:l,children:[t&&n(N.Header,{closeButton:c,children:n(N.Title,{as:x,children:t})}),n(N.Body,{as:y,children:i}),s&&n(N.Footer,{children:s})]})};let ie;oe.Message=function(e){const[t,r]=a(Q);return s((()=>{K=r}),[]),n(G.Provider,{value:e,children:Array.from(t).map(((e,t)=>n(l,{children:e},`message-${t}`)))})},oe.confirm=function(e){return J(Y(re))(e)},oe.show=Z;const ae={};const se=e=>{let{type:t,...r}=e;!function(e){if(ie)return e(ie);O.newInstance({...ae,prefixCls:"notification",maxCount:5,style:{top:20,right:20}},(t=>{ie?e(ie):(ie=t,e(t))}))}((e=>{r.duration=3;let o=t;if("error"===t)o="danger",r.duration=r.closable?0:5;r.content=n(S,{variant:o,children:r.content}),e.notice(r)}))},ce=["error","success","info"].reduce(((e,t)=>(e[t]=(e,n)=>{se({...n,type:t,content:e})},e)),{});function le(e){return e&&"object"==typeof e}ce.defaults=ae,F.attach(),A.defaults.raxConfig={retryDelay:2e3,backoffType:"static",shouldRetry:e=>{let{config:t,response:n}=e;return!(t.raxConfig?.retryDecider&&!t.raxConfig.retryDecider())&&("GET"===t.method?.toUpperCase()&&449===n?.status)}},A.defaults.maxContentLength=1/0,A.defaults.maxBodyLength=1/0,A.defaults.baseURL="/api",A.defaults.authTokenName="authorization",A.interceptors.request.use((e=>{const t=e.authTokenName;if(t){const n=localStorage.getItem(t);n&&(e.headers={Authorization:`Bearer ${n}`,...e.headers})}return e}),(e=>Promise.reject(e))),A.interceptors.response.use((e=>(201===e.status&&e.data.location&&(window.location.href=e.data.location,e.data=void 0),e)),(e=>{if(A.isAxiosError(e)&&e.response){const{data:t,status:n}=e.response;401===n?(e.errors="Unauthorized",ce.error("Unauthorized")):le(t)?422===n?e.errors=t:"message"in t&&(e.errors=t.message):e.errors=t}return Promise.reject(e)}));const de=A.isAxiosError,ue=e=>{if(!A.isAxiosError(e))throw e;{let t=e.errors;"string"!=typeof e.errors&&(t=Object.values(e.errors).join("<br />")),ce.error(t)}},he=async function(e){e="string"==typeof e?{url:e}:e;const{data:t}=await A.request({paramsSerializer:function(e){return L.stringify(e,{sort:!1,skipNull:!0,skipEmptyString:!0,arrayFormat:"bracket"})},...e});return t};he.defaults=A.defaults,he.interceptors=A.interceptors;const fe=()=>{const e=i(!1);return s((()=>(e.current=!1,()=>{e.current=!0})),[]),e};function me(e){const t=fe(),[n,r]=a(e);return[n,u((e=>{t.current||r(e)}),[])]}const pe=function(e){let{state:t,message:r,resolve:o}=e;const a=i(!0),{result:c,checkUrl:l,onComplete:d}=r,[u,h]=me(!1);return s((()=>{he({url:l,method:"post",data:{order_no:c.order_no},raxConfig:{shouldRetry:e=>a.current&&449===e.response?.status}}).then((()=>{d?.(),o()})).catch((()=>null))}),[]),n(oe,{...t,centered:!0,onHide:()=>{a.current=!1,t.onHide()},backdrop:"static",header:"支付结果",okText:"已完成支付",okButtonProps:{loading:u},onOk:async e=>{e.preventDefault();try{h(!0),await he({url:l,method:"post",data:{order_no:c.order_no},raxConfig:{shouldRetry:()=>!1}}),d?.(),o()}catch{}finally{h(!1)}},cancelText:"取消",children:"请在新打开的页面上进行支付,支付完成后再关闭此窗口"})};function ge(e){const{result:t}=e;window.open(t.pay_url),Z(pe,e)}const ye=_.div`
|
|
2
|
+
padding: 48px 32px;
|
|
3
|
+
`,xe=_.div`
|
|
4
|
+
margin-bottom: 24px;
|
|
5
|
+
text-align: center;
|
|
6
|
+
font-size: 72px;
|
|
7
|
+
`,ve=_.div`
|
|
8
|
+
color: rgba(0, 0, 0, .85);
|
|
9
|
+
font-size: 24px;
|
|
10
|
+
line-height: 1.8;
|
|
11
|
+
text-align: center;
|
|
12
|
+
`,be=_.div`
|
|
13
|
+
margin-top: 32px;
|
|
14
|
+
text-align: center;
|
|
15
|
+
`,we={success:n("i",{className:"bi bi-check-circle-fill text-success"}),error:n("i",{className:"bi bi-exclamation-circle-fill text-danger"}),info:n("i",{className:"bi bi-info-circle-fill text-info"}),warning:n("i",{className:"bi bi-exclamation-triangle-fill text-warning"})};function ke(e){let{status:t,title:o,icon:i,extra:a}=e;return!i&&t&&(i=we[t]),r(ye,{children:[i&&n(xe,{children:i}),o&&n(ve,{children:o}),a&&n(be,{children:a})]})}_.div`
|
|
16
|
+
position: relative;
|
|
17
|
+
`;const Ce=_.div`
|
|
18
|
+
display: ${e=>e.active?"flex":"none"};
|
|
19
|
+
position: absolute;
|
|
20
|
+
top: 0 !important;
|
|
21
|
+
left: 0 !important;
|
|
22
|
+
width: 100%;
|
|
23
|
+
height: 100%;
|
|
24
|
+
text-align: center;
|
|
25
|
+
vertical-align: middle;
|
|
26
|
+
padding: 1em;
|
|
27
|
+
background-color: ${e=>e.inverted?"rgba(255, 255, 255, .85)":"rgba(0, 0, 0, .85)"};
|
|
28
|
+
opacity: ${e=>e.active?1:0};
|
|
29
|
+
line-height: 1;
|
|
30
|
+
animation-fill-mode: both;
|
|
31
|
+
animation-duration: .5s;
|
|
32
|
+
transition: background-color .5s linear;
|
|
33
|
+
flex-direction: column;
|
|
34
|
+
align-items: center;
|
|
35
|
+
justify-content: center;
|
|
36
|
+
user-select: none;
|
|
37
|
+
will-change: opacity;
|
|
38
|
+
z-index: 990;
|
|
39
|
+
`;function Ne(e){let{loading:t=!0,children:o,variant:i="primary",animation:a="border",wrap:s,...c}=e;return t?(o&&(o=n("p",{className:"mt-3 text-secondary",children:o})),o=r(Ce,{inverted:!0,active:!0,children:[n(k,{animation:a,variant:i,...c}),o]}),s?n(Se,{$height:"number"==typeof s?s:150,children:o}):o):null}const Se=_.div`
|
|
40
|
+
position: relative;
|
|
41
|
+
height: ${e=>`${e.$height}px`};
|
|
42
|
+
`;function ze(e){let{children:t,title:i,className:a,...s}=e;return n(z,{className:M("border-0 shadow-sm mb-3",a),...s,children:r("div",{className:"card-body",children:[i&&r(o,{children:[n("h5",{children:i}),n("hr",{})]}),t]})})}function Be(e){let{errors:t}=e;return t?n(S,{variant:"danger",children:n("ul",{className:"mb-0",children:"string"==typeof t?n("li",{children:t}):Object.entries(t).map((e=>{let[t,r]=e;return n("li",{children:r},t)}))})}):null}function Pe(e){let{children:t,className:r,size:o="small",direction:i="horizontal"}=e;"string"==typeof o&&(o={small:8,middle:16,large:24}[o]);const a=m.map(t,(e=>{if(e)return n(Te,{children:e})}));return n(je,{className:r,$direction:i,$size:o,children:a})}const je=_.div`
|
|
43
|
+
display: inline-flex;
|
|
44
|
+
align-items: center;
|
|
45
|
+
gap: ${e=>e.$size}px;
|
|
46
|
+
|
|
47
|
+
${e=>"vertical"===e.$direction&&D`
|
|
48
|
+
display: flex;
|
|
49
|
+
flex-direction: column;
|
|
50
|
+
align-items: inherit;
|
|
51
|
+
`}
|
|
52
|
+
`,Te=_.div`
|
|
53
|
+
|
|
54
|
+
`,$e=p((()=>import("./steps-b_BcYIwk.js"))),He=p((()=>import("./steps-b_BcYIwk.js").then((e=>{let{Step:t}=e;return{default:t}}))));function Ee(e){return n(g,{fallback:null,children:n($e,{...e})})}const Ae=function(e){return n(g,{fallback:null,children:n(He,{...e})})};function Le(e){let{title:t,content:o,footer:i}=e;return r(ze,{children:[n(_e,{children:t}),n(Oe,{children:o}),i&&n(Fe,{children:i})]})}Ee.Step=Ae;const Fe=_.div`
|
|
55
|
+
margin-top: 9px;
|
|
56
|
+
padding-top: 10px;
|
|
57
|
+
border-top: 1px solid #f0f0f0;
|
|
58
|
+
color: rgba(0, 0, 0, .65);
|
|
59
|
+
`,Oe=_.div`
|
|
60
|
+
color: rgba(0, 0, 0, .85);
|
|
61
|
+
font-size: 24px;
|
|
62
|
+
`,_e=_.div`
|
|
63
|
+
margin-bottom: 4px;
|
|
64
|
+
color: rgba(0, 0, 0, .45);
|
|
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,v=d+1<g?d+1:g,b=[];let w=null,k=null,C=null,N=null;if(g<=7)for(let e=1;e<=g;e+=1){const t=d===e;b.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(v)},"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;b.push(n(B.Item,{active:e,onClick:y(r),children:r},r))}d-1>=4&&3!==d&&b.unshift(w),g-d>=4&&d!==g-2&&b.push(k),1!==e&&b.unshift(C),t!==g&&b.push(N)}return n(B,{className:c,children:b})}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-zJSNEC-2.js"))),Ke=f(((e,t)=>n(g,{fallback:null,children:n(Je,{...e,ref:t})}))),Qe=p((()=>import("./index-RvCEJ0zy.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 v=y(h,{...f,onClick:p},i);return r(o,{children:[v,n(oe,{header:i,...s,...m,confirmLoading:u,onOk:async e=>{if(a){!1===await a()&&e.preventDefault()}},children:c})]})}));function tt(e){let{text:t,onSuccess:o,buttonProps:s,modalProps:c,children:l,...d}=e;const[h,f]=a(!1),m=i(null),p=i(null),g=u((()=>(p.current?.submit(),!1)),[]),y=u((e=>{o&&o(e),m.current?.close()}),[o]);return n(et,{ref:m,text:t,...s,modalProps:c,onOk:g,confirmLoading:h,children:r(Ke,{...d,onSubmitting:f,ref:p,onSuccess:y,children:[l,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{paginate:c=!0,sync:l=!1,columns:d=3,source:h,renderItem:f,renderEmpty:m}=e;const[p,g]=a([]),[y,v]=a(c?{total:0,current:1,pageSize:10}:null),[b,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&&v({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(o,{children:[n(Ne,{loading:b}),0===p.length&&!b&&m?.(),n(j,{children:p.map(((e,t)=>n(T,{className:"d-flex",md:12/d,children:f(e)},`card-${t}`)))}),y&&n(st,{...y,onChange:S})]})})),st=_(Ue)`
|
|
67
|
+
margin-bottom: 0;
|
|
68
|
+
justify-content: flex-end;
|
|
69
|
+
margin-top: 1rem;
|
|
70
|
+
`;var ct=v(at);function lt(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 dt(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,ct as q,he as r,lt as s,Ze as t,dt as u,de as v,ge as w,ue as x};
|
|
@@ -0,0 +1 @@
|
|
|
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-gIRl3vp6.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};
|
package/es/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{B as Button,C as Card,E as Error,F as Form,I as ImageZoom,L as Loader,
|
|
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-gIRl3vp6.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.70",
|
|
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.51",
|
|
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": "2ae5d03102bfac20cbe565a8e23f0f73b2e7e526"
|
|
68
68
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ForwardRefExoticComponent, PropsWithChildren, PropsWithoutRef, ReactNode, RefAttributes } from 'react';
|
|
2
|
+
type Params = {
|
|
3
|
+
page?: number;
|
|
4
|
+
[key: string]: any;
|
|
5
|
+
};
|
|
6
|
+
export interface CardListProps<RecordType = any> {
|
|
7
|
+
source: string | ((params: Params) => Promise<RecordType>);
|
|
8
|
+
paginate?: boolean;
|
|
9
|
+
sync?: boolean;
|
|
10
|
+
columns?: number;
|
|
11
|
+
renderItem: (item: RecordType) => ReactNode;
|
|
12
|
+
renderEmpty?: () => ReactNode;
|
|
13
|
+
}
|
|
14
|
+
export interface CardListType {
|
|
15
|
+
reload: () => void;
|
|
16
|
+
}
|
|
17
|
+
export type CustomCardListType<T = any> = ForwardRefExoticComponent<PropsWithoutRef<PropsWithChildren<CardListProps<T>>> & RefAttributes<CardListType>>;
|
|
18
|
+
declare const _default: CustomCardListType<any>;
|
|
19
|
+
export default _default;
|
package/types/index.d.ts
CHANGED
|
@@ -24,6 +24,7 @@ export { default as Modal, ModalProps, MessageProps } from './components/modal';
|
|
|
24
24
|
export { default as OffcanvasButton, OffcanvasType, OffcanvasButtonProps } from './components/offcanvas-button';
|
|
25
25
|
export { default as Offcanvas, OffcanvasProps } from './components/offcanvas';
|
|
26
26
|
export { default as Tooltip } from './components/tooltip';
|
|
27
|
+
export { default as CardList, CardListType } from './components/card-list';
|
|
27
28
|
export { default as useRequest } from './hooks/use-request';
|
|
28
29
|
export { default as useOverlayState } from './hooks/use-overlay-state';
|
|
29
30
|
export { default as useControllableState } from './hooks/use-controllable-state';
|
package/es/index-WNXBQWc1.js
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import e from"sweetalert2/dist/sweetalert2.js";import t from"sweetalert2-react-content";import{jsx as n,jsxs as r,Fragment as o}from"react/jsx-runtime";import{useRef as i,useState as a,useEffect as s,createContext as c,Fragment as l,useContext as d,useCallback as u,useMemo as h,forwardRef as f,Children as m,lazy as p,Suspense as g,createElement as y,useImperativeHandle as x}from"react";import{OverlayTrigger as b,Tooltip as v,Spinner as w,Button as k,Modal as C,Alert as N,Card as S,Pagination as z,Offcanvas as B}from"react-bootstrap";import{uniqueId as P,values as T,debounce as j}from"lodash";import H from"axios";import $ from"query-string";import*as A from"retry-axios";import E from"rc-notification";import L,{css as F}from"styled-components";import O from"classnames";import{useAsyncCallback as D}from"react-async-hook";const M=t(e),I={confirmButtonText:"确定",cancelButtonText:"取消"},U={confirm:async e=>{const{isConfirmed:t}=await M.fire({...I,icon:"warning",showCancelButton:!0,...e,async preConfirm(t){if(e.preConfirm)try{return await e.preConfirm(t)}catch(e){return e instanceof Error&&M.showValidationMessage(e.message),!1}return!0}});return t},success:e=>{M.fire({...I,toast:!0,position:"top",icon:"success",timer:2e3,showConfirmButton:!1,...e})},error:e=>{M.fire({...I,toast:!0,position:"top",icon:"error",timer:5e3,showConfirmButton:!1,...e})},close:e=>{M.close(e)},defaults:I};const R=c({});function _(e){return t=>{let{resolve:r,destroy:o,message:c}=t;const[l,f]=function(e){const t=i(null),[n,r]=a(e);return s((()=>{t.current&&(t.current(),t.current=null)}),[n]),[n,(e,n)=>{t.current="function"==typeof n?n:null,r(e)}]}(!0),m=d(R),p=u((e=>{f(!1,(()=>{r(e)}))}),[f,r]),g=h((()=>({show:l,onHide:()=>p(),onExited:()=>o(),container:m.container})),[l,p,o]);return n(e,{resolve:p,state:g,message:c})}}function q(e){return t=>new Promise((r=>{const o=n(e,{resolve:r,destroy:()=>{J(o)},message:t});Y(o)}))}let V=()=>{},G=new Set;const Y=e=>{G=new Set(G),G.add(e),V(G)},J=e=>{G=new Set(G),G.delete(e),V(G)};function K(e,t){return q(_(e))(t)}function Q(e){let{tooltip:t,children:r,placement:o="bottom"}=e;return n(b,{placement:o,overlay:n(v,{id:P(),children:t}),children:r})}const W=c(!1),X=f(((e,t)=>{let{loading:i,percent:a,disabled:s,children:c,tooltip:l,variant:u,...h}=e;d(W)&&!u&&(u="link"),i&&(s=!0,c=r(o,{children:[n(w,{ref:t,as:"span",size:"sm",role:"status","aria-hidden":"true",animation:"border"}),a?r("span",{className:"ms-2",children:[a,"%"]}):null]}));const f=n(k,{ref:t,...h,variant:u,disabled:s,children:c});return l?n(Q,{tooltip:l,children:n("span",{className:"d-inline-block",children:f})}):f})),Z=function(e){let{state:t,message:{title:o,message:i,okText:a,cancelText:s},resolve:c}=e;return r(C,{centered:!0,...t,children:[n(C.Header,{children:n(C.Title,{as:"h5",children:o||"确认"})}),n(C.Body,{children:i}),r(C.Footer,{children:[n(X,{variant:"secondary",onClick:()=>c(),children:s||"取消"}),n(X,{onClick:()=>c(!0),children:a||"确定"})]})]})};const ee=e=>{let{header:t,children:i,footer:s,closable:c=!0,show:l,cancelText:d="取消",okText:u="确定",onOk:f,onCancel:m,onHide:p,okButtonProps:g,bodyAs:y,headerAs:x="h5",confirmLoading:b=!1,...v}=e;const[w,k]=a(!1),N=h((()=>n(X,{loading:w||b,variant:"primary",onClick:async e=>{k(!0);try{await(f?.(e)),e.defaultPrevented||p?.()}finally{k(!1)}},...g,children:u})),[g,u,f,p,w,b]),S=h((()=>n(X,{variant:"secondary",onClick:e=>{m?.(e),e.defaultPrevented||p?.()},children:d})),[m,p,d]);switch(typeof s){case"undefined":s=r(o,{children:[S,N]});break;case"function":s=s({okButton:N,cancelButton:S})}return r(C,{...v,onHide:p,show:l,children:[t&&n(C.Header,{closeButton:c,children:n(C.Title,{as:x,children:t})}),n(C.Body,{as:y,children:i}),s&&n(C.Footer,{children:s})]})};let te;ee.Message=function(e){const[t,r]=a(G);return s((()=>{V=r}),[]),n(R.Provider,{value:e,children:Array.from(t).map(((e,t)=>n(l,{children:e},`message-${t}`)))})},ee.confirm=function(e){return q(_(Z))(e)},ee.show=K;const ne={};const re=e=>{let{type:t,...r}=e;!function(e){if(te)return e(te);E.newInstance({...ne,prefixCls:"notification",maxCount:5,style:{top:20,right:20}},(t=>{te?e(te):(te=t,e(t))}))}((e=>{r.duration=3;let o=t;if("error"===t)o="danger",r.duration=r.closable?0:5;r.content=n(N,{variant:o,children:r.content}),e.notice(r)}))},oe=["error","success","info"].reduce(((e,t)=>(e[t]=(e,n)=>{re({...n,type:t,content:e})},e)),{});function ie(e){return e&&"object"==typeof e}oe.defaults=ne,A.attach(),H.defaults.raxConfig={retryDelay:2e3,backoffType:"static",shouldRetry:e=>{let{config:t,response:n}=e;return!(t.raxConfig?.retryDecider&&!t.raxConfig.retryDecider())&&("GET"===t.method?.toUpperCase()&&449===n?.status)}},H.defaults.maxContentLength=1/0,H.defaults.maxBodyLength=1/0,H.defaults.baseURL="/api",H.defaults.authTokenName="authorization",H.interceptors.request.use((e=>{const t=e.authTokenName;if(t){const n=localStorage.getItem(t);n&&(e.headers={Authorization:`Bearer ${n}`,...e.headers})}return e}),(e=>Promise.reject(e))),H.interceptors.response.use((e=>(201===e.status&&e.data.location&&(window.location.href=e.data.location,e.data=void 0),e)),(e=>{if(H.isAxiosError(e)&&e.response){const{data:t,status:n}=e.response;401===n?(e.errors="Unauthorized",oe.error("Unauthorized")):ie(t)?422===n?e.errors=t:"message"in t&&(e.errors=t.message):e.errors=t}return Promise.reject(e)}));const ae=H.isAxiosError,se=e=>{if(!H.isAxiosError(e))throw e;{let t=e.errors;"string"!=typeof e.errors&&(t=Object.values(e.errors).join("<br />")),oe.error(t)}},ce=async function(e){e="string"==typeof e?{url:e}:e;const{data:t}=await H.request({paramsSerializer:function(e){return $.stringify(e,{sort:!1,skipNull:!0,skipEmptyString:!0,arrayFormat:"bracket"})},...e});return t};ce.defaults=H.defaults,ce.interceptors=H.interceptors;const le=()=>{const e=i(!1);return s((()=>(e.current=!1,()=>{e.current=!0})),[]),e};function de(e){const t=le(),[n,r]=a(e);return[n,u((e=>{t.current||r(e)}),[])]}const ue=function(e){let{state:t,message:r,resolve:o}=e;const a=i(!0),{result:c,checkUrl:l,onComplete:d}=r,[u,h]=de(!1);return s((()=>{ce({url:l,method:"post",data:{order_no:c.order_no},raxConfig:{shouldRetry:e=>a.current&&449===e.response?.status}}).then((()=>{d?.(),o()})).catch((()=>null))}),[]),n(ee,{...t,centered:!0,onHide:()=>{a.current=!1,t.onHide()},backdrop:"static",header:"支付结果",okText:"已完成支付",okButtonProps:{loading:u},onOk:async e=>{e.preventDefault();try{h(!0),await ce({url:l,method:"post",data:{order_no:c.order_no},raxConfig:{shouldRetry:()=>!1}}),d?.(),o()}catch{}finally{h(!1)}},cancelText:"取消",children:"请在新打开的页面上进行支付,支付完成后再关闭此窗口"})};function he(e){const{result:t}=e;window.open(t.pay_url),K(ue,e)}const fe=L.div`
|
|
2
|
-
padding: 48px 32px;
|
|
3
|
-
`,me=L.div`
|
|
4
|
-
margin-bottom: 24px;
|
|
5
|
-
text-align: center;
|
|
6
|
-
font-size: 72px;
|
|
7
|
-
`,pe=L.div`
|
|
8
|
-
color: rgba(0, 0, 0, .85);
|
|
9
|
-
font-size: 24px;
|
|
10
|
-
line-height: 1.8;
|
|
11
|
-
text-align: center;
|
|
12
|
-
`,ge=L.div`
|
|
13
|
-
margin-top: 32px;
|
|
14
|
-
text-align: center;
|
|
15
|
-
`,ye={success:n("i",{className:"bi bi-check-circle-fill text-success"}),error:n("i",{className:"bi bi-exclamation-circle-fill text-danger"}),info:n("i",{className:"bi bi-info-circle-fill text-info"}),warning:n("i",{className:"bi bi-exclamation-triangle-fill text-warning"})};function xe(e){let{status:t,title:o,icon:i,extra:a}=e;return!i&&t&&(i=ye[t]),r(fe,{children:[i&&n(me,{children:i}),o&&n(pe,{children:o}),a&&n(ge,{children:a})]})}L.div`
|
|
16
|
-
position: relative;
|
|
17
|
-
`;const be=L.div`
|
|
18
|
-
display: ${e=>e.active?"flex":"none"};
|
|
19
|
-
position: absolute;
|
|
20
|
-
top: 0 !important;
|
|
21
|
-
left: 0 !important;
|
|
22
|
-
width: 100%;
|
|
23
|
-
height: 100%;
|
|
24
|
-
text-align: center;
|
|
25
|
-
vertical-align: middle;
|
|
26
|
-
padding: 1em;
|
|
27
|
-
background-color: ${e=>e.inverted?"rgba(255, 255, 255, .85)":"rgba(0, 0, 0, .85)"};
|
|
28
|
-
opacity: ${e=>e.active?1:0};
|
|
29
|
-
line-height: 1;
|
|
30
|
-
animation-fill-mode: both;
|
|
31
|
-
animation-duration: .5s;
|
|
32
|
-
transition: background-color .5s linear;
|
|
33
|
-
flex-direction: column;
|
|
34
|
-
align-items: center;
|
|
35
|
-
justify-content: center;
|
|
36
|
-
user-select: none;
|
|
37
|
-
will-change: opacity;
|
|
38
|
-
z-index: 990;
|
|
39
|
-
`;function ve(e){let{loading:t=!0,children:o,variant:i="primary",animation:a="border",wrap:s,...c}=e;return t?(o&&(o=n("p",{className:"mt-3 text-secondary",children:o})),o=r(be,{inverted:!0,active:!0,children:[n(w,{animation:a,variant:i,...c}),o]}),s?n(we,{$height:"number"==typeof s?s:150,children:o}):o):null}const we=L.div`
|
|
40
|
-
position: relative;
|
|
41
|
-
height: ${e=>`${e.$height}px`};
|
|
42
|
-
`;function ke(e){let{children:t,title:i,className:a,...s}=e;return n(S,{className:O("border-0 shadow-sm mb-3",a),...s,children:r("div",{className:"card-body",children:[i&&r(o,{children:[n("h5",{children:i}),n("hr",{})]}),t]})})}function Ce(e){let{errors:t}=e;return t?n(N,{variant:"danger",children:n("ul",{className:"mb-0",children:"string"==typeof t?n("li",{children:t}):Object.entries(t).map((e=>{let[t,r]=e;return n("li",{children:r},t)}))})}):null}function Ne(e){let{children:t,className:r,size:o="small",direction:i="horizontal"}=e;"string"==typeof o&&(o={small:8,middle:16,large:24}[o]);const a=m.map(t,(e=>{if(e)return n(ze,{children:e})}));return n(Se,{className:r,$direction:i,$size:o,children:a})}const Se=L.div`
|
|
43
|
-
display: inline-flex;
|
|
44
|
-
align-items: center;
|
|
45
|
-
gap: ${e=>e.$size}px;
|
|
46
|
-
|
|
47
|
-
${e=>"vertical"===e.$direction&&F`
|
|
48
|
-
display: flex;
|
|
49
|
-
flex-direction: column;
|
|
50
|
-
align-items: inherit;
|
|
51
|
-
`}
|
|
52
|
-
`,ze=L.div`
|
|
53
|
-
|
|
54
|
-
`,Be=p((()=>import("./steps-b_BcYIwk.js"))),Pe=p((()=>import("./steps-b_BcYIwk.js").then((e=>{let{Step:t}=e;return{default:t}}))));function Te(e){return n(g,{fallback:null,children:n(Be,{...e})})}const je=function(e){return n(g,{fallback:null,children:n(Pe,{...e})})};function He(e){let{title:t,content:o,footer:i}=e;return r(ke,{children:[n(Ee,{children:t}),n(Ae,{children:o}),i&&n($e,{children:i})]})}Te.Step=je;const $e=L.div`
|
|
55
|
-
margin-top: 9px;
|
|
56
|
-
padding-top: 10px;
|
|
57
|
-
border-top: 1px solid #f0f0f0;
|
|
58
|
-
color: rgba(0, 0, 0, .65);
|
|
59
|
-
`,Ae=L.div`
|
|
60
|
-
color: rgba(0, 0, 0, .85);
|
|
61
|
-
font-size: 24px;
|
|
62
|
-
`,Ee=L.div`
|
|
63
|
-
margin-bottom: 4px;
|
|
64
|
-
color: rgba(0, 0, 0, .45);
|
|
65
|
-
font-size: 1.1rem;
|
|
66
|
-
`;function Le(){}function Fe(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e}function Oe(e){let{total:t=0,onChange:r=Le,defaultCurrent:o=1,defaultPageSize:i=10,className:c,...l}=e;const[d,f]=a(o),[m,p]=a(i);s((()=>{Fe(l.current)&&f(l.current)}),[l.current]),s((()=>{Fe(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(z.Item,{active:t,onClick:y(e),children:e},e))}else{N=n(z.Last,{onClick:y(g)},"last"),C=n(z.First,{onClick:y(1)},"first"),w=n(z.Prev,{onClick:y(x)},"prev"),k=n(z.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(z.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(z,{className:c,children:v})}function De(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 Me(e){let{loading:t,disabled:r,children:o,...i}=e;return n(k,{...i,disabled:t||r,children:t?"Loading…":o})}const Ie=p((()=>import("./image-zoom-OrIPGqh0.js")));function Ue(e){return n(g,{fallback:null,children:n(Ie,{...e})})}function Re(e){let{url:t,method:n,confirm:r,onSuccess:o,children:i,disabled:a,as:s=X,...c}=e;const[l,d]=de(!1),h=u((async e=>{e.preventDefault();try{if(d(!0),r&&!await ee.confirm({message:r}))return;const e="string"==typeof t?{url:t,method:n}:{method:n,...t},i=await ce(e);o&&o(i)}catch(e){se(e)}finally{d(!1)}}),[t,n,d]);return y(s,{...c,disabled:a||l,onClick:h},i)}const _e=p((()=>import("./index-oPMscx3h.js"))),qe=f(((e,t)=>n(g,{fallback:null,children:n(_e,{...e,ref:t})}))),Ve=p((()=>import("./index-mlGSIgGo.js"))),Ge=f(((e,t)=>n(g,{fallback:null,children:n(Ve,{...e,ref:t})})));let Ye=0;function Je(){let{onHide:e,onShow:t}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const[n,r]=a(!1),[o,i]=a(`visible-${Ye}`),s=u((()=>{r(!1),e&&e()}),[r,e]),c=u((()=>{i("visible-"+ ++Ye)}),[i,Ye]);return{visible:n,show:u((()=>{r(!0),t&&t()}),[r,t]),hide:s,state:{show:n,onHide:s,onExited:c,key:o}}}const Ke=f(((e,t)=>{let{text:i,onOk:a,modalProps:s,children:c,onShow:l,onHide:d,confirmLoading:u,as:h=X,...f}=e;const{state:m,show:p,hide:g}=Je({onShow:l,onHide:d});x(t,(()=>({close:g})));const b=y(h,{...f,onClick:p},i);return r(o,{children:[b,n(ee,{header:i,...s,...m,confirmLoading:u,onOk:async e=>{if(a){!1===await a()&&e.preventDefault()}},children:c})]})}));function Qe(e){let{text:t,onSuccess:o,buttonProps:s,modalProps:c,children:l,...d}=e;const[h,f]=a(!1),m=i(null),p=i(null),g=u((()=>(p.current?.submit(),!1)),[]),y=u((e=>{o&&o(e),m.current?.close()}),[o]);return n(Ke,{ref:m,text:t,...s,modalProps:c,onOk:g,confirmLoading:h,children:r(qe,{...d,onSubmitting:f,ref:p,onSuccess:y,children:[l,n("input",{type:"submit",hidden:!0})]})})}function We(e){let{header:t,children:o,closable:i=!0,show:a,onHide:s,bodyAs:c,headerAs:l="h5",...d}=e;return r(B,{...d,onHide:s,show:a,children:[t&&n(B.Header,{closeButton:i,children:n(B.Title,{as:l,children:t})}),n(B.Body,{as:c,children:o})]})}const Xe=f(((e,t)=>{let{text:i,offcanvasProps:a,children:s,onShow:c,onHide:l,as:d=X,...u}=e;const{state:h,show:f,hide:m}=Je({onShow:c,onHide:l});x(t,(()=>({close:m})));const p=y(d,{...u,onClick:f},i);return r(o,{children:[p,n(We,{header:i,...a,...h,children:s})]})}));function Ze(e){let{manual:t,refreshDeps:n,...r}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{execute:o,currentParams:i,error:a,...c}=D((async t=>(e="string"==typeof e?{url:e}:e,await ce({...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&&ae(a)){const e=a.errors;a=new Error("string"==typeof e?e:T(e).join(""))}return{refresh:l,execute:o,error:a,...c}}function et(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 tt(e){const{value:t,defaultValue:n,onChange:r,shouldUpdate:o=((e,t)=>e!==t)}=e,i=et(r),s=et(o),[c,l]=a(n),d=void 0!==t,u=d?t:c,h=et((e=>{const t="function"==typeof e?e(u):e;s(u,t)&&(d||l(t),i(t))}),[d,i,u,s]);return[u,h]}function nt(e,t,n){const r=i(e),o=i(j(e,t,n));return s((()=>{r.current=e})),s((()=>{o.current=j((function(){r.current(...arguments)}),t,n)}),[t,n]),o.current}export{X as B,ke as C,Ce as E,qe as F,Ue as I,ve as L,U as M,De as N,Xe as O,Oe as P,xe as R,Ne as S,W as T,tt as a,de as b,oe as c,Te as d,je as e,He as f,Me as g,Re as h,ie as i,Ge as j,Qe as k,Ke as l,ee as m,We as n,Q as o,Ze as p,Je as q,ce as r,ae as s,se as t,nt as u,he as w};
|
package/es/index-mlGSIgGo.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import{jsx as e,jsxs as t,Fragment as r}from"react/jsx-runtime";import n from"rc-table";import{unstable_batchedUpdates as o}from"react-dom";import{FormControl as a,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,N as k,L as S,T as E,C as O,S as V}from"./index-WNXBQWc1.js";import z from"styled-components";import N from"./index-oPMscx3h.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 H=function(t){let{indeterminate:r=!1,...n}=t;const o=m(null);return h((()=>{o.current&&(o.current.indeterminate=r)}),[r]),e("input",{ref:o,...n,className:"form-check-input",type:"checkbox"})};var q;function K(){return K=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},K.apply(this,arguments)}const M=e=>d.createElement("svg",K({xmlns:"http://www.w3.org/2000/svg",width:16,height:16,fill:"currentColor",viewBox:"0 0 1024 1024"},e),q||(q=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 B;function P(){return P=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},P.apply(this,arguments)}const F=e=>d.createElement("svg",P({xmlns:"http://www.w3.org/2000/svg",width:16,height:16,fill:"currentColor",viewBox:"0 0 1024 1024"},e),B||(B=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 T(r){let{data:n,options:o,columns:a,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":o.order},t={},r={};o.fields.forEach((n=>{const i=a.find((e=>e.dataIndex===n));if(i){const a=i.title;if("string"==typeof a){if(e[n]={"ui:col":4,"ui:labelCol":3,"ui:placeholder":"请输入",...o.ui?.[n]},i.valueEnum){const t=i.valueEnum;return e[n]["ui:placeholder"]="请选择",r[n]={title:a,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:a,type:"string"}}}})),o.extraFields&&Object.entries(o.extraFields).forEach((n=>{let[a,i]=n;e[a]={"ui:col":4,"ui:labelCol":3,"ui:placeholder":"请输入",...o.ui?.[a]},t[a]=void 0,r[a]={title:i,type:"string"}}));return[{type:"object",properties:r},e,t]}),[o.fields,o.extraFields]),x=p((e=>{let{formData:t}=e;m(t),i({...y,...t})}),[i,y]),w=p((()=>{i(y)}),[i,y]);return e(_,{children:e(N,{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 _=z.div`
|
|
2
|
-
margin-bottom: 1rem;
|
|
3
|
-
`;function D(t){let{keyword:r,onKeywordChange:n}=t;const[o,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(a,{value:o,onChange:l,type:"search",placeholder:"Search..."})}const I=z.thead`
|
|
4
|
-
th {
|
|
5
|
-
padding: 0.5rem 0.5rem;
|
|
6
|
-
border-bottom-width: 1px;
|
|
7
|
-
border-color: var(--bs-border-color);
|
|
8
|
-
}
|
|
9
|
-
`,R={table:t=>e(i,{...t,className:"mb-0 align-middle table-hover"}),header:{wrapper:t=>e(I,{...t})}},A=z.a`
|
|
10
|
-
cursor: pointer;
|
|
11
|
-
width: 28px;
|
|
12
|
-
height: 28px;
|
|
13
|
-
display: inline-flex;
|
|
14
|
-
align-items: center;
|
|
15
|
-
justify-content: center;
|
|
16
|
-
vertical-align: middle;
|
|
17
|
-
`,L=function(t){let{record:r,expanded:n,expandable:o,onExpand:a}=t;return e(A,o?{onClick:e=>a(r,e),children:e(n?F:M,{})}:{})},$=z(w)`
|
|
18
|
-
margin-bottom: 0;
|
|
19
|
-
justify-content: flex-end;
|
|
20
|
-
margin-top: 1rem;
|
|
21
|
-
`;const G=v(((a,i)=>{let{source:l,rowKey:d="id",paginate:g=!0,toolBarRender:v,columns:b=[],search:x,rowSelection:w,card:V=!0,expandable:z={},sync:N=!1,...q}=a;const[K,M]=u([]),[B,P]=u(g?{total:0,current:1,pageSize:10}:null),[F,_]=u(!0),[I,A]=c({}),[G,J]=function(t,r,n){const[o,a]=u((()=>new Set(t?.selectedRowKeys||[]))),i=e=>"string"==typeof r?e[r]:r(e),c=e=>n.find((t=>i(t)===e)),l=p((e=>{e instanceof Set||(e=new Set(e)),a(e);const r=Array.from(e),n=r.map((function(e){return c(e)}));t?.onChange&&t?.onChange(r,n)}),[c]);return[p((r=>{if(!t)return r;const a=n.map(i),c=a.every((function(e){return o.has(e)})),s=a.some((function(e){return o.has(e)}));return[{key:"selection",title:e(H,{checked:c&&n.length>0,indeterminate:!c&&s,onChange:()=>{c?a.forEach((function(e){o.delete(e)})):a.forEach((function(e){o.add(e)})),l(new Set(o))}}),width:30,align:"center",render(t){let{record:r}=t;const n=i(r),a=o.has(n);return e(H,{checked:a,onChange:()=>{a?o.delete(n):o.add(n),l(new Set(o))}})}},...r]}),[n,t,o]),l]}(w,d,K),Y=f((()=>s(I,["q","page"])),[I]),[Z,ee]=j({value:N?Y:void 0,defaultValue:{},onChange:e=>{N&&A(e)}}),[te,re]=j({value:N?I.q||"":void 0,defaultValue:"",onChange:e=>{N&&A({q:e||void 0})}}),[ne,oe]=j({value:N?I.page||1:void 0,defaultValue:1,onChange:e=>{N&&A({page:e||void 0})}}),ae=p((async()=>{_(!0),J([]);try{let e;const t={...Z,q:te,page:ne>1?ne:void 0};e="string"==typeof l?await C({url:l,params:t}):await l(t),g&&function(e){return"current_page"in e}(e)&&(P({total:e.total,current:e.current_page,pageSize:e.per_page}),e=e.data),M(e)}catch(e){}finally{_(!1)}}),[l,M,te,ne,Z]);h((()=>{ae()}),[te,ne,Z]);const ie=m({reload:ae});h((()=>{ie.current={reload:ae}}),[ae]),y(i,(()=>ie.current));const ce=f((()=>G(b).map((t=>{let{render:r,valueType:n,valueEnum:o,...a}=t;const i={...a};return r?i.render=(e,t,n)=>r({value:e,record:t,index:n,action:ie.current}):"currency"===n?i.render=t=>e(k,{value:t}):o&&(i.render=t=>o[t]?o[t].status?e("span",{className:`text-${o[t].status}`,children:o[t].text}):o[t].text:t),i}))),[b,G,ie]),le=t(r,{children:[e(S,{loading:F}),"object"==typeof x&&e(T,{data:Z,columns:b,options:x,onSearch:e=>{o((()=>{oe(1),ee(e)}))}}),!1!==v&&t(Q,{children:[e(W,{size:12,children:v&&v(ie.current)}),t(U,{size:12,children:[!0===x&&e(D,{keyword:te,onKeywordChange:e=>{o((()=>{oe(1),re(e)}))}}),e(X,{onClick:ie.current.reload,children:e("i",{className:"bi bi-arrow-repeat"})})]})]}),e(E.Provider,{value:!0,children:e(n,{...q,expandable:{expandIcon:L,...z},rowKey:d,columns:ce,components:R,data:K})}),B&&e($,{...B,onChange:oe})]});return V?e(O,{children:le}):le}));var J=g(G);const Q=z.div`
|
|
22
|
-
display: flex;
|
|
23
|
-
justify-content: space-between;
|
|
24
|
-
padding-bottom: 1rem;
|
|
25
|
-
height: 48px;
|
|
26
|
-
border-bottom: 2px solid #212529;
|
|
27
|
-
`,U=z(V)`
|
|
28
|
-
|
|
29
|
-
`,W=z(V)`
|
|
30
|
-
|
|
31
|
-
`,X=z.span`
|
|
32
|
-
cursor: pointer;
|
|
33
|
-
font-size: 20px;
|
|
34
|
-
line-height: 1;
|
|
35
|
-
|
|
36
|
-
&:hover {
|
|
37
|
-
color: var(--bs-primary);
|
|
38
|
-
}
|
|
39
|
-
`;export{J as default};
|
package/es/index-oPMscx3h.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
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 l,r as m,B as p}from"./index-WNXBQWc1.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"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})}),y={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 m({url:a.endpoint,method:"post",data:o});return{url:r,value:e}}),t(n.upload,{...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 m({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 m({url:a.endpoint,params:{value:o,query:r}})}),t(n.typeahead,{...e,options:a})}},h=e(((r,a)=>{let{action:e,method:u="post",onSuccess:f,formData:h,onSubmitting:w,onSubmit:g,onChange:b,submitText:x="提交",transformData:v,children:D,...j}=r;const[S,k]=n(),[q,_]=l(!1),[z,E]=n(h),C=i((async(t,o)=>{if(!q)try{if(_(!0),w&&w(!0),e){let{formData:o}=t;v&&(o=v(o));try{const t=await m({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]),F=i((t=>{const{formData:o}=t;E(o),b&&b(t)}),[E,b]),N=i((t=>(t=t.map((t=>({keyword:t.name,dataPath:t.property,...t}))),d(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(o,{ref:a,extraErrors:S,onSubmit:C,transformErrors:N,noHtml5Validate:!0,noValidate:!0,...j,formData:z,onChange:F,widgets:y,children:D||t("div",{className:"col-12",children:U})})}));export{h as default};
|