@frontile/changeset-form 0.12.4 → 0.14.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.
@@ -5,6 +5,7 @@
5
5
  @label={{@label}}
6
6
  @hint={{@hint}}
7
7
  @hasError={{@hasError}}
8
+ @showError={{@showError}}
8
9
  @hasSubmitted={{@hasSubmitted}}
9
10
  @containerClass={{@containerClass}}
10
11
  @size={{@size}}
@@ -10,6 +10,7 @@
10
10
  @label={{@label}}
11
11
  @hint={{@hint}}
12
12
  @hasError={{@hasError}}
13
+ @showError={{@showError}}
13
14
  @containerClass={{@containerClass}}
14
15
  @size={{@size}}
15
16
  @onChange={{@onChange}}
@@ -7,6 +7,7 @@
7
7
  @hint={{@hint}}
8
8
  @hasSubmitted={{@hasSubmitted}}
9
9
  @hasError={{@hasError}}
10
+ @showError={{@showError}}
10
11
  @containerClass={{@containerClass}}
11
12
  @size={{@size}}
12
13
  @isInline={{@isInline}}
@@ -10,6 +10,7 @@
10
10
  @label={{@label}}
11
11
  @hint={{@hint}}
12
12
  @hasError={{@hasError}}
13
+ @showError={{@showError}}
13
14
  @containerClass={{@containerClass}}
14
15
  @size={{@size}}
15
16
 
@@ -10,6 +10,7 @@
10
10
  @label={{@label}}
11
11
  @hint={{@hint}}
12
12
  @hasError={{@hasError}}
13
+ @showError={{@showError}}
13
14
  @containerClass={{@containerClass}}
14
15
  @size={{@size}}
15
16
  @onChange={{@onChange}}
@@ -3,21 +3,53 @@
3
3
  {{on "submit" (fn this.handleSubmit @changeset)}}
4
4
  {{on "reset" (fn this.handleReset @changeset)}}
5
5
  >
6
- <ChangesetForm::Context @changeset={{@changeset}} as |Form|>
7
- {{yield
8
- (hash
9
- Input=(component Form.Input hasSubmitted=this.hasSubmitted)
10
- Textarea=(component Form.Textarea hasSubmitted=this.hasSubmitted)
11
- Select=(component Form.Select hasSubmitted=this.hasSubmitted)
12
- Checkbox=(component Form.Checkbox hasSubmitted=this.hasSubmitted)
13
- CheckboxGroup=(component
14
- Form.CheckboxGroup hasSubmitted=this.hasSubmitted
15
- )
16
- Radio=(component Form.Radio hasSubmitted=this.hasSubmitted)
17
- RadioGroup=(component Form.RadioGroup hasSubmitted=this.hasSubmitted)
6
+
7
+ {{yield
8
+ (hash
9
+ Input=(component
10
+ "changeset-form/fields/input"
11
+ changeset=@changeset
12
+ hasSubmitted=this.hasSubmitted
13
+ showError=@alwaysShowErrors
18
14
  )
19
- @changeset
20
- (hash hasSubmitted=this.hasSubmitted)
21
- }}
22
- </ChangesetForm::Context>
15
+ Textarea=(component
16
+ "changeset-form/fields/textarea"
17
+ changeset=@changeset
18
+ hasSubmitted=this.hasSubmitted
19
+ showError=@alwaysShowErrors
20
+ )
21
+ Select=(component
22
+ "changeset-form/fields/select"
23
+ changeset=@changeset
24
+ hasSubmitted=this.hasSubmitted
25
+ showError=@alwaysShowErrors
26
+ )
27
+ Checkbox=(component
28
+ "changeset-form/fields/checkbox"
29
+ changeset=@changeset
30
+ hasSubmitted=this.hasSubmitted
31
+ showError=@alwaysShowErrors
32
+ )
33
+ CheckboxGroup=(component
34
+ "changeset-form/fields/checkbox-group"
35
+ changeset=@changeset
36
+ hasSubmitted=this.hasSubmitted
37
+ showError=@alwaysShowErrors
38
+ )
39
+ Radio=(component
40
+ "changeset-form/fields/radio"
41
+ changeset=@changeset
42
+ hasSubmitted=this.hasSubmitted
43
+ showError=@alwaysShowErrors
44
+ )
45
+ RadioGroup=(component
46
+ "changeset-form/fields/radio-group"
47
+ changeset=@changeset
48
+ hasSubmitted=this.hasSubmitted
49
+ showError=@alwaysShowErrors
50
+ )
51
+ state=(hash hasSubmitted=this.hasSubmitted)
52
+ )
53
+ }}
54
+
23
55
  </form>
@@ -3,6 +3,7 @@ import { tracked } from '@glimmer/tracking';
3
3
  import { BufferedChangeset } from 'ember-changeset/types';
4
4
  import { action } from '@ember/object';
5
5
  import { assert } from '@ember/debug';
6
+ import { next } from '@ember/runloop';
6
7
 
7
8
  interface ChangesetFormArgs {
8
9
  /** Changeset Object */
@@ -14,6 +15,18 @@ interface ChangesetFormArgs {
14
15
  * */
15
16
  runExecuteInsteadOfSave?: boolean;
16
17
 
18
+ /**
19
+ * Always show errors if there are any
20
+ * @defaultValue false
21
+ */
22
+ alwaysShowErrors?: boolean;
23
+
24
+ /**
25
+ * Validate the changeset on initialization
26
+ * @defaultValue false
27
+ */
28
+ validateOnInit?: boolean;
29
+
17
30
  /** Callback exeuted when from `onsubmit` event is triggered */
18
31
  onSubmit?: (data: unknown, event: Event) => void;
19
32
 
@@ -30,6 +43,12 @@ export default class ChangesetForm extends Component<ChangesetFormArgs> {
30
43
  '@changeset must be defined on <ChangesetForm> component',
31
44
  this.args.changeset
32
45
  );
46
+
47
+ if (this.args.validateOnInit) {
48
+ next(() => {
49
+ this.args.changeset.validate();
50
+ });
51
+ }
33
52
  }
34
53
 
35
54
  @action
@@ -8,6 +8,16 @@ interface ChangesetFormArgs {
8
8
  * @defaultValue false
9
9
  * */
10
10
  runExecuteInsteadOfSave?: boolean;
11
+ /**
12
+ * Always show errors if there are any
13
+ * @defaultValue false
14
+ */
15
+ alwaysShowErrors?: boolean;
16
+ /**
17
+ * Validate the changeset on initialization
18
+ * @defaultValue false
19
+ */
20
+ validateOnInit?: boolean;
11
21
  /** Callback exeuted when from `onsubmit` event is triggered */
12
22
  onSubmit?: (data: unknown, event: Event) => void;
13
23
  /** Callback exeuted when from `onreset` event is triggered */
@@ -7,79 +7,81 @@ order: 1
7
7
  This shows how to have a complete form using `ChangesetForm`.
8
8
 
9
9
  ```hbs template
10
- <ChangesetForm @changeset={{changeset this.model this.validations}} as |Form changeset|>
11
- <Form.Input
12
- @label="First Name"
13
- @fieldName="firstName"
14
- placeholder="What is your first name?"
15
- />
16
- <Form.Input
17
- @label="Last Name"
18
- @fieldName="lastName"
19
- @containerClass="mt-4"
20
- placeholder="What is your family name?"
21
- />
22
- <Form.Input
23
- @label="Email Address"
24
- @fieldName="email"
25
- type="email"
26
- @containerClass="mt-4"
27
- />
28
- <Form.Textarea
29
- @label="Comments"
30
- @fieldName="comments"
31
- @containerClass="mt-4"
32
- />
33
- <Form.Select
34
- @label="Countries"
35
- @fieldName="countries"
36
- @isMultiple={{true}}
37
- @options={{this.countries}}
38
- @allowClear={{true}}
39
- @containerClass="mt-4" as |option|
40
- >
41
- {{option}}
42
- </Form.Select>
43
- <Form.CheckboxGroup
44
- @groupName="coreValues"
45
- @label="Core Values"
46
- @containerClass="mt-4" as |Checkbox|
47
- >
48
- <Checkbox @label="Hungry" @fieldName="hungry" />
49
- <Checkbox @label="Humble" @fieldName="humble" />
50
- <Checkbox @label="Curious" @fieldName="curious" />
51
- </Form.CheckboxGroup>
52
- <Form.RadioGroup
53
- @label="Favorite Meal"
54
- @containerClass="mt-4"
55
- @fieldName="favoriteMeal" as |Radio|
56
- >
57
- <Radio @label="Breakfast" @value="breakfast" />
58
- <Radio @label="Lunch" @value="lunch" />
59
- <Radio @label="Dinner" @value="dinner" />
60
- </Form.RadioGroup>
61
- <Button
62
- @type="submit"
63
- @intent="primary"
64
- disabled={{changeset.isInvalid}}
65
- class="mt-4"
66
- >
67
- Save
68
- </Button>
69
- <Button
70
- @type="reset"
71
- @appearance="outlined"
72
- >
73
- Reset
74
- </Button>
75
- <div class="mt-4">
76
- <code>
77
- <p>isPristine: {{changeset.isPristine}}</p>
78
- <p>isValid: {{changeset.isValid}}</p>
79
- <p>isInvalid: {{changeset.isInvalid}}</p>
80
- </code>
81
- </div>
82
- </ChangesetForm>
10
+ {{#let (changeset this.model this.validations) as |changeset|}}
11
+ <ChangesetForm @changeset={{changeset}} as |Form|>
12
+ <Form.Input
13
+ @label='First Name'
14
+ @fieldName='firstName'
15
+ placeholder='What is your first name?'
16
+ />
17
+ <Form.Input
18
+ @label='Last Name'
19
+ @fieldName='lastName'
20
+ @containerClass='mt-4'
21
+ placeholder='What is your family name?'
22
+ />
23
+ <Form.Input
24
+ @label='Email Address'
25
+ @fieldName='email'
26
+ type='email'
27
+ @containerClass='mt-4'
28
+ />
29
+ <Form.Textarea
30
+ @label='Comments'
31
+ @fieldName='comments'
32
+ @containerClass='mt-4'
33
+ />
34
+ <Form.Select
35
+ @label='Countries'
36
+ @fieldName='countries'
37
+ @isMultiple={{true}}
38
+ @options={{this.countries}}
39
+ @allowClear={{true}}
40
+ @containerClass='mt-4'
41
+ as |option|
42
+ >
43
+ {{option}}
44
+ </Form.Select>
45
+ <Form.CheckboxGroup
46
+ @groupName='coreValues'
47
+ @label='Core Values'
48
+ @containerClass='mt-4'
49
+ as |Checkbox|
50
+ >
51
+ <Checkbox @label='Hungry' @fieldName='hungry' />
52
+ <Checkbox @label='Humble' @fieldName='humble' />
53
+ <Checkbox @label='Curious' @fieldName='curious' />
54
+ </Form.CheckboxGroup>
55
+ <Form.RadioGroup
56
+ @label='Favorite Meal'
57
+ @containerClass='mt-4'
58
+ @fieldName='favoriteMeal'
59
+ as |Radio|
60
+ >
61
+ <Radio @label='Breakfast' @value='breakfast' />
62
+ <Radio @label='Lunch' @value='lunch' />
63
+ <Radio @label='Dinner' @value='dinner' />
64
+ </Form.RadioGroup>
65
+ <Button
66
+ @type='submit'
67
+ @intent='primary'
68
+ disabled={{changeset.isInvalid}}
69
+ class='mt-4'
70
+ >
71
+ Save
72
+ </Button>
73
+ <Button @type='reset' @appearance='outlined'>
74
+ Reset
75
+ </Button>
76
+ <div class='mt-4'>
77
+ <code>
78
+ <p>isPristine: {{changeset.isPristine}}</p>
79
+ <p>isValid: {{changeset.isValid}}</p>
80
+ <p>isInvalid: {{changeset.isInvalid}}</p>
81
+ </code>
82
+ </div>
83
+ </ChangesetForm>
84
+ {{/let}}
83
85
  ```
84
86
 
85
87
  ```ts component
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@frontile/changeset-form",
3
- "version": "0.12.4",
3
+ "version": "0.14.0",
4
4
  "description": "Component Library for Ember Octane apps: ChangesetForm",
5
5
  "keywords": [
6
6
  "ember-addon"
@@ -22,49 +22,58 @@
22
22
  "postpack": "ember ts:clean"
23
23
  },
24
24
  "dependencies": {
25
- "@frontile/forms": "^0.12.4",
26
- "ember-changeset": "^3.15.0",
27
- "ember-changeset-validations": "^3.16.0",
28
- "ember-cli-babel": "^7.26.6",
29
- "ember-cli-htmlbars": "^5.7.1",
30
- "ember-cli-typescript": "^4.2.1"
25
+ "@frontile/forms": "^0.14.0",
26
+ "ember-changeset": "^4.0.0",
27
+ "ember-changeset-validations": "^4.0.0",
28
+ "ember-cli-babel": "^7.26.11",
29
+ "ember-cli-htmlbars": "^6.0.1",
30
+ "ember-cli-typescript": "^5.0.0"
31
31
  },
32
32
  "devDependencies": {
33
- "@babel/core": "^7.15.8",
33
+ "@babel/core": "^7.17.8",
34
34
  "@ember/optional-features": "^2.0.0",
35
- "@ember/test-helpers": "^2.5.0",
36
- "@embroider/test-setup": "^0.45.0",
37
- "@frontile/core": "^0.12.4",
35
+ "@ember/test-helpers": "^2.6.0",
36
+ "@embroider/test-setup": "^1.5.0",
37
+ "@frontile/core": "^0.14.0",
38
38
  "@glimmer/component": "^1.0.4",
39
39
  "@glimmer/tracking": "^1.0.4",
40
- "@types/ember": "^3.16.5",
41
- "@types/ember-qunit": "^3.4.14",
42
- "@types/ember-resolver": "^5.0.10",
43
- "@types/ember__test-helpers": "^2.0.2",
44
- "@types/qunit": "^2.11.2",
40
+ "@types/ember-qunit": "^5.0.0",
41
+ "@types/ember-resolver": "^5.0.11",
42
+ "@types/ember__application": "^4.0.0",
43
+ "@types/ember__array": "^4.0.1",
44
+ "@types/ember__component": "^4.0.4",
45
+ "@types/ember__debug": "^4.0.1",
46
+ "@types/ember__error": "^4.0.0",
47
+ "@types/ember__object": "^4.0.1",
48
+ "@types/ember__routing": "^4.0.4",
49
+ "@types/ember__runloop": "^4.0.0",
50
+ "@types/ember__service": "^4.0.0",
51
+ "@types/ember__string": "^3.0.9",
52
+ "@types/ember__template": "^4.0.0",
53
+ "@types/ember__test": "^4.0.0",
54
+ "@types/ember__test-helpers": "^2.6.1",
55
+ "@types/htmlbars-inline-precompile": "^3.0.0",
56
+ "@types/qunit": "^2.11.3",
45
57
  "@types/rsvp": "^4.0.4",
46
- "autoprefixer": "^10.3.7",
47
58
  "broccoli-asset-rev": "^3.0.0",
48
- "ember-auto-import": "^2.2.0",
49
- "ember-cli": "~3.28.1",
59
+ "ember-auto-import": "^2.4.1",
60
+ "ember-cli": "^4.2.0",
50
61
  "ember-cli-dependency-checker": "^3.2.0",
51
62
  "ember-cli-inject-live-reload": "^2.1.0",
52
- "ember-cli-postcss": "^7.0.2",
53
63
  "ember-cli-typescript-blueprints": "^3.0.0",
54
64
  "ember-cli-uglify": "^3.0.0",
55
65
  "ember-disable-prototype-extensions": "^1.1.3",
56
66
  "ember-load-initializers": "^2.1.2",
57
- "ember-maybe-import-regenerator": "^1.0.0",
58
67
  "ember-qunit": "^5.1.5",
59
68
  "ember-resolver": "^8.0.3",
60
- "ember-source": "~3.28.1",
61
- "ember-try": "^1.4.0",
69
+ "ember-source": "^4.3.0",
70
+ "ember-try": "^2.0.0",
62
71
  "loader.js": "^4.7.0",
63
- "qunit": "^2.17.2",
72
+ "qunit": "^2.18.0",
64
73
  "qunit-dom": "^2.0.0",
65
- "tailwindcss": "^2.2.16",
66
- "typescript": "^4.4.3",
67
- "webpack": "^5.58.0"
74
+ "tailwindcss": "^3.0.23",
75
+ "typescript": "^4.6.2",
76
+ "webpack": "^5.70.0"
68
77
  },
69
78
  "engines": {
70
79
  "node": ">= 10.*"
@@ -78,5 +87,5 @@
78
87
  "ember-addon": {
79
88
  "configPath": "tests/dummy/config"
80
89
  },
81
- "gitHead": "223dcc591866f108f1b95174f4fc5a188096e489"
90
+ "gitHead": "d6e03521904b6e523018a74f85c2fe3bce34b4f9"
82
91
  }
@@ -0,0 +1,3 @@
1
+ import Config from 'dummy/config/environment';
2
+
3
+ export default Config;
@@ -1,15 +0,0 @@
1
- {{yield
2
- (hash
3
- Input=(component "changeset-form/fields/input" changeset=@changeset)
4
- Textarea=(component "changeset-form/fields/textarea" changeset=@changeset)
5
- Select=(component "changeset-form/fields/select" changeset=@changeset)
6
- Checkbox=(component "changeset-form/fields/checkbox" changeset=@changeset)
7
- CheckboxGroup=(component
8
- "changeset-form/fields/checkbox-group" changeset=@changeset
9
- )
10
- Radio=(component "changeset-form/fields/radio" changeset=@changeset)
11
- RadioGroup=(component
12
- "changeset-form/fields/radio-group" changeset=@changeset
13
- )
14
- )
15
- }}
@@ -1 +0,0 @@
1
- export { default } from '@frontile/changeset-form/components/changeset-form/context';