@kadoui/react 1.1.3 → 1.2.4

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.
@@ -0,0 +1,8 @@
1
+ import { PopoverMenu } from "./PopoverMenu";
2
+ import { PopoverRoot } from "./PopoverRoot";
3
+ import { PopoverToggle } from "./PopoverToggle";
4
+ export declare const Popover: typeof PopoverRoot & {
5
+ Toggle: typeof PopoverToggle;
6
+ Menu: typeof PopoverMenu;
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,7 @@
1
+ import { PopoverMenu } from "./PopoverMenu";
2
+ import { PopoverRoot } from "./PopoverRoot";
3
+ import { PopoverToggle } from "./PopoverToggle";
4
+ export const Popover = Object.assign(PopoverRoot, {
5
+ Toggle: PopoverToggle,
6
+ Menu: PopoverMenu
7
+ });
@@ -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
+ menuRef: 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,2 @@
1
+ import { createContext } from "react";
2
+ export const PopoverContext = createContext({});
@@ -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 menuRef = 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 (!menuRef.current) {
23
+ return;
24
+ }
25
+ const children = selectAccessibleChildren(menuRef.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, menuRef, 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,4 @@
1
+ import { HTMLAttributes } from "react";
2
+ export type PopoverTogglePropsT = HTMLAttributes<HTMLButtonElement>;
3
+ export declare function PopoverToggle({ onClick, ...props }: PopoverTogglePropsT): import("react").JSX.Element;
4
+ //# sourceMappingURL=PopoverToggle.d.ts.map
@@ -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";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gDAAgD,CAAC;AAC/D,cAAc,kCAAkC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;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,6 +1,6 @@
1
1
  {
2
2
  "name": "@kadoui/react",
3
- "version": "1.1.3",
3
+ "version": "1.2.4",
4
4
  "description": "Kadoui primitive components for React",
5
5
  "author": "Jstation",
6
6
  "license": "MIT",
@@ -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
- "@repo/tsconfig": "workspace:*",
37
+ "tsconfig": "workspace:*",
39
38
  "typescript": "^5",
40
39
  "@types/node": "^20",
41
40
  "@types/react": "^19",
package/tsconfig.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "extends": "@repo/tsconfig",
2
+ "extends": "tsconfig",
3
3
  "compilerOptions": {
4
4
  "module": "ESNext",
5
5
  "moduleResolution": "Bundler",