@vft/directives 0.0.29 → 0.0.30
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/cjs/click-out-side.cjs +1 -1
- package/dist/cjs/permission.cjs +1 -1
- package/dist/es/click-out-side.js +19 -14
- package/dist/es/permission.js +8 -9
- package/package.json +5 -4
- package/src/index.ts +0 -15
@@ -1 +1 @@
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const d=require("@vft/utils"),s=new Map;if(d.isClient){let e;document.addEventListener("mousedown",t=>e=t),document.addEventListener("mouseup",t=>{if(e){for(const n of s.values())for(const{documentHandler:o}of n)o(t,e);e=void 0}})}function i(e,t){let n=[];return d.isArray(t.arg)?n=t.arg:d.isElement(t.arg)&&n.push(t.arg),function(o,a){const c=t.instance.popperRef,r=o.target,u=a?.target,l=!t||!t.instance,f=!r||!u,p=e.contains(r)||e.contains(u),m=e===r,g=n.length&&n.some(v=>v?.contains(r))||n.length&&n.includes(u),h=c&&(c.contains(r)||c.contains(u));l||f||p||m||g||h||t.value(o,a)}}const E={beforeMount(e,t){s.has(e)||s.set(e,[]),s.get(e).push({documentHandler:i(e,t),bindingFn:t.value})},updated(e,t){s.has(e)||s.set(e,[]);const n=s.get(e),o=n.findIndex(c=>c.bindingFn===t.oldValue),a={documentHandler:i(e,t),bindingFn:t.value};o>=0?n.splice(o,1,a):n.push(a)},unmounted(e){s.delete(e)}};exports.default=E;
|
package/dist/cjs/permission.cjs
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("@vft/use"),n=require("vue");function o(e,i,t){const{hasPermission:r}=u.usePermission(t||n.ref([])),s=i.value;s&&(r(s)||e.parentNode?.removeChild(e))}function c(e,i){e.directive("auth",{mounted:(t,r)=>{o(t,r,i)}})}exports.setupPermissionDirective=c;
|
@@ -1,31 +1,36 @@
|
|
1
|
-
import { isClient as
|
1
|
+
import { isClient as v, isArray as x, isElement as E } from "@vft/utils";
|
2
2
|
const s = /* @__PURE__ */ new Map();
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
n(
|
8
|
-
})
|
9
|
-
|
3
|
+
if (v) {
|
4
|
+
let e;
|
5
|
+
document.addEventListener("mousedown", (t) => e = t), document.addEventListener("mouseup", (t) => {
|
6
|
+
if (e) {
|
7
|
+
for (const n of s.values())
|
8
|
+
for (const { documentHandler: o } of n)
|
9
|
+
o(t, e);
|
10
|
+
e = void 0;
|
11
|
+
}
|
12
|
+
});
|
13
|
+
}
|
14
|
+
function u(e, t) {
|
10
15
|
let n = [];
|
11
|
-
return
|
12
|
-
const
|
13
|
-
|
16
|
+
return x(t.arg) ? n = t.arg : E(t.arg) && n.push(t.arg), function(o, a) {
|
17
|
+
const c = t.instance.popperRef, r = o.target, d = a?.target, i = !t || !t.instance, l = !r || !d, f = e.contains(r) || e.contains(d), p = e === r, m = n.length && n.some((g) => g?.contains(r)) || n.length && n.includes(d), h = c && (c.contains(r) || c.contains(d));
|
18
|
+
i || l || f || p || m || h || t.value(o, a);
|
14
19
|
};
|
15
20
|
}
|
16
21
|
const C = {
|
17
22
|
beforeMount(e, t) {
|
18
23
|
s.has(e) || s.set(e, []), s.get(e).push({
|
19
|
-
documentHandler:
|
24
|
+
documentHandler: u(e, t),
|
20
25
|
bindingFn: t.value
|
21
26
|
});
|
22
27
|
},
|
23
28
|
updated(e, t) {
|
24
29
|
s.has(e) || s.set(e, []);
|
25
30
|
const n = s.get(e), o = n.findIndex(
|
26
|
-
(
|
31
|
+
(c) => c.bindingFn === t.oldValue
|
27
32
|
), a = {
|
28
|
-
documentHandler:
|
33
|
+
documentHandler: u(e, t),
|
29
34
|
bindingFn: t.value
|
30
35
|
};
|
31
36
|
o >= 0 ? n.splice(o, 1, a) : n.push(a);
|
package/dist/es/permission.js
CHANGED
@@ -1,17 +1,16 @@
|
|
1
|
-
import { usePermission as
|
2
|
-
import { ref as
|
3
|
-
function
|
4
|
-
|
5
|
-
|
6
|
-
t && (r(t) || (n = e.parentNode) == null || n.removeChild(e));
|
1
|
+
import { usePermission as n } from "@vft/use";
|
2
|
+
import { ref as s } from "vue";
|
3
|
+
function u(e, i, o) {
|
4
|
+
const { hasPermission: r } = n(o || s([])), t = i.value;
|
5
|
+
t && (r(t) || e.parentNode?.removeChild(e));
|
7
6
|
}
|
8
|
-
function
|
7
|
+
function c(e, i) {
|
9
8
|
e.directive("auth", {
|
10
9
|
mounted: (o, r) => {
|
11
|
-
|
10
|
+
u(o, r, i);
|
12
11
|
}
|
13
12
|
});
|
14
13
|
}
|
15
14
|
export {
|
16
|
-
|
15
|
+
c as setupPermissionDirective
|
17
16
|
};
|
package/package.json
CHANGED
@@ -1,17 +1,18 @@
|
|
1
1
|
{
|
2
2
|
"name": "@vft/directives",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.30",
|
4
4
|
"main": "./dist/cjs/index.cjs",
|
5
5
|
"module": "./dist/es/index.js",
|
6
|
+
"type": "module",
|
6
7
|
"files": [
|
7
8
|
"dist"
|
8
9
|
],
|
9
10
|
"devDependencies": {
|
10
|
-
"@vft/use": "0.0.
|
11
|
-
"@vft/utils": "0.0.
|
11
|
+
"@vft/use": "0.0.54",
|
12
|
+
"@vft/utils": "0.0.114"
|
12
13
|
},
|
13
14
|
"peerDependencies": {
|
14
|
-
"vue": "3.
|
15
|
+
"vue": "3.5.13"
|
15
16
|
},
|
16
17
|
"scripts": {
|
17
18
|
"clean": "pnpm /^clean:/",
|
package/src/index.ts
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
import type { App } from 'vue';
|
2
|
-
import ClickOutside from './click-out-side';
|
3
|
-
import ScrollFix from './scroll-fix';
|
4
|
-
|
5
|
-
export const registerScrollFix = (app: App) => {
|
6
|
-
app.directive('scrollFix', ScrollFix);
|
7
|
-
};
|
8
|
-
|
9
|
-
export const registerClickOut = (app: App) => {
|
10
|
-
app.directive('ClickOutside', ClickOutside);
|
11
|
-
};
|
12
|
-
|
13
|
-
export * from './permission';
|
14
|
-
export * from './repeat-click';
|
15
|
-
export { ClickOutside, ScrollFix };
|