ember-validated-form 5.3.1 → 6.0.2

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.
Files changed (83) hide show
  1. package/CHANGELOG.md +152 -135
  2. package/README.md +3 -3
  3. package/addon/components/validated-button/button.hbs +17 -1
  4. package/addon/components/validated-button.hbs +19 -17
  5. package/addon/components/validated-button.js +9 -15
  6. package/addon/components/validated-form.js +7 -9
  7. package/addon/components/validated-input/error.hbs +15 -1
  8. package/addon/components/validated-input/hint.hbs +9 -1
  9. package/addon/components/validated-input/label.hbs +5 -1
  10. package/addon/components/validated-input/render/wrapper.hbs +5 -0
  11. package/addon/components/validated-input/render.hbs +21 -27
  12. package/addon/components/validated-input/render.js +7 -8
  13. package/addon/components/validated-input/types/checkbox-group.hbs +51 -13
  14. package/addon/components/validated-input/types/checkbox.hbs +41 -10
  15. package/addon/components/validated-input/types/input.hbs +16 -1
  16. package/addon/components/validated-input/types/input.js +0 -1
  17. package/addon/components/validated-input/types/radio-group.hbs +53 -13
  18. package/addon/components/validated-input/types/select.hbs +18 -3
  19. package/addon/components/validated-input/types/select.js +8 -28
  20. package/addon/components/validated-input/types/textarea.hbs +16 -1
  21. package/addon/components/validated-input.hbs +52 -54
  22. package/addon/components/validated-input.js +5 -5
  23. package/addon/helpers/class-list.js +9 -0
  24. package/addon/passed-or-default.js +16 -0
  25. package/app/components/validated-input/{-themes/uikit/hint.js → render/wrapper.js} +1 -1
  26. package/app/helpers/class-list.js +1 -0
  27. package/index.js +63 -0
  28. package/package.json +25 -23
  29. package/addon/-private/themed-component.js +0 -38
  30. package/addon/components/validated-button/-themes/bootstrap/button.js +0 -10
  31. package/addon/components/validated-button/-themes/uikit/button.js +0 -10
  32. package/addon/components/validated-button/button.js +0 -4
  33. package/addon/components/validated-input/-themes/bootstrap/error.js +0 -5
  34. package/addon/components/validated-input/-themes/bootstrap/hint.js +0 -5
  35. package/addon/components/validated-input/-themes/bootstrap/label.js +0 -3
  36. package/addon/components/validated-input/-themes/bootstrap/render.js +0 -5
  37. package/addon/components/validated-input/-themes/uikit/error.hbs +0 -4
  38. package/addon/components/validated-input/-themes/uikit/error.js +0 -3
  39. package/addon/components/validated-input/-themes/uikit/hint.js +0 -5
  40. package/addon/components/validated-input/-themes/uikit/label.js +0 -5
  41. package/addon/components/validated-input/-themes/uikit/render.hbs +0 -118
  42. package/addon/components/validated-input/-themes/uikit/render.js +0 -5
  43. package/addon/components/validated-input/hint.js +0 -4
  44. package/addon/components/validated-input/label.js +0 -4
  45. package/addon/components/validated-input/types/-themes/bootstrap/checkbox-group.hbs +0 -19
  46. package/addon/components/validated-input/types/-themes/bootstrap/checkbox-group.js +0 -3
  47. package/addon/components/validated-input/types/-themes/bootstrap/checkbox.hbs +0 -14
  48. package/addon/components/validated-input/types/-themes/bootstrap/checkbox.js +0 -3
  49. package/addon/components/validated-input/types/-themes/bootstrap/input.js +0 -13
  50. package/addon/components/validated-input/types/-themes/bootstrap/radio-group.hbs +0 -20
  51. package/addon/components/validated-input/types/-themes/bootstrap/radio-group.js +0 -3
  52. package/addon/components/validated-input/types/-themes/bootstrap/select.js +0 -13
  53. package/addon/components/validated-input/types/-themes/bootstrap/textarea.js +0 -13
  54. package/addon/components/validated-input/types/-themes/uikit/checkbox-group.hbs +0 -19
  55. package/addon/components/validated-input/types/-themes/uikit/checkbox-group.js +0 -3
  56. package/addon/components/validated-input/types/-themes/uikit/checkbox.hbs +0 -15
  57. package/addon/components/validated-input/types/-themes/uikit/checkbox.js +0 -3
  58. package/addon/components/validated-input/types/-themes/uikit/input.js +0 -13
  59. package/addon/components/validated-input/types/-themes/uikit/radio-group.hbs +0 -20
  60. package/addon/components/validated-input/types/-themes/uikit/radio-group.js +0 -3
  61. package/addon/components/validated-input/types/-themes/uikit/select.js +0 -13
  62. package/addon/components/validated-input/types/-themes/uikit/textarea.js +0 -13
  63. package/app/components/validated-button/-themes/bootstrap/button.js +0 -1
  64. package/app/components/validated-button/-themes/uikit/button.js +0 -1
  65. package/app/components/validated-input/-themes/bootstrap/error.js +0 -1
  66. package/app/components/validated-input/-themes/bootstrap/hint.js +0 -1
  67. package/app/components/validated-input/-themes/bootstrap/label.js +0 -1
  68. package/app/components/validated-input/-themes/bootstrap/render.js +0 -1
  69. package/app/components/validated-input/-themes/uikit/error.js +0 -1
  70. package/app/components/validated-input/-themes/uikit/label.js +0 -1
  71. package/app/components/validated-input/-themes/uikit/render.js +0 -1
  72. package/app/components/validated-input/types/-themes/bootstrap/checkbox-group.js +0 -1
  73. package/app/components/validated-input/types/-themes/bootstrap/checkbox.js +0 -1
  74. package/app/components/validated-input/types/-themes/bootstrap/input.js +0 -1
  75. package/app/components/validated-input/types/-themes/bootstrap/radio-group.js +0 -1
  76. package/app/components/validated-input/types/-themes/bootstrap/select.js +0 -1
  77. package/app/components/validated-input/types/-themes/bootstrap/textarea.js +0 -1
  78. package/app/components/validated-input/types/-themes/uikit/checkbox-group.js +0 -1
  79. package/app/components/validated-input/types/-themes/uikit/checkbox.js +0 -1
  80. package/app/components/validated-input/types/-themes/uikit/input.js +0 -1
  81. package/app/components/validated-input/types/-themes/uikit/radio-group.js +0 -1
  82. package/app/components/validated-input/types/-themes/uikit/select.js +0 -1
  83. package/app/components/validated-input/types/-themes/uikit/textarea.js +0 -1
@@ -1,17 +1,19 @@
1
- {{#let
2
- (component
3
- this.buttonComponent
4
- onClick=this.click
5
- loading=this.loading
6
- disabled=(or @disabled this.loading)
7
- label=@label
8
- type=@type
9
- )
10
- as |Button|
11
- }}
12
- {{#if (has-block)}}
13
- <Button ...attributes>{{yield}}</Button>
14
- {{else}}
15
- <Button ...attributes />
16
- {{/if}}
17
- {{/let}}
1
+ {{#if (has-block)}}
2
+ <this.buttonComponent
3
+ @onClick={{this.click}}
4
+ @loading={{this.loading}}
5
+ @disabled={{or @disabled this.loading}}
6
+ @label={{@label}}
7
+ @type={{@type}}
8
+ ...attributes
9
+ >{{yield}}</this.buttonComponent>
10
+ {{else}}
11
+ <this.buttonComponent
12
+ @onClick={{this.click}}
13
+ @loading={{this.loading}}
14
+ @disabled={{or @disabled this.loading}}
15
+ @label={{@label}}
16
+ @type={{@type}}
17
+ ...attributes
18
+ />
19
+ {{/if}}
@@ -1,25 +1,17 @@
1
- import { getOwner } from "@ember/application";
2
1
  import { action } from "@ember/object";
2
+ import { macroCondition, getOwnConfig } from "@embroider/macros";
3
3
  import Component from "@glimmer/component";
4
4
  import { tracked } from "@glimmer/tracking";
5
5
  import { resolve } from "rsvp";
6
6
 
7
- import themedComponent from "../-private/themed-component";
7
+ import passedOrDefault from "ember-validated-form/passed-or-default";
8
8
 
9
9
  const ON_CLICK = "on-click";
10
10
  const ON_INVALID_CLICK = "on-invalid-click";
11
11
  export default class ValidatedButtonComponent extends Component {
12
- @themedComponent("validated-button/button") buttonComponent;
13
-
14
12
  @tracked _loading;
15
13
 
16
- constructor(...args) {
17
- super(...args);
18
- this.config =
19
- getOwner(this).resolveRegistration("config:environment")[
20
- "ember-validated-form"
21
- ];
22
- }
14
+ @passedOrDefault("button") buttonComponent;
23
15
 
24
16
  get loading() {
25
17
  return this.args.loading || this._loading;
@@ -48,10 +40,12 @@ export default class ValidatedButtonComponent extends Component {
48
40
 
49
41
  await model.validate();
50
42
 
51
- if (this.config?.features?.scrollErrorIntoView && model.errors[0]?.key) {
52
- document
53
- .querySelector(`[name=${model.errors[0].key}]`)
54
- ?.scrollIntoView({ behavior: "smooth" });
43
+ if (macroCondition(getOwnConfig().scrollErrorIntoView)) {
44
+ if (model.errors[0]?.key) {
45
+ document
46
+ .querySelector(`[name=${model.errors[0].key}]`)
47
+ ?.scrollIntoView({ behavior: "smooth" });
48
+ }
55
49
  }
56
50
 
57
51
  if (model.get("isInvalid")) {
@@ -1,6 +1,6 @@
1
- import { getOwner } from "@ember/application";
2
1
  import { action } from "@ember/object";
3
2
  import { scheduleOnce } from "@ember/runloop";
3
+ import { macroCondition, getOwnConfig } from "@embroider/macros";
4
4
  import Component from "@glimmer/component";
5
5
  import { tracked } from "@glimmer/tracking";
6
6
  import { resolve } from "rsvp";
@@ -15,10 +15,6 @@ export default class ValidatedFormComponent extends Component {
15
15
 
16
16
  constructor(...args) {
17
17
  super(...args);
18
- this.config =
19
- getOwner(this).resolveRegistration("config:environment")[
20
- "ember-validated-form"
21
- ];
22
18
 
23
19
  if (this.args.model && this.args.model.validate) {
24
20
  scheduleOnce("actions", this, "validateModel", this.args.model);
@@ -49,10 +45,12 @@ export default class ValidatedFormComponent extends Component {
49
45
  await model.validate();
50
46
 
51
47
  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({ behavior: "smooth" });
48
+ if (macroCondition(getOwnConfig().scrollErrorIntoView)) {
49
+ if (model.errors[0]?.key) {
50
+ document
51
+ .querySelector(`[name=${model.errors[0].key}]`)
52
+ ?.scrollIntoView({ behavior: "smooth" });
53
+ }
56
54
  }
57
55
  this.runCallback(PROP_ON_INVALID_SUBMIT);
58
56
  } else {
@@ -1 +1,15 @@
1
- <span class={{this.class}} ...attributes>{{yield}}{{this.errorString}}</span>
1
+ {{#if (macroCondition (macroGetOwnConfig "isUikit"))}}
2
+ <small class="uk-text-danger" ...attributes>
3
+ {{yield}}{{this.errorString}}
4
+ </small>
5
+ {{else}}
6
+ <span
7
+ class={{if
8
+ (macroCondition (macroGetOwnConfig "isBootstrap"))
9
+ "invalid-feedback"
10
+ }}
11
+ ...attributes
12
+ >
13
+ {{yield}}{{this.errorString}}
14
+ </span>
15
+ {{/if}}
@@ -1 +1,9 @@
1
- <small class={{this.class}} ...attributes>{{yield}}{{@hint}}</small>
1
+ <small
2
+ class={{class-list
3
+ (if (macroCondition (macroGetOwnConfig "isUikit")) "uk-text-muted")
4
+ (if
5
+ (macroCondition (macroGetOwnConfig "isBootstrap")) "form-text text-muted"
6
+ )
7
+ }}
8
+ ...attributes
9
+ >{{yield}}{{@hint}}</small>
@@ -1,3 +1,7 @@
1
- <label class={{this.class}} for={{@inputId}} ...attributes>
1
+ <label
2
+ class={{if (macroCondition (macroGetOwnConfig "isUikit")) "uk-form-label"}}
3
+ for={{@inputId}}
4
+ ...attributes
5
+ >
2
6
  {{yield}}{{@label}}{{if @required " *"}}
3
7
  </label>
@@ -0,0 +1,5 @@
1
+ {{#if (macroCondition (macroGetOwnConfig "isUikit"))}}
2
+ <div class="uk-form-controls">{{yield}}</div>
3
+ {{else}}
4
+ {{yield}}
5
+ {{/if}}
@@ -1,14 +1,18 @@
1
1
  {{! template-lint-disable no-autofocus-attribute }}
2
- <div class={{this.class}}>
2
+ <div
3
+ class={{class-list
4
+ (if (macroCondition (macroGetOwnConfig "isUikit")) "uk-margin")
5
+ (if (macroCondition (macroGetOwnConfig "isBootstrap")) "form-group")
6
+ }}
7
+ >
3
8
  {{#if (not-eq @type "checkbox")}}
4
9
  <@labelComponent />
5
10
  {{/if}}
6
11
 
7
- {{#if (eq @type "select")}}
8
- {{#let (component this.selectComponent) as |Select|}}
9
- <Select
12
+ <ValidatedInput::Render::Wrapper>
13
+ {{#if (eq @type "select")}}
14
+ <this.selectComponent
10
15
  @disabled={{@disabled}}
11
- @includeBlank={{@includeBlank}}
12
16
  @inputId={{@inputId}}
13
17
  @isInvalid={{@isInvalid}}
14
18
  @isValid={{@isValid}}
@@ -25,10 +29,8 @@
25
29
  @value={{@value}}
26
30
  ...attributes
27
31
  />
28
- {{/let}}
29
- {{else if (or (eq @type "radioGroup") (eq @type "radio-group"))}}
30
- {{#let (component this.radioGroupComponent) as |RadioGroup|}}
31
- <RadioGroup
32
+ {{else if (or (eq @type "radioGroup") (eq @type "radio-group"))}}
33
+ <this.radioGroupComponent
32
34
  @disabled={{@disabled}}
33
35
  @inputId={{@inputId}}
34
36
  @isInvalid={{@isInvalid}}
@@ -40,10 +42,8 @@
40
42
  @value={{@value}}
41
43
  ...attributes
42
44
  />
43
- {{/let}}
44
- {{else if (or (eq @type "checkboxGroup") (eq @type "checkbox-group"))}}
45
- {{#let (component this.checkboxGroupComponent) as |CheckboxGroup|}}
46
- <CheckboxGroup
45
+ {{else if (or (eq @type "checkboxGroup") (eq @type "checkbox-group"))}}
46
+ <this.checkboxGroupComponent
47
47
  @disabled={{@disabled}}
48
48
  @inputId={{@inputId}}
49
49
  @isInvalid={{@isInvalid}}
@@ -55,10 +55,8 @@
55
55
  @value={{@value}}
56
56
  ...attributes
57
57
  />
58
- {{/let}}
59
- {{else if (eq @type "checkbox")}}
60
- {{#let (component this.checkboxComponent) as |Checkbox|}}
61
- <Checkbox
58
+ {{else if (eq @type "checkbox")}}
59
+ <this.checkboxComponent
62
60
  @disabled={{@disabled}}
63
61
  @inputId={{@inputId}}
64
62
  @isInvalid={{@isInvalid}}
@@ -71,10 +69,8 @@
71
69
  @value={{@value}}
72
70
  ...attributes
73
71
  />
74
- {{/let}}
75
- {{else if (eq @type "textarea")}}
76
- {{#let (component this.textareaComponent) as |DynamicTextarea|}}
77
- <DynamicTextarea
72
+ {{else if (eq @type "textarea")}}
73
+ <this.textareaComponent
78
74
  autocomplete={{@autocomplete}}
79
75
  autofocus={{@autofocus}}
80
76
  cols={{@cols}}
@@ -90,10 +86,8 @@
90
86
  @update={{@update}}
91
87
  ...attributes
92
88
  />
93
- {{/let}}
94
- {{else}}
95
- {{#let (component this.inputComponent) as |DynamicInput|}}
96
- <DynamicInput
89
+ {{else}}
90
+ <this.inputComponent
97
91
  autocomplete={{@autocomplete}}
98
92
  autofocus={{@autofocus}}
99
93
  disabled={{@disabled}}
@@ -108,8 +102,8 @@
108
102
  @update={{@update}}
109
103
  ...attributes
110
104
  />
111
- {{/let}}
112
- {{/if}}
105
+ {{/if}}
106
+ </ValidatedInput::Render::Wrapper>
113
107
 
114
108
  <@hintComponent />
115
109
  <@errorComponent />
@@ -1,13 +1,12 @@
1
1
  import Component from "@glimmer/component";
2
2
 
3
- import themedComponent from "../../-private/themed-component";
3
+ import passedOrDefault from "ember-validated-form/passed-or-default";
4
4
 
5
5
  export default class RenderComponent extends Component {
6
- @themedComponent("validated-input/types/input") inputComponent;
7
- @themedComponent("validated-input/types/textarea") textareaComponent;
8
- @themedComponent("validated-input/types/checkbox") checkboxComponent;
9
- @themedComponent("validated-input/types/radio-group") radioGroupComponent;
10
- @themedComponent("validated-input/types/checkbox-group")
11
- checkboxGroupComponent;
12
- @themedComponent("validated-input/types/select") selectComponent;
6
+ @passedOrDefault("types/checkbox-group") checkboxGroupComponent;
7
+ @passedOrDefault("types/checkbox") checkboxComponent;
8
+ @passedOrDefault("types/input") inputComponent;
9
+ @passedOrDefault("types/radio-group") radioGroupComponent;
10
+ @passedOrDefault("types/select") selectComponent;
11
+ @passedOrDefault("types/textarea") textareaComponent;
13
12
  }
@@ -1,15 +1,53 @@
1
1
  {{#each @options as |option i|}}
2
- <label>
3
- <input
4
- type="checkbox"
5
- checked={{eq @value option.key}}
6
- value={{option.key}}
7
- name={{@name}}
8
- id="{{@inputId}}-{{i}}"
9
- disabled={{@disabled}}
10
- {{on "input" (fn this.onUpdate option.key)}}
11
- ...attributes
12
- />
13
- {{option.label}}
14
- </label>
2
+ {{#if (macroCondition (macroGetOwnConfig "isUikit"))}}
3
+ {{#if (not-eq i 0)}}<br />{{/if}}
4
+ <label
5
+ class="uk-form-label
6
+ {{if @isValid 'uk-text-success'}}
7
+ {{if @isInvalid 'uk-text-danger'}}"
8
+ >
9
+ <input
10
+ type="checkbox"
11
+ class="uk-checkbox uk-margin-small-right"
12
+ checked={{includes option.key @value}}
13
+ name={{@name}}
14
+ id="{{@inputId}}-{{i}}"
15
+ disabled={{@disabled}}
16
+ {{on "input" (fn this.onUpdate option.key)}}
17
+ />
18
+ {{option.label}}
19
+ </label>
20
+ {{else if (macroCondition (macroGetOwnConfig "isBootstrap"))}}
21
+ <div class="custom-control custom-checkbox">
22
+ <input
23
+ type="checkbox"
24
+ class="custom-control-input
25
+ {{if @isValid 'is-valid'}}
26
+ {{if @isInvalid 'is-invalid'}}"
27
+ checked={{includes option.key @value}}
28
+ name={{@name}}
29
+ id="{{@inputId}}-{{i}}"
30
+ disabled={{@disabled}}
31
+ {{on "input" (fn this.onUpdate option.key)}}
32
+ />
33
+ <label
34
+ class="custom-control-label"
35
+ for="{{@inputId}}-{{i}}"
36
+ >{{option.label}}</label>
37
+ </div>
38
+ {{else}}
39
+ <label>
40
+ <input
41
+ type="checkbox"
42
+ checked={{eq @value option.key}}
43
+ value={{option.key}}
44
+ name={{@name}}
45
+ id="{{@inputId}}-{{i}}"
46
+ disabled={{@disabled}}
47
+ {{on "input" (fn this.onUpdate option.key)}}
48
+ ...attributes
49
+ />
50
+ {{option.label}}
51
+ </label>
52
+ {{/if}}
15
53
  {{/each}}
@@ -1,10 +1,41 @@
1
- <input
2
- type="checkbox"
3
- name={{@name}}
4
- id={{@inputId}}
5
- disabled={{@disabled}}
6
- checked={{@value}}
7
- {{on "input" this.onUpdate}}
8
- ...attributes
9
- />
10
- <@labelComponent />
1
+ {{#if (macroCondition (macroGetOwnConfig "isUikit"))}}
2
+ <@labelComponent
3
+ class="{{if @isValid 'uk-text-success'}} {{if @isInvalid 'uk-text-danger'}}"
4
+ >
5
+ <input
6
+ class="uk-checkbox uk-margin-small-right"
7
+ type="checkbox"
8
+ name={{@name}}
9
+ id={{@inputId}}
10
+ disabled={{@disabled}}
11
+ checked={{@value}}
12
+ {{on "input" this.onUpdate}}
13
+ />
14
+ </@labelComponent>
15
+ {{else if (macroCondition (macroGetOwnConfig "isBootstrap"))}}
16
+ <div class="custom-control custom-checkbox">
17
+ <input
18
+ class="custom-control-input
19
+ {{if @isValid 'is-valid'}}
20
+ {{if @isInvalid 'is-invalid'}}"
21
+ type="checkbox"
22
+ name={{@name}}
23
+ id={{@inputId}}
24
+ disabled={{@disabled}}
25
+ checked={{@value}}
26
+ {{on "input" this.onUpdate}}
27
+ />
28
+ <@labelComponent class="custom-control-label" />
29
+ </div>
30
+ {{else}}
31
+ <input
32
+ type="checkbox"
33
+ name={{@name}}
34
+ id={{@inputId}}
35
+ disabled={{@disabled}}
36
+ checked={{@value}}
37
+ {{on "input" this.onUpdate}}
38
+ ...attributes
39
+ />
40
+ <@labelComponent />
41
+ {{/if}}
@@ -1,5 +1,20 @@
1
1
  <input
2
- class={{this.class}}
2
+ class={{class-list
3
+ (if
4
+ (macroCondition (macroGetOwnConfig "isUikit"))
5
+ (class-list
6
+ "uk-input"
7
+ (if @isValid "uk-form-success")
8
+ (if @isInvalid "uk-form-danger")
9
+ )
10
+ )
11
+ (if
12
+ (macroCondition (macroGetOwnConfig "isBootstrap"))
13
+ (class-list
14
+ "form-control" (if @isValid "is-valid") (if @isInvalid "is-invalid")
15
+ )
16
+ )
17
+ }}
3
18
  {{on "input" this.onUpdate}}
4
19
  {{on "blur" @setDirty}}
5
20
  ...attributes
@@ -1,6 +1,5 @@
1
1
  import { action } from "@ember/object";
2
2
  import Component from "@glimmer/component";
3
-
4
3
  export default class InputComponent extends Component {
5
4
  @action
6
5
  onUpdate(event) {
@@ -1,15 +1,55 @@
1
1
  {{#each @options as |option i|}}
2
- <label>
3
- <input
4
- type="radio"
5
- checked={{eq @value option.key}}
6
- value={{option.key}}
7
- name={{@name}}
8
- id="{{@inputId}}-{{i}}"
9
- disabled={{@disabled}}
10
- {{on "input" (fn this.onUpdate option.key)}}
11
- ...attributes
12
- />
13
- {{option.label}}
14
- </label>
2
+ {{#if (macroCondition (macroGetOwnConfig "isUikit"))}}
3
+ {{#if (not-eq i 0)}}<br />{{/if}}
4
+ <label
5
+ class="uk-form-label
6
+ {{if @isValid 'uk-text-success'}}
7
+ {{if @isInvalid 'uk-text-danger'}}"
8
+ >
9
+ <input
10
+ type="radio"
11
+ class="uk-radio uk-margin-small-right"
12
+ checked={{eq @value option.key}}
13
+ value={{option.key}}
14
+ name={{@name}}
15
+ id="{{@inputId}}-{{i}}"
16
+ disabled={{@disabled}}
17
+ {{on "input" (fn this.onUpdate option.key)}}
18
+ />
19
+ {{option.label}}
20
+ </label>
21
+ {{else if (macroCondition (macroGetOwnConfig "isBootstrap"))}}
22
+ <div class="custom-control custom-radio">
23
+ <input
24
+ type="radio"
25
+ class="custom-control-input
26
+ {{if @isValid 'is-valid'}}
27
+ {{if @isInvalid 'is-invalid'}}"
28
+ checked={{eq @value option.key}}
29
+ value={{option.key}}
30
+ name={{@name}}
31
+ id="{{@inputId}}-{{i}}"
32
+ disabled={{@disabled}}
33
+ {{on "input" (fn this.onUpdate option.key)}}
34
+ />
35
+ <label
36
+ class="custom-control-label"
37
+ for="{{@inputId}}-{{i}}"
38
+ >{{option.label}}</label>
39
+ </div>
40
+ {{else}}
41
+ <label>
42
+ <input
43
+ type="radio"
44
+ checked={{eq @value option.key}}
45
+ value={{option.key}}
46
+ name={{@name}}
47
+ id="{{@inputId}}-{{i}}"
48
+ disabled={{@disabled}}
49
+ {{on "input" (fn this.onUpdate option.key)}}
50
+ ...attributes
51
+ />
52
+ {{option.label}}
53
+ </label>
54
+ {{/if}}
15
55
  {{/each}}
@@ -1,5 +1,20 @@
1
1
  <select
2
- class={{this.class}}
2
+ class={{class-list
3
+ (if
4
+ (macroCondition (macroGetOwnConfig "isUikit"))
5
+ (class-list
6
+ "uk-select"
7
+ (if @isValid "uk-form-success")
8
+ (if @isInvalid "uk-form-danger")
9
+ )
10
+ )
11
+ (if
12
+ (macroCondition (macroGetOwnConfig "isBootstrap"))
13
+ (class-list
14
+ "form-control" (if @isValid "is-valid") (if @isInvalid "is-invalid")
15
+ )
16
+ )
17
+ }}
3
18
  name={{@name}}
4
19
  id={{@inpudId}}
5
20
  disabled={{@disabled}}
@@ -8,12 +23,12 @@
8
23
  {{on "blur" this.onBlur}}
9
24
  ...attributes
10
25
  >
11
- {{#if (or @prompt @includeBlank)}}
26
+ {{#if @prompt}}
12
27
  <option
13
28
  value=""
14
29
  disabled={{not @promptIsSelectable}}
15
30
  selected={{not @value}}
16
- >{{or @prompt @includeBlank}}</option>
31
+ >{{@prompt}}</option>
17
32
  {{/if}}
18
33
 
19
34
  {{#if this.hasGrouping}}
@@ -1,5 +1,3 @@
1
- import { A as emberArray, isArray } from "@ember/array";
2
- import { deprecate } from "@ember/debug";
3
1
  import EmberObject, { action, get } from "@ember/object";
4
2
  import Component from "@glimmer/component";
5
3
 
@@ -9,29 +7,11 @@ import Component from "@glimmer/component";
9
7
  * Our implementation is slightly simpler, since it does not support
10
8
  * the block syntax for options.
11
9
  */
12
-
13
10
  export default class SelectComponent extends Component {
14
- constructor(...args) {
15
- super(...args);
16
-
17
- if (this.args.includeBlank) {
18
- deprecate(
19
- "The `includeBlank` property is deprecated. Please use `prompt` instead.",
20
- false,
21
- {
22
- id: "ember-validated-form:NoMoreincludeBlank",
23
- until: "6.0.0",
24
- since: "5.1.0",
25
- url: "https://github.com/adfinis-sygroup/ember-validated-form/releases/tag/v5.1.0",
26
- for: "ember-validated-form",
27
- }
28
- );
29
- }
30
- }
31
-
32
11
  get hasPreGroupedOptions() {
33
12
  return (
34
- this.args.options[0]?.groupName && isArray(this.args.options[0]?.options)
13
+ this.args.options[0]?.groupName &&
14
+ Array.isArray(this.args.options[0]?.options)
35
15
  );
36
16
  }
37
17
 
@@ -61,26 +41,26 @@ export default class SelectComponent extends Component {
61
41
  if (!groupLabelPath) {
62
42
  return this.args.options;
63
43
  }
64
- const groups = emberArray();
44
+ const groups = [];
65
45
 
66
46
  this.args.options.forEach((item) => {
67
47
  const label = get(item, groupLabelPath);
68
48
 
69
49
  if (label) {
70
- let group = groups.findBy("groupName", label);
50
+ let group = groups.find((group) => group.groupName === label);
71
51
 
72
52
  if (!group) {
73
53
  group = EmberObject.create({
74
54
  groupName: label,
75
- options: emberArray(),
55
+ options: [],
76
56
  });
77
57
 
78
- groups.pushObject(group);
58
+ groups.push(group);
79
59
  }
80
60
 
81
- group.options.pushObject(this.normalize(item));
61
+ group.options.push(this.normalize(item));
82
62
  } else {
83
- groups.pushObject(item);
63
+ groups.push(item);
84
64
  }
85
65
  });
86
66
 
@@ -1,5 +1,20 @@
1
1
  <textarea
2
- class={{this.class}}
2
+ class={{class-list
3
+ (if
4
+ (macroCondition (macroGetOwnConfig "isUikit"))
5
+ (class-list
6
+ "uk-textarea"
7
+ (if @isValid "uk-form-success")
8
+ (if @isInvalid "uk-form-danger")
9
+ )
10
+ )
11
+ (if
12
+ (macroCondition (macroGetOwnConfig "isBootstrap"))
13
+ (class-list
14
+ "form-control" (if @isValid "is-valid") (if @isInvalid "is-invalid")
15
+ )
16
+ )
17
+ }}
3
18
  {{on "input" this.onUpdate}}
4
19
  {{on "blur" @setDirty}}
5
20
  ...attributes