@topthink/components 1.1.22 → 1.1.23
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/{image-tAsC3XQ0.js → image-qSKcFPGU.js} +1 -1
- package/es/{index-rVGQp32_.js → index-So7TiG4o.js} +1 -1
- package/es/index-kOIT3IUs.js +1 -0
- package/es/{index-nXQCmkOA.js → index-qqtWKONG.js} +1 -1
- package/es/{index-QdTiM3Oz.js → index-t5sPwmd8.js} +2 -2
- package/es/index.js +1 -1
- package/es/{infinite-scroller-XItH4cRS.js → infinite-scroller-_g5R4GSj.js} +1 -1
- package/package.json +3 -3
- package/types/components/lazy/form/index.d.ts +3 -1
- package/es/index-_Zcl8FIo.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as t,Fragment as r}from"react/jsx-runtime";import{memo as e,useContext as i,useState as o,useEffect as s}from"react";import{I as a}from"./index-
|
|
1
|
+
import{jsx as t,Fragment as r}from"react/jsx-runtime";import{memo as e,useContext as i,useState as o,useEffect as s}from"react";import{I as a}from"./index-t5sPwmd8.js";import{useInView as m}from"react-intersection-observer";import"sweetalert2/dist/sweetalert2.js";import"sweetalert2-react-content";import"react-bootstrap";import"lodash";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"dayjs/plugin/duration";import"classnames";import"use-url-search-params";import"copy-to-clipboard";import"goober";import"immer";var n=e((e=>{let{lazy:n=!0,...p}=e;const{registerImage:c,setShow:l,setCurrent:d,getId:h}=i(a),[g,u]=o(),[w,f]=o(!1),{ref:y,inView:v}=m({threshold:.2,skip:!n,initialInView:!0}),[j]=o(h);if(s((()=>{if(p.src)return c(j,p.src)}),[]),w)return t(r,{children:p.alt?`[图片加载失败:${p.alt}]`:" "});const x=!v&&n&&g?"data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='100%25' height='100%25'%3e %3crect width='1' height='1' fill='none'/%3e%3c/svg%3e":p.src;return t("img",{width:g?.[0],height:g?.[1],onLoad:t=>{g||u([t.currentTarget.clientWidth,t.currentTarget.clientHeight])},onError:()=>{f(!0)},ref:y,...p,alt:void 0,src:x,onClick:()=>{d(j),l(!0)}})}));export{n as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{jsx as e,jsxs as t,Fragment as r}from"react/jsx-runtime";import n from"rc-table";import{unstable_batchedUpdates as 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 m,useRef as u,useEffect as h,useMemo as f,memo as g,forwardRef as y,useImperativeHandle as v}from"react";import{B as b,u as x,P as w,a as j,b as C,r as k,i as S,N as E,L as z,T as O,C as V,S as N}from"./index-
|
|
1
|
+
import{jsx as e,jsxs as t,Fragment as r}from"react/jsx-runtime";import n from"rc-table";import{unstable_batchedUpdates as 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 m,useRef as u,useEffect as h,useMemo as f,memo as g,forwardRef as y,useImperativeHandle as v}from"react";import{B as b,u as x,P as w,a as j,b as C,r as k,i as S,N as E,L as z,T as O,C as V,S as N}from"./index-t5sPwmd8.js";import M from"styled-components";import H from"./index-kOIT3IUs.js";import q from"dayjs";import"sweetalert2/dist/sweetalert2.js";import"sweetalert2-react-content";import"axios";import"query-string";import"retry-axios";import"notistack";import"path";import"react-async-hook";import"dayjs/locale/zh-cn";import"dayjs/plugin/relativeTime";import"dayjs/plugin/duration";import"classnames";import"copy-to-clipboard";import"goober";import"immer";import"react-intersection-observer";import"@topthink/json-form";const K=function(t){let{indeterminate:r=!1,...n}=t;const o=u(null);return h((()=>{o.current&&(o.current.indeterminate=r)}),[r]),e("input",{ref:o,...n,className:"form-check-input",type:"checkbox"})};var B;function D(){return D=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},D.apply(this,arguments)}const P=e=>d.createElement("svg",D({xmlns:"http://www.w3.org/2000/svg",width:16,height:16,fill:"currentColor",viewBox:"0 0 1024 1024"},e),B||(B=d.createElement("path",{d:"M252.069 906.496h520.283c89.582 0 134.144-44.562 134.144-132.846V250.331c0-88.283-44.562-132.845-134.144-132.845H252.069c-89.143 0-134.583 44.141-134.583 132.845V773.67c0 88.704 45.44 132.845 134.583 132.845zm1.28-68.992c-42.844 0-66.853-22.71-66.853-67.291V253.806c0-44.58 24.01-67.292 66.853-67.292h517.723c42.423 0 66.432 22.711 66.432 67.292v516.388c0 44.58-24.01 67.292-66.432 67.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 T;function Y(){return Y=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},Y.apply(this,arguments)}const F=e=>d.createElement("svg",Y({xmlns:"http://www.w3.org/2000/svg",width:16,height:16,fill:"currentColor",viewBox:"0 0 1024 1024"},e),T||(T=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 I(r){let{data:n,options:o,columns:a,onSearch:i}=r;const[c,s]=p(0),[d,u]=p(n);h((()=>{l(n,d)||(u(n),s((e=>e+1)))}),[n]);const[g,y,v]=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=m((e=>{let{formData:t}=e;u(t),i({...v,...t})}),[i,v]),w=m((()=>{i(v)}),[i,v]);return e(R,{children:e(H,{formContext:{layout:"horizontal"},schema:g,uiSchema:y,onSubmit:x,formData:d,children:e("div",{className:"col-12 col-md-2 ms-auto mt-md-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 R=M.div`
|
|
2
2
|
margin-bottom: 1rem;
|
|
3
3
|
`;function _(t){let{keyword:r,onKeywordChange:n}=t;const[o,i]=p(r),c=x(n,500);h((()=>{i(r)}),[r]);const l=m((e=>{i(e.target.value),c(e.target.value)}),[c,i]);return e(a,{value:o,onChange:l,type:"search",placeholder:"Search..."})}const A=M.thead`
|
|
4
4
|
th {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as t}from"react/jsx-runtime";import o,{getRegistry as r}from"@topthink/json-form";import*as a from"react";import{forwardRef as e,useState as i,useCallback as n}from"react";import s from"axios";import{c as p,r as l,B as m}from"./index-t5sPwmd8.js";import{mapValues as d}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"dayjs/plugin/duration";import"classnames";import"use-url-search-params";import"copy-to-clipboard";import"goober";import"immer";import"react-intersection-observer";const c=require("ajv-i18n/localize/zh"),u=a.lazy((()=>import("./editor-widget-ZqrBTAWC.js"))),f=o=>t(a.Suspense,{fallback:null,children:t(u,{...o})}),y={upload:function(o){let{options:a,...e}=o;const{widgets:i}=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(i.upload,{...e,options:a})},avatar:function(o){let{options:a,...e}=o;const{widgets:i}=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(i.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:i}=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(i.typeahead,{...e,options:a})}},h=e(((r,a)=>{let{action:e,method:u="post",onSuccess:f,formData:h,onSubmitting:w,onSubmit:b,onChange:g,submitText:v="保存",transformData:j,children:x,validate:D,disabled:S,...k}=r;const[q,z]=i(),[_,E]=p(!1),[F,U]=i(h),C=n((async(t,o)=>{if(!_)try{if(E(!0),w&&w(!0),e){let{formData:o}=t;j&&(o=j(o));try{const t=await l({url:e,method:u,data:o});return z(void 0),f&&await f(t),t}catch(t){if(!s.isAxiosError(t))throw t;z((t=>{const o=t.errors;return"string"==typeof o?{__errors:[o]}:d(o,(t=>({__errors:[t]})))})(t))}}else if(b)return await b(t,o)}finally{E(!1),w&&w(!1)}}),[e,u,b]),N=n((t=>{const{formData:o}=t;U(o),g&&g(t)}),[U,g]),T=n((t=>(t=t.map((t=>({keyword:t.name,dataPath:t.property,...t}))),c(t),t)),[]),V=t(m,{className:"px-4",disabled:S,loading:_,type:"submit",variant:"primary",children:v});"function"==typeof x&&(x=x({submit:V,loading:_,disabled:S}));const A=!D;return!0===D&&(D=void 0),t(o,{ref:a,extraErrors:q,onSubmit:C,transformErrors:T,noHtml5Validate:!0,noValidate:A,validate:D,disabled:S,...k,formData:F,onChange:N,widgets:y,children:x||t("div",{className:"col-12",children:V})})}));export{h as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{jsxs as t,jsx as r}from"react/jsx-runtime";import{useState as o,useCallback as e}from"react";import i,{useController as n,useLightboxState as a}from"yet-another-react-lightbox";import s from"yet-another-react-lightbox/plugins/counter";import l from"yet-another-react-lightbox/plugins/download";import m from"yet-another-react-lightbox/plugins/zoom";import p from"yet-another-react-lightbox/plugins/thumbnails";import"yet-another-react-lightbox/styles.css";import"yet-another-react-lightbox/plugins/counter.css";import"yet-another-react-lightbox/plugins/thumbnails.css";import{I as c}from"./index-
|
|
1
|
+
import{jsxs as t,jsx as r}from"react/jsx-runtime";import{useState as o,useCallback as e}from"react";import i,{useController as n,useLightboxState as a}from"yet-another-react-lightbox";import s from"yet-another-react-lightbox/plugins/counter";import l from"yet-another-react-lightbox/plugins/download";import m from"yet-another-react-lightbox/plugins/zoom";import p from"yet-another-react-lightbox/plugins/thumbnails";import"yet-another-react-lightbox/styles.css";import"yet-another-react-lightbox/plugins/counter.css";import"yet-another-react-lightbox/plugins/thumbnails.css";import{I as c}from"./index-t5sPwmd8.js";import u from"styled-components";import"sweetalert2/dist/sweetalert2.js";import"sweetalert2-react-content";import"react-bootstrap";import"lodash";import"axios";import"query-string";import"retry-axios";import"notistack";import"path";import"react-async-hook";import"dayjs";import"dayjs/locale/zh-cn";import"dayjs/plugin/relativeTime";import"dayjs/plugin/duration";import"classnames";import"use-url-search-params";import"copy-to-clipboard";import"goober";import"immer";import"react-intersection-observer";const d={counter:s,zoom:m,download:l,thumbnails:p};let g=0;function h(i){let{children:s,render:l,zoom:m,toolbar:p,plugins:u=["counter","zoom","download"]}=i;const[h,y]=o((()=>new Map)),[x,f]=o(),[w,_]=o(!1),j=e(((t,r)=>(y((o=>new Map(o).set(t,r))),()=>{y((r=>{const o=new Map(r);return o.delete(t)?o:r}))})),[]),k=Array.from(h.keys()),v=k.indexOf(x),z=k.map((t=>{const r=h.get(t);return"string"==typeof r?{src:r}:{render:r}})),C=e((()=>g++),[]);return t(c.Provider,{value:{images:h,current:x,setCurrent:f,setShow:_,registerImage:j,getId:C},children:[s,r(b,{plugins:u.map((t=>d[t])),open:w,index:v,close:()=>_(!1),slides:z,carousel:{finite:!0,preload:3},toolbar:p?.({useController:n,useLightboxState:a}),zoom:m,render:{...l,buttonPrev:z.length<=1?()=>null:void 0,buttonNext:z.length<=1?()=>null:void 0,slide:t=>{let{slide:r}=t;if("render"in r)return r.render()}},controller:{closeOnBackdropClick:!0}})]})}const b=u(i)`
|
|
2
2
|
--yarl__color_backdrop: rgba(0, 0, 0, .7);
|
|
3
3
|
--yarl__thumbnails_container_background_color: rgba(0, 0, 0, .9);
|
|
4
4
|
`;export{h as default};
|
|
@@ -67,12 +67,12 @@ import e from"sweetalert2/dist/sweetalert2.js";import t from"sweetalert2-react-c
|
|
|
67
67
|
margin-bottom: 4px;
|
|
68
68
|
color: rgba(0, 0, 0, .45);
|
|
69
69
|
font-size: 1.1rem;
|
|
70
|
-
`;function mt(){}function ft(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e}function pt(e){return"current_page"in e}function gt(e){let{total:t=0,onChange:o=mt,defaultCurrent:a=1,defaultPageSize:c=10,className:l,...d}=e;const[m,f]=i(a),[p,g]=i(c);s((()=>{ft(d.current)&&f(d.current)}),[d.current]),s((()=>{ft(d.pageSize)&&g(d.pageSize)}),[d.pageSize]);const y=h((()=>Math.floor((t-1)/p)+1),[t,p]),w=u((e=>()=>{e!==m&&(f(e),o(e,p))}),[o,m,p]),v=m-1>0?m-1:0,b=m+1<y?m+1:y,x=[];let k=null,N=null,C=null,S=null;if(y<=7)for(let e=1;e<=y;e+=1){const t=m===e;x.push(n(H.Item,{active:t,onClick:w(e),children:e},e))}else{S=n(H.Last,{onClick:w(y)},"last"),C=n(H.First,{onClick:w(1)},"first"),k=n(H.Prev,{onClick:w(v)},"prev"),N=n(H.Next,{onClick:w(b)},"next");let e=Math.max(1,m-2),t=Math.min(m+2,y);m-1<=2&&(t=5),y-m<=2&&(e=y-4);for(let r=e;r<=t;r+=1){const e=m===r;x.push(n(H.Item,{active:e,onClick:w(r),children:r},r))}m-1>=4&&3!==m&&x.unshift(k),y-m>=4&&m!==y-2&&x.push(N),1!==e&&x.unshift(C),t!==y&&x.push(S)}return r("div",{className:X("mb-3 d-flex align-column-center justify-content-between",l),children:[r("div",{className:"d-flex align-items-center",children:["共 ",t," 条"]}),n(H,{className:"mb-0",children:x})]})}function yt(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 wt(e){let{loading:t,disabled:r,children:o,...a}=e;return n(N,{...a,disabled:t||r,children:t?"Loading…":o})}const vt=f((()=>import("./image-zoom-OrIPGqh0.js")));function bt(e){return n(p,{fallback:null,children:n(vt,{...e})})}const xt=m(((e,t)=>{let{confirm:n,onSuccess:r,children:o,disabled:a,as:i=we,onError:s,...c}=e;const[l,d]=ze(!1),h=u((async e=>{e.preventDefault(),e.stopPropagation();try{if(d(!0),n&&!await be.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 je(t)}r&&r(e)}catch(e){if(!(e instanceof Error))throw e;s?s(e):xe.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)})),kt=f((()=>import("./index-
|
|
70
|
+
`;function mt(){}function ft(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e}function pt(e){return"current_page"in e}function gt(e){let{total:t=0,onChange:o=mt,defaultCurrent:a=1,defaultPageSize:c=10,className:l,...d}=e;const[m,f]=i(a),[p,g]=i(c);s((()=>{ft(d.current)&&f(d.current)}),[d.current]),s((()=>{ft(d.pageSize)&&g(d.pageSize)}),[d.pageSize]);const y=h((()=>Math.floor((t-1)/p)+1),[t,p]),w=u((e=>()=>{e!==m&&(f(e),o(e,p))}),[o,m,p]),v=m-1>0?m-1:0,b=m+1<y?m+1:y,x=[];let k=null,N=null,C=null,S=null;if(y<=7)for(let e=1;e<=y;e+=1){const t=m===e;x.push(n(H.Item,{active:t,onClick:w(e),children:e},e))}else{S=n(H.Last,{onClick:w(y)},"last"),C=n(H.First,{onClick:w(1)},"first"),k=n(H.Prev,{onClick:w(v)},"prev"),N=n(H.Next,{onClick:w(b)},"next");let e=Math.max(1,m-2),t=Math.min(m+2,y);m-1<=2&&(t=5),y-m<=2&&(e=y-4);for(let r=e;r<=t;r+=1){const e=m===r;x.push(n(H.Item,{active:e,onClick:w(r),children:r},r))}m-1>=4&&3!==m&&x.unshift(k),y-m>=4&&m!==y-2&&x.push(N),1!==e&&x.unshift(C),t!==y&&x.push(S)}return r("div",{className:X("mb-3 d-flex align-column-center justify-content-between",l),children:[r("div",{className:"d-flex align-items-center",children:["共 ",t," 条"]}),n(H,{className:"mb-0",children:x})]})}function yt(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 wt(e){let{loading:t,disabled:r,children:o,...a}=e;return n(N,{...a,disabled:t||r,children:t?"Loading…":o})}const vt=f((()=>import("./image-zoom-OrIPGqh0.js")));function bt(e){return n(p,{fallback:null,children:n(vt,{...e})})}const xt=m(((e,t)=>{let{confirm:n,onSuccess:r,children:o,disabled:a,as:i=we,onError:s,...c}=e;const[l,d]=ze(!1),h=u((async e=>{e.preventDefault(),e.stopPropagation();try{if(d(!0),n&&!await be.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 je(t)}r&&r(e)}catch(e){if(!(e instanceof Error))throw e;s?s(e):xe.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)})),kt=f((()=>import("./index-kOIT3IUs.js"))),Nt=m(((e,t)=>n(p,{fallback:null,children:n(kt,{...e,ref:t})}))),Ct=f((()=>import("./index-So7TiG4o.js"))),St=m(((e,t)=>n(p,{fallback:null,children:n(Ct,{...e,ref:t})})));let jt=0;function zt(){let{onHide:e,onShow:t}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const[n,r]=i(!1),[o,a]=i(`visible-${jt}`),s=u((()=>{r(!1),e&&e()}),[r,e]),c=u((()=>{a("visible-"+ ++jt)}),[a,jt]);return{visible:n,show:u((()=>{r(!0),t&&t()}),[r,t]),hide:s,state:{show:n,onHide:s,onExited:c,key:o}}}const Pt=m(((e,t)=>{let{text:a,onOk:i,modalProps:s,children:c,onShow:l,onHide:d,confirmLoading:u,as:h=we,...m}=e;const{state:f,show:p,hide:g}=zt({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(be,{header:a,...s,...f,confirmLoading:u,onOk:async e=>{if(i){!1===await i()&&e.preventDefault()}},children:c})]})})),Tt=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((async()=>(y.current?.submit().catch((()=>{})),!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(Pt,{ref:g,text:o,...l,modalProps:d,onOk:v,confirmLoading:f,children:r(Nt,{...m,onSubmitting:p,ref:y,onSuccess:b,onSubmit:x,children:[h,n("input",{type:"submit",hidden:!0})]})})}));function $t(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 Ht=m(((e,t)=>{let{text:a,offcanvasProps:i,children:s,onShow:c,onHide:l,as:d=we,...u}=e;const{state:h,show:m,hide:f}=zt({onShow:c,onHide:l});w(t,(()=>({close:f})));const p=y(d,{...u,onClick:m},a);return r(o,{children:[p,n($t,{header:a,...i,...h,children:s})]})}));function Bt(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 Et(e){const{value:t,defaultValue:n,onChange:r,shouldUpdate:o=((e,t)=>e!==t)}=e,a=Bt(r),s=Bt(o),[c,l]=i(n),d=void 0!==t,u=d?t:c,h=Bt((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 Lt=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]=Z({}),[S,j]=Et({value:d?N.page||1:void 0,defaultValue:1,onChange:e=>{d&&C({page:e||void 0})}}),z=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 je({url:m,params:t}):await m(t),l&&pt(e)?(e.last_page>1?b({total:e.total,current:e.current_page,pageSize:e.per_page}):b(null),e=e.data):b(null),y(e)}catch(e){}finally{k(!1)}}),[m,y,S]);s((()=>{z()}),[S]),s((()=>{P.current={reload:z}}),[z]);const P=a({reload:z});return w(t,(()=>P.current)),r(_t,{className:o,children:[n(Be,{wrap:!0,loading:x}),0===g.length&&!x&&p?.(),n(E,{className:X(c,"g-4"),children:g.map(((e,t)=>n(L,{className:"d-flex",md:12/h,children:f(e)},`card-${t}`)))}),v&&n(Dt,{...v,onChange:j})]})})),_t=G.div`
|
|
71
71
|
|
|
72
72
|
`,Dt=G(gt)`
|
|
73
73
|
margin-bottom: 0;
|
|
74
74
|
justify-content: flex-end;
|
|
75
75
|
margin-top: 1rem;
|
|
76
|
-
`;var Rt=v(Lt);function Mt(){const[e,t]=i(!1),n=a();return s((()=>()=>{n.current&&clearTimeout(n.current)}),[]),{copied:e,copy:u((e=>{ee(e),t(!0),n.current&&clearTimeout(n.current),n.current=setTimeout((()=>{t(!1),n.current=void 0}),3e3)}),[])}}function Ft(e){let{as:t="div",className:r,content:o,tooltip:a=!0,placement:i}=e;const{copy:s,copied:c}=Mt(),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(ge,{tooltip:c?"已复制":"复制",placement:i,children:d}):d}const Ot=c({images:new Map,current:0,setCurrent:()=>null,setShow:()=>null,registerImage:()=>()=>null,getId:()=>0}),At=f((()=>import("./index-
|
|
76
|
+
`;var Rt=v(Lt);function Mt(){const[e,t]=i(!1),n=a();return s((()=>()=>{n.current&&clearTimeout(n.current)}),[]),{copied:e,copy:u((e=>{ee(e),t(!0),n.current&&clearTimeout(n.current),n.current=setTimeout((()=>{t(!1),n.current=void 0}),3e3)}),[])}}function Ft(e){let{as:t="div",className:r,content:o,tooltip:a=!0,placement:i}=e;const{copy:s,copied:c}=Mt(),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(ge,{tooltip:c?"已复制":"复制",placement:i,children:d}):d}const Ot=c({images:new Map,current:0,setCurrent:()=>null,setShow:()=>null,registerImage:()=>()=>null,getId:()=>0}),At=f((()=>import("./index-qqtWKONG.js"))),Ut=f((()=>import("./image-qSKcFPGU.js")));function It(e){return n(p,{fallback:null,children:n(At,{...e})})}It.Image=function(e){return n(p,{fallback:null,children:n(Ut,{...e})})},It.Context=Ot;const qt=f((()=>import("./infinite-scroller-_g5R4GSj.js"))),Wt=m(((e,t)=>n(p,{fallback:null,children:n(qt,{...e,ref:t})}))),Gt=f((()=>import("./slider-KuqHu6UH.js")));function Kt(e){return n(p,{fallback:null,children:n(Gt,{...e})})}function Vt(e){let{children:t}=e;return r(I,{children:[n(Yt,{}),t]})}const Yt=V`
|
|
77
77
|
${te.extractCss()}
|
|
78
78
|
`,Qt=f((()=>import("./cascader-pKgfaE9t.js")));function Jt(e){return n(p,{fallback:null,children:n(Qt,{...e})})}const Xt=f((()=>import("./select-WnBtupzS.js")));function Zt(e){return n(p,{fallback:null,children:n(Xt,{...e})})}function en(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 tn(e){const[t,n]=i((()=>ne("function"==typeof e?e():e,!0)));return[t,u((e=>{n("function"==typeof e?re(e):ne(e))}),[])]}function nn(){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=en((()=>{r(t())}),100);return s((()=>(window.addEventListener("resize",o),()=>window.removeEventListener("resize",o))),[]),n}var rn;!function(e){e[e.init=0]="init",e[e.play=1]="play",e[e.pause=2]="pause",e[e.end=3]="end"}(rn||(rn={}));const on=(e,t)=>{let n=a(!1);const[r,o]=i((()=>{const{lang:e="default",name:n=""}=t.voice||{};return{isPlaying:!1,status:rn[rn.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:rn[rn.play]})))}),[]),l=u((()=>{n.current&&o((e=>({...e,isPlaying:!1,status:rn[rn.pause]})))}),[]),d=u((()=>{n.current&&o((e=>({...e,isPlaying:!1,status:rn[rn.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 an(e,t){s((()=>{const t=e();!async function(){await t}()}),t)}export{zt as $,Pt as A,we as B,Ye as C,be as D,tt as E,Nt as F,$t as G,ge as H,Ot as I,Rt as J,Ft as K,Be as L,se as M,yt as N,Ht as O,gt as P,It as Q,qe as R,nt as S,ye as T,Wt as U,Kt as V,_e as W,Vt as X,Jt as Y,Zt as Z,Te as _,nn as a,Mt as a0,on as a1,an as a2,Ne as a3,Ce as a4,Et as b,ze as c,tn as d,xe as e,ke as f,Fe as g,Pe as h,pt as i,Oe as j,Ae as k,Ue as l,et as m,Xe as n,Ze as o,st as p,ct as q,je as r,lt as s,wt as t,en as u,bt as v,Me as w,xt as x,St as y,Tt as z};
|
package/es/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{B as Button,C as Card,J as CardList,Y as Cascader,K as Clipboard,E as Error,F as Form,v as ImageZoom,U as InfiniteScroller,Q as Lightbox,L as Loader,t as LoadingButton,M as Message,D as Modal,A as ModalButton,z as ModalForm,N as NumberFormat,G as Offcanvas,O as OffcanvasButton,P as Pagination,m as Panel,n as PanelGroup,W as Qrcode,x as RequestButton,R as Result,Z as Select,V as Slider,S as Space,s as Statistic,q as Step,p as Steps,y as Table,e as Toast,X as ToastProvider,H as Tooltip,j as formatLongNumber,h as formatNumber,g as formatSize,l as getAbsoluteUrl,k as isImageUrl,f as isRecord,a3 as isRequestError,r as request,a4 as showRequestError,a2 as useAsyncEffect,a0 as useClipboard,b as useControllableState,u as useDebounce,d as useImmer,$ as useOverlayState,o as usePanel,_ as useRequest,c as useSafeState,a1 as useSpeech,a as useWindowSize,w as waitPayComplete}from"./index-
|
|
1
|
+
export{B as Button,C as Card,J as CardList,Y as Cascader,K as Clipboard,E as Error,F as Form,v as ImageZoom,U as InfiniteScroller,Q as Lightbox,L as Loader,t as LoadingButton,M as Message,D as Modal,A as ModalButton,z as ModalForm,N as NumberFormat,G as Offcanvas,O as OffcanvasButton,P as Pagination,m as Panel,n as PanelGroup,W as Qrcode,x as RequestButton,R as Result,Z as Select,V as Slider,S as Space,s as Statistic,q as Step,p as Steps,y as Table,e as Toast,X as ToastProvider,H as Tooltip,j as formatLongNumber,h as formatNumber,g as formatSize,l as getAbsoluteUrl,k as isImageUrl,f as isRecord,a3 as isRequestError,r as request,a4 as showRequestError,a2 as useAsyncEffect,a0 as useClipboard,b as useControllableState,u as useDebounce,d as useImmer,$ as useOverlayState,o as usePanel,_ as useRequest,c as useSafeState,a1 as useSpeech,a as useWindowSize,w as waitPayComplete}from"./index-t5sPwmd8.js";export{StyleSheetManager,ThemeProvider,createGlobalStyle,css,keyframes,default as styled}from"styled-components";export{useAsync,useAsyncCallback}from"react-async-hook";export{useInView}from"react-intersection-observer";export{default as queryString}from"query-string";export{freeze,immerable,produce}from"immer";export{default as dayjs}from"dayjs";import"sweetalert2/dist/sweetalert2.js";import"sweetalert2-react-content";import"react/jsx-runtime";import"react";import"react-bootstrap";import"lodash";import"axios";import"retry-axios";import"notistack";import"path";import"dayjs/locale/zh-cn";import"dayjs/plugin/relativeTime";import"dayjs/plugin/duration";import"classnames";import"use-url-search-params";import"copy-to-clipboard";import"goober";
|
|
@@ -1 +1 @@
|
|
|
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-
|
|
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-t5sPwmd8.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"dayjs/plugin/duration";import"classnames";import"use-url-search-params";import"copy-to-clipboard";import"goober";import"immer";import"react-intersection-observer";var c=a(r(((a,r)=>{let{source:c,render:l,as:u,useWindow:g,className:f,getState:y,limit:h=10}=a;const[j,w]=e(!1),[x,b]=n({params:{},end:!1,data:[]}),v=o((async function(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(!j){w(!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);b({...e,data:t?e.data:[...x.data,...e.data]})}catch{b({...x,end:!0})}finally{w(!1)}}}),[c,x,y,j]),_=o((()=>{v(!0)}),[v]);i(r,(()=>({reload:_})),[_]);const k=o((t=>{b((a=>{const r=t(a.data);r&&(a.data=r)}))}),[b]);return t(s,{className:f,hasMore:!x.end,pageStart:0,loadMore:()=>{v()},useWindow:g,element:u,children:l({data:x.data,setData:k,end:x.end,loading:j,action:{reload:_}})})})));export{c as default};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@topthink/components",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.23",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"prebuild": "rimraf es types",
|
|
6
6
|
"build": "rollup -c --environment NODE_ENV:production",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"@toast-ui/editor": "^3.2.2",
|
|
21
21
|
"@toast-ui/react-editor": "^3.2.3",
|
|
22
22
|
"@topthink/bootstrap": "^1.0.27",
|
|
23
|
-
"@topthink/json-form": "^1.0.
|
|
23
|
+
"@topthink/json-form": "^1.0.67",
|
|
24
24
|
"@types/react-infinite-scroller": "^1.2.5",
|
|
25
25
|
"ajv-i18n": "^4.0.0",
|
|
26
26
|
"axios": "^0.27.2",
|
|
@@ -75,5 +75,5 @@
|
|
|
75
75
|
},
|
|
76
76
|
"author": "yunwuxin <tzzhangyajun@qq.com> (https://github.com/yunwuxin)",
|
|
77
77
|
"license": "MIT",
|
|
78
|
-
"gitHead": "
|
|
78
|
+
"gitHead": "a3b55b29586394f73a1a16982d2f1c13901d5061"
|
|
79
79
|
}
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import { JsonFormProps, JsonFormType } from '@topthink/json-form';
|
|
2
2
|
import { ForwardRefExoticComponent, PropsWithoutRef, ReactNode, RefAttributes } from 'react';
|
|
3
3
|
import { Method } from 'axios';
|
|
4
|
-
export interface FormProps<T = any> extends JsonFormProps<T> {
|
|
4
|
+
export interface FormProps<T = any> extends Omit<JsonFormProps<T>, 'validate'> {
|
|
5
5
|
onSuccess?: (data: any) => void;
|
|
6
6
|
method?: Method;
|
|
7
7
|
children?: ReactNode | ((props: {
|
|
8
8
|
submit: ReactNode;
|
|
9
9
|
loading: boolean;
|
|
10
|
+
disabled?: boolean;
|
|
10
11
|
}) => ReactNode);
|
|
11
12
|
submitText?: string;
|
|
12
13
|
onSubmitting?: (submitting: boolean) => void;
|
|
13
14
|
transformData?: (data: T) => T;
|
|
15
|
+
validate?: JsonFormProps<T>['validate'] | true;
|
|
14
16
|
}
|
|
15
17
|
export interface FormType extends JsonFormType {
|
|
16
18
|
}
|
package/es/index-_Zcl8FIo.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{c as p,r as m,B as l}from"./index-QdTiM3Oz.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"dayjs/plugin/duration";import"classnames";import"use-url-search-params";import"copy-to-clipboard";import"goober";import"immer";import"react-intersection-observer";const d=require("ajv-i18n/localize/zh"),u=a.lazy((()=>import("./editor-widget-ZqrBTAWC.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,validate:D,...S}=r;const[k,q]=n(),[z,_]=p(!1),[E,F]=n(h),U=i((async(t,o)=>{if(!z)try{if(_(!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 q(void 0),f&&await f(t),t}catch(t){if(!s.isAxiosError(t))throw t;q((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]),C=i((t=>{const{formData:o}=t;F(o),v&&v(t)}),[F,v]),N=i((t=>(t=t.map((t=>({keyword:t.name,dataPath:t.property,...t}))),d(t),t)),[]),T=t(l,{className:"px-4",loading:z,type:"submit",variant:"primary",children:b});return"function"==typeof x&&(x=x({submit:T,loading:z})),t(o,{ref:a,extraErrors:k,onSubmit:U,transformErrors:N,noHtml5Validate:!0,noValidate:!D,validate:D,...S,formData:E,onChange:C,widgets:y,children:x||t("div",{className:"col-12",children:T})})}));export{h as default};
|