Design tweaks for mod pref dialog

This commit is contained in:
Eric Bailey
2024-03-09 11:25:21 -06:00
parent ca561de2d0
commit ed91041448
2 changed files with 70 additions and 63 deletions
+6 -6
View File
@@ -49,12 +49,12 @@ const GroupContext = React.createContext<{
setFieldValue: () => {},
})
export type GroupProps = React.PropsWithChildren<{
export type GroupProps<T = string> = React.PropsWithChildren<{
type?: 'radio' | 'checkbox'
values: string[]
values: T[]
maxSelections?: number
disabled?: boolean
onChange: (value: string[]) => void
onChange: (value: T[]) => void
label: string
}>
@@ -73,7 +73,7 @@ export function useItemContext() {
return React.useContext(ItemContext)
}
export function Group({
export function Group<ValuesType = string>({
children,
values: providedValues,
onChange,
@@ -81,13 +81,13 @@ export function Group({
type = 'checkbox',
maxSelections,
label,
}: GroupProps) {
}: GroupProps<ValuesType>) {
const groupRole = type === 'radio' ? 'radiogroup' : undefined
const values = type === 'radio' ? providedValues.slice(0, 1) : providedValues
const [maxReached, setMaxReached] = React.useState(false)
const setFieldValue = React.useCallback<
(props: {name: string; value: boolean}) => void
(props: {name: ValuesType; value: boolean}) => void
>(
({name, value}) => {
if (type === 'checkbox') {