@frontile/forms 0.14.1 → 0.16.0-alpha.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/addon-main.js +37 -0
- package/{components → declarations/components}/form-checkbox-group.d.ts +3 -1
- package/declarations/components/form-checkbox-group.d.ts.map +1 -0
- package/{components → declarations/components}/form-checkbox.d.ts +9 -0
- package/declarations/components/form-checkbox.d.ts.map +1 -0
- package/{components → declarations/components}/form-field/checkbox.d.ts +2 -0
- package/declarations/components/form-field/checkbox.d.ts.map +1 -0
- package/{components → declarations/components}/form-field/feedback.d.ts +5 -0
- package/declarations/components/form-field/feedback.d.ts.map +1 -0
- package/{components → declarations/components}/form-field/hint.d.ts +4 -0
- package/declarations/components/form-field/hint.d.ts.map +1 -0
- package/{components → declarations/components}/form-field/input.d.ts +4 -2
- package/declarations/components/form-field/input.d.ts.map +1 -0
- package/{components → declarations/components}/form-field/label.d.ts +4 -0
- package/declarations/components/form-field/label.d.ts.map +1 -0
- package/{components → declarations/components}/form-field/radio.d.ts +3 -1
- package/declarations/components/form-field/radio.d.ts.map +1 -0
- package/{components → declarations/components}/form-field/textarea.d.ts +4 -2
- package/declarations/components/form-field/textarea.d.ts.map +1 -0
- package/declarations/components/form-field.d.ts +38 -0
- package/declarations/components/form-field.d.ts.map +1 -0
- package/{components → declarations/components}/form-input.d.ts +5 -1
- package/declarations/components/form-input.d.ts.map +1 -0
- package/{components → declarations/components}/form-radio-group.d.ts +6 -2
- package/declarations/components/form-radio-group.d.ts.map +1 -0
- package/{components → declarations/components}/form-radio.d.ts +9 -1
- package/declarations/components/form-radio.d.ts.map +1 -0
- package/{components → declarations/components}/form-select.d.ts +6 -2
- package/declarations/components/form-select.d.ts.map +1 -0
- package/{components → declarations/components}/form-textarea.d.ts +5 -1
- package/declarations/components/form-textarea.d.ts.map +1 -0
- package/declarations/template-registry.d.ts +33 -0
- package/declarations/template-registry.d.ts.map +1 -0
- package/dist/_app_/components/form-checkbox-group.js +1 -0
- package/dist/_app_/components/form-checkbox.js +1 -0
- package/dist/_app_/components/form-field/checkbox.js +1 -0
- package/dist/_app_/components/form-field/feedback.js +1 -0
- package/dist/_app_/components/form-field/hint.js +1 -0
- package/dist/_app_/components/form-field/input.js +1 -0
- package/dist/_app_/components/form-field/label.js +1 -0
- package/dist/_app_/components/form-field/radio.js +1 -0
- package/dist/_app_/components/form-field/textarea.js +1 -0
- package/dist/_app_/components/form-field.js +1 -0
- package/dist/_app_/components/form-input.js +1 -0
- package/dist/_app_/components/form-radio-group.js +1 -0
- package/dist/_app_/components/form-radio.js +1 -0
- package/dist/_app_/components/form-select.js +1 -0
- package/dist/_app_/components/form-textarea.js +1 -0
- package/dist/components/form-checkbox-group.js +55 -0
- package/dist/components/form-checkbox-group.js.map +1 -0
- package/dist/components/form-checkbox.js +30 -0
- package/dist/components/form-checkbox.js.map +1 -0
- package/dist/components/form-field/checkbox.js +30 -0
- package/dist/components/form-field/checkbox.js.map +1 -0
- package/dist/components/form-field/feedback.js +29 -0
- package/dist/components/form-field/feedback.js.map +1 -0
- package/dist/components/form-field/hint.js +17 -0
- package/dist/components/form-field/hint.js.map +1 -0
- package/dist/components/form-field/input.js +36 -0
- package/dist/components/form-field/input.js.map +1 -0
- package/dist/components/form-field/label.js +17 -0
- package/dist/components/form-field/label.js.map +1 -0
- package/dist/components/form-field/radio.js +29 -0
- package/dist/components/form-field/radio.js.map +1 -0
- package/dist/components/form-field/textarea.js +30 -0
- package/dist/components/form-field/textarea.js.map +1 -0
- package/dist/components/form-field.js +44 -0
- package/dist/components/form-field.js.map +1 -0
- package/dist/components/form-input.js +64 -0
- package/dist/components/form-input.js.map +1 -0
- package/dist/components/form-radio-group.js +55 -0
- package/dist/components/form-radio-group.js.map +1 -0
- package/dist/components/form-radio.js +34 -0
- package/dist/components/form-radio.js.map +1 -0
- package/dist/components/form-select.js +102 -0
- package/dist/components/form-select.js.map +1 -0
- package/dist/components/form-textarea.js +23 -0
- package/dist/components/form-textarea.js.map +1 -0
- package/dist/template-registry.js +2 -0
- package/dist/template-registry.js.map +1 -0
- package/package.json +95 -63
- package/addon/components/form-checkbox-demo/usage.md +0 -30
- package/addon/components/form-checkbox-group-demo/usage.md +0 -54
- package/addon/components/form-checkbox-group.hbs +0 -38
- package/addon/components/form-checkbox-group.md +0 -5
- package/addon/components/form-checkbox-group.ts +0 -68
- package/addon/components/form-checkbox.hbs +0 -42
- package/addon/components/form-checkbox.md +0 -5
- package/addon/components/form-checkbox.ts +0 -45
- package/addon/components/form-field/checkbox.hbs +0 -10
- package/addon/components/form-field/checkbox.ts +0 -32
- package/addon/components/form-field/feedback.hbs +0 -10
- package/addon/components/form-field/feedback.ts +0 -30
- package/addon/components/form-field/hint.hbs +0 -8
- package/addon/components/form-field/hint.ts +0 -13
- package/addon/components/form-field/index.hbs +0 -20
- package/addon/components/form-field/index.ts +0 -46
- package/addon/components/form-field/input.hbs +0 -10
- package/addon/components/form-field/input.ts +0 -40
- package/addon/components/form-field/label.hbs +0 -8
- package/addon/components/form-field/label.ts +0 -13
- package/addon/components/form-field/radio.hbs +0 -11
- package/addon/components/form-field/radio.ts +0 -31
- package/addon/components/form-field/textarea.hbs +0 -10
- package/addon/components/form-field/textarea.ts +0 -32
- package/addon/components/form-input-demo/hint.md +0 -34
- package/addon/components/form-input-demo/no-label.md +0 -33
- package/addon/components/form-input-demo/simple.md +0 -42
- package/addon/components/form-input-demo/with-button.md +0 -60
- package/addon/components/form-input.hbs +0 -45
- package/addon/components/form-input.md +0 -5
- package/addon/components/form-input.ts +0 -96
- package/addon/components/form-radio-demo/usage.md +0 -39
- package/addon/components/form-radio-group-demo/usage.md +0 -43
- package/addon/components/form-radio-group.hbs +0 -39
- package/addon/components/form-radio-group.md +0 -5
- package/addon/components/form-radio-group.ts +0 -67
- package/addon/components/form-radio.hbs +0 -39
- package/addon/components/form-radio.md +0 -5
- package/addon/components/form-radio.ts +0 -53
- package/addon/components/form-select-demo/multiple.md +0 -60
- package/addon/components/form-select-demo/usage.md +0 -60
- package/addon/components/form-select.hbs +0 -101
- package/addon/components/form-select.md +0 -11
- package/addon/components/form-select.ts +0 -126
- package/addon/components/form-textarea-demo/usage.md +0 -40
- package/addon/components/form-textarea.hbs +0 -44
- package/addon/components/form-textarea.md +0 -5
- package/addon/components/form-textarea.ts +0 -7
- package/app/components/form-checkbox-group.js +0 -1
- package/app/components/form-checkbox.js +0 -1
- package/app/components/form-field/checkbox.js +0 -1
- package/app/components/form-field/feedback.js +0 -1
- package/app/components/form-field/hint.js +0 -1
- package/app/components/form-field/index.js +0 -1
- package/app/components/form-field/input.js +0 -1
- package/app/components/form-field/label.js +0 -1
- package/app/components/form-field/radio.js +0 -1
- package/app/components/form-field/textarea.js +0 -1
- package/app/components/form-input.js +0 -1
- package/app/components/form-radio-group.js +0 -1
- package/app/components/form-radio.js +0 -1
- package/app/components/form-select.js +0 -1
- package/app/components/form-textarea.js +0 -1
- package/components/form-field/index.d.ts +0 -36
- package/config/environment.js +0 -5
- package/index.js +0 -34
- package/tsconfig.json +0 -23
- package/types/dummy/index.d.ts +0 -0
- package/types/ember-get-config.d.ts +0 -3
- package/types/ember-power-select/test-support.d.ts +0 -29
- package/types/global.d.ts +0 -6
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import Component from '@glimmer/component';
|
|
2
|
-
import { action } from '@ember/object';
|
|
3
|
-
import { tracked } from '@glimmer/tracking';
|
|
4
|
-
|
|
5
|
-
export interface FormInputArgs {
|
|
6
|
-
/**
|
|
7
|
-
* The value to be used in the input.
|
|
8
|
-
* You must also pass `onChange` or `onInput` to update its value.
|
|
9
|
-
*/
|
|
10
|
-
value: unknown;
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* The input type
|
|
14
|
-
* @defaultValue 'text'
|
|
15
|
-
*/
|
|
16
|
-
type?: string;
|
|
17
|
-
|
|
18
|
-
/** The group label */
|
|
19
|
-
label?: string;
|
|
20
|
-
/** A help text to be displayed */
|
|
21
|
-
hint?: string;
|
|
22
|
-
/** If the form has been submitted, used to force displaying errors */
|
|
23
|
-
hasSubmitted?: boolean;
|
|
24
|
-
/** If has errors */
|
|
25
|
-
hasError?: boolean;
|
|
26
|
-
/** Force displaying errors */
|
|
27
|
-
showError?: boolean;
|
|
28
|
-
/** A list of errors or a single text describing the error */
|
|
29
|
-
errors?: string[] | string;
|
|
30
|
-
/** CSS classes to be added in the container element */
|
|
31
|
-
containerClass?: string;
|
|
32
|
-
/** The size */
|
|
33
|
-
size?: 'sm' | 'lg';
|
|
34
|
-
|
|
35
|
-
/** Callback when oninput is triggered */
|
|
36
|
-
onInput?: (value: string, event: InputEvent) => void;
|
|
37
|
-
|
|
38
|
-
/** Callback when onchange is triggered */
|
|
39
|
-
onChange?: (value: string, event: InputEvent) => void;
|
|
40
|
-
|
|
41
|
-
/** Callback when onfocus is triggered */
|
|
42
|
-
onFocusIn?: (event: FocusEvent) => void;
|
|
43
|
-
|
|
44
|
-
/** Callback when onblur is triggered */
|
|
45
|
-
onFocusOut?: (event: FocusEvent) => void;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export interface FormInputBaseSignature {
|
|
49
|
-
Args: FormInputArgs;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export interface FormInputSignature extends FormInputBaseSignature {
|
|
53
|
-
Element: HTMLInputElement;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export class FormInputBase<
|
|
57
|
-
T extends FormInputBaseSignature
|
|
58
|
-
> extends Component<T> {
|
|
59
|
-
@tracked shouldShowErrorFeedback = false;
|
|
60
|
-
|
|
61
|
-
get showErrorFeedback(): boolean {
|
|
62
|
-
if (this.args.hasError === false) {
|
|
63
|
-
return false;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
if (
|
|
67
|
-
(this.args.showError ||
|
|
68
|
-
this.args.hasSubmitted ||
|
|
69
|
-
this.shouldShowErrorFeedback) &&
|
|
70
|
-
this.args.errors &&
|
|
71
|
-
this.args.errors.length > 0
|
|
72
|
-
) {
|
|
73
|
-
return true;
|
|
74
|
-
} else {
|
|
75
|
-
return false;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
@action handleFocusIn(event: FocusEvent): void {
|
|
80
|
-
this.shouldShowErrorFeedback = false;
|
|
81
|
-
|
|
82
|
-
if (typeof this.args.onFocusIn === 'function') {
|
|
83
|
-
this.args.onFocusIn(event);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
@action handleFocusOut(event: FocusEvent): void {
|
|
88
|
-
this.shouldShowErrorFeedback = true;
|
|
89
|
-
|
|
90
|
-
if (typeof this.args.onFocusOut === 'function') {
|
|
91
|
-
this.args.onFocusOut(event);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
export default class FormInput extends FormInputBase<FormInputSignature> {}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
order: 1
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
# Usage
|
|
6
|
-
|
|
7
|
-
```hbs template
|
|
8
|
-
<FormRadio
|
|
9
|
-
name="my-radio-input"
|
|
10
|
-
@label="Yes"
|
|
11
|
-
@value={{true}}
|
|
12
|
-
@checked={{this.value}}
|
|
13
|
-
@onChange={{this.setValue}}
|
|
14
|
-
/>
|
|
15
|
-
|
|
16
|
-
<FormRadio
|
|
17
|
-
name="my-radio-input"
|
|
18
|
-
@label="No"
|
|
19
|
-
@value={{false}}
|
|
20
|
-
@checked={{this.value}}
|
|
21
|
-
@onChange={{this.setValue}}
|
|
22
|
-
/>
|
|
23
|
-
|
|
24
|
-
<p class="mt-4">Selected Value: "{{this.value}}"</p>
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
```js component
|
|
28
|
-
import Component from '@glimmer/component';
|
|
29
|
-
import { tracked } from '@glimmer/tracking';
|
|
30
|
-
import { action } from '@ember/object';
|
|
31
|
-
|
|
32
|
-
export default class DemoComponent extends Component {
|
|
33
|
-
@tracked value = '';
|
|
34
|
-
|
|
35
|
-
@action setValue(value) {
|
|
36
|
-
this.value = value;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
```
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
order: 1
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
# Usage
|
|
6
|
-
|
|
7
|
-
```hbs template
|
|
8
|
-
<FormRadioGroup
|
|
9
|
-
@label="Grouped radio buttons"
|
|
10
|
-
@value={{this.value}}
|
|
11
|
-
@onChange={{this.setValue}}
|
|
12
|
-
@errors={{this.validationErrors}}
|
|
13
|
-
as |Radio|
|
|
14
|
-
>
|
|
15
|
-
<Radio @value={{true}} @label="Yes" />
|
|
16
|
-
<Radio @value={{false}} @label="No" />
|
|
17
|
-
<Radio @value="maybe" @label="Maybe" />
|
|
18
|
-
</FormRadioGroup>
|
|
19
|
-
|
|
20
|
-
<p class="mt-4">Selected Value: "{{this.value}}"</p>
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
```js component
|
|
24
|
-
import Component from '@glimmer/component';
|
|
25
|
-
import { tracked } from '@glimmer/tracking';
|
|
26
|
-
import { action } from '@ember/object';
|
|
27
|
-
|
|
28
|
-
export default class DemoComponent extends Component {
|
|
29
|
-
@tracked value = '';
|
|
30
|
-
|
|
31
|
-
get validationErrors() {
|
|
32
|
-
if (this.value === 'maybe') {
|
|
33
|
-
return ['You cannot select maybe as an option'];
|
|
34
|
-
} else {
|
|
35
|
-
return [];
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
@action setValue(value) {
|
|
40
|
-
this.value = value;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
```
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
<FormField
|
|
2
|
-
@size={{@size}}
|
|
3
|
-
class={{use-frontile-class "form-radio-group" @size (if @isInline "inline") class=@containerClass}}
|
|
4
|
-
role="radiogroup"
|
|
5
|
-
...attributes
|
|
6
|
-
as |f|
|
|
7
|
-
>
|
|
8
|
-
{{#if @label}}
|
|
9
|
-
<f.Label
|
|
10
|
-
class={{use-frontile-class "form-radio-group" @size (if @isInline "inline") part="label"}}
|
|
11
|
-
>
|
|
12
|
-
{{@label}}
|
|
13
|
-
</f.Label>
|
|
14
|
-
{{/if}}
|
|
15
|
-
|
|
16
|
-
{{#if @hint}}
|
|
17
|
-
<f.Hint
|
|
18
|
-
class={{use-frontile-class "form-radio-group" @size (if @isInline "inline") part="hint"}}
|
|
19
|
-
>
|
|
20
|
-
{{@hint}}
|
|
21
|
-
</f.Hint>
|
|
22
|
-
{{/if}}
|
|
23
|
-
|
|
24
|
-
{{yield (component "form-radio"
|
|
25
|
-
checked=@value
|
|
26
|
-
privateContainerClass=(use-frontile-class "form-radio-group" @size (if @isInline "inline") part="form-radio")
|
|
27
|
-
_parentOnChange=this.handleChange
|
|
28
|
-
size=@size
|
|
29
|
-
name=(concat f.id "-radio-group")
|
|
30
|
-
)
|
|
31
|
-
}}
|
|
32
|
-
|
|
33
|
-
{{#if this.showErrorFeedback}}
|
|
34
|
-
<f.Feedback
|
|
35
|
-
class={{use-frontile-class "form-radio-group" @size (if @isInline "inline") part="feedback"}}
|
|
36
|
-
@errors={{@errors}}
|
|
37
|
-
/>
|
|
38
|
-
{{/if}}
|
|
39
|
-
</FormField>
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import Component from '@glimmer/component';
|
|
2
|
-
import { action } from '@ember/object';
|
|
3
|
-
import { tracked } from '@glimmer/tracking';
|
|
4
|
-
import FormRadio from './form-radio';
|
|
5
|
-
|
|
6
|
-
export interface FormRadioGroupArgs {
|
|
7
|
-
value: unknown;
|
|
8
|
-
/** The group label */
|
|
9
|
-
label?: string;
|
|
10
|
-
/** A help text to be displayed */
|
|
11
|
-
hint?: string;
|
|
12
|
-
/** If the form has been submitted, used to force displaying errors */
|
|
13
|
-
hasSubmitted?: boolean;
|
|
14
|
-
/** If has errors */
|
|
15
|
-
hasError?: boolean;
|
|
16
|
-
/** Force displaying errors */
|
|
17
|
-
showError?: boolean;
|
|
18
|
-
/** A list of errors or a single text describing the error */
|
|
19
|
-
errors?: string[] | string;
|
|
20
|
-
/** CSS classes to be added in the container element */
|
|
21
|
-
containerClass?: string;
|
|
22
|
-
/** The size */
|
|
23
|
-
size?: 'sm' | 'lg';
|
|
24
|
-
/** If the Checkbox should be in one line */
|
|
25
|
-
isInline?: boolean;
|
|
26
|
-
|
|
27
|
-
/** Default callback added to the yielded FormRadio component, called when onchange is triggered */
|
|
28
|
-
onChange?: (value: unknown, event: Event) => void;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export interface FormRadioGroupSignature {
|
|
32
|
-
Args: FormRadioGroupArgs;
|
|
33
|
-
Blocks: {
|
|
34
|
-
default: [radio: FormRadio];
|
|
35
|
-
};
|
|
36
|
-
Element: HTMLDivElement;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export default class FormRadioGroup extends Component<FormRadioGroupSignature> {
|
|
40
|
-
@tracked shouldShowErrorFeedback = false;
|
|
41
|
-
|
|
42
|
-
get showErrorFeedback(): boolean {
|
|
43
|
-
if (this.args.hasError === false) {
|
|
44
|
-
return false;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
if (
|
|
48
|
-
(this.args.showError ||
|
|
49
|
-
this.args.hasSubmitted ||
|
|
50
|
-
this.shouldShowErrorFeedback) &&
|
|
51
|
-
this.args.errors &&
|
|
52
|
-
this.args.errors.length > 0
|
|
53
|
-
) {
|
|
54
|
-
return true;
|
|
55
|
-
} else {
|
|
56
|
-
return false;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
@action handleChange(value: unknown, event: Event): void {
|
|
61
|
-
this.shouldShowErrorFeedback = true;
|
|
62
|
-
|
|
63
|
-
if (typeof this.args.onChange === 'function') {
|
|
64
|
-
this.args.onChange(value, event);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
<FormField
|
|
2
|
-
@size={{@size}}
|
|
3
|
-
class={{
|
|
4
|
-
use-frontile-class
|
|
5
|
-
"form-radio"
|
|
6
|
-
@size
|
|
7
|
-
class=(array @containerClass @privateContainerClass)
|
|
8
|
-
}} as |f|
|
|
9
|
-
>
|
|
10
|
-
<div class={{use-frontile-class "form-radio" @size part="label-container"}}>
|
|
11
|
-
<div class={{use-frontile-class "form-radio" @size part="input-container"}}>
|
|
12
|
-
{{! Zero-width space character, used to align checkbox properly }}
|
|
13
|
-
|
|
14
|
-
<f.Radio
|
|
15
|
-
@onChange={{this.handleChange}}
|
|
16
|
-
@value={{@value}}
|
|
17
|
-
@checked={{@checked}}
|
|
18
|
-
@name={{@name}}
|
|
19
|
-
class={{use-frontile-class "form-radio" @size part="radio"}}
|
|
20
|
-
aria-describedby={{if @hint f.hintId}}
|
|
21
|
-
...attributes
|
|
22
|
-
/>
|
|
23
|
-
</div>
|
|
24
|
-
|
|
25
|
-
<f.Label class={{use-frontile-class "form-radio" @size part="label"}}>
|
|
26
|
-
{{#if (has-block)}}
|
|
27
|
-
{{yield}}
|
|
28
|
-
{{else}}
|
|
29
|
-
{{@label}}
|
|
30
|
-
{{/if}}
|
|
31
|
-
</f.Label>
|
|
32
|
-
</div>
|
|
33
|
-
|
|
34
|
-
{{#if @hint}}
|
|
35
|
-
<f.Hint class={{use-frontile-class "form-radio" @size part="hint"}}>
|
|
36
|
-
{{@hint}}
|
|
37
|
-
</f.Hint>
|
|
38
|
-
{{/if}}
|
|
39
|
-
</FormField>
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import Component from '@glimmer/component';
|
|
2
|
-
import { action } from '@ember/object';
|
|
3
|
-
|
|
4
|
-
export interface FormRadioArgs {
|
|
5
|
-
/** The input field label */
|
|
6
|
-
label?: string;
|
|
7
|
-
/** A help text to be displayed */
|
|
8
|
-
hint?: string;
|
|
9
|
-
/**
|
|
10
|
-
* The value to be used in the radio button.
|
|
11
|
-
* You must also pass `onChange` to update its value.
|
|
12
|
-
*/
|
|
13
|
-
value: unknown;
|
|
14
|
-
/**
|
|
15
|
-
* The current checked value.
|
|
16
|
-
* This will be used to compare against the `value` argument,
|
|
17
|
-
* if equal, the radio will me marked as checked.
|
|
18
|
-
*/
|
|
19
|
-
checked: unknown;
|
|
20
|
-
/** The name of the checkbox */
|
|
21
|
-
name?: string;
|
|
22
|
-
/** CSS classes to be added in the container element */
|
|
23
|
-
containerClass?: string;
|
|
24
|
-
/** The size */
|
|
25
|
-
size?: 'sm' | 'lg';
|
|
26
|
-
/** Callback when onchange is triggered */
|
|
27
|
-
onChange: (value: unknown, event: Event) => void;
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Internal function for InputRadioGroup
|
|
31
|
-
* @ignore
|
|
32
|
-
**/
|
|
33
|
-
_parentOnChange?: (value: unknown, event: Event) => void;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export interface FormRadioSignature {
|
|
37
|
-
Args: FormRadioArgs;
|
|
38
|
-
Element: HTMLInputElement;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export default class FormRadio extends Component<FormRadioSignature> {
|
|
42
|
-
@action handleChange(value: unknown, event: Event): void {
|
|
43
|
-
event.preventDefault();
|
|
44
|
-
|
|
45
|
-
if (typeof this.args.onChange === 'function') {
|
|
46
|
-
this.args.onChange(value, event);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
if (typeof this.args._parentOnChange === 'function') {
|
|
50
|
-
this.args._parentOnChange(value, event);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
order: 2
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
# Multiple Select
|
|
6
|
-
|
|
7
|
-
In example you can select multiple options. To enable multiple select,
|
|
8
|
-
just pass `@isMultiple={{true}}` to the component.
|
|
9
|
-
|
|
10
|
-
```hbs template
|
|
11
|
-
<FormSelect
|
|
12
|
-
@isMultiple={{true}}
|
|
13
|
-
@hint="Select all countries you have lived"
|
|
14
|
-
@errors={{this.countryErrors}}
|
|
15
|
-
@allowClear={{true}}
|
|
16
|
-
@label="Countries"
|
|
17
|
-
@options={{this.countries}}
|
|
18
|
-
@selected={{this.selectedCountries}}
|
|
19
|
-
@onChange={{this.setCountry}}
|
|
20
|
-
as |country|
|
|
21
|
-
>
|
|
22
|
-
{{country}}
|
|
23
|
-
</FormSelect>
|
|
24
|
-
|
|
25
|
-
<p class="mt-4">
|
|
26
|
-
You selected, "{{this.selectedCountries}}"
|
|
27
|
-
</p>
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
```js component
|
|
31
|
-
import Component from '@glimmer/component';
|
|
32
|
-
import { tracked } from '@glimmer/tracking';
|
|
33
|
-
import { action } from '@ember/object';
|
|
34
|
-
|
|
35
|
-
export default class DemoComponent extends Component {
|
|
36
|
-
@tracked selectedCountries;
|
|
37
|
-
|
|
38
|
-
countries = [
|
|
39
|
-
'United States',
|
|
40
|
-
'Spain',
|
|
41
|
-
'Portugal',
|
|
42
|
-
'Russia',
|
|
43
|
-
'Latvia',
|
|
44
|
-
'Brazil',
|
|
45
|
-
'United Kingdom'
|
|
46
|
-
];
|
|
47
|
-
|
|
48
|
-
get countryErrors() {
|
|
49
|
-
if (this.selectedCountries && this.selectedCountries.length > 0) {
|
|
50
|
-
return [];
|
|
51
|
-
} else {
|
|
52
|
-
return ["Countries can't be blank"];
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
@action setCountry(value) {
|
|
57
|
-
this.selectedCountries = value;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
```
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
order: 1
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
# Usage
|
|
6
|
-
|
|
7
|
-
Single Select.
|
|
8
|
-
|
|
9
|
-
```hbs template
|
|
10
|
-
<FormSelect
|
|
11
|
-
@hint="Select your country of residence"
|
|
12
|
-
@errors={{this.countryErrors}}
|
|
13
|
-
@allowClear={{true}}
|
|
14
|
-
@label="Country"
|
|
15
|
-
@searchEnabled={{true}}
|
|
16
|
-
@searchField="name"
|
|
17
|
-
@options={{this.countries}}
|
|
18
|
-
@selected={{this.country}}
|
|
19
|
-
@onChange={{this.setCountry}}
|
|
20
|
-
as |country|
|
|
21
|
-
>
|
|
22
|
-
{{country.name}}
|
|
23
|
-
</FormSelect>
|
|
24
|
-
|
|
25
|
-
<p class="mt-4">
|
|
26
|
-
You selected, "{{this.country.name}}"
|
|
27
|
-
</p>
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
```js component
|
|
31
|
-
import Component from '@glimmer/component';
|
|
32
|
-
import { tracked } from '@glimmer/tracking';
|
|
33
|
-
import { action } from '@ember/object';
|
|
34
|
-
|
|
35
|
-
export default class DemoComponent extends Component {
|
|
36
|
-
@tracked country;
|
|
37
|
-
|
|
38
|
-
countries = [
|
|
39
|
-
{ name: 'United States', code: 'US' },
|
|
40
|
-
{ name: 'Spain', code: 'ES' },
|
|
41
|
-
{ name: 'Portugal', code: 'PT', disabled: true },
|
|
42
|
-
{ name: 'Russia', code: 'RU', disabled: true },
|
|
43
|
-
{ name: 'Latvia', code: 'LV' },
|
|
44
|
-
{ name: 'Brazil', code: 'BR' },
|
|
45
|
-
{ name: 'United Kingdom', code: 'GB' }
|
|
46
|
-
];
|
|
47
|
-
|
|
48
|
-
get countryErrors() {
|
|
49
|
-
if (this.country) {
|
|
50
|
-
return [];
|
|
51
|
-
} else {
|
|
52
|
-
return ["Country can't be blank"];
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
@action setCountry(value) {
|
|
57
|
-
this.country = value;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
```
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
<FormField
|
|
2
|
-
@size={{@size}}
|
|
3
|
-
class={{use-frontile-class "form-select" @size class=@containerClass}} as |f|
|
|
4
|
-
>
|
|
5
|
-
{{#if @label}}
|
|
6
|
-
<f.Label
|
|
7
|
-
@for={{false}}
|
|
8
|
-
id={{f.id}}
|
|
9
|
-
class={{use-frontile-class "form-select" @size part="label"}}
|
|
10
|
-
>
|
|
11
|
-
{{@label}}
|
|
12
|
-
</f.Label>
|
|
13
|
-
{{/if}}
|
|
14
|
-
|
|
15
|
-
{{#if @hint}}
|
|
16
|
-
<f.Hint class={{use-frontile-class "form-select" @size part="hint"}}>
|
|
17
|
-
{{@hint}}
|
|
18
|
-
</f.Hint>
|
|
19
|
-
{{/if}}
|
|
20
|
-
|
|
21
|
-
{{#let
|
|
22
|
-
(if
|
|
23
|
-
@isMultiple (component "power-select-multiple") (component "power-select")
|
|
24
|
-
) as |Component|
|
|
25
|
-
}}
|
|
26
|
-
<Component
|
|
27
|
-
...attributes
|
|
28
|
-
@onChange={{this.handleChange}}
|
|
29
|
-
@onFocus={{this.handleFocusIn}}
|
|
30
|
-
@onBlur={{this.handleFocusOut}}
|
|
31
|
-
@onOpen={{this.handleOpen}}
|
|
32
|
-
@onClose={{this.handleClose}}
|
|
33
|
-
@ariaDescribedBy="{{if @hint f.hintId}}{{
|
|
34
|
-
if this.showErrorFeedback (concat " " f.feedbackId)
|
|
35
|
-
}}{{if @ariaDescribedBy (concat " " @ariaDescribedBy)}}"
|
|
36
|
-
@ariaLabelledBy="{{if @label f.id}}{{
|
|
37
|
-
if @ariaLabelledBy (concat " " @ariaLabelledBy)
|
|
38
|
-
}}"
|
|
39
|
-
@ariaInvalid={{if this.showErrorFeedback "true"}}
|
|
40
|
-
@triggerClass="{{@triggerClass}} {{
|
|
41
|
-
if @size (concat "ember-power-select-trigger-" @size)
|
|
42
|
-
}} {{use-frontile-class "form-select" @size part="select"}}"
|
|
43
|
-
@highlightOnHover={{@highlightOnHover}}
|
|
44
|
-
@placeholderComponent={{@placeholderComponent}}
|
|
45
|
-
@searchMessage={{@searchMessage}}
|
|
46
|
-
@noMatchesMessage={{@noMatchesMessage}}
|
|
47
|
-
@matchTriggerWidth={{@matchTriggerWidth}}
|
|
48
|
-
@options={{@options}}
|
|
49
|
-
@selected={{@selected}}
|
|
50
|
-
@closeOnSelect={{@closeOnSelect}}
|
|
51
|
-
@defaultHighlighted={{@defaultHighlighted}}
|
|
52
|
-
@searchField={{@searchField}}
|
|
53
|
-
@searchEnabled={{@searchEnabled}}
|
|
54
|
-
@tabindex={{@tabindex}}
|
|
55
|
-
@triggerComponent={{@triggerComponent}}
|
|
56
|
-
@matcher={{@matcher}}
|
|
57
|
-
@initiallyOpened={{@initiallyOpened}}
|
|
58
|
-
@typeAheadOptionMatcher={{@typeAheadOptionMatcher}}
|
|
59
|
-
@buildSelection={{@buildSelection}}
|
|
60
|
-
@search={{@search}}
|
|
61
|
-
@onInput={{@onInput}}
|
|
62
|
-
@onKeydown={{@onKeydown}}
|
|
63
|
-
@scrollTo={{@scrollTo}}
|
|
64
|
-
@registerAPI={{@registerAPI}}
|
|
65
|
-
@horizontalPosition={{@horizontalPosition}}
|
|
66
|
-
@destination={{@destination}}
|
|
67
|
-
@preventScroll={{@preventScroll}}
|
|
68
|
-
@renderInPlace={{@renderInPlace}}
|
|
69
|
-
@verticalPosition={{@verticalPosition}}
|
|
70
|
-
@disabled={{@disabled}}
|
|
71
|
-
@calculatePosition={{@calculatePosition}}
|
|
72
|
-
@eventType={{@eventType}}
|
|
73
|
-
@ariaLabel={{@ariaLabel}}
|
|
74
|
-
@required={{@required}}
|
|
75
|
-
@triggerRole={{@triggerRole}}
|
|
76
|
-
@title={{@title}}
|
|
77
|
-
@triggerId={{@triggerId}}
|
|
78
|
-
@allowClear={{@allowClear}}
|
|
79
|
-
@loadingMessage={{@loadingMessage}}
|
|
80
|
-
@selectedItemComponent={{@selectedItemComponent}}
|
|
81
|
-
@dropdownClass={{@dropdownClass}}
|
|
82
|
-
@beforeOptionsComponent={{@beforeOptionsComponent}}
|
|
83
|
-
@placeholder={{@placeholder}}
|
|
84
|
-
@searchPlaceholder={{@searchPlaceholder}}
|
|
85
|
-
@searchMessageComponent={{@searchMessageComponent}}
|
|
86
|
-
@optionsComponent={{@optionsComponent}}
|
|
87
|
-
@extra={{@extra}}
|
|
88
|
-
@groupComponent={{@groupComponent}}
|
|
89
|
-
@afterOptionsComponent={{@afterOptionsComponent}} as |option term|
|
|
90
|
-
>
|
|
91
|
-
{{yield option term}}
|
|
92
|
-
</Component>
|
|
93
|
-
{{/let}}
|
|
94
|
-
|
|
95
|
-
{{#if this.showErrorFeedback}}
|
|
96
|
-
<f.Feedback
|
|
97
|
-
class={{use-frontile-class "form-select" @size part="feedback"}}
|
|
98
|
-
@errors={{@errors}}
|
|
99
|
-
/>
|
|
100
|
-
{{/if}}
|
|
101
|
-
</FormField>
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
# FormSelect
|
|
2
|
-
|
|
3
|
-
We use [Ember Power Select](https://github.com/cibernox/ember-power-select/)
|
|
4
|
-
under the hood to deliver the best select experience. Please refer to their
|
|
5
|
-
documentation for further customization.
|
|
6
|
-
|
|
7
|
-
In the example below, we have a label, hint, error validation, search and `allowClear`.
|
|
8
|
-
|
|
9
|
-
## API
|
|
10
|
-
|
|
11
|
-
<ArgsTable @of="FormSelect" />
|