@nocobase/plugin-action-import 1.0.0-alpha.9 → 1.0.1-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/ImportActionInitializer.d.ts +1 -6
- package/dist/client/index.js +6 -6
- package/dist/client/useImportAction.d.ts +1 -0
- package/dist/externalVersion.js +9 -6
- package/dist/locale/en-US.json +3 -3
- package/dist/locale/es-ES.json +2 -2
- package/dist/locale/ko_KR.json +3 -3
- package/dist/locale/pt-BR.json +2 -2
- package/dist/locale/zh-CN.json +3 -3
- package/dist/node_modules/xlsx/bin/xlsx.njs +8 -0
- package/dist/node_modules/xlsx/bower.json +1 -1
- package/dist/node_modules/xlsx/dist/cpexcel.d.ts +39 -0
- package/dist/node_modules/xlsx/dist/xlsx.core.min.js +16 -17
- package/dist/node_modules/xlsx/dist/xlsx.extendscript.js +11207 -15096
- package/dist/node_modules/xlsx/dist/xlsx.full.min.js +23 -23
- package/dist/node_modules/xlsx/dist/xlsx.mini.min.js +9 -8
- package/dist/node_modules/xlsx/dist/xlsx.zahl.js +4 -0
- package/dist/node_modules/xlsx/dist/zahl.d.ts +4 -0
- package/dist/node_modules/xlsx/package.json +1 -1
- package/dist/node_modules/xlsx/types/index.d.ts +220 -40
- package/dist/node_modules/xlsx/xlsx.js +5 -4
- package/dist/node_modules/xlsx/xlsxworker.js +1 -2
- package/dist/server/actions/{downloadXlsxTemplate.js → download-xlsx-template.js} +13 -17
- package/dist/server/actions/import-xlsx.js +89 -0
- package/dist/server/actions/index.d.ts +2 -2
- package/dist/server/actions/index.js +4 -4
- package/dist/server/index.d.ts +1 -2
- package/dist/server/index.js +0 -6
- package/dist/server/services/template-creator.d.ts +24 -0
- package/dist/server/services/template-creator.js +70 -0
- package/dist/server/services/xlsx-importer.d.ts +37 -0
- package/dist/server/services/xlsx-importer.js +185 -0
- package/package.json +3 -3
- package/dist/node_modules/node-xlsx/lib/helpers.js +0 -142
- package/dist/node_modules/node-xlsx/lib/index.js +0 -6
- package/dist/node_modules/node-xlsx/lib/workbook.js +0 -16
- package/dist/node_modules/node-xlsx/package.json +0 -1
- package/dist/node_modules/xlsx/dist/jszip.js +0 -9000
- package/dist/node_modules/xlsx/dist/xlsx.js +0 -22693
- package/dist/node_modules/xlsx/dist/xlsx.min.js +0 -15
- package/dist/node_modules/xlsx/jszip.js +0 -9000
- package/dist/node_modules/xlsx/xlsx.mini.js +0 -10709
- package/dist/server/actions/importXlsx.js +0 -194
- /package/dist/server/actions/{downloadXlsxTemplate.d.ts → download-xlsx-template.d.ts} +0 -0
- /package/dist/server/actions/{importXlsx.d.ts → import-xlsx.d.ts} +0 -0
|
@@ -6,12 +6,7 @@
|
|
|
6
6
|
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
|
-
import { Schema } from '@formily/react';
|
|
10
9
|
import React from 'react';
|
|
11
|
-
export declare const useCurrentSchema: (action: string, key: string, find?: (schema: Schema, key: string, action: string) => any, rm?: (schema: any, cb: any) => any) => {
|
|
12
|
-
schema: any;
|
|
13
|
-
exists: boolean;
|
|
14
|
-
remove(): void;
|
|
15
|
-
};
|
|
16
10
|
export declare const ImportWarning: () => React.JSX.Element;
|
|
11
|
+
export declare const DownloadTips: () => React.JSX.Element;
|
|
17
12
|
export declare const ImportActionInitializer: () => React.JSX.Element;
|
package/dist/client/index.js
CHANGED
|
@@ -7,27 +7,27 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
(function(
|
|
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`
|
|
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: "${
|
|
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`
|
|
15
15
|
margin-top: 5px;
|
|
16
|
-
`,useAction:"{{ useDownloadXlsxTemplateAction }}"}}}},upload:{type:"array",title:`{{ t("Step 2: Upload Excel", {ns: "${
|
|
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`
|
|
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:
|
|
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`
|
|
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(
|
|
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`
|
|
29
29
|
display: flex;
|
|
30
30
|
justify-content: center;
|
|
31
31
|
align-items: center;
|
|
32
32
|
height: 100%;
|
|
33
|
-
`,children:[
|
|
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"}})});
|
package/dist/externalVersion.js
CHANGED
|
@@ -10,18 +10,21 @@
|
|
|
10
10
|
module.exports = {
|
|
11
11
|
"@formily/react": "2.3.0",
|
|
12
12
|
"@formily/shared": "2.3.0",
|
|
13
|
-
"@nocobase/client": "1.0.
|
|
14
|
-
"react": "18.2.0",
|
|
13
|
+
"@nocobase/client": "1.0.1-alpha.2",
|
|
15
14
|
"antd": "5.12.8",
|
|
15
|
+
"react": "18.2.0",
|
|
16
16
|
"@formily/antd-v5": "1.1.9",
|
|
17
17
|
"react-i18next": "11.18.6",
|
|
18
18
|
"@ant-design/icons": "5.2.6",
|
|
19
19
|
"react-dom": "18.2.0",
|
|
20
20
|
"lodash": "4.17.21",
|
|
21
21
|
"@formily/core": "2.3.0",
|
|
22
|
-
"@nocobase/server": "1.0.
|
|
23
|
-
"@nocobase/actions": "1.0.
|
|
24
|
-
"@nocobase/database": "1.0.
|
|
25
|
-
"
|
|
22
|
+
"@nocobase/server": "1.0.1-alpha.2",
|
|
23
|
+
"@nocobase/actions": "1.0.1-alpha.2",
|
|
24
|
+
"@nocobase/database": "1.0.1-alpha.2",
|
|
25
|
+
"async-mutex": "0.3.2",
|
|
26
|
+
"@nocobase/data-source-manager": "1.0.1-alpha.2",
|
|
27
|
+
"@nocobase/utils": "1.0.1-alpha.2",
|
|
28
|
+
"sequelize": "6.35.2",
|
|
26
29
|
"mathjs": "10.6.4"
|
|
27
30
|
};
|
package/dist/locale/en-US.json
CHANGED
|
@@ -8,11 +8,11 @@
|
|
|
8
8
|
"Download template": "Download template",
|
|
9
9
|
"Step 1: Download template": "Step 1: Download template",
|
|
10
10
|
"Step 2: Upload Excel": "Step 2: Upload Excel",
|
|
11
|
-
"Download
|
|
12
|
-
"Import
|
|
11
|
+
"Download tips": "- Download the template and fill in the data according to the format \r\n - Import only the first worksheet \r\n - Do not change the header of the template to prevent import failure",
|
|
12
|
+
"Import warnings": "You can import up to {{limit}} rows of data at a time, any excess will be ignored.",
|
|
13
13
|
"Upload placeholder": "Drag and drop the file here or click to upload, file size should not exceed 30M",
|
|
14
14
|
"Excel data importing": "Excel data importing",
|
|
15
|
-
"
|
|
15
|
+
"{{successCount}} records have been successfully imported": "{{successCount}} records have been successfully imported",
|
|
16
16
|
"To download the failure data": "To download the failure data",
|
|
17
17
|
"Add importable field": "Add importable field",
|
|
18
18
|
"Done": "Done",
|
package/dist/locale/es-ES.json
CHANGED
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
"Download template": "Descargar plantilla",
|
|
9
9
|
"Step 1: Download template": "Paso 1: Descargar plantilla",
|
|
10
10
|
"Step 2: Upload Excel": "Paso 2: Cargar Excel",
|
|
11
|
-
"Download
|
|
11
|
+
"Download tips": "- Descargar la plantilla y rellenar los datos según el formato \r\n - Importar sólo la primera hoja de cálculo \r\n - No cambiar la cabecera de la plantilla para evitar fallos en la importación",
|
|
12
12
|
"Upload placeholder": "Arrastra y suelta el archivo aquí o haga clic para cargarlo, el tamaño del archivo no debe superar los 10M",
|
|
13
13
|
"Excel data importing": "Importación de datos Excel",
|
|
14
|
-
"
|
|
14
|
+
"{{successCount}} records have been successfully imported": "{{successCount}} registros han sido importados exitosamente",
|
|
15
15
|
"To download the failure data": "Para descargar los datos de fallo",
|
|
16
16
|
"Add importable field": "Añadir campo importable",
|
|
17
17
|
"Done": "Hecho",
|
package/dist/locale/ko_KR.json
CHANGED
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
"Download template": "템플릿 다운로드",
|
|
9
9
|
"Step 1: Download template": "단계 1: 템플릿 다운로드",
|
|
10
10
|
"Step 2: Upload Excel": "단계 2: Excel 업로드",
|
|
11
|
-
"Download
|
|
11
|
+
"Download tips": "- 템플릿을 다운로드하고 형식에 맞게 데이터를 작성합니다.\r\n - 첫 번째 시트만 가져옵니다.\r\n - 템플릿 헤더를 수정하지 마세요. 가져오기 실패를 방지합니다.",
|
|
12
12
|
"Upload placeholder": "파일을 여기에 드래그하거나 클릭하여 업로드하십시오. 파일 크기는 10M을 초과할 수 없습니다.",
|
|
13
13
|
"Excel data importing": "Excel 데이터 가져오기 중입니다. 창을 닫지 마십시오.",
|
|
14
|
-
"
|
|
14
|
+
"{{successCount}} records have been successfully imported": "{{successCount}} 개의 데이터를 성공적으로 가져왔습니다.",
|
|
15
15
|
"To download the failure data": "실패한 데이터를 다운로드하려면",
|
|
16
16
|
"Add importable field": "가져올 수 있는 필드 추가",
|
|
17
17
|
"Done": "완료",
|
|
@@ -24,5 +24,5 @@
|
|
|
24
24
|
"Incorrect date format": "잘못된 날짜 형식",
|
|
25
25
|
"Incorrect email format": "잘못된 이메일 형식",
|
|
26
26
|
"Illegal percentage format": "잘못된 백분율 형식",
|
|
27
|
-
"Imported template does not match, please download again.": "가져온 템플릿이 일치하지 않습니다. 다시 다운로드하세요."
|
|
27
|
+
"Imported template does not match, please download again.": "가져온 템플릿이 일치하지 않습니다. 다시 다운로드하세요."
|
|
28
28
|
}
|
package/dist/locale/pt-BR.json
CHANGED
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
"Download template": "Baixar modelo",
|
|
9
9
|
"Step 1: Download template": "Passo 1: Baixar modelo",
|
|
10
10
|
"Step 2: Upload Excel": "Passo 2: Enviar Excel",
|
|
11
|
-
"Download
|
|
11
|
+
"Download tips": "- Baixe o modelo e preencha os dados de acordo com o formato \r\n - Importe apenas a primeira planilha \r\n - Não altere o cabeçalho do modelo para evitar falhas de importação",
|
|
12
12
|
"Upload placeholder": "Arraste e solte o arquivo aqui ou clique para enviar, o tamanho do arquivo não deve exceder 10 MB",
|
|
13
13
|
"Excel data importing": "Importando dados do Excel",
|
|
14
|
-
"Import done, total success have {{successCount}} , total failure have {{failureCount}}": "
|
|
14
|
+
"Import done, total success have {{successCount}} , total failure have {{failureCount}}": "{{successCount}} dados foram importados com sucesso",
|
|
15
15
|
"To download the failure data": "Para baixar os dados que falharam",
|
|
16
16
|
"Add importable field": "Adicionar campo importável",
|
|
17
17
|
"Done": "Concluído",
|
package/dist/locale/zh-CN.json
CHANGED
|
@@ -8,11 +8,11 @@
|
|
|
8
8
|
"Download template": "下载模板",
|
|
9
9
|
"Step 1: Download template": "1.下载模板",
|
|
10
10
|
"Step 2: Upload Excel": "2.上传完善后的表格",
|
|
11
|
-
"Download
|
|
12
|
-
"Import
|
|
11
|
+
"Download tips": "- 下载模板后,按格式填写数据\r\n - 只导入第一张工作表\r\n - 请勿改模板表头,防止导入失败",
|
|
12
|
+
"Import warnings": "每次最多导入 {{limit}} 行数据,超出的将被忽略。",
|
|
13
13
|
"Upload placeholder": "将文件拖曳到此处或点击上传,文件大小不超过10M",
|
|
14
14
|
"Excel data importing": "数据导入中,请勿关闭窗口",
|
|
15
|
-
"
|
|
15
|
+
"{{successCount}} records have been successfully imported": "已成功导入 {{successCount}} 条数据",
|
|
16
16
|
"To download the failure data": "下载导入失败的数据",
|
|
17
17
|
"Add importable field": "添加可导入字段",
|
|
18
18
|
"Done": "完成",
|
|
@@ -44,6 +44,7 @@ program
|
|
|
44
44
|
.option('-6, --xlml', 'emit SSML to <sheetname> or <file>.xls (2003 XML)')
|
|
45
45
|
.option('-T, --fods', 'emit FODS to <sheetname> or <file>.fods (Flat ODS)')
|
|
46
46
|
.option('--wk3', 'emit WK3 to <sheetname> or <file>.txt (Lotus WK3)')
|
|
47
|
+
.option('--numbers', 'emit NUMBERS to <sheetname> or <file>.numbers')
|
|
47
48
|
|
|
48
49
|
.option('-S, --formulae', 'emit list of values and formulae')
|
|
49
50
|
.option('-j, --json', 'emit formatted JSON (all fields text)')
|
|
@@ -90,6 +91,7 @@ var workbook_formats = [
|
|
|
90
91
|
['xls', 'xls', 'xls'],
|
|
91
92
|
['xla', 'xla', 'xla'],
|
|
92
93
|
['biff5', 'biff5', 'xls'],
|
|
94
|
+
['numbers', 'numbers', 'numbers'],
|
|
93
95
|
['ods', 'ods', 'ods'],
|
|
94
96
|
['fods', 'fods', 'fods'],
|
|
95
97
|
['wk3', 'wk3', 'wk3']
|
|
@@ -129,6 +131,7 @@ function wb_fmt() {
|
|
|
129
131
|
seen = true;
|
|
130
132
|
opts.cellFormula = true;
|
|
131
133
|
opts.cellNF = true;
|
|
134
|
+
opts.xlfn = true;
|
|
132
135
|
if(program.output) sheetname = program.output;
|
|
133
136
|
}
|
|
134
137
|
function isfmt(m/*:string*/)/*:boolean*/ {
|
|
@@ -153,6 +156,7 @@ if(program.all) {
|
|
|
153
156
|
opts.cellStyles = true;
|
|
154
157
|
opts.sheetStubs = true;
|
|
155
158
|
opts.cellDates = true;
|
|
159
|
+
wopts.cellFormula = true;
|
|
156
160
|
wopts.cellStyles = true;
|
|
157
161
|
wopts.sheetStubs = true;
|
|
158
162
|
wopts.bookVBA = true;
|
|
@@ -190,6 +194,10 @@ if(program.props) {
|
|
|
190
194
|
/* full workbook formats */
|
|
191
195
|
workbook_formats.forEach(function(m) { if(program[m[0]] || isfmt(m[0])) {
|
|
192
196
|
wopts.bookType = m[1];
|
|
197
|
+
if(wopts.bookType == "numbers") try {
|
|
198
|
+
var XLSX_ZAHL = require("../dist/xlsx.zahl");
|
|
199
|
+
wopts.numbers = XLSX_ZAHL;
|
|
200
|
+
} catch(e) {}
|
|
193
201
|
if(wb) X.writeFile(wb, program.output || sheetname || ((filename || "") + "." + m[2]), wopts);
|
|
194
202
|
process.exit(0);
|
|
195
203
|
} });
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/* codepage.js (C) 2013-present SheetJS -- http://sheetjs.com */
|
|
2
|
+
// TypeScript Version: 2.2
|
|
3
|
+
|
|
4
|
+
/** Codepage index type (integer or string representation) */
|
|
5
|
+
export type CP$Index = number | string;
|
|
6
|
+
|
|
7
|
+
/* Individual codepage converter */
|
|
8
|
+
export interface CP$Conv {
|
|
9
|
+
enc: {[n: string]: number; };
|
|
10
|
+
dec: {[n: number]: string; };
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/** Encode input type (string, array of characters, Buffer) */
|
|
14
|
+
export type CP$String = string | string[] | Uint8Array;
|
|
15
|
+
|
|
16
|
+
/** Encode output / decode input type */
|
|
17
|
+
export type CP$Data = string | number[] | Uint8Array;
|
|
18
|
+
|
|
19
|
+
/** General utilities */
|
|
20
|
+
export interface CP$Utils {
|
|
21
|
+
decode(cp: CP$Index, data: CP$Data): string;
|
|
22
|
+
encode(cp: CP$Index, data: CP$String, opts?: any): CP$Data;
|
|
23
|
+
hascp(n: number): boolean;
|
|
24
|
+
magic: {[cp: string]: string};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/* note: TS cannot export top-level indexer, hence default workaround */
|
|
28
|
+
export interface CP$Module {
|
|
29
|
+
/** Version string */
|
|
30
|
+
version: string;
|
|
31
|
+
|
|
32
|
+
/** Utility Functions */
|
|
33
|
+
utils: CP$Utils;
|
|
34
|
+
|
|
35
|
+
/** Codepage Converters */
|
|
36
|
+
[cp: number]: CP$Conv;
|
|
37
|
+
}
|
|
38
|
+
export const cptable: CP$Module;
|
|
39
|
+
export default cptable;
|