@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.
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const f=require("@vft/utils"),s=new Map;let d;f.isClient&&(document.addEventListener("mousedown",e=>d=e),document.addEventListener("mouseup",e=>{for(const t of s.values())for(const{documentHandler:n}of t)n(e,d)}));function i(e,t){let n=[];return Array.isArray(t.arg)?n=t.arg:f.isElement(t.arg)&&n.push(t.arg),function(a,o){const r=t.instance.popperRef,c=a.target,u=o==null?void 0:o.target,p=!t||!t.instance,g=!c||!u,h=e.contains(c)||e.contains(u),v=e===c,E=n.length&&n.some(l=>l==null?void 0:l.contains(c))||n.length&&n.includes(u),H=r&&(r.contains(c)||r.contains(u));p||g||h||v||E||H||t.value(a,o)}}const x={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),a=n.findIndex(r=>r.bindingFn===t.oldValue),o={documentHandler:i(e,t),bindingFn:t.value};a>=0?n.splice(a,1,o):n.push(o)},unmounted(e){s.delete(e)}};exports.default=x;
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;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("@vft/use"),o=require("vue");function c(e,i,t){var u;const{hasPermission:r}=n.usePermission(t||o.ref([])),s=i.value;s&&(r(s)||(u=e.parentNode)==null||u.removeChild(e))}function v(e,i){e.directive("auth",{mounted:(t,r)=>{c(t,r,i)}})}exports.setupPermissionDirective=v;
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 E, isElement as H } from "@vft/utils";
1
+ import { isClient as v, isArray as x, isElement as E } from "@vft/utils";
2
2
  const s = /* @__PURE__ */ new Map();
3
- let l;
4
- E && (document.addEventListener("mousedown", (e) => l = e), document.addEventListener("mouseup", (e) => {
5
- for (const t of s.values())
6
- for (const { documentHandler: n } of t)
7
- n(e, l);
8
- }));
9
- function i(e, t) {
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 Array.isArray(t.arg) ? n = t.arg : H(t.arg) && n.push(t.arg), function(o, a) {
12
- const r = t.instance.popperRef, c = o.target, u = a == null ? void 0 : a.target, f = !t || !t.instance, p = !c || !u, h = e.contains(c) || e.contains(u), g = e === c, v = n.length && n.some((d) => d == null ? void 0 : d.contains(c)) || n.length && n.includes(u), x = r && (r.contains(c) || r.contains(u));
13
- f || p || h || g || v || x || t.value(o, a);
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: i(e, t),
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
- (r) => r.bindingFn === t.oldValue
31
+ (c) => c.bindingFn === t.oldValue
27
32
  ), a = {
28
- documentHandler: i(e, t),
33
+ documentHandler: u(e, t),
29
34
  bindingFn: t.value
30
35
  };
31
36
  o >= 0 ? n.splice(o, 1, a) : n.push(a);
@@ -1,17 +1,16 @@
1
- import { usePermission as s } from "@vft/use";
2
- import { ref as u } from "vue";
3
- function m(e, i, o) {
4
- var n;
5
- const { hasPermission: r } = s(o || u([])), t = i.value;
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 a(e, i) {
7
+ function c(e, i) {
9
8
  e.directive("auth", {
10
9
  mounted: (o, r) => {
11
- m(o, r, i);
10
+ u(o, r, i);
12
11
  }
13
12
  });
14
13
  }
15
14
  export {
16
- a as setupPermissionDirective
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.29",
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.42",
11
- "@vft/utils": "0.0.63"
11
+ "@vft/use": "0.0.54",
12
+ "@vft/utils": "0.0.114"
12
13
  },
13
14
  "peerDependencies": {
14
- "vue": "3.4.19"
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 };