element-plus-suite 0.0.1 → 0.0.3
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/README.md +129 -0
- package/dist/index.cjs +1 -1
- package/dist/index.css +1 -0
- package/dist/index.js +66 -64
- package/dist/table-pro/index.vue.d.ts +2 -2
- package/package.json +12 -3
package/README.md
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
# Element Plus Suite
|
|
2
|
+
|
|
3
|
+
Element Plus Suite 是基于 Element Plus 二次封装的组件库,开箱即用。可以显著地提升制作 CRUD 页面的效率,轻松搬砖。
|
|
4
|
+
|
|
5
|
+
[文档](https://th74100.github.io/element-plus-suite/) · [GitHub](https://github.com/th74100/element-plus-suite)
|
|
6
|
+
|
|
7
|
+
## 特性
|
|
8
|
+
|
|
9
|
+
- **🚀 高效开发**:提供常用业务组件,减少重复代码
|
|
10
|
+
- **🎯 灵活配置**:支持 JSON 配置式和模板式,满足不同场景需求
|
|
11
|
+
- **💪 TypeScript**:提供完整的类型定义,更好的开发体验
|
|
12
|
+
- **🔥 Element Plus**:基于 Element Plus,支持主题定制
|
|
13
|
+
|
|
14
|
+
## 环境要求
|
|
15
|
+
|
|
16
|
+
- Vue 3.2 或更高版本
|
|
17
|
+
- Element Plus 2.0 或更高版本
|
|
18
|
+
- 支持 ESM 的现代构建工具
|
|
19
|
+
|
|
20
|
+
## 安装
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npm install element-plus-suite
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## 注册组件
|
|
27
|
+
|
|
28
|
+
如果项目已经全局注册 Element Plus,可以直接注册组件库:
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
import { createApp } from 'vue'
|
|
32
|
+
import ElementPlusSuite from 'element-plus-suite'
|
|
33
|
+
import App from './App.vue'
|
|
34
|
+
|
|
35
|
+
const app = createApp(App)
|
|
36
|
+
|
|
37
|
+
app.use(ElementPlusSuite)
|
|
38
|
+
app.mount('#app')
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
如果需要一起注册 Element Plus:
|
|
42
|
+
|
|
43
|
+
```ts
|
|
44
|
+
import { createApp } from 'vue'
|
|
45
|
+
import ElementPlus from 'element-plus'
|
|
46
|
+
import 'element-plus/dist/index.css'
|
|
47
|
+
import ElementPlusSuite from 'element-plus-suite'
|
|
48
|
+
import 'element-plus-suite/dist/index.css'
|
|
49
|
+
import App from './App.vue'
|
|
50
|
+
|
|
51
|
+
const app = createApp(App)
|
|
52
|
+
|
|
53
|
+
app.use(ElementPlus)
|
|
54
|
+
app.use(ElementPlusSuite)
|
|
55
|
+
app.mount('#app')
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
也可以按需导入:
|
|
59
|
+
|
|
60
|
+
```ts
|
|
61
|
+
import { ElTablePro } from 'element-plus-suite'
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## 快速开始
|
|
65
|
+
|
|
66
|
+
```vue
|
|
67
|
+
<script setup lang="ts">
|
|
68
|
+
import { ElTablePro, type TableProColumn } from 'element-plus-suite'
|
|
69
|
+
|
|
70
|
+
interface User {
|
|
71
|
+
id: number
|
|
72
|
+
name: string
|
|
73
|
+
email: string
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const columns: TableProColumn<User>[] = [
|
|
77
|
+
{ prop: 'name', label: '姓名', minWidth: 140 },
|
|
78
|
+
{ prop: 'email', label: '邮箱', minWidth: 220 },
|
|
79
|
+
]
|
|
80
|
+
|
|
81
|
+
const dataSource: User[] = [
|
|
82
|
+
{ id: 1, name: '林晓', email: 'linxiao@example.com' },
|
|
83
|
+
{ id: 2, name: '陈默', email: 'chenmo@example.com' },
|
|
84
|
+
]
|
|
85
|
+
</script>
|
|
86
|
+
|
|
87
|
+
<template>
|
|
88
|
+
<ElTablePro
|
|
89
|
+
:columns="columns"
|
|
90
|
+
:data="dataSource"
|
|
91
|
+
row-key="id"
|
|
92
|
+
:pagination="false"
|
|
93
|
+
/>
|
|
94
|
+
</template>
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## 远程数据
|
|
98
|
+
|
|
99
|
+
将 `data` 换成 `request` 即可接入远程数据。`request` 接收当前分页参数和取消信号,并返回统一的数据结构:
|
|
100
|
+
|
|
101
|
+
```ts
|
|
102
|
+
import type { TableProRequest } from 'element-plus-suite'
|
|
103
|
+
|
|
104
|
+
const requestUsers: TableProRequest<User> = async ({
|
|
105
|
+
page,
|
|
106
|
+
pageSize,
|
|
107
|
+
signal,
|
|
108
|
+
}) => {
|
|
109
|
+
const params = new URLSearchParams({
|
|
110
|
+
page: String(page ?? 1),
|
|
111
|
+
pageSize: String(pageSize ?? 20),
|
|
112
|
+
})
|
|
113
|
+
const response = await fetch(`/api/users?${params}`, { signal })
|
|
114
|
+
const payload = await response.json()
|
|
115
|
+
|
|
116
|
+
return {
|
|
117
|
+
data: payload.list,
|
|
118
|
+
total: payload.total,
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
接口的原始返回结构在 `request` 内部适配即可,组件只接收 `data` 和 `total`。
|
|
124
|
+
|
|
125
|
+
更多用法请查看[文档](https://th74100.github.io/element-plus-suite/)。
|
|
126
|
+
|
|
127
|
+
## License
|
|
128
|
+
|
|
129
|
+
MIT
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("vue"),b=require("element-plus");function M(e,t){return e.flatMap(r=>{if(r.visible===!1)return[];const{visible:
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("vue"),b=require("element-plus");function M(e,t){return e.flatMap(r=>{if(r.visible===!1)return[];const{visible:u,slot:c,headerSlot:s,render:l,headerRender:n,autoMerge:a,children:d,...m}=r,p={...m},g={},h=c?t[c]:void 0,y=s?t[s]:void 0;if(h?g.default=h:l&&(g.default=f=>l({row:f.row,column:f.column,$index:f.$index})),y?g.header=y:n&&(g.header=f=>n({column:f.column,$index:f.$index,store:f.store,_self:f._self})),d?.length){const f={default:()=>M(d,t)};return g.header&&(f.header=g.header),[o.h(b.ElTableColumn,p,f)]}return[o.h(b.ElTableColumn,p,Object.keys(g).length?g:void 0)]})}function z(e){return e.prop??e.property}function x(e,t){if(e===null||typeof e!="object")return;const r=e;if(Object.prototype.hasOwnProperty.call(r,t))return r[t];if(!t.includes("."))return;let u=r;for(const c of t.split(".")){if(u===null||typeof u!="object")return;u=u[c]}return u}function q(e){return e.flatMap(t=>t.visible===!1?[]:t.children?.length?q(t.children):[t])}function C(e,t=[]){const r=q(e),u=new Map;for(const n of r){const a=z(n);a&&!u.has(a)&&u.set(a,n)}const c=new Set,s=[],l=n=>{!n||c.has(n)||!u.has(n)||(c.add(n),s.push({key:n,getValue:a=>x(a,n)}))};return t.forEach(l),r.forEach(n=>{n.autoMerge&&l(z(n))}),s}function D(e,t){const r=e.length,u=new Map(t.map(l=>[l.key,Array.from({length:r},()=>1)]));if(!r||!t.length)return u;const c=e.map(l=>t.map(n=>n.getValue(l))),s=t.map(()=>0);for(let l=1;l<=r;l+=1){let n=!0;for(let a=0;a<t.length;a+=1){const d=l<r&&n&&c[l][a]===c[l-1][a];if(!d){const m=u.get(t[a].key),p=s[a],g=l-p;m[p]=g;for(let h=p+1;h<l;h+=1)m[h]=0;s[a]=l}n=d}}return u}function I(e,t="children"){return e.some(r=>{if(r===null||typeof r!="object")return!1;const u=r[t];return Array.isArray(u)&&u.length>0})}function L(e){const t=o.computed(()=>C(e.columns(),e.mergeFields())),r=o.computed(()=>t.value.length?e.tableRef.value?.store?.states?.data?.value??e.data.value:e.data.value),u=o.computed(()=>{if(!t.value.length||e.lazy())return new Map;const s=e.treeProps()?.children??"children",l=r.value;return I(l,s)?new Map:D(l,t.value)});return{spanMethod:o.computed(()=>{const s=e.userSpanMethod();return t.value.length?l=>{const n=s?.(l);if(n!==void 0)return n;const a=l.column.property,d=a?u.value.get(a)?.[l.rowIndex]:void 0;if(!(d===void 0||d===1))return{rowspan:d,colspan:1}}:s}),spanMap:u}}const T={page:1,pageSize:20,pageSizes:[10,20,50,100],layout:"total, sizes, prev, pager, next, jumper",background:!0};function _(e){return e===!1?null:{...T,...e===!0?{}:e??{}}}function O(e){const t=o.computed(()=>_(e())),r=o.shallowRef(t.value?.page??1),u=o.shallowRef(t.value?.pageSize??20);o.watch(()=>t.value?.page,n=>{n!==void 0&&(r.value=n)}),o.watch(()=>t.value?.pageSize,n=>{n!==void 0&&(u.value=n)});const c=o.computed(()=>t.value?r.value:null),s=o.computed(()=>t.value?u.value:null);function l(n){u.value=n,r.value=1}return{enabled:o.computed(()=>t.value!=null),config:t,currentPage:r,pageSize:u,requestPage:c,requestPageSize:s,setPageSize:l}}function j(e){const t=o.shallowRef(!1);let r=null,u=0;async function c(){const l=e.request();if(!l)return;r?.abort(),r=new AbortController;const n=++u,a=r;t.value=!0;try{const d=await l({page:e.page(),pageSize:e.pageSize(),signal:a.signal});if(a.signal.aborted||n!==u)return;e.onData?.(d),e.onLoaded?.(d)}catch(d){if(a.signal.aborted||n!==u)return;e.onError?.(d)}finally{n===u&&(t.value=!1)}}function s(){r?.abort(),u+=1,t.value=!1}return o.onBeforeUnmount(s),{loading:t,load:c,cancel:s}}const A=o.defineComponent({name:"ElTablePro",inheritAttrs:!1,props:{columns:{type:Array,default:()=>[]},request:{type:Function,default:void 0},pagination:{type:[Boolean,Object],default:!0},mergeFields:{type:Array,default:()=>[]},data:{type:Array,default:()=>[]},rowKey:{type:[String,Function],required:!0}},emits:{loaded:e=>!0,error:e=>!0},setup(e,{attrs:t,emit:r,expose:u}){const c=o.useSlots(),s=o.shallowRef(null),l=o.shallowRef([]),n=o.shallowRef(0),a=O(()=>e.pagination),d=o.computed(()=>{const i=e.rowKey;return typeof i=="function"?v=>String(i(v)):i}),{loading:m,load:p,cancel:g}=j({request:()=>e.request,page:()=>a.requestPage.value,pageSize:()=>a.requestPageSize.value,onData:i=>{l.value=i.data,n.value=i.total},onLoaded:i=>r("loaded",i),onError:i=>r("error",i)}),h=o.computed(()=>m.value),y=o.computed(()=>{if(e.request)return l.value;if(!e.data)return[];if(!a.config.value)return e.data;const i=(a.currentPage.value-1)*a.pageSize.value;return e.data.slice(i,i+a.pageSize.value)}),f=o.computed(()=>e.request?n.value:e.data?.length??0),{spanMethod:R}=L({tableRef:s,columns:()=>e.columns,data:y,mergeFields:()=>e.mergeFields,userSpanMethod:()=>t.spanMethod,treeProps:()=>t.treeProps,lazy:()=>!!t.lazy});async function S(i){i?.page!==void 0&&(a.currentPage.value=i.page),await p()}o.watch(()=>e.request,i=>{l.value=[],n.value=0,i?S():g()}),o.watch(()=>[a.requestPage.value,a.requestPageSize.value],()=>{e.request&&S()});const F=new Proxy({},{get(i,v){if(v==="reload")return S;const P=s.value;if(!P)return;const w=P[v];return typeof w=="function"?w.bind(P):w},has(i,v){return v==="reload"?!0:s.value!=null&&v in s.value}});return u(F),o.onMounted(()=>{e.request&&S()}),()=>{const i=o.h(b.ElTable,{...t,ref:s,data:y.value,rowKey:d.value,spanMethod:R.value},{default:()=>M(e.columns,c),empty:c.empty,append:c.append});return o.h("div",{class:"el-table-pro"},[o.withDirectives(i,[[b.vLoading,h.value]]),a.enabled.value?o.h(b.ElPagination,{currentPage:a.currentPage.value,pageSize:a.pageSize.value,total:f.value,pageSizes:[...a.config.value?.pageSizes??[]],layout:a.config.value?.layout,background:a.config.value?.background,"onUpdate:currentPage":v=>{a.currentPage.value=v},"onUpdate:pageSize":v=>{a.setPageSize(v)}}):null])}}}),k=[A];function E(e){k.forEach(t=>{const r=t.name;r&&e.component(r,t)})}const B={install:E};exports.ElTablePro=A;exports.TABLE_PRO_DEFAULT_PAGINATION=T;exports.default=B;exports.install=E;exports.normalizePagination=_;
|
package/dist/index.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.el-table-pro{display:flex;flex-direction:column;gap:16px;min-width:0}
|
package/dist/index.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { h as
|
|
1
|
+
import { h as S, computed as g, shallowRef as m, watch as z, onBeforeUnmount as F, defineComponent as C, useSlots as D, onMounted as R, withDirectives as j } from "vue";
|
|
2
2
|
import { ElTableColumn as q, ElTable as I, vLoading as L, ElPagination as k } from "element-plus";
|
|
3
3
|
function T(e, t) {
|
|
4
4
|
return e.flatMap((r) => {
|
|
5
5
|
if (r.visible === !1) return [];
|
|
6
6
|
const {
|
|
7
|
-
visible:
|
|
7
|
+
visible: u,
|
|
8
8
|
slot: s,
|
|
9
9
|
headerSlot: o,
|
|
10
|
-
render:
|
|
10
|
+
render: l,
|
|
11
11
|
headerRender: n,
|
|
12
12
|
autoMerge: a,
|
|
13
13
|
children: c,
|
|
14
14
|
...y
|
|
15
15
|
} = r, p = { ...y }, f = {}, h = s ? t[s] : void 0, b = o ? t[o] : void 0;
|
|
16
|
-
if (h ? f.default = h :
|
|
16
|
+
if (h ? f.default = h : l && (f.default = (d) => l({
|
|
17
17
|
row: d.row,
|
|
18
18
|
column: d.column,
|
|
19
19
|
$index: d.$index
|
|
@@ -26,10 +26,10 @@ function T(e, t) {
|
|
|
26
26
|
const d = {
|
|
27
27
|
default: () => T(c, t)
|
|
28
28
|
};
|
|
29
|
-
return f.header && (d.header = f.header), [
|
|
29
|
+
return f.header && (d.header = f.header), [S(q, p, d)];
|
|
30
30
|
}
|
|
31
31
|
return [
|
|
32
|
-
|
|
32
|
+
S(
|
|
33
33
|
q,
|
|
34
34
|
p,
|
|
35
35
|
Object.keys(f).length ? f : void 0
|
|
@@ -46,82 +46,82 @@ function O(e, t) {
|
|
|
46
46
|
if (Object.prototype.hasOwnProperty.call(r, t))
|
|
47
47
|
return r[t];
|
|
48
48
|
if (!t.includes(".")) return;
|
|
49
|
-
let
|
|
49
|
+
let u = r;
|
|
50
50
|
for (const s of t.split(".")) {
|
|
51
|
-
if (
|
|
52
|
-
|
|
51
|
+
if (u === null || typeof u != "object") return;
|
|
52
|
+
u = u[s];
|
|
53
53
|
}
|
|
54
|
-
return
|
|
54
|
+
return u;
|
|
55
55
|
}
|
|
56
56
|
function _(e) {
|
|
57
57
|
return e.flatMap((t) => t.visible === !1 ? [] : t.children?.length ? _(t.children) : [t]);
|
|
58
58
|
}
|
|
59
59
|
function V(e, t = []) {
|
|
60
|
-
const r = _(e),
|
|
60
|
+
const r = _(e), u = /* @__PURE__ */ new Map();
|
|
61
61
|
for (const n of r) {
|
|
62
62
|
const a = x(n);
|
|
63
|
-
a && !
|
|
63
|
+
a && !u.has(a) && u.set(a, n);
|
|
64
64
|
}
|
|
65
|
-
const s = /* @__PURE__ */ new Set(), o = [],
|
|
66
|
-
!n || s.has(n) || !
|
|
65
|
+
const s = /* @__PURE__ */ new Set(), o = [], l = (n) => {
|
|
66
|
+
!n || s.has(n) || !u.has(n) || (s.add(n), o.push({
|
|
67
67
|
key: n,
|
|
68
68
|
getValue: (a) => O(a, n)
|
|
69
69
|
}));
|
|
70
70
|
};
|
|
71
|
-
return t.forEach(
|
|
72
|
-
n.autoMerge &&
|
|
71
|
+
return t.forEach(l), r.forEach((n) => {
|
|
72
|
+
n.autoMerge && l(x(n));
|
|
73
73
|
}), o;
|
|
74
74
|
}
|
|
75
75
|
function B(e, t) {
|
|
76
|
-
const r = e.length,
|
|
77
|
-
t.map((
|
|
76
|
+
const r = e.length, u = new Map(
|
|
77
|
+
t.map((l) => [l.key, Array.from({ length: r }, () => 1)])
|
|
78
78
|
);
|
|
79
|
-
if (!r || !t.length) return
|
|
80
|
-
const s = e.map((
|
|
81
|
-
for (let
|
|
79
|
+
if (!r || !t.length) return u;
|
|
80
|
+
const s = e.map((l) => t.map((n) => n.getValue(l))), o = t.map(() => 0);
|
|
81
|
+
for (let l = 1; l <= r; l += 1) {
|
|
82
82
|
let n = !0;
|
|
83
83
|
for (let a = 0; a < t.length; a += 1) {
|
|
84
|
-
const c =
|
|
84
|
+
const c = l < r && n && s[l][a] === s[l - 1][a];
|
|
85
85
|
if (!c) {
|
|
86
|
-
const y =
|
|
86
|
+
const y = u.get(t[a].key), p = o[a], f = l - p;
|
|
87
87
|
y[p] = f;
|
|
88
|
-
for (let h = p + 1; h <
|
|
88
|
+
for (let h = p + 1; h < l; h += 1)
|
|
89
89
|
y[h] = 0;
|
|
90
|
-
o[a] =
|
|
90
|
+
o[a] = l;
|
|
91
91
|
}
|
|
92
92
|
n = c;
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
|
-
return
|
|
95
|
+
return u;
|
|
96
96
|
}
|
|
97
97
|
function K(e, t = "children") {
|
|
98
98
|
return e.some((r) => {
|
|
99
99
|
if (r === null || typeof r != "object") return !1;
|
|
100
|
-
const
|
|
101
|
-
return Array.isArray(
|
|
100
|
+
const u = r[t];
|
|
101
|
+
return Array.isArray(u) && u.length > 0;
|
|
102
102
|
});
|
|
103
103
|
}
|
|
104
104
|
function U(e) {
|
|
105
105
|
const t = g(
|
|
106
106
|
() => V(e.columns(), e.mergeFields())
|
|
107
|
-
), r = g(() => t.value.length ? e.tableRef.value?.store?.states?.data?.value ?? e.data.value : e.data.value),
|
|
107
|
+
), r = g(() => t.value.length ? e.tableRef.value?.store?.states?.data?.value ?? e.data.value : e.data.value), u = g(() => {
|
|
108
108
|
if (!t.value.length || e.lazy())
|
|
109
109
|
return /* @__PURE__ */ new Map();
|
|
110
|
-
const o = e.treeProps()?.children ?? "children",
|
|
111
|
-
return K(
|
|
110
|
+
const o = e.treeProps()?.children ?? "children", l = r.value;
|
|
111
|
+
return K(l, o) ? /* @__PURE__ */ new Map() : B(l, t.value);
|
|
112
112
|
});
|
|
113
113
|
return {
|
|
114
114
|
spanMethod: g(() => {
|
|
115
115
|
const o = e.userSpanMethod();
|
|
116
|
-
return t.value.length ? (
|
|
117
|
-
const n = o?.(
|
|
116
|
+
return t.value.length ? (l) => {
|
|
117
|
+
const n = o?.(l);
|
|
118
118
|
if (n !== void 0) return n;
|
|
119
|
-
const a =
|
|
119
|
+
const a = l.column.property, c = a ? u.value.get(a)?.[l.rowIndex] : void 0;
|
|
120
120
|
if (!(c === void 0 || c === 1))
|
|
121
121
|
return { rowspan: c, colspan: 1 };
|
|
122
122
|
} : o;
|
|
123
123
|
}),
|
|
124
|
-
spanMap:
|
|
124
|
+
spanMap: u
|
|
125
125
|
};
|
|
126
126
|
}
|
|
127
127
|
const $ = {
|
|
@@ -138,7 +138,7 @@ function N(e) {
|
|
|
138
138
|
};
|
|
139
139
|
}
|
|
140
140
|
function G(e) {
|
|
141
|
-
const t = g(() => N(e())), r = m(t.value?.page ?? 1),
|
|
141
|
+
const t = g(() => N(e())), r = m(t.value?.page ?? 1), u = m(t.value?.pageSize ?? 20);
|
|
142
142
|
z(
|
|
143
143
|
() => t.value?.page,
|
|
144
144
|
(n) => {
|
|
@@ -147,56 +147,56 @@ function G(e) {
|
|
|
147
147
|
), z(
|
|
148
148
|
() => t.value?.pageSize,
|
|
149
149
|
(n) => {
|
|
150
|
-
n !== void 0 && (
|
|
150
|
+
n !== void 0 && (u.value = n);
|
|
151
151
|
}
|
|
152
152
|
);
|
|
153
153
|
const s = g(
|
|
154
154
|
() => t.value ? r.value : null
|
|
155
155
|
), o = g(
|
|
156
|
-
() => t.value ?
|
|
156
|
+
() => t.value ? u.value : null
|
|
157
157
|
);
|
|
158
|
-
function
|
|
159
|
-
|
|
158
|
+
function l(n) {
|
|
159
|
+
u.value = n, r.value = 1;
|
|
160
160
|
}
|
|
161
161
|
return {
|
|
162
162
|
// 模板直接依赖这个布尔值,避免访问可能为 null 的配置。
|
|
163
163
|
enabled: g(() => t.value != null),
|
|
164
164
|
config: t,
|
|
165
165
|
currentPage: r,
|
|
166
|
-
pageSize:
|
|
166
|
+
pageSize: u,
|
|
167
167
|
requestPage: s,
|
|
168
168
|
requestPageSize: o,
|
|
169
|
-
setPageSize:
|
|
169
|
+
setPageSize: l
|
|
170
170
|
};
|
|
171
171
|
}
|
|
172
172
|
function H(e) {
|
|
173
173
|
const t = m(!1);
|
|
174
|
-
let r = null,
|
|
174
|
+
let r = null, u = 0;
|
|
175
175
|
async function s() {
|
|
176
|
-
const
|
|
177
|
-
if (!
|
|
176
|
+
const l = e.request();
|
|
177
|
+
if (!l) return;
|
|
178
178
|
r?.abort(), r = new AbortController();
|
|
179
|
-
const n = ++
|
|
179
|
+
const n = ++u, a = r;
|
|
180
180
|
t.value = !0;
|
|
181
181
|
try {
|
|
182
|
-
const c = await
|
|
182
|
+
const c = await l({
|
|
183
183
|
page: e.page(),
|
|
184
184
|
pageSize: e.pageSize(),
|
|
185
185
|
signal: a.signal
|
|
186
186
|
});
|
|
187
|
-
if (a.signal.aborted || n !==
|
|
187
|
+
if (a.signal.aborted || n !== u)
|
|
188
188
|
return;
|
|
189
189
|
e.onData?.(c), e.onLoaded?.(c);
|
|
190
190
|
} catch (c) {
|
|
191
|
-
if (a.signal.aborted || n !==
|
|
191
|
+
if (a.signal.aborted || n !== u)
|
|
192
192
|
return;
|
|
193
193
|
e.onError?.(c);
|
|
194
194
|
} finally {
|
|
195
|
-
n ===
|
|
195
|
+
n === u && (t.value = !1);
|
|
196
196
|
}
|
|
197
197
|
}
|
|
198
198
|
function o() {
|
|
199
|
-
r?.abort(),
|
|
199
|
+
r?.abort(), u += 1, t.value = !1;
|
|
200
200
|
}
|
|
201
201
|
return F(o), { loading: t, load: s, cancel: o };
|
|
202
202
|
}
|
|
@@ -236,9 +236,9 @@ const J = /* @__PURE__ */ C({
|
|
|
236
236
|
setup(e, {
|
|
237
237
|
attrs: t,
|
|
238
238
|
emit: r,
|
|
239
|
-
expose:
|
|
239
|
+
expose: u
|
|
240
240
|
}) {
|
|
241
|
-
const s = D(), o = m(null),
|
|
241
|
+
const s = D(), o = m(null), l = m([]), n = m(0), a = G(() => e.pagination), c = g(() => {
|
|
242
242
|
const i = e.rowKey;
|
|
243
243
|
return typeof i == "function" ? (v) => String(i(v)) : i;
|
|
244
244
|
}), {
|
|
@@ -250,12 +250,12 @@ const J = /* @__PURE__ */ C({
|
|
|
250
250
|
page: () => a.requestPage.value,
|
|
251
251
|
pageSize: () => a.requestPageSize.value,
|
|
252
252
|
onData: (i) => {
|
|
253
|
-
|
|
253
|
+
l.value = i.data, n.value = i.total;
|
|
254
254
|
},
|
|
255
255
|
onLoaded: (i) => r("loaded", i),
|
|
256
256
|
onError: (i) => r("error", i)
|
|
257
257
|
}), h = g(() => y.value), b = g(() => {
|
|
258
|
-
if (e.request) return
|
|
258
|
+
if (e.request) return l.value;
|
|
259
259
|
if (!e.data) return [];
|
|
260
260
|
if (!a.config.value) return e.data;
|
|
261
261
|
const i = (a.currentPage.value - 1) * a.pageSize.value;
|
|
@@ -271,17 +271,17 @@ const J = /* @__PURE__ */ C({
|
|
|
271
271
|
treeProps: () => t.treeProps,
|
|
272
272
|
lazy: () => !!t.lazy
|
|
273
273
|
});
|
|
274
|
-
async function
|
|
274
|
+
async function P(i) {
|
|
275
275
|
i?.page !== void 0 && (a.currentPage.value = i.page), await p();
|
|
276
276
|
}
|
|
277
277
|
z(() => e.request, (i) => {
|
|
278
|
-
|
|
278
|
+
l.value = [], n.value = 0, i ? P() : f();
|
|
279
279
|
}), z(() => [a.requestPage.value, a.requestPageSize.value], () => {
|
|
280
|
-
e.request &&
|
|
280
|
+
e.request && P();
|
|
281
281
|
});
|
|
282
282
|
const E = new Proxy({}, {
|
|
283
283
|
get(i, v) {
|
|
284
|
-
if (v === "reload") return
|
|
284
|
+
if (v === "reload") return P;
|
|
285
285
|
const M = o.value;
|
|
286
286
|
if (!M) return;
|
|
287
287
|
const w = M[v];
|
|
@@ -291,10 +291,10 @@ const J = /* @__PURE__ */ C({
|
|
|
291
291
|
return v === "reload" ? !0 : o.value != null && v in o.value;
|
|
292
292
|
}
|
|
293
293
|
});
|
|
294
|
-
return
|
|
295
|
-
e.request &&
|
|
294
|
+
return u(E), R(() => {
|
|
295
|
+
e.request && P();
|
|
296
296
|
}), () => {
|
|
297
|
-
const i =
|
|
297
|
+
const i = S(I, {
|
|
298
298
|
...t,
|
|
299
299
|
ref: o,
|
|
300
300
|
data: b.value,
|
|
@@ -305,7 +305,9 @@ const J = /* @__PURE__ */ C({
|
|
|
305
305
|
empty: s.empty,
|
|
306
306
|
append: s.append
|
|
307
307
|
});
|
|
308
|
-
return
|
|
308
|
+
return S("div", {
|
|
309
|
+
class: "el-table-pro"
|
|
310
|
+
}, [j(i, [[L, h.value]]), a.enabled.value ? S(k, {
|
|
309
311
|
currentPage: a.currentPage.value,
|
|
310
312
|
pageSize: a.pageSize.value,
|
|
311
313
|
total: d.value,
|
|
@@ -318,7 +320,7 @@ const J = /* @__PURE__ */ C({
|
|
|
318
320
|
"onUpdate:pageSize": (v) => {
|
|
319
321
|
a.setPageSize(v);
|
|
320
322
|
}
|
|
321
|
-
}) : null];
|
|
323
|
+
}) : null]);
|
|
322
324
|
};
|
|
323
325
|
}
|
|
324
326
|
}), Q = [J];
|
|
@@ -25,9 +25,9 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
|
|
|
25
25
|
type: PropType<string | ((row: any) => string | number)>;
|
|
26
26
|
required: true;
|
|
27
27
|
};
|
|
28
|
-
}>, () =>
|
|
28
|
+
}>, () => import('vue').VNode<import('vue').RendererNode, import('vue').RendererElement, {
|
|
29
29
|
[key: string]: any;
|
|
30
|
-
}
|
|
30
|
+
}>, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
31
31
|
loaded: (_result: TableProRequestResult<any>) => true;
|
|
32
32
|
error: (_error: unknown) => true;
|
|
33
33
|
}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
|
package/package.json
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "element-plus-suite",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"description": "Unofficial enhancement components for Element Plus",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/th74100/element-plus-suite.git"
|
|
9
|
+
},
|
|
10
|
+
"homepage": "https://th74100.github.io/element-plus-suite/",
|
|
5
11
|
"type": "module",
|
|
6
|
-
"sideEffects":
|
|
12
|
+
"sideEffects": [
|
|
13
|
+
"**/*.css"
|
|
14
|
+
],
|
|
7
15
|
"files": [
|
|
8
16
|
"dist"
|
|
9
17
|
],
|
|
@@ -15,7 +23,8 @@
|
|
|
15
23
|
"types": "./dist/index.d.ts",
|
|
16
24
|
"import": "./dist/index.js",
|
|
17
25
|
"require": "./dist/index.cjs"
|
|
18
|
-
}
|
|
26
|
+
},
|
|
27
|
+
"./dist/index.css": "./dist/index.css"
|
|
19
28
|
},
|
|
20
29
|
"scripts": {
|
|
21
30
|
"build": "vite build",
|