vsoft-ui 1.0.1 → 1.0.2

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.
@@ -1,396 +1,174 @@
1
- var W = Object.defineProperty;
2
- var K = (e, t, s) => t in e ? W(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s;
3
- var $ = (e, t, s) => K(e, typeof t != "symbol" ? t + "" : t, s);
4
- import Y from "element-plus";
5
- import { getCurrentInstance as q, inject as L, reactive as G, defineComponent as w, computed as m, resolveComponent as b, createBlock as S, createCommentVNode as T, openBlock as v, mergeProps as P, withCtx as p, renderSlot as y, createSlots as B, ref as J, createElementBlock as Q, Fragment as X, renderList as Z } from "vue";
6
- function E() {
7
- return q() ? L(I, null) : null;
8
- }
9
- const ee = {
10
- mounted(e, t) {
11
- const s = t.value, a = E();
12
- if (!a) {
13
- console.warn("[VS UI] Permission service not found in directive context");
14
- return;
15
- }
16
- a.check(s) || (e.style.display = "none", e.__originalDisplay = e.style.display || "");
17
- },
18
- updated(e, t) {
19
- const s = t.value, a = E();
20
- if (a)
21
- if (a.check(s)) {
22
- const l = e.__originalDisplay;
23
- e.style.display = l || "";
24
- } else
25
- e.style.display !== "none" && (e.__originalDisplay = e.style.display || ""), e.style.display = "none";
26
- }
27
- };
28
- function te(e) {
29
- e.directive("permission", ee);
30
- }
31
- const I = Symbol("permission");
32
- class N {
1
+ var I = Object.defineProperty;
2
+ var O = (n, s, e) => s in n ? I(n, s, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[s] = e;
3
+ var y = (n, s, e) => O(n, typeof s != "symbol" ? s + "" : s, e);
4
+ import { ref as S, computed as h, isRef as V, defineComponent as g, createBlock as P, createCommentVNode as v, openBlock as _, unref as C, normalizeProps as B, mergeProps as N, withCtx as m, renderSlot as l } from "vue";
5
+ import { ElButton as x, ElInput as b } from "element-plus";
6
+ class k {
33
7
  constructor() {
34
- $(this, "permissions", G(/* @__PURE__ */ new Set()));
35
- $(this, "checker", null);
36
- }
37
- /**
38
- * 设置权限列表
39
- */
40
- setPermissions(t) {
41
- this.permissions.clear(), t.forEach((s) => this.permissions.add(s));
42
- }
43
- /**
44
- * 添加权限
45
- */
46
- addPermission(t) {
47
- this.permissions.add(t);
48
- }
49
- /**
50
- * 移除权限
51
- */
52
- removePermission(t) {
53
- this.permissions.delete(t);
8
+ y(this, "permissions", []);
54
9
  }
55
10
  /**
56
- * 检查权限
11
+ * 设置用户权限
12
+ * @param permissions 权限数组
57
13
  */
58
- check(t) {
59
- return t ? this.checker ? this.checker(t) : typeof t == "string" ? this.permissions.has(t) : t.some((s) => this.permissions.has(s)) : !0;
14
+ setPermissions(s) {
15
+ this.permissions = s || [];
60
16
  }
61
17
  /**
62
- * 检查所有权限(需要全部满足)
18
+ * 获取当前用户权限
19
+ * @returns 权限数组
63
20
  */
64
- checkAll(t) {
65
- return t.every((s) => this.permissions.has(s));
21
+ getPermissions() {
22
+ return this.permissions;
66
23
  }
67
24
  /**
68
- * 设置自定义权限检查函数
25
+ * 检查是否拥有任一权限
26
+ * @param requiredPermissions 需要的权限
27
+ * @returns 是否拥有权限
69
28
  */
70
- setChecker(t) {
71
- this.checker = t;
29
+ hasAny(s) {
30
+ if (!s) return !0;
31
+ const e = Array.isArray(s) ? s : [s];
32
+ return e.length === 0 ? !1 : e.some((t) => this.permissions.includes(t));
72
33
  }
73
34
  /**
74
- * 清空权限
35
+ * 检查是否拥有所有权限
36
+ * @param requiredPermissions 需要的权限
37
+ * @returns 是否拥有权限
75
38
  */
76
- clear() {
77
- this.permissions.clear(), this.checker = null;
39
+ hasAll(s) {
40
+ if (!s) return !0;
41
+ const e = Array.isArray(s) ? s : [s];
42
+ return e.length === 0 ? !1 : e.every((t) => this.permissions.includes(t));
78
43
  }
79
44
  /**
80
- * 获取所有权限
45
+ * 检查是否拥有指定权限
46
+ * @param requiredPermissions 需要的权限
47
+ * @returns 是否拥有权限
81
48
  */
82
- getAll() {
83
- return Array.from(this.permissions);
49
+ hasPermission(s) {
50
+ return this.hasAny(s);
84
51
  }
85
- /**
86
- * 检查是否有权限
87
- */
88
- has(t) {
89
- return this.permissions.has(t);
90
- }
91
- }
92
- function O() {
93
- return new N();
94
52
  }
95
- function ne(e, t) {
96
- const s = O();
97
- t != null && t.permissions && s.setPermissions(t.permissions), t != null && t.checker && s.setChecker(t.checker), e.provide(I, s), e.config.globalProperties.$permission = s;
98
- }
99
- function C() {
100
- const e = L(I);
101
- return e || (console.warn("[VS UI] Permission service not found. Make sure to call app.use(VsUI) with permission options."), O());
53
+ const u = new k();
54
+ function $() {
55
+ const n = S(u.getPermissions()), s = (r) => {
56
+ if (!r) return !0;
57
+ const o = Array.isArray(r) ? r : [r];
58
+ return o.length === 0 ? !1 : o.some((p) => n.value.includes(p));
59
+ }, e = (r) => {
60
+ if (!r) return !0;
61
+ const o = Array.isArray(r) ? r : [r];
62
+ return o.length === 0 ? !1 : o.every((p) => n.value.includes(p));
63
+ };
64
+ return {
65
+ permissions: n,
66
+ hasPermission: (r) => s(r),
67
+ hasAnyPermission: s,
68
+ hasAllPermissions: e,
69
+ createPermissionComputed: (r, o = {}) => h(() => {
70
+ const p = V(r) ? r.value : r, d = Array.isArray(p) ? p : [p];
71
+ return o.mode === "all" ? e(d) : s(d);
72
+ }),
73
+ setPermissions: (r) => {
74
+ u.setPermissions(r), n.value = [...r];
75
+ }
76
+ };
102
77
  }
103
- const se = {
104
- name: "VsButton"
105
- }, F = /* @__PURE__ */ w({
106
- ...se,
78
+ const f = /* @__PURE__ */ g({
79
+ name: "VButton",
80
+ __name: "Button",
107
81
  props: {
108
- type: { default: "default" },
109
- size: { default: "default" },
110
- disabled: { type: Boolean, default: !1 },
111
- loading: { type: Boolean, default: !1 },
112
- permission: { default: void 0 }
82
+ permission: { default: void 0 },
83
+ permissionMode: { default: "any" }
113
84
  },
114
- emits: ["click"],
115
- setup(e, { emit: t }) {
116
- const s = e, a = t, l = C(), r = m(() => l.check(s.permission)), h = (d) => {
117
- !s.disabled && !s.loading && r.value && a("click", d);
118
- };
119
- return (d, x) => {
120
- const k = b("el-button");
121
- return r.value ? (v(), S(k, P({ key: 0 }, d.$attrs, {
122
- type: e.type,
123
- size: e.size,
124
- disabled: e.disabled || !r.value,
125
- loading: e.loading,
126
- onClick: h
127
- }), {
128
- default: p(() => [
129
- y(d.$slots, "default")
130
- ]),
131
- _: 3
132
- }, 16, ["type", "size", "disabled", "loading"])) : T("", !0);
133
- };
85
+ setup(n) {
86
+ const s = n, { hasAnyPermission: e, hasAllPermissions: t } = $(), a = h(() => {
87
+ if (s.permission === void 0 || s.permission === null)
88
+ return !0;
89
+ const i = Array.isArray(s.permission) ? s.permission : [s.permission];
90
+ return i.length === 0 ? !1 : s.permissionMode === "all" ? t(i) : e(i);
91
+ });
92
+ return (i, r) => a.value ? (_(), P(C(x), B(N({ key: 0 }, i.$attrs)), {
93
+ default: m(() => [
94
+ l(i.$slots, "default")
95
+ ]),
96
+ _: 3
97
+ }, 16)) : v("", !0);
134
98
  }
135
- }), ae = {
136
- name: "VsCard"
137
- }, A = /* @__PURE__ */ w({
138
- ...ae,
99
+ });
100
+ f.install = (n) => {
101
+ n.component(f.name || "VButton", f);
102
+ };
103
+ const c = /* @__PURE__ */ g({
104
+ name: "VInput",
105
+ __name: "Input",
139
106
  props: {
140
- header: {},
141
- shadow: { default: "always" },
142
- bodyStyle: {},
143
- permission: { default: void 0 }
107
+ permission: { default: void 0 },
108
+ permissionMode: { default: "any" }
144
109
  },
145
- setup(e) {
146
- const t = e, s = C(), a = m(() => s.check(t.permission));
147
- return (l, r) => {
148
- const h = b("el-card");
149
- return a.value ? (v(), S(h, P({ key: 0 }, l.$attrs, {
150
- header: e.header,
151
- shadow: e.shadow,
152
- "body-style": e.bodyStyle
153
- }), B({
154
- default: p(() => [
155
- y(l.$slots, "default")
156
- ]),
157
- _: 2
158
- }, [
159
- l.$slots.header ? {
160
- name: "header",
161
- fn: p(() => [
162
- y(l.$slots, "header")
163
- ]),
164
- key: "0"
165
- } : void 0
166
- ]), 1040, ["header", "shadow", "body-style"])) : T("", !0);
167
- };
110
+ setup(n) {
111
+ const s = n, { hasAnyPermission: e, hasAllPermissions: t } = $(), a = h(() => {
112
+ if (s.permission === void 0 || s.permission === null)
113
+ return !0;
114
+ const i = Array.isArray(s.permission) ? s.permission : [s.permission];
115
+ return i.length === 0 ? !1 : s.permissionMode === "all" ? t(i) : e(i);
116
+ });
117
+ return (i, r) => a.value ? (_(), P(C(b), B(N({ key: 0 }, i.$attrs)), {
118
+ prepend: m(() => [
119
+ l(i.$slots, "prepend")
120
+ ]),
121
+ append: m(() => [
122
+ l(i.$slots, "append")
123
+ ]),
124
+ prefix: m(() => [
125
+ l(i.$slots, "prefix")
126
+ ]),
127
+ suffix: m(() => [
128
+ l(i.$slots, "suffix")
129
+ ]),
130
+ _: 3
131
+ }, 16)) : v("", !0);
168
132
  }
169
- }), re = {
170
- name: "VsTable"
171
- }, H = /* @__PURE__ */ w({
172
- ...re,
173
- props: {
174
- data: { default: () => [] },
175
- columns: { default: () => [] },
176
- checkPermission: { type: Function, default: void 0 },
177
- showHeader: { type: Boolean, default: !0 },
178
- showBody: { type: Boolean, default: !0 }
133
+ });
134
+ c.install = (n) => {
135
+ n.component(c.name || "VInput", c);
136
+ };
137
+ const E = {
138
+ mounted(n, s) {
139
+ A(n, s);
179
140
  },
180
- emits: ["sortChange"],
181
- setup(e, { expose: t, emit: s }) {
182
- const a = e, l = s, r = J(), h = C(), d = m(() => a.checkPermission || ((n) => h.check(n))), x = (n) => n ? d.value(n) : !0, k = m(() => a.columns.filter((n) => n.visible === !1 ? !1 : x(n.permission))), c = m(() => a.showBody ? a.data : []), D = m(() => {
183
- const { data: n, columns: o, checkPermission: u, showHeader: V, showBody: i, ...f } = a;
184
- return f;
185
- }), z = (n) => {
186
- const {
187
- prop: o,
188
- label: u,
189
- visible: V,
190
- sortable: i,
191
- sortOrder: f,
192
- width: g,
193
- minWidth: j,
194
- align: ce,
195
- fixed: de,
196
- permission: ue,
197
- headerSlot: fe,
198
- defaultSlot: he,
199
- ...U
200
- } = n;
201
- return U;
202
- }, R = (n) => {
203
- l("sortChange", n);
204
- const o = a.columns.find((u) => u.prop === n.prop);
205
- o && o.sortable && (o.sortOrder = n.order);
206
- };
207
- return t({
208
- tableRef: r,
209
- clearSort: () => {
210
- var n;
211
- return (n = r.value) == null ? void 0 : n.clearSort();
212
- },
213
- clearFilter: (n) => {
214
- var o;
215
- return (o = r.value) == null ? void 0 : o.clearFilter(n);
216
- },
217
- doLayout: () => {
218
- var n;
219
- return (n = r.value) == null ? void 0 : n.doLayout();
220
- },
221
- scrollTo: (n, o) => {
222
- var u;
223
- return (u = r.value) == null ? void 0 : u.scrollTo(n, o);
224
- },
225
- setScrollTop: (n) => {
226
- var o;
227
- return (o = r.value) == null ? void 0 : o.setScrollTop(n);
228
- },
229
- setScrollLeft: (n) => {
230
- var o;
231
- return (o = r.value) == null ? void 0 : o.setScrollLeft(n);
232
- }
233
- }), (n, o) => {
234
- const u = b("el-table-column"), V = b("el-table");
235
- return v(), S(V, P({
236
- ref_key: "tableRef",
237
- ref: r
238
- }, D.value, {
239
- data: c.value,
240
- "show-header": e.showHeader,
241
- onSortChange: R
242
- }), B({
243
- default: p(() => [
244
- (v(!0), Q(X, null, Z(k.value, (i) => (v(), S(u, P({
245
- key: i.prop,
246
- prop: i.prop,
247
- label: i.label,
248
- width: i.width,
249
- "min-width": i.minWidth,
250
- align: i.align,
251
- fixed: i.fixed,
252
- sortable: i.sortable ? i.sortOrder !== void 0 ? "custom" : !0 : !1,
253
- "sort-orders": i.sortable ? ["ascending", "descending", null] : []
254
- }, { ref_for: !0 }, z(i)), B({ _: 2 }, [
255
- i.headerSlot ? {
256
- name: "header",
257
- fn: p(({ column: f, $index: g }) => [
258
- y(n.$slots, i.headerSlot, {
259
- column: f,
260
- index: g
261
- })
262
- ]),
263
- key: "0"
264
- } : void 0,
265
- i.defaultSlot ? {
266
- name: "default",
267
- fn: p(({ row: f, column: g, $index: j }) => [
268
- y(n.$slots, i.defaultSlot, {
269
- row: f,
270
- column: g,
271
- index: j
272
- })
273
- ]),
274
- key: "1"
275
- } : void 0
276
- ]), 1040, ["prop", "label", "width", "min-width", "align", "fixed", "sortable", "sort-orders"]))), 128))
277
- ]),
278
- _: 2
279
- }, [
280
- n.$slots.default ? {
281
- name: "default",
282
- fn: p(({ row: i, column: f, $index: g }) => [
283
- y(n.$slots, "default", {
284
- row: i,
285
- column: f,
286
- index: g
287
- })
288
- ]),
289
- key: "0"
290
- } : void 0
291
- ]), 1040, ["data", "show-header"]);
292
- };
141
+ updated(n, s) {
142
+ A(n, s);
293
143
  }
294
- }), ie = {
295
- name: "VsPagination"
296
- }, M = /* @__PURE__ */ w({
297
- ...ie,
298
- props: {
299
- currentPage: { default: 1 },
300
- pageSize: { default: 10 },
301
- total: { default: 0 },
302
- pageCount: { default: void 0 },
303
- pageSizes: { default: () => [10, 20, 30, 40, 50, 100] },
304
- layout: { default: "prev, pager, next, jumper, ->, total" },
305
- pagerCount: { default: 7 },
306
- background: { type: Boolean, default: !1 },
307
- size: { default: "default" },
308
- disabled: { type: Boolean, default: !1 },
309
- hideOnSinglePage: { type: Boolean, default: !1 },
310
- prevText: { default: "" },
311
- prevIcon: { default: void 0 },
312
- nextText: { default: "" },
313
- nextIcon: { default: void 0 },
314
- teleported: { type: Boolean, default: !0 },
315
- permission: { default: void 0 }
316
- },
317
- emits: ["update:currentPage", "update:pageSize", "current-change", "size-change", "prev-click", "next-click"],
318
- setup(e, { emit: t }) {
319
- const s = e, a = t, l = C(), r = m(() => l.check(s.permission)), h = (c) => {
320
- r.value && (a("update:currentPage", c), a("current-change", c));
321
- }, d = (c) => {
322
- r.value && (a("update:pageSize", c), a("size-change", c));
323
- }, x = (c) => {
324
- r.value && a("prev-click", c);
325
- }, k = (c) => {
326
- r.value && a("next-click", c);
327
- };
328
- return (c, D) => {
329
- const z = b("el-pagination");
330
- return r.value ? (v(), S(z, P({ key: 0 }, c.$attrs, {
331
- "current-page": e.currentPage,
332
- "page-size": e.pageSize,
333
- total: e.total,
334
- "page-count": e.pageCount,
335
- "page-sizes": e.pageSizes,
336
- layout: e.layout,
337
- "pager-count": e.pagerCount,
338
- background: e.background,
339
- size: e.size,
340
- disabled: e.disabled || !r.value,
341
- "hide-on-single-page": e.hideOnSinglePage,
342
- "prev-text": e.prevText,
343
- "prev-icon": e.prevIcon,
344
- "next-text": e.nextText,
345
- "next-icon": e.nextIcon,
346
- teleported: e.teleported,
347
- onCurrentChange: h,
348
- onSizeChange: d,
349
- onPrevClick: x,
350
- onNextClick: k
351
- }), null, 16, ["current-page", "page-size", "total", "page-count", "page-sizes", "layout", "pager-count", "background", "size", "disabled", "hide-on-single-page", "prev-text", "prev-icon", "next-text", "next-icon", "teleported"])) : T("", !0);
352
- };
144
+ };
145
+ function A(n, s) {
146
+ const { value: e, modifiers: t, arg: a } = s;
147
+ let i = !0;
148
+ if (e != null) {
149
+ const r = t.all || a === "all";
150
+ t.any || a === "any" ? i = u.hasAny(e) : r ? i = u.hasAll(e) : i = u.hasPermission(e);
353
151
  }
354
- }), oe = {
355
- VsButton: F,
356
- VsCard: A,
357
- VsTable: H,
358
- VsPagination: M
359
- }, _ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
360
- __proto__: null,
361
- PermissionService: N,
362
- VsButton: F,
363
- VsCard: A,
364
- VsPagination: M,
365
- VsTable: H,
366
- createPermissionService: O,
367
- default: oe,
368
- usePermission: C
369
- }, Symbol.toStringTag, { value: "Module" }));
370
- function le(e, t) {
371
- e.use(Y), ne(e, {
372
- permissions: t == null ? void 0 : t.permissions,
373
- checker: t == null ? void 0 : t.permissionChecker
374
- }), te(e), Object.keys(_).forEach((s) => {
375
- const a = _[s];
376
- if (a && typeof a == "object" && "name" in a) {
377
- const l = a.name, r = a;
378
- e.component(l, r);
379
- }
380
- });
152
+ n._permissionOriginalParent || (n._permissionOriginalParent = n.parentNode, n._permissionNextSibling = n.nextSibling), i ? n.parentNode !== n._permissionOriginalParent && n._permissionOriginalParent && (n._permissionNextSibling ? n._permissionOriginalParent.insertBefore(n, n._permissionNextSibling) : n._permissionOriginalParent.appendChild(n)) : n.parentNode && n.parentNode.removeChild(n);
153
+ }
154
+ function M(n) {
155
+ n.directive("permission", E);
381
156
  }
382
- const ve = {
383
- install: le,
384
- version: "1.0.0"
157
+ const w = [
158
+ f,
159
+ c
160
+ ], U = {
161
+ install(n) {
162
+ w.forEach((s) => {
163
+ s.name && n.component(s.name, s);
164
+ }), M(n);
165
+ }
385
166
  };
386
167
  export {
387
- N as PermissionService,
388
- F as VsButton,
389
- A as VsCard,
390
- M as VsPagination,
391
- H as VsTable,
392
- O as createPermissionService,
393
- ve as default,
394
- le as install,
395
- C as usePermission
168
+ f as Button,
169
+ c as Input,
170
+ U as VSoftUI,
171
+ U as default,
172
+ u as permission,
173
+ $ as usePermission
396
174
  };
@@ -1 +1 @@
1
- (function(i,u){typeof exports=="object"&&typeof module<"u"?u(exports,require("element-plus"),require("vue")):typeof define=="function"&&define.amd?define(["exports","element-plus","vue"],u):(i=typeof globalThis<"u"?globalThis:i||self,u(i.VsoftUI={},i.ElementPlus,i.Vue))})(this,function(i,u,e){"use strict";var W=Object.defineProperty;var K=(i,u,e)=>u in i?W(i,u,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[u]=e;var T=(i,u,e)=>K(i,typeof u!="symbol"?u+"":u,e);function I(){return e.getCurrentInstance()?e.inject(P,null):null}const N={mounted(t,n){const o=n.value,r=I();if(!r){console.warn("[VS UI] Permission service not found in directive context");return}r.check(o)||(t.style.display="none",t.__originalDisplay=t.style.display||"")},updated(t,n){const o=n.value,r=I();if(r)if(r.check(o)){const d=t.__originalDisplay;t.style.display=d||""}else t.style.display!=="none"&&(t.__originalDisplay=t.style.display||""),t.style.display="none"}};function E(t){t.directive("permission",N)}const P=Symbol("permission");class w{constructor(){T(this,"permissions",e.reactive(new Set));T(this,"checker",null)}setPermissions(n){this.permissions.clear(),n.forEach(o=>this.permissions.add(o))}addPermission(n){this.permissions.add(n)}removePermission(n){this.permissions.delete(n)}check(n){return n?this.checker?this.checker(n):typeof n=="string"?this.permissions.has(n):n.some(o=>this.permissions.has(o)):!0}checkAll(n){return n.every(o=>this.permissions.has(o))}setChecker(n){this.checker=n}clear(){this.permissions.clear(),this.checker=null}getAll(){return Array.from(this.permissions)}has(n){return this.permissions.has(n)}}function b(){return new w}function L(t,n){const o=b();n!=null&&n.permissions&&o.setPermissions(n.permissions),n!=null&&n.checker&&o.setChecker(n.checker),t.provide(P,o),t.config.globalProperties.$permission=o}function y(){const t=e.inject(P);return t||(console.warn("[VS UI] Permission service not found. Make sure to call app.use(VsUI) with permission options."),b())}const M={name:"VsButton"},x=e.defineComponent({...M,props:{type:{default:"default"},size:{default:"default"},disabled:{type:Boolean,default:!1},loading:{type:Boolean,default:!1},permission:{default:void 0}},emits:["click"],setup(t,{emit:n}){const o=t,r=n,d=y(),a=e.computed(()=>d.check(o.permission)),g=m=>{!o.disabled&&!o.loading&&a.value&&r("click",m)};return(m,C)=>{const S=e.resolveComponent("el-button");return a.value?(e.openBlock(),e.createBlock(S,e.mergeProps({key:0},m.$attrs,{type:t.type,size:t.size,disabled:t.disabled||!a.value,loading:t.loading,onClick:g}),{default:e.withCtx(()=>[e.renderSlot(m.$slots,"default")]),_:3},16,["type","size","disabled","loading"])):e.createCommentVNode("",!0)}}}),F={name:"VsCard"},B=e.defineComponent({...F,props:{header:{},shadow:{default:"always"},bodyStyle:{},permission:{default:void 0}},setup(t){const n=t,o=y(),r=e.computed(()=>o.check(n.permission));return(d,a)=>{const g=e.resolveComponent("el-card");return r.value?(e.openBlock(),e.createBlock(g,e.mergeProps({key:0},d.$attrs,{header:t.header,shadow:t.shadow,"body-style":t.bodyStyle}),e.createSlots({default:e.withCtx(()=>[e.renderSlot(d.$slots,"default")]),_:2},[d.$slots.header?{name:"header",fn:e.withCtx(()=>[e.renderSlot(d.$slots,"header")]),key:"0"}:void 0]),1040,["header","shadow","body-style"])):e.createCommentVNode("",!0)}}}),U={name:"VsTable"},v=e.defineComponent({...U,props:{data:{default:()=>[]},columns:{default:()=>[]},checkPermission:{type:Function,default:void 0},showHeader:{type:Boolean,default:!0},showBody:{type:Boolean,default:!0}},emits:["sortChange"],setup(t,{expose:n,emit:o}){const r=t,d=o,a=e.ref(),g=y(),m=e.computed(()=>r.checkPermission||(s=>g.check(s))),C=s=>s?m.value(s):!0,S=e.computed(()=>r.columns.filter(s=>s.visible===!1?!1:C(s.permission))),f=e.computed(()=>r.showBody?r.data:[]),_=e.computed(()=>{const{data:s,columns:c,checkPermission:h,showHeader:$,showBody:l,...p}=r;return p}),z=s=>{const{prop:c,label:h,visible:$,sortable:l,sortOrder:p,width:k,minWidth:D,align:G,fixed:J,permission:Q,headerSlot:X,defaultSlot:Z,...q}=s;return q},R=s=>{d("sortChange",s);const c=r.columns.find(h=>h.prop===s.prop);c&&c.sortable&&(c.sortOrder=s.order)};return n({tableRef:a,clearSort:()=>{var s;return(s=a.value)==null?void 0:s.clearSort()},clearFilter:s=>{var c;return(c=a.value)==null?void 0:c.clearFilter(s)},doLayout:()=>{var s;return(s=a.value)==null?void 0:s.doLayout()},scrollTo:(s,c)=>{var h;return(h=a.value)==null?void 0:h.scrollTo(s,c)},setScrollTop:s=>{var c;return(c=a.value)==null?void 0:c.setScrollTop(s)},setScrollLeft:s=>{var c;return(c=a.value)==null?void 0:c.setScrollLeft(s)}}),(s,c)=>{const h=e.resolveComponent("el-table-column"),$=e.resolveComponent("el-table");return e.openBlock(),e.createBlock($,e.mergeProps({ref_key:"tableRef",ref:a},_.value,{data:f.value,"show-header":t.showHeader,onSortChange:R}),e.createSlots({default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(S.value,l=>(e.openBlock(),e.createBlock(h,e.mergeProps({key:l.prop,prop:l.prop,label:l.label,width:l.width,"min-width":l.minWidth,align:l.align,fixed:l.fixed,sortable:l.sortable?l.sortOrder!==void 0?"custom":!0:!1,"sort-orders":l.sortable?["ascending","descending",null]:[]},{ref_for:!0},z(l)),e.createSlots({_:2},[l.headerSlot?{name:"header",fn:e.withCtx(({column:p,$index:k})=>[e.renderSlot(s.$slots,l.headerSlot,{column:p,index:k})]),key:"0"}:void 0,l.defaultSlot?{name:"default",fn:e.withCtx(({row:p,column:k,$index:D})=>[e.renderSlot(s.$slots,l.defaultSlot,{row:p,column:k,index:D})]),key:"1"}:void 0]),1040,["prop","label","width","min-width","align","fixed","sortable","sort-orders"]))),128))]),_:2},[s.$slots.default?{name:"default",fn:e.withCtx(({row:l,column:p,$index:k})=>[e.renderSlot(s.$slots,"default",{row:l,column:p,index:k})]),key:"0"}:void 0]),1040,["data","show-header"])}}}),A={name:"VsPagination"},V=e.defineComponent({...A,props:{currentPage:{default:1},pageSize:{default:10},total:{default:0},pageCount:{default:void 0},pageSizes:{default:()=>[10,20,30,40,50,100]},layout:{default:"prev, pager, next, jumper, ->, total"},pagerCount:{default:7},background:{type:Boolean,default:!1},size:{default:"default"},disabled:{type:Boolean,default:!1},hideOnSinglePage:{type:Boolean,default:!1},prevText:{default:""},prevIcon:{default:void 0},nextText:{default:""},nextIcon:{default:void 0},teleported:{type:Boolean,default:!0},permission:{default:void 0}},emits:["update:currentPage","update:pageSize","current-change","size-change","prev-click","next-click"],setup(t,{emit:n}){const o=t,r=n,d=y(),a=e.computed(()=>d.check(o.permission)),g=f=>{a.value&&(r("update:currentPage",f),r("current-change",f))},m=f=>{a.value&&(r("update:pageSize",f),r("size-change",f))},C=f=>{a.value&&r("prev-click",f)},S=f=>{a.value&&r("next-click",f)};return(f,_)=>{const z=e.resolveComponent("el-pagination");return a.value?(e.openBlock(),e.createBlock(z,e.mergeProps({key:0},f.$attrs,{"current-page":t.currentPage,"page-size":t.pageSize,total:t.total,"page-count":t.pageCount,"page-sizes":t.pageSizes,layout:t.layout,"pager-count":t.pagerCount,background:t.background,size:t.size,disabled:t.disabled||!a.value,"hide-on-single-page":t.hideOnSinglePage,"prev-text":t.prevText,"prev-icon":t.prevIcon,"next-text":t.nextText,"next-icon":t.nextIcon,teleported:t.teleported,onCurrentChange:g,onSizeChange:m,onPrevClick:C,onNextClick:S}),null,16,["current-page","page-size","total","page-count","page-sizes","layout","pager-count","background","size","disabled","hide-on-single-page","prev-text","prev-icon","next-text","next-icon","teleported"])):e.createCommentVNode("",!0)}}}),O=Object.freeze(Object.defineProperty({__proto__:null,PermissionService:w,VsButton:x,VsCard:B,VsPagination:V,VsTable:v,createPermissionService:b,default:{VsButton:x,VsCard:B,VsTable:v,VsPagination:V},usePermission:y},Symbol.toStringTag,{value:"Module"}));function j(t,n){t.use(u),L(t,{permissions:n==null?void 0:n.permissions,checker:n==null?void 0:n.permissionChecker}),E(t),Object.keys(O).forEach(o=>{const r=O[o];if(r&&typeof r=="object"&&"name"in r){const d=r.name,a=r;t.component(d,a)}})}const H={install:j,version:"1.0.0"};i.PermissionService=w,i.VsButton=x,i.VsCard=B,i.VsPagination=V,i.VsTable=v,i.createPermissionService=b,i.default=H,i.install=j,i.usePermission=y,Object.defineProperties(i,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
1
+ (function(t,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("vue"),require("element-plus")):typeof define=="function"&&define.amd?define(["exports","vue","element-plus"],s):(t=typeof globalThis<"u"?globalThis:t||self,s(t.VSoftUI={},t.Vue,t.ElementPlus))})(this,(function(t,s,m){"use strict";var V=Object.defineProperty;var N=(t,s,m)=>s in t?V(t,s,{enumerable:!0,configurable:!0,writable:!0,value:m}):t[s]=m;var g=(t,s,m)=>N(t,typeof s!="symbol"?s+"":s,m);class _{constructor(){g(this,"permissions",[])}setPermissions(n){this.permissions=n||[]}getPermissions(){return this.permissions}hasAny(n){if(!n)return!0;const o=Array.isArray(n)?n:[n];return o.length===0?!1:o.some(a=>this.permissions.includes(a))}hasAll(n){if(!n)return!0;const o=Array.isArray(n)?n:[n];return o.length===0?!1:o.every(a=>this.permissions.includes(a))}hasPermission(n){return this.hasAny(n)}}const u=new _;function h(){const e=s.ref(u.getPermissions()),n=r=>{if(!r)return!0;const l=Array.isArray(r)?r:[r];return l.length===0?!1:l.some(f=>e.value.includes(f))},o=r=>{if(!r)return!0;const l=Array.isArray(r)?r:[r];return l.length===0?!1:l.every(f=>e.value.includes(f))};return{permissions:e,hasPermission:r=>n(r),hasAnyPermission:n,hasAllPermissions:o,createPermissionComputed:(r,l={})=>s.computed(()=>{const f=s.isRef(r)?r.value:r,P=Array.isArray(f)?f:[f];return l.mode==="all"?o(P):n(P)}),setPermissions:r=>{u.setPermissions(r),e.value=[...r]}}}const c=s.defineComponent({name:"VButton",__name:"Button",props:{permission:{default:void 0},permissionMode:{default:"any"}},setup(e){const n=e,{hasAnyPermission:o,hasAllPermissions:a}=h(),p=s.computed(()=>{if(n.permission===void 0||n.permission===null)return!0;const i=Array.isArray(n.permission)?n.permission:[n.permission];return i.length===0?!1:n.permissionMode==="all"?a(i):o(i)});return(i,r)=>p.value?(s.openBlock(),s.createBlock(s.unref(m.ElButton),s.normalizeProps(s.mergeProps({key:0},i.$attrs)),{default:s.withCtx(()=>[s.renderSlot(i.$slots,"default")]),_:3},16)):s.createCommentVNode("",!0)}});c.install=e=>{e.component(c.name||"VButton",c)};const d=s.defineComponent({name:"VInput",__name:"Input",props:{permission:{default:void 0},permissionMode:{default:"any"}},setup(e){const n=e,{hasAnyPermission:o,hasAllPermissions:a}=h(),p=s.computed(()=>{if(n.permission===void 0||n.permission===null)return!0;const i=Array.isArray(n.permission)?n.permission:[n.permission];return i.length===0?!1:n.permissionMode==="all"?a(i):o(i)});return(i,r)=>p.value?(s.openBlock(),s.createBlock(s.unref(m.ElInput),s.normalizeProps(s.mergeProps({key:0},i.$attrs)),{prepend:s.withCtx(()=>[s.renderSlot(i.$slots,"prepend")]),append:s.withCtx(()=>[s.renderSlot(i.$slots,"append")]),prefix:s.withCtx(()=>[s.renderSlot(i.$slots,"prefix")]),suffix:s.withCtx(()=>[s.renderSlot(i.$slots,"suffix")]),_:3},16)):s.createCommentVNode("",!0)}});d.install=e=>{e.component(d.name||"VInput",d)};const C={mounted(e,n){y(e,n)},updated(e,n){y(e,n)}};function y(e,n){const{value:o,modifiers:a,arg:p}=n;let i=!0;if(o!=null){const r=a.all||p==="all";a.any||p==="any"?i=u.hasAny(o):r?i=u.hasAll(o):i=u.hasPermission(o)}e._permissionOriginalParent||(e._permissionOriginalParent=e.parentNode,e._permissionNextSibling=e.nextSibling),i?e.parentNode!==e._permissionOriginalParent&&e._permissionOriginalParent&&(e._permissionNextSibling?e._permissionOriginalParent.insertBefore(e,e._permissionNextSibling):e._permissionOriginalParent.appendChild(e)):e.parentNode&&e.parentNode.removeChild(e)}function S(e){e.directive("permission",C)}const B=[c,d],A={install(e){B.forEach(n=>{n.name&&e.component(n.name,n)}),S(e)}};t.Button=c,t.Input=d,t.VSoftUI=A,t.default=A,t.permission=u,t.usePermission=h,Object.defineProperties(t,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));