-
-
Notifications
You must be signed in to change notification settings - Fork 376
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
Calendar - Advanced Customization / Month & Year Selects #1713
Comments
Also i found out that the state is not being preserved in the current version of code in the docs Right now the docs for month and day select have this: (...)
<Calendar.GridBody>
{#each month.weeks as weekDates}
<Calendar.GridRow class="mt-2 w-full">
{#each weekDates as date}
<Calendar.Cell {date} month={month.value}>
<Calendar.Day />
</Calendar.Cell>
{/each}
</Calendar.GridRow>
{/each}
</Calendar.GridBody>
(...) brave_Kuexi5LfzT.mp4It's a custom element but i pretty much copied the whole thing from the docs and just changed the locale + added My fix: (...)
<Calendar.GridBody>
{#each month.weeks as weekDates}
<Calendar.GridRow class="mt-2 w-full">
{#each weekDates as date}
<Calendar.Cell {date} month={month.value}>
{#if date.day === placeholder.day}
<Calendar.Day data-selected />
{:else}
<Calendar.Day />
{/if}
</Calendar.Cell>
{/each}
</Calendar.GridRow>
{/each}
</Calendar.GridBody>
(...) |
It's meant to be saved as a component and then you use it like this: <MyCustomCalendar type="single" />
<MyCustomCalendar type="multiple" /> when you hard code it into the component you cannot do the above. |
Yea i guess that makes sense, but due to how the docs have ...restParams the compiler does not error out when the <script lang="ts">
let {
value = $bindable(),
placeholder = $bindable(),
weekdayFormat,
class: className,
...restProps
}: WithoutChildrenOrChild<CalendarRootProps> = $props();
</script>
<!-- no error-->
<MyCustomCalendar /> <script lang="ts">
let {
value = $bindable(),
placeholder = $bindable(),
weekdayFormat,
class: className,
type, // added
...restProps
}: WithoutChildrenOrChild<CalendarRootProps> = $props();
</script>
<!-- errors out that type is not specified-->
<MyCustomCalendar />
<!-- No error-->
<MyCustomCalendar type="single" /> |
From my testing it does error if The error also doesn't change:
The error is pretty unhelpful though, it would be nice if Svelte was able to improve this. |
Sorry, this is one of the annoyances with having to destructure all This is how we get around those errors in the |
Change Type
Correction
Proposed Changes
The Advanced Customization Section is missing the
type=""
attribute inside the documentation.I copied the whole component with month and year options and couldn't figure out why it wasn't working since there are no errors when type is not specifies when restProps are spread
brave_x4AnjNC6oP.mp4
Browser: Brave
The text was updated successfully, but these errors were encountered: