Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fallback to "-text-field" component name for unrecognized input type
Previously, using an input type not in the map (such as "email") would cause an exception. This renames the `classification` var to more expressive `componentNameMap`, and turns the map into a whitelist of non-default component names only. Any value of "type" not in that map (or no value for "type") will use the default "-text-field" component name.
- Loading branch information
5a1c5e1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not expose
componentNameMap
as a global config to enable custom inputs using the same convenient{{input prop type="custom-comp"}}
?5a1c5e1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@juggy Not sure exactly what you are asking. Using another type should "just work". E.g.
{{input type="color"}}
should be fine.5a1c5e1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
type=date-picker
to load the component date-picker for example with the value and properties set. But now I realise this is just sugar that might not be good in the long run. Just call the component directly.I guess what bugs me here is that
input
either create a checkbox or a textfield, you also havetextarea
to create a text area. At the end we should get rid of all that and just call the components. Another discussion altogether. So nevermind for now.5a1c5e1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@juggy -
{{textarea}}
creates a<textarea>
5a1c5e1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@juggy The
type="checkbox"
isn't actually intended to only be sugar to simplify creation of check box inputs. It's to reflect the fact that both text inputs and check box inputs are the same html tag (input
) but have somewhat different semantics. The meaning of thevalue
property is somewhat different between the two, and a checkbox input has a booleanchecked
property that is meaningless for text inputs. For custom inputs making your own component would definitely be the best way to go (i.e.{{calendar-date-picker-input}}
).