prlg-ui 1.8.49 → 1.8.51

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.
@@ -0,0 +1 @@
1
+ "use strict";const n=require("vue");class m{scrollY=0;lockCount=0;preventTouch=e=>{const t=e.target.closest(".modal-scrollable, .scrollable");if(!t){e.preventDefault();return}const{scrollTop:o,scrollHeight:s,clientHeight:c}=t;if(!(s>c)){e.preventDefault();return}const y=e.startY||e.touches[0].clientY,f=e.touches[0].clientY,u=y-f;(o<=0&&u<0||o>=s-c&&u>0)&&e.preventDefault()};preventWheel=e=>{const t=e.target.closest(".modal-scrollable, .scrollable");if(!t){e.preventDefault();return}const{scrollTop:o,scrollHeight:s,clientHeight:c}=t;if(!(s>c)){e.preventDefault();return}(o<=0&&e.deltaY<0||o>=s-c&&e.deltaY>0)&&e.preventDefault()};handleTouchStart=e=>{e.startY=e.touches[0].clientY};preventKeys=e=>{[32,33,34,35,36,37,38,39,40].includes(e.keyCode)&&(e.target.closest(".modal-scrollable, .scrollable")||e.preventDefault())};lock(){if(this.lockCount++,this.lockCount===1){console.log(this.lockCount),this.scrollY=window.scrollY,document.body.style.position="fixed",document.body.style.top=`-${this.scrollY}px`,document.body.style.left="0",document.body.style.right="0",document.body.style.width="100%",document.body.style.overflow="hidden";const e={passive:!1};document.addEventListener("touchstart",this.handleTouchStart,e),document.addEventListener("touchmove",this.preventTouch,e),document.addEventListener("wheel",this.preventWheel,e),document.addEventListener("keydown",this.preventKeys)}}unlock(){if(this.lockCount>0&&this.lockCount--,this.lockCount===0){document.body.style.position="",document.body.style.top="",document.body.style.left="",document.body.style.right="",document.body.style.width="",document.body.style.overflow="",window.scrollTo(0,this.scrollY);const e={passive:!1};document.removeEventListener("touchstart",this.handleTouchStart,e),document.removeEventListener("touchmove",this.preventTouch,e),document.removeEventListener("wheel",this.preventWheel,e),document.removeEventListener("keydown",this.preventKeys)}}forceUnlock(){this.lockCount=0,this.unlock()}isLocked(){return this.lockCount>0}getLockCount(){return this.lockCount}}const i=new m,p=()=>({unlockScroll:()=>i.unlock(),lockScroll:()=>i.lock()}),d={BASE:1e3,DROPDOWN:1010,STICKY:1020,DRAWER:1030,TOOLTIP:1040,POPOVER:1050,MODAL:1060,NOTIFICATION:1070,DEBUG:9999},v=Symbol("z-index-context");let a=d.BASE;function b(){const l=n.inject(v,null);return l||{currentLayer:n.ref(a),getNextLayer:()=>(a+=10,a)}}const k=["data-layer"],g=n.defineComponent({__name:"Portal",props:{layer:{default:"BASE"},teleport:{type:Boolean,default:!0},target:{default:"body"},zIndex:{},show:{type:Boolean,default:!0}},setup(l){const e=l,{getNextLayer:r}=b(),t=n.computed(()=>e.zIndex?e.zIndex:e.layer&&e.layer!=="BASE"?d[e.layer]:r());return(o,s)=>o.show?(n.openBlock(),n.createBlock(n.Teleport,{key:0,to:o.target,disabled:!o.teleport},[n.createElementVNode("div",{style:n.normalizeStyle({zIndex:t.value,position:"relative"}),"data-layer":o.layer},[n.renderSlot(o.$slots,"default")],12,k)],8,["to","disabled"])):n.createCommentVNode("",!0)}});function E(){const l=new Map;return{on(e,r){const t=l.get(e)||[];t.push(r),l.set(e,t)},off(e,r){const t=l.get(e);t&&l.set(e,t.filter(o=>o!==r))},emit(e,r){const t=l.get(e);t&&t.forEach(o=>o(r))},clear(){l.clear()}}}exports.EventBus=E;exports._sfc_main=g;exports.useBodyScroll=p;
@@ -0,0 +1,143 @@
1
+ import { inject as f, ref as m, defineComponent as p, computed as v, createBlock as b, createCommentVNode as k, openBlock as g, Teleport as E, createElementVNode as S, normalizeStyle as C, renderSlot as L } from "vue";
2
+ class T {
3
+ scrollY = 0;
4
+ lockCount = 0;
5
+ // Счетчик вложенных модальных окон
6
+ preventTouch = (e) => {
7
+ const t = e.target.closest(".modal-scrollable, .scrollable");
8
+ if (!t) {
9
+ e.preventDefault();
10
+ return;
11
+ }
12
+ const { scrollTop: o, scrollHeight: r, clientHeight: s } = t;
13
+ if (!(r > s)) {
14
+ e.preventDefault();
15
+ return;
16
+ }
17
+ const h = e.startY || e.touches[0].clientY, y = e.touches[0].clientY, a = h - y;
18
+ (o <= 0 && a < 0 || o >= r - s && a > 0) && e.preventDefault();
19
+ };
20
+ preventWheel = (e) => {
21
+ const t = e.target.closest(".modal-scrollable, .scrollable");
22
+ if (!t) {
23
+ e.preventDefault();
24
+ return;
25
+ }
26
+ const { scrollTop: o, scrollHeight: r, clientHeight: s } = t;
27
+ if (!(r > s)) {
28
+ e.preventDefault();
29
+ return;
30
+ }
31
+ (o <= 0 && e.deltaY < 0 || o >= r - s && e.deltaY > 0) && e.preventDefault();
32
+ };
33
+ handleTouchStart = (e) => {
34
+ e.startY = e.touches[0].clientY;
35
+ };
36
+ preventKeys = (e) => {
37
+ [32, 33, 34, 35, 36, 37, 38, 39, 40].includes(e.keyCode) && (e.target.closest(".modal-scrollable, .scrollable") || e.preventDefault());
38
+ };
39
+ lock() {
40
+ if (this.lockCount++, this.lockCount === 1) {
41
+ console.log(this.lockCount), this.scrollY = window.scrollY, document.body.style.position = "fixed", document.body.style.top = `-${this.scrollY}px`, document.body.style.left = "0", document.body.style.right = "0", document.body.style.width = "100%", document.body.style.overflow = "hidden";
42
+ const e = { passive: !1 };
43
+ document.addEventListener("touchstart", this.handleTouchStart, e), document.addEventListener("touchmove", this.preventTouch, e), document.addEventListener("wheel", this.preventWheel, e), document.addEventListener("keydown", this.preventKeys);
44
+ }
45
+ }
46
+ unlock() {
47
+ if (this.lockCount > 0 && this.lockCount--, this.lockCount === 0) {
48
+ document.body.style.position = "", document.body.style.top = "", document.body.style.left = "", document.body.style.right = "", document.body.style.width = "", document.body.style.overflow = "", window.scrollTo(0, this.scrollY);
49
+ const e = { passive: !1 };
50
+ document.removeEventListener("touchstart", this.handleTouchStart, e), document.removeEventListener("touchmove", this.preventTouch, e), document.removeEventListener("wheel", this.preventWheel, e), document.removeEventListener("keydown", this.preventKeys);
51
+ }
52
+ }
53
+ // Метод для принудительной разблокировки (например, при ошибке)
54
+ forceUnlock() {
55
+ this.lockCount = 0, this.unlock();
56
+ }
57
+ // Метод для получения текущего состояния
58
+ isLocked() {
59
+ return this.lockCount > 0;
60
+ }
61
+ // Метод для получения количества активных блокировок
62
+ getLockCount() {
63
+ return this.lockCount;
64
+ }
65
+ }
66
+ const u = new T(), B = () => ({
67
+ unlockScroll: () => u.unlock(),
68
+ lockScroll: () => u.lock()
69
+ }), i = {
70
+ BASE: 1e3,
71
+ DROPDOWN: 1010,
72
+ STICKY: 1020,
73
+ DRAWER: 1030,
74
+ TOOLTIP: 1040,
75
+ POPOVER: 1050,
76
+ MODAL: 1060,
77
+ NOTIFICATION: 1070,
78
+ DEBUG: 9999
79
+ }, w = Symbol("z-index-context");
80
+ let c = i.BASE;
81
+ function D() {
82
+ const l = f(w, null);
83
+ return l || {
84
+ currentLayer: m(c),
85
+ getNextLayer: () => (c += 10, c)
86
+ };
87
+ }
88
+ const Y = ["data-layer"], x = /* @__PURE__ */ p({
89
+ __name: "Portal",
90
+ props: {
91
+ layer: { default: "BASE" },
92
+ teleport: { type: Boolean, default: !0 },
93
+ target: { default: "body" },
94
+ zIndex: {},
95
+ show: { type: Boolean, default: !0 }
96
+ },
97
+ setup(l) {
98
+ const e = l, { getNextLayer: n } = D(), t = v(() => e.zIndex ? e.zIndex : e.layer && e.layer !== "BASE" ? i[e.layer] : n());
99
+ return (o, r) => o.show ? (g(), b(E, {
100
+ key: 0,
101
+ to: o.target,
102
+ disabled: !o.teleport
103
+ }, [
104
+ S("div", {
105
+ style: C({
106
+ zIndex: t.value,
107
+ position: "relative"
108
+ }),
109
+ "data-layer": o.layer
110
+ }, [
111
+ L(o.$slots, "default")
112
+ ], 12, Y)
113
+ ], 8, ["to", "disabled"])) : k("", !0);
114
+ }
115
+ });
116
+ function N() {
117
+ const l = /* @__PURE__ */ new Map();
118
+ return {
119
+ on(e, n) {
120
+ const t = l.get(e) || [];
121
+ t.push(n), l.set(e, t);
122
+ },
123
+ off(e, n) {
124
+ const t = l.get(e);
125
+ t && l.set(
126
+ e,
127
+ t.filter((o) => o !== n)
128
+ );
129
+ },
130
+ emit(e, n) {
131
+ const t = l.get(e);
132
+ t && t.forEach((o) => o(n));
133
+ },
134
+ clear() {
135
+ l.clear();
136
+ }
137
+ };
138
+ }
139
+ export {
140
+ N as E,
141
+ x as _,
142
+ B as u
143
+ };