Skip to content

Conversation

saleyn
Copy link
Contributor

@saleyn saleyn commented Feb 26, 2025

This change enables to extend fields with custom types in order to be able to inject custom body in a field wrapper.

@saleyn saleyn force-pushed the extend-fields branch 2 times, most recently from daf535e to e600a4c Compare February 28, 2025 13:30
Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

This PR introduces a field extension behavior system that allows developers to create custom field types with their own rendering logic and CSS classes in the Petal Components library.

  • Added new PetalComponents.Field.Extension behavior with required render/1 and optional get_class_for_type/1 callbacks
  • Implemented persistent term storage for field extensions to optimize performance (6.96x faster than Application.get_env)
  • Added support for merging custom assigns with field extensions for flexible customization
  • Added comprehensive test coverage for extension fields with datalist support
  • Introduced phx-debounce support for form validation with configurable delay

💡 (1/5) You can manually trigger the bot by mentioning @greptileai in a comment!

5 file(s) reviewed, 6 comment(s)
Edit PR Review Bot Settings | Greptile

saleyn added 2 commits April 18, 2025 09:12
This change enables to extend fields with custom types
in order to be able to inject custom body in a field wrapper.
@mitkins
Copy link
Collaborator

mitkins commented Apr 25, 2025

Hi @saleyn. Could you create a standalone component to achieve the same thing or is there a benefit to using this method instead?

@saleyn
Copy link
Contributor Author

saleyn commented Apr 26, 2025

It seems to me that restricting the inputs to a set of predefined types is too limiting as users often need to define custom input handlers. The disadvantage of needing to implement a standalone input component is in uniformity of field styling and naming (e.g. not being able to use <.input .../> tags for user inputs, and having to explicitly copy the styling options)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants