@nocobase/plugin-action-import 1.0.0-alpha.13 → 1.0.0-alpha.15
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.
|
@@ -6,12 +6,6 @@
|
|
|
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;
|
|
17
11
|
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(p,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):(p=typeof globalThis!="undefined"?globalThis:p||self,i(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,i,g,c,M,F,N,T,y,U,R,V){"use strict";var Ie=Object.defineProperty,Se=Object.defineProperties;var be=Object.getOwnPropertyDescriptors;var le=Object.getOwnPropertySymbols;var Ae=Object.prototype.hasOwnProperty,we=Object.prototype.propertyIsEnumerable;var de=(p,i,g)=>i in p?Ie(p,i,{enumerable:!0,configurable:!0,writable:!0,value:g}):p[i]=g,j=(p,i)=>{for(var g in i||(i={}))Ae.call(i,g)&&de(p,g,i[g]);if(le)for(var g of le(i))we.call(i,g)&&de(p,g,i[g]);return p},me=(p,i)=>Se(p,be(i));var q=(p,i,g)=>new Promise((c,M)=>{var F=y=>{try{T(g.next(y))}catch(U){M(U)}},N=y=>{try{T(g.throw(y))}catch(U){M(U)}},T=y=>y.done?c(y.value):Promise.resolve(y.value).then(F,N);T((g=g.apply(p,i)).next())});const w="action-import",ue="action-import";function xe(){return F.useTranslation([ue,"client"],{nsMode:"fallback"})}const fe=["id","createdAt","createdBy","updatedAt","updatedBy"],H=t=>{const{getCollectionFields:e}=c.useCollectionManager_deprecated(),l=e(t),n=(s,r)=>{var h;if(!s.interface||fe.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)},he=t=>({importColumns:t==null?void 0:t.filter(l=>!l.children).map(l=>({dataIndex:[l.name]})),explain:""}),X=()=>{const{t}=xe();return i.jsx(M.Alert,{type:"warning",style:{marginBottom:"10px"},message:t("Import warning")})},G=()=>{const t=c.useSchemaInitializerItem(),{insert:e}=c.useSchemaInitializer(),{name:l}=c.useCollection_deprecated(),n=H(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: "${w}" }) }}`,"x-component":"Action.Container","x-decorator":"Form","x-component-props":{width:"50%",className:c.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: "${w}" }) }}`,"x-component":"FormItem","x-acl-ignore":!0,properties:{tip:{type:"void","x-component":"Markdown.Void","x-editable":!1,"x-component-props":{style:{padding:"var(--paddingContentVerticalSM)",backgroundColor:"var(--colorInfoBg)",border:"1px solid var(--colorInfoBorder)",color:"var(--colorText)",marginBottom:"var(--marginSM)"},content:`{{ t("Download tip", {ns: "${w}" }) }}`}},downloadAction:{type:"void",title:`{{ t("Download template", {ns: "${w}" }) }}`,"x-component":"Action","x-component-props":{className:
|
|
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: "${w}" }) }}`,"x-component":"FormItem","x-acl-ignore":!0,properties:{tip:{type:"void","x-component":"Markdown.Void","x-editable":!1,"x-component-props":{style:{padding:"var(--paddingContentVerticalSM)",backgroundColor:"var(--colorInfoBg)",border:"1px solid var(--colorInfoBorder)",color:"var(--colorText)",marginBottom:"var(--marginSM)"},content:`{{ t("Download tip", {ns: "${w}" }) }}`}},downloadAction:{type:"void",title:`{{ t("Download template", {ns: "${w}" }) }}`,"x-component":"Action","x-component-props":{className:c.css`
|
|
15
15
|
margin-top: 5px;
|
|
16
|
-
`,useAction:"{{ useDownloadXlsxTemplateAction }}"}}}},upload:{type:"array",title:`{{ t("Step 2: Upload Excel", {ns: "${w}" }) }}`,"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: "${w}" }) }}`,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: "${w}" }) }}`,"x-component":"Action","x-component-props":{type:"primary",htmlType:"submit",useAction:"{{ useImportStartAction }}"},"x-reactions":{dependencies:["upload"],fulfill:{run:"validateUpload($form, $self, $deps)"}}}}}}}}}}};return
|
|
16
|
+
`,useAction:"{{ useDownloadXlsxTemplateAction }}"}}}},upload:{type:"array",title:`{{ t("Step 2: Upload Excel", {ns: "${w}" }) }}`,"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: "${w}" }) }}`,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: "${w}" }) }}`,"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(c.SchemaInitializerItem,{title:t.title,onClick:()=>{var r;x["x-action-settings"].importSettings=he(n);const s=g.merge(x||{},t.schema||{});(r=t==null?void 0:t.schemaInitialize)==null||r.call(t,s),e(s)}})},ge=["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.ms-excel"],$=()=>{const{t}=F.useTranslation(w),{name:e}=c.useCollection_deprecated(),l=H(e);return{importSettingsSchema:{type:"void","x-component":"Grid",properties:{explain:{type:"string",title:`{{ t("Import explain", {ns: "${w}"}) }}`,"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:c.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":
|
|
21
|
+
`},properties:{sort:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.SortHandle"},dataIndex:{type:"array","x-decorator":"FormItem","x-component":c.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: "${w}"}) }}`,"x-component":"ArrayItems.Addition","x-component-props":{className:c.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")}:ge.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=me(j({},x.componentProps),{disabled:(r==null?void 0:r.length)===0||((m=n.errors)==null?void 0:m.length)>0})}}},W=()=>{var m,h,o,a,f,d;const t=T.useField(),e=T.useFieldSchema(),{t:l}=F.useTranslation(),{dn:n}=c.useDesignable(),[x,s]=y.useState(),{importSettingsSchema:r}=$();return y.useEffect(()=>{s(r)},[t.address,(m=e==null?void 0:e["x-action-settings"])==null?void 0:m.importSettings]),i.jsxs(c.GeneralSchemaDesigner,{disableInitializer:!0,children:[i.jsx(c.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:v,type:I})=>{e.title=u,t.title=u,t.componentProps.icon=v,t.componentProps.danger=I==="danger",t.componentProps.type=I,e["x-component-props"]=e["x-component-props"]||{},e["x-component-props"].icon=v,e["x-component-props"].danger=I==="danger",e["x-component-props"].type=I,n.emit("patch",{schema:{"x-uid":e["x-uid"],title:u,"x-component-props":j({},e["x-component-props"])}}),n.refresh()}}),i.jsx(c.SchemaSettingsActionModalItem,{title:l("Importable fields"),schema:x,initialValues:j({},(d=(f=e==null?void 0:e["x-action-settings"])==null?void 0:f.importSettings)!=null?d:{}),components:{ArrayItems:N.ArrayItems},onSubmit:({importColumns:u,explain:v})=>{const I=u==null?void 0:u.filter(b=>{var E;return(E=b==null?void 0:b.dataIndex)==null?void 0:E.length}).map(b=>({dataIndex:b.dataIndex.map(E=>{var S;return(S=E.name)!=null?S:E}),title:b.title}));e["x-action-settings"].importSettings={importColumns:I,explain:v},n.emit("patch",{schema:{"x-uid":e["x-uid"],"x-action-settings":e["x-action-settings"]}}),n.refresh()}}),i.jsx(c.SchemaSettingsDivider,{}),i.jsx(c.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:u=>u["x-component"]==="Space"||u["x-component"].endsWith("ActionBar"),confirm:{title:l("Delete action")}})]})},z=y.createContext(null);z.displayName="ImportContext";const J=()=>y.useContext(z);var k=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{},K={exports:{}};(function(t,e){(function(l,n){n()})(k,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 k=="object"&&k.global===k?k: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",v=/constructor/i.test(r.HTMLElement)||r.safari,I=/CriOS\/[\d]+/.test(navigator.userAgent);if((I||u&&v||m)&&typeof FileReader!="undefined"){var b=new FileReader;b.onloadend=function(){var A=b.result;A=I?A:A.replace(/^data:[^;]*;/,"data:attachment/file;"),d?d.location.href=A:location=A,d=null},b.readAsDataURL(o)}else{var E=r.URL||r.webkitURL,S=E.createObjectURL(o);d?d.location=S:location.href=S,d=null,setTimeout(function(){E.revokeObjectURL(S)},4e4)}});r.saveAs=h.saveAs=h,t.exports=h})})(K);var Y=K.exports;const B={IMPORTING:1,IMPORTED:2},ye=t=>{const{t:e}=F.useTranslation(w),{importModalVisible:l,importStatus:n,importResult:x,setImportModalVisible:s}=J(),{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"});Y.saveAs(f,"fail.xlsx")};return i.jsx(M.Modal,{title:e("Import Data"),width:"50%",styles:{body:{height:"calc(80vh - 200px)"}},open:l,footer:null,closable:n===B.IMPORTED,onCancel:h,children:i.jsxs("div",{className:c.css`
|
|
29
29
|
display: flex;
|
|
30
30
|
justify-content: center;
|
|
31
31
|
align-items: center;
|
|
32
32
|
height: 100%;
|
|
33
|
-
`,children:[
|
|
33
|
+
`,children:[n===B.IMPORTING&&i.jsx(M.Spin,{indicator:i.jsx(R.LoadingOutlined,{style:{fontSize:24},spin:!0}),tip:e("Excel data importing")}),n===B.IMPORTED&&i.jsxs(M.Space,{direction:"vertical",align:"center",children:[i.jsx(R.ExclamationCircleFilled,{style:{fontSize:72,color:"#1890ff"}}),i.jsx("p",{children:e("Import done, total success have {{successCount}} , total failure have {{failureCount}}",j({},m!=null?m:{}))}),i.jsxs(M.Space,{children:[(m==null?void 0:m.failureCount)>0&&i.jsx(M.Button,{onClick:o,children:e("To download the failure data")}),i.jsx(M.Button,{type:"primary",onClick:h,children:e("Done")})]})]})]})})},Q=t=>{let e=t;for(;e&&e["x-action"]!=="importXlsx";)e=e.parent;return{schema:e}},Z=t=>!t||!Array.isArray(t)?[]:t,ee=()=>{const{service:t,resource:e}=c.useBlockRequestContext();c.useAPIClient();const l=T.useFieldSchema(),n=c.useCompile(),{getCollectionJoinField:x,getCollectionField:s}=c.useCollectionManager_deprecated(),{name:r,title:m,getField:h}=c.useCollection_deprecated();F.useTranslation(w);const{schema:o}=Q(l);return{run(){return q(this,null,function*(){var b,E;const{importColumns:f,explain:d}=V.cloneDeep((E=(b=o==null?void 0:o["x-action-settings"])==null?void 0:b.importSettings)!=null?E:{}),u=Z(f).map(S=>{var _,P;const A=s(`${r}.${S.dataIndex[0]}`);if(A){if(S.defaultTitle=n((_=A==null?void 0:A.uiSchema)==null?void 0:_.title)||A.name,S.dataIndex.length>1){const D=x(`${r}.${S.dataIndex.join(".")}`);if(!D)return;S.defaultTitle=S.defaultTitle+"/"+n((P=D==null?void 0:D.uiSchema)==null?void 0:P.title)||D.name}return A.interface==="chinaRegion"&&S.dataIndex.push("name"),S}}).filter(Boolean),{data:v}=yield e.downloadXlsxTemplate({values:{title:n(m),explain:d,columns:n(u)}},{method:"post",responseType:"blob"}),I=new Blob([v],{type:"application/x-xls"});Y.saveAs(I,`${n(m)}.xlsx`)})}}},te=()=>{const{service:t,resource:e}=c.useBlockRequestContext(),l=c.useAPIClient(),n=T.useFieldSchema(),x=c.useCompile(),{getCollectionJoinField:s,getCollectionField:r}=c.useCollectionManager_deprecated(),{name:m,title:h,getField:o}=c.useCollection_deprecated();F.useTranslation(w);const{schema:a}=Q(n),f=T.useForm(),{setVisible:d,fieldSchema:u}=c.useActionContext(),{setImportModalVisible:v,setImportStatus:I,setImportResult:b}=J();return{run(){return q(this,null,function*(){var ae,ie,se;const{importColumns:S,explain:A}=V.cloneDeep((ie=(ae=a==null?void 0:a["x-action-settings"])==null?void 0:ae.importSettings)!=null?ie:{}),_=Z(S).map(C=>{var ce,pe;const O=r(`${m}.${C.dataIndex[0]}`);if(O){if(C.defaultTitle=x((ce=O==null?void 0:O.uiSchema)==null?void 0:ce.title)||O.name,C.dataIndex.length>1){const L=s(`${m}.${C.dataIndex.join(".")}`);if(!L)return;C.defaultTitle=C.defaultTitle+"/"+x((pe=L==null?void 0:L.uiSchema)==null?void 0:pe.title)||L.name}return O.interface==="chinaRegion"&&C.dataIndex.push("name"),C}}).filter(Boolean),P=new FormData,D=f.values.upload.map(C=>C.originFileObj);P.append("file",D[0]),P.append("columns",JSON.stringify(_)),P.append("explain",A),d(!1),v(!0),I(B.IMPORTING);try{const{data:C}=yield l.axios.post(`${m}:importXlsx`,P,{timeout:6e5});b(C),f.reset(),yield(se=t==null?void 0:t.refresh)==null?void 0:se.call(t),I(B.IMPORTED)}catch(C){v(!1),d(!0)}})}}},oe=t=>{const{uploadValidator:e,beforeUploadHandler:l,validateUpload:n}=$();return i.jsx(c.SchemaComponentOptions,{components:{ImportActionInitializer:G,ImportDesigner:W,ImportWarning:X},scope:{uploadValidator:e,validateUpload:n,beforeUploadHandler:l,useDownloadXlsxTemplateAction:ee,useImportStartAction:te},children:i.jsx(ne,{children:t.children})})},ne=t=>{const[e,l]=y.useState(!1),[n,x]=y.useState(B.IMPORTING),[s,r]=y.useState(null);return i.jsxs(z.Provider,{value:{importModalVisible:e,setImportModalVisible:l,importStatus:n,setImportStatus:x,importResult:s,setImportResult:r},children:[U.createPortal(i.jsx(ye,{}),document.body),t.children]})},ve=new c.SchemaSettings({name:"actionSettings:import",items:[{name:"editButton",Component:c.ButtonEditor,useComponentProps(){const{buttonEditorProps:t}=c.useSchemaToolbar();return t}},{name:"importableFields",type:"actionModal",useComponentProps(){var m,h,o;const t=T.useField(),e=T.useFieldSchema(),{t:l}=F.useTranslation(),{dn:n}=c.useDesignable(),[x,s]=y.useState(),{importSettingsSchema:r}=$();return y.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:j({},(o=(h=e==null?void 0:e["x-action-settings"])==null?void 0:h.importSettings)!=null?o:{}),components:{ArrayItems:N.ArrayItems},onSubmit:({importColumns:a,explain:f})=>{const d=a==null?void 0:a.filter(u=>{var v;return(v=u==null?void 0:u.dataIndex)==null?void 0:v.length}).map(u=>({dataIndex:u.dataIndex.map(v=>{var I;return(I=v.name)!=null?I:v}),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}=F.useTranslation();return{removeParentsIfNoChildren:!0,breakRemoveOn:e=>e["x-component"]==="Space"||e["x-component"].endsWith("ActionBar"),confirm:{title:t("Delete action")}}}}]});class re extends c.Plugin{load(){return q(this,null,function*(){this.app.use(oe);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=c.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(ve)})}}p.ImportActionInitializer=G,p.ImportContextProvider=ne,p.ImportDesigner=W,p.ImportPluginProvider=oe,p.ImportWarning=X,p.PluginActionImportClient=re,p.default=re,p.useDownloadXlsxTemplateAction=ee,p.useImportStartAction=te,Object.defineProperties(p,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/dist/externalVersion.js
CHANGED
|
@@ -10,18 +10,18 @@
|
|
|
10
10
|
module.exports = {
|
|
11
11
|
"@formily/react": "2.3.0",
|
|
12
12
|
"@formily/shared": "2.3.0",
|
|
13
|
-
"@nocobase/client": "1.0.0-alpha.
|
|
14
|
-
"react": "18.2.0",
|
|
13
|
+
"@nocobase/client": "1.0.0-alpha.15",
|
|
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.0-alpha.
|
|
23
|
-
"@nocobase/actions": "1.0.0-alpha.
|
|
24
|
-
"@nocobase/database": "1.0.0-alpha.
|
|
25
|
-
"@nocobase/utils": "1.0.0-alpha.
|
|
22
|
+
"@nocobase/server": "1.0.0-alpha.15",
|
|
23
|
+
"@nocobase/actions": "1.0.0-alpha.15",
|
|
24
|
+
"@nocobase/database": "1.0.0-alpha.15",
|
|
25
|
+
"@nocobase/utils": "1.0.0-alpha.15",
|
|
26
26
|
"mathjs": "10.6.4"
|
|
27
27
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"node-xlsx","author":"Olivier Louvignes <olivier@mg-crea.com>","version":"0.16.2","description":"NodeJS Excel files parser & builder","main":"lib/index.js","scripts":{"start":"yarn test:watch","test":"NODE_ENV=test jest --runInBand","test:watch":"yarn test -- --watch","test:coverage":"yarn test -- --coverage","lint":"NODE_ENV=test eslint src/ test/","build":"rimraf lib/*; NODE_ENV=production babel src/ -d lib/ -s","build:watch":"yarn build -- -w","prepublish":"yarn build"},"repository":"github:mgcrea/node-xlsx","license":"Apache-2.0","dependencies":{"@babel/runtime":"^7.14.6","buffer-from":"^1.1.1","xlsx":"^0.17.0"},"devDependencies":{"@babel/cli":"^7.14.5","@babel/core":"^7.14.6","@babel/plugin-proposal-class-properties":"^7.14.5","@babel/plugin-transform-runtime":"^7.14.5","@babel/preset-env":"^7.14.7","babel-eslint":"^10.1.0","codacy-coverage":"^3.4.0","debug-utils":"^0.5.3","eslint":"^7.30.0","eslint-config-airbnb-base":"^14.2.1","eslint-config-prettier":"^8.3.0","eslint-plugin-import":"^2.23.4","expect":"^27.0.6","jest":"^27.0.6","rimraf":"^3.0.2"},"engines":{"node":">=4.0.0"},"keywords":["excel","parser","builder","xlsx","xls"],"jest":{"testEnvironment":"node","setupFiles":["<rootDir>/test/setup.js"]},"_lastModified":"2024-05-
|
|
1
|
+
{"name":"node-xlsx","author":"Olivier Louvignes <olivier@mg-crea.com>","version":"0.16.2","description":"NodeJS Excel files parser & builder","main":"lib/index.js","scripts":{"start":"yarn test:watch","test":"NODE_ENV=test jest --runInBand","test:watch":"yarn test -- --watch","test:coverage":"yarn test -- --coverage","lint":"NODE_ENV=test eslint src/ test/","build":"rimraf lib/*; NODE_ENV=production babel src/ -d lib/ -s","build:watch":"yarn build -- -w","prepublish":"yarn build"},"repository":"github:mgcrea/node-xlsx","license":"Apache-2.0","dependencies":{"@babel/runtime":"^7.14.6","buffer-from":"^1.1.1","xlsx":"^0.17.0"},"devDependencies":{"@babel/cli":"^7.14.5","@babel/core":"^7.14.6","@babel/plugin-proposal-class-properties":"^7.14.5","@babel/plugin-transform-runtime":"^7.14.5","@babel/preset-env":"^7.14.7","babel-eslint":"^10.1.0","codacy-coverage":"^3.4.0","debug-utils":"^0.5.3","eslint":"^7.30.0","eslint-config-airbnb-base":"^14.2.1","eslint-config-prettier":"^8.3.0","eslint-plugin-import":"^2.23.4","expect":"^27.0.6","jest":"^27.0.6","rimraf":"^3.0.2"},"engines":{"node":">=4.0.0"},"keywords":["excel","parser","builder","xlsx","xls"],"jest":{"testEnvironment":"node","setupFiles":["<rootDir>/test/setup.js"]},"_lastModified":"2024-05-21T03:00:01.905Z"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"xlsx","version":"0.17.5","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","unpkg":"dist/xlsx.full.min.js","jsdelivr":"dist/xlsx.full.min.js","types":"types/index.d.ts","browser":{"buffer":false,"crypto":false,"stream":false,"process":false,"fs":false},"dependencies":{"adler-32":"~1.2.0","cfb":"^1.1.4","codepage":"~1.15.0","crc-32":"~1.2.0","ssf":"~0.11.2","wmf":"~1.0.1","word":"~0.3.0"},"devDependencies":{"@sheetjs/uglify-js":"~2.7.3","@types/node":"^8.5.9","acorn":"7.4.1","alex":"^9.1.0","blanket":"~1.2.3","commander":"~2.17.1","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","typescript":"2.2.0"},"repository":{"type":"git","url":"git://github.com/SheetJS/sheetjs.git"},"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/","bugs":{"url":"https://github.com/SheetJS/sheetjs/issues"},"license":"Apache-2.0","engines":{"node":">=0.8"},"_lastModified":"2024-05-
|
|
1
|
+
{"name":"xlsx","version":"0.17.5","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","unpkg":"dist/xlsx.full.min.js","jsdelivr":"dist/xlsx.full.min.js","types":"types/index.d.ts","browser":{"buffer":false,"crypto":false,"stream":false,"process":false,"fs":false},"dependencies":{"adler-32":"~1.2.0","cfb":"^1.1.4","codepage":"~1.15.0","crc-32":"~1.2.0","ssf":"~0.11.2","wmf":"~1.0.1","word":"~0.3.0"},"devDependencies":{"@sheetjs/uglify-js":"~2.7.3","@types/node":"^8.5.9","acorn":"7.4.1","alex":"^9.1.0","blanket":"~1.2.3","commander":"~2.17.1","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","typescript":"2.2.0"},"repository":{"type":"git","url":"git://github.com/SheetJS/sheetjs.git"},"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/","bugs":{"url":"https://github.com/SheetJS/sheetjs/issues"},"license":"Apache-2.0","engines":{"node":">=0.8"},"_lastModified":"2024-05-21T03:00:04.298Z"}
|
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.0.0-alpha.
|
|
7
|
+
"version": "1.0.0-alpha.15",
|
|
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": "
|
|
37
|
+
"gitHead": "2793d371368e094ea2bba04cfbe9b9b73c44edba",
|
|
38
38
|
"keywords": [
|
|
39
39
|
"Actions"
|
|
40
40
|
]
|