Skip to content

Commit

Permalink
feat(input): allow custom date component to be configured
Browse files Browse the repository at this point in the history
If none is set we just default to the `inputComponent` aka HTML5 picker.
  • Loading branch information
velrest committed Sep 14, 2022
1 parent 27c243b commit a5bf884
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
18 changes: 18 additions & 0 deletions addon/components/validated-input/render.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,24 @@
@update={{@update}}
...attributes
/>
{{else if (and
(eq @type "date") (not-eq this.dateComponent this.inputComponent)
)}}
<this.dateComponent
@autocomplete={{@autocomplete}}
@autofocus={{@autofocus}}
@disabled={{@disabled}}
@id={{@inputId}}
@name={{or @inputName @name}}
@placeholder={{@placeholder}}
@type={{@type}}
@value={{@value}}
@isInvalid={{@isInvalid}}
@isValid={{@isValid}}
@setDirty={{@setDirty}}
@update={{@update}}
...attributes
/>
{{else}}
<this.inputComponent
autocomplete={{@autocomplete}}
Expand Down
1 change: 1 addition & 0 deletions addon/components/validated-input/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ export default class RenderComponent extends Component {
@passedOrDefault("types/radio-group") radioGroupComponent;
@passedOrDefault("types/select") selectComponent;
@passedOrDefault("types/textarea") textareaComponent;
@passedOrDefault("types/date") dateComponent;
}
3 changes: 3 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ module.exports = {
this.options["@embroider/macros"].setOwnConfig["types/textarea"] =
defaults["types/textarea"] ??
"ember-validated-form/components/validated-input/types/textarea";
this.options["@embroider/macros"].setOwnConfig["types/date"] =
defaults["types/date"] ??
"ember-validated-form/components/validated-input/types/input";
},

options: {
Expand Down

0 comments on commit a5bf884

Please sign in to comment.