@kushagradhawan/kookie-ui 0.1.49 → 0.1.50
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/components.css +235 -64
- package/dist/cjs/components/_internal/shell-sidebar.d.ts.map +1 -1
- package/dist/cjs/components/_internal/shell-sidebar.js +1 -1
- package/dist/cjs/components/_internal/shell-sidebar.js.map +3 -3
- package/dist/cjs/components/shell.context.d.ts +1 -0
- package/dist/cjs/components/shell.context.d.ts.map +1 -1
- package/dist/cjs/components/shell.context.js +1 -1
- package/dist/cjs/components/shell.context.js.map +2 -2
- package/dist/cjs/components/shell.d.ts.map +1 -1
- package/dist/cjs/components/shell.js +1 -1
- package/dist/cjs/components/shell.js.map +3 -3
- package/dist/cjs/components/sidebar.d.ts +7 -1
- package/dist/cjs/components/sidebar.d.ts.map +1 -1
- package/dist/cjs/components/sidebar.js +1 -1
- package/dist/cjs/components/sidebar.js.map +3 -3
- package/dist/esm/components/_internal/shell-sidebar.d.ts.map +1 -1
- package/dist/esm/components/_internal/shell-sidebar.js +1 -1
- package/dist/esm/components/_internal/shell-sidebar.js.map +3 -3
- package/dist/esm/components/shell.context.d.ts +1 -0
- package/dist/esm/components/shell.context.d.ts.map +1 -1
- package/dist/esm/components/shell.context.js.map +2 -2
- package/dist/esm/components/shell.d.ts.map +1 -1
- package/dist/esm/components/shell.js +1 -1
- package/dist/esm/components/shell.js.map +3 -3
- package/dist/esm/components/sidebar.d.ts +7 -1
- package/dist/esm/components/sidebar.d.ts.map +1 -1
- package/dist/esm/components/sidebar.js +1 -1
- package/dist/esm/components/sidebar.js.map +3 -3
- package/package.json +1 -1
- package/schemas/base-button.json +1 -1
- package/schemas/button.json +1 -1
- package/schemas/icon-button.json +1 -1
- package/schemas/index.json +6 -6
- package/schemas/toggle-button.json +1 -1
- package/schemas/toggle-icon-button.json +1 -1
- package/src/components/_internal/base-menu.css +4 -5
- package/src/components/_internal/base-sidebar-menu.css +0 -1
- package/src/components/_internal/base-sidebar.css +7 -0
- package/src/components/_internal/shell-sidebar.tsx +24 -1
- package/src/components/shell.context.tsx +3 -0
- package/src/components/shell.css +28 -1
- package/src/components/shell.tsx +24 -3
- package/src/components/sidebar.css +233 -33
- package/src/components/sidebar.tsx +247 -213
- package/styles.css +235 -64
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";"use client";var
|
|
1
|
+
"use strict";"use client";var ne=Object.create;var x=Object.defineProperty;var ae=Object.getOwnPropertyDescriptor;var ie=Object.getOwnPropertyNames;var se=Object.getPrototypeOf,de=Object.prototype.hasOwnProperty;var ue=(r,t)=>{for(var o in t)x(r,o,{get:t[o],enumerable:!0})},Q=(r,t,o,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of ie(t))!de.call(r,i)&&i!==o&&x(r,i,{get:()=>t[i],enumerable:!(n=ae(t,i))||n.enumerable});return r};var E=(r,t,o)=>(o=r!=null?ne(se(r)):{},Q(t||!r||!r.__esModule?x(o,"default",{value:r,enumerable:!0}):o,r)),pe=r=>Q(x({},"__esModule",{value:!0}),r);var le={};ue(le,{Content:()=>I,Footer:()=>V,Group:()=>j,GroupContent:()=>q,GroupLabel:()=>O,Header:()=>G,Menu:()=>W,MenuButton:()=>F,MenuItem:()=>k,MenuSub:()=>$,MenuSubContent:()=>K,MenuSubTrigger:()=>_,Root:()=>D,Separator:()=>A});module.exports=pe(le);var e=E(require("react")),u=E(require("classnames")),z=require("./slot.js"),P=E(require("@radix-ui/react-accordion")),C=E(require("./dropdown-menu.js")),y=require("./sidebar.props.js"),Y=require("./theme.js"),Z=require("./scroll-area.js"),ee=require("./separator.js"),re=require("./icons.js"),te=require("../helpers/extract-props.js"),R=require("./kbd.js"),N=require("./badge.js");const X=e.createContext(null);function v(){return e.useContext(X)}const D=e.forwardRef((r,t)=>{const o=(0,Y.useThemeContext)(),{size:n=y.sidebarPropDefs.size.default,variant:i=y.sidebarPropDefs.variant.default,menuVariant:m=y.sidebarPropDefs.menuVariant.default,layout:p=y.sidebarPropDefs.layout.default,presentation:c,panelBackground:a,color:f,highContrast:d=y.sidebarPropDefs.highContrast.default}=r,{className:g,children:B,...U}=(0,te.extractProps)(r,y.sidebarPropDefs),{asChild:b,panelBackground:J,presentation:T,...H}=U,M=f||o.accentColor,S=c==="thin"?"rail":c==="expanded"?"panel":p||"panel",w=typeof n=="object"?n.initial||"2":n;return e.createElement("div",{...H,ref:t,"data-accent-color":M,className:(0,u.default)("rt-SidebarRoot",g)},e.createElement(X.Provider,{value:{size:w,menuVariant:m,presentation:c,color:M}},e.createElement("div",{className:(0,u.default)("rt-SidebarContainer",`rt-variant-${i}`,`rt-r-size-${w}`,`rt-menu-variant-${m}`,S&&`rt-layout-${S}`),"data-accent-color":M,"data-high-contrast":d||void 0,"data-panel-background":a,"data-presentation":c,"data-layout":S},B)))});D.displayName="Sidebar.Root";const I=e.forwardRef(({className:r,children:t,role:o="navigation","aria-label":n="Main navigation",id:i,...m},p)=>{const c=v(),a=c?.size??"2",f=c?.menuVariant??"soft";return e.createElement(Z.ScrollArea,{type:"hover"},e.createElement("div",{...m,ref:p,id:i,role:o,"aria-label":n,className:(0,u.default)("rt-BaseMenuContent","rt-SidebarContent",`rt-r-size-${a}`,`rt-menu-variant-${f}`,r)},e.createElement("div",{className:"rt-BaseMenuViewport"},t)))});I.displayName="Sidebar.Content";const G=e.forwardRef(({className:r,asContainer:t=!0,...o},n)=>{const i=v(),m=i?.size??"2",p=i?.menuVariant??"soft";return e.createElement("div",{...o,ref:n,className:(0,u.default)("rt-SidebarHeader",`rt-r-size-${m}`,`rt-menu-variant-${p}`,{"rt-SidebarHeader--container":t},r)})});G.displayName="Sidebar.Header";const V=e.forwardRef(({className:r,asContainer:t=!0,...o},n)=>{const i=v(),m=i?.size??"2",p=i?.menuVariant??"soft";return e.createElement("div",{...o,ref:n,className:(0,u.default)("rt-SidebarFooter",`rt-r-size-${m}`,`rt-menu-variant-${p}`,{"rt-SidebarFooter--container":t},r)})});V.displayName="Sidebar.Footer";const A=e.forwardRef(({className:r,...t},o)=>e.createElement(ee.Separator,{...t,ref:o,className:(0,u.default)("rt-SidebarSeparator",r)}));A.displayName="Sidebar.Separator";const W=e.forwardRef(({className:r,...t},o)=>e.createElement("ul",{...t,ref:o,role:"menu",className:(0,u.default)("rt-SidebarMenu",r)}));W.displayName="Sidebar.Menu";const k=e.forwardRef(({className:r,...t},o)=>e.createElement("li",{...t,ref:o,className:(0,u.default)("rt-SidebarMenuItem",r)}));k.displayName="Sidebar.MenuItem";const F=e.forwardRef(({asChild:r=!1,isActive:t=!1,shortcut:o,badge:n,className:i,children:m,onMouseEnter:p,onMouseLeave:c,onKeyDown:a,...f},d)=>{const[g,B]=e.useState(!1),b=v()?.size??"2",J=r?z.Slot:"button",{onClick:T}=f,H=e.useCallback(s=>{switch(s.key){case"Enter":case" ":s.preventDefault(),T&&T(s);break;case"ArrowDown":{s.preventDefault();const l=s.currentTarget.nextElementSibling?.querySelector('[role="menuitem"]');l&&l.focus();break}case"ArrowUp":{s.preventDefault();const l=s.currentTarget.previousElementSibling?.querySelector('[role="menuitem"]');l&&l.focus();break}}a?.(s)},[T,a]),M=s=>{if(typeof s=="string"||typeof s=="number")return e.createElement("span",{className:"rt-SidebarMenuLabel"},s);if(Array.isArray(s))return s.map((l,h)=>e.createElement(e.Fragment,{key:h},M(l)));if(e.isValidElement(s)){const l=s,h=l.props&&l.props.className||"";if(typeof l.type=="string"&&h.split(" ").includes("rt-SidebarMenuLabel"))return l;const oe=M(l.props?.children);return e.cloneElement(l,{...l.props},oe)}return s},S=M(m),w=e.useMemo(()=>{if(!r)return null;try{const s=e.Children.only(S),l=s.props?.children,h=e.createElement(e.Fragment,null,l,n&&e.createElement("div",{className:"rt-SidebarMenuBadge"},typeof n=="string"?e.createElement(N.Badge,{size:b,variant:"soft"},n):e.createElement(N.Badge,{size:n.size||b,variant:n.variant||"soft",color:n.color,highContrast:n.highContrast,radius:n.radius},n.content)),o&&e.createElement("div",{className:"rt-BaseMenuShortcut rt-SidebarMenuShortcut"},e.createElement(R.Kbd,{size:b},o)));return e.cloneElement(s,{...s.props},h)}catch{return S}},[r,S,n,o,b]);return e.createElement(J,{...f,ref:d,role:"menuitem","aria-current":t?"page":void 0,className:(0,u.default)("rt-reset","rt-BaseMenuItem","rt-SidebarMenuButton",i),"data-active":t||void 0,"data-highlighted":g||void 0,onKeyDown:H,onMouseEnter:s=>{B(!0),p?.(s)},onMouseLeave:s=>{B(!1),c?.(s)}},r?w:e.createElement(e.Fragment,null,S,n&&e.createElement("div",{className:"rt-SidebarMenuBadge"},typeof n=="string"?e.createElement(N.Badge,{size:b,variant:"soft"},n):e.createElement(N.Badge,{size:n.size||b,variant:n.variant||"soft",color:n.color,highContrast:n.highContrast,radius:n.radius},n.content)),o&&e.createElement("div",{className:"rt-BaseMenuShortcut rt-SidebarMenuShortcut"},e.createElement(R.Kbd,{size:b},o))))});F.displayName="Sidebar.MenuButton";const L=e.createContext("accordion"),$=e.forwardRef(({defaultOpen:r=!1,children:t,...o},n)=>(v()?.presentation==="thin"?"dropdown":"accordion")==="dropdown"?e.createElement("div",{...o,ref:n},e.createElement(C.Root,null,e.createElement(L.Provider,{value:"dropdown"},t))):e.createElement("div",{...o,ref:n},e.createElement(L.Provider,{value:"accordion"},e.createElement(P.Root,{type:"single",collapsible:!0,defaultValue:r?"item":void 0},e.createElement(P.Item,{value:"item"},t)))));$.displayName="Sidebar.MenuSub";const _=e.forwardRef(({asChild:r=!1,className:t,children:o,onMouseEnter:n,onMouseLeave:i,...m},p)=>{const[c,a]=e.useState(!1);return e.useContext(L)==="dropdown"?e.createElement(C.Trigger,null,e.createElement("button",{...m,ref:p,type:"button",role:"menuitem","aria-haspopup":"menu",className:(0,u.default)("rt-reset","rt-BaseMenuItem","rt-SidebarMenuButton","rt-SidebarMenuSubTrigger",t),"data-highlighted":c||void 0,onMouseEnter:d=>{a(!0),n?.(d)},onMouseLeave:d=>{a(!1),i?.(d)}},o)):e.createElement(P.Header,{asChild:!0},e.createElement("div",null,e.createElement(P.Trigger,{...m,ref:p,asChild:r,role:"menuitem","aria-haspopup":"true",className:(0,u.default)("rt-reset","rt-BaseMenuItem","rt-SidebarMenuButton","rt-SidebarMenuSubTrigger",t),"data-highlighted":c||void 0,onMouseEnter:d=>{a(!0),n?.(d)},onMouseLeave:d=>{a(!1),i?.(d)}},r?o:e.createElement(e.Fragment,null,o,e.createElement(re.ThickChevronRightIcon,{className:(0,u.default)("rt-BaseMenuSubTriggerIcon","rt-SidebarMenuSubTriggerIcon")})))))});_.displayName="Sidebar.MenuSubTrigger";const K=e.forwardRef(({className:r,children:t,...o},n)=>{const i=v();if(e.useContext(L)==="dropdown"){const p=a=>{if(Array.isArray(a))return a.map((f,d)=>e.createElement(e.Fragment,{key:d},p(f)));if(e.isValidElement(a)){if(a.type?.displayName==="Sidebar.MenuButton")return a.props?.children;const d=a.props?.children;if(d!==void 0)return e.cloneElement(a,{...a.props,children:p(d)})}return a},c=e.Children.map(t,(a,f)=>{if(e.isValidElement(a)&&a.type?.displayName==="Sidebar.MenuItem"){const d=a.props?.children,g=p(d);return e.createElement(C.Item,{key:f,asChild:!0},g)}return e.createElement(C.Item,{key:f,asChild:!0},p(a))});return e.createElement(C.Content,{size:i?.size,variant:i?.menuVariant,className:(0,u.default)(r)},e.createElement(C.Group,null,c))}return e.createElement(P.Content,{...o,ref:n,className:(0,u.default)("rt-SidebarMenuSubContent",r)},e.createElement("div",{className:"rt-SidebarMenuSubList"},t))});K.displayName="Sidebar.MenuSubContent";const j=e.forwardRef(({className:r,...t},o)=>e.createElement("div",{...t,ref:o,className:(0,u.default)("rt-BaseMenuGroup","rt-SidebarGroup",r)}));j.displayName="Sidebar.Group";const O=e.forwardRef(({asChild:r=!1,className:t,...o},n)=>e.createElement(r?z.Slot:"div",{...o,ref:n,role:"group",className:(0,u.default)("rt-BaseMenuLabel","rt-SidebarGroupLabel",t)}));O.displayName="Sidebar.GroupLabel";const q=e.forwardRef(({className:r,...t},o)=>e.createElement("div",{...t,ref:o,className:(0,u.default)("rt-SidebarGroupContent",r)}));q.displayName="Sidebar.GroupContent";
|
|
2
2
|
//# sourceMappingURL=sidebar.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/sidebar.tsx"],
|
|
4
|
-
"sourcesContent": ["'use client';\n\nimport * as React from 'react';\nimport classNames from 'classnames';\nimport { Slot } from './slot.js';\nimport * as Accordion from '@radix-ui/react-accordion';\n\nimport { sidebarPropDefs } from './sidebar.props.js';\nimport { useThemeContext } from './theme.js';\n// import { IconButton } from './icon-button.js';\nimport { ScrollArea } from './scroll-area.js';\nimport { Separator } from './separator.js';\nimport { ThickChevronRightIcon } from './icons.js';\nimport { extractProps } from '../helpers/extract-props.js';\nimport { Kbd } from './kbd.js';\nimport { Badge } from './badge.js';\n\nimport type { ComponentPropsWithout, RemovedProps } from '../helpers/component-props.js';\nimport type { GetPropDefTypes } from '../props/prop-def.js';\nimport type { BadgeProps } from './badge.js';\n\n// Badge configuration type for sidebar menu buttons\ntype BadgeConfig = {\n content: React.ReactNode;\n variant?: BadgeProps['variant'];\n size?: BadgeProps['size'];\n color?: BadgeProps['color'];\n highContrast?: BadgeProps['highContrast'];\n radius?: BadgeProps['radius'];\n};\n\n// Internal presentational context (not exported) for size/menu variant\ntype SidebarVisualContextValue = {\n size: '1' | '2';\n menuVariant: 'solid' | 'soft';\n};\nconst SidebarVisualContext = React.createContext<SidebarVisualContextValue | null>(null);\nfunction useSidebarVisual() {\n return React.useContext(SidebarVisualContext);\n}\n\n// Sidebar is now independent of Shell - no integration needed\n\n// Main Sidebar component\ntype SidebarOwnProps = GetPropDefTypes<typeof sidebarPropDefs>;\ninterface SidebarProps extends ComponentPropsWithout<'div', RemovedProps>, SidebarOwnProps {}\n\nconst Sidebar = React.forwardRef<HTMLDivElement, SidebarProps>((props, forwardedRef) => {\n const themeContext = useThemeContext();\n\n const {\n size = sidebarPropDefs.size.default,\n variant = sidebarPropDefs.variant.default,\n menuVariant = sidebarPropDefs.menuVariant.default,\n layout = sidebarPropDefs.layout.default,\n // type = sidebarPropDefs.type.default,\n // side = sidebarPropDefs.side.default,\n // collapsible = sidebarPropDefs.collapsible.default,\n panelBackground,\n color,\n highContrast = sidebarPropDefs.highContrast.default,\n } = props;\n\n const { className, children, ...rootProps } = extractProps(props, sidebarPropDefs);\n const { asChild: _, panelBackground: __, ...safeRootProps } = rootProps; // Remove asChild and panelBackground from DOM props\n const resolvedColor = color || themeContext.accentColor;\n\n // Resolve layout (default to 'panel')\n const resolvedLayout = layout || 'panel';\n\n // Update context with current props - we'll pass the resolved values\n const resolvedSize = typeof size === 'object' ? size.initial || '2' : size;\n return (\n <div\n {...safeRootProps}\n ref={forwardedRef}\n data-accent-color={resolvedColor}\n className={classNames('rt-SidebarRoot', className)}\n >\n <SidebarVisualContext.Provider value={{ size: resolvedSize, menuVariant }}>\n <div\n className={classNames(\n 'rt-SidebarContainer',\n `rt-variant-${variant}`,\n `rt-r-size-${resolvedSize}`,\n `rt-menu-variant-${menuVariant}`,\n resolvedLayout && `rt-layout-${resolvedLayout}`,\n )}\n data-accent-color={resolvedColor}\n data-high-contrast={highContrast || undefined}\n data-panel-background={panelBackground}\n data-layout={resolvedLayout}\n >\n {children}\n </div>\n </SidebarVisualContext.Provider>\n </div>\n );\n});\nSidebar.displayName = 'Sidebar.Root';\n\n// Sidebar content area\ninterface SidebarContentProps extends React.ComponentPropsWithoutRef<'div'> {\n id?: string;\n role?: 'navigation' | 'none';\n 'aria-label'?: string;\n}\n\nconst SidebarContent = React.forwardRef<HTMLDivElement, SidebarContentProps>(\n (\n {\n className,\n children,\n role = 'navigation',\n 'aria-label': ariaLabel = 'Main navigation',\n id,\n ...props\n },\n forwardedRef,\n ) => {\n const visual = useSidebarVisual();\n const size = visual?.size ?? '2';\n const menuVariant = visual?.menuVariant ?? 'soft';\n\n return (\n <ScrollArea type=\"hover\">\n <div\n {...props}\n ref={forwardedRef}\n id={id}\n role={role}\n aria-label={ariaLabel}\n className={classNames(\n 'rt-BaseMenuContent',\n 'rt-SidebarContent',\n `rt-r-size-${size}`,\n `rt-menu-variant-${menuVariant}`,\n className,\n )}\n >\n <div className=\"rt-BaseMenuViewport\">{children}</div>\n </div>\n </ScrollArea>\n );\n },\n);\nSidebarContent.displayName = 'Sidebar.Content';\n\n// Sidebar header\ninterface SidebarHeaderProps extends React.ComponentPropsWithoutRef<'div'> {\n /**\n * Whether to use the default flex container layout.\n * @default true\n */\n asContainer?: boolean;\n}\n\nconst SidebarHeader = React.forwardRef<HTMLDivElement, SidebarHeaderProps>(\n ({ className, asContainer = true, ...props }, forwardedRef) => {\n const visual = useSidebarVisual();\n const size = visual?.size ?? '2';\n const menuVariant = visual?.menuVariant ?? 'soft';\n\n return (\n <div\n {...props}\n ref={forwardedRef}\n className={classNames(\n 'rt-SidebarHeader',\n `rt-r-size-${size}`,\n `rt-menu-variant-${menuVariant}`,\n {\n 'rt-SidebarHeader--container': asContainer,\n },\n className,\n )}\n />\n );\n },\n);\nSidebarHeader.displayName = 'Sidebar.Header';\n\n// Sidebar footer\ninterface SidebarFooterProps extends React.ComponentPropsWithoutRef<'div'> {\n /**\n * Whether to use the default flex container layout.\n * @default true\n */\n asContainer?: boolean;\n}\n\nconst SidebarFooter = React.forwardRef<HTMLDivElement, SidebarFooterProps>(\n ({ className, asContainer = true, ...props }, forwardedRef) => {\n const visual = useSidebarVisual();\n const size = visual?.size ?? '2';\n const menuVariant = visual?.menuVariant ?? 'soft';\n\n return (\n <div\n {...props}\n ref={forwardedRef}\n className={classNames(\n 'rt-SidebarFooter',\n `rt-r-size-${size}`,\n `rt-menu-variant-${menuVariant}`,\n {\n 'rt-SidebarFooter--container': asContainer,\n },\n className,\n )}\n />\n );\n },\n);\nSidebarFooter.displayName = 'Sidebar.Footer';\n\n// Sidebar trigger button\n// removed Trigger in presentational-only Sidebar\n\n// Removed SidebarInset - not needed\n\n// Sidebar separator\ninterface SidebarSeparatorProps extends ComponentPropsWithout<typeof Separator, RemovedProps> {}\n\nconst SidebarSeparator = React.forwardRef<\n React.ComponentRef<typeof Separator>,\n SidebarSeparatorProps\n>(({ className, ...props }, forwardedRef) => (\n <Separator\n {...props}\n ref={forwardedRef}\n className={classNames('rt-SidebarSeparator', className)}\n />\n));\nSidebarSeparator.displayName = 'Sidebar.Separator';\n\n// Menu components - reusing dropdown menu structure\ninterface SidebarMenuProps extends React.ComponentPropsWithoutRef<'ul'> {}\n\nconst SidebarMenu = React.forwardRef<HTMLUListElement, SidebarMenuProps>(\n ({ className, ...props }, forwardedRef) => (\n <ul\n {...props}\n ref={forwardedRef}\n role=\"menu\"\n className={classNames('rt-SidebarMenu', className)}\n />\n ),\n);\nSidebarMenu.displayName = 'Sidebar.Menu';\n\ninterface SidebarMenuItemProps extends React.ComponentPropsWithoutRef<'li'> {}\n\nconst SidebarMenuItem = React.forwardRef<HTMLLIElement, SidebarMenuItemProps>(\n ({ className, ...props }, forwardedRef) => (\n <li {...props} ref={forwardedRef} className={classNames('rt-SidebarMenuItem', className)} />\n ),\n);\nSidebarMenuItem.displayName = 'Sidebar.MenuItem';\n\ninterface SidebarMenuButtonProps extends React.ComponentPropsWithoutRef<'button'> {\n asChild?: boolean;\n isActive?: boolean;\n shortcut?: React.ReactNode;\n badge?: string | BadgeConfig;\n}\n\nconst SidebarMenuButton = React.forwardRef<HTMLButtonElement, SidebarMenuButtonProps>(\n (\n {\n asChild = false,\n isActive = false,\n shortcut,\n badge,\n className,\n children,\n onMouseEnter,\n onMouseLeave,\n onKeyDown,\n ...props\n },\n forwardedRef,\n ) => {\n const [isHighlighted, setIsHighlighted] = React.useState(false);\n const visual = useSidebarVisual();\n const sidebarSize = visual?.size ?? '2';\n\n const Comp = asChild ? Slot : 'button';\n\n const { onClick } = props;\n const handleKeyDown = React.useCallback(\n (event: React.KeyboardEvent<HTMLButtonElement>) => {\n switch (event.key) {\n case 'Enter':\n case ' ':\n event.preventDefault();\n if (onClick) onClick(event as any);\n break;\n case 'ArrowDown': {\n event.preventDefault();\n // Focus next menu item\n const nextItem = (event.currentTarget as HTMLElement).nextElementSibling?.querySelector(\n '[role=\"menuitem\"]',\n ) as HTMLElement;\n if (nextItem) nextItem.focus();\n break;\n }\n case 'ArrowUp': {\n event.preventDefault();\n // Focus previous menu item\n const prevItem = (\n event.currentTarget as HTMLElement\n ).previousElementSibling?.querySelector('[role=\"menuitem\"]') as HTMLElement;\n if (prevItem) prevItem.focus();\n break;\n }\n }\n onKeyDown?.(event);\n },\n [onClick, onKeyDown],\n );\n\n return (\n <Comp\n {...props}\n ref={forwardedRef}\n role=\"menuitem\"\n aria-current={isActive ? 'page' : undefined}\n className={classNames('rt-reset', 'rt-BaseMenuItem', 'rt-SidebarMenuButton', className)}\n data-active={isActive || undefined}\n data-highlighted={isHighlighted || undefined}\n onKeyDown={handleKeyDown}\n onMouseEnter={(event) => {\n setIsHighlighted(true);\n onMouseEnter?.(event);\n }}\n onMouseLeave={(event) => {\n setIsHighlighted(false);\n onMouseLeave?.(event);\n }}\n >\n {asChild ? (\n children\n ) : (\n <>\n {children}\n {/* Badge with soft variant default and size mapping to sidebar size */}\n {badge && (\n <div className=\"rt-SidebarMenuBadge\">\n {typeof badge === 'string' ? (\n <Badge size={sidebarSize} variant=\"soft\">\n {badge}\n </Badge>\n ) : (\n <Badge\n size={badge.size || sidebarSize}\n variant={badge.variant || 'soft'}\n color={badge.color}\n highContrast={badge.highContrast}\n radius={badge.radius}\n >\n {badge.content}\n </Badge>\n )}\n </div>\n )}\n {shortcut && (\n <div className=\"rt-BaseMenuShortcut rt-SidebarMenuShortcut\">\n <Kbd size={sidebarSize}>{shortcut}</Kbd>\n </div>\n )}\n </>\n )}\n </Comp>\n );\n },\n);\nSidebarMenuButton.displayName = 'Sidebar.MenuButton';\n\n// Sub-menu components using Radix Accordion\ninterface SidebarMenuSubProps extends React.ComponentPropsWithoutRef<'div'> {\n defaultOpen?: boolean;\n}\n\nconst SidebarMenuSub = React.forwardRef<HTMLDivElement, SidebarMenuSubProps>(\n ({ defaultOpen = false, children, ...props }, forwardedRef) => {\n return (\n <div {...props} ref={forwardedRef}>\n <Accordion.Root type=\"single\" collapsible defaultValue={defaultOpen ? 'item' : undefined}>\n <Accordion.Item value=\"item\">{children}</Accordion.Item>\n </Accordion.Root>\n </div>\n );\n },\n);\nSidebarMenuSub.displayName = 'Sidebar.MenuSub';\n\ninterface SidebarMenuSubTriggerProps\n extends React.ComponentPropsWithoutRef<typeof Accordion.Trigger> {\n asChild?: boolean;\n}\n\nconst SidebarMenuSubTrigger = React.forwardRef<\n React.ElementRef<typeof Accordion.Trigger>,\n SidebarMenuSubTriggerProps\n>(\n (\n { asChild = false, className, children, onMouseEnter, onMouseLeave, ...props },\n forwardedRef,\n ) => {\n const [isHighlighted, setIsHighlighted] = React.useState(false);\n\n return (\n <Accordion.Header asChild>\n <div>\n <Accordion.Trigger\n {...props}\n ref={forwardedRef}\n asChild={asChild}\n role=\"menuitem\"\n aria-haspopup=\"true\"\n className={classNames(\n 'rt-reset',\n 'rt-BaseMenuItem',\n 'rt-SidebarMenuButton',\n 'rt-SidebarMenuSubTrigger',\n className,\n )}\n data-highlighted={isHighlighted || undefined}\n onMouseEnter={(event) => {\n setIsHighlighted(true);\n onMouseEnter?.(event);\n }}\n onMouseLeave={(event) => {\n setIsHighlighted(false);\n onMouseLeave?.(event);\n }}\n >\n {asChild ? (\n children\n ) : (\n <>\n {children}\n <ThickChevronRightIcon\n className={classNames(\n 'rt-BaseMenuSubTriggerIcon',\n 'rt-SidebarMenuSubTriggerIcon',\n )}\n />\n </>\n )}\n </Accordion.Trigger>\n </div>\n </Accordion.Header>\n );\n },\n);\nSidebarMenuSubTrigger.displayName = 'Sidebar.MenuSubTrigger';\n\ninterface SidebarMenuSubContentProps\n extends React.ComponentPropsWithoutRef<typeof Accordion.Content> {}\n\nconst SidebarMenuSubContent = React.forwardRef<\n React.ElementRef<typeof Accordion.Content>,\n SidebarMenuSubContentProps\n>(({ className, children, ...props }, forwardedRef) => {\n return (\n <Accordion.Content\n {...props}\n ref={forwardedRef}\n className={classNames('rt-SidebarMenuSubContent', className)}\n >\n <div className=\"rt-SidebarMenuSubList\">{children}</div>\n </Accordion.Content>\n );\n});\nSidebarMenuSubContent.displayName = 'Sidebar.MenuSubContent';\n\n// Group components\ninterface SidebarGroupProps extends React.ComponentPropsWithoutRef<'div'> {}\n\nconst SidebarGroup = React.forwardRef<HTMLDivElement, SidebarGroupProps>(\n ({ className, ...props }, forwardedRef) => (\n <div\n {...props}\n ref={forwardedRef}\n className={classNames('rt-BaseMenuGroup', 'rt-SidebarGroup', className)}\n />\n ),\n);\nSidebarGroup.displayName = 'Sidebar.Group';\n\ninterface SidebarGroupLabelProps extends React.ComponentPropsWithoutRef<'div'> {\n asChild?: boolean;\n}\n\nconst SidebarGroupLabel = React.forwardRef<HTMLDivElement, SidebarGroupLabelProps>(\n ({ asChild = false, className, ...props }, forwardedRef) => {\n const Comp = asChild ? Slot : 'div';\n\n return (\n <Comp\n {...props}\n ref={forwardedRef}\n role=\"group\"\n className={classNames('rt-BaseMenuLabel', 'rt-SidebarGroupLabel', className)}\n />\n );\n },\n);\nSidebarGroupLabel.displayName = 'Sidebar.GroupLabel';\n\ninterface SidebarGroupContentProps extends React.ComponentPropsWithoutRef<'div'> {}\n\nconst SidebarGroupContent = React.forwardRef<HTMLDivElement, SidebarGroupContentProps>(\n ({ className, ...props }, forwardedRef) => (\n <div\n {...props}\n ref={forwardedRef}\n className={classNames('rt-SidebarGroupContent', className)}\n />\n ),\n);\nSidebarGroupContent.displayName = 'Sidebar.GroupContent';\n\n// Export all components following shadcn's pattern\nexport {\n Sidebar as Root,\n SidebarContent as Content,\n SidebarHeader as Header,\n SidebarFooter as Footer,\n SidebarSeparator as Separator,\n SidebarMenu as Menu,\n SidebarMenuItem as MenuItem,\n SidebarMenuButton as MenuButton,\n SidebarMenuSub as MenuSub,\n SidebarMenuSubTrigger as MenuSubTrigger,\n SidebarMenuSubContent as MenuSubContent,\n SidebarGroup as Group,\n SidebarGroupLabel as GroupLabel,\n SidebarGroupContent as GroupContent,\n};\n\n/**\n * Enhanced Sidebar Header and Footer Usage Examples:\n *\n * 1. Simple default container (backwards compatible):\n * <Sidebar.Header>\n * <Logo />\n * <span>App Name</span>\n * </Sidebar.Header>\n *\n * 2. Custom flex layout:\n * <Sidebar.Header className=\"rt-justify-between rt-gap-3\">\n * <Logo />\n * <Sidebar.MenuButton>\n * <SettingsIcon />\n * </Sidebar.MenuButton>\n * </Sidebar.Header>\n *\n * 3. Column layout for multiple rows:\n * <Sidebar.Header className=\"rt-flex-col rt-gap-2\" asContainer={false}>\n * <div className=\"rt-flex rt-items-center rt-gap-2\">\n * <Logo />\n * <span>App Name</span>\n * </div>\n * <Sidebar.MenuButton>\n * <UserAvatar />\n * <span>John Doe</span>\n * </Sidebar.MenuButton>\n * </Sidebar.Header>\n *\n * 4. Interactive footer with menu button:\n * <Sidebar.Footer>\n * <Sidebar.MenuButton>\n * <UserIcon />\n * <span>Settings</span>\n * <ChevronUpIcon />\n * </Sidebar.MenuButton>\n * </Sidebar.Footer>\n *\n * 5. Custom footer layout:\n * <Sidebar.Footer className=\"rt-justify-between\">\n * <span>v1.0.0</span>\n * <Sidebar.MenuButton>\n * <HelpIcon />\n * </Sidebar.MenuButton>\n * </Sidebar.Footer>\n *\n * Available utility classes:\n * - Layout: rt-flex-row, rt-flex-col\n * - Alignment: rt-items-center, rt-items-start, rt-items-end\n * - Justification: rt-justify-between, rt-justify-center, rt-justify-start, rt-justify-end\n * - Gap: rt-gap-1, rt-gap-2, rt-gap-3, rt-gap-4\n */\n\nexport type {\n SidebarProps as RootProps,\n SidebarContentProps as ContentProps,\n SidebarHeaderProps as HeaderProps,\n SidebarFooterProps as FooterProps,\n BadgeConfig,\n};\n"],
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["sidebar_exports", "__export", "SidebarContent", "SidebarFooter", "SidebarGroup", "SidebarGroupContent", "SidebarGroupLabel", "SidebarHeader", "SidebarMenu", "SidebarMenuButton", "SidebarMenuItem", "SidebarMenuSub", "SidebarMenuSubContent", "SidebarMenuSubTrigger", "Sidebar", "SidebarSeparator", "__toCommonJS", "React", "import_classnames", "import_slot", "Accordion", "import_sidebar_props", "import_theme", "import_scroll_area", "import_separator", "import_icons", "import_extract_props", "import_kbd", "import_badge", "SidebarVisualContext", "useSidebarVisual", "props", "forwardedRef", "themeContext", "size", "variant", "menuVariant", "layout", "panelBackground", "color", "highContrast", "className", "children", "rootProps", "_", "__", "safeRootProps", "resolvedColor", "resolvedLayout", "resolvedSize", "classNames", "role", "ariaLabel", "id", "visual", "asContainer", "asChild", "isActive", "shortcut", "badge", "onMouseEnter", "onMouseLeave", "onKeyDown", "isHighlighted", "setIsHighlighted", "sidebarSize", "Comp", "onClick", "handleKeyDown", "event", "nextItem", "prevItem", "defaultOpen"]
|
|
4
|
+
"sourcesContent": ["'use client';\n\nimport * as React from 'react';\nimport classNames from 'classnames';\nimport { Slot } from './slot.js';\nimport * as Accordion from '@radix-ui/react-accordion';\nimport * as DropdownMenu from './dropdown-menu.js';\n\nimport { sidebarPropDefs } from './sidebar.props.js';\nimport { useThemeContext } from './theme.js';\n// import { IconButton } from './icon-button.js';\nimport { ScrollArea } from './scroll-area.js';\nimport { Separator } from './separator.js';\nimport { ThickChevronRightIcon } from './icons.js';\nimport { extractProps } from '../helpers/extract-props.js';\nimport { Kbd } from './kbd.js';\nimport { Badge } from './badge.js';\n\nimport type { ComponentPropsWithout, RemovedProps } from '../helpers/component-props.js';\nimport type { GetPropDefTypes } from '../props/prop-def.js';\nimport type { BadgeProps } from './badge.js';\n\n// Badge configuration type for sidebar menu buttons\ntype BadgeConfig = {\n content: React.ReactNode;\n variant?: BadgeProps['variant'];\n size?: BadgeProps['size'];\n color?: BadgeProps['color'];\n highContrast?: BadgeProps['highContrast'];\n radius?: BadgeProps['radius'];\n};\n\n// Internal presentational context (not exported) for size/menu variant\ntype SidebarVisualContextValue = {\n size: '1' | '2';\n menuVariant: 'solid' | 'soft';\n presentation?: 'thin' | 'expanded';\n color?: string;\n};\nconst SidebarVisualContext = React.createContext<SidebarVisualContextValue | null>(null);\nfunction useSidebarVisual() {\n return React.useContext(SidebarVisualContext);\n}\n\n// Sidebar is now independent of Shell - no integration needed\n\n// Main Sidebar component\ntype SidebarOwnProps = GetPropDefTypes<typeof sidebarPropDefs>;\ninterface SidebarProps extends ComponentPropsWithout<'div', RemovedProps>, SidebarOwnProps {\n /**\n * Presentational mode independent of Shell.\n * 'thin' renders a rail-style sidebar, 'expanded' renders a panel-style sidebar.\n * If both `presentation` and `layout` are provided, `presentation` takes precedence.\n */\n presentation?: 'thin' | 'expanded';\n}\n\nconst Sidebar = React.forwardRef<HTMLDivElement, SidebarProps>((props, forwardedRef) => {\n const themeContext = useThemeContext();\n\n const {\n size = sidebarPropDefs.size.default,\n variant = sidebarPropDefs.variant.default,\n menuVariant = sidebarPropDefs.menuVariant.default,\n layout = sidebarPropDefs.layout.default,\n presentation,\n // type = sidebarPropDefs.type.default,\n // side = sidebarPropDefs.side.default,\n // collapsible = sidebarPropDefs.collapsible.default,\n panelBackground,\n color,\n highContrast = sidebarPropDefs.highContrast.default,\n } = props;\n\n const { className, children, ...rootProps } = extractProps(props, sidebarPropDefs);\n // Remove internal-only props from DOM\n const { asChild: _, panelBackground: __, presentation: ___, ...safeRootProps } = rootProps;\n const resolvedColor = color || themeContext.accentColor;\n\n // Resolve layout (default to 'panel'). `presentation` takes precedence over `layout`.\n const resolvedLayout = presentation === 'thin' ? 'rail' : presentation === 'expanded' ? 'panel' : layout || 'panel';\n\n // Update context with current props - we'll pass the resolved values\n const resolvedSize = typeof size === 'object' ? size.initial || '2' : size;\n return (\n <div {...safeRootProps} ref={forwardedRef} data-accent-color={resolvedColor} className={classNames('rt-SidebarRoot', className)}>\n <SidebarVisualContext.Provider value={{ size: resolvedSize, menuVariant, presentation, color: resolvedColor }}>\n <div\n className={classNames('rt-SidebarContainer', `rt-variant-${variant}`, `rt-r-size-${resolvedSize}`, `rt-menu-variant-${menuVariant}`, resolvedLayout && `rt-layout-${resolvedLayout}`)}\n data-accent-color={resolvedColor}\n data-high-contrast={highContrast || undefined}\n data-panel-background={panelBackground}\n data-presentation={presentation}\n data-layout={resolvedLayout}\n >\n {children}\n </div>\n </SidebarVisualContext.Provider>\n </div>\n );\n});\nSidebar.displayName = 'Sidebar.Root';\n\n// Sidebar content area\ninterface SidebarContentProps extends React.ComponentPropsWithoutRef<'div'> {\n id?: string;\n role?: 'navigation' | 'none';\n 'aria-label'?: string;\n}\n\nconst SidebarContent = React.forwardRef<HTMLDivElement, SidebarContentProps>(\n ({ className, children, role = 'navigation', 'aria-label': ariaLabel = 'Main navigation', id, ...props }, forwardedRef) => {\n const visual = useSidebarVisual();\n const size = visual?.size ?? '2';\n const menuVariant = visual?.menuVariant ?? 'soft';\n\n return (\n <ScrollArea type=\"hover\">\n <div\n {...props}\n ref={forwardedRef}\n id={id}\n role={role}\n aria-label={ariaLabel}\n className={classNames('rt-BaseMenuContent', 'rt-SidebarContent', `rt-r-size-${size}`, `rt-menu-variant-${menuVariant}`, className)}\n >\n <div className=\"rt-BaseMenuViewport\">{children}</div>\n </div>\n </ScrollArea>\n );\n },\n);\nSidebarContent.displayName = 'Sidebar.Content';\n\n// Sidebar header\ninterface SidebarHeaderProps extends React.ComponentPropsWithoutRef<'div'> {\n /**\n * Whether to use the default flex container layout.\n * @default true\n */\n asContainer?: boolean;\n}\n\nconst SidebarHeader = React.forwardRef<HTMLDivElement, SidebarHeaderProps>(({ className, asContainer = true, ...props }, forwardedRef) => {\n const visual = useSidebarVisual();\n const size = visual?.size ?? '2';\n const menuVariant = visual?.menuVariant ?? 'soft';\n\n return (\n <div\n {...props}\n ref={forwardedRef}\n className={classNames(\n 'rt-SidebarHeader',\n `rt-r-size-${size}`,\n `rt-menu-variant-${menuVariant}`,\n {\n 'rt-SidebarHeader--container': asContainer,\n },\n className,\n )}\n />\n );\n});\nSidebarHeader.displayName = 'Sidebar.Header';\n\n// Sidebar footer\ninterface SidebarFooterProps extends React.ComponentPropsWithoutRef<'div'> {\n /**\n * Whether to use the default flex container layout.\n * @default true\n */\n asContainer?: boolean;\n}\n\nconst SidebarFooter = React.forwardRef<HTMLDivElement, SidebarFooterProps>(({ className, asContainer = true, ...props }, forwardedRef) => {\n const visual = useSidebarVisual();\n const size = visual?.size ?? '2';\n const menuVariant = visual?.menuVariant ?? 'soft';\n\n return (\n <div\n {...props}\n ref={forwardedRef}\n className={classNames(\n 'rt-SidebarFooter',\n `rt-r-size-${size}`,\n `rt-menu-variant-${menuVariant}`,\n {\n 'rt-SidebarFooter--container': asContainer,\n },\n className,\n )}\n />\n );\n});\nSidebarFooter.displayName = 'Sidebar.Footer';\n\n// Sidebar trigger button\n// removed Trigger in presentational-only Sidebar\n\n// Removed SidebarInset - not needed\n\n// Sidebar separator\ninterface SidebarSeparatorProps extends ComponentPropsWithout<typeof Separator, RemovedProps> {}\n\nconst SidebarSeparator = React.forwardRef<React.ComponentRef<typeof Separator>, SidebarSeparatorProps>(({ className, ...props }, forwardedRef) => (\n <Separator {...props} ref={forwardedRef} className={classNames('rt-SidebarSeparator', className)} />\n));\nSidebarSeparator.displayName = 'Sidebar.Separator';\n\n// Menu components - reusing dropdown menu structure\ninterface SidebarMenuProps extends React.ComponentPropsWithoutRef<'ul'> {}\n\nconst SidebarMenu = React.forwardRef<HTMLUListElement, SidebarMenuProps>(({ className, ...props }, forwardedRef) => (\n <ul {...props} ref={forwardedRef} role=\"menu\" className={classNames('rt-SidebarMenu', className)} />\n));\nSidebarMenu.displayName = 'Sidebar.Menu';\n\ninterface SidebarMenuItemProps extends React.ComponentPropsWithoutRef<'li'> {}\n\nconst SidebarMenuItem = React.forwardRef<HTMLLIElement, SidebarMenuItemProps>(({ className, ...props }, forwardedRef) => (\n <li {...props} ref={forwardedRef} className={classNames('rt-SidebarMenuItem', className)} />\n));\nSidebarMenuItem.displayName = 'Sidebar.MenuItem';\n\ninterface SidebarMenuButtonProps extends React.ComponentPropsWithoutRef<'button'> {\n asChild?: boolean;\n isActive?: boolean;\n shortcut?: React.ReactNode;\n badge?: string | BadgeConfig;\n}\n\nconst SidebarMenuButton = React.forwardRef<HTMLButtonElement, SidebarMenuButtonProps>(\n ({ asChild = false, isActive = false, shortcut, badge, className, children, onMouseEnter, onMouseLeave, onKeyDown, ...props }, forwardedRef) => {\n const [isHighlighted, setIsHighlighted] = React.useState(false);\n const visual = useSidebarVisual();\n const sidebarSize = visual?.size ?? '2';\n\n const Comp = asChild ? Slot : 'button';\n\n const { onClick } = props;\n const handleKeyDown = React.useCallback(\n (event: React.KeyboardEvent<HTMLButtonElement>) => {\n switch (event.key) {\n case 'Enter':\n case ' ':\n event.preventDefault();\n if (onClick) onClick(event as any);\n break;\n case 'ArrowDown': {\n event.preventDefault();\n // Focus next menu item\n const nextItem = (event.currentTarget as HTMLElement).nextElementSibling?.querySelector('[role=\"menuitem\"]') as HTMLElement;\n if (nextItem) nextItem.focus();\n break;\n }\n case 'ArrowUp': {\n event.preventDefault();\n // Focus previous menu item\n const prevItem = (event.currentTarget as HTMLElement).previousElementSibling?.querySelector('[role=\"menuitem\"]') as HTMLElement;\n if (prevItem) prevItem.focus();\n break;\n }\n }\n onKeyDown?.(event);\n },\n [onClick, onKeyDown],\n );\n\n // Wrap bare text nodes so CSS can target labels (e.g., for truncation in thin mode)\n const wrapTextNodes = (node: React.ReactNode): React.ReactNode => {\n if (typeof node === 'string' || typeof node === 'number') {\n return <span className=\"rt-SidebarMenuLabel\">{node}</span>;\n }\n if (Array.isArray(node)) {\n return node.map((child, index) => <React.Fragment key={index}>{wrapTextNodes(child)}</React.Fragment>);\n }\n if (React.isValidElement(node)) {\n const el = node as React.ReactElement<any>;\n const className: string = (el.props && (el.props as any).className) || '';\n const isAlreadyLabel = typeof el.type === 'string' && className.split(' ').includes('rt-SidebarMenuLabel');\n if (isAlreadyLabel) return el;\n const newChildren = wrapTextNodes((el.props as any)?.children);\n return React.cloneElement(el, { ...(el.props as any) }, newChildren);\n }\n return node;\n };\n\n const processedChildren = wrapTextNodes(children);\n\n // When rendering asChild, Slot expects a single child element. We still want to\n // append optional badge/shortcut inside that element so they render with Link.\n const slottedChildren = React.useMemo(() => {\n if (!asChild) return null;\n try {\n const onlyChild = React.Children.only(processedChildren as React.ReactElement<any>) as React.ReactElement<any>;\n const originalInnerChildren = (onlyChild.props as any)?.children;\n const enhancedInnerChildren = (\n <>\n {originalInnerChildren}\n {badge && (\n <div className=\"rt-SidebarMenuBadge\">\n {typeof badge === 'string' ? (\n <Badge size={sidebarSize} variant=\"soft\">\n {badge}\n </Badge>\n ) : (\n <Badge size={badge.size || sidebarSize} variant={badge.variant || 'soft'} color={badge.color} highContrast={badge.highContrast} radius={badge.radius}>\n {badge.content}\n </Badge>\n )}\n </div>\n )}\n {shortcut && (\n <div className=\"rt-BaseMenuShortcut rt-SidebarMenuShortcut\">\n <Kbd size={sidebarSize}>{shortcut}</Kbd>\n </div>\n )}\n </>\n );\n return React.cloneElement(onlyChild, { ...(onlyChild.props as any) }, enhancedInnerChildren);\n } catch {\n // Fallback: if multiple children were passed incorrectly, just return processedChildren\n return processedChildren as React.ReactNode;\n }\n }, [asChild, processedChildren, badge, shortcut, sidebarSize]);\n\n return (\n <Comp\n {...props}\n ref={forwardedRef}\n role=\"menuitem\"\n aria-current={isActive ? 'page' : undefined}\n className={classNames('rt-reset', 'rt-BaseMenuItem', 'rt-SidebarMenuButton', className)}\n data-active={isActive || undefined}\n data-highlighted={isHighlighted || undefined}\n onKeyDown={handleKeyDown}\n onMouseEnter={(event) => {\n setIsHighlighted(true);\n onMouseEnter?.(event);\n }}\n onMouseLeave={(event) => {\n setIsHighlighted(false);\n onMouseLeave?.(event);\n }}\n >\n {asChild ? (\n slottedChildren\n ) : (\n <>\n {processedChildren}\n {/* Badge with soft variant default and size mapping to sidebar size */}\n {badge && (\n <div className=\"rt-SidebarMenuBadge\">\n {typeof badge === 'string' ? (\n <Badge size={sidebarSize} variant=\"soft\">\n {badge}\n </Badge>\n ) : (\n <Badge size={badge.size || sidebarSize} variant={badge.variant || 'soft'} color={badge.color} highContrast={badge.highContrast} radius={badge.radius}>\n {badge.content}\n </Badge>\n )}\n </div>\n )}\n {shortcut && (\n <div className=\"rt-BaseMenuShortcut rt-SidebarMenuShortcut\">\n <Kbd size={sidebarSize}>{shortcut}</Kbd>\n </div>\n )}\n </>\n )}\n </Comp>\n );\n },\n);\nSidebarMenuButton.displayName = 'Sidebar.MenuButton';\n\n// Sub-menu components: Accordion in expanded, Dropdown in thin\nconst SidebarSubMenuModeContext = React.createContext<'accordion' | 'dropdown'>('accordion');\ninterface SidebarMenuSubProps extends React.ComponentPropsWithoutRef<'div'> {\n defaultOpen?: boolean;\n}\n\nconst SidebarMenuSub = React.forwardRef<HTMLDivElement, SidebarMenuSubProps>(({ defaultOpen = false, children, ...props }, forwardedRef) => {\n const visual = useSidebarVisual();\n const mode: 'accordion' | 'dropdown' = visual?.presentation === 'thin' ? 'dropdown' : 'accordion';\n\n if (mode === 'dropdown') {\n return (\n <div {...props} ref={forwardedRef}>\n <DropdownMenu.Root>\n <SidebarSubMenuModeContext.Provider value=\"dropdown\">{children}</SidebarSubMenuModeContext.Provider>\n </DropdownMenu.Root>\n </div>\n );\n }\n\n return (\n <div {...props} ref={forwardedRef}>\n <SidebarSubMenuModeContext.Provider value=\"accordion\">\n <Accordion.Root type=\"single\" collapsible defaultValue={defaultOpen ? 'item' : undefined}>\n <Accordion.Item value=\"item\">{children}</Accordion.Item>\n </Accordion.Root>\n </SidebarSubMenuModeContext.Provider>\n </div>\n );\n});\nSidebarMenuSub.displayName = 'Sidebar.MenuSub';\n\ninterface SidebarMenuSubTriggerProps extends React.ComponentPropsWithoutRef<typeof Accordion.Trigger> {\n asChild?: boolean;\n}\n\nconst SidebarMenuSubTrigger = React.forwardRef<React.ElementRef<typeof Accordion.Trigger>, SidebarMenuSubTriggerProps>(\n ({ asChild = false, className, children, onMouseEnter, onMouseLeave, ...props }, forwardedRef) => {\n const [isHighlighted, setIsHighlighted] = React.useState(false);\n const mode = React.useContext(SidebarSubMenuModeContext);\n\n if (mode === 'dropdown') {\n return (\n <DropdownMenu.Trigger>\n <button\n {...(props as any)}\n ref={forwardedRef as any}\n type=\"button\"\n role=\"menuitem\"\n aria-haspopup=\"menu\"\n className={classNames('rt-reset', 'rt-BaseMenuItem', 'rt-SidebarMenuButton', 'rt-SidebarMenuSubTrigger', className)}\n data-highlighted={isHighlighted || undefined}\n onMouseEnter={(event) => {\n setIsHighlighted(true);\n onMouseEnter?.(event as any);\n }}\n onMouseLeave={(event) => {\n setIsHighlighted(false);\n onMouseLeave?.(event as any);\n }}\n >\n {children}\n </button>\n </DropdownMenu.Trigger>\n );\n }\n\n return (\n <Accordion.Header asChild>\n <div>\n <Accordion.Trigger\n {...props}\n ref={forwardedRef}\n asChild={asChild}\n role=\"menuitem\"\n aria-haspopup=\"true\"\n className={classNames('rt-reset', 'rt-BaseMenuItem', 'rt-SidebarMenuButton', 'rt-SidebarMenuSubTrigger', className)}\n data-highlighted={isHighlighted || undefined}\n onMouseEnter={(event) => {\n setIsHighlighted(true);\n onMouseEnter?.(event);\n }}\n onMouseLeave={(event) => {\n setIsHighlighted(false);\n onMouseLeave?.(event);\n }}\n >\n {asChild ? (\n children\n ) : (\n <>\n {children}\n <ThickChevronRightIcon className={classNames('rt-BaseMenuSubTriggerIcon', 'rt-SidebarMenuSubTriggerIcon')} />\n </>\n )}\n </Accordion.Trigger>\n </div>\n </Accordion.Header>\n );\n },\n);\nSidebarMenuSubTrigger.displayName = 'Sidebar.MenuSubTrigger';\n\ninterface SidebarMenuSubContentProps extends React.ComponentPropsWithoutRef<typeof Accordion.Content> {}\n\nconst SidebarMenuSubContent = React.forwardRef<React.ElementRef<typeof Accordion.Content>, SidebarMenuSubContentProps>(({ className, children, ...props }, forwardedRef) => {\n const visual = useSidebarVisual();\n const mode = React.useContext(SidebarSubMenuModeContext);\n\n if (mode === 'dropdown') {\n const unwrapMenuButton = (node: React.ReactNode): React.ReactNode => {\n if (Array.isArray(node)) {\n return node.map((n, i) => <React.Fragment key={i}>{unwrapMenuButton(n)}</React.Fragment>);\n }\n if (React.isValidElement(node)) {\n const typeDisplay = (node.type as any)?.displayName;\n if (typeDisplay === 'Sidebar.MenuButton') {\n return (node.props as any)?.children;\n }\n const child = (node.props as any)?.children;\n if (child !== undefined) {\n return React.cloneElement(node as any, { ...(node.props as any), children: unwrapMenuButton(child) });\n }\n }\n return node;\n };\n\n const normalized = React.Children.map(children as React.ReactNode, (child, index) => {\n if (React.isValidElement(child) && (child.type as any)?.displayName === 'Sidebar.MenuItem') {\n const itemChildren = (child.props as any)?.children;\n const content = unwrapMenuButton(itemChildren);\n return (\n <DropdownMenu.Item key={index} asChild>\n {content as any}\n </DropdownMenu.Item>\n );\n }\n // Fallback: wrap raw nodes too for consistent menu styling\n return (\n <DropdownMenu.Item key={index} asChild>\n {unwrapMenuButton(child) as any}\n </DropdownMenu.Item>\n );\n });\n\n return (\n <DropdownMenu.Content size={visual?.size} variant={visual?.menuVariant} className={classNames(className)}>\n <DropdownMenu.Group>{normalized}</DropdownMenu.Group>\n </DropdownMenu.Content>\n );\n }\n\n return (\n <Accordion.Content {...props} ref={forwardedRef} className={classNames('rt-SidebarMenuSubContent', className)}>\n <div className=\"rt-SidebarMenuSubList\">{children}</div>\n </Accordion.Content>\n );\n});\nSidebarMenuSubContent.displayName = 'Sidebar.MenuSubContent';\n\n// Group components\ninterface SidebarGroupProps extends React.ComponentPropsWithoutRef<'div'> {}\n\nconst SidebarGroup = React.forwardRef<HTMLDivElement, SidebarGroupProps>(({ className, ...props }, forwardedRef) => (\n <div {...props} ref={forwardedRef} className={classNames('rt-BaseMenuGroup', 'rt-SidebarGroup', className)} />\n));\nSidebarGroup.displayName = 'Sidebar.Group';\n\ninterface SidebarGroupLabelProps extends React.ComponentPropsWithoutRef<'div'> {\n asChild?: boolean;\n}\n\nconst SidebarGroupLabel = React.forwardRef<HTMLDivElement, SidebarGroupLabelProps>(({ asChild = false, className, ...props }, forwardedRef) => {\n const Comp = asChild ? Slot : 'div';\n\n return <Comp {...props} ref={forwardedRef} role=\"group\" className={classNames('rt-BaseMenuLabel', 'rt-SidebarGroupLabel', className)} />;\n});\nSidebarGroupLabel.displayName = 'Sidebar.GroupLabel';\n\ninterface SidebarGroupContentProps extends React.ComponentPropsWithoutRef<'div'> {}\n\nconst SidebarGroupContent = React.forwardRef<HTMLDivElement, SidebarGroupContentProps>(({ className, ...props }, forwardedRef) => (\n <div {...props} ref={forwardedRef} className={classNames('rt-SidebarGroupContent', className)} />\n));\nSidebarGroupContent.displayName = 'Sidebar.GroupContent';\n\n// Export all components following shadcn's pattern\nexport {\n Sidebar as Root,\n SidebarContent as Content,\n SidebarHeader as Header,\n SidebarFooter as Footer,\n SidebarSeparator as Separator,\n SidebarMenu as Menu,\n SidebarMenuItem as MenuItem,\n SidebarMenuButton as MenuButton,\n SidebarMenuSub as MenuSub,\n SidebarMenuSubTrigger as MenuSubTrigger,\n SidebarMenuSubContent as MenuSubContent,\n SidebarGroup as Group,\n SidebarGroupLabel as GroupLabel,\n SidebarGroupContent as GroupContent,\n};\n\n/**\n * Enhanced Sidebar Header and Footer Usage Examples:\n *\n * 1. Simple default container (backwards compatible):\n * <Sidebar.Header>\n * <Logo />\n * <span>App Name</span>\n * </Sidebar.Header>\n *\n * 2. Custom flex layout:\n * <Sidebar.Header className=\"rt-justify-between rt-gap-3\">\n * <Logo />\n * <Sidebar.MenuButton>\n * <SettingsIcon />\n * </Sidebar.MenuButton>\n * </Sidebar.Header>\n *\n * 3. Column layout for multiple rows:\n * <Sidebar.Header className=\"rt-flex-col rt-gap-2\" asContainer={false}>\n * <div className=\"rt-flex rt-items-center rt-gap-2\">\n * <Logo />\n * <span>App Name</span>\n * </div>\n * <Sidebar.MenuButton>\n * <UserAvatar />\n * <span>John Doe</span>\n * </Sidebar.MenuButton>\n * </Sidebar.Header>\n *\n * 4. Interactive footer with menu button:\n * <Sidebar.Footer>\n * <Sidebar.MenuButton>\n * <UserIcon />\n * <span>Settings</span>\n * <ChevronUpIcon />\n * </Sidebar.MenuButton>\n * </Sidebar.Footer>\n *\n * 5. Custom footer layout:\n * <Sidebar.Footer className=\"rt-justify-between\">\n * <span>v1.0.0</span>\n * <Sidebar.MenuButton>\n * <HelpIcon />\n * </Sidebar.MenuButton>\n * </Sidebar.Footer>\n *\n * Available utility classes:\n * - Layout: rt-flex-row, rt-flex-col\n * - Alignment: rt-items-center, rt-items-start, rt-items-end\n * - Justification: rt-justify-between, rt-justify-center, rt-justify-start, rt-justify-end\n * - Gap: rt-gap-1, rt-gap-2, rt-gap-3, rt-gap-4\n */\n\nexport type { SidebarProps as RootProps, SidebarContentProps as ContentProps, SidebarHeaderProps as HeaderProps, SidebarFooterProps as FooterProps, BadgeConfig };\n"],
|
|
5
|
+
"mappings": "mlBAAA,IAAAA,GAAA,GAAAC,GAAAD,GAAA,aAAAE,EAAA,WAAAC,EAAA,UAAAC,EAAA,iBAAAC,EAAA,eAAAC,EAAA,WAAAC,EAAA,SAAAC,EAAA,eAAAC,EAAA,aAAAC,EAAA,YAAAC,EAAA,mBAAAC,EAAA,mBAAAC,EAAA,SAAAC,EAAA,cAAAC,IAAA,eAAAC,GAAAhB,IAEA,IAAAiB,EAAuB,oBACvBC,EAAuB,yBACvBC,EAAqB,qBACrBC,EAA2B,wCAC3BC,EAA8B,iCAE9BC,EAAgC,8BAChCC,EAAgC,sBAEhCC,EAA2B,4BAC3BC,GAA0B,0BAC1BC,GAAsC,sBACtCC,GAA6B,uCAC7BC,EAAoB,oBACpBC,EAAsB,sBAuBtB,MAAMC,EAAuBb,EAAM,cAAgD,IAAI,EACvF,SAASc,GAAmB,CAC1B,OAAOd,EAAM,WAAWa,CAAoB,CAC9C,CAeA,MAAMhB,EAAUG,EAAM,WAAyC,CAACe,EAAOC,IAAiB,CACtF,MAAMC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,EAAc,aAAW,EAAAoB,SAAW,yBAA0BV,CAAS,EAAG,CAChG,EACDtC,EAAoB,YAAc",
|
|
6
|
+
"names": ["sidebar_exports", "__export", "SidebarContent", "SidebarFooter", "SidebarGroup", "SidebarGroupContent", "SidebarGroupLabel", "SidebarHeader", "SidebarMenu", "SidebarMenuButton", "SidebarMenuItem", "SidebarMenuSub", "SidebarMenuSubContent", "SidebarMenuSubTrigger", "Sidebar", "SidebarSeparator", "__toCommonJS", "React", "import_classnames", "import_slot", "Accordion", "DropdownMenu", "import_sidebar_props", "import_theme", "import_scroll_area", "import_separator", "import_icons", "import_extract_props", "import_kbd", "import_badge", "SidebarVisualContext", "useSidebarVisual", "props", "forwardedRef", "themeContext", "size", "variant", "menuVariant", "layout", "presentation", "panelBackground", "color", "highContrast", "className", "children", "rootProps", "_", "__", "___", "safeRootProps", "resolvedColor", "resolvedLayout", "resolvedSize", "classNames", "role", "ariaLabel", "id", "visual", "asContainer", "asChild", "isActive", "shortcut", "badge", "onMouseEnter", "onMouseLeave", "onKeyDown", "isHighlighted", "setIsHighlighted", "sidebarSize", "Comp", "onClick", "handleKeyDown", "event", "nextItem", "prevItem", "wrapTextNodes", "node", "child", "index", "el", "newChildren", "processedChildren", "slottedChildren", "onlyChild", "originalInnerChildren", "enhancedInnerChildren", "SidebarSubMenuModeContext", "defaultOpen", "unwrapMenuButton", "n", "i", "normalized", "itemChildren", "content"]
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shell-sidebar.d.ts","sourceRoot":"","sources":["../../../../src/components/_internal/shell-sidebar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAO/B,OAAO,EAAE,aAAa,EAAc,MAAM,oBAAoB,CAAC;AAC/D,OAAO,KAAK,EAAc,QAAQ,EAAE,mBAAmB,EAAqB,sBAAsB,EAAE,qBAAqB,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGlK,UAA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W,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACrC,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,mBAAmB,CAAC;CACnC;AAED,KAAK,gBAAgB,GAAG,KAAK,CAAC,yBAAyB,CACrD,IAAI,CAAC,SAAS,EAAE,MAAM,GAAG,aAAa,GAAG,cAAc,CAAC,GAAG;IACzD,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,WAAW,CAAC,EAAE,qBAAqB,CAAC;IACpC,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,IAAI,CAAC;IAC3C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,GAAG,QAAQ,CAAC;CACjC,GAAG,KAAK,CAAC,aAAa,CAAC,cAAc,CAAC,CACxC,GAAG;IAAE,MAAM,EAAE,OAAO,aAAa,CAAA;CAAE,CAAC;AAErC,eAAO,MAAM,OAAO,EAkUf,gBAAgB,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import*as r from"react";import
|
|
1
|
+
import*as r from"react";import ae from"classnames";import*as C from"../sheet.js";import{VisuallyHidden as ie}from"../visually-hidden.js";import{useShell as L}from"../shell.context.js";import{useResponsivePresentation as oe}from"../shell.hooks.js";import{PaneResizeContext as se}from"./shell-resize.js";import{SidebarHandle as E,PaneHandle as de}from"./shell-handles.js";import{BREAKPOINTS as le}from"../shell.types.js";const K=r.forwardRef(({className:j,presentation:q={initial:"overlay",md:"fixed"},mode:i,defaultMode:c="expanded",onModeChange:x,expandedSize:s=288,minSize:B=200,maxSize:w=400,resizable:S=!1,collapsible:F=!0,onExpand:T,onCollapse:H,onResize:y,onResizeStart:W,onResizeEnd:G,snapPoints:J,snapTolerance:Q,collapseThreshold:U,paneId:g,persistence:v,children:X,style:Y,thinSize:b=64,toggleModes:R,...Z},f)=>{const t=L(),P=oe(q),d=P==="overlay",_=P==="stacked",l=t.sidebarPhase;r.useLayoutEffect(()=>{if(d)return;const e=u.current;if(e){if(l==="hiding")try{const a=e.getBoundingClientRect();e.style.width=`${Math.round(a.width)}px`}catch{}else if(l==="resizing")try{e.style.removeProperty("width")}catch{}else if(l==="idle")try{e.style.removeProperty("width")}catch{}}},[l,d]);const u=r.useRef(null),ee=r.useCallback(e=>{u.current=e,typeof f=="function"?f(e):f&&(f.current=e)},[f]),z=r.Children.toArray(X),O=z.filter(e=>r.isValidElement(e)&&e.type===E),N=z.filter(e=>!(r.isValidElement(e)&&e.type===E)),te=r.useId();r.useEffect(()=>(t.setHasSidebar(!0),()=>{t.setHasSidebar(!1)}),[t,te]);const $=r.useRef(!1);r.useEffect(()=>{$.current||($.current=!0,i===void 0&&t.sidebarMode!==c&&t.setSidebarMode(c))},[]),r.useEffect(()=>{i!==void 0&&t.sidebarMode!==i&&t.setSidebarMode(i)},[i,t]),r.useEffect(()=>{i===void 0&&x?.(t.sidebarMode)},[t.sidebarMode,i,x]),r.useEffect(()=>{t.sidebarMode==="expanded"?T?.():H?.()},[t.sidebarMode,T,H]);const A=t.sidebarMode!=="collapsed",m=r.useMemo(()=>{if(!g||v)return v;const e=`kookie-ui:shell:sidebar:${g}`;return{load:()=>{if(typeof window>"u")return;const n=window.localStorage.getItem(e);return n?Number(n):void 0},save:n=>{typeof window>"u"||window.localStorage.setItem(e,String(n))}}},[g,v]);r.useEffect(()=>{let e=!0;return(async()=>{if(!S||!m?.load||d)return;const a=await m.load();e&&typeof a=="number"&&u.current&&(u.current.style.setProperty("--sidebar-size",`${a}px`),y?.(a))})(),()=>{e=!1}},[S,m,y,d]);const M=r.useCallback(()=>{if(typeof c=="string")return c;const e=c;if(e&&e[t.currentBreakpoint])return e[t.currentBreakpoint];const n=[...Object.keys(le)].reverse().concat("initial"),o=n.indexOf(t.currentBreakpoint);for(let p=o+1;p<n.length;p++){const D=n[p];if(e&&e[D])return e[D]}return"collapsed"},[c,t.currentBreakpoint]),h=L(),k=r.useCallback(()=>{const e=M();return e==="thin"||e==="expanded"?e:"expanded"},[M]);r.useEffect(()=>{if(!h.setSidebarToggleComputer)return;const e=R??"both",a=n=>{if(e==="both")return n==="collapsed"?"thin":n==="thin"?"expanded":"collapsed";const o=k();return n==="collapsed"?o:n===o?"collapsed":o};return h.setSidebarToggleComputer(a),()=>{h.setSidebarToggleComputer?.(n=>n==="collapsed"?"thin":n==="thin"?"expanded":"collapsed")}},[h,R,k]);const I=r.useRef(s),re=r.useRef("expanded");r.useEffect(()=>{t.sidebarMode!=="collapsed"&&(re.current=t.sidebarMode,I.current=t.sidebarMode==="thin"?b:s)},[t.sidebarMode,b,s]);const V=r.useRef(null);r.useEffect(()=>{if(i!==void 0||!t.currentBreakpointReady||V.current===t.currentBreakpoint)return;V.current=t.currentBreakpoint;const e=M();e!==t.sidebarMode&&t.setSidebarMode(e)},[i,t.currentBreakpoint,t.currentBreakpointReady,M,t.sidebarMode,t.setSidebarMode]);const ne=S&&!d&&t.sidebarMode==="expanded"?r.createElement(se.Provider,{value:{containerRef:u,cssVarName:"--sidebar-size",minSize:B,maxSize:w,defaultSize:s,orientation:"vertical",edge:"end",computeNext:(e,a,n)=>{const o=getComputedStyle(u.current).direction==="rtl",p=e-a;return n+(o?-p:p)},onResize:y,onResizeStart:W,onResizeEnd:e=>{G?.(e),m?.save?.(e)},target:"sidebar",collapsible:F,snapPoints:J,snapTolerance:Q??8,collapseThreshold:U,requestCollapse:()=>t.setSidebarMode("collapsed"),requestToggle:()=>t.togglePane("sidebar")}},O.length>0?O.map((e,a)=>r.cloneElement(e,{key:e.key??a})):r.createElement(de,null)):null;if(d){const e=t.sidebarMode!=="collapsed";return r.createElement(C.Root,{open:e,onOpenChange:a=>t.setSidebarMode(a?"expanded":"collapsed")},r.createElement(C.Content,{side:"start",style:{padding:0},width:{initial:`${e?t.sidebarMode==="thin"?b:s:I.current}px`}},r.createElement(ie,null,r.createElement(C.Title,null,"Sidebar")),N))}return r.createElement("div",{...Z,ref:ee,className:ae("rt-ShellSidebar",j),"data-mode":t.sidebarMode,"data-peek":t.peekTarget==="sidebar"||void 0,"data-presentation":P,"data-open":_&&A||void 0,style:{...Y,"--sidebar-size":`${s}px`,"--sidebar-thin-size":`${b}px`,"--sidebar-min-size":`${B}px`,"--sidebar-max-size":`${w}px`,...t.peekTarget==="sidebar"&&t.sidebarMode==="collapsed"&&!d?(()=>{const e=R??"both",a=t.sidebarMode;let n;if(e==="both")n=a==="collapsed"?"thin":a==="thin"?"expanded":"collapsed";else{const o=k();n=a==="collapsed"?o:"collapsed"}return n==="thin"?{"--peek-sidebar-width":`${b}px`}:{"--peek-sidebar-width":`var(--sidebar-size, ${s}px)`}})():{}}},r.createElement("div",{className:"rt-ShellSidebarContent","data-visible":A||void 0,"data-phase":l&&l!=="idle"?l:void 0},N),ne)});K.displayName="Shell.Sidebar",K.Handle=E;export{K as Sidebar};
|
|
2
2
|
//# sourceMappingURL=shell-sidebar.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/components/_internal/shell-sidebar.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nimport classNames from 'classnames';\nimport * as Sheet from '../sheet.js';\nimport { VisuallyHidden } from '../visually-hidden.js';\nimport { useShell } from '../shell.context.js';\nimport { useResponsivePresentation } from '../shell.hooks.js';\nimport { PaneResizeContext } from './shell-resize.js';\nimport { SidebarHandle, PaneHandle } from './shell-handles.js';\nimport type { Breakpoint, PaneMode, PaneSizePersistence, PresentationValue, ResponsivePresentation, ResponsiveSidebarMode, SidebarMode } from '../shell.types.js';\nimport { BREAKPOINTS } from '../shell.types.js';\n\ninterface PaneProps extends React.ComponentPropsWithoutRef<'div'> {\n presentation?: ResponsivePresentation;\n mode?: PaneMode;\n defaultMode?: any;\n onModeChange?: (mode: PaneMode | SidebarMode) => void;\n expandedSize?: number;\n minSize?: number;\n maxSize?: number;\n resizable?: boolean;\n collapsible?: boolean;\n onExpand?: () => void;\n onCollapse?: () => void;\n onResize?: (size: number) => void;\n resizer?: React.ReactNode;\n onResizeStart?: (size: number) => void;\n onResizeEnd?: (size: number) => void;\n snapPoints?: number[];\n snapTolerance?: number;\n collapseThreshold?: number;\n paneId?: string;\n persistence?: PaneSizePersistence;\n}\n\ntype SidebarComponent = React.ForwardRefExoticComponent<\n Omit<PaneProps, 'mode' | 'defaultMode' | 'onModeChange'> & {\n mode?: SidebarMode;\n defaultMode?: ResponsiveSidebarMode;\n onModeChange?: (mode: SidebarMode) => void;\n thinSize?: number;\n toggleModes?: 'both' | 'single';\n } & React.RefAttributes<HTMLDivElement>\n> & { Handle: typeof SidebarHandle };\n\nexport const Sidebar = React.forwardRef<\n HTMLDivElement,\n Omit<PaneProps, 'mode' | 'defaultMode' | 'onModeChange'> & {\n mode?: SidebarMode;\n defaultMode?: ResponsiveSidebarMode;\n onModeChange?: (mode: SidebarMode) => void;\n thinSize?: number;\n toggleModes?: 'both' | 'single';\n }\n>(\n (\n {\n className,\n presentation = { initial: 'overlay', md: 'fixed' },\n mode,\n defaultMode = 'expanded',\n onModeChange,\n expandedSize = 288,\n minSize = 200,\n maxSize = 400,\n resizable = false,\n collapsible = true,\n onExpand,\n onCollapse,\n onResize,\n onResizeStart,\n onResizeEnd,\n snapPoints,\n snapTolerance,\n collapseThreshold,\n paneId,\n persistence,\n children,\n style,\n thinSize = 64,\n toggleModes,\n ...props\n },\n ref,\n ) => {\n const shell = useShell();\n const resolvedPresentation = useResponsivePresentation(presentation);\n const isOverlay = resolvedPresentation === 'overlay';\n const isStacked = resolvedPresentation === 'stacked';\n const localRef = React.useRef<HTMLDivElement | null>(null);\n const setRef = React.useCallback(\n (node: HTMLDivElement | null) => {\n localRef.current = node;\n if (typeof ref === 'function') ref(node);\n else if (ref) (ref as React.MutableRefObject<HTMLDivElement | null>).current = node;\n },\n [ref],\n );\n const childArray = React.Children.toArray(children) as React.ReactElement[];\n const handleChildren = childArray.filter((el: React.ReactElement) => React.isValidElement(el) && el.type === SidebarHandle);\n const contentChildren = childArray.filter((el: React.ReactElement) => !(React.isValidElement(el) && el.type === SidebarHandle));\n\n // Register with shell\n const sidebarId = React.useId();\n React.useEffect(() => {\n shell.setHasSidebar(true);\n return () => {\n shell.setHasSidebar(false);\n };\n }, [shell, sidebarId]);\n\n // Honor defaultMode on mount when uncontrolled\n const didInitRef = React.useRef(false);\n React.useEffect(() => {\n if (didInitRef.current) return;\n didInitRef.current = true;\n if (mode === undefined && shell.sidebarMode !== (defaultMode as SidebarMode)) {\n shell.setSidebarMode(defaultMode as SidebarMode);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n // Sync controlled mode\n React.useEffect(() => {\n if (mode !== undefined && shell.sidebarMode !== mode) {\n shell.setSidebarMode(mode);\n }\n }, [mode, shell]);\n\n // Emit mode changes\n React.useEffect(() => {\n if (mode === undefined) {\n onModeChange?.(shell.sidebarMode);\n }\n }, [shell.sidebarMode, mode, onModeChange]);\n\n // Emit expand/collapse events\n React.useEffect(() => {\n if (shell.sidebarMode === 'expanded') {\n onExpand?.();\n } else {\n onCollapse?.();\n }\n }, [shell.sidebarMode, onExpand, onCollapse]);\n\n // Option A: thin is width-only; content remains visible whenever not collapsed\n const isContentVisible = shell.sidebarMode !== 'collapsed';\n\n // Default persistence if paneId provided and none supplied (fixed only)\n const persistenceAdapter = React.useMemo(() => {\n if (!paneId || persistence) return persistence;\n const key = `kookie-ui:shell:sidebar:${paneId}`;\n const adapter: PaneSizePersistence = {\n load: () => {\n if (typeof window === 'undefined') return undefined;\n const v = window.localStorage.getItem(key);\n return v ? Number(v) : undefined;\n },\n save: (size: number) => {\n if (typeof window === 'undefined') return;\n window.localStorage.setItem(key, String(size));\n },\n };\n return adapter;\n }, [paneId, persistence]);\n\n React.useEffect(() => {\n let mounted = true;\n (async () => {\n if (!resizable || !persistenceAdapter?.load || isOverlay) return;\n const loaded = await persistenceAdapter.load();\n if (mounted && typeof loaded === 'number' && localRef.current) {\n localRef.current.style.setProperty('--sidebar-size', `${loaded}px`);\n onResize?.(loaded);\n }\n })();\n return () => {\n mounted = false;\n };\n }, [resizable, persistenceAdapter, onResize, isOverlay]);\n\n // Always-follow responsive defaultMode for uncontrolled Sidebar (on breakpoint change only)\n const resolveResponsiveMode = React.useCallback((): SidebarMode => {\n if (typeof defaultMode === 'string') return defaultMode as SidebarMode;\n const dm = defaultMode as Partial<Record<Breakpoint, SidebarMode>> | undefined;\n if (dm && dm[shell.currentBreakpoint as Breakpoint]) {\n return dm[shell.currentBreakpoint as Breakpoint] as SidebarMode;\n }\n const bpKeys = Object.keys(BREAKPOINTS) as Array<keyof typeof BREAKPOINTS>;\n const order: Breakpoint[] = ([...bpKeys].reverse() as Breakpoint[]).concat('initial' as Breakpoint);\n const startIdx = order.indexOf(shell.currentBreakpoint as Breakpoint);\n for (let i = startIdx + 1; i < order.length; i++) {\n const bp = order[i];\n if (dm && dm[bp]) return dm[bp] as SidebarMode;\n }\n return 'collapsed';\n }, [defaultMode, shell.currentBreakpoint]);\n\n // Register custom toggle behavior based on toggleModes (both|single)\n const shellForToggle = useShell();\n const resolveDefaultSidebarMode = React.useCallback((): SidebarMode => {\n const resolved = resolveResponsiveMode();\n return resolved === 'thin' || resolved === 'expanded' ? resolved : 'expanded';\n }, [resolveResponsiveMode]);\n\n React.useEffect(() => {\n if (!shellForToggle.setSidebarToggleComputer) return;\n const strategy: 'both' | 'single' = toggleModes ?? 'both';\n const compute = (current: SidebarMode): SidebarMode => {\n if (strategy === 'both') {\n if (current === 'collapsed') return 'thin';\n if (current === 'thin') return 'expanded';\n return 'collapsed';\n }\n const target = resolveDefaultSidebarMode();\n if (current === 'collapsed') return target;\n if (current === target) return 'collapsed';\n return target;\n };\n shellForToggle.setSidebarToggleComputer(compute);\n return () => {\n shellForToggle.setSidebarToggleComputer?.((cur) => (cur === 'collapsed' ? 'thin' : cur === 'thin' ? 'expanded' : 'collapsed'));\n };\n }, [shellForToggle, toggleModes, resolveDefaultSidebarMode]);\n\n const lastOverlayWidthRef = React.useRef<number>(expandedSize);\n const lastOverlayModeRef = React.useRef<SidebarMode>('expanded');\n React.useEffect(() => {\n if (shell.sidebarMode !== 'collapsed') {\n lastOverlayModeRef.current = shell.sidebarMode as SidebarMode;\n lastOverlayWidthRef.current = shell.sidebarMode === 'thin' ? thinSize : expandedSize;\n }\n }, [shell.sidebarMode, thinSize, expandedSize]);\n\n const lastSidebarBpRef = React.useRef<Breakpoint | null>(null);\n React.useEffect(() => {\n if (mode !== undefined) return;\n if (!shell.currentBreakpointReady) return;\n if (lastSidebarBpRef.current === shell.currentBreakpoint) return;\n lastSidebarBpRef.current = shell.currentBreakpoint as Breakpoint;\n const next = resolveResponsiveMode();\n if (next !== shell.sidebarMode) shell.setSidebarMode(next);\n }, [mode, shell.currentBreakpoint, shell.currentBreakpointReady, resolveResponsiveMode, shell.sidebarMode, shell.setSidebarMode]);\n\n const handleEl =\n resizable && !isOverlay && shell.sidebarMode === 'expanded' ? (\n <PaneResizeContext.Provider\n value={{\n containerRef: localRef,\n cssVarName: '--sidebar-size',\n minSize,\n maxSize,\n defaultSize: expandedSize,\n orientation: 'vertical',\n edge: 'end',\n computeNext: (client, startClient, startSize) => {\n const isRtl = getComputedStyle(localRef.current!).direction === 'rtl';\n const delta = client - startClient;\n return startSize + (isRtl ? -delta : delta);\n },\n onResize,\n onResizeStart,\n onResizeEnd: (size) => {\n onResizeEnd?.(size);\n persistenceAdapter?.save?.(size);\n },\n target: 'sidebar',\n collapsible,\n snapPoints,\n snapTolerance: snapTolerance ?? 8,\n collapseThreshold,\n requestCollapse: () => shell.setSidebarMode('collapsed'),\n requestToggle: () => shell.togglePane('sidebar'),\n }}\n >\n {handleChildren.length > 0 ? handleChildren.map((el, i) => React.cloneElement(el, { key: el.key ?? i })) : <PaneHandle />}\n </PaneResizeContext.Provider>\n ) : null;\n\n if (isOverlay) {\n const open = shell.sidebarMode !== 'collapsed';\n return (\n <Sheet.Root open={open} onOpenChange={(o) => shell.setSidebarMode(o ? 'expanded' : 'collapsed')}>\n <Sheet.Content\n side=\"start\"\n style={{ padding: 0 }}\n width={{\n initial: `${open ? (shell.sidebarMode === 'thin' ? thinSize : expandedSize) : lastOverlayWidthRef.current}px`,\n }}\n >\n <VisuallyHidden>\n <Sheet.Title>Sidebar</Sheet.Title>\n </VisuallyHidden>\n {contentChildren}\n </Sheet.Content>\n </Sheet.Root>\n );\n }\n\n return (\n <div\n {...props}\n ref={setRef}\n className={classNames('rt-ShellSidebar', className)}\n data-mode={shell.sidebarMode}\n data-peek={shell.peekTarget === 'sidebar' || undefined}\n data-presentation={resolvedPresentation}\n data-open={(isStacked && isContentVisible) || undefined}\n style={{\n ...style,\n ['--sidebar-size' as any]: `${expandedSize}px`,\n ['--sidebar-thin-size' as any]: `${thinSize}px`,\n ['--sidebar-min-size' as any]: `${minSize}px`,\n ['--sidebar-max-size' as any]: `${maxSize}px`,\n ...(shell.peekTarget === 'sidebar' && shell.sidebarMode === 'collapsed' && !isOverlay\n ? (() => {\n const strategy: 'both' | 'single' = toggleModes ?? 'both';\n const current = shell.sidebarMode as SidebarMode;\n let next: SidebarMode;\n if (strategy === 'both') {\n next = current === 'collapsed' ? 'thin' : current === 'thin' ? 'expanded' : 'collapsed';\n } else {\n const target = resolveDefaultSidebarMode();\n next = current === 'collapsed' ? target : 'collapsed';\n }\n if (next === 'thin') {\n return {\n ['--peek-sidebar-width' as any]: `${thinSize}px`,\n } as React.CSSProperties;\n }\n return {\n ['--peek-sidebar-width' as any]: `var(--sidebar-size, ${expandedSize}px)`,\n } as React.CSSProperties;\n })()\n : {}),\n }}\n >\n <div className=\"rt-ShellSidebarContent\" data-visible={isContentVisible || undefined}>\n {contentChildren}\n </div>\n {handleEl}\n </div>\n );\n },\n) as SidebarComponent;\n\nSidebar.displayName = 'Shell.Sidebar';\nSidebar.Handle = SidebarHandle;\n"],
|
|
5
|
-
"mappings": "AAAA,UAAYA,MAAW,QACvB,OAAOC,OAAgB,aACvB,UAAYC,MAAW,cACvB,OAAS,kBAAAC,OAAsB,wBAC/B,OAAS,YAAAC,MAAgB,sBACzB,OAAS,6BAAAC,OAAiC,oBAC1C,OAAS,qBAAAC,OAAyB,oBAClC,OAAS,iBAAAC,EAAe,cAAAC,OAAkB,qBAE1C,OAAS,eAAAC,OAAmB,oBAmCrB,MAAMC,EAAUV,EAAM,WAU3B,CACE,CACE,UAAAW,EACA,aAAAC,EAAe,CAAE,QAAS,UAAW,GAAI,OAAQ,EACjD,KAAAC,EACA,YAAAC,EAAc,WACd,aAAAC,EACA,aAAAC,EAAe,IACf,QAAAC,EAAU,IACV,QAAAC,EAAU,IACV,UAAAC,EAAY,GACZ,YAAAC,EAAc,GACd,SAAAC,EACA,WAAAC,EACA,SAAAC,EACA,cAAAC,EACA,YAAAC,EACA,WAAAC,EACA,cAAAC,EACA,kBAAAC,EACA,OAAAC,EACA,YAAAC,EACA,SAAAC,EACA,MAAAC,EACA,SAAAC,EAAW,GACX,YAAAC,EACA,GAAGC,CACL,EACAC,IACG,CACH,MAAMC,EAAQjC,EAAS,EACjBkC,EAAuBjC,GAA0BO,CAAY,EAC7D2B,EAAYD,IAAyB,UACrCE,EAAYF,IAAyB,
|
|
6
|
-
"names": ["React", "classNames", "Sheet", "VisuallyHidden", "useShell", "useResponsivePresentation", "PaneResizeContext", "SidebarHandle", "PaneHandle", "BREAKPOINTS", "Sidebar", "className", "presentation", "mode", "defaultMode", "onModeChange", "expandedSize", "minSize", "maxSize", "resizable", "collapsible", "onExpand", "onCollapse", "onResize", "onResizeStart", "onResizeEnd", "snapPoints", "snapTolerance", "collapseThreshold", "paneId", "persistence", "children", "style", "thinSize", "toggleModes", "props", "ref", "shell", "resolvedPresentation", "isOverlay", "isStacked", "localRef", "setRef", "node", "childArray", "handleChildren", "el", "contentChildren", "sidebarId", "didInitRef", "isContentVisible", "persistenceAdapter", "key", "v", "size", "mounted", "loaded", "resolveResponsiveMode", "dm", "order", "startIdx", "i", "bp", "shellForToggle", "resolveDefaultSidebarMode", "resolved", "strategy", "compute", "current", "target", "cur", "lastOverlayWidthRef", "lastOverlayModeRef", "lastSidebarBpRef", "next", "handleEl", "client", "startClient", "startSize", "isRtl", "delta", "open", "o"]
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nimport classNames from 'classnames';\nimport * as Sheet from '../sheet.js';\nimport { VisuallyHidden } from '../visually-hidden.js';\nimport { useShell } from '../shell.context.js';\nimport { useResponsivePresentation } from '../shell.hooks.js';\nimport { PaneResizeContext } from './shell-resize.js';\nimport { SidebarHandle, PaneHandle } from './shell-handles.js';\nimport type { Breakpoint, PaneMode, PaneSizePersistence, PresentationValue, ResponsivePresentation, ResponsiveSidebarMode, SidebarMode } from '../shell.types.js';\nimport { BREAKPOINTS } from '../shell.types.js';\n\ninterface PaneProps extends React.ComponentPropsWithoutRef<'div'> {\n presentation?: ResponsivePresentation;\n mode?: PaneMode;\n defaultMode?: any;\n onModeChange?: (mode: PaneMode | SidebarMode) => void;\n expandedSize?: number;\n minSize?: number;\n maxSize?: number;\n resizable?: boolean;\n collapsible?: boolean;\n onExpand?: () => void;\n onCollapse?: () => void;\n onResize?: (size: number) => void;\n resizer?: React.ReactNode;\n onResizeStart?: (size: number) => void;\n onResizeEnd?: (size: number) => void;\n snapPoints?: number[];\n snapTolerance?: number;\n collapseThreshold?: number;\n paneId?: string;\n persistence?: PaneSizePersistence;\n}\n\ntype SidebarComponent = React.ForwardRefExoticComponent<\n Omit<PaneProps, 'mode' | 'defaultMode' | 'onModeChange'> & {\n mode?: SidebarMode;\n defaultMode?: ResponsiveSidebarMode;\n onModeChange?: (mode: SidebarMode) => void;\n thinSize?: number;\n toggleModes?: 'both' | 'single';\n } & React.RefAttributes<HTMLDivElement>\n> & { Handle: typeof SidebarHandle };\n\nexport const Sidebar = React.forwardRef<\n HTMLDivElement,\n Omit<PaneProps, 'mode' | 'defaultMode' | 'onModeChange'> & {\n mode?: SidebarMode;\n defaultMode?: ResponsiveSidebarMode;\n onModeChange?: (mode: SidebarMode) => void;\n thinSize?: number;\n toggleModes?: 'both' | 'single';\n }\n>(\n (\n {\n className,\n presentation = { initial: 'overlay', md: 'fixed' },\n mode,\n defaultMode = 'expanded',\n onModeChange,\n expandedSize = 288,\n minSize = 200,\n maxSize = 400,\n resizable = false,\n collapsible = true,\n onExpand,\n onCollapse,\n onResize,\n onResizeStart,\n onResizeEnd,\n snapPoints,\n snapTolerance,\n collapseThreshold,\n paneId,\n persistence,\n children,\n style,\n thinSize = 64,\n toggleModes,\n ...props\n },\n ref,\n ) => {\n const shell = useShell();\n const resolvedPresentation = useResponsivePresentation(presentation);\n const isOverlay = resolvedPresentation === 'overlay';\n const isStacked = resolvedPresentation === 'stacked';\n // Use library-managed phase for thin \u2194 expanded sequencing\n const transitionPhase = (shell as any).sidebarPhase as 'idle' | 'hiding' | 'resizing' | 'showing' | undefined;\n React.useLayoutEffect(() => {\n if (isOverlay) return;\n const containerEl = localRef.current;\n if (!containerEl) return;\n if (transitionPhase === 'hiding') {\n // Freeze width while we fade out\n try {\n const rect = containerEl.getBoundingClientRect();\n containerEl.style.width = `${Math.round(rect.width)}px`;\n } catch {}\n } else if (transitionPhase === 'resizing') {\n // Release width so the CSS width transition happens\n try {\n containerEl.style.removeProperty('width');\n } catch {}\n } else if (transitionPhase === 'idle') {\n try {\n containerEl.style.removeProperty('width');\n } catch {}\n }\n }, [transitionPhase, isOverlay]);\n const localRef = React.useRef<HTMLDivElement | null>(null);\n const setRef = React.useCallback(\n (node: HTMLDivElement | null) => {\n localRef.current = node;\n if (typeof ref === 'function') ref(node);\n else if (ref) (ref as React.MutableRefObject<HTMLDivElement | null>).current = node;\n },\n [ref],\n );\n const childArray = React.Children.toArray(children) as React.ReactElement[];\n const handleChildren = childArray.filter((el: React.ReactElement) => React.isValidElement(el) && el.type === SidebarHandle);\n const contentChildren = childArray.filter((el: React.ReactElement) => !(React.isValidElement(el) && el.type === SidebarHandle));\n\n // Register with shell\n const sidebarId = React.useId();\n React.useEffect(() => {\n shell.setHasSidebar(true);\n return () => {\n shell.setHasSidebar(false);\n };\n }, [shell, sidebarId]);\n\n // Honor defaultMode on mount when uncontrolled\n const didInitRef = React.useRef(false);\n React.useEffect(() => {\n if (didInitRef.current) return;\n didInitRef.current = true;\n if (mode === undefined && shell.sidebarMode !== (defaultMode as SidebarMode)) {\n shell.setSidebarMode(defaultMode as SidebarMode);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n // Sync controlled mode\n React.useEffect(() => {\n if (mode !== undefined && shell.sidebarMode !== mode) {\n shell.setSidebarMode(mode);\n }\n }, [mode, shell]);\n\n // Emit mode changes\n React.useEffect(() => {\n if (mode === undefined) {\n onModeChange?.(shell.sidebarMode);\n }\n }, [shell.sidebarMode, mode, onModeChange]);\n\n // Emit expand/collapse events\n React.useEffect(() => {\n if (shell.sidebarMode === 'expanded') {\n onExpand?.();\n } else {\n onCollapse?.();\n }\n }, [shell.sidebarMode, onExpand, onCollapse]);\n\n // Option A: thin is width-only; content remains visible whenever not collapsed\n const isContentVisible = shell.sidebarMode !== 'collapsed';\n\n // Default persistence if paneId provided and none supplied (fixed only)\n const persistenceAdapter = React.useMemo(() => {\n if (!paneId || persistence) return persistence;\n const key = `kookie-ui:shell:sidebar:${paneId}`;\n const adapter: PaneSizePersistence = {\n load: () => {\n if (typeof window === 'undefined') return undefined;\n const v = window.localStorage.getItem(key);\n return v ? Number(v) : undefined;\n },\n save: (size: number) => {\n if (typeof window === 'undefined') return;\n window.localStorage.setItem(key, String(size));\n },\n };\n return adapter;\n }, [paneId, persistence]);\n\n React.useEffect(() => {\n let mounted = true;\n (async () => {\n if (!resizable || !persistenceAdapter?.load || isOverlay) return;\n const loaded = await persistenceAdapter.load();\n if (mounted && typeof loaded === 'number' && localRef.current) {\n localRef.current.style.setProperty('--sidebar-size', `${loaded}px`);\n onResize?.(loaded);\n }\n })();\n return () => {\n mounted = false;\n };\n }, [resizable, persistenceAdapter, onResize, isOverlay]);\n\n // Always-follow responsive defaultMode for uncontrolled Sidebar (on breakpoint change only)\n const resolveResponsiveMode = React.useCallback((): SidebarMode => {\n if (typeof defaultMode === 'string') return defaultMode as SidebarMode;\n const dm = defaultMode as Partial<Record<Breakpoint, SidebarMode>> | undefined;\n if (dm && dm[shell.currentBreakpoint as Breakpoint]) {\n return dm[shell.currentBreakpoint as Breakpoint] as SidebarMode;\n }\n const bpKeys = Object.keys(BREAKPOINTS) as Array<keyof typeof BREAKPOINTS>;\n const order: Breakpoint[] = ([...bpKeys].reverse() as Breakpoint[]).concat('initial' as Breakpoint);\n const startIdx = order.indexOf(shell.currentBreakpoint as Breakpoint);\n for (let i = startIdx + 1; i < order.length; i++) {\n const bp = order[i];\n if (dm && dm[bp]) return dm[bp] as SidebarMode;\n }\n return 'collapsed';\n }, [defaultMode, shell.currentBreakpoint]);\n\n // Register custom toggle behavior based on toggleModes (both|single)\n const shellForToggle = useShell();\n const resolveDefaultSidebarMode = React.useCallback((): SidebarMode => {\n const resolved = resolveResponsiveMode();\n return resolved === 'thin' || resolved === 'expanded' ? resolved : 'expanded';\n }, [resolveResponsiveMode]);\n\n React.useEffect(() => {\n if (!shellForToggle.setSidebarToggleComputer) return;\n const strategy: 'both' | 'single' = toggleModes ?? 'both';\n const compute = (current: SidebarMode): SidebarMode => {\n if (strategy === 'both') {\n if (current === 'collapsed') return 'thin';\n if (current === 'thin') return 'expanded';\n return 'collapsed';\n }\n const target = resolveDefaultSidebarMode();\n if (current === 'collapsed') return target;\n if (current === target) return 'collapsed';\n return target;\n };\n shellForToggle.setSidebarToggleComputer(compute);\n return () => {\n shellForToggle.setSidebarToggleComputer?.((cur) => (cur === 'collapsed' ? 'thin' : cur === 'thin' ? 'expanded' : 'collapsed'));\n };\n }, [shellForToggle, toggleModes, resolveDefaultSidebarMode]);\n\n const lastOverlayWidthRef = React.useRef<number>(expandedSize);\n const lastOverlayModeRef = React.useRef<SidebarMode>('expanded');\n React.useEffect(() => {\n if (shell.sidebarMode !== 'collapsed') {\n lastOverlayModeRef.current = shell.sidebarMode as SidebarMode;\n lastOverlayWidthRef.current = shell.sidebarMode === 'thin' ? thinSize : expandedSize;\n }\n }, [shell.sidebarMode, thinSize, expandedSize]);\n\n const lastSidebarBpRef = React.useRef<Breakpoint | null>(null);\n React.useEffect(() => {\n if (mode !== undefined) return;\n if (!shell.currentBreakpointReady) return;\n if (lastSidebarBpRef.current === shell.currentBreakpoint) return;\n lastSidebarBpRef.current = shell.currentBreakpoint as Breakpoint;\n const next = resolveResponsiveMode();\n if (next !== shell.sidebarMode) shell.setSidebarMode(next);\n }, [mode, shell.currentBreakpoint, shell.currentBreakpointReady, resolveResponsiveMode, shell.sidebarMode, shell.setSidebarMode]);\n\n const handleEl =\n resizable && !isOverlay && shell.sidebarMode === 'expanded' ? (\n <PaneResizeContext.Provider\n value={{\n containerRef: localRef,\n cssVarName: '--sidebar-size',\n minSize,\n maxSize,\n defaultSize: expandedSize,\n orientation: 'vertical',\n edge: 'end',\n computeNext: (client, startClient, startSize) => {\n const isRtl = getComputedStyle(localRef.current!).direction === 'rtl';\n const delta = client - startClient;\n return startSize + (isRtl ? -delta : delta);\n },\n onResize,\n onResizeStart,\n onResizeEnd: (size) => {\n onResizeEnd?.(size);\n persistenceAdapter?.save?.(size);\n },\n target: 'sidebar',\n collapsible,\n snapPoints,\n snapTolerance: snapTolerance ?? 8,\n collapseThreshold,\n requestCollapse: () => shell.setSidebarMode('collapsed'),\n requestToggle: () => shell.togglePane('sidebar'),\n }}\n >\n {handleChildren.length > 0 ? handleChildren.map((el, i) => React.cloneElement(el, { key: el.key ?? i })) : <PaneHandle />}\n </PaneResizeContext.Provider>\n ) : null;\n\n if (isOverlay) {\n const open = shell.sidebarMode !== 'collapsed';\n return (\n <Sheet.Root open={open} onOpenChange={(o) => shell.setSidebarMode(o ? 'expanded' : 'collapsed')}>\n <Sheet.Content\n side=\"start\"\n style={{ padding: 0 }}\n width={{\n initial: `${open ? (shell.sidebarMode === 'thin' ? thinSize : expandedSize) : lastOverlayWidthRef.current}px`,\n }}\n >\n <VisuallyHidden>\n <Sheet.Title>Sidebar</Sheet.Title>\n </VisuallyHidden>\n {contentChildren}\n </Sheet.Content>\n </Sheet.Root>\n );\n }\n\n return (\n <div\n {...props}\n ref={setRef}\n className={classNames('rt-ShellSidebar', className)}\n data-mode={shell.sidebarMode}\n data-peek={shell.peekTarget === 'sidebar' || undefined}\n data-presentation={resolvedPresentation}\n data-open={(isStacked && isContentVisible) || undefined}\n style={{\n ...style,\n ['--sidebar-size' as any]: `${expandedSize}px`,\n ['--sidebar-thin-size' as any]: `${thinSize}px`,\n ['--sidebar-min-size' as any]: `${minSize}px`,\n ['--sidebar-max-size' as any]: `${maxSize}px`,\n ...(shell.peekTarget === 'sidebar' && shell.sidebarMode === 'collapsed' && !isOverlay\n ? (() => {\n const strategy: 'both' | 'single' = toggleModes ?? 'both';\n const current = shell.sidebarMode as SidebarMode;\n let next: SidebarMode;\n if (strategy === 'both') {\n next = current === 'collapsed' ? 'thin' : current === 'thin' ? 'expanded' : 'collapsed';\n } else {\n const target = resolveDefaultSidebarMode();\n next = current === 'collapsed' ? target : 'collapsed';\n }\n if (next === 'thin') {\n return {\n ['--peek-sidebar-width' as any]: `${thinSize}px`,\n } as React.CSSProperties;\n }\n return {\n ['--peek-sidebar-width' as any]: `var(--sidebar-size, ${expandedSize}px)`,\n } as React.CSSProperties;\n })()\n : {}),\n }}\n >\n <div className=\"rt-ShellSidebarContent\" data-visible={isContentVisible || undefined} data-phase={transitionPhase && transitionPhase !== 'idle' ? transitionPhase : undefined}>\n {contentChildren}\n </div>\n {handleEl}\n </div>\n );\n },\n) as SidebarComponent;\n\nSidebar.displayName = 'Shell.Sidebar';\nSidebar.Handle = SidebarHandle;\n"],
|
|
5
|
+
"mappings": "A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,MAAN,KAAY,SAAO,CACtB,EACCgD,CACH,CACF,CAEJ,CAEA,OACElD,EAAA,cAAC,OACE,GAAGmC,EACJ,IAAKU,GACL,UAAW5C,GAAW,kBAAmBU,CAAS,EAClD,YAAW0B,EAAM,YACjB,YAAWA,EAAM,aAAe,WAAa,OAC7C,oBAAmBC,EACnB,YAAYE,GAAaa,GAAqB,OAC9C,MAAO,CACL,GAAGrB,EACF,iBAA0B,GAAGhB,CAAY,KACzC,sBAA+B,GAAGiB,CAAQ,KAC1C,qBAA8B,GAAGhB,CAAO,KACxC,qBAA8B,GAAGC,CAAO,KACzC,GAAImB,EAAM,aAAe,WAAaA,EAAM,cAAgB,aAAe,CAACE,GACvE,IAAM,CACL,MAAM8B,EAA8BnC,GAAe,OAC7CqC,EAAUlC,EAAM,YACtB,IAAIwC,EACJ,GAAIR,IAAa,OACfQ,EAAON,IAAY,YAAc,OAASA,IAAY,OAAS,WAAa,gBACvE,CACL,MAAMC,EAASL,EAA0B,EACzCU,EAAON,IAAY,YAAcC,EAAS,WAC5C,CACA,OAAIK,IAAS,OACJ,CACJ,uBAAgC,GAAG5C,CAAQ,IAC9C,EAEK,CACJ,uBAAgC,uBAAuBjB,CAAY,KACtE,CACF,GAAG,EACH,CAAC,CACP,GAEAhB,EAAA,cAAC,OAAI,UAAU,yBAAyB,eAAcqD,GAAoB,OAAW,aAAYZ,GAAmBA,IAAoB,OAASA,EAAkB,QAChKS,CACH,EACC4B,EACH,CAEJ,CACF,EAEApE,EAAQ,YAAc,gBACtBA,EAAQ,OAASH",
|
|
6
|
+
"names": ["React", "classNames", "Sheet", "VisuallyHidden", "useShell", "useResponsivePresentation", "PaneResizeContext", "SidebarHandle", "PaneHandle", "BREAKPOINTS", "Sidebar", "className", "presentation", "mode", "defaultMode", "onModeChange", "expandedSize", "minSize", "maxSize", "resizable", "collapsible", "onExpand", "onCollapse", "onResize", "onResizeStart", "onResizeEnd", "snapPoints", "snapTolerance", "collapseThreshold", "paneId", "persistence", "children", "style", "thinSize", "toggleModes", "props", "ref", "shell", "resolvedPresentation", "isOverlay", "isStacked", "transitionPhase", "containerEl", "localRef", "rect", "setRef", "node", "childArray", "handleChildren", "el", "contentChildren", "sidebarId", "didInitRef", "isContentVisible", "persistenceAdapter", "key", "v", "size", "mounted", "loaded", "resolveResponsiveMode", "dm", "order", "startIdx", "i", "bp", "shellForToggle", "resolveDefaultSidebarMode", "resolved", "strategy", "compute", "current", "target", "cur", "lastOverlayWidthRef", "lastOverlayModeRef", "lastSidebarBpRef", "next", "handleEl", "client", "startClient", "startSize", "isRtl", "delta", "open", "o"]
|
|
7
7
|
}
|
|
@@ -15,6 +15,7 @@ export interface ShellContextValue {
|
|
|
15
15
|
setPeekTarget: (target: PaneTarget | null) => void;
|
|
16
16
|
peekPane: (target: PaneTarget) => void;
|
|
17
17
|
clearPeek: () => void;
|
|
18
|
+
sidebarPhase?: 'idle' | 'hiding' | 'resizing' | 'showing';
|
|
18
19
|
hasLeft: boolean;
|
|
19
20
|
setHasLeft: (has: boolean) => void;
|
|
20
21
|
hasSidebar: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shell.context.d.ts","sourceRoot":"","sources":["../../../src/components/shell.context.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,UAAU,EAAE,iBAAiB,EAAE,WAAW,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEzG,MAAM,WAAW,iBAAiB;IAEhC,QAAQ,EAAE,QAAQ,CAAC;IACnB,WAAW,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,IAAI,CAAC;IACtC,SAAS,EAAE,QAAQ,CAAC;IACpB,YAAY,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,IAAI,CAAC;IACvC,WAAW,EAAE,WAAW,CAAC;IACzB,cAAc,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,IAAI,CAA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E,CAAC,GAAG,EAAE,OAAO,KAAK,IAAI,CAAC;IAGtC,iBAAiB,EAAE,UAAU,CAAC;IAC9B,sBAAsB,EAAE,OAAO,CAAC;IAChC,wBAAwB,CAAC,EAAE,iBAAiB,CAAC;IAG7C,UAAU,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI,CAAC;IACzC,UAAU,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI,CAAC;IACzC,YAAY,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI,CAAC;IAE3C,wBAAwB,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,OAAO,EAAE,WAAW,KAAK,WAAW,KAAK,IAAI,CAAC;IAE/E,UAAU,CAAC,EAAE,CAAC,CAAC,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAE5C,cAAc,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CACzC;AAID,wBAAgB,QAAQ,sBAIvB;AAED,wBAAgB,aAAa,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE;IAAE,KAAK,EAAE,iBAAiB,CAAC;IAAC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,qBAEzG"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/shell.context.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nimport type { Breakpoint, PresentationValue, SidebarMode, PaneMode, PaneTarget } from './shell.types.js';\n\nexport interface ShellContextValue {\n // Pane states\n leftMode: PaneMode;\n setLeftMode: (mode: PaneMode) => void;\n panelMode: PaneMode; // Panel state within left container\n setPanelMode: (mode: PaneMode) => void;\n sidebarMode: SidebarMode;\n setSidebarMode: (mode: SidebarMode) => void;\n inspectorMode: PaneMode;\n setInspectorMode: (mode: PaneMode) => void;\n bottomMode: PaneMode;\n setBottomMode: (mode: PaneMode) => void;\n\n // Peek state (layout-only, ephemeral)\n peekTarget: PaneTarget | null;\n setPeekTarget: (target: PaneTarget | null) => void;\n peekPane: (target: PaneTarget) => void;\n clearPeek: () => void;\n\n // Composition detection\n hasLeft: boolean;\n setHasLeft: (has: boolean) => void;\n hasSidebar: boolean;\n setHasSidebar: (has: boolean) => void;\n\n // Presentation resolution\n currentBreakpoint: Breakpoint;\n currentBreakpointReady: boolean;\n leftResolvedPresentation?: PresentationValue;\n\n // Actions\n togglePane: (target: PaneTarget) => void;\n expandPane: (target: PaneTarget) => void;\n collapsePane: (target: PaneTarget) => void;\n // Toggle customization\n setSidebarToggleComputer?: (fn: (current: SidebarMode) => SidebarMode) => void;\n // Dev-only hooks for presentation warnings\n onLeftPres?: (p: PresentationValue) => void;\n // Sizing info for overlay grouping\n onLeftDefaults?: (size: number) => void;\n}\n\nconst ShellContext = React.createContext<ShellContextValue | null>(null);\n\nexport function useShell() {\n const ctx = React.useContext(ShellContext);\n if (!ctx) throw new Error('Shell components must be used within <Shell.Root>');\n return ctx;\n}\n\nexport function ShellProvider({ value, children }: { value: ShellContextValue; children: React.ReactNode }) {\n return <ShellContext.Provider value={value}>{children}</ShellContext.Provider>;\n}\n"],
|
|
5
|
-
"mappings": "AAAA,UAAYA,MAAW,
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nimport type { Breakpoint, PresentationValue, SidebarMode, PaneMode, PaneTarget } from './shell.types.js';\n\nexport interface ShellContextValue {\n // Pane states\n leftMode: PaneMode;\n setLeftMode: (mode: PaneMode) => void;\n panelMode: PaneMode; // Panel state within left container\n setPanelMode: (mode: PaneMode) => void;\n sidebarMode: SidebarMode;\n setSidebarMode: (mode: SidebarMode) => void;\n inspectorMode: PaneMode;\n setInspectorMode: (mode: PaneMode) => void;\n bottomMode: PaneMode;\n setBottomMode: (mode: PaneMode) => void;\n\n // Peek state (layout-only, ephemeral)\n peekTarget: PaneTarget | null;\n setPeekTarget: (target: PaneTarget | null) => void;\n peekPane: (target: PaneTarget) => void;\n clearPeek: () => void;\n\n // Sidebar presentation sequencing phase (library-managed)\n sidebarPhase?: 'idle' | 'hiding' | 'resizing' | 'showing';\n\n // Composition detection\n hasLeft: boolean;\n setHasLeft: (has: boolean) => void;\n hasSidebar: boolean;\n setHasSidebar: (has: boolean) => void;\n\n // Presentation resolution\n currentBreakpoint: Breakpoint;\n currentBreakpointReady: boolean;\n leftResolvedPresentation?: PresentationValue;\n\n // Actions\n togglePane: (target: PaneTarget) => void;\n expandPane: (target: PaneTarget) => void;\n collapsePane: (target: PaneTarget) => void;\n // Toggle customization\n setSidebarToggleComputer?: (fn: (current: SidebarMode) => SidebarMode) => void;\n // Dev-only hooks for presentation warnings\n onLeftPres?: (p: PresentationValue) => void;\n // Sizing info for overlay grouping\n onLeftDefaults?: (size: number) => void;\n}\n\nconst ShellContext = React.createContext<ShellContextValue | null>(null);\n\nexport function useShell() {\n const ctx = React.useContext(ShellContext);\n if (!ctx) throw new Error('Shell components must be used within <Shell.Root>');\n return ctx;\n}\n\nexport function ShellProvider({ value, children }: { value: ShellContextValue; children: React.ReactNode }) {\n return <ShellContext.Provider value={value}>{children}</ShellContext.Provider>;\n}\n"],
|
|
5
|
+
"mappings": "AAAA,UAAYA,MAAW,QAgDvB,MAAMC,EAAeD,EAAM,cAAwC,IAAI,EAEhE,SAASE,GAAW,CACzB,MAAMC,EAAMH,EAAM,WAAWC,CAAY,EACzC,GAAI,CAACE,EAAK,MAAM,IAAI,MAAM,mDAAmD,EAC7E,OAAOA,CACT,CAEO,SAASC,EAAc,CAAE,MAAAC,EAAO,SAAAC,CAAS,EAA4D,CAC1G,OAAON,EAAA,cAACC,EAAa,SAAb,CAAsB,MAAOI,GAAQC,CAAS,CACxD",
|
|
6
6
|
"names": ["React", "ShellContext", "useShell", "ctx", "ShellProvider", "value", "children"]
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shell.d.ts","sourceRoot":"","sources":["../../../src/components/shell.tsx"],"names":[],"mappings":"AA2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AA,MAAM,KAAK,EAqKN,cAAc,CAAC;AAOpB,UAAU,iBAAkB,SAAQ,KAAK,CAAC,wBAAwB,CAAC,MAAM,CAAC;CAAG;AAE7E,QAAA,MAAM,OAAO,uFAAyK,CAAC;AAWvL,KAAK,aAAa,GAAG,QAAQ,GAAG,QAAQ,GAAG,UAAU,CAAC;AAEtD,UAAU,YAAa,SAAQ,KAAK,CAAC,wBAAwB,CAAC,QAAQ,CAAC;IACrE,MAAM,EAAE,UAAU,CAAC;IACnB,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,QAAA,MAAM,OAAO,wFAqEX,CAAC;AAIH,OAAO,EACL,IAAI,EACJ,MAAM,EACN,IAAI,EACJ,IAAI,EACJ,KAAK,EACL,OAAO,EACP,OAAO,EACP,SAAS,EACT,MAAM,EACN,OAAO,EACP,QAAQ,EACR,yBAAyB,EACzB,KAAK,QAAQ,EACb,KAAK,WAAW,EAChB,KAAK,sBAAsB,EAC3B,KAAK,UAAU,EACf,KAAK,aAAa,GACnB,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";import*as e from"react";import O from"classnames";import*as Q from"./sheet.js";import"./inset.js";import{VisuallyHidden as be}from"./visually-hidden.js";import{useResponsivePresentation as ne}from"./shell.hooks.js";import{PaneResizeContext as Re}from"./_internal/shell-resize.js";import{PaneHandle as Me,PanelHandle as X}from"./_internal/shell-handles.js";import{Sidebar as Y}from"./_internal/shell-sidebar.js";import{Bottom as ae}from"./_internal/shell-bottom.js";import{Inspector as oe}from"./_internal/shell-inspector.js";import{BREAKPOINTS as se}from"./shell.types.js";import{ShellProvider as he,useShell as F}from"./shell.context.js";function ve(){const[r,m]=e.useState("initial"),[s,c]=e.useState(!1);return e.useEffect(()=>{if(typeof window>"u")return;const P=Object.entries(se).map(([i,u])=>[i,window.matchMedia(u)]),M=()=>{const i=P.filter(([,o])=>o.matches).map(([o])=>o),u=i[i.length-1]??"initial";m(u),c(!0)};return M(),P.forEach(([,i])=>i.addEventListener("change",M)),()=>{P.forEach(([,i])=>i.removeEventListener("change",M))}},[]),{bp:r,ready:s}}const le=e.forwardRef(({className:r,children:m,height:s="full",...c},E)=>{const{bp:P,ready:M}=ve(),[i,u]=e.useState("collapsed"),[o,b]=e.useState("collapsed"),[v,t]=e.useState("expanded"),[f,h]=e.useState("collapsed"),[W,B]=e.useState("collapsed"),[T,$]=e.useState(!1),[z,K]=e.useState(!1),d=e.useRef(n=>n==="collapsed"?"thin":n==="thin"?"expanded":"collapsed"),l=e.useCallback(n=>{d.current=n},[]);e.useEffect(()=>{i==="collapsed"&&b("collapsed")},[i]),e.useEffect(()=>{z&&T&&console.warn("Shell: Sidebar cannot coexist with Rail or Panel. Use either Rail+Panel OR Sidebar.")},[z,T]);const[p,S]=e.useState(void 0),R=e.useCallback(n=>S(n),[]),C=e.useRef(64),D=e.useRef(288),L=e.useCallback(n=>{C.current=n},[]),w=e.useCallback(n=>{D.current=n},[]),A=e.useMemo(()=>{const n=e.Children.toArray(m),y=(x,j)=>e.isValidElement(x)&&(x.type===j||x.type?.displayName===j.displayName);return n.some(x=>y(x,q)||y(x,I))},[m]),g=e.useMemo(()=>{const n=e.Children.toArray(m),y=(x,j)=>e.isValidElement(x)&&(x.type===j||x.type?.displayName===j.displayName);return n.some(x=>y(x,Y))},[m]),a=e.useCallback(n=>{switch(n){case"left":case"rail":u(y=>y==="expanded"?"collapsed":"expanded");break;case"panel":i==="collapsed"?(u("expanded"),b("expanded")):b(y=>y==="expanded"?"collapsed":"expanded");break;case"sidebar":t(y=>d.current(y));break;case"inspector":h(y=>y==="expanded"?"collapsed":"expanded");break;case"bottom":B(y=>y==="expanded"?"collapsed":"expanded");break}},[i]),k=e.useCallback(n=>{switch(n){case"left":case"rail":u("expanded");break;case"panel":u("expanded"),b("expanded");break;case"sidebar":t("expanded");break;case"inspector":h("expanded");break;case"bottom":B("expanded");break}},[]),H=e.useCallback(n=>{switch(n){case"left":case"rail":u("collapsed");break;case"panel":b("collapsed");break;case"sidebar":t("collapsed");break;case"inspector":h("collapsed");break;case"bottom":B("collapsed");break}},[]),G=e.useMemo(()=>({leftMode:i,setLeftMode:u,panelMode:o,setPanelMode:b,sidebarMode:v,setSidebarMode:t,inspectorMode:f,setInspectorMode:h,bottomMode:W,setBottomMode:B,hasLeft:T,setHasLeft:$,hasSidebar:z,setHasSidebar:K,currentBreakpoint:P,currentBreakpointReady:M,leftResolvedPresentation:p,togglePane:a,expandPane:k,collapsePane:H,setSidebarToggleComputer:l,onLeftPres:R,onRailDefaults:L,onPanelDefaults:w}),[i,o,v,f,W,T,z,P,M,p,a,k,H,l,R,L,w]),N=e.Children.toArray(m),V=(n,y)=>e.isValidElement(n)&&(n.type===y||n.type?.displayName===y.displayName),de=N.filter(n=>V(n,Z)),te=N.filter(n=>V(n,q)),ie=N.filter(n=>V(n,I)),pe=N.filter(n=>V(n,Y)),ce=N.filter(n=>V(n,ee)),fe=N.filter(n=>V(n,oe)),ue=N.filter(n=>V(n,ae)),me=e.useMemo(()=>s==="full"?{height:"100vh"}:s==="auto"?{height:"auto"}:typeof s=="string"?{height:s}:typeof s=="number"?{height:`${s}px`}:{},[s]),[U,J]=e.useState(null),ye=e.useCallback(n=>J(n),[]),Pe=e.useCallback(()=>J(null),[]);return e.createElement("div",{...c,ref:E,className:O("rt-ShellRoot",r),style:{...me,...c.style}},e.createElement(he,{value:{...G,peekTarget:U,setPeekTarget:J,peekPane:ye,clearPeek:Pe}},de,e.createElement("div",{className:"rt-ShellBody","data-peek-target":U??void 0,style:U==="rail"||U==="panel"?{"--peek-rail-width":`${C.current}px`}:void 0},A&&!g?(()=>{const n=te[0],y=n?{mode:n.props?.mode,defaultMode:n.props?.defaultMode,onModeChange:n.props?.onModeChange,presentation:n.props?.presentation,collapsible:n.props?.collapsible,onExpand:n.props?.onExpand,onCollapse:n.props?.onCollapse}:{};return e.createElement(_,{...y},te,ie)})():pe,ce,fe),ue))});le.displayName="Shell.Root";const Z=e.forwardRef(({className:r,height:m=64,style:s,...c},E)=>e.createElement("header",{...c,ref:E,className:O("rt-ShellHeader",r),style:{...s,"--shell-header-height":`${m}px`}}));Z.displayName="Shell.Header";const _=e.forwardRef(({className:r,presentation:m={initial:"overlay",sm:"fixed"},mode:s,defaultMode:c="collapsed",onModeChange:E,collapsible:P=!0,onExpand:M,onCollapse:i,children:u,style:o,...b},v)=>{const t=F(),f=ne(m),h=f==="overlay",W=f==="stacked",B=e.useRef(null);e.useEffect(()=>{t.onLeftPres?.(f)},[t,f]);const T=e.useCallback(d=>{B.current=d,typeof v=="function"?v(d):v&&(v.current=d)},[v]);e.useEffect(()=>(t.setHasLeft(!0),()=>t.setHasLeft(!1)),[t]);const $=e.useCallback(()=>{if(typeof c=="string")return c;const d=c;if(d&&d[t.currentBreakpoint])return d[t.currentBreakpoint];const p=[...Object.keys(se)].reverse().concat("initial"),S=p.indexOf(t.currentBreakpoint);for(let R=S+1;R<p.length;R++){const C=p[R];if(d&&d[C])return d[C]}return"collapsed"},[c,t.currentBreakpoint]),z=e.useRef(null);e.useEffect(()=>{if(s!==void 0||!t.currentBreakpointReady||z.current===t.currentBreakpoint)return;z.current=t.currentBreakpoint;const d=$();d!==t.leftMode&&t.setLeftMode(d)},[s,t.currentBreakpoint,t.currentBreakpointReady,$,t.leftMode,t.setLeftMode]),e.useEffect(()=>{s!==void 0&&t.leftMode!==s&&t.setLeftMode(s)},[s,t]),e.useEffect(()=>{s===void 0&&E?.(t.leftMode)},[t.leftMode,s,E]),e.useEffect(()=>{t.leftMode==="expanded"?M?.():i?.()},[t.leftMode,M,i]);const K=t.leftMode==="expanded";if(h){const d=t.leftMode==="expanded",l=e.Children.toArray(u),p=(g,a)=>e.isValidElement(g)&&g.type===a,S=l.find(g=>p(g,q)),R=l.find(g=>p(g,I)),C=typeof S?.props?.expandedSize=="number"?S.props.expandedSize:64,D=typeof R?.props?.expandedSize=="number"?R.props.expandedSize:288,L=!!S,w=!!R,A=(L?C:0)+(t.panelMode==="expanded"&&w?D:0);return e.createElement(Q.Root,{open:d,onOpenChange:g=>t.setLeftMode(g?"expanded":"collapsed")},e.createElement(Q.Content,{side:"start",style:{padding:0},width:{initial:`${A}px`}},e.createElement(be,null,e.createElement(Q.Title,null,"Navigation")),e.createElement("div",{className:"rt-ShellLeft"},u)))}if(W){const d=t.leftMode==="expanded",l=e.Children.toArray(u),p=(a,k)=>e.isValidElement(a)&&a.type===k,S=l.find(a=>p(a,q)),R=l.find(a=>p(a,I)),C=typeof S?.props?.expandedSize=="number"?S.props.expandedSize:64,D=typeof R?.props?.expandedSize=="number"?R.props.expandedSize:288,L=!!S,A=!!R&&(t.panelMode==="expanded"||t.peekTarget==="panel"),g=(L?C:0)+(A?D:0);return e.createElement("div",{...b,ref:T,className:O("rt-ShellLeft",r),"data-mode":t.leftMode,"data-peek":t.peekTarget==="left"||t.peekTarget==="rail"||t.peekTarget==="panel"||void 0,"data-presentation":f,style:{...o},"data-open":d||void 0},u)}return e.createElement("div",{...b,ref:T,className:O("rt-ShellLeft",r),"data-mode":t.leftMode,"data-peek":t.peekTarget==="left"||t.peekTarget==="rail"||t.peekTarget==="panel"||void 0,"data-presentation":f,style:{...o}},u)});_.displayName="Shell.Left";const q=e.forwardRef(({className:r,presentation:m,mode:s,defaultMode:c,onModeChange:E,expandedSize:P=64,collapsible:M,onExpand:i,onCollapse:u,children:o,style:b,...v},t)=>{const f=F();e.useEffect(()=>{f.onRailDefaults?.(P)},[f,P]);const h=f.leftMode==="expanded";return e.createElement("div",{...v,ref:t,className:O("rt-ShellRail",r),"data-mode":f.leftMode,"data-peek":f.leftResolvedPresentation!=="overlay"&&f.peekTarget==="rail"||void 0,style:{...b,"--rail-size":`${P}px`}},e.createElement("div",{className:"rt-ShellRailContent","data-visible":h||f.leftResolvedPresentation!=="overlay"&&f.peekTarget==="rail"||void 0},o))});q.displayName="Shell.Rail";const I=e.forwardRef(({className:r,mode:m,onModeChange:s,expandedSize:c=288,minSize:E,maxSize:P,resizable:M,collapsible:i=!0,onExpand:u,onCollapse:o,onResize:b,onResizeStart:v,onResizeEnd:t,snapPoints:f,snapTolerance:h,collapseThreshold:W,paneId:B,persistence:T,children:$,style:z,...K},d)=>{const l=F();e.useEffect(()=>{l.onPanelDefaults?.(c)},[l,c]);const p=e.useRef(null),S=e.useCallback(a=>{p.current=a,typeof d=="function"?d(a):d&&(d.current=a)},[d]),R=e.Children.toArray($),C=R.filter(a=>e.isValidElement(a)&&a.type===X),D=R.filter(a=>!(e.isValidElement(a)&&a.type===X)),L=l.leftResolvedPresentation==="overlay",w=e.useMemo(()=>{if(!B||T)return T;const a=`kookie-ui:shell:panel:${B}`;return{load:()=>{if(typeof window>"u")return;const H=window.localStorage.getItem(a);return H?Number(H):void 0},save:H=>{typeof window>"u"||window.localStorage.setItem(a,String(H))}}},[B,T]);e.useEffect(()=>{let a=!0;return(async()=>{if(!M||!w?.load||L)return;const k=await w.load();a&&typeof k=="number"&&p.current&&(p.current.style.setProperty("--panel-size",`${k}px`),b?.(k))})(),()=>{a=!1}},[M,w,b,L]),e.useEffect(()=>{p.current&&L&&p.current.style.setProperty("--panel-size",`${c}px`)},[L,c]),e.useEffect(()=>{if(p.current&&l.leftResolvedPresentation!=="overlay"&&l.leftMode==="expanded"&&l.panelMode==="expanded"){const a=p.current.parentElement||null;try{a?.style.removeProperty("width")}catch{}}},[l.leftResolvedPresentation,l.leftMode,l.panelMode]);const A=l.leftMode==="expanded"&&l.panelMode==="expanded",g=M&&l.leftResolvedPresentation!=="overlay"&&A?e.createElement(Re.Provider,{value:{containerRef:p,cssVarName:"--panel-size",minSize:typeof E=="number"?E:100,maxSize:typeof P=="number"?P:800,defaultSize:c,orientation:"vertical",edge:"end",computeNext:(a,k,H)=>{const G=getComputedStyle(p.current).direction==="rtl",N=a-k;return H+(G?-N:N)},onResize:b,onResizeStart:a=>{const H=p.current?.parentElement;try{H?.style.removeProperty("width")}catch{}v?.(a)},onResizeEnd:a=>{t?.(a),w?.save?.(a)},target:"panel",collapsible:!!i,snapPoints:f,snapTolerance:h??8,collapseThreshold:W,requestCollapse:()=>l.setPanelMode("collapsed"),requestToggle:()=>l.togglePane("panel")}},C.length>0?C.map((a,k)=>e.cloneElement(a,{key:a.key??k})):e.createElement(Me,null)):null;return e.createElement("div",{...K,ref:S,className:O("rt-ShellPanel",r),"data-mode":l.panelMode,"data-visible":A||l.leftResolvedPresentation!=="overlay"&&l.peekTarget==="panel"||void 0,"data-peek":l.leftResolvedPresentation!=="overlay"&&l.peekTarget==="panel"||void 0,style:{...z,"--panel-size":`${c}px`}},e.createElement("div",{className:"rt-ShellPanelContent","data-visible":A||void 0},D),g)});I.displayName="Shell.Panel",I.Handle=X;const ee=e.forwardRef(({className:r,...m},s)=>e.createElement("main",{...m,ref:s,className:O("rt-ShellContent",r)}));ee.displayName="Shell.Content";const re=e.forwardRef(({target:r,action:m="toggle",peekOnHover:s,onClick:c,onMouseEnter:E,onMouseLeave:P,children:M,...i},u)=>{const o=F(),b=e.useCallback(h=>{switch(c?.(h),o.peekTarget===r&&o.clearPeek(),m){case"toggle":o.togglePane(r);break;case"expand":o.expandPane(r);break;case"collapse":o.collapsePane(r);break}},[o,r,m,c]),v=(()=>{switch(r){case"left":case"rail":return o.leftMode==="collapsed";case"panel":return o.leftMode==="collapsed"||o.panelMode==="collapsed";case"sidebar":return o.sidebarMode==="collapsed";case"inspector":return o.inspectorMode==="collapsed";case"bottom":return o.bottomMode==="collapsed"}})(),t=e.useCallback(h=>{E?.(h),!(!s||!v)&&o.peekPane(r)},[E,s,v,o,r]),f=e.useCallback(h=>{P?.(h),s&&o.peekTarget===r&&o.clearPeek()},[P,s,o,r]);return e.createElement("button",{...i,ref:u,onClick:b,onMouseEnter:t,onMouseLeave:f,"data-shell-trigger":r,"data-shell-action":m},M)});re.displayName="Shell.Trigger";export{ae as Bottom,ee as Content,Z as Header,oe as Inspector,_ as Left,I as Panel,q as Rail,le as Root,Y as Sidebar,re as Trigger,ne as useResponsivePresentation,F as useShell};
|
|
1
|
+
"use client";import*as e from"react";import I from"classnames";import*as Q from"./sheet.js";import"./inset.js";import{VisuallyHidden as Me}from"./visually-hidden.js";import{useResponsivePresentation as ae}from"./shell.hooks.js";import{PaneResizeContext as he}from"./_internal/shell-resize.js";import{PaneHandle as ve,PanelHandle as X}from"./_internal/shell-handles.js";import{Sidebar as Y}from"./_internal/shell-sidebar.js";import{Bottom as oe}from"./_internal/shell-bottom.js";import{Inspector as se}from"./_internal/shell-inspector.js";import{BREAKPOINTS as le}from"./shell.types.js";import{ShellProvider as Ee,useShell as K}from"./shell.context.js";function Se(){const[i,y]=e.useState("initial"),[s,c]=e.useState(!1);return e.useEffect(()=>{if(typeof window>"u")return;const P=Object.entries(le).map(([d,m])=>[d,window.matchMedia(m)]),h=()=>{const d=P.filter(([,o])=>o.matches).map(([o])=>o),m=d[d.length-1]??"initial";y(m),c(!0)};return h(),P.forEach(([,d])=>d.addEventListener("change",h)),()=>{P.forEach(([,d])=>d.removeEventListener("change",h))}},[]),{bp:i,ready:s}}const re=e.forwardRef(({className:i,children:y,height:s="full",...c},E)=>{const{bp:P,ready:h}=Se(),[d,m]=e.useState("collapsed"),[o,R]=e.useState("collapsed"),[b,t]=e.useState("expanded"),[f,v]=e.useState("idle"),[q,H]=e.useState("collapsed"),[w,N]=e.useState("collapsed"),[z,U]=e.useState(!1),[l,r]=e.useState(!1),p=e.useRef(n=>n==="collapsed"?"thin":n==="thin"?"expanded":"collapsed"),S=e.useCallback(n=>{p.current=n},[]);e.useEffect(()=>{d==="collapsed"&&R("collapsed")},[d]),e.useEffect(()=>{l&&z&&console.warn("Shell: Sidebar cannot coexist with Rail or Panel. Use either Rail+Panel OR Sidebar.")},[l,z]);const[M,x]=e.useState(void 0),O=e.useCallback(n=>x(n),[]),T=e.useRef(64),A=e.useRef(288),B=e.useCallback(n=>{T.current=n},[]),k=e.useCallback(n=>{A.current=n},[]),a=e.useMemo(()=>{const n=e.Children.toArray(y),u=(C,D)=>e.isValidElement(C)&&(C.type===D||C.type?.displayName===D.displayName);return n.some(C=>u(C,j)||u(C,$))},[y]),g=e.useMemo(()=>{const n=e.Children.toArray(y),u=(C,D)=>e.isValidElement(C)&&(C.type===D||C.type?.displayName===D.displayName);return n.some(C=>u(C,Y))},[y]),L=e.useCallback(n=>{switch(n){case"left":case"rail":m(u=>u==="expanded"?"collapsed":"expanded");break;case"panel":d==="collapsed"?(m("expanded"),R("expanded")):R(u=>u==="expanded"?"collapsed":"expanded");break;case"sidebar":{const u=p.current(b);if(!(b!==u&&b!=="collapsed"&&u!=="collapsed")){t(u);break}const D=150;v("hiding"),window.setTimeout(()=>{v("resizing"),t(u),window.setTimeout(()=>{v("showing"),window.setTimeout(()=>v("idle"),D)},D)},D);break}case"inspector":H(u=>u==="expanded"?"collapsed":"expanded");break;case"bottom":N(u=>u==="expanded"?"collapsed":"expanded");break}},[d,b]),_=e.useCallback(n=>{switch(n){case"left":case"rail":m("expanded");break;case"panel":m("expanded"),R("expanded");break;case"sidebar":t("expanded");break;case"inspector":H("expanded");break;case"bottom":N("expanded");break}},[]),F=e.useCallback(n=>{switch(n){case"left":case"rail":m("collapsed");break;case"panel":R("collapsed");break;case"sidebar":t("collapsed");break;case"inspector":H("collapsed");break;case"bottom":N("collapsed");break}},[]),de=e.useMemo(()=>({leftMode:d,setLeftMode:m,panelMode:o,setPanelMode:R,sidebarMode:b,setSidebarMode:t,inspectorMode:q,setInspectorMode:H,bottomMode:w,setBottomMode:N,sidebarPhase:f,hasLeft:z,setHasLeft:U,hasSidebar:l,setHasSidebar:r,currentBreakpoint:P,currentBreakpointReady:h,leftResolvedPresentation:M,togglePane:L,expandPane:_,collapsePane:F,setSidebarToggleComputer:S,onLeftPres:O,onRailDefaults:B,onPanelDefaults:k}),[d,o,b,q,w,f,z,l,P,h,M,L,_,F,S,O,B,k]),V=e.Children.toArray(y),W=(n,u)=>e.isValidElement(n)&&(n.type===u||n.type?.displayName===u.displayName),pe=V.filter(n=>W(n,Z)),ne=V.filter(n=>W(n,j)),ce=V.filter(n=>W(n,$)),fe=V.filter(n=>W(n,Y)),ue=V.filter(n=>W(n,te)),me=V.filter(n=>W(n,se)),ye=V.filter(n=>W(n,oe)),be=e.useMemo(()=>s==="full"?{height:"100vh"}:s==="auto"?{height:"auto"}:typeof s=="string"?{height:s}:typeof s=="number"?{height:`${s}px`}:{},[s]),[G,J]=e.useState(null),Pe=e.useCallback(n=>J(n),[]),Re=e.useCallback(()=>J(null),[]);return e.createElement("div",{...c,ref:E,className:I("rt-ShellRoot",i),style:{...be,...c.style}},e.createElement(Ee,{value:{...de,peekTarget:G,setPeekTarget:J,peekPane:Pe,clearPeek:Re}},pe,e.createElement("div",{className:"rt-ShellBody","data-peek-target":G??void 0,style:G==="rail"||G==="panel"?{"--peek-rail-width":`${T.current}px`}:void 0},a&&!g?(()=>{const n=ne[0],u=n?{mode:n.props?.mode,defaultMode:n.props?.defaultMode,onModeChange:n.props?.onModeChange,presentation:n.props?.presentation,collapsible:n.props?.collapsible,onExpand:n.props?.onExpand,onCollapse:n.props?.onCollapse}:{};return e.createElement(ee,{...u},ne,ce)})():fe,ue,me),ye))});re.displayName="Shell.Root";const Z=e.forwardRef(({className:i,height:y=64,style:s,...c},E)=>e.createElement("header",{...c,ref:E,className:I("rt-ShellHeader",i),style:{...s,"--shell-header-height":`${y}px`}}));Z.displayName="Shell.Header";const ee=e.forwardRef(({className:i,presentation:y={initial:"overlay",sm:"fixed"},mode:s,defaultMode:c="collapsed",onModeChange:E,collapsible:P=!0,onExpand:h,onCollapse:d,children:m,style:o,...R},b)=>{const t=K(),f=ae(y),v=f==="overlay",q=f==="stacked",H=e.useRef(null);e.useEffect(()=>{t.onLeftPres?.(f)},[t,f]);const w=e.useCallback(l=>{H.current=l,typeof b=="function"?b(l):b&&(b.current=l)},[b]);e.useEffect(()=>(t.setHasLeft(!0),()=>t.setHasLeft(!1)),[t]);const N=e.useCallback(()=>{if(typeof c=="string")return c;const l=c;if(l&&l[t.currentBreakpoint])return l[t.currentBreakpoint];const p=[...Object.keys(le)].reverse().concat("initial"),S=p.indexOf(t.currentBreakpoint);for(let M=S+1;M<p.length;M++){const x=p[M];if(l&&l[x])return l[x]}return"collapsed"},[c,t.currentBreakpoint]),z=e.useRef(null);e.useEffect(()=>{if(s!==void 0||!t.currentBreakpointReady||z.current===t.currentBreakpoint)return;z.current=t.currentBreakpoint;const l=N();l!==t.leftMode&&t.setLeftMode(l)},[s,t.currentBreakpoint,t.currentBreakpointReady,N,t.leftMode,t.setLeftMode]),e.useEffect(()=>{s!==void 0&&t.leftMode!==s&&t.setLeftMode(s)},[s,t]),e.useEffect(()=>{s===void 0&&E?.(t.leftMode)},[t.leftMode,s,E]),e.useEffect(()=>{t.leftMode==="expanded"?h?.():d?.()},[t.leftMode,h,d]);const U=t.leftMode==="expanded";if(v){const l=t.leftMode==="expanded",r=e.Children.toArray(m),p=(k,a)=>e.isValidElement(k)&&k.type===a,S=r.find(k=>p(k,j)),M=r.find(k=>p(k,$)),x=typeof S?.props?.expandedSize=="number"?S.props.expandedSize:64,O=typeof M?.props?.expandedSize=="number"?M.props.expandedSize:288,T=!!S,A=!!M,B=(T?x:0)+(t.panelMode==="expanded"&&A?O:0);return e.createElement(Q.Root,{open:l,onOpenChange:k=>t.setLeftMode(k?"expanded":"collapsed")},e.createElement(Q.Content,{side:"start",style:{padding:0},width:{initial:`${B}px`}},e.createElement(Me,null,e.createElement(Q.Title,null,"Navigation")),e.createElement("div",{className:"rt-ShellLeft"},m)))}if(q){const l=t.leftMode==="expanded",r=e.Children.toArray(m),p=(a,g)=>e.isValidElement(a)&&a.type===g,S=r.find(a=>p(a,j)),M=r.find(a=>p(a,$)),x=typeof S?.props?.expandedSize=="number"?S.props.expandedSize:64,O=typeof M?.props?.expandedSize=="number"?M.props.expandedSize:288,T=!!S,B=!!M&&(t.panelMode==="expanded"||t.peekTarget==="panel"),k=(T?x:0)+(B?O:0);return e.createElement("div",{...R,ref:w,className:I("rt-ShellLeft",i),"data-mode":t.leftMode,"data-peek":t.peekTarget==="left"||t.peekTarget==="rail"||t.peekTarget==="panel"||void 0,"data-presentation":f,style:{...o},"data-open":l||void 0},m)}return e.createElement("div",{...R,ref:w,className:I("rt-ShellLeft",i),"data-mode":t.leftMode,"data-peek":t.peekTarget==="left"||t.peekTarget==="rail"||t.peekTarget==="panel"||void 0,"data-presentation":f,style:{...o}},m)});ee.displayName="Shell.Left";const j=e.forwardRef(({className:i,presentation:y,mode:s,defaultMode:c,onModeChange:E,expandedSize:P=64,collapsible:h,onExpand:d,onCollapse:m,children:o,style:R,...b},t)=>{const f=K();e.useEffect(()=>{f.onRailDefaults?.(P)},[f,P]);const v=f.leftMode==="expanded";return e.createElement("div",{...b,ref:t,className:I("rt-ShellRail",i),"data-mode":f.leftMode,"data-peek":f.leftResolvedPresentation!=="overlay"&&f.peekTarget==="rail"||void 0,style:{...R,"--rail-size":`${P}px`}},e.createElement("div",{className:"rt-ShellRailContent","data-visible":v||f.leftResolvedPresentation!=="overlay"&&f.peekTarget==="rail"||void 0},o))});j.displayName="Shell.Rail";const $=e.forwardRef(({className:i,mode:y,onModeChange:s,expandedSize:c=288,minSize:E,maxSize:P,resizable:h,collapsible:d=!0,onExpand:m,onCollapse:o,onResize:R,onResizeStart:b,onResizeEnd:t,snapPoints:f,snapTolerance:v,collapseThreshold:q,paneId:H,persistence:w,children:N,style:z,...U},l)=>{const r=K();e.useEffect(()=>{r.onPanelDefaults?.(c)},[r,c]);const p=e.useRef(null),S=e.useCallback(a=>{p.current=a,typeof l=="function"?l(a):l&&(l.current=a)},[l]),M=e.Children.toArray(N),x=M.filter(a=>e.isValidElement(a)&&a.type===X),O=M.filter(a=>!(e.isValidElement(a)&&a.type===X)),T=r.leftResolvedPresentation==="overlay",A=e.useMemo(()=>{if(!H||w)return w;const a=`kookie-ui:shell:panel:${H}`;return{load:()=>{if(typeof window>"u")return;const L=window.localStorage.getItem(a);return L?Number(L):void 0},save:L=>{typeof window>"u"||window.localStorage.setItem(a,String(L))}}},[H,w]);e.useEffect(()=>{let a=!0;return(async()=>{if(!h||!A?.load||T)return;const g=await A.load();a&&typeof g=="number"&&p.current&&(p.current.style.setProperty("--panel-size",`${g}px`),R?.(g))})(),()=>{a=!1}},[h,A,R,T]),e.useEffect(()=>{p.current&&T&&p.current.style.setProperty("--panel-size",`${c}px`)},[T,c]),e.useEffect(()=>{if(p.current&&r.leftResolvedPresentation!=="overlay"&&r.leftMode==="expanded"&&r.panelMode==="expanded"){const a=p.current.parentElement||null;try{a?.style.removeProperty("width")}catch{}}},[r.leftResolvedPresentation,r.leftMode,r.panelMode]);const B=r.leftMode==="expanded"&&r.panelMode==="expanded",k=h&&r.leftResolvedPresentation!=="overlay"&&B?e.createElement(he.Provider,{value:{containerRef:p,cssVarName:"--panel-size",minSize:typeof E=="number"?E:100,maxSize:typeof P=="number"?P:800,defaultSize:c,orientation:"vertical",edge:"end",computeNext:(a,g,L)=>{const _=getComputedStyle(p.current).direction==="rtl",F=a-g;return L+(_?-F:F)},onResize:R,onResizeStart:a=>{const L=p.current?.parentElement;try{L?.style.removeProperty("width")}catch{}b?.(a)},onResizeEnd:a=>{t?.(a),A?.save?.(a)},target:"panel",collapsible:!!d,snapPoints:f,snapTolerance:v??8,collapseThreshold:q,requestCollapse:()=>r.setPanelMode("collapsed"),requestToggle:()=>r.togglePane("panel")}},x.length>0?x.map((a,g)=>e.cloneElement(a,{key:a.key??g})):e.createElement(ve,null)):null;return e.createElement("div",{...U,ref:S,className:I("rt-ShellPanel",i),"data-mode":r.panelMode,"data-visible":B||r.leftResolvedPresentation!=="overlay"&&r.peekTarget==="panel"||void 0,"data-peek":r.leftResolvedPresentation!=="overlay"&&r.peekTarget==="panel"||void 0,style:{...z,"--panel-size":`${c}px`}},e.createElement("div",{className:"rt-ShellPanelContent","data-visible":B||void 0},O),k)});$.displayName="Shell.Panel",$.Handle=X;const te=e.forwardRef(({className:i,...y},s)=>e.createElement("main",{...y,ref:s,className:I("rt-ShellContent",i)}));te.displayName="Shell.Content";const ie=e.forwardRef(({target:i,action:y="toggle",peekOnHover:s,onClick:c,onMouseEnter:E,onMouseLeave:P,children:h,...d},m)=>{const o=K(),R=e.useCallback(v=>{switch(c?.(v),o.peekTarget===i&&o.clearPeek(),y){case"toggle":o.togglePane(i);break;case"expand":o.expandPane(i);break;case"collapse":o.collapsePane(i);break}},[o,i,y,c]),b=(()=>{switch(i){case"left":case"rail":return o.leftMode==="collapsed";case"panel":return o.leftMode==="collapsed"||o.panelMode==="collapsed";case"sidebar":return o.sidebarMode==="collapsed";case"inspector":return o.inspectorMode==="collapsed";case"bottom":return o.bottomMode==="collapsed"}})(),t=e.useCallback(v=>{E?.(v),!(!s||!b)&&o.peekPane(i)},[E,s,b,o,i]),f=e.useCallback(v=>{P?.(v),s&&o.peekTarget===i&&o.clearPeek()},[P,s,o,i]);return e.createElement("button",{...d,ref:m,onClick:R,onMouseEnter:t,onMouseLeave:f,"data-shell-trigger":i,"data-shell-action":y},h)});ie.displayName="Shell.Trigger";export{oe as Bottom,te as Content,Z as Header,se as Inspector,ee as Left,$ as Panel,j as Rail,re as Root,Y as Sidebar,ie as Trigger,ae as useResponsivePresentation,K as useShell};
|
|
2
2
|
//# sourceMappingURL=shell.js.map
|