@fullkekw/popup 2.0.10 → 2.0.11

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/index.es.js CHANGED
@@ -1,8 +1,8 @@
1
- import { jsx as k, jsxs as _ } from "react/jsx-runtime";
2
- import { useState as x, createContext as L, useEffect as S, Suspense as M, useContext as P, useMemo as T } from "react";
1
+ import { jsx as S, jsxs as _ } from "react/jsx-runtime";
2
+ import { createContext as L, useState as g, useEffect as y, Suspense as T, useContext as N } from "react";
3
3
  import { createPortal as A } from "react-dom";
4
- function q(o) {
5
- return o && o.__esModule && Object.prototype.hasOwnProperty.call(o, "default") ? o.default : o;
4
+ function M(s) {
5
+ return s && s.__esModule && Object.prototype.hasOwnProperty.call(s, "default") ? s.default : s;
6
6
  }
7
7
  var b = { exports: {} };
8
8
  /*!
@@ -11,156 +11,150 @@ var b = { exports: {} };
11
11
  http://jedwatson.github.io/classnames
12
12
  */
13
13
  var C;
14
- function F() {
15
- return C || (C = 1, function(o) {
14
+ function q() {
15
+ return C || (C = 1, function(s) {
16
16
  (function() {
17
- var d = {}.hasOwnProperty;
18
- function p() {
17
+ var m = {}.hasOwnProperty;
18
+ function a() {
19
19
  for (var e = "", n = 0; n < arguments.length; n++) {
20
20
  var u = arguments[n];
21
- u && (e = r(e, c(u)));
21
+ u && (e = r(e, f(u)));
22
22
  }
23
23
  return e;
24
24
  }
25
- function c(e) {
25
+ function f(e) {
26
26
  if (typeof e == "string" || typeof e == "number")
27
27
  return e;
28
28
  if (typeof e != "object")
29
29
  return "";
30
30
  if (Array.isArray(e))
31
- return p.apply(null, e);
31
+ return a.apply(null, e);
32
32
  if (e.toString !== Object.prototype.toString && !e.toString.toString().includes("[native code]"))
33
33
  return e.toString();
34
34
  var n = "";
35
35
  for (var u in e)
36
- d.call(e, u) && e[u] && (n = r(n, u));
36
+ m.call(e, u) && e[u] && (n = r(n, u));
37
37
  return n;
38
38
  }
39
39
  function r(e, n) {
40
40
  return n ? e ? e + " " + n : e + n : e;
41
41
  }
42
- o.exports ? (p.default = p, o.exports = p) : window.classNames = p;
42
+ s.exports ? (a.default = a, s.exports = a) : window.classNames = a;
43
43
  })();
44
44
  }(b)), b.exports;
45
45
  }
46
- var Z = F();
47
- const O = /* @__PURE__ */ q(Z);
48
- function B(o, d) {
49
- const p = arguments.length === 2 && d !== void 0, [c, r] = x(o);
50
- return p ? [
51
- o,
52
- d
53
- ] : [c, r];
54
- }
55
- const N = {
46
+ var F = q();
47
+ const k = /* @__PURE__ */ M(F), P = {
56
48
  disableScroll: !0,
57
49
  exitOnDocument: !0,
58
50
  exitOnEscape: !0,
59
51
  preventStateChange: !1
60
- }, h = L({}), G = ({ className: o, settings: d, children: p, ...c }) => {
61
- const [r] = x(z(d ?? {}, N)), [e, n] = x([]), u = {
52
+ }, h = L({}), Z = ({ className: s, settings: m, children: a, ...f }) => {
53
+ const [r] = g(z(m ?? {}, P)), [e, n] = g([]), u = {
62
54
  nodes: e,
63
- toggleNode: m,
64
- registerNode: w,
65
- toggleDocument: y
55
+ toggleNode: x,
56
+ registerNode: v,
57
+ toggleDocument: O
66
58
  };
67
- S(() => {
59
+ y(() => {
68
60
  if (typeof window > "u") return;
69
- window.addEventListener("keydown", a);
70
- function a(s) {
71
- if (s.key === "Escape") {
72
- const f = Math.max(...e.filter((l) => l.open).map((l) => l.zIndex)), i = e.find((l) => l.open && l.zIndex === f);
61
+ window.addEventListener("keydown", p);
62
+ function p(o) {
63
+ if (o.key === "Escape") {
64
+ const c = Math.max(...e.filter((d) => d.open).map((d) => d.zIndex)), i = e.find((d) => d.open && d.zIndex === c);
73
65
  if (!i || !i.settings.exitOnEscape || !(r != null && r.exitOnEscape)) return;
74
- m(i.id);
66
+ x(i.id);
75
67
  }
76
68
  }
77
69
  return () => {
78
- window.removeEventListener("keydown", a);
70
+ window.removeEventListener("keydown", p);
79
71
  };
80
72
  }, [e]);
81
- function m(a, s) {
73
+ function x(p, o) {
82
74
  let t;
83
- if (typeof a == "string" ? t = { ...e.find((i) => i.id === a) } : t = { ...a }, !t.id) return;
84
- if ((r.preventStateChange || t.settings.preventStateChange) && s === void 0) return console.warn("Popup action prevented");
85
- const f = s ?? !(t != null && t.open);
86
- t.open = f, t.zIndex = f ? Math.max(...e.map((i) => i.zIndex), 0) + 1 : 0, n((i) => [...i.filter((l) => l.id !== t.id), t]), r.disableScroll && t.settings.disableScroll && f && document.body.classList.add("fkw-popup--noScroll"), !f && !e.filter((i) => i.id !== t.id).some((i) => i.open) && document.body.classList.remove("fkw-popup--noScroll");
75
+ if (typeof p == "string" ? t = { ...e.find((i) => i.id === p) } : t = { ...p }, !t.id) return;
76
+ if ((r.preventStateChange || t.settings.preventStateChange) && o === void 0) return console.warn("Popup action prevented");
77
+ const c = o ?? !(t != null && t.open);
78
+ t.open = c, t.zIndex = c ? Math.max(...e.map((i) => i.zIndex), 0) + 1 : 0, n((i) => [...i.filter((d) => d.id !== t.id), t]), r.disableScroll && t.settings.disableScroll && c && document.body.classList.add("fkw-popup--noScroll"), !c && !e.filter((i) => i.id !== t.id).some((i) => i.open) && document.body.classList.remove("fkw-popup--noScroll");
87
79
  }
88
- function w(a) {
89
- n((s) => [...s, a]), a.open && m(a, !0);
80
+ function v(p) {
81
+ n((o) => [...o, p]), p.open && x(p, !0);
90
82
  }
91
- function y(a, s) {
92
- const t = { ...e.find((i) => i.id === a) };
93
- !t.id || !t.settings.exitOnDocument || s.target.closest(".fkw-popup") || !t.settings.exitOnDocument || !r.exitOnDocument || m(t.id);
83
+ function O(p, o) {
84
+ const t = { ...e.find((i) => i.id === p) };
85
+ !t.id || !t.settings.exitOnDocument || o.target.closest(".fkw-popup") || !t.settings.exitOnDocument || !r.exitOnDocument || x(t.id);
94
86
  }
95
- return /* @__PURE__ */ k(M, { children: /* @__PURE__ */ _(h.Provider, { value: u, children: [
96
- p,
97
- /* @__PURE__ */ k("section", { className: O("fkw-popup-container", o), id: "fkw-popup-container", ...c })
87
+ return /* @__PURE__ */ S(T, { children: /* @__PURE__ */ _(h.Provider, { value: u, children: [
88
+ a,
89
+ /* @__PURE__ */ S("section", { className: k("fkw-popup-container", s), id: "fkw-popup-container", ...f })
98
90
  ] }) });
99
- }, K = ({ children: o, className: d, layerClassName: p, style: c, id: r, settings: e, isOpen: n, setIsOpen: u, animation: m, onExit: w, onOpen: y, ...a }) => {
100
- const s = P(h);
101
- n = T(() => n ?? !1, []);
102
- const [t] = x(m ?? "scale"), [f] = x(z(e ?? {}, N)), [i, l] = x(null), [v, D] = B(n, u), [E, I] = x(0);
103
- return S(() => {
104
- l(document.querySelector("#fkw-popup-container")), s.registerNode({
91
+ }, B = ({ children: s, className: m, layerClassName: a, style: f, id: r, settings: e, isOpen: n, setIsOpen: u, animation: x, onExit: v, onOpen: O, ...p }) => {
92
+ const o = N(h), [t] = g(x ?? "scale"), [c] = g(z(e ?? {}, P)), [i, d] = g(null), [l, D] = g(n ?? !1), [E, I] = g(0);
93
+ return y(() => {
94
+ d(document.querySelector("#fkw-popup-container")), o.registerNode({
105
95
  id: r,
106
- open: n,
96
+ open: l,
107
97
  zIndex: 0,
108
- settings: f
98
+ settings: c
109
99
  });
110
- }, []), S(() => {
111
- v && y && y(), !v && w && w();
112
- }, [v]), S(() => {
113
- const g = s.nodes.find((j) => j.id === r);
114
- g && (D(g.open), g.zIndex !== 0 ? I(g.zIndex) : setTimeout(() => {
115
- I(g.zIndex);
100
+ }, []), y(() => {
101
+ l && O && O(), !l && v && v();
102
+ }, [n]), y(() => {
103
+ const w = o.nodes.find((j) => j.id === r);
104
+ w && (D(w.open), w.zIndex !== 0 ? I(w.zIndex) : setTimeout(() => {
105
+ I(w.zIndex);
116
106
  }, 200));
117
- }, [s]), i ? A(/* @__PURE__ */ k(
107
+ }, [o]), y(() => {
108
+ u === void 0 || n === l || u(l);
109
+ }, [l]), y(() => {
110
+ n === void 0 || n === l || o.toggleNode(r, n);
111
+ }, [n]), i ? A(/* @__PURE__ */ S(
118
112
  "section",
119
113
  {
120
114
  id: r,
121
- className: O("fkw-popup-layer", v && "fkw-popup-layer--open", p),
122
- style: { zIndex: 1e4 + E, cursor: f.exitOnDocument && !f.preventStateChange ? "pointer" : "auto", ...c },
123
- onClick: f.exitOnDocument && !f.preventStateChange ? (g) => s.toggleDocument(r, g) : void 0,
124
- children: /* @__PURE__ */ k(
115
+ className: k("fkw-popup-layer", l && "fkw-popup-layer--open", a),
116
+ style: { zIndex: 1e4 + E, cursor: c.exitOnDocument && !c.preventStateChange ? "pointer" : "auto", ...f },
117
+ onClick: c.exitOnDocument && !c.preventStateChange ? (w) => o.toggleDocument(r, w) : void 0,
118
+ children: /* @__PURE__ */ S(
125
119
  "article",
126
120
  {
127
- className: O("fkw-popup", v && "fkw-popup--open", t && `fkw-popup-animation--${t}`, d),
121
+ className: k("fkw-popup", l && "fkw-popup--open", t && `fkw-popup-animation--${t}`, m),
128
122
  role: "dialog",
129
123
  "aria-modal": !0,
130
- "aria-hidden": !v,
131
- ...a,
132
- children: o
124
+ "aria-hidden": !l,
125
+ ...p,
126
+ children: s
133
127
  }
134
128
  )
135
129
  }
136
130
  ), i) : null;
137
- }, R = ({ children: o, as: d, className: p, onClick: c, disabled: r, popupId: e, ...n }) => {
138
- const u = P(h), [m, w] = x(!1), y = d ?? "button";
139
- S(() => {
140
- const s = u.nodes.find((t) => t.id === e);
141
- s && w(s.open);
131
+ }, G = ({ children: s, as: m, className: a, onClick: f, disabled: r, popupId: e, ...n }) => {
132
+ const u = N(h), [x, v] = g(!1), O = m ?? "button";
133
+ y(() => {
134
+ const o = u.nodes.find((t) => t.id === e);
135
+ o && v(o.open);
142
136
  }, [u]);
143
- function a(s) {
144
- u.toggleNode(e), c && c(s);
137
+ function p(o) {
138
+ u.toggleNode(e), f && f(o);
145
139
  }
146
- return /* @__PURE__ */ k(y, { className: O("fkw-popup-button", m && "fkw-popup-button--active", p), role: "button", onClick: a, "aria-haspopup": "dialog", tabIndex: 0, disabled: r, "aria-disabled": r, "data-fkw-popup-operator": e, "aria-label": m ? "Close Popup" : "Open Popup", ...n, children: o });
140
+ return /* @__PURE__ */ S(O, { className: k("fkw-popup-button", x && "fkw-popup-button--active", a), role: "button", onClick: p, "aria-haspopup": "dialog", tabIndex: 0, disabled: r, "aria-disabled": r, "data-fkw-popup-operator": e, "aria-label": x ? "Close Popup" : "Open Popup", ...n, children: s });
147
141
  };
148
- function z(o, d) {
149
- const p = { ...d };
150
- for (const c in o)
151
- p[c] = o[c];
152
- return p;
142
+ function z(s, m) {
143
+ const a = { ...m };
144
+ for (const f in s)
145
+ a[f] = s[f];
146
+ return a;
153
147
  }
154
- const H = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
148
+ const V = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
155
149
  __proto__: null,
156
- PopupButton: R,
157
- PopupLayer: G,
158
- PopupWindow: K
150
+ PopupButton: G,
151
+ PopupLayer: Z,
152
+ PopupWindow: B
159
153
  }, Symbol.toStringTag, { value: "Module" }));
160
154
  export {
161
- R as PopupButton,
162
- G as PopupLayer,
163
- K as PopupWindow,
164
- H as default
155
+ G as PopupButton,
156
+ Z as PopupLayer,
157
+ B as PopupWindow,
158
+ V as default
165
159
  };
166
160
  //# sourceMappingURL=index.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.es.js","sources":["../node_modules/classnames/index.js","../src/_package/useMixedState.ts","../src/_package/Package.tsx"],"sourcesContent":["/*!\n\tCopyright (c) 2018 Jed Watson.\n\tLicensed under the MIT License (MIT), see\n\thttp://jedwatson.github.io/classnames\n*/\n/* global define */\n\n(function () {\n\t'use strict';\n\n\tvar hasOwn = {}.hasOwnProperty;\n\n\tfunction classNames () {\n\t\tvar classes = '';\n\n\t\tfor (var i = 0; i < arguments.length; i++) {\n\t\t\tvar arg = arguments[i];\n\t\t\tif (arg) {\n\t\t\t\tclasses = appendClass(classes, parseValue(arg));\n\t\t\t}\n\t\t}\n\n\t\treturn classes;\n\t}\n\n\tfunction parseValue (arg) {\n\t\tif (typeof arg === 'string' || typeof arg === 'number') {\n\t\t\treturn arg;\n\t\t}\n\n\t\tif (typeof arg !== 'object') {\n\t\t\treturn '';\n\t\t}\n\n\t\tif (Array.isArray(arg)) {\n\t\t\treturn classNames.apply(null, arg);\n\t\t}\n\n\t\tif (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes('[native code]')) {\n\t\t\treturn arg.toString();\n\t\t}\n\n\t\tvar classes = '';\n\n\t\tfor (var key in arg) {\n\t\t\tif (hasOwn.call(arg, key) && arg[key]) {\n\t\t\t\tclasses = appendClass(classes, key);\n\t\t\t}\n\t\t}\n\n\t\treturn classes;\n\t}\n\n\tfunction appendClass (value, newClass) {\n\t\tif (!newClass) {\n\t\t\treturn value;\n\t\t}\n\t\n\t\tif (value) {\n\t\t\treturn value + ' ' + newClass;\n\t\t}\n\t\n\t\treturn value + newClass;\n\t}\n\n\tif (typeof module !== 'undefined' && module.exports) {\n\t\tclassNames.default = classNames;\n\t\tmodule.exports = classNames;\n\t} else if (typeof define === 'function' && typeof define.amd === 'object' && define.amd) {\n\t\t// register as 'classnames', consistent with npm package name\n\t\tdefine('classnames', [], function () {\n\t\t\treturn classNames;\n\t\t});\n\t} else {\n\t\twindow.classNames = classNames;\n\t}\n}());\n","'use client';\r\n\r\nimport { useState } from 'react';\r\nimport { StateSetter } from './Interfaces';\r\n\r\n\r\n\r\nexport default function useMixedState<S = undefined>(): [S | undefined, StateSetter<S | undefined>];\r\nexport default function useMixedState<S>(initialState: S | (() => S)): [S, StateSetter<S>];\r\nexport default function useMixedState<S>(state: S, setter?: StateSetter<S>): [S, StateSetter<S>];\r\n\r\n\r\n\r\n/** \r\n * Use mixed state hook\r\n * \r\n * @param initialStateOrValue Initial state, can be undefined, value or function. If externalSetter not specified, will return default state\r\n * @param externalSetter External state setter. If specified will return external state\r\n */\r\nexport default function useMixedState<S>(initialStateOrValue?: S | (() => S), externalSetter?: StateSetter<S>) {\r\n const isControlled = arguments.length === 2 && externalSetter !== undefined;\r\n\r\n const [defaultState, defaultSetter] = useState<S | undefined>(initialStateOrValue);\r\n\r\n\r\n\r\n if (isControlled) {\r\n return [\r\n initialStateOrValue as S,\r\n externalSetter as StateSetter<S>\r\n ];\r\n }\r\n\r\n return [defaultState, defaultSetter];\r\n}","import './styles.scss';\r\n\r\nimport React, { createContext, FC, JSX, Suspense, useContext, useEffect, useMemo, useState } from \"react\";\r\nimport cn from 'classnames';\r\nimport { IPopupButtonProps, IPopupContextProps, IPopupLayerProps, IPopupNode, IPopupSettings, PopupWindowAnimationType, IPopupWindowProps } from './Interfaces';\r\nimport { createPortal } from 'react-dom';\r\nimport useMixedState from './useMixedState';\r\n\r\n\r\n\r\nconst DEFAULT_SETTINGS: Required<IPopupSettings> = {\r\n disableScroll: true,\r\n exitOnDocument: true,\r\n exitOnEscape: true,\r\n preventStateChange: false\r\n};\r\n\r\nconst PopupContext = createContext<IPopupContextProps>({} as IPopupContextProps);\r\n\r\n\r\n\r\n/** \r\n * Popup context provider. Must be inside body tag and in client environment (NextJS)\r\n */\r\nexport const PopupLayer: FC<IPopupLayerProps> = ({ className, settings: initialSettings, children, ...props }) => {\r\n const [settings] = useState<IPopupSettings>(reassingObject(initialSettings ?? {}, DEFAULT_SETTINGS));\r\n const [nodes, setNodes] = useState<IPopupNode[]>([]);\r\n\r\n const context: IPopupContextProps = {\r\n nodes,\r\n toggleNode,\r\n registerNode,\r\n toggleDocument\r\n };\r\n\r\n\r\n\r\n // Handle exitOnEscape\r\n useEffect(() => {\r\n if (typeof window === 'undefined') return;\r\n\r\n window.addEventListener('keydown', handleKeydown);\r\n\r\n function handleKeydown(e: KeyboardEvent) {\r\n const key = e.key;\r\n\r\n if (key === 'Escape') {\r\n const maxZIndex = Math.max(...nodes.filter(el => el.open).map(el => el.zIndex));\r\n const node = nodes.find(el => el.open && el.zIndex === maxZIndex);\r\n if (!node || !node.settings.exitOnEscape || !settings?.exitOnEscape) return;\r\n\r\n toggleNode(node.id);\r\n }\r\n }\r\n\r\n return () => {\r\n window.removeEventListener('keydown', handleKeydown);\r\n };\r\n }, [nodes]);\r\n\r\n\r\n /** \r\n * @param state Forced state\r\n */\r\n function toggleNode(nod: string | IPopupNode, force?: boolean) {\r\n let node: IPopupNode;\r\n\r\n if (typeof nod === 'string') {\r\n node = { ...nodes.find(el => el.id === nod) } as IPopupNode;\r\n } else {\r\n node = { ...nod };\r\n }\r\n\r\n if (!node.id) return;\r\n if ((settings.preventStateChange || node.settings.preventStateChange) && force === undefined) return console.warn(`Popup action prevented`);\r\n\r\n const open = force ?? !node?.open;\r\n\r\n node.open = open;\r\n node.zIndex = open ? Math.max(...nodes.map(el => el.zIndex), 0) + 1 : 0;\r\n\r\n setNodes(prev => [...prev.filter(el => el.id !== node.id), node]);\r\n\r\n // Hide scroll on open\r\n if (settings.disableScroll && node.settings.disableScroll && open) {\r\n document.body.classList.add('fkw-popup--noScroll');\r\n }\r\n\r\n // Show scroll if no popup open\r\n if (!open && !nodes.filter(el => el.id !== node.id).some(el => el.open)) {\r\n document.body.classList.remove('fkw-popup--noScroll');\r\n }\r\n }\r\n\r\n /** Register new node */\r\n function registerNode(node: IPopupNode) {\r\n setNodes(prev => [...prev, node]);\r\n\r\n if (node.open) toggleNode(node, true);\r\n }\r\n\r\n function toggleDocument(id: string, e: React.MouseEvent) {\r\n const node: IPopupNode = { ...nodes.find(el => el.id === id) } as IPopupNode;\r\n if (!node.id) return;\r\n if (!node.settings.exitOnDocument) return;\r\n\r\n const popup = (e.target as HTMLElement).closest('.fkw-popup');\r\n if (popup || !node.settings.exitOnDocument || !settings.exitOnDocument) return;\r\n\r\n toggleNode(node.id);\r\n }\r\n\r\n\r\n\r\n return <Suspense>\r\n <PopupContext.Provider value={context}>\r\n {children}\r\n\r\n <section className={cn(`fkw-popup-container`, className)} id='fkw-popup-container' {...props}></section>\r\n </PopupContext.Provider>\r\n </Suspense>;\r\n};\r\n\r\n\r\n\r\n/** \r\n * Popup window\r\n */\r\nexport const PopupWindow: FC<IPopupWindowProps> = ({ children, className, layerClassName, style, id, settings: initialSettings, isOpen: state, setIsOpen: stateSetter, animation: initialAnimation, onExit, onOpen, ...props }) => {\r\n const ctx = useContext(PopupContext) as IPopupContextProps;\r\n\r\n state = useMemo(() => state ?? false, []);\r\n\r\n const [animation] = useState<PopupWindowAnimationType>(initialAnimation ?? 'scale');\r\n const [settings] = useState<IPopupSettings>(reassingObject(initialSettings ?? {}, DEFAULT_SETTINGS));\r\n const [container, setContainer] = useState<Element | null>(null);\r\n\r\n const [isOpen, setIsOpen] = useMixedState(state, stateSetter);\r\n const [zIndex, setZIndex] = useState<number>(0);\r\n\r\n\r\n\r\n // Mount\r\n useEffect(() => {\r\n setContainer(document.querySelector('#fkw-popup-container'));\r\n\r\n ctx.registerNode({\r\n id,\r\n open: state,\r\n zIndex: 0,\r\n settings\r\n });\r\n }, []);\r\n\r\n // Handle onOpen, onExit\r\n useEffect(() => {\r\n if (isOpen && onOpen) onOpen();\r\n if (!isOpen && onExit) onExit();\r\n }, [isOpen]);\r\n\r\n // Listen context\r\n useEffect(() => {\r\n const node = ctx.nodes.find(el => el.id === id);\r\n if (!node) return;\r\n\r\n setIsOpen(node.open);\r\n\r\n if (node.zIndex !== 0) {\r\n // Instantly update zIndex\r\n setZIndex(node.zIndex);\r\n } else {\r\n // Timeout zIndex update\r\n setTimeout(() => {\r\n setZIndex(node.zIndex);\r\n }, 200); // TODO: fix constant animation delay timeout\r\n }\r\n }, [ctx]);\r\n\r\n\r\n\r\n if (!container) return null;\r\n\r\n return createPortal(<section\r\n id={id}\r\n className={cn(`fkw-popup-layer`, isOpen && 'fkw-popup-layer--open', layerClassName)}\r\n style={{ zIndex: 10000 + zIndex, cursor: settings.exitOnDocument && !settings.preventStateChange ? 'pointer' : 'auto', ...style }}\r\n onClick={settings.exitOnDocument && !settings.preventStateChange ? e => ctx.toggleDocument(id, e) : undefined}\r\n >\r\n <article\r\n className={cn(`fkw-popup`, isOpen && 'fkw-popup--open', animation && `fkw-popup-animation--${animation}`, className)}\r\n role='dialog'\r\n aria-modal\r\n aria-hidden={!isOpen}\r\n {...props}\r\n >\r\n {children}\r\n </article>\r\n </section>, container);\r\n};\r\n\r\n\r\n\r\n/** \r\n * Popup trigger button\r\n */\r\nexport const PopupButton: FC<IPopupButtonProps> = ({ children, as, className, onClick, disabled, popupId, ...props }) => {\r\n const ctx = useContext(PopupContext) as IPopupContextProps;\r\n\r\n const [isActive, setIsActive] = useState<boolean>(false);\r\n\r\n const Tag: keyof JSX.IntrinsicElements = as ?? 'button';\r\n\r\n\r\n\r\n // Listen context\r\n useEffect(() => {\r\n const node = ctx.nodes.find(el => el.id === popupId);\r\n if (!node) return;\r\n\r\n setIsActive(node.open);\r\n }, [ctx]);\r\n\r\n\r\n\r\n function toggle(e: React.MouseEvent) {\r\n ctx.toggleNode(popupId);\r\n onClick && onClick(e);\r\n }\r\n\r\n\r\n\r\n return <Tag className={cn('fkw-popup-button', isActive && 'fkw-popup-button--active', className)} role='button' onClick={toggle} aria-haspopup=\"dialog\" tabIndex={0} disabled={disabled} aria-disabled={disabled} data-fkw-popup-operator={popupId} aria-label={isActive ? 'Close Popup' : 'Open Popup'} {...props}>\r\n {children}\r\n </Tag>;\r\n};\r\n\r\n\r\n\r\nfunction reassingObject(target: object, refference: object) {\r\n const payload = { ...refference };\r\n\r\n for (const key in target) {\r\n payload[key] = target[key];\r\n }\r\n\r\n return payload;\r\n}"],"names":["hasOwn","classNames","classes","i","arg","appendClass","parseValue","key","value","newClass","module","useMixedState","initialStateOrValue","externalSetter","isControlled","defaultState","defaultSetter","useState","DEFAULT_SETTINGS","PopupContext","createContext","PopupLayer","className","initialSettings","children","props","settings","reassingObject","nodes","setNodes","context","toggleNode","registerNode","toggleDocument","useEffect","handleKeydown","e","maxZIndex","el","node","nod","force","open","prev","id","Suspense","jsxs","jsx","cn","PopupWindow","layerClassName","style","state","stateSetter","initialAnimation","onExit","onOpen","ctx","useContext","useMemo","animation","container","setContainer","isOpen","setIsOpen","zIndex","setZIndex","createPortal","PopupButton","as","onClick","disabled","popupId","isActive","setIsActive","Tag","toggle","target","refference","payload"],"mappings":";;;;;;;;;;;;;;;AAOA,KAAC,WAAY;AAGZ,UAAIA,IAAS,CAAA,EAAG;AAEhB,eAASC,IAAc;AAGtB,iBAFIC,IAAU,IAELC,IAAI,GAAGA,IAAI,UAAU,QAAQA,KAAK;AAC1C,cAAIC,IAAM,UAAUD,CAAC;AACrB,UAAIC,MACHF,IAAUG,EAAYH,GAASI,EAAWF,CAAG,CAAC;AAAA,QAElD;AAEE,eAAOF;AAAA,MACT;AAEC,eAASI,EAAYF,GAAK;AACzB,YAAI,OAAOA,KAAQ,YAAY,OAAOA,KAAQ;AAC7C,iBAAOA;AAGR,YAAI,OAAOA,KAAQ;AAClB,iBAAO;AAGR,YAAI,MAAM,QAAQA,CAAG;AACpB,iBAAOH,EAAW,MAAM,MAAMG,CAAG;AAGlC,YAAIA,EAAI,aAAa,OAAO,UAAU,YAAY,CAACA,EAAI,SAAS,SAAQ,EAAG,SAAS,eAAe;AAClG,iBAAOA,EAAI,SAAU;AAGtB,YAAIF,IAAU;AAEd,iBAASK,KAAOH;AACf,UAAIJ,EAAO,KAAKI,GAAKG,CAAG,KAAKH,EAAIG,CAAG,MACnCL,IAAUG,EAAYH,GAASK,CAAG;AAIpC,eAAOL;AAAA,MACT;AAEC,eAASG,EAAaG,GAAOC,GAAU;AACtC,eAAKA,IAIDD,IACIA,IAAQ,MAAMC,IAGfD,IAAQC,IAPPD;AAAA,MAQV;AAEC,MAAqCE,EAAO,WAC3CT,EAAW,UAAUA,GACrBS,YAAiBT,KAOjB,OAAO,aAAaA;AAAA,IAEtB;;;;;ACzDwB,SAAAU,EAAiBC,GAAqCC,GAAiC;AAC7G,QAAMC,IAAe,UAAU,WAAW,KAAKD,MAAmB,QAE5D,CAACE,GAAcC,CAAa,IAAIC,EAAwBL,CAAmB;AAIjF,SAAIE,IACK;AAAA,IACLF;AAAA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ACnC,IAAAqB,EAAI,WAAWe,CAAO,GACtBF,KAAWA,EAAQlC,CAAC;AAAA,EAAA;AAKtB,SAAQ,gBAAAW,EAAA4B,GAAA,EAAI,WAAW3B,EAAG,oBAAoByB,KAAY,4BAA4BnD,CAAS,GAAG,MAAK,UAAS,SAASsD,GAAQ,iBAAc,UAAS,UAAU,GAAG,UAAAL,GAAoB,iBAAeA,GAAU,2BAAyBC,GAAS,cAAYC,IAAW,gBAAgB,cAAe,GAAGhD,GAC1S,UAAAD,EACH,CAAA;AACF;AAIA,SAASG,EAAekD,GAAgBC,GAAoB;AACpD,QAAAC,IAAU,EAAE,GAAGD,EAAW;AAEhC,aAAWvE,KAAOsE;AACR,IAAAE,EAAAxE,CAAG,IAAIsE,EAAOtE,CAAG;AAGpB,SAAAwE;AACT;;;;;;;","x_google_ignoreList":[0]}
1
+ {"version":3,"file":"index.es.js","sources":["../node_modules/classnames/index.js","../src/_package/Package.tsx"],"sourcesContent":["/*!\n\tCopyright (c) 2018 Jed Watson.\n\tLicensed under the MIT License (MIT), see\n\thttp://jedwatson.github.io/classnames\n*/\n/* global define */\n\n(function () {\n\t'use strict';\n\n\tvar hasOwn = {}.hasOwnProperty;\n\n\tfunction classNames () {\n\t\tvar classes = '';\n\n\t\tfor (var i = 0; i < arguments.length; i++) {\n\t\t\tvar arg = arguments[i];\n\t\t\tif (arg) {\n\t\t\t\tclasses = appendClass(classes, parseValue(arg));\n\t\t\t}\n\t\t}\n\n\t\treturn classes;\n\t}\n\n\tfunction parseValue (arg) {\n\t\tif (typeof arg === 'string' || typeof arg === 'number') {\n\t\t\treturn arg;\n\t\t}\n\n\t\tif (typeof arg !== 'object') {\n\t\t\treturn '';\n\t\t}\n\n\t\tif (Array.isArray(arg)) {\n\t\t\treturn classNames.apply(null, arg);\n\t\t}\n\n\t\tif (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes('[native code]')) {\n\t\t\treturn arg.toString();\n\t\t}\n\n\t\tvar classes = '';\n\n\t\tfor (var key in arg) {\n\t\t\tif (hasOwn.call(arg, key) && arg[key]) {\n\t\t\t\tclasses = appendClass(classes, key);\n\t\t\t}\n\t\t}\n\n\t\treturn classes;\n\t}\n\n\tfunction appendClass (value, newClass) {\n\t\tif (!newClass) {\n\t\t\treturn value;\n\t\t}\n\t\n\t\tif (value) {\n\t\t\treturn value + ' ' + newClass;\n\t\t}\n\t\n\t\treturn value + newClass;\n\t}\n\n\tif (typeof module !== 'undefined' && module.exports) {\n\t\tclassNames.default = classNames;\n\t\tmodule.exports = classNames;\n\t} else if (typeof define === 'function' && typeof define.amd === 'object' && define.amd) {\n\t\t// register as 'classnames', consistent with npm package name\n\t\tdefine('classnames', [], function () {\n\t\t\treturn classNames;\n\t\t});\n\t} else {\n\t\twindow.classNames = classNames;\n\t}\n}());\n","import './styles.scss';\r\n\r\nimport React, { createContext, FC, JSX, Suspense, useContext, useEffect, useMemo, useState } from \"react\";\r\nimport cn from 'classnames';\r\nimport { IPopupButtonProps, IPopupContextProps, IPopupLayerProps, IPopupNode, IPopupSettings, PopupWindowAnimationType, IPopupWindowProps } from './Interfaces';\r\nimport { createPortal } from 'react-dom';\r\nimport useMixedState from './useMixedState';\r\n\r\n\r\n\r\nconst DEFAULT_SETTINGS: Required<IPopupSettings> = {\r\n disableScroll: true,\r\n exitOnDocument: true,\r\n exitOnEscape: true,\r\n preventStateChange: false\r\n};\r\n\r\nconst PopupContext = createContext<IPopupContextProps>({} as IPopupContextProps);\r\n\r\n\r\n\r\n/** \r\n * Popup context provider. Must be inside body tag and in client environment (NextJS)\r\n */\r\nexport const PopupLayer: FC<IPopupLayerProps> = ({ className, settings: initialSettings, children, ...props }) => {\r\n const [settings] = useState<IPopupSettings>(reassingObject(initialSettings ?? {}, DEFAULT_SETTINGS));\r\n const [nodes, setNodes] = useState<IPopupNode[]>([]);\r\n\r\n const context: IPopupContextProps = {\r\n nodes,\r\n toggleNode,\r\n registerNode,\r\n toggleDocument\r\n };\r\n\r\n\r\n\r\n // Handle exitOnEscape\r\n useEffect(() => {\r\n if (typeof window === 'undefined') return;\r\n\r\n window.addEventListener('keydown', handleKeydown);\r\n\r\n function handleKeydown(e: KeyboardEvent) {\r\n const key = e.key;\r\n\r\n if (key === 'Escape') {\r\n const maxZIndex = Math.max(...nodes.filter(el => el.open).map(el => el.zIndex));\r\n const node = nodes.find(el => el.open && el.zIndex === maxZIndex);\r\n if (!node || !node.settings.exitOnEscape || !settings?.exitOnEscape) return;\r\n\r\n toggleNode(node.id);\r\n }\r\n }\r\n\r\n return () => {\r\n window.removeEventListener('keydown', handleKeydown);\r\n };\r\n }, [nodes]);\r\n\r\n\r\n /** \r\n * @param state Forced state\r\n */\r\n function toggleNode(nod: string | IPopupNode, force?: boolean) {\r\n let node: IPopupNode;\r\n\r\n if (typeof nod === 'string') {\r\n node = { ...nodes.find(el => el.id === nod) } as IPopupNode;\r\n } else {\r\n node = { ...nod };\r\n }\r\n\r\n if (!node.id) return;\r\n if ((settings.preventStateChange || node.settings.preventStateChange) && force === undefined) return console.warn(`Popup action prevented`);\r\n\r\n const open = force ?? !node?.open;\r\n\r\n node.open = open;\r\n node.zIndex = open ? Math.max(...nodes.map(el => el.zIndex), 0) + 1 : 0;\r\n\r\n setNodes(prev => [...prev.filter(el => el.id !== node.id), node]);\r\n\r\n // Hide scroll on open\r\n if (settings.disableScroll && node.settings.disableScroll && open) {\r\n document.body.classList.add('fkw-popup--noScroll');\r\n }\r\n\r\n // Show scroll if no popup open\r\n if (!open && !nodes.filter(el => el.id !== node.id).some(el => el.open)) {\r\n document.body.classList.remove('fkw-popup--noScroll');\r\n }\r\n }\r\n\r\n /** Register new node */\r\n function registerNode(node: IPopupNode) {\r\n setNodes(prev => [...prev, node]);\r\n\r\n if (node.open) toggleNode(node, true);\r\n }\r\n\r\n function toggleDocument(id: string, e: React.MouseEvent) {\r\n const node: IPopupNode = { ...nodes.find(el => el.id === id) } as IPopupNode;\r\n if (!node.id) return;\r\n if (!node.settings.exitOnDocument) return;\r\n\r\n const popup = (e.target as HTMLElement).closest('.fkw-popup');\r\n if (popup || !node.settings.exitOnDocument || !settings.exitOnDocument) return;\r\n\r\n toggleNode(node.id);\r\n }\r\n\r\n\r\n\r\n return <Suspense>\r\n <PopupContext.Provider value={context}>\r\n {children}\r\n\r\n <section className={cn(`fkw-popup-container`, className)} id='fkw-popup-container' {...props}></section>\r\n </PopupContext.Provider>\r\n </Suspense>;\r\n};\r\n\r\n\r\n\r\n/** \r\n * Popup window\r\n */\r\nexport const PopupWindow: FC<IPopupWindowProps> = ({ children, className, layerClassName, style, id, settings: initialSettings, isOpen: state, setIsOpen: stateSetter, animation: initialAnimation, onExit, onOpen, ...props }) => {\r\n const ctx = useContext(PopupContext) as IPopupContextProps;\r\n\r\n const [animation] = useState<PopupWindowAnimationType>(initialAnimation ?? 'scale');\r\n const [settings] = useState<IPopupSettings>(reassingObject(initialSettings ?? {}, DEFAULT_SETTINGS));\r\n const [container, setContainer] = useState<Element | null>(null);\r\n\r\n const [isOpen, setIsOpen] = useState(state ?? false);\r\n const [zIndex, setZIndex] = useState<number>(0);\r\n\r\n\r\n\r\n // Mount\r\n useEffect(() => {\r\n setContainer(document.querySelector('#fkw-popup-container'));\r\n\r\n ctx.registerNode({\r\n id,\r\n open: isOpen,\r\n zIndex: 0,\r\n settings\r\n });\r\n }, []);\r\n\r\n // Handle onOpen, onExit\r\n useEffect(() => {\r\n if (isOpen && onOpen) onOpen();\r\n if (!isOpen && onExit) onExit();\r\n }, [state]);\r\n\r\n // Listen context\r\n useEffect(() => {\r\n const node = ctx.nodes.find(el => el.id === id);\r\n if (!node) return;\r\n\r\n setIsOpen(node.open);\r\n\r\n if (node.zIndex !== 0) {\r\n // Instantly update zIndex\r\n setZIndex(node.zIndex);\r\n } else {\r\n // Timeout zIndex update\r\n setTimeout(() => {\r\n setZIndex(node.zIndex);\r\n }, 200); // TODO: fix constant animation delay timeout\r\n }\r\n }, [ctx]);\r\n\r\n // Sync out state on current change\r\n useEffect(() => {\r\n if (stateSetter === undefined || state === isOpen) return;\r\n\r\n stateSetter(isOpen);\r\n }, [isOpen]);\r\n\r\n // Sync current state on out change\r\n useEffect(() => {\r\n if (state === undefined || state === isOpen) return;\r\n\r\n ctx.toggleNode(id, state);\r\n }, [state]);\r\n\r\n\r\n\r\n if (!container) return null;\r\n\r\n return createPortal(<section\r\n id={id}\r\n className={cn(`fkw-popup-layer`, isOpen && 'fkw-popup-layer--open', layerClassName)}\r\n style={{ zIndex: 10000 + zIndex, cursor: settings.exitOnDocument && !settings.preventStateChange ? 'pointer' : 'auto', ...style }}\r\n onClick={settings.exitOnDocument && !settings.preventStateChange ? e => ctx.toggleDocument(id, e) : undefined}\r\n >\r\n <article\r\n className={cn(`fkw-popup`, isOpen && 'fkw-popup--open', animation && `fkw-popup-animation--${animation}`, className)}\r\n role='dialog'\r\n aria-modal\r\n aria-hidden={!isOpen}\r\n {...props}\r\n >\r\n {children}\r\n </article>\r\n </section>, container);\r\n};\r\n\r\n\r\n\r\n/** \r\n * Popup trigger button\r\n */\r\nexport const PopupButton: FC<IPopupButtonProps> = ({ children, as, className, onClick, disabled, popupId, ...props }) => {\r\n const ctx = useContext(PopupContext) as IPopupContextProps;\r\n\r\n const [isActive, setIsActive] = useState<boolean>(false);\r\n\r\n const Tag: keyof JSX.IntrinsicElements = as ?? 'button';\r\n\r\n\r\n\r\n // Listen context\r\n useEffect(() => {\r\n const node = ctx.nodes.find(el => el.id === popupId);\r\n if (!node) return;\r\n\r\n setIsActive(node.open);\r\n }, [ctx]);\r\n\r\n\r\n\r\n function toggle(e: React.MouseEvent) {\r\n ctx.toggleNode(popupId);\r\n onClick && onClick(e);\r\n }\r\n\r\n\r\n\r\n return <Tag className={cn('fkw-popup-button', isActive && 'fkw-popup-button--active', className)} role='button' onClick={toggle} aria-haspopup=\"dialog\" tabIndex={0} disabled={disabled} aria-disabled={disabled} data-fkw-popup-operator={popupId} aria-label={isActive ? 'Close Popup' : 'Open Popup'} {...props}>\r\n {children}\r\n </Tag>;\r\n};\r\n\r\n\r\n\r\nfunction reassingObject(target: object, refference: object) {\r\n const payload = { ...refference };\r\n\r\n for (const key in target) {\r\n payload[key] = target[key];\r\n }\r\n\r\n return payload;\r\n}"],"names":["hasOwn","classNames","classes","i","arg","appendClass","parseValue","key","value","newClass","module","DEFAULT_SETTINGS","PopupContext","createContext","PopupLayer","className","initialSettings","children","props","settings","useState","reassingObject","nodes","setNodes","context","toggleNode","registerNode","toggleDocument","useEffect","handleKeydown","e","maxZIndex","el","node","nod","force","open","prev","id","Suspense","jsxs","jsx","cn","PopupWindow","layerClassName","style","state","stateSetter","initialAnimation","onExit","onOpen","ctx","useContext","animation","container","setContainer","isOpen","setIsOpen","zIndex","setZIndex","createPortal","PopupButton","as","onClick","disabled","popupId","isActive","setIsActive","Tag","toggle","target","refference","payload"],"mappings":";;;;;;;;;;;;;;;AAOA,KAAC,WAAY;AAGZ,UAAIA,IAAS,CAAA,EAAG;AAEhB,eAASC,IAAc;AAGtB,iBAFIC,IAAU,IAELC,IAAI,GAAGA,IAAI,UAAU,QAAQA,KAAK;AAC1C,cAAIC,IAAM,UAAUD,CAAC;AACrB,UAAIC,MACHF,IAAUG,EAAYH,GAASI,EAAWF,CAAG,CAAC;AAAA,QAElD;AAEE,eAAOF;AAAA,MACT;AAEC,eAASI,EAAYF,GAAK;AACzB,YAAI,OAAOA,KAAQ,YAAY,OAAOA,KAAQ;AAC7C,iBAAOA;AAGR,YAAI,OAAOA,KAAQ;AAClB,iBAAO;AAGR,YAAI,MAAM,QAAQA,CAAG;AACpB,iBAAOH,EAAW,MAAM,MAAMG,CAAG;AAGlC,YAAIA,EAAI,aAAa,OAAO,UAAU,YAAY,CAACA,EAAI,SAAS,SAAQ,EAAG,SAAS,eAAe;AAClG,iBAAOA,EAAI,SAAU;AAGtB,YAAIF,IAAU;AAEd,iBAASK,KAAOH;AACf,UAAIJ,EAAO,KAAKI,GAAKG,CAAG,KAAKH,EAAIG,CAAG,MACnCL,IAAUG,EA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AAC,GAAU,SAAAC,GAAS,GAAG/C,QAAY;AACjH,QAAAiC,IAAMC,EAAWxC,CAAY,GAE7B,CAACsD,GAAUC,CAAW,IAAI/C,EAAkB,EAAK,GAEjDgD,IAAmCN,KAAM;AAK/C,EAAAlC,EAAU,MAAM;AACd,UAAMK,IAAOkB,EAAI,MAAM,KAAK,CAAMnB,MAAAA,EAAG,OAAOiC,CAAO;AACnD,IAAKhC,KAELkC,EAAYlC,EAAK,IAAI;AAAA,EAAA,GACpB,CAACkB,CAAG,CAAC;AAIR,WAASkB,EAAOvC,GAAqB;AACnC,IAAAqB,EAAI,WAAWc,CAAO,GACtBF,KAAWA,EAAQjC,CAAC;AAAA,EAAA;AAKtB,SAAQ,gBAAAW,EAAA2B,GAAA,EAAI,WAAW1B,EAAG,oBAAoBwB,KAAY,4BAA4BnD,CAAS,GAAG,MAAK,UAAS,SAASsD,GAAQ,iBAAc,UAAS,UAAU,GAAG,UAAAL,GAAoB,iBAAeA,GAAU,2BAAyBC,GAAS,cAAYC,IAAW,gBAAgB,cAAe,GAAGhD,GAC1S,UAAAD,EACH,CAAA;AACF;AAIA,SAASI,EAAeiD,GAAgBC,GAAoB;AACpD,QAAAC,IAAU,EAAE,GAAGD,EAAW;AAEhC,aAAWhE,KAAO+D;AACR,IAAAE,EAAAjE,CAAG,IAAI+D,EAAO/D,CAAG;AAGpB,SAAAiE;AACT;;;;;;;","x_google_ignoreList":[0]}
package/dist/index.umd.js CHANGED
@@ -1,6 +1,6 @@
1
- (function(l,x){typeof exports=="object"&&typeof module<"u"?x(exports,require("react/jsx-runtime"),require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","react-dom"],x):(l=typeof globalThis<"u"?globalThis:l||self,x(l["@fullkekw/fkw-popup"]={},l.ReactJsxRuntime,l.React,l.ReactDOM))})(this,function(l,x,i,D){"use strict";function M(o){return o&&o.__esModule&&Object.prototype.hasOwnProperty.call(o,"default")?o.default:o}var O={exports:{}};/*!
1
+ (function(d,m){typeof exports=="object"&&typeof module<"u"?m(exports,require("react/jsx-runtime"),require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","react-dom"],m):(d=typeof globalThis<"u"?globalThis:d||self,m(d["@fullkekw/fkw-popup"]={},d.ReactJsxRuntime,d.React,d.ReactDOM))})(this,function(d,m,o,D){"use strict";function T(u){return u&&u.__esModule&&Object.prototype.hasOwnProperty.call(u,"default")?u.default:u}var h={exports:{}};/*!
2
2
  Copyright (c) 2018 Jed Watson.
3
3
  Licensed under the MIT License (MIT), see
4
4
  http://jedwatson.github.io/classnames
5
- */var P;function T(){return P||(P=1,function(o){(function(){var m={}.hasOwnProperty;function p(){for(var e="",n=0;n<arguments.length;n++){var c=arguments[n];c&&(e=s(e,f(c)))}return e}function f(e){if(typeof e=="string"||typeof e=="number")return e;if(typeof e!="object")return"";if(Array.isArray(e))return p.apply(null,e);if(e.toString!==Object.prototype.toString&&!e.toString.toString().includes("[native code]"))return e.toString();var n="";for(var c in e)m.call(e,c)&&e[c]&&(n=s(n,c));return n}function s(e,n){return n?e?e+" "+n:e+n:e}o.exports?(p.default=p,o.exports=p):window.classNames=p})()}(O)),O.exports}var _=T();const h=M(_);function L(o,m){const p=arguments.length===2&&m!==void 0,[f,s]=i.useState(o);return p?[o,m]:[f,s]}const C={disableScroll:!0,exitOnDocument:!0,exitOnEscape:!0,preventStateChange:!1},b=i.createContext({}),I=({className:o,settings:m,children:p,...f})=>{const[s]=i.useState(N(m??{},C)),[e,n]=i.useState([]),c={nodes:e,toggleNode:g,registerNode:y,toggleDocument:v};i.useEffect(()=>{if(typeof window>"u")return;window.addEventListener("keydown",a);function a(r){if(r.key==="Escape"){const d=Math.max(...e.filter(S=>S.open).map(S=>S.zIndex)),u=e.find(S=>S.open&&S.zIndex===d);if(!u||!u.settings.exitOnEscape||!(s!=null&&s.exitOnEscape))return;g(u.id)}}return()=>{window.removeEventListener("keydown",a)}},[e]);function g(a,r){let t;if(typeof a=="string"?t={...e.find(u=>u.id===a)}:t={...a},!t.id)return;if((s.preventStateChange||t.settings.preventStateChange)&&r===void 0)return console.warn("Popup action prevented");const d=r??!(t!=null&&t.open);t.open=d,t.zIndex=d?Math.max(...e.map(u=>u.zIndex),0)+1:0,n(u=>[...u.filter(S=>S.id!==t.id),t]),s.disableScroll&&t.settings.disableScroll&&d&&document.body.classList.add("fkw-popup--noScroll"),!d&&!e.filter(u=>u.id!==t.id).some(u=>u.open)&&document.body.classList.remove("fkw-popup--noScroll")}function y(a){n(r=>[...r,a]),a.open&&g(a,!0)}function v(a,r){const t={...e.find(u=>u.id===a)};!t.id||!t.settings.exitOnDocument||r.target.closest(".fkw-popup")||!t.settings.exitOnDocument||!s.exitOnDocument||g(t.id)}return x.jsx(i.Suspense,{children:x.jsxs(b.Provider,{value:c,children:[p,x.jsx("section",{className:h("fkw-popup-container",o),id:"fkw-popup-container",...f})]})})},E=({children:o,className:m,layerClassName:p,style:f,id:s,settings:e,isOpen:n,setIsOpen:c,animation:g,onExit:y,onOpen:v,...a})=>{const r=i.useContext(b);n=i.useMemo(()=>n??!1,[]);const[t]=i.useState(g??"scale"),[d]=i.useState(N(e??{},C)),[u,S]=i.useState(null),[k,A]=L(n,c),[B,z]=i.useState(0);return i.useEffect(()=>{S(document.querySelector("#fkw-popup-container")),r.registerNode({id:s,open:n,zIndex:0,settings:d})},[]),i.useEffect(()=>{k&&v&&v(),!k&&y&&y()},[k]),i.useEffect(()=>{const w=r.nodes.find(F=>F.id===s);w&&(A(w.open),w.zIndex!==0?z(w.zIndex):setTimeout(()=>{z(w.zIndex)},200))},[r]),u?D.createPortal(x.jsx("section",{id:s,className:h("fkw-popup-layer",k&&"fkw-popup-layer--open",p),style:{zIndex:1e4+B,cursor:d.exitOnDocument&&!d.preventStateChange?"pointer":"auto",...f},onClick:d.exitOnDocument&&!d.preventStateChange?w=>r.toggleDocument(s,w):void 0,children:x.jsx("article",{className:h("fkw-popup",k&&"fkw-popup--open",t&&`fkw-popup-animation--${t}`,m),role:"dialog","aria-modal":!0,"aria-hidden":!k,...a,children:o})}),u):null},j=({children:o,as:m,className:p,onClick:f,disabled:s,popupId:e,...n})=>{const c=i.useContext(b),[g,y]=i.useState(!1),v=m??"button";i.useEffect(()=>{const r=c.nodes.find(t=>t.id===e);r&&y(r.open)},[c]);function a(r){c.toggleNode(e),f&&f(r)}return x.jsx(v,{className:h("fkw-popup-button",g&&"fkw-popup-button--active",p),role:"button",onClick:a,"aria-haspopup":"dialog",tabIndex:0,disabled:s,"aria-disabled":s,"data-fkw-popup-operator":e,"aria-label":g?"Close Popup":"Open Popup",...n,children:o})};function N(o,m){const p={...m};for(const f in o)p[f]=o[f];return p}const q=Object.freeze(Object.defineProperty({__proto__:null,PopupButton:j,PopupLayer:I,PopupWindow:E},Symbol.toStringTag,{value:"Module"}));l.PopupButton=j,l.PopupLayer=I,l.PopupWindow=E,l.default=q,Object.defineProperties(l,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
5
+ */var P;function _(){return P||(P=1,function(u){(function(){var w={}.hasOwnProperty;function c(){for(var e="",n=0;n<arguments.length;n++){var f=arguments[n];f&&(e=i(e,l(f)))}return e}function l(e){if(typeof e=="string"||typeof e=="number")return e;if(typeof e!="object")return"";if(Array.isArray(e))return c.apply(null,e);if(e.toString!==Object.prototype.toString&&!e.toString.toString().includes("[native code]"))return e.toString();var n="";for(var f in e)w.call(e,f)&&e[f]&&(n=i(n,f));return n}function i(e,n){return n?e?e+" "+n:e+n:e}u.exports?(c.default=c,u.exports=c):window.classNames=c})()}(h)),h.exports}var L=_();const O=T(L),E={disableScroll:!0,exitOnDocument:!0,exitOnEscape:!0,preventStateChange:!1},b=o.createContext({}),I=({className:u,settings:w,children:c,...l})=>{const[i]=o.useState(j(w??{},E)),[e,n]=o.useState([]),f={nodes:e,toggleNode:y,registerNode:v,toggleDocument:k};o.useEffect(()=>{if(typeof window>"u")return;window.addEventListener("keydown",p);function p(s){if(s.key==="Escape"){const a=Math.max(...e.filter(x=>x.open).map(x=>x.zIndex)),r=e.find(x=>x.open&&x.zIndex===a);if(!r||!r.settings.exitOnEscape||!(i!=null&&i.exitOnEscape))return;y(r.id)}}return()=>{window.removeEventListener("keydown",p)}},[e]);function y(p,s){let t;if(typeof p=="string"?t={...e.find(r=>r.id===p)}:t={...p},!t.id)return;if((i.preventStateChange||t.settings.preventStateChange)&&s===void 0)return console.warn("Popup action prevented");const a=s??!(t!=null&&t.open);t.open=a,t.zIndex=a?Math.max(...e.map(r=>r.zIndex),0)+1:0,n(r=>[...r.filter(x=>x.id!==t.id),t]),i.disableScroll&&t.settings.disableScroll&&a&&document.body.classList.add("fkw-popup--noScroll"),!a&&!e.filter(r=>r.id!==t.id).some(r=>r.open)&&document.body.classList.remove("fkw-popup--noScroll")}function v(p){n(s=>[...s,p]),p.open&&y(p,!0)}function k(p,s){const t={...e.find(r=>r.id===p)};!t.id||!t.settings.exitOnDocument||s.target.closest(".fkw-popup")||!t.settings.exitOnDocument||!i.exitOnDocument||y(t.id)}return m.jsx(o.Suspense,{children:m.jsxs(b.Provider,{value:f,children:[c,m.jsx("section",{className:O("fkw-popup-container",u),id:"fkw-popup-container",...l})]})})},C=({children:u,className:w,layerClassName:c,style:l,id:i,settings:e,isOpen:n,setIsOpen:f,animation:y,onExit:v,onOpen:k,...p})=>{const s=o.useContext(b),[t]=o.useState(y??"scale"),[a]=o.useState(j(e??{},E)),[r,x]=o.useState(null),[g,q]=o.useState(n??!1),[A,z]=o.useState(0);return o.useEffect(()=>{x(document.querySelector("#fkw-popup-container")),s.registerNode({id:i,open:g,zIndex:0,settings:a})},[]),o.useEffect(()=>{g&&k&&k(),!g&&v&&v()},[n]),o.useEffect(()=>{const S=s.nodes.find(B=>B.id===i);S&&(q(S.open),S.zIndex!==0?z(S.zIndex):setTimeout(()=>{z(S.zIndex)},200))},[s]),o.useEffect(()=>{f===void 0||n===g||f(g)},[g]),o.useEffect(()=>{n===void 0||n===g||s.toggleNode(i,n)},[n]),r?D.createPortal(m.jsx("section",{id:i,className:O("fkw-popup-layer",g&&"fkw-popup-layer--open",c),style:{zIndex:1e4+A,cursor:a.exitOnDocument&&!a.preventStateChange?"pointer":"auto",...l},onClick:a.exitOnDocument&&!a.preventStateChange?S=>s.toggleDocument(i,S):void 0,children:m.jsx("article",{className:O("fkw-popup",g&&"fkw-popup--open",t&&`fkw-popup-animation--${t}`,w),role:"dialog","aria-modal":!0,"aria-hidden":!g,...p,children:u})}),r):null},N=({children:u,as:w,className:c,onClick:l,disabled:i,popupId:e,...n})=>{const f=o.useContext(b),[y,v]=o.useState(!1),k=w??"button";o.useEffect(()=>{const s=f.nodes.find(t=>t.id===e);s&&v(s.open)},[f]);function p(s){f.toggleNode(e),l&&l(s)}return m.jsx(k,{className:O("fkw-popup-button",y&&"fkw-popup-button--active",c),role:"button",onClick:p,"aria-haspopup":"dialog",tabIndex:0,disabled:i,"aria-disabled":i,"data-fkw-popup-operator":e,"aria-label":y?"Close Popup":"Open Popup",...n,children:u})};function j(u,w){const c={...w};for(const l in u)c[l]=u[l];return c}const M=Object.freeze(Object.defineProperty({__proto__:null,PopupButton:N,PopupLayer:I,PopupWindow:C},Symbol.toStringTag,{value:"Module"}));d.PopupButton=N,d.PopupLayer=I,d.PopupWindow=C,d.default=M,Object.defineProperties(d,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
6
6
  //# sourceMappingURL=index.umd.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.umd.js","sources":["../node_modules/classnames/index.js","../src/_package/useMixedState.ts","../src/_package/Package.tsx"],"sourcesContent":["/*!\n\tCopyright (c) 2018 Jed Watson.\n\tLicensed under the MIT License (MIT), see\n\thttp://jedwatson.github.io/classnames\n*/\n/* global define */\n\n(function () {\n\t'use strict';\n\n\tvar hasOwn = {}.hasOwnProperty;\n\n\tfunction classNames () {\n\t\tvar classes = '';\n\n\t\tfor (var i = 0; i < arguments.length; i++) {\n\t\t\tvar arg = arguments[i];\n\t\t\tif (arg) {\n\t\t\t\tclasses = appendClass(classes, parseValue(arg));\n\t\t\t}\n\t\t}\n\n\t\treturn classes;\n\t}\n\n\tfunction parseValue (arg) {\n\t\tif (typeof arg === 'string' || typeof arg === 'number') {\n\t\t\treturn arg;\n\t\t}\n\n\t\tif (typeof arg !== 'object') {\n\t\t\treturn '';\n\t\t}\n\n\t\tif (Array.isArray(arg)) {\n\t\t\treturn classNames.apply(null, arg);\n\t\t}\n\n\t\tif (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes('[native code]')) {\n\t\t\treturn arg.toString();\n\t\t}\n\n\t\tvar classes = '';\n\n\t\tfor (var key in arg) {\n\t\t\tif (hasOwn.call(arg, key) && arg[key]) {\n\t\t\t\tclasses = appendClass(classes, key);\n\t\t\t}\n\t\t}\n\n\t\treturn classes;\n\t}\n\n\tfunction appendClass (value, newClass) {\n\t\tif (!newClass) {\n\t\t\treturn value;\n\t\t}\n\t\n\t\tif (value) {\n\t\t\treturn value + ' ' + newClass;\n\t\t}\n\t\n\t\treturn value + newClass;\n\t}\n\n\tif (typeof module !== 'undefined' && module.exports) {\n\t\tclassNames.default = classNames;\n\t\tmodule.exports = classNames;\n\t} else if (typeof define === 'function' && typeof define.amd === 'object' && define.amd) {\n\t\t// register as 'classnames', consistent with npm package name\n\t\tdefine('classnames', [], function () {\n\t\t\treturn classNames;\n\t\t});\n\t} else {\n\t\twindow.classNames = classNames;\n\t}\n}());\n","'use client';\r\n\r\nimport { useState } from 'react';\r\nimport { StateSetter } from './Interfaces';\r\n\r\n\r\n\r\nexport default function useMixedState<S = undefined>(): [S | undefined, StateSetter<S | undefined>];\r\nexport default function useMixedState<S>(initialState: S | (() => S)): [S, StateSetter<S>];\r\nexport default function useMixedState<S>(state: S, setter?: StateSetter<S>): [S, StateSetter<S>];\r\n\r\n\r\n\r\n/** \r\n * Use mixed state hook\r\n * \r\n * @param initialStateOrValue Initial state, can be undefined, value or function. If externalSetter not specified, will return default state\r\n * @param externalSetter External state setter. If specified will return external state\r\n */\r\nexport default function useMixedState<S>(initialStateOrValue?: S | (() => S), externalSetter?: StateSetter<S>) {\r\n const isControlled = arguments.length === 2 && externalSetter !== undefined;\r\n\r\n const [defaultState, defaultSetter] = useState<S | undefined>(initialStateOrValue);\r\n\r\n\r\n\r\n if (isControlled) {\r\n return [\r\n initialStateOrValue as S,\r\n externalSetter as StateSetter<S>\r\n ];\r\n }\r\n\r\n return [defaultState, defaultSetter];\r\n}","import './styles.scss';\r\n\r\nimport React, { createContext, FC, JSX, Suspense, useContext, useEffect, useMemo, useState } from \"react\";\r\nimport cn from 'classnames';\r\nimport { IPopupButtonProps, IPopupContextProps, IPopupLayerProps, IPopupNode, IPopupSettings, PopupWindowAnimationType, IPopupWindowProps } from './Interfaces';\r\nimport { createPortal } from 'react-dom';\r\nimport useMixedState from './useMixedState';\r\n\r\n\r\n\r\nconst DEFAULT_SETTINGS: Required<IPopupSettings> = {\r\n disableScroll: true,\r\n exitOnDocument: true,\r\n exitOnEscape: true,\r\n preventStateChange: false\r\n};\r\n\r\nconst PopupContext = createContext<IPopupContextProps>({} as IPopupContextProps);\r\n\r\n\r\n\r\n/** \r\n * Popup context provider. Must be inside body tag and in client environment (NextJS)\r\n */\r\nexport const PopupLayer: FC<IPopupLayerProps> = ({ className, settings: initialSettings, children, ...props }) => {\r\n const [settings] = useState<IPopupSettings>(reassingObject(initialSettings ?? {}, DEFAULT_SETTINGS));\r\n const [nodes, setNodes] = useState<IPopupNode[]>([]);\r\n\r\n const context: IPopupContextProps = {\r\n nodes,\r\n toggleNode,\r\n registerNode,\r\n toggleDocument\r\n };\r\n\r\n\r\n\r\n // Handle exitOnEscape\r\n useEffect(() => {\r\n if (typeof window === 'undefined') return;\r\n\r\n window.addEventListener('keydown', handleKeydown);\r\n\r\n function handleKeydown(e: KeyboardEvent) {\r\n const key = e.key;\r\n\r\n if (key === 'Escape') {\r\n const maxZIndex = Math.max(...nodes.filter(el => el.open).map(el => el.zIndex));\r\n const node = nodes.find(el => el.open && el.zIndex === maxZIndex);\r\n if (!node || !node.settings.exitOnEscape || !settings?.exitOnEscape) return;\r\n\r\n toggleNode(node.id);\r\n }\r\n }\r\n\r\n return () => {\r\n window.removeEventListener('keydown', handleKeydown);\r\n };\r\n }, [nodes]);\r\n\r\n\r\n /** \r\n * @param state Forced state\r\n */\r\n function toggleNode(nod: string | IPopupNode, force?: boolean) {\r\n let node: IPopupNode;\r\n\r\n if (typeof nod === 'string') {\r\n node = { ...nodes.find(el => el.id === nod) } as IPopupNode;\r\n } else {\r\n node = { ...nod };\r\n }\r\n\r\n if (!node.id) return;\r\n if ((settings.preventStateChange || node.settings.preventStateChange) && force === undefined) return console.warn(`Popup action prevented`);\r\n\r\n const open = force ?? !node?.open;\r\n\r\n node.open = open;\r\n node.zIndex = open ? Math.max(...nodes.map(el => el.zIndex), 0) + 1 : 0;\r\n\r\n setNodes(prev => [...prev.filter(el => el.id !== node.id), node]);\r\n\r\n // Hide scroll on open\r\n if (settings.disableScroll && node.settings.disableScroll && open) {\r\n document.body.classList.add('fkw-popup--noScroll');\r\n }\r\n\r\n // Show scroll if no popup open\r\n if (!open && !nodes.filter(el => el.id !== node.id).some(el => el.open)) {\r\n document.body.classList.remove('fkw-popup--noScroll');\r\n }\r\n }\r\n\r\n /** Register new node */\r\n function registerNode(node: IPopupNode) {\r\n setNodes(prev => [...prev, node]);\r\n\r\n if (node.open) toggleNode(node, true);\r\n }\r\n\r\n function toggleDocument(id: string, e: React.MouseEvent) {\r\n const node: IPopupNode = { ...nodes.find(el => el.id === id) } as IPopupNode;\r\n if (!node.id) return;\r\n if (!node.settings.exitOnDocument) return;\r\n\r\n const popup = (e.target as HTMLElement).closest('.fkw-popup');\r\n if (popup || !node.settings.exitOnDocument || !settings.exitOnDocument) return;\r\n\r\n toggleNode(node.id);\r\n }\r\n\r\n\r\n\r\n return <Suspense>\r\n <PopupContext.Provider value={context}>\r\n {children}\r\n\r\n <section className={cn(`fkw-popup-container`, className)} id='fkw-popup-container' {...props}></section>\r\n </PopupContext.Provider>\r\n </Suspense>;\r\n};\r\n\r\n\r\n\r\n/** \r\n * Popup window\r\n */\r\nexport const PopupWindow: FC<IPopupWindowProps> = ({ children, className, layerClassName, style, id, settings: initialSettings, isOpen: state, setIsOpen: stateSetter, animation: initialAnimation, onExit, onOpen, ...props }) => {\r\n const ctx = useContext(PopupContext) as IPopupContextProps;\r\n\r\n state = useMemo(() => state ?? false, []);\r\n\r\n const [animation] = useState<PopupWindowAnimationType>(initialAnimation ?? 'scale');\r\n const [settings] = useState<IPopupSettings>(reassingObject(initialSettings ?? {}, DEFAULT_SETTINGS));\r\n const [container, setContainer] = useState<Element | null>(null);\r\n\r\n const [isOpen, setIsOpen] = useMixedState(state, stateSetter);\r\n const [zIndex, setZIndex] = useState<number>(0);\r\n\r\n\r\n\r\n // Mount\r\n useEffect(() => {\r\n setContainer(document.querySelector('#fkw-popup-container'));\r\n\r\n ctx.registerNode({\r\n id,\r\n open: state,\r\n zIndex: 0,\r\n settings\r\n });\r\n }, []);\r\n\r\n // Handle onOpen, onExit\r\n useEffect(() => {\r\n if (isOpen && onOpen) onOpen();\r\n if (!isOpen && onExit) onExit();\r\n }, [isOpen]);\r\n\r\n // Listen context\r\n useEffect(() => {\r\n const node = ctx.nodes.find(el => el.id === id);\r\n if (!node) return;\r\n\r\n setIsOpen(node.open);\r\n\r\n if (node.zIndex !== 0) {\r\n // Instantly update zIndex\r\n setZIndex(node.zIndex);\r\n } else {\r\n // Timeout zIndex update\r\n setTimeout(() => {\r\n setZIndex(node.zIndex);\r\n }, 200); // TODO: fix constant animation delay timeout\r\n }\r\n }, [ctx]);\r\n\r\n\r\n\r\n if (!container) return null;\r\n\r\n return createPortal(<section\r\n id={id}\r\n className={cn(`fkw-popup-layer`, isOpen && 'fkw-popup-layer--open', layerClassName)}\r\n style={{ zIndex: 10000 + zIndex, cursor: settings.exitOnDocument && !settings.preventStateChange ? 'pointer' : 'auto', ...style }}\r\n onClick={settings.exitOnDocument && !settings.preventStateChange ? e => ctx.toggleDocument(id, e) : undefined}\r\n >\r\n <article\r\n className={cn(`fkw-popup`, isOpen && 'fkw-popup--open', animation && `fkw-popup-animation--${animation}`, className)}\r\n role='dialog'\r\n aria-modal\r\n aria-hidden={!isOpen}\r\n {...props}\r\n >\r\n {children}\r\n </article>\r\n </section>, container);\r\n};\r\n\r\n\r\n\r\n/** \r\n * Popup trigger button\r\n */\r\nexport const PopupButton: FC<IPopupButtonProps> = ({ children, as, className, onClick, disabled, popupId, ...props }) => {\r\n const ctx = useContext(PopupContext) as IPopupContextProps;\r\n\r\n const [isActive, setIsActive] = useState<boolean>(false);\r\n\r\n const Tag: keyof JSX.IntrinsicElements = as ?? 'button';\r\n\r\n\r\n\r\n // Listen context\r\n useEffect(() => {\r\n const node = ctx.nodes.find(el => el.id === popupId);\r\n if (!node) return;\r\n\r\n setIsActive(node.open);\r\n }, [ctx]);\r\n\r\n\r\n\r\n function toggle(e: React.MouseEvent) {\r\n ctx.toggleNode(popupId);\r\n onClick && onClick(e);\r\n }\r\n\r\n\r\n\r\n return <Tag className={cn('fkw-popup-button', isActive && 'fkw-popup-button--active', className)} role='button' onClick={toggle} aria-haspopup=\"dialog\" tabIndex={0} disabled={disabled} aria-disabled={disabled} data-fkw-popup-operator={popupId} aria-label={isActive ? 'Close Popup' : 'Open Popup'} {...props}>\r\n {children}\r\n </Tag>;\r\n};\r\n\r\n\r\n\r\nfunction reassingObject(target: object, refference: object) {\r\n const payload = { ...refference };\r\n\r\n for (const key in target) {\r\n payload[key] = target[key];\r\n }\r\n\r\n return payload;\r\n}"],"names":["hasOwn","classNames","classes","i","arg","appendClass","parseValue","key","value","newClass","module","useMixedState","initialStateOrValue","externalSetter","isControlled","defaultState","defaultSetter","useState","DEFAULT_SETTINGS","PopupContext","createContext","PopupLayer","className","initialSettings","children","props","settings","reassingObject","nodes","setNodes","context","toggleNode","registerNode","toggleDocument","useEffect","handleKeydown","e","maxZIndex","el","node","nod","force","open","prev","id","Suspense","jsxs","jsx","cn","PopupWindow","layerClassName","style","state","stateSetter","initialAnimation","onExit","onOpen","ctx","useContext","useMemo","animation","container","setContainer","isOpen","setIsOpen","zIndex","setZIndex","createPortal","PopupButton","as","onClick","disabled","popupId","isActive","setIsActive","Tag","toggle","target","refference","payload"],"mappings":";;;;iDAOC,UAAY,CAGZ,IAAIA,EAAS,CAAA,EAAG,eAEhB,SAASC,GAAc,CAGtB,QAFIC,EAAU,GAELC,EAAI,EAAGA,EAAI,UAAU,OAAQA,IAAK,CAC1C,IAAIC,EAAM,UAAUD,CAAC,EACjBC,IACHF,EAAUG,EAAYH,EAASI,EAAWF,CAAG,CAAC,EAElD,CAEE,OAAOF,CACT,CAEC,SAASI,EAAYF,EAAK,CACzB,GAAI,OAAOA,GAAQ,UAAY,OAAOA,GAAQ,SAC7C,OAAOA,EAGR,GAAI,OAAOA,GAAQ,SAClB,MAAO,GAGR,GAAI,MAAM,QAAQA,CAAG,EACpB,OAAOH,EAAW,MAAM,KAAMG,CAAG,EAGlC,GAAIA,EAAI,WAAa,OAAO,UAAU,UAAY,CAACA,EAAI,SAAS,SAAQ,EAAG,SAAS,eAAe,EAClG,OAAOA,EAAI,SAAU,EAGtB,IAAIF,EAAU,GAEd,QAASK,KAAOH,EACXJ,EAAO,KAAKI,EAAKG,CAAG,GAAKH,EAAIG,CAAG,IACnCL,EAAUG,EAAYH,EAASK,CAAG,GAIpC,OAAOL,CACT,CAEC,SAASG,EAAaG,EAAOC,EAAU,CACtC,OAAKA,EAIDD,EACIA,EAAQ,IAAMC,EAGfD,EAAQC,EAPPD,CAQV,CAEsCE,EAAO,SAC3CT,EAAW,QAAUA,EACrBS,UAAiBT,GAOjB,OAAO,WAAaA,CAEtB,2CCzDwB,SAAAU,EAAiBC,EAAqCC,EAAiC,CAC7G,MAAMC,EAAe,UAAU,SAAW,GAAKD,IAAmB,OAE5D,CAACE,EAAcC,CAAa,EAAIC,EAAAA,SAAwBL,CAAmB,EAIjF,OAAIE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AoB,CACpD,MAAAC,EAAU,CAAE,GAAGD,CAAW,EAEhC,UAAWvE,KAAOsE,EACRE,EAAAxE,CAAG,EAAIsE,EAAOtE,CAAG,EAGpB,OAAAwE,CACT","x_google_ignoreList":[0]}
1
+ {"version":3,"file":"index.umd.js","sources":["../node_modules/classnames/index.js","../src/_package/Package.tsx"],"sourcesContent":["/*!\n\tCopyright (c) 2018 Jed Watson.\n\tLicensed under the MIT License (MIT), see\n\thttp://jedwatson.github.io/classnames\n*/\n/* global define */\n\n(function () {\n\t'use strict';\n\n\tvar hasOwn = {}.hasOwnProperty;\n\n\tfunction classNames () {\n\t\tvar classes = '';\n\n\t\tfor (var i = 0; i < arguments.length; i++) {\n\t\t\tvar arg = arguments[i];\n\t\t\tif (arg) {\n\t\t\t\tclasses = appendClass(classes, parseValue(arg));\n\t\t\t}\n\t\t}\n\n\t\treturn classes;\n\t}\n\n\tfunction parseValue (arg) {\n\t\tif (typeof arg === 'string' || typeof arg === 'number') {\n\t\t\treturn arg;\n\t\t}\n\n\t\tif (typeof arg !== 'object') {\n\t\t\treturn '';\n\t\t}\n\n\t\tif (Array.isArray(arg)) {\n\t\t\treturn classNames.apply(null, arg);\n\t\t}\n\n\t\tif (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes('[native code]')) {\n\t\t\treturn arg.toString();\n\t\t}\n\n\t\tvar classes = '';\n\n\t\tfor (var key in arg) {\n\t\t\tif (hasOwn.call(arg, key) && arg[key]) {\n\t\t\t\tclasses = appendClass(classes, key);\n\t\t\t}\n\t\t}\n\n\t\treturn classes;\n\t}\n\n\tfunction appendClass (value, newClass) {\n\t\tif (!newClass) {\n\t\t\treturn value;\n\t\t}\n\t\n\t\tif (value) {\n\t\t\treturn value + ' ' + newClass;\n\t\t}\n\t\n\t\treturn value + newClass;\n\t}\n\n\tif (typeof module !== 'undefined' && module.exports) {\n\t\tclassNames.default = classNames;\n\t\tmodule.exports = classNames;\n\t} else if (typeof define === 'function' && typeof define.amd === 'object' && define.amd) {\n\t\t// register as 'classnames', consistent with npm package name\n\t\tdefine('classnames', [], function () {\n\t\t\treturn classNames;\n\t\t});\n\t} else {\n\t\twindow.classNames = classNames;\n\t}\n}());\n","import './styles.scss';\r\n\r\nimport React, { createContext, FC, JSX, Suspense, useContext, useEffect, useMemo, useState } from \"react\";\r\nimport cn from 'classnames';\r\nimport { IPopupButtonProps, IPopupContextProps, IPopupLayerProps, IPopupNode, IPopupSettings, PopupWindowAnimationType, IPopupWindowProps } from './Interfaces';\r\nimport { createPortal } from 'react-dom';\r\nimport useMixedState from './useMixedState';\r\n\r\n\r\n\r\nconst DEFAULT_SETTINGS: Required<IPopupSettings> = {\r\n disableScroll: true,\r\n exitOnDocument: true,\r\n exitOnEscape: true,\r\n preventStateChange: false\r\n};\r\n\r\nconst PopupContext = createContext<IPopupContextProps>({} as IPopupContextProps);\r\n\r\n\r\n\r\n/** \r\n * Popup context provider. Must be inside body tag and in client environment (NextJS)\r\n */\r\nexport const PopupLayer: FC<IPopupLayerProps> = ({ className, settings: initialSettings, children, ...props }) => {\r\n const [settings] = useState<IPopupSettings>(reassingObject(initialSettings ?? {}, DEFAULT_SETTINGS));\r\n const [nodes, setNodes] = useState<IPopupNode[]>([]);\r\n\r\n const context: IPopupContextProps = {\r\n nodes,\r\n toggleNode,\r\n registerNode,\r\n toggleDocument\r\n };\r\n\r\n\r\n\r\n // Handle exitOnEscape\r\n useEffect(() => {\r\n if (typeof window === 'undefined') return;\r\n\r\n window.addEventListener('keydown', handleKeydown);\r\n\r\n function handleKeydown(e: KeyboardEvent) {\r\n const key = e.key;\r\n\r\n if (key === 'Escape') {\r\n const maxZIndex = Math.max(...nodes.filter(el => el.open).map(el => el.zIndex));\r\n const node = nodes.find(el => el.open && el.zIndex === maxZIndex);\r\n if (!node || !node.settings.exitOnEscape || !settings?.exitOnEscape) return;\r\n\r\n toggleNode(node.id);\r\n }\r\n }\r\n\r\n return () => {\r\n window.removeEventListener('keydown', handleKeydown);\r\n };\r\n }, [nodes]);\r\n\r\n\r\n /** \r\n * @param state Forced state\r\n */\r\n function toggleNode(nod: string | IPopupNode, force?: boolean) {\r\n let node: IPopupNode;\r\n\r\n if (typeof nod === 'string') {\r\n node = { ...nodes.find(el => el.id === nod) } as IPopupNode;\r\n } else {\r\n node = { ...nod };\r\n }\r\n\r\n if (!node.id) return;\r\n if ((settings.preventStateChange || node.settings.preventStateChange) && force === undefined) return console.warn(`Popup action prevented`);\r\n\r\n const open = force ?? !node?.open;\r\n\r\n node.open = open;\r\n node.zIndex = open ? Math.max(...nodes.map(el => el.zIndex), 0) + 1 : 0;\r\n\r\n setNodes(prev => [...prev.filter(el => el.id !== node.id), node]);\r\n\r\n // Hide scroll on open\r\n if (settings.disableScroll && node.settings.disableScroll && open) {\r\n document.body.classList.add('fkw-popup--noScroll');\r\n }\r\n\r\n // Show scroll if no popup open\r\n if (!open && !nodes.filter(el => el.id !== node.id).some(el => el.open)) {\r\n document.body.classList.remove('fkw-popup--noScroll');\r\n }\r\n }\r\n\r\n /** Register new node */\r\n function registerNode(node: IPopupNode) {\r\n setNodes(prev => [...prev, node]);\r\n\r\n if (node.open) toggleNode(node, true);\r\n }\r\n\r\n function toggleDocument(id: string, e: React.MouseEvent) {\r\n const node: IPopupNode = { ...nodes.find(el => el.id === id) } as IPopupNode;\r\n if (!node.id) return;\r\n if (!node.settings.exitOnDocument) return;\r\n\r\n const popup = (e.target as HTMLElement).closest('.fkw-popup');\r\n if (popup || !node.settings.exitOnDocument || !settings.exitOnDocument) return;\r\n\r\n toggleNode(node.id);\r\n }\r\n\r\n\r\n\r\n return <Suspense>\r\n <PopupContext.Provider value={context}>\r\n {children}\r\n\r\n <section className={cn(`fkw-popup-container`, className)} id='fkw-popup-container' {...props}></section>\r\n </PopupContext.Provider>\r\n </Suspense>;\r\n};\r\n\r\n\r\n\r\n/** \r\n * Popup window\r\n */\r\nexport const PopupWindow: FC<IPopupWindowProps> = ({ children, className, layerClassName, style, id, settings: initialSettings, isOpen: state, setIsOpen: stateSetter, animation: initialAnimation, onExit, onOpen, ...props }) => {\r\n const ctx = useContext(PopupContext) as IPopupContextProps;\r\n\r\n const [animation] = useState<PopupWindowAnimationType>(initialAnimation ?? 'scale');\r\n const [settings] = useState<IPopupSettings>(reassingObject(initialSettings ?? {}, DEFAULT_SETTINGS));\r\n const [container, setContainer] = useState<Element | null>(null);\r\n\r\n const [isOpen, setIsOpen] = useState(state ?? false);\r\n const [zIndex, setZIndex] = useState<number>(0);\r\n\r\n\r\n\r\n // Mount\r\n useEffect(() => {\r\n setContainer(document.querySelector('#fkw-popup-container'));\r\n\r\n ctx.registerNode({\r\n id,\r\n open: isOpen,\r\n zIndex: 0,\r\n settings\r\n });\r\n }, []);\r\n\r\n // Handle onOpen, onExit\r\n useEffect(() => {\r\n if (isOpen && onOpen) onOpen();\r\n if (!isOpen && onExit) onExit();\r\n }, [state]);\r\n\r\n // Listen context\r\n useEffect(() => {\r\n const node = ctx.nodes.find(el => el.id === id);\r\n if (!node) return;\r\n\r\n setIsOpen(node.open);\r\n\r\n if (node.zIndex !== 0) {\r\n // Instantly update zIndex\r\n setZIndex(node.zIndex);\r\n } else {\r\n // Timeout zIndex update\r\n setTimeout(() => {\r\n setZIndex(node.zIndex);\r\n }, 200); // TODO: fix constant animation delay timeout\r\n }\r\n }, [ctx]);\r\n\r\n // Sync out state on current change\r\n useEffect(() => {\r\n if (stateSetter === undefined || state === isOpen) return;\r\n\r\n stateSetter(isOpen);\r\n }, [isOpen]);\r\n\r\n // Sync current state on out change\r\n useEffect(() => {\r\n if (state === undefined || state === isOpen) return;\r\n\r\n ctx.toggleNode(id, state);\r\n }, [state]);\r\n\r\n\r\n\r\n if (!container) return null;\r\n\r\n return createPortal(<section\r\n id={id}\r\n className={cn(`fkw-popup-layer`, isOpen && 'fkw-popup-layer--open', layerClassName)}\r\n style={{ zIndex: 10000 + zIndex, cursor: settings.exitOnDocument && !settings.preventStateChange ? 'pointer' : 'auto', ...style }}\r\n onClick={settings.exitOnDocument && !settings.preventStateChange ? e => ctx.toggleDocument(id, e) : undefined}\r\n >\r\n <article\r\n className={cn(`fkw-popup`, isOpen && 'fkw-popup--open', animation && `fkw-popup-animation--${animation}`, className)}\r\n role='dialog'\r\n aria-modal\r\n aria-hidden={!isOpen}\r\n {...props}\r\n >\r\n {children}\r\n </article>\r\n </section>, container);\r\n};\r\n\r\n\r\n\r\n/** \r\n * Popup trigger button\r\n */\r\nexport const PopupButton: FC<IPopupButtonProps> = ({ children, as, className, onClick, disabled, popupId, ...props }) => {\r\n const ctx = useContext(PopupContext) as IPopupContextProps;\r\n\r\n const [isActive, setIsActive] = useState<boolean>(false);\r\n\r\n const Tag: keyof JSX.IntrinsicElements = as ?? 'button';\r\n\r\n\r\n\r\n // Listen context\r\n useEffect(() => {\r\n const node = ctx.nodes.find(el => el.id === popupId);\r\n if (!node) return;\r\n\r\n setIsActive(node.open);\r\n }, [ctx]);\r\n\r\n\r\n\r\n function toggle(e: React.MouseEvent) {\r\n ctx.toggleNode(popupId);\r\n onClick && onClick(e);\r\n }\r\n\r\n\r\n\r\n return <Tag className={cn('fkw-popup-button', isActive && 'fkw-popup-button--active', className)} role='button' onClick={toggle} aria-haspopup=\"dialog\" tabIndex={0} disabled={disabled} aria-disabled={disabled} data-fkw-popup-operator={popupId} aria-label={isActive ? 'Close Popup' : 'Open Popup'} {...props}>\r\n {children}\r\n </Tag>;\r\n};\r\n\r\n\r\n\r\nfunction reassingObject(target: object, refference: object) {\r\n const payload = { ...refference };\r\n\r\n for (const key in target) {\r\n payload[key] = target[key];\r\n }\r\n\r\n return payload;\r\n}"],"names":["hasOwn","classNames","classes","i","arg","appendClass","parseValue","key","value","newClass","module","DEFAULT_SETTINGS","PopupContext","createContext","PopupLayer","className","initialSettings","children","props","settings","useState","reassingObject","nodes","setNodes","context","toggleNode","registerNode","toggleDocument","useEffect","handleKeydown","e","maxZIndex","el","node","nod","force","open","prev","id","Suspense","jsxs","jsx","cn","PopupWindow","layerClassName","style","state","stateSetter","initialAnimation","onExit","onOpen","ctx","useContext","animation","container","setContainer","isOpen","setIsOpen","zIndex","setZIndex","createPortal","PopupButton","as","onClick","disabled","popupId","isActive","setIsActive","Tag","toggle","target","refference","payload"],"mappings":";;;;iDAOC,UAAY,CAGZ,IAAIA,EAAS,CAAA,EAAG,eAEhB,SAASC,GAAc,CAGtB,QAFIC,EAAU,GAELC,EAAI,EAAGA,EAAI,UAAU,OAAQA,IAAK,CAC1C,IAAIC,EAAM,UAAUD,CAAC,EACjBC,IACHF,EAAUG,EAAYH,EAASI,EAAWF,CAAG,CAAC,EAElD,CAEE,OAAOF,CACT,CAEC,SAASI,EAAYF,EAAK,CACzB,GAAI,OAAOA,GAAQ,UAAY,OAAOA,GAAQ,SAC7C,OAAOA,EAGR,GAAI,OAAOA,GAAQ,SAClB,MAAO,GAGR,GAAI,MAAM,QAAQA,CAAG,EACpB,OAAOH,EAAW,MAAM,KAAMG,CAAG,EAGlC,GAAIA,EAAI,WAAa,OAAO,UAAU,UAAY,CAACA,EAAI,SAAS,SAAQ,EAAG,SAAS,eAAe,EAClG,OAAOA,EAAI,SAAU,EAGtB,IAAIF,EAAU,GAEd,QAASK,KAAOH,EACXJ,EAAO,KAAKI,EAAKG,CAAG,GAAKH,EAAIG,CAAG,IACnCL,EAAUG,EAAYH,EAASK,CAAG,GAIpC,OAAOL,CACT,CAEC,SAASG,EAAaG,EAAOC,EAAU,CACtC,OAAKA,EAIDD,EACIA,EAAQ,IAAMC,EAGfD,EAAQC,EAPPD,CAQV,CAEsCE,EAAO,SAC3CT,EAAW,QAAUA,EACrBS,UAAiBT,GAOjB,OAAO,WAAaA,CAEtB,2CClEMU,EAA6C,CACjD,cAAe,GACf,eAAgB,GAChB,aAAc,GACd,mBAAoB,EACtB,EAEMC,EAAeC,EAAkC,cAAA,EAAwB,EAOlEC,EAAmC,CAAC,CAAE,UAAAC,EAAW,SAAUC,EAAiB,SAAAC,EAAU,GAAGC,KAAY,CAC1G,KAAA,CAACC,C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AO/D,CAAG,EAGpB,OAAAiE,CACT","x_google_ignoreList":[0]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fullkekw/popup",
3
- "version": "2.0.10",
3
+ "version": "2.0.11",
4
4
  "description": "React Popup component written on Typescript. Compatible with NextJS & Vite!",
5
5
  "keywords": [
6
6
  "fkw",