@toptal/picasso-forms 6.0.4 → 6.0.5

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 (236) hide show
  1. package/CHANGELOG.md +657 -0
  2. package/{Autocomplete → dist-package/Autocomplete}/Autocomplete.d.ts +0 -0
  3. package/{Autocomplete → dist-package/Autocomplete}/Autocomplete.js +0 -0
  4. package/{Autocomplete → dist-package/Autocomplete}/Autocomplete.js.map +0 -0
  5. package/{Autocomplete → dist-package/Autocomplete}/index.d.ts +0 -0
  6. package/{Autocomplete → dist-package/Autocomplete}/index.js +0 -0
  7. package/{Autocomplete → dist-package/Autocomplete}/index.js.map +0 -0
  8. package/{ButtonCheckbox → dist-package/ButtonCheckbox}/ButtonCheckbox.d.ts +0 -0
  9. package/{ButtonCheckbox → dist-package/ButtonCheckbox}/ButtonCheckbox.js +0 -0
  10. package/{ButtonCheckbox → dist-package/ButtonCheckbox}/ButtonCheckbox.js.map +0 -0
  11. package/{ButtonCheckbox → dist-package/ButtonCheckbox}/index.d.ts +0 -0
  12. package/{ButtonCheckbox → dist-package/ButtonCheckbox}/index.js +0 -0
  13. package/{ButtonCheckbox → dist-package/ButtonCheckbox}/index.js.map +0 -0
  14. package/{ButtonRadio → dist-package/ButtonRadio}/ButtonRadio.d.ts +0 -0
  15. package/{ButtonRadio → dist-package/ButtonRadio}/ButtonRadio.js +0 -0
  16. package/{ButtonRadio → dist-package/ButtonRadio}/ButtonRadio.js.map +0 -0
  17. package/{ButtonRadio → dist-package/ButtonRadio}/index.d.ts +0 -0
  18. package/{ButtonRadio → dist-package/ButtonRadio}/index.js +0 -0
  19. package/{ButtonRadio → dist-package/ButtonRadio}/index.js.map +0 -0
  20. package/{Checkbox → dist-package/Checkbox}/Checkbox.d.ts +0 -0
  21. package/{Checkbox → dist-package/Checkbox}/Checkbox.js +0 -0
  22. package/{Checkbox → dist-package/Checkbox}/Checkbox.js.map +0 -0
  23. package/{Checkbox → dist-package/Checkbox}/index.d.ts +0 -0
  24. package/{Checkbox → dist-package/Checkbox}/index.js +0 -0
  25. package/{Checkbox → dist-package/Checkbox}/index.js.map +0 -0
  26. package/{CheckboxGroup → dist-package/CheckboxGroup}/CheckboxGroup.d.ts +0 -0
  27. package/{CheckboxGroup → dist-package/CheckboxGroup}/CheckboxGroup.js +0 -0
  28. package/{CheckboxGroup → dist-package/CheckboxGroup}/CheckboxGroup.js.map +0 -0
  29. package/{CheckboxGroup → dist-package/CheckboxGroup}/CheckboxGroupContext.d.ts +0 -0
  30. package/{CheckboxGroup → dist-package/CheckboxGroup}/CheckboxGroupContext.js +0 -0
  31. package/{CheckboxGroup → dist-package/CheckboxGroup}/CheckboxGroupContext.js.map +0 -0
  32. package/{CheckboxGroup → dist-package/CheckboxGroup}/index.d.ts +0 -0
  33. package/{CheckboxGroup → dist-package/CheckboxGroup}/index.js +0 -0
  34. package/{CheckboxGroup → dist-package/CheckboxGroup}/index.js.map +0 -0
  35. package/{DatePicker → dist-package/DatePicker}/DatePicker.d.ts +0 -0
  36. package/{DatePicker → dist-package/DatePicker}/DatePicker.js +0 -0
  37. package/{DatePicker → dist-package/DatePicker}/DatePicker.js.map +0 -0
  38. package/{DatePicker → dist-package/DatePicker}/index.d.ts +0 -0
  39. package/{DatePicker → dist-package/DatePicker}/index.js +0 -0
  40. package/{DatePicker → dist-package/DatePicker}/index.js.map +0 -0
  41. package/{FieldWrapper → dist-package/FieldWrapper}/FieldWrapper.d.ts +0 -0
  42. package/{FieldWrapper → dist-package/FieldWrapper}/FieldWrapper.js +0 -0
  43. package/{FieldWrapper → dist-package/FieldWrapper}/FieldWrapper.js.map +0 -0
  44. package/{FieldWrapper → dist-package/FieldWrapper}/index.d.ts +0 -0
  45. package/{FieldWrapper → dist-package/FieldWrapper}/index.js +0 -0
  46. package/{FieldWrapper → dist-package/FieldWrapper}/index.js.map +0 -0
  47. package/{FileInput → dist-package/FileInput}/FileInput.d.ts +0 -0
  48. package/{FileInput → dist-package/FileInput}/FileInput.js +0 -0
  49. package/{FileInput → dist-package/FileInput}/FileInput.js.map +0 -0
  50. package/{FileInput → dist-package/FileInput}/index.d.ts +0 -0
  51. package/{FileInput → dist-package/FileInput}/index.js +0 -0
  52. package/{FileInput → dist-package/FileInput}/index.js.map +0 -0
  53. package/{Form → dist-package/Form}/Form.d.ts +0 -0
  54. package/{Form → dist-package/Form}/Form.js +0 -0
  55. package/{Form → dist-package/Form}/Form.js.map +0 -0
  56. package/{Form → dist-package/Form}/FormContext.d.ts +0 -0
  57. package/{Form → dist-package/Form}/FormContext.js +0 -0
  58. package/{Form → dist-package/Form}/FormContext.js.map +0 -0
  59. package/{Form → dist-package/Form}/index.d.ts +0 -0
  60. package/{Form → dist-package/Form}/index.js +0 -0
  61. package/{Form → dist-package/Form}/index.js.map +0 -0
  62. package/{FormConfig → dist-package/FormConfig}/FormConfig.d.ts +0 -0
  63. package/{FormConfig → dist-package/FormConfig}/FormConfig.js +0 -0
  64. package/{FormConfig → dist-package/FormConfig}/FormConfig.js.map +0 -0
  65. package/{FormConfig → dist-package/FormConfig}/index.d.ts +0 -0
  66. package/{FormConfig → dist-package/FormConfig}/index.js +0 -0
  67. package/{FormConfig → dist-package/FormConfig}/index.js.map +0 -0
  68. package/{Input → dist-package/Input}/Input.d.ts +0 -0
  69. package/{Input → dist-package/Input}/Input.js +0 -0
  70. package/{Input → dist-package/Input}/Input.js.map +0 -0
  71. package/{Input → dist-package/Input}/index.d.ts +0 -0
  72. package/{Input → dist-package/Input}/index.js +0 -0
  73. package/{Input → dist-package/Input}/index.js.map +0 -0
  74. package/{Input → dist-package/Input}/utils/get-input-name.d.ts +0 -0
  75. package/{Input → dist-package/Input}/utils/get-input-name.js +0 -0
  76. package/{Input → dist-package/Input}/utils/get-input-name.js.map +0 -0
  77. package/{Input → dist-package/Input}/utils/get-input-name.test.d.ts +0 -0
  78. package/{Input → dist-package/Input}/utils/get-input-name.test.js +0 -0
  79. package/{Input → dist-package/Input}/utils/get-input-name.test.js.map +0 -0
  80. package/{NumberInput → dist-package/NumberInput}/NumberInput.d.ts +0 -0
  81. package/{NumberInput → dist-package/NumberInput}/NumberInput.js +0 -0
  82. package/{NumberInput → dist-package/NumberInput}/NumberInput.js.map +0 -0
  83. package/{NumberInput → dist-package/NumberInput}/index.d.ts +0 -0
  84. package/{NumberInput → dist-package/NumberInput}/index.js +0 -0
  85. package/{NumberInput → dist-package/NumberInput}/index.js.map +0 -0
  86. package/dist-package/README.md +29 -0
  87. package/{Radio → dist-package/Radio}/Radio.d.ts +0 -0
  88. package/{Radio → dist-package/Radio}/Radio.js +0 -0
  89. package/{Radio → dist-package/Radio}/Radio.js.map +0 -0
  90. package/{Radio → dist-package/Radio}/index.d.ts +0 -0
  91. package/{Radio → dist-package/Radio}/index.js +0 -0
  92. package/{Radio → dist-package/Radio}/index.js.map +0 -0
  93. package/{RadioGroup → dist-package/RadioGroup}/RadioGroup.d.ts +0 -0
  94. package/{RadioGroup → dist-package/RadioGroup}/RadioGroup.js +0 -0
  95. package/{RadioGroup → dist-package/RadioGroup}/RadioGroup.js.map +0 -0
  96. package/{RadioGroup → dist-package/RadioGroup}/RadioGroupContext.d.ts +0 -0
  97. package/{RadioGroup → dist-package/RadioGroup}/RadioGroupContext.js +0 -0
  98. package/{RadioGroup → dist-package/RadioGroup}/RadioGroupContext.js.map +0 -0
  99. package/{RadioGroup → dist-package/RadioGroup}/index.d.ts +0 -0
  100. package/{RadioGroup → dist-package/RadioGroup}/index.js +0 -0
  101. package/{RadioGroup → dist-package/RadioGroup}/index.js.map +0 -0
  102. package/{Rating → dist-package/Rating}/Rating.d.ts +0 -0
  103. package/{Rating → dist-package/Rating}/Rating.js +0 -0
  104. package/{Rating → dist-package/Rating}/Rating.js.map +0 -0
  105. package/{Rating → dist-package/Rating}/index.d.ts +0 -0
  106. package/{Rating → dist-package/Rating}/index.js +0 -0
  107. package/{Rating → dist-package/Rating}/index.js.map +0 -0
  108. package/{Select → dist-package/Select}/Select.d.ts +0 -0
  109. package/{Select → dist-package/Select}/Select.js +0 -0
  110. package/{Select → dist-package/Select}/Select.js.map +0 -0
  111. package/{Select → dist-package/Select}/index.d.ts +0 -0
  112. package/{Select → dist-package/Select}/index.js +0 -0
  113. package/{Select → dist-package/Select}/index.js.map +0 -0
  114. package/{SubmitButton → dist-package/SubmitButton}/SubmitButton.d.ts +0 -0
  115. package/{SubmitButton → dist-package/SubmitButton}/SubmitButton.js +0 -0
  116. package/{SubmitButton → dist-package/SubmitButton}/SubmitButton.js.map +0 -0
  117. package/{SubmitButton → dist-package/SubmitButton}/index.d.ts +0 -0
  118. package/{SubmitButton → dist-package/SubmitButton}/index.js +0 -0
  119. package/{SubmitButton → dist-package/SubmitButton}/index.js.map +0 -0
  120. package/{Switch → dist-package/Switch}/Switch.d.ts +0 -0
  121. package/{Switch → dist-package/Switch}/Switch.js +0 -0
  122. package/{Switch → dist-package/Switch}/Switch.js.map +0 -0
  123. package/{Switch → dist-package/Switch}/index.d.ts +0 -0
  124. package/{Switch → dist-package/Switch}/index.js +0 -0
  125. package/{Switch → dist-package/Switch}/index.js.map +0 -0
  126. package/{TagSelector → dist-package/TagSelector}/TagSelector.d.ts +0 -0
  127. package/{TagSelector → dist-package/TagSelector}/TagSelector.js +0 -0
  128. package/{TagSelector → dist-package/TagSelector}/TagSelector.js.map +0 -0
  129. package/{TagSelector → dist-package/TagSelector}/index.d.ts +0 -0
  130. package/{TagSelector → dist-package/TagSelector}/index.js +0 -0
  131. package/{TagSelector → dist-package/TagSelector}/index.js.map +0 -0
  132. package/{TimePicker → dist-package/TimePicker}/TimePicker.d.ts +0 -0
  133. package/{TimePicker → dist-package/TimePicker}/TimePicker.js +0 -0
  134. package/{TimePicker → dist-package/TimePicker}/TimePicker.js.map +0 -0
  135. package/{TimePicker → dist-package/TimePicker}/index.d.ts +0 -0
  136. package/{TimePicker → dist-package/TimePicker}/index.js +0 -0
  137. package/{TimePicker → dist-package/TimePicker}/index.js.map +0 -0
  138. package/{index.d.ts → dist-package/index.d.ts} +2 -1
  139. package/{index.js → dist-package/index.js} +0 -1
  140. package/dist-package/index.js.map +1 -0
  141. package/dist-package/package.json +44 -0
  142. package/{utils → dist-package/utils}/flat-map.d.ts +0 -0
  143. package/{utils → dist-package/utils}/flat-map.js +0 -0
  144. package/{utils → dist-package/utils}/flat-map.js.map +0 -0
  145. package/{utils → dist-package/utils}/index.d.ts +0 -0
  146. package/{utils → dist-package/utils}/index.js +0 -0
  147. package/{utils → dist-package/utils}/index.js.map +0 -0
  148. package/{utils → dist-package/utils}/scroll-to-error-decorator.d.ts +0 -0
  149. package/{utils → dist-package/utils}/scroll-to-error-decorator.js +0 -0
  150. package/{utils → dist-package/utils}/scroll-to-error-decorator.js.map +0 -0
  151. package/{utils → dist-package/utils}/validators.d.ts +0 -0
  152. package/{utils → dist-package/utils}/validators.js +0 -0
  153. package/{utils → dist-package/utils}/validators.js.map +0 -0
  154. package/package.json +4 -5
  155. package/src/Autocomplete/Autocomplete.tsx +21 -0
  156. package/src/Autocomplete/index.ts +1 -0
  157. package/src/ButtonCheckbox/ButtonCheckbox.tsx +57 -0
  158. package/src/ButtonCheckbox/index.ts +1 -0
  159. package/src/ButtonRadio/ButtonRadio.tsx +24 -0
  160. package/src/ButtonRadio/index.ts +1 -0
  161. package/src/Checkbox/Checkbox.tsx +73 -0
  162. package/src/Checkbox/__snapshots__/test.tsx.snap +254 -0
  163. package/src/Checkbox/index.ts +1 -0
  164. package/src/Checkbox/test.tsx +91 -0
  165. package/src/CheckboxGroup/CheckboxGroup.tsx +30 -0
  166. package/src/CheckboxGroup/CheckboxGroupContext.ts +3 -0
  167. package/src/CheckboxGroup/index.ts +3 -0
  168. package/src/CheckboxGroup/test.tsx +35 -0
  169. package/src/DatePicker/DatePicker.tsx +26 -0
  170. package/src/DatePicker/index.ts +1 -0
  171. package/src/FieldWrapper/FieldWrapper.tsx +287 -0
  172. package/src/FieldWrapper/index.ts +2 -0
  173. package/src/FieldWrapper/story/index.jsx +137 -0
  174. package/src/FileInput/FileInput.tsx +66 -0
  175. package/src/FileInput/index.ts +1 -0
  176. package/src/Form/Form.tsx +181 -0
  177. package/src/Form/FormContext.ts +38 -0
  178. package/src/Form/__image_snapshots__/form-default-snap.png +0 -0
  179. package/src/Form/__image_snapshots__/form-form-level-configurations-snap.png +0 -0
  180. package/src/Form/__snapshots__/test.tsx.snap +61 -0
  181. package/src/Form/index.ts +1 -0
  182. package/src/Form/story/BackendCommunication.example.tsx +139 -0
  183. package/src/Form/story/CustomFormLevelConfiguration.example.tsx +26 -0
  184. package/src/Form/story/CustomValidator.example.tsx +45 -0
  185. package/src/Form/story/Default.example.tsx +177 -0
  186. package/src/Form/story/FileInput.example.tsx +42 -0
  187. package/src/Form/story/ParseInput.example.tsx +28 -0
  188. package/src/Form/story/TitleCase.example.tsx +167 -0
  189. package/src/Form/story/ValidateOnSubmit.example.tsx +85 -0
  190. package/src/Form/story/index.jsx +203 -0
  191. package/src/Form/test.tsx +27 -0
  192. package/src/FormConfig/FormConfig.ts +12 -0
  193. package/src/FormConfig/index.ts +1 -0
  194. package/src/FormConfig/test.tsx +44 -0
  195. package/src/Input/Input.tsx +27 -0
  196. package/src/Input/index.ts +1 -0
  197. package/src/Input/test.tsx +34 -0
  198. package/src/Input/utils/get-input-name.test.ts +16 -0
  199. package/src/Input/utils/get-input-name.ts +11 -0
  200. package/src/NumberInput/NumberInput.tsx +45 -0
  201. package/src/NumberInput/index.ts +1 -0
  202. package/src/Radio/Radio.tsx +24 -0
  203. package/src/Radio/__snapshots__/test.tsx.snap +231 -0
  204. package/src/Radio/index.ts +1 -0
  205. package/src/Radio/test.tsx +49 -0
  206. package/src/RadioGroup/RadioGroup.tsx +39 -0
  207. package/src/RadioGroup/RadioGroupContext.ts +3 -0
  208. package/src/RadioGroup/index.ts +3 -0
  209. package/src/RadioGroup/test.tsx +35 -0
  210. package/src/Rating/Rating.tsx +22 -0
  211. package/src/Rating/index.ts +1 -0
  212. package/src/Select/Select.tsx +47 -0
  213. package/src/Select/index.ts +1 -0
  214. package/src/SubmitButton/SubmitButton.tsx +70 -0
  215. package/src/SubmitButton/__image_snapshots__/submitbutton-button-types-snap.png +0 -0
  216. package/src/SubmitButton/__image_snapshots__/submitbutton-default-snap.png +0 -0
  217. package/src/SubmitButton/index.ts +6 -0
  218. package/src/SubmitButton/story/ButtonTypes.example.tsx +46 -0
  219. package/src/SubmitButton/story/Default.example.tsx +15 -0
  220. package/src/SubmitButton/story/index.jsx +32 -0
  221. package/src/Switch/Switch.tsx +23 -0
  222. package/src/Switch/index.ts +1 -0
  223. package/src/TagSelector/TagSelector.tsx +25 -0
  224. package/src/TagSelector/index.ts +1 -0
  225. package/src/TimePicker/TimePicker.tsx +24 -0
  226. package/src/TimePicker/index.ts +1 -0
  227. package/src/index.ts +16 -0
  228. package/src/story/Deserialization.example.tsx +34 -0
  229. package/src/story/FormSpy.example.tsx +42 -0
  230. package/src/story/index.jsx +37 -0
  231. package/src/utils/flat-map.ts +4 -0
  232. package/src/utils/index.ts +3 -0
  233. package/src/utils/scroll-to-error-decorator.ts +78 -0
  234. package/src/utils/validators.ts +18 -0
  235. package/tsconfig.build.json +7 -0
  236. package/index.js.map +0 -1
@@ -0,0 +1,231 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`FormRadio renders 1`] = `
4
+ <div>
5
+ <div
6
+ class="Picasso-root"
7
+ >
8
+ <div
9
+ class=""
10
+ >
11
+ <form>
12
+ <div
13
+ class="PicassoFormField-root"
14
+ data-field-has-error="false"
15
+ >
16
+ <label
17
+ class="PicassoFormLabel-root"
18
+ for="color"
19
+ >
20
+ <span
21
+ class="PicassoFormLabel-text"
22
+ >
23
+ What's your favorite color?
24
+ (optional)
25
+ </span>
26
+ </label>
27
+ <div
28
+ class="MuiFormGroup-root"
29
+ id="color"
30
+ role="radiogroup"
31
+ type="radio"
32
+ >
33
+ <div
34
+ class="MuiGrid-root PicassoRadioGroup-grid MuiGrid-container PicassoGrid-container MuiGrid-direction-xs MuiGrid-align-items-xs-flex"
35
+ >
36
+ <div
37
+ class="MuiGrid-root PicassoRadioGroup-gridItem MuiGrid-item"
38
+ >
39
+ <label
40
+ class="PicassoFormControlLabel-root Radio-root Radio-labelWithRightSpacing"
41
+ >
42
+ <span
43
+ aria-disabled="false"
44
+ class="MuiButtonBase-root MuiIconButton-root PrivateSwitchBase-root MuiRadio-root Radio-root Radio-withLabel"
45
+ >
46
+ <span
47
+ class="MuiIconButton-label"
48
+ >
49
+ <input
50
+ class="PrivateSwitchBase-input"
51
+ name="color"
52
+ type="radio"
53
+ value="#ed143d"
54
+ />
55
+ <div
56
+ class="Radio-uncheckedIcon"
57
+ />
58
+ </span>
59
+ </span>
60
+ <span
61
+ class="PicassoFormLabel-root PicassoFormLabel-inline PicassoFormControlLabel-label Radio-label"
62
+ >
63
+ <span
64
+ class="PicassoFormLabel-text"
65
+ >
66
+ Crimson
67
+ </span>
68
+ </span>
69
+ </label>
70
+ </div>
71
+ <div
72
+ class="MuiGrid-root PicassoRadioGroup-gridItem MuiGrid-item"
73
+ >
74
+ <label
75
+ class="PicassoFormControlLabel-root Radio-root Radio-labelWithRightSpacing"
76
+ >
77
+ <span
78
+ aria-disabled="false"
79
+ class="MuiButtonBase-root MuiIconButton-root PrivateSwitchBase-root MuiRadio-root Radio-root Radio-withLabel PrivateSwitchBase-checked Mui-checked"
80
+ >
81
+ <span
82
+ class="MuiIconButton-label"
83
+ >
84
+ <input
85
+ checked=""
86
+ class="PrivateSwitchBase-input"
87
+ name="color"
88
+ type="radio"
89
+ value="#ffe4b5"
90
+ />
91
+ <div
92
+ class="Radio-checkedIcon"
93
+ />
94
+ </span>
95
+ </span>
96
+ <span
97
+ class="PicassoFormLabel-root PicassoFormLabel-inline PicassoFormControlLabel-label Radio-label"
98
+ >
99
+ <span
100
+ class="PicassoFormLabel-text"
101
+ >
102
+ Moccasin
103
+ </span>
104
+ </span>
105
+ </label>
106
+ </div>
107
+ </div>
108
+ </div>
109
+ </div>
110
+ </form>
111
+ </div>
112
+ </div>
113
+ </div>
114
+ `;
115
+
116
+ exports[`FormRadio required with asterisk 1`] = `
117
+ <div>
118
+ <div
119
+ class="Picasso-root"
120
+ >
121
+ <div
122
+ class=""
123
+ >
124
+ <form>
125
+ <div
126
+ class="PicassoFormField-root"
127
+ data-field-has-error="false"
128
+ >
129
+ <label
130
+ class="PicassoFormLabel-root"
131
+ for="color"
132
+ >
133
+ <span
134
+ class="PicassoFormLabel-asterisk"
135
+ >
136
+ *
137
+ </span>
138
+ <span
139
+ class="PicassoFormLabel-text"
140
+ >
141
+ What's your favorite color?
142
+ </span>
143
+ </label>
144
+ <div
145
+ class="MuiFormGroup-root"
146
+ id="color"
147
+ role="radiogroup"
148
+ type="radio"
149
+ >
150
+ <div
151
+ class="MuiGrid-root PicassoRadioGroup-grid MuiGrid-container PicassoGrid-container MuiGrid-direction-xs MuiGrid-align-items-xs-flex"
152
+ >
153
+ <div
154
+ class="MuiGrid-root PicassoRadioGroup-gridItem MuiGrid-item"
155
+ >
156
+ <label
157
+ class="PicassoFormControlLabel-root Radio-root Radio-labelWithRightSpacing"
158
+ >
159
+ <span
160
+ aria-disabled="false"
161
+ class="MuiButtonBase-root MuiIconButton-root PrivateSwitchBase-root MuiRadio-root Radio-root Radio-withLabel"
162
+ >
163
+ <span
164
+ class="MuiIconButton-label"
165
+ >
166
+ <input
167
+ class="PrivateSwitchBase-input"
168
+ name="color"
169
+ type="radio"
170
+ value="#ed143d"
171
+ />
172
+ <div
173
+ class="Radio-uncheckedIcon"
174
+ />
175
+ </span>
176
+ </span>
177
+ <span
178
+ class="PicassoFormLabel-root PicassoFormLabel-inline PicassoFormControlLabel-label Radio-label"
179
+ >
180
+ <span
181
+ class="PicassoFormLabel-text"
182
+ >
183
+ Crimson
184
+ </span>
185
+ </span>
186
+ </label>
187
+ </div>
188
+ <div
189
+ class="MuiGrid-root PicassoRadioGroup-gridItem MuiGrid-item"
190
+ >
191
+ <label
192
+ class="PicassoFormControlLabel-root Radio-root Radio-labelWithRightSpacing"
193
+ >
194
+ <span
195
+ aria-disabled="false"
196
+ class="MuiButtonBase-root MuiIconButton-root PrivateSwitchBase-root MuiRadio-root Radio-root Radio-withLabel PrivateSwitchBase-checked Mui-checked"
197
+ >
198
+ <span
199
+ class="MuiIconButton-label"
200
+ >
201
+ <input
202
+ checked=""
203
+ class="PrivateSwitchBase-input"
204
+ name="color"
205
+ type="radio"
206
+ value="#ffe4b5"
207
+ />
208
+ <div
209
+ class="Radio-checkedIcon"
210
+ />
211
+ </span>
212
+ </span>
213
+ <span
214
+ class="PicassoFormLabel-root PicassoFormLabel-inline PicassoFormControlLabel-label Radio-label"
215
+ >
216
+ <span
217
+ class="PicassoFormLabel-text"
218
+ >
219
+ Moccasin
220
+ </span>
221
+ </span>
222
+ </label>
223
+ </div>
224
+ </div>
225
+ </div>
226
+ </div>
227
+ </form>
228
+ </div>
229
+ </div>
230
+ </div>
231
+ `;
@@ -0,0 +1 @@
1
+ export { default } from './Radio'
@@ -0,0 +1,49 @@
1
+ import React from 'react'
2
+ import { render } from '@toptal/picasso/test-utils'
3
+
4
+ import { FormConfigProps } from '../FormConfig'
5
+ import Form from '../Form'
6
+ import { Props as RadioGroupProps } from '../RadioGroup'
7
+
8
+ const renderFormRadio = (
9
+ { required, name }: RadioGroupProps,
10
+ formConfig: FormConfigProps = {}
11
+ ) =>
12
+ render(
13
+ <Form.ConfigProvider value={formConfig}>
14
+ <Form onSubmit={() => {}} initialValues={{ color: '#ffe4b5' }}>
15
+ <Form.RadioGroup
16
+ name={name}
17
+ label="What's your favorite color?"
18
+ required={required}
19
+ >
20
+ <Form.Radio label='Crimson' value='#ed143d' />
21
+ <Form.Radio label='Moccasin' value='#ffe4b5' />
22
+ </Form.RadioGroup>
23
+ </Form>
24
+ </Form.ConfigProvider>
25
+ )
26
+
27
+ describe('FormRadio', () => {
28
+ it('renders', () => {
29
+ const { container } = renderFormRadio({
30
+ name: 'color'
31
+ })
32
+
33
+ expect(container).toMatchSnapshot()
34
+ })
35
+
36
+ it('required with asterisk', () => {
37
+ const { container } = renderFormRadio(
38
+ {
39
+ name: 'color',
40
+ required: true
41
+ },
42
+ {
43
+ requiredVariant: 'asterisk'
44
+ }
45
+ )
46
+
47
+ expect(container).toMatchSnapshot()
48
+ })
49
+ })
@@ -0,0 +1,39 @@
1
+ import React from 'react'
2
+ import {
3
+ Radio as PicassoRadio,
4
+ RadioProps,
5
+ RadioGroupProps
6
+ } from '@toptal/picasso'
7
+
8
+ import FieldWrapper, { FieldProps } from '../FieldWrapper'
9
+ import RadioGroupContext from './RadioGroupContext'
10
+
11
+ export type Props = RadioGroupProps & FieldProps<RadioProps['value']>
12
+
13
+ export const RadioGroup = (props: Props) => {
14
+ const { children, ...rest } = props
15
+
16
+ return (
17
+ <RadioGroupContext.Provider value={props.name}>
18
+ {}
19
+ <FieldWrapper {...rest} type='radio'>
20
+ {radioGroupProps => {
21
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
22
+ const { error, ...restRadioGroupProps } = radioGroupProps
23
+
24
+ return (
25
+ <PicassoRadio.Group {...restRadioGroupProps}>
26
+ {children}
27
+ </PicassoRadio.Group>
28
+ )
29
+ }}
30
+ </FieldWrapper>
31
+ </RadioGroupContext.Provider>
32
+ )
33
+ }
34
+
35
+ RadioGroup.defaultProps = {}
36
+
37
+ RadioGroup.displayName = 'RadioGroup'
38
+
39
+ export default RadioGroup
@@ -0,0 +1,3 @@
1
+ import { createContext } from 'react'
2
+
3
+ export default createContext<string | undefined>(undefined)
@@ -0,0 +1,3 @@
1
+ export { default } from './RadioGroup'
2
+ export { default as RadioGroupContext } from './RadioGroupContext'
3
+ export type { Props } from './RadioGroup'
@@ -0,0 +1,35 @@
1
+ import { render } from '@toptal/picasso/test-utils'
2
+ import React from 'react'
3
+
4
+ import Radio from '../Radio'
5
+ import Form from '../Form'
6
+ import RadioGroup, { Props } from './RadioGroup'
7
+
8
+ const arrangeTest = ({ titleCase }: Partial<Props> = {}) =>
9
+ render(
10
+ <Form onSubmit={() => {}}>
11
+ <RadioGroup
12
+ required
13
+ name='radio-group'
14
+ label='Radio group label'
15
+ titleCase={titleCase}
16
+ >
17
+ <Radio label='radio-label-0' value='radio-value-0' />
18
+ <Radio label='radio-label-1' value='radio-value-1' />
19
+ </RadioGroup>
20
+ </Form>
21
+ )
22
+
23
+ describe('RadioGroup', () => {
24
+ it('shows the label in default case', () => {
25
+ const { getByText } = arrangeTest()
26
+
27
+ expect(getByText('Radio group label')).toBeInTheDocument()
28
+ })
29
+
30
+ it('shows the label in title case', () => {
31
+ const { getByText } = arrangeTest({ titleCase: true })
32
+
33
+ expect(getByText('Radio Group Label')).toBeInTheDocument()
34
+ })
35
+ })
@@ -0,0 +1,22 @@
1
+ import React from 'react'
2
+ import { Rating as PicassoRating, RatingProps } from '@toptal/picasso'
3
+
4
+ import FieldWrapper, { FieldProps } from '../FieldWrapper'
5
+
6
+ export type Props = RatingProps & FieldProps<RatingProps['value']>
7
+
8
+ export const Rating = (props: Props) => (
9
+ // eslint-disable-next-line react/jsx-props-no-spreading
10
+ <FieldWrapper<RatingProps> {...props} type='number'>
11
+ {(inputProps: RatingProps) => {
12
+ // eslint-disable-next-line react/jsx-props-no-spreading
13
+ return <PicassoRating {...inputProps} />
14
+ }}
15
+ </FieldWrapper>
16
+ )
17
+
18
+ Rating.defaultProps = {}
19
+
20
+ Rating.displayName = 'Rating'
21
+
22
+ export default Rating
@@ -0,0 +1 @@
1
+ export { default } from './Rating'
@@ -0,0 +1,47 @@
1
+ import React from 'react'
2
+ import {
3
+ Select as PicassoSelect,
4
+ SelectProps,
5
+ SelectValueType
6
+ } from '@toptal/picasso'
7
+ import { generateRandomStringOrGetEmptyInTest } from '@toptal/picasso/utils'
8
+
9
+ import FieldWrapper, { FieldProps } from '../FieldWrapper'
10
+
11
+ export type Props<
12
+ T extends SelectValueType,
13
+ M extends boolean = false
14
+ > = SelectProps<T, M> & FieldProps<SelectProps<T, M>['value']>
15
+
16
+ export const Select = <T extends SelectValueType, M extends boolean = false>({
17
+ name,
18
+ id = name,
19
+ ...rest
20
+ }: Props<T, M>) => {
21
+ const randomizedId = id ? generateRandomStringOrGetEmptyInTest(id) : undefined
22
+
23
+ return (
24
+ <FieldWrapper<SelectProps<any, any>>
25
+ {...rest}
26
+ name={name}
27
+ id={randomizedId}
28
+ >
29
+ {(selectProps: SelectProps) => {
30
+ return (
31
+ <PicassoSelect
32
+ {...selectProps}
33
+ id={randomizedId}
34
+ // if `id` is specified, we have to provide a not correct value for autoComplete, e.g. `none` to trick google chrome
35
+ autoComplete={id ? 'none' : rest.autoComplete || 'off'}
36
+ />
37
+ )
38
+ }}
39
+ </FieldWrapper>
40
+ )
41
+ }
42
+
43
+ Select.defaultProps = {}
44
+
45
+ Select.displayName = 'Select'
46
+
47
+ export default Select
@@ -0,0 +1 @@
1
+ export { default } from './Select'
@@ -0,0 +1,70 @@
1
+ import React, { ReactNode } from 'react'
2
+ import { Button, ButtonProps } from '@toptal/picasso'
3
+ import { useFormState } from 'react-final-form'
4
+ import { ButtonCircularProps } from '@toptal/picasso/ButtonCircular'
5
+
6
+ type ButtonTypeProps = {
7
+ buttonType: 'rectangular'
8
+ variant?: ButtonProps['variant']
9
+ children: ReactNode
10
+ }
11
+
12
+ type CircularButtonTypeProps = {
13
+ buttonType: 'circular'
14
+ variant?: ButtonCircularProps['variant']
15
+ }
16
+
17
+ type ActionButtonTypeProps = {
18
+ buttonType: 'action'
19
+ variant?: null
20
+ children?: ReactNode
21
+ }
22
+
23
+ // Intersection with the type { id?: string } is needed here because of
24
+ // TS compiler issue https://github.com/microsoft/TypeScript/issues/34793
25
+ export type Props = Omit<ButtonProps, 'type' | 'variant' | 'children'> & {
26
+ id?: string
27
+ } & (CircularButtonTypeProps | ActionButtonTypeProps | ButtonTypeProps)
28
+
29
+ export const SubmitButton = ({
30
+ buttonType,
31
+ variant,
32
+ ...restOfProps
33
+ }: Props) => {
34
+ /* eslint-disable react/jsx-props-no-spreading */
35
+ const { submitting } = useFormState({ subscription: { submitting: true } })
36
+
37
+ const submitButtonProps = {
38
+ type: 'submit' as const,
39
+ loading: submitting
40
+ }
41
+
42
+ const resultComponentProps = { ...submitButtonProps, ...restOfProps }
43
+
44
+ switch (buttonType) {
45
+ case 'circular':
46
+ return (
47
+ <Button.Circular
48
+ {...resultComponentProps}
49
+ variant={variant as ButtonCircularProps['variant']}
50
+ />
51
+ )
52
+ case 'action':
53
+ return <Button.Action {...resultComponentProps} />
54
+ default:
55
+ return (
56
+ <Button
57
+ {...resultComponentProps}
58
+ variant={variant as ButtonProps['variant']}
59
+ />
60
+ )
61
+ }
62
+ }
63
+
64
+ SubmitButton.defaultProps = {
65
+ buttonType: 'rectangular'
66
+ }
67
+
68
+ SubmitButton.displayName = 'SubmitButton'
69
+
70
+ export default SubmitButton
@@ -0,0 +1,6 @@
1
+ import { Props } from './SubmitButton'
2
+
3
+ export { default } from './SubmitButton'
4
+
5
+ export type SubmitButtonProps = Props
6
+ export * from './SubmitButton'
@@ -0,0 +1,46 @@
1
+ import React from 'react'
2
+ import { Check16, Container, Typography } from '@toptal/picasso'
3
+ import { Form } from '@toptal/picasso-forms'
4
+
5
+ const onSubmit = () => new Promise(resolve => setTimeout(resolve, 1000))
6
+
7
+ const Example = () => (
8
+ <>
9
+ <Typography variant='heading' size='small'>
10
+ Rectangular (Default)
11
+ </Typography>
12
+ <Container top='small' bottom='large'>
13
+ <Form onSubmit={onSubmit}>
14
+ <Container top='small'>
15
+ <Form.SubmitButton buttonType='rectangular'>
16
+ Rectangular
17
+ </Form.SubmitButton>
18
+ </Container>
19
+ </Form>
20
+ </Container>
21
+
22
+ <Typography variant='heading' size='small'>
23
+ Circular
24
+ </Typography>
25
+ <Container top='small' bottom='large'>
26
+ <Form onSubmit={onSubmit}>
27
+ <Container top='small'>
28
+ <Form.SubmitButton buttonType='circular' icon={<Check16 />} />
29
+ </Container>
30
+ </Form>
31
+ </Container>
32
+
33
+ <Typography variant='heading' size='small'>
34
+ Action
35
+ </Typography>
36
+ <Container top='small' bottom='large'>
37
+ <Form onSubmit={onSubmit}>
38
+ <Container top='small'>
39
+ <Form.SubmitButton buttonType='action'>Action</Form.SubmitButton>
40
+ </Container>
41
+ </Form>
42
+ </Container>
43
+ </>
44
+ )
45
+
46
+ export default Example
@@ -0,0 +1,15 @@
1
+ import React from 'react'
2
+ import { Container } from '@toptal/picasso'
3
+ import { Form } from '@toptal/picasso-forms'
4
+
5
+ const onSubmit = () => new Promise(resolve => setTimeout(resolve, 1000))
6
+
7
+ const Example = () => (
8
+ <Form onSubmit={onSubmit}>
9
+ <Container top='small'>
10
+ <Form.SubmitButton>Submit form</Form.SubmitButton>
11
+ </Container>
12
+ </Form>
13
+ )
14
+
15
+ export default Example
@@ -0,0 +1,32 @@
1
+ import SubmitButton from '../SubmitButton'
2
+ import PicassoBook from '~/.storybook/components/PicassoBook'
3
+
4
+ const page = PicassoBook.section('Picasso Forms').createPage(
5
+ 'SubmitButton',
6
+ 'SubmitButton reacts to the submission state of the form.'
7
+ )
8
+
9
+ page.createTabChapter('Props').addComponentDocs({
10
+ component: SubmitButton,
11
+ name: 'SubmitButton',
12
+ additionalDocs: {
13
+ buttonType: {
14
+ name: 'buttonType',
15
+ type: 'string',
16
+ description: 'The button type to use',
17
+ defaultValue: 'rectangular',
18
+ enums: ['rectangular', 'circular', 'action']
19
+ },
20
+ variant: {
21
+ name: 'variant',
22
+ type: 'string',
23
+ description:
24
+ 'The variant to use. Depending on the "buttonType" property value, the "variant" property accepts circular or action button "variant" property values.'
25
+ }
26
+ }
27
+ })
28
+
29
+ page
30
+ .createChapter()
31
+ .addExample('SubmitButton/story/Default.example.tsx', 'Default')
32
+ .addExample('SubmitButton/story/ButtonTypes.example.tsx', 'Button types')
@@ -0,0 +1,23 @@
1
+ import React from 'react'
2
+ import { Switch as PicassoSwitch, SwitchProps } from '@toptal/picasso'
3
+
4
+ import FieldWrapper, { FieldProps } from '../FieldWrapper'
5
+
6
+ export type FormSwitchProps = Omit<SwitchProps, 'onChange'> & {
7
+ onChange?: SwitchProps['onChange']
8
+ }
9
+ export type Props = FormSwitchProps & FieldProps<SwitchProps['value']>
10
+
11
+ export const Switch = (props: Props) => (
12
+ <FieldWrapper<FormSwitchProps> hideLabelRequiredDecoration {...props}>
13
+ {(inputProps: SwitchProps) => {
14
+ return <PicassoSwitch {...inputProps} />
15
+ }}
16
+ </FieldWrapper>
17
+ )
18
+
19
+ Switch.defaultProps = {}
20
+
21
+ Switch.displayName = 'Switch'
22
+
23
+ export default Switch
@@ -0,0 +1 @@
1
+ export { default } from './Switch'
@@ -0,0 +1,25 @@
1
+ import React from 'react'
2
+ import {
3
+ TagSelector as PicassoTagSelector,
4
+ TagSelectorProps
5
+ } from '@toptal/picasso'
6
+
7
+ import FieldWrapper, { FieldProps } from '../FieldWrapper'
8
+
9
+ export type Props = TagSelectorProps & FieldProps<TagSelectorProps['value']>
10
+
11
+ export const TagSelector = (props: Props) => (
12
+ <FieldWrapper<TagSelectorProps> {...props}>
13
+ {(inputProps: TagSelectorProps) => {
14
+ return <PicassoTagSelector {...inputProps} />
15
+ }}
16
+ </FieldWrapper>
17
+ )
18
+
19
+ TagSelector.defaultProps = {
20
+ initialValue: []
21
+ }
22
+
23
+ TagSelector.displayName = 'TagSelector'
24
+
25
+ export default TagSelector
@@ -0,0 +1 @@
1
+ export { default } from './TagSelector'