ember-validated-form 5.2.2 → 6.0.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 +149 -123
- package/README.md +3 -3
- package/addon/components/validated-button/button.hbs +17 -1
- package/addon/components/validated-button.hbs +19 -17
- package/addon/components/validated-button.js +9 -15
- package/addon/components/validated-form.js +7 -9
- package/addon/components/validated-input/error.hbs +15 -1
- package/addon/components/validated-input/hint.hbs +9 -1
- package/addon/components/validated-input/label.hbs +5 -1
- package/addon/components/validated-input/render/wrapper.hbs +5 -0
- package/addon/components/validated-input/render.hbs +29 -27
- package/addon/components/validated-input/render.js +7 -8
- package/addon/components/validated-input/types/checkbox-group.hbs +51 -12
- package/addon/components/validated-input/types/checkbox.hbs +41 -9
- package/addon/components/validated-input/types/input.hbs +17 -2
- package/addon/components/validated-input/types/input.js +0 -1
- package/addon/components/validated-input/types/radio-group.hbs +53 -12
- package/addon/components/validated-input/types/select.hbs +19 -4
- package/addon/components/validated-input/types/select.js +11 -28
- package/addon/components/validated-input/types/textarea.hbs +17 -2
- package/addon/components/validated-input.hbs +52 -52
- package/addon/components/validated-input.js +5 -5
- package/addon/helpers/class-list.js +9 -0
- package/addon/passed-or-default.js +17 -0
- package/app/components/validated-input/{-themes/uikit/hint.js → render/wrapper.js} +1 -1
- package/app/helpers/class-list.js +1 -0
- package/blueprints/ember-validated-form/index.js +1 -0
- package/index.js +63 -0
- package/package.json +40 -44
- package/.github/ISSUE_TEMPLATE/bug_report.md +0 -9
- package/.github/dependabot.yml +0 -11
- package/.github/workflows/deploy.yml +0 -28
- package/.github/workflows/release.yml +0 -25
- package/.github/workflows/test.yml +0 -84
- package/addon/-private/themed-component.js +0 -38
- package/addon/components/validated-button/-themes/bootstrap/button.js +0 -10
- package/addon/components/validated-button/-themes/uikit/button.js +0 -10
- package/addon/components/validated-button/button.js +0 -4
- package/addon/components/validated-input/-themes/bootstrap/error.js +0 -5
- package/addon/components/validated-input/-themes/bootstrap/hint.js +0 -5
- package/addon/components/validated-input/-themes/bootstrap/label.js +0 -3
- package/addon/components/validated-input/-themes/bootstrap/render.js +0 -5
- package/addon/components/validated-input/-themes/uikit/error.hbs +0 -4
- package/addon/components/validated-input/-themes/uikit/error.js +0 -3
- package/addon/components/validated-input/-themes/uikit/hint.js +0 -5
- package/addon/components/validated-input/-themes/uikit/label.js +0 -5
- package/addon/components/validated-input/-themes/uikit/render.hbs +0 -110
- package/addon/components/validated-input/-themes/uikit/render.js +0 -5
- package/addon/components/validated-input/hint.js +0 -4
- package/addon/components/validated-input/label.js +0 -4
- package/addon/components/validated-input/types/-themes/bootstrap/checkbox-group.hbs +0 -19
- package/addon/components/validated-input/types/-themes/bootstrap/checkbox-group.js +0 -3
- package/addon/components/validated-input/types/-themes/bootstrap/checkbox.hbs +0 -14
- package/addon/components/validated-input/types/-themes/bootstrap/checkbox.js +0 -3
- package/addon/components/validated-input/types/-themes/bootstrap/input.js +0 -13
- package/addon/components/validated-input/types/-themes/bootstrap/radio-group.hbs +0 -20
- package/addon/components/validated-input/types/-themes/bootstrap/radio-group.js +0 -3
- package/addon/components/validated-input/types/-themes/bootstrap/select.js +0 -13
- package/addon/components/validated-input/types/-themes/bootstrap/textarea.js +0 -13
- package/addon/components/validated-input/types/-themes/uikit/checkbox-group.hbs +0 -19
- package/addon/components/validated-input/types/-themes/uikit/checkbox-group.js +0 -3
- package/addon/components/validated-input/types/-themes/uikit/checkbox.hbs +0 -15
- package/addon/components/validated-input/types/-themes/uikit/checkbox.js +0 -3
- package/addon/components/validated-input/types/-themes/uikit/input.js +0 -13
- package/addon/components/validated-input/types/-themes/uikit/radio-group.hbs +0 -20
- package/addon/components/validated-input/types/-themes/uikit/radio-group.js +0 -3
- package/addon/components/validated-input/types/-themes/uikit/select.js +0 -13
- package/addon/components/validated-input/types/-themes/uikit/textarea.js +0 -13
- package/app/components/validated-button/-themes/bootstrap/button.js +0 -1
- package/app/components/validated-button/-themes/uikit/button.js +0 -1
- package/app/components/validated-input/-themes/bootstrap/error.js +0 -1
- package/app/components/validated-input/-themes/bootstrap/hint.js +0 -1
- package/app/components/validated-input/-themes/bootstrap/label.js +0 -1
- package/app/components/validated-input/-themes/bootstrap/render.js +0 -1
- package/app/components/validated-input/-themes/uikit/error.js +0 -1
- package/app/components/validated-input/-themes/uikit/label.js +0 -1
- package/app/components/validated-input/-themes/uikit/render.js +0 -1
- package/app/components/validated-input/types/-themes/bootstrap/checkbox-group.js +0 -1
- package/app/components/validated-input/types/-themes/bootstrap/checkbox.js +0 -1
- package/app/components/validated-input/types/-themes/bootstrap/input.js +0 -1
- package/app/components/validated-input/types/-themes/bootstrap/radio-group.js +0 -1
- package/app/components/validated-input/types/-themes/bootstrap/select.js +0 -1
- package/app/components/validated-input/types/-themes/bootstrap/textarea.js +0 -1
- package/app/components/validated-input/types/-themes/uikit/checkbox-group.js +0 -1
- package/app/components/validated-input/types/-themes/uikit/checkbox.js +0 -1
- package/app/components/validated-input/types/-themes/uikit/input.js +0 -1
- package/app/components/validated-input/types/-themes/uikit/radio-group.js +0 -1
- package/app/components/validated-input/types/-themes/uikit/select.js +0 -1
- package/app/components/validated-input/types/-themes/uikit/textarea.js +0 -1
|
@@ -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
|
|
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
|
-
|
|
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 (
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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 (
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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
|
-
|
|
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
|
|
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,13 +1,18 @@
|
|
|
1
|
-
|
|
1
|
+
{{! template-lint-disable no-autofocus-attribute }}
|
|
2
|
+
<div
|
|
3
|
+
class={{class-list
|
|
4
|
+
(if (macroCondition (macroGetOwnConfig "isUikit")) "uk-margin")
|
|
5
|
+
(if (macroCondition (macroGetOwnConfig "isBootstrap")) "form-group")
|
|
6
|
+
}}
|
|
7
|
+
>
|
|
2
8
|
{{#if (not-eq @type "checkbox")}}
|
|
3
9
|
<@labelComponent />
|
|
4
10
|
{{/if}}
|
|
5
11
|
|
|
6
|
-
|
|
7
|
-
{{#
|
|
8
|
-
<
|
|
12
|
+
<ValidatedInput::Render::Wrapper>
|
|
13
|
+
{{#if (eq @type "select")}}
|
|
14
|
+
<this.selectComponent
|
|
9
15
|
@disabled={{@disabled}}
|
|
10
|
-
@includeBlank={{@includeBlank}}
|
|
11
16
|
@inputId={{@inputId}}
|
|
12
17
|
@isInvalid={{@isInvalid}}
|
|
13
18
|
@isValid={{@isValid}}
|
|
@@ -17,15 +22,15 @@
|
|
|
17
22
|
@options={{@options}}
|
|
18
23
|
@optionTargetPath={{@optionTargetPath}}
|
|
19
24
|
@optionValuePath={{@optionValuePath}}
|
|
25
|
+
@prompt={{@prompt}}
|
|
20
26
|
@promptIsSelectable={{@promptIsSelectable}}
|
|
21
27
|
@setDirty={{@setDirty}}
|
|
22
28
|
@update={{@update}}
|
|
23
29
|
@value={{@value}}
|
|
30
|
+
...attributes
|
|
24
31
|
/>
|
|
25
|
-
{{
|
|
26
|
-
|
|
27
|
-
{{#let (component this.radioGroupComponent) as |RadioGroup|}}
|
|
28
|
-
<RadioGroup
|
|
32
|
+
{{else if (or (eq @type "radioGroup") (eq @type "radio-group"))}}
|
|
33
|
+
<this.radioGroupComponent
|
|
29
34
|
@disabled={{@disabled}}
|
|
30
35
|
@inputId={{@inputId}}
|
|
31
36
|
@isInvalid={{@isInvalid}}
|
|
@@ -35,11 +40,10 @@
|
|
|
35
40
|
@setDirty={{@setDirty}}
|
|
36
41
|
@update={{@update}}
|
|
37
42
|
@value={{@value}}
|
|
43
|
+
...attributes
|
|
38
44
|
/>
|
|
39
|
-
{{
|
|
40
|
-
|
|
41
|
-
{{#let (component this.checkboxGroupComponent) as |CheckboxGroup|}}
|
|
42
|
-
<CheckboxGroup
|
|
45
|
+
{{else if (or (eq @type "checkboxGroup") (eq @type "checkbox-group"))}}
|
|
46
|
+
<this.checkboxGroupComponent
|
|
43
47
|
@disabled={{@disabled}}
|
|
44
48
|
@inputId={{@inputId}}
|
|
45
49
|
@isInvalid={{@isInvalid}}
|
|
@@ -49,11 +53,10 @@
|
|
|
49
53
|
@setDirty={{@setDirty}}
|
|
50
54
|
@update={{@update}}
|
|
51
55
|
@value={{@value}}
|
|
56
|
+
...attributes
|
|
52
57
|
/>
|
|
53
|
-
{{
|
|
54
|
-
|
|
55
|
-
{{#let (component this.checkboxComponent) as |Checkbox|}}
|
|
56
|
-
<Checkbox
|
|
58
|
+
{{else if (eq @type "checkbox")}}
|
|
59
|
+
<this.checkboxComponent
|
|
57
60
|
@disabled={{@disabled}}
|
|
58
61
|
@inputId={{@inputId}}
|
|
59
62
|
@isInvalid={{@isInvalid}}
|
|
@@ -64,11 +67,10 @@
|
|
|
64
67
|
@setDirty={{@setDirty}}
|
|
65
68
|
@update={{@update}}
|
|
66
69
|
@value={{@value}}
|
|
70
|
+
...attributes
|
|
67
71
|
/>
|
|
68
|
-
{{
|
|
69
|
-
|
|
70
|
-
{{#let (component this.textareaComponent) as |DynamicTextarea|}}
|
|
71
|
-
<DynamicTextarea
|
|
72
|
+
{{else if (eq @type "textarea")}}
|
|
73
|
+
<this.textareaComponent
|
|
72
74
|
autocomplete={{@autocomplete}}
|
|
73
75
|
autofocus={{@autofocus}}
|
|
74
76
|
cols={{@cols}}
|
|
@@ -82,11 +84,10 @@
|
|
|
82
84
|
@isValid={{@isValid}}
|
|
83
85
|
@setDirty={{@setDirty}}
|
|
84
86
|
@update={{@update}}
|
|
87
|
+
...attributes
|
|
85
88
|
/>
|
|
86
|
-
{{
|
|
87
|
-
|
|
88
|
-
{{#let (component this.inputComponent) as |DynamicInput|}}
|
|
89
|
-
<DynamicInput
|
|
89
|
+
{{else}}
|
|
90
|
+
<this.inputComponent
|
|
90
91
|
autocomplete={{@autocomplete}}
|
|
91
92
|
autofocus={{@autofocus}}
|
|
92
93
|
disabled={{@disabled}}
|
|
@@ -99,9 +100,10 @@
|
|
|
99
100
|
@isValid={{@isValid}}
|
|
100
101
|
@setDirty={{@setDirty}}
|
|
101
102
|
@update={{@update}}
|
|
103
|
+
...attributes
|
|
102
104
|
/>
|
|
103
|
-
{{/
|
|
104
|
-
|
|
105
|
+
{{/if}}
|
|
106
|
+
</ValidatedInput::Render::Wrapper>
|
|
105
107
|
|
|
106
108
|
<@hintComponent />
|
|
107
109
|
<@errorComponent />
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import Component from "@glimmer/component";
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import passedOrDefault from "ember-validated-form/passed-or-default";
|
|
4
4
|
|
|
5
5
|
export default class RenderComponent extends Component {
|
|
6
|
-
@
|
|
7
|
-
@
|
|
8
|
-
@
|
|
9
|
-
@
|
|
10
|
-
@
|
|
11
|
-
|
|
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,14 +1,53 @@
|
|
|
1
1
|
{{#each @options as |option i|}}
|
|
2
|
-
|
|
3
|
-
<
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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}}
|
|
14
53
|
{{/each}}
|
|
@@ -1,9 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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,6 +1,21 @@
|
|
|
1
1
|
<input
|
|
2
|
-
class={{
|
|
3
|
-
|
|
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
|
+
}}
|
|
4
18
|
{{on "input" this.onUpdate}}
|
|
5
19
|
{{on "blur" @setDirty}}
|
|
20
|
+
...attributes
|
|
6
21
|
/>
|
|
@@ -1,14 +1,55 @@
|
|
|
1
1
|
{{#each @options as |option i|}}
|
|
2
|
-
|
|
3
|
-
<
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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}}
|
|
14
55
|
{{/each}}
|
|
@@ -1,19 +1,34 @@
|
|
|
1
1
|
<select
|
|
2
|
-
class={{
|
|
3
|
-
|
|
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
|
+
}}
|
|
4
18
|
name={{@name}}
|
|
5
19
|
id={{@inpudId}}
|
|
6
20
|
disabled={{@disabled}}
|
|
7
21
|
multiple={{@multiple}}
|
|
8
22
|
{{on "change" this.onUpdate}}
|
|
9
23
|
{{on "blur" this.onBlur}}
|
|
24
|
+
...attributes
|
|
10
25
|
>
|
|
11
|
-
{{#if
|
|
26
|
+
{{#if @prompt}}
|
|
12
27
|
<option
|
|
13
28
|
value=""
|
|
14
29
|
disabled={{not @promptIsSelectable}}
|
|
15
30
|
selected={{not @value}}
|
|
16
|
-
>{{
|
|
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,28 +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
|
-
}
|
|
27
|
-
);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
11
|
get hasPreGroupedOptions() {
|
|
32
12
|
return (
|
|
33
|
-
this.args.options[0]?.groupName &&
|
|
13
|
+
this.args.options[0]?.groupName &&
|
|
14
|
+
Array.isArray(this.args.options[0]?.options)
|
|
34
15
|
);
|
|
35
16
|
}
|
|
36
17
|
|
|
@@ -60,26 +41,26 @@ export default class SelectComponent extends Component {
|
|
|
60
41
|
if (!groupLabelPath) {
|
|
61
42
|
return this.args.options;
|
|
62
43
|
}
|
|
63
|
-
const groups =
|
|
44
|
+
const groups = [];
|
|
64
45
|
|
|
65
46
|
this.args.options.forEach((item) => {
|
|
66
47
|
const label = get(item, groupLabelPath);
|
|
67
48
|
|
|
68
49
|
if (label) {
|
|
69
|
-
let group = groups.
|
|
50
|
+
let group = groups.find((group) => group.groupName === label);
|
|
70
51
|
|
|
71
52
|
if (!group) {
|
|
72
53
|
group = EmberObject.create({
|
|
73
54
|
groupName: label,
|
|
74
|
-
options:
|
|
55
|
+
options: [],
|
|
75
56
|
});
|
|
76
57
|
|
|
77
|
-
groups.
|
|
58
|
+
groups.push(group);
|
|
78
59
|
}
|
|
79
60
|
|
|
80
|
-
group.options.
|
|
61
|
+
group.options.push(this.normalize(item));
|
|
81
62
|
} else {
|
|
82
|
-
groups.
|
|
63
|
+
groups.push(item);
|
|
83
64
|
}
|
|
84
65
|
});
|
|
85
66
|
|
|
@@ -124,7 +105,9 @@ export default class SelectComponent extends Component {
|
|
|
124
105
|
|
|
125
106
|
//single select
|
|
126
107
|
const foundOption = options.find((item) => getValue(item) === target.value);
|
|
127
|
-
|
|
108
|
+
|
|
109
|
+
// If @promptIsSelectable is set to true, foundOption in this case will be undefined.
|
|
110
|
+
if (targetPath && foundOption) {
|
|
128
111
|
return foundOption[targetPath];
|
|
129
112
|
}
|
|
130
113
|
return foundOption;
|
|
@@ -1,7 +1,22 @@
|
|
|
1
1
|
<textarea
|
|
2
|
-
class={{
|
|
3
|
-
|
|
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
|
+
}}
|
|
4
18
|
{{on "input" this.onUpdate}}
|
|
5
19
|
{{on "blur" @setDirty}}
|
|
20
|
+
...attributes
|
|
6
21
|
>
|
|
7
22
|
</textarea>
|