Skip to content

Commit

Permalink
fix: typecheck and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lisalupi committed Nov 22, 2024
1 parent c9b5d71 commit dd6be08
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ exports[`SelectInputField > should display right value on grouped options 1`] =
novalidate=""
>
<div
class="emotion-0 emotion-1"
class=" emotion-0 emotion-1"
data-testid="select-input-test"
>
<span
Expand All @@ -293,10 +293,10 @@ exports[`SelectInputField > should display right value on grouped options 1`] =
role="log"
/>
<div
class="emotion-4"
class=" emotion-4"
>
<div
class="emotion-5"
class=" emotion-5"
>
<label
aria-live="assertive"
Expand All @@ -307,7 +307,7 @@ exports[`SelectInputField > should display right value on grouped options 1`] =
Select...
</label>
<div
class="emotion-8"
class=" emotion-8"
>
Group Label
</div>
Expand Down Expand Up @@ -335,14 +335,14 @@ exports[`SelectInputField > should display right value on grouped options 1`] =
</div>
</div>
<div
class="emotion-11"
class=" emotion-11"
>
<span
class="emotion-12"
class=" emotion-12"
/>
<div
aria-hidden="true"
class="emotion-13"
class=" emotion-13"
>
<div
class="emotion-14 emotion-15"
Expand Down Expand Up @@ -644,7 +644,7 @@ exports[`SelectInputField > should render correctly 1`] = `
novalidate=""
>
<div
class="emotion-0 emotion-1"
class=" emotion-0 emotion-1"
data-testid="select-input-test"
>
<span
Expand All @@ -659,10 +659,10 @@ exports[`SelectInputField > should render correctly 1`] = `
role="log"
/>
<div
class="emotion-4"
class=" emotion-4"
>
<div
class="emotion-5"
class=" emotion-5"
>
<label
aria-live="assertive"
Expand All @@ -673,7 +673,7 @@ exports[`SelectInputField > should render correctly 1`] = `
Select...
</label>
<div
class="emotion-8"
class=" emotion-8"
id="react-select-2-placeholder"
>
Select...
Expand Down Expand Up @@ -703,14 +703,14 @@ exports[`SelectInputField > should render correctly 1`] = `
</div>
</div>
<div
class="emotion-11"
class=" emotion-11"
>
<span
class="emotion-12"
class=" emotion-12"
/>
<div
aria-hidden="true"
class="emotion-13"
class=" emotion-13"
>
<div
class="emotion-14 emotion-15"
Expand Down Expand Up @@ -1006,7 +1006,7 @@ exports[`SelectInputField > should render correctly disabled 1`] = `
novalidate=""
>
<div
class="emotion-0 emotion-1"
class=" emotion-0 emotion-1"
data-testid="select-input-test"
>
<span
Expand All @@ -1022,10 +1022,10 @@ exports[`SelectInputField > should render correctly disabled 1`] = `
/>
<div
aria-disabled="true"
class="emotion-4"
class=" emotion-4"
>
<div
class="emotion-5"
class=" emotion-5"
>
<label
aria-live="assertive"
Expand All @@ -1036,7 +1036,7 @@ exports[`SelectInputField > should render correctly disabled 1`] = `
Select...
</label>
<div
class="emotion-8"
class=" emotion-8"
id="react-select-3-placeholder"
>
Select...
Expand Down Expand Up @@ -1067,14 +1067,14 @@ exports[`SelectInputField > should render correctly disabled 1`] = `
</div>
</div>
<div
class="emotion-11"
class=" emotion-11"
>
<span
class="emotion-12"
class=" emotion-12"
/>
<div
aria-hidden="true"
class="emotion-13"
class=" emotion-13"
>
<div
class="emotion-14 emotion-15"
Expand Down Expand Up @@ -1370,7 +1370,7 @@ exports[`SelectInputField > should render correctly multiple 1`] = `
novalidate=""
>
<div
class="emotion-0 emotion-1"
class=" emotion-0 emotion-1"
data-testid="select-input-test"
>
<span
Expand All @@ -1385,10 +1385,10 @@ exports[`SelectInputField > should render correctly multiple 1`] = `
role="log"
/>
<div
class="emotion-4"
class=" emotion-4"
>
<div
class="emotion-5"
class=" emotion-5"
>
<label
aria-live="assertive"
Expand All @@ -1399,7 +1399,7 @@ exports[`SelectInputField > should render correctly multiple 1`] = `
Select...
</label>
<div
class="emotion-8"
class=" emotion-8"
id="react-select-4-placeholder"
>
Select...
Expand Down Expand Up @@ -1429,14 +1429,14 @@ exports[`SelectInputField > should render correctly multiple 1`] = `
</div>
</div>
<div
class="emotion-11"
class=" emotion-11"
>
<span
class="emotion-12"
class=" emotion-12"
/>
<div
aria-hidden="true"
class="emotion-13"
class=" emotion-13"
>
<div
class="emotion-14 emotion-15"
Expand Down Expand Up @@ -1740,7 +1740,7 @@ exports[`SelectInputField > should render correctly with a disabled option 1`] =
novalidate=""
>
<div
class="emotion-0 emotion-1"
class=" emotion-0 emotion-1"
data-testid="select-input-test"
>
<span
Expand All @@ -1755,10 +1755,10 @@ exports[`SelectInputField > should render correctly with a disabled option 1`] =
role="log"
/>
<div
class="emotion-4"
class=" emotion-4"
>
<div
class="emotion-5"
class=" emotion-5"
>
<label
aria-live="assertive"
Expand All @@ -1769,7 +1769,7 @@ exports[`SelectInputField > should render correctly with a disabled option 1`] =
Select...
</label>
<div
class="emotion-8"
class=" emotion-8"
id="react-select-5-placeholder"
>
Select...
Expand Down Expand Up @@ -1799,14 +1799,14 @@ exports[`SelectInputField > should render correctly with a disabled option 1`] =
</div>
</div>
<div
class="emotion-11"
class=" emotion-11"
>
<span
class="emotion-12"
class=" emotion-12"
/>
<div
aria-hidden="true"
class="emotion-13"
class=" emotion-13"
>
<div
class="emotion-14 emotion-15"
Expand Down Expand Up @@ -2123,7 +2123,7 @@ exports[`SelectInputField > should trigger events 1`] = `
novalidate=""
>
<div
class="emotion-0 emotion-1"
class=" emotion-0 emotion-1"
data-testid="select-input-test"
>
<span
Expand All @@ -2138,10 +2138,10 @@ exports[`SelectInputField > should trigger events 1`] = `
role="log"
/>
<div
class="emotion-4"
class=" emotion-4"
>
<div
class="emotion-5"
class=" emotion-5"
>
<label
aria-live="assertive"
Expand All @@ -2152,7 +2152,7 @@ exports[`SelectInputField > should trigger events 1`] = `
Select...
</label>
<div
class="emotion-8"
class=" emotion-8"
>
Label
</div>
Expand Down Expand Up @@ -2180,14 +2180,14 @@ exports[`SelectInputField > should trigger events 1`] = `
</div>
</div>
<div
class="emotion-11"
class=" emotion-11"
>
<span
class="emotion-12"
class=" emotion-12"
/>
<div
aria-hidden="true"
class="emotion-13"
class=" emotion-13"
>
<div
class="emotion-14 emotion-15"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ describe('SwitchButtonField', () => {
name="test"
leftButton={leftButton}
rightButton={rightButton}
onChange={() => vi.fn()}
/>,
)
expect(asFragment()).toMatchSnapshot()
Expand Down
5 changes: 3 additions & 2 deletions packages/form/src/components/SwitchButtonField/index.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import type { FieldPath, FieldValues, PathValue } from '@ultraviolet/form'
import { SwitchButton } from '@ultraviolet/ui'
import type { ComponentProps } from 'react'
import type { FieldPath, FieldValues, PathValue } from 'react-hook-form'
import { useController } from 'react-hook-form'
import type { BaseFieldProps } from '../../types'

type SwitchButtonFieldProps<
TFieldValues extends FieldValues,
TFieldName extends FieldPath<TFieldValues>,
> = BaseFieldProps<TFieldValues, TFieldName> &
Omit<ComponentProps<typeof SwitchButton>, 'value' | 'name'> & {
Omit<ComponentProps<typeof SwitchButton>, 'value' | 'name' | 'onChange'> &
Partial<Pick<ComponentProps<typeof SwitchButton>, 'onChange'>> & {
name: FieldPath<TFieldValues>
}

Expand Down

0 comments on commit dd6be08

Please sign in to comment.