@nocobase/plugin-action-export 2.2.0-beta.8 → 2.2.0-beta.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,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("lodash"),require("react-i18next"),require("@nocobase/flow-engine"),require("@nocobase/client-v2"),require("@emotion/css"),require("@formily/antd-v5"),require("@formily/shared"),require("react"),require("antd"),require("@nocobase/client"),require("@formily/react")):"function"==typeof define&&define.amd?define("@nocobase/plugin-action-export",["lodash","react-i18next","@nocobase/flow-engine","@nocobase/client-v2","@emotion/css","@formily/antd-v5","@formily/shared","react","antd","@nocobase/client","@formily/react"],t):"object"==typeof exports?exports["@nocobase/plugin-action-export"]=t(require("lodash"),require("react-i18next"),require("@nocobase/flow-engine"),require("@nocobase/client-v2"),require("@emotion/css"),require("@formily/antd-v5"),require("@formily/shared"),require("react"),require("antd"),require("@nocobase/client"),require("@formily/react")):e["@nocobase/plugin-action-export"]=t(e.lodash,e["react-i18next"],e["@nocobase/flow-engine"],e["@nocobase/client-v2"],e["@emotion/css"],e["@formily/antd-v5"],e["@formily/shared"],e.react,e.antd,e["@nocobase/client"],e["@formily/react"])}(self,function(e,t,n,r,o,i,a,l,c,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(){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)},477:function(e){"use strict";e.exports=o},418:function(e){"use strict";e.exports=i},230:function(e){"use strict";e.exports=s},166:function(e){"use strict";e.exports=a},342:function(e){"use strict";e.exports=u},485:function(e){"use strict";e.exports=r},694:function(e){"use strict";e.exports=n},59:function(e){"use strict";e.exports=c},773:function(t){"use strict";t.exports=e},155:function(e){"use strict";e.exports=l},953:function(e){"use strict";e.exports=t}},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,b=d.g.document;if(!m&&b&&(b.currentScript&&"SCRIPT"===b.currentScript.tagName.toUpperCase()&&(m=b.currentScript.src),!m)){var y=b.getElementsByTagName("script");if(y.length)for(var v=y.length-1;v>-1&&(!m||!/^http(s?):/.test(m));)m=y[v--].src}if(!m)throw Error("Automatic publicPath is not supported in this browser");d.p=m.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/");var h={};return!function(){"use strict";var e="",t="u">typeof document?document.currentScript:null;if(t&&t.src){var n=t.src.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"");n.indexOf("/static/plugins/@nocobase/plugin-action-export/dist/client/")>=0&&(e=n.replace(/\/[^\/]+$/,"/"))}if(!e){var r=window.__webpack_public_path__||"";r&&("/"!==r.charAt(r.length-1)&&(r+="/"),e=r+"static/plugins/@nocobase/plugin-action-export/dist/client/")}if(!e){var o=window.__nocobase_modern_client_prefix__||"v",i="/"+(o=String(o).replace(/^\/+|\/+$/g,"")||"v")+"/";if(!(e=window.__nocobase_public_path__||"")&&window.location&&window.location.pathname){var a=window.location.pathname||"/",l=a.indexOf(i);e=l>=0?a.slice(0,l+1):"/"}e&&(e=e.replace(RegExp("/"+o+"/?$"),"/")),e||(e="/"),"/"!==e.charAt(e.length-1)&&(e+="/"),e+="static/plugins/@nocobase/plugin-action-export/dist/client/"}d.p=e}(),!function(){"use strict";d.r(h),d.d(h,{PluginActionExportClient:function(){return eh},ExportDesigner:function(){return D},buildExportFieldOptions:function(){return x},default:function(){return eg},ExportActionModel:function(){return ec},ExportPluginProvider:function(){return B},useExportAction:function(){return $},ExportActionInitializer:function(){return A}});var e,t=d(166),n=d(342),r=d(155),o=d.n(r),i=d(230);function a(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 l(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}function c(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}var u=["hasMany","belongsToMany","belongsToArray"],s=((function(e){if(Array.isArray(e))return a(e)})(e=["hasOne","belongsTo"])||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e){if(e){if("string"==typeof e)return a(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 a(e,void 0)}}(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()).concat(["hasMany","belongsToMany","belongsToArray"]),p=new WeakMap,f=function(e){return(null==e?void 0:e.target)&&s.includes(e.type)},m=function(e){return(null==e?void 0:e.target)&&u.includes(e.type)},b=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}},y=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=f(e),o=c(l({},b(e,t)),{isLeaf:!r});return p.set(o,{field:e,relationDepth:r?n:0}),o},v=function(e,t,n){return!(n>=2||m(e)&&m(t))},g=function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;if(!(null==e?void 0:e.interface))return null;if(!f(e))return b(e,t);var o=(n(e)||[]).map(function(o){return f(o)?v(e,o,r)?g(o,t,n,r+1):null:g(o,t,n)}).filter(Boolean);return o.length?c(l({},b(e,t)),{children:o}):b(e,t,!0)},x=function(e,t,n){return(e||[]).map(function(e){return g(e,t,n,+!!f(e))}).filter(Boolean)},S=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=n.parentField,o=n.parentRelationDepth,i=void 0===o?0:o;return(e||[]).map(function(e){return!(null==e?void 0:e.interface)||r&&f(e)&&!v(r,e,i)?null:y(e,t,f(e)?i+1:0)}).filter(Boolean)},w=function(e,t,n){var r=e&&(void 0===e?"undefined":e&&"u">typeof Symbol&&e.constructor===Symbol?"symbol":typeof e)=="object"?p.get(e):null,o=null==r?void 0:r.field;return f(o)?S(n(o)||[],t,{parentField:o,parentRelationDepth:(null==r?void 0:r.relationDepth)||1}):[]},O=function(e,t,n){var r=S(e,t),o=function(e){if(!e||e.isLeaf)return[];if(e.children)return e.children;var r=w(e,t,n);return r.length?e.children=r:(e.isLeaf=!0,e.disabled=!0,e.children=[]),e.children};return{getRootOptions:function(){return r},loadChildren:o,preloadPath:function(e){if(!Array.isArray(e)||e.length<=1)return!1;for(var t=!1,n=r,i=0;i<e.length-1&&"break"!==function(r){var i,a,l=null!=(i=null==(a=e[r])?void 0:a.name)?i:e[r],c=n.find(function(e){return(null==e?void 0:e.name)===l});if(!c||c.isLeaf)return"break";var u=!!c.children;n=o(c),u||(t=!0)}(i);i++);return t}}},j=function(e){var t,r=(0,i.useFieldSchema)();null==r||null==(t=r["x-component-props"])||t.nonfilterable;var o=(0,n.useCollectionManager_deprecated)().getCollectionFields,a=o(e),l=(0,n.useCompile)();return x(a,function(e){var t;return l(null==e||null==(t=e.uiSchema)?void 0:t.title)||e.name},function(e){return o(e.target)})},A=function(){var e=(0,n.useSchemaInitializerItem)(),r=(0,n.useSchemaInitializer)().insert,i=j((0,n.useCollection_deprecated)().name),a={type:"void",title:'{{ t("Export") }}',"x-action":"export","x-action-settings":{exportSettings:[]},"x-toolbar":"ActionSchemaToolbar","x-settings":"actionSettings:export","x-decorator":"ACLActionProvider","x-component":"Action","x-use-component-props":"useExportAction","x-component-props":{icon:"clouddownloadoutlined"}};return o().createElement(n.SchemaInitializerItem,{title:e.title,onClick:function(){a["x-action-settings"].exportSettings=null==i?void 0:i.filter(function(e){return!e.children&&!e.disabled}).map(function(e){return{dataIndex:[e.name]}});var n,o=(0,t.merge)(a||{},e.schema||{});null==e||null==(n=e.schemaInitialize)||n.call(e,o),r(o)}})},I=d(418);function E(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function P(){var e=E(["\n width: 100%;\n & .ant-space-item:nth-child(2),\n & .ant-space-item:nth-child(3) {\n flex: 1;\n }\n "]);return P=function(){return e},e}function k(){var e=E(["\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 k=function(){return e},e}var C=function(){var e=(0,n.useCollection_deprecated)().name,t=(0,n.useCompile)(),r=j(e);return{schema:{type:"void","x-component":"Grid",properties:{exportSettings:{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)(P())},properties:{sort:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.SortHandle"},dataIndex:{type:"array","x-decorator":"FormItem","x-component":"Cascader",required:!0,"x-component-props":{fieldNames:{label:"title",value:"name",children:"children"},changeOnSelect:!1},"x-use-component-props":function(){return{options:t(r)}}},title:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:'{{ t("Custom column title") }}'}},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:'{{ t("Add exportable field") }}',"x-component":"ArrayItems.Addition","x-component-props":{className:(0,n.css)(k())}}}}}}}},T=d(953),_="action-export";function F(){return(0,T.useTranslation)([_,"client"],{nsMode:"fallback"})}function M(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 R(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var D=function(){var e,t,a,l,c,u,s=(0,i.useField)(),p=(0,i.useFieldSchema)(),f=F().t,d=(0,n.useDesignable)().dn,m=function(e){if(Array.isArray(e))return e}(e=(0,r.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 M(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 M(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=m[0],y=m[1],v=C().schema;return(0,r.useEffect)(function(){y(v)},[s.address,null==p||null==(t=p["x-action-settings"])?void 0:t.exportSettings]),o().createElement(n.GeneralSchemaDesigner,{disableInitializer:!0},o().createElement(n.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,d.emit("patch",{schema:(R(t={},"x-uid",p["x-uid"]),R(t,"title",n),R(t,"x-component-props",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){R(e,t,n[t])})}return e}({},p["x-component-props"])),t)}),d.refresh()}}),o().createElement(n.SchemaSettingsActionModalItem,{title:f("Exportable fields"),schema:b,initialValues:{exportSettings:null==p||null==(u=p["x-action-settings"])?void 0:u.exportSettings},scope:{t:f},components:{ArrayItems:I.ArrayItems},onSubmit:function(e){var t,n=e.exportSettings;p["x-action-settings"].exportSettings=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}}),d.emit("patch",{schema:(R(t={},"x-uid",p["x-uid"]),R(t,"x-action-settings",p["x-action-settings"]),t)}),d.refresh()}}),o().createElement(n.SchemaSettingsDivider,null),o().createElement(n.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:function(e){return"Space"===e["x-component"]||e["x-component"].endsWith("ActionBar")},confirm:{title:f("Delete action")}}))},B=function(e){return o().createElement(n.SchemaComponentOptions,{components:{ExportActionInitializer:A,ExportDesigner:D},scope:{useExportAction:$}},e.children)},q=d(773),L=d.n(q),U=d(574),z=d(59);function N(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)}var $=function(){var e,t=(0,n.useBlockRequestContext)(),o=t.service,a=t.props,l=(0,n.useDataBlockResource)(),c=(0,n.useTableBlockContext)().params,u=(0,n.useCurrentAppInfo)(),s=null==a?void 0:a.params.filter,p=(0,i.useFieldSchema)(),f=(0,n.useCompile)(),d=(0,n.useCollectionManager_deprecated)().getCollectionJoinField,m=(0,n.useCollection_deprecated)(),b=m.name,y=m.title,v=F().t,h=z.App.useApp().modal,g=(null==(e=o.params[0])?void 0:e.filter)||{},x=(0,i.useField)(),S=(0,r.useMemo)(function(){var e;return(null==u||null==(e=u.data)?void 0:e.exportLimit)?u.data.exportLimit:2e3},[u]);return{onClick:function(){var e;return(e=function(){var e,t,r,i,a;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(u){switch(u.label){case 0:return x.data=x.data||{},[4,h.confirm({title:v("Export"),content:v("Export warning",{limit:S}),okText:v("Start export")})];case 1:if(!u.sent())return[2];return x.data.loading=!0,(i=L().cloneDeep(null!=(e=null==p?void 0:p["x-action-settings"])?e:{}).exportSettings).forEach(function(e){var t,n,r=null!=(t=d("".concat(b,".").concat(e.dataIndex.join("."))))?t:{},o=r.uiSchema;r.interface,e.enum=null==o||null==(n=o.enum)?void 0:n.map(function(e){return{value:e.value,label:e.label}}),e.enum||(null==o?void 0:o.type)!=="boolean"||(e.enum=[{value:!0,label:v("Yes")},{value:!1,label:v("No")}]),e.defaultTitle=null==o?void 0:o.title}),[4,l.export({title:f(y),appends:null==(r=o.params[0])||null==(t=r.appends)?void 0:t.join(),filter:(0,n.mergeFilter)([g,s]),sort:null==c?void 0:c.sort,values:{columns:f(i)}},{responseType:"blob"})];case 2:return a=new Blob([u.sent().data],{type:"application/x-xls"}),x.data.loading=!1,(0,U.saveAs)(a,"".concat(f(y),".xlsx")),[2]}})},function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){N(i,r,o,a,l,"next",e)}function l(e){N(i,r,o,a,l,"throw",e)}a(void 0)})})()}}},H=d(694),G=d(485),K=d(477);function V(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}var W=function(e){return Array.isArray(e)&&e.length?e.map(function(e){var t;return null!=(t=null==e?void 0:e.name)?t:e}):null},X=function(e){var t;return function(e){if(Array.isArray(e))return V(e)}(t=e.getRootOptions())||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(t)||function(e){if(e){if("string"==typeof e)return V(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 V(e,void 0)}}(t)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()};function Y(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 l=e[i](a),c=l.value}catch(e){n(e);return}l.done?t(c):Promise.resolve(c).then(r,o)}function Q(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Z(e){return(Z=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function ee(e,t){return(ee=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function et(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function en(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(en=function(){return!!e})()}function er(){var e=et(["\n width: 100%;\n & .ant-space-item:nth-child(2),\n & .ant-space-item:nth-child(3) {\n flex: 1;\n }\n "]);return er=function(){return e},e}function eo(){var e=et(["\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 eo=function(){return e},e}var ei={label:"title",value:"name",children:"children"},ea=function(e){var t,n,r,i=e.optionsCache,a=e.value,l=e.onChange,c=e.onDropdownVisibleChange,u=function(e,t){if(null==e)return{};var n,r,o,i={};if("u">typeof Reflect&&Reflect.ownKeys){for(o=0,n=Reflect.ownKeys(Object(e));o<n.length;o++)r=n[o],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(i[r]=e[r]);return i}if(i=function(e,t){if(null==e)return{};var n,r,o={},i=Object.getOwnPropertyNames(e);for(r=0;r<i.length;r++)n=i[r],!(t.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n]);return o}(e,t),Object.getOwnPropertySymbols)for(o=0,n=Object.getOwnPropertySymbols(e);o<n.length;o++)r=n[o],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(i[r]=e[r]);return i}(e,["optionsCache","value","onChange","onDropdownVisibleChange"]),s=function(e){if(Array.isArray(e))return e}(t=o().useState(function(){return X(i)}))||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}}(t)||function(e){if(e){if("string"==typeof e)return Y(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 Y(e,2)}}(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.")}(),p=s[0],f=s[1],d=o().useRef(null),m=o().useMemo(function(){return W(a)||void 0},[a]),b=o().useCallback(function(){f(X(i))},[i]);o().useEffect(function(){b()},[b]);var y=o().useCallback(function(e){return Array.isArray(e)?e.map(function(e){var t;return null!=(t=null==e?void 0:e.name)?t:e}).join("."):""},[]),v=o().useCallback(function(e){var t=null==e?void 0:e[e.length-1];!t||t.isLeaf||t.children||(t.loading=!0,i.loadChildren(t),t.loading=!1,b())},[i,b]),h=o().useCallback(function(){var e=y(a);e&&d.current!==e&&(d.current=e,i.preloadPath(a)&&b())},[y,i,b,a]),g=o().useCallback(function(e){e&&h(),null==c||c(e)},[c,h]),x=o().useCallback(function(e){null==l||l(W(e))},[l]),S=o().useCallback(function(e,t){var n=y(a),r=n?n.split(".").length:0;return(null==e?void 0:e.length)&&(!r||e.length>=r)?e.join(" / "):n?n.replace(/\./g," / "):null==t?void 0:t.map(function(e){return(null==e?void 0:e.title)||(null==e?void 0:e.name)}).join(" / ")},[y,a]);return o().createElement(z.Cascader,(n=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){Q(e,t,n[t])})}return e}({},u),r=r={value:m,fieldNames:ei,options:p,loadData:v,onChange:x,onDropdownVisibleChange:g,displayRender:S},Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(r)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(r)).forEach(function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(r,e))}),n))},el=function(e,t){return O(e,function(e){var n;return t(null==e||null==(n=e.uiSchema)?void 0:n.title)||e.name},function(e){return e.targetCollection&&e.targetCollection.getFields()||[]})},ec=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=Z(t),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,en()?Reflect.construct(t,r||[],Z(this).constructor):t.apply(this,r)),"defaultProps",{title:(0,H.escapeT)("Export"),type:"default",icon:"clouddownloadoutlined"}),e}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&ee(n,e),t=[{key:"getAclActionName",value:function(){return"export"}}],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}(G.ActionModel);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,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}Q(ec,"scene",G.ActionSceneEnum.collection),ec.define({label:(0,H.escapeT)("Export"),sort:1030}),ec.registerFlow({key:"exportSettings",on:"click",steps:{confirm:{use:"confirm",hideInSettings:!0,defaultParams:{enable:!0,title:(0,H.escapeT)("Export"),content:(0,H.escapeT)("Export warning",{ns:_,limit:2e3})}},export:{handler:function(e,t){var n;return(n=function(){var t,n,r,o,i,a,l,c,u,s;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(p){switch(p.label){case 0:return t=e.model.getProps().exportSettings,r=(n=e.model.context.blockModel).resource,i=(o=n.collection).title,a=o.fields,l=o.filterTargetKey,u=(c=r.getSelectedRows()).length>0?Q({},l,e.blockModel.collection.getFilterByTK(c)):r.getFilter(),Array.isArray(l)&&l.length>1&&(u={$or:e.blockModel.collection.getFilterByTK(c)}),t.forEach(function(t){var n,r,o=null!=(n=a.get(t.dataIndex[0]))?n:{},i=o.uiSchema;o.interface,t.enum=null==i||null==(r=i.enum)?void 0:r.map(function(e){return{value:e.value,label:e.label}}),t.enum||(null==i?void 0:i.type)!=="boolean"||(t.enum=[{value:!0,label:e.t("Yes")},{value:!1,label:e.t("No")}]),t.defaultTitle=e.t(null==i?void 0:i.title)}),[4,r.runAction("export",{data:{columns:t},responseType:"blob",params:{title:e.t(i),appends:r.getAppends(),sort:r.getSort(),filter:u}})];case 1:return s=new Blob([p.sent()],{type:"application/x-xls"}),(0,U.saveAs)(s,"".concat(e.t(i),".xlsx")),[2]}})},function(){var e=this,t=arguments;return new Promise(function(r,o){var i=n.apply(e,t);function a(e){J(i,r,o,a,l,"next",e)}function l(e){J(i,r,o,a,l,"throw",e)}a(void 0)})})()}}}}),ec.registerFlow({key:"exportActionSetting",title:(0,H.escapeT)("Export settings",{ns:_}),steps:{exportableFields:{title:(0,H.escapeT)("Exportable fields"),uiSchema:function(e){var t=el(e.model.context.blockModel.collection.getFields(),e.t);return{exportSettings:{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)(er())},properties:{sort:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.SortHandle"},dataIndex:{type:"array","x-decorator":"FormItem","x-component":ea,required:!0,"x-component-props":{changeOnSelect:!1,optionsCache:t}},title:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:'{{ t("Custom column title") }}'}},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:'{{ t("Add exportable field") }}',"x-component":"ArrayItems.Addition","x-component-props":{className:(0,K.css)(eo())}}}}}},defaultParams:function(e){var t;return{exportSettings:null==(t=e.model.context.blockModel.collection.getFields())?void 0:t.filter(function(e){return!e.isAssociationField()&&e.options.interface}).map(function(e){return{dataIndex:[e.name]}})}},handler:function(e,t){var n=t.exportSettings,r=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}});e.model.setProps("exportSettings",r)}}}});var ep=new n.SchemaSettings({name:"actionSettings:export",items:[{name:"editButton",Component:n.ButtonEditor,useComponentProps:function(){return(0,n.useSchemaToolbar)().buttonEditorProps}},{name:"linkageRules",Component:n.SchemaSettingsLinkageRules,useComponentProps:function(){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){es(e,t,n[t])})}return e}({},(0,n.useSchemaToolbar)().linkageRulesProps)}},{name:"exportableFields",type:"actionModal",useComponentProps:function(){var e,t,o,a=(0,i.useField)(),l=(0,i.useFieldSchema)(),c=(0,T.useTranslation)().t,u=(0,n.useDesignable)().dn,s=function(e){if(Array.isArray(e))return e}(e=(0,r.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 eu(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 eu(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],d=C().schema;return(0,r.useEffect)(function(){f(d)},[a.address,null==l||null==(t=l["x-action-settings"])?void 0:t.exportSettings]),{title:c("Exportable fields"),schema:p,initialValues:{exportSettings:null==l||null==(o=l["x-action-settings"])?void 0:o.exportSettings},components:{ArrayItems:I.ArrayItems},onSubmit:function(e){var t,n=e.exportSettings;l["x-action-settings"].exportSettings=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}}),u.emit("patch",{schema:(es(t={},"x-uid",l["x-uid"]),es(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,T.useTranslation)().t)("Delete action")}}}}]});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 ed(e,t,n){return(ed=ev()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&eb(o,n.prototype),o}).apply(null,arguments)}function em(e){return(em=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 ey(e){var t="function"==typeof Map?new Map:void 0;return(ey=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 ed(e,arguments,em(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),eb(n,e)})(e)}function ev(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(ev=function(){return!!e})()}var eh=function(e){var t;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=em(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,ev()?Reflect.construct(e,t||[],em(this).constructor):e.apply(this,t))}return r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),e&&eb(r,e),t=[{key:"load",value:function(){var e;return(e=function(){var e,t;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(B),e={title:"{{t('Export')}}",Component:"ExportActionInitializer",schema:{"x-align":"right","x-decorator":"ACLActionProvider","x-acl-action-props":{skipScopeCheck:!0}},useVisible:function(){return(0,n.useActionAvailable)("export")}},null==(t=this.app.schemaInitializerManager.get("table:configureActions"))||t.add("enableActions.export",e),this.app.schemaInitializerManager.addItem("gantt:configureActions","enableActions.export",e),this.app.schemaSettingsManager.add(ep),this.app.flowEngine.registerModels({ExportActionModel:ec}),[2]})},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)})}).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,t),r}(ey(n.Plugin)),eg=eh}(),h}()});
10
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("lodash"),require("react-i18next"),require("@nocobase/flow-engine"),require("@nocobase/client-v2"),require("@emotion/css"),require("@formily/antd-v5"),require("@formily/shared"),require("react"),require("antd"),require("@nocobase/client"),require("@formily/react")):"function"==typeof define&&define.amd?define("@nocobase/plugin-action-export",["lodash","react-i18next","@nocobase/flow-engine","@nocobase/client-v2","@emotion/css","@formily/antd-v5","@formily/shared","react","antd","@nocobase/client","@formily/react"],t):"object"==typeof exports?exports["@nocobase/plugin-action-export"]=t(require("lodash"),require("react-i18next"),require("@nocobase/flow-engine"),require("@nocobase/client-v2"),require("@emotion/css"),require("@formily/antd-v5"),require("@formily/shared"),require("react"),require("antd"),require("@nocobase/client"),require("@formily/react")):e["@nocobase/plugin-action-export"]=t(e.lodash,e["react-i18next"],e["@nocobase/flow-engine"],e["@nocobase/client-v2"],e["@emotion/css"],e["@formily/antd-v5"],e["@formily/shared"],e.react,e.antd,e["@nocobase/client"],e["@formily/react"])}(self,function(e,t,n,r,o,i,a,l,c,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(){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)},477:function(e){"use strict";e.exports=o},418:function(e){"use strict";e.exports=i},230:function(e){"use strict";e.exports=s},166:function(e){"use strict";e.exports=a},342:function(e){"use strict";e.exports=u},485:function(e){"use strict";e.exports=r},694:function(e){"use strict";e.exports=n},59:function(e){"use strict";e.exports=c},773:function(t){"use strict";t.exports=e},155:function(e){"use strict";e.exports=l},953:function(e){"use strict";e.exports=t}},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,b=d.g.document;if(!m&&b&&(b.currentScript&&"SCRIPT"===b.currentScript.tagName.toUpperCase()&&(m=b.currentScript.src),!m)){var y=b.getElementsByTagName("script");if(y.length)for(var v=y.length-1;v>-1&&(!m||!/^http(s?):/.test(m));)m=y[v--].src}if(!m)throw Error("Automatic publicPath is not supported in this browser");d.p=m.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/");var h={};return!function(){"use strict";var e="",t="u">typeof document?document.currentScript:null;if(t&&t.src){var n=t.src.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"");n.indexOf("/static/plugins/@nocobase/plugin-action-export/dist/client/")>=0&&(e=n.replace(/\/[^\/]+$/,"/"))}if(!e){var r=window.__webpack_public_path__||"";r&&("/"!==r.charAt(r.length-1)&&(r+="/"),e=r+"static/plugins/@nocobase/plugin-action-export/dist/client/")}if(!e){var o=window.__nocobase_modern_client_prefix__||"v",i="/"+(o=String(o).replace(/^\/+|\/+$/g,"")||"v")+"/";if(!(e=window.__nocobase_public_path__||"")&&window.location&&window.location.pathname){var a=window.location.pathname||"/",l=a.indexOf(i);e=l>=0?a.slice(0,l+1):"/"}e&&(e=e.replace(RegExp("/"+o+"/?$"),"/")),e||(e="/"),"/"!==e.charAt(e.length-1)&&(e+="/"),e+="static/plugins/@nocobase/plugin-action-export/dist/client/"}d.p=e}(),!function(){"use strict";d.r(h),d.d(h,{PluginActionExportClient:function(){return eh},ExportDesigner:function(){return D},buildExportFieldOptions:function(){return x},default:function(){return eg},ExportActionModel:function(){return ec},ExportPluginProvider:function(){return B},useExportAction:function(){return $},ExportActionInitializer:function(){return A}});var e,t=d(166),n=d(342),r=d(155),o=d.n(r),i=d(230);function a(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 l(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}function c(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}var u=["hasMany","belongsToMany","belongsToArray"],s=((function(e){if(Array.isArray(e))return a(e)})(e=["hasOne","belongsTo"])||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e){if(e){if("string"==typeof e)return a(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 a(e,void 0)}}(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()).concat(["hasMany","belongsToMany","belongsToArray"]),p=new WeakMap,f=function(e){return(null==e?void 0:e.target)&&s.includes(e.type)},m=function(e){return(null==e?void 0:e.target)&&u.includes(e.type)},b=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}},y=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=f(e),o=c(l({},b(e,t)),{isLeaf:!r});return p.set(o,{field:e,relationDepth:r?n:0}),o},v=function(e,t,n){return!(n>=2||m(e)&&m(t))},g=function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;if(!(null==e?void 0:e.interface))return null;if(!f(e))return b(e,t);var o=(n(e)||[]).map(function(o){return f(o)?v(e,o,r)?g(o,t,n,r+1):null:g(o,t,n)}).filter(Boolean);return o.length?c(l({},b(e,t)),{children:o}):b(e,t,!0)},x=function(e,t,n){return(e||[]).map(function(e){return g(e,t,n,+!!f(e))}).filter(Boolean)},S=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=n.parentField,o=n.parentRelationDepth,i=void 0===o?0:o;return(e||[]).map(function(e){return!(null==e?void 0:e.interface)||r&&f(e)&&!v(r,e,i)?null:y(e,t,f(e)?i+1:0)}).filter(Boolean)},w=function(e,t,n){var r=e&&(void 0===e?"undefined":e&&"u">typeof Symbol&&e.constructor===Symbol?"symbol":typeof e)=="object"?p.get(e):null,o=null==r?void 0:r.field;return f(o)?S(n(o)||[],t,{parentField:o,parentRelationDepth:(null==r?void 0:r.relationDepth)||1}):[]},O=function(e,t,n){var r=S(e,t),o=function(e){if(!e||e.isLeaf)return[];if(e.children)return e.children;var r=w(e,t,n);return r.length?e.children=r:(e.isLeaf=!0,e.disabled=!0,e.children=[]),e.children};return{getRootOptions:function(){return r},loadChildren:o,preloadPath:function(e){if(!Array.isArray(e)||e.length<=1)return!1;for(var t=!1,n=r,i=0;i<e.length-1&&"break"!==function(r){var i,a,l=null!=(i=null==(a=e[r])?void 0:a.name)?i:e[r],c=n.find(function(e){return(null==e?void 0:e.name)===l});if(!c||c.isLeaf)return"break";var u=!!c.children;n=o(c),u||(t=!0)}(i);i++);return t}}},j=function(e){var t,r=(0,i.useFieldSchema)();null==r||null==(t=r["x-component-props"])||t.nonfilterable;var o=(0,n.useCollectionManager_deprecated)().getCollectionFields,a=o(e),l=(0,n.useCompile)();return x(a,function(e){var t;return l(null==e||null==(t=e.uiSchema)?void 0:t.title)||e.name},function(e){return o(e.target)})},A=function(){var e=(0,n.useSchemaInitializerItem)(),r=(0,n.useSchemaInitializer)().insert,i=j((0,n.useCollection_deprecated)().name),a={type:"void",title:'{{ t("Export") }}',"x-action":"export","x-action-settings":{exportSettings:[]},"x-toolbar":"ActionSchemaToolbar","x-settings":"actionSettings:export","x-decorator":"ACLActionProvider","x-component":"Action","x-use-component-props":"useExportAction","x-component-props":{icon:"clouddownloadoutlined"}};return o().createElement(n.SchemaInitializerItem,{title:e.title,onClick:function(){a["x-action-settings"].exportSettings=null==i?void 0:i.filter(function(e){return!e.children&&!e.disabled}).map(function(e){return{dataIndex:[e.name]}});var n,o=(0,t.merge)(a||{},e.schema||{});null==e||null==(n=e.schemaInitialize)||n.call(e,o),r(o)}})},I=d(418);function P(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function E(){var e=P(["\n width: 100%;\n & .ant-space-item:nth-child(2),\n & .ant-space-item:nth-child(3) {\n flex: 1;\n }\n "]);return E=function(){return e},e}function k(){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 k=function(){return e},e}var C=function(){var e=(0,n.useCollection_deprecated)().name,t=(0,n.useCompile)(),r=j(e);return{schema:{type:"void","x-component":"Grid",properties:{exportSettings:{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)(E())},properties:{sort:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.SortHandle"},dataIndex:{type:"array","x-decorator":"FormItem","x-component":"Cascader",required:!0,"x-component-props":{fieldNames:{label:"title",value:"name",children:"children"},changeOnSelect:!1},"x-use-component-props":function(){return{options:t(r)}}},title:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:'{{ t("Custom column title") }}'}},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:'{{ t("Add exportable field") }}',"x-component":"ArrayItems.Addition","x-component-props":{className:(0,n.css)(k())}}}}}}}},T=d(953),_="action-export";function F(){return(0,T.useTranslation)([_,"client"],{nsMode:"fallback"})}function M(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 R(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var D=function(){var e,t,a,l,c,u,s=(0,i.useField)(),p=(0,i.useFieldSchema)(),f=F().t,d=(0,n.useDesignable)().dn,m=function(e){if(Array.isArray(e))return e}(e=(0,r.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 M(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 M(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=m[0],y=m[1],v=C().schema;return(0,r.useEffect)(function(){y(v)},[s.address,null==p||null==(t=p["x-action-settings"])?void 0:t.exportSettings]),o().createElement(n.GeneralSchemaDesigner,{disableInitializer:!0},o().createElement(n.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,d.emit("patch",{schema:(R(t={},"x-uid",p["x-uid"]),R(t,"title",n),R(t,"x-component-props",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){R(e,t,n[t])})}return e}({},p["x-component-props"])),t)}),d.refresh()}}),o().createElement(n.SchemaSettingsActionModalItem,{title:f("Exportable fields"),schema:b,initialValues:{exportSettings:null==p||null==(u=p["x-action-settings"])?void 0:u.exportSettings},scope:{t:f},components:{ArrayItems:I.ArrayItems},onSubmit:function(e){var t,n=e.exportSettings;p["x-action-settings"].exportSettings=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}}),d.emit("patch",{schema:(R(t={},"x-uid",p["x-uid"]),R(t,"x-action-settings",p["x-action-settings"]),t)}),d.refresh()}}),o().createElement(n.SchemaSettingsDivider,null),o().createElement(n.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:function(e){return"Space"===e["x-component"]||e["x-component"].endsWith("ActionBar")},confirm:{title:f("Delete action")}}))},B=function(e){return o().createElement(n.SchemaComponentOptions,{components:{ExportActionInitializer:A,ExportDesigner:D},scope:{useExportAction:$}},e.children)},q=d(773),L=d.n(q),U=d(574),z=d(59);function N(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)}var $=function(){var e,t=(0,n.useBlockRequestContext)(),o=t.service,a=t.props,l=(0,n.useDataBlockResource)(),c=(0,n.useTableBlockContext)().params,u=(0,n.useCurrentAppInfo)(),s=null==a?void 0:a.params.filter,p=(0,i.useFieldSchema)(),f=(0,n.useCompile)(),d=(0,n.useCollectionManager_deprecated)().getCollectionJoinField,m=(0,n.useCollection_deprecated)(),b=m.name,y=m.title,v=F().t,h=z.App.useApp().modal,g=(null==(e=o.params[0])?void 0:e.filter)||{},x=(0,i.useField)(),S=(0,r.useMemo)(function(){var e;return(null==u||null==(e=u.data)?void 0:e.exportLimit)?u.data.exportLimit:2e3},[u]);return{onClick:function(){var e;return(e=function(){var e,t,r,i,a;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(u){switch(u.label){case 0:return x.data=x.data||{},[4,h.confirm({title:v("Export"),content:v("Export warning",{limit:S}),okText:v("Start export")})];case 1:if(!u.sent())return[2];return x.data.loading=!0,(i=L().cloneDeep(null!=(e=null==p?void 0:p["x-action-settings"])?e:{}).exportSettings).forEach(function(e){var t,n,r=null!=(t=d("".concat(b,".").concat(e.dataIndex.join("."))))?t:{},o=r.uiSchema;r.interface,e.enum=null==o||null==(n=o.enum)?void 0:n.map(function(e){return{value:e.value,label:e.label}}),e.enum||(null==o?void 0:o.type)!=="boolean"||(e.enum=[{value:!0,label:v("Yes")},{value:!1,label:v("No")}]),e.defaultTitle=null==o?void 0:o.title}),[4,l.export({title:f(y),appends:null==(r=o.params[0])||null==(t=r.appends)?void 0:t.join(),filter:(0,n.mergeFilter)([g,s]),sort:null==c?void 0:c.sort,values:{columns:f(i)}},{responseType:"blob"})];case 2:return a=new Blob([u.sent().data],{type:"application/x-xls"}),x.data.loading=!1,(0,U.saveAs)(a,"".concat(f(y),".xlsx")),[2]}})},function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){N(i,r,o,a,l,"next",e)}function l(e){N(i,r,o,a,l,"throw",e)}a(void 0)})})()}}},H=d(694),G=d(485),K=d(477);function V(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}var W=function(e){return Array.isArray(e)&&e.length?e.map(function(e){var t;return null!=(t=null==e?void 0:e.name)?t:e}):null},X=function(e){var t;return function(e){if(Array.isArray(e))return V(e)}(t=e.getRootOptions())||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(t)||function(e){if(e){if("string"==typeof e)return V(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 V(e,void 0)}}(t)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()};function Y(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 l=e[i](a),c=l.value}catch(e){n(e);return}l.done?t(c):Promise.resolve(c).then(r,o)}function Q(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Z(e){return(Z=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function ee(e,t){return(ee=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function et(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function en(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(en=function(){return!!e})()}function er(){var e=et(["\n width: 100%;\n & .ant-space-item:nth-child(2),\n & .ant-space-item:nth-child(3) {\n flex: 1;\n }\n "]);return er=function(){return e},e}function eo(){var e=et(["\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 eo=function(){return e},e}var ei={label:"title",value:"name",children:"children"},ea=function(e){var t,n,r,i=e.optionsCache,a=e.value,l=e.onChange,c=e.onDropdownVisibleChange,u=function(e,t){if(null==e)return{};var n,r,o,i={};if("u">typeof Reflect&&Reflect.ownKeys){for(o=0,n=Reflect.ownKeys(Object(e));o<n.length;o++)r=n[o],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(i[r]=e[r]);return i}if(i=function(e,t){if(null==e)return{};var n,r,o={},i=Object.getOwnPropertyNames(e);for(r=0;r<i.length;r++)n=i[r],!(t.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n]);return o}(e,t),Object.getOwnPropertySymbols)for(o=0,n=Object.getOwnPropertySymbols(e);o<n.length;o++)r=n[o],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(i[r]=e[r]);return i}(e,["optionsCache","value","onChange","onDropdownVisibleChange"]),s=function(e){if(Array.isArray(e))return e}(t=o().useState(0))||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}}(t)||function(e){if(e){if("string"==typeof e)return Y(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 Y(e,2)}}(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.")}(),p=(s[0],s[1]),f=o().useMemo(function(){return W(a)},[a]),d=o().useCallback(function(){p(function(e){return e+1})},[]),m=o().useCallback(function(e){return Array.isArray(e)?e.map(function(e){var t;return null!=(t=null==e?void 0:e.name)?t:e}).join("."):""},[]);i.preloadPath(f);var b=X(i),y=o().useCallback(function(e){var t=null==e?void 0:e[e.length-1];!t||t.isLeaf||t.children||(t.loading=!0,i.loadChildren(t),t.loading=!1,d())},[i,d]),v=o().useCallback(function(e){e&&d(),null==c||c(e)},[c,d]),h=o().useCallback(function(e){null==l||l(W(e))},[l]),g=o().useCallback(function(e,t){var n=m(a),r=n?n.split(".").length:0;return(null==e?void 0:e.length)&&(!r||e.length>=r)?e.join(" / "):n?n.replace(/\./g," / "):null==t?void 0:t.map(function(e){return(null==e?void 0:e.title)||(null==e?void 0:e.name)}).join(" / ")},[m,a]);return o().createElement(z.Cascader,(n=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){Q(e,t,n[t])})}return e}({},u),r=r={value:f||void 0,fieldNames:ei,options:b,loadData:y,onChange:h,onDropdownVisibleChange:v,displayRender:g},Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(r)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(r)).forEach(function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(r,e))}),n))},el=function(e,t){return O(e,function(e){var n;return t(null==e||null==(n=e.uiSchema)?void 0:n.title)||e.name},function(e){return e.targetCollection&&e.targetCollection.getFields()||[]})},ec=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=Z(t),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,en()?Reflect.construct(t,r||[],Z(this).constructor):t.apply(this,r)),"defaultProps",{title:(0,H.escapeT)("Export"),type:"default",icon:"clouddownloadoutlined"}),e}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&ee(n,e),t=[{key:"getAclActionName",value:function(){return"export"}}],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}(G.ActionModel);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,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}Q(ec,"scene",G.ActionSceneEnum.collection),ec.define({label:(0,H.escapeT)("Export"),sort:1030}),ec.registerFlow({key:"exportSettings",on:"click",steps:{confirm:{use:"confirm",hideInSettings:!0,defaultParams:{enable:!0,title:(0,H.escapeT)("Export"),content:(0,H.escapeT)("Export warning",{ns:_,limit:2e3})}},export:{handler:function(e,t){var n;return(n=function(){var t,n,r,o,i,a,l,c,u,s;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(p){switch(p.label){case 0:return t=e.model.getProps().exportSettings,r=(n=e.model.context.blockModel).resource,i=(o=n.collection).title,a=o.fields,l=o.filterTargetKey,u=(c=r.getSelectedRows()).length>0?Q({},l,e.blockModel.collection.getFilterByTK(c)):r.getFilter(),Array.isArray(l)&&l.length>1&&(u={$or:e.blockModel.collection.getFilterByTK(c)}),t.forEach(function(t){var n,r,o=null!=(n=a.get(t.dataIndex[0]))?n:{},i=o.uiSchema;o.interface,t.enum=null==i||null==(r=i.enum)?void 0:r.map(function(e){return{value:e.value,label:e.label}}),t.enum||(null==i?void 0:i.type)!=="boolean"||(t.enum=[{value:!0,label:e.t("Yes")},{value:!1,label:e.t("No")}]),t.defaultTitle=e.t(null==i?void 0:i.title)}),[4,r.runAction("export",{data:{columns:t},responseType:"blob",params:{title:e.t(i),appends:r.getAppends(),sort:r.getSort(),filter:u}})];case 1:return s=new Blob([p.sent()],{type:"application/x-xls"}),(0,U.saveAs)(s,"".concat(e.t(i),".xlsx")),[2]}})},function(){var e=this,t=arguments;return new Promise(function(r,o){var i=n.apply(e,t);function a(e){J(i,r,o,a,l,"next",e)}function l(e){J(i,r,o,a,l,"throw",e)}a(void 0)})})()}}}}),ec.registerFlow({key:"exportActionSetting",title:(0,H.escapeT)("Export settings",{ns:_}),steps:{exportableFields:{title:(0,H.escapeT)("Exportable fields"),uiSchema:function(e){var t=el(e.model.context.blockModel.collection.getFields(),e.t);return{exportSettings:{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)(er())},properties:{sort:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.SortHandle"},dataIndex:{type:"array","x-decorator":"FormItem","x-component":ea,required:!0,"x-component-props":{changeOnSelect:!1,optionsCache:t}},title:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:'{{ t("Custom column title") }}'}},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:'{{ t("Add exportable field") }}',"x-component":"ArrayItems.Addition","x-component-props":{className:(0,K.css)(eo())}}}}}},defaultParams:function(e){var t;return{exportSettings:null==(t=e.model.context.blockModel.collection.getFields())?void 0:t.filter(function(e){return!e.isAssociationField()&&e.options.interface}).map(function(e){return{dataIndex:[e.name]}})}},handler:function(e,t){var n=t.exportSettings,r=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}});e.model.setProps("exportSettings",r)}}}});var ep=new n.SchemaSettings({name:"actionSettings:export",items:[{name:"editButton",Component:n.ButtonEditor,useComponentProps:function(){return(0,n.useSchemaToolbar)().buttonEditorProps}},{name:"linkageRules",Component:n.SchemaSettingsLinkageRules,useComponentProps:function(){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){es(e,t,n[t])})}return e}({},(0,n.useSchemaToolbar)().linkageRulesProps)}},{name:"exportableFields",type:"actionModal",useComponentProps:function(){var e,t,o,a=(0,i.useField)(),l=(0,i.useFieldSchema)(),c=(0,T.useTranslation)().t,u=(0,n.useDesignable)().dn,s=function(e){if(Array.isArray(e))return e}(e=(0,r.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 eu(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 eu(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],d=C().schema;return(0,r.useEffect)(function(){f(d)},[a.address,null==l||null==(t=l["x-action-settings"])?void 0:t.exportSettings]),{title:c("Exportable fields"),schema:p,initialValues:{exportSettings:null==l||null==(o=l["x-action-settings"])?void 0:o.exportSettings},components:{ArrayItems:I.ArrayItems},onSubmit:function(e){var t,n=e.exportSettings;l["x-action-settings"].exportSettings=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}}),u.emit("patch",{schema:(es(t={},"x-uid",l["x-uid"]),es(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,T.useTranslation)().t)("Delete action")}}}}]});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 ed(e,t,n){return(ed=ev()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&eb(o,n.prototype),o}).apply(null,arguments)}function em(e){return(em=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 ey(e){var t="function"==typeof Map?new Map:void 0;return(ey=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 ed(e,arguments,em(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),eb(n,e)})(e)}function ev(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(ev=function(){return!!e})()}var eh=function(e){var t;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=em(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,ev()?Reflect.construct(e,t||[],em(this).constructor):e.apply(this,t))}return r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),e&&eb(r,e),t=[{key:"load",value:function(){var e;return(e=function(){var e,t;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(B),e={title:"{{t('Export')}}",Component:"ExportActionInitializer",schema:{"x-align":"right","x-decorator":"ACLActionProvider","x-acl-action-props":{skipScopeCheck:!0}},useVisible:function(){return(0,n.useActionAvailable)("export")}},null==(t=this.app.schemaInitializerManager.get("table:configureActions"))||t.add("enableActions.export",e),this.app.schemaInitializerManager.addItem("gantt:configureActions","enableActions.export",e),this.app.schemaSettingsManager.add(ep),this.app.flowEngine.registerModels({ExportActionModel:ec}),[2]})},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)})}).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,t),r}(ey(n.Plugin)),eg=eh}(),h}()});
@@ -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("@emotion/css"),require("@nocobase/client-v2"),require("react"),require("antd"),require("@nocobase/flow-engine")):"function"==typeof define&&define.amd?define("@nocobase/plugin-action-export/client-v2",["@emotion/css","@nocobase/client-v2","react","antd","@nocobase/flow-engine"],t):"object"==typeof exports?exports["@nocobase/plugin-action-export/client-v2"]=t(require("@emotion/css"),require("@nocobase/client-v2"),require("react"),require("antd"),require("@nocobase/flow-engine")):e["@nocobase/plugin-action-export/client-v2"]=t(e["@emotion/css"],e["@nocobase/client-v2"],e.react,e.antd,e["@nocobase/flow-engine"])}(self,function(e,t,n,r,o){return function(){var i={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 f=i.URL||i.webkitURL,p=f.createObjectURL(e);o?o.location=p:location.href=p,o=null,setTimeout(function(){f.revokeObjectURL(p)},4e4)}});i.saveAs=l.saveAs=l,e.exports=l})?r.apply(t,[]):r)||(e.exports=o)},682:function(e,t,n){"use strict";n.r(t),n.d(t,{ExportActionModel:function(){return E}});var r=n(694),o=n(485),i=n(477),a=n(574),l=n(59),c=n(155),u=n.n(c),s=n(132),f="action-export";function p(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}var d=function(e){return Array.isArray(e)&&e.length?e.map(function(e){var t;return null!=(t=null==e?void 0:e.name)?t:e}):null},b=function(e){var t;return function(e){if(Array.isArray(e))return p(e)}(t=e.getRootOptions())||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(t)||function(e){if(e){if("string"==typeof e)return p(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 p(e,void 0)}}(t)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()};function y(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 v(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 m(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function h(e){return(h=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function g(e,t){return(g=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function w(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function O(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(O=function(){return!!e})()}function x(){var e=w(["\n width: 100%;\n & .ant-space-item:nth-child(2),\n & .ant-space-item:nth-child(3) {\n flex: 1;\n }\n "]);return x=function(){return e},e}function j(){var e=w(["\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 j=function(){return e},e}var S={label:"title",value:"name",children:"children"},A=function(e){var t,n,r,o=e.optionsCache,i=e.value,a=e.onChange,c=e.onDropdownVisibleChange,s=function(e,t){if(null==e)return{};var n,r,o,i={};if("u">typeof Reflect&&Reflect.ownKeys){for(o=0,n=Reflect.ownKeys(Object(e));o<n.length;o++)r=n[o],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(i[r]=e[r]);return i}if(i=function(e,t){if(null==e)return{};var n,r,o={},i=Object.getOwnPropertyNames(e);for(r=0;r<i.length;r++)n=i[r],!(t.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n]);return o}(e,t),Object.getOwnPropertySymbols)for(o=0,n=Object.getOwnPropertySymbols(e);o<n.length;o++)r=n[o],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(i[r]=e[r]);return i}(e,["optionsCache","value","onChange","onDropdownVisibleChange"]),f=function(e){if(Array.isArray(e))return e}(t=u().useState(function(){return b(o)}))||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}}(t)||function(e){if(e){if("string"==typeof e)return y(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 y(e,2)}}(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.")}(),p=f[0],v=f[1],h=u().useRef(null),g=u().useMemo(function(){return d(i)||void 0},[i]),w=u().useCallback(function(){v(b(o))},[o]);u().useEffect(function(){w()},[w]);var O=u().useCallback(function(e){return Array.isArray(e)?e.map(function(e){var t;return null!=(t=null==e?void 0:e.name)?t:e}).join("."):""},[]),x=u().useCallback(function(e){var t=null==e?void 0:e[e.length-1];!t||t.isLeaf||t.children||(t.loading=!0,o.loadChildren(t),t.loading=!1,w())},[o,w]),j=u().useCallback(function(){var e=O(i);e&&h.current!==e&&(h.current=e,o.preloadPath(i)&&w())},[O,o,w,i]),A=u().useCallback(function(e){e&&j(),null==c||c(e)},[c,j]),P=u().useCallback(function(e){null==a||a(d(e))},[a]),E=u().useCallback(function(e,t){var n=O(i),r=n?n.split(".").length:0;return(null==e?void 0:e.length)&&(!r||e.length>=r)?e.join(" / "):n?n.replace(/\./g," / "):null==t?void 0:t.map(function(e){return(null==e?void 0:e.title)||(null==e?void 0:e.name)}).join(" / ")},[O,i]);return u().createElement(l.Cascader,(n=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){m(e,t,n[t])})}return e}({},s),r=r={value:g,fieldNames:S,options:p,loadData:x,onChange:P,onDropdownVisibleChange:A,displayRender:E},Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(r)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(r)).forEach(function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(r,e))}),n))},P=function(e,t){return(0,s.Fv)(e,function(e){var n;return t(null==e||null==(n=e.uiSchema)?void 0:n.title)||e.name},function(e){return e.targetCollection&&e.targetCollection.getFields()||[]})},E=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,o;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return t=n,o=arguments,t=h(t),m(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,O()?Reflect.construct(t,o||[],h(this).constructor):t.apply(this,o)),"defaultProps",{title:(0,r.escapeT)("Export"),type:"default",icon:"clouddownloadoutlined"}),e}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&g(n,e),t=[{key:"getAclActionName",value:function(){return"export"}}],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}(o.ActionModel);m(E,"scene",o.ActionSceneEnum.collection),E.define({label:(0,r.escapeT)("Export"),sort:1030}),E.registerFlow({key:"exportSettings",on:"click",steps:{confirm:{use:"confirm",hideInSettings:!0,defaultParams:{enable:!0,title:(0,r.escapeT)("Export"),content:(0,r.escapeT)("Export warning",{ns:f,limit:2e3})}},export:{handler:function(e,t){var n;return(n=function(){var t,n,r,o,i,l,c,u,s,f;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(p){switch(p.label){case 0:return t=e.model.getProps().exportSettings,r=(n=e.model.context.blockModel).resource,i=(o=n.collection).title,l=o.fields,c=o.filterTargetKey,s=(u=r.getSelectedRows()).length>0?m({},c,e.blockModel.collection.getFilterByTK(u)):r.getFilter(),Array.isArray(c)&&c.length>1&&(s={$or:e.blockModel.collection.getFilterByTK(u)}),t.forEach(function(t){var n,r,o=null!=(n=l.get(t.dataIndex[0]))?n:{},i=o.uiSchema;o.interface,t.enum=null==i||null==(r=i.enum)?void 0:r.map(function(e){return{value:e.value,label:e.label}}),t.enum||(null==i?void 0:i.type)!=="boolean"||(t.enum=[{value:!0,label:e.t("Yes")},{value:!1,label:e.t("No")}]),t.defaultTitle=e.t(null==i?void 0:i.title)}),[4,r.runAction("export",{data:{columns:t},responseType:"blob",params:{title:e.t(i),appends:r.getAppends(),sort:r.getSort(),filter:s}})];case 1:return f=new Blob([p.sent()],{type:"application/x-xls"}),(0,a.saveAs)(f,"".concat(e.t(i),".xlsx")),[2]}})},function(){var e=this,t=arguments;return new Promise(function(r,o){var i=n.apply(e,t);function a(e){v(i,r,o,a,l,"next",e)}function l(e){v(i,r,o,a,l,"throw",e)}a(void 0)})})()}}}}),E.registerFlow({key:"exportActionSetting",title:(0,r.escapeT)("Export settings",{ns:f}),steps:{exportableFields:{title:(0,r.escapeT)("Exportable fields"),uiSchema:function(e){var t=P(e.model.context.blockModel.collection.getFields(),e.t);return{exportSettings:{type:"array","x-component":"ArrayItems","x-decorator":"FormItem",items:{type:"object",properties:{space:{type:"void","x-component":"Space","x-component-props":{className:(0,i.css)(x())},properties:{sort:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.SortHandle"},dataIndex:{type:"array","x-decorator":"FormItem","x-component":A,required:!0,"x-component-props":{changeOnSelect:!1,optionsCache:t}},title:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:'{{ t("Custom column title") }}'}},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:'{{ t("Add exportable field") }}',"x-component":"ArrayItems.Addition","x-component-props":{className:(0,i.css)(j())}}}}}},defaultParams:function(e){var t;return{exportSettings:null==(t=e.model.context.blockModel.collection.getFields())?void 0:t.filter(function(e){return!e.isAssociationField()&&e.options.interface}).map(function(e){return{dataIndex:[e.name]}})}},handler:function(e,t){var n=t.exportSettings,r=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}});e.model.setProps("exportSettings",r)}}}})},132:function(e,t,n){"use strict";function r(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 o(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}function i(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}n.d(t,{Fv:function(){return g},xD:function(){return v}});var a,l=["hasMany","belongsToMany","belongsToArray"],c=((function(e){if(Array.isArray(e))return r(e)})(a=["hasOne","belongsTo"])||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(a)||function(e){if(e){if("string"==typeof e)return r(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 r(e,void 0)}}(a)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()).concat(["hasMany","belongsToMany","belongsToArray"]),u=new WeakMap,s=function(e){return(null==e?void 0:e.target)&&c.includes(e.type)},f=function(e){return(null==e?void 0:e.target)&&l.includes(e.type)},p=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}},d=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=s(e),a=i(o({},p(e,t)),{isLeaf:!r});return u.set(a,{field:e,relationDepth:r?n:0}),a},b=function(e,t,n){return!(n>=2||f(e)&&f(t))},y=function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;if(!(null==e?void 0:e.interface))return null;if(!s(e))return p(e,t);var a=(n(e)||[]).map(function(o){return s(o)?b(e,o,r)?y(o,t,n,r+1):null:y(o,t,n)}).filter(Boolean);return a.length?i(o({},p(e,t)),{children:a}):p(e,t,!0)},v=function(e,t,n){return(e||[]).map(function(e){return y(e,t,n,+!!s(e))}).filter(Boolean)},m=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=n.parentField,o=n.parentRelationDepth,i=void 0===o?0:o;return(e||[]).map(function(e){return!(null==e?void 0:e.interface)||r&&s(e)&&!b(r,e,i)?null:d(e,t,s(e)?i+1:0)}).filter(Boolean)},h=function(e,t,n){var r=e&&(void 0===e?"undefined":e&&"u">typeof Symbol&&e.constructor===Symbol?"symbol":typeof e)=="object"?u.get(e):null,o=null==r?void 0:r.field;return s(o)?m(n(o)||[],t,{parentField:o,parentRelationDepth:(null==r?void 0:r.relationDepth)||1}):[]},g=function(e,t,n){var r=m(e,t),o=function(e){if(!e||e.isLeaf)return[];if(e.children)return e.children;var r=h(e,t,n);return r.length?e.children=r:(e.isLeaf=!0,e.disabled=!0,e.children=[]),e.children};return{getRootOptions:function(){return r},loadChildren:o,preloadPath:function(e){if(!Array.isArray(e)||e.length<=1)return!1;for(var t=!1,n=r,i=0;i<e.length-1&&"break"!==function(r){var i,a,l=null!=(i=null==(a=e[r])?void 0:a.name)?i:e[r],c=n.find(function(e){return(null==e?void 0:e.name)===l});if(!c||c.isLeaf)return"break";var u=!!c.children;n=o(c),u||(t=!0)}(i);i++);return t}}}},477:function(t){"use strict";t.exports=e},485:function(e){"use strict";e.exports=t},694:function(e){"use strict";e.exports=o},59:function(e){"use strict";e.exports=r},155:function(e){"use strict";e.exports=n}},a={};function l(e){var t=a[e];if(void 0!==t)return t.exports;var n=a[e]={exports:{}};return i[e].call(n.exports,n,n.exports,l),n.exports}l.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return l.d(t,{a:t}),t},l.d=function(e,t){for(var n in t)l.o(t,n)&&!l.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},l.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),l.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},l.r=function(e){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},l.g.importScripts&&(c=l.g.location+"");var c,u=l.g.document;if(!c&&u&&(u.currentScript&&"SCRIPT"===u.currentScript.tagName.toUpperCase()&&(c=u.currentScript.src),!c)){var s=u.getElementsByTagName("script");if(s.length)for(var f=s.length-1;f>-1&&(!c||!/^http(s?):/.test(c));)c=s[f--].src}if(!c)throw Error("Automatic publicPath is not supported in this browser");l.p=c.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/");var p={};return!function(){"use strict";var e="",t="u">typeof document?document.currentScript:null;if(t&&t.src){var n=t.src.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"");n.indexOf("/static/plugins/@nocobase/plugin-action-export/dist/client-v2/")>=0&&(e=n.replace(/\/[^\/]+$/,"/"))}if(!e){var r=window.__webpack_public_path__||"";r&&("/"!==r.charAt(r.length-1)&&(r+="/"),e=r+"static/plugins/@nocobase/plugin-action-export/dist/client-v2/")}if(!e){var o=window.__nocobase_modern_client_prefix__||"v",i="/"+(o=String(o).replace(/^\/+|\/+$/g,"")||"v")+"/";if(!(e=window.__nocobase_public_path__||"")&&window.location&&window.location.pathname){var a=window.location.pathname||"/",c=a.indexOf(i);e=c>=0?a.slice(0,c+1):"/"}e&&(e=e.replace(RegExp("/"+o+"/?$"),"/")),e||(e="/"),"/"!==e.charAt(e.length-1)&&(e+="/"),e+="static/plugins/@nocobase/plugin-action-export/dist/client-v2/"}l.p=e}(),!function(){"use strict";l.r(p),l.d(p,{ExportActionModel:function(){return t.ExportActionModel},PluginActionExportClient:function(){return s},buildExportFieldOptions:function(){return n.xD}});var e=l(485),t=l(682),n=l(132);function r(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 o(e,t,n){return(o=u()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&a(o,n.prototype),o}).apply(null,arguments)}function i(e){return(i=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function a(e,t){return(a=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function c(e){var t="function"==typeof Map?new Map:void 0;return(c=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 o(e,arguments,i(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),a(n,e)})(e)}function u(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(u=function(){return!!e})()}var s=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=i(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,u()?Reflect.construct(e,t||[],i(this).constructor):e.apply(this,t))}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&a(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.registerModelLoaders({ExportActionModel:{extends:"ActionModel",loader:function(){return Promise.resolve().then(l.bind(l,682))}}}),[2]})},function(){var t=this,n=arguments;return new Promise(function(o,i){var a=e.apply(t,n);function l(e){r(a,o,i,l,c,"next",e)}function c(e){r(a,o,i,l,c,"throw",e)}l(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}(c(e.Plugin));p.default=s}(),p}()});
10
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@emotion/css"),require("@nocobase/client-v2"),require("react"),require("antd"),require("@nocobase/flow-engine")):"function"==typeof define&&define.amd?define("@nocobase/plugin-action-export/client-v2",["@emotion/css","@nocobase/client-v2","react","antd","@nocobase/flow-engine"],t):"object"==typeof exports?exports["@nocobase/plugin-action-export/client-v2"]=t(require("@emotion/css"),require("@nocobase/client-v2"),require("react"),require("antd"),require("@nocobase/flow-engine")):e["@nocobase/plugin-action-export/client-v2"]=t(e["@emotion/css"],e["@nocobase/client-v2"],e.react,e.antd,e["@nocobase/flow-engine"])}(self,function(e,t,n,r,o){return function(){var i={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 f=i.URL||i.webkitURL,p=f.createObjectURL(e);o?o.location=p:location.href=p,o=null,setTimeout(function(){f.revokeObjectURL(p)},4e4)}});i.saveAs=l.saveAs=l,e.exports=l})?r.apply(t,[]):r)||(e.exports=o)},682:function(e,t,n){"use strict";n.r(t),n.d(t,{ExportActionModel:function(){return E}});var r=n(694),o=n(485),i=n(477),a=n(574),l=n(59),c=n(155),u=n.n(c),s=n(132),f="action-export";function p(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}var d=function(e){return Array.isArray(e)&&e.length?e.map(function(e){var t;return null!=(t=null==e?void 0:e.name)?t:e}):null},b=function(e){var t;return function(e){if(Array.isArray(e))return p(e)}(t=e.getRootOptions())||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(t)||function(e){if(e){if("string"==typeof e)return p(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 p(e,void 0)}}(t)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()};function y(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 v(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 m(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function h(e){return(h=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function g(e,t){return(g=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function w(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function O(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(O=function(){return!!e})()}function x(){var e=w(["\n width: 100%;\n & .ant-space-item:nth-child(2),\n & .ant-space-item:nth-child(3) {\n flex: 1;\n }\n "]);return x=function(){return e},e}function j(){var e=w(["\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 j=function(){return e},e}var S={label:"title",value:"name",children:"children"},A=function(e){var t,n,r,o=e.optionsCache,i=e.value,a=e.onChange,c=e.onDropdownVisibleChange,s=function(e,t){if(null==e)return{};var n,r,o,i={};if("u">typeof Reflect&&Reflect.ownKeys){for(o=0,n=Reflect.ownKeys(Object(e));o<n.length;o++)r=n[o],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(i[r]=e[r]);return i}if(i=function(e,t){if(null==e)return{};var n,r,o={},i=Object.getOwnPropertyNames(e);for(r=0;r<i.length;r++)n=i[r],!(t.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n]);return o}(e,t),Object.getOwnPropertySymbols)for(o=0,n=Object.getOwnPropertySymbols(e);o<n.length;o++)r=n[o],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(i[r]=e[r]);return i}(e,["optionsCache","value","onChange","onDropdownVisibleChange"]),f=function(e){if(Array.isArray(e))return e}(t=u().useState(0))||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}}(t)||function(e){if(e){if("string"==typeof e)return y(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 y(e,2)}}(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.")}(),p=(f[0],f[1]),v=u().useMemo(function(){return d(i)},[i]),h=u().useCallback(function(){p(function(e){return e+1})},[]),g=u().useCallback(function(e){return Array.isArray(e)?e.map(function(e){var t;return null!=(t=null==e?void 0:e.name)?t:e}).join("."):""},[]);o.preloadPath(v);var w=b(o),O=u().useCallback(function(e){var t=null==e?void 0:e[e.length-1];!t||t.isLeaf||t.children||(t.loading=!0,o.loadChildren(t),t.loading=!1,h())},[o,h]),x=u().useCallback(function(e){e&&h(),null==c||c(e)},[c,h]),j=u().useCallback(function(e){null==a||a(d(e))},[a]),A=u().useCallback(function(e,t){var n=g(i),r=n?n.split(".").length:0;return(null==e?void 0:e.length)&&(!r||e.length>=r)?e.join(" / "):n?n.replace(/\./g," / "):null==t?void 0:t.map(function(e){return(null==e?void 0:e.title)||(null==e?void 0:e.name)}).join(" / ")},[g,i]);return u().createElement(l.Cascader,(n=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){m(e,t,n[t])})}return e}({},s),r=r={value:v||void 0,fieldNames:S,options:w,loadData:O,onChange:j,onDropdownVisibleChange:x,displayRender:A},Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(r)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(r)).forEach(function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(r,e))}),n))},P=function(e,t){return(0,s.Fv)(e,function(e){var n;return t(null==e||null==(n=e.uiSchema)?void 0:n.title)||e.name},function(e){return e.targetCollection&&e.targetCollection.getFields()||[]})},E=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,o;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return t=n,o=arguments,t=h(t),m(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,O()?Reflect.construct(t,o||[],h(this).constructor):t.apply(this,o)),"defaultProps",{title:(0,r.escapeT)("Export"),type:"default",icon:"clouddownloadoutlined"}),e}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&g(n,e),t=[{key:"getAclActionName",value:function(){return"export"}}],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}(o.ActionModel);m(E,"scene",o.ActionSceneEnum.collection),E.define({label:(0,r.escapeT)("Export"),sort:1030}),E.registerFlow({key:"exportSettings",on:"click",steps:{confirm:{use:"confirm",hideInSettings:!0,defaultParams:{enable:!0,title:(0,r.escapeT)("Export"),content:(0,r.escapeT)("Export warning",{ns:f,limit:2e3})}},export:{handler:function(e,t){var n;return(n=function(){var t,n,r,o,i,l,c,u,s,f;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(p){switch(p.label){case 0:return t=e.model.getProps().exportSettings,r=(n=e.model.context.blockModel).resource,i=(o=n.collection).title,l=o.fields,c=o.filterTargetKey,s=(u=r.getSelectedRows()).length>0?m({},c,e.blockModel.collection.getFilterByTK(u)):r.getFilter(),Array.isArray(c)&&c.length>1&&(s={$or:e.blockModel.collection.getFilterByTK(u)}),t.forEach(function(t){var n,r,o=null!=(n=l.get(t.dataIndex[0]))?n:{},i=o.uiSchema;o.interface,t.enum=null==i||null==(r=i.enum)?void 0:r.map(function(e){return{value:e.value,label:e.label}}),t.enum||(null==i?void 0:i.type)!=="boolean"||(t.enum=[{value:!0,label:e.t("Yes")},{value:!1,label:e.t("No")}]),t.defaultTitle=e.t(null==i?void 0:i.title)}),[4,r.runAction("export",{data:{columns:t},responseType:"blob",params:{title:e.t(i),appends:r.getAppends(),sort:r.getSort(),filter:s}})];case 1:return f=new Blob([p.sent()],{type:"application/x-xls"}),(0,a.saveAs)(f,"".concat(e.t(i),".xlsx")),[2]}})},function(){var e=this,t=arguments;return new Promise(function(r,o){var i=n.apply(e,t);function a(e){v(i,r,o,a,l,"next",e)}function l(e){v(i,r,o,a,l,"throw",e)}a(void 0)})})()}}}}),E.registerFlow({key:"exportActionSetting",title:(0,r.escapeT)("Export settings",{ns:f}),steps:{exportableFields:{title:(0,r.escapeT)("Exportable fields"),uiSchema:function(e){var t=P(e.model.context.blockModel.collection.getFields(),e.t);return{exportSettings:{type:"array","x-component":"ArrayItems","x-decorator":"FormItem",items:{type:"object",properties:{space:{type:"void","x-component":"Space","x-component-props":{className:(0,i.css)(x())},properties:{sort:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.SortHandle"},dataIndex:{type:"array","x-decorator":"FormItem","x-component":A,required:!0,"x-component-props":{changeOnSelect:!1,optionsCache:t}},title:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:'{{ t("Custom column title") }}'}},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:'{{ t("Add exportable field") }}',"x-component":"ArrayItems.Addition","x-component-props":{className:(0,i.css)(j())}}}}}},defaultParams:function(e){var t;return{exportSettings:null==(t=e.model.context.blockModel.collection.getFields())?void 0:t.filter(function(e){return!e.isAssociationField()&&e.options.interface}).map(function(e){return{dataIndex:[e.name]}})}},handler:function(e,t){var n=t.exportSettings,r=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}});e.model.setProps("exportSettings",r)}}}})},132:function(e,t,n){"use strict";function r(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 o(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}function i(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}n.d(t,{Fv:function(){return g},xD:function(){return v}});var a,l=["hasMany","belongsToMany","belongsToArray"],c=((function(e){if(Array.isArray(e))return r(e)})(a=["hasOne","belongsTo"])||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(a)||function(e){if(e){if("string"==typeof e)return r(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 r(e,void 0)}}(a)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()).concat(["hasMany","belongsToMany","belongsToArray"]),u=new WeakMap,s=function(e){return(null==e?void 0:e.target)&&c.includes(e.type)},f=function(e){return(null==e?void 0:e.target)&&l.includes(e.type)},p=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}},d=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=s(e),a=i(o({},p(e,t)),{isLeaf:!r});return u.set(a,{field:e,relationDepth:r?n:0}),a},b=function(e,t,n){return!(n>=2||f(e)&&f(t))},y=function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;if(!(null==e?void 0:e.interface))return null;if(!s(e))return p(e,t);var a=(n(e)||[]).map(function(o){return s(o)?b(e,o,r)?y(o,t,n,r+1):null:y(o,t,n)}).filter(Boolean);return a.length?i(o({},p(e,t)),{children:a}):p(e,t,!0)},v=function(e,t,n){return(e||[]).map(function(e){return y(e,t,n,+!!s(e))}).filter(Boolean)},m=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=n.parentField,o=n.parentRelationDepth,i=void 0===o?0:o;return(e||[]).map(function(e){return!(null==e?void 0:e.interface)||r&&s(e)&&!b(r,e,i)?null:d(e,t,s(e)?i+1:0)}).filter(Boolean)},h=function(e,t,n){var r=e&&(void 0===e?"undefined":e&&"u">typeof Symbol&&e.constructor===Symbol?"symbol":typeof e)=="object"?u.get(e):null,o=null==r?void 0:r.field;return s(o)?m(n(o)||[],t,{parentField:o,parentRelationDepth:(null==r?void 0:r.relationDepth)||1}):[]},g=function(e,t,n){var r=m(e,t),o=function(e){if(!e||e.isLeaf)return[];if(e.children)return e.children;var r=h(e,t,n);return r.length?e.children=r:(e.isLeaf=!0,e.disabled=!0,e.children=[]),e.children};return{getRootOptions:function(){return r},loadChildren:o,preloadPath:function(e){if(!Array.isArray(e)||e.length<=1)return!1;for(var t=!1,n=r,i=0;i<e.length-1&&"break"!==function(r){var i,a,l=null!=(i=null==(a=e[r])?void 0:a.name)?i:e[r],c=n.find(function(e){return(null==e?void 0:e.name)===l});if(!c||c.isLeaf)return"break";var u=!!c.children;n=o(c),u||(t=!0)}(i);i++);return t}}}},477:function(t){"use strict";t.exports=e},485:function(e){"use strict";e.exports=t},694:function(e){"use strict";e.exports=o},59:function(e){"use strict";e.exports=r},155:function(e){"use strict";e.exports=n}},a={};function l(e){var t=a[e];if(void 0!==t)return t.exports;var n=a[e]={exports:{}};return i[e].call(n.exports,n,n.exports,l),n.exports}l.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return l.d(t,{a:t}),t},l.d=function(e,t){for(var n in t)l.o(t,n)&&!l.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},l.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),l.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},l.r=function(e){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},l.g.importScripts&&(c=l.g.location+"");var c,u=l.g.document;if(!c&&u&&(u.currentScript&&"SCRIPT"===u.currentScript.tagName.toUpperCase()&&(c=u.currentScript.src),!c)){var s=u.getElementsByTagName("script");if(s.length)for(var f=s.length-1;f>-1&&(!c||!/^http(s?):/.test(c));)c=s[f--].src}if(!c)throw Error("Automatic publicPath is not supported in this browser");l.p=c.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/");var p={};return!function(){"use strict";var e="",t="u">typeof document?document.currentScript:null;if(t&&t.src){var n=t.src.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"");n.indexOf("/static/plugins/@nocobase/plugin-action-export/dist/client-v2/")>=0&&(e=n.replace(/\/[^\/]+$/,"/"))}if(!e){var r=window.__webpack_public_path__||"";r&&("/"!==r.charAt(r.length-1)&&(r+="/"),e=r+"static/plugins/@nocobase/plugin-action-export/dist/client-v2/")}if(!e){var o=window.__nocobase_modern_client_prefix__||"v",i="/"+(o=String(o).replace(/^\/+|\/+$/g,"")||"v")+"/";if(!(e=window.__nocobase_public_path__||"")&&window.location&&window.location.pathname){var a=window.location.pathname||"/",c=a.indexOf(i);e=c>=0?a.slice(0,c+1):"/"}e&&(e=e.replace(RegExp("/"+o+"/?$"),"/")),e||(e="/"),"/"!==e.charAt(e.length-1)&&(e+="/"),e+="static/plugins/@nocobase/plugin-action-export/dist/client-v2/"}l.p=e}(),!function(){"use strict";l.r(p),l.d(p,{ExportActionModel:function(){return t.ExportActionModel},PluginActionExportClient:function(){return s},buildExportFieldOptions:function(){return n.xD}});var e=l(485),t=l(682),n=l(132);function r(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 o(e,t,n){return(o=u()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&a(o,n.prototype),o}).apply(null,arguments)}function i(e){return(i=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function a(e,t){return(a=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function c(e){var t="function"==typeof Map?new Map:void 0;return(c=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 o(e,arguments,i(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),a(n,e)})(e)}function u(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(u=function(){return!!e})()}var s=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=i(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,u()?Reflect.construct(e,t||[],i(this).constructor):e.apply(this,t))}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&a(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.registerModelLoaders({ExportActionModel:{extends:"ActionModel",loader:function(){return Promise.resolve().then(l.bind(l,682))}}}),[2]})},function(){var t=this,n=arguments;return new Promise(function(o,i){var a=e.apply(t,n);function l(e){r(a,o,i,l,c,"next",e)}function c(e){r(a,o,i,l,c,"throw",e)}l(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}(c(e.Plugin));p.default=s}(),p}()});
@@ -10,20 +10,20 @@
10
10
  module.exports = {
11
11
  "@formily/react": "2.3.7",
12
12
  "@formily/shared": "2.3.7",
13
- "@nocobase/client": "2.2.0-beta.8",
13
+ "@nocobase/client": "2.2.0-beta.9",
14
14
  "react": "18.2.0",
15
15
  "@formily/antd-v5": "1.2.3",
16
16
  "react-i18next": "11.18.6",
17
17
  "lodash": "4.18.1",
18
18
  "antd": "5.24.2",
19
- "@nocobase/flow-engine": "2.2.0-beta.8",
20
- "@nocobase/client-v2": "2.2.0-beta.8",
19
+ "@nocobase/flow-engine": "2.2.0-beta.9",
20
+ "@nocobase/client-v2": "2.2.0-beta.9",
21
21
  "@emotion/css": "11.13.0",
22
- "@nocobase/server": "2.2.0-beta.8",
23
- "@nocobase/logger": "2.2.0-beta.8",
24
- "@nocobase/actions": "2.2.0-beta.8",
25
- "@nocobase/database": "2.2.0-beta.8",
22
+ "@nocobase/server": "2.2.0-beta.9",
23
+ "@nocobase/logger": "2.2.0-beta.9",
24
+ "@nocobase/actions": "2.2.0-beta.9",
25
+ "@nocobase/database": "2.2.0-beta.9",
26
26
  "async-mutex": "0.5.0",
27
- "@nocobase/data-source-manager": "2.2.0-beta.8",
28
- "@nocobase/utils": "2.2.0-beta.8"
27
+ "@nocobase/data-source-manager": "2.2.0-beta.9",
28
+ "@nocobase/utils": "2.2.0-beta.9"
29
29
  };
@@ -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-29T01:53:10.270Z"}
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-07-06T02:54:57.163Z"}
@@ -10,6 +10,10 @@
10
10
  import { FindOptions, ICollection, ICollectionManager, IField, IModel, IRepository } from '@nocobase/data-source-manager';
11
11
  import EventEmitter from 'events';
12
12
  import { Logger } from '@nocobase/logger';
13
+ type FieldResolution = {
14
+ field?: IField;
15
+ collection?: ICollection;
16
+ };
13
17
  export type ExportOptions = {
14
18
  collectionManager: ICollectionManager;
15
19
  collection: ICollection;
@@ -45,11 +49,18 @@ declare abstract class BaseExporter<T extends ExportOptions = ExportOptions> ext
45
49
  private removePathAfterFileField;
46
50
  protected getAppendOptionsFromFields(ctx?: any): string[];
47
51
  protected getFindOptions(ctx?: any): any;
52
+ protected resolveFieldByDataIndex(dataIndex: Array<string>): FieldResolution;
48
53
  protected findFieldByDataIndex(dataIndex: Array<string>): IField;
49
54
  protected renderRawValue(value: any): any;
50
- protected getFieldRenderer(field?: IField, ctx?: any): (value: any) => any;
55
+ protected getFieldRenderer(field?: IField, ctx?: any, dataIndex?: Array<string>): (value: any) => any;
51
56
  protected formatValue(rowData: IModel, dataIndex: Array<string>, ctx?: any): any;
52
- protected normalizeRenderedValue(value: any, field?: IField): any;
57
+ protected normalizeRenderedValue(value: any, field?: IField, dataIndex?: Array<string>): any;
58
+ protected shouldExportAsText(field?: IField, dataIndex?: Array<string>): boolean;
59
+ protected isKeyField(field?: IField, dataIndex?: Array<string>): boolean;
60
+ protected getFieldCollection(field?: IField): ICollection | undefined;
61
+ protected isForeignKeyField(field?: IField): boolean;
62
+ protected normalizeTextCellValue(value: any): any;
63
+ protected shouldApplyTextCellFormat(value: any, field?: IField, dataIndex?: Array<string>): boolean;
53
64
  generateOutputPath(prefix?: string, ext?: string, destination?: string): string;
54
65
  }
55
66
  export { BaseExporter };
@@ -45,6 +45,54 @@ var import_path = __toESM(require("path"));
45
45
  var import_lodash = __toESM(require("lodash"));
46
46
  var import_database = require("@nocobase/database");
47
47
  var import_utils = require("@nocobase/utils");
48
+ const TEXT_EXPORT_INTERFACES = /* @__PURE__ */ new Set([
49
+ "attachmentURL",
50
+ "chinaRegion",
51
+ "code",
52
+ "input",
53
+ "textarea",
54
+ "richText",
55
+ "richtext",
56
+ "markdown",
57
+ "vditor",
58
+ "select",
59
+ "radio",
60
+ "radioGroup",
61
+ "multipleSelect",
62
+ "checkboxGroup",
63
+ "checkboxes",
64
+ "url",
65
+ "email",
66
+ "phone",
67
+ "password",
68
+ "color",
69
+ "icon",
70
+ "attachment"
71
+ ]);
72
+ const IDENTIFIER_EXPORT_INTERFACES = /* @__PURE__ */ new Set(["id", "uuid", "nanoid", "snowflakeId", "tableoid"]);
73
+ const NON_TEXT_EXPORT_INTERFACES = /* @__PURE__ */ new Set([
74
+ "boolean",
75
+ "checkbox",
76
+ "createdAt",
77
+ "date",
78
+ "datetime",
79
+ "datetimeNoTz",
80
+ "formula",
81
+ "integer",
82
+ "json",
83
+ "number",
84
+ "percent",
85
+ "time",
86
+ "unixTimestamp",
87
+ "updatedAt",
88
+ "sort",
89
+ "point",
90
+ "circle",
91
+ "polygon",
92
+ "lineString"
93
+ ]);
94
+ const TEXT_EXPORT_TYPES = /* @__PURE__ */ new Set(["string", "text", "uid", "uuid", "nanoid", "password"]);
95
+ const FORMULA_INJECTION_PREFIX_RE = /^\s*[=+\-@]/;
48
96
  class BaseExporter extends import_events.default {
49
97
  constructor(options) {
50
98
  super();
@@ -179,21 +227,26 @@ class BaseExporter extends import_events.default {
179
227
  }
180
228
  return findOptions;
181
229
  }
182
- findFieldByDataIndex(dataIndex) {
230
+ resolveFieldByDataIndex(dataIndex) {
183
231
  const { collection } = this.options;
184
- let currentField = collection.getField(dataIndex[0]);
232
+ let currentCollection = collection;
233
+ let currentField = currentCollection.getField(dataIndex[0]);
185
234
  if (dataIndex.length === 1) {
186
- return currentField;
235
+ return { field: currentField, collection: currentCollection };
187
236
  }
188
237
  let targetCollection = currentField.targetCollection();
189
238
  for (let i = 1; i < dataIndex.length; i++) {
239
+ currentCollection = targetCollection;
190
240
  currentField = targetCollection.getField(dataIndex[i]);
191
241
  const isLast = i === dataIndex.length - 1;
192
242
  if (!isLast && currentField instanceof import_database.RelationField) {
193
243
  targetCollection = currentField.targetCollection();
194
244
  }
195
245
  }
196
- return currentField;
246
+ return { field: currentField, collection: currentCollection };
247
+ }
248
+ findFieldByDataIndex(dataIndex) {
249
+ return this.resolveFieldByDataIndex(dataIndex).field;
197
250
  }
198
251
  renderRawValue(value) {
199
252
  if (typeof value === "object" && value !== null) {
@@ -201,23 +254,25 @@ class BaseExporter extends import_events.default {
201
254
  }
202
255
  return value;
203
256
  }
204
- getFieldRenderer(field, ctx) {
257
+ getFieldRenderer(field, ctx, dataIndex) {
205
258
  var _a;
206
259
  const InterfaceClass = this.options.collectionManager.getFieldInterface((_a = field == null ? void 0 : field.options) == null ? void 0 : _a.interface);
207
260
  if (!InterfaceClass) {
208
- return this.renderRawValue;
261
+ return (value) => {
262
+ return this.normalizeRenderedValue(this.renderRawValue(value), field, dataIndex);
263
+ };
209
264
  }
210
265
  const fieldInterface = new InterfaceClass(field == null ? void 0 : field.options);
211
266
  return (value) => {
212
267
  const renderedValue = fieldInterface.toString(value, ctx);
213
- return this.normalizeRenderedValue(renderedValue, field);
268
+ return this.normalizeRenderedValue(renderedValue, field, dataIndex);
214
269
  };
215
270
  }
216
271
  formatValue(rowData, dataIndex, ctx) {
217
272
  rowData = rowData.toJSON();
218
273
  const value = rowData[dataIndex[0]];
219
274
  const field = this.findFieldByDataIndex(dataIndex);
220
- const render = this.getFieldRenderer(field, ctx);
275
+ const render = this.getFieldRenderer(field, ctx, dataIndex);
221
276
  if (dataIndex.length > 1) {
222
277
  const deepValue = (0, import_deep_get.deepGet)(rowData, dataIndex);
223
278
  if (Array.isArray(deepValue)) {
@@ -227,7 +282,10 @@ class BaseExporter extends import_events.default {
227
282
  }
228
283
  return render(value);
229
284
  }
230
- normalizeRenderedValue(value, field) {
285
+ normalizeRenderedValue(value, field, dataIndex) {
286
+ if (this.shouldExportAsText(field, dataIndex)) {
287
+ return this.normalizeTextCellValue(value);
288
+ }
231
289
  if (!this.options.collectionManager.isNumericField(field)) {
232
290
  return value;
233
291
  }
@@ -246,6 +304,81 @@ class BaseExporter extends import_events.default {
246
304
  }
247
305
  return value;
248
306
  }
307
+ shouldExportAsText(field, dataIndex) {
308
+ var _a, _b, _c;
309
+ const fieldInterface = (_a = field == null ? void 0 : field.options) == null ? void 0 : _a.interface;
310
+ const fieldType = (_b = field == null ? void 0 : field.options) == null ? void 0 : _b.type;
311
+ const formulaDataType = (_c = field == null ? void 0 : field.options) == null ? void 0 : _c.dataType;
312
+ if (this.isKeyField(field, dataIndex)) {
313
+ return true;
314
+ }
315
+ if (this.isForeignKeyField(field)) {
316
+ return true;
317
+ }
318
+ if (fieldType === "formula") {
319
+ return formulaDataType === "string";
320
+ }
321
+ if (typeof fieldInterface === "string") {
322
+ if (TEXT_EXPORT_INTERFACES.has(fieldInterface) || IDENTIFIER_EXPORT_INTERFACES.has(fieldInterface)) {
323
+ return true;
324
+ }
325
+ if (NON_TEXT_EXPORT_INTERFACES.has(fieldInterface)) {
326
+ return false;
327
+ }
328
+ }
329
+ return typeof fieldType === "string" && TEXT_EXPORT_TYPES.has(fieldType);
330
+ }
331
+ isKeyField(field, dataIndex) {
332
+ var _a, _b, _c;
333
+ const fieldName = (_a = field == null ? void 0 : field.options) == null ? void 0 : _a.name;
334
+ if (!fieldName) {
335
+ return false;
336
+ }
337
+ const fieldCollection = dataIndex ? this.resolveFieldByDataIndex(dataIndex).collection : this.getFieldCollection(field);
338
+ const primaryKeyAttributes = (_b = fieldCollection == null ? void 0 : fieldCollection.model) == null ? void 0 : _b.primaryKeyAttributes;
339
+ if (Array.isArray(primaryKeyAttributes) && primaryKeyAttributes.includes(fieldName)) {
340
+ return true;
341
+ }
342
+ const filterTargetKey = fieldCollection == null ? void 0 : fieldCollection.filterTargetKey;
343
+ if (Array.isArray(filterTargetKey)) {
344
+ return filterTargetKey.includes(fieldName);
345
+ }
346
+ if (typeof filterTargetKey === "string" && filterTargetKey === fieldName) {
347
+ return true;
348
+ }
349
+ return ((_c = field.options) == null ? void 0 : _c.primaryKey) === true;
350
+ }
351
+ getFieldCollection(field) {
352
+ return field == null ? void 0 : field.collection;
353
+ }
354
+ isForeignKeyField(field) {
355
+ var _a;
356
+ const fieldName = (_a = field == null ? void 0 : field.options) == null ? void 0 : _a.name;
357
+ const fieldCollection = this.getFieldCollection(field);
358
+ if (!fieldName || !fieldCollection) {
359
+ return false;
360
+ }
361
+ return fieldCollection.getFields().some((candidate) => {
362
+ var _a2;
363
+ if (!candidate.isRelationField()) {
364
+ return false;
365
+ }
366
+ const relationForeignKey = candidate.foreignKey ?? ((_a2 = candidate.options) == null ? void 0 : _a2.foreignKey);
367
+ return relationForeignKey === fieldName;
368
+ });
369
+ }
370
+ normalizeTextCellValue(value) {
371
+ if (value == null || value === "") {
372
+ return value;
373
+ }
374
+ return String(value);
375
+ }
376
+ shouldApplyTextCellFormat(value, field, dataIndex) {
377
+ if (!this.shouldExportAsText(field, dataIndex) || value == null || value === "") {
378
+ return false;
379
+ }
380
+ return FORMULA_INJECTION_PREFIX_RE.test(String(value));
381
+ }
249
382
  generateOutputPath(prefix = "export", ext = "", destination = (0, import_utils.storagePathJoin)("tmp")) {
250
383
  const fileName = `${prefix}-${Date.now()}-${Math.random().toString(36).slice(2)}${ext}`;
251
384
  return import_path.default.join(destination, fileName);
@@ -86,7 +86,14 @@ class XlsxExporter extends import_base_exporter.BaseExporter {
86
86
  const rowData = this.options.columns.map((col) => {
87
87
  return this.formatValue(row, col.dataIndex, ctx);
88
88
  });
89
- this.worksheet.addRow(rowData).commit();
89
+ const xlsxRow = this.worksheet.addRow(rowData);
90
+ this.options.columns.forEach((col, index) => {
91
+ const field = this.findFieldByDataIndex(col.dataIndex);
92
+ if (this.shouldApplyTextCellFormat(rowData[index], field, col.dataIndex)) {
93
+ xlsxRow.getCell(index + 1).numFmt = "@";
94
+ }
95
+ });
96
+ xlsxRow.commit();
90
97
  }
91
98
  async finalize() {
92
99
  await this.worksheet.commit();
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "description": "Export filtered records to excel, you can configure which fields to export.",
7
7
  "description.ru-RU": "Экспорт в Excel: можно настроить, какие поля будут экспортироваться.",
8
8
  "description.zh-CN": "导出筛选后的记录到 Excel 中,可以配置导出哪些字段。",
9
- "version": "2.2.0-beta.8",
9
+ "version": "2.2.0-beta.9",
10
10
  "license": "Apache-2.0",
11
11
  "main": "./dist/server/index.js",
12
12
  "homepage": "https://docs.nocobase.com/handbook/action-export",
@@ -40,7 +40,7 @@
40
40
  "@nocobase/test": "2.x",
41
41
  "@nocobase/utils": "2.x"
42
42
  },
43
- "gitHead": "fa2502c1e9faf6d74b3f51b42dbc6546638d46af",
43
+ "gitHead": "60e3d7abbaa0c7cead76f71a4f3d5eedb6b8acdb",
44
44
  "keywords": [
45
45
  "Actions"
46
46
  ]