@vft/directives 0.0.1
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 -0
- package/dist/cjs/index.cjs +1 -0
- package/dist/cjs/permission.cjs +1 -0
- package/dist/cjs/scroll-fix.cjs +1 -0
- package/dist/click-out-side.d.ts +3 -0
- package/dist/es/click-out-side.js +37 -0
- package/dist/es/index.js +13 -0
- package/dist/es/permission.js +16 -0
- package/dist/es/scroll-fix.js +19 -0
- package/dist/index.d.ts +4 -0
- package/dist/permission.d.ts +2 -0
- package/dist/scroll-fix.d.ts +9 -0
- package/package.json +37 -0
@@ -0,0 +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;
|
@@ -0,0 +1 @@
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./scroll-fix.cjs"),r=require("./click-out-side.cjs"),t=require("./permission.cjs"),s=e=>{e.directive("scrollFix",i.scrollFix)},c=e=>{e.directive("ClickOutside",r.default)};exports.setupPermissionDirective=t.setupPermissionDirective;exports.registerGlobalDirective=s;exports.registerGlobalDirectiveForWeb=c;
|
@@ -0,0 +1 @@
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@vft/use");function u(e,i,t){var n;const{hasPermission:s}=o.usePermission(t||[]),r=i.value;r&&(s(r)||(n=e.parentNode)==null||n.removeChild(e))}function c(e,i){e.directive("auth",{mounted:(t,s)=>{u(t,s,i)}})}exports.setupPermissionDirective=c;
|
@@ -0,0 +1 @@
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l={mounted(c){let o={};c.addEventListener("touchstart",e=>{o=e.touches[0]}),c.addEventListener("touchmove",e=>{e.stopPropagation();const t=e.currentTarget,s=e.touches[0];(t.scrollHeight<=t.offsetHeight||!t.scrollTop&&s.screenY>o.screenY||t.scrollTop===t.scrollHeight-t.offsetHeight&&s.screenY<o.screenY)&&e.cancelable&&e.preventDefault(),o=s},!1)}};exports.scrollFix=l;
|
@@ -0,0 +1,37 @@
|
|
1
|
+
import { isClient as E, isElement as H } from "@vft/utils";
|
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) {
|
10
|
+
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);
|
14
|
+
};
|
15
|
+
}
|
16
|
+
const C = {
|
17
|
+
beforeMount(e, t) {
|
18
|
+
s.has(e) || s.set(e, []), s.get(e).push({
|
19
|
+
documentHandler: i(e, t),
|
20
|
+
bindingFn: t.value
|
21
|
+
});
|
22
|
+
},
|
23
|
+
updated(e, t) {
|
24
|
+
s.has(e) || s.set(e, []);
|
25
|
+
const n = s.get(e), o = n.findIndex((r) => r.bindingFn === t.oldValue), a = {
|
26
|
+
documentHandler: i(e, t),
|
27
|
+
bindingFn: t.value
|
28
|
+
};
|
29
|
+
o >= 0 ? n.splice(o, 1, a) : n.push(a);
|
30
|
+
},
|
31
|
+
unmounted(e) {
|
32
|
+
s.delete(e);
|
33
|
+
}
|
34
|
+
};
|
35
|
+
export {
|
36
|
+
C as default
|
37
|
+
};
|
package/dist/es/index.js
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
import { scrollFix as e } from "./scroll-fix.js";
|
2
|
+
import r from "./click-out-side.js";
|
3
|
+
import { setupPermissionDirective as p } from "./permission.js";
|
4
|
+
const c = (i) => {
|
5
|
+
i.directive("scrollFix", e);
|
6
|
+
}, s = (i) => {
|
7
|
+
i.directive("ClickOutside", r);
|
8
|
+
};
|
9
|
+
export {
|
10
|
+
c as registerGlobalDirective,
|
11
|
+
s as registerGlobalDirectiveForWeb,
|
12
|
+
p as setupPermissionDirective
|
13
|
+
};
|
@@ -0,0 +1,16 @@
|
|
1
|
+
import { usePermission as s } from "@vft/use";
|
2
|
+
function u(e, i, t) {
|
3
|
+
var r;
|
4
|
+
const { hasPermission: o } = s(t || []), n = i.value;
|
5
|
+
n && (o(n) || (r = e.parentNode) == null || r.removeChild(e));
|
6
|
+
}
|
7
|
+
function c(e, i) {
|
8
|
+
e.directive("auth", {
|
9
|
+
mounted: (t, o) => {
|
10
|
+
u(t, o, i);
|
11
|
+
}
|
12
|
+
});
|
13
|
+
}
|
14
|
+
export {
|
15
|
+
c as setupPermissionDirective
|
16
|
+
};
|
@@ -0,0 +1,19 @@
|
|
1
|
+
const r = {
|
2
|
+
mounted(c) {
|
3
|
+
let o = {};
|
4
|
+
c.addEventListener("touchstart", (e) => {
|
5
|
+
o = e.touches[0];
|
6
|
+
}), c.addEventListener(
|
7
|
+
"touchmove",
|
8
|
+
(e) => {
|
9
|
+
e.stopPropagation();
|
10
|
+
const t = e.currentTarget, s = e.touches[0];
|
11
|
+
(t.scrollHeight <= t.offsetHeight || !t.scrollTop && s.screenY > o.screenY || t.scrollTop === t.scrollHeight - t.offsetHeight && s.screenY < o.screenY) && e.cancelable && e.preventDefault(), o = s;
|
12
|
+
},
|
13
|
+
!1
|
14
|
+
);
|
15
|
+
}
|
16
|
+
};
|
17
|
+
export {
|
18
|
+
r as scrollFix
|
19
|
+
};
|
package/dist/index.d.ts
ADDED
package/package.json
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
{
|
2
|
+
"name": "@vft/directives",
|
3
|
+
"version": "0.0.1",
|
4
|
+
"main": "./dist/cjs/index.cjs",
|
5
|
+
"module": "./dist/es/index.js",
|
6
|
+
"types": "./dist/index.d.ts",
|
7
|
+
"exports": {
|
8
|
+
".": {
|
9
|
+
"require": "./dist/cjs/index.cjs",
|
10
|
+
"import": "./dist/es/index.js"
|
11
|
+
}
|
12
|
+
},
|
13
|
+
"files": [
|
14
|
+
"dist"
|
15
|
+
],
|
16
|
+
"devDependencies": {
|
17
|
+
"vue": "^3.2.45",
|
18
|
+
"@vft/use": "0.0.3",
|
19
|
+
"@vft/utils": "0.0.6",
|
20
|
+
"@vft/constants": "0.0.28"
|
21
|
+
},
|
22
|
+
"peerDependencies": {
|
23
|
+
"vue": "^3.2.45",
|
24
|
+
"@vft/utils": "0.0.6",
|
25
|
+
"@vft/use": "0.0.3",
|
26
|
+
"@vft/constants": "0.0.28"
|
27
|
+
},
|
28
|
+
"scripts": {
|
29
|
+
"stub": "unbuild --stub && pnpm -F @vft/scripts stub-helper",
|
30
|
+
"dev": "pnpm run stub",
|
31
|
+
"clean": "pnpm /^clean:/",
|
32
|
+
"clean:dist": "rimraf dist",
|
33
|
+
"clean:node_modules": "rimraf node_modules",
|
34
|
+
"build": "vite build",
|
35
|
+
"pub": "pnpm clean:dist && pnpm build && tsx ../../scripts/src/publish.ts --pkg packages/directives -b"
|
36
|
+
}
|
37
|
+
}
|