@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.
- package/CHANGELOG.md +657 -0
- package/{Autocomplete → dist-package/Autocomplete}/Autocomplete.d.ts +0 -0
- package/{Autocomplete → dist-package/Autocomplete}/Autocomplete.js +0 -0
- package/{Autocomplete → dist-package/Autocomplete}/Autocomplete.js.map +0 -0
- package/{Autocomplete → dist-package/Autocomplete}/index.d.ts +0 -0
- package/{Autocomplete → dist-package/Autocomplete}/index.js +0 -0
- package/{Autocomplete → dist-package/Autocomplete}/index.js.map +0 -0
- package/{ButtonCheckbox → dist-package/ButtonCheckbox}/ButtonCheckbox.d.ts +0 -0
- package/{ButtonCheckbox → dist-package/ButtonCheckbox}/ButtonCheckbox.js +0 -0
- package/{ButtonCheckbox → dist-package/ButtonCheckbox}/ButtonCheckbox.js.map +0 -0
- package/{ButtonCheckbox → dist-package/ButtonCheckbox}/index.d.ts +0 -0
- package/{ButtonCheckbox → dist-package/ButtonCheckbox}/index.js +0 -0
- package/{ButtonCheckbox → dist-package/ButtonCheckbox}/index.js.map +0 -0
- package/{ButtonRadio → dist-package/ButtonRadio}/ButtonRadio.d.ts +0 -0
- package/{ButtonRadio → dist-package/ButtonRadio}/ButtonRadio.js +0 -0
- package/{ButtonRadio → dist-package/ButtonRadio}/ButtonRadio.js.map +0 -0
- package/{ButtonRadio → dist-package/ButtonRadio}/index.d.ts +0 -0
- package/{ButtonRadio → dist-package/ButtonRadio}/index.js +0 -0
- package/{ButtonRadio → dist-package/ButtonRadio}/index.js.map +0 -0
- package/{Checkbox → dist-package/Checkbox}/Checkbox.d.ts +0 -0
- package/{Checkbox → dist-package/Checkbox}/Checkbox.js +0 -0
- package/{Checkbox → dist-package/Checkbox}/Checkbox.js.map +0 -0
- package/{Checkbox → dist-package/Checkbox}/index.d.ts +0 -0
- package/{Checkbox → dist-package/Checkbox}/index.js +0 -0
- package/{Checkbox → dist-package/Checkbox}/index.js.map +0 -0
- package/{CheckboxGroup → dist-package/CheckboxGroup}/CheckboxGroup.d.ts +0 -0
- package/{CheckboxGroup → dist-package/CheckboxGroup}/CheckboxGroup.js +0 -0
- package/{CheckboxGroup → dist-package/CheckboxGroup}/CheckboxGroup.js.map +0 -0
- package/{CheckboxGroup → dist-package/CheckboxGroup}/CheckboxGroupContext.d.ts +0 -0
- package/{CheckboxGroup → dist-package/CheckboxGroup}/CheckboxGroupContext.js +0 -0
- package/{CheckboxGroup → dist-package/CheckboxGroup}/CheckboxGroupContext.js.map +0 -0
- package/{CheckboxGroup → dist-package/CheckboxGroup}/index.d.ts +0 -0
- package/{CheckboxGroup → dist-package/CheckboxGroup}/index.js +0 -0
- package/{CheckboxGroup → dist-package/CheckboxGroup}/index.js.map +0 -0
- package/{DatePicker → dist-package/DatePicker}/DatePicker.d.ts +0 -0
- package/{DatePicker → dist-package/DatePicker}/DatePicker.js +0 -0
- package/{DatePicker → dist-package/DatePicker}/DatePicker.js.map +0 -0
- package/{DatePicker → dist-package/DatePicker}/index.d.ts +0 -0
- package/{DatePicker → dist-package/DatePicker}/index.js +0 -0
- package/{DatePicker → dist-package/DatePicker}/index.js.map +0 -0
- package/{FieldWrapper → dist-package/FieldWrapper}/FieldWrapper.d.ts +0 -0
- package/{FieldWrapper → dist-package/FieldWrapper}/FieldWrapper.js +0 -0
- package/{FieldWrapper → dist-package/FieldWrapper}/FieldWrapper.js.map +0 -0
- package/{FieldWrapper → dist-package/FieldWrapper}/index.d.ts +0 -0
- package/{FieldWrapper → dist-package/FieldWrapper}/index.js +0 -0
- package/{FieldWrapper → dist-package/FieldWrapper}/index.js.map +0 -0
- package/{FileInput → dist-package/FileInput}/FileInput.d.ts +0 -0
- package/{FileInput → dist-package/FileInput}/FileInput.js +0 -0
- package/{FileInput → dist-package/FileInput}/FileInput.js.map +0 -0
- package/{FileInput → dist-package/FileInput}/index.d.ts +0 -0
- package/{FileInput → dist-package/FileInput}/index.js +0 -0
- package/{FileInput → dist-package/FileInput}/index.js.map +0 -0
- package/{Form → dist-package/Form}/Form.d.ts +0 -0
- package/{Form → dist-package/Form}/Form.js +0 -0
- package/{Form → dist-package/Form}/Form.js.map +0 -0
- package/{Form → dist-package/Form}/FormContext.d.ts +0 -0
- package/{Form → dist-package/Form}/FormContext.js +0 -0
- package/{Form → dist-package/Form}/FormContext.js.map +0 -0
- package/{Form → dist-package/Form}/index.d.ts +0 -0
- package/{Form → dist-package/Form}/index.js +0 -0
- package/{Form → dist-package/Form}/index.js.map +0 -0
- package/{FormConfig → dist-package/FormConfig}/FormConfig.d.ts +0 -0
- package/{FormConfig → dist-package/FormConfig}/FormConfig.js +0 -0
- package/{FormConfig → dist-package/FormConfig}/FormConfig.js.map +0 -0
- package/{FormConfig → dist-package/FormConfig}/index.d.ts +0 -0
- package/{FormConfig → dist-package/FormConfig}/index.js +0 -0
- package/{FormConfig → dist-package/FormConfig}/index.js.map +0 -0
- package/{Input → dist-package/Input}/Input.d.ts +0 -0
- package/{Input → dist-package/Input}/Input.js +0 -0
- package/{Input → dist-package/Input}/Input.js.map +0 -0
- package/{Input → dist-package/Input}/index.d.ts +0 -0
- package/{Input → dist-package/Input}/index.js +0 -0
- package/{Input → dist-package/Input}/index.js.map +0 -0
- package/{Input → dist-package/Input}/utils/get-input-name.d.ts +0 -0
- package/{Input → dist-package/Input}/utils/get-input-name.js +0 -0
- package/{Input → dist-package/Input}/utils/get-input-name.js.map +0 -0
- package/{Input → dist-package/Input}/utils/get-input-name.test.d.ts +0 -0
- package/{Input → dist-package/Input}/utils/get-input-name.test.js +0 -0
- package/{Input → dist-package/Input}/utils/get-input-name.test.js.map +0 -0
- package/{NumberInput → dist-package/NumberInput}/NumberInput.d.ts +0 -0
- package/{NumberInput → dist-package/NumberInput}/NumberInput.js +0 -0
- package/{NumberInput → dist-package/NumberInput}/NumberInput.js.map +0 -0
- package/{NumberInput → dist-package/NumberInput}/index.d.ts +0 -0
- package/{NumberInput → dist-package/NumberInput}/index.js +0 -0
- package/{NumberInput → dist-package/NumberInput}/index.js.map +0 -0
- package/dist-package/README.md +29 -0
- package/{Radio → dist-package/Radio}/Radio.d.ts +0 -0
- package/{Radio → dist-package/Radio}/Radio.js +0 -0
- package/{Radio → dist-package/Radio}/Radio.js.map +0 -0
- package/{Radio → dist-package/Radio}/index.d.ts +0 -0
- package/{Radio → dist-package/Radio}/index.js +0 -0
- package/{Radio → dist-package/Radio}/index.js.map +0 -0
- package/{RadioGroup → dist-package/RadioGroup}/RadioGroup.d.ts +0 -0
- package/{RadioGroup → dist-package/RadioGroup}/RadioGroup.js +0 -0
- package/{RadioGroup → dist-package/RadioGroup}/RadioGroup.js.map +0 -0
- package/{RadioGroup → dist-package/RadioGroup}/RadioGroupContext.d.ts +0 -0
- package/{RadioGroup → dist-package/RadioGroup}/RadioGroupContext.js +0 -0
- package/{RadioGroup → dist-package/RadioGroup}/RadioGroupContext.js.map +0 -0
- package/{RadioGroup → dist-package/RadioGroup}/index.d.ts +0 -0
- package/{RadioGroup → dist-package/RadioGroup}/index.js +0 -0
- package/{RadioGroup → dist-package/RadioGroup}/index.js.map +0 -0
- package/{Rating → dist-package/Rating}/Rating.d.ts +0 -0
- package/{Rating → dist-package/Rating}/Rating.js +0 -0
- package/{Rating → dist-package/Rating}/Rating.js.map +0 -0
- package/{Rating → dist-package/Rating}/index.d.ts +0 -0
- package/{Rating → dist-package/Rating}/index.js +0 -0
- package/{Rating → dist-package/Rating}/index.js.map +0 -0
- package/{Select → dist-package/Select}/Select.d.ts +0 -0
- package/{Select → dist-package/Select}/Select.js +0 -0
- package/{Select → dist-package/Select}/Select.js.map +0 -0
- package/{Select → dist-package/Select}/index.d.ts +0 -0
- package/{Select → dist-package/Select}/index.js +0 -0
- package/{Select → dist-package/Select}/index.js.map +0 -0
- package/{SubmitButton → dist-package/SubmitButton}/SubmitButton.d.ts +0 -0
- package/{SubmitButton → dist-package/SubmitButton}/SubmitButton.js +0 -0
- package/{SubmitButton → dist-package/SubmitButton}/SubmitButton.js.map +0 -0
- package/{SubmitButton → dist-package/SubmitButton}/index.d.ts +0 -0
- package/{SubmitButton → dist-package/SubmitButton}/index.js +0 -0
- package/{SubmitButton → dist-package/SubmitButton}/index.js.map +0 -0
- package/{Switch → dist-package/Switch}/Switch.d.ts +0 -0
- package/{Switch → dist-package/Switch}/Switch.js +0 -0
- package/{Switch → dist-package/Switch}/Switch.js.map +0 -0
- package/{Switch → dist-package/Switch}/index.d.ts +0 -0
- package/{Switch → dist-package/Switch}/index.js +0 -0
- package/{Switch → dist-package/Switch}/index.js.map +0 -0
- package/{TagSelector → dist-package/TagSelector}/TagSelector.d.ts +0 -0
- package/{TagSelector → dist-package/TagSelector}/TagSelector.js +0 -0
- package/{TagSelector → dist-package/TagSelector}/TagSelector.js.map +0 -0
- package/{TagSelector → dist-package/TagSelector}/index.d.ts +0 -0
- package/{TagSelector → dist-package/TagSelector}/index.js +0 -0
- package/{TagSelector → dist-package/TagSelector}/index.js.map +0 -0
- package/{TimePicker → dist-package/TimePicker}/TimePicker.d.ts +0 -0
- package/{TimePicker → dist-package/TimePicker}/TimePicker.js +0 -0
- package/{TimePicker → dist-package/TimePicker}/TimePicker.js.map +0 -0
- package/{TimePicker → dist-package/TimePicker}/index.d.ts +0 -0
- package/{TimePicker → dist-package/TimePicker}/index.js +0 -0
- package/{TimePicker → dist-package/TimePicker}/index.js.map +0 -0
- package/{index.d.ts → dist-package/index.d.ts} +2 -1
- package/{index.js → dist-package/index.js} +0 -1
- package/dist-package/index.js.map +1 -0
- package/dist-package/package.json +44 -0
- package/{utils → dist-package/utils}/flat-map.d.ts +0 -0
- package/{utils → dist-package/utils}/flat-map.js +0 -0
- package/{utils → dist-package/utils}/flat-map.js.map +0 -0
- package/{utils → dist-package/utils}/index.d.ts +0 -0
- package/{utils → dist-package/utils}/index.js +0 -0
- package/{utils → dist-package/utils}/index.js.map +0 -0
- package/{utils → dist-package/utils}/scroll-to-error-decorator.d.ts +0 -0
- package/{utils → dist-package/utils}/scroll-to-error-decorator.js +0 -0
- package/{utils → dist-package/utils}/scroll-to-error-decorator.js.map +0 -0
- package/{utils → dist-package/utils}/validators.d.ts +0 -0
- package/{utils → dist-package/utils}/validators.js +0 -0
- package/{utils → dist-package/utils}/validators.js.map +0 -0
- package/package.json +4 -5
- package/src/Autocomplete/Autocomplete.tsx +21 -0
- package/src/Autocomplete/index.ts +1 -0
- package/src/ButtonCheckbox/ButtonCheckbox.tsx +57 -0
- package/src/ButtonCheckbox/index.ts +1 -0
- package/src/ButtonRadio/ButtonRadio.tsx +24 -0
- package/src/ButtonRadio/index.ts +1 -0
- package/src/Checkbox/Checkbox.tsx +73 -0
- package/src/Checkbox/__snapshots__/test.tsx.snap +254 -0
- package/src/Checkbox/index.ts +1 -0
- package/src/Checkbox/test.tsx +91 -0
- package/src/CheckboxGroup/CheckboxGroup.tsx +30 -0
- package/src/CheckboxGroup/CheckboxGroupContext.ts +3 -0
- package/src/CheckboxGroup/index.ts +3 -0
- package/src/CheckboxGroup/test.tsx +35 -0
- package/src/DatePicker/DatePicker.tsx +26 -0
- package/src/DatePicker/index.ts +1 -0
- package/src/FieldWrapper/FieldWrapper.tsx +287 -0
- package/src/FieldWrapper/index.ts +2 -0
- package/src/FieldWrapper/story/index.jsx +137 -0
- package/src/FileInput/FileInput.tsx +66 -0
- package/src/FileInput/index.ts +1 -0
- package/src/Form/Form.tsx +181 -0
- package/src/Form/FormContext.ts +38 -0
- package/src/Form/__image_snapshots__/form-default-snap.png +0 -0
- package/src/Form/__image_snapshots__/form-form-level-configurations-snap.png +0 -0
- package/src/Form/__snapshots__/test.tsx.snap +61 -0
- package/src/Form/index.ts +1 -0
- package/src/Form/story/BackendCommunication.example.tsx +139 -0
- package/src/Form/story/CustomFormLevelConfiguration.example.tsx +26 -0
- package/src/Form/story/CustomValidator.example.tsx +45 -0
- package/src/Form/story/Default.example.tsx +177 -0
- package/src/Form/story/FileInput.example.tsx +42 -0
- package/src/Form/story/ParseInput.example.tsx +28 -0
- package/src/Form/story/TitleCase.example.tsx +167 -0
- package/src/Form/story/ValidateOnSubmit.example.tsx +85 -0
- package/src/Form/story/index.jsx +203 -0
- package/src/Form/test.tsx +27 -0
- package/src/FormConfig/FormConfig.ts +12 -0
- package/src/FormConfig/index.ts +1 -0
- package/src/FormConfig/test.tsx +44 -0
- package/src/Input/Input.tsx +27 -0
- package/src/Input/index.ts +1 -0
- package/src/Input/test.tsx +34 -0
- package/src/Input/utils/get-input-name.test.ts +16 -0
- package/src/Input/utils/get-input-name.ts +11 -0
- package/src/NumberInput/NumberInput.tsx +45 -0
- package/src/NumberInput/index.ts +1 -0
- package/src/Radio/Radio.tsx +24 -0
- package/src/Radio/__snapshots__/test.tsx.snap +231 -0
- package/src/Radio/index.ts +1 -0
- package/src/Radio/test.tsx +49 -0
- package/src/RadioGroup/RadioGroup.tsx +39 -0
- package/src/RadioGroup/RadioGroupContext.ts +3 -0
- package/src/RadioGroup/index.ts +3 -0
- package/src/RadioGroup/test.tsx +35 -0
- package/src/Rating/Rating.tsx +22 -0
- package/src/Rating/index.ts +1 -0
- package/src/Select/Select.tsx +47 -0
- package/src/Select/index.ts +1 -0
- package/src/SubmitButton/SubmitButton.tsx +70 -0
- package/src/SubmitButton/__image_snapshots__/submitbutton-button-types-snap.png +0 -0
- package/src/SubmitButton/__image_snapshots__/submitbutton-default-snap.png +0 -0
- package/src/SubmitButton/index.ts +6 -0
- package/src/SubmitButton/story/ButtonTypes.example.tsx +46 -0
- package/src/SubmitButton/story/Default.example.tsx +15 -0
- package/src/SubmitButton/story/index.jsx +32 -0
- package/src/Switch/Switch.tsx +23 -0
- package/src/Switch/index.ts +1 -0
- package/src/TagSelector/TagSelector.tsx +25 -0
- package/src/TagSelector/index.ts +1 -0
- package/src/TimePicker/TimePicker.tsx +24 -0
- package/src/TimePicker/index.ts +1 -0
- package/src/index.ts +16 -0
- package/src/story/Deserialization.example.tsx +34 -0
- package/src/story/FormSpy.example.tsx +42 -0
- package/src/story/index.jsx +37 -0
- package/src/utils/flat-map.ts +4 -0
- package/src/utils/index.ts +3 -0
- package/src/utils/scroll-to-error-decorator.ts +78 -0
- package/src/utils/validators.ts +18 -0
- package/tsconfig.build.json +7 -0
- 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,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,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'
|