@nocobase/plugin-action-import 2.2.0-alpha.1 → 2.2.0-beta.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/client-v2.d.ts +2 -0
- package/dist/client/index.js +1 -1
- package/dist/client/useFields.d.ts +1 -1
- package/dist/client-v2/buildImportFieldOptions.d.ts +22 -1
- package/dist/client-v2/getOptionFields.d.ts +1 -1
- package/dist/client-v2/index.js +1 -1
- package/dist/externalVersion.js +10 -10
- package/dist/locale/en-US.json +2 -1
- package/dist/locale/zh-CN.json +2 -1
- package/dist/node_modules/exceljs/package.json +1 -1
- package/dist/node_modules/xlsx/package.json +1 -1
- package/dist/server/actions/import-xlsx.d.ts +1 -1
- package/dist/server/actions/import-xlsx.js +38 -21
- package/dist/server/middleware/index.js +27 -1
- package/package.json +2 -2
package/client-v2.d.ts
CHANGED
package/dist/client/index.js
CHANGED
|
@@ -7,4 +7,4 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react-i18next"),require("@emotion/css"),require("react-dom"),require("@formily/antd-v5"),require("@formily/reactive"),require("@formily/react"),require("@ant-design/icons"),require("@nocobase/flow-engine"),require("@nocobase/client-v2"),require("@formily/shared"),require("@formily/core"),require("react"),require("antd"),require("@nocobase/client"),require("@nocobase/utils/client"),require("lodash")):"function"==typeof define&&define.amd?define("@nocobase/plugin-action-import",["react-i18next","@emotion/css","react-dom","@formily/antd-v5","@formily/reactive","@formily/react","@ant-design/icons","@nocobase/flow-engine","@nocobase/client-v2","@formily/shared","@formily/core","react","antd","@nocobase/client","@nocobase/utils/client","lodash"],t):"object"==typeof exports?exports["@nocobase/plugin-action-import"]=t(require("react-i18next"),require("@emotion/css"),require("react-dom"),require("@formily/antd-v5"),require("@formily/reactive"),require("@formily/react"),require("@ant-design/icons"),require("@nocobase/flow-engine"),require("@nocobase/client-v2"),require("@formily/shared"),require("@formily/core"),require("react"),require("antd"),require("@nocobase/client"),require("@nocobase/utils/client"),require("lodash")):e["@nocobase/plugin-action-import"]=t(e["react-i18next"],e["@emotion/css"],e["react-dom"],e["@formily/antd-v5"],e["@formily/reactive"],e["@formily/react"],e["@ant-design/icons"],e["@nocobase/flow-engine"],e["@nocobase/client-v2"],e["@formily/shared"],e["@formily/core"],e.react,e.antd,e["@nocobase/client"],e["@nocobase/utils/client"],e.lodash)}(self,function(e,t,n,r,o,i,a,l,c,u,s,p,f,m,d,y){return function(){var b={574:function(e,t,n){var r,o;void 0===(o="function"==typeof(r=function(){"use strict";function t(e,t,n){var r=new XMLHttpRequest;r.open("GET",e),r.responseType="blob",r.onload=function(){l(r.response,t,n)},r.onerror=function(){console.error("could not download file")},r.send()}function r(e){var t=new XMLHttpRequest;t.open("HEAD",e,!1);try{t.send()}catch(e){}return 200<=t.status&&299>=t.status}function o(e){try{e.dispatchEvent(new MouseEvent("click"))}catch(n){var t=document.createEvent("MouseEvents");t.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),e.dispatchEvent(t)}}var i="object"==typeof window&&window.window===window?window:"object"==typeof self&&self.self===self?self:"object"==typeof n.g&&n.g.global===n.g?n.g:void 0,a=i.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),l=i.saveAs||("object"!=typeof window||window!==i?function(){}:"download"in HTMLAnchorElement.prototype&&!a?function(e,n,a){var l=i.URL||i.webkitURL,c=document.createElement("a");c.download=n=n||e.name||"download",c.rel="noopener","string"==typeof e?(c.href=e,c.origin===location.origin?o(c):r(c.href)?t(e,n,a):o(c,c.target="_blank")):(c.href=l.createObjectURL(e),setTimeout(function(){l.revokeObjectURL(c.href)},4e4),setTimeout(function(){o(c)},0))}:"msSaveOrOpenBlob"in navigator?function(e,n,i){if(n=n||e.name||"download","string"!=typeof e){var a;navigator.msSaveOrOpenBlob((void 0===(a=i)?a={autoBom:!1}:"object"!=typeof a&&(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(e.type)?new Blob(["\uFEFF",e],{type:e.type}):e),n)}else if(r(e))t(e,n,i);else{var l=document.createElement("a");l.href=e,l.target="_blank",setTimeout(function(){o(l)})}}:function(e,n,r,o){if((o=o||open("","_blank"))&&(o.document.title=o.document.body.innerText="downloading..."),"string"==typeof e)return t(e,n,r);var l="application/octet-stream"===e.type,c=/constructor/i.test(i.HTMLElement)||i.safari,u=/CriOS\/[\d]+/.test(navigator.userAgent);if((u||l&&c||a)&&"u">typeof FileReader){var s=new FileReader;s.onloadend=function(){var e=s.result;e=u?e:e.replace(/^data:[^;]*;/,"data:attachment/file;"),o?o.location.href=e:location=e,o=null},s.readAsDataURL(e)}else{var p=i.URL||i.webkitURL,f=p.createObjectURL(e);o?o.location=f:location.href=f,o=null,setTimeout(function(){p.revokeObjectURL(f)},4e4)}});i.saveAs=l.saveAs=l,e.exports=l})?r.apply(t,[]):r)||(e.exports=o)},375:function(e){"use strict";e.exports=a},477:function(e){"use strict";e.exports=t},418:function(e){"use strict";e.exports=r},452:function(e){"use strict";e.exports=s},230:function(e){"use strict";e.exports=i},992:function(e){"use strict";e.exports=o},166:function(e){"use strict";e.exports=u},342:function(e){"use strict";e.exports=m},485:function(e){"use strict";e.exports=c},694:function(e){"use strict";e.exports=l},768:function(e){"use strict";e.exports=d},59:function(e){"use strict";e.exports=f},773:function(e){"use strict";e.exports=y},155:function(e){"use strict";e.exports=p},514:function(e){"use strict";e.exports=n},953:function(t){"use strict";t.exports=e}},v={};function h(e){var t=v[e];if(void 0!==t)return t.exports;var n=v[e]={exports:{}};return b[e].call(n.exports,n,n.exports,h),n.exports}h.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return h.d(t,{a:t}),t},h.d=function(e,t){for(var n in t)h.o(t,n)&&!h.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},h.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),h.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},h.r=function(e){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},h.g.importScripts&&(g=h.g.location+"");var g,x=h.g.document;if(!g&&x&&(x.currentScript&&"SCRIPT"===x.currentScript.tagName.toUpperCase()&&(g=x.currentScript.src),!g)){var w=x.getElementsByTagName("script");if(w.length)for(var S=w.length-1;S>-1&&(!g||!/^http(s?):/.test(g));)g=w[S--].src}if(!g)throw Error("Automatic publicPath is not supported in this browser");h.p=g.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/");var O={};return!function(){"use strict";var e="",t="u">typeof document?document.currentScript:null;if(t&&t.src&&(e=t.src.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/")),!e){var n=window.__webpack_public_path__||"";n&&("/"!==n.charAt(n.length-1)&&(n+="/"),e=n+"static/plugins/@nocobase/plugin-action-import/dist/client/")}if(!e){var r=window.__nocobase_modern_client_prefix__||"v",o="/"+(r=String(r).replace(/^\/+|\/+$/g,"")||"v")+"/";if(!(e=window.__nocobase_public_path__||"")&&window.location&&window.location.pathname){var i=window.location.pathname||"/",a=i.indexOf(o);e=a>=0?i.slice(0,a+1):"/"}e&&(e=e.replace(RegExp("/"+r+"/?$"),"/")),e||(e="/"),"/"!==e.charAt(e.length-1)&&(e+="/"),e+="static/plugins/@nocobase/plugin-action-import/dist/client/"}h.p=e}(),!function(){"use strict";h.r(O),h.d(O,{useImportStartAction:function(){return J},default:function(){return eq},ImportActionInitializer:function(){return x},ImportContextProvider:function(){return ea},DownloadTips:function(){return g},ImportPluginProvider:function(){return ei},ImportDesigner:function(){return D},ImportWarning:function(){return v},ImportActionModel:function(){return eA},PluginActionImportClient:function(){return eR},buildImportFieldOptions:function(){return s},initImportSettings:function(){return b},useDownloadXlsxTemplateAction:function(){return W}});var e=h(166),t=h(342),n=h(155),r=h.n(n),o=["createdAt","createdBy","updatedAt","updatedBy"],i=["hasOne","belongsTo","hasMany","belongsToMany","belongsToArray"],a=function(e){return(null==e?void 0:e.target)&&i.includes(e.type)},l=function(e){return!(null==e?void 0:e.interface)||o.includes(e.interface)},c=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return{name:e.name,title:t(e),schema:null==e?void 0:e.uiSchema,disabled:n}},u=function(e,t,n){var r,o,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;if(l(e))return null;if(!a(e))return c(e,t);var s=(n(e)||[]).map(function(e){return l(e)?null:a(e)?i>=1?c(e,t,!0):u(e,t,n,i+1):u(e,t,n)}).filter(Boolean);return s.length?(r=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({},c(e,t)),o=o={children:s},Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(o)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(o)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(o,e))}),r):c(e,t,!0)},s=function(e,t,n){return(e||[]).map(function(e){return u(e,t,n,+!!a(e))}).filter(Boolean)},p=function(e){var n=(0,t.useCollectionManager_deprecated)().getCollectionFields,r=n(e),o=(0,t.useCompile)();return s(r,function(e){var t;return o(null==e||null==(t=e.uiSchema)?void 0:t.title)||e.name},function(e){return n(e.target)})},f=h(768),m=h(59),d=h(953),y="action-import",b=function(e){return{importColumns:null==e?void 0:e.filter(function(e){return!e.children&&!e.disabled}).map(function(e){return{dataIndex:[e.name]}}),explain:""}},v=function(){var e=(0,d.useTranslation)([y,"client"],{nsMode:"fallback"}).t;return r().createElement(m.Alert,{type:"warning",style:{marginBottom:"10px"},message:e("Import warnings",{limit:2e3})})},g=function(){var e=(0,d.useTranslation)([y,"client"],{nsMode:"fallback"}).t;return r().createElement(m.Alert,{type:"info",style:{marginBottom:"10px",whiteSpace:"pre-line"},message:e("Download tips")})},x=function(){var n=(0,t.useSchemaInitializerItem)(),o=(0,t.useSchemaInitializer)().insert,i=p((0,t.useCollection_deprecated)().name),a={type:"void",title:'{{ t("Import") }}',"x-component":"ImportAction","x-action":"importXlsx","x-settings":"actionSettings:import","x-toolbar":"ActionSchemaToolbar"};return r().createElement(t.SchemaInitializerItem,{title:n.title,onClick:function(){f.lodash.set(a,"x-action-settings.importSettings",b(i));var t,r=(0,e.merge)(a||{},n.schema||{});null==n||null==(t=n.schemaInitialize)||t.call(n,r),o(r)}})},w=h(418),S=h(230);function I(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function j(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function A(){var e=j(["\n width: 100%;\n & .ant-space-item:nth-child(2) {\n flex: 1;\n }\n "]);return A=function(){return e},e}function P(){var e=j(["\n border-color: var(--colorSettings);\n color: var(--colorSettings);\n &.ant-btn-dashed:hover {\n border-color: var(--colorSettings);\n color: var(--colorSettings);\n }\n "]);return P=function(){return e},e}var E=["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.ms-excel","application/wps-office.xlsx"],C=function(){var e=(0,d.useTranslation)(y).t,n=p((0,t.useCollection_deprecated)().name),r=(0,t.useCompile)();return{importSettingsSchema:{type:"void","x-component":"Grid",properties:{explain:{type:"string",title:'{{ t("Import explain", {ns: "'.concat(y,'"}) }}'),"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:(0,t.css)(A())},properties:{sort:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.SortHandle"},dataIndex:{type:"array","x-decorator":"FormItem","x-component":t.Cascader,required:!0,"x-use-component-props":function(){return{options:r(n)}},"x-component-props":{fieldNames:{label:"title",value:"name",children:"children"},changeOnSelect:!1}},title:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:'{{ t("Custom column title") }}'}},description:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:'{{ t("Field description placeholder", {ns: "'.concat(y,'"}) }}')}},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:'{{ t("Add importable field", {ns: "'.concat(y,'"}) }}'),"x-component":"ArrayItems.Addition","x-component-props":{className:(0,t.css)(P())}}}}}},beforeUploadHandler:function(){return!1},uploadValidator:function(t,n){if(t.length>1)return{type:"error",message:e("Only one file is allowed to be uploaded")};var r,o=null!=(r=t[0])?r:{};return E.includes(o.type)?"":{type:"error",message:e("Please upload the file of Excel")}},validateUpload:function(e,t,n){var r,o,i,a=(function(e){if(Array.isArray(e))return e}(n)||function(e){var t,n,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],i=!0,a=!1;try{for(r=r.call(e);!(i=(t=r.next()).done)&&(o.push(t.value),1!==o.length);i=!0);}catch(e){a=!0,n=e}finally{try{i||null==r.return||r.return()}finally{if(a)throw n}}return o}}(n)||function(e){if(e){if("string"==typeof e)return I(e,1);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return I(e,1)}}(n)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())[0];t.disabled=(null==a?void 0:a.length)===0,r=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({},t.componentProps),o=o={disabled:(null==a?void 0:a.length)===0||(null==(i=e.errors)?void 0:i.length)>0},Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(o)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(o)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(o,e))}),t.componentProps=r}}};function T(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function k(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function F(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){k(e,t,n[t])})}return e}var D=function(){var e,o,i,a,l,c,u,s=(0,S.useField)(),p=(0,S.useFieldSchema)(),f=(0,d.useTranslation)().t,m=(0,t.useDesignable)().dn,y=function(e){if(Array.isArray(e))return e}(e=(0,n.useState)())||function(e){var t,n,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],i=!0,a=!1;try{for(r=r.call(e);!(i=(t=r.next()).done)&&(o.push(t.value),2!==o.length);i=!0);}catch(e){a=!0,n=e}finally{try{i||null==r.return||r.return()}finally{if(a)throw n}}return o}}(e)||function(e){if(e){if("string"==typeof e)return T(e,2);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return T(e,2)}}(e)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),b=y[0],v=y[1],h=C().importSettingsSchema;return(0,n.useEffect)(function(){v(h)},[s.address,null==p||null==(i=p["x-action-settings"])?void 0:i.importSettings]),r().createElement(t.GeneralSchemaDesigner,{disableInitializer:!0},r().createElement(t.SchemaSettingsModalItem,{title:f("Edit button"),schema:{type:"object",title:f("Edit button"),properties:{title:{"x-decorator":"FormItem","x-component":"Input",title:f("Button title"),default:p.title,"x-component-props":{}},icon:{"x-decorator":"FormItem","x-component":"IconPicker",title:f("Button icon"),default:null==p||null==(a=p["x-component-props"])?void 0:a.icon,"x-component-props":{}},type:{"x-decorator":"FormItem","x-component":"Radio.Group",title:f("Button background color"),default:(null==p||null==(l=p["x-component-props"])?void 0:l.danger)?"danger":(null==p||null==(c=p["x-component-props"])?void 0:c.type)==="primary"?"primary":"default",enum:[{value:"default",label:'{{t("Default")}}'},{value:"primary",label:'{{t("Highlight")}}'},{value:"danger",label:'{{t("Danger red")}}'}]}}},onSubmit:function(e){var t,n=e.title,r=e.icon,o=e.type;p.title=n,s.title=n,s.componentProps.icon=r,s.componentProps.danger="danger"===o,s.componentProps.type=o,p["x-component-props"]=p["x-component-props"]||{},p["x-component-props"].icon=r,p["x-component-props"].danger="danger"===o,p["x-component-props"].type=o,m.emit("patch",{schema:(k(t={},"x-uid",p["x-uid"]),k(t,"title",n),k(t,"x-component-props",F({},p["x-component-props"])),t)}),m.refresh()}}),r().createElement(t.SchemaSettingsActionModalItem,{title:f("Importable fields"),schema:b,initialValues:F({},null!=(o=null==p||null==(u=p["x-action-settings"])?void 0:u.importSettings)?o:{}),components:{ArrayItems:w.ArrayItems},onSubmit:function(e){var t,n=e.importColumns,r=e.explain,o=null==n?void 0:n.filter(function(e){var t;return null==e||null==(t=e.dataIndex)?void 0:t.length}).map(function(e){return{dataIndex:e.dataIndex.map(function(e){var t;return null!=(t=e.name)?t:e}),title:e.title}});p["x-action-settings"].importSettings={importColumns:o,explain:r},m.emit("patch",{schema:(k(t={},"x-uid",p["x-uid"]),k(t,"x-action-settings",p["x-action-settings"]),t)}),m.refresh()}}),r().createElement(t.SchemaSettingsDivider,null),r().createElement(t.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:function(e){return"Space"===e["x-component"]||e["x-component"].endsWith("ActionBar")},confirm:{title:f("Delete action")}}))},M=h(514),_=(0,n.createContext)(null);_.displayName="ImportContext";var B=function(){return(0,n.useContext)(_)},R=h(375),q=h(574);function U(){var e,t,n=(e=["\n display: flex;\n justify-content: center;\n align-items: center;\n height: 100%;\n "],t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}})));return U=function(){return n},n}var L=function(e){var n=(0,d.useTranslation)(y).t,o=B(),i=o.importModalVisible,a=o.importStatus,l=o.importResult,c=o.setImportModalVisible,u=null!=l?l:{},s=u.data,p=u.meta,f=function(){c(!1)};return r().createElement(m.Modal,{title:n("Import Data"),width:"50%",styles:{body:{height:"calc(80vh - 200px)"}},open:i,footer:null,closable:2===a,onCancel:f},r().createElement("div",{className:(0,t.css)(U())},1===a&&r().createElement(m.Spin,{indicator:r().createElement(R.LoadingOutlined,{style:{fontSize:24},spin:!0}),tip:n("Excel data importing")}),2===a&&r().createElement(m.Space,{direction:"vertical",align:"center"},r().createElement(R.ExclamationCircleFilled,{style:{fontSize:72,color:"#1890ff"}}),r().createElement("p",null,function(e){if(!e)return null;var t=e.data,r=e.meta;if(r)return n("{{successCount}} records have been successfully imported",function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({},null!=r?r:{}));var o=["".concat(n("Total records"),": ").concat(t.total||0),"".concat(n("Successfully imported"),": ").concat(t.success||0)];return t.skipped>0&&o.push("".concat(n("Skipped"),": ").concat(t.skipped)),t.updated>0&&o.push("".concat(n("Updated"),": ").concat(t.updated)),o.join(", ")}(l)),r().createElement(m.Space,null,(null==p?void 0:p.failureCount)>0&&r().createElement(m.Button,{onClick:function(){var e=new Blob([new Int8Array(null==s?void 0:s.data)],{type:"application/x-xls"});(0,q.saveAs)(e,"fail.xlsx")}},n("To download the failure data")),r().createElement(m.Button,{type:"primary",onClick:f},n("Done"))))))},z=h(773),N=h.n(z);function $(e,t,n,r,o,i,a){try{var l=e[i](a),c=l.value}catch(e){n(e);return}l.done?t(c):Promise.resolve(c).then(r,o)}function X(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){$(i,r,o,a,l,"next",e)}function l(e){$(i,r,o,a,l,"throw",e)}a(void 0)})}}function V(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),l=Object.defineProperty;return l(a,"next",{value:c(0)}),l(a,"throw",{value:c(1)}),l(a,"return",{value:c(2)}),"function"==typeof Symbol&&l(a,Symbol.iterator,{value:function(){return this}}),a;function c(l){return function(c){var u=[l,c];if(n)throw TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=t.call(e,i)}catch(e){u=[6,e],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}var H=function(){for(var e=(0,t.useActionContext)().fieldSchema,n=(0,S.useFieldSchema)(),r=e||n;r&&"importXlsx"!==r["x-action"];)console.log("schema",r=r.parent);return{schema:r}},G=function(e){return e&&Array.isArray(e)?e:[]},W=function(){var e=(0,t.useBlockRequestContext)().resource,n=(0,t.useCompile)(),r=(0,t.useCollectionManager_deprecated)(),o=r.getCollectionJoinField,i=r.getCollectionField,a=(0,t.useCollection_deprecated)(),l=a.name,c=a.title,u=H().schema;return{run:function(){return X(function(){var t,r,a,s,p,f,m;return V(this,function(d){switch(d.label){case 0:return s=(a=N().cloneDeep(null!=(t=null==u||null==(r=u["x-action-settings"])?void 0:r.importSettings)?t:{})).importColumns,p=a.explain,f=G(s).map(function(e){var t=i("".concat(l,".").concat(e.dataIndex[0]));if(t){if(e.defaultTitle=n(null==t||null==(r=t.uiSchema)?void 0:r.title)||t.name,e.dataIndex.length>1){var r,a,c=o("".concat(l,".").concat(e.dataIndex.join(".")));if(!c)return;e.defaultTitle=e.defaultTitle+"/"+n(null==c||null==(a=c.uiSchema)?void 0:a.title)||c.name}return"chinaRegion"===t.interface&&e.dataIndex.push("name"),e}}).filter(Boolean),[4,e.downloadXlsxTemplate({values:{title:n(c),explain:p,columns:n(f)}},{method:"post",responseType:"blob"})];case 1:return m=new Blob([d.sent().data],{type:"application/x-xls"}),(0,q.saveAs)(m,"".concat(n(c),".xlsx")),[2]}})})()}}},J=function(){var e,r=(0,t.useBlockRequestContext)().service,o=(0,t.useCompile)(),i=(0,t.useCollectionManager_deprecated)(),a=i.getCollectionJoinField,l=i.getCollectionField,c=(0,t.useCollection_deprecated)().name,u=H().schema,s=(0,S.useForm)(),p=(0,t.useActionContext)().setVisible,f=B(),m=f.setImportModalVisible,d=f.setImportStatus,y=f.setImportResult,b=s.values.upload,v=(0,t.useDataBlockResource)();return(0,n.useEffect)(function(){s.reset()},[]),{run:function(){return X(function(){var e,t,n,i,f,b,h,g,x,w,S,O,I,j;return V(this,function(A){switch(A.label){case 0:b=(f=N().cloneDeep(null!=(e=null==u||null==(t=u["x-action-settings"])?void 0:t.importSettings)?e:{})).importColumns,h=f.explain,g=G(b).map(function(e){var t=l("".concat(c,".").concat(e.dataIndex[0]));if(t){if(e.defaultTitle=o(null==t||null==(n=t.uiSchema)?void 0:n.title)||t.name,e.dataIndex.length>1){var n,r,i=a("".concat(c,".").concat(e.dataIndex.join(".")));if(!i)return;e.defaultTitle=e.defaultTitle+"/"+o(null==i||null==(r=i.uiSchema)?void 0:r.title)||i.name}return"chinaRegion"===t.interface&&e.dataIndex.push("name"),e}}).filter(Boolean),x=new FormData,w=s.values.upload.map(function(e){return e.originFileObj}),x.append("file",w[0]),x.append("columns",JSON.stringify(g)),x.append("explain",h),S=(null==u||null==(n=u["x-action-settings"])?void 0:n.importMode)||"auto",O=(null==u||null==(i=u["x-action-settings"])?void 0:i.timeout)||6e5,p(!1),m(!0),d(1),A.label=1;case 1:return A.trys.push([1,6,,7]),[4,v.importXlsx({values:x,mode:S,timeout:O})];case 2:if(I=A.sent().data,s.reset(),I.data.taskId)return[3,4];return y(I),[4,null==r||null==(j=r.refresh)?void 0:j.call(r)];case 3:return A.sent(),d(2),[3,5];case 4:m(!1),p(!1),A.label=5;case 5:return[3,7];case 6:return A.sent(),m(!1),p(!0),[3,7];case 7:return[2]}})})()},disabled:(null==b?void 0:b.length)===0||(null==(e=s.errors)?void 0:e.length)>0}},K=h(477);function Q(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function Y(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function Z(){var e=Y(["\n .ant-formily-item-label {\n height: var(--controlHeightLG);\n }\n "]);return Z=function(){return e},e}function ee(){var e=Y(["\n margin-top: 5px;\n "]);return ee=function(){return e},e}var et={type:"void",name:"import-modal",title:'{{ t("Import Data", {ns: "'.concat(y,'" }) }}'),"x-component":"Action.Modal","x-decorator":"Form","x-component-props":{width:"100%",style:{maxWidth:"750px"},className:(0,K.css)(Z())},properties:{formLayout:{type:"void","x-component":"FormLayout",properties:{warning:{type:"void","x-component":"ImportWarning"},download:{type:"void",title:'{{ t("Step 1: Download template", {ns: "'.concat(y,'" }) }}'),"x-component":"FormItem","x-acl-ignore":!0,properties:{tip:{type:"void","x-component":"DownloadTips"},downloadAction:{type:"void",title:'{{ t("Download template", {ns: "'.concat(y,'" }) }}'),"x-component":"Action","x-component-props":{className:(0,K.css)(ee()),useAction:"{{ useDownloadXlsxTemplateAction }}"}}}},upload:{type:"array",title:'{{ t("Step 2: Upload Excel", {ns: "'.concat(y,'" }) }}'),"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: "'.concat(y,'" }) }}'),beforeUpload:"{{ beforeUploadHandler }}"}}}},footer:{"x-component":"Action.Modal.Footer","x-component-props":{},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{},properties:{cancel:{type:"void",title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},startImport:{type:"void",title:'{{ t("Start import", {ns: "'.concat(y,'" }) }}'),"x-component":"Action","x-component-props":{type:"primary",htmlType:"submit",useAction:"{{ useImportStartAction }}"},"x-reactions":{dependencies:["upload"],fulfill:{run:"validateUpload($form, $self, $deps)"}}}}}}}}},en=function(e){var o,i,a,l=function(e){if(Array.isArray(e))return e}(o=(0,n.useState)(!1))||function(e){var t,n,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],i=!0,a=!1;try{for(r=r.call(e);!(i=(t=r.next()).done)&&(o.push(t.value),2!==o.length);i=!0);}catch(e){a=!0,n=e}finally{try{i||null==r.return||r.return()}finally{if(a)throw n}}return o}}(o)||function(e){if(e){if("string"==typeof e)return Q(e,2);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return Q(e,2)}}(o)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),c=l[0],u=l[1],s=(0,t.useCompile)(),p=(0,S.useFieldSchema)();return r().createElement(t.ActionContextProvider,{value:{visible:c,setVisible:u,fieldSchema:p}},r().createElement(t.Action,(i=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({icon:e.icon||"uploadoutlined",title:s((null==p?void 0:p.title)||"t('Import')")},e),a=a={onClick:function(){return u(!0)}},Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(a)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(a)).forEach(function(e){Object.defineProperty(i,e,Object.getOwnPropertyDescriptor(a,e))}),i)),r().createElement(t.SchemaComponent,{schema:et}))};function er(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function eo(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,l=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(e){l=!0,r=e}finally{try{a||null==o.return||o.return()}finally{if(l)throw r}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return er(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return er(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var ei=function(e){var n=C(),o=n.uploadValidator,i=n.beforeUploadHandler,a=n.validateUpload;return r().createElement(t.SchemaComponentOptions,{components:{ImportActionInitializer:x,ImportDesigner:D,ImportWarning:v,DownloadTips:g,ImportAction:en},scope:{uploadValidator:o,validateUpload:a,beforeUploadHandler:i,useDownloadXlsxTemplateAction:W,useImportStartAction:J}},r().createElement(ea,null,e.children))},ea=function(e){var t=eo((0,n.useState)(!1),2),o=t[0],i=t[1],a=eo((0,n.useState)(1),2),l=a[0],c=a[1],u=eo((0,n.useState)(null),2),s=u[0],p=u[1];return r().createElement(_.Provider,{value:{importModalVisible:o,setImportModalVisible:i,importStatus:l,setImportStatus:c,importResult:s,setImportResult:p}},(0,M.createPortal)(r().createElement(L,null),document.body),e.children)},el=h(452),ec=h(992),eu=h(485),es=h(694);function ep(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function ef(e,t,n,r,o,i,a){try{var l=e[i](a),c=l.value}catch(e){n(e);return}l.done?t(c):Promise.resolve(c).then(r,o)}function em(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){ef(i,r,o,a,l,"next",e)}function l(e){ef(i,r,o,a,l,"throw",e)}a(void 0)})}}function ed(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ey(e){return(ey=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function eb(e,t){return(eb=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function ev(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function eh(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(eh=function(){return!!e})()}function eg(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),l=Object.defineProperty;return l(a,"next",{value:c(0)}),l(a,"throw",{value:c(1)}),l(a,"return",{value:c(2)}),"function"==typeof Symbol&&l(a,Symbol.iterator,{value:function(){return this}}),a;function c(l){return function(c){var u=[l,c];if(n)throw TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=t.call(e,i)}catch(e){u=[6,e],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}function ex(){var e=ev(["\n margin-top: 5px;\n "]);return ex=function(){return e},e}function ew(){var e=ev(["\n width: 100%;\n & .ant-space-item:nth-child(2) {\n flex: 1;\n }\n "]);return ew=function(){return e},e}function eS(){var e=ev(["\n border-color: var(--colorSettings);\n color: var(--colorSettings);\n &.ant-btn-dashed:hover {\n border-color: var(--colorSettings);\n color: var(--colorSettings);\n }\n "]);return eS=function(){return e},e}var eO=["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.ms-excel","application/wps-office.xlsx"],eI={type:"object",properties:{warning:{type:"void","x-component":"ImportWarning"},download:{type:"void",title:(0,es.escapeT)("Step 1: Download template",{ns:"".concat(y)}),"x-component":"FormItem",properties:{tip:{type:"void","x-component":"DownloadTips"},downloadAction:{type:"void",title:(0,es.escapeT)("Download template",{ns:"".concat(y)}),"x-component":"Button","x-component-props":{className:(0,K.css)(ex()),children:(0,es.escapeT)("Download template",{ns:"".concat(y)}),onClick:"{{ handelDownloadXlsxTemplateAction }}"}}}},upload:{type:"array",title:(0,es.escapeT)("Step 2: Upload Excel",{ns:"".concat(y)}),"x-decorator":"FormItem","x-acl-ignore":!0,"x-component":"Upload.Dragger","x-validator":function(e){var t,n=e.fileList;if(n.length>1)return{type:"error",message:(0,es.escapeT)("Only one file is allowed to be uploaded")};var r=null!=(t=n[0])?t:{};return eO.includes(r.type)?"":{type:"error",message:(0,es.escapeT)("Please upload the file of Excel")}},"x-component-props":{action:"",height:"150px",maxCount:1,children:(0,es.escapeT)("Upload placeholder",{ns:"".concat(y)}),beforeUpload:function(){return!1}}}}},ej=(0,S.createSchemaField)({components:{ImportWarning:v,DownloadTips:g,Upload:m.Upload,FormItem:w.FormItem,Button:m.Button}}),eA=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function n(){var e,t,r;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return t=n,r=arguments,t=ey(t),ed(e=function(e,t){var n;if(t&&("object"==((n=t)&&"u">typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,eh()?Reflect.construct(t,r||[],ey(this).constructor):t.apply(this,r)),"defaultProps",{title:(0,es.escapeT)("Import"),type:"default",icon:"uploadoutlined"}),e}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&eb(n,e),t=[{key:"getAclActionName",value:function(){return"importXlsx"}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(n.prototype,t),n}(eu.ActionModel);function eP(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function eE(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function eC(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){eE(e,t,n[t])})}return e}ed(eA,"scene",eu.ActionSceneEnum.collection),eA.define({label:(0,es.escapeT)("Import")}),eA.registerFlow({key:"importSettings",title:(0,es.escapeT)("Import settings"),on:"click",steps:{import:{handler:function(e){return em(function(){var t,n,o,i,a,l,c,u,s,p,f,d;return eg(this,function(b){switch(b.label){case 0:var v;return t=(0,ec.observable)({status:"",result:null}),n=(0,el.createForm)(),i=(o=e.model.context.blockModel).resource,l=(a=o.collection).title,c=a.name,s=(u=e.model.getProps().importSettings).explain,p=(!(v=u.importColumns)||!Array.isArray(v)?[]:v).map(function(t){var n=e.model.context.dataSourceManager.getCollectionField("".concat(o.collection.dataSourceKey,".").concat(c,".").concat(t.dataIndex[0]));if(n){if(t.defaultTitle=e.t(null==n||null==(r=n.uiSchema)?void 0:r.title)||n.name,t.dataIndex.length>1){var r,i,a=e.model.context.dataSourceManager.getCollectionField("".concat(e.model.context.collection.dataSourceKey,".").concat(c,".").concat(t.dataIndex.join(".")));if(!a)return;t.defaultTitle=t.defaultTitle+"/"+e.t(null==a||null==(i=a.uiSchema)?void 0:i.title)||a.name}return t}}).filter(Boolean),f=function(){return em(function(){var t;return eg(this,function(n){switch(n.label){case 0:return[4,i.runAction("downloadXlsxTemplate",{data:{title:e.t(l),explain:s,columns:function(e){if(Array.isArray(e))return ep(e)}(p)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(p)||function(e){if(e){if("string"==typeof e)return ep(e,void 0);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return ep(e,void 0)}}(p)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()},responseType:"blob",method:"post"})];case 1:return t=new Blob([n.sent()],{type:"application/x-xls"}),(0,q.saveAs)(t,"".concat(e.t(l),".xlsx")),[2]}})})()},d=(0,es.observer)(function(o){var a=o.popover,l=e.t;if("importing"===t.status)return r().createElement("div",{style:{display:"flex",justifyContent:"center",padding:40}},r().createElement(m.Spin,{tip:l("Excel data importing"),indicator:r().createElement(R.LoadingOutlined,{spin:!0,style:{fontSize:24}})}));if("imported"===t.status){var c,u,d,b=null==(d=t.result)?void 0:d.meta;return r().createElement(m.Space,{direction:"vertical",align:"center",style:{width:"100%",padding:24}},r().createElement(R.ExclamationCircleFilled,{style:{fontSize:72,color:"#1890ff"}}),r().createElement("p",null,function(e){if(!e)return null;var t=e.successCount;if(t)return l("{{successCount}} records have been successfully imported",{successCount:t,ns:y})}(t.result)),r().createElement(m.Space,null,(null==b?void 0:b.failureCount)>0&&r().createElement(m.Button,{onClick:function(){var e,n,r=new Blob([new Int8Array(null==(n=t.result)||null==(e=n.data)?void 0:e.data)],{type:"application/x-xls"});(0,q.saveAs)(r,"fail.xlsx")}},l("To download the failure data")),r().createElement(m.Button,{type:"primary",onClick:function(){a.close(),t.status="",t.result=null}},l("Done"))))}return r().createElement(S.FormProvider,{form:n},r().createElement(w.FormLayout,{layout:"vertical"},r().createElement(ej,{schema:eI,scope:{t:e.t,handelDownloadXlsxTemplateAction:f}})),r().createElement(w.FormButtonGroup,{align:"right"},r().createElement(m.Button,{onClick:function(){return a.close()}},l("Cancel")),r().createElement(m.Button,{type:"primary",onClick:function(){return em(function(){var r,o,l,c,u,f,m,d;return eg(this,function(y){switch(y.label){case 0:r=n.values.upload.fileList,o=new FormData,l=r.map(function(e){return e.originFileObj}),o.append("file",l[0]),o.append("columns",JSON.stringify(p)),o.append("explain",s),c=e.model.getProps().importMode,t.status="importing",y.label=1;case 1:return y.trys.push([1,6,,7]),[4,i.runAction("importXlsx",{data:o,mode:c,timeout:6e5})];case 2:if(null==(f=y.sent().data)||null==(u=f.data)?void 0:u.taskId)return[3,4];return t.result=f,t.status="imported",[4,null==i||null==(m=i.refresh)?void 0:m.call(i)];case 3:return y.sent(),n.reset(),[3,5];case 4:a.close(),n.reset(),y.label=5;case 5:return[3,7];case 6:return d=y.sent(),t.status="",console.error(d),[3,7];case 7:return[2]}})})()},disabled:!(null==(u=n.values.upload)||null==(c=u.fileList)?void 0:c.length)},l("Start import",{ns:"".concat(y)}))))}),[4,e.viewer.open({type:"dialog",placement:"center",width:800,title:e.t("Import Data",{ns:"".concat(y)}),content:function(e){return r().createElement(d,{popover:e})}})];case 1:return b.sent(),[2]}})})()}}}}),eA.registerFlow({key:"importActionSetting",title:(0,es.escapeT)("Import action settings",{ns:y}),steps:{importSetting:{title:(0,es.escapeT)("Importable fields"),uiSchema:function(e){var t,n,r=(t=e.model.context.blockModel.collection.getFields(),n=e.t,s(t,function(e){var t;return n(null==e||null==(t=e.uiSchema)?void 0:t.title)||e.name},function(e){return e.targetCollection&&e.targetCollection.getFields()||[]}));return{explain:{type:"string",title:'{{ t("Import explain", {ns: "'.concat(y,'"}) }}'),"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:(0,K.css)(ew())},properties:{sort:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.SortHandle"},dataIndex:{type:"array","x-decorator":"FormItem","x-component":m.Cascader,required:!0,"x-component-props":{fieldNames:{label:"title",value:"name",children:"children"},changeOnSelect:!1,options:r}},title:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:'{{ t("Custom column title") }}'}},description:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:'{{ t("Field description placeholder", {ns: "'.concat(y,'"}) }}')}},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:'{{ t("Add importable field", {ns: "'.concat(y,'"}) }}'),"x-component":"ArrayItems.Addition","x-component-props":{className:(0,K.css)(eS())}}}}}},defaultParams:function(e){return function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){ed(e,t,n[t])})}return e}({},b(e.model.context.blockModel.collection.getFields()))},handler:function(e,t){var n=t.importColumns,r=t.explain,o=null==n?void 0:n.filter(function(e){var t;return null==e||null==(t=e.dataIndex)?void 0:t.length}).map(function(e){return{dataIndex:e.dataIndex.map(function(e){var t;return null!=(t=e.name)?t:e}),title:e.title,description:e.description}});e.model.setProps("importSettings",{importColumns:o,explain:r})}}}});var eT=new t.SchemaSettings({name:"actionSettings:import",items:[{name:"editButton",Component:t.ButtonEditor,useComponentProps:function(){return(0,t.useSchemaToolbar)().buttonEditorProps}},{name:"linkageRules",Component:t.SchemaSettingsLinkageRules,useComponentProps:function(){return eC({},(0,t.useSchemaToolbar)().linkageRulesProps)}},{name:"importableFields",type:"actionModal",useComponentProps:function(){var e,r,o,i,a=(0,S.useField)(),l=(0,S.useFieldSchema)(),c=(0,d.useTranslation)().t,u=(0,t.useDesignable)().dn,s=function(e){if(Array.isArray(e))return e}(e=(0,n.useState)())||function(e){var t,n,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],i=!0,a=!1;try{for(r=r.call(e);!(i=(t=r.next()).done)&&(o.push(t.value),2!==o.length);i=!0);}catch(e){a=!0,n=e}finally{try{i||null==r.return||r.return()}finally{if(a)throw n}}return o}}(e)||function(e){if(e){if("string"==typeof e)return eP(e,2);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return eP(e,2)}}(e)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),p=s[0],f=s[1],m=C().importSettingsSchema;return(0,n.useEffect)(function(){f(m)},[a.address,null==l||null==(o=l["x-action-settings"])?void 0:o.importSettings]),{title:c("Importable fields"),schema:eC({},p),initialValues:eC({},null!=(r=null==l||null==(i=l["x-action-settings"])?void 0:i.importSettings)?r:{}),components:{ArrayItems:w.ArrayItems},onSubmit:function(e){var t,n=e.importColumns,r=e.explain,o=null==n?void 0:n.filter(function(e){var t;return null==e||null==(t=e.dataIndex)?void 0:t.length}).map(function(e){return{dataIndex:e.dataIndex.map(function(e){var t;return null!=(t=e.name)?t:e}),title:e.title,description:e.description}});l["x-action-settings"].importSettings={importColumns:o,explain:r},u.emit("patch",{schema:(eE(t={},"x-uid",l["x-uid"]),eE(t,"x-action-settings",l["x-action-settings"]),t)}),u.refresh()}}}},{name:"divider",type:"divider"},{name:"delete",type:"remove",useComponentProps:function(){return{removeParentsIfNoChildren:!0,breakRemoveOn:function(e){return"Space"===e["x-component"]||e["x-component"].endsWith("ActionBar")},confirm:{title:(0,(0,d.useTranslation)().t)("Delete action")}}}}]});function ek(e,t,n,r,o,i,a){try{var l=e[i](a),c=l.value}catch(e){n(e);return}l.done?t(c):Promise.resolve(c).then(r,o)}function eF(e,t,n){return(eF=eB()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&eM(o,n.prototype),o}).apply(null,arguments)}function eD(e){return(eD=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function eM(e,t){return(eM=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function e_(e){var t="function"==typeof Map?new Map:void 0;return(e_=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return eF(e,arguments,eD(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),eM(n,e)})(e)}function eB(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(eB=function(){return!!e})()}var eR=function(e){var n;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function r(){var e,t;if(!(this instanceof r))throw TypeError("Cannot call a class as a function");return e=r,t=arguments,e=eD(e),function(e,t){var n;if(t&&("object"==((n=t)&&"u">typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,eB()?Reflect.construct(e,t||[],eD(this).constructor):e.apply(this,t))}return r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),e&&eM(r,e),n=[{key:"load",value:function(){var e;return(e=function(){var e,n;return function(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),l=Object.defineProperty;return l(a,"next",{value:c(0)}),l(a,"throw",{value:c(1)}),l(a,"return",{value:c(2)}),"function"==typeof Symbol&&l(a,Symbol.iterator,{value:function(){return this}}),a;function c(l){return function(c){var u=[l,c];if(n)throw TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=t.call(e,i)}catch(e){u=[6,e],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(r){return this.app.use(ei),e={title:"{{t('Import')}}",Component:"ImportActionInitializer",schema:{"x-align":"right","x-decorator":"ACLActionProvider","x-acl-action":"importXlsx","x-acl-action-props":{skipScopeCheck:!0}},useVisible:function(){return(0,t.useActionAvailable)("importXlsx")}},null==(n=this.app.schemaInitializerManager.get("table:configureActions"))||n.add("enableActions.import",e),this.app.schemaInitializerManager.addItem("gantt:configureActions","enableActions.import",e),this.app.schemaSettingsManager.add(eT),this.app.flowEngine.registerModels({ImportActionModel:eA}),[2]})},function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){ek(i,r,o,a,l,"next",e)}function l(e){ek(i,r,o,a,l,"throw",e)}a(void 0)})}).call(this)}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(r.prototype,n),r}(e_(t.Plugin)),eq=eR}(),O}()});
|
|
10
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react-i18next"),require("@emotion/css"),require("react-dom"),require("@formily/antd-v5"),require("@formily/reactive"),require("@formily/react"),require("@ant-design/icons"),require("@nocobase/flow-engine"),require("@nocobase/client-v2"),require("@formily/shared"),require("react"),require("antd"),require("@nocobase/client"),require("@nocobase/utils/client"),require("lodash")):"function"==typeof define&&define.amd?define("@nocobase/plugin-action-import",["react-i18next","@emotion/css","react-dom","@formily/antd-v5","@formily/reactive","@formily/react","@ant-design/icons","@nocobase/flow-engine","@nocobase/client-v2","@formily/shared","react","antd","@nocobase/client","@nocobase/utils/client","lodash"],t):"object"==typeof exports?exports["@nocobase/plugin-action-import"]=t(require("react-i18next"),require("@emotion/css"),require("react-dom"),require("@formily/antd-v5"),require("@formily/reactive"),require("@formily/react"),require("@ant-design/icons"),require("@nocobase/flow-engine"),require("@nocobase/client-v2"),require("@formily/shared"),require("react"),require("antd"),require("@nocobase/client"),require("@nocobase/utils/client"),require("lodash")):e["@nocobase/plugin-action-import"]=t(e["react-i18next"],e["@emotion/css"],e["react-dom"],e["@formily/antd-v5"],e["@formily/reactive"],e["@formily/react"],e["@ant-design/icons"],e["@nocobase/flow-engine"],e["@nocobase/client-v2"],e["@formily/shared"],e.react,e.antd,e["@nocobase/client"],e["@nocobase/utils/client"],e.lodash)}(self,function(e,t,n,r,o,i,a,l,c,u,s,p,m,f,d){return function(){var y={574:function(e,t,n){var r,o;void 0===(o="function"==typeof(r=function(){"use strict";function t(e,t,n){var r=new XMLHttpRequest;r.open("GET",e),r.responseType="blob",r.onload=function(){l(r.response,t,n)},r.onerror=function(){console.error("could not download file")},r.send()}function r(e){var t=new XMLHttpRequest;t.open("HEAD",e,!1);try{t.send()}catch(e){}return 200<=t.status&&299>=t.status}function o(e){try{e.dispatchEvent(new MouseEvent("click"))}catch(n){var t=document.createEvent("MouseEvents");t.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),e.dispatchEvent(t)}}var i="object"==typeof window&&window.window===window?window:"object"==typeof self&&self.self===self?self:"object"==typeof n.g&&n.g.global===n.g?n.g:void 0,a=i.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),l=i.saveAs||("object"!=typeof window||window!==i?function(){}:"download"in HTMLAnchorElement.prototype&&!a?function(e,n,a){var l=i.URL||i.webkitURL,c=document.createElement("a");c.download=n=n||e.name||"download",c.rel="noopener","string"==typeof e?(c.href=e,c.origin===location.origin?o(c):r(c.href)?t(e,n,a):o(c,c.target="_blank")):(c.href=l.createObjectURL(e),setTimeout(function(){l.revokeObjectURL(c.href)},4e4),setTimeout(function(){o(c)},0))}:"msSaveOrOpenBlob"in navigator?function(e,n,i){if(n=n||e.name||"download","string"!=typeof e){var a;navigator.msSaveOrOpenBlob((void 0===(a=i)?a={autoBom:!1}:"object"!=typeof a&&(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(e.type)?new Blob(["\uFEFF",e],{type:e.type}):e),n)}else if(r(e))t(e,n,i);else{var l=document.createElement("a");l.href=e,l.target="_blank",setTimeout(function(){o(l)})}}:function(e,n,r,o){if((o=o||open("","_blank"))&&(o.document.title=o.document.body.innerText="downloading..."),"string"==typeof e)return t(e,n,r);var l="application/octet-stream"===e.type,c=/constructor/i.test(i.HTMLElement)||i.safari,u=/CriOS\/[\d]+/.test(navigator.userAgent);if((u||l&&c||a)&&"u">typeof FileReader){var s=new FileReader;s.onloadend=function(){var e=s.result;e=u?e:e.replace(/^data:[^;]*;/,"data:attachment/file;"),o?o.location.href=e:location=e,o=null},s.readAsDataURL(e)}else{var p=i.URL||i.webkitURL,m=p.createObjectURL(e);o?o.location=m:location.href=m,o=null,setTimeout(function(){p.revokeObjectURL(m)},4e4)}});i.saveAs=l.saveAs=l,e.exports=l})?r.apply(t,[]):r)||(e.exports=o)},375:function(e){"use strict";e.exports=a},477:function(e){"use strict";e.exports=t},418:function(e){"use strict";e.exports=r},230:function(e){"use strict";e.exports=i},992:function(e){"use strict";e.exports=o},166:function(e){"use strict";e.exports=u},342:function(e){"use strict";e.exports=m},485:function(e){"use strict";e.exports=c},694:function(e){"use strict";e.exports=l},768:function(e){"use strict";e.exports=f},59:function(e){"use strict";e.exports=p},773:function(e){"use strict";e.exports=d},155:function(e){"use strict";e.exports=s},514:function(e){"use strict";e.exports=n},953:function(t){"use strict";t.exports=e}},v={};function b(e){var t=v[e];if(void 0!==t)return t.exports;var n=v[e]={exports:{}};return y[e].call(n.exports,n,n.exports,b),n.exports}b.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return b.d(t,{a:t}),t},b.d=function(e,t){for(var n in t)b.o(t,n)&&!b.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},b.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),b.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},b.r=function(e){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},b.g.importScripts&&(g=b.g.location+"");var g,h=b.g.document;if(!g&&h&&(h.currentScript&&"SCRIPT"===h.currentScript.tagName.toUpperCase()&&(g=h.currentScript.src),!g)){var x=h.getElementsByTagName("script");if(x.length)for(var w=x.length-1;w>-1&&(!g||!/^http(s?):/.test(g));)g=x[w--].src}if(!g)throw Error("Automatic publicPath is not supported in this browser");b.p=g.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/");var S={};return!function(){"use strict";var e="",t="u">typeof document?document.currentScript:null;if(t&&t.src&&(e=t.src.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/")),!e){var n=window.__webpack_public_path__||"";n&&("/"!==n.charAt(n.length-1)&&(n+="/"),e=n+"static/plugins/@nocobase/plugin-action-import/dist/client/")}if(!e){var r=window.__nocobase_modern_client_prefix__||"v",o="/"+(r=String(r).replace(/^\/+|\/+$/g,"")||"v")+"/";if(!(e=window.__nocobase_public_path__||"")&&window.location&&window.location.pathname){var i=window.location.pathname||"/",a=i.indexOf(o);e=a>=0?i.slice(0,a+1):"/"}e&&(e=e.replace(RegExp("/"+r+"/?$"),"/")),e||(e="/"),"/"!==e.charAt(e.length-1)&&(e+="/"),e+="static/plugins/@nocobase/plugin-action-import/dist/client/"}b.p=e}(),!function(){"use strict";b.r(S),b.d(S,{useImportStartAction:function(){return Q},default:function(){return eV},ImportActionInitializer:function(){return x},ImportContextProvider:function(){return em},DownloadTips:function(){return h},ImportPluginProvider:function(){return ep},ImportDesigner:function(){return F},ImportWarning:function(){return g},ImportActionModel:function(){return eD},PluginActionImportClient:function(){return e$},buildImportFieldOptions:function(){return s},initImportSettings:function(){return v},useDownloadXlsxTemplateAction:function(){return J}});var e=b(166),t=b(342),n=b(155),r=b.n(n),o=["createdAt","createdBy","updatedAt","updatedBy"],i=["hasOne","belongsTo","hasMany","belongsToMany","belongsToArray"],a=function(e){return!!((null==e?void 0:e.target)&&i.includes(e.type||""))},l=function(e){return!(null==e?void 0:e.interface)||o.includes(e.interface)},c=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return{name:e.name,title:t(e),schema:e.uiSchema,disabled:n}},u=function(e,t,n){var r,o,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;if(l(e))return null;if(!a(e))return c(e,t);var s=(n(e)||[]).map(function(e){return l(e)?null:a(e)?i>=1?c(e,t,!0):u(e,t,n,i+1):u(e,t,n)}).filter(function(e){return!!e});return s.length?(r=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({},c(e,t)),o=o={children:s},Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(o)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(o)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(o,e))}),r):c(e,t,!0)},s=function(e,t,n){return(e||[]).map(function(e){return u(e,t,n,+!!a(e))}).filter(function(e){return!!e})},p=function(e){var n=(0,t.useCollectionManager_deprecated)().getCollectionFields,r=n(e),o=(0,t.useCompile)();return s(r,function(e){var t;return o(null==e||null==(t=e.uiSchema)?void 0:t.title)||e.name},function(e){return n(e.target)})},m=b(768),f=b(59),d=b(953),y="action-import",v=function(e){return{importColumns:null==e?void 0:e.filter(function(e){return!e.children&&!e.disabled}).map(function(e){return{dataIndex:[e.name]}}),explain:""}},g=function(){var e=(0,d.useTranslation)([y,"client"],{nsMode:"fallback"}).t;return r().createElement(f.Alert,{type:"warning",style:{marginBottom:"10px"},message:e("Import warnings",{limit:2e3})})},h=function(){var e=(0,d.useTranslation)([y,"client"],{nsMode:"fallback"}).t;return r().createElement(f.Alert,{type:"info",style:{marginBottom:"10px",whiteSpace:"pre-line"},message:e("Download tips")})},x=function(){var n=(0,t.useSchemaInitializerItem)(),o=(0,t.useSchemaInitializer)().insert,i=p((0,t.useCollection_deprecated)().name),a={type:"void",title:'{{ t("Import") }}',"x-component":"ImportAction","x-action":"importXlsx","x-settings":"actionSettings:import","x-toolbar":"ActionSchemaToolbar"};return r().createElement(t.SchemaInitializerItem,{title:n.title,onClick:function(){m.lodash.set(a,"x-action-settings.importSettings",v(i));var t,r=(0,e.merge)(a||{},n.schema||{});null==n||null==(t=n.schemaInitialize)||t.call(n,r),o(r)}})},w=b(418),O=b(230);function I(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function j(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function A(){var e=j(["\n width: 100%;\n & .ant-space-item:nth-child(2) {\n flex: 1;\n }\n "]);return A=function(){return e},e}function E(){var e=j(["\n border-color: var(--colorSettings);\n color: var(--colorSettings);\n &.ant-btn-dashed:hover {\n border-color: var(--colorSettings);\n color: var(--colorSettings);\n }\n "]);return E=function(){return e},e}var P=["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.ms-excel","application/wps-office.xlsx"],C=function(){var e=(0,d.useTranslation)(y).t,n=p((0,t.useCollection_deprecated)().name),r=(0,t.useCompile)();return{importSettingsSchema:{type:"void","x-component":"Grid",properties:{explain:{type:"string",title:'{{ t("Import explain", {ns: "'.concat(y,'"}) }}'),"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:(0,t.css)(A())},properties:{sort:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.SortHandle"},dataIndex:{type:"array","x-decorator":"FormItem","x-component":t.Cascader,required:!0,"x-use-component-props":function(){return{options:r(n)}},"x-component-props":{fieldNames:{label:"title",value:"name",children:"children"},changeOnSelect:!1}},title:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:'{{ t("Custom column title") }}'}},description:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:'{{ t("Field description placeholder", {ns: "'.concat(y,'"}) }}')}},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:'{{ t("Add importable field", {ns: "'.concat(y,'"}) }}'),"x-component":"ArrayItems.Addition","x-component-props":{className:(0,t.css)(E())}}}}}},beforeUploadHandler:function(){return!1},uploadValidator:function(t,n){if(t.length>1)return{type:"error",message:e("Only one file is allowed to be uploaded")};var r,o=null!=(r=t[0])?r:{};return P.includes(o.type)?"":{type:"error",message:e("Please upload the file of Excel")}},validateUpload:function(e,t,n){var r,o,i,a=(function(e){if(Array.isArray(e))return e}(n)||function(e){var t,n,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],i=!0,a=!1;try{for(r=r.call(e);!(i=(t=r.next()).done)&&(o.push(t.value),1!==o.length);i=!0);}catch(e){a=!0,n=e}finally{try{i||null==r.return||r.return()}finally{if(a)throw n}}return o}}(n)||function(e){if(e){if("string"==typeof e)return I(e,1);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return I(e,1)}}(n)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())[0];t.disabled=(null==a?void 0:a.length)===0,r=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({},t.componentProps),o=o={disabled:(null==a?void 0:a.length)===0||(null==(i=e.errors)?void 0:i.length)>0},Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(o)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(o)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(o,e))}),t.componentProps=r}}};function k(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function T(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function M(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){T(e,t,n[t])})}return e}var F=function(){var e,o,i,a,l,c,u,s=(0,O.useField)(),p=(0,O.useFieldSchema)(),m=(0,d.useTranslation)().t,f=(0,t.useDesignable)().dn,y=function(e){if(Array.isArray(e))return e}(e=(0,n.useState)())||function(e){var t,n,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],i=!0,a=!1;try{for(r=r.call(e);!(i=(t=r.next()).done)&&(o.push(t.value),2!==o.length);i=!0);}catch(e){a=!0,n=e}finally{try{i||null==r.return||r.return()}finally{if(a)throw n}}return o}}(e)||function(e){if(e){if("string"==typeof e)return k(e,2);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return k(e,2)}}(e)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),v=y[0],b=y[1],g=C().importSettingsSchema;return(0,n.useEffect)(function(){b(g)},[s.address,null==p||null==(i=p["x-action-settings"])?void 0:i.importSettings]),r().createElement(t.GeneralSchemaDesigner,{disableInitializer:!0},r().createElement(t.SchemaSettingsModalItem,{title:m("Edit button"),schema:{type:"object",title:m("Edit button"),properties:{title:{"x-decorator":"FormItem","x-component":"Input",title:m("Button title"),default:p.title,"x-component-props":{}},icon:{"x-decorator":"FormItem","x-component":"IconPicker",title:m("Button icon"),default:null==p||null==(a=p["x-component-props"])?void 0:a.icon,"x-component-props":{}},type:{"x-decorator":"FormItem","x-component":"Radio.Group",title:m("Button background color"),default:(null==p||null==(l=p["x-component-props"])?void 0:l.danger)?"danger":(null==p||null==(c=p["x-component-props"])?void 0:c.type)==="primary"?"primary":"default",enum:[{value:"default",label:'{{t("Default")}}'},{value:"primary",label:'{{t("Highlight")}}'},{value:"danger",label:'{{t("Danger red")}}'}]}}},onSubmit:function(e){var t,n=e.title,r=e.icon,o=e.type;p.title=n,s.title=n,s.componentProps.icon=r,s.componentProps.danger="danger"===o,s.componentProps.type=o,p["x-component-props"]=p["x-component-props"]||{},p["x-component-props"].icon=r,p["x-component-props"].danger="danger"===o,p["x-component-props"].type=o,f.emit("patch",{schema:(T(t={},"x-uid",p["x-uid"]),T(t,"title",n),T(t,"x-component-props",M({},p["x-component-props"])),t)}),f.refresh()}}),r().createElement(t.SchemaSettingsActionModalItem,{title:m("Importable fields"),schema:v,initialValues:M({},null!=(o=null==p||null==(u=p["x-action-settings"])?void 0:u.importSettings)?o:{}),components:{ArrayItems:w.ArrayItems},onSubmit:function(e){var t,n=e.importColumns,r=e.explain,o=null==n?void 0:n.filter(function(e){var t;return null==e||null==(t=e.dataIndex)?void 0:t.length}).map(function(e){return{dataIndex:e.dataIndex.map(function(e){var t;return null!=(t=e.name)?t:e}),title:e.title}});p["x-action-settings"].importSettings={importColumns:o,explain:r},f.emit("patch",{schema:(T(t={},"x-uid",p["x-uid"]),T(t,"x-action-settings",p["x-action-settings"]),t)}),f.refresh()}}),r().createElement(t.SchemaSettingsDivider,null),r().createElement(t.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:function(e){return"Space"===e["x-component"]||e["x-component"].endsWith("ActionBar")},confirm:{title:m("Delete action")}}))},D=b(514),_=(0,n.createContext)(null);_.displayName="ImportContext";var B=function(){return(0,n.useContext)(_)},R=b(375),N=b(574);function q(){var e,t,n=(e=["\n display: flex;\n justify-content: center;\n align-items: center;\n height: 100%;\n "],t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}})));return q=function(){return n},n}var U=function(e){var n=(0,d.useTranslation)(y).t,o=B(),i=o.importModalVisible,a=o.importStatus,l=o.importResult,c=o.setImportModalVisible,u=null!=l?l:{},s=u.data,p=u.meta,m=function(){c(!1)};return r().createElement(f.Modal,{title:n("Import Data"),width:"50%",styles:{body:{height:"calc(80vh - 200px)"}},open:i,footer:null,closable:2===a,onCancel:m},r().createElement("div",{className:(0,t.css)(q())},1===a&&r().createElement(f.Spin,{indicator:r().createElement(R.LoadingOutlined,{style:{fontSize:24},spin:!0}),tip:n("Excel data importing")}),2===a&&r().createElement(f.Space,{direction:"vertical",align:"center"},r().createElement(R.ExclamationCircleFilled,{style:{fontSize:72,color:"#1890ff"}}),r().createElement("p",null,function(e){if(!e)return null;var t=e.data,r=e.meta;if(r)return n("{{successCount}} records have been successfully imported",function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({},null!=r?r:{}));var o=["".concat(n("Total records"),": ").concat(t.total||0),"".concat(n("Successfully imported"),": ").concat(t.success||0)];return t.skipped>0&&o.push("".concat(n("Skipped"),": ").concat(t.skipped)),t.updated>0&&o.push("".concat(n("Updated"),": ").concat(t.updated)),o.join(", ")}(l)),r().createElement(f.Space,null,(null==p?void 0:p.failureCount)>0&&r().createElement(f.Button,{onClick:function(){var e=new Blob([new Int8Array(null==s?void 0:s.data)],{type:"application/x-xls"});(0,N.saveAs)(e,"fail.xlsx")}},n("To download the failure data")),r().createElement(f.Button,{type:"primary",onClick:m},n("Done"))))))},L=b(773),z=b.n(L);function X(e,t,n,r,o,i,a){try{var l=e[i](a),c=l.value}catch(e){n(e);return}l.done?t(c):Promise.resolve(c).then(r,o)}function H(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){X(i,r,o,a,l,"next",e)}function l(e){X(i,r,o,a,l,"throw",e)}a(void 0)})}}function $(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),l=Object.defineProperty;return l(a,"next",{value:c(0)}),l(a,"throw",{value:c(1)}),l(a,"return",{value:c(2)}),"function"==typeof Symbol&&l(a,Symbol.iterator,{value:function(){return this}}),a;function c(l){return function(c){var u=[l,c];if(n)throw TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=t.call(e,i)}catch(e){u=[6,e],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}var V=function(){for(var e=(0,t.useActionContext)().fieldSchema,n=(0,O.useFieldSchema)(),r=e||n;r&&"importXlsx"!==r["x-action"];)console.log("schema",r=r.parent);return{schema:r}},G=function(e){return e&&Array.isArray(e)?e:[]},W=function(e){if(!e)return"";if("string"==typeof e){var t=document.createElement("div");return t.innerHTML=e,t.textContent||t.innerText||e}if("string"==typeof e.message)return e.message;if(e.error)return W(e.error);var n=e.errors||e.messages;return Array.isArray(n)?n.map(W).filter(Boolean).join("\n"):""},K=function(e){var t;return W(null==e||null==(t=e.response)?void 0:t.data)||W(null==e?void 0:e.data)||(null==e?void 0:e.message)||"Import failed"},J=function(){var e=(0,t.useBlockRequestContext)().resource,n=(0,t.useCompile)(),r=(0,t.useCollectionManager_deprecated)(),o=r.getCollectionJoinField,i=r.getCollectionField,a=(0,t.useCollection_deprecated)(),l=a.name,c=a.title,u=V().schema;return{run:function(){return H(function(){var t,r,a,s,p,m,f;return $(this,function(d){switch(d.label){case 0:return s=(a=z().cloneDeep(null!=(t=null==u||null==(r=u["x-action-settings"])?void 0:r.importSettings)?t:{})).importColumns,p=a.explain,m=G(s).map(function(e){var t=i("".concat(l,".").concat(e.dataIndex[0]));if(t){if(e.defaultTitle=n(null==t||null==(r=t.uiSchema)?void 0:r.title)||t.name,e.dataIndex.length>1){var r,a,c=o("".concat(l,".").concat(e.dataIndex.join(".")));if(!c)return;e.defaultTitle=e.defaultTitle+"/"+n(null==c||null==(a=c.uiSchema)?void 0:a.title)||c.name}return"chinaRegion"===t.interface&&e.dataIndex.push("name"),e}}).filter(Boolean),[4,e.downloadXlsxTemplate({values:{title:n(c),explain:p,columns:n(m)}},{method:"post",responseType:"blob"})];case 1:return f=new Blob([d.sent().data],{type:"application/x-xls"}),(0,N.saveAs)(f,"".concat(n(c),".xlsx")),[2]}})})()}}},Q=function(){var e,r=(0,t.useBlockRequestContext)().service,o=(0,t.useCompile)(),i=(0,t.useCollectionManager_deprecated)(),a=i.getCollectionJoinField,l=i.getCollectionField,c=(0,t.useCollection_deprecated)().name,u=V().schema,s=(0,O.useForm)(),p=(0,t.useActionContext)(),m=p.setVisible,f=p.setErrorMessage,d=B(),y=d.setImportModalVisible,v=d.setImportStatus,b=d.setImportResult,g=s.values.upload,h=(0,t.useDataBlockResource)();return(0,n.useEffect)(function(){s.reset()},[s]),{run:function(){return H(function(){var e,t,n,i,p,d,g,x,w,S,O,I,j,A,E;return $(this,function(P){switch(P.label){case 0:d=(p=z().cloneDeep(null!=(e=null==u||null==(t=u["x-action-settings"])?void 0:t.importSettings)?e:{})).importColumns,g=p.explain,x=G(d).map(function(e){var t=l("".concat(c,".").concat(e.dataIndex[0]));if(t){if(e.defaultTitle=o(null==t||null==(n=t.uiSchema)?void 0:n.title)||t.name,e.dataIndex.length>1){var n,r,i=a("".concat(c,".").concat(e.dataIndex.join(".")));if(!i)return;e.defaultTitle=e.defaultTitle+"/"+o(null==i||null==(r=i.uiSchema)?void 0:r.title)||i.name}return"chinaRegion"===t.interface&&e.dataIndex.push("name"),e}}).filter(Boolean),w=new FormData,S=s.values.upload.map(function(e){return e.originFileObj}),w.append("file",S[0]),w.append("columns",JSON.stringify(x)),w.append("explain",g),O=(null==u||null==(n=u["x-action-settings"])?void 0:n.importMode)||"auto",I=(null==u||null==(i=u["x-action-settings"])?void 0:i.timeout)||6e5,null==f||f(""),m(!1),y(!0),v(1),P.label=1;case 1:return P.trys.push([1,6,,7]),[4,h.importXlsx({values:w,mode:O,timeout:I},{skipNotify:!0})];case 2:if(j=P.sent().data,null==f||f(""),s.reset(),j.data.taskId)return[3,4];return b(j),[4,null==r||null==(A=r.refresh)?void 0:A.call(r)];case 3:return P.sent(),v(2),[3,5];case 4:y(!1),m(!1),P.label=5;case 5:return[3,7];case 6:return E=P.sent(),null==f||f(K(E)),y(!1),m(!0),[3,7];case 7:return[2]}})})()},disabled:(null==g?void 0:g.length)===0||(null==(e=s.errors)?void 0:e.length)>0}},Y=b(477);function Z(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function ee(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,l=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(e){l=!0,r=e}finally{try{a||null==o.return||o.return()}finally{if(l)throw r}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return Z(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Z(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function et(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function en(){var e=et(["\n max-height: min(42vh, 420px);\n overflow: auto;\n white-space: pre-wrap;\n word-break: break-word;\n line-height: 1.6;\n padding-right: 8px;\n "]);return en=function(){return e},e}function er(){var e=et(["\n margin-bottom: 16px;\n "]);return er=function(){return e},e}function eo(){var e=et(["\n .ant-formily-item-label {\n height: var(--controlHeightLG);\n }\n "]);return eo=function(){return e},e}function ei(){var e=et(["\n margin-top: 5px;\n "]);return ei=function(){return e},e}var ea=function(e){var t=e.errorMessage,n=(0,d.useTranslation)(y).t;return t?r().createElement(f.Alert,{type:"error",showIcon:!0,message:n("Import failed"),description:r().createElement("div",{className:(0,Y.css)(en())},t),className:(0,Y.css)(er())}):null},el={type:"void",name:"import-modal",title:'{{ t("Import Data", {ns: "'.concat(y,'" }) }}'),"x-component":"Action.Modal","x-decorator":"Form","x-component-props":{width:"100%",style:{maxWidth:"750px"},className:(0,Y.css)(eo())},properties:{formLayout:{type:"void","x-component":"FormLayout",properties:{importError:{type:"void","x-component":"ImportErrorAlert","x-visible":"{{ !!importErrorMessage }}","x-component-props":{errorMessage:"{{ importErrorMessage }}"}},warning:{type:"void","x-component":"ImportWarning"},download:{type:"void",title:'{{ t("Step 1: Download template", {ns: "'.concat(y,'" }) }}'),"x-component":"FormItem","x-acl-ignore":!0,properties:{tip:{type:"void","x-component":"DownloadTips"},downloadAction:{type:"void",title:'{{ t("Download template", {ns: "'.concat(y,'" }) }}'),"x-component":"Action","x-component-props":{className:(0,Y.css)(ei()),useAction:"{{ useDownloadXlsxTemplateAction }}"}}}},upload:{type:"array",title:'{{ t("Step 2: Upload Excel", {ns: "'.concat(y,'" }) }}'),"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: "'.concat(y,'" }) }}'),beforeUpload:"{{ beforeUploadHandler }}"}}}},footer:{"x-component":"Action.Modal.Footer","x-component-props":{},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{},properties:{cancel:{type:"void",title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},startImport:{type:"void",title:'{{ t("Start import", {ns: "'.concat(y,'" }) }}'),"x-component":"Action","x-component-props":{type:"primary",htmlType:"submit",useAction:"{{ useImportStartAction }}"},"x-reactions":{dependencies:["upload"],fulfill:{run:"validateUpload($form, $self, $deps)"}}}}}}}}},ec=function(e){var o,i,a=ee((0,n.useState)(!1),2),l=a[0],c=a[1],u=ee((0,n.useState)(""),2),s=u[0],p=u[1],m=(0,t.useCompile)(),f=(0,O.useFieldSchema)();return r().createElement(t.ActionContextProvider,{value:{visible:l,setVisible:c,fieldSchema:f,errorMessage:s,setErrorMessage:p}},r().createElement(t.Action,(o=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({icon:e.icon||"uploadoutlined",title:m((null==f?void 0:f.title)||"t('Import')")},e),i=i={onClick:function(){p(""),c(!0)}},Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(i)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(i)).forEach(function(e){Object.defineProperty(o,e,Object.getOwnPropertyDescriptor(i,e))}),o)),r().createElement(t.SchemaComponent,{schema:el,components:{ImportErrorAlert:ea},scope:{importErrorMessage:s}}))};function eu(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function es(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,l=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(e){l=!0,r=e}finally{try{a||null==o.return||o.return()}finally{if(l)throw r}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return eu(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return eu(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var ep=function(e){var n=C(),o=n.uploadValidator,i=n.beforeUploadHandler,a=n.validateUpload;return r().createElement(t.SchemaComponentOptions,{components:{ImportActionInitializer:x,ImportDesigner:F,ImportWarning:g,DownloadTips:h,ImportAction:ec},scope:{uploadValidator:o,validateUpload:a,beforeUploadHandler:i,useDownloadXlsxTemplateAction:J,useImportStartAction:Q}},r().createElement(em,null,e.children))},em=function(e){var t=es((0,n.useState)(!1),2),o=t[0],i=t[1],a=es((0,n.useState)(1),2),l=a[0],c=a[1],u=es((0,n.useState)(null),2),s=u[0],p=u[1];return r().createElement(_.Provider,{value:{importModalVisible:o,setImportModalVisible:i,importStatus:l,setImportStatus:c,importResult:s,setImportResult:p}},(0,D.createPortal)(r().createElement(U,null),document.body),e.children)},ef=b(992),ed=b(485),ey=b(694);function ev(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function eb(e,t,n,r,o,i,a){try{var l=e[i](a),c=l.value}catch(e){n(e);return}l.done?t(c):Promise.resolve(c).then(r,o)}function eg(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){eb(i,r,o,a,l,"next",e)}function l(e){eb(i,r,o,a,l,"throw",e)}a(void 0)})}}function eh(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ex(e){return(ex=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function ew(e,t){return(ew=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function eS(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,l=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(e){l=!0,r=e}finally{try{a||null==o.return||o.return()}finally{if(l)throw r}}return i}}(e,t)||eI(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function eO(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function eI(e,t){if(e){if("string"==typeof e)return ev(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return ev(e,t)}}function ej(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(ej=function(){return!!e})()}function eA(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),l=Object.defineProperty;return l(a,"next",{value:c(0)}),l(a,"throw",{value:c(1)}),l(a,"return",{value:c(2)}),"function"==typeof Symbol&&l(a,Symbol.iterator,{value:function(){return this}}),a;function c(l){return function(c){var u=[l,c];if(n)throw TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=t.call(e,i)}catch(e){u=[6,e],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}function eE(){var e=eO(["\n max-height: min(42vh, 420px);\n overflow: auto;\n white-space: pre-wrap;\n word-break: break-word;\n line-height: 1.6;\n padding-right: 8px;\n "]);return eE=function(){return e},e}function eP(){var e=eO(["\n .import-warning {\n margin-bottom: ","px;\n }\n\n .import-step {\n margin-bottom: ","px;\n }\n\n .import-step-title {\n margin-bottom: ","px;\n color: ",";\n line-height: ",";\n }\n\n .import-download-action {\n margin-top: ","px;\n }\n\n .import-upload-wrapper {\n margin-bottom: ","px;\n }\n\n .import-upload-dragger-shell {\n height: 150px;\n border: 1px dashed ",";\n border-radius: ","px;\n background: ",";\n transition: border-color 0.2s;\n }\n\n .import-upload-dragger-shell:hover {\n border-color: ",";\n }\n\n .import-upload-dragger-shell .ant-upload-wrapper,\n .import-upload-dragger-shell .ant-upload,\n .import-upload-dragger-shell .ant-upload-drag {\n width: 100%;\n height: 100%;\n border: 0;\n background: transparent;\n }\n\n .import-upload-dragger-shell .ant-upload-drag-container {\n height: 100%;\n display: flex;\n align-items: center;\n justify-content: center;\n }\n\n .import-upload-dragger-shell .ant-upload-list {\n display: none;\n }\n\n .import-upload-file {\n display: flex;\n align-items: center;\n column-gap: ","px;\n min-height: ","px;\n margin-top: ","px;\n padding: 0 ","px;\n border-radius: ","px;\n color: ",";\n line-height: ",";\n transition: background-color 0.2s;\n }\n\n .import-upload-file:hover {\n background: ",";\n }\n\n .import-upload-file-icon {\n color: ",";\n font-size: ","px;\n }\n\n .import-upload-file-name {\n flex: 1;\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n .import-upload-file-remove {\n color: ",";\n }\n\n .import-upload-file-remove:hover {\n color: ",";\n background: transparent;\n }\n\n .import-upload-placeholder {\n padding: 0 ","px;\n color: ",";\n line-height: ",";\n text-align: center;\n }\n\n .import-upload-error {\n margin-top: ","px;\n margin-bottom: ","px;\n color: ",";\n line-height: ",";\n word-break: break-word;\n }\n\n .import-footer {\n display: flex;\n justify-content: flex-end;\n gap: ","px;\n margin-top: ","px;\n }\n "]);return eP=function(){return e},e}function eC(){var e=eO(["\n width: 100%;\n & .ant-space-item:nth-child(2) {\n flex: 1;\n }\n "]);return eC=function(){return e},e}function ek(){var e=eO(["\n border-color: var(--colorSettings);\n color: var(--colorSettings);\n &.ant-btn-dashed:hover {\n border-color: var(--colorSettings);\n color: var(--colorSettings);\n }\n "]);return ek=function(){return e},e}var eT=["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.ms-excel","application/wps-office.xlsx"],eM=function(e){if(!e)return"";if("string"==typeof e){var t=document.createElement("div");return t.innerHTML=e,t.textContent||t.innerText||e}if("string"==typeof e.message)return e.message;if(e.error)return eM(e.error);var n=e.errors||e.messages;return Array.isArray(n)?n.map(eM).filter(Boolean).join("\n"):""},eF=function(e){var t;return eM(null==e||null==(t=e.response)?void 0:t.data)||eM(null==e?void 0:e.data)||(null==e?void 0:e.message)||"Import failed"},eD=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function n(){var e,t,r;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return t=n,r=arguments,t=ex(t),eh(e=function(e,t){var n;if(t&&("object"==((n=t)&&"u">typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,ej()?Reflect.construct(t,r||[],ex(this).constructor):t.apply(this,r)),"defaultProps",{title:(0,ey.escapeT)("Import"),type:"default",icon:"uploadoutlined"}),e}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&ew(n,e),t=[{key:"getAclActionName",value:function(){return"importXlsx"}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(n.prototype,t),n}(ed.ActionModel);function e_(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function eB(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function eR(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){eB(e,t,n[t])})}return e}eh(eD,"scene",ed.ActionSceneEnum.collection),eD.define({label:(0,ey.escapeT)("Import")}),eD.registerFlow({key:"importSettings",title:(0,ey.escapeT)("Import settings"),on:"click",steps:{import:{handler:function(e){return eg(function(){var t,n,o,i,a,l,c,u,s,p,m,d;return eA(this,function(v){switch(v.label){case 0:var b;return t=(0,ef.observable)({status:"",result:null,errorMessage:""}),o=(n=e.model.context.blockModel).resource,a=(i=n.collection).title,l=i.name,u=(c=e.model.getProps().importSettings).explain,s=(!(b=c.importColumns)||!Array.isArray(b)?[]:b).map(function(t){var r=e.model.context.dataSourceManager.getCollectionField("".concat(n.collection.dataSourceKey,".").concat(l,".").concat(t.dataIndex[0]));if(r){if(t.defaultTitle=e.t(null==r||null==(o=r.uiSchema)?void 0:o.title)||r.name,t.dataIndex.length>1){var o,i,a=e.model.context.dataSourceManager.getCollectionField("".concat(e.model.context.collection.dataSourceKey,".").concat(l,".").concat(t.dataIndex.join(".")));if(!a)return;t.defaultTitle=t.defaultTitle+"/"+e.t(null==a||null==(i=a.uiSchema)?void 0:i.title)||a.name}return t}}).filter(Boolean),p=function(){return eg(function(){var t;return eA(this,function(n){switch(n.label){case 0:return[4,o.runAction("downloadXlsxTemplate",{data:{title:e.t(a),explain:u,columns:function(e){if(Array.isArray(e))return ev(e)}(s)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(s)||eI(s)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()},responseType:"blob",method:"post"})];case 1:return t=new Blob([n.sent()],{type:"application/x-xls"}),(0,N.saveAs)(t,"".concat(e.t(a),".xlsx")),[2]}})})()},m=function(t){if(0===t.length)return"";if(t.length>1)return e.t("Only one file is allowed to be uploaded",{ns:y});var n,r,o=null!=(n=t[0])?n:{},i=o.type||(null==(r=o.originFileObj)?void 0:r.type);return eT.includes(i)?"":e.t("Please upload the file of Excel",{ns:y})},d=(0,ey.observer)(function(i){var a=i.popover,c=e.t,d=f.theme.useToken().token,v=eS(r().useState([]),2),b=v[0],g=v[1],h=eS(r().useState(""),2),x=h[0],w=h[1],S=function(){a.close(),t.status="",t.result=null,t.errorMessage="",g([]),w("")};if("importing"===t.status)return r().createElement("div",{style:{display:"flex",justifyContent:"center",padding:40}},r().createElement(f.Spin,{tip:c("Excel data importing"),indicator:r().createElement(R.LoadingOutlined,{spin:!0,style:{fontSize:24}})}));if("imported"===t.status){var O,I=null==(O=t.result)?void 0:O.meta;return r().createElement(f.Space,{direction:"vertical",align:"center",style:{width:"100%",padding:24}},r().createElement(R.ExclamationCircleFilled,{style:{fontSize:72,color:"#1890ff"}}),r().createElement("p",null,function(e){if(!e)return null;var t=((null==e?void 0:e.data)||e).successCount;if(t)return c("{{successCount}} records have been successfully imported",{successCount:t,ns:y})}(t.result)),r().createElement(f.Space,null,(null==I?void 0:I.failureCount)>0&&r().createElement(f.Button,{onClick:function(){var e,n,r=new Blob([new Int8Array(null==(n=t.result)||null==(e=n.data)?void 0:e.data)],{type:"application/x-xls"});(0,N.saveAs)(r,"fail.xlsx")}},c("To download the failure data")),r().createElement(f.Button,{type:"primary",onClick:S},c("Done"))))}if("error"===t.status)return r().createElement(f.Space,{direction:"vertical",style:{width:"100%"},size:d.marginLG},r().createElement(f.Alert,{type:"error",showIcon:!0,message:c("Import failed",{ns:y}),description:r().createElement("div",{className:(0,Y.css)(eE())},t.errorMessage)}),r().createElement(f.Space,{style:{width:"100%",justifyContent:"flex-end"}},r().createElement(f.Button,{onClick:S},c("Close")),r().createElement(f.Button,{type:"primary",onClick:function(){t.status="",t.errorMessage=""}},c("Back"))));var j=!b.length||!!x;return r().createElement("div",{className:(0,Y.css)(eP(),d.marginLG,d.marginLG,d.marginXS,d.colorText,d.lineHeight,d.marginXS,x?d.marginMD:0,d.colorBorder,d.borderRadius,d.colorBgContainer,d.colorPrimary,d.marginXXS,d.controlHeight,d.marginSM,d.paddingXXS,d.borderRadiusSM,d.colorText,d.lineHeight,d.colorFillAlter,d.colorTextSecondary,d.fontSizeLG,d.colorTextTertiary,d.colorText,d.padding,d.colorTextDescription,d.lineHeight,b.length?d.marginXXS:d.marginSM,d.marginMD,d.colorError,d.lineHeight,d.marginXS,d.marginLG)},r().createElement(f.Alert,{className:"import-warning",type:"warning",message:c("Import warnings",{ns:y,limit:2e3})}),r().createElement("div",{className:"import-step"},r().createElement("div",{className:"import-step-title"},c("Step 1: Download template",{ns:y})),r().createElement(f.Alert,{type:"info",style:{whiteSpace:"pre-line"},message:c("Download tips",{ns:y})}),r().createElement(f.Button,{className:"import-download-action",onClick:p},c("Download template",{ns:y}))),r().createElement("div",{className:"import-step"},r().createElement("div",{className:"import-step-title"},c("Step 2: Upload Excel",{ns:y})),r().createElement("div",{className:"import-upload-wrapper"},r().createElement("div",{className:"import-upload-dragger-shell"},r().createElement(f.Upload.Dragger,{action:"",maxCount:1,fileList:b,beforeUpload:function(){return!1},showUploadList:!1,onChange:function(e){var t=e.fileList.slice(-1);g(t),w(m(t))}},r().createElement("div",{className:"import-upload-placeholder"},c("Upload placeholder",{ns:y})))),b[0]&&r().createElement("div",{className:"import-upload-file"},r().createElement(R.PaperClipOutlined,{className:"import-upload-file-icon"}),r().createElement("span",{className:"import-upload-file-name",title:b[0].name},b[0].name),r().createElement(f.Button,{type:"text",size:"small",className:"import-upload-file-remove",icon:r().createElement(R.DeleteOutlined,null),onClick:function(){g([]),w("")}})),x&&r().createElement("div",{className:"import-upload-error"},x))),r().createElement("div",{className:"import-footer"},r().createElement(f.Button,{onClick:function(){return a.close()}},c("Cancel")),r().createElement(f.Button,{type:"primary",onClick:function(){return eg(function(){var r,i,c,p,f,d,y,v,h,x,S,O,I,j;return eA(this,function(A){switch(A.label){case 0:if(w(r=m(b)),r||!b.length)return[2];i=new FormData,c=b.map(function(e){return e.originFileObj}),i.append("file",c[0]),i.append("columns",JSON.stringify(s)),i.append("explain",u),p=e.model.getProps().importMode,t.status="importing",t.errorMessage="",A.label=1;case 1:return A.trys.push([1,6,,7]),h=(null==(f=o.getResourceName)?void 0:f.call(o))||l,x=null==(d=o.getSourceId)?void 0:d.call(o),O=(S=(null==(y=o.getDataSourceKey)?void 0:y.call(o))||n.collection.dataSourceKey)?{"X-Data-Source":S}:void 0,[4,e.api.resource(h,x,O).importXlsx({values:i,mode:p,timeout:6e5},{skipNotify:!0})];case 2:if(null==(I=A.sent().data)||null==(v=I.data)?void 0:v.taskId)return[3,4];return t.result=I,t.status="imported",[4,null==o||null==(j=o.refresh)?void 0:j.call(o)];case 3:return A.sent(),g([]),w(""),[3,5];case 4:a.close(),g([]),w(""),A.label=5;case 5:return[3,7];case 6:return t.errorMessage=eF(A.sent()),t.status="error",[3,7];case 7:return[2]}})})()},disabled:j},c("Start import",{ns:"".concat(y)}))))}),[4,e.viewer.open({type:"dialog",placement:"center",width:800,title:e.t("Import Data",{ns:"".concat(y)}),content:function(e){return r().createElement(d,{popover:e})}})];case 1:return v.sent(),[2]}})})()}}}}),eD.registerFlow({key:"importActionSetting",title:(0,ey.escapeT)("Import action settings",{ns:y}),steps:{importSetting:{title:(0,ey.escapeT)("Importable fields"),uiSchema:function(e){var t,n,r=(t=e.model.context.blockModel.collection.getFields(),n=e.t,s(t,function(e){var t;return n(null==e||null==(t=e.uiSchema)?void 0:t.title)||e.name},function(e){return e.targetCollection&&e.targetCollection.getFields()||[]}));return{explain:{type:"string",title:'{{ t("Import explain", {ns: "'.concat(y,'"}) }}'),"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:(0,Y.css)(eC())},properties:{sort:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.SortHandle"},dataIndex:{type:"array","x-decorator":"FormItem","x-component":f.Cascader,required:!0,"x-component-props":{fieldNames:{label:"title",value:"name",children:"children"},changeOnSelect:!1,options:r}},title:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:'{{ t("Custom column title") }}'}},description:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:'{{ t("Field description placeholder", {ns: "'.concat(y,'"}) }}')}},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:'{{ t("Add importable field", {ns: "'.concat(y,'"}) }}'),"x-component":"ArrayItems.Addition","x-component-props":{className:(0,Y.css)(ek())}}}}}},defaultParams:function(e){return function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){eh(e,t,n[t])})}return e}({},v(e.model.context.blockModel.collection.getFields()))},handler:function(e,t){var n=t.importColumns,r=t.explain,o=null==n?void 0:n.filter(function(e){var t;return null==e||null==(t=e.dataIndex)?void 0:t.length}).map(function(e){return{dataIndex:e.dataIndex.map(function(e){var t;return null!=(t=e.name)?t:e}),title:e.title,description:e.description}});e.model.setProps("importSettings",{importColumns:o,explain:r})}}}});var eN=new t.SchemaSettings({name:"actionSettings:import",items:[{name:"editButton",Component:t.ButtonEditor,useComponentProps:function(){return(0,t.useSchemaToolbar)().buttonEditorProps}},{name:"linkageRules",Component:t.SchemaSettingsLinkageRules,useComponentProps:function(){return eR({},(0,t.useSchemaToolbar)().linkageRulesProps)}},{name:"importableFields",type:"actionModal",useComponentProps:function(){var e,r,o,i,a=(0,O.useField)(),l=(0,O.useFieldSchema)(),c=(0,d.useTranslation)().t,u=(0,t.useDesignable)().dn,s=function(e){if(Array.isArray(e))return e}(e=(0,n.useState)())||function(e){var t,n,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],i=!0,a=!1;try{for(r=r.call(e);!(i=(t=r.next()).done)&&(o.push(t.value),2!==o.length);i=!0);}catch(e){a=!0,n=e}finally{try{i||null==r.return||r.return()}finally{if(a)throw n}}return o}}(e)||function(e){if(e){if("string"==typeof e)return e_(e,2);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return e_(e,2)}}(e)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),p=s[0],m=s[1],f=C().importSettingsSchema;return(0,n.useEffect)(function(){m(f)},[a.address,null==l||null==(o=l["x-action-settings"])?void 0:o.importSettings]),{title:c("Importable fields"),schema:eR({},p),initialValues:eR({},null!=(r=null==l||null==(i=l["x-action-settings"])?void 0:i.importSettings)?r:{}),components:{ArrayItems:w.ArrayItems},onSubmit:function(e){var t,n=e.importColumns,r=e.explain,o=null==n?void 0:n.filter(function(e){var t;return null==e||null==(t=e.dataIndex)?void 0:t.length}).map(function(e){return{dataIndex:e.dataIndex.map(function(e){var t;return null!=(t=e.name)?t:e}),title:e.title,description:e.description}});l["x-action-settings"].importSettings={importColumns:o,explain:r},u.emit("patch",{schema:(eB(t={},"x-uid",l["x-uid"]),eB(t,"x-action-settings",l["x-action-settings"]),t)}),u.refresh()}}}},{name:"divider",type:"divider"},{name:"delete",type:"remove",useComponentProps:function(){return{removeParentsIfNoChildren:!0,breakRemoveOn:function(e){return"Space"===e["x-component"]||e["x-component"].endsWith("ActionBar")},confirm:{title:(0,(0,d.useTranslation)().t)("Delete action")}}}}]});function eq(e,t,n,r,o,i,a){try{var l=e[i](a),c=l.value}catch(e){n(e);return}l.done?t(c):Promise.resolve(c).then(r,o)}function eU(e,t,n){return(eU=eH()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&ez(o,n.prototype),o}).apply(null,arguments)}function eL(e){return(eL=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function ez(e,t){return(ez=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function eX(e){var t="function"==typeof Map?new Map:void 0;return(eX=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return eU(e,arguments,eL(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),ez(n,e)})(e)}function eH(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(eH=function(){return!!e})()}var e$=function(e){var n;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function r(){var e,t;if(!(this instanceof r))throw TypeError("Cannot call a class as a function");return e=r,t=arguments,e=eL(e),function(e,t){var n;if(t&&("object"==((n=t)&&"u">typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,eH()?Reflect.construct(e,t||[],eL(this).constructor):e.apply(this,t))}return r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),e&&ez(r,e),n=[{key:"load",value:function(){var e;return(e=function(){var e,n;return function(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),l=Object.defineProperty;return l(a,"next",{value:c(0)}),l(a,"throw",{value:c(1)}),l(a,"return",{value:c(2)}),"function"==typeof Symbol&&l(a,Symbol.iterator,{value:function(){return this}}),a;function c(l){return function(c){var u=[l,c];if(n)throw TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=t.call(e,i)}catch(e){u=[6,e],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(r){return this.app.use(ep),e={title:"{{t('Import')}}",Component:"ImportActionInitializer",schema:{"x-align":"right","x-decorator":"ACLActionProvider","x-acl-action":"importXlsx","x-acl-action-props":{skipScopeCheck:!0}},useVisible:function(){return(0,t.useActionAvailable)("importXlsx")}},null==(n=this.app.schemaInitializerManager.get("table:configureActions"))||n.add("enableActions.import",e),this.app.schemaInitializerManager.addItem("gantt:configureActions","enableActions.import",e),this.app.schemaSettingsManager.add(eN),this.app.flowEngine.registerModels({ImportActionModel:eD}),[2]})},function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){eq(i,r,o,a,l,"next",e)}function l(e){eq(i,r,o,a,l,"throw",e)}a(void 0)})}).call(this)}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(r.prototype,n),r}(eX(t.Plugin)),eV=e$}(),S}()});
|
|
@@ -6,4 +6,4 @@
|
|
|
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
|
-
export declare const useFields: (collectionName: string) =>
|
|
9
|
+
export declare const useFields: (collectionName: string) => import("../client-v2/buildImportFieldOptions").ImportFieldOption[];
|
|
@@ -6,4 +6,25 @@
|
|
|
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
|
-
export
|
|
9
|
+
export type ImportFieldOptionSource = {
|
|
10
|
+
name?: string;
|
|
11
|
+
type?: string;
|
|
12
|
+
target?: string;
|
|
13
|
+
interface?: string;
|
|
14
|
+
uiSchema?: {
|
|
15
|
+
title?: unknown;
|
|
16
|
+
[key: string]: unknown;
|
|
17
|
+
};
|
|
18
|
+
targetCollection?: {
|
|
19
|
+
getFields: () => ImportFieldOptionSource[];
|
|
20
|
+
};
|
|
21
|
+
[key: string]: unknown;
|
|
22
|
+
};
|
|
23
|
+
export type ImportFieldOption = {
|
|
24
|
+
name?: string;
|
|
25
|
+
title: unknown;
|
|
26
|
+
schema: unknown;
|
|
27
|
+
disabled?: boolean;
|
|
28
|
+
children?: ImportFieldOption[];
|
|
29
|
+
};
|
|
30
|
+
export declare const buildImportFieldOptions: <T extends ImportFieldOptionSource>(fields: T[], getTitle: (field: T) => unknown, getTargetFields: (field: T) => ImportFieldOptionSource[] | null | undefined) => ImportFieldOption[];
|
|
@@ -6,4 +6,4 @@
|
|
|
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
|
-
export declare const getOptionFields: (fields: any, t: any) =>
|
|
9
|
+
export declare const getOptionFields: (fields: any, t: any) => import("./buildImportFieldOptions").ImportFieldOption[];
|
package/dist/client-v2/index.js
CHANGED
|
@@ -7,4 +7,4 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react-i18next"),require("@emotion/css"),require("@nocobase/client-v2"),require("@formily/antd-v5"),require("@formily/core"),require("@formily/reactive"),require("react"),require("antd"),require("@formily/react"),require("@ant-design/icons"),require("@nocobase/flow-engine")):"function"==typeof define&&define.amd?define("@nocobase/plugin-action-import/client-v2",["react-i18next","@emotion/css","@nocobase/client-v2","@formily/antd-v5","@formily/core","@formily/reactive","react","antd","@formily/react","@ant-design/icons","@nocobase/flow-engine"],t):"object"==typeof exports?exports["@nocobase/plugin-action-import/client-v2"]=t(require("react-i18next"),require("@emotion/css"),require("@nocobase/client-v2"),require("@formily/antd-v5"),require("@formily/core"),require("@formily/reactive"),require("react"),require("antd"),require("@formily/react"),require("@ant-design/icons"),require("@nocobase/flow-engine")):e["@nocobase/plugin-action-import/client-v2"]=t(e["react-i18next"],e["@emotion/css"],e["@nocobase/client-v2"],e["@formily/antd-v5"],e["@formily/core"],e["@formily/reactive"],e.react,e.antd,e["@formily/react"],e["@ant-design/icons"],e["@nocobase/flow-engine"])}(self,function(e,t,n,r,o,i,a,c,l,u,s){return function(){var p={574:function(e,t,n){var r,o;void 0===(o="function"==typeof(r=function(){"use strict";function t(e,t,n){var r=new XMLHttpRequest;r.open("GET",e),r.responseType="blob",r.onload=function(){c(r.response,t,n)},r.onerror=function(){console.error("could not download file")},r.send()}function r(e){var t=new XMLHttpRequest;t.open("HEAD",e,!1);try{t.send()}catch(e){}return 200<=t.status&&299>=t.status}function o(e){try{e.dispatchEvent(new MouseEvent("click"))}catch(n){var t=document.createEvent("MouseEvents");t.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),e.dispatchEvent(t)}}var i="object"==typeof window&&window.window===window?window:"object"==typeof self&&self.self===self?self:"object"==typeof n.g&&n.g.global===n.g?n.g:void 0,a=i.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),c=i.saveAs||("object"!=typeof window||window!==i?function(){}:"download"in HTMLAnchorElement.prototype&&!a?function(e,n,a){var c=i.URL||i.webkitURL,l=document.createElement("a");l.download=n=n||e.name||"download",l.rel="noopener","string"==typeof e?(l.href=e,l.origin===location.origin?o(l):r(l.href)?t(e,n,a):o(l,l.target="_blank")):(l.href=c.createObjectURL(e),setTimeout(function(){c.revokeObjectURL(l.href)},4e4),setTimeout(function(){o(l)},0))}:"msSaveOrOpenBlob"in navigator?function(e,n,i){if(n=n||e.name||"download","string"!=typeof e){var a;navigator.msSaveOrOpenBlob((void 0===(a=i)?a={autoBom:!1}:"object"!=typeof a&&(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(e.type)?new Blob(["\uFEFF",e],{type:e.type}):e),n)}else if(r(e))t(e,n,i);else{var c=document.createElement("a");c.href=e,c.target="_blank",setTimeout(function(){o(c)})}}:function(e,n,r,o){if((o=o||open("","_blank"))&&(o.document.title=o.document.body.innerText="downloading..."),"string"==typeof e)return t(e,n,r);var c="application/octet-stream"===e.type,l=/constructor/i.test(i.HTMLElement)||i.safari,u=/CriOS\/[\d]+/.test(navigator.userAgent);if((u||c&&l||a)&&"u">typeof FileReader){var s=new FileReader;s.onloadend=function(){var e=s.result;e=u?e:e.replace(/^data:[^;]*;/,"data:attachment/file;"),o?o.location.href=e:location=e,o=null},s.readAsDataURL(e)}else{var p=i.URL||i.webkitURL,f=p.createObjectURL(e);o?o.location=f:location.href=f,o=null,setTimeout(function(){p.revokeObjectURL(f)},4e4)}});i.saveAs=c.saveAs=c,e.exports=c})?r.apply(t,[]):r)||(e.exports=o)},375:function(e){"use strict";e.exports=u},477:function(e){"use strict";e.exports=t},418:function(e){"use strict";e.exports=r},452:function(e){"use strict";e.exports=o},230:function(e){"use strict";e.exports=l},992:function(e){"use strict";e.exports=i},485:function(e){"use strict";e.exports=n},694:function(e){"use strict";e.exports=s},59:function(e){"use strict";e.exports=c},155:function(e){"use strict";e.exports=a},953:function(t){"use strict";t.exports=e}},f={};function d(e){var t=f[e];if(void 0!==t)return t.exports;var n=f[e]={exports:{}};return p[e].call(n.exports,n,n.exports,d),n.exports}d.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return d.d(t,{a:t}),t},d.d=function(e,t){for(var n in t)d.o(t,n)&&!d.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},d.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),d.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},d.r=function(e){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},d.g.importScripts&&(m=d.g.location+"");var m,y=d.g.document;if(!m&&y&&(y.currentScript&&"SCRIPT"===y.currentScript.tagName.toUpperCase()&&(m=y.currentScript.src),!m)){var v=y.getElementsByTagName("script");if(v.length)for(var b=v.length-1;b>-1&&(!m||!/^http(s?):/.test(m));)m=v[b--].src}if(!m)throw Error("Automatic publicPath is not supported in this browser");d.p=m.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/");var g={};return!function(){"use strict";var e="",t="u">typeof document?document.currentScript:null;if(t&&t.src&&(e=t.src.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/")),!e){var n=window.__webpack_public_path__||"";n&&("/"!==n.charAt(n.length-1)&&(n+="/"),e=n+"static/plugins/@nocobase/plugin-action-import/dist/client-v2/")}if(!e){var r=window.__nocobase_modern_client_prefix__||"v",o="/"+(r=String(r).replace(/^\/+|\/+$/g,"")||"v")+"/";if(!(e=window.__nocobase_public_path__||"")&&window.location&&window.location.pathname){var i=window.location.pathname||"/",a=i.indexOf(o);e=a>=0?i.slice(0,a+1):"/"}e&&(e=e.replace(RegExp("/"+r+"/?$"),"/")),e||(e="/"),"/"!==e.charAt(e.length-1)&&(e+="/"),e+="static/plugins/@nocobase/plugin-action-import/dist/client-v2/"}d.p=e}(),!function(){"use strict";d.r(g),d.d(g,{PluginActionImportClient:function(){return z},default:function(){return G},buildImportFieldOptions:function(){return O},ImportActionModel:function(){return D}});var e=d(485),t=d(375),n=d(477),r=d(418),o=d(452),i=d(230),a=d(992),c=d(694),l=d(59),u=d(574),s=d(155),p=d.n(s),f=d(953),m="action-import",y=["createdAt","createdBy","updatedAt","updatedBy"],v=["hasOne","belongsTo","hasMany","belongsToMany","belongsToArray"],b=function(e){return(null==e?void 0:e.target)&&v.includes(e.type)},h=function(e){return!(null==e?void 0:e.interface)||y.includes(e.interface)},w=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return{name:e.name,title:t(e),schema:null==e?void 0:e.uiSchema,disabled:n}},x=function(e,t,n){var r,o,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;if(h(e))return null;if(!b(e))return w(e,t);var a=(n(e)||[]).map(function(e){return h(e)?null:b(e)?i>=1?w(e,t,!0):x(e,t,n,i+1):x(e,t,n)}).filter(Boolean);return a.length?(r=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({},w(e,t)),o=o={children:a},Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(o)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(o)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(o,e))}),r):w(e,t,!0)},O=function(e,t,n){return(e||[]).map(function(e){return x(e,t,n,+!!b(e))}).filter(Boolean)};function S(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function j(e,t,n,r,o,i,a){try{var c=e[i](a),l=c.value}catch(e){n(e);return}c.done?t(l):Promise.resolve(l).then(r,o)}function E(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){j(i,r,o,a,c,"next",e)}function c(e){j(i,r,o,a,c,"throw",e)}a(void 0)})}}function A(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function T(e){return(T=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function I(e,t){return(I=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function P(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function _(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(_=function(){return!!e})()}function k(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),c=Object.defineProperty;return c(a,"next",{value:l(0)}),c(a,"throw",{value:l(1)}),c(a,"return",{value:l(2)}),"function"==typeof Symbol&&c(a,Symbol.iterator,{value:function(){return this}}),a;function l(c){return function(l){var u=[c,l];if(n)throw TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=t.call(e,i)}catch(e){u=[6,e],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}function F(){var e=P(["\n margin-top: 5px;\n "]);return F=function(){return e},e}function C(){var e=P(["\n width: 100%;\n & .ant-space-item:nth-child(2) {\n flex: 1;\n }\n "]);return C=function(){return e},e}function B(){var e=P(["\n border-color: var(--colorSettings);\n color: var(--colorSettings);\n &.ant-btn-dashed:hover {\n border-color: var(--colorSettings);\n color: var(--colorSettings);\n }\n "]);return B=function(){return e},e}var M=["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.ms-excel","application/wps-office.xlsx"],q={type:"object",properties:{warning:{type:"void","x-component":"ImportWarning"},download:{type:"void",title:(0,c.escapeT)("Step 1: Download template",{ns:"".concat(m)}),"x-component":"FormItem",properties:{tip:{type:"void","x-component":"DownloadTips"},downloadAction:{type:"void",title:(0,c.escapeT)("Download template",{ns:"".concat(m)}),"x-component":"Button","x-component-props":{className:(0,n.css)(F()),children:(0,c.escapeT)("Download template",{ns:"".concat(m)}),onClick:"{{ handelDownloadXlsxTemplateAction }}"}}}},upload:{type:"array",title:(0,c.escapeT)("Step 2: Upload Excel",{ns:"".concat(m)}),"x-decorator":"FormItem","x-acl-ignore":!0,"x-component":"Upload.Dragger","x-validator":function(e){var t,n=e.fileList;if(n.length>1)return{type:"error",message:(0,c.escapeT)("Only one file is allowed to be uploaded")};var r=null!=(t=n[0])?t:{};return M.includes(r.type)?"":{type:"error",message:(0,c.escapeT)("Please upload the file of Excel")}},"x-component-props":{action:"",height:"150px",maxCount:1,children:(0,c.escapeT)("Upload placeholder",{ns:"".concat(m)}),beforeUpload:function(){return!1}}}}},R=(0,i.createSchemaField)({components:{ImportWarning:function(){var e=(0,f.useTranslation)([m,"client"],{nsMode:"fallback"}).t;return p().createElement(l.Alert,{type:"warning",style:{marginBottom:"10px"},message:e("Import warnings",{limit:2e3})})},DownloadTips:function(){var e=(0,f.useTranslation)([m,"client"],{nsMode:"fallback"}).t;return p().createElement(l.Alert,{type:"info",style:{marginBottom:"10px",whiteSpace:"pre-line"},message:e("Download tips")})},Upload:l.Upload,FormItem:r.FormItem,Button:l.Button}}),D=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function n(){var e,t,r;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return t=n,r=arguments,t=T(t),A(e=function(e,t){var n;if(t&&("object"==((n=t)&&"u">typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,_()?Reflect.construct(t,r||[],T(this).constructor):t.apply(this,r)),"defaultProps",{title:(0,c.escapeT)("Import"),type:"default",icon:"uploadoutlined"}),e}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&I(n,e),t=[{key:"getAclActionName",value:function(){return"importXlsx"}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(n.prototype,t),n}(e.ActionModel);function L(e,t,n,r,o,i,a){try{var c=e[i](a),l=c.value}catch(e){n(e);return}c.done?t(l):Promise.resolve(l).then(r,o)}function U(e,t,n){return(U=H()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&N(o,n.prototype),o}).apply(null,arguments)}A(D,"scene",e.ActionSceneEnum.collection),D.define({label:(0,c.escapeT)("Import")}),D.registerFlow({key:"importSettings",title:(0,c.escapeT)("Import settings"),on:"click",steps:{import:{handler:function(e){return E(function(){var n,s,f,d,y,v,b,g,h,w,x,O;return k(this,function(j){switch(j.label){case 0:var A;return n=(0,a.observable)({status:"",result:null}),s=(0,o.createForm)(),d=(f=e.model.context.blockModel).resource,v=(y=f.collection).title,b=y.name,h=(g=e.model.getProps().importSettings).explain,w=(!(A=g.importColumns)||!Array.isArray(A)?[]:A).map(function(t){var n=e.model.context.dataSourceManager.getCollectionField("".concat(f.collection.dataSourceKey,".").concat(b,".").concat(t.dataIndex[0]));if(n){if(t.defaultTitle=e.t(null==n||null==(r=n.uiSchema)?void 0:r.title)||n.name,t.dataIndex.length>1){var r,o,i=e.model.context.dataSourceManager.getCollectionField("".concat(e.model.context.collection.dataSourceKey,".").concat(b,".").concat(t.dataIndex.join(".")));if(!i)return;t.defaultTitle=t.defaultTitle+"/"+e.t(null==i||null==(o=i.uiSchema)?void 0:o.title)||i.name}return t}}).filter(Boolean),x=function(){return E(function(){var t;return k(this,function(n){switch(n.label){case 0:return[4,d.runAction("downloadXlsxTemplate",{data:{title:e.t(v),explain:h,columns:function(e){if(Array.isArray(e))return S(e)}(w)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(w)||function(e){if(e){if("string"==typeof e)return S(e,void 0);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return S(e,void 0)}}(w)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()},responseType:"blob",method:"post"})];case 1:return t=new Blob([n.sent()],{type:"application/x-xls"}),(0,u.saveAs)(t,"".concat(e.t(v),".xlsx")),[2]}})})()},O=(0,c.observer)(function(o){var a=o.popover,c=e.t;if("importing"===n.status)return p().createElement("div",{style:{display:"flex",justifyContent:"center",padding:40}},p().createElement(l.Spin,{tip:c("Excel data importing"),indicator:p().createElement(t.LoadingOutlined,{spin:!0,style:{fontSize:24}})}));if("imported"===n.status){var f,y,v,b=null==(v=n.result)?void 0:v.meta;return p().createElement(l.Space,{direction:"vertical",align:"center",style:{width:"100%",padding:24}},p().createElement(t.ExclamationCircleFilled,{style:{fontSize:72,color:"#1890ff"}}),p().createElement("p",null,function(e){if(!e)return null;var t=e.successCount;if(t)return c("{{successCount}} records have been successfully imported",{successCount:t,ns:m})}(n.result)),p().createElement(l.Space,null,(null==b?void 0:b.failureCount)>0&&p().createElement(l.Button,{onClick:function(){var e,t,r=new Blob([new Int8Array(null==(t=n.result)||null==(e=t.data)?void 0:e.data)],{type:"application/x-xls"});(0,u.saveAs)(r,"fail.xlsx")}},c("To download the failure data")),p().createElement(l.Button,{type:"primary",onClick:function(){a.close(),n.status="",n.result=null}},c("Done"))))}return p().createElement(i.FormProvider,{form:s},p().createElement(r.FormLayout,{layout:"vertical"},p().createElement(R,{schema:q,scope:{t:e.t,handelDownloadXlsxTemplateAction:x}})),p().createElement(r.FormButtonGroup,{align:"right"},p().createElement(l.Button,{onClick:function(){return a.close()}},c("Cancel")),p().createElement(l.Button,{type:"primary",onClick:function(){return E(function(){var t,r,o,i,c,l,u,p;return k(this,function(f){switch(f.label){case 0:t=s.values.upload.fileList,r=new FormData,o=t.map(function(e){return e.originFileObj}),r.append("file",o[0]),r.append("columns",JSON.stringify(w)),r.append("explain",h),i=e.model.getProps().importMode,n.status="importing",f.label=1;case 1:return f.trys.push([1,6,,7]),[4,d.runAction("importXlsx",{data:r,mode:i,timeout:6e5})];case 2:if(null==(l=f.sent().data)||null==(c=l.data)?void 0:c.taskId)return[3,4];return n.result=l,n.status="imported",[4,null==d||null==(u=d.refresh)?void 0:u.call(d)];case 3:return f.sent(),s.reset(),[3,5];case 4:a.close(),s.reset(),f.label=5;case 5:return[3,7];case 6:return p=f.sent(),n.status="",console.error(p),[3,7];case 7:return[2]}})})()},disabled:!(null==(y=s.values.upload)||null==(f=y.fileList)?void 0:f.length)},c("Start import",{ns:"".concat(m)}))))}),[4,e.viewer.open({type:"dialog",placement:"center",width:800,title:e.t("Import Data",{ns:"".concat(m)}),content:function(e){return p().createElement(O,{popover:e})}})];case 1:return j.sent(),[2]}})})()}}}}),D.registerFlow({key:"importActionSetting",title:(0,c.escapeT)("Import action settings",{ns:m}),steps:{importSetting:{title:(0,c.escapeT)("Importable fields"),uiSchema:function(e){var t,r,o=(t=e.model.context.blockModel.collection.getFields(),r=e.t,O(t,function(e){var t;return r(null==e||null==(t=e.uiSchema)?void 0:t.title)||e.name},function(e){return e.targetCollection&&e.targetCollection.getFields()||[]}));return{explain:{type:"string",title:'{{ t("Import explain", {ns: "'.concat(m,'"}) }}'),"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:(0,n.css)(C())},properties:{sort:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.SortHandle"},dataIndex:{type:"array","x-decorator":"FormItem","x-component":l.Cascader,required:!0,"x-component-props":{fieldNames:{label:"title",value:"name",children:"children"},changeOnSelect:!1,options:o}},title:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:'{{ t("Custom column title") }}'}},description:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:'{{ t("Field description placeholder", {ns: "'.concat(m,'"}) }}')}},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:'{{ t("Add importable field", {ns: "'.concat(m,'"}) }}'),"x-component":"ArrayItems.Addition","x-component-props":{className:(0,n.css)(B())}}}}}},defaultParams:function(e){var t;return function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){A(e,t,n[t])})}return e}({},{importColumns:null==(t=e.model.context.blockModel.collection.getFields())?void 0:t.filter(function(e){return!e.children&&!e.disabled}).map(function(e){return{dataIndex:[e.name]}}),explain:""})},handler:function(e,t){var n=t.importColumns,r=t.explain,o=null==n?void 0:n.filter(function(e){var t;return null==e||null==(t=e.dataIndex)?void 0:t.length}).map(function(e){return{dataIndex:e.dataIndex.map(function(e){var t;return null!=(t=e.name)?t:e}),title:e.title,description:e.description}});e.model.setProps("importSettings",{importColumns:o,explain:r})}}}});function $(e){return($=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function N(e,t){return(N=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function X(e){var t="function"==typeof Map?new Map:void 0;return(X=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return U(e,arguments,$(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),N(n,e)})(e)}function H(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(H=function(){return!!e})()}var z=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function n(){var e,t;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return e=n,t=arguments,e=$(e),function(e,t){var n;if(t&&("object"==((n=t)&&"u">typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,H()?Reflect.construct(e,t||[],$(this).constructor):e.apply(this,t))}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&N(n,e),t=[{key:"load",value:function(){var e;return(e=function(){return function(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),c=Object.defineProperty;return c(a,"next",{value:l(0)}),c(a,"throw",{value:l(1)}),c(a,"return",{value:l(2)}),"function"==typeof Symbol&&c(a,Symbol.iterator,{value:function(){return this}}),a;function l(c){return function(l){var u=[c,l];if(n)throw TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=t.call(e,i)}catch(e){u=[6,e],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(e){return this.app.flowEngine.registerModels({ImportActionModel:D}),[2]})},function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){L(i,r,o,a,c,"next",e)}function c(e){L(i,r,o,a,c,"throw",e)}a(void 0)})}).call(this)}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(n.prototype,t),n}(X(e.Plugin)),G=z}(),g}()});
|
|
10
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react-i18next"),require("@emotion/css"),require("@nocobase/client-v2"),require("@formily/reactive"),require("react"),require("antd"),require("@ant-design/icons"),require("@nocobase/flow-engine")):"function"==typeof define&&define.amd?define("@nocobase/plugin-action-import/client-v2",["react-i18next","@emotion/css","@nocobase/client-v2","@formily/reactive","react","antd","@ant-design/icons","@nocobase/flow-engine"],t):"object"==typeof exports?exports["@nocobase/plugin-action-import/client-v2"]=t(require("react-i18next"),require("@emotion/css"),require("@nocobase/client-v2"),require("@formily/reactive"),require("react"),require("antd"),require("@ant-design/icons"),require("@nocobase/flow-engine")):e["@nocobase/plugin-action-import/client-v2"]=t(e["react-i18next"],e["@emotion/css"],e["@nocobase/client-v2"],e["@formily/reactive"],e.react,e.antd,e["@ant-design/icons"],e["@nocobase/flow-engine"])}(self,function(e,t,n,r,o,i,a,l){return function(){var c={574:function(e,t,n){var r,o;void 0===(o="function"==typeof(r=function(){"use strict";function t(e,t,n){var r=new XMLHttpRequest;r.open("GET",e),r.responseType="blob",r.onload=function(){l(r.response,t,n)},r.onerror=function(){console.error("could not download file")},r.send()}function r(e){var t=new XMLHttpRequest;t.open("HEAD",e,!1);try{t.send()}catch(e){}return 200<=t.status&&299>=t.status}function o(e){try{e.dispatchEvent(new MouseEvent("click"))}catch(n){var t=document.createEvent("MouseEvents");t.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),e.dispatchEvent(t)}}var i="object"==typeof window&&window.window===window?window:"object"==typeof self&&self.self===self?self:"object"==typeof n.g&&n.g.global===n.g?n.g:void 0,a=i.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),l=i.saveAs||("object"!=typeof window||window!==i?function(){}:"download"in HTMLAnchorElement.prototype&&!a?function(e,n,a){var l=i.URL||i.webkitURL,c=document.createElement("a");c.download=n=n||e.name||"download",c.rel="noopener","string"==typeof e?(c.href=e,c.origin===location.origin?o(c):r(c.href)?t(e,n,a):o(c,c.target="_blank")):(c.href=l.createObjectURL(e),setTimeout(function(){l.revokeObjectURL(c.href)},4e4),setTimeout(function(){o(c)},0))}:"msSaveOrOpenBlob"in navigator?function(e,n,i){if(n=n||e.name||"download","string"!=typeof e){var a;navigator.msSaveOrOpenBlob((void 0===(a=i)?a={autoBom:!1}:"object"!=typeof a&&(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(e.type)?new Blob(["\uFEFF",e],{type:e.type}):e),n)}else if(r(e))t(e,n,i);else{var l=document.createElement("a");l.href=e,l.target="_blank",setTimeout(function(){o(l)})}}:function(e,n,r,o){if((o=o||open("","_blank"))&&(o.document.title=o.document.body.innerText="downloading..."),"string"==typeof e)return t(e,n,r);var l="application/octet-stream"===e.type,c=/constructor/i.test(i.HTMLElement)||i.safari,u=/CriOS\/[\d]+/.test(navigator.userAgent);if((u||l&&c||a)&&"u">typeof FileReader){var s=new FileReader;s.onloadend=function(){var e=s.result;e=u?e:e.replace(/^data:[^;]*;/,"data:attachment/file;"),o?o.location.href=e:location=e,o=null},s.readAsDataURL(e)}else{var p=i.URL||i.webkitURL,f=p.createObjectURL(e);o?o.location=f:location.href=f,o=null,setTimeout(function(){p.revokeObjectURL(f)},4e4)}});i.saveAs=l.saveAs=l,e.exports=l})?r.apply(t,[]):r)||(e.exports=o)},375:function(e){"use strict";e.exports=a},477:function(e){"use strict";e.exports=t},992:function(e){"use strict";e.exports=r},485:function(e){"use strict";e.exports=n},694:function(e){"use strict";e.exports=l},59:function(e){"use strict";e.exports=i},155:function(e){"use strict";e.exports=o},953:function(t){"use strict";t.exports=e}},u={};function s(e){var t=u[e];if(void 0!==t)return t.exports;var n=u[e]={exports:{}};return c[e].call(n.exports,n,n.exports,s),n.exports}s.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return s.d(t,{a:t}),t},s.d=function(e,t){for(var n in t)s.o(t,n)&&!s.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},s.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),s.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},s.r=function(e){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},s.g.importScripts&&(p=s.g.location+"");var p,f=s.g.document;if(!p&&f&&(f.currentScript&&"SCRIPT"===f.currentScript.tagName.toUpperCase()&&(p=f.currentScript.src),!p)){var d=f.getElementsByTagName("script");if(d.length)for(var m=d.length-1;m>-1&&(!p||!/^http(s?):/.test(p));)p=d[m--].src}if(!p)throw Error("Automatic publicPath is not supported in this browser");s.p=p.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/");var g={};return!function(){"use strict";var e="",t="u">typeof document?document.currentScript:null;if(t&&t.src&&(e=t.src.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/")),!e){var n=window.__webpack_public_path__||"";n&&("/"!==n.charAt(n.length-1)&&(n+="/"),e=n+"static/plugins/@nocobase/plugin-action-import/dist/client-v2/")}if(!e){var r=window.__nocobase_modern_client_prefix__||"v",o="/"+(r=String(r).replace(/^\/+|\/+$/g,"")||"v")+"/";if(!(e=window.__nocobase_public_path__||"")&&window.location&&window.location.pathname){var i=window.location.pathname||"/",a=i.indexOf(o);e=a>=0?i.slice(0,a+1):"/"}e&&(e=e.replace(RegExp("/"+r+"/?$"),"/")),e||(e="/"),"/"!==e.charAt(e.length-1)&&(e+="/"),e+="static/plugins/@nocobase/plugin-action-import/dist/client-v2/"}s.p=e}(),!function(){"use strict";s.r(g),s.d(g,{PluginActionImportClient:function(){return $},default:function(){return z},buildImportFieldOptions:function(){return b},ImportActionModel:function(){return R}});var e=s(485),t=s(375),n=s(477),r=s(992),o=s(694),i=s(59),a=s(574),l=s(155),c=s.n(l);s(953);var u="action-import",p=["createdAt","createdBy","updatedAt","updatedBy"],f=["hasOne","belongsTo","hasMany","belongsToMany","belongsToArray"],d=function(e){return!!((null==e?void 0:e.target)&&f.includes(e.type||""))},m=function(e){return!(null==e?void 0:e.interface)||p.includes(e.interface)},y=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return{name:e.name,title:t(e),schema:e.uiSchema,disabled:n}},v=function(e,t,n){var r,o,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;if(m(e))return null;if(!d(e))return y(e,t);var a=(n(e)||[]).map(function(e){return m(e)?null:d(e)?i>=1?y(e,t,!0):v(e,t,n,i+1):v(e,t,n)}).filter(function(e){return!!e});return a.length?(r=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({},y(e,t)),o=o={children:a},Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(o)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(o)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(o,e))}),r):y(e,t,!0)},b=function(e,t,n){return(e||[]).map(function(e){return v(e,t,n,+!!d(e))}).filter(function(e){return!!e})};function h(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function w(e,t,n,r,o,i,a){try{var l=e[i](a),c=l.value}catch(e){n(e);return}l.done?t(c):Promise.resolve(c).then(r,o)}function x(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){w(i,r,o,a,l,"next",e)}function l(e){w(i,r,o,a,l,"throw",e)}a(void 0)})}}function S(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function O(e){return(O=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function E(e,t){return(E=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function j(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,l=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(e){l=!0,r=e}finally{try{a||null==o.return||o.return()}finally{if(l)throw r}}return i}}(e,t)||A(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function k(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function A(e,t){if(e){if("string"==typeof e)return h(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return h(e,t)}}function I(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(I=function(){return!!e})()}function T(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),l=Object.defineProperty;return l(a,"next",{value:c(0)}),l(a,"throw",{value:c(1)}),l(a,"return",{value:c(2)}),"function"==typeof Symbol&&l(a,Symbol.iterator,{value:function(){return this}}),a;function c(l){return function(c){var u=[l,c];if(n)throw TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=t.call(e,i)}catch(e){u=[6,e],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}function P(){var e=k(["\n max-height: min(42vh, 420px);\n overflow: auto;\n white-space: pre-wrap;\n word-break: break-word;\n line-height: 1.6;\n padding-right: 8px;\n "]);return P=function(){return e},e}function _(){var e=k(["\n .import-warning {\n margin-bottom: ","px;\n }\n\n .import-step {\n margin-bottom: ","px;\n }\n\n .import-step-title {\n margin-bottom: ","px;\n color: ",";\n line-height: ",";\n }\n\n .import-download-action {\n margin-top: ","px;\n }\n\n .import-upload-wrapper {\n margin-bottom: ","px;\n }\n\n .import-upload-dragger-shell {\n height: 150px;\n border: 1px dashed ",";\n border-radius: ","px;\n background: ",";\n transition: border-color 0.2s;\n }\n\n .import-upload-dragger-shell:hover {\n border-color: ",";\n }\n\n .import-upload-dragger-shell .ant-upload-wrapper,\n .import-upload-dragger-shell .ant-upload,\n .import-upload-dragger-shell .ant-upload-drag {\n width: 100%;\n height: 100%;\n border: 0;\n background: transparent;\n }\n\n .import-upload-dragger-shell .ant-upload-drag-container {\n height: 100%;\n display: flex;\n align-items: center;\n justify-content: center;\n }\n\n .import-upload-dragger-shell .ant-upload-list {\n display: none;\n }\n\n .import-upload-file {\n display: flex;\n align-items: center;\n column-gap: ","px;\n min-height: ","px;\n margin-top: ","px;\n padding: 0 ","px;\n border-radius: ","px;\n color: ",";\n line-height: ",";\n transition: background-color 0.2s;\n }\n\n .import-upload-file:hover {\n background: ",";\n }\n\n .import-upload-file-icon {\n color: ",";\n font-size: ","px;\n }\n\n .import-upload-file-name {\n flex: 1;\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n .import-upload-file-remove {\n color: ",";\n }\n\n .import-upload-file-remove:hover {\n color: ",";\n background: transparent;\n }\n\n .import-upload-placeholder {\n padding: 0 ","px;\n color: ",";\n line-height: ",";\n text-align: center;\n }\n\n .import-upload-error {\n margin-top: ","px;\n margin-bottom: ","px;\n color: ",";\n line-height: ",";\n word-break: break-word;\n }\n\n .import-footer {\n display: flex;\n justify-content: flex-end;\n gap: ","px;\n margin-top: ","px;\n }\n "]);return _=function(){return e},e}function C(){var e=k(["\n width: 100%;\n & .ant-space-item:nth-child(2) {\n flex: 1;\n }\n "]);return C=function(){return e},e}function M(){var e=k(["\n border-color: var(--colorSettings);\n color: var(--colorSettings);\n &.ant-btn-dashed:hover {\n border-color: var(--colorSettings);\n color: var(--colorSettings);\n }\n "]);return M=function(){return e},e}var F=["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.ms-excel","application/wps-office.xlsx"],B=function(e){if(!e)return"";if("string"==typeof e){var t=document.createElement("div");return t.innerHTML=e,t.textContent||t.innerText||e}if("string"==typeof e.message)return e.message;if(e.error)return B(e.error);var n=e.errors||e.messages;return Array.isArray(n)?n.map(B).filter(Boolean).join("\n"):""},N=function(e){var t;return B(null==e||null==(t=e.response)?void 0:t.data)||B(null==e?void 0:e.data)||(null==e?void 0:e.message)||"Import failed"},R=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function n(){var e,t,r;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return t=n,r=arguments,t=O(t),S(e=function(e,t){var n;if(t&&("object"==((n=t)&&"u">typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,I()?Reflect.construct(t,r||[],O(this).constructor):t.apply(this,r)),"defaultProps",{title:(0,o.escapeT)("Import"),type:"default",icon:"uploadoutlined"}),e}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&E(n,e),t=[{key:"getAclActionName",value:function(){return"importXlsx"}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(n.prototype,t),n}(e.ActionModel);function L(e,t,n,r,o,i,a){try{var l=e[i](a),c=l.value}catch(e){n(e);return}l.done?t(c):Promise.resolve(c).then(r,o)}function D(e,t,n){return(D=H()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&U(o,n.prototype),o}).apply(null,arguments)}S(R,"scene",e.ActionSceneEnum.collection),R.define({label:(0,o.escapeT)("Import")}),R.registerFlow({key:"importSettings",title:(0,o.escapeT)("Import settings"),on:"click",steps:{import:{handler:function(e){return x(function(){var l,s,p,f,d,m,g,y,v,b,w,S;return T(this,function(O){switch(O.label){case 0:var E;return l=(0,r.observable)({status:"",result:null,errorMessage:""}),p=(s=e.model.context.blockModel).resource,d=(f=s.collection).title,m=f.name,y=(g=e.model.getProps().importSettings).explain,v=(!(E=g.importColumns)||!Array.isArray(E)?[]:E).map(function(t){var n=e.model.context.dataSourceManager.getCollectionField("".concat(s.collection.dataSourceKey,".").concat(m,".").concat(t.dataIndex[0]));if(n){if(t.defaultTitle=e.t(null==n||null==(r=n.uiSchema)?void 0:r.title)||n.name,t.dataIndex.length>1){var r,o,i=e.model.context.dataSourceManager.getCollectionField("".concat(e.model.context.collection.dataSourceKey,".").concat(m,".").concat(t.dataIndex.join(".")));if(!i)return;t.defaultTitle=t.defaultTitle+"/"+e.t(null==i||null==(o=i.uiSchema)?void 0:o.title)||i.name}return t}}).filter(Boolean),b=function(){return x(function(){var t;return T(this,function(n){switch(n.label){case 0:return[4,p.runAction("downloadXlsxTemplate",{data:{title:e.t(d),explain:y,columns:function(e){if(Array.isArray(e))return h(e)}(v)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(v)||A(v)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()},responseType:"blob",method:"post"})];case 1:return t=new Blob([n.sent()],{type:"application/x-xls"}),(0,a.saveAs)(t,"".concat(e.t(d),".xlsx")),[2]}})})()},w=function(t){if(0===t.length)return"";if(t.length>1)return e.t("Only one file is allowed to be uploaded",{ns:u});var n,r,o=null!=(n=t[0])?n:{},i=o.type||(null==(r=o.originFileObj)?void 0:r.type);return F.includes(i)?"":e.t("Please upload the file of Excel",{ns:u})},S=(0,o.observer)(function(r){var o=r.popover,f=e.t,d=i.theme.useToken().token,g=j(c().useState([]),2),h=g[0],S=g[1],O=j(c().useState(""),2),E=O[0],k=O[1],A=function(){o.close(),l.status="",l.result=null,l.errorMessage="",S([]),k("")};if("importing"===l.status)return c().createElement("div",{style:{display:"flex",justifyContent:"center",padding:40}},c().createElement(i.Spin,{tip:f("Excel data importing"),indicator:c().createElement(t.LoadingOutlined,{spin:!0,style:{fontSize:24}})}));if("imported"===l.status){var I,C=null==(I=l.result)?void 0:I.meta;return c().createElement(i.Space,{direction:"vertical",align:"center",style:{width:"100%",padding:24}},c().createElement(t.ExclamationCircleFilled,{style:{fontSize:72,color:"#1890ff"}}),c().createElement("p",null,function(e){if(!e)return null;var t=((null==e?void 0:e.data)||e).successCount;if(t)return f("{{successCount}} records have been successfully imported",{successCount:t,ns:u})}(l.result)),c().createElement(i.Space,null,(null==C?void 0:C.failureCount)>0&&c().createElement(i.Button,{onClick:function(){var e,t,n=new Blob([new Int8Array(null==(t=l.result)||null==(e=t.data)?void 0:e.data)],{type:"application/x-xls"});(0,a.saveAs)(n,"fail.xlsx")}},f("To download the failure data")),c().createElement(i.Button,{type:"primary",onClick:A},f("Done"))))}if("error"===l.status)return c().createElement(i.Space,{direction:"vertical",style:{width:"100%"},size:d.marginLG},c().createElement(i.Alert,{type:"error",showIcon:!0,message:f("Import failed",{ns:u}),description:c().createElement("div",{className:(0,n.css)(P())},l.errorMessage)}),c().createElement(i.Space,{style:{width:"100%",justifyContent:"flex-end"}},c().createElement(i.Button,{onClick:A},f("Close")),c().createElement(i.Button,{type:"primary",onClick:function(){l.status="",l.errorMessage=""}},f("Back"))));var M=!h.length||!!E;return c().createElement("div",{className:(0,n.css)(_(),d.marginLG,d.marginLG,d.marginXS,d.colorText,d.lineHeight,d.marginXS,E?d.marginMD:0,d.colorBorder,d.borderRadius,d.colorBgContainer,d.colorPrimary,d.marginXXS,d.controlHeight,d.marginSM,d.paddingXXS,d.borderRadiusSM,d.colorText,d.lineHeight,d.colorFillAlter,d.colorTextSecondary,d.fontSizeLG,d.colorTextTertiary,d.colorText,d.padding,d.colorTextDescription,d.lineHeight,h.length?d.marginXXS:d.marginSM,d.marginMD,d.colorError,d.lineHeight,d.marginXS,d.marginLG)},c().createElement(i.Alert,{className:"import-warning",type:"warning",message:f("Import warnings",{ns:u,limit:2e3})}),c().createElement("div",{className:"import-step"},c().createElement("div",{className:"import-step-title"},f("Step 1: Download template",{ns:u})),c().createElement(i.Alert,{type:"info",style:{whiteSpace:"pre-line"},message:f("Download tips",{ns:u})}),c().createElement(i.Button,{className:"import-download-action",onClick:b},f("Download template",{ns:u}))),c().createElement("div",{className:"import-step"},c().createElement("div",{className:"import-step-title"},f("Step 2: Upload Excel",{ns:u})),c().createElement("div",{className:"import-upload-wrapper"},c().createElement("div",{className:"import-upload-dragger-shell"},c().createElement(i.Upload.Dragger,{action:"",maxCount:1,fileList:h,beforeUpload:function(){return!1},showUploadList:!1,onChange:function(e){var t=e.fileList.slice(-1);S(t),k(w(t))}},c().createElement("div",{className:"import-upload-placeholder"},f("Upload placeholder",{ns:u})))),h[0]&&c().createElement("div",{className:"import-upload-file"},c().createElement(t.PaperClipOutlined,{className:"import-upload-file-icon"}),c().createElement("span",{className:"import-upload-file-name",title:h[0].name},h[0].name),c().createElement(i.Button,{type:"text",size:"small",className:"import-upload-file-remove",icon:c().createElement(t.DeleteOutlined,null),onClick:function(){S([]),k("")}})),E&&c().createElement("div",{className:"import-upload-error"},E))),c().createElement("div",{className:"import-footer"},c().createElement(i.Button,{onClick:function(){return o.close()}},f("Cancel")),c().createElement(i.Button,{type:"primary",onClick:function(){return x(function(){var t,n,r,i,a,c,u,f,d,g,b,x,O,E;return T(this,function(j){switch(j.label){case 0:if(k(t=w(h)),t||!h.length)return[2];n=new FormData,r=h.map(function(e){return e.originFileObj}),n.append("file",r[0]),n.append("columns",JSON.stringify(v)),n.append("explain",y),i=e.model.getProps().importMode,l.status="importing",l.errorMessage="",j.label=1;case 1:return j.trys.push([1,6,,7]),d=(null==(a=p.getResourceName)?void 0:a.call(p))||m,g=null==(c=p.getSourceId)?void 0:c.call(p),x=(b=(null==(u=p.getDataSourceKey)?void 0:u.call(p))||s.collection.dataSourceKey)?{"X-Data-Source":b}:void 0,[4,e.api.resource(d,g,x).importXlsx({values:n,mode:i,timeout:6e5},{skipNotify:!0})];case 2:if(null==(O=j.sent().data)||null==(f=O.data)?void 0:f.taskId)return[3,4];return l.result=O,l.status="imported",[4,null==p||null==(E=p.refresh)?void 0:E.call(p)];case 3:return j.sent(),S([]),k(""),[3,5];case 4:o.close(),S([]),k(""),j.label=5;case 5:return[3,7];case 6:return l.errorMessage=N(j.sent()),l.status="error",[3,7];case 7:return[2]}})})()},disabled:M},f("Start import",{ns:"".concat(u)}))))}),[4,e.viewer.open({type:"dialog",placement:"center",width:800,title:e.t("Import Data",{ns:"".concat(u)}),content:function(e){return c().createElement(S,{popover:e})}})];case 1:return O.sent(),[2]}})})()}}}}),R.registerFlow({key:"importActionSetting",title:(0,o.escapeT)("Import action settings",{ns:u}),steps:{importSetting:{title:(0,o.escapeT)("Importable fields"),uiSchema:function(e){var t,r,o=(t=e.model.context.blockModel.collection.getFields(),r=e.t,b(t,function(e){var t;return r(null==e||null==(t=e.uiSchema)?void 0:t.title)||e.name},function(e){return e.targetCollection&&e.targetCollection.getFields()||[]}));return{explain:{type:"string",title:'{{ t("Import explain", {ns: "'.concat(u,'"}) }}'),"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:(0,n.css)(C())},properties:{sort:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.SortHandle"},dataIndex:{type:"array","x-decorator":"FormItem","x-component":i.Cascader,required:!0,"x-component-props":{fieldNames:{label:"title",value:"name",children:"children"},changeOnSelect:!1,options:o}},title:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:'{{ t("Custom column title") }}'}},description:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:'{{ t("Field description placeholder", {ns: "'.concat(u,'"}) }}')}},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:'{{ t("Add importable field", {ns: "'.concat(u,'"}) }}'),"x-component":"ArrayItems.Addition","x-component-props":{className:(0,n.css)(M())}}}}}},defaultParams:function(e){var t;return function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){S(e,t,n[t])})}return e}({},{importColumns:null==(t=e.model.context.blockModel.collection.getFields())?void 0:t.filter(function(e){return!e.children&&!e.disabled}).map(function(e){return{dataIndex:[e.name]}}),explain:""})},handler:function(e,t){var n=t.importColumns,r=t.explain,o=null==n?void 0:n.filter(function(e){var t;return null==e||null==(t=e.dataIndex)?void 0:t.length}).map(function(e){return{dataIndex:e.dataIndex.map(function(e){var t;return null!=(t=e.name)?t:e}),title:e.title,description:e.description}});e.model.setProps("importSettings",{importColumns:o,explain:r})}}}});function q(e){return(q=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function U(e,t){return(U=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function X(e){var t="function"==typeof Map?new Map:void 0;return(X=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return D(e,arguments,q(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),U(n,e)})(e)}function H(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(H=function(){return!!e})()}var $=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function n(){var e,t;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return e=n,t=arguments,e=q(e),function(e,t){var n;if(t&&("object"==((n=t)&&"u">typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,H()?Reflect.construct(e,t||[],q(this).constructor):e.apply(this,t))}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&U(n,e),t=[{key:"load",value:function(){var e;return(e=function(){return function(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),l=Object.defineProperty;return l(a,"next",{value:c(0)}),l(a,"throw",{value:c(1)}),l(a,"return",{value:c(2)}),"function"==typeof Symbol&&l(a,Symbol.iterator,{value:function(){return this}}),a;function c(l){return function(c){var u=[l,c];if(n)throw TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=t.call(e,i)}catch(e){u=[6,e],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(e){return this.app.flowEngine.registerModels({ImportActionModel:R}),[2]})},function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){L(i,r,o,a,l,"next",e)}function l(e){L(i,r,o,a,l,"throw",e)}a(void 0)})}).call(this)}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(n.prototype,t),n}(X(e.Plugin)),z=$}(),g}()});
|
package/dist/externalVersion.js
CHANGED
|
@@ -10,26 +10,26 @@
|
|
|
10
10
|
module.exports = {
|
|
11
11
|
"@emotion/css": "11.13.0",
|
|
12
12
|
"@formily/react": "2.3.7",
|
|
13
|
-
"@nocobase/client": "2.2.0-
|
|
13
|
+
"@nocobase/client": "2.2.0-beta.2",
|
|
14
|
+
"antd": "5.24.2",
|
|
14
15
|
"react": "18.2.0",
|
|
15
16
|
"react-i18next": "11.18.6",
|
|
16
17
|
"@ant-design/icons": "5.6.1",
|
|
17
18
|
"@formily/shared": "2.3.7",
|
|
18
|
-
"@nocobase/utils": "2.2.0-
|
|
19
|
+
"@nocobase/utils": "2.2.0-beta.2",
|
|
19
20
|
"@formily/antd-v5": "1.2.3",
|
|
20
|
-
"antd": "5.24.2",
|
|
21
21
|
"react-dom": "18.2.0",
|
|
22
22
|
"lodash": "4.18.1",
|
|
23
23
|
"@formily/core": "2.3.7",
|
|
24
24
|
"@formily/reactive": "2.3.7",
|
|
25
|
-
"@nocobase/client-v2": "2.2.0-
|
|
26
|
-
"@nocobase/flow-engine": "2.2.0-
|
|
27
|
-
"@nocobase/server": "2.2.0-
|
|
28
|
-
"@nocobase/actions": "2.2.0-
|
|
29
|
-
"@nocobase/database": "2.2.0-
|
|
25
|
+
"@nocobase/client-v2": "2.2.0-beta.2",
|
|
26
|
+
"@nocobase/flow-engine": "2.2.0-beta.2",
|
|
27
|
+
"@nocobase/server": "2.2.0-beta.2",
|
|
28
|
+
"@nocobase/actions": "2.2.0-beta.2",
|
|
29
|
+
"@nocobase/database": "2.2.0-beta.2",
|
|
30
30
|
"async-mutex": "0.5.0",
|
|
31
|
-
"@nocobase/data-source-manager": "2.2.0-
|
|
31
|
+
"@nocobase/data-source-manager": "2.2.0-beta.2",
|
|
32
32
|
"sequelize": "6.35.2",
|
|
33
|
-
"@nocobase/logger": "2.2.0-
|
|
33
|
+
"@nocobase/logger": "2.2.0-beta.2",
|
|
34
34
|
"mathjs": "15.1.0"
|
|
35
35
|
};
|
package/dist/locale/en-US.json
CHANGED
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
"Import action settings": "Import action settings",
|
|
21
21
|
"Import completed": "Import completed",
|
|
22
22
|
"Import explain": "Guide",
|
|
23
|
+
"Import failed": "Import failed",
|
|
23
24
|
"Import warnings": "You can import up to {{limit}} rows of data at a time, any excess will be ignored.",
|
|
24
25
|
"ImportResult": "ImportResult",
|
|
25
26
|
"Imported template does not match, please download again.": "Imported template does not match, please download again.",
|
|
@@ -50,4 +51,4 @@
|
|
|
50
51
|
"import-error": "Failed to import row {{rowIndex}}, row data: {{rowData}}, cause: {{causeMessage}}",
|
|
51
52
|
"password is empty": "password is empty",
|
|
52
53
|
"{{successCount}} records have been successfully imported": "{{successCount}} records have been successfully imported"
|
|
53
|
-
}
|
|
54
|
+
}
|
package/dist/locale/zh-CN.json
CHANGED
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
"Import action settings": "导入设置",
|
|
21
21
|
"Import completed": "导入完成:{{success}} 条记录已导入,{{updated}} 条记录已更新,{{skipped}} 条记录已跳过,共 {{total}} 条记录",
|
|
22
22
|
"Import explain": "说明",
|
|
23
|
+
"Import failed": "导入失败",
|
|
23
24
|
"Import warnings": "每次最多导入 {{limit}} 行数据,超出的将被忽略。",
|
|
24
25
|
"ImportResult": "已导入 {{success}} 条,更新 {{updated}} 条,跳过 {{skipped}} 条,共 {{total}} 条",
|
|
25
26
|
"Imported template does not match, please download again.": "导入模板不匹配,请检查导入文件标题行或重新下载导入模板",
|
|
@@ -50,4 +51,4 @@
|
|
|
50
51
|
"import-error": "导入第 {{rowIndex}} 行失败,行数据:{{rowData}}, 原因:{{causeMessage}}",
|
|
51
52
|
"password is empty": "密码为空",
|
|
52
53
|
"{{successCount}} records have been successfully imported": "已成功导入 {{successCount}} 条数据"
|
|
53
|
-
}
|
|
54
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"exceljs","version":"4.4.0","description":"Excel Workbook Manager - Read and Write xlsx and csv Files.","private":false,"license":"MIT","author":{"name":"Guyon Roche","email":"guyon@live.com"},"repository":{"type":"git","url":"https://github.com/exceljs/exceljs.git"},"engines":{"node":">=8.3.0"},"main":"./excel.js","browser":"./dist/exceljs.min.js","types":"./index.d.ts","files":["dist","lib","excel.js","LICENSE","README.md","README_zh.md","index.ts","index.d.ts"],"scripts":{"test":"npm run test:full","test:es5":"export EXCEL_BUILD=es5 && npm run test:full","test:full":"npm run build && npm run test:unit && npm run test:integration && npm run test:end-to-end && npm run test:jasmine","test:version":"npm run build && npm run test:unit && npm run test:integration && npm run test:end-to-end && npm run test:browser && npm run test:dist","test:all":"npm run test:native && npm run test:es5","test:native":"npm run test:full","test:unit":"mocha --require spec/config/setup --require spec/config/setup-unit spec/unit --recursive","test:integration":"mocha --require spec/config/setup spec/integration --recursive","test:end-to-end":"mocha --require spec/config/setup spec/end-to-end --recursive","test:browser":"if [ ! -f .disable-test-browser ]; then npm run build && npm run test:jasmine; fi","test:jasmine":"grunt jasmine","test:unit:es5":"export EXCEL_BUILD=es5 && npm run test:unit","test:integration:es5":"export EXCEL_BUILD=es5 && npm run test:integration","test:end-to-end:es5":"export EXCEL_BUILD=es5 && npm run test:end-to-end","test:dist":"mocha --require spec/config/setup spec/dist --recursive","test:manual":"node spec/manual/app.js","test:typescript":"mocha -r ts-node/register spec/typescript/**/*.spec.ts","clean-build":"npm run clean && npm run build","lint":"eslint --format node_modules/eslint-friendly-formatter .","lint:fix":"prettier-eslint --write $(pwd)'/**/*.js'","lint:staged":"lint-staged","clean":"rm -rf build/ && rm -rf dist","benchmark":"node --expose-gc benchmark","benchmark:debug":"node --expose-gc --inspect-brk --trace-deopt benchmark","build":"grunt build","install-build":"npm install && grunt build","preversion":"npm run clean && npm run build && npm run test:version","postversion":"git push --no-verify && git push --tags --no-verify"},"husky":{"hooks":{"pre-commit":"lint-staged"}},"lint-staged":{"*.js":["prettier-eslint --write","eslint --format node_modules/eslint-friendly-formatter","git add"]},"keywords":["xlsx","json","csv","excel","font","border","fill","number","format","number format","alignment","office","spreadsheet","workbook","defined names","data validations","rich text","in-cell format","outlineLevel","views","frozen","split","pageSetup"],"dependencies":{"archiver":"^5.0.0","dayjs":"^1.8.34","fast-csv":"^4.3.1","jszip":"^3.10.1","readable-stream":"^3.6.0","saxes":"^5.0.1","tmp":"^0.2.0","unzipper":"^0.10.11","uuid":"^8.3.0"},"devDependencies":{"@babel/cli":"^7.10.5","@babel/core":"^7.11.4","@babel/preset-env":"^7.11.0","@types/chai":"^4.2.12","@types/mocha":"^8.0.3","@types/node":"^14.11.2","babelify":"^10.0.0","browserify":"^16.5.2","chai":"^4.2.0","chai-datetime":"^1.7.0","chai-xml":"^0.3.2","core-js":"^3.6.5","dirty-chai":"^2.0.1","eslint":"^6.5.1","eslint-config-airbnb-base":"^14.2.0","eslint-config-prettier":"^6.12.0","eslint-friendly-formatter":"^4.0.1","eslint-plugin-import":"^2.22.0","eslint-plugin-node":"^11.1.0","express":"^4.16.4","got":"^9.0.0","grunt":"^1.3.0","grunt-babel":"^8.0.0","grunt-browserify":"^5.3.0","grunt-contrib-copy":"^1.0.0","grunt-contrib-jasmine":"^2.2.0","grunt-contrib-watch":"^1.1.0","grunt-exorcise":"^2.1.1","grunt-terser":"^1.0.0","husky":"^4.3.0","lint-staged":"^10.2.13","mocha":"^7.2.0","prettier-eslint":"^11.0.0","prettier-eslint-cli":"^5.0.0","regenerator-runtime":"^0.13.7","sax":"^1.2.4","ts-node":"^8.10.2","typescript":"^3.9.7"},"_lastModified":"2026-06-
|
|
1
|
+
{"name":"exceljs","version":"4.4.0","description":"Excel Workbook Manager - Read and Write xlsx and csv Files.","private":false,"license":"MIT","author":{"name":"Guyon Roche","email":"guyon@live.com"},"repository":{"type":"git","url":"https://github.com/exceljs/exceljs.git"},"engines":{"node":">=8.3.0"},"main":"./excel.js","browser":"./dist/exceljs.min.js","types":"./index.d.ts","files":["dist","lib","excel.js","LICENSE","README.md","README_zh.md","index.ts","index.d.ts"],"scripts":{"test":"npm run test:full","test:es5":"export EXCEL_BUILD=es5 && npm run test:full","test:full":"npm run build && npm run test:unit && npm run test:integration && npm run test:end-to-end && npm run test:jasmine","test:version":"npm run build && npm run test:unit && npm run test:integration && npm run test:end-to-end && npm run test:browser && npm run test:dist","test:all":"npm run test:native && npm run test:es5","test:native":"npm run test:full","test:unit":"mocha --require spec/config/setup --require spec/config/setup-unit spec/unit --recursive","test:integration":"mocha --require spec/config/setup spec/integration --recursive","test:end-to-end":"mocha --require spec/config/setup spec/end-to-end --recursive","test:browser":"if [ ! -f .disable-test-browser ]; then npm run build && npm run test:jasmine; fi","test:jasmine":"grunt jasmine","test:unit:es5":"export EXCEL_BUILD=es5 && npm run test:unit","test:integration:es5":"export EXCEL_BUILD=es5 && npm run test:integration","test:end-to-end:es5":"export EXCEL_BUILD=es5 && npm run test:end-to-end","test:dist":"mocha --require spec/config/setup spec/dist --recursive","test:manual":"node spec/manual/app.js","test:typescript":"mocha -r ts-node/register spec/typescript/**/*.spec.ts","clean-build":"npm run clean && npm run build","lint":"eslint --format node_modules/eslint-friendly-formatter .","lint:fix":"prettier-eslint --write $(pwd)'/**/*.js'","lint:staged":"lint-staged","clean":"rm -rf build/ && rm -rf dist","benchmark":"node --expose-gc benchmark","benchmark:debug":"node --expose-gc --inspect-brk --trace-deopt benchmark","build":"grunt build","install-build":"npm install && grunt build","preversion":"npm run clean && npm run build && npm run test:version","postversion":"git push --no-verify && git push --tags --no-verify"},"husky":{"hooks":{"pre-commit":"lint-staged"}},"lint-staged":{"*.js":["prettier-eslint --write","eslint --format node_modules/eslint-friendly-formatter","git add"]},"keywords":["xlsx","json","csv","excel","font","border","fill","number","format","number format","alignment","office","spreadsheet","workbook","defined names","data validations","rich text","in-cell format","outlineLevel","views","frozen","split","pageSetup"],"dependencies":{"archiver":"^5.0.0","dayjs":"^1.8.34","fast-csv":"^4.3.1","jszip":"^3.10.1","readable-stream":"^3.6.0","saxes":"^5.0.1","tmp":"^0.2.0","unzipper":"^0.10.11","uuid":"^8.3.0"},"devDependencies":{"@babel/cli":"^7.10.5","@babel/core":"^7.11.4","@babel/preset-env":"^7.11.0","@types/chai":"^4.2.12","@types/mocha":"^8.0.3","@types/node":"^14.11.2","babelify":"^10.0.0","browserify":"^16.5.2","chai":"^4.2.0","chai-datetime":"^1.7.0","chai-xml":"^0.3.2","core-js":"^3.6.5","dirty-chai":"^2.0.1","eslint":"^6.5.1","eslint-config-airbnb-base":"^14.2.0","eslint-config-prettier":"^6.12.0","eslint-friendly-formatter":"^4.0.1","eslint-plugin-import":"^2.22.0","eslint-plugin-node":"^11.1.0","express":"^4.16.4","got":"^9.0.0","grunt":"^1.3.0","grunt-babel":"^8.0.0","grunt-browserify":"^5.3.0","grunt-contrib-copy":"^1.0.0","grunt-contrib-jasmine":"^2.2.0","grunt-contrib-watch":"^1.1.0","grunt-exorcise":"^2.1.1","grunt-terser":"^1.0.0","husky":"^4.3.0","lint-staged":"^10.2.13","mocha":"^7.2.0","prettier-eslint":"^11.0.0","prettier-eslint-cli":"^5.0.0","regenerator-runtime":"^0.13.7","sax":"^1.2.4","ts-node":"^8.10.2","typescript":"^3.9.7"},"_lastModified":"2026-06-13T08:42:41.281Z"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"xlsx","version":"0.20.3","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":"2026-06-
|
|
1
|
+
{"name":"xlsx","version":"0.20.3","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":"2026-06-13T08:42:44.064Z"}
|
|
@@ -9,5 +9,5 @@
|
|
|
9
9
|
/// <reference types="node" />
|
|
10
10
|
import { Context, Next } from '@nocobase/actions';
|
|
11
11
|
import * as XLSX from 'xlsx';
|
|
12
|
-
export declare function readImportWorkbook(
|
|
12
|
+
export declare function readImportWorkbook(file: Buffer | string, sheetRows: number): XLSX.WorkBook;
|
|
13
13
|
export declare function importXlsx(ctx: Context, next: Next): Promise<void>;
|
|
@@ -43,16 +43,26 @@ module.exports = __toCommonJS(import_xlsx_exports);
|
|
|
43
43
|
var XLSX = __toESM(require("xlsx"));
|
|
44
44
|
var import_async_mutex = require("async-mutex");
|
|
45
45
|
var import_xlsx_importer = require("../services/xlsx-importer");
|
|
46
|
+
var import_fs = __toESM(require("fs"));
|
|
46
47
|
const IMPORT_LIMIT_COUNT = 2e3;
|
|
47
48
|
const mutex = new import_async_mutex.Mutex();
|
|
48
|
-
function readImportWorkbook(
|
|
49
|
-
|
|
50
|
-
type: "buffer",
|
|
49
|
+
function readImportWorkbook(file, sheetRows) {
|
|
50
|
+
const options = {
|
|
51
51
|
sheetRows,
|
|
52
52
|
// Keep Excel date cells as serial numbers. SheetJS `cellDates: true` converts
|
|
53
53
|
// them to local-time Date objects through a timezone-sensitive path, which can
|
|
54
54
|
// shift date-only values in non-UTC environments (for example Asia/Shanghai).
|
|
55
55
|
cellDates: false
|
|
56
|
+
};
|
|
57
|
+
if (typeof file === "string") {
|
|
58
|
+
return XLSX.read(import_fs.default.readFileSync(file), {
|
|
59
|
+
type: "buffer",
|
|
60
|
+
...options
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
return XLSX.read(file, {
|
|
64
|
+
type: "buffer",
|
|
65
|
+
...options
|
|
56
66
|
});
|
|
57
67
|
}
|
|
58
68
|
async function importXlsxAction(ctx, next) {
|
|
@@ -66,24 +76,31 @@ async function importXlsxAction(ctx, next) {
|
|
|
66
76
|
if (ctx.request.body.explain) {
|
|
67
77
|
readLimit += 1;
|
|
68
78
|
}
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
79
|
+
const uploadedFilePath = ctx.file.path;
|
|
80
|
+
try {
|
|
81
|
+
const workbook = readImportWorkbook(uploadedFilePath || ctx.file.buffer, readLimit);
|
|
82
|
+
const repository = ctx.getCurrentRepository();
|
|
83
|
+
const dataSource = ctx.dataSource;
|
|
84
|
+
const collection = repository.collection;
|
|
85
|
+
const importer = new import_xlsx_importer.XlsxImporter({
|
|
86
|
+
collectionManager: dataSource.collectionManager,
|
|
87
|
+
collection,
|
|
88
|
+
columns,
|
|
89
|
+
workbook,
|
|
90
|
+
explain: ctx.request.body.explain,
|
|
91
|
+
repository,
|
|
92
|
+
rowDefaultValues: ((_a = ctx.action.params) == null ? void 0 : _a.rowDefaultValues) || {}
|
|
93
|
+
});
|
|
94
|
+
const importedCount = await importer.run({
|
|
95
|
+
context: ctx
|
|
96
|
+
});
|
|
97
|
+
ctx.bodyMeta = { successCount: importedCount };
|
|
98
|
+
ctx.body = ctx.bodyMeta;
|
|
99
|
+
} finally {
|
|
100
|
+
if (uploadedFilePath) {
|
|
101
|
+
await import_fs.default.promises.rm(uploadedFilePath, { force: true });
|
|
102
|
+
}
|
|
103
|
+
}
|
|
87
104
|
}
|
|
88
105
|
async function importXlsx(ctx, next) {
|
|
89
106
|
if (mutex.isLocked()) {
|
|
@@ -7,9 +7,11 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
+
var __create = Object.create;
|
|
10
11
|
var __defProp = Object.defineProperty;
|
|
11
12
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
13
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
14
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
13
15
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
16
|
var __export = (target, all) => {
|
|
15
17
|
for (var name in all)
|
|
@@ -23,6 +25,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
23
25
|
}
|
|
24
26
|
return to;
|
|
25
27
|
};
|
|
28
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
29
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
30
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
31
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
32
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
33
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
34
|
+
mod
|
|
35
|
+
));
|
|
26
36
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
27
37
|
var middleware_exports = {};
|
|
28
38
|
__export(middleware_exports, {
|
|
@@ -30,11 +40,27 @@ __export(middleware_exports, {
|
|
|
30
40
|
});
|
|
31
41
|
module.exports = __toCommonJS(middleware_exports);
|
|
32
42
|
var import_utils = require("@nocobase/utils");
|
|
43
|
+
var import_fs = __toESM(require("fs"));
|
|
44
|
+
var import_path = __toESM(require("path"));
|
|
45
|
+
function getUploadDir() {
|
|
46
|
+
return import_path.default.join(process.cwd(), "storage", "tmp");
|
|
47
|
+
}
|
|
33
48
|
async function importMiddleware(ctx, next) {
|
|
34
49
|
if (ctx.action.actionName !== "importXlsx") {
|
|
35
50
|
return next();
|
|
36
51
|
}
|
|
37
|
-
const
|
|
52
|
+
const storage = import_utils.koaMulter.diskStorage({
|
|
53
|
+
destination(req, file, cb) {
|
|
54
|
+
const dir = getUploadDir();
|
|
55
|
+
import_fs.default.mkdirSync(dir, { recursive: true });
|
|
56
|
+
cb(null, dir);
|
|
57
|
+
},
|
|
58
|
+
filename(req, file, cb) {
|
|
59
|
+
const ext = import_path.default.extname(file.originalname || ".xlsx") || ".xlsx";
|
|
60
|
+
cb(null, `import-${Date.now()}-${Math.random().toString(36).slice(2)}${ext}`);
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
const upload = (0, import_utils.koaMulter)({ storage }).single("file");
|
|
38
64
|
return upload(ctx, next);
|
|
39
65
|
}
|
|
40
66
|
// Annotate the CommonJS export names for ESM import in node:
|
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"description": "Import records using excel templates. You can configure which fields to import and templates will be generated automatically.",
|
|
7
7
|
"description.ru-RU": "Импорт записей с помощью шаблонов Excel: можно настроить, какие поля импортировать, шаблоны будут генерироваться автоматически.",
|
|
8
8
|
"description.zh-CN": "使用 Excel 模板导入数据,可以配置导入哪些字段,自动生成模板。",
|
|
9
|
-
"version": "2.2.0-
|
|
9
|
+
"version": "2.2.0-beta.2",
|
|
10
10
|
"license": "Apache-2.0",
|
|
11
11
|
"main": "./dist/server/index.js",
|
|
12
12
|
"homepage": "https://docs.nocobase.com/handbook/action-import",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"@nocobase/test": "2.x",
|
|
48
48
|
"@nocobase/utils": "2.x"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "2fe3e6a86fc1d0cd039349a68b2e4d1d6945ce45",
|
|
51
51
|
"keywords": [
|
|
52
52
|
"Actions"
|
|
53
53
|
]
|