@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,124 +0,0 @@
1
- ---
2
- order: 1
3
- ---
4
-
5
- # Complete Form
6
-
7
- This shows how to have a complete form using `ChangesetForm`.
8
-
9
- ```hbs template
10
- {{#let (changeset this.model this.validations) as |changeset|}}
11
- <ChangesetForm @changeset={{changeset}} as |Form|>
12
- <Form.Input
13
- @label='First Name'
14
- @fieldName='firstName'
15
- placeholder='What is your first name?'
16
- />
17
- <Form.Input
18
- @label='Last Name'
19
- @fieldName='lastName'
20
- @containerClass='mt-4'
21
- placeholder='What is your family name?'
22
- />
23
- <Form.Input
24
- @label='Email Address'
25
- @fieldName='email'
26
- type='email'
27
- @containerClass='mt-4'
28
- />
29
- <Form.Textarea
30
- @label='Comments'
31
- @fieldName='comments'
32
- @containerClass='mt-4'
33
- />
34
- <Form.Select
35
- @label='Countries'
36
- @fieldName='countries'
37
- @isMultiple={{true}}
38
- @options={{this.countries}}
39
- @allowClear={{true}}
40
- @containerClass='mt-4'
41
- as |option|
42
- >
43
- {{option}}
44
- </Form.Select>
45
- <Form.CheckboxGroup
46
- @groupName='coreValues'
47
- @label='Core Values'
48
- @containerClass='mt-4'
49
- as |Checkbox|
50
- >
51
- <Checkbox @label='Hungry' @fieldName='hungry' />
52
- <Checkbox @label='Humble' @fieldName='humble' />
53
- <Checkbox @label='Curious' @fieldName='curious' />
54
- </Form.CheckboxGroup>
55
- <Form.RadioGroup
56
- @label='Favorite Meal'
57
- @containerClass='mt-4'
58
- @fieldName='favoriteMeal'
59
- as |Radio|
60
- >
61
- <Radio @label='Breakfast' @value='breakfast' />
62
- <Radio @label='Lunch' @value='lunch' />
63
- <Radio @label='Dinner' @value='dinner' />
64
- </Form.RadioGroup>
65
- <Button
66
- @type='submit'
67
- @intent='primary'
68
- disabled={{changeset.isInvalid}}
69
- class='mt-4'
70
- >
71
- Save
72
- </Button>
73
- <Button @type='reset' @appearance='outlined'>
74
- Reset
75
- </Button>
76
- <div class='mt-4'>
77
- <code>
78
- <p>isPristine: {{changeset.isPristine}}</p>
79
- <p>isValid: {{changeset.isValid}}</p>
80
- <p>isInvalid: {{changeset.isInvalid}}</p>
81
- </code>
82
- </div>
83
- </ChangesetForm>
84
- {{/let}}
85
- ```
86
-
87
- ```ts component
88
- import Component from '@glimmer/component';
89
- import validateFormat from 'ember-changeset-validations/validators/format';
90
- import validatePresence from 'ember-changeset-validations/validators/presence';
91
-
92
- export const myValidations = {
93
- firstName: validatePresence(true),
94
- lastName: validatePresence(true),
95
- email: validateFormat({ type: 'email' }),
96
- countries: validatePresence(true)
97
- };
98
-
99
- export default class Demo extends Component {
100
- validations = myValidations;
101
- countries = [
102
- 'Brazil',
103
- 'India',
104
- 'Israel',
105
- 'Japan',
106
- 'United Kingdom',
107
- 'United States'
108
- ];
109
-
110
- model = {
111
- firstName: null,
112
- lastName: null,
113
- email: 'frontile@example.com',
114
- comments: 'Changeset forms are great! 🚀',
115
- countries: ['Brazil', 'United States'],
116
- coreValues: {
117
- hungry: true,
118
- humble: true,
119
- curious: true
120
- },
121
- favoriteMeal: 'lunch'
122
- };
123
- }
124
- ```
@@ -1,134 +0,0 @@
1
- ---
2
- title: Usage
3
- url: /usage
4
- ---
5
-
6
- # Using ChangesetFornm
7
-
8
- Almost every single app out there has some kind of form. It might be a user preference
9
- page or a core part of the experience you are providing your user. Usually,
10
- forms are bound to an object that the user can update or add more values.
11
- To provide rich user experience, validating the user's input might be a requirement,
12
- or to avoid confusing users, you might want to wait for the user to click "save" until
13
- updating parts of the screen that shows the data that the user is changing.
14
-
15
- ChangesetForm helps to implement all these features in your apps. We use
16
- [ember-changeset](http://github.com/poteto/ember-changeset) under the hood,
17
- validations are provided by [ember-changeset-validations](https://github.com/poteto/ember-changeset-validations/).
18
-
19
- The `<ChangesetForm>` component yields an object with all the components pre-bonded
20
- to a changeset for you to create a form. It also exposes the changeset itself if
21
- you need to access any information directly.
22
-
23
- ## Form Data Model
24
-
25
- The data model used to back the `<ChangesetForm>` is an instance of a changeset object by `ember-changeset`,
26
- and so, nested property paths are supported. Ember Data Models are also supported.
27
-
28
- ```js
29
- import Component from '@glimmer/component';
30
-
31
- export default class Demo extends Component {
32
- myFormModel = {
33
- name: {
34
- first: 'Ron',
35
- last: 'Swanson'
36
- },
37
- email: 'ron@pawnee.in.gov',
38
- hometown: 'Pawnee, IN',
39
- preferences: ['Lagavulin', 'Steak', 'Bacon', 'No govt.']
40
- };
41
- }
42
- ```
43
-
44
- ## Validation
45
-
46
- Changeset validation is provided by [ember-changeset-validations](https://github.com/poteto/ember-changeset-validations/),
47
- and is optional for any `Changeset` object used by `<ChangesetForm>` components. This takes the form of another
48
- JS object literal mapping properties to validation functions:
49
-
50
- ```js
51
- import Component from '@glimmer/component';
52
- import validateFormat from 'ember-changeset-validations/validators/format';
53
- import validatePresence from 'ember-changeset-validations/validators/presence';
54
-
55
- export default class Demo extends Component {
56
- // ...
57
- myValidations = {
58
- 'name.first': validatePresence(true),
59
- 'name.last': validatePresence(true),
60
- email: validateFormat({ type: 'email' }),
61
- hometown: validatePresence(true),
62
- preferences: validatePresence(true)
63
- };
64
- }
65
- ```
66
-
67
- ## Creating an Instance of a changeset via the template
68
-
69
- ```hbs
70
- <ChangesetForm
71
- @changeset={{changeset this.myFormModel this.myValidations}}
72
- as |Form|
73
- >
74
- <!-- ... -->
75
- </ChangesetForm>
76
- ```
77
-
78
- ## Creating Your Own Changeset via JS
79
-
80
- In this case you are responsible for also providing any validation you wish to apply
81
- to your `Changeset`. The following is a brief example of that method:
82
-
83
- ```js
84
- import Component from '@glimmer/component';
85
- import { Changeset } from 'ember-changeset';
86
- import lookupValidator from 'ember-changeset-validations';
87
- import validatePresence from 'ember-changeset-validations/validators/presence';
88
-
89
- export default class Demo extends Component {
90
- validations = {
91
- myValue: validatePresence(true)
92
- };
93
-
94
- myModel = {
95
- myValue: ''
96
- };
97
-
98
- myChangeset = new Changeset(
99
- this.myModel,
100
- lookupValidator(this.validations),
101
- this.validations
102
- );
103
- }
104
- ```
105
-
106
- ```hbs
107
- <ChangesetForm @changeset={{this.myChangeset}} as |Form|>
108
- <!-- ... -->
109
- </ChangesetForm>
110
- ```
111
-
112
- ## API
113
-
114
- ### Args
115
-
116
- <ArgsTable @of="ChangesetForm" class="mb-8" />
117
-
118
- ### Blocks
119
-
120
- | Name | Type |
121
- | --------- | -------------------------------------------------------------------------------------------------- |
122
- | `default` | `[formComponents: FormComponents, changeset: BufferedChangeset, state: { hasSubmitted: boolean }]` |
123
-
124
- Here's the list of yielded form components from `FormComponents`:
125
-
126
- | Key | Component |
127
- | ------------- | --------------------- |
128
- | Text | `<FormText>` |
129
- | Textarea | `<FormTextArea>` |
130
- | Select | `<FormSelect>` |
131
- | Checkbox | `<FormCheckbox>` |
132
- | CheckboxGroup | `<FormCheckboxGroup>` |
133
- | Radio | `<FormRadio>` |
134
- | RadioGroup | `<FormRadioGroup>` |
package/index.js DELETED
@@ -1,5 +0,0 @@
1
- 'use strict';
2
-
3
- module.exports = {
4
- name: require('./package').name
5
- };
package/tsconfig.json DELETED
@@ -1,24 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.base.json",
3
- "compilerOptions": {
4
- "baseUrl": ".",
5
- "skipLibCheck": true,
6
- "paths": {
7
- "dummy/tests/*": ["tests/*"],
8
- "dummy/*": ["tests/dummy/app/*", "app/*"],
9
- "@frontile/changeset-form": ["addon"],
10
- "@frontile/changeset-form/*": ["addon/*"],
11
- "@frontile/changeset-form/test-support": ["addon-test-support"],
12
- "@frontile/changeset-form/test-support/*": ["addon-test-support/*"],
13
- "*": ["types/*"]
14
- }
15
- },
16
- "include": [
17
- "app/**/*",
18
- "addon/**/*",
19
- "tests/**/*",
20
- "types/**/*",
21
- "test-support/**/*",
22
- "addon-test-support/**/*"
23
- ]
24
- }
File without changes
@@ -1,56 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-type-alias */
2
-
3
- declare module 'ember-changeset-validations' {
4
- import {
5
- ValidationResult,
6
- ValidatorMapFunc,
7
- ValidatorAction
8
- } from 'ember-changeset/types';
9
-
10
- interface NestedValidator<T> {
11
- [key: string]: T;
12
- }
13
-
14
- type Validator =
15
- | ValidatorMapFunc
16
- | ValidatorMapFunc[]
17
- | ValidatorAction
18
- | NestedValidator<Validator>;
19
-
20
- interface ValidatorMap {
21
- [s: string]: Validator;
22
- }
23
-
24
- export default function lookupValidator(
25
- validationMap: ValidatorMap
26
- ): (params: {
27
- key: string;
28
- newValue: unknown;
29
- oldValue: unknown;
30
- changes: { [s: string]: unknown };
31
- content: { [s: string]: unknown };
32
- }) => string | boolean | [boolean] | string[] | Promise<ValidationResult>;
33
- }
34
-
35
- declare module 'ember-changeset-validations/validators/presence' {
36
- import { ValidatorAction } from 'ember-changeset/types';
37
- export default function validatePresence(
38
- options?:
39
- | boolean
40
- | {
41
- presence?: boolean;
42
- ignoreBlank?: boolean;
43
- }
44
- ): ValidatorAction;
45
- }
46
- declare module 'ember-changeset-validations/validators/format' {
47
- import { ValidatorAction } from 'ember-changeset/types';
48
- export default function validateFormat(options?: {
49
- allowBlank?: boolean;
50
- type?: string;
51
- inverse?: string;
52
- regex?: RegExp | string;
53
- allowNonTld?: boolean;
54
- minTldLength?: number;
55
- }): ValidatorAction;
56
- }
@@ -1,3 +0,0 @@
1
- import Config from 'dummy/config/environment';
2
-
3
- export default Config;
@@ -1,29 +0,0 @@
1
- declare module 'ember-power-select/test-support' {
2
- export function selectChoose(
3
- cssPath: string,
4
- optionTextOrOptionSelector: string,
5
- index?: number
6
- ): Promise<void>;
7
- export function selectSearch(
8
- cssPath: string,
9
- searchText: string
10
- ): Promise<void>;
11
- export function removeMultipleOption(
12
- cssPath: string,
13
- optionText: string
14
- ): Promise<void>;
15
- export function clearSelected(
16
- cssPath: string,
17
- optionText: string
18
- ): Promise<void>;
19
- }
20
-
21
- declare module 'ember-power-select/test-support/helpers' {
22
- export function clickTrigger(scope?: string): Promise<void>;
23
- export function typeInSearch(text: string): Promise<void>;
24
- export function selectChoose(
25
- cssPath: string,
26
- optionTextOrOptionSelector: string,
27
- index?: number
28
- ): Promise<void>;
29
- }
package/types/global.d.ts DELETED
@@ -1,6 +0,0 @@
1
- // Types for compiled templates
2
- declare module '@frontile/changeset-form/templates/*' {
3
- import { TemplateFactory } from 'htmlbars-inline-precompile';
4
- const tmpl: TemplateFactory;
5
- export default tmpl;
6
- }
package/types/index.d.ts DELETED
@@ -1 +0,0 @@
1
- import 'ember-source/types';