ember-validated-form 5.1.1 → 5.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ # [5.2.0](https://github.com/adfinis-sygroup/ember-validated-form/compare/v5.1.1...v5.2.0) (2022-02-03)
2
+
3
+
4
+ ### Features
5
+
6
+ * scroll first invalid element into view ([#733](https://github.com/adfinis-sygroup/ember-validated-form/issues/733)) ([ae7c8b2](https://github.com/adfinis-sygroup/ember-validated-form/commit/ae7c8b2b160307646adf90cd09a091effa549238))
7
+ * **validated-button:** add `triggerValidations` flag ([#721](https://github.com/adfinis-sygroup/ember-validated-form/issues/721)) ([765f5f4](https://github.com/adfinis-sygroup/ember-validated-form/commit/765f5f40c9d2e5ccfca7129fb701ff3bb0ed661e))
8
+
1
9
  # [5.0.0](https://github.com/adfinis-sygroup/ember-validated-form/compare/v4.1.0...v5.0.0) (2021-10-08)
2
10
 
3
11
 
@@ -25,6 +25,11 @@ export default class ValidatedButtonComponent extends Component {
25
25
  }
26
26
 
27
27
  event.preventDefault();
28
+
29
+ if (this.args.triggerValidations) {
30
+ this.args.markAsDirty();
31
+ }
32
+
28
33
  const model = this.args.model;
29
34
 
30
35
  if (!model || !model.validate) {
@@ -22,6 +22,7 @@
22
22
  loading=this.loading
23
23
  label="Action"
24
24
  model=@model
25
+ markAsDirty=this.markAsDirty
25
26
  )
26
27
  )
27
28
  }}
@@ -1,3 +1,4 @@
1
+ import { getOwner } from "@ember/application";
1
2
  import { action } from "@ember/object";
2
3
  import { scheduleOnce } from "@ember/runloop";
3
4
  import Component from "@glimmer/component";
@@ -14,6 +15,10 @@ export default class ValidatedFormComponent extends Component {
14
15
 
15
16
  constructor(...args) {
16
17
  super(...args);
18
+ this.config =
19
+ getOwner(this).resolveRegistration("config:environment")[
20
+ "ember-validated-form"
21
+ ];
17
22
 
18
23
  if (this.args.model && this.args.model.validate) {
19
24
  scheduleOnce("actions", this, "validateModel", this.args.model);
@@ -24,6 +29,11 @@ export default class ValidatedFormComponent extends Component {
24
29
  model.validate();
25
30
  }
26
31
 
32
+ @action
33
+ markAsDirty() {
34
+ this.submitted = true;
35
+ }
36
+
27
37
  @action
28
38
  async submit(event) {
29
39
  event.preventDefault();
@@ -39,6 +49,11 @@ export default class ValidatedFormComponent extends Component {
39
49
  await model.validate();
40
50
 
41
51
  if (model.get("isInvalid")) {
52
+ if (this.config?.features?.scrollErrorIntoView && model.errors[0]?.key) {
53
+ document
54
+ .querySelector(`[name=${model.errors[0].key}]`)
55
+ ?.scrollIntoView();
56
+ }
42
57
  this.runCallback(PROP_ON_INVALID_SUBMIT);
43
58
  } else {
44
59
  this.runCallback(PROP_ON_SUBMIT);
@@ -3,8 +3,8 @@
3
3
  <input
4
4
  type="checkbox"
5
5
  class="custom-control-input
6
- {{if @isValid "is-valid"}}
7
- {{if @isInvalid "is-invalid"}}"
6
+ {{if @isValid 'is-valid'}}
7
+ {{if @isInvalid 'is-invalid'}}"
8
8
  checked={{includes option.key @value}}
9
9
  name={{@name}}
10
10
  id="{{@inputId}}-{{i}}"
@@ -1,8 +1,8 @@
1
1
  <div class="custom-control custom-checkbox">
2
2
  <input
3
3
  class="custom-control-input
4
- {{if @isValid "is-valid"}}
5
- {{if @isInvalid "is-invalid"}}"
4
+ {{if @isValid 'is-valid'}}
5
+ {{if @isInvalid 'is-invalid'}}"
6
6
  type="checkbox"
7
7
  name={{@name}}
8
8
  id={{@inputId}}
@@ -3,8 +3,8 @@
3
3
  <input
4
4
  type="radio"
5
5
  class="custom-control-input
6
- {{if @isValid "is-valid"}}
7
- {{if @isInvalid "is-invalid"}}"
6
+ {{if @isValid 'is-valid'}}
7
+ {{if @isInvalid 'is-invalid'}}"
8
8
  checked={{eq @value option.key}}
9
9
  value={{option.key}}
10
10
  name={{@name}}
@@ -2,8 +2,8 @@
2
2
  {{#if (not-eq i 0)}}<br />{{/if}}
3
3
  <label
4
4
  class="uk-form-label
5
- {{if @isValid "uk-text-success"}}
6
- {{if @isInvalid "uk-text-danger"}}"
5
+ {{if @isValid 'uk-text-success'}}
6
+ {{if @isInvalid 'uk-text-danger'}}"
7
7
  >
8
8
  <input
9
9
  type="checkbox"
@@ -1,6 +1,6 @@
1
1
  {{#let (component @labelComponent) as |Label|}}
2
2
  <Label
3
- class="{{if @isValid "uk-text-success"}} {{if @isInvalid "uk-text-danger"}}"
3
+ class="{{if @isValid 'uk-text-success'}} {{if @isInvalid 'uk-text-danger'}}"
4
4
  >
5
5
  <input
6
6
  class="uk-checkbox uk-margin-small-right"
@@ -2,8 +2,8 @@
2
2
  {{#if (not-eq i 0)}}<br />{{/if}}
3
3
  <label
4
4
  class="uk-form-label
5
- {{if @isValid "uk-text-success"}}
6
- {{if @isInvalid "uk-text-danger"}}"
5
+ {{if @isValid 'uk-text-success'}}
6
+ {{if @isInvalid 'uk-text-danger'}}"
7
7
  >
8
8
  <input
9
9
  type="radio"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ember-validated-form",
3
- "version": "5.1.1",
3
+ "version": "5.2.0",
4
4
  "description": "Easily create forms with client-side validations",
5
5
  "keywords": [
6
6
  "ember-addon",
@@ -33,20 +33,20 @@
33
33
  "prepare": "husky install"
34
34
  },
35
35
  "dependencies": {
36
- "ember-auto-import": "^2.2.0",
36
+ "ember-auto-import": "^2.4.0",
37
37
  "ember-cli-babel": "^7.26.6",
38
38
  "ember-cli-htmlbars": "^5.7.1",
39
39
  "ember-truth-helpers": "^3.0.0"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@adfinis-sygroup/eslint-config": "1.5.0",
43
- "@adfinis-sygroup/semantic-release-config": "3.2.1",
44
- "@babel/core": "7.16.7",
43
+ "@adfinis-sygroup/semantic-release-config": "3.4.0",
44
+ "@babel/core": "7.16.12",
45
45
  "@babel/helper-create-regexp-features-plugin": "^7.16.7",
46
- "@babel/helper-environment-visitor": "^7.16.5",
46
+ "@babel/helper-environment-visitor": "^7.16.7",
47
47
  "@babel/plugin-proposal-decorators": "^7.16.7",
48
48
  "@babel/plugin-transform-modules-amd": "^7.16.7",
49
- "@babel/preset-env": "^7.16.7",
49
+ "@babel/preset-env": "^7.16.11",
50
50
  "@ember/optional-features": "2.0.0",
51
51
  "@ember/test-helpers": "2.6.0",
52
52
  "@embroider/test-setup": "0.45.0",
@@ -56,8 +56,8 @@
56
56
  "@glimmer/tracking": "1.0.4",
57
57
  "babel-eslint": "10.1.0",
58
58
  "broccoli-asset-rev": "3.0.0",
59
- "ember-changeset": "3.15.0",
60
- "ember-changeset-validations": "3.16.0",
59
+ "ember-changeset": "4.0.0-beta.2",
60
+ "ember-changeset-validations": "4.0.0-beta.2",
61
61
  "ember-cli": "3.28.1",
62
62
  "ember-cli-addon-docs": "4.2.1",
63
63
  "ember-cli-dependency-checker": "3.2.0",
@@ -75,7 +75,7 @@
75
75
  "ember-disable-prototype-extensions": "1.1.3",
76
76
  "ember-load-initializers": "2.1.2",
77
77
  "ember-maybe-import-regenerator": "1.0.0",
78
- "ember-power-select": "4.1.6",
78
+ "ember-power-select": "5.0.3",
79
79
  "ember-qunit": "5.1.5",
80
80
  "ember-resolver": "8.0.3",
81
81
  "ember-source": "3.28.1",
@@ -86,7 +86,7 @@
86
86
  "eslint": "7.32.0",
87
87
  "eslint-config-prettier": "8.3.0",
88
88
  "eslint-plugin-ember": "10.5.8",
89
- "eslint-plugin-import": "2.25.3",
89
+ "eslint-plugin-import": "2.25.4",
90
90
  "eslint-plugin-node": "11.1.0",
91
91
  "eslint-plugin-prettier": "4.0.0",
92
92
  "eslint-plugin-qunit": "6.2.0",
@@ -94,13 +94,16 @@
94
94
  "lint-staged": "11.2.0",
95
95
  "loader.js": "4.7.0",
96
96
  "npm-run-all": "4.1.5",
97
- "prettier": "2.4.1",
97
+ "prettier": "2.5.1",
98
98
  "qunit": "2.17.2",
99
99
  "qunit-dom": "2.0.0",
100
- "webpack": "5.58.0"
100
+ "webpack": "5.67.0"
101
101
  },
102
102
  "resolutions": {
103
- "graceful-fs": ">=4.2.0"
103
+ "graceful-fs": ">=4.2.0",
104
+ "@embroider/macros": "^1.0.0",
105
+ "@embroider/core": "^1.0.0",
106
+ "@embroider/util": "^1.0.0"
104
107
  },
105
108
  "engines": {
106
109
  "node": "12.* || 14.* || >= 16"