@barabel324/popups-engine 0.0.5 → 0.0.6

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/README.md CHANGED
@@ -1,12 +1,13 @@
1
1
  # Popups-engine
2
2
 
3
3
  Движок для управления попапами в React с поддержкой кастомных компонентов и анимаций через motion.
4
+
4
5
  Версия motion "^12.24.7"
5
6
 
6
7
  ## Установка
7
8
 
8
9
  ```bash
9
- npm install your-popups-engine
10
+ npm i @barabel324/popups-engine
10
11
  ```
11
12
 
12
13
  ## Основные компоненты
package/dist/css.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ declare const css: string;
2
+ export default css;
@@ -1,7 +1,5 @@
1
1
  import { Variant } from 'motion/react';
2
2
 
3
- export declare const css: string;
4
-
5
3
  /** Утилитарный дженерик для обозначения функционального компонента с пропсами children и className */
6
4
  declare type FCClass<P = object> = React.FC<P & React.PropsWithChildren & {
7
5
  className?: string;
@@ -1,6 +1,6 @@
1
1
  import { jsx as o } from "react/jsx-runtime";
2
- import { createContext as g, useContext as x, useRef as N, useEffect as h, Suspense as V, useState as $, useCallback as D, useMemo as f } from "react";
3
- import { motion as O, AnimatePresence as R } from "motion/react";
2
+ import { createContext as g, useContext as x, useRef as N, useEffect as h, Suspense as V, useState as D, useCallback as O, useMemo as f } from "react";
3
+ import { motion as R, AnimatePresence as $ } from "motion/react";
4
4
  const y = g({
5
5
  openPopup: () => {
6
6
  },
@@ -22,22 +22,22 @@ const y = g({
22
22
  exit: { opacity: 0 }
23
23
  }, z = ({
24
24
  className: n,
25
- motionVariants: a = S,
25
+ motionVariants: u = S,
26
26
  children: p
27
27
  }) => {
28
- const t = N(null), { closePopup: e } = k(), u = (r) => {
28
+ const t = N(null), { closePopup: e } = k(), a = (r) => {
29
29
  r.target === t.current && e();
30
30
  };
31
31
  return /* @__PURE__ */ o(
32
- O.div,
32
+ R.div,
33
33
  {
34
- variants: a,
34
+ variants: u,
35
35
  initial: "initial",
36
36
  animate: "animate",
37
37
  exit: "exit",
38
38
  ref: t,
39
39
  className: n ?? I.parent,
40
- onClick: u,
40
+ onClick: a,
41
41
  children: p
42
42
  }
43
43
  );
@@ -53,11 +53,11 @@ const y = g({
53
53
  }
54
54
  ), Q = ({
55
55
  className: n,
56
- id: a = "popups-engine-root",
56
+ id: u = "popups-engine-root",
57
57
  enableBodyScroll: p,
58
58
  lockBodyScroll: t
59
59
  }) => {
60
- const { popupList: e } = b(), { popups: u } = j(), { closePopup: r, closeAllPopups: l } = k();
60
+ const { popupList: e } = b(), { popups: a } = j(), { closePopup: r, closeAllPopups: l } = k();
61
61
  return h(() => (e.length > 0 && t?.(), () => {
62
62
  e.length > 0 && p?.();
63
63
  }), [
@@ -79,8 +79,8 @@ const y = g({
79
79
  "div",
80
80
  {
81
81
  className: n,
82
- id: a,
83
- children: /* @__PURE__ */ o(R, { children: e.map((i) => {
82
+ id: u,
83
+ children: /* @__PURE__ */ o($, { children: e.map((i) => {
84
84
  const {
85
85
  popupID: P,
86
86
  variant: d,
@@ -89,7 +89,7 @@ const y = g({
89
89
  components: c,
90
90
  classNames: E,
91
91
  motionVariants: m
92
- } = i, A = c?.wrapper ?? z, _ = c?.loader ?? q, C = u[d];
92
+ } = i, A = c?.wrapper ?? z, _ = c?.loader ?? q, C = a[d];
93
93
  return C ? /* @__PURE__ */ o(
94
94
  A,
95
95
  {
@@ -116,15 +116,15 @@ const y = g({
116
116
  );
117
117
  }, T = ({
118
118
  popups: n,
119
- children: a
119
+ children: u
120
120
  }) => {
121
- const [p, t] = $([]), e = D((s) => {
121
+ const [p, t] = D([]), e = O((s) => {
122
122
  const v = Object.keys(n), { variant: c } = s;
123
123
  c && (v.some((m) => m === c) ? t((m) => [...m, {
124
124
  ...s,
125
125
  popupID: Date.now()
126
126
  }]) : console.error(`there are no "${c}" popup`));
127
- }, [n]), u = () => {
127
+ }, [n]), a = () => {
128
128
  t((s) => s.slice(0, -1));
129
129
  }, r = () => {
130
130
  t((s) => s.slice(1));
@@ -132,7 +132,7 @@ const y = g({
132
132
  t(() => []);
133
133
  }, i = f(() => ({
134
134
  openPopup: e,
135
- closePopup: u,
135
+ closePopup: a,
136
136
  closeFirstPopup: r,
137
137
  closeAllPopups: l
138
138
  }), [e]), P = f(() => ({
@@ -140,11 +140,10 @@ const y = g({
140
140
  }), [p]), d = f(() => ({
141
141
  popups: n
142
142
  }), [n]);
143
- return /* @__PURE__ */ o(y.Provider, { value: i, children: /* @__PURE__ */ o(w.Provider, { value: P, children: /* @__PURE__ */ o(L.Provider, { value: d, children: a }) }) });
144
- }, U = css;
143
+ return /* @__PURE__ */ o(y.Provider, { value: i, children: /* @__PURE__ */ o(w.Provider, { value: P, children: /* @__PURE__ */ o(L.Provider, { value: d, children: u }) }) });
144
+ };
145
145
  export {
146
146
  T as PopupsEngineProvider,
147
147
  Q as PopupsEngineRoot,
148
- U as css,
149
148
  k as usePopupsEngineProvider
150
149
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barabel324/popups-engine",
3
- "version": "0.0.5",
3
+ "version": "0.0.6",
4
4
  "type": "module",
5
5
  "main": "./dist/popups-engine.js",
6
6
  "types": "./dist/popups-engine.d.ts",