@nocobase/plugin-action-import 1.2.16-alpha → 1.2.17-alpha

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,i){typeof exports=="object"&&typeof module!="undefined"?i(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"],i):(c=typeof globalThis!="undefined"?globalThis:c||self,i(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,i,y,p,E,M,k,F,g,j,$,V){"use strict";var be=Object.defineProperty,we=Object.defineProperties;var Ce=Object.getOwnPropertyDescriptors;var ue=Object.getOwnPropertySymbols;var Te=Object.prototype.hasOwnProperty,Ee=Object.prototype.propertyIsEnumerable;var xe=(c,i,y)=>i in c?be(c,i,{enumerable:!0,configurable:!0,writable:!0,value:y}):c[i]=y,O=(c,i)=>{for(var y in i||(i={}))Te.call(i,y)&&xe(c,y,i[y]);if(ue)for(var y of ue(i))Ee.call(i,y)&&xe(c,y,i[y]);return c},fe=(c,i)=>we(c,Ce(i));var z=(c,i,y)=>new Promise((p,E)=>{var M=g=>{try{F(y.next(g))}catch(j){E(j)}},k=g=>{try{F(y.throw(g))}catch(j){E(j)}},F=g=>g.done?p(g.value):Promise.resolve(g.value).then(M,k);F((y=y.apply(c,i)).next())});const T="action-import",he="action-import";function X(){return M.useTranslation([he,"client"],{nsMode:"fallback"})}const ge=["id","createdAt","createdBy","updatedAt","updatedBy"],G=t=>{const{getCollectionFields:e}=p.useCollectionManager_deprecated(),l=e(t),n=(s,r)=>{var h;if(!s.interface||ge.includes(s.interface))return;const m={name:s.name,title:((h=s==null?void 0:s.uiSchema)==null?void 0:h.title)||s.name,schema:s==null?void 0:s.uiSchema};if(!s.target||r>=2)return m;if(s.target){const o=e(s.target),a=x(o,r+1).filter(Boolean);m.children=m.children||[],m.children.push(...a)}return m},x=(s,r)=>{const m=[];return s.forEach(h=>{const o=n(h,r);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:""}),W=()=>{const{t}=X();return i.jsx(E.Alert,{type:"warning",style:{marginBottom:"10px"},message:t("Import warnings",{limit:2e3})})},J=()=>{const{t}=X();return i.jsx(E.Alert,{type:"info",style:{marginBottom:"10px",whiteSpace:"pre-line"},message:t("Download tips")})},K=()=>{const t=p.useSchemaInitializerItem(),{insert:e}=p.useSchemaInitializer(),{name:l}=p.useCollection_deprecated(),n=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.Container","x-decorator":"Form","x-component-props":{width:"50%",className:p.css`
10
+ (function(p,s){typeof exports=="object"&&typeof module!="undefined"?s(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"],s):(p=typeof globalThis!="undefined"?globalThis:p||self,s(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,s,y,i,E,P,N,F,g,j,R,$){"use strict";var Ce=Object.defineProperty,Te=Object.defineProperties;var Ee=Object.getOwnPropertyDescriptors;var ue=Object.getOwnPropertySymbols;var Fe=Object.prototype.hasOwnProperty,Pe=Object.prototype.propertyIsEnumerable;var xe=(p,s,y)=>s in p?Ce(p,s,{enumerable:!0,configurable:!0,writable:!0,value:y}):p[s]=y,O=(p,s)=>{for(var y in s||(s={}))Fe.call(s,y)&&xe(p,y,s[y]);if(ue)for(var y of ue(s))Pe.call(s,y)&&xe(p,y,s[y]);return p},he=(p,s)=>Te(p,Ee(s));var q=(p,s,y)=>new Promise((i,E)=>{var P=g=>{try{F(y.next(g))}catch(j){E(j)}},N=g=>{try{F(y.throw(g))}catch(j){E(j)}},F=g=>g.done?i(g.value):Promise.resolve(g.value).then(P,N);F((y=y.apply(p,s)).next())});const T="action-import",fe="action-import";function V(){return P.useTranslation([fe,"client"],{nsMode:"fallback"})}const ge=["id","createdAt","createdBy","updatedAt","updatedBy"],X=t=>{const{getCollectionFields:e}=i.useCollectionManager_deprecated(),l=e(t),n=(c,r)=>{var f;if(!c.interface||ge.includes(c.interface))return;const m={name:c.name,title:((f=c==null?void 0:c.uiSchema)==null?void 0:f.title)||c.name,schema:c==null?void 0:c.uiSchema};if(!c.target||r>=2)return m;if(c.target){const o=e(c.target),a=x(o,r+1).filter(Boolean);m.children=m.children||[],m.children.push(...a)}return m},x=(c,r)=>{const m=[];return c.forEach(f=>{const o=n(f,r);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 s.jsx(E.Alert,{type:"warning",style:{marginBottom:"10px"},message:t("Import warnings",{limit:2e3})})},W=()=>{const{t}=V();return s.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(),n=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: "${T}" }) }}`,"x-component":"Action.Container","x-decorator":"Form","x-component-props":{width:"50%",className:i.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: "${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:p.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:i.css`
15
15
  margin-top: 5px;
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.Container.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 i.jsx(p.SchemaInitializerItem,{title:t.title,onClick:()=>{var r;x["x-action-settings"].importSettings=ye(n);const s=y.merge(x||{},t.schema||{});(r=t==null?void 0:t.schemaInitialize)==null||r.call(t,s),e(s)}})},Ie=["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.ms-excel"],H=()=>{const{t}=M.useTranslation(T),{name:e}=p.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:p.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.Container.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 s.jsx(i.SchemaInitializerItem,{title:t.title,onClick:()=>{var r;x["x-action-settings"].importSettings=ye(n);const c=y.merge(x||{},t.schema||{});(r=t==null?void 0:t.schemaInitialize)==null||r.call(t,c),e(c)}})},Ie=["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.ms-excel"],z=()=>{const{t}=P.useTranslation(T),{name:e}=i.useCollection_deprecated(),l=X(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:i.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":p.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:p.css`
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: "${T}"}) }}`,"x-component":"ArrayItems.Addition","x-component-props":{className:i.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(n,x){var r;if(n.length>1)return{type:"error",message:t("Only one file is allowed to be uploaded")};const s=(r=n[0])!=null?r:{};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(n,x,s){var m;const[r]=s;x.disabled=(r==null?void 0:r.length)===0,x.componentProps=fe(O({},x.componentProps),{disabled:(r==null?void 0:r.length)===0||((m=n.errors)==null?void 0:m.length)>0})}}},Y=()=>{var m,h,o,a,f,d;const t=F.useField(),e=F.useFieldSchema(),{t:l}=M.useTranslation(),{dn:n}=p.useDesignable(),[x,s]=g.useState(),{importSettingsSchema:r}=H();return g.useEffect(()=>{s(r)},[t.address,(m=e==null?void 0:e["x-action-settings"])==null?void 0:m.importSettings]),i.jsxs(p.GeneralSchemaDesigner,{disableInitializer:!0,children:[i.jsx(p.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:(h=e==null?void 0:e["x-component-props"])==null?void 0:h.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":((a=e==null?void 0:e["x-component-props"])==null?void 0:a.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,n.emit("patch",{schema:{"x-uid":e["x-uid"],title:u,"x-component-props":O({},e["x-component-props"])}}),n.refresh()}}),i.jsx(p.SchemaSettingsActionModalItem,{title:l("Importable fields"),schema:x,initialValues:O({},(d=(f=e==null?void 0:e["x-action-settings"])==null?void 0:f.importSettings)!=null?d:{}),components:{ArrayItems:k.ArrayItems},onSubmit:({importColumns:u,explain:I})=>{const v=u==null?void 0:u.filter(S=>{var A;return(A=S==null?void 0:S.dataIndex)==null?void 0:A.length}).map(S=>({dataIndex:S.dataIndex.map(A=>{var b;return(b=A.name)!=null?b:A}),title:S.title}));e["x-action-settings"].importSettings={importColumns:v,explain:I},n.emit("patch",{schema:{"x-uid":e["x-uid"],"x-action-settings":e["x-action-settings"]}}),n.refresh()}}),i.jsx(p.SchemaSettingsDivider,{}),i.jsx(p.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:u=>u["x-component"]==="Space"||u["x-component"].endsWith("ActionBar"),confirm:{title:l("Delete action")}})]})},R=g.createContext(null);R.displayName="ImportContext";const Q=()=>g.useContext(R);var U=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{},Z={exports:{}};(function(t,e){(function(l,n){n()})(U,function(){function l(o,a){return typeof a=="undefined"?a={autoBom:!1}:typeof a!="object"&&(console.warn("Deprecated: Expected third argument to be a object"),a={autoBom:!a}),a.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 n(o,a,f){var d=new XMLHttpRequest;d.open("GET",o),d.responseType="blob",d.onload=function(){h(d.response,a,f)},d.onerror=function(){console.error("could not download file")},d.send()}function x(o){var a=new XMLHttpRequest;a.open("HEAD",o,!1);try{a.send()}catch(f){}return 200<=a.status&&299>=a.status}function s(o){try{o.dispatchEvent(new MouseEvent("click"))}catch(f){var a=document.createEvent("MouseEvents");a.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),o.dispatchEvent(a)}}var r=typeof window=="object"&&window.window===window?window:typeof self=="object"&&self.self===self?self:typeof U=="object"&&U.global===U?U:void 0,m=r.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),h=r.saveAs||(typeof window!="object"||window!==r?function(){}:"download"in HTMLAnchorElement.prototype&&!m?function(o,a,f){var d=r.URL||r.webkitURL,u=document.createElement("a");a=a||o.name||"download",u.download=a,u.rel="noopener",typeof o=="string"?(u.href=o,u.origin===location.origin?s(u):x(u.href)?n(o,a,f):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,a,f){if(a=a||o.name||"download",typeof o!="string")navigator.msSaveOrOpenBlob(l(o,f),a);else if(x(o))n(o,a,f);else{var d=document.createElement("a");d.href=o,d.target="_blank",setTimeout(function(){s(d)})}}:function(o,a,f,d){if(d=d||open("","_blank"),d&&(d.document.title=d.document.body.innerText="downloading..."),typeof o=="string")return n(o,a,f);var u=o.type==="application/octet-stream",I=/constructor/i.test(r.HTMLElement)||r.safari,v=/CriOS\/[\d]+/.test(navigator.userAgent);if((v||u&&I||m)&&typeof FileReader!="undefined"){var S=new FileReader;S.onloadend=function(){var w=S.result;w=v?w:w.replace(/^data:[^;]*;/,"data:attachment/file;"),d?d.location.href=w:location=w,d=null},S.readAsDataURL(o)}else{var A=r.URL||r.webkitURL,b=A.createObjectURL(o);d?d.location=b:location.href=b,d=null,setTimeout(function(){A.revokeObjectURL(b)},4e4)}});r.saveAs=h.saveAs=h,t.exports=h})})(Z);var ee=Z.exports;const D={IMPORTING:1,IMPORTED:2},ve=t=>{const{t:e}=M.useTranslation(T),{importModalVisible:l,importStatus:n,importResult:x,setImportModalVisible:s}=Q(),{data:r,meta:m}=x!=null?x:{},h=()=>{s(!1)},o=()=>{const a=new Int8Array(r==null?void 0:r.data),f=new Blob([a],{type:"application/x-xls"});ee.saveAs(f,"fail.xlsx")};return i.jsx(E.Modal,{title:e("Import Data"),width:"50%",styles:{body:{height:"calc(80vh - 200px)"}},open:l,footer:null,closable:n===D.IMPORTED,onCancel:h,children:i.jsxs("div",{className:p.css`
28
+ `}}}}}},beforeUploadHandler(){return!1},uploadValidator(n,x){var r;if(n.length>1)return{type:"error",message:t("Only one file is allowed to be uploaded")};const c=(r=n[0])!=null?r:{};return c.size>10*1024*1024?{type:"error",message:t("File size cannot exceed 10M")}:Ie.includes(c.type)?"":{type:"error",message:t("Please upload the file of Excel")}},validateUpload(n,x,c){var m;const[r]=c;x.disabled=(r==null?void 0:r.length)===0,x.componentProps=he(O({},x.componentProps),{disabled:(r==null?void 0:r.length)===0||((m=n.errors)==null?void 0:m.length)>0})}}},K=()=>{var m,f,o,a,h,d;const t=F.useField(),e=F.useFieldSchema(),{t:l}=P.useTranslation(),{dn:n}=i.useDesignable(),[x,c]=g.useState(),{importSettingsSchema:r}=z();return g.useEffect(()=>{c(r)},[t.address,(m=e==null?void 0:e["x-action-settings"])==null?void 0:m.importSettings]),s.jsxs(i.GeneralSchemaDesigner,{disableInitializer:!0,children:[s.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":((a=e==null?void 0:e["x-component-props"])==null?void 0:a.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,n.emit("patch",{schema:{"x-uid":e["x-uid"],title:u,"x-component-props":O({},e["x-component-props"])}}),n.refresh()}}),s.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},n.emit("patch",{schema:{"x-uid":e["x-uid"],"x-action-settings":e["x-action-settings"]}}),n.refresh()}}),s.jsx(i.SchemaSettingsDivider,{}),s.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,n){n()})(U,function(){function l(o,a){return typeof a=="undefined"?a={autoBom:!1}:typeof a!="object"&&(console.warn("Deprecated: Expected third argument to be a object"),a={autoBom:!a}),a.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 n(o,a,h){var d=new XMLHttpRequest;d.open("GET",o),d.responseType="blob",d.onload=function(){f(d.response,a,h)},d.onerror=function(){console.error("could not download file")},d.send()}function x(o){var a=new XMLHttpRequest;a.open("HEAD",o,!1);try{a.send()}catch(h){}return 200<=a.status&&299>=a.status}function c(o){try{o.dispatchEvent(new MouseEvent("click"))}catch(h){var a=document.createEvent("MouseEvents");a.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),o.dispatchEvent(a)}}var r=typeof window=="object"&&window.window===window?window:typeof self=="object"&&self.self===self?self:typeof U=="object"&&U.global===U?U:void 0,m=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&&!m?function(o,a,h){var d=r.URL||r.webkitURL,u=document.createElement("a");a=a||o.name||"download",u.download=a,u.rel="noopener",typeof o=="string"?(u.href=o,u.origin===location.origin?c(u):x(u.href)?n(o,a,h):c(u,u.target="_blank")):(u.href=d.createObjectURL(o),setTimeout(function(){d.revokeObjectURL(u.href)},4e4),setTimeout(function(){c(u)},0))}:"msSaveOrOpenBlob"in navigator?function(o,a,h){if(a=a||o.name||"download",typeof o!="string")navigator.msSaveOrOpenBlob(l(o,h),a);else if(x(o))n(o,a,h);else{var d=document.createElement("a");d.href=o,d.target="_blank",setTimeout(function(){c(d)})}}:function(o,a,h,d){if(d=d||open("","_blank"),d&&(d.document.title=d.document.body.innerText="downloading..."),typeof o=="string")return n(o,a,h);var u=o.type==="application/octet-stream",I=/constructor/i.test(r.HTMLElement)||r.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=r.URL||r.webkitURL,S=b.createObjectURL(o);d?d.location=S:location.href=S,d=null,setTimeout(function(){b.revokeObjectURL(S)},4e4)}});r.saveAs=f.saveAs=f,t.exports=f})})(Q);var Z=Q.exports;const M={IMPORTING:1,IMPORTED:2},ve=t=>{const{t:e}=P.useTranslation(T),{importModalVisible:l,importStatus:n,importResult:x,setImportModalVisible:c}=Y(),{data:r,meta:m}=x!=null?x:{},f=()=>{c(!1)},o=()=>{const a=new Int8Array(r==null?void 0:r.data),h=new Blob([a],{type:"application/x-xls"});Z.saveAs(h,"fail.xlsx")};return s.jsx(E.Modal,{title:e("Import Data"),width:"50%",styles:{body:{height:"calc(80vh - 200px)"}},open:l,footer:null,closable:n===M.IMPORTED,onCancel:f,children:s.jsxs("div",{className:i.css`
29
29
  display: flex;
30
30
  justify-content: center;
31
31
  align-items: center;
32
32
  height: 100%;
33
- `,children:[n===D.IMPORTING&&i.jsx(E.Spin,{indicator:i.jsx($.LoadingOutlined,{style:{fontSize:24},spin:!0}),tip:e("Excel data importing")}),n===D.IMPORTED&&i.jsxs(E.Space,{direction:"vertical",align:"center",children:[i.jsx($.ExclamationCircleFilled,{style:{fontSize:72,color:"#1890ff"}}),i.jsx("p",{children:e("{{successCount}} records have been successfully imported",O({},m!=null?m:{}))}),i.jsxs(E.Space,{children:[(m==null?void 0:m.failureCount)>0&&i.jsx(E.Button,{onClick:o,children:e("To download the failure data")}),i.jsx(E.Button,{type:"primary",onClick:h,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}=p.useBlockRequestContext();p.useAPIClient();const l=F.useFieldSchema(),n=p.useCompile(),{getCollectionJoinField:x,getCollectionField:s}=p.useCollectionManager_deprecated(),{name:r,title:m,getField:h}=p.useCollection_deprecated();M.useTranslation(T);const{schema:o}=te(l);return{run(){return z(this,null,function*(){var S,A;const{importColumns:f,explain:d}=V.cloneDeep((A=(S=o==null?void 0:o["x-action-settings"])==null?void 0:S.importSettings)!=null?A:{}),u=oe(f).map(b=>{var N,_;const w=s(`${r}.${b.dataIndex[0]}`);if(w){if(b.defaultTitle=n((N=w==null?void 0:w.uiSchema)==null?void 0:N.title)||w.name,b.dataIndex.length>1){const P=x(`${r}.${b.dataIndex.join(".")}`);if(!P)return;b.defaultTitle=b.defaultTitle+"/"+n((_=P==null?void 0:P.uiSchema)==null?void 0:_.title)||P.name}return w.interface==="chinaRegion"&&b.dataIndex.push("name"),b}}).filter(Boolean),{data:I}=yield e.downloadXlsxTemplate({values:{title:n(m),explain:d,columns:n(u)}},{method:"post",responseType:"blob"}),v=new Blob([I],{type:"application/x-xls"});ee.saveAs(v,`${n(m)}.xlsx`)})}}},re=()=>{var w;const{service:t,resource:e}=p.useBlockRequestContext(),l=p.useAPIClient(),n=F.useFieldSchema(),x=p.useCompile(),{getCollectionJoinField:s,getCollectionField:r}=p.useCollectionManager_deprecated(),{name:m,title:h,getField:o}=p.useCollection_deprecated();M.useTranslation(T);const{schema:a}=te(n),f=F.useForm(),{setVisible:d,fieldSchema:u}=p.useActionContext(),{setImportModalVisible:I,setImportStatus:v,setImportResult:S}=Q(),{upload:A}=f.values;return g.useEffect(()=>{f.reset()},[]),{run(){return z(this,null,function*(){var ce,pe,le;const{importColumns:N,explain:_}=V.cloneDeep((pe=(ce=a==null?void 0:a["x-action-settings"])==null?void 0:ce.importSettings)!=null?pe:{}),P=oe(N).map(C=>{var de,me;const B=r(`${m}.${C.dataIndex[0]}`);if(B){if(C.defaultTitle=x((de=B==null?void 0:B.uiSchema)==null?void 0:de.title)||B.name,C.dataIndex.length>1){const L=s(`${m}.${C.dataIndex.join(".")}`);if(!L)return;C.defaultTitle=C.defaultTitle+"/"+x((me=L==null?void 0:L.uiSchema)==null?void 0:me.title)||L.name}return B.interface==="chinaRegion"&&C.dataIndex.push("name"),C}}).filter(Boolean),q=new FormData,Ae=f.values.upload.map(C=>C.originFileObj);q.append("file",Ae[0]),q.append("columns",JSON.stringify(P)),q.append("explain",_),d(!1),I(!0),v(D.IMPORTING);try{const{data:C}=yield l.axios.post(`${m}:importXlsx`,q,{timeout:6e5});S(C),f.reset(),yield(le=t==null?void 0:t.refresh)==null?void 0:le.call(t),v(D.IMPORTED)}catch(C){I(!1),d(!0)}})},disabled:(A==null?void 0:A.length)===0||((w=f.errors)==null?void 0:w.length)>0}},ae=t=>{const{uploadValidator:e,beforeUploadHandler:l,validateUpload:n}=H();return i.jsx(p.SchemaComponentOptions,{components:{ImportActionInitializer:K,ImportDesigner:Y,ImportWarning:W,DownloadTips:J},scope:{uploadValidator:e,validateUpload:n,beforeUploadHandler:l,useDownloadXlsxTemplateAction:ne,useImportStartAction:re},children:i.jsx(ie,{children:t.children})})},ie=t=>{const[e,l]=g.useState(!1),[n,x]=g.useState(D.IMPORTING),[s,r]=g.useState(null);return i.jsxs(R.Provider,{value:{importModalVisible:e,setImportModalVisible:l,importStatus:n,setImportStatus:x,importResult:s,setImportResult:r},children:[j.createPortal(i.jsx(ve,{}),document.body),t.children]})},Se=new p.SchemaSettings({name:"actionSettings:import",items:[{name:"editButton",Component:p.ButtonEditor,useComponentProps(){const{buttonEditorProps:t}=p.useSchemaToolbar();return t}},{name:"importableFields",type:"actionModal",useComponentProps(){var m,h,o;const t=F.useField(),e=F.useFieldSchema(),{t:l}=M.useTranslation(),{dn:n}=p.useDesignable(),[x,s]=g.useState(),{importSettingsSchema:r}=H();return g.useEffect(()=>{s(r)},[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=(h=e==null?void 0:e["x-action-settings"])==null?void 0:h.importSettings)!=null?o:{}),components:{ArrayItems:k.ArrayItems},onSubmit:({importColumns:a,explain:f})=>{const d=a==null?void 0:a.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:f},n.emit("patch",{schema:{"x-uid":e["x-uid"],"x-action-settings":e["x-action-settings"]}}),n.refresh()}}}},{name:"divider",type:"divider"},{name:"delete",type:"remove",useComponentProps(){const{t}=M.useTranslation();return{removeParentsIfNoChildren:!0,breakRemoveOn:e=>e["x-component"]==="Space"||e["x-component"].endsWith("ActionBar"),confirm:{title:t("Delete action")}}}}]});class se extends p.Plugin{load(){return z(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(){const n=p.useCollection_deprecated();return(n.template!=="view"||(n==null?void 0:n.writableView))&&n.template!=="file"&&n.template!=="sql"}},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=J,c.ImportActionInitializer=K,c.ImportContextProvider=ie,c.ImportDesigner=Y,c.ImportPluginProvider=ae,c.ImportWarning=W,c.PluginActionImportClient=se,c.default=se,c.useDownloadXlsxTemplateAction=ne,c.useImportStartAction=re,Object.defineProperties(c,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
33
+ `,children:[n===M.IMPORTING&&s.jsx(E.Spin,{indicator:s.jsx(R.LoadingOutlined,{style:{fontSize:24},spin:!0}),tip:e("Excel data importing")}),n===M.IMPORTED&&s.jsxs(E.Space,{direction:"vertical",align:"center",children:[s.jsx(R.ExclamationCircleFilled,{style:{fontSize:72,color:"#1890ff"}}),s.jsx("p",{children:e("{{successCount}} records have been successfully imported",O({},m!=null?m:{}))}),s.jsxs(E.Space,{children:[(m==null?void 0:m.failureCount)>0&&s.jsx(E.Button,{onClick:o,children:e("To download the failure data")}),s.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=F.useFieldSchema(),n=i.useCompile(),{getCollectionJoinField:x,getCollectionField:c}=i.useCollectionManager_deprecated(),{name:r,title:m,getField:f}=i.useCollection_deprecated();P.useTranslation(T);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=c(`${r}.${S.dataIndex[0]}`);if(w){if(S.defaultTitle=n((ie=w==null?void 0:w.uiSchema)==null?void 0:ie.title)||w.name,S.dataIndex.length>1){const D=x(`${r}.${S.dataIndex.join(".")}`);if(!D)return;S.defaultTitle=S.defaultTitle+"/"+n((k=D==null?void 0:D.uiSchema)==null?void 0:k.title)||D.name}return w.interface==="chinaRegion"&&S.dataIndex.push("name"),S}}).filter(Boolean),{data:I}=yield e.downloadXlsxTemplate({values:{title:n(m),explain:d,columns:n(u)}},{method:"post",responseType:"blob"}),v=new Blob([I],{type:"application/x-xls"});Z.saveAs(v,`${n(m)}.xlsx`)})}}},ne=()=>{var k;const{service:t,resource:e}=i.useBlockRequestContext(),l=i.useAPIClient(),n=F.useFieldSchema(),x=i.useCompile(),{getCollectionJoinField:c,getCollectionField:r}=i.useCollectionManager_deprecated(),{name:m,title:f,getField:o}=i.useCollection_deprecated();P.useTranslation(T);const{schema:a}=ee(n),h=F.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:D,explain:Ae}=$.cloneDeep((pe=(ce=a==null?void 0:a["x-action-settings"])==null?void 0:ce.importSettings)!=null?pe:{}),be=te(D).map(C=>{var de,me;const B=r(`${m}.${C.dataIndex[0]}`);if(B){if(C.defaultTitle=x((de=B==null?void 0:B.uiSchema)==null?void 0:de.title)||B.name,C.dataIndex.length>1){const L=c(`${m}.${C.dataIndex.join(".")}`);if(!L)return;C.defaultTitle=C.defaultTitle+"/"+x((me=L==null?void 0:L.uiSchema)==null?void 0:me.title)||L.name}return B.interface==="chinaRegion"&&C.dataIndex.push("name"),C}}).filter(Boolean),_=new FormData,we=h.values.upload.map(C=>C.originFileObj);_.append("file",we[0]),_.append("columns",JSON.stringify(be)),_.append("explain",Ae),d(!1),I(!0),v(M.IMPORTING);try{const{data:C}=yield l.axios.post(`${m}:importXlsx`,_,{headers:w,timeout:6e5});A(C),h.reset(),yield(le=t==null?void 0:t.refresh)==null?void 0:le.call(t),v(M.IMPORTED)}catch(C){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:n}=z();return s.jsx(i.SchemaComponentOptions,{components:{ImportActionInitializer:J,ImportDesigner:K,ImportWarning:G,DownloadTips:W},scope:{uploadValidator:e,validateUpload:n,beforeUploadHandler:l,useDownloadXlsxTemplateAction:oe,useImportStartAction:ne},children:s.jsx(ae,{children:t.children})})},ae=t=>{const[e,l]=g.useState(!1),[n,x]=g.useState(M.IMPORTING),[c,r]=g.useState(null);return s.jsxs(H.Provider,{value:{importModalVisible:e,setImportModalVisible:l,importStatus:n,setImportStatus:x,importResult:c,setImportResult:r},children:[j.createPortal(s.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=F.useField(),e=F.useFieldSchema(),{t:l}=P.useTranslation(),{dn:n}=i.useDesignable(),[x,c]=g.useState(),{importSettingsSchema:r}=z();return g.useEffect(()=>{c(r)},[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:a,explain:h})=>{const d=a==null?void 0:a.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},n.emit("patch",{schema:{"x-uid":e["x-uid"],"x-action-settings":e["x-action-settings"]}}),n.refresh()}}}},{name:"divider",type:"divider"},{name:"delete",type:"remove",useComponentProps(){const{t}=P.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(){const n=i.useCollection_deprecated();return(n.template!=="view"||(n==null?void 0:n.writableView))&&n.template!=="file"&&n.template!=="sql"}},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=W,p.ImportActionInitializer=J,p.ImportContextProvider=ae,p.ImportDesigner=K,p.ImportPluginProvider=re,p.ImportWarning=G,p.PluginActionImportClient=se,p.default=se,p.useDownloadXlsxTemplateAction=oe,p.useImportStartAction=ne,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.0",
13
- "@nocobase/client": "1.2.16-alpha",
13
+ "@nocobase/client": "1.2.17-alpha",
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.2.16-alpha",
23
- "@nocobase/actions": "1.2.16-alpha",
24
- "@nocobase/database": "1.2.16-alpha",
22
+ "@nocobase/server": "1.2.17-alpha",
23
+ "@nocobase/actions": "1.2.17-alpha",
24
+ "@nocobase/database": "1.2.17-alpha",
25
25
  "async-mutex": "0.3.2",
26
- "@nocobase/data-source-manager": "1.2.16-alpha",
27
- "@nocobase/utils": "1.2.16-alpha",
26
+ "@nocobase/data-source-manager": "1.2.17-alpha",
27
+ "@nocobase/utils": "1.2.17-alpha",
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-07-12T09:13:24.284Z"}
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-07-16T00:49:05.480Z"}
@@ -32,6 +32,7 @@ export declare class XlsxImporter extends EventEmitter {
32
32
  run(options?: RunOptions): Promise<number>;
33
33
  resetSeq(options?: RunOptions): Promise<void>;
34
34
  performImport(options?: RunOptions): Promise<number>;
35
+ renderErrorMessage(error: any): any;
35
36
  trimString(str: string): string;
36
37
  getData(): unknown[];
37
38
  firstSheet(): XLSX.WorkSheet;
@@ -155,7 +155,9 @@ class XlsxImporter extends import_events.default {
155
155
  await new Promise((resolve) => setTimeout(resolve, 5));
156
156
  } catch (error) {
157
157
  throw new Error(
158
- `failed to import row ${handingRowIndex}, message: ${error.message}, rowData: ${JSON.stringify(rowValues)}`,
158
+ `failed to import row ${handingRowIndex}, ${this.renderErrorMessage(error)}, rowData: ${JSON.stringify(
159
+ rowValues
160
+ )}`,
159
161
  { cause: error }
160
162
  );
161
163
  }
@@ -164,6 +166,13 @@ class XlsxImporter extends import_events.default {
164
166
  }
165
167
  return imported;
166
168
  }
169
+ renderErrorMessage(error) {
170
+ let message = error.message;
171
+ if (error.parent) {
172
+ message += `: ${error.parent.message}`;
173
+ }
174
+ return message;
175
+ }
167
176
  trimString(str) {
168
177
  if (typeof str === "string") {
169
178
  return str.trim();
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.2.16-alpha",
7
+ "version": "1.2.17-alpha",
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": "f3383e8fe51a1e7911f312d767e8793b8dcd86f4",
37
+ "gitHead": "76ca7a1be6d868a536cb7d4ce41c4f8629363d15",
38
38
  "keywords": [
39
39
  "Actions"
40
40
  ]