@nocobase/plugin-action-import 1.5.0-beta.2 → 1.5.0-beta.3

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.
@@ -7,27 +7,27 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
 
10
- (function(c,a){typeof exports=="object"&&typeof module!="undefined"?a(exports,require("react/jsx-runtime"),require("@formily/shared"),require("@nocobase/client"),require("antd"),require("react-i18next"),require("@formily/antd-v5"),require("@formily/react"),require("react"),require("react-dom"),require("@ant-design/icons"),require("lodash")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","@formily/shared","@nocobase/client","antd","react-i18next","@formily/antd-v5","@formily/react","react","react-dom","@ant-design/icons","lodash"],a):(c=typeof globalThis!="undefined"?globalThis:c||self,a(c["@nocobase/plugin-action-import"]={},c.jsxRuntime,c["@formily/shared"],c["@nocobase/client"],c.antd,c["react-i18next"],c["@formily/antd-v5"],c["@formily/react"],c.react,c["react-dom"],c["@ant-design/icons"],c.lodash))})(this,function(c,a,y,i,E,F,N,M,g,j,R,$){"use strict";var Te=Object.defineProperty,Ce=Object.defineProperties;var Ee=Object.getOwnPropertyDescriptors;var ue=Object.getOwnPropertySymbols;var Me=Object.prototype.hasOwnProperty,Fe=Object.prototype.propertyIsEnumerable;var xe=(c,a,y)=>a in c?Te(c,a,{enumerable:!0,configurable:!0,writable:!0,value:y}):c[a]=y,O=(c,a)=>{for(var y in a||(a={}))Me.call(a,y)&&xe(c,y,a[y]);if(ue)for(var y of ue(a))Fe.call(a,y)&&xe(c,y,a[y]);return c},he=(c,a)=>Ce(c,Ee(a));var q=(c,a,y)=>new Promise((i,E)=>{var F=g=>{try{M(y.next(g))}catch(j){E(j)}},N=g=>{try{M(y.throw(g))}catch(j){E(j)}},M=g=>g.done?i(g.value):Promise.resolve(g.value).then(F,N);M((y=y.apply(c,a)).next())});const C="action-import",fe="action-import";function V(){return F.useTranslation([fe,"client"],{nsMode:"fallback"})}const ge=["id","createdAt","createdBy","updatedAt","updatedBy"],X=t=>{const{getCollectionFields:e}=i.useCollectionManager_deprecated(),l=e(t),p=(s,n)=>{var f;if(!s.interface||ge.includes(s.interface))return;const m={name:s.name,title:((f=s==null?void 0:s.uiSchema)==null?void 0:f.title)||s.name,schema:s==null?void 0:s.uiSchema};if(!s.target||n>=2)return m;if(s.target&&["hasOne","hasMany","belongsTo","belongsToMany","belongsToArray"].includes(s.type)){const o=e(s.target),r=x(o,n+1).filter(Boolean);m.children=m.children||[],m.children.push(...r)}return m},x=(s,n)=>{const m=[];return s.forEach(f=>{const o=p(f,n);o&&m.push(o)}),m};return x(l,1)},ye=t=>({importColumns:t==null?void 0:t.filter(l=>!l.children).map(l=>({dataIndex:[l.name]})),explain:""}),G=()=>{const{t}=V();return a.jsx(E.Alert,{type:"warning",style:{marginBottom:"10px"},message:t("Import warnings",{limit:2e3})})},W=()=>{const{t}=V();return a.jsx(E.Alert,{type:"info",style:{marginBottom:"10px",whiteSpace:"pre-line"},message:t("Download tips")})},J=()=>{const t=i.useSchemaInitializerItem(),{insert:e}=i.useSchemaInitializer(),{name:l}=i.useCollection_deprecated(),p=X(l),x={type:"void",title:'{{ t("Import") }}',"x-action":"importXlsx","x-action-settings":{importSettings:{importColumns:[],explain:""}},"x-toolbar":"ActionSchemaToolbar","x-settings":"actionSettings:import","x-component":"Action","x-component-props":{icon:"CloudUploadOutlined",openMode:"modal"},properties:{modal:{type:"void",title:`{{ t("Import Data", {ns: "${C}" }) }}`,"x-component":"Action.Modal","x-decorator":"Form","x-component-props":{width:"100%",style:{maxWidth:"750px"},className:i.css`
10
+ (function(p,a){typeof exports=="object"&&typeof module!="undefined"?a(exports,require("react/jsx-runtime"),require("@formily/shared"),require("@nocobase/client"),require("antd"),require("react-i18next"),require("@formily/antd-v5"),require("@formily/react"),require("react"),require("react-dom"),require("@ant-design/icons"),require("lodash")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","@formily/shared","@nocobase/client","antd","react-i18next","@formily/antd-v5","@formily/react","react","react-dom","@ant-design/icons","lodash"],a):(p=typeof globalThis!="undefined"?globalThis:p||self,a(p["@nocobase/plugin-action-import"]={},p.jsxRuntime,p["@formily/shared"],p["@nocobase/client"],p.antd,p["react-i18next"],p["@formily/antd-v5"],p["@formily/react"],p.react,p["react-dom"],p["@ant-design/icons"],p.lodash))})(this,function(p,a,y,s,E,F,N,M,g,j,$,V){"use strict";var we=Object.defineProperty,Te=Object.defineProperties;var Ce=Object.getOwnPropertyDescriptors;var ue=Object.getOwnPropertySymbols;var Ee=Object.prototype.hasOwnProperty,Me=Object.prototype.propertyIsEnumerable;var xe=(p,a,y)=>a in p?we(p,a,{enumerable:!0,configurable:!0,writable:!0,value:y}):p[a]=y,O=(p,a)=>{for(var y in a||(a={}))Ee.call(a,y)&&xe(p,y,a[y]);if(ue)for(var y of ue(a))Me.call(a,y)&&xe(p,y,a[y]);return p},he=(p,a)=>Te(p,Ce(a));var R=(p,a,y)=>new Promise((s,E)=>{var F=g=>{try{M(y.next(g))}catch(j){E(j)}},N=g=>{try{M(y.throw(g))}catch(j){E(j)}},M=g=>g.done?s(g.value):Promise.resolve(g.value).then(F,N);M((y=y.apply(p,a)).next())});const T="action-import",fe="action-import";function X(){return F.useTranslation([fe,"client"],{nsMode:"fallback"})}const ge=["id","createdAt","createdBy","updatedAt","updatedBy"],G=t=>{const{getCollectionFields:e}=s.useCollectionManager_deprecated(),l=e(t),c=(i,r)=>{var f;if(!i.interface||ge.includes(i.interface))return;const u={name:i.name,title:((f=i==null?void 0:i.uiSchema)==null?void 0:f.title)||i.name,schema:i==null?void 0:i.uiSchema};if(!i.target||r>=2)return u;if(i.target&&["hasOne","hasMany","belongsTo","belongsToMany","belongsToArray"].includes(i.type)){const o=e(i.target),n=x(o,r+1).filter(Boolean);u.children=u.children||[],u.children.push(...n)}return u},x=(i,r)=>{const u=[];return i.forEach(f=>{const o=c(f,r);o&&u.push(o)}),u};return x(l,1)},ye=t=>({importColumns:t==null?void 0:t.filter(l=>!l.children).map(l=>({dataIndex:[l.name]})),explain:""}),W=()=>{const{t}=X();return a.jsx(E.Alert,{type:"warning",style:{marginBottom:"10px"},message:t("Import warnings",{limit:2e3})})},J=()=>{const{t}=X();return a.jsx(E.Alert,{type:"info",style:{marginBottom:"10px",whiteSpace:"pre-line"},message:t("Download tips")})},K=()=>{const t=s.useSchemaInitializerItem(),{insert:e}=s.useSchemaInitializer(),{name:l}=s.useCollection_deprecated(),c=G(l),x={type:"void",title:'{{ t("Import") }}',"x-action":"importXlsx","x-action-settings":{importSettings:{importColumns:[],explain:""}},"x-toolbar":"ActionSchemaToolbar","x-settings":"actionSettings:import","x-component":"Action","x-component-props":{icon:"CloudUploadOutlined",openMode:"modal"},properties:{modal:{type:"void",title:`{{ t("Import Data", {ns: "${T}" }) }}`,"x-component":"Action.Modal","x-decorator":"Form","x-component-props":{width:"100%",style:{maxWidth:"750px"},className:s.css`
11
11
  .ant-formily-item-label {
12
12
  height: var(--controlHeightLG);
13
13
  }
14
- `},properties:{formLayout:{type:"void","x-component":"FormLayout",properties:{warning:{type:"void","x-component":"ImportWarning"},download:{type:"void",title:`{{ t("Step 1: Download template", {ns: "${C}" }) }}`,"x-component":"FormItem","x-acl-ignore":!0,properties:{tip:{type:"void","x-component":"DownloadTips"},downloadAction:{type:"void",title:`{{ t("Download template", {ns: "${C}" }) }}`,"x-component":"Action","x-component-props":{className:i.css`
14
+ `},properties:{formLayout:{type:"void","x-component":"FormLayout",properties:{warning:{type:"void","x-component":"ImportWarning"},download:{type:"void",title:`{{ t("Step 1: Download template", {ns: "${T}" }) }}`,"x-component":"FormItem","x-acl-ignore":!0,properties:{tip:{type:"void","x-component":"DownloadTips"},downloadAction:{type:"void",title:`{{ t("Download template", {ns: "${T}" }) }}`,"x-component":"Action","x-component-props":{className:s.css`
15
15
  margin-top: 5px;
16
- `,useAction:"{{ useDownloadXlsxTemplateAction }}"}}}},upload:{type:"array",title:`{{ t("Step 2: Upload Excel", {ns: "${C}" }) }}`,"x-decorator":"FormItem","x-acl-ignore":!0,"x-component":"Upload.Dragger","x-validator":"{{ uploadValidator }}","x-component-props":{action:"",height:"150px",tipContent:`{{ t("Upload placeholder", {ns: "${C}" }) }}`,beforeUpload:"{{ beforeUploadHandler }}"}}}},footer:{"x-component":"Action.Modal.Footer","x-component-props":{},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{},properties:{cancel:{type:"void",title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},startImport:{type:"void",title:`{{ t("Start import", {ns: "${C}" }) }}`,"x-component":"Action","x-component-props":{type:"primary",htmlType:"submit",useAction:"{{ useImportStartAction }}"},"x-reactions":{dependencies:["upload"],fulfill:{run:"validateUpload($form, $self, $deps)"}}}}}}}}}}};return a.jsx(i.SchemaInitializerItem,{title:t.title,onClick:()=>{var n;x["x-action-settings"].importSettings=ye(p);const s=y.merge(x||{},t.schema||{});(n=t==null?void 0:t.schemaInitialize)==null||n.call(t,s),e(s)}})},Ie=["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.ms-excel","application/wps-office.xlsx"],z=()=>{const{t}=F.useTranslation(C),{name:e}=i.useCollection_deprecated(),l=X(e);return{importSettingsSchema:{type:"void","x-component":"Grid",properties:{explain:{type:"string",title:`{{ t("Import explain", {ns: "${C}"}) }}`,"x-decorator":"FormItem","x-component":"Input.TextArea"},importColumns:{type:"array","x-component":"ArrayItems","x-decorator":"FormItem",items:{type:"object",properties:{space:{type:"void","x-component":"Space","x-component-props":{className:i.css`
16
+ `,useAction:"{{ useDownloadXlsxTemplateAction }}"}}}},upload:{type:"array",title:`{{ t("Step 2: Upload Excel", {ns: "${T}" }) }}`,"x-decorator":"FormItem","x-acl-ignore":!0,"x-component":"Upload.Dragger","x-validator":"{{ uploadValidator }}","x-component-props":{action:"",height:"150px",tipContent:`{{ t("Upload placeholder", {ns: "${T}" }) }}`,beforeUpload:"{{ beforeUploadHandler }}"}}}},footer:{"x-component":"Action.Modal.Footer","x-component-props":{},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{},properties:{cancel:{type:"void",title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},startImport:{type:"void",title:`{{ t("Start import", {ns: "${T}" }) }}`,"x-component":"Action","x-component-props":{type:"primary",htmlType:"submit",useAction:"{{ useImportStartAction }}"},"x-reactions":{dependencies:["upload"],fulfill:{run:"validateUpload($form, $self, $deps)"}}}}}}}}}}};return a.jsx(s.SchemaInitializerItem,{title:t.title,onClick:()=>{var r;x["x-action-settings"].importSettings=ye(c);const i=y.merge(x||{},t.schema||{});(r=t==null?void 0:t.schemaInitialize)==null||r.call(t,i),e(i)}})},Ie=["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.ms-excel","application/wps-office.xlsx"],z=()=>{const{t}=F.useTranslation(T),{name:e}=s.useCollection_deprecated(),l=G(e);return{importSettingsSchema:{type:"void","x-component":"Grid",properties:{explain:{type:"string",title:`{{ t("Import explain", {ns: "${T}"}) }}`,"x-decorator":"FormItem","x-component":"Input.TextArea"},importColumns:{type:"array","x-component":"ArrayItems","x-decorator":"FormItem",items:{type:"object",properties:{space:{type:"void","x-component":"Space","x-component-props":{className:s.css`
17
17
  width: 100%;
18
18
  & .ant-space-item:nth-child(2) {
19
19
  flex: 1;
20
20
  }
21
- `},properties:{sort:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.SortHandle"},dataIndex:{type:"array","x-decorator":"FormItem","x-component":i.Cascader,required:!0,enum:l,"x-component-props":{fieldNames:{label:"title",value:"name",children:"children"},changeOnSelect:!1}},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:`{{ t("Add importable field", {ns: "${C}"}) }}`,"x-component":"ArrayItems.Addition","x-component-props":{className:i.css`
21
+ `},properties:{sort:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.SortHandle"},dataIndex:{type:"array","x-decorator":"FormItem","x-component":s.Cascader,required:!0,enum:l,"x-component-props":{fieldNames:{label:"title",value:"name",children:"children"},changeOnSelect:!1}},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:`{{ t("Add importable field", {ns: "${T}"}) }}`,"x-component":"ArrayItems.Addition","x-component-props":{className:s.css`
22
22
  border-color: var(--colorSettings);
23
23
  color: var(--colorSettings);
24
24
  &.ant-btn-dashed:hover {
25
25
  border-color: var(--colorSettings);
26
26
  color: var(--colorSettings);
27
27
  }
28
- `}}}}}},beforeUploadHandler(){return!1},uploadValidator(p,x){var n;if(p.length>1)return{type:"error",message:t("Only one file is allowed to be uploaded")};const s=(n=p[0])!=null?n:{};return s.size>10*1024*1024?{type:"error",message:t("File size cannot exceed 10M")}:Ie.includes(s.type)?"":{type:"error",message:t("Please upload the file of Excel")}},validateUpload(p,x,s){var m;const[n]=s;x.disabled=(n==null?void 0:n.length)===0,x.componentProps=he(O({},x.componentProps),{disabled:(n==null?void 0:n.length)===0||((m=p.errors)==null?void 0:m.length)>0})}}},K=()=>{var m,f,o,r,h,d;const t=M.useField(),e=M.useFieldSchema(),{t:l}=F.useTranslation(),{dn:p}=i.useDesignable(),[x,s]=g.useState(),{importSettingsSchema:n}=z();return g.useEffect(()=>{s(n)},[t.address,(m=e==null?void 0:e["x-action-settings"])==null?void 0:m.importSettings]),a.jsxs(i.GeneralSchemaDesigner,{disableInitializer:!0,children:[a.jsx(i.SchemaSettingsModalItem,{title:l("Edit button"),schema:{type:"object",title:l("Edit button"),properties:{title:{"x-decorator":"FormItem","x-component":"Input",title:l("Button title"),default:e.title,"x-component-props":{}},icon:{"x-decorator":"FormItem","x-component":"IconPicker",title:l("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:l("Button background color"),default:(o=e==null?void 0:e["x-component-props"])!=null&&o.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:u,icon:I,type:v})=>{e.title=u,t.title=u,t.componentProps.icon=I,t.componentProps.danger=v==="danger",t.componentProps.type=v,e["x-component-props"]=e["x-component-props"]||{},e["x-component-props"].icon=I,e["x-component-props"].danger=v==="danger",e["x-component-props"].type=v,p.emit("patch",{schema:{"x-uid":e["x-uid"],title:u,"x-component-props":O({},e["x-component-props"])}}),p.refresh()}}),a.jsx(i.SchemaSettingsActionModalItem,{title:l("Importable fields"),schema:x,initialValues:O({},(d=(h=e==null?void 0:e["x-action-settings"])==null?void 0:h.importSettings)!=null?d:{}),components:{ArrayItems:N.ArrayItems},onSubmit:({importColumns:u,explain:I})=>{const v=u==null?void 0:u.filter(A=>{var b;return(b=A==null?void 0:A.dataIndex)==null?void 0:b.length}).map(A=>({dataIndex:A.dataIndex.map(b=>{var S;return(S=b.name)!=null?S:b}),title:A.title}));e["x-action-settings"].importSettings={importColumns:v,explain:I},p.emit("patch",{schema:{"x-uid":e["x-uid"],"x-action-settings":e["x-action-settings"]}}),p.refresh()}}),a.jsx(i.SchemaSettingsDivider,{}),a.jsx(i.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:u=>u["x-component"]==="Space"||u["x-component"].endsWith("ActionBar"),confirm:{title:l("Delete action")}})]})},H=g.createContext(null);H.displayName="ImportContext";const Y=()=>g.useContext(H);var U=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{},Q={exports:{}};(function(t,e){(function(l,p){p()})(U,function(){function l(o,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(o.type)?new Blob(["\uFEFF",o],{type:o.type}):o}function p(o,r,h){var d=new XMLHttpRequest;d.open("GET",o),d.responseType="blob",d.onload=function(){f(d.response,r,h)},d.onerror=function(){console.error("could not download file")},d.send()}function x(o){var r=new XMLHttpRequest;r.open("HEAD",o,!1);try{r.send()}catch(h){}return 200<=r.status&&299>=r.status}function s(o){try{o.dispatchEvent(new MouseEvent("click"))}catch(h){var r=document.createEvent("MouseEvents");r.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),o.dispatchEvent(r)}}var n=typeof window=="object"&&window.window===window?window:typeof self=="object"&&self.self===self?self:typeof U=="object"&&U.global===U?U:void 0,m=n.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),f=n.saveAs||(typeof window!="object"||window!==n?function(){}:"download"in HTMLAnchorElement.prototype&&!m?function(o,r,h){var d=n.URL||n.webkitURL,u=document.createElement("a");r=r||o.name||"download",u.download=r,u.rel="noopener",typeof o=="string"?(u.href=o,u.origin===location.origin?s(u):x(u.href)?p(o,r,h):s(u,u.target="_blank")):(u.href=d.createObjectURL(o),setTimeout(function(){d.revokeObjectURL(u.href)},4e4),setTimeout(function(){s(u)},0))}:"msSaveOrOpenBlob"in navigator?function(o,r,h){if(r=r||o.name||"download",typeof o!="string")navigator.msSaveOrOpenBlob(l(o,h),r);else if(x(o))p(o,r,h);else{var d=document.createElement("a");d.href=o,d.target="_blank",setTimeout(function(){s(d)})}}:function(o,r,h,d){if(d=d||open("","_blank"),d&&(d.document.title=d.document.body.innerText="downloading..."),typeof o=="string")return p(o,r,h);var u=o.type==="application/octet-stream",I=/constructor/i.test(n.HTMLElement)||n.safari,v=/CriOS\/[\d]+/.test(navigator.userAgent);if((v||u&&I||m)&&typeof FileReader!="undefined"){var A=new FileReader;A.onloadend=function(){var w=A.result;w=v?w:w.replace(/^data:[^;]*;/,"data:attachment/file;"),d?d.location.href=w:location=w,d=null},A.readAsDataURL(o)}else{var b=n.URL||n.webkitURL,S=b.createObjectURL(o);d?d.location=S:location.href=S,d=null,setTimeout(function(){b.revokeObjectURL(S)},4e4)}});n.saveAs=f.saveAs=f,t.exports=f})})(Q);var Z=Q.exports;const D={IMPORTING:1,IMPORTED:2},ve=t=>{const{t:e}=F.useTranslation(C),{importModalVisible:l,importStatus:p,importResult:x,setImportModalVisible:s}=Y(),{data:n,meta:m}=x!=null?x:{},f=()=>{s(!1)},o=()=>{const r=new Int8Array(n==null?void 0:n.data),h=new Blob([r],{type:"application/x-xls"});Z.saveAs(h,"fail.xlsx")};return a.jsx(E.Modal,{title:e("Import Data"),width:"50%",styles:{body:{height:"calc(80vh - 200px)"}},open:l,footer:null,closable:p===D.IMPORTED,onCancel:f,children:a.jsxs("div",{className:i.css`
28
+ `}}}}}},beforeUploadHandler(){return!1},uploadValidator(c,x){var r;if(c.length>1)return{type:"error",message:t("Only one file is allowed to be uploaded")};const i=(r=c[0])!=null?r:{};return i.size>10*1024*1024?{type:"error",message:t("File size cannot exceed 10M")}:Ie.includes(i.type)?"":{type:"error",message:t("Please upload the file of Excel")}},validateUpload(c,x,i){var u;const[r]=i;x.disabled=(r==null?void 0:r.length)===0,x.componentProps=he(O({},x.componentProps),{disabled:(r==null?void 0:r.length)===0||((u=c.errors)==null?void 0:u.length)>0})}}},Y=()=>{var u,f,o,n,h,m;const t=M.useField(),e=M.useFieldSchema(),{t:l}=F.useTranslation(),{dn:c}=s.useDesignable(),[x,i]=g.useState(),{importSettingsSchema:r}=z();return g.useEffect(()=>{i(r)},[t.address,(u=e==null?void 0:e["x-action-settings"])==null?void 0:u.importSettings]),a.jsxs(s.GeneralSchemaDesigner,{disableInitializer:!0,children:[a.jsx(s.SchemaSettingsModalItem,{title:l("Edit button"),schema:{type:"object",title:l("Edit button"),properties:{title:{"x-decorator":"FormItem","x-component":"Input",title:l("Button title"),default:e.title,"x-component-props":{}},icon:{"x-decorator":"FormItem","x-component":"IconPicker",title:l("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:l("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:d,icon:I,type:A})=>{e.title=d,t.title=d,t.componentProps.icon=I,t.componentProps.danger=A==="danger",t.componentProps.type=A,e["x-component-props"]=e["x-component-props"]||{},e["x-component-props"].icon=I,e["x-component-props"].danger=A==="danger",e["x-component-props"].type=A,c.emit("patch",{schema:{"x-uid":e["x-uid"],title:d,"x-component-props":O({},e["x-component-props"])}}),c.refresh()}}),a.jsx(s.SchemaSettingsActionModalItem,{title:l("Importable fields"),schema:x,initialValues:O({},(m=(h=e==null?void 0:e["x-action-settings"])==null?void 0:h.importSettings)!=null?m:{}),components:{ArrayItems:N.ArrayItems},onSubmit:({importColumns:d,explain:I})=>{const A=d==null?void 0:d.filter(v=>{var b;return(b=v==null?void 0:v.dataIndex)==null?void 0:b.length}).map(v=>({dataIndex:v.dataIndex.map(b=>{var S;return(S=b.name)!=null?S:b}),title:v.title}));e["x-action-settings"].importSettings={importColumns:A,explain:I},c.emit("patch",{schema:{"x-uid":e["x-uid"],"x-action-settings":e["x-action-settings"]}}),c.refresh()}}),a.jsx(s.SchemaSettingsDivider,{}),a.jsx(s.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:d=>d["x-component"]==="Space"||d["x-component"].endsWith("ActionBar"),confirm:{title:l("Delete action")}})]})},H=g.createContext(null);H.displayName="ImportContext";const Q=()=>g.useContext(H);var k=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{},Z={exports:{}};(function(t,e){(function(l,c){c()})(k,function(){function l(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 c(o,n,h){var m=new XMLHttpRequest;m.open("GET",o),m.responseType="blob",m.onload=function(){f(m.response,n,h)},m.onerror=function(){console.error("could not download file")},m.send()}function x(o){var n=new XMLHttpRequest;n.open("HEAD",o,!1);try{n.send()}catch(h){}return 200<=n.status&&299>=n.status}function i(o){try{o.dispatchEvent(new MouseEvent("click"))}catch(h){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 r=typeof window=="object"&&window.window===window?window:typeof self=="object"&&self.self===self?self:typeof k=="object"&&k.global===k?k:void 0,u=r.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),f=r.saveAs||(typeof window!="object"||window!==r?function(){}:"download"in HTMLAnchorElement.prototype&&!u?function(o,n,h){var m=r.URL||r.webkitURL,d=document.createElement("a");n=n||o.name||"download",d.download=n,d.rel="noopener",typeof o=="string"?(d.href=o,d.origin===location.origin?i(d):x(d.href)?c(o,n,h):i(d,d.target="_blank")):(d.href=m.createObjectURL(o),setTimeout(function(){m.revokeObjectURL(d.href)},4e4),setTimeout(function(){i(d)},0))}:"msSaveOrOpenBlob"in navigator?function(o,n,h){if(n=n||o.name||"download",typeof o!="string")navigator.msSaveOrOpenBlob(l(o,h),n);else if(x(o))c(o,n,h);else{var m=document.createElement("a");m.href=o,m.target="_blank",setTimeout(function(){i(m)})}}:function(o,n,h,m){if(m=m||open("","_blank"),m&&(m.document.title=m.document.body.innerText="downloading..."),typeof o=="string")return c(o,n,h);var d=o.type==="application/octet-stream",I=/constructor/i.test(r.HTMLElement)||r.safari,A=/CriOS\/[\d]+/.test(navigator.userAgent);if((A||d&&I||u)&&typeof FileReader!="undefined"){var v=new FileReader;v.onloadend=function(){var C=v.result;C=A?C:C.replace(/^data:[^;]*;/,"data:attachment/file;"),m?m.location.href=C:location=C,m=null},v.readAsDataURL(o)}else{var b=r.URL||r.webkitURL,S=b.createObjectURL(o);m?m.location=S:location.href=S,m=null,setTimeout(function(){b.revokeObjectURL(S)},4e4)}});r.saveAs=f.saveAs=f,t.exports=f})})(Z);var ee=Z.exports;const D={IMPORTING:1,IMPORTED:2},ve=t=>{const{t:e}=F.useTranslation(T),{importModalVisible:l,importStatus:c,importResult:x,setImportModalVisible:i}=Q(),{data:r,meta:u}=x!=null?x:{},f=()=>{i(!1)},o=()=>{const n=new Int8Array(r==null?void 0:r.data),h=new Blob([n],{type:"application/x-xls"});ee.saveAs(h,"fail.xlsx")};return a.jsx(E.Modal,{title:e("Import Data"),width:"50%",styles:{body:{height:"calc(80vh - 200px)"}},open:l,footer:null,closable:c===D.IMPORTED,onCancel:f,children:a.jsxs("div",{className:s.css`
29
29
  display: flex;
30
30
  justify-content: center;
31
31
  align-items: center;
32
32
  height: 100%;
33
- `,children:[p===D.IMPORTING&&a.jsx(E.Spin,{indicator:a.jsx(R.LoadingOutlined,{style:{fontSize:24},spin:!0}),tip:e("Excel data importing")}),p===D.IMPORTED&&a.jsxs(E.Space,{direction:"vertical",align:"center",children:[a.jsx(R.ExclamationCircleFilled,{style:{fontSize:72,color:"#1890ff"}}),a.jsx("p",{children:e("{{successCount}} records have been successfully imported",O({},m!=null?m:{}))}),a.jsxs(E.Space,{children:[(m==null?void 0:m.failureCount)>0&&a.jsx(E.Button,{onClick:o,children:e("To download the failure data")}),a.jsx(E.Button,{type:"primary",onClick:f,children:e("Done")})]})]})]})})},ee=t=>{let e=t;for(;e&&e["x-action"]!=="importXlsx";)e=e.parent;return{schema:e}},te=t=>!t||!Array.isArray(t)?[]:t,oe=()=>{const{service:t,resource:e}=i.useBlockRequestContext();i.useAPIClient();const l=M.useFieldSchema(),p=i.useCompile(),{getCollectionJoinField:x,getCollectionField:s}=i.useCollectionManager_deprecated(),{name:n,title:m,getField:f}=i.useCollection_deprecated();F.useTranslation(C);const{schema:o}=ee(l);return{run(){return q(this,null,function*(){var A,b;const{importColumns:h,explain:d}=$.cloneDeep((b=(A=o==null?void 0:o["x-action-settings"])==null?void 0:A.importSettings)!=null?b:{}),u=te(h).map(S=>{var ie,k;const w=s(`${n}.${S.dataIndex[0]}`);if(w){if(S.defaultTitle=p((ie=w==null?void 0:w.uiSchema)==null?void 0:ie.title)||w.name,S.dataIndex.length>1){const P=x(`${n}.${S.dataIndex.join(".")}`);if(!P)return;S.defaultTitle=S.defaultTitle+"/"+p((k=P==null?void 0:P.uiSchema)==null?void 0:k.title)||P.name}return w.interface==="chinaRegion"&&S.dataIndex.push("name"),S}}).filter(Boolean),{data:I}=yield e.downloadXlsxTemplate({values:{title:p(m),explain:d,columns:p(u)}},{method:"post",responseType:"blob"}),v=new Blob([I],{type:"application/x-xls"});Z.saveAs(v,`${p(m)}.xlsx`)})}}},ne=()=>{var k;const{service:t,resource:e}=i.useBlockRequestContext(),l=i.useAPIClient(),p=M.useFieldSchema(),x=i.useCompile(),{getCollectionJoinField:s,getCollectionField:n}=i.useCollectionManager_deprecated(),{name:m,title:f,getField:o}=i.useCollection_deprecated();F.useTranslation(C);const{schema:r}=ee(p),h=M.useForm(),{setVisible:d,fieldSchema:u}=i.useActionContext(),{setImportModalVisible:I,setImportStatus:v,setImportResult:A}=Y(),{upload:b}=h.values,S=i.useDataBlockProps()||{},w=i.useDataSourceHeaders(S.dataSource);return g.useEffect(()=>{h.reset()},[]),{run(){return q(this,null,function*(){var ce,pe,le;const{importColumns:P,explain:Ae}=$.cloneDeep((pe=(ce=r==null?void 0:r["x-action-settings"])==null?void 0:ce.importSettings)!=null?pe:{}),be=te(P).map(T=>{var de,me;const B=n(`${m}.${T.dataIndex[0]}`);if(B){if(T.defaultTitle=x((de=B==null?void 0:B.uiSchema)==null?void 0:de.title)||B.name,T.dataIndex.length>1){const L=s(`${m}.${T.dataIndex.join(".")}`);if(!L)return;T.defaultTitle=T.defaultTitle+"/"+x((me=L==null?void 0:L.uiSchema)==null?void 0:me.title)||L.name}return B.interface==="chinaRegion"&&T.dataIndex.push("name"),T}}).filter(Boolean),_=new FormData,we=h.values.upload.map(T=>T.originFileObj);_.append("file",we[0]),_.append("columns",JSON.stringify(be)),_.append("explain",Ae),d(!1),I(!0),v(D.IMPORTING);try{const{data:T}=yield l.axios.post(`${m}:importXlsx`,_,{headers:w,timeout:6e5});A(T),h.reset(),yield(le=t==null?void 0:t.refresh)==null?void 0:le.call(t),v(D.IMPORTED)}catch(T){I(!1),d(!0)}})},disabled:(b==null?void 0:b.length)===0||((k=h.errors)==null?void 0:k.length)>0}},re=t=>{const{uploadValidator:e,beforeUploadHandler:l,validateUpload:p}=z();return a.jsx(i.SchemaComponentOptions,{components:{ImportActionInitializer:J,ImportDesigner:K,ImportWarning:G,DownloadTips:W},scope:{uploadValidator:e,validateUpload:p,beforeUploadHandler:l,useDownloadXlsxTemplateAction:oe,useImportStartAction:ne},children:a.jsx(ae,{children:t.children})})},ae=t=>{const[e,l]=g.useState(!1),[p,x]=g.useState(D.IMPORTING),[s,n]=g.useState(null);return a.jsxs(H.Provider,{value:{importModalVisible:e,setImportModalVisible:l,importStatus:p,setImportStatus:x,importResult:s,setImportResult:n},children:[j.createPortal(a.jsx(ve,{}),document.body),t.children]})},Se=new i.SchemaSettings({name:"actionSettings:import",items:[{name:"editButton",Component:i.ButtonEditor,useComponentProps(){const{buttonEditorProps:t}=i.useSchemaToolbar();return t}},{name:"importableFields",type:"actionModal",useComponentProps(){var m,f,o;const t=M.useField(),e=M.useFieldSchema(),{t:l}=F.useTranslation(),{dn:p}=i.useDesignable(),[x,s]=g.useState(),{importSettingsSchema:n}=z();return g.useEffect(()=>{s(n)},[t.address,(m=e==null?void 0:e["x-action-settings"])==null?void 0:m.importSettings]),{title:l("Importable fields"),schema:x,initialValues:O({},(o=(f=e==null?void 0:e["x-action-settings"])==null?void 0:f.importSettings)!=null?o:{}),components:{ArrayItems:N.ArrayItems},onSubmit:({importColumns:r,explain:h})=>{const d=r==null?void 0:r.filter(u=>{var I;return(I=u==null?void 0:u.dataIndex)==null?void 0:I.length}).map(u=>({dataIndex:u.dataIndex.map(I=>{var v;return(v=I.name)!=null?v:I}),title:u.title}));e["x-action-settings"].importSettings={importColumns:d,explain:h},p.emit("patch",{schema:{"x-uid":e["x-uid"],"x-action-settings":e["x-action-settings"]}}),p.refresh()}}}},{name:"divider",type:"divider"},{name:"delete",type:"remove",useComponentProps(){const{t}=F.useTranslation();return{removeParentsIfNoChildren:!0,breakRemoveOn:e=>e["x-component"]==="Space"||e["x-component"].endsWith("ActionBar"),confirm:{title:t("Delete action")}}}}]});class se extends i.Plugin{load(){return q(this,null,function*(){this.app.use(re);const e={title:"{{t('Import')}}",Component:"ImportActionInitializer",schema:{"x-align":"right","x-decorator":"ACLActionProvider","x-acl-action":"importXlsx","x-acl-action-props":{skipScopeCheck:!0}},useVisible:()=>i.useActionAvailable("import")},l=this.app.schemaInitializerManager.get("table:configureActions");l==null||l.add("enableActions.import",e),this.app.schemaInitializerManager.addItem("gantt:configureActions","enableActions.import",e),this.app.schemaSettingsManager.add(Se)})}}c.DownloadTips=W,c.ImportActionInitializer=J,c.ImportContextProvider=ae,c.ImportDesigner=K,c.ImportPluginProvider=re,c.ImportWarning=G,c.PluginActionImportClient=se,c.default=se,c.useDownloadXlsxTemplateAction=oe,c.useImportStartAction=ne,Object.defineProperties(c,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
33
+ `,children:[c===D.IMPORTING&&a.jsx(E.Spin,{indicator:a.jsx($.LoadingOutlined,{style:{fontSize:24},spin:!0}),tip:e("Excel data importing")}),c===D.IMPORTED&&a.jsxs(E.Space,{direction:"vertical",align:"center",children:[a.jsx($.ExclamationCircleFilled,{style:{fontSize:72,color:"#1890ff"}}),a.jsx("p",{children:e("{{successCount}} records have been successfully imported",O({},u!=null?u:{}))}),a.jsxs(E.Space,{children:[(u==null?void 0:u.failureCount)>0&&a.jsx(E.Button,{onClick:o,children:e("To download the failure data")}),a.jsx(E.Button,{type:"primary",onClick:f,children:e("Done")})]})]})]})})},te=t=>{let e=t;for(;e&&e["x-action"]!=="importXlsx";)e=e.parent;return{schema:e}},oe=t=>!t||!Array.isArray(t)?[]:t,ne=()=>{const{service:t,resource:e}=s.useBlockRequestContext();s.useAPIClient();const l=M.useFieldSchema(),c=s.useCompile(),{getCollectionJoinField:x,getCollectionField:i}=s.useCollectionManager_deprecated(),{name:r,title:u,getField:f}=s.useCollection_deprecated();F.useTranslation(T);const{schema:o}=te(l);return{run(){return R(this,null,function*(){var v,b;const{importColumns:h,explain:m}=V.cloneDeep((b=(v=o==null?void 0:o["x-action-settings"])==null?void 0:v.importSettings)!=null?b:{}),d=oe(h).map(S=>{var U,_;const C=i(`${r}.${S.dataIndex[0]}`);if(C){if(S.defaultTitle=c((U=C==null?void 0:C.uiSchema)==null?void 0:U.title)||C.name,S.dataIndex.length>1){const P=x(`${r}.${S.dataIndex.join(".")}`);if(!P)return;S.defaultTitle=S.defaultTitle+"/"+c((_=P==null?void 0:P.uiSchema)==null?void 0:_.title)||P.name}return C.interface==="chinaRegion"&&S.dataIndex.push("name"),S}}).filter(Boolean),{data:I}=yield e.downloadXlsxTemplate({values:{title:c(u),explain:m,columns:c(d)}},{method:"post",responseType:"blob"}),A=new Blob([I],{type:"application/x-xls"});ee.saveAs(A,`${c(u)}.xlsx`)})}}},re=()=>{var U;const{service:t,resource:e}=s.useBlockRequestContext();s.useAPIClient();const l=M.useFieldSchema(),c=s.useCompile(),{getCollectionJoinField:x,getCollectionField:i}=s.useCollectionManager_deprecated(),{name:r,title:u,getField:f}=s.useCollection_deprecated();F.useTranslation(T);const{schema:o}=te(l),n=M.useForm(),{setVisible:h,fieldSchema:m}=s.useActionContext(),{setImportModalVisible:d,setImportStatus:I,setImportResult:A}=Q(),{upload:v}=n.values,b=s.useDataBlockProps()||{};s.useDataSourceHeaders(b.dataSource);const S=s.useDataBlockResource();return g.useEffect(()=>{n.reset()},[]),{run(){return R(this,null,function*(){var ce,pe,le;const{importColumns:_,explain:P}=V.cloneDeep((pe=(ce=o==null?void 0:o["x-action-settings"])==null?void 0:ce.importSettings)!=null?pe:{}),Ae=oe(_).map(w=>{var de,me;const B=i(`${r}.${w.dataIndex[0]}`);if(B){if(w.defaultTitle=c((de=B==null?void 0:B.uiSchema)==null?void 0:de.title)||B.name,w.dataIndex.length>1){const L=x(`${r}.${w.dataIndex.join(".")}`);if(!L)return;w.defaultTitle=w.defaultTitle+"/"+c((me=L==null?void 0:L.uiSchema)==null?void 0:me.title)||L.name}return B.interface==="chinaRegion"&&w.dataIndex.push("name"),w}}).filter(Boolean),q=new FormData,be=n.values.upload.map(w=>w.originFileObj);q.append("file",be[0]),q.append("columns",JSON.stringify(Ae)),q.append("explain",P),h(!1),d(!0),I(D.IMPORTING);try{const{data:w}=yield S.importXlsx({values:q},{timeout:6e5});A(w),n.reset(),yield(le=t==null?void 0:t.refresh)==null?void 0:le.call(t),I(D.IMPORTED)}catch(w){d(!1),h(!0)}})},disabled:(v==null?void 0:v.length)===0||((U=n.errors)==null?void 0:U.length)>0}},ae=t=>{const{uploadValidator:e,beforeUploadHandler:l,validateUpload:c}=z();return a.jsx(s.SchemaComponentOptions,{components:{ImportActionInitializer:K,ImportDesigner:Y,ImportWarning:W,DownloadTips:J},scope:{uploadValidator:e,validateUpload:c,beforeUploadHandler:l,useDownloadXlsxTemplateAction:ne,useImportStartAction:re},children:a.jsx(se,{children:t.children})})},se=t=>{const[e,l]=g.useState(!1),[c,x]=g.useState(D.IMPORTING),[i,r]=g.useState(null);return a.jsxs(H.Provider,{value:{importModalVisible:e,setImportModalVisible:l,importStatus:c,setImportStatus:x,importResult:i,setImportResult:r},children:[j.createPortal(a.jsx(ve,{}),document.body),t.children]})},Se=new s.SchemaSettings({name:"actionSettings:import",items:[{name:"editButton",Component:s.ButtonEditor,useComponentProps(){const{buttonEditorProps:t}=s.useSchemaToolbar();return t}},{name:"importableFields",type:"actionModal",useComponentProps(){var u,f,o;const t=M.useField(),e=M.useFieldSchema(),{t:l}=F.useTranslation(),{dn:c}=s.useDesignable(),[x,i]=g.useState(),{importSettingsSchema:r}=z();return g.useEffect(()=>{i(r)},[t.address,(u=e==null?void 0:e["x-action-settings"])==null?void 0:u.importSettings]),{title:l("Importable fields"),schema:x,initialValues:O({},(o=(f=e==null?void 0:e["x-action-settings"])==null?void 0:f.importSettings)!=null?o:{}),components:{ArrayItems:N.ArrayItems},onSubmit:({importColumns:n,explain:h})=>{const m=n==null?void 0:n.filter(d=>{var I;return(I=d==null?void 0:d.dataIndex)==null?void 0:I.length}).map(d=>({dataIndex:d.dataIndex.map(I=>{var A;return(A=I.name)!=null?A:I}),title:d.title}));e["x-action-settings"].importSettings={importColumns:m,explain:h},c.emit("patch",{schema:{"x-uid":e["x-uid"],"x-action-settings":e["x-action-settings"]}}),c.refresh()}}}},{name:"divider",type:"divider"},{name:"delete",type:"remove",useComponentProps(){const{t}=F.useTranslation();return{removeParentsIfNoChildren:!0,breakRemoveOn:e=>e["x-component"]==="Space"||e["x-component"].endsWith("ActionBar"),confirm:{title:t("Delete action")}}}}]});class ie extends s.Plugin{load(){return R(this,null,function*(){this.app.use(ae);const e={title:"{{t('Import')}}",Component:"ImportActionInitializer",schema:{"x-align":"right","x-decorator":"ACLActionProvider","x-acl-action":"importXlsx","x-acl-action-props":{skipScopeCheck:!0}},useVisible:()=>s.useActionAvailable("import")},l=this.app.schemaInitializerManager.get("table:configureActions");l==null||l.add("enableActions.import",e),this.app.schemaInitializerManager.addItem("gantt:configureActions","enableActions.import",e),this.app.schemaSettingsManager.add(Se)})}}p.DownloadTips=J,p.ImportActionInitializer=K,p.ImportContextProvider=se,p.ImportDesigner=Y,p.ImportPluginProvider=ae,p.ImportWarning=W,p.PluginActionImportClient=ie,p.default=ie,p.useDownloadXlsxTemplateAction=ne,p.useImportStartAction=re,Object.defineProperties(p,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
@@ -10,7 +10,7 @@
10
10
  module.exports = {
11
11
  "@formily/react": "2.3.0",
12
12
  "@formily/shared": "2.3.2",
13
- "@nocobase/client": "1.5.0-beta.2",
13
+ "@nocobase/client": "1.5.0-beta.3",
14
14
  "antd": "5.12.8",
15
15
  "react": "18.2.0",
16
16
  "@formily/antd-v5": "1.1.9",
@@ -19,12 +19,12 @@ module.exports = {
19
19
  "react-dom": "18.2.0",
20
20
  "lodash": "4.17.21",
21
21
  "@formily/core": "2.3.0",
22
- "@nocobase/server": "1.5.0-beta.2",
23
- "@nocobase/actions": "1.5.0-beta.2",
24
- "@nocobase/database": "1.5.0-beta.2",
22
+ "@nocobase/server": "1.5.0-beta.3",
23
+ "@nocobase/actions": "1.5.0-beta.3",
24
+ "@nocobase/database": "1.5.0-beta.3",
25
25
  "async-mutex": "0.3.2",
26
- "@nocobase/data-source-manager": "1.5.0-beta.2",
27
- "@nocobase/utils": "1.5.0-beta.2",
26
+ "@nocobase/data-source-manager": "1.5.0-beta.3",
27
+ "@nocobase/utils": "1.5.0-beta.3",
28
28
  "sequelize": "6.35.2",
29
29
  "mathjs": "10.6.4"
30
30
  };
@@ -1 +1 @@
1
- {"name":"xlsx","version":"0.20.2","author":"sheetjs","description":"SheetJS Spreadsheet data parser and writer","keywords":["excel","xls","xlsx","xlsb","xlsm","ods","csv","dbf","dif","sylk","office","spreadsheet"],"bin":{"xlsx":"./bin/xlsx.njs"},"main":"xlsx.js","module":"xlsx.mjs","unpkg":"dist/xlsx.full.min.js","jsdelivr":"dist/xlsx.full.min.js","types":"types/index.d.ts","exports":{".":{"import":"./xlsx.mjs","require":"./xlsx.js","types":"./types/index.d.ts"},"./xlsx.mjs":{"import":"./xlsx.mjs","types":"./types/index.d.ts"},"./xlsx.js":{"require":"./xlsx.js","types":"./types/index.d.ts"},"./dist/xlsx.core.min":{"import":"./dist/xlsx.core.min.js","require":"./dist/xlsx.core.min.js","types":"./types/index.d.ts"},"./dist/xlsx.core.min.js":{"import":"./dist/xlsx.core.min.js","require":"./dist/xlsx.core.min.js","types":"./types/index.d.ts"},"./dist/xlsx.full.min":{"import":"./dist/xlsx.full.min.js","require":"./dist/xlsx.full.min.js","types":"./types/index.d.ts"},"./dist/xlsx.full.min.js":{"import":"./dist/xlsx.full.min.js","require":"./dist/xlsx.full.min.js","types":"./types/index.d.ts"},"./dist/xlsx.mini.min":{"import":"./dist/xlsx.mini.min.js","require":"./dist/xlsx.mini.min.js","types":"./types/index.d.ts"},"./dist/xlsx.mini.min.js":{"import":"./dist/xlsx.mini.min.js","require":"./dist/xlsx.mini.min.js","types":"./types/index.d.ts"},"./dist/xlsx.zahl":{"import":"./dist/xlsx.zahl.mjs","require":"./dist/xlsx.zahl.js","types":"./dist/zahl.d.ts"},"./dist/xlsx.zahl.mjs":{"import":"./dist/xlsx.zahl.mjs","types":"./dist/zahl.d.ts"},"./dist/xlsx.zahl.js":{"require":"./dist/xlsx.zahl.js","types":"./dist/zahl.d.ts"},"./dist/cpexcel":{"import":"./dist/cpexcel.full.mjs","require":"./dist/cpexcel.js","types":"./dist/cpexcel.d.ts"},"./dist/cpexcel.js":{"require":"./dist/cpexcel.js","types":"./dist/cpexcel.d.ts"},"./dist/cpexcel.full":{"import":"./dist/cpexcel.full.mjs","require":"./dist/cpexcel.js","types":"./dist/cpexcel.d.ts"},"./dist/cpexcel.full.mjs":{"import":"./dist/cpexcel.full.mjs","types":"./dist/cpexcel.d.ts"}},"browser":{"buffer":false,"crypto":false,"stream":false,"process":false,"fs":false},"sideEffects":false,"dependencies":{},"devDependencies":{"@sheetjs/uglify-js":"~2.7.3","@types/node":"^8.5.9","acorn":"7.4.1","adler-32":"~1.3.1","alex":"8.1.1","blanket":"~1.2.3","cfb":"~1.2.2","codepage":"~1.15.0","commander":"~2.17.1","crc-32":"~1.2.2","dtslint":"^0.1.2","eslint":"7.23.0","eslint-plugin-html":"^6.1.2","eslint-plugin-json":"^2.1.2","exit-on-epipe":"~1.0.1","fflate":"^0.7.1","jsdom":"~11.1.0","markdown-spellcheck":"^1.3.1","mocha":"~2.5.3","sinon":"^1.17.7","ssf":"~0.11.2","typescript":"2.2.0","wmf":"~1.0.1","word":"~0.3.0"},"repository":{"type":"git","url":"https://git.sheetjs.com/SheetJS/sheetjs"},"scripts":{"pretest":"npm run lint","test":"npm run tests-only","pretest-only":"git submodule init && git submodule update","tests-only":"make travis","build":"make","lint":"make fullint","dtslint":"dtslint types"},"config":{"blanket":{"pattern":"xlsx.js"}},"alex":{"allow":["chinese","special","simple","just","crash","wtf","holes"]},"homepage":"https://sheetjs.com/","files":["CHANGELOG.md","LICENSE","README.md","bower.json","package.json","xlsx.js","xlsx.mjs","xlsxworker.js","bin/xlsx.njs","dist/LICENSE","dist/*.mjs","dist/*.js","dist/*.map","dist/*.d.ts","types/index.d.ts","types/tsconfig.json"],"bugs":{"url":"https://git.sheetjs.com/SheetJS/sheetjs/issues"},"license":"Apache-2.0","engines":{"node":">=0.8"},"_lastModified":"2024-12-06T08:56:34.333Z"}
1
+ {"name":"xlsx","version":"0.20.2","author":"sheetjs","description":"SheetJS Spreadsheet data parser and writer","keywords":["excel","xls","xlsx","xlsb","xlsm","ods","csv","dbf","dif","sylk","office","spreadsheet"],"bin":{"xlsx":"./bin/xlsx.njs"},"main":"xlsx.js","module":"xlsx.mjs","unpkg":"dist/xlsx.full.min.js","jsdelivr":"dist/xlsx.full.min.js","types":"types/index.d.ts","exports":{".":{"import":"./xlsx.mjs","require":"./xlsx.js","types":"./types/index.d.ts"},"./xlsx.mjs":{"import":"./xlsx.mjs","types":"./types/index.d.ts"},"./xlsx.js":{"require":"./xlsx.js","types":"./types/index.d.ts"},"./dist/xlsx.core.min":{"import":"./dist/xlsx.core.min.js","require":"./dist/xlsx.core.min.js","types":"./types/index.d.ts"},"./dist/xlsx.core.min.js":{"import":"./dist/xlsx.core.min.js","require":"./dist/xlsx.core.min.js","types":"./types/index.d.ts"},"./dist/xlsx.full.min":{"import":"./dist/xlsx.full.min.js","require":"./dist/xlsx.full.min.js","types":"./types/index.d.ts"},"./dist/xlsx.full.min.js":{"import":"./dist/xlsx.full.min.js","require":"./dist/xlsx.full.min.js","types":"./types/index.d.ts"},"./dist/xlsx.mini.min":{"import":"./dist/xlsx.mini.min.js","require":"./dist/xlsx.mini.min.js","types":"./types/index.d.ts"},"./dist/xlsx.mini.min.js":{"import":"./dist/xlsx.mini.min.js","require":"./dist/xlsx.mini.min.js","types":"./types/index.d.ts"},"./dist/xlsx.zahl":{"import":"./dist/xlsx.zahl.mjs","require":"./dist/xlsx.zahl.js","types":"./dist/zahl.d.ts"},"./dist/xlsx.zahl.mjs":{"import":"./dist/xlsx.zahl.mjs","types":"./dist/zahl.d.ts"},"./dist/xlsx.zahl.js":{"require":"./dist/xlsx.zahl.js","types":"./dist/zahl.d.ts"},"./dist/cpexcel":{"import":"./dist/cpexcel.full.mjs","require":"./dist/cpexcel.js","types":"./dist/cpexcel.d.ts"},"./dist/cpexcel.js":{"require":"./dist/cpexcel.js","types":"./dist/cpexcel.d.ts"},"./dist/cpexcel.full":{"import":"./dist/cpexcel.full.mjs","require":"./dist/cpexcel.js","types":"./dist/cpexcel.d.ts"},"./dist/cpexcel.full.mjs":{"import":"./dist/cpexcel.full.mjs","types":"./dist/cpexcel.d.ts"}},"browser":{"buffer":false,"crypto":false,"stream":false,"process":false,"fs":false},"sideEffects":false,"dependencies":{},"devDependencies":{"@sheetjs/uglify-js":"~2.7.3","@types/node":"^8.5.9","acorn":"7.4.1","adler-32":"~1.3.1","alex":"8.1.1","blanket":"~1.2.3","cfb":"~1.2.2","codepage":"~1.15.0","commander":"~2.17.1","crc-32":"~1.2.2","dtslint":"^0.1.2","eslint":"7.23.0","eslint-plugin-html":"^6.1.2","eslint-plugin-json":"^2.1.2","exit-on-epipe":"~1.0.1","fflate":"^0.7.1","jsdom":"~11.1.0","markdown-spellcheck":"^1.3.1","mocha":"~2.5.3","sinon":"^1.17.7","ssf":"~0.11.2","typescript":"2.2.0","wmf":"~1.0.1","word":"~0.3.0"},"repository":{"type":"git","url":"https://git.sheetjs.com/SheetJS/sheetjs"},"scripts":{"pretest":"npm run lint","test":"npm run tests-only","pretest-only":"git submodule init && git submodule update","tests-only":"make travis","build":"make","lint":"make fullint","dtslint":"dtslint types"},"config":{"blanket":{"pattern":"xlsx.js"}},"alex":{"allow":["chinese","special","simple","just","crash","wtf","holes"]},"homepage":"https://sheetjs.com/","files":["CHANGELOG.md","LICENSE","README.md","bower.json","package.json","xlsx.js","xlsx.mjs","xlsxworker.js","bin/xlsx.njs","dist/LICENSE","dist/*.mjs","dist/*.js","dist/*.map","dist/*.d.ts","types/index.d.ts","types/tsconfig.json"],"bugs":{"url":"https://git.sheetjs.com/SheetJS/sheetjs/issues"},"license":"Apache-2.0","engines":{"node":">=0.8"},"_lastModified":"2024-12-10T07:14:31.544Z"}
@@ -66,7 +66,8 @@ async function importXlsxAction(ctx, next) {
66
66
  collection,
67
67
  columns,
68
68
  workbook,
69
- explain: ctx.request.body.explain
69
+ explain: ctx.request.body.explain,
70
+ repository
70
71
  });
71
72
  const importedCount = await importer.run({
72
73
  context: ctx
@@ -22,6 +22,7 @@ type ImporterOptions = {
22
22
  workbook: WorkBook;
23
23
  chunkSize?: number;
24
24
  explain?: string;
25
+ repository?: any;
25
26
  };
26
27
  type RunOptions = {
27
28
  transaction?: Transaction;
@@ -29,6 +30,7 @@ type RunOptions = {
29
30
  };
30
31
  export declare class XlsxImporter extends EventEmitter {
31
32
  private options;
33
+ private repository;
32
34
  constructor(options: ImporterOptions);
33
35
  run(options?: RunOptions): Promise<number>;
34
36
  resetSeq(options?: RunOptions): Promise<void>;
@@ -49,7 +49,9 @@ class XlsxImporter extends import_events.default {
49
49
  if (options.columns.length == 0) {
50
50
  throw new Error(`columns is empty`);
51
51
  }
52
+ this.repository = options.repository ? options.repository : options.collection.repository;
52
53
  }
54
+ repository;
53
55
  async run(options = {}) {
54
56
  let transaction = options.transaction;
55
57
  if (!transaction && this.options.collectionManager.db) {
@@ -148,7 +150,7 @@ class XlsxImporter extends import_events.default {
148
150
  }
149
151
  rowValues[dataKey] = await interfaceInstance.toValue(this.trimString(str), ctx);
150
152
  }
151
- await this.options.collection.repository.create({
153
+ await this.repository.create({
152
154
  values: rowValues,
153
155
  context: options == null ? void 0 : options.context,
154
156
  transaction
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "displayName.zh-CN": "操作:导入记录",
5
5
  "description": "Import records using excel templates. You can configure which fields to import and templates will be generated automatically.",
6
6
  "description.zh-CN": "使用 Excel 模板导入数据,可以配置导入哪些字段,自动生成模板。",
7
- "version": "1.5.0-beta.2",
7
+ "version": "1.5.0-beta.3",
8
8
  "license": "AGPL-3.0",
9
9
  "main": "./dist/server/index.js",
10
10
  "homepage": "https://docs.nocobase.com/handbook/action-import",
@@ -34,7 +34,7 @@
34
34
  "@nocobase/test": "1.x",
35
35
  "@nocobase/utils": "1.x"
36
36
  },
37
- "gitHead": "8a9c29fdac5c6295dcc7abf00c3fa81bd9e01a36",
37
+ "gitHead": "81afcf4affdb652faf4636e6d9351828ce8906be",
38
38
  "keywords": [
39
39
  "Actions"
40
40
  ]