refactor: radio button group value generic
This commit is contained in:
@@ -1,19 +1,19 @@
|
||||
import { VisuallyHidden, Radio, RadioGroup, useRadioStore } from '@ariakit/react'
|
||||
import { classNames } from '@standardnotes/utils'
|
||||
|
||||
type Props = {
|
||||
items: { label: string; value: string }[]
|
||||
value: string
|
||||
onChange: (value: string) => void
|
||||
type Props<Value extends string> = {
|
||||
items: { label: string; value: Value }[]
|
||||
value: Value
|
||||
onChange: (value: Value) => void
|
||||
className?: string
|
||||
}
|
||||
|
||||
const RadioButtonGroup = ({ value, items, onChange, className }: Props) => {
|
||||
function RadioButtonGroup<Value extends string>({ value, items, onChange, className }: Props<Value>) {
|
||||
const radio = useRadioStore({
|
||||
value,
|
||||
orientation: 'horizontal',
|
||||
setValue(value) {
|
||||
onChange(value as string)
|
||||
onChange(value as Value)
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ const VaultSelectionMenu = () => {
|
||||
{ label: 'One', value: 'single' },
|
||||
]}
|
||||
value={mode}
|
||||
onChange={(value) => changeSelectionMode(value as SettingsMode)}
|
||||
onChange={(value) => changeSelectionMode(value)}
|
||||
className="m-3 mt-1"
|
||||
/>
|
||||
{mode === 'many' && <ManyVaultSelectionMenu />}
|
||||
|
||||
Reference in New Issue
Block a user