@toptal/picasso-forms 66.3.2 → 67.0.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 (552) hide show
  1. package/{Autocomplete → dist-package/src/Autocomplete}/Autocomplete.d.ts +1 -0
  2. package/dist-package/src/Autocomplete/Autocomplete.d.ts.map +1 -0
  3. package/dist-package/src/Autocomplete/Autocomplete.js.map +1 -0
  4. package/{Autocomplete → dist-package/src/Autocomplete}/index.d.ts +1 -0
  5. package/dist-package/src/Autocomplete/index.d.ts.map +1 -0
  6. package/dist-package/src/Autocomplete/index.js.map +1 -0
  7. package/{AvatarUpload → dist-package/src/AvatarUpload}/AvatarUpload.d.ts +1 -0
  8. package/dist-package/src/AvatarUpload/AvatarUpload.d.ts.map +1 -0
  9. package/dist-package/src/AvatarUpload/AvatarUpload.js.map +1 -0
  10. package/{AvatarUpload → dist-package/src/AvatarUpload}/index.d.ts +1 -0
  11. package/dist-package/src/AvatarUpload/index.d.ts.map +1 -0
  12. package/dist-package/src/AvatarUpload/index.js.map +1 -0
  13. package/{ButtonCheckbox → dist-package/src/ButtonCheckbox}/ButtonCheckbox.d.ts +1 -0
  14. package/dist-package/src/ButtonCheckbox/ButtonCheckbox.d.ts.map +1 -0
  15. package/dist-package/src/ButtonCheckbox/ButtonCheckbox.js.map +1 -0
  16. package/{ButtonCheckbox → dist-package/src/ButtonCheckbox}/index.d.ts +1 -0
  17. package/dist-package/src/ButtonCheckbox/index.d.ts.map +1 -0
  18. package/dist-package/src/ButtonCheckbox/index.js.map +1 -0
  19. package/{ButtonRadio → dist-package/src/ButtonRadio}/ButtonRadio.d.ts +1 -0
  20. package/dist-package/src/ButtonRadio/ButtonRadio.d.ts.map +1 -0
  21. package/dist-package/src/ButtonRadio/ButtonRadio.js.map +1 -0
  22. package/{ButtonRadio → dist-package/src/ButtonRadio}/index.d.ts +1 -0
  23. package/dist-package/src/ButtonRadio/index.d.ts.map +1 -0
  24. package/dist-package/src/ButtonRadio/index.js.map +1 -0
  25. package/{Checkbox → dist-package/src/Checkbox}/Checkbox.d.ts +1 -0
  26. package/dist-package/src/Checkbox/Checkbox.d.ts.map +1 -0
  27. package/dist-package/src/Checkbox/Checkbox.js.map +1 -0
  28. package/dist-package/src/Checkbox/index.d.ts +3 -0
  29. package/dist-package/src/Checkbox/index.d.ts.map +1 -0
  30. package/dist-package/src/Checkbox/index.js.map +1 -0
  31. package/{CheckboxGroup → dist-package/src/CheckboxGroup}/CheckboxGroup.d.ts +1 -0
  32. package/dist-package/src/CheckboxGroup/CheckboxGroup.d.ts.map +1 -0
  33. package/dist-package/src/CheckboxGroup/CheckboxGroup.js.map +1 -0
  34. package/{CheckboxGroup → dist-package/src/CheckboxGroup}/CheckboxGroupContext.d.ts +1 -0
  35. package/dist-package/src/CheckboxGroup/CheckboxGroupContext.d.ts.map +1 -0
  36. package/dist-package/src/CheckboxGroup/CheckboxGroupContext.js.map +1 -0
  37. package/{CheckboxGroup → dist-package/src/CheckboxGroup}/index.d.ts +1 -0
  38. package/dist-package/src/CheckboxGroup/index.d.ts.map +1 -0
  39. package/dist-package/src/CheckboxGroup/index.js.map +1 -0
  40. package/{DatePicker → dist-package/src/DatePicker}/DatePicker.d.ts +1 -0
  41. package/dist-package/src/DatePicker/DatePicker.d.ts.map +1 -0
  42. package/dist-package/src/DatePicker/DatePicker.js.map +1 -0
  43. package/{DatePicker → dist-package/src/DatePicker}/index.d.ts +1 -0
  44. package/dist-package/src/DatePicker/index.d.ts.map +1 -0
  45. package/dist-package/src/DatePicker/index.js.map +1 -0
  46. package/{Dropzone → dist-package/src/Dropzone}/Dropzone.d.ts +1 -0
  47. package/dist-package/src/Dropzone/Dropzone.d.ts.map +1 -0
  48. package/dist-package/src/Dropzone/Dropzone.js.map +1 -0
  49. package/{Dropzone → dist-package/src/Dropzone}/index.d.ts +1 -0
  50. package/dist-package/src/Dropzone/index.d.ts.map +1 -0
  51. package/dist-package/src/Dropzone/index.js.map +1 -0
  52. package/{Field → dist-package/src/Field}/Field.d.ts +1 -0
  53. package/dist-package/src/Field/Field.d.ts.map +1 -0
  54. package/dist-package/src/Field/Field.js.map +1 -0
  55. package/{Field → dist-package/src/Field}/index.d.ts +1 -0
  56. package/dist-package/src/Field/index.d.ts.map +1 -0
  57. package/dist-package/src/Field/index.js.map +1 -0
  58. package/dist-package/src/FieldBase/index.d.ts +2 -0
  59. package/dist-package/src/FieldBase/index.d.ts.map +1 -0
  60. package/dist-package/src/FieldBase/index.js.map +1 -0
  61. package/dist-package/src/FieldBase/types.d.ts +6 -0
  62. package/dist-package/src/FieldBase/types.d.ts.map +1 -0
  63. package/{FieldBase → dist-package/src/FieldBase}/types.js.map +1 -1
  64. package/{FieldLabel → dist-package/src/FieldLabel}/FieldLabel.d.ts +1 -0
  65. package/dist-package/src/FieldLabel/FieldLabel.d.ts.map +1 -0
  66. package/dist-package/src/FieldLabel/FieldLabel.js.map +1 -0
  67. package/{FieldLabel → dist-package/src/FieldLabel}/index.d.ts +1 -0
  68. package/dist-package/src/FieldLabel/index.d.ts.map +1 -0
  69. package/dist-package/src/FieldLabel/index.js.map +1 -0
  70. package/{FieldWrapper → dist-package/src/FieldWrapper}/FieldWrapper.d.ts +1 -0
  71. package/dist-package/src/FieldWrapper/FieldWrapper.d.ts.map +1 -0
  72. package/dist-package/src/FieldWrapper/FieldWrapper.js.map +1 -0
  73. package/{FieldWrapper → dist-package/src/FieldWrapper}/index.d.ts +1 -0
  74. package/dist-package/src/FieldWrapper/index.d.ts.map +1 -0
  75. package/dist-package/src/FieldWrapper/index.js.map +1 -0
  76. package/{FileInput → dist-package/src/FileInput}/FileInput.d.ts +1 -0
  77. package/dist-package/src/FileInput/FileInput.d.ts.map +1 -0
  78. package/dist-package/src/FileInput/FileInput.js.map +1 -0
  79. package/{FileInput → dist-package/src/FileInput}/index.d.ts +1 -0
  80. package/dist-package/src/FileInput/index.d.ts.map +1 -0
  81. package/dist-package/src/FileInput/index.js.map +1 -0
  82. package/{Form → dist-package/src/Form}/Form.d.ts +1 -0
  83. package/dist-package/src/Form/Form.d.ts.map +1 -0
  84. package/{Form → dist-package/src/Form}/Form.js +1 -1
  85. package/dist-package/src/Form/Form.js.map +1 -0
  86. package/{Form → dist-package/src/Form}/FormContext.d.ts +1 -0
  87. package/dist-package/src/Form/FormContext.d.ts.map +1 -0
  88. package/dist-package/src/Form/FormContext.js.map +1 -0
  89. package/{Form → dist-package/src/Form}/FormRenderer.d.ts +1 -0
  90. package/dist-package/src/Form/FormRenderer.d.ts.map +1 -0
  91. package/dist-package/src/Form/FormRenderer.js.map +1 -0
  92. package/{Form → dist-package/src/Form}/index.d.ts +1 -0
  93. package/dist-package/src/Form/index.d.ts.map +1 -0
  94. package/dist-package/src/Form/index.js.map +1 -0
  95. package/{Form → dist-package/src/Form}/mutators/index.d.ts +1 -0
  96. package/dist-package/src/Form/mutators/index.d.ts.map +1 -0
  97. package/dist-package/src/Form/mutators/index.js.map +1 -0
  98. package/{Form → dist-package/src/Form}/mutators/set-active-field-touched.d.ts +1 -0
  99. package/dist-package/src/Form/mutators/set-active-field-touched.d.ts.map +1 -0
  100. package/dist-package/src/Form/mutators/set-active-field-touched.js.map +1 -0
  101. package/{Form → dist-package/src/Form}/mutators/set-has-multiline-counter.d.ts +1 -0
  102. package/dist-package/src/Form/mutators/set-has-multiline-counter.d.ts.map +1 -0
  103. package/dist-package/src/Form/mutators/set-has-multiline-counter.js.map +1 -0
  104. package/{FormCompound → dist-package/src/FormCompound}/index.d.ts +7 -6
  105. package/dist-package/src/FormCompound/index.d.ts.map +1 -0
  106. package/dist-package/src/FormCompound/index.js.map +1 -0
  107. package/{FormConfig → dist-package/src/FormConfig}/FormConfig.d.ts +1 -0
  108. package/dist-package/src/FormConfig/FormConfig.d.ts.map +1 -0
  109. package/dist-package/src/FormConfig/FormConfig.js.map +1 -0
  110. package/dist-package/src/FormConfig/index.d.ts +2 -0
  111. package/dist-package/src/FormConfig/index.d.ts.map +1 -0
  112. package/dist-package/src/FormConfig/index.js.map +1 -0
  113. package/{Input → dist-package/src/Input}/Input.d.ts +1 -0
  114. package/dist-package/src/Input/Input.d.ts.map +1 -0
  115. package/dist-package/src/Input/Input.js.map +1 -0
  116. package/{Input → dist-package/src/Input}/index.d.ts +1 -0
  117. package/dist-package/src/Input/index.d.ts.map +1 -0
  118. package/dist-package/src/Input/index.js.map +1 -0
  119. package/{InputField → dist-package/src/InputField}/InputField.d.ts +1 -0
  120. package/dist-package/src/InputField/InputField.d.ts.map +1 -0
  121. package/dist-package/src/InputField/InputField.js.map +1 -0
  122. package/{InputField → dist-package/src/InputField}/index.d.ts +1 -0
  123. package/dist-package/src/InputField/index.d.ts.map +1 -0
  124. package/dist-package/src/InputField/index.js.map +1 -0
  125. package/{NumberInput → dist-package/src/NumberInput}/NumberInput.d.ts +1 -0
  126. package/dist-package/src/NumberInput/NumberInput.d.ts.map +1 -0
  127. package/dist-package/src/NumberInput/NumberInput.js.map +1 -0
  128. package/dist-package/src/NumberInput/index.d.ts +3 -0
  129. package/dist-package/src/NumberInput/index.d.ts.map +1 -0
  130. package/dist-package/src/NumberInput/index.js.map +1 -0
  131. package/{PasswordInput → dist-package/src/PasswordInput}/FieldRenderer.d.ts +1 -0
  132. package/dist-package/src/PasswordInput/FieldRenderer.d.ts.map +1 -0
  133. package/dist-package/src/PasswordInput/FieldRenderer.js.map +1 -0
  134. package/{PasswordInput → dist-package/src/PasswordInput}/PasswordInput.d.ts +1 -0
  135. package/dist-package/src/PasswordInput/PasswordInput.d.ts.map +1 -0
  136. package/dist-package/src/PasswordInput/PasswordInput.js.map +1 -0
  137. package/{PasswordInput → dist-package/src/PasswordInput}/index.d.ts +1 -0
  138. package/dist-package/src/PasswordInput/index.d.ts.map +1 -0
  139. package/dist-package/src/PasswordInput/index.js.map +1 -0
  140. package/{PasswordInput → dist-package/src/PasswordInput}/validators.d.ts +1 -0
  141. package/dist-package/src/PasswordInput/validators.d.ts.map +1 -0
  142. package/dist-package/src/PasswordInput/validators.js.map +1 -0
  143. package/{Radio → dist-package/src/Radio}/Radio.d.ts +1 -0
  144. package/dist-package/src/Radio/Radio.d.ts.map +1 -0
  145. package/dist-package/src/Radio/Radio.js.map +1 -0
  146. package/{Radio → dist-package/src/Radio}/index.d.ts +1 -0
  147. package/dist-package/src/Radio/index.d.ts.map +1 -0
  148. package/dist-package/src/Radio/index.js.map +1 -0
  149. package/{RadioGroup → dist-package/src/RadioGroup}/RadioGroup.d.ts +1 -0
  150. package/dist-package/src/RadioGroup/RadioGroup.d.ts.map +1 -0
  151. package/dist-package/src/RadioGroup/RadioGroup.js.map +1 -0
  152. package/{RadioGroup → dist-package/src/RadioGroup}/RadioGroupContext.d.ts +1 -0
  153. package/dist-package/src/RadioGroup/RadioGroupContext.d.ts.map +1 -0
  154. package/dist-package/src/RadioGroup/RadioGroupContext.js.map +1 -0
  155. package/{RadioGroup → dist-package/src/RadioGroup}/index.d.ts +1 -0
  156. package/dist-package/src/RadioGroup/index.d.ts.map +1 -0
  157. package/dist-package/src/RadioGroup/index.js.map +1 -0
  158. package/{Rating → dist-package/src/Rating}/Rating.d.ts +1 -0
  159. package/dist-package/src/Rating/Rating.d.ts.map +1 -0
  160. package/dist-package/src/Rating/Rating.js.map +1 -0
  161. package/{Rating → dist-package/src/Rating}/index.d.ts +1 -0
  162. package/dist-package/src/Rating/index.d.ts.map +1 -0
  163. package/dist-package/src/Rating/index.js.map +1 -0
  164. package/{RichTextEditor → dist-package/src/RichTextEditor}/RichTextEditor.d.ts +2 -1
  165. package/dist-package/src/RichTextEditor/RichTextEditor.d.ts.map +1 -0
  166. package/dist-package/src/RichTextEditor/RichTextEditor.js.map +1 -0
  167. package/dist-package/src/RichTextEditor/hooks/index.d.ts +2 -0
  168. package/dist-package/src/RichTextEditor/hooks/index.d.ts.map +1 -0
  169. package/dist-package/src/RichTextEditor/hooks/index.js.map +1 -0
  170. package/{RichTextEditor → dist-package/src/RichTextEditor}/hooks/use-enforce-highlight-autofill.d.ts +1 -0
  171. package/dist-package/src/RichTextEditor/hooks/use-enforce-highlight-autofill.d.ts.map +1 -0
  172. package/dist-package/src/RichTextEditor/hooks/use-enforce-highlight-autofill.js.map +1 -0
  173. package/{RichTextEditor → dist-package/src/RichTextEditor}/index.d.ts +1 -0
  174. package/dist-package/src/RichTextEditor/index.d.ts.map +1 -0
  175. package/dist-package/src/RichTextEditor/index.js.map +1 -0
  176. package/{Select → dist-package/src/Select}/Select.d.ts +1 -0
  177. package/dist-package/src/Select/Select.d.ts.map +1 -0
  178. package/{Select → dist-package/src/Select}/Select.js +1 -1
  179. package/dist-package/src/Select/Select.js.map +1 -0
  180. package/dist-package/src/Select/index.d.ts +3 -0
  181. package/dist-package/src/Select/index.d.ts.map +1 -0
  182. package/dist-package/src/Select/index.js.map +1 -0
  183. package/{SubmitButton → dist-package/src/SubmitButton}/SubmitButton.d.ts +2 -2
  184. package/dist-package/src/SubmitButton/SubmitButton.d.ts.map +1 -0
  185. package/dist-package/src/SubmitButton/SubmitButton.js.map +1 -0
  186. package/{SubmitButton → dist-package/src/SubmitButton}/index.d.ts +1 -0
  187. package/dist-package/src/SubmitButton/index.d.ts.map +1 -0
  188. package/dist-package/src/SubmitButton/index.js.map +1 -0
  189. package/{Switch → dist-package/src/Switch}/Switch.d.ts +1 -0
  190. package/dist-package/src/Switch/Switch.d.ts.map +1 -0
  191. package/dist-package/src/Switch/Switch.js.map +1 -0
  192. package/{Switch → dist-package/src/Switch}/index.d.ts +1 -0
  193. package/dist-package/src/Switch/index.d.ts.map +1 -0
  194. package/dist-package/src/Switch/index.js.map +1 -0
  195. package/{TagSelector → dist-package/src/TagSelector}/TagSelector.d.ts +1 -0
  196. package/dist-package/src/TagSelector/TagSelector.d.ts.map +1 -0
  197. package/dist-package/src/TagSelector/TagSelector.js.map +1 -0
  198. package/dist-package/src/TagSelector/index.d.ts +3 -0
  199. package/dist-package/src/TagSelector/index.d.ts.map +1 -0
  200. package/dist-package/src/TagSelector/index.js.map +1 -0
  201. package/{TimePicker → dist-package/src/TimePicker}/TimePicker.d.ts +1 -0
  202. package/dist-package/src/TimePicker/TimePicker.d.ts.map +1 -0
  203. package/dist-package/src/TimePicker/TimePicker.js.map +1 -0
  204. package/{TimePicker → dist-package/src/TimePicker}/index.d.ts +1 -0
  205. package/dist-package/src/TimePicker/index.d.ts.map +1 -0
  206. package/dist-package/src/TimePicker/index.js.map +1 -0
  207. package/{index.d.ts → dist-package/src/index.d.ts} +10 -0
  208. package/dist-package/src/index.d.ts.map +1 -0
  209. package/{index.js → dist-package/src/index.js} +3 -0
  210. package/dist-package/src/index.js.map +1 -0
  211. package/{utils → dist-package/src/utils}/flat-map.d.ts +1 -0
  212. package/dist-package/src/utils/flat-map.d.ts.map +1 -0
  213. package/dist-package/src/utils/flat-map.js.map +1 -0
  214. package/{utils → dist-package/src/utils}/form-values-change-decorator/form-values-change-decorator.d.ts +1 -0
  215. package/dist-package/src/utils/form-values-change-decorator/form-values-change-decorator.d.ts.map +1 -0
  216. package/dist-package/src/utils/form-values-change-decorator/form-values-change-decorator.js.map +1 -0
  217. package/{utils → dist-package/src/utils}/form-values-change-decorator/index.d.ts +1 -0
  218. package/dist-package/src/utils/form-values-change-decorator/index.d.ts.map +1 -0
  219. package/dist-package/src/utils/form-values-change-decorator/index.js.map +1 -0
  220. package/{utils → dist-package/src/utils}/index.d.ts +1 -0
  221. package/dist-package/src/utils/index.d.ts.map +1 -0
  222. package/dist-package/src/utils/index.js.map +1 -0
  223. package/{utils → dist-package/src/utils}/scroll-to-error-decorator.d.ts +1 -0
  224. package/dist-package/src/utils/scroll-to-error-decorator.d.ts.map +1 -0
  225. package/dist-package/src/utils/scroll-to-error-decorator.js.map +1 -0
  226. package/{utils → dist-package/src/utils}/scroll-to.d.ts +1 -0
  227. package/dist-package/src/utils/scroll-to.d.ts.map +1 -0
  228. package/dist-package/src/utils/scroll-to.js.map +1 -0
  229. package/{utils → dist-package/src/utils}/use-field-validation/index.d.ts +1 -0
  230. package/dist-package/src/utils/use-field-validation/index.d.ts.map +1 -0
  231. package/dist-package/src/utils/use-field-validation/index.js.map +1 -0
  232. package/{utils → dist-package/src/utils}/use-field-validation/use-field-validation.d.ts +1 -0
  233. package/dist-package/src/utils/use-field-validation/use-field-validation.d.ts.map +1 -0
  234. package/dist-package/src/utils/use-field-validation/use-field-validation.js.map +1 -0
  235. package/{utils → dist-package/src/utils}/use-form-auto-save/index.d.ts +1 -0
  236. package/dist-package/src/utils/use-form-auto-save/index.d.ts.map +1 -0
  237. package/dist-package/src/utils/use-form-auto-save/index.js.map +1 -0
  238. package/{utils → dist-package/src/utils}/use-form-auto-save/use-form-auto-save.d.ts +1 -0
  239. package/dist-package/src/utils/use-form-auto-save/use-form-auto-save.d.ts.map +1 -0
  240. package/dist-package/src/utils/use-form-auto-save/use-form-auto-save.js.map +1 -0
  241. package/{utils → dist-package/src/utils}/use-form-input-reset/index.d.ts +1 -0
  242. package/dist-package/src/utils/use-form-input-reset/index.d.ts.map +1 -0
  243. package/dist-package/src/utils/use-form-input-reset/index.js.map +1 -0
  244. package/{utils → dist-package/src/utils}/use-form-input-reset/use-form-input-reset.d.ts +1 -0
  245. package/dist-package/src/utils/use-form-input-reset/use-form-input-reset.d.ts.map +1 -0
  246. package/dist-package/src/utils/use-form-input-reset/use-form-input-reset.js.map +1 -0
  247. package/{utils → dist-package/src/utils}/validators.d.ts +1 -0
  248. package/dist-package/src/utils/validators.d.ts.map +1 -0
  249. package/dist-package/src/utils/validators.js.map +1 -0
  250. package/package.json +24 -11
  251. package/src/Autocomplete/Autocomplete.tsx +37 -0
  252. package/src/Autocomplete/index.ts +1 -0
  253. package/src/AvatarUpload/AvatarUpload.tsx +92 -0
  254. package/src/AvatarUpload/index.ts +1 -0
  255. package/src/ButtonCheckbox/ButtonCheckbox.tsx +63 -0
  256. package/src/ButtonCheckbox/index.ts +1 -0
  257. package/src/ButtonRadio/ButtonRadio.tsx +25 -0
  258. package/src/ButtonRadio/index.ts +1 -0
  259. package/src/Checkbox/Checkbox.tsx +79 -0
  260. package/src/Checkbox/__snapshots__/test.tsx.snap +259 -0
  261. package/src/Checkbox/index.ts +2 -0
  262. package/src/Checkbox/test.tsx +92 -0
  263. package/src/CheckboxGroup/CheckboxGroup.tsx +47 -0
  264. package/src/CheckboxGroup/CheckboxGroupContext.ts +3 -0
  265. package/src/CheckboxGroup/index.ts +3 -0
  266. package/src/CheckboxGroup/test.tsx +36 -0
  267. package/src/DatePicker/DatePicker.tsx +40 -0
  268. package/src/DatePicker/index.ts +1 -0
  269. package/src/Dropzone/Dropzone.tsx +102 -0
  270. package/src/Dropzone/index.ts +6 -0
  271. package/src/Field/Field.tsx +196 -0
  272. package/src/Field/index.ts +2 -0
  273. package/src/FieldBase/index.ts +1 -0
  274. package/src/FieldBase/types.ts +23 -0
  275. package/src/FieldLabel/FieldLabel.tsx +64 -0
  276. package/src/FieldLabel/__snapshots__/test.tsx.snap +21 -0
  277. package/src/FieldLabel/index.ts +2 -0
  278. package/src/FieldLabel/test.tsx +52 -0
  279. package/src/FieldWrapper/FieldWrapper.tsx +48 -0
  280. package/src/FieldWrapper/index.ts +6 -0
  281. package/src/FieldWrapper/story/index.jsx +153 -0
  282. package/src/FieldWrapper/test.tsx +32 -0
  283. package/src/FileInput/FileInput.tsx +85 -0
  284. package/src/FileInput/index.ts +1 -0
  285. package/src/Form/Form.tsx +161 -0
  286. package/src/Form/FormContext.ts +38 -0
  287. package/src/Form/FormRenderer.tsx +38 -0
  288. package/src/Form/__snapshots__/test.tsx.snap +140 -0
  289. package/src/Form/index.ts +2 -0
  290. package/src/Form/mutators/index.ts +2 -0
  291. package/src/Form/mutators/set-active-field-touched.ts +16 -0
  292. package/src/Form/mutators/set-has-multiline-counter.ts +16 -0
  293. package/src/Form/story/AutoSave.example.tsx +120 -0
  294. package/src/Form/story/AvatarUpload.example.tsx +81 -0
  295. package/src/Form/story/BackendCommunication.example.tsx +137 -0
  296. package/src/Form/story/CustomFormLevelConfiguration.example.tsx +35 -0
  297. package/src/Form/story/CustomValidator.example.tsx +53 -0
  298. package/src/Form/story/Default.example.tsx +218 -0
  299. package/src/Form/story/Dropzone.example.tsx +42 -0
  300. package/src/Form/story/FieldRequirements.example.tsx +58 -0
  301. package/src/Form/story/FileInput.example.tsx +43 -0
  302. package/src/Form/story/HighlightAutofill.example.tsx +96 -0
  303. package/src/Form/story/Horizontal.example.tsx +281 -0
  304. package/src/Form/story/HorizontalLabelWidth.example.tsx +26 -0
  305. package/src/Form/story/NoScrolling.example.tsx +42 -0
  306. package/src/Form/story/ParseInput.example.tsx +31 -0
  307. package/src/Form/story/RichTextEditor.example.tsx +32 -0
  308. package/src/Form/story/Status.example.tsx +35 -0
  309. package/src/Form/story/TitleCase.example.tsx +194 -0
  310. package/src/Form/story/ValidateOnSubmit.example.tsx +99 -0
  311. package/src/Form/story/index.jsx +289 -0
  312. package/src/Form/test.tsx +202 -0
  313. package/src/FormCompound/index.ts +51 -0
  314. package/src/FormConfig/FormConfig.ts +35 -0
  315. package/src/FormConfig/index.ts +1 -0
  316. package/src/FormConfig/test.tsx +44 -0
  317. package/src/Input/Input.tsx +80 -0
  318. package/src/Input/index.ts +2 -0
  319. package/src/Input/test.tsx +35 -0
  320. package/src/InputField/InputField.tsx +71 -0
  321. package/src/InputField/index.ts +1 -0
  322. package/src/InputField/test.ts +105 -0
  323. package/src/NumberInput/NumberInput.tsx +58 -0
  324. package/src/NumberInput/index.ts +2 -0
  325. package/src/PasswordInput/FieldRenderer.tsx +36 -0
  326. package/src/PasswordInput/PasswordInput.tsx +144 -0
  327. package/src/PasswordInput/index.ts +1 -0
  328. package/src/PasswordInput/test.ts +45 -0
  329. package/src/PasswordInput/validators.ts +28 -0
  330. package/src/Radio/Radio.tsx +25 -0
  331. package/src/Radio/__snapshots__/test.tsx.snap +235 -0
  332. package/src/Radio/index.ts +1 -0
  333. package/src/Radio/test.tsx +49 -0
  334. package/src/RadioGroup/RadioGroup.tsx +53 -0
  335. package/src/RadioGroup/RadioGroupContext.ts +3 -0
  336. package/src/RadioGroup/index.ts +3 -0
  337. package/src/RadioGroup/test.tsx +36 -0
  338. package/src/Rating/Rating.tsx +95 -0
  339. package/src/Rating/__snapshots__/test.tsx.snap +226 -0
  340. package/src/Rating/index.ts +1 -0
  341. package/src/Rating/test.tsx +171 -0
  342. package/src/RichTextEditor/RichTextEditor.tsx +87 -0
  343. package/{RichTextEditor/hooks/index.d.ts → src/RichTextEditor/hooks/index.ts} +1 -1
  344. package/src/RichTextEditor/hooks/use-enforce-highlight-autofill.test.tsx +67 -0
  345. package/src/RichTextEditor/hooks/use-enforce-highlight-autofill.ts +48 -0
  346. package/src/RichTextEditor/index.ts +1 -0
  347. package/src/Select/Select.tsx +55 -0
  348. package/src/Select/index.ts +2 -0
  349. package/src/SubmitButton/SubmitButton.tsx +71 -0
  350. package/src/SubmitButton/index.ts +6 -0
  351. package/src/SubmitButton/story/ButtonTypes.example.tsx +45 -0
  352. package/src/SubmitButton/story/Default.example.tsx +16 -0
  353. package/src/SubmitButton/story/index.jsx +35 -0
  354. package/src/Switch/Switch.tsx +40 -0
  355. package/src/Switch/index.ts +1 -0
  356. package/src/TagSelector/TagSelector.tsx +41 -0
  357. package/src/TagSelector/index.ts +2 -0
  358. package/src/TimePicker/TimePicker.tsx +43 -0
  359. package/src/TimePicker/index.ts +1 -0
  360. package/src/index.ts +86 -0
  361. package/src/story/Deserialization.example.tsx +40 -0
  362. package/src/story/FormSpy.example.tsx +50 -0
  363. package/src/story/index.jsx +39 -0
  364. package/src/utils/flat-map.ts +4 -0
  365. package/src/utils/form-values-change-decorator/form-values-change-decorator.ts +64 -0
  366. package/src/utils/form-values-change-decorator/index.ts +3 -0
  367. package/src/utils/form-values-change-decorator/test.tsx +77 -0
  368. package/src/utils/index.ts +6 -0
  369. package/src/utils/scroll-to-error-decorator.ts +85 -0
  370. package/src/utils/scroll-to.ts +10 -0
  371. package/src/utils/use-field-validation/index.ts +1 -0
  372. package/src/utils/use-field-validation/test.tsx +73 -0
  373. package/src/utils/use-field-validation/use-field-validation.ts +63 -0
  374. package/src/utils/use-form-auto-save/index.ts +1 -0
  375. package/src/utils/use-form-auto-save/use-form-auto-save.ts +59 -0
  376. package/src/utils/use-form-input-reset/index.ts +1 -0
  377. package/src/utils/use-form-input-reset/test.ts +72 -0
  378. package/src/utils/use-form-input-reset/use-form-input-reset.ts +32 -0
  379. package/src/utils/validators.ts +18 -0
  380. package/utils.d.ts +1 -0
  381. package/utils.js +4 -0
  382. package/Autocomplete/Autocomplete.js.map +0 -1
  383. package/Autocomplete/index.js.map +0 -1
  384. package/AvatarUpload/AvatarUpload.js.map +0 -1
  385. package/AvatarUpload/index.js.map +0 -1
  386. package/ButtonCheckbox/ButtonCheckbox.js.map +0 -1
  387. package/ButtonCheckbox/index.js.map +0 -1
  388. package/ButtonRadio/ButtonRadio.js.map +0 -1
  389. package/ButtonRadio/index.js.map +0 -1
  390. package/Checkbox/Checkbox.js.map +0 -1
  391. package/Checkbox/index.d.ts +0 -1
  392. package/Checkbox/index.js.map +0 -1
  393. package/CheckboxGroup/CheckboxGroup.js.map +0 -1
  394. package/CheckboxGroup/CheckboxGroupContext.js.map +0 -1
  395. package/CheckboxGroup/index.js.map +0 -1
  396. package/DatePicker/DatePicker.js.map +0 -1
  397. package/DatePicker/index.js.map +0 -1
  398. package/Dropzone/Dropzone.js.map +0 -1
  399. package/Dropzone/index.js.map +0 -1
  400. package/Field/Field.js.map +0 -1
  401. package/Field/index.js.map +0 -1
  402. package/FieldBase/index.d.ts +0 -1
  403. package/FieldBase/index.js.map +0 -1
  404. package/FieldBase/types.d.ts +0 -8
  405. package/FieldLabel/FieldLabel.js.map +0 -1
  406. package/FieldLabel/index.js.map +0 -1
  407. package/FieldWrapper/FieldWrapper.js.map +0 -1
  408. package/FieldWrapper/index.js.map +0 -1
  409. package/FileInput/FileInput.js.map +0 -1
  410. package/FileInput/index.js.map +0 -1
  411. package/Form/Form.js.map +0 -1
  412. package/Form/FormContext.js.map +0 -1
  413. package/Form/FormRenderer.js.map +0 -1
  414. package/Form/index.js.map +0 -1
  415. package/Form/mutators/index.js.map +0 -1
  416. package/Form/mutators/set-active-field-touched.js.map +0 -1
  417. package/Form/mutators/set-has-multiline-counter.js.map +0 -1
  418. package/FormCompound/index.js.map +0 -1
  419. package/FormConfig/FormConfig.js.map +0 -1
  420. package/FormConfig/index.d.ts +0 -1
  421. package/FormConfig/index.js.map +0 -1
  422. package/Input/Input.js.map +0 -1
  423. package/Input/index.js.map +0 -1
  424. package/InputField/InputField.js.map +0 -1
  425. package/InputField/index.js.map +0 -1
  426. package/LICENSE +0 -20
  427. package/NumberInput/NumberInput.js.map +0 -1
  428. package/NumberInput/index.d.ts +0 -1
  429. package/NumberInput/index.js.map +0 -1
  430. package/PasswordInput/FieldRenderer.js.map +0 -1
  431. package/PasswordInput/PasswordInput.js.map +0 -1
  432. package/PasswordInput/index.js.map +0 -1
  433. package/PasswordInput/validators.js.map +0 -1
  434. package/Radio/Radio.js.map +0 -1
  435. package/Radio/index.js.map +0 -1
  436. package/RadioGroup/RadioGroup.js.map +0 -1
  437. package/RadioGroup/RadioGroupContext.js.map +0 -1
  438. package/RadioGroup/index.js.map +0 -1
  439. package/Rating/Rating.js.map +0 -1
  440. package/Rating/index.js.map +0 -1
  441. package/RichTextEditor/RichTextEditor.js.map +0 -1
  442. package/RichTextEditor/hooks/index.js.map +0 -1
  443. package/RichTextEditor/hooks/use-enforce-highlight-autofill.js.map +0 -1
  444. package/RichTextEditor/hooks/use-enforce-highlight-autofill.test.d.ts +0 -1
  445. package/RichTextEditor/hooks/use-enforce-highlight-autofill.test.js +0 -51
  446. package/RichTextEditor/hooks/use-enforce-highlight-autofill.test.js.map +0 -1
  447. package/RichTextEditor/index.js.map +0 -1
  448. package/Select/Select.js.map +0 -1
  449. package/Select/index.d.ts +0 -1
  450. package/Select/index.js.map +0 -1
  451. package/SubmitButton/SubmitButton.js.map +0 -1
  452. package/SubmitButton/index.js.map +0 -1
  453. package/Switch/Switch.js.map +0 -1
  454. package/Switch/index.js.map +0 -1
  455. package/TagSelector/TagSelector.js.map +0 -1
  456. package/TagSelector/index.d.ts +0 -1
  457. package/TagSelector/index.js.map +0 -1
  458. package/TimePicker/TimePicker.js.map +0 -1
  459. package/TimePicker/index.js.map +0 -1
  460. package/index.js.map +0 -1
  461. package/utils/flat-map.js.map +0 -1
  462. package/utils/form-values-change-decorator/form-values-change-decorator.js.map +0 -1
  463. package/utils/form-values-change-decorator/index.js.map +0 -1
  464. package/utils/index.js.map +0 -1
  465. package/utils/scroll-to-error-decorator.js.map +0 -1
  466. package/utils/scroll-to.js.map +0 -1
  467. package/utils/use-field-validation/index.js.map +0 -1
  468. package/utils/use-field-validation/use-field-validation.js.map +0 -1
  469. package/utils/use-form-auto-save/index.js.map +0 -1
  470. package/utils/use-form-auto-save/use-form-auto-save.js.map +0 -1
  471. package/utils/use-form-input-reset/index.js.map +0 -1
  472. package/utils/use-form-input-reset/use-form-input-reset.js.map +0 -1
  473. package/utils/validators.js.map +0 -1
  474. /package/{Autocomplete → dist-package/src/Autocomplete}/Autocomplete.js +0 -0
  475. /package/{Autocomplete → dist-package/src/Autocomplete}/index.js +0 -0
  476. /package/{AvatarUpload → dist-package/src/AvatarUpload}/AvatarUpload.js +0 -0
  477. /package/{AvatarUpload → dist-package/src/AvatarUpload}/index.js +0 -0
  478. /package/{ButtonCheckbox → dist-package/src/ButtonCheckbox}/ButtonCheckbox.js +0 -0
  479. /package/{ButtonCheckbox → dist-package/src/ButtonCheckbox}/index.js +0 -0
  480. /package/{ButtonRadio → dist-package/src/ButtonRadio}/ButtonRadio.js +0 -0
  481. /package/{ButtonRadio → dist-package/src/ButtonRadio}/index.js +0 -0
  482. /package/{Checkbox → dist-package/src/Checkbox}/Checkbox.js +0 -0
  483. /package/{Checkbox → dist-package/src/Checkbox}/index.js +0 -0
  484. /package/{CheckboxGroup → dist-package/src/CheckboxGroup}/CheckboxGroup.js +0 -0
  485. /package/{CheckboxGroup → dist-package/src/CheckboxGroup}/CheckboxGroupContext.js +0 -0
  486. /package/{CheckboxGroup → dist-package/src/CheckboxGroup}/index.js +0 -0
  487. /package/{DatePicker → dist-package/src/DatePicker}/DatePicker.js +0 -0
  488. /package/{DatePicker → dist-package/src/DatePicker}/index.js +0 -0
  489. /package/{Dropzone → dist-package/src/Dropzone}/Dropzone.js +0 -0
  490. /package/{Dropzone → dist-package/src/Dropzone}/index.js +0 -0
  491. /package/{Field → dist-package/src/Field}/Field.js +0 -0
  492. /package/{Field → dist-package/src/Field}/index.js +0 -0
  493. /package/{FieldBase → dist-package/src/FieldBase}/index.js +0 -0
  494. /package/{FieldBase → dist-package/src/FieldBase}/types.js +0 -0
  495. /package/{FieldLabel → dist-package/src/FieldLabel}/FieldLabel.js +0 -0
  496. /package/{FieldLabel → dist-package/src/FieldLabel}/index.js +0 -0
  497. /package/{FieldWrapper → dist-package/src/FieldWrapper}/FieldWrapper.js +0 -0
  498. /package/{FieldWrapper → dist-package/src/FieldWrapper}/index.js +0 -0
  499. /package/{FileInput → dist-package/src/FileInput}/FileInput.js +0 -0
  500. /package/{FileInput → dist-package/src/FileInput}/index.js +0 -0
  501. /package/{Form → dist-package/src/Form}/FormContext.js +0 -0
  502. /package/{Form → dist-package/src/Form}/FormRenderer.js +0 -0
  503. /package/{Form → dist-package/src/Form}/index.js +0 -0
  504. /package/{Form → dist-package/src/Form}/mutators/index.js +0 -0
  505. /package/{Form → dist-package/src/Form}/mutators/set-active-field-touched.js +0 -0
  506. /package/{Form → dist-package/src/Form}/mutators/set-has-multiline-counter.js +0 -0
  507. /package/{FormCompound → dist-package/src/FormCompound}/index.js +0 -0
  508. /package/{FormConfig → dist-package/src/FormConfig}/FormConfig.js +0 -0
  509. /package/{FormConfig → dist-package/src/FormConfig}/index.js +0 -0
  510. /package/{Input → dist-package/src/Input}/Input.js +0 -0
  511. /package/{Input → dist-package/src/Input}/index.js +0 -0
  512. /package/{InputField → dist-package/src/InputField}/InputField.js +0 -0
  513. /package/{InputField → dist-package/src/InputField}/index.js +0 -0
  514. /package/{NumberInput → dist-package/src/NumberInput}/NumberInput.js +0 -0
  515. /package/{NumberInput → dist-package/src/NumberInput}/index.js +0 -0
  516. /package/{PasswordInput → dist-package/src/PasswordInput}/FieldRenderer.js +0 -0
  517. /package/{PasswordInput → dist-package/src/PasswordInput}/PasswordInput.js +0 -0
  518. /package/{PasswordInput → dist-package/src/PasswordInput}/index.js +0 -0
  519. /package/{PasswordInput → dist-package/src/PasswordInput}/validators.js +0 -0
  520. /package/{Radio → dist-package/src/Radio}/Radio.js +0 -0
  521. /package/{Radio → dist-package/src/Radio}/index.js +0 -0
  522. /package/{RadioGroup → dist-package/src/RadioGroup}/RadioGroup.js +0 -0
  523. /package/{RadioGroup → dist-package/src/RadioGroup}/RadioGroupContext.js +0 -0
  524. /package/{RadioGroup → dist-package/src/RadioGroup}/index.js +0 -0
  525. /package/{Rating → dist-package/src/Rating}/Rating.js +0 -0
  526. /package/{Rating → dist-package/src/Rating}/index.js +0 -0
  527. /package/{RichTextEditor → dist-package/src/RichTextEditor}/RichTextEditor.js +0 -0
  528. /package/{RichTextEditor → dist-package/src/RichTextEditor}/hooks/index.js +0 -0
  529. /package/{RichTextEditor → dist-package/src/RichTextEditor}/hooks/use-enforce-highlight-autofill.js +0 -0
  530. /package/{RichTextEditor → dist-package/src/RichTextEditor}/index.js +0 -0
  531. /package/{Select → dist-package/src/Select}/index.js +0 -0
  532. /package/{SubmitButton → dist-package/src/SubmitButton}/SubmitButton.js +0 -0
  533. /package/{SubmitButton → dist-package/src/SubmitButton}/index.js +0 -0
  534. /package/{Switch → dist-package/src/Switch}/Switch.js +0 -0
  535. /package/{Switch → dist-package/src/Switch}/index.js +0 -0
  536. /package/{TagSelector → dist-package/src/TagSelector}/TagSelector.js +0 -0
  537. /package/{TagSelector → dist-package/src/TagSelector}/index.js +0 -0
  538. /package/{TimePicker → dist-package/src/TimePicker}/TimePicker.js +0 -0
  539. /package/{TimePicker → dist-package/src/TimePicker}/index.js +0 -0
  540. /package/{utils → dist-package/src/utils}/flat-map.js +0 -0
  541. /package/{utils → dist-package/src/utils}/form-values-change-decorator/form-values-change-decorator.js +0 -0
  542. /package/{utils → dist-package/src/utils}/form-values-change-decorator/index.js +0 -0
  543. /package/{utils → dist-package/src/utils}/index.js +0 -0
  544. /package/{utils → dist-package/src/utils}/scroll-to-error-decorator.js +0 -0
  545. /package/{utils → dist-package/src/utils}/scroll-to.js +0 -0
  546. /package/{utils → dist-package/src/utils}/use-field-validation/index.js +0 -0
  547. /package/{utils → dist-package/src/utils}/use-field-validation/use-field-validation.js +0 -0
  548. /package/{utils → dist-package/src/utils}/use-form-auto-save/index.js +0 -0
  549. /package/{utils → dist-package/src/utils}/use-form-auto-save/use-form-auto-save.js +0 -0
  550. /package/{utils → dist-package/src/utils}/use-form-input-reset/index.js +0 -0
  551. /package/{utils → dist-package/src/utils}/use-form-input-reset/use-form-input-reset.js +0 -0
  552. /package/{utils → dist-package/src/utils}/validators.js +0 -0
@@ -0,0 +1,137 @@
1
+ import React, { useCallback } from 'react'
2
+ import { Container } from '@toptal/picasso'
3
+ import { SPACING_4 } from '@toptal/picasso-utils'
4
+ import { FormNonCompound, Input, SubmitButton } from '@toptal/picasso-forms'
5
+
6
+ const BackendCommunicationExample = () => {
7
+ const handleSuccessSubmit = useCallback(
8
+ (values: any) => api.successSubmit(values),
9
+ []
10
+ )
11
+ const handleSubmitWithInlineError = useCallback(
12
+ (values: any) => api.submitWithInlineError(values),
13
+ []
14
+ )
15
+ const handleSubmitWithCustomNotificationError = useCallback(
16
+ (values: any) => api.submitWithCustomNotificationError(values),
17
+ []
18
+ )
19
+
20
+ return (
21
+ <Container
22
+ style={{
23
+ display: 'grid',
24
+ gap: '2rem',
25
+ gridTemplateColumns: 'repeat(auto-fit, minmax(300px, 1fr))',
26
+ }}
27
+ >
28
+ <FormNonCompound
29
+ onSubmit={handleSuccessSubmit}
30
+ successSubmitMessage='Login successful!'
31
+ >
32
+ <Input
33
+ required
34
+ name='backendCommunication-successName'
35
+ label='First name'
36
+ placeholder='e.g. Bruce'
37
+ width='full'
38
+ />
39
+ <Input
40
+ required
41
+ name='backendCommunication-successSurname'
42
+ label='Last name'
43
+ placeholder='e.g. Wayne'
44
+ width='full'
45
+ />
46
+
47
+ <Container top={SPACING_4}>
48
+ <SubmitButton variant='positive' data-testid='success-submit-button'>
49
+ Login Success
50
+ </SubmitButton>
51
+ </Container>
52
+ </FormNonCompound>
53
+
54
+ <FormNonCompound
55
+ onSubmit={handleSubmitWithInlineError}
56
+ failedSubmitMessage='Login failed! Please try another combination of first and last names.'
57
+ >
58
+ <Input
59
+ required
60
+ name='backendCommunication-inlineErrorName'
61
+ label='First name'
62
+ placeholder='e.g. Bruce'
63
+ width='full'
64
+ />
65
+ <Input
66
+ required
67
+ name='backendCommunication-inlineErrorSurname'
68
+ label='Last name'
69
+ placeholder='e.g. Wayne'
70
+ width='full'
71
+ />
72
+
73
+ <Container top={SPACING_4}>
74
+ <SubmitButton
75
+ variant='negative'
76
+ data-testid='submit-with-inline-error-button'
77
+ >
78
+ Login with Inline Error
79
+ </SubmitButton>
80
+ </Container>
81
+ </FormNonCompound>
82
+
83
+ <FormNonCompound onSubmit={handleSubmitWithCustomNotificationError}>
84
+ <Input
85
+ required
86
+ name='backendCommunication-customNotificationErrorName'
87
+ label='First name'
88
+ placeholder='e.g. Bruce'
89
+ width='full'
90
+ />
91
+ <Input
92
+ required
93
+ name='backendCommunication-customNotificationErrorSurname'
94
+ label='Last name'
95
+ placeholder='e.g. Wayne'
96
+ width='full'
97
+ />
98
+
99
+ <Container top={SPACING_4}>
100
+ <SubmitButton
101
+ variant='negative'
102
+ data-testid='submit-with-custom-notification-button'
103
+ >
104
+ Login with Custom Notification Error
105
+ </SubmitButton>
106
+ </Container>
107
+ </FormNonCompound>
108
+ </Container>
109
+ )
110
+ }
111
+
112
+ // the emulation of the api call
113
+ const responseWithDelay = async (response: any) =>
114
+ new Promise(resolve => setTimeout(() => resolve(response), 2000))
115
+
116
+ const api = {
117
+ successSubmit: (values: any) => {
118
+ // do something with received values
119
+ console.log('Success submit. Form values:', values)
120
+
121
+ return responseWithDelay(undefined)
122
+ },
123
+ submitWithInlineError: (values: any) => {
124
+ console.log('Submit with Inline Errors. Form values:', values)
125
+
126
+ return responseWithDelay({
127
+ 'backendCommunication-inlineErrorName': 'Unknown first name',
128
+ })
129
+ },
130
+ submitWithCustomNotificationError: (values: any) => {
131
+ console.log('Submit with Custom Notification Errors. Form values:', values)
132
+
133
+ return responseWithDelay('Custom Notification Message!')
134
+ },
135
+ }
136
+
137
+ export default BackendCommunicationExample
@@ -0,0 +1,35 @@
1
+ import React from 'react'
2
+ import { Container } from '@toptal/picasso'
3
+ import { SPACING_4 } from '@toptal/picasso-utils'
4
+ import type { FormConfigProps } from '@toptal/picasso-forms'
5
+ import {
6
+ FormNonCompound,
7
+ ConfigProvider,
8
+ Input,
9
+ SubmitButton,
10
+ } from '@toptal/picasso-forms'
11
+
12
+ const formConfig: FormConfigProps = {
13
+ requiredVariant: 'asterisk',
14
+ }
15
+
16
+ const Example = () => (
17
+ <ConfigProvider value={formConfig}>
18
+ <FormNonCompound
19
+ onSubmit={values => window.alert(JSON.stringify(values, undefined, 2))}
20
+ >
21
+ <Input
22
+ required
23
+ name='formConfig-firstName'
24
+ label='First name'
25
+ placeholder='e.g. Bruce'
26
+ />
27
+
28
+ <Container top={SPACING_4}>
29
+ <SubmitButton>Submit</SubmitButton>
30
+ </Container>
31
+ </FormNonCompound>
32
+ </ConfigProvider>
33
+ )
34
+
35
+ export default Example
@@ -0,0 +1,53 @@
1
+ import React from 'react'
2
+ import { Container } from '@toptal/picasso'
3
+ import { SPACING_4 } from '@toptal/picasso-utils'
4
+ import {
5
+ FormNonCompound,
6
+ Input,
7
+ NumberInput,
8
+ SubmitButton,
9
+ } from '@toptal/picasso-forms'
10
+
11
+ const minMaxValidator = (value?: string | number) => {
12
+ if (value === undefined) {
13
+ return undefined
14
+ }
15
+
16
+ const number = Number(value)
17
+
18
+ if (number < 0) {
19
+ return "Age can't be negative"
20
+ }
21
+
22
+ if (number > 120) {
23
+ return "Age can't have value more than 120 years"
24
+ }
25
+
26
+ return undefined
27
+ }
28
+
29
+ const CustomValidatorExample = () => (
30
+ <FormNonCompound
31
+ onSubmit={values => window.alert(JSON.stringify(values, undefined, 2))}
32
+ >
33
+ <Input
34
+ required
35
+ name='customValidator-userName'
36
+ label='First name'
37
+ placeholder='e.g. Bruce'
38
+ />
39
+ <NumberInput
40
+ required
41
+ validate={minMaxValidator}
42
+ name='customValidator-userAge'
43
+ label="What's your age?"
44
+ placeholder='e.g. 25'
45
+ />
46
+
47
+ <Container top={SPACING_4}>
48
+ <SubmitButton>Submit</SubmitButton>
49
+ </Container>
50
+ </FormNonCompound>
51
+ )
52
+
53
+ export default CustomValidatorExample
@@ -0,0 +1,218 @@
1
+ import React, { useState } from 'react'
2
+ import { FormActionsContainer } from '@toptal/picasso'
3
+ import { SPACING_4, isSubstring } from '@toptal/picasso-utils'
4
+ import type { Item } from '@toptal/picasso/Autocomplete'
5
+ import {
6
+ FormNonCompound as Form,
7
+ NumberInput,
8
+ Input,
9
+ RadioGroup,
10
+ Radio,
11
+ SubmitButton,
12
+ ButtonRadio,
13
+ CheckboxGroup,
14
+ Checkbox,
15
+ DatePicker,
16
+ TimePicker,
17
+ ButtonCheckbox,
18
+ Autocomplete,
19
+ FileInput,
20
+ Dropzone,
21
+ AvatarUpload,
22
+ Rating,
23
+ TagSelector,
24
+ Select,
25
+ Switch,
26
+ } from '@toptal/picasso-forms'
27
+
28
+ const countries = [
29
+ { value: 'Afghanistan', text: 'Afghanistan' },
30
+ { value: 'Albania', text: 'Albania' },
31
+ { value: 'Algeria', text: 'Algeria' },
32
+ { value: 'Belarus', text: 'Belarus' },
33
+ { value: 'Croatia', text: 'Croatia' },
34
+ { value: 'Lithuania', text: 'Lithuania' },
35
+ { value: 'Slovakia', text: 'Slovakia' },
36
+ { value: 'Spain', text: 'Spain' },
37
+ { value: 'Ukraine', text: 'Ukraine' },
38
+ ]
39
+
40
+ const skills = [
41
+ { value: 0, text: 'HTML' },
42
+ { value: 1, text: 'CSS' },
43
+ { value: 2, text: 'Javascript' },
44
+ ]
45
+
46
+ const EMPTY_INPUT_VALUE = ''
47
+ const getAutocompleteDisplayValue = (item: Item | null) =>
48
+ item?.text || EMPTY_INPUT_VALUE
49
+
50
+ const filterOptions = (str = '', options: Item[] = []): Item[] | null => {
51
+ if (!str) {
52
+ return options
53
+ }
54
+ const result = options.filter(option =>
55
+ option?.text ? isSubstring(str, option.text) : false
56
+ )
57
+
58
+ return result.length > 0 ? result : null
59
+ }
60
+
61
+ const initialValues = {
62
+ 'default-gender': 'female',
63
+ }
64
+
65
+ const Example = () => {
66
+ const [skillInputValue, setSkillInputValue] =
67
+ useState<string>(EMPTY_INPUT_VALUE)
68
+ const skillOptions = filterOptions(skillInputValue, skills)
69
+
70
+ const [autocompleteValue, setAutocompleteValue] =
71
+ useState<string>(EMPTY_INPUT_VALUE)
72
+ const [autocompleteOptions, setAutocompleteOptions] = useState<Item[] | null>(
73
+ countries
74
+ )
75
+
76
+ return (
77
+ <Form
78
+ autoComplete='off'
79
+ onSubmit={values => window.alert(JSON.stringify(values, undefined, 2))}
80
+ initialValues={initialValues}
81
+ >
82
+ <Input
83
+ enableReset
84
+ onResetClick={(set: (value: string) => void) => {
85
+ set('')
86
+ }}
87
+ required
88
+ name='default-firstName'
89
+ label='First name'
90
+ placeholder='e.g. Bruce'
91
+ />
92
+ <Input
93
+ required
94
+ name='default-lastName'
95
+ label='Last name'
96
+ placeholder='e.g. Wayne'
97
+ />
98
+ <NumberInput
99
+ enableReset
100
+ required
101
+ name='default-age'
102
+ label="What's your age?"
103
+ placeholder='e.g. 25'
104
+ />
105
+ <RadioGroup name='default-gender' label='Gender'>
106
+ <Radio label='Male' value='male' />
107
+ <Radio label='Female' value='female' />
108
+ </RadioGroup>
109
+ <RadioGroup name='default-gender' label='Gender' horizontal spacing={8}>
110
+ <ButtonRadio value='male'>Male</ButtonRadio>
111
+ <ButtonRadio value='female'>Female</ButtonRadio>
112
+ </RadioGroup>
113
+ <DatePicker name='default-dateOfBirth' label='Date of birth' />
114
+ <TimePicker name='default-timeOfBirth' label='Time of birth' />
115
+ <TagSelector
116
+ name='default-skills'
117
+ label='Skills'
118
+ inputValue={skillInputValue}
119
+ options={skillOptions}
120
+ onInputChange={setSkillInputValue}
121
+ />
122
+ <CheckboxGroup name='default-hobbies' label='Hobbies'>
123
+ <Checkbox label='Skiing' value='skiing' />
124
+ <Checkbox label='Free diving' value='freeDiving' />
125
+ <Checkbox label='Dancing' value='dancing' />
126
+ </CheckboxGroup>
127
+ <CheckboxGroup
128
+ name='default-hobbies'
129
+ label='Hobbies'
130
+ horizontal
131
+ spacing={8}
132
+ >
133
+ <ButtonCheckbox value='skiing'>Skiing</ButtonCheckbox>
134
+ <ButtonCheckbox value='freeDiving'>Free diving</ButtonCheckbox>
135
+ <ButtonCheckbox value='dancing'>Dancing</ButtonCheckbox>
136
+ </CheckboxGroup>
137
+ <Select
138
+ enableReset
139
+ required
140
+ name='default-businessType'
141
+ label='Business type'
142
+ width='auto'
143
+ options={[
144
+ { value: 0, text: 'Company' },
145
+ { value: 1, text: 'Individual' },
146
+ ]}
147
+ />
148
+ <Select
149
+ name='default-origin_country'
150
+ label='Origin country'
151
+ width='auto'
152
+ options={countries}
153
+ />
154
+ <Autocomplete
155
+ name='default-current_country'
156
+ label='Current country'
157
+ placeholder='Start typing country...'
158
+ width='auto'
159
+ value={autocompleteValue}
160
+ options={autocompleteOptions}
161
+ onSelect={(item: Item) => {
162
+ console.log('onSelect returns item object:', item)
163
+
164
+ const itemValue = getAutocompleteDisplayValue(item)
165
+
166
+ if (autocompleteValue !== itemValue) {
167
+ setAutocompleteValue(itemValue)
168
+ }
169
+ }}
170
+ onChange={(newValue: string) => {
171
+ console.log('onChange returns just item value:', newValue)
172
+
173
+ setAutocompleteOptions(filterOptions(newValue, countries))
174
+ setAutocompleteValue(newValue)
175
+ }}
176
+ getDisplayValue={getAutocompleteDisplayValue}
177
+ />
178
+ <Rating.Stars
179
+ name='default-rating'
180
+ label='How much do you love Picasso?'
181
+ required
182
+ />
183
+ <Rating.Thumbs
184
+ name='default-thumbs'
185
+ label='Would you recommend picasso?'
186
+ required
187
+ />
188
+ <FileInput
189
+ required
190
+ name='default-resume'
191
+ label='Resume'
192
+ status='No file selected.'
193
+ />
194
+ <Dropzone label='Attachments' required name='default-attachments' />
195
+ <AvatarUpload
196
+ label='Profile photo'
197
+ required
198
+ name='default-avatarUpload'
199
+ />
200
+ <Checkbox
201
+ required
202
+ name='default-legal'
203
+ label='I confirm that I have legal permission from the client to feature this project.'
204
+ />
205
+ <Switch
206
+ name='default-publicProfile'
207
+ label='Public Profile'
208
+ width='auto'
209
+ />
210
+
211
+ <FormActionsContainer top={SPACING_4}>
212
+ <SubmitButton>Submit</SubmitButton>
213
+ </FormActionsContainer>
214
+ </Form>
215
+ )
216
+ }
217
+
218
+ export default Example
@@ -0,0 +1,42 @@
1
+ import React from 'react'
2
+ import { Container } from '@toptal/picasso'
3
+ import { SPACING_4 } from '@toptal/picasso-utils'
4
+ import { FormNonCompound, Dropzone, SubmitButton } from '@toptal/picasso-forms'
5
+ import type { FileUpload } from '@toptal/picasso/FileInput'
6
+
7
+ type FormType = {
8
+ 'dropzone-attachments': FileUpload[]
9
+ }
10
+
11
+ const Example = () => {
12
+ const MAX_SIZE = 2
13
+ const initialAttachments = [{ file: new File(['resume.pdf'], 'resume.pdf') }]
14
+
15
+ const handleSubmit = ({ 'dropzone-attachments': attachments }: FormType) => {
16
+ window.alert(
17
+ `Uploading: ${attachments.map(({ file }) => file.name).join(', ')}`
18
+ )
19
+ }
20
+
21
+ return (
22
+ <FormNonCompound<FormType>
23
+ autoComplete='off'
24
+ onSubmit={handleSubmit}
25
+ initialValues={{
26
+ 'dropzone-attachments': initialAttachments,
27
+ }}
28
+ >
29
+ <Dropzone
30
+ required
31
+ name='dropzone-attachments'
32
+ dropzoneHint={`Max file size: ${MAX_SIZE}MB.`}
33
+ hint='These documents will be used to analyze and identify your potential.'
34
+ />
35
+ <Container top={SPACING_4}>
36
+ <SubmitButton>Submit</SubmitButton>
37
+ </Container>
38
+ </FormNonCompound>
39
+ )
40
+ }
41
+
42
+ export default Example
@@ -0,0 +1,58 @@
1
+ import React from 'react'
2
+ import { Container } from '@toptal/picasso'
3
+ import { SPACING_4 } from '@toptal/picasso-utils'
4
+ import {
5
+ FormNonCompound,
6
+ PasswordInput,
7
+ SubmitButton,
8
+ } from '@toptal/picasso-forms'
9
+
10
+ type FormType = {
11
+ 'fieldRequirements-password': string
12
+ 'fieldRequirements-confirmPassword': string
13
+ }
14
+
15
+ const Example = () => {
16
+ const handleSubmit = ({
17
+ 'fieldRequirements-password': password,
18
+ 'fieldRequirements-confirmPassword': confirmPassword,
19
+ }: FormType) => {
20
+ window.alert(`Password: ${password}, Confirm Password: ${confirmPassword}`)
21
+ }
22
+
23
+ return (
24
+ <FormNonCompound<FormType>
25
+ autoComplete='off'
26
+ onSubmit={handleSubmit}
27
+ initialValues={{
28
+ 'fieldRequirements-password': '',
29
+ 'fieldRequirements-confirmPassword': '',
30
+ }}
31
+ >
32
+ <PasswordInput
33
+ label='Password'
34
+ name='fieldRequirements-password'
35
+ required
36
+ />
37
+ <PasswordInput
38
+ label='Confirm password'
39
+ name='fieldRequirements-confirmPassword'
40
+ hideRequirements
41
+ required
42
+ validate={(confirmPassword, allValues) => {
43
+ if (
44
+ (allValues as FormType)['fieldRequirements-password'] !==
45
+ confirmPassword
46
+ ) {
47
+ return 'Passwords do not match'
48
+ }
49
+ }}
50
+ />
51
+ <Container top={SPACING_4}>
52
+ <SubmitButton>Submit</SubmitButton>
53
+ </Container>
54
+ </FormNonCompound>
55
+ )
56
+ }
57
+
58
+ export default Example
@@ -0,0 +1,43 @@
1
+ import React from 'react'
2
+ import { Container } from '@toptal/picasso'
3
+ import { SPACING_4 } from '@toptal/picasso-utils'
4
+ import { FormNonCompound, FileInput, SubmitButton } from '@toptal/picasso-forms'
5
+ import type { FileUpload } from '@toptal/picasso/FileInput'
6
+
7
+ type FormType = {
8
+ 'fileInput-attachments': FileUpload[]
9
+ }
10
+
11
+ const Example = () => {
12
+ const MAX_SIZE = 2
13
+ const initialAttachments = [
14
+ { file: new File(['image.png'], 'image.png') },
15
+ { file: new File(['resume.pdf'], 'resume.pdf') },
16
+ ]
17
+
18
+ const handleSubmit = ({ 'fileInput-attachments': attachments }: FormType) => {
19
+ window.alert(
20
+ `Uploading: ${attachments.map(({ file }) => file.name).join(', ')}`
21
+ )
22
+ }
23
+
24
+ return (
25
+ <FormNonCompound<FormType>
26
+ autoComplete='off'
27
+ onSubmit={handleSubmit}
28
+ initialValues={{
29
+ 'fileInput-attachments': initialAttachments,
30
+ }}
31
+ >
32
+ <FileInput
33
+ name='fileInput-attachments'
34
+ hint={`Max file size: ${MAX_SIZE}MB.`}
35
+ />
36
+ <Container top={SPACING_4}>
37
+ <SubmitButton>Submit</SubmitButton>
38
+ </Container>
39
+ </FormNonCompound>
40
+ )
41
+ }
42
+
43
+ export default Example
@@ -0,0 +1,96 @@
1
+ import React from 'react'
2
+ import { Container } from '@toptal/picasso'
3
+ import { SPACING_4 } from '@toptal/picasso-utils'
4
+ import type { FormConfigProps } from '@toptal/picasso-forms'
5
+ import {
6
+ FormNonCompound,
7
+ ConfigProvider,
8
+ SubmitButton,
9
+ Autocomplete,
10
+ DatePicker,
11
+ Input,
12
+ NumberInput,
13
+ PasswordInput,
14
+ RichTextEditor,
15
+ Select,
16
+ TagSelector,
17
+ TimePicker,
18
+ } from '@toptal/picasso-forms'
19
+ import { htmlToHast } from '@toptal/picasso-rich-text-editor/utils'
20
+
21
+ const formConfig: FormConfigProps = {
22
+ highlightAutofill: true,
23
+ }
24
+
25
+ const april2nd = new Date(2023, 3, 2)
26
+
27
+ const INITIAL_RTE_VALUE = '<p>Rich Text Editor</p>'
28
+
29
+ const Example = () => (
30
+ <ConfigProvider value={formConfig}>
31
+ <FormNonCompound
32
+ onSubmit={values => window.alert(JSON.stringify(values, undefined, 2))}
33
+ initialValues={{
34
+ 'highlight-firstName': 'Bruce',
35
+ 'highlight-autocomplete': 'foo',
36
+ 'highlight-datepicker': april2nd,
37
+ 'highlight-numberinput': 1,
38
+ 'highlight-passwordinput': 'password',
39
+ 'highlight-rte': INITIAL_RTE_VALUE,
40
+ 'highlight-select': 'foo',
41
+ 'highlight-tagselector': 'foo',
42
+ 'highlight-timepicker': april2nd,
43
+ }}
44
+ >
45
+ <Input
46
+ required
47
+ name='highlight-firstName'
48
+ label='textinput'
49
+ placeholder='e.g. Bruce'
50
+ />
51
+
52
+ <Input
53
+ required
54
+ name='highlight-noDefaultValue'
55
+ label='textinput'
56
+ placeholder='e.g. Bruce'
57
+ />
58
+
59
+ <Autocomplete
60
+ label='autocomplete'
61
+ value='foo'
62
+ name='highlight-autocomplete'
63
+ />
64
+
65
+ <DatePicker label='datepicker' name='highlight-datepicker' />
66
+ <NumberInput label='numberinput' name='highlight-numberinput' />
67
+ <PasswordInput label='passwordinput' name='highlight-passwordinput' />
68
+ <RichTextEditor
69
+ id='highlight-rte'
70
+ label='rte'
71
+ name='highlight-rte'
72
+ defaultValue={htmlToHast(INITIAL_RTE_VALUE)} // we expect HAST from BE
73
+ />
74
+ <Select
75
+ options={[{ value: 'foo', text: 'first option ' }]}
76
+ label='select'
77
+ name='highlight-select'
78
+ />
79
+ <TagSelector
80
+ options={[{ value: 'foo', text: 'first option ' }]}
81
+ label='tagselector'
82
+ name='highlight-tagselector'
83
+ inputValue='foo'
84
+ />
85
+ <TimePicker label='timepicker' name='highlight-timepicker' />
86
+
87
+ <Container top={SPACING_4}>
88
+ <SubmitButton id='highlight-autofill-submit-button'>
89
+ Submit
90
+ </SubmitButton>
91
+ </Container>
92
+ </FormNonCompound>
93
+ </ConfigProvider>
94
+ )
95
+
96
+ export default Example