engram-popup 0.1.1 → 0.1.3

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,59 @@
1
-
1
+ function h() {
2
+ const l = document.querySelectorAll("[data-engram-button]");
3
+ if (console.log(l.length), !l || l.length < 1) return;
4
+ let i = null;
5
+ const r = document.querySelectorAll(["[data-engram-popup]"]);
6
+ console.log(r[0]);
7
+ for (let e = 0; e < l.length; e++)
8
+ l[e].addEventListener("click", () => {
9
+ const n = l[e].getAttribute("data-engram-button");
10
+ i != n && s().then((o) => {
11
+ console.log(o), o === !0 && c(n);
12
+ });
13
+ });
14
+ function c(e) {
15
+ let n = null;
16
+ for (let o = 0; o < r.length; o++) {
17
+ let t = r[o].getAttribute("data-engram-popup");
18
+ if (e === t) {
19
+ n = r[o];
20
+ break;
21
+ }
22
+ }
23
+ n ? d(n) : alert(`popup container with name ${e} dont finded`);
24
+ }
25
+ function d(e) {
26
+ let n = e.cloneNode(!0);
27
+ i = n.getAttribute("data-engram-popup");
28
+ let o = n.getAttribute("data-engram-theme") ?? "white";
29
+ n.getAttribute("data-engram-animation");
30
+ let t = document.createElement("div"), p = document.createElement("div");
31
+ p.classList.add("engram-popup__close"), t.classList.add("engram-popup"), o == "white" ? t.classList.add("engram-popup--theme-white") : o == "black" ? t.classList.add("engram-popup--theme-black") : t.classList.add("engram-popup--theme-white"), n.removeAttribute("data-engram-popup"), t.appendChild(p), t.appendChild(n), t.style.visibility = "hidden", document.body.appendChild(t);
32
+ let g = t.clientHeight, u = window.innerHeight;
33
+ console.log(u), t.style.visibility = "", t.style.transform = `translateY(${+u / 2 - +g / 2}px)`, p.addEventListener("click", m), setTimeout(() => {
34
+ document.addEventListener("click", a);
35
+ }, 0);
36
+ }
37
+ function a(e) {
38
+ e.target.closest(".engram-popup") || (s(), console.log("click outside"));
39
+ }
40
+ function m() {
41
+ let e = this.closest(".engram-popup");
42
+ e.style.transform = "translateY(110vh)", setTimeout(() => {
43
+ e.style.visibility = "", e.remove(), i = null, document.removeEventListener("click", a), console.log("close current popup");
44
+ }, 500);
45
+ }
46
+ function s() {
47
+ const e = Array.from(document.querySelectorAll(".engram-popup"));
48
+ if (document.removeEventListener("click", a), e.length < 1) return Promise.resolve(!0);
49
+ const n = e.map((o) => new Promise((t, p) => {
50
+ o.style.transform = "translateY(110vh)", setTimeout(() => {
51
+ o.style.visibility = "", o.remove(), i = null, t();
52
+ }, 500);
53
+ }));
54
+ return Promise.all(n).then(() => !0);
55
+ }
56
+ }
57
+ export {
58
+ h as popup
59
+ };
@@ -1,2 +1,2 @@
1
- (function(e){typeof define=="function"&&define.amd?define(e):e()})((function(){"use strict";var e=document.createElement("style");e.textContent=`[data-engram-popup]{display:none}.engram-popup{width:600px;z-index:999;background:#fff;border-radius:20px;position:fixed;box-shadow:0 0 10px #0000001a;left:calc(50% - 300px);padding:30px;transform:translateY(110vh);transition:all ease .5s}.engram-popup--theme-black{background:#222}.engram-popup__close{position:absolute;width:35px;height:35px;border-radius:100px;display:flex;align-items:center;justify-content:center;background:#ccc;right:10px;top:10px;cursor:pointer}
2
- /*$vite$:1*/`,document.head.appendChild(e)}));
1
+ (function(i,p){typeof exports=="object"&&typeof module<"u"?p(exports):typeof define=="function"&&define.amd?define(["exports"],p):(i=typeof globalThis<"u"?globalThis:i||self,p(i["engram-popup"]={}))})(this,(function(i){"use strict";var p=document.createElement("style");p.textContent=`[data-engram-popup]{display:none}.engram-popup{width:600px;z-index:999;background:#fff;border-radius:20px;position:fixed;box-shadow:0 0 10px #0000001a;left:calc(50% - 300px);padding:30px;transform:translateY(110vh);transition:all ease .5s}.engram-popup--theme-black{background:#222}.engram-popup__close{position:absolute;width:35px;height:35px;border-radius:100px;display:flex;align-items:center;justify-content:center;background:#ccc;right:10px;top:10px;cursor:pointer}
2
+ /*$vite$:1*/`,document.head.appendChild(p);function m(){const l=document.querySelectorAll("[data-engram-button]");if(console.log(l.length),!l||l.length<1)return;let r=null;const a=document.querySelectorAll(["[data-engram-popup]"]);console.log(a[0]);for(let e=0;e<l.length;e++)l[e].addEventListener("click",()=>{const n=l[e].getAttribute("data-engram-button");r!=n&&c().then(o=>{console.log(o),o===!0&&g(n)})});function g(e){let n=null;for(let o=0;o<a.length;o++){let t=a[o].getAttribute("data-engram-popup");if(e===t){n=a[o];break}}n?f(n):alert(`popup container with name ${e} dont finded`)}function f(e){let n=e.cloneNode(!0);r=n.getAttribute("data-engram-popup");let o=n.getAttribute("data-engram-theme")??"white";n.getAttribute("data-engram-animation");let t=document.createElement("div"),s=document.createElement("div");s.classList.add("engram-popup__close"),t.classList.add("engram-popup"),o=="white"?t.classList.add("engram-popup--theme-white"):o=="black"?t.classList.add("engram-popup--theme-black"):t.classList.add("engram-popup--theme-white"),n.removeAttribute("data-engram-popup"),t.appendChild(s),t.appendChild(n),t.style.visibility="hidden",document.body.appendChild(t);let b=t.clientHeight,d=window.innerHeight;console.log(d),t.style.visibility="",t.style.transform=`translateY(${+d/2-+b/2}px)`,s.addEventListener("click",h),setTimeout(()=>{document.addEventListener("click",u)},0)}function u(e){e.target.closest(".engram-popup")||(c(),console.log("click outside"))}function h(){let e=this.closest(".engram-popup");e.style.transform="translateY(110vh)",setTimeout(()=>{e.style.visibility="",e.remove(),r=null,document.removeEventListener("click",u),console.log("close current popup")},500)}function c(){const e=Array.from(document.querySelectorAll(".engram-popup"));if(document.removeEventListener("click",u),e.length<1)return Promise.resolve(!0);const n=e.map(o=>new Promise((t,s)=>{o.style.transform="translateY(110vh)",setTimeout(()=>{o.style.visibility="",o.remove(),r=null,t()},500)}));return Promise.all(n).then(()=>!0)}}i.popup=m,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})}));
package/package.json CHANGED
@@ -1,22 +1,19 @@
1
1
  {
2
2
  "name": "engram-popup",
3
- "private": false,
4
- "version": "0.1.1",
3
+ "version": "0.1.3",
5
4
  "type": "module",
6
- "scripts": {
7
- "dev": "vite",
8
- "build": "vite build",
9
- "preview": "vite preview"
10
- },
5
+ "private": false,
6
+ "description": "A lightweight and dependency-free JavaScript library for creating popups and modals. Works via npm and CDN, and fits projects of any size — from simple landing pages to complex SPA applications.",
11
7
  "main": "dist/engram-popup.umd.js",
12
8
  "module": "dist/engram-popup.es.js",
13
- "style": "dist/index.css",
14
- "devDependencies": {
15
- "vite": "^7.2.4"
16
- },
17
9
  "files": [
18
10
  "dist"
19
11
  ],
12
+ "scripts": {
13
+ "dev": "vite",
14
+ "build": "vite build",
15
+ "preview": "vite preview"
16
+ },
20
17
  "keywords": [
21
18
  "popup",
22
19
  "modal",
@@ -33,6 +30,12 @@
33
30
  ],
34
31
  "author": "psih2131 https://github.com/psih2131",
35
32
  "license": "ISC",
36
- "description": "A lightweight and dependency-free JavaScript library for creating popups and modals. Works via npm and CDN, and fits projects of any size — from simple landing pages to complex SPA applications.",
37
- "homepage": ""
33
+ "devDependencies": {
34
+ "vite": "^7.2.4"
35
+ },
36
+ "homepage": "",
37
+ "repository": {
38
+ "type": "git",
39
+ "url": "https://github.com/psih2131/engram-popup.git"
40
+ }
38
41
  }