@tachybase/plugin-action-export 1.5.0 → 1.6.0

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,14 +1,14 @@
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`
1
+ (function(i,o){typeof exports=="object"&&typeof module!="undefined"?o(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"],o):(i=typeof globalThis!="undefined"?globalThis:i||self,o(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,o,m,A,y,B,I,P,S){"use strict";var ae=Object.defineProperty,se=Object.defineProperties;var ie=Object.getOwnPropertyDescriptors;var K=Object.getOwnPropertySymbols;var ce=Object.prototype.hasOwnProperty,pe=Object.prototype.propertyIsEnumerable;var Y=(i,o,m)=>o in i?ae(i,o,{enumerable:!0,configurable:!0,writable:!0,value:m}):i[o]=m,T=(i,o)=>{for(var m in o||(o={}))ce.call(o,m)&&Y(i,m,o[m]);if(K)for(var m of K(o))pe.call(o,m)&&Y(i,m,o[m]);return i},Q=(i,o)=>se(i,ie(o));var L=(i,o,m)=>new Promise((A,y)=>{var B=S=>{try{P(m.next(S))}catch(F){y(F)}},I=S=>{try{P(m.throw(S))}catch(F){y(F)}},P=S=>S.done?A(S.value):Promise.resolve(S.value).then(B,I);P((m=m.apply(i,o)).next())});const F=n=>m.jsx(o.SchemaComponentOptions,{components:{ExportActionInitializer:N,ExportDesigner:H},scope:{useExportAction:G},children:n.children}),_=n=>{var p;const e=y.useFieldSchema();(p=e==null?void 0:e["x-component-props"])!=null&&p.nonfilterable;const{getCollectionFields:s}=o.useCollectionManager_deprecated(),d=s(n),x=(c,f)=>{var r;if(!c.interface)return;const t={name:c.name,title:((r=c==null?void 0:c.uiSchema)==null?void 0:r.title)||c.name,schema:c==null?void 0:c.uiSchema};if(!c.target||f>=3)return t;if(c.target){const l=s(c.target),a=h(l,f+1).filter(Boolean);t.children=t.children||[],t.children.push(...a)}return t},h=(c,f)=>{const t=[];return c.forEach(r=>{const l=x(r,f);l&&t.push(l)}),t};return h(d,1)},q=()=>{const{name:n}=o.useCollection_deprecated(),e=_(n);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:o.css`
2
2
  width: 100%;
3
3
  & .ant-space-item:nth-child(2),
4
4
  & .ant-space-item:nth-child(3) {
5
5
  flex: 1;
6
6
  }
7
- `},properties:{sort:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.SortHandle"},dataIndex:{type:"array","x-decorator":"FormItem","x-component":t.Cascader,required:!0,enum:e,"x-component-props":{fieldNames:{label:"title",value:"name",children:"children"},changeOnSelect:!1}},title:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:'{{ t("Custom column title") }}'}},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:'{{ t("Add exportable field") }}',"x-component":"ArrayItems.Addition","x-component-props":{className:t.css`
7
+ `},properties:{sort:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.SortHandle"},dataIndex:{type:"array","x-decorator":"FormItem","x-component":o.Cascader,required:!0,enum:e,"x-component-props":{fieldNames:{label:"title",value:"name",children:"children"},changeOnSelect:!1}},title:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:'{{ t("Custom column title") }}'}},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:'{{ t("Add exportable field") }}',"x-component":"ArrayItems.Addition","x-component-props":{className:o.css`
8
8
  border-color: var(--colorSettings);
9
9
  color: var(--colorSettings);
10
10
  &.ant-btn-dashed:hover {
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=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"}})});
14
+ `}}}}}}}},Z=new o.SchemaSettings({name:"actionSettings:export",items:[{name:"editButton",Component:o.ButtonEditor,useComponentProps(){const{buttonEditorProps:n}=o.useSchemaToolbar();return n}},{name:"exportableFields",type:"actionModal",useComponentProps(){var c,f;const n=y.useField(),e=y.useFieldSchema(),{t:s}=I.useTranslation(),{dn:d}=o.useDesignable(),[x,h]=A.useState(),{schema:p}=q();return A.useEffect(()=>{h(p)},[n.address,(c=e==null?void 0:e["x-action-settings"])==null?void 0:c.exportSettings]),{title:s("Exportable fields"),schema:x,initialValues:{exportSettings:(f=e==null?void 0:e["x-action-settings"])==null?void 0:f.exportSettings},components:{ArrayItems:B.ArrayItems},onSubmit:({exportSettings:t})=>{e["x-action-settings"].exportSettings=t==null?void 0:t.filter(r=>{var l;return(l=r==null?void 0:r.dataIndex)==null?void 0:l.length}).map(r=>({dataIndex:r.dataIndex.map(l=>{var a;return(a=l.name)!=null?a:l}),title:r.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:n}=I.useTranslation();return{removeParentsIfNoChildren:!0,breakRemoveOn:e=>e["x-component"]==="Space"||e["x-component"].endsWith("ActionBar"),confirm:{title:n("Delete action")}}}}]}),z=(n,e,s)=>n.reduceProperties((d,x)=>{if(x[e]===s)return x;const h=z(x,e,s);return h||d}),ee=(n,e)=>e(n),U=(n,e,s=z,d=ee)=>{const x=y.useFieldSchema(),{remove:h}=o.useDesignable(),p=s(x,e,n);return{schema:p,exists:!!p,remove(){p&&d(p,h)}}},te=n=>n==null?void 0:n.filter(s=>!s.children).map(s=>({dataIndex:[s.name]})),N=()=>{const n=o.useSchemaInitializerItem(),{insert:e}=o.useSchemaInitializer(),{exists:s,remove:d}=U("export","x-action",n.find,n.remove),{name:x}=o.useCollection_deprecated(),h=_(x),p={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(o.SchemaInitializerSwitch,Q(T({},n),{checked:s,title:n.title,onClick:()=>{var f;if(s)return d();p["x-action-settings"].exportSettings=te(h);const c=y.merge(p||{},n.schema||{});(f=n==null?void 0:n.schemaInitialize)==null||f.call(n,c),e(c)}}))},H=()=>{var c,f,t,r,l;const n=y.useField(),e=y.useFieldSchema(),{t:s}=I.useTranslation(),{dn:d}=o.useDesignable(),[x,h]=A.useState(),{schema:p}=q();return A.useEffect(()=>{h(p)},[n.address,(c=e==null?void 0:e["x-action-settings"])==null?void 0:c.exportSettings]),m.jsxs(o.GeneralSchemaDesigner,{disableInitializer:!0,children:[m.jsx(o.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:(f=e==null?void 0:e["x-component-props"])==null?void 0:f.icon,"x-component-props":{}},type:{"x-decorator":"FormItem","x-component":"Radio.Group",title:s("Button background color"),default:(t=e==null?void 0:e["x-component-props"])!=null&&t.danger?"danger":((r=e==null?void 0:e["x-component-props"])==null?void 0:r.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,n.title=a,n.componentProps.icon=u,n.componentProps.danger=v==="danger",n.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":T({},e["x-component-props"])}}),d.refresh()}}),m.jsx(o.SchemaSettingsActionModalItem,{title:s("Exportable fields"),schema:x,initialValues:{exportSettings:(l=e==null?void 0:e["x-action-settings"])==null?void 0:l.exportSettings},components:{ArrayItems:B.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 w;return(w=v.name)!=null?w:v}),title:u.title})),d.emit("patch",{schema:{"x-uid":e["x-uid"],"x-action-settings":e["x-action-settings"]}}),d.refresh()}}),m.jsx(o.SchemaSettingsDivider,{}),m.jsx(o.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:a=>a["x-component"]==="Space"||a["x-component"].endsWith("ActionBar"),confirm:{title:s("Delete action")}})]})};var D=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{},O={exports:{}},oe=O.exports,$;function ne(){return $||($=1,function(n,e){(function(s,d){d()})(oe,function(){function s(t,r){return typeof r=="undefined"?r={autoBom:!1}:typeof r!="object"&&(console.warn("Deprecated: Expected third argument to be a object"),r={autoBom:!r}),r.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(t.type)?new Blob(["\uFEFF",t],{type:t.type}):t}function d(t,r,l){var a=new XMLHttpRequest;a.open("GET",t),a.responseType="blob",a.onload=function(){f(a.response,r,l)},a.onerror=function(){console.error("could not download file")},a.send()}function x(t){var r=new XMLHttpRequest;r.open("HEAD",t,!1);try{r.send()}catch(l){}return 200<=r.status&&299>=r.status}function h(t){try{t.dispatchEvent(new MouseEvent("click"))}catch(l){var r=document.createEvent("MouseEvents");r.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),t.dispatchEvent(r)}}var p=typeof window=="object"&&window.window===window?window:typeof self=="object"&&self.self===self?self:typeof D=="object"&&D.global===D?D:void 0,c=p.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),f=p.saveAs||(typeof window!="object"||window!==p?function(){}:"download"in HTMLAnchorElement.prototype&&!c?function(t,r,l){var a=p.URL||p.webkitURL,u=document.createElement("a");r=r||t.name||"download",u.download=r,u.rel="noopener",typeof t=="string"?(u.href=t,u.origin===location.origin?h(u):x(u.href)?d(t,r,l):h(u,u.target="_blank")):(u.href=a.createObjectURL(t),setTimeout(function(){a.revokeObjectURL(u.href)},4e4),setTimeout(function(){h(u)},0))}:"msSaveOrOpenBlob"in navigator?function(t,r,l){if(r=r||t.name||"download",typeof t!="string")navigator.msSaveOrOpenBlob(s(t,l),r);else if(x(t))d(t,r,l);else{var a=document.createElement("a");a.href=t,a.target="_blank",setTimeout(function(){h(a)})}}:function(t,r,l,a){if(a=a||open("","_blank"),a&&(a.document.title=a.document.body.innerText="downloading..."),typeof t=="string")return d(t,r,l);var u=t.type==="application/octet-stream",v=/constructor/i.test(p.HTMLElement)||p.safari,w=/CriOS\/[\d]+/.test(navigator.userAgent);if((w||u&&v||c)&&typeof FileReader!="undefined"){var C=new FileReader;C.onloadend=function(){var E=C.result;E=w?E:E.replace(/^data:[^;]*;/,"data:attachment/file;"),a?a.location.href=E:location=E,a=null},C.readAsDataURL(t)}else{var M=p.URL||p.webkitURL,j=M.createObjectURL(t);a?a.location=j:location.href=j,a=null,setTimeout(function(){M.revokeObjectURL(j)},4e4)}});p.saveAs=f.saveAs=f,n.exports=f})}(O)),O.exports}var re=ne();const G=()=>{var l,a,u;const{service:n,resource:e}=o.useBlockRequestContext(),s=o.useTableBlockContext();o.useAPIClient();const d=y.useFieldSchema(),x=o.useCompile(),{getCollectionJoinField:h}=o.useCollectionManager_deprecated(),{name:p,title:c,getField:f}=o.useCollection_deprecated(),{t}=I.useTranslation(),r=T(T(T({},(l=n.params[0])==null?void 0:l.filter),(a=s.params)==null?void 0:a.filter),(u=s.service.params[0])==null?void 0:u.filter);return{onClick(){return L(this,null,function*(){var M,j,E,W;const{exportSettings:w}=S.cloneDeep((M=d==null?void 0:d["x-action-settings"])!=null?M:{});w.forEach(b=>{var R,V;const{uiSchema:g,interface:k}=(R=h(`${p}.${b.dataIndex.join(".")}`))!=null?R:{};b.enum=(V=g==null?void 0:g.enum)==null?void 0:V.map(X=>({value:X.value,label:X.label})),!b.enum&&(g==null?void 0:g.type)==="boolean"&&(b.enum=[{value:!0,label:t("Yes")},{value:!1,label:t("No")}]),b.defaultTitle=g==null?void 0:g.title,k==="chinaRegion"&&b.dataIndex.push("name")});const C=P.message.loading(t("Exporting Data..."),0);try{const b=yield e.export({title:x(c),appends:(E=(j=n.params[0])==null?void 0:j.appends)==null?void 0:E.join(),filter:JSON.stringify(r),sort:(W=n.params[0])==null?void 0:W.sort},{method:"post",data:{columns:x(w)},responseType:"blob"}),{data:g}=b;if(g.type==="application/json"){const k=yield g.text(),{data:{filename:R}}=JSON.parse(k);window.location.href=R}else{const k=new Blob([g],{type:"application/x-xls"});re.saveAs(k,`${x(c)}.xlsx`)}C()}catch(b){console.error(b),C()}})}}};class J extends o.Plugin{load(){return L(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(Z)})}}i.ExportActionInitializer=N,i.ExportDesigner=H,i.ExportPlugin=J,i.ExportPluginProvider=F,i.default=J,i.useCurrentSchema=U,i.useExportAction=G,Object.defineProperties(i,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
@@ -1,6 +1,6 @@
1
1
  module.exports = {
2
2
  "react": "18.3.1",
3
- "@tachybase/client": "1.5.0",
3
+ "@tachybase/client": "1.6.0",
4
4
  "@tachybase/schema": "1.3.52",
5
5
  "@tego/client": "1.3.52",
6
6
  "react-i18next": "16.2.1",
@@ -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-11-11T06:40:31.059Z"}
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-11-20T08:10:41.842Z"}
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.5.0",
4
+ "version": "1.6.0",
5
5
  "description": "Export filtered records to excel, you can configure which fields to export.",
6
6
  "keywords": [
7
7
  "Actions"
@@ -10,18 +10,18 @@
10
10
  "main": "./dist/server/index.js",
11
11
  "dependencies": {},
12
12
  "devDependencies": {
13
- "@tachybase/schema": "*",
14
- "@tachybase/test": "*",
15
- "@tego/client": "*",
16
- "@tego/server": "*",
13
+ "@tachybase/schema": "1.3.52",
14
+ "@tachybase/test": "1.3.52",
15
+ "@tego/client": "1.3.52",
16
+ "@tego/server": "1.3.52",
17
17
  "antd": "5.22.5",
18
- "dayjs": "^1.11.13",
18
+ "dayjs": "1.11.13",
19
19
  "file-saver": "^2.0.5",
20
20
  "lodash": "4.17.21",
21
21
  "node-xlsx": "^0.24.0",
22
22
  "react": "18.3.1",
23
23
  "react-i18next": "16.2.1",
24
- "@tachybase/client": "1.5.0"
24
+ "@tachybase/client": "1.6.0"
25
25
  },
26
26
  "description.zh-CN": "导出筛选后的记录到 Excel 中,可以配置导出哪些字段。",
27
27
  "displayName.zh-CN": "操作:导出记录",