neko-popup 3.0.2 → 3.0.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.
- package/dist/PopupButton.d.ts +1 -2
- package/dist/PopupLayer.d.ts +2 -3
- package/dist/PopupWindow.d.ts +3 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.es.js +37 -36
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/styles.css +1 -0
- package/package.json +1 -1
package/dist/PopupButton.d.ts
CHANGED
package/dist/PopupLayer.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FC, ReactNode } from 'react';
|
|
2
|
-
interface IPopupLayerProps {
|
|
2
|
+
export interface IPopupLayerProps {
|
|
3
3
|
children?: ReactNode | ReactNode[];
|
|
4
4
|
/** @default 10000 */
|
|
5
5
|
baseZIndex?: number;
|
|
@@ -10,5 +10,4 @@ interface IPopupLayerProps {
|
|
|
10
10
|
*/
|
|
11
11
|
disableBodyScrollOnActivePopup?: boolean;
|
|
12
12
|
}
|
|
13
|
-
declare const PopupLayer: FC<IPopupLayerProps>;
|
|
14
|
-
export default PopupLayer;
|
|
13
|
+
export declare const PopupLayer: FC<IPopupLayerProps>;
|
package/dist/PopupWindow.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { FC, ReactNode } from 'react';
|
|
2
2
|
import { PopupWindowDisabledType, StateSetter } from './Interfaces';
|
|
3
|
-
|
|
3
|
+
export type PopupWindowAnimationType = 'fade' | 'scale' | null;
|
|
4
|
+
export interface IPopupWindowProps {
|
|
4
5
|
id: string;
|
|
5
6
|
children: ReactNode | ReactNode[];
|
|
6
7
|
isOpen?: boolean;
|
|
@@ -41,5 +42,4 @@ interface IPopupWindowProps {
|
|
|
41
42
|
*/
|
|
42
43
|
onAfterExit?(): void;
|
|
43
44
|
}
|
|
44
|
-
declare const PopupWindow: FC<IPopupWindowProps>;
|
|
45
|
-
export default PopupWindow;
|
|
45
|
+
export declare const PopupWindow: FC<IPopupWindowProps>;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
1
|
+
export * from './PopupButton';
|
|
2
|
+
export * from './PopupLayer';
|
|
3
|
+
export * from './PopupWindow';
|
|
4
|
+
export type { IPopupContext, IPopupNode } from './Interfaces';
|
package/dist/index.es.js
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { createContext as A,
|
|
1
|
+
import { jsx as v, jsxs as N } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as A, useContext as I, useState as m, useEffect as u, useRef as P, useMemo as z, useLayoutEffect as O } from "react";
|
|
3
3
|
import { createPortal as w } from "react-dom";
|
|
4
|
-
class B extends Error {
|
|
5
|
-
constructor(n) {
|
|
6
|
-
super(n), this.name = "error at [neko-popup]";
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
4
|
function C(e) {
|
|
10
5
|
var n, s, o = "";
|
|
11
6
|
if (typeof e == "string" || typeof e == "number") o += e;
|
|
@@ -15,12 +10,40 @@ function C(e) {
|
|
|
15
10
|
} else for (s in e) e[s] && (o && (o += " "), o += s);
|
|
16
11
|
return o;
|
|
17
12
|
}
|
|
18
|
-
function
|
|
13
|
+
function B() {
|
|
19
14
|
for (var e, n, s = 0, o = "", a = arguments.length; s < a; s++) (e = arguments[s]) && (n = C(e)) && (o && (o += " "), o += n);
|
|
20
15
|
return o;
|
|
21
16
|
}
|
|
22
|
-
const E = A({}), g =
|
|
23
|
-
const
|
|
17
|
+
const E = A({}), g = B, R = (e) => {
|
|
18
|
+
const n = I(E), [s, o] = m(!1), a = e.as ?? "button";
|
|
19
|
+
u(() => {
|
|
20
|
+
const l = n.nodes.find((x) => x.id === e.popupId);
|
|
21
|
+
l && o(l.isOpen);
|
|
22
|
+
}, [n]);
|
|
23
|
+
function b(l) {
|
|
24
|
+
n.invokePopup(e.popupId), e.onClick && e.onClick(l);
|
|
25
|
+
}
|
|
26
|
+
return /* @__PURE__ */ v(
|
|
27
|
+
a,
|
|
28
|
+
{
|
|
29
|
+
tabIndex: 0,
|
|
30
|
+
disabled: e.disabled,
|
|
31
|
+
"aria-disabled": e.disabled,
|
|
32
|
+
"aria-haspopup": "dialog",
|
|
33
|
+
id: e.id,
|
|
34
|
+
className: g("neko-popup-button", s && "neko-popup-button--active", e.className),
|
|
35
|
+
onClick: b,
|
|
36
|
+
children: e.children
|
|
37
|
+
}
|
|
38
|
+
);
|
|
39
|
+
};
|
|
40
|
+
class L extends Error {
|
|
41
|
+
constructor(n) {
|
|
42
|
+
super(n), this.name = "error at [neko-popup]";
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
const T = (e) => {
|
|
46
|
+
const [n, s] = m([]), [o, a] = m(!1), b = P(null), l = e.baseZIndex ?? 1e4, x = e.disableBodyScrollOnActivePopup ?? !0;
|
|
24
47
|
u(() => {
|
|
25
48
|
const i = new AbortController();
|
|
26
49
|
if (window.addEventListener("keydown", (d) => {
|
|
@@ -41,7 +64,7 @@ const E = A({}), g = L, R = (e) => {
|
|
|
41
64
|
}, [o]);
|
|
42
65
|
function f(i, d) {
|
|
43
66
|
const t = typeof i == "string" ? n.find((r) => r.id === i) : i;
|
|
44
|
-
if (!t) throw new
|
|
67
|
+
if (!t) throw new L(typeof i == "string" ? `Cannot find popup node with id #${i}` : "Entity is not assigned to the node");
|
|
45
68
|
const c = d ?? !t.isOpen;
|
|
46
69
|
t.isOpen = c, t.zIndex = c ? Math.max(...n.map((r) => r.zIndex), 0) + 1 : -1, p(t);
|
|
47
70
|
}
|
|
@@ -63,28 +86,6 @@ const E = A({}), g = L, R = (e) => {
|
|
|
63
86
|
e.children,
|
|
64
87
|
/* @__PURE__ */ v("section", { style: { zIndex: l }, ref: b })
|
|
65
88
|
] });
|
|
66
|
-
}, T = (e) => {
|
|
67
|
-
const n = P(E), [s, o] = m(!1), a = e.as ?? "button";
|
|
68
|
-
u(() => {
|
|
69
|
-
const l = n.nodes.find((x) => x.id === e.popupId);
|
|
70
|
-
l && o(l.isOpen);
|
|
71
|
-
}, [n]);
|
|
72
|
-
function b(l) {
|
|
73
|
-
n.invokePopup(e.popupId), e.onClick && e.onClick(l);
|
|
74
|
-
}
|
|
75
|
-
return /* @__PURE__ */ v(
|
|
76
|
-
a,
|
|
77
|
-
{
|
|
78
|
-
tabIndex: 0,
|
|
79
|
-
disabled: e.disabled,
|
|
80
|
-
"aria-disabled": e.disabled,
|
|
81
|
-
"aria-haspopup": "dialog",
|
|
82
|
-
id: e.id,
|
|
83
|
-
className: g("neko-popup-button", s && "neko-popup-button--active", e.className),
|
|
84
|
-
onClick: b,
|
|
85
|
-
children: e.children
|
|
86
|
-
}
|
|
87
|
-
);
|
|
88
89
|
};
|
|
89
90
|
function D(e, n) {
|
|
90
91
|
const s = z(() => arguments.length === 2 && n !== void 0, []), [o, a] = m(e);
|
|
@@ -96,7 +97,7 @@ function D(e, n) {
|
|
|
96
97
|
] : [o, a];
|
|
97
98
|
}
|
|
98
99
|
const Z = (e) => {
|
|
99
|
-
const n =
|
|
100
|
+
const n = I(E), [s, o] = m(null), [a, b] = D(e.isOpen ?? !1, e.setIsOpen), [l, x] = m(-1), [f, h] = m([]), p = P(null), k = e.animation !== void 0 ? e.animation : "fade", i = e.animationDuraionMs ?? 200;
|
|
100
101
|
O(() => {
|
|
101
102
|
let t = [];
|
|
102
103
|
typeof e.disabled == "boolean" ? t = e.disabled ? ["onEscape", "onLayer"] : [] : t = e.disabled ?? [], n.updateNodeProperty(e.id, "disabled", t);
|
|
@@ -148,8 +149,8 @@ const Z = (e) => {
|
|
|
148
149
|
), s);
|
|
149
150
|
};
|
|
150
151
|
export {
|
|
151
|
-
|
|
152
|
-
|
|
152
|
+
R as PopupButton,
|
|
153
|
+
T as PopupLayer,
|
|
153
154
|
Z as PopupWindow
|
|
154
155
|
};
|
|
155
156
|
//# sourceMappingURL=index.es.js.map
|
package/dist/index.es.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.es.js","sources":["../src/_package/components/ErrorComponents.ts","../node_modules/clsx/dist/clsx.mjs","../src/_package/Interfaces.ts","../src/_package/PopupLayer.tsx","../src/_package/PopupButton.tsx","../src/_package/hooks/useMixedState.ts","../src/_package/PopupWindow.tsx"],"sourcesContent":["class EFKW extends Error {\n constructor(msg: string) {\n super(msg);\n\n this.name = 'error at [neko-popup]';\n }\n}\n\nexport default EFKW;","function r(e){var t,f,n=\"\";if(\"string\"==typeof e||\"number\"==typeof e)n+=e;else if(\"object\"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=\" \"),n+=f)}else for(f in e)e[f]&&(n&&(n+=\" \"),n+=f);return n}export function clsx(){for(var e,t,f=0,n=\"\",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r(e))&&(n&&(n+=\" \"),n+=t);return n}export default clsx;","import React, { createContext, RefObject } from 'react';\nimport clsx from 'clsx';\n\n\n\n\nexport type PopupWindowDisabledType = 'onEscape' | 'onLayer';\nexport type StateSetter<S = any> = React.Dispatch<React.SetStateAction<S>>\nexport type RegisterNodeArgs = Pick<IPopupNode, 'id' | 'isOpen' | 'disabled'>\n\n/** Get value type from nested object path */\nexport type ValueFromPath<T, P> =\n P extends `${infer K}.${infer R}`\n ? K extends keyof T\n ? R extends keyof T[K]\n ? T[K][R]\n : never\n : never\n : P extends keyof T\n ? T[P]\n : never;\n\n\n\nexport interface IPopupNode {\n id: string\n isOpen: boolean\n zIndex: number\n disabled: PopupWindowDisabledType[]\n}\n\nexport interface IPopupContext {\n nodes: IPopupNode[]\n containerRef: RefObject<HTMLDivElement | null>\n\n invokePopup(id: string, forceState?: boolean): void\n registerNode(args: RegisterNodeArgs): void\n updateNodeProperty<K extends keyof IPopupNode>(id: string, key: K, value: ValueFromPath<IPopupNode, K>): void\n}\n\n\n\nexport const PopupContext = createContext<IPopupContext>({} as IPopupContext);\nexport const cn = clsx;","'use client';\n\nimport { FC, ReactNode, useEffect, useRef, useState } from 'react';\n\nimport EFKW from './components/ErrorComponents';\nimport { IPopupNode, PopupContext, RegisterNodeArgs, ValueFromPath } from './Interfaces';\n\n\n\ninterface IPopupLayerProps {\n children?: ReactNode | ReactNode[]\n\n /** @default 10000 */\n baseZIndex?: number\n\n /**\n * Disable body scroll when there is at least one open popup\n * \n * @default true\n */\n disableBodyScrollOnActivePopup?: boolean\n}\n\n\n\nconst PopupLayer: FC<IPopupLayerProps> = (props) => {\n const [nodes, setNodes] = useState<IPopupNode[]>([]);\n const [isScrollDisabled, setIsScrollDisabled] = useState(false);\n\n const containerRef = useRef<HTMLDivElement>(null);\n\n const baseZIndex = props.baseZIndex ?? 10000;\n const disableBodyScrollOnActivePopup = props.disableBodyScrollOnActivePopup ?? true;\n\n\n\n // Handle close closest to user popup on escape & scroll\n useEffect(() => {\n // === Handle close closest popup on escape\n const controller = new AbortController();\n\n window.addEventListener('keydown', e => {\n const key = e.key;\n\n if (key === 'Escape') {\n const maxZIndex = Math.max(...nodes.filter(el => el.isOpen).map(el => el.zIndex));\n const node = nodes.find(el => el.zIndex === maxZIndex);\n if (!node || node.disabled.includes('onEscape')) return;\n\n // eslint-disable-next-line\n invokePopup(node.id, false);\n }\n }, { signal: controller.signal });\n\n\n\n // === Disable body scroll on active popup\n if (disableBodyScrollOnActivePopup) {\n let anyOpenNode = false;\n nodes.forEach(el => el.isOpen ? anyOpenNode = true : null);\n\n setIsScrollDisabled(anyOpenNode);\n }\n\n\n\n return () => {\n controller.abort();\n };\n }, [nodes]);\n\n // Handle body scroll\n useEffect(() => {\n if (isScrollDisabled) document.body.classList.add('neko-popup--noScroll');\n else document.body.classList.remove('neko-popup--noScroll');\n }, [isScrollDisabled]);\n\n\n\n /** Toggle popup state */\n function invokePopup(entityOrId: string | IPopupNode, forceState?: boolean) {\n const node = typeof entityOrId === 'string' ? nodes.find(el => el.id === entityOrId) : entityOrId;\n if (!node) throw new EFKW(typeof entityOrId === 'string' ? `Cannot find popup node with id #${entityOrId}` : `Entity is not assigned to the node`);\n\n const newState = forceState ?? !node.isOpen;\n\n // === Update node\n node.isOpen = newState;\n node.zIndex = newState ? Math.max(...nodes.map(el => el.zIndex), 0) + 1 : -1; // Make new popup invocation closer to user using larger z-index\n\n _updateNodeInNodes(node);\n }\n\n /** Update node property */\n function updateNodeProperty<K extends keyof IPopupNode>(id: string, key: K, value: ValueFromPath<IPopupNode, K>) {\n const node = nodes.find(el => el.id === id);\n if (!node) return;\n\n node[key] = value;\n\n _updateNodeInNodes(node);\n }\n\n /** Update node in nodes array */\n function _updateNodeInNodes(node: IPopupNode) {\n setNodes(prev => [...prev.filter(el => el.id !== node.id), node]);\n }\n\n /** Add new popup window to state */\n const registerNode = ({ id, isOpen, disabled }: RegisterNodeArgs) => invokePopup({ id, isOpen: false, disabled, zIndex: -1 }, isOpen);\n\n\n\n return <PopupContext.Provider value={{\n nodes,\n containerRef,\n invokePopup,\n registerNode,\n updateNodeProperty\n }}>\n {props.children}\n\n <section style={{ zIndex: baseZIndex }} ref={containerRef} />\n </PopupContext.Provider>;\n};\n\nexport default PopupLayer;","'use client';\n\nimport { FC, JSX, ReactNode, useContext, useEffect, useState } from 'react';\n\nimport { cn, PopupContext } from './Interfaces';\n\n\n\nexport interface IPopupButtonProps {\n popupId: string\n\n /** \n * Element tag\n * \n * @default \"button\"\n */\n as?: 'button' | 'div'\n\n disabled?: boolean\n children?: ReactNode | ReactNode[]\n className?: string\n id?: string\n\n onClick?(e: React.MouseEvent): void\n}\n\n\n\nconst PopupButton: FC<IPopupButtonProps> = (props) => {\n const ctx = useContext(PopupContext);\n\n const [isActive, setIsActive] = useState(false);\n\n const Tag: keyof JSX.IntrinsicElements = props.as ?? 'button';\n\n\n\n // Handle isActive on context change\n useEffect(() => {\n const node = ctx.nodes.find(el => el.id === props.popupId);\n if (!node) return;\n\n setIsActive(node.isOpen);\n }, [ctx]);\n\n\n\n function invokePopup(e: React.MouseEvent) {\n ctx.invokePopup(props.popupId);\n\n if (props.onClick) props.onClick(e);\n }\n\n\n\n return <Tag\n tabIndex={0}\n disabled={props.disabled}\n aria-disabled={props.disabled}\n aria-haspopup={'dialog'}\n id={props.id}\n className={cn(`neko-popup-button`, isActive && 'neko-popup-button--active', props.className)}\n onClick={invokePopup}\n >\n {props.children}\n </Tag>;\n};\n\nexport default PopupButton;","'use client';\n\nimport { useEffect, useMemo, useState } from 'react';\n\n\n\n\ntype StateSetter<S> = React.Dispatch<React.SetStateAction<S>>;\ntype InitialState<S> = S | (() => S);\n\nexport default function useMixedState<S = undefined>(): [S | undefined, StateSetter<S | undefined>];\nexport default function useMixedState<S>(initialState: InitialState<S>): [S, StateSetter<S>];\nexport default function useMixedState<S>(state: S, setter?: StateSetter<S>): [S, StateSetter<S>];\n\n\n\n/** \n * Use mixed state hook\n * \n * @param initialStateOrValue Initial state, can be undefined, value or function. If externalSetter not specified, will return default state\n * @param externalSetter External state setter. If specified will return external state\n */\nexport default function useMixedState<S>(initialStateOrValue?: InitialState<S>, externalSetter?: StateSetter<S>) {\n const isControlled = useMemo(() => arguments.length === 2 && externalSetter !== undefined, []);\n\n const [state, setter] = useState<S | undefined>(initialStateOrValue);\n\n\n\n // Propagate state update on external state update even if external setter is not provided\n useEffect(() => {\n if (!isControlled) {\n \n setter(initialStateOrValue);\n }\n }, [initialStateOrValue]);\n\n\n\n if (isControlled) {\n return [\n initialStateOrValue as S,\n externalSetter as StateSetter<S>\n ];\n }\n\n return [state, setter];\n}","'use client';\n\nimport { FC, ReactNode, useContext, useEffect, useLayoutEffect, useRef, useState } from 'react';\nimport { createPortal } from 'react-dom';\n\nimport useMixedState from './hooks/useMixedState';\nimport { cn, PopupContext, PopupWindowDisabledType, StateSetter } from './Interfaces';\n\n\n\ntype PopupWindowAnimationType = 'fade' | 'scale' | null\n\n\n\ninterface IPopupWindowProps {\n id: string\n children: ReactNode | ReactNode[]\n\n isOpen?: boolean\n setIsOpen?: StateSetter<boolean>\n\n className?: string\n layerClassName?: string\n disabled?: PopupWindowDisabledType[] | boolean\n\n /** \n * Popup dialog animation type\n * \n * @default \"fade\"\n */\n animation?: 'fade' | 'scale' | null\n\n /**\n * Popup animation duration in msec\n * \n * @default 200\n */\n animationDuraionMs?: number\n\n /** \n * Fire callback when popup invoked to open\n */\n onBeforeEnter?(): void\n\n /** \n * Fire callback when popup open animation fullfilled. \n * \n * @see animationDuration\n */\n onAfterEnter?(): void\n\n /** \n * Fire callback when popup invoked to close\n */\n onBeforeExit?(): void\n\n /** \n * Fire callback when popup close animation fullfilled. \n * \n * @see animationDuration\n */\n onAfterExit?(): void\n}\n\n\n\nconst PopupWindow: FC<IPopupWindowProps> = (props) => {\n const ctx = useContext(PopupContext);\n\n const [container, setContainer] = useState<HTMLDivElement | null>(null);\n const [isOpen, setIsOpen] = useMixedState(props.isOpen ?? false, props.setIsOpen);\n const [zIndex, setZIndex] = useState(-1);\n const [disabled, setDisabled] = useState<PopupWindowDisabledType[]>([]);\n\n const layerRef = useRef<HTMLDivElement>(null);\n\n const animation: PopupWindowAnimationType = props.animation !== undefined ? props.animation : 'fade';\n const animationDuration = props.animationDuraionMs ?? 200;\n\n\n\n // Handle disabled\n useLayoutEffect(() => {\n let disabled: PopupWindowDisabledType[] = [];\n\n if (typeof props.disabled === 'boolean') disabled = props.disabled ? ['onEscape', 'onLayer'] : [];\n else disabled = props.disabled ?? [];\n\n ctx.updateNodeProperty(props.id, 'disabled', disabled);\n }, [props.disabled]);\n\n\n\n // Mount & register node\n useEffect(() => {\n const container = ctx.containerRef.current;\n if (!container) return;\n\n setContainer(container);\n\n ctx.registerNode({\n id: props.id,\n isOpen: Boolean(props.isOpen),\n disabled\n });\n }, []);\n\n // Handle node sync with context\n useEffect(() => {\n const node = ctx.nodes.find(el => el.id === props.id);\n if (!node) return;\n\n setIsOpen(node.isOpen);\n setZIndex(node.zIndex);\n setDisabled(node.disabled);\n }, [ctx.nodes]);\n\n // Handle layer z-index change\n useEffect(() => {\n const layer = layerRef.current;\n if (!layer) return;\n\n if (isOpen) layer.style.zIndex = `${zIndex}`;\n else setTimeout(() => {\n layer.style.zIndex = `${-1}`;\n }, animationDuration);\n }, [isOpen]);\n\n // Handle events (onBeforeEnter, etc)\n useEffect(() => {\n if (isOpen) {\n if (props.onBeforeEnter) props.onBeforeEnter();\n\n setTimeout(() => {\n if (props.onAfterEnter) props.onAfterEnter();\n }, animationDuration);\n } else {\n if (props.onBeforeExit) props.onBeforeExit();\n\n setTimeout(() => {\n if (props.onAfterExit) props.onAfterExit();\n }, animationDuration);\n }\n }, [isOpen]);\n\n\n\n function layerOnClick() {\n if (disabled.includes('onLayer')) return;\n\n ctx.invokePopup(props.id, false);\n }\n\n\n\n return container && createPortal(<section\n className={cn(`neko-popup-backdrop`, isOpen && 'neko-popup-backdrop--active', props.layerClassName)}\n aria-hidden={!isOpen}\n style={{ transition: `${animationDuration}ms ease-in-out`, cursor: disabled.includes('onLayer') ? 'default' : 'pointer' }}\n onClick={layerOnClick}\n ref={layerRef}\n >\n <article\n id={props.id}\n className={cn(`neko-popup`, isOpen && 'neko-popup--active', animation && `neko-popup--animation_${animation}`, props.className)}\n role=\"dialog\"\n aria-modal\n onClick={e => e.stopPropagation()}\n >\n {props.children}\n </article>\n </section>, container);\n};\n\nexport default PopupWindow;"],"names":["EFKW","msg","r","t","f","n","o","clsx","PopupContext","createContext","cn","PopupLayer","props","nodes","setNodes","useState","isScrollDisabled","setIsScrollDisabled","containerRef","useRef","baseZIndex","disableBodyScrollOnActivePopup","useEffect","controller","e","maxZIndex","el","node","invokePopup","anyOpenNode","entityOrId","forceState","newState","_updateNodeInNodes","updateNodeProperty","id","key","value","prev","registerNode","isOpen","disabled","jsxs","jsx","PopupButton","ctx","useContext","isActive","setIsActive","Tag","useMixedState","initialStateOrValue","externalSetter","isControlled","useMemo","state","setter","PopupWindow","container","setContainer","setI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C;AAAA,IAAA;AAAA,MAChC,WAAWjC,EAAG,uBAAuB8B,KAAU,+BAA+B5B,EAAM,cAAc;AAAA,MAClG,eAAa,CAAC4B;AAAA,MACd,OAAO,EAAE,YAAY,GAAG0B,CAAiB,kBAAkB,QAAQzB,EAAS,SAAS,SAAS,IAAI,YAAY,UAAA;AAAA,MAC9G,SAAS4B;AAAA,MACT,KAAKL;AAAA,MAEL,UAAA,gBAAArB;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,IAAI/B,EAAM;AAAA,UACV,WAAWF,EAAG,cAAc8B,KAAU,sBAAsByB,KAAa,yBAAyBA,CAAS,IAAIrD,EAAM,SAAS;AAAA,UAC9H,MAAK;AAAA,UACL,cAAU;AAAA,UACV,SAAS,CAAAY,MAAKA,EAAE,gBAAA;AAAA,UAEf,UAAAZ,EAAM;AAAA,QAAA;AAAA,MAAA;AAAA,IACT;AAAA,EAAA,GACU8C,CAAS;AACvB;","x_google_ignoreList":[1]}
|
|
1
|
+
{"version":3,"file":"index.es.js","sources":["../node_modules/clsx/dist/clsx.mjs","../src/_package/Interfaces.ts","../src/_package/PopupButton.tsx","../src/_package/components/ErrorComponents.ts","../src/_package/PopupLayer.tsx","../src/_package/hooks/useMixedState.ts","../src/_package/PopupWindow.tsx"],"sourcesContent":["function r(e){var t,f,n=\"\";if(\"string\"==typeof e||\"number\"==typeof e)n+=e;else if(\"object\"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=\" \"),n+=f)}else for(f in e)e[f]&&(n&&(n+=\" \"),n+=f);return n}export function clsx(){for(var e,t,f=0,n=\"\",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r(e))&&(n&&(n+=\" \"),n+=t);return n}export default clsx;","import React, { createContext, RefObject } from 'react';\nimport clsx from 'clsx';\n\n\n\n\nexport type PopupWindowDisabledType = 'onEscape' | 'onLayer';\nexport type StateSetter<S = any> = React.Dispatch<React.SetStateAction<S>>\nexport type RegisterNodeArgs = Pick<IPopupNode, 'id' | 'isOpen' | 'disabled'>\n\n/** Get value type from nested object path */\nexport type ValueFromPath<T, P> =\n P extends `${infer K}.${infer R}`\n ? K extends keyof T\n ? R extends keyof T[K]\n ? T[K][R]\n : never\n : never\n : P extends keyof T\n ? T[P]\n : never;\n\n\n\nexport interface IPopupNode {\n id: string\n isOpen: boolean\n zIndex: number\n disabled: PopupWindowDisabledType[]\n}\n\nexport interface IPopupContext {\n nodes: IPopupNode[]\n containerRef: RefObject<HTMLDivElement | null>\n\n invokePopup(id: string, forceState?: boolean): void\n registerNode(args: RegisterNodeArgs): void\n updateNodeProperty<K extends keyof IPopupNode>(id: string, key: K, value: ValueFromPath<IPopupNode, K>): void\n}\n\n\n\nexport const PopupContext = createContext<IPopupContext>({} as IPopupContext);\nexport const cn = clsx;","'use client';\n\nimport { FC, JSX, ReactNode, useContext, useEffect, useState } from 'react';\n\nimport { cn, PopupContext } from './Interfaces';\n\n\n\nexport interface IPopupButtonProps {\n popupId: string\n\n /** \n * Element tag\n * \n * @default \"button\"\n */\n as?: 'button' | 'div'\n\n disabled?: boolean\n children?: ReactNode | ReactNode[]\n className?: string\n id?: string\n\n onClick?(e: React.MouseEvent): void\n}\n\n\n\nexport const PopupButton: FC<IPopupButtonProps> = (props) => {\n const ctx = useContext(PopupContext);\n\n const [isActive, setIsActive] = useState(false);\n\n const Tag: keyof JSX.IntrinsicElements = props.as ?? 'button';\n\n\n\n // Handle isActive on context change\n useEffect(() => {\n const node = ctx.nodes.find(el => el.id === props.popupId);\n if (!node) return;\n\n setIsActive(node.isOpen);\n }, [ctx]);\n\n\n\n function invokePopup(e: React.MouseEvent) {\n ctx.invokePopup(props.popupId);\n\n if (props.onClick) props.onClick(e);\n }\n\n\n\n return <Tag\n tabIndex={0}\n disabled={props.disabled}\n aria-disabled={props.disabled}\n aria-haspopup={'dialog'}\n id={props.id}\n className={cn(`neko-popup-button`, isActive && 'neko-popup-button--active', props.className)}\n onClick={invokePopup}\n >\n {props.children}\n </Tag>;\n};","class EFKW extends Error {\n constructor(msg: string) {\n super(msg);\n\n this.name = 'error at [neko-popup]';\n }\n}\n\nexport default EFKW;","'use client';\n\nimport { FC, ReactNode, useEffect, useRef, useState } from 'react';\n\nimport EFKW from './components/ErrorComponents';\nimport { IPopupNode, PopupContext, RegisterNodeArgs, ValueFromPath } from './Interfaces';\n\n\n\nexport interface IPopupLayerProps {\n children?: ReactNode | ReactNode[]\n\n /** @default 10000 */\n baseZIndex?: number\n\n /**\n * Disable body scroll when there is at least one open popup\n * \n * @default true\n */\n disableBodyScrollOnActivePopup?: boolean\n}\n\n\n\nexport const PopupLayer: FC<IPopupLayerProps> = (props) => {\n const [nodes, setNodes] = useState<IPopupNode[]>([]);\n const [isScrollDisabled, setIsScrollDisabled] = useState(false);\n\n const containerRef = useRef<HTMLDivElement>(null);\n\n const baseZIndex = props.baseZIndex ?? 10000;\n const disableBodyScrollOnActivePopup = props.disableBodyScrollOnActivePopup ?? true;\n\n\n\n // Handle close closest to user popup on escape & scroll\n useEffect(() => {\n // === Handle close closest popup on escape\n const controller = new AbortController();\n\n window.addEventListener('keydown', e => {\n const key = e.key;\n\n if (key === 'Escape') {\n const maxZIndex = Math.max(...nodes.filter(el => el.isOpen).map(el => el.zIndex));\n const node = nodes.find(el => el.zIndex === maxZIndex);\n if (!node || node.disabled.includes('onEscape')) return;\n\n // eslint-disable-next-line\n invokePopup(node.id, false);\n }\n }, { signal: controller.signal });\n\n\n\n // === Disable body scroll on active popup\n if (disableBodyScrollOnActivePopup) {\n let anyOpenNode = false;\n nodes.forEach(el => el.isOpen ? anyOpenNode = true : null);\n\n setIsScrollDisabled(anyOpenNode);\n }\n\n\n\n return () => {\n controller.abort();\n };\n }, [nodes]);\n\n // Handle body scroll\n useEffect(() => {\n if (isScrollDisabled) document.body.classList.add('neko-popup--noScroll');\n else document.body.classList.remove('neko-popup--noScroll');\n }, [isScrollDisabled]);\n\n\n\n /** Toggle popup state */\n function invokePopup(entityOrId: string | IPopupNode, forceState?: boolean) {\n const node = typeof entityOrId === 'string' ? nodes.find(el => el.id === entityOrId) : entityOrId;\n if (!node) throw new EFKW(typeof entityOrId === 'string' ? `Cannot find popup node with id #${entityOrId}` : `Entity is not assigned to the node`);\n\n const newState = forceState ?? !node.isOpen;\n\n // === Update node\n node.isOpen = newState;\n node.zIndex = newState ? Math.max(...nodes.map(el => el.zIndex), 0) + 1 : -1; // Make new popup invocation closer to user using larger z-index\n\n _updateNodeInNodes(node);\n }\n\n /** Update node property */\n function updateNodeProperty<K extends keyof IPopupNode>(id: string, key: K, value: ValueFromPath<IPopupNode, K>) {\n const node = nodes.find(el => el.id === id);\n if (!node) return;\n\n node[key] = value;\n\n _updateNodeInNodes(node);\n }\n\n /** Update node in nodes array */\n function _updateNodeInNodes(node: IPopupNode) {\n setNodes(prev => [...prev.filter(el => el.id !== node.id), node]);\n }\n\n /** Add new popup window to state */\n const registerNode = ({ id, isOpen, disabled }: RegisterNodeArgs) => invokePopup({ id, isOpen: false, disabled, zIndex: -1 }, isOpen);\n\n\n\n return <PopupContext.Provider value={{\n nodes,\n containerRef,\n invokePopup,\n registerNode,\n updateNodeProperty\n }}>\n {props.children}\n\n <section style={{ zIndex: baseZIndex }} ref={containerRef} />\n </PopupContext.Provider>;\n};","'use client';\n\nimport { useEffect, useMemo, useState } from 'react';\n\n\n\n\ntype StateSetter<S> = React.Dispatch<React.SetStateAction<S>>;\ntype InitialState<S> = S | (() => S);\n\nexport default function useMixedState<S = undefined>(): [S | undefined, StateSetter<S | undefined>];\nexport default function useMixedState<S>(initialState: InitialState<S>): [S, StateSetter<S>];\nexport default function useMixedState<S>(state: S, setter?: StateSetter<S>): [S, StateSetter<S>];\n\n\n\n/** \n * Use mixed state hook\n * \n * @param initialStateOrValue Initial state, can be undefined, value or function. If externalSetter not specified, will return default state\n * @param externalSetter External state setter. If specified will return external state\n */\nexport default function useMixedState<S>(initialStateOrValue?: InitialState<S>, externalSetter?: StateSetter<S>) {\n const isControlled = useMemo(() => arguments.length === 2 && externalSetter !== undefined, []);\n\n const [state, setter] = useState<S | undefined>(initialStateOrValue);\n\n\n\n // Propagate state update on external state update even if external setter is not provided\n useEffect(() => {\n if (!isControlled) {\n \n setter(initialStateOrValue);\n }\n }, [initialStateOrValue]);\n\n\n\n if (isControlled) {\n return [\n initialStateOrValue as S,\n externalSetter as StateSetter<S>\n ];\n }\n\n return [state, setter];\n}","'use client';\n\nimport { FC, ReactNode, useContext, useEffect, useLayoutEffect, useRef, useState } from 'react';\nimport { createPortal } from 'react-dom';\n\nimport useMixedState from './hooks/useMixedState';\nimport { cn, PopupContext, PopupWindowDisabledType, StateSetter } from './Interfaces';\n\n\n\nexport type PopupWindowAnimationType = 'fade' | 'scale' | null\n\n\n\nexport interface IPopupWindowProps {\n id: string\n children: ReactNode | ReactNode[]\n\n isOpen?: boolean\n setIsOpen?: StateSetter<boolean>\n\n className?: string\n layerClassName?: string\n disabled?: PopupWindowDisabledType[] | boolean\n\n /** \n * Popup dialog animation type\n * \n * @default \"fade\"\n */\n animation?: 'fade' | 'scale' | null\n\n /**\n * Popup animation duration in msec\n * \n * @default 200\n */\n animationDuraionMs?: number\n\n /** \n * Fire callback when popup invoked to open\n */\n onBeforeEnter?(): void\n\n /** \n * Fire callback when popup open animation fullfilled. \n * \n * @see animationDuration\n */\n onAfterEnter?(): void\n\n /** \n * Fire callback when popup invoked to close\n */\n onBeforeExit?(): void\n\n /** \n * Fire callback when popup close animation fullfilled. \n * \n * @see animationDuration\n */\n onAfterExit?(): void\n}\n\n\n\nexport const PopupWindow: FC<IPopupWindowProps> = (props) => {\n const ctx = useContext(PopupContext);\n\n const [container, setContainer] = useState<HTMLDivElement | null>(null);\n const [isOpen, setIsOpen] = useMixedState(props.isOpen ?? false, props.setIsOpen);\n const [zIndex, setZIndex] = useState(-1);\n const [disabled, setDisabled] = useState<PopupWindowDisabledType[]>([]);\n\n const layerRef = useRef<HTMLDivElement>(null);\n\n const animation: PopupWindowAnimationType = props.animation !== undefined ? props.animation : 'fade';\n const animationDuration = props.animationDuraionMs ?? 200;\n\n\n\n // Handle disabled\n useLayoutEffect(() => {\n let disabled: PopupWindowDisabledType[] = [];\n\n if (typeof props.disabled === 'boolean') disabled = props.disabled ? ['onEscape', 'onLayer'] : [];\n else disabled = props.disabled ?? [];\n\n ctx.updateNodeProperty(props.id, 'disabled', disabled);\n }, [props.disabled]);\n\n\n\n // Mount & register node\n useEffect(() => {\n const container = ctx.containerRef.current;\n if (!container) return;\n\n setContainer(container);\n\n ctx.registerNode({\n id: props.id,\n isOpen: Boolean(props.isOpen),\n disabled\n });\n }, []);\n\n // Handle node sync with context\n useEffect(() => {\n const node = ctx.nodes.find(el => el.id === props.id);\n if (!node) return;\n\n setIsOpen(node.isOpen);\n setZIndex(node.zIndex);\n setDisabled(node.disabled);\n }, [ctx.nodes]);\n\n // Handle layer z-index change\n useEffect(() => {\n const layer = layerRef.current;\n if (!layer) return;\n\n if (isOpen) layer.style.zIndex = `${zIndex}`;\n else setTimeout(() => {\n layer.style.zIndex = `${-1}`;\n }, animationDuration);\n }, [isOpen]);\n\n // Handle events (onBeforeEnter, etc)\n useEffect(() => {\n if (isOpen) {\n if (props.onBeforeEnter) props.onBeforeEnter();\n\n setTimeout(() => {\n if (props.onAfterEnter) props.onAfterEnter();\n }, animationDuration);\n } else {\n if (props.onBeforeExit) props.onBeforeExit();\n\n setTimeout(() => {\n if (props.onAfterExit) props.onAfterExit();\n }, animationDuration);\n }\n }, [isOpen]);\n\n\n\n function layerOnClick() {\n if (disabled.includes('onLayer')) return;\n\n ctx.invokePopup(props.id, false);\n }\n\n\n\n return container && createPortal(<section\n className={cn(`neko-popup-backdrop`, isOpen && 'neko-popup-backdrop--active', props.layerClassName)}\n aria-hidden={!isOpen}\n style={{ transition: `${animationDuration}ms ease-in-out`, cursor: disabled.includes('onLayer') ? 'default' : 'pointer' }}\n onClick={layerOnClick}\n ref={layerRef}\n >\n <article\n id={props.id}\n className={cn(`neko-popup`, isOpen && 'neko-popup--active', animation && `neko-popup--animation_${animation}`, props.className)}\n role=\"dialog\"\n aria-modal\n onClick={e => e.stopPropagation()}\n >\n {props.children}\n </article>\n </section>, container);\n};"],"names":["r","t","f","n","o","clsx","PopupContext","createContext","cn","PopupButton","props","ctx","useContext","isActive","setIsActive","useState","Tag","useEffect","node","el","invokePopup","e","jsx","EFKW","msg","PopupLayer","nodes","setNodes","isScrollDisabled","setIsScrollDisabled","containerRef","useRef","baseZIndex","disableBodyScrollOnActivePopup","controller","maxZIndex","anyOpenNode","entityOrId","forceState","newState","_updateNodeInNodes","updateNodeProperty","id","key","value","prev","registerNode","isOpen","disabled","jsxs","useMixedState","initialStateOrValue","externalSetter","isControlled","useMemo","state","setter","PopupWindow","container","setContainer","setIsOpen","zIndex","setZIndex","setDisabled","layerRef","animation","animationDuration","useLayoutEffect","layer","layerOnClick","createPortal"],"mappings":";;;AAAA,SAASA,EAAE,GAAE;AAAC,MAAIC,GAAEC,GAAEC,IAAE;AAAG,MAAa,OAAO,KAAjB,YAA8B,OAAO,KAAjB,SAAmB,CAAAA,KAAG;AAAA,WAAoB,OAAO,KAAjB,SAAmB,KAAG,MAAM,QAAQ,CAAC,GAAE;AAAC,QAAIC,IAAE,EAAE;AAAO,SAAIH,IAAE,GAAEA,IAAEG,GAAEH,IAAI,GAAEA,CAAC,MAAIC,IAAEF,EAAE,EAAEC,CAAC,CAAC,OAAKE,MAAIA,KAAG,MAAKA,KAAGD;AAAA,EAAE,MAAM,MAAIA,KAAK,EAAE,GAAEA,CAAC,MAAIC,MAAIA,KAAG,MAAKA,KAAGD;AAAG,SAAOC;AAAC;AAAQ,SAASE,IAAM;AAAC,WAAQ,GAAEJ,GAAEC,IAAE,GAAEC,IAAE,IAAGC,IAAE,UAAU,QAAOF,IAAEE,GAAEF,IAAI,EAAC,IAAE,UAAUA,CAAC,OAAKD,IAAED,EAAE,CAAC,OAAKG,MAAIA,KAAG,MAAKA,KAAGF;AAAG,SAAO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G,CAACnB,CAAM,CAAC,GAGX9B,EAAU,MAAM;AACd,IAAI8B,KACErC,EAAM,iBAAeA,EAAM,cAAA,GAE/B,WAAW,MAAM;AACf,MAAIA,EAAM,gBAAcA,EAAM,aAAA;AAAA,IAChC,GAAGwD,CAAiB,MAEhBxD,EAAM,gBAAcA,EAAM,aAAA,GAE9B,WAAW,MAAM;AACf,MAAIA,EAAM,eAAaA,EAAM,YAAA;AAAA,IAC/B,GAAGwD,CAAiB;AAAA,EAExB,GAAG,CAACnB,CAAM,CAAC;AAIX,WAASsB,IAAe;AACtB,IAAIrB,EAAS,SAAS,SAAS,KAE/BrC,EAAI,YAAYD,EAAM,IAAI,EAAK;AAAA,EACjC;AAIA,SAAOgD,KAAaY,EAAa,gBAAAhD;AAAA,IAAC;AAAA,IAAA;AAAA,MAChC,WAAWd,EAAG,uBAAuBuC,KAAU,+BAA+BrC,EAAM,cAAc;AAAA,MAClG,eAAa,CAACqC;AAAA,MACd,OAAO,EAAE,YAAY,GAAGmB,CAAiB,kBAAkB,QAAQlB,EAAS,SAAS,SAAS,IAAI,YAAY,UAAA;AAAA,MAC9G,SAASqB;AAAA,MACT,KAAKL;AAAA,MAEL,UAAA,gBAAA1C;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,IAAIZ,EAAM;AAAA,UACV,WAAWF,EAAG,cAAcuC,KAAU,sBAAsBkB,KAAa,yBAAyBA,CAAS,IAAIvD,EAAM,SAAS;AAAA,UAC9H,MAAK;AAAA,UACL,cAAU;AAAA,UACV,SAAS,CAAAW,MAAKA,EAAE,gBAAA;AAAA,UAEf,UAAAX,EAAM;AAAA,QAAA;AAAA,MAAA;AAAA,IACT;AAAA,EAAA,GACUgD,CAAS;AACvB;","x_google_ignoreList":[0]}
|
package/dist/index.umd.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(c,l){typeof exports=="object"&&typeof module<"u"?l(exports,require("react/jsx-runtime"),require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","react-dom"],l):(c=typeof globalThis<"u"?globalThis:c||self,l(c["neko-popup"]={},c.jsxRuntime,c.React,c.ReactDOM))})(this,(function(c,l,o,g){"use strict";
|
|
1
|
+
(function(c,l){typeof exports=="object"&&typeof module<"u"?l(exports,require("react/jsx-runtime"),require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","react-dom"],l):(c=typeof globalThis<"u"?globalThis:c||self,l(c["neko-popup"]={},c.jsxRuntime,c.React,c.ReactDOM))})(this,(function(c,l,o,g){"use strict";function I(e){var n,d,i="";if(typeof e=="string"||typeof e=="number")i+=e;else if(typeof e=="object")if(Array.isArray(e)){var a=e.length;for(n=0;n<a;n++)e[n]&&(d=I(e[n]))&&(i&&(i+=" "),i+=d)}else for(d in e)e[d]&&(i&&(i+=" "),i+=d);return i}function C(){for(var e,n,d=0,i="",a=arguments.length;d<a;d++)(e=arguments[d])&&(n=I(e))&&(i&&(i+=" "),i+=n);return i}const h=o.createContext({}),v=C,N=e=>{const n=o.useContext(h),[d,i]=o.useState(!1),a=e.as??"button";o.useEffect(()=>{const p=n.nodes.find(y=>y.id===e.popupId);p&&i(p.isOpen)},[n]);function x(p){n.invokePopup(e.popupId),e.onClick&&e.onClick(p)}return l.jsx(a,{tabIndex:0,disabled:e.disabled,"aria-disabled":e.disabled,"aria-haspopup":"dialog",id:e.id,className:v("neko-popup-button",d&&"neko-popup-button--active",e.className),onClick:x,children:e.children})};class S extends Error{constructor(n){super(n),this.name="error at [neko-popup]"}}const O=e=>{const[n,d]=o.useState([]),[i,a]=o.useState(!1),x=o.useRef(null),p=e.baseZIndex??1e4,y=e.disableBodyScrollOnActivePopup??!0;o.useEffect(()=>{const s=new AbortController;if(window.addEventListener("keydown",u=>{if(u.key==="Escape"){const f=Math.max(...n.filter(k=>k.isOpen).map(k=>k.zIndex)),r=n.find(k=>k.zIndex===f);if(!r||r.disabled.includes("onEscape"))return;m(r.id,!1)}},{signal:s.signal}),y){let u=!1;n.forEach(t=>t.isOpen?u=!0:null),a(u)}return()=>{s.abort()}},[n]),o.useEffect(()=>{i?document.body.classList.add("neko-popup--noScroll"):document.body.classList.remove("neko-popup--noScroll")},[i]);function m(s,u){const t=typeof s=="string"?n.find(r=>r.id===s):s;if(!t)throw new S(typeof s=="string"?`Cannot find popup node with id #${s}`:"Entity is not assigned to the node");const f=u??!t.isOpen;t.isOpen=f,t.zIndex=f?Math.max(...n.map(r=>r.zIndex),0)+1:-1,b(t)}function P(s,u,t){const f=n.find(r=>r.id===s);f&&(f[u]=t,b(f))}function b(s){d(u=>[...u.filter(t=>t.id!==s.id),s])}const E=({id:s,isOpen:u,disabled:t})=>m({id:s,isOpen:!1,disabled:t,zIndex:-1},u);return l.jsxs(h.Provider,{value:{nodes:n,containerRef:x,invokePopup:m,registerNode:E,updateNodeProperty:P},children:[e.children,l.jsx("section",{style:{zIndex:p},ref:x})]})};function A(e,n){const d=o.useMemo(()=>arguments.length===2&&n!==void 0,[]),[i,a]=o.useState(e);return o.useEffect(()=>{d||a(e)},[e]),d?[e,n]:[i,a]}const w=e=>{const n=o.useContext(h),[d,i]=o.useState(null),[a,x]=A(e.isOpen??!1,e.setIsOpen),[p,y]=o.useState(-1),[m,P]=o.useState([]),b=o.useRef(null),E=e.animation!==void 0?e.animation:"fade",s=e.animationDuraionMs??200;o.useLayoutEffect(()=>{let t=[];typeof e.disabled=="boolean"?t=e.disabled?["onEscape","onLayer"]:[]:t=e.disabled??[],n.updateNodeProperty(e.id,"disabled",t)},[e.disabled]),o.useEffect(()=>{const t=n.containerRef.current;t&&(i(t),n.registerNode({id:e.id,isOpen:!!e.isOpen,disabled:m}))},[]),o.useEffect(()=>{const t=n.nodes.find(f=>f.id===e.id);t&&(x(t.isOpen),y(t.zIndex),P(t.disabled))},[n.nodes]),o.useEffect(()=>{const t=b.current;t&&(a?t.style.zIndex=`${p}`:setTimeout(()=>{t.style.zIndex="-1"},s))},[a]),o.useEffect(()=>{a?(e.onBeforeEnter&&e.onBeforeEnter(),setTimeout(()=>{e.onAfterEnter&&e.onAfterEnter()},s)):(e.onBeforeExit&&e.onBeforeExit(),setTimeout(()=>{e.onAfterExit&&e.onAfterExit()},s))},[a]);function u(){m.includes("onLayer")||n.invokePopup(e.id,!1)}return d&&g.createPortal(l.jsx("section",{className:v("neko-popup-backdrop",a&&"neko-popup-backdrop--active",e.layerClassName),"aria-hidden":!a,style:{transition:`${s}ms ease-in-out`,cursor:m.includes("onLayer")?"default":"pointer"},onClick:u,ref:b,children:l.jsx("article",{id:e.id,className:v("neko-popup",a&&"neko-popup--active",E&&`neko-popup--animation_${E}`,e.className),role:"dialog","aria-modal":!0,onClick:t=>t.stopPropagation(),children:e.children})}),d)};c.PopupButton=N,c.PopupLayer=O,c.PopupWindow=w,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})}));
|
|
2
2
|
//# sourceMappingURL=index.umd.js.map
|
package/dist/index.umd.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.umd.js","sources":["../src/_package/components/ErrorComponents.ts","../node_modules/clsx/dist/clsx.mjs","../src/_package/Interfaces.ts","../src/_package/PopupLayer.tsx","../src/_package/PopupButton.tsx","../src/_package/hooks/useMixedState.ts","../src/_package/PopupWindow.tsx"],"sourcesContent":["class EFKW extends Error {\n constructor(msg: string) {\n super(msg);\n\n this.name = 'error at [neko-popup]';\n }\n}\n\nexport default EFKW;","function r(e){var t,f,n=\"\";if(\"string\"==typeof e||\"number\"==typeof e)n+=e;else if(\"object\"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=\" \"),n+=f)}else for(f in e)e[f]&&(n&&(n+=\" \"),n+=f);return n}export function clsx(){for(var e,t,f=0,n=\"\",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r(e))&&(n&&(n+=\" \"),n+=t);return n}export default clsx;","import React, { createContext, RefObject } from 'react';\nimport clsx from 'clsx';\n\n\n\n\nexport type PopupWindowDisabledType = 'onEscape' | 'onLayer';\nexport type StateSetter<S = any> = React.Dispatch<React.SetStateAction<S>>\nexport type RegisterNodeArgs = Pick<IPopupNode, 'id' | 'isOpen' | 'disabled'>\n\n/** Get value type from nested object path */\nexport type ValueFromPath<T, P> =\n P extends `${infer K}.${infer R}`\n ? K extends keyof T\n ? R extends keyof T[K]\n ? T[K][R]\n : never\n : never\n : P extends keyof T\n ? T[P]\n : never;\n\n\n\nexport interface IPopupNode {\n id: string\n isOpen: boolean\n zIndex: number\n disabled: PopupWindowDisabledType[]\n}\n\nexport interface IPopupContext {\n nodes: IPopupNode[]\n containerRef: RefObject<HTMLDivElement | null>\n\n invokePopup(id: string, forceState?: boolean): void\n registerNode(args: RegisterNodeArgs): void\n updateNodeProperty<K extends keyof IPopupNode>(id: string, key: K, value: ValueFromPath<IPopupNode, K>): void\n}\n\n\n\nexport const PopupContext = createContext<IPopupContext>({} as IPopupContext);\nexport const cn = clsx;","'use client';\n\nimport { FC, ReactNode, useEffect, useRef, useState } from 'react';\n\nimport EFKW from './components/ErrorComponents';\nimport { IPopupNode, PopupContext, RegisterNodeArgs, ValueFromPath } from './Interfaces';\n\n\n\ninterface IPopupLayerProps {\n children?: ReactNode | ReactNode[]\n\n /** @default 10000 */\n baseZIndex?: number\n\n /**\n * Disable body scroll when there is at least one open popup\n * \n * @default true\n */\n disableBodyScrollOnActivePopup?: boolean\n}\n\n\n\nconst PopupLayer: FC<IPopupLayerProps> = (props) => {\n const [nodes, setNodes] = useState<IPopupNode[]>([]);\n const [isScrollDisabled, setIsScrollDisabled] = useState(false);\n\n const containerRef = useRef<HTMLDivElement>(null);\n\n const baseZIndex = props.baseZIndex ?? 10000;\n const disableBodyScrollOnActivePopup = props.disableBodyScrollOnActivePopup ?? true;\n\n\n\n // Handle close closest to user popup on escape & scroll\n useEffect(() => {\n // === Handle close closest popup on escape\n const controller = new AbortController();\n\n window.addEventListener('keydown', e => {\n const key = e.key;\n\n if (key === 'Escape') {\n const maxZIndex = Math.max(...nodes.filter(el => el.isOpen).map(el => el.zIndex));\n const node = nodes.find(el => el.zIndex === maxZIndex);\n if (!node || node.disabled.includes('onEscape')) return;\n\n // eslint-disable-next-line\n invokePopup(node.id, false);\n }\n }, { signal: controller.signal });\n\n\n\n // === Disable body scroll on active popup\n if (disableBodyScrollOnActivePopup) {\n let anyOpenNode = false;\n nodes.forEach(el => el.isOpen ? anyOpenNode = true : null);\n\n setIsScrollDisabled(anyOpenNode);\n }\n\n\n\n return () => {\n controller.abort();\n };\n }, [nodes]);\n\n // Handle body scroll\n useEffect(() => {\n if (isScrollDisabled) document.body.classList.add('neko-popup--noScroll');\n else document.body.classList.remove('neko-popup--noScroll');\n }, [isScrollDisabled]);\n\n\n\n /** Toggle popup state */\n function invokePopup(entityOrId: string | IPopupNode, forceState?: boolean) {\n const node = typeof entityOrId === 'string' ? nodes.find(el => el.id === entityOrId) : entityOrId;\n if (!node) throw new EFKW(typeof entityOrId === 'string' ? `Cannot find popup node with id #${entityOrId}` : `Entity is not assigned to the node`);\n\n const newState = forceState ?? !node.isOpen;\n\n // === Update node\n node.isOpen = newState;\n node.zIndex = newState ? Math.max(...nodes.map(el => el.zIndex), 0) + 1 : -1; // Make new popup invocation closer to user using larger z-index\n\n _updateNodeInNodes(node);\n }\n\n /** Update node property */\n function updateNodeProperty<K extends keyof IPopupNode>(id: string, key: K, value: ValueFromPath<IPopupNode, K>) {\n const node = nodes.find(el => el.id === id);\n if (!node) return;\n\n node[key] = value;\n\n _updateNodeInNodes(node);\n }\n\n /** Update node in nodes array */\n function _updateNodeInNodes(node: IPopupNode) {\n setNodes(prev => [...prev.filter(el => el.id !== node.id), node]);\n }\n\n /** Add new popup window to state */\n const registerNode = ({ id, isOpen, disabled }: RegisterNodeArgs) => invokePopup({ id, isOpen: false, disabled, zIndex: -1 }, isOpen);\n\n\n\n return <PopupContext.Provider value={{\n nodes,\n containerRef,\n invokePopup,\n registerNode,\n updateNodeProperty\n }}>\n {props.children}\n\n <section style={{ zIndex: baseZIndex }} ref={containerRef} />\n </PopupContext.Provider>;\n};\n\nexport default PopupLayer;","'use client';\n\nimport { FC, JSX, ReactNode, useContext, useEffect, useState } from 'react';\n\nimport { cn, PopupContext } from './Interfaces';\n\n\n\nexport interface IPopupButtonProps {\n popupId: string\n\n /** \n * Element tag\n * \n * @default \"button\"\n */\n as?: 'button' | 'div'\n\n disabled?: boolean\n children?: ReactNode | ReactNode[]\n className?: string\n id?: string\n\n onClick?(e: React.MouseEvent): void\n}\n\n\n\nconst PopupButton: FC<IPopupButtonProps> = (props) => {\n const ctx = useContext(PopupContext);\n\n const [isActive, setIsActive] = useState(false);\n\n const Tag: keyof JSX.IntrinsicElements = props.as ?? 'button';\n\n\n\n // Handle isActive on context change\n useEffect(() => {\n const node = ctx.nodes.find(el => el.id === props.popupId);\n if (!node) return;\n\n setIsActive(node.isOpen);\n }, [ctx]);\n\n\n\n function invokePopup(e: React.MouseEvent) {\n ctx.invokePopup(props.popupId);\n\n if (props.onClick) props.onClick(e);\n }\n\n\n\n return <Tag\n tabIndex={0}\n disabled={props.disabled}\n aria-disabled={props.disabled}\n aria-haspopup={'dialog'}\n id={props.id}\n className={cn(`neko-popup-button`, isActive && 'neko-popup-button--active', props.className)}\n onClick={invokePopup}\n >\n {props.children}\n </Tag>;\n};\n\nexport default PopupButton;","'use client';\n\nimport { useEffect, useMemo, useState } from 'react';\n\n\n\n\ntype StateSetter<S> = React.Dispatch<React.SetStateAction<S>>;\ntype InitialState<S> = S | (() => S);\n\nexport default function useMixedState<S = undefined>(): [S | undefined, StateSetter<S | undefined>];\nexport default function useMixedState<S>(initialState: InitialState<S>): [S, StateSetter<S>];\nexport default function useMixedState<S>(state: S, setter?: StateSetter<S>): [S, StateSetter<S>];\n\n\n\n/** \n * Use mixed state hook\n * \n * @param initialStateOrValue Initial state, can be undefined, value or function. If externalSetter not specified, will return default state\n * @param externalSetter External state setter. If specified will return external state\n */\nexport default function useMixedState<S>(initialStateOrValue?: InitialState<S>, externalSetter?: StateSetter<S>) {\n const isControlled = useMemo(() => arguments.length === 2 && externalSetter !== undefined, []);\n\n const [state, setter] = useState<S | undefined>(initialStateOrValue);\n\n\n\n // Propagate state update on external state update even if external setter is not provided\n useEffect(() => {\n if (!isControlled) {\n \n setter(initialStateOrValue);\n }\n }, [initialStateOrValue]);\n\n\n\n if (isControlled) {\n return [\n initialStateOrValue as S,\n externalSetter as StateSetter<S>\n ];\n }\n\n return [state, setter];\n}","'use client';\n\nimport { FC, ReactNode, useContext, useEffect, useLayoutEffect, useRef, useState } from 'react';\nimport { createPortal } from 'react-dom';\n\nimport useMixedState from './hooks/useMixedState';\nimport { cn, PopupContext, PopupWindowDisabledType, StateSetter } from './Interfaces';\n\n\n\ntype PopupWindowAnimationType = 'fade' | 'scale' | null\n\n\n\ninterface IPopupWindowProps {\n id: string\n children: ReactNode | ReactNode[]\n\n isOpen?: boolean\n setIsOpen?: StateSetter<boolean>\n\n className?: string\n layerClassName?: string\n disabled?: PopupWindowDisabledType[] | boolean\n\n /** \n * Popup dialog animation type\n * \n * @default \"fade\"\n */\n animation?: 'fade' | 'scale' | null\n\n /**\n * Popup animation duration in msec\n * \n * @default 200\n */\n animationDuraionMs?: number\n\n /** \n * Fire callback when popup invoked to open\n */\n onBeforeEnter?(): void\n\n /** \n * Fire callback when popup open animation fullfilled. \n * \n * @see animationDuration\n */\n onAfterEnter?(): void\n\n /** \n * Fire callback when popup invoked to close\n */\n onBeforeExit?(): void\n\n /** \n * Fire callback when popup close animation fullfilled. \n * \n * @see animationDuration\n */\n onAfterExit?(): void\n}\n\n\n\nconst PopupWindow: FC<IPopupWindowProps> = (props) => {\n const ctx = useContext(PopupContext);\n\n const [container, setContainer] = useState<HTMLDivElement | null>(null);\n const [isOpen, setIsOpen] = useMixedState(props.isOpen ?? false, props.setIsOpen);\n const [zIndex, setZIndex] = useState(-1);\n const [disabled, setDisabled] = useState<PopupWindowDisabledType[]>([]);\n\n const layerRef = useRef<HTMLDivElement>(null);\n\n const animation: PopupWindowAnimationType = props.animation !== undefined ? props.animation : 'fade';\n const animationDuration = props.animationDuraionMs ?? 200;\n\n\n\n // Handle disabled\n useLayoutEffect(() => {\n let disabled: PopupWindowDisabledType[] = [];\n\n if (typeof props.disabled === 'boolean') disabled = props.disabled ? ['onEscape', 'onLayer'] : [];\n else disabled = props.disabled ?? [];\n\n ctx.updateNodeProperty(props.id, 'disabled', disabled);\n }, [props.disabled]);\n\n\n\n // Mount & register node\n useEffect(() => {\n const container = ctx.containerRef.current;\n if (!container) return;\n\n setContainer(container);\n\n ctx.registerNode({\n id: props.id,\n isOpen: Boolean(props.isOpen),\n disabled\n });\n }, []);\n\n // Handle node sync with context\n useEffect(() => {\n const node = ctx.nodes.find(el => el.id === props.id);\n if (!node) return;\n\n setIsOpen(node.isOpen);\n setZIndex(node.zIndex);\n setDisabled(node.disabled);\n }, [ctx.nodes]);\n\n // Handle layer z-index change\n useEffect(() => {\n const layer = layerRef.current;\n if (!layer) return;\n\n if (isOpen) layer.style.zIndex = `${zIndex}`;\n else setTimeout(() => {\n layer.style.zIndex = `${-1}`;\n }, animationDuration);\n }, [isOpen]);\n\n // Handle events (onBeforeEnter, etc)\n useEffect(() => {\n if (isOpen) {\n if (props.onBeforeEnter) props.onBeforeEnter();\n\n setTimeout(() => {\n if (props.onAfterEnter) props.onAfterEnter();\n }, animationDuration);\n } else {\n if (props.onBeforeExit) props.onBeforeExit();\n\n setTimeout(() => {\n if (props.onAfterExit) props.onAfterExit();\n }, animationDuration);\n }\n }, [isOpen]);\n\n\n\n function layerOnClick() {\n if (disabled.includes('onLayer')) return;\n\n ctx.invokePopup(props.id, false);\n }\n\n\n\n return container && createPortal(<section\n className={cn(`neko-popup-backdrop`, isOpen && 'neko-popup-backdrop--active', props.layerClassName)}\n aria-hidden={!isOpen}\n style={{ transition: `${animationDuration}ms ease-in-out`, cursor: disabled.includes('onLayer') ? 'default' : 'pointer' }}\n onClick={layerOnClick}\n ref={layerRef}\n >\n <article\n id={props.id}\n className={cn(`neko-popup`, isOpen && 'neko-popup--active', animation && `neko-popup--animation_${animation}`, props.className)}\n role=\"dialog\"\n aria-modal\n onClick={e => e.stopPropagation()}\n >\n {props.children}\n </article>\n </section>, container);\n};\n\nexport default PopupWindow;"],"names":["EFKW","msg","r","t","f","n","o","clsx","PopupContext","createContext","cn","PopupLayer","props","nodes","setNodes","useState","isScrollDisabled","setIsScrollDisabled","containerRef","useRef","baseZIndex","disableBodyScrollOnActivePopup","useEffect","controller","e","maxZIndex","el","node","invokePopup","anyOpenNode","entityOrId","forceState","newState","_updateNodeInNodes","updateNodeProperty","id","key","value","prev","registerNode","isOpen","disabled","jsxs","jsx","PopupButton","ctx","useContext","isActive","setIsActive","Tag","useMixedState","initialStateOrValue","externalSetter","isControlled","useMemo","state","setter","PopupWindow","container","setContainer","setIsOpen","zIndex","setZIndex","setDisabled","layerRef","animation","animationDuration","useLayoutEffect","layer","layerOnClick","createPortal"],"mappings":"uXAAA,MAAMA,UAAa,KAAM,CACvB,YAAYC,EAAa,CACvB,MAAMA,CAAG,EAET,KAAK,KAAO,uBACd,CACF,CCNA,SAASC,EAAE,EAAE,CAAC,IAAIC,EAAEC,EAAEC,EAAE,GAAG,GAAa,OAAO,GAAjB,UAA8B,OAAO,GAAjB,SAAmBA,GAAG,UAAoB,OAAO,GAAjB,SAAmB,GAAG,MAAM,QAAQ,CAAC,EAAE,CAAC,IAAIC,EAAE,EAAE,OAAO,IAAIH,EAAE,EAAEA,EAAEG,EAAEH,IAAI,EAAEA,CAAC,IAAIC,EAAEF,EAAE,EAAEC,CAAC,CAAC,KAAKE,IAAIA,GAAG,KAAKA,GAAGD,EAAE,KAAM,KAAIA,KAAK,EAAE,EAAEA,CAAC,IAAIC,IAAIA,GAAG,KAAKA,GAAGD,GAAG,OAAOC,CAAC,CAAQ,SAASE,GAAM,CAAC,QAAQ,EAAEJ,EAAEC,EAAE,EAAEC,EAAE,GAAGC,EAAE,U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GAAe,CAClB5B,EAAS,SAAS,SAAS,GAE/BI,EAAI,YAAYjC,EAAM,GAAI,EAAK,CACjC,CAIA,OAAO8C,GAAaY,EAAAA,aAAa3B,EAAAA,IAAC,UAAA,CAChC,UAAWjC,EAAG,sBAAuB8B,GAAU,8BAA+B5B,EAAM,cAAc,EAClG,cAAa,CAAC4B,EACd,MAAO,CAAE,WAAY,GAAG0B,CAAiB,iBAAkB,OAAQzB,EAAS,SAAS,SAAS,EAAI,UAAY,SAAA,EAC9G,QAAS4B,EACT,IAAKL,EAEL,SAAArB,EAAAA,IAAC,UAAA,CACC,GAAI/B,EAAM,GACV,UAAWF,EAAG,aAAc8B,GAAU,qBAAsByB,GAAa,yBAAyBA,CAAS,GAAIrD,EAAM,SAAS,EAC9H,KAAK,SACL,aAAU,GACV,QAASY,GAAKA,EAAE,gBAAA,EAEf,SAAAZ,EAAM,QAAA,CAAA,CACT,CAAA,EACU8C,CAAS,CACvB","x_google_ignoreList":[1]}
|
|
1
|
+
{"version":3,"file":"index.umd.js","sources":["../node_modules/clsx/dist/clsx.mjs","../src/_package/Interfaces.ts","../src/_package/PopupButton.tsx","../src/_package/components/ErrorComponents.ts","../src/_package/PopupLayer.tsx","../src/_package/hooks/useMixedState.ts","../src/_package/PopupWindow.tsx"],"sourcesContent":["function r(e){var t,f,n=\"\";if(\"string\"==typeof e||\"number\"==typeof e)n+=e;else if(\"object\"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=\" \"),n+=f)}else for(f in e)e[f]&&(n&&(n+=\" \"),n+=f);return n}export function clsx(){for(var e,t,f=0,n=\"\",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r(e))&&(n&&(n+=\" \"),n+=t);return n}export default clsx;","import React, { createContext, RefObject } from 'react';\nimport clsx from 'clsx';\n\n\n\n\nexport type PopupWindowDisabledType = 'onEscape' | 'onLayer';\nexport type StateSetter<S = any> = React.Dispatch<React.SetStateAction<S>>\nexport type RegisterNodeArgs = Pick<IPopupNode, 'id' | 'isOpen' | 'disabled'>\n\n/** Get value type from nested object path */\nexport type ValueFromPath<T, P> =\n P extends `${infer K}.${infer R}`\n ? K extends keyof T\n ? R extends keyof T[K]\n ? T[K][R]\n : never\n : never\n : P extends keyof T\n ? T[P]\n : never;\n\n\n\nexport interface IPopupNode {\n id: string\n isOpen: boolean\n zIndex: number\n disabled: PopupWindowDisabledType[]\n}\n\nexport interface IPopupContext {\n nodes: IPopupNode[]\n containerRef: RefObject<HTMLDivElement | null>\n\n invokePopup(id: string, forceState?: boolean): void\n registerNode(args: RegisterNodeArgs): void\n updateNodeProperty<K extends keyof IPopupNode>(id: string, key: K, value: ValueFromPath<IPopupNode, K>): void\n}\n\n\n\nexport const PopupContext = createContext<IPopupContext>({} as IPopupContext);\nexport const cn = clsx;","'use client';\n\nimport { FC, JSX, ReactNode, useContext, useEffect, useState } from 'react';\n\nimport { cn, PopupContext } from './Interfaces';\n\n\n\nexport interface IPopupButtonProps {\n popupId: string\n\n /** \n * Element tag\n * \n * @default \"button\"\n */\n as?: 'button' | 'div'\n\n disabled?: boolean\n children?: ReactNode | ReactNode[]\n className?: string\n id?: string\n\n onClick?(e: React.MouseEvent): void\n}\n\n\n\nexport const PopupButton: FC<IPopupButtonProps> = (props) => {\n const ctx = useContext(PopupContext);\n\n const [isActive, setIsActive] = useState(false);\n\n const Tag: keyof JSX.IntrinsicElements = props.as ?? 'button';\n\n\n\n // Handle isActive on context change\n useEffect(() => {\n const node = ctx.nodes.find(el => el.id === props.popupId);\n if (!node) return;\n\n setIsActive(node.isOpen);\n }, [ctx]);\n\n\n\n function invokePopup(e: React.MouseEvent) {\n ctx.invokePopup(props.popupId);\n\n if (props.onClick) props.onClick(e);\n }\n\n\n\n return <Tag\n tabIndex={0}\n disabled={props.disabled}\n aria-disabled={props.disabled}\n aria-haspopup={'dialog'}\n id={props.id}\n className={cn(`neko-popup-button`, isActive && 'neko-popup-button--active', props.className)}\n onClick={invokePopup}\n >\n {props.children}\n </Tag>;\n};","class EFKW extends Error {\n constructor(msg: string) {\n super(msg);\n\n this.name = 'error at [neko-popup]';\n }\n}\n\nexport default EFKW;","'use client';\n\nimport { FC, ReactNode, useEffect, useRef, useState } from 'react';\n\nimport EFKW from './components/ErrorComponents';\nimport { IPopupNode, PopupContext, RegisterNodeArgs, ValueFromPath } from './Interfaces';\n\n\n\nexport interface IPopupLayerProps {\n children?: ReactNode | ReactNode[]\n\n /** @default 10000 */\n baseZIndex?: number\n\n /**\n * Disable body scroll when there is at least one open popup\n * \n * @default true\n */\n disableBodyScrollOnActivePopup?: boolean\n}\n\n\n\nexport const PopupLayer: FC<IPopupLayerProps> = (props) => {\n const [nodes, setNodes] = useState<IPopupNode[]>([]);\n const [isScrollDisabled, setIsScrollDisabled] = useState(false);\n\n const containerRef = useRef<HTMLDivElement>(null);\n\n const baseZIndex = props.baseZIndex ?? 10000;\n const disableBodyScrollOnActivePopup = props.disableBodyScrollOnActivePopup ?? true;\n\n\n\n // Handle close closest to user popup on escape & scroll\n useEffect(() => {\n // === Handle close closest popup on escape\n const controller = new AbortController();\n\n window.addEventListener('keydown', e => {\n const key = e.key;\n\n if (key === 'Escape') {\n const maxZIndex = Math.max(...nodes.filter(el => el.isOpen).map(el => el.zIndex));\n const node = nodes.find(el => el.zIndex === maxZIndex);\n if (!node || node.disabled.includes('onEscape')) return;\n\n // eslint-disable-next-line\n invokePopup(node.id, false);\n }\n }, { signal: controller.signal });\n\n\n\n // === Disable body scroll on active popup\n if (disableBodyScrollOnActivePopup) {\n let anyOpenNode = false;\n nodes.forEach(el => el.isOpen ? anyOpenNode = true : null);\n\n setIsScrollDisabled(anyOpenNode);\n }\n\n\n\n return () => {\n controller.abort();\n };\n }, [nodes]);\n\n // Handle body scroll\n useEffect(() => {\n if (isScrollDisabled) document.body.classList.add('neko-popup--noScroll');\n else document.body.classList.remove('neko-popup--noScroll');\n }, [isScrollDisabled]);\n\n\n\n /** Toggle popup state */\n function invokePopup(entityOrId: string | IPopupNode, forceState?: boolean) {\n const node = typeof entityOrId === 'string' ? nodes.find(el => el.id === entityOrId) : entityOrId;\n if (!node) throw new EFKW(typeof entityOrId === 'string' ? `Cannot find popup node with id #${entityOrId}` : `Entity is not assigned to the node`);\n\n const newState = forceState ?? !node.isOpen;\n\n // === Update node\n node.isOpen = newState;\n node.zIndex = newState ? Math.max(...nodes.map(el => el.zIndex), 0) + 1 : -1; // Make new popup invocation closer to user using larger z-index\n\n _updateNodeInNodes(node);\n }\n\n /** Update node property */\n function updateNodeProperty<K extends keyof IPopupNode>(id: string, key: K, value: ValueFromPath<IPopupNode, K>) {\n const node = nodes.find(el => el.id === id);\n if (!node) return;\n\n node[key] = value;\n\n _updateNodeInNodes(node);\n }\n\n /** Update node in nodes array */\n function _updateNodeInNodes(node: IPopupNode) {\n setNodes(prev => [...prev.filter(el => el.id !== node.id), node]);\n }\n\n /** Add new popup window to state */\n const registerNode = ({ id, isOpen, disabled }: RegisterNodeArgs) => invokePopup({ id, isOpen: false, disabled, zIndex: -1 }, isOpen);\n\n\n\n return <PopupContext.Provider value={{\n nodes,\n containerRef,\n invokePopup,\n registerNode,\n updateNodeProperty\n }}>\n {props.children}\n\n <section style={{ zIndex: baseZIndex }} ref={containerRef} />\n </PopupContext.Provider>;\n};","'use client';\n\nimport { useEffect, useMemo, useState } from 'react';\n\n\n\n\ntype StateSetter<S> = React.Dispatch<React.SetStateAction<S>>;\ntype InitialState<S> = S | (() => S);\n\nexport default function useMixedState<S = undefined>(): [S | undefined, StateSetter<S | undefined>];\nexport default function useMixedState<S>(initialState: InitialState<S>): [S, StateSetter<S>];\nexport default function useMixedState<S>(state: S, setter?: StateSetter<S>): [S, StateSetter<S>];\n\n\n\n/** \n * Use mixed state hook\n * \n * @param initialStateOrValue Initial state, can be undefined, value or function. If externalSetter not specified, will return default state\n * @param externalSetter External state setter. If specified will return external state\n */\nexport default function useMixedState<S>(initialStateOrValue?: InitialState<S>, externalSetter?: StateSetter<S>) {\n const isControlled = useMemo(() => arguments.length === 2 && externalSetter !== undefined, []);\n\n const [state, setter] = useState<S | undefined>(initialStateOrValue);\n\n\n\n // Propagate state update on external state update even if external setter is not provided\n useEffect(() => {\n if (!isControlled) {\n \n setter(initialStateOrValue);\n }\n }, [initialStateOrValue]);\n\n\n\n if (isControlled) {\n return [\n initialStateOrValue as S,\n externalSetter as StateSetter<S>\n ];\n }\n\n return [state, setter];\n}","'use client';\n\nimport { FC, ReactNode, useContext, useEffect, useLayoutEffect, useRef, useState } from 'react';\nimport { createPortal } from 'react-dom';\n\nimport useMixedState from './hooks/useMixedState';\nimport { cn, PopupContext, PopupWindowDisabledType, StateSetter } from './Interfaces';\n\n\n\nexport type PopupWindowAnimationType = 'fade' | 'scale' | null\n\n\n\nexport interface IPopupWindowProps {\n id: string\n children: ReactNode | ReactNode[]\n\n isOpen?: boolean\n setIsOpen?: StateSetter<boolean>\n\n className?: string\n layerClassName?: string\n disabled?: PopupWindowDisabledType[] | boolean\n\n /** \n * Popup dialog animation type\n * \n * @default \"fade\"\n */\n animation?: 'fade' | 'scale' | null\n\n /**\n * Popup animation duration in msec\n * \n * @default 200\n */\n animationDuraionMs?: number\n\n /** \n * Fire callback when popup invoked to open\n */\n onBeforeEnter?(): void\n\n /** \n * Fire callback when popup open animation fullfilled. \n * \n * @see animationDuration\n */\n onAfterEnter?(): void\n\n /** \n * Fire callback when popup invoked to close\n */\n onBeforeExit?(): void\n\n /** \n * Fire callback when popup close animation fullfilled. \n * \n * @see animationDuration\n */\n onAfterExit?(): void\n}\n\n\n\nexport const PopupWindow: FC<IPopupWindowProps> = (props) => {\n const ctx = useContext(PopupContext);\n\n const [container, setContainer] = useState<HTMLDivElement | null>(null);\n const [isOpen, setIsOpen] = useMixedState(props.isOpen ?? false, props.setIsOpen);\n const [zIndex, setZIndex] = useState(-1);\n const [disabled, setDisabled] = useState<PopupWindowDisabledType[]>([]);\n\n const layerRef = useRef<HTMLDivElement>(null);\n\n const animation: PopupWindowAnimationType = props.animation !== undefined ? props.animation : 'fade';\n const animationDuration = props.animationDuraionMs ?? 200;\n\n\n\n // Handle disabled\n useLayoutEffect(() => {\n let disabled: PopupWindowDisabledType[] = [];\n\n if (typeof props.disabled === 'boolean') disabled = props.disabled ? ['onEscape', 'onLayer'] : [];\n else disabled = props.disabled ?? [];\n\n ctx.updateNodeProperty(props.id, 'disabled', disabled);\n }, [props.disabled]);\n\n\n\n // Mount & register node\n useEffect(() => {\n const container = ctx.containerRef.current;\n if (!container) return;\n\n setContainer(container);\n\n ctx.registerNode({\n id: props.id,\n isOpen: Boolean(props.isOpen),\n disabled\n });\n }, []);\n\n // Handle node sync with context\n useEffect(() => {\n const node = ctx.nodes.find(el => el.id === props.id);\n if (!node) return;\n\n setIsOpen(node.isOpen);\n setZIndex(node.zIndex);\n setDisabled(node.disabled);\n }, [ctx.nodes]);\n\n // Handle layer z-index change\n useEffect(() => {\n const layer = layerRef.current;\n if (!layer) return;\n\n if (isOpen) layer.style.zIndex = `${zIndex}`;\n else setTimeout(() => {\n layer.style.zIndex = `${-1}`;\n }, animationDuration);\n }, [isOpen]);\n\n // Handle events (onBeforeEnter, etc)\n useEffect(() => {\n if (isOpen) {\n if (props.onBeforeEnter) props.onBeforeEnter();\n\n setTimeout(() => {\n if (props.onAfterEnter) props.onAfterEnter();\n }, animationDuration);\n } else {\n if (props.onBeforeExit) props.onBeforeExit();\n\n setTimeout(() => {\n if (props.onAfterExit) props.onAfterExit();\n }, animationDuration);\n }\n }, [isOpen]);\n\n\n\n function layerOnClick() {\n if (disabled.includes('onLayer')) return;\n\n ctx.invokePopup(props.id, false);\n }\n\n\n\n return container && createPortal(<section\n className={cn(`neko-popup-backdrop`, isOpen && 'neko-popup-backdrop--active', props.layerClassName)}\n aria-hidden={!isOpen}\n style={{ transition: `${animationDuration}ms ease-in-out`, cursor: disabled.includes('onLayer') ? 'default' : 'pointer' }}\n onClick={layerOnClick}\n ref={layerRef}\n >\n <article\n id={props.id}\n className={cn(`neko-popup`, isOpen && 'neko-popup--active', animation && `neko-popup--animation_${animation}`, props.className)}\n role=\"dialog\"\n aria-modal\n onClick={e => e.stopPropagation()}\n >\n {props.children}\n </article>\n </section>, container);\n};"],"names":["r","t","f","n","o","clsx","PopupContext","createContext","cn","PopupButton","props","ctx","useContext","isActive","setIsActive","useState","Tag","useEffect","node","el","invokePopup","e","jsx","EFKW","msg","PopupLayer","nodes","setNodes","isScrollDisabled","setIsScrollDisabled","containerRef","useRef","baseZIndex","disableBodyScrollOnActivePopup","controller","maxZIndex","anyOpenNode","entityOrId","forceState","newState","_updateNodeInNodes","updateNodeProperty","id","key","value","prev","registerNode","isOpen","disabled","jsxs","useMixedState","initialStateOrValue","externalSetter","isControlled","useMemo","state","setter","PopupWindow","container","setContainer","setIsOpen","zIndex","setZIndex","setDisabled","layerRef","animation","animationDuration","useLayoutEffect","layer","layerOnClick","createPortal"],"mappings":"uXAAA,SAASA,EAAE,EAAE,CAAC,IAAIC,EAAEC,EAAEC,EAAE,GAAG,GAAa,OAAO,GAAjB,UAA8B,OAAO,GAAjB,SAAmBA,GAAG,UAAoB,OAAO,GAAjB,SAAmB,GAAG,MAAM,QAAQ,CAAC,EAAE,CAAC,IAAIC,EAAE,EAAE,OAAO,IAAIH,EAAE,EAAEA,EAAEG,EAAEH,IAAI,EAAEA,CAAC,IAAIC,EAAEF,EAAE,EAAEC,CAAC,CAAC,KAAKE,IAAIA,GAAG,KAAKA,GAAGD,EAAE,KAAM,KAAIA,KAAK,EAAE,EAAEA,CAAC,IAAIC,IAAIA,GAAG,KAAKA,GAAGD,GAAG,OAAOC,CAAC,CAAQ,SAASE,GAAM,CAAC,QAAQ,EAAEJ,EAAEC,EAAE,EAAEC,EAAE,GAAGC,EAAE,UAAU,OAAOF,EAAEE,EAAEF,KAAK,EAAE,UAAUA,CAAC,KAAKD,EAAED,EAAE,CAAC,KAAKG,IAAIA,GAAG,KAAKA,GAAGF,GAAG,OAAOE,CAAC,CC0CxW,MA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EAAM,GAAI,EAAK,CACjC,CAIA,OAAOgD,GAAaY,EAAAA,aAAahD,EAAAA,IAAC,UAAA,CAChC,UAAWd,EAAG,sBAAuBuC,GAAU,8BAA+BrC,EAAM,cAAc,EAClG,cAAa,CAACqC,EACd,MAAO,CAAE,WAAY,GAAGmB,CAAiB,iBAAkB,OAAQlB,EAAS,SAAS,SAAS,EAAI,UAAY,SAAA,EAC9G,QAASqB,EACT,IAAKL,EAEL,SAAA1C,EAAAA,IAAC,UAAA,CACC,GAAIZ,EAAM,GACV,UAAWF,EAAG,aAAcuC,GAAU,qBAAsBkB,GAAa,yBAAyBA,CAAS,GAAIvD,EAAM,SAAS,EAC9H,KAAK,SACL,aAAU,GACV,QAASW,GAAKA,EAAE,gBAAA,EAEf,SAAAX,EAAM,QAAA,CAAA,CACT,CAAA,EACUgD,CAAS,CACvB","x_google_ignoreList":[0]}
|
package/dist/styles.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.neko-popup{cursor:auto;max-height:100%;overflow-y:auto}.neko-popup--animation_fade{transition:inherit}.neko-popup--animation_scale{transition:inherit;scale:.8}.neko-popup--animation_scale.neko-popup--active{scale:1}.neko-popup-backdrop{position:fixed;inset:0;width:100%;height:100%;max-height:100%;background:#0003;-webkit-tap-highlight-color:transparent;contain:paint;opacity:0;visibility:hidden;touch-action:none;pointer-events:none;display:flex;align-items:center;justify-content:center}.neko-popup-backdrop--active{opacity:1;visibility:visible;touch-action:auto;pointer-events:auto}.neko-popup-button{cursor:pointer}.neko-popup--noScroll{overflow:hidden;scrollbar-gutter:stable}
|