@kadoui/react 1.1.3 → 1.2.5
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/components/Popover/Popover.d.ts +8 -0
- package/dist/components/Popover/Popover.d.ts.map +1 -0
- package/dist/components/Popover/Popover.js +7 -0
- package/dist/components/Popover/PopoverBody.d.ts +6 -0
- package/dist/components/Popover/PopoverBody.d.ts.map +1 -0
- package/dist/components/Popover/PopoverBody.jsx +12 -0
- package/dist/components/Popover/PopoverContext.d.ts +10 -0
- package/dist/components/Popover/PopoverContext.d.ts.map +1 -0
- package/dist/components/Popover/PopoverContext.js +2 -0
- package/dist/components/Popover/PopoverMenu.d.ts +6 -0
- package/dist/components/Popover/PopoverMenu.d.ts.map +1 -0
- package/dist/components/Popover/PopoverMenu.jsx +12 -0
- package/dist/components/Popover/PopoverRoot.d.ts +8 -0
- package/dist/components/Popover/PopoverRoot.d.ts.map +1 -0
- package/dist/components/Popover/PopoverRoot.jsx +75 -0
- package/dist/components/Popover/PopoverToggle.d.ts +4 -0
- package/dist/components/Popover/PopoverToggle.d.ts.map +1 -0
- package/dist/components/Popover/PopoverToggle.jsx +13 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/package.json +3 -4
- package/tsconfig.json +1 -1
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { PopoverBody } from "./PopoverBody";
|
|
2
|
+
import { PopoverRoot } from "./PopoverRoot";
|
|
3
|
+
import { PopoverToggle } from "./PopoverToggle";
|
|
4
|
+
export declare const Popover: typeof PopoverRoot & {
|
|
5
|
+
Toggle: typeof PopoverToggle;
|
|
6
|
+
Body: typeof PopoverBody;
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=Popover.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Popover.d.ts","sourceRoot":"","sources":["../../../src/components/Popover/Popover.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,eAAO,MAAM,OAAO;;;CAGlB,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { HTMLAttributes } from "react";
|
|
2
|
+
export type PopoverBodyPropsT = HTMLAttributes<HTMLDivElement> & {
|
|
3
|
+
preventClose?: boolean;
|
|
4
|
+
};
|
|
5
|
+
export declare function PopoverBody({ preventClose, onClick, ...p }: PopoverBodyPropsT): import("react").JSX.Element | null;
|
|
6
|
+
//# sourceMappingURL=PopoverBody.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PopoverBody.d.ts","sourceRoot":"","sources":["../../../src/components/Popover/PopoverBody.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAO,MAAM,OAAO,CAAC;AAI5C,MAAM,MAAM,iBAAiB,GAAG,cAAc,CAAC,cAAc,CAAC,GAAG;IAC/D,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB,CAAA;AAED,wBAAgB,WAAW,CAAC,EAAE,YAAY,EAAE,OAAO,EAAE,GAAG,CAAC,EAAE,EAAE,iBAAiB,sCAkB7E"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { use } from "react";
|
|
3
|
+
import { PopoverContext } from "./PopoverContext";
|
|
4
|
+
export function PopoverBody({ preventClose, onClick, ...p }) {
|
|
5
|
+
const { bodyRef, isOpen } = use(PopoverContext);
|
|
6
|
+
return (isOpen ? (<div ref={bodyRef} onClick={ev => {
|
|
7
|
+
if (preventClose) {
|
|
8
|
+
ev.stopPropagation();
|
|
9
|
+
}
|
|
10
|
+
onClick?.(ev);
|
|
11
|
+
}} {...p}/>) : null);
|
|
12
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Dispatch, RefObject, SetStateAction } from "react";
|
|
2
|
+
export type PopoverContextT = {
|
|
3
|
+
isOpen: boolean;
|
|
4
|
+
setOpen: Dispatch<SetStateAction<boolean>>;
|
|
5
|
+
toggleRef: RefObject<HTMLButtonElement | null>;
|
|
6
|
+
bodyRef: RefObject<HTMLDivElement | null>;
|
|
7
|
+
mode: "click" | "hover" | "both";
|
|
8
|
+
};
|
|
9
|
+
export declare const PopoverContext: import("react").Context<PopoverContextT>;
|
|
10
|
+
//# sourceMappingURL=PopoverContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PopoverContext.d.ts","sourceRoot":"","sources":["../../../src/components/Popover/PopoverContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,QAAQ,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAE3E,MAAM,MAAM,eAAe,GAAG;IAC5B,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,QAAQ,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC;IAC3C,SAAS,EAAE,SAAS,CAAC,iBAAiB,GAAG,IAAI,CAAC,CAAC;IAC/C,OAAO,EAAE,SAAS,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;IAC1C,IAAI,EAAE,OAAO,GAAG,OAAO,GAAG,MAAM,CAAC;CAClC,CAAA;AAED,eAAO,MAAM,cAAc,0CAAwD,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { HTMLAttributes } from "react";
|
|
2
|
+
export type PopoverMenuPropsT = HTMLAttributes<HTMLDivElement> & {
|
|
3
|
+
preventClose?: boolean;
|
|
4
|
+
};
|
|
5
|
+
export declare function PopoverMenu({ preventClose, onClick, ...p }: PopoverMenuPropsT): import("react").JSX.Element | null;
|
|
6
|
+
//# sourceMappingURL=PopoverMenu.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PopoverMenu.d.ts","sourceRoot":"","sources":["../../../src/components/Popover/PopoverMenu.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAO,MAAM,OAAO,CAAC;AAI5C,MAAM,MAAM,iBAAiB,GAAG,cAAc,CAAC,cAAc,CAAC,GAAG;IAC/D,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB,CAAA;AAED,wBAAgB,WAAW,CAAC,EAAE,YAAY,EAAE,OAAO,EAAE,GAAG,CAAC,EAAE,EAAE,iBAAiB,sCAkB7E"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { use } from "react";
|
|
3
|
+
import { PopoverContext } from "./PopoverContext";
|
|
4
|
+
export function PopoverMenu({ preventClose, onClick, ...p }) {
|
|
5
|
+
const { menuRef, isOpen } = use(PopoverContext);
|
|
6
|
+
return (isOpen ? (<div ref={menuRef} onClick={ev => {
|
|
7
|
+
if (preventClose) {
|
|
8
|
+
ev.stopPropagation();
|
|
9
|
+
}
|
|
10
|
+
onClick?.(ev);
|
|
11
|
+
}} {...p}/>) : null);
|
|
12
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { HTMLAttributes } from "react";
|
|
2
|
+
import { PopoverContextT } from "./PopoverContext";
|
|
3
|
+
export type PopoverRootPropsT = HTMLAttributes<HTMLDivElement> & {
|
|
4
|
+
mode?: PopoverContextT["mode"];
|
|
5
|
+
accessHorizontalArrows?: "ArrowRight" | "ArrowLeft";
|
|
6
|
+
};
|
|
7
|
+
export declare function PopoverRoot({ mode, accessHorizontalArrows, onKeyDown, onMouseEnter, onMouseLeave, ...p }: PopoverRootPropsT): import("react").JSX.Element;
|
|
8
|
+
//# sourceMappingURL=PopoverRoot.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PopoverRoot.d.ts","sourceRoot":"","sources":["../../../src/components/Popover/PopoverRoot.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAA8C,MAAM,OAAO,CAAC;AAEnF,OAAO,EAAkB,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAInE,MAAM,MAAM,iBAAiB,GAAG,cAAc,CAAC,cAAc,CAAC,GAAG;IAC/D,IAAI,CAAC,EAAE,eAAe,CAAC,MAAM,CAAC,CAAC;IAC/B,sBAAsB,CAAC,EAAE,YAAY,GAAG,WAAW,CAAC;CACrD,CAAA;AAED,wBAAgB,WAAW,CAAC,EAAE,IAAc,EAAE,sBAAsB,EAAE,SAAS,EAAE,YAAY,EAAE,YAAY,EAAE,GAAG,CAAC,EAAE,EAAE,iBAAiB,+BAwFrI"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useEffect, useRef, useState } from "react";
|
|
3
|
+
import { PopoverContext } from "./PopoverContext";
|
|
4
|
+
import { selectAccessibleChildren } from "../../utils";
|
|
5
|
+
export function PopoverRoot({ mode = "click", accessHorizontalArrows, onKeyDown, onMouseEnter, onMouseLeave, ...p }) {
|
|
6
|
+
const [isOpen, setOpen] = useState(false);
|
|
7
|
+
const toggleRef = useRef(null);
|
|
8
|
+
const bodyRef = useRef(null);
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
const closeHandler = () => {
|
|
11
|
+
setOpen(false);
|
|
12
|
+
};
|
|
13
|
+
window.addEventListener("click", closeHandler);
|
|
14
|
+
return () => window.removeEventListener("click", closeHandler);
|
|
15
|
+
}, []);
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
if (isOpen) {
|
|
18
|
+
selectFirstMenuChild();
|
|
19
|
+
}
|
|
20
|
+
}, [isOpen]);
|
|
21
|
+
const selectFirstMenuChild = () => {
|
|
22
|
+
if (!bodyRef.current) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const children = selectAccessibleChildren(bodyRef.current);
|
|
26
|
+
const firstChild = children[0];
|
|
27
|
+
if (!firstChild) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
firstChild.focus();
|
|
31
|
+
};
|
|
32
|
+
const handleKeyDown = (ev) => {
|
|
33
|
+
if (!accessHorizontalArrows) {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
if (ev.key === "ArrowRight") {
|
|
37
|
+
if (accessHorizontalArrows === "ArrowRight") {
|
|
38
|
+
setOpen(true);
|
|
39
|
+
selectFirstMenuChild();
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
setOpen(false);
|
|
43
|
+
toggleRef.current?.focus();
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
if (ev.key === "ArrowLeft") {
|
|
47
|
+
if (accessHorizontalArrows === "ArrowLeft") {
|
|
48
|
+
setOpen(true);
|
|
49
|
+
selectFirstMenuChild();
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
setOpen(false);
|
|
53
|
+
toggleRef.current?.focus();
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
return (<PopoverContext value={{ isOpen, setOpen, toggleRef, bodyRef, mode }}>
|
|
58
|
+
<div onKeyDown={ev => {
|
|
59
|
+
onKeyDown?.(ev);
|
|
60
|
+
handleKeyDown(ev);
|
|
61
|
+
}} onMouseEnter={ev => {
|
|
62
|
+
onMouseEnter?.(ev);
|
|
63
|
+
if (["hover", "both"].includes(mode)) {
|
|
64
|
+
ev.stopPropagation();
|
|
65
|
+
setOpen(true);
|
|
66
|
+
}
|
|
67
|
+
}} onMouseLeave={ev => {
|
|
68
|
+
onMouseLeave?.(ev);
|
|
69
|
+
if (["hover", "both"].includes(mode)) {
|
|
70
|
+
ev.stopPropagation();
|
|
71
|
+
setOpen(false);
|
|
72
|
+
}
|
|
73
|
+
}} {...p}/>
|
|
74
|
+
</PopoverContext>);
|
|
75
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PopoverToggle.d.ts","sourceRoot":"","sources":["../../../src/components/Popover/PopoverToggle.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAO,MAAM,OAAO,CAAC;AAI5C,MAAM,MAAM,mBAAmB,GAAG,cAAc,CAAC,iBAAiB,CAAC,CAAC;AAEpE,wBAAgB,aAAa,CAAC,EAAE,OAAO,EAAE,GAAG,KAAK,EAAE,EAAE,mBAAmB,+BAgBvE"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { use } from "react";
|
|
3
|
+
import { PopoverContext } from "./PopoverContext";
|
|
4
|
+
export function PopoverToggle({ onClick, ...props }) {
|
|
5
|
+
const { mode, toggleRef, setOpen } = use(PopoverContext);
|
|
6
|
+
return (<button ref={toggleRef} onClick={ev => {
|
|
7
|
+
onClick?.(ev);
|
|
8
|
+
ev.stopPropagation();
|
|
9
|
+
if (["click", "both"].includes(mode)) {
|
|
10
|
+
setOpen(prev => !prev);
|
|
11
|
+
}
|
|
12
|
+
}} {...props}/>);
|
|
13
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -7,12 +7,12 @@ export * from "./components/ClientOnly/ClientOnly";
|
|
|
7
7
|
export * from "./components/Clipboard/Clipboard";
|
|
8
8
|
export * from "./components/ContextMenu/ContextMenu";
|
|
9
9
|
export * from "./components/Drawer/Drawer";
|
|
10
|
-
export * from "./components/Dropdown/Dropdown";
|
|
11
10
|
export * from "./components/LoaderLink/LoaderLink";
|
|
12
11
|
export * from "./components/Modal/Modal";
|
|
13
12
|
export * from "./components/Otp/Otp";
|
|
14
13
|
export * from "./components/Pagination/Pagination";
|
|
15
14
|
export * from "./components/PasswordInput/PasswordInput";
|
|
15
|
+
export * from "./components/Popover/Popover";
|
|
16
16
|
export * from "./components/Portal/Portal";
|
|
17
17
|
export * from "./components/Progress/Progress";
|
|
18
18
|
export * from "./components/QrCode/QrCode";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gDAAgD,CAAC;AAC/D,cAAc,kCAAkC,CAAC;AACjD,cAAc,0BAA0B,CAAC;AACzC,cAAc,sCAAsC,CAAC;AACrD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,oCAAoC,CAAC;AACnD,cAAc,kCAAkC,CAAC;AACjD,cAAc,sCAAsC,CAAC;AACrD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gDAAgD,CAAC;AAC/D,cAAc,kCAAkC,CAAC;AACjD,cAAc,0BAA0B,CAAC;AACzC,cAAc,sCAAsC,CAAC;AACrD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,oCAAoC,CAAC;AACnD,cAAc,kCAAkC,CAAC;AACjD,cAAc,sCAAsC,CAAC;AACrD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,oCAAoC,CAAC;AACnD,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oCAAoC,CAAC;AACnD,cAAc,0CAA0C,CAAC;AACzD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,0BAA0B,CAAC;AACzC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -7,12 +7,12 @@ export * from "./components/ClientOnly/ClientOnly";
|
|
|
7
7
|
export * from "./components/Clipboard/Clipboard";
|
|
8
8
|
export * from "./components/ContextMenu/ContextMenu";
|
|
9
9
|
export * from "./components/Drawer/Drawer";
|
|
10
|
-
export * from "./components/Dropdown/Dropdown";
|
|
11
10
|
export * from "./components/LoaderLink/LoaderLink";
|
|
12
11
|
export * from "./components/Modal/Modal";
|
|
13
12
|
export * from "./components/Otp/Otp";
|
|
14
13
|
export * from "./components/Pagination/Pagination";
|
|
15
14
|
export * from "./components/PasswordInput/PasswordInput";
|
|
15
|
+
export * from "./components/Popover/Popover";
|
|
16
16
|
export * from "./components/Portal/Portal";
|
|
17
17
|
export * from "./components/Progress/Progress";
|
|
18
18
|
export * from "./components/QrCode/QrCode";
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kadoui/react",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.5",
|
|
4
4
|
"description": "Kadoui primitive components for React",
|
|
5
|
-
"author": "
|
|
5
|
+
"author": "ArrowUp",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"scripts": {
|
|
@@ -27,7 +27,6 @@
|
|
|
27
27
|
"next": "15.4.5",
|
|
28
28
|
"@mantine/hooks": "^8.1.3",
|
|
29
29
|
"framer-motion": "^12.23.0",
|
|
30
|
-
"lucide-react": "^0.525.0",
|
|
31
30
|
"qrcode": "^1.5.4",
|
|
32
31
|
"zustand": "^5.0.6",
|
|
33
32
|
"nanoid": "^5.1.5",
|
|
@@ -35,7 +34,7 @@
|
|
|
35
34
|
"tailwind-merge": "^3.3.1"
|
|
36
35
|
},
|
|
37
36
|
"devDependencies": {
|
|
38
|
-
"
|
|
37
|
+
"tsconfig": "workspace:*",
|
|
39
38
|
"typescript": "^5",
|
|
40
39
|
"@types/node": "^20",
|
|
41
40
|
"@types/react": "^19",
|
package/tsconfig.json
CHANGED