@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.
Files changed (152) hide show
  1. package/addon-main.js +37 -0
  2. package/{components → declarations/components}/form-checkbox-group.d.ts +3 -1
  3. package/declarations/components/form-checkbox-group.d.ts.map +1 -0
  4. package/{components → declarations/components}/form-checkbox.d.ts +9 -0
  5. package/declarations/components/form-checkbox.d.ts.map +1 -0
  6. package/{components → declarations/components}/form-field/checkbox.d.ts +2 -0
  7. package/declarations/components/form-field/checkbox.d.ts.map +1 -0
  8. package/{components → declarations/components}/form-field/feedback.d.ts +5 -0
  9. package/declarations/components/form-field/feedback.d.ts.map +1 -0
  10. package/{components → declarations/components}/form-field/hint.d.ts +4 -0
  11. package/declarations/components/form-field/hint.d.ts.map +1 -0
  12. package/{components → declarations/components}/form-field/input.d.ts +4 -2
  13. package/declarations/components/form-field/input.d.ts.map +1 -0
  14. package/{components → declarations/components}/form-field/label.d.ts +4 -0
  15. package/declarations/components/form-field/label.d.ts.map +1 -0
  16. package/{components → declarations/components}/form-field/radio.d.ts +3 -1
  17. package/declarations/components/form-field/radio.d.ts.map +1 -0
  18. package/{components → declarations/components}/form-field/textarea.d.ts +4 -2
  19. package/declarations/components/form-field/textarea.d.ts.map +1 -0
  20. package/declarations/components/form-field.d.ts +38 -0
  21. package/declarations/components/form-field.d.ts.map +1 -0
  22. package/{components → declarations/components}/form-input.d.ts +5 -1
  23. package/declarations/components/form-input.d.ts.map +1 -0
  24. package/{components → declarations/components}/form-radio-group.d.ts +6 -2
  25. package/declarations/components/form-radio-group.d.ts.map +1 -0
  26. package/{components → declarations/components}/form-radio.d.ts +9 -1
  27. package/declarations/components/form-radio.d.ts.map +1 -0
  28. package/{components → declarations/components}/form-select.d.ts +6 -2
  29. package/declarations/components/form-select.d.ts.map +1 -0
  30. package/{components → declarations/components}/form-textarea.d.ts +5 -1
  31. package/declarations/components/form-textarea.d.ts.map +1 -0
  32. package/declarations/template-registry.d.ts +33 -0
  33. package/declarations/template-registry.d.ts.map +1 -0
  34. package/dist/_app_/components/form-checkbox-group.js +1 -0
  35. package/dist/_app_/components/form-checkbox.js +1 -0
  36. package/dist/_app_/components/form-field/checkbox.js +1 -0
  37. package/dist/_app_/components/form-field/feedback.js +1 -0
  38. package/dist/_app_/components/form-field/hint.js +1 -0
  39. package/dist/_app_/components/form-field/input.js +1 -0
  40. package/dist/_app_/components/form-field/label.js +1 -0
  41. package/dist/_app_/components/form-field/radio.js +1 -0
  42. package/dist/_app_/components/form-field/textarea.js +1 -0
  43. package/dist/_app_/components/form-field.js +1 -0
  44. package/dist/_app_/components/form-input.js +1 -0
  45. package/dist/_app_/components/form-radio-group.js +1 -0
  46. package/dist/_app_/components/form-radio.js +1 -0
  47. package/dist/_app_/components/form-select.js +1 -0
  48. package/dist/_app_/components/form-textarea.js +1 -0
  49. package/dist/components/form-checkbox-group.js +55 -0
  50. package/dist/components/form-checkbox-group.js.map +1 -0
  51. package/dist/components/form-checkbox.js +30 -0
  52. package/dist/components/form-checkbox.js.map +1 -0
  53. package/dist/components/form-field/checkbox.js +30 -0
  54. package/dist/components/form-field/checkbox.js.map +1 -0
  55. package/dist/components/form-field/feedback.js +29 -0
  56. package/dist/components/form-field/feedback.js.map +1 -0
  57. package/dist/components/form-field/hint.js +17 -0
  58. package/dist/components/form-field/hint.js.map +1 -0
  59. package/dist/components/form-field/input.js +36 -0
  60. package/dist/components/form-field/input.js.map +1 -0
  61. package/dist/components/form-field/label.js +17 -0
  62. package/dist/components/form-field/label.js.map +1 -0
  63. package/dist/components/form-field/radio.js +29 -0
  64. package/dist/components/form-field/radio.js.map +1 -0
  65. package/dist/components/form-field/textarea.js +30 -0
  66. package/dist/components/form-field/textarea.js.map +1 -0
  67. package/dist/components/form-field.js +44 -0
  68. package/dist/components/form-field.js.map +1 -0
  69. package/dist/components/form-input.js +64 -0
  70. package/dist/components/form-input.js.map +1 -0
  71. package/dist/components/form-radio-group.js +55 -0
  72. package/dist/components/form-radio-group.js.map +1 -0
  73. package/dist/components/form-radio.js +34 -0
  74. package/dist/components/form-radio.js.map +1 -0
  75. package/dist/components/form-select.js +102 -0
  76. package/dist/components/form-select.js.map +1 -0
  77. package/dist/components/form-textarea.js +23 -0
  78. package/dist/components/form-textarea.js.map +1 -0
  79. package/dist/template-registry.js +2 -0
  80. package/dist/template-registry.js.map +1 -0
  81. package/package.json +95 -63
  82. package/addon/components/form-checkbox-demo/usage.md +0 -30
  83. package/addon/components/form-checkbox-group-demo/usage.md +0 -54
  84. package/addon/components/form-checkbox-group.hbs +0 -38
  85. package/addon/components/form-checkbox-group.md +0 -5
  86. package/addon/components/form-checkbox-group.ts +0 -68
  87. package/addon/components/form-checkbox.hbs +0 -42
  88. package/addon/components/form-checkbox.md +0 -5
  89. package/addon/components/form-checkbox.ts +0 -45
  90. package/addon/components/form-field/checkbox.hbs +0 -10
  91. package/addon/components/form-field/checkbox.ts +0 -32
  92. package/addon/components/form-field/feedback.hbs +0 -10
  93. package/addon/components/form-field/feedback.ts +0 -30
  94. package/addon/components/form-field/hint.hbs +0 -8
  95. package/addon/components/form-field/hint.ts +0 -13
  96. package/addon/components/form-field/index.hbs +0 -20
  97. package/addon/components/form-field/index.ts +0 -46
  98. package/addon/components/form-field/input.hbs +0 -10
  99. package/addon/components/form-field/input.ts +0 -40
  100. package/addon/components/form-field/label.hbs +0 -8
  101. package/addon/components/form-field/label.ts +0 -13
  102. package/addon/components/form-field/radio.hbs +0 -11
  103. package/addon/components/form-field/radio.ts +0 -31
  104. package/addon/components/form-field/textarea.hbs +0 -10
  105. package/addon/components/form-field/textarea.ts +0 -32
  106. package/addon/components/form-input-demo/hint.md +0 -34
  107. package/addon/components/form-input-demo/no-label.md +0 -33
  108. package/addon/components/form-input-demo/simple.md +0 -42
  109. package/addon/components/form-input-demo/with-button.md +0 -60
  110. package/addon/components/form-input.hbs +0 -45
  111. package/addon/components/form-input.md +0 -5
  112. package/addon/components/form-input.ts +0 -96
  113. package/addon/components/form-radio-demo/usage.md +0 -39
  114. package/addon/components/form-radio-group-demo/usage.md +0 -43
  115. package/addon/components/form-radio-group.hbs +0 -39
  116. package/addon/components/form-radio-group.md +0 -5
  117. package/addon/components/form-radio-group.ts +0 -67
  118. package/addon/components/form-radio.hbs +0 -39
  119. package/addon/components/form-radio.md +0 -5
  120. package/addon/components/form-radio.ts +0 -53
  121. package/addon/components/form-select-demo/multiple.md +0 -60
  122. package/addon/components/form-select-demo/usage.md +0 -60
  123. package/addon/components/form-select.hbs +0 -101
  124. package/addon/components/form-select.md +0 -11
  125. package/addon/components/form-select.ts +0 -126
  126. package/addon/components/form-textarea-demo/usage.md +0 -40
  127. package/addon/components/form-textarea.hbs +0 -44
  128. package/addon/components/form-textarea.md +0 -5
  129. package/addon/components/form-textarea.ts +0 -7
  130. package/app/components/form-checkbox-group.js +0 -1
  131. package/app/components/form-checkbox.js +0 -1
  132. package/app/components/form-field/checkbox.js +0 -1
  133. package/app/components/form-field/feedback.js +0 -1
  134. package/app/components/form-field/hint.js +0 -1
  135. package/app/components/form-field/index.js +0 -1
  136. package/app/components/form-field/input.js +0 -1
  137. package/app/components/form-field/label.js +0 -1
  138. package/app/components/form-field/radio.js +0 -1
  139. package/app/components/form-field/textarea.js +0 -1
  140. package/app/components/form-input.js +0 -1
  141. package/app/components/form-radio-group.js +0 -1
  142. package/app/components/form-radio.js +0 -1
  143. package/app/components/form-select.js +0 -1
  144. package/app/components/form-textarea.js +0 -1
  145. package/components/form-field/index.d.ts +0 -36
  146. package/config/environment.js +0 -5
  147. package/index.js +0 -34
  148. package/tsconfig.json +0 -23
  149. package/types/dummy/index.d.ts +0 -0
  150. package/types/ember-get-config.d.ts +0 -3
  151. package/types/ember-power-select/test-support.d.ts +0 -29
  152. package/types/global.d.ts +0 -6
@@ -1,45 +0,0 @@
1
- import Component from '@glimmer/component';
2
- import { action } from '@ember/object';
3
-
4
- export interface FormCheckboxArgs {
5
- /** The input field label */
6
- label?: string;
7
- /** A help text to be displayed */
8
- hint?: string;
9
- /**
10
- * If the checkbox is checked.
11
- * You must also pass `onChange` to update its value.
12
- */
13
- checked: boolean;
14
- /** The name of the checkbox */
15
- name?: string;
16
- /** CSS classes to be added in the container element */
17
- containerClass?: string;
18
- /** The size */
19
- size?: 'sm' | 'lg';
20
- /** Callback when onchange is triggered */
21
- onChange: (value: boolean, event: Event) => void;
22
-
23
- /**
24
- * Internal function for InputCheckboxGroup
25
- * @ignore
26
- **/
27
- _parentOnChange?: (value: boolean, event: Event) => void;
28
- }
29
-
30
- export interface FormCheckboxSignature {
31
- Args: FormCheckboxArgs;
32
- Element: HTMLInputElement;
33
- }
34
-
35
- export default class FormCheckbox extends Component<FormCheckboxSignature> {
36
- @action handleChange(value: boolean, event: Event): void {
37
- if (typeof this.args.onChange === 'function') {
38
- this.args.onChange(value, event);
39
- }
40
-
41
- if (typeof this.args._parentOnChange === 'function') {
42
- this.args._parentOnChange(value, event);
43
- }
44
- }
45
- }
@@ -1,10 +0,0 @@
1
- <input
2
- {{on "change" this.handleChange}}
3
- id={{@id}}
4
- name={{@name}}
5
- checked={{this.isChecked}}
6
- type="checkbox"
7
- class={{use-frontile-class "form-field-checkbox" @size}}
8
- data-test-id="form-field-checkbox"
9
- ...attributes
10
- >
@@ -1,32 +0,0 @@
1
- import Component from '@glimmer/component';
2
- import { action } from '@ember/object';
3
-
4
- export interface FormFieldCheckboxArgs {
5
- checked?: boolean;
6
- name?: string;
7
- size?: 'sm' | 'lg';
8
-
9
- // Callback when onchange is triggered
10
- onChange?: (value: boolean, event: Event) => void;
11
- }
12
-
13
- export interface FormFieldCheckboxSignature {
14
- Args: FormFieldCheckboxArgs;
15
- Element: HTMLInputElement;
16
- }
17
-
18
- export default class FormFieldCheckbox extends Component<FormFieldCheckboxSignature> {
19
- get isChecked(): boolean {
20
- return !!this.args.checked;
21
- }
22
-
23
- @action handleChange(event: Event): void {
24
- event.preventDefault();
25
-
26
- const value = !this.args.checked;
27
-
28
- if (typeof this.args.onChange === 'function') {
29
- this.args.onChange(value, event);
30
- }
31
- }
32
- }
@@ -1,10 +0,0 @@
1
- <div
2
- id={{@id}}
3
- class={{use-frontile-class "form-field-feedback" @size (if this.isError "error")}}
4
- data-test-id="form-field-feedback"
5
- aria-live={{if this.isError "assertive" "polite"}}
6
- ...attributes
7
- >
8
- {{this.errorMessage}}
9
- {{yield}}
10
- </div>
@@ -1,30 +0,0 @@
1
- import Component from '@glimmer/component';
2
-
3
- export interface FormFieldFeedbackArgs {
4
- isError?: boolean;
5
- errors?: string[] | string;
6
- size?: 'sm' | 'lg';
7
- }
8
-
9
- export interface FormFieldFeedbackSignature {
10
- Args: FormFieldFeedbackArgs;
11
- Element: HTMLDivElement;
12
- }
13
-
14
- export default class FormFieldFeedback extends Component<FormFieldFeedbackSignature> {
15
- get isError(): boolean {
16
- return (
17
- typeof this.args.errors !== 'undefined' || this.args.isError === true
18
- );
19
- }
20
-
21
- get errorMessage(): string {
22
- if (!this.args.errors) return '';
23
-
24
- if (typeof this.args.errors === 'string') {
25
- return this.args.errors;
26
- } else {
27
- return this.args.errors.join('; ');
28
- }
29
- }
30
- }
@@ -1,8 +0,0 @@
1
- <div
2
- id={{@id}}
3
- class={{use-frontile-class "form-field-hint" @size}}
4
- data-test-id="form-field-hint"
5
- ...attributes
6
- >
7
- {{yield}}
8
- </div>
@@ -1,13 +0,0 @@
1
- import Component from '@glimmer/component';
2
-
3
- export interface FormFieldHintArgs {
4
- id?: string;
5
- size?: 'sm' | 'lg';
6
- }
7
-
8
- export interface FormFieldHintSignature {
9
- Args: FormFieldHintArgs;
10
- Element: HTMLDivElement;
11
- }
12
-
13
- export default class FormFieldHint extends Component<FormFieldHintSignature> {}
@@ -1,20 +0,0 @@
1
- <div
2
- ...attributes
3
- >
4
- {{yield
5
- (hash
6
- id=this.id
7
- hintId=this.hintId
8
- feedbackId=this.feedbackId
9
-
10
- Label=(component "form-field/label" for=this.id size=@size)
11
- Hint=(component "form-field/hint" id=this.hintId size=@size)
12
- Feedback=(component "form-field/feedback" id=this.feedbackId size=@size)
13
-
14
- Input=(component "form-field/input" id=this.id size=@size)
15
- Textarea=(component "form-field/textarea" id=this.id size=@size)
16
- Checkbox=(component "form-field/checkbox" id=this.id size=@size)
17
- Radio=(component "form-field/radio" id=this.id size=@size)
18
- )
19
- }}
20
- </div>
@@ -1,46 +0,0 @@
1
- import Component from '@glimmer/component';
2
- import { guidFor } from '@ember/object/internals';
3
- import FormFieldCheckbox from './checkbox';
4
- import FormFieldFeedback from './feedback';
5
- import FormFieldHint from './hint';
6
- import FormFieldInput from './input';
7
- import FormFieldLabel from './label';
8
- import FormFieldRadio from './radio';
9
- import FormFieldTextarea from './textarea';
10
-
11
- export interface FormFieldArgs {
12
- size?: 'sm' | 'lg';
13
- }
14
-
15
- export interface FormFieldSignature {
16
- Args: FormFieldArgs;
17
- Blocks: {
18
- default: [
19
- {
20
- id: string;
21
- hintId: string;
22
- feedbackId: string;
23
- Label: FormFieldLabel;
24
- Hint: FormFieldHint;
25
- Feedback: FormFieldFeedback;
26
- Input: FormFieldInput;
27
- Textarea: FormFieldTextarea;
28
- Checkbox: FormFieldCheckbox;
29
- Radio: FormFieldRadio;
30
- }
31
- ];
32
- };
33
- Element: HTMLDivElement;
34
- }
35
-
36
- export default class FormField extends Component<FormFieldSignature> {
37
- id = guidFor(this);
38
-
39
- get hintId(): string {
40
- return this.id + '-hint';
41
- }
42
-
43
- get feedbackId(): string {
44
- return this.id + '-feedback';
45
- }
46
- }
@@ -1,10 +0,0 @@
1
- <input
2
- {{on "input" this.handleOnInput}}
3
- {{on "change" this.handleOnChange}}
4
- id={{@id}}
5
- value={{@value}}
6
- type={{this.type}}
7
- class={{use-frontile-class "form-field-input" @size}}
8
- data-test-id="form-field-input"
9
- ...attributes
10
- >
@@ -1,40 +0,0 @@
1
- import Component from '@glimmer/component';
2
- import { action } from '@ember/object';
3
-
4
- export interface FormFieldInputArgs {
5
- id?: string;
6
- type?: string;
7
- size?: 'sm' | 'lg';
8
-
9
- // Callback when oninput is triggered
10
- onInput?: (value: string, event: InputEvent) => void;
11
-
12
- // Callback when onchange is triggered
13
- onChange?: (value: string, event: InputEvent) => void;
14
- }
15
-
16
- export interface FormFieldInputSignature {
17
- Args: FormFieldInputArgs;
18
- Element: HTMLInputElement;
19
- }
20
-
21
- export default class FormFieldInput extends Component<FormFieldInputSignature> {
22
- get type(): string {
23
- if (typeof this.args.type === 'string') {
24
- return this.args.type;
25
- }
26
- return 'text';
27
- }
28
-
29
- @action handleOnInput(event: InputEvent): void {
30
- if (typeof this.args.onInput === 'function') {
31
- this.args.onInput((event.target as HTMLInputElement).value, event);
32
- }
33
- }
34
-
35
- @action handleOnChange(event: InputEvent): void {
36
- if (typeof this.args.onChange === 'function') {
37
- this.args.onChange((event.target as HTMLInputElement).value, event);
38
- }
39
- }
40
- }
@@ -1,8 +0,0 @@
1
- <label
2
- for={{@for}}
3
- class={{use-frontile-class "form-field-label" @size}}
4
- data-test-id="form-field-label"
5
- ...attributes
6
- >
7
- {{yield}}
8
- </label>
@@ -1,13 +0,0 @@
1
- import Component from '@glimmer/component';
2
-
3
- export interface FormFieldLabelArgs {
4
- for?: string;
5
- size?: 'sm' | 'lg';
6
- }
7
-
8
- export interface FormFieldLabelSignature {
9
- Args: FormFieldLabelArgs;
10
- Element: HTMLLabelElement;
11
- }
12
-
13
- export default class FormFieldLabel extends Component<FormFieldLabelSignature> {}
@@ -1,11 +0,0 @@
1
- <input
2
- {{on "change" this.handleChange}}
3
- id={{@id}}
4
- name={{@name}}
5
- value={{@value}}
6
- checked={{this.isChecked}}
7
- type="radio"
8
- class={{use-frontile-class "form-field-radio" @size}}
9
- data-test-id="form-field-radio"
10
- ...attributes
11
- >
@@ -1,31 +0,0 @@
1
- import Component from '@glimmer/component';
2
- import { action } from '@ember/object';
3
-
4
- export interface FormFieldRadioArgs {
5
- value?: unknown;
6
- checked?: unknown;
7
- name?: string;
8
- size?: 'sm' | 'lg';
9
-
10
- // Callback when onchange is triggered
11
- onChange?: (value: unknown, event: Event) => void;
12
- }
13
-
14
- export interface FormFieldRadioSignature {
15
- Args: FormFieldRadioArgs;
16
- Element: HTMLInputElement;
17
- }
18
-
19
- export default class FormFieldRadio extends Component<FormFieldRadioSignature> {
20
- get isChecked(): boolean {
21
- return this.args.checked === this.args.value;
22
- }
23
-
24
- @action handleChange(event: Event): void {
25
- event.preventDefault();
26
-
27
- if (typeof this.args.onChange === 'function') {
28
- this.args.onChange(this.args.value, event);
29
- }
30
- }
31
- }
@@ -1,10 +0,0 @@
1
- <textarea
2
- {{on "input" this.handleOnInput}}
3
- {{on "change" this.handleOnChange}}
4
- id={{@id}}
5
- value={{@value}}
6
- class={{use-frontile-class "form-field-textarea" @size}}
7
- data-test-id="form-field-textarea"
8
- ...attributes
9
- >
10
- </textarea>
@@ -1,32 +0,0 @@
1
- import Component from '@glimmer/component';
2
- import { action } from '@ember/object';
3
-
4
- export interface FormFieldTextareaArgs {
5
- id?: string;
6
- size?: 'sm' | 'lg';
7
-
8
- // Callback when oninput is triggered
9
- onInput?: (value: string, event: InputEvent) => void;
10
-
11
- // Callback when onchange is triggered
12
- onChange?: (value: string, event: InputEvent) => void;
13
- }
14
-
15
- export interface FormFieldTextareaSignature {
16
- Args: FormFieldTextareaArgs;
17
- Element: HTMLTextAreaElement;
18
- }
19
-
20
- export default class FormFieldTextarea extends Component<FormFieldTextareaSignature> {
21
- @action handleOnInput(event: InputEvent): void {
22
- if (typeof this.args.onInput === 'function') {
23
- this.args.onInput((event.target as HTMLInputElement).value, event);
24
- }
25
- }
26
-
27
- @action handleOnChange(event: InputEvent): void {
28
- if (typeof this.args.onChange === 'function') {
29
- this.args.onChange((event.target as HTMLInputElement).value, event);
30
- }
31
- }
32
- }
@@ -1,34 +0,0 @@
1
- ---
2
- order: 3
3
- ---
4
-
5
- # Input with Hint
6
-
7
- You can pass `@hint` to the component to add hint content.
8
-
9
- ```hbs template
10
- <FormInput
11
- @label="I have Hint"
12
- @hint="InputText support optional hints"
13
- @value={{this.value}}
14
- @onInput={{this.setValue}}
15
- />
16
-
17
- <p class="mt-4">
18
- You typed, "{{this.value}}"
19
- </p>
20
- ```
21
-
22
- ```js component
23
- import Component from '@glimmer/component';
24
- import { tracked } from '@glimmer/tracking';
25
- import { action } from '@ember/object';
26
-
27
- export default class DemoComponent extends Component {
28
- @tracked value = '';
29
-
30
- @action setValue(value) {
31
- this.value = value;
32
- }
33
- }
34
- ```
@@ -1,33 +0,0 @@
1
- ---
2
- order: 2
3
- ---
4
-
5
- # No Label
6
-
7
- If you don't want the label then simply leave it out of the component tag:
8
-
9
- ```hbs template
10
- <FormInput
11
- @value={{this.value}}
12
- @onInput={{this.setValue}}
13
- placeholder="I have no label"
14
- />
15
-
16
- <p class="mt-4">
17
- You typed, "{{this.value}}"
18
- </p>
19
- ```
20
-
21
- ```js component
22
- import Component from '@glimmer/component';
23
- import { tracked } from '@glimmer/tracking';
24
- import { action } from '@ember/object';
25
-
26
- export default class DemoComponent extends Component {
27
- @tracked value = '';
28
-
29
- @action setValue(value) {
30
- this.value = value;
31
- }
32
- }
33
- ```
@@ -1,42 +0,0 @@
1
- ---
2
- order: 1
3
- ---
4
-
5
- # Standard usage
6
-
7
- The most common use case is a plain text input with validation:
8
-
9
- ```hbs template
10
- <FormInput
11
- @label="First Name"
12
- @value={{this.value}}
13
- @onInput={{this.setValue}}
14
- @errors={{this.validationErrors}}
15
- />
16
-
17
- <p class="mt-4">
18
- You typed, "{{this.value}}"
19
- </p>
20
- ```
21
-
22
- ```js component
23
- import Component from '@glimmer/component';
24
- import { tracked } from '@glimmer/tracking';
25
- import { action } from '@ember/object';
26
-
27
- export default class DemoComponent extends Component {
28
- @tracked value = '';
29
-
30
- get validationErrors() {
31
- if (/^$/.test(this.value)) {
32
- return ['Please enter First Name'];
33
- } else {
34
- return [];
35
- }
36
- }
37
-
38
- @action setValue(value) {
39
- this.value = value;
40
- }
41
- }
42
- ```
@@ -1,60 +0,0 @@
1
- ---
2
- order: 4
3
- ---
4
-
5
- # Input with Button
6
-
7
- This is an example of how to implement an input with a button next to it.
8
-
9
- ```hbs template
10
- <FormInput
11
- @value={{this.value}}
12
- @onInput={{this.setValue}}
13
- @label="Referral Code"
14
- @errors={{this.validationErrors}}
15
- @onChange={{this.validate}}
16
- placeholder="Input your URL or 6 Digit referral code"
17
- class="rounded-r-none"
18
- >
19
- <button
20
- type="button"
21
- {{on "click" this.validate}}
22
- class="px-4 py-2 border text-gray-100 rounded-r
23
- {{if this.isValid "bg-green-800 border-green-800 hover:bg-green-700" "bg-teal-600 border-teal-600 hover:bg-teal-700"}}"
24
- >
25
- {{#if this.isValid}}
26
- <span>
27
- Code Applied
28
- </span>
29
- {{else}}
30
- Apply
31
- {{/if}}
32
- </button>
33
- </FormInput>
34
- ```
35
-
36
- ```js component
37
- import Component from '@glimmer/component';
38
- import { tracked } from '@glimmer/tracking';
39
- import { action } from '@ember/object';
40
-
41
- export default class DemoComponent extends Component {
42
- @tracked value = '';
43
- @tracked validationErrors = [];
44
- @tracked isValid = false;
45
-
46
- @action setValue(value) {
47
- this.value = value;
48
- }
49
-
50
- @action validate() {
51
- if (/^$/.test(this.value)) {
52
- this.validationErrors = ['Incorrect Code Applied'];
53
- this.isValid = false;
54
- } else {
55
- this.validationErrors = [];
56
- this.isValid = true;
57
- }
58
- }
59
- }
60
- ```
@@ -1,45 +0,0 @@
1
- <FormField
2
- @size={{@size}}
3
- class={{use-frontile-class "form-input" @size class=@containerClass}}
4
- as |f|
5
- >
6
- {{#if @label}}
7
- <f.Label
8
- class={{use-frontile-class "form-input" @size part="label"}}
9
- >
10
- {{@label}}
11
- </f.Label>
12
- {{/if}}
13
-
14
- {{#if @hint}}
15
- <f.Hint
16
- class={{use-frontile-class "form-input" @size part="hint"}}
17
- >
18
- {{@hint}}
19
- </f.Hint>
20
- {{/if}}
21
-
22
- <f.Input
23
- {{on "focus" this.handleFocusIn}}
24
- {{on "blur" this.handleFocusOut}}
25
-
26
- @onInput={{@onInput}}
27
- @onChange={{@onChange}}
28
- @value={{@value}}
29
- @type={{@type}}
30
-
31
- class={{use-frontile-class "form-input" @size part="input"}}
32
- aria-invalid={{if this.showErrorFeedback "true"}}
33
- aria-describedby="{{if @hint f.hintId}}{{if this.showErrorFeedback (concat " " f.feedbackId)}}"
34
- ...attributes
35
- />
36
-
37
- {{yield}}
38
-
39
- {{#if this.showErrorFeedback}}
40
- <f.Feedback
41
- class={{use-frontile-class "form-input" @size part="feedback"}}
42
- @errors={{@errors}}
43
- />
44
- {{/if}}
45
- </FormField>
@@ -1,5 +0,0 @@
1
- # FormInput
2
-
3
- ## API
4
-
5
- <ArgsTable @of="FormInput" />