mirror of
https://github.com/luxfi/explore.git
synced 2026-09-24 00:28:18 +00:00
* migrate from yarn to pnpm * feature-reporter: migrate from webpack to vite * remove unnecessary deps * bump pnpm to 10.32.1 * fix sitemap and favicon generator tools in docker * review and workflow fixes * fix pw test * update screenshots * update screenshot and add default maxDiffPixels value
50 lines
1.7 KiB
TypeScript
50 lines
1.7 KiB
TypeScript
import type { CheckboxGroupProps as ChakraCheckboxGroupProps } from '@chakra-ui/react';
|
|
import { Checkbox as ChakraCheckbox, CheckboxGroup as ChakraCheckboxGroup } from '@chakra-ui/react';
|
|
import * as React from 'react';
|
|
|
|
export interface CheckboxProps extends ChakraCheckbox.RootProps {
|
|
icon?: React.ReactNode;
|
|
inputProps?: React.InputHTMLAttributes<HTMLInputElement>;
|
|
rootRef?: React.Ref<HTMLLabelElement>;
|
|
}
|
|
|
|
export const Checkbox = React.forwardRef<HTMLInputElement, CheckboxProps>(
|
|
function Checkbox(props, ref) {
|
|
const { icon, children, inputProps, rootRef, ...rest } = props;
|
|
return (
|
|
<ChakraCheckbox.Root ref={ rootRef } { ...rest }>
|
|
<ChakraCheckbox.HiddenInput ref={ ref } { ...inputProps }/>
|
|
<ChakraCheckbox.Control>
|
|
{ icon || <ChakraCheckbox.Indicator/> }
|
|
</ChakraCheckbox.Control>
|
|
{ children != null && (
|
|
<ChakraCheckbox.Label>{ children }</ChakraCheckbox.Label>
|
|
) }
|
|
</ChakraCheckbox.Root>
|
|
);
|
|
},
|
|
);
|
|
|
|
export interface CheckboxGroupProps extends ChakraCheckboxGroupProps {
|
|
orientation?: 'vertical' | 'horizontal';
|
|
}
|
|
|
|
export const CheckboxGroup = React.forwardRef<HTMLDivElement, CheckboxGroupProps>(
|
|
function CheckboxGroup(props, ref) {
|
|
const { children, orientation = 'vertical', ...rest } = props;
|
|
return (
|
|
<ChakraCheckboxGroup
|
|
// @ts-ignore: ChakraCheckboxGroup is not typed correctly
|
|
ref={ ref }
|
|
orientation={ orientation }
|
|
display="flex"
|
|
flexDirection={ orientation === 'vertical' ? 'column' : 'row' }
|
|
gap={ orientation === 'vertical' ? 3 : 8 }
|
|
{ ...rest }
|
|
>
|
|
{ children }
|
|
</ChakraCheckboxGroup>
|
|
);
|
|
},
|
|
);
|