import type { Component, ValidComponent } from "solid-js"; import { FormControlLabel, type FormControlLabelCommonProps, type FormControlLabelOptions, type FormControlLabelRenderProps, } from "../form-control"; import type { ElementOf, PolymorphicProps } from "../polymorphic"; import { type SwitchDataSet, useSwitchContext } from "./switch-context"; import type { SwitchDescriptionCommonProps } from "./switch-description"; export interface SwitchLabelOptions extends FormControlLabelOptions {} export interface SwitchLabelCommonProps extends FormControlLabelCommonProps {} export interface SwitchLabelRenderProps extends SwitchDescriptionCommonProps, FormControlLabelRenderProps, SwitchDataSet {} export type SwitchLabelProps< T extends ValidComponent | HTMLElement = HTMLElement, > = SwitchLabelOptions & Partial>>; /** * The label that gives the user information on the switch. */ export function SwitchLabel( props: PolymorphicProps>, ) { const context = useSwitchContext(); return ( > > {...context.dataset()} {...(props as SwitchLabelProps)} /> ); }