@mineadmin/table 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 X.Mo
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,8 @@
1
+ ## MineAdmin Table 组件
2
+
3
+ 二次封装了element plus table
4
+
5
+
6
+ ## 许可证
7
+
8
+ [MIT © 2022-present, @mineadmin/table](./LICENSE)
@@ -0,0 +1,26 @@
1
+ import type { PropType } from 'vue';
2
+ import { MaTableOptions, MaTableColumns } from '../types';
3
+ import '../style/index.scss';
4
+ declare const _default: import("vue").DefineComponent<{
5
+ options: {
6
+ type: PropType<MaTableOptions>;
7
+ default: () => {};
8
+ };
9
+ columns: {
10
+ type: PropType<MaTableColumns[]>;
11
+ default: () => any[];
12
+ };
13
+ }, () => any, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
14
+ options: {
15
+ type: PropType<MaTableOptions>;
16
+ default: () => {};
17
+ };
18
+ columns: {
19
+ type: PropType<MaTableColumns[]>;
20
+ default: () => any[];
21
+ };
22
+ }>>, {
23
+ options: {};
24
+ columns: MaTableColumns[];
25
+ }, {}>;
26
+ export default _default;
@@ -0,0 +1,113 @@
1
+ import type { PropType } from 'vue';
2
+ import type { PaginationProps } from 'element-plus/es/components/pagination/src/pagination';
3
+ import { MaTableColumns } from '../types';
4
+ declare const _default: {
5
+ options: {
6
+ data: {
7
+ type: PropType<any[]>;
8
+ default: () => never[];
9
+ };
10
+ size: {
11
+ readonly type: PropType<import("element-plus/es/utils/index.mjs").EpPropMergeType<StringConstructor, "" | "small" | "default" | "large", never>>;
12
+ readonly required: false;
13
+ readonly validator: ((val: unknown) => boolean) | undefined;
14
+ __epPropKey: true;
15
+ };
16
+ width: (NumberConstructor | StringConstructor)[];
17
+ height: (NumberConstructor | StringConstructor)[];
18
+ maxHeight: (NumberConstructor | StringConstructor)[];
19
+ fit: {
20
+ type: BooleanConstructor;
21
+ default: boolean;
22
+ };
23
+ stripe: BooleanConstructor;
24
+ border: BooleanConstructor;
25
+ rowKey: PropType<string | ((row: any) => string) | undefined>;
26
+ showHeader: {
27
+ type: BooleanConstructor;
28
+ default: boolean;
29
+ };
30
+ showSummary: BooleanConstructor;
31
+ sumText: StringConstructor;
32
+ summaryMethod: PropType<import("element-plus/es/components/table/src/table/defaults.mjs").SummaryMethod<any> | undefined>;
33
+ rowClassName: PropType<import("element-plus/es/components/table/src/table/defaults.mjs").ColumnCls<any> | undefined>;
34
+ rowStyle: PropType<import("element-plus/es/components/table/src/table/defaults.mjs").ColumnStyle<any> | undefined>;
35
+ cellClassName: PropType<import("element-plus/es/components/table/src/table/defaults.mjs").CellCls<any> | undefined>;
36
+ cellStyle: PropType<import("element-plus/es/components/table/src/table/defaults.mjs").CellStyle<any> | undefined>;
37
+ headerRowClassName: PropType<import("element-plus/es/components/table/src/table/defaults.mjs").ColumnCls<any> | undefined>;
38
+ headerRowStyle: PropType<import("element-plus/es/components/table/src/table/defaults.mjs").ColumnStyle<any> | undefined>;
39
+ headerCellClassName: PropType<import("element-plus/es/components/table/src/table/defaults.mjs").CellCls<any> | undefined>;
40
+ headerCellStyle: PropType<import("element-plus/es/components/table/src/table/defaults.mjs").CellStyle<any> | undefined>;
41
+ highlightCurrentRow: BooleanConstructor;
42
+ currentRowKey: (NumberConstructor | StringConstructor)[];
43
+ emptyText: StringConstructor;
44
+ expandRowKeys: PropType<string[] | undefined>;
45
+ defaultExpandAll: BooleanConstructor;
46
+ defaultSort: PropType<import("element-plus/es/components/table/src/table/defaults.mjs").Sort | undefined>;
47
+ tooltipEffect: StringConstructor;
48
+ tooltipOptions: PropType<Partial<Pick<import("element-plus").ElTooltipProps, "offset" | "transition" | "placement" | "effect" | "showAfter" | "hideAfter" | "popperOptions" | "enterable" | "popperClass" | "appendTo" | "showArrow">> | undefined>;
49
+ spanMethod: PropType<((data: {
50
+ row: any;
51
+ rowIndex: number;
52
+ column: import("element-plus/es/components/table/src/table-column/defaults.mjs").TableColumnCtx<any>;
53
+ columnIndex: number;
54
+ }) => number[] | {
55
+ rowspan: number;
56
+ colspan: number;
57
+ } | undefined) | undefined>;
58
+ selectOnIndeterminate: {
59
+ type: BooleanConstructor;
60
+ default: boolean;
61
+ };
62
+ indent: {
63
+ type: NumberConstructor;
64
+ default: number;
65
+ };
66
+ treeProps: {
67
+ type: PropType<import("element-plus/es/components/table/src/table/defaults.mjs").TreeProps | undefined>;
68
+ default: () => {
69
+ hasChildren: string;
70
+ children: string;
71
+ checkStrictly: boolean;
72
+ };
73
+ };
74
+ lazy: BooleanConstructor;
75
+ load: PropType<((row: any, treeNode: import("element-plus/es/components/table/src/table/defaults.mjs").TreeNode, resolve: (data: any[]) => void) => void) | undefined>;
76
+ style: {
77
+ type: PropType<import("vue").CSSProperties>;
78
+ default: () => {};
79
+ };
80
+ className: {
81
+ type: StringConstructor;
82
+ default: string;
83
+ };
84
+ tableLayout: {
85
+ type: PropType<"fixed" | "auto">;
86
+ default: string;
87
+ };
88
+ scrollbarAlwaysOn: BooleanConstructor;
89
+ flexible: BooleanConstructor;
90
+ showOverflowTooltip: PropType<boolean | Partial<Pick<import("element-plus").ElTooltipProps, "offset" | "transition" | "placement" | "effect" | "showAfter" | "hideAfter" | "popperOptions" | "enterable" | "popperClass" | "appendTo" | "showArrow">> | undefined>;
91
+ loading: {
92
+ type: BooleanConstructor;
93
+ default: boolean;
94
+ };
95
+ columnAlign: {
96
+ type: StringConstructor;
97
+ default: string;
98
+ };
99
+ headerAlign: {
100
+ type: StringConstructor;
101
+ default: string;
102
+ };
103
+ pagination: {
104
+ type: PropType<PaginationProps>;
105
+ default: PaginationProps;
106
+ };
107
+ };
108
+ columns: {
109
+ type: PropType<MaTableColumns[]>;
110
+ default: any[];
111
+ };
112
+ };
113
+ export default _default;
@@ -0,0 +1 @@
1
+ export default function useTable(refName: string): Promise<any>;
@@ -0,0 +1,9 @@
1
+ import type { App } from 'vue';
2
+ import useTable from './components/useTable';
3
+ import type { MaTableInstallOptions } from './types';
4
+ export declare const MaTable: {
5
+ install(app: App, options?: MaTableInstallOptions): void;
6
+ };
7
+ export default MaTable;
8
+ export { useTable };
9
+ export type { MaTableOptions, } from './types';
@@ -0,0 +1,72 @@
1
+ import { defineComponent as R, ref as b, inject as H, onMounted as N, nextTick as A, onBeforeUnmount as V, computed as $, createVNode as u, mergeProps as C, withDirectives as k, resolveDirective as I, Fragment as m, isVNode as F, getCurrentInstance as S } from "vue";
2
+ import { ElLoadingDirective as U, ElPagination as q, ElTable as G, ElEmpty as J, ElTableColumn as K } from "element-plus";
3
+ const z = R({ name: "MaTable", props: { options: { type: Object, default: () => ({}) }, columns: { type: Array, default: () => [] } }, directives: { Loading: U }, setup(i, { slots: a, attrs: d, emit: h, expose: t }) {
4
+ const l = b(i.options), g = b(i.columns), D = H("MaTableOptions"), w = b(!1), T = b(), y = () => {
5
+ const { adaptionOffsetBottom: e } = l.value, n = window.innerHeight - (e ?? 65);
6
+ l.value.height = `${n}px`;
7
+ };
8
+ N(async () => {
9
+ w.value = !0, await A(() => {
10
+ var e;
11
+ (e = l.value) != null && e.adaption && (y(), window.addEventListener("resize", y));
12
+ });
13
+ }), V(() => {
14
+ var e;
15
+ w.value = !1, (e = l.value) != null && e.adaption && window.removeEventListener("resize", y);
16
+ });
17
+ const B = $(() => {
18
+ const { pagination: e } = l.value;
19
+ return e ? u("div", { className: "mineadmin-pagination", style: `justify-content: ${(e == null ? void 0 : e.align) ?? "right"}` }, [u(q, C(e, { size: (e == null ? void 0 : e.size) ?? "default", pagerCount: (e == null ? void 0 : e.pagerCount) ?? 5, layout: (e == null ? void 0 : e.layout) ?? "total, prev, pager, next, sizes, jumper" }), null)]) : null;
20
+ }), x = (e, n) => {
21
+ var M, E, P;
22
+ if (e != null && e.hide && (e == null ? void 0 : e.hide) instanceof Function && e.hide(d) || e != null && e.hide && typeof (e == null ? void 0 : e.hide) == "boolean" && e.hide) return;
23
+ let p = { default: (s) => {
24
+ var r, v, f;
25
+ return ((r = e == null ? void 0 : e.cellRender) == null ? void 0 : r.call(e, Object.assign(s, { options: l.value, attrs: d }))) ?? ((v = a == null ? void 0 : a[`column-${e.prop}`]) == null ? void 0 : v.call(a, s)) ?? ((f = a == null ? void 0 : a.default) == null ? void 0 : f.call(a, s));
26
+ }, header: (s) => {
27
+ var r, v, f;
28
+ return ((r = e == null ? void 0 : e.headerRender) == null ? void 0 : r.call(e, Object.assign(s, { options: l.value, attrs: d }))) ?? ((v = a == null ? void 0 : a[`header-${e.prop}`]) == null ? void 0 : v.call(a, s)) ?? ((f = a == null ? void 0 : a.header) == null ? void 0 : f.call(a, s));
29
+ }, filterIcon: (s) => {
30
+ var r;
31
+ return (r = a == null ? void 0 : a.filterIcon) == null ? void 0 : r.call(a, s);
32
+ } };
33
+ const { children: c, ...o } = e;
34
+ return c && c.length > 0 && (p = c == null ? void 0 : c.map(x)), u(K, C({ key: n }, o, { align: (e == null ? void 0 : e.align) ?? ((M = l.value) == null ? void 0 : M.columnAlign) ?? "center", headerAlign: (e == null ? void 0 : e.headerAlign) ?? ((E = l.value) == null ? void 0 : E.headerAlign) ?? "center", showOverflowTooltip: (e == null ? void 0 : e.showOverflowTooltip) ?? ((P = l.value) == null ? void 0 : P.showOverflowTooltip) ?? !0 }), typeof (O = p) == "function" || Object.prototype.toString.call(O) === "[object Object]" && !F(O) ? p : { default: () => [p] });
35
+ var O;
36
+ }, L = () => {
37
+ const { loading: e, loadingConfig: n, height: p, maxHeight: c } = l.value;
38
+ return k(u("div", { className: "mineadmin-table", "element-loading-svg": (n == null ? void 0 : n.svg) ?? '<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 1024 1024"><path fill="currentColor" d="M512 64a32 32 0 0 1 32 32v192a32 32 0 0 1-64 0V96a32 32 0 0 1 32-32m0 640a32 32 0 0 1 32 32v192a32 32 0 1 1-64 0V736a32 32 0 0 1 32-32m448-192a32 32 0 0 1-32 32H736a32 32 0 1 1 0-64h192a32 32 0 0 1 32 32m-640 0a32 32 0 0 1-32 32H96a32 32 0 0 1 0-64h192a32 32 0 0 1 32 32M195.2 195.2a32 32 0 0 1 45.248 0L376.32 331.008a32 32 0 0 1-45.248 45.248L195.2 240.448a32 32 0 0 1 0-45.248m452.544 452.544a32 32 0 0 1 45.248 0L828.8 783.552a32 32 0 0 1-45.248 45.248L647.744 692.992a32 32 0 0 1 0-45.248M828.8 195.264a32 32 0 0 1 0 45.184L692.992 376.32a32 32 0 0 1-45.248-45.248l135.808-135.808a32 32 0 0 1 45.248 0m-452.544 452.48a32 32 0 0 1 0 45.248L240.448 828.8a32 32 0 0 1-45.248-45.248l135.808-135.808a32 32 0 0 1 45.248 0"/></svg>', "element-loading-svg-view-box": (n == null ? void 0 : n.viewBox) ?? "-9, -9, 50, 50", "element-loading-text": (n == null ? void 0 : n.text) ?? null, "element-loading-spinner": (n == null ? void 0 : n.spinner) ?? null, "element-loading-background": (n == null ? void 0 : n.spinner) ?? null, "element-loading-custom-class": (n == null ? void 0 : n.customClass) ?? null }, [u(m, null, [u(G, C({ ref: T }, l.value, d), { default: () => {
39
+ var o;
40
+ return [u(m, null, [(o = g.value) == null ? void 0 : o.map(x)])];
41
+ }, append: () => {
42
+ var o;
43
+ return (o = a.append) == null ? void 0 : o.call(a);
44
+ }, empty: () => {
45
+ var o;
46
+ return ((o = a.empty) == null ? void 0 : o.call(a)) ?? u(J, null, null);
47
+ } }), B.value])]), [[I("loading"), e]]);
48
+ }, j = (e) => g.value = e;
49
+ return t({ setData: (e) => l.value.data = e, setPagination: (e) => l.value.pagination = e, setLoadingState: (e) => l.value.loading = e, setOptions: (e) => l.value = Object.assign(l.value, e), getOptions: () => l.value, setColumns: j, getColumns: () => g.value, appendColumn: (e) => g.value.push(e), removeColumn: (e) => j(g.value.filter((n) => n.prop !== e)), getColumnByProp: (e) => {
50
+ var n;
51
+ return ((n = g.value.filter((p) => p.prop === e)) == null ? void 0 : n[0]) ?? null;
52
+ }, getTableRef: () => T.value }), () => D.ssr ? w.value && L() : L();
53
+ } });
54
+ function X(i) {
55
+ return new Promise(async (a, d) => {
56
+ const h = S();
57
+ await A(() => {
58
+ if (h && h.refs[i]) {
59
+ const t = h.refs[i];
60
+ a({ instance: t, setData: t == null ? void 0 : t.setData, setOptions: t == null ? void 0 : t.setOptions, setColumns: t == null ? void 0 : t.setColumns, setPagination: t == null ? void 0 : t.setPagination, getTableRef: t == null ? void 0 : t.getTableRef });
61
+ } else d("[@mineadmin/table]: not found ref for ma-table component");
62
+ });
63
+ });
64
+ }
65
+ const Y = { install(i, a) {
66
+ i.component(z.name, z), i.provide("MaTableOptions", a ?? { ssr: !1 });
67
+ } };
68
+ export {
69
+ Y as MaTable,
70
+ Y as default,
71
+ X as useTable
72
+ };
@@ -0,0 +1 @@
1
+ (function(s,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue"),require("element-plus")):typeof define=="function"&&define.amd?define(["exports","vue","element-plus"],t):t((s=typeof globalThis<"u"?globalThis:s||self).MaTable={},s.Vue,s.ElementPlus)})(this,function(s,t,v){"use strict";const O=t.defineComponent({name:"MaTable",props:{options:{type:Object,default:()=>({})},columns:{type:Array,default:()=>[]}},directives:{Loading:v.ElLoadingDirective},setup(u,{slots:a,attrs:c,emit:b,expose:o}){const i=t.ref(u.options),g=t.ref(u.columns),E=t.inject("MaTableOptions"),w=t.ref(!1),C=t.ref(),y=()=>{const{adaptionOffsetBottom:e}=i.value,l=window.innerHeight-(e??65);i.value.height=`${l}px`};t.onMounted(async()=>{w.value=!0,await t.nextTick(()=>{var e;(e=i.value)!=null&&e.adaption&&(y(),window.addEventListener("resize",y))})}),t.onBeforeUnmount(()=>{var e;w.value=!1,(e=i.value)!=null&&e.adaption&&window.removeEventListener("resize",y)});const D=t.computed(()=>{const{pagination:e}=i.value;return e?t.createVNode("div",{className:"mineadmin-pagination",style:`justify-content: ${(e==null?void 0:e.align)??"right"}`},[t.createVNode(v.ElPagination,t.mergeProps(e,{size:(e==null?void 0:e.size)??"default",pagerCount:(e==null?void 0:e.pagerCount)??5,layout:(e==null?void 0:e.layout)??"total, prev, pager, next, sizes, jumper"}),null)]):null}),j=(e,l)=>{var M,N,P;if(e!=null&&e.hide&&(e==null?void 0:e.hide)instanceof Function&&e.hide(c)||e!=null&&e.hide&&typeof(e==null?void 0:e.hide)=="boolean"&&e.hide)return;let p={default:r=>{var d,f,h;return((d=e==null?void 0:e.cellRender)==null?void 0:d.call(e,Object.assign(r,{options:i.value,attrs:c})))??((f=a==null?void 0:a[`column-${e.prop}`])==null?void 0:f.call(a,r))??((h=a==null?void 0:a.default)==null?void 0:h.call(a,r))},header:r=>{var d,f,h;return((d=e==null?void 0:e.headerRender)==null?void 0:d.call(e,Object.assign(r,{options:i.value,attrs:c})))??((f=a==null?void 0:a[`header-${e.prop}`])==null?void 0:f.call(a,r))??((h=a==null?void 0:a.header)==null?void 0:h.call(a,r))},filterIcon:r=>{var d;return(d=a==null?void 0:a.filterIcon)==null?void 0:d.call(a,r)}};const{children:m,...n}=e;return m&&m.length>0&&(p=m==null?void 0:m.map(j)),t.createVNode(v.ElTableColumn,t.mergeProps({key:l},n,{align:(e==null?void 0:e.align)??((M=i.value)==null?void 0:M.columnAlign)??"center",headerAlign:(e==null?void 0:e.headerAlign)??((N=i.value)==null?void 0:N.headerAlign)??"center",showOverflowTooltip:(e==null?void 0:e.showOverflowTooltip)??((P=i.value)==null?void 0:P.showOverflowTooltip)??!0}),typeof(T=p)=="function"||Object.prototype.toString.call(T)==="[object Object]"&&!t.isVNode(T)?p:{default:()=>[p]});var T},V=()=>{const{loading:e,loadingConfig:l,height:p,maxHeight:m}=i.value;return t.withDirectives(t.createVNode("div",{className:"mineadmin-table","element-loading-svg":(l==null?void 0:l.svg)??'<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 1024 1024"><path fill="currentColor" d="M512 64a32 32 0 0 1 32 32v192a32 32 0 0 1-64 0V96a32 32 0 0 1 32-32m0 640a32 32 0 0 1 32 32v192a32 32 0 1 1-64 0V736a32 32 0 0 1 32-32m448-192a32 32 0 0 1-32 32H736a32 32 0 1 1 0-64h192a32 32 0 0 1 32 32m-640 0a32 32 0 0 1-32 32H96a32 32 0 0 1 0-64h192a32 32 0 0 1 32 32M195.2 195.2a32 32 0 0 1 45.248 0L376.32 331.008a32 32 0 0 1-45.248 45.248L195.2 240.448a32 32 0 0 1 0-45.248m452.544 452.544a32 32 0 0 1 45.248 0L828.8 783.552a32 32 0 0 1-45.248 45.248L647.744 692.992a32 32 0 0 1 0-45.248M828.8 195.264a32 32 0 0 1 0 45.184L692.992 376.32a32 32 0 0 1-45.248-45.248l135.808-135.808a32 32 0 0 1 45.248 0m-452.544 452.48a32 32 0 0 1 0 45.248L240.448 828.8a32 32 0 0 1-45.248-45.248l135.808-135.808a32 32 0 0 1 45.248 0"/></svg>',"element-loading-svg-view-box":(l==null?void 0:l.viewBox)??"-9, -9, 50, 50","element-loading-text":(l==null?void 0:l.text)??null,"element-loading-spinner":(l==null?void 0:l.spinner)??null,"element-loading-background":(l==null?void 0:l.spinner)??null,"element-loading-custom-class":(l==null?void 0:l.customClass)??null},[t.createVNode(t.Fragment,null,[t.createVNode(v.ElTable,t.mergeProps({ref:C},i.value,c),{default:()=>{var n;return[t.createVNode(t.Fragment,null,[(n=g.value)==null?void 0:n.map(j)])]},append:()=>{var n;return(n=a.append)==null?void 0:n.call(a)},empty:()=>{var n;return((n=a.empty)==null?void 0:n.call(a))??t.createVNode(v.ElEmpty,null,null)}}),D.value])]),[[t.resolveDirective("loading"),e]])},L=e=>g.value=e;return o({setData:e=>i.value.data=e,setPagination:e=>i.value.pagination=e,setLoadingState:e=>i.value.loading=e,setOptions:e=>i.value=Object.assign(i.value,e),getOptions:()=>i.value,setColumns:L,getColumns:()=>g.value,appendColumn:e=>g.value.push(e),removeColumn:e=>L(g.value.filter(l=>l.prop!==e)),getColumnByProp:e=>{var l;return((l=g.value.filter(p=>p.prop===e))==null?void 0:l[0])??null},getTableRef:()=>C.value}),()=>E.ssr?w.value&&V():V()}}),x={install(u,a){u.component(O.name,O),u.provide("MaTableOptions",a??{ssr:!1})}};s.MaTable=x,s.default=x,s.useTable=function(u){return new Promise(async(a,c)=>{const b=t.getCurrentInstance();await t.nextTick(()=>{if(b&&b.refs[u]){const o=b.refs[u];a({instance:o,setData:o==null?void 0:o.setData,setOptions:o==null?void 0:o.setOptions,setColumns:o==null?void 0:o.setColumns,setPagination:o==null?void 0:o.setPagination,getTableRef:o==null?void 0:o.getTableRef})}else c("[@mineadmin/table]: not found ref for ma-table component")})})},Object.defineProperties(s,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
package/dist/style.css ADDED
@@ -0,0 +1 @@
1
+ .mineadmin-table{width:100%;height:100%;overflow:hidden;display:flex;flex-direction:column}.mineadmin-pagination{width:100%;display:flex;padding:.5rem 0}
@@ -0,0 +1,17 @@
1
+ import { MaTableColumns, TableColumnFilterPlacement, TableColumnSortOrders, TableColumnSortable, TableColumnRenderer, TableColumnFixed, TableColumnScope, TableColumnType, TableColumn } from './table-column';
2
+ import { MaTableOptions, MaTableSetting } from './table-options';
3
+ import { LoadingConfig } from './loading-config';
4
+ import { PaginationProps } from './pagination';
5
+ import { Ref } from 'vue';
6
+ type MaTableInstallOptions = {
7
+ ssr?: boolean;
8
+ };
9
+ interface MaTableExpose {
10
+ instance: any;
11
+ setData: (data: any[]) => void;
12
+ setOptions: (opts: MaTableOptions) => void;
13
+ setColumns: (cols: MaTableColumns[]) => void;
14
+ setPagination: (pagination: PaginationProps) => void;
15
+ getTableRef: () => Ref<HTMLElement>;
16
+ }
17
+ export type { MaTableInstallOptions, MaTableSetting, MaTableColumns, MaTableExpose, MaTableOptions, TableColumnFilterPlacement, TableColumnSortOrders, TableColumnSortable, TableColumnRenderer, TableColumnScope, TableColumnFixed, TableColumnType, PaginationProps, LoadingConfig, TableColumn, };
@@ -0,0 +1,12 @@
1
+ /**
2
+ * @description 加载动画相关配置
3
+ * @see {@link https://element-plus.org/zh-CN/component/loading.html#%E6%8C%87%E4%BB%A4}
4
+ */
5
+ export interface LoadingConfig {
6
+ text?: string;
7
+ spinner?: string;
8
+ svg?: string;
9
+ viewBox?: string;
10
+ background?: string;
11
+ customClass?: string;
12
+ }
@@ -0,0 +1,32 @@
1
+ import type { CSSProperties } from 'vue';
2
+ /**
3
+ * @description 分页相关配置。注意:`pageSize`、`total`、`currentPage` 这三个属性必传
4
+ * @see {@link https://element-plus.org/zh-CN/component/pagination.html#%E5%B1%9E%E6%80%A7}
5
+ */
6
+ export interface PaginationProps {
7
+ total: number;
8
+ pageSize?: number;
9
+ currentPage?: number;
10
+ size?: '' | 'small' | 'default' | 'large';
11
+ small?: boolean;
12
+ background?: boolean;
13
+ defaultPageSize?: number;
14
+ pageCount?: number;
15
+ pagerCount?: number;
16
+ defaultCurrentPage?: number;
17
+ layout?: string;
18
+ pageSizes?: number[];
19
+ popperClass?: string;
20
+ prevText?: string;
21
+ nextText?: string;
22
+ disabled?: boolean;
23
+ hideOnSinglePage?: boolean;
24
+ align?: 'left' | 'center' | 'right';
25
+ style?: CSSProperties;
26
+ class?: string;
27
+ onSizeChange?: (value: number) => void;
28
+ onCurrentChange?: (value: number) => void;
29
+ onChange?: (currentPage: number, pageSize: number) => void;
30
+ onPrevClick?: (value: number) => void;
31
+ onNextClick?: (value: number) => void;
32
+ }
@@ -0,0 +1,69 @@
1
+ import type { TableColumnCtx } from 'element-plus';
2
+ import type { VNode } from 'vue';
3
+ export type TableColumnSortOrders = 'ascending' | 'descending' | null;
4
+ export type TableColumnType = 'selection' | 'index' | 'expand';
5
+ export type TableColumnSortable = false | true | 'custom';
6
+ export type TableColumnFixed = true | 'left' | 'right';
7
+ export type TableColumnFilterPlacement = 'top-start' | 'top-end' | 'top' | 'bottom-start' | 'bottom-end' | 'bottom' | 'left-start' | 'left-end' | 'left' | 'right-start' | 'right-end' | 'right';
8
+ type FilterMethods = (value: any, row: any, column: TableColumnCtx<any>) => void;
9
+ export interface TableHeaderScope {
10
+ column: TableColumnCtx<any>;
11
+ $index: number;
12
+ }
13
+ export interface TableColumnScope {
14
+ row?: any;
15
+ column: TableColumn;
16
+ $index: number;
17
+ }
18
+ export interface TableColumnRenderer extends TableColumnScope {
19
+ options: TableColumn;
20
+ attrs: any;
21
+ }
22
+ /**
23
+ * @description `element-plus` 的 `table` 中 `Table-column` 属性,未拓展
24
+ * @see {@link https://element-plus.org/zh-CN/component/table.html#table-column-%E5%B1%9E%E6%80%A7}
25
+ */
26
+ export interface TableColumn {
27
+ label?: string;
28
+ prop?: string | ((index: number) => string);
29
+ type?: TableColumnType;
30
+ index?: number | ((index: number) => number);
31
+ columnKey?: string;
32
+ width?: string | number;
33
+ minWidth?: string | number;
34
+ fixed?: TableColumnFixed;
35
+ renderHeader?: (data: TableHeaderScope) => VNode | string;
36
+ sortable?: TableColumnSortable;
37
+ sortMethod?: (a: any, b: any) => number;
38
+ sortBy?: string | ((row: any, index: number) => string) | string[];
39
+ sortOrders?: Array<TableColumnSortOrders>;
40
+ resizable?: boolean;
41
+ formatter?: (row: any, column: TableColumnCtx<any>, cellValue: any, index: number) => VNode | string;
42
+ showOverflowTooltip?: boolean;
43
+ align?: 'left' | 'center' | 'right';
44
+ headerAlign?: 'left' | 'center' | 'right';
45
+ className?: string;
46
+ labelClassName?: string;
47
+ selectable?: (row: any, index: number) => boolean;
48
+ reserveSelection?: boolean;
49
+ filters?: {
50
+ text: string;
51
+ value: string;
52
+ }[];
53
+ filterPlacement?: TableColumnFilterPlacement;
54
+ filterClassName?: string;
55
+ filterMultiple?: boolean;
56
+ filterMethod?: FilterMethods;
57
+ filteredValue?: Array<any>;
58
+ }
59
+ /**
60
+ * @description `element-plus` 的 `table` 中 `Table-column` 属性,已拓展,额外增加 `hide` 、`slot` 、`cellRenderer` 、`headerRenderer` 四个属性
61
+ * @see {@link https://element-plus.org/zh-CN/component/table.html#table-column-%E5%B1%9E%E6%80%A7}
62
+ */
63
+ export interface MaTableColumns extends TableColumn {
64
+ hide?: boolean | CallableFunction;
65
+ children?: MaTableColumns[];
66
+ cellRender?: (data: TableColumnRenderer) => VNode | string;
67
+ headerRender?: (data: TableColumnRenderer) => VNode | string;
68
+ }
69
+ export {};
@@ -0,0 +1,77 @@
1
+ import { PaginationProps, LoadingConfig } from './index';
2
+ import { MaTableColumns } from './table-column';
3
+ import type { TableColumnCtx, SummaryMethod, ColumnStyle, ColumnCls, CellStyle, TreeNode, CellCls, Sort } from 'element-plus';
4
+ import type { TableOverflowTooltipOptions } from 'element-plus/es/components/table/src/util';
5
+ export interface ExtraOptions {
6
+ containerHeight?: string;
7
+ loading?: boolean;
8
+ loadingConfig?: LoadingConfig;
9
+ columnAlign?: 'left' | 'center' | 'right';
10
+ headerAlign?: 'left' | 'center' | 'right';
11
+ showOverflowTooltip?: boolean;
12
+ pagination?: PaginationProps;
13
+ adaption?: boolean;
14
+ adaptionOffsetBottom?: number;
15
+ }
16
+ /**
17
+ * @description `element-plus` 的 `table` 属性,未拓展
18
+ * @see {@link https://element-plus.org/zh-CN/component/table.html#table-%E5%B1%9E%E6%80%A7}
19
+ */
20
+ export interface MaTableOptions extends ExtraOptions {
21
+ data?: Array<any>;
22
+ height?: string | number;
23
+ maxHeight?: string | number;
24
+ stripe?: boolean;
25
+ border?: boolean;
26
+ size?: '' | 'large' | 'default' | 'small';
27
+ fit?: boolean;
28
+ showHeader?: boolean;
29
+ highlightCurrentRow?: boolean;
30
+ currentRowKey?: string | number;
31
+ rowClassName?: ColumnCls<any>;
32
+ rowStyle?: ColumnStyle<any>;
33
+ cellClassName?: CellCls<any>;
34
+ cellStyle?: CellStyle<any>;
35
+ headerRowClassName?: ColumnCls<any>;
36
+ headerRowStyle?: ColumnStyle<any>;
37
+ headerCellClassName?: CellCls<any>;
38
+ headerCellStyle?: CellStyle<any>;
39
+ rowKey?: string | ((row: any) => string);
40
+ emptyText?: string;
41
+ defaultExpandAll?: boolean;
42
+ expandRowKeys?: any[];
43
+ defaultSort?: Sort;
44
+ tooltipEffect?: 'dark' | 'light';
45
+ tooltipOptions?: TableOverflowTooltipOptions;
46
+ showSummary?: boolean;
47
+ sumText?: string;
48
+ summaryMethod?: SummaryMethod<any>;
49
+ spanMethod?: (data: {
50
+ row: any;
51
+ rowIndex: number;
52
+ column: TableColumnCtx<any>;
53
+ columnIndex: number;
54
+ }) => number[] | {
55
+ rowspan: number;
56
+ colspan: number;
57
+ } | undefined;
58
+ selectOnIndeterminate?: boolean;
59
+ indent?: number;
60
+ lazy?: boolean;
61
+ load?: (row: any, treeNode: TreeNode, resolve: (data: any[]) => void) => void;
62
+ treeProps?: {
63
+ hasChildren?: string;
64
+ children?: string;
65
+ };
66
+ tableLayout?: 'fixed' | 'auto';
67
+ scrollbarAlwaysOn?: boolean;
68
+ flexible?: boolean;
69
+ }
70
+ export interface MaTableSetting {
71
+ columns?: MaTableColumns[];
72
+ /**
73
+ * @description 拓展 `element-plus` 的 `table` 属性
74
+ * @see {@link https://element-plus.org/zh-CN/component/table.html#table-%E5%B1%9E%E6%80%A7}
75
+ */
76
+ options?: MaTableOptions;
77
+ }
package/package.json ADDED
@@ -0,0 +1,103 @@
1
+ {
2
+ "name": "@mineadmin/table",
3
+ "version": "1.0.0",
4
+ "packageManager": "pnpm@8.6.10",
5
+ "description": "基于element plus的表格组件,进行封装,提供方便、灵活的配置和使用方式",
6
+ "keywords": [
7
+ "@mineadmin/table",
8
+ "element-plus",
9
+ "typescript",
10
+ "el-table",
11
+ "nuxt3",
12
+ "vue3",
13
+ "vite",
14
+ "tsx"
15
+ ],
16
+ "homepage": "https://github.com/mineadmin/mineadmin-table/tree/main/#readme",
17
+ "bugs": {
18
+ "url": "https://github.com/mineadmin/mineadmin-table/issues"
19
+ },
20
+ "license": "MIT",
21
+ "author": "kanyxmo",
22
+ "repository": {
23
+ "type": "git",
24
+ "url": "git+https://github.com/mineadmin/mineadmin-table.git"
25
+ },
26
+ "publishConfig": {
27
+ "registry": "https://registry.npmjs.org/",
28
+ "access": "public"
29
+ },
30
+ "main": "dist/index.umd.js",
31
+ "module": "dist/index.es.js",
32
+ "types": "dist/index.d.ts",
33
+ "jsdelivr": "dist/index.umd.js",
34
+ "unpkg": "dist/index.umd.js",
35
+ "exports": {
36
+ ".": {
37
+ "types": "./dist/index.d.ts",
38
+ "import": "./dist/index.es.js",
39
+ "require": "./dist/index.umd.js"
40
+ },
41
+ "./volar": {
42
+ "types": "./volar.d.ts"
43
+ },
44
+ "./*": "./*"
45
+ },
46
+ "files": [
47
+ "dist",
48
+ "volar.d.ts"
49
+ ],
50
+ "style": "dist/index.css",
51
+ "sideEffects": false,
52
+ "scripts": {
53
+ "dev": "vite",
54
+ "test": "vitest run",
55
+ "build": "vite build",
56
+ "preview": "vite preview",
57
+ "lib": "vite build && vue-tsc -p tsconfig.build.json",
58
+ "lint": "prettier --write \"packages/**/*.{ts,tsx}\" \"__tests__/table.test.tsx\" \"src/*.{ts,tsx,vue}\"",
59
+ "lint:lint-staged": "lint-staged -c ./.husky/lintstagedrc.js",
60
+ "lint:pretty": "pretty-quick --staged",
61
+ "pub": "pub lib"
62
+ },
63
+ "peerDependencies": {
64
+ "element-plus": "^2.0.0"
65
+ },
66
+ "dependencies": {
67
+ "element-plus": "^2.8.0",
68
+ "vue": "^3.4.31"
69
+ },
70
+ "devDependencies": {
71
+ "@antfu/eslint-config": "^2.25.1",
72
+ "@commitlint/cli": "^18.4.3",
73
+ "@commitlint/config-conventional": "^18.4.3",
74
+ "@commitlint/types": "^18.4.3",
75
+ "@intlify/unplugin-vue-i18n": "^2.0.0",
76
+ "@rollup/plugin-terser": "^0.4.4",
77
+ "@types/node": "^20.10.5",
78
+ "@vitejs/plugin-vue": "^4.4.1",
79
+ "@vitejs/plugin-vue-jsx": "^3.0.2",
80
+ "@vue/test-utils": "^2.4.3",
81
+ "eslint": "^9.7.0",
82
+ "husky": "^8.0.3",
83
+ "jsdom": "^23.0.1",
84
+ "lint-staged": "^15.2.0",
85
+ "prettier": "^3.1.1",
86
+ "rollup": "^4.3.0",
87
+ "sass": "^1.77.8",
88
+ "sass-loader": "^13.3.2",
89
+ "typescript": "^5.3.3",
90
+ "vite": "5.3.3",
91
+ "vite-svg-loader": "^5.1.0",
92
+ "vitest": "0.34.6",
93
+ "vue-i18n": "^9.13.1",
94
+ "vue-tsc": "^2.0.26"
95
+ },
96
+ "pnpm": {
97
+ "peerDependencyRules": {
98
+ "ignoreMissing": [
99
+ "webpack"
100
+ ]
101
+ }
102
+ }
103
+ }
package/volar.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ // Auto generated component declarations
2
+ declare module "vue" {
3
+ export interface GlobalComponents {
4
+ MaTable: typeof import("@mineadmin/table")["MaTable"];
5
+ }
6
+ }
7
+
8
+ export {};