diff --git a/addon/components/validated-input/render.hbs b/addon/components/validated-input/render.hbs
index bf2239af..de2372e0 100644
--- a/addon/components/validated-input/render.hbs
+++ b/addon/components/validated-input/render.hbs
@@ -86,6 +86,23 @@
@update={{@update}}
...attributes
/>
+ {{else if (and
+ (eq @type "date") (not-eq this.dateComponent this.inputComponent)
+ )}}
+
{{else}}
<@hintComponent />
-<@errorComponent class="d-block" />
+<@errorComponent />
{{! END-SNIPPET }}
\ No newline at end of file
diff --git a/tests/dummy/app/components/flatpickr-wrapper.hbs b/tests/dummy/app/components/flatpickr-wrapper.hbs
new file mode 100644
index 00000000..c0bb48dd
--- /dev/null
+++ b/tests/dummy/app/components/flatpickr-wrapper.hbs
@@ -0,0 +1,17 @@
+{{! BEGIN-SNIPPET flatpickr-wrapper.hbs }}
+<@labelComponent />
+
+
+
+
+
+
+<@hintComponent />
+<@errorComponent />
+{{! END-SNIPPET }}
\ No newline at end of file
diff --git a/tests/dummy/app/components/x-custom-date.hbs b/tests/dummy/app/components/x-custom-date.hbs
new file mode 100644
index 00000000..601ff6a3
--- /dev/null
+++ b/tests/dummy/app/components/x-custom-date.hbs
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/tests/dummy/app/components/x-custom-render.hbs b/tests/dummy/app/components/x-custom-render.hbs
index ec68be2e..7dc6be73 100644
--- a/tests/dummy/app/components/x-custom-render.hbs
+++ b/tests/dummy/app/components/x-custom-render.hbs
@@ -13,6 +13,10 @@
{{else if (eq @type "textarea")}}
+ {{else if (and
+ (eq @type "date") (not-eq this.dateComponent this.inputComponent)
+ )}}
+
{{else}}
{{/if}}
diff --git a/tests/dummy/app/snippets/config-custom-date.js b/tests/dummy/app/snippets/config-custom-date.js
new file mode 100644
index 00000000..537fee74
--- /dev/null
+++ b/tests/dummy/app/snippets/config-custom-date.js
@@ -0,0 +1,9 @@
+const app = new EmberAddon(defaults, {
+ // ...
+ "ember-validated-form": {
+ defaults: {
+ "types/date": "myapp/components/flatpickr-wrapper",
+ },
+ },
+ // ...
+});
diff --git a/tests/dummy/app/snippets/config-defaults.js b/tests/dummy/app/snippets/config-defaults.js
index 778796c1..4b8af206 100644
--- a/tests/dummy/app/snippets/config-defaults.js
+++ b/tests/dummy/app/snippets/config-defaults.js
@@ -16,6 +16,7 @@ const app = new EmberAddon(defaults, {
"types/radio-group": "myapp/components/x-my-radio-group",
"types/select": "myapp/components/x-my-select",
"types/textarea": "myapp/components/x-my-textarea",
+ "types/date": "myapp/components/x-my-date-picker",
},
},
// ...
diff --git a/tests/dummy/app/templates/docs/customization.md b/tests/dummy/app/templates/docs/customization.md
index 3fa54908..b2d32fbc 100644
--- a/tests/dummy/app/templates/docs/customization.md
+++ b/tests/dummy/app/templates/docs/customization.md
@@ -135,6 +135,60 @@ inside a label tag.
- `` **errors** The error messages of the field
+### Date
+
+`ember-validated-form` has no default date picker implemented. If you specify an input
+with type `date`, a plain input with the HTML5 (depending on your browser) will
+be rendered.
+
+
+
+
+
+
+
+
+
+
+
+This is on purpose due to there being many date picker components/addons
+available. And not every date picker fits every theme.
+
+If you would like to configure a custom date picker, configure a custom date
+component as specified in the _Defaults_ section of `Configuration`.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+**Arguments**
+
+- `<*>` **value** The current value of the field
+- `` **update** Action to update the value
+- `` **inputId** The ID of the field (generated with `guidFor` from `@ember/object/internals`)
+- `` **placeholder** The placeholder of the field
+- `` **isValid** Whether the form data is valid
+- `` **isInvalid** Whether the form data is invalid
+- `` **setDirty** Action to mark the field as dirty
+- `` **name** The name of the field
+- `` **disabled** Whether the field is disabled
+- `` **autocomplete** Whether to enable autocompletion on the field
+
## validated-button
diff --git a/tests/integration/components/validated-form-defaults-test.js b/tests/integration/components/validated-form-defaults-test.js
index f68ee3b0..6b52effd 100644
--- a/tests/integration/components/validated-form-defaults-test.js
+++ b/tests/integration/components/validated-form-defaults-test.js
@@ -50,7 +50,7 @@ module("Integration | Component | validated form defaults", function (hooks) {
testCustomComponents(
"renders custom type components",
async function (assert) {
- assert.expect(6);
+ assert.expect(7);
await render(hbs`
@@ -60,6 +60,7 @@ module("Integration | Component | validated form defaults", function (hooks) {
+
`);
@@ -69,6 +70,7 @@ module("Integration | Component | validated form defaults", function (hooks) {
assert.dom("custom-radio-group").exists();
assert.dom("custom-select").exists();
assert.dom("custom-textarea").exists();
+ assert.dom("custom-date").exists();
}
);
});
diff --git a/yarn.lock b/yarn.lock
index 19db19ab..06b79985 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -1366,7 +1366,7 @@
mkdirp "^1.0.4"
silent-error "^1.1.1"
-"@ember/render-modifiers@^1.0.2 || ^2.0.0", "@ember/render-modifiers@^2.0.0":
+"@ember/render-modifiers@^1.0.2 || ^2.0.0", "@ember/render-modifiers@^2.0.0", "@ember/render-modifiers@^2.0.3":
version "2.0.4"
resolved "https://registry.yarnpkg.com/@ember/render-modifiers/-/render-modifiers-2.0.4.tgz#0ac7af647cb736076dbfcd54ca71e090cd329d71"
integrity sha512-Zh/fo5VUmVzYHkHVvzWVjJ1RjFUxA2jH0zCp2+DQa80Bf3DUXauiEByxU22UkN4LFT55DBFttC0xCQSJG3WTsg==
@@ -7922,6 +7922,22 @@ ember-fetch@^8.1.1:
node-fetch "^2.6.1"
whatwg-fetch "^3.6.2"
+ember-flatpickr@^3.2.3:
+ version "3.2.3"
+ resolved "https://registry.yarnpkg.com/ember-flatpickr/-/ember-flatpickr-3.2.3.tgz#4ec405d03853d67316fb1813e4e39bca487f1b83"
+ integrity sha512-ON6FNh3gFSxDTam2UOyPOSeYki5qNqPqPEB+SS/Q+L+kPEvxmDMPeG/lWLLvdDsPR0X55W9q7uSjzZZAD/UxqA==
+ dependencies:
+ "@ember/render-modifiers" "^2.0.3"
+ "@glimmer/component" "^1.0.4"
+ "@glimmer/tracking" "^1.0.4"
+ broccoli-funnel "^3.0.3"
+ broccoli-merge-trees "^4.2.0"
+ broccoli-stew "^3.0.0"
+ ember-cli-babel "^7.26.11"
+ ember-cli-htmlbars "^6.0.1"
+ ember-cli-typescript "^5.0.0"
+ flatpickr "^4.6.9"
+
"ember-get-config@^0.3.0 || ^0.4.0 || ^0.5.0 || ^1.0.2":
version "1.1.0"
resolved "https://registry.yarnpkg.com/ember-get-config/-/ember-get-config-1.1.0.tgz#731e192f1fe8022e06c0dbcbe5622fb8c4c78b87"
@@ -9285,6 +9301,11 @@ flat-cache@^3.0.4:
flatted "^3.1.0"
rimraf "^3.0.2"
+flatpickr@^4.6.9:
+ version "4.6.13"
+ resolved "https://registry.yarnpkg.com/flatpickr/-/flatpickr-4.6.13.tgz#8a029548187fd6e0d670908471e43abe9ad18d94"
+ integrity sha512-97PMG/aywoYpB4IvbvUJi0RQi8vearvU0oov1WW3k0WZPBMrTQVqekSX5CjSG/M4Q3i6A/0FKXC7RyAoAUUSPw==
+
flatted@^3.1.0:
version "3.2.7"
resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.2.7.tgz#609f39207cb614b89d0765b477cb2d437fbf9787"