Skip to content

Commit

Permalink
feat: menu radio group value change callback
Browse files Browse the repository at this point in the history
  • Loading branch information
paring-chan committed Jan 3, 2025
1 parent eb1155c commit e3f22ed
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/lib/components/menu/MenuRadioGroup.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,22 @@
interface Props {
value?: string | null
defaultValue?: string
onchange?: (value: string | null) => void
children: Snippet
}
let { value = null, children, defaultValue }: Props = $props()
let { value = $bindable(null), onchange, children, defaultValue }: Props = $props()
const {
builders: { createMenuRadioGroup }
} = getContext<MenuContextData>(MenuContext)
const group = createMenuRadioGroup({ defaultValue })
const group = createMenuRadioGroup({
defaultValue,
onValueChange: (v) => {
onchange?.(v.next)
return v.next
}
})
setContext(MenuRadioContext, group)
Expand Down

0 comments on commit e3f22ed

Please sign in to comment.