@toptal/picasso-forms 6.0.5 → 7.1.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.
- package/{dist-package/Autocomplete → Autocomplete}/Autocomplete.d.ts +0 -0
- package/{dist-package/Autocomplete → Autocomplete}/Autocomplete.js +0 -0
- package/{dist-package/Autocomplete → Autocomplete}/Autocomplete.js.map +0 -0
- package/{dist-package/Autocomplete → Autocomplete}/index.d.ts +0 -0
- package/{dist-package/Autocomplete → Autocomplete}/index.js +0 -0
- package/{dist-package/Autocomplete → Autocomplete}/index.js.map +0 -0
- package/{dist-package/ButtonCheckbox → ButtonCheckbox}/ButtonCheckbox.d.ts +0 -0
- package/{dist-package/ButtonCheckbox → ButtonCheckbox}/ButtonCheckbox.js +0 -0
- package/{dist-package/ButtonCheckbox → ButtonCheckbox}/ButtonCheckbox.js.map +0 -0
- package/{dist-package/ButtonCheckbox → ButtonCheckbox}/index.d.ts +0 -0
- package/{dist-package/ButtonCheckbox → ButtonCheckbox}/index.js +0 -0
- package/{dist-package/ButtonCheckbox → ButtonCheckbox}/index.js.map +0 -0
- package/{dist-package/ButtonRadio → ButtonRadio}/ButtonRadio.d.ts +0 -0
- package/{dist-package/ButtonRadio → ButtonRadio}/ButtonRadio.js +0 -0
- package/{dist-package/ButtonRadio → ButtonRadio}/ButtonRadio.js.map +0 -0
- package/{dist-package/ButtonRadio → ButtonRadio}/index.d.ts +0 -0
- package/{dist-package/ButtonRadio → ButtonRadio}/index.js +0 -0
- package/{dist-package/ButtonRadio → ButtonRadio}/index.js.map +0 -0
- package/{dist-package/Checkbox → Checkbox}/Checkbox.d.ts +0 -0
- package/{dist-package/Checkbox → Checkbox}/Checkbox.js +0 -0
- package/{dist-package/Checkbox → Checkbox}/Checkbox.js.map +0 -0
- package/{dist-package/Checkbox → Checkbox}/index.d.ts +0 -0
- package/{dist-package/Checkbox → Checkbox}/index.js +0 -0
- package/{dist-package/Checkbox → Checkbox}/index.js.map +0 -0
- package/{dist-package/CheckboxGroup → CheckboxGroup}/CheckboxGroup.d.ts +0 -0
- package/{dist-package/CheckboxGroup → CheckboxGroup}/CheckboxGroup.js +0 -0
- package/{dist-package/CheckboxGroup → CheckboxGroup}/CheckboxGroup.js.map +0 -0
- package/{dist-package/CheckboxGroup → CheckboxGroup}/CheckboxGroupContext.d.ts +0 -0
- package/{dist-package/CheckboxGroup → CheckboxGroup}/CheckboxGroupContext.js +0 -0
- package/{dist-package/CheckboxGroup → CheckboxGroup}/CheckboxGroupContext.js.map +0 -0
- package/{dist-package/CheckboxGroup → CheckboxGroup}/index.d.ts +0 -0
- package/{dist-package/CheckboxGroup → CheckboxGroup}/index.js +0 -0
- package/{dist-package/CheckboxGroup → CheckboxGroup}/index.js.map +0 -0
- package/{dist-package/DatePicker → DatePicker}/DatePicker.d.ts +0 -0
- package/{dist-package/DatePicker → DatePicker}/DatePicker.js +0 -0
- package/{dist-package/DatePicker → DatePicker}/DatePicker.js.map +0 -0
- package/{dist-package/DatePicker → DatePicker}/index.d.ts +0 -0
- package/{dist-package/DatePicker → DatePicker}/index.js +0 -0
- package/{dist-package/DatePicker → DatePicker}/index.js.map +0 -0
- package/{dist-package/FieldWrapper → FieldWrapper}/FieldWrapper.d.ts +0 -0
- package/{dist-package/FieldWrapper → FieldWrapper}/FieldWrapper.js +0 -0
- package/{dist-package/FieldWrapper → FieldWrapper}/FieldWrapper.js.map +0 -0
- package/{dist-package/FieldWrapper → FieldWrapper}/index.d.ts +0 -0
- package/{dist-package/FieldWrapper → FieldWrapper}/index.js +0 -0
- package/{dist-package/FieldWrapper → FieldWrapper}/index.js.map +0 -0
- package/{dist-package/FileInput → FileInput}/FileInput.d.ts +0 -0
- package/{dist-package/FileInput → FileInput}/FileInput.js +0 -0
- package/{dist-package/FileInput → FileInput}/FileInput.js.map +0 -0
- package/{dist-package/FileInput → FileInput}/index.d.ts +0 -0
- package/{dist-package/FileInput → FileInput}/index.js +0 -0
- package/{dist-package/FileInput → FileInput}/index.js.map +0 -0
- package/{dist-package/Form → Form}/Form.d.ts +0 -0
- package/{dist-package/Form → Form}/Form.js +0 -0
- package/{dist-package/Form → Form}/Form.js.map +0 -0
- package/{dist-package/Form → Form}/FormContext.d.ts +0 -0
- package/{dist-package/Form → Form}/FormContext.js +0 -0
- package/{dist-package/Form → Form}/FormContext.js.map +0 -0
- package/{dist-package/Form → Form}/index.d.ts +0 -0
- package/{dist-package/Form → Form}/index.js +0 -0
- package/{dist-package/Form → Form}/index.js.map +0 -0
- package/{dist-package/FormConfig → FormConfig}/FormConfig.d.ts +0 -0
- package/{dist-package/FormConfig → FormConfig}/FormConfig.js +0 -0
- package/{dist-package/FormConfig → FormConfig}/FormConfig.js.map +0 -0
- package/{dist-package/FormConfig → FormConfig}/index.d.ts +0 -0
- package/{dist-package/FormConfig → FormConfig}/index.js +0 -0
- package/{dist-package/FormConfig → FormConfig}/index.js.map +0 -0
- package/{dist-package/Input → Input}/Input.d.ts +0 -0
- package/Input/Input.js +25 -0
- package/Input/Input.js.map +1 -0
- package/{dist-package/Input → Input}/index.d.ts +0 -0
- package/{dist-package/Input → Input}/index.js +0 -0
- package/{dist-package/Input → Input}/index.js.map +0 -0
- package/{dist-package/NumberInput → NumberInput}/NumberInput.d.ts +0 -0
- package/{dist-package/NumberInput → NumberInput}/NumberInput.js +0 -0
- package/{dist-package/NumberInput → NumberInput}/NumberInput.js.map +0 -0
- package/{dist-package/NumberInput → NumberInput}/index.d.ts +0 -0
- package/{dist-package/NumberInput → NumberInput}/index.js +0 -0
- package/{dist-package/NumberInput → NumberInput}/index.js.map +0 -0
- package/{dist-package/Radio → Radio}/Radio.d.ts +0 -0
- package/{dist-package/Radio → Radio}/Radio.js +0 -0
- package/{dist-package/Radio → Radio}/Radio.js.map +0 -0
- package/{dist-package/Radio → Radio}/index.d.ts +0 -0
- package/{dist-package/Radio → Radio}/index.js +0 -0
- package/{dist-package/Radio → Radio}/index.js.map +0 -0
- package/{dist-package/RadioGroup → RadioGroup}/RadioGroup.d.ts +0 -0
- package/{dist-package/RadioGroup → RadioGroup}/RadioGroup.js +0 -0
- package/{dist-package/RadioGroup → RadioGroup}/RadioGroup.js.map +0 -0
- package/{dist-package/RadioGroup → RadioGroup}/RadioGroupContext.d.ts +0 -0
- package/{dist-package/RadioGroup → RadioGroup}/RadioGroupContext.js +0 -0
- package/{dist-package/RadioGroup → RadioGroup}/RadioGroupContext.js.map +0 -0
- package/{dist-package/RadioGroup → RadioGroup}/index.d.ts +0 -0
- package/{dist-package/RadioGroup → RadioGroup}/index.js +0 -0
- package/{dist-package/RadioGroup → RadioGroup}/index.js.map +0 -0
- package/{dist-package/Rating → Rating}/Rating.d.ts +0 -0
- package/{dist-package/Rating → Rating}/Rating.js +0 -0
- package/{dist-package/Rating → Rating}/Rating.js.map +0 -0
- package/{dist-package/Rating → Rating}/index.d.ts +0 -0
- package/{dist-package/Rating → Rating}/index.js +0 -0
- package/{dist-package/Rating → Rating}/index.js.map +0 -0
- package/{dist-package/Select → Select}/Select.d.ts +0 -0
- package/{dist-package/Select → Select}/Select.js +0 -0
- package/{dist-package/Select → Select}/Select.js.map +0 -0
- package/{dist-package/Select → Select}/index.d.ts +0 -0
- package/{dist-package/Select → Select}/index.js +0 -0
- package/{dist-package/Select → Select}/index.js.map +0 -0
- package/{dist-package/SubmitButton → SubmitButton}/SubmitButton.d.ts +0 -0
- package/{dist-package/SubmitButton → SubmitButton}/SubmitButton.js +0 -0
- package/{dist-package/SubmitButton → SubmitButton}/SubmitButton.js.map +0 -0
- package/{dist-package/SubmitButton → SubmitButton}/index.d.ts +0 -0
- package/{dist-package/SubmitButton → SubmitButton}/index.js +0 -0
- package/{dist-package/SubmitButton → SubmitButton}/index.js.map +0 -0
- package/{dist-package/Switch → Switch}/Switch.d.ts +0 -0
- package/{dist-package/Switch → Switch}/Switch.js +0 -0
- package/{dist-package/Switch → Switch}/Switch.js.map +0 -0
- package/{dist-package/Switch → Switch}/index.d.ts +0 -0
- package/{dist-package/Switch → Switch}/index.js +0 -0
- package/{dist-package/Switch → Switch}/index.js.map +0 -0
- package/{dist-package/TagSelector → TagSelector}/TagSelector.d.ts +0 -0
- package/{dist-package/TagSelector → TagSelector}/TagSelector.js +0 -0
- package/{dist-package/TagSelector → TagSelector}/TagSelector.js.map +0 -0
- package/{dist-package/TagSelector → TagSelector}/index.d.ts +0 -0
- package/{dist-package/TagSelector → TagSelector}/index.js +0 -0
- package/{dist-package/TagSelector → TagSelector}/index.js.map +0 -0
- package/{dist-package/TimePicker → TimePicker}/TimePicker.d.ts +0 -0
- package/{dist-package/TimePicker → TimePicker}/TimePicker.js +0 -0
- package/{dist-package/TimePicker → TimePicker}/TimePicker.js.map +0 -0
- package/{dist-package/TimePicker → TimePicker}/index.d.ts +0 -0
- package/{dist-package/TimePicker → TimePicker}/index.js +0 -0
- package/{dist-package/TimePicker → TimePicker}/index.js.map +0 -0
- package/{dist-package/index.d.ts → index.d.ts} +0 -0
- package/{dist-package/index.js → index.js} +0 -0
- package/{dist-package/index.js.map → index.js.map} +0 -0
- package/package.json +6 -6
- package/{dist-package/utils → utils}/flat-map.d.ts +0 -0
- package/{dist-package/utils → utils}/flat-map.js +0 -0
- package/{dist-package/utils → utils}/flat-map.js.map +0 -0
- package/{dist-package/utils → utils}/index.d.ts +0 -0
- package/{dist-package/utils → utils}/index.js +0 -0
- package/{dist-package/utils → utils}/index.js.map +0 -0
- package/{dist-package/utils → utils}/scroll-to-error-decorator.d.ts +0 -0
- package/{dist-package/utils → utils}/scroll-to-error-decorator.js +0 -0
- package/{dist-package/utils → utils}/scroll-to-error-decorator.js.map +0 -0
- package/{dist-package/utils → utils}/validators.d.ts +0 -0
- package/{dist-package/utils → utils}/validators.js +0 -0
- package/{dist-package/utils → utils}/validators.js.map +0 -0
- package/CHANGELOG.md +0 -657
- package/dist-package/Input/Input.js +0 -26
- package/dist-package/Input/Input.js.map +0 -1
- package/dist-package/Input/utils/get-input-name.d.ts +0 -2
- package/dist-package/Input/utils/get-input-name.js +0 -9
- package/dist-package/Input/utils/get-input-name.js.map +0 -1
- package/dist-package/Input/utils/get-input-name.test.d.ts +0 -1
- package/dist-package/Input/utils/get-input-name.test.js +0 -12
- package/dist-package/Input/utils/get-input-name.test.js.map +0 -1
- package/dist-package/README.md +0 -29
- package/dist-package/package.json +0 -44
- package/src/Autocomplete/Autocomplete.tsx +0 -21
- package/src/Autocomplete/index.ts +0 -1
- package/src/ButtonCheckbox/ButtonCheckbox.tsx +0 -57
- package/src/ButtonCheckbox/index.ts +0 -1
- package/src/ButtonRadio/ButtonRadio.tsx +0 -24
- package/src/ButtonRadio/index.ts +0 -1
- package/src/Checkbox/Checkbox.tsx +0 -73
- package/src/Checkbox/__snapshots__/test.tsx.snap +0 -254
- package/src/Checkbox/index.ts +0 -1
- package/src/Checkbox/test.tsx +0 -91
- package/src/CheckboxGroup/CheckboxGroup.tsx +0 -30
- package/src/CheckboxGroup/CheckboxGroupContext.ts +0 -3
- package/src/CheckboxGroup/index.ts +0 -3
- package/src/CheckboxGroup/test.tsx +0 -35
- package/src/DatePicker/DatePicker.tsx +0 -26
- package/src/DatePicker/index.ts +0 -1
- package/src/FieldWrapper/FieldWrapper.tsx +0 -287
- package/src/FieldWrapper/index.ts +0 -2
- package/src/FieldWrapper/story/index.jsx +0 -137
- package/src/FileInput/FileInput.tsx +0 -66
- package/src/FileInput/index.ts +0 -1
- package/src/Form/Form.tsx +0 -181
- package/src/Form/FormContext.ts +0 -38
- 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 +0 -61
- package/src/Form/index.ts +0 -1
- package/src/Form/story/BackendCommunication.example.tsx +0 -139
- package/src/Form/story/CustomFormLevelConfiguration.example.tsx +0 -26
- package/src/Form/story/CustomValidator.example.tsx +0 -45
- package/src/Form/story/Default.example.tsx +0 -177
- package/src/Form/story/FileInput.example.tsx +0 -42
- package/src/Form/story/ParseInput.example.tsx +0 -28
- package/src/Form/story/TitleCase.example.tsx +0 -167
- package/src/Form/story/ValidateOnSubmit.example.tsx +0 -85
- package/src/Form/story/index.jsx +0 -203
- package/src/Form/test.tsx +0 -27
- package/src/FormConfig/FormConfig.ts +0 -12
- package/src/FormConfig/index.ts +0 -1
- package/src/FormConfig/test.tsx +0 -44
- package/src/Input/Input.tsx +0 -27
- package/src/Input/index.ts +0 -1
- package/src/Input/test.tsx +0 -34
- package/src/Input/utils/get-input-name.test.ts +0 -16
- package/src/Input/utils/get-input-name.ts +0 -11
- package/src/NumberInput/NumberInput.tsx +0 -45
- package/src/NumberInput/index.ts +0 -1
- package/src/Radio/Radio.tsx +0 -24
- package/src/Radio/__snapshots__/test.tsx.snap +0 -231
- package/src/Radio/index.ts +0 -1
- package/src/Radio/test.tsx +0 -49
- package/src/RadioGroup/RadioGroup.tsx +0 -39
- package/src/RadioGroup/RadioGroupContext.ts +0 -3
- package/src/RadioGroup/index.ts +0 -3
- package/src/RadioGroup/test.tsx +0 -35
- package/src/Rating/Rating.tsx +0 -22
- package/src/Rating/index.ts +0 -1
- package/src/Select/Select.tsx +0 -47
- package/src/Select/index.ts +0 -1
- package/src/SubmitButton/SubmitButton.tsx +0 -70
- 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 +0 -6
- package/src/SubmitButton/story/ButtonTypes.example.tsx +0 -46
- package/src/SubmitButton/story/Default.example.tsx +0 -15
- package/src/SubmitButton/story/index.jsx +0 -32
- package/src/Switch/Switch.tsx +0 -23
- package/src/Switch/index.ts +0 -1
- package/src/TagSelector/TagSelector.tsx +0 -25
- package/src/TagSelector/index.ts +0 -1
- package/src/TimePicker/TimePicker.tsx +0 -24
- package/src/TimePicker/index.ts +0 -1
- package/src/index.ts +0 -16
- package/src/story/Deserialization.example.tsx +0 -34
- package/src/story/FormSpy.example.tsx +0 -42
- package/src/story/index.jsx +0 -37
- package/src/utils/flat-map.ts +0 -4
- package/src/utils/index.ts +0 -3
- package/src/utils/scroll-to-error-decorator.ts +0 -78
- package/src/utils/validators.ts +0 -18
- package/tsconfig.build.json +0 -7
|
@@ -1,15 +0,0 @@
|
|
|
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
|
|
@@ -1,32 +0,0 @@
|
|
|
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')
|
package/src/Switch/Switch.tsx
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
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
|
package/src/Switch/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from './Switch'
|
|
@@ -1,25 +0,0 @@
|
|
|
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
|
package/src/TagSelector/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from './TagSelector'
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import {
|
|
3
|
-
TimePicker as PicassoTimePicker,
|
|
4
|
-
TimePickerProps
|
|
5
|
-
} from '@toptal/picasso'
|
|
6
|
-
|
|
7
|
-
import FieldWrapper, { FieldProps } from '../FieldWrapper'
|
|
8
|
-
|
|
9
|
-
export type FormTimePickerProps = Omit<TimePickerProps, 'onChange'> & {
|
|
10
|
-
onChange?: TimePickerProps['onChange']
|
|
11
|
-
}
|
|
12
|
-
export type Props = FormTimePickerProps & FieldProps<TimePickerProps['value']>
|
|
13
|
-
|
|
14
|
-
export const TimePicker = (props: Props) => (
|
|
15
|
-
<FieldWrapper<FormTimePickerProps> {...props}>
|
|
16
|
-
{(inputProps: TimePickerProps) => {
|
|
17
|
-
return <PicassoTimePicker {...inputProps} />
|
|
18
|
-
}}
|
|
19
|
-
</FieldWrapper>
|
|
20
|
-
)
|
|
21
|
-
|
|
22
|
-
TimePicker.displayName = 'TimePicker'
|
|
23
|
-
|
|
24
|
-
export default TimePicker
|
package/src/TimePicker/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from './TimePicker'
|
package/src/index.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
// Final Form exports
|
|
3
|
-
export type { FormApi, MutableState, AnyObject, FieldValidator, SubmissionErrors, Config } from 'final-form'
|
|
4
|
-
export { FORM_ERROR, setIn } from 'final-form'
|
|
5
|
-
export { useForm, useField, useFormState, FormSpy, Form as FinalForm, Field as FinalField } from 'react-final-form'
|
|
6
|
-
export type { FieldMetaState, FieldRenderProps, FormRenderProps, FieldProps, FormProps, FieldInputProps } from 'react-final-form'
|
|
7
|
-
export { default as arrayMutators } from 'final-form-arrays'
|
|
8
|
-
export { useFieldArray, FieldArray } from 'react-final-form-arrays'
|
|
9
|
-
export type { FieldArrayProps, FieldArrayRenderProps } from 'react-final-form-arrays'
|
|
10
|
-
export { OnChange, OnFocus, ExternallyChanged, OnBlur } from 'react-final-form-listeners'
|
|
11
|
-
|
|
12
|
-
// Picasso Forms exports
|
|
13
|
-
export { default as Form } from './Form'
|
|
14
|
-
export { default as FieldWrapper } from './FieldWrapper'
|
|
15
|
-
export type { FormConfigProps, RequiredVariant } from './FormConfig'
|
|
16
|
-
// hygen code generator inserts export statements above this comment.
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import { Container } from '@toptal/picasso'
|
|
3
|
-
import { Form } from '@toptal/picasso-forms'
|
|
4
|
-
|
|
5
|
-
const deserializeValue = <T extends unknown>(value: T) => {
|
|
6
|
-
if (value === 'true') {
|
|
7
|
-
return true
|
|
8
|
-
}
|
|
9
|
-
if (value === 'false') {
|
|
10
|
-
return false
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
return value
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const Example = () => (
|
|
17
|
-
<Form
|
|
18
|
-
onSubmit={values => {
|
|
19
|
-
console.log('Raw: ', { foo: values.foo })
|
|
20
|
-
console.log('Deserialized: ', { foo: deserializeValue(values.foo) })
|
|
21
|
-
}}
|
|
22
|
-
initialValues={{ foo: 'true' }}
|
|
23
|
-
>
|
|
24
|
-
<Form.RadioGroup name='foo' label='Foo'>
|
|
25
|
-
<Form.Radio label='yes' value='true' />
|
|
26
|
-
<Form.Radio label='no' value='false' />
|
|
27
|
-
</Form.RadioGroup>
|
|
28
|
-
<Container top='small'>
|
|
29
|
-
<Form.SubmitButton>Submit</Form.SubmitButton>
|
|
30
|
-
</Container>
|
|
31
|
-
</Form>
|
|
32
|
-
)
|
|
33
|
-
|
|
34
|
-
export default Example
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import { Container } from '@toptal/picasso'
|
|
3
|
-
import { Form, FormSpy } from '@toptal/picasso-forms'
|
|
4
|
-
|
|
5
|
-
const Example = () => (
|
|
6
|
-
<Form onSubmit={values => window.alert(values)}>
|
|
7
|
-
<Form.Input
|
|
8
|
-
required
|
|
9
|
-
name='firstName'
|
|
10
|
-
label='First name'
|
|
11
|
-
placeholder='e.g. Bruce'
|
|
12
|
-
/>
|
|
13
|
-
|
|
14
|
-
<FormSpy>
|
|
15
|
-
{({ values }) => (
|
|
16
|
-
<Form.Input
|
|
17
|
-
required
|
|
18
|
-
name='lastName'
|
|
19
|
-
disabled={!values?.firstName}
|
|
20
|
-
label='Last name'
|
|
21
|
-
placeholder='Disabled until first name is filled out'
|
|
22
|
-
/>
|
|
23
|
-
)}
|
|
24
|
-
</FormSpy>
|
|
25
|
-
|
|
26
|
-
<Container top='small'>
|
|
27
|
-
<FormSpy>
|
|
28
|
-
{({ pristine, values }) => {
|
|
29
|
-
const isDisabled = pristine || !values?.lastName
|
|
30
|
-
|
|
31
|
-
return (
|
|
32
|
-
<Form.SubmitButton disabled={isDisabled}>
|
|
33
|
-
{isDisabled ? 'Fill out form to enable' : 'Submit'}
|
|
34
|
-
</Form.SubmitButton>
|
|
35
|
-
)
|
|
36
|
-
}}
|
|
37
|
-
</FormSpy>
|
|
38
|
-
</Container>
|
|
39
|
-
</Form>
|
|
40
|
-
)
|
|
41
|
-
|
|
42
|
-
export default Example
|
package/src/story/index.jsx
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { doc } from 'storybook-readme'
|
|
2
|
-
|
|
3
|
-
import PicassoBook from '~/.storybook/components/PicassoBook'
|
|
4
|
-
import README from '../../README.md'
|
|
5
|
-
import CHANGELOG from '../../CHANGELOG.md'
|
|
6
|
-
|
|
7
|
-
const section = PicassoBook.section('Picasso Forms')
|
|
8
|
-
|
|
9
|
-
section.createDocPage('README', doc(README), { alwaysOnTop: true })
|
|
10
|
-
section.createDocPage('CHANGELOG', doc(CHANGELOG), { alwaysOnTop: true })
|
|
11
|
-
|
|
12
|
-
const page = section.createPage('Final Form', 'Final Form')
|
|
13
|
-
|
|
14
|
-
page
|
|
15
|
-
.createChapter()
|
|
16
|
-
.addExample(
|
|
17
|
-
'story/FormSpy.example.tsx',
|
|
18
|
-
{
|
|
19
|
-
title: 'Form Spy',
|
|
20
|
-
description: `
|
|
21
|
-
Sometimes you might want to perform a conditional action based on the value of another field in the form or its overall state.
|
|
22
|
-
For smaller forms, you can just directly work with values, but with a larger form you can avoid prop drilling with FormSpy.`
|
|
23
|
-
},
|
|
24
|
-
'picasso-form'
|
|
25
|
-
) // picasso-skip-visuals
|
|
26
|
-
.addExample(
|
|
27
|
-
'story/Deserialization.example.tsx',
|
|
28
|
-
{
|
|
29
|
-
title: 'Deserialization',
|
|
30
|
-
description: `
|
|
31
|
-
By default final-form converts all values to strings.
|
|
32
|
-
If want to pass a boolean or a number value to a field,
|
|
33
|
-
you should pass it serialized and deserialize it later.
|
|
34
|
-
`
|
|
35
|
-
},
|
|
36
|
-
'picasso-form'
|
|
37
|
-
) // picasso-skip-visuals
|
package/src/utils/flat-map.ts
DELETED
package/src/utils/index.ts
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { FormApi } from 'final-form'
|
|
2
|
-
|
|
3
|
-
const UNHIDDEN_INPUT_SELECTOR = 'input:not([type=hidden])'
|
|
4
|
-
|
|
5
|
-
const getErrorField = () =>
|
|
6
|
-
document.querySelector<HTMLElement>('[data-field-has-error="true"]')
|
|
7
|
-
|
|
8
|
-
const getErrorFieldAfterNextPaint = () =>
|
|
9
|
-
new Promise<HTMLElement | null>(resolve => {
|
|
10
|
-
const resolveField = () => resolve(getErrorField())
|
|
11
|
-
|
|
12
|
-
if (typeof requestAnimationFrame === 'undefined') {
|
|
13
|
-
setTimeout(resolveField, 16)
|
|
14
|
-
} else {
|
|
15
|
-
requestAnimationFrame(resolveField)
|
|
16
|
-
}
|
|
17
|
-
})
|
|
18
|
-
|
|
19
|
-
const getErrorFieldWithRetries = async () => {
|
|
20
|
-
for (let index = 0; index < 3; index++) {
|
|
21
|
-
const field = await getErrorFieldAfterNextPaint()
|
|
22
|
-
|
|
23
|
-
if (field) {
|
|
24
|
-
return field
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const scrollTo = (field: HTMLElement) => {
|
|
30
|
-
field.scrollIntoView({ block: 'center', behavior: 'smooth' })
|
|
31
|
-
field
|
|
32
|
-
.querySelector<HTMLInputElement>(UNHIDDEN_INPUT_SELECTOR)
|
|
33
|
-
?.focus({ preventScroll: true })
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
let state: { errors?: object; submitErrors?: object } = {}
|
|
37
|
-
|
|
38
|
-
export default () => <T>(form: FormApi<T>) => {
|
|
39
|
-
const originalSubmit = form.submit
|
|
40
|
-
|
|
41
|
-
const unsubscribe = form.subscribe(
|
|
42
|
-
nextState => {
|
|
43
|
-
state = nextState
|
|
44
|
-
},
|
|
45
|
-
{ errors: true, submitErrors: true }
|
|
46
|
-
)
|
|
47
|
-
|
|
48
|
-
const scrollOnErrors = async () => {
|
|
49
|
-
const { errors = {}, submitErrors = {} } = state
|
|
50
|
-
|
|
51
|
-
if (Object.keys(errors).length || Object.keys(submitErrors).length) {
|
|
52
|
-
const field = await getErrorFieldWithRetries()
|
|
53
|
-
|
|
54
|
-
if (field) {
|
|
55
|
-
scrollTo(field)
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// Rewrite submit function
|
|
61
|
-
form.submit = () => {
|
|
62
|
-
const result = originalSubmit.call(form)
|
|
63
|
-
|
|
64
|
-
if (result && typeof result.then === 'function') {
|
|
65
|
-
result.then(scrollOnErrors).catch(() => {})
|
|
66
|
-
} else {
|
|
67
|
-
scrollOnErrors()
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
return result
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
return () => {
|
|
74
|
-
state = {}
|
|
75
|
-
unsubscribe()
|
|
76
|
-
form.submit = originalSubmit
|
|
77
|
-
}
|
|
78
|
-
}
|
package/src/utils/validators.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
const composeValidators = (validators: any[]) => (value: any, allValues: any) =>
|
|
2
|
-
validators
|
|
3
|
-
.filter(Boolean)
|
|
4
|
-
.reduce(
|
|
5
|
-
(error, validator) => error || validator(value, allValues),
|
|
6
|
-
undefined
|
|
7
|
-
)
|
|
8
|
-
|
|
9
|
-
const required = (value: unknown) =>
|
|
10
|
-
value === undefined ||
|
|
11
|
-
value === false ||
|
|
12
|
-
value === '' ||
|
|
13
|
-
value === null ||
|
|
14
|
-
(Array.isArray(value) && value.length === 0)
|
|
15
|
-
? 'Please complete this field.'
|
|
16
|
-
: undefined
|
|
17
|
-
|
|
18
|
-
export default { composeValidators, required }
|