@@ -80,24 +80,34 @@ function getState(checked: boolean): 'checked' | 'unchecked' {
8080}
8181
8282function Switch ( props : ScopedProps < SwitchProps > ) : FictNode {
83+ const {
84+ __scopeSwitch,
85+ checked : checkedInput ,
86+ defaultChecked : defaultCheckedInput ,
87+ form : formInput ,
88+ name : nameInput ,
89+ onCheckedChange,
90+ required : requiredInput ,
91+ ...buttonProps
92+ } = props
8393 const button = createSignal < HTMLButtonElement | null > ( null )
8494 const bubbleInput = createSignal < HTMLInputElement | null > ( null )
8595 const isFormControl = createSignal ( true )
8696 const checkedProp = ( ) =>
87- props . checked === undefined ? undefined : readValue ( props . checked as MaybeAccessor < boolean | undefined > )
97+ checkedInput === undefined ? undefined : readValue ( checkedInput as MaybeAccessor < boolean | undefined > )
8898 const defaultChecked = ( ) =>
89- props . defaultChecked === undefined ? false : ( readValue ( props . defaultChecked ) ?? false )
99+ defaultCheckedInput === undefined ? false : ( readValue ( defaultCheckedInput ) ?? false )
90100 const required = ( ) =>
91- props . required === undefined ? undefined : readValue ( props . required as MaybeAccessor < boolean | undefined > )
101+ requiredInput === undefined ? undefined : readValue ( requiredInput as MaybeAccessor < boolean | undefined > )
92102 const disabled = ( ) => Boolean ( readValue ( props . disabled as MaybeAccessor < unknown > ) )
93103 const name = ( ) =>
94- props . name === undefined ? undefined : readValue ( props . name as MaybeAccessor < string | undefined > )
104+ nameInput === undefined ? undefined : readValue ( nameInput as MaybeAccessor < string | undefined > )
95105 const value = ( ) =>
96106 props . value === undefined
97107 ? 'on'
98108 : ( readValue ( props . value as MaybeAccessor < SwitchValue | undefined > ) ?? 'on' )
99109 const form = ( ) =>
100- props . form === undefined ? undefined : readValue ( props . form as MaybeAccessor < string | undefined > )
110+ formInput === undefined ? undefined : readValue ( formInput as MaybeAccessor < string | undefined > )
101111 const composedRefs = useComposedRefs (
102112 props . ref as PossibleRef < HTMLButtonElement > ,
103113 ( node ) => button ( node ) ,
@@ -106,7 +116,7 @@ function Switch(props: ScopedProps<SwitchProps>): FictNode {
106116 prop : checkedProp ,
107117 defaultProp : defaultChecked ,
108118 caller : SWITCH_NAME ,
109- ...( props . onCheckedChange ? { onChange : props . onCheckedChange } : { } ) ,
119+ ...( onCheckedChange ? { onChange : onCheckedChange } : { } ) ,
110120 }
111121 const [ checked , setChecked ] = useControllableState < boolean > ( controllableStateProps )
112122 let hasConsumerStoppedPropagation = false
@@ -175,17 +185,12 @@ function Switch(props: ScopedProps<SwitchProps>): FictNode {
175185 'data-state' : prop ( ( ) => getState ( checked ( ) ) ) ,
176186 'data-disabled' : prop ( ( ) => ( disabled ( ) ? '' : undefined ) ) ,
177187 } ,
178- ( ) => props as Record < string , unknown > ,
188+ ( ) => buttonProps as Record < string , unknown > ,
179189 {
180190 __scopeSwitch : undefined ,
181- checked : undefined ,
182- defaultChecked : undefined ,
183- form : undefined ,
184- name : undefined ,
185191 onCheckedChange : undefined ,
186192 onClick : handleClick ,
187193 ref : undefined ,
188- required : undefined ,
189194 value : prop ( value ) ,
190195 } ,
191196 )
@@ -206,7 +211,7 @@ function Switch(props: ScopedProps<SwitchProps>): FictNode {
206211 ) : null ) as unknown as FictNode
207212
208213 return (
209- < SwitchProvider scope = { props . __scopeSwitch } checked = { checked } disabled = { disabled } >
214+ < SwitchProvider scope = { __scopeSwitch } checked = { checked } disabled = { disabled } >
210215 < >
211216 < Primitive . button { ...switchProps } ref = { composedRefs } />
212217 { bubbleInputNode }
@@ -234,19 +239,20 @@ function SwitchThumb(props: ScopedProps<SwitchThumbProps>): FictNode {
234239SwitchThumb . displayName = THUMB_NAME
235240
236241function SwitchBubbleInput ( props : SwitchBubbleInputProps ) : FictNode {
242+ const { form : formProp , ...inputRestProps } = props
237243 const controlSize = useSize ( props . control )
238244
239245 const inputProps = mergeProps (
240- ( ) => props as Record < string , unknown > ,
246+ ( ) => inputRestProps as Record < string , unknown > ,
241247 {
242248 'aria-hidden' : true ,
243249 checked : prop ( props . checked ) ,
244250 control : undefined ,
245251 bubbles : undefined ,
246252 children : undefined ,
247253 disabled : prop ( ( ) => ( props . disabled === undefined ? undefined : Boolean ( readValue ( props . disabled ) ) ) ) ,
248- form : prop ( ( ) =>
249- props . form === undefined ? undefined : readValue ( props . form as MaybeAccessor < string | undefined > ) ,
254+ 'attr: form' : prop ( ( ) =>
255+ formProp === undefined ? undefined : readValue ( formProp as MaybeAccessor < string | undefined > ) ,
250256 ) ,
251257 name : prop ( ( ) =>
252258 props . name === undefined ? undefined : readValue ( props . name as MaybeAccessor < string | undefined > ) ,
0 commit comments