@nocobase/plugin-action-export 1.0.0-alpha.1

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.
Files changed (44) hide show
  1. package/LICENSE +661 -0
  2. package/README.md +9 -0
  3. package/README.zh-CN.md +9 -0
  4. package/client.d.ts +2 -0
  5. package/client.js +1 -0
  6. package/dist/client/ExportActionInitializer.d.ts +8 -0
  7. package/dist/client/ExportDesigner.d.ts +2 -0
  8. package/dist/client/ExportPluginProvider.d.ts +2 -0
  9. package/dist/client/index.d.ts +9 -0
  10. package/dist/client/index.js +14 -0
  11. package/dist/client/locale/index.d.ts +2 -0
  12. package/dist/client/schemaSettings.d.ts +2 -0
  13. package/dist/client/useExportAction.d.ts +3 -0
  14. package/dist/client/useFields.d.ts +1 -0
  15. package/dist/client/useShared.d.ts +71 -0
  16. package/dist/externalVersion.js +14 -0
  17. package/dist/index.d.ts +2 -0
  18. package/dist/index.js +39 -0
  19. package/dist/locale/en-US.json +4 -0
  20. package/dist/locale/zh-CN.json +4 -0
  21. package/dist/node_modules/node-xlsx/lib/helpers.js +142 -0
  22. package/dist/node_modules/node-xlsx/lib/index.js +6 -0
  23. package/dist/node_modules/node-xlsx/lib/workbook.js +16 -0
  24. package/dist/node_modules/node-xlsx/package.json +1 -0
  25. package/dist/server/actions/export-xlsx.d.ts +2 -0
  26. package/dist/server/actions/export-xlsx.js +80 -0
  27. package/dist/server/actions/index.d.ts +1 -0
  28. package/dist/server/actions/index.js +21 -0
  29. package/dist/server/index.d.ts +7 -0
  30. package/dist/server/index.js +49 -0
  31. package/dist/server/migrations/20240425220631-change-locale-module.d.ts +6 -0
  32. package/dist/server/migrations/20240425220631-change-locale-module.js +42 -0
  33. package/dist/server/renders/index.d.ts +8 -0
  34. package/dist/server/renders/index.js +159 -0
  35. package/dist/server/renders/renders.d.ts +15 -0
  36. package/dist/server/renders/renders.js +167 -0
  37. package/dist/server/utils/columns2Appends.d.ts +1 -0
  38. package/dist/server/utils/columns2Appends.js +45 -0
  39. package/dist/server/utils/index.d.ts +1 -0
  40. package/dist/server/utils/index.js +21 -0
  41. package/dist/swagger/index.json +21 -0
  42. package/package.json +34 -0
  43. package/server.d.ts +2 -0
  44. package/server.js +1 -0
package/client.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './dist/client';
2
+ export { default } from './dist/client';
package/client.js ADDED
@@ -0,0 +1 @@
1
+ module.exports = require('./dist/client/index.js');
@@ -0,0 +1,8 @@
1
+ import { Schema } from '@formily/react';
2
+ import React from 'react';
3
+ export declare const useCurrentSchema: (action: string, key: string, find?: (schema: Schema, key: string, action: string) => any, rm?: (schema: any, cb: any) => any) => {
4
+ schema: any;
5
+ exists: boolean;
6
+ remove(): void;
7
+ };
8
+ export declare const ExportActionInitializer: () => React.JSX.Element;
@@ -0,0 +1,2 @@
1
+ import React from 'react';
2
+ export declare const ExportDesigner: () => React.JSX.Element;
@@ -0,0 +1,2 @@
1
+ import React from 'react';
2
+ export declare const ExportPluginProvider: (props: any) => React.JSX.Element;
@@ -0,0 +1,9 @@
1
+ export * from './ExportActionInitializer';
2
+ export * from './ExportDesigner';
3
+ export * from './ExportPluginProvider';
4
+ export * from './useExportAction';
5
+ import { Plugin } from '@nocobase/client';
6
+ export declare class PluginActionExportClient extends Plugin {
7
+ load(): Promise<void>;
8
+ }
9
+ export default PluginActionExportClient;
@@ -0,0 +1,14 @@
1
+ (function(s,l){typeof exports=="object"&&typeof module!="undefined"?l(exports,require("react/jsx-runtime"),require("@formily/react"),require("@formily/shared"),require("@nocobase/client"),require("@formily/antd-v5"),require("react"),require("react-i18next"),require("lodash"),require("antd")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","@formily/react","@formily/shared","@nocobase/client","@formily/antd-v5","react","react-i18next","lodash","antd"],l):(s=typeof globalThis!="undefined"?globalThis:s||self,l(s["@nocobase/plugin-action-export"]={},s.jsxRuntime,s["@formily/react"],s["@formily/shared"],s["@nocobase/client"],s["@formily/antd-v5"],s.react,s["react-i18next"],s.lodash,s.antd))})(this,function(s,l,h,k,i,M,w,E,y,j){"use strict";var re=Object.defineProperty,ae=Object.defineProperties;var se=Object.getOwnPropertyDescriptors;var V=Object.getOwnPropertySymbols;var ie=Object.prototype.hasOwnProperty,ce=Object.prototype.propertyIsEnumerable;var Y=(s,l,h)=>l in s?re(s,l,{enumerable:!0,configurable:!0,writable:!0,value:h}):s[l]=h,B=(s,l)=>{for(var h in l||(l={}))ie.call(l,h)&&Y(s,h,l[h]);if(V)for(var h of V(l))ce.call(l,h)&&Y(s,h,l[h]);return s},Q=(s,l)=>ae(s,se(l));var D=(s,l,h)=>new Promise((k,i)=>{var M=y=>{try{E(h.next(y))}catch(j){i(j)}},w=y=>{try{E(h.throw(y))}catch(j){i(j)}},E=y=>y.done?k(y.value):Promise.resolve(y.value).then(M,w);E((h=h.apply(s,l)).next())});const O=o=>{var c;const e=h.useFieldSchema();(c=e==null?void 0:e["x-component-props"])!=null&&c.nonfilterable;const{getCollectionFields:a}=i.useCollectionManager_deprecated(),d=a(o),g=(p,x)=>{var r;if(!p.interface)return;const t={name:p.name,title:((r=p==null?void 0:p.uiSchema)==null?void 0:r.title)||p.name,schema:p==null?void 0:p.uiSchema};if(!p.target||x>=3)return t;if(p.target){const u=a(p.target),n=f(u,x+1).filter(Boolean);t.children=t.children||[],t.children.push(...n)}return t},f=(p,x)=>{const t=[];return p.forEach(r=>{const u=g(r,x);u&&t.push(u)}),t};return f(d,1)},L=(o,e,a)=>o.reduceProperties((d,g)=>{if(g[e]===a)return g;const f=L(g,e,a);return f||d}),Z=(o,e)=>e(o),R=(o,e,a=L,d=Z)=>{const g=h.useFieldSchema(),{remove:f}=i.useDesignable(),c=a(g,e,o);return{schema:c,exists:!!c,remove(){c&&d(c,f)}}},$=o=>o==null?void 0:o.filter(a=>!a.children).map(a=>({dataIndex:[a.name]})),q=()=>{const o=i.useSchemaInitializerItem(),{insert:e}=i.useSchemaInitializer(),{exists:a,remove:d}=R("export","x-action",o.find,o.remove),{name:g}=i.useCollection_deprecated(),f=O(g),c={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 l.jsx(i.SchemaInitializerSwitch,Q(B({},o),{checked:a,title:o.title,onClick:()=>{var x;if(a)return d();c["x-action-settings"].exportSettings=$(f);const p=k.merge(c||{},o.schema||{});(x=o==null?void 0:o.schemaInitialize)==null||x.call(o,p),e(p)}}))},_=()=>{const{name:o}=i.useCollection_deprecated(),e=O(o);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:i.css`
2
+ width: 100%;
3
+ & .ant-space-item:nth-child(2),
4
+ & .ant-space-item:nth-child(3) {
5
+ flex: 1;
6
+ }
7
+ `},properties:{sort:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.SortHandle"},dataIndex:{type:"array","x-decorator":"FormItem","x-component":i.Cascader,required:!0,enum:e,"x-component-props":{fieldNames:{label:"title",value:"name",children:"children"},changeOnSelect:!1}},title:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:'{{ t("Custom column title") }}'}},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:i.css`
8
+ border-color: var(--colorSettings);
9
+ color: var(--colorSettings);
10
+ &.ant-btn-dashed:hover {
11
+ border-color: var(--colorSettings);
12
+ color: var(--colorSettings);
13
+ }
14
+ `}}}}}}}},ee="action-export";function z(){return E.useTranslation([ee,"client"],{nsMode:"fallback"})}const U=()=>{var p,x,t,r,u;const o=h.useField(),e=h.useFieldSchema(),{t:a}=z(),{dn:d}=i.useDesignable(),[g,f]=w.useState(),{schema:c}=_();return w.useEffect(()=>{f(c)},[o.address,(p=e==null?void 0:e["x-action-settings"])==null?void 0:p.exportSettings]),l.jsxs(i.GeneralSchemaDesigner,{disableInitializer:!0,children:[l.jsx(i.SchemaSettingsModalItem,{title:a("Edit button"),schema:{type:"object",title:a("Edit button"),properties:{title:{"x-decorator":"FormItem","x-component":"Input",title:a("Button title"),default:e.title,"x-component-props":{}},icon:{"x-decorator":"FormItem","x-component":"IconPicker",title:a("Button icon"),default:(x=e==null?void 0:e["x-component-props"])==null?void 0:x.icon,"x-component-props":{}},type:{"x-decorator":"FormItem","x-component":"Radio.Group",title:a("Button background color"),default:(t=e==null?void 0:e["x-component-props"])!=null&&t.danger?"danger":((r=e==null?void 0:e["x-component-props"])==null?void 0:r.type)==="primary"?"primary":"default",enum:[{value:"default",label:'{{t("Default")}}'},{value:"primary",label:'{{t("Highlight")}}'},{value:"danger",label:'{{t("Danger red")}}'}]}}},onSubmit:({title:n,icon:m,type:v})=>{e.title=n,o.title=n,o.componentProps.icon=m,o.componentProps.danger=v==="danger",o.componentProps.type=v,e["x-component-props"]=e["x-component-props"]||{},e["x-component-props"].icon=m,e["x-component-props"].danger=v==="danger",e["x-component-props"].type=v,d.emit("patch",{schema:{"x-uid":e["x-uid"],title:n,"x-component-props":B({},e["x-component-props"])}}),d.refresh()}}),l.jsx(i.SchemaSettingsActionModalItem,{title:a("Exportable fields"),schema:g,initialValues:{exportSettings:(u=e==null?void 0:e["x-action-settings"])==null?void 0:u.exportSettings},scope:{t:a},components:{ArrayItems:M.ArrayItems},onSubmit:({exportSettings:n})=>{e["x-action-settings"].exportSettings=n==null?void 0:n.filter(m=>{var v;return(v=m==null?void 0:m.dataIndex)==null?void 0:v.length}).map(m=>({dataIndex:m.dataIndex.map(v=>{var S;return(S=v.name)!=null?S:v}),title:m.title})),d.emit("patch",{schema:{"x-uid":e["x-uid"],"x-action-settings":e["x-action-settings"]}}),d.refresh()}}),l.jsx(i.SchemaSettingsDivider,{}),l.jsx(i.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:n=>n["x-component"]==="Space"||n["x-component"].endsWith("ActionBar"),confirm:{title:a("Delete action")}})]})},N=o=>l.jsx(i.SchemaComponentOptions,{components:{ExportActionInitializer:q,ExportDesigner:U},scope:{useExportAction:G},children:o.children});var P=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{},H={exports:{}};(function(o,e){(function(a,d){d()})(P,function(){function a(t,r){return typeof r=="undefined"?r={autoBom:!1}:typeof r!="object"&&(console.warn("Deprecated: Expected third argument to be a object"),r={autoBom:!r}),r.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(t.type)?new Blob(["\uFEFF",t],{type:t.type}):t}function d(t,r,u){var n=new XMLHttpRequest;n.open("GET",t),n.responseType="blob",n.onload=function(){x(n.response,r,u)},n.onerror=function(){console.error("could not download file")},n.send()}function g(t){var r=new XMLHttpRequest;r.open("HEAD",t,!1);try{r.send()}catch(u){}return 200<=r.status&&299>=r.status}function f(t){try{t.dispatchEvent(new MouseEvent("click"))}catch(u){var r=document.createEvent("MouseEvents");r.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),t.dispatchEvent(r)}}var c=typeof window=="object"&&window.window===window?window:typeof self=="object"&&self.self===self?self:typeof P=="object"&&P.global===P?P:void 0,p=c.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),x=c.saveAs||(typeof window!="object"||window!==c?function(){}:"download"in HTMLAnchorElement.prototype&&!p?function(t,r,u){var n=c.URL||c.webkitURL,m=document.createElement("a");r=r||t.name||"download",m.download=r,m.rel="noopener",typeof t=="string"?(m.href=t,m.origin===location.origin?f(m):g(m.href)?d(t,r,u):f(m,m.target="_blank")):(m.href=n.createObjectURL(t),setTimeout(function(){n.revokeObjectURL(m.href)},4e4),setTimeout(function(){f(m)},0))}:"msSaveOrOpenBlob"in navigator?function(t,r,u){if(r=r||t.name||"download",typeof t!="string")navigator.msSaveOrOpenBlob(a(t,u),r);else if(g(t))d(t,r,u);else{var n=document.createElement("a");n.href=t,n.target="_blank",setTimeout(function(){f(n)})}}:function(t,r,u,n){if(n=n||open("","_blank"),n&&(n.document.title=n.document.body.innerText="downloading..."),typeof t=="string")return d(t,r,u);var m=t.type==="application/octet-stream",v=/constructor/i.test(c.HTMLElement)||c.safari,S=/CriOS\/[\d]+/.test(navigator.userAgent);if((S||m&&v||p)&&typeof FileReader!="undefined"){var I=new FileReader;I.onloadend=function(){var A=I.result;A=S?A:A.replace(/^data:[^;]*;/,"data:attachment/file;"),n?n.location.href=A:location=A,n=null},I.readAsDataURL(t)}else{var T=c.URL||c.webkitURL,C=T.createObjectURL(t);n?n.location=C:location.href=C,n=null,setTimeout(function(){T.revokeObjectURL(C)},4e4)}});c.saveAs=x.saveAs=x,o.exports=x})})(H);var te=H.exports;const G=()=>{const{service:o,resource:e}=i.useBlockRequestContext();i.useAPIClient();const a=h.useFieldSchema(),d=i.useCompile(),{getCollectionJoinField:g}=i.useCollectionManager_deprecated(),{name:f,title:c,getField:p}=i.useCollection_deprecated(),{t:x}=z(),{modal:t}=j.App.useApp();return{onClick(){return D(this,null,function*(){var S,I,T,C,A;if(!(yield t.confirm({title:x("Export"),content:x("Export warning"),okText:x("Start export")})))return;const{exportSettings:n}=y.cloneDeep((S=a==null?void 0:a["x-action-settings"])!=null?S:{});n.forEach(F=>{var J,X;const{uiSchema:b,interface:ne}=(J=g(`${f}.${F.dataIndex.join(".")}`))!=null?J:{};F.enum=(X=b==null?void 0:b.enum)==null?void 0:X.map(K=>({value:K.value,label:K.label})),!F.enum&&(b==null?void 0:b.type)==="boolean"&&(F.enum=[{value:!0,label:x("Yes")},{value:!1,label:x("No")}]),F.defaultTitle=b==null?void 0:b.title,ne==="chinaRegion"&&F.dataIndex.push("name")});const{data:m}=yield e.export({title:d(c),appends:(T=(I=o.params[0])==null?void 0:I.appends)==null?void 0:T.join(),filter:JSON.stringify((C=o.params[0])==null?void 0:C.filter),sort:(A=o.params[0])==null?void 0:A.sort},{method:"post",data:{columns:d(n)},responseType:"blob"}),v=new Blob([m],{type:"application/x-xls"});te.saveAs(v,`${d(c)}.xlsx`)})}}},oe=new i.SchemaSettings({name:"actionSettings:export",items:[{name:"editButton",Component:i.ButtonEditor,useComponentProps(){const{buttonEditorProps:o}=i.useSchemaToolbar();return o}},{name:"exportableFields",type:"actionModal",useComponentProps(){var p,x;const o=h.useField(),e=h.useFieldSchema(),{t:a}=E.useTranslation(),{dn:d}=i.useDesignable(),[g,f]=w.useState(),{schema:c}=_();return w.useEffect(()=>{f(c)},[o.address,(p=e==null?void 0:e["x-action-settings"])==null?void 0:p.exportSettings]),{title:a("Exportable fields"),schema:g,initialValues:{exportSettings:(x=e==null?void 0:e["x-action-settings"])==null?void 0:x.exportSettings},components:{ArrayItems:M.ArrayItems},onSubmit:({exportSettings:t})=>{e["x-action-settings"].exportSettings=t==null?void 0:t.filter(r=>{var u;return(u=r==null?void 0:r.dataIndex)==null?void 0:u.length}).map(r=>({dataIndex:r.dataIndex.map(u=>{var n;return(n=u.name)!=null?n:u}),title:r.title})),d.emit("patch",{schema:{"x-uid":e["x-uid"],"x-action-settings":e["x-action-settings"]}}),d.refresh()}}}},{name:"divider",type:"divider"},{name:"delete",type:"remove",useComponentProps(){const{t:o}=E.useTranslation();return{removeParentsIfNoChildren:!0,breakRemoveOn:e=>e["x-component"]==="Space"||e["x-component"].endsWith("ActionBar"),confirm:{title:o("Delete action")}}}}]});class W extends i.Plugin{load(){return D(this,null,function*(){this.app.use(N);const e={title:"{{t('Export')}}",Component:"ExportActionInitializer",schema:{"x-align":"right","x-decorator":"ACLActionProvider","x-acl-action-props":{skipScopeCheck:!0}}},a=this.app.schemaInitializerManager.get("table:configureActions");a==null||a.add("enableActions.export",e),this.app.schemaInitializerManager.addItem("gantt:configureActions","enableActions.export",e),this.app.schemaSettingsManager.add(oe)})}}s.ExportActionInitializer=q,s.ExportDesigner=U,s.ExportPluginProvider=N,s.PluginActionExportClient=W,s.default=W,s.useCurrentSchema=R,s.useExportAction=G,Object.defineProperties(s,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
@@ -0,0 +1,2 @@
1
+ export declare const NAMESPACE = "action-export";
2
+ export declare function useExportTranslation(): import("react-i18next").UseTranslationResponse<("action-export" | "client")[], undefined>;
@@ -0,0 +1,2 @@
1
+ import { SchemaSettings } from '@nocobase/client';
2
+ export declare const exportActionSchemaSettings: SchemaSettings<{}>;
@@ -0,0 +1,3 @@
1
+ export declare const useExportAction: () => {
2
+ onClick(): Promise<void>;
3
+ };
@@ -0,0 +1 @@
1
+ export declare const useFields: (collectionName: string) => any[];
@@ -0,0 +1,71 @@
1
+ /// <reference types="react" />
2
+ export declare const useShared: () => {
3
+ schema: {
4
+ type: string;
5
+ 'x-component': string;
6
+ properties: {
7
+ exportSettings: {
8
+ type: string;
9
+ 'x-component': string;
10
+ 'x-decorator': string;
11
+ items: {
12
+ type: string;
13
+ properties: {
14
+ space: {
15
+ type: string;
16
+ 'x-component': string;
17
+ 'x-component-props': {
18
+ className: string;
19
+ };
20
+ properties: {
21
+ sort: {
22
+ type: string;
23
+ 'x-decorator': string;
24
+ 'x-component': string;
25
+ };
26
+ dataIndex: {
27
+ type: string;
28
+ 'x-decorator': string;
29
+ 'x-component': import("react").ForwardRefExoticComponent<Omit<Partial<any>, "ref"> & import("react").RefAttributes<unknown>>;
30
+ required: boolean;
31
+ enum: any[];
32
+ 'x-component-props': {
33
+ fieldNames: {
34
+ label: string;
35
+ value: string;
36
+ children: string;
37
+ };
38
+ changeOnSelect: boolean;
39
+ };
40
+ };
41
+ title: {
42
+ type: string;
43
+ 'x-decorator': string;
44
+ 'x-component': string;
45
+ 'x-component-props': {
46
+ placeholder: string;
47
+ };
48
+ };
49
+ remove: {
50
+ type: string;
51
+ 'x-decorator': string;
52
+ 'x-component': string;
53
+ };
54
+ };
55
+ };
56
+ };
57
+ };
58
+ properties: {
59
+ add: {
60
+ type: string;
61
+ title: string;
62
+ 'x-component': string;
63
+ 'x-component-props': {
64
+ className: string;
65
+ };
66
+ };
67
+ };
68
+ };
69
+ };
70
+ };
71
+ };
@@ -0,0 +1,14 @@
1
+ module.exports = {
2
+ "@formily/react": "2.3.0",
3
+ "@formily/shared": "2.3.0",
4
+ "@nocobase/client": "1.0.0-alpha.1",
5
+ "react": "18.2.0",
6
+ "@formily/antd-v5": "1.1.9",
7
+ "react-i18next": "11.18.6",
8
+ "lodash": "4.17.21",
9
+ "antd": "5.12.8",
10
+ "@nocobase/server": "1.0.0-alpha.1",
11
+ "@nocobase/actions": "1.0.0-alpha.1",
12
+ "@nocobase/database": "1.0.0-alpha.1",
13
+ "@nocobase/utils": "1.0.0-alpha.1"
14
+ };
@@ -0,0 +1,2 @@
1
+ export * from './server';
2
+ export { default } from './server';
package/dist/index.js ADDED
@@ -0,0 +1,39 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var src_exports = {};
30
+ __export(src_exports, {
31
+ default: () => import_server.default
32
+ });
33
+ module.exports = __toCommonJS(src_exports);
34
+ __reExport(src_exports, require("./server"), module.exports);
35
+ var import_server = __toESM(require("./server"));
36
+ // Annotate the CommonJS export names for ESM import in node:
37
+ 0 && (module.exports = {
38
+ ...require("./server")
39
+ });
@@ -0,0 +1,4 @@
1
+ {
2
+ "Export warning": "You can export up to 200 rows of data at a time, any excess will be ignored.",
3
+ "Start export": "Start export"
4
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "Export warning": "每次最多导出 200 行数据,超出的将被忽略。",
3
+ "Start export": "开始导出"
4
+ }
@@ -0,0 +1,142 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ exports.__esModule = true;
6
+ exports.buildSheetFromMatrix = exports.buildExcelDate = exports.isCellDescriptor = exports.isObject = exports.isString = exports.isNumber = exports.isBoolean = void 0;
7
+
8
+ var _xlsx = _interopRequireDefault(require("xlsx"));
9
+
10
+ var ORIGIN_DATE = new Date(Date.UTC(1899, 11, 30));
11
+
12
+ var isBoolean = function isBoolean(maybeBoolean) {
13
+ return typeof maybeBoolean === 'boolean';
14
+ };
15
+
16
+ exports.isBoolean = isBoolean;
17
+
18
+ var isNumber = function isNumber(maybeNumber) {
19
+ return typeof maybeNumber === 'number';
20
+ };
21
+
22
+ exports.isNumber = isNumber;
23
+
24
+ var isString = function isString(maybeString) {
25
+ return typeof maybeString === 'string';
26
+ };
27
+
28
+ exports.isString = isString;
29
+
30
+ var isObject = function isObject(maybeObject) {
31
+ return maybeObject !== null && typeof maybeObject === 'object';
32
+ };
33
+
34
+ exports.isObject = isObject;
35
+
36
+ var isCellDescriptor = function isCellDescriptor(maybeCell) {
37
+ return isObject(maybeCell) && 'v' in maybeCell;
38
+ };
39
+
40
+ exports.isCellDescriptor = isCellDescriptor;
41
+
42
+ var buildExcelDate = function buildExcelDate(value, is1904) {
43
+ var epoch = Date.parse(value + (is1904 ? 1462 : 0));
44
+ return (epoch - ORIGIN_DATE) / 864e5;
45
+ };
46
+
47
+ exports.buildExcelDate = buildExcelDate;
48
+
49
+ var buildSheetFromMatrix = function buildSheetFromMatrix(data, options) {
50
+ if (options === void 0) {
51
+ options = {};
52
+ }
53
+
54
+ var workSheet = {};
55
+ var range = {
56
+ s: {
57
+ c: 1e7,
58
+ r: 1e7
59
+ },
60
+ e: {
61
+ c: 0,
62
+ r: 0
63
+ }
64
+ };
65
+ if (!Array.isArray(data)) throw new Error('sheet data is not array');
66
+
67
+ for (var R = 0; R !== data.length; R += 1) {
68
+ for (var C = 0; C !== data[R].length; C += 1) {
69
+ if (!Array.isArray(data[R])) throw new Error(`${R}th row data is not array`);
70
+ if (range.s.r > R) range.s.r = R;
71
+ if (range.s.c > C) range.s.c = C;
72
+ if (range.e.r < R) range.e.r = R;
73
+ if (range.e.c < C) range.e.c = C;
74
+
75
+ if (data[R][C] === null) {
76
+ continue; // eslint-disable-line
77
+ }
78
+
79
+ var cell = isCellDescriptor(data[R][C]) ? data[R][C] : {
80
+ v: data[R][C]
81
+ };
82
+
83
+ var cellRef = _xlsx.default.utils.encode_cell({
84
+ c: C,
85
+ r: R
86
+ });
87
+
88
+ if (isNumber(cell.v)) {
89
+ cell.t = 'n';
90
+ } else if (isBoolean(cell.v)) {
91
+ cell.t = 'b';
92
+ } else if (cell.v instanceof Date) {
93
+ cell.t = 'n';
94
+ cell.v = buildExcelDate(cell.v);
95
+ cell.z = cell.z || _xlsx.default.SSF._table[14]; // eslint-disable-line no-underscore-dangle
96
+
97
+ /* eslint-disable spaced-comment, no-trailing-spaces */
98
+
99
+ /***
100
+ * Allows for an non-abstracted representation of the data
101
+ *
102
+ * example: {t:'n', z:10, f:'=AVERAGE(A:A)'}
103
+ *
104
+ * Documentation:
105
+ * - Cell Object: https://sheetjs.gitbooks.io/docs/#cell-object
106
+ * - Data Types: https://sheetjs.gitbooks.io/docs/#data-types
107
+ * - Format: https://sheetjs.gitbooks.io/docs/#number-formats
108
+ **/
109
+
110
+ /* eslint-disable spaced-comment, no-trailing-spaces */
111
+ } else if (isObject(cell.v)) {
112
+ cell.t = cell.v.t;
113
+ cell.f = cell.v.f;
114
+ cell.F = cell.v.F;
115
+ cell.z = cell.v.z;
116
+ } else {
117
+ cell.t = 's';
118
+ }
119
+
120
+ if (isNumber(cell.z)) cell.z = _xlsx.default.SSF._table[cell.z]; // eslint-disable-line no-underscore-dangle
121
+
122
+ workSheet[cellRef] = cell;
123
+ }
124
+ }
125
+
126
+ if (range.s.c < 1e7) {
127
+ workSheet['!ref'] = _xlsx.default.utils.encode_range(range);
128
+ }
129
+
130
+ if (options['!cols']) {
131
+ workSheet['!cols'] = options['!cols'];
132
+ }
133
+
134
+ if (options['!merges']) {
135
+ workSheet['!merges'] = options['!merges'];
136
+ }
137
+
138
+ return workSheet;
139
+ };
140
+
141
+ exports.buildSheetFromMatrix = buildSheetFromMatrix;
142
+ //# sourceMappingURL=helpers.js.map