From 7ff28492a29180a0af4eb8315581b3dcc63b751e Mon Sep 17 00:00:00 2001 From: Ryan Gossiaux Date: Mon, 20 Dec 2021 22:40:09 -0800 Subject: [PATCH] Move RadioGroup to --- .../components/radio-group/RadioGroup.svelte | 28 +++++++--- .../radio-group/RadioGroupOption.svelte | 53 ++++++++++--------- 2 files changed, 50 insertions(+), 31 deletions(-) diff --git a/src/lib/components/radio-group/RadioGroup.svelte b/src/lib/components/radio-group/RadioGroup.svelte index 84766e7..2ca21fa 100644 --- a/src/lib/components/radio-group/RadioGroup.svelte +++ b/src/lib/components/radio-group/RadioGroup.svelte @@ -46,6 +46,18 @@ - - -
+ + -
+
diff --git a/src/lib/components/radio-group/RadioGroupOption.svelte b/src/lib/components/radio-group/RadioGroupOption.svelte index 3aaaac1..f6bad7c 100644 --- a/src/lib/components/radio-group/RadioGroupOption.svelte +++ b/src/lib/components/radio-group/RadioGroupOption.svelte @@ -2,9 +2,17 @@ import { onDestroy } from "svelte"; import DescriptionProvider from "$lib/components/description/DescriptionProvider.svelte"; import LabelProvider from "$lib/components/label/LabelProvider.svelte"; - import { useRadioGroupContext, Option } from "./RadioGroup.svelte"; import { useId } from "$lib/hooks/use-id"; + import { forwardEventsBuilder } from "$lib/internal/forwardEventsBuilder"; + import { get_current_component } from "svelte/internal"; + import type { SupportedAs } from "$lib/internal/elements"; + import type { HTMLActionArray } from "$lib/hooks/use-actions"; + import Render from "$lib/utils/Render.svelte"; + const forwardEvents = forwardEventsBuilder(get_current_component()); + + export let as: SupportedAs = "div"; + export let use: HTMLActionArray = []; enum OptionState { Empty = 1 << 0, @@ -50,42 +58,37 @@ state &= ~OptionState.Active; } - $: classStyle = $$props.class - ? typeof $$props.class === "function" - ? $$props.class({ - active: state & OptionState.Active, - checked, - disabled: isDisabled, - }) - : $$props.class - : ""; - $: propsWeControl = { id, - class: classStyle, role: "radio", "aria-checked": checked ? ("true" as const) : ("false" as const), "aria-disabled": isDisabled ? true : undefined, tabIndex: tabIndex, }; + + $: slotProps = { + checked, + disabled: isDisabled, + active: state & OptionState.Active, + }; - - -
+ + {} : handleClick} + on:focus={isDisabled ? () => {} : handleFocus} + on:blur={isDisabled ? () => {} : handleBlur} > - -
+ +