@kadoui/react 1.6.3 → 1.6.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.
@@ -1 +1 @@
1
- {"version":3,"file":"DrawerRoot.d.ts","sourceRoot":"","sources":["../../../src/components/Drawer/DrawerRoot.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAuB,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAI/D,MAAM,MAAM,gBAAgB,GAAG,iBAAiB,CAAC;AAEjD,wBAAgB,UAAU,CAAC,EAAE,QAAQ,EAAE,EAAE,gBAAgB,2CAmCxD"}
1
+ {"version":3,"file":"DrawerRoot.d.ts","sourceRoot":"","sources":["../../../src/components/Drawer/DrawerRoot.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAuB,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAK/D,MAAM,MAAM,gBAAgB,GAAG,iBAAiB,CAAC;AAEjD,wBAAgB,UAAU,CAAC,EAAE,QAAQ,EAAE,EAAE,gBAAgB,2CAqCxD"}
@@ -1,16 +1,20 @@
1
1
  "use client";
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
- import { getBrowserScrollbarWith } from "../../utils";
3
+ import { usePathname } from "next/navigation";
4
4
  import { useState, useEffect } from "react";
5
5
  import { DrawerContext } from "./DrawerContext";
6
+ import { getBrowserScrollbarWith } from "../../utils";
6
7
  export function DrawerRoot({ children }) {
8
+ const pathname = usePathname();
7
9
  const [isOpen, setOpen] = useState(false);
10
+ useEffect(() => {
11
+ setOpen(false);
12
+ }, [pathname]);
8
13
  useEffect(() => {
9
14
  const handleEscape = (ev) => {
10
15
  if (ev.key === "Escape") {
11
16
  setOpen(false);
12
17
  }
13
- ;
14
18
  };
15
19
  document.addEventListener("keydown", handleEscape);
16
20
  return () => {
@@ -28,7 +32,6 @@ export function DrawerRoot({ children }) {
28
32
  document.body.style.overflow = "unset";
29
33
  document.body.style.paddingRight = "0px";
30
34
  }
31
- ;
32
35
  }, [isOpen]);
33
- return (_jsx(DrawerContext, { value: { isOpen, setOpen }, children: children }));
36
+ return _jsx(DrawerContext, { value: { isOpen, setOpen }, children: children });
34
37
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ModalRoot.d.ts","sourceRoot":"","sources":["../../../src/components/Modal/ModalRoot.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAuB,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAM/D,MAAM,MAAM,eAAe,GAAG,iBAAiB,GAAG;IAChD,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,CAAC;AAEF,wBAAgB,SAAS,CAAC,EAAE,QAAQ,EAAE,WAAmB,EAAE,EAAE,eAAe,2CA+B3E"}
1
+ {"version":3,"file":"ModalRoot.d.ts","sourceRoot":"","sources":["../../../src/components/Modal/ModalRoot.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAuB,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAK/D,MAAM,MAAM,eAAe,GAAG,iBAAiB,GAAG;IAChD,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,CAAC;AAEF,wBAAgB,SAAS,CAAC,EAAE,QAAQ,EAAE,WAAmB,EAAE,EAAE,eAAe,2CAoC3E"}
@@ -1,10 +1,15 @@
1
1
  "use client";
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { usePathname } from "next/navigation";
3
4
  import { useState, useEffect } from "react";
4
- import { getBrowserScrollbarWith } from "../../utils";
5
5
  import { ModalContext } from "./ModalContext";
6
+ import { getBrowserScrollbarWith } from "../../utils";
6
7
  export function ModalRoot({ children, defaultOpen = false }) {
8
+ const pathname = usePathname();
7
9
  const [isOpen, setOpen] = useState(defaultOpen);
10
+ useEffect(() => {
11
+ setOpen(false);
12
+ }, [pathname]);
8
13
  useEffect(() => {
9
14
  const handleEscape = (e) => {
10
15
  if (e.key === "Escape") {
@@ -1 +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,2CAyFrI"}
1
+ {"version":3,"file":"PopoverRoot.d.ts","sourceRoot":"","sources":["../../../src/components/Popover/PopoverRoot.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAA8C,MAAM,OAAO,CAAC;AAGnF,OAAO,EAAkB,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEnE,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,CAAC;AAEF,wBAAgB,WAAW,CAAC,EAC1B,IAAc,EACd,sBAAsB,EACtB,SAAS,EACT,YAAY,EACZ,YAAY,EACZ,GAAG,CAAC,EACL,EAAE,iBAAiB,2CA+FnB"}
@@ -1,9 +1,11 @@
1
1
  "use client";
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { usePathname } from "next/navigation";
3
4
  import { useEffect, useRef, useState } from "react";
4
- import { PopoverContext } from "./PopoverContext";
5
5
  import { selectAccessibleChildren } from "../../utils";
6
+ import { PopoverContext } from "./PopoverContext";
6
7
  export function PopoverRoot({ mode = "click", accessHorizontalArrows, onKeyDown, onMouseEnter, onMouseLeave, ...p }) {
8
+ const pathname = usePathname();
7
9
  const [isOpen, setOpen] = useState(false);
8
10
  const toggleRef = useRef(null);
9
11
  const bodyRef = useRef(null);
@@ -14,6 +16,9 @@ export function PopoverRoot({ mode = "click", accessHorizontalArrows, onKeyDown,
14
16
  window.addEventListener("click", closeHandler);
15
17
  return () => window.removeEventListener("click", closeHandler);
16
18
  }, []);
19
+ useEffect(() => {
20
+ setOpen(false);
21
+ }, [pathname]);
17
22
  useEffect(() => {
18
23
  if (isOpen) {
19
24
  selectFirstMenuChild();
@@ -55,16 +60,16 @@ export function PopoverRoot({ mode = "click", accessHorizontalArrows, onKeyDown,
55
60
  }
56
61
  }
57
62
  };
58
- return (_jsx(PopoverContext, { value: { isOpen, setOpen, toggleRef, bodyRef, mode }, children: _jsx("div", { "data-state": isOpen ? "active" : "inactive", onKeyDown: ev => {
63
+ return (_jsx(PopoverContext, { value: { isOpen, setOpen, toggleRef, bodyRef, mode }, children: _jsx("div", { "data-state": isOpen ? "active" : "inactive", onKeyDown: (ev) => {
59
64
  onKeyDown?.(ev);
60
65
  handleKeyDown(ev);
61
- }, onMouseEnter: ev => {
66
+ }, onMouseEnter: (ev) => {
62
67
  onMouseEnter?.(ev);
63
68
  if (["hover", "both"].includes(mode)) {
64
69
  ev.stopPropagation();
65
70
  setOpen(true);
66
71
  }
67
- }, onMouseLeave: ev => {
72
+ }, onMouseLeave: (ev) => {
68
73
  onMouseLeave?.(ev);
69
74
  if (["hover", "both"].includes(mode)) {
70
75
  ev.stopPropagation();
@@ -1,4 +1,4 @@
1
1
  import { HTMLMotionProps } from "framer-motion";
2
2
  export type SheetBodyPropsT = HTMLMotionProps<"div">;
3
- export declare function SheetBody(p: SheetBodyPropsT): import("react/jsx-runtime").JSX.Element;
3
+ export declare function SheetBody({ onPointerDown, ...p }: SheetBodyPropsT): import("react/jsx-runtime").JSX.Element;
4
4
  //# sourceMappingURL=SheetBody.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SheetBody.d.ts","sourceRoot":"","sources":["../../../src/components/Sheet/SheetBody.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAU,MAAM,eAAe,CAAC;AAIxD,MAAM,MAAM,eAAe,GAAG,eAAe,CAAC,KAAK,CAAC,CAAC;AAErD,wBAAgB,SAAS,CAAC,CAAC,EAAE,eAAe,2CAiC3C"}
1
+ {"version":3,"file":"SheetBody.d.ts","sourceRoot":"","sources":["../../../src/components/Sheet/SheetBody.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAA2B,MAAM,eAAe,CAAC;AAIzE,MAAM,MAAM,eAAe,GAAG,eAAe,CAAC,KAAK,CAAC,CAAC;AAErD,wBAAgB,SAAS,CAAC,EAAE,aAAa,EAAE,GAAG,CAAC,EAAE,EAAE,eAAe,2CAuCjE"}
@@ -1,11 +1,16 @@
1
1
  "use client";
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
3
  import { use } from "react";
4
- import { motion } from "framer-motion";
4
+ import { motion, useDragControls } from "framer-motion";
5
5
  import { SheetContext } from "./SheetContext";
6
- export function SheetBody(p) {
7
- const { controls, y, closeHandler: handleClose } = use(SheetContext);
8
- return (_jsx(motion.div, { id: "sheet", onClick: (ev) => ev.stopPropagation(), initial: { y: "100%" }, animate: { y: "0%" }, exit: { y: "100%" }, style: { y }, drag: "y", dragControls: controls, dragListener: false, transition: {
6
+ export function SheetBody({ onPointerDown, ...p }) {
7
+ const { y, closeHandler: handleClose } = use(SheetContext);
8
+ const controls = useDragControls();
9
+ return (_jsx(motion.div, { id: "sheet", onClick: (ev) => ev.stopPropagation(), initial: { y: "100%" }, animate: { y: "0%" }, exit: { y: "100%" }, style: { y }, drag: "y", dragListener: false, dragControls: controls, onPointerDown: (ev) => {
10
+ ev.stopPropagation();
11
+ controls?.start(ev);
12
+ onPointerDown?.(ev);
13
+ }, transition: {
9
14
  ease: "easeInOut",
10
15
  }, onDragEnd: () => {
11
16
  if ((y?.get() || 0) >= 100) {
@@ -1,4 +1,4 @@
1
1
  import { HTMLAttributes } from "react";
2
2
  export type SheetContentPropsT = HTMLAttributes<HTMLDivElement>;
3
- export declare function SheetContent(p: SheetContentPropsT): import("react/jsx-runtime").JSX.Element;
3
+ export declare function SheetContent({ style, onScroll, ...p }: SheetContentPropsT): import("react/jsx-runtime").JSX.Element;
4
4
  //# sourceMappingURL=SheetContent.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SheetContent.d.ts","sourceRoot":"","sources":["../../../src/components/Sheet/SheetContent.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAEvC,MAAM,MAAM,kBAAkB,GAAG,cAAc,CAAC,cAAc,CAAC,CAAC;AAEhE,wBAAgB,YAAY,CAAC,CAAC,EAAE,kBAAkB,2CAEjD"}
1
+ {"version":3,"file":"SheetContent.d.ts","sourceRoot":"","sources":["../../../src/components/Sheet/SheetContent.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAEvC,MAAM,MAAM,kBAAkB,GAAG,cAAc,CAAC,cAAc,CAAC,CAAC;AAEhE,wBAAgB,YAAY,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,CAAC,EAAE,EAAE,kBAAkB,2CAmBzE"}
@@ -1,4 +1,15 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- export function SheetContent(p) {
3
- return _jsx("div", { ...p });
2
+ export function SheetContent({ style, onScroll, ...p }) {
3
+ return (_jsx("div", { style: {
4
+ touchAction: "pan-down",
5
+ ...style,
6
+ }, onScroll: (ev) => {
7
+ if (ev.currentTarget.scrollTop > 0) {
8
+ ev.currentTarget.style.touchAction = "pan-y";
9
+ }
10
+ else {
11
+ ev.currentTarget.style.touchAction = "pan-down";
12
+ }
13
+ onScroll?.(ev);
14
+ }, ...p }));
4
15
  }
@@ -1,11 +1,10 @@
1
+ import { AnimationScope, MotionValue } from "framer-motion";
1
2
  import { Dispatch, SetStateAction } from "react";
2
- import { AnimationScope, DragControls, MotionValue } from "framer-motion";
3
3
  export type SheetContextT = {
4
4
  isOpen: boolean;
5
5
  setOpen: Dispatch<SetStateAction<boolean>>;
6
6
  closeHandler: () => void;
7
7
  scope?: AnimationScope<any>;
8
- controls?: DragControls;
9
8
  y?: MotionValue<number>;
10
9
  };
11
10
  export declare const SheetContext: import("react").Context<SheetContextT>;
@@ -1 +1 @@
1
- {"version":3,"file":"SheetContext.d.ts","sourceRoot":"","sources":["../../../src/components/Sheet/SheetContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,QAAQ,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE1E,MAAM,MAAM,aAAa,GAAG;IAC1B,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,QAAQ,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC;IAC3C,YAAY,EAAE,MAAM,IAAI,CAAC;IACzB,KAAK,CAAC,EAAE,cAAc,CAAC,GAAG,CAAC,CAAC;IAC5B,QAAQ,CAAC,EAAE,YAAY,CAAC;IACxB,CAAC,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;CACzB,CAAA;AAED,eAAO,MAAM,YAAY,wCAAoD,CAAC"}
1
+ {"version":3,"file":"SheetContext.d.ts","sourceRoot":"","sources":["../../../src/components/Sheet/SheetContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,EAAiB,QAAQ,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAEhE,MAAM,MAAM,aAAa,GAAG;IAC1B,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,QAAQ,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC;IAC3C,YAAY,EAAE,MAAM,IAAI,CAAC;IACzB,KAAK,CAAC,EAAE,cAAc,CAAC,GAAG,CAAC,CAAC;IAC5B,CAAC,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;CACzB,CAAA;AAED,eAAO,MAAM,YAAY,wCAAoD,CAAC"}
@@ -1,4 +1,4 @@
1
1
  import { HTMLAttributes } from "react";
2
2
  export type SheetHeaderPropsT = HTMLAttributes<HTMLDivElement>;
3
- export declare function SheetHeader({ onPointerDown, ...p }: SheetHeaderPropsT): import("react/jsx-runtime").JSX.Element;
3
+ export declare function SheetHeader({ ...p }: SheetHeaderPropsT): import("react/jsx-runtime").JSX.Element;
4
4
  //# sourceMappingURL=SheetHeader.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SheetHeader.d.ts","sourceRoot":"","sources":["../../../src/components/Sheet/SheetHeader.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAO,MAAM,OAAO,CAAC;AAI5C,MAAM,MAAM,iBAAiB,GAAG,cAAc,CAAC,cAAc,CAAC,CAAC;AAE/D,wBAAgB,WAAW,CAAC,EAAE,aAAa,EAAE,GAAG,CAAC,EAAE,EAAE,iBAAiB,2CAYrE"}
1
+ {"version":3,"file":"SheetHeader.d.ts","sourceRoot":"","sources":["../../../src/components/Sheet/SheetHeader.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAEvC,MAAM,MAAM,iBAAiB,GAAG,cAAc,CAAC,cAAc,CAAC,CAAC;AAE/D,wBAAgB,WAAW,CAAC,EAAE,GAAG,CAAC,EAAE,EAAE,iBAAiB,2CAEtD"}
@@ -1,11 +1,5 @@
1
1
  "use client";
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
- import { use } from "react";
4
- import { SheetContext } from "./SheetContext";
5
- export function SheetHeader({ onPointerDown, ...p }) {
6
- const { controls } = use(SheetContext);
7
- return (_jsx("div", { onPointerDown: (ev) => {
8
- controls?.start(ev);
9
- onPointerDown?.(ev);
10
- }, ...p }));
3
+ export function SheetHeader({ ...p }) {
4
+ return _jsx("div", { ...p });
11
5
  }
@@ -1 +1 @@
1
- {"version":3,"file":"SheetRoot.d.ts","sourceRoot":"","sources":["../../../src/components/Sheet/SheetRoot.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAuB,MAAM,OAAO,CAAC;AAS/D,MAAM,MAAM,eAAe,GAAG,iBAAiB,CAAC;AAEhD,wBAAgB,SAAS,CAAC,EAAE,QAAQ,EAAE,EAAE,eAAe,2CAyCtD"}
1
+ {"version":3,"file":"SheetRoot.d.ts","sourceRoot":"","sources":["../../../src/components/Sheet/SheetRoot.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,iBAAiB,EAAuB,MAAM,OAAO,CAAC;AAI/D,MAAM,MAAM,eAAe,GAAG,iBAAiB,CAAC;AAEhD,wBAAgB,SAAS,CAAC,EAAE,QAAQ,EAAE,EAAE,eAAe,2CA8CtD"}
@@ -1,13 +1,17 @@
1
1
  "use client";
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { usePathname } from "next/navigation";
4
+ import { useMotionValue, useAnimate } from "framer-motion";
3
5
  import { useEffect, useState } from "react";
4
- import { useDragControls, useMotionValue, useAnimate, } from "framer-motion";
5
6
  import { SheetContext } from "./SheetContext";
6
7
  export function SheetRoot({ children }) {
8
+ const pathname = usePathname();
7
9
  const y = useMotionValue(0);
8
- const controls = useDragControls();
9
10
  const [scope, animate] = useAnimate();
10
11
  const [isOpen, setOpen] = useState(false);
12
+ useEffect(() => {
13
+ setOpen(false);
14
+ }, [pathname]);
11
15
  useEffect(() => {
12
16
  const bodyElem = document.body;
13
17
  const removeOverflow = () => {
@@ -31,5 +35,5 @@ export function SheetRoot({ children }) {
31
35
  });
32
36
  setOpen(false);
33
37
  };
34
- return (_jsx(SheetContext, { value: { isOpen, setOpen, closeHandler, scope, controls, y }, children: children }));
38
+ return (_jsx(SheetContext, { value: { isOpen, setOpen, closeHandler, scope, y }, children: children }));
35
39
  }
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@kadoui/react",
3
- "version": "1.6.3",
3
+ "version": "1.6.5",
4
4
  "description": "Kadoui primitive components for React",
5
5
  "author": "ArrowUp",
6
6
  "license": "MIT",
7
7
  "type": "module",
8
8
  "scripts": {
9
9
  "build": "tsc",
10
- "push": "npm run build && npm publish"
10
+ "push": "npm run build && git push && npm publish"
11
11
  },
12
12
  "exports": {
13
13
  ".": "./dist/index.js",
@@ -42,4 +42,4 @@
42
42
  "@types/react-dom": "^19",
43
43
  "@types/qrcode": "^1.5.5"
44
44
  }
45
- }
45
+ }