@liberfi.io/ui-scaffold 0.1.36 → 0.1.37
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/index.d.mts +9 -7
- package/dist/index.d.ts +9 -7
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +8 -8
package/dist/index.d.mts
CHANGED
|
@@ -323,12 +323,12 @@ type RenderAsyncModalProps<P = any, R = any> = {
|
|
|
323
323
|
params?: P;
|
|
324
324
|
/** whether the modal is open */
|
|
325
325
|
isOpen: boolean;
|
|
326
|
-
/** close the modal */
|
|
326
|
+
/** close the modal without a result (resolves Promise with undefined) */
|
|
327
327
|
onClose: () => void;
|
|
328
328
|
/** change the open state of the modal */
|
|
329
329
|
onOpenChange: (isOpen: boolean) => void;
|
|
330
|
-
/**
|
|
331
|
-
onResult
|
|
330
|
+
/** submit a result and auto-close the modal */
|
|
331
|
+
onResult: (result: R) => void;
|
|
332
332
|
};
|
|
333
333
|
type AsyncModalProps<P = any, R = any> = {
|
|
334
334
|
/** unique identifier for the modal */
|
|
@@ -339,13 +339,15 @@ type AsyncModalProps<P = any, R = any> = {
|
|
|
339
339
|
type OpenAsyncModalOptions<P = any, R = any> = {
|
|
340
340
|
/** custom parameters for the modal */
|
|
341
341
|
params?: P;
|
|
342
|
-
/** callback when the modal
|
|
343
|
-
onResult?: (result: R) => void;
|
|
342
|
+
/** callback when the modal resolves (result value, or undefined on dismiss) */
|
|
343
|
+
onResult?: (result: R | undefined) => void;
|
|
344
344
|
};
|
|
345
345
|
declare function AsyncModal<P = any, R = any>({ id, children, }: AsyncModalProps<P, R>): ReactNode;
|
|
346
346
|
|
|
347
347
|
type UseAsyncModalReturnType<P = any, R = any> = {
|
|
348
|
-
|
|
348
|
+
/** Open the modal. Returns a Promise that resolves with the result, or undefined on dismiss. */
|
|
349
|
+
onOpen: (options?: OpenAsyncModalOptions<P, R>) => Promise<R | undefined>;
|
|
350
|
+
/** Close the modal from outside (triggers dismiss). */
|
|
349
351
|
onClose: () => void;
|
|
350
352
|
};
|
|
351
353
|
declare function useAsyncModal<P = any, R = any>(id: string): UseAsyncModalReturnType<P, R>;
|
|
@@ -398,6 +400,6 @@ declare global {
|
|
|
398
400
|
};
|
|
399
401
|
}
|
|
400
402
|
}
|
|
401
|
-
declare const _default: "0.1.
|
|
403
|
+
declare const _default: "0.1.37";
|
|
402
404
|
|
|
403
405
|
export { ALL_BREAKPOINTS, AsyncModal, type AsyncModalProps, type DraggableContentProps, DraggableModal, type DraggableModalProps, DraggablePanel, type DraggablePanelProps, DraggablePanelProvider, type DraggablePanelProviderProps, type LayoutBreakpoint, Logo, type LogoProps, type NavItem, NavLink, type NavLinkProps, type OpenAsyncModalOptions, type OpenDraggableModalOptions, type OpenDraggablePanelOptions, type RenderAsyncModalProps, Scaffold, ScaffoldContext, type ScaffoldContextValue, ScaffoldFooter, type ScaffoldFooterProps, ScaffoldHeader, type ScaffoldHeaderProps, type ScaffoldProps, ScaffoldToolbar, type ScaffoldToolbarProps, SplitHandle, type SplitHandleProps, SplitView, type SplitViewProps, type UseAsyncModalReturnType, type UseDraggableDisclosureReturnType, type UseDraggableModalDisclosureReturnType, type UseDraggablePanelDisclosureReturnType, getVisibilityClass, isNavItemActive, useAsyncModal, useDraggableDisclosure, useDraggableModalDisclosure, useDraggablePanelDisclosure, useScaffold, useScaffoldLayout, _default as version };
|
package/dist/index.d.ts
CHANGED
|
@@ -323,12 +323,12 @@ type RenderAsyncModalProps<P = any, R = any> = {
|
|
|
323
323
|
params?: P;
|
|
324
324
|
/** whether the modal is open */
|
|
325
325
|
isOpen: boolean;
|
|
326
|
-
/** close the modal */
|
|
326
|
+
/** close the modal without a result (resolves Promise with undefined) */
|
|
327
327
|
onClose: () => void;
|
|
328
328
|
/** change the open state of the modal */
|
|
329
329
|
onOpenChange: (isOpen: boolean) => void;
|
|
330
|
-
/**
|
|
331
|
-
onResult
|
|
330
|
+
/** submit a result and auto-close the modal */
|
|
331
|
+
onResult: (result: R) => void;
|
|
332
332
|
};
|
|
333
333
|
type AsyncModalProps<P = any, R = any> = {
|
|
334
334
|
/** unique identifier for the modal */
|
|
@@ -339,13 +339,15 @@ type AsyncModalProps<P = any, R = any> = {
|
|
|
339
339
|
type OpenAsyncModalOptions<P = any, R = any> = {
|
|
340
340
|
/** custom parameters for the modal */
|
|
341
341
|
params?: P;
|
|
342
|
-
/** callback when the modal
|
|
343
|
-
onResult?: (result: R) => void;
|
|
342
|
+
/** callback when the modal resolves (result value, or undefined on dismiss) */
|
|
343
|
+
onResult?: (result: R | undefined) => void;
|
|
344
344
|
};
|
|
345
345
|
declare function AsyncModal<P = any, R = any>({ id, children, }: AsyncModalProps<P, R>): ReactNode;
|
|
346
346
|
|
|
347
347
|
type UseAsyncModalReturnType<P = any, R = any> = {
|
|
348
|
-
|
|
348
|
+
/** Open the modal. Returns a Promise that resolves with the result, or undefined on dismiss. */
|
|
349
|
+
onOpen: (options?: OpenAsyncModalOptions<P, R>) => Promise<R | undefined>;
|
|
350
|
+
/** Close the modal from outside (triggers dismiss). */
|
|
349
351
|
onClose: () => void;
|
|
350
352
|
};
|
|
351
353
|
declare function useAsyncModal<P = any, R = any>(id: string): UseAsyncModalReturnType<P, R>;
|
|
@@ -398,6 +400,6 @@ declare global {
|
|
|
398
400
|
};
|
|
399
401
|
}
|
|
400
402
|
}
|
|
401
|
-
declare const _default: "0.1.
|
|
403
|
+
declare const _default: "0.1.37";
|
|
402
404
|
|
|
403
405
|
export { ALL_BREAKPOINTS, AsyncModal, type AsyncModalProps, type DraggableContentProps, DraggableModal, type DraggableModalProps, DraggablePanel, type DraggablePanelProps, DraggablePanelProvider, type DraggablePanelProviderProps, type LayoutBreakpoint, Logo, type LogoProps, type NavItem, NavLink, type NavLinkProps, type OpenAsyncModalOptions, type OpenDraggableModalOptions, type OpenDraggablePanelOptions, type RenderAsyncModalProps, Scaffold, ScaffoldContext, type ScaffoldContextValue, ScaffoldFooter, type ScaffoldFooterProps, ScaffoldHeader, type ScaffoldHeaderProps, type ScaffoldProps, ScaffoldToolbar, type ScaffoldToolbarProps, SplitHandle, type SplitHandleProps, SplitView, type SplitViewProps, type UseAsyncModalReturnType, type UseDraggableDisclosureReturnType, type UseDraggableModalDisclosureReturnType, type UseDraggablePanelDisclosureReturnType, getVisibilityClass, isNavItemActive, useAsyncModal, useDraggableDisclosure, useDraggableModalDisclosure, useDraggablePanelDisclosure, useScaffold, useScaffoldLayout, _default as version };
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var react=require('react'),reactDom=require('react-dom'),jotai=require('jotai'),hooks=require('@liberfi.io/hooks'),i18n=require('@liberfi.io/i18n'),ui=require('@liberfi.io/ui'),utils$1=require('@liberfi.io/utils'),jotaiFamily=require('jotai-family'),utils=require('jotai/utils'),jsxRuntime=require('react/jsx-runtime');var ge=jotaiFamily.atomFamily(e=>utils.atomWithStorage(`panelState.${e??"default"}`,"none",void 0,{getOnInit:true})),_e=jotaiFamily.atomFamily(e=>utils.atomWithStorage(`panelWidth.${e??"default"}`,350,void 0,{getOnInit:true})),Xe=jotaiFamily.atomFamily(e=>utils.atomWithStorage(`panelMinWidth.${e??"default"}`,320,void 0,{getOnInit:true})),Ye=jotaiFamily.atomFamily(e=>utils.atomWithStorage(`panelMaxWidth.${e??"default"}`,440,void 0,{getOnInit:true})),kt=jotaiFamily.atomFamily(e=>utils.atomWithStorage(`modalOpen.${e??"default"}`,false,void 0,{getOnInit:true})),Ue=jotaiFamily.atomFamily(e=>utils.atomWithStorage(`modalShouldStartDragging.${e??"default"}`,false,void 0,{getOnInit:true})),Ze=jotaiFamily.atomFamily(e=>utils.atomWithStorage(`modalSize.${e??"default"}`,{width:350,height:580},void 0,{getOnInit:true})),je=jotaiFamily.atomFamily(e=>utils.atomWithStorage(`modalRestoreSize.${e??"default"}`,{width:350,height:580},void 0,{getOnInit:true})),Ge=jotaiFamily.atomFamily(e=>utils.atomWithStorage(`modalPosition.${e??"default"}`,{x:typeof window<"u"?Math.max(0,(window.innerWidth-350)/2):0,y:typeof window<"u"?Math.max(0,(window.innerHeight-580)/2):0},void 0,{getOnInit:true})),Ke=jotaiFamily.atomFamily(e=>utils.atomWithStorage(`modalRestorePosition.${e??"default"}`,{x:typeof window<"u"?Math.max(0,(window.innerWidth-350)/2):0,y:typeof window<"u"?Math.max(0,(window.innerHeight-580)/2):0},void 0,{getOnInit:true})),Je=jotaiFamily.atomFamily(e=>utils.atomWithStorage(`modalMinimized.${e??"default"}`,false,void 0,{getOnInit:true})),qe=jotaiFamily.atomFamily(e=>utils.atomWithStorage(`modalMinWidth.${e??"default"}`,200,void 0,{getOnInit:true})),Qe=jotaiFamily.atomFamily(e=>utils.atomWithStorage(`modalMaxWidth.${e??"default"}`,typeof window<"u"?window.innerWidth-40:0,void 0,{getOnInit:true})),ve=jotaiFamily.atomFamily(e=>utils.atomWithStorage(`lastPanelType.${e??"default"}`,"modal",void 0,{getOnInit:true})),et=utils.atomWithStorage("panelOrders",{left:{},right:{}},void 0,{getOnInit:true});function we(e){let[t,n]=jotai.useAtom(kt(e)),[a,r]=jotai.useAtom(Je(e)),l=jotai.useAtomValue(je(e)),c=jotai.useAtomValue(Ke(e)),o=jotai.useSetAtom(Ze(e)),i=jotai.useSetAtom(Ge(e)),g=jotai.useSetAtom(Ue(e)),p=jotai.useSetAtom(ve(e)),u=react.useCallback((x={})=>{let{shouldStartDragging:E,position:H,size:y}=x;H&&i(k=>({...k,...H})),y&&o(k=>({...k,...y})),g(E??false),n(true),p("modal");},[n,i,o,g]),b=react.useCallback(()=>{n(false),a&&(o({...l}),i({...c}),r(false));},[a,l,c,r,n,o,i]);return react.useMemo(()=>({isOpen:t,onOpen:u,onClose:b}),[t,u,b])}function Me(e){let[t,n]=jotai.useAtom(ge(e)),a=jotai.useSetAtom(_e(e)),r=jotai.useSetAtom(ve(e)),l=jotai.useSetAtom(et),c=react.useCallback((p={})=>{let u=p.position??"left";a(p.width??320),n(u),r(u),l(({left:b,right:x})=>u==="left"?{left:{...b,[e]:Date.now()},right:x}:{left:b,right:{...x,[e]:Date.now()}});},[e,n,a]),o=react.useCallback(()=>{n("none");},[n]),i=react.useMemo(()=>t!=="none",[t]),g=react.useMemo(()=>t!=="none"?t:void 0,[t]);return react.useMemo(()=>({isOpen:i,position:g,onOpen:c,onClose:o}),[i,c,o])}var Vo={width:200,height:48},Ce={width:typeof window<"u"?window.innerWidth-40:0,height:typeof window<"u"?window.innerHeight-40:0},Fo={x:20,y:20},Ht=react.memo(function({id:t,title:n,minWidth:a=504,maxWidth:r=Ce.width,minHeight:l=200,maxHeight:c=Ce.height,leftSidebar:o,leftSidebarWidth:i=200,rightSidebar:g,rightSidebarWidth:p=200,aspectRatio:u,showHeader:b=true,header:x,headerHeight:E=44,children:H}){let{t:y}=i18n.useTranslation(),{isOpen:k,onClose:_}=we(t),{onOpen:ee}=Me(t),[M,L]=jotai.useAtom(Je(t)),[h,ce]=jotai.useAtom(Ge(t)),[d,De]=jotai.useAtom(Ze(t)),[te,oe]=jotai.useAtom(je(t)),[X,j]=jotai.useAtom(Ke(t)),[ne,re]=jotai.useAtom(Ue(t)),[R,ie]=react.useState(ne),[ue,v]=react.useState(false),[P,ae]=react.useState(null),[me,se]=react.useState(null),[fe,A]=react.useState(null),[xe,le]=react.useState(null),G=react.useRef(null),ao=jotai.useAtomValue(Xe(t)),so=jotai.useAtomValue(Ye(t)),K=hooks.useValueRef(h),S=hooks.useCallbackRef(ce),pe=hooks.useValueRef(d),F=hooks.useCallbackRef(De),lo=hooks.useValueRef(i),co=hooks.useValueRef(!!o),uo=hooks.useValueRef(p),mo=hooks.useValueRef(!!g),U=hooks.useValueRef(u),J=hooks.useValueRef(E),Oe=hooks.useValueRef(a),We=hooks.useValueRef(r),Ee=hooks.useValueRef(l),ke=hooks.useValueRef(c),fo=hooks.useValueRef(R),Nt=hooks.useValueRef(me),st=hooks.useValueRef(xe),po=hooks.useCallbackRef(_),ho=hooks.useCallbackRef(ee),go=hooks.useValueRef(ao),bo=hooks.useValueRef(so),Le=react.useMemo(()=>d.width===Ce.width&&d.height===Ce.height,[d.width,d.height]);react.useEffect(()=>{let s=Math.min(Math.max(d.width,a),r),D=Math.min(Math.max(d.height,l),c);(s!==d.width||D!==d.height)&&F({width:s,height:D});let T=Math.max(0,h.x),he=Math.max(0,h.y);T+s>window.innerWidth&&(T=Math.max(0,window.innerWidth-s)),he+D>window.innerHeight&&(he=Math.max(0,window.innerHeight-D)),(T!==h.x||he!==h.y)&&S({x:T,y:he});},[t]),react.useEffect(()=>{if(k&&ne){ie(true);let s=T=>{S({x:T.clientX-d.width/2,y:T.clientY-20});},D=()=>{ie(false),re(false),document.removeEventListener("mousemove",s),document.removeEventListener("mouseup",D);};return document.addEventListener("mousemove",s),document.addEventListener("mouseup",D),document.body.style.cursor="grabbing",()=>{document.removeEventListener("mousemove",s),document.removeEventListener("mouseup",D),document.body.style.cursor="";}}},[k,ne,re,d.width]);let Z=(s,D,T)=>{re(false),ie(false),v(false),ae(null),D==="drag"?ie(true):D==="resize"&&(ae(T||null),v(true));let he=s.clientX,Pt=s.clientY,$=pe.current.width,Y=pe.current.height,B={...K.current},St=()=>{document.removeEventListener("mousemove",Dt),document.removeEventListener("mouseup",Ot),document.body.style.cursor="",ie(false),v(false),ae(null),se(null),G.current&&(clearTimeout(G.current),G.current=null),le(null),A(null);},Dt=$e=>{if(D==="drag"){let q=$e.clientX-he,Q=$e.clientY-Pt,z=B.x+q,f=B.y+Q,ye=co.current?lo.current:0,Ie=12+ye,I=mo.current?uo.current:0,N=window.innerWidth-12-$-I,Be=window.innerHeight-12-44,O=z<=Ie?"left":z>=N?"right":null;O!==Nt.current&&se(O),G.current&&O&&A(O),G.current&&(st.current==="left"&&(z>Ie||O!=="left")||st.current==="right"&&(z<N||O!=="right"))&&(clearTimeout(G.current),G.current=null,le(null),A(null)),!G.current&&O&&st.current!==O&&(le(O),A(O),G.current=setTimeout(()=>{fo.current&&Nt.current===O?(St(),po(),ho({position:O,width:Math.min(Math.max(pe.current.width,go.current),bo.current)})):le(null);},350)),z=Math.min(Math.max(z,12+ye),N),f=Math.min(Math.max(f,12),Be),S({x:z,y:f});}else if(D==="resize"&&T){let q=$e.clientX-he,Q=$e.clientY-Pt,z=(f,ye,Ie)=>{let I=Math.min(Math.max(f,Oe.current),We.current),N=Math.min(Math.max(ye,Ee.current),ke.current);if(U.current){if(Ie==="width")N=Math.min(Math.max(f/U.current+J.current,Ee.current),ke.current),I=(N-J.current)*U.current;else if(Ie==="height")I=Math.min(Math.max((ye-J.current)*U.current,Oe.current),We.current),N=I/U.current+J.current;else {let Be=f/U.current+J.current,O=(ye-J.current)*U.current,Wt=Math.abs(q),Et=Math.abs(Q);if(Wt>1.1*Et)N=Math.min(Math.max(Be,Ee.current),ke.current),I=(N-J.current)*U.current;else if(Et>1.1*Wt)I=Math.min(Math.max(O,Oe.current),We.current),N=I/U.current+J.current;else {let vo=(N+Be)/2;I=Math.min(Math.max((I+O)/2,Oe.current),We.current),N=Math.min(Math.max(vo,Ee.current),ke.current),I=(N-J.current)*U.current;}}I=Math.min(Math.max(I,Oe.current),We.current),N=Math.min(Math.max(N,Ee.current),ke.current);}return {width:I,height:N}};switch(T){case "topLeft":{let f=z($-q,Y-Q,"both");F(f),S({x:B.x+($-f.width),y:B.y+(Y-f.height)});break}case "topRight":{let f=z($+q,Y-Q,"both");F(f),S({x:B.x,y:B.y+(Y-f.height)});break}case "bottomLeft":{let f=z($-q,Y+Q,"both");F(f),S({x:B.x+($-f.width),y:B.y});break}case "bottomRight":{F(z($+q,Y+Q,"both"));break}case "top":{let f=z($,Y-Q,"height");F(f),S({x:B.x,y:B.y+(Y-f.height)});break}case "bottom":{F(z($,Y+Q,"height"));break}case "left":{let f=z($-q,Y,"width");F(f),S({x:B.x+($-f.width),y:B.y});break}case "right":{F(z($+q,Y,"width"));break}}}},Ot=()=>{(h.x<0||h.y<0)&&S({x:Math.max(0,h.x),y:Math.max(0,h.y)}),St();};document.addEventListener("mousemove",Dt),document.addEventListener("mouseup",Ot);},xo=react.useCallback(()=>{M?(F({...te}),S({...X}),L(false)):(Le?S({...X}):(oe({...d}),j({...h})),F({...Vo}),L(true));},[M,Le,d,h,te,X,L,oe,j]),yo=react.useCallback(()=>{Le?(F({...te}),S({...X})):(M?L(false):(oe({...d}),j({...h})),F({...Ce}),S({...Fo}));},[Le,M,d,h,te,X,L,oe,j]);return react.useEffect(()=>{let s=utils$1.throttle(()=>{(K.current.x<0||K.current.y<0)&&S({x:Math.max(0,K.current.x),y:Math.max(0,K.current.y)});let D=K.current.x+pe.current.width,T=K.current.y+pe.current.height;(D>window.innerWidth||T>window.innerHeight)&&S({x:Math.min(K.current.x,Math.max(0,window.innerWidth-pe.current.width)),y:Math.min(K.current.y,Math.max(0,window.innerHeight-pe.current.height))});},100);return window.addEventListener("resize",s),()=>{window.removeEventListener("resize",s);}},[]),k?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[(R||ue)&&reactDom.createPortal(jsxRuntime.jsx("div",{className:ui.cn("max-sm:hidden fixed inset-0 z-9999 bg-transparent w-full h-full select-none",R&&(xe?"cursor-grabbing":"cursor-move"),!R&&{"cursor-ns-resize":P==="top"||P==="bottom","cursor-ew-resize":P==="left"||P==="right","cursor-nwse-resize":P==="topLeft"||P==="bottomRight","cursor-nesw-resize":P==="topRight"||P==="bottomLeft","cursor-auto":P===null})}),document.body),jsxRuntime.jsx("div",{className:ui.cn("max-sm:hidden fixed z-50 left-0 top-0",R?"will-change-transform":"will-change-auto",ue||R?"transition-none":"transition-transform duration-250 ease-[cubic-bezier(0.16,1,0.3,1)]"),style:{transform:`translate(${Math.round(h.x-(o?i:0))}px, ${Math.round(h.y)}px)`},children:jsxRuntime.jsxs("div",{className:"flex relative z-50",children:[o&&jsxRuntime.jsx("div",{className:ui.cn("relative mt-1 z-10 transition-all duration-250 ease-[cubic-bezier(0.16,1,0.3,1)]",R?"opacity-40 translate-x-4":"opacity-100 translate-x-0"),style:{width:i,height:M?40:d.height-8},children:o}),jsxRuntime.jsx("div",{className:ui.cn("z-50 relative bg-content1 border border-border rounded-lg overflow-hidden",R?"opacity-80 shadow-md scale-102 blur-[0.5px]":"opacity-100 shadow-lg scale-100 blur-none"),style:{width:d.width,height:d.height,transition:ue||R?"none":"transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s cubic-bezier(0.33, 1, 0.68, 1), height 0.25s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s cubic-bezier(0.33, 1, 0.68, 1)",contain:"content"},children:jsxRuntime.jsxs("div",{className:ui.cn("w-full h-full",fe&&"animate-modal-shrink",fe==="left"?"origin-left":"origin-right"),style:{contain:"paint"},children:[!M&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"absolute top-0 left-0 w-3 h-3 cursor-nw-resize z-20",onMouseDown:s=>Z(s,"resize","topLeft")}),jsxRuntime.jsx("div",{className:"absolute top-0 right-0 w-3 h-3 cursor-ne-resize z-20",onMouseDown:s=>Z(s,"resize","topRight")}),jsxRuntime.jsx("div",{className:"absolute bottom-0 left-0 w-3 h-3 cursor-sw-resize z-20",onMouseDown:s=>Z(s,"resize","bottomLeft")}),jsxRuntime.jsx("div",{className:"absolute bottom-0 right-0 w-3 h-3 cursor-se-resize z-20",onMouseDown:s=>Z(s,"resize","bottomRight")}),jsxRuntime.jsx("div",{className:"absolute top-0 left-3 right-3 h-1.5 cursor-n-resize z-20",onMouseDown:s=>Z(s,"resize","top")}),jsxRuntime.jsx("div",{className:"absolute bottom-0 left-3 right-3 h-1.5 cursor-s-resize z-20",onMouseDown:s=>Z(s,"resize","bottom")}),jsxRuntime.jsx("div",{className:"absolute left-0 top-3 bottom-3 w-1.5 cursor-w-resize z-20",onMouseDown:s=>Z(s,"resize","left")}),jsxRuntime.jsx("div",{className:"absolute right-0 top-3 bottom-3 w-1.5 cursor-e-resize z-20",onMouseDown:s=>Z(s,"resize","right")})]}),b&&jsxRuntime.jsxs("div",{className:"relative border-b border-border/80 px-3 gap-4 flex items-center justify-between cursor-move select-none",onMouseDown:s=>Z(s,"drag"),style:{height:E},children:[jsxRuntime.jsx(ui.StyledTooltip,{placement:"top",closeDelay:0,content:y("scaffold.draggableModal.snapToEdge"),children:jsxRuntime.jsx(ui.DraggableIcon,{className:"text-neutral absolute left-1/2 -translate-x-1/2 top-0"})}),x||jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"min-w-0 flex-initial text-sm font-medium truncate cursor-auto",onMouseDown:s=>s.stopPropagation(),children:n}),jsxRuntime.jsxs("div",{className:"flex-none flex items-center justify-end gap-1",onMouseDown:s=>s.stopPropagation(),children:[jsxRuntime.jsx(ui.Button,{size:"sm",variant:"light",radius:"lg",isIconOnly:true,onPress:xo,children:M?jsxRuntime.jsx(ui.RestoreWindowIcon,{width:18,height:18,className:"text-neutral"}):jsxRuntime.jsx(ui.MinimizeIcon,{width:18,height:18,className:"text-neutral"})}),jsxRuntime.jsx(ui.Button,{size:"sm",variant:"light",radius:"lg",isIconOnly:true,onPress:yo,children:Le?jsxRuntime.jsx(ui.UnMaximizeIcon,{width:18,height:18,className:"text-neutral"}):jsxRuntime.jsx(ui.MaximizeIcon,{width:18,height:18,className:"text-neutral"})}),jsxRuntime.jsx(ui.Button,{size:"sm",variant:"light",radius:"lg",isIconOnly:true,onPress:_,children:jsxRuntime.jsx(ui.XCloseIcon,{width:18,height:18,className:"text-neutral"})})]})]})]}),!M&&jsxRuntime.jsx("div",{className:b?"h-[calc(100%-44px)] overflow-x-hidden overflow-y-auto":"h-full overflow-x-hidden overflow-y-auto cursor-move",onMouseDown:b?void 0:s=>Z(s,"drag"),children:H})]})}),g&&jsxRuntime.jsx("div",{className:ui.cn("relative mt-1 z-10 transition-all duration-250 ease-[cubic-bezier(0.16,1,0.3,1)]",R?"opacity-40 -translate-x-4":"opacity-100 translate-x-0"),style:{width:p,height:M?40:d.height-8},children:g})]})})]}):null});function ht({id:e,title:t,maxWidth:n=440,minWidth:a=320,position:r,showHeader:l=true,header:c,headerHeight:o=44,children:i}){let{t:g}=i18n.useTranslation(),p=jotai.useAtomValue(ge(e)),[u,b]=react.useState(false),[x,E]=react.useState(false),[H,y]=jotai.useAtom(_e(e)),{onOpen:k}=we(e),{onClose:_}=Me(e),ee=jotai.useAtomValue(qe(e)),M=jotai.useAtomValue(Qe(e)),L=hooks.useValueRef(H),h=hooks.useValueRef(n),ce=hooks.useValueRef(a),d=hooks.useValueRef(r),De=hooks.useValueRef(u),te=hooks.useValueRef(x),oe=hooks.useCallbackRef(y),X=hooks.useCallbackRef(k),j=hooks.useCallbackRef(_),ne=hooks.useValueRef(ee),re=hooks.useValueRef(M),R=v=>{v.preventDefault(),v.stopPropagation(),b(true),document.body.style.cursor="ew-resize",document.body.style.userSelect="none",document.body.style.overflow="hidden",document.body.style.position="fixed",document.body.style.width="100%",document.body.style.height="100%";let P=v.clientX,ae=L.current,me=fe=>{if(!De.current)return;let A=fe.clientX-P,xe=d.current==="right"?ae-A:ae+A,le=Math.min(Math.max(xe,ce.current),h.current);oe(le);},se=()=>{b(false),document.body.style.cursor="",document.body.style.userSelect="",document.body.style.overflow="",document.body.style.position="",document.body.style.width="",document.body.style.height="",document.removeEventListener("mousemove",me),document.removeEventListener("mouseup",se);};document.addEventListener("mousemove",me),document.addEventListener("mouseup",se);},ie=v=>{if(v.target instanceof HTMLElement&&v.target.closest("button"))return;v.preventDefault(),E(true);let P=v.clientX,ae=v.clientY,me=()=>{document.removeEventListener("mousemove",se),document.removeEventListener("mouseup",fe),E(false);},se=A=>{if(!te.current)return;let xe=Math.abs(A.clientX-P),le=Math.abs(A.clientY-ae);(xe>10||le>10)&&(me(),j(),X({shouldStartDragging:true,position:{x:A.clientX-L.current/2+20,y:A.clientY-20},size:{width:Math.min(Math.max(L.current,ne.current),re.current)}}));},fe=()=>{me();};document.addEventListener("mousemove",se),document.addEventListener("mouseup",fe);},ue=()=>{j();};return p!==r?null:jsxRuntime.jsxs("div",{className:"max-sm:hidden flex-none flex flex-row overflow-hidden",children:[r==="right"&&jsxRuntime.jsx($t,{isResizing:u,handleResizeStart:R}),jsxRuntime.jsxs("div",{className:ui.cn("flex flex-col min-h-0 overflow-hidden bg-content1",x?"opacity-80 scale-98 blur-[1px]":"opacity-100 scale-100 blur-none"),style:{width:`${H}px`,transition:u||x?"none":"transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s cubic-bezier(0.33, 1, 0.68, 1), height 0.4s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s cubic-bezier(0.33, 1, 0.68, 1)",contain:"content"},children:[l&&jsxRuntime.jsxs("div",{className:"flex-none relative border-b border-border/80 px-3 gap-4 flex items-center justify-between cursor-move select-none",onMouseDown:ie,style:{height:o},children:[jsxRuntime.jsx(ui.StyledTooltip,{placement:"top",closeDelay:0,content:g("scaffold.draggablePanel.snapToModal"),children:jsxRuntime.jsx(ui.DraggableIcon,{className:"text-neutral absolute left-1/2 -translate-x-1/2 top-0"})}),c||jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"min-w-0 flex-initial text-sm font-medium truncate cursor-auto",onMouseDown:v=>v.stopPropagation(),children:t}),jsxRuntime.jsx("div",{className:"flex-none flex items-center justify-end gap-1",onMouseDown:v=>v.stopPropagation(),children:jsxRuntime.jsx(ui.Button,{size:"sm",variant:"light",radius:"lg",isIconOnly:true,onPress:ue,children:jsxRuntime.jsx(ui.XCloseIcon,{width:18,height:18,className:"text-neutral"})})})]})]}),jsxRuntime.jsx("div",{className:"flex-auto min-h-0 overflow-y-auto",children:i})]}),r==="left"&&jsxRuntime.jsx($t,{isResizing:u,handleResizeStart:R})]})}function $t({isResizing:e,handleResizeStart:t}){return jsxRuntime.jsxs("div",{className:"relative",children:[jsxRuntime.jsxs("div",{className:"relative w-1 h-full cursor-ew-resize bg-border/80 hover:bg-border transition-colors duration-150 ease-in-out group flex flex-col items-center justify-center gap-1",children:[jsxRuntime.jsx("i",{className:"rounded-full w-0.5 h-0.5 bg-neutral"}),jsxRuntime.jsx("i",{className:"rounded-full w-0.5 h-0.5 bg-neutral"}),jsxRuntime.jsx("i",{className:"rounded-full w-0.5 h-0.5 bg-neutral"}),jsxRuntime.jsx("div",{className:"absolute inset-0 -left-1.5 -right-1.5 cursor-ew-resize",onMouseDown:t})]}),e&&jsxRuntime.jsx("div",{className:"fixed inset-0 z-50 cursor-ew-resize"})]})}function fr({contents:e=[],className:t,classNames:n,children:a}){let r=jotai.useAtomValue(et);react.useEffect(()=>{let o=jotai.getDefaultStore();e.forEach(i=>{o.set(Xe(i.id),i.panelMinWidth??320),o.set(Ye(i.id),i.panelMaxWidth??440),o.set(qe(i.id),i.modalMinWidth??504),o.set(Qe(i.id),i.modalMaxWidth??window.innerWidth-40);});},[e]);let l=react.useMemo(()=>e.filter(o=>{let i=jotai.getDefaultStore();return r.left[o.id]?i.get(ge(o.id))==="left":false}).sort((o,i)=>r.left[i.id]-r.left[o.id]),[e,r.left]),c=react.useMemo(()=>e.filter(o=>{let i=jotai.getDefaultStore();return r.right[o.id]?i.get(ge(o.id))==="right":false}).sort((o,i)=>(r.right[o.id]??0)-(r.right[i.id]??0)),[e,r.right]);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:ui.cn("w-full h-full flex flex-row overflow-hidden",t,n?.root),children:[jsxRuntime.jsx("div",{className:ui.cn("flex-none h-full flex flex-row",n?.left),children:l.map(o=>jsxRuntime.jsx(ht,{...o,position:"left",minWidth:o.panelMinWidth??320,maxWidth:o.panelMaxWidth??440},`left-${o.id}`))}),jsxRuntime.jsx("div",{className:ui.cn("flex-auto min-w-0 h-full",n?.content),children:a}),jsxRuntime.jsx("div",{className:ui.cn("flex-none h-full flex flex-row",n?.right),children:c.map(o=>jsxRuntime.jsx(ht,{...o,position:"right",minWidth:o.panelMinWidth??320,maxWidth:o.panelMaxWidth??440},`right-${o.id}`))})]}),e.map(o=>jsxRuntime.jsx(Ht,{...o,minWidth:o.modalMinWidth??504,maxWidth:o.modalMaxWidth??window.innerWidth-40},`modal-${o.id}`))]})}function wr(e){let{isOpen:t,onOpen:n,onClose:a}=we(e),{isOpen:r,onOpen:l,onClose:c}=Me(e),o=jotai.useAtomValue(ve(e)),i=react.useCallback(()=>{t||r||(o==="modal"?n():l({position:o}));},[t,r,o,n,l]),g=react.useCallback(()=>{t?a():r&&c();},[t,r,a,c]),p=react.useMemo(()=>t||r,[t,r]);return react.useMemo(()=>({isOpen:p,onOpen:i,onClose:g}),[p,i,g])}var Ut=["desktop","tablet","mobile"];function Zt(e,t){return e.match!==void 0?typeof e.match=="function"?e.match(t):e.match instanceof RegExp?e.match.test(t):t.startsWith(e.match):e.href==="/"?t==="/":t.startsWith(e.href)}function rt(e){let t={desktop:e.includes("desktop"),tablet:e.includes("tablet"),mobile:e.includes("mobile")};if(t.desktop&&t.tablet&&t.mobile)return "";if(!t.desktop&&!t.tablet&&!t.mobile)return "hidden";if(t.desktop&&t.tablet&&!t.mobile)return "max-sm:hidden";if(t.desktop&&!t.tablet&&!t.mobile)return "max-lg:hidden";if(!t.desktop&&t.tablet&&t.mobile)return "lg:hidden";if(!t.desktop&&!t.tablet&&t.mobile)return "sm:hidden";if(!t.desktop&&t.tablet&&!t.mobile)return "max-sm:hidden lg:hidden";throw new Error(`getVisibilityClass: non-contiguous breakpoints [${e.join(", ")}] are not supported. Use a contiguous range (e.g. [desktop, tablet], [tablet, mobile]).`)}var bt=react.createContext(null);function xt(){let e=react.useContext(bt);if(!e)throw new Error("useScaffold must be used within a <Scaffold> component.");return e}function kr(e){let t=xt();react.useEffect(()=>(e.headerVisible!==void 0&&t.setHeaderVisible(e.headerVisible),e.footerVisible!==void 0&&t.setFooterVisible(e.footerVisible),e.toolbarVisible!==void 0&&t.setToolbarVisible(e.toolbarVisible),()=>{e.headerVisible!==void 0&&t.setHeaderVisible(t.defaultHeaderVisible),e.footerVisible!==void 0&&t.setFooterVisible(t.defaultFooterVisible),e.toolbarVisible!==void 0&&t.setToolbarVisible(t.defaultToolbarVisible);}),[e.headerVisible,e.footerVisible,e.toolbarVisible]);}var en=60,tn=56,on=36,nn=()=>{};function Tr({children:e,pathname:t="",onNavigate:n=nn,header:a,footer:r,toolbar:l,headerHeight:c=en,footerHeight:o=tn,toolbarHeight:i=on,headerVisible:g=Ut,footerVisible:p=[],toolbarVisible:u=[],className:b,classNames:x}){let[E,H]=react.useState(g),[y,k]=react.useState(p),[_,ee]=react.useState(u),M=react.useMemo(()=>({pathname:t,onNavigate:n,headerHeight:c,footerHeight:o,toolbarHeight:i,headerVisible:E,footerVisible:y,toolbarVisible:_,setHeaderVisible:H,setFooterVisible:k,setToolbarVisible:ee,defaultHeaderVisible:g,defaultFooterVisible:p,defaultToolbarVisible:u}),[t,n,c,o,i,E,y,_,g,p,u]),L=rt(E),h=rt(y),ce=rt(_);return jsxRuntime.jsx(bt.Provider,{value:M,children:jsxRuntime.jsxs("div",{className:ui.cn("w-full h-screen max-sm:h-dvh flex flex-col overflow-hidden bg-background",x?.wrapper,b),style:{"--scaffold-header-height":`${c}px`,"--scaffold-footer-height":`calc(${o}px + env(safe-area-inset-bottom))`,"--scaffold-toolbar-height":`${i}px`},children:[a&&jsxRuntime.jsx("nav",{className:ui.cn("w-full flex-none",L,x?.header),style:{height:`${c}px`},children:a}),jsxRuntime.jsx("div",{className:ui.cn("w-full flex-auto min-h-0 relative",x?.content),children:e}),l&&jsxRuntime.jsx("div",{className:ui.cn("w-full flex-none",ce,x?.toolbar),style:{height:`${i}px`},children:l}),r&&jsxRuntime.jsx("div",{className:ui.cn("w-full flex-none pb-[env(safe-area-inset-bottom)]",h,x?.footer),style:{height:`calc(${o}px + env(safe-area-inset-bottom))`},children:r})]})})}function it({item:e,variant:t="header",className:n}){let{pathname:a,onNavigate:r}=xt(),l=Zt(e,a),c=react.useCallback(()=>{r(e.href);},[r,e.href]);return t==="footer"?jsxRuntime.jsxs("button",{type:"button","data-active":l,className:ui.cn("flex flex-col items-center justify-center gap-0.5 px-2 py-1 min-w-0","text-xs font-medium text-foreground/60","data-[active=true]:text-primary",n),onClick:c,"aria-label":e.label,"aria-current":l?"page":void 0,children:[e.icon&&jsxRuntime.jsx("span",{className:"flex items-center justify-center",children:e.icon}),jsxRuntime.jsx("span",{className:"truncate",children:e.label})]}):jsxRuntime.jsx("button",{type:"button","data-active":l,className:ui.cn("h-8 text-sm font-medium px-2 xl:px-3 rounded-sm cursor-pointer","text-foreground hover:text-primary hover:bg-primary-50","data-[active=true]:text-primary",n),onClick:c,"aria-label":e.label,"aria-current":l?"page":void 0,children:e.label})}function Gr({children:e,left:t,right:n,navItems:a,className:r}){return e?jsxRuntime.jsx("header",{className:ui.cn("w-full h-full flex items-center bg-background border-b border-border",r),children:e}):jsxRuntime.jsxs("header",{className:ui.cn("w-full h-full px-6 max-lg:px-4 flex items-center justify-between gap-6 max-lg:gap-4 bg-background border-b border-border",r),children:[t&&jsxRuntime.jsx("div",{className:"shrink-0 flex items-center",children:t}),a&&a.length>0&&jsxRuntime.jsx(ui.HorizontalScrollContainer,{className:"flex-auto min-w-0 max-sm:hidden",classNames:{content:"gap-1"},children:a.map(l=>jsxRuntime.jsx(it,{item:l,variant:"header"},l.key))}),n&&jsxRuntime.jsx("div",{className:"shrink-0 flex items-center gap-4",children:n})]})}function ei({children:e,navItems:t,className:n}){return e?jsxRuntime.jsx("footer",{className:ui.cn("w-full h-full flex items-center bg-background border-t border-border",n),children:e}):jsxRuntime.jsx("footer",{className:ui.cn("w-full h-full flex justify-evenly items-center bg-background border-t border-border",n),children:t?.map(a=>jsxRuntime.jsx(it,{item:a,variant:"footer"},a.key))})}function ri({children:e,left:t,right:n,className:a}){return e?jsxRuntime.jsx("div",{className:ui.cn("w-full h-full flex items-center bg-background border-t border-border",a),children:e}):jsxRuntime.jsxs("div",{className:ui.cn("w-full h-full px-6 flex items-center justify-between gap-4 bg-background border-t border-border",a),children:[t&&jsxRuntime.jsx("div",{className:"flex items-center gap-4",children:t}),n&&jsxRuntime.jsx("div",{className:"flex items-center gap-4",children:n})]})}function di({href:e="/",icon:t,miniIcon:n,className:a}){let{t:r}=i18n.useTranslation();return jsxRuntime.jsxs(ui.Link,{href:e,className:ui.cn("flex-none flex justify-center items-center",a),"aria-label":r("scaffold.home"),children:[jsxRuntime.jsx("div",{className:ui.cn("flex justify-center items-center",!!n&&"max-xl:hidden"),children:t}),n&&jsxRuntime.jsx("div",{className:"flex justify-center items-center xl:hidden",children:n})]})}function Ni({id:e,children:t}){let n=hooks.useEventEmitter(),{isOpen:a,onOpen:r,onClose:l,onOpenChange:c}=ui.useDisclosure(),[o,i]=react.useState(void 0),[g,p]=react.useState(void 0);return react.useEffect(()=>{let u=({params:b,onResult:x})=>{i(b),p(x),r();};return n.on(`open_modal:${e}`,u),()=>{n.off(`open_modal:${e}`,u);}},[e,r,n]),react.useEffect(()=>{let u=()=>{l();};return n.on(`close_modal:${e}`,u),()=>{n.off(`close_modal:${e}`,u);}},[e,l,n]),t({params:o,isOpen:a,onClose:l,onOpenChange:c,onResult:g})}function Oi(e){let t=hooks.useEventEmitter(),n=react.useCallback(r=>{t.emit(`open_modal:${e}`,r);},[e,t]),a=react.useCallback(()=>{t.emit(`close_modal:${e}`);},[e,t]);return {onOpen:n,onClose:a}}function ro({direction:e,isResizing:t,onResizeStart:n,className:a}){let r=e==="horizontal";return jsxRuntime.jsxs("div",{className:ui.cn("relative flex-none",a),children:[jsxRuntime.jsxs("div",{className:ui.cn("flex items-center justify-center bg-border/80 hover:bg-border transition-colors duration-150 ease-in-out",r?"w-1 h-full cursor-ew-resize flex-col gap-1":"w-full h-1 cursor-ns-resize flex-row gap-1"),children:[jsxRuntime.jsx("i",{className:"rounded-full w-0.5 h-0.5 bg-neutral"}),jsxRuntime.jsx("i",{className:"rounded-full w-0.5 h-0.5 bg-neutral"}),jsxRuntime.jsx("i",{className:"rounded-full w-0.5 h-0.5 bg-neutral"}),jsxRuntime.jsx("div",{className:ui.cn("absolute inset-0",r?"-left-1.5 -right-1.5 cursor-ew-resize":"-top-1.5 -bottom-1.5 cursor-ns-resize"),onMouseDown:n})]}),t&&jsxRuntime.jsx("div",{className:ui.cn("fixed inset-0 z-50",r?"cursor-ew-resize":"cursor-ns-resize")})]})}var vn=4;function wn(e){if(!e)return null;try{let t=localStorage.getItem(`splitView.${e}`);return t?Number(t):null}catch{return null}}function Mn(e,t){if(e)try{localStorage.setItem(`splitView.${e}`,String(t));}catch{}}function $i({direction:e="horizontal",primary:t,secondary:n,defaultSize:a=400,minSize:r=100,maxSize:l=1/0,secondaryMinSize:c=100,onSizeChange:o,persistId:i,className:g,classNames:p}){let u=react.useRef(null),[b,x]=react.useState(()=>wn(i)??a),[E,H]=react.useState(false),y=e==="horizontal",k=hooks.useValueRef(b),_=hooks.useValueRef(r),ee=hooks.useValueRef(l),M=hooks.useValueRef(c),L=hooks.useValueRef(E),h=hooks.useCallbackRef(d=>{x(d),Mn(i,d),o?.(d);}),ce=react.useCallback(d=>{d.preventDefault(),d.stopPropagation(),H(true);let De=y?"ew-resize":"ns-resize";document.body.style.cursor=De,document.body.style.userSelect="none";let te=y?d.clientX:d.clientY,oe=k.current,X=u.current,j=X?y?X.offsetWidth:X.offsetHeight:1/0,ne=R=>{if(!L.current)return;let ue=(y?R.clientX:R.clientY)-te,v=Math.min(ee.current,j-M.current-vn),P=Math.min(Math.max(oe+ue,_.current),v);h(P);},re=()=>{H(false),document.body.style.cursor="",document.body.style.userSelect="",document.removeEventListener("mousemove",ne),document.removeEventListener("mouseup",re);};document.addEventListener("mousemove",ne),document.addEventListener("mouseup",re);},[y,k,_,ee,M,L,h]);return jsxRuntime.jsxs("div",{ref:u,className:ui.cn("w-full h-full flex overflow-hidden",y?"flex-row":"flex-col",g),children:[jsxRuntime.jsx("div",{className:ui.cn("flex-none overflow-hidden",p?.primary),style:y?{width:`${b}px`,minWidth:`${r}px`}:{height:`${b}px`,minHeight:`${r}px`},children:t}),jsxRuntime.jsx(ro,{direction:e,isResizing:E,onResizeStart:ce,className:p?.handle}),jsxRuntime.jsx("div",{className:ui.cn("flex-auto min-w-0 min-h-0 overflow-hidden",p?.secondary),style:y?{minWidth:`${c}px`}:{minHeight:`${c}px`},children:n})]})}typeof window<"u"&&(window.__LIBERFI_VERSION__=window.__LIBERFI_VERSION__||{},window.__LIBERFI_VERSION__["@liberfi.io/ui-scaffold"]="0.1.36");var zn="0.1.36";exports.ALL_BREAKPOINTS=Ut;exports.AsyncModal=Ni;exports.DraggableModal=Ht;exports.DraggablePanel=ht;exports.DraggablePanelProvider=fr;exports.Logo=di;exports.NavLink=it;exports.Scaffold=Tr;exports.ScaffoldContext=bt;exports.ScaffoldFooter=ei;exports.ScaffoldHeader=Gr;exports.ScaffoldToolbar=ri;exports.SplitHandle=ro;exports.SplitView=$i;exports.getVisibilityClass=rt;exports.isNavItemActive=Zt;exports.useAsyncModal=Oi;exports.useDraggableDisclosure=wr;exports.useDraggableModalDisclosure=we;exports.useDraggablePanelDisclosure=Me;exports.useScaffold=xt;exports.useScaffoldLayout=kr;exports.version=zn;//# sourceMappingURL=index.js.map
|
|
1
|
+
'use strict';var react=require('react'),reactDom=require('react-dom'),jotai=require('jotai'),hooks=require('@liberfi.io/hooks'),i18n=require('@liberfi.io/i18n'),ui=require('@liberfi.io/ui'),utils$1=require('@liberfi.io/utils'),jotaiFamily=require('jotai-family'),utils=require('jotai/utils'),jsxRuntime=require('react/jsx-runtime');var ge=jotaiFamily.atomFamily(e=>utils.atomWithStorage(`panelState.${e??"default"}`,"none",void 0,{getOnInit:true})),_e=jotaiFamily.atomFamily(e=>utils.atomWithStorage(`panelWidth.${e??"default"}`,350,void 0,{getOnInit:true})),Xe=jotaiFamily.atomFamily(e=>utils.atomWithStorage(`panelMinWidth.${e??"default"}`,320,void 0,{getOnInit:true})),Ye=jotaiFamily.atomFamily(e=>utils.atomWithStorage(`panelMaxWidth.${e??"default"}`,440,void 0,{getOnInit:true})),Lt=jotaiFamily.atomFamily(e=>utils.atomWithStorage(`modalOpen.${e??"default"}`,false,void 0,{getOnInit:true})),Ue=jotaiFamily.atomFamily(e=>utils.atomWithStorage(`modalShouldStartDragging.${e??"default"}`,false,void 0,{getOnInit:true})),Ze=jotaiFamily.atomFamily(e=>utils.atomWithStorage(`modalSize.${e??"default"}`,{width:350,height:580},void 0,{getOnInit:true})),je=jotaiFamily.atomFamily(e=>utils.atomWithStorage(`modalRestoreSize.${e??"default"}`,{width:350,height:580},void 0,{getOnInit:true})),Ge=jotaiFamily.atomFamily(e=>utils.atomWithStorage(`modalPosition.${e??"default"}`,{x:typeof window<"u"?Math.max(0,(window.innerWidth-350)/2):0,y:typeof window<"u"?Math.max(0,(window.innerHeight-580)/2):0},void 0,{getOnInit:true})),Ke=jotaiFamily.atomFamily(e=>utils.atomWithStorage(`modalRestorePosition.${e??"default"}`,{x:typeof window<"u"?Math.max(0,(window.innerWidth-350)/2):0,y:typeof window<"u"?Math.max(0,(window.innerHeight-580)/2):0},void 0,{getOnInit:true})),Je=jotaiFamily.atomFamily(e=>utils.atomWithStorage(`modalMinimized.${e??"default"}`,false,void 0,{getOnInit:true})),qe=jotaiFamily.atomFamily(e=>utils.atomWithStorage(`modalMinWidth.${e??"default"}`,200,void 0,{getOnInit:true})),Qe=jotaiFamily.atomFamily(e=>utils.atomWithStorage(`modalMaxWidth.${e??"default"}`,typeof window<"u"?window.innerWidth-40:0,void 0,{getOnInit:true})),ve=jotaiFamily.atomFamily(e=>utils.atomWithStorage(`lastPanelType.${e??"default"}`,"modal",void 0,{getOnInit:true})),et=utils.atomWithStorage("panelOrders",{left:{},right:{}},void 0,{getOnInit:true});function we(e){let[t,n]=jotai.useAtom(Lt(e)),[a,r]=jotai.useAtom(Je(e)),l=jotai.useAtomValue(je(e)),d=jotai.useAtomValue(Ke(e)),o=jotai.useSetAtom(Ze(e)),i=jotai.useSetAtom(Ge(e)),p=jotai.useSetAtom(Ue(e)),m=jotai.useSetAtom(ve(e)),c=react.useCallback((y={})=>{let{shouldStartDragging:h,position:S,size:v}=y;S&&i(L=>({...L,...S})),v&&o(L=>({...L,...v})),p(h??false),n(true),m("modal");},[n,i,o,p]),x=react.useCallback(()=>{n(false),a&&(o({...l}),i({...d}),r(false));},[a,l,d,r,n,o,i]);return react.useMemo(()=>({isOpen:t,onOpen:c,onClose:x}),[t,c,x])}function Re(e){let[t,n]=jotai.useAtom(ge(e)),a=jotai.useSetAtom(_e(e)),r=jotai.useSetAtom(ve(e)),l=jotai.useSetAtom(et),d=react.useCallback((m={})=>{let c=m.position??"left";a(m.width??320),n(c),r(c),l(({left:x,right:y})=>c==="left"?{left:{...x,[e]:Date.now()},right:y}:{left:x,right:{...y,[e]:Date.now()}});},[e,n,a]),o=react.useCallback(()=>{n("none");},[n]),i=react.useMemo(()=>t!=="none",[t]),p=react.useMemo(()=>t!=="none"?t:void 0,[t]);return react.useMemo(()=>({isOpen:i,position:p,onOpen:d,onClose:o}),[i,d,o])}var Vo={width:200,height:48},Ie={width:typeof window<"u"?window.innerWidth-40:0,height:typeof window<"u"?window.innerHeight-40:0},Fo={x:20,y:20},At=react.memo(function({id:t,title:n,minWidth:a=504,maxWidth:r=Ie.width,minHeight:l=200,maxHeight:d=Ie.height,leftSidebar:o,leftSidebarWidth:i=200,rightSidebar:p,rightSidebarWidth:m=200,aspectRatio:c,showHeader:x=true,header:y,headerHeight:h=44,children:S}){let{t:v}=i18n.useTranslation(),{isOpen:L,onClose:_}=we(t),{onOpen:ee}=Re(t),[M,C]=jotai.useAtom(Je(t)),[b,ue]=jotai.useAtom(Ge(t)),[u,De]=jotai.useAtom(Ze(t)),[te,oe]=jotai.useAtom(je(t)),[X,j]=jotai.useAtom(Ke(t)),[ne,re]=jotai.useAtom(Ue(t)),[z,ie]=react.useState(ne),[ce,w]=react.useState(false),[D,ae]=react.useState(null),[me,se]=react.useState(null),[fe,A]=react.useState(null),[xe,le]=react.useState(null),G=react.useRef(null),ao=jotai.useAtomValue(Xe(t)),so=jotai.useAtomValue(Ye(t)),K=hooks.useValueRef(b),O=hooks.useCallbackRef(ue),pe=hooks.useValueRef(u),T=hooks.useCallbackRef(De),lo=hooks.useValueRef(i),uo=hooks.useValueRef(!!o),co=hooks.useValueRef(m),mo=hooks.useValueRef(!!p),U=hooks.useValueRef(c),J=hooks.useValueRef(h),Oe=hooks.useValueRef(a),We=hooks.useValueRef(r),ke=hooks.useValueRef(l),Ee=hooks.useValueRef(d),fo=hooks.useValueRef(z),Pt=hooks.useValueRef(me),lt=hooks.useValueRef(xe),po=hooks.useCallbackRef(_),ho=hooks.useCallbackRef(ee),go=hooks.useValueRef(ao),bo=hooks.useValueRef(so),Le=react.useMemo(()=>u.width===Ie.width&&u.height===Ie.height,[u.width,u.height]);react.useEffect(()=>{let s=Math.min(Math.max(u.width,a),r),W=Math.min(Math.max(u.height,l),d);(s!==u.width||W!==u.height)&&T({width:s,height:W});let H=Math.max(0,b.x),he=Math.max(0,b.y);H+s>window.innerWidth&&(H=Math.max(0,window.innerWidth-s)),he+W>window.innerHeight&&(he=Math.max(0,window.innerHeight-W)),(H!==b.x||he!==b.y)&&O({x:H,y:he});},[t]),react.useEffect(()=>{if(L&&ne){ie(true);let s=H=>{O({x:H.clientX-u.width/2,y:H.clientY-20});},W=()=>{ie(false),re(false),document.removeEventListener("mousemove",s),document.removeEventListener("mouseup",W);};return document.addEventListener("mousemove",s),document.addEventListener("mouseup",W),document.body.style.cursor="grabbing",()=>{document.removeEventListener("mousemove",s),document.removeEventListener("mouseup",W),document.body.style.cursor="";}}},[L,ne,re,u.width]);let Z=(s,W,H)=>{re(false),ie(false),w(false),ae(null),W==="drag"?ie(true):W==="resize"&&(ae(H||null),w(true));let he=s.clientX,St=s.clientY,$=pe.current.width,Y=pe.current.height,B={...K.current},Dt=()=>{document.removeEventListener("mousemove",Ot),document.removeEventListener("mouseup",Wt),document.body.style.cursor="",ie(false),w(false),ae(null),se(null),G.current&&(clearTimeout(G.current),G.current=null),le(null),A(null);},Ot=$e=>{if(W==="drag"){let q=$e.clientX-he,Q=$e.clientY-St,N=B.x+q,g=B.y+Q,ye=uo.current?lo.current:0,Ce=12+ye,I=mo.current?co.current:0,P=window.innerWidth-12-$-I,Be=window.innerHeight-12-44,k=N<=Ce?"left":N>=P?"right":null;k!==Pt.current&&se(k),G.current&&k&&A(k),G.current&&(lt.current==="left"&&(N>Ce||k!=="left")||lt.current==="right"&&(N<P||k!=="right"))&&(clearTimeout(G.current),G.current=null,le(null),A(null)),!G.current&&k&<.current!==k&&(le(k),A(k),G.current=setTimeout(()=>{fo.current&&Pt.current===k?(Dt(),po(),ho({position:k,width:Math.min(Math.max(pe.current.width,go.current),bo.current)})):le(null);},350)),N=Math.min(Math.max(N,12+ye),P),g=Math.min(Math.max(g,12),Be),O({x:N,y:g});}else if(W==="resize"&&H){let q=$e.clientX-he,Q=$e.clientY-St,N=(g,ye,Ce)=>{let I=Math.min(Math.max(g,Oe.current),We.current),P=Math.min(Math.max(ye,ke.current),Ee.current);if(U.current){if(Ce==="width")P=Math.min(Math.max(g/U.current+J.current,ke.current),Ee.current),I=(P-J.current)*U.current;else if(Ce==="height")I=Math.min(Math.max((ye-J.current)*U.current,Oe.current),We.current),P=I/U.current+J.current;else {let Be=g/U.current+J.current,k=(ye-J.current)*U.current,kt=Math.abs(q),Et=Math.abs(Q);if(kt>1.1*Et)P=Math.min(Math.max(Be,ke.current),Ee.current),I=(P-J.current)*U.current;else if(Et>1.1*kt)I=Math.min(Math.max(k,Oe.current),We.current),P=I/U.current+J.current;else {let vo=(P+Be)/2;I=Math.min(Math.max((I+k)/2,Oe.current),We.current),P=Math.min(Math.max(vo,ke.current),Ee.current),I=(P-J.current)*U.current;}}I=Math.min(Math.max(I,Oe.current),We.current),P=Math.min(Math.max(P,ke.current),Ee.current);}return {width:I,height:P}};switch(H){case "topLeft":{let g=N($-q,Y-Q,"both");T(g),O({x:B.x+($-g.width),y:B.y+(Y-g.height)});break}case "topRight":{let g=N($+q,Y-Q,"both");T(g),O({x:B.x,y:B.y+(Y-g.height)});break}case "bottomLeft":{let g=N($-q,Y+Q,"both");T(g),O({x:B.x+($-g.width),y:B.y});break}case "bottomRight":{T(N($+q,Y+Q,"both"));break}case "top":{let g=N($,Y-Q,"height");T(g),O({x:B.x,y:B.y+(Y-g.height)});break}case "bottom":{T(N($,Y+Q,"height"));break}case "left":{let g=N($-q,Y,"width");T(g),O({x:B.x+($-g.width),y:B.y});break}case "right":{T(N($+q,Y,"width"));break}}}},Wt=()=>{(b.x<0||b.y<0)&&O({x:Math.max(0,b.x),y:Math.max(0,b.y)}),Dt();};document.addEventListener("mousemove",Ot),document.addEventListener("mouseup",Wt);},xo=react.useCallback(()=>{M?(T({...te}),O({...X}),C(false)):(Le?O({...X}):(oe({...u}),j({...b})),T({...Vo}),C(true));},[M,Le,u,b,te,X,C,oe,j]),yo=react.useCallback(()=>{Le?(T({...te}),O({...X})):(M?C(false):(oe({...u}),j({...b})),T({...Ie}),O({...Fo}));},[Le,M,u,b,te,X,C,oe,j]);return react.useEffect(()=>{let s=utils$1.throttle(()=>{(K.current.x<0||K.current.y<0)&&O({x:Math.max(0,K.current.x),y:Math.max(0,K.current.y)});let W=K.current.x+pe.current.width,H=K.current.y+pe.current.height;(W>window.innerWidth||H>window.innerHeight)&&O({x:Math.min(K.current.x,Math.max(0,window.innerWidth-pe.current.width)),y:Math.min(K.current.y,Math.max(0,window.innerHeight-pe.current.height))});},100);return window.addEventListener("resize",s),()=>{window.removeEventListener("resize",s);}},[]),L?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[(z||ce)&&reactDom.createPortal(jsxRuntime.jsx("div",{className:ui.cn("max-sm:hidden fixed inset-0 z-9999 bg-transparent w-full h-full select-none",z&&(xe?"cursor-grabbing":"cursor-move"),!z&&{"cursor-ns-resize":D==="top"||D==="bottom","cursor-ew-resize":D==="left"||D==="right","cursor-nwse-resize":D==="topLeft"||D==="bottomRight","cursor-nesw-resize":D==="topRight"||D==="bottomLeft","cursor-auto":D===null})}),document.body),jsxRuntime.jsx("div",{className:ui.cn("max-sm:hidden fixed z-50 left-0 top-0",z?"will-change-transform":"will-change-auto",ce||z?"transition-none":"transition-transform duration-250 ease-[cubic-bezier(0.16,1,0.3,1)]"),style:{transform:`translate(${Math.round(b.x-(o?i:0))}px, ${Math.round(b.y)}px)`},children:jsxRuntime.jsxs("div",{className:"flex relative z-50",children:[o&&jsxRuntime.jsx("div",{className:ui.cn("relative mt-1 z-10 transition-all duration-250 ease-[cubic-bezier(0.16,1,0.3,1)]",z?"opacity-40 translate-x-4":"opacity-100 translate-x-0"),style:{width:i,height:M?40:u.height-8},children:o}),jsxRuntime.jsx("div",{className:ui.cn("z-50 relative bg-content1 border border-border rounded-lg overflow-hidden",z?"opacity-80 shadow-md scale-102 blur-[0.5px]":"opacity-100 shadow-lg scale-100 blur-none"),style:{width:u.width,height:u.height,transition:ce||z?"none":"transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s cubic-bezier(0.33, 1, 0.68, 1), height 0.25s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s cubic-bezier(0.33, 1, 0.68, 1)",contain:"content"},children:jsxRuntime.jsxs("div",{className:ui.cn("w-full h-full",fe&&"animate-modal-shrink",fe==="left"?"origin-left":"origin-right"),style:{contain:"paint"},children:[!M&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"absolute top-0 left-0 w-3 h-3 cursor-nw-resize z-20",onMouseDown:s=>Z(s,"resize","topLeft")}),jsxRuntime.jsx("div",{className:"absolute top-0 right-0 w-3 h-3 cursor-ne-resize z-20",onMouseDown:s=>Z(s,"resize","topRight")}),jsxRuntime.jsx("div",{className:"absolute bottom-0 left-0 w-3 h-3 cursor-sw-resize z-20",onMouseDown:s=>Z(s,"resize","bottomLeft")}),jsxRuntime.jsx("div",{className:"absolute bottom-0 right-0 w-3 h-3 cursor-se-resize z-20",onMouseDown:s=>Z(s,"resize","bottomRight")}),jsxRuntime.jsx("div",{className:"absolute top-0 left-3 right-3 h-1.5 cursor-n-resize z-20",onMouseDown:s=>Z(s,"resize","top")}),jsxRuntime.jsx("div",{className:"absolute bottom-0 left-3 right-3 h-1.5 cursor-s-resize z-20",onMouseDown:s=>Z(s,"resize","bottom")}),jsxRuntime.jsx("div",{className:"absolute left-0 top-3 bottom-3 w-1.5 cursor-w-resize z-20",onMouseDown:s=>Z(s,"resize","left")}),jsxRuntime.jsx("div",{className:"absolute right-0 top-3 bottom-3 w-1.5 cursor-e-resize z-20",onMouseDown:s=>Z(s,"resize","right")})]}),x&&jsxRuntime.jsxs("div",{className:"relative border-b border-border/80 px-3 gap-4 flex items-center justify-between cursor-move select-none",onMouseDown:s=>Z(s,"drag"),style:{height:h},children:[jsxRuntime.jsx(ui.StyledTooltip,{placement:"top",closeDelay:0,content:v("scaffold.draggableModal.snapToEdge"),children:jsxRuntime.jsx(ui.DraggableIcon,{className:"text-neutral absolute left-1/2 -translate-x-1/2 top-0"})}),y||jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"min-w-0 flex-initial text-sm font-medium truncate cursor-auto",onMouseDown:s=>s.stopPropagation(),children:n}),jsxRuntime.jsxs("div",{className:"flex-none flex items-center justify-end gap-1",onMouseDown:s=>s.stopPropagation(),children:[jsxRuntime.jsx(ui.Button,{size:"sm",variant:"light",radius:"lg",isIconOnly:true,onPress:xo,children:M?jsxRuntime.jsx(ui.RestoreWindowIcon,{width:18,height:18,className:"text-neutral"}):jsxRuntime.jsx(ui.MinimizeIcon,{width:18,height:18,className:"text-neutral"})}),jsxRuntime.jsx(ui.Button,{size:"sm",variant:"light",radius:"lg",isIconOnly:true,onPress:yo,children:Le?jsxRuntime.jsx(ui.UnMaximizeIcon,{width:18,height:18,className:"text-neutral"}):jsxRuntime.jsx(ui.MaximizeIcon,{width:18,height:18,className:"text-neutral"})}),jsxRuntime.jsx(ui.Button,{size:"sm",variant:"light",radius:"lg",isIconOnly:true,onPress:_,children:jsxRuntime.jsx(ui.XCloseIcon,{width:18,height:18,className:"text-neutral"})})]})]})]}),!M&&jsxRuntime.jsx("div",{className:x?"h-[calc(100%-44px)] overflow-x-hidden overflow-y-auto":"h-full overflow-x-hidden overflow-y-auto cursor-move",onMouseDown:x?void 0:s=>Z(s,"drag"),children:S})]})}),p&&jsxRuntime.jsx("div",{className:ui.cn("relative mt-1 z-10 transition-all duration-250 ease-[cubic-bezier(0.16,1,0.3,1)]",z?"opacity-40 -translate-x-4":"opacity-100 translate-x-0"),style:{width:m,height:M?40:u.height-8},children:p})]})})]}):null});function gt({id:e,title:t,maxWidth:n=440,minWidth:a=320,position:r,showHeader:l=true,header:d,headerHeight:o=44,children:i}){let{t:p}=i18n.useTranslation(),m=jotai.useAtomValue(ge(e)),[c,x]=react.useState(false),[y,h]=react.useState(false),[S,v]=jotai.useAtom(_e(e)),{onOpen:L}=we(e),{onClose:_}=Re(e),ee=jotai.useAtomValue(qe(e)),M=jotai.useAtomValue(Qe(e)),C=hooks.useValueRef(S),b=hooks.useValueRef(n),ue=hooks.useValueRef(a),u=hooks.useValueRef(r),De=hooks.useValueRef(c),te=hooks.useValueRef(y),oe=hooks.useCallbackRef(v),X=hooks.useCallbackRef(L),j=hooks.useCallbackRef(_),ne=hooks.useValueRef(ee),re=hooks.useValueRef(M),z=w=>{w.preventDefault(),w.stopPropagation(),x(true),document.body.style.cursor="ew-resize",document.body.style.userSelect="none",document.body.style.overflow="hidden",document.body.style.position="fixed",document.body.style.width="100%",document.body.style.height="100%";let D=w.clientX,ae=C.current,me=fe=>{if(!De.current)return;let A=fe.clientX-D,xe=u.current==="right"?ae-A:ae+A,le=Math.min(Math.max(xe,ue.current),b.current);oe(le);},se=()=>{x(false),document.body.style.cursor="",document.body.style.userSelect="",document.body.style.overflow="",document.body.style.position="",document.body.style.width="",document.body.style.height="",document.removeEventListener("mousemove",me),document.removeEventListener("mouseup",se);};document.addEventListener("mousemove",me),document.addEventListener("mouseup",se);},ie=w=>{if(w.target instanceof HTMLElement&&w.target.closest("button"))return;w.preventDefault(),h(true);let D=w.clientX,ae=w.clientY,me=()=>{document.removeEventListener("mousemove",se),document.removeEventListener("mouseup",fe),h(false);},se=A=>{if(!te.current)return;let xe=Math.abs(A.clientX-D),le=Math.abs(A.clientY-ae);(xe>10||le>10)&&(me(),j(),X({shouldStartDragging:true,position:{x:A.clientX-C.current/2+20,y:A.clientY-20},size:{width:Math.min(Math.max(C.current,ne.current),re.current)}}));},fe=()=>{me();};document.addEventListener("mousemove",se),document.addEventListener("mouseup",fe);},ce=()=>{j();};return m!==r?null:jsxRuntime.jsxs("div",{className:"max-sm:hidden flex-none flex flex-row overflow-hidden",children:[r==="right"&&jsxRuntime.jsx(Bt,{isResizing:c,handleResizeStart:z}),jsxRuntime.jsxs("div",{className:ui.cn("flex flex-col min-h-0 overflow-hidden bg-content1",y?"opacity-80 scale-98 blur-[1px]":"opacity-100 scale-100 blur-none"),style:{width:`${S}px`,transition:c||y?"none":"transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s cubic-bezier(0.33, 1, 0.68, 1), height 0.4s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s cubic-bezier(0.33, 1, 0.68, 1)",contain:"content"},children:[l&&jsxRuntime.jsxs("div",{className:"flex-none relative border-b border-border/80 px-3 gap-4 flex items-center justify-between cursor-move select-none",onMouseDown:ie,style:{height:o},children:[jsxRuntime.jsx(ui.StyledTooltip,{placement:"top",closeDelay:0,content:p("scaffold.draggablePanel.snapToModal"),children:jsxRuntime.jsx(ui.DraggableIcon,{className:"text-neutral absolute left-1/2 -translate-x-1/2 top-0"})}),d||jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"min-w-0 flex-initial text-sm font-medium truncate cursor-auto",onMouseDown:w=>w.stopPropagation(),children:t}),jsxRuntime.jsx("div",{className:"flex-none flex items-center justify-end gap-1",onMouseDown:w=>w.stopPropagation(),children:jsxRuntime.jsx(ui.Button,{size:"sm",variant:"light",radius:"lg",isIconOnly:true,onPress:ce,children:jsxRuntime.jsx(ui.XCloseIcon,{width:18,height:18,className:"text-neutral"})})})]})]}),jsxRuntime.jsx("div",{className:"flex-auto min-h-0 overflow-y-auto",children:i})]}),r==="left"&&jsxRuntime.jsx(Bt,{isResizing:c,handleResizeStart:z})]})}function Bt({isResizing:e,handleResizeStart:t}){return jsxRuntime.jsxs("div",{className:"relative",children:[jsxRuntime.jsxs("div",{className:"relative w-1 h-full cursor-ew-resize bg-border/80 hover:bg-border transition-colors duration-150 ease-in-out group flex flex-col items-center justify-center gap-1",children:[jsxRuntime.jsx("i",{className:"rounded-full w-0.5 h-0.5 bg-neutral"}),jsxRuntime.jsx("i",{className:"rounded-full w-0.5 h-0.5 bg-neutral"}),jsxRuntime.jsx("i",{className:"rounded-full w-0.5 h-0.5 bg-neutral"}),jsxRuntime.jsx("div",{className:"absolute inset-0 -left-1.5 -right-1.5 cursor-ew-resize",onMouseDown:t})]}),e&&jsxRuntime.jsx("div",{className:"fixed inset-0 z-50 cursor-ew-resize"})]})}function hr({contents:e=[],className:t,classNames:n,children:a}){let r=jotai.useAtomValue(et);react.useEffect(()=>{let o=jotai.getDefaultStore();e.forEach(i=>{o.set(Xe(i.id),i.panelMinWidth??320),o.set(Ye(i.id),i.panelMaxWidth??440),o.set(qe(i.id),i.modalMinWidth??504),o.set(Qe(i.id),i.modalMaxWidth??window.innerWidth-40);});},[e]);let l=react.useMemo(()=>e.filter(o=>{let i=jotai.getDefaultStore();return r.left[o.id]?i.get(ge(o.id))==="left":false}).sort((o,i)=>r.left[i.id]-r.left[o.id]),[e,r.left]),d=react.useMemo(()=>e.filter(o=>{let i=jotai.getDefaultStore();return r.right[o.id]?i.get(ge(o.id))==="right":false}).sort((o,i)=>(r.right[o.id]??0)-(r.right[i.id]??0)),[e,r.right]);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:ui.cn("w-full h-full flex flex-row overflow-hidden",t,n?.root),children:[jsxRuntime.jsx("div",{className:ui.cn("flex-none h-full flex flex-row",n?.left),children:l.map(o=>jsxRuntime.jsx(gt,{...o,position:"left",minWidth:o.panelMinWidth??320,maxWidth:o.panelMaxWidth??440},`left-${o.id}`))}),jsxRuntime.jsx("div",{className:ui.cn("flex-auto min-w-0 h-full",n?.content),children:a}),jsxRuntime.jsx("div",{className:ui.cn("flex-none h-full flex flex-row",n?.right),children:d.map(o=>jsxRuntime.jsx(gt,{...o,position:"right",minWidth:o.panelMinWidth??320,maxWidth:o.panelMaxWidth??440},`right-${o.id}`))})]}),e.map(o=>jsxRuntime.jsx(At,{...o,minWidth:o.modalMinWidth??504,maxWidth:o.modalMaxWidth??window.innerWidth-40},`modal-${o.id}`))]})}function Mr(e){let{isOpen:t,onOpen:n,onClose:a}=we(e),{isOpen:r,onOpen:l,onClose:d}=Re(e),o=jotai.useAtomValue(ve(e)),i=react.useCallback(()=>{t||r||(o==="modal"?n():l({position:o}));},[t,r,o,n,l]),p=react.useCallback(()=>{t?a():r&&d();},[t,r,a,d]),m=react.useMemo(()=>t||r,[t,r]);return react.useMemo(()=>({isOpen:m,onOpen:i,onClose:p}),[m,i,p])}var Zt=["desktop","tablet","mobile"];function jt(e,t){return e.match!==void 0?typeof e.match=="function"?e.match(t):e.match instanceof RegExp?e.match.test(t):t.startsWith(e.match):e.href==="/"?t==="/":t.startsWith(e.href)}function rt(e){let t={desktop:e.includes("desktop"),tablet:e.includes("tablet"),mobile:e.includes("mobile")};if(t.desktop&&t.tablet&&t.mobile)return "";if(!t.desktop&&!t.tablet&&!t.mobile)return "hidden";if(t.desktop&&t.tablet&&!t.mobile)return "max-sm:hidden";if(t.desktop&&!t.tablet&&!t.mobile)return "max-lg:hidden";if(!t.desktop&&t.tablet&&t.mobile)return "lg:hidden";if(!t.desktop&&!t.tablet&&t.mobile)return "sm:hidden";if(!t.desktop&&t.tablet&&!t.mobile)return "max-sm:hidden lg:hidden";throw new Error(`getVisibilityClass: non-contiguous breakpoints [${e.join(", ")}] are not supported. Use a contiguous range (e.g. [desktop, tablet], [tablet, mobile]).`)}var xt=react.createContext(null);function yt(){let e=react.useContext(xt);if(!e)throw new Error("useScaffold must be used within a <Scaffold> component.");return e}function Cr(e){let t=yt();react.useEffect(()=>(e.headerVisible!==void 0&&t.setHeaderVisible(e.headerVisible),e.footerVisible!==void 0&&t.setFooterVisible(e.footerVisible),e.toolbarVisible!==void 0&&t.setToolbarVisible(e.toolbarVisible),()=>{e.headerVisible!==void 0&&t.setHeaderVisible(t.defaultHeaderVisible),e.footerVisible!==void 0&&t.setFooterVisible(t.defaultFooterVisible),e.toolbarVisible!==void 0&&t.setToolbarVisible(t.defaultToolbarVisible);}),[e.headerVisible,e.footerVisible,e.toolbarVisible]);}var en=60,tn=56,on=36,nn=()=>{};function Ar({children:e,pathname:t="",onNavigate:n=nn,header:a,footer:r,toolbar:l,headerHeight:d=en,footerHeight:o=tn,toolbarHeight:i=on,headerVisible:p=Zt,footerVisible:m=[],toolbarVisible:c=[],className:x,classNames:y}){let[h,S]=react.useState(p),[v,L]=react.useState(m),[_,ee]=react.useState(c),M=react.useMemo(()=>({pathname:t,onNavigate:n,headerHeight:d,footerHeight:o,toolbarHeight:i,headerVisible:h,footerVisible:v,toolbarVisible:_,setHeaderVisible:S,setFooterVisible:L,setToolbarVisible:ee,defaultHeaderVisible:p,defaultFooterVisible:m,defaultToolbarVisible:c}),[t,n,d,o,i,h,v,_,p,m,c]),C=rt(h),b=rt(v),ue=rt(_);return jsxRuntime.jsx(xt.Provider,{value:M,children:jsxRuntime.jsxs("div",{className:ui.cn("w-full h-screen max-sm:h-dvh flex flex-col overflow-hidden bg-background",y?.wrapper,x),style:{"--scaffold-header-height":`${d}px`,"--scaffold-footer-height":`calc(${o}px + env(safe-area-inset-bottom))`,"--scaffold-toolbar-height":`${i}px`},children:[a&&jsxRuntime.jsx("nav",{className:ui.cn("w-full flex-none",C,y?.header),style:{height:`${d}px`},children:a}),jsxRuntime.jsx("div",{className:ui.cn("w-full flex-auto min-h-0 relative",y?.content),children:e}),l&&jsxRuntime.jsx("div",{className:ui.cn("w-full flex-none",ue,y?.toolbar),style:{height:`${i}px`},children:l}),r&&jsxRuntime.jsx("div",{className:ui.cn("w-full flex-none pb-[env(safe-area-inset-bottom)]",b,y?.footer),style:{height:`calc(${o}px + env(safe-area-inset-bottom))`},children:r})]})})}function it({item:e,variant:t="header",className:n}){let{pathname:a,onNavigate:r}=yt(),l=jt(e,a),d=react.useCallback(()=>{r(e.href);},[r,e.href]);return t==="footer"?jsxRuntime.jsxs("button",{type:"button","data-active":l,className:ui.cn("flex flex-col items-center justify-center gap-0.5 px-2 py-1 min-w-0","text-xs font-medium text-foreground/60","data-[active=true]:text-primary",n),onClick:d,"aria-label":e.label,"aria-current":l?"page":void 0,children:[e.icon&&jsxRuntime.jsx("span",{className:"flex items-center justify-center",children:e.icon}),jsxRuntime.jsx("span",{className:"truncate",children:e.label})]}):jsxRuntime.jsx("button",{type:"button","data-active":l,className:ui.cn("h-8 text-sm font-medium px-2 xl:px-3 rounded-sm cursor-pointer","text-foreground hover:text-primary hover:bg-primary-50","data-[active=true]:text-primary",n),onClick:d,"aria-label":e.label,"aria-current":l?"page":void 0,children:e.label})}function Jr({children:e,left:t,right:n,navItems:a,className:r}){return e?jsxRuntime.jsx("header",{className:ui.cn("w-full h-full flex items-center bg-background border-b border-border",r),children:e}):jsxRuntime.jsxs("header",{className:ui.cn("w-full h-full px-6 max-lg:px-4 flex items-center justify-between gap-6 max-lg:gap-4 bg-background border-b border-border",r),children:[t&&jsxRuntime.jsx("div",{className:"shrink-0 flex items-center",children:t}),a&&a.length>0&&jsxRuntime.jsx(ui.HorizontalScrollContainer,{className:"flex-auto min-w-0 max-sm:hidden",classNames:{content:"gap-1"},children:a.map(l=>jsxRuntime.jsx(it,{item:l,variant:"header"},l.key))}),n&&jsxRuntime.jsx("div",{className:"shrink-0 flex items-center gap-4",children:n})]})}function oi({children:e,navItems:t,className:n}){return e?jsxRuntime.jsx("footer",{className:ui.cn("w-full h-full flex items-center bg-background border-t border-border",n),children:e}):jsxRuntime.jsx("footer",{className:ui.cn("w-full h-full flex justify-evenly items-center bg-background border-t border-border",n),children:t?.map(a=>jsxRuntime.jsx(it,{item:a,variant:"footer"},a.key))})}function ai({children:e,left:t,right:n,className:a}){return e?jsxRuntime.jsx("div",{className:ui.cn("w-full h-full flex items-center bg-background border-t border-border",a),children:e}):jsxRuntime.jsxs("div",{className:ui.cn("w-full h-full px-6 flex items-center justify-between gap-4 bg-background border-t border-border",a),children:[t&&jsxRuntime.jsx("div",{className:"flex items-center gap-4",children:t}),n&&jsxRuntime.jsx("div",{className:"flex items-center gap-4",children:n})]})}function ci({href:e="/",icon:t,miniIcon:n,className:a}){let{t:r}=i18n.useTranslation();return jsxRuntime.jsxs(ui.Link,{href:e,className:ui.cn("flex-none flex justify-center items-center",a),"aria-label":r("scaffold.home"),children:[jsxRuntime.jsx("div",{className:ui.cn("flex justify-center items-center",!!n&&"max-xl:hidden"),children:t}),n&&jsxRuntime.jsx("div",{className:"flex justify-center items-center xl:hidden",children:n})]})}function Si({id:e,children:t}){let n=hooks.useEventEmitter(),{isOpen:a,onOpen:r,onClose:l,onOpenChange:d}=ui.useDisclosure(),[o,i]=react.useState(void 0),p=react.useRef(void 0),m=react.useCallback(()=>{p.current=void 0,i(void 0);},[]),c=react.useCallback(()=>{p.current?.(void 0),m(),l();},[l,m]),x=react.useCallback(h=>{p.current?.(h),m(),l();},[l,m]),y=react.useCallback(h=>{h||c();},[c]);return react.useEffect(()=>{let h=S=>{i(S?.params),p.current=S?.onResult,r();};return n.on(`open_modal:${e}`,h),()=>{n.off(`open_modal:${e}`,h);}},[e,r,n]),react.useEffect(()=>{let h=()=>{c();};return n.on(`close_modal:${e}`,h),()=>{n.off(`close_modal:${e}`,h);}},[e,c,n]),t({params:o,isOpen:a,onClose:c,onOpenChange:y,onResult:x})}function ki(e){let t=hooks.useEventEmitter(),n=react.useCallback(r=>new Promise(l=>{let d=o=>{r?.onResult?.(o),l(o);};t.emit(`open_modal:${e}`,{...r,onResult:d});}),[e,t]),a=react.useCallback(()=>{t.emit(`close_modal:${e}`);},[e,t]);return {onOpen:n,onClose:a}}function ro({direction:e,isResizing:t,onResizeStart:n,className:a}){let r=e==="horizontal";return jsxRuntime.jsxs("div",{className:ui.cn("relative flex-none",a),children:[jsxRuntime.jsxs("div",{className:ui.cn("flex items-center justify-center bg-border/80 hover:bg-border transition-colors duration-150 ease-in-out",r?"w-1 h-full cursor-ew-resize flex-col gap-1":"w-full h-1 cursor-ns-resize flex-row gap-1"),children:[jsxRuntime.jsx("i",{className:"rounded-full w-0.5 h-0.5 bg-neutral"}),jsxRuntime.jsx("i",{className:"rounded-full w-0.5 h-0.5 bg-neutral"}),jsxRuntime.jsx("i",{className:"rounded-full w-0.5 h-0.5 bg-neutral"}),jsxRuntime.jsx("div",{className:ui.cn("absolute inset-0",r?"-left-1.5 -right-1.5 cursor-ew-resize":"-top-1.5 -bottom-1.5 cursor-ns-resize"),onMouseDown:n})]}),t&&jsxRuntime.jsx("div",{className:ui.cn("fixed inset-0 z-50",r?"cursor-ew-resize":"cursor-ns-resize")})]})}var Rn=4;function Mn(e){if(!e)return null;try{let t=localStorage.getItem(`splitView.${e}`);return t?Number(t):null}catch{return null}}function zn(e,t){if(e)try{localStorage.setItem(`splitView.${e}`,String(t));}catch{}}function _i({direction:e="horizontal",primary:t,secondary:n,defaultSize:a=400,minSize:r=100,maxSize:l=1/0,secondaryMinSize:d=100,onSizeChange:o,persistId:i,className:p,classNames:m}){let c=react.useRef(null),[x,y]=react.useState(()=>Mn(i)??a),[h,S]=react.useState(false),v=e==="horizontal",L=hooks.useValueRef(x),_=hooks.useValueRef(r),ee=hooks.useValueRef(l),M=hooks.useValueRef(d),C=hooks.useValueRef(h),b=hooks.useCallbackRef(u=>{y(u),zn(i,u),o?.(u);}),ue=react.useCallback(u=>{u.preventDefault(),u.stopPropagation(),S(true);let De=v?"ew-resize":"ns-resize";document.body.style.cursor=De,document.body.style.userSelect="none";let te=v?u.clientX:u.clientY,oe=L.current,X=c.current,j=X?v?X.offsetWidth:X.offsetHeight:1/0,ne=z=>{if(!C.current)return;let ce=(v?z.clientX:z.clientY)-te,w=Math.min(ee.current,j-M.current-Rn),D=Math.min(Math.max(oe+ce,_.current),w);b(D);},re=()=>{S(false),document.body.style.cursor="",document.body.style.userSelect="",document.removeEventListener("mousemove",ne),document.removeEventListener("mouseup",re);};document.addEventListener("mousemove",ne),document.addEventListener("mouseup",re);},[v,L,_,ee,M,C,b]);return jsxRuntime.jsxs("div",{ref:c,className:ui.cn("w-full h-full flex overflow-hidden",v?"flex-row":"flex-col",p),children:[jsxRuntime.jsx("div",{className:ui.cn("flex-none overflow-hidden",m?.primary),style:v?{width:`${x}px`,minWidth:`${r}px`}:{height:`${x}px`,minHeight:`${r}px`},children:t}),jsxRuntime.jsx(ro,{direction:e,isResizing:h,onResizeStart:ue,className:m?.handle}),jsxRuntime.jsx("div",{className:ui.cn("flex-auto min-w-0 min-h-0 overflow-hidden",m?.secondary),style:v?{minWidth:`${d}px`}:{minHeight:`${d}px`},children:n})]})}typeof window<"u"&&(window.__LIBERFI_VERSION__=window.__LIBERFI_VERSION__||{},window.__LIBERFI_VERSION__["@liberfi.io/ui-scaffold"]="0.1.37");var Pn="0.1.37";exports.ALL_BREAKPOINTS=Zt;exports.AsyncModal=Si;exports.DraggableModal=At;exports.DraggablePanel=gt;exports.DraggablePanelProvider=hr;exports.Logo=ci;exports.NavLink=it;exports.Scaffold=Ar;exports.ScaffoldContext=xt;exports.ScaffoldFooter=oi;exports.ScaffoldHeader=Jr;exports.ScaffoldToolbar=ai;exports.SplitHandle=ro;exports.SplitView=_i;exports.getVisibilityClass=rt;exports.isNavItemActive=jt;exports.useAsyncModal=ki;exports.useDraggableDisclosure=Mr;exports.useDraggableModalDisclosure=we;exports.useDraggablePanelDisclosure=Re;exports.useScaffold=yt;exports.useScaffoldLayout=Cr;exports.version=Pn;//# sourceMappingURL=index.js.map
|
|
2
2
|
//# sourceMappingURL=index.js.map
|