@tachybase/plugin-action-export 1.3.21 → 1.3.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- (function(i,t){typeof exports=="object"&&typeof module!="undefined"?t(exports,require("@tachybase/client"),require("react/jsx-runtime"),require("react"),require("@tachybase/components"),require("@tachybase/schema"),require("react-i18next"),require("antd"),require("lodash")):typeof define=="function"&&define.amd?define(["exports","@tachybase/client","react/jsx-runtime","react","@tachybase/components","@tachybase/schema","react-i18next","antd","lodash"],t):(i=typeof globalThis!="undefined"?globalThis:i||self,t(i["@tachybase/plugin-action-export"]={},i["@tachybase/client"],i.jsxRuntime,i.react,i["@tachybase/components"],i["@tachybase/schema"],i["react-i18next"],i.antd,i.lodash))})(this,function(i,t,m,A,j,S,I,P,w){"use strict";var te=Object.defineProperty,oe=Object.defineProperties;var ne=Object.getOwnPropertyDescriptors;var J=Object.getOwnPropertySymbols;var re=Object.prototype.hasOwnProperty,ae=Object.prototype.propertyIsEnumerable;var W=(i,t,m)=>t in i?te(i,t,{enumerable:!0,configurable:!0,writable:!0,value:m}):i[t]=m,O=(i,t)=>{for(var m in t||(t={}))re.call(t,m)&&W(i,m,t[m]);if(J)for(var m of J(t))ae.call(t,m)&&W(i,m,t[m]);return i},V=(i,t)=>oe(i,ne(t));var k=(i,t,m)=>new Promise((A,j)=>{var S=w=>{try{P(m.next(w))}catch(F){j(F)}},I=w=>{try{P(m.throw(w))}catch(F){j(F)}},P=w=>w.done?A(w.value):Promise.resolve(w.value).then(S,I);P((m=m.apply(i,t)).next())});const F=r=>m.jsx(t.SchemaComponentOptions,{components:{ExportActionInitializer:q,ExportDesigner:z},scope:{useExportAction:N},children:r.children}),B=r=>{var c;const e=S.useFieldSchema();(c=e==null?void 0:e["x-component-props"])!=null&&c.nonfilterable;const{getCollectionFields:s}=t.useCollectionManager_deprecated(),d=s(r),f=(p,x)=>{var n;if(!p.interface)return;const o={name:p.name,title:((n=p==null?void 0:p.uiSchema)==null?void 0:n.title)||p.name,schema:p==null?void 0:p.uiSchema};if(!p.target||x>=3)return o;if(p.target){const l=s(p.target),a=h(l,x+1).filter(Boolean);o.children=o.children||[],o.children.push(...a)}return o},h=(p,x)=>{const o=[];return p.forEach(n=>{const l=f(n,x);l&&o.push(l)}),o};return h(d,1)},R=()=>{const{name:r}=t.useCollection_deprecated(),e=B(r);return{schema:{type:"void","x-component":"Grid",properties:{exportSettings:{type:"array","x-component":"ArrayItems","x-decorator":"FormItem",items:{type:"object",properties:{space:{type:"void","x-component":"Space","x-component-props":{className:t.css`
1
+ (function(i,t){typeof exports=="object"&&typeof module!="undefined"?t(exports,require("@tachybase/client"),require("react/jsx-runtime"),require("react"),require("@tachybase/schema"),require("@tego/client"),require("react-i18next"),require("antd"),require("lodash")):typeof define=="function"&&define.amd?define(["exports","@tachybase/client","react/jsx-runtime","react","@tachybase/schema","@tego/client","react-i18next","antd","lodash"],t):(i=typeof globalThis!="undefined"?globalThis:i||self,t(i["@tachybase/plugin-action-export"]={},i["@tachybase/client"],i.jsxRuntime,i.react,i["@tachybase/schema"],i["@tego/client"],i["react-i18next"],i.antd,i.lodash))})(this,function(i,t,m,A,b,P,I,j,w){"use strict";var te=Object.defineProperty,oe=Object.defineProperties;var ne=Object.getOwnPropertyDescriptors;var J=Object.getOwnPropertySymbols;var re=Object.prototype.hasOwnProperty,ae=Object.prototype.propertyIsEnumerable;var W=(i,t,m)=>t in i?te(i,t,{enumerable:!0,configurable:!0,writable:!0,value:m}):i[t]=m,O=(i,t)=>{for(var m in t||(t={}))re.call(t,m)&&W(i,m,t[m]);if(J)for(var m of J(t))ae.call(t,m)&&W(i,m,t[m]);return i},V=(i,t)=>oe(i,ne(t));var k=(i,t,m)=>new Promise((A,b)=>{var P=w=>{try{j(m.next(w))}catch(F){b(F)}},I=w=>{try{j(m.throw(w))}catch(F){b(F)}},j=w=>w.done?A(w.value):Promise.resolve(w.value).then(P,I);j((m=m.apply(i,t)).next())});const F=r=>m.jsx(t.SchemaComponentOptions,{components:{ExportActionInitializer:q,ExportDesigner:z},scope:{useExportAction:N},children:r.children}),B=r=>{var c;const e=b.useFieldSchema();(c=e==null?void 0:e["x-component-props"])!=null&&c.nonfilterable;const{getCollectionFields:s}=t.useCollectionManager_deprecated(),d=s(r),f=(p,x)=>{var n;if(!p.interface)return;const o={name:p.name,title:((n=p==null?void 0:p.uiSchema)==null?void 0:n.title)||p.name,schema:p==null?void 0:p.uiSchema};if(!p.target||x>=3)return o;if(p.target){const l=s(p.target),a=h(l,x+1).filter(Boolean);o.children=o.children||[],o.children.push(...a)}return o},h=(p,x)=>{const o=[];return p.forEach(n=>{const l=f(n,x);l&&o.push(l)}),o};return h(d,1)},R=()=>{const{name:r}=t.useCollection_deprecated(),e=B(r);return{schema:{type:"void","x-component":"Grid",properties:{exportSettings:{type:"array","x-component":"ArrayItems","x-decorator":"FormItem",items:{type:"object",properties:{space:{type:"void","x-component":"Space","x-component-props":{className:t.css`
2
2
  width: 100%;
3
3
  & .ant-space-item:nth-child(2),
4
4
  & .ant-space-item:nth-child(3) {
@@ -11,4 +11,4 @@
11
11
  border-color: var(--colorSettings);
12
12
  color: var(--colorSettings);
13
13
  }
14
- `}}}}}}}},X=new t.SchemaSettings({name:"actionSettings:export",items:[{name:"editButton",Component:t.ButtonEditor,useComponentProps(){const{buttonEditorProps:r}=t.useSchemaToolbar();return r}},{name:"exportableFields",type:"actionModal",useComponentProps(){var p,x;const r=S.useField(),e=S.useFieldSchema(),{t:s}=I.useTranslation(),{dn:d}=t.useDesignable(),[f,h]=A.useState(),{schema:c}=R();return A.useEffect(()=>{h(c)},[r.address,(p=e==null?void 0:e["x-action-settings"])==null?void 0:p.exportSettings]),{title:s("Exportable fields"),schema:f,initialValues:{exportSettings:(x=e==null?void 0:e["x-action-settings"])==null?void 0:x.exportSettings},components:{ArrayItems:j.ArrayItems},onSubmit:({exportSettings:o})=>{e["x-action-settings"].exportSettings=o==null?void 0:o.filter(n=>{var l;return(l=n==null?void 0:n.dataIndex)==null?void 0:l.length}).map(n=>({dataIndex:n.dataIndex.map(l=>{var a;return(a=l.name)!=null?a:l}),title:n.title})),d.emit("patch",{schema:{"x-uid":e["x-uid"],"x-action-settings":e["x-action-settings"]}}),d.refresh()}}}},{name:"divider",type:"divider"},{name:"delete",type:"remove",useComponentProps(){const{t:r}=I.useTranslation();return{removeParentsIfNoChildren:!0,breakRemoveOn:e=>e["x-component"]==="Space"||e["x-component"].endsWith("ActionBar"),confirm:{title:r("Delete action")}}}}]}),L=(r,e,s)=>r.reduceProperties((d,f)=>{if(f[e]===s)return f;const h=L(f,e,s);return h||d}),K=(r,e)=>e(r),_=(r,e,s=L,d=K)=>{const f=S.useFieldSchema(),{remove:h}=t.useDesignable(),c=s(f,e,r);return{schema:c,exists:!!c,remove(){c&&d(c,h)}}},Y=r=>r==null?void 0:r.filter(s=>!s.children).map(s=>({dataIndex:[s.name]})),q=()=>{const r=t.useSchemaInitializerItem(),{insert:e}=t.useSchemaInitializer(),{exists:s,remove:d}=_("export","x-action",r.find,r.remove),{name:f}=t.useCollection_deprecated(),h=B(f),c={type:"void",title:'{{ t("Export") }}',"x-action":"export","x-action-settings":{exportSettings:[]},"x-toolbar":"ActionSchemaToolbar","x-settings":"actionSettings:export","x-decorator":"ACLActionProvider","x-component":"Action","x-use-component-props":"useExportAction","x-component-props":{icon:"clouddownloadoutlined"}};return m.jsx(t.SchemaInitializerSwitch,V(O({},r),{checked:s,title:r.title,onClick:()=>{var x;if(s)return d();c["x-action-settings"].exportSettings=Y(h);const p=S.merge(c||{},r.schema||{});(x=r==null?void 0:r.schemaInitialize)==null||x.call(r,p),e(p)}}))},z=()=>{var p,x,o,n,l;const r=S.useField(),e=S.useFieldSchema(),{t:s}=I.useTranslation(),{dn:d}=t.useDesignable(),[f,h]=A.useState(),{schema:c}=R();return A.useEffect(()=>{h(c)},[r.address,(p=e==null?void 0:e["x-action-settings"])==null?void 0:p.exportSettings]),m.jsxs(t.GeneralSchemaDesigner,{disableInitializer:!0,children:[m.jsx(t.SchemaSettingsModalItem,{title:s("Edit button"),schema:{type:"object",title:s("Edit button"),properties:{title:{"x-decorator":"FormItem","x-component":"Input",title:s("Button title"),default:e.title,"x-component-props":{}},icon:{"x-decorator":"FormItem","x-component":"IconPicker",title:s("Button icon"),default:(x=e==null?void 0:e["x-component-props"])==null?void 0:x.icon,"x-component-props":{}},type:{"x-decorator":"FormItem","x-component":"Radio.Group",title:s("Button background color"),default:(o=e==null?void 0:e["x-component-props"])!=null&&o.danger?"danger":((n=e==null?void 0:e["x-component-props"])==null?void 0:n.type)==="primary"?"primary":"default",enum:[{value:"default",label:'{{t("Default")}}'},{value:"primary",label:'{{t("Highlight")}}'},{value:"danger",label:'{{t("Danger red")}}'}]}}},onSubmit:({title:a,icon:u,type:v})=>{e.title=a,r.title=a,r.componentProps.icon=u,r.componentProps.danger=v==="danger",r.componentProps.type=v,e["x-component-props"]=e["x-component-props"]||{},e["x-component-props"].icon=u,e["x-component-props"].danger=v==="danger",e["x-component-props"].type=v,d.emit("patch",{schema:{"x-uid":e["x-uid"],title:a,"x-component-props":O({},e["x-component-props"])}}),d.refresh()}}),m.jsx(t.SchemaSettingsActionModalItem,{title:s("Exportable fields"),schema:f,initialValues:{exportSettings:(l=e==null?void 0:e["x-action-settings"])==null?void 0:l.exportSettings},components:{ArrayItems:j.ArrayItems},onSubmit:({exportSettings:a})=>{e["x-action-settings"].exportSettings=a==null?void 0:a.filter(u=>{var v;return(v=u==null?void 0:u.dataIndex)==null?void 0:v.length}).map(u=>({dataIndex:u.dataIndex.map(v=>{var E;return(E=v.name)!=null?E:v}),title:u.title})),d.emit("patch",{schema:{"x-uid":e["x-uid"],"x-action-settings":e["x-action-settings"]}}),d.refresh()}}),m.jsx(t.SchemaSettingsDivider,{}),m.jsx(t.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:a=>a["x-component"]==="Space"||a["x-component"].endsWith("ActionBar"),confirm:{title:s("Delete action")}})]})};var T=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{},M={exports:{}},Q=M.exports,U;function Z(){return U||(U=1,function(r,e){(function(s,d){d()})(Q,function(){function s(o,n){return typeof n=="undefined"?n={autoBom:!1}:typeof n!="object"&&(console.warn("Deprecated: Expected third argument to be a object"),n={autoBom:!n}),n.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(o.type)?new Blob(["\uFEFF",o],{type:o.type}):o}function d(o,n,l){var a=new XMLHttpRequest;a.open("GET",o),a.responseType="blob",a.onload=function(){x(a.response,n,l)},a.onerror=function(){console.error("could not download file")},a.send()}function f(o){var n=new XMLHttpRequest;n.open("HEAD",o,!1);try{n.send()}catch(l){}return 200<=n.status&&299>=n.status}function h(o){try{o.dispatchEvent(new MouseEvent("click"))}catch(l){var n=document.createEvent("MouseEvents");n.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),o.dispatchEvent(n)}}var c=typeof window=="object"&&window.window===window?window:typeof self=="object"&&self.self===self?self:typeof T=="object"&&T.global===T?T:void 0,p=c.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),x=c.saveAs||(typeof window!="object"||window!==c?function(){}:"download"in HTMLAnchorElement.prototype&&!p?function(o,n,l){var a=c.URL||c.webkitURL,u=document.createElement("a");n=n||o.name||"download",u.download=n,u.rel="noopener",typeof o=="string"?(u.href=o,u.origin===location.origin?h(u):f(u.href)?d(o,n,l):h(u,u.target="_blank")):(u.href=a.createObjectURL(o),setTimeout(function(){a.revokeObjectURL(u.href)},4e4),setTimeout(function(){h(u)},0))}:"msSaveOrOpenBlob"in navigator?function(o,n,l){if(n=n||o.name||"download",typeof o!="string")navigator.msSaveOrOpenBlob(s(o,l),n);else if(f(o))d(o,n,l);else{var a=document.createElement("a");a.href=o,a.target="_blank",setTimeout(function(){h(a)})}}:function(o,n,l,a){if(a=a||open("","_blank"),a&&(a.document.title=a.document.body.innerText="downloading..."),typeof o=="string")return d(o,n,l);var u=o.type==="application/octet-stream",v=/constructor/i.test(c.HTMLElement)||c.safari,E=/CriOS\/[\d]+/.test(navigator.userAgent);if((E||u&&v||p)&&typeof FileReader!="undefined"){var C=new FileReader;C.onloadend=function(){var b=C.result;b=E?b:b.replace(/^data:[^;]*;/,"data:attachment/file;"),a?a.location.href=b:location=b,a=null},C.readAsDataURL(o)}else{var y=c.URL||c.webkitURL,g=y.createObjectURL(o);a?a.location=g:location.href=g,a=null,setTimeout(function(){y.revokeObjectURL(g)},4e4)}});c.saveAs=x.saveAs=x,r.exports=x})}(M)),M.exports}var ee=Z();const N=()=>{const{service:r,resource:e}=t.useBlockRequestContext();t.useAPIClient();const s=S.useFieldSchema(),d=t.useCompile(),{getCollectionJoinField:f}=t.useCollectionManager_deprecated(),{name:h,title:c,getField:p}=t.useCollection_deprecated(),{t:x}=I.useTranslation();return{onClick(){return k(this,null,function*(){var a,u,v,E,C;const{exportSettings:n}=w.cloneDeep((a=s==null?void 0:s["x-action-settings"])!=null?a:{});n.forEach(y=>{var D,H;const{uiSchema:g,interface:b}=(D=f(`${h}.${y.dataIndex.join(".")}`))!=null?D:{};y.enum=(H=g==null?void 0:g.enum)==null?void 0:H.map(G=>({value:G.value,label:G.label})),!y.enum&&(g==null?void 0:g.type)==="boolean"&&(y.enum=[{value:!0,label:x("Yes")},{value:!1,label:x("No")}]),y.defaultTitle=g==null?void 0:g.title,b==="chinaRegion"&&y.dataIndex.push("name")});const l=P.message.loading(x("Exporting Data..."),0);try{const y=yield e.export({title:d(c),appends:(v=(u=r.params[0])==null?void 0:u.appends)==null?void 0:v.join(),filter:JSON.stringify((E=r.params[0])==null?void 0:E.filter),sort:(C=r.params[0])==null?void 0:C.sort},{method:"post",data:{columns:d(n)},responseType:"blob"}),{data:g}=y;if(g.type==="application/json"){const b=yield g.text(),{data:{filename:D}}=JSON.parse(b);window.location.href=D}else{const b=new Blob([g],{type:"application/x-xls"});ee.saveAs(b,`${d(c)}.xlsx`)}l()}catch(y){console.error(y),l()}})}}};class $ extends t.Plugin{load(){return k(this,null,function*(){this.app.use(F);const e={title:"{{t('Export')}}",Component:"ExportActionInitializer",schema:{"x-align":"right","x-decorator":"ACLActionProvider","x-acl-action-props":{skipScopeCheck:!0}}},s=this.app.schemaInitializerManager.get("table:configureActions");s==null||s.add("enableActions.export",e),this.app.schemaInitializerManager.addItem("gantt:configureActions","enableActions.export",e),this.app.schemaSettingsManager.add(X)})}}i.ExportActionInitializer=q,i.ExportDesigner=z,i.ExportPlugin=$,i.ExportPluginProvider=F,i.default=$,i.useCurrentSchema=_,i.useExportAction=N,Object.defineProperties(i,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
14
+ `}}}}}}}},X=new t.SchemaSettings({name:"actionSettings:export",items:[{name:"editButton",Component:t.ButtonEditor,useComponentProps(){const{buttonEditorProps:r}=t.useSchemaToolbar();return r}},{name:"exportableFields",type:"actionModal",useComponentProps(){var p,x;const r=b.useField(),e=b.useFieldSchema(),{t:s}=I.useTranslation(),{dn:d}=t.useDesignable(),[f,h]=A.useState(),{schema:c}=R();return A.useEffect(()=>{h(c)},[r.address,(p=e==null?void 0:e["x-action-settings"])==null?void 0:p.exportSettings]),{title:s("Exportable fields"),schema:f,initialValues:{exportSettings:(x=e==null?void 0:e["x-action-settings"])==null?void 0:x.exportSettings},components:{ArrayItems:P.ArrayItems},onSubmit:({exportSettings:o})=>{e["x-action-settings"].exportSettings=o==null?void 0:o.filter(n=>{var l;return(l=n==null?void 0:n.dataIndex)==null?void 0:l.length}).map(n=>({dataIndex:n.dataIndex.map(l=>{var a;return(a=l.name)!=null?a:l}),title:n.title})),d.emit("patch",{schema:{"x-uid":e["x-uid"],"x-action-settings":e["x-action-settings"]}}),d.refresh()}}}},{name:"divider",type:"divider"},{name:"delete",type:"remove",useComponentProps(){const{t:r}=I.useTranslation();return{removeParentsIfNoChildren:!0,breakRemoveOn:e=>e["x-component"]==="Space"||e["x-component"].endsWith("ActionBar"),confirm:{title:r("Delete action")}}}}]}),L=(r,e,s)=>r.reduceProperties((d,f)=>{if(f[e]===s)return f;const h=L(f,e,s);return h||d}),K=(r,e)=>e(r),_=(r,e,s=L,d=K)=>{const f=b.useFieldSchema(),{remove:h}=t.useDesignable(),c=s(f,e,r);return{schema:c,exists:!!c,remove(){c&&d(c,h)}}},Y=r=>r==null?void 0:r.filter(s=>!s.children).map(s=>({dataIndex:[s.name]})),q=()=>{const r=t.useSchemaInitializerItem(),{insert:e}=t.useSchemaInitializer(),{exists:s,remove:d}=_("export","x-action",r.find,r.remove),{name:f}=t.useCollection_deprecated(),h=B(f),c={type:"void",title:'{{ t("Export") }}',"x-action":"export","x-action-settings":{exportSettings:[]},"x-toolbar":"ActionSchemaToolbar","x-settings":"actionSettings:export","x-decorator":"ACLActionProvider","x-component":"Action","x-use-component-props":"useExportAction","x-component-props":{icon:"clouddownloadoutlined"}};return m.jsx(t.SchemaInitializerSwitch,V(O({},r),{checked:s,title:r.title,onClick:()=>{var x;if(s)return d();c["x-action-settings"].exportSettings=Y(h);const p=b.merge(c||{},r.schema||{});(x=r==null?void 0:r.schemaInitialize)==null||x.call(r,p),e(p)}}))},z=()=>{var p,x,o,n,l;const r=b.useField(),e=b.useFieldSchema(),{t:s}=I.useTranslation(),{dn:d}=t.useDesignable(),[f,h]=A.useState(),{schema:c}=R();return A.useEffect(()=>{h(c)},[r.address,(p=e==null?void 0:e["x-action-settings"])==null?void 0:p.exportSettings]),m.jsxs(t.GeneralSchemaDesigner,{disableInitializer:!0,children:[m.jsx(t.SchemaSettingsModalItem,{title:s("Edit button"),schema:{type:"object",title:s("Edit button"),properties:{title:{"x-decorator":"FormItem","x-component":"Input",title:s("Button title"),default:e.title,"x-component-props":{}},icon:{"x-decorator":"FormItem","x-component":"IconPicker",title:s("Button icon"),default:(x=e==null?void 0:e["x-component-props"])==null?void 0:x.icon,"x-component-props":{}},type:{"x-decorator":"FormItem","x-component":"Radio.Group",title:s("Button background color"),default:(o=e==null?void 0:e["x-component-props"])!=null&&o.danger?"danger":((n=e==null?void 0:e["x-component-props"])==null?void 0:n.type)==="primary"?"primary":"default",enum:[{value:"default",label:'{{t("Default")}}'},{value:"primary",label:'{{t("Highlight")}}'},{value:"danger",label:'{{t("Danger red")}}'}]}}},onSubmit:({title:a,icon:u,type:v})=>{e.title=a,r.title=a,r.componentProps.icon=u,r.componentProps.danger=v==="danger",r.componentProps.type=v,e["x-component-props"]=e["x-component-props"]||{},e["x-component-props"].icon=u,e["x-component-props"].danger=v==="danger",e["x-component-props"].type=v,d.emit("patch",{schema:{"x-uid":e["x-uid"],title:a,"x-component-props":O({},e["x-component-props"])}}),d.refresh()}}),m.jsx(t.SchemaSettingsActionModalItem,{title:s("Exportable fields"),schema:f,initialValues:{exportSettings:(l=e==null?void 0:e["x-action-settings"])==null?void 0:l.exportSettings},components:{ArrayItems:P.ArrayItems},onSubmit:({exportSettings:a})=>{e["x-action-settings"].exportSettings=a==null?void 0:a.filter(u=>{var v;return(v=u==null?void 0:u.dataIndex)==null?void 0:v.length}).map(u=>({dataIndex:u.dataIndex.map(v=>{var E;return(E=v.name)!=null?E:v}),title:u.title})),d.emit("patch",{schema:{"x-uid":e["x-uid"],"x-action-settings":e["x-action-settings"]}}),d.refresh()}}),m.jsx(t.SchemaSettingsDivider,{}),m.jsx(t.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:a=>a["x-component"]==="Space"||a["x-component"].endsWith("ActionBar"),confirm:{title:s("Delete action")}})]})};var T=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{},M={exports:{}},Q=M.exports,U;function Z(){return U||(U=1,function(r,e){(function(s,d){d()})(Q,function(){function s(o,n){return typeof n=="undefined"?n={autoBom:!1}:typeof n!="object"&&(console.warn("Deprecated: Expected third argument to be a object"),n={autoBom:!n}),n.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(o.type)?new Blob(["\uFEFF",o],{type:o.type}):o}function d(o,n,l){var a=new XMLHttpRequest;a.open("GET",o),a.responseType="blob",a.onload=function(){x(a.response,n,l)},a.onerror=function(){console.error("could not download file")},a.send()}function f(o){var n=new XMLHttpRequest;n.open("HEAD",o,!1);try{n.send()}catch(l){}return 200<=n.status&&299>=n.status}function h(o){try{o.dispatchEvent(new MouseEvent("click"))}catch(l){var n=document.createEvent("MouseEvents");n.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),o.dispatchEvent(n)}}var c=typeof window=="object"&&window.window===window?window:typeof self=="object"&&self.self===self?self:typeof T=="object"&&T.global===T?T:void 0,p=c.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),x=c.saveAs||(typeof window!="object"||window!==c?function(){}:"download"in HTMLAnchorElement.prototype&&!p?function(o,n,l){var a=c.URL||c.webkitURL,u=document.createElement("a");n=n||o.name||"download",u.download=n,u.rel="noopener",typeof o=="string"?(u.href=o,u.origin===location.origin?h(u):f(u.href)?d(o,n,l):h(u,u.target="_blank")):(u.href=a.createObjectURL(o),setTimeout(function(){a.revokeObjectURL(u.href)},4e4),setTimeout(function(){h(u)},0))}:"msSaveOrOpenBlob"in navigator?function(o,n,l){if(n=n||o.name||"download",typeof o!="string")navigator.msSaveOrOpenBlob(s(o,l),n);else if(f(o))d(o,n,l);else{var a=document.createElement("a");a.href=o,a.target="_blank",setTimeout(function(){h(a)})}}:function(o,n,l,a){if(a=a||open("","_blank"),a&&(a.document.title=a.document.body.innerText="downloading..."),typeof o=="string")return d(o,n,l);var u=o.type==="application/octet-stream",v=/constructor/i.test(c.HTMLElement)||c.safari,E=/CriOS\/[\d]+/.test(navigator.userAgent);if((E||u&&v||p)&&typeof FileReader!="undefined"){var C=new FileReader;C.onloadend=function(){var S=C.result;S=E?S:S.replace(/^data:[^;]*;/,"data:attachment/file;"),a?a.location.href=S:location=S,a=null},C.readAsDataURL(o)}else{var y=c.URL||c.webkitURL,g=y.createObjectURL(o);a?a.location=g:location.href=g,a=null,setTimeout(function(){y.revokeObjectURL(g)},4e4)}});c.saveAs=x.saveAs=x,r.exports=x})}(M)),M.exports}var ee=Z();const N=()=>{const{service:r,resource:e}=t.useBlockRequestContext();t.useAPIClient();const s=b.useFieldSchema(),d=t.useCompile(),{getCollectionJoinField:f}=t.useCollectionManager_deprecated(),{name:h,title:c,getField:p}=t.useCollection_deprecated(),{t:x}=I.useTranslation();return{onClick(){return k(this,null,function*(){var a,u,v,E,C;const{exportSettings:n}=w.cloneDeep((a=s==null?void 0:s["x-action-settings"])!=null?a:{});n.forEach(y=>{var D,$;const{uiSchema:g,interface:S}=(D=f(`${h}.${y.dataIndex.join(".")}`))!=null?D:{};y.enum=($=g==null?void 0:g.enum)==null?void 0:$.map(G=>({value:G.value,label:G.label})),!y.enum&&(g==null?void 0:g.type)==="boolean"&&(y.enum=[{value:!0,label:x("Yes")},{value:!1,label:x("No")}]),y.defaultTitle=g==null?void 0:g.title,S==="chinaRegion"&&y.dataIndex.push("name")});const l=j.message.loading(x("Exporting Data..."),0);try{const y=yield e.export({title:d(c),appends:(v=(u=r.params[0])==null?void 0:u.appends)==null?void 0:v.join(),filter:JSON.stringify((E=r.params[0])==null?void 0:E.filter),sort:(C=r.params[0])==null?void 0:C.sort},{method:"post",data:{columns:d(n)},responseType:"blob"}),{data:g}=y;if(g.type==="application/json"){const S=yield g.text(),{data:{filename:D}}=JSON.parse(S);window.location.href=D}else{const S=new Blob([g],{type:"application/x-xls"});ee.saveAs(S,`${d(c)}.xlsx`)}l()}catch(y){console.error(y),l()}})}}};class H extends t.Plugin{load(){return k(this,null,function*(){this.app.use(F);const e={title:"{{t('Export')}}",Component:"ExportActionInitializer",schema:{"x-align":"right","x-decorator":"ACLActionProvider","x-acl-action-props":{skipScopeCheck:!0}}},s=this.app.schemaInitializerManager.get("table:configureActions");s==null||s.add("enableActions.export",e),this.app.schemaInitializerManager.addItem("gantt:configureActions","enableActions.export",e),this.app.schemaSettingsManager.add(X)})}}i.ExportActionInitializer=q,i.ExportDesigner=z,i.ExportPlugin=H,i.ExportPluginProvider=F,i.default=H,i.useCurrentSchema=_,i.useExportAction=N,Object.defineProperties(i,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
@@ -1,13 +1,10 @@
1
1
  module.exports = {
2
2
  "react": "18.3.1",
3
- "@tachybase/client": "1.3.21",
4
- "@tachybase/schema": "1.3.21",
5
- "@tachybase/components": "1.3.21",
3
+ "@tachybase/client": "1.3.22",
4
+ "@tachybase/schema": "1.3.39",
5
+ "@tego/client": "1.3.39",
6
6
  "react-i18next": "15.2.0",
7
7
  "antd": "5.22.5",
8
8
  "lodash": "4.17.21",
9
- "@tachybase/database": "1.3.21",
10
- "@tachybase/server": "1.3.21",
11
- "@tachybase/utils": "1.3.21",
12
- "@tachybase/actions": "1.3.21"
9
+ "@tego/server": "1.3.39"
13
10
  };
@@ -10,9 +10,9 @@ case `uname` in
10
10
  esac
11
11
 
12
12
  if [ -z "$NODE_PATH" ]; then
13
- export NODE_PATH="/home/runner/work/tego/tego/node_modules/.pnpm/xlsx@https+++cdn.sheetjs.com+xlsx-0.20.2+xlsx-0.20.2.tgz/node_modules/xlsx/bin/node_modules:/home/runner/work/tego/tego/node_modules/.pnpm/xlsx@https+++cdn.sheetjs.com+xlsx-0.20.2+xlsx-0.20.2.tgz/node_modules/xlsx/node_modules:/home/runner/work/tego/tego/node_modules/.pnpm/xlsx@https+++cdn.sheetjs.com+xlsx-0.20.2+xlsx-0.20.2.tgz/node_modules:/home/runner/work/tego/tego/node_modules/.pnpm/node_modules"
13
+ export NODE_PATH="/home/runner/work/tego-standard/tego-standard/node_modules/.pnpm/xlsx@https+++cdn.sheetjs.com+xlsx-0.20.2+xlsx-0.20.2.tgz/node_modules/xlsx/bin/node_modules:/home/runner/work/tego-standard/tego-standard/node_modules/.pnpm/xlsx@https+++cdn.sheetjs.com+xlsx-0.20.2+xlsx-0.20.2.tgz/node_modules/xlsx/node_modules:/home/runner/work/tego-standard/tego-standard/node_modules/.pnpm/xlsx@https+++cdn.sheetjs.com+xlsx-0.20.2+xlsx-0.20.2.tgz/node_modules:/home/runner/work/tego-standard/tego-standard/node_modules/.pnpm/node_modules"
14
14
  else
15
- export NODE_PATH="/home/runner/work/tego/tego/node_modules/.pnpm/xlsx@https+++cdn.sheetjs.com+xlsx-0.20.2+xlsx-0.20.2.tgz/node_modules/xlsx/bin/node_modules:/home/runner/work/tego/tego/node_modules/.pnpm/xlsx@https+++cdn.sheetjs.com+xlsx-0.20.2+xlsx-0.20.2.tgz/node_modules/xlsx/node_modules:/home/runner/work/tego/tego/node_modules/.pnpm/xlsx@https+++cdn.sheetjs.com+xlsx-0.20.2+xlsx-0.20.2.tgz/node_modules:/home/runner/work/tego/tego/node_modules/.pnpm/node_modules:$NODE_PATH"
15
+ export NODE_PATH="/home/runner/work/tego-standard/tego-standard/node_modules/.pnpm/xlsx@https+++cdn.sheetjs.com+xlsx-0.20.2+xlsx-0.20.2.tgz/node_modules/xlsx/bin/node_modules:/home/runner/work/tego-standard/tego-standard/node_modules/.pnpm/xlsx@https+++cdn.sheetjs.com+xlsx-0.20.2+xlsx-0.20.2.tgz/node_modules/xlsx/node_modules:/home/runner/work/tego-standard/tego-standard/node_modules/.pnpm/xlsx@https+++cdn.sheetjs.com+xlsx-0.20.2+xlsx-0.20.2.tgz/node_modules:/home/runner/work/tego-standard/tego-standard/node_modules/.pnpm/node_modules:$NODE_PATH"
16
16
  fi
17
17
  if [ -x "$basedir/node" ]; then
18
18
  exec "$basedir/node" "$basedir/../../../../../xlsx@https+++cdn.sheetjs.com+xlsx-0.20.2+xlsx-0.20.2.tgz/node_modules/xlsx/bin/xlsx.njs" "$@"
@@ -1 +1 @@
1
- {"name":"node-xlsx","author":"Olivier Louvignes <olivier@mg-crea.com>","version":"0.24.0","description":"NodeJS Excel files parser & builder","type":"module","main":"./dist/index.cjs","exports":{".":{"require":"./dist/index.cjs","import":"./dist/index.js","types":"./dist/index.d.ts"}},"bin":{"node-xlsx":"./dist/bin/cli.js"},"files":["dist"],"scripts":{"start":"npm run spec -- --watch","build":"tsup --entry src/index.ts --format cjs,esm --sourcemap --dts --clean --entry src/bin/cli.ts","lint":"eslint src/ test/","prettycheck":"prettier --check src/ test/","prettify":"prettier --write src/ test/","typecheck":"tsc --noEmit","spec":"DEBUG=node-xlsx* vitest --run","watch":"DEBUG=node-xlsx* vitest --watch","test":"npm run lint && npm run prettycheck && npm run typecheck && npm run spec","prepublishOnly":"npm run build"},"repository":"github:mgcrea/node-xlsx","license":"Apache-2.0","dependencies":{"xlsx":"https://cdn.sheetjs.com/xlsx-0.20.2/xlsx-0.20.2.tgz"},"devDependencies":{"@mgcrea/eslint-config-node":"^0.10.0","@tsconfig/node-lts":"^20.1.1","@types/node":"^20.12.7","eslint":"^8.57.0","prettier":"^3.2.5","prettier-plugin-organize-imports":"^3.2.4","tsup":"^8.0.2","typescript":"^5.4.5","vite-tsconfig-paths":"^4.3.2","vitest":"^1.5.0"},"engines":{"node":">=10.0.0"},"keywords":["excel","parser","builder","xlsx","xls"],"_lastModified":"2025-07-25T05:49:27.550Z"}
1
+ {"name":"node-xlsx","author":"Olivier Louvignes <olivier@mg-crea.com>","version":"0.24.0","description":"NodeJS Excel files parser & builder","type":"module","main":"./dist/index.cjs","exports":{".":{"require":"./dist/index.cjs","import":"./dist/index.js","types":"./dist/index.d.ts"}},"bin":{"node-xlsx":"./dist/bin/cli.js"},"files":["dist"],"scripts":{"start":"npm run spec -- --watch","build":"tsup --entry src/index.ts --format cjs,esm --sourcemap --dts --clean --entry src/bin/cli.ts","lint":"eslint src/ test/","prettycheck":"prettier --check src/ test/","prettify":"prettier --write src/ test/","typecheck":"tsc --noEmit","spec":"DEBUG=node-xlsx* vitest --run","watch":"DEBUG=node-xlsx* vitest --watch","test":"npm run lint && npm run prettycheck && npm run typecheck && npm run spec","prepublishOnly":"npm run build"},"repository":"github:mgcrea/node-xlsx","license":"Apache-2.0","dependencies":{"xlsx":"https://cdn.sheetjs.com/xlsx-0.20.2/xlsx-0.20.2.tgz"},"devDependencies":{"@mgcrea/eslint-config-node":"^0.10.0","@tsconfig/node-lts":"^20.1.1","@types/node":"^20.12.7","eslint":"^8.57.0","prettier":"^3.2.5","prettier-plugin-organize-imports":"^3.2.4","tsup":"^8.0.2","typescript":"^5.4.5","vite-tsconfig-paths":"^4.3.2","vitest":"^1.5.0"},"engines":{"node":">=10.0.0"},"keywords":["excel","parser","builder","xlsx","xls"],"_lastModified":"2025-07-29T06:16:06.819Z"}
@@ -1,2 +1,2 @@
1
- import { Context, Next } from '@tachybase/actions';
1
+ import { Context, Next } from '@tego/server';
2
2
  export declare function exportXlsx(ctx: Context, next: Next): Promise<any>;
@@ -30,12 +30,12 @@ __export(export_xlsx_exports, {
30
30
  exportXlsx: () => exportXlsx
31
31
  });
32
32
  module.exports = __toCommonJS(export_xlsx_exports);
33
- var import_utils = require("@tachybase/utils");
33
+ var import_server = require("@tego/server");
34
34
  var import_node_xlsx = __toESM(require("node-xlsx"));
35
35
  var import__ = __toESM(require(".."));
36
36
  var import_constants = require("../constants");
37
37
  var import_renders = __toESM(require("../renders"));
38
- var import_utils2 = require("../utils");
38
+ var import_utils = require("../utils");
39
39
  async function exportXlsx(ctx, next) {
40
40
  var _a, _b, _c;
41
41
  const { title, filter, sort, fields, except } = ctx.action.params;
@@ -50,7 +50,7 @@ async function exportXlsx(ctx, next) {
50
50
  var _a2;
51
51
  return collection.hasField(col.dataIndex[0]) && ((_a2 = col == null ? void 0 : col.dataIndex) == null ? void 0 : _a2.length) > 0;
52
52
  });
53
- const appends = (0, import_utils2.columns2Appends)(columns, ctx);
53
+ const appends = (0, import_utils.columns2Appends)(columns, ctx);
54
54
  const count = await repository.count({
55
55
  filter,
56
56
  context: ctx
@@ -110,7 +110,7 @@ async function exportXlsx(ctx, next) {
110
110
  for (const data2 of rows) {
111
111
  for (const key in data2) {
112
112
  if (data2[key] instanceof Date) {
113
- data2[key] = (0, import_utils.dayjs)(data2[key]).utcOffset(timezone).format("YYYY-MM-DD HH:mm:ss");
113
+ data2[key] = (0, import_server.dayjs)(data2[key]).utcOffset(timezone).format("YYYY-MM-DD HH:mm:ss");
114
114
  }
115
115
  }
116
116
  }
@@ -1,4 +1,4 @@
1
- import { InstallOptions, Plugin } from '@tachybase/server';
1
+ import { InstallOptions, Plugin } from '@tego/server';
2
2
  export declare class ExportPlugin extends Plugin {
3
3
  beforeLoad(): void;
4
4
  load(): Promise<void>;
@@ -31,10 +31,9 @@ __export(server_exports, {
31
31
  default: () => server_default
32
32
  });
33
33
  module.exports = __toCommonJS(server_exports);
34
- var import_fs = require("fs");
35
- var import_path = __toESM(require("path"));
36
- var import_server = require("@tachybase/server");
37
- var import_utils = require("@tachybase/utils");
34
+ var import_node_fs = require("node:fs");
35
+ var import_node_path = __toESM(require("node:path"));
36
+ var import_server = require("@tego/server");
38
37
  var import_node_xlsx = __toESM(require("node-xlsx"));
39
38
  var import_actions = require("./actions");
40
39
  var import_constants = require("./constants");
@@ -52,7 +51,7 @@ const _ExportPlugin = class _ExportPlugin extends import_server.Plugin {
52
51
  async install(options) {
53
52
  }
54
53
  xlsxStorageDir() {
55
- return import_path.default.resolve(process.cwd(), _ExportPlugin.defaultSavePath);
54
+ return import_node_path.default.resolve(process.cwd(), _ExportPlugin.defaultSavePath);
56
55
  }
57
56
  async workerExportXlsx(params) {
58
57
  const { title, filter, sort, fields, except, appends, resourceName, resourceOf, timezone } = params;
@@ -90,7 +89,7 @@ const _ExportPlugin = class _ExportPlugin extends import_server.Plugin {
90
89
  for (const data2 of rows) {
91
90
  for (const key in data2) {
92
91
  if (data2[key] instanceof Date) {
93
- data2[key] = (0, import_utils.dayjs)(data2[key]).utcOffset(timezone).format("YYYY-MM-DD HH:mm:ss");
92
+ data2[key] = (0, import_server.dayjs)(data2[key]).utcOffset(timezone).format("YYYY-MM-DD HH:mm:ss");
94
93
  }
95
94
  }
96
95
  }
@@ -105,12 +104,12 @@ const _ExportPlugin = class _ExportPlugin extends import_server.Plugin {
105
104
  }
106
105
  ]);
107
106
  const savePath = this.xlsxStorageDir();
108
- if (!(0, import_fs.existsSync)(savePath)) {
109
- (0, import_fs.mkdirSync)(savePath, { recursive: true });
107
+ if (!(0, import_node_fs.existsSync)(savePath)) {
108
+ (0, import_node_fs.mkdirSync)(savePath, { recursive: true });
110
109
  }
111
- const fileName = `${resourceName}_${(0, import_utils.dayjs)().format("YYYYMMDDHHmm")}.xlsx`;
110
+ const fileName = `${resourceName}_${(0, import_server.dayjs)().format("YYYYMMDDHHmm")}.xlsx`;
112
111
  const rawFile = `${savePath}/${fileName}`;
113
- (0, import_fs.writeFileSync)(rawFile, Buffer.from(stream));
112
+ (0, import_node_fs.writeFileSync)(rawFile, Buffer.from(stream));
114
113
  return `${_ExportPlugin.defaultSavePath}/${fileName}`;
115
114
  }
116
115
  };
@@ -1,4 +1,4 @@
1
- import Database from '@tachybase/database';
1
+ import { Database } from '@tego/server';
2
2
  export default function ({ columns, fields, data, utcOffset }: {
3
3
  columns: any;
4
4
  fields: any;
@@ -34,7 +34,7 @@ __export(renders_exports, {
34
34
  subTable: () => subTable
35
35
  });
36
36
  module.exports = __toCommonJS(renders_exports);
37
- var import_utils = require("@tachybase/utils");
37
+ var import_server = require("@tego/server");
38
38
  async function _(field, row, ctx, column) {
39
39
  if ((column == null ? void 0 : column.dataIndex.length) > 1) {
40
40
  const result = column.dataIndex.reduce((result2, col) => {
@@ -72,15 +72,15 @@ async function datetime(field, row, { utcOffset }) {
72
72
  return "";
73
73
  }
74
74
  const props = ((_b = (_a = field.options) == null ? void 0 : _a.uiSchema) == null ? void 0 : _b["x-component-props"]) ?? {};
75
- const format = (0, import_utils.getDefaultFormat)(props);
76
- const m = (0, import_utils.str2moment)(value, { ...props, utcOffset });
75
+ const format = (0, import_server.getDefaultFormat)(props);
76
+ const m = (0, import_server.str2moment)(value, { ...props, utcOffset });
77
77
  return m ? m.format(format) : "";
78
78
  }
79
79
  async function percent(field, row, ctx) {
80
80
  var _a, _b, _c;
81
81
  const value = row.get(field.name);
82
82
  const step = ((_c = (_b = (_a = field.options) == null ? void 0 : _a.uiSchema) == null ? void 0 : _b["x-component-props"]) == null ? void 0 : _c["step"]) ?? 0;
83
- return value && `${(0, import_utils.toFixedByStep)(value * 100, step)}%`;
83
+ return value && `${(0, import_server.toFixedByStep)(value * 100, step)}%`;
84
84
  }
85
85
  async function boolean(field, row, ctx, column) {
86
86
  const value = row.get(field.name);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tachybase/plugin-action-export",
3
3
  "displayName": "Action: Export records",
4
- "version": "1.3.21",
4
+ "version": "1.3.22",
5
5
  "description": "Export filtered records to excel, you can configure which fields to export.",
6
6
  "keywords": [
7
7
  "Actions"
@@ -10,27 +10,19 @@
10
10
  "main": "./dist/server/index.js",
11
11
  "dependencies": {},
12
12
  "devDependencies": {
13
- "@types/node-xlsx": "^0.21.0",
13
+ "@tachybase/schema": "^1.3.39",
14
+ "@tachybase/test": "^1.3.39",
15
+ "@tego/client": "^1.3.39",
16
+ "@tego/server": "^1.3.39",
14
17
  "antd": "5.22.5",
15
18
  "file-saver": "^2.0.5",
16
19
  "lodash": "4.17.21",
17
20
  "node-xlsx": "^0.24.0",
18
- "react": "^18.3.1",
19
- "react-i18next": "^15.2.0",
20
- "@tachybase/components": "1.3.21",
21
- "@tachybase/schema": "1.3.21"
22
- },
23
- "peerDependencies": {
24
- "@tachybase/client": "1.3.21",
25
- "@tachybase/actions": "1.3.21",
26
- "@tachybase/test": "1.3.21",
27
- "@tachybase/database": "1.3.21",
28
- "@tachybase/server": "1.3.21",
29
- "@tachybase/utils": "1.3.21"
21
+ "react": "18.3.1",
22
+ "react-i18next": "15.2.0",
23
+ "@tachybase/client": "1.3.22"
30
24
  },
31
25
  "description.zh-CN": "导出筛选后的记录到 Excel 中,可以配置导出哪些字段。",
32
26
  "displayName.zh-CN": "操作:导出记录",
33
- "scripts": {
34
- "build": "tachybase-build --no-dts @tachybase/plugin-action-export"
35
- }
27
+ "scripts": {}
36
28
  }