@kushagradhawan/kookie-ui 0.1.23 → 0.1.25
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 +298 -666
- package/dist/cjs/components/image.d.ts.map +1 -1
- package/dist/cjs/components/image.js +1 -1
- package/dist/cjs/components/image.js.map +3 -3
- 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 +2 -2
- package/dist/esm/components/image.d.ts.map +1 -1
- package/dist/esm/components/image.js +1 -1
- package/dist/esm/components/image.js.map +3 -3
- 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 +2 -2
- package/package.json +1 -1
- package/src/components/image.css +8 -18
- package/src/components/image.tsx +124 -112
- package/src/components/sidebar.css +333 -245
- package/src/components/sidebar.tsx +26 -5
- package/src/styles/tokens/constants.css +1 -1
- package/styles.css +299 -667
- package/tokens.css +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";import*as e from"react";import n from"classnames";import{Slot as
|
|
1
|
+
"use client";import*as e from"react";import n from"classnames";import{Slot as L}from"./slot.js";import{Accordion as x}from"radix-ui";import{sidebarPropDefs as P}from"./sidebar.props.js";import{Theme as w,useThemeContext as J}from"./theme.js";import{IconButton as Q}from"./icon-button.js";import{ScrollArea as X}from"./scroll-area.js";import{Separator as Y}from"./separator.js";import{ChevronDownIcon as Z,ThickChevronRightIcon as ee}from"./icons.js";import{extractProps as te}from"../helpers/extract-props.js";import{Kbd as oe}from"./kbd.js";import{Badge as R}from"./badge.js";const M=e.createContext(null);function H(){const t=e.useContext(M);if(!t)throw new Error("useSidebar must be used within a SidebarProvider.");return t}function re(){const[t,r]=e.useState(!1);return e.useEffect(()=>{const o=()=>{r(window.innerWidth<768)};return o(),window.addEventListener("resize",o),()=>window.removeEventListener("resize",o)},[]),t}const I=e.forwardRef(({defaultOpen:t=!0,open:r,onOpenChange:o,side:a="left",className:i,children:s,...b},p)=>{const d=re(),[m,l]=e.useState(!1),[c,f]=e.useState(t),u=r??c,g=e.useCallback(S=>{const T=typeof S=="function"?S(u):S;o?o(T):f(T)},[o,u]),v=e.useCallback(()=>d?l(S=>!S):g(S=>!S),[d,g,l]),N=u?"expanded":"collapsed",y=e.useMemo(()=>({state:N,open:u,setOpen:g,isMobile:d,openMobile:m,setOpenMobile:l,toggleSidebar:v,side:a}),[N,u,g,d,m,l,v,a]);return e.createElement("div",{...b,ref:p,className:n("rt-SidebarProvider",i),"data-state":N,"data-side":a},e.createElement(M.Provider,{value:y},s))});I.displayName="Sidebar.Provider";const z=e.forwardRef((t,r)=>{const o=J(),{isMobile:a,state:i,openMobile:s,setOpenMobile:b}=H(),{size:p=P.size.default,variant:d=P.variant.default,menuVariant:m=P.menuVariant.default,type:l=P.type.default,side:c=P.side.default,collapsible:f=P.collapsible.default,panelBackground:u,color:g,highContrast:v=P.highContrast.default,asChild:N}=t,{className:y,children:S,...T}=te(t,P),{asChild:ae,panelBackground:ne,...B}=T,h=g||o.accentColor,q=typeof p=="object"?p.initial||"2":p,C=e.useContext(M);return C&&(C.side=c,C.type=l,C.variant=d,C.menuVariant=m,C.collapsible=f,C.size=q),f==="none"?e.createElement("div",{...B,ref:r,"data-accent-color":h,"data-state":i,"data-side":c,"data-type":l,"data-collapsible":f,className:n("rt-SidebarRoot",`rt-r-size-${p}`,y)},e.createElement(w,null,e.createElement("div",{className:n("rt-SidebarContainer",`rt-variant-${d}`),"data-accent-color":h,"data-high-contrast":v||void 0,"data-side":c,"data-panel-background":u},S))):a?e.createElement("div",{...B,ref:r,"data-accent-color":h,"data-state":s?"open":"closed","data-side":c,"data-type":l,"data-collapsible":f,className:n("rt-SidebarRoot","rt-SidebarRoot--mobile",y)},e.createElement(w,null,e.createElement("div",{className:n("rt-SidebarContainer",`rt-variant-${d}`,`rt-r-size-${p}`),"data-accent-color":h,"data-high-contrast":v||void 0,"data-side":c,"data-type":l,"data-collapsible":f,"data-panel-background":u},S))):e.createElement("div",{...B,ref:r,"data-accent-color":h,"data-state":i,"data-side":c,"data-type":l,"data-collapsible":f,className:n("rt-SidebarRoot",y)},e.createElement(w,null,e.createElement("div",{className:n("rt-SidebarContainer",`rt-variant-${d}`,`rt-r-size-${p}`),"data-accent-color":h,"data-high-contrast":v||void 0,"data-side":c,"data-type":l,"data-collapsible":f,"data-panel-background":u},S)))});z.displayName="Sidebar.Root";const E=e.forwardRef(({className:t,children:r,...o},a)=>{const i=e.useContext(M),{size:s="2",menuVariant:b="soft",type:p="sidebar",collapsible:d="none"}=i||{};return e.createElement(X,{type:"auto"},e.createElement("div",{...o,ref:a,className:n("rt-BaseMenuContent","rt-SidebarContent",`rt-r-size-${s}`,`rt-menu-variant-${b}`,t),"data-type":p,"data-collapsible":d},r))});E.displayName="Sidebar.Content";const G=e.forwardRef(({className:t,asContainer:r=!0,...o},a)=>{const i=e.useContext(M),{size:s="2",menuVariant:b="soft"}=i||{};return e.createElement("div",{...o,ref:a,className:n("rt-SidebarHeader",`rt-r-size-${s}`,`rt-menu-variant-${b}`,{"rt-SidebarHeader--container":r},t)})});G.displayName="Sidebar.Header";const W=e.forwardRef(({className:t,asContainer:r=!0,...o},a)=>{const i=e.useContext(M),{size:s="2",menuVariant:b="soft"}=i||{};return e.createElement("div",{...o,ref:a,className:n("rt-SidebarFooter",`rt-r-size-${s}`,`rt-menu-variant-${b}`,{"rt-SidebarFooter--container":r},t)})});W.displayName="Sidebar.Footer";const D=e.forwardRef(({onClick:t,children:r,...o},a)=>{const{toggleSidebar:i}=H();return e.createElement(Q,{...o,ref:a,variant:"ghost",onClick:s=>{t?.(s),i()}},r||e.createElement(Z,null))});D.displayName="Sidebar.Trigger";const A=e.forwardRef(({className:t,...r},o)=>e.createElement(Y,{...r,ref:o,className:n("rt-SidebarSeparator",t)}));A.displayName="Sidebar.Separator";const $=e.forwardRef(({className:t,...r},o)=>e.createElement("ul",{...r,ref:o,className:n("rt-BaseMenuViewport","rt-SidebarMenu",t)}));$.displayName="Sidebar.Menu";const O=e.forwardRef(({className:t,...r},o)=>e.createElement("li",{...r,ref:o,className:n("rt-SidebarMenuItem",t)}));O.displayName="Sidebar.MenuItem";const k=e.forwardRef(({asChild:t=!1,isActive:r=!1,shortcut:o,badge:a,className:i,children:s,onMouseEnter:b,onMouseLeave:p,...d},m)=>{const[l,c]=e.useState(!1),f=e.useContext(M),{size:u="2"}=f||{};return e.createElement(t?L:"button",{...d,ref:m,className:n("rt-reset","rt-BaseMenuItem","rt-SidebarMenuButton",i),"data-active":r||void 0,"data-highlighted":l||void 0,onMouseEnter:v=>{c(!0),b?.(v)},onMouseLeave:v=>{c(!1),p?.(v)}},t?s:e.createElement(e.Fragment,null,s,a&&e.createElement("div",{className:"rt-SidebarMenuBadge"},typeof a=="string"?e.createElement(R,{size:u,variant:"soft"},a):e.createElement(R,{size:a.size||u,variant:a.variant||"soft",color:a.color,highContrast:a.highContrast,radius:a.radius},a.content)),o&&e.createElement("div",{className:"rt-BaseMenuShortcut rt-SidebarMenuShortcut"},e.createElement(oe,{size:u},o))))});k.displayName="Sidebar.MenuButton";const V=e.forwardRef(({defaultOpen:t=!1,children:r,...o},a)=>e.createElement("div",{...o,ref:a},e.createElement(x.Root,{type:"single",collapsible:!0,defaultValue:t?"item":void 0},e.createElement(x.Item,{value:"item"},r))));V.displayName="Sidebar.MenuSub";const F=e.forwardRef(({asChild:t=!1,className:r,children:o,onMouseEnter:a,onMouseLeave:i,...s},b)=>{const[p,d]=e.useState(!1);return e.createElement(x.Header,{asChild:!0},e.createElement("div",null,e.createElement(x.Trigger,{...s,ref:b,asChild:t,className:n("rt-reset","rt-BaseMenuItem","rt-SidebarMenuButton","rt-SidebarMenuSubTrigger",r),"data-highlighted":p||void 0,onMouseEnter:m=>{d(!0),a?.(m)},onMouseLeave:m=>{d(!1),i?.(m)}},t?o:e.createElement(e.Fragment,null,o,e.createElement(ee,{className:n("rt-BaseMenuSubTriggerIcon","rt-SidebarMenuSubTriggerIcon")})))))});F.displayName="Sidebar.MenuSubTrigger";const j=e.forwardRef(({className:t,children:r,...o},a)=>e.createElement(x.Content,{...o,ref:a,className:n("rt-SidebarMenuSubContent",t)},e.createElement("div",{className:"rt-SidebarMenuSubList"},r)));j.displayName="Sidebar.MenuSubContent";const _=e.forwardRef(({className:t,...r},o)=>e.createElement("div",{...r,ref:o,className:n("rt-BaseMenuGroup","rt-SidebarGroup",t)}));_.displayName="Sidebar.Group";const K=e.forwardRef(({asChild:t=!1,className:r,...o},a)=>e.createElement(t?L:"div",{...o,ref:a,className:n("rt-BaseMenuLabel","rt-SidebarGroupLabel",r)}));K.displayName="Sidebar.GroupLabel";const U=e.forwardRef(({className:t,...r},o)=>e.createElement("div",{...r,ref:o,className:n("rt-SidebarGroupContent",t)}));U.displayName="Sidebar.GroupContent";export{E as Content,W as Footer,_ as Group,U as GroupContent,K as GroupLabel,G as Header,$ as Menu,k as MenuButton,O as MenuItem,V as MenuSub,j as MenuSubContent,F as MenuSubTrigger,I as Provider,z as Root,A as Separator,D as Trigger,H as useSidebar};
|
|
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 { Accordion } from 'radix-ui';\n\nimport { sidebarPropDefs } from './sidebar.props.js';\nimport { Theme, useThemeContext } from './theme.js';\nimport { IconButton } from './icon-button.js';\nimport { ScrollArea } from './scroll-area.js';\nimport { Separator } from './separator.js';\nimport { ChevronDownIcon, 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// Sidebar context for state management\ntype SidebarContextProps = {\n state: 'expanded' | 'collapsed';\n open: boolean;\n setOpen: (open: boolean) => void;\n openMobile: boolean;\n setOpenMobile: (open: boolean) => void;\n isMobile: boolean;\n toggleSidebar: () => void;\n side: 'left' | 'right';\n type: 'sidebar' | 'floating';\n variant: 'soft' | 'surface' | 'ghost';\n menuVariant: 'solid' | 'soft';\n collapsible: 'offcanvas' | 'icon' | 'none';\n size: '1' | '2';\n};\n\nconst SidebarContext = React.createContext<SidebarContextProps | null>(null);\n\nfunction useSidebar() {\n const context = React.useContext(SidebarContext);\n if (!context) {\n throw new Error('useSidebar must be used within a SidebarProvider.');\n }\n return context;\n}\n\n// Hook to detect mobile (simplified version)\nfunction useIsMobile() {\n const [isMobile, setIsMobile] = React.useState(false);\n\n React.useEffect(() => {\n const checkIsMobile = () => {\n setIsMobile(window.innerWidth < 768);\n };\n\n checkIsMobile();\n window.addEventListener('resize', checkIsMobile);\n return () => window.removeEventListener('resize', checkIsMobile);\n }, []);\n\n return isMobile;\n}\n\n// Provider component\ninterface SidebarProviderProps extends React.ComponentPropsWithoutRef<'div'> {\n defaultOpen?: boolean;\n open?: boolean;\n onOpenChange?: (open: boolean) => void;\n side?: 'left' | 'right';\n}\n\nconst SidebarProvider = React.forwardRef<HTMLDivElement, SidebarProviderProps>(\n (\n {\n defaultOpen = true,\n open: openProp,\n onOpenChange: setOpenProp,\n side = 'left',\n className,\n children,\n ...props\n },\n forwardedRef,\n ) => {\n const isMobile = useIsMobile();\n const [openMobile, setOpenMobile] = React.useState(false);\n\n // Internal state for uncontrolled mode\n const [internalOpen, setInternalOpen] = React.useState(defaultOpen);\n\n // Use controlled state if provided, otherwise internal state\n const open = openProp ?? internalOpen;\n\n const setOpen = React.useCallback(\n (value: boolean | ((value: boolean) => boolean)) => {\n const openState = typeof value === 'function' ? value(open) : value;\n if (setOpenProp) {\n setOpenProp(openState);\n } else {\n setInternalOpen(openState);\n }\n },\n [setOpenProp, open],\n );\n\n // Helper to toggle the sidebar\n const toggleSidebar = React.useCallback(() => {\n return isMobile ? setOpenMobile((open) => !open) : setOpen((open) => !open);\n }, [isMobile, setOpen, setOpenMobile]);\n\n // State for data attributes\n const state = open ? 'expanded' : 'collapsed';\n\n const contextValue = React.useMemo<Partial<SidebarContextProps>>(\n () => ({\n state,\n open,\n setOpen,\n isMobile,\n openMobile,\n setOpenMobile,\n toggleSidebar,\n side,\n }),\n [state, open, setOpen, isMobile, openMobile, setOpenMobile, toggleSidebar, side],\n );\n\n return (\n <div\n {...props}\n ref={forwardedRef}\n className={classNames('rt-SidebarProvider', className)}\n data-state={state}\n data-side={side}\n >\n <SidebarContext.Provider value={contextValue as SidebarContextProps}>\n {children}\n </SidebarContext.Provider>\n </div>\n );\n },\n);\nSidebarProvider.displayName = 'Sidebar.Provider';\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 const { isMobile, state, openMobile, setOpenMobile } = useSidebar();\n\n const {\n size = sidebarPropDefs.size.default,\n variant = sidebarPropDefs.variant.default,\n menuVariant = sidebarPropDefs.menuVariant.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 asChild,\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 // Update context with current props - we'll pass the resolved values\n const resolvedSize = typeof size === 'object' ? size.initial || '2' : size;\n const context = React.useContext(SidebarContext);\n if (context) {\n context.side = side;\n context.type = type;\n context.variant = variant;\n context.menuVariant = menuVariant;\n context.collapsible = collapsible;\n context.size = resolvedSize;\n }\n\n if (collapsible === 'none') {\n return (\n <div\n {...safeRootProps}\n ref={forwardedRef}\n data-accent-color={resolvedColor}\n data-state={state}\n data-side={side}\n data-type={type}\n data-collapsible={collapsible}\n className={classNames('rt-SidebarRoot', `rt-r-size-${size}`, className)}\n >\n <Theme>\n <div\n className={classNames('rt-SidebarContainer', `rt-variant-${variant}`)}\n data-accent-color={resolvedColor}\n data-high-contrast={highContrast || undefined}\n data-side={side}\n data-panel-background={panelBackground}\n >\n {children}\n </div>\n </Theme>\n </div>\n );\n }\n\n if (isMobile) {\n return (\n <div\n {...safeRootProps}\n ref={forwardedRef}\n data-accent-color={resolvedColor}\n data-state={openMobile ? 'open' : 'closed'}\n data-side={side}\n data-type={type}\n data-collapsible={collapsible}\n className={classNames('rt-SidebarRoot', 'rt-SidebarRoot--mobile', className)}\n >\n <Theme>\n <div\n className={classNames(\n 'rt-SidebarContainer',\n `rt-variant-${variant}`,\n `rt-r-size-${size}`,\n )}\n data-accent-color={resolvedColor}\n data-high-contrast={highContrast || undefined}\n data-side={side}\n data-panel-background={panelBackground}\n >\n {children}\n </div>\n </Theme>\n </div>\n );\n }\n\n return (\n <div\n {...safeRootProps}\n ref={forwardedRef}\n data-accent-color={resolvedColor}\n data-state={state}\n data-side={side}\n data-type={type}\n data-collapsible={collapsible}\n className={classNames('rt-SidebarRoot', className)}\n >\n <Theme>\n <div\n className={classNames(\n 'rt-SidebarContainer',\n `rt-variant-${variant}`,\n `rt-r-size-${size}`,\n )}\n data-accent-color={resolvedColor}\n data-high-contrast={highContrast || undefined}\n data-side={side}\n data-panel-background={panelBackground}\n >\n {children}\n </div>\n </Theme>\n </div>\n );\n});\nSidebar.displayName = 'Sidebar.Root';\n\n// Sidebar content area\ninterface SidebarContentProps extends React.ComponentPropsWithoutRef<'div'> {}\n\nconst SidebarContent = React.forwardRef<HTMLDivElement, SidebarContentProps>(\n ({ className, children, ...props }, forwardedRef) => {\n const context = React.useContext(SidebarContext);\n const { size = '2', menuVariant = 'soft' } = context || {};\n\n return (\n <ScrollArea type=\"auto\">\n <div\n {...props}\n ref={forwardedRef}\n className={classNames(\n 'rt-SidebarContent',\n `rt-r-size-${size}`,\n `rt-menu-variant-${menuVariant}`,\n className,\n )}\n >\n {children}\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 context = React.useContext(SidebarContext);\n const { size = '2', menuVariant = 'soft' } = context || {};\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 context = React.useContext(SidebarContext);\n const { size = '2', menuVariant = 'soft' } = context || {};\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\ninterface SidebarTriggerProps extends ComponentPropsWithout<typeof IconButton, RemovedProps> {}\n\nconst SidebarTrigger = React.forwardRef<React.ElementRef<typeof IconButton>, SidebarTriggerProps>(\n ({ onClick, children, ...props }, forwardedRef) => {\n const { toggleSidebar } = useSidebar();\n\n return (\n <IconButton\n {...props}\n ref={forwardedRef}\n variant=\"ghost\"\n onClick={(event) => {\n onClick?.(event);\n toggleSidebar();\n }}\n >\n {children || <ChevronDownIcon />}\n </IconButton>\n );\n },\n);\nSidebarTrigger.displayName = 'Sidebar.Trigger';\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 {...props} ref={forwardedRef} className={classNames('rt-SidebarMenu', className)} />\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 ...props\n },\n forwardedRef,\n ) => {\n const [isHighlighted, setIsHighlighted] = React.useState(false);\n const context = React.useContext(SidebarContext);\n const { size: sidebarSize = '2' } = context || {};\n\n const Comp = asChild ? Slot : 'button';\n\n return (\n <Comp\n {...props}\n ref={forwardedRef}\n className={classNames('rt-reset', 'rt-SidebarMenuButton', className)}\n data-active={isActive || undefined}\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 {/* 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 className={classNames(\n 'rt-reset',\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 {...props} ref={forwardedRef} className={classNames('rt-SidebarGroup', className)} />\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 className={classNames('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 SidebarProvider as Provider,\n Sidebar as Root,\n SidebarContent as Content,\n SidebarHeader as Header,\n SidebarFooter as Footer,\n SidebarTrigger as Trigger,\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 // Export hook\n useSidebar,\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 SidebarProviderProps as ProviderProps,\n SidebarProps as RootProps,\n SidebarContentProps as ContentProps,\n SidebarHeaderProps as HeaderProps,\n SidebarFooterProps as FooterProps,\n SidebarTriggerProps as TriggerProps,\n BadgeConfig,\n};\n"],
|
|
5
|
-
"mappings": "aAEA,UAAYA,MAAW,QACvB,OAAOC,MAAgB,aACvB,OAAS,QAAAC,MAAY,YACrB,OAAS,aAAAC,MAAiB,WAE1B,OAAS,mBAAAC,MAAuB,qBAChC,OAAS,SAAAC,EAA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AGtCe,EAAe,OAAOd,GAAS,SAAWA,EAAK,SAAW,IAAMA,EAChE3B,EAAUjB,EAAM,WAAWe,CAAc,EAU/C,OATIE,IACFA,EAAQ,KAAOS,EACfT,EAAQ,KAAO8B,EACf9B,EAAQ,QAAU4B,EAClB5B,EAAQ,YAAc6B,EACtB7B,EAAQ,YAAc+B,EACtB/B,EAAQ,KAAOyC,GAGbV,IAAgB,OAEhBhD,EAAA,cAAC,OACE,GAAGwD,EACJ,IAAK1B,EACL,oBAAmB2B,EACnB,aAAYjB,EACZ,YAAWd,EACX,YAAWqB,EACX,mBAAkBC,EAClB,UAAW/C,EAAW,iBAAkB,aAAa2C,CAAI,GAAIjB,CAAS,GAEtE3B,EAAA,cAACK,EAAA,KACCL,EAAA,cAAC,OACC,UAAWC,EAAW,sBAAuB,cAAc4C,CAAO,EAAE,EACpE,oBAAmBY,EACnB,qBAAoBN,GAAgB,OACpC,YAAWzB,EACX,wBAAuBuB,GAEtBrB,CACH,CACF,CACF,EAIAT,EAEAnB,EAAA,cAAC,OACE,GAAGwD,EACJ,IAAK1B,EACL,oBAAmB2B,EACnB,aAAY1B,EAAa,OAAS,SAClC,YAAWL,EACX,YAAWqB,EACX,mBAAkBC,EAClB,UAAW/C,EAAW,iBAAkB,yBAA0B0B,CAAS,GAE3E3B,EAAA,cAACK,EAAA,KACCL,EAAA,cAAC,OACC,UAAWC,EACT,sBACA,cAAc4C,CAAO,GACrB,aAAaD,CAAI,EACnB,EACA,oBAAmBa,EACnB,qBAAoBN,GAAgB,OACpC,YAAWzB,EACX,
|
|
4
|
+
"sourcesContent": ["'use client';\n\nimport * as React from 'react';\nimport classNames from 'classnames';\nimport { Slot } from './slot.js';\nimport { Accordion } from 'radix-ui';\n\nimport { sidebarPropDefs } from './sidebar.props.js';\nimport { Theme, useThemeContext } from './theme.js';\nimport { IconButton } from './icon-button.js';\nimport { ScrollArea } from './scroll-area.js';\nimport { Separator } from './separator.js';\nimport { ChevronDownIcon, 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// Sidebar context for state management\ntype SidebarContextProps = {\n state: 'expanded' | 'collapsed';\n open: boolean;\n setOpen: (open: boolean) => void;\n openMobile: boolean;\n setOpenMobile: (open: boolean) => void;\n isMobile: boolean;\n toggleSidebar: () => void;\n side: 'left' | 'right';\n type: 'sidebar' | 'floating';\n variant: 'soft' | 'surface' | 'ghost';\n menuVariant: 'solid' | 'soft';\n collapsible: 'offcanvas' | 'icon' | 'none';\n size: '1' | '2';\n};\n\nconst SidebarContext = React.createContext<SidebarContextProps | null>(null);\n\nfunction useSidebar() {\n const context = React.useContext(SidebarContext);\n if (!context) {\n throw new Error('useSidebar must be used within a SidebarProvider.');\n }\n return context;\n}\n\n// Hook to detect mobile (simplified version)\nfunction useIsMobile() {\n const [isMobile, setIsMobile] = React.useState(false);\n\n React.useEffect(() => {\n const checkIsMobile = () => {\n setIsMobile(window.innerWidth < 768);\n };\n\n checkIsMobile();\n window.addEventListener('resize', checkIsMobile);\n return () => window.removeEventListener('resize', checkIsMobile);\n }, []);\n\n return isMobile;\n}\n\n// Provider component\ninterface SidebarProviderProps extends React.ComponentPropsWithoutRef<'div'> {\n defaultOpen?: boolean;\n open?: boolean;\n onOpenChange?: (open: boolean) => void;\n side?: 'left' | 'right';\n}\n\nconst SidebarProvider = React.forwardRef<HTMLDivElement, SidebarProviderProps>(\n (\n {\n defaultOpen = true,\n open: openProp,\n onOpenChange: setOpenProp,\n side = 'left',\n className,\n children,\n ...props\n },\n forwardedRef,\n ) => {\n const isMobile = useIsMobile();\n const [openMobile, setOpenMobile] = React.useState(false);\n\n // Internal state for uncontrolled mode\n const [internalOpen, setInternalOpen] = React.useState(defaultOpen);\n\n // Use controlled state if provided, otherwise internal state\n const open = openProp ?? internalOpen;\n\n const setOpen = React.useCallback(\n (value: boolean | ((value: boolean) => boolean)) => {\n const openState = typeof value === 'function' ? value(open) : value;\n if (setOpenProp) {\n setOpenProp(openState);\n } else {\n setInternalOpen(openState);\n }\n },\n [setOpenProp, open],\n );\n\n // Helper to toggle the sidebar\n const toggleSidebar = React.useCallback(() => {\n return isMobile ? setOpenMobile((open) => !open) : setOpen((open) => !open);\n }, [isMobile, setOpen, setOpenMobile]);\n\n // State for data attributes\n const state = open ? 'expanded' : 'collapsed';\n\n const contextValue = React.useMemo<Partial<SidebarContextProps>>(\n () => ({\n state,\n open,\n setOpen,\n isMobile,\n openMobile,\n setOpenMobile,\n toggleSidebar,\n side,\n }),\n [state, open, setOpen, isMobile, openMobile, setOpenMobile, toggleSidebar, side],\n );\n\n return (\n <div\n {...props}\n ref={forwardedRef}\n className={classNames('rt-SidebarProvider', className)}\n data-state={state}\n data-side={side}\n >\n <SidebarContext.Provider value={contextValue as SidebarContextProps}>\n {children}\n </SidebarContext.Provider>\n </div>\n );\n },\n);\nSidebarProvider.displayName = 'Sidebar.Provider';\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 const { isMobile, state, openMobile, setOpenMobile } = useSidebar();\n\n const {\n size = sidebarPropDefs.size.default,\n variant = sidebarPropDefs.variant.default,\n menuVariant = sidebarPropDefs.menuVariant.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 asChild,\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 // Update context with current props - we'll pass the resolved values\n const resolvedSize = typeof size === 'object' ? size.initial || '2' : size;\n const context = React.useContext(SidebarContext);\n if (context) {\n context.side = side;\n context.type = type;\n context.variant = variant;\n context.menuVariant = menuVariant;\n context.collapsible = collapsible;\n context.size = resolvedSize;\n }\n\n if (collapsible === 'none') {\n return (\n <div\n {...safeRootProps}\n ref={forwardedRef}\n data-accent-color={resolvedColor}\n data-state={state}\n data-side={side}\n data-type={type}\n data-collapsible={collapsible}\n className={classNames('rt-SidebarRoot', `rt-r-size-${size}`, className)}\n >\n <Theme>\n <div\n className={classNames('rt-SidebarContainer', `rt-variant-${variant}`)}\n data-accent-color={resolvedColor}\n data-high-contrast={highContrast || undefined}\n data-side={side}\n data-panel-background={panelBackground}\n >\n {children}\n </div>\n </Theme>\n </div>\n );\n }\n\n if (isMobile) {\n return (\n <div\n {...safeRootProps}\n ref={forwardedRef}\n data-accent-color={resolvedColor}\n data-state={openMobile ? 'open' : 'closed'}\n data-side={side}\n data-type={type}\n data-collapsible={collapsible}\n className={classNames('rt-SidebarRoot', 'rt-SidebarRoot--mobile', className)}\n >\n <Theme>\n <div\n className={classNames(\n 'rt-SidebarContainer',\n `rt-variant-${variant}`,\n `rt-r-size-${size}`,\n )}\n data-accent-color={resolvedColor}\n data-high-contrast={highContrast || undefined}\n data-side={side}\n data-type={type}\n data-collapsible={collapsible}\n data-panel-background={panelBackground}\n >\n {children}\n </div>\n </Theme>\n </div>\n );\n }\n\n return (\n <div\n {...safeRootProps}\n ref={forwardedRef}\n data-accent-color={resolvedColor}\n data-state={state}\n data-side={side}\n data-type={type}\n data-collapsible={collapsible}\n className={classNames('rt-SidebarRoot', className)}\n >\n <Theme>\n <div\n className={classNames(\n 'rt-SidebarContainer',\n `rt-variant-${variant}`,\n `rt-r-size-${size}`,\n )}\n data-accent-color={resolvedColor}\n data-high-contrast={highContrast || undefined}\n data-side={side}\n data-type={type}\n data-collapsible={collapsible}\n data-panel-background={panelBackground}\n >\n {children}\n </div>\n </Theme>\n </div>\n );\n});\nSidebar.displayName = 'Sidebar.Root';\n\n// Sidebar content area\ninterface SidebarContentProps extends React.ComponentPropsWithoutRef<'div'> {}\n\nconst SidebarContent = React.forwardRef<HTMLDivElement, SidebarContentProps>(\n ({ className, children, ...props }, forwardedRef) => {\n const context = React.useContext(SidebarContext);\n const {\n size = '2',\n menuVariant = 'soft',\n type = 'sidebar',\n collapsible = 'none',\n } = context || {};\n\n return (\n <ScrollArea type=\"auto\">\n <div\n {...props}\n ref={forwardedRef}\n className={classNames(\n 'rt-BaseMenuContent',\n 'rt-SidebarContent',\n `rt-r-size-${size}`,\n `rt-menu-variant-${menuVariant}`,\n className,\n )}\n data-type={type}\n data-collapsible={collapsible}\n >\n {children}\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 context = React.useContext(SidebarContext);\n const { size = '2', menuVariant = 'soft' } = context || {};\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 context = React.useContext(SidebarContext);\n const { size = '2', menuVariant = 'soft' } = context || {};\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\ninterface SidebarTriggerProps extends ComponentPropsWithout<typeof IconButton, RemovedProps> {}\n\nconst SidebarTrigger = React.forwardRef<React.ElementRef<typeof IconButton>, SidebarTriggerProps>(\n ({ onClick, children, ...props }, forwardedRef) => {\n const { toggleSidebar } = useSidebar();\n\n return (\n <IconButton\n {...props}\n ref={forwardedRef}\n variant=\"ghost\"\n onClick={(event) => {\n onClick?.(event);\n toggleSidebar();\n }}\n >\n {children || <ChevronDownIcon />}\n </IconButton>\n );\n },\n);\nSidebarTrigger.displayName = 'Sidebar.Trigger';\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 className={classNames('rt-BaseMenuViewport', '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 ...props\n },\n forwardedRef,\n ) => {\n const [isHighlighted, setIsHighlighted] = React.useState(false);\n const context = React.useContext(SidebarContext);\n const { size: sidebarSize = '2' } = context || {};\n\n const Comp = asChild ? Slot : 'button';\n\n return (\n <Comp\n {...props}\n ref={forwardedRef}\n className={classNames('rt-reset', 'rt-BaseMenuItem', 'rt-SidebarMenuButton', className)}\n data-active={isActive || undefined}\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 {/* 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 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 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 SidebarProvider as Provider,\n Sidebar as Root,\n SidebarContent as Content,\n SidebarHeader as Header,\n SidebarFooter as Footer,\n SidebarTrigger as Trigger,\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 // Export hook\n useSidebar,\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 SidebarProviderProps as ProviderProps,\n SidebarProps as RootProps,\n SidebarContentProps as ContentProps,\n SidebarHeaderProps as HeaderProps,\n SidebarFooterProps as FooterProps,\n SidebarTriggerProps as TriggerProps,\n BadgeConfig,\n};\n"],
|
|
5
|
+
"mappings": "aAEA,UAAYA,MAAW,QACvB,OAAOC,MAAgB,aACvB,OAAS,QAAAC,MAAY,YACrB,OAAS,aAAAC,MAAiB,WAE1B,OAAS,mBAAAC,MAAuB,qBAChC,OAAS,SAAAC,EAAO,mBAAAC,MAAuB,aACvC,OAAS,cAAAC,MAAkB,mBAC3B,OAAS,cAAAC,MAAkB,mBAC3B,OAAS,aAAAC,MAAiB,iBAC1B,OAAS,mBAAAC,EAAiB,yBAAAC,OAA6B,aACvD,OAAS,gBAAAC,OAAoB,8BAC7B,OAAS,OAAAC,OAAW,WACpB,OAAS,SAAAC,MAAa,aAiCtB,MAAMC,EAAiBf,EAAM,cAA0C,IAAI,EAE3E,SAASgB,GAAa,CACpB,MAAMC,EAAUjB,EAAM,WAAWe,CAAc,EAC/C,GAAI,CAACE,EACH,MAAM,IAAI,MAAM,mDAAmD,EAErE,OAAOA,CACT,CAGA,SAASC,IAAc,CACrB,KAAM,CAACC,EAAUC,CAAW,EAAIpB,EAAM,SAAS,EAAK,EAEpD,OAAAA,EAAM,UAAU,IAAM,CACpB,MAAMqB,EAAgB,IAAM,CAC1BD,EAAY,OAAO,WAAa,GAAG,CACrC,EAEA,OAAAC,EAAc,EACd,OAAO,iBAAiB,SAAUA,CAAa,EACxC,IAAM,OAAO,oBAAoB,SAAUA,CAAa,CACjE,EAAG,CAAC,CAAC,EAEEF,CACT,CAUA,MAAMG,EAAkBtB,EAAM,WAC5B,CACE,CACE,YAAAuB,EAAc,GACd,KAAMC,EACN,aAAcC,EACd,KAAAC,EAAO,OACP,UAAAC,EACA,SAAAC,EACA,GAAGC,CACL,EACAC,IACG,CACH,MAA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,EAAA,cACG4B,EACD5B,EAAA,cAACW,GAAA,CACC,UAAWV,EACT,4BACA,8BACF,EACF,CACF,CAEJ,CACF,CACF,CAEJ,CACF,EACA8E,EAAsB,YAAc,yBAKpC,MAAMC,EAAwBhF,EAAM,WAGlC,CAAC,CAAE,UAAA2B,EAAW,SAAAC,EAAU,GAAGC,CAAM,EAAGC,IAElC9B,EAAA,cAACG,EAAU,QAAV,CACE,GAAG0B,EACJ,IAAKC,EACL,UAAW7B,EAAW,2BAA4B0B,CAAS,GAE3D3B,EAAA,cAAC,OAAI,UAAU,yBAAyB4B,CAAS,CACnD,CAEH,EACDoD,EAAsB,YAAc,yBAKpC,MAAMC,EAAejF,EAAM,WACzB,CAAC,CAAE,UAAA2B,EAAW,GAAGE,CAAM,EAAGC,IACxB9B,EAAA,cAAC,OACE,GAAG6B,EACJ,IAAKC,EACL,UAAW7B,EAAW,mBAAoB,kBAAmB0B,CAAS,EACxE,CAEJ,EACAsD,EAAa,YAAc,gBAM3B,MAAMC,EAAoBlF,EAAM,WAC9B,CAAC,CAAE,QAAAoD,EAAU,GAAO,UAAAzB,EAAW,GAAGE,CAAM,EAAGC,IAIvC9B,EAAA,cAHWoD,EAAUlD,EAAO,MAG3B,CACE,GAAG2B,EACJ,IAAKC,EACL,UAAW7B,EAAW,mBAAoB,uBAAwB0B,CAAS,EAC7E,CAGN,EACAuD,EAAkB,YAAc,qBAIhC,MAAMC,EAAsBnF,EAAM,WAChC,CAAC,CAAE,UAAA2B,EAAW,GAAGE,CAAM,EAAGC,IACxB9B,EAAA,cAAC,OACE,GAAG6B,EACJ,IAAKC,EACL,UAAW7B,EAAW,yBAA0B0B,CAAS,EAC3D,CAEJ,EACAwD,EAAoB,YAAc",
|
|
6
6
|
"names": ["React", "classNames", "Slot", "Accordion", "sidebarPropDefs", "Theme", "useThemeContext", "IconButton", "ScrollArea", "Separator", "ChevronDownIcon", "ThickChevronRightIcon", "extractProps", "Kbd", "Badge", "SidebarContext", "useSidebar", "context", "useIsMobile", "isMobile", "setIsMobile", "checkIsMobile", "SidebarProvider", "defaultOpen", "openProp", "setOpenProp", "side", "className", "children", "props", "forwardedRef", "openMobile", "setOpenMobile", "internalOpen", "setInternalOpen", "open", "setOpen", "value", "openState", "toggleSidebar", "state", "contextValue", "Sidebar", "themeContext", "size", "variant", "menuVariant", "type", "collapsible", "panelBackground", "color", "highContrast", "asChild", "rootProps", "_", "__", "safeRootProps", "resolvedColor", "resolvedSize", "SidebarContent", "SidebarHeader", "asContainer", "SidebarFooter", "SidebarTrigger", "onClick", "event", "SidebarSeparator", "SidebarMenu", "SidebarMenuItem", "SidebarMenuButton", "isActive", "shortcut", "badge", "onMouseEnter", "onMouseLeave", "isHighlighted", "setIsHighlighted", "sidebarSize", "SidebarMenuSub", "SidebarMenuSubTrigger", "SidebarMenuSubContent", "SidebarGroup", "SidebarGroupLabel", "SidebarGroupContent"]
|
|
7
7
|
}
|
package/package.json
CHANGED
package/src/components/image.css
CHANGED
|
@@ -60,6 +60,10 @@
|
|
|
60
60
|
/* Blur variant wrapper */
|
|
61
61
|
.rt-variant-blur {
|
|
62
62
|
position: relative;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/* Blur variant when used with asChild - use inline-block for proper sizing */
|
|
66
|
+
.rt-variant-blur--as-child {
|
|
63
67
|
display: inline-block;
|
|
64
68
|
}
|
|
65
69
|
|
|
@@ -93,28 +97,14 @@
|
|
|
93
97
|
box-shadow: var(--box-shadow) !important;
|
|
94
98
|
}
|
|
95
99
|
|
|
96
|
-
/* Blur background image */
|
|
100
|
+
/* Blur background image - simplified */
|
|
97
101
|
.rt-Image--blur-bg {
|
|
98
|
-
|
|
99
|
-
top: var(--blur-offset-y, 8px);
|
|
100
|
-
left: var(--blur-offset-x, 0);
|
|
101
|
-
filter: var(--blur-filter);
|
|
102
|
-
opacity: var(--blur-opacity);
|
|
103
|
-
z-index: -1;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/* Blur variant CSS variables */
|
|
107
|
-
.rt-variant-blur {
|
|
108
|
-
--blur-filter: blur(16px) saturate(1.5);
|
|
109
|
-
--blur-opacity: 0.5;
|
|
110
|
-
--blur-offset-y: 8px;
|
|
111
|
-
--blur-offset-x: 0;
|
|
102
|
+
/* No additional styles needed - all handled inline */
|
|
112
103
|
}
|
|
113
104
|
|
|
114
|
-
/* Image inside blur variant
|
|
105
|
+
/* Image inside blur variant - simplified */
|
|
115
106
|
.rt-Image--blur {
|
|
116
|
-
|
|
117
|
-
z-index: 1;
|
|
107
|
+
/* No additional styles needed - all handled inline */
|
|
118
108
|
}
|
|
119
109
|
|
|
120
110
|
/* Object fit variants */
|
package/src/components/image.tsx
CHANGED
|
@@ -79,7 +79,7 @@ const Image = React.forwardRef<ImageElement, ImageProps>((props, forwardedRef) =
|
|
|
79
79
|
onLoad: userOnLoad,
|
|
80
80
|
onError: userOnError,
|
|
81
81
|
children,
|
|
82
|
-
...
|
|
82
|
+
...wrapperProps
|
|
83
83
|
} = extractProps(
|
|
84
84
|
restProps,
|
|
85
85
|
imagePropDefs,
|
|
@@ -97,7 +97,7 @@ const Image = React.forwardRef<ImageElement, ImageProps>((props, forwardedRef) =
|
|
|
97
97
|
// Ref to check if image is already loaded (for cached images)
|
|
98
98
|
const imgRef = React.useRef<HTMLImageElement>(null);
|
|
99
99
|
|
|
100
|
-
// Handle image load
|
|
100
|
+
// Handle image load
|
|
101
101
|
const handleLoad = React.useCallback(
|
|
102
102
|
(event: React.SyntheticEvent<HTMLImageElement>) => {
|
|
103
103
|
setImageLoaded(true);
|
|
@@ -108,7 +108,7 @@ const Image = React.forwardRef<ImageElement, ImageProps>((props, forwardedRef) =
|
|
|
108
108
|
[userOnLoad],
|
|
109
109
|
);
|
|
110
110
|
|
|
111
|
-
// Handle image error
|
|
111
|
+
// Handle image error
|
|
112
112
|
const handleError = React.useCallback(
|
|
113
113
|
(event: React.SyntheticEvent<HTMLImageElement>) => {
|
|
114
114
|
setImageLoaded(false);
|
|
@@ -139,14 +139,30 @@ const Image = React.forwardRef<ImageElement, ImageProps>((props, forwardedRef) =
|
|
|
139
139
|
console.warn('Image component: alt prop is required for accessibility when not using asChild');
|
|
140
140
|
}
|
|
141
141
|
|
|
142
|
+
// Common image styles that apply to the actual img element
|
|
143
|
+
const imgStyle: React.CSSProperties = {
|
|
144
|
+
width: '100%',
|
|
145
|
+
height: '100%',
|
|
146
|
+
display: 'block',
|
|
147
|
+
opacity: fadeIn ? (imageLoaded ? 1 : 0) : 1,
|
|
148
|
+
transition: fadeIn ? 'opacity 0.3s ease-out' : 'none',
|
|
149
|
+
...style, // Allow style overrides for the image
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
// Wrapper styles that get all the sizing and positioning
|
|
153
|
+
const wrapperStyleFinal: React.CSSProperties = {
|
|
154
|
+
position: 'relative',
|
|
155
|
+
display: 'block', // Use block instead of inline-block to work better with AspectRatio
|
|
156
|
+
...wrapperStyle,
|
|
157
|
+
};
|
|
158
|
+
|
|
142
159
|
// Create skeleton placeholder
|
|
143
160
|
const skeletonElement =
|
|
144
161
|
showSkeleton && !imageLoaded && !imageError ? (
|
|
145
162
|
<Skeleton
|
|
146
163
|
width="100%"
|
|
147
|
-
height="100px" // Default height, can be overridden by
|
|
164
|
+
height="100px" // Default height, can be overridden by wrapper
|
|
148
165
|
style={{
|
|
149
|
-
...style,
|
|
150
166
|
borderRadius: radius ? `var(--radius-${radius})` : undefined,
|
|
151
167
|
}}
|
|
152
168
|
className={className}
|
|
@@ -159,7 +175,7 @@ const Image = React.forwardRef<ImageElement, ImageProps>((props, forwardedRef) =
|
|
|
159
175
|
<img
|
|
160
176
|
data-radius={radius}
|
|
161
177
|
style={{
|
|
162
|
-
...
|
|
178
|
+
...imgStyle,
|
|
163
179
|
filter: 'blur(4px)',
|
|
164
180
|
opacity: 0.7,
|
|
165
181
|
transition: 'opacity 0.3s ease-out',
|
|
@@ -170,51 +186,7 @@ const Image = React.forwardRef<ImageElement, ImageProps>((props, forwardedRef) =
|
|
|
170
186
|
/>
|
|
171
187
|
) : null;
|
|
172
188
|
|
|
173
|
-
//
|
|
174
|
-
const imgElement = (
|
|
175
|
-
<img
|
|
176
|
-
data-radius={radius}
|
|
177
|
-
loading={loading}
|
|
178
|
-
style={{
|
|
179
|
-
...style,
|
|
180
|
-
opacity: fadeIn ? (imageLoaded ? (style?.opacity ?? 1) : 0) : (style?.opacity ?? 1),
|
|
181
|
-
transition: fadeIn ? 'opacity 0.3s ease-out' : 'none',
|
|
182
|
-
}}
|
|
183
|
-
className={classNames(
|
|
184
|
-
'rt-reset',
|
|
185
|
-
'rt-Image',
|
|
186
|
-
variant === 'blur' && 'rt-Image--blur',
|
|
187
|
-
className,
|
|
188
|
-
)}
|
|
189
|
-
alt={alt}
|
|
190
|
-
src={src}
|
|
191
|
-
onLoad={handleLoad}
|
|
192
|
-
onError={handleError}
|
|
193
|
-
{...imgProps}
|
|
194
|
-
ref={(node) => {
|
|
195
|
-
imgRef.current = node;
|
|
196
|
-
if (typeof forwardedRef === 'function') {
|
|
197
|
-
forwardedRef(node);
|
|
198
|
-
} else if (forwardedRef) {
|
|
199
|
-
forwardedRef.current = node;
|
|
200
|
-
}
|
|
201
|
-
}}
|
|
202
|
-
/>
|
|
203
|
-
);
|
|
204
|
-
|
|
205
|
-
// Wrapper for images with placeholders
|
|
206
|
-
const imageWithPlaceholder =
|
|
207
|
-
placeholder || showSkeleton ? (
|
|
208
|
-
<Box position="relative" display="inline-block" style={wrapperStyle}>
|
|
209
|
-
{skeletonElement}
|
|
210
|
-
{placeholderElement}
|
|
211
|
-
{imgElement}
|
|
212
|
-
</Box>
|
|
213
|
-
) : (
|
|
214
|
-
imgElement
|
|
215
|
-
);
|
|
216
|
-
|
|
217
|
-
// Handle asChild - inject img into the child element
|
|
189
|
+
// Handle asChild - inject content into the child element
|
|
218
190
|
if (asChild && children) {
|
|
219
191
|
const child = React.Children.only(children) as React.ReactElement<any>;
|
|
220
192
|
|
|
@@ -223,55 +195,48 @@ const Image = React.forwardRef<ImageElement, ImageProps>((props, forwardedRef) =
|
|
|
223
195
|
return React.cloneElement(child, {
|
|
224
196
|
className: classNames(child.props?.className, 'rt-variant-blur'),
|
|
225
197
|
style: {
|
|
226
|
-
textDecoration: 'none',
|
|
227
|
-
color: 'inherit',
|
|
228
|
-
border: 'none',
|
|
229
|
-
background: 'none',
|
|
230
|
-
padding: 0,
|
|
231
|
-
font: 'inherit',
|
|
232
|
-
cursor: 'pointer',
|
|
198
|
+
textDecoration: 'none',
|
|
199
|
+
color: 'inherit',
|
|
200
|
+
border: 'none',
|
|
201
|
+
background: 'none',
|
|
202
|
+
padding: 0,
|
|
203
|
+
font: 'inherit',
|
|
204
|
+
cursor: 'pointer',
|
|
205
|
+
...wrapperStyleFinal,
|
|
206
|
+
...style, // Apply sizing to the child element
|
|
233
207
|
...child.props?.style,
|
|
234
208
|
},
|
|
235
209
|
children: (
|
|
236
|
-
|
|
210
|
+
<>
|
|
237
211
|
{/* Background blurred image */}
|
|
238
212
|
<img
|
|
239
213
|
data-radius={radius}
|
|
240
214
|
loading={loading}
|
|
241
215
|
style={{
|
|
242
|
-
...style,
|
|
243
216
|
position: 'absolute',
|
|
244
|
-
top: '
|
|
217
|
+
top: '0',
|
|
245
218
|
left: '0',
|
|
219
|
+
width: '105%',
|
|
220
|
+
height: '105%',
|
|
221
|
+
transform: 'translate(-2.5%, -2.5%)',
|
|
222
|
+
filter: 'blur(16px) saturate(1.5)',
|
|
223
|
+
opacity: 0.5,
|
|
224
|
+
zIndex: -1,
|
|
246
225
|
}}
|
|
247
|
-
className={classNames(
|
|
248
|
-
'rt-reset',
|
|
249
|
-
'rt-Image',
|
|
250
|
-
'rt-Image--blur',
|
|
251
|
-
'rt-Image--blur-bg',
|
|
252
|
-
className,
|
|
253
|
-
)}
|
|
226
|
+
className={classNames('rt-reset', 'rt-Image', 'rt-Image--blur-bg', className)}
|
|
254
227
|
alt=""
|
|
255
228
|
src={src}
|
|
256
|
-
{...imgProps}
|
|
257
229
|
/>
|
|
258
230
|
{/* Foreground image */}
|
|
259
231
|
<img
|
|
260
232
|
data-radius={radius}
|
|
261
233
|
loading={loading}
|
|
262
|
-
style={
|
|
263
|
-
...style,
|
|
264
|
-
position: 'relative',
|
|
265
|
-
zIndex: 1,
|
|
266
|
-
opacity: fadeIn ? (imageLoaded ? (style?.opacity ?? 1) : 0) : (style?.opacity ?? 1),
|
|
267
|
-
transition: fadeIn ? 'opacity 0.3s ease-out' : 'none',
|
|
268
|
-
}}
|
|
234
|
+
style={imgStyle}
|
|
269
235
|
className={classNames('rt-reset', 'rt-Image', 'rt-Image--blur', className)}
|
|
270
236
|
alt={alt}
|
|
271
237
|
src={src}
|
|
272
238
|
onLoad={handleLoad}
|
|
273
239
|
onError={handleError}
|
|
274
|
-
{...imgProps}
|
|
275
240
|
ref={(node) => {
|
|
276
241
|
imgRef.current = node;
|
|
277
242
|
if (typeof forwardedRef === 'function') {
|
|
@@ -281,7 +246,7 @@ const Image = React.forwardRef<ImageElement, ImageProps>((props, forwardedRef) =
|
|
|
281
246
|
}
|
|
282
247
|
}}
|
|
283
248
|
/>
|
|
284
|
-
|
|
249
|
+
</>
|
|
285
250
|
),
|
|
286
251
|
});
|
|
287
252
|
} else {
|
|
@@ -289,68 +254,84 @@ const Image = React.forwardRef<ImageElement, ImageProps>((props, forwardedRef) =
|
|
|
289
254
|
return React.cloneElement(child, {
|
|
290
255
|
className: classNames(child.props?.className),
|
|
291
256
|
style: {
|
|
292
|
-
textDecoration: 'none',
|
|
293
|
-
color: 'inherit',
|
|
294
|
-
border: 'none',
|
|
295
|
-
background: 'none',
|
|
296
|
-
padding: 0,
|
|
297
|
-
font: 'inherit',
|
|
298
|
-
cursor: 'pointer',
|
|
299
|
-
|
|
300
|
-
...child.props?.style,
|
|
257
|
+
textDecoration: 'none',
|
|
258
|
+
color: 'inherit',
|
|
259
|
+
border: 'none',
|
|
260
|
+
background: 'none',
|
|
261
|
+
padding: 0,
|
|
262
|
+
font: 'inherit',
|
|
263
|
+
cursor: 'pointer',
|
|
264
|
+
...wrapperStyleFinal,
|
|
265
|
+
...child.props?.style,
|
|
301
266
|
},
|
|
302
|
-
children:
|
|
267
|
+
children: (
|
|
268
|
+
<>
|
|
269
|
+
{skeletonElement}
|
|
270
|
+
{placeholderElement}
|
|
271
|
+
<img
|
|
272
|
+
data-radius={radius}
|
|
273
|
+
loading={loading}
|
|
274
|
+
style={imgStyle}
|
|
275
|
+
className={classNames('rt-reset', 'rt-Image', className)}
|
|
276
|
+
alt={alt}
|
|
277
|
+
src={src}
|
|
278
|
+
onLoad={handleLoad}
|
|
279
|
+
onError={handleError}
|
|
280
|
+
ref={(node) => {
|
|
281
|
+
imgRef.current = node;
|
|
282
|
+
if (typeof forwardedRef === 'function') {
|
|
283
|
+
forwardedRef(node);
|
|
284
|
+
} else if (forwardedRef) {
|
|
285
|
+
forwardedRef.current = node;
|
|
286
|
+
}
|
|
287
|
+
}}
|
|
288
|
+
/>
|
|
289
|
+
</>
|
|
290
|
+
),
|
|
303
291
|
});
|
|
304
292
|
}
|
|
305
293
|
}
|
|
306
294
|
|
|
307
|
-
// Regular rendering without asChild
|
|
295
|
+
// Regular rendering without asChild - both variants use Box wrapper
|
|
308
296
|
if (variant === 'blur') {
|
|
309
297
|
return (
|
|
310
298
|
<Box
|
|
311
|
-
className=
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
299
|
+
className={classNames('rt-variant-blur', className)}
|
|
300
|
+
style={{
|
|
301
|
+
...style, // Include the width/height styles from extractProps
|
|
302
|
+
...wrapperStyleFinal,
|
|
303
|
+
}}
|
|
304
|
+
{...wrapperProps} // Apply other props to wrapper
|
|
315
305
|
>
|
|
316
306
|
{/* Background blurred image */}
|
|
317
307
|
<img
|
|
318
308
|
data-radius={radius}
|
|
319
309
|
loading={loading}
|
|
320
310
|
style={{
|
|
321
|
-
...style,
|
|
322
311
|
position: 'absolute',
|
|
323
|
-
top: '
|
|
312
|
+
top: '0',
|
|
324
313
|
left: '0',
|
|
314
|
+
width: '105%',
|
|
315
|
+
height: '105%',
|
|
316
|
+
transform: 'translate(-2.5%, -2.5%)',
|
|
317
|
+
filter: 'blur(16px) saturate(1.5)',
|
|
318
|
+
opacity: 0.5,
|
|
319
|
+
zIndex: -1,
|
|
325
320
|
}}
|
|
326
|
-
className={classNames(
|
|
327
|
-
'rt-reset',
|
|
328
|
-
'rt-Image',
|
|
329
|
-
'rt-Image--blur',
|
|
330
|
-
'rt-Image--blur-bg',
|
|
331
|
-
className,
|
|
332
|
-
)}
|
|
321
|
+
className={classNames('rt-reset', 'rt-Image', 'rt-Image--blur-bg', className)}
|
|
333
322
|
alt=""
|
|
334
323
|
src={src}
|
|
335
|
-
{...imgProps}
|
|
336
324
|
/>
|
|
337
325
|
{/* Foreground image */}
|
|
338
326
|
<img
|
|
339
327
|
data-radius={radius}
|
|
340
328
|
loading={loading}
|
|
341
|
-
style={
|
|
342
|
-
...style,
|
|
343
|
-
position: 'relative',
|
|
344
|
-
zIndex: 1,
|
|
345
|
-
opacity: fadeIn ? (imageLoaded ? (style?.opacity ?? 1) : 0) : (style?.opacity ?? 1),
|
|
346
|
-
transition: fadeIn ? 'opacity 0.3s ease-out' : 'none',
|
|
347
|
-
}}
|
|
329
|
+
style={imgStyle}
|
|
348
330
|
className={classNames('rt-reset', 'rt-Image', 'rt-Image--blur', className)}
|
|
349
331
|
alt={alt}
|
|
350
332
|
src={src}
|
|
351
333
|
onLoad={handleLoad}
|
|
352
334
|
onError={handleError}
|
|
353
|
-
{...imgProps}
|
|
354
335
|
ref={(node) => {
|
|
355
336
|
imgRef.current = node;
|
|
356
337
|
if (typeof forwardedRef === 'function') {
|
|
@@ -364,7 +345,38 @@ const Image = React.forwardRef<ImageElement, ImageProps>((props, forwardedRef) =
|
|
|
364
345
|
);
|
|
365
346
|
}
|
|
366
347
|
|
|
367
|
-
|
|
348
|
+
// Surface variant - also use Box wrapper for consistency
|
|
349
|
+
return (
|
|
350
|
+
<Box
|
|
351
|
+
className={className}
|
|
352
|
+
style={{
|
|
353
|
+
...style, // Include the width/height styles from extractProps
|
|
354
|
+
...wrapperStyleFinal,
|
|
355
|
+
}}
|
|
356
|
+
{...wrapperProps} // Apply other props to wrapper
|
|
357
|
+
>
|
|
358
|
+
{skeletonElement}
|
|
359
|
+
{placeholderElement}
|
|
360
|
+
<img
|
|
361
|
+
data-radius={radius}
|
|
362
|
+
loading={loading}
|
|
363
|
+
style={imgStyle}
|
|
364
|
+
className={classNames('rt-reset', 'rt-Image', className)}
|
|
365
|
+
alt={alt}
|
|
366
|
+
src={src}
|
|
367
|
+
onLoad={handleLoad}
|
|
368
|
+
onError={handleError}
|
|
369
|
+
ref={(node) => {
|
|
370
|
+
imgRef.current = node;
|
|
371
|
+
if (typeof forwardedRef === 'function') {
|
|
372
|
+
forwardedRef(node);
|
|
373
|
+
} else if (forwardedRef) {
|
|
374
|
+
forwardedRef.current = node;
|
|
375
|
+
}
|
|
376
|
+
}}
|
|
377
|
+
/>
|
|
378
|
+
</Box>
|
|
379
|
+
);
|
|
368
380
|
});
|
|
369
381
|
|
|
370
382
|
Image.displayName = 'Image';
|