-
-
Notifications
You must be signed in to change notification settings - Fork 130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DateRangeField usage in forms #234
Comments
Thanks for reporting @ochrstn , i don't seem to have access to the code sandbox. |
Sorry, sandbox should be public now. |
Thanks! I got another request for support of isInvalid and invalid styles, I'll investigate. Here is an example with DateInput that might be useful. import { forwardRef } from '@chakra-ui/react'
import {
DateInput,
DateInputProps,
DateValue,
parseDate,
} from '@saas-ui/date-picker'
import { createField } from '@saas-ui/forms'
interface DateFieldProps extends Omit<DateInputProps, 'value' | 'onChange'> {
value?: string
onChange?: (value: string) => void
}
const DateField = createField(
forwardRef<DateFieldProps, 'input'>((props, ref) => {
const { value: valueProp, onChange: onChangeProp, ...rest } = props
const value =
typeof valueProp === 'string' && valueProp !== ''
? parseDate(valueProp)
: valueProp === ''
? undefined
: valueProp
const onChange = (value: DateValue | null) => {
onChangeProp?.(value?.toString() || '')
}
return <DateInput ref={ref} value={value} onChange={onChange} {...rest} />
}),
{
isControlled: true,
},
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description
The usage of the DateRangeField inside of a form should be as easy and feature complete as any of the other build-in fields
This includes showing the error border highlighting on the field in addition to the validation message and also respecting props like
isDisabled
.Link to Reproduction
https://codesandbox.io/p/sandbox/ecstatic-feistel-v7rt4g
Steps to reproduce
No response
Saas UI Version
2.8.3
Chakra UI Version
No response
Browser
No response
Operating System
Additional Information
No response
The text was updated successfully, but these errors were encountered: