dlg-ui 1.0.29 → 1.0.31

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.
@@ -3,8 +3,8 @@
3
3
  {{this.args.label}}
4
4
  </div>
5
5
  <div class='dropdown-select {{if this.isOpen "open"}}'>
6
- {{#if this.value.label}}
7
- {{this.value.label}}
6
+ {{#if this.displayValue}}
7
+ {{this.displayValue}}
8
8
  {{! TODO - If there is no label, then they submitted just strings and we can use those for a dropdown }}
9
9
  {{else}}
10
10
  <span class='dropdown-placeholder'>
@@ -4,6 +4,7 @@ import { tracked } from '@glimmer/tracking';
4
4
 
5
5
  export default class DropdownComponent extends Component {
6
6
  @tracked isOpen = false;
7
+ @tracked displayValue = null;
7
8
 
8
9
  get dropdownClass() {
9
10
  if (this.isOpen) {
@@ -47,11 +48,12 @@ export default class DropdownComponent extends Component {
47
48
  }
48
49
  }
49
50
 
50
- saveSelection(value) {
51
+ saveSelection(option) {
51
52
  if (!this.args.preventDefault) {
52
- this.value = value;
53
+ this.value = option?.value;
53
54
  }
54
- this.args.onSelect?.(value);
55
+ this.displayValue = option?.label || null;
56
+ this.args.onSelect?.(option);
55
57
  }
56
58
 
57
59
  @action
@@ -77,7 +79,7 @@ export default class DropdownComponent extends Component {
77
79
 
78
80
  @action
79
81
  makeSelection(option) {
80
- if (option === this.value) {
82
+ if (option.value === this.value) {
81
83
  this.saveSelection(null);
82
84
  } else {
83
85
  this.saveSelection(option);
@@ -2,7 +2,9 @@
2
2
  <form>
3
3
  {{yield (hash Field=(component "form/field" addValidator=this.addValidator didValidate=this.didValidate errors=this.errors validate=this.validate))}}
4
4
  </form>
5
- <ButtonPrimary @onClick={{this.submitForm}}>
6
- Submit
7
- </ButtonPrimary>
5
+ {{#unless @hideSubmit}}
6
+ <ButtonPrimary @onClick={{this.submitForm}}>
7
+ Submit
8
+ </ButtonPrimary>
9
+ {{/unless}}
8
10
  </div>
@@ -3,11 +3,12 @@ import { action, get, set } from '@ember/object';
3
3
  import { tracked } from '@glimmer/tracking';
4
4
 
5
5
  export default class DropdownComponent extends Component {
6
+ @tracked displayValue = null;
6
7
  @tracked isOpen = false;
7
8
 
8
9
  get displaySelectedOption() {
9
- if (this.value?.label) {
10
- return this.value.label;
10
+ if (this.displayValue) {
11
+ return this.displayValue;
11
12
  } else {
12
13
  return this.placeholder;
13
14
  }
@@ -41,11 +42,12 @@ export default class DropdownComponent extends Component {
41
42
  }
42
43
  }
43
44
 
44
- saveSelection(value) {
45
+ saveSelection(option) {
45
46
  if (!this.args.preventDefault) {
46
- this.value = value;
47
+ this.value = option?.value;
47
48
  }
48
- this.args.onSelect?.(value);
49
+ this.displayValue = option?.label || null;
50
+ this.args.onSelect?.(option);
49
51
  }
50
52
 
51
53
  @action
@@ -72,11 +74,13 @@ export default class DropdownComponent extends Component {
72
74
 
73
75
  @action
74
76
  makeSelection(option) {
75
- if (option === this.value) {
77
+ if (option.value === this.value) {
78
+ this.saveSelection(null);
76
79
  } else {
77
80
  this.saveSelection(option);
78
81
  }
79
82
  this.isOpen = false;
83
+ this.args.onChange?.(this.value);
80
84
  }
81
85
 
82
86
  @action
@@ -20,7 +20,7 @@ export default class RadioComponent extends Component {
20
20
  }
21
21
 
22
22
  onChange = (option) => {
23
- this.value = option;
23
+ this.value = option.value;
24
24
  this.args.onChange?.(option);
25
25
  }
26
26
  }
@@ -9,7 +9,7 @@ export default class TextInputComponent extends Component {
9
9
 
10
10
  get value() {
11
11
  const value = get(this.args.model, this.args.valuePath);
12
- return value !== undefined ? value : this.placeholder;
12
+ return value !== undefined ? value : null;
13
13
  }
14
14
 
15
15
  set value(newValue) {
@@ -18,7 +18,7 @@
18
18
  }
19
19
 
20
20
  .form-field {
21
- margin-bottom: 2.25em;
21
+ margin-bottom: 1.50em;
22
22
  }
23
23
 
24
24
  .form-wrapper {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dlg-ui",
3
- "version": "1.0.29",
3
+ "version": "1.0.31",
4
4
  "description": "The default blueprint for ember-cli addons.",
5
5
  "keywords": [
6
6
  "ember-addon"