-
Say I have a basic custom DatePicker component as follows <script lang="ts">
import { DatePicker } from 'bits-ui';
export let value;
export let min;
export let max;
</script>
<DatePicker.Root bind:value={value} minValue={min} maxValue={max}>
... What should I type these props as? I've tried |
Beta Was this translation helpful? Give feedback.
Answered by
Spaxterr
Mar 19, 2024
Replies: 1 comment
-
I ended up solving it using <script lang="ts">
import { DatePicker } from 'bits-ui';
import { type CalendarDate, parseDate } from '@internationalized/date';
export let value: string | undefined = undefined;
export let min: string | undefined = undefined;
export let max: string | undefined = undefined;
let minDate: CalendarDate | undefined = undefined;
let maxDate: CalendarDate | undefined = undefined;
let dateValue: CalendarDate | undefined = value ? parseDate(value) : undefined;
$: if (min) minDate = parseDate(min);
$: if (max) maxDate = parseDate(max);
</script>
<DatePicker.Root bind:value={dateValue} minValue={minDate} maxValue={maxDate}> |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
Spaxterr
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I ended up solving it using
parseDate
from@internationalized/date
, but I'm open to suggestions if there are other recommended methods