Skip to content

Commit

Permalink
fix(ActionGroup): simplify types
Browse files Browse the repository at this point in the history
  • Loading branch information
LexSwed committed Dec 31, 2022
1 parent c09570b commit a7786ab
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions src/lib/action-group/action-group.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,21 @@ import * as ToggleGroup from '@radix-ui/react-toggle-group';
import flattenChildren from 'react-keyed-flatten-children';
import { clsx } from 'clsx';

import { ComponentProps, ForwardedRef, forwardRef, isValidElement, ReactElement, ReactNode } from 'react';
import { ComponentProps, ForwardedRef, forwardRef, isValidElement, ReactElement } from 'react';
import { ToggleButton } from '../toggle-button';
import { flexCss, FlexVariants } from '../flex/flex';

import styles from './action-group.module.css';

type Props<T> = FlexVariants &
Omit<
T extends { type: 'single' } ? ToggleGroup.ToggleGroupSingleProps : ToggleGroup.ToggleGroupMultipleProps,
'direction' | 'rovingFocus' | 'as'
> & {
children?: ReactNode;
};
type Props = FlexVariants &
Omit<ToggleGroup.ToggleGroupSingleProps | ToggleGroup.ToggleGroupMultipleProps, 'direction' | 'rovingFocus' | 'as'>;

export const ActionGroup = forwardRef(
<T extends {}>(
{ children, type, gap = 'none', value, className, ...props }: Props<T>,
ref: ForwardedRef<HTMLDivElement>
) => {
({ children, type, gap = 'none', value, className, ...props }: Props, ref: ForwardedRef<HTMLDivElement>) => {
return (
// @ts-expect-error 🤷‍♂️
<ToggleGroup.Root
type={type || 'single'}
type={type}
value={value}
className={clsx(flexCss({ gap, ...props }), className)}
{...props}
Expand Down

1 comment on commit a7786ab

@vercel
Copy link

@vercel vercel bot commented on a7786ab Dec 31, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

fxtrot-ui – ./

fxtrot-ui.vercel.app
fxtrot-ui-git-main-lexswed.vercel.app
fxtrot-ui-lexswed.vercel.app

Please sign in to comment.