automoby-kit 1.0.70 → 1.0.71
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/cjs/Drawer.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";var e=require("react/jsx-runtime"),t=require("react"),r=require("react-dom"),
|
|
1
|
+
"use client";"use strict";var e=require("react/jsx-runtime"),t=require("react"),r=require("react-dom"),n=require("./utils.js"),l=require("./contexts.js");const o=t.forwardRef(({children:o,direction:a="bottom",fullScreen:u=!1,isOpen:s=!1,onClose:i,className:d,isMobile:c,keepMounted:f,zIndex:b,...m},h)=>{const[w,x]=t.useState(!1),p=l.useMobile(),y=c??p,v=t.useRef(null),g=t.useRef(null);t.useEffect(()=>{x(!0)},[]),t.useEffect(()=>{const handleEscape=e=>{"Escape"===e.key&&s&&i&&i()};return s&&(document.addEventListener("keydown",handleEscape),document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",handleEscape),document.body.style.overflow="auto"}},[s,i]);const k=n("fixed inset-0 transition-all duration-300",`z-[${b??"10000000001"}]`),E=n(k,{"bg-neutral-darker/50 backdrop-blur-sm":s,"bg-transparent pointer-events-none":!s,"hidden invisible absolute inset-0":f&&!w}),j=n("fixed bg-white shadow-2xl transition-all duration-300 ease-out overflow-auto",(()=>{switch(a){case"top":return"top-0 left-0 right-0";case"bottom":default:return"bottom-0 left-0 right-0";case"left":return"top-0 left-0 bottom-0";case"right":return"top-0 right-0 bottom-0"}})(),(()=>{const e="top"===a||"bottom"===a;return u?"w-full h-full":e?"w-full max-h-[90vh]":"h-full max-w-[90vw]"})(),(()=>{if(!s)switch(a){case"top":return"-translate-y-full";case"bottom":default:return"translate-y-full";case"left":return"-translate-x-full";case"right":return"translate-x-full"}return"translate-x-0 translate-y-0"})(),{"rounded-t-2xl":"bottom"===a&&!u,"rounded-b-2xl":"top"===a&&!u,"rounded-r-2xl":"left"===a&&!u,"rounded-l-2xl":"right"===a&&!u,"p-6":!y,"p-4":y},d),q=e.jsx("div",{ref:v,className:E,onClick:e=>{!u&&i&&v.current&&e.target===v.current&&i()},onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||!u&&i&&v.current&&e.target===v.current&&i()},tabIndex:-1,role:"button","aria-label":"Close drawer","aria-hidden":!s,children:e.jsx("div",{ref:h||g,className:j,role:"dialog","aria-modal":"true","aria-label":"Drawer",...m,children:o})});return f||w?f&&!w?q:s?r.createPortal(q,document.body):null:null});o.displayName="Drawer",exports.Drawer=o;
|
package/dist/esm/Drawer.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as
|
|
1
|
+
"use client";import{jsx as e}from"react/jsx-runtime";import t,{useState as r,useRef as o,useEffect as n}from"react";import{createPortal as l}from"react-dom";import a from"./utils.js";import{useMobile as i}from"./contexts.js";const s=t.forwardRef(({children:t,direction:s="bottom",fullScreen:u=!1,isOpen:d=!1,onClose:c,className:m,isMobile:f,keepMounted:b,zIndex:p,...h},w)=>{const[x,y]=r(!1),g=i(),v=f??g,k=o(null),E=o(null);n(()=>{y(!0)},[]),n(()=>{const handleEscape=e=>{"Escape"===e.key&&d&&c&&c()};return d&&(document.addEventListener("keydown",handleEscape),document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",handleEscape),document.body.style.overflow="auto"}},[d,c]);const N=a("fixed inset-0 transition-all duration-300",`z-[${p??"10000000001"}]`),j=a(N,{"bg-neutral-darker/50 backdrop-blur-sm":d,"bg-transparent pointer-events-none":!d,"hidden invisible absolute inset-0":b&&!x}),C=a("fixed bg-white shadow-2xl transition-all duration-300 ease-out overflow-auto",(()=>{switch(s){case"top":return"top-0 left-0 right-0";case"bottom":default:return"bottom-0 left-0 right-0";case"left":return"top-0 left-0 bottom-0";case"right":return"top-0 right-0 bottom-0"}})(),(()=>{const e="top"===s||"bottom"===s;return u?"w-full h-full":e?"w-full max-h-[90vh]":"h-full max-w-[90vw]"})(),(()=>{if(!d)switch(s){case"top":return"-translate-y-full";case"bottom":default:return"translate-y-full";case"left":return"-translate-x-full";case"right":return"translate-x-full"}return"translate-x-0 translate-y-0"})(),{"rounded-t-2xl":"bottom"===s&&!u,"rounded-b-2xl":"top"===s&&!u,"rounded-r-2xl":"left"===s&&!u,"rounded-l-2xl":"right"===s&&!u,"p-6":!v,"p-4":v},m),D=e("div",{ref:k,className:j,onClick:e=>{!u&&c&&k.current&&e.target===k.current&&c()},onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||!u&&c&&k.current&&e.target===k.current&&c()},tabIndex:-1,role:"button","aria-label":"Close drawer","aria-hidden":!d,children:e("div",{ref:w||E,className:C,role:"dialog","aria-modal":"true","aria-label":"Drawer",...h,children:t})});return b||x?b&&!x?D:d?l(D,document.body):null:null});s.displayName="Drawer";export{s as Drawer};
|
package/dist/types/Drawer.js
CHANGED
|
@@ -4,7 +4,7 @@ import { createPortal } from 'react-dom';
|
|
|
4
4
|
import cn from './utils.js';
|
|
5
5
|
import { useMobile } from './contexts.js';
|
|
6
6
|
|
|
7
|
-
const Drawer = React.forwardRef(({ children, direction = 'bottom', fullScreen = false, isOpen = false, onClose, className, isMobile, keepMounted, ...props }, ref) => {
|
|
7
|
+
const Drawer = React.forwardRef(({ children, direction = 'bottom', fullScreen = false, isOpen = false, onClose, className, isMobile, keepMounted, zIndex, ...props }, ref) => {
|
|
8
8
|
const [isClient, setIsClient] = useState(false);
|
|
9
9
|
const detectedIsMobile = useMobile();
|
|
10
10
|
const actualIsMobile = isMobile ?? detectedIsMobile;
|
|
@@ -91,7 +91,10 @@ const Drawer = React.forwardRef(({ children, direction = 'bottom', fullScreen =
|
|
|
91
91
|
}
|
|
92
92
|
return 'h-full max-w-[90vw]';
|
|
93
93
|
};
|
|
94
|
-
const
|
|
94
|
+
const defaultZIndex = '10000000001';
|
|
95
|
+
const zIndexValue = zIndex ?? defaultZIndex;
|
|
96
|
+
const zIndexClass = `z-[${zIndexValue}]`;
|
|
97
|
+
const baseOverlayClasses = cn('fixed inset-0 transition-all duration-300', zIndexClass);
|
|
95
98
|
const baseDrawerClasses = 'fixed bg-white shadow-2xl transition-all duration-300 ease-out overflow-auto';
|
|
96
99
|
const overlayClasses = cn(baseOverlayClasses, {
|
|
97
100
|
'bg-neutral-darker/50 backdrop-blur-sm': isOpen,
|
|
@@ -16,6 +16,10 @@ export type DrawerProps = {
|
|
|
16
16
|
* This allows SSR rendering but keeps it visually hidden until opened.
|
|
17
17
|
*/
|
|
18
18
|
keepMounted?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Custom z-index value for the overlay. Defaults to 10000000001.
|
|
21
|
+
*/
|
|
22
|
+
zIndex?: number | string;
|
|
19
23
|
};
|
|
20
24
|
declare const Drawer: React.ForwardRefExoticComponent<DrawerProps & React.RefAttributes<HTMLDivElement>>;
|
|
21
25
|
export { Drawer };
|