1- import type React from "react"
21import {
32 type Dispatch ,
43 type ReactNode ,
@@ -125,10 +124,12 @@ function useOptions({
125124 }
126125
127126 // add the value or default value to the top
128- if ( _value ) {
129- slots . unshift ( _value )
130- } else if ( _defaultValue ) {
131- slots . unshift ( _defaultValue )
127+ if ( ! foundValue ) {
128+ if ( _value ) {
129+ slots . unshift ( _value )
130+ } else if ( _defaultValue ) {
131+ slots . unshift ( _defaultValue )
132+ }
132133 }
133134
134135 // create options
@@ -165,8 +166,8 @@ export function TimePicker<FormData extends FieldValues>(
165166
166167/**
167168 * The timepicker is a select that opens a list of times.
168- * @param param0
169- * @returns
169+ * @param param0
170+ * @returns
170171 */
171172export function TimePicker < FormData extends FieldValues > ( {
172173 invalid,
@@ -215,10 +216,15 @@ export function TimePicker<FormData extends FieldValues>({
215216 [ onChange ] ,
216217 )
217218
218- const classNameMerged = twMerge ( "flex flex-1 min-w-28 cursor-pointer" , className )
219+ const classNameMerged = twMerge (
220+ "flex flex-1 min-w-28 cursor-pointer" ,
221+ className ,
222+ )
219223 const ariaLabel = label ?? _ariaLabel ?? "time picker"
220224
221- const selectProps : SelectProps < TimeType , false > | SelectInFormProps < FormData , TimeType , false > = {
225+ const selectProps :
226+ | SelectProps < TimeType , false >
227+ | SelectInFormProps < FormData , TimeType , false > = {
222228 testId,
223229 options,
224230 "aria-label" : ariaLabel ,
@@ -248,19 +254,15 @@ export function TimePicker<FormData extends FieldValues>({
248254
249255 if ( ! control ) {
250256 selectProps satisfies SelectProps < TimeType , false >
251- return (
252- < TimePickerNotInForm
253- { ...selectProps }
254- />
255- )
257+ return < TimePickerNotInForm { ...selectProps } />
256258 }
257259
258- const selectInFormProps = { ... selectProps , control , name } satisfies SelectInFormProps < FormData , TimeType , false >
259- return (
260- < TimePickerInForm < FormData >
261- { ... selectInFormProps }
262- / >
263- )
260+ const selectInFormProps = {
261+ ... selectProps ,
262+ control ,
263+ name ,
264+ } satisfies SelectInFormProps < FormData , TimeType , false >
265+ return < TimePickerInForm < FormData > { ... selectInFormProps } />
264266}
265267
266268function TimePickerNotInForm ( props : SelectProps < TimeType , false > ) {
@@ -270,9 +272,5 @@ function TimePickerNotInForm(props: SelectProps<TimeType, false>) {
270272function TimePickerInForm < FormData extends FieldValues > ( {
271273 ...props
272274} : SelectInFormProps < FormData , TimeType , false > ) {
273- return (
274- < Select < FormData , TimeType , false >
275- { ...props }
276- />
277- )
275+ return < Select < FormData , TimeType , false > { ...props } />
278276}
0 commit comments