Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions packages/raystack/components/sidebar/sidebar-misc.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
'use client';

import { Accordion as AccordionPrimitive } from '@base-ui/react';
import {
Accordion as AccordionPrimitive,
type AccordionRootProps
} from '@base-ui/react';
import { TriangleDownIcon } from '@radix-ui/react-icons';
import { cx } from 'class-variance-authority';
import { ComponentProps, ReactNode, useContext } from 'react';
Expand Down Expand Up @@ -41,9 +44,13 @@ export function SidebarFooter({
}
SidebarFooter.displayName = 'Sidebar.Footer';

export interface SidebarNavigationGroupProps extends ComponentProps<'section'> {
export interface SidebarNavigationGroupProps
extends ComponentProps<'section'>,
Pick<
AccordionRootProps,
'value' | 'defaultValue' | 'onValueChange' | 'disabled'
> {
label: string;
value?: string;
collapsible?: boolean;
leadingIcon?: ReactNode;
trailingIcon?: ReactNode;
Expand All @@ -62,6 +69,9 @@ export function SidebarNavigationGroup({
className,
label,
value,
defaultValue,
onValueChange,
disabled,
collapsible = false,
leadingIcon,
trailingIcon,
Expand All @@ -70,7 +80,7 @@ export function SidebarNavigationGroup({
...props
}: SidebarNavigationGroupProps) {
const { isCollapsed } = useContext(SidebarContext);
const groupValue = value ?? label;
const groupValue = label;

if (!collapsible) {
return (
Expand Down Expand Up @@ -122,7 +132,10 @@ export function SidebarNavigationGroup({
key={isCollapsed ? 'collapsed' : 'expanded'}
className={styles['nav-group-accordion']}
multiple
defaultValue={[groupValue]}
disabled={disabled}
{...(value !== undefined
? { value, onValueChange }
: { defaultValue: defaultValue ?? [groupValue] })}
>
<AccordionPrimitive.Item
value={groupValue}
Expand Down
Loading