@mineadmin/table 1.0.35 → 1.0.39

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/dist/index.d.ts CHANGED
@@ -5,5 +5,5 @@ export declare const MaTable: {
5
5
  install(app: App, options?: MaTableInstallOptions): void;
6
6
  };
7
7
  export default MaTable;
8
- export { useTable };
8
+ export { useTable, };
9
9
  export type { MaTableInstallOptions, MaTableSetting, MaTableOptions, MaTableExpose, MaTableColumns, PaginationProps, LoadingConfig, TableColumnFilterPlacement, TableColumnSortOrders, TableColumnSortable, TableColumnRenderer, TableColumnScope, TableColumnFixed, TableColumnType, TableColumn, } from './types';
package/dist/index.es.js CHANGED
@@ -1,90 +1,96 @@
1
- import { defineComponent as $, ref as h, inject as F, onMounted as H, watch as z, onBeforeUnmount as U, withDirectives as R, createVNode as i, resolveDirective as q, Fragment as k, mergeProps as x, vShow as G, isVNode as J, getCurrentInstance as K } from "vue";
1
+ import { defineComponent as $, inject as F, ref as h, onMounted as N, watch as z, onBeforeUnmount as U, withDirectives as R, createVNode as i, resolveDirective as q, Fragment as D, mergeProps as x, vShow as G, isVNode as J, getCurrentInstance as K } from "vue";
2
2
  import { ElLoadingDirective as Q, ElTable as W, ElEmpty as X, ElPagination as Y, ElTableColumn as Z } from "element-plus";
3
- const D = $({ name: "MaTable", props: { options: { type: Object, default: () => ({}) }, columns: { type: Array, default: () => [] } }, directives: { Loading: Q }, emits: ["set-data-callback"], setup(r, { slots: e, attrs: p, emit: m, expose: w }) {
4
- const t = h(r.options), d = h(r.columns), N = F("MaTableOptions"), y = h(!1), T = h(), b = () => {
5
- const { adaptionOffsetBottom: a } = t.value, n = window.innerHeight - (a ?? 70);
6
- t.value.height = `${n}px`;
7
- }, O = h(1);
8
- H(async () => {
9
- y.value = !0;
3
+ const H = $({ name: "MaTable", props: { options: { type: Object, default: () => ({}) }, columns: { type: Array, default: () => [] } }, directives: { Loading: Q }, emits: ["set-data-callback"], setup(s, { slots: a, attrs: p, emit: c, expose: O }) {
4
+ const b = F("MaTableOptions"), n = h({});
5
+ Object.keys(s.options).map((e) => {
6
+ var t;
7
+ n.value[e] = Object.assign(((t = b == null ? void 0 : b.options) == null ? void 0 : t[e]) ?? {}, s.options[e]);
8
+ });
9
+ const d = h(s.columns), C = h(!1), T = h(), w = () => {
10
+ const { adaptionOffsetBottom: e } = n.value, t = window.innerHeight - (e ?? 70);
11
+ n.value.height = `${t}px`;
12
+ }, y = h(1);
13
+ N(async () => {
14
+ C.value = !0;
10
15
  }), z(() => {
11
- var a;
12
- return (a = t.value) == null ? void 0 : a.adaption;
13
- }, (a) => {
14
- a && (window.addEventListener("resize", b), b());
16
+ var e;
17
+ return (e = n.value) == null ? void 0 : e.adaption;
18
+ }, (e) => {
19
+ e && (window.addEventListener("resize", w), w());
15
20
  }, { immediate: !0 }), z(() => {
16
- var a;
17
- return (a = t.value) == null ? void 0 : a.adaptionOffsetBottom;
21
+ var e;
22
+ return (e = n.value) == null ? void 0 : e.adaptionOffsetBottom;
18
23
  }, () => {
19
- var a;
20
- (a = t.value) != null && a.adaption && b();
24
+ var e;
25
+ (e = n.value) != null && e.adaption && w();
21
26
  }, { immediate: !0 }), U(() => {
22
- y.value = !1, window.removeEventListener("resize", b);
27
+ C.value = !1, window.removeEventListener("resize", w);
23
28
  });
24
29
  const V = () => {
25
- var n, o;
26
- const { pagination: a } = t.value;
27
- return R(i("div", { className: "mineadmin-pagination" }, [i("div", { class: "mineadmin-pagination-left" }, [(n = e == null ? void 0 : e.pageLeft) == null ? void 0 : n.call(e)]), (((o = t.value) == null ? void 0 : o.showPagination) ?? !1) && a && i("div", { class: "mineadmin-el-page" }, [i(Y, x({ total: 0, onChange: () => {
28
- } }, a, { currentPage: O.value, "onUpdate:currentPage": (l) => O.value = l, size: (a == null ? void 0 : a.size) ?? "default", pagerCount: (a == null ? void 0 : a.pagerCount) ?? 5, layout: (a == null ? void 0 : a.layout) ?? "total, prev, pager, next, sizes, jumper" }), null)])]), [[G, e.pageLeft || a]]);
29
- }, j = (a, n) => {
30
- var M, A, B, c;
31
- if (a != null && a.hide && (a == null ? void 0 : a.hide) instanceof Function && a.hide(p) || a != null && a.hide && typeof (a == null ? void 0 : a.hide) == "boolean" && a.hide) return;
32
- const o = typeof a.prop == "function" ? a.prop(n) : a.prop;
33
- let l = { default: (s) => {
30
+ var t, o;
31
+ const { pagination: e } = n.value;
32
+ return R(i("div", { className: "mineadmin-pagination" }, [i("div", { class: "mineadmin-pagination-left" }, [(t = a == null ? void 0 : a.pageLeft) == null ? void 0 : t.call(a)]), (((o = n.value) == null ? void 0 : o.showPagination) ?? !1) && e && i("div", { class: "mineadmin-el-page" }, [i(Y, x({ total: 0, onChange: () => {
33
+ } }, e, { currentPage: y.value, "onUpdate:currentPage": (l) => y.value = l, 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)])]), [[G, a.pageLeft || e]]);
34
+ }, P = (e, t) => {
35
+ var k, m, A, B;
36
+ if (e != null && e.hide && (e == null ? void 0 : e.hide) instanceof Function && e.hide(p) || e != null && e.hide && typeof (e == null ? void 0 : e.hide) == "boolean" && e.hide) return;
37
+ const o = typeof e.prop == "function" ? e.prop(t) : e.prop;
38
+ let l = { default: (r) => {
34
39
  var u, g, f;
35
- return ((u = a == null ? void 0 : a.cellRender) == null ? void 0 : u.call(a, Object.assign(s, { options: t.value, attrs: p }))) ?? ((g = e == null ? void 0 : e[`column-${o}`]) == null ? void 0 : g.call(e, s)) ?? ((f = e == null ? void 0 : e.default) == null ? void 0 : f.call(e, s));
36
- }, header: (s) => {
40
+ return ((u = e == null ? void 0 : e.cellRender) == null ? void 0 : u.call(e, Object.assign(r, { options: n.value, attrs: p }))) ?? ((g = a == null ? void 0 : a[`column-${o}`]) == null ? void 0 : g.call(a, r)) ?? ((f = a == null ? void 0 : a.default) == null ? void 0 : f.call(a, r));
41
+ }, header: (r) => {
37
42
  var u, g, f;
38
- return ((u = a == null ? void 0 : a.headerRender) == null ? void 0 : u.call(a, Object.assign(s, { options: t.value, attrs: p }))) ?? ((g = e == null ? void 0 : e[`header-${o}`]) == null ? void 0 : g.call(e, s)) ?? ((f = e == null ? void 0 : e.header) == null ? void 0 : f.call(e, s));
39
- }, filterIcon: (s) => {
43
+ return ((u = e == null ? void 0 : e.headerRender) == null ? void 0 : u.call(e, Object.assign(r, { options: n.value, attrs: p }))) ?? ((g = a == null ? void 0 : a[`header-${o}`]) == null ? void 0 : g.call(a, r)) ?? ((f = a == null ? void 0 : a.header) == null ? void 0 : f.call(a, r));
44
+ }, filterIcon: (r) => {
40
45
  var u;
41
- return (u = e == null ? void 0 : e.filterIcon) == null ? void 0 : u.call(e, s);
46
+ return (u = a == null ? void 0 : a.filterIcon) == null ? void 0 : u.call(a, r);
42
47
  } };
43
- const { label: C, prop: _, children: v, cellRender: aa, headerRender: ea, ...S } = a;
44
- return v && v.length > 0 && (l.default = () => v == null ? void 0 : v.map(j)), i(Z, x({ key: n }, S, { label: typeof C == "function" ? C() : C, prop: o, align: (a == null ? void 0 : a.align) ?? ((M = t.value) == null ? void 0 : M.columnAlign) ?? "center", headerAlign: (a == null ? void 0 : a.align) ?? ((A = t.value) == null ? void 0 : A.columnAlign) ?? (a == null ? void 0 : a.headerAlign) ?? ((B = t.value) == null ? void 0 : B.headerAlign) ?? "center", showOverflowTooltip: (a == null ? void 0 : a.showOverflowTooltip) ?? ((c = t.value) == null ? void 0 : c.showOverflowTooltip) ?? !0 }), typeof (L = l) == "function" || Object.prototype.toString.call(L) === "[object Object]" && !J(L) ? l : { default: () => [l] });
45
- var L;
48
+ const { label: L, prop: _, children: v, cellRender: ee, headerRender: ae, ...S } = e;
49
+ return v && v.length > 0 && (l.default = () => v == null ? void 0 : v.map(P)), i(Z, x({ key: t }, S, { label: typeof L == "function" ? L() : L, prop: o, align: (e == null ? void 0 : e.align) ?? ((k = n.value) == null ? void 0 : k.columnAlign) ?? "center", headerAlign: (e == null ? void 0 : e.align) ?? ((m = n.value) == null ? void 0 : m.columnAlign) ?? (e == null ? void 0 : e.headerAlign) ?? ((A = n.value) == null ? void 0 : A.headerAlign) ?? "center", showOverflowTooltip: (e == null ? void 0 : e.showOverflowTooltip) ?? ((B = n.value) == null ? void 0 : B.showOverflowTooltip) ?? !0 }), typeof (j = l) == "function" || Object.prototype.toString.call(j) === "[object Object]" && !J(j) ? l : { default: () => [l] });
50
+ var j;
46
51
  }, I = () => {
47
- const { on: a, pagination: n, ...o } = t.value;
48
- return i(k, null, [i(W, x({ ref: T }, a, o, p), { default: () => {
52
+ const { on: e, pagination: t, ...o } = n.value;
53
+ return i(D, null, [i(W, x({ ref: T }, e, o, p), { default: () => {
49
54
  var l;
50
- return [i(k, null, [(l = d.value) == null ? void 0 : l.map(j)])];
55
+ return [i(D, null, [(l = d.value) == null ? void 0 : l.map(P)])];
51
56
  }, append: () => {
52
57
  var l;
53
- return (l = e.append) == null ? void 0 : l.call(e);
58
+ return (l = a.append) == null ? void 0 : l.call(a);
54
59
  }, empty: () => {
55
60
  var l;
56
- return ((l = e.empty) == null ? void 0 : l.call(e)) ?? i(X, null, null);
61
+ return ((l = a.empty) == null ? void 0 : l.call(a)) ?? i(X, null, null);
57
62
  } }), V()]);
58
- }, P = () => {
59
- const { loading: a, loadingConfig: n, height: o, maxHeight: l } = t.value;
60
- return R(i("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 }, [I()]), [[q("loading"), a]]);
61
- }, E = (a) => d.value = a;
62
- return w({ setData: (a) => {
63
- t.value.data = a, m("set-data-callback", a);
64
- }, setPagination: (a) => {
65
- var n;
66
- return t.value.pagination = Object.assign(((n = t.value) == null ? void 0 : n.pagination) ?? {}, a);
67
- }, setCurrentPage: (a) => O.value = a, setLoadingState: (a) => t.value.loading = a, setOptions: (a) => t.value = Object.assign(t.value, a), getOptions: () => t.value, setColumns: E, getColumns: () => d.value, appendColumn: (a) => d.value.push(a), removeColumn: (a) => E(d.value.filter((n, o) => (typeof n.prop == "function" ? n.prop(o) : n.prop) !== a)), getColumnByProp: (a) => {
68
- var n;
69
- return ((n = d.value.filter((o, l) => (typeof o.prop == "function" ? o.prop(l) : o.prop) === a)) == null ? void 0 : n[0]) ?? null;
70
- }, getElTableRef: () => T.value }), () => N.ssr ? y.value && P() : P();
63
+ }, E = () => {
64
+ const { loading: e, loadingConfig: t, height: o, maxHeight: l } = n.value;
65
+ return R(i("div", { className: "mineadmin-table", "element-loading-svg": (t == null ? void 0 : t.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": (t == null ? void 0 : t.viewBox) ?? "-9, -9, 50, 50", "element-loading-text": (t == null ? void 0 : t.text) ?? null, "element-loading-spinner": (t == null ? void 0 : t.spinner) ?? null, "element-loading-background": (t == null ? void 0 : t.spinner) ?? null, "element-loading-custom-class": (t == null ? void 0 : t.customClass) ?? null }, [I()]), [[q("loading"), e]]);
66
+ }, M = (e) => d.value = e;
67
+ return O({ setData: (e) => {
68
+ n.value.data = e, c("set-data-callback", e);
69
+ }, setPagination: (e) => {
70
+ Object.keys(e).map((t) => {
71
+ n.value.pagination[t] = e[t];
72
+ });
73
+ }, setCurrentPage: (e) => y.value = e, getCurrentPage: () => y.value, setLoadingState: (e) => n.value.loading = e, setOptions: (e) => n.value = Object.assign(n.value, e), getOptions: () => n.value, setColumns: M, getColumns: () => d.value, appendColumn: (e) => d.value.push(e), removeColumn: (e) => M(d.value.filter((t, o) => (typeof t.prop == "function" ? t.prop(o) : t.prop) !== e)), getColumnByProp: (e) => {
74
+ var t;
75
+ return ((t = d.value.filter((o, l) => (typeof o.prop == "function" ? o.prop(l) : o.prop) === e)) == null ? void 0 : t[0]) ?? null;
76
+ }, getElTableRef: () => T.value }), () => b.ssr ? C.value && E() : E();
71
77
  } });
72
- function la(r) {
73
- return new Promise(async (e, p) => {
74
- const m = K();
75
- H(async () => {
76
- if (m && m.refs[r]) {
77
- const w = m.refs[r];
78
- e({ ...w });
78
+ function le(s) {
79
+ return new Promise(async (a, p) => {
80
+ const c = K();
81
+ N(async () => {
82
+ if (c && c.refs[s]) {
83
+ const O = c.refs[s];
84
+ a({ ...O });
79
85
  } else p("[@mineadmin/table]: not found ref for ma-table component");
80
86
  });
81
87
  });
82
88
  }
83
- const oa = { install(r, e) {
84
- r.component(D.name, D), r.provide("MaTableOptions", e ?? { ssr: !1 });
89
+ const oe = { install(s, a) {
90
+ s.component(H.name, H), s.provide("MaTableOptions", a ?? { ssr: !1 });
85
91
  } };
86
92
  export {
87
- oa as MaTable,
88
- oa as default,
89
- la as useTable
93
+ oe as MaTable,
94
+ oe as default,
95
+ le as useTable
90
96
  };
package/dist/index.umd.js CHANGED
@@ -1 +1 @@
1
- (function(r,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("vue"),require("element-plus")):typeof define=="function"&&define.amd?define(["exports","vue","element-plus"],o):o((r=typeof globalThis<"u"?globalThis:r||self).MaTable={},r.Vue,r.ElementPlus)})(this,function(r,o,g){"use strict";const V=o.defineComponent({name:"MaTable",props:{options:{type:Object,default:()=>({})},columns:{type:Array,default:()=>[]}},directives:{Loading:g.ElLoadingDirective},emits:["set-data-callback"],setup(u,{slots:t,attrs:d,emit:m,expose:w}){const l=o.ref(u.options),c=o.ref(u.columns),z=o.inject("MaTableOptions"),y=o.ref(!1),L=o.ref(),b=()=>{const{adaptionOffsetBottom:e}=l.value,a=window.innerHeight-(e??70);l.value.height=`${a}px`},O=o.ref(1);o.onMounted(async()=>{y.value=!0}),o.watch(()=>{var e;return(e=l.value)==null?void 0:e.adaption},e=>{e&&(window.addEventListener("resize",b),b())},{immediate:!0}),o.watch(()=>{var e;return(e=l.value)==null?void 0:e.adaptionOffsetBottom},()=>{var e;(e=l.value)!=null&&e.adaption&&b()},{immediate:!0}),o.onBeforeUnmount(()=>{y.value=!1,window.removeEventListener("resize",b)});const D=()=>{var a,n;const{pagination:e}=l.value;return o.withDirectives(o.createVNode("div",{className:"mineadmin-pagination"},[o.createVNode("div",{class:"mineadmin-pagination-left"},[(a=t==null?void 0:t.pageLeft)==null?void 0:a.call(t)]),(((n=l.value)==null?void 0:n.showPagination)??!1)&&e&&o.createVNode("div",{class:"mineadmin-el-page"},[o.createVNode(g.ElPagination,o.mergeProps({total:0,onChange:()=>{}},e,{currentPage:O.value,"onUpdate:currentPage":i=>O.value=i,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)])]),[[o.vShow,t.pageLeft||e]])},N=(e,a)=>{var M,E,A,B;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;const n=typeof e.prop=="function"?e.prop(a):e.prop;let i={default:s=>{var p,f,h;return((p=e==null?void 0:e.cellRender)==null?void 0:p.call(e,Object.assign(s,{options:l.value,attrs:d})))??((f=t==null?void 0:t[`column-${n}`])==null?void 0:f.call(t,s))??((h=t==null?void 0:t.default)==null?void 0:h.call(t,s))},header:s=>{var p,f,h;return((p=e==null?void 0:e.headerRender)==null?void 0:p.call(e,Object.assign(s,{options:l.value,attrs:d})))??((f=t==null?void 0:t[`header-${n}`])==null?void 0:f.call(t,s))??((h=t==null?void 0:t.header)==null?void 0:h.call(t,s))},filterIcon:s=>{var p;return(p=t==null?void 0:t.filterIcon)==null?void 0:p.call(t,s)}};const{label:C,prop:k,children:v,cellRender:H,headerRender:F,...S}=e;return v&&v.length>0&&(i.default=()=>v==null?void 0:v.map(N)),o.createVNode(g.ElTableColumn,o.mergeProps({key:a},S,{label:typeof C=="function"?C():C,prop:n,align:(e==null?void 0:e.align)??((M=l.value)==null?void 0:M.columnAlign)??"center",headerAlign:(e==null?void 0:e.align)??((E=l.value)==null?void 0:E.columnAlign)??(e==null?void 0:e.headerAlign)??((A=l.value)==null?void 0:A.headerAlign)??"center",showOverflowTooltip:(e==null?void 0:e.showOverflowTooltip)??((B=l.value)==null?void 0:B.showOverflowTooltip)??!0}),typeof(T=i)=="function"||Object.prototype.toString.call(T)==="[object Object]"&&!o.isVNode(T)?i:{default:()=>[i]});var T},R=()=>{const{on:e,pagination:a,...n}=l.value;return o.createVNode(o.Fragment,null,[o.createVNode(g.ElTable,o.mergeProps({ref:L},e,n,d),{default:()=>{var i;return[o.createVNode(o.Fragment,null,[(i=c.value)==null?void 0:i.map(N)])]},append:()=>{var i;return(i=t.append)==null?void 0:i.call(t)},empty:()=>{var i;return((i=t.empty)==null?void 0:i.call(t))??o.createVNode(g.ElEmpty,null,null)}}),D()])},P=()=>{const{loading:e,loadingConfig:a,height:n,maxHeight:i}=l.value;return o.withDirectives(o.createVNode("div",{className:"mineadmin-table","element-loading-svg":(a==null?void 0:a.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":(a==null?void 0:a.viewBox)??"-9, -9, 50, 50","element-loading-text":(a==null?void 0:a.text)??null,"element-loading-spinner":(a==null?void 0:a.spinner)??null,"element-loading-background":(a==null?void 0:a.spinner)??null,"element-loading-custom-class":(a==null?void 0:a.customClass)??null},[R()]),[[o.resolveDirective("loading"),e]])},j=e=>c.value=e;return w({setData:e=>{l.value.data=e,m("set-data-callback",e)},setPagination:e=>{var a;return l.value.pagination=Object.assign(((a=l.value)==null?void 0:a.pagination)??{},e)},setCurrentPage:e=>O.value=e,setLoadingState:e=>l.value.loading=e,setOptions:e=>l.value=Object.assign(l.value,e),getOptions:()=>l.value,setColumns:j,getColumns:()=>c.value,appendColumn:e=>c.value.push(e),removeColumn:e=>j(c.value.filter((a,n)=>(typeof a.prop=="function"?a.prop(n):a.prop)!==e)),getColumnByProp:e=>{var a;return((a=c.value.filter((n,i)=>(typeof n.prop=="function"?n.prop(i):n.prop)===e))==null?void 0:a[0])??null},getElTableRef:()=>L.value}),()=>z.ssr?y.value&&P():P()}}),x={install(u,t){u.component(V.name,V),u.provide("MaTableOptions",t??{ssr:!1})}};r.MaTable=x,r.default=x,r.useTable=function(u){return new Promise(async(t,d)=>{const m=o.getCurrentInstance();o.onMounted(async()=>{if(m&&m.refs[u]){const w=m.refs[u];t({...w})}else d("[@mineadmin/table]: not found ref for ma-table component")})})},Object.defineProperties(r,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
1
+ (function(r,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((r=typeof globalThis<"u"?globalThis:r||self).MaTable={},r.Vue,r.ElementPlus)})(this,function(r,t,g){"use strict";const P=t.defineComponent({name:"MaTable",props:{options:{type:Object,default:()=>({})},columns:{type:Array,default:()=>[]}},directives:{Loading:g.ElLoadingDirective},emits:["set-data-callback"],setup(s,{slots:a,attrs:d,emit:m,expose:O}){const b=t.inject("MaTableOptions"),l=t.ref({});Object.keys(s.options).map(e=>{var o;l.value[e]=Object.assign(((o=b==null?void 0:b.options)==null?void 0:o[e])??{},s.options[e])});const c=t.ref(s.columns),C=t.ref(!1),x=t.ref(),w=()=>{const{adaptionOffsetBottom:e}=l.value,o=window.innerHeight-(e??70);l.value.height=`${o}px`},y=t.ref(1);t.onMounted(async()=>{C.value=!0}),t.watch(()=>{var e;return(e=l.value)==null?void 0:e.adaption},e=>{e&&(window.addEventListener("resize",w),w())},{immediate:!0}),t.watch(()=>{var e;return(e=l.value)==null?void 0:e.adaptionOffsetBottom},()=>{var e;(e=l.value)!=null&&e.adaption&&w()},{immediate:!0}),t.onBeforeUnmount(()=>{C.value=!1,window.removeEventListener("resize",w)});const z=()=>{var o,n;const{pagination:e}=l.value;return t.withDirectives(t.createVNode("div",{className:"mineadmin-pagination"},[t.createVNode("div",{class:"mineadmin-pagination-left"},[(o=a==null?void 0:a.pageLeft)==null?void 0:o.call(a)]),(((n=l.value)==null?void 0:n.showPagination)??!1)&&e&&t.createVNode("div",{class:"mineadmin-el-page"},[t.createVNode(g.ElPagination,t.mergeProps({total:0,onChange:()=>{}},e,{currentPage:y.value,"onUpdate:currentPage":i=>y.value=i,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)])]),[[t.vShow,a.pageLeft||e]])},L=(e,o)=>{var E,k,A,B;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;const n=typeof e.prop=="function"?e.prop(o):e.prop;let i={default:u=>{var p,f,h;return((p=e==null?void 0:e.cellRender)==null?void 0:p.call(e,Object.assign(u,{options:l.value,attrs:d})))??((f=a==null?void 0:a[`column-${n}`])==null?void 0:f.call(a,u))??((h=a==null?void 0:a.default)==null?void 0:h.call(a,u))},header:u=>{var p,f,h;return((p=e==null?void 0:e.headerRender)==null?void 0:p.call(e,Object.assign(u,{options:l.value,attrs:d})))??((f=a==null?void 0:a[`header-${n}`])==null?void 0:f.call(a,u))??((h=a==null?void 0:a.header)==null?void 0:h.call(a,u))},filterIcon:u=>{var p;return(p=a==null?void 0:a.filterIcon)==null?void 0:p.call(a,u)}};const{label:T,prop:S,children:v,cellRender:H,headerRender:F,...R}=e;return v&&v.length>0&&(i.default=()=>v==null?void 0:v.map(L)),t.createVNode(g.ElTableColumn,t.mergeProps({key:o},R,{label:typeof T=="function"?T():T,prop:n,align:(e==null?void 0:e.align)??((E=l.value)==null?void 0:E.columnAlign)??"center",headerAlign:(e==null?void 0:e.align)??((k=l.value)==null?void 0:k.columnAlign)??(e==null?void 0:e.headerAlign)??((A=l.value)==null?void 0:A.headerAlign)??"center",showOverflowTooltip:(e==null?void 0:e.showOverflowTooltip)??((B=l.value)==null?void 0:B.showOverflowTooltip)??!0}),typeof(j=i)=="function"||Object.prototype.toString.call(j)==="[object Object]"&&!t.isVNode(j)?i:{default:()=>[i]});var j},D=()=>{const{on:e,pagination:o,...n}=l.value;return t.createVNode(t.Fragment,null,[t.createVNode(g.ElTable,t.mergeProps({ref:x},e,n,d),{default:()=>{var i;return[t.createVNode(t.Fragment,null,[(i=c.value)==null?void 0:i.map(L)])]},append:()=>{var i;return(i=a.append)==null?void 0:i.call(a)},empty:()=>{var i;return((i=a.empty)==null?void 0:i.call(a))??t.createVNode(g.ElEmpty,null,null)}}),z()])},N=()=>{const{loading:e,loadingConfig:o,height:n,maxHeight:i}=l.value;return t.withDirectives(t.createVNode("div",{className:"mineadmin-table","element-loading-svg":(o==null?void 0:o.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":(o==null?void 0:o.viewBox)??"-9, -9, 50, 50","element-loading-text":(o==null?void 0:o.text)??null,"element-loading-spinner":(o==null?void 0:o.spinner)??null,"element-loading-background":(o==null?void 0:o.spinner)??null,"element-loading-custom-class":(o==null?void 0:o.customClass)??null},[D()]),[[t.resolveDirective("loading"),e]])},M=e=>c.value=e;return O({setData:e=>{l.value.data=e,m("set-data-callback",e)},setPagination:e=>{Object.keys(e).map(o=>{l.value.pagination[o]=e[o]})},setCurrentPage:e=>y.value=e,getCurrentPage:()=>y.value,setLoadingState:e=>l.value.loading=e,setOptions:e=>l.value=Object.assign(l.value,e),getOptions:()=>l.value,setColumns:M,getColumns:()=>c.value,appendColumn:e=>c.value.push(e),removeColumn:e=>M(c.value.filter((o,n)=>(typeof o.prop=="function"?o.prop(n):o.prop)!==e)),getColumnByProp:e=>{var o;return((o=c.value.filter((n,i)=>(typeof n.prop=="function"?n.prop(i):n.prop)===e))==null?void 0:o[0])??null},getElTableRef:()=>x.value}),()=>b.ssr?C.value&&N():N()}}),V={install(s,a){s.component(P.name,P),s.provide("MaTableOptions",a??{ssr:!1})}};r.MaTable=V,r.default=V,r.useTable=function(s){return new Promise(async(a,d)=>{const m=t.getCurrentInstance();t.onMounted(async()=>{if(m&&m.refs[s]){const O=m.refs[s];a({...O})}else d("[@mineadmin/table]: not found ref for ma-table component")})})},Object.defineProperties(r,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
@@ -6,11 +6,13 @@ import type { LoadingConfig } from './loading-config';
6
6
  import type { PaginationProps } from './pagination';
7
7
  interface MaTableInstallOptions {
8
8
  ssr?: boolean;
9
+ options?: MaTableOptions;
9
10
  }
10
11
  interface MaTableExpose {
11
12
  setData: (data: any[]) => void;
12
13
  setPagination: (pagination: PaginationProps) => void;
13
14
  setCurrentPage: (pager: number) => void;
15
+ getCurrentPage: () => number;
14
16
  setLoadingState: (loading: boolean) => void;
15
17
  setOptions: (opts: MaTableOptions) => void;
16
18
  getOptions: () => MaTableOptions;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mineadmin/table",
3
- "version": "1.0.35",
3
+ "version": "1.0.39",
4
4
  "packageManager": "pnpm@8.6.10",
5
5
  "description": "基于element plus的表格组件,进行封装,提供方便、灵活的配置和使用方式",
6
6
  "keywords": [