Type RadioGroup with $$Props

This commit is contained in:
Ryan Gossiaux
2022-02-07 18:01:29 -08:00
parent a193729ea9
commit f03512d07c
2 changed files with 49 additions and 16 deletions

View File

@@ -1,3 +1,13 @@
<script lang="ts" context="module">
type TRadioGroupOptionProps<
TSlotProps extends {},
TAsProp extends SupportedAs
> = TPassThroughProps<TSlotProps, TAsProp> & {
value: unknown;
disabled?: boolean;
};
</script>
<script lang="ts">
import { onDestroy } from "svelte";
import DescriptionProvider from "$lib/components/description/DescriptionProvider.svelte";
@@ -9,19 +19,26 @@
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());
import Render, { type TPassThroughProps } from "$lib/utils/Render.svelte";
/***** Props *****/
type TAsProp = $$Generic<SupportedAs>;
type $$Props = TRadioGroupOptionProps<typeof slotProps, TAsProp>;
export let as: SupportedAs = "div";
export let use: HTMLActionArray = [];
export let value: unknown;
export let disabled: boolean = false;
/***** Events *****/
const forwardEvents = forwardEventsBuilder(get_current_component());
/***** Component *****/
enum OptionState {
Empty = 1 << 0,
Active = 1 << 1,
}
export let value: unknown;
export let disabled: boolean = false;
let api = useRadioGroupContext("RadioGroupOption");
let id = `headlessui-radiogroup-option-${useId()}`;
let optionRef: HTMLElement | null = null;