vantezzen / auto-form

🌟 A React component that automatically creates a @shadcn/ui form based on a zod schema.
https://vantezzen.github.io/auto-form/
2.29k stars 81 forks source link

feat(select): placeholder #13

Closed papsavas closed 11 months ago

papsavas commented 11 months ago

You can now pass a custom Select placeholder

<Autoform 
  formSchema={schema}
  fieldConfig={{
    myEnumField: { 
      inputProps: { placeholder: "Custom Select Placeholder" } 
    }
  }}
/>

?? "Select an option" should be default on placeholder but having only the field value on SelectValue content causes the first select to be empty for some reason,

vantezzen commented 11 months ago

Thank you for your contribution! Is there anything speaking against changing it to <SelectValue className="w-full" {...fieldConfigItem.inputProps}> to pass all input props? This way we don't need to explicitly set every prop.

papsavas commented 11 months ago

So there are couple of places where they accept placeholders. SelectTrigger, SelectValue and SelectContent. Turns out only SelectValue works for that. That being said, some props might be more suitable for different components. For ex you might want to have a background color for all options, hence SelectContent.

In conclusion, that means you will not have a single component to dump them all, but rather you'll need to redistribute them accordingly.

Because this is difficult to implement, i would add one prop at a time to its corresponding component

vantezzen commented 11 months ago

I see, that makes sense - thank you again for the contribution!