@frontile/changeset-form 0.15.0 → 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 (90) hide show
  1. package/addon-main.js +4 -0
  2. package/{components → declarations/components}/changeset-form/fields/base.d.ts +5 -9
  3. package/declarations/components/changeset-form/fields/base.d.ts.map +1 -0
  4. package/{components → declarations/components}/changeset-form/fields/checkbox-group.d.ts +9 -4
  5. package/declarations/components/changeset-form/fields/checkbox-group.d.ts.map +1 -0
  6. package/{components → declarations/components}/changeset-form/fields/checkbox.d.ts +11 -5
  7. package/declarations/components/changeset-form/fields/checkbox.d.ts.map +1 -0
  8. package/declarations/components/changeset-form/fields/input.d.ts +16 -0
  9. package/declarations/components/changeset-form/fields/input.d.ts.map +1 -0
  10. package/declarations/components/changeset-form/fields/radio-group.d.ts +18 -0
  11. package/declarations/components/changeset-form/fields/radio-group.d.ts.map +1 -0
  12. package/declarations/components/changeset-form/fields/radio.d.ts +16 -0
  13. package/declarations/components/changeset-form/fields/radio.d.ts.map +1 -0
  14. package/{components → declarations/components}/changeset-form/fields/select.d.ts +6 -5
  15. package/declarations/components/changeset-form/fields/select.d.ts.map +1 -0
  16. package/{components → declarations/components}/changeset-form/fields/textarea.d.ts +9 -3
  17. package/declarations/components/changeset-form/fields/textarea.d.ts.map +1 -0
  18. package/{components → declarations/components}/changeset-form/index.d.ts +10 -8
  19. package/declarations/components/changeset-form/index.d.ts.map +1 -0
  20. package/declarations/template-registry.d.ts +19 -0
  21. package/declarations/template-registry.d.ts.map +1 -0
  22. package/dist/_app_/components/changeset-form/fields/base.js +1 -0
  23. package/dist/_app_/components/changeset-form/fields/checkbox-group.js +1 -0
  24. package/dist/_app_/components/changeset-form/fields/checkbox.js +1 -0
  25. package/dist/_app_/components/changeset-form/fields/input.js +1 -0
  26. package/dist/_app_/components/changeset-form/fields/radio-group.js +1 -0
  27. package/dist/_app_/components/changeset-form/fields/radio.js +1 -0
  28. package/dist/_app_/components/changeset-form/fields/select.js +1 -0
  29. package/dist/_app_/components/changeset-form/fields/textarea.js +1 -0
  30. package/dist/_app_/components/changeset-form/index.js +1 -0
  31. package/dist/components/changeset-form/fields/base.js +47 -0
  32. package/dist/components/changeset-form/fields/base.js.map +1 -0
  33. package/dist/components/changeset-form/fields/checkbox-group.js +58 -0
  34. package/dist/components/changeset-form/fields/checkbox-group.js.map +1 -0
  35. package/dist/components/changeset-form/fields/checkbox.js +59 -0
  36. package/dist/components/changeset-form/fields/checkbox.js.map +1 -0
  37. package/dist/components/changeset-form/fields/input.js +26 -0
  38. package/dist/components/changeset-form/fields/input.js.map +1 -0
  39. package/dist/components/changeset-form/fields/radio-group.js +26 -0
  40. package/dist/components/changeset-form/fields/radio-group.js.map +1 -0
  41. package/dist/components/changeset-form/fields/radio.js +28 -0
  42. package/dist/components/changeset-form/fields/radio.js.map +1 -0
  43. package/dist/components/changeset-form/fields/select.js +37 -0
  44. package/dist/components/changeset-form/fields/select.js.map +1 -0
  45. package/dist/components/changeset-form/fields/textarea.js +27 -0
  46. package/dist/components/changeset-form/fields/textarea.js.map +1 -0
  47. package/dist/components/changeset-form/index.js +85 -0
  48. package/dist/components/changeset-form/index.js.map +1 -0
  49. package/dist/template-registry.js +2 -0
  50. package/dist/template-registry.js.map +1 -0
  51. package/package.json +80 -49
  52. package/addon/components/changeset-form/fields/base.ts +0 -75
  53. package/addon/components/changeset-form/fields/checkbox-group.hbs +0 -24
  54. package/addon/components/changeset-form/fields/checkbox-group.ts +0 -68
  55. package/addon/components/changeset-form/fields/checkbox.hbs +0 -15
  56. package/addon/components/changeset-form/fields/checkbox.ts +0 -60
  57. package/addon/components/changeset-form/fields/input.hbs +0 -23
  58. package/addon/components/changeset-form/fields/input.ts +0 -20
  59. package/addon/components/changeset-form/fields/radio-group.hbs +0 -19
  60. package/addon/components/changeset-form/fields/radio-group.ts +0 -29
  61. package/addon/components/changeset-form/fields/radio.hbs +0 -17
  62. package/addon/components/changeset-form/fields/radio.ts +0 -25
  63. package/addon/components/changeset-form/fields/select.hbs +0 -70
  64. package/addon/components/changeset-form/fields/select.ts +0 -51
  65. package/addon/components/changeset-form/fields/textarea.hbs +0 -23
  66. package/addon/components/changeset-form/fields/textarea.ts +0 -20
  67. package/addon/components/changeset-form/index.hbs +0 -55
  68. package/addon/components/changeset-form/index.ts +0 -116
  69. package/app/components/changeset-form/fields/checkbox-group.js +0 -1
  70. package/app/components/changeset-form/fields/checkbox.js +0 -1
  71. package/app/components/changeset-form/fields/input.js +0 -1
  72. package/app/components/changeset-form/fields/radio-group.js +0 -1
  73. package/app/components/changeset-form/fields/radio.js +0 -1
  74. package/app/components/changeset-form/fields/select.js +0 -1
  75. package/app/components/changeset-form/fields/textarea.js +0 -1
  76. package/app/components/changeset-form.js +0 -1
  77. package/components/changeset-form/fields/input.d.ts +0 -10
  78. package/components/changeset-form/fields/radio-group.d.ts +0 -15
  79. package/components/changeset-form/fields/radio.d.ts +0 -11
  80. package/config/environment.js +0 -5
  81. package/docs/changeset-form-usage-demo/demo.md +0 -124
  82. package/docs/changeset-form-usage.md +0 -134
  83. package/index.js +0 -5
  84. package/tsconfig.json +0 -24
  85. package/types/dummy/index.d.ts +0 -0
  86. package/types/ember-changeset-validations.d.ts +0 -56
  87. package/types/ember-get-config.d.ts +0 -3
  88. package/types/ember-power-select/test-support.d.ts +0 -29
  89. package/types/global.d.ts +0 -6
  90. package/types/index.d.ts +0 -1
@@ -1,60 +0,0 @@
1
- import Base, { BaseArgs, BaseSignature, ValidationError } from './base';
2
- import { action } from '@ember/object';
3
-
4
- export interface ChangesetFormFieldsCheckboxArgs extends BaseArgs {
5
- _groupName?: string;
6
- _parentOnChange?: (value: unknown, event: Event) => void;
7
-
8
- onChange?: (value: unknown, event: Event) => void;
9
- }
10
-
11
- export interface ChangesetFormFieldsCheckboxSignature extends BaseSignature {
12
- Args: ChangesetFormFieldsCheckboxArgs;
13
- }
14
-
15
- export default class ChangesetFormFieldsCheckbox extends Base<ChangesetFormFieldsCheckboxSignature> {
16
- get fullFieldName(): string {
17
- return this.args._groupName
18
- ? `${this.args._groupName}.${this.args.fieldName}`
19
- : this.args.fieldName;
20
- }
21
-
22
- get value(): unknown {
23
- return this.args.changeset.get(this.fullFieldName);
24
- }
25
-
26
- get errors(): string[] {
27
- if (typeof this.args.errors !== 'undefined') {
28
- return this.args.errors;
29
- }
30
-
31
- const fieldErrors = this.args.changeset.errors.filter((error) => {
32
- return error.key === this.fullFieldName;
33
- });
34
-
35
- return fieldErrors.reduce(
36
- (errors: string[], error: ValidationError): string[] => {
37
- return [...errors, ...error.validation];
38
- },
39
- []
40
- );
41
- }
42
-
43
- @action async validate(): Promise<void> {
44
- await this.args.changeset.validate(this.fullFieldName);
45
- }
46
-
47
- @action async handleChange(value: unknown, event: Event): Promise<void> {
48
- this.args.changeset.set(this.fullFieldName, value);
49
-
50
- await this.validate();
51
-
52
- if (typeof this.args._parentOnChange === 'function') {
53
- this.args._parentOnChange(value, event);
54
- }
55
-
56
- if (typeof this.args.onChange === 'function') {
57
- this.args.onChange(value, event);
58
- }
59
- }
60
- }
@@ -1,23 +0,0 @@
1
- <FormInput
2
- {{on "blur" this.validate}}
3
-
4
- @value={{this.value}}
5
- @onInput={{this.handleInput}}
6
- @errors={{this.errors}}
7
-
8
- @hasSubmitted={{@hasSubmitted}}
9
- @type={{@type}}
10
- @label={{@label}}
11
- @hint={{@hint}}
12
- @hasError={{@hasError}}
13
- @showError={{@showError}}
14
- @containerClass={{@containerClass}}
15
- @size={{@size}}
16
- @onChange={{@onChange}}
17
- @onFocusIn={{@onFocusIn}}
18
- @onFocusOut={{@onFocusOut}}
19
-
20
- ...attributes
21
- >
22
- {{yield}}
23
- </FormInput>
@@ -1,20 +0,0 @@
1
- import Base, { BaseArgs, BaseSignature } from './base';
2
- import { action } from '@ember/object';
3
-
4
- export interface ChangesetFormFieldsInputArgs extends BaseArgs {
5
- onInput?: (value: string, event: InputEvent) => void;
6
- }
7
-
8
- export interface ChangesetFormFieldsInputSignature extends BaseSignature {
9
- Args: ChangesetFormFieldsInputArgs;
10
- }
11
-
12
- export default class ChangesetFormFieldsInput extends Base<ChangesetFormFieldsInputSignature> {
13
- @action handleInput(value: string, event: InputEvent): void {
14
- this.args.changeset.set(this.args.fieldName, value);
15
-
16
- if (typeof this.args.onInput === 'function') {
17
- this.args.onInput(value, event);
18
- }
19
- }
20
- }
@@ -1,19 +0,0 @@
1
- <FormRadioGroup
2
- @onChange={{this.handleChange}}
3
- @value={{this.value}}
4
- @errors={{this.errors}}
5
-
6
- @label={{@label}}
7
- @hint={{@hint}}
8
- @hasSubmitted={{@hasSubmitted}}
9
- @hasError={{@hasError}}
10
- @showError={{@showError}}
11
- @containerClass={{@containerClass}}
12
- @size={{@size}}
13
- @isInline={{@isInline}}
14
-
15
- ...attributes
16
- as |Radio|
17
- >
18
- {{yield Radio}}
19
- </FormRadioGroup>
@@ -1,29 +0,0 @@
1
- import Base, { BaseArgs, BaseSignature } from './base';
2
- import { action } from '@ember/object';
3
- import FormRadio from '@frontile/forms/addon/components/form-radio';
4
-
5
- export interface ChangesetFormFieldsRadioGroupArgs extends BaseArgs {
6
- onChange?: (value: unknown, event: Event) => void;
7
- }
8
-
9
- export interface ChangesetFormFieldsRadioGroupSignature extends BaseSignature {
10
- Args: ChangesetFormFieldsRadioGroupArgs;
11
- Blocks: {
12
- default: [radio: FormRadio];
13
- };
14
- Element: HTMLDivElement;
15
- }
16
-
17
- export default class ChangesetFormFieldsRadioGroup extends Base<ChangesetFormFieldsRadioGroupSignature> {
18
- @action
19
- async handleChange(value: unknown, event: Event): Promise<void> {
20
- event.preventDefault();
21
-
22
- this.args.changeset.set(this.args.fieldName, value);
23
- await this.validate();
24
-
25
- if (typeof this.args.onChange === 'function') {
26
- this.args.onChange(value, event);
27
- }
28
- }
29
- }
@@ -1,17 +0,0 @@
1
- <FormRadio
2
- @onChange={{this.handleChange}}
3
- @checked={{this.value}}
4
- @hint={{@hint}}
5
- @value={{@value}}
6
- @name={{@name}}
7
- @containerClass={{@containerClass}}
8
- @size={{@size}}
9
- ...attributes
10
- {{on "blur" this.validate}}
11
- >
12
- {{#if (has-block)}}
13
- {{yield}}
14
- {{else}}
15
- {{@label}}
16
- {{/if}}
17
- </FormRadio>
@@ -1,25 +0,0 @@
1
- import Base, { BaseArgs, BaseSignature } from './base';
2
- import { action } from '@ember/object';
3
-
4
- export interface ChangesetFormFieldsRadioArgs extends BaseArgs {
5
- onChange?: (value: unknown, event: Event) => void;
6
- }
7
-
8
- export interface ChangesetFormFieldsRadioSignature extends BaseSignature {
9
- Args: ChangesetFormFieldsRadioArgs;
10
- Element: HTMLInputElement;
11
- }
12
-
13
- export default class ChangesetFormFieldsRadio extends Base<ChangesetFormFieldsRadioSignature> {
14
- @action
15
- async handleChange(value: unknown, event: Event): Promise<void> {
16
- event.preventDefault();
17
-
18
- this.args.changeset.set(this.args.fieldName, value);
19
- await this.validate();
20
-
21
- if (typeof this.args.onChange === 'function') {
22
- this.args.onChange(value, event);
23
- }
24
- }
25
- }
@@ -1,70 +0,0 @@
1
- <FormSelect
2
- @selected={{this.value}}
3
- @onChange={{this.handleChange}}
4
- @onFocusOut={{this.handleFocusOut}}
5
- @onClose={{this.handleClose}}
6
- @errors={{this.errors}}
7
- @hasSubmitted={{@hasSubmitted}}
8
- @isMultiple={{@isMultiple}}
9
- @label={{@label}}
10
- @hint={{@hint}}
11
- @hasError={{@hasError}}
12
- @showError={{@showError}}
13
- @containerClass={{@containerClass}}
14
- @size={{@size}}
15
- @onFocusIn={{@onFocusIn}}
16
- @onFocus={{@onFocus}}
17
- @onBlur={{@onBlur}}
18
- @onOpen={{@onOpen}}
19
- @triggerClass={{@triggerClass}}
20
- @highlightOnHover={{@highlightOnHover}}
21
- @placeholderComponent={{@placeholderComponent}}
22
- @searchMessage={{@searchMessage}}
23
- @noMatchesMessage={{@noMatchesMessage}}
24
- @matchTriggerWidth={{@matchTriggerWidth}}
25
- @options={{@options}}
26
- @closeOnSelect={{@closeOnSelect}}
27
- @defaultHighlighted={{@defaultHighlighted}}
28
- @searchField={{@searchField}}
29
- @searchEnabled={{@searchEnabled}}
30
- @tabindex={{@tabindex}}
31
- @triggerComponent={{@triggerComponent}}
32
- @matcher={{@matcher}}
33
- @initiallyOpened={{@initiallyOpened}}
34
- @typeAheadOptionMatcher={{@typeAheadOptionMatcher}}
35
- @buildSelection={{@buildSelection}}
36
- @search={{@search}}
37
- @onInput={{@onInput}}
38
- @onKeydown={{@onKeydown}}
39
- @scrollTo={{@scrollTo}}
40
- @registerAPI={{@registerAPI}}
41
- @horizontalPosition={{@horizontalPosition}}
42
- @destination={{@destination}}
43
- @preventScroll={{@preventScroll}}
44
- @renderInPlace={{@renderInPlace}}
45
- @verticalPosition={{@verticalPosition}}
46
- @disabled={{@disabled}}
47
- @calculatePosition={{@calculatePosition}}
48
- @eventType={{@eventType}}
49
- @ariaLabel={{@ariaLabel}}
50
- @required={{@required}}
51
- @triggerRole={{@triggerRole}}
52
- @title={{@title}}
53
- @triggerId={{@triggerId}}
54
- @allowClear={{@allowClear}}
55
- @loadingMessage={{@loadingMessage}}
56
- @selectedItemComponent={{@selectedItemComponent}}
57
- @dropdownClass={{@dropdownClass}}
58
- @beforeOptionsComponent={{@beforeOptionsComponent}}
59
- @placeholder={{@placeholder}}
60
- @searchPlaceholder={{@searchPlaceholder}}
61
- @searchMessageComponent={{@searchMessageComponent}}
62
- @optionsComponent={{@optionsComponent}}
63
- @extra={{@extra}}
64
- @groupComponent={{@groupComponent}}
65
- @afterOptionsComponent={{@afterOptionsComponent}}
66
- ...attributes
67
- as |option term|
68
- >
69
- {{yield option term}}
70
- </FormSelect>
@@ -1,51 +0,0 @@
1
- import Base, { BaseArgs, BaseSignature } from './base';
2
- import { action } from '@ember/object';
3
- import { Select } from 'ember-power-select/addon/components/power-select';
4
-
5
- export interface ChangesetFormFieldsSelectArgs extends BaseArgs {
6
- onChange?: (selection: unknown, select: Select, event?: Event) => void;
7
- onFocusOut?: (select: Select, event: FocusEvent) => void;
8
- onClose?: (select: Select, event: Event) => void;
9
- }
10
-
11
- export interface ChangesetFormFieldsSelectSignature extends BaseSignature {
12
- Args: ChangesetFormFieldsSelectArgs;
13
- Blocks: {
14
- default: [option: unknown, select: Select];
15
- };
16
- Element: HTMLDivElement;
17
- }
18
-
19
- export default class ChangesetFormFieldsSelect extends Base<ChangesetFormFieldsSelectSignature> {
20
- @action
21
- async handleChange(
22
- selection: unknown,
23
- select: Select,
24
- event?: Event
25
- ): Promise<void> {
26
- this.args.changeset.set(this.args.fieldName, selection);
27
- await this.validate();
28
-
29
- if (typeof this.args.onChange === 'function') {
30
- this.args.onChange(selection, select, event);
31
- }
32
- }
33
-
34
- @action
35
- async handleFocusOut(select: Select, event: FocusEvent): Promise<void> {
36
- await this.validate();
37
-
38
- if (typeof this.args.onFocusOut === 'function') {
39
- this.args.onFocusOut(select, event);
40
- }
41
- }
42
-
43
- @action
44
- async handleClose(select: Select, event: Event): Promise<void> {
45
- await this.validate();
46
-
47
- if (typeof this.args.onClose === 'function') {
48
- this.args.onClose(select, event);
49
- }
50
- }
51
- }
@@ -1,23 +0,0 @@
1
- <FormTextarea
2
- {{on "blur" this.validate}}
3
-
4
- @value={{this.value}}
5
- @onInput={{this.handleInput}}
6
- @errors={{this.errors}}
7
-
8
- @hasSubmitted={{@hasSubmitted}}
9
- @type={{@type}}
10
- @label={{@label}}
11
- @hint={{@hint}}
12
- @hasError={{@hasError}}
13
- @showError={{@showError}}
14
- @containerClass={{@containerClass}}
15
- @size={{@size}}
16
- @onChange={{@onChange}}
17
- @onFocusIn={{@onFocusIn}}
18
- @onFocusOut={{@onFocusOut}}
19
-
20
- ...attributes
21
- >
22
- {{yield}}
23
- </FormTextarea>
@@ -1,20 +0,0 @@
1
- import Base, { BaseArgs, BaseSignature } from './base';
2
- import { action } from '@ember/object';
3
-
4
- export interface ChangesetFormFieldsTextareaArgs extends BaseArgs {
5
- onInput?: (value: string, event: InputEvent) => void;
6
- }
7
-
8
- export interface ChangesetFormFieldsTextareaSignature extends BaseSignature {
9
- Args: ChangesetFormFieldsTextareaArgs;
10
- }
11
-
12
- export default class ChangesetFormFieldsTextarea extends Base<ChangesetFormFieldsTextareaSignature> {
13
- @action handleInput(value: string, event: InputEvent): void {
14
- this.args.changeset.set(this.args.fieldName, value);
15
-
16
- if (typeof this.args.onInput === 'function') {
17
- this.args.onInput(value, event);
18
- }
19
- }
20
- }
@@ -1,55 +0,0 @@
1
- <form
2
- ...attributes
3
- {{on "submit" (fn this.handleSubmit @changeset)}}
4
- {{on "reset" (fn this.handleReset @changeset)}}
5
- >
6
-
7
- {{yield
8
- (hash
9
- Input=(component
10
- "changeset-form/fields/input"
11
- changeset=@changeset
12
- hasSubmitted=this.hasSubmitted
13
- showError=@alwaysShowErrors
14
- )
15
- Textarea=(component
16
- "changeset-form/fields/textarea"
17
- changeset=@changeset
18
- hasSubmitted=this.hasSubmitted
19
- showError=@alwaysShowErrors
20
- )
21
- Select=(component
22
- "changeset-form/fields/select"
23
- changeset=@changeset
24
- hasSubmitted=this.hasSubmitted
25
- showError=@alwaysShowErrors
26
- )
27
- Checkbox=(component
28
- "changeset-form/fields/checkbox"
29
- changeset=@changeset
30
- hasSubmitted=this.hasSubmitted
31
- showError=@alwaysShowErrors
32
- )
33
- CheckboxGroup=(component
34
- "changeset-form/fields/checkbox-group"
35
- changeset=@changeset
36
- hasSubmitted=this.hasSubmitted
37
- showError=@alwaysShowErrors
38
- )
39
- Radio=(component
40
- "changeset-form/fields/radio"
41
- changeset=@changeset
42
- hasSubmitted=this.hasSubmitted
43
- showError=@alwaysShowErrors
44
- )
45
- RadioGroup=(component
46
- "changeset-form/fields/radio-group"
47
- changeset=@changeset
48
- hasSubmitted=this.hasSubmitted
49
- showError=@alwaysShowErrors
50
- )
51
- state=(hash hasSubmitted=this.hasSubmitted)
52
- )
53
- }}
54
-
55
- </form>
@@ -1,116 +0,0 @@
1
- import Component from '@glimmer/component';
2
- import { tracked } from '@glimmer/tracking';
3
- import { BufferedChangeset } from 'ember-changeset/types';
4
- import { action } from '@ember/object';
5
- import { assert } from '@ember/debug';
6
- import { next } from '@ember/runloop';
7
- import ChangesetFormFieldsInput from './fields/input';
8
- import ChangesetFormFieldsTextarea from './fields/textarea';
9
- import ChangesetFormFieldsSelect from './fields/select';
10
- import ChangesetFormFieldsCheckbox from './fields/checkbox';
11
- import ChangesetFormFieldsCheckboxGroup from './fields/checkbox-group';
12
- import ChangesetFormFieldsRadio from './fields/radio';
13
- import ChangesetFormFieldsRadioGroup from './fields/radio-group';
14
-
15
- export interface ChangesetFormArgs {
16
- /** Changeset Object */
17
- changeset: BufferedChangeset;
18
-
19
- /**
20
- * Run Changeset execute method instead of save
21
- * @defaultValue false
22
- * */
23
- runExecuteInsteadOfSave?: boolean;
24
-
25
- /**
26
- * Always show errors if there are any
27
- * @defaultValue false
28
- */
29
- alwaysShowErrors?: boolean;
30
-
31
- /**
32
- * Validate the changeset on initialization
33
- * @defaultValue false
34
- */
35
- validateOnInit?: boolean;
36
-
37
- /** Callback executed when from `onsubmit` event is triggered */
38
- onSubmit?: (data: unknown, event: Event) => void;
39
-
40
- /** Callback executed when from `onreset` event is triggered */
41
- onReset?: (data: unknown, event: Event) => void;
42
- }
43
-
44
- export interface ChangesetFormSignature {
45
- Args: ChangesetFormArgs;
46
- Blocks: {
47
- default: [
48
- {
49
- Input: ChangesetFormFieldsInput;
50
- Textarea: ChangesetFormFieldsTextarea;
51
- Select: ChangesetFormFieldsSelect;
52
- Checkbox: ChangesetFormFieldsCheckbox;
53
- CheckboxGroup: ChangesetFormFieldsCheckboxGroup;
54
- Radio: ChangesetFormFieldsRadio;
55
- RadioGroup: ChangesetFormFieldsRadioGroup;
56
- state: { hasSubmitted: boolean };
57
- }
58
- ];
59
- };
60
- Element: HTMLFormElement;
61
- }
62
-
63
- export default class ChangesetForm extends Component<ChangesetFormSignature> {
64
- @tracked hasSubmitted = false;
65
-
66
- constructor(owner: unknown, args: ChangesetFormArgs) {
67
- super(owner, args);
68
- assert(
69
- '@changeset must be defined on <ChangesetForm> component',
70
- this.args.changeset
71
- );
72
-
73
- if (this.args.validateOnInit) {
74
- next(() => {
75
- this.args.changeset.validate();
76
- });
77
- }
78
- }
79
-
80
- @action
81
- async handleSubmit(
82
- changeset: BufferedChangeset,
83
- event: Event
84
- ): Promise<void> {
85
- event.preventDefault();
86
- await changeset.validate();
87
-
88
- this.hasSubmitted = true;
89
-
90
- if (changeset.isInvalid) {
91
- return;
92
- }
93
-
94
- let result;
95
- if (this.args.runExecuteInsteadOfSave) {
96
- result = changeset.execute();
97
- } else {
98
- result = await changeset.save({});
99
- }
100
-
101
- if (typeof this.args.onSubmit === 'function') {
102
- this.args.onSubmit(result.data, event);
103
- }
104
- }
105
-
106
- @action
107
- handleReset(changeset: BufferedChangeset, event: Event): void {
108
- event.preventDefault();
109
- this.hasSubmitted = false;
110
-
111
- const { data } = changeset.rollback();
112
- if (typeof this.args.onReset === 'function') {
113
- this.args.onReset(data, event);
114
- }
115
- }
116
- }
@@ -1 +0,0 @@
1
- export { default } from '@frontile/changeset-form/components/changeset-form/fields/checkbox-group';
@@ -1 +0,0 @@
1
- export { default } from '@frontile/changeset-form/components/changeset-form/fields/checkbox';
@@ -1 +0,0 @@
1
- export { default } from '@frontile/changeset-form/components/changeset-form/fields/input';
@@ -1 +0,0 @@
1
- export { default } from '@frontile/changeset-form/components/changeset-form/fields/radio-group';
@@ -1 +0,0 @@
1
- export { default } from '@frontile/changeset-form/components/changeset-form/fields/radio';
@@ -1 +0,0 @@
1
- export { default } from '@frontile/changeset-form/components/changeset-form/fields/select';
@@ -1 +0,0 @@
1
- export { default } from '@frontile/changeset-form/components/changeset-form/fields/textarea';
@@ -1 +0,0 @@
1
- export { default } from '@frontile/changeset-form/components/changeset-form';
@@ -1,10 +0,0 @@
1
- import Base, { BaseArgs, BaseSignature } from './base';
2
- export interface ChangesetFormFieldsInputArgs extends BaseArgs {
3
- onInput?: (value: string, event: InputEvent) => void;
4
- }
5
- export interface ChangesetFormFieldsInputSignature extends BaseSignature {
6
- Args: ChangesetFormFieldsInputArgs;
7
- }
8
- export default class ChangesetFormFieldsInput extends Base<ChangesetFormFieldsInputSignature> {
9
- handleInput(value: string, event: InputEvent): void;
10
- }
@@ -1,15 +0,0 @@
1
- import Base, { BaseArgs, BaseSignature } from './base';
2
- import FormRadio from '@frontile/forms/addon/components/form-radio';
3
- export interface ChangesetFormFieldsRadioGroupArgs extends BaseArgs {
4
- onChange?: (value: unknown, event: Event) => void;
5
- }
6
- export interface ChangesetFormFieldsRadioGroupSignature extends BaseSignature {
7
- Args: ChangesetFormFieldsRadioGroupArgs;
8
- Blocks: {
9
- default: [radio: FormRadio];
10
- };
11
- Element: HTMLDivElement;
12
- }
13
- export default class ChangesetFormFieldsRadioGroup extends Base<ChangesetFormFieldsRadioGroupSignature> {
14
- handleChange(value: unknown, event: Event): Promise<void>;
15
- }
@@ -1,11 +0,0 @@
1
- import Base, { BaseArgs, BaseSignature } from './base';
2
- export interface ChangesetFormFieldsRadioArgs extends BaseArgs {
3
- onChange?: (value: unknown, event: Event) => void;
4
- }
5
- export interface ChangesetFormFieldsRadioSignature extends BaseSignature {
6
- Args: ChangesetFormFieldsRadioArgs;
7
- Element: HTMLInputElement;
8
- }
9
- export default class ChangesetFormFieldsRadio extends Base<ChangesetFormFieldsRadioSignature> {
10
- handleChange(value: unknown, event: Event): Promise<void>;
11
- }
@@ -1,5 +0,0 @@
1
- 'use strict';
2
-
3
- module.exports = function (/* environment, appConfig */) {
4
- return {};
5
- };