@topthink/components 1.1.7 → 1.1.9

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.
Files changed (43) hide show
  1. package/es/editor-widget-ZqrBTAWC.js +355 -0
  2. package/es/image-xVpjTjcN.js +1 -0
  3. package/es/{index-pdAII942.js → index-4j3qlSEA.js} +1 -1
  4. package/es/{index-7Eo6mqDi.js → index-alLkMNpj.js} +2 -2
  5. package/es/index-fW_tvsVH.js +1 -0
  6. package/es/index-tFUwxWXk.js +78 -0
  7. package/es/index.js +1 -1
  8. package/es/infinite-scroller-toFkixFC.js +1 -0
  9. package/package.json +3 -2
  10. package/types/components/card.d.ts +1 -1
  11. package/types/components/clipboard.d.ts +1 -1
  12. package/types/components/dimmer.d.ts +1 -1
  13. package/types/components/error.d.ts +1 -2
  14. package/types/components/image-zoom.d.ts +1 -1
  15. package/types/components/lazy/form/widgets/editor-widget.d.ts +3 -4
  16. package/types/components/lazy/lightbox/image.d.ts +1 -1
  17. package/types/components/lazy/lightbox/index.d.ts +1 -1
  18. package/types/components/lazy/slider.d.ts +1 -2
  19. package/types/components/lazy/steps.d.ts +1 -1
  20. package/types/components/lazy/table/search.d.ts +2 -3
  21. package/types/components/lightbox.d.ts +4 -4
  22. package/types/components/loading-button.d.ts +1 -2
  23. package/types/components/modal/index.d.ts +1 -1
  24. package/types/components/modal/message.d.ts +1 -1
  25. package/types/components/number-format.d.ts +1 -2
  26. package/types/components/offcanvas.d.ts +1 -1
  27. package/types/components/pagination.d.ts +1 -2
  28. package/types/components/panel.d.ts +2 -2
  29. package/types/components/qrcode.d.ts +1 -2
  30. package/types/components/result.d.ts +5 -5
  31. package/types/components/slider.d.ts +1 -1
  32. package/types/components/space.d.ts +1 -1
  33. package/types/components/statistic.d.ts +1 -1
  34. package/types/components/steps.d.ts +3 -3
  35. package/types/components/toast-provider.d.ts +2 -0
  36. package/types/components/tooltip.d.ts +1 -2
  37. package/types/index.d.ts +2 -1
  38. package/types/theme.d.ts +7 -0
  39. package/es/editor-widget-CQ3zv-Xu.js +0 -355
  40. package/es/image-TAFDJRLj.js +0 -1
  41. package/es/index-rwu3sC2k.js +0 -76
  42. package/es/index-xM26Eo_f.js +0 -1
  43. package/es/infinite-scroller-5Z8JxvFT.js +0 -1
@@ -1,76 +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 a,useState as i,useEffect as s,createContext as c,Fragment as l,useContext as d,useCallback as u,useMemo as h,forwardRef as m,lazy as f,Suspense as p,Children as g,createElement as y,useImperativeHandle as w,memo as v}from"react";import{OverlayTrigger as b,Tooltip as x,Spinner as k,Button as N,Modal as C,ButtonGroup as S,ToggleButton as z,Card as P,Accordion as j,Stack as T,Alert as $,Pagination as H,Offcanvas as B,Row as E,Col as L}from"react-bootstrap";import{uniqueId as _,values as D,omit as R,debounce as M}from"lodash";import F from"axios";import O from"query-string";import*as A from"retry-axios";import{enqueueSnackbar as U}from"notistack";import I from"path";import{useAsyncCallback as q}from"react-async-hook";import W,{css as G}from"styled-components";import K from"dayjs";import"dayjs/locale/zh-cn";import V from"dayjs/plugin/relativeTime";import Y from"classnames";import{useUrlSearchParams as Q}from"use-url-search-params";import J from"copy-to-clipboard";import{freeze as X,produce as Z}from"immer";import"react-intersection-observer";const ee=()=>{document.body.style.setProperty("--vh",window.innerHeight/100+"px"),document.body.style.setProperty("--100vh",window.innerHeight+"px")};window.addEventListener("resize",ee),ee();const te=t(e),ne={confirmButtonText:"确定",cancelButtonText:"取消"},re={confirm:async e=>{const{isConfirmed:t}=await te.fire({...ne,icon:"warning",showCancelButton:!0,...e,async preConfirm(t){if(e.preConfirm)try{return await e.preConfirm(t)}catch(e){return e instanceof Error&&te.showValidationMessage(e.message),!1}return!0}});return t},success:e=>{te.fire({...ne,toast:!0,position:"top",icon:"success",timer:2e3,showConfirmButton:!1,...e})},error:e=>{te.fire({...ne,toast:!0,position:"top",icon:"error",timer:5e3,showConfirmButton:!1,...e})},close:e=>{te.close(e)},defaults:ne};const oe=c({});function ae(e){return t=>{let{resolve:r,destroy:o,message:c}=t;const[l,m]=function(e){const t=a(null),[n,r]=i(e);return s((()=>{t.current&&(t.current(),t.current=null)}),[n]),[n,(e,n)=>{t.current="function"==typeof n?n:null,r(e)}]}(!0),f=d(oe),p=u((e=>{m(!1,(()=>{r(e)}))}),[m,r]),g=h((()=>({show:l,onHide:()=>p(),onExited:()=>o(),container:f.container})),[l,p,o]);return n(e,{resolve:p,state:g,message:c})}}function ie(e){return t=>new Promise((r=>{const o=n(e,{resolve:r,destroy:()=>{de(o)},message:t});le(o)}))}let se=()=>{},ce=new Set;const le=e=>{ce=new Set(ce),ce.add(e),se(ce)},de=e=>{ce=new Set(ce),ce.delete(e),se(ce)};function ue(e,t){return ie(ae(e))(t)}function he(e){let{tooltip:t,children:r,placement:o="bottom"}=e;return n(b,{placement:o,overlay:n(x,{id:_(),children:t}),children:r})}const me=c(!1),fe=m(((e,t)=>{let{loading:a,percent:i,disabled:s,children:c,tooltip:l,variant:u,...h}=e;d(me)&&!u&&(u="link"),a&&(s=!0,c=r(o,{children:[n(k,{ref:t,as:"span",size:"sm",role:"status","aria-hidden":"true",animation:"border"}),i?r("span",{className:"ms-2",children:[i,"%"]}):null]}));const m=n(N,{ref:t,...h,variant:u,disabled:s,children:c});return l?n(he,{tooltip:l,children:n("span",{className:"d-inline-block",children:m})}):m})),pe=function(e){let{state:t,message:{title:o,message:a,okText:i,cancelText:s},resolve:c}=e;return r(C,{...t,children:[n(C.Header,{children:n(C.Title,{as:"h5",children:o||"确认"})}),n(C.Body,{children:a}),r(C.Footer,{children:[n(fe,{variant:"secondary",onClick:()=>c(),children:s||"取消"}),n(fe,{onClick:()=>c(!0),children:i||"确定"})]})]})};const ge=e=>{let{header:t,children:a,footer:s,closable:c=!0,show:l,cancelText:d="取消",okText:u="确定",onOk:m,onCancel:f,onHide:p,okButtonProps:g,bodyAs:y,headerAs:w="h5",confirmLoading:v=!1,...b}=e;const[x,k]=i(!1),N=h((()=>n(fe,{loading:x||v,variant:"primary",onClick:async e=>{k(!0);try{await(m?.(e)),e.defaultPrevented||p?.()}finally{k(!1)}},...g,children:u})),[g,u,m,p,x,v]),S=h((()=>n(fe,{variant:"secondary",onClick:e=>{f?.(e),e.defaultPrevented||p?.()},children:d})),[f,p,d]),z={close:()=>{p?.()}};switch(typeof s){case"undefined":s=r(o,{children:[S,N]});break;case"function":s=s({okButton:N,cancelButton:S,action:z})}return r(C,{...b,onHide:p,show:l,children:[t&&n(C.Header,{closeButton:c,children:n(C.Title,{as:w,children:t})}),n(C.Body,{as:y,children:a}),s&&n(C.Footer,{children:s})]})};ge.Message=function(e){const[t,r]=i(ce);return s((()=>{se=r}),[]),n(oe.Provider,{value:e,children:Array.from(t).map(((e,t)=>n(l,{children:e},`message-${t}`)))})},ge.confirm=function(e){return ie(ae(pe))(e)},ge.show=ue;const ye=["default","error","warning","success","info"].reduce(((e,t)=>(e[t]=(e,n)=>U(e,{variant:t,autoHideDuration:3e3,anchorOrigin:{vertical:"top",horizontal:"center"},...n}),e)),{});function we(e){return e&&"object"==typeof e}A.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";const ve=F.isAxiosError,be=e=>{if(!F.isAxiosError(e))throw e;ye.error(e.message)},xe=function(e){e?.baseURL&&(e.baseURL=I.resolve(F.defaults.baseURL||"/",e.baseURL));const t=F.create(e);return A.attach(t),t.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))),t.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":we(t)?422===n?e.errors=t:"message"in t&&(e.errors=t.message):e.errors=t,"string"!=typeof e.errors?e.message=Object.values(e.errors).join("<br />"):e.message=e.errors}return Promise.reject(e)})),t},ke=async function(e,t){if(t||(t=xe()),e="string"==typeof e?{url:e}:e,(e={paramsSerializer:function(e){return O.stringify(e,{sort:!1,skipNull:!0,skipEmptyString:!0,arrayFormat:"bracket"})},...e}).onMessage){let t=0,n="",r=null;const o=e.onMessage;e.onDownloadProgress=e=>{const a=e.target,{responseText:i}=a;for(;t<e.loaded;){const e=i.substring(t,++t);if(n+=e,"\n"===e){if(r||(r={id:"",event:"",data:""}),"\n"===n)o(r),r=null;else{const e=n.match(/^data:(?<data>.*)/);e&&(r.data=e.groups.data.trim())}n=""}}}}const{data:n}=await t.request(e);return n};ke.create=function(e){const t=xe(e),n=e=>ke(e,t);return n.interceptors=t.interceptors,n},ke.defaults=F.defaults,ke.interceptors=F.interceptors;function Ne(e){const t=(()=>{const e=a(!1);return s((()=>(e.current=!1,()=>{e.current=!0})),[]),e})(),[n,r]=i(e);return[n,u((e=>{t.current||r(e)}),[])]}function Ce(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{locale:n="zh-CN",currency:r=!0,...o}=t;let a;a=r?{style:"currency",currency:"CNY"}:{minimumFractionDigits:2};return new Intl.NumberFormat(n,{...a,...o}).format(e)}function Se(e){let{manual:t,refreshDeps:n,...r}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{execute:o,currentParams:a,error:i,...c}=q((async t=>(e="string"==typeof e?{url:e}:e,await ke({...e,...t}))),r);s((()=>{if(!t&&!n)try{o()}catch{}}),[]),s((()=>{n&&l()}),n);const l=u((async()=>{try{a?await o(...a):await o()}catch{}}),[o,a]);if(i&&ve(i)){const e=i.errors;i=new Error("string"==typeof e?e:D(e).join(""))}return{refresh:l,execute:o,error:i,...c}}function ze(e){let{active:t,inverted:r,...o}=e;return n(Pe,{$active:t,$inverted:r,...o})}W.div`
2
- position: relative;
3
- `;const Pe=W.div`
4
- display: ${e=>e.$active?"flex":"none"};
5
- position: absolute;
6
- top: 0 !important;
7
- left: 0 !important;
8
- width: 100%;
9
- height: 100%;
10
- text-align: center;
11
- vertical-align: middle;
12
- padding: 1em;
13
- background-color: ${e=>e.$inverted?"rgba(255, 255, 255, .85)":"rgba(0, 0, 0, .85)"};
14
- opacity: ${e=>e.$active?1:0};
15
- line-height: 1;
16
- animation-fill-mode: both;
17
- animation-duration: .5s;
18
- transition: background-color .5s linear;
19
- flex-direction: column;
20
- align-items: center;
21
- justify-content: center;
22
- user-select: none;
23
- will-change: opacity;
24
- z-index: 990;
25
- `;function je(e){let{loading:t=!0,children:o,variant:a="primary",animation:i="border",wrap:s,...c}=e;return t?(o&&(o=n("p",{className:"mt-3 text-secondary",children:o})),o=r(ze,{inverted:!0,active:!0,children:[n(k,{animation:i,variant:a,...c}),o]}),s?n(Te,{$height:"number"==typeof s?s:150,children:o}):o):null}const Te=W.div`
26
- position: relative;
27
- height: ${e=>`${e.$height}px`};
28
- `,$e=f((async()=>{const{QRCodeSVG:e}=await import("qrcode.react");return{default:e}}));function He(e){return n(p,{fallback:null,children:n($e,{...e})})}const Be=function(e){let{state:t,message:r,resolve:o}=e;const i=a(!0),{result:c,checkUrl:l,onComplete:d}=r,[u,h]=Ne(!1);return s((()=>{ke({url:l,method:"post",data:{order_no:c.order_no},raxConfig:{shouldRetry:e=>i.current&&449===e.response?.status}}).then((()=>{d?.(),o()})).catch((()=>null))}),[]),n(ge,{...t,centered:!0,onHide:()=>{i.current=!1,t.onHide()},backdrop:"static",header:"支付结果",okText:"已完成支付",okButtonProps:{loading:u},onOk:async e=>{e.preventDefault();try{h(!0),await ke({url:l,method:"post",data:{order_no:c.order_no,force:!0},raxConfig:{shouldRetry:()=>!1}}),d?.(),o()}catch(e){ve(e)&&ye.error(e.message)}finally{h(!1)}},cancelText:"取消",children:"请在新打开的页面上进行支付,支付完成后再关闭此窗口"})},Ee=function(e){let{state:t,message:o,resolve:i}=e;const c=a(!0),{result:{pay_options:l,order_no:d},checkUrl:u,onComplete:h}=o,[m,f]=Ne(l.channels.alipay?"alipay":"wechat"),[p,g]=Ne(!1);s((()=>{ke({url:u,method:"post",data:{order_no:d},raxConfig:{shouldRetry:e=>c.current&&449===e.response?.status}}).then((()=>{h?.(),i()})).catch((()=>null))}),[]);const{loading:y,result:w}=Se({url:l.url,method:"POST",data:{channel:m,order_no:d}},{refreshDeps:[m]});return r(ge,{...t,onHide:()=>{c.current=!1,t.onHide()},centered:!0,backdrop:"static",header:"收银台",okText:"已完成支付",okButtonProps:{loading:p},onOk:async e=>{e.preventDefault();try{g(!0),await ke({url:u,method:"post",data:{order_no:d,force:{channel:m}},raxConfig:{shouldRetry:()=>!1}}),h?.(),i()}catch(e){ve(e)&&ye.error(e.message)}finally{g(!1)}},cancelText:"取消",children:[r("dl",{className:"row",children:[n("dt",{className:"col-3",children:"商品名称"}),n("dd",{className:"col-9",children:l.subject})]}),r("dl",{className:"row",children:[n("dt",{className:"col-3",children:"支付金额"}),n("dd",{className:"col-9 text-success h3",children:Ce(l.amount/100)})]}),r("dl",{className:"row",children:[n("dt",{className:"col-3",children:"支付方式"}),n("dd",{className:"col-9",children:r(S,{children:[l.channels.alipay&&n(z,{id:"payment-alipay",type:"radio",variant:"alipay"===m?"primary":"outline-primary",name:"alipay",value:"alipay",checked:"alipay"===m,onChange:()=>f("alipay"),children:"支付宝"}),l.channels.alipay&&n(z,{id:"payment-wechat",type:"radio",variant:"wechat"===m?"primary":"outline-primary",name:"wechat",value:"wechat",checked:"wechat"===m,onChange:()=>f("wechat"),children:"微信支付"})]})})]}),r("dl",{className:"row mb-0",children:[n("dt",{className:"col-3",children:"扫码支付"}),r("dd",{className:"col-9",children:[n(je,{loading:y,wrap:200}),w&&n(He,{size:200,value:w.data})]})]})]})};function Le(e){const{result:t}=e;t.pay_url?(window.opener=null,window.innerWidth<992?location.href=t.pay_url:(window.open(t.pay_url),ue(Be,e))):ue(Ee,e)}function _e(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2;const n=["","K","M","G"];let r=0;for(;e>=1024&&r<n.length-1;)e/=1024,r++;return e%1==0&&(t=0),e.toFixed(t)+n[r]}function De(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2;const n=["","K","M","G"];let r=0;for(;e>=1e3&&r<n.length-1;)e/=1e3,r++;return e%1==0&&(t=0),e.toFixed(t)+n[r]}function Re(e){const t=I.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 Me(e){const t=document.createElement("a");return t.href=e,t.href}K.locale("zh-cn"),K.extend(V);const Fe={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 Oe(e){let{className:t,status:o,title:a,icon:i,extra:s}=e;return!i&&o&&(i=Fe[o]),r(Ae,{className:t,children:[i&&n(Ue,{children:i}),a&&n(Ie,{children:a}),s&&n(qe,{children:s})]})}const Ae=W.div`
29
- padding: 48px 32px;
30
- `,Ue=W.div`
31
- margin-bottom: 24px;
32
- text-align: center;
33
- font-size: 72px;
34
- `,Ie=W.div`
35
- color: rgba(0, 0, 0, .85);
36
- font-size: 24px;
37
- line-height: 1.8;
38
- text-align: center;
39
- `,qe=W.div`
40
- margin-top: 32px;
41
- text-align: center;
42
- `;function We(e){let{children:t,title:a,className:i,...s}=e;return n(Ge,{className:Y("border-0 shadow-sm",i),...s,children:r("div",{className:"card-body",children:[a&&r(o,{children:[n("h5",{children:a}),n("hr",{})]}),t]})})}const Ge=W(P)`
43
- &:not(:last-child) {
44
- margin-bottom: 1rem;
45
- }
46
- `,Ke=c(void 0);function Ve(e){let{children:t}=e;const[r,o]=i(new Set),a=u((e=>{e&&"string"==typeof e&&(e=[e]),o(new Set(e))}),[o]);return n(Ke.Provider,{value:[r,o],children:n(j,{activeKey:Array.from(r),onSelect:a,alwaysOpen:!0,children:t})})}const Ye=()=>{const e=d(Ke);if(!e)throw new Error("usePanel must be used within a PanelGroup");return e};function Qe(e){let{title:t,action:a,children:i,eventKey:c,open:l}=e;if(c){const[,e]=Ye();s((()=>{void 0!==l&&e((e=>l?new Set([...e,c]):new Set([...e].filter((e=>e!==c)))))}),[l]),i=n(j.Collapse,{eventKey:c,children:r(o,{children:[n("hr",{}),i]})})}else i=r(o,{children:[n("hr",{}),i]});return r(We,{children:[r(T,{direction:"horizontal",children:[n("div",{className:"fs-5 me-auto",children:t}),a]}),i]})}function Je(e){let{errors:t}=e;return t?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 Xe(e){let{children:t,className:r,size:o="small",direction:a="horizontal"}=e;"string"==typeof o&&(o={small:8,middle:16,large:24}[o]);const i=g.map(t,(e=>{if(e)return n(et,{children:e})}));return n(Ze,{className:r,$direction:a,$size:o,children:i})}const Ze=W.div`
47
- display: inline-flex;
48
- align-items: center;
49
- gap: ${e=>e.$size}px;
50
-
51
- ${e=>"vertical"===e.$direction&&G`
52
- display: flex;
53
- flex-direction: column;
54
- align-items: inherit;
55
- `}
56
- `,et=W.div`
57
-
58
- `,tt=f((()=>import("./steps-b_BcYIwk.js"))),nt=f((()=>import("./steps-b_BcYIwk.js").then((e=>{let{Step:t}=e;return{default:t}}))));function rt(e){return n(p,{fallback:null,children:n(tt,{...e})})}const ot=function(e){return n(p,{fallback:null,children:n(nt,{...e})})};function at(e){let{title:t,content:o,footer:a}=e;return r(We,{children:[n(ct,{children:t}),n(st,{children:o}),a&&n(it,{children:a})]})}rt.Step=ot;const it=W.div`
59
- margin-top: 9px;
60
- padding-top: 10px;
61
- border-top: 1px solid #f0f0f0;
62
- color: rgba(0, 0, 0, .65);
63
- `,st=W.div`
64
- color: rgba(0, 0, 0, .85);
65
- font-size: 24px;
66
- `,ct=W.div`
67
- margin-bottom: 4px;
68
- color: rgba(0, 0, 0, .45);
69
- font-size: 1.1rem;
70
- `;function lt(){}function dt(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e}function ut(e){return"current_page"in e}function ht(e){let{total:t=0,onChange:r=lt,defaultCurrent:o=1,defaultPageSize:a=10,className:c,...l}=e;const[d,m]=i(o),[f,p]=i(a);s((()=>{dt(l.current)&&m(l.current)}),[l.current]),s((()=>{dt(l.pageSize)&&p(l.pageSize)}),[l.pageSize]);const g=h((()=>Math.floor((t-1)/f)+1),[t,f]),y=u((e=>()=>{e!==d&&(m(e),r(e,f))}),[r,d,f]),w=d-1>0?d-1:0,v=d+1<g?d+1:g,b=[];let x=null,k=null,N=null,C=null;if(g<=7)for(let e=1;e<=g;e+=1){const t=d===e;b.push(n(H.Item,{active:t,onClick:y(e),children:e},e))}else{C=n(H.Last,{onClick:y(g)},"last"),N=n(H.First,{onClick:y(1)},"first"),x=n(H.Prev,{onClick:y(w)},"prev"),k=n(H.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(H.Item,{active:e,onClick:y(r),children:r},r))}d-1>=4&&3!==d&&b.unshift(x),g-d>=4&&d!==g-2&&b.push(k),1!==e&&b.unshift(N),t!==g&&b.push(C)}return n(H,{className:c,children:b})}function mt(e){let{className:t,value:r,locale:a="zh-CN",currency:i=!0,options:s={}}=e;const c=h((()=>{let e;return e=i?{style:"currency",currency:"CNY"}:{minimumFractionDigits:2},new Intl.NumberFormat(a,{...e,...s})}),[i,a,s]);return t?n("span",{className:t,children:c.format(r)}):n(o,{children:c.format(r)})}function ft(e){let{loading:t,disabled:r,children:o,...a}=e;return n(N,{...a,disabled:t||r,children:t?"Loading…":o})}const pt=f((()=>import("./image-zoom-OrIPGqh0.js")));function gt(e){return n(p,{fallback:null,children:n(pt,{...e})})}const yt=m(((e,t)=>{let{confirm:n,onSuccess:r,children:o,disabled:a,as:i=fe,onError:s,...c}=e;const[l,d]=Ne(!1),h=u((async e=>{e.preventDefault(),e.stopPropagation();try{if(d(!0),n&&!await ge.confirm({message:n}))return;let e;if("onRequest"in c)e=await c.onRequest();else{const t="string"==typeof c.url?{url:c.url,method:c.method}:{method:c.method,...c.url};e=await ke(t)}r&&r(e)}catch(e){if(!(e instanceof Error))throw e;s?s(e):ye.error(e.message,{preventDuplicate:!0})}finally{d(!1)}}),[c,d]);return y(i,{...R(c,["onRequest","url","method"]),disabled:a||l,onClick:h,ref:t},o)})),wt=f((()=>import("./index-xM26Eo_f.js"))),vt=m(((e,t)=>n(p,{fallback:null,children:n(wt,{...e,ref:t})}))),bt=f((()=>import("./index-pdAII942.js"))),xt=m(((e,t)=>n(p,{fallback:null,children:n(bt,{...e,ref:t})})));let kt=0;function Nt(){let{onHide:e,onShow:t}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const[n,r]=i(!1),[o,a]=i(`visible-${kt}`),s=u((()=>{r(!1),e&&e()}),[r,e]),c=u((()=>{a("visible-"+ ++kt)}),[a,kt]);return{visible:n,show:u((()=>{r(!0),t&&t()}),[r,t]),hide:s,state:{show:n,onHide:s,onExited:c,key:o}}}const Ct=m(((e,t)=>{let{text:a,onOk:i,modalProps:s,children:c,onShow:l,onHide:d,confirmLoading:u,as:h=fe,...m}=e;const{state:f,show:p,hide:g}=Nt({onShow:l,onHide:d});w(t,(()=>({close:g})));const v=y(h,{...m,onClick:e=>{e.preventDefault(),e.stopPropagation(),p()}},a);return r(o,{children:[v,n(ge,{header:a,...s,...f,confirmLoading:u,onOk:async e=>{if(i){!1===await i()&&e.preventDefault()}},children:c})]})})),St=m(((e,t)=>{let{text:o,onSuccess:s,onSubmit:c,buttonProps:l,modalProps:d,children:h,...m}=e;const[f,p]=i(!1),g=a(null),y=a(null);w(t,(()=>({close:()=>{g.current?.close()}})));const v=u((()=>(y.current?.submit(),!1)),[]),b=u((e=>{s&&s(e),g.current?.close()}),[s]),x=u((async(e,t)=>{c&&await c(e,t)&&g.current?.close()}),[c]);return n(Ct,{ref:g,text:o,...l,modalProps:d,onOk:v,confirmLoading:f,children:r(vt,{...m,onSubmitting:p,ref:y,onSuccess:b,onSubmit:x,children:[h,n("input",{type:"submit",hidden:!0})]})})}));function zt(e){let{header:t,children:o,closable:a=!0,show:i,onHide:s,bodyAs:c,headerAs:l="h5",...d}=e;return r(B,{...d,onHide:s,show:i,children:[t&&n(B.Header,{closeButton:a,children:n(B.Title,{as:l,children:t})}),n(B.Body,{as:c,children:o})]})}const Pt=m(((e,t)=>{let{text:a,offcanvasProps:i,children:s,onShow:c,onHide:l,as:d=fe,...u}=e;const{state:h,show:m,hide:f}=Nt({onShow:c,onHide:l});w(t,(()=>({close:f})));const p=y(d,{...u,onClick:m},a);return r(o,{children:[p,n(zt,{header:a,...i,...h,children:s})]})}));function jt(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];const n=a(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,a=jt(r),s=jt(o),[c,l]=i(n),d=void 0!==t,u=d?t:c,h=jt((e=>{const t="function"==typeof e?e(u):e;s(u,t)&&(d||l(t),a(t))}),[d,a,u,s]);return[u,h]}const $t=m(((e,t)=>{let{className:o,rowClassName:c,paginate:l=!0,sync:d=!1,columns:h=3,source:m,renderItem:f,renderEmpty:p}=e;const[g,y]=i([]),[v,b]=i(l?{total:0,current:1,pageSize:10}:null),[x,k]=i(!0),[N,C]=Q({}),[S,z]=Tt({value:d?N.page||1:void 0,defaultValue:1,onChange:e=>{d&&C({page:e||void 0})}}),P=u((async function(){arguments.length>0&&void 0!==arguments[0]&&arguments[0]||k(!0);try{let e;const t={page:S>1?S:void 0};e="string"==typeof m?await ke({url:m,params:t}):await m(t),l&&ut(e)&&(e.last_page>1&&b({total:e.total,current:e.current_page,pageSize:e.per_page}),e=e.data),y(e)}catch(e){}finally{k(!1)}}),[m,y,S]);s((()=>{P()}),[S]),s((()=>{j.current={reload:P}}),[P]);const j=a({reload:P});return w(t,(()=>j.current)),r(Ht,{className:o,children:[n(je,{wrap:!0,loading:x}),0===g.length&&!x&&p?.(),n(E,{className:Y(c,"g-4"),children:g.map(((e,t)=>n(L,{className:"d-flex",md:12/h,children:f(e)},`card-${t}`)))}),v&&n(Bt,{...v,onChange:z})]})})),Ht=W.div`
71
-
72
- `,Bt=W(ht)`
73
- margin-bottom: 0;
74
- justify-content: flex-end;
75
- margin-top: 1rem;
76
- `;var Et=v($t);function Lt(){const[e,t]=i(!1),n=a();return s((()=>()=>{n.current&&clearTimeout(n.current)}),[]),{copied:e,copy:u((e=>{J(e),t(!0),n.current&&clearTimeout(n.current),n.current=setTimeout((()=>{t(!1),n.current=void 0}),3e3)}),[])}}function _t(e){let{as:t="div",className:r,content:o,tooltip:a=!0,placement:i}=e;const{copy:s,copied:c}=Lt(),l=a?n("i",c?{className:"bi bi-clipboard-check"}:{className:"bi bi-clipboard"}):c?"已复制":"复制",d=y(t,{role:"button",className:r,onClick:()=>{"function"==typeof o&&(o=o()),s(o)}},l);return a?n(he,{tooltip:c?"已复制":"复制",placement:i,children:d}):d}const Dt=c({images:new Map,current:0,setCurrent:()=>null,setShow:()=>null,registerImage:()=>()=>null,getId:()=>0}),Rt=f((()=>import("./index-7Eo6mqDi.js"))),Mt=f((()=>import("./image-TAFDJRLj.js")));function Ft(e){return n(p,{fallback:null,children:n(Rt,{...e})})}Ft.Image=function(e){return n(p,{fallback:null,children:n(Mt,{...e})})},Ft.Context=Dt;const Ot=f((()=>import("./infinite-scroller-5Z8JxvFT.js"))),At=m(((e,t)=>n(p,{fallback:null,children:n(Ot,{...e,ref:t})}))),Ut=f((()=>import("./slider-KuqHu6UH.js")));function It(e){return n(p,{fallback:null,children:n(Ut,{...e})})}function qt(e,t,n){const r=a(e),o=a(M(e,t,n));return s((()=>{r.current=e})),s((()=>{o.current=M((function(){r.current(...arguments)}),t,n)}),[t,n]),o.current}function Wt(e){const[t,n]=i((()=>X("function"==typeof e?e():e,!0)));return[t,u((e=>{n("function"==typeof e?Z(e):X(e))}),[])]}function Gt(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"lg";function t(){const t=e=>{switch(e){case"xxl":return window.innerWidth>=1400;case"xl":return window.innerWidth>=1200;case"lg":return window.innerWidth>=992;case"md":return window.innerWidth>=768;case"sm":return window.innerWidth>=576;default:return!0}};return{isMobile:!t(e),width:window.innerWidth,match:t}}const[n,r]=i(t),o=qt((()=>{r(t())}),100);return s((()=>(window.addEventListener("resize",o),()=>window.removeEventListener("resize",o))),[]),n}var Kt;!function(e){e[e.init=0]="init",e[e.play=1]="play",e[e.pause=2]="pause",e[e.end=3]="end"}(Kt||(Kt={}));const Vt=(e,t)=>{let n=a(!1);const[r,o]=i((()=>{const{lang:e="default",name:n=""}=t.voice||{};return{isPlaying:!1,status:Kt[Kt.init],lang:t.lang||"default",voiceInfo:{lang:e,name:n},rate:t.rate||1,pitch:t.pitch||1,volume:t.volume||1}})),c=u((()=>{n.current&&o((e=>({...e,isPlaying:!0,status:Kt[Kt.play]})))}),[]),l=u((()=>{n.current&&o((e=>({...e,isPlaying:!1,status:Kt[Kt.pause]})))}),[]),d=u((()=>{n.current&&o((e=>({...e,isPlaying:!1,status:Kt[Kt.end]})))}),[]);return s((()=>{n.current=!0;const r=new SpeechSynthesisUtterance(e);return t.lang&&(r.lang=t.lang),t.voice&&(r.voice=t.voice),r.rate=t.rate||1,r.pitch=t.pitch||1,r.volume=t.volume||1,r.onstart=c,r.onpause=l,r.onresume=c,r.onend=d,window.speechSynthesis.speak(r),()=>{n.current=!1}}),[]),r};function Yt(e,t){s((()=>{const t=e();!async function(){await t}()}),t)}export{Yt as $,Ct as A,fe as B,We as C,ge as D,Je as E,vt as F,zt as G,he as H,Dt as I,Et as J,_t as K,je as L,re as M,mt as N,Pt as O,ht as P,Ft as Q,Oe as R,Xe as S,me as T,At as U,It as V,He as W,Se as X,Nt as Y,Lt as Z,Vt as _,Gt as a,ve as a0,be as a1,Tt as b,Ne as c,Wt as d,ye as e,we as f,_e as g,Ce as h,ut as i,De as j,Re as k,Me as l,Qe as m,Ve as n,Ye as o,rt as p,ot as q,ke as r,at as s,ft as t,qt as u,gt as v,Le as w,yt as x,xt as y,St as z};
@@ -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{c as p,r as m,B as l}from"./index-rwu3sC2k.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"notistack";import"path";import"react-async-hook";import"styled-components";import"dayjs";import"dayjs/locale/zh-cn";import"dayjs/plugin/relativeTime";import"classnames";import"use-url-search-params";import"copy-to-clipboard";import"immer";import"react-intersection-observer";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})},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})}},h=e(((r,a)=>{let{action:e,method:u="post",onSuccess:f,formData:h,onSubmitting:w,onSubmit:g,onChange:v,submitText:b="保存",transformData:j,children:x,...D}=r;const[S,k]=n(),[q,z]=p(!1),[_,E]=n(h),F=i((async(t,o)=>{if(!q)try{if(z(!0),w&&w(!0),e){let{formData:o}=t;j&&(o=j(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{z(!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(l,{className:"px-4",loading:q,type:"submit",variant:"primary",children:b});return"function"==typeof x&&(x=x({submit:N,loading:q})),t(o,{ref:a,extraErrors:S,onSubmit:F,transformErrors:C,noHtml5Validate:!0,noValidate:!0,...D,formData:_,onChange:U,widgets:y,children:x||t("div",{className:"col-12",children:N})})}));export{h as default};
@@ -1 +0,0 @@
1
- import{jsx as t}from"react/jsx-runtime";import{memo as a,forwardRef as r,useState as e,useCallback as o,useImperativeHandle as i}from"react";import s from"react-infinite-scroller";import{d as n,r as m,i as p}from"./index-rwu3sC2k.js";import{last as d}from"lodash";import"sweetalert2/dist/sweetalert2.js";import"sweetalert2-react-content";import"react-bootstrap";import"axios";import"query-string";import"retry-axios";import"notistack";import"path";import"react-async-hook";import"styled-components";import"dayjs";import"dayjs/locale/zh-cn";import"dayjs/plugin/relativeTime";import"classnames";import"use-url-search-params";import"copy-to-clipboard";import"immer";import"react-intersection-observer";var c=a(r(((a,r)=>{let{source:c,render:l,as:u,useWindow:f,className:g,getState:y,limit:h=10}=a;const[w,j]=e(!1),[x,v]=n({params:{},end:!1,data:[]}),b=o((async function(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(!w){j(!0);try{let a;const r=t?{}:x.params;a="string"==typeof c?await m({url:c,params:r}):await c(r),y||(y=t=>p(t)?{params:{page:t.current_page+1},end:t.current_page>=t.last_page,data:t.data}:{params:{offset:d(t)?.id},end:t.length<h,data:t});const e=y(a);v({...e,data:t?e.data:[...x.data,...e.data]})}catch{v({...x,end:!0})}finally{j(!1)}}}),[c,x,y,w]),_=o((()=>{b(!0)}),[b]);i(r,(()=>({reload:_})),[_]);const k=o((t=>{v((a=>{const r=t(a.data);r&&(a.data=r)}))}),[v]);return t(s,{className:g,hasMore:!x.end,pageStart:0,loadMore:()=>{b()},useWindow:f,element:u,children:l({data:x.data,setData:k,end:x.end,loading:w,action:{reload:_}})})})));export{c as default};