diff --git a/packages/raystack/components/popover/popover.tsx b/packages/raystack/components/popover/popover.tsx index 823aca06c..752e02680 100644 --- a/packages/raystack/components/popover/popover.tsx +++ b/packages/raystack/components/popover/popover.tsx @@ -2,55 +2,47 @@ import { Popover as PopoverPrimitive } from '@base-ui/react'; import { cx } from 'class-variance-authority'; -import { ElementRef, forwardRef } from 'react'; import styles from './popover.module.css'; export interface PopoverContentProps extends Omit< PopoverPrimitive.Positioner.Props, - 'render' | 'className' | 'style' + 'render' | 'className' | 'style' | 'ref' >, PopoverPrimitive.Popup.Props {} -const PopoverContent = forwardRef< - ElementRef, - PopoverContentProps ->( - ( - { - initialFocus, - finalFocus, - className, - style, - render, - children, - ...positionerProps - }, - ref - ) => { - return ( - - + + - - {children} - - - - ); - } -); + {children} + + + + ); +} PopoverContent.displayName = 'Popover.Content'; export const Popover = Object.assign(PopoverPrimitive.Root, { diff --git a/packages/raystack/components/preview-card/preview-card.tsx b/packages/raystack/components/preview-card/preview-card.tsx index bbd3c7958..1e8243e9f 100644 --- a/packages/raystack/components/preview-card/preview-card.tsx +++ b/packages/raystack/components/preview-card/preview-card.tsx @@ -2,13 +2,12 @@ import { PreviewCard as PreviewCardPrimitive } from '@base-ui/react'; import { cx } from 'class-variance-authority'; -import { type ElementRef, forwardRef } from 'react'; import styles from './preview-card.module.css'; export interface PreviewCardContentProps extends Omit< PreviewCardPrimitive.Positioner.Props, - 'render' | 'className' | 'style' + 'render' | 'className' | 'style' | 'ref' >, PreviewCardPrimitive.Popup.Props { /** @@ -18,70 +17,64 @@ export interface PreviewCardContentProps showArrow?: boolean; } -const PreviewCardContent = forwardRef< - ElementRef, - PreviewCardContentProps ->( - ( - { - className, - children, - showArrow = false, - style, - render, - ...positionerProps - }, - ref - ) => { - return ( - - + + - - {children} - {showArrow && ( - - - - - - )} - - - - ); - } -); + {children} + {showArrow && ( + + + + + + )} + + + + ); +} PreviewCardContent.displayName = 'PreviewCard.Content'; -const PreviewCardViewport = forwardRef< - ElementRef, - PreviewCardPrimitive.Viewport.Props ->(({ className, ...props }, ref) => ( - -)); +function PreviewCardViewport({ + className, + ...props +}: PreviewCardPrimitive.Viewport.Props) { + return ( + + ); +} PreviewCardViewport.displayName = 'PreviewCard.Viewport'; export const PreviewCard = Object.assign(PreviewCardPrimitive.Root, { diff --git a/packages/raystack/components/progress/progress-misc.tsx b/packages/raystack/components/progress/progress-misc.tsx index f1dd42f77..9f64288cd 100644 --- a/packages/raystack/components/progress/progress-misc.tsx +++ b/packages/raystack/components/progress/progress-misc.tsx @@ -2,31 +2,32 @@ import { Progress as ProgressPrimitive } from '@base-ui/react'; import { cx } from 'class-variance-authority'; -import { type ElementRef, forwardRef } from 'react'; import styles from './progress.module.css'; -export const ProgressLabel = forwardRef< - ElementRef, - ProgressPrimitive.Label.Props ->(({ className, ...props }, ref) => ( - -)); +export function ProgressLabel({ + className, + ...props +}: ProgressPrimitive.Label.Props) { + return ( + + ); +} -ProgressLabel.displayName = 'ProgressLabel'; +ProgressLabel.displayName = 'Progress.Label'; -export const ProgressValue = forwardRef< - ElementRef, - ProgressPrimitive.Value.Props ->(({ className, ...props }, ref) => ( - -)); +export function ProgressValue({ + className, + ...props +}: ProgressPrimitive.Value.Props) { + return ( + + ); +} -ProgressValue.displayName = 'ProgressValue'; +ProgressValue.displayName = 'Progress.Value'; diff --git a/packages/raystack/components/progress/progress-root.tsx b/packages/raystack/components/progress/progress-root.tsx index f02adedd8..6cae64547 100644 --- a/packages/raystack/components/progress/progress-root.tsx +++ b/packages/raystack/components/progress/progress-root.tsx @@ -2,7 +2,7 @@ import { Progress as ProgressPrimitive } from '@base-ui/react'; import { cva, type VariantProps } from 'class-variance-authority'; -import { createContext, type ElementRef, forwardRef } from 'react'; +import { type CSSProperties, createContext } from 'react'; import styles from './progress.module.css'; import { ProgressTrack } from './progress-track'; @@ -34,48 +34,39 @@ export const ProgressContext = createContext({ percentage: 0 }); -export const ProgressRoot = forwardRef< - ElementRef, - ProgressProps ->( - ( - { - className, - style = {}, - variant = 'linear', - children = , - value = 0, - min = 0, - max = 100, - ...props - }, - ref - ) => { - const percentage = value === null ? 0 : ((value - min) * 100) / (max - min); +export function ProgressRoot({ + className, + style = {}, + variant = 'linear', + children = , + value = 0, + min = 0, + max = 100, + ...props +}: ProgressProps) { + const percentage = value === null ? 0 : ((value - min) * 100) / (max - min); - return ( - + - - {children} - - - ); - } -); + {children} + + + ); +} -ProgressRoot.displayName = 'ProgressRoot'; +ProgressRoot.displayName = 'Progress'; diff --git a/packages/raystack/components/progress/progress-track.tsx b/packages/raystack/components/progress/progress-track.tsx index 9c8e6ab80..2f1e63af1 100644 --- a/packages/raystack/components/progress/progress-track.tsx +++ b/packages/raystack/components/progress/progress-track.tsx @@ -2,20 +2,20 @@ import { Progress as ProgressPrimitive } from '@base-ui/react'; import { cx } from 'class-variance-authority'; -import { type ElementRef, forwardRef, useContext } from 'react'; +import { useContext } from 'react'; import styles from './progress.module.css'; import { ProgressContext } from './progress-root'; -export const ProgressTrack = forwardRef< - ElementRef, - ProgressPrimitive.Track.Props ->(({ className, children, ...props }, ref) => { +export function ProgressTrack({ + className, + children, + ...props +}: ProgressPrimitive.Track.Props) { const { variant } = useContext(ProgressContext); if (variant === 'circular') { return ( ( @@ -34,15 +34,11 @@ export const ProgressTrack = forwardRef< } return ( - + {children} ); -}); +} -ProgressTrack.displayName = 'ProgressTrack'; +ProgressTrack.displayName = 'Progress.Track'; diff --git a/packages/raystack/components/radio/radio.tsx b/packages/raystack/components/radio/radio.tsx index ff1d0ac93..81e79b73e 100644 --- a/packages/raystack/components/radio/radio.tsx +++ b/packages/raystack/components/radio/radio.tsx @@ -1,33 +1,24 @@ import { Radio as RadioPrimitive } from '@base-ui/react/radio'; import { RadioGroup as RadioGroupPrimitive } from '@base-ui/react/radio-group'; import { cx } from 'class-variance-authority'; -import { forwardRef } from 'react'; import styles from './radio.module.css'; -const RadioGroup = forwardRef( - ({ className, ...props }, ref) => ( - - ) -); +function RadioGroup({ className, ...props }: RadioGroupPrimitive.Props) { + return ( + + ); +} RadioGroup.displayName = 'Radio.Group'; -const RadioItem = forwardRef( - ({ className, ...props }, forwardedRef) => ( - +function RadioItem({ className, ...props }: RadioPrimitive.Root.Props) { + return ( + - ) -); + ); +} RadioItem.displayName = 'Radio'; diff --git a/packages/raystack/components/scroll-area/scroll-area-scrollbar.tsx b/packages/raystack/components/scroll-area/scroll-area-scrollbar.tsx index bcb3ca4ce..9321932d4 100644 --- a/packages/raystack/components/scroll-area/scroll-area-scrollbar.tsx +++ b/packages/raystack/components/scroll-area/scroll-area-scrollbar.tsx @@ -2,7 +2,6 @@ import { ScrollArea as ScrollAreaPrimitive } from '@base-ui/react/scroll-area'; import { cx } from 'class-variance-authority'; -import { forwardRef } from 'react'; import type { ScrollAreaType } from './scroll-area'; import styles from './scroll-area.module.css'; @@ -11,13 +10,14 @@ export interface ScrollAreaScrollbarProps type?: ScrollAreaType; } -export const ScrollAreaScrollbar = forwardRef< - HTMLDivElement, - ScrollAreaScrollbarProps ->(({ className, orientation = 'vertical', type = 'hover', ...props }, ref) => { +export function ScrollAreaScrollbar({ + className, + orientation = 'vertical', + type = 'hover', + ...props +}: ScrollAreaScrollbarProps) { return ( ); -}); +} -ScrollAreaScrollbar.displayName = 'ScrollAreaScrollbar'; +ScrollAreaScrollbar.displayName = 'ScrollArea.Scrollbar'; diff --git a/packages/raystack/components/scroll-area/scroll-area.tsx b/packages/raystack/components/scroll-area/scroll-area.tsx index a6e0c767f..2f1e53023 100644 --- a/packages/raystack/components/scroll-area/scroll-area.tsx +++ b/packages/raystack/components/scroll-area/scroll-area.tsx @@ -2,7 +2,6 @@ import { ScrollArea as ScrollAreaPrimitive } from '@base-ui/react/scroll-area'; import { cx } from 'class-variance-authority'; -import { forwardRef } from 'react'; import styles from './scroll-area.module.css'; import { ScrollAreaScrollbar } from './scroll-area-scrollbar'; @@ -12,23 +11,22 @@ export interface ScrollAreaProps extends ScrollAreaPrimitive.Root.Props { type?: ScrollAreaType; } -export const ScrollArea = forwardRef( - ({ className, type = 'hover', children, ...props }, ref) => { - return ( - - - {children} - - - - - - ); - } -); +export function ScrollArea({ + className, + type = 'hover', + children, + ...props +}: ScrollAreaProps) { + return ( + + + {children} + + + + + + ); +} ScrollArea.displayName = 'ScrollArea'; diff --git a/packages/raystack/components/search/search.tsx b/packages/raystack/components/search/search.tsx index 06ef6a669..e79fcab6e 100644 --- a/packages/raystack/components/search/search.tsx +++ b/packages/raystack/components/search/search.tsx @@ -5,7 +5,6 @@ import { IconButton } from '../icon-button'; import { InputField } from '../input-field'; import { InputFieldProps } from '../input-field/input-field'; -import { forwardRef } from 'react'; import styles from './search.module.css'; export interface SearchProps extends Omit { @@ -14,62 +13,56 @@ export interface SearchProps extends Omit { variant?: 'default' | 'borderless'; } -export const Search = forwardRef( - ( - { - className, - disabled, - placeholder = 'Search', - size, - showClearButton, - onClear, - value, - onChange, - width = '100%', - variant = 'default', - ...props - }: SearchProps, - ref - ) => { - const trailingIconWithClear = - showClearButton && value ? ( -
- { - e.stopPropagation(); - if (!disabled && onClear) { - onClear(); - } - }} - disabled={disabled} - aria-label='Clear search' - className={styles.clearButton} - > - - -
- ) : undefined; - - return ( -
- } - trailingIcon={trailingIconWithClear} - placeholder={placeholder} +export function Search({ + className, + disabled, + placeholder = 'Search', + size, + showClearButton, + onClear, + value, + onChange, + width = '100%', + variant = 'default', + ...props +}: SearchProps) { + const trailingIconWithClear = + showClearButton && value ? ( +
+ { + e.stopPropagation(); + if (!disabled && onClear) { + onClear(); + } + }} disabled={disabled} - value={value} - onChange={onChange} - size={size} - className={className} - aria-label={placeholder} - variant={variant} - ref={ref} - {...props} - /> + aria-label='Clear search' + className={styles.clearButton} + > + +
- ); - } -); + ) : undefined; + + return ( +
+ } + trailingIcon={trailingIconWithClear} + placeholder={placeholder} + disabled={disabled} + value={value} + onChange={onChange} + size={size} + className={className} + aria-label={placeholder} + variant={variant} + {...props} + /> +
+ ); +} Search.displayName = 'Search'; diff --git a/packages/raystack/components/select/select-content.tsx b/packages/raystack/components/select/select-content.tsx index 51645699b..377faae71 100644 --- a/packages/raystack/components/select/select-content.tsx +++ b/packages/raystack/components/select/select-content.tsx @@ -5,78 +5,71 @@ import { Select as SelectPrimitive } from '@base-ui/react'; import { cx } from 'class-variance-authority'; -import { forwardRef, ReactNode } from 'react'; import styles from './select.module.css'; import { useSelectContext } from './select-root'; -export interface SelectContentProps { - className?: string; - children?: ReactNode; +export interface SelectContentProps + extends Omit< + SelectPrimitive.Positioner.Props, + 'render' | 'className' | 'style' | 'ref' + >, + SelectPrimitive.Popup.Props { searchPlaceholder?: string; - sideOffset?: number; - style?: React.CSSProperties; } -export const SelectContent = forwardRef( - ( - { - className, - children, - searchPlaceholder = 'Search...', - sideOffset = 4, - ...props - }, - ref - ) => { - const { autocomplete, multiple } = useSelectContext(); - - if (autocomplete) { - return ( - - - - - - {children} - - - - - ); - } +export function SelectContent({ + className, + children, + searchPlaceholder = 'Search...', + sideOffset = 4, + ...props +}: SelectContentProps) { + const { autocomplete, multiple } = useSelectContext(); + if (autocomplete) { return ( - - + - - {children} - - - + + + + {children} + + + + ); } -); + + return ( + + + + {children} + + + + ); +} SelectContent.displayName = 'Select.Content'; diff --git a/packages/raystack/components/select/select-item.tsx b/packages/raystack/components/select/select-item.tsx index b0d12629a..9a7c52797 100644 --- a/packages/raystack/components/select/select-item.tsx +++ b/packages/raystack/components/select/select-item.tsx @@ -5,92 +5,82 @@ import { Select as SelectPrimitive } from '@base-ui/react'; import { cx } from 'class-variance-authority'; -import { forwardRef, ReactNode, useLayoutEffect } from 'react'; +import { ReactNode, useLayoutEffect } from 'react'; import { Checkbox } from '../checkbox'; import { getMatch } from '../menu/utils'; import { Text } from '../text'; import styles from './select.module.css'; import { useSelectContext } from './select-root'; -export interface SelectItemProps { - className?: string; - children?: ReactNode; - value: string; +export interface SelectItemProps extends SelectPrimitive.Item.Props { leadingIcon?: ReactNode; - disabled?: boolean; } -export const SelectItem = forwardRef( - ( - { - className, - children, - value: providedValue, - leadingIcon, - disabled, - ...props - }, - ref - ) => { - const value = String(providedValue); - const { - registerItem, - unregisterItem, - autocomplete, - searchValue, - value: selectValue, - shouldFilter, - hasItems, - multiple - } = useSelectContext(); +export function SelectItem({ + className, + children, + value: providedValue, + leadingIcon, + disabled, + ...props +}: SelectItemProps) { + const value = String(providedValue); + const { + registerItem, + unregisterItem, + autocomplete, + searchValue, + value: selectValue, + shouldFilter, + hasItems, + multiple + } = useSelectContext(); - const isSelected = multiple - ? selectValue?.includes(value) - : value === selectValue; - const isMatched = getMatch(value, children, searchValue); - const isHidden = shouldFilter && !hasItems && isSelected && !isMatched; + const isSelected = multiple + ? selectValue?.includes(value) + : value === selectValue; + const isMatched = getMatch(value, children, searchValue); + const isHidden = shouldFilter && !hasItems && isSelected && !isMatched; - const element = - typeof children === 'string' ? ( - <> - {leadingIcon &&
{leadingIcon}
} - {children} - - ) : ( - children - ); + const element = + typeof children === 'string' ? ( + <> + {leadingIcon &&
{leadingIcon}
} + {children} + + ) : ( + children + ); - useLayoutEffect(() => { - registerItem({ leadingIcon, children, value }); - return () => { - unregisterItem(value); - }; - }, [value, children, registerItem, unregisterItem, leadingIcon]); + useLayoutEffect(() => { + registerItem({ leadingIcon, children, value }); + return () => { + unregisterItem(value); + }; + }, [value, children, registerItem, unregisterItem, leadingIcon]); - if (shouldFilter && !hasItems && !isMatched && !isSelected) { - return null; - } + if (shouldFilter && !hasItems && !isMatched && !isSelected) { + return null; + } - const ItemPrimitive = autocomplete - ? ComboboxPrimitive.Item - : SelectPrimitive.Item; + const ItemPrimitive = autocomplete + ? ComboboxPrimitive.Item + : SelectPrimitive.Item; - return ( - ( -
- {multiple && } - {element} -
- )} - /> - ); - } -); + return ( + ( +
+ {multiple && } + {element} +
+ )} + /> + ); +} SelectItem.displayName = 'Select.Item'; diff --git a/packages/raystack/components/select/select-misc.tsx b/packages/raystack/components/select/select-misc.tsx index 289f64d79..b2bb47e32 100644 --- a/packages/raystack/components/select/select-misc.tsx +++ b/packages/raystack/components/select/select-misc.tsx @@ -5,85 +5,64 @@ import { Select as SelectPrimitive } from '@base-ui/react'; import { cx } from 'class-variance-authority'; -import { Fragment, forwardRef, ReactNode } from 'react'; +import { Fragment, ReactNode } from 'react'; import styles from './select.module.css'; import { useSelectContext } from './select-root'; -export interface SelectGroupProps { - className?: string; - children?: ReactNode; -} +export interface SelectGroupProps extends SelectPrimitive.Group.Props {} -export const SelectGroup = forwardRef( - ({ className, children, ...props }, ref) => { - const { shouldFilter, autocomplete } = useSelectContext(); - - if (shouldFilter) return {children}; - - const GroupPrimitive = autocomplete - ? ComboboxPrimitive.Group - : SelectPrimitive.Group; - - return ( - - {children} - - ); - } -); -SelectGroup.displayName = 'Select.Group'; +export function SelectGroup({ + className, + children, + ...props +}: SelectGroupProps) { + const { shouldFilter, autocomplete } = useSelectContext(); + + if (shouldFilter) return {children}; + + const GroupPrimitive = autocomplete + ? ComboboxPrimitive.Group + : SelectPrimitive.Group; -export interface SelectLabelProps { - className?: string; - children?: ReactNode; + return ( + + {children} + + ); } +SelectGroup.displayName = 'Select.Group'; -export const SelectLabel = forwardRef( - ({ className, ...props }, ref) => { - const { shouldFilter, autocomplete } = useSelectContext(); - - if (shouldFilter) return null; - - const LabelPrimitive = autocomplete - ? ComboboxPrimitive.GroupLabel - : SelectPrimitive.GroupLabel; - - return ( - - ); - } -); -SelectLabel.displayName = 'Select.Label'; +export interface SelectLabelProps extends SelectPrimitive.GroupLabel.Props {} + +export function SelectLabel({ className, ...props }: SelectLabelProps) { + const { shouldFilter, autocomplete } = useSelectContext(); + + if (shouldFilter) return null; -export interface SelectSeparatorProps { - className?: string; + const LabelPrimitive = autocomplete + ? ComboboxPrimitive.GroupLabel + : SelectPrimitive.GroupLabel; + + return ; } +SelectLabel.displayName = 'Select.Label'; + +export interface SelectSeparatorProps extends SelectPrimitive.Separator.Props {} + +export function SelectSeparator({ className, ...props }: SelectSeparatorProps) { + const { shouldFilter, autocomplete } = useSelectContext(); -export const SelectSeparator = forwardRef( - ({ className, ...props }, ref) => { - const { shouldFilter, autocomplete } = useSelectContext(); - - if (shouldFilter) return null; - - const SeparatorPrimitive = autocomplete - ? ComboboxPrimitive.Separator - : SelectPrimitive.Separator; - - return ( - - ); - } -); + if (shouldFilter) return null; + + const SeparatorPrimitive = autocomplete + ? ComboboxPrimitive.Separator + : SelectPrimitive.Separator; + + return ( + + ); +} SelectSeparator.displayName = 'Select.Separator'; diff --git a/packages/raystack/components/select/select-root.tsx b/packages/raystack/components/select/select-root.tsx index 120f64a9f..039758a28 100644 --- a/packages/raystack/components/select/select-root.tsx +++ b/packages/raystack/components/select/select-root.tsx @@ -203,7 +203,7 @@ export const SelectRoot = (props: SelectRootProps) => { if (autocomplete) { return ( - + { > {children} - + ); } return ( - + {children} - + ); }; + +SelectRoot.displayName = 'Select'; diff --git a/packages/raystack/components/select/select-trigger.tsx b/packages/raystack/components/select/select-trigger.tsx index 2d74bb936..6c75fbcaa 100644 --- a/packages/raystack/components/select/select-trigger.tsx +++ b/packages/raystack/components/select/select-trigger.tsx @@ -6,7 +6,7 @@ import { } from '@base-ui/react'; import { ChevronDownIcon } from '@radix-ui/react-icons'; import { cva, VariantProps } from 'class-variance-authority'; -import { ComponentPropsWithoutRef, forwardRef, SVGAttributes } from 'react'; +import { ComponentProps, SVGAttributes } from 'react'; import { Flex } from '../flex'; import styles from './select.module.css'; import { useSelectContext } from './select-root'; @@ -34,48 +34,45 @@ const trigger = cva(styles.trigger, { }); export interface SelectTriggerProps - extends ComponentPropsWithoutRef<'button'>, + extends ComponentProps<'button'>, VariantProps { iconProps?: IconProps; + nativeButton?: boolean; } -export const SelectTrigger = forwardRef( - ( - { - size, - variant, - className, - children, - iconProps = {}, - 'aria-label': ariaLabel, - ...props - }, - ref - ) => { - const { multiple, autocomplete } = useSelectContext(); +export function SelectTrigger({ + ref, + size, + variant, + className, + children, + iconProps = {}, + 'aria-label': ariaLabel, + ...props +}: SelectTriggerProps) { + const { multiple, autocomplete } = useSelectContext(); - const TriggerPrimitive = autocomplete - ? ComboboxPrimitive.Trigger - : SelectPrimitive.Trigger; + const TriggerPrimitive = autocomplete + ? ComboboxPrimitive.Trigger + : SelectPrimitive.Trigger; - return ( - - - {children} - - - ); - } -); + return ( + + + {children} + + + ); +} SelectTrigger.displayName = 'Select.Trigger'; diff --git a/packages/raystack/components/select/select-value.tsx b/packages/raystack/components/select/select-value.tsx index b796eac09..11ec4ef5b 100644 --- a/packages/raystack/components/select/select-value.tsx +++ b/packages/raystack/components/select/select-value.tsx @@ -1,7 +1,7 @@ 'use client'; import { cx } from 'class-variance-authority'; -import { forwardRef, ReactNode, useMemo } from 'react'; +import { ComponentProps, ReactNode, useMemo } from 'react'; import styles from './select.module.css'; import { SelectMultipleValue } from './select-multiple-value'; import { useSelectContext } from './select-root'; @@ -9,73 +9,75 @@ import { ItemType } from './types'; type ValueType = Omit; -type SelectValueProps = { +type SelectValueProps = ComponentProps<'span'> & { placeholder?: string; children?: ((value?: ValueType | ValueType[]) => ReactNode) | ReactNode; className?: string; }; -export const SelectValue = forwardRef( - ({ children, placeholder, className, ...props }, ref) => { - const { value, items, multiple } = useSelectContext(); +export function SelectValue({ + children, + placeholder, + className, + ...props +}: SelectValueProps) { + const { value, items, multiple } = useSelectContext(); - const hasValue = multiple - ? Array.isArray(value) && value.length > 0 - : !!value; + const hasValue = multiple + ? Array.isArray(value) && value.length > 0 + : !!value; - const item = useMemo(() => { - if (!value) return undefined; - if (multiple && Array.isArray(value)) { - const itemValues = value.map(v => items[v]); - if (itemValues.length === 1) return itemValues[0]; - return itemValues; - } - return items[value as string]; - }, [value, items, multiple]); - - if (!hasValue) { - return ( - - {placeholder} - - ); - } - - if (typeof children === 'function') { - return ( - - {children(item)} - - ); + const item = useMemo(() => { + if (!value) return undefined; + if (multiple && Array.isArray(value)) { + const itemValues = value.map(v => items[v]); + if (itemValues.length === 1) return itemValues[0]; + return itemValues; } + return items[value as string]; + }, [value, items, multiple]); - if (children) { - return ( - - {children} - - ); - } + if (!hasValue) { + return ( + + {placeholder} + + ); + } - if (Array.isArray(item)) { - return ; - } + if (typeof children === 'function') { + return ( + + {children(item)} + + ); + } + if (children) { return ( - -
- {typeof item?.children === 'string' && item?.leadingIcon && ( -
{item.leadingIcon}
- )} - {item?.children ?? value} -
+ + {children} ); } -); + + if (Array.isArray(item)) { + return ; + } + + return ( + +
+ {typeof item?.children === 'string' && item?.leadingIcon && ( +
{item.leadingIcon}
+ )} + {item?.children ?? value} +
+
+ ); +} SelectValue.displayName = 'Select.Value'; diff --git a/packages/raystack/components/side-panel/side-panel.tsx b/packages/raystack/components/side-panel/side-panel.tsx index 471169948..073f1fa27 100644 --- a/packages/raystack/components/side-panel/side-panel.tsx +++ b/packages/raystack/components/side-panel/side-panel.tsx @@ -1,5 +1,5 @@ -import { cva, VariantProps } from 'class-variance-authority'; -import { Fragment, ReactNode } from 'react'; +import { cva, cx, VariantProps } from 'class-variance-authority'; +import { ComponentProps, Fragment, ReactNode } from 'react'; import { Flex } from '../flex'; import { Text } from '../text'; import styles from './side-panel.module.css'; @@ -16,22 +16,21 @@ const sidePanelRoot = cva(styles['side-panel'], { } }); -interface SidePanelProps extends VariantProps { - children: ReactNode; - className?: string; -} +interface SidePanelProps + extends ComponentProps<'aside'>, + VariantProps {} const SidePanelRoot = ({ - children, side = 'right', - className + className, + ...props }: SidePanelProps) => { - return ( - - ); + return