automoby-kit 1.0.45 → 1.0.46
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 +1 -1
- package/dist/esm/Drawer.js +1 -1
- package/dist/types/Drawer.js +3 -2
- package/package.json +1 -1
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"),o=require("./contexts.js");const l=t.forwardRef(({children:l,direction:a="bottom",fullScreen:s=!1,isOpen:u=!1,onClose:i,className:d,isMobile:c,keepMounted:f,...b},m)=>{const[h,w]=t.useState(!1),x=o.useMobile(),p=c??x,y=t.useRef(null),v=t.useRef(null);t.useEffect(()=>{w(!0)},[]),t.useEffect(()=>{const handleEscape=e=>{"Escape"===e.key&&u&&i&&i()};return u&&(document.addEventListener("keydown",handleEscape),document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",handleEscape),document.body.style.overflow="auto"}},[u,i]);const g=n("fixed inset-0 z-[1000] transition-all duration-300",{"bg-neutral-darker/50 backdrop-blur-sm":u,"bg-transparent pointer-events-none":!u,"hidden invisible absolute inset-0":f&&!h}),k=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 s?"w-full h-full":e?"w-full max-h-[90vh]":"h-full max-w-[90vw]"})(),(()=>{if(!u)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&&!s,"rounded-b-2xl":"top"===a&&!s,"rounded-r-2xl":"left"===a&&!s,"rounded-l-2xl":"right"===a&&!s,"p-6":!p,"p-4":p},d),E=e.jsx("div",{ref:y,className:g,onClick:e=>{!s&&i&&y.current&&e.target===y.current&&i()},onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||!s&&i&&y.current&&e.target===y.current&&i()},tabIndex:-1,role:"button","aria-label":"Close drawer","aria-hidden":!u,children:e.jsx("div",{ref:m||v,className:k,role:"dialog","aria-modal":"true","aria-label":"Drawer",...b,children:l})});return f||h?f&&!h?E:r.createPortal(E,document.body):null});l.displayName="Drawer",exports.Drawer=l;
|
package/dist/esm/Drawer.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as t}from"react/jsx-runtime";import e,{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
|
|
1
|
+
"use client";import{jsx as t}from"react/jsx-runtime";import e,{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=e.forwardRef(({children:e,direction:s="bottom",fullScreen:u=!1,isOpen:d=!1,onClose:c,className:m,isMobile:f,keepMounted:b,...p},h)=>{const[w,x]=r(!1),y=i(),g=f??y,v=o(null),k=o(null);n(()=>{x(!0)},[]),n(()=>{const handleEscape=t=>{"Escape"===t.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 E=a("fixed inset-0 z-[1000] transition-all duration-300",{"bg-neutral-darker/50 backdrop-blur-sm":d,"bg-transparent pointer-events-none":!d,"hidden invisible absolute inset-0":b&&!w}),N=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 t="top"===s||"bottom"===s;return u?"w-full h-full":t?"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":!g,"p-4":g},m),j=t("div",{ref:v,className:E,onClick:t=>{!u&&c&&v.current&&t.target===v.current&&c()},onKeyDown:t=>{"Enter"!==t.key&&" "!==t.key||!u&&c&&v.current&&t.target===v.current&&c()},tabIndex:-1,role:"button","aria-label":"Close drawer","aria-hidden":!d,children:t("div",{ref:h||k,className:N,role:"dialog","aria-modal":"true","aria-label":"Drawer",...p,children:e})});return b||w?b&&!w?j:l(j,document.body):null});s.displayName="Drawer";export{s as Drawer};
|
package/dist/types/Drawer.js
CHANGED
|
@@ -96,6 +96,7 @@ const Drawer = React.forwardRef(({ children, direction = 'bottom', fullScreen =
|
|
|
96
96
|
const overlayClasses = cn(baseOverlayClasses, {
|
|
97
97
|
'bg-neutral-darker/50 backdrop-blur-sm': isOpen,
|
|
98
98
|
'bg-transparent pointer-events-none': !isOpen,
|
|
99
|
+
'hidden invisible absolute inset-0': keepMounted && !isClient,
|
|
99
100
|
});
|
|
100
101
|
const drawerClasses = cn(baseDrawerClasses, getPositionClasses(), getSizeClasses(), getTranslateClasses(), {
|
|
101
102
|
'rounded-t-2xl': direction === 'bottom' && !fullScreen,
|
|
@@ -107,12 +108,12 @@ const Drawer = React.forwardRef(({ children, direction = 'bottom', fullScreen =
|
|
|
107
108
|
}, className);
|
|
108
109
|
const content = (jsx("div", { ref: overlayRef, className: overlayClasses, onClick: handleOverlayClick, onKeyDown: handleOverlayKeyDown, tabIndex: -1, role: "button", "aria-label": "Close drawer", "aria-hidden": !isOpen, children: jsx("div", { ref: ref || drawerRef, className: drawerClasses, role: "dialog", "aria-modal": "true", "aria-label": "Drawer", ...props, children: children }) }));
|
|
109
110
|
// If not open and not requested to keep mounted, render nothing
|
|
110
|
-
if (!
|
|
111
|
+
if (!keepMounted && !isClient) {
|
|
111
112
|
return null;
|
|
112
113
|
}
|
|
113
114
|
// During SSR or before client mounts, we cannot portal.
|
|
114
115
|
// If keepMounted is true, render the content inline (hidden when closed).
|
|
115
|
-
if (!isClient) {
|
|
116
|
+
if (keepMounted && !isClient) {
|
|
116
117
|
return content;
|
|
117
118
|
}
|
|
118
119
|
// On the client, render into body using a portal.
|