@ember-eui/validated-form 7.1.5 → 8.0.0-beta.14

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 (174) hide show
  1. package/addon-main.js +5 -0
  2. package/declarations/components/validated-form/field-base/index.d.ts +37 -0
  3. package/declarations/components/validated-form/field-base/index.d.ts.map +1 -0
  4. package/declarations/components/validated-form/field-base.d.ts +56 -0
  5. package/declarations/components/validated-form/field-base.d.ts.map +1 -0
  6. package/declarations/components/validated-form/field-checkbox-group/index.d.ts +8 -0
  7. package/declarations/components/validated-form/field-checkbox-group/index.d.ts.map +1 -0
  8. package/declarations/components/validated-form/field-checkbox-group.d.ts +30 -0
  9. package/declarations/components/validated-form/field-checkbox-group.d.ts.map +1 -0
  10. package/declarations/components/validated-form/field-combo-box/index.d.ts +5 -0
  11. package/declarations/components/validated-form/field-combo-box/index.d.ts.map +1 -0
  12. package/declarations/components/validated-form/field-combo-box.d.ts +27 -0
  13. package/declarations/components/validated-form/field-combo-box.d.ts.map +1 -0
  14. package/declarations/components/validated-form/field-dual-range-slider/index.d.ts +5 -0
  15. package/declarations/components/validated-form/field-dual-range-slider/index.d.ts.map +1 -0
  16. package/declarations/components/validated-form/field-dual-range-slider.d.ts +32 -0
  17. package/declarations/components/validated-form/field-dual-range-slider.d.ts.map +1 -0
  18. package/{addon/components/validated-form/field-markdown-editor/index.js → declarations/components/validated-form/field-markdown-editor/index.d.ts} +3 -8
  19. package/declarations/components/validated-form/field-markdown-editor/index.d.ts.map +1 -0
  20. package/declarations/components/validated-form/field-markdown-editor.d.ts +25 -0
  21. package/declarations/components/validated-form/field-markdown-editor.d.ts.map +1 -0
  22. package/{addon/components/validated-form/field-number/index.js → declarations/components/validated-form/field-number/index.d.ts} +3 -2
  23. package/declarations/components/validated-form/field-number/index.d.ts.map +1 -0
  24. package/declarations/components/validated-form/field-number.d.ts +24 -0
  25. package/declarations/components/validated-form/field-number.d.ts.map +1 -0
  26. package/{addon/components/validated-form/field-password/index.js → declarations/components/validated-form/field-password/index.d.ts} +3 -2
  27. package/declarations/components/validated-form/field-password/index.d.ts.map +1 -0
  28. package/declarations/components/validated-form/field-password.d.ts +24 -0
  29. package/declarations/components/validated-form/field-password.d.ts.map +1 -0
  30. package/declarations/components/validated-form/field-radio-group/index.d.ts +8 -0
  31. package/declarations/components/validated-form/field-radio-group/index.d.ts.map +1 -0
  32. package/declarations/components/validated-form/field-radio-group.d.ts +29 -0
  33. package/declarations/components/validated-form/field-radio-group.d.ts.map +1 -0
  34. package/{addon/components/validated-form/field-range-slider/index.js → declarations/components/validated-form/field-range-slider/index.d.ts} +3 -2
  35. package/declarations/components/validated-form/field-range-slider/index.d.ts.map +1 -0
  36. package/declarations/components/validated-form/field-range-slider.d.ts +28 -0
  37. package/declarations/components/validated-form/field-range-slider.d.ts.map +1 -0
  38. package/{addon/components/validated-form/field-select/index.js → declarations/components/validated-form/field-select/index.d.ts} +3 -2
  39. package/declarations/components/validated-form/field-select/index.d.ts.map +1 -0
  40. package/declarations/components/validated-form/field-select.d.ts +23 -0
  41. package/declarations/components/validated-form/field-select.d.ts.map +1 -0
  42. package/declarations/components/validated-form/field-switch/index.d.ts +5 -0
  43. package/declarations/components/validated-form/field-switch/index.d.ts.map +1 -0
  44. package/declarations/components/validated-form/field-switch.d.ts +24 -0
  45. package/declarations/components/validated-form/field-switch.d.ts.map +1 -0
  46. package/{addon/components/validated-form/field-text/index.js → declarations/components/validated-form/field-text/index.d.ts} +3 -2
  47. package/declarations/components/validated-form/field-text/index.d.ts.map +1 -0
  48. package/{addon/components/validated-form/field-text-area/index.js → declarations/components/validated-form/field-text-area/index.d.ts} +3 -2
  49. package/declarations/components/validated-form/field-text-area/index.d.ts.map +1 -0
  50. package/declarations/components/validated-form/field-text-area.d.ts +29 -0
  51. package/declarations/components/validated-form/field-text-area.d.ts.map +1 -0
  52. package/declarations/components/validated-form/field-text.d.ts +22 -0
  53. package/declarations/components/validated-form/field-text.d.ts.map +1 -0
  54. package/declarations/components/validated-form/index.d.ts +30 -0
  55. package/declarations/components/validated-form/index.d.ts.map +1 -0
  56. package/declarations/components/validated-form.d.ts +91 -0
  57. package/declarations/components/validated-form.d.ts.map +1 -0
  58. package/declarations/utils/build-validation-messages.d.ts +13 -0
  59. package/declarations/utils/build-validation-messages.d.ts.map +1 -0
  60. package/declarations/utils/get-messages.d.ts +11 -0
  61. package/declarations/utils/get-messages.d.ts.map +1 -0
  62. package/declarations/utils/validation-errors.d.ts +2 -0
  63. package/declarations/utils/validation-errors.d.ts.map +1 -0
  64. package/declarations/utils/with-defaults.d.ts +10 -0
  65. package/declarations/utils/with-defaults.d.ts.map +1 -0
  66. package/declarations/validators/messages.d.ts +4 -0
  67. package/declarations/validators/messages.d.ts.map +1 -0
  68. package/dist/_app_/components/validated-form/field-base.js +1 -0
  69. package/dist/_app_/components/validated-form/field-checkbox-group.js +1 -0
  70. package/dist/_app_/components/validated-form/field-combo-box.js +1 -0
  71. package/dist/_app_/components/validated-form/field-dual-range-slider.js +1 -0
  72. package/dist/_app_/components/validated-form/field-markdown-editor.js +1 -0
  73. package/dist/_app_/components/validated-form/field-number.js +1 -0
  74. package/dist/_app_/components/validated-form/field-password.js +1 -0
  75. package/dist/_app_/components/validated-form/field-radio-group.js +1 -0
  76. package/dist/_app_/components/validated-form/field-range-slider.js +1 -0
  77. package/dist/_app_/components/validated-form/field-select.js +1 -0
  78. package/dist/_app_/components/validated-form/field-switch.js +1 -0
  79. package/dist/_app_/components/validated-form/field-text-area.js +1 -0
  80. package/dist/_app_/components/validated-form/field-text.js +1 -0
  81. package/dist/_app_/components/validated-form.js +1 -0
  82. package/dist/_app_/utils/build-validation-messages.js +1 -0
  83. package/dist/_app_/utils/get-messages.js +1 -0
  84. package/dist/_app_/utils/validation-errors.js +1 -0
  85. package/dist/_app_/utils/with-defaults.js +1 -0
  86. package/dist/_app_/validators/messages.js +1 -0
  87. package/dist/components/validated-form/field-base.js +7 -0
  88. package/dist/components/validated-form/field-base.js.map +1 -0
  89. package/dist/components/validated-form/field-checkbox-group.js +104 -0
  90. package/dist/components/validated-form/field-checkbox-group.js.map +1 -0
  91. package/dist/components/validated-form/field-combo-box.js +106 -0
  92. package/dist/components/validated-form/field-combo-box.js.map +1 -0
  93. package/dist/components/validated-form/field-dual-range-slider.js +112 -0
  94. package/dist/components/validated-form/field-dual-range-slider.js.map +1 -0
  95. package/dist/components/validated-form/field-markdown-editor.js +102 -0
  96. package/dist/components/validated-form/field-markdown-editor.js.map +1 -0
  97. package/dist/components/validated-form/field-number.js +94 -0
  98. package/dist/components/validated-form/field-number.js.map +1 -0
  99. package/dist/components/validated-form/field-password.js +87 -0
  100. package/dist/components/validated-form/field-password.js.map +1 -0
  101. package/dist/components/validated-form/field-radio-group.js +102 -0
  102. package/dist/components/validated-form/field-radio-group.js.map +1 -0
  103. package/dist/components/validated-form/field-range-slider.js +119 -0
  104. package/dist/components/validated-form/field-range-slider.js.map +1 -0
  105. package/dist/components/validated-form/field-select.js +88 -0
  106. package/dist/components/validated-form/field-select.js.map +1 -0
  107. package/dist/components/validated-form/field-switch.js +87 -0
  108. package/dist/components/validated-form/field-switch.js.map +1 -0
  109. package/dist/components/validated-form/field-text-area.js +80 -0
  110. package/dist/components/validated-form/field-text-area.js.map +1 -0
  111. package/dist/components/validated-form/field-text.js +90 -0
  112. package/dist/components/validated-form/field-text.js.map +1 -0
  113. package/dist/components/validated-form.js +303 -0
  114. package/dist/components/validated-form.js.map +1 -0
  115. package/dist/field-base-t4F7Xj_I.js +185 -0
  116. package/dist/field-base-t4F7Xj_I.js.map +1 -0
  117. package/{addon → dist}/utils/build-validation-messages.js +13 -36
  118. package/dist/utils/build-validation-messages.js.map +1 -0
  119. package/{addon → dist}/utils/get-messages.js +6 -7
  120. package/dist/utils/get-messages.js.map +1 -0
  121. package/dist/utils/validation-errors.js +18 -0
  122. package/dist/utils/validation-errors.js.map +1 -0
  123. package/{addon → dist}/utils/with-defaults.js +5 -2
  124. package/dist/utils/with-defaults.js.map +1 -0
  125. package/dist/validators/messages.js +7 -0
  126. package/dist/validators/messages.js.map +1 -0
  127. package/package.json +116 -75
  128. package/addon/components/validated-form/field-base/index.js +0 -144
  129. package/addon/components/validated-form/field-checkbox-group/index.hbs +0 -47
  130. package/addon/components/validated-form/field-checkbox-group/index.js +0 -42
  131. package/addon/components/validated-form/field-combo-box/index.hbs +0 -65
  132. package/addon/components/validated-form/field-combo-box/index.js +0 -12
  133. package/addon/components/validated-form/field-dual-range-slider/index.hbs +0 -80
  134. package/addon/components/validated-form/field-dual-range-slider/index.js +0 -12
  135. package/addon/components/validated-form/field-markdown-editor/index.hbs +0 -61
  136. package/addon/components/validated-form/field-number/index.hbs +0 -63
  137. package/addon/components/validated-form/field-password/index.hbs +0 -56
  138. package/addon/components/validated-form/field-radio-group/index.hbs +0 -45
  139. package/addon/components/validated-form/field-radio-group/index.js +0 -39
  140. package/addon/components/validated-form/field-range-slider/index.hbs +0 -93
  141. package/addon/components/validated-form/field-select/index.hbs +0 -57
  142. package/addon/components/validated-form/field-switch/index.hbs +0 -48
  143. package/addon/components/validated-form/field-switch/index.js +0 -12
  144. package/addon/components/validated-form/field-text/index.hbs +0 -59
  145. package/addon/components/validated-form/field-text-area/index.hbs +0 -54
  146. package/addon/components/validated-form/index.hbs +0 -158
  147. package/addon/components/validated-form/index.js +0 -132
  148. package/addon/utils/validation-errors.js +0 -13
  149. package/addon/validators/messages.js +0 -4
  150. package/app/components/validated-form/field-base/index.js +0 -1
  151. package/app/components/validated-form/field-checkbox-group/index.js +0 -1
  152. package/app/components/validated-form/field-combo-box/index.js +0 -1
  153. package/app/components/validated-form/field-dual-range-slider/index.js +0 -1
  154. package/app/components/validated-form/field-markdown-editor/index.js +0 -1
  155. package/app/components/validated-form/field-number/index.js +0 -1
  156. package/app/components/validated-form/field-password/index.js +0 -1
  157. package/app/components/validated-form/field-radio-group/index.js +0 -1
  158. package/app/components/validated-form/field-range-slider/index.js +0 -1
  159. package/app/components/validated-form/field-select/index.js +0 -1
  160. package/app/components/validated-form/field-switch/index.js +0 -1
  161. package/app/components/validated-form/field-text/index.js +0 -1
  162. package/app/components/validated-form/field-text-area/index.js +0 -1
  163. package/app/components/validated-form/index.js +0 -1
  164. package/app/utils/build-validation-messages.js +0 -1
  165. package/app/utils/get-messages.js +0 -1
  166. package/app/utils/validation-errors.js +0 -1
  167. package/app/validators/messages.js +0 -1
  168. package/config/environment.js +0 -5
  169. package/docs/validated-form-demo/demo1.md +0 -162
  170. package/docs/validated-form.md +0 -1
  171. package/index.js +0 -5
  172. package/tsconfig.json +0 -27
  173. package/types/dummy/index.d.ts +0 -1
  174. package/types/global.d.ts +0 -22
@@ -1,158 +0,0 @@
1
- {{#let (arg-or-default @id (unique-id)) as |formId|}}
2
- <EuiForm
3
- @tagName={{arg-or-default @tagName "form"}}
4
- ...attributes
5
- id={{formId}}
6
- @isInvalid={{@isInvalid}}
7
- @invalidCallout={{@invalidCallout}}
8
- @error={{@error}}
9
- @errorTitle={{@errorTitle}}
10
- {{on "submit" this.handleSubmit}}
11
- {{on "reset" this.handleReset}}
12
- {{did-insert this.setNewValidity}}
13
- >
14
- {{yield
15
- (hash
16
- formHasBeenValidated=this.formHasBeenValidated
17
- onValidityChange=this.onChildValidityChange
18
- register=this.register
19
- unregister=this.unregister
20
- isValid=this.isValid
21
- isInvalid=this.isInvalid
22
- isTouched=this.isTouched
23
- isInvalidAndTouched=this.isInvalidAndTouched
24
- formId=formId
25
- FieldNumber=(component
26
- "validated-form/field-number"
27
- register=this.register
28
- unregister=this.unregister
29
- formHasBeenValidated=this.formHasBeenValidated
30
- onValidityChange=this.onChildValidityChange
31
- fullWidth=@fullWidth
32
- formId=formId
33
- disabled=@isDisabled
34
- )
35
- FieldText=(component
36
- "validated-form/field-text"
37
- register=this.register
38
- unregister=this.unregister
39
- formHasBeenValidated=this.formHasBeenValidated
40
- onValidityChange=this.onChildValidityChange
41
- fullWidth=@fullWidth
42
- formId=formId
43
- disabled=@isDisabled
44
- )
45
- FieldPassword=(component
46
- "validated-form/field-password"
47
- register=this.register
48
- unregister=this.unregister
49
- formHasBeenValidated=this.formHasBeenValidated
50
- onValidityChange=this.onChildValidityChange
51
- fullWidth=@fullWidth
52
- formId=formId
53
- disabled=@isDisabled
54
- )
55
- FieldTextArea=(component
56
- "validated-form/field-text-area"
57
- register=this.register
58
- unregister=this.unregister
59
- formHasBeenValidated=this.formHasBeenValidated
60
- onValidityChange=this.onChildValidityChange
61
- fullWidth=@fullWidth
62
- formId=formId
63
- disabled=@isDisabled
64
- )
65
- FieldSelect=(component
66
- "validated-form/field-select"
67
- register=this.register
68
- unregister=this.unregister
69
- formHasBeenValidated=this.formHasBeenValidated
70
- onValidityChange=this.onChildValidityChange
71
- fullWidth=@fullWidth
72
- formId=formId
73
- disabled=@isDisabled
74
- )
75
- FieldComboBox=(component
76
- "validated-form/field-combo-box"
77
- register=this.register
78
- unregister=this.unregister
79
- formHasBeenValidated=this.formHasBeenValidated
80
- onValidityChange=this.onChildValidityChange
81
- fullWidth=@fullWidth
82
- formId=formId
83
- isDisabled=@isDisabled
84
- )
85
- FieldCheckboxGroup=(component
86
- "validated-form/field-checkbox-group"
87
- register=this.register
88
- unregister=this.unregister
89
- formHasBeenValidated=this.formHasBeenValidated
90
- onValidityChange=this.onChildValidityChange
91
- fullWidth=@fullWidth
92
- formId=formId
93
- disabled=@isDisabled
94
- )
95
- FieldRadioGroup=(component
96
- "validated-form/field-radio-group"
97
- register=this.register
98
- unregister=this.unregister
99
- formHasBeenValidated=this.formHasBeenValidated
100
- onValidityChange=this.onChildValidityChange
101
- fullWidth=@fullWidth
102
- formId=formId
103
- disabled=@isDisabled
104
- )
105
- FieldRangeSlider=(component
106
- "validated-form/field-range-slider"
107
- register=this.register
108
- unregister=this.unregister
109
- formHasBeenValidated=this.formHasBeenValidated
110
- onValidityChange=this.onChildValidityChange
111
- fullWidth=@fullWidth
112
- formId=formId
113
- disabled=@isDisabled
114
- )
115
- FieldDualRangeSlider=(component
116
- "validated-form/field-dual-range-slider"
117
- register=this.register
118
- unregister=this.unregister
119
- formHasBeenValidated=this.formHasBeenValidated
120
- onValidityChange=this.onChildValidityChange
121
- fullWidth=@fullWidth
122
- formId=formId
123
- disabled=@isDisabled
124
- )
125
- FieldSwitch=(component
126
- "validated-form/field-switch"
127
- register=this.register
128
- unregister=this.unregister
129
- formHasBeenValidated=this.formHasBeenValidated
130
- onValidityChange=this.onChildValidityChange
131
- fullWidth=@fullWidth
132
- formId=formId
133
- disabled=@isDisabled
134
- )
135
- FieldMarkdownEditor=(component
136
- "validated-form/field-markdown-editor"
137
- register=this.register
138
- unregister=this.unregister
139
- formHasBeenValidated=this.formHasBeenValidated
140
- onValidityChange=this.onChildValidityChange
141
- fullWidth=@fullWidth
142
- formId=formId
143
- disabled=@isDisabled
144
- )
145
- FieldNestedForm=(component
146
- "validated-form"
147
- register=this.register
148
- unregister=this.unregister
149
- formHasBeenValidated=this.formHasBeenValidated
150
- onValidityChange=this.onChildValidityChange
151
- fullWidth=@fullWidth
152
- formId=formId
153
- disabled=@isDisabled
154
- )
155
- )
156
- }}
157
- </EuiForm>
158
- {{/let}}
@@ -1,132 +0,0 @@
1
- import Component from '@glimmer/component';
2
- import { action } from '@ember/object';
3
- import { tracked } from '@glimmer/tracking';
4
- import { A } from '@ember/array';
5
- import { schedule, next } from '@ember/runloop';
6
-
7
- export default class ValidatedForm extends Component {
8
- @tracked childComponents = A([]);
9
- //cache to only notify if changed
10
- lastIsValid;
11
- lastIsTouched;
12
-
13
- @tracked isInvalid = false;
14
- @tracked isTouched = false;
15
-
16
- constructor() {
17
- super(...arguments);
18
- this.args.register?.(this);
19
- }
20
-
21
- willDestroy() {
22
- super.willDestroy(...arguments);
23
- this.args.unregister?.(this);
24
- }
25
-
26
- get isValid() {
27
- return !this.isInvalid;
28
- }
29
-
30
- get isInvalidAndTouched() {
31
- return this.isInvalid && this.isTouched;
32
- }
33
-
34
- addChild(child) {
35
- this.childComponents.pushObject(child);
36
- }
37
-
38
- removeChild(child) {
39
- this.childComponents.removeObject(child);
40
- }
41
-
42
- @action
43
- async handleSubmit(e) {
44
- e.preventDefault();
45
- if (this.isInvalid) {
46
- this.childComponents.setEach('isTouched', true);
47
- this.args.onInvalid?.();
48
- } else {
49
- this.childComponents.setEach('isTouched', false);
50
- try {
51
- await this.args.onSubmit?.();
52
- } catch (e) {
53
- this.childComponents.setEach('isTouched', true);
54
- }
55
- }
56
- }
57
-
58
- @action
59
- handleReset(e) {
60
- e.preventDefault();
61
- this.args.onReset?.(e);
62
- }
63
-
64
- @action
65
- register(child) {
66
- if (!this.isDestroyed) {
67
- schedule('afterRender', this, this.addChild, child);
68
- }
69
- }
70
-
71
- @action
72
- unregister(child) {
73
- if (!this.isDestroyed) {
74
- schedule('afterRender', this, this.removeChild, child);
75
- // When adding a child the validation gets calculated on a `did-insert` modifier
76
- // for removal there's no modifier so it gets called here
77
- schedule('afterRender', this, this.triggerValidityChange);
78
- }
79
- }
80
-
81
- @action
82
- updateValidity() {
83
- this.triggerValidityChange();
84
- }
85
-
86
- getIsValid() {
87
- return this.childComponents.isEvery('isValid');
88
- }
89
-
90
- getIsTouched() {
91
- return this.childComponents.isAny('isTouched');
92
- }
93
-
94
- triggerValidityChange() {
95
- const lastIsValid = this.isValid;
96
- const lastIsTouched = this.isTouched;
97
-
98
- if (
99
- lastIsValid !== this.getIsValid() ||
100
- lastIsTouched !== this.getIsTouched()
101
- ) {
102
- this.setNewValidity();
103
- }
104
- }
105
-
106
- @action
107
- setNewValidity() {
108
- next(() => {
109
- this.isInvalid = !this.getIsValid();
110
- this.isTouched = this.getIsTouched();
111
- if (!this.isDestroying) {
112
- this.args.onValidityChange?.(
113
- this.isValid,
114
- this.isTouched,
115
- this.isInvalidAndTouched
116
- );
117
- }
118
- });
119
- }
120
-
121
- @action
122
- onChildValidityChange({ child, isValid, isTouched, isInvalidAndTouched }) {
123
- if (!this.isDestroying) {
124
- this.updateValidity({
125
- child,
126
- isValid,
127
- isTouched,
128
- isInvalidAndTouched
129
- });
130
- }
131
- }
132
- }
@@ -1,13 +0,0 @@
1
- import { assign } from '@ember/polyfills';
2
-
3
- export default function buildMessage(messages, key, result = {}) {
4
- let description = messages.getDescriptionFor(key);
5
-
6
- if (result?.context?.message) {
7
- return result.context.message;
8
- }
9
-
10
- let { type, context = {} } = result;
11
-
12
- return messages.getMessageFor(type, assign({ description }, context));
13
- }
@@ -1,4 +0,0 @@
1
- import Messages from 'ember-validators/messages';
2
- import EmberObject from '@ember/object';
3
-
4
- export default EmberObject.extend(Messages)
@@ -1 +0,0 @@
1
- export { default } from '@ember-eui/validated-form/components/validated-form/field-base';
@@ -1 +0,0 @@
1
- export { default } from '@ember-eui/validated-form/components/validated-form/field-checkbox-group';
@@ -1 +0,0 @@
1
- export { default } from '@ember-eui/validated-form/components/validated-form/field-combo-box';
@@ -1 +0,0 @@
1
- export { default } from '@ember-eui/validated-form/components/validated-form/field-dual-range-slider';
@@ -1 +0,0 @@
1
- export { default } from '@ember-eui/validated-form/components/validated-form/field-markdown-editor';
@@ -1 +0,0 @@
1
- export { default } from '@ember-eui/validated-form/components/validated-form/field-number';
@@ -1 +0,0 @@
1
- export { default } from '@ember-eui/validated-form/components/validated-form/field-password';
@@ -1 +0,0 @@
1
- export { default } from '@ember-eui/validated-form/components/validated-form/field-radio-group';
@@ -1 +0,0 @@
1
- export { default } from '@ember-eui/validated-form/components/validated-form/field-range-slider';
@@ -1 +0,0 @@
1
- export { default } from '@ember-eui/validated-form/components/validated-form/field-select';
@@ -1 +0,0 @@
1
- export { default } from '@ember-eui/validated-form/components/validated-form/field-switch';
@@ -1 +0,0 @@
1
- export { default } from '@ember-eui/validated-form/components/validated-form/field-text';
@@ -1 +0,0 @@
1
- export { default } from '@ember-eui/validated-form/components/validated-form/field-text-area';
@@ -1 +0,0 @@
1
- export { default } from '@ember-eui/validated-form/components/validated-form';
@@ -1 +0,0 @@
1
- export { default } from '@ember-eui/validated-form/utils/build-validation-messages';
@@ -1 +0,0 @@
1
- export { default } from '@ember-eui/validated-form/utils/get-messages';
@@ -1 +0,0 @@
1
- export { default } from '@ember-eui/validated-form/utils/validation-errors';
@@ -1 +0,0 @@
1
- export { default } from '@ember-eui/validated-form/validators/messages';
@@ -1,5 +0,0 @@
1
- 'use strict';
2
-
3
- module.exports = function (/* environment, appConfig */) {
4
- return {};
5
- };
@@ -1,162 +0,0 @@
1
- # Validated form
2
-
3
- <EuiText>
4
- <p>Inspired on <strong>ember-paper</strong>'s <EuiCode>{{t "validated_form.ember_paper"}}</EuiCode></p>
5
-
6
- <p>The idea is simple, <strong>ValidatedForm</strong> yields most basic <strong>@ember-eui/core</strong> components with some wiring to keep the form state on sync.</p>
7
-
8
- <p>It uses <EuiLink @target="_blank" @href="https://github.com/offirgolan/ember-validators">ember-validators</EuiLink> by default to describe the validations. To provide the validations ergonomically you'd just pass a hash where each key is a valid
9
- ember-valitador validator, <EuiCode>length</EuiCode>, <EuiCode>presence</EuiCode>, <EuiCode>number</EuiCode>, the values and the <EuiCode>config</EuiCode> expected by those.</p>
10
-
11
- <p><EuiCodeBlock @isCopyable={{true}}>ember install @ember-eui/validated-form</EuiCodeBlock></p>
12
-
13
- </EuiText>
14
-
15
- ```hbs template
16
- <ValidatedForm as |Form|>
17
- <Form.FieldText
18
- @value={{this.data.fieldText}}
19
- @label='Email'
20
- @onChange={{set this.data 'fieldText'}}
21
- @validations={{hash
22
- presence=(hash presence=true)
23
- format=(hash type='email')
24
- }}
25
- />
26
- <Form.FieldMarkdownEditor
27
- @value={{this.data.markdownText}}
28
- @label='Markdown'
29
- @onChange={{set this.data 'markdownText'}}
30
- @validations={{hash presence=(hash presence=true)}}
31
- @error={{array 'one error'}}
32
- />
33
- <Form.FieldSelect
34
- @onChange={{set this.data 'fieldSelect'}}
35
- @value={{this.data.fieldSelect}}
36
- @validations={{hash presence=(hash presence=true)}}
37
- @options={{array
38
- (hash value='mx' text='Mexico')
39
- (hash value='pt' text='Portugal')
40
- (hash value='us' text='United States')
41
- }}
42
- @label='Country'
43
- />
44
- <Form.FieldComboBox
45
- @onChange={{set this.data 'fieldComboBoxSingleSelection'}}
46
- @singleSelection={{true}}
47
- @selectedOptions={{this.data.fieldComboBoxSingleSelection}}
48
- @validations={{hash presence=(hash presence=true)}}
49
- @required={{true}}
50
- @options={{array
51
- (hash value='mx' text='Mexico')
52
- (hash value='pt' text='Portugal')
53
- (hash value='us' text='United States')
54
- }}
55
- @label='fieldComboBoxSingleSelection'
56
- as |option|
57
- >
58
- {{option.text}}
59
- </Form.FieldComboBox>
60
- <Form.FieldComboBox
61
- @onChange={{set this.data 'fieldComboBoxMultiple'}}
62
- @selectedOptions={{this.data.fieldComboBoxMultiple}}
63
- @validations={{hash presence=(hash presence=true) length=(hash min=2)}}
64
- @hasNoInitialSelection={{true}}
65
- @options={{array
66
- (hash value='mx' text='Mexico')
67
- (hash value='pt' text='Portugal')
68
- (hash value='us' text='United States')
69
- }}
70
- @label='fieldComboBoxMultiple'
71
- as |option|
72
- >
73
- {{option.text}}
74
- </Form.FieldComboBox>
75
- <Form.FieldRangeSlider
76
- @onChange={{set this.data 'rangeSlider'}}
77
- @value={{this.data.rangeSlider}}
78
- @label='Range slider'
79
- @showLabels={{true}}
80
- @showValue={{true}}
81
- @min={{0}}
82
- @max={{300}}
83
- @validations={{hash
84
- number=(hash gte=0 lte=100 allowString=true)
85
- presence=(hash presence=true)
86
- }}
87
- @required={{true}}
88
- />
89
- <Form.FieldCheckboxGroup
90
- @onChange={{set this.data 'fieldCheckbox'}}
91
- @validations={{hash presence=(hash presence=true) length=(hash min=1)}}
92
- @value={{this.data.fieldCheckbox}}
93
- @options={{array
94
- (hash id='checkbox-1' label='Checkbox 1')
95
- (hash id='checkbox-2' label='Checkbox 2')
96
- (hash id='checkbox-3' label='Checkbox 3')
97
- }}
98
- @label='Checkbox Group'
99
- />
100
- <Form.FieldRadioGroup
101
- @onChange={{set this.data 'fieldRadioGroup'}}
102
- @validations={{hash presence=(hash presence=true)}}
103
- @value={{this.data.fieldRadioGroup}}
104
- @options={{array
105
- (hash id='radio-1' label='Radio 1')
106
- (hash id='radio-2' label='Radio 2')
107
- (hash id='radio-3' label='Radio 3')
108
- }}
109
- @label='Radio Group'
110
- />
111
- <Form.FieldNumber
112
- @value={{this.data.fieldNumber}}
113
- @onChange={{set this.data 'fieldNumber'}}
114
- @validations={{hash number=(hash lt=10 allowString=true)}}
115
- @label='Less than 10'
116
- @errors={{this.data.errors}}
117
- />
118
- <Form.FieldPassword
119
- @value={{this.data.fieldPassword}}
120
- @onChange={{set this.data 'fieldPassword'}}
121
- @validations={{hash presence=(hash presence=true)}}
122
- >
123
- <:label>
124
- Field password
125
- </:label>
126
- </Form.FieldPassword>
127
- <Form.FieldTextArea
128
- @value={{this.data.fieldTextArea}}
129
- @onChange={{set this.data 'fieldTextArea'}}
130
- @validations={{hash length=(hash min=10) presence=(hash presence=true)}}
131
- @label='Field Text minlength 10'
132
- />
133
- <Form.FieldSwitch
134
- @validations={{hash presence=(hash presence=true)}}
135
- @value={{this.data.fieldSwitch}}
136
- @label='Field must be true'
137
- @onChange={{set this.data 'fieldSwitch'}}
138
- />
139
- <Form.FieldNestedForm as |NestedForm|>
140
- <NestedForm.FieldText
141
- @validations={{hash presence=(hash presence=true)}}
142
- @label='Nested form field text'
143
- @value={{this.data.nestedFormFieldText}}
144
- @onChange={{set this.data 'nestedFormFieldText'}}
145
- />
146
- </Form.FieldNestedForm>
147
- <EuiButton @type='submit'>
148
- Submit
149
- </EuiButton>
150
- </ValidatedForm>
151
- ```
152
-
153
- ```js component
154
- import Component from '@glimmer/component';
155
- import { action } from '@ember/object';
156
- import { tracked } from '@glimmer/tracking';
157
- import O from '@ember/object';
158
-
159
- export default class DemoCardComponent extends Component {
160
- @tracked data = O.create({});
161
- }
162
- ```
@@ -1 +0,0 @@
1
- <!-- empty on purpose -->
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,27 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.base.json",
3
- "compilerOptions": {
4
- "baseUrl": ".",
5
- "paths": {
6
- "dummy/tests/*": ["tests/*"],
7
- "@glimmer/tracking": [
8
- "../../node_modules/ember-cached-decorator-polyfill",
9
- "../../node_modules/@glimmer/tracking/dist/types"
10
- ],
11
- "dummy/*": ["tests/dummy/app/*", "app/*"],
12
- "changeset-form": ["addon"],
13
- "changeset-form/*": ["addon/*"],
14
- "changeset-form/test-support": ["addon-test-support"],
15
- "changeset-form/test-support/*": ["addon-test-support/*"],
16
- "*": ["types/*"]
17
- }
18
- },
19
- "include": [
20
- "app/**/*",
21
- "addon/**/*",
22
- "tests/**/*",
23
- "types/**/*",
24
- "test-support/**/*",
25
- "addon-test-support/**/*"
26
- ]
27
- }
@@ -1 +0,0 @@
1
-
package/types/global.d.ts DELETED
@@ -1,22 +0,0 @@
1
- // Types for compiled templates
2
- declare module '@ember-eui/validated-form/templates/*' {
3
- import { TemplateFactory } from 'htmlbars-inline-precompile';
4
- const tmpl: TemplateFactory;
5
- export default tmpl;
6
- }
7
-
8
- interface Validator {
9
- param: string;
10
- message: string;
11
- validate: (value: any, ...params: any[]) => boolean;
12
- }
13
-
14
- type ErrorMessages = Record<string, string>;
15
-
16
- type ExtraError = { message: string } | string;
17
-
18
- interface ValidateableControl {
19
- customValidations?: Array<Validator>;
20
- errorMessages?: ErrorMessages;
21
- errors?: Array<ExtraError>;
22
- }