@topthink/components 1.0.76 → 1.0.78
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/context-jiLXU49j.js +1 -0
- package/es/image-GvVhZYp9.js +1 -0
- package/es/index-7FvyDh2h.js +1 -0
- package/es/index-ay0UACAO.js +39 -0
- package/es/index-gYTBuYWX.js +1 -0
- package/es/index-kWp6EVXg.js +72 -0
- package/es/index.js +1 -1
- package/package.json +6 -3
- package/types/components/card-list.d.ts +1 -1
- package/types/components/clipboard.d.ts +11 -0
- package/types/components/lazy/lightbox/context.d.ts +10 -0
- package/types/components/lazy/lightbox/image.d.ts +2 -0
- package/types/components/lazy/lightbox/index.d.ts +8 -0
- package/types/components/lightbox.d.ts +7 -0
- package/types/hooks/use-immer.d.ts +5 -0
- package/types/index.d.ts +6 -0
- package/types/utils/format-size.d.ts +1 -0
- package/types/utils/get-absolute-url.d.ts +1 -0
- package/types/utils/is-image-url.d.ts +1 -0
- package/es/index-Lew1TOat.js +0 -39
- package/es/index-PAwhCzF3.js +0 -72
- package/es/index-WWkgdiqC.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createContext as e}from"react";const r=e({images:new Map,current:0,setCurrent:()=>null,setShow:()=>null,registerImage:()=>()=>null});export{r as I};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as r}from"react/jsx-runtime";import{useContext as t,useState as e,useEffect as o}from"react";import{I as s}from"./context-jiLXU49j.js";let i=0;function m(m){const{registerImage:n,setShow:c,setCurrent:a}=t(s),[f]=e((()=>(i+=1,i)));return o((()=>{if(m.src)return n(f,m.src)}),[]),r("img",{...m,onClick:()=>{a(f),c(!0)}})}export{m as default};
|
|
@@ -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 m,B as l}from"./index-kWp6EVXg.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"path";import"styled-components";import"classnames";import"use-url-search-params";import"copy-to-clipboard";import"react-async-hook";import"immer";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 m({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 m({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 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})}},y=e(((r,a)=>{let{action:e,method:u="post",onSuccess:f,formData:y,onSubmitting:w,onSubmit:g,onChange:b,submitText:v="提交",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 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]),U=i((t=>{const{formData:o}=t;E(o),b&&b(t)}),[E,b]),C=i((t=>(t=t.map((t=>({keyword:t.name,dataPath:t.property,...t}))),d(t),t)),[]),N=t(l,{className:"px-4",loading:q,type:"submit",variant:"primary",children:v});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};
|
|
@@ -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 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 p,useCallback as u,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-kWp6EVXg.js";import N from"styled-components";import H from"./index-7FvyDh2h.js";import"sweetalert2/dist/sweetalert2.js";import"sweetalert2-react-content";import"axios";import"query-string";import"retry-axios";import"rc-notification";import"path";import"classnames";import"copy-to-clipboard";import"react-async-hook";import"immer";import"@topthink/json-form";const q=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 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:o,columns:a,onSearch:i}=r;const[c,s]=p(0),[d,m]=p(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=u((e=>{let{formData:t}=e;m(t),i({...y,...t})}),[i,y]),w=u((()=>{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[o,i]=p(r),c=x(n,500);h((()=>{i(r)}),[r]);const l=u((e=>{i(e.target.value),c(e.target.value)}),[c,i]);return e(a,{value:o,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:o,onExpand:a}=t;return e(L,o?{onClick:e=>a(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(((a,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}=a;const[M,B]=p([]),[P,F]=p(g?{total:0,current:1,pageSize:10}:null),[T,I]=p(!0),[_,L]=c({}),[J,Q]=function(t,r,n){const[o,a]=p((()=>new Set(t?.selectedRowKeys||[]))),i=e=>"string"==typeof r?e[r]:r(e),c=e=>n.find((t=>i(t)===e)),l=u((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[u((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(q,{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(q,{checked:a,onChange:()=>{a?o.delete(n):o.add(n),l(new Set(o))}})}},...r]}),[n,t,o]),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})}}),[oe,ae]=j({value:H?_.page||1:void 0,defaultValue:1,onChange:e=>{H&&L({page:e||void 0})}}),ie=u((async function(){arguments.length>0&&void 0!==arguments[0]&&arguments[0]||I(!0),Q([]);try{let e;const t={...ee,q:re,page:oe>1?oe: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,oe,ee]);h((()=>{ie()}),[re,oe,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:o,...a}=t;const i={...a};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}):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,J,ce]),se=t(r,{children:[e(E,{loading:T}),"object"==typeof x&&e(D,{data:ee,columns:b,options:x,onSearch:e=>{o((()=>{ae(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=>{o((()=>{ae(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:ae})]});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 @@
|
|
|
1
|
+
import{jsxs as t,jsx as e}from"react/jsx-runtime";import{useState as r,useCallback as o}from"react";import n from"yet-another-react-lightbox";import i from"yet-another-react-lightbox/plugins/counter";import l from"yet-another-react-lightbox/plugins/download";import a from"yet-another-react-lightbox/plugins/zoom";import"yet-another-react-lightbox/styles.css";import"yet-another-react-lightbox/plugins/counter.css";import{I as s}from"./context-jiLXU49j.js";function c(c){let{children:m}=c;const[p,u]=r((()=>new Map)),[g,h]=r(),[d,x]=r(!1),f=o(((t,e)=>(u((r=>new Map(r).set(t,e))),()=>{u((e=>{const r=new Map(e);return r.delete(t)?r:e}))})),[]),b=Array.from(p.keys()),y=b.indexOf(g),v=b.map((t=>({src:p.get(t)})));return t(s.Provider,{value:{images:p,current:g,setCurrent:h,setShow:x,registerImage:f},children:[m,e(n,{styles:{container:{backgroundColor:"rgba(0, 0, 0, .7)"}},plugins:[i,l,a],open:d,index:y,close:()=>x(!1),slides:v,render:{buttonPrev:v.length<=1?()=>null:void 0,buttonNext:v.length<=1?()=>null:void 0},controller:{closeOnBackdropClick:!0}})]})}export{c as default};
|
|
@@ -0,0 +1,72 @@
|
|
|
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 c,createContext as s,Fragment as l,useContext as d,useCallback as u,useMemo as f,forwardRef as m,Children as h,lazy as p,Suspense as g,createElement as y,useImperativeHandle as b,memo as x}from"react";import{OverlayTrigger as v,Tooltip as w,Spinner as k,Button as C,Modal as N,Alert as S,Card as z,Pagination as j,Offcanvas as T,Row as B,Col as P}from"react-bootstrap";import{uniqueId as $,values as H,debounce as E}from"lodash";import F from"axios";import A from"query-string";import*as L from"retry-axios";import D from"rc-notification";import M from"path";import O,{css as _}from"styled-components";import I from"classnames";import{useUrlSearchParams as U}from"use-url-search-params";import R from"copy-to-clipboard";import{useAsyncCallback as q}from"react-async-hook";import{freeze as G,produce as V}from"immer";const K=t(e),Y={confirmButtonText:"确定",cancelButtonText:"取消"},J={confirm:async e=>{const{isConfirmed:t}=await K.fire({...Y,icon:"warning",showCancelButton:!0,...e,async preConfirm(t){if(e.preConfirm)try{return await e.preConfirm(t)}catch(e){return e instanceof Error&&K.showValidationMessage(e.message),!1}return!0}});return t},success:e=>{K.fire({...Y,toast:!0,position:"top",icon:"success",timer:2e3,showConfirmButton:!1,...e})},error:e=>{K.fire({...Y,toast:!0,position:"top",icon:"error",timer:5e3,showConfirmButton:!1,...e})},close:e=>{K.close(e)},defaults:Y};const Q=s({});function W(e){return t=>{let{resolve:r,destroy:o,message:s}=t;const[l,m]=function(e){const t=i(null),[n,r]=a(e);return c((()=>{t.current&&(t.current(),t.current=null)}),[n]),[n,(e,n)=>{t.current="function"==typeof n?n:null,r(e)}]}(!0),h=d(Q),p=u((e=>{m(!1,(()=>{r(e)}))}),[m,r]),g=f((()=>({show:l,onHide:()=>p(),onExited:()=>o(),container:h.container})),[l,p,o]);return n(e,{resolve:p,state:g,message:s})}}function X(e){return t=>new Promise((r=>{const o=n(e,{resolve:r,destroy:()=>{ne(o)},message:t});te(o)}))}let Z=()=>{},ee=new Set;const te=e=>{ee=new Set(ee),ee.add(e),Z(ee)},ne=e=>{ee=new Set(ee),ee.delete(e),Z(ee)};function re(e,t){return X(W(e))(t)}function oe(e){let{tooltip:t,children:r,placement:o="bottom"}=e;return n(v,{placement:o,overlay:n(w,{id:$(),children:t}),children:r})}const ie=s(!1),ae=m(((e,t)=>{let{loading:i,percent:a,disabled:c,children:s,tooltip:l,variant:u,...f}=e;d(ie)&&!u&&(u="link"),i&&(c=!0,s=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 m=n(C,{ref:t,...f,variant:u,disabled:c,children:s});return l?n(oe,{tooltip:l,children:n("span",{className:"d-inline-block",children:m})}):m})),ce=function(e){let{state:t,message:{title:o,message:i,okText:a,cancelText:c},resolve:s}=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(ae,{variant:"secondary",onClick:()=>s(),children:c||"取消"}),n(ae,{onClick:()=>s(!0),children:a||"确定"})]})]})};const se=e=>{let{header:t,children:i,footer:c,closable:s=!0,show:l,cancelText:d="取消",okText:u="确定",onOk:m,onCancel:h,onHide:p,okButtonProps:g,bodyAs:y,headerAs:b="h5",confirmLoading:x=!1,...v}=e;const[w,k]=a(!1),C=f((()=>n(ae,{loading:w||x,variant:"primary",onClick:async e=>{k(!0);try{await(m?.(e)),e.defaultPrevented||p?.()}finally{k(!1)}},...g,children:u})),[g,u,m,p,w,x]),S=f((()=>n(ae,{variant:"secondary",onClick:e=>{h?.(e),e.defaultPrevented||p?.()},children:d})),[h,p,d]);switch(typeof c){case"undefined":c=r(o,{children:[S,C]});break;case"function":c=c({okButton:C,cancelButton:S})}return r(N,{...v,onHide:p,show:l,children:[t&&n(N.Header,{closeButton:s,children:n(N.Title,{as:b,children:t})}),n(N.Body,{as:y,children:i}),c&&n(N.Footer,{children:c})]})};let le;se.Message=function(e){const[t,r]=a(ee);return c((()=>{Z=r}),[]),n(Q.Provider,{value:e,children:Array.from(t).map(((e,t)=>n(l,{children:e},`message-${t}`)))})},se.confirm=function(e){return X(W(ce))(e)},se.show=re;const de={};const ue=e=>{let{type:t,...r}=e;!function(e){if(le)return e(le);D.newInstance({...de,prefixCls:"notification",maxCount:5,style:{top:20,right:20}},(t=>{le?e(le):(le=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)}))},fe=["error","success","info"].reduce(((e,t)=>(e[t]=(e,n)=>{ue({...n,type:t,content:e})},e)),{});function me(e){return e&&"object"==typeof e}fe.defaults=de,L.attach(),F.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)}},F.defaults.maxContentLength=1/0,F.defaults.maxBodyLength=1/0,F.defaults.baseURL="/api",F.defaults.authTokenName="authorization",F.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))),F.interceptors.response.use((e=>(201===e.status&&e.data.location&&(window.location.href=e.data.location,e.data=void 0),e)),(e=>{if(F.isAxiosError(e)&&e.response){const{data:t,status:n}=e.response;401===n?(e.errors="Unauthorized",fe.error("Unauthorized")):me(t)?422===n?e.errors=t:"message"in t&&(e.errors=t.message):e.errors=t}return Promise.reject(e)}));const he=F.isAxiosError,pe=e=>{if(!F.isAxiosError(e))throw e;{let t=e.errors;"string"!=typeof e.errors&&(t=Object.values(e.errors).join("<br />")),fe.error(t)}},ge=async function(e){e="string"==typeof e?{url:e}:e;const{data:t}=await F.request({paramsSerializer:function(e){return A.stringify(e,{sort:!1,skipNull:!0,skipEmptyString:!0,arrayFormat:"bracket"})},...e});return t};ge.defaults=F.defaults,ge.interceptors=F.interceptors;const ye=()=>{const e=i(!1);return c((()=>(e.current=!1,()=>{e.current=!0})),[]),e};function be(e){const t=ye(),[n,r]=a(e);return[n,u((e=>{t.current||r(e)}),[])]}const xe=function(e){let{state:t,message:r,resolve:o}=e;const a=i(!0),{result:s,checkUrl:l,onComplete:d}=r,[u,f]=be(!1);return c((()=>{ge({url:l,method:"post",data:{order_no:s.order_no},raxConfig:{shouldRetry:e=>a.current&&449===e.response?.status}}).then((()=>{d?.(),o()})).catch((()=>null))}),[]),n(se,{...t,centered:!0,onHide:()=>{a.current=!1,t.onHide()},backdrop:"static",header:"支付结果",okText:"已完成支付",okButtonProps:{loading:u},onOk:async e=>{e.preventDefault();try{f(!0),await ge({url:l,method:"post",data:{order_no:s.order_no},raxConfig:{shouldRetry:()=>!1}}),d?.(),o()}catch{}finally{f(!1)}},cancelText:"取消",children:"请在新打开的页面上进行支付,支付完成后再关闭此窗口"})};function ve(e){const{result:t}=e;window.open(t.pay_url),re(xe,e)}function we(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2;return e>=1024**3?(e/1024**3).toFixed(t)+"G":e>=1048576?(e/1048576).toFixed(t)+"M":(e/1024).toFixed(t)+"K"}function ke(e){const t=M.extname(e);return!(!/^data:image\//.test(e)&&!/(webp|svg|png|gif|jpg|jpeg|jfif|bmp|dpg|ico)$/i.test(t))||!/^data:/.test(e)&&!t}function Ce(e){const t=document.createElement("a");return t.href=e,t.href}const Ne=O.div`
|
|
2
|
+
padding: 48px 32px;
|
|
3
|
+
`,Se=O.div`
|
|
4
|
+
margin-bottom: 24px;
|
|
5
|
+
text-align: center;
|
|
6
|
+
font-size: 72px;
|
|
7
|
+
`,ze=O.div`
|
|
8
|
+
color: rgba(0, 0, 0, .85);
|
|
9
|
+
font-size: 24px;
|
|
10
|
+
line-height: 1.8;
|
|
11
|
+
text-align: center;
|
|
12
|
+
`,je=O.div`
|
|
13
|
+
margin-top: 32px;
|
|
14
|
+
text-align: center;
|
|
15
|
+
`,Te={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 Be(e){let{status:t,title:o,icon:i,extra:a}=e;return!i&&t&&(i=Te[t]),r(Ne,{children:[i&&n(Se,{children:i}),o&&n(ze,{children:o}),a&&n(je,{children:a})]})}O.div`
|
|
16
|
+
position: relative;
|
|
17
|
+
`;const Pe=O.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 $e(e){let{loading:t=!0,children:o,variant:i="primary",animation:a="border",wrap:c,...s}=e;return t?(o&&(o=n("p",{className:"mt-3 text-secondary",children:o})),o=r(Pe,{inverted:!0,active:!0,children:[n(k,{animation:a,variant:i,...s}),o]}),c?n(He,{$height:"number"==typeof c?c:150,children:o}):o):null}const He=O.div`
|
|
40
|
+
position: relative;
|
|
41
|
+
height: ${e=>`${e.$height}px`};
|
|
42
|
+
`;function Ee(e){let{children:t,title:i,className:a,...c}=e;return n(z,{className:I("border-0 shadow-sm mb-3",a),...c,children:r("div",{className:"card-body",children:[i&&r(o,{children:[n("h5",{children:i}),n("hr",{})]}),t]})})}function Fe(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 Ae(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=h.map(t,(e=>{if(e)return n(De,{children:e})}));return n(Le,{className:r,$direction:i,$size:o,children:a})}const Le=O.div`
|
|
43
|
+
display: inline-flex;
|
|
44
|
+
align-items: center;
|
|
45
|
+
gap: ${e=>e.$size}px;
|
|
46
|
+
|
|
47
|
+
${e=>"vertical"===e.$direction&&_`
|
|
48
|
+
display: flex;
|
|
49
|
+
flex-direction: column;
|
|
50
|
+
align-items: inherit;
|
|
51
|
+
`}
|
|
52
|
+
`,De=O.div`
|
|
53
|
+
|
|
54
|
+
`,Me=p((()=>import("./steps-b_BcYIwk.js"))),Oe=p((()=>import("./steps-b_BcYIwk.js").then((e=>{let{Step:t}=e;return{default:t}}))));function _e(e){return n(g,{fallback:null,children:n(Me,{...e})})}const Ie=function(e){return n(g,{fallback:null,children:n(Oe,{...e})})};function Ue(e){let{title:t,content:o,footer:i}=e;return r(Ee,{children:[n(Ge,{children:t}),n(qe,{children:o}),i&&n(Re,{children:i})]})}_e.Step=Ie;const Re=O.div`
|
|
55
|
+
margin-top: 9px;
|
|
56
|
+
padding-top: 10px;
|
|
57
|
+
border-top: 1px solid #f0f0f0;
|
|
58
|
+
color: rgba(0, 0, 0, .65);
|
|
59
|
+
`,qe=O.div`
|
|
60
|
+
color: rgba(0, 0, 0, .85);
|
|
61
|
+
font-size: 24px;
|
|
62
|
+
`,Ge=O.div`
|
|
63
|
+
margin-bottom: 4px;
|
|
64
|
+
color: rgba(0, 0, 0, .45);
|
|
65
|
+
font-size: 1.1rem;
|
|
66
|
+
`;function Ve(){}function Ke(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e}function Ye(e){return"current_page"in e}function Je(e){let{total:t=0,onChange:r=Ve,defaultCurrent:o=1,defaultPageSize:i=10,className:s,...l}=e;const[d,m]=a(o),[h,p]=a(i);c((()=>{Ke(l.current)&&m(l.current)}),[l.current]),c((()=>{Ke(l.pageSize)&&p(l.pageSize)}),[l.pageSize]);const g=f((()=>Math.floor((t-1)/h)+1),[t,h]),y=u((e=>()=>{e!==d&&(m(e),r(e,h))}),[r,d,h]),b=d-1>0?d-1:0,x=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(j.Item,{active:t,onClick:y(e),children:e},e))}else{N=n(j.Last,{onClick:y(g)},"last"),C=n(j.First,{onClick:y(1)},"first"),w=n(j.Prev,{onClick:y(b)},"prev"),k=n(j.Next,{onClick:y(x)},"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(j.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(j,{className:s,children:v})}function Qe(e){let{className:t,value:r,locale:i="zh-CN",currency:a=!0,options:c={}}=e;const s=f((()=>{let e;return e=a?{style:"currency",currency:"CNY"}:{minimumFractionDigits:2},new Intl.NumberFormat(i,{...e,...c})}),[a,i,c]);return t?n("span",{className:t,children:s.format(r)}):n(o,{children:s.format(r)})}function We(e){let{loading:t,disabled:r,children:o,...i}=e;return n(C,{...i,disabled:t||r,children:t?"Loading…":o})}const Xe=p((()=>import("./image-zoom-OrIPGqh0.js")));function Ze(e){return n(g,{fallback:null,children:n(Xe,{...e})})}function et(e){let{url:t,method:n,confirm:r,onSuccess:o,children:i,disabled:a,as:c=ae,...s}=e;const[l,d]=be(!1),f=u((async e=>{e.preventDefault();try{if(d(!0),r&&!await se.confirm({message:r}))return;const e="string"==typeof t?{url:t,method:n}:{method:n,...t},i=await ge(e);o&&o(i)}catch(e){pe(e)}finally{d(!1)}}),[t,n,d]);return y(c,{...s,disabled:a||l,onClick:f},i)}const tt=p((()=>import("./index-7FvyDh2h.js"))),nt=m(((e,t)=>n(g,{fallback:null,children:n(tt,{...e,ref:t})}))),rt=p((()=>import("./index-ay0UACAO.js"))),ot=m(((e,t)=>n(g,{fallback:null,children:n(rt,{...e,ref:t})})));let it=0;function at(){let{onHide:e,onShow:t}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const[n,r]=a(!1),[o,i]=a(`visible-${it}`),c=u((()=>{r(!1),e&&e()}),[r,e]),s=u((()=>{i("visible-"+ ++it)}),[i,it]);return{visible:n,show:u((()=>{r(!0),t&&t()}),[r,t]),hide:c,state:{show:n,onHide:c,onExited:s,key:o}}}const ct=m(((e,t)=>{let{text:i,onOk:a,modalProps:c,children:s,onShow:l,onHide:d,confirmLoading:u,as:f=ae,...m}=e;const{state:h,show:p,hide:g}=at({onShow:l,onHide:d});b(t,(()=>({close:g})));const x=y(f,{...m,onClick:p},i);return r(o,{children:[x,n(se,{header:i,...c,...h,confirmLoading:u,onOk:async e=>{if(a){!1===await a()&&e.preventDefault()}},children:s})]})})),st=m(((e,t)=>{let{text:o,onSuccess:c,onSubmit:s,buttonProps:l,modalProps:d,children:f,...m}=e;const[h,p]=a(!1),g=i(null),y=i(null);b(t,(()=>({close:()=>{g.current?.close()}})));const x=u((()=>(y.current?.submit(),!1)),[]),v=u((e=>{c&&c(e),g.current?.close()}),[c]),w=u((async(e,t)=>{s&&await s(e,t)&&g.current?.close()}),[s]);return n(ct,{ref:g,text:o,...l,modalProps:d,onOk:x,confirmLoading:h,children:r(nt,{...m,onSubmitting:p,ref:y,onSuccess:v,onSubmit:w,children:[f,n("input",{type:"submit",hidden:!0})]})})}));function lt(e){let{header:t,children:o,closable:i=!0,show:a,onHide:c,bodyAs:s,headerAs:l="h5",...d}=e;return r(T,{...d,onHide:c,show:a,children:[t&&n(T.Header,{closeButton:i,children:n(T.Title,{as:l,children:t})}),n(T.Body,{as:s,children:o})]})}const dt=m(((e,t)=>{let{text:i,offcanvasProps:a,children:c,onShow:s,onHide:l,as:d=ae,...u}=e;const{state:f,show:m,hide:h}=at({onShow:s,onHide:l});b(t,(()=>({close:h})));const p=y(d,{...u,onClick:m},i);return r(o,{children:[p,n(lt,{header:i,...a,...f,children:c})]})}));function ut(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];const n=i(e);return c((()=>{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 ft(e){const{value:t,defaultValue:n,onChange:r,shouldUpdate:o=((e,t)=>e!==t)}=e,i=ut(r),c=ut(o),[s,l]=a(n),d=void 0!==t,u=d?t:s,f=ut((e=>{const t="function"==typeof e?e(u):e;c(u,t)&&(d||l(t),i(t))}),[d,i,u,c]);return[u,f]}const mt=m(((e,t)=>{let{className:o,paginate:s=!0,sync:l=!1,columns:d=3,source:f,renderItem:m,renderEmpty:h}=e;const[p,g]=a([]),[y,x]=a(s?{total:0,current:1,pageSize:10}:null),[v,w]=a(!0),[k,C]=U({}),[N,S]=ft({value:l?k.page||1:void 0,defaultValue:1,onChange:e=>{l&&C({page:e||void 0})}}),z=u((async function(){arguments.length>0&&void 0!==arguments[0]&&arguments[0]||w(!0);try{let e;const t={page:N>1?N:void 0};e="string"==typeof f?await ge({url:f,params:t}):await f(t),s&&Ye(e)&&(e.last_page>1&&x({total:e.total,current:e.current_page,pageSize:e.per_page}),e=e.data),g(e)}catch(e){}finally{w(!1)}}),[f,g,N]);c((()=>{z()}),[N]),c((()=>{j.current={reload:z}}),[z]);const j=i({reload:z});return b(t,(()=>j.current)),r(ht,{className:o,children:[n($e,{wrap:!0,loading:v}),0===p.length&&!v&&h?.(),n(B,{children:p.map(((e,t)=>n(P,{className:"d-flex",md:12/d,children:m(e)},`card-${t}`)))}),y&&n(pt,{...y,onChange:S})]})})),ht=O.div`
|
|
67
|
+
|
|
68
|
+
`,pt=O(Je)`
|
|
69
|
+
margin-bottom: 0;
|
|
70
|
+
justify-content: flex-end;
|
|
71
|
+
margin-top: 1rem;
|
|
72
|
+
`;var gt=x(mt);function yt(e){let{as:t="div",className:r,content:o,tooltip:s=!0,placement:l}=e;const[d,u]=a(!1),f=i();c((()=>()=>{f.current&&clearTimeout(f.current)}),[]);const m=s?n("i",d?{className:"bi bi-clipboard-check"}:{className:"bi bi-clipboard"}):d?"已复制":"复制",h=y(t,{role:"button",className:r,onClick:()=>{"function"==typeof o&&(o=o()),R(o),u(!0),f.current&&clearTimeout(f.current),f.current=setTimeout((()=>{u(!1),f.current=void 0}),3e3)}},m);return s?n(oe,{tooltip:d?"已复制":"复制",placement:l,children:h}):h}const bt=p((()=>import("./index-gYTBuYWX.js"))),xt=p((()=>import("./image-GvVhZYp9.js")));function vt(e){return n(g,{fallback:null,children:n(bt,{...e})})}function wt(e){let{manual:t,refreshDeps:n,...r}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{execute:o,currentParams:i,error:a,...s}=q((async t=>(e="string"==typeof e?{url:e}:e,await ge({...e,...t}))),r);c((()=>{if(!t&&!n)try{o()}catch{}}),[]),c((()=>{n&&l()}),n);const l=u((async()=>{try{i?await o(...i):await o()}catch{}}),[o,i]);if(a&&he(a)){const e=a.errors;a=new Error("string"==typeof e?e:H(e).join(""))}return{refresh:l,execute:o,error:a,...s}}function kt(e,t,n){const r=i(e),o=i(E(e,t,n));return c((()=>{r.current=e})),c((()=>{o.current=E((function(){r.current(...arguments)}),t,n)}),[t,n]),o.current}function Ct(e){const[t,n]=a((()=>G("function"==typeof e?e():e,!0)));return[t,u((e=>{n("function"==typeof e?V(e):G(e))}),[])]}vt.Image=function(e){return n(g,{fallback:null,children:n(xt,{...e})})};export{at as A,ae as B,Ee as C,Ct as D,Fe as E,nt as F,he as G,pe as H,Ze as I,$e as L,J as M,Qe as N,dt as O,Je as P,Be as R,Ae as S,ie as T,ft as a,be as b,fe as c,me as d,ke as e,we as f,Ce as g,_e as h,Ye as i,Ie as j,Ue as k,We as l,et as m,ot as n,st as o,ct as p,se as q,ge as r,lt as s,oe as t,kt as u,gt as v,ve as w,yt as x,vt as y,wt as z};
|
package/es/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{B as Button,C as Card,
|
|
1
|
+
export{B as Button,C as Card,v as CardList,x as Clipboard,E as Error,F as Form,I as ImageZoom,y as Lightbox,L as Loader,l as LoadingButton,M as Message,q as Modal,p as ModalButton,o as ModalForm,N as NumberFormat,s as Offcanvas,O as OffcanvasButton,P as Pagination,m as RequestButton,R as Result,S as Space,k as Statistic,j as Step,h as Steps,n as Table,c as Toast,t as Tooltip,f as formatSize,g as getAbsoluteUrl,e as isImageUrl,d as isRecord,G as isRequestError,r as request,H as showRequestError,a as useControllableState,u as useDebounce,D as useImmer,A as useOverlayState,z as useRequest,b as useSafeState,w as waitPayComplete}from"./index-kWp6EVXg.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"path";import"classnames";import"use-url-search-params";import"copy-to-clipboard";import"immer";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@topthink/components",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.78",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"prebuild": "rimraf es types",
|
|
6
6
|
"build": "rollup -c --environment NODE_ENV:production",
|
|
@@ -25,6 +25,8 @@
|
|
|
25
25
|
"ajv-i18n": "^4.0.0",
|
|
26
26
|
"axios": "^0.27.2",
|
|
27
27
|
"classnames": "^2.3.1",
|
|
28
|
+
"copy-to-clipboard": "^3.3.3",
|
|
29
|
+
"immer": "^9.0.6",
|
|
28
30
|
"query-string": "^8.1.0",
|
|
29
31
|
"rc-notification": "^4.5.2",
|
|
30
32
|
"rc-steps": "^4.1.4",
|
|
@@ -35,7 +37,8 @@
|
|
|
35
37
|
"styled-components": "^5.3.0",
|
|
36
38
|
"sweetalert2": "^11.0.18",
|
|
37
39
|
"sweetalert2-react-content": "^4.1.0",
|
|
38
|
-
"use-url-search-params": "^2.5.1"
|
|
40
|
+
"use-url-search-params": "^2.5.1",
|
|
41
|
+
"yet-another-react-lightbox": "^3.17.5"
|
|
39
42
|
},
|
|
40
43
|
"peerDependencies": {
|
|
41
44
|
"lodash": "*",
|
|
@@ -64,5 +67,5 @@
|
|
|
64
67
|
},
|
|
65
68
|
"author": "yunwuxin <tzzhangyajun@qq.com> (https://github.com/yunwuxin)",
|
|
66
69
|
"license": "MIT",
|
|
67
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "708024d254652c45a434c4a6b18971b44483a841"
|
|
68
71
|
}
|
|
@@ -13,7 +13,7 @@ export interface CardListProps<RecordType = any> {
|
|
|
13
13
|
renderEmpty?: () => ReactNode;
|
|
14
14
|
}
|
|
15
15
|
export interface CardListType {
|
|
16
|
-
reload: () => void;
|
|
16
|
+
reload: (silent?: boolean) => void;
|
|
17
17
|
}
|
|
18
18
|
export type CustomCardListType<T = any> = ForwardRefExoticComponent<PropsWithoutRef<PropsWithChildren<CardListProps<T>>> & RefAttributes<CardListType>>;
|
|
19
19
|
declare const _default: CustomCardListType<any>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ElementType } from 'react';
|
|
2
|
+
import { OverlayTriggerProps } from 'react-bootstrap';
|
|
3
|
+
interface Props {
|
|
4
|
+
className?: string;
|
|
5
|
+
content: string | (() => string);
|
|
6
|
+
as?: ElementType;
|
|
7
|
+
placement?: OverlayTriggerProps['placement'];
|
|
8
|
+
tooltip?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export default function Clipboard({ as, className, content, tooltip, placement }: Props): JSX.Element;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Dispatch, SetStateAction } from 'react';
|
|
2
|
+
interface ImageContextType {
|
|
3
|
+
images: Map<number, string>;
|
|
4
|
+
current: number | undefined;
|
|
5
|
+
setCurrent: Dispatch<SetStateAction<number | undefined>>;
|
|
6
|
+
setShow: Dispatch<SetStateAction<boolean>>;
|
|
7
|
+
registerImage: (id: number, url: string) => () => void;
|
|
8
|
+
}
|
|
9
|
+
export declare const ImageContext: import("react").Context<ImageContextType>;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import 'yet-another-react-lightbox/styles.css';
|
|
3
|
+
import 'yet-another-react-lightbox/plugins/counter.css';
|
|
4
|
+
interface Props {
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
}
|
|
7
|
+
export default function Lightbox({ children }: Props): JSX.Element;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ComponentProps } from 'react';
|
|
2
|
+
declare const LazyLightbox: import("react").LazyExoticComponent<typeof import("./lazy/lightbox").default>;
|
|
3
|
+
declare function Lightbox(props: ComponentProps<typeof LazyLightbox>): JSX.Element;
|
|
4
|
+
declare namespace Lightbox {
|
|
5
|
+
var Image: (props: import("react").ImgHTMLAttributes<HTMLImageElement>) => JSX.Element;
|
|
6
|
+
}
|
|
7
|
+
export default Lightbox;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Draft } from 'immer';
|
|
2
|
+
export type DraftFunction<S> = (draft: Draft<S>) => void;
|
|
3
|
+
export type Updater<S> = (arg: S | DraftFunction<S>) => void;
|
|
4
|
+
export type ImmerHook<S> = [S, Updater<S>];
|
|
5
|
+
export default function useImmer<S = any>(initialValue: S | (() => S)): ImmerHook<S>;
|
package/types/index.d.ts
CHANGED
|
@@ -3,6 +3,9 @@ export { default as waitPayComplete } from './utils/wait-pay-complete';
|
|
|
3
3
|
export { default as Toast } from './utils/toast';
|
|
4
4
|
export { PaginationType } from './utils/types';
|
|
5
5
|
export { default as isRecord } from './utils/is-record';
|
|
6
|
+
export { default as formatSize } from './utils/format-size';
|
|
7
|
+
export { default as isImageUrl } from './utils/is-image-url';
|
|
8
|
+
export { default as getAbsoluteUrl } from './utils/get-absolute-url';
|
|
6
9
|
export { default as Result } from './components/result';
|
|
7
10
|
export { default as Loader } from './components/loader';
|
|
8
11
|
export { default as Card } from './components/card';
|
|
@@ -25,11 +28,14 @@ export { default as OffcanvasButton, OffcanvasType, OffcanvasButtonProps } from
|
|
|
25
28
|
export { default as Offcanvas, OffcanvasProps } from './components/offcanvas';
|
|
26
29
|
export { default as Tooltip } from './components/tooltip';
|
|
27
30
|
export { default as CardList, CardListType } from './components/card-list';
|
|
31
|
+
export { default as Clipboard } from './components/clipboard';
|
|
32
|
+
export { default as Lightbox } from './components/lightbox';
|
|
28
33
|
export { default as useRequest } from './hooks/use-request';
|
|
29
34
|
export { default as useOverlayState } from './hooks/use-overlay-state';
|
|
30
35
|
export { default as useControllableState } from './hooks/use-controllable-state';
|
|
31
36
|
export { default as useDebounce } from './hooks/use-debounce';
|
|
32
37
|
export { default as useSafeState } from './hooks/use-safe-state';
|
|
38
|
+
export { default as useImmer } from './hooks/use-immer';
|
|
33
39
|
export { default as request, RequestConfig, RequestInstance, isRequestError, showRequestError } from './request';
|
|
34
40
|
export type { UiSchema as FormUiSchema, Schema as FormSchema, WidgetProps as FormWidgetProps, Widget as FormWidget, IChangeEvent as FormChangeEvent, ISubmitEvent as FormSubmitEvent } from '@topthink/json-form';
|
|
35
41
|
export { default as styled, css, keyframes, createGlobalStyle, StyleSheetManager, ThemeProvider } from 'styled-components';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function formatSize(token: number, fractionDigits?: number): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function getAbsoluteUrl(url: string): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function isImageUrl(url: string): boolean;
|
package/es/index-Lew1TOat.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,i as k,N as S,L as E,T as O,C as V,S as z}from"./index-PAwhCzF3.js";import N from"styled-components";import H from"./index-WWkgdiqC.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 o=m(null);return h((()=>{o.current&&(o.current.indeterminate=r)}),[r]),e("input",{ref:o,...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: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(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[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 _=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:o,onExpand:a}=t;return e(L,o?{onClick:e=>a(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(((a,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}=a;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[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(q,{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(q,{checked:a,onChange:()=>{a?o.delete(n):o.add(n),l(new Set(o))}})}},...r]}),[n,t,o]),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})}}),[oe,ae]=j({value:H?_.page||1:void 0,defaultValue:1,onChange:e=>{H&&L({page:e||void 0})}}),ie=p((async function(){arguments.length>0&&void 0!==arguments[0]&&arguments[0]||I(!0),Q([]);try{let e;const t={...ee,q:re,page:oe>1?oe: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,oe,ee]);h((()=>{ie()}),[re,oe,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:o,...a}=t;const i={...a};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}):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,J,ce]),se=t(r,{children:[e(E,{loading:T}),"object"==typeof x&&e(D,{data:ee,columns:b,options:x,onSearch:e=>{o((()=>{ae(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=>{o((()=>{ae(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:ae})]});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};
|
package/es/index-PAwhCzF3.js
DELETED
|
@@ -1,72 +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,memo as b}from"react";import{OverlayTrigger as v,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(v,{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:b=!1,...v}=e;const[w,k]=a(!1),C=h((()=>n(ne,{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(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,{...v,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
|
-
`,be=_.div`
|
|
8
|
-
color: rgba(0, 0, 0, .85);
|
|
9
|
-
font-size: 24px;
|
|
10
|
-
line-height: 1.8;
|
|
11
|
-
text-align: center;
|
|
12
|
-
`,ve=_.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(be,{children:o}),a&&n(ve,{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,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-WWkgdiqC.js"))),Ke=f(((e,t)=>n(g,{fallback:null,children:n(Je,{...e,ref:t})}))),Qe=p((()=>import("./index-Lew1TOat.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)`
|
|
69
|
-
margin-bottom: 0;
|
|
70
|
-
justify-content: flex-end;
|
|
71
|
-
margin-top: 1rem;
|
|
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-WWkgdiqC.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 p,r as l,B as m}from"./index-PAwhCzF3.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};
|